@arcmantle/lit-jsx 1.0.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/README.md +768 -0
- package/dist/compiler/attribute-processor.d.ts +128 -0
- package/dist/compiler/attribute-processor.d.ts.map +1 -0
- package/dist/compiler/attribute-processor.js +380 -0
- package/dist/compiler/attribute-processor.js.map +1 -0
- package/dist/compiler/babel-preset.d.ts +6 -0
- package/dist/compiler/babel-preset.d.ts.map +1 -0
- package/dist/compiler/babel-preset.js +27 -0
- package/dist/compiler/babel-preset.js.map +1 -0
- package/dist/compiler/builder.d.ts +22 -0
- package/dist/compiler/builder.d.ts.map +1 -0
- package/dist/compiler/builder.js +62 -0
- package/dist/compiler/builder.js.map +1 -0
- package/dist/compiler/compiler-utils.d.ts +81 -0
- package/dist/compiler/compiler-utils.d.ts.map +1 -0
- package/dist/compiler/compiler-utils.js +410 -0
- package/dist/compiler/compiler-utils.js.map +1 -0
- package/dist/compiler/config.d.ts +77 -0
- package/dist/compiler/config.d.ts.map +1 -0
- package/dist/compiler/config.js +78 -0
- package/dist/compiler/config.js.map +1 -0
- package/dist/compiler/postprocess.d.ts +5 -0
- package/dist/compiler/postprocess.d.ts.map +1 -0
- package/dist/compiler/postprocess.js +3 -0
- package/dist/compiler/postprocess.js.map +1 -0
- package/dist/compiler/preprocess.d.ts +5 -0
- package/dist/compiler/preprocess.d.ts.map +1 -0
- package/dist/compiler/preprocess.js +28 -0
- package/dist/compiler/preprocess.js.map +1 -0
- package/dist/compiler/transform-jsx.d.ts +5 -0
- package/dist/compiler/transform-jsx.d.ts.map +1 -0
- package/dist/compiler/transform-jsx.js +25 -0
- package/dist/compiler/transform-jsx.js.map +1 -0
- package/dist/compiler/transpiler.d.ts +48 -0
- package/dist/compiler/transpiler.d.ts.map +1 -0
- package/dist/compiler/transpiler.js +463 -0
- package/dist/compiler/transpiler.js.map +1 -0
- package/dist/compiler/vite-plugin.d.ts +38 -0
- package/dist/compiler/vite-plugin.d.ts.map +1 -0
- package/dist/compiler/vite-plugin.js +96 -0
- package/dist/compiler/vite-plugin.js.map +1 -0
- package/dist/runtime/choose-component.d.ts +39 -0
- package/dist/runtime/choose-component.d.ts.map +1 -0
- package/dist/runtime/choose-component.js +40 -0
- package/dist/runtime/choose-component.js.map +1 -0
- package/dist/runtime/compiler-ctors.d.ts +21 -0
- package/dist/runtime/compiler-ctors.d.ts.map +1 -0
- package/dist/runtime/compiler-ctors.js +21 -0
- package/dist/runtime/compiler-ctors.js.map +1 -0
- package/dist/runtime/for-component.d.ts +25 -0
- package/dist/runtime/for-component.d.ts.map +1 -0
- package/dist/runtime/for-component.js +35 -0
- package/dist/runtime/for-component.js.map +1 -0
- package/dist/runtime/literal-map.d.ts +22 -0
- package/dist/runtime/literal-map.d.ts.map +1 -0
- package/dist/runtime/literal-map.js +29 -0
- package/dist/runtime/literal-map.js.map +1 -0
- package/dist/runtime/rest-directive.d.ts +28 -0
- package/dist/runtime/rest-directive.d.ts.map +1 -0
- package/dist/runtime/rest-directive.js +49 -0
- package/dist/runtime/rest-directive.js.map +1 -0
- package/dist/runtime/show-component.d.ts +33 -0
- package/dist/runtime/show-component.d.ts.map +1 -0
- package/dist/runtime/show-component.js +30 -0
- package/dist/runtime/show-component.js.map +1 -0
- package/dist/runtime/tagged-template.d.ts +12 -0
- package/dist/runtime/tagged-template.d.ts.map +1 -0
- package/dist/runtime/tagged-template.js +12 -0
- package/dist/runtime/tagged-template.js.map +1 -0
- package/dist/runtime/type-helpers.d.ts +80 -0
- package/dist/runtime/type-helpers.d.ts.map +1 -0
- package/dist/runtime/type-helpers.js +85 -0
- package/dist/runtime/type-helpers.js.map +1 -0
- package/dist/shared/jsx-types.d.ts +2139 -0
- package/dist/shared/jsx-types.d.ts.map +1 -0
- package/dist/shared/jsx-types.js +2 -0
- package/dist/shared/jsx-types.js.map +1 -0
- package/dist/shared/jsx-utils.d.ts +30 -0
- package/dist/shared/jsx-utils.d.ts.map +1 -0
- package/dist/shared/jsx-utils.js +58 -0
- package/dist/shared/jsx-utils.js.map +1 -0
- package/dist/shared/mathml-tags.d.ts +12 -0
- package/dist/shared/mathml-tags.d.ts.map +1 -0
- package/dist/shared/mathml-tags.js +215 -0
- package/dist/shared/mathml-tags.js.map +1 -0
- package/dist/shared/svg-tags.d.ts +13 -0
- package/dist/shared/svg-tags.d.ts.map +1 -0
- package/dist/shared/svg-tags.js +95 -0
- package/dist/shared/svg-tags.js.map +1 -0
- package/dist/utils.d.ts +30 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +30 -0
- package/dist/utils.js.map +1 -0
- package/package.json +52 -0
- package/src/compiler/attribute-processor.ts +579 -0
- package/src/compiler/babel-preset.ts +34 -0
- package/src/compiler/builder.ts +86 -0
- package/src/compiler/compiler-utils.ts +789 -0
- package/src/compiler/config.ts +77 -0
- package/src/compiler/postprocess.ts +7 -0
- package/src/compiler/preprocess.ts +40 -0
- package/src/compiler/transform-jsx.ts +36 -0
- package/src/compiler/transpiler.ts +644 -0
- package/src/compiler/vite-plugin.ts +114 -0
- package/src/external.d.ts +9 -0
- package/src/runtime/choose-component.ts +53 -0
- package/src/runtime/compiler-ctors.ts +28 -0
- package/src/runtime/for-component.ts +54 -0
- package/src/runtime/literal-map.ts +37 -0
- package/src/runtime/rest-directive.ts +66 -0
- package/src/runtime/show-component.ts +48 -0
- package/src/runtime/tagged-template.ts +11 -0
- package/src/runtime/type-helpers.ts +91 -0
- package/src/shared/jsx-types.ts +2556 -0
- package/src/shared/jsx-utils.ts +85 -0
- package/src/shared/mathml-tags.ts +235 -0
- package/src/shared/svg-tags.ts +103 -0
- package/src/tsconfig.json +4 -0
- package/src/utils.ts +30 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
|
|
3
|
+
import { CreateCompiledPart } from './attribute-processor.js';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export class TemplateBuilder {
|
|
7
|
+
|
|
8
|
+
protected currentQuasi: string[] = [];
|
|
9
|
+
protected quasis: t.TemplateElement[] = [];
|
|
10
|
+
protected expressions: (t.Expression | t.TSType)[] = [];
|
|
11
|
+
|
|
12
|
+
protected commitQuasi(): void {
|
|
13
|
+
this.quasis.push(t.templateElement({ raw: this.currentQuasi.join(''), cooked: '' }));
|
|
14
|
+
this.currentQuasi.length = 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
addText(text: string): void {
|
|
18
|
+
this.currentQuasi.push(text);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
addExpression(expression: t.Expression): void {
|
|
22
|
+
this.commitQuasi();
|
|
23
|
+
this.expressions.push(expression);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
createTaggedTemplate(identifier: string): t.TaggedTemplateExpression {
|
|
27
|
+
if (this.currentQuasi.length)
|
|
28
|
+
this.commitQuasi();
|
|
29
|
+
|
|
30
|
+
const ttl = t.taggedTemplateExpression(
|
|
31
|
+
t.identifier(identifier),
|
|
32
|
+
t.templateLiteral(this.quasis, this.expressions),
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
this.quasis = [];
|
|
36
|
+
this.expressions = [];
|
|
37
|
+
|
|
38
|
+
return ttl;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
export class CompiledBuilder {
|
|
45
|
+
|
|
46
|
+
protected templateText: string = '';
|
|
47
|
+
protected parts: t.ObjectExpression[] = [];
|
|
48
|
+
protected values: t.Expression[] = [];
|
|
49
|
+
|
|
50
|
+
addText(text: string): void {
|
|
51
|
+
this.templateText += text;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
addPart(part: t.ObjectExpression): void {
|
|
55
|
+
this.parts.push(part);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
addValue(value: t.Expression): void {
|
|
59
|
+
this.values.push(value);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
addChild(index: number, value: t.Expression): void {
|
|
63
|
+
this.addPart(CreateCompiledPart.child(index));
|
|
64
|
+
this.addValue(value);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
createCompiledTemplate(): t.ObjectExpression {
|
|
68
|
+
const taggedTemplate = t.taggedTemplateExpression(
|
|
69
|
+
t.identifier('__$t'),
|
|
70
|
+
t.templateLiteral([ t.templateElement({ raw: this.templateText }) ], []),
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
return t.objectExpression([
|
|
74
|
+
t.objectProperty(t.stringLiteral('h'), taggedTemplate),
|
|
75
|
+
t.objectProperty(t.stringLiteral('parts'), t.arrayExpression(this.parts)),
|
|
76
|
+
]);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
createExpression(variableName: string): t.ObjectExpression {
|
|
80
|
+
return t.objectExpression([
|
|
81
|
+
t.objectProperty(t.stringLiteral('_$litType$'), t.identifier(variableName)),
|
|
82
|
+
t.objectProperty(t.stringLiteral('values'), t.arrayExpression(this.values)),
|
|
83
|
+
]);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
}
|