@jxsuite/compiler 0.23.1 → 0.23.2
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/package.json +3 -3
- package/src/site/content-loader.js +2 -4
- package/src/site/site-build.js +19 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jxsuite/compiler",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.2",
|
|
4
4
|
"description": "Jx static HTML compiler, island detector, and site builder",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@apidevtools/json-schema-ref-parser": "^15.3.5",
|
|
41
|
-
"@jxsuite/parser": "^0.23.
|
|
42
|
-
"@jxsuite/runtime": "^0.23.
|
|
41
|
+
"@jxsuite/parser": "^0.23.2",
|
|
42
|
+
"@jxsuite/runtime": "^0.23.2",
|
|
43
43
|
"remark-gfm": "^4.0.1",
|
|
44
44
|
"remark-stringify": "^11.0.0",
|
|
45
45
|
"sharp": "^0.34.5",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @module content-loader
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import { readFileSync, readdirSync, existsSync
|
|
12
|
+
import { readFileSync, readdirSync, existsSync } from "node:fs";
|
|
13
13
|
import { resolve, basename, extname } from "node:path";
|
|
14
14
|
|
|
15
15
|
// ─── CSV Parser (minimal, spec-compliant) ─────────────────────────────────────
|
|
@@ -291,9 +291,7 @@ async function loadContentType(name, contentTypeDef, projectRoot) {
|
|
|
291
291
|
/** @type {string[]} */
|
|
292
292
|
let files;
|
|
293
293
|
|
|
294
|
-
if (
|
|
295
|
-
files = globSync(source, { cwd: projectRoot }).map((f) => resolve(projectRoot, f));
|
|
296
|
-
} else if (extname(source)) {
|
|
294
|
+
if (extname(source)) {
|
|
297
295
|
files = existsSync(resolvedSource) ? [resolvedSource] : [];
|
|
298
296
|
} else {
|
|
299
297
|
const format = contentTypeDef.format || "md";
|
package/src/site/site-build.js
CHANGED
|
@@ -598,19 +598,21 @@ function expandMapTemplate(template, scope) {
|
|
|
598
598
|
return expandMapTemplate(/** @type {JxMutableNode} */ (child), scope);
|
|
599
599
|
});
|
|
600
600
|
} else if (k === "style" && v && typeof v === "object") {
|
|
601
|
-
|
|
602
|
-
for (const [sk, sv] of Object.entries(
|
|
601
|
+
const style = /** @type {Record<string, unknown>} */ ({ ...v });
|
|
602
|
+
for (const [sk, sv] of Object.entries(style)) {
|
|
603
603
|
if (typeof sv === "string" && isTemplateString(sv)) {
|
|
604
|
-
|
|
604
|
+
style[sk] = evaluateMapTemplate(sv, scope) ?? sv;
|
|
605
605
|
}
|
|
606
606
|
}
|
|
607
|
+
node.style = style;
|
|
607
608
|
} else if (k === "attributes" && v && typeof v === "object") {
|
|
608
|
-
|
|
609
|
-
for (const [ak, av] of Object.entries(
|
|
609
|
+
const attrs = /** @type {Record<string, unknown>} */ ({ ...v });
|
|
610
|
+
for (const [ak, av] of Object.entries(attrs)) {
|
|
610
611
|
if (typeof av === "string" && isTemplateString(av)) {
|
|
611
|
-
|
|
612
|
+
attrs[ak] = evaluateMapTemplate(av, scope) ?? av;
|
|
612
613
|
}
|
|
613
614
|
}
|
|
615
|
+
node.attributes = attrs;
|
|
614
616
|
} else if (typeof v === "string" && isTemplateString(v)) {
|
|
615
617
|
node[k] = evaluateMapTemplate(v, scope) ?? v;
|
|
616
618
|
} else {
|
|
@@ -701,15 +703,17 @@ function resolveDocTemplates(node, scope) {
|
|
|
701
703
|
items = itemsSrc;
|
|
702
704
|
}
|
|
703
705
|
if (Array.isArray(items) && arrayDef.map) {
|
|
704
|
-
node.children =
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
706
|
+
node.children = /** @type {(string | JxElement)[]} */ (
|
|
707
|
+
items.map((item, index) => {
|
|
708
|
+
const childScope = Object.create(scope);
|
|
709
|
+
childScope.$map = { item, index };
|
|
710
|
+
childScope["$map/item"] = item;
|
|
711
|
+
childScope["$map/index"] = index;
|
|
712
|
+
const expanded = expandMapTemplate(arrayDef.map, childScope);
|
|
713
|
+
resolveDocTemplates(/** @type {JxElement} */ (expanded), childScope);
|
|
714
|
+
return expanded;
|
|
715
|
+
})
|
|
716
|
+
);
|
|
713
717
|
return;
|
|
714
718
|
}
|
|
715
719
|
}
|