@emailmaker/emailmaker 1.1.32 → 1.1.37

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 (31) hide show
  1. package/{emailmaker-core.8bdd92fb.js → emailmaker-core.0ff481a9.js} +1 -1
  2. package/emailmaker-esm.js +16 -5
  3. package/emailmaker.d.ts +6 -2
  4. package/emailmaker.js +169 -5
  5. package/iframe/js/amp.DieSnBUu.js +1 -1
  6. package/iframe/js/iframe-eblock.js +1 -1
  7. package/iframe/js/iframe.js +1 -1
  8. package/iframe/js/rules.CNqvmp_P.js +1 -1
  9. package/package.json +1 -1
  10. package/singlepage_headless_plugin.html +1 -1
  11. package/static/core/{34ed48da.js → 27685bbb.js} +1 -1
  12. package/static/core/{96583da0.js → 320461fe.js} +1 -1
  13. package/static/core/{1369407e2.js → 4093d2d32.js} +1 -1
  14. package/static/core/{4698f05f.js → 477647c7.js} +3 -3
  15. package/static/core/{3d1e7c2e.js → 68686884.js} +1 -1
  16. package/static/core/{2c12aa51.js → 792e7855.js} +1 -1
  17. package/static/core/{7ae09748.js → 8136054a.js} +1 -1
  18. package/static/core/9cca346f.js +1 -0
  19. package/static/core/{db185a82.js → b8e0a832.js} +62 -62
  20. package/static/core/{7760eab7.js → ba180803.js} +1 -1
  21. package/static/core/{0a752305.js → c9e0bc5a.js} +1 -1
  22. package/static/core/{d5670b2e.js → d94a3331.js} +1 -1
  23. package/static/core/{b7b90cb5.js → e8011287.js} +3 -3
  24. package/two_step_headless_plugin.html +1 -1
  25. package/vite/index.cjs +109 -18
  26. package/vite/index.js +109 -18
  27. package/webpack/index.cjs +108 -11
  28. package/webpack/index.js +108 -11
  29. package/static/core/e1095f09.js +0 -1
  30. /package/iframe/{iframe-eblock.8bdd92fb.html → iframe-eblock.0ff481a9.html} +0 -0
  31. /package/iframe/{iframe.8bdd92fb.html → iframe.0ff481a9.html} +0 -0
package/webpack/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import path from "path";
2
2
  import fs from "fs";
3
+ import { createRequire } from "module";
3
4
  //#region src/shared/stringCase.ts
