@aerobuilt/core 0.2.4 → 0.2.6
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/README.md +2 -2
- package/dist/types.d.ts +1 -1
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.js +41 -17
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -65,7 +65,7 @@ const html = await aero.render('index', { props: { title: 'Home' } })
|
|
|
65
65
|
|
|
66
66
|
### Vite plugin
|
|
67
67
|
|
|
68
|
-
- **Plugin** from `aerobuilt/vite`: `aero(options?)`. Options: `
|
|
68
|
+
- **Plugin** from `aerobuilt/vite`: `aero(options?)`. Options: `server`, `apiPrefix`, `dirs`, `site` (canonical URL; exposed as `import.meta.env.SITE` and `Aero.site`; when set, generates `dist/sitemap.xml` after build).
|
|
69
69
|
- Sub-plugins: config resolution, virtual client modules (`\0`-prefixed), HTML transform, SSR middleware, HMR.
|
|
70
70
|
- Build: page discovery, static render, optional Nitro build, optional image optimizer (sharp/svgo).
|
|
71
71
|
|
|
@@ -74,7 +74,7 @@ const html = await aero.render('index', { props: { title: 'Home' } })
|
|
|
74
74
|
```js
|
|
75
75
|
import { aero } from 'aerobuilt/vite'
|
|
76
76
|
export default {
|
|
77
|
-
plugins: [aero({
|
|
77
|
+
plugins: [aero({ server: true })],
|
|
78
78
|
}
|
|
79
79
|
```
|
|
80
80
|
|
package/dist/types.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ interface RedirectRule {
|
|
|
22
22
|
}
|
|
23
23
|
interface AeroOptions {
|
|
24
24
|
/** Enable Nitro server integration (default: `false`). */
|
|
25
|
-
|
|
25
|
+
server?: boolean;
|
|
26
26
|
/** API route prefix (default: `'/api'`). */
|
|
27
27
|
apiPrefix?: string;
|
|
28
28
|
/** Directory overrides. */
|
package/dist/vite/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ import { PluginOption } from 'vite';
|
|
|
15
15
|
* HMR for templates and content is handled by Vite's dependency graph when the app uses a single
|
|
16
16
|
* client entry that imports @aerobuilt/core and calls aero.mount().
|
|
17
17
|
*
|
|
18
|
-
* @param options - AeroOptions (
|
|
18
|
+
* @param options - AeroOptions (server, apiPrefix, dirs). Server can be disabled at runtime via AERO_SERVER=false.
|
|
19
19
|
* @returns PluginOption[] to pass to Vite's plugins array.
|
|
20
20
|
*/
|
|
21
21
|
declare function aero(options?: AeroOptions): PluginOption[];
|
package/dist/vite/index.js
CHANGED
|
@@ -283,6 +283,19 @@ function parse(html) {
|
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
// src/compiler/helpers.ts
|
|
286
|
+
function validateSingleBracedExpression(value, options = {}) {
|
|
287
|
+
const trimmed = value.trim();
|
|
288
|
+
const segments = tokenizeCurlyInterpolation(trimmed, { attributeMode: true });
|
|
289
|
+
const ok = segments.length === 1 && segments[0].kind === "interpolation" && segments[0].start === 0 && segments[0].end === trimmed.length;
|
|
290
|
+
if (!ok) {
|
|
291
|
+
const directive = options.directive ?? "directive";
|
|
292
|
+
const tagName = options.tagName ?? "element";
|
|
293
|
+
throw new Error(
|
|
294
|
+
`Directive \`${directive}\` on <${tagName}> must use a braced expression, e.g. ${directive}="{ expression }".`
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
return trimmed;
|
|
298
|
+
}
|
|
286
299
|
function compileInterpolation(text) {
|
|
287
300
|
if (!text) return "";
|
|
288
301
|
const segments = tokenizeCurlyInterpolation(text, { attributeMode: false });
|
|
@@ -592,7 +605,17 @@ var Lowerer = class {
|
|
|
592
605
|
}
|
|
593
606
|
return null;
|
|
594
607
|
}
|
|
595
|
-
|
|
608
|
+
/**
|
|
609
|
+
* Require directive value to be a braced expression; optionally strip outer braces.
|
|
610
|
+
*
|
|
611
|
+
* @param value - Raw attribute value.
|
|
612
|
+
* @param directive - Attribute name for error message (e.g. `each`, `pass:data`).
|
|
613
|
+
* @param node - DOM node for error message (tag name).
|
|
614
|
+
* @param options - `strip: true` (default) returns inner expression; `strip: false` returns trimmed value including braces (e.g. for pass:data).
|
|
615
|
+
* @returns Trimmed value, with or without outer braces per options.
|
|
616
|
+
*/
|
|
617
|
+
requireBracedExpression(value, directive, node, options) {
|
|
618
|
+
const strip = options?.strip !== false;
|
|
596
619
|
const trimmed = value.trim();
|
|
597
620
|
if (!trimmed.startsWith("{") || !trimmed.endsWith("}")) {
|
|
598
621
|
const tagName = node?.tagName?.toLowerCase?.() || "element";
|
|
@@ -600,7 +623,7 @@ var Lowerer = class {
|
|
|
600
623
|
`Directive \`${directive}\` on <${tagName}> must use a braced expression, e.g. ${directive}="{ expression }".`
|
|
601
624
|
);
|
|
602
625
|
}
|
|
603
|
-
return stripBraces(trimmed);
|
|
626
|
+
return strip ? stripBraces(trimmed) : trimmed;
|
|
604
627
|
}
|
|
605
628
|
isSingleWrappedExpression(value) {
|
|
606
629
|
const trimmed = value.trim();
|
|
@@ -680,7 +703,10 @@ var Lowerer = class {
|
|
|
680
703
|
if (isAttr(attr.name, ATTR_ELSE_IF, ATTR_PREFIX)) continue;
|
|
681
704
|
if (isAttr(attr.name, ATTR_ELSE, ATTR_PREFIX)) continue;
|
|
682
705
|
if (isAttr(attr.name, ATTR_PASS_DATA, ATTR_PREFIX)) {
|
|
683
|
-
passDataExpr =
|
|
706
|
+
passDataExpr = validateSingleBracedExpression(attr.value || "", {
|
|
707
|
+
directive: attr.name,
|
|
708
|
+
tagName: node?.tagName?.toLowerCase?.() || "element"
|
|
709
|
+
});
|
|
684
710
|
continue;
|
|
685
711
|
}
|
|
686
712
|
if (attr.name === ATTR_IS_INLINE) {
|
|
@@ -1009,7 +1035,7 @@ function compile(parsed, options) {
|
|
|
1009
1035
|
const tagExpr = `'<script ${baseAttrsEscaped} src="'+${urlExpr}+'"></script>'`;
|
|
1010
1036
|
const isHead = clientScript.injectInHead;
|
|
1011
1037
|
if (clientScript.passDataExpr) {
|
|
1012
|
-
const jsonExpr = `JSON.stringify(${
|
|
1038
|
+
const jsonExpr = `JSON.stringify(${clientScript.passDataExpr})`;
|
|
1013
1039
|
if (isHead) {
|
|
1014
1040
|
headScripts.push(
|
|
1015
1041
|
`(function(){const __pid=Aero.nextPassDataId();\`<\`+'script type="application/json" id="'+__pid+'" class="__aero_data">'+${jsonExpr}+'</'+'script>';window.__aero_data_next=JSON.parse(document.getElementById("'+__pid+'").textContent);})();${tagExpr}`
|
|
@@ -1031,13 +1057,11 @@ function compile(parsed, options) {
|
|
|
1031
1057
|
if (options.blockingScripts) {
|
|
1032
1058
|
for (const blockingScript of options.blockingScripts) {
|
|
1033
1059
|
if (blockingScript.passDataExpr) {
|
|
1034
|
-
const
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
}
|
|
1040
|
-
const jsMapExpr = `Object.entries(${stripBraces(blockingScript.passDataExpr)}).map(([k, v]) => "\\nconst " + k + " = " + JSON.stringify(v) + ";").join("")`;
|
|
1060
|
+
const passDataExpr = validateSingleBracedExpression(blockingScript.passDataExpr, {
|
|
1061
|
+
directive: "pass:data",
|
|
1062
|
+
tagName: "script"
|
|
1063
|
+
});
|
|
1064
|
+
const jsMapExpr = `Object.entries(${passDataExpr}).map(([k, v]) => "\\nconst " + k + " = " + JSON.stringify(v) + ";").join("")`;
|
|
1041
1065
|
headScripts.push(
|
|
1042
1066
|
`\`<script${blockingScript.attrs ? " " + blockingScript.attrs : ""}>\${${jsMapExpr}}${blockingScript.content.replace(/`/g, "\\`")}</script>\``
|
|
1043
1067
|
);
|
|
@@ -1381,8 +1405,8 @@ async function renderStaticPages(options, outDir) {
|
|
|
1381
1405
|
const discoveredPages = discoverPages(root, path3.join(dirs.client, "pages"));
|
|
1382
1406
|
const distDir = path3.resolve(root, outDir);
|
|
1383
1407
|
const manifest = readManifest(distDir);
|
|
1384
|
-
const
|
|
1385
|
-
process.env.
|
|
1408
|
+
const previousAeroServer = process.env.AERO_SERVER;
|
|
1409
|
+
process.env.AERO_SERVER = "false";
|
|
1386
1410
|
const staticCacheDir = path3.join(root, ".aero", "vite-ssr");
|
|
1387
1411
|
const server = await createServer({
|
|
1388
1412
|
configFile: false,
|
|
@@ -1481,10 +1505,10 @@ async function renderStaticPages(options, outDir) {
|
|
|
1481
1505
|
}
|
|
1482
1506
|
} finally {
|
|
1483
1507
|
await server.close();
|
|
1484
|
-
if (
|
|
1485
|
-
delete process.env.
|
|
1508
|
+
if (previousAeroServer === void 0) {
|
|
1509
|
+
delete process.env.AERO_SERVER;
|
|
1486
1510
|
} else {
|
|
1487
|
-
process.env.
|
|
1511
|
+
process.env.AERO_SERVER = previousAeroServer;
|
|
1488
1512
|
}
|
|
1489
1513
|
}
|
|
1490
1514
|
}
|
|
@@ -1852,7 +1876,7 @@ function createAeroSsrPlugin(state) {
|
|
|
1852
1876
|
function aero(options = {}) {
|
|
1853
1877
|
const dirs = resolveDirs(options.dirs);
|
|
1854
1878
|
const apiPrefix = options.apiPrefix || DEFAULT_API_PREFIX;
|
|
1855
|
-
const enableNitro = options.
|
|
1879
|
+
const enableNitro = options.server === true && process.env.AERO_SERVER !== "false";
|
|
1856
1880
|
const runtimeInstanceJsPath = fileURLToPath(
|
|
1857
1881
|
new URL("../runtime/instance.js", import.meta.url)
|
|
1858
1882
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aerobuilt/core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Jamie Wilson",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"sharp": "^0.34.5",
|
|
56
56
|
"svgo": "^4.0.0",
|
|
57
57
|
"vite-plugin-image-optimizer": "^2.0.3",
|
|
58
|
-
"@aerobuilt/interpolation": "0.2.
|
|
58
|
+
"@aerobuilt/interpolation": "0.2.6"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"vite": "^8.0.0-0"
|