@ecopages/ecopages-jsx 0.2.0-alpha.20 → 0.2.0-alpha.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -8,6 +8,7 @@
8
8
 
9
9
  ### Bug Fixes
10
10
 
11
+ - Patched the Ecopages JSX browser runtime bundle so nested SVG templates restore canonical camel-cased SVG tag names during client rendering.
11
12
  - Aligned Ecopages JSX peer dependency ranges with the current `@ecopages/jsx` and `@ecopages/radiant` alpha releases.
12
13
  - Aligned Radiant SSR and hydration wiring with the public `@ecopages/radiant/server/render-component` and `@ecopages/radiant/client/hydrator` entrypoints so JSX apps install an explicit client hydrator bootstrap instead of relying on implicit side effects.
13
14
  - Fixed Radiant SSR page inspection to install the light-DOM shim before JSX page modules are imported outside the normal render pass.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecopages/ecopages-jsx",
3
- "version": "0.2.0-alpha.20",
3
+ "version": "0.2.0-alpha.22",
4
4
  "description": "JSX integration plugin for Ecopages",
5
5
  "keywords": [
6
6
  "ecopages",
@@ -21,8 +21,8 @@
21
21
  "vfile": "^6.0.3"
22
22
  },
23
23
  "peerDependencies": {
24
- "@ecopages/core": "0.2.0-alpha.20",
25
- "@ecopages/jsx": "^0.3.0-alpha.2",
26
- "@ecopages/radiant": "^0.3.0-alpha.2"
24
+ "@ecopages/core": "0.2.0-alpha.22",
25
+ "@ecopages/jsx": "0.3.0-alpha.4",
26
+ "@ecopages/radiant": "0.3.0-alpha.4"
27
27
  }
28
28
  }
@@ -12,6 +12,17 @@ const VENDOR_FILE_NAMES = {
12
12
  radiant: "ecopages-radiant-esm.js"
13
13
  };
14
14
  const RADIANT_HYDRATOR_BOOTSTRAP_ATTRIBUTE = "data-ecopages-jsx-radiant-hydrator";