4
5
  function toPascalCase(str) {
5
6
  return `${str}`.toLowerCase().replace(/[-_]+/g, " ").replace(/[^\w\s]/g, "").replace(/\s+(.)(\w*)/g, (_m, a, b) => `${a.toUpperCase()}${b}`).replace(/\w/, (s) => s.toUpperCase());
@@ -18,6 +19,11 @@ function toPascalCase(str) {
18
19
  * (`/product` -> `/product/`, resolved against the host `document.baseURI`).
19
20
  * - With `publicPath`: `http://host:3032` + `/product` -> `http://host:3032/product/`.
20
21
  */
22
+ function normalizeHostBundlerPublicPath(publicPath) {
23
+ const value = String(publicPath ?? "").trim();
24
+ if (!value || value === "auto" || value === "automatic") return "";
25
+ return value;
26
+ }
21
27
  function joinHostPublicPath(publicPath, outputFolder, defaultOutputFolder) {
22
28
  const folder = outputFolder != null && outputFolder !== "" ? String(outputFolder) : defaultOutputFolder;
23
29
  const base = String(publicPath || "").replace(/\/+$/, "");
@@ -60,12 +66,29 @@ function createInitFragment(environmentVariable, publicPath, startupPrefetchMode
60
66
  `if (!window.${environmentVariable}.startupPrefetchMode) window.${environmentVariable}.startupPrefetchMode = "${startupPrefetchMode}";`
61
67
  ].join(" ");
62
68
  }
69
+ function moduleSourceContainsFacadeSentinel(source) {
70
+ return typeof source === "string" && source.includes("@shared-runtime:init-complete");
71
+ }
72
+ /**
73
+ * True when host bootstrap was already prepended (avoid double injection).
74
+ *
75
+ * Must match the host-plugin assignment shape from `createInitFragment` /
76
+ * `createNormalizedPublicPathAssignment`, NOT a bare `window.__ns__.publicPath`
77
+ * substring — publish diagnostics embed that substring inside string literals and
78
+ * would otherwise false-positive and block all host injection.
79
+ */
80
+ function moduleSourceHasHostPublicPathBootstrap(source, environmentVariable) {
81
+ if (typeof source !== "string" || !source) return false;
82
+ return source.includes(`if (!window.${environmentVariable}.publicPath) window.${environmentVariable}.publicPath =`);
83
+ }
63
84
  //#endregion
64
85
  //#region src/shared/hostPackageEntryMatch.ts
65
86
  /**
66
87
  * Match main product entry modules for host bootstrap injection (Vite + Webpack).
67
88
  * Uses suffix matching so absolute node_modules ids ending with `{packagePath}/{appName}-esm.js`
68
89
  * match the same way as Webpack `renderModuleContent` (endsWith), not exact relative paths.
90
+ * When path matching fails (alias, wrapper re-export), falls back to publish facade sentinel
91
+ * in module source (`@shared-runtime:init-complete`).
69
92
  */
70
93
  function normalizeHostModulePath(value) {
71
94
  return String(value || "").replace(/#.*$/s, "").replace(/\?.*$/s, "").replace(/\\/g, "/");
@@ -87,6 +110,50 @@ function shouldMatchProductPackageEntry(moduleId, packagePath, appName, optimize
87
110
  }
88
111
  return false;
89
112
  }
113
+ function shouldPatchProductEntry(options) {
114
+ const { moduleId, source, packagePath, appName, optimizedDepFileName, environmentVariable } = options;
115
+ if (environmentVariable && moduleSourceHasHostPublicPathBootstrap(source, environmentVariable)) return false;
116
+ if (shouldMatchProductPackageEntry(moduleId, packagePath, appName, optimizedDepFileName)) return true;
117
+ return moduleSourceContainsFacadeSentinel(source);
118
+ }
119
+ //#endregion
120
+ //#region src/shared/resolvePublishedPackage.ts
121
+ /**
122
+ * Resolve the on-disk root of the published main package (handles pnpm hoisting / symlinks).
123
+ * Prefers `modulesPath/<packagePath>` under `cwd` when `package.json` exists there.
124
+ */
125
+ function resolvePublishedPackageRoot(packagePath, modulesPath = "node_modules", cwd = process.cwd()) {
126
+ const modulesRoot = path.isAbsolute(modulesPath) ? modulesPath : path.join(cwd, modulesPath);
127
+ const localRoot = path.join(modulesRoot, ...packagePath.split("/"));
128
+ const localPackageJson = path.join(localRoot, "package.json");
129
+ if (fs.existsSync(localPackageJson)) return localRoot;
130
+ try {
131
+ const packageJsonPath = createRequire(path.join(cwd, "package.json")).resolve(`${packagePath}/package.json`);
132
+ return path.dirname(packageJsonPath);
133
+ } catch {
134
+ return localRoot;
135
+ }
136
+ }
137
+ var PublishedPackageNotFoundError = class extends Error {
138
+ constructor(packagePath, resolvedPath) {
139
+ super(`[host-plugin] Published package "${packagePath}" was not found at "${resolvedPath}". Install the product npm package or set \`modulesPath\` to the directory that contains it.`);
140
+ this.packagePath = packagePath;
141
+ this.resolvedPath = resolvedPath;
142
+ this.name = "PublishedPackageNotFoundError";
143
+ }
144
+ };
145
+ function assertPublishedPackageExists(packageRoot, packagePath) {
146
+ if (!fs.existsSync(packageRoot) || !fs.statSync(packageRoot).isDirectory()) throw new PublishedPackageNotFoundError(packagePath, packageRoot);
147
+ }
148
+ function assertCoreChunkInCompilationAssets(assetNames, appName, outputFolder) {
149
+ const folderPrefix = String(outputFolder || "").replace(/\\/g, "/").replace(/^\/+|\/+$/g, "");
150
+ const corePattern = new RegExp(`(^|/)${appName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}-core\\.[^/]+\\.js$`);
151
+ if (!Array.from(assetNames).some((name) => {
152
+ const normalized = name.replace(/\\/g, "/");
153
+ if (folderPrefix && !(normalized === folderPrefix || normalized.startsWith(`${folderPrefix}/`))) return false;
154
+ return corePattern.test(normalized);
155
+ })) throw new Error(`[host-plugin] No "${appName}-core.*.js" asset was emitted under "${folderPrefix || "(output)"}" after copy. The published package may be incomplete or IGNORED_PATTERNS filtered the core chunk.`);
156
+ }
90
157
  //#endregion
91
158
  //#region src/shared/branding.ts
92
159
  /**
@@ -134,12 +201,43 @@ function getWebpackModulePath(module) {
134
201
  const name = typeof module.nameForCondition === "function" ? module.nameForCondition() : null;
135
202
  return typeof name === "string" && name ? name : void 0;
136
203
  }
137
- function getModuleSourceCode(source) {
204
+ function getConcatenatedInnerModules(module) {
205
+ const inner = module?.modules;
206
+ if (!inner) return [];
207
+ if (Array.isArray(inner)) return inner;
208
+ if (typeof inner[Symbol.iterator] === "function") return Array.from(inner);
209
+ return [];
210
+ }
211
+ function getWebpackModuleSource(source) {
212
+ if (typeof source === "string") return source;
138
213
  if (source && typeof source === "object" && "source" in source && typeof source.source === "function") return source.source();
139
- return String(source ?? "");
214
+ return "";
140
215
  }
141
- function shouldInjectRuntimeBootstrap(modulePath) {
142
- return shouldMatchProductPackageEntry(modulePath || "", BUNDLER_DEFAULT_PACKAGE_NAME, BUNDLER_DEFAULT_APP_NAME);
216
+ /**
217
+ * With `optimization.concatenateModules` (scope hoisting) `renderModuleContent` fires once for
218
+ * the `ConcatenatedModule`: its own `resource` is undefined and `nameForCondition`/`rootModule`
219
+ * point at the host entry, not the product facade. We inspect the concatenated inner modules so
220
+ * the publicPath bootstrap still reaches the facade (regression: enKod / Angular prod webpack).
221
+ * Content sentinel fallback covers alias / wrapper paths where inner module paths do not match.
222
+ */
223
+ function shouldInjectRuntimeBootstrap(module, source) {
224
+ const sourceCode = getWebpackModuleSource(source);
225
+ if (moduleSourceHasHostPublicPathBootstrap(sourceCode, ENVIRONMENT_VARIABLE)) return false;
226
+ const shared = {
227
+ packagePath: BUNDLER_DEFAULT_PACKAGE_NAME,
228
+ appName: BUNDLER_DEFAULT_APP_NAME,
229
+ environmentVariable: ENVIRONMENT_VARIABLE
230
+ };
231
+ if (shouldPatchProductEntry({
232
+ moduleId: getWebpackModulePath(module) || "",
233
+ source: sourceCode,
234
+ ...shared
235
+ })) return true;
236
+ return getConcatenatedInnerModules(module).some((inner) => shouldPatchProductEntry({
237
+ moduleId: getWebpackModulePath(inner) || "",
238
+ source: void 0,
239
+ ...shared
240
+ }));
143
241
  }
144
242
  /**
145
243
  * Webpack plugin for host applications.
@@ -184,7 +282,7 @@ var WebpackPlugin = class {
184
282
  apply(compiler) {
185
283
  const rawPub = compiler.options.output.publicPath;
186
284
  const optionsPublicPath = typeof rawPub === "string" ? rawPub : "";
187
- const initFragment = createInitFragment(ENVIRONMENT_VARIABLE, joinHostPublicPath(this._publicPath === void 0 ? optionsPublicPath : this._publicPath, this._outputFolder, DEFAULT_OUTPUT_FOLDER), this._startupPrefetchMode);
285
+ const initFragment = createInitFragment(ENVIRONMENT_VARIABLE, joinHostPublicPath(normalizeHostBundlerPublicPath(this._publicPath === void 0 ? optionsPublicPath : this._publicPath), this._outputFolder, DEFAULT_OUTPUT_FOLDER), this._startupPrefetchMode);
188
286
  const webpack = compiler.webpack;
189
287
  const javascript = webpack.javascript;
190
288
  this._sources = webpack.sources;
@@ -194,18 +292,17 @@ var WebpackPlugin = class {
194
292
  stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL
195
293
  }, async (_unusedAssets, cb) => {
196
294
  try {
197
- await this.copyFiles(compilation, path.join(this._modulesPath, BUNDLER_DEFAULT_PACKAGE_NAME), this._outputFolder);
295
+ const packageRoot = resolvePublishedPackageRoot(BUNDLER_DEFAULT_PACKAGE_NAME, this._modulesPath, compilation.compiler.context);
296
+ assertPublishedPackageExists(packageRoot, BUNDLER_DEFAULT_PACKAGE_NAME);
297
+ await this.copyFiles(compilation, packageRoot, this._outputFolder);
298
+ assertCoreChunkInCompilationAssets(compilation.getAssets().map((asset) => asset.name), BUNDLER_DEFAULT_APP_NAME, toAssetPath(this._outputFolder));
198
299
  cb(null);
199
300
  } catch (error) {
200
301
  cb(error);
201
302
  }
202
303
  });
203
304
  javascript.JavascriptModulesPlugin.getCompilationHooks(compilation).renderModuleContent.tap(PLUGIN_NAME, (source, module) => {
204
- if (shouldInjectRuntimeBootstrap(getWebpackModulePath(module))) {
205
- const sources = this._sources || compilation.compiler.webpack.sources;
206
- const patched = `${initFragment}\n${getModuleSourceCode(source)}`;
207
- return new sources.RawSource(patched);
208
- }
305
+ if (shouldInjectRuntimeBootstrap(module, source)) return new (this._sources || compilation.compiler.webpack.sources).ConcatSource(`${initFragment}\n`, source);
209
306
  return source;
210
307
  });
211
308
  });
@@ -1 +0,0 @@
1
- __emailmaker__.define(`static/core/e1095f09.js`,[`require`,`exports`,`module`,`static/core/354bf8a9.js`,`static/core/db185a82.js`],function(e,t,n){e("./354bf8a9.js"),t.default=e("./db185a82.js").t});