@dom-expressions/runtime 0.50.0-next.15

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.
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Flags
3
+ *
4
+ * - 1 - Stateful property - value derives from reactive state
5
+ * - 2 - Locked to property - value not specially treated
6
+ */
7
+ export const DOMWithState: Record<string, Record<string, 1 | 2>>;
8
+
9
+ export const ChildProperties: Set<string>;
10
+
11
+ export const DelegatedEvents: Set<string>;
12
+
13
+ export const SVGElements: Set<string>;
14
+
15
+ export const MathMLElements: Set<string>;
16
+
17
+ export const VoidElements: Set<string>;
18
+
19
+ export const RawTextElements: Set<string>;
20
+
21
+ export const Namespaces: Record<string, string>;
22
+
23
+ export const DOMElements: Set<string>;
@@ -0,0 +1,517 @@
1
+ /**
2
+ * Flags
3
+ *
4
+ * - 1 - Stateful property - value derives from reactive state
5
+ * - 2 - Locked to property - value not specially treated
6
+ */
7
+ const DOMWithState = {
8
+ INPUT: { value: 1, defaultValue: 2, checked: 1, defaultChecked: 2 },
9
+ SELECT: { value: 1 },
10
+ OPTION: { value: 1, selected: 1, defaultSelected: 2 },
11
+ TEXTAREA: { value: 1, defaultValue: 2 },
12
+ VIDEO: { muted: 1, defaultMuted: 2 },
13
+ AUDIO: { muted: 1, defaultMuted: 2 }
14
+ };
15
+
16
+ const ChildProperties = /*#__PURE__*/ new Set([
17
+ "innerHTML",
18
+ "textContent",
19
+ "innerText",
20
+ "children"
21
+ ]);
22
+
23
+ // Per-node tag identifying the owning slot's marker. Set on every runtime
24
+ // insertion site so that subsequent reconcile / cleanup work can distinguish
25
+ // "the node still belongs to my slot" from "the node has migrated to another
26
+ // slot in the same parent" without consulting external bookkeeping.
27
+ const $$SLOT = /*#__PURE__*/ Symbol("slot");
28
+
29
+ // Guard companion to the `_$host` getter applied by `insert`'s `host` option:
30
+ // records which host accessor a node was last tagged with so unchanged nodes
31
+ // skip the `defineProperty` on subsequent updates.
32
+ const $$HOST = /*#__PURE__*/ Symbol("host");
33
+
34
+ // list of Element events that will be delegated
35
+ const DelegatedEvents = /*#__PURE__*/ new Set([
36
+ "beforeinput",
37
+ "click",
38
+ "dblclick",
39
+ "contextmenu",
40
+ "focusin",
41
+ "focusout",
42
+ "input",
43
+ "keydown",
44
+ "keyup",
45
+ "mousedown",
46
+ "mousemove",
47
+ "mouseout",
48
+ "mouseover",
49
+ "mouseup",
50
+ "pointerdown",
51
+ "pointermove",
52
+ "pointerout",
53
+ "pointerover",
54
+ "pointerup",
55
+ "touchend",
56
+ "touchmove",
57
+ "touchstart"
58
+ ]);
59
+
60
+ const SVGElements = /*#__PURE__*/ new Set([
61
+ // "a",
62
+ "altGlyph",
63
+ "altGlyphDef",
64
+ "altGlyphItem",
65
+ "animate",
66
+ "animateColor",
67
+ "animateMotion",
68
+ "animateTransform",
69
+ "circle",
70
+ "clipPath",
71
+ "color-profile",
72
+ "cursor",
73
+ "defs",
74
+ "desc",
75
+ "ellipse",
76
+ "feBlend",
77
+ "feColorMatrix",
78
+ "feComponentTransfer",
79
+ "feComposite",
80
+ "feConvolveMatrix",
81
+ "feDiffuseLighting",
82
+ "feDisplacementMap",
83
+ "feDistantLight",
84
+ "feDropShadow",
85
+ "feFlood",
86
+ "feFuncA",
87
+ "feFuncB",
88
+ "feFuncG",
89
+ "feFuncR",
90
+ "feGaussianBlur",
91
+ "feImage",
92
+ "feMerge",
93
+ "feMergeNode",
94
+ "feMorphology",
95
+ "feOffset",
96
+ "fePointLight",
97
+ "feSpecularLighting",
98
+ "feSpotLight",
99
+ "feTile",
100
+ "feTurbulence",
101
+ "filter",
102
+ "font",
103
+ "font-face",
104
+ "font-face-format",
105
+ "font-face-name",
106
+ "font-face-src",
107
+ "font-face-uri",
108
+ "foreignObject",
109
+ "g",
110
+ "glyph",
111
+ "glyphRef",
112
+ "hkern",
113
+ "image",
114
+ "line",
115
+ "linearGradient",
116
+ "marker",
117
+ "mask",
118
+ "metadata",
119
+ "missing-glyph",
120
+ "mpath",
121
+ "path",
122
+ "pattern",
123
+ "polygon",
124
+ "polyline",
125
+ "radialGradient",
126
+ "rect",
127
+ // "script",
128
+ "set",
129
+ "stop",
130
+ // "style",
131
+ "svg",
132
+ "switch",
133
+ "symbol",
134
+ "text",
135
+ "textPath",
136
+ // "title",
137
+ "tref",
138
+ "tspan",
139
+ "use",
140
+ "view",
141
+ "vkern"
142
+ ]);
143
+
144
+ const MathMLElements = /*#__PURE__*/ new Set([
145
+ "annotation",
146
+ "annotation-xml",
147
+ "maction",
148
+ "math",
149
+ "menclose",
150
+ "merror",
151
+ "mfenced",
152
+ "mfrac",
153
+ "mi",
154
+ "mmultiscripts",
155
+ "mn",
156
+ "mo",
157
+ "mover",
158
+ "mpadded",
159
+ "mphantom",
160
+ "mprescripts",
161
+ "mroot",
162
+ "mrow",
163
+ "ms",
164
+ "mspace",
165
+ "msqrt",
166
+ "mstyle",
167
+ "msub",
168
+ "msubsup",
169
+ "msup",
170
+ "mtable",
171
+ "mtd",
172
+ "mtext",
173
+ "mtr",
174
+ "munder",
175
+ "munderover",
176
+ "semantics"
177
+ ]);
178
+
179
+ const Namespaces = {
180
+ svg: "http://www.w3.org/2000/svg",
181
+ mathml: "http://www.w3.org/1998/Math/MathML",
182
+ xlink: "http://www.w3.org/1999/xlink",
183
+ xml: "http://www.w3.org/XML/1998/namespace"
184
+ };
185
+
186
+ const VoidElements = /*#__PURE__*/ new Set([
187
+ "area",
188
+ "base",
189
+ "br",
190
+ "col",
191
+ "embed",
192
+ "hr",
193
+ "img",
194
+ "input",
195
+ "link",
196
+ "meta",
197
+ "param",
198
+ "source",
199
+ "track",
200
+ "wbr"
201
+ ]);
202
+
203
+ const RawTextElements = /*#__PURE__*/ new Set([
204
+ "style",
205
+ "script",
206
+ "noscript",
207
+ "template",
208
+ "textarea",
209
+ "title"
210
+ ]);
211
+
212
+ const DOMElements = /*#__PURE__*/ new Set([
213
+ "html",
214
+ "base",
215
+ "head",
216
+ "link",
217
+ "meta",
218
+ "style",
219
+ "title",
220
+ "body",
221
+ "address",
222
+ "article",
223
+ "aside",
224
+ "footer",
225
+ "header",
226
+ "main",
227
+ "nav",
228
+ "section",
229
+ "body",
230
+ "blockquote",
231
+ "dd",
232
+ "div",
233
+ "dl",
234
+ "dt",
235
+ "figcaption",
236
+ "figure",
237
+ "hr",
238
+ "li",
239
+ "ol",
240
+ "p",
241
+ "pre",
242
+ "ul",
243
+ "a",
244
+ "abbr",
245
+ "b",
246
+ "bdi",
247
+ "bdo",
248
+ "br",
249
+ "cite",
250
+ "code",
251
+ "data",
252
+ "dfn",
253
+ "em",
254
+ "i",
255
+ "kbd",
256
+ "mark",
257
+ "q",
258
+ "rp",
259
+ "rt",
260
+ "ruby",
261
+ "s",
262
+ "samp",
263
+ "small",
264
+ "span",
265
+ "strong",
266
+ "sub",
267
+ "sup",
268
+ "time",
269
+ "u",
270
+ "var",
271
+ "wbr",
272
+ "area",
273
+ "audio",
274
+ "img",
275
+ "map",
276
+ "track",
277
+ "video",
278
+ "embed",
279
+ "iframe",
280
+ "object",
281
+ "param",
282
+ "picture",
283
+ "portal",
284
+ "source",
285
+ "svg",
286
+ "math",
287
+ "canvas",
288
+ "noscript",
289
+ "script",
290
+ "del",
291
+ "ins",
292
+ "caption",
293
+ "col",
294
+ "colgroup",
295
+ "table",
296
+ "tbody",
297
+ "td",
298
+ "tfoot",
299
+ "th",
300
+ "thead",
301
+ "tr",
302
+ "button",
303
+ "datalist",
304
+ "fieldset",
305
+ "form",
306
+ "input",
307
+ "label",
308
+ "legend",
309
+ "meter",
310
+ "optgroup",
311
+ "option",
312
+ "output",
313
+ "progress",
314
+ "select",
315
+ "textarea",
316
+ "details",
317
+ "dialog",
318
+ "menu",
319
+ "summary",
320
+ "details",
321
+ "slot",
322
+ "template",
323
+ "acronym",
324
+ "applet",
325
+ "basefont",
326
+ "bgsound",
327
+ "big",
328
+ "blink",
329
+ "center",
330
+ "content",
331
+ "dir",
332
+ "font",
333
+ "frame",
334
+ "frameset",
335
+ "hgroup",
336
+ "image",
337
+ "keygen",
338
+ "marquee",
339
+ "menuitem",
340
+ "nobr",
341
+ "noembed",
342
+ "noframes",
343
+ "plaintext",
344
+ "rb",
345
+ "rtc",
346
+ "shadow",
347
+ "spacer",
348
+ "strike",
349
+ "tt",
350
+ "xmp",
351
+ "a",
352
+ "abbr",
353
+ "acronym",
354
+ "address",
355
+ "applet",
356
+ "area",
357
+ "article",
358
+ "aside",
359
+ "audio",
360
+ "b",
361
+ "base",
362
+ "basefont",
363
+ "bdi",
364
+ "bdo",
365
+ "bgsound",
366
+ "big",
367
+ "blink",
368
+ "blockquote",
369
+ "body",
370
+ "br",
371
+ "button",
372
+ "canvas",
373
+ "caption",
374
+ "center",
375
+ "cite",
376
+ "code",
377
+ "col",
378
+ "colgroup",
379
+ "content",
380
+ "data",
381
+ "datalist",
382
+ "dd",
383
+ "del",
384
+ "details",
385
+ "dfn",
386
+ "dialog",
387
+ "dir",
388
+ "div",
389
+ "dl",
390
+ "dt",
391
+ "em",
392
+ "embed",
393
+ "fieldset",
394
+ "figcaption",
395
+ "figure",
396
+ "font",
397
+ "footer",
398
+ "form",
399
+ "frame",
400
+ "frameset",
401
+ "head",
402
+ "header",
403
+ "hgroup",
404
+ "hr",
405
+ "html",
406
+ "i",
407
+ "iframe",
408
+ "image",
409
+ "img",
410
+ "input",
411
+ "ins",
412
+ "kbd",
413
+ "keygen",
414
+ "label",
415
+ "legend",
416
+ "li",
417
+ "link",
418
+ "main",
419
+ "map",
420
+ "mark",
421
+ "marquee",
422
+ "menu",
423
+ "menuitem",
424
+ "meta",
425
+ "meter",
426
+ "nav",
427
+ "nobr",
428
+ "noembed",
429
+ "noframes",
430
+ "noscript",
431
+ "object",
432
+ "ol",
433
+ "optgroup",
434
+ "option",
435
+ "output",
436
+ "p",
437
+ "param",
438
+ "picture",
439
+ "plaintext",
440
+ "portal",
441
+ "pre",
442
+ "progress",
443
+ "q",
444
+ "rb",
445
+ "rp",
446
+ "rt",
447
+ "rtc",
448
+ "ruby",
449
+ "s",
450
+ "samp",
451
+ "script",
452
+ "section",
453
+ "select",
454
+ "shadow",
455
+ "slot",
456
+ "small",
457
+ "source",
458
+ "spacer",
459
+ "span",
460
+ "strike",
461
+ "strong",
462
+ "style",
463
+ "sub",
464
+ "summary",
465
+ "sup",
466
+ "table",
467
+ "tbody",
468
+ "td",
469
+ "template",
470
+ "textarea",
471
+ "tfoot",
472
+ "th",
473
+ "thead",
474
+ "time",
475
+ "title",
476
+ "tr",
477
+ "track",
478
+ "tt",
479
+ "u",
480
+ "ul",
481
+ "var",
482
+ "video",
483
+ "wbr",
484
+ "xmp",
485
+ "input",
486
+ "h1",
487
+ "h2",
488
+ "h3",
489
+ "h4",
490
+ "h5",
491
+ "h6",
492
+
493
+ // special
494
+ "webview",
495
+
496
+ // deprecated
497
+ "isindex",
498
+ "listing",
499
+ "multicol",
500
+ "nextid",
501
+ "noindex",
502
+ "search"
503
+ ]);
504
+
505
+ export {
506
+ DOMWithState,
507
+ ChildProperties,
508
+ DelegatedEvents,
509
+ SVGElements,
510
+ MathMLElements,
511
+ VoidElements,
512
+ RawTextElements,
513
+ Namespaces,
514
+ DOMElements,
515
+ $$SLOT,
516
+ $$HOST
517
+ };
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from "fs";
4
+
5
+ const args = process.argv.slice(2);
6
+
7
+ function readOption(name) {
8
+ const index = args.indexOf(`--${name}`);
9
+ if (index === -1) return undefined;
10
+ const value = args[index + 1];
11
+ if (!value || value.startsWith("--")) throw new Error(`Missing value for --${name}`);
12
+ return value;
13
+ }
14
+
15
+ const input = readOption("input");
16
+ const output = readOption("output") ?? input;
17
+ const element = readOption("element");
18
+ const imports = args
19
+ .flatMap((arg, index) => (arg === "--import" ? [args[index + 1]] : []))
20
+ .filter(Boolean);
21
+
22
+ if (!input || !element) {
23
+ throw new Error(
24
+ [
25
+ "Usage: jsx-customize --input <jsx.d.ts> --element <type> [--output <jsx.d.ts>] [--import <statement>...]",
26
+ "",
27
+ "Example:",
28
+ ' jsx-customize --input ./src/jsx.d.ts --element "SolidElement | Node | ArrayElement" --import "import type { Element as SolidElement } from \\"solid-js\\";"'
29
+ ].join("\n")
30
+ );
31
+ }
32
+
33
+ let source = fs.readFileSync(input, "utf8");
34
+
35
+ for (const statement of imports) {
36
+ source = source.replace(new RegExp(`^${escapeRegExp(statement)}\\n`, "gm"), "");
37
+ }
38
+
39
+ const importAnchor = 'import type { PropKey, WidenPropValue } from "./jsx-properties.js";';
40
+ if (!source.includes(importAnchor)) {
41
+ throw new Error(`Unable to find JSX properties import in ${input}`);
42
+ }
43
+ source = source.replace(importAnchor, [importAnchor, ...imports].join("\n"));
44
+
45
+ const nextSource = source.replace(
46
+ /type Element =[\s\S]*?\n \/\/ END - difference between `jsx\.d\.ts` and `jsx-h\.d\.ts`/,
47
+ `type Element = ${element};\n // END - difference between \`jsx.d.ts\` and \`jsx-h.d.ts\``
48
+ );
49
+ if (nextSource === source) {
50
+ throw new Error(`Unable to find JSX.Element declaration block in ${input}`);
51
+ }
52
+ source = nextSource;
53
+
54
+ fs.writeFileSync(output, source);
55
+
56
+ function escapeRegExp(value) {
57
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
58
+ }