@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,77 @@
|
|
|
1
|
+
export declare const COMPONENT_LITERAL_PREFIX = "__$";
|
|
2
|
+
export declare const COMPONENT_POSTFIX = ".tag";
|
|
3
|
+
export declare const WHITESPACE_TAGS: string[];
|
|
4
|
+
export declare const SPECIAL_TAGS: string[];
|
|
5
|
+
export declare const ATTR_NAMES: {
|
|
6
|
+
readonly REF: "ref";
|
|
7
|
+
readonly CLASS_LIST: "classList";
|
|
8
|
+
readonly STYLE_LIST: "styleList";
|
|
9
|
+
readonly DIRECTIVE: "directive";
|
|
10
|
+
readonly EVENT_PREFIX: "on-";
|
|
11
|
+
};
|
|
12
|
+
export declare const ATTR_BIND_OBJ_NAME = "as";
|
|
13
|
+
export declare const ATTR_VALUES: {
|
|
14
|
+
readonly BOOL: "bool";
|
|
15
|
+
readonly PROP: "prop";
|
|
16
|
+
};
|
|
17
|
+
export declare const VARIABLES: {
|
|
18
|
+
readonly HTML: "html";
|
|
19
|
+
readonly HTML_STATIC: "htmlStatic";
|
|
20
|
+
readonly SVG: "svg";
|
|
21
|
+
readonly SVG_STATIC: "svgStatic";
|
|
22
|
+
readonly MATHML: "mathml";
|
|
23
|
+
readonly MATHML_STATIC: "mathmlStatic";
|
|
24
|
+
readonly UNSAFE_STATIC: "unsafeStatic";
|
|
25
|
+
readonly CLASS_MAP: "classMap";
|
|
26
|
+
readonly STYLE_MAP: "styleMap";
|
|
27
|
+
readonly REF: "ref";
|
|
28
|
+
readonly REST: "__$rest";
|
|
29
|
+
readonly LITERAL_MAP: "__$literalMap";
|
|
30
|
+
readonly TAGGED_TEMPLATE_UTIL: "__$t";
|
|
31
|
+
readonly BOOLEAN_PART: "BooleanPart";
|
|
32
|
+
readonly ATTRIBUTE_PART: "AttributePart";
|
|
33
|
+
readonly PROPERTY_PART: "PropertyPart";
|
|
34
|
+
readonly ELEMENT_PART: "ElementPart";
|
|
35
|
+
readonly EVENT_PART: "EventPart";
|
|
36
|
+
readonly CHILD_PART: "ChildPart";
|
|
37
|
+
};
|
|
38
|
+
export declare const SOURCES: {
|
|
39
|
+
readonly HTML: "lit-html";
|
|
40
|
+
readonly HTML_ALT: "lit";
|
|
41
|
+
readonly HTML_STATIC: "lit-html/static.js";
|
|
42
|
+
readonly HTML_STATIC_ALT: "lit/static-html.js";
|
|
43
|
+
readonly SVG: "lit-html/directives/svg.js";
|
|
44
|
+
readonly SVG_ALT: "lit/directives/svg.js";
|
|
45
|
+
readonly MATHML: "lit-html/directives/mathml.js";
|
|
46
|
+
readonly MATHML_ALT: "lit/directives/mathml.js";
|
|
47
|
+
readonly SVG_STATIC: "lit-html/static.js";
|
|
48
|
+
readonly SVG_STATIC_ALT: "lit/static-html.js";
|
|
49
|
+
readonly MATHML_STATIC: "lit-html/static.js";
|
|
50
|
+
readonly MATHML_STATIC_ALT: "lit/static-html.js";
|
|
51
|
+
readonly UNSAFE_STATIC: "lit-html/static.js";
|
|
52
|
+
readonly UNSAFE_STATIC_ALT: "lit/static-html.js";
|
|
53
|
+
readonly REF: "lit-html/directives/ref.js";
|
|
54
|
+
readonly REF_ALT: "lit/directives/ref.js";
|
|
55
|
+
readonly CLASS_MAP: "lit-html/directives/class-map.js";
|
|
56
|
+
readonly CLASS_MAP_ALT: "lit/directives/class-map.js";
|
|
57
|
+
readonly STYLE_MAP: "lit-html/directives/style-map.js";
|
|
58
|
+
readonly STYLE_MAP_ALT: "lit/directives/style-map.js";
|
|
59
|
+
readonly REST: "jsx-lit";
|
|
60
|
+
readonly LITERAL_MAP: "jsx-lit";
|
|
61
|
+
readonly JSX_LIT: "jsx-lit";
|
|
62
|
+
};
|
|
63
|
+
export declare const ERROR_MESSAGES: {
|
|
64
|
+
readonly NO_PROGRAM_FOUND: "No program found for JSX transformation.";
|
|
65
|
+
readonly INVALID_OPENING_TAG: "Invalid opening tag found.";
|
|
66
|
+
readonly EMPTY_JSX_EXPRESSION: "Empty JSX expression found.";
|
|
67
|
+
readonly ONLY_STRING_LITERALS: "Only string literals are supported for JSX attributes.";
|
|
68
|
+
readonly INVALID_DIRECTIVE_VALUE: "Invalid value in directive expression.";
|
|
69
|
+
readonly UNKNOWN_JSX_ATTRIBUTE_TYPE: "Unknown JSX attribute type found.";
|
|
70
|
+
readonly EMPTY_EXPRESSION: "Empty expression found in JSX.";
|
|
71
|
+
readonly IDENTIFIER_NOT_FOUND: (name: string) => string;
|
|
72
|
+
readonly TAG_NAME_NOT_FOUND: (tagName: string) => string;
|
|
73
|
+
readonly NO_STATEMENT_PATH: (tagName: string) => string;
|
|
74
|
+
readonly UNKNOWN_TEMPLATE_TYPE: (type: string) => string;
|
|
75
|
+
readonly INVALID_BIND_TYPE: (type: string) => string;
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/compiler/config.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,wBAAwB,QAAQ,CAAC;AAC9C,eAAO,MAAM,iBAAiB,SAAS,CAAC;AACxC,eAAO,MAAM,eAAe,EAAE,MAAM,EAA0B,CAAC;AAC/D,eAAO,MAAM,YAAY,EAAE,MAAM,EAAO,CAAC;AACzC,eAAO,MAAM,UAAU;;;;;;CAMb,CAAC;AACX,eAAO,MAAM,kBAAkB,OAAO,CAAC;AACvC,eAAO,MAAM,WAAW;;;CAGd,CAAC;AACX,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;CAoBZ,CAAC;AACX,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;CAwBV,CAAC;AACX,eAAO,MAAM,cAAc;;;;;;;;0CAQS,MAAM,KAAG,MAAM;2CACZ,MAAM,KAAG,MAAM;0CACf,MAAM,KAAG,MAAM;2CAClB,MAAM,KAAG,MAAM;uCACf,MAAM,KAAG,MAAM;CACzC,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
//
|
|
2
|
+
export const COMPONENT_LITERAL_PREFIX = '__$';
|
|
3
|
+
export const COMPONENT_POSTFIX = '.tag';
|
|
4
|
+
export const WHITESPACE_TAGS = ['pre', 'textarea'];
|
|
5
|
+
export const SPECIAL_TAGS = [];
|
|
6
|
+
export const ATTR_NAMES = {
|
|
7
|
+
REF: 'ref',
|
|
8
|
+
CLASS_LIST: 'classList',
|
|
9
|
+
STYLE_LIST: 'styleList',
|
|
10
|
+
DIRECTIVE: 'directive',
|
|
11
|
+
EVENT_PREFIX: 'on-',
|
|
12
|
+
};
|
|
13
|
+
export const ATTR_BIND_OBJ_NAME = 'as';
|
|
14
|
+
export const ATTR_VALUES = {
|
|
15
|
+
BOOL: 'bool',
|
|
16
|
+
PROP: 'prop',
|
|
17
|
+
};
|
|
18
|
+
export const VARIABLES = {
|
|
19
|
+
HTML: 'html',
|
|
20
|
+
HTML_STATIC: 'htmlStatic',
|
|
21
|
+
SVG: 'svg',
|
|
22
|
+
SVG_STATIC: 'svgStatic',
|
|
23
|
+
MATHML: 'mathml',
|
|
24
|
+
MATHML_STATIC: 'mathmlStatic',
|
|
25
|
+
UNSAFE_STATIC: 'unsafeStatic',
|
|
26
|
+
CLASS_MAP: 'classMap',
|
|
27
|
+
STYLE_MAP: 'styleMap',
|
|
28
|
+
REF: 'ref',
|
|
29
|
+
REST: '__$rest',
|
|
30
|
+
LITERAL_MAP: '__$literalMap',
|
|
31
|
+
TAGGED_TEMPLATE_UTIL: '__$t',
|
|
32
|
+
BOOLEAN_PART: 'BooleanPart',
|
|
33
|
+
ATTRIBUTE_PART: 'AttributePart',
|
|
34
|
+
PROPERTY_PART: 'PropertyPart',
|
|
35
|
+
ELEMENT_PART: 'ElementPart',
|
|
36
|
+
EVENT_PART: 'EventPart',
|
|
37
|
+
CHILD_PART: 'ChildPart',
|
|
38
|
+
};
|
|
39
|
+
export const SOURCES = {
|
|
40
|
+
HTML: 'lit-html',
|
|
41
|
+
HTML_ALT: 'lit',
|
|
42
|
+
HTML_STATIC: 'lit-html/static.js',
|
|
43
|
+
HTML_STATIC_ALT: 'lit/static-html.js',
|
|
44
|
+
SVG: 'lit-html/directives/svg.js',
|
|
45
|
+
SVG_ALT: 'lit/directives/svg.js',
|
|
46
|
+
MATHML: 'lit-html/directives/mathml.js',
|
|
47
|
+
MATHML_ALT: 'lit/directives/mathml.js',
|
|
48
|
+
SVG_STATIC: 'lit-html/static.js',
|
|
49
|
+
SVG_STATIC_ALT: 'lit/static-html.js',
|
|
50
|
+
MATHML_STATIC: 'lit-html/static.js',
|
|
51
|
+
MATHML_STATIC_ALT: 'lit/static-html.js',
|
|
52
|
+
UNSAFE_STATIC: 'lit-html/static.js',
|
|
53
|
+
UNSAFE_STATIC_ALT: 'lit/static-html.js',
|
|
54
|
+
REF: 'lit-html/directives/ref.js',
|
|
55
|
+
REF_ALT: 'lit/directives/ref.js',
|
|
56
|
+
CLASS_MAP: 'lit-html/directives/class-map.js',
|
|
57
|
+
CLASS_MAP_ALT: 'lit/directives/class-map.js',
|
|
58
|
+
STYLE_MAP: 'lit-html/directives/style-map.js',
|
|
59
|
+
STYLE_MAP_ALT: 'lit/directives/style-map.js',
|
|
60
|
+
REST: 'jsx-lit',
|
|
61
|
+
LITERAL_MAP: 'jsx-lit',
|
|
62
|
+
JSX_LIT: 'jsx-lit',
|
|
63
|
+
};
|
|
64
|
+
export const ERROR_MESSAGES = {
|
|
65
|
+
NO_PROGRAM_FOUND: 'No program found for JSX transformation.',
|
|
66
|
+
INVALID_OPENING_TAG: 'Invalid opening tag found.',
|
|
67
|
+
EMPTY_JSX_EXPRESSION: 'Empty JSX expression found.',
|
|
68
|
+
ONLY_STRING_LITERALS: 'Only string literals are supported for JSX attributes.',
|
|
69
|
+
INVALID_DIRECTIVE_VALUE: 'Invalid value in directive expression.',
|
|
70
|
+
UNKNOWN_JSX_ATTRIBUTE_TYPE: 'Unknown JSX attribute type found.',
|
|
71
|
+
EMPTY_EXPRESSION: 'Empty expression found in JSX.',
|
|
72
|
+
IDENTIFIER_NOT_FOUND: (name) => `Identifier '${name}' not found in any accessible scope`,
|
|
73
|
+
TAG_NAME_NOT_FOUND: (tagName) => `Tag name '${tagName}' not found in any accessible scope`,
|
|
74
|
+
NO_STATEMENT_PATH: (tagName) => `Could not find statement-level path for tagName: ${tagName}`,
|
|
75
|
+
UNKNOWN_TEMPLATE_TYPE: (type) => `Unknown template type: ${type}`,
|
|
76
|
+
INVALID_BIND_TYPE: (type) => `Invalid bind type: ${type}`,
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/compiler/config.ts"],"names":[],"mappings":"AAAA,EAAE;AACF,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAC9C,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACxC,MAAM,CAAC,MAAM,eAAe,GAAa,CAAE,KAAK,EAAE,UAAU,CAAE,CAAC;AAC/D,MAAM,CAAC,MAAM,YAAY,GAAa,EAAE,CAAC;AACzC,MAAM,CAAC,MAAM,UAAU,GAAG;IACzB,GAAG,EAAW,KAAK;IACnB,UAAU,EAAI,WAAW;IACzB,UAAU,EAAI,WAAW;IACzB,SAAS,EAAK,WAAW;IACzB,YAAY,EAAE,KAAK;CACV,CAAC;AACX,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC;AACvC,MAAM,CAAC,MAAM,WAAW,GAAG;IAC1B,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;CACH,CAAC;AACX,MAAM,CAAC,MAAM,SAAS,GAAG;IACxB,IAAI,EAAkB,MAAM;IAC5B,WAAW,EAAW,YAAY;IAClC,GAAG,EAAmB,KAAK;IAC3B,UAAU,EAAY,WAAW;IACjC,MAAM,EAAgB,QAAQ;IAC9B,aAAa,EAAS,cAAc;IACpC,aAAa,EAAS,cAAc;IACpC,SAAS,EAAa,UAAU;IAChC,SAAS,EAAa,UAAU;IAChC,GAAG,EAAmB,KAAK;IAC3B,IAAI,EAAkB,SAAS;IAC/B,WAAW,EAAW,eAAe;IACrC,oBAAoB,EAAE,MAAM;IAC5B,YAAY,EAAU,aAAa;IACnC,cAAc,EAAQ,eAAe;IACrC,aAAa,EAAS,cAAc;IACpC,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AY,EAAU,EAAE,CAAC,0BAA2B,IAAK,EAAE;IACxF,iBAAiB,EAAW,CAAC,IAAY,EAAU,EAAE,CAAC,sBAAuB,IAAK,EAAE;CAC3E,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PluginPass } from '@babel/core';
|
|
2
|
+
import type { VisitNodeFunction } from '@babel/traverse';
|
|
3
|
+
import type { Program } from '@babel/types';
|
|
4
|
+
export declare const postprocess: VisitNodeFunction<PluginPass, Program>;
|
|
5
|
+
//# sourceMappingURL=postprocess.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postprocess.d.ts","sourceRoot":"","sources":["../../src/compiler/postprocess.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG5C,eAAO,MAAM,WAAW,EAAE,iBAAiB,CAAC,UAAU,EAAE,OAAO,CAC9D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postprocess.js","sourceRoot":"","sources":["../../src/compiler/postprocess.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,WAAW,GAA2C,CAAC,GAAG,IAAI,EAAQ,EAAE;AACrF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preprocess.d.ts","sourceRoot":"","sources":["../../src/compiler/preprocess.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAiC,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAmC3E,eAAO,MAAM,UAAU,EAAE,iBAAiB,CAAC,UAAU,EAAE,OAAO,CAE7D,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { isJSXElement, isJSXIdentifier } from '@babel/types';
|
|
2
|
+
import { isValidHTMLNesting } from 'validate-html-nesting';
|
|
3
|
+
import { isComponent } from './compiler-utils.js';
|
|
4
|
+
// From https://github.com/MananTank/babel-plugin-validate-jsx-nesting/blob/main/src/index.js
|
|
5
|
+
const JSXValidator = {
|
|
6
|
+
JSXElement(path) {
|
|
7
|
+
const elName = path.node.openingElement.name;
|
|
8
|
+
const parent = path.parent;
|
|
9
|
+
if (!isJSXElement(parent) || !isJSXIdentifier(elName))
|
|
10
|
+
return;
|
|
11
|
+
const elTagName = elName.name;
|
|
12
|
+
if (isComponent(elTagName))
|
|
13
|
+
return;
|
|
14
|
+
const parentElName = parent.openingElement.name;
|
|
15
|
+
if (!isJSXIdentifier(parentElName))
|
|
16
|
+
return;
|
|
17
|
+
const parentElTagName = parentElName.name;
|
|
18
|
+
if (!isComponent(parentElTagName)) {
|
|
19
|
+
if (!isValidHTMLNesting(parentElTagName, elTagName)) {
|
|
20
|
+
throw path.buildCodeFrameError(`Invalid JSX: <${elTagName}> cannot be child of <${parentElTagName}>`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
export const preprocess = (path, state) => {
|
|
26
|
+
path.traverse(JSXValidator);
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=preprocess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preprocess.js","sourceRoot":"","sources":["../../src/compiler/preprocess.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAgB,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD,6FAA6F;AAC7F,MAAM,YAAY,GAAG;IACpB,UAAU,CAAC,IAAS;QACnB,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;QAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAE3B,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC;YACpD,OAAO;QAER,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC;QAC9B,IAAI,WAAW,CAAC,SAAS,CAAC;YACzB,OAAO;QAER,MAAM,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC;QAChD,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC;YACjC,OAAO;QAER,MAAM,eAAe,GAAG,YAAY,CAAC,IAAI,CAAC;QAC1C,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,EAAE,CAAC;YACnC,IAAI,CAAC,kBAAkB,CAAC,eAAe,EAAE,SAAS,CAAC,EAAE,CAAC;gBACrD,MAAM,IAAI,CAAC,mBAAmB,CAC9B,iBAAkB,SAAU,yBAA0B,eAAgB,GAAG,CACxE,CAAC;YACH,CAAC;QACF,CAAC;IACF,CAAC;CACD,CAAC;AAGF,MAAM,CAAC,MAAM,UAAU,GAA2C,CAAC,IAAI,EAAE,KAAK,EAAQ,EAAE;IACvF,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AAC7B,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type PluginPass } from '@babel/core';
|
|
2
|
+
import type { VisitNode } from '@babel/traverse';
|
|
3
|
+
import * as t from '@babel/types';
|
|
4
|
+
export declare const transformJSXElement: VisitNode<PluginPass, t.JSXElement | t.JSXFragment>;
|
|
5
|
+
//# sourceMappingURL=transform-jsx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-jsx.d.ts","sourceRoot":"","sources":["../../src/compiler/transform-jsx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAY,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAMlC,eAAO,MAAM,mBAAmB,EAAE,SAAS,CAC1C,UAAU,EAAE,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,WAAW,CAWxC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {} from '@babel/core';
|
|
2
|
+
import * as t from '@babel/types';
|
|
3
|
+
import { getTemplateType, isJSXElementStatic, isJSXFunctionElementComponent } from './compiler-utils.js';
|
|
4
|
+
import { CompiledTranspiler, TemplateTranspiler } from './transpiler.js';
|
|
5
|
+
export const transformJSXElement = (path) => {
|
|
6
|
+
// If the parent is a JSX element, we do not need to transform it.
|
|
7
|
+
// The below condition will handle the case where the JSX element
|
|
8
|
+
// is nested inside another JSX element.
|
|
9
|
+
if (t.isJSXElement(path.parent) || t.isJSXFragment(path.parent))
|
|
10
|
+
return;
|
|
11
|
+
// If the parent is not a JSX element,
|
|
12
|
+
// we need to wrap the JSX in a tagged template expression
|
|
13
|
+
return void path.replaceWith(processJSXElement(path));
|
|
14
|
+
};
|
|
15
|
+
const processJSXElement = (path) => {
|
|
16
|
+
const isStatic = isJSXElementStatic(path);
|
|
17
|
+
const templateType = getTemplateType(path);
|
|
18
|
+
const isFunctionComponent = isJSXFunctionElementComponent(path);
|
|
19
|
+
if (isFunctionComponent)
|
|
20
|
+
return new TemplateTranspiler().createFunctionalComponent(path);
|
|
21
|
+
if (isStatic || templateType !== 'html')
|
|
22
|
+
return new TemplateTranspiler().start(path);
|
|
23
|
+
return new CompiledTranspiler().start(path);
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=transform-jsx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-jsx.js","sourceRoot":"","sources":["../../src/compiler/transform-jsx.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+
import { type ProcessorContext } from './attribute-processor.js';
|
|
4
|
+
import { CompiledBuilder, TemplateBuilder } from './builder.js';
|
|
5
|
+
declare abstract class JSXTranspiler<TContext extends ProcessorContext> {
|
|
6
|
+
protected abstract createContext(path: NodePath<t.JSXElement | t.JSXFragment>): TContext;
|
|
7
|
+
start(path: NodePath<t.JSXElement | t.JSXFragment>): t.Expression;
|
|
8
|
+
abstract process(context: TContext): void;
|
|
9
|
+
abstract openingTag(context: TContext): void;
|
|
10
|
+
abstract attributes(context: TContext): void;
|
|
11
|
+
abstract children(context: TContext): void;
|
|
12
|
+
abstract closingTag(context: TContext): void;
|
|
13
|
+
abstract createExpression(context: TContext): t.Expression;
|
|
14
|
+
abstract createFunctionalComponent(path: NodePath<t.JSXElement | t.JSXFragment>): t.Expression;
|
|
15
|
+
abstract functionalComponent(context: TContext): void;
|
|
16
|
+
}
|
|
17
|
+
export interface TemplateContext extends ProcessorContext {
|
|
18
|
+
builder: TemplateBuilder;
|
|
19
|
+
literalName: string;
|
|
20
|
+
}
|
|
21
|
+
export declare class TemplateTranspiler extends JSXTranspiler<TemplateContext> {
|
|
22
|
+
protected createContext(path: NodePath<t.JSXElement | t.JSXFragment>): TemplateContext;
|
|
23
|
+
process(context: TemplateContext): void;
|
|
24
|
+
openingTag(context: TemplateContext): void;
|
|
25
|
+
attributes(context: TemplateContext): void;
|
|
26
|
+
children(context: TemplateContext): void;
|
|
27
|
+
closingTag(context: TemplateContext): void;
|
|
28
|
+
createExpression(context: TemplateContext): t.Expression;
|
|
29
|
+
createFunctionalComponent(path: NodePath<t.JSXElement | t.JSXFragment>): t.Expression;
|
|
30
|
+
functionalComponent(context: TemplateContext): void;
|
|
31
|
+
}
|
|
32
|
+
export interface CompiledContext extends ProcessorContext {
|
|
33
|
+
builder: CompiledBuilder;
|
|
34
|
+
currentIndex: number;
|
|
35
|
+
}
|
|
36
|
+
export declare class CompiledTranspiler extends JSXTranspiler<CompiledContext> {
|
|
37
|
+
protected createContext(path: NodePath<t.JSXElement | t.JSXFragment>): CompiledContext;
|
|
38
|
+
process(context: CompiledContext): void;
|
|
39
|
+
openingTag(context: CompiledContext): void;
|
|
40
|
+
attributes(context: CompiledContext): void;
|
|
41
|
+
children(context: CompiledContext): void;
|
|
42
|
+
closingTag(context: CompiledContext): void;
|
|
43
|
+
createExpression(context: CompiledContext): t.Expression;
|
|
44
|
+
createFunctionalComponent(path: NodePath<t.JSXElement | t.JSXFragment>): t.Expression;
|
|
45
|
+
functionalComponent(context: CompiledContext): void;
|
|
46
|
+
}
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=transpiler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transpiler.d.ts","sourceRoot":"","sources":["../../src/compiler/transpiler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAElC,OAAO,EAGN,KAAK,gBAAgB,EAErB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAyBhE,uBAAe,aAAa,CAAC,QAAQ,SAAS,gBAAgB;IAE7D,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,WAAW,CAAC,GAAG,QAAQ;IAExF,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU;IAYjE,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI;IACzC,QAAQ,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI;IAC5C,QAAQ,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI;IAC5C,QAAQ,CAAC,QA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