From d674052aa39f561cd198a842658dd40a3d203c83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20=F0=9F=8E=83=20Khripkov?= Date: Thu, 19 Dec 2024 18:43:39 +0300 Subject: [PATCH 1/8] feat: add side-effects; --- .changeset/nervous-ants-learn.md | 33 ++++++++++++++++++++++ bin/build.sh | 2 +- packages/base-modal/package.json | 4 ++- packages/drawer/package.json | 1 + packages/form-control/package.json | 1 + packages/notification-manager/package.json | 1 + packages/notification/package.json | 1 + packages/number-input/package.json | 1 + packages/pagination/package.json | 1 + packages/pass-code-v1/package.json | 1 + packages/pass-code/package.json | 1 + packages/password-input/package.json | 1 + packages/pattern-lock-v1/package.json | 1 + packages/pattern-lock/package.json | 1 + packages/popover/package.json | 1 + packages/popup-sheet/package.json | 1 + packages/portal/package.json | 1 + packages/product-cover/package.json | 1 + packages/pure-cell/package.json | 1 + packages/radio-group/package.json | 1 + packages/radio/package.json | 1 + packages/segmented-control/package.json | 1 + packages/shared/package.json | 1 + packages/skeleton/package.json | 1 + packages/slider-input/package.json | 1 + packages/status-badge/package.json | 1 + packages/stepped-progress-bar/package.json | 1 + packages/switch/package.json | 1 + packages/system-message/package.json | 1 + packages/time-input/package.json | 1 + packages/with-suffix/package.json | 1 + 31 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 .changeset/nervous-ants-learn.md diff --git a/.changeset/nervous-ants-learn.md b/.changeset/nervous-ants-learn.md new file mode 100644 index 0000000000..14795869f3 --- /dev/null +++ b/.changeset/nervous-ants-learn.md @@ -0,0 +1,33 @@ +--- +'@alfalab/core-components-drawer': patch +'@alfalab/core-components-form-control': patch +'@alfalab/core-components-notification': patch +'@alfalab/core-components-notification-manager': patch +'@alfalab/core-components-number-input': patch +'@alfalab/core-components-pagination': patch +'@alfalab/core-components-pass-code': patch +'@alfalab/core-components-pass-code-v1': patch +'@alfalab/core-components-password-input': patch +'@alfalab/core-components-pattern-lock': patch +'@alfalab/core-components-pattern-lock-v1': patch +'@alfalab/core-components-popover': patch +'@alfalab/core-components-popup-sheet': patch +'@alfalab/core-components-portal': patch +'@alfalab/core-components-product-cover': patch +'@alfalab/core-components-pure-cell': patch +'@alfalab/core-components-radio': patch +'@alfalab/core-components-radio-group': patch +'@alfalab/core-components-segmented-control': patch +'@alfalab/core-components-shared': patch +'@alfalab/core-components-skeleton': patch +'@alfalab/core-components-slider-input': patch +'@alfalab/core-components-status-badge': patch +'@alfalab/core-components-stepped-progress-bar': patch +'@alfalab/core-components-switch': patch +'@alfalab/core-components-system-message': patch +'@alfalab/core-components-time-input': patch +'@alfalab/core-components-with-suffix': patch +--- + +- Добавлено "sideEffects": false, чтобы бандлер лучше делал тришейк. +- В SideEffect пакета base-modal добавлена зависимость от полифила. diff --git a/bin/build.sh b/bin/build.sh index 05c0159095..dfd2e40d64 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -26,7 +26,7 @@ lerna exec --scope @alfalab/core-components-themes -- node $(pwd)/bin/build-them lerna exec --scope @alfalab/core-components-vars -- node $(pwd)/bin/export-css-custom-properties-as-js-vars.js # собираю все подпакеты с компонентами -lerna exec --concurrency $CONCURRENCY \ +lerna exec --scope @alfalab/core-components-base-modal \ --ignore @alfalab/core-components-codemod \ -- $(pwd)/bin/rollup.sh diff --git a/packages/base-modal/package.json b/packages/base-modal/package.json index b1c6d7c9bf..634e2e12d3 100644 --- a/packages/base-modal/package.json +++ b/packages/base-modal/package.json @@ -10,7 +10,9 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, + "sideEffects": [ + "matches-polyfill.*" + ], "dependencies": { "@alfalab/core-components-backdrop": "^3.4.3", "@alfalab/core-components-global-store": "^2.1.0", diff --git a/packages/drawer/package.json b/packages/drawer/package.json index 94a5de42f0..9046ac14e5 100644 --- a/packages/drawer/package.json +++ b/packages/drawer/package.json @@ -10,6 +10,7 @@ "access": "public", "directory": "dist" }, + "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/form-control/package.json b/packages/form-control/package.json index 14de9999fd..0f8c289b7a 100644 --- a/packages/form-control/package.json +++ b/packages/form-control/package.json @@ -10,6 +10,7 @@ "access": "public", "directory": "dist" }, + "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/notification-manager/package.json b/packages/notification-manager/package.json index 0a3a4f4153..29b3b2f203 100644 --- a/packages/notification-manager/package.json +++ b/packages/notification-manager/package.json @@ -10,6 +10,7 @@ "access": "public", "directory": "dist" }, + "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0" }, diff --git a/packages/notification/package.json b/packages/notification/package.json index 4e44e40541..75029dc83f 100644 --- a/packages/notification/package.json +++ b/packages/notification/package.json @@ -10,6 +10,7 @@ "access": "public", "directory": "dist" }, + "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0" }, diff --git a/packages/number-input/package.json b/packages/number-input/package.json index 7d99bafd19..77eea639fa 100644 --- a/packages/number-input/package.json +++ b/packages/number-input/package.json @@ -10,6 +10,7 @@ "access": "public", "directory": "dist" }, + "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0" }, diff --git a/packages/pagination/package.json b/packages/pagination/package.json index 25706f03dd..a94f0bea9a 100644 --- a/packages/pagination/package.json +++ b/packages/pagination/package.json @@ -10,6 +10,7 @@ "access": "public", "directory": "dist" }, + "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/pass-code-v1/package.json b/packages/pass-code-v1/package.json index 0b67f2a0c3..a2ca60babb 100644 --- a/packages/pass-code-v1/package.json +++ b/packages/pass-code-v1/package.json @@ -10,6 +10,7 @@ "access": "public", "directory": "dist" }, + "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/pass-code/package.json b/packages/pass-code/package.json index 334dbec0b3..5dad207e06 100644 --- a/packages/pass-code/package.json +++ b/packages/pass-code/package.json @@ -10,6 +10,7 @@ "access": "public", "directory": "dist" }, + "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/password-input/package.json b/packages/password-input/package.json index 7f974f8925..668cabfbad 100644 --- a/packages/password-input/package.json +++ b/packages/password-input/package.json @@ -10,6 +10,7 @@ "access": "public", "directory": "dist" }, + "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/pattern-lock-v1/package.json b/packages/pattern-lock-v1/package.json index 4f9c61fda1..b770b9dfea 100644 --- a/packages/pattern-lock-v1/package.json +++ b/packages/pattern-lock-v1/package.json @@ -10,6 +10,7 @@ "access": "public", "directory": "dist" }, + "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/pattern-lock/package.json b/packages/pattern-lock/package.json index fe5f7fed77..5390ca392e 100644 --- a/packages/pattern-lock/package.json +++ b/packages/pattern-lock/package.json @@ -10,6 +10,7 @@ "access": "public", "directory": "dist" }, + "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/popover/package.json b/packages/popover/package.json index b9c169e3c4..c45f68e92b 100644 --- a/packages/popover/package.json +++ b/packages/popover/package.json @@ -10,6 +10,7 @@ "access": "public", "directory": "dist" }, + "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/popup-sheet/package.json b/packages/popup-sheet/package.json index c8519a40a8..f3c8e6646a 100644 --- a/packages/popup-sheet/package.json +++ b/packages/popup-sheet/package.json @@ -10,6 +10,7 @@ "access": "public", "directory": "dist" }, + "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/portal/package.json b/packages/portal/package.json index 75e43c1c04..9069bdc518 100644 --- a/packages/portal/package.json +++ b/packages/portal/package.json @@ -10,6 +10,7 @@ "access": "public", "directory": "dist" }, + "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/product-cover/package.json b/packages/product-cover/package.json index 8fcdb0bc53..db33b9fece 100644 --- a/packages/product-cover/package.json +++ b/packages/product-cover/package.json @@ -10,6 +10,7 @@ "access": "public", "directory": "dist" }, + "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/pure-cell/package.json b/packages/pure-cell/package.json index d30b26e13e..8067dce96f 100644 --- a/packages/pure-cell/package.json +++ b/packages/pure-cell/package.json @@ -10,6 +10,7 @@ "access": "public", "directory": "dist" }, + "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/radio-group/package.json b/packages/radio-group/package.json index efeeccfb2e..1715157ecd 100644 --- a/packages/radio-group/package.json +++ b/packages/radio-group/package.json @@ -10,6 +10,7 @@ "access": "public", "directory": "dist" }, + "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/radio/package.json b/packages/radio/package.json index 8696655b42..88508233f0 100644 --- a/packages/radio/package.json +++ b/packages/radio/package.json @@ -10,6 +10,7 @@ "access": "public", "directory": "dist" }, + "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/segmented-control/package.json b/packages/segmented-control/package.json index f1f8872b9c..e59ab0f4d0 100644 --- a/packages/segmented-control/package.json +++ b/packages/segmented-control/package.json @@ -10,6 +10,7 @@ "access": "public", "directory": "dist" }, + "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/shared/package.json b/packages/shared/package.json index fbd2d7cd3a..9b50ea9b19 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -10,6 +10,7 @@ "access": "public", "directory": "dist" }, + "sideEffects": false, "peerDependencies": { "react": ">=16.8.0" }, diff --git a/packages/skeleton/package.json b/packages/skeleton/package.json index 6e29f5d997..56dec35373 100644 --- a/packages/skeleton/package.json +++ b/packages/skeleton/package.json @@ -10,6 +10,7 @@ "access": "public", "directory": "dist" }, + "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/slider-input/package.json b/packages/slider-input/package.json index 2469d15d48..1293cd8f3a 100644 --- a/packages/slider-input/package.json +++ b/packages/slider-input/package.json @@ -10,6 +10,7 @@ "access": "public", "directory": "dist" }, + "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/status-badge/package.json b/packages/status-badge/package.json index 2d89b06965..a1efc9d016 100644 --- a/packages/status-badge/package.json +++ b/packages/status-badge/package.json @@ -10,6 +10,7 @@ "access": "public", "directory": "dist" }, + "sideEffects": false, "peerDependencies": { "react": ">=16.8.0" }, diff --git a/packages/stepped-progress-bar/package.json b/packages/stepped-progress-bar/package.json index 1677d534da..e2f5a0694d 100644 --- a/packages/stepped-progress-bar/package.json +++ b/packages/stepped-progress-bar/package.json @@ -10,6 +10,7 @@ "access": "public", "directory": "dist" }, + "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0" }, diff --git a/packages/switch/package.json b/packages/switch/package.json index 8600288461..54a70ae015 100644 --- a/packages/switch/package.json +++ b/packages/switch/package.json @@ -11,6 +11,7 @@ "access": "public", "directory": "dist" }, + "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0" }, diff --git a/packages/system-message/package.json b/packages/system-message/package.json index 7d9313900b..4608ab866c 100644 --- a/packages/system-message/package.json +++ b/packages/system-message/package.json @@ -10,6 +10,7 @@ "access": "public", "directory": "dist" }, + "sideEffects": false, "peerDependencies": { "react": ">=16.8.0" }, diff --git a/packages/time-input/package.json b/packages/time-input/package.json index 36dbafc852..710b699681 100644 --- a/packages/time-input/package.json +++ b/packages/time-input/package.json @@ -10,6 +10,7 @@ "access": "public", "directory": "dist" }, + "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/with-suffix/package.json b/packages/with-suffix/package.json index c47c13cbde..471688c5ef 100644 --- a/packages/with-suffix/package.json +++ b/packages/with-suffix/package.json @@ -10,6 +10,7 @@ "access": "public", "directory": "dist" }, + "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0" }, From cedb18481c0c518bb4a4c97d4042f13fc674747b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20=F0=9F=8E=83=20Khripkov?= Date: Thu, 19 Dec 2024 18:47:30 +0300 Subject: [PATCH 2/8] fix: rollback build; --- bin/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/build.sh b/bin/build.sh index dfd2e40d64..05c0159095 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -26,7 +26,7 @@ lerna exec --scope @alfalab/core-components-themes -- node $(pwd)/bin/build-them lerna exec --scope @alfalab/core-components-vars -- node $(pwd)/bin/export-css-custom-properties-as-js-vars.js # собираю все подпакеты с компонентами -lerna exec --scope @alfalab/core-components-base-modal \ +lerna exec --concurrency $CONCURRENCY \ --ignore @alfalab/core-components-codemod \ -- $(pwd)/bin/rollup.sh From e875c318d6ab96bbd1a6801b4f86e317905cbbf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20=F0=9F=8E=83=20Khripkov?= Date: Fri, 20 Dec 2024 10:13:09 +0300 Subject: [PATCH 3/8] feat(galary): hls light; --- .changeset/nervous-ants-learn.md | 33 ------------------- .changeset/strange-coats-exercise.md | 5 +++ packages/base-modal/package.json | 4 +-- packages/drawer/package.json | 1 - packages/form-control/package.json | 1 - .../components/image-viewer/video/index.tsx | 8 +++-- packages/notification-manager/package.json | 1 - packages/notification/package.json | 1 - packages/number-input/package.json | 1 - packages/pagination/package.json | 1 - packages/pass-code-v1/package.json | 1 - packages/pass-code/package.json | 1 - packages/password-input/package.json | 1 - packages/pattern-lock-v1/package.json | 1 - packages/pattern-lock/package.json | 1 - packages/popover/package.json | 1 - packages/popup-sheet/package.json | 1 - packages/portal/package.json | 1 - packages/product-cover/package.json | 1 - packages/pure-cell/package.json | 1 - packages/radio-group/package.json | 1 - packages/radio/package.json | 1 - packages/segmented-control/package.json | 1 - packages/shared/package.json | 1 - packages/skeleton/package.json | 1 - packages/slider-input/package.json | 1 - packages/status-badge/package.json | 1 - packages/stepped-progress-bar/package.json | 1 - packages/switch/package.json | 1 - packages/system-message/package.json | 1 - packages/time-input/package.json | 1 - packages/with-suffix/package.json | 1 - 32 files changed, 11 insertions(+), 67 deletions(-) delete mode 100644 .changeset/nervous-ants-learn.md create mode 100644 .changeset/strange-coats-exercise.md diff --git a/.changeset/nervous-ants-learn.md b/.changeset/nervous-ants-learn.md deleted file mode 100644 index 14795869f3..0000000000 --- a/.changeset/nervous-ants-learn.md +++ /dev/null @@ -1,33 +0,0 @@ ---- -'@alfalab/core-components-drawer': patch -'@alfalab/core-components-form-control': patch -'@alfalab/core-components-notification': patch -'@alfalab/core-components-notification-manager': patch -'@alfalab/core-components-number-input': patch -'@alfalab/core-components-pagination': patch -'@alfalab/core-components-pass-code': patch -'@alfalab/core-components-pass-code-v1': patch -'@alfalab/core-components-password-input': patch -'@alfalab/core-components-pattern-lock': patch -'@alfalab/core-components-pattern-lock-v1': patch -'@alfalab/core-components-popover': patch -'@alfalab/core-components-popup-sheet': patch -'@alfalab/core-components-portal': patch -'@alfalab/core-components-product-cover': patch -'@alfalab/core-components-pure-cell': patch -'@alfalab/core-components-radio': patch -'@alfalab/core-components-radio-group': patch -'@alfalab/core-components-segmented-control': patch -'@alfalab/core-components-shared': patch -'@alfalab/core-components-skeleton': patch -'@alfalab/core-components-slider-input': patch -'@alfalab/core-components-status-badge': patch -'@alfalab/core-components-stepped-progress-bar': patch -'@alfalab/core-components-switch': patch -'@alfalab/core-components-system-message': patch -'@alfalab/core-components-time-input': patch -'@alfalab/core-components-with-suffix': patch ---- - -- Добавлено "sideEffects": false, чтобы бандлер лучше делал тришейк. -- В SideEffect пакета base-modal добавлена зависимость от полифила. diff --git a/.changeset/strange-coats-exercise.md b/.changeset/strange-coats-exercise.md new file mode 100644 index 0000000000..ae773f7fbd --- /dev/null +++ b/.changeset/strange-coats-exercise.md @@ -0,0 +1,5 @@ +--- +'@alfalab/core-components-gallery': patch +--- + +Импорт HLS заменён на light версию, только енкодер без дополнительных обвязок diff --git a/packages/base-modal/package.json b/packages/base-modal/package.json index 634e2e12d3..b1c6d7c9bf 100644 --- a/packages/base-modal/package.json +++ b/packages/base-modal/package.json @@ -10,9 +10,7 @@ "access": "public", "directory": "dist" }, - "sideEffects": [ - "matches-polyfill.*" - ], + "sideEffects": false, "dependencies": { "@alfalab/core-components-backdrop": "^3.4.3", "@alfalab/core-components-global-store": "^2.1.0", diff --git a/packages/drawer/package.json b/packages/drawer/package.json index 9046ac14e5..94a5de42f0 100644 --- a/packages/drawer/package.json +++ b/packages/drawer/package.json @@ -10,7 +10,6 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/form-control/package.json b/packages/form-control/package.json index 0f8c289b7a..14de9999fd 100644 --- a/packages/form-control/package.json +++ b/packages/form-control/package.json @@ -10,7 +10,6 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/gallery/src/components/image-viewer/video/index.tsx b/packages/gallery/src/components/image-viewer/video/index.tsx index eb4c9b9524..9abdd84881 100644 --- a/packages/gallery/src/components/image-viewer/video/index.tsx +++ b/packages/gallery/src/components/image-viewer/video/index.tsx @@ -1,6 +1,8 @@ import React, { MouseEvent, ReactEventHandler, useContext, useEffect, useRef } from 'react'; import cn from 'classnames'; -import Hls from 'hls.js'; +import type HlsType from 'hls.js'; +import type { ErrorData, Events } from 'hls.js'; +import Hls from 'hls.js/dist/hls.light.mjs'; import { Circle } from '@alfalab/core-components/icon-view/circle'; import PlayCompactMIcon from '@alfalab/icons-glyph/PlayCompactMIcon'; @@ -32,10 +34,10 @@ export const Video = ({ url, index, className, isActive }: Props) => { }, [index]); useEffect(() => { - const hls = new Hls(); + const hls = new Hls() as HlsType; if (Hls.isSupported()) { - hls.on(Hls.Events.ERROR, (_, data) => { + hls.on(Hls.Events.ERROR, (_: Events.ERROR, data: ErrorData) => { if (data.fatal) { switch (data.type) { case Hls.ErrorTypes.MEDIA_ERROR: diff --git a/packages/notification-manager/package.json b/packages/notification-manager/package.json index 29b3b2f203..0a3a4f4153 100644 --- a/packages/notification-manager/package.json +++ b/packages/notification-manager/package.json @@ -10,7 +10,6 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0" }, diff --git a/packages/notification/package.json b/packages/notification/package.json index 75029dc83f..4e44e40541 100644 --- a/packages/notification/package.json +++ b/packages/notification/package.json @@ -10,7 +10,6 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0" }, diff --git a/packages/number-input/package.json b/packages/number-input/package.json index 77eea639fa..7d99bafd19 100644 --- a/packages/number-input/package.json +++ b/packages/number-input/package.json @@ -10,7 +10,6 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0" }, diff --git a/packages/pagination/package.json b/packages/pagination/package.json index a94f0bea9a..25706f03dd 100644 --- a/packages/pagination/package.json +++ b/packages/pagination/package.json @@ -10,7 +10,6 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/pass-code-v1/package.json b/packages/pass-code-v1/package.json index a2ca60babb..0b67f2a0c3 100644 --- a/packages/pass-code-v1/package.json +++ b/packages/pass-code-v1/package.json @@ -10,7 +10,6 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/pass-code/package.json b/packages/pass-code/package.json index 5dad207e06..334dbec0b3 100644 --- a/packages/pass-code/package.json +++ b/packages/pass-code/package.json @@ -10,7 +10,6 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/password-input/package.json b/packages/password-input/package.json index 668cabfbad..7f974f8925 100644 --- a/packages/password-input/package.json +++ b/packages/password-input/package.json @@ -10,7 +10,6 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/pattern-lock-v1/package.json b/packages/pattern-lock-v1/package.json index b770b9dfea..4f9c61fda1 100644 --- a/packages/pattern-lock-v1/package.json +++ b/packages/pattern-lock-v1/package.json @@ -10,7 +10,6 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/pattern-lock/package.json b/packages/pattern-lock/package.json index 5390ca392e..fe5f7fed77 100644 --- a/packages/pattern-lock/package.json +++ b/packages/pattern-lock/package.json @@ -10,7 +10,6 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/popover/package.json b/packages/popover/package.json index c45f68e92b..b9c169e3c4 100644 --- a/packages/popover/package.json +++ b/packages/popover/package.json @@ -10,7 +10,6 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/popup-sheet/package.json b/packages/popup-sheet/package.json index f3c8e6646a..c8519a40a8 100644 --- a/packages/popup-sheet/package.json +++ b/packages/popup-sheet/package.json @@ -10,7 +10,6 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/portal/package.json b/packages/portal/package.json index 9069bdc518..75e43c1c04 100644 --- a/packages/portal/package.json +++ b/packages/portal/package.json @@ -10,7 +10,6 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/product-cover/package.json b/packages/product-cover/package.json index db33b9fece..8fcdb0bc53 100644 --- a/packages/product-cover/package.json +++ b/packages/product-cover/package.json @@ -10,7 +10,6 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/pure-cell/package.json b/packages/pure-cell/package.json index 8067dce96f..d30b26e13e 100644 --- a/packages/pure-cell/package.json +++ b/packages/pure-cell/package.json @@ -10,7 +10,6 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/radio-group/package.json b/packages/radio-group/package.json index 1715157ecd..efeeccfb2e 100644 --- a/packages/radio-group/package.json +++ b/packages/radio-group/package.json @@ -10,7 +10,6 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/radio/package.json b/packages/radio/package.json index 88508233f0..8696655b42 100644 --- a/packages/radio/package.json +++ b/packages/radio/package.json @@ -10,7 +10,6 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/segmented-control/package.json b/packages/segmented-control/package.json index e59ab0f4d0..f1f8872b9c 100644 --- a/packages/segmented-control/package.json +++ b/packages/segmented-control/package.json @@ -10,7 +10,6 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/shared/package.json b/packages/shared/package.json index 9b50ea9b19..fbd2d7cd3a 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -10,7 +10,6 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, "peerDependencies": { "react": ">=16.8.0" }, diff --git a/packages/skeleton/package.json b/packages/skeleton/package.json index 56dec35373..6e29f5d997 100644 --- a/packages/skeleton/package.json +++ b/packages/skeleton/package.json @@ -10,7 +10,6 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/slider-input/package.json b/packages/slider-input/package.json index 1293cd8f3a..2469d15d48 100644 --- a/packages/slider-input/package.json +++ b/packages/slider-input/package.json @@ -10,7 +10,6 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/status-badge/package.json b/packages/status-badge/package.json index a1efc9d016..2d89b06965 100644 --- a/packages/status-badge/package.json +++ b/packages/status-badge/package.json @@ -10,7 +10,6 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, "peerDependencies": { "react": ">=16.8.0" }, diff --git a/packages/stepped-progress-bar/package.json b/packages/stepped-progress-bar/package.json index e2f5a0694d..1677d534da 100644 --- a/packages/stepped-progress-bar/package.json +++ b/packages/stepped-progress-bar/package.json @@ -10,7 +10,6 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0" }, diff --git a/packages/switch/package.json b/packages/switch/package.json index 54a70ae015..8600288461 100644 --- a/packages/switch/package.json +++ b/packages/switch/package.json @@ -11,7 +11,6 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0" }, diff --git a/packages/system-message/package.json b/packages/system-message/package.json index 4608ab866c..7d9313900b 100644 --- a/packages/system-message/package.json +++ b/packages/system-message/package.json @@ -10,7 +10,6 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, "peerDependencies": { "react": ">=16.8.0" }, diff --git a/packages/time-input/package.json b/packages/time-input/package.json index 710b699681..36dbafc852 100644 --- a/packages/time-input/package.json +++ b/packages/time-input/package.json @@ -10,7 +10,6 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0" diff --git a/packages/with-suffix/package.json b/packages/with-suffix/package.json index 471688c5ef..c47c13cbde 100644 --- a/packages/with-suffix/package.json +++ b/packages/with-suffix/package.json @@ -10,7 +10,6 @@ "access": "public", "directory": "dist" }, - "sideEffects": false, "peerDependencies": { "react": "^16.9.0 || ^17.0.1 || ^18.0.0" }, From 521900b212bdefa21c069118d986e3c60250c2fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20=F0=9F=8E=83=20Khripkov?= Date: Fri, 20 Dec 2024 15:36:34 +0300 Subject: [PATCH 4/8] fix: code logic; --- .../components/image-viewer/video/index.tsx | 80 ++++++++++++------- packages/gallery/src/declaration.d.ts | 5 ++ 2 files changed, 54 insertions(+), 31 deletions(-) create mode 100644 packages/gallery/src/declaration.d.ts diff --git a/packages/gallery/src/components/image-viewer/video/index.tsx b/packages/gallery/src/components/image-viewer/video/index.tsx index 9abdd84881..1254653298 100644 --- a/packages/gallery/src/components/image-viewer/video/index.tsx +++ b/packages/gallery/src/components/image-viewer/video/index.tsx @@ -1,8 +1,14 @@ -import React, { MouseEvent, ReactEventHandler, useContext, useEffect, useRef } from 'react'; +import React, { + MouseEvent, + ReactEventHandler, + useContext, + useEffect, + useRef, + useState, +} from 'react'; import cn from 'classnames'; import type HlsType from 'hls.js'; import type { ErrorData, Events } from 'hls.js'; -import Hls from 'hls.js/dist/hls.light.mjs'; import { Circle } from '@alfalab/core-components/icon-view/circle'; import PlayCompactMIcon from '@alfalab/icons-glyph/PlayCompactMIcon'; @@ -22,6 +28,7 @@ type Props = { export const Video = ({ url, index, className, isActive }: Props) => { const playerRef = useRef(null); const timer = useRef>(); + const [HLSSupported, setHLSSupported] = useState(true); const { setImageMeta, mutedVideo, view, playingVideo, setPlayingVideo, setHideNavigation } = useContext(GalleryContext); @@ -34,39 +41,50 @@ export const Video = ({ url, index, className, isActive }: Props) => { }, [index]); useEffect(() => { - const hls = new Hls() as HlsType; - - if (Hls.isSupported()) { - hls.on(Hls.Events.ERROR, (_: Events.ERROR, data: ErrorData) => { - if (data.fatal) { - switch (data.type) { - case Hls.ErrorTypes.MEDIA_ERROR: - hls.recoverMediaError(); - break; - case Hls.ErrorTypes.NETWORK_ERROR: - setImageMeta({ player: { current: null }, broken: true }, index); - break; - default: - hls.destroy(); - break; + async function initHls() { + const { default: Hls } = await import( + /* webpackChunkName: "HLSVideo" */ 'hls.js/dist/hls.light.mjs' + ); + + const hls: HlsType = new Hls(); + + if (Hls.isSupported()) { + hls.on(Hls.Events.ERROR, (_: Events.ERROR, data: ErrorData) => { + if (data.fatal) { + switch (data.type) { + case Hls.ErrorTypes.MEDIA_ERROR: + hls.recoverMediaError(); + break; + case Hls.ErrorTypes.NETWORK_ERROR: + setImageMeta({ player: { current: null }, broken: true }, index); + break; + default: + hls.destroy(); + break; + } } - } - }); + }); - hls.loadSource(url); - if (playerRef.current) { - hls.attachMedia(playerRef.current); + hls.loadSource(url); + if (playerRef.current) { + hls.attachMedia(playerRef.current); + } + } else { + setHLSSupported(false); } + + return () => { + if (hls) { + hls.destroy(); + } + if (timer.current) { + clearTimeout(timer.current); + } + }; } - return () => { - if (hls) { - hls.destroy(); - } - if (timer.current) { - clearTimeout(timer.current); - } - }; + initHls().catch(); + /* eslint-disable-next-line react-hooks/exhaustive-deps */ }, [url, index]); @@ -144,7 +162,7 @@ export const Video = ({ url, index, className, isActive }: Props) => { playsInline={true} muted={mutedVideo} loop={true} - src={Hls.isSupported() ? undefined : url} + src={HLSSupported ? undefined : url} className={cn(styles.video, { [styles.mobile]: view === 'mobile' }, className)} > diff --git a/packages/gallery/src/declaration.d.ts b/packages/gallery/src/declaration.d.ts new file mode 100644 index 0000000000..9c8f5c3cfa --- /dev/null +++ b/packages/gallery/src/declaration.d.ts @@ -0,0 +1,5 @@ +declare module 'hls.js/dist/hls.light.mjs' { + import Hls from 'hls'; + + export default Hls; +} From 2e682fb365ec080aecd22a507221ac0305845690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20=F0=9F=8E=83=20Khripkov?= Date: Fri, 20 Dec 2024 15:43:45 +0300 Subject: [PATCH 5/8] fix: clear func; --- .../components/image-viewer/video/index.tsx | 67 ++++++++++--------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/packages/gallery/src/components/image-viewer/video/index.tsx b/packages/gallery/src/components/image-viewer/video/index.tsx index 1254653298..777ab3166f 100644 --- a/packages/gallery/src/components/image-viewer/video/index.tsx +++ b/packages/gallery/src/components/image-viewer/video/index.tsx @@ -41,50 +41,55 @@ export const Video = ({ url, index, className, isActive }: Props) => { }, [index]); useEffect(() => { + let hls: HlsType; + async function initHls() { const { default: Hls } = await import( - /* webpackChunkName: "HLSVideo" */ 'hls.js/dist/hls.light.mjs' + /* webpackChunkName: "hls-js-video" */ 'hls.js/dist/hls.light.mjs' ); - const hls: HlsType = new Hls(); - - if (Hls.isSupported()) { - hls.on(Hls.Events.ERROR, (_: Events.ERROR, data: ErrorData) => { - if (data.fatal) { - switch (data.type) { - case Hls.ErrorTypes.MEDIA_ERROR: - hls.recoverMediaError(); - break; - case Hls.ErrorTypes.NETWORK_ERROR: - setImageMeta({ player: { current: null }, broken: true }, index); - break; - default: - hls.destroy(); - break; - } - } - }); + hls = new Hls(); - hls.loadSource(url); - if (playerRef.current) { - hls.attachMedia(playerRef.current); - } - } else { + if (!Hls.isSupported()) { setHLSSupported(false); + + return; } - return () => { - if (hls) { - hls.destroy(); - } - if (timer.current) { - clearTimeout(timer.current); + hls.on(Hls.Events.ERROR, (_: Events.ERROR, data: ErrorData) => { + if (data.fatal) { + switch (data.type) { + case Hls.ErrorTypes.MEDIA_ERROR: + hls.recoverMediaError(); + break; + case Hls.ErrorTypes.NETWORK_ERROR: + setImageMeta({ player: { current: null }, broken: true }, index); + break; + default: + hls.destroy(); + break; + } } - }; + }); + + hls.loadSource(url); + + if (playerRef.current) { + hls.attachMedia(playerRef.current); + } } initHls().catch(); + return () => { + if (hls) { + hls.destroy(); + } + if (timer.current) { + clearTimeout(timer.current); + } + }; + /* eslint-disable-next-line react-hooks/exhaustive-deps */ }, [url, index]); From 722b4b3682a067aa817f63df5efd4cad2b9f0ba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20=F0=9F=8E=83=20Khripkov?= Date: Sat, 21 Dec 2024 13:58:06 +0300 Subject: [PATCH 6/8] fix: dts settings; --- packages/gallery/src/components/image-viewer/video/index.tsx | 4 ++-- packages/gallery/src/declaration.d.ts | 3 ++- tsconfig.json | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/gallery/src/components/image-viewer/video/index.tsx b/packages/gallery/src/components/image-viewer/video/index.tsx index 777ab3166f..5520bfb740 100644 --- a/packages/gallery/src/components/image-viewer/video/index.tsx +++ b/packages/gallery/src/components/image-viewer/video/index.tsx @@ -7,8 +7,8 @@ import React, { useState, } from 'react'; import cn from 'classnames'; -import type HlsType from 'hls.js'; -import type { ErrorData, Events } from 'hls.js'; +import type HlsType from 'hls.js/dist/hls.light.mjs'; +import type { ErrorData, Events } from 'hls.js/dist/hls.light.mjs'; import { Circle } from '@alfalab/core-components/icon-view/circle'; import PlayCompactMIcon from '@alfalab/icons-glyph/PlayCompactMIcon'; diff --git a/packages/gallery/src/declaration.d.ts b/packages/gallery/src/declaration.d.ts index 9c8f5c3cfa..f18c299be9 100644 --- a/packages/gallery/src/declaration.d.ts +++ b/packages/gallery/src/declaration.d.ts @@ -1,5 +1,6 @@ declare module 'hls.js/dist/hls.light.mjs' { - import Hls from 'hls'; + import Hls, { ErrorData, Events } from 'hls'; export default Hls; + export { ErrorData, Events }; } diff --git a/tsconfig.json b/tsconfig.json index a21f257553..e1df4d6bd3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -45,5 +45,5 @@ } }, "exclude": ["node_modules", "dist", "**/*.stories*", "**/*.test*"], - "include": ["./typings"] + "include": ["./typings", "**/declaration.d.ts"] } From d884f1bc6f1bf3f3ccd7db2811c4f89eea9c14f6 Mon Sep 17 00:00:00 2001 From: denisx Date: Wed, 25 Dec 2024 22:41:09 +0300 Subject: [PATCH 7/8] Update .changeset/strange-coats-exercise.md Co-authored-by: Evgeny Sergeev --- .changeset/strange-coats-exercise.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/strange-coats-exercise.md b/.changeset/strange-coats-exercise.md index ae773f7fbd..6e8d186fc4 100644 --- a/.changeset/strange-coats-exercise.md +++ b/.changeset/strange-coats-exercise.md @@ -2,4 +2,4 @@ '@alfalab/core-components-gallery': patch --- -Импорт HLS заменён на light версию, только енкодер без дополнительных обвязок +Импорт HLS заменён на light версию, только энкодер без дополнительных обвязок From 6f35815bc114d4cf3e42d7056980a4f1401bf988 Mon Sep 17 00:00:00 2001 From: denisx Date: Thu, 26 Dec 2024 13:50:04 +0300 Subject: [PATCH 8/8] Update strange-coats-exercise.md --- .changeset/strange-coats-exercise.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.changeset/strange-coats-exercise.md b/.changeset/strange-coats-exercise.md index 6e8d186fc4..091e6d53a1 100644 --- a/.changeset/strange-coats-exercise.md +++ b/.changeset/strange-coats-exercise.md @@ -2,4 +2,5 @@ '@alfalab/core-components-gallery': patch --- -Импорт HLS заменён на light версию, только энкодер без дополнительных обвязок +- Импорт HLS заменён на light версию, только энкодер без дополнительных обвязок. +- Подгрузка модуля перенесена на время после загрузки основного js, для лучшей клиентской доступности основного приложения.