solid-js 1.3.10 → 1.3.13

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
@@ -645,16 +645,16 @@ function readSignal() {
645
645
  return this.value;
646
646
  }
647
647
  function writeSignal(node, value, isComp) {
648
- if (node.comparator) {
649
- if (Transition && Transition.running && Transition.sources.has(node)) {
650
- if (node.comparator(node.tValue, value)) return value;
651
- } else if (node.comparator(node.value, value)) return value;
652
- }
653
648
  if (Pending) {
654
649
  if (node.pending === NOTPENDING) Pending.push(node);
655
650
  node.pending = value;
656
651
  return value;
657
652
  }
653
+ if (node.comparator) {
654
+ if (Transition && Transition.running && Transition.sources.has(node)) {
655
+ if (node.comparator(node.tValue, value)) return value;
656
+ } else if (node.comparator(node.value, value)) return value;
657
+ }
658
658
  let TransitionRunning = false;
659
659
  if (Transition) {
660
660
  TransitionRunning = Transition.running;
@@ -763,7 +763,8 @@ function createComputation(fn, init, pure, state = STALE, options) {
763
763
  }
764
764
  function runTop(node) {
765
765
  const runningTransition = Transition && Transition.running;
766
- if (!runningTransition && node.state !== STALE || runningTransition && node.tState !== STALE) return lookDownstream(node);
766
+ if (!runningTransition && node.state === 0 || runningTransition && node.tState === 0) return;
767
+ if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) return lookDownstream(node);
767
768
  if (node.suspense && untrack(node.suspense.inFallback)) return node.suspense.effects.push(node);
768
769
  const ancestors = [node];
769
770
  while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) {
@@ -884,8 +885,8 @@ function runUserEffects(queue) {
884
885
  for (i = resume; i < queue.length; i++) runTop(queue[i]);
885
886
  }
886
887
  function lookDownstream(node, ignore) {
887
- node.state = 0;
888
888
  const runningTransition = Transition && Transition.running;
889
+ if (runningTransition) node.tState = 0;else node.state = 0;
889
890
  for (let i = 0; i < node.sources.length; i += 1) {
890
891
  const source = node.sources[i];
891
892
  if (source.sources) {
package/dist/dev.js CHANGED
@@ -641,16 +641,16 @@ function readSignal() {
641
641
  return this.value;
642
642
  }
643
643
  function writeSignal(node, value, isComp) {
644
- if (node.comparator) {
645
- if (Transition && Transition.running && Transition.sources.has(node)) {
646
- if (node.comparator(node.tValue, value)) return value;
647
- } else if (node.comparator(node.value, value)) return value;
648
- }
649
644
  if (Pending) {
650
645
  if (node.pending === NOTPENDING) Pending.push(node);
651
646
  node.pending = value;
652
647
  return value;
653
648
  }
649
+ if (node.comparator) {
650
+ if (Transition && Transition.running && Transition.sources.has(node)) {
651
+ if (node.comparator(node.tValue, value)) return value;
652
+ } else if (node.comparator(node.value, value)) return value;
653
+ }
654
654
  let TransitionRunning = false;
655
655
  if (Transition) {
656
656
  TransitionRunning = Transition.running;
@@ -759,7 +759,8 @@ function createComputation(fn, init, pure, state = STALE, options) {
759
759
  }
760
760
  function runTop(node) {
761
761
  const runningTransition = Transition && Transition.running;
762
- if (!runningTransition && node.state !== STALE || runningTransition && node.tState !== STALE) return lookDownstream(node);
762
+ if (!runningTransition && node.state === 0 || runningTransition && node.tState === 0) return;
763
+ if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) return lookDownstream(node);
763
764
  if (node.suspense && untrack(node.suspense.inFallback)) return node.suspense.effects.push(node);
764
765
  const ancestors = [node];
765
766
  while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) {
@@ -880,8 +881,8 @@ function runUserEffects(queue) {
880
881
  for (i = resume; i < queue.length; i++) runTop(queue[i]);
881
882
  }
882
883
  function lookDownstream(node, ignore) {
883
- node.state = 0;
884
884
  const runningTransition = Transition && Transition.running;
885
+ if (runningTransition) node.tState = 0;else node.state = 0;
885
886
  for (let i = 0; i < node.sources.length; i += 1) {
886
887
  const source = node.sources[i];
887
888
  if (source.sources) {
package/dist/server.cjs CHANGED
@@ -331,16 +331,16 @@ function ErrorBoundary(props) {
331
331
  }
332
332
  const SuspenseContext = createContext();
333
333
  let resourceContext = null;
334
- function createResource(fn, fetcher, options = {}) {
334
+ function createResource(source, fetcher, options = {}) {
335
335
  if (arguments.length === 2) {
336
336
  if (typeof fetcher === "object") {
337
337
  options = fetcher;
338
- fetcher = fn;
339
- fn = true;
338
+ fetcher = source;
339
+ source = true;
340
340
  }
341
341
  } else if (arguments.length === 1) {
342
- fetcher = fn;
343
- fn = true;
342
+ fetcher = source;
343
+ source = true;
344
344
  }
345
345
  const contexts = new Set();
346
346
  const id = sharedConfig.context.id + sharedConfig.context.count++;
@@ -372,23 +372,27 @@ function createResource(fn, fetcher, options = {}) {
372
372
  read.error = undefined;
373
373
  function load() {
374
374
  const ctx = sharedConfig.context;
375
- if (!ctx.async) return read.loading = !!(typeof fn === "function" ? fn() : fn);
375
+ if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
376
376
  if (ctx.resources && id in ctx.resources && ctx.resources[id].data) {
377
377
  value = ctx.resources[id].data;
378
378
  return;
379
379
  }
380
380
  resourceContext = [];
381
- const lookup = typeof fn === "function" ? fn() : fn;
381
+ const lookup = typeof source === "function" ? source() : source;
382
382
  if (resourceContext.length) {
383
- p = Promise.all(resourceContext).then(() => fetcher(fn(), () => value));
383
+ p = Promise.all(resourceContext).then(() => fetcher(source(), {
384
+ value
385
+ }));
384
386
  }
385
387
  resourceContext = null;
386
388
  if (!p) {
387
389
  if (lookup == null || lookup === false) return;
388
- p = fetcher(lookup, () => value);
390
+ p = fetcher(lookup, {
391
+ value
392
+ });
389
393
  }
390
- read.loading = true;
391
- if ("then" in p) {
394
+ if (p && "then" in p) {
395
+ read.loading = true;
392
396
  if (ctx.writeResource) ctx.writeResource(id, p);
393
397
  return p.then(res => {
394
398
  read.loading = false;
package/dist/server.js CHANGED
@@ -327,16 +327,16 @@ function ErrorBoundary(props) {
327
327
  }
328
328
  const SuspenseContext = createContext();
329
329
  let resourceContext = null;
330
- function createResource(fn, fetcher, options = {}) {
330
+ function createResource(source, fetcher, options = {}) {
331
331
  if (arguments.length === 2) {
332
332
  if (typeof fetcher === "object") {
333
333
  options = fetcher;
334
- fetcher = fn;
335
- fn = true;
334
+ fetcher = source;
335
+ source = true;
336
336
  }
337
337
  } else if (arguments.length === 1) {
338
- fetcher = fn;
339
- fn = true;
338
+ fetcher = source;
339
+ source = true;
340
340
  }
341
341
  const contexts = new Set();
342
342
  const id = sharedConfig.context.id + sharedConfig.context.count++;
@@ -368,23 +368,27 @@ function createResource(fn, fetcher, options = {}) {
368
368
  read.error = undefined;
369
369
  function load() {
370
370
  const ctx = sharedConfig.context;
371
- if (!ctx.async) return read.loading = !!(typeof fn === "function" ? fn() : fn);
371
+ if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
372
372
  if (ctx.resources && id in ctx.resources && ctx.resources[id].data) {
373
373
  value = ctx.resources[id].data;
374
374
  return;
375
375
  }
376
376
  resourceContext = [];
377
- const lookup = typeof fn === "function" ? fn() : fn;
377
+ const lookup = typeof source === "function" ? source() : source;
378
378
  if (resourceContext.length) {
379
- p = Promise.all(resourceContext).then(() => fetcher(fn(), () => value));
379
+ p = Promise.all(resourceContext).then(() => fetcher(source(), {
380
+ value
381
+ }));
380
382
  }
381
383
  resourceContext = null;
382
384
  if (!p) {
383
385
  if (lookup == null || lookup === false) return;
384
- p = fetcher(lookup, () => value);
386
+ p = fetcher(lookup, {
387
+ value
388
+ });
385
389
  }
386
- read.loading = true;
387
- if ("then" in p) {
390
+ if (p && "then" in p) {
391
+ read.loading = true;
388
392
  if (ctx.writeResource) ctx.writeResource(id, p);
389
393
  return p.then(res => {
390
394
  read.loading = false;
package/dist/solid.cjs CHANGED
@@ -589,16 +589,16 @@ function readSignal() {
589
589
  return this.value;
590
590
  }
591
591
  function writeSignal(node, value, isComp) {
592
- if (node.comparator) {
593
- if (Transition && Transition.running && Transition.sources.has(node)) {
594
- if (node.comparator(node.tValue, value)) return value;
595
- } else if (node.comparator(node.value, value)) return value;
596
- }
597
592
  if (Pending) {
598
593
  if (node.pending === NOTPENDING) Pending.push(node);
599
594
  node.pending = value;
600
595
  return value;
601
596
  }
597
+ if (node.comparator) {
598
+ if (Transition && Transition.running && Transition.sources.has(node)) {
599
+ if (node.comparator(node.tValue, value)) return value;
600
+ } else if (node.comparator(node.value, value)) return value;
601
+ }
602
602
  let TransitionRunning = false;
603
603
  if (Transition) {
604
604
  TransitionRunning = Transition.running;
@@ -706,7 +706,8 @@ function createComputation(fn, init, pure, state = STALE, options) {
706
706
  }
707
707
  function runTop(node) {
708
708
  const runningTransition = Transition && Transition.running;
709
- if (!runningTransition && node.state !== STALE || runningTransition && node.tState !== STALE) return lookDownstream(node);
709
+ if (!runningTransition && node.state === 0 || runningTransition && node.tState === 0) return;
710
+ if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) return lookDownstream(node);
710
711
  if (node.suspense && untrack(node.suspense.inFallback)) return node.suspense.effects.push(node);
711
712
  const ancestors = [node];
712
713
  while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) {
@@ -826,8 +827,8 @@ function runUserEffects(queue) {
826
827
  for (i = resume; i < queue.length; i++) runTop(queue[i]);
827
828
  }
828
829
  function lookDownstream(node, ignore) {
829
- node.state = 0;
830
830
  const runningTransition = Transition && Transition.running;
831
+ if (runningTransition) node.tState = 0;else node.state = 0;
831
832
  for (let i = 0; i < node.sources.length; i += 1) {
832
833
  const source = node.sources[i];
833
834
  if (source.sources) {
package/dist/solid.js CHANGED
@@ -585,16 +585,16 @@ function readSignal() {
585
585
  return this.value;
586
586
  }
587
587
  function writeSignal(node, value, isComp) {
588
- if (node.comparator) {
589
- if (Transition && Transition.running && Transition.sources.has(node)) {
590
- if (node.comparator(node.tValue, value)) return value;
591
- } else if (node.comparator(node.value, value)) return value;
592
- }
593
588
  if (Pending) {
594
589
  if (node.pending === NOTPENDING) Pending.push(node);
595
590
  node.pending = value;
596
591
  return value;
597
592
  }
593
+ if (node.comparator) {
594
+ if (Transition && Transition.running && Transition.sources.has(node)) {
595
+ if (node.comparator(node.tValue, value)) return value;
596
+ } else if (node.comparator(node.value, value)) return value;
597
+ }
598
598
  let TransitionRunning = false;
599
599
  if (Transition) {
600
600
  TransitionRunning = Transition.running;
@@ -702,7 +702,8 @@ function createComputation(fn, init, pure, state = STALE, options) {
702
702
  }
703
703
  function runTop(node) {
704
704
  const runningTransition = Transition && Transition.running;
705
- if (!runningTransition && node.state !== STALE || runningTransition && node.tState !== STALE) return lookDownstream(node);
705
+ if (!runningTransition && node.state === 0 || runningTransition && node.tState === 0) return;
706
+ if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) return lookDownstream(node);
706
707
  if (node.suspense && untrack(node.suspense.inFallback)) return node.suspense.effects.push(node);
707
708
  const ancestors = [node];
708
709
  while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) {
@@ -822,8 +823,8 @@ function runUserEffects(queue) {
822
823
  for (i = resume; i < queue.length; i++) runTop(queue[i]);
823
824
  }
824
825
  function lookDownstream(node, ignore) {
825
- node.state = 0;
826
826
  const runningTransition = Transition && Transition.running;
827
+ if (runningTransition) node.tState = 0;else node.state = 0;
827
828
  for (let i = 0; i < node.sources.length; i += 1) {
828
829
  const source = node.sources[i];
829
830
  if (source.sources) {
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.3.10",
4
+ "version": "1.3.13",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
@@ -144,5 +144,5 @@
144
144
  "compiler",
145
145
  "performance"
146
146
  ],
147
- "gitHead": "95969d0b67dbad306f7b18736d88356d5e678532"
147
+ "gitHead": "dfacd34d443f9cdf1958445756e7317bd8e3632c"
148
148
  }
@@ -185,6 +185,7 @@ function updatePath(current, path, traversed = []) {
185
185
  }
186
186
  function createStore(store, options) {
187
187
  const unwrappedStore = unwrap(store || {});
188
+ if (typeof unwrappedStore !== "object" && typeof unwrappedStore !== "function") throw new Error(`Unexpected type ${typeof unwrappedStore} received when initializing 'createStore'. Expected an object.`);
188
189
  const wrappedStore = wrap$1(unwrappedStore, (options && options.name || solidJs.DEV.hashValue(unwrappedStore)));
189
190
  {
190
191
  const name = options && options.name || solidJs.DEV.hashValue(unwrappedStore);
@@ -260,6 +261,7 @@ function wrap(value, name) {
260
261
  }
261
262
  function createMutable(state, options) {
262
263
  const unwrappedStore = unwrap(state || {});
264
+ if (typeof unwrappedStore !== "object" && typeof unwrappedStore !== "function") throw new Error(`Unexpected type ${typeof unwrappedStore} received when initializing 'createMutable'. Expected an object.`);
263
265
  const wrappedStore = wrap(unwrappedStore, (options && options.name || solidJs.DEV.hashValue(unwrappedStore)));
264
266
  {
265
267
  const name = options && options.name || solidJs.DEV.hashValue(unwrappedStore);
package/store/dist/dev.js CHANGED
@@ -181,6 +181,7 @@ function updatePath(current, path, traversed = []) {
181
181
  }
182
182
  function createStore(store, options) {
183
183
  const unwrappedStore = unwrap(store || {});
184
+ if (typeof unwrappedStore !== "object" && typeof unwrappedStore !== "function") throw new Error(`Unexpected type ${typeof unwrappedStore} received when initializing 'createStore'. Expected an object.`);
184
185
  const wrappedStore = wrap$1(unwrappedStore, (options && options.name || DEV.hashValue(unwrappedStore)));
185
186
  {
186
187
  const name = options && options.name || DEV.hashValue(unwrappedStore);
@@ -256,6 +257,7 @@ function wrap(value, name) {
256
257
  }
257
258
  function createMutable(state, options) {
258
259
  const unwrappedStore = unwrap(state || {});
260
+ if (typeof unwrappedStore !== "object" && typeof unwrappedStore !== "function") throw new Error(`Unexpected type ${typeof unwrappedStore} received when initializing 'createMutable'. Expected an object.`);
259
261
  const wrappedStore = wrap(unwrappedStore, (options && options.name || DEV.hashValue(unwrappedStore)));
260
262
  {
261
263
  const name = options && options.name || DEV.hashValue(unwrappedStore);
@@ -1,4 +1,4 @@
1
1
  export { createStore, unwrap, $RAW } from "./store";
2
- export type { Store, SetStoreFunction, NotWrappable, StoreNode, StoreSetter, StorePathRange, ArrayFilterFn, Part, DeepReadonly, DeepMutable } from "./store";
2
+ export type { Store, SetStoreFunction, NotWrappable, SolidStore, StoreNode, StoreSetter, StorePathRange, ArrayFilterFn, Part, DeepReadonly, DeepMutable } from "./store";
3
3
  export * from "./mutable";
4
4
  export * from "./modifiers";
@@ -1,7 +1,7 @@
1
- import { DeepMutable, NotWrappable } from "./store";
1
+ import { DeepMutable } from "./store";
2
2
  export declare type ReconcileOptions = {
3
3
  key?: string | null;
4
4
  merge?: boolean;
5
5
  };
6
6
  export declare function reconcile<T extends U, U>(value: T, options?: ReconcileOptions): (state: U) => T;
7
- export declare function produce<T>(fn: (state: DeepMutable<Exclude<T, NotWrappable>>) => void): (state: T) => T;
7
+ export declare function produce<T>(fn: (state: DeepMutable<T>) => void): (state: T) => T;
@@ -1,7 +1,11 @@
1
1
  import { Accessor } from "../..";
2
2
  export declare const $RAW: unique symbol, $NODE: unique symbol, $NAME: unique symbol;
3
3
  export declare type StoreNode = Record<PropertyKey, any>;
4
- export declare type NotWrappable = string | number | bigint | symbol | boolean | Function | null | undefined;
4
+ export declare namespace SolidStore {
5
+ interface Unwrappable {
6
+ }
7
+ }
8
+ export declare type NotWrappable = string | number | bigint | symbol | boolean | Function | null | undefined | SolidStore.Unwrappable[keyof SolidStore.Unwrappable];
5
9
  export declare type Store<T> = DeepReadonly<T>;
6
10
  export declare function isWrappable(obj: any): any;
7
11
  export declare function unwrap<T extends StoreNode>(item: any, set?: Set<unknown>): T;
@@ -13,11 +17,11 @@ export declare function createDataNode(): Accessor<void> & {
13
17
  };
14
18
  export declare function setProperty(state: StoreNode, property: PropertyKey, value: any): void;
15
19
  export declare function updatePath(current: StoreNode, path: any[], traversed?: PropertyKey[]): void;
16
- export declare type DeepReadonly<T> = 0 extends 1 & T ? T : {
17
- readonly [K in keyof T]: T[K] extends NotWrappable ? T[K] : DeepReadonly<T[K]>;
20
+ export declare type DeepReadonly<T> = 0 extends 1 & T ? T : T extends NotWrappable ? T : {
21
+ readonly [K in keyof T]: T[K];
18
22
  };
19
- export declare type DeepMutable<T> = 0 extends 1 & T ? T : {
20
- -readonly [K in keyof T]: T[K] extends NotWrappable ? T[K] : DeepMutable<T[K]>;
23
+ export declare type DeepMutable<T> = 0 extends 1 & T ? T : T extends NotWrappable ? T : {
24
+ -readonly [K in keyof T]: T[K];
21
25
  };
22
26
  export declare type StorePathRange = {
23
27
  from?: number;
@@ -25,10 +29,10 @@ export declare type StorePathRange = {
25
29
  by?: number;
26
30
  };
27
31
  export declare type ArrayFilterFn<T> = (item: DeepReadonly<T>, index: number) => boolean;
28
- export declare type StoreSetter<T, U extends PropertyKey[] = []> = ((prevState: DeepReadonly<T>, traversed: U) => DeepReadonly<T> | Partial<DeepReadonly<T>> | void) | DeepReadonly<T> | Partial<DeepReadonly<T>>;
29
- export declare type Part<T, K extends KeyOf<T> = KeyOf<T>> = [K] extends [never] ? never : K | readonly K[] | (number extends K ? ArrayFilterFn<T[number]> | StorePathRange : never);
32
+ 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>>;
33
+ 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);
30
34
  declare type W<T> = Exclude<T, NotWrappable>;
31
- declare type KeyOf<T> = number extends keyof T ? 0 extends 1 & T ? keyof T : [T] extends [never] ? never : number : keyof T;
35
+ 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;
32
36
  declare type Rest<T, U extends PropertyKey[]> = [StoreSetter<T, U>] | (0 extends 1 & T ? [...Part<any>[], StoreSetter<any, PropertyKey[]>] : DistributeRest<W<T>, KeyOf<W<T>>, U>);
33
37
  declare type DistributeRest<T, K, U extends PropertyKey[]> = [T] extends [never] ? never : K extends KeyOf<T> ? [Part<T, K>, ...Rest<T[K], [K, ...U]>] : never;
34
38
  export interface SetStoreFunction<T> {
@@ -70,7 +70,7 @@ export declare type RootFunction<T> = (dispose: () => void) => T;
70
70
  */
71
71
  export declare function createRoot<T>(fn: RootFunction<T>, detachedOwner?: Owner): T;
72
72
  export declare type Accessor<T> = () => T;
73
- 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;
73
+ export declare type Setter<T> = (undefined extends T ? (value?: undefined) => undefined : {}) & (<U extends T>(value: Exclude<U, Function> | ((prev: T) => U)) => U);
74
74
  export declare type Signal<T> = [get: Accessor<T>, set: Setter<T>];
75
75
  export interface SignalOptions<T> extends MemoOptions<T> {
76
76
  internal?: boolean;
@@ -1,8 +1,9 @@
1
- import type { Accessor, Setter } from "../reactive/signal";
2
1
  export declare const equalFn: <T>(a: T, b: T) => boolean;
3
2
  export declare const $PROXY: unique symbol;
4
3
  export declare const $DEVCOMP: unique symbol;
5
4
  export declare const DEV: {};
5
+ export declare type Accessor<T> = () => T;
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;
6
7
  export declare let Owner: Owner | null;
7
8
  interface Owner {
8
9
  owner: Owner | null;
@@ -1,3 +1,4 @@
1
+ import { Setter } from "./reactive";
1
2
  import type { JSX } from "../jsx";
2
3
  declare type PropsWithChildren<P> = P & {
3
4
  children?: JSX.Element;
@@ -72,19 +73,32 @@ declare type SuspenseContextType = {
72
73
  }>;
73
74
  completed: () => void;
74
75
  };
75
- declare type ResourceReturn<T> = [
76
- Resource<T>,
77
- {
78
- mutate: (v: T | undefined) => T | undefined;
79
- refetch: () => void;
80
- }
81
- ];
82
- export declare function createResource<T, U = true>(fetcher: (k: U, getPrev: () => T | undefined) => T | Promise<T>, options?: {
83
- initialValue?: T;
84
- }): ResourceReturn<T>;
85
- export declare function createResource<T, U>(fn: U | false | (() => U | false), fetcher: (k: U, getPrev: () => T | undefined) => T | Promise<T>, options?: {
76
+ export declare type ResourceActions<T> = {
77
+ mutate: Setter<T>;
78
+ refetch: (info?: unknown) => void;
79
+ };
80
+ export declare type ResourceReturn<T> = [Resource<T>, ResourceActions<T>];
81
+ export declare type ResourceSource<S> = S | false | null | undefined | (() => S | false | null | undefined);
82
+ export declare type ResourceFetcher<S, T> = (k: S, info: ResourceFetcherInfo<T>) => T | Promise<T>;
83
+ export declare type ResourceFetcherInfo<T> = {
84
+ value: T | undefined;
85
+ refetching?: unknown;
86
+ };
87
+ export declare type ResourceOptions<T> = undefined extends T ? {
86
88
  initialValue?: T;
87
- }): ResourceReturn<T>;
89
+ name?: string;
90
+ globalRefetch?: boolean;
91
+ onHydrated?: <S, T>(k: S, info: ResourceFetcherInfo<T>) => void;
92
+ } : {
93
+ initialValue: T;
94
+ name?: string;
95
+ globalRefetch?: boolean;
96
+ onHydrated?: <S, T>(k: S, info: ResourceFetcherInfo<T>) => void;
97
+ };
98
+ export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S, T>, options?: ResourceOptions<undefined>): ResourceReturn<T | undefined>;
99
+ export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): ResourceReturn<T>;
100
+ export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options?: ResourceOptions<undefined>): ResourceReturn<T | undefined>;
101
+ export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): ResourceReturn<T>;
88
102
  export declare function refetchResources(info?: unknown): void;
89
103
  export declare function lazy(fn: () => Promise<{
90
104
  default: any;
package/web/dist/dev.cjs CHANGED
@@ -19,7 +19,7 @@ const PropAliases = {
19
19
  playsinline: "playsInline",
20
20
  readonly: "readOnly"
21
21
  };
22
- const DelegatedEvents = new Set(["beforeinput", "click", "dblclick", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
22
+ const DelegatedEvents = new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
23
23
  const SVGElements = new Set([
24
24
  "altGlyph", "altGlyphDef", "altGlyphItem", "animate", "animateColor", "animateMotion", "animateTransform", "circle", "clipPath", "color-profile", "cursor", "defs", "desc", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "filter", "font", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignObject", "g", "glyph", "glyphRef", "hkern", "image", "line", "linearGradient", "marker", "mask", "metadata", "missing-glyph", "mpath", "path", "pattern", "polygon", "polyline", "radialGradient", "rect",
25
25
  "set", "stop",
@@ -357,6 +357,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
357
357
  multi = marker !== undefined;
358
358
  parent = multi && current[0] && current[0].parentNode || parent;
359
359
  if (t === "string" || t === "number") {
360
+ if (solidJs.sharedConfig.context) return current;
360
361
  if (t === "number") value = value.toString();
361
362
  if (multi) {
362
363
  let node = current[0];
@@ -474,9 +475,19 @@ function NoHydration(props) {
474
475
  return solidJs.sharedConfig.context ? undefined : props.children;
475
476
  }
476
477
 
477
- function renderToString(fn, options) {}
478
- function renderToStringAsync(fn, options) {}
479
- function renderToStream(fn, options) {}
478
+ function throwInBrowser(func) {
479
+ const err = new Error(`${func.name} is not supported in the browser, returning undefined`);
480
+ console.error(err);
481
+ }
482
+ function renderToString(fn, options) {
483
+ throwInBrowser(renderToString);
484
+ }
485
+ function renderToStringAsync(fn, options) {
486
+ throwInBrowser(renderToStringAsync);
487
+ }
488
+ function renderToStream(fn, options) {
489
+ throwInBrowser(renderToStream);
490
+ }
480
491
  function ssr(template, ...nodes) {}
481
492
  function resolveSSRNode(node) {}
482
493
  function ssrClassList(value) {}
package/web/dist/dev.js CHANGED
@@ -16,7 +16,7 @@ const PropAliases = {
16
16
  playsinline: "playsInline",
17
17
  readonly: "readOnly"
18
18
  };
19
- const DelegatedEvents = new Set(["beforeinput", "click", "dblclick", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
19
+ const DelegatedEvents = new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
20
20
  const SVGElements = new Set([
21
21
  "altGlyph", "altGlyphDef", "altGlyphItem", "animate", "animateColor", "animateMotion", "animateTransform", "circle", "clipPath", "color-profile", "cursor", "defs", "desc", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "filter", "font", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignObject", "g", "glyph", "glyphRef", "hkern", "image", "line", "linearGradient", "marker", "mask", "metadata", "missing-glyph", "mpath", "path", "pattern", "polygon", "polyline", "radialGradient", "rect",
22
22
  "set", "stop",
@@ -354,6 +354,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
354
354
  multi = marker !== undefined;
355
355
  parent = multi && current[0] && current[0].parentNode || parent;
356
356
  if (t === "string" || t === "number") {
357
+ if (sharedConfig.context) return current;
357
358
  if (t === "number") value = value.toString();
358
359
  if (multi) {
359
360
  let node = current[0];
@@ -471,9 +472,19 @@ function NoHydration(props) {
471
472
  return sharedConfig.context ? undefined : props.children;
472
473
  }
473
474
 
474
- function renderToString(fn, options) {}
475
- function renderToStringAsync(fn, options) {}
476
- function renderToStream(fn, options) {}
475
+ function throwInBrowser(func) {
476
+ const err = new Error(`${func.name} is not supported in the browser, returning undefined`);
477
+ console.error(err);
478
+ }
479
+ function renderToString(fn, options) {
480
+ throwInBrowser(renderToString);
481
+ }
482
+ function renderToStringAsync(fn, options) {
483
+ throwInBrowser(renderToStringAsync);
484
+ }
485
+ function renderToStream(fn, options) {
486
+ throwInBrowser(renderToStream);
487
+ }
477
488
  function ssr(template, ...nodes) {}
478
489
  function resolveSSRNode(node) {}
479
490
  function ssrClassList(value) {}
@@ -233,7 +233,7 @@ function stringifyString(str) {
233
233
  }
234
234
 
235
235
  const REPLACE_SCRIPT = `function $df(e,y,t,g){t=document.getElementById(e),g=document.getElementById("pl"+e),g&&g.replaceWith(...t.childNodes),_$HY.set(e,y||null)}`;
236
- const FRAGMENT_REPLACE = /<!\[([\d.]+)\]>/;
236
+ const FRAGMENT_REPLACE = /<!\[([\d-]+)\]>/;
237
237
  function renderToString(code, options = {}) {
238
238
  let scripts = "";
239
239
  solidJs.sharedConfig.context = {
@@ -604,7 +604,19 @@ function injectScripts(html, scripts, nonce) {
604
604
  return html + tag;
605
605
  }
606
606
  function serializeError(error) {
607
- return error.message ? `new Error(${devalue(error.message)})` : devalue(error);
607
+ if (error.message) {
608
+ const fields = {};
609
+ const keys = Object.getOwnPropertyNames(error);
610
+ for (let i = 0; i < keys.length; i++) {
611
+ const key = keys[i];
612
+ const value = error[key];
613
+ if (!value || key !== "message" && typeof value !== "function") {
614
+ fields[key] = value;
615
+ }
616
+ }
617
+ return `Object.assign(new Error(${devalue(error.message)}), ${devalue(fields)})`;
618
+ }
619
+ return devalue(error);
608
620
  }
609
621
  function waitForFragments(registry, key) {
610
622
  for (const k of [...registry.keys()].reverse()) {
@@ -230,7 +230,7 @@ function stringifyString(str) {
230
230
  }
231
231
 
232
232
  const REPLACE_SCRIPT = `function $df(e,y,t,g){t=document.getElementById(e),g=document.getElementById("pl"+e),g&&g.replaceWith(...t.childNodes),_$HY.set(e,y||null)}`;
233
- const FRAGMENT_REPLACE = /<!\[([\d.]+)\]>/;
233
+ const FRAGMENT_REPLACE = /<!\[([\d-]+)\]>/;
234
234
  function renderToString(code, options = {}) {
235
235
  let scripts = "";
236
236
  sharedConfig.context = {
@@ -601,7 +601,19 @@ function injectScripts(html, scripts, nonce) {
601
601
  return html + tag;
602
602
  }
603
603
  function serializeError(error) {
604
- return error.message ? `new Error(${devalue(error.message)})` : devalue(error);
604
+ if (error.message) {
605
+ const fields = {};
606
+ const keys = Object.getOwnPropertyNames(error);
607
+ for (let i = 0; i < keys.length; i++) {
608
+ const key = keys[i];
609
+ const value = error[key];
610
+ if (!value || key !== "message" && typeof value !== "function") {
611
+ fields[key] = value;
612
+ }
613
+ }
614
+ return `Object.assign(new Error(${devalue(error.message)}), ${devalue(fields)})`;
615
+ }
616
+ return devalue(error);
605
617
  }
606
618
  function waitForFragments(registry, key) {
607
619
  for (const k of [...registry.keys()].reverse()) {
package/web/dist/web.cjs CHANGED
@@ -19,7 +19,7 @@ const PropAliases = {
19
19
  playsinline: "playsInline",
20
20
  readonly: "readOnly"
21
21
  };
22
- const DelegatedEvents = new Set(["beforeinput", "click", "dblclick", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
22
+ const DelegatedEvents = new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
23
23
  const SVGElements = new Set([
24
24
  "altGlyph", "altGlyphDef", "altGlyphItem", "animate", "animateColor", "animateMotion", "animateTransform", "circle", "clipPath", "color-profile", "cursor", "defs", "desc", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "filter", "font", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignObject", "g", "glyph", "glyphRef", "hkern", "image", "line", "linearGradient", "marker", "mask", "metadata", "missing-glyph", "mpath", "path", "pattern", "polygon", "polyline", "radialGradient", "rect",
25
25
  "set", "stop",
@@ -356,6 +356,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
356
356
  multi = marker !== undefined;
357
357
  parent = multi && current[0] && current[0].parentNode || parent;
358
358
  if (t === "string" || t === "number") {
359
+ if (solidJs.sharedConfig.context) return current;
359
360
  if (t === "number") value = value.toString();
360
361
  if (multi) {
361
362
  let node = current[0];
@@ -473,9 +474,19 @@ function NoHydration(props) {
473
474
  return solidJs.sharedConfig.context ? undefined : props.children;
474
475
  }
475
476
 
476
- function renderToString(fn, options) {}
477
- function renderToStringAsync(fn, options) {}
478
- function renderToStream(fn, options) {}
477
+ function throwInBrowser(func) {
478
+ const err = new Error(`${func.name} is not supported in the browser, returning undefined`);
479
+ console.error(err);
480
+ }
481
+ function renderToString(fn, options) {
482
+ throwInBrowser(renderToString);
483
+ }
484
+ function renderToStringAsync(fn, options) {
485
+ throwInBrowser(renderToStringAsync);
486
+ }
487
+ function renderToStream(fn, options) {
488
+ throwInBrowser(renderToStream);
489
+ }
479
490
  function ssr(template, ...nodes) {}
480
491
  function resolveSSRNode(node) {}
481
492
  function ssrClassList(value) {}
package/web/dist/web.js CHANGED
@@ -16,7 +16,7 @@ const PropAliases = {
16
16
  playsinline: "playsInline",
17
17
  readonly: "readOnly"
18
18
  };
19
- const DelegatedEvents = new Set(["beforeinput", "click", "dblclick", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
19
+ const DelegatedEvents = new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
20
20
  const SVGElements = new Set([
21
21
  "altGlyph", "altGlyphDef", "altGlyphItem", "animate", "animateColor", "animateMotion", "animateTransform", "circle", "clipPath", "color-profile", "cursor", "defs", "desc", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "filter", "font", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignObject", "g", "glyph", "glyphRef", "hkern", "image", "line", "linearGradient", "marker", "mask", "metadata", "missing-glyph", "mpath", "path", "pattern", "polygon", "polyline", "radialGradient", "rect",
22
22
  "set", "stop",
@@ -353,6 +353,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
353
353
  multi = marker !== undefined;
354
354
  parent = multi && current[0] && current[0].parentNode || parent;
355
355
  if (t === "string" || t === "number") {
356
+ if (sharedConfig.context) return current;
356
357
  if (t === "number") value = value.toString();
357
358
  if (multi) {
358
359
  let node = current[0];
@@ -470,9 +471,19 @@ function NoHydration(props) {
470
471
  return sharedConfig.context ? undefined : props.children;
471
472
  }
472
473
 
473
- function renderToString(fn, options) {}
474
- function renderToStringAsync(fn, options) {}
475
- function renderToStream(fn, options) {}
474
+ function throwInBrowser(func) {
475
+ const err = new Error(`${func.name} is not supported in the browser, returning undefined`);
476
+ console.error(err);
477
+ }
478
+ function renderToString(fn, options) {
479
+ throwInBrowser(renderToString);
480
+ }
481
+ function renderToStringAsync(fn, options) {
482
+ throwInBrowser(renderToStringAsync);
483
+ }
484
+ function renderToStream(fn, options) {
485
+ throwInBrowser(renderToStream);
486
+ }
476
487
  function ssr(template, ...nodes) {}
477
488
  function resolveSSRNode(node) {}
478
489
  function ssrClassList(value) {}
@@ -10,8 +10,12 @@ export declare function renderToStringAsync<T>(fn: () => T, options?: {
10
10
  export declare function renderToStream<T>(fn: () => T, options?: {
11
11
  nonce?: string;
12
12
  renderId?: string;
13
- onCompleteShell?: () => void;
14
- onCompleteAll?: () => void;
13
+ onCompleteShell?: (info: {
14
+ write: (v: string) => void;
15
+ }) => void;
16
+ onCompleteAll?: (info: {
17
+ write: (v: string) => void;
18
+ }) => void;
15
19
  }): {
16
20
  pipe: (writable: {
17
21
  write: (v: string) => void;