@openelement/compiler 1.0.0-alpha.15 → 1.0.0-alpha.16
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 -2
- package/src/compiler.d.ts +8 -6
- package/src/compiler.js +7 -6
- package/src/internal/compiler/compiled-artifact-class-candidates.d.ts +5 -30
- package/src/internal/compiler/compiled-artifact-class-candidates.js +18 -32
- package/src/internal/compiler/compiled-artifact-style-requests.d.ts +9 -7
- package/src/internal/compiler/compiled-artifact-style-requests.js +9 -7
- package/src/internal/compiler/plugin.d.ts +31 -50
- package/src/internal/compiler/plugin.js +41 -108
- package/src/internal/compiler/semantic-core/analyze-module.d.ts +1 -45
- package/src/internal/compiler/semantic-core/analyze-module.js +10 -405
- package/src/internal/compiler/semantic-core/attribute-classification.js +92 -0
- package/src/internal/compiler/semantic-core/compiler-diagnostics.js +2 -16
- package/src/internal/compiler/semantic-core/expression-lowering.js +469 -0
- package/src/internal/compiler/semantic-core/expression-registry.js +165 -0
- package/src/internal/compiler/semantic-core/function-frontend.js +1229 -0
- package/src/internal/compiler/semantic-core/island-policy-statement.js +52 -0
- package/src/internal/compiler/semantic-core/jsx-module-id.d.ts +4 -0
- package/src/internal/compiler/semantic-core/jsx-module-id.js +7 -0
- package/src/internal/compiler/semantic-core/lower-program.d.ts +51 -0
- package/src/internal/compiler/semantic-core/lower-program.js +186 -90
- package/src/internal/compiler/semantic-core/module-analysis.d.ts +28 -5
- package/src/internal/compiler/semantic-core/module-analysis.js +16 -17
- package/src/internal/compiler/semantic-core/parse-module.js +16 -16
- package/src/internal/compiler/semantic-core/scope-resolution.d.ts +208 -0
- package/src/internal/compiler/semantic-core/scope-resolution.js +1121 -0
- package/src/internal/compiler/semantic-core/server-component.d.ts +22 -7
- package/src/internal/compiler/semantic-core/server-component.js +163 -57
- package/src/internal/compiler/semantic-core/type-erasure.js +156 -0
- package/src/internal/compiler/semantic-ir/generated-element/compile.d.ts +61 -0
- package/src/internal/compiler/semantic-ir/generated-element/compile.js +137 -0
- package/src/internal/compiler/semantic-ir/generated-element/contract.d.ts +201 -0
- package/src/internal/compiler/semantic-ir/generated-element/contract.js +147 -0
- package/src/internal/compiler/semantic-ir/generated-element/emit.js +452 -0
- package/src/internal/compiler/semantic-ir/generated-element/site.js +1195 -0
- package/src/internal/compiler/semantic-ir/generated-leaf/claim-emission.js +1372 -0
- package/src/internal/compiler/semantic-ir/generated-leaf/codegen-literals.js +31 -0
- package/src/internal/compiler/semantic-ir/generated-leaf/component-emission.js +647 -0
- package/src/internal/compiler/semantic-ir/generated-leaf/emission.js +388 -0
- package/src/internal/compiler/semantic-ir/generated-leaf/generate.js +395 -0
- package/src/internal/compiler/semantic-ir/generated-leaf/instance-emission.js +865 -0
- package/src/internal/compiler/semantic-ir/generated-leaf/mount-emission.js +960 -0
- package/src/internal/compiler/semantic-ir/generated-leaf/server-emission.js +1011 -0
- package/src/internal/compiler/semantic-ir/generated-leaf/structure.js +714 -0
- package/src/internal/compiler/style-requests.d.ts +0 -8
- package/src/internal/compiler/style-requests.js +1 -14
- package/src/internal/compiler/semantic-core/compile.d.ts +0 -47
- package/src/internal/compiler/semantic-core/compile.js +0 -100
- package/src/internal/compiler/semantic-core/emit-module.js +0 -317
- package/src/internal/compiler/semantic-core/emit-program.js +0 -141
- package/src/internal/compiler/semantic-core/style-imports.js +0 -87
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { CompiledElementSourceMap } from "./source-map.js";
|
|
2
1
|
import { CompilerFail } from "./compiler-diagnostics.js";
|
|
3
2
|
import { Lowering } from "./lower-program.js";
|
|
3
|
+
import { CompiledElementSourceMap } from "./source-map.js";
|
|
4
4
|
import ts from "typescript";
|
|
5
5
|
import { ProgramTreeNode } from "@openelement/protocol/part-program";
|
|
6
6
|
//#region src/internal/compiler/semantic-core/server-component.d.ts
|
|
7
|
+
/** Authored source with the resolved filename that determines its syntax. */
|
|
8
|
+
export interface ResolvedServerComponentSource {
|
|
9
|
+
readonly fileName: string;
|
|
10
|
+
readonly source: string;
|
|
11
|
+
}
|
|
7
12
|
/** Host-supplied inputs for the server function component compile. */
|
|
8
13
|
export interface ServerComponentCompileOptions {
|
|
9
14
|
/**
|
|
@@ -12,9 +17,11 @@ export interface ServerComponentCompileOptions {
|
|
|
12
17
|
* binding (compile-time resolved, deterministic). Absent or returning
|
|
13
18
|
* undefined: importing components from that specifier is a coded rejection.
|
|
14
19
|
* Resolution of specifiers to files stays the host's job — the compiler
|
|
15
|
-
* never reads the filesystem.
|
|
20
|
+
* never reads the filesystem. Supply the resolved filename when resolution
|
|
21
|
+
* can pick a different extension from the authored specifier. A source-only
|
|
22
|
+
* answer uses the specifier as the parser's filename.
|
|
16
23
|
*/
|
|
17
|
-
readonly resolveModule?: (specifier: string) => string | undefined;
|
|
24
|
+
readonly resolveModule?: (specifier: string) => string | ResolvedServerComponentSource | undefined;
|
|
18
25
|
/**
|
|
19
26
|
* The custom-element host tags the host build admitted as @element
|
|
20
27
|
* compiled components: those JSX children ride `__ssr(tag, props)`.
|
|
@@ -37,6 +44,8 @@ export interface CompileServerComponentResult {
|
|
|
37
44
|
*/
|
|
38
45
|
classCandidates?: string[];
|
|
39
46
|
}
|
|
47
|
+
/** Resolve the compiler's static source candidates through an asynchronous host. */
|
|
48
|
+
export declare function prepareServerComponentImports(source: string, fileName: string, resolve: (specifier: string) => string | ResolvedServerComponentSource | undefined | Promise<string | ResolvedServerComponentSource | undefined>): Promise<ServerComponentCompileOptions['resolveModule']>;
|
|
40
49
|
/**
|
|
41
50
|
* Compile one authored TSX module's server function components into the
|
|
42
51
|
* generative constructor module. Returns null for modules with no exported
|
|
@@ -51,12 +60,18 @@ export declare function compileServerComponentModule(source: string, fileName: s
|
|
|
51
60
|
* - a module carrying a compiled-element decorator (or an unsupported
|
|
52
61
|
* decorator spelling, which the class lane compiles so it fails closed with
|
|
53
62
|
* OEC9027) belongs to the class lane: null;
|
|
54
|
-
* - a module with no
|
|
55
|
-
* admit: null;
|
|
56
|
-
* - a
|
|
63
|
+
* - a module with no admitted server function component and no near-miss
|
|
64
|
+
* exported JSX function has nothing to admit: null;
|
|
65
|
+
* - a near-miss (statements before the return, a block-bodied arrow, or any
|
|
66
|
+
* other exported function/arrow whose body contains JSX but is not the
|
|
67
|
+
* single-return shape) is NOT null: it goes through
|
|
68
|
+
* {@link compileServerComponentModule}, which fails closed with OEC9032.
|
|
69
|
+
* Returning null would hand the authored module to another lane unchanged;
|
|
70
|
+
* - a plain script id never carries the JSX grammar: null;
|
|
57
71
|
* - the cheap `export` + `<` prefilter (the same conservative superset idea
|
|
58
72
|
* the class lane's prefilter uses) keeps plainly inert modules off the
|
|
59
|
-
* parse.
|
|
73
|
+
* parse. A module that does not parse stays null so the host reports the
|
|
74
|
+
* syntax error.
|
|
60
75
|
*
|
|
61
76
|
* Everything else goes through {@link compileServerComponentModule}, whose
|
|
62
77
|
* diagnostics fail the build closed.
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { analyzeModuleSemantics, createModuleIntrinsicBindings, isExportedServerComponentDeclaration, serverComponentName } from "./module-analysis.js";
|
|
2
1
|
import { CompiledElementError, failAt } from "./compiler-diagnostics.js";
|
|
2
|
+
import { isJsxModuleId } from "./jsx-module-id.js";
|
|
3
|
+
import { analyzeModuleSemantics, createModuleIntrinsicBindings, isExportedServerComponentDeclaration, serverComponentName } from "./module-analysis.js";
|
|
3
4
|
import { Lowering } from "./lower-program.js";
|
|
4
5
|
import { SourceMapSegmentBuilder } from "./source-map.js";
|
|
5
|
-
import { typescriptParser } from "./parse-module.js";
|
|
6
|
+
import { authoredPropsType, typescriptParser } from "./parse-module.js";
|
|
6
7
|
import ts from "typescript";
|
|
7
8
|
//#region src/internal/compiler/semantic-core/server-component.ts
|
|
8
9
|
/**
|
|
@@ -29,6 +30,9 @@ import ts from "typescript";
|
|
|
29
30
|
* - a nested server function component composes by DIRECT function call to
|
|
30
31
|
* the imported binding, resolved from the authored imports at compile time
|
|
31
32
|
* (deterministic — the host hands the compiler the imported sources).
|
|
33
|
+
* An async child is awaited by an async parent; a synchronous parent of an
|
|
34
|
+
* async child is refused. Await inside the single returned JSX is admitted
|
|
35
|
+
* only in the bounded full-await grammar (text children and nested props).
|
|
32
36
|
*
|
|
33
37
|
* The artifact is generated TS — not an IR, not an interpreter, no Part
|
|
34
38
|
* Program, no element class, no client graph edge.
|
|
@@ -59,15 +63,31 @@ function propsTypeOf(type) {
|
|
|
59
63
|
if (/^(Record|Map|Object)</.test(text)) return "object";
|
|
60
64
|
return "string";
|
|
61
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* True when the annotation is exactly `Promise<...>` (M14-2: "a Promise is not
|
|
68
|
+
* a normal child"). The only type fact this lane reads — it is NOT a type
|
|
69
|
+
* checker: `Promise<T>[]`, aliases and conditional types stay unknown.
|
|
70
|
+
*/
|
|
71
|
+
function isPromiseAnnotation(type) {
|
|
72
|
+
if (type === void 0) return false;
|
|
73
|
+
let node = type;
|
|
74
|
+
while (ts.isParenthesizedTypeNode(node)) node = node.type;
|
|
75
|
+
return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.text === "Promise";
|
|
76
|
+
}
|
|
62
77
|
/** Build the synthetic field table one props type literal admits. */
|
|
63
78
|
function fieldsOfPropsType(typeNode, fail) {
|
|
64
|
-
if (typeNode === void 0) return
|
|
79
|
+
if (typeNode === void 0) return {
|
|
80
|
+
fields: [],
|
|
81
|
+
promiseFields: /* @__PURE__ */ new Set()
|
|
82
|
+
};
|
|
65
83
|
let literal = typeNode;
|
|
66
84
|
while (ts.isParenthesizedTypeNode(literal)) literal = literal.type;
|
|
67
85
|
if (!ts.isTypeLiteralNode(literal)) fail(typeNode, "OEC9032", "the props parameter must be annotated inline as an object type literal (props: { name: string }) — type aliases and interfaces are outside the server function grammar");
|
|
68
86
|
const fields = [];
|
|
87
|
+
const promiseFields = /* @__PURE__ */ new Set();
|
|
69
88
|
for (const member of literal.members) {
|
|
70
89
|
if (!ts.isPropertySignature(member) || !ts.isIdentifier(member.name)) fail(member, "OEC9032", "the props type admits property signatures only");
|
|
90
|
+
if (isPromiseAnnotation(member.type)) promiseFields.add(member.name.text);
|
|
71
91
|
const label = propsTypeOf(member.type);
|
|
72
92
|
fields.push({
|
|
73
93
|
name: member.name.text,
|
|
@@ -83,13 +103,16 @@ function fieldsOfPropsType(typeNode, fail) {
|
|
|
83
103
|
node: member
|
|
84
104
|
});
|
|
85
105
|
}
|
|
86
|
-
return
|
|
106
|
+
return {
|
|
107
|
+
fields,
|
|
108
|
+
promiseFields
|
|
109
|
+
};
|
|
87
110
|
}
|
|
88
111
|
/** One component's admitted shape, with the diagnostics every other shape rejects. */
|
|
89
112
|
function admitComponent(statement, fail) {
|
|
90
113
|
const name = serverComponentName(statement);
|
|
91
114
|
if (ts.isFunctionDeclaration(statement)) {
|
|
92
|
-
|
|
115
|
+
const isAsync = (ts.getModifiers(statement) ?? []).some((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword);
|
|
93
116
|
if (statement.typeParameters?.length) fail(statement, "OEC9032", `server function component ${name} may not declare type parameters`);
|
|
94
117
|
if (statement.body === void 0 || !ts.isBlock(statement.body)) fail(statement, "OEC9032", `server function component ${name} must have a body`);
|
|
95
118
|
const returns = statement.body.statements.filter(ts.isReturnStatement);
|
|
@@ -98,10 +121,13 @@ function admitComponent(statement, fail) {
|
|
|
98
121
|
if (parameters.length > 1) fail(parameters[1], "OEC9032", `server function component ${name} takes at most one props parameter`);
|
|
99
122
|
let parameter = null;
|
|
100
123
|
let fields = [];
|
|
124
|
+
let promiseFields = /* @__PURE__ */ new Set();
|
|
101
125
|
if (parameters.length === 1) {
|
|
102
126
|
if (!ts.isIdentifier(parameters[0].name)) fail(parameters[0], "OEC9032", "the props parameter must be a plain identifier");
|
|
103
127
|
parameter = parameters[0].name.text;
|
|
104
|
-
|
|
128
|
+
const facts = fieldsOfPropsType(authoredPropsType(parameters[0]), fail);
|
|
129
|
+
fields = facts.fields;
|
|
130
|
+
promiseFields = facts.promiseFields;
|
|
105
131
|
}
|
|
106
132
|
return {
|
|
107
133
|
statement,
|
|
@@ -109,25 +135,33 @@ function admitComponent(statement, fail) {
|
|
|
109
135
|
parameter,
|
|
110
136
|
fields,
|
|
111
137
|
returned: returns[0].expression,
|
|
112
|
-
isArrow: false
|
|
138
|
+
isArrow: false,
|
|
139
|
+
isAsync,
|
|
140
|
+
promiseFields
|
|
113
141
|
};
|
|
114
142
|
}
|
|
115
143
|
const arrow = statement.declarationList.declarations[0].initializer;
|
|
116
144
|
if (arrow.parameters.length > 1) fail(arrow.parameters[1], "OEC9032", `${name} takes at most one props parameter`);
|
|
117
145
|
let parameter = null;
|
|
118
146
|
let fields = [];
|
|
147
|
+
let promiseFields = /* @__PURE__ */ new Set();
|
|
119
148
|
if (arrow.parameters.length === 1) {
|
|
120
149
|
if (!ts.isIdentifier(arrow.parameters[0].name)) fail(arrow.parameters[0], "OEC9032", "the props parameter must be a plain identifier");
|
|
121
150
|
parameter = arrow.parameters[0].name.text;
|
|
122
|
-
|
|
151
|
+
const facts = fieldsOfPropsType(authoredPropsType(arrow.parameters[0]), fail);
|
|
152
|
+
fields = facts.fields;
|
|
153
|
+
promiseFields = facts.promiseFields;
|
|
123
154
|
}
|
|
155
|
+
const arrowModifiers = ts.canHaveModifiers(arrow) ? ts.getModifiers(arrow) ?? [] : [];
|
|
124
156
|
return {
|
|
125
157
|
statement,
|
|
126
158
|
name,
|
|
127
159
|
parameter,
|
|
128
160
|
fields,
|
|
129
161
|
returned: arrow.body,
|
|
130
|
-
isArrow: true
|
|
162
|
+
isArrow: true,
|
|
163
|
+
isAsync: arrowModifiers.some((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword),
|
|
164
|
+
promiseFields
|
|
131
165
|
};
|
|
132
166
|
}
|
|
133
167
|
/** True when the component body touches `this` — a class-path-only binding. */
|
|
@@ -144,14 +178,53 @@ function parameterTextOf(component) {
|
|
|
144
178
|
const found = (component.isArrow ? component.statement.declarationList.declarations[0].initializer : component.statement).parameters.find((candidate) => ts.isIdentifier(candidate.name) && candidate.name.text === component.parameter);
|
|
145
179
|
return found ? found.getText() : component.parameter ?? "";
|
|
146
180
|
}
|
|
147
|
-
/**
|
|
148
|
-
function
|
|
181
|
+
/** Exported server function components of one module: name → whether it is async. */
|
|
182
|
+
function exportedServerComponents(source, fileName) {
|
|
149
183
|
const parsed = typescriptParser.parseModule(source, fileName);
|
|
150
|
-
const
|
|
151
|
-
if (parsed.syntaxDiagnostics.length === 0) {
|
|
152
|
-
|
|
184
|
+
const components = /* @__PURE__ */ new Map();
|
|
185
|
+
if (parsed.syntaxDiagnostics.length === 0) for (const statement of parsed.sourceFile.statements) {
|
|
186
|
+
if (!isExportedServerComponentDeclaration(statement)) continue;
|
|
187
|
+
components.set(serverComponentName(statement), statementIsAsync(statement));
|
|
188
|
+
}
|
|
189
|
+
return components;
|
|
190
|
+
}
|
|
191
|
+
/** Static named value imports are the only candidates for direct server JSX calls. */
|
|
192
|
+
function* serverComponentValueImports(sourceFile) {
|
|
193
|
+
for (const statement of sourceFile.statements) {
|
|
194
|
+
if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)) continue;
|
|
195
|
+
const clause = statement.importClause;
|
|
196
|
+
const bindings = clause?.namedBindings;
|
|
197
|
+
if (clause?.isTypeOnly || bindings === void 0 || !ts.isNamedImports(bindings)) continue;
|
|
198
|
+
const specifier = statement.moduleSpecifier.text;
|
|
199
|
+
const elements = bindings.elements.filter((element) => !element.isTypeOnly);
|
|
200
|
+
if (specifier !== SERVER_HELPER_SPECIFIER && elements.length > 0) yield {
|
|
201
|
+
specifier,
|
|
202
|
+
elements
|
|
203
|
+
};
|
|
153
204
|
}
|
|
154
|
-
|
|
205
|
+
}
|
|
206
|
+
/** Resolve the compiler's static source candidates through an asynchronous host. */
|
|
207
|
+
async function prepareServerComponentImports(source, fileName, resolve) {
|
|
208
|
+
if (!isJsxModuleId(fileName) || !source.includes("export") || !source.includes("import") || !source.includes("<")) return;
|
|
209
|
+
const { sourceFile, syntaxDiagnostics } = typescriptParser.parseModule(source, fileName);
|
|
210
|
+
if (syntaxDiagnostics.length > 0) return void 0;
|
|
211
|
+
const tags = /* @__PURE__ */ new Set();
|
|
212
|
+
const visit = (node) => {
|
|
213
|
+
if ((ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) && ts.isIdentifier(node.tagName)) tags.add(node.tagName.text);
|
|
214
|
+
ts.forEachChild(node, visit);
|
|
215
|
+
};
|
|
216
|
+
for (const statement of sourceFile.statements) if (isExportedServerComponentDeclaration(statement)) visit(statement);
|
|
217
|
+
const specifiers = /* @__PURE__ */ new Set();
|
|
218
|
+
for (const { specifier, elements } of serverComponentValueImports(sourceFile)) if (elements.some((element) => tags.has(element.name.text))) specifiers.add(specifier);
|
|
219
|
+
if (specifiers.size === 0) return void 0;
|
|
220
|
+
const modules = new Map(await Promise.all([...specifiers].map(async (specifier) => [specifier, await resolve(specifier)])));
|
|
221
|
+
return (specifier) => modules.get(specifier);
|
|
222
|
+
}
|
|
223
|
+
function statementIsAsync(statement) {
|
|
224
|
+
if (ts.isFunctionDeclaration(statement)) return (ts.getModifiers(statement) ?? []).some((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword);
|
|
225
|
+
const initializer = statement.declarationList.declarations[0].initializer;
|
|
226
|
+
if (initializer === void 0 || !ts.isArrowFunction(initializer)) return false;
|
|
227
|
+
return (ts.canHaveModifiers(initializer) ? ts.getModifiers(initializer) ?? [] : []).some((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword);
|
|
155
228
|
}
|
|
156
229
|
/**
|
|
157
230
|
* Compile one authored TSX module's server function components into the
|
|
@@ -177,47 +250,30 @@ function compileServerComponentModule(source, fileName, options = {}) {
|
|
|
177
250
|
}));
|
|
178
251
|
const fail = failAt(sf);
|
|
179
252
|
const candidates = sf.statements.filter(isExportedServerComponentDeclaration);
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
const visit = (child) => {
|
|
183
|
-
if (ts.isJsxElement(child) || ts.isJsxSelfClosingElement(child) || ts.isJsxFragment(child)) found = true;
|
|
184
|
-
ts.forEachChild(child, visit);
|
|
185
|
-
};
|
|
186
|
-
visit(node);
|
|
187
|
-
return found;
|
|
188
|
-
};
|
|
189
|
-
for (const statement of sf.statements) {
|
|
190
|
-
if (candidates.includes(statement)) continue;
|
|
191
|
-
const modifiers = ts.canHaveModifiers(statement) ? ts.getModifiers(statement) ?? [] : [];
|
|
192
|
-
if (!modifiers.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword)) continue;
|
|
193
|
-
if (modifiers.some((modifier) => modifier.kind === ts.SyntaxKind.DefaultKeyword)) continue;
|
|
194
|
-
let body;
|
|
195
|
-
if (ts.isFunctionDeclaration(statement)) body = statement.body;
|
|
196
|
-
else if (ts.isVariableStatement(statement) && statement.declarationList.declarations.length === 1 && statement.declarationList.declarations[0].initializer !== void 0 && ts.isArrowFunction(statement.declarationList.declarations[0].initializer)) body = statement.declarationList.declarations[0].initializer;
|
|
197
|
-
if (body !== void 0 && containsJsx(body)) fail(statement, "OEC9032", "this exported function renders JSX but is not an admitted server function component (a component is a single return of one JSX element) — runtime JSX has no interpreter in the server lane; fix the shape or move it out of the module");
|
|
198
|
-
}
|
|
253
|
+
const nearMiss = serverComponentNearMiss(sf, candidates);
|
|
254
|
+
if (nearMiss !== void 0) fail(nearMiss, "OEC9032", "this exported function renders JSX but is not an admitted server function component (a component is a single return of one JSX element) — runtime JSX has no interpreter in the server lane; fix the shape or move it out of the module");
|
|
199
255
|
if (candidates.length === 0) return null;
|
|
200
256
|
const intrinsics = createModuleIntrinsicBindings(sf);
|
|
201
257
|
for (const helper of SERVER_HELPERS) if (intrinsics.hasModuleScopeBinding(helper)) fail(sf, "OEC9032", `"${helper}" is reserved for the generated constructor imports (${SERVER_HELPER_SPECIFIER}) — remove or rename the module-scope binding`);
|
|
202
258
|
const componentBindings = /* @__PURE__ */ new Map();
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
const
|
|
206
|
-
if (
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
const
|
|
210
|
-
const bindings = statement.importClause?.namedBindings;
|
|
211
|
-
if (!bindings || !ts.isNamedImports(bindings)) continue;
|
|
212
|
-
for (const element of bindings.elements) {
|
|
259
|
+
const asyncComponents = /* @__PURE__ */ new Set();
|
|
260
|
+
if (options.resolveModule !== void 0) for (const { specifier, elements } of serverComponentValueImports(sf)) {
|
|
261
|
+
const importedModule = options.resolveModule(specifier);
|
|
262
|
+
if (importedModule === void 0) continue;
|
|
263
|
+
if (typeof importedModule !== "string" && !isJsxModuleId(importedModule.fileName)) continue;
|
|
264
|
+
const importedComponents = exportedServerComponents(typeof importedModule === "string" ? importedModule : importedModule.source, typeof importedModule === "string" ? `${fileName}→${specifier}` : importedModule.fileName);
|
|
265
|
+
for (const element of elements) {
|
|
213
266
|
const imported = element.propertyName?.text ?? element.name.text;
|
|
214
|
-
if (
|
|
267
|
+
if (!importedComponents.has(imported)) continue;
|
|
268
|
+
componentBindings.set(element.name.text, element.name.text);
|
|
269
|
+
if (importedComponents.get(imported) === true) asyncComponents.add(element.name.text);
|
|
215
270
|
}
|
|
216
271
|
}
|
|
217
272
|
const serverBinding = {
|
|
218
273
|
parameter: "props",
|
|
219
274
|
components: componentBindings,
|
|
220
|
-
compiledTags: new Set(options.compiledTags ?? [])
|
|
275
|
+
compiledTags: new Set(options.compiledTags ?? []),
|
|
276
|
+
asyncComponents
|
|
221
277
|
};
|
|
222
278
|
const generatedByStatement = /* @__PURE__ */ new Map();
|
|
223
279
|
const classCandidates = /* @__PURE__ */ new Set();
|
|
@@ -226,7 +282,11 @@ function compileServerComponentModule(source, fileName, options = {}) {
|
|
|
226
282
|
assertNoThisReads(component.isArrow ? statement.declarationList.declarations[0].initializer : statement, fail);
|
|
227
283
|
const lowering = new Lowering(sf, component.fields, [], {
|
|
228
284
|
computedLocal: null,
|
|
229
|
-
server:
|
|
285
|
+
server: {
|
|
286
|
+
...serverBinding,
|
|
287
|
+
asyncFunction: component.isAsync,
|
|
288
|
+
promiseFields: component.promiseFields
|
|
289
|
+
}
|
|
230
290
|
});
|
|
231
291
|
const root = lowering.lowerRoot(component.returned);
|
|
232
292
|
if (root.k !== "el") fail(component.returned, "OEC9007", "a server function component must return one element");
|
|
@@ -239,9 +299,10 @@ function compileServerComponentModule(source, fileName, options = {}) {
|
|
|
239
299
|
signatureNode: statement,
|
|
240
300
|
bodyNode: component.returned
|
|
241
301
|
};
|
|
242
|
-
|
|
302
|
+
const asyncKeyword = component.isAsync ? "async " : "";
|
|
303
|
+
if (component.isArrow) piece.single = `export const ${component.name} = ${asyncKeyword}(${parameterText}) => ${body};`;
|
|
243
304
|
else {
|
|
244
|
-
piece.signature = `export function ${component.name}(${parameterText}) {`;
|
|
305
|
+
piece.signature = `export ${asyncKeyword}function ${component.name}(${parameterText}) {`;
|
|
245
306
|
piece.bodyLine = ` return ${body};`;
|
|
246
307
|
piece.closing = "}";
|
|
247
308
|
}
|
|
@@ -304,28 +365,69 @@ function compileServerComponentModule(source, fileName, options = {}) {
|
|
|
304
365
|
};
|
|
305
366
|
}
|
|
306
367
|
/**
|
|
368
|
+
* An exported function or arrow whose body contains JSX but is not the
|
|
369
|
+
* admitted single-return shape. Statements before the return and a
|
|
370
|
+
* block-bodied arrow are the shapes authors actually write; both carry JSX
|
|
371
|
+
* the server lane cannot leave for a runtime JSX transform. Default exports
|
|
372
|
+
* stay out: they are page/route surface, not composed components. The fact
|
|
373
|
+
* scan ({@link isExportedServerComponentDeclaration}) does not count these,
|
|
374
|
+
* so an admission bridge that stops on an empty component list would return
|
|
375
|
+
* null and the host would pass the module through unchanged.
|
|
376
|
+
*/
|
|
377
|
+
function serverComponentNearMiss(sf, candidates) {
|
|
378
|
+
const containsJsx = (node) => {
|
|
379
|
+
let found = false;
|
|
380
|
+
const visit = (child) => {
|
|
381
|
+
if (ts.isJsxElement(child) || ts.isJsxSelfClosingElement(child) || ts.isJsxFragment(child)) found = true;
|
|
382
|
+
ts.forEachChild(child, visit);
|
|
383
|
+
};
|
|
384
|
+
visit(node);
|
|
385
|
+
return found;
|
|
386
|
+
};
|
|
387
|
+
for (const statement of sf.statements) {
|
|
388
|
+
if (candidates.includes(statement)) continue;
|
|
389
|
+
const modifiers = ts.canHaveModifiers(statement) ? ts.getModifiers(statement) ?? [] : [];
|
|
390
|
+
if (!modifiers.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword)) continue;
|
|
391
|
+
if (modifiers.some((modifier) => modifier.kind === ts.SyntaxKind.DefaultKeyword)) continue;
|
|
392
|
+
let body;
|
|
393
|
+
if (ts.isFunctionDeclaration(statement)) body = statement.body;
|
|
394
|
+
else if (ts.isVariableStatement(statement) && statement.declarationList.declarations.length === 1 && statement.declarationList.declarations[0].initializer !== void 0 && ts.isArrowFunction(statement.declarationList.declarations[0].initializer)) body = statement.declarationList.declarations[0].initializer;
|
|
395
|
+
if (body !== void 0 && containsJsx(body)) return statement;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
307
399
|
* The host-build admission bridge: compile `code` through the server function
|
|
308
400
|
* component lane when — and only when — this module belongs to it.
|
|
309
401
|
*
|
|
310
402
|
* - a module carrying a compiled-element decorator (or an unsupported
|
|
311
403
|
* decorator spelling, which the class lane compiles so it fails closed with
|
|
312
404
|
* OEC9027) belongs to the class lane: null;
|
|
313
|
-
* - a module with no
|
|
314
|
-
* admit: null;
|
|
315
|
-
* - a
|
|
405
|
+
* - a module with no admitted server function component and no near-miss
|
|
406
|
+
* exported JSX function has nothing to admit: null;
|
|
407
|
+
* - a near-miss (statements before the return, a block-bodied arrow, or any
|
|
408
|
+
* other exported function/arrow whose body contains JSX but is not the
|
|
409
|
+
* single-return shape) is NOT null: it goes through
|
|
410
|
+
* {@link compileServerComponentModule}, which fails closed with OEC9032.
|
|
411
|
+
* Returning null would hand the authored module to another lane unchanged;
|
|
412
|
+
* - a plain script id never carries the JSX grammar: null;
|
|
316
413
|
* - the cheap `export` + `<` prefilter (the same conservative superset idea
|
|
317
414
|
* the class lane's prefilter uses) keeps plainly inert modules off the
|
|
318
|
-
* parse.
|
|
415
|
+
* parse. A module that does not parse stays null so the host reports the
|
|
416
|
+
* syntax error.
|
|
319
417
|
*
|
|
320
418
|
* Everything else goes through {@link compileServerComponentModule}, whose
|
|
321
419
|
* diagnostics fail the build closed.
|
|
322
420
|
*/
|
|
323
421
|
function compileServerComponentIfAdmitted(code, id, options = {}) {
|
|
324
|
-
if (
|
|
422
|
+
if (!isJsxModuleId(id)) return null;
|
|
325
423
|
if (!code.includes("export") || !code.includes("<")) return null;
|
|
326
424
|
const facts = analyzeModuleSemantics(code, id);
|
|
327
425
|
if (facts.compiledElementDecorator || facts.unsupportedElementDecorator !== void 0) return null;
|
|
328
|
-
if (facts.serverFunctionComponents.length === 0)
|
|
426
|
+
if (facts.serverFunctionComponents.length === 0) {
|
|
427
|
+
const parsed = typescriptParser.parseModule(code, id);
|
|
428
|
+
if (parsed.syntaxDiagnostics.length > 0) return null;
|
|
429
|
+
if (serverComponentNearMiss(parsed.sourceFile, []) === void 0) return null;
|
|
430
|
+
}
|
|
329
431
|
return compileServerComponentModule(code, id, options);
|
|
330
432
|
}
|
|
331
433
|
/**
|
|
@@ -429,11 +531,15 @@ var ConstructorEmitter = class {
|
|
|
429
531
|
}
|
|
430
532
|
return this.fail(this.sf, "OEC9013", `sink ${part.k} cannot anchor in server function output`);
|
|
431
533
|
}
|
|
534
|
+
const awaitedSlot = this.lowering.serverExpressionSlots?.get(node.id);
|
|
535
|
+
if (awaitedSlot !== void 0) return awaitedSlot;
|
|
432
536
|
const componentCall = this.lowering.componentCalls.get(node.id);
|
|
433
537
|
if (componentCall !== void 0) {
|
|
434
538
|
const entries = componentCall.propsEntries.map(([name, value]) => `${JSON.stringify(name)}: ${value}`);
|
|
435
539
|
if (componentCall.children.length > 0) entries.push(`${JSON.stringify("children")}: [${componentCall.children.map((child) => this.node(child)).join(", ")}].join('')`);
|
|
436
|
-
|
|
540
|
+
const component = this.identifier(componentCall.component, "the nested component binding");
|
|
541
|
+
const call = `${component}({ ${entries.join(", ")} })`;
|
|
542
|
+
return this.lowering.isServerAsyncComponent?.(component) === true ? `await ${call}` : call;
|
|
437
543
|
}
|
|
438
544
|
const sinks = this.sinksOf(node.id);
|
|
439
545
|
const isSsr = this.lowering.ssrCalls.has(node.id);
|
|
@@ -478,4 +584,4 @@ var ConstructorEmitter = class {
|
|
|
478
584
|
}
|
|
479
585
|
};
|
|
480
586
|
//#endregion
|
|
481
|
-
export { ConstructorEmitter, compileServerComponentIfAdmitted, compileServerComponentModule };
|
|
587
|
+
export { ConstructorEmitter, compileServerComponentIfAdmitted, compileServerComponentModule, prepareServerComponentImports };
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
//#region src/internal/compiler/semantic-core/type-erasure.ts
|
|
3
|
+
/**
|
|
4
|
+
* M03-I-3 — TypeScript-only syntax erasure for lowered expression text.
|
|
5
|
+
*
|
|
6
|
+
* Design authority: `docs/architecture/m03-expression-identity.md` (M03-B) §3
|
|
7
|
+
* Route 3 step 2a and §8 rule 2. The erasure visitor is the one place where
|
|
8
|
+
* this design takes on work TypeScript's own emitter would otherwise do, which
|
|
9
|
+
* is exactly why §10 keeps a differential `ts.transpileModule` oracle: the
|
|
10
|
+
* oracle checks this visitor, it is never the mechanism.
|
|
11
|
+
*
|
|
12
|
+
* Scope (the admitted erasure set):
|
|
13
|
+
* - wrappers: `as`, `satisfies`, non-null `!`, angle-bracket type assertions and
|
|
14
|
+
* instantiation expressions (`f<string>` as a value) are replaced by their
|
|
15
|
+
* inner expression;
|
|
16
|
+
* - type arguments on `call`/`new` sites are dropped;
|
|
17
|
+
* - annotations on function-like nodes are dropped (type parameters, return
|
|
18
|
+
* types, parameter types and their optional `?`); a `this` parameter is
|
|
19
|
+
* removed; this covers arrows/function expressions, object-literal methods
|
|
20
|
+
* and accessors, and nested function declarations;
|
|
21
|
+
* - property declarations only need their type/`?`/`!` erased, but they occur
|
|
22
|
+
* inside class expressions, which this model refuses (see below).
|
|
23
|
+
*
|
|
24
|
+
* Outside the admitted erasure set this module fails closed: class declarations
|
|
25
|
+
* and class expressions are outside the function-component expression model
|
|
26
|
+
* (class authoring retires; M03-B §6), so they are refused with
|
|
27
|
+
* `OEIR_ERASURE_UNSUPPORTED` rather than half-lowered. Context-sensitive
|
|
28
|
+
* constructs (`this`/`arguments`/`super`/`new.target`/`await`/`yield`/`eval`)
|
|
29
|
+
* stay refused by the caller's context matrix.
|
|
30
|
+
*
|
|
31
|
+
* The visitor preserves authored positions on every rebuilt node
|
|
32
|
+
* (`ts.setTextRange`), so the A2 marker/anchor pipeline keeps reporting node
|
|
33
|
+
* starts for the surviving nodes: erasure changes the printed text, never the
|
|
34
|
+
* provenance arithmetic.
|
|
35
|
+
*/
|
|
36
|
+
function withAuthoredRange(updated, original) {
|
|
37
|
+
return ts.setTextRange(updated, original);
|
|
38
|
+
}
|
|
39
|
+
/** Type-assert a visited child back to the factory's expected child type. */
|
|
40
|
+
function visitAs(visit, node) {
|
|
41
|
+
return visit(node);
|
|
42
|
+
}
|
|
43
|
+
function isThisParameter(parameter) {
|
|
44
|
+
return ts.isIdentifier(parameter.name) && parameter.name.text === "this";
|
|
45
|
+
}
|
|
46
|
+
function parameterNeedsErasure(parameter) {
|
|
47
|
+
return parameter.type !== void 0 || parameter.questionToken !== void 0;
|
|
48
|
+
}
|
|
49
|
+
/** Erase parameter annotations, optional markers and `this` parameters. */
|
|
50
|
+
function eraseParameters(parameters, visit) {
|
|
51
|
+
const erased = [];
|
|
52
|
+
for (const parameter of parameters) {
|
|
53
|
+
if (isThisParameter(parameter)) continue;
|
|
54
|
+
const initializer = parameter.initializer === void 0 ? void 0 : visitAs(visit, parameter.initializer);
|
|
55
|
+
if (!parameterNeedsErasure(parameter) && initializer === parameter.initializer) {
|
|
56
|
+
erased.push(parameter);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
erased.push(withAuthoredRange(ts.factory.updateParameterDeclaration(parameter, parameter.modifiers, parameter.dotDotDotToken, parameter.name, void 0, void 0, initializer), parameter));
|
|
60
|
+
}
|
|
61
|
+
return erased;
|
|
62
|
+
}
|
|
63
|
+
function eraseArrow(node, visit) {
|
|
64
|
+
return withAuthoredRange(ts.factory.updateArrowFunction(node, node.modifiers, void 0, eraseParameters(node.parameters, visit), void 0, node.equalsGreaterThanToken, visitAs(visit, node.body)), node);
|
|
65
|
+
}
|
|
66
|
+
function eraseFunctionExpression(node, visit) {
|
|
67
|
+
return withAuthoredRange(ts.factory.updateFunctionExpression(node, node.modifiers, node.asteriskToken, node.name, void 0, eraseParameters(node.parameters, visit), void 0, visitAs(visit, node.body)), node);
|
|
68
|
+
}
|
|
69
|
+
function eraseFunctionDeclaration(node, visit) {
|
|
70
|
+
return withAuthoredRange(ts.factory.updateFunctionDeclaration(node, node.modifiers, node.asteriskToken, node.name, void 0, eraseParameters(node.parameters, visit), void 0, node.body === void 0 ? void 0 : visitAs(visit, node.body)), node);
|
|
71
|
+
}
|
|
72
|
+
function eraseMethodDeclaration(node, visit) {
|
|
73
|
+
return withAuthoredRange(ts.factory.updateMethodDeclaration(node, node.modifiers, node.asteriskToken, node.name, node.questionToken, void 0, eraseParameters(node.parameters, visit), void 0, node.body === void 0 ? void 0 : visitAs(visit, node.body)), node);
|
|
74
|
+
}
|
|
75
|
+
function eraseGetAccessor(node, visit) {
|
|
76
|
+
return withAuthoredRange(ts.factory.updateGetAccessorDeclaration(node, node.modifiers, node.name, eraseParameters(node.parameters, visit), void 0, node.body === void 0 ? void 0 : visitAs(visit, node.body)), node);
|
|
77
|
+
}
|
|
78
|
+
function eraseSetAccessor(node, visit) {
|
|
79
|
+
return withAuthoredRange(ts.factory.updateSetAccessorDeclaration(node, node.modifiers, node.name, eraseParameters(node.parameters, visit), node.body === void 0 ? void 0 : visitAs(visit, node.body)), node);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Erase TypeScript-only syntax at this node. Returns the replacement, or
|
|
83
|
+
* `undefined` when this node is not erased here and the caller should continue
|
|
84
|
+
* with its normal child traversal (`ts.visitEachChild`).
|
|
85
|
+
*/
|
|
86
|
+
function eraseTypeScriptSyntax(node, visit) {
|
|
87
|
+
if (ts.isAsExpression(node) || ts.isSatisfiesExpression(node) || ts.isNonNullExpression(node) || ts.isTypeAssertionExpression(node)) return visit(node.expression);
|
|
88
|
+
if (ts.isExpressionWithTypeArguments(node)) return visitAs(visit, node.expression);
|
|
89
|
+
if (ts.isCallExpression(node)) {
|
|
90
|
+
if (node.typeArguments === void 0 || node.typeArguments.length === 0) return void 0;
|
|
91
|
+
return withAuthoredRange(ts.factory.updateCallExpression(node, visitAs(visit, node.expression), void 0, node.arguments.map((argument) => visitAs(visit, argument))), node);
|
|
92
|
+
}
|
|
93
|
+
if (ts.isNewExpression(node)) {
|
|
94
|
+
if (node.typeArguments === void 0 || node.typeArguments.length === 0) return void 0;
|
|
95
|
+
return withAuthoredRange(ts.factory.updateNewExpression(node, visitAs(visit, node.expression), void 0, node.arguments === void 0 ? void 0 : node.arguments.map((argument) => visitAs(visit, argument))), node);
|
|
96
|
+
}
|
|
97
|
+
if (ts.isVariableDeclaration(node)) {
|
|
98
|
+
if (node.type === void 0 && node.exclamationToken === void 0) return void 0;
|
|
99
|
+
return withAuthoredRange(ts.factory.updateVariableDeclaration(node, node.name, void 0, void 0, node.initializer === void 0 ? void 0 : visitAs(visit, node.initializer)), node);
|
|
100
|
+
}
|
|
101
|
+
if (ts.isArrowFunction(node)) return eraseArrow(node, visit);
|
|
102
|
+
if (ts.isFunctionExpression(node)) return eraseFunctionExpression(node, visit);
|
|
103
|
+
if (ts.isFunctionDeclaration(node)) return eraseFunctionDeclaration(node, visit);
|
|
104
|
+
if (ts.isMethodDeclaration(node)) return eraseMethodDeclaration(node, visit);
|
|
105
|
+
if (ts.isGetAccessorDeclaration(node)) return eraseGetAccessor(node, visit);
|
|
106
|
+
if (ts.isSetAccessorDeclaration(node)) return eraseSetAccessor(node, visit);
|
|
107
|
+
}
|
|
108
|
+
/** A source-located erasure refusal. */
|
|
109
|
+
function refusal(sourceFile, node, code, message) {
|
|
110
|
+
const start = node.getStart(sourceFile);
|
|
111
|
+
const position = sourceFile.getLineAndCharacterOfPosition(start);
|
|
112
|
+
return {
|
|
113
|
+
severity: "error",
|
|
114
|
+
code,
|
|
115
|
+
message,
|
|
116
|
+
span: {
|
|
117
|
+
file: sourceFile.fileName,
|
|
118
|
+
start,
|
|
119
|
+
end: node.getEnd(),
|
|
120
|
+
line: position.line + 1,
|
|
121
|
+
column: position.character + 1
|
|
122
|
+
},
|
|
123
|
+
origin: "source"
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Fail closed on TypeScript syntax outside the admitted erasure set. Class
|
|
128
|
+
* authoring retires (M03-B §6), so a class declaration/expression inside the
|
|
129
|
+
* lowered expression is refused instead of half-lowered. JSX subtrees are
|
|
130
|
+
* recipe interiors and are not inspected.
|
|
131
|
+
*/
|
|
132
|
+
function collectErasureBoundaryRefusals(sourceFile, root, diagnostics) {
|
|
133
|
+
const visit = (node) => {
|
|
134
|
+
if (node !== root && ts.isJsxElement(node)) return;
|
|
135
|
+
if (ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)) return;
|
|
136
|
+
if (ts.isClassExpression(node) || ts.isClassDeclaration(node)) {
|
|
137
|
+
diagnostics.push(refusal(sourceFile, node, "OEIR_ERASURE_UNSUPPORTED", "class authoring is outside the function-component expression model; fail closed rather than print a half-erased class"));
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (ts.isTypeAliasDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isEnumDeclaration(node) || ts.isModuleDeclaration(node)) {
|
|
141
|
+
diagnostics.push(refusal(sourceFile, node, "OEIR_ERASURE_UNSUPPORTED", "type-only declarations inside a lowered expression are outside the erasure set; fail closed rather than print TypeScript-only declarations as JavaScript"));
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (ts.canHaveModifiers(node)) {
|
|
145
|
+
const declare = ts.getModifiers(node)?.find((modifier) => modifier.kind === ts.SyntaxKind.DeclareKeyword);
|
|
146
|
+
if (declare !== void 0) {
|
|
147
|
+
diagnostics.push(refusal(sourceFile, declare, "OEIR_ERASURE_UNSUPPORTED", "`declare` is outside the admitted erasure set; fail closed"));
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
ts.forEachChild(node, visit);
|
|
152
|
+
};
|
|
153
|
+
visit(root);
|
|
154
|
+
}
|
|
155
|
+
//#endregion
|
|
156
|
+
export { collectErasureBoundaryRefusals, eraseTypeScriptSyntax };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { CompiledElementSourceMap } from "../../semantic-core/source-map.js";
|
|
2
|
+
import { GeneratedElementSite } from "./contract.js";
|
|
3
|
+
//#region src/internal/compiler/semantic-ir/generated-element/compile.d.ts
|
|
4
|
+
/** Host-supplied inputs for one generated-element compile. */
|
|
5
|
+
export interface CompileGeneratedElementOptions {
|
|
6
|
+
/** The host's site fact; null keeps the lane inert. */
|
|
7
|
+
readonly site: GeneratedElementSite | null;
|
|
8
|
+
/** The authored source for the emitted module's source map. */
|
|
9
|
+
readonly authoredSource?: string;
|
|
10
|
+
}
|
|
11
|
+
/** The compiled generated-element module (text plus the leaf's unchanged map). */
|
|
12
|
+
export interface CompiledGeneratedElement {
|
|
13
|
+
readonly code: string;
|
|
14
|
+
/** The leaf source map, unchanged; the appended CE tail has no segments. */
|
|
15
|
+
readonly map: CompiledElementSourceMap | null;
|
|
16
|
+
readonly tag: string;
|
|
17
|
+
readonly component: string;
|
|
18
|
+
/**
|
|
19
|
+
* The emitted host-wrapper export name (`<component>__ssrHost`), or null when
|
|
20
|
+
* the emitter appended no host producer. It is the compiler-owned emitted
|
|
21
|
+
* export identity (M11 review §4.1/S1), produced by the same emitter
|
|
22
|
+
* `hostWrapper` decision that appends the function and returned here as
|
|
23
|
+
* build metadata: `null` means "this module has no host producer" (a light or
|
|
24
|
+
* absent root, a leaf without `<component>__ssr`, or a hostless/refused
|
|
25
|
+
* module), not an error. `code` is byte-identical whether or not the field is
|
|
26
|
+
* read; callers must not re-derive the name from the emitted text.
|
|
27
|
+
*/
|
|
28
|
+
readonly ssrHostExport: string | null;
|
|
29
|
+
/** Whether emission attached the light-root SSR producer to the constructor. */
|
|
30
|
+
readonly lightSsr: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* The module's admitted STATIC class tokens (deletion prerequisite P-1): the
|
|
33
|
+
* component stylesheet's candidate set, collected from the same function model
|
|
34
|
+
* the module was emitted from. Empty when every class channel is dynamic.
|
|
35
|
+
*/
|
|
36
|
+
readonly classCandidates: readonly string[];
|
|
37
|
+
/**
|
|
38
|
+
* Whether this module's tree contains a `when`/`each` Block — the blocks axis of
|
|
39
|
+
* the runtime-shape floor table (ADR-0166), which picks the `./no-blocks` entry
|
|
40
|
+
* when no island in the app uses one.
|
|
41
|
+
*
|
|
42
|
+
* This replaces the class lane's `program.blocks`: the router's scan used to read
|
|
43
|
+
* that Part Program field, and with the class lane gone it had no fact at all.
|
|
44
|
+
* Answered from the SAME function model this compile already lowered, so it is a
|
|
45
|
+
* fact of the compilation and not a second derivation.
|
|
46
|
+
*/
|
|
47
|
+
readonly usesBlocks: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Compile one module through the generated native element lane when — and only
|
|
51
|
+
* when — the host supplied a site fact for it.
|
|
52
|
+
*
|
|
53
|
+
* Admission order (design §4.2): site fact → class-lane ownership → syntactic
|
|
54
|
+
* default-export/sidecar admission (the root and focus facts and the property
|
|
55
|
+
* table included: the lane reads them from the sidecar, D-root-source /
|
|
56
|
+
* D-delegatesFocus / D-props) → props parameter/type cross-check → leaf
|
|
57
|
+
* generation → bindings requirement. The final emitter step is append-only over the leaf text, so
|
|
58
|
+
* every refusal happens before a half-built module can be returned.
|
|
59
|
+
*/
|
|
60
|
+
export declare function compileGeneratedElementIfAdmitted(code: string, id: string, options: CompileGeneratedElementOptions): CompiledGeneratedElement | null;
|
|
61
|
+
//#endregion
|