#
# spec file for package element-web
#
# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


Name:           element-web
Version:        1.11.95
Release:        1%{?dist}
Summary:        A glossy Matrix collaboration client - web files
License:        AGPL-3.0-only or GPL-3.0-only
Group:          Productivity/Networking/Talk/Clients
URL:            https://github.com/element-hq/element-web
Source0:        https://github.com/element-hq/element-web/archive/v%{version}/element-web-%{version}.tar.gz
Source1:        npm-packages-offline-cache.tar.gz
Source3:        prepare.sh
Patch0:         fix-webpack-oom.patch
BuildRequires:  fdupes
BuildRequires:  nodejs
BuildRequires:  yarnpkg
BuildRequires:  rust-packaging
BuildRequires:  cargo
BuildArch:      noarch

%description
A glossy Matrix collaboration client - web files

%prep
%autosetup -n element-web-%{version} -a1 -p1

%build
echo 'yarn-offline-mirror "./npm-packages-offline-cache"' > .yarnrc
ls -l ./npm-packages-offline-cache | head

# fix some strange dependency
#cp npm-packages-offline-cache/matrix-analytics-events-0.0.1.tgz \
#   npm-packages-offline-cache/@matrix-analytics-events-0.0.1.tgz
#ls -l ./npm-packages-offline-cache/*matrix-analytics-events*

#sed -i -e 's|    matrix-analytics-events "github:matrix-org/matrix-analytics-events.git#[^"]*"|    matrix-analytics-events "^0.0.1"|' yarn.lock
#sed -i -e 's|"matrix-analytics-events@github:matrix-org/matrix-analytics-events#[^"]*"|matrix-analytics-events@^0.0.1|' yarn.lock

export SENTRYCLI_SKIP_DOWNLOAD=1
yarn install --offline --pure-lockfile

DIST_VERSION=%{version} ./scripts/package.sh

pushd dist || exit 1
tar xf element-%{version}.tar.gz
popd
cp LICENSE* dist/element-%{version}/

%install
install -d -m 0755 %{buildroot}%{_datadir}/element/webapp

cp -av dist/element-%{version}/* %{buildroot}%{_datadir}/element/webapp/

install -d -m 0755 %{buildroot}%{_datadir}/icons/hicolor/scalable/apps/
install -m 0644 res/themes/element/img/logos/element-logo.svg %{buildroot}%{_datadir}/icons/hicolor/scalable/apps/io.element.Element.svg

%fdupes %{buildroot}%{_datadir}/webapps/element/

%files
%license LICENSE-AGPL-3.0 LICENSE-GPL-3.0
%{_datadir}/element/webapp
%{_datadir}/icons/hicolor/scalable/apps/io.element.Element.svg

%changelog
* Sat Mar 15 2025 Sérgio Basto <sergio@serjux.com> - 1.11.95-1
- Update to 1.11.95

* Mon Mar 03 2025 Sérgio Basto <sergio@serjux.com> - 1.11.94-1
- Update to 1.11.94

* Sun Jan 26 2025 Sérgio Basto <sergio@serjux.com> - 1.11.90-1
- Update to 1.11.90

* Fri Dec 27 2024 Sérgio Basto <sergio@serjux.com> - 1.11.89-1
- Update to 1.11.89

* Wed Sep 11 2024 Sérgio Basto <sergio@serjux.com> - 1.11.76-1
- Update to 1.11.76

* Tue Jun 25 2024 Sérgio Basto <sergio@serjux.com> - 1.11.69-1
- 1.11.69

* Thu May 30 2024 Sérgio Basto <sergio@serjux.com> - 1.11.67-2
- rebuilt

* Sun May 26 2024 Sérgio Basto <sergio@serjux.com> - 1.11.67-1
- 1.11.67

* Sun Mar 24 2024 Sérgio Basto <sergio@serjux.com> - 1.11.61-1
- 1.11.61

* Wed Feb 21 2024 Sérgio Basto <sergio@serjux.com> - 1.11.58-3
- update

* Sun Feb 18 2024 Sérgio Basto <sergio@serjux.com> - 1.11.58-2
- 1.11.58