@aerobuilt/core 0.2.9 → 0.3.0
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/dist/build-script-analysis-Bd9EyItC.mjs +193 -0
- package/dist/{entry-dev.d.ts → entry-dev.d.mts} +6 -16
- package/dist/entry-dev.mjs +127 -0
- package/dist/{entry-editor.d.ts → entry-editor.d.mts} +24 -22
- package/dist/entry-editor.mjs +3 -0
- package/dist/entry-prod.d.mts +10 -0
- package/dist/entry-prod.mjs +15 -0
- package/dist/routing-Bai79LCq.mjs +198 -0
- package/dist/runtime/index.d.mts +65 -0
- package/dist/runtime/index.mjs +207 -0
- package/dist/runtime/instance.d.mts +19 -0
- package/dist/runtime/instance.mjs +45 -0
- package/dist/types-CLHGhnGA.d.mts +209 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +1 -0
- package/dist/utils/aliases.d.mts +38 -0
- package/dist/utils/aliases.mjs +117 -0
- package/dist/utils/{redirects.d.ts → redirects.d.mts} +7 -12
- package/dist/utils/redirects.mjs +21 -0
- package/dist/vite/{index.d.ts → index.d.mts} +5 -12
- package/dist/vite/index.mjs +1890 -0
- package/package.json +25 -20
- package/dist/chunk-4DAK56WB.js +0 -36
- package/dist/chunk-5ZNUGZOW.js +0 -238
- package/dist/chunk-F7MXQXLM.js +0 -15
- package/dist/chunk-JAMYN2VX.js +0 -133
- package/dist/chunk-VTEG2UU3.js +0 -184
- package/dist/entry-dev.js +0 -101
- package/dist/entry-editor.js +0 -14
- package/dist/entry-prod.d.ts +0 -19
- package/dist/entry-prod.js +0 -19
- package/dist/runtime/index.d.ts +0 -74
- package/dist/runtime/index.js +0 -7
- package/dist/runtime/instance.d.ts +0 -31
- package/dist/runtime/instance.js +0 -10
- package/dist/types.d.ts +0 -202
- package/dist/types.js +0 -0
- package/dist/utils/redirects.js +0 -6
- package/dist/vite/index.js +0 -1991
package/dist/chunk-VTEG2UU3.js
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
// src/compiler/tokenizer.ts
|
|
2
|
-
import {
|
|
3
|
-
tokenizeCurlyInterpolation,
|
|
4
|
-
compileInterpolationFromSegments
|
|
5
|
-
} from "@aerobuilt/interpolation";
|
|
6
|
-
|
|
7
|
-
// src/compiler/directive-attributes.ts
|
|
8
|
-
var DEFAULT_DIRECTIVE_PREFIXES = ["x-", "@", ":", "."];
|
|
9
|
-
var defaultConfig = {
|
|
10
|
-
prefixes: DEFAULT_DIRECTIVE_PREFIXES,
|
|
11
|
-
exactNames: []
|
|
12
|
-
};
|
|
13
|
-
function isDirectiveAttr(attrName, config = defaultConfig) {
|
|
14
|
-
const prefixes = config.prefixes ?? defaultConfig.prefixes;
|
|
15
|
-
const exactNames = config.exactNames ?? defaultConfig.exactNames;
|
|
16
|
-
if (exactNames.includes(attrName)) return true;
|
|
17
|
-
return prefixes.some((p) => attrName.startsWith(p));
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// src/compiler/build-script-analysis.ts
|
|
21
|
-
import { parseSync, ImportNameKind } from "oxc-parser";
|
|
22
|
-
var BUILD_SCRIPT_FILENAME = "build.ts";
|
|
23
|
-
function analyzeBuildScript(script) {
|
|
24
|
-
if (!script.trim()) {
|
|
25
|
-
return {
|
|
26
|
-
imports: [],
|
|
27
|
-
getStaticPathsFn: null,
|
|
28
|
-
scriptWithoutImportsAndGetStaticPaths: script
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
const result = parseSync(BUILD_SCRIPT_FILENAME, script, {
|
|
32
|
-
sourceType: "module",
|
|
33
|
-
range: true,
|
|
34
|
-
lang: "ts"
|
|
35
|
-
});
|
|
36
|
-
const errors = result.errors;
|
|
37
|
-
if (errors.length > 0) {
|
|
38
|
-
const first = errors[0];
|
|
39
|
-
throw new Error(
|
|
40
|
-
`[aero] Build script parse error: ${first.message}${first.codeframe ? "\n" + first.codeframe : ""}`
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
const mod = result.module;
|
|
44
|
-
const program = result.program;
|
|
45
|
-
const imports = [];
|
|
46
|
-
for (const imp of mod.staticImports) {
|
|
47
|
-
const specifier = imp.moduleRequest.value;
|
|
48
|
-
let defaultBinding = null;
|
|
49
|
-
const namedBindings = [];
|
|
50
|
-
let namespaceBinding = null;
|
|
51
|
-
for (const entry of imp.entries) {
|
|
52
|
-
if (entry.isType) continue;
|
|
53
|
-
const local = entry.localName.value;
|
|
54
|
-
switch (entry.importName.kind) {
|
|
55
|
-
case ImportNameKind.Default:
|
|
56
|
-
defaultBinding = local;
|
|
57
|
-
break;
|
|
58
|
-
case ImportNameKind.NamespaceObject:
|
|
59
|
-
namespaceBinding = local;
|
|
60
|
-
break;
|
|
61
|
-
case ImportNameKind.Name: {
|
|
62
|
-
const imported = entry.importName.name ?? local;
|
|
63
|
-
namedBindings.push({ imported, local });
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
default:
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
imports.push({
|
|
71
|
-
specifier,
|
|
72
|
-
defaultBinding,
|
|
73
|
-
namedBindings,
|
|
74
|
-
namespaceBinding
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
let getStaticPathsRange = null;
|
|
78
|
-
const body = program.body;
|
|
79
|
-
if (body) {
|
|
80
|
-
for (const stmt of body) {
|
|
81
|
-
if (stmt.type !== "ExportNamedDeclaration") continue;
|
|
82
|
-
const decl = stmt.declaration;
|
|
83
|
-
if (!decl || decl.type !== "FunctionDeclaration") continue;
|
|
84
|
-
const name = decl.id?.name;
|
|
85
|
-
if (name !== "getStaticPaths") continue;
|
|
86
|
-
const range = stmt.range;
|
|
87
|
-
if (range) {
|
|
88
|
-
getStaticPathsRange = range;
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
const getStaticPathsFn = getStaticPathsRange !== null ? script.slice(getStaticPathsRange[0], getStaticPathsRange[1]) : null;
|
|
94
|
-
const rangesToRemove = [];
|
|
95
|
-
if (getStaticPathsRange) {
|
|
96
|
-
rangesToRemove.push(getStaticPathsRange);
|
|
97
|
-
}
|
|
98
|
-
for (const imp of mod.staticImports) {
|
|
99
|
-
rangesToRemove.push([imp.start, imp.end]);
|
|
100
|
-
}
|
|
101
|
-
rangesToRemove.sort((a, b) => a[0] - b[0]);
|
|
102
|
-
const parts = [];
|
|
103
|
-
let lastEnd = 0;
|
|
104
|
-
for (const [start, end] of rangesToRemove) {
|
|
105
|
-
if (start > lastEnd) {
|
|
106
|
-
parts.push(script.slice(lastEnd, start));
|
|
107
|
-
}
|
|
108
|
-
lastEnd = end;
|
|
109
|
-
}
|
|
110
|
-
if (lastEnd < script.length) {
|
|
111
|
-
parts.push(script.slice(lastEnd));
|
|
112
|
-
}
|
|
113
|
-
const scriptWithoutImportsAndGetStaticPaths = parts.join("").trim();
|
|
114
|
-
return {
|
|
115
|
-
imports,
|
|
116
|
-
getStaticPathsFn,
|
|
117
|
-
scriptWithoutImportsAndGetStaticPaths
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
function analyzeBuildScriptForEditor(script) {
|
|
121
|
-
if (!script.trim()) {
|
|
122
|
-
return { imports: [] };
|
|
123
|
-
}
|
|
124
|
-
const result = parseSync(BUILD_SCRIPT_FILENAME, script, {
|
|
125
|
-
sourceType: "module",
|
|
126
|
-
range: true,
|
|
127
|
-
lang: "ts"
|
|
128
|
-
});
|
|
129
|
-
const errors = result.errors;
|
|
130
|
-
if (errors.length > 0) {
|
|
131
|
-
const first = errors[0];
|
|
132
|
-
throw new Error(
|
|
133
|
-
`[aero] Build script parse error: ${first.message}${first.codeframe ? "\n" + first.codeframe : ""}`
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
const mod = result.module;
|
|
137
|
-
const imports = [];
|
|
138
|
-
for (const imp of mod.staticImports) {
|
|
139
|
-
const specifier = imp.moduleRequest.value;
|
|
140
|
-
let defaultBinding = null;
|
|
141
|
-
const namedBindings = [];
|
|
142
|
-
let namespaceBinding = null;
|
|
143
|
-
const bindingRanges = {};
|
|
144
|
-
for (const entry of imp.entries) {
|
|
145
|
-
if (entry.isType) continue;
|
|
146
|
-
const local = entry.localName.value;
|
|
147
|
-
bindingRanges[local] = [entry.localName.start, entry.localName.end];
|
|
148
|
-
switch (entry.importName.kind) {
|
|
149
|
-
case ImportNameKind.Default:
|
|
150
|
-
defaultBinding = local;
|
|
151
|
-
break;
|
|
152
|
-
case ImportNameKind.NamespaceObject:
|
|
153
|
-
namespaceBinding = local;
|
|
154
|
-
break;
|
|
155
|
-
case ImportNameKind.Name: {
|
|
156
|
-
const imported = entry.importName.name ?? local;
|
|
157
|
-
namedBindings.push({ imported, local });
|
|
158
|
-
break;
|
|
159
|
-
}
|
|
160
|
-
default:
|
|
161
|
-
break;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
imports.push({
|
|
165
|
-
specifier,
|
|
166
|
-
defaultBinding,
|
|
167
|
-
namedBindings,
|
|
168
|
-
namespaceBinding,
|
|
169
|
-
range: [imp.start, imp.end],
|
|
170
|
-
specifierRange: [imp.moduleRequest.start, imp.moduleRequest.end],
|
|
171
|
-
bindingRanges
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
return { imports };
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
export {
|
|
178
|
-
tokenizeCurlyInterpolation,
|
|
179
|
-
compileInterpolationFromSegments,
|
|
180
|
-
DEFAULT_DIRECTIVE_PREFIXES,
|
|
181
|
-
isDirectiveAttr,
|
|
182
|
-
analyzeBuildScript,
|
|
183
|
-
analyzeBuildScriptForEditor
|
|
184
|
-
};
|
package/dist/entry-dev.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
aero,
|
|
3
|
-
onUpdate
|
|
4
|
-
} from "./chunk-4DAK56WB.js";
|
|
5
|
-
import "./chunk-5ZNUGZOW.js";
|
|
6
|
-
import {
|
|
7
|
-
resolvePageName
|
|
8
|
-
} from "./chunk-JAMYN2VX.js";
|
|
9
|
-
|
|
10
|
-
// src/runtime/client.ts
|
|
11
|
-
function extractDocumentParts(html) {
|
|
12
|
-
const parser = new DOMParser();
|
|
13
|
-
const doc = parser.parseFromString(html, "text/html");
|
|
14
|
-
const head = doc.head?.innerHTML?.trim() || "";
|
|
15
|
-
const body = doc.body?.innerHTML ?? html;
|
|
16
|
-
return { head, body };
|
|
17
|
-
}
|
|
18
|
-
var rendering = false;
|
|
19
|
-
var PERSISTENT_SELECTORS = [
|
|
20
|
-
'script[src*="/@vite/client"]',
|
|
21
|
-
"[data-vite-dev-id]"
|
|
22
|
-
].join(", ");
|
|
23
|
-
function updateHead(headContent) {
|
|
24
|
-
const headEl = document.head;
|
|
25
|
-
const queriedNodes = headEl.querySelectorAll(PERSISTENT_SELECTORS);
|
|
26
|
-
const persistentSet = new Set(Array.from(queriedNodes));
|
|
27
|
-
for (const node of Array.from(headEl.children)) {
|
|
28
|
-
if (persistentSet.has(node)) continue;
|
|
29
|
-
headEl.removeChild(node);
|
|
30
|
-
}
|
|
31
|
-
const parser = new DOMParser();
|
|
32
|
-
const frag = parser.parseFromString(`<head>${headContent}</head>`, "text/html");
|
|
33
|
-
const nodes = Array.from(frag.head?.childNodes || []);
|
|
34
|
-
for (const node of nodes) {
|
|
35
|
-
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
36
|
-
const el = node;
|
|
37
|
-
if (el.matches(PERSISTENT_SELECTORS)) {
|
|
38
|
-
const devId = el.getAttribute("data-vite-dev-id");
|
|
39
|
-
if (devId && headEl.querySelector(`[data-vite-dev-id="${devId}"]`)) continue;
|
|
40
|
-
if (el instanceof HTMLScriptElement && el.src && headEl.querySelector(`script[src="${el.src}"]`)) {
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
headEl.appendChild(document.importNode(node, true));
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
var DOCS_PATH_PREFIX = "/docs";
|
|
49
|
-
async function renderPage(appEl, renderFn) {
|
|
50
|
-
if (rendering) return;
|
|
51
|
-
rendering = true;
|
|
52
|
-
const pathname = window.location.pathname;
|
|
53
|
-
const pageName = resolvePageName(pathname);
|
|
54
|
-
try {
|
|
55
|
-
let html;
|
|
56
|
-
const useFetch = typeof window !== "undefined" && (pathname === DOCS_PATH_PREFIX || pathname.startsWith(DOCS_PATH_PREFIX + "/")) && import.meta.hot;
|
|
57
|
-
if (useFetch) {
|
|
58
|
-
const res = await fetch(pathname, { headers: { Accept: "text/html" } });
|
|
59
|
-
if (!res.ok) throw new Error(`Fetch failed: ${res.status}`);
|
|
60
|
-
html = await res.text();
|
|
61
|
-
} else {
|
|
62
|
-
html = await renderFn(pageName);
|
|
63
|
-
}
|
|
64
|
-
const { head, body } = extractDocumentParts(html);
|
|
65
|
-
if (head) updateHead(head);
|
|
66
|
-
appEl.innerHTML = body;
|
|
67
|
-
} catch (err) {
|
|
68
|
-
appEl.innerHTML = `<h1>Error rendering page: ${pageName}</h1><pre>${String(err)}</pre>`;
|
|
69
|
-
console.error("[aero] Render Error:", err);
|
|
70
|
-
} finally {
|
|
71
|
-
rendering = false;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// src/entry-dev.ts
|
|
76
|
-
var coreRender = aero.render.bind(aero);
|
|
77
|
-
var hmrState = { lastEl: null, unsubscribe: null };
|
|
78
|
-
function mount(options = {}) {
|
|
79
|
-
const { target = "#app", onRender } = options;
|
|
80
|
-
const el = typeof target === "string" ? document.querySelector(target) : target;
|
|
81
|
-
if (!el) throw new Error("Target element not found: " + target);
|
|
82
|
-
hmrState.lastEl = el;
|
|
83
|
-
if (onRender) onRender(el);
|
|
84
|
-
const done = Promise.resolve();
|
|
85
|
-
if (import.meta.hot && !hmrState.unsubscribe) {
|
|
86
|
-
hmrState.unsubscribe = onUpdate(() => {
|
|
87
|
-
const el2 = hmrState.lastEl;
|
|
88
|
-
if (el2) {
|
|
89
|
-
void renderPage(el2, coreRender).then(() => {
|
|
90
|
-
if (onRender) onRender(el2);
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
return done;
|
|
96
|
-
}
|
|
97
|
-
aero.mount = mount;
|
|
98
|
-
var entry_dev_default = aero;
|
|
99
|
-
export {
|
|
100
|
-
entry_dev_default as default
|
|
101
|
-
};
|
package/dist/entry-editor.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DEFAULT_DIRECTIVE_PREFIXES,
|
|
3
|
-
analyzeBuildScriptForEditor,
|
|
4
|
-
compileInterpolationFromSegments,
|
|
5
|
-
isDirectiveAttr,
|
|
6
|
-
tokenizeCurlyInterpolation
|
|
7
|
-
} from "./chunk-VTEG2UU3.js";
|
|
8
|
-
export {
|
|
9
|
-
DEFAULT_DIRECTIVE_PREFIXES,
|
|
10
|
-
analyzeBuildScriptForEditor,
|
|
11
|
-
compileInterpolationFromSegments,
|
|
12
|
-
isDirectiveAttr,
|
|
13
|
-
tokenizeCurlyInterpolation
|
|
14
|
-
};
|
package/dist/entry-prod.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { MountOptions } from './types.js';
|
|
2
|
-
import { Aero } from './runtime/index.js';
|
|
3
|
-
import 'vite';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Minimal client entry for static production builds.
|
|
7
|
-
*
|
|
8
|
-
* @remarks
|
|
9
|
-
* Does not import the runtime instance (no import.meta.glob of components/layouts/pages),
|
|
10
|
-
* so the production client bundle stays small: no template chunks, only mount + onRender.
|
|
11
|
-
* Use this when building for production; dev uses the full entry (entry-dev.ts) for HMR.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
declare function mount(options?: MountOptions): Promise<void>;
|
|
15
|
-
declare const _default: Aero & {
|
|
16
|
-
mount: typeof mount;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export { _default as default };
|
package/dist/entry-prod.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Aero
|
|
3
|
-
} from "./chunk-5ZNUGZOW.js";
|
|
4
|
-
import "./chunk-JAMYN2VX.js";
|
|
5
|
-
|
|
6
|
-
// src/entry-prod.ts
|
|
7
|
-
function mount(options = {}) {
|
|
8
|
-
const { target = "#app", onRender } = options;
|
|
9
|
-
const el = typeof target === "string" ? document.querySelector(target) : target;
|
|
10
|
-
if (!el) throw new Error("Target element not found: " + target);
|
|
11
|
-
if (onRender) onRender(el);
|
|
12
|
-
return Promise.resolve();
|
|
13
|
-
}
|
|
14
|
-
var aero = new Aero();
|
|
15
|
-
aero.mount = mount;
|
|
16
|
-
var entry_prod_default = aero;
|
|
17
|
-
export {
|
|
18
|
-
entry_prod_default as default
|
|
19
|
-
};
|
package/dist/runtime/index.d.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { MountOptions, AeroRenderInput } from '../types.js';
|
|
2
|
-
import 'vite';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Aero runtime: page registration, route resolution, and HTML rendering.
|
|
6
|
-
*
|
|
7
|
-
* @remarks
|
|
8
|
-
* The `Aero` class holds globals and a map of page/layout modules. `render()` resolves a page name
|
|
9
|
-
* (e.g. from `resolvePageName`), builds template context, and invokes the compiled render function.
|
|
10
|
-
* `mount` is optionally set by the client entry (`core/src/entry-dev.ts`).
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
declare class Aero {
|
|
14
|
-
/** Global values merged into template context (e.g. from content modules). */
|
|
15
|
-
private globals;
|
|
16
|
-
/** Map from page name (or path) to module. Keys include both canonical name and full path for lookup. */
|
|
17
|
-
private pagesMap;
|
|
18
|
-
/** Set by client entry when running in the browser; used to attach the app to a DOM root. */
|
|
19
|
-
mount?: (options?: MountOptions) => Promise<void>;
|
|
20
|
-
/**
|
|
21
|
-
* Register a global value available in all templates as `name`.
|
|
22
|
-
*
|
|
23
|
-
* @param name - Key used in templates (e.g. `site`).
|
|
24
|
-
* @param value - Any value (object, string, etc.).
|
|
25
|
-
*/
|
|
26
|
-
global(name: string, value: any): void;
|
|
27
|
-
/**
|
|
28
|
-
* Register page/layout modules from a Vite glob (e.g. `import.meta.glob('@pages/**\/*.html')`).
|
|
29
|
-
* Derives a lookup key from each path via pagePathToKey; also stores by full path for resolution.
|
|
30
|
-
*
|
|
31
|
-
* @param pages - Record of resolved path → module (default export is the render function).
|
|
32
|
-
*/
|
|
33
|
-
registerPages(pages: Record<string, any>): void;
|
|
34
|
-
/** Type guard: true if value looks like an `AeroRenderInput` (has at least one of props, slots, request, url, params, routePath). */
|
|
35
|
-
private isRenderInput;
|
|
36
|
-
/** Coerce various call signatures into a single `AeroRenderInput` (e.g. plain object → `{ props }`). */
|
|
37
|
-
private normalizeRenderInput;
|
|
38
|
-
/** Convert a page name to a route path (e.g. `index` → `'/'`, `about` → `'/about'`). */
|
|
39
|
-
private toRoutePath;
|
|
40
|
-
/** Build a URL from route path and optional raw URL. Uses `http://localhost` as base when only a path is given. */
|
|
41
|
-
private toURL;
|
|
42
|
-
/** Build template context: globals, props, slots, request, url, params, site, and `renderComponent` / `nextPassDataId`. */
|
|
43
|
-
private createContext;
|
|
44
|
-
/** True if entry params and request params have the same keys and stringified values. */
|
|
45
|
-
private paramsMatch;
|
|
46
|
-
/**
|
|
47
|
-
* Render a page or layout to HTML.
|
|
48
|
-
*
|
|
49
|
-
* @remarks
|
|
50
|
-
* Resolves `component` (page name string or module) via `pagesMap`, with fallbacks: directory index
|
|
51
|
-
* (`foo` → `foo/index`), `index` → `home`, dynamic routes, and trailing-slash stripping. If the module
|
|
52
|
-
* exports `getStaticPaths` and no props are provided, finds the matching static path and uses its props.
|
|
53
|
-
* For root-level renders, injects accumulated styles and scripts into the document and fixes content
|
|
54
|
-
* that ends up after `</html>` when using layouts (moves it into `</body>`).
|
|
55
|
-
*
|
|
56
|
-
* @param component - Page name (e.g. `'index'`, `'about'`) or the module object.
|
|
57
|
-
* @param input - Render input (props, request, url, params, etc.). Can be a plain object (treated as props).
|
|
58
|
-
* @returns HTML string, or `null` if the page is not found or no static path match.
|
|
59
|
-
*/
|
|
60
|
-
render(component: any, input?: any): Promise<any>;
|
|
61
|
-
/**
|
|
62
|
-
* Render a child component (layout or component) with the given props and slots.
|
|
63
|
-
* Used by compiled templates via context.renderComponent.
|
|
64
|
-
*
|
|
65
|
-
* @param component - Render function or module with `default` render function.
|
|
66
|
-
* @param props - Props object for the component.
|
|
67
|
-
* @param slots - Named slot content (key → HTML string).
|
|
68
|
-
* @param input - Optional request/url/params for context; `headScripts` is not passed through.
|
|
69
|
-
* @returns HTML string from the component's render function, or empty string if not invokable.
|
|
70
|
-
*/
|
|
71
|
-
renderComponent(component: any, props?: any, slots?: Record<string, string>, input?: AeroRenderInput): Promise<any>;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export { Aero };
|
package/dist/runtime/index.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Aero } from './index.js';
|
|
2
|
-
import '../types.js';
|
|
3
|
-
import 'vite';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Singleton Aero instance and HMR update subscription.
|
|
7
|
-
*
|
|
8
|
-
* @remarks
|
|
9
|
-
* Provides a single shared `Aero` instance and a listener set so the client entry can subscribe to
|
|
10
|
-
* "something changed" (e.g. template or glob updates). Uses `globalThis` so the instance survives
|
|
11
|
-
* Vite HMR re-execution. On load, runs Vite-specific `import.meta.glob` for pages, components, and
|
|
12
|
-
* layouts, registers them with the instance, then calls `notify()` so any existing subscribers
|
|
13
|
-
* (e.g. the client `mount()` HMR callback) can re-render. Only used in a Vite app context.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/** Global slot for the singleton Aero instance; used so HMR re-execution reuses the same instance. */
|
|
17
|
-
declare global {
|
|
18
|
-
var __AERO_INSTANCE__: Aero | undefined;
|
|
19
|
-
var __AERO_LISTENERS__: Set<() => void> | undefined;
|
|
20
|
-
}
|
|
21
|
-
declare const aero: Aero;
|
|
22
|
-
/**
|
|
23
|
-
* Subscribe to update notifications (e.g. after globs or templates change).
|
|
24
|
-
* Used by the client entry to re-render on HMR.
|
|
25
|
-
*
|
|
26
|
-
* @param cb - Callback invoked when `notify()` runs (e.g. after this module re-executes).
|
|
27
|
-
* @returns Unsubscribe function that removes `cb` from the listener set.
|
|
28
|
-
*/
|
|
29
|
-
declare const onUpdate: (cb: () => void) => () => boolean;
|
|
30
|
-
|
|
31
|
-
export { aero, onUpdate };
|
package/dist/runtime/instance.js
DELETED
package/dist/types.d.ts
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import * as vite from 'vite';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Shared type definitions for the Aero framework (compiler, runtime, Vite plugin).
|
|
5
|
-
*
|
|
6
|
-
* @remarks
|
|
7
|
-
* Grouped roughly by: config/dirs, compile/parse, resolver/aliases, routing, render context.
|
|
8
|
-
*/
|
|
9
|
-
interface AeroDirs {
|
|
10
|
-
/** Site source directory; pages live at `client/pages` (default: `'client'`). */
|
|
11
|
-
client?: string;
|
|
12
|
-
/** Nitro server directory (default: `'server'`). */
|
|
13
|
-
server?: string;
|
|
14
|
-
/** Build output directory (default: `'dist'`). */
|
|
15
|
-
dist?: string;
|
|
16
|
-
}
|
|
17
|
-
/** One redirect rule: from path to URL, optional status (default 302). */
|
|
18
|
-
interface RedirectRule {
|
|
19
|
-
from: string;
|
|
20
|
-
to: string;
|
|
21
|
-
status?: number;
|
|
22
|
-
}
|
|
23
|
-
interface AeroOptions {
|
|
24
|
-
/** Enable Nitro server integration (default: `false`). */
|
|
25
|
-
server?: boolean;
|
|
26
|
-
/** API route prefix (default: `'/api'`). */
|
|
27
|
-
apiPrefix?: string;
|
|
28
|
-
/** Directory overrides. */
|
|
29
|
-
dirs?: AeroDirs;
|
|
30
|
-
/**
|
|
31
|
-
* Canonical site URL (e.g. `'https://example.com'`). Exposed as `import.meta.env.SITE` and
|
|
32
|
-
* as `Aero.site` in templates. Used for sitemap, RSS, and canonical links.
|
|
33
|
-
*/
|
|
34
|
-
site?: string;
|
|
35
|
-
/**
|
|
36
|
-
* Redirect rules applied in dev (Vite) and when using the Nitro server (preview:api / production).
|
|
37
|
-
* For static-only deploys use host redirect config (_redirects, vercel.json, etc.).
|
|
38
|
-
*/
|
|
39
|
-
redirects?: RedirectRule[];
|
|
40
|
-
/**
|
|
41
|
-
* Optional request-time middleware (redirects, rewrites, custom responses).
|
|
42
|
-
* Runs in dev before rendering; for production redirects use Nitro server middleware or `redirects` config.
|
|
43
|
-
*/
|
|
44
|
-
middleware?: AeroMiddleware[];
|
|
45
|
-
/**
|
|
46
|
-
* Optional plugins to add to the static render server (e.g. content plugin when using aero:content).
|
|
47
|
-
* Merged after the core Aero plugins so pages that import aero:content resolve during static build.
|
|
48
|
-
*/
|
|
49
|
-
staticServerPlugins?: vite.Plugin[];
|
|
50
|
-
}
|
|
51
|
-
/** Request context passed to middleware (url, request, route path, resolved page name, site). */
|
|
52
|
-
interface AeroRequestContext {
|
|
53
|
-
url: URL;
|
|
54
|
-
request: Request;
|
|
55
|
-
routePath: string;
|
|
56
|
-
pageName: string;
|
|
57
|
-
site?: string;
|
|
58
|
-
}
|
|
59
|
-
/** Result of middleware: redirect, rewrite render input, or send a custom response. */
|
|
60
|
-
type AeroMiddlewareResult = {
|
|
61
|
-
redirect: {
|
|
62
|
-
url: string;
|
|
63
|
-
status?: number;
|
|
64
|
-
};
|
|
65
|
-
} | {
|
|
66
|
-
rewrite: Partial<AeroRenderInput> & {
|
|
67
|
-
pageName?: string;
|
|
68
|
-
};
|
|
69
|
-
} | {
|
|
70
|
-
response: Response;
|
|
71
|
-
} | void;
|
|
72
|
-
/** Middleware handler: receives request context; returns redirect/rewrite/response or nothing to continue. */
|
|
73
|
-
type AeroMiddleware = (ctx: AeroRequestContext) => AeroMiddlewareResult | Promise<AeroMiddlewareResult>;
|
|
74
|
-
/** Options for the client-side `mount()` entry (see `core/src/entry-dev.ts`). */
|
|
75
|
-
interface MountOptions {
|
|
76
|
-
/** Root element: CSS selector or `HTMLElement`. Defaults to `#app`. */
|
|
77
|
-
target?: string | HTMLElement;
|
|
78
|
-
/** Called with the root element after mount and after each HMR re-render. */
|
|
79
|
-
onRender?: (root: HTMLElement) => void;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Single script entry: attrs (optional), content (body or virtual URL), optional pass:data expression.
|
|
83
|
-
* Used by parser, codegen, Vite plugin, and static build for client/inline/blocking script arrays.
|
|
84
|
-
*/
|
|
85
|
-
interface ScriptEntry {
|
|
86
|
-
attrs?: string;
|
|
87
|
-
content: string;
|
|
88
|
-
passDataExpr?: string;
|
|
89
|
-
/** If true, client script is injected in <head> instead of before </body>. */
|
|
90
|
-
injectInHead?: boolean;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Input to the codegen compiler for a single template.
|
|
94
|
-
*
|
|
95
|
-
* @remarks
|
|
96
|
-
* Script arrays come from the parser; `root` and `resolvePath` from the build.
|
|
97
|
-
*/
|
|
98
|
-
interface CompileOptions {
|
|
99
|
-
root: string;
|
|
100
|
-
/** Client script entries (plain `<script>`): after transform, `content` may be virtual URL. */
|
|
101
|
-
clientScripts?: ScriptEntry[];
|
|
102
|
-
/** Inline scripts (`is:inline`) to be emitted in the page. */
|
|
103
|
-
inlineScripts?: ScriptEntry[];
|
|
104
|
-
/** Blocking scripts (`is:blocking`) to be emitted in the page. */
|
|
105
|
-
blockingScripts?: ScriptEntry[];
|
|
106
|
-
/** Resolve import specifiers (e.g. `@components/foo`) to absolute paths. */
|
|
107
|
-
resolvePath?: (specifier: string) => string;
|
|
108
|
-
}
|
|
109
|
-
/** Options for the path resolver (e.g. resolving `@components/foo` to a file path). */
|
|
110
|
-
interface ResolverOptions {
|
|
111
|
-
root: string;
|
|
112
|
-
resolvePath?: (specifier: string) => string;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Result of parsing one HTML template.
|
|
116
|
-
*
|
|
117
|
-
* @remarks
|
|
118
|
-
* Produced by `parser.ts`. Extracted script blocks and the remaining template string for codegen.
|
|
119
|
-
*/
|
|
120
|
-
interface ParseResult {
|
|
121
|
-
/** Single `<script is:build>` block, or `null` if none. */
|
|
122
|
-
buildScript: {
|
|
123
|
-
content: string;
|
|
124
|
-
} | null;
|
|
125
|
-
clientScripts: ScriptEntry[];
|
|
126
|
-
inlineScripts: ScriptEntry[];
|
|
127
|
-
blockingScripts: ScriptEntry[];
|
|
128
|
-
/** HTML after script blocks are stripped; used as input to codegen. */
|
|
129
|
-
template: string;
|
|
130
|
-
}
|
|
131
|
-
/** One path alias from tsconfig (e.g. find: `@components`, replacement: `.../src/components`). */
|
|
132
|
-
interface UserAlias {
|
|
133
|
-
find: string;
|
|
134
|
-
replacement: string;
|
|
135
|
-
}
|
|
136
|
-
/** Result of loading project path aliases (`utils/aliases.ts`). */
|
|
137
|
-
interface AliasResult {
|
|
138
|
-
aliases: UserAlias[];
|
|
139
|
-
resolvePath?: (specifier: string) => string;
|
|
140
|
-
}
|
|
141
|
-
/** Head and body HTML fragments (e.g. from `runtime/client` `extractDocumentParts`). */
|
|
142
|
-
interface PageFragments {
|
|
143
|
-
head: string;
|
|
144
|
-
body: string;
|
|
145
|
-
}
|
|
146
|
-
/** Dynamic route segment key → value (e.g. `{ id: '42' }` for `/posts/42`). */
|
|
147
|
-
interface AeroRouteParams {
|
|
148
|
-
[key: string]: string;
|
|
149
|
-
}
|
|
150
|
-
/** One static path for pre-rendering (e.g. from static path discovery). */
|
|
151
|
-
interface StaticPathEntry {
|
|
152
|
-
params: AeroRouteParams;
|
|
153
|
-
props?: Record<string, any>;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Input passed into a page or layout render (request, url, params, etc.).
|
|
157
|
-
*
|
|
158
|
-
* @remarks
|
|
159
|
-
* Used by the runtime when calling the compiled render function and when rendering child components.
|
|
160
|
-
*/
|
|
161
|
-
interface AeroRenderInput {
|
|
162
|
-
props?: Record<string, any>;
|
|
163
|
-
/** Named slot content (key → HTML string) for layout/page render. */
|
|
164
|
-
slots?: Record<string, string>;
|
|
165
|
-
request?: Request;
|
|
166
|
-
url?: URL | string;
|
|
167
|
-
params?: AeroRouteParams;
|
|
168
|
-
/** Resolved route path pattern (e.g. `'/posts/[id]'`) for the current request. */
|
|
169
|
-
routePath?: string;
|
|
170
|
-
/** Accumulated style URLs/labels for this request. */
|
|
171
|
-
styles?: Set<string>;
|
|
172
|
-
/** Accumulated script URLs/labels for this request. */
|
|
173
|
-
scripts?: Set<string>;
|
|
174
|
-
/** Scripts to inject in <head>. */
|
|
175
|
-
headScripts?: Set<string>;
|
|
176
|
-
/** Canonical site URL from config (e.g. `'https://example.com'`). Exposed as Aero.site in templates. */
|
|
177
|
-
site?: string;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Context object available inside compiled templates (`is:build`) and when rendering components.
|
|
181
|
-
*
|
|
182
|
-
* @remarks
|
|
183
|
-
* Includes `props`, `slots`, `renderComponent`, `request`, `url`, `params`, and optional style/script sets.
|
|
184
|
-
* The index signature allows extra keys (e.g. from content or page data).
|
|
185
|
-
*/
|
|
186
|
-
interface AeroTemplateContext {
|
|
187
|
-
[key: string]: any;
|
|
188
|
-
props: Record<string, any>;
|
|
189
|
-
slots: Record<string, string>;
|
|
190
|
-
/** Used by codegen to emit calls that render a child component and return its HTML. */
|
|
191
|
-
renderComponent: (component: any, props?: Record<string, any>, slots?: Record<string, string>, context?: AeroRenderInput) => Promise<string>;
|
|
192
|
-
request: Request;
|
|
193
|
-
url: URL;
|
|
194
|
-
params: AeroRouteParams;
|
|
195
|
-
/** Canonical site URL from config (e.g. `'https://example.com'`). */
|
|
196
|
-
site?: string;
|
|
197
|
-
styles?: Set<string>;
|
|
198
|
-
scripts?: Set<string>;
|
|
199
|
-
headScripts?: Set<string>;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export type { AeroDirs, AeroMiddleware, AeroMiddlewareResult, AeroOptions, AeroRenderInput, AeroRequestContext, AeroRouteParams, AeroTemplateContext, AliasResult, CompileOptions, MountOptions, PageFragments, ParseResult, RedirectRule, ResolverOptions, ScriptEntry, StaticPathEntry, UserAlias };
|
package/dist/types.js
DELETED
|
File without changes
|