solid-js 1.4.0 → 1.4.3

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/dist/dev.cjs CHANGED
@@ -1415,24 +1415,25 @@ function Match(props) {
1415
1415
  return props;
1416
1416
  }
1417
1417
  let Errors;
1418
+ const NoErrors = {};
1418
1419
  function resetErrorBoundaries() {
1419
- Errors && [...Errors].forEach(fn => fn());
1420
+ Errors && [...Errors].forEach(fn => fn(NoErrors));
1420
1421
  }
1421
1422
  function ErrorBoundary(props) {
1422
- let err = undefined;
1423
+ let err = NoErrors;
1423
1424
  if (sharedConfig.context && sharedConfig.load) {
1424
- err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
1425
+ err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count) || NoErrors;
1425
1426
  }
1426
1427
  const [errored, setErrored] = createSignal(err);
1427
1428
  Errors || (Errors = new Set());
1428
1429
  Errors.add(setErrored);
1429
1430
  onCleanup(() => Errors.delete(setErrored));
1430
- let e;
1431
1431
  return createMemo(() => {
1432
- if ((e = errored()) != null) {
1432
+ let e;
1433
+ if ((e = errored()) !== NoErrors) {
1433
1434
  const f = props.fallback;
1434
1435
  if ((typeof f !== "function" || f.length == 0)) console.error(e);
1435
- return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored(null))) : f;
1436
+ return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored(NoErrors))) : f;
1436
1437
  }
1437
1438
  onError(setErrored);
1438
1439
  return props.children;
package/dist/dev.js CHANGED
@@ -1411,24 +1411,25 @@ function Match(props) {
1411
1411
  return props;
1412
1412
  }
1413
1413
  let Errors;
1414
+ const NoErrors = {};
1414
1415
  function resetErrorBoundaries() {
1415
- Errors && [...Errors].forEach(fn => fn());
1416
+ Errors && [...Errors].forEach(fn => fn(NoErrors));
1416
1417
  }
1417
1418
  function ErrorBoundary(props) {
1418
- let err = undefined;
1419
+ let err = NoErrors;
1419
1420
  if (sharedConfig.context && sharedConfig.load) {
1420
- err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
1421
+ err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count) || NoErrors;
1421
1422
  }
1422
1423
  const [errored, setErrored] = createSignal(err);
1423
1424
  Errors || (Errors = new Set());
1424
1425
  Errors.add(setErrored);
1425
1426
  onCleanup(() => Errors.delete(setErrored));
1426
- let e;
1427
1427
  return createMemo(() => {
1428
- if ((e = errored()) != null) {
1428
+ let e;
1429
+ if ((e = errored()) !== NoErrors) {
1429
1430
  const f = props.fallback;
1430
1431
  if ((typeof f !== "function" || f.length == 0)) console.error(e);
1431
- return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored(null))) : f;
1432
+ return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored(NoErrors))) : f;
1432
1433
  }
1433
1434
  onError(setErrored);
1434
1435
  return props.children;