15
+ const JSX_RUNTIME_NAMESPACE_REPAIR_SNIPPET = "function rG(W,G,J){let j=G instanceof Element?G:G?.parentElement,U=j?.namespaceURI??K9,$=j?.localName,X=W.firstElementChild;if(!X)return;let F=J??X.localName,Z=O9(U,$,F);if(X.namespaceURI===Z&&X.localName===F)return;W.replaceChild(tG(X,Z,F),X)}function tG(W,G,J){let j=document.createElementNS(G,J);for(let U of Array.from(W.attributes)){if(U.namespaceURI){j.setAttributeNS(U.namespaceURI,U.name,U.value);continue}n(j,U.name,U.value)}return j.append(...W.childNodes),j}";
16
+ const JSX_RUNTIME_NAMESPACE_REPAIR_PATCH = [
17
+ "const eopHtmlNamespace='http://www.w3.org/1999/xhtml',eopSvgNamespace='http://www.w3.org/2000/svg',eopCanonicalSvgLocalNames={altglyph:'altGlyph',altglyphdef:'altGlyphDef',altglyphitem:'altGlyphItem',animatemotion:'animateMotion',animatetransform:'animateTransform',clippath:'clipPath',feblend:'feBlend',fecolormatrix:'feColorMatrix',fecomponenttransfer:'feComponentTransfer',fecomposite:'feComposite',feconvolvematrix:'feConvolveMatrix',fediffuselighting:'feDiffuseLighting',fedisplacementmap:'feDisplacementMap',fedistantlight:'feDistantLight',fedropshadow:'feDropShadow',feflood:'feFlood',fefunca:'feFuncA',fefuncb:'feFuncB',fefuncg:'feFuncG',fefuncr:'feFuncR',fegaussianblur:'feGaussianBlur',feimage:'feImage',femerge:'feMerge',femergenode:'feMergeNode',femorphology:'feMorphology',feoffset:'feOffset',fepointlight:'fePointLight',fespecularlighting:'feSpecularLighting',fespotlight:'feSpotLight',fetile:'feTile',feturbulence:'feTurbulence',foreignobject:'foreignObject',glyphref:'glyphRef',lineargradient:'linearGradient',radialgradient:'radialGradient',textpath:'textPath'};",
18
+ "function eopGetCanonicalSvgLocalName(W){return eopCanonicalSvgLocalNames[W]??W}",
19
+ "function eopIsSvgNamespace(W){return W===eopSvgNamespace}",
20
+ "function rG(W,G,J){let j=G instanceof Element?G:G?.parentElement,U=j?.namespaceURI??K9,$=j?.localName;eopRepairNamespaceFragment(W,U??eopHtmlNamespace,$,J)}",
21
+ "function eopRepairNamespaceFragment(W,G,J,j){let U=W.firstElementChild;if(!U)return;let $=j??U.localName,X=O9(G,J,$),F=eopIsSvgNamespace(X)?eopGetCanonicalSvgLocalName($):$;eopRepairNamespaceElement(W,U,X,F)}",
22
+ "function eopRepairNamespaceElement(W,G,J,j){let U=G;if(G.namespaceURI!==J||G.localName!==j)U=tG(G,J,j),W.replaceChild(U,G);eopRepairNamespaceChildren(U,J,j)}",
23
+ "function eopRepairNamespaceChildren(W,G,J){for(let j of Array.from(W.children)){let U=O9(G,J,j.localName),$=eopIsSvgNamespace(U)?eopGetCanonicalSvgLocalName(j.localName):j.localName,X=j;if(j.namespaceURI!==U||j.localName!==$)X=tG(j,U,$),W.replaceChild(X,j);eopRepairNamespaceChildren(X,U,$)}}",
24
+ "function tG(W,G,J){let j=document.createElementNS(G,eopIsSvgNamespace(G)?eopGetCanonicalSvgLocalName(J):J);for(let U of Array.from(W.attributes)){if(U.namespaceURI){j.setAttributeNS(U.namespaceURI,U.name,U.value);continue}n(j,U.name,U.value)}return j.append(...W.childNodes),j}"
25
+ ].join("");
15
26
  function getNamedExportNamesFromModuleSource(source) {
16
27
  const exportNames = /* @__PURE__ */ new Set();
17
28
  for (const match of source.matchAll(/export\s*\{([^}]+)\}/g)) {
@@ -47,6 +58,20 @@ function isBrowserRuntimeRadiantSpecifier(exportKey) {
47
58
  }
48
59
  return exportKey === "./core/radiant-component" || exportKey === "./core/radiant-element";
49
60
  }
61
+ function replaceExactOnce(source, search, replacement, label) {
62
+ if (!source.includes(search)) {
63
+ throw new Error(`Could not find ${label} in @ecopages/jsx browser runtime source`);
64
+ }
65
+ return source.replace(search, replacement);
66
+ }
67
+ function createPatchedJsxBrowserRuntimeSource(source) {
68
+ return replaceExactOnce(
69
+ source,
70
+ JSX_RUNTIME_NAMESPACE_REPAIR_SNIPPET,
71
+ JSX_RUNTIME_NAMESPACE_REPAIR_PATCH,
72
+ "SVG namespace repair snippet"
73
+ );
74
+ }
50
75
  function findPackageManifestPath(packageName) {
51
76
  let currentDir = path.dirname(new URL(import.meta.url).pathname);
52
77
  while (true) {
@@ -200,9 +225,9 @@ class JsxRuntimeBundleService {
200
225
  ".",
201
226
  jsxPkg.exports?.["."]
202
227
  );
203
- const entryImportPath = this.getEntryImportPath(artifactsDir, jsxModulePath);
228
+ const patchedRuntimeSource = createPatchedJsxBrowserRuntimeSource(readFileSync(jsxModulePath, "utf8"));
204
229
  mkdirSync(artifactsDir, { recursive: true });
205
- writeFileSync(filePath, [`export * from '${entryImportPath}';`].join("\n"), "utf8");
230
+ writeFileSync(filePath, patchedRuntimeSource, "utf8");
206
231
  this.cachedJsxEntryModulePath = filePath;
207
232
  return filePath;
208
233
  }