@tsrx/core 0.1.6 → 0.1.8
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 +25 -10
- package/src/index.js +1 -2
- package/src/plugin.js +185 -104
- package/src/runtime/events.js +10 -0
- package/src/runtime/hash.js +1 -0
- package/src/runtime/html.js +3 -0
- package/src/transform/jsx/index.js +29 -47
- package/src/transform/lazy.js +289 -152
- package/src/utils/ast.js +13 -0
- package/src/utils/dom.js +158 -0
- package/src/utils.js +6 -159
- package/types/index.d.ts +1 -0
- package/types/jsx-platform.d.ts +4 -2
- package/types/runtime/events.d.ts +11 -0
- package/types/runtime/hash.d.ts +2 -0
- package/types/runtime/html.d.ts +4 -0
- package/types/runtime/language-helpers.d.ts +17 -0
- /package/src/runtime/{index.js → iterable.js} +0 -0
- /package/types/runtime/{index.d.ts → iterable.d.ts} +0 -0
package/src/utils/dom.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
const VOID_ELEMENT_NAMES = [
|
|
2
|
+
'area',
|
|
3
|
+
'base',
|
|
4
|
+
'br',
|
|
5
|
+
'col',
|
|
6
|
+
'command',
|
|
7
|
+
'embed',
|
|
8
|
+
'hr',
|
|
9
|
+
'img',
|
|
10
|
+
'input',
|
|
11
|
+
'keygen',
|
|
12
|
+
'link',
|
|
13
|
+
'meta',
|
|
14
|
+
'param',
|
|
15
|
+
'source',
|
|
16
|
+
'track',
|
|
17
|
+
'wbr',
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Returns true if name is a void element
|
|
22
|
+
* @param {string} name
|
|
23
|
+
* @returns {boolean}
|
|
24
|
+
*/
|
|
25
|
+
export function is_void_element(name) {
|
|
26
|
+
return VOID_ELEMENT_NAMES.includes(name) || name.toLowerCase() === '!doctype';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const RESERVED_WORDS = [
|
|
30
|
+
'arguments',
|
|
31
|
+
'await',
|
|
32
|
+
'break',
|
|
33
|
+
'case',
|
|
34
|
+
'catch',
|
|
35
|
+
'class',
|
|
36
|
+
'const',
|
|
37
|
+
'continue',
|
|
38
|
+
'debugger',
|
|
39
|
+
'default',
|
|
40
|
+
'delete',
|
|
41
|
+
'do',
|
|
42
|
+
'else',
|
|
43
|
+
'enum',
|
|
44
|
+
'eval',
|
|
45
|
+
'export',
|
|
46
|
+
'extends',
|
|
47
|
+
'false',
|
|
48
|
+
'finally',
|
|
49
|
+
'for',
|
|
50
|
+
'function',
|
|
51
|
+
'if',
|
|
52
|
+
'implements',
|
|
53
|
+
'import',
|
|
54
|
+
'in',
|
|
55
|
+
'instanceof',
|
|
56
|
+
'interface',
|
|
57
|
+
'let',
|
|
58
|
+
'new',
|
|
59
|
+
'null',
|
|
60
|
+
'package',
|
|
61
|
+
'private',
|
|
62
|
+
'protected',
|
|
63
|
+
'public',
|
|
64
|
+
'return',
|
|
65
|
+
'static',
|
|
66
|
+
'super',
|
|
67
|
+
'switch',
|
|
68
|
+
'this',
|
|
69
|
+
'throw',
|
|
70
|
+
'true',
|
|
71
|
+
'try',
|
|
72
|
+
'typeof',
|
|
73
|
+
'var',
|
|
74
|
+
'void',
|
|
75
|
+
'while',
|
|
76
|
+
'with',
|
|
77
|
+
'yield',
|
|
78
|
+
];
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Returns true if word is a reserved JS keyword
|
|
82
|
+
* @param {string} word
|
|
83
|
+
* @returns {boolean}
|
|
84
|
+
*/
|
|
85
|
+
export function is_reserved(word) {
|
|
86
|
+
return RESERVED_WORDS.includes(word);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Attributes that are boolean, i.e. they are present or not present.
|
|
91
|
+
*/
|
|
92
|
+
const DOM_BOOLEAN_ATTRIBUTES = [
|
|
93
|
+
'allowfullscreen',
|
|
94
|
+
'async',
|
|
95
|
+
'autofocus',
|
|
96
|
+
'autoplay',
|
|
97
|
+
'checked',
|
|
98
|
+
'controls',
|
|
99
|
+
'default',
|
|
100
|
+
'disabled',
|
|
101
|
+
'formnovalidate',
|
|
102
|
+
'hidden',
|
|
103
|
+
'indeterminate',
|
|
104
|
+
'inert',
|
|
105
|
+
'ismap',
|
|
106
|
+
'loop',
|
|
107
|
+
'multiple',
|
|
108
|
+
'muted',
|
|
109
|
+
'nomodule',
|
|
110
|
+
'novalidate',
|
|
111
|
+
'open',
|
|
112
|
+
'playsinline',
|
|
113
|
+
'readonly',
|
|
114
|
+
'required',
|
|
115
|
+
'reversed',
|
|
116
|
+
'seamless',
|
|
117
|
+
'selected',
|
|
118
|
+
'webkitdirectory',
|
|
119
|
+
'defer',
|
|
120
|
+
'disablepictureinpicture',
|
|
121
|
+
'disableremoteplayback',
|
|
122
|
+
];
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Returns true if name is a boolean DOM attribute
|
|
126
|
+
* @param {string} name
|
|
127
|
+
* @returns {boolean}
|
|
128
|
+
*/
|
|
129
|
+
export function is_boolean_attribute(name) {
|
|
130
|
+
return DOM_BOOLEAN_ATTRIBUTES.includes(name);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const DOM_PROPERTIES = [
|
|
134
|
+
...DOM_BOOLEAN_ATTRIBUTES,
|
|
135
|
+
'formNoValidate',
|
|
136
|
+
'isMap',
|
|
137
|
+
'noModule',
|
|
138
|
+
'playsInline',
|
|
139
|
+
'readOnly',
|
|
140
|
+
'value',
|
|
141
|
+
'volume',
|
|
142
|
+
'defaultValue',
|
|
143
|
+
'defaultChecked',
|
|
144
|
+
'srcObject',
|
|
145
|
+
'noValidate',
|
|
146
|
+
'allowFullscreen',
|
|
147
|
+
'disablePictureInPicture',
|
|
148
|
+
'disableRemotePlayback',
|
|
149
|
+
];
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Returns true if name is a DOM property
|
|
153
|
+
* @param {string} name
|
|
154
|
+
* @returns {boolean}
|
|
155
|
+
*/
|
|
156
|
+
export function is_dom_property(name) {
|
|
157
|
+
return DOM_PROPERTIES.includes(name);
|
|
158
|
+
}
|
package/src/utils.js
CHANGED
|
@@ -4,162 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
export { simple_hash, strong_hash } from './utils/hashing.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
'command',
|
|
14
|
-
'embed',
|
|
15
|
-
'hr',
|
|
16
|
-
'img',
|
|
17
|
-
'input',
|
|
18
|
-
'keygen',
|
|
19
|
-
'link',
|
|
20
|
-
'meta',
|
|
21
|
-
'param',
|
|
22
|
-
'source',
|
|
23
|
-
'track',
|
|
24
|
-
'wbr',
|
|
25
|
-
];
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Returns true if name is a void element
|
|
29
|
-
* @param {string} name
|
|
30
|
-
* @returns {boolean}
|
|
31
|
-
*/
|
|
32
|
-
export function is_void_element(name) {
|
|
33
|
-
return VOID_ELEMENT_NAMES.includes(name) || name.toLowerCase() === '!doctype';
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const RESERVED_WORDS = [
|
|
37
|
-
'arguments',
|
|
38
|
-
'await',
|
|
39
|
-
'break',
|
|
40
|
-
'case',
|
|
41
|
-
'catch',
|
|
42
|
-
'class',
|
|
43
|
-
'const',
|
|
44
|
-
'continue',
|
|
45
|
-
'debugger',
|
|
46
|
-
'default',
|
|
47
|
-
'delete',
|
|
48
|
-
'do',
|
|
49
|
-
'else',
|
|
50
|
-
'enum',
|
|
51
|
-
'eval',
|
|
52
|
-
'export',
|
|
53
|
-
'extends',
|
|
54
|
-
'false',
|
|
55
|
-
'finally',
|
|
56
|
-
'for',
|
|
57
|
-
'function',
|
|
58
|
-
'if',
|
|
59
|
-
'implements',
|
|
60
|
-
'import',
|
|
61
|
-
'in',
|
|
62
|
-
'instanceof',
|
|
63
|
-
'interface',
|
|
64
|
-
'let',
|
|
65
|
-
'new',
|
|
66
|
-
'null',
|
|
67
|
-
'package',
|
|
68
|
-
'private',
|
|
69
|
-
'protected',
|
|
70
|
-
'public',
|
|
71
|
-
'return',
|
|
72
|
-
'static',
|
|
73
|
-
'super',
|
|
74
|
-
'switch',
|
|
75
|
-
'this',
|
|
76
|
-
'throw',
|
|
77
|
-
'true',
|
|
78
|
-
'try',
|
|
79
|
-
'typeof',
|
|
80
|
-
'var',
|
|
81
|
-
'void',
|
|
82
|
-
'while',
|
|
83
|
-
'with',
|
|
84
|
-
'yield',
|
|
85
|
-
];
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Returns true if word is a reserved JS keyword
|
|
89
|
-
* @param {string} word
|
|
90
|
-
* @returns {boolean}
|
|
91
|
-
*/
|
|
92
|
-
export function is_reserved(word) {
|
|
93
|
-
return RESERVED_WORDS.includes(word);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Attributes that are boolean, i.e. they are present or not present.
|
|
98
|
-
*/
|
|
99
|
-
const DOM_BOOLEAN_ATTRIBUTES = [
|
|
100
|
-
'allowfullscreen',
|
|
101
|
-
'async',
|
|
102
|
-
'autofocus',
|
|
103
|
-
'autoplay',
|
|
104
|
-
'checked',
|
|
105
|
-
'controls',
|
|
106
|
-
'default',
|
|
107
|
-
'disabled',
|
|
108
|
-
'formnovalidate',
|
|
109
|
-
'hidden',
|
|
110
|
-
'indeterminate',
|
|
111
|
-
'inert',
|
|
112
|
-
'ismap',
|
|
113
|
-
'loop',
|
|
114
|
-
'multiple',
|
|
115
|
-
'muted',
|
|
116
|
-
'nomodule',
|
|
117
|
-
'novalidate',
|
|
118
|
-
'open',
|
|
119
|
-
'playsinline',
|
|
120
|
-
'readonly',
|
|
121
|
-
'required',
|
|
122
|
-
'reversed',
|
|
123
|
-
'seamless',
|
|
124
|
-
'selected',
|
|
125
|
-
'webkitdirectory',
|
|
126
|
-
'defer',
|
|
127
|
-
'disablepictureinpicture',
|
|
128
|
-
'disableremoteplayback',
|
|
129
|
-
];
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Returns true if name is a boolean DOM attribute
|
|
133
|
-
* @param {string} name
|
|
134
|
-
* @returns {boolean}
|
|
135
|
-
*/
|
|
136
|
-
export function is_boolean_attribute(name) {
|
|
137
|
-
return DOM_BOOLEAN_ATTRIBUTES.includes(name);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const DOM_PROPERTIES = [
|
|
141
|
-
...DOM_BOOLEAN_ATTRIBUTES,
|
|
142
|
-
'formNoValidate',
|
|
143
|
-
'isMap',
|
|
144
|
-
'noModule',
|
|
145
|
-
'playsInline',
|
|
146
|
-
'readOnly',
|
|
147
|
-
'value',
|
|
148
|
-
'volume',
|
|
149
|
-
'defaultValue',
|
|
150
|
-
'defaultChecked',
|
|
151
|
-
'srcObject',
|
|
152
|
-
'noValidate',
|
|
153
|
-
'allowFullscreen',
|
|
154
|
-
'disablePictureInPicture',
|
|
155
|
-
'disableRemotePlayback',
|
|
156
|
-
];
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Returns true if name is a DOM property
|
|
160
|
-
* @param {string} name
|
|
161
|
-
* @returns {boolean}
|
|
162
|
-
*/
|
|
163
|
-
export function is_dom_property(name) {
|
|
164
|
-
return DOM_PROPERTIES.includes(name);
|
|
165
|
-
}
|
|
7
|
+
export {
|
|
8
|
+
is_boolean_attribute,
|
|
9
|
+
is_dom_property,
|
|
10
|
+
is_reserved,
|
|
11
|
+
is_void_element,
|
|
12
|
+
} from './utils/dom.js';
|
package/types/index.d.ts
CHANGED
|
@@ -92,6 +92,7 @@ interface FunctionMetaData extends BaseNodeMetaData {
|
|
|
92
92
|
is_component?: boolean;
|
|
93
93
|
is_method?: boolean;
|
|
94
94
|
tracked?: boolean;
|
|
95
|
+
has_lazy_descendants?: boolean;
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
// Strip parent, loc, and range from TSESTree nodes to match @sveltejs/acorn-typescript output
|
package/types/jsx-platform.d.ts
CHANGED
|
@@ -306,8 +306,10 @@ export interface JsxPlatform {
|
|
|
306
306
|
* Module to import the `map_iterable` runtime helper (and the
|
|
307
307
|
* `IterationValue` type) from when compiling `for ... of` bodies whose
|
|
308
308
|
* source can be any `Iterable` — not just an array. React and Preact
|
|
309
|
-
* use `'@tsrx/
|
|
310
|
-
*
|
|
309
|
+
* use target-owned paths like `'@tsrx/react/runtime/iterable'` and
|
|
310
|
+
* `'@tsrx/preact/runtime/iterable'`, which re-export from
|
|
311
|
+
* `'@tsrx/core/runtime/iterable'`. Solid and Vue lower for-of via their
|
|
312
|
+
* own iteration components and leave this unset.
|
|
311
313
|
*/
|
|
312
314
|
forOfIterableHelper?: string;
|
|
313
315
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function event_name_from_capture(event_name: string): string;
|
|
2
|
+
export function get_attribute_event_name(
|
|
3
|
+
name: string,
|
|
4
|
+
handler: EventListener | { customName?: string },
|
|
5
|
+
): string;
|
|
6
|
+
export function get_original_event_name(name: string): string;
|
|
7
|
+
export function is_capture_event(event_name: string): boolean;
|
|
8
|
+
export function is_event_attribute(attr: string): boolean;
|
|
9
|
+
export function is_non_delegated(event_name: string): boolean;
|
|
10
|
+
export function is_passive_event(name: string): boolean;
|
|
11
|
+
export function normalize_event_name(name: string): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const get_descriptor: typeof Object.getOwnPropertyDescriptor;
|
|
2
|
+
export const get_descriptors: typeof Object.getOwnPropertyDescriptors;
|
|
3
|
+
export const array_from: typeof Array.from;
|
|
4
|
+
export const is_array: typeof Array.isArray;
|
|
5
|
+
export const define_property: typeof Object.defineProperty;
|
|
6
|
+
export const get_prototype_of: typeof Object.getPrototypeOf;
|
|
7
|
+
export const object_values: typeof Object.values;
|
|
8
|
+
export const object_entries: typeof Object.entries;
|
|
9
|
+
export const object_keys: typeof Object.keys;
|
|
10
|
+
export const get_own_property_symbols: typeof Object.getOwnPropertySymbols;
|
|
11
|
+
export const structured_clone: typeof structuredClone;
|
|
12
|
+
export const object_prototype: typeof Object.prototype;
|
|
13
|
+
export const array_prototype: typeof Array.prototype;
|
|
14
|
+
export const has_own_property: typeof Object.prototype.hasOwnProperty;
|
|
15
|
+
|
|
16
|
+
export function has_prototype_accessor(value: object, key: PropertyKey): boolean;
|
|
17
|
+
export function array_slice(array_like: ArrayLike<any>, ...args: number[]): any[];
|
|
File without changes
|
|
File without changes
|