package/dist/server.cjs CHANGED
@@ -258,8 +258,9 @@ function createComponent(Comp, props) {
258
258
  function mergeProps(...sources) {
259
259
  const target = {};
260
260
  for (let i = 0; i < sources.length; i++) {
261
- const descriptors = Object.getOwnPropertyDescriptors(sources[i]);
262
- Object.defineProperties(target, descriptors);
261
+ let source = sources[i];
262
+ if (typeof source === "function") source = source();
263
+ if (source) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
263
264
  }
264
265
  return target;
265
266
  }
@@ -314,14 +315,16 @@ function Switch(props) {
314
315
  function Match(props) {
315
316
  return props;
316
317
  }
318
+ const NoErrors = {};
317
319
  function resetErrorBoundaries() {}
318
320
  function ErrorBoundary(props) {
319
- let error, res;
321
+ let error = NoErrors,
322
+ res;
320
323
  const ctx = sharedConfig.context;
321
324
  const id = ctx.id + ctx.count;
322
325
  onError(err => error = err);
323
326
  createMemo(() => res = props.children);
324
- if (error) {
327
+ if (error !== NoErrors) {
325
328
  ctx.writeResource(id, error, true);
326
329
  setHydrateContext({ ...ctx,
327
330
  count: 0
@@ -360,7 +363,7 @@ function createResource(source, fetcher, options = {}) {
360
363
  const read = () => {
361
364
  if (error) throw error;
362
365
  if (resourceContext && p) resourceContext.push(p);
363
- const resolved = sharedConfig.context.async && sharedConfig.context.resources[id].data;
366
+ const resolved = sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
364
367
  if (!resolved && read.loading) {
365
368
  const ctx = useContext(SuspenseContext);
366
369
  if (ctx) {
@@ -380,7 +383,7 @@ function createResource(source, fetcher, options = {}) {
380
383
  function load() {
381
384
  const ctx = sharedConfig.context;
382
385
  if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
383
- if (ctx.resources && id in ctx.resources && ctx.resources[id].data) {
386
+ if (ctx.resources && id in ctx.resources && "data" in ctx.resources[id]) {
384
387
  value = ctx.resources[id].data;
385
388
  return;
386
389
  }
package/dist/server.js CHANGED
@@ -254,8 +254,9 @@ function createComponent(Comp, props) {
254
254
  function mergeProps(...sources) {
255
255
  const target = {};
256
256
  for (let i = 0; i < sources.length; i++) {
257
- const descriptors = Object.getOwnPropertyDescriptors(sources[i]);
258
- Object.defineProperties(target, descriptors);
257
+ let source = sources[i];
258
+ if (typeof source === "function") source = source();
259
+ if (source) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
259
260
  }
260
261
  return target;
261
262
  }
@@ -310,14 +311,16 @@ function Switch(props) {
310
311
  function Match(props) {
311
312
  return props;
312
313
  }
314
+ const NoErrors = {};
313
315
  function resetErrorBoundaries() {}
314
316
  function ErrorBoundary(props) {
315
- let error, res;
317
+ let error = NoErrors,
318
+ res;
316
319
  const ctx = sharedConfig.context;
317
320
  const id = ctx.id + ctx.count;
318
321
  onError(err => error = err);
319
322
  createMemo(() => res = props.children);
320
- if (error) {
323
+ if (error !== NoErrors) {
321
324
  ctx.writeResource(id, error, true);
322
325
  setHydrateContext({ ...ctx,
323
326
  count: 0
@@ -356,7 +359,7 @@ function createResource(source, fetcher, options = {}) {
356
359
  const read = () => {
357
360
  if (error) throw error;
358
361
  if (resourceContext && p) resourceContext.push(p);
359
- const resolved = sharedConfig.context.async && sharedConfig.context.resources[id].data;
362
+ const resolved = sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
360
363
  if (!resolved && read.loading) {
361
364
  const ctx = useContext(SuspenseContext);
362
365
  if (ctx) {
@@ -376,7 +379,7 @@ function createResource(source, fetcher, options = {}) {
376
379
  function load() {
377
380
  const ctx = sharedConfig.context;
378
381
  if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
379
- if (ctx.resources && id in ctx.resources && ctx.resources[id].data) {
382
+ if (ctx.resources && id in ctx.resources && "data" in ctx.resources[id]) {
380
383
  value = ctx.resources[id].data;
381
384
  return;
382
385
  }
package/dist/solid.cjs CHANGED
@@ -1331,23 +1331,24 @@ function Match(props) {
1331
1331
  return props;
1332
1332
  }
1333
1333
  let Errors;
1334
+ const NoErrors = {};
1334
1335
  function resetErrorBoundaries() {
1335
- Errors && [...Errors].forEach(fn => fn());
1336
+ Errors && [...Errors].forEach(fn => fn(NoErrors));
1336
1337
  }
1337
1338
  function ErrorBoundary(props) {
1338
- let err = undefined;
1339
+ let err = NoErrors;
1339
1340
  if (sharedConfig.context && sharedConfig.load) {
1340
- err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
1341
+ err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count) || NoErrors;
1341
1342
  }
1342
1343
  const [errored, setErrored] = createSignal(err);
1343
1344
  Errors || (Errors = new Set());
1344
1345
  Errors.add(setErrored);
1345
1346
  onCleanup(() => Errors.delete(setErrored));
1346
- let e;
1347
1347
  return createMemo(() => {
1348
- if ((e = errored()) != null) {
1348
+ let e;
1349
+ if ((e = errored()) !== NoErrors) {
1349
1350
  const f = props.fallback;
1350
- return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored(null))) : f;
1351
+ return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored(NoErrors))) : f;
1351
1352
  }
1352
1353
  onError(setErrored);
1353
1354
  return props.children;
package/dist/solid.js CHANGED
@@ -1327,23 +1327,24 @@ function Match(props) {
1327
1327
  return props;
1328
1328
  }
1329
1329
  let Errors;
1330
+ const NoErrors = {};
1330
1331
  function resetErrorBoundaries() {
1331
- Errors && [...Errors].forEach(fn => fn());
1332
+ Errors && [...Errors].forEach(fn => fn(NoErrors));
1332
1333
  }
1333
1334
  function ErrorBoundary(props) {
1334
- let err = undefined;
1335
+ let err = NoErrors;
1335
1336
  if (sharedConfig.context && sharedConfig.load) {
1336
- err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
1337
+ err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count) || NoErrors;
1337
1338
  }
1338
1339
  const [errored, setErrored] = createSignal(err);
1339
1340
  Errors || (Errors = new Set());
1340
1341
  Errors.add(setErrored);
1341
1342
  onCleanup(() => Errors.delete(setErrored));
1342
- let e;
1343
1343
  return createMemo(() => {
1344
- if ((e = errored()) != null) {
1344
+ let e;
1345
+ if ((e = errored()) !== NoErrors) {
1345
1346
  const f = props.fallback;
1346
- return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored(null))) : f;
1347
+ return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored(NoErrors))) : f;
1347
1348
  }
1348
1349
  onError(setErrored);
1349
1350
  return props.children;
@@ -179,15 +179,15 @@ const attrName = "[ " + spaces + "]+" + almostEverything;
179
179
  const tagName = "<([A-Za-z$#]+[A-Za-z0-9:_-]*)((?:";
180
180
  const attrPartials = "(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|\\([^)]*?\\)|<[^>]*?>|" + almostEverything + "))?)";
181
181
  const attrSeeker = new RegExp(tagName + attrName + attrPartials + "+)([ " + spaces + "]*/?>)", "g");
182
- const findAttributes = new RegExp("(" + attrName + "\\s*=\\s*)(['\"(]?)" + "<!--#-->" + "(['\")]?)", "gi");
182
+ const findAttributes = new RegExp("(" + attrName + "\\s*=\\s*)(<!--#-->|['\"(]([\\w\\s]*<!--#-->[\\w\\s]*)*['\")])", "gi");
183
183
  const selfClosing = new RegExp(tagName + attrName + attrPartials + "*)([ " + spaces + "]*/>)", "g");
184
184
  const marker = "<!--#-->";
185
185
  const reservedNameSpaces = new Set(["class", "on", "oncapture", "style", "use", "prop", "attr"]);
186
186
  function attrReplacer($0, $1, $2, $3) {
187
187
  return "<" + $1 + $2.replace(findAttributes, replaceAttributes) + $3;
188
188
  }
189
- function replaceAttributes($0, $1, $2, $3) {
190
- return $1 + ($2 || '"') + "###" + ($3 || '"');
189
+ function replaceAttributes($0, $1, $2) {
190
+ return $1 + ($2[0] === '"' || $2[0] === "'" ? $2.replace(/<!--#-->/g, "###") : '"###"');
191
191
  }
192
192
  function fullClosing($0, $1, $2) {
193
193
  return VOID_ELEMENTS.test($1) ? $0 : "<" + $1 + $2 + "></" + $1 + ">";
@@ -236,9 +236,8 @@ function createHTML(r, {
236
236
  cache.set(statics, templates);
237
237
  return templates;
238
238
  }
239
- function parseKeyValue(tag, name, isSVG, isCE, options) {
240
- let count = options.counter++,
241
- expr = `!doNotWrap ? exprs[${count}]() : exprs[${count}]`,
239
+ function parseKeyValue(tag, name, value, isSVG, isCE, options) {
240
+ 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(""),
242
241
  parts,
243
242
  namespace;
244
243
  if ((parts = name.split(":")) && parts[1] && reservedNameSpaces.has(parts[0])) {
@@ -263,7 +262,7 @@ function createHTML(r, {
263
262
  if (ns) options.exprs.push(`r.setAttributeNS(${tag},"${ns}","${name}",${expr})`);else options.exprs.push(`r.setAttribute(${tag},"${r.Aliases[name] || name}",${expr})`);
264
263
  }
265
264
  }
266
- function parseAttribute(tag, name, isSVG, isCE, options) {
265
+ function parseAttribute(tag, name, value, isSVG, isCE, options) {
267
266
  if (name.slice(0, 2) === "on") {
268
267
  if (!name.includes(":")) {
269
268
  const lc = name.slice(2).toLowerCase();
@@ -281,9 +280,18 @@ function createHTML(r, {
281
280
  exprs: []
282
281
  }),
283
282
  count = options.counter;
284
- parseKeyValue(tag, name, isSVG, isCE, childOptions);
285
- options.decl.push(`_fn${count} = doNotWrap => {\n${childOptions.exprs.join(";\n")};\n}`);
286
- options.exprs.push(`typeof exprs[${count}] === "function" ? r.effect(_fn${count}) : _fn${count}(true)`);
283
+ parseKeyValue(tag, name, value, isSVG, isCE, childOptions);
284
+ options.decl.push(`_fn${count} = (${value === "###" ? "doNotWrap" : ""}) => {\n${childOptions.exprs.join(";\n")};\n}`);
285
+ if (value === "###") {
286
+ options.exprs.push(`typeof exprs[${count}] === "function" ? r.effect(_fn${count}) : _fn${count}(true)`);
287
+ } else {
288
+ let check = "";
289
+ for (let i = count; i < childOptions.counter; i++) {
290
+ i !== count && (check += " || ");
291
+ check += `typeof exprs[${i}] === "function"`;
292
+ }
293
+ options.exprs.push(check + ` ? r.effect(_fn${count}) : _fn${count}()`);
294
+ }
287
295
  options.counter = childOptions.counter;
288
296
  options.wrap = false;
289
297
  }
@@ -322,6 +330,7 @@ function createHTML(r, {
322
330
  }
323
331
  options.counter = childOptions.counter;
324
332
  options.templateId = childOptions.templateId;
333
+ options.hasCustomElement = options.hasCustomElement || childOptions.hasCustomElement;
325
334
  }
326
335
  function processComponentProps(propGroups) {
327
336
  let result = [];
@@ -414,16 +423,19 @@ function createHTML(r, {
414
423
  options.exprs.push(`return [${parts.join(", \n")}]`);
415
424
  } else if (node.type === "tag") {
416
425
  const tag = `_$el${uuid++}`;
417
- options.decl.push(!options.decl.length ? `const ${tag} = tmpls[${options.templateId}].content.firstChild.cloneNode(true)` : `${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`);
426
+ const topDecl = !options.decl.length;
427
+ const templateId = options.templateId;
428
+ options.decl.push(topDecl ? "" : `${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`);
418
429
  const keys = Object.keys(node.attrs);
419
430
  const isSVG = r.SVGElements.has(node.name);
420
431
  const isCE = node.name.includes("-");
432
+ options.hasCustomElement = isCE;
421
433
  for (let i = 0; i < keys.length; i++) {
422
434
  const name = keys[i],
423
435
  value = node.attrs[name];
424
- if (value === "###") {
436
+ if (value.includes("###")) {
425
437
  delete node.attrs[name];
426
- parseAttribute(tag, name, isSVG, isCE, options);
438
+ parseAttribute(tag, name, value, isSVG, isCE, options);
427
439
  } else if (name === "###") {
428
440
  delete node.attrs[name];
429
441
  options.exprs.push(`r.spread(${tag},exprs[${options.counter++}],${isSVG},${!!node.children.length})`);
@@ -432,17 +444,22 @@ function createHTML(r, {
432
444
  options.path = tag;
433
445
  options.first = false;
434
446
  processChildren(node, options);
447
+ if (topDecl) {
448
+ options.decl[0] = options.hasCustomElement ? `const ${tag} = document.importNode(tmpls[${templateId}].content.firstChild, true)` : `const ${tag} = tmpls[${templateId}].content.firstChild.cloneNode(true)`;
449
+ }
435
450
  } else if (node.type === "text") {
436
451
  const tag = `_$el${uuid++}`;
437
452
  options.decl.push(`${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`);
438
453
  options.path = tag;
439
454
  options.first = false;
440
- } else if (node.type === "comment" && node.content === "#") {
455
+ } else if (node.type === "comment") {
441
456
  const tag = `_$el${uuid++}`;
442
457
  options.decl.push(`${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`);
443
- if (options.multi) {
444
- options.exprs.push(`r.insert(${options.parent}, exprs[${options.counter++}], ${tag})`);
445
- } else options.exprs.push(`r.insert(${options.parent}, exprs[${options.counter++}])`);
458
+ if (node.content === "#") {
459
+ if (options.multi) {
460
+ options.exprs.push(`r.insert(${options.parent}, exprs[${options.counter++}], ${tag})`);
461
+ } else options.exprs.push(`r.insert(${options.parent}, exprs[${options.counter++}])`);
462
+ }
446
463
  options.path = tag;
447
464
  options.first = false;
448
465
  }
package/html/dist/html.js CHANGED
@@ -177,15 +177,15 @@ const attrName = "[ " + spaces + "]+" + almostEverything;
177
177
  const tagName = "<([A-Za-z$#]+[A-Za-z0-9:_-]*)((?:";
178
178
  const attrPartials = "(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|\\([^)]*?\\)|<[^>]*?>|" + almostEverything + "))?)";
179
179
  const attrSeeker = new RegExp(tagName + attrName + attrPartials + "+)([ " + spaces + "]*/?>)", "g");
180
- const findAttributes = new RegExp("(" + attrName + "\\s*=\\s*)(['\"(]?)" + "<!--#-->" + "(['\")]?)", "gi");
180
+ const findAttributes = new RegExp("(" + attrName + "\\s*=\\s*)(<!--#-->|['\"(]([\\w\\s]*<!--#-->[\\w\\s]*)*['\")])", "gi");
181
181
  const selfClosing = new RegExp(tagName + attrName + attrPartials + "*)([ " + spaces + "]*/>)", "g");
182
182
  const marker = "<!--#-->";
183
183
  const reservedNameSpaces = new Set(["class", "on", "oncapture", "style", "use", "prop", "attr"]);
184
184
  function attrReplacer($0, $1, $2, $3) {
185
185
  return "<" + $1 + $2.replace(findAttributes, replaceAttributes) + $3;
186
186
  }
187
- function replaceAttributes($0, $1, $2, $3) {
188
- return $1 + ($2 || '"') + "###" + ($3 || '"');
187
+ function replaceAttributes($0, $1, $2) {
188
+ return $1 + ($2[0] === '"' || $2[0] === "'" ? $2.replace(/<!--#-->/g, "###") : '"###"');
189
189
  }
190
190
  function fullClosing($0, $1, $2) {
191
191
  return VOID_ELEMENTS.test($1) ? $0 : "<" + $1 + $2 + "></" + $1 + ">";
@@ -234,9 +234,8 @@ function createHTML(r, {
234
234
  cache.set(statics, templates);
235
235
  return templates;
236
236
  }
237
- function parseKeyValue(tag, name, isSVG, isCE, options) {
238
- let count = options.counter++,
239
- expr = `!doNotWrap ? exprs[${count}]() : exprs[${count}]`,
237
+ function parseKeyValue(tag, name, value, isSVG, isCE, options) {
238
+ 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(""),
240
239
  parts,
241
240
  namespace;
242
241
  if ((parts = name.split(":")) && parts[1] && reservedNameSpaces.has(parts[0])) {
@@ -261,7 +260,7 @@ function createHTML(r, {
261
260
  if (ns) options.exprs.push(`r.setAttributeNS(${tag},"${ns}","${name}",${expr})`);else options.exprs.push(`r.setAttribute(${tag},"${r.Aliases[name] || name}",${expr})`);
262
261
  }
263
262
  }
264
- function parseAttribute(tag, name, isSVG, isCE, options) {
263
+ function parseAttribute(tag, name, value, isSVG, isCE, options) {
265
264
  if (name.slice(0, 2) === "on") {
266
265
  if (!name.includes(":")) {
267
266
  const lc = name.slice(2).toLowerCase();
@@ -279,9 +278,18 @@ function createHTML(r, {
279
278
  exprs: []
280
279
  }),
281
280
  count = options.counter;
282
- parseKeyValue(tag, name, isSVG, isCE, childOptions);
283
- options.decl.push(`_fn${count} = doNotWrap => {\n${childOptions.exprs.join(";\n")};\n}`);
284
- options.exprs.push(`typeof exprs[${count}] === "function" ? r.effect(_fn${count}) : _fn${count}(true)`);
281
+ parseKeyValue(tag, name, value, isSVG, isCE, childOptions);
282
+ options.decl.push(`_fn${count} = (${value === "###" ? "doNotWrap" : ""}) => {\n${childOptions.exprs.join(";\n")};\n}`);
283
+ if (value === "###") {
284
+ options.exprs.push(`typeof exprs[${count}] === "function" ? r.effect(_fn${count}) : _fn${count}(true)`);
285
+ } else {
286
+ let check = "";
287
+ for (let i = count; i < childOptions.counter; i++) {
288
+ i !== count && (check += " || ");
289
+ check += `typeof exprs[${i}] === "function"`;
290
+ }
291
+ options.exprs.push(check + ` ? r.effect(_fn${count}) : _fn${count}()`);
292
+ }
285
293
  options.counter = childOptions.counter;
286
294
  options.wrap = false;
287
295
  }
@@ -320,6 +328,7 @@ function createHTML(r, {
320
328
  }
321
329
  options.counter = childOptions.counter;
322
330
  options.templateId = childOptions.templateId;
331
+ options.hasCustomElement = options.hasCustomElement || childOptions.hasCustomElement;
323
332
  }
324
333
  function processComponentProps(propGroups) {
325
334
  let result = [];
@@ -412,16 +421,19 @@ function createHTML(r, {
412
421
  options.exprs.push(`return [${parts.join(", \n")}]`);
413
422
  } else if (node.type === "tag") {
414
423
  const tag = `_$el${uuid++}`;
415
- options.decl.push(!options.decl.length ? `const ${tag} = tmpls[${options.templateId}].content.firstChild.cloneNode(true)` : `${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`);
424
+ const topDecl = !options.decl.length;
425
+ const templateId = options.templateId;
426
+ options.decl.push(topDecl ? "" : `${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`);
416
427
  const keys = Object.keys(node.attrs);
417
428
  const isSVG = r.SVGElements.has(node.name);
418
429
  const isCE = node.name.includes("-");
430
+ options.hasCustomElement = isCE;
419
431
  for (let i = 0; i < keys.length; i++) {
420
432
  const name = keys[i],
421
433
  value = node.attrs[name];
422
- if (value === "###") {
434
+ if (value.includes("###")) {
423
435
  delete node.attrs[name];
424
- parseAttribute(tag, name, isSVG, isCE, options);
436
+ parseAttribute(tag, name, value, isSVG, isCE, options);
425
437
  } else if (name === "###") {
426
438
  delete node.attrs[name];
427
439
  options.exprs.push(`r.spread(${tag},exprs[${options.counter++}],${isSVG},${!!node.children.length})`);
@@ -430,17 +442,22 @@ function createHTML(r, {
430
442
  options.path = tag;
431
443
  options.first = false;
432
444
  processChildren(node, options);
445
+ if (topDecl) {
446
+ options.decl[0] = options.hasCustomElement ? `const ${tag} = document.importNode(tmpls[${templateId}].content.firstChild, true)` : `const ${tag} = tmpls[${templateId}].content.firstChild.cloneNode(true)`;
447
+ }
433
448
  } else if (node.type === "text") {
434
449
  const tag = `_$el${uuid++}`;
435
450
  options.decl.push(`${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`);
436
451
  options.path = tag;
437
452
  options.first = false;
438
- } else if (node.type === "comment" && node.content === "#") {
453
+ } else if (node.type === "comment") {
439
454
  const tag = `_$el${uuid++}`;
440
455
  options.decl.push(`${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`);
441
- if (options.multi) {
442
- options.exprs.push(`r.insert(${options.parent}, exprs[${options.counter++}], ${tag})`);
443
- } else options.exprs.push(`r.insert(${options.parent}, exprs[${options.counter++}])`);
456
+ if (node.content === "#") {
457
+ if (options.multi) {
458
+ options.exprs.push(`r.insert(${options.parent}, exprs[${options.counter++}], ${tag})`);
459
+ } else options.exprs.push(`r.insert(${options.parent}, exprs[${options.counter++}])`);
460
+ }
444
461
  options.path = tag;
445
462
  options.first = false;
446
463
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "solid-js",
3
3
  "description": "A declarative JavaScript library for building user interfaces.",
4
- "version": "1.4.0",
4
+ "version": "1.4.3",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
@@ -114,8 +114,8 @@
114
114
  "require": "./h/dist/h.cjs"
115
115
  },
116
116
  "./h/jsx-runtime": {
117
- "import": "./h/dist/jsx.js",
118
- "require": "./h/dist/jsx.cjs"
117
+ "import": "./h/jsx-runtime/dist/jsx.js",
118
+ "require": "./h/jsx-runtime/dist/jsx.cjs"
119
119
  },
120
120
  "./h/dist/*": "./h/dist/*",
121
121
  "./html": {
@@ -151,5 +151,5 @@
151
151
  "compiler",
152
152
  "performance"
153
153
  ],
154
- "gitHead": "6c9e976c002d3ae327ff509213a091ce79f7582a"
154
+ "gitHead": "44197a3f304400b055baef40da9ac661c0585b85"
155
155
  }
package/store/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  This submodules contains the means for handling deeps nested reactivity. It provides 2 main primitives `createStore` and `createMutable` which leverage proxies to create dynamic nested reactive structures.
4
4
 
5
- This also contains helper methods `produce` and `reconcile` which augment the behavior of the store setter method to allow for localized mutationa and data diffing.
5
+ This also contains helper methods `produce` and `reconcile` which augment the behavior of the store setter method to allow for localized mutation and data diffing.
6
6
 
7
7
  For full documentation, check out the [website](https://www.solidjs.com/docs/latest/api).
8
8
 
@@ -20,4 +20,4 @@ const [store, setStore] = createStore({
20
20
 
21
21
  // update store.user.firstName
22
22
  setStore("user", "firstName", "Will");
23
- ```
23
+ ```
@@ -143,14 +143,16 @@ function mergeStoreNode(state, value) {
143
143
  function updateArray(current, next) {
144
144
  if (typeof next === "function") next = next(current);
145
145
  next = unwrap(next);
146
- if (current === next) return;
147
- let i = 0,
148
- len = next.length;
149
- for (; i < len; i++) {
150
- const value = next[i];
151
- if (current[i] !== value) setProperty(current, i, value);
152
- }
153
- setProperty(current, "length", len);
146
+ if (Array.isArray(next)) {
147
+ if (current === next) return;
148
+ let i = 0,
149
+ len = next.length;
150
+ for (; i < len; i++) {
151
+ const value = next[i];
152
+ if (current[i] !== value) setProperty(current, i, value);
153
+ }
154
+ setProperty(current, "length", len);
155
+ } else mergeStoreNode(current, next);
154
156
  }
155
157
  function updatePath(current, path, traversed = []) {
156
158
  let part,
@@ -227,8 +229,8 @@ const proxyTraps = {
227
229
  if (property === $NODE || property === "__proto__") return value;
228
230
  if (!tracked) {
229
231
  const desc = Object.getOwnPropertyDescriptor(target, property);
230
- const isFunction = typeof value !== "function";
231
- if (solidJs.getListener() && (isFunction || target.hasOwnProperty(property)) && !(desc && desc.get)) value = getDataNode(nodes, property, value)();else if (value != null && isFunction && value === Array.prototype[property]) {
232
+ const isFunction = typeof value === "function";
233
+ if (solidJs.getListener() && (!isFunction || target.hasOwnProperty(property)) && !(desc && desc.get)) value = getDataNode(nodes, property, value)();else if (value != null && isFunction && value === Array.prototype[property]) {
232
234
  return (...args) => solidJs.batch(() => Array.prototype[property].apply(receiver, args));
233
235
  }
234
236
  }
@@ -373,11 +375,13 @@ function reconcile(value, options = {}) {
373
375
  return state;
374
376
  };
375
377
  }
378
+ const producers = new WeakMap();
376
379
  const setterTraps = {
377
380
  get(target, property) {
378
381
  if (property === $RAW) return target;
379
382
  const value = target[property];
380
- return isWrappable(value) ? new Proxy(value, setterTraps) : value;
383
+ let proxy;
384
+ return isWrappable(value) ? producers.get(value) || (producers.set(value, proxy = new Proxy(value, setterTraps)), proxy) : value;
381
385
  },
382
386
  set(target, property, value) {
383
387
  setProperty(target, property, unwrap(value));
@@ -390,7 +394,13 @@ const setterTraps = {
390
394
  };
391
395
  function produce(fn) {
392
396
  return state => {
393
- if (isWrappable(state)) fn(new Proxy(state, setterTraps));
397
+ if (isWrappable(state)) {
398
+ let proxy;
399
+ if (!(proxy = producers.get(state))) {
400
+ producers.set(state, proxy = new Proxy(state, setterTraps));
401
+ }
402
+ fn(proxy);
403
+ }
394
404
  return state;
395
405
  };
396
406
  }
package/store/dist/dev.js CHANGED
@@ -139,14 +139,16 @@ function mergeStoreNode(state, value) {
139
139
  function updateArray(current, next) {
140
140
  if (typeof next === "function") next = next(current);
141
141
  next = unwrap(next);
142
- if (current === next) return;
143
- let i = 0,
144
- len = next.length;
145
- for (; i < len; i++) {
146
- const value = next[i];
147
- if (current[i] !== value) setProperty(current, i, value);
148
- }
149
- setProperty(current, "length", len);
142
+ if (Array.isArray(next)) {
143
+ if (current === next) return;
144
+ let i = 0,
145
+ len = next.length;
146
+ for (; i < len; i++) {
147
+ const value = next[i];
148
+ if (current[i] !== value) setProperty(current, i, value);
149
+ }
150
+ setProperty(current, "length", len);
151
+ } else mergeStoreNode(current, next);
150
152
  }
151
153
  function updatePath(current, path, traversed = []) {
152
154
  let part,
@@ -223,8 +225,8 @@ const proxyTraps = {
223
225
  if (property === $NODE || property === "__proto__") return value;
224
226
  if (!tracked) {
225
227
  const desc = Object.getOwnPropertyDescriptor(target, property);
226
- const isFunction = typeof value !== "function";
227
- if (getListener() && (isFunction || target.hasOwnProperty(property)) && !(desc && desc.get)) value = getDataNode(nodes, property, value)();else if (value != null && isFunction && value === Array.prototype[property]) {
228
+ const isFunction = typeof value === "function";
229
+ if (getListener() && (!isFunction || target.hasOwnProperty(property)) && !(desc && desc.get)) value = getDataNode(nodes, property, value)();else if (value != null && isFunction && value === Array.prototype[property]) {
228
230
  return (...args) => batch(() => Array.prototype[property].apply(receiver, args));
229
231
  }
230
232
  }
@@ -369,11 +371,13 @@ function reconcile(value, options = {}) {
369
371
  return state;
370
372
  };
371
373
  }
374
+ const producers = new WeakMap();
372
375
  const setterTraps = {
373
376
  get(target, property) {
374
377
  if (property === $RAW) return target;
375
378
  const value = target[property];
376
- return isWrappable(value) ? new Proxy(value, setterTraps) : value;
379
+ let proxy;
380
+ return isWrappable(value) ? producers.get(value) || (producers.set(value, proxy = new Proxy(value, setterTraps)), proxy) : value;
377
381
  },
378
382
  set(target, property, value) {
379
383
  setProperty(target, property, unwrap(value));
@@ -386,7 +390,13 @@ const setterTraps = {
386
390
  };
387
391
  function produce(fn) {
388
392
  return state => {
389
- if (isWrappable(state)) fn(new Proxy(state, setterTraps));
393
+ if (isWrappable(state)) {
394
+ let proxy;
395
+ if (!(proxy = producers.get(state))) {
396
+ producers.set(state, proxy = new Proxy(state, setterTraps));
397
+ }
398
+ fn(proxy);
399
+ }
390
400
  return state;
391
401
  };
392
402
  }
@@ -138,14 +138,16 @@ function mergeStoreNode(state, value) {
138
138
  function updateArray(current, next) {
139
139
  if (typeof next === "function") next = next(current);
140
140
  next = unwrap(next);
141
- if (current === next) return;
142
- let i = 0,
143
- len = next.length;
144
- for (; i < len; i++) {
145
- const value = next[i];
146
- if (current[i] !== value) setProperty(current, i, value);
147
- }
148
- setProperty(current, "length", len);
141
+ if (Array.isArray(next)) {
142
+ if (current === next) return;
143
+ let i = 0,
144
+ len = next.length;
145
+ for (; i < len; i++) {
146
+ const value = next[i];
147
+ if (current[i] !== value) setProperty(current, i, value);
148
+ }
149
+ setProperty(current, "length", len);
150
+ } else mergeStoreNode(current, next);
149
151
  }
150
152
  function updatePath(current, path, traversed = []) {
151
153
  let part,
@@ -215,8 +217,8 @@ const proxyTraps = {
215
217
  if (property === $NODE || property === "__proto__") return value;
216
218
  if (!tracked) {
217
219
  const desc = Object.getOwnPropertyDescriptor(target, property);
218
- const isFunction = typeof value !== "function";
219
- if (solidJs.getListener() && (isFunction || target.hasOwnProperty(property)) && !(desc && desc.get)) value = getDataNode(nodes, property, value)();else if (value != null && isFunction && value === Array.prototype[property]) {
220
+ const isFunction = typeof value === "function";
221
+ if (solidJs.getListener() && (!isFunction || target.hasOwnProperty(property)) && !(desc && desc.get)) value = getDataNode(nodes, property, value)();else if (value != null && isFunction && value === Array.prototype[property]) {
220
222
  return (...args) => solidJs.batch(() => Array.prototype[property].apply(receiver, args));
221
223
  }
222
224
  }
@@ -351,11 +353,13 @@ function reconcile(value, options = {}) {
351
353
  return state;
352
354
  };
353
355
  }
356
+ const producers = new WeakMap();
354
357
  const setterTraps = {
355
358
  get(target, property) {
356
359
  if (property === $RAW) return target;
357
360
  const value = target[property];
358
- return isWrappable(value) ? new Proxy(value, setterTraps) : value;
361
+ let proxy;
362
+ return isWrappable(value) ? producers.get(value) || (producers.set(value, proxy = new Proxy(value, setterTraps)), proxy) : value;
359
363
  },
360
364
  set(target, property, value) {
361
365
  setProperty(target, property, unwrap(value));
@@ -368,7 +372,13 @@ const setterTraps = {
368
372
  };
369
373
  function produce(fn) {
370
374
  return state => {
371
- if (isWrappable(state)) fn(new Proxy(state, setterTraps));
375
+ if (isWrappable(state)) {
376
+ let proxy;
377
+ if (!(proxy = producers.get(state))) {
378
+ producers.set(state, proxy = new Proxy(state, setterTraps));
379
+ }
380
+ fn(proxy);
381
+ }
372
382
  return state;
373
383
  };
374
384
  }
@@ -134,14 +134,16 @@ function mergeStoreNode(state, value) {
134
134
  function updateArray(current, next) {
135
135
  if (typeof next === "function") next = next(current);
136
136
  next = unwrap(next);
137
- if (current === next) return;
138
- let i = 0,
139
- len = next.length;
140
- for (; i < len; i++) {
141
- const value = next[i];
142
- if (current[i] !== value) setProperty(current, i, value);
143
- }
144
- setProperty(current, "length", len);
137
+ if (Array.isArray(next)) {
138
+ if (current === next) return;
139
+ let i = 0,
140
+ len = next.length;
141
+ for (; i < len; i++) {
142
+ const value = next[i];
143
+ if (current[i] !== value) setProperty(current, i, value);
144
+ }
145
+ setProperty(current, "length", len);
146
+ } else mergeStoreNode(current, next);
145
147
  }
146
148
  function updatePath(current, path, traversed = []) {
147
149
  let part,
@@ -211,8 +213,8 @@ const proxyTraps = {
211
213
  if (property === $NODE || property === "__proto__") return value;
212
214
  if (!tracked) {
213
215
  const desc = Object.getOwnPropertyDescriptor(target, property);
214
- const isFunction = typeof value !== "function";
215
- if (getListener() && (isFunction || target.hasOwnProperty(property)) && !(desc && desc.get)) value = getDataNode(nodes, property, value)();else if (value != null && isFunction && value === Array.prototype[property]) {
216
+ const isFunction = typeof value === "function";
217
+ if (getListener() && (!isFunction || target.hasOwnProperty(property)) && !(desc && desc.get)) value = getDataNode(nodes, property, value)();else if (value != null && isFunction && value === Array.prototype[property]) {
216
218
  return (...args) => batch(() => Array.prototype[property].apply(receiver, args));
217
219
  }
218
220
  }
@@ -347,11 +349,13 @@ function reconcile(value, options = {}) {
347
349
  return state;
348
350
  };
349
351
  }
352
+ const producers = new WeakMap();
350
353
  const setterTraps = {
351
354
  get(target, property) {
352
355
  if (property === $RAW) return target;
353
356
  const value = target[property];
354
- return isWrappable(value) ? new Proxy(value, setterTraps) : value;
357
+ let proxy;
358
+ return isWrappable(value) ? producers.get(value) || (producers.set(value, proxy = new Proxy(value, setterTraps)), proxy) : value;
355
359
  },
356
360
  set(target, property, value) {
357
361
  setProperty(target, property, unwrap(value));
@@ -364,7 +368,13 @@ const setterTraps = {
364
368
  };
365
369
  function produce(fn) {
366
370
  return state => {
367
- if (isWrappable(state)) fn(new Proxy(state, setterTraps));
371
+ if (isWrappable(state)) {
372
+ let proxy;
373
+ if (!(proxy = producers.get(state))) {
374
+ producers.set(state, proxy = new Proxy(state, setterTraps));
375
+ }
376
+ fn(proxy);
377
+ }
368
378
  return state;
369
379
  };
370
380
  }
@@ -1,7 +1,6 @@
1
- import { DeepMutable } from "./store";
2
1
  export declare type ReconcileOptions = {
3
2
  key?: string | null;
4
3
  merge?: boolean;
5
4
  };
6
5
  export declare function reconcile<T extends U, U>(value: T, options?: ReconcileOptions): (state: U) => T;
7
- export declare function produce<T>(fn: (state: DeepMutable<T>) => void): (state: T) => T;
6
+ export declare function produce<T>(fn: (state: T) => void): (state: T) => T;
@@ -1,7 +1,7 @@
1
- import type { DeepMutable, SetStoreFunction, Store } from "store";
1
+ import type { SetStoreFunction, Store } from "store";
2
2
  export declare const $RAW: unique symbol;
3
3
  export declare function isWrappable(obj: any): boolean;
4
- export declare function unwrap<T>(item: any): T;
4
+ export declare function unwrap<T>(item: T): T;
5
5
  export declare function setProperty(state: any, property: PropertyKey, value: any, force?: boolean): void;
6
6
  export declare function updatePath(current: any, path: any[], traversed?: PropertyKey[]): void;
7
7
  export declare function createStore<T>(state: T | Store<T>): [Store<T>, SetStoreFunction<T>];
@@ -11,5 +11,5 @@ declare type ReconcileOptions = {
11
11
  merge?: boolean;
12
12
  };
13
13
  export declare function reconcile<T extends U, U>(value: T, options?: ReconcileOptions): (state: U) => T;
14
- export declare function produce<T>(fn: (state: DeepMutable<T>) => void): (state: T) => T;
14
+ export declare function produce<T>(fn: (state: T) => void): (state: T) => T;
15
15
  export {};
@@ -5,9 +5,9 @@ export declare namespace SolidStore {
5
5
  }
6
6
  }
7
7
  export declare type NotWrappable = string | number | bigint | symbol | boolean | Function | null | undefined | SolidStore.Unwrappable[keyof SolidStore.Unwrappable];
8
- export declare type Store<T> = DeepReadonly<T>;
9
- export declare function isWrappable(obj: any): any;
10
- export declare function unwrap<T extends StoreNode>(item: any, set?: Set<unknown>): T;
8
+ export declare type Store<T> = T;
9
+ export declare function isWrappable<T>(obj: T | NotWrappable): obj is T;
10
+ export declare function unwrap<T>(item: T, set?: Set<unknown>): T;
11
11
  export declare function getDataNodes(target: StoreNode): any;
12
12
  export declare function getDataNode(nodes: Record<string, any>, property: string | symbol, value: any): any;
13
13
  export declare function proxyDescriptor(target: StoreNode, property: PropertyKey): PropertyDescriptor | undefined;
@@ -15,19 +15,26 @@ export declare function trackSelf(target: StoreNode): void;
15
15
  export declare function ownKeys(target: StoreNode): (string | symbol)[];
16
16
  export declare function setProperty(state: StoreNode, property: PropertyKey, value: any): void;
17
17
  export declare function updatePath(current: StoreNode, path: any[], traversed?: PropertyKey[]): void;
18
+ /** @deprecated */
18
19
  export declare type DeepReadonly<T> = 0 extends 1 & T ? T : T extends NotWrappable ? T : {
19
20
  readonly [K in keyof T]: DeepReadonly<T[K]>;
20
21
  };
22
+ /** @deprecated */
21
23
  export declare type DeepMutable<T> = 0 extends 1 & T ? T : T extends NotWrappable ? T : {
22
24
  -readonly [K in keyof T]: DeepMutable<T[K]>;
23
25
  };
26
+ export declare type CustomPartial<T> = T extends readonly unknown[] ? "0" extends keyof T ? {
27
+ [K in Extract<keyof T, `${number}`>]?: T[K];
28
+ } : {
29
+ [x: number]: T[number];
30
+ } : Partial<T>;
24
31
  export declare type StorePathRange = {
25
32
  from?: number;
26
33
  to?: number;
27
34
  by?: number;
28
35
  };
29
- export declare type ArrayFilterFn<T> = (item: DeepReadonly<T>, index: number) => boolean;
30
- export declare type StoreSetter<T, U extends PropertyKey[] = []> = ((prevState: DeepReadonly<T>, traversed: U) => T | Partial<T> | DeepReadonly<T> | Partial<DeepReadonly<T>> | void) | T | Partial<T> | DeepReadonly<T> | Partial<DeepReadonly<T>>;
36
+ export declare type ArrayFilterFn<T> = (item: T, index: number) => boolean;
37
+ export declare type StoreSetter<T, U extends PropertyKey[] = []> = ((prevState: T, traversed: U) => T | CustomPartial<T> | void) | T | CustomPartial<T>;
31
38
  export declare type Part<T, K extends KeyOf<T> = KeyOf<T>> = [K] extends [never] ? never : K | readonly K[] | ([T] extends [readonly unknown[]] ? ArrayFilterFn<T[number]> | StorePathRange : never);
32
39
  declare type W<T> = Exclude<T, NotWrappable>;
33
40
  declare type KeyOf<T> = number extends keyof T ? 0 extends 1 & T ? keyof T : [T] extends [readonly unknown[]] ? number : [T] extends [never] ? never : keyof T : keyof T;
@@ -200,13 +200,12 @@ export declare function createMemo<Next extends Prev, Init = Next, Prev = Next>(
200
200
  export interface Resource<T> extends Accessor<T> {
201
201
  loading: boolean;
202
202
  error: any;
203
- latest: T | undefined;
203
+ latest: T;
204
204
  }
205
205
  export declare type ResourceActions<T> = {
206
206
  mutate: Setter<T>;
207
207
  refetch: (info?: unknown) => T | Promise<T> | undefined | null;
208
208
  };
209
- export declare type ResourceReturn<T> = [Resource<T>, ResourceActions<T>];
210
209
  export declare type ResourceSource<S> = S | false | null | undefined | (() => S | false | null | undefined);
211
210
  export declare type ResourceFetcher<S, T> = (k: S, info: ResourceFetcherInfo<T>) => T | Promise<T>;
212
211
  export declare type ResourceFetcherInfo<T> = {
@@ -224,6 +223,10 @@ export declare type ResourceOptions<T> = undefined extends T ? {
224
223
  deferStream?: boolean;
225
224
  onHydrated?: <S, T>(k: S, info: ResourceFetcherInfo<T>) => void;
226
225
  };
226
+ export declare type ResourceReturn<T, O extends ResourceOptions<T | undefined> | undefined, K = T> = [
227
+ Resource<O extends undefined | null ? T | undefined : NonNullable<O>["initialValue"] extends undefined ? T | undefined : T>,
228
+ ResourceActions<K>
229
+ ];
227
230
  /**
228
231
  * Creates a resource that wraps a repeated promise in a reactive pattern:
229
232
  * ```typescript
@@ -249,10 +252,10 @@ export declare type ResourceOptions<T> = undefined extends T ? {
249
252
  *
250
253
  * @description https://www.solidjs.com/docs/latest/api#createresource
251
254
  */
252
- export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S, T>, options?: ResourceOptions<undefined>): ResourceReturn<T | undefined>;
253
- export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): ResourceReturn<T>;
254
- export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options?: ResourceOptions<undefined>): ResourceReturn<T | undefined>;
255
- export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): ResourceReturn<T>;
255
+ export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S, T>, options?: ResourceOptions<undefined>): ResourceReturn<T | undefined, typeof options>;
256
+ export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): ResourceReturn<T, typeof options>;
257
+ export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options?: ResourceOptions<undefined>): ResourceReturn<T | undefined, typeof options>;
258
+ export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): ResourceReturn<T, typeof options>;
256
259
  export interface DeferredOptions<T> {
257
260
  equals?: false | ((prev: T, next: T) => boolean);
258
261
  name?: string;
@@ -66,25 +66,19 @@ export declare type ComponentProps<T extends keyof JSX.IntrinsicElements | Compo
66
66
  */
67
67
  export declare type Ref<T> = T | ((val: T) => void);
68
68
  export declare function createComponent<T>(Comp: Component<T>, props: T): JSX.Element;
69
- declare type Simplify<T> = T extends object ? {
70
- [K in keyof T]: T[K];
71
- } : T;
72
- declare type UnboxLazy<T> = T extends () => infer U ? U : T;
73
- declare type RequiredKeys<T> = keyof {
74
- [K in keyof T as T extends {
75
- [_ in K]: unknown;
76
- } ? K : never]: 0;
77
- };
78
- declare type Override<T, U> = {
79
- [K in keyof Omit<T, RequiredKeys<U>>]: T[K] | Exclude<U[K & keyof U], undefined>;
69
+ declare type Override<T, U> = T extends any ? U extends any ? {
70
+ [K in keyof T]: K extends keyof U ? undefined extends U[K] ? Exclude<U[K], undefined> | T[K] : U[K] : T[K];
80
71
  } & {
81
- [K in keyof Omit<U, Exclude<keyof T, RequiredKeys<U>>>]: Exclude<U[K], undefined> | (undefined extends U[K] ? (K extends keyof T ? T[K] : undefined) : never);
82
- };
83
- export declare type MergeProps<T extends unknown[], Curr = {}> = T extends [infer Next, ...infer Rest] ? MergeProps<Rest, Next extends object ? (Next extends Function ? Curr : Override<Curr, UnboxLazy<Next>>) : Curr> : Simplify<Curr>;
72
+ [K in keyof U]: K extends keyof T ? undefined extends U[K] ? Exclude<U[K], undefined> | T[K] : U[K] : U[K];
73
+ } : T & U : T & U;
74
+ export declare type MergeProps<T extends unknown[], Curr = {}> = T extends [
75
+ infer Next | (() => infer Next),
76
+ ...infer Rest
77
+ ] ? MergeProps<Rest, Override<Curr, Next>> : Curr;
84
78
  export declare function mergeProps<T extends [unknown, ...unknown[]]>(...sources: T): MergeProps<T>;
85
79
  export declare type SplitProps<T, K extends (readonly (keyof T)[])[]> = [
86
80
  ...{
87
- [P in keyof K]: P extends `${number}` ? Pick<T, Extract<K[P], readonly (keyof T)[]>[number]> : K[P];
81
+ [P in keyof K]: P extends `${number}` ? Pick<T, Extract<K[P], readonly (keyof T)[]>[number]> : never;
88
82
  },
89
83
  Omit<T, K[number][number]>
90
84
  ];
@@ -7,7 +7,7 @@ declare type SharedConfig = {
7
7
  resources?: {
8
8
  [key: string]: any;
9
9
  };
10
- load?: (id: string) => Promise<any> | undefined;
10
+ load?: (id: string) => Promise<any> | any | undefined;
11
11
  gather?: (key: string) => void;
12
12
  registry?: Map<string, Element>;
13
13
  done?: boolean;
@@ -269,7 +269,7 @@ function renderToStringAsync(code, options = {}) {
269
269
  nonce,
270
270
  writeResource(id, p, error) {
271
271
  if (error) return scripts += `_$HY.set("${id}", ${serializeError(p)});`;
272
- if (!p || typeof p !== "object" || !("then" in p)) return (scripts += serializeSet(dedupe, id, p)) + ";";
272
+ if (!p || typeof p !== "object" || !("then" in p)) return scripts += serializeSet(dedupe, id, p) + ";";
273
273
  p.then(d => scripts += serializeSet(dedupe, id, d) + ";").catch(() => scripts += `_$HY.set("${id}", {});`);
274
274
  }
275
275
  };
@@ -266,7 +266,7 @@ function renderToStringAsync(code, options = {}) {
266
266
  nonce,
267
267
  writeResource(id, p, error) {
268
268
  if (error) return scripts += `_$HY.set("${id}", ${serializeError(p)});`;
269
- if (!p || typeof p !== "object" || !("then" in p)) return (scripts += serializeSet(dedupe, id, p)) + ";";
269
+ if (!p || typeof p !== "object" || !("then" in p)) return scripts += serializeSet(dedupe, id, p) + ";";
270
270
  p.then(d => scripts += serializeSet(dedupe, id, d) + ";").catch(() => scripts += `_$HY.set("${id}", {});`);
271
271
  }
272
272
  };