@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,87 +0,0 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
//#region src/internal/compiler/semantic-core/style-imports.ts
|
|
3
|
-
/**
|
|
4
|
-
* Sheet-import admission (#1558) — the one style authoring form.
|
|
5
|
-
*
|
|
6
|
-
* A compiled module's sheets are real `.css` files imported into the module
|
|
7
|
-
* and arrayed in the class's `static styles`. The generated module copies the
|
|
8
|
-
* authored imports and the initializer verbatim (emit-module), the sheet's
|
|
9
|
-
* bytes stay in exactly one place — the authored file (P6) — and the compile
|
|
10
|
-
* result carries the import edges so the host build's style-asset plugin can
|
|
11
|
-
* intercept them (style-requests.ts). Nothing here reads sheet bytes and
|
|
12
|
-
* nothing here synthesizes sheet text: the compiler polices only the
|
|
13
|
-
* import/initializer shape, and every other sheet spelling fails closed with
|
|
14
|
-
* OEC9029 plus a migration hint — a silent inline path would put stylesheet
|
|
15
|
-
* bytes back into JS chunks and void the zero-inline guarantee (#1553).
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* The OEC9029 diagnostic: the one style authoring form is `.css` file
|
|
19
|
-
* imports arrayed in `static styles`; the message carries the migration hint.
|
|
20
|
-
*/
|
|
21
|
-
function failStyleShape(fail, node, message) {
|
|
22
|
-
fail(node, "OEC9029", `${message} — write the sheet to a .css file, import it (\`import sheet from './<component>.css'\`) and array the binding in static styles; inline sheet strings are retired (#1558)`);
|
|
23
|
-
}
|
|
24
|
-
/** Strip parens and type assertions — the initializer's expression core. */
|
|
25
|
-
function unwrap(expr) {
|
|
26
|
-
let current = expr;
|
|
27
|
-
while (ts.isParenthesizedExpression(current) || ts.isAsExpression(current) || ts.isTypeAssertionExpression(current)) current = current.expression;
|
|
28
|
-
return current;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Collect the module's `.css` imports and police their shape: every sheet
|
|
32
|
-
* import is a relative specifier bound through a default import — the
|
|
33
|
-
* side-effect form has no binding for `static styles` to adopt, and a bare
|
|
34
|
-
* package specifier does not resolve inside the authoring tree (the style
|
|
35
|
-
* edge is per-module: the intercept keys on the importing module's directory
|
|
36
|
-
* plus the file name). Named or type-only forms are refused for the same
|
|
37
|
-
* dangling-binding reason.
|
|
38
|
-
*/
|
|
39
|
-
function collectSheetImports(sf, fail) {
|
|
40
|
-
const imports = /* @__PURE__ */ new Map();
|
|
41
|
-
for (const statement of sf.statements) {
|
|
42
|
-
if (!ts.isImportDeclaration(statement)) continue;
|
|
43
|
-
if (!ts.isStringLiteral(statement.moduleSpecifier)) continue;
|
|
44
|
-
const specifier = statement.moduleSpecifier.text;
|
|
45
|
-
if (!specifier.endsWith(".css")) continue;
|
|
46
|
-
if (!specifier.startsWith("./") && !specifier.startsWith("../")) failStyleShape(fail, statement, `the .css import specifier "${specifier}" must be relative; a bare package specifier does not resolve inside the authoring tree`);
|
|
47
|
-
const clause = statement.importClause;
|
|
48
|
-
if (!clause || clause.isTypeOnly || !clause.name) failStyleShape(fail, statement, clause ? `the .css import of "${specifier}" must bind its sheet as a default import; named and type-only forms have no sheet binding for static styles to adopt` : `the .css import of "${specifier}" must bind its sheet — the side-effect form has no binding for static styles to adopt`);
|
|
49
|
-
const name = clause.name.text;
|
|
50
|
-
if (imports.has(name)) fail(statement, "OEC9029", `duplicate sheet import binding "${name}" — a compiled module's .css imports bind distinct names so static styles can array them individually`);
|
|
51
|
-
imports.set(name, {
|
|
52
|
-
name,
|
|
53
|
-
specifier,
|
|
54
|
-
node: statement
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
return imports;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Admit the class's authored `static styles` initializer: an array literal of
|
|
61
|
-
* the module's sheet-import bindings, in authored order. Returns the edge
|
|
62
|
-
* specifiers in that order; the admitted initializer emits verbatim, so the
|
|
63
|
-
* generated module keeps the authored import edges the host build intercepts.
|
|
64
|
-
* Every other shape fails closed with OEC9029, and every collected sheet
|
|
65
|
-
* import must be arrayed — an unadopted edge would dangle in the generated
|
|
66
|
-
* module with no style channel to ride.
|
|
67
|
-
*/
|
|
68
|
-
function admitStylesInitializer(stylesNode, sheetImports, sf, fail) {
|
|
69
|
-
const arrayNode = stylesNode === void 0 ? void 0 : unwrap(stylesNode);
|
|
70
|
-
if (arrayNode !== void 0 && !ts.isArrayLiteralExpression(arrayNode)) failStyleShape(fail, arrayNode, `static styles must array the module's .css file imports; "${arrayNode.getText(sf)}" is not an array of sheet imports`);
|
|
71
|
-
const edges = [];
|
|
72
|
-
const arrayed = /* @__PURE__ */ new Set();
|
|
73
|
-
if (arrayNode !== void 0) for (const element of arrayNode.elements) {
|
|
74
|
-
if (ts.isSpreadElement(element) || !ts.isIdentifier(element)) failStyleShape(fail, element, `static styles must array the module's .css file imports as plain bindings; "${element.getText(sf)}" is not a sheet-import binding`);
|
|
75
|
-
const name = element.text;
|
|
76
|
-
const sheet = sheetImports.get(name);
|
|
77
|
-
if (sheet === void 0) failStyleShape(fail, element, `static styles must array the module's .css file imports; "${name}" is not a .css import binding of this module`);
|
|
78
|
-
if (!arrayed.has(name)) {
|
|
79
|
-
arrayed.add(name);
|
|
80
|
-
edges.push(sheet.specifier);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
for (const sheet of sheetImports.values()) if (!arrayed.has(sheet.name)) fail(sheet.node, "OEC9029", `the .css import "${sheet.name}" ("${sheet.specifier}") is never arrayed in static styles — every sheet import of a compiled module is adopted by its class`);
|
|
84
|
-
return edges;
|
|
85
|
-
}
|
|
86
|
-
//#endregion
|
|
87
|
-
export { admitStylesInitializer, collectSheetImports };
|