solid-js 1.9.5 → 1.9.7

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.
Files changed (51) hide show
  1. package/dist/dev.cjs +21 -10
  2. package/dist/dev.js +327 -557
  3. package/dist/server.js +81 -178
  4. package/dist/solid.cjs +21 -10
  5. package/dist/solid.js +283 -486
  6. package/h/dist/h.js +9 -40
  7. package/h/jsx-runtime/dist/jsx.js +1 -1
  8. package/h/jsx-runtime/types/index.d.ts +8 -11
  9. package/h/jsx-runtime/types/jsx.d.ts +2947 -1021
  10. package/h/types/hyperscript.d.ts +11 -11
  11. package/html/dist/html.cjs +2 -2
  12. package/html/dist/html.js +96 -221
  13. package/html/types/lit.d.ts +33 -52
  14. package/package.json +3 -3
  15. package/store/dist/dev.js +43 -123
  16. package/store/dist/server.js +8 -20
  17. package/store/dist/store.js +40 -114
  18. package/store/types/index.d.ts +7 -21
  19. package/store/types/modifiers.d.ts +3 -6
  20. package/store/types/mutable.d.ts +2 -5
  21. package/store/types/server.d.ts +5 -25
  22. package/store/types/store.d.ts +61 -218
  23. package/types/index.d.ts +11 -78
  24. package/types/jsx.d.ts +2091 -278
  25. package/types/reactive/array.d.ts +4 -12
  26. package/types/reactive/observable.d.ts +16 -22
  27. package/types/reactive/scheduler.d.ts +6 -9
  28. package/types/reactive/signal.d.ts +145 -236
  29. package/types/render/Suspense.d.ts +5 -5
  30. package/types/render/component.d.ts +37 -73
  31. package/types/render/flow.d.ts +31 -43
  32. package/types/render/hydration.d.ts +15 -15
  33. package/types/server/index.d.ts +2 -57
  34. package/types/server/reactive.d.ts +45 -76
  35. package/types/server/rendering.d.ts +98 -169
  36. package/universal/dist/dev.cjs +3 -1
  37. package/universal/dist/dev.js +15 -29
  38. package/universal/dist/universal.cjs +3 -1
  39. package/universal/dist/universal.js +15 -29
  40. package/universal/types/index.d.ts +1 -3
  41. package/universal/types/universal.d.ts +1 -0
  42. package/web/dist/dev.cjs +8 -5
  43. package/web/dist/dev.js +96 -643
  44. package/web/dist/server.cjs +9 -6
  45. package/web/dist/server.js +116 -646
  46. package/web/dist/web.cjs +8 -5
  47. package/web/dist/web.js +94 -631
  48. package/web/storage/dist/storage.js +3 -3
  49. package/web/types/core.d.ts +2 -10
  50. package/web/types/index.d.ts +11 -31
  51. package/web/types/server-mock.d.ts +32 -47
@@ -1,20 +1,20 @@
1
1
  type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
2
2
  interface Runtime {
3
- insert(parent: MountableElement, accessor: any, marker?: Node | null, init?: any): any;
4
- spread(node: Element, accessor: any, isSVG?: Boolean, skipChildren?: Boolean): void;
5
- assign(node: Element, props: any, isSVG?: Boolean, skipChildren?: Boolean): void;
6
- createComponent(Comp: (props: any) => any, props: any): any;
7
- dynamicProperty(props: any, key: string): any;
8
- SVGElements: Set<string>;
3
+ insert(parent: MountableElement, accessor: any, marker?: Node | null, init?: any): any;
4
+ spread(node: Element, accessor: any, isSVG?: Boolean, skipChildren?: Boolean): void;
5
+ assign(node: Element, props: any, isSVG?: Boolean, skipChildren?: Boolean): void;
6
+ createComponent(Comp: (props: any) => any, props: any): any;
7
+ dynamicProperty(props: any, key: string): any;
8
+ SVGElements: Set<string>;
9
9
  }
10
10
  type ExpandableNode = Node & {
11
- [key: string]: any;
11
+ [key: string]: any;
12
12
  };
13
13
  export type HyperScript = {
14
- (...args: any[]): () => ExpandableNode | ExpandableNode[];
15
- Fragment: (props: {
16
- children: (() => ExpandableNode) | (() => ExpandableNode)[];
17
- }) => ExpandableNode[];
14
+ (...args: any[]): () => ExpandableNode | ExpandableNode[];
15
+ Fragment: (props: {
16
+ children: (() => ExpandableNode) | (() => ExpandableNode)[];
17
+ }) => ExpandableNode[];
18
18
  };
