solid-js 1.5.0-beta.3 → 1.5.0-beta.6

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
@@ -264,7 +264,7 @@ function createResource(pSource, pFetcher, pOptions) {
264
264
  resolved = ("initialValue" in options),
265
265
  dynamic = typeof source === "function" && createMemo(source);
266
266
  const contexts = new Set(),
267
- [value, setValue] = options.store ? options.store(options.initialValue) : createSignal(options.initialValue),
267
+ [value, setValue] = (options.storage || createSignal)(options.initialValue),
268
268
  [track, trigger] = createSignal(undefined, {
269
269
  equals: false
270
270
  }),
@@ -272,7 +272,7 @@ function createResource(pSource, pFetcher, pOptions) {
272
272
  if (sharedConfig.context) {
273
273
  id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
274
274
  let v;
275
- if (options.useInitialValue) initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
275
+ if (options.ssrValue === "initial") initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
276
276
  }
277
277
  function loadEnd(p, v, success, key) {
278
278
  if (pr === p) {
@@ -301,7 +301,7 @@ function createResource(pSource, pFetcher, pOptions) {
301
301
  !success && (err = castError(v));
302
302
  runUpdates(() => {
303
303
  setValue(() => v);
304
- setState(success ? "ready" : "error");
304
+ setState(success ? "ready" : "errored");
305
305
  for (const c of contexts.keys()) c.decrement();
306
306
  contexts.clear();
307
307
  }, false);
@@ -353,9 +353,7 @@ function createResource(pSource, pFetcher, pOptions) {
353
353
  }
354
354
  Object.defineProperties(read, {
355
355
  state: {
356
- get() {
357
- return state();
358
- }
356
+ get: () => state()
359
357
  },
360
358
  loading: {
361
359
  get() {
@@ -365,13 +363,13 @@ function createResource(pSource, pFetcher, pOptions) {
365
363
  },
366
364
  error: {
367
365
  get() {
368
- return state() === "error" ? err : undefined;
366
+ return state() === "errored" ? err : undefined;
369
367
  }
370
368
  },
371
369
  latest: {
372
370
  get() {
373
371
  if (!resolved) return read();
374
- if (state() === "error") throw err;
372
+ if (state() === "errored") throw err;
375
373
  return value();
376
374
  }
377
375
  }
@@ -400,9 +398,8 @@ function createSelector(source, fn = equalFn, options) {
400
398
  const subs = new Map();
401
399
  const node = createComputation(p => {
402
400
  const v = source();
403
- for (const key of subs.keys()) if (fn(key, v) !== fn(key, p)) {
404
- const l = subs.get(key);
405
- for (const c of l.values()) {
401
+ for (const [key, val] of subs.entries()) if (fn(key, v) !== fn(key, p)) {
402
+ for (const c of val.values()) {
406
403
  c.state = STALE;
407
404
  if (c.pure) Updates.push(c);else Effects.push(c);
408
405
  }
@@ -411,8 +408,8 @@ function createSelector(source, fn = equalFn, options) {
411
408
  }, undefined, true, STALE, options );
412
409
  updateComputation(node);
413
410
  return key => {
414
- let listener;
415
- if (listener = Listener) {
411
+ const listener = Listener;
412
+ if (listener) {
416
413
  let l;
417
414
  if (l = subs.get(key)) l.add(listener);else subs.set(key, l = new Set([listener]));
418
415
  onCleanup(() => {
@@ -585,7 +582,12 @@ function useContext(context) {
585
582
  }
586
583
  function children(fn) {
587
584
  const children = createMemo(fn);
588
- return createMemo(() => resolveChildren(children()));
585
+ const memo = createMemo(() => resolveChildren(children()));
586
+ memo.toArray = () => {
587
+ const c = memo();
588
+ return Array.isArray(c) ? c : c != null ? [c] : [];
589
+ };
590
+ return memo;
589
591
  }
590
592
  let SuspenseContext;
591
593
  function getSuspenseContext() {
@@ -700,7 +702,7 @@ function runComputation(node, value, time) {
700
702
  handleError(err);
701
703
  }
702
704
  if (!node.updatedAt || node.updatedAt <= time) {
703
- if (node.updatedAt && "observers" in node) {
705
+ if (node.updatedAt != null && "observers" in node) {
704
706
  writeSignal(node, nextValue, true);
705
707
  } else if (Transition && Transition.running && node.pure) {
706
708
  Transition.sources.add(node);
package/dist/dev.js CHANGED
@@ -260,7 +260,7 @@ function createResource(pSource, pFetcher, pOptions) {
260
260
  resolved = ("initialValue" in options),
261
261
  dynamic = typeof source === "function" && createMemo(source);
262
262
  const contexts = new Set(),
263
- [value, setValue] = options.store ? options.store(options.initialValue) : createSignal(options.initialValue),
263
+ [value, setValue] = (options.storage || createSignal)(options.initialValue),
264
264
  [track, trigger] = createSignal(undefined, {
265
265
  equals: false
266
266
  }),
@@ -268,7 +268,7 @@ function createResource(pSource, pFetcher, pOptions) {
268
268
  if (sharedConfig.context) {
269
269
  id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
270
270
  let v;
271
- if (options.useInitialValue) initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
271
+ if (options.ssrValue === "initial") initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
272
272
  }
273
273
  function loadEnd(p, v, success, key) {
274
274
  if (pr === p) {
@@ -297,7 +297,7 @@ function createResource(pSource, pFetcher, pOptions) {
297
297
  !success && (err = castError(v));
298
298
  runUpdates(() => {
299
299
  setValue(() => v);
300
- setState(success ? "ready" : "error");
300
+ setState(success ? "ready" : "errored");
301
301
  for (const c of contexts.keys()) c.decrement();
302
302
  contexts.clear();
303
303
  }, false);
@@ -349,9 +349,7 @@ function createResource(pSource, pFetcher, pOptions) {
349
349
  }
350
350
  Object.defineProperties(read, {
351
351
  state: {
352
- get() {
353
- return state();
354
- }
352
+ get: () => state()
355
353
  },
356
354
  loading: {
357
355
  get() {
@@ -361,13 +359,13 @@ function createResource(pSource, pFetcher, pOptions) {
361
359
  },
362
360
  error: {
363
361
  get() {
364
- return state() === "error" ? err : undefined;
362
+ return state() === "errored" ? err : undefined;
365
363
  }
366
364
  },
367
365
  latest: {
368
366
  get() {
369
367
  if (!resolved) return read();
370
- if (state() === "error") throw err;
368
+ if (state() === "errored") throw err;
371
369
  return value();
372
370
  }
373
371
  }
@@ -396,9 +394,8 @@ function createSelector(source, fn = equalFn, options) {
396
394
  const subs = new Map();
397
395
  const node = createComputation(p => {
398
396
  const v = source();
399
- for (const key of subs.keys()) if (fn(key, v) !== fn(key, p)) {
400
- const l = subs.get(key);
401
- for (const c of l.values()) {
397
+ for (const [key, val] of subs.entries()) if (fn(key, v) !== fn(key, p)) {
398
+ for (const c of val.values()) {
402
399
  c.state = STALE;
403
400
  if (c.pure) Updates.push(c);else Effects.push(c);
404
401
  }
@@ -407,8 +404,8 @@ function createSelector(source, fn = equalFn, options) {
407
404
  }, undefined, true, STALE, options );
408
405
  updateComputation(node);
409
406
  return key => {
410
- let listener;
411
- if (listener = Listener) {
407
+ const listener = Listener;
408
+ if (listener) {
412
409
  let l;
413
410
  if (l = subs.get(key)) l.add(listener);else subs.set(key, l = new Set([listener]));
414
411
  onCleanup(() => {
@@ -581,7 +578,12 @@ function useContext(context) {
581
578
  }
582
579
  function children(fn) {
583
580
  const children = createMemo(fn);
584
- return createMemo(() => resolveChildren(children()));
581
+ const memo = createMemo(() => resolveChildren(children()));
582
+ memo.toArray = () => {
583
+ const c = memo();
584
+ return Array.isArray(c) ? c : c != null ? [c] : [];
585
+ };
586
+ return memo;
585
587
  }
586
588
  let SuspenseContext;
587
589
  function getSuspenseContext() {
@@ -696,7 +698,7 @@ function runComputation(node, value, time) {
696
698
  handleError(err);
697
699
  }
698
700
  if (!node.updatedAt || node.updatedAt <= time) {
699
- if (node.updatedAt && "observers" in node) {
701
+ if (node.updatedAt != null && "observers" in node) {
700
702
  writeSignal(node, nextValue, true);
701
703
  } else if (Transition && Transition.running && node.pure) {
702
704
  Transition.sources.add(node);
package/dist/server.cjs CHANGED
@@ -144,7 +144,12 @@ function getOwner() {
144
144
  return Owner;
145
145
  }
146
146
  function children(fn) {
147
- return createMemo(() => resolveChildren(fn()));
147
+ const memo = createMemo(() => resolveChildren(fn()));
148
+ memo.toArray = () => {
149
+ const c = memo();
150
+ return Array.isArray(c) ? c : c != null ? [c] : [];
151
+ };
152
+ return memo;
148
153
  }
149
154
  function runWithOwner(o, fn) {
150
155
  const prev = Owner;
@@ -391,10 +396,10 @@ function createResource(source, fetcher, options = {}) {
391
396
  const contexts = new Set();
392
397
  const id = sharedConfig.context.id + sharedConfig.context.count++;
393
398
  let resource = {};
394
- let value = options.initialValue;
399
+ let value = options.storage ? options.storage(options.initialValue)[0]() : options.initialValue;
395
400
  let p;
396
401
  let error;
397
- if (sharedConfig.context.async && !options.useInitialValue) {
402
+ if (sharedConfig.context.async && options.ssrValue !== "initial") {
398
403
  resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
399
404
  if (resource.ref) {
400
405
  if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error) resource.ref[1].refetch();
@@ -404,7 +409,7 @@ function createResource(source, fetcher, options = {}) {
404
409
  const read = () => {
405
410
  if (error) throw error;
406
411
  if (resourceContext && p) resourceContext.push(p);
407
- const resolved = !options.useInitialValue && sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
412
+ const resolved = options.ssrValue !== "initial" && sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
408
413
  if (!resolved && read.loading) {
409
414
  const ctx = useContext(SuspenseContext);
410
415
  if (ctx) {
@@ -416,6 +421,7 @@ function createResource(source, fetcher, options = {}) {
416
421
  };
417
422
  read.loading = false;
418
423
  read.error = undefined;
424
+ read.state = "initialValue" in options ? "resolved" : "unresolved";
419
425
  Object.defineProperty(read, "latest", {
420
426
  get() {
421
427
  return read();
@@ -444,15 +450,18 @@ function createResource(source, fetcher, options = {}) {
444
450
  }
445
451
  if (p != undefined && typeof p === "object" && "then" in p) {
446
452
  read.loading = true;
453
+ read.state = "pending";
447
454
  if (ctx.writeResource) ctx.writeResource(id, p, undefined, options.deferStream);
448
455
  return p.then(res => {
449
456
  read.loading = false;
457
+ read.state = "resolved";
450
458
  ctx.resources[id].data = res;
451
459
  p = null;
452
460
  notifySuspense(contexts);
453
461
  return res;
454
462
  }).catch(err => {
455
463
  read.loading = false;
464
+ read.state = "errored";
456
465
  read.error = error = castError(err);
457
466
  p = null;
458
467
  notifySuspense(contexts);
@@ -463,7 +472,7 @@ function createResource(source, fetcher, options = {}) {
463
472
  p = null;
464
473
  return ctx.resources[id].data;
465
474
  }
466
- if (!options.useInitialValue) load();
475
+ if (options.ssrValue !== "initial") load();
467
476
  return resource.ref = [read, {
468
477
  refetch: load,
469
478
  mutate: v => value = v
package/dist/server.js CHANGED
@@ -140,7 +140,12 @@ function getOwner() {
140
140
  return Owner;
141
141
  }
142
142
  function children(fn) {
143
- return createMemo(() => resolveChildren(fn()));
143
+ const memo = createMemo(() => resolveChildren(fn()));
144
+ memo.toArray = () => {
145
+ const c = memo();
146
+ return Array.isArray(c) ? c : c != null ? [c] : [];
147
+ };
148
+ return memo;
144
149
  }
145
150
  function runWithOwner(o, fn) {
146
151
  const prev = Owner;
@@ -387,10 +392,10 @@ function createResource(source, fetcher, options = {}) {
387
392
  const contexts = new Set();
388
393
  const id = sharedConfig.context.id + sharedConfig.context.count++;
389
394
  let resource = {};
390
- let value = options.initialValue;
395
+ let value = options.storage ? options.storage(options.initialValue)[0]() : options.initialValue;
391
396
  let p;
392
397
  let error;
393
- if (sharedConfig.context.async && !options.useInitialValue) {
398
+ if (sharedConfig.context.async && options.ssrValue !== "initial") {
394
399
  resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
395
400
  if (resource.ref) {
396
401
  if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error) resource.ref[1].refetch();
@@ -400,7 +405,7 @@ function createResource(source, fetcher, options = {}) {
400
405
  const read = () => {
401
406
  if (error) throw error;
402
407
  if (resourceContext && p) resourceContext.push(p);
403
- const resolved = !options.useInitialValue && sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
408
+ const resolved = options.ssrValue !== "initial" && sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
404
409
  if (!resolved && read.loading) {
405
410
  const ctx = useContext(SuspenseContext);
406
411
  if (ctx) {
@@ -412,6 +417,7 @@ function createResource(source, fetcher, options = {}) {
412
417
  };
413
418
  read.loading = false;
414
419
  read.error = undefined;
420
+ read.state = "initialValue" in options ? "resolved" : "unresolved";
415
421
  Object.defineProperty(read, "latest", {
416
422
  get() {
417
423
  return read();
@@ -440,15 +446,18 @@ function createResource(source, fetcher, options = {}) {
440
446
  }
441
447
  if (p != undefined && typeof p === "object" && "then" in p) {
442
448
  read.loading = true;
449
+ read.state = "pending";
443
450
  if (ctx.writeResource) ctx.writeResource(id, p, undefined, options.deferStream);
444
451
  return p.then(res => {
445
452
  read.loading = false;
453
+ read.state = "resolved";
446
454
  ctx.resources[id].data = res;
447
455
  p = null;
448
456
  notifySuspense(contexts);
449
457
  return res;
450
458
  }).catch(err => {
451
459
  read.loading = false;
460
+ read.state = "errored";
452
461
  read.error = error = castError(err);
453
462
  p = null;
454
463
  notifySuspense(contexts);
@@ -459,7 +468,7 @@ function createResource(source, fetcher, options = {}) {
459
468
  p = null;
460
469
  return ctx.resources[id].data;
461
470
  }
462
- if (!options.useInitialValue) load();
471
+ if (options.ssrValue !== "initial") load();
463
472
  return resource.ref = [read, {
464
473
  refetch: load,
465
474
  mutate: v => value = v
package/dist/solid.cjs CHANGED
@@ -256,7 +256,7 @@ function createResource(pSource, pFetcher, pOptions) {
256
256
  resolved = ("initialValue" in options),
257
257
  dynamic = typeof source === "function" && createMemo(source);
258
258
  const contexts = new Set(),
259
- [value, setValue] = options.store ? options.store(options.initialValue) : createSignal(options.initialValue),
259
+ [value, setValue] = (options.storage || createSignal)(options.initialValue),
260
260
  [track, trigger] = createSignal(undefined, {
261
261
  equals: false
262
262
  }),
@@ -264,7 +264,7 @@ function createResource(pSource, pFetcher, pOptions) {
264
264
  if (sharedConfig.context) {
265
265
  id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
266
266
  let v;
267
- if (options.useInitialValue) initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
267
+ if (options.ssrValue === "initial") initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
268
268
  }
269
269
  function loadEnd(p, v, success, key) {
270
270
  if (pr === p) {
@@ -293,7 +293,7 @@ function createResource(pSource, pFetcher, pOptions) {
293
293
  !success && (err = castError(v));
294
294
  runUpdates(() => {
295
295
  setValue(() => v);
296
- setState(success ? "ready" : "error");
296
+ setState(success ? "ready" : "errored");
297
297
  for (const c of contexts.keys()) c.decrement();
298
298
  contexts.clear();
299
299
  }, false);
@@ -345,9 +345,7 @@ function createResource(pSource, pFetcher, pOptions) {
345
345
  }
346
346
  Object.defineProperties(read, {
347
347
  state: {
348
- get() {
349
- return state();
350
- }
348
+ get: () => state()
351
349
  },
352
350
  loading: {
353
351
  get() {
@@ -357,13 +355,13 @@ function createResource(pSource, pFetcher, pOptions) {
357
355
  },
358
356
  error: {
359
357
  get() {
360
- return state() === "error" ? err : undefined;
358
+ return state() === "errored" ? err : undefined;
361
359
  }
362
360
  },
363
361
  latest: {
364
362
  get() {
365
363
  if (!resolved) return read();
366
- if (state() === "error") throw err;
364
+ if (state() === "errored") throw err;
367
365
  return value();
368
366
  }
369
367
  }
@@ -392,9 +390,8 @@ function createSelector(source, fn = equalFn, options) {
392
390
  const subs = new Map();
393
391
  const node = createComputation(p => {
394
392
  const v = source();
395
- for (const key of subs.keys()) if (fn(key, v) !== fn(key, p)) {
396
- const l = subs.get(key);
397
- for (const c of l.values()) {
393
+ for (const [key, val] of subs.entries()) if (fn(key, v) !== fn(key, p)) {
394
+ for (const c of val.values()) {
398
395
  c.state = STALE;
399
396
  if (c.pure) Updates.push(c);else Effects.push(c);
400
397
  }
@@ -403,8 +400,8 @@ function createSelector(source, fn = equalFn, options) {
403
400
  }, undefined, true, STALE);
404
401
  updateComputation(node);
405
402
  return key => {
406
- let listener;
407
- if (listener = Listener) {
403
+ const listener = Listener;
404
+ if (listener) {
408
405
  let l;
409
406
  if (l = subs.get(key)) l.add(listener);else subs.set(key, l = new Set([listener]));
410
407
  onCleanup(() => {
@@ -525,7 +522,12 @@ function useContext(context) {
525
522
  }
526
523
  function children(fn) {
527
524
  const children = createMemo(fn);
528
- return createMemo(() => resolveChildren(children()));
525
+ const memo = createMemo(() => resolveChildren(children()));
526
+ memo.toArray = () => {
527
+ const c = memo();
528
+ return Array.isArray(c) ? c : c != null ? [c] : [];
529
+ };
530
+ return memo;
529
531
  }
530
532
  let SuspenseContext;
531
533
  function getSuspenseContext() {
@@ -640,7 +642,7 @@ function runComputation(node, value, time) {
640
642
  handleError(err);
641
643
  }
642
644
  if (!node.updatedAt || node.updatedAt <= time) {
643
- if (node.updatedAt && "observers" in node) {
645
+ if (node.updatedAt != null && "observers" in node) {
644
646
  writeSignal(node, nextValue, true);
645
647
  } else if (Transition && Transition.running && node.pure) {
646
648
  Transition.sources.add(node);
package/dist/solid.js CHANGED
@@ -252,7 +252,7 @@ function createResource(pSource, pFetcher, pOptions) {
252
252
  resolved = ("initialValue" in options),
253
253
  dynamic = typeof source === "function" && createMemo(source);
254
254
  const contexts = new Set(),
255
- [value, setValue] = options.store ? options.store(options.initialValue) : createSignal(options.initialValue),
255
+ [value, setValue] = (options.storage || createSignal)(options.initialValue),
256
256
  [track, trigger] = createSignal(undefined, {
257
257
  equals: false
258
258
  }),
@@ -260,7 +260,7 @@ function createResource(pSource, pFetcher, pOptions) {
260
260
  if (sharedConfig.context) {
261
261
  id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
262
262
  let v;
263
- if (options.useInitialValue) initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
263
+ if (options.ssrValue === "initial") initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
264
264
  }
265
265
  function loadEnd(p, v, success, key) {
266
266
  if (pr === p) {
@@ -289,7 +289,7 @@ function createResource(pSource, pFetcher, pOptions) {
289
289
  !success && (err = castError(v));
290
290
  runUpdates(() => {
291
291
  setValue(() => v);
292
- setState(success ? "ready" : "error");
292
+ setState(success ? "ready" : "errored");
293
293
  for (const c of contexts.keys()) c.decrement();
294
294
  contexts.clear();
295
295
  }, false);
@@ -341,9 +341,7 @@ function createResource(pSource, pFetcher, pOptions) {
341
341
  }
342
342
  Object.defineProperties(read, {
343
343
  state: {
344
- get() {
345
- return state();
346
- }
344
+ get: () => state()
347
345
  },
348
346
  loading: {
349
347
  get() {
@@ -353,13 +351,13 @@ function createResource(pSource, pFetcher, pOptions) {
353
351
  },
354
352
  error: {
355
353
  get() {
356
- return state() === "error" ? err : undefined;
354
+ return state() === "errored" ? err : undefined;
357
355
  }
358
356
  },
359
357
  latest: {
360
358
  get() {
361
359
  if (!resolved) return read();
362
- if (state() === "error") throw err;
360
+ if (state() === "errored") throw err;
363
361
  return value();
364
362
  }
365
363
  }
@@ -388,9 +386,8 @@ function createSelector(source, fn = equalFn, options) {
388
386
  const subs = new Map();
389
387
  const node = createComputation(p => {
390
388
  const v = source();
391
- for (const key of subs.keys()) if (fn(key, v) !== fn(key, p)) {
392
- const l = subs.get(key);
393
- for (const c of l.values()) {
389
+ for (const [key, val] of subs.entries()) if (fn(key, v) !== fn(key, p)) {
390
+ for (const c of val.values()) {
394
391
  c.state = STALE;
395
392
  if (c.pure) Updates.push(c);else Effects.push(c);
396
393
  }
@@ -399,8 +396,8 @@ function createSelector(source, fn = equalFn, options) {
399
396
  }, undefined, true, STALE);
400
397
  updateComputation(node);
401
398
  return key => {
402
- let listener;
403
- if (listener = Listener) {
399
+ const listener = Listener;
400
+ if (listener) {
404
401
  let l;
405
402
  if (l = subs.get(key)) l.add(listener);else subs.set(key, l = new Set([listener]));
406
403
  onCleanup(() => {
@@ -521,7 +518,12 @@ function useContext(context) {
521
518
  }
522
519
  function children(fn) {
523
520
  const children = createMemo(fn);
524
- return createMemo(() => resolveChildren(children()));
521
+ const memo = createMemo(() => resolveChildren(children()));
522
+ memo.toArray = () => {
523
+ const c = memo();
524
+ return Array.isArray(c) ? c : c != null ? [c] : [];
525
+ };
526
+ return memo;
525
527
  }
526
528
  let SuspenseContext;
527
529
  function getSuspenseContext() {
@@ -636,7 +638,7 @@ function runComputation(node, value, time) {
636
638
  handleError(err);
637
639
  }
638
640
  if (!node.updatedAt || node.updatedAt <= time) {
639
- if (node.updatedAt && "observers" in node) {
641
+ if (node.updatedAt != null && "observers" in node) {
640
642
  writeSignal(node, nextValue, true);
641
643
  } else if (Transition && Transition.running && node.pure) {
642
644
  Transition.sources.add(node);
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.5.0-beta.3",
4
+ "version": "1.5.0-beta.6",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
@@ -73,6 +73,10 @@
73
73
  "require": "./dist/solid.cjs"
74
74
  },
75
75
  "./dist/*": "./dist/*",
76
+ "./jsx-runtime": {
77
+ "types": "./types/jsx.d.ts",
78
+ "default": "./dist/solid.js"
79
+ },
76
80
  "./store": {
77
81
  "browser": {
78
82
  "development": {
@@ -55,9 +55,9 @@ export interface SetStoreFunction<T> {
55
55
  *
56
56
  * @description https://www.solidjs.com/docs/latest/api#createstore
57
57
  */
58
- export declare function createStore<T extends {}>(...[store, options]: {} extends T ? [store?: T | Store<T>, options?: {
58
+ export declare function createStore<T extends object = {}>(...[store, options]: {} extends T ? [store?: T | Store<T>, options?: {
59
59
  name?: string;
60
- }] : [store: object & (T | Store<T>), options?: {
60
+ }] : [store: T | Store<T>, options?: {
61
61
  name?: string;
62
62
  }]): [get: Store<T>, set: SetStoreFunction<T>];
63
63
  export {};
package/types/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { createRoot, createSignal, createEffect, createRenderEffect, createComputed, createReaction, createDeferred, createSelector, createMemo, createResource, onMount, onCleanup, onError, untrack, batch, on, enableScheduling, enableExternalSource, startTransition, useTransition, createContext, useContext, children, getListener, getOwner, runWithOwner, equalFn, $DEVCOMP, $PROXY, $TRACK } from "./reactive/signal.js";
2
- export type { Accessor, Setter, Signal, Resource, ResourceOptions, ResourceReturn, ResourceFetcher, ResourceFetcherInfo, Context, ReturnTypes, Owner, InitializedResource, InitializedResourceOptions, InitializedResourceReturn } from "./reactive/signal.js";
2
+ export type { Accessor, Setter, Signal, Resource, ResourceOptions, ResourceReturn, ResourceFetcher, ResourceFetcherInfo, ChildrenReturn, Context, ReturnTypes, Owner, InitializedResource, InitializedResourceOptions, InitializedResourceReturn } from "./reactive/signal.js";
3
3
  export * from "./reactive/observable.js";
4
4
  export * from "./reactive/scheduler.js";
5
5
  export * from "./reactive/array.js";
@@ -224,15 +224,15 @@ interface Refreshing<T> {
224
224
  latest: T;
225
225
  (): T;
226
226
  }
227
- interface Error {
228
- state: "error";
227
+ interface Errored {
228
+ state: "errored";
229
229
  loading: false;
230
230
  error: any;
231
231
  latest: never;
232
232
  (): never;
233
233
  }
234
- export declare type Resource<T> = Unresolved | Pending | Ready<T> | Refreshing<T> | Error;
235
- export declare type InitializedResource<T> = Ready<T> | Refreshing<T> | Error;
234
+ export declare type Resource<T> = Unresolved | Pending | Ready<T> | Refreshing<T> | Errored;
235
+ export declare type InitializedResource<T> = Ready<T> | Refreshing<T> | Errored;
236
236
  export declare type ResourceActions<T, R = unknown> = {
237
237
  mutate: Setter<T | undefined>;
238
238
  refetch: (info?: R) => T | Promise<T> | undefined | null;
@@ -247,8 +247,8 @@ export declare type ResourceOptions<T, S = unknown> = {
247
247
  initialValue?: T;
248
248
  name?: string;
249
249
  deferStream?: boolean;
250
- useInitialValue?: boolean;
251
- store?: (init: T | undefined) => [Accessor<T | undefined>, Setter<T | undefined>];
250
+ ssrValue?: "initial" | "server";
251
+ storage?: (init: T | undefined) => [Accessor<T | undefined>, Setter<T | undefined>];
252
252
  onHydrated?: (k: S | undefined, info: {
253
253
  value: T | undefined;
254
254
  }) => void;
@@ -489,6 +489,9 @@ export declare function createContext<T>(defaultValue: T): Context<T>;
489
489
  export declare function useContext<T>(context: Context<T>): T;
490
490
  export declare type ResolvedJSXElement = Exclude<JSX.Element, JSX.ArrayElement | JSX.FunctionElement>;
491
491
  export declare type ResolvedChildren = ResolvedJSXElement | ResolvedJSXElement[];
492
+ export declare type ChildrenReturn = Accessor<ResolvedChildren> & {
493
+ toArray: () => ResolvedJSXElement[];
494
+ };
492
495
  /**
493
496
  * Resolves child elements to help interact with children
494
497
  *
@@ -497,7 +500,7 @@ export declare type ResolvedChildren = ResolvedJSXElement | ResolvedJSXElement[]
497
500
  *
498
501
  * @description https://www.solidjs.com/docs/latest/api#children
499
502
  */
500
- export declare function children(fn: Accessor<JSX.Element>): Accessor<ResolvedChildren>;
503
+ export declare function children(fn: Accessor<JSX.Element>): ChildrenReturn;
501
504
  export declare type SuspenseContextType = {
502
505
  increment?: () => void;
503
506
  decrement?: () => void;
@@ -4,6 +4,7 @@ export declare const $DEVCOMP: unique symbol;
4
4
  export declare const DEV: {};
5
5
  export declare type Accessor<T> = () => T;
6
6
  export declare type Setter<T> = undefined extends T ? <U extends T>(value?: (U extends Function ? never : U) | ((prev?: T) => U)) => U : <U extends T>(value: (U extends Function ? never : U) | ((prev: T) => U)) => U;
7
+ export declare type Signal<T> = [get: Accessor<T>, set: Setter<T>];
7
8
  export declare const BRANCH: unique symbol;
8
9
  export declare function castError(err: any): string | Error;
9
10
  export declare let Owner: Owner | null;
@@ -46,7 +47,10 @@ export interface Context<T> {
46
47
  export declare function createContext<T>(defaultValue?: T): Context<T>;
47
48
  export declare function useContext<T>(context: Context<T>): T;
48
49
  export declare function getOwner(): Owner | null;
49
- export declare function children(fn: () => any): () => unknown;
50
+ declare type ChildrenReturn = Accessor<any> & {
51
+ toArray: () => any[];
52
+ };
53
+ export declare function children(fn: () => any): ChildrenReturn;
50
54
  export declare function runWithOwner<T>(o: Owner, fn: () => T): T | undefined;
51
55
  export declare function lookup(owner: Owner | null, key: symbol | string): any;
52
56
  export interface Task {
@@ -1,4 +1,4 @@
1
- import { Setter } from "./reactive.js";
1
+ import { Setter, Signal } from "./reactive.js";
2
2
  import type { JSX } from "../jsx.js";
3
3
  export declare type Component<P = {}> = (props: P) => JSX.Element;
4
4
  export declare type VoidProps<P = {}> = P & {
@@ -72,7 +72,7 @@ export declare function ErrorBoundary(props: {
72
72
  };
73
73
  export interface Resource<T> {
74
74
  (): T | undefined;
75
- state: "unresolved" | "pending" | "ready" | "refreshing" | "error";
75
+ state: "unresolved" | "pending" | "ready" | "refreshing" | "errored";
76
76
  loading: boolean;
77
77
  error: any;
78
78
  latest: T | undefined;
@@ -100,13 +100,15 @@ export declare type ResourceOptions<T> = undefined extends T ? {
100
100
  initialValue?: T;
101
101
  name?: string;
102
102
  deferStream?: boolean;
103
- useInitialValue?: boolean;
103
+ ssrValue?: "initial" | "server";
104
+ storage?: () => Signal<T | undefined>;
104
105
  onHydrated?: <S, T>(k: S, info: ResourceFetcherInfo<T>) => void;
105
106
  } : {
106
107
  initialValue: T;
107
108
  name?: string;
108
109
  deferStream?: boolean;
109
- useInitialValue?: boolean;
110
+ ssrValue?: "initial" | "server";
111
+ storage?: (v?: T) => Signal<T | undefined>;
110
112
  onHydrated?: <S, T>(k: S, info: ResourceFetcherInfo<T>) => void;
111
113
  };
112
114
  export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S, T>, options?: ResourceOptions<undefined>): ResourceReturn<T | undefined>;
package/web/dist/dev.cjs CHANGED
@@ -502,12 +502,10 @@ function getHydrationKey() {
502
502
  const hydrate = solidJs.sharedConfig.context;
503
503
  return `${hydrate.id}${hydrate.count++}`;
504
504
  }
505
- function Assets() {
506
- return;
507
- }
508
505
  function NoHydration(props) {
509
506
  return solidJs.sharedConfig.context ? undefined : props.children;
510
507
  }
508
+ function voidFn() {}
511
509
 
512
510
  function throwInBrowser(func) {
513
511
  const err = new Error(`${func.name} is not supported in the browser, returning undefined`);
@@ -530,7 +528,7 @@ function ssrAttribute(key, value) {}
530
528
  function ssrHydrationKey() {}
531
529
  function resolveSSRNode(node) {}
532
530
  function escape(html) {}
533
- function generateHydrationScript() {}
531
+ function ssrSpread(props, isSVG, skipChildren) {}
534
532
 
535
533
  const isServer = false;
536
534
  const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
@@ -647,12 +645,12 @@ Object.defineProperty(exports, 'mergeProps', {
647
645
  get: function () { return solidJs.mergeProps; }
648
646
  });
649
647
  exports.Aliases = Aliases;
650
- exports.Assets = Assets;
648
+ exports.Assets = voidFn;
651
649
  exports.ChildProperties = ChildProperties;
652
650
  exports.DOMElements = DOMElements;
653
651
  exports.DelegatedEvents = DelegatedEvents;
654
652
  exports.Dynamic = Dynamic;
655
- exports.HydrationScript = Assets;
653
+ exports.HydrationScript = voidFn;
656
654
  exports.NoHydration = NoHydration;
657
655
  exports.Portal = Portal;
658
656
  exports.PropAliases = PropAliases;
@@ -667,7 +665,8 @@ exports.clearDelegatedEvents = clearDelegatedEvents;
667
665
  exports.delegateEvents = delegateEvents;
668
666
  exports.dynamicProperty = dynamicProperty;
669
667
  exports.escape = escape;
670
- exports.generateHydrationScript = generateHydrationScript;
668
+ exports.generateHydrationScript = voidFn;
669
+ exports.getAssets = voidFn;
671
670
  exports.getHydrationKey = getHydrationKey;
672
671
  exports.getNextElement = getNextElement;
673
672
  exports.getNextMarker = getNextMarker;
@@ -691,7 +690,9 @@ exports.ssrAttribute = ssrAttribute;
691
690
  exports.ssrClassList = ssrClassList;
692
691
  exports.ssrElement = ssrElement;
693
692
  exports.ssrHydrationKey = ssrHydrationKey;
693
+ exports.ssrSpread = ssrSpread;
694
694
  exports.ssrStyle = ssrStyle;
695
695
  exports.style = style;
696
696
  exports.template = template;
697
697
  exports.use = use;
698
+ exports.useAssets = voidFn;
package/web/dist/dev.js CHANGED
@@ -499,12 +499,10 @@ function getHydrationKey() {
499
499
  const hydrate = sharedConfig.context;
500
500
  return `${hydrate.id}${hydrate.count++}`;
501
501
  }
502
- function Assets() {
503
- return;
504
- }
505
502
  function NoHydration(props) {
506
503
  return sharedConfig.context ? undefined : props.children;
507
504
  }
505
+ function voidFn() {}
508
506
 
509
507
  function throwInBrowser(func) {
510
508
  const err = new Error(`${func.name} is not supported in the browser, returning undefined`);
@@ -527,7 +525,7 @@ function ssrAttribute(key, value) {}
527
525
  function ssrHydrationKey() {}
528
526
  function resolveSSRNode(node) {}
529
527
  function escape(html) {}
530
- function generateHydrationScript() {}
528
+ function ssrSpread(props, isSVG, skipChildren) {}
531
529
 
532
530
  const isServer = false;
533
531
  const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
@@ -595,4 +593,4 @@ function Dynamic(props) {
595
593
  });
596
594
  }
597
595
 
598
- export { Aliases, Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, Assets as HydrationScript, NoHydration, Portal, PropAliases, Properties, SVGElements, SVGNamespace, addEventListener, assign, classList, className, clearDelegatedEvents, delegateEvents, dynamicProperty, escape, generateHydrationScript, getHydrationKey, getNextElement, getNextMarker, getNextMatch, hydrate, innerHTML, insert, isServer, memo, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, use };
596
+ export { Aliases, voidFn as Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, voidFn as HydrationScript, NoHydration, Portal, PropAliases, Properties, SVGElements, SVGNamespace, addEventListener, assign, classList, className, clearDelegatedEvents, delegateEvents, dynamicProperty, escape, voidFn as generateHydrationScript, voidFn as getAssets, getHydrationKey, getNextElement, getNextMarker, getNextMatch, hydrate, innerHTML, insert, isServer, memo, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrSpread, ssrStyle, style, template, use, voidFn as useAssets };
@@ -266,7 +266,8 @@ function toRefParam(index) {
266
266
  const REPLACE_SCRIPT = `function $df(e,t,d,l){d=document.getElementById(e),(l=document.getElementById("pl-"+e))&&l.replaceWith(...d.childNodes),d.remove(),_$HY.set(e,t)}`;
267
267
  function renderToString(code, options = {}) {
268
268
  let scripts = "";
269
- solidJs.sharedConfig.context = {
269
+ let context;
270
+ solidJs.sharedConfig.context = context = {
270
271
  id: options.renderId || "",
271
272
  count: 0,
272
273
  suspense: {},
@@ -277,7 +278,9 @@ function renderToString(code, options = {}) {
277
278
  scripts += `_$HY.set("${id}", ${stringify(p)});`;
278
279
  }
279
280
  };
280
- let html = injectAssets(solidJs.sharedConfig.context.assets, resolveSSRNode(escape(code())));
281
+ let html = resolveSSRNode(escape(code()));
282
+ solidJs.sharedConfig.context = undefined;
283
+ html = injectAssets(context.assets, html);
281
284
  if (scripts.length) html = injectScripts(html, scripts, options.nonce);
282
285
  return html;
283
286
  }
@@ -397,6 +400,7 @@ function renderToStream(code, options = {}) {
397
400
  };
398
401
  let html = resolveSSRNode(escape(code()));
399
402
  function doShell() {
403
+ solidJs.sharedConfig.context = undefined;
400
404
  html = injectAssets(context.assets, html);
401
405
  for (const key in context.resources) {
402
406
  if (!("data" in context.resources[key] || context.resources[key].ref[0].error)) pushTask(`_$HY.init("${key}")`);
@@ -460,22 +464,16 @@ function renderToStream(code, options = {}) {
460
464
  };
461
465
  }
462
466
  function Assets(props) {
463
- solidJs.sharedConfig.context.assets.push(() => NoHydration({
464
- get children() {
465
- return resolveSSRNode(props.children);
466
- }
467
- }));
468
- return ssr(`%%$${solidJs.sharedConfig.context.assets.length - 1}%%`);
467
+ useAssets(() => props.children);
469
468
  }
470
469
  function HydrationScript(props) {
471
470
  const {
472
471
  nonce
473
472
  } = solidJs.sharedConfig.context;
474
- solidJs.sharedConfig.context.assets.push(() => generateHydrationScript({
473
+ return ssr(generateHydrationScript({
475
474
  nonce,
476
475
  ...props
477
476
  }));
478
- return ssr(`%%$${solidJs.sharedConfig.context.assets.length - 1}%%`);
479
477
  }
480
478
  function NoHydration(props) {
481
479
  const c = solidJs.sharedConfig.context;
@@ -621,6 +619,15 @@ function getHydrationKey() {
621
619
  const hydrate = solidJs.sharedConfig.context;
622
620
  return hydrate && !hydrate.noHydrate && `${hydrate.id}${hydrate.count++}`;
623
621
  }
622
+ function useAssets(fn) {
623
+ solidJs.sharedConfig.context.assets.push(() => resolveSSRNode(fn()));
624
+ }
625
+ function getAssets() {
626
+ const assets = solidJs.sharedConfig.context.assets;
627
+ let out = "";
628
+ for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
629
+ return out;
630
+ }
624
631
  function generateHydrationScript({
625
632
  eventNames = ["click", "input"],
626
633
  nonce
@@ -628,10 +635,10 @@ function generateHydrationScript({
628
635
  return `<script${nonce ? ` nonce="${nonce}"` : ""}>var e,t;e=window._$HY||(_$HY={events:[],completed:new WeakSet,r:{}}),t=e=>e&&e.hasAttribute&&(e.hasAttribute("data-hk")?e:t(e.host&&e.host instanceof Node?e.host:e.parentNode)),["${eventNames.join('","')}"].forEach((o=>document.addEventListener(o,(o=>{let s=o.composedPath&&o.composedPath()[0]||o.target,a=t(s);a&&!e.completed.has(a)&&e.events.push([a,o])})))),e.init=(t,o)=>{e.r[t]=[new Promise(((e,t)=>o=e)),o]},e.set=(t,o,s)=>{(s=e.r[t])&&s[1](o),e.r[t]=[o]},e.unset=t=>{delete e.r[t]},e.load=t=>e.r[t];</script><!--xs-->`;
629
636
  }
630
637
  function injectAssets(assets, html) {
631
- for (let i = 0; i < assets.length; i++) {
632
- html = html.replace(`%%$${i}%%`, assets[i]());
633
- }
634
- return html;
638
+ if (!assets || !assets.length) return html;
639
+ let out = "";
640
+ for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
641
+ return html.replace(`</head>`, out + `</head>`);
635
642
  }
636
643
  function injectScripts(html, scripts, nonce) {
637
644
  const tag = `<script${nonce ? ` nonce="${nonce}"` : ""}>${scripts}</script>`;
@@ -720,6 +727,37 @@ function pipeToWritable(code, writable, options = {}) {
720
727
  const stream = renderToStream(code, options);
721
728
  if (!options.onReady) stream.pipeTo(writable);
722
729
  }
730
+ function ssrSpread(props, isSVG, skipChildren) {
731
+ let result = "";
732
+ if (props == null) return result;
733
+ if (typeof props === "function") props = props();
734
+ const keys = Object.keys(props);
735
+ let classResolved;
736
+ for (let i = 0; i < keys.length; i++) {
737
+ const prop = keys[i];
738
+ if (prop === "children") {
739
+ !skipChildren && console.warn(`SSR currently does not support spread children.`);
740
+ continue;
741
+ }
742
+ const value = props[prop];
743
+ if (prop === "style") {
744
+ result += `style="${ssrStyle(value)}"`;
745
+ } else if (prop === "class" || prop === "className" || prop === "classList") {
746
+ if (classResolved) continue;
747
+ let n;
748
+ result += `class="${(n = props.class) ? n + " " : ""}${(n = props.className) ? n + " " : ""}${ssrClassList(props.classList)}"`;
749
+ classResolved = true;
750
+ } else if (BooleanAttributes.has(prop)) {
751
+ if (value) result += prop;else continue;
752
+ } else if (value == undefined || prop === "ref" || prop.slice(0, 2) === "on") {
753
+ continue;
754
+ } else {
755
+ result += `${Aliases[prop] || prop}="${escape(value, true)}"`;
756
+ }
757
+ if (i !== keys.length - 1) result += " ";
758
+ }
759
+ return result;
760
+ }
723
761
 
724
762
  const isServer = true;
725
763
  function spread() {}
@@ -784,6 +822,7 @@ exports.NoHydration = NoHydration;
784
822
  exports.Portal = Portal;
785
823
  exports.escape = escape;
786
824
  exports.generateHydrationScript = generateHydrationScript;
825
+ exports.getAssets = getAssets;
787
826
  exports.getHydrationKey = getHydrationKey;
788
827
  exports.isServer = isServer;
789
828
  exports.pipeToNodeWritable = pipeToNodeWritable;
@@ -798,4 +837,6 @@ exports.ssrAttribute = ssrAttribute;
798
837
  exports.ssrClassList = ssrClassList;
799
838
  exports.ssrElement = ssrElement;
800
839
  exports.ssrHydrationKey = ssrHydrationKey;
840
+ exports.ssrSpread = ssrSpread;
801
841
  exports.ssrStyle = ssrStyle;
842
+ exports.useAssets = useAssets;
@@ -263,7 +263,8 @@ function toRefParam(index) {
263
263
  const REPLACE_SCRIPT = `function $df(e,t,d,l){d=document.getElementById(e),(l=document.getElementById("pl-"+e))&&l.replaceWith(...d.childNodes),d.remove(),_$HY.set(e,t)}`;
264
264
  function renderToString(code, options = {}) {
265
265
  let scripts = "";
266
- sharedConfig.context = {
266
+ let context;
267
+ sharedConfig.context = context = {
267
268
  id: options.renderId || "",
268
269
  count: 0,
269
270
  suspense: {},
@@ -274,7 +275,9 @@ function renderToString(code, options = {}) {
274
275
  scripts += `_$HY.set("${id}", ${stringify(p)});`;
275
276
  }
276
277
  };
277
- let html = injectAssets(sharedConfig.context.assets, resolveSSRNode(escape(code())));
278
+ let html = resolveSSRNode(escape(code()));
279
+ sharedConfig.context = undefined;
280
+ html = injectAssets(context.assets, html);
278
281
  if (scripts.length) html = injectScripts(html, scripts, options.nonce);
279
282
  return html;
280
283
  }
@@ -394,6 +397,7 @@ function renderToStream(code, options = {}) {
394
397
  };
395
398
  let html = resolveSSRNode(escape(code()));
396
399
  function doShell() {
400
+ sharedConfig.context = undefined;
397
401
  html = injectAssets(context.assets, html);
398
402
  for (const key in context.resources) {
399
403
  if (!("data" in context.resources[key] || context.resources[key].ref[0].error)) pushTask(`_$HY.init("${key}")`);
@@ -457,22 +461,16 @@ function renderToStream(code, options = {}) {
457
461
  };
458
462
  }
459
463
  function Assets(props) {
460
- sharedConfig.context.assets.push(() => NoHydration({
461
- get children() {
462
- return resolveSSRNode(props.children);
463
- }
464
- }));
465
- return ssr(`%%$${sharedConfig.context.assets.length - 1}%%`);
464
+ useAssets(() => props.children);
466
465
  }
467
466
  function HydrationScript(props) {
468
467
  const {
469
468
  nonce
470
469
  } = sharedConfig.context;
471
- sharedConfig.context.assets.push(() => generateHydrationScript({
470
+ return ssr(generateHydrationScript({
472
471
  nonce,
473
472
  ...props
474
473
  }));
475
- return ssr(`%%$${sharedConfig.context.assets.length - 1}%%`);
476
474
  }
477
475
  function NoHydration(props) {
478
476
  const c = sharedConfig.context;
@@ -618,6 +616,15 @@ function getHydrationKey() {
618
616
  const hydrate = sharedConfig.context;
619
617
  return hydrate && !hydrate.noHydrate && `${hydrate.id}${hydrate.count++}`;
620
618
  }
619
+ function useAssets(fn) {
620
+ sharedConfig.context.assets.push(() => resolveSSRNode(fn()));
621
+ }
622
+ function getAssets() {
623
+ const assets = sharedConfig.context.assets;
624
+ let out = "";
625
+ for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
626
+ return out;
627
+ }
621
628
  function generateHydrationScript({
622
629
  eventNames = ["click", "input"],
623
630
  nonce
@@ -625,10 +632,10 @@ function generateHydrationScript({
625
632
  return `<script${nonce ? ` nonce="${nonce}"` : ""}>var e,t;e=window._$HY||(_$HY={events:[],completed:new WeakSet,r:{}}),t=e=>e&&e.hasAttribute&&(e.hasAttribute("data-hk")?e:t(e.host&&e.host instanceof Node?e.host:e.parentNode)),["${eventNames.join('","')}"].forEach((o=>document.addEventListener(o,(o=>{let s=o.composedPath&&o.composedPath()[0]||o.target,a=t(s);a&&!e.completed.has(a)&&e.events.push([a,o])})))),e.init=(t,o)=>{e.r[t]=[new Promise(((e,t)=>o=e)),o]},e.set=(t,o,s)=>{(s=e.r[t])&&s[1](o),e.r[t]=[o]},e.unset=t=>{delete e.r[t]},e.load=t=>e.r[t];</script><!--xs-->`;
626
633
  }
627
634
  function injectAssets(assets, html) {
628
- for (let i = 0; i < assets.length; i++) {
629
- html = html.replace(`%%$${i}%%`, assets[i]());
630
- }
631
- return html;
635
+ if (!assets || !assets.length) return html;
636
+ let out = "";
637
+ for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
638
+ return html.replace(`</head>`, out + `</head>`);
632
639
  }
633
640
  function injectScripts(html, scripts, nonce) {
634
641
  const tag = `<script${nonce ? ` nonce="${nonce}"` : ""}>${scripts}</script>`;
@@ -717,6 +724,37 @@ function pipeToWritable(code, writable, options = {}) {
717
724
  const stream = renderToStream(code, options);
718
725
  if (!options.onReady) stream.pipeTo(writable);
719
726
  }
727
+ function ssrSpread(props, isSVG, skipChildren) {
728
+ let result = "";
729
+ if (props == null) return result;
730
+ if (typeof props === "function") props = props();
731
+ const keys = Object.keys(props);
732
+ let classResolved;
733
+ for (let i = 0; i < keys.length; i++) {
734
+ const prop = keys[i];
735
+ if (prop === "children") {
736
+ !skipChildren && console.warn(`SSR currently does not support spread children.`);
737
+ continue;
738
+ }
739
+ const value = props[prop];
740
+ if (prop === "style") {
741
+ result += `style="${ssrStyle(value)}"`;
742
+ } else if (prop === "class" || prop === "className" || prop === "classList") {
743
+ if (classResolved) continue;
744
+ let n;
745
+ result += `class="${(n = props.class) ? n + " " : ""}${(n = props.className) ? n + " " : ""}${ssrClassList(props.classList)}"`;
746
+ classResolved = true;
747
+ } else if (BooleanAttributes.has(prop)) {
748
+ if (value) result += prop;else continue;
749
+ } else if (value == undefined || prop === "ref" || prop.slice(0, 2) === "on") {
750
+ continue;
751
+ } else {
752
+ result += `${Aliases[prop] || prop}="${escape(value, true)}"`;
753
+ }
754
+ if (i !== keys.length - 1) result += " ";
755
+ }
756
+ return result;
757
+ }
720
758
 
721
759
  const isServer = true;
722
760
  function spread() {}
@@ -734,4 +772,4 @@ function Portal(props) {
734
772
  return "";
735
773
  }
736
774
 
737
- export { Assets, Dynamic, HydrationScript, NoHydration, Portal, escape, generateHydrationScript, getHydrationKey, isServer, pipeToNodeWritable, pipeToWritable, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle };
775
+ export { Assets, Dynamic, HydrationScript, NoHydration, Portal, escape, generateHydrationScript, getAssets, getHydrationKey, isServer, pipeToNodeWritable, pipeToWritable, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrSpread, ssrStyle, useAssets };
package/web/dist/web.cjs CHANGED
@@ -501,12 +501,10 @@ function getHydrationKey() {
501
501
  const hydrate = solidJs.sharedConfig.context;
502
502
  return `${hydrate.id}${hydrate.count++}`;
503
503
  }
504
- function Assets() {
505
- return;
506
- }
507
504
  function NoHydration(props) {
508
505
  return solidJs.sharedConfig.context ? undefined : props.children;
509
506
  }
507
+ function voidFn() {}
510
508
 
511
509
  function throwInBrowser(func) {
512
510
  const err = new Error(`${func.name} is not supported in the browser, returning undefined`);
@@ -529,7 +527,7 @@ function ssrAttribute(key, value) {}
529
527
  function ssrHydrationKey() {}
530
528
  function resolveSSRNode(node) {}
531
529
  function escape(html) {}
532
- function generateHydrationScript() {}
530
+ function ssrSpread(props, isSVG, skipChildren) {}
533
531
 
534
532
  const isServer = false;
535
533
  const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
@@ -643,12 +641,12 @@ Object.defineProperty(exports, 'mergeProps', {
643
641
  get: function () { return solidJs.mergeProps; }
644
642
  });
645
643
  exports.Aliases = Aliases;
646
- exports.Assets = Assets;
644
+ exports.Assets = voidFn;
647
645
  exports.ChildProperties = ChildProperties;
648
646
  exports.DOMElements = DOMElements;
649
647
  exports.DelegatedEvents = DelegatedEvents;
650
648
  exports.Dynamic = Dynamic;
651
- exports.HydrationScript = Assets;
649
+ exports.HydrationScript = voidFn;
652
650
  exports.NoHydration = NoHydration;
653
651
  exports.Portal = Portal;
654
652
  exports.PropAliases = PropAliases;
@@ -663,7 +661,8 @@ exports.clearDelegatedEvents = clearDelegatedEvents;
663
661
  exports.delegateEvents = delegateEvents;
664
662
  exports.dynamicProperty = dynamicProperty;
665
663
  exports.escape = escape;
666
- exports.generateHydrationScript = generateHydrationScript;
664
+ exports.generateHydrationScript = voidFn;
665
+ exports.getAssets = voidFn;
667
666
  exports.getHydrationKey = getHydrationKey;
668
667
  exports.getNextElement = getNextElement;
669
668
  exports.getNextMarker = getNextMarker;
@@ -687,7 +686,9 @@ exports.ssrAttribute = ssrAttribute;
687
686
  exports.ssrClassList = ssrClassList;
688
687
  exports.ssrElement = ssrElement;
689
688
  exports.ssrHydrationKey = ssrHydrationKey;
689
+ exports.ssrSpread = ssrSpread;
690
690
  exports.ssrStyle = ssrStyle;
691
691
  exports.style = style;
692
692
  exports.template = template;
693
693
  exports.use = use;
694
+ exports.useAssets = voidFn;
package/web/dist/web.js CHANGED
@@ -498,12 +498,10 @@ function getHydrationKey() {
498
498
  const hydrate = sharedConfig.context;
499
499
  return `${hydrate.id}${hydrate.count++}`;
500
500
  }
501
- function Assets() {
502
- return;
503
- }
504
501
  function NoHydration(props) {
505
502
  return sharedConfig.context ? undefined : props.children;
506
503
  }
504
+ function voidFn() {}
507
505
 
508
506
  function throwInBrowser(func) {
509
507
  const err = new Error(`${func.name} is not supported in the browser, returning undefined`);
@@ -526,7 +524,7 @@ function ssrAttribute(key, value) {}
526
524
  function ssrHydrationKey() {}
527
525
  function resolveSSRNode(node) {}
528
526
  function escape(html) {}
529
- function generateHydrationScript() {}
527
+ function ssrSpread(props, isSVG, skipChildren) {}
530
528
 
531
529
  const isServer = false;
532
530
  const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
@@ -591,4 +589,4 @@ function Dynamic(props) {
591
589
  });
592
590
  }
593
591
 
594
- export { Aliases, Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, Assets as HydrationScript, NoHydration, Portal, PropAliases, Properties, SVGElements, SVGNamespace, addEventListener, assign, classList, className, clearDelegatedEvents, delegateEvents, dynamicProperty, escape, generateHydrationScript, getHydrationKey, getNextElement, getNextMarker, getNextMatch, hydrate, innerHTML, insert, isServer, memo, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, use };
592
+ export { Aliases, voidFn as Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, voidFn as HydrationScript, NoHydration, Portal, PropAliases, Properties, SVGElements, SVGNamespace, addEventListener, assign, classList, className, clearDelegatedEvents, delegateEvents, dynamicProperty, escape, voidFn as generateHydrationScript, voidFn as getAssets, getHydrationKey, getNextElement, getNextMarker, getNextMatch, hydrate, innerHTML, insert, isServer, memo, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrSpread, ssrStyle, style, template, use, voidFn as useAssets };
@@ -62,6 +62,9 @@ export function getHydrationKey(): string;
62
62
  export function getNextElement(template?: HTMLTemplateElement): Element;
63
63
  export function getNextMatch(start: Node, elementName: string): Element;
64
64
  export function getNextMarker(start: Node): [Node, Array<Node>];
65
+ export function useAssets(fn: () => string): void;
66
+ export function getAssets(): string;
65
67
  export function Assets(props: { children?: JSX.Element }): JSX.Element;
66
68
  export function HydrationScript(): JSX.Element;
67
69
  export function NoHydration(props: { children?: JSX.Element }): JSX.Element;
70
+ export function getHydrationScript(): string;
@@ -38,7 +38,10 @@ export declare function ssrAttribute(key: string, value: boolean): string;
38
38
  export declare function ssrHydrationKey(): string;
39
39
  export declare function resolveSSRNode(node: any): string;
40
40
  export declare function escape(html: string): string;
41
- export declare function generateHydrationScript(): string;
41
+ /**
42
+ * @deprecated Replaced by ssrElement
43
+ */
44
+ export declare function ssrSpread(props: any, isSVG: boolean, skipChildren: boolean): void;
42
45
  export declare type LegacyResults = {
43
46
  startWriting: () => void;
44
47
  };
@@ -37,6 +37,8 @@ export function ssrAttribute(key: string, value: any, isBoolean: boolean): strin
37
37
  export function ssrHydrationKey(): string;
38
38
  export function resolveSSRNode(node: any): string;
39
39
  export function escape(html: string): string;
40
+ export function useAssets(fn: () => string): void;
41
+ export function getAssets(): string;
40
42
  export function getHydrationKey(): string;
41
43
  export function effect<T>(fn: (prev?: T) => T, init?: T): void;
42
44
  export function memo<T>(fn: () => T, equal: boolean): () => T;
package/jsx-runtime.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./types/jsx"