useblocks-cli 1.1.46 → 1.1.49

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.
Files changed (2) hide show
  1. package/dist/index.js +244 -139
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -51,7 +51,7 @@ var ROOT_DIR$2 = (0, path.resolve)(__dirname, "../../..");
51
51
  (0, path.resolve)(ROOT_DIR$2, "./packages");
52
52
  (0, path.resolve)(ROOT_DIR$2, "./local_modules");
53
53
  (0, path.resolve)(ROOT_DIR$2, "./build");
54
- (0, path.resolve)(ROOT_DIR$2, "index.html"), (0, path.resolve)(ROOT_DIR$2, "src/index.tsx"), (0, path.resolve)(ROOT_DIR$2, "src/plugin/loader/index.ts"), (0, path.resolve)(ROOT_DIR$2, "src/plugin/core/entry.ts"), (0, path.resolve)(ROOT_DIR$2, "iframe"), (0, path.resolve)(ROOT_DIR$2, "iframe/iframe.html"), (0, path.resolve)(ROOT_DIR$2, "iframe/iframe-eblock.html"), (0, path.resolve)(ROOT_DIR$2, "public"), (0, path.resolve)(ROOT_DIR$2, "src/pluginExamples"), (0, path.resolve)(ROOT_DIR$2, "src/extensions"), (0, path.resolve)(ROOT_DIR$2, "src/tsconfig.json"), (0, path.resolve)(ROOT_DIR$2, "src/tsconfig.json"), (0, path.resolve)(ROOT_DIR$2, "src"), (0, path.resolve)(ROOT_DIR$2, "iframe/tsconfig.json"), (0, path.resolve)(ROOT_DIR$2, "src/extensions/api/src/index.ts"), (0, path.resolve)(ROOT_DIR$2, "src/extensions/react/src/index.ts"), (0, path.resolve)(ROOT_DIR$2, "src/assets/images/atoms"), (0, path.resolve)(ROOT_DIR$2, "src/assets"), (0, path.resolve)(ROOT_DIR$2, "src"), (0, path.resolve)(ROOT_DIR$2, "packages/extensions-core/identifiers"), (0, path.resolve)(ROOT_DIR$2, "src/app/identifiers"), (0, path.resolve)(ROOT_DIR$2, "src/plugin/pluginRegistry"), (0, path.resolve)(ROOT_DIR$2, "src/constants/errors"), (0, path.resolve)(ROOT_DIR$2, "src/helpers/shared/mapHttpStatusToErrorCode"), (0, path.resolve)(ROOT_DIR$2, "src/plugin/const"), (0, path.resolve)(ROOT_DIR$2, "src/helpers/guid"), (0, path.resolve)(ROOT_DIR$2, "src/plugin/utils/waitForElement"), (0, path.resolve)(ROOT_DIR$2, "src/plugin/mixins/auth"), (0, path.resolve)(ROOT_DIR$2, "src/plugin/mixins/base");
54
+ (0, path.resolve)(ROOT_DIR$2, "index.html"), (0, path.resolve)(ROOT_DIR$2, "src/index.tsx"), (0, path.resolve)(ROOT_DIR$2, "src/plugin/loader/index.ts"), (0, path.resolve)(ROOT_DIR$2, "src/plugin/core/entry.ts"), (0, path.resolve)(ROOT_DIR$2, "iframe"), (0, path.resolve)(ROOT_DIR$2, "iframe/iframe.html"), (0, path.resolve)(ROOT_DIR$2, "iframe/iframe-eblock.html"), (0, path.resolve)(ROOT_DIR$2, "public"), (0, path.resolve)(ROOT_DIR$2, "src/pluginExamples"), (0, path.resolve)(ROOT_DIR$2, "src/extensions"), (0, path.resolve)(ROOT_DIR$2, "src/tsconfig.json"), (0, path.resolve)(ROOT_DIR$2, "tsconfig.types.json"), (0, path.resolve)(ROOT_DIR$2, "src"), (0, path.resolve)(ROOT_DIR$2, "iframe/tsconfig.json"), (0, path.resolve)(ROOT_DIR$2, "src/extensions/api/src/index.ts"), (0, path.resolve)(ROOT_DIR$2, "src/extensions/react/src/index.ts"), (0, path.resolve)(ROOT_DIR$2, "src/assets/images/atoms"), (0, path.resolve)(ROOT_DIR$2, "src/assets"), (0, path.resolve)(ROOT_DIR$2, "src"), (0, path.resolve)(ROOT_DIR$2, "packages/extensions-core/identifiers"), (0, path.resolve)(ROOT_DIR$2, "src/app/identifiers"), (0, path.resolve)(ROOT_DIR$2, "src/plugin/pluginRegistry"), (0, path.resolve)(ROOT_DIR$2, "src/constants/errors"), (0, path.resolve)(ROOT_DIR$2, "src/helpers/shared/mapHttpStatusToErrorCode"), (0, path.resolve)(ROOT_DIR$2, "src/plugin/const"), (0, path.resolve)(ROOT_DIR$2, "src/helpers/guid"), (0, path.resolve)(ROOT_DIR$2, "src/plugin/utils/waitForElement"), (0, path.resolve)(ROOT_DIR$2, "src/plugin/mixins/auth"), (0, path.resolve)(ROOT_DIR$2, "src/plugin/mixins/base");
55
55
  (0, path.resolve)(ROOT_DIR$2, "apps/widget/saas/index.tsx"), (0, path.resolve)(ROOT_DIR$2, "apps/widget/lib/entries/loader.ts"), (0, path.resolve)(ROOT_DIR$2, "apps/widget/lib/entries/core.ts"), (0, path.resolve)(ROOT_DIR$2, "iframe"), (0, path.resolve)(ROOT_DIR$2, "iframe/iframe.html"), (0, path.resolve)(ROOT_DIR$2, "iframe/iframe-eblock.html"), (0, path.resolve)(ROOT_DIR$2, "apps/widget/public"), (0, path.resolve)(ROOT_DIR$2, "apps/widget/lib/pluginExamples"), (0, path.resolve)(ROOT_DIR$2, "apps/widget/extensions"), (0, path.resolve)(ROOT_DIR$2, "apps/widget"), (0, path.resolve)(ROOT_DIR$2, "apps/widget/lib/tsconfig.json"), (0, path.resolve)(ROOT_DIR$2, "apps/widget/tsconfig.json"), (0, path.resolve)(ROOT_DIR$2, "apps/widget"), (0, path.resolve)(ROOT_DIR$2, "iframe/tsconfig.json"), (0, path.resolve)(ROOT_DIR$2, "apps/widget/extensions/api/src/index.ts"), (0, path.resolve)(ROOT_DIR$2, "apps/widget/src/assets"), (0, path.resolve)(ROOT_DIR$2, "apps/widget/src"), (0, path.resolve)(ROOT_DIR$2, "apps/widget/lib/pluginRuntime");
56
56
  (0, path.resolve)(ROOT_DIR$2, "iframe/js/extensions/api/src/index.ts"), (0, path.resolve)(ROOT_DIR$2, "packages/ui-kit/src"), (0, path.resolve)(ROOT_DIR$2, "packages/ui-kit/src/index.ts"), (0, path.resolve)(ROOT_DIR$2, "packages/ui-kit/public"), (0, path.resolve)(ROOT_DIR$2, "build-tools/config/runtime"), (0, path.resolve)(ROOT_DIR$2, "packages/core-loader/src"), (0, path.resolve)(ROOT_DIR$2, "build-tools/plugins/loaders/loaders/amd-loader.js");
57
57
  path.default.resolve(__dirname, "../../..");