19
19
  export declare function createHyperScript(r: Runtime): HyperScript;
20
20
  export {};
@@ -358,8 +358,8 @@ function createHTML(r, {
358
358
  propGroups.push(`exprs[${options.counter++}]`);
359
359
  propGroups.push(props = []);
360
360
  } else if (value === "###") {
361
- props.push(`${name}: exprs[${options.counter++}]`);
362
- } else props.push(`${name}: "${value}"`);
361
+ props.push(`"${name}": exprs[${options.counter++}]`);
362
+ } else props.push(`"${name}": "${value}"`);
363
363
  } else if (type === 'directive') {
364
364
  const tag = `_$el${uuid++}`;
365
365
  const topDecl = !options.decl.length;
package/html/dist/html.js CHANGED
@@ -1,29 +1,7 @@
1
- import {
2
- effect,
3
- style,
4
- insert,
5
- untrack,
6
- spread,
7
- createComponent,
8
- delegateEvents,
9
- classList,
10
- mergeProps,
11
- dynamicProperty,
12
- setAttribute,
13
- setAttributeNS,
14
- addEventListener,
15
- Aliases,
16
- getPropAlias,
17
- Properties,
18
- ChildProperties,
19
- DelegatedEvents,
20
- SVGElements,
21
- SVGNamespace
22
- } from "solid-js/web";
1
+ import { effect, style, insert, untrack, spread, createComponent, delegateEvents, classList, mergeProps, dynamicProperty, setAttribute, setAttributeNS, addEventListener, Aliases, getPropAlias, Properties, ChildProperties, DelegatedEvents, SVGElements, SVGNamespace } from 'solid-js/web';
23
2
 
24
3
  const tagRE = /(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g;
25
- const attrRE =
26
- /(?:\s(?<boolean>[^/\s><=]+?)(?=[\s/>]))|(?:(?<name>\S+?)(?:\s*=\s*(?:(['"])(?<quotedValue>[\s\S]*?)\3|(?<unquotedValue>[^\s>]+))))/g;
4
+ const attrRE = /(?:\s(?<boolean>[^/\s><=]+?)(?=[\s/>]))|(?:(?<name>\S+?)(?:\s*=\s*(?:(['"])(?<quotedValue>[\s\S]*?)\3|(?<unquotedValue>[^\s>]+))))/g;
27
5
  const lookup = {
28
6
  area: true,
29
7
  base: true,
@@ -44,8 +22,8 @@ const lookup = {
44
22
  };
45
23
  function parseTag(tag) {
46
24
  const res = {
47
- type: "tag",
48
- name: "",
25
+ type: 'tag',
26
+ name: '',
49
27
  voidElement: false,
50
28
  attrs: [],
51
29
  children: []
@@ -53,50 +31,50 @@ function parseTag(tag) {
53
31
  const tagMatch = tag.match(/<\/?([^\s]+?)[/\s>]/);
54
32
  if (tagMatch) {
55
33
  res.name = tagMatch[1];
56
- if (lookup[tagMatch[1].toLowerCase()] || tag.charAt(tag.length - 2) === "/") {
34
+ if (lookup[tagMatch[1].toLowerCase()] || tag.charAt(tag.length - 2) === '/') {
57
35
  res.voidElement = true;
58
36
  }
59
- if (res.name.startsWith("!--")) {
60
- const endIndex = tag.indexOf("-->");
37
+ if (res.name.startsWith('!--')) {
38
+ const endIndex = tag.indexOf('-->');
61
39
  return {
62
- type: "comment",
63
- comment: endIndex !== -1 ? tag.slice(4, endIndex) : ""
40
+ type: 'comment',
41
+ comment: endIndex !== -1 ? tag.slice(4, endIndex) : ''
64
42
  };
65
43
  }
66
44
  }
67
45
  const reg = new RegExp(attrRE);
68
46
  for (const match of tag.matchAll(reg)) {
69
- if ((match[1] || match[2]).startsWith("use:")) {
47
+ if ((match[1] || match[2]).startsWith('use:')) {
70
48
  res.attrs.push({
71
- type: "directive",
49
+ type: 'directive',
72
50
  name: match[1] || match[2],
73
- value: match[4] || match[5] || ""
51
+ value: match[4] || match[5] || ''
74
52
  });
75
53
  } else {
76
54
  res.attrs.push({
77
- type: "attr",
55
+ type: 'attr',
78
56
  name: match[1] || match[2],
79
- value: match[4] || match[5] || ""
57
+ value: match[4] || match[5] || ''
80
58
  });
81
59
  }
82
60
  }
83
61
  return res;
84
62
  }
85
63
  function pushTextNode(list, html, start) {
86
- const end = html.indexOf("<", start);
64
+ const end = html.indexOf('<', start);
87
65
  const content = html.slice(start, end === -1 ? undefined : end);
88
66
  if (!/^\s*$/.test(content)) {
89
67
  list.push({
90
- type: "text",
68
+ type: 'text',
91
69
  content: content
92
70
  });
93
71
  }
94
72
  }
95
73
  function pushCommentNode(list, tag) {
96
- const content = tag.replace("<!--", "").replace("-->", "");
74
+ const content = tag.replace('<!--', '').replace('-->', '');
97
75
  if (!/^\s*$/.test(content)) {
98
76
  list.push({
99
- type: "comment",
77
+ type: 'comment',
100
78
  content: content
101
79
  });
102
80
  }
@@ -108,15 +86,15 @@ function parse(html) {
108
86
  const arr = [];
109
87
  const byTag = {};
110
88
  html.replace(tagRE, (tag, index) => {
111
- const isOpen = tag.charAt(1) !== "/";
112
- const isComment = tag.slice(0, 4) === "<!--";
89
+ const isOpen = tag.charAt(1) !== '/';
90
+ const isComment = tag.slice(0, 4) === '<!--';
113
91
  const start = index + tag.length;
114
92
  const nextChar = html.charAt(start);
115
93
  let parent = undefined;
116
94
  if (isOpen && !isComment) {
117
95
  level++;
118
96
  current = parseTag(tag);
119
- if (!current.voidElement && nextChar && nextChar !== "<") {
97
+ if (!current.voidElement && nextChar && nextChar !== '<') {
120
98
  pushTextNode(current.children, html, start);
121
99
  }
122
100
  byTag[current.tagName] = current;
@@ -140,7 +118,7 @@ function parse(html) {
140
118
  if (!isComment) {
141
119
  level--;
142
120
  }
143
- if (nextChar !== "<" && nextChar) {
121
+ if (nextChar !== '<' && nextChar) {
144
122
  parent = level === -1 ? result : arr[level].children;
145
123
  pushTextNode(parent, html, start);
146
124
  }
@@ -151,47 +129,41 @@ function parse(html) {
151
129
  function attrString(attrs) {
152
130
  const buff = [];
153
131
  for (const attr of attrs) {
154
- buff.push(attr.name + '="' + attr.value.replace(/"/g, "&quot;") + '"');
132
+ buff.push(attr.name + '="' + attr.value.replace(/"/g, '&quot;') + '"');
155
133
  }
156
134
  if (!buff.length) {
157
- return "";
135
+ return '';
158
136
  }
159
- return " " + buff.join(" ");
137
+ return ' ' + buff.join(' ');
160
138
  }
161
139
  function stringifier(buff, doc) {
162
140
  switch (doc.type) {
163
- case "text":
141
+ case 'text':
164
142
  return buff + doc.content;
165
- case "tag":
166
- buff +=
167
- "<" + doc.name + (doc.attrs ? attrString(doc.attrs) : "") + (doc.voidElement ? "/>" : ">");
143
+ case 'tag':
144
+ buff += '<' + doc.name + (doc.attrs ? attrString(doc.attrs) : '') + (doc.voidElement ? '/>' : '>');
168
145
  if (doc.voidElement) {
169
146
  return buff;
170
147
  }
171
- return buff + doc.children.reduce(stringifier, "") + "</" + doc.name + ">";
172
- case "comment":
173
- return (buff += "<!--" + doc.content + "-->");
148
+ return buff + doc.children.reduce(stringifier, '') + '</' + doc.name + '>';
149
+ case 'comment':
150
+ return buff += '<!--' + doc.content + '-->';
174
151
  }
175
152
  }
176
153
  function stringify(doc) {
177
154
  return doc.reduce(function (token, rootEl) {
178
- return token + stringifier("", rootEl);
179
- }, "");
155
+ return token + stringifier('', rootEl);
156
+ }, '');
180
157
  }
181
158
  const cache = new Map();
182
- const VOID_ELEMENTS =
183
- /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
159
+ const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
184
160
  const spaces = " \\f\\n\\r\\t";
185
161
  const almostEverything = "[^" + spaces + "\\/>\"'=]+";
186
- const attrName = "[ " + spaces + "]+(?:use:<!--#-->|" + almostEverything + ")";
162
+ const attrName = "[ " + spaces + "]+(?:use:<!--#-->|" + almostEverything + ')';
187
163
  const tagName = "<([A-Za-z$#]+[A-Za-z0-9:_-]*)((?:";
188
- const attrPartials =
189
- "(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|\\([^)]*?\\)|<[^>]*?>|" + almostEverything + "))?)";
164
+ const attrPartials = "(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|\\([^)]*?\\)|<[^>]*?>|" + almostEverything + "))?)";
190
165
  const attrSeeker = new RegExp(tagName + attrName + attrPartials + "+)([ " + spaces + "]*/?>)", "g");
191
- const findAttributes = new RegExp(
192
- "(" + attrName + "\\s*=\\s*)(<!--#-->|['\"(]([\\w\\s]*<!--#-->[\\w\\s]*)*['\")])",
193
- "gi"
194
- );
166
+ const findAttributes = new RegExp("(" + attrName + "\\s*=\\s*)(<!--#-->|['\"(]([\\w\\s]*<!--#-->[\\w\\s]*)*['\")])", "gi");
195
167
  const selfClosing = new RegExp(tagName + attrName + attrPartials + "*)([ " + spaces + "]*/>)", "g");
196
168
  const marker = "<!--#-->";
197
169
  const reservedNameSpaces = new Set(["class", "on", "oncapture", "style", "use", "prop", "attr"]);
@@ -199,10 +171,7 @@ function attrReplacer($0, $1, $2, $3) {
199
171
  return "<" + $1 + $2.replace(findAttributes, replaceAttributes) + $3;
200
172
  }
201
173
  function replaceAttributes($0, $1, $2) {
202
- return (
203
- $1.replace(/<!--#-->/g, "###") +
204
- ($2[0] === '"' || $2[0] === "'" ? $2.replace(/<!--#-->/g, "###") : '"###"')
205
- );
174
+ return $1.replace(/<!--#-->/g, "###") + ($2[0] === '"' || $2[0] === "'" ? $2.replace(/<!--#-->/g, "###") : '"###"');
206
175
  }
207
176
  function fullClosing($0, $1, $2) {
208
177
  return VOID_ELEMENTS.test($1) ? $0 : "<" + $1 + $2 + "></" + $1 + ">";
@@ -211,19 +180,17 @@ function toPropertyName(name) {
211
180
  return name.toLowerCase().replace(/-([a-z])/g, (_, w) => w.toUpperCase());
212
181
  }
213
182
  function parseDirective(name, value, tag, options) {
214
- if (name === "use:###" && value === "###") {
183
+ if (name === 'use:###' && value === '###') {
215
184
  const count = options.counter++;
216
- options.exprs.push(
217
- `typeof exprs[${count}] === "function" ? r.use(exprs[${count}], ${tag}, exprs[${options.counter++}]) : (()=>{throw new Error("use:### must be a function")})()`
218
- );
185
+ options.exprs.push(`typeof exprs[${count}] === "function" ? r.use(exprs[${count}], ${tag}, exprs[${options.counter++}]) : (()=>{throw new Error("use:### must be a function")})()`);
219
186
  } else {
220
187
  throw new Error(`Not support syntax ${name} must be use:{function}`);
221
188
  }
222
189
  }
223
- function createHTML(
224
- r,
225
- { delegateEvents = true, functionBuilder = (...args) => new Function(...args) } = {}
226
- ) {
190
+ function createHTML(r, {
191
+ delegateEvents = true,
192
+ functionBuilder = (...args) => new Function(...args)
193
+ } = {}) {
227
194
  let uuid = 1;
228
195
  r.wrapProps = props => {
229
196
  const d = Object.getOwnPropertyDescriptors(props);
@@ -239,16 +206,7 @@ function createHTML(
239
206
  markup = markup + statics[i] + "<!--#-->";
240
207
  }
241
208
  markup = markup + statics[i];
242
- const replaceList = [
243
- [selfClosing, fullClosing],
244
- [/<(<!--#-->)/g, "<###"],
245
- [/\.\.\.(<!--#-->)/g, "###"],
246
- [attrSeeker, attrReplacer],
247
- [/>\n+\s*/g, ">"],
248
- [/\n+\s*</g, "<"],
249
- [/\s+</g, " <"],
250
- [/>\s+/g, "> "]
251
- ];
209
+ const replaceList = [[selfClosing, fullClosing], [/<(<!--#-->)/g, "<###"], [/\.\.\.(<!--#-->)/g, "###"], [attrSeeker, attrReplacer], [/>\n+\s*/g, ">"], [/\n+\s*</g, "<"], [/\s+</g, " <"], [/>\s+/g, "> "]];
252
210
  markup = replaceList.reduce((acc, x) => {
253
211
  return acc.replace(x[0], x[1]);
254
212
  }, markup);
@@ -276,19 +234,7 @@ function createHTML(
276
234
  return templates;
277
235
  }
278
236
  function parseKeyValue(node, tag, name, value, isSVG, isCE, options) {
279
- let expr =
280
- value === "###"
281
- ? `!doNotWrap ? exprs[${options.counter}]() : exprs[${options.counter++}]`
282
- : value
283
- .split("###")
284
- .map((v, i) =>
285
- i
286
- ? ` + (typeof exprs[${options.counter}] === "function" ? exprs[${
287
- options.counter
288
- }]() : exprs[${options.counter++}]) + "${v}"`
289
- : `"${v}"`
290
- )
291
- .join(""),
237
+ let expr = value === "###" ? `!doNotWrap ? exprs[${options.counter}]() : exprs[${options.counter++}]` : value.split("###").map((v, i) => i ? ` + (typeof exprs[${options.counter}] === "function" ? exprs[${options.counter}]() : exprs[${options.counter++}]) + "${v}"` : `"${v}"`).join(""),
292
238
  parts,
293
239
  namespace;
294
240
  if ((parts = name.split(":")) && parts[1] && reservedNameSpaces.has(parts[0])) {
@@ -305,21 +251,12 @@ function createHTML(
305
251
  const prev = `_$v${uuid++}`;
306
252
  options.decl.push(`${prev}={}`);
307
253
  options.exprs.push(`r.classList(${tag},${expr},${prev})`);
308
- } else if (
309
- namespace !== "attr" &&
310
- (isChildProp ||
311
- (!isSVG && (r.getPropAlias(name, node.name.toUpperCase()) || isProp)) ||
312
- isCE ||
313
- namespace === "prop")
314
- ) {
254
+ } else if (namespace !== "attr" && (isChildProp || !isSVG && (r.getPropAlias(name, node.name.toUpperCase()) || isProp) || isCE || namespace === "prop")) {
315
255
  if (isCE && !isChildProp && !isProp && namespace !== "prop") name = toPropertyName(name);
316
- options.exprs.push(
317
- `${tag}.${r.getPropAlias(name, node.name.toUpperCase()) || name} = ${expr}`
318
- );
256
+ options.exprs.push(`${tag}.${r.getPropAlias(name, node.name.toUpperCase()) || name} = ${expr}`);
319
257
  } else {
320
258
  const ns = isSVG && name.indexOf(":") > -1 && r.SVGNamespace[name.split(":")[0]];
321
- if (ns) options.exprs.push(`r.setAttributeNS(${tag},"${ns}","${name}",${expr})`);
322
- else options.exprs.push(`r.setAttribute(${tag},"${r.Aliases[name] || name}",${expr})`);
259
+ if (ns) options.exprs.push(`r.setAttributeNS(${tag},"${ns}","${name}",${expr})`);else options.exprs.push(`r.setAttribute(${tag},"${r.Aliases[name] || name}",${expr})`);
323
260
  }
324
261
  }
325
262
  function parseAttribute(node, tag, name, value, isSVG, isCE, options) {
@@ -327,17 +264,11 @@ function createHTML(
327
264
  if (!name.includes(":")) {
328
265
  const lc = name.slice(2).toLowerCase();
329
266
  const delegate = delegateEvents && r.DelegatedEvents.has(lc);
330
- options.exprs.push(
331
- `r.addEventListener(${tag},"${lc}",exprs[${options.counter++}],${delegate})`
332
- );
267
+ options.exprs.push(`r.addEventListener(${tag},"${lc}",exprs[${options.counter++}],${delegate})`);
333
268
  delegate && options.delegatedEvents.add(lc);
334
269
  } else {
335
270
  let capture = name.startsWith("oncapture:");
336
- options.exprs.push(
337
- `${tag}.addEventListener("${name.slice(capture ? 10 : 3)}",exprs[${options.counter++}]${
338
- capture ? ",true" : ""
339
- })`
340
- );
271
+ options.exprs.push(`${tag}.addEventListener("${name.slice(capture ? 10 : 3)}",exprs[${options.counter++}]${capture ? ",true" : ""})`);
341
272
  }
342
273
  } else if (name === "ref") {
343
274
  options.exprs.push(`exprs[${options.counter++}](${tag})`);
@@ -347,15 +278,9 @@ function createHTML(
347
278
  }),
348
279
  count = options.counter;
349
280
  parseKeyValue(node, tag, name, value, isSVG, isCE, childOptions);
350
- options.decl.push(
351
- `_fn${count} = (${value === "###" ? "doNotWrap" : ""}) => {\n${childOptions.exprs.join(
352
- ";\n"
353
- )};\n}`
354
- );
281
+ options.decl.push(`_fn${count} = (${value === "###" ? "doNotWrap" : ""}) => {\n${childOptions.exprs.join(";\n")};\n}`);
355
282
  if (value === "###") {
356
- options.exprs.push(
357
- `typeof exprs[${count}] === "function" ? r.effect(_fn${count}) : _fn${count}(true)`
358
- );
283
+ options.exprs.push(`typeof exprs[${count}] === "function" ? r.effect(_fn${count}) : _fn${count}(true)`);
359
284
  } else {
360
285
  let check = "";
361
286
  for (let i = count; i < childOptions.counter; i++) {
@@ -377,10 +302,7 @@ function createHTML(
377
302
  if (node.children.length > 1) {
378
303
  for (let i = 0; i < node.children.length; i++) {
379
304
  const child = node.children[i];
380
- if (
381
- (child.type === "comment" && child.content === "#") ||
382
- (child.type === "tag" && child.name === "###")
383
- ) {
305
+ if (child.type === "comment" && child.content === "#" || child.type === "tag" && child.name === "###") {
384
306
  childOptions.multi = true;
385
307
  break;
386
308
  }
@@ -401,9 +323,7 @@ function createHTML(
401
323
  continue;
402
324
  }
403
325
  parseNode(child, childOptions);
404
- if (!childOptions.multi && child.type === "comment" && child.content === "#")
405
- node.children.splice(i, 1);
406
- else i++;
326
+ if (!childOptions.multi && child.type === "comment" && child.content === "#") node.children.splice(i, 1);else i++;
407
327
  }
408
328
  options.counter = childOptions.counter;
409
329
  options.templateId = childOptions.templateId;
@@ -426,28 +346,26 @@ function createHTML(
426
346
  propGroups = [props],
427
347
  componentIdentifier = options.counter++;
428
348
  for (let i = 0; i < keys.length; i++) {
429
- const { type, name, value } = node.attrs[i];
430
- if (type === "attr") {
349
+ const {
350
+ type,
351
+ name,
352
+ value
353
+ } = node.attrs[i];
354
+ if (type === 'attr') {
431
355
  if (name === "###") {
432
356
  propGroups.push(`exprs[${options.counter++}]`);
433
- propGroups.push((props = []));
357
+ propGroups.push(props = []);
434
358
  } else if (value === "###") {
435
- props.push(`${name}: exprs[${options.counter++}]`);
436
- } else props.push(`${name}: "${value}"`);
437
- } else if (type === "directive") {
359
+ props.push(`"${name}": exprs[${options.counter++}]`);
360
+ } else props.push(`"${name}": "${value}"`);
361
+ } else if (type === 'directive') {
438
362
  const tag = `_$el${uuid++}`;
439
363
  const topDecl = !options.decl.length;
440
- options.decl.push(
441
- topDecl ? "" : `${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`
442
- );
364
+ options.decl.push(topDecl ? "" : `${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`);
443
365
  parseDirective(name, value, tag, options);
444
366
  }
445
367
  }
446
- if (
447
- node.children.length === 1 &&
448
- node.children[0].type === "comment" &&
449
- node.children[0].content === "#"
450
- ) {
368
+ if (node.children.length === 1 && node.children[0].type === "comment" && node.children[0].content === "#") {
451
369
  props.push(`children: () => exprs[${options.counter++}]`);
452
370
  } else if (node.children.length) {
453
371
  const children = {
@@ -470,20 +388,7 @@ function createHTML(
470
388
  tag = `_$el${uuid++}`;
471
389
  options.decl.push(`${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`);
472
390
  }
473
- if (options.parent)
474
- options.exprs.push(
475
- `r.insert(${
476
- options.parent
477
- }, r.createComponent(exprs[${componentIdentifier}],${processComponentProps(propGroups)})${
478
- tag ? `, ${tag}` : ""
479
- })`
480
- );
481
- else
482
- options.exprs.push(
483
- `${
484
- options.fragment ? "" : "return "
485
- }r.createComponent(exprs[${componentIdentifier}],${processComponentProps(propGroups)})`
486
- );
391
+ if (options.parent) options.exprs.push(`r.insert(${options.parent}, r.createComponent(exprs[${componentIdentifier}],${processComponentProps(propGroups)})${tag ? `, ${tag}` : ""})`);else options.exprs.push(`${options.fragment ? "" : "return "}r.createComponent(exprs[${componentIdentifier}],${processComponentProps(propGroups)})`);
487
392
  options.path = tag;
488
393
  options.first = false;
489
394
  }
@@ -514,21 +419,13 @@ function createHTML(
514
419
  });
515
420
  options.templateNodes.push([child]);
516
421
  parseNode(child, childOptions);
517
- parts.push(
518
- `function() { ${
519
- childOptions.decl.join(",\n") +
520
- ";\n" +
521
- childOptions.exprs.join(";\n") +
522
- `;\nreturn _$el${id};\n`
523
- }}()`
524
- );
422
+ parts.push(`function() { ${childOptions.decl.join(",\n") + ";\n" + childOptions.exprs.join(";\n") + `;\nreturn _$el${id};\n`}}()`);
525
423
  options.counter = childOptions.counter;
526
424
  options.templateId = childOptions.templateId;
527
425
  } else if (child.type === "text") {
528
426
  parts.push(`"${child.content}"`);
529
427
  } else if (child.type === "comment") {
530
- if (child.content === "#") parts.push(`exprs[${options.counter++}]`);
531
- else if (child.content) {
428
+ if (child.content === "#") parts.push(`exprs[${options.counter++}]`);else if (child.content) {
532
429
  for (let i = 0; i < child.content.split("###").length - 1; i++) {
533
430
  parts.push(`exprs[${options.counter++}]`);
534
431
  }
@@ -540,27 +437,25 @@ function createHTML(
540
437
  const tag = `_$el${uuid++}`;
541
438
  const topDecl = !options.decl.length;
542
439
  const templateId = options.templateId;
543
- options.decl.push(
544
- topDecl ? "" : `${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`
545
- );
440
+ options.decl.push(topDecl ? "" : `${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`);
546
441
  const isSVG = r.SVGElements.has(node.name);
547
442
  const isCE = node.name.includes("-") || node.attrs.some(e => e.name === "is");
548
443
  options.hasCustomElement = isCE;
549
- options.isImportNode =
550
- (node.name === "img" || node.name === "iframe") &&
551
- node.attrs.some(e => e.name === "loading" && e.value === "lazy");
444
+ options.isImportNode = (node.name === 'img' || node.name === 'iframe') && node.attrs.some(e => e.name === "loading" && e.value === 'lazy');
552
445
  if (node.attrs.some(e => e.name === "###")) {
553
446
  const spreadArgs = [];
554
447
  let current = "";
555
448
  const newAttrs = [];
556
449
  for (let i = 0; i < node.attrs.length; i++) {
557
- const { type, name, value } = node.attrs[i];
558
- if (type === "attr") {
450
+ const {
451
+ type,
452
+ name,
453
+ value
454
+ } = node.attrs[i];
455
+ if (type === 'attr') {
559
456
  if (value.includes("###")) {
560
457
  let count = options.counter++;
561
- current += `${name}: ${
562
- name !== "ref" ? `typeof exprs[${count}] === "function" ? exprs[${count}]() : ` : ""
563
- }exprs[${count}],`;
458
+ current += `${name}: ${name !== "ref" ? `typeof exprs[${count}] === "function" ? exprs[${count}]() : ` : ""}exprs[${count}],`;
564
459
  } else if (name === "###") {
565
460
  if (current.length) {
566
461
  spreadArgs.push(`()=>({${current}})`);
@@ -570,7 +465,7 @@ function createHTML(
570
465
  } else {
571
466
  newAttrs.push(node.attrs[i]);
572
467
  }
573
- } else if (type === "directive") {
468
+ } else if (type === 'directive') {
574
469
  parseDirective(name, value, tag, options);
575
470
  }
576
471
  }
@@ -578,17 +473,15 @@ function createHTML(
578
473
  if (current.length) {
579
474
  spreadArgs.push(`()=>({${current}})`);
580
475
  }
581
- options.exprs.push(
582
- `r.spread(${tag},${
583
- spreadArgs.length === 1
584
- ? `typeof ${spreadArgs[0]} === "function" ? r.mergeProps(${spreadArgs[0]}) : ${spreadArgs[0]}`
585
- : `r.mergeProps(${spreadArgs.join(",")})`
586
- },${isSVG},${!!node.children.length})`
587
- );
476
+ options.exprs.push(`r.spread(${tag},${spreadArgs.length === 1 ? `typeof ${spreadArgs[0]} === "function" ? r.mergeProps(${spreadArgs[0]}) : ${spreadArgs[0]}` : `r.mergeProps(${spreadArgs.join(",")})`},${isSVG},${!!node.children.length})`);
588
477
  } else {
589
478
  for (let i = 0; i < node.attrs.length; i++) {
590
- const { type, name, value } = node.attrs[i];
591
- if (type === "directive") {
479
+ const {
480
+ type,
481
+ name,
482
+ value
483
+ } = node.attrs[i];
484
+ if (type === 'directive') {
592
485
  parseDirective(name, value, tag, options);
593
486
  node.attrs.splice(i, 1);
594
487
  i--;
@@ -605,10 +498,7 @@ function createHTML(
605
498
  options.first = false;
606
499
  processChildren(node, options);
607
500
  if (topDecl) {
608
- options.decl[0] =
609
- options.hasCustomElement || options.isImportNode
610
- ? `const ${tag} = r.untrack(() => document.importNode(tmpls[${templateId}].content.firstChild, true))`
611
- : `const ${tag} = tmpls[${templateId}].content.firstChild.cloneNode(true)`;
501
+ options.decl[0] = options.hasCustomElement || options.isImportNode ? `const ${tag} = r.untrack(() => document.importNode(tmpls[${templateId}].content.firstChild, true))` : `const ${tag} = tmpls[${templateId}].content.firstChild.cloneNode(true)`;
612
502
  }
613
503
  } else if (node.type === "text") {
614
504
  const tag = `_$el${uuid++}`;
@@ -643,12 +533,10 @@ function createHTML(
643
533
  origNodes = nodes;
644
534
  let toplevel;
645
535
  if (nodes.length > 1) {
646
- nodes = [
647
- {
648
- type: "fragment",
649
- children: nodes
650
- }
651
- ];
536
+ nodes = [{
537
+ type: "fragment",
538
+ children: nodes
539
+ }];
652
540
  }
653
541
  if (nodes[0].name === "###") {
654
542
  toplevel = true;
@@ -656,25 +544,12 @@ function createHTML(
656
544
  } else parseNode(nodes[0], options);
657
545
  r.delegateEvents(Array.from(options.delegatedEvents));
658
546
  const templateNodes = [origNodes].concat(options.templateNodes);
659
- return [
660
- templateNodes.map(t => stringify(t)),
661
- funcBuilder(
662
- "tmpls",
663
- "exprs",
664
- "r",
665
- options.decl.join(",\n") +
666
- ";\n" +
667
- options.exprs.join(";\n") +
668
- (toplevel ? "" : `;\nreturn _$el${id};\n`)
669
- )
670
- ];
547
+ return [templateNodes.map(t => stringify(t)), funcBuilder("tmpls", "exprs", "r", options.decl.join(",\n") + ";\n" + options.exprs.join(";\n") + (toplevel ? "" : `;\nreturn _$el${id};\n`))];
671
548
  }
672
549
  function html(statics, ...args) {
673
- const templates =
674
- cache.get(statics) ||
675
- createTemplate(statics, {
676
- funcBuilder: functionBuilder
677
- });
550
+ const templates = cache.get(statics) || createTemplate(statics, {
551
+ funcBuilder: functionBuilder
552
+ });
678
553
  return templates[0].create(templates, args, r);
679
554
  }
680
555
  return html;