@tramvai/cli 5.49.1 → 6.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__migrations__/d2023-02-01b-tramvai-config-refactoring.js +78 -80
- package/__migrations__/d2025-04-11b-tramvai-config-remove-modern.js +13 -0
- package/bin/spawn.js +76 -4
- package/lib/api/analyze/index.d.ts +0 -1
- package/lib/api/analyze/index.d.ts.map +1 -1
- package/lib/api/analyze/index.js +2 -2
- package/lib/api/analyze/index.js.map +1 -1
- package/lib/api/build/application.d.ts.map +1 -1
- package/lib/api/build/application.js +2 -5
- package/lib/api/build/application.js.map +1 -1
- package/lib/api/build/child-app.d.ts.map +1 -1
- package/lib/api/build/child-app.js +1 -5
- package/lib/api/build/child-app.js.map +1 -1
- package/lib/api/build/index.d.ts +0 -2
- package/lib/api/build/index.d.ts.map +1 -1
- package/lib/api/build/index.js.map +1 -1
- package/lib/api/build/module.d.ts.map +1 -1
- package/lib/api/build/module.js +1 -3
- package/lib/api/build/module.js.map +1 -1
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +0 -4
- package/lib/api/index.js.map +1 -1
- package/lib/api/start/application.experimental.d.ts +7 -0
- package/lib/api/start/application.experimental.d.ts.map +1 -0
- package/lib/api/start/application.experimental.js +275 -0
- package/lib/api/start/application.experimental.js.map +1 -0
- package/lib/api/start/index.d.ts +1 -1
- package/lib/api/start/index.d.ts.map +1 -1
- package/lib/api/start/index.js +17 -6
- package/lib/api/start/index.js.map +1 -1
- package/lib/api/start/utils/banner.d.ts.map +1 -1
- package/lib/api/start/utils/banner.js +0 -1
- package/lib/api/start/utils/banner.js.map +1 -1
- package/lib/api/start/utils/tips/tips.d.ts.map +1 -1
- package/lib/api/start/utils/tips/tips.js +0 -8
- package/lib/api/start/utils/tips/tips.js.map +1 -1
- package/lib/builder/webpack/devServer/pool/process/pool.d.ts.map +1 -1
- package/lib/builder/webpack/devServer/pool/process/pool.js +0 -2
- package/lib/builder/webpack/devServer/pool/process/pool.js.map +1 -1
- package/lib/builder/webpack/devServer/server.d.ts.map +1 -1
- package/lib/builder/webpack/devServer/server.js +4 -0
- package/lib/builder/webpack/devServer/server.js.map +1 -1
- package/lib/builder/webpack/devServer/setup.d.ts.map +1 -1
- package/lib/builder/webpack/devServer/setup.js +3 -1
- package/lib/builder/webpack/devServer/setup.js.map +1 -1
- package/lib/builder/webpack/index.d.ts.map +1 -1
- package/lib/builder/webpack/index.js +3 -5
- package/lib/builder/webpack/index.js.map +1 -1
- package/lib/builder/webpack/providers/analyze/shared.d.ts.map +1 -1
- package/lib/builder/webpack/providers/analyze/shared.js +5 -9
- package/lib/builder/webpack/providers/analyze/shared.js.map +1 -1
- package/lib/builder/webpack/providers/build/client.d.ts.map +1 -1
- package/lib/builder/webpack/providers/build/client.js +0 -1
- package/lib/builder/webpack/providers/build/client.js.map +1 -1
- package/lib/builder/webpack/providers/build/clientShared.d.ts.map +1 -1
- package/lib/builder/webpack/providers/build/clientShared.js +4 -6
- package/lib/builder/webpack/providers/build/clientShared.js.map +1 -1
- package/lib/builder/webpack/providers/client.d.ts.map +1 -1
- package/lib/builder/webpack/providers/client.js +10 -22
- package/lib/builder/webpack/providers/client.js.map +1 -1
- package/lib/builder/webpack/providers/server.d.ts.map +1 -1
- package/lib/builder/webpack/providers/server.js +10 -9
- package/lib/builder/webpack/providers/server.js.map +1 -1
- package/lib/builder/webpack/providers/shared.d.ts.map +1 -1
- package/lib/builder/webpack/providers/shared.js +2 -8
- package/lib/builder/webpack/providers/shared.js.map +1 -1
- package/lib/builder/webpack/tokens.d.ts +4 -139
- package/lib/builder/webpack/tokens.d.ts.map +1 -1
- package/lib/builder/webpack/tokens.js +1 -4
- package/lib/builder/webpack/tokens.js.map +1 -1
- package/lib/builder/webpack/utils/copyStatsJsonFile.d.ts.map +1 -1
- package/lib/builder/webpack/utils/copyStatsJsonFile.js +0 -11
- package/lib/builder/webpack/utils/copyStatsJsonFile.js.map +1 -1
- package/lib/cli/CLI.d.ts +2 -2
- package/lib/cli/CLI.d.ts.map +1 -1
- package/lib/cli/CLI.js +2 -2
- package/lib/cli/CLI.js.map +1 -1
- package/lib/cli/bin-init.js +0 -2
- package/lib/cli/bin-init.js.map +1 -1
- package/lib/cli/index.d.ts.map +1 -1
- package/lib/cli/index.js +28 -18
- package/lib/cli/index.js.map +1 -1
- package/lib/cli/runCLI.d.ts +3 -0
- package/lib/cli/runCLI.d.ts.map +1 -1
- package/lib/cli/runCLI.js +18 -6
- package/lib/cli/runCLI.js.map +1 -1
- package/lib/commands/add/command.d.ts +1 -4
- package/lib/commands/add/command.d.ts.map +1 -1
- package/lib/commands/add/command.js +3 -2
- package/lib/commands/add/command.js.map +1 -1
- package/lib/commands/analyze/command.d.ts +1 -1
- package/lib/commands/analyze/command.d.ts.map +1 -1
- package/lib/commands/analyze/command.js +11 -13
- package/lib/commands/analyze/command.js.map +1 -1
- package/lib/commands/benchmark/command.d.ts +1 -1
- package/lib/commands/benchmark/command.d.ts.map +1 -1
- package/lib/commands/benchmark/command.js +8 -9
- package/lib/commands/benchmark/command.js.map +1 -1
- package/lib/commands/build/build.d.ts.map +1 -1
- package/lib/commands/build/build.js +1 -0
- package/lib/commands/build/build.js.map +1 -1
- package/lib/commands/build/command.d.ts +2 -2
- package/lib/commands/build/command.d.ts.map +1 -1
- package/lib/commands/build/command.js +53 -28
- package/lib/commands/build/command.js.map +1 -1
- package/lib/commands/createApp.d.ts.map +1 -1
- package/lib/commands/createApp.js +0 -1
- package/lib/commands/createApp.js.map +1 -1
- package/lib/commands/generate/command.d.ts +1 -1
- package/lib/commands/generate/command.d.ts.map +1 -1
- package/lib/commands/generate/command.js +3 -2
- package/lib/commands/generate/command.js.map +1 -1
- package/lib/commands/lint/command.d.ts +1 -1
- package/lib/commands/lint/command.d.ts.map +1 -1
- package/lib/commands/lint/command.js +3 -2
- package/lib/commands/lint/command.js.map +1 -1
- package/lib/commands/new/command.d.ts +0 -1
- package/lib/commands/new/command.d.ts.map +1 -1
- package/lib/commands/new/command.js +0 -1
- package/lib/commands/new/command.js.map +1 -1
- package/lib/commands/new/new.d.ts.map +1 -1
- package/lib/commands/new/new.js +28 -3
- package/lib/commands/new/new.js.map +1 -1
- package/lib/commands/new/steps/installDependencies.js +3 -3
- package/lib/commands/new/steps/installDependencies.js.map +1 -1
- package/lib/commands/start/command.d.ts +2 -2
- package/lib/commands/start/command.d.ts.map +1 -1
- package/lib/commands/start/command.js +57 -22
- package/lib/commands/start/command.js.map +1 -1
- package/lib/commands/start/start.d.ts +1 -1
- package/lib/commands/start/start.d.ts.map +1 -1
- package/lib/commands/start/start.js +2 -1
- package/lib/commands/start/start.js.map +1 -1
- package/lib/commands/start-prod/command.d.ts +1 -1
- package/lib/commands/start-prod/command.d.ts.map +1 -1
- package/lib/commands/start-prod/command.js +11 -13
- package/lib/commands/start-prod/command.js.map +1 -1
- package/lib/commands/static/application.d.ts.map +1 -1
- package/lib/commands/static/application.js +0 -1
- package/lib/commands/static/application.js.map +1 -1
- package/lib/commands/static/command.d.ts +1 -1
- package/lib/commands/static/command.d.ts.map +1 -1
- package/lib/commands/static/command.js +7 -3
- package/lib/commands/static/command.js.map +1 -1
- package/lib/commands/update/command.d.ts +7 -5
- package/lib/commands/update/command.d.ts.map +1 -1
- package/lib/commands/update/command.js +11 -3
- package/lib/commands/update/command.js.map +1 -1
- package/lib/commands/update/dependantLibs.d.ts +2 -1
- package/lib/commands/update/dependantLibs.d.ts.map +1 -1
- package/lib/commands/update/dependantLibs.js +17 -4
- package/lib/commands/update/dependantLibs.js.map +1 -1
- package/lib/commands/update/update.d.ts +2 -1
- package/lib/commands/update/update.d.ts.map +1 -1
- package/lib/commands/update/update.js +6 -6
- package/lib/commands/update/update.js.map +1 -1
- package/lib/commands/update/updatePackageJson.d.ts +1 -1
- package/lib/commands/update/updatePackageJson.d.ts.map +1 -1
- package/lib/commands/update/updatePackageJson.js +10 -14
- package/lib/commands/update/updatePackageJson.js.map +1 -1
- package/lib/config/configManager.d.ts +0 -1
- package/lib/config/configManager.d.ts.map +1 -1
- package/lib/config/configManager.js +2 -17
- package/lib/config/configManager.js.map +1 -1
- package/lib/config/validate.d.ts.map +1 -1
- package/lib/config/validate.js +8 -1
- package/lib/config/validate.js.map +1 -1
- package/lib/di/providers/index.d.ts +0 -1
- package/lib/di/providers/index.d.ts.map +1 -1
- package/lib/di/providers/index.js +0 -1
- package/lib/di/providers/index.js.map +1 -1
- package/lib/di/tokens/config.d.ts +2 -0
- package/lib/di/tokens/config.d.ts.map +1 -1
- package/lib/di/tokens/index.d.ts +0 -1
- package/lib/di/tokens/index.d.ts.map +1 -1
- package/lib/di/tokens/index.js +0 -1
- package/lib/di/tokens/index.js.map +1 -1
- package/lib/external/config.d.ts.map +1 -1
- package/lib/external/config.js.map +1 -1
- package/lib/library/babel/index.d.ts +3 -53
- package/lib/library/babel/index.d.ts.map +1 -1
- package/lib/library/babel/index.js +3 -139
- package/lib/library/babel/index.js.map +1 -1
- package/lib/library/swc/index.d.ts +3 -3
- package/lib/library/swc/index.d.ts.map +1 -1
- package/lib/library/swc/index.js +4 -114
- package/lib/library/swc/index.js.map +1 -1
- package/lib/library/typescript/index.d.ts +0 -23
- package/lib/library/typescript/index.d.ts.map +1 -1
- package/lib/library/typescript/index.js +1 -2
- package/lib/library/typescript/index.js.map +1 -1
- package/lib/library/webpack/application/client/common.d.ts.map +1 -1
- package/lib/library/webpack/application/client/common.js +45 -10
- package/lib/library/webpack/application/client/common.js.map +1 -1
- package/lib/library/webpack/application/client/dev.js +2 -2
- package/lib/library/webpack/application/client/dev.js.map +1 -1
- package/lib/library/webpack/application/client/prod.d.ts.map +1 -1
- package/lib/library/webpack/application/client/prod.js +1 -2
- package/lib/library/webpack/application/client/prod.js.map +1 -1
- package/lib/library/webpack/application/common.d.ts.map +1 -1
- package/lib/library/webpack/application/common.js +4 -5
- package/lib/library/webpack/application/common.js.map +1 -1
- package/lib/library/webpack/application/server/common.js +1 -1
- package/lib/library/webpack/application/server/common.js.map +1 -1
- package/lib/library/webpack/application/server/dev.js +1 -1
- package/lib/library/webpack/application/server/dev.js.map +1 -1
- package/lib/library/webpack/application/server/prod.js +1 -1
- package/lib/library/webpack/application/server/prod.js.map +1 -1
- package/lib/library/webpack/blocks/css.d.ts.map +1 -1
- package/lib/library/webpack/blocks/css.js +15 -11
- package/lib/library/webpack/blocks/css.js.map +1 -1
- package/lib/library/webpack/blocks/optimize.js +2 -2
- package/lib/library/webpack/blocks/optimize.js.map +1 -1
- package/lib/library/webpack/blocks/pwa/client.d.ts.map +1 -1
- package/lib/library/webpack/blocks/pwa/client.js +11 -63
- package/lib/library/webpack/blocks/pwa/client.js.map +1 -1
- package/lib/library/webpack/blocks/pwa/shared.d.ts.map +1 -1
- package/lib/library/webpack/blocks/pwa/shared.js +2 -3
- package/lib/library/webpack/blocks/pwa/shared.js.map +1 -1
- package/lib/library/webpack/blocks/resolve.d.ts.map +1 -1
- package/lib/library/webpack/blocks/resolve.js +3 -2
- package/lib/library/webpack/blocks/resolve.js.map +1 -1
- package/lib/library/webpack/blocks/serverInline.d.ts.map +1 -1
- package/lib/library/webpack/blocks/serverInline.js +1 -2
- package/lib/library/webpack/blocks/serverInline.js.map +1 -1
- package/lib/library/webpack/blocks/sourcemaps.d.ts +1 -1
- package/lib/library/webpack/blocks/sourcemaps.d.ts.map +1 -1
- package/lib/library/webpack/blocks/sourcemaps.js +4 -2
- package/lib/library/webpack/blocks/sourcemaps.js.map +1 -1
- package/lib/library/webpack/child-app/client/common.d.ts.map +1 -1
- package/lib/library/webpack/child-app/client/common.js +8 -3
- package/lib/library/webpack/child-app/client/common.js.map +1 -1
- package/lib/library/webpack/child-app/client/dev.d.ts.map +1 -1
- package/lib/library/webpack/child-app/client/dev.js +5 -1
- package/lib/library/webpack/child-app/client/dev.js.map +1 -1
- package/lib/library/webpack/child-app/client/prod.d.ts.map +1 -1
- package/lib/library/webpack/child-app/client/prod.js +4 -0
- package/lib/library/webpack/child-app/client/prod.js.map +1 -1
- package/lib/library/webpack/child-app/common.d.ts.map +1 -1
- package/lib/library/webpack/child-app/common.js +4 -9
- package/lib/library/webpack/child-app/common.js.map +1 -1
- package/lib/library/webpack/child-app/server/dev.d.ts.map +1 -1
- package/lib/library/webpack/child-app/server/dev.js +4 -0
- package/lib/library/webpack/child-app/server/dev.js.map +1 -1
- package/lib/library/webpack/child-app/server/prod.d.ts.map +1 -1
- package/lib/library/webpack/child-app/server/prod.js +4 -0
- package/lib/library/webpack/child-app/server/prod.js.map +1 -1
- package/lib/library/webpack/common/client/prod.js +1 -1
- package/lib/library/webpack/common/client/prod.js.map +1 -1
- package/lib/library/webpack/common/main.d.ts.map +1 -1
- package/lib/library/webpack/common/main.js +1 -2
- package/lib/library/webpack/common/main.js.map +1 -1
- package/lib/library/webpack/constants/stats.d.ts.map +1 -1
- package/lib/library/webpack/constants/stats.js +2 -0
- package/lib/library/webpack/constants/stats.js.map +1 -1
- package/lib/library/webpack/loaders/image-loader/getImageMiniatureURL.js +1 -1
- package/lib/library/webpack/loaders/image-loader/getImageMiniatureURL.js.map +1 -1
- package/lib/library/webpack/module/client/common.js +1 -1
- package/lib/library/webpack/module/client/common.js.map +1 -1
- package/lib/library/webpack/module/externals.js +1 -1
- package/lib/library/webpack/module/externals.js.map +1 -1
- package/lib/library/webpack/module/server/common.js +1 -1
- package/lib/library/webpack/module/server/common.js.map +1 -1
- package/lib/library/webpack/plugins/RuntimePathPlugin.d.ts.map +1 -1
- package/lib/library/webpack/plugins/RuntimePathPlugin.js +7 -3
- package/lib/library/webpack/plugins/RuntimePathPlugin.js.map +1 -1
- package/lib/library/webpack/utils/threadLoader.d.ts.map +1 -1
- package/lib/library/webpack/utils/threadLoader.js +20 -3
- package/lib/library/webpack/utils/threadLoader.js.map +1 -1
- package/lib/library/webpack/utils/transpiler.d.ts +0 -1
- package/lib/library/webpack/utils/transpiler.d.ts.map +1 -1
- package/lib/library/webpack/utils/transpiler.js +2 -6
- package/lib/library/webpack/utils/transpiler.js.map +1 -1
- package/lib/models/analytics/utils.d.ts +16 -0
- package/lib/models/analytics/utils.d.ts.map +1 -0
- package/lib/models/analytics/utils.js +88 -0
- package/lib/models/analytics/utils.js.map +1 -0
- package/lib/models/command.d.ts +1 -1
- package/lib/models/command.d.ts.map +1 -1
- package/lib/models/command.js +2 -8
- package/lib/models/command.js.map +1 -1
- package/lib/models/context.d.ts +4 -4
- package/lib/models/context.d.ts.map +1 -1
- package/lib/models/context.js +3 -2
- package/lib/models/context.js.map +1 -1
- package/lib/models/logger.js +1 -1
- package/lib/models/logger.js.map +1 -1
- package/lib/models/task.d.ts.map +1 -1
- package/lib/models/task.js +1 -7
- package/lib/models/task.js.map +1 -1
- package/lib/schema/autogeneratedSchema.json +161 -20
- package/lib/schema/topLevelSchema.d.ts +14 -0
- package/lib/schema/topLevelSchema.d.ts.map +1 -1
- package/lib/schema/topLevelSchema.js +14 -0
- package/lib/schema/topLevelSchema.js.map +1 -1
- package/lib/typings/build/Builder.d.ts +2 -6
- package/lib/typings/build/Builder.d.ts.map +1 -1
- package/lib/typings/configEntry/application.d.ts +11 -6
- package/lib/typings/configEntry/application.d.ts.map +1 -1
- package/lib/typings/configEntry/cli.d.ts +13 -0
- package/lib/typings/configEntry/cli.d.ts.map +1 -1
- package/lib/typings/projectType.d.ts +5 -0
- package/lib/typings/projectType.d.ts.map +1 -1
- package/lib/typings/public.d.ts +0 -1
- package/lib/typings/public.d.ts.map +1 -1
- package/lib/typings/public.js +0 -2
- package/lib/typings/public.js.map +1 -1
- package/lib/typings/target.d.ts +1 -1
- package/lib/typings/target.d.ts.map +1 -1
- package/lib/utils/commands/dependencies/findTramvaiVersion.d.ts +1 -1
- package/lib/utils/commands/dependencies/findTramvaiVersion.d.ts.map +1 -1
- package/lib/utils/commands/dependencies/findTramvaiVersion.js +4 -11
- package/lib/utils/commands/dependencies/findTramvaiVersion.js.map +1 -1
- package/lib/utils/commands/dependencies/getLatestPackageVersion.d.ts +1 -1
- package/lib/utils/commands/dependencies/getLatestPackageVersion.d.ts.map +1 -1
- package/lib/utils/commands/dependencies/getLatestPackageVersion.js +7 -3
- package/lib/utils/commands/dependencies/getLatestPackageVersion.js.map +1 -1
- package/lib/utils/cpu-profile.d.ts +3 -0
- package/lib/utils/cpu-profile.d.ts.map +1 -1
- package/lib/utils/cpu-profile.js +8 -4
- package/lib/utils/cpu-profile.js.map +1 -1
- package/lib/utils/safeRequire.d.ts +1 -1
- package/lib/utils/safeRequire.d.ts.map +1 -1
- package/lib/utils/safeRequire.js +13 -3
- package/lib/utils/safeRequire.js.map +1 -1
- package/package.json +26 -32
- package/schema.json +175 -20
- package/src/api/analyze/index.ts +2 -3
- package/src/api/benchmark/__integration__/__fixtures__/tramvai.json +3 -0
- package/src/api/build/__integration__/__fixtures__/tramvai.json +4 -2
- package/src/api/build/__integration__/build.test.ts +0 -1
- package/src/api/build/application.ts +2 -5
- package/src/api/build/child-app.ts +1 -5
- package/src/api/build/index.ts +0 -2
- package/src/api/build/module.ts +1 -3
- package/src/api/index.ts +1 -10
- package/src/api/start/__integration__/__fixtures__/app/server.tsx +1 -0
- package/src/api/start/__integration__/__fixtures__/package.json +0 -3
- package/src/api/start/__integration__/__fixtures__/tramvai.json +3 -0
- package/src/api/start/__integration__/start.test.ts +10 -1
- package/src/api/start/application.experimental.ts +305 -0
- package/src/api/start/index.ts +20 -5
- package/src/api/start/utils/banner.ts +0 -1
- package/src/api/start/utils/tips/tips.ts +0 -9
- package/src/builder/webpack/devServer/pool/process/pool.ts +0 -2
- package/src/builder/webpack/devServer/server.ts +5 -0
- package/src/builder/webpack/devServer/setup.ts +1 -0
- package/src/builder/webpack/index.ts +3 -5
- package/src/builder/webpack/providers/analyze/shared.ts +6 -10
- package/src/builder/webpack/providers/build/client.ts +0 -1
- package/src/builder/webpack/providers/build/clientShared.ts +5 -11
- package/src/builder/webpack/providers/client.ts +16 -29
- package/src/builder/webpack/providers/server.ts +15 -10
- package/src/builder/webpack/providers/shared.ts +2 -9
- package/src/builder/webpack/tokens.ts +0 -9
- package/src/builder/webpack/utils/copyStatsJsonFile.ts +0 -17
- package/src/cli/CLI.ts +6 -4
- package/src/cli/bin-init.ts +0 -2
- package/src/cli/index.ts +36 -18
- package/src/cli/runCLI.ts +26 -6
- package/src/commands/add/command.ts +3 -2
- package/src/commands/analyze/command.ts +12 -14
- package/src/commands/benchmark/command.ts +9 -10
- package/src/commands/build/build.ts +2 -0
- package/src/commands/build/command.ts +58 -29
- package/src/commands/createApp.ts +0 -2
- package/src/commands/generate/command.ts +3 -2
- package/src/commands/lint/command.ts +3 -2
- package/src/commands/new/command.ts +0 -2
- package/src/commands/new/new.ts +39 -7
- package/src/commands/new/steps/installDependencies.ts +3 -3
- package/src/commands/new/templates/packageManagerConfig/yarnPackageManagerConfig/_yarnrc.yml.hbs +9 -0
- package/src/commands/new/templates/shared/_gitignore.hbs +10 -0
- package/src/commands/new/templates/shared/_prettierrc.js.hbs +1 -1
- package/src/commands/new/templates/shared/package.json.hbs +5 -1
- package/src/commands/start/command.ts +62 -23
- package/src/commands/start/start.ts +7 -1
- package/src/commands/start-prod/command.ts +12 -14
- package/src/commands/static/application.ts +0 -1
- package/src/commands/static/command.ts +7 -3
- package/src/commands/update/command.ts +12 -3
- package/src/commands/update/dependantLibs.ts +23 -8
- package/src/commands/update/update.ts +7 -6
- package/src/commands/update/updatePackageJson.spec.ts +66 -3
- package/src/commands/update/updatePackageJson.ts +28 -16
- package/src/config/__integration__/__fixtures__/relative/src/index.ts +0 -0
- package/src/config/__integration__/__fixtures__/relative/src/polyfill.ts +0 -0
- package/src/config/__integration__/validate.test.ts +94 -0
- package/src/config/configManager.ts +2 -19
- package/src/config/validate.ts +8 -1
- package/src/di/providers/index.ts +0 -1
- package/src/di/tokens/index.ts +0 -1
- package/src/external/config.ts +1 -0
- package/src/library/babel/index.ts +3 -166
- package/src/library/swc/__integration__/__snapshots__/swc.build.test.ts.snap +61 -236
- package/src/library/swc/__integration__/__snapshots__/swc.start.test.ts.snap +19 -18
- package/src/library/swc/__integration__/swc.build.test.ts +1 -13
- package/src/library/swc/__integration__/swc.start.test.ts +4 -1
- package/src/library/swc/index.ts +3 -139
- package/src/library/typescript/index.ts +1 -3
- package/src/library/webpack/application/client/common.ts +71 -9
- package/src/library/webpack/application/client/dev.ts +2 -2
- package/src/library/webpack/application/client/prod.ts +1 -2
- package/src/library/webpack/application/common.ts +9 -5
- package/src/library/webpack/application/server/common.ts +1 -1
- package/src/library/webpack/application/server/dev.ts +1 -1
- package/src/library/webpack/application/server/prod.ts +1 -1
- package/src/library/webpack/blocks/css.ts +17 -11
- package/src/library/webpack/blocks/optimize.ts +2 -2
- package/src/library/webpack/blocks/pwa/client.ts +14 -70
- package/src/library/webpack/blocks/pwa/shared.ts +1 -3
- package/src/library/webpack/blocks/resolve.ts +3 -2
- package/src/library/webpack/blocks/serverInline.ts +1 -2
- package/src/library/webpack/blocks/sourcemaps.ts +4 -2
- package/src/library/webpack/child-app/client/common.ts +9 -3
- package/src/library/webpack/child-app/client/dev.ts +6 -1
- package/src/library/webpack/child-app/client/prod.ts +5 -0
- package/src/library/webpack/child-app/common.ts +8 -12
- package/src/library/webpack/child-app/server/dev.ts +5 -0
- package/src/library/webpack/child-app/server/prod.ts +5 -0
- package/src/library/webpack/common/client/prod.ts +1 -1
- package/src/library/webpack/common/main.ts +1 -5
- package/src/library/webpack/constants/stats.ts +2 -0
- package/src/library/webpack/loaders/image-loader/getImageMiniatureURL.ts +1 -1
- package/src/library/webpack/module/client/common.ts +1 -1
- package/src/library/webpack/module/externals.ts +1 -1
- package/src/library/webpack/module/server/common.ts +1 -1
- package/src/library/webpack/plugins/RuntimePathPlugin.ts +8 -3
- package/src/library/webpack/utils/threadLoader.ts +21 -0
- package/src/library/webpack/utils/transpiler.ts +3 -7
- package/src/models/analytics/utils.ts +126 -0
- package/src/models/command.ts +4 -12
- package/src/models/config.spec.ts +6 -2
- package/src/models/context.ts +4 -5
- package/src/models/logger.ts +1 -1
- package/src/models/task.ts +1 -7
- package/src/schema/autogeneratedSchema.json +161 -20
- package/src/schema/topLevelSchema.js +14 -0
- package/src/schema/tramvai.spec.ts +3 -1
- package/src/typings/build/Builder.ts +3 -8
- package/src/typings/configEntry/application.ts +16 -7
- package/src/typings/configEntry/cli.ts +14 -0
- package/src/typings/projectType.ts +5 -0
- package/src/typings/public.ts +0 -2
- package/src/typings/target.ts +1 -1
- package/src/utils/commands/dependencies/findTramvaiVersion.ts +5 -12
- package/src/utils/commands/dependencies/getLatestPackageVersion.ts +11 -3
- package/src/utils/cpu-profile.ts +14 -4
- package/src/utils/safeRequire.spec.ts +36 -0
- package/src/utils/safeRequire.ts +12 -3
- package/lib/builder/webpack/providers/build/clientModern.d.ts +0 -3
- package/lib/builder/webpack/providers/build/clientModern.d.ts.map +0 -1
- package/lib/builder/webpack/providers/build/clientModern.js +0 -60
- package/lib/builder/webpack/providers/build/clientModern.js.map +0 -1
- package/lib/di/providers/analytics.d.ts +0 -3
- package/lib/di/providers/analytics.d.ts.map +0 -1
- package/lib/di/providers/analytics.js +0 -20
- package/lib/di/providers/analytics.js.map +0 -1
- package/lib/di/tokens/analytics.d.ts +0 -14
- package/lib/di/tokens/analytics.d.ts.map +0 -1
- package/lib/di/tokens/analytics.js +0 -8
- package/lib/di/tokens/analytics.js.map +0 -1
- package/lib/library/babel/plugins/create-token-pure.d.ts +0 -7
- package/lib/library/babel/plugins/create-token-pure.d.ts.map +0 -1
- package/lib/library/babel/plugins/create-token-pure.js +0 -39
- package/lib/library/babel/plugins/create-token-pure.js.map +0 -1
- package/lib/library/babel/plugins/fill-action-name.d.ts +0 -3
- package/lib/library/babel/plugins/fill-action-name.d.ts.map +0 -1
- package/lib/library/babel/plugins/fill-action-name.js +0 -107
- package/lib/library/babel/plugins/fill-action-name.js.map +0 -1
- package/lib/library/babel/plugins/fill-declare-action-name.d.ts +0 -6
- package/lib/library/babel/plugins/fill-declare-action-name.d.ts.map +0 -1
- package/lib/library/babel/plugins/fill-declare-action-name.js +0 -94
- package/lib/library/babel/plugins/fill-declare-action-name.js.map +0 -1
- package/lib/library/babel/plugins/lazy-component/lazy-component.d.ts +0 -7
- package/lib/library/babel/plugins/lazy-component/lazy-component.d.ts.map +0 -1
- package/lib/library/babel/plugins/lazy-component/lazy-component.js +0 -75
- package/lib/library/babel/plugins/lazy-component/lazy-component.js.map +0 -1
- package/lib/library/babel/plugins/lazy-component/legacy-universal-replace.d.ts +0 -14
- package/lib/library/babel/plugins/lazy-component/legacy-universal-replace.d.ts.map +0 -1
- package/lib/library/babel/plugins/lazy-component/legacy-universal-replace.js +0 -53
- package/lib/library/babel/plugins/lazy-component/legacy-universal-replace.js.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/chunkName.d.ts +0 -3
- package/lib/library/babel/plugins/lazy-component/properties/chunkName.d.ts.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/chunkName.js +0 -133
- package/lib/library/babel/plugins/lazy-component/properties/chunkName.js.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/importAsync.d.ts +0 -3
- package/lib/library/babel/plugins/lazy-component/properties/importAsync.d.ts.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/importAsync.js +0 -11
- package/lib/library/babel/plugins/lazy-component/properties/importAsync.js.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/isReady.d.ts +0 -3
- package/lib/library/babel/plugins/lazy-component/properties/isReady.d.ts.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/isReady.js +0 -14
- package/lib/library/babel/plugins/lazy-component/properties/isReady.js.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/requireAsync.d.ts +0 -3
- package/lib/library/babel/plugins/lazy-component/properties/requireAsync.d.ts.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/requireAsync.js +0 -15
- package/lib/library/babel/plugins/lazy-component/properties/requireAsync.js.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/requireSync.d.ts +0 -3
- package/lib/library/babel/plugins/lazy-component/properties/requireSync.d.ts.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/requireSync.js +0 -16
- package/lib/library/babel/plugins/lazy-component/properties/requireSync.js.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/resolve.d.ts +0 -3
- package/lib/library/babel/plugins/lazy-component/properties/resolve.d.ts.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/resolve.js +0 -14
- package/lib/library/babel/plugins/lazy-component/properties/resolve.js.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/types.d.ts +0 -14
- package/lib/library/babel/plugins/lazy-component/properties/types.d.ts.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/types.js +0 -3
- package/lib/library/babel/plugins/lazy-component/properties/types.js.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/utils/webpackComments.d.ts +0 -14
- package/lib/library/babel/plugins/lazy-component/properties/utils/webpackComments.d.ts.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/utils/webpackComments.js +0 -57
- package/lib/library/babel/plugins/lazy-component/properties/utils/webpackComments.js.map +0 -1
- package/lib/library/babel/plugins/provider-stack.d.ts +0 -4
- package/lib/library/babel/plugins/provider-stack.d.ts.map +0 -1
- package/lib/library/babel/plugins/provider-stack.js +0 -63
- package/lib/library/babel/plugins/provider-stack.js.map +0 -1
- package/lib/library/babel/plugins/react-compiler.d.ts +0 -13
- package/lib/library/babel/plugins/react-compiler.d.ts.map +0 -1
- package/lib/library/babel/plugins/react-compiler.js +0 -27
- package/lib/library/babel/plugins/react-compiler.js.map +0 -1
- package/lib/library/babel/plugins/react-element-info-unique.d.ts +0 -26
- package/lib/library/babel/plugins/react-element-info-unique.d.ts.map +0 -1
- package/lib/library/babel/plugins/react-element-info-unique.js +0 -112
- package/lib/library/babel/plugins/react-element-info-unique.js.map +0 -1
- package/lib/library/babel/plugins/types.h.d.ts +0 -7
- package/lib/library/babel/plugins/types.h.d.ts.map +0 -1
- package/lib/library/babel/plugins/types.h.js +0 -3
- package/lib/library/babel/plugins/types.h.js.map +0 -1
- package/lib/library/webpack/plugins/AutoPublicPathPlugin.d.ts +0 -4
- package/lib/library/webpack/plugins/AutoPublicPathPlugin.d.ts.map +0 -1
- package/lib/library/webpack/plugins/AutoPublicPathPlugin.js +0 -23
- package/lib/library/webpack/plugins/AutoPublicPathPlugin.js.map +0 -1
- package/lib/library/webpack/plugins/ModuleFederationFixRange.d.ts +0 -24
- package/lib/library/webpack/plugins/ModuleFederationFixRange.d.ts.map +0 -1
- package/lib/library/webpack/plugins/ModuleFederationFixRange.js +0 -127
- package/lib/library/webpack/plugins/ModuleFederationFixRange.js.map +0 -1
- package/lib/library/webpack/plugins/ModuleFederationIgnoreEntries.d.ts +0 -15
- package/lib/library/webpack/plugins/ModuleFederationIgnoreEntries.d.ts.map +0 -1
- package/lib/library/webpack/plugins/ModuleFederationIgnoreEntries.js +0 -49
- package/lib/library/webpack/plugins/ModuleFederationIgnoreEntries.js.map +0 -1
- package/lib/library/webpack/plugins/PolyfillCondition.d.ts +0 -8
- package/lib/library/webpack/plugins/PolyfillCondition.d.ts.map +0 -1
- package/lib/library/webpack/plugins/PolyfillCondition.js +0 -46
- package/lib/library/webpack/plugins/PolyfillCondition.js.map +0 -1
- package/lib/library/webpack/plugins/PwaIconsPlugin.d.ts +0 -12
- package/lib/library/webpack/plugins/PwaIconsPlugin.d.ts.map +0 -1
- package/lib/library/webpack/plugins/PwaIconsPlugin.js +0 -78
- package/lib/library/webpack/plugins/PwaIconsPlugin.js.map +0 -1
- package/lib/library/webpack/plugins/WebManifestPlugin.d.ts +0 -13
- package/lib/library/webpack/plugins/WebManifestPlugin.d.ts.map +0 -1
- package/lib/library/webpack/plugins/WebManifestPlugin.js +0 -47
- package/lib/library/webpack/plugins/WebManifestPlugin.js.map +0 -1
- package/lib/library/webpack/utils/polyfills/const.d.ts +0 -3
- package/lib/library/webpack/utils/polyfills/const.d.ts.map +0 -1
- package/lib/library/webpack/utils/polyfills/const.js +0 -49
- package/lib/library/webpack/utils/polyfills/const.js.map +0 -1
- package/lib/library/webpack/utils/polyfills/polyfillCondition.d.ts +0 -8
- package/lib/library/webpack/utils/polyfills/polyfillCondition.d.ts.map +0 -1
- package/lib/library/webpack/utils/polyfills/polyfillCondition.js +0 -51
- package/lib/library/webpack/utils/polyfills/polyfillCondition.js.map +0 -1
- package/lib/library/webpack/utils/polyfills/specToFeature.d.ts +0 -7
- package/lib/library/webpack/utils/polyfills/specToFeature.d.ts.map +0 -1
- package/lib/library/webpack/utils/polyfills/specToFeature.js +0 -207
- package/lib/library/webpack/utils/polyfills/specToFeature.js.map +0 -1
- package/lib/models/analytics.d.ts +0 -31
- package/lib/models/analytics.d.ts.map +0 -1
- package/lib/models/analytics.js +0 -79
- package/lib/models/analytics.js.map +0 -1
- package/lib/typings/pwa/index.d.ts +0 -80
- package/lib/typings/pwa/index.d.ts.map +0 -1
- package/lib/typings/pwa/index.js +0 -3
- package/lib/typings/pwa/index.js.map +0 -1
- package/lib/utils/sentry.d.ts +0 -2
- package/lib/utils/sentry.d.ts.map +0 -1
- package/lib/utils/sentry.js +0 -27
- package/lib/utils/sentry.js.map +0 -1
- package/src/builder/webpack/providers/build/clientModern.ts +0 -64
- package/src/di/providers/analytics.ts +0 -22
- package/src/di/tokens/analytics.ts +0 -8
- package/src/library/babel/plugins/__fixtures__/create-token-pure/already-has-comment.ts +0 -5
- package/src/library/babel/plugins/__fixtures__/create-token-pure/do-nothing.ts +0 -10
- package/src/library/babel/plugins/__fixtures__/create-token-pure/from-core.ts +0 -5
- package/src/library/babel/plugins/__fixtures__/create-token-pure/from-dippy.ts +0 -5
- package/src/library/babel/plugins/__fixtures__/create-token-pure/many-imports.ts +0 -9
- package/src/library/babel/plugins/__fixtures__/fill-declare-action-name/import-mixed.ts +0 -17
- package/src/library/babel/plugins/__fixtures__/fill-declare-action-name/import-with-name.ts +0 -28
- package/src/library/babel/plugins/__fixtures__/fill-declare-action-name/import-without-name.ts +0 -25
- package/src/library/babel/plugins/__fixtures__/fill-declare-action-name/require-with-name.ts +0 -21
- package/src/library/babel/plugins/__fixtures__/fill-declare-action-name/require-without-name.ts +0 -19
- package/src/library/babel/plugins/__fixtures__/lazy-component/base.ts +0 -3
- package/src/library/babel/plugins/__fixtures__/lazy-component/cmp.tsx +0 -7
- package/src/library/babel/plugins/__fixtures__/lazy-component/comments.ts +0 -7
- package/src/library/babel/plugins/__fixtures__/lazy-component/dynamic.ts +0 -3
- package/src/library/babel/plugins/__fixtures__/lazy-component/inner/first.tsx +0 -7
- package/src/library/babel/plugins/__fixtures__/lazy-component/inner/path/cmp.tsx +0 -7
- package/src/library/babel/plugins/__fixtures__/lazy-component/inner/second.tsx +0 -7
- package/src/library/babel/plugins/__fixtures__/lazy-component/inner/third.tsx +0 -7
- package/src/library/babel/plugins/__fixtures__/lazy-component/lazy+hmr.ts +0 -3
- package/src/library/babel/plugins/__fixtures__/lazy-component/long-import.ts +0 -3
- package/src/library/babel/plugins/__fixtures__/lazy-component/not-lazy-import.ts +0 -7
- package/src/library/babel/plugins/__fixtures__/lazy-component/not-lazy.ts +0 -8
- package/src/library/babel/plugins/__fixtures__/legacy-universal-replace/cmp.tsx +0 -7
- package/src/library/babel/plugins/__fixtures__/legacy-universal-replace/not-universal.ts +0 -8
- package/src/library/babel/plugins/__fixtures__/legacy-universal-replace/platform-legacy.ts +0 -5
- package/src/library/babel/plugins/__fixtures__/legacy-universal-replace/react-universal.ts +0 -3
- package/src/library/babel/plugins/__fixtures__/legacy-universal-replace/tramvai/react/index.es.ts +0 -3
- package/src/library/babel/plugins/__fixtures__/provider-stack/add-stack.ts +0 -22
- package/src/library/babel/plugins/__fixtures__/provider-stack/check-function-name.ts +0 -10
- package/src/library/babel/plugins/__fixtures__/provider-stack/do-nothing.ts +0 -16
- package/src/library/babel/plugins/__fixtures__/provider-stack/error-in-scope.ts +0 -24
- package/src/library/babel/plugins/__fixtures__/provider-stack/inside-await.ts +0 -12
- package/src/library/babel/plugins/__fixtures__/provider-stack/module-decorator.ts +0 -27
- package/src/library/babel/plugins/__snapshots__/create-token-pure.spec.ts.snap +0 -108
- package/src/library/babel/plugins/__snapshots__/fill-declare-action-name.spec.ts.snap +0 -266
- package/src/library/babel/plugins/__snapshots__/provider-stack.spec.ts.snap +0 -381
- package/src/library/babel/plugins/create-token-pure.spec.ts +0 -39
- package/src/library/babel/plugins/create-token-pure.ts +0 -47
- package/src/library/babel/plugins/fill-action-name.ts +0 -126
- package/src/library/babel/plugins/fill-declare-action-name.spec.ts +0 -37
- package/src/library/babel/plugins/fill-declare-action-name.ts +0 -110
- package/src/library/babel/plugins/lazy-component/__snapshots__/lazy-component.spec.ts.snap +0 -313
- package/src/library/babel/plugins/lazy-component/__snapshots__/legacy-universal-replace.spec.ts.snap +0 -114
- package/src/library/babel/plugins/lazy-component/lazy-component.spec.ts +0 -47
- package/src/library/babel/plugins/lazy-component/lazy-component.ts +0 -91
- package/src/library/babel/plugins/lazy-component/legacy-universal-replace.spec.ts +0 -34
- package/src/library/babel/plugins/lazy-component/legacy-universal-replace.ts +0 -88
- package/src/library/babel/plugins/lazy-component/properties/chunkName.ts +0 -185
- package/src/library/babel/plugins/lazy-component/properties/importAsync.ts +0 -8
- package/src/library/babel/plugins/lazy-component/properties/isReady.ts +0 -19
- package/src/library/babel/plugins/lazy-component/properties/requireAsync.ts +0 -20
- package/src/library/babel/plugins/lazy-component/properties/requireSync.ts +0 -21
- package/src/library/babel/plugins/lazy-component/properties/resolve.ts +0 -21
- package/src/library/babel/plugins/lazy-component/properties/types.ts +0 -20
- package/src/library/babel/plugins/lazy-component/properties/utils/webpackComments.ts +0 -61
- package/src/library/babel/plugins/provider-stack.spec.ts +0 -55
- package/src/library/babel/plugins/provider-stack.ts +0 -88
- package/src/library/babel/plugins/react-compiler.ts +0 -39
- package/src/library/babel/plugins/react-element-info-unique.ts +0 -144
- package/src/library/babel/plugins/types.h.ts +0 -8
- package/src/library/webpack/plugins/AutoPublicPathPlugin.ts +0 -23
- package/src/library/webpack/plugins/ModuleFederationFixRange.ts +0 -181
- package/src/library/webpack/plugins/ModuleFederationIgnoreEntries.ts +0 -59
- package/src/library/webpack/plugins/PolyfillCondition.ts +0 -62
- package/src/library/webpack/plugins/PwaIconsPlugin.ts +0 -94
- package/src/library/webpack/plugins/WebManifestPlugin.ts +0 -62
- package/src/library/webpack/utils/polyfills/__integration__/__snapshots__/condition.test.ts.snap +0 -1348
- package/src/library/webpack/utils/polyfills/__integration__/condition.test.ts +0 -128
- package/src/library/webpack/utils/polyfills/const.ts +0 -46
- package/src/library/webpack/utils/polyfills/polyfillCondition.ts +0 -63
- package/src/library/webpack/utils/polyfills/specToFeature.ts +0 -243
- package/src/models/analytics.ts +0 -116
- package/src/typings/pwa/index.ts +0 -83
- package/src/utils/sentry.ts +0 -25
- /package/src/commands/new/templates/{shared → packageManagerConfig/defaultPackageManagerConfig}/_npmrc.hbs +0 -0
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import { fastify } from 'fastify';
|
|
3
|
-
import { getPort } from '@tramvai/internal-test-utils/utils/getPort';
|
|
4
|
-
import { initPlaywright } from '@tramvai/test-pw';
|
|
5
|
-
import { getMaxBrowserVersionsByFeatures, getPolyfillCondition } from '../polyfillCondition';
|
|
6
|
-
import { getSpecToFeatureDict } from '../specToFeature';
|
|
7
|
-
|
|
8
|
-
const polyfillEntryPath = require.resolve('@tinkoff/pack-polyfills');
|
|
9
|
-
const polyfillsEntryContent = fs.readFileSync(polyfillEntryPath, 'utf-8');
|
|
10
|
-
|
|
11
|
-
// import 'core-js/modules/es.array.at'; => 'es.array.at'
|
|
12
|
-
const usedFeatures = [...polyfillsEntryContent.matchAll(/core-js\/modules\/(.*)'/gm)].map(
|
|
13
|
-
(item) => item[1]
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
jest.setTimeout(3 * 60 * 1000);
|
|
17
|
-
|
|
18
|
-
describe('polyfills', () => {
|
|
19
|
-
let server;
|
|
20
|
-
let port;
|
|
21
|
-
let testUrl;
|
|
22
|
-
|
|
23
|
-
beforeAll(async () => {
|
|
24
|
-
server = fastify();
|
|
25
|
-
port = await getPort();
|
|
26
|
-
testUrl = `http://localhost:${port}`;
|
|
27
|
-
|
|
28
|
-
server.get('*', () => '<html></html>');
|
|
29
|
-
server.listen({ port });
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
afterAll(() => {
|
|
33
|
-
server.close();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
describe('spec to feature generator', () => {
|
|
37
|
-
it('should generate feature: expression dictionary', () => {
|
|
38
|
-
const specToFeatureDict = getSpecToFeatureDict();
|
|
39
|
-
|
|
40
|
-
expect(specToFeatureDict).toMatchSnapshot('featureDict');
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('all feature expresssion should be valid', async () => {
|
|
44
|
-
const specToFeatureDict = getSpecToFeatureDict();
|
|
45
|
-
const { getPageWrapper, browser } = await initPlaywright(testUrl);
|
|
46
|
-
|
|
47
|
-
const { page } = await getPageWrapper(testUrl);
|
|
48
|
-
|
|
49
|
-
const specExpressionsResult = await page.evaluate(
|
|
50
|
-
([specDict]) => {
|
|
51
|
-
const evalResult: Record<string, string> = {};
|
|
52
|
-
|
|
53
|
-
for (const featureName in specDict) {
|
|
54
|
-
const expression = specDict[featureName];
|
|
55
|
-
try {
|
|
56
|
-
// eslint-disable-next-line no-eval
|
|
57
|
-
const result = eval(`Boolean(${expression})`);
|
|
58
|
-
evalResult[featureName] = result;
|
|
59
|
-
} catch (err) {
|
|
60
|
-
evalResult[featureName] = '';
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return evalResult;
|
|
65
|
-
},
|
|
66
|
-
[specToFeatureDict]
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
expect(specExpressionsResult).toMatchSnapshot('expressionsResult');
|
|
70
|
-
|
|
71
|
-
const failedSpecExpressions = [];
|
|
72
|
-
|
|
73
|
-
// Неподдерживаемые в браузерах спецификации
|
|
74
|
-
const ignoredSpecs = [
|
|
75
|
-
'es.async-disposable-stack',
|
|
76
|
-
'es.disposable-stack',
|
|
77
|
-
'es.suppressed-error',
|
|
78
|
-
'es.web.immediate',
|
|
79
|
-
'web.immediate',
|
|
80
|
-
'es.observable',
|
|
81
|
-
];
|
|
82
|
-
|
|
83
|
-
// Проверяем что не прошли проверку только esnext фичи и несколько исключений
|
|
84
|
-
for (const specName in specExpressionsResult) {
|
|
85
|
-
const specResult = specExpressionsResult[specName];
|
|
86
|
-
|
|
87
|
-
if (!specResult && !specName.includes('esnext') && !ignoredSpecs.includes(specName)) {
|
|
88
|
-
failedSpecExpressions.push(`${specName} - ${specToFeatureDict[specName]}`);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
expect(failedSpecExpressions.length).toBe(0);
|
|
93
|
-
|
|
94
|
-
await browser.close();
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
describe('polyfill condition', () => {
|
|
99
|
-
it('should generate max browser versions dict', () => {
|
|
100
|
-
const browserVersions = getMaxBrowserVersionsByFeatures(usedFeatures);
|
|
101
|
-
|
|
102
|
-
expect(browserVersions).toMatchSnapshot('browserVersions');
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('should generate valid polyfill condition', async () => {
|
|
106
|
-
const browserVersions = getMaxBrowserVersionsByFeatures(usedFeatures);
|
|
107
|
-
const polyfillCondition = getPolyfillCondition(browserVersions);
|
|
108
|
-
|
|
109
|
-
expect(polyfillCondition).toMatchSnapshot('polyfillCondition');
|
|
110
|
-
|
|
111
|
-
const { getPageWrapper, browser } = await initPlaywright(testUrl);
|
|
112
|
-
|
|
113
|
-
const { page } = await getPageWrapper(testUrl);
|
|
114
|
-
|
|
115
|
-
const polyfillConditionResult = await page.evaluate(
|
|
116
|
-
([expression]) => {
|
|
117
|
-
// eslint-disable-next-line no-eval
|
|
118
|
-
return eval(expression);
|
|
119
|
-
},
|
|
120
|
-
[polyfillCondition]
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
expect(polyfillConditionResult).toBe(false);
|
|
124
|
-
|
|
125
|
-
browser.close();
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// List of ignore polyfills
|
|
2
|
-
// they are impossible or very difficult to support check in the browser
|
|
3
|
-
export const ignoredPolyfills = [
|
|
4
|
-
'es.json.to-string-tag',
|
|
5
|
-
'es.error.to-string',
|
|
6
|
-
'es.aggregate-error.cause',
|
|
7
|
-
'es.iterator',
|
|
8
|
-
'es.object.to-string',
|
|
9
|
-
'es.array.species',
|
|
10
|
-
'es.date.to-primitive',
|
|
11
|
-
'es.function.has-instance',
|
|
12
|
-
'es.string.at-alternative',
|
|
13
|
-
'es.math.to-string-tag',
|
|
14
|
-
'esnext.math.to-string-tag',
|
|
15
|
-
'es.reflect.to-string-tag',
|
|
16
|
-
'esnext.reflect.to-string-tag',
|
|
17
|
-
'esnext.function.metadata',
|
|
18
|
-
'esnext.composite-key',
|
|
19
|
-
'esnext.composite-symbol',
|
|
20
|
-
'web.dom-collections.for-each',
|
|
21
|
-
'web.dom-collections.iterator',
|
|
22
|
-
'web.dom-exception.to-string-tag',
|
|
23
|
-
'web.dom-exception.stack',
|
|
24
|
-
'es.array.unscopables.flat-map',
|
|
25
|
-
'es.array.unscopables.flat',
|
|
26
|
-
'es.array.push',
|
|
27
|
-
'es.set.difference.v2',
|
|
28
|
-
'es.set.intersection.v2',
|
|
29
|
-
'es.set.is-disjoint-from.v2',
|
|
30
|
-
'es.set.is-subset-of.v2',
|
|
31
|
-
'es.set.is-superset-of.v2',
|
|
32
|
-
'es.set.symmetric-difference.v2',
|
|
33
|
-
'es.set.union.v2',
|
|
34
|
-
];
|
|
35
|
-
|
|
36
|
-
export const browsers = [
|
|
37
|
-
'chrome',
|
|
38
|
-
'safari',
|
|
39
|
-
'firefox',
|
|
40
|
-
'opera',
|
|
41
|
-
'edge',
|
|
42
|
-
'chrome-android',
|
|
43
|
-
'ios',
|
|
44
|
-
'opera_mobile',
|
|
45
|
-
'samsung',
|
|
46
|
-
];
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import compat from 'core-js-compat';
|
|
2
|
-
import { coerce, compare } from 'semver';
|
|
3
|
-
import { getSpecToFeatureDict } from './specToFeature';
|
|
4
|
-
import { ignoredPolyfills, browsers } from './const';
|
|
5
|
-
|
|
6
|
-
type BrowserVersions = Record<string, { version: string; spec: string }>;
|
|
7
|
-
|
|
8
|
-
export function getMaxBrowserVersionsByFeatures(usedFeatures: string[]) {
|
|
9
|
-
const { data } = compat;
|
|
10
|
-
const browserVersions: BrowserVersions = {};
|
|
11
|
-
|
|
12
|
-
usedFeatures.forEach((spec) => {
|
|
13
|
-
if (ignoredPolyfills.includes(spec)) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const specBrowsers = data[spec];
|
|
18
|
-
|
|
19
|
-
if (!specBrowsers) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
browsers.forEach((browserName) => {
|
|
24
|
-
const maxBrowserVersion = specBrowsers[browserName];
|
|
25
|
-
|
|
26
|
-
if (
|
|
27
|
-
maxBrowserVersion &&
|
|
28
|
-
(!browserVersions[browserName] ||
|
|
29
|
-
compare(coerce(browserVersions[browserName].version), coerce(maxBrowserVersion)) === -1)
|
|
30
|
-
) {
|
|
31
|
-
browserVersions[browserName] = { version: maxBrowserVersion, spec };
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
return browserVersions;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function getPolyfillCondition(browserVersions: BrowserVersions) {
|
|
40
|
-
const supportConditions = new Set();
|
|
41
|
-
|
|
42
|
-
Object.values(browserVersions).forEach(({ spec }) =>
|
|
43
|
-
supportConditions.add(`!(${getSpecToFeature(spec)})`)
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
const polyfillCondition = [...supportConditions].join(' || ');
|
|
47
|
-
|
|
48
|
-
return polyfillCondition;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Converting the name of the specification into an expression for checking support in runtime
|
|
53
|
-
* es.string.at => String.prototype.at
|
|
54
|
-
* es.object.assign => Object.assign
|
|
55
|
-
*/
|
|
56
|
-
let specToFeatureDictCache;
|
|
57
|
-
function getSpecToFeature(spec) {
|
|
58
|
-
if (!specToFeatureDictCache) {
|
|
59
|
-
specToFeatureDictCache = getSpecToFeatureDict();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return specToFeatureDictCache[spec];
|
|
63
|
-
}
|
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import camelCaseName from '@tinkoff/utils/string/camelCaseName';
|
|
3
|
-
import { ignoredPolyfills } from './const';
|
|
4
|
-
|
|
5
|
-
// built-in-definitions.js file is not listed in the package.json exports of package, so it cannot be imported
|
|
6
|
-
// workaround this by using require with an absolute path to file
|
|
7
|
-
const pathToDep = require.resolve('babel-plugin-polyfill-corejs3/package.json');
|
|
8
|
-
const definitions = require(path.join(path.dirname(pathToDep), '/lib/built-in-definitions.js'));
|
|
9
|
-
|
|
10
|
-
// A list of new primitives, their support in browsers was added recently
|
|
11
|
-
const newPrimitivies = {
|
|
12
|
-
'weak-map': 'window.WeakMap',
|
|
13
|
-
'weak-set': 'window.WeakSet',
|
|
14
|
-
'async-disposable-stack': 'window.AsyncDisposableStack',
|
|
15
|
-
'disposable-stack': 'window.DisposableStack',
|
|
16
|
-
'suppressed-error': 'window.SuppressedError',
|
|
17
|
-
'web.immediate': 'window.setImmediate',
|
|
18
|
-
observable: 'window.Observable',
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// A list of primitives for which there are no polyfills, but they are needed as a base for methods like JSON.stringify
|
|
22
|
-
const missingBuiltIns = {
|
|
23
|
-
...newPrimitivies,
|
|
24
|
-
'typed-array': 'window.Int8Array',
|
|
25
|
-
'uint8-array': 'window.Uint8Array',
|
|
26
|
-
string: 'window.String',
|
|
27
|
-
array: 'window.Array',
|
|
28
|
-
object: 'window.Object',
|
|
29
|
-
math: 'window.Math',
|
|
30
|
-
function: 'window.Function',
|
|
31
|
-
json: 'window.JSON',
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
// Exclude fetch builtin, because its treated as object.constructor
|
|
35
|
-
const excludedBuiltIns = ['fetch'];
|
|
36
|
-
const isBuiltInExcluded = (builtInName) => excludedBuiltIns.includes(builtInName);
|
|
37
|
-
|
|
38
|
-
// Exclude iterators
|
|
39
|
-
// we do not provide polyfills for them and their support check is much more complicated
|
|
40
|
-
// es.iterator, es.async-iterator, esnext.async-iterator, esnext.iterator
|
|
41
|
-
const isSpecExcluded = (specName) =>
|
|
42
|
-
/(es(next)?)?\.(async-)?iterator/.test(specName) || ignoredPolyfills.includes(specName);
|
|
43
|
-
|
|
44
|
-
const specToFeatureDict = {};
|
|
45
|
-
function _addFeature(specName: string, primitive: string, method: string, isInstance: boolean) {
|
|
46
|
-
if (specToFeatureDict[specName]) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
let checkExpression = isInstance
|
|
51
|
-
? `'${method}' in ${primitive}.prototype`
|
|
52
|
-
: `${primitive}.${method}`;
|
|
53
|
-
|
|
54
|
-
// For new primitives, we add a check for the existence of the primitive itself.
|
|
55
|
-
// for example WeakMap && WeakMap.from
|
|
56
|
-
// since WeakMap itself may not be supported in the browser, WeakMap check support may also be required
|
|
57
|
-
const isPrimitiveNew = Boolean(Object.values(newPrimitivies).includes(primitive));
|
|
58
|
-
if (isPrimitiveNew) {
|
|
59
|
-
checkExpression = `${primitive} && ${checkExpression}`;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
specToFeatureDict[specName] = checkExpression;
|
|
63
|
-
specToFeatureDict[specName.replace('es.', 'esnext.')] = checkExpression;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const addStaticFeature = (specName: string, primitive: string, method: string) =>
|
|
67
|
-
_addFeature(specName, primitive, method, false);
|
|
68
|
-
const addInstanceFeature = (specName: string, primitive: string, method: string) =>
|
|
69
|
-
_addFeature(specName, primitive, method, true);
|
|
70
|
-
|
|
71
|
-
const methods = {};
|
|
72
|
-
function addMethod(specName, expression) {
|
|
73
|
-
methods[specName] = expression;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const instanceMethods = new Set(['web.url.to-json']);
|
|
77
|
-
const globals = new Set();
|
|
78
|
-
function _addGlobal(globalList: string[], isInstance: boolean) {
|
|
79
|
-
globalList.forEach((globalSpecName) => {
|
|
80
|
-
globals.add(globalSpecName);
|
|
81
|
-
|
|
82
|
-
if (isInstance) {
|
|
83
|
-
instanceMethods.add(globalSpecName);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
const addInstanceGlobal = (globalList: string[]) => _addGlobal(globalList, true);
|
|
88
|
-
const addGlobal = (globalList: string[]) => _addGlobal(globalList, false);
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* For conversion, a dictionary of the form `spec: feature` needs to be created
|
|
92
|
-
* we use a file from babel-plugin-polyfill-corejs3 for this - https://github.com/babel/babel-polyfills/blob/main/packages/babel-plugin-polyfill-corejs3/src/built-in-definitions.ts
|
|
93
|
-
* as a result we get dictinary like { 'es.array.at: 'Array.prototype.at', 'es.object.assign': 'Object.assign' }
|
|
94
|
-
*/
|
|
95
|
-
export function getSpecToFeatureDict(): Record<string, string> {
|
|
96
|
-
const { BuiltIns, InstanceProperties, StaticProperties } = definitions;
|
|
97
|
-
|
|
98
|
-
// JS primitives: Number, Reflect, Set, Map...
|
|
99
|
-
const builtIns = Object.keys(BuiltIns).reduce((acc, builtInKey) => {
|
|
100
|
-
const { name: builtInName, global } = BuiltIns[builtInKey];
|
|
101
|
-
|
|
102
|
-
if (isBuiltInExcluded(builtInKey)) return acc;
|
|
103
|
-
|
|
104
|
-
addGlobal(global);
|
|
105
|
-
|
|
106
|
-
const removeBaseMethodNames = (builtInName) =>
|
|
107
|
-
builtInName.replace('.constructor', '').replace('.to-string', '');
|
|
108
|
-
|
|
109
|
-
acc[removeBaseMethodNames(builtInName)] = `window.${builtInKey}`;
|
|
110
|
-
acc[removeBaseMethodNames(builtInName).replace('es.', 'esnext.')] = `window.${builtInKey}`;
|
|
111
|
-
|
|
112
|
-
return acc;
|
|
113
|
-
}, {});
|
|
114
|
-
|
|
115
|
-
// Some primitives are missing, so we add them manually
|
|
116
|
-
Object.keys(missingBuiltIns).forEach((missingBuiltInName) => {
|
|
117
|
-
builtIns[`es.${missingBuiltInName}`] = `${missingBuiltIns[missingBuiltInName]}`;
|
|
118
|
-
builtIns[`esnext.${missingBuiltInName}`] = `${missingBuiltIns[missingBuiltInName]}`;
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
function parseSpec(spec: string) {
|
|
122
|
-
// es.string.push
|
|
123
|
-
const splitName = spec.split('.');
|
|
124
|
-
// es.string
|
|
125
|
-
const builtInName = splitName.slice(0, -1).join('.');
|
|
126
|
-
// String
|
|
127
|
-
const primitiveExpr = builtIns[builtInName];
|
|
128
|
-
// push
|
|
129
|
-
const methodName = splitName.at(-1);
|
|
130
|
-
|
|
131
|
-
return {
|
|
132
|
-
builtInName,
|
|
133
|
-
primitiveExpr,
|
|
134
|
-
methodName,
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// Instance methods, for example [1, 2, 3].at(), 'some_string'.toLowerCase()...
|
|
139
|
-
Object.keys(InstanceProperties).forEach((instancePropertyName) => {
|
|
140
|
-
const { name: instanceSpecName, global } = InstanceProperties[instancePropertyName];
|
|
141
|
-
if (isSpecExcluded(instanceSpecName)) return;
|
|
142
|
-
|
|
143
|
-
const { primitiveExpr, methodName } = parseSpec(instanceSpecName);
|
|
144
|
-
|
|
145
|
-
addMethod(methodName, instancePropertyName);
|
|
146
|
-
addInstanceGlobal(global);
|
|
147
|
-
|
|
148
|
-
// Some instance methods have no parent
|
|
149
|
-
// for example Symbol.constructor is es.Symbol
|
|
150
|
-
if (!primitiveExpr) return;
|
|
151
|
-
|
|
152
|
-
addInstanceFeature(instanceSpecName, primitiveExpr, instancePropertyName);
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
// Static methods for example Object.assign(), RegExp.escape()...
|
|
156
|
-
Object.keys(StaticProperties).forEach((primitiveName) => {
|
|
157
|
-
const staticPrimitiveProperties = StaticProperties[primitiveName];
|
|
158
|
-
|
|
159
|
-
Object.keys(staticPrimitiveProperties).forEach((staticPropertyName) => {
|
|
160
|
-
const { name: staticSpecName, global } = staticPrimitiveProperties[staticPropertyName];
|
|
161
|
-
if (isSpecExcluded(staticSpecName)) return;
|
|
162
|
-
|
|
163
|
-
const { methodName } = parseSpec(staticSpecName);
|
|
164
|
-
addGlobal(global);
|
|
165
|
-
addMethod(methodName, staticPropertyName);
|
|
166
|
-
|
|
167
|
-
// For some reason, several static properties have names that match a builtin
|
|
168
|
-
// we ignore such properties since their support in browsers appeared at the same time as the builtin itself
|
|
169
|
-
// for example Promise and Promise.all
|
|
170
|
-
if (builtIns[staticSpecName]) return;
|
|
171
|
-
|
|
172
|
-
addStaticFeature(staticSpecName, primitiveName, staticPropertyName);
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
function isFeatureExists(specName) {
|
|
177
|
-
return Boolean(builtIns[specName]) || Boolean(specToFeatureDict[specName]);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// Each spec has a list of globals, which also need to be converted into an expression for support check
|
|
181
|
-
// but not all globals can have their method name determined unambiguously
|
|
182
|
-
[...globals].forEach((globalSpecName: string) => {
|
|
183
|
-
if (!isFeatureExists(globalSpecName)) {
|
|
184
|
-
if (isSpecExcluded(globalSpecName)) return;
|
|
185
|
-
|
|
186
|
-
const { methodName, primitiveExpr, builtInName } = parseSpec(globalSpecName);
|
|
187
|
-
|
|
188
|
-
// es.array-buffer.from
|
|
189
|
-
const globalNameSplit = globalSpecName.split('.');
|
|
190
|
-
|
|
191
|
-
// Trying to find a support check expression for a method from the already bypassed spec
|
|
192
|
-
// for example, array and typed-array have the findLastIndex method, but typed-array is listed in global
|
|
193
|
-
const featureMethod = methodName === 'constructor' ? 'constructor' : methods[methodName];
|
|
194
|
-
|
|
195
|
-
// We consider a method to be simple if its name does not contain a '-'
|
|
196
|
-
// every, filter, map can be left as it is, the method in the language is called the same way
|
|
197
|
-
const isMethodSimple = !/-/.test(methodName);
|
|
198
|
-
|
|
199
|
-
// Primitives don't have a method, so its length is 2
|
|
200
|
-
// for example es.symbol или es.string
|
|
201
|
-
const isPrimitive = globalNameSplit.length === 2;
|
|
202
|
-
if (isPrimitive) {
|
|
203
|
-
builtIns[globalSpecName] = `${BuiltIns[globalSpecName]}`;
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// Trying to determine the type of method from global static or instance
|
|
208
|
-
const globalInstancePrimitives = [
|
|
209
|
-
'es.array-buffer',
|
|
210
|
-
'es.typed-array',
|
|
211
|
-
'es.symbol',
|
|
212
|
-
'web.url-search-params',
|
|
213
|
-
'esnext.weak-map',
|
|
214
|
-
'esnext.weak-set',
|
|
215
|
-
'uint8-array',
|
|
216
|
-
];
|
|
217
|
-
const isInstanceMethod =
|
|
218
|
-
globalInstancePrimitives.includes(builtInName) || instanceMethods.has(globalSpecName);
|
|
219
|
-
|
|
220
|
-
let method: string;
|
|
221
|
-
if (featureMethod) {
|
|
222
|
-
method = featureMethod;
|
|
223
|
-
} else if (isMethodSimple) {
|
|
224
|
-
method = methodName;
|
|
225
|
-
} else if (primitiveExpr) {
|
|
226
|
-
// couldn't find a similar method in the original list and it contains '-'
|
|
227
|
-
// speculatively translating it to camelCase web.url.can-parse => URL.canParse
|
|
228
|
-
method = camelCaseName(methodName);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
isInstanceMethod
|
|
232
|
-
? addInstanceFeature(globalSpecName, primitiveExpr, method)
|
|
233
|
-
: addStaticFeature(globalSpecName, primitiveExpr, method);
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
return fixBrokenSpec({ ...builtIns, ...specToFeatureDict });
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
function fixBrokenSpec(specs: Record<string, string>) {
|
|
241
|
-
specs['es.string.italics'] = "'italics' in window.String.prototype";
|
|
242
|
-
return specs;
|
|
243
|
-
}
|
package/src/models/analytics.ts
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import type { Visitor } from 'universal-analytics';
|
|
2
|
-
import ua from 'universal-analytics';
|
|
3
|
-
import isString from '@tinkoff/utils/is/string';
|
|
4
|
-
import { performance } from 'perf_hooks';
|
|
5
|
-
|
|
6
|
-
interface Event {
|
|
7
|
-
name: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface ActionEvent extends Event {
|
|
11
|
-
category: 'command' | 'task';
|
|
12
|
-
executionTime?: number;
|
|
13
|
-
label?: string;
|
|
14
|
-
parameters?: any;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface ErrorEvent extends Event {
|
|
18
|
-
errorMessage?: string;
|
|
19
|
-
errorStatus?: number;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export class Analytics {
|
|
23
|
-
private readonly enabled: boolean;
|
|
24
|
-
|
|
25
|
-
private visitor: Visitor;
|
|
26
|
-
|
|
27
|
-
private trackErrorInternal = ({ name, errorMessage, errorStatus }: ErrorEvent, resolve) => {
|
|
28
|
-
if (!this.enabled) {
|
|
29
|
-
resolve();
|
|
30
|
-
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
this.visitor.event('error', name, errorMessage, errorStatus).send(resolve);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
private trackCommandInternal = (
|
|
38
|
-
{ name, executionTime, label, parameters, category }: ActionEvent,
|
|
39
|
-
resolve
|
|
40
|
-
) => {
|
|
41
|
-
if (!this.enabled) {
|
|
42
|
-
resolve();
|
|
43
|
-
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const path = [category, name, label].join('/');
|
|
48
|
-
const event = this.visitor
|
|
49
|
-
.screenview({ cd: path })
|
|
50
|
-
.event(category, name, isString(parameters) ? parameters : JSON.stringify(parameters));
|
|
51
|
-
if (executionTime) {
|
|
52
|
-
event.timing(category, name, Math.floor(executionTime));
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
event.send(resolve);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
private trackTimingInternal = ({ name, executionTime, category }: ActionEvent, resolve) => {
|
|
59
|
-
if (!this.enabled) {
|
|
60
|
-
resolve();
|
|
61
|
-
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
this.visitor.timing(category, name, Math.floor(executionTime)).send(resolve);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
private readonly trackError = this.promisify(this.trackErrorInternal);
|
|
69
|
-
|
|
70
|
-
private readonly track = this.promisify(this.trackCommandInternal);
|
|
71
|
-
|
|
72
|
-
private readonly trackTiming = this.promisify(this.trackTimingInternal);
|
|
73
|
-
|
|
74
|
-
constructor({ trackingCode, packageInfo: { name, version }, enabled }) {
|
|
75
|
-
this.enabled = enabled ?? false;
|
|
76
|
-
|
|
77
|
-
if (this.enabled) {
|
|
78
|
-
this.visitor = ua(trackingCode);
|
|
79
|
-
|
|
80
|
-
this.visitor.set('ds', 'app');
|
|
81
|
-
this.visitor.set('an', name);
|
|
82
|
-
this.visitor.set('av', version);
|
|
83
|
-
this.visitor.set('aid', 'tramvai-cli');
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
trackAfter(actionEvent: ActionEvent) {
|
|
88
|
-
const startedAt = performance.now();
|
|
89
|
-
const trackingPromise = this.track(actionEvent);
|
|
90
|
-
return async <TResult>(promise: Promise<TResult>): Promise<TResult> => {
|
|
91
|
-
try {
|
|
92
|
-
const result = await promise;
|
|
93
|
-
return Promise.all([
|
|
94
|
-
trackingPromise,
|
|
95
|
-
this.trackTiming({ ...actionEvent, executionTime: performance.now() - startedAt }),
|
|
96
|
-
]).then(() => result);
|
|
97
|
-
} catch (e) {
|
|
98
|
-
return this.trackError({
|
|
99
|
-
name: actionEvent.name,
|
|
100
|
-
errorMessage: e.name,
|
|
101
|
-
errorStatus: e.status,
|
|
102
|
-
}).then(() => {
|
|
103
|
-
throw e;
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
private promisify<TEvent>(func: (event: TEvent, resolve: any, ...args) => void) {
|
|
110
|
-
return function promisified(event: TEvent, ...args): Promise<void> {
|
|
111
|
-
return new Promise((resolve) => func(event, resolve, ...args));
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// tslint:disable-line member-ordering
|
|
116
|
-
}
|
package/src/typings/pwa/index.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
export type WebManifestOptions = {
|
|
2
|
-
/**
|
|
3
|
-
* @title Create webmanifest file
|
|
4
|
-
* @default false
|
|
5
|
-
*/
|
|
6
|
-
enabled?: boolean;
|
|
7
|
-
/**
|
|
8
|
-
* @title Name of generated manifest file (will be placed in "output.client" directory). You can use `[hash]` placeholder for manifest cache busting in production mode
|
|
9
|
-
* @default "/manifest.[hash].json"
|
|
10
|
-
*/
|
|
11
|
-
dest?: string;
|
|
12
|
-
/**
|
|
13
|
-
* @title prefer to use "pwa.sw.scope" instead, this field will be generated automatically
|
|
14
|
-
*/
|
|
15
|
-
scope?: string;
|
|
16
|
-
name?: string;
|
|
17
|
-
short_name?: string;
|
|
18
|
-
description?: string;
|
|
19
|
-
// @todo - example or default with `/?standalone=true`?
|
|
20
|
-
start_url?: string;
|
|
21
|
-
display?: string;
|
|
22
|
-
/**
|
|
23
|
-
* @title prefer to use "pwa.meta.themeColor" instead, this field will be generated automatically
|
|
24
|
-
*/
|
|
25
|
-
theme_color?: string;
|
|
26
|
-
background_color?: string;
|
|
27
|
-
/**
|
|
28
|
-
* @title prefer to use "pwa.icon" instead, this field will be generated automatically
|
|
29
|
-
*/
|
|
30
|
-
icons?: Array<PwaIconItem>;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export type PwaIconItem = {
|
|
34
|
-
src: string;
|
|
35
|
-
sizes: string;
|
|
36
|
-
type?: string;
|
|
37
|
-
density?: number;
|
|
38
|
-
purpose?: string;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export type PwaIconOptions = {
|
|
42
|
-
/**
|
|
43
|
-
* @title Path to icon file (relative to "root" directory)
|
|
44
|
-
*/
|
|
45
|
-
src: string;
|
|
46
|
-
/**
|
|
47
|
-
* @title Folder for generated icons (will be placed in "output.client" directory)
|
|
48
|
-
* @default "pwa-icons"
|
|
49
|
-
*/
|
|
50
|
-
dest?: string;
|
|
51
|
-
/**
|
|
52
|
-
* @title Icon sizes
|
|
53
|
-
* @default [36, 48, 72, 96, 144, 192, 512]
|
|
54
|
-
*/
|
|
55
|
-
sizes?: number[];
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export type PwaMetaOptions = {
|
|
59
|
-
/**
|
|
60
|
-
* @title "viewport" meta tag
|
|
61
|
-
*/
|
|
62
|
-
viewport?: string;
|
|
63
|
-
/**
|
|
64
|
-
* @title "theme-color" meta tag
|
|
65
|
-
*/
|
|
66
|
-
themeColor?: string;
|
|
67
|
-
/**
|
|
68
|
-
* @title "mobile-web-app-capable" meta tag
|
|
69
|
-
*/
|
|
70
|
-
mobileApp?: string;
|
|
71
|
-
/**
|
|
72
|
-
* @title "apple-mobile-web-app-capable" meta tag
|
|
73
|
-
*/
|
|
74
|
-
mobileAppIOS?: string;
|
|
75
|
-
/**
|
|
76
|
-
* @title "apple-mobile-web-app-title" meta tag
|
|
77
|
-
*/
|
|
78
|
-
appleTitle?: string;
|
|
79
|
-
/**
|
|
80
|
-
* @title "apple-mobile-web-app-status-bar-style" meta tag
|
|
81
|
-
*/
|
|
82
|
-
appleStatusBarStyle?: string;
|
|
83
|
-
};
|