@@ -243,7 +243,7 @@ var DEFAULT_UI_TEXT = {
243
243
  promptStandModeReactAdapter: "React adapter",
244
244
  promptStandModeAdvanced: "Advanced scenarios",
245
245
  promptStandModeResourceProxy: "Resource proxy demo",
246
- promptStandModeAngular: "Angular + CustomWebpack",
246
+ promptStandModeAngular: "Angular + CustomWebpack (publicPath repro)",
247
247
  promptStandModeAngularEsbuild: "Angular + CustomEsbuild",
248
248
  standAngularWebpackOnly: "Angular demo stand is supported only with the webpack bundler.",
249
249
  standAngularEsbuildBundlerOnly: "Angular CustomEsbuild demo stand uses webpack only as the CLI routing flag.",
@@ -255,6 +255,7 @@ var DEFAULT_UI_TEXT = {
255
255
  promptAdvancedProfileShadowDom: "Shadow DOM (closed / hard mode)",
256
256
  promptAdvancedProfileUmd: "UMD bundle via page script tag",
257
257
  promptAdvancedProfileMemoryUsage: "Memory usage test (local-only repro stand)",
258
+ promptAdvancedProfileModuleFederation: "Module Federation host + remote (local-only stand)",
258
259
  promptOutputDir: "Where should the project be created?",
259
260
  promptOutputDirValidate: "Specify an output directory",
260
261
  helpInteractive: "Run the interactive project creation wizard",
@@ -327,6 +328,7 @@ var DEFAULT_UI_TEXT = {
327
328
  promptStartModeRelease: "Production-like check (build + host using built assets)",
328
329
  promptStandStartModeDebug: "Development (dev server, /api proxy, live reload)",
329
330
  promptStandStartModeRelease: "Production-like (build + static server)",
331
+ promptStandStartModeRepro: "Repro: rebundle + cross-origin chunks",
330
332
  credentialsTitle: "CREDENTIALS REQUIRED",
331
333
  credentialsOAuth: "Fill in clientId and clientSecret in src/dev/oauthCredentials.ts.",
332
334
  credentialsStandalone: "Fill in standaloneKey in src/dev/standaloneCredentials.ts.",
@@ -336,11 +338,13 @@ var DEFAULT_UI_TEXT = {
336
338
  autoStart: "Starting the project...",
337
339
  autoStartDebug: "Starting the debug mode...",
338
340
  autoStartRelease: "Starting the production-like smoke test...",
341
+ autoStartRepro: "Starting publicPath repro (rebundle + cross-origin chunks)...",
339
342
  nextStepFillCredentials: "Fill in credentials:",
340
343
  nextStepAlreadyInstalled: "Dependencies are already installed.",
341
344
  nextStepServerStarting: "The dev server is starting in the project directory.",
342
345
  nextStepServerStartingDebug: "The debug host is starting in the project directory.",
343
- nextStepServerStartingRelease: "The production-like smoke test is starting in the project directory."
346
+ nextStepServerStartingRelease: "The production-like smoke test is starting in the project directory.",
347
+ nextStepServerStartingRepro: "PublicPath repro is starting (rebundle build + cross-origin chunk servers)."
344
348
  };
345
349
  //#endregion
346
350
  //#region lib/cli/messages.ts
@@ -414,9 +418,9 @@ var DEFAULT_EXTENSIONS_API_PACKAGE = "useblocks-extensions-api";
414
418
  var DEFAULT_EXTENSIONS_REACT_PACKAGE = "useblocks-extensions-react";
415
419
  var DEFAULT_EXTENSIONS_SANDBOX_PACKAGE = "useblocks-extensions-sandbox";
416
420
  var DEFAULT_CLI_PACKAGE = "useblocks-cli";
417
- var DEFAULT_VERSION = "1.1.46";
418
- var DEFAULT_UI_KIT_VERSION = "1.1.46";
419
- var DEFAULT_CLI_VERSION = "1.1.46";
421
+ var DEFAULT_VERSION = "1.1.49";
422
+ var DEFAULT_UI_KIT_VERSION = "1.1.49";
423
+ var DEFAULT_CLI_VERSION = "1.1.49";
420
424
  var DEFAULT_OPENAPI_BASE_URL = "https://app.useblocks.io/api";
421
425
  var DEFAULT_CDN_URL = "https://cdn.useblocks.io";
422
426
  var DEFAULT_BACKEND_DOMAIN = "api.useblocks.io";
@@ -670,7 +674,7 @@ var DEMO_STAND_MODE_CHOICES = [
670
674
  ];
671
675
  var RESOURCE_PROXY_AUTH_CHOICES = ["oauth", "standalone"];
672
676
  /** Профили, доступные только при локальной сборке (vite). */
673
- var LOCAL_ONLY_ADVANCED_PROFILE_CHOICES = ["memory-usage"];
677
+ var LOCAL_ONLY_ADVANCED_PROFILE_CHOICES = ["memory-usage", "module-federation"];
674
678
  var ADVANCED_PROFILE_CHOICES = [
675
679
  "subpath",
676
680
  "shadow-dom",
@@ -678,6 +682,15 @@ var ADVANCED_PROFILE_CHOICES = [
678
682
  ...LOCAL_ONLY_ADVANCED_PROFILE_CHOICES
679
683
  ];
680
684
  //#endregion
685
+ //#region lib/cli/advancedProfileVisibility.ts
686
+ function getVisibleAdvancedProfileChoices(options = {}) {
687
+ return ADVANCED_PROFILE_CHOICES.filter((value) => {
688
+ if (!LOCAL_ONLY_ADVANCED_PROFILE_CHOICES.includes(value)) return true;
689
+ if (!options.localTest) return false;
690
+ return !options.bundler || options.bundler === "vite";
691
+ });
692
+ }
693
+ //#endregion
681
694
  //#region lib/cli/suggestProjectName.ts
682
695
  function getTemplateSlug(options) {
683
696
  if (options.kind === "demo-stand") {
@@ -855,12 +868,6 @@ function deriveRuntimeModeFromTarget(target, advancedTarget) {
855
868
  default: return target;
856
869
  }
857
870
  }
858
- function getVisibleAdvancedProfileChoices(options = {}) {
859
- return ADVANCED_PROFILE_CHOICES.filter((value) => {
860
- if (!LOCAL_ONLY_ADVANCED_PROFILE_CHOICES.includes(value)) return true;
861
- return Boolean(options.localTest) && options.bundler === "vite";
862
- });
863
- }
864
871
  function normalizeProjectOptions(options) {
865
872
  normalizeLegacyKind(options);
866
873
  if (options.appName != null && options.appName !== "") options.appName = String(options.appName).trim();
@@ -892,7 +899,7 @@ function assertValidProjectOptions(options, messages) {
892
899
  if (options.standMode === "advanced") {
893
900
  if (!options.advancedProfile) throw new Error(messages.requiredAdvancedProfile);
894
901
  if (!ADVANCED_PROFILE_CHOICES.includes(options.advancedProfile)) throw new Error(messages.invalidAdvancedProfile(options.advancedProfile));
895
- if (options.advancedProfile === "memory-usage" && bundler !== "vite") throw new Error(messages.advancedProfileViteOnly(options.advancedProfile));
902
+ if ((options.advancedProfile === "memory-usage" || options.advancedProfile === "module-federation") && bundler !== "vite") throw new Error(messages.advancedProfileViteOnly(options.advancedProfile));
896
903
  if (!getVisibleAdvancedProfileChoices(options).includes(options.advancedProfile)) throw new Error(messages.advancedProfileLocalOnly(options.advancedProfile));
897
904
  }
898
905
  options.preset = "minimal";
@@ -993,7 +1000,7 @@ function getPresetChoicesForOptions(messages, options = {}) {
993
1000
  }
994
1001
  function getAdvancedProfileChoices(messages, options = {}) {
995
1002
  return getVisibleAdvancedProfileChoices(options).map((value) => ({
996
- title: value === "shadow-dom" ? messages.promptAdvancedProfileShadowDom : value === "umd" ? messages.promptAdvancedProfileUmd : value === "memory-usage" ? messages.promptAdvancedProfileMemoryUsage : messages.promptAdvancedProfileSubpath,
1003
+ title: value === "shadow-dom" ? messages.promptAdvancedProfileShadowDom : value === "umd" ? messages.promptAdvancedProfileUmd : value === "memory-usage" ? messages.promptAdvancedProfileMemoryUsage : value === "module-federation" ? messages.promptAdvancedProfileModuleFederation : messages.promptAdvancedProfileSubpath,
997
1004
  value
998
1005
  }));
999
1006
  }
@@ -1050,19 +1057,6 @@ async function promptForMissingOptions(initialOptions, messages) {
1050
1057
  }, { onCancel: cancelPrompt });
1051
1058
  if (response.resourceProxyAuth) options.resourceProxyAuth = response.resourceProxyAuth;
1052
1059
  }
1053
- if (options.kind === "demo-stand" && options.standMode === "advanced" && !options.advancedProfile) {
1054
- const response = await (0, prompts.default)({
1055
- type: "select",
1056
- name: "advancedProfile",
1057
- message: messages.promptAdvancedProfile,
1058
- choices: getAdvancedProfileChoices(messages, options),
1059
- initial: 0
1060
- }, { onCancel: cancelPrompt });
1061
- if (response.advancedProfile) {
1062
- options.advancedProfile = response.advancedProfile;
1063
- options.qaProfile = response.advancedProfile;
1064
- }
1065
- }
1066
1060
  if (options.kind === "demo-stand" && (options.standMode === "angular" || options.standMode === "angular-esbuild") && !options.bundler) options.bundler = "webpack";
1067
1061
  if (!options.bundler) {
1068
1062
  const response = await (0, prompts.default)({
@@ -1080,6 +1074,19 @@ async function promptForMissingOptions(initialOptions, messages) {
1080
1074
  }, { onCancel: cancelPrompt });
1081
1075
  if (response.bundler) options.bundler = response.bundler;
1082
1076
  }
1077
+ if (options.kind === "demo-stand" && options.standMode === "advanced" && !options.advancedProfile) {
1078
+ const response = await (0, prompts.default)({
1079
+ type: "select",
1080
+ name: "advancedProfile",
1081
+ message: messages.promptAdvancedProfile,
1082
+ choices: getAdvancedProfileChoices(messages, options),
1083
+ initial: 0
1084
+ }, { onCancel: cancelPrompt });
1085
+ if (response.advancedProfile) {
1086
+ options.advancedProfile = response.advancedProfile;
1087
+ options.qaProfile = response.advancedProfile;
1088
+ }
1089
+ }
1083
1090
  if (options.kind === "plugin" && !options.target && options.bundler) {
1084
1091
  const response = await (0, prompts.default)({
1085
1092
  type: "select",
@@ -1455,7 +1462,7 @@ var ROOT_PKG = {
1455
1462
  packageManager: "pnpm@11.4.0",
1456
1463
  dependencies: {
1457
1464
  "@easylogic/colorpicker": "1.10.7",
1458
- "@emailmaker/filemanager": "^0.10.95",
1465
+ "@emailmaker/filemanager": "^0.10.96",
1459
1466
  "@emailmaker/ui-kit": "workspace:*",
1460
1467
  "@emailmaker/extensions-api": "workspace:*",
1461
1468
  "@emailmaker/extensions-react": "workspace:*",
@@ -1488,13 +1495,13 @@ var ROOT_PKG = {
1488
1495
  "@monaco-editor/react": "^4.3.1",
1489
1496
  "@react-hook/window-size": "^3.0.7",
1490
1497
  "@react-oauth/google": "^0.12.1",
1491
- "@reduxjs/toolkit": "^1.9.3",
1498
+ "@reduxjs/toolkit": "^2.12.0",
1492
1499
  "@sentry/browser": "^9.18.0",
1493
1500
  "@sentry/cli": "^2.58.2",
1494
1501
  "@sentry/react": "^10.18.0",
1495
1502
  "@sentry/tracing": "^7.120.3",
1496
1503
  "@testing-library/jest-dom": "^6.1.5",
1497
- "@testing-library/react": "^14.1.2",
1504
+ "@testing-library/react": "^16.3.2",
1498
1505
  "@testing-library/user-event": "^14.5.1",
1499
1506
  "@types/js-cookie": "^3.0.6",
1500
1507
  "@wordpress/i18n": "^4.58.0",
@@ -1516,14 +1523,13 @@ var ROOT_PKG = {
1516
1523
  "eml-parse-js": "^1.1.1",
1517
1524
  "emmet": "^2.3.6",
1518
1525
  "emmet-monaco-es": "file:local_modules/emmet-monaco-es",
1519
- "eslint-plugin-jest": "^29.15.2",
1520
1526
  "event-source-polyfill": "^1.0.31",
1521
1527
  "file-saver": "^2.0.5",
1522
- "html-react-parser": "5.2.11",
1528
+ "html-react-parser": "6.1.4",
1523
1529
  "html2pdf.js": "^0.9.3",
1524
1530
  "i": "^0.3.7",
1525
- "iframe-resizer-react": "^1.1.0",
1526
- "immer": "^9.0.21",
1531
+ "iframe-resizer": "4.4.5",
1532
+ "immer": "^11.1.11",
1527
1533
  "js-cookie": "^3.0.1",
1528
1534
  "js-sha256": "^0.11.0",
1529
1535
  "jszip": "^3.10.1",
@@ -1540,14 +1546,14 @@ var ROOT_PKG = {
1540
1546
  "po2json": "^1.0.0-beta-3",
1541
1547
  "process": "^0.11.10",
1542
1548
  "prop-types": "^15.8.1",
1543
- "react": "18.2.0",
1544
- "react-dom": "18.2.0",
1545
- "react-infinite-scroll-component": "^6.1.0",
1549
+ "react": "19.2.7",
1550
+ "react-dom": "19.2.7",
1551
+ "react-infinite-scroll-component": "^7.2.1",
1546
1552
  "rc-input-number": "^9.5.0",
1547
1553
  "react-masonry-css": "^1.0.16",
1548
- "react-redux": "^7.2.3",
1554
+ "react-redux": "^9.3.0",
1549
1555
  "react-refresh": "^0.18.0",
1550
- "react-router-dom": "^6.4.0",
1556
+ "react-router-dom": "^7.18.1",
1551
1557
  "react-split": "^2.0.13",
1552
1558
  "react-sticky-box": "^1.0.1",
1553
1559
  "react-transition-group": "^4.4.5",
@@ -1585,7 +1591,7 @@ var ROOT_PKG = {
1585
1591
  "cli:browser-smoke:plugins": "tsx build-tools/cli/scripts/e2e/browser-smoke.ts --only-plugins",
1586
1592
  "cli:vite-plugin-matrix": "tsx build-tools/cli/scripts/e2e/vite-plugin-version-matrix.ts",
1587
1593
  "start": "tsx build-tools/pipeline.ts --serve",
1588
- "prepare": "tsx build-tools/scripts/dev/setup-dev-cert.ts --hook",
1594
+ "prepare": "husky && tsx build-tools/scripts/dev/setup-dev-cert.ts --hook",
1589
1595
  "setup:dev-cert": "tsx build-tools/scripts/dev/setup-dev-cert.ts",
1590
1596
  "publish:npm": "node build-tools/scripts/publish/publish-from-manifest.mjs",
1591
1597
  "publish:plan": "tsx build-tools/scripts/publish/publish-plan.ts",
@@ -1597,7 +1603,7 @@ var ROOT_PKG = {
1597
1603
  "test": "pnpm run test:jest && pnpm run test:build-tools",
1598
1604
  "test:jest": "jest",
1599
1605
  "test:build-tools": "jest --config jest.build-tools.config.cjs && pnpm run test:build-tools:node",
1600
- "test:build-tools:node": "tsx --tsconfig build-tools/cli/tsconfig.json --test build-tools/bundler-plugins/src/shared/__tests__/hostPackageEntryMatch.test.ts build-tools/bundler-plugins/src/shared/__tests__/hostPluginDiagnostics.test.ts build-tools/bundler-plugins/src/shared/__tests__/externalizedPackageDetect.test.ts build-tools/bundler-plugins/src/vite/__tests__/vitePluginPublicPath.diagnostics.test.ts build-tools/bundler-plugins/src/webpack/__tests__/webpackPluginMissingPackage.test.ts build-tools/bundler-plugins/src/vite/__tests__/vitePluginMissingPackage.test.ts build-tools/bundler-plugins/src/shared/__tests__/resolvePublishedPackage.test.ts build-tools/bundler-plugins/src/shared/__tests__/facadeSentinel.test.ts build-tools/bundler-plugins/src/shared/__tests__/joinHostPublicPath.test.ts build-tools/bundler-plugins/src/shared/__tests__/hostBootstrapRuntime.test.ts build-tools/plugins/loaders/plugins/__tests__/publicPath.test.ts build-tools/bundler-plugins/src/vite/__tests__/vitePluginPublicPath.test.ts build-tools/bundler-plugins/src/webpack/__tests__/webpackPluginPublicPath.test.ts build-tools/bundler-plugins/src/webpack/__tests__/webpackPluginPublicPath.concat.integration.test.ts build-tools/bundler-plugins/src/shared/__tests__/webpackModuleSource.test.ts build-tools/bundler-plugins/src/shared/__tests__/hostPackageEntryMatch.hypothesis.test.ts build-tools/bundler-plugins/src/webpack/__tests__/webpackPluginPublicPath.hypothesis.test.ts build-tools/cli/lib/__tests__/localTestDirectoryLock.test.ts build-tools/cli/lib/cli/__tests__/normalizeProjectOptions.test.ts build-tools/cli/lib/cli/__tests__/postCreateRunCommands.test.ts build-tools/cli/lib/cli/__tests__/suggestProjectName.test.ts build-tools/cli/lib/template-engine/__tests__/standLayers.test.ts build-tools/cli/lib/template-engine/context/__tests__/assertDistReady.test.ts build-tools/cli/lib/template-engine/context/__tests__/prepareDist.test.ts build-tools/cli/lib/template-engine/context/__tests__/serveDist.test.ts build-tools/cli/lib/template-engine/context/__tests__/standAngularEsbuildPackageJsonData.test.ts build-tools/cli/lib/template-engine/context/__tests__/standAngularPackageJsonData.test.ts build-tools/cli/lib/template-engine/context/__tests__/standReadmeStrings.test.ts build-tools/cli/lib/template-engine/context/__tests__/standScripts.test.ts build-tools/cli/lib/template-engine/emitEtaTree.test.ts build-tools/cli/lib/template-engine/resolveVariantDir.test.ts build-tools/cli/lib/template-engine/context/buildResourceProxyStandPolicy.test.ts build-tools/cli/lib/template-engine/standResourceProxyViteDevHostEta.test.ts build-tools/cli/lib/template-engine/standDevStorageMiddleware.test.ts build-tools/cli/lib/template-engine/standHostDevServerWebpack.test.ts build-tools/cli/project-templates/stand/resource-proxy/vite/config/lib/proxy/__tests__/core.test.ts build-tools/cli/lib/templates/shared/__tests__/legacyReactDependencies.test.ts build-tools/cli/project-templates/plugin/shared-base/scripts/resolvePluginDevPort.test.ts build-tools/config/__tests__/runtimeCoreBuildDefine.test.ts build-tools/config/utils/__tests__/treeshakeConfig.test.ts build-tools/utils/__tests__/normalizeScriptArgv.test.ts build-tools/utils/__tests__/pipelineConcurrency.test.ts build-tools/utils/__tests__/taskResourceMetrics.test.ts",
1606
+ "test:build-tools:node": "tsx --tsconfig build-tools/cli/tsconfig.json --test build-tools/bundler-plugins/src/shared/__tests__/hostPackageEntryMatch.test.ts build-tools/bundler-plugins/src/shared/__tests__/hostPluginDiagnostics.test.ts build-tools/bundler-plugins/src/shared/__tests__/externalizedPackageDetect.test.ts build-tools/bundler-plugins/src/vite/__tests__/vitePluginPublicPath.diagnostics.test.ts build-tools/bundler-plugins/src/webpack/__tests__/webpackPluginMissingPackage.test.ts build-tools/bundler-plugins/src/vite/__tests__/vitePluginMissingPackage.test.ts build-tools/bundler-plugins/src/shared/__tests__/resolvePublishedPackage.test.ts build-tools/bundler-plugins/src/shared/__tests__/facadeSentinel.test.ts build-tools/bundler-plugins/src/shared/__tests__/joinHostPublicPath.test.ts build-tools/bundler-plugins/src/shared/__tests__/hostBootstrapRuntime.test.ts build-tools/plugins/loaders/plugins/__tests__/publicPath.test.ts build-tools/plugins/shared/__tests__/publicPathResolve.test.ts build-tools/plugins/shared-runtime/__tests__/publishBootstrapShim.test.ts build-tools/bundler-plugins/src/vite/__tests__/vitePluginPublicPath.test.ts build-tools/bundler-plugins/src/webpack/__tests__/webpackPluginPublicPath.test.ts build-tools/bundler-plugins/src/webpack/__tests__/webpackPluginPublicPath.concat.integration.test.ts build-tools/bundler-plugins/src/shared/__tests__/webpackModuleSource.test.ts build-tools/bundler-plugins/src/shared/__tests__/hostPackageEntryMatch.hypothesis.test.ts build-tools/bundler-plugins/src/webpack/__tests__/webpackPluginPublicPath.hypothesis.test.ts build-tools/cli/lib/__tests__/localTestDirectoryLock.test.ts build-tools/cli/lib/cli/__tests__/normalizeProjectOptions.test.ts build-tools/cli/lib/cli/__tests__/postCreateRunCommands.test.ts build-tools/cli/lib/cli/__tests__/suggestProjectName.test.ts build-tools/cli/lib/template-engine/__tests__/standLayers.test.ts build-tools/cli/lib/template-engine/context/__tests__/assertDistReady.test.ts build-tools/cli/lib/template-engine/context/__tests__/prepareDist.test.ts build-tools/cli/lib/template-engine/context/__tests__/serveDist.test.ts build-tools/cli/lib/template-engine/context/__tests__/standAngularEsbuildPackageJsonData.test.ts build-tools/cli/lib/template-engine/context/__tests__/standAngularPackageJsonData.test.ts build-tools/cli/lib/template-engine/context/__tests__/standReadmeStrings.test.ts build-tools/cli/lib/template-engine/context/__tests__/standScripts.test.ts build-tools/cli/lib/template-engine/emitEtaTree.test.ts build-tools/cli/lib/template-engine/resolveVariantDir.test.ts build-tools/cli/lib/template-engine/context/buildResourceProxyStandPolicy.test.ts build-tools/cli/lib/template-engine/standResourceProxyViteDevHostEta.test.ts build-tools/cli/lib/template-engine/standDevStorageMiddleware.test.ts build-tools/cli/lib/template-engine/standHostDevServerWebpack.test.ts build-tools/cli/project-templates/stand/resource-proxy/vite/config/lib/proxy/__tests__/core.test.ts build-tools/cli/lib/templates/shared/__tests__/legacyReactDependencies.test.ts build-tools/cli/project-templates/plugin/shared-base/scripts/resolvePluginDevPort.test.ts build-tools/config/__tests__/runtimeCoreBuildDefine.test.ts build-tools/config/utils/__tests__/treeshakeConfig.test.ts build-tools/utils/__tests__/normalizeScriptArgv.test.ts build-tools/utils/__tests__/pipelineConcurrency.test.ts build-tools/utils/__tests__/taskResourceMetrics.test.ts",
1601
1607
  "clear:babel-cache": "rimraf -rf ./node_modules/.cache/babel-loader/*",
1602
1608
  "delete-maps": "find ./build -name '*.map' -delete && find ./build -regex '.*\\.\\(js\\|css\\)' -exec sed -i -E '\\/[\\*\\/]#\\ssourceMappingURL=main(\\.[0-9a-f]+)?\\.(css|js)\\.map(\\*\\/)?/g' {} +",
1603
1609
  "delete-map-files": "find ./build -name '*.map' -delete",
@@ -1615,18 +1621,17 @@ var ROOT_PKG = {
1615
1621
  "ui-kit:test:unit:coverage": "tsx build-tools/scripts/run-ui-kit.ts vitest --config vitest.unit.config.ts --run --coverage",
1616
1622
  "ui-kit:test:unit:ui": "tsx build-tools/scripts/run-ui-kit.ts vitest --config vitest.unit.config.ts --ui",
1617
1623
  "ui-kit:test:all": "tsx build-tools/scripts/run-ui-kit.ts vitest --config vitest.unit.config.ts --run && cross-env A11Y_ENFORCE=true tsx build-tools/scripts/run-ui-kit.ts vitest --config vitest.config.ts --run",
1618
- "lint:summury": "eslint . **/*.{js,jsx,ts,tsx} --format=node_modules/eslint-formatter-summary/index.js",
1619
1624
  "type-check": "tsx build-tools/scripts/typecheck/run-entry-type-check.ts",
1620
1625
  "type-check:tsc": "tsc -p src/tsconfig.json --noEmit",
1621
1626
  "type-check:watch": "tsc -p src/tsconfig.json --noEmit --watch",
1622
1627
  "lint:types": "tsc --noEmit && tsc -p build-tools/tsconfig.tooling.json",
1623
1628
  "test:typecheck": "npm run lint:types && tsc -p iframe/tsconfig.json --noEmit",
1624
1629
  "type-check:tooling": "tsc -p build-tools/tsconfig.tooling.json",
1625
- "lint:js": "eslint . --fix",
1630
+ "lint:new": "tsx build-tools/scripts/lint/diffAwareLint.ts",
1631
+ "lint:ci": "tsx build-tools/scripts/lint/diffAwareLint.ts",
1632
+ "test:lint": "oxlint --config .oxlintrc.json .",
1626
1633
  "lint:css": "stylelint \"**/*.{css,scss,sass}\" --fix",
1627
- "lint": "eslint . --fix && stylelint \"**/*.{css,scss,sass}\" --fix",
1628
1634
  "format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,css,scss,sass,md,html}\"",
1629
- "nibble": "eslint-nibble .",
1630
1635
  "sentry:sourcemaps-dev": "sentry-cli sourcemaps inject --org sentry --project emailmaker-dev ./build && sentry-cli --url https://sentry.emcdn.ru/ sourcemaps upload --org sentry --project emailmaker-dev ./build",
1631
1636
  "sentry:sourcemaps-prod": "sentry-cli sourcemaps inject --org sentry --project emailmaker-prod ./build && sentry-cli --url https://sentry.emcdn.ru/ sourcemaps upload --org sentry --project emailmaker-prod ./build",
1632
1637
  "sentry:sourcemaps-bl-dev": "sentry-cli sourcemaps inject --org sentry --project blocks-dev ./build && sentry-cli --url https://sentry.emcdn.ru/ sourcemaps upload --org sentry --project blocks-dev ./build",
@@ -1646,7 +1651,7 @@ var ROOT_PKG = {
1646
1651
  },
1647
1652
  devDependencies: {
1648
1653
  "@chromatic-com/storybook": "^5.1.1",
1649
- "@eslint/js": "^9.19.0",
1654
+ "@oxc-project/types": "0.139.0",
1650
1655
  "@react-buddy/ide-toolbox": "^2.4.0",
1651
1656
  "@rolldown/plugin-node-polyfills": "^1.0.3",
1652
1657
  "@types/amphtml-validator": "^1.0.4",
@@ -1661,13 +1666,9 @@ var ROOT_PKG = {
1661
1666
  "@types/mailparser": "^3.4.4",
1662
1667
  "@types/mime-types": "^3.0.1",
1663
1668
  "@types/node": "^20.12.7",
1664
- "@types/react": "^18.2.70",
1665
- "@types/react-dom": "18.2.0",
1669
+ "@types/react": "^19.2.17",
1670
+ "@types/react-dom": "^19.2.3",
1666
1671
  "@types/sortablejs": "^1.15.8",
1667
- "@typescript-eslint/parser": "^8.22.0",
1668
- "@typescript-eslint/type-utils": "^8.23.0",
1669
- "@typescript-eslint/utils": "^8.21.0",
1670
- "@typescript/native-preview": "^7.0.0-dev.20260707.2",
1671
1672
  "@vitejs/plugin-basic-ssl": "^2.3.0",
1672
1673
  "@vitejs/plugin-react": "^6.0.2",
1673
1674
  "allure-jest": "^3.5.0",
@@ -1676,25 +1677,8 @@ var ROOT_PKG = {
1676
1677
  "dotenv": "^17.3.1",
1677
1678
  "ejs": "^5.0.1",
1678
1679
  "env-cmd": "^10.1.0",
1679
- "eslint": "^9.19.0",
1680
- "eslint-config-prettier": "^10.0.1",
1681
- "eslint-formatter-summary": "^1.1.0",
1682
- "eslint-nibble": "^8.1.0",
1683
- "eslint-plugin-import": "^2.31.0",
1684
- "eslint-plugin-jsx-a11y": "^6.10.2",
1685
- "eslint-plugin-promise": "^7.2.1",
1686
- "eslint-plugin-react": "^7.37.4",
1687
- "eslint-plugin-react-hooks": "^5.1.0",
1688
- "eslint-plugin-react-perf": "^3.3.3",
1689
- "eslint-plugin-react-refresh": "^0.4.18",
1690
- "eslint-plugin-security": "^3.0.1",
1691
1680
  "eslint-plugin-sonarjs": "^3.0.1",
1692
- "eslint-plugin-storybook": "10.3.4",
1693
- "eslint-plugin-testing-library": "^7.1.1",
1694
- "eslint-plugin-unicorn": "^56.0.1",
1695
- "eslint-plugin-unused-imports": "^4.1.4",
1696
1681
  "express": "^5.2.1",
1697
- "globals": "^15.14.0",
1698
1682
  "handlebars": "^4.7.8",
1699
1683
  "husky": "^9.1.7",
1700
1684
  "identity-obj-proxy": "^3.0.0",
@@ -1705,8 +1689,8 @@ var ROOT_PKG = {
1705
1689
  "jsdom": "^16.7.0",
1706
1690
  "less": "^4.1.3",
1707
1691
  "napi-postinstall": "^0.3.4",
1708
- "oxlint": "^1.59.0",
1709
- "oxlint-tsgolint": "^0.23.0",
1692
+ "oxlint": "1.77.0",
1693
+ "oxlint-tsgolint": "7.0.2001",
1710
1694
  "playwright": "^1.59.1",
1711
1695
  "postcss-flexbugs-fixes": "^5.0.2",
1712
1696
  "postcss-prefix-selector": "^2.1.0",
@@ -1714,7 +1698,7 @@ var ROOT_PKG = {
1714
1698
  "prettier": "^3.4.2",
1715
1699
  "react-error-overlay": "6.0.9",
1716
1700
  "rolldown": "~1.1.5",
1717
- "rolldown-plugin-dts": "^0.22.5",
1701
+ "rolldown-plugin-dts": "^0.28.0",
1718
1702
  "rollup": "^4.61.1",
1719
1703
  "sass-cast": "^0.5.6",
1720
1704
  "string-width": "^4.2.3",
@@ -1730,8 +1714,7 @@ var ROOT_PKG = {
1730
1714
  "ts-node": "^10.9.2",
1731
1715
  "tsdown": "^0.21.0-beta.2",
1732
1716
  "tsx": "^4.21.0",
1733
- "typescript": "^5.7.3",
1734
- "typescript-eslint": "^8.58.2",
1717
+ "typescript": "^7.0.2",
1735
1718
  "vite": "^8.1.5",
1736
1719
  "vite-plugin-commonjs": "^0.10.4",
1737
1720
  "vite-plugin-css-injected-by-js": "^4.0.1",
@@ -2662,11 +2645,13 @@ var MESSAGES = {
2662
2645
  "readmeStand.modeAngularEsbuild": "Angular CustomEsbuild",
2663
2646
  "readmeStand.angularHost": "- Angular CustomWebpack host with lazy editor import in the webpack graph",
2664
2647
  "readmeStand.angularDevServer": "- Angular CLI dev server (`ng serve`)",
2665
- "readmeStand.angularCommandsDevUrl": "> Dev server URL: `http://localhost:{port}/` (`npm start`; production graph: `npm run start:prod`)",
2666
- "readmeStand.angularCommandsProdUrl": "> Production-like URL: `http://localhost:{port}/`",
2648
+ "readmeStand.angularCommandsDevUrl": "> Dev server URL: `http://localhost:{port}/` (`npm start` — `ng serve`, dev only)",
2649
+ "readmeStand.angularCommandsProdUrl": "> Production-like URL: `http://localhost:{port}/` (`npm run build` then `npm run serve:dist`)",
2650
+ "readmeStand.angularCommandsProdUrlEsbuild": "> Client-like prod URL: `http://localhost:4200/` (`npm run build` then `npm run serve:chunk-repro`)",
2667
2651
  "readmeStand.angularEntryPoint": "- `src/main.ts` — bootstrap; `src/app/editor-host.ts` — editor init",
2668
2652
  "readmeStand.angularConfigFile": "- `custom-webpack.config.cjs` — host plugin, `/api` proxy, CORP headers, esbuild-loader (TS) + EsbuildPlugin minify in production",
2669
- "readmeStand.angularEsbuildConfigFile": "- `angular.json` — `@angular-builders/custom-esbuild:application`, assets under `embed/<app>/`, `esbuild/publicPath-shim.ts` sets `publicPath`",
2653
+ "readmeStand.angularEsbuildConfigFile": "- `angular.json` — `@angular-builders/custom-esbuild:application`, assets under `panel/<app>/`, `esbuild/publicPath-shim.ts` sets `publicPath`",
2654
+ "readmeStand.angularEsbuildClientProd": "> Client-like prod: `npm run build` then `npm run serve:chunk-repro` (HTML :4200, JS chunks :4201). Same-origin baseline: `npm run serve:dist`. Readable build: `npm run build:debug`.",
2670
2655
  "readmeStand.modeResourceProxy": "resource proxy demo",
2671
2656
  "readmeStand.resourceProxyHint": "## Resource proxy demo\n\n- Full `resourceProxy` and `backendProxy` config is wired in `src/dev/editorConfig.ts`.\n- Test proxy through File Manager upload-by-URL, stock images, and CDN assets in the letter.\n- Watch the browser Network tab and the dev server console for `/proxy/` requests.",
2672
2657
  "readmeStand.resourceProxySecurityWarning": "## Security (dev only)\n\n- Run this stand on `localhost` / `127.0.0.1` only. Do not expose the dev server to LAN or the public internet.\n- `/proxy` and `/__debug-resource-proxy` are intentional open forward proxies for local testing (SSRF relay risk).\n- `/dev-storage/upload-by-url` can fetch arbitrary URLs and write files to `./storage`.\n- `proxySameOrigin: true` in `editorConfig.ts` is intentional: same-origin `/dev-storage` assets also go through `/proxy` for lab coverage.",
@@ -2679,6 +2664,8 @@ var MESSAGES = {
2679
2664
  "readmeStand.modeAdvancedShadowDom": "advanced: shadow DOM (closed)",
2680
2665
  "readmeStand.modeAdvancedUmd": "advanced: UMD from page script",
2681
2666
  "readmeStand.modeAdvancedMemoryUsage": "advanced: memory usage test",
2667
+ "readmeStand.modeAdvancedModuleFederation": "advanced: Module Federation host + remote",
2668
+ "readmeStand.moduleFederationHint": "## Module Federation stand (local CLI only)\n\nCross-origin: host `http://localhost:3000`, remote/CDN `http://localhost:3001/remoteEntry.js`. Editor `publicPath` points to port 3001.\n\nOpen `http://localhost:3000/`.\n\n`npm start`: remote `vite build --watch` + preview on :3001, host Vite dev on :3000. First remote build takes a few seconds; host starts after `remoteEntry.js` is ready.",
2682
2669
  "readmeStand.whatIncluded": "## What is included",
2683
2670
  "readmeStand.simpleProject": "- simple project with {title} connected",
2684
2671
  "readmeStand.storageProvider": "- StorageProvider with pathMode - files are stored in `./storage`",
@@ -2762,10 +2749,10 @@ var STAND_ANGULAR_DIST_RELATIVE = "dist/angular-host";
2762
2749
  /** `@angular-builders/custom-esbuild:application` uses the application builder (`…/browser/`). */
2763
2750
  var STAND_ANGULAR_ESBUILD_DIST_RELATIVE = "dist/angular-host/browser";
2764
2751
  /**
2765
- * Nested URL segment for product static assets on angular-esbuild stands.
2766
- * Partner integrations often use `panel/<app>/`; our abstract stand uses `embed/<app>/`.
2752
+ * Nested URL segment for product static assets on Angular demo stands.
2753
+ * Matches typical partner layout (`panel/<app>/`).
2767
2754
  */
2768
- var STAND_ANGULAR_ESBUILD_PRODUCT_PATH_PREFIX = "embed";
2755
+ var STAND_ANGULAR_ESBUILD_PRODUCT_PATH_PREFIX = "panel";
2769
2756
  //#endregion
2770
2757
  //#region lib/template-engine/context/webpackCliCommand.ts
2771
2758
  /** Shared webpack-cli invocation for generated stand/plugin package.json scripts. */
@@ -2774,10 +2761,12 @@ var WEBPACK_CLI_COMMAND = "tsx ./node_modules/webpack-cli/bin/cli.js";
2774
2761
  //#region lib/template-engine/context/standScripts.ts
2775
2762
  var DIST_GUARD = "node ./scripts/assertDistReady.cjs";
2776
2763
  var SERVE_DIST = "node ./scripts/serveDist.cjs";
2764
+ var ANGULAR_PROD_BUILD = "ng build --configuration production";
2777
2765
  function resolveStandDistRelativePath(options) {
2778
2766
  const standMode = getDemoStandMode(options);
2779
2767
  const advancedProfile = getAdvancedStandProfile(options);
2780
2768
  if (standMode === "advanced" && advancedProfile === "memory-usage") return "dist/profile-a";
2769
+ if (standMode === "advanced" && advancedProfile === "module-federation") return "dist/host";
2781
2770
  return "dist";
2782
2771
  }
2783
2772
  function buildDistGuardCommand(distRelativePath) {
@@ -2788,8 +2777,23 @@ function buildViteStandScripts(options) {
2788
2777
  const standMode = getDemoStandMode(options);
2789
2778
  const advancedProfile = getAdvancedStandProfile(options);
2790
2779
  const isMemoryUsageStand = standMode === "advanced" && advancedProfile === "memory-usage";
2780
+ const isModuleFederationStand = standMode === "advanced" && advancedProfile === "module-federation";
2791
2781
  const configFlag = `--config ./${generatedPaths.devConfig}`;
2792
- const previewCommand = `${buildDistGuardCommand(resolveStandDistRelativePath(options))} && vite preview ${configFlag}`;
2782
+ const remoteConfigFlag = "--config ./config/dev-remote.ts";
2783
+ const distGuard = buildDistGuardCommand(resolveStandDistRelativePath(options));
2784
+ const previewCommand = `${distGuard} && vite preview ${configFlag}`;
2785
+ if (isModuleFederationStand) {
2786
+ const concurrently = "concurrently -k";
2787
+ const remoteDistGuard = buildDistGuardCommand("dist/remote");
2788
+ const remotePreviewOnly = `vite preview ${remoteConfigFlag}`;
2789
+ const hostPreviewOnly = `vite preview ${configFlag}`;
2790
+ return {
2791
+ start: `${concurrently} -n remote-build,remote,host "${`vite build --watch ${remoteConfigFlag}`}" "${`wait-on dist/remote/remoteEntry.js -t 120000 && vite preview ${remoteConfigFlag}`}" "wait-on http://localhost:3001/remoteEntry.js -t 120000 && vite ${configFlag}"`,
2792
+ build: `vite build ${remoteConfigFlag} && vite build ${configFlag}`,
2793
+ preview: `${remoteDistGuard} && ${distGuard} && ${concurrently} -n remote,host "${remotePreviewOnly}" "${hostPreviewOnly}"`,
2794
+ "serve:dist": `${remoteDistGuard} && ${distGuard} && ${concurrently} -n remote,host "${remotePreviewOnly}" "${hostPreviewOnly}"`
2795
+ };
2796
+ }
2793
2797
  if (isMemoryUsageStand) {
2794
2798
  const prefix = "cross-env NODE_OPTIONS=--max-old-space-size=512";
2795
2799
  return {
@@ -2819,14 +2823,28 @@ function resolveAngularDistRelativePath(options) {
2819
2823
  if (options && getDemoStandMode(options) === "angular-esbuild") return STAND_ANGULAR_ESBUILD_DIST_RELATIVE;
2820
2824
  return STAND_ANGULAR_DIST_RELATIVE;
2821
2825
  }
2826
+ function isAngularWebpackStand$1(options) {
2827
+ return Boolean(options && getDemoStandMode(options) === "angular");
2828
+ }
2829
+ function isAngularEsbuildStand$1(options) {
2830
+ return Boolean(options && getDemoStandMode(options) === "angular-esbuild");
2831
+ }
2822
2832
  function buildAngularScripts(options) {
2823
2833
  const distRelative = resolveAngularDistRelativePath(options);
2824
- return {
2834
+ const scripts = {
2825
2835
  start: "ng serve",
2826
- "start:prod": "ng serve --configuration production",
2827
- build: "ng build --configuration production",
2836
+ build: ANGULAR_PROD_BUILD,
2828
2837
  "serve:dist": `${buildDistGuardCommand(distRelative)} && ${SERVE_DIST} ${distRelative} ${STAND_ANGULAR_SERVE_DIST_PORT}`
2829
2838
  };
2839
+ if (isAngularEsbuildStand$1(options)) {
2840
+ scripts["build:debug"] = `cross-env NG_BUILD_MANGLE=0 ${ANGULAR_PROD_BUILD}`;
2841
+ scripts["build:rebundle"] = ANGULAR_PROD_BUILD;
2842
+ scripts["serve:chunk-repro"] = "node ./scripts/chunkRepro.cjs";
2843
+ } else if (isAngularWebpackStand$1(options)) {
2844
+ scripts["build:rebundle"] = `cross-env STAND_REBUNDLE_REPRO=1 ${ANGULAR_PROD_BUILD}`;
2845
+ scripts["serve:chunk-repro"] = "node ./scripts/chunkRepro.cjs";
2846
+ }
2847
+ return scripts;
2830
2848
  }
2831
2849
  //#endregion
2832
2850
  //#region lib/template-engine/context/standVitePackageJsonData.ts
@@ -2843,6 +2861,7 @@ function buildStandVitePackageJsonData(options) {
2843
2861
  const standMode = getDemoStandMode(options);
2844
2862
  const advancedProfile = getAdvancedStandProfile(options);
2845
2863
  const isMemoryUsageStand = standMode === "advanced" && advancedProfile === "memory-usage";
2864
+ const isModuleFederationStand = standMode === "advanced" && advancedProfile === "module-federation";
2846
2865
  const isClosedLoopStand = standMode === "closed-loop";
2847
2866
  const appPackageVersion = localTarballs?.packageName || packageConfig.version;
2848
2867
  const devDependencies = {
@@ -2862,6 +2881,13 @@ function buildStandVitePackageJsonData(options) {
2862
2881
  devDependencies["vite-plugin-css-injected-by-js"] = "^3.5.2";
2863
2882
  devDependencies["vite-plugin-image-optimizer"] = "2.0.3";
2864
2883
  }
2884
+ if (isModuleFederationStand) {
2885
+ devDependencies["@module-federation/vite"] = "1.20.1";
2886
+ devDependencies["concurrently"] = "^9.1.2";
2887
+ devDependencies["wait-on"] = "^8.0.1";
2888
+ devDependencies["uuid"] = "^13.0.0";
2889
+ devDependencies["vite-plugin-css-injected-by-js"] = "^3.5.2";
2890
+ }
2865
2891
  } else {
2866
2892
  devDependencies.webpack = packageConfig.versions.webpack;
2867
2893
  devDependencies["webpack-cli"] = packageConfig.versions.webpackCli;
@@ -2880,10 +2906,10 @@ function buildStandVitePackageJsonData(options) {
2880
2906
  }
2881
2907
  //#endregion
2882
2908
  //#region lib/template-engine/context/standAngularPackageJsonData.ts
2883
- var ANGULAR_VERSION$1 = "^19.2.0";
2884
- var ANGULAR_BUILDERS_VERSION = "^19.0.1";
2885
- /** @angular/compiler-cli@19.x peer: >=5.5.0 <5.9.0 */
2886
- var ANGULAR_TYPESCRIPT_VERSION$1 = "~5.8.3";
2909
+ var ANGULAR_VERSION$1 = "^22.1.0";
2910
+ var ANGULAR_BUILDERS_VERSION = "^22.0.1";
2911
+ /** @angular/compiler-cli@22.x peer: >=6.0 <6.1 */
2912
+ var ANGULAR_TYPESCRIPT_VERSION$1 = "~6.0.3";
2887
2913
  /**
2888
2914
  * package.json для stand angular (Angular + @angular-builders/custom-webpack).
2889
2915
  */
@@ -2904,8 +2930,11 @@ function buildStandAngularPackageJsonData(options) {
2904
2930
  tsx: packageConfig.versions.tsx,
2905
2931
  esbuild: packageConfig.versions.esbuild,
2906
2932
  "esbuild-loader": packageConfig.versions.esbuildLoader,
2907
- "zone.js": "~0.15.0",
2908
- formidable: "^3.5.2"
2933
+ rxjs: "^7.8.0",
2934
+ "zone.js": "~0.16.0",
2935
+ formidable: "^3.5.2",
2936
+ "@types/node": "^22.10.0",
2937
+ "cross-env": "^7.0.3"
2909
2938
  };
2910
2939
  return {
2911
2940
  name: pluginPackageName,
@@ -2919,10 +2948,10 @@ function buildStandAngularPackageJsonData(options) {
2919
2948
  }
2920
2949
  //#endregion
2921
2950
  //#region lib/template-engine/context/standAngularEsbuildPackageJsonData.ts
2922
- var ANGULAR_VERSION = "^19.2.0";
2923
- var ANGULAR_CUSTOM_ESBUILD_VERSION = "^19.0.1";
2924
- /** @angular/compiler-cli@19.x peer: >=5.5.0 <5.9.0 */
2925
- var ANGULAR_TYPESCRIPT_VERSION = "~5.8.3";
2951
+ var ANGULAR_VERSION = "^22.1.0";
2952
+ var ANGULAR_CUSTOM_ESBUILD_VERSION = "^22.0.1";
2953
+ /** @angular/compiler-cli@22.x peer: >=6.0 <6.1 */
2954
+ var ANGULAR_TYPESCRIPT_VERSION = "~6.0.3";
2926
2955
  /**
2927
2956
  * package.json для stand angular-esbuild (Angular + @angular-builders/custom-esbuild).
2928
2957
  */
@@ -2932,7 +2961,7 @@ function buildStandAngularEsbuildPackageJsonData(options) {
2932
2961
  const devDependencies = {
2933
2962
  [resolveLocalPublishedPackageKey(localPublishedNames, "packageName", packageConfig.packageName)]: appPackageVersion,
2934
2963
  "@angular-builders/custom-esbuild": ANGULAR_CUSTOM_ESBUILD_VERSION,
2935
- "@angular-devkit/build-angular": ANGULAR_VERSION,
2964
+ "@angular/build": ANGULAR_VERSION,
2936
2965
  "@angular/cli": ANGULAR_VERSION,
2937
2966
  "@angular/common": ANGULAR_VERSION,
2938
2967
  "@angular/compiler": ANGULAR_VERSION,
@@ -2942,8 +2971,11 @@ function buildStandAngularEsbuildPackageJsonData(options) {
2942
2971
  typescript: ANGULAR_TYPESCRIPT_VERSION,
2943
2972
  tsx: packageConfig.versions.tsx,
2944
2973
  esbuild: packageConfig.versions.esbuild,
2945
- "zone.js": "~0.15.0",
2946
- formidable: "^3.5.2"
2974
+ rxjs: "^7.8.0",
2975
+ "zone.js": "~0.16.0",
2976
+ formidable: "^3.5.2",
2977
+ "@types/node": "^22.10.0",
2978
+ "cross-env": "^7.0.3"
2947
2979
  };
2948
2980
  return {
2949
2981
  name: pluginPackageName,
@@ -2971,7 +3003,7 @@ function buildStandReadmeEtaStrings(options) {
2971
3003
  const title = capitalize(packageConfig?.appName || "app");
2972
3004
  const { t } = createTemplateI18n(options);
2973
3005
  const isAngular = standMode === "angular" || standMode === "angular-esbuild";
2974
- const scenarioLabel = standMode === "react-adapter" ? t("readmeStand.modeReactAdapter") : isAngular ? t("readmeStand.modeAngular") : standMode === "resource-proxy" ? t("readmeStand.modeResourceProxy") : standMode === "advanced" && advancedProfile === "subpath" ? t("readmeStand.modeAdvancedSubpath") : standMode === "advanced" && advancedProfile === "shadow-dom" ? t("readmeStand.modeAdvancedShadowDom") : standMode === "advanced" && advancedProfile === "umd" ? t("readmeStand.modeAdvancedUmd") : standMode === "advanced" && advancedProfile === "memory-usage" ? t("readmeStand.modeAdvancedMemoryUsage") : isClosed ? t("readmeStand.modeClosedLoop") : t("readmeStand.modeOAuth");
3006
+ const scenarioLabel = standMode === "react-adapter" ? t("readmeStand.modeReactAdapter") : isAngular ? t("readmeStand.modeAngular") : standMode === "resource-proxy" ? t("readmeStand.modeResourceProxy") : standMode === "advanced" && advancedProfile === "subpath" ? t("readmeStand.modeAdvancedSubpath") : standMode === "advanced" && advancedProfile === "shadow-dom" ? t("readmeStand.modeAdvancedShadowDom") : standMode === "advanced" && advancedProfile === "umd" ? t("readmeStand.modeAdvancedUmd") : standMode === "advanced" && advancedProfile === "memory-usage" ? t("readmeStand.modeAdvancedMemoryUsage") : standMode === "advanced" && advancedProfile === "module-federation" ? t("readmeStand.modeAdvancedModuleFederation") : isClosed ? t("readmeStand.modeClosedLoop") : t("readmeStand.modeOAuth");
2975
3007
  return {
2976
3008
  standReadmeIsClosedLoop: isClosed ? "true" : "false",
2977
3009
  readmePluginPackageName: pluginPackageName,
@@ -2987,7 +3019,8 @@ function buildStandReadmeEtaStrings(options) {
2987
3019
  readmeRouteHint: isAngular ? "" : t("readmeStand.routeHint", { route: standRoutePath }),
2988
3020
  readmeAngularHost: isAngular ? t("readmeStand.angularHost") : "",
2989
3021
  readmeAngularCommandsDevUrl: isAngular ? t("readmeStand.angularCommandsDevUrl", { port: STAND_ANGULAR_DEV_PORT }) : "",
2990
- readmeAngularCommandsProdUrl: isAngular ? t("readmeStand.angularCommandsProdUrl", { port: STAND_ANGULAR_SERVE_DIST_PORT }) : "",
3022
+ readmeAngularCommandsProdUrl: isAngular ? standMode === "angular-esbuild" ? t("readmeStand.angularCommandsProdUrlEsbuild") : t("readmeStand.angularCommandsProdUrl", { port: STAND_ANGULAR_SERVE_DIST_PORT }) : "",
3023
+ readmeAngularEsbuildClientProd: standMode === "angular-esbuild" ? t("readmeStand.angularEsbuildClientProd") : "",
2991
3024
  readmeClosedStandaloneKey: t("readmeStand.closedStandaloneKey"),
2992
3025
  readmeClosedHandleReadLocale: t("readmeStand.closedHandleReadLocale"),
2993
3026
  readmeConfiguration: t("readmeStand.configuration"),
@@ -3009,7 +3042,8 @@ function buildStandReadmeEtaStrings(options) {
3009
3042
  readmeConfigDir: isAngular ? standMode === "angular-esbuild" ? t("readmeStand.angularEsbuildConfigFile") : t("readmeStand.angularConfigFile") : t("readmeStand.configDir"),
3010
3043
  readmeOauthCredentialsFile: t("readmeStand.oauthCredentialsFile"),
3011
3044
  readmeOauthTokenFile: t("readmeStand.oauthTokenFile"),
3012
- readmeStandaloneCredentialsFile: t("readmeStand.standaloneCredentialsFile")
3045
+ readmeStandaloneCredentialsFile: t("readmeStand.standaloneCredentialsFile"),
3046
+ readmeModuleFederationHint: standMode === "advanced" && advancedProfile === "module-federation" ? t("readmeStand.moduleFederationHint") : ""
3013
3047
  };
3014
3048
  }
3015
3049
  //#endregion
@@ -3249,7 +3283,7 @@ function shouldUseEtaStandReactAdapterWebpack(options) {
3249
3283
  if (options.bundler !== "webpack") return false;
3250
3284
  return getDemoStandMode(options) === "react-adapter";
3251
3285
  }
3252
- /** advanced + vite (shadow-dom | umd | memory-usage | subpath) */
3286
+ /** advanced + vite (shadow-dom | umd | memory-usage | module-federation | subpath) */
3253
3287
  function getStandAdvancedViteEtaLayerRoots(templateOptions, rootPrefix = TEMPLATE_ROOT) {
3254
3288
  if (templateOptions.bundler !== "vite") return null;
3255
3289
  if (getDemoStandMode(templateOptions) !== "advanced") return null;
@@ -3259,6 +3293,7 @@ function getStandAdvancedViteEtaLayerRoots(templateOptions, rootPrefix = TEMPLAT
3259
3293
  if (prof === "shadow-dom") return [base, resolveStandAdvancedViteVariantDir("shadow-dom", rootPrefix)];
3260
3294
  if (prof === "umd") return [base, resolveStandAdvancedViteVariantDir("umd", rootPrefix)];
3261
3295
  if (prof === "memory-usage") return [base, resolveStandAdvancedViteVariantDir("memory-usage", rootPrefix)];
3296
+ if (prof === "module-federation") return [base, resolveStandAdvancedViteVariantDir("module-federation", rootPrefix)];
3262
3297
  if (prof === "subpath") return [base, resolveStandAdvancedViteVariantDir("subpath", rootPrefix)];
3263
3298
  return null;
3264
3299
  }
@@ -3381,13 +3416,15 @@ function buildStandEtaContext(templateOptions) {
3381
3416
  standUmdPublicPath,
3382
3417
  standUmdScriptPath,
3383
3418
  standShowMemoryUsageBanner: standMode === "advanced" && advancedProfile === "memory-usage",
3419
+ standShowModuleFederationBanner: standMode === "advanced" && advancedProfile === "module-federation",
3384
3420
  standShowSubpathBanner: standMode === "advanced" && advancedProfile === "subpath",
3385
3421
  standViteOutputFolder: computeStandViteOutputFolder(templateOptions),
3386
3422
  includeSmokeHelpers: Boolean(templateOptions.localTest),
3387
3423
  standAngular: isAngularStand,
3388
- ...standMode === "angular-esbuild" ? {
3424
+ ...standMode === "angular-esbuild" || standMode === "angular" ? {
3389
3425
  standAngularProductAssetsOutput: `${STAND_ANGULAR_ESBUILD_PRODUCT_PATH_PREFIX}/${appNameSlug}/`,
3390
- standAngularProductPublicPath: `${STAND_ANGULAR_ESBUILD_PRODUCT_PATH_PREFIX}/${appNameSlug}`
3426
+ standAngularProductPublicPath: `${STAND_ANGULAR_ESBUILD_PRODUCT_PATH_PREFIX}/${appNameSlug}`,
3427
+ standAngularChunkReproDistRelative: standMode === "angular-esbuild" ? STAND_ANGULAR_ESBUILD_DIST_RELATIVE : STAND_ANGULAR_DIST_RELATIVE
3391
3428
  } : {},
3392
3429
  standWindowNamespace: `__${appNameSlug}__`,
3393
3430
  standReadmeIsResourceProxy: standMode === "resource-proxy" ? "true" : "false",
@@ -3527,7 +3564,7 @@ var rawTemplateModules = /* #__PURE__ */ Object.assign({
3527
3564
  "../../project-templates/plugin/templating/src/app/__PLUGIN_CLASS_NAME__.tsx.eta": "import { pluginRegistry, createComponentIdentifier } from '<%= it.packageConfig.extensionsApiPackageName %>';\nimport { ComponentRegistry } from '<%= it.packageConfig.extensionsReactPackageName %>';\nimport type { IPlugin, Instance } from '<%= it.packageConfig.packageName %>';\nimport type { <%= it.pluginClassName %>Options } from '../public-types';\nimport {\n <%= it.pluginClassName %>TemplateDataPanel,\n type <%= it.pluginClassName %>TemplateDataPanelProps,\n} from './ui/<%= it.pluginClassName %>Panel';\nimport {\n OPEN_TEMPLATE_DATA_PANEL_MESSAGE,\n PREVIEW_STATES,\n TEMPLATE_DATA_MESSAGE,\n TEMPLATE_DATA_META_KEY,\n TWIG_RUNTIME_URL,\n clonePreviewData,\n type PreviewTemplateData,\n} from '../interfaces';\n\nconst <%= it.pluginClassName %>TemplateDataPanelId =\n createComponentIdentifier<<%= it.pluginClassName %>TemplateDataPanelProps>('<%= it.pluginClassName %>TemplateDataPanel');\n\nComponentRegistry.add(<%= it.pluginClassName %>TemplateDataPanelId, <%= it.pluginClassName %>TemplateDataPanel);\n\nfunction normalizePublicPath(value?: string): string | undefined {\n if (!value) {\n return undefined;\n }\n\n const trimmed = value.replace(/\\/+$/, '');\n return `${trimmed}/`;\n}\n\nconst AUTO_PUBLIC_PATH = (() => {\n if (typeof document === 'undefined') {\n return undefined;\n }\n\n const currentScript = document.currentScript as HTMLScriptElement | null;\n if (!currentScript?.src) {\n return undefined;\n }\n\n return normalizePublicPath(currentScript.src.replace(/[^/]*$/, ''));\n})();\n\nfunction getDefaultPreviewData(): PreviewTemplateData {\n return clonePreviewData(PREVIEW_STATES[0]?.data ?? {});\n}\n\nexport class <%= it.pluginClassName %> implements IPlugin {\n private _previewData: PreviewTemplateData = getDefaultPreviewData();\n private _matcherReadyPromise: Promise<void> = Promise.resolve();\n private readonly _disposables: Array<{ dispose(): void }> = [];\n private _settingsPanel?: { showSettingsPanel?: (options: unknown) => void };\n\n constructor(\n private readonly _editor: Instance,\n private readonly _options: <%= it.pluginClassName %>Options = {},\n ) {}\n\n init() {\n const sandboxApi = this._editor.use('SandboxScriptApi');\n const settingsPanel = this._editor.use('SettingsPanelApi');\n const messageService = this._editor.use('MessageService');\n this._settingsPanel = settingsPanel;\n\n const publicPath = normalizePublicPath(this._options.publicPath) || AUTO_PUBLIC_PATH;\n const twigRuntimeHandle = sandboxApi.registerSandboxScript(TWIG_RUNTIME_URL);\n\n if (publicPath) {\n this._matcherReadyPromise = twigRuntimeHandle.ready\n .then(() => sandboxApi.registerSandboxScript(publicPath + 'sandbox.js').ready)\n .then(() => undefined);\n } else {\n this._matcherReadyPromise = twigRuntimeHandle.ready.then(() => undefined);\n }\n\n this._trackDisposable(messageService.addListener(OPEN_TEMPLATE_DATA_PANEL_MESSAGE, () => {\n this._openTemplateDataPanel(this._settingsPanel);\n }));\n\n this._trackDisposable(this._editor.handleEmailInit?.((email) => {\n void this._hydratePreviewData(email);\n }));\n }\n\n afterInit() {\n void this._hydratePreviewData();\n }\n\n dispose() {\n while (this._disposables.length > 0) {\n this._disposables.pop()?.dispose();\n }\n }\n\n private _trackDisposable(value: { dispose(): void } | (() => void) | void) {\n if (!value) {\n return;\n }\n\n if (typeof value === 'function') {\n this._disposables.push({ dispose: value });\n return;\n }\n\n if (typeof value.dispose === 'function') {\n this._disposables.push(value);\n }\n }\n\n private _readPreviewDataFromEmail(email: unknown): PreviewTemplateData {\n const emailMeta = (email as { meta?: Record<string, unknown> } | undefined)?.meta;\n const storedData = emailMeta?.[TEMPLATE_DATA_META_KEY];\n if (storedData && typeof storedData === 'object') {\n return clonePreviewData(storedData as PreviewTemplateData);\n }\n\n return getDefaultPreviewData();\n }\n\n private async _hydratePreviewData(email?: unknown) {\n const sourceEmail = email ?? await this._editor.getEmail?.();\n this._previewData = this._readPreviewDataFromEmail(sourceEmail);\n await this._sendPreviewData();\n }\n\n private _persistPreviewData(nextData: PreviewTemplateData) {\n this._previewData = clonePreviewData(nextData);\n this._editor.setEmailMeta?.({\n [TEMPLATE_DATA_META_KEY]: clonePreviewData(nextData),\n });\n }\n\n private _openTemplateDataPanel(settingsPanel: { showSettingsPanel?: (options: unknown) => void } | undefined) {\n if (!settingsPanel || typeof settingsPanel.showSettingsPanel !== 'function') {\n return;\n }\n\n settingsPanel.showSettingsPanel({\n caption: 'Template data JSON',\n deletable: false,\n content: {\n type: <%= it.pluginClassName %>TemplateDataPanelId,\n props: {\n initialValue: JSON.stringify(this._previewData ?? {}, null, 2),\n onValidJson: (nextData) => {\n this._persistPreviewData(nextData);\n void this._sendPreviewData();\n },\n },\n },\n });\n }\n\n private async _sendPreviewData() {\n const messageService = this._editor.use('MessageService');\n await this._matcherReadyPromise;\n messageService.send(TEMPLATE_DATA_MESSAGE, this._previewData);\n }\n}\n\npluginRegistry.add(<%~ it.pluginKeyLiteral %>, <%= it.pluginClassName %>);\n",
3528
3565
  "../../project-templates/plugin/templating/src/app/ui/__PLUGIN_PANEL_CLASS_NAME__.tsx.eta": "import React, { useEffect, useState } from 'react';\nimport type { PreviewTemplateData } from '../../interfaces';\n\nexport interface <%= it.pluginClassName %>TemplateDataPanelProps {\n initialValue: string;\n onValidJson?(value: PreviewTemplateData): void;\n}\n\nexport function <%= it.pluginClassName %>TemplateDataPanel({\n initialValue,\n onValidJson,\n}: <%= it.pluginClassName %>TemplateDataPanelProps) {\n const [value, setValue] = useState(initialValue);\n const [status, setStatus] = useState('Valid JSON applies automatically to the preview.');\n const [statusColor, setStatusColor] = useState('#64748b');\n\n useEffect(() => {\n setValue(initialValue);\n setStatus('Valid JSON applies automatically to the preview.');\n setStatusColor('#64748b');\n }, [initialValue]);\n\n useEffect(() => {\n const timer = window.setTimeout(() => {\n try {\n onValidJson?.(JSON.parse(value) as PreviewTemplateData);\n setStatus('Preview updated from sidebar JSON.');\n setStatusColor('#15803d');\n } catch (error) {\n setStatus(`JSON error: ${String(error instanceof Error ? error.message : error)}`);\n setStatusColor('#b91c1c');\n }\n }, 250);\n\n return () => {\n window.clearTimeout(timer);\n };\n }, [onValidJson, value]);\n\n return (\n <div style={{ display: 'flex', flexDirection: 'column', gap: '12px', height: '100%', padding: '16px', boxSizing: 'border-box' }}>\n <div style={{ font: '13px/1.5 Arial,sans-serif', color: '#475569' }}>\n Edit template data as raw JSON. Valid JSON applies to the Twig preview automatically.\n </div>\n <textarea\n spellCheck={false}\n wrap=\"off\"\n value={value}\n onChange={(event) => {\n setStatus('Validating JSON...');\n setStatusColor('#64748b');\n setValue(event.target.value);\n }}\n style={{\n width: '100%',\n minHeight: '320px',\n flex: 1,\n padding: '12px',\n border: '1px solid #cbd5e1',\n borderRadius: '8px',\n background: '#0f172a',\n color: '#e2e8f0',\n font: '13px/1.5 Consolas, Monaco, monospace',\n resize: 'vertical',\n boxSizing: 'border-box',\n }}\n />\n <div style={{ font: '12px/1.5 Arial,sans-serif', color: statusColor, whiteSpace: 'pre-wrap' }}>\n {status}\n </div>\n </div>\n );\n}\n",
3529
3566
  "../../project-templates/plugin/templating/src/dev/editorConfig.ts.eta": "import type { Config } from '<%= it.packageConfig.packageName %>';\nimport type { <%= it.pluginClassName %>Config } from '../public-types';\n\nconst mergeTagItems = [\n {\n label: 'System',\n value: 'system',\n children: [\n { label: 'Additional field \"Name\"', value: 'Name' },\n { label: 'Recipient name', value: 'ToName' },\n ],\n },\n];\n\nconst baseEditorConfig = {\n theme: 'light',\n locale: 'en_US',\n historyEnabled: true,\n commonStylesEnabled: true,\n previewIconEnabled: true,\n previewModeEnabled: true,\n livePreviewEnabled: true,\n sendTestEnabled: false,\n emailExportEnabled: false,\n sharePreviewEnabled: false,\n codeModeDirection: 'bottom',\n codeMode: 'true',\n mergeTagsShow: true,\n mergeTags: {\n syntax: ['{{' + '%value%' + '}}'],\n items: mergeTagItems,\n },\n} satisfies Partial<Config & <%= it.pluginClassName %>Config>;\n\nexport function createEditorConfig(): Partial<Config> {\n return baseEditorConfig;\n}\n\nexport const editorConfig = createEditorConfig();\n",
3530
- "../../project-templates/plugin/templating/src/dev/hostApp.tsx.eta": "import { useEffect, useRef, useState } from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { init } from '<%= it.packageConfig.packageName %>';\nimport type { ExportedApi } from '<%= it.packageConfig.packageName %>';\nimport { editorConfig } from './editorConfig';\nimport { getAuthToken } from './getAuthToken';\nimport { TWIG_EMAIL_CODE } from '../interfaces';\n\nfunction createDemoEmailId() {\n if (typeof globalThis.crypto?.randomUUID === 'function') {\n return globalThis.crypto.randomUUID();\n }\n\n return `demo-email-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;\n}\n\nexport interface HostAppOptions {\n plugins: NonNullable<ExportedApi.Options['plugins']>;\n}\n\n<%~ include('editor-init-smoke', it) %>\nexport function renderHostApp(options: HostAppOptions): void {\n const { plugins } = options;\n\n function EditorApp() {\n const instanceRef = useRef<ExportedApi.Instance | null>(null);\n const [initError, setInitError] = useState<string | null>(null);\n\n useEffect(() => {\n async function run() {\n if (instanceRef.current) {\n return;\n }\n\n const mountElement = document.getElementById('editor-root');\n const smokeMeta = {\n hostKind: 'plugin-host',\n variant: 'plugin-host-templating',\n mountLabel: '#editor-root',\n } as const;\n\n try {\n const initOptions = {\n getAuthToken,\n element: '#editor-root',\n content: {\n email: {\n id: createDemoEmailId(),\n title: <%~ it.devHostDemoTitleLiteral %>,\n code: TWIG_EMAIL_CODE,\n },\n },\n config: editorConfig,\n plugins,\n } satisfies ExportedApi.Options;\n const instance = await init(initOptions);\n instanceRef.current = instance;\n reportEditorReady(smokeMeta, mountElement);\n } catch (error) {\n const message = reportEditorInitError(smokeMeta, error, mountElement);\n setInitError(message);\n }\n }\n\n run();\n }, []);\n\n return (\n <>\n {initError ? (\n <div style={{ margin: '12px 0', color: '#b42318', fontSize: '14px' }}>\n Editor failed to initialize: {initError}\n </div>\n ) : null}\n <div id=\"editor-root\" />\n </>\n );\n }\n\n const rootElement = document.getElementById('root');\n\n if (!rootElement) {\n throw new Error(<%~ it.rootElementNotFoundLiteral %>);\n }\n\n createRoot(rootElement).render(<EditorApp />);\n}\n",
3567
+ "../../project-templates/plugin/templating/src/dev/hostApp.tsx.eta": "/* @jsxImportSource <%= it.packageConfig.packageName %>/runtime/react */\nimport { useEffect, useRef, useState } from '<%= it.packageConfig.packageName %>/runtime/react';\nimport { createRoot } from '<%= it.packageConfig.packageName %>/runtime/react-dom/client';\nimport { init } from '<%= it.packageConfig.packageName %>';\nimport type { ExportedApi } from '<%= it.packageConfig.packageName %>';\nimport { editorConfig } from './editorConfig';\nimport { getAuthToken } from './getAuthToken';\nimport { TWIG_EMAIL_CODE } from '../interfaces';\n\nfunction createDemoEmailId() {\n if (typeof globalThis.crypto?.randomUUID === 'function') {\n return globalThis.crypto.randomUUID();\n }\n\n return `demo-email-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;\n}\n\nexport interface HostAppOptions {\n plugins: NonNullable<ExportedApi.Options['plugins']>;\n}\n\n<%~ include('editor-init-smoke', it) %>\nexport function renderHostApp(options: HostAppOptions): void {\n const { plugins } = options;\n\n function EditorApp() {\n const instanceRef = useRef<ExportedApi.Instance | null>(null);\n const [initError, setInitError] = useState<string | null>(null);\n\n useEffect(() => {\n async function run() {\n if (instanceRef.current) {\n return;\n }\n\n const mountElement = document.getElementById('editor-root');\n const smokeMeta = {\n hostKind: 'plugin-host',\n variant: 'plugin-host-templating',\n mountLabel: '#editor-root',\n } as const;\n\n try {\n const initOptions = {\n getAuthToken,\n element: '#editor-root',\n content: {\n email: {\n id: createDemoEmailId(),\n title: <%~ it.devHostDemoTitleLiteral %>,\n code: TWIG_EMAIL_CODE,\n },\n },\n config: editorConfig,\n plugins,\n } satisfies ExportedApi.Options;\n const instance = await init(initOptions);\n instanceRef.current = instance;\n reportEditorReady(smokeMeta, mountElement);\n } catch (error) {\n const message = reportEditorInitError(smokeMeta, error, mountElement);\n setInitError(message);\n }\n }\n\n run();\n }, []);\n\n return (\n <>\n {initError ? (\n <div style={{ margin: '12px 0', color: '#b42318', fontSize: '14px' }}>\n Editor failed to initialize: {initError}\n </div>\n ) : null}\n <div id=\"editor-root\" />\n </>\n );\n }\n\n const rootElement = document.getElementById('root');\n\n if (!rootElement) {\n throw new Error(<%~ it.rootElementNotFoundLiteral %>);\n }\n\n createRoot(rootElement).render(<EditorApp />);\n}\n",
3531
3568
  "../../project-templates/plugin/templating/src/interfaces/index.ts.eta": "export interface PreviewTemplateData {\n product?: {\n title?: string;\n sku?: string;\n cards?: Array<{\n title?: string;\n price?: string;\n badge?: string;\n }>;\n };\n}\n\nexport interface PreviewState {\n label: string;\n data: PreviewTemplateData;\n}\n\nexport const TWIG_RUNTIME_URL = 'https://cdn.jsdelivr.net/npm/twig@3.0.0/twig.min.js';\nexport const TEMPLATE_DATA_MESSAGE = 'templating:preview-data';\nexport const OPEN_TEMPLATE_DATA_PANEL_MESSAGE = 'templating:open-panel';\nexport const TEMPLATE_DATA_META_KEY = 'templatingPreviewData';\nexport const TEMPLATE_DATA_PREVIEW_ATTRIBUTE = 'data-em-templating-preview';\n\nexport const PREVIEW_STATES: PreviewState[] = [\n {\n label: 'Featured products',\n data: {\n product: {\n title: 'Featured products for Alice',\n sku: 'SKU-ALPHA-001',\n cards: [\n { title: 'Starter pack', price: '$29', badge: 'Popular' },\n { title: 'Growth pack', price: '$79', badge: 'Best value' },\n ],\n },\n },\n },\n {\n label: 'Empty catalog',\n data: {\n product: {\n title: 'Recommended products for Bob',\n sku: 'SKU-BETA-002',\n cards: [],\n },\n },\n },\n];\n\nexport const TWIG_EMAIL_CODE = `<!DOCTYPE html>\n<html>\n <head>\n <meta charset=\"utf-8\" />\n <title>Twig matcher demo</title>\n </head>\n <body style=\"margin:0;padding:24px;font-family:Arial,sans-serif;background:#f8fafc;\">\n <table role=\"presentation\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n <tr>\n <td align=\"center\">\n <table role=\"presentation\" width=\"640\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style=\"background:#ffffff;border-radius:16px;overflow:hidden;\">\n <tr>\n <td style=\"padding:32px;\">\n <h1 style=\"margin:0 0 16px;\">{{ product.title }}</h1>\n {# sandbox matcher should replace this comment with preview html #}\n {% if product.cards is not empty %}\n <table role=\"presentation\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style=\"margin:16px 0 0;\">\n <tr>\n {% for card in product.cards %}\n <td style=\"width:50%;padding:8px;vertical-align:top;\">\n <table role=\"presentation\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style=\"border:1px solid #dbe4f0;border-radius:12px;background:#f8fafc;\">\n <tr>\n <td style=\"padding:16px;\">\n <div style=\"font-size:12px;line-height:16px;color:#475569;text-transform:uppercase;\">{{ card.badge }}</div>\n <div style=\"margin-top:8px;font-size:18px;line-height:24px;color:#0f172a;font-weight:bold;\">{{ card.title }}</div>\n <div style=\"margin-top:8px;font-size:14px;line-height:20px;color:#2563eb;\">{{ card.price }}</div>\n </td>\n </tr>\n </table>\n </td>\n {% endfor %}\n </tr>\n </table>\n {% endif %}\n <p style=\"margin:16px 0 0;color:#475569;\">SKU: {{ product.sku }}</p>\n </td>\n </tr>\n </table>\n </td>\n </tr>\n </table>\n </body>\n</html>`;\n\nexport function clonePreviewData<T>(value: T): T {\n return JSON.parse(JSON.stringify(value)) as T;\n}\n",
3532
3569
  "../../project-templates/plugin/templating/src/sandbox/index.ts.eta": "import { App } from '<%= it.packageConfig.extensionsSandboxPackageName %>';\nimport type { IPlugin } from '<%= it.packageConfig.extensionsSandboxPackageName %>';\nimport {\n OPEN_TEMPLATE_DATA_PANEL_MESSAGE,\n TEMPLATE_DATA_MESSAGE,\n TEMPLATE_DATA_PREVIEW_ATTRIBUTE,\n type PreviewTemplateData,\n} from '../interfaces';\n\ntype Disposable = { dispose(): void };\ntype MatcherRange = { start: number; end: number };\ntype MatcherMapping = {\n registerMatcherPair(config: {\n syntax?: string;\n escape: {\n match(text: string): MatcherRange[];\n mapFn(text: string): string | false;\n overrideBuiltins?: boolean;\n };\n unescape: {\n match(text: string): MatcherRange[];\n mapFn(text: string): string | false;\n overrideBuiltins?: boolean;\n };\n }): Disposable;\n rebuildFromBase?(): void;\n};\n\nclass <%= it.pluginClassName %>Sandbox implements IPlugin {\n private _previewData: PreviewTemplateData = {};\n private readonly _disposables: Disposable[] = [];\n private _messageService?: { send(message: string, data?: unknown): void; addListener(message: string, listener: (value: PreviewTemplateData) => void): Disposable };\n\n init() {\n const mapping = App.use('Mapping') as MatcherMapping | undefined;\n const messageService = App.use('MessageService');\n this._messageService = messageService;\n\n if (!mapping || typeof mapping.registerMatcherPair !== 'function') {\n console.warn('[<%= it.pluginClassName %>Sandbox] Mapping.registerMatcherPair is unavailable');\n return;\n }\n\n const registration = mapping.registerMatcherPair({\n syntax: 'twig-preview',\n escape: {\n match: (text) => this._findTwigRanges(text),\n mapFn: (text) => this._renderTwigSource(text),\n overrideBuiltins: true,\n },\n unescape: {\n match: (text) => this._findPreviewRanges(text),\n mapFn: (text) => this._restoreTwigSource(text),\n overrideBuiltins: true,\n },\n });\n\n this._disposables.push(\n registration,\n {\n dispose: this._bindPreviewClickHandler(),\n },\n messageService.addListener(TEMPLATE_DATA_MESSAGE, (nextPreviewData: PreviewTemplateData) => {\n this._previewData = nextPreviewData || {};\n mapping.rebuildFromBase?.();\n }),\n );\n }\n\n dispose() {\n while (this._disposables.length > 0) {\n this._disposables.pop()?.dispose();\n }\n }\n\n private _encodeSource(source: string): string {\n const bytes = new TextEncoder().encode(source);\n let binary = '';\n bytes.forEach((byte) => {\n binary += String.fromCharCode(byte);\n });\n return btoa(binary);\n }\n\n private _decodeSource(encodedSource: string): string {\n const binary = atob(encodedSource);\n const bytes = new Uint8Array(binary.length);\n for (let index = 0; index < binary.length; index += 1) {\n bytes[index] = binary.charCodeAt(index);\n }\n return new TextDecoder().decode(bytes);\n }\n\n private _collectMatches(text: string, patterns: RegExp[]): MatcherRange[] {\n const ranges: MatcherRange[] = [];\n patterns.forEach((pattern) => {\n pattern.lastIndex = 0;\n let match: RegExpExecArray | null;\n while ((match = pattern.exec(text)) !== null) {\n ranges.push({\n start: match.index,\n end: match.index + match[0].length,\n });\n }\n });\n ranges.sort((first, second) => first.start - second.start || first.end - second.end);\n return ranges;\n }\n\n private _isIntersectRange(first: MatcherRange, second: MatcherRange): boolean {\n return first.start < second.end && second.start < first.end;\n }\n\n private _mergeRanges(ranges: MatcherRange[]): MatcherRange[] {\n const sorted = ranges.slice().sort((first, second) => first.start - second.start || first.end - second.end);\n const merged: MatcherRange[] = [];\n sorted.forEach((range) => {\n const previous = merged[merged.length - 1];\n if (previous && range.start < previous.end) {\n previous.end = Math.max(previous.end, range.end);\n return;\n }\n merged.push({ start: range.start, end: range.end });\n });\n return merged;\n }\n\n private _findBlockTwigRanges(text: string): MatcherRange[] {\n const ranges: MatcherRange[] = [];\n const stack: Array<{ type: 'if' | 'for'; start: number }> = [];\n const tokenPattern = /\\{%\\s*(if|for|endif|endfor)\\b[\\s\\S]*?%\\}/g;\n const validStartPositions = new Set<number>();\n let match: RegExpExecArray | null;\n\n while ((match = tokenPattern.exec(text)) !== null) {\n const keyword = match[1];\n const tokenEnd = match.index + match[0].length;\n if (keyword === 'if' || keyword === 'for') {\n validStartPositions.add(match.index);\n stack.push({ type: keyword, start: match.index });\n continue;\n }\n\n const startType = keyword === 'endif' ? 'if' : 'for';\n for (let index = stack.length - 1; index >= 0; index -= 1) {\n if (stack[index].type === startType) {\n const start = stack[index].start;\n stack.splice(index);\n ranges.push({ start, end: tokenEnd });\n break;\n }\n }\n }\n\n stack.forEach((entry) => {\n ranges.push({ start: entry.start, end: text.length });\n });\n\n const rawStartPattern = /\\{%\\s*(if|for)\\b/g;\n while ((match = rawStartPattern.exec(text)) !== null) {\n if (!validStartPositions.has(match.index) && !ranges.some((range) => match.index >= range.start && match.index < range.end)) {\n ranges.push({ start: match.index, end: text.length });\n }\n }\n\n return this._mergeRanges(ranges);\n }\n\n private _findInlineTwigRanges(text: string): MatcherRange[] {\n const ranges = this._collectMatches(text, [\n /\\{\\{[\\s\\S]*?\\}\\}/g,\n /\\{#[\\s\\S]*?#\\}/g,\n ]);\n const rawStartPattern = /\\{\\{|\\{#/g;\n let match: RegExpExecArray | null;\n\n while ((match = rawStartPattern.exec(text)) !== null) {\n if (!ranges.some((range) => match.index >= range.start && match.index < range.end)) {\n ranges.push({ start: match.index, end: text.length });\n }\n }\n\n return this._mergeRanges(ranges);\n }\n\n private _findTwigRanges(text: string): MatcherRange[] {\n const blockRanges = this._findBlockTwigRanges(text);\n const inlineRanges = this._findInlineTwigRanges(text)\n .filter((range) => !blockRanges.some((blockRange) => this._isIntersectRange(blockRange, range)));\n\n return [...blockRanges, ...inlineRanges].sort((first, second) => first.start - second.start || first.end - second.end);\n }\n\n private _findPreviewRanges(text: string): MatcherRange[] {\n return this._collectMatches(text, [\n /<!--twig-preview-start:[A-Za-z0-9+/=]+-->[\\s\\S]*?<!--twig-preview-end-->/g,\n ]);\n }\n\n private _createPreviewMarkers(source: string, renderedHtml: string): string {\n const encodedSource = this._encodeSource(source);\n return '<!--twig-preview-start:' + encodedSource + '-->' + this._wrapRenderedHtml(source, renderedHtml) + '<!--twig-preview-end-->';\n }\n\n private _createEmptyPreview(source: string): string {\n const encodedSource = this._encodeSource(source);\n return '<!--twig-preview-start:' + encodedSource + '--><!--twig-preview-end-->';\n }\n\n private _renderTwigSource(source: string): string {\n const twigRuntime = (window as Window & { Twig?: { twig?: (options: { data: string; allowInlineIncludes: boolean; autoescape: boolean }) => { render(data: PreviewTemplateData): string } } }).Twig;\n if (!twigRuntime || typeof twigRuntime.twig !== 'function') {\n console.warn('[<%= it.pluginClassName %>Sandbox] Twig runtime is unavailable');\n return this._createEmptyPreview(source);\n }\n\n try {\n const template = twigRuntime.twig({\n data: source,\n allowInlineIncludes: true,\n autoescape: false,\n });\n const rendered = template.render(this._previewData || {});\n return this._createPreviewMarkers(source, rendered);\n } catch (error) {\n console.warn('[<%= it.pluginClassName %>Sandbox] Twig render failed, showing empty preview', error);\n return this._createEmptyPreview(source);\n }\n }\n\n private _restoreTwigSource(previewMarkup: string): string {\n const match = previewMarkup.match(/<!--twig-preview-start:([A-Za-z0-9+/=]+)-->/);\n return match ? this._decodeSource(match[1]) : previewMarkup;\n }\n\n private _wrapRenderedHtml(source: string, renderedHtml: string): string {\n const attribute = TEMPLATE_DATA_PREVIEW_ATTRIBUTE + '=\"1\"';\n const className = 'em-prevent-action';\n const trimmed = renderedHtml.trim();\n const isBlockTwig = source.includes('{%');\n\n if (isBlockTwig) {\n return '<div ' + attribute + ' class=\"' + className + '\" style=\"display:block;cursor:pointer;\">' + renderedHtml + '</div>';\n }\n\n if (trimmed.startsWith('<')) {\n return '<span ' + attribute + ' class=\"' + className + '\" style=\"display:inline-block;cursor:pointer;\">' + renderedHtml + '</span>';\n }\n\n return '<span ' + attribute + ' class=\"' + className + '\" style=\"cursor:pointer;\">' + renderedHtml + '</span>';\n }\n\n private _bindPreviewClickHandler(): () => void {\n const onClick = (event: MouseEvent) => {\n const target = event.target as HTMLElement | null;\n const previewRoot = target?.closest?.('[' + TEMPLATE_DATA_PREVIEW_ATTRIBUTE + ']');\n if (!previewRoot) {\n return;\n }\n\n this._messageService?.send(OPEN_TEMPLATE_DATA_PANEL_MESSAGE);\n };\n\n document.addEventListener('click', onClick);\n return () => {\n document.removeEventListener('click', onClick);\n };\n }\n}\n\nApp.use(<%= it.pluginClassName %>Sandbox);\n",
3533
3570
  "../../project-templates/shared/comments/plugin-host-comments.en.ts": "export const pluginHostComments = {\n devHostMode: 'Source-mode host: load the plugin from source and keep dev helpers enabled.',\n releasePackages: 'Keep editor/runtime packages external here so the release host stays on the same DI/runtime contract as the built plugin.',\n releaseOptimizeDeps: 'Do not prebundle these packages in Vite, otherwise the host can evaluate its own runtime copy and duplicate singletons.',\n releaseAlias: 'Point the release smoke test to the built plugin bundle from dist/.',\n apiProxy: 'Proxy local /api calls to the target backend and preserve the expected origin header.',\n releaseEntry: 'Release smoke-test entry: boot the host against built assets from dist/.',\n} as const;\n",
@@ -3538,8 +3575,8 @@ var rawTemplateModules = /* #__PURE__ */ Object.assign({
3538
3575
  "../../project-templates/shared/partials/plugin-app-advanced.eta": "import { pluginRegistry, createComponentIdentifier } from '<%= it.packageConfig.extensionsApiPackageName %>';\nimport { ComponentRegistry } from '<%= it.packageConfig.extensionsReactPackageName %>';\nimport type { ExportedApi, IPlugin, Instance } from '<%= it.packageConfig.packageName %>';\nimport type { <%= it.pluginClassName %>Config, <%= it.pluginClassName %>Options } from '../public-types';\nimport type { Group, VisualSettings } from '../interfaces';\nimport { Activate_Product_Settings, Change_Product_Settings } from '../interfaces';\nimport {\n <%= it.pluginClassName %>Icon,\n <%= it.pluginClassName %>SaveForm,\n <%= it.pluginClassName %>SettingsPanel,\n type <%= it.pluginClassName %>SaveFormProps,\n} from './ui/<%= it.pluginClassName %>Panel';\n\ntype DisposableLike = { dispose(): void } | (() => void) | void;\ntype Email = ExportedApi.Email;\ntype ProductBlockConfig = <%~ `NonNullable<${it.pluginClassName}Config['productBlock']>` %>;\ntype ProductBlockGroup = NonNullable<ProductBlockConfig['groups']>[number];\n\nfunction normalizePublicPath(value?: string): string | undefined {\n if (!value) {\n return undefined;\n }\n const trimmed = value.replace(/\\/+$/, '');\n return `${trimmed}/`;\n}\n\nconst AUTO_PUBLIC_PATH = (() => {\n if (typeof document === 'undefined') {\n return undefined;\n }\n\n const currentScript = document.currentScript as HTMLScriptElement | null;\n if (!currentScript?.src) {\n return undefined;\n }\n\n return normalizePublicPath(currentScript.src.replace(/[^/]*$/, ''));\n})();\n\ninterface SaveParams {\n email: Email;\n content: string;\n format: string;\n}\n\nconst ELEMENT_NAME = <%~ it.literalPluginAppElementTitle %>;\nconst PRODUCT_HTML = <%~ it.productHtmlLiteral %>;\nconst PRODUCT_CARD_CSS = <%~ it.productCardCssLiteral %>;\nconst PRODUCT_CARD_SANDBOX_CSS_KEY = 'product-card-styles';\nconst <%= it.pluginClassName %>IconId = createComponentIdentifier<{ size?: number }>('<%= it.pluginClassName %>Icon');\nconst <%= it.pluginClassName %>SettingsPanelId = createComponentIdentifier<{\n groups: Group[];\n settings: VisualSettings;\n selectedGroup?: string;\n onChange?(group: Group | undefined, settings: VisualSettings): void;\n}>('<%= it.pluginClassName %>SettingsPanel');\nconst <%= it.pluginClassName %>SaveFormId = <%~ `createComponentIdentifier<${it.pluginClassName}SaveFormProps>` %>('<%= it.pluginClassName %>SaveForm');\n\n// Step 0 — register React panel/icon components for ElementsApi and SettingsPanelApi.\nComponentRegistry.add(<%= it.pluginClassName %>IconId, <%= it.pluginClassName %>Icon);\nComponentRegistry.add(<%= it.pluginClassName %>SettingsPanelId, <%= it.pluginClassName %>SettingsPanel);\nComponentRegistry.add(<%= it.pluginClassName %>SaveFormId, <%= it.pluginClassName %>SaveForm);\n\nexport class <%= it.pluginClassName %> implements IPlugin {\n private readonly _disposables: Array<{ dispose(): void }> = [];\n private _groups: ProductBlockGroup[] = [];\n\n constructor(\n private readonly _editor: Instance,\n private readonly _options: <%= it.pluginClassName %>Options = {},\n ) {}\n\n init() {\n // Step 1 — sandbox assets: CSS for the email iframe + sandbox.js (see end of init).\n const sandboxApi = this._editor.use('SandboxScriptApi');\n this._disposables.push(\n sandboxApi.registerSandboxCSSCode(PRODUCT_CARD_SANDBOX_CSS_KEY, PRODUCT_CARD_CSS),\n );\n\n const elementsApi = this._editor.use('ElementsApi');\n const messageService = this._editor.use('MessageService');\n const modalApi = this._editor.use('ModalApi');\n const config = this._editor.getConfig?.() as <%~ `Partial<${it.pluginClassName}Config>` %> | undefined;\n this._groups = config?.productBlock?.groups ?? [];\n\n // Step 2 — sidebar element + listen for clicks from sandbox (Activate_Product_Settings).\n this._disposables.push(\n elementsApi.insert({\n name: ELEMENT_NAME,\n title: ELEMENT_NAME,\n icon: {\n type: <%= it.pluginClassName %>IconId,\n props: { size: 24 },\n },\n className: 'product-atom',\n html: PRODUCT_HTML,\n }),\n messageService.addListener(Activate_Product_Settings, this._handleShowPanel),\n );\n\n // Optional demo — save modal + compileEmail download (not required for the product-card loop).\n this._trackDisposable(this._editor.handleSaveEmail?.((event) => {\n const { value } = event;\n let values: SaveParams = {\n email: value,\n content: value.code ?? '',\n format: 'text',\n };\n\n modalApi.show({\n title: <%~ it.literalPluginAppSaveEmailTitle %>,\n onOk: async () => {\n await this._onSave(values);\n },\n content: {\n type: <%= it.pluginClassName %>SaveFormId,\n props: {\n content: value.code ?? '',\n onChange: (nextValues: Omit<SaveParams, 'email'>) => {\n values = { ...values, ...nextValues };\n },\n },\n },\n });\n }));\n\n this._trackDisposable(this._editor.handleNotify?.((event: { id?: string }) => {\n if (event.id === 'EMAIL_SAVING_SUCCESS') {\n return false;\n }\n return undefined;\n }));\n\n this._trackDisposable(this._editor.handleConfigChanged?.(this._onConfigChanged));\n\n // Step 3 — load sandbox script from plugin publicPath (dev: `/`, release: `/dist/`).\n const publicPath = normalizePublicPath(this._options.publicPath) || AUTO_PUBLIC_PATH;\n if (publicPath) {\n this._disposables.push(\n sandboxApi.registerSandboxScript(publicPath + 'sandbox.js'),\n );\n }\n }\n\n private _trackDisposable(value: DisposableLike) {\n if (!value) {\n return;\n }\n\n if (typeof value === 'function') {\n this._disposables.push({ dispose: value });\n return;\n }\n\n if (typeof value.dispose === 'function') {\n this._disposables.push(value);\n }\n }\n\n private _onConfigChanged = (nextConfig: <%~ `Partial<${it.pluginClassName}Config>` %>) => {\n this._groups = nextConfig.productBlock?.enabled !== false\n ? nextConfig.productBlock?.groups ?? []\n : [];\n };\n\n private async _onSave({ email, content, format }: SaveParams) {\n try {\n if (typeof this._editor.compileEmail !== 'function') {\n throw new Error('compileEmail is not available');\n }\n\n const nextEmail: Email = { ...email, code: content };\n const result = await this._editor.compileEmail(nextEmail, true);\n const compiled = result.compiled;\n\n const lowerFormat = format.toLowerCase();\n let fileContent;\n let fileExtension;\n\n if (lowerFormat === 'amp' && compiled.ampHtml) {\n fileContent = compiled.ampHtml;\n fileExtension = 'html';\n } else if (lowerFormat === 'text' && compiled.text) {\n fileContent = compiled.text;\n fileExtension = 'txt';\n } else if (compiled.html) {\n fileContent = compiled.html;\n fileExtension = 'html';\n } else {\n throw new Error('Unable to resolve compiled email content.');\n }\n\n const blob = new Blob([fileContent], {\n type: fileExtension === 'txt' ? 'text/plain' : 'text/html',\n });\n\n const url = URL.createObjectURL(blob);\n const link = document.createElement('a');\n link.href = url;\n link.download = 'email-' + new Date().toISOString().slice(0, 10) + '.' + fileExtension;\n\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n URL.revokeObjectURL(url);\n\n if (typeof this._editor.notify === 'function') {\n this._editor.notify(<%~ it.literalPluginAppSavedSuccessfully %>);\n }\n } catch (error) {\n console.error('[<%= it.pluginClassName %>] Save failed', error);\n }\n }\n\n // Step 4 — open React settings panel; panel changes go back to sandbox via Change_Product_Settings.\n private _handleShowPanel = ({\n groupId,\n visualSettings,\n }: {\n groupId?: string;\n visualSettings: VisualSettings;\n }) => {\n if (!this._groups.length) return;\n const settingsPanel = this._editor.use('SettingsPanelApi');\n settingsPanel.showSettingsPanel({\n content: {\n type: <%= it.pluginClassName %>SettingsPanelId,\n props: {\n groups: this._groups,\n settings: visualSettings,\n selectedGroup: groupId || '',\n onChange: (group, settings) => {\n this._editor.use('MessageService').send(Change_Product_Settings, {\n group,\n visualSettings: settings,\n });\n },\n },\n },\n });\n };\n\n dispose() {\n this._editor.use('ElementsApi').delete(ELEMENT_NAME);\n while (this._disposables.length > 0) {\n const d = this._disposables.pop();\n d?.dispose();\n }\n }\n}\n\npluginRegistry.add(<%~ it.pluginKeyLiteral %>, <%= it.pluginClassName %>);\n",
3539
3576
  "../../project-templates/shared/partials/plugin-app-minimal.eta": "import { pluginRegistry } from '<%= it.packageConfig.extensionsApiPackageName %>';\nimport type { IPlugin, Instance } from '<%= it.packageConfig.packageName %>';\nimport type { <%= it.pluginClassName %>Options } from '../public-types';\n\ntype Disposable = { dispose(): void };\n\nfunction normalizePublicPath(value?: string): string | undefined {\n if (!value) {\n return undefined;\n }\n const trimmed = value.replace(/\\/+$/, '');\n return trimmed + '/';\n}\n\nconst AUTO_PUBLIC_PATH = (() => {\n if (typeof document === 'undefined') {\n return undefined;\n }\n\n const currentScript = document.currentScript as HTMLScriptElement | null;\n if (!currentScript?.src) {\n return undefined;\n }\n\n return normalizePublicPath(currentScript.src.replace(/[^/]*$/, ''));\n})();\n\nexport class <%= it.pluginClassName %> implements IPlugin {\n private readonly _disposables: Disposable[] = [];\n\n constructor(\n private readonly _editor: Instance,\n private readonly _options: <%= it.pluginClassName %>Options = {},\n ) {}\n\n init() {\n const publicPath = normalizePublicPath(this._options.publicPath) || AUTO_PUBLIC_PATH;\n if (publicPath) {\n const sandboxApi = this._editor.use('SandboxScriptApi');\n this._disposables.push(\n sandboxApi.registerSandboxScript(publicPath + 'sandbox.js'),\n );\n }\n }\n\n dispose() {\n while (this._disposables.length > 0) {\n const disposable = this._disposables.pop();\n disposable?.dispose();\n }\n }\n}\n\npluginRegistry.add(<%~ it.pluginKeyLiteral %>, <%= it.pluginClassName %>);\n",
3540
3577
  "../../project-templates/shared/partials/plugin-dev-get-auth-token.eta": "import { hasOAuthCredentials, oauthCredentials } from './oauthCredentials';\n\nexport async function getAuthToken() {\n if (!hasOAuthCredentials()) {\n throw new Error(<%~ it.devAuthMissing %>);\n }\n\n const formData = new FormData();\n formData.append('grant_type', 'client_credentials');\n formData.append('client_id', oauthCredentials.clientId);\n formData.append('client_secret', oauthCredentials.clientSecret);\n\n const response = await fetch('/api?oauth=token', {\n method: 'POST',\n body: formData,\n redirect: 'follow',\n });\n const payload = await response.json().catch(() => null);\n\n if (!response.ok || !payload || typeof payload.access_token !== 'string') {\n throw new Error(\n <%~ it.devAuthTokenFailed %>,\n );\n }\n\n return payload.access_token;\n}\n",
3541
- "../../project-templates/shared/partials/plugin-dev-host-app-advanced.eta": "import { useEffect, useRef, useState } from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { init } from '<%= it.packageConfig.packageName %>';\nimport type { ExportedApi } from '<%= it.packageConfig.packageName %>';\nimport baseEmailHtml from './email.html?raw';\nimport { createEditorConfig } from './editorConfig';\nimport { getAuthToken } from './getAuthToken';\n\nconst productBlockGroups = [\n {\n id: 'group1',\n name: 'iPhone X',\n image_url: '/demo/product-1.svg',\n price: 999.95,\n count: 5,\n },\n {\n id: 'group2',\n name: 'MacBook Pro',\n image_url: '/demo/product-2.svg',\n price: 1499.95,\n count: 1,\n },\n];\n\nconst editorConfig = createEditorConfig({ productBlockGroups });\n\nfunction createDemoEmailId() {\n if (typeof globalThis.crypto?.randomUUID === 'function') {\n return globalThis.crypto.randomUUID();\n }\n\n return `demo-email-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;\n}\n\n// Demo hint injected into the starter email HTML (see README → Demo Flow).\nconst DEMO_TARGET_MARKUP = [\n '<tr em=\"block\" class=\"empty-structure\">',\n ' <td align=\"center\">',\n ' <table align=\"center\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" style=\"max-width: 660px;\">',\n ' <tr>',\n ' <td align=\"center\">',\n ' <table align=\"center\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"91%\">',\n ' <tr>',\n ' <td align=\"left\"></td>',\n ' </tr>',\n ' </table>',\n ' </td>',\n ' </tr>',\n ' </table>',\n ' </td>',\n '</tr>',\n '<tr>',\n ' <td style=\"padding: 32px; font-family: Arial, sans-serif; font-size: 16px; line-height: 24px; color: #333333;\">',\n ' <div style=\"padding: 16px; border: 1px dashed #d9d9d9; border-radius: 8px; background: #ffffff;\">',\n <%~ it.demoMessageLiteral %>,\n ' </div>',\n ' </td>',\n '</tr>',\n].join('');\n\nconst EMPTY_EMAIL_CONTAINER = '<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" border=\"0\" style=\"max-width: 660px; min-width: 660px; width: 660px;\" class=\"em-narrow-table\"></table>';\n\nfunction createDemoEmailHtml() {\n const populatedContainer = EMPTY_EMAIL_CONTAINER.replace('</table>', DEMO_TARGET_MARKUP + '</table>');\n return baseEmailHtml.includes(EMPTY_EMAIL_CONTAINER)\n ? baseEmailHtml.replace(EMPTY_EMAIL_CONTAINER, populatedContainer)\n : baseEmailHtml;\n}\n\nexport interface HostAppOptions {\n plugins: NonNullable<ExportedApi.Options['plugins']>;\n}\n\n<%~ include('editor-init-smoke', it) %>\nexport function renderHostApp(options: HostAppOptions): void {\n const { plugins } = options;\n const contentCode = createDemoEmailHtml();\n\n function EditorApp() {\n const instanceRef = useRef<ExportedApi.Instance | null>(null);\n const [initError, setInitError] = useState<string | null>(null);\n\n useEffect(() => {\n async function run() {\n if (instanceRef.current) {\n return;\n }\n\n const mountElement = document.getElementById('editor-root');\n const smokeMeta = {\n hostKind: 'plugin-host',\n variant: 'plugin-host-advanced',\n mountLabel: '#editor-root',\n } as const;\n\n try {\n const initOptions = {\n getAuthToken,\n element: '#editor-root',\n content: {\n email: {\n id: createDemoEmailId(),\n title: <%~ it.devHostDemoTitleLiteral %>,\n code: contentCode,\n },\n },\n config: editorConfig,\n plugins,\n } satisfies ExportedApi.Options;\n const instance = await init(initOptions);\n instanceRef.current = instance;\n reportEditorReady(smokeMeta, mountElement);\n } catch (error) {\n const message = reportEditorInitError(smokeMeta, error, mountElement);\n setInitError(message);\n }\n }\n\n run();\n }, []);\n\n return (\n <>\n {initError ? (\n <div style={{ marginBottom: '12px', color: '#b42318', fontSize: '14px' }}>\n Editor failed to initialize: {initError}\n </div>\n ) : null}\n <div id=\"editor-root\" />\n </>\n );\n }\n\n const rootElement = document.getElementById('root');\n\n if (!rootElement) {\n throw new Error(<%~ it.rootElementNotFoundLiteral %>);\n }\n\n createRoot(rootElement).render(<EditorApp />);\n}\n",
3542
- "../../project-templates/shared/partials/plugin-dev-host-app-minimal.eta": "import { useEffect, useRef, useState } from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { init } from '<%= it.packageConfig.packageName %>';\nimport type { ExportedApi } from '<%= it.packageConfig.packageName %>';\nimport baseEmailHtml from './email.html?raw';\nimport { editorConfig } from './editorConfig';\nimport { getAuthToken } from './getAuthToken';\n\nfunction createDemoEmailId() {\n if (typeof globalThis.crypto?.randomUUID === 'function') {\n return globalThis.crypto.randomUUID();\n }\n\n return `demo-email-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;\n}\n\nexport interface HostAppOptions {\n plugins: NonNullable<ExportedApi.Options['plugins']>;\n}\n\n<%~ include('editor-init-smoke', it) %>\nexport function renderHostApp(options: HostAppOptions): void {\n const { plugins } = options;\n\n function EditorApp() {\n const instanceRef = useRef<ExportedApi.Instance | null>(null);\n const [initError, setInitError] = useState<string | null>(null);\n\n useEffect(() => {\n async function run() {\n if (instanceRef.current) {\n return;\n }\n\n const mountElement = document.getElementById('editor-root');\n const smokeMeta = {\n hostKind: 'plugin-host',\n variant: 'plugin-host-minimal',\n mountLabel: '#editor-root',\n } as const;\n\n try {\n const initOptions = {\n getAuthToken,\n element: '#editor-root',\n content: {\n email: {\n id: createDemoEmailId(),\n title: <%~ it.devHostDemoTitleLiteral %>,\n code: baseEmailHtml,\n },\n },\n config: editorConfig,\n plugins,\n } satisfies ExportedApi.Options;\n const instance = await init(initOptions);\n instanceRef.current = instance;\n reportEditorReady(smokeMeta, mountElement);\n } catch (error) {\n const message = reportEditorInitError(smokeMeta, error, mountElement);\n setInitError(message);\n }\n }\n\n run();\n }, []);\n\n return (\n <>\n {initError ? (\n <div style={{ marginBottom: '12px', color: '#b42318', fontSize: '14px' }}>\n Editor failed to initialize: {initError}\n </div>\n ) : null}\n <div id=\"editor-root\" />\n </>\n );\n }\n\n const rootElement = document.getElementById('root');\n\n if (!rootElement) {\n throw new Error(<%~ it.rootElementNotFoundLiteral %>);\n }\n\n createRoot(rootElement).render(<EditorApp />);\n}\n",
3578
+ "../../project-templates/shared/partials/plugin-dev-host-app-advanced.eta": "/* @jsxImportSource <%= it.packageConfig.packageName %>/runtime/react */\nimport { useEffect, useRef, useState } from '<%= it.packageConfig.packageName %>/runtime/react';\nimport { createRoot } from '<%= it.packageConfig.packageName %>/runtime/react-dom/client';\nimport { init } from '<%= it.packageConfig.packageName %>';\nimport type { ExportedApi } from '<%= it.packageConfig.packageName %>';\nimport baseEmailHtml from './email.html?raw';\nimport { createEditorConfig } from './editorConfig';\nimport { getAuthToken } from './getAuthToken';\n\nconst productBlockGroups = [\n {\n id: 'group1',\n name: 'iPhone X',\n image_url: '/demo/product-1.svg',\n price: 999.95,\n count: 5,\n },\n {\n id: 'group2',\n name: 'MacBook Pro',\n image_url: '/demo/product-2.svg',\n price: 1499.95,\n count: 1,\n },\n];\n\nconst editorConfig = createEditorConfig({ productBlockGroups });\n\nfunction createDemoEmailId() {\n if (typeof globalThis.crypto?.randomUUID === 'function') {\n return globalThis.crypto.randomUUID();\n }\n\n return `demo-email-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;\n}\n\n// Demo hint injected into the starter email HTML (see README → Demo Flow).\nconst DEMO_TARGET_MARKUP = [\n '<tr em=\"block\" class=\"empty-structure\">',\n ' <td align=\"center\">',\n ' <table align=\"center\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" style=\"max-width: 660px;\">',\n ' <tr>',\n ' <td align=\"center\">',\n ' <table align=\"center\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"91%\">',\n ' <tr>',\n ' <td align=\"left\"></td>',\n ' </tr>',\n ' </table>',\n ' </td>',\n ' </tr>',\n ' </table>',\n ' </td>',\n '</tr>',\n '<tr>',\n ' <td style=\"padding: 32px; font-family: Arial, sans-serif; font-size: 16px; line-height: 24px; color: #333333;\">',\n ' <div style=\"padding: 16px; border: 1px dashed #d9d9d9; border-radius: 8px; background: #ffffff;\">',\n <%~ it.demoMessageLiteral %>,\n ' </div>',\n ' </td>',\n '</tr>',\n].join('');\n\nconst EMPTY_EMAIL_CONTAINER = '<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" border=\"0\" style=\"max-width: 660px; min-width: 660px; width: 660px;\" class=\"em-narrow-table\"></table>';\n\nfunction createDemoEmailHtml() {\n const populatedContainer = EMPTY_EMAIL_CONTAINER.replace('</table>', DEMO_TARGET_MARKUP + '</table>');\n return baseEmailHtml.includes(EMPTY_EMAIL_CONTAINER)\n ? baseEmailHtml.replace(EMPTY_EMAIL_CONTAINER, populatedContainer)\n : baseEmailHtml;\n}\n\nexport interface HostAppOptions {\n plugins: NonNullable<ExportedApi.Options['plugins']>;\n}\n\n<%~ include('editor-init-smoke', it) %>\nexport function renderHostApp(options: HostAppOptions): void {\n const { plugins } = options;\n const contentCode = createDemoEmailHtml();\n\n function EditorApp() {\n const instanceRef = useRef<ExportedApi.Instance | null>(null);\n const [initError, setInitError] = useState<string | null>(null);\n\n useEffect(() => {\n async function run() {\n if (instanceRef.current) {\n return;\n }\n\n const mountElement = document.getElementById('editor-root');\n const smokeMeta = {\n hostKind: 'plugin-host',\n variant: 'plugin-host-advanced',\n mountLabel: '#editor-root',\n } as const;\n\n try {\n const initOptions = {\n getAuthToken,\n element: '#editor-root',\n content: {\n email: {\n id: createDemoEmailId(),\n title: <%~ it.devHostDemoTitleLiteral %>,\n code: contentCode,\n },\n },\n config: editorConfig,\n plugins,\n } satisfies ExportedApi.Options;\n const instance = await init(initOptions);\n instanceRef.current = instance;\n reportEditorReady(smokeMeta, mountElement);\n } catch (error) {\n const message = reportEditorInitError(smokeMeta, error, mountElement);\n setInitError(message);\n }\n }\n\n run();\n }, []);\n\n return (\n <>\n {initError ? (\n <div style={{ marginBottom: '12px', color: '#b42318', fontSize: '14px' }}>\n Editor failed to initialize: {initError}\n </div>\n ) : null}\n <div id=\"editor-root\" />\n </>\n );\n }\n\n const rootElement = document.getElementById('root');\n\n if (!rootElement) {\n throw new Error(<%~ it.rootElementNotFoundLiteral %>);\n }\n\n createRoot(rootElement).render(<EditorApp />);\n}\n",
3579
+ "../../project-templates/shared/partials/plugin-dev-host-app-minimal.eta": "/* @jsxImportSource <%= it.packageConfig.packageName %>/runtime/react */\nimport { useEffect, useRef, useState } from '<%= it.packageConfig.packageName %>/runtime/react';\nimport { createRoot } from '<%= it.packageConfig.packageName %>/runtime/react-dom/client';\nimport { init } from '<%= it.packageConfig.packageName %>';\nimport type { ExportedApi } from '<%= it.packageConfig.packageName %>';\nimport baseEmailHtml from './email.html?raw';\nimport { editorConfig } from './editorConfig';\nimport { getAuthToken } from './getAuthToken';\n\nfunction createDemoEmailId() {\n if (typeof globalThis.crypto?.randomUUID === 'function') {\n return globalThis.crypto.randomUUID();\n }\n\n return `demo-email-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;\n}\n\nexport interface HostAppOptions {\n plugins: NonNullable<ExportedApi.Options['plugins']>;\n}\n\n<%~ include('editor-init-smoke', it) %>\nexport function renderHostApp(options: HostAppOptions): void {\n const { plugins } = options;\n\n function EditorApp() {\n const instanceRef = useRef<ExportedApi.Instance | null>(null);\n const [initError, setInitError] = useState<string | null>(null);\n\n useEffect(() => {\n async function run() {\n if (instanceRef.current) {\n return;\n }\n\n const mountElement = document.getElementById('editor-root');\n const smokeMeta = {\n hostKind: 'plugin-host',\n variant: 'plugin-host-minimal',\n mountLabel: '#editor-root',\n } as const;\n\n try {\n const initOptions = {\n getAuthToken,\n element: '#editor-root',\n content: {\n email: {\n id: createDemoEmailId(),\n title: <%~ it.devHostDemoTitleLiteral %>,\n code: baseEmailHtml,\n },\n },\n config: editorConfig,\n plugins,\n } satisfies ExportedApi.Options;\n const instance = await init(initOptions);\n instanceRef.current = instance;\n reportEditorReady(smokeMeta, mountElement);\n } catch (error) {\n const message = reportEditorInitError(smokeMeta, error, mountElement);\n setInitError(message);\n }\n }\n\n run();\n }, []);\n\n return (\n <>\n {initError ? (\n <div style={{ marginBottom: '12px', color: '#b42318', fontSize: '14px' }}>\n Editor failed to initialize: {initError}\n </div>\n ) : null}\n <div id=\"editor-root\" />\n </>\n );\n }\n\n const rootElement = document.getElementById('root');\n\n if (!rootElement) {\n throw new Error(<%~ it.rootElementNotFoundLiteral %>);\n }\n\n createRoot(rootElement).render(<EditorApp />);\n}\n",
3543
3580
  "../../project-templates/shared/partials/plugin-dev-tsx-debug.eta": "<% if (it.isLegacyWebpack) { %>\n\n\n\nimport '<%= it.packageConfig.packageName %>';\n\n\n\nimport './dev/legacyRuntimeDiagAfterProduct';\n\n\n\nimport PluginClass from './index';\n\n\n\nimport './dev/legacyRuntimeDiagAfterPlugin';\n\n\n\nimport type { ExportedApi } from '<%= it.packageConfig.packageName %>';\n\n\n\nimport { renderHostApp } from './dev/hostApp';\n\n\n\nimport { logLegacyRuntimeStage } from './dev/legacyRuntimeDiag';\n\n\n\nlogLegacyRuntimeStage('before-renderHostApp');\n\n\n\n\n\n\n\nif (!PluginClass) {\n\n\n\n throw new Error('Unable to resolve the local plugin constructor from ./index.');\n\n\n\n}\n\n\n\n\n\n\n\nconst plugins: NonNullable<ExportedApi.Options['plugins']> = [\n\n\n\n [PluginClass, { publicPath: '/' }],\n\n\n\n];\n\n\n\n\n\n\n\nrenderHostApp({ plugins });\n\n\n\n<% } else { %>\n\n\n\nimport type { ExportedApi } from '<%= it.packageConfig.packageName %>';\n\nimport { renderHostApp } from './dev/hostApp';\n\n\n\n\n\n\n\n\nasync function main(): Promise<void> {\n\n\n\n const pluginModule = await import('./index');\n\n\n\n\n\n\n\n if (!pluginModule.default) {\n\n\n\n throw new Error('Unable to resolve the local plugin constructor from ./index.');\n\n\n\n }\n\n\n\n\n\n\n\n const plugins: NonNullable<ExportedApi.Options['plugins']> = [\n\n\n\n [pluginModule.default, { publicPath: '/' }],\n\n\n\n ];\n\n\n\n\n\n\n\n renderHostApp({ plugins });\n\n\n\n}\n\n\n\n\n\n\n\nvoid main();\n\n\n\n<% } %>\n\n",
3544
3581
  "../../project-templates/shared/partials/plugin-dev-tsx-minimal.eta": "import { useEffect, useRef, useState } from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { init } from '<%= it.packageConfig.packageName %>';\nimport type { ExportedApi } from '<%= it.packageConfig.packageName %>';\nimport baseEmailHtml from './dev/email.html?raw';\nimport { editorConfig } from './dev/editorConfig';\nimport { getAuthToken } from './dev/getAuthToken';\n\n<%~ include('plugin-dev-tsx-runtime-helpers', it) %>\n<%~ include('editor-init-smoke', it) %>\nfunction createDemoEmailId() {\n if (typeof globalThis.crypto?.randomUUID === 'function') {\n return globalThis.crypto.randomUUID();\n }\n\n return `demo-email-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;\n}\n\nfunction EditorApp() {\n const instanceRef = useRef<ExportedApi.Instance | null>(null);\n const [initError, setInitError] = useState<string | null>(null);\n\n useEffect(() => {\n async function run() {\n if (instanceRef.current) {\n return;\n }\n\n const mountElement = document.getElementById('editor-root');\n const smokeMeta = {\n hostKind: 'plugin-host',\n variant: 'plugin-dev-minimal',\n mountLabel: '#editor-root',\n } as const;\n\n try {\n const PluginClass = IS_RELEASE_MODE && <%= it.releaseUsesUmd ? 'true' : 'false' %>\n ? undefined\n : await loadPluginConstructor();\n const initOptions = {\n getAuthToken,\n element: '#editor-root',\n content: {\n email: {\n id: createDemoEmailId(),\n title: <%~ it.devHostDemoTitleLiteral %>,\n code: baseEmailHtml,\n },\n },\n config: editorConfig,\n plugins: getPluginEntries(PluginClass),\n } satisfies ExportedApi.Options;\n const instance = await init(initOptions);\n instanceRef.current = instance;\n reportEditorReady(smokeMeta, mountElement);\n } catch (error) {\n const message = reportEditorInitError(smokeMeta, error, mountElement);\n setInitError(message);\n }\n }\n\n run();\n }, []);\n\n return (\n <>\n {initError ? (\n <div style={{ marginBottom: '12px', color: '#b42318', fontSize: '14px' }}>\n Editor failed to initialize: {initError}\n </div>\n ) : null}\n <div id=\"editor-root\" />\n </>\n );\n}\n\nconst rootElement = document.getElementById('root');\n\nif (!rootElement) {\n throw new Error(<%~ it.rootElementNotFoundLiteral %>);\n}\n\ncreateRoot(rootElement).render(<EditorApp />);\n",
3545
3582
  "../../project-templates/shared/partials/plugin-dev-tsx-release.eta": "<% if (it.isLegacyWebpack) { %>\n\n\n\nimport '<%= it.packageConfig.packageName %>';\n\n\n\nimport './dev/legacyRuntimeDiagAfterProduct';\n\n\n\nimport type { ExportedApi } from '<%= it.packageConfig.packageName %>';\n\n\n\nimport { renderHostApp } from './dev/hostApp';\n\n\n\nimport { logLegacyRuntimeStage } from './dev/legacyRuntimeDiag';\n\n\n\n// <%= it.commentReleaseEntry %>\n\n\n\n<% if (it.releaseUsesUmd) { %>\n\n\n\nlogLegacyRuntimeStage('release-before-renderHostApp-umd');\n\n\n\nrenderHostApp({\n\n\n\n plugins: [{\n\n\n\n type: 'umd',\n\n\n\n url: '/dist/index.js',\n\n\n\n name: <%~ it.pluginKeyLiteral %>,\n\n\n\n resolve: 'registry',\n\n\n\n }] as NonNullable<ExportedApi.Options['plugins']>,\n\n\n\n});\n\n\n\n<% } else { %>\n\n\n\nimport PluginClass from './index';\n\n\n\nimport './dev/legacyRuntimeDiagAfterPlugin';\n\n\n\nif (!PluginClass) {\n\n\n\n throw new Error('Unable to resolve the local plugin constructor from ./index.');\n\n\n\n}\n\n\n\n\n\n\n\nrenderHostApp({\n\n\n\n plugins: [[PluginClass, { publicPath: '/dist/' }]],\n\n\n\n});\n\n\n\n<% } %>\n\n\n\n<% } else { %>\n\n\n\nimport type { ExportedApi } from '<%= it.packageConfig.packageName %>';\n\n\n\nimport { renderHostApp } from './dev/hostApp';\n\n\n\n// <%= it.commentReleaseEntry %>\n\n\n\n<% if (it.releaseUsesUmd) { %>\n\n\n\nrenderHostApp({\n\n\n\n plugins: [{\n\n\n\n type: 'umd',\n\n\n\n url: '/dist/index.js',\n\n\n\n name: <%~ it.pluginKeyLiteral %>,\n\n\n\n resolve: 'registry',\n\n\n\n }] as NonNullable<ExportedApi.Options['plugins']>,\n\n\n\n});\n\n\n\n<% } else { %>\n\n\n\nasync function main(): Promise<void> {\n\n\n\n const pluginModule = await import(/* @vite-ignore */ '../dist/index.js') as {\n\n\n\n default?: typeof import('./index').default;\n\n\n\n };\n\n\n\n\n\n\n\n if (!pluginModule.default) {\n\n\n\n throw new Error('Unable to resolve the built plugin constructor from ../dist/index.js.');\n\n\n\n }\n\n\n\n\n\n\n\n const plugins: NonNullable<ExportedApi.Options['plugins']> = [\n\n\n\n [pluginModule.default, { publicPath: '/dist/' }],\n\n\n\n ];\n\n\n\n\n\n\n\n renderHostApp({ plugins });\n\n\n\n}\n\n\n\n\n\n\n\nvoid main();\n\n\n\n<% } %>\n\n\n\n<% } %>\n\n",
@@ -3553,10 +3590,10 @@ var rawTemplateModules = /* #__PURE__ */ Object.assign({
3553
3590
  "../../project-templates/shared/partials/plugin-sandbox-advanced.eta": "import { App, MessageService, SyncService } from '<%= it.packageConfig.extensionsSandboxPackageName %>';\nimport type { IPlugin } from '<%= it.packageConfig.extensionsSandboxPackageName %>';\nimport {\n Activate_Product_Settings,\n Change_Product_Settings,\n Group,\n VisualSettings,\n} from '../interfaces';\n\nimport groupCardTemplate from '../common/templates/group-card.html?raw';\nimport emptyGroupTemplate from '../common/templates/empty-group.html?raw';\n\n/** SSOT: same CSS as plugin-app-advanced (`plugin/assets/advanced/product-card.css` via Eta). */\nconst PRODUCT_CARD_CSS = <%~ it.productCardCssLiteral %>;\n\ntype Disposable = { dispose(): void };\n\nclass ProductCardSandbox implements IPlugin {\n private _messageService!: MessageService;\n private _syncService?: SyncService;\n private _activeAtom: HTMLElement | null = null;\n private readonly _disposables: Disposable[] = [];\n\n private _hasExtensionStyles(): boolean {\n return Boolean(document.querySelector('style[data-extension=\"product-card-styles\"]'));\n }\n\n private _injectStylesFallback() {\n if (this._hasExtensionStyles()) {\n return;\n }\n const style = document.createElement('style');\n style.setAttribute('data-extension', 'product-card-styles');\n style.textContent = PRODUCT_CARD_CSS;\n document.head.appendChild(style);\n }\n\n private async _ensureStyles() {\n for (let attempt = 0; attempt < 40; attempt += 1) {\n if (this._hasExtensionStyles()) {\n return;\n }\n await new Promise((resolve) => setTimeout(resolve, 50));\n }\n this._injectStylesFallback();\n }\n\n private _fillTemplate(template: string, data: Record<string, string>): string {\n return template.replace(/\\{\\{\\s*(\\w+)\\s*\\}\\}/g, (_, key) => data[key] || '');\n }\n\n private _onClick = (e: MouseEvent) => {\n const target = e.target as HTMLElement;\n const atom = target.closest('.product-atom') as HTMLElement | null;\n if (!atom) return;\n this._activeAtom = atom;\n const groupId = this._getGroupId(atom);\n const settings = this._extractVisualSettings(atom);\n this._messageService.send(Activate_Product_Settings, { groupId, visualSettings: settings });\n e.preventDefault();\n };\n\n private _onChangeSettings = ({\n group,\n visualSettings,\n }: {\n group?: Group;\n visualSettings: VisualSettings;\n }) => {\n if (!this._activeAtom) return;\n if (this._getGroupId(this._activeAtom) !== group?.id) {\n this._renderGroupCard(this._activeAtom, group);\n const groupId = this._getGroupId(this._activeAtom);\n const settings = this._extractVisualSettings(this._activeAtom);\n this._messageService.send(Activate_Product_Settings, {\n groupId,\n visualSettings: settings,\n });\n }\n setTimeout(() => {\n this._applyVisualSettings(this._activeAtom!, visualSettings);\n }, 0);\n };\n\n private _renderGroupCard(containerAtom: HTMLElement, group?: Group) {\n const container = containerAtom.querySelector('.groups-container') as HTMLElement;\n if (!container) return;\n const html = group\n ? this._fillTemplate(groupCardTemplate, {\n groupId: group.id,\n imageUrl: group.image_url,\n name: group.name,\n price: String(group.price),\n count: String(group.count),\n })\n : emptyGroupTemplate;\n container.innerHTML = html;\n this._syncService?.commit();\n }\n\n private _applyVisualSettings(atom: HTMLElement, settings: VisualSettings) {\n const card = atom.querySelector('.group-container') as HTMLElement | null;\n if (!card) return;\n const button = card.querySelector('.button-buy') as HTMLElement | null;\n if (settings.blockBorder !== undefined) {\n card.style.border = settings.blockBorder + 'px solid #ccc';\n }\n if (settings.blockPadding !== undefined) {\n card.style.padding = settings.blockPadding + 'px';\n }\n if (settings.cardBackgroundColor) card.style.backgroundColor = settings.cardBackgroundColor;\n if (settings.cardTextColor && button) button.style.color = settings.cardTextColor;\n if (settings.cardTextAlign) card.style.textAlign = settings.cardTextAlign;\n if (button) {\n if (settings.cardButtonColor) button.style.backgroundColor = settings.cardButtonColor;\n if (settings.cardButtonText) button.textContent = settings.cardButtonText;\n }\n this._syncService?.commit();\n }\n\n private _extractVisualSettings(atom: HTMLElement): VisualSettings {\n const card = atom.querySelector('.group-container') as HTMLElement | null;\n const button = card?.querySelector('.button-buy') as HTMLElement | null;\n const cardStyle = card && getComputedStyle(card);\n const buttonStyle = button && getComputedStyle(button);\n return {\n blockBorder: cardStyle?.border ? parseInt(cardStyle.border, 10) : 0,\n blockPadding: cardStyle?.padding ? parseInt(cardStyle.padding, 10) : 0,\n cardBackgroundColor: cardStyle?.backgroundColor || undefined,\n cardTextColor: buttonStyle?.color || cardStyle?.color || undefined,\n cardTextAlign: (cardStyle?.textAlign as VisualSettings['cardTextAlign']) || 'left',\n cardButtonText: button?.textContent || '',\n cardButtonColor: buttonStyle?.backgroundColor || undefined,\n };\n }\n\n private _getGroupId(atom: HTMLElement): string | undefined {\n const container = atom.querySelector('.group-container');\n return container?.getAttribute('data-group-id') || undefined;\n }\n\n init() {\n this._messageService = App.use('MessageService');\n this._syncService = App.use('SyncService');\n void this._ensureStyles();\n // Click on .product-atom in the email → tell app to open the settings panel.\n document.addEventListener('mousedown', this._onClick, true);\n this._disposables.push(\n this._messageService.addListener(Change_Product_Settings, this._onChangeSettings),\n );\n }\n\n dispose() {\n document.removeEventListener('mousedown', this._onClick, true);\n while (this._disposables.length > 0) {\n this._disposables.pop()?.dispose();\n }\n }\n}\n\nApp.use(ProductCardSandbox);\n",
3554
3591
  "../../project-templates/shared/partials/plugin-sandbox-minimal.eta": "import { App } from '<%= it.packageConfig.extensionsSandboxPackageName %>';\nimport type { IPlugin } from '<%= it.packageConfig.extensionsSandboxPackageName %>';\n\nclass <%= it.pluginClassName %>Sandbox implements IPlugin {}\n\nApp.use(<%= it.pluginClassName %>Sandbox);\n",
3555
3592
  "../../project-templates/shared/partials/plugin-types-dts.eta": "declare module '*.html?raw' {\n const content: string;\n export default content;\n}\n\ndeclare module '*.css?raw' {\n const content: string;\n export default content;\n}\n",
3556
- "../../project-templates/shared/partials/plugin-vite-dev-host.eta": "import path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { defineConfig, type UserConfigExport } from 'vite';\nimport react from '@vitejs/plugin-react';\nimport VitePlugin from '<%= it.packageConfig.packageName %>/vite';\nimport PluginDev from '<%= it.packageConfig.packageName %>/vite/pluginDev';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst projectRoot = path.resolve(__dirname, '..');\nconst runtimeReactJsx = '<%= it.packageConfig.packageName %>/runtime/react';\nconst devPort = Number(process.env.PLUGIN_DEV_PORT) || 3000;\n\nconst config = defineConfig(() => ({\n root: projectRoot,\n // <%= it.commentDevHostMode %>\n plugins: [\n PluginDev({ externals: false }),\n react({ jsxImportSource: runtimeReactJsx }),\n VitePlugin(),\n ],\n optimizeDeps: {\n entries: ['index.html'],\n },\n server: {\n port: devPort,\n strictPort: true,\n // Allow `/@vite/client` when the initiator has opaque origin (`Origin: null`, e.g. sandbox iframe).\n cors: true,\n proxy: {\n '/api': {\n target: <%~ JSON.stringify(it.packageConfig.openApiBaseUrl || '') %>,\n secure: false,\n changeOrigin: true,\n configure: (proxy) => {\n // <%= it.commentApiProxy %>\n proxy.on('proxyReq', (proxyReq) => {\n if (proxyReq.getHeader('origin')) {\n proxyReq.setHeader('origin', <%~ JSON.stringify(it.packageConfig.openApiOrigin || it.packageConfig.openApiBaseUrl || '') %>);\n }\n });\n },\n },\n },\n },\n})) satisfies UserConfigExport;\n\nexport default config;\n",
3593
+ "../../project-templates/shared/partials/plugin-vite-dev-host.eta": "import path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { defineConfig, type UserConfigExport } from 'vite';\nimport react from '@vitejs/plugin-react';\nimport VitePlugin from '<%= it.packageConfig.packageName %>/vite';\nimport PluginDev from '<%= it.packageConfig.packageName %>/vite/pluginDev';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst projectRoot = path.resolve(__dirname, '..');\nconst devPort = Number(process.env.PLUGIN_DEV_PORT) || 3000;\n\nconst config = defineConfig(() => ({\n root: projectRoot,\n // <%= it.commentDevHostMode %>\n plugins: [\n PluginDev({ externals: false }),\n react(),\n VitePlugin(),\n ],\n optimizeDeps: {\n entries: ['index.html'],\n },\n server: {\n port: devPort,\n strictPort: true,\n // Allow `/@vite/client` when the initiator has opaque origin (`Origin: null`, e.g. sandbox iframe).\n cors: true,\n proxy: {\n '/api': {\n target: <%~ JSON.stringify(it.packageConfig.openApiBaseUrl || '') %>,\n secure: false,\n changeOrigin: true,\n configure: (proxy) => {\n // <%= it.commentApiProxy %>\n proxy.on('proxyReq', (proxyReq) => {\n if (proxyReq.getHeader('origin')) {\n proxyReq.setHeader('origin', <%~ JSON.stringify(it.packageConfig.openApiOrigin || it.packageConfig.openApiBaseUrl || '') %>);\n }\n });\n },\n },\n },\n },\n})) satisfies UserConfigExport;\n\nexport default config;\n",
3557
3594
  "../../project-templates/shared/partials/plugin-vite-index-html.eta": "<!doctype html>\n<html lang=\"<%= it.htmlLang %>\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title><%= it.indexHtmlTitle %> <%= it.indexHtmlTitleSuffix %></title>\n </head>\n <body>\n <div id=\"root\"></div>\n <script type=\"module\" src=\"<%= it.pluginViteIndexScriptSrc %>\"><\/script>\n </body>\n</html>\n",
3558
3595
  "../../project-templates/shared/partials/plugin-vite-plugin-build.eta": "import path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { defineConfig, type UserConfigExport } from 'vite';\nimport PluginDev from '<%= it.packageConfig.packageName %>/vite/pluginDev';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst projectRoot = path.resolve(__dirname, '..');\nconst pluginDevExternals = <%~ it.importsModeLiteral %>;\n\nconst config = defineConfig({\n root: projectRoot,\n plugins: [\n PluginDev({ externals: pluginDevExternals }),\n ],\n build: {\n sourcemap: true,\n minify: true,\n outDir: 'dist',\n emptyOutDir: false,\n lib: {\n entry: path.resolve(projectRoot, 'src/index.ts'),\n formats: ['<%= it.pluginFormatVite %>'],\n name: '<%= it.pluginClassName %>',\n fileName: () => 'index.js',\n },\n },\n}) satisfies UserConfigExport;\n\nexport default config;\n",
3559
- "../../project-templates/shared/partials/plugin-vite-release-host.eta": "import path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { defineConfig, type UserConfigExport } from 'vite';\nimport react from '@vitejs/plugin-react';\nimport VitePlugin from '<%= it.packageConfig.packageName %>/vite';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst projectRoot = path.resolve(__dirname, '..');\nconst runtimeReactJsx = '<%= it.packageConfig.packageName %>/runtime/react';\nconst devPort = Number(process.env.PLUGIN_DEV_PORT) || 3000;\n\nconst config = defineConfig(() => ({\n root: projectRoot,\n plugins: [\n react({ jsxImportSource: runtimeReactJsx }),\n VitePlugin(),\n ],\n oxc: {\n jsx: {\n runtime: 'automatic',\n importSource: runtimeReactJsx,\n development: false,\n },\n },\n server: {\n port: devPort,\n strictPort: true,\n open: '/release.html',\n // Allow `/@vite/client` when the initiator has opaque origin (`Origin: null`, e.g. sandbox iframe).\n cors: true,\n proxy: {\n '/api': {\n target: <%~ JSON.stringify(it.packageConfig.openApiBaseUrl || '') %>,\n secure: false,\n changeOrigin: true,\n configure: (proxy) => {\n // <%= it.commentApiProxy %>\n proxy.on('proxyReq', (proxyReq) => {\n if (proxyReq.getHeader('origin')) {\n proxyReq.setHeader('origin', <%~ JSON.stringify(it.packageConfig.openApiOrigin || it.packageConfig.openApiBaseUrl || '') %>);\n }\n });\n },\n },\n },\n },\n})) satisfies UserConfigExport;\n\nexport default config;\n",
3596
+ "../../project-templates/shared/partials/plugin-vite-release-host.eta": "import path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { defineConfig, type UserConfigExport } from 'vite';\nimport react from '@vitejs/plugin-react';\nimport VitePlugin from '<%= it.packageConfig.packageName %>/vite';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst projectRoot = path.resolve(__dirname, '..');\nconst devPort = Number(process.env.PLUGIN_DEV_PORT) || 3000;\n\nconst config = defineConfig(() => ({\n root: projectRoot,\n plugins: [\n react(),\n VitePlugin(),\n ],\n server: {\n port: devPort,\n strictPort: true,\n open: '/release.html',\n // Allow `/@vite/client` when the initiator has opaque origin (`Origin: null`, e.g. sandbox iframe).\n cors: true,\n proxy: {\n '/api': {\n target: <%~ JSON.stringify(it.packageConfig.openApiBaseUrl || '') %>,\n secure: false,\n changeOrigin: true,\n configure: (proxy) => {\n // <%= it.commentApiProxy %>\n proxy.on('proxyReq', (proxyReq) => {\n if (proxyReq.getHeader('origin')) {\n proxyReq.setHeader('origin', <%~ JSON.stringify(it.packageConfig.openApiOrigin || it.packageConfig.openApiBaseUrl || '') %>);\n }\n });\n },\n },\n },\n },\n})) satisfies UserConfigExport;\n\nexport default config;\n",
3560
3597
  "../../project-templates/shared/partials/plugin-vite-release-html.eta": "<!doctype html>\n<html lang=\"<%= it.htmlLang %>\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title><%= it.indexHtmlTitle %> release host</title>\n </head>\n <body>\n <div id=\"root\"></div>\n <script type=\"module\" src=\"/src/dev-release.tsx\"><\/script>\n </body>\n</html>\n",
3561
3598
  "../../project-templates/shared/partials/plugin-vite-sandbox-build.eta": "import path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { defineConfig, type UserConfigExport } from 'vite';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst projectRoot = path.resolve(__dirname, '..');\n\nconst config = defineConfig(({ mode }) => ({\n root: projectRoot,\n build: {\n sourcemap: true,\n minify: mode === 'production',\n outDir: mode === 'development' ? 'public' : 'dist',\n emptyOutDir: false,\n lib: {\n entry: path.resolve(projectRoot, 'src/sandbox/index.ts'),\n formats: ['iife'],\n name: '<%= it.pluginClassName %>Sandbox',\n fileName: () => 'sandbox.js',\n },\n },\n})) satisfies UserConfigExport;\n\nexport default config;\n",
3562
3599
  "../../project-templates/shared/partials/plugin-webpack-dev-host-legacy.eta": "import fs from 'node:fs';\n\nimport path from 'node:path';\n\nimport { fileURLToPath } from 'node:url';\n\nimport type { Configuration } from 'webpack';\n\nimport WebpackPlugin from '<%= it.packageConfig.packageName %>/webpack';\nimport { mergeHostEditorDevServer } from '../scripts/hostDevServerHeaders.ts';\n\n\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nconst projectRoot = path.resolve(__dirname, '..');\n\n\n\n<%~ include('plugin-wp-legacy-externals', it) %>\n\n\n\nconst devServerPort = process.env.PLUGIN_DEV_PORT\n\n ? Number(process.env.PLUGIN_DEV_PORT)\n\n : 'auto';\n\n\n\nconst config = {\n\n mode: 'development',\n\n devtool: 'eval-source-map',\n\n entry: path.resolve(projectRoot, 'src/dev.tsx'),\n\n module: {\n\n rules: [\n\n {\n\n test: /\\.tsx?$/,\n\n use: { loader: 'ts-loader', options: { transpileOnly: true } },\n\n exclude: /node_modules/,\n\n },\n\n {\n\n test: /\\.(html|css)$/,\n\n resourceQuery: /raw/,\n\n type: 'asset/source',\n\n },\n\n ],\n\n },\n\n resolve: {\n\n extensions: ['.ts', '.tsx', '.js'],\n\n },\n\n externals: getExternals(),\n\n // <%= it.commentDevHostMode %>\n\n plugins: [\n\n new WebpackPlugin(),\n\n ],\n\n output: {\n\n filename: 'dev.js',\n\n path: path.resolve(projectRoot, 'dev-build'),\n\n publicPath: '/',\n\n },\n\n devServer: {\n\n static: [\n\n { directory: path.resolve(projectRoot, 'public') },\n\n { directory: path.resolve(projectRoot, 'dist'), publicPath: '/dist' },\n\n ],\n\n port: devServerPort,\n\n hot: false,\n\n liveReload: true,\n\n allowedHosts: 'all',\n\n proxy: [\n\n {\n\n context: ['/api'],\n\n target: <%~ JSON.stringify(it.packageConfig.openApiBaseUrl || '') %>,\n\n secure: false,\n\n changeOrigin: true,\n\n onProxyReq: (proxyReq) => {\n\n // <%= it.commentApiProxy %>\n\n proxyReq.setHeader('origin', <%~ JSON.stringify(it.packageConfig.openApiOrigin || it.packageConfig.openApiBaseUrl || '') %>);\n\n },\n\n },\n\n ],\n\n },\n\n} satisfies Configuration;\n\n\n\nmergeHostEditorDevServer(config);\n\nexport default config;\n",
@@ -3598,7 +3635,7 @@ var rawTemplateModules = /* #__PURE__ */ Object.assign({
3598
3635
  "../../project-templates/shared/partials/stand-host-shadow-dom.eta": "import { useEffect, useRef, useState } from 'react';\nimport { createRoot } from 'react-dom/client';\nimport * as <%= it.standProductApiName %> from '<%~ it.packageName %>';\nimport baseEmailHtml from './dev/email.html?raw';\nimport { editorConfig } from './dev/editorConfig';\nimport { getAuthToken } from './dev/getAuthToken';\nimport { createLocalFolderStorageProvider } from './dev/storageProvider';\n\n<%~ include('editor-init-smoke', it) %>\ntype EditorInstance = Awaited<ReturnType<typeof <%= it.standProductApiName %>.init>>;\n\nfunction EditorApp() {\n const instanceRef = useRef<EditorInstance | null>(null);\n const shadowHostRef = useRef<HTMLDivElement | null>(null);\n const [initError, setInitError] = useState<string | null>(null);\n\n useEffect(() => {\n const shadowHost = shadowHostRef.current;\n if (!shadowHost || shadowHost.dataset.mounted === 'true' || instanceRef.current) {\n return;\n }\n\n shadowHost.dataset.mounted = 'true';\n\n const shadowRoot = shadowHost.attachShadow({ mode: 'closed' });\n const shadowStyle = document.createElement('style');\n shadowStyle.textContent = [\n ':host { display: block; min-height: 100vh; background: #ffffff; color: #111827; }',\n '#editor-root { min-height: 100vh; }',\n ].join(' ');\n\n const editorRoot = document.createElement('div');\n editorRoot.id = 'editor-root';\n\n shadowRoot.appendChild(shadowStyle);\n shadowRoot.appendChild(editorRoot);\n\n async function run() {\n const smokeMeta = {\n hostKind: 'stand-host',\n variant: 'stand-advanced-shadow-dom',\n mountLabel: '#shadow-host -> #editor-root',\n } as const;\n\n try {\n const instance = await <%= it.standProductApiName %>.init({\n getAuthToken,\n storageProvider: createLocalFolderStorageProvider(),\n element: editorRoot,\n content: {\n email: {\n title: <%~ JSON.stringify(it.devHostDemoTitle) %>,\n code: baseEmailHtml,\n },\n },\n config: editorConfig,\n });\n instanceRef.current = instance;\n reportEditorReady(smokeMeta, editorRoot);\n } catch (error) {\n const message = reportEditorInitError(smokeMeta, error, editorRoot);\n setInitError(message);\n }\n }\n\n run();\n }, []);\n\n return (\n <>\n <style>{`\n html, body, #root {\n margin: 0;\n min-height: 100%;\n }\n\n body {\n background:\n linear-gradient(135deg, rgba(255, 84, 89, 0.15), rgba(91, 146, 255, 0.18)),\n repeating-linear-gradient(90deg, rgba(17, 24, 39, 0.04) 0 8px, transparent 8px 16px);\n }\n\n body * {\n box-sizing: border-box;\n font-family: 'Courier New', monospace !important;\n letter-spacing: 0.02em;\n }\n\n button, input, select, textarea {\n border-radius: 0 !important;\n }\n `}</style>\n <div style={{ padding: '24px' }}>\n {initError ? (\n <div style={{ marginBottom: '12px', color: '#b42318', fontSize: '14px' }}>\n Editor failed to initialize: {initError}\n </div>\n ) : null}\n <div style={{ marginBottom: '12px', color: '#111827', fontSize: '14px' }}>\n Advanced shadow-dom stand: closed shadow root + OAuth credentials + hostile host CSS\n </div>\n <div\n ref={shadowHostRef}\n id=\"shadow-host\"\n style={{ minHeight: '100vh', border: '2px dashed #111827', background: '#ffffff' }}\n />\n </div>\n </>\n );\n}\n\nconst rootElement = document.getElementById('root');\n\nif (!rootElement) {\n throw new Error(<%~ JSON.stringify(it.commonRootElementNotFound) %>);\n}\n\ncreateRoot(rootElement).render(<EditorApp />);\n",
3599
3636
  "../../project-templates/shared/partials/stand-host-umd.eta": "import { useEffect, useRef, useState } from 'react';\nimport { createRoot } from 'react-dom/client';\nimport baseEmailHtml from './dev/email.html?raw';\nimport { editorConfig } from './dev/editorConfig';\nimport { getAuthToken } from './dev/getAuthToken';\nimport { createLocalFolderStorageProvider } from './dev/storageProvider';\n\nconst editorGlobalName = <%~ JSON.stringify(it.standUmdEditorGlobalName) %>;\n\nfunction getEditorApi() {\n const editorApi = globalThis[editorGlobalName];\n if (!editorApi || typeof editorApi.init !== 'function') {\n throw new Error(`UMD bundle \"${editorGlobalName}\" was not found on window. Check <%~ it.standUmdScriptPath %>.`);\n }\n\n return editorApi;\n}\n\n<%~ include('editor-init-smoke', it) %>\ntype EditorApi = ReturnType<typeof getEditorApi>;\ntype EditorInstance = Awaited<ReturnType<EditorApi['init']>>;\n\nfunction EditorApp() {\n const instanceRef = useRef<EditorInstance | null>(null);\n const [initError, setInitError] = useState<string | null>(null);\n\n useEffect(() => {\n async function run() {\n if (instanceRef.current) {\n return;\n }\n\n const mountElement = document.getElementById('editor-root');\n const smokeMeta = {\n hostKind: 'stand-host',\n variant: 'stand-advanced-umd',\n mountLabel: '#editor-root',\n } as const;\n\n try {\n const instance = await getEditorApi().init({\n getAuthToken,\n storageProvider: createLocalFolderStorageProvider(),\n element: '#editor-root',\n content: {\n email: {\n title: <%~ JSON.stringify(it.devHostDemoTitle) %>,\n code: baseEmailHtml,\n },\n },\n config: editorConfig,\n });\n instanceRef.current = instance;\n reportEditorReady(smokeMeta, mountElement);\n } catch (error) {\n const message = reportEditorInitError(smokeMeta, error, mountElement);\n setInitError(message);\n }\n }\n\n run();\n }, []);\n\n return (\n <div style={{ minHeight: '100vh', background: '#f5f7fb', padding: '24px' }}>\n <div style={{ margin: '0 auto', maxWidth: '1280px' }}>\n {initError ? (\n <div style={{ marginBottom: '12px', color: '#b42318', fontSize: '14px' }}>\n Editor failed to initialize: {initError}\n </div>\n ) : null}\n <div style={{ marginBottom: '12px', color: '#44506b', fontSize: '14px' }}>\n Advanced UMD stand: editor loads from <%= it.standUmdScriptPath %> via a plain script tag.\n </div>\n <div id=\"editor-root\" style={{ minHeight: '100vh' }} />\n </div>\n </div>\n );\n}\n\nconst rootElement = document.getElementById('root');\n\nif (!rootElement) {\n throw new Error(<%~ JSON.stringify(it.commonRootElementNotFound) %>);\n}\n\ncreateRoot(rootElement).render(<EditorApp />);\n",
3600
3637
  "../../project-templates/shared/partials/stand-package-json.eta": "<%~ JSON.stringify(it.standPackageJson, null, 2) + '\\n' %>\n",
3601
- "../../project-templates/shared/partials/stand-readme.eta": "# <%= it.readmePluginPackageName %>\n\n<%= it.readmeGenerated %>\n\n<%= it.readmeWhatIncluded %>\n\n<%= it.readmeSimpleProject %>\n<%= it.readmeStorageProvider %>\n<%= it.readmeDevServer %>\n<% if (it.standAngular) { %>\n<%= it.readmeAngularHost %>\n<% } else { %>\n<%= it.readmeReactWrapper %>\n<%= it.readmeRouteHint %>\n<% } %>\n<% if (it.standReadmeIsResourceProxy === 'true') { %>\n\n<%= it.readmeStandResourceProxyAuth %>\n\n<%= it.readmeOauthTokenFile %>\n<% } else if (it.standReadmeIsClosedLoop === 'true') { %>\n<%= it.readmeClosedStandaloneKey %>\n<%= it.readmeClosedHandleReadLocale %>\n\n<%= it.readmeConfiguration %>\n\n<%= it.readmeClosedConfigHint %>\n<% } else { %>\n<%= it.readmeOauthProxy %>\n\n<%= it.readmeOauthTitle %>\n\n<%= it.readmeOauthHint %>\n<% } %>\n<% if (it.standReadmeIsResourceProxy === 'true') { %>\n\n<%= it.readmeStandResourceProxyHint %>\n\n<%= it.readmeStandResourceProxySecurityWarning %>\n\n<%= it.readmeStandResourceProxyDevRoutes %>\n\n<%= it.readmeStandResourceProxySampleProject %>\n<% } %>\n\n<%= it.readmeCommands %>\n\n```bash\nnpm install\n```\n\n<%= it.readmeCommandsDevelopment %>\n\n```bash\nnpm start\n```\n\n<%= it.readmeCommandsProduction %>\n\n<% if (it.standBundler === 'vite') { %>\n```bash\nnpm run build\nnpm run preview\n# alias: npm run serve:dist\n```\n<% } else { %>\n```bash\nnpm run build\nnpm run serve:dist\n```\n<% } %>\n\n<%= it.readmeCommandsProductionNote %>\n\n<% if (it.standAngular) { %>\n<%= it.readmeAngularCommandsDevUrl %>\n<%= it.readmeAngularCommandsProdUrl %>\n<% } else { %>\n> Production-like URL: `http://localhost:<%~ it.standPreviewPort %>/` (webpack/vite). Subpath stands may need the route suffix from dev mode.\n<% } %>\n\n<%= it.readmeStructure %>\n\n<%= it.readmeEntryPoint %>\n<%= it.readmeEmailTemplate %>\n<%= it.readmeEditorConfigFile %>\n<%= it.readmeStorageProviderFile %>\n<%= it.readmeStorageMiddleware %>\n<%= it.readmeStorageFolder %>\n<%= it.readmeConfigDir %>\n<% if (it.standReadmeIsClosedLoop === 'true') { %>\n<%= it.readmeStandaloneCredentialsFile %>\n<% } else if (it.standReadmeIsResourceProxy !== 'true') { %>\n<%= it.readmeOauthCredentialsFile %>\n<%= it.readmeOauthTokenFile %>\n<% } %>\n",
3638
+ "../../project-templates/shared/partials/stand-readme.eta": "# <%= it.readmePluginPackageName %>\n\n<%= it.readmeGenerated %>\n\n<%= it.readmeWhatIncluded %>\n\n<%= it.readmeSimpleProject %>\n<%= it.readmeStorageProvider %>\n<%= it.readmeDevServer %>\n<% if (it.standAngular) { %>\n<%= it.readmeAngularHost %>\n<% } else { %>\n<%= it.readmeReactWrapper %>\n<%= it.readmeRouteHint %>\n<% } %>\n<% if (it.standReadmeIsResourceProxy === 'true') { %>\n\n<%= it.readmeStandResourceProxyAuth %>\n\n<%= it.readmeOauthTokenFile %>\n<% } else if (it.standReadmeIsClosedLoop === 'true') { %>\n<%= it.readmeClosedStandaloneKey %>\n<%= it.readmeClosedHandleReadLocale %>\n\n<%= it.readmeConfiguration %>\n\n<%= it.readmeClosedConfigHint %>\n<% } else { %>\n<%= it.readmeOauthProxy %>\n\n<%= it.readmeOauthTitle %>\n\n<%= it.readmeOauthHint %>\n<% } %>\n<% if (it.standReadmeIsResourceProxy === 'true') { %>\n\n<%= it.readmeStandResourceProxyHint %>\n\n<%= it.readmeStandResourceProxySecurityWarning %>\n\n<%= it.readmeStandResourceProxyDevRoutes %>\n\n<%= it.readmeStandResourceProxySampleProject %>\n<% } %>\n\n<%= it.readmeCommands %>\n\n```bash\nnpm install\n```\n\n<%= it.readmeCommandsDevelopment %>\n\n```bash\nnpm start\n```\n\n<%= it.readmeCommandsProduction %>\n\n<% if (it.standBundler === 'vite') { %>\n```bash\nnpm run build\nnpm run preview\n# alias: npm run serve:dist\n```\n<% } else { %>\n```bash\nnpm run build\nnpm run serve:dist\n```\n<% } %>\n\n<%= it.readmeCommandsProductionNote %>\n\n<% if (it.readmeModuleFederationHint) { %>\n\n<%= it.readmeModuleFederationHint %>\n\n<% } %>\n\n<% if (it.standAngular) { %>\n<%= it.readmeAngularCommandsDevUrl %>\n<%= it.readmeAngularCommandsProdUrl %>\n<% if (it.readmeAngularEsbuildClientProd) { %>\n<%= it.readmeAngularEsbuildClientProd %>\n<% } %>\n<% } else { %>\n> Production-like URL: `http://localhost:<%~ it.standPreviewPort %>/` (webpack/vite). Subpath stands may need the route suffix from dev mode.\n<% } %>\n\n<%= it.readmeStructure %>\n\n<%= it.readmeEntryPoint %>\n<%= it.readmeEmailTemplate %>\n<%= it.readmeEditorConfigFile %>\n<%= it.readmeStorageProviderFile %>\n<%= it.readmeStorageMiddleware %>\n<%= it.readmeStorageFolder %>\n<%= it.readmeConfigDir %>\n<% if (it.standReadmeIsClosedLoop === 'true') { %>\n<%= it.readmeStandaloneCredentialsFile %>\n<% } else if (it.standReadmeIsResourceProxy !== 'true') { %>\n<%= it.readmeOauthCredentialsFile %>\n<%= it.readmeOauthTokenFile %>\n<% } %>\n",
3602
3639
  "../../project-templates/shared/partials/stand-resource-proxy-demo-storage-provider.eta": "/** Demo URLs from buildResourceProxyStandPolicy (email + FM seed). */\nconst RESOURCE_PROXY_DEMO_DIRECT_URL = <%~ JSON.stringify(it.resourceProxyDemoDirectUrl) %>;\nconst RESOURCE_PROXY_DEMO_PROXY_URL = <%~ JSON.stringify(it.resourceProxyDemoProxyUrl) %>;\n\nfunction createResourceProxyDemoSeedFiles(): FileSystemItem[] {\n const date = new Date().toISOString();\n return [\n {\n id: 'demo-direct-placehold',\n name: 'directHosts (placehold.co).png',\n folderId: '',\n isFolder: false,\n type: 'image/png',\n size: 0,\n date,\n url: RESOURCE_PROXY_DEMO_DIRECT_URL,\n thumbnailUrl: RESOURCE_PROXY_DEMO_DIRECT_URL,\n },\n {\n id: 'demo-proxy-dummyimage',\n name: 'via proxy (dummyimage.com).png',\n folderId: '',\n isFolder: false,\n type: 'image/png',\n size: 0,\n date,\n url: RESOURCE_PROXY_DEMO_PROXY_URL,\n thumbnailUrl: RESOURCE_PROXY_DEMO_PROXY_URL,\n },\n ];\n}\n\nfunction isResourceProxyDemoFileId(id: string | undefined): boolean {\n return id === 'demo-direct-placehold' || id === 'demo-proxy-dummyimage';\n}\n\nfunction normalizeFolderId(folderId: string | undefined, rootId: string | undefined): string {\n if (!folderId || folderId === rootId) {\n return '';\n }\n return folderId;\n}\n\nfunction filterDemoItems(\n demoFiles: FileSystemItem[],\n folderId: string | undefined,\n rootId: string | undefined,\n options: { search?: string; itemType?: 'all' | 'file' | 'folder' },\n): FileSystemItem[] {\n const normalizedFolderId = normalizeFolderId(folderId, rootId);\n if (options.itemType === 'folder') {\n return [];\n }\n\n let items = demoFiles.filter((item) => item.folderId === normalizedFolderId);\n const search = (options.search || '').trim().toLowerCase();\n if (search) {\n items = items.filter((item) => item.name.toLowerCase().includes(search));\n }\n return items;\n}\n\nfunction removeDemoFile(demoFiles: FileSystemItem[], id: string): void {\n const index = demoFiles.findIndex((demoItem) => demoItem.id === id);\n if (index >= 0) {\n demoFiles.splice(index, 1);\n }\n}\n\n/**\n * Local folder storage with two seeded external-image demo files for resource-proxy stand.\n * Demo files can be deleted or moved during the session; they reappear after page reload.\n */\nexport function createResourceProxyDemoStorageProvider(): StorageProvider {\n const inner = createLocalFolderStorageProvider();\n const demoFiles = createResourceProxyDemoSeedFiles();\n\n return {\n ...inner,\n\n async getItems(options) {\n const result = await inner.getItems(options);\n const demoItems = filterDemoItems(demoFiles, options.folderId, inner.rootId, options);\n const items = [...demoItems, ...(result.items || [])];\n const pagination = result.pagination\n ? {\n ...result.pagination,\n total: (result.pagination.total ?? result.items?.length ?? 0) + demoItems.length,\n }\n : result.pagination;\n\n return { items, pagination };\n },\n\n async deleteItem(item, options) {\n if (isResourceProxyDemoFileId(item.id)) {\n removeDemoFile(demoFiles, item.id);\n return;\n }\n\n return inner.deleteItem!(item, options);\n },\n\n async deleteItems(items, options) {\n const demoItems = items.filter((item) => isResourceProxyDemoFileId(item.id));\n for (const item of demoItems) {\n removeDemoFile(demoFiles, item.id);\n }\n\n const remaining = items.filter((item) => !isResourceProxyDemoFileId(item.id));\n if (remaining.length === 0) {\n return {\n success: demoItems.every(() => true),\n detailed: demoItems.map((item) => ({ success: true, requestId: item.id })),\n };\n }\n\n const innerResult = await inner.deleteItems!(remaining, options);\n const demoDetailed = demoItems.map((item) => ({ success: true, requestId: item.id }));\n return {\n success: innerResult.success && demoDetailed.every((entry) => entry.success),\n detailed: [...demoDetailed, ...(innerResult.detailed || [])],\n };\n },\n\n async moveItem(item, targetFolderId) {\n if (isResourceProxyDemoFileId(item.id)) {\n const demoItem = demoFiles.find((entry) => entry.id === item.id);\n if (!demoItem) {\n throw new Error('Demo file not found');\n }\n demoItem.folderId = normalizeFolderId(targetFolderId, inner.rootId);\n return { id: demoItem.id, folderId: demoItem.folderId };\n }\n\n return inner.moveItem!(item, targetFolderId);\n },\n\n async renameItem(item, newName) {\n if (isResourceProxyDemoFileId(item.id)) {\n const demoItem = demoFiles.find((entry) => entry.id === item.id);\n if (!demoItem) {\n throw new Error('Demo file not found');\n }\n demoItem.name = newName;\n return { id: demoItem.id, name: newName };\n }\n\n return inner.renameItem!(item, newName);\n },\n };\n}\n",
3603
3640
  "../../project-templates/shared/partials/stand-storage-provider.eta": "import type {\n BatchResult,\n FileSystemItem,\n OperationResult,\n StorageProvider,\n UploadFilesRequest,\n} from '<%~ it.storageTypesPackage %>';\n\n/**\n * StorageProvider for dev stand. Stores files in ./storage via /dev-storage.\n * Uses pathMode: true - folderId and id are path strings.\n */\nexport function createLocalFolderStorageProvider(): StorageProvider {\n const base = '/dev-storage';\n\n const toPath = (id: string | null | undefined): string => {\n if (!id || id === '/' || id === '.') return '';\n return id.replace(/^\\/+/, '');\n };\n\n const readErrorMessage = async (res: Response, fallback: string): Promise<string> => {\n const err = await res.json().catch(() => ({})) as { error?: string };\n return err.error || fallback;\n };\n\n return {\n pathMode: true,\n rootId: '',\n ensureFolderTrailingSlash: true,\n\n async getItems(options) {\n const folderId = toPath(options.folderId);\n const q = folderId ? `?folderId=${encodeURIComponent(folderId)}` : '';\n const res = await fetch(`${base}/items${q}`);\n if (!res.ok) throw new Error(`getItems failed: ${res.status}`);\n const data = await res.json();\n return {\n items: (data.items || []).map((it: Record<string, unknown>) => ({\n ...it,\n folderId: it['folderId'] ?? '',\n })),\n pagination: data.pagination,\n };\n },\n\n async createFolder(name: string, parentid?: string) {\n const res = await fetch(`${base}/folder`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n name,\n parentId: toPath(parentid),\n }),\n });\n if (!res.ok) {\n const err = await res.json().catch(() => ({}));\n throw new Error(err.error || `createFolder failed: ${res.status}`);\n }\n const item = await res.json();\n return item as FileSystemItem;\n },\n\n async uploadFile(file: {\n name: string;\n size: number;\n type: string;\n folderId?: string;\n data: Blob | File;\n }) {\n const form = new FormData();\n form.append('file', file.data instanceof Blob ? new File([file.data], file.name, { type: file.type }) : file.data);\n form.append('folderId', toPath(file.folderId) || '');\n const res = await fetch(`${base}/upload`, {\n method: 'POST',\n body: form,\n });\n if (!res.ok) {\n throw new Error(await readErrorMessage(res, `uploadFile failed: ${res.status}`));\n }\n const data = await res.json();\n const items = data.items || [];\n const first = items[0];\n if (!first) throw new Error('No file returned');\n return { id: first.id, ...first } as FileSystemItem;\n },\n\n async uploadFiles(request: UploadFilesRequest): Promise<BatchResult<FileSystemItem>> {\n const form = new FormData();\n form.append('folderId', toPath(request.folderId) || '');\n for (const it of request.items) {\n const file = it.data instanceof Blob ? new File([it.data], it.name, { type: it.type }) : it.data;\n form.append('file', file);\n }\n const res = await fetch(`${base}/upload`, {\n method: 'POST',\n body: form,\n });\n if (!res.ok) {\n throw new Error(await readErrorMessage(res, `uploadFiles failed: ${res.status}`));\n }\n const data = await res.json();\n const items = (data.items || []).map((it: Record<string, unknown>) => ({\n ...it,\n id: String(it['id'] || ''),\n })) as FileSystemItem[];\n if (request.items.length > 0 && items.length === 0) {\n throw new Error('No files returned');\n }\n const detailed: OperationResult<FileSystemItem>[] = items.map((it, index) => ({\n success: true,\n requestId: request.items[index]?.requestId,\n data: it,\n }));\n return { success: true, detailed };\n },\n\n async uploadFileByUrl(url: string, folderId?: string) {\n const res = await fetch(`${base}/upload-by-url`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ url, folderId: toPath(folderId) }),\n });\n if (!res.ok) {\n const err = await res.json().catch(() => ({}));\n throw new Error(err.error || `uploadFileByUrl failed: ${res.status}`);\n }\n const item = await res.json();\n return item as FileSystemItem;\n },\n\n async deleteItem(item: FileSystemItem, _options: { permanent: boolean }) {\n const res = await fetch(`${base}/item`, {\n method: 'DELETE',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ path: item.id }),\n });\n if (!res.ok) {\n throw new Error(await readErrorMessage(res, `deleteItem failed: ${res.status}`));\n }\n },\n\n async deleteItems(\n items: FileSystemItem[],\n _options: { permanent: boolean },\n ): Promise<BatchResult<never>> {\n const detailed: OperationResult<never>[] = await Promise.all(\n items.map(async (item) => {\n try {\n const res = await fetch(`${base}/item`, {\n method: 'DELETE',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ path: item.id }),\n });\n if (!res.ok) {\n throw new Error(await readErrorMessage(res, `deleteItem failed: ${res.status}`));\n }\n return { success: true, requestId: item.id };\n } catch (error) {\n return {\n success: false,\n requestId: item.id,\n error: error instanceof Error ? error : new Error(String(error)),\n };\n }\n }),\n );\n\n return {\n success: detailed.every((entry) => entry.success),\n detailed,\n };\n },\n\n async renameItem(item: FileSystemItem, newName: string) {\n const res = await fetch(`${base}/rename`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ path: item.id, newName }),\n });\n if (!res.ok) {\n throw new Error(await readErrorMessage(res, `renameItem failed: ${res.status}`));\n }\n const updated = await res.json();\n return updated as FileSystemItem;\n },\n\n async moveItem(item: FileSystemItem, targetFolderId?: string) {\n const res = await fetch(`${base}/move`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n path: item.id,\n targetFolderId: toPath(targetFolderId),\n }),\n });\n if (!res.ok) {\n throw new Error(await readErrorMessage(res, `moveItem failed: ${res.status}`));\n }\n const updated = await res.json();\n return updated as FileSystemItem;\n },\n\n getUrl(file: FileSystemItem) {\n return `${base}/file/${encodeURIComponent(file.id)}`;\n },\n };\n}\n",
3604
3641
  "../../project-templates/shared/partials/stand-vite-index-body.eta": "<% if (it.standAdvancedUmd) { %>\n <script src=\"<%= it.standUmdScriptPath %>\"><\/script>\n<% } %>\n <script type=\"module\" src=\"<%~ it.standIndexScriptSrc %>\"><\/script>\n",
@@ -3624,7 +3661,7 @@ var rawTemplateModules = /* #__PURE__ */ Object.assign({
3624
3661
  "../../project-templates/shared/stand-webpack-base/tsconfig.json": "{\n \"compilerOptions\": {\n \"target\": \"ES2020\",\n \"module\": \"ESNext\",\n \"moduleResolution\": \"Bundler\",\n \"jsx\": \"react-jsx\",\n \"strict\": true,\n \"esModuleInterop\": true,\n \"allowSyntheticDefaultImports\": true,\n \"skipLibCheck\": true,\n \"forceConsistentCasingInFileNames\": true,\n \"baseUrl\": \".\",\n \"types\": []\n },\n \"include\": [\"src/**/*\"]\n}\n",
3625
3662
  "../../project-templates/stand/advanced/memory-usage/vite/README.md.eta": "<%~ include('stand-readme', it) %>\n",
3626
3663
  "../../project-templates/stand/advanced/memory-usage/vite/config/dev-host.ts.eta": "<%~ include('stand-dev-host-vite-memory', it) %>\n",
3627
- "../../project-templates/stand/advanced/memory-usage/vite/config/lib/createMemoryUsageStandConfig.ts": "import path from 'node:path';\nimport react from '@vitejs/plugin-react';\nimport { v4 as uuid } from 'uuid';\nimport type { PluginOption, UserConfigExport } from 'vite';\nimport { defineConfig } from 'vite';\nimport cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js';\nimport { ViteImageOptimizer } from 'vite-plugin-image-optimizer';\nimport devStorageMiddleware from '../../scripts/devStorageMiddleware.ts';\nimport { createStandApiProxyOptions } from '../../../../../shared/stand-vite-base/config/lib/standApiProxy.ts';\nimport { STAND_PREVIEW_HEADERS, STAND_PREVIEW_PORT } from './standPreviewSettings.ts';\nimport { STAND_VITE_PRODUCTION_BUILD } from '../../../../../shared/stand-vite-base/config/lib/standProductionBuild.ts';\n\ninterface CreateMemoryUsageStandConfigOptions {\n projectRoot: string;\n vitePlugin: () => PluginOption[];\n closedLoop?: boolean;\n apiBaseUrl: string;\n apiOrigin: string;\n}\n\nexport function createMemoryUsageStandConfig(options: CreateMemoryUsageStandConfigOptions): UserConfigExport {\n const {\n projectRoot,\n vitePlugin,\n closedLoop,\n apiBaseUrl,\n apiOrigin,\n } = options;\n\n return defineConfig(() => {\n const apiProxy = closedLoop\n ? undefined\n : createStandApiProxyOptions(apiBaseUrl, apiOrigin);\n\n return {\n root: projectRoot,\n plugins: [\n react(),\n ...vitePlugin(),\n ViteImageOptimizer(),\n cssInjectedByJsPlugin({\n injectCode: (content) => `\n if (document) {\n const style = document.createElement('style');\n style.setAttribute('data-mf-app', 'memory-usage-test');\n style.innerHTML = ${content};\n document.body.append(style);\n }`,\n }),\n {\n name: 'dev-storage',\n configureServer(server) {\n server.middlewares.use(devStorageMiddleware());\n },\n },\n ],\n resolve: {\n alias: {\n '@': path.join(projectRoot, 'src'),\n },\n },\n server: {\n port: 3000,\n ...(apiProxy ? { proxy: apiProxy } : {}),\n },\n build: {\n ...STAND_VITE_PRODUCTION_BUILD,\n outDir: './dist/profile-a',\n rollupOptions: {\n output: {\n entryFileNames: `[name]${uuid()}.js`,\n chunkFileNames: `[name]${uuid()}.js`,\n assetFileNames: `[name]${uuid()}.[ext]`,\n },\n },\n },\n preview: {\n port: STAND_PREVIEW_PORT,\n headers: STAND_PREVIEW_HEADERS,\n ...(apiProxy ? { proxy: apiProxy } : {}),\n },\n };\n });\n}\n",
3664
+ "../../project-templates/stand/advanced/memory-usage/vite/config/lib/createMemoryUsageStandConfig.ts": "import path from 'node:path';\nimport react from '@vitejs/plugin-react';\nimport { v4 as uuid } from 'uuid';\nimport type { PluginOption, UserConfigExport } from 'vite';\nimport { defineConfig } from 'vite';\nimport cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js';\nimport { ViteImageOptimizer } from 'vite-plugin-image-optimizer';\nimport devStorageMiddleware from '../../scripts/devStorageMiddleware.ts';\nimport { createStandApiProxyOptions } from './standApiProxy.ts';\nimport { STAND_PREVIEW_HEADERS, STAND_PREVIEW_PORT } from './standPreviewSettings.ts';\nimport { STAND_VITE_PRODUCTION_BUILD } from './standProductionBuild.ts';\n\ninterface CreateMemoryUsageStandConfigOptions {\n projectRoot: string;\n vitePlugin: () => PluginOption[];\n closedLoop?: boolean;\n apiBaseUrl: string;\n apiOrigin: string;\n}\n\nexport function createMemoryUsageStandConfig(options: CreateMemoryUsageStandConfigOptions): UserConfigExport {\n const {\n projectRoot,\n vitePlugin,\n closedLoop,\n apiBaseUrl,\n apiOrigin,\n } = options;\n\n return defineConfig(() => {\n const apiProxy = closedLoop\n ? undefined\n : createStandApiProxyOptions(apiBaseUrl, apiOrigin);\n\n return {\n root: projectRoot,\n plugins: [\n react(),\n ...vitePlugin(),\n ViteImageOptimizer(),\n cssInjectedByJsPlugin({\n injectCode: (content) => `\n if (document) {\n const style = document.createElement('style');\n style.setAttribute('data-mf-app', 'memory-usage-test');\n style.innerHTML = ${content};\n document.body.append(style);\n }`,\n }),\n {\n name: 'dev-storage',\n configureServer(server) {\n server.middlewares.use(devStorageMiddleware());\n },\n },\n ],\n resolve: {\n alias: {\n '@': path.join(projectRoot, 'src'),\n },\n },\n server: {\n port: 3000,\n ...(apiProxy ? { proxy: apiProxy } : {}),\n },\n build: {\n ...STAND_VITE_PRODUCTION_BUILD,\n outDir: './dist/profile-a',\n rollupOptions: {\n output: {\n entryFileNames: `[name]${uuid()}.js`,\n chunkFileNames: `[name]${uuid()}.js`,\n assetFileNames: `[name]${uuid()}.[ext]`,\n },\n },\n },\n preview: {\n port: STAND_PREVIEW_PORT,\n headers: STAND_PREVIEW_HEADERS,\n ...(apiProxy ? { proxy: apiProxy } : {}),\n },\n };\n });\n}\n",
3628
3665
  "../../project-templates/stand/advanced/memory-usage/vite/index.html.eta": "<%~ include('stand-vite-index-shell', it) %>\n",
3629
3666
  "../../project-templates/stand/advanced/memory-usage/vite/package.json.eta": "<%~ include('stand-package-json', it) %>\n",
3630
3667
  "../../project-templates/stand/advanced/memory-usage/vite/src/dev/editorConfig.ts.eta": "<%~ include('stand-editor-config', it) %>\n",
@@ -3633,6 +3670,28 @@ var rawTemplateModules = /* #__PURE__ */ Object.assign({
3633
3670
  "../../project-templates/stand/advanced/memory-usage/vite/src/dev/oauthCredentials.ts": "export const oauthCredentials = {\n clientId: 'YOUR_CLIENT_ID',\n clientSecret: 'YOUR_CLIENT_SECRET',\n};\n\nexport function hasOAuthCredentials() {\n return oauthCredentials.clientId !== 'YOUR_CLIENT_ID'\n && oauthCredentials.clientSecret !== 'YOUR_CLIENT_SECRET';\n}\n",
3634
3671
  "../../project-templates/stand/advanced/memory-usage/vite/src/dev/storageProvider.ts.eta": "<%~ include('stand-storage-provider', it) %>\n",
3635
3672
  "../../project-templates/stand/advanced/memory-usage/vite/src/index.tsx.eta": "<%~ include('stand-host-oauth-default-banners', it) %>\n",
3673
+ "../../project-templates/stand/advanced/module-federation/vite/README.md.eta": "<%~ include('stand-readme', it) %>\n",
3674
+ "../../project-templates/stand/advanced/module-federation/vite/config/dev-host.ts.eta": "import path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { createModuleFederationHostConfig } from './lib/createModuleFederationHostConfig.ts';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst projectRoot = path.resolve(__dirname, '..');\n\nexport default createModuleFederationHostConfig({\n projectRoot,\n apiBaseUrl: <%~ JSON.stringify(it.standOpenApiBaseUrl) %>,\n apiOrigin: <%~ JSON.stringify(it.standOpenApiOrigin) %>,\n});\n",
3675
+ "../../project-templates/stand/advanced/module-federation/vite/config/dev-remote.ts.eta": "import path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport VitePlugin from '<%~ it.standVitePluginPackage %>/vite';\nimport { createModuleFederationRemoteConfig } from './lib/createModuleFederationRemoteConfig.ts';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst projectRoot = path.resolve(__dirname, '..');\n\nexport default createModuleFederationRemoteConfig({\n projectRoot,\n vitePlugin: VitePlugin,\n closedLoop: <%= it.standClosedLoop %>,\n apiBaseUrl: <%~ JSON.stringify(it.standOpenApiBaseUrl) %>,\n apiOrigin: <%~ JSON.stringify(it.standOpenApiOrigin) %>,\n});\n",
3676
+ "../../project-templates/stand/advanced/module-federation/vite/config/lib/createModuleFederationHostConfig.ts": "import path from 'node:path';\nimport react from '@vitejs/plugin-react';\nimport { federation } from '@module-federation/vite';\nimport type { UserConfigExport } from 'vite';\nimport { defineConfig } from 'vite';\nimport devStorageMiddleware from '../../scripts/devStorageMiddleware.ts';\nimport { createStandApiProxyOptions } from './standApiProxy.ts';\nimport { STAND_VITE_PRODUCTION_BUILD } from './standProductionBuild.ts';\nimport { crossOriginAssetCorsPlugin } from './crossOriginAssetCorsPlugin.ts';\nimport {\n MF_STAND_HOST,\n MF_STAND_HOST_PORT,\n moduleFederationHostRemotes,\n moduleFederationRemoteEntryUrl,\n} from './moduleFederationHosts.ts';\nimport { MODULE_FEDERATION_HOST_SHARED } from './moduleFederationShared.ts';\nimport { getModuleFederationHostOptimizeDepsEntries } from './moduleFederationOptimizeDeps.ts';\nimport { STAND_PREVIEW_HEADERS } from './standPreviewSettings.ts';\n\ninterface CreateModuleFederationHostConfigOptions {\n projectRoot: string;\n apiBaseUrl: string;\n apiOrigin: string;\n}\n\nexport function createModuleFederationHostConfig(options: CreateModuleFederationHostConfigOptions): UserConfigExport {\n const { projectRoot, apiBaseUrl, apiOrigin } = options;\n const remoteEntry = moduleFederationRemoteEntryUrl();\n\n return defineConfig(() => {\n const apiProxy = createStandApiProxyOptions(apiBaseUrl, apiOrigin);\n\n return {\n root: projectRoot,\n base: '/',\n plugins: [\n react(),\n federation({\n name: 'mf_stand_host',\n manifest: true,\n dts: false,\n shareStrategy: 'loaded-first',\n remotes: moduleFederationHostRemotes(remoteEntry),\n shared: MODULE_FEDERATION_HOST_SHARED,\n }),\n crossOriginAssetCorsPlugin(),\n {\n name: 'dev-storage',\n configureServer(server) {\n server.middlewares.use(devStorageMiddleware());\n },\n },\n ],\n resolve: {\n alias: {\n '@': path.join(projectRoot, 'src'),\n },\n dedupe: ['react', 'react-dom'],\n },\n optimizeDeps: {\n entries: getModuleFederationHostOptimizeDepsEntries(projectRoot),\n include: ['react', 'react-dom', 'react/jsx-dev-runtime'],\n exclude: ['editor/Editor'],\n },\n server: {\n port: MF_STAND_HOST_PORT,\n host: MF_STAND_HOST,\n strictPort: true,\n origin: `http://${MF_STAND_HOST}:${MF_STAND_HOST_PORT}`,\n proxy: apiProxy,\n },\n build: {\n ...STAND_VITE_PRODUCTION_BUILD,\n target: 'esnext',\n outDir: './dist/host',\n },\n preview: {\n port: MF_STAND_HOST_PORT,\n host: MF_STAND_HOST,\n strictPort: true,\n origin: `http://${MF_STAND_HOST}:${MF_STAND_HOST_PORT}`,\n headers: STAND_PREVIEW_HEADERS,\n proxy: apiProxy,\n },\n };\n });\n}\n",
3677
+ "../../project-templates/stand/advanced/module-federation/vite/config/lib/createModuleFederationRemoteConfig.ts": "import path from 'node:path';\nimport react from '@vitejs/plugin-react';\nimport { federation } from '@module-federation/vite';\nimport { v4 as uuid } from 'uuid';\nimport type { PluginOption, UserConfigExport } from 'vite';\nimport { defineConfig } from 'vite';\nimport cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js';\nimport devStorageMiddleware from '../../scripts/devStorageMiddleware.ts';\nimport { createStandApiProxyOptions } from './standApiProxy.ts';\nimport { STAND_VITE_PRODUCTION_BUILD } from './standProductionBuild.ts';\nimport { crossOriginAssetCorsPlugin } from './crossOriginAssetCorsPlugin.ts';\nimport { editorWorkerCorsPlugin } from './editorWorkerCorsPlugin.ts';\nimport {\n MF_STAND_HOST,\n MF_STAND_REMOTE_PORT,\n moduleFederationCdnPublicPath,\n} from './moduleFederationHosts.ts';\nimport { MODULE_FEDERATION_REMOTE_SHARED } from './moduleFederationShared.ts';\nimport { getModuleFederationRemoteOptimizeDepsEntries } from './moduleFederationOptimizeDeps.ts';\nimport { STAND_PREVIEW_HEADERS } from './standPreviewSettings.ts';\n\ninterface CreateModuleFederationRemoteConfigOptions {\n projectRoot: string;\n vitePlugin: (options?: { publicPath?: string }) => PluginOption[];\n closedLoop?: boolean;\n apiBaseUrl: string;\n apiOrigin: string;\n}\n\nfunction remoteIndexHtmlPlugin(): PluginOption {\n return {\n name: 'module-federation-remote-index-html',\n configureServer(server) {\n server.middlewares.use((req, _res, next) => {\n if (req.url === '/' || req.url === '/index.html') {\n req.url = '/remote-index.html';\n }\n next();\n });\n },\n };\n}\n\nexport function createModuleFederationRemoteConfig(options: CreateModuleFederationRemoteConfigOptions): UserConfigExport {\n const {\n projectRoot,\n vitePlugin,\n closedLoop,\n apiBaseUrl,\n apiOrigin,\n } = options;\n const cdnPublicPath = moduleFederationCdnPublicPath();\n\n return defineConfig(() => {\n const apiProxy = closedLoop\n ? undefined\n : createStandApiProxyOptions(apiBaseUrl, apiOrigin);\n\n return {\n root: projectRoot,\n base: '/',\n plugins: [\n react(),\n federation({\n name: 'editor',\n filename: 'remoteEntry.js',\n manifest: true,\n dts: false,\n publicPath: cdnPublicPath,\n shareStrategy: 'loaded-first',\n exposes: {\n './Editor': './src/remote/EditorApp.tsx',\n },\n shared: MODULE_FEDERATION_REMOTE_SHARED,\n }),\n ...vitePlugin({\n publicPath: cdnPublicPath,\n }),\n cssInjectedByJsPlugin({\n injectCode: (content) => ``\n + `if (document) {`\n + `const style = document.createElement('style');`\n + `style.setAttribute('data-mf-app', 'module-federation-editor-remote');`\n + `style.innerHTML = ${content};`\n + `document.body.append(style);`\n + `}`,\n }),\n editorWorkerCorsPlugin(),\n crossOriginAssetCorsPlugin(),\n remoteIndexHtmlPlugin(),\n {\n name: 'dev-storage',\n configureServer(server) {\n server.middlewares.use(devStorageMiddleware());\n },\n },\n ],\n resolve: {\n alias: {\n '@': path.join(projectRoot, 'src'),\n },\n dedupe: ['react', 'react-dom'],\n },\n optimizeDeps: {\n entries: getModuleFederationRemoteOptimizeDepsEntries(projectRoot),\n include: ['react', 'react-dom', 'react/jsx-dev-runtime'],\n },\n server: {\n port: MF_STAND_REMOTE_PORT,\n host: MF_STAND_HOST,\n strictPort: true,\n origin: `http://${MF_STAND_HOST}:${MF_STAND_REMOTE_PORT}`,\n ...(apiProxy ? { proxy: apiProxy } : {}),\n },\n build: {\n ...STAND_VITE_PRODUCTION_BUILD,\n target: 'esnext',\n outDir: './dist/remote',\n rollupOptions: {\n input: {\n remote: path.join(projectRoot, 'remote-index.html'),\n },\n output: {\n entryFileNames: `[name]${uuid()}.js`,\n chunkFileNames: `[name]${uuid()}.js`,\n assetFileNames: `[name]${uuid()}.[ext]`,\n },\n },\n },\n preview: {\n port: MF_STAND_REMOTE_PORT,\n host: MF_STAND_HOST,\n strictPort: true,\n origin: `http://${MF_STAND_HOST}:${MF_STAND_REMOTE_PORT}`,\n headers: STAND_PREVIEW_HEADERS,\n ...(apiProxy ? { proxy: apiProxy } : {}),\n },\n };\n });\n}\n",
3678
+ "../../project-templates/stand/advanced/module-federation/vite/config/lib/crossOriginAssetCorsPlugin.ts": "import type { Plugin } from 'vite';\nimport type { ServerResponse } from 'node:http';\n\nfunction applyCrossOriginAssetHeaders(res: ServerResponse): void {\n res.setHeader('Access-Control-Allow-Origin', '*');\n res.setHeader('Cross-Origin-Resource-Policy', 'cross-origin');\n}\n\n/** CORS on the CDN dev/preview server: lets the host origin load static assets cross-origin. */\nexport function crossOriginAssetCorsPlugin(): Plugin {\n return {\n name: 'cross-origin-asset-cors',\n enforce: 'pre',\n configureServer(server) {\n server.middlewares.use((_req, res, next) => {\n applyCrossOriginAssetHeaders(res);\n next();\n });\n },\n configurePreviewServer(server) {\n server.middlewares.use((_req, res, next) => {\n applyCrossOriginAssetHeaders(res);\n next();\n });\n },\n };\n}\n",
3679
+ "../../project-templates/stand/advanced/module-federation/vite/config/lib/editorWorkerCorsPlugin.ts": "import type { Plugin } from 'vite';\nimport type { IncomingMessage, ServerResponse } from 'node:http';\n\nconst EDITOR_WORKER_PATH = '/monacoeditorwork/';\n\nfunction applyEditorWorkerCorsHeaders(res: ServerResponse): void {\n res.setHeader('Access-Control-Allow-Origin', '*');\n res.setHeader('Cross-Origin-Resource-Policy', 'cross-origin');\n res.setHeader('Access-Control-Allow-Methods', 'GET, HEAD, OPTIONS');\n}\n\nfunction editorWorkerCorsMiddleware(\n req: IncomingMessage,\n res: ServerResponse,\n next: (err?: unknown) => void,\n): void {\n if (!req.url?.includes(EDITOR_WORKER_PATH)) {\n next();\n return;\n }\n\n applyEditorWorkerCorsHeaders(res);\n\n if (req.method === 'OPTIONS') {\n res.statusCode = 204;\n res.end();\n return;\n }\n\n next();\n}\n\n/** CORS for editor worker bundles under cross-origin Module Federation. */\nexport function editorWorkerCorsPlugin(): Plugin {\n return {\n name: 'editor-worker-cors',\n enforce: 'pre',\n configureServer(server) {\n server.middlewares.use(editorWorkerCorsMiddleware);\n },\n configurePreviewServer(server) {\n server.middlewares.use(editorWorkerCorsMiddleware);\n },\n };\n}\n",
3680
+ "../../project-templates/stand/advanced/module-federation/vite/config/lib/moduleFederationHosts.ts": "/** Host and CDN remote both on localhost; different ports make them cross-origin, like MF behind a separate CDN. */\nexport const MF_STAND_HOST = 'localhost';\nexport const MF_STAND_HOST_PORT = 3000;\nexport const MF_STAND_REMOTE_PORT = 3001;\n\nexport function moduleFederationCdnPublicPath(port = MF_STAND_REMOTE_PORT): string {\n return `http://${MF_STAND_HOST}:${port}/`;\n}\n\nexport function moduleFederationRemoteEntryUrl(port = MF_STAND_REMOTE_PORT): string {\n return `${moduleFederationCdnPublicPath(port)}remoteEntry.js`;\n}\n\nexport function moduleFederationHostPageUrl(port = MF_STAND_HOST_PORT): string {\n return `http://${MF_STAND_HOST}:${port}/`;\n}\n\n/** Remotes host: a Vite remoteEntry is ESM, so it needs type module rather than a classic script. */\nexport function moduleFederationHostRemotes(remoteEntryUrl = moduleFederationRemoteEntryUrl()) {\n return {\n editor: {\n type: 'module' as const,\n name: 'editor',\n entry: remoteEntryUrl,\n entryGlobalName: 'editor',\n shareScope: 'default',\n },\n };\n}\n",
3681
+ "../../project-templates/stand/advanced/module-federation/vite/config/lib/moduleFederationOptimizeDeps.ts": "import path from 'node:path';\n\n/** Entrypoints for the remote dev server dep scan, excluding the host index and editor/Editor. */\nexport function getModuleFederationRemoteOptimizeDepsEntries(projectRoot: string): string[] {\n return [\n path.join(projectRoot, 'remote-index.html'),\n path.join(projectRoot, 'src/remote/EditorApp.tsx'),\n path.join(projectRoot, 'src/remote/devShell.tsx'),\n ];\n}\n\n/** Entrypoints for the host dev server dep scan. */\nexport function getModuleFederationHostOptimizeDepsEntries(projectRoot: string): string[] {\n return [\n path.join(projectRoot, 'index.html'),\n path.join(projectRoot, 'src/index.tsx'),\n ];\n}\n",
3682
+ "../../project-templates/stand/advanced/module-federation/vite/config/lib/moduleFederationShared.ts": "/** Shared deps for @module-federation/vite; versions match the stand package.json. */\nexport const MODULE_FEDERATION_REACT_VERSION = '19.2.7';\n\nexport const MODULE_FEDERATION_REMOTE_SHARED = {\n react: {\n singleton: true,\n requiredVersion: MODULE_FEDERATION_REACT_VERSION,\n import: false,\n },\n 'react-dom': {\n singleton: true,\n requiredVersion: MODULE_FEDERATION_REACT_VERSION,\n import: false,\n },\n} as const;\n\n/** The host must load React before the MF runtime; otherwise ReactCurrentDispatcher breaks. */\nexport const MODULE_FEDERATION_HOST_SHARED = {\n react: {\n singleton: true,\n requiredVersion: MODULE_FEDERATION_REACT_VERSION,\n eager: true,\n },\n 'react-dom': {\n singleton: true,\n requiredVersion: MODULE_FEDERATION_REACT_VERSION,\n eager: true,\n },\n} as const;\n",
3683
+ "../../project-templates/stand/advanced/module-federation/vite/index.html.eta": "<%~ include('stand-vite-index-shell', it) %>\n",
3684
+ "../../project-templates/stand/advanced/module-federation/vite/package.json.eta": "<%~ include('stand-package-json', it) %>\n",
3685
+ "../../project-templates/stand/advanced/module-federation/vite/remote-index.html.eta": "<!doctype html>\n<html lang=\"<%= it.standIndexHtmlLang %>\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title><%= it.standIndexHtmlTitle %> — CDN remote</title>\n </head>\n <body>\n <div id=\"root\"></div>\n <script type=\"module\" src=\"/src/remote/devShell.tsx\"><\/script>\n </body>\n</html>\n",
3686
+ "../../project-templates/stand/advanced/module-federation/vite/src/dev/editorConfig.ts.eta": "<%~ include('stand-editor-config', it) %>\n",
3687
+ "../../project-templates/stand/advanced/module-federation/vite/src/dev/email.html.eta": "<%~ include('stand-dev-email', it) %>\n",
3688
+ "../../project-templates/stand/advanced/module-federation/vite/src/dev/getAuthToken.ts.eta": "<%~ include('stand-get-auth-token', it) %>\n",
3689
+ "../../project-templates/stand/advanced/module-federation/vite/src/dev/oauthCredentials.ts": "export const oauthCredentials = {\n clientId: 'YOUR_CLIENT_ID',\n clientSecret: 'YOUR_CLIENT_SECRET',\n};\n\nexport function hasOAuthCredentials() {\n return oauthCredentials.clientId !== 'YOUR_CLIENT_ID'\n && oauthCredentials.clientSecret !== 'YOUR_CLIENT_SECRET';\n}\n",
3690
+ "../../project-templates/stand/advanced/module-federation/vite/src/dev/storageProvider.ts.eta": "<%~ include('stand-storage-provider', it) %>\n",
3691
+ "../../project-templates/stand/advanced/module-federation/vite/src/index.tsx.eta": "import { lazy, Suspense } from 'react';\nimport { createRoot } from 'react-dom/client';\n\nconst EditorRemote = lazy(() => import('editor/Editor'));\n\nfunction HostApp() {\n return (\n <div style={{ minHeight: '100vh', background: '#f5f7fb', padding: '24px' }}>\n <div style={{ margin: '0 auto', maxWidth: '1280px' }}>\n<% if (it.standShowModuleFederationBanner) { %>\n <div style={{ marginBottom: '12px', color: '#7c2d12', fontSize: '14px' }}>\n Module Federation stand — open <code>http://localhost:3000/</code> (remote/CDN on port 3001).\n </div>\n<% } %>\n <Suspense fallback={<div style={{ padding: '16px', fontSize: '14px' }}>Loading editor remote…</div>}>\n <EditorRemote />\n </Suspense>\n </div>\n </div>\n );\n}\n\nconst rootElement = document.getElementById('root');\n\nif (!rootElement) {\n throw new Error(<%~ JSON.stringify(it.commonRootElementNotFound) %>);\n}\n\ncreateRoot(rootElement).render(<HostApp />);\n",
3692
+ "../../project-templates/stand/advanced/module-federation/vite/src/remote/EditorApp.tsx.eta": "import { useEffect, useRef, useState } from 'react';\nimport * as <%= it.standProductApiName %> from '<%~ it.packageName %>';\nimport baseEmailHtml from '../dev/email.html?raw';\nimport { editorConfig } from '../dev/editorConfig';\nimport { getAuthToken } from '../dev/getAuthToken';\nimport { createLocalFolderStorageProvider } from '../dev/storageProvider';\n\n<%~ include('editor-init-smoke', it) %>\ntype EditorInstance = Awaited<ReturnType<typeof <%= it.standProductApiName %>.init>>;\n\nexport default function EditorRemoteApp() {\n const instanceRef = useRef<EditorInstance | null>(null);\n const [initError, setInitError] = useState<string | null>(null);\n\n useEffect(() => {\n async function run() {\n if (instanceRef.current) {\n return;\n }\n\n const mountElement = document.getElementById('editor-root');\n const smokeMeta = {\n hostKind: 'stand-host',\n variant: 'module-federation',\n mountLabel: '#editor-root',\n } as const;\n\n try {\n const instance = await <%= it.standProductApiName %>.init({\n getAuthToken,\n storageProvider: createLocalFolderStorageProvider(),\n element: '#editor-root',\n content: {\n email: {\n title: <%~ JSON.stringify(it.devHostDemoTitle) %>,\n code: baseEmailHtml,\n },\n },\n config: {\n ...editorConfig,\n codeMode: 'true',\n codeModeDirection: 'bottom',\n },\n });\n instanceRef.current = instance;\n reportEditorReady(smokeMeta, mountElement);\n } catch (error) {\n const message = reportEditorInitError(smokeMeta, error, mountElement);\n setInitError(message);\n }\n }\n\n run();\n }, []);\n\n return (\n <div style={{ minHeight: '80vh' }}>\n {initError ? (\n <div style={{ marginBottom: '12px', color: '#b42318', fontSize: '14px' }}>\n Editor failed to initialize: {initError}\n </div>\n ) : null}\n <div id=\"editor-root\" style={{ minHeight: '80vh' }} />\n </div>\n );\n}\n",
3693
+ "../../project-templates/stand/advanced/module-federation/vite/src/remote/devShell.tsx": "import { createRoot } from 'react-dom/client';\n\n/** Dev-only remote shell; the MF host runs on localhost:3000. */\nfunction RemoteDevShell() {\n return (\n <div style={{ padding: '16px', fontFamily: 'system-ui, sans-serif', fontSize: '14px', color: '#44506b' }}>\n Editor MF remote (localhost:3001). Open host at <code>http://localhost:3000/</code>\n </div>\n );\n}\n\nconst rootElement = document.getElementById('root');\n\nif (rootElement) {\n createRoot(rootElement).render(<RemoteDevShell />);\n}\n",
3694
+ "../../project-templates/stand/advanced/module-federation/vite/src/types/mf.d.ts": "declare module 'editor/Editor' {\n import type { ComponentType } from 'react';\n\n const EditorRemoteApp: ComponentType;\n export default EditorRemoteApp;\n}\n",
3636
3695
  "../../project-templates/stand/advanced/shadow-dom/vite/README.md.eta": "<%~ include('stand-readme', it) %>\n",
3637
3696
  "../../project-templates/stand/advanced/shadow-dom/vite/config/dev-host.ts.eta": "<%~ include('stand-dev-host-vite', it) %>\n",
3638
3697
  "../../project-templates/stand/advanced/shadow-dom/vite/index.html.eta": "<%~ include('stand-vite-index-shell', it) %>\n",
@@ -3695,40 +3754,48 @@ var rawTemplateModules = /* #__PURE__ */ Object.assign({
3695
3754
  "../../project-templates/stand/advanced/umd/webpack/src/dev/storageProvider.ts.eta": "<%~ include('stand-storage-provider', it) %>\n",
3696
3755
  "../../project-templates/stand/advanced/umd/webpack/src/index.tsx.eta": "<%~ include('stand-host-umd', it) %>\n",
3697
3756
  "../../project-templates/stand/angular/esbuild/README.md.eta": "<%~ include('stand-readme', it) %>\n",
3698
- "../../project-templates/stand/angular/esbuild/angular.json.eta": "{\n \"$schema\": \"./node_modules/@angular/cli/lib/config/schema.json\",\n \"version\": 1,\n \"newProjectRoot\": \"projects\",\n \"projects\": {\n \"angular-host\": {\n \"projectType\": \"application\",\n \"root\": \"\",\n \"sourceRoot\": \"src\",\n \"prefix\": \"app\",\n \"architect\": {\n \"build\": {\n \"builder\": \"@angular-builders/custom-esbuild:application\",\n \"options\": {\n \"plugins\": [\"./esbuild/plugins.cjs\"],\n \"outputPath\": \"dist/angular-host\",\n \"index\": \"src/index.html\",\n \"browser\": \"src/main.ts\",\n \"polyfills\": [\"zone.js\"],\n \"tsConfig\": \"tsconfig.app.json\",\n \"assets\": [\n {\n \"glob\": \"serve.json\",\n \"input\": \".\",\n \"output\": \".\"\n },\n {\n \"glob\": \"**/*\",\n \"input\": \"node_modules/<%~ it.packageName %>\",\n \"output\": \"<%~ it.standAngularProductAssetsOutput %>\",\n \"ignore\": [\n \"*.md\",\n \"*.ts\",\n \"*.d.ts\",\n \"*.json\",\n \"*.ico\",\n \"*.pot\",\n \"*.npmignore\",\n \"*.gitignore\",\n \"robots.txt\",\n \"webpack/**\",\n \"vite/**\",\n \"react/**\"\n ]\n }\n ],\n \"styles\": [\"src/styles.css\"],\n \"scripts\": []\n },\n \"configurations\": {\n \"production\": {\n \"budgets\": [\n {\n \"type\": \"initial\",\n \"maximumWarning\": \"8mb\",\n \"maximumError\": \"16mb\"\n }\n ],\n \"outputHashing\": \"all\",\n <%~ include('stand-angular-production-optimization', it) %>\n \"sourceMap\": false,\n \"namedChunks\": false,\n \"extractLicenses\": true\n },\n \"development\": {\n \"optimization\": false,\n \"extractLicenses\": false,\n \"sourceMap\": true,\n \"namedChunks\": true\n }\n },\n \"defaultConfiguration\": \"development\"\n },\n \"serve\": {\n \"builder\": \"@angular-builders/custom-esbuild:dev-server\",\n \"options\": {\n \"buildTarget\": \"angular-host:build\",\n \"middlewares\": [\"./scripts/standDevMiddleware.ts\"],\n \"proxyConfig\": \"./proxy.conf.json\"\n },\n \"configurations\": {\n \"production\": {\n \"buildTarget\": \"angular-host:build:production\"\n },\n \"development\": {\n \"buildTarget\": \"angular-host:build:development\"\n }\n },\n \"defaultConfiguration\": \"development\"\n }\n }\n }\n }\n}\n",
3699
- "../../project-templates/stand/angular/esbuild/esbuild/plugins.cjs": "const fs = require('node:fs');\nconst path = require('node:path');\n\n/** Vite-style `?raw` imports for stand dev email HTML (webpack used asset/source rule). */\nconst rawImportPlugin = {\n name: 'stand-raw-import',\n setup(build) {\n build.onResolve({ filter: /\\?raw$/ }, (args) => {\n const sourcePath = args.path.replace(/\\?raw$/, '');\n return {\n path: path.resolve(args.resolveDir, sourcePath),\n namespace: 'stand-raw-import',\n };\n });\n\n build.onLoad({ filter: /.*/, namespace: 'stand-raw-import' }, async (args) => {\n const contents = await fs.promises.readFile(args.path, 'utf8');\n return {\n contents: `export default ${JSON.stringify(contents)};`,\n loader: 'js',\n };\n });\n },\n};\n\nmodule.exports = [rawImportPlugin];\n",
3757
+ "../../project-templates/stand/angular/esbuild/angular.json.eta": "{\n \"$schema\": \"./node_modules/@angular/cli/lib/config/schema.json\",\n \"version\": 1,\n \"newProjectRoot\": \"projects\",\n \"projects\": {\n \"angular-host\": {\n \"projectType\": \"application\",\n \"root\": \"\",\n \"sourceRoot\": \"src\",\n \"prefix\": \"app\",\n \"architect\": {\n \"build\": {\n \"builder\": \"@angular-builders/custom-esbuild:application\",\n \"options\": {\n \"plugins\": [\"./esbuild/plugins.cjs\"],\n \"outputPath\": \"dist/angular-host\",\n \"index\": \"src/index.html\",\n \"browser\": \"src/main.ts\",\n \"polyfills\": [\"src/polyfills.ts\"],\n \"tsConfig\": \"tsconfig.app.json\",\n \"assets\": [\n {\n \"glob\": \"serve.json\",\n \"input\": \".\",\n \"output\": \".\"\n },\n {\n \"glob\": \"**/*\",\n \"input\": \"node_modules/<%~ it.packageName %>\",\n \"output\": \"<%~ it.standAngularProductAssetsOutput %>\",\n \"ignore\": [\n \"*.md\",\n \"*.ts\",\n \"*.d.ts\",\n \"*.json\",\n \"*.ico\",\n \"*.pot\",\n \"*.npmignore\",\n \"*.gitignore\",\n \"robots.txt\",\n \"webpack/**\",\n \"vite/**\",\n \"react/**\"\n ]\n }\n ],\n \"styles\": [\"src/styles.css\"],\n \"scripts\": []\n },\n \"configurations\": {\n \"production\": {\n \"budgets\": [\n {\n \"type\": \"initial\",\n \"maximumWarning\": \"8mb\",\n \"maximumError\": \"16mb\"\n }\n ],\n \"outputHashing\": \"bundles\",\n <%~ include('stand-angular-production-optimization', it) %>\n \"sourceMap\": false,\n \"namedChunks\": false,\n \"extractLicenses\": true\n },\n \"development\": {\n \"optimization\": false,\n \"extractLicenses\": false,\n \"sourceMap\": true,\n \"namedChunks\": true\n }\n },\n \"defaultConfiguration\": \"development\"\n },\n \"serve\": {\n \"builder\": \"@angular-builders/custom-esbuild:dev-server\",\n \"options\": {\n \"buildTarget\": \"angular-host:build\",\n \"middlewares\": [\"./scripts/standDevMiddleware.ts\"],\n \"proxyConfig\": \"./proxy.conf.json\"\n },\n \"configurations\": {\n \"production\": {\n \"buildTarget\": \"angular-host:build:production\"\n },\n \"development\": {\n \"buildTarget\": \"angular-host:build:development\"\n }\n },\n \"defaultConfiguration\": \"development\"\n }\n }\n }\n }\n}\n",
3758
+ "../../project-templates/stand/angular/esbuild/esbuild/plugins.cjs.eta": "const fs = require('node:fs');\nconst path = require('node:path');\n\n/** Vite-style `?raw` imports for stand dev email HTML (webpack used asset/source rule). */\nconst rawImportPlugin = {\n name: 'stand-raw-import',\n setup(build) {\n build.onResolve({ filter: /\\?raw$/ }, (args) => {\n const sourcePath = args.path.replace(/\\?raw$/, '');\n return {\n path: path.resolve(args.resolveDir, sourcePath),\n namespace: 'stand-raw-import',\n };\n });\n\n build.onLoad({ filter: /.*/, namespace: 'stand-raw-import' }, async (args) => {\n const contents = await fs.promises.readFile(args.path, 'utf8');\n return {\n contents: `export default ${JSON.stringify(contents)};`,\n loader: 'js',\n };\n });\n },\n};\n\nmodule.exports = [rawImportPlugin];\n",
3700
3759
  "../../project-templates/stand/angular/esbuild/esbuild/publicPath-shim.ts.eta": "type ProductNamespace = {\n publicPath?: string;\n};\n\nconst namespace = <%~ JSON.stringify(it.standWindowNamespace) %>;\nconst publicPath = <%~ JSON.stringify(it.standAngularProductPublicPath + '/') %>;\n\nconst root = window as unknown as Record<string, ProductNamespace | undefined>;\n\nroot[namespace] = {\n ...(root[namespace] ?? {}),\n publicPath,\n};\n\nexport {};\n",
3701
3760
  "../../project-templates/stand/angular/esbuild/package.json.eta": "<%~ include('stand-package-json', it) %>\n",
3702
3761
  "../../project-templates/stand/angular/esbuild/proxy.conf.json.eta": "{\n \"/api\": {\n \"target\": <%~ JSON.stringify(it.standOpenApiBaseUrl) %>,\n \"secure\": false,\n \"changeOrigin\": true,\n \"headers\": {\n \"origin\": <%~ JSON.stringify(it.standOpenApiOrigin) %>\n }\n }\n}\n",
3762
+ "../../project-templates/stand/angular/esbuild/scripts/chunkRepro.cjs.eta": "#!/usr/bin/env node\n/**\n * Cross-origin chunk repro: HTML on :4200, JS chunks and <base href> on :4201.\n * Lazy chunk import.meta.url points at the CDN host; product assets stay on the page\n * origin (panel/<app>/).\n * Compile graph: thin facade only (~0.4 MB); static/esm is copied into panel/, not bundled.\n *\n * Usage: npm run build:rebundle && npm run serve:chunk-repro\n */\nconst http = require('node:http');\nconst https = require('node:https');\nconst fs = require('node:fs');\nconst path = require('node:path');\nconst { URL } = require('node:url');\n\nconst API_PROXY_ENABLED = <%= it.standClosedLoop ? 'false' : 'true' %>;\nconst API_TARGET = <%~ JSON.stringify(it.standOpenApiBaseUrl) %>;\nconst API_ORIGIN = <%~ JSON.stringify(it.standOpenApiOrigin) %>;\nconst SITE_PORT = 4200;\nconst CDN_PORT = 4201;\n// <base href> points at the CDN, so every relative path (publicPath from the shim,\n// iframe src, worker url) resolves against that origin instead of the page origin.\n// STAND_CDN_BASE_HREF=0 keeps the page base href for comparison.\nconst CDN_BASE_HREF = process.env.STAND_CDN_BASE_HREF !== '0';\nconst DIST_RELATIVE = <%~ JSON.stringify(it.standAngularChunkReproDistRelative) %>;\n\nconst MIME = {\n '.html': 'text/html; charset=utf-8',\n '.js': 'text/javascript; charset=utf-8',\n '.css': 'text/css; charset=utf-8',\n '.json': 'application/json; charset=utf-8',\n '.woff': 'font/woff',\n '.woff2': 'font/woff2',\n '.png': 'image/png',\n '.svg': 'image/svg+xml',\n '.ico': 'image/x-icon',\n};\n\nconst STATIC_HEADERS = {\n 'Cross-Origin-Resource-Policy': 'cross-origin',\n 'Access-Control-Allow-Origin': '*',\n};\n\n// The page origin and the API port differ under this repro, so proxied answers need CORS.\nconst CORS_HEADERS = {\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, PATCH, DELETE, OPTIONS',\n 'Access-Control-Allow-Headers': '*',\n 'Access-Control-Max-Age': '600',\n};\n\nfunction contentType(filePath) {\n return MIME[path.extname(filePath).toLowerCase()] || 'application/octet-stream';\n}\n\nfunction resolveFile(distDir, requestPath) {\n const safe = path.normalize(requestPath).replace(/^(\\.\\.[/\\\\])+/, '');\n const candidate = path.join(distDir, safe);\n if (!candidate.startsWith(distDir)) return null;\n if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) return candidate;\n return null;\n}\n\nfunction patchIndexHtml(html, cdnOrigin) {\n const patched = html.replace(\n /(<script\\b[^>]*\\ssrc=\")(?!https?:|\\/\\/)([^\"]+)\"/gi,\n (_, prefix, src) => `${prefix}${cdnOrigin}/${src.replace(/^\\//, '')}\"`,\n );\n\n if (!CDN_BASE_HREF) {\n return patched;\n }\n\n return patched.replace(/(<base\\b[^>]*\\shref=\")[^\"]*\"/i, (_, prefix) => `${prefix}${cdnOrigin}/\"`);\n}\n\nfunction readRequestBody(req) {\n return new Promise((resolve, reject) => {\n const chunks = [];\n req.on('data', (chunk) => chunks.push(chunk));\n req.on('end', () => resolve(Buffer.concat(chunks)));\n req.on('error', reject);\n });\n}\n\nfunction buildProxyRequestHeaders(req, targetUrl, bodyLength) {\n const headers = { ...req.headers, host: targetUrl.host };\n if (headers.origin) {\n headers.origin = API_ORIGIN;\n }\n delete headers.connection;\n delete headers['transfer-encoding'];\n if (bodyLength > 0) {\n headers['content-length'] = String(bodyLength);\n } else {\n delete headers['content-length'];\n }\n return headers;\n}\n\nfunction drainResponse(proxyRes) {\n return new Promise((resolve) => {\n proxyRes.on('end', resolve);\n proxyRes.resume();\n });\n}\n\nfunction proxyApiRequest(req, res, targetUrl, body, redirectCount, method) {\n const MAX_REDIRECTS = 5;\n if (redirectCount > MAX_REDIRECTS) {\n res.writeHead(502, { 'Content-Type': 'text/plain; charset=utf-8' });\n res.end('Too many redirects');\n return;\n }\n\n const requestMethod = method || req.method || 'GET';\n const transport = targetUrl.protocol === 'https:' ? https : http;\n const headers = buildProxyRequestHeaders(req, targetUrl, body.length);\n\n const proxyReq = transport.request(\n targetUrl,\n { method: requestMethod, headers },\n (proxyRes) => {\n const status = proxyRes.statusCode || 502;\n const location = proxyRes.headers.location;\n if (status >= 300 && status < 400 && location) {\n drainResponse(proxyRes).then(() => {\n const nextUrl = new URL(location, targetUrl);\n const useGet = status === 303;\n proxyApiRequest(\n req,\n res,\n nextUrl,\n useGet ? Buffer.alloc(0) : body,\n redirectCount + 1,\n useGet ? 'GET' : requestMethod,\n );\n });\n return;\n }\n\n const outHeaders = { ...proxyRes.headers, ...CORS_HEADERS };\n delete outHeaders.location;\n res.writeHead(status, outHeaders);\n proxyRes.pipe(res);\n },\n );\n\n proxyReq.on('error', (error) => {\n console.error('[chunkRepro] API proxy error:', error.message);\n if (!res.headersSent) {\n res.writeHead(502, { 'Content-Type': 'text/plain; charset=utf-8' });\n res.end('Bad Gateway');\n }\n });\n\n if (body.length > 0) {\n proxyReq.write(body);\n }\n proxyReq.end();\n}\n\nasync function proxyApi(req, res) {\n const body = await readRequestBody(req);\n const targetUrl = new URL(req.url || '/', API_TARGET);\n proxyApiRequest(req, res, targetUrl, body, 0);\n}\n\nfunction createStaticServer(distDir, port, options = {}) {\n const { patchIndex = false, cdnOrigin = '' } = options;\n\n return http.createServer((req, res) => {\n const url = new URL(req.url || '/', `http://127.0.0.1:${port}`);\n const pathname = decodeURIComponent(url.pathname);\n\n // Both servers proxy /api: with <base href> on the CDN even a root-relative\n // fetch('/api') takes its origin from the base, so it lands on the CDN port.\n if (API_PROXY_ENABLED && pathname.startsWith('/api')) {\n if ((req.method || '').toUpperCase() === 'OPTIONS') {\n res.writeHead(204, CORS_HEADERS);\n res.end();\n return;\n }\n proxyApi(req, res);\n return;\n }\n\n let filePath = resolveFile(distDir, pathname === '/' ? '/index.html' : pathname);\n\n if (!filePath) {\n res.writeHead(404, STATIC_HEADERS);\n res.end('Not found');\n return;\n }\n\n if (patchIndex && filePath.endsWith('index.html')) {\n const raw = fs.readFileSync(filePath, 'utf8');\n res.writeHead(200, { ...STATIC_HEADERS, 'Content-Type': 'text/html; charset=utf-8' });\n res.end(patchIndexHtml(raw, cdnOrigin));\n return;\n }\n\n res.writeHead(200, { ...STATIC_HEADERS, 'Content-Type': contentType(filePath) });\n fs.createReadStream(filePath).pipe(res);\n }).listen(port, () => {\n console.log(`[chunkRepro] ${patchIndex ? 'site' : 'cdn'} → http://localhost:${port}/`);\n if (API_PROXY_ENABLED) {\n console.log(`[chunkRepro] /api → ${API_TARGET}`);\n }\n });\n}\n\nconst distDir = path.resolve(process.cwd(), DIST_RELATIVE);\nif (!fs.existsSync(path.join(distDir, 'index.html'))) {\n console.error(`[chunkRepro] Missing ${DIST_RELATIVE}/index.html — run \\`npm run build:rebundle\\` first.`);\n process.exit(1);\n}\n\nconst cdnOrigin = `http://localhost:${CDN_PORT}`;\ncreateStaticServer(distDir, CDN_PORT);\ncreateStaticServer(distDir, SITE_PORT, { patchIndex: true, cdnOrigin });\n\nconsole.log(\n CDN_BASE_HREF\n ? `[chunkRepro] <base href> → ${cdnOrigin}/ (set STAND_CDN_BASE_HREF=0 to disable)`\n : '[chunkRepro] <base href> left on the page origin',\n);\nconsole.log('[chunkRepro] Open http://localhost:4200/ — check Network + console [publicPath-diag]');\n",
3703
3763
  "../../project-templates/stand/angular/esbuild/scripts/devStorageMiddleware.ts.eta": "<%~ include('stand-dev-storage-middleware', it) %>\n",
3704
- "../../project-templates/stand/angular/esbuild/scripts/standDevMiddleware.ts.eta": "import type { IncomingMessage, ServerResponse } from 'node:http';\n\nimport devStorageMiddleware from './devStorageMiddleware.ts';\n\nconst HOST_EDITOR_ASSET_HEADERS = Object.freeze({\n 'Cross-Origin-Resource-Policy': 'cross-origin',\n 'Access-Control-Allow-Origin': '*',\n});\n\ntype ConnectMiddleware = (\n req: IncomingMessage,\n res: ServerResponse,\n next: (error?: unknown) => void,\n) => void;\n\nfunction createHostEditorHeaderMiddleware(): ConnectMiddleware {\n return (_req, res, next) => {\n for (const [key, value] of Object.entries(HOST_EDITOR_ASSET_HEADERS)) {\n res.setHeader(key, value);\n }\n next();\n };\n}\n\nconst middlewares: ConnectMiddleware[] = [\n createHostEditorHeaderMiddleware(),\n devStorageMiddleware(),\n];\n\nexport default middlewares;\n",
3705
- "../../project-templates/stand/angular/esbuild/src/app/app.component.css": ".page {\n font-family: system-ui, sans-serif;\n margin: 0 auto;\n max-width: 1200px;\n padding: 16px;\n}\n\n.error {\n color: #b42318;\n margin: 0 0 12px;\n}\n\n.editor-mount {\n min-height: 640px;\n}\n",
3706
- "../../project-templates/stand/angular/esbuild/src/app/app.component.html.eta": "<main class=\"page\">\r\r\n @if (initError()) {\r\r\n <p class=\"error\">Editor failed: {{ initError() }}</p>\r\r\n }\r\r\n <div id=\"editor-root\" class=\"editor-mount\"></div>\r\r\n</main>\r\r\n",
3707
- "../../project-templates/stand/angular/esbuild/src/app/app.component.ts.eta": "import { Component, OnInit, signal } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { initOAuthEditor } from './editor-host';\n\n@Component({\n selector: 'app-root',\n standalone: true,\n imports: [CommonModule],\n templateUrl: './app.component.html',\n styleUrl: './app.component.css',\n})\nexport class AppComponent implements OnInit {\n readonly initError = signal<string | null>(null);\n\n async ngOnInit(): Promise<void> {\n try {\n await initOAuthEditor();\n } catch (error) {\n this.initError.set(error instanceof Error ? error.message : String(error));\n }\n }\n}\n",
3764
+ "../../project-templates/stand/angular/esbuild/scripts/formidable.d.ts": "declare module 'formidable';\n",
3765
+ "../../project-templates/stand/angular/esbuild/scripts/publicPathDiagnostics.ts.eta": "type ProductNamespace = {\n publicPath?: string;\n};\n\nexport type PublicPathDiagSnapshot = {\n label: string;\n pageOrigin: string;\n pageHref: string;\n baseURI: string;\n windowNamespacePublicPath: string | undefined;\n expectedShimPrefix: string;\n bareNamespaceReadable: boolean;\n bareNamespacePublicPath: string | undefined;\n resolvedFromBaseURI: string;\n resolvedFromPageOrigin: string;\n basesDiverge: boolean;\n};\n\n/**\n * resolveAgainst expands publicPath against the given base; empty string when the base is invalid.\n * A relative publicPath resolves to different addresses against <base href> and the page origin;\n * that divergence is what breaks asset loading when base href points at another origin.\n */\nfunction resolveAgainst(publicPath: string | undefined, base: string): string {\n if (!publicPath || !base) {\n return '';\n }\n try {\n return new URL(publicPath, base).href;\n } catch {\n return '';\n }\n}\n\nconst namespace = <%~ JSON.stringify(it.standWindowNamespace) %>;\nconst expectedShimPrefix = <%~ JSON.stringify(it.standAngularProductPublicPath + '/') %>;\n\nfunction readBareNamespacePublicPath(): { readable: boolean; publicPath: string | undefined } {\n try {\n // eslint-disable-next-line no-new-func\n const read = new Function(\n `try { return typeof <%= it.standWindowNamespace %> !== 'undefined' ? <%= it.standWindowNamespace %>.publicPath : undefined; } catch (e) { return undefined; }`,\n ) as () => string | undefined;\n return { readable: true, publicPath: read() };\n } catch {\n return { readable: false, publicPath: undefined };\n }\n}\n\nexport function snapshotPublicPathDiagnostics(label: string): PublicPathDiagSnapshot {\n const root = window as unknown as Record<string, ProductNamespace | undefined>;\n const bare = readBareNamespacePublicPath();\n const pageOrigin = window.location.origin;\n const baseURI = typeof document !== 'undefined' ? document.baseURI : '';\n const publicPath = root[namespace]?.publicPath;\n const resolvedFromBaseURI = resolveAgainst(publicPath, baseURI);\n const resolvedFromPageOrigin = resolveAgainst(publicPath, pageOrigin);\n\n const snapshot: PublicPathDiagSnapshot = {\n label,\n pageOrigin,\n pageHref: window.location.href,\n baseURI,\n windowNamespacePublicPath: publicPath,\n expectedShimPrefix,\n bareNamespaceReadable: bare.readable,\n bareNamespacePublicPath: bare.publicPath,\n resolvedFromBaseURI,\n resolvedFromPageOrigin,\n basesDiverge: Boolean(resolvedFromBaseURI) && resolvedFromBaseURI !== resolvedFromPageOrigin,\n };\n\n const bag = window as unknown as { __standPublicPathDiagnostics?: PublicPathDiagSnapshot[] };\n bag.__standPublicPathDiagnostics = [...(bag.__standPublicPathDiagnostics ?? []), snapshot];\n console.info('[publicPath-diag]', label, snapshot);\n return snapshot;\n}\n",
3766
+ "../../project-templates/stand/angular/esbuild/scripts/standDevMiddleware.ts.eta": "import type { IncomingMessage, ServerResponse } from 'node:http';\n\nimport devStorageMiddleware from './devStorageMiddleware';\n\nconst HOST_EDITOR_ASSET_HEADERS = Object.freeze({\n 'Cross-Origin-Resource-Policy': 'cross-origin',\n 'Access-Control-Allow-Origin': '*',\n});\n\ntype ConnectMiddleware = (\n req: IncomingMessage,\n res: ServerResponse,\n next: (error?: unknown) => void,\n) => void;\n\nfunction createHostEditorHeaderMiddleware(): ConnectMiddleware {\n return (_req, res, next) => {\n for (const [key, value] of Object.entries(HOST_EDITOR_ASSET_HEADERS)) {\n res.setHeader(key, value);\n }\n next();\n };\n}\n\nconst middlewares: ConnectMiddleware[] = [\n createHostEditorHeaderMiddleware(),\n devStorageMiddleware(),\n];\n\nexport default middlewares;\n",
3767
+ "../../project-templates/stand/angular/esbuild/src/app/app.component.css": ".page {\n font-family: system-ui, sans-serif;\n margin: 0 auto;\n max-width: 1200px;\n padding: 16px;\n}\n\n.error {\n color: #b42318;\n margin: 0 0 12px;\n}\n\n.diag {\n background: #f4f4f5;\n border: 1px solid #d4d4d8;\n font-size: 12px;\n margin: 0 0 12px;\n max-height: 200px;\n overflow: auto;\n padding: 8px;\n}\n\n.editor-mount {\n min-height: 640px;\n}\n",
3768
+ "../../project-templates/stand/angular/esbuild/src/app/app.component.html.eta": "<main class=\"page\">\n @if (initError()) {\n <p class=\"error\">Editor failed: {{ initError() }}</p>\n }\n @if (publicPathDiag()) {\n <pre class=\"diag\">{{ publicPathDiag() }}</pre>\n }\n <div id=\"editor-root\" class=\"editor-mount\"></div>\n</main>\n",
3769
+ "../../project-templates/stand/angular/esbuild/src/app/app.component.ts.eta": "import { Component, AfterViewInit, signal } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport type { PublicPathDiagSnapshot } from '../../scripts/publicPathDiagnostics';\n\ntype DiagBag = { __standPublicPathDiagnostics?: PublicPathDiagSnapshot[] };\n\n@Component({\n selector: 'app-root',\n standalone: true,\n imports: [CommonModule],\n templateUrl: './app.component.html',\n styleUrl: './app.component.css',\n})\nexport class AppComponent implements AfterViewInit {\n readonly initError = signal<string | null>(null);\n readonly publicPathDiag = signal<string | null>(null);\n\n ngAfterViewInit(): void {\n import('./editor-host')\n .then(({ initOAuthEditor }) => initOAuthEditor())\n .then(() => {\n const bag = window as unknown as DiagBag;\n const last = bag.__standPublicPathDiagnostics?.at(-1);\n if (last) {\n this.publicPathDiag.set(JSON.stringify(last, null, 2));\n }\n })\n .catch((error) => {\n this.initError.set(error instanceof Error ? error.message : String(error));\n });\n }\n}\n",
3708
3770
  "../../project-templates/stand/angular/esbuild/src/app/app.config.ts.eta": "import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';\n\nexport const appConfig: ApplicationConfig = {\n providers: [provideZoneChangeDetection({ eventCoalescing: true })],\n};\n",
3709
- "../../project-templates/stand/angular/esbuild/src/app/editor-host.ts.eta": "import baseEmailHtml from '../dev/email.html?raw';\nimport { editorConfig } from '../dev/editorConfig';\nimport { getAuthToken } from '../dev/getAuthToken';\nimport { createLocalFolderStorageProvider } from '../dev/storageProvider';\n\ntype EmailmakerModule = typeof import('<%~ it.packageName %>');\ntype EditorInstance = Awaited<ReturnType<EmailmakerModule['init']>>;\n\nlet editorInstance: EditorInstance | null = null;\n\nasync function loadEmailmakerModule(): Promise<EmailmakerModule> {\n return import('<%~ it.packageName %>');\n}\n\nfunction formatInitError(error: unknown): string {\n if (error instanceof Error && error.message) {\n return error.message;\n }\n if (typeof error === 'string' && error.trim()) {\n return error.trim();\n }\n return 'Editor initialization failed.';\n}\n\nexport async function initOAuthEditor(): Promise<EditorInstance> {\n if (editorInstance) {\n return editorInstance;\n }\n\n const <%= it.standProductApiName %> = await loadEmailmakerModule();\n\n try {\n const instance = await <%= it.standProductApiName %>.init({\n getAuthToken,\n storageProvider: createLocalFolderStorageProvider(),\n element: '#editor-root',\n content: {\n email: {\n title: <%~ JSON.stringify(it.devHostDemoTitle) %>,\n code: baseEmailHtml,\n },\n },\n config: editorConfig,\n });\n\n editorInstance = instance;\n return instance;\n } catch (error) {\n const message = formatInitError(error);\n console.error('[editor-host] Editor initialization failed', error);\n throw new Error(message);\n }\n}\n",
3771
+ "../../project-templates/stand/angular/esbuild/src/app/editor-host.ts.eta": "import baseEmailHtml from '../dev/email.html?raw';\nimport { editorConfig } from '../dev/editorConfig';\nimport { getAuthToken } from '../dev/getAuthToken';\nimport { createLocalFolderStorageProvider } from '../dev/storageProvider';\nimport { snapshotPublicPathDiagnostics } from '../../scripts/publicPathDiagnostics';\n\ntype EmailmakerModule = typeof import('<%~ it.packageName %>');\ntype EditorInstance = Awaited<ReturnType<EmailmakerModule['init']>>;\n\nlet editorInstance: EditorInstance | null = null;\n\nasync function loadEmailmakerModule(): Promise<EmailmakerModule> {\n return import('<%~ it.packageName %>');\n}\n\nfunction formatInitError(error: unknown): string {\n if (error instanceof Error && error.message) {\n return error.message;\n }\n if (typeof error === 'string' && error.trim()) {\n return error.trim();\n }\n return 'Editor initialization failed.';\n}\n\nexport async function initOAuthEditor(): Promise<EditorInstance> {\n if (editorInstance) {\n return editorInstance;\n }\n\n snapshotPublicPathDiagnostics('before-emailmaker-import');\n const <%= it.standProductApiName %> = await loadEmailmakerModule();\n snapshotPublicPathDiagnostics('after-emailmaker-import');\n\n try {\n const instance = await <%= it.standProductApiName %>.init({\n getAuthToken,\n storageProvider: createLocalFolderStorageProvider(),\n element: '#editor-root',\n content: {\n email: {\n title: <%~ JSON.stringify(it.devHostDemoTitle) %>,\n code: baseEmailHtml,\n },\n },\n config: editorConfig,\n });\n\n editorInstance = instance;\n return instance;\n } catch (error) {\n const message = formatInitError(error);\n console.error('[editor-host] Editor initialization failed', error);\n throw new Error(message);\n }\n}\n",
3710
3772
  "../../project-templates/stand/angular/esbuild/src/dev/editorConfig.ts.eta": "<%~ include('stand-editor-config', it) %>\n",
3711
3773
  "../../project-templates/stand/angular/esbuild/src/dev/email.html.eta": "<%~ include('stand-dev-email', it) %>\n",
3712
3774
  "../../project-templates/stand/angular/esbuild/src/dev/getAuthToken.ts.eta": "<%~ include('stand-get-auth-token', it) %>\n",
3713
3775
  "../../project-templates/stand/angular/esbuild/src/dev/oauthCredentials.ts": "export const oauthCredentials = {\n clientId: 'YOUR_CLIENT_ID',\n clientSecret: 'YOUR_CLIENT_SECRET',\n};\n\nexport function hasOAuthCredentials() {\n return oauthCredentials.clientId !== 'YOUR_CLIENT_ID'\n && oauthCredentials.clientSecret !== 'YOUR_CLIENT_SECRET';\n}\n",
3714
3776
  "../../project-templates/stand/angular/esbuild/src/dev/storageProvider.ts.eta": "<%~ include('stand-storage-provider', it) %>\n",
3715
3777
  "../../project-templates/stand/angular/esbuild/src/index.html.eta": "<!doctype html>\n<html lang=\"<%~ it.standIndexHtmlLang %>\">\n <head>\n <meta charset=\"utf-8\" />\n <title><%~ it.standIndexHtmlTitle %></title>\n <base href=\"/\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n </head>\n <body>\n <app-root></app-root>\n </body>\n</html>\n",
3716
- "../../project-templates/stand/angular/esbuild/src/main.ts.eta": "import '../esbuild/publicPath-shim';\nimport { bootstrapApplication } from '@angular/platform-browser';\nimport { AppComponent } from './app/app.component';\nimport { appConfig } from './app/app.config';\n\nbootstrapApplication(AppComponent, appConfig).catch((error) => {\n console.error('[angular-stand] bootstrap failed', error);\n});\n",
3778
+ "../../project-templates/stand/angular/esbuild/src/main.ts.eta": "import { bootstrapApplication } from '@angular/platform-browser';\nimport { AppComponent } from './app/app.component';\nimport { appConfig } from './app/app.config';\n\nbootstrapApplication(AppComponent, appConfig).catch((error) => {\n console.error('[angular-stand] bootstrap failed', error);\n});\n",
3779
+ "../../project-templates/stand/angular/esbuild/src/polyfills.ts.eta": "import '../esbuild/publicPath-shim';\nimport 'zone.js';\n",
3717
3780
  "../../project-templates/stand/angular/esbuild/src/styles.css": "body {\n margin: 0;\n background: #fff;\n color: #101828;\n}\n\ncode {\n font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n font-size: 0.92em;\n}\n",
3718
3781
  "../../project-templates/stand/angular/esbuild/src/types.d.ts": "declare module '*?raw' {\n const content: string;\n export default content;\n}\n",
3719
- "../../project-templates/stand/angular/esbuild/tsconfig.app.json.eta": "{\n \"extends\": \"./tsconfig.json\",\n \"compilerOptions\": {\n \"outDir\": \"./out-tsc/app\",\n \"types\": []\n },\n \"files\": [\"src/main.ts\"],\n \"include\": [\"src/**/*.d.ts\", \"src/**/*.ts\", \"esbuild/publicPath-shim.ts\"]\n}\n",
3782
+ "../../project-templates/stand/angular/esbuild/tsconfig.app.json.eta": "{\n \"extends\": \"./tsconfig.json\",\n \"compilerOptions\": {\n \"outDir\": \"./out-tsc/app\",\n \"types\": []\n },\n \"files\": [\"src/main.ts\", \"src/polyfills.ts\"],\n \"include\": [\"src/**/*.d.ts\", \"src/**/*.ts\", \"esbuild/publicPath-shim.ts\", \"scripts/publicPathDiagnostics.ts\"]\n}\n",
3720
3783
  "../../project-templates/stand/angular/esbuild/tsconfig.json.eta": "{\n \"compileOnSave\": false,\n \"compilerOptions\": {\n \"outDir\": \"./dist/out-tsc\",\n \"strict\": true,\n \"noImplicitOverride\": true,\n \"noPropertyAccessFromIndexSignature\": true,\n \"noImplicitReturns\": true,\n \"noFallthroughCasesInSwitch\": true,\n \"skipLibCheck\": true,\n \"isolatedModules\": true,\n \"esModuleInterop\": true,\n \"experimentalDecorators\": true,\n \"moduleResolution\": \"bundler\",\n \"importHelpers\": true,\n \"target\": \"ES2022\",\n \"module\": \"ES2022\",\n \"lib\": [\"ES2022\", \"dom\"],\n \"useDefineForClassFields\": false\n },\n \"angularCompilerOptions\": {\n \"enableI18nLegacyMessageIdFormat\": false,\n \"strictInjectionParameters\": true,\n \"strictInputAccessModifiers\": true,\n \"strictTemplates\": true\n }\n}\n",
3784
+ "../../project-templates/stand/angular/esbuild/tsconfig.middleware.json.eta": "{\n \"extends\": \"./tsconfig.json\",\n \"compilerOptions\": {\n \"types\": [\"node\"],\n \"moduleResolution\": \"bundler\"\n },\n \"include\": [\"scripts/devStorageMiddleware.ts\", \"scripts/standDevMiddleware.ts\"]\n}\n",
3721
3785
  "../../project-templates/stand/angular/webpack/README.md.eta": "<%~ include('stand-readme', it) %>\n",
3722
- "../../project-templates/stand/angular/webpack/angular.json.eta": "{\n \"$schema\": \"./node_modules/@angular/cli/lib/config/schema.json\",\n \"version\": 1,\n \"newProjectRoot\": \"projects\",\n \"projects\": {\n \"angular-host\": {\n \"projectType\": \"application\",\n \"root\": \"\",\n \"sourceRoot\": \"src\",\n \"prefix\": \"app\",\n \"architect\": {\n \"build\": {\n \"builder\": \"@angular-builders/custom-webpack:browser\",\n \"options\": {\n \"customWebpackConfig\": {\n \"path\": \"./custom-webpack.config.cjs\"\n },\n \"outputPath\": \"dist/angular-host\",\n \"index\": \"src/index.html\",\n \"main\": \"src/main.ts\",\n \"polyfills\": [\"zone.js\"],\n \"tsConfig\": \"tsconfig.app.json\",\n \"assets\": [\n {\n \"glob\": \"**/*\",\n \"input\": \"public\"\n },\n {\n \"glob\": \"serve.json\",\n \"input\": \".\",\n \"output\": \".\"\n }\n ],\n \"styles\": [\"src/styles.css\"],\n \"scripts\": []\n },\n \"configurations\": {\n \"production\": {\n \"budgets\": [\n {\n \"type\": \"initial\",\n \"maximumWarning\": \"8mb\",\n \"maximumError\": \"16mb\"\n }\n ],\n \"outputHashing\": \"all\",\n \"optimization\": true,\n \"sourceMap\": false,\n \"namedChunks\": false,\n \"extractLicenses\": true\n },\n \"development\": {\n \"optimization\": false,\n \"extractLicenses\": false,\n \"sourceMap\": true,\n \"namedChunks\": true\n }\n },\n \"defaultConfiguration\": \"development\"\n },\n \"serve\": {\n \"builder\": \"@angular-builders/custom-webpack:dev-server\",\n \"configurations\": {\n \"production\": {\n \"buildTarget\": \"angular-host:build:production\"\n },\n \"development\": {\n \"buildTarget\": \"angular-host:build:development\"\n }\n },\n \"defaultConfiguration\": \"development\"\n }\n }\n }\n }\n}\n",
3723
- "../../project-templates/stand/angular/webpack/custom-webpack.config.cjs.eta": "const { register } = require('tsx/cjs/api');\n\nfunction resolveDefaultExport(mod) {\n return mod && typeof mod === 'object' && 'default' in mod ? mod.default : mod;\n}\n\nconst hostWebpackPluginModule = require('<%~ it.packageName %>/webpack');\nconst <%= it.standWebpackPluginClassName %> = resolveDefaultExport(hostWebpackPluginModule);\n\nregister();\nconst devStorageMiddleware = resolveDefaultExport(require('./scripts/devStorageMiddleware.ts'));\nconst { mergeHostEditorDevServer } = require('./scripts/hostDevServerHeaders.ts');\n\n/**\n * Production graph close to Angular + custom-webpack hosts (enKod-like):\n * - scope hoisting → webpack `ConcatenatedModule`\n * - vendor split → product facade in a separate `vendors` chunk\n *\n * Host publicPath bootstrap must still reach the facade module under this layout.\n */\nfunction applyProductionConcatAndVendorSplit(config) {\n config.optimization = config.optimization || {};\n config.optimization.concatenateModules = true;\n\n const existingSplitChunks = config.optimization.splitChunks;\n const splitChunksObject =\n existingSplitChunks && typeof existingSplitChunks === 'object' && !Array.isArray(existingSplitChunks)\n ? existingSplitChunks\n : {};\n const existingCacheGroups =\n splitChunksObject.cacheGroups && typeof splitChunksObject.cacheGroups === 'object'\n ? splitChunksObject.cacheGroups\n : {};\n\n config.optimization.splitChunks = {\n ...splitChunksObject,\n cacheGroups: {\n ...existingCacheGroups,\n vendors: {\n ...(existingCacheGroups.vendors && typeof existingCacheGroups.vendors === 'object'\n ? existingCacheGroups.vendors\n : {}),\n test: /[\\\\/]node_modules[\\\\/]/,\n name: 'vendors',\n chunks: 'all',\n minSize: 0,\n priority: 10,\n enforce: true,\n },\n },\n };\n}\n\n/**\n * Typical Angular CustomWebpack host integration:\n * - CustomWebpack merge (Angular builder)\n * - output.publicPath: 'auto'\n * - scope hoisting (concatenateModules) + vendor split in production\n * - <%= it.standWebpackPluginClassName %> copies /<%~ it.standProductApiName %> assets + injects host publicPath bootstrap\n *\n * Mutate `config` in place — do not webpack-merge `module.rules` (breaks Angular style pipeline).\n */\nmodule.exports = (config, options) => {\n const isProd =\n options?.configuration === 'production' ||\n config.mode === 'production';\n\n const apiProxy = {\n context: ['/api'],\n target: <%~ JSON.stringify(it.standOpenApiBaseUrl) %>,\n secure: false,\n changeOrigin: true,\n onProxyReq: (proxyReq) => {\n proxyReq.setHeader('origin', <%~ JSON.stringify(it.standOpenApiOrigin) %>);\n },\n };\n\n config.module.rules.push({\n test: /\\.html$/i,\n resourceQuery: /raw/,\n type: 'asset/source',\n });\n\n config.output.publicPath = 'auto';\n if (isProd) {\n applyProductionConcatAndVendorSplit(config);\n }\n config.plugins.push(new <%= it.standWebpackPluginClassName %>());\n\n const prevSetupMiddlewares = config.devServer?.setupMiddlewares;\n config.devServer = {\n ...(config.devServer || {}),\n proxy: [\n ...(Array.isArray(config.devServer?.proxy) ? config.devServer.proxy : []),\n apiProxy,\n ],\n setupMiddlewares: (middlewares, devServer) => {\n devServer.app?.use(devStorageMiddleware());\n return typeof prevSetupMiddlewares === 'function'\n ? prevSetupMiddlewares(middlewares, devServer)\n : middlewares;\n },\n };\n mergeHostEditorDevServer(config);\n\n return config;\n};\n",
3786
+ "../../project-templates/stand/angular/webpack/angular.json.eta": "{\n \"$schema\": \"./node_modules/@angular/cli/lib/config/schema.json\",\n \"version\": 1,\n \"newProjectRoot\": \"projects\",\n \"projects\": {\n \"angular-host\": {\n \"projectType\": \"application\",\n \"root\": \"\",\n \"sourceRoot\": \"src\",\n \"prefix\": \"app\",\n \"architect\": {\n \"build\": {\n \"builder\": \"@angular-builders/custom-webpack:browser\",\n \"options\": {\n \"customWebpackConfig\": {\n \"path\": \"./custom-webpack.config.cjs\"\n },\n \"outputPath\": \"dist/angular-host\",\n \"index\": \"src/index.html\",\n \"main\": \"src/main.ts\",\n \"polyfills\": [\"src/polyfills.ts\"],\n \"tsConfig\": \"tsconfig.app.json\",\n \"assets\": [\n {\n \"glob\": \"**/*\",\n \"input\": \"public\"\n },\n {\n \"glob\": \"serve.json\",\n \"input\": \".\",\n \"output\": \".\"\n },\n {\n \"glob\": \"**/*\",\n \"input\": \"node_modules/<%~ it.packageName %>\",\n \"output\": \"<%~ it.standAngularProductAssetsOutput %>\",\n \"ignore\": [\n \"*.md\",\n \"*.ts\",\n \"*.d.ts\",\n \"*.json\",\n \"*.ico\",\n \"*.pot\",\n \"*.npmignore\",\n \"*.gitignore\",\n \"robots.txt\",\n \"webpack/**\",\n \"vite/**\",\n \"react/**\"\n ]\n }\n ],\n \"styles\": [\"src/styles.css\"],\n \"scripts\": []\n },\n \"configurations\": {\n \"production\": {\n \"budgets\": [\n {\n \"type\": \"initial\",\n \"maximumWarning\": \"8mb\",\n \"maximumError\": \"16mb\"\n }\n ],\n \"outputHashing\": \"bundles\",\n \"optimization\": true,\n \"sourceMap\": false,\n \"namedChunks\": false,\n \"extractLicenses\": true\n },\n \"development\": {\n \"optimization\": false,\n \"extractLicenses\": false,\n \"sourceMap\": true,\n \"namedChunks\": true\n }\n },\n \"defaultConfiguration\": \"development\"\n },\n \"serve\": {\n \"builder\": \"@angular-builders/custom-webpack:dev-server\",\n \"configurations\": {\n \"production\": {\n \"buildTarget\": \"angular-host:build:production\"\n },\n \"development\": {\n \"buildTarget\": \"angular-host:build:development\"\n }\n },\n \"defaultConfiguration\": \"development\"\n }\n }\n }\n }\n}\n",
3787
+ "../../project-templates/stand/angular/webpack/custom-webpack.config.cjs.eta": "const { register } = require('tsx/cjs/api');\n\nfunction resolveDefaultExport(mod) {\n return mod && typeof mod === 'object' && 'default' in mod ? mod.default : mod;\n}\n\nconst hostWebpackPluginModule = require('<%~ it.packageName %>/webpack');\nconst <%= it.standWebpackPluginClassName %> = resolveDefaultExport(hostWebpackPluginModule);\n\nregister();\nconst devStorageMiddleware = resolveDefaultExport(require('./scripts/devStorageMiddleware.ts'));\nconst { mergeHostEditorDevServer } = require('./scripts/hostDevServerHeaders.ts');\n\n/**\n * Production graph for Angular + custom-webpack: scope hoisting and vendor split.\n */\nfunction applyProductionConcatAndVendorSplit(config) {\n config.optimization = config.optimization || {};\n config.optimization.concatenateModules = true;\n\n const existingSplitChunks = config.optimization.splitChunks;\n const splitChunksObject =\n existingSplitChunks && typeof existingSplitChunks === 'object' && !Array.isArray(existingSplitChunks)\n ? existingSplitChunks\n : {};\n const existingCacheGroups =\n splitChunksObject.cacheGroups && typeof splitChunksObject.cacheGroups === 'object'\n ? splitChunksObject.cacheGroups\n : {};\n\n config.optimization.splitChunks = {\n ...splitChunksObject,\n cacheGroups: {\n ...existingCacheGroups,\n vendors: {\n ...(existingCacheGroups.vendors && typeof existingCacheGroups.vendors === 'object'\n ? existingCacheGroups.vendors\n : {}),\n test: /[\\\\/]node_modules[\\\\/]/,\n name: 'vendors',\n chunks: 'all',\n minSize: 0,\n priority: 10,\n enforce: true,\n },\n },\n };\n}\n\n/**\n * Typical Angular CustomWebpack host integration:\n * - CustomWebpack merge (Angular builder)\n * - output.publicPath: 'auto'\n * - scope hoisting (concatenateModules) + vendor split in production\n * - <%= it.standWebpackPluginClassName %> copies product assets + injects host publicPath bootstrap\n *\n * Repro (`STAND_REBUNDLE_REPRO=1`): the host plugin is off, so the bootstrap self-detects inside\n * the thin facade (~0.4 MB static closure in the lazy chunk). The rest of static/esm is copied\n * into embed/ at runtime and stays out of the compile graph.\n *\n * Mutate `config` in place — do not webpack-merge `module.rules` (breaks Angular style pipeline).\n */\nmodule.exports = (config, options) => {\n const rebundleRepro = process.env.STAND_REBUNDLE_REPRO === '1';\n const isProd =\n options?.configuration === 'production' ||\n config.mode === 'production';\n\n const apiProxy = {\n context: ['/api'],\n target: <%~ JSON.stringify(it.standOpenApiBaseUrl) %>,\n secure: false,\n changeOrigin: true,\n onProxyReq: (proxyReq) => {\n proxyReq.setHeader('origin', <%~ JSON.stringify(it.standOpenApiOrigin) %>);\n },\n };\n\n config.module.rules.push({\n test: /\\.html$/i,\n resourceQuery: /raw/,\n type: 'asset/source',\n });\n\n config.output.publicPath = 'auto';\n if (isProd) {\n applyProductionConcatAndVendorSplit(config);\n }\n if (!rebundleRepro) {\n config.plugins.push(new <%= it.standWebpackPluginClassName %>());\n }\n\n const prevSetupMiddlewares = config.devServer?.setupMiddlewares;\n config.devServer = {\n ...(config.devServer || {}),\n proxy: [\n ...(Array.isArray(config.devServer?.proxy) ? config.devServer.proxy : []),\n apiProxy,\n ],\n setupMiddlewares: (middlewares, devServer) => {\n devServer.app?.use(devStorageMiddleware());\n return typeof prevSetupMiddlewares === 'function'\n ? prevSetupMiddlewares(middlewares, devServer)\n : middlewares;\n },\n };\n mergeHostEditorDevServer(config);\n\n return config;\n};\n",
3724
3788
  "../../project-templates/stand/angular/webpack/package.json.eta": "<%~ include('stand-package-json', it) %>\n",
3789
+ "../../project-templates/stand/angular/webpack/scripts/chunkRepro.cjs.eta": "#!/usr/bin/env node\n/**\n * Cross-origin chunk repro: HTML on :4200, JS chunks on :4201.\n * Lazy chunk import.meta.url points at the CDN host; product assets stay on the page\n * origin (panel/<app>/).\n * Compile graph: thin facade only (~0.4 MB); static/esm is copied into panel/, not bundled.\n *\n * Usage: npm run build:rebundle && npm run serve:chunk-repro\n */\nconst http = require('node:http');\nconst https = require('node:https');\nconst fs = require('node:fs');\nconst path = require('node:path');\nconst { URL } = require('node:url');\n\nconst API_PROXY_ENABLED = <%= it.standClosedLoop ? 'false' : 'true' %>;\nconst API_TARGET = <%~ JSON.stringify(it.standOpenApiBaseUrl) %>;\nconst API_ORIGIN = <%~ JSON.stringify(it.standOpenApiOrigin) %>;\nconst SITE_PORT = 4200;\nconst CDN_PORT = 4201;\nconst DIST_RELATIVE = <%~ JSON.stringify(it.standAngularChunkReproDistRelative) %>;\n\nconst MIME = {\n '.html': 'text/html; charset=utf-8',\n '.js': 'text/javascript; charset=utf-8',\n '.css': 'text/css; charset=utf-8',\n '.json': 'application/json; charset=utf-8',\n '.woff': 'font/woff',\n '.woff2': 'font/woff2',\n '.png': 'image/png',\n '.svg': 'image/svg+xml',\n '.ico': 'image/x-icon',\n};\n\nconst STATIC_HEADERS = {\n 'Cross-Origin-Resource-Policy': 'cross-origin',\n 'Access-Control-Allow-Origin': '*',\n};\n\nfunction contentType(filePath) {\n return MIME[path.extname(filePath).toLowerCase()] || 'application/octet-stream';\n}\n\nfunction resolveFile(distDir, requestPath) {\n const safe = path.normalize(requestPath).replace(/^(\\.\\.[/\\\\])+/, '');\n const candidate = path.join(distDir, safe);\n if (!candidate.startsWith(distDir)) return null;\n if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) return candidate;\n return null;\n}\n\nfunction patchIndexHtml(html, cdnOrigin) {\n return html.replace(\n /(<script\\b[^>]*\\ssrc=\")(?!https?:|\\/\\/)([^\"]+)\"/gi,\n (_, prefix, src) => `${prefix}${cdnOrigin}/${src.replace(/^\\//, '')}\"`,\n );\n}\n\nfunction readRequestBody(req) {\n return new Promise((resolve, reject) => {\n const chunks = [];\n req.on('data', (chunk) => chunks.push(chunk));\n req.on('end', () => resolve(Buffer.concat(chunks)));\n req.on('error', reject);\n });\n}\n\nfunction buildProxyRequestHeaders(req, targetUrl, bodyLength) {\n const headers = { ...req.headers, host: targetUrl.host };\n if (headers.origin) {\n headers.origin = API_ORIGIN;\n }\n delete headers.connection;\n delete headers['transfer-encoding'];\n if (bodyLength > 0) {\n headers['content-length'] = String(bodyLength);\n } else {\n delete headers['content-length'];\n }\n return headers;\n}\n\nfunction drainResponse(proxyRes) {\n return new Promise((resolve) => {\n proxyRes.on('end', resolve);\n proxyRes.resume();\n });\n}\n\nfunction proxyApiRequest(req, res, targetUrl, body, redirectCount, method) {\n const MAX_REDIRECTS = 5;\n if (redirectCount > MAX_REDIRECTS) {\n res.writeHead(502, { 'Content-Type': 'text/plain; charset=utf-8' });\n res.end('Too many redirects');\n return;\n }\n\n const requestMethod = method || req.method || 'GET';\n const transport = targetUrl.protocol === 'https:' ? https : http;\n const headers = buildProxyRequestHeaders(req, targetUrl, body.length);\n\n const proxyReq = transport.request(\n targetUrl,\n { method: requestMethod, headers },\n (proxyRes) => {\n const status = proxyRes.statusCode || 502;\n const location = proxyRes.headers.location;\n if (status >= 300 && status < 400 && location) {\n drainResponse(proxyRes).then(() => {\n const nextUrl = new URL(location, targetUrl);\n const useGet = status === 303;\n proxyApiRequest(\n req,\n res,\n nextUrl,\n useGet ? Buffer.alloc(0) : body,\n redirectCount + 1,\n useGet ? 'GET' : requestMethod,\n );\n });\n return;\n }\n\n const outHeaders = { ...proxyRes.headers };\n delete outHeaders.location;\n res.writeHead(status, outHeaders);\n proxyRes.pipe(res);\n },\n );\n\n proxyReq.on('error', (error) => {\n console.error('[chunkRepro] API proxy error:', error.message);\n if (!res.headersSent) {\n res.writeHead(502, { 'Content-Type': 'text/plain; charset=utf-8' });\n res.end('Bad Gateway');\n }\n });\n\n if (body.length > 0) {\n proxyReq.write(body);\n }\n proxyReq.end();\n}\n\nasync function proxyApi(req, res) {\n const body = await readRequestBody(req);\n const targetUrl = new URL(req.url || '/', API_TARGET);\n proxyApiRequest(req, res, targetUrl, body, 0);\n}\n\nfunction createStaticServer(distDir, port, options = {}) {\n const { patchIndex = false, cdnOrigin = '' } = options;\n\n return http.createServer((req, res) => {\n const url = new URL(req.url || '/', `http://127.0.0.1:${port}`);\n const pathname = decodeURIComponent(url.pathname);\n\n if (patchIndex && API_PROXY_ENABLED && pathname.startsWith('/api')) {\n proxyApi(req, res);\n return;\n }\n\n let filePath = resolveFile(distDir, pathname === '/' ? '/index.html' : pathname);\n\n if (!filePath) {\n res.writeHead(404, STATIC_HEADERS);\n res.end('Not found');\n return;\n }\n\n if (patchIndex && filePath.endsWith('index.html')) {\n const raw = fs.readFileSync(filePath, 'utf8');\n res.writeHead(200, { ...STATIC_HEADERS, 'Content-Type': 'text/html; charset=utf-8' });\n res.end(patchIndexHtml(raw, cdnOrigin));\n return;\n }\n\n res.writeHead(200, { ...STATIC_HEADERS, 'Content-Type': contentType(filePath) });\n fs.createReadStream(filePath).pipe(res);\n }).listen(port, () => {\n console.log(`[chunkRepro] ${patchIndex ? 'site' : 'cdn'} → http://localhost:${port}/`);\n if (patchIndex && API_PROXY_ENABLED) {\n console.log(`[chunkRepro] /api → ${API_TARGET}`);\n }\n });\n}\n\nconst distDir = path.resolve(process.cwd(), DIST_RELATIVE);\nif (!fs.existsSync(path.join(distDir, 'index.html'))) {\n console.error(`[chunkRepro] Missing ${DIST_RELATIVE}/index.html — run \\`npm run build:rebundle\\` first.`);\n process.exit(1);\n}\n\nconst cdnOrigin = `http://localhost:${CDN_PORT}`;\ncreateStaticServer(distDir, CDN_PORT);\ncreateStaticServer(distDir, SITE_PORT, { patchIndex: true, cdnOrigin });\n\nconsole.log('[chunkRepro] Open http://localhost:4200/ — check Network + console [publicPath-diag]');\n",
3725
3790
  "../../project-templates/stand/angular/webpack/scripts/devStorageMiddleware.ts.eta": "<%~ include('stand-dev-storage-middleware', it) %>\n",
3726
3791
  "../../project-templates/stand/angular/webpack/scripts/hostDevServerHeaders.ts.eta": "<%~ include('stand-host-dev-server-webpack', it) %>\n",
3727
- "../../project-templates/stand/angular/webpack/src/app/app.component.css": ".page {\n font-family: system-ui, sans-serif;\n margin: 0 auto;\n max-width: 1200px;\n padding: 16px;\n}\n\n.error {\n color: #b42318;\n margin: 0 0 12px;\n}\n\n.editor-mount {\n min-height: 640px;\n}\n",
3728
- "../../project-templates/stand/angular/webpack/src/app/app.component.html.eta": "<main class=\"page\">\r\r\n @if (initError()) {\r\r\n <p class=\"error\">Editor failed: {{ initError() }}</p>\r\r\n }\r\r\n <div id=\"editor-root\" class=\"editor-mount\"></div>\r\r\n</main>\r\r\n",
3729
- "../../project-templates/stand/angular/webpack/src/app/app.component.ts.eta": "import { Component, OnInit, signal } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { initOAuthEditor } from './editor-host';\n\n@Component({\n selector: 'app-root',\n standalone: true,\n imports: [CommonModule],\n templateUrl: './app.component.html',\n styleUrl: './app.component.css',\n})\nexport class AppComponent implements OnInit {\n readonly initError = signal<string | null>(null);\n\n async ngOnInit(): Promise<void> {\n try {\n await initOAuthEditor();\n } catch (error) {\n this.initError.set(error instanceof Error ? error.message : String(error));\n }\n }\n}\n",
3792
+ "../../project-templates/stand/angular/webpack/scripts/publicPath-shim.ts.eta": "type ProductNamespace = {\n publicPath?: string;\n};\n\nconst namespace = <%~ JSON.stringify(it.standWindowNamespace) %>;\nconst publicPath = <%~ JSON.stringify(it.standAngularProductPublicPath + '/') %>;\n\nconst root = window as unknown as Record<string, ProductNamespace | undefined>;\n\nroot[namespace] = {\n ...(root[namespace] ?? {}),\n publicPath,\n};\n\nexport {};\n",
3793
+ "../../project-templates/stand/angular/webpack/scripts/publicPathDiagnostics.ts.eta": "type ProductNamespace = {\n publicPath?: string;\n};\n\nexport type PublicPathDiagSnapshot = {\n label: string;\n pageOrigin: string;\n pageHref: string;\n baseURI: string;\n windowNamespacePublicPath: string | undefined;\n expectedShimPrefix: string;\n bareNamespaceReadable: boolean;\n bareNamespacePublicPath: string | undefined;\n};\n\nconst namespace = <%~ JSON.stringify(it.standWindowNamespace) %>;\nconst expectedShimPrefix = <%~ JSON.stringify(it.standAngularProductPublicPath + '/') %>;\n\nfunction readBareNamespacePublicPath(): { readable: boolean; publicPath: string | undefined } {\n try {\n // eslint-disable-next-line no-new-func\n const read = new Function(\n `try { return typeof <%= it.standWindowNamespace %> !== 'undefined' ? <%= it.standWindowNamespace %>.publicPath : undefined; } catch (e) { return undefined; }`,\n ) as () => string | undefined;\n return { readable: true, publicPath: read() };\n } catch {\n return { readable: false, publicPath: undefined };\n }\n}\n\nexport function snapshotPublicPathDiagnostics(label: string): PublicPathDiagSnapshot {\n const root = window as unknown as Record<string, ProductNamespace | undefined>;\n const bare = readBareNamespacePublicPath();\n\n const snapshot: PublicPathDiagSnapshot = {\n label,\n pageOrigin: window.location.origin,\n pageHref: window.location.href,\n baseURI: typeof document !== 'undefined' ? document.baseURI : '',\n windowNamespacePublicPath: root[namespace]?.publicPath,\n expectedShimPrefix,\n bareNamespaceReadable: bare.readable,\n bareNamespacePublicPath: bare.publicPath,\n };\n\n const bag = window as unknown as { __standPublicPathDiagnostics?: PublicPathDiagSnapshot[] };\n bag.__standPublicPathDiagnostics = [...(bag.__standPublicPathDiagnostics ?? []), snapshot];\n console.info('[publicPath-diag]', label, snapshot);\n return snapshot;\n}\n",
3794
+ "../../project-templates/stand/angular/webpack/src/app/app.component.css": ".page {\n font-family: system-ui, sans-serif;\n margin: 0 auto;\n max-width: 1200px;\n padding: 16px;\n}\n\n.error {\n color: #b42318;\n margin: 0 0 12px;\n}\n\n.diag {\n background: #f4f4f5;\n border: 1px solid #d4d4d8;\n font-size: 12px;\n margin: 0 0 12px;\n max-height: 200px;\n overflow: auto;\n padding: 8px;\n}\n\n.editor-mount {\n min-height: 640px;\n}\n",
3795
+ "../../project-templates/stand/angular/webpack/src/app/app.component.html.eta": "<main class=\"page\">\n @if (initError()) {\n <p class=\"error\">Editor failed: {{ initError() }}</p>\n }\n @if (publicPathDiag()) {\n <pre class=\"diag\">{{ publicPathDiag() }}</pre>\n }\n <div id=\"editor-root\" class=\"editor-mount\"></div>\n</main>\n",
3796
+ "../../project-templates/stand/angular/webpack/src/app/app.component.ts.eta": "import { Component, AfterViewInit, signal } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport type { PublicPathDiagSnapshot } from '../../scripts/publicPathDiagnostics';\n\ntype DiagBag = { __standPublicPathDiagnostics?: PublicPathDiagSnapshot[] };\n\n@Component({\n selector: 'app-root',\n standalone: true,\n imports: [CommonModule],\n templateUrl: './app.component.html',\n styleUrl: './app.component.css',\n})\nexport class AppComponent implements AfterViewInit {\n readonly initError = signal<string | null>(null);\n readonly publicPathDiag = signal<string | null>(null);\n\n ngAfterViewInit(): void {\n import('./editor-host')\n .then(({ initOAuthEditor }) => initOAuthEditor())\n .then(() => {\n const bag = window as unknown as DiagBag;\n const last = bag.__standPublicPathDiagnostics?.at(-1);\n if (last) {\n this.publicPathDiag.set(JSON.stringify(last, null, 2));\n }\n })\n .catch((error) => {\n this.initError.set(error instanceof Error ? error.message : String(error));\n });\n }\n}\n",
3730
3797
  "../../project-templates/stand/angular/webpack/src/app/app.config.ts.eta": "import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';\n\nexport const appConfig: ApplicationConfig = {\n providers: [provideZoneChangeDetection({ eventCoalescing: true })],\n};\n",
3731
- "../../project-templates/stand/angular/webpack/src/app/editor-host.ts.eta": "import baseEmailHtml from '../dev/email.html?raw';\nimport { editorConfig } from '../dev/editorConfig';\nimport { getAuthToken } from '../dev/getAuthToken';\nimport { createLocalFolderStorageProvider } from '../dev/storageProvider';\n\n<%~ include('editor-init-smoke', it) %>\n\ntype EmailmakerModule = typeof import('<%~ it.packageName %>');\ntype EditorInstance = Awaited<ReturnType<EmailmakerModule['init']>>;\n\nlet editorInstance: EditorInstance | null = null;\n\nconst smokeMeta = {\n hostKind: 'stand-host' as const,\n variant: 'stand-angular',\n mountLabel: '#editor-root',\n};\n\nasync function loadEmailmakerModule(): Promise<EmailmakerModule> {\n return import('<%~ it.packageName %>');\n}\n\nexport async function initOAuthEditor(): Promise<EditorInstance> {\n if (editorInstance) {\n return editorInstance;\n }\n\n const mountElement = document.getElementById('editor-root');\n const <%= it.standProductApiName %> = await loadEmailmakerModule();\n\n try {\n const instance = await <%= it.standProductApiName %>.init({\n getAuthToken,\n storageProvider: createLocalFolderStorageProvider(),\n element: '#editor-root',\n content: {\n email: {\n title: <%~ JSON.stringify(it.devHostDemoTitle) %>,\n code: baseEmailHtml,\n },\n },\n config: editorConfig,\n });\n\n editorInstance = instance;\n reportEditorReady(smokeMeta, mountElement);\n return instance;\n } catch (error) {\n const message = reportEditorInitError(smokeMeta, error, mountElement);\n throw new Error(message);\n }\n}\n",
3798
+ "../../project-templates/stand/angular/webpack/src/app/editor-host.ts.eta": "import baseEmailHtml from '../dev/email.html?raw';\nimport { editorConfig } from '../dev/editorConfig';\nimport { getAuthToken } from '../dev/getAuthToken';\nimport { createLocalFolderStorageProvider } from '../dev/storageProvider';\nimport { snapshotPublicPathDiagnostics } from '../../scripts/publicPathDiagnostics';\n\n<%~ include('editor-init-smoke', it) %>\n\ntype EmailmakerModule = typeof import('<%~ it.packageName %>');\ntype EditorInstance = Awaited<ReturnType<EmailmakerModule['init']>>;\n\nlet editorInstance: EditorInstance | null = null;\n\nconst smokeMeta = {\n hostKind: 'stand-host' as const,\n variant: 'stand-angular',\n mountLabel: '#editor-root',\n};\n\nasync function loadEmailmakerModule(): Promise<EmailmakerModule> {\n return import('<%~ it.packageName %>');\n}\n\nfunction formatInitError(error: unknown): string {\n if (error instanceof Error && error.message) {\n return error.message;\n }\n if (typeof error === 'string' && error.trim()) {\n return error.trim();\n }\n return 'Editor initialization failed.';\n}\n\nexport async function initOAuthEditor(): Promise<EditorInstance> {\n if (editorInstance) {\n return editorInstance;\n }\n\n const mountElement = document.getElementById('editor-root');\n snapshotPublicPathDiagnostics('before-emailmaker-import');\n const <%= it.standProductApiName %> = await loadEmailmakerModule();\n snapshotPublicPathDiagnostics('after-emailmaker-import');\n\n try {\n const instance = await <%= it.standProductApiName %>.init({\n getAuthToken,\n storageProvider: createLocalFolderStorageProvider(),\n element: '#editor-root',\n content: {\n email: {\n title: <%~ JSON.stringify(it.devHostDemoTitle) %>,\n code: baseEmailHtml,\n },\n },\n config: editorConfig,\n });\n\n editorInstance = instance;\n reportEditorReady(smokeMeta, mountElement);\n return instance;\n } catch (error) {\n const message = reportEditorInitError(smokeMeta, error, mountElement) ?? formatInitError(error);\n throw new Error(message);\n }\n}\n",
3732
3799
  "../../project-templates/stand/angular/webpack/src/dev/editorConfig.ts.eta": "<%~ include('stand-editor-config', it) %>\n",
3733
3800
  "../../project-templates/stand/angular/webpack/src/dev/email.html.eta": "<%~ include('stand-dev-email', it) %>\n",
3734
3801
  "../../project-templates/stand/angular/webpack/src/dev/getAuthToken.ts.eta": "<%~ include('stand-get-auth-token', it) %>\n",
@@ -3736,9 +3803,10 @@ var rawTemplateModules = /* #__PURE__ */ Object.assign({
3736
3803
  "../../project-templates/stand/angular/webpack/src/dev/storageProvider.ts.eta": "<%~ include('stand-storage-provider', it) %>\n",
3737
3804
  "../../project-templates/stand/angular/webpack/src/index.html.eta": "<!doctype html>\n<html lang=\"<%~ it.standIndexHtmlLang %>\">\n <head>\n <meta charset=\"utf-8\" />\n <title><%~ it.standIndexHtmlTitle %></title>\n <base href=\"/\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n </head>\n <body>\n <app-root></app-root>\n </body>\n</html>\n",
3738
3805
  "../../project-templates/stand/angular/webpack/src/main.ts.eta": "import { bootstrapApplication } from '@angular/platform-browser';\nimport { AppComponent } from './app/app.component';\nimport { appConfig } from './app/app.config';\n\nbootstrapApplication(AppComponent, appConfig).catch((error) => {\n console.error('[angular-stand] bootstrap failed', error);\n});\n",
3806
+ "../../project-templates/stand/angular/webpack/src/polyfills.ts.eta": "import '../scripts/publicPath-shim';\nimport 'zone.js';\n",
3739
3807
  "../../project-templates/stand/angular/webpack/src/styles.css": "body {\n margin: 0;\n background: #fff;\n color: #101828;\n}\n\ncode {\n font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n font-size: 0.92em;\n}\n",
3740
3808
  "../../project-templates/stand/angular/webpack/src/types.d.ts": "declare module '*?raw' {\n const content: string;\n export default content;\n}\n",
3741
- "../../project-templates/stand/angular/webpack/tsconfig.app.json.eta": "{\n \"extends\": \"./tsconfig.json\",\n \"compilerOptions\": {\n \"outDir\": \"./out-tsc/app\",\n \"types\": []\n },\n \"files\": [\"src/main.ts\"],\n \"include\": [\"src/**/*.d.ts\", \"src/**/*.ts\"]\n}\n",
3809
+ "../../project-templates/stand/angular/webpack/tsconfig.app.json.eta": "{\n \"extends\": \"./tsconfig.json\",\n \"compilerOptions\": {\n \"outDir\": \"./out-tsc/app\",\n \"types\": []\n },\n \"files\": [\"src/main.ts\", \"src/polyfills.ts\"],\n \"include\": [\"src/**/*.d.ts\", \"src/**/*.ts\", \"scripts/publicPathDiagnostics.ts\"]\n}\n",
3742
3810
  "../../project-templates/stand/angular/webpack/tsconfig.json.eta": "{\n \"compileOnSave\": false,\n \"compilerOptions\": {\n \"outDir\": \"./dist/out-tsc\",\n \"strict\": true,\n \"noImplicitOverride\": true,\n \"noPropertyAccessFromIndexSignature\": true,\n \"noImplicitReturns\": true,\n \"noFallthroughCasesInSwitch\": true,\n \"skipLibCheck\": true,\n \"isolatedModules\": true,\n \"esModuleInterop\": true,\n \"experimentalDecorators\": true,\n \"moduleResolution\": \"bundler\",\n \"importHelpers\": true,\n \"target\": \"ES2022\",\n \"module\": \"ES2022\",\n \"lib\": [\"ES2022\", \"dom\"],\n \"useDefineForClassFields\": false\n },\n \"angularCompilerOptions\": {\n \"enableI18nLegacyMessageIdFormat\": false,\n \"strictInjectionParameters\": true,\n \"strictInputAccessModifiers\": true,\n \"strictTemplates\": true\n }\n}\n",
3743
3811
  "../../project-templates/stand/closed-loop/vite/README.md.eta": "<%~ include('stand-readme', it) %>\n",
3744
3812
  "../../project-templates/stand/closed-loop/vite/config/dev-host.ts.eta": "<%~ include('stand-dev-host-vite', it) %>\n",
@@ -4303,17 +4371,42 @@ function generateFiles(options) {
4303
4371
  }
4304
4372
  //#endregion
4305
4373
  //#region lib/cli/postCreateRunCommands.ts
4306
- function getStandProductionServeScript(bundler) {
4307
- return bundler === "vite" ? "preview" : "serve:dist";
4374
+ function isModuleFederationStand(options) {
4375
+ return options.kind === "demo-stand" && options.standMode === "advanced" && options.advancedProfile === "module-federation";
4376
+ }
4377
+ function isAngularEsbuildStand(options) {
4378
+ return options.kind === "demo-stand" && options.standMode === "angular-esbuild";
4379
+ }
4380
+ function isAngularWebpackStand(options) {
4381
+ return options.kind === "demo-stand" && options.standMode === "angular";
4382
+ }
4383
+ function isAngularReproStand(options) {
4384
+ return isAngularWebpackStand(options) || isAngularEsbuildStand(options);
4385
+ }
4386
+ function getStandProductionServeScript(options) {
4387
+ if (isAngularEsbuildStand(options)) return "serve:chunk-repro";
4388
+ return options.bundler === "vite" ? "preview" : "serve:dist";
4308
4389
  }
4309
- function formatStandProductionCommand(packageManager, bundler) {
4310
- return `${packageManager} run build && ${packageManager} run ${getStandProductionServeScript(bundler)}`;
4390
+ function formatStandReproCommand(packageManager, options) {
4391
+ if (!isAngularReproStand(options)) throw new Error("Repro start mode is only available for Angular demo stands (CustomWebpack or CustomEsbuild).");
4392
+ if (isAngularEsbuildStand(options)) return `${packageManager} run build && ${packageManager} run serve:chunk-repro`;
4393
+ return `${packageManager} run build:rebundle && ${packageManager} run serve:chunk-repro`;
4394
+ }
4395
+ function formatStandProductionCommand(packageManager, options) {
4396
+ if (isModuleFederationStand(options)) return `${packageManager} run start`;
4397
+ return `${packageManager} run build && ${packageManager} run ${getStandProductionServeScript(options)}`;
4311
4398
  }
4312
4399
  function getPostCreateRunCommands(startMode, options, packageManager = "npm") {
4313
4400
  if (startMode === "none") return [];
4314
4401
  if (startMode === "debug") return [[packageManager, ["run", "start"]]];
4402
+ if (startMode === "repro") {
4403
+ if (!isAngularReproStand(options)) throw new Error("Repro start mode is only available for Angular demo stands (CustomWebpack or CustomEsbuild).");
4404
+ if (isAngularEsbuildStand(options)) return [[packageManager, ["run", "build"]], [packageManager, ["run", "serve:chunk-repro"]]];
4405
+ return [[packageManager, ["run", "build:rebundle"]], [packageManager, ["run", "serve:chunk-repro"]]];
4406
+ }
4315
4407
  if (options.kind === "demo-stand") {
4316
- const serveScript = getStandProductionServeScript(options.bundler);
4408
+ if (isModuleFederationStand(options)) return [[packageManager, ["run", "start"]]];
4409
+ const serveScript = getStandProductionServeScript(options);
4317
4410
  return [[packageManager, ["run", "build"]], [packageManager, ["run", serveScript]]];
4318
4411
  }
4319
4412
  return [[packageManager, ["run", "start:release"]]];
@@ -4410,6 +4503,7 @@ async function promptForPostCreateActions(options, messages) {
4410
4503
  startMode: "none"
4411
4504
  };
4412
4505
  const isStand = options.kind === "demo-stand";
4506
+ const isAngularReproStand = isStand && (options.standMode === "angular" || options.standMode === "angular-esbuild");
4413
4507
  return {
4414
4508
  installDependencies: true,
4415
4509
  startMode: (await (0, prompts.default)({
@@ -4428,7 +4522,11 @@ async function promptForPostCreateActions(options, messages) {
4428
4522
  {
4429
4523
  title: isStand ? messages.promptStandStartModeRelease : messages.promptStartModeRelease,
4430
4524
  value: "release"
4431
- }
4525
+ },
4526
+ ...isAngularReproStand ? [{
4527
+ title: messages.promptStandStartModeRepro,
4528
+ value: "repro"
4529
+ }] : []
4432
4530
  ],
4433
4531
  initial: 1
4434
4532
  }, { onCancel: cancelPrompt })).startMode ?? "none"
@@ -4449,7 +4547,8 @@ function printNextSteps(result, options, actions, messages, credentialsReady = f
4449
4547
  const packageManager = result.packageManager ?? getCurrentPackageManager();
4450
4548
  const installCommand = formatInstallCommand(packageManager);
4451
4549
  const startDebugCommand = `${packageManager} run start`;
4452
- const startReleaseCommand = options.kind === "demo-stand" ? formatStandProductionCommand(packageManager, options.bundler) : `${packageManager} run start:release`;
4550
+ const startReleaseCommand = options.kind === "demo-stand" ? formatStandProductionCommand(packageManager, options) : `${packageManager} run start:release`;
4551
+ const startReproCommand = options.kind === "demo-stand" && (options.standMode === "angular" || options.standMode === "angular-esbuild") ? formatStandReproCommand(packageManager, options) : null;
4453
4552
  const relativeTargetDir = path.default.relative(process.cwd(), result.targetDir) || ".";
4454
4553
  const steps = [{
4455
4554
  title: messages.nextStepChangeDir,
@@ -4495,7 +4594,10 @@ function printNextSteps(result, options, actions, messages, credentialsReady = f
4495
4594
  }, {
4496
4595
  title: messages.nextStepStartRelease,
4497
4596
  command: startReleaseCommand
4498
- });
4597
+ }, ...startReproCommand ? [{
4598
+ title: messages.promptStandStartModeRepro,
4599
+ command: startReproCommand
4600
+ }] : []);
4499
4601
  else if (actions.startMode === "none") steps.push({
4500
4602
  title: messages.nextStepAlreadyInstalled,
4501
4603
  command: null
@@ -4505,12 +4607,15 @@ function printNextSteps(result, options, actions, messages, credentialsReady = f
4505
4607
  }, {
4506
4608
  title: messages.nextStepStartRelease,
4507
4609
  command: startReleaseCommand
4508
- });
4610
+ }, ...startReproCommand ? [{
4611
+ title: messages.promptStandStartModeRepro,
4612
+ command: startReproCommand
4613
+ }] : []);
4509
4614
  else steps.push({
4510
4615
  title: messages.nextStepAlreadyInstalled,
4511
4616
  command: null
4512
4617
  }, {
4513
- title: actions.startMode === "release" ? messages.nextStepServerStartingRelease : messages.nextStepServerStartingDebug,
4618
+ title: actions.startMode === "repro" ? messages.nextStepServerStartingRepro : actions.startMode === "release" ? messages.nextStepServerStartingRelease : messages.nextStepServerStartingDebug,
4514
4619
  command: null
4515
4620
  });
4516
4621
  console.log(`[cli] ${messages.nextSteps}`);
@@ -4652,7 +4757,7 @@ async function runCli(argvInput = process.argv.slice(2)) {
4652
4757
  console.log(`[cli] ${messages.resourceProxyAuth(resourceProxyAuthLabel)}`);
4653
4758
  }
4654
4759
  if (validated.standMode === "advanced" && validated.advancedProfile) {
4655
- const advancedProfileLabel = validated.advancedProfile === "shadow-dom" ? messages.promptAdvancedProfileShadowDom : validated.advancedProfile === "umd" ? messages.promptAdvancedProfileUmd : validated.advancedProfile === "memory-usage" ? messages.promptAdvancedProfileMemoryUsage : messages.promptAdvancedProfileSubpath;
4760
+ const advancedProfileLabel = validated.advancedProfile === "shadow-dom" ? messages.promptAdvancedProfileShadowDom : validated.advancedProfile === "umd" ? messages.promptAdvancedProfileUmd : validated.advancedProfile === "memory-usage" ? messages.promptAdvancedProfileMemoryUsage : validated.advancedProfile === "module-federation" ? messages.promptAdvancedProfileModuleFederation : messages.promptAdvancedProfileSubpath;
4656
4761
  console.log(`[cli] ${messages.advancedProfile(advancedProfileLabel)}`);
4657
4762
  }
4658
4763
  }
@@ -4664,7 +4769,7 @@ async function runCli(argvInput = process.argv.slice(2)) {
4664
4769
  printNextSteps(result, validated, postCreateActions, messages, isLocalCredentialsComplete(validated, result.localCredentials));
4665
4770
  if (postCreateActions.startMode !== "none") {
4666
4771
  const runCommands = getPostCreateRunCommands(postCreateActions.startMode, validated, result.packageManager);
4667
- const startMessage = postCreateActions.startMode === "release" ? messages.autoStartRelease : validated.kind === "plugin" ? messages.autoStartDebug : messages.autoStart;
4772
+ const startMessage = postCreateActions.startMode === "release" ? messages.autoStartRelease : postCreateActions.startMode === "repro" ? messages.autoStartRepro : validated.kind === "plugin" ? messages.autoStartDebug : messages.autoStart;
4668
4773
  console.log(`[cli] ${startMessage}`);
4669
4774
  for (const [runCommand, runArgs] of runCommands) runProjectCommand(result.targetDir, runCommand, runArgs);
4670
4775
  }