solid-js 1.3.9 → 1.3.12

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
@@ -587,7 +587,8 @@ function createContext(defaultValue) {
587
587
  };
588
588
  }
589
589
  function useContext(context) {
590
- return lookup(Owner, context.id) || context.defaultValue;
590
+ let ctx;
591
+ return (ctx = lookup(Owner, context.id)) !== undefined ? ctx : context.defaultValue;
591
592
  }
592
593
  function children(fn) {
593
594
  const children = createMemo(fn);
@@ -668,8 +669,10 @@ function writeSignal(node, value, isComp) {
668
669
  for (let i = 0; i < node.observers.length; i += 1) {
669
670
  const o = node.observers[i];
670
671
  if (TransitionRunning && Transition.disposed.has(o)) continue;
671
- if (o.pure) Updates.push(o);else Effects.push(o);
672
- if (o.observers && (TransitionRunning && !o.tState || !TransitionRunning && !o.state)) markUpstream(o);
672
+ if (TransitionRunning && !o.tState || !TransitionRunning && !o.state) {
673
+ if (o.pure) Updates.push(o);else Effects.push(o);
674
+ if (o.observers) markUpstream(o);
675
+ }
673
676
  if (TransitionRunning) o.tState = STALE;else o.state = STALE;
674
677
  }
675
678
  if (Updates.length > 10e5) {
@@ -760,8 +763,8 @@ function createComputation(fn, init, pure, state = STALE, options) {
760
763
  }
761
764
  function runTop(node) {
762
765
  const runningTransition = Transition && Transition.running;
763
- if (!runningTransition && node.state !== STALE) return node.state = 0;
764
- if (runningTransition && node.tState !== STALE) return node.tState = 0;
766
+ if (!runningTransition && node.state === 0 || runningTransition && node.tState === 0) return;
767
+ if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) return lookDownstream(node);
765
768
  if (node.suspense && untrack(node.suspense.inFallback)) return node.suspense.effects.push(node);
766
769
  const ancestors = [node];
767
770
  while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) {
@@ -882,8 +885,8 @@ function runUserEffects(queue) {
882
885
  for (i = resume; i < queue.length; i++) runTop(queue[i]);
883
886
  }
884
887
  function lookDownstream(node, ignore) {
885
- node.state = 0;
886
888
  const runningTransition = Transition && Transition.running;
889
+ if (runningTransition) node.tState = 0;else node.state = 0;
887
890
  for (let i = 0; i < node.sources.length; i += 1) {
888
891
  const source = node.sources[i];
889
892
  if (source.sources) {
@@ -954,7 +957,7 @@ function handleError(err) {
954
957
  fns.forEach(f => f(err));
955
958
  }
956
959
  function lookup(owner, key) {
957
- return owner && (owner.context && owner.context[key] !== undefined ? owner.context[key] : owner.owner && lookup(owner.owner, key));
960
+ return owner ? owner.context && owner.context[key] !== undefined ? owner.context[key] : lookup(owner.owner, key) : undefined;
958
961
  }
959
962
  function resolveChildren(children) {
960
963
  if (typeof children === "function" && !children.length) return resolveChildren(children());
package/dist/dev.js CHANGED
@@ -583,7 +583,8 @@ function createContext(defaultValue) {
583
583
  };
584
584
  }
585
585
  function useContext(context) {
586
- return lookup(Owner, context.id) || context.defaultValue;
586
+ let ctx;
587
+ return (ctx = lookup(Owner, context.id)) !== undefined ? ctx : context.defaultValue;
587
588
  }
588
589
  function children(fn) {
589
590
  const children = createMemo(fn);
@@ -664,8 +665,10 @@ function writeSignal(node, value, isComp) {
664
665
  for (let i = 0; i < node.observers.length; i += 1) {
665
666
  const o = node.observers[i];
666
667
  if (TransitionRunning && Transition.disposed.has(o)) continue;
667
- if (o.pure) Updates.push(o);else Effects.push(o);
668
- if (o.observers && (TransitionRunning && !o.tState || !TransitionRunning && !o.state)) markUpstream(o);
668
+ if (TransitionRunning && !o.tState || !TransitionRunning && !o.state) {
669
+ if (o.pure) Updates.push(o);else Effects.push(o);
670
+ if (o.observers) markUpstream(o);
671
+ }
669
672
  if (TransitionRunning) o.tState = STALE;else o.state = STALE;
670
673
  }
671
674
  if (Updates.length > 10e5) {
@@ -756,8 +759,8 @@ function createComputation(fn, init, pure, state = STALE, options) {
756
759
  }
757
760
  function runTop(node) {
758
761
  const runningTransition = Transition && Transition.running;
759
- if (!runningTransition && node.state !== STALE) return node.state = 0;
760
- if (runningTransition && node.tState !== STALE) return node.tState = 0;
762
+ if (!runningTransition && node.state === 0 || runningTransition && node.tState === 0) return;
763
+ if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) return lookDownstream(node);
761
764
  if (node.suspense && untrack(node.suspense.inFallback)) return node.suspense.effects.push(node);
762
765
  const ancestors = [node];
763
766
  while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) {
@@ -878,8 +881,8 @@ function runUserEffects(queue) {
878
881
  for (i = resume; i < queue.length; i++) runTop(queue[i]);
879
882
  }
880
883
  function lookDownstream(node, ignore) {
881
- node.state = 0;
882
884
  const runningTransition = Transition && Transition.running;
885
+ if (runningTransition) node.tState = 0;else node.state = 0;
883
886
  for (let i = 0; i < node.sources.length; i += 1) {
884
887
  const source = node.sources[i];
885
888
  if (source.sources) {
@@ -950,7 +953,7 @@ function handleError(err) {
950
953
  fns.forEach(f => f(err));
951
954
  }
952
955
  function lookup(owner, key) {
953
- return owner && (owner.context && owner.context[key] !== undefined ? owner.context[key] : owner.owner && lookup(owner.owner, key));
956
+ return owner ? owner.context && owner.context[key] !== undefined ? owner.context[key] : lookup(owner.owner, key) : undefined;
954
957
  }
955
958
  function resolveChildren(children) {
956
959
  if (typeof children === "function" && !children.length) return resolveChildren(children());
package/dist/server.cjs CHANGED
@@ -118,7 +118,8 @@ function createContext(defaultValue) {
118
118
  };
119
119
  }
120
120
  function useContext(context) {
121
- return lookup(Owner, context.id) || context.defaultValue;
121
+ let ctx;
122
+ return (ctx = lookup(Owner, context.id)) !== undefined ? ctx : context.defaultValue;
122
123
  }
123
124
  function getOwner() {
124
125
  return Owner;
@@ -136,7 +137,7 @@ function runWithOwner(o, fn) {
136
137
  }
137
138
  }
138
139
  function lookup(owner, key) {
139
- return owner && (owner.context && owner.context[key] !== undefined ? owner.context[key] : owner.owner && lookup(owner.owner, key));
140
+ return owner ? owner.context && owner.context[key] !== undefined ? owner.context[key] : lookup(owner.owner, key) : undefined;
140
141
  }
141
142
  function resolveChildren(children) {
142
143
  if (typeof children === "function" && !children.length) return resolveChildren(children());
@@ -330,16 +331,16 @@ function ErrorBoundary(props) {
330
331
  }
331
332
  const SuspenseContext = createContext();
332
333
  let resourceContext = null;
333
- function createResource(fn, fetcher, options = {}) {
334
+ function createResource(source, fetcher, options = {}) {
334
335
  if (arguments.length === 2) {
335
336
  if (typeof fetcher === "object") {
336
337
  options = fetcher;
337
- fetcher = fn;
338
- fn = true;
338
+ fetcher = source;
339
+ source = true;
339
340
  }
340
341
  } else if (arguments.length === 1) {
341
- fetcher = fn;
342
- fn = true;
342
+ fetcher = source;
343
+ source = true;
343
344
  }
344
345
  const contexts = new Set();
345
346
  const id = sharedConfig.context.id + sharedConfig.context.count++;
@@ -371,23 +372,27 @@ function createResource(fn, fetcher, options = {}) {
371
372
  read.error = undefined;
372
373
  function load() {
373
374
  const ctx = sharedConfig.context;
374
- if (!ctx.async) return read.loading = !!(typeof fn === "function" ? fn() : fn);
375
+ if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
375
376
  if (ctx.resources && id in ctx.resources && ctx.resources[id].data) {
376
377
  value = ctx.resources[id].data;
377
378
  return;
378
379
  }
379
380
  resourceContext = [];
380
- const lookup = typeof fn === "function" ? fn() : fn;
381
+ const lookup = typeof source === "function" ? source() : source;
381
382
  if (resourceContext.length) {
382
- p = Promise.all(resourceContext).then(() => fetcher(fn(), () => value));
383
+ p = Promise.all(resourceContext).then(() => fetcher(source(), {
384
+ value
385
+ }));
383
386
  }
384
387
  resourceContext = null;
385
388
  if (!p) {
386
389
  if (lookup == null || lookup === false) return;
387
- p = fetcher(lookup, () => value);
390
+ p = fetcher(lookup, {
391
+ value
392
+ });
388
393
  }
389
- read.loading = true;
390
- if ("then" in p) {
394
+ if (p && "then" in p) {
395
+ read.loading = true;
391
396
  if (ctx.writeResource) ctx.writeResource(id, p);
392
397
  return p.then(res => {
393
398
  read.loading = false;
package/dist/server.js CHANGED
@@ -114,7 +114,8 @@ function createContext(defaultValue) {
114
114
  };
115
115
  }
116
116
  function useContext(context) {
117
- return lookup(Owner, context.id) || context.defaultValue;
117
+ let ctx;
118
+ return (ctx = lookup(Owner, context.id)) !== undefined ? ctx : context.defaultValue;
118
119
  }
119
120
  function getOwner() {
120
121
  return Owner;
@@ -132,7 +133,7 @@ function runWithOwner(o, fn) {
132
133
  }
133
134
  }
134
135
  function lookup(owner, key) {
135
- return owner && (owner.context && owner.context[key] !== undefined ? owner.context[key] : owner.owner && lookup(owner.owner, key));
136
+ return owner ? owner.context && owner.context[key] !== undefined ? owner.context[key] : lookup(owner.owner, key) : undefined;
136
137
  }
137
138
  function resolveChildren(children) {
138
139
  if (typeof children === "function" && !children.length) return resolveChildren(children());
@@ -326,16 +327,16 @@ function ErrorBoundary(props) {
326
327
  }
327
328
  const SuspenseContext = createContext();
328
329
  let resourceContext = null;
329
- function createResource(fn, fetcher, options = {}) {
330
+ function createResource(source, fetcher, options = {}) {
330
331
  if (arguments.length === 2) {
331
332
  if (typeof fetcher === "object") {
332
333
  options = fetcher;
333
- fetcher = fn;
334
- fn = true;
334
+ fetcher = source;
335
+ source = true;
335
336
  }
336
337
  } else if (arguments.length === 1) {
337
- fetcher = fn;
338
- fn = true;
338
+ fetcher = source;
339
+ source = true;
339
340
  }
340
341
  const contexts = new Set();
341
342
  const id = sharedConfig.context.id + sharedConfig.context.count++;
@@ -367,23 +368,27 @@ function createResource(fn, fetcher, options = {}) {
367
368
  read.error = undefined;
368
369
  function load() {
369
370
  const ctx = sharedConfig.context;
370
- if (!ctx.async) return read.loading = !!(typeof fn === "function" ? fn() : fn);
371
+ if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
371
372
  if (ctx.resources && id in ctx.resources && ctx.resources[id].data) {
372
373
  value = ctx.resources[id].data;
373
374
  return;
374
375
  }
375
376
  resourceContext = [];
376
- const lookup = typeof fn === "function" ? fn() : fn;
377
+ const lookup = typeof source === "function" ? source() : source;
377
378
  if (resourceContext.length) {
378
- p = Promise.all(resourceContext).then(() => fetcher(fn(), () => value));
379
+ p = Promise.all(resourceContext).then(() => fetcher(source(), {
380
+ value
381
+ }));
379
382
  }
380
383
  resourceContext = null;
381
384
  if (!p) {
382
385
  if (lookup == null || lookup === false) return;
383
- p = fetcher(lookup, () => value);
386
+ p = fetcher(lookup, {
387
+ value
388
+ });
384
389
  }
385
- read.loading = true;
386
- if ("then" in p) {
390
+ if (p && "then" in p) {
391
+ read.loading = true;
387
392
  if (ctx.writeResource) ctx.writeResource(id, p);
388
393
  return p.then(res => {
389
394
  read.loading = false;
package/dist/solid.cjs CHANGED
@@ -531,7 +531,8 @@ function createContext(defaultValue) {
531
531
  };
532
532
  }
533
533
  function useContext(context) {
534
- return lookup(Owner, context.id) || context.defaultValue;
534
+ let ctx;
535
+ return (ctx = lookup(Owner, context.id)) !== undefined ? ctx : context.defaultValue;
535
536
  }
536
537
  function children(fn) {
537
538
  const children = createMemo(fn);
@@ -612,8 +613,10 @@ function writeSignal(node, value, isComp) {
612
613
  for (let i = 0; i < node.observers.length; i += 1) {
613
614
  const o = node.observers[i];
614
615
  if (TransitionRunning && Transition.disposed.has(o)) continue;
615
- if (o.pure) Updates.push(o);else Effects.push(o);
616
- if (o.observers && (TransitionRunning && !o.tState || !TransitionRunning && !o.state)) markUpstream(o);
616
+ if (TransitionRunning && !o.tState || !TransitionRunning && !o.state) {
617
+ if (o.pure) Updates.push(o);else Effects.push(o);
618
+ if (o.observers) markUpstream(o);
619
+ }
617
620
  if (TransitionRunning) o.tState = STALE;else o.state = STALE;
618
621
  }
619
622
  if (Updates.length > 10e5) {
@@ -703,8 +706,8 @@ function createComputation(fn, init, pure, state = STALE, options) {
703
706
  }
704
707
  function runTop(node) {
705
708
  const runningTransition = Transition && Transition.running;
706
- if (!runningTransition && node.state !== STALE) return node.state = 0;
707
- if (runningTransition && node.tState !== STALE) return node.tState = 0;
709
+ if (!runningTransition && node.state === 0 || runningTransition && node.tState === 0) return;
710
+ if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) return lookDownstream(node);
708
711
  if (node.suspense && untrack(node.suspense.inFallback)) return node.suspense.effects.push(node);
709
712
  const ancestors = [node];
710
713
  while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) {
@@ -824,8 +827,8 @@ function runUserEffects(queue) {
824
827
  for (i = resume; i < queue.length; i++) runTop(queue[i]);
825
828
  }
826
829
  function lookDownstream(node, ignore) {
827
- node.state = 0;
828
830
  const runningTransition = Transition && Transition.running;
831
+ if (runningTransition) node.tState = 0;else node.state = 0;
829
832
  for (let i = 0; i < node.sources.length; i += 1) {
830
833
  const source = node.sources[i];
831
834
  if (source.sources) {
@@ -896,7 +899,7 @@ function handleError(err) {
896
899
  fns.forEach(f => f(err));
897
900
  }
898
901
  function lookup(owner, key) {
899
- return owner && (owner.context && owner.context[key] !== undefined ? owner.context[key] : owner.owner && lookup(owner.owner, key));
902
+ return owner ? owner.context && owner.context[key] !== undefined ? owner.context[key] : lookup(owner.owner, key) : undefined;
900
903
  }
901
904
  function resolveChildren(children) {
902
905
  if (typeof children === "function" && !children.length) return resolveChildren(children());
package/dist/solid.js CHANGED
@@ -527,7 +527,8 @@ function createContext(defaultValue) {
527
527
  };
528
528
  }
529
529
  function useContext(context) {
530
- return lookup(Owner, context.id) || context.defaultValue;
530
+ let ctx;
531
+ return (ctx = lookup(Owner, context.id)) !== undefined ? ctx : context.defaultValue;
531
532
  }
532
533
  function children(fn) {
533
534
  const children = createMemo(fn);
@@ -608,8 +609,10 @@ function writeSignal(node, value, isComp) {
608
609
  for (let i = 0; i < node.observers.length; i += 1) {
609
610
  const o = node.observers[i];
610
611
  if (TransitionRunning && Transition.disposed.has(o)) continue;
611
- if (o.pure) Updates.push(o);else Effects.push(o);
612
- if (o.observers && (TransitionRunning && !o.tState || !TransitionRunning && !o.state)) markUpstream(o);
612
+ if (TransitionRunning && !o.tState || !TransitionRunning && !o.state) {
613
+ if (o.pure) Updates.push(o);else Effects.push(o);
614
+ if (o.observers) markUpstream(o);
615
+ }
613
616
  if (TransitionRunning) o.tState = STALE;else o.state = STALE;
614
617
  }
615
618
  if (Updates.length > 10e5) {
@@ -699,8 +702,8 @@ function createComputation(fn, init, pure, state = STALE, options) {
699
702
  }
700
703
  function runTop(node) {
701
704
  const runningTransition = Transition && Transition.running;
702
- if (!runningTransition && node.state !== STALE) return node.state = 0;
703
- if (runningTransition && node.tState !== STALE) return node.tState = 0;
705
+ if (!runningTransition && node.state === 0 || runningTransition && node.tState === 0) return;
706
+ if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) return lookDownstream(node);
704
707
  if (node.suspense && untrack(node.suspense.inFallback)) return node.suspense.effects.push(node);
705
708
  const ancestors = [node];
706
709
  while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) {
@@ -820,8 +823,8 @@ function runUserEffects(queue) {
820
823
  for (i = resume; i < queue.length; i++) runTop(queue[i]);
821
824
  }
822
825
  function lookDownstream(node, ignore) {
823
- node.state = 0;
824
826
  const runningTransition = Transition && Transition.running;
827
+ if (runningTransition) node.tState = 0;else node.state = 0;
825
828
  for (let i = 0; i < node.sources.length; i += 1) {
826
829
  const source = node.sources[i];
827
830
  if (source.sources) {
@@ -892,7 +895,7 @@ function handleError(err) {
892
895
  fns.forEach(f => f(err));
893
896
  }
894
897
  function lookup(owner, key) {
895
- return owner && (owner.context && owner.context[key] !== undefined ? owner.context[key] : owner.owner && lookup(owner.owner, key));
898
+ return owner ? owner.context && owner.context[key] !== undefined ? owner.context[key] : lookup(owner.owner, key) : undefined;
896
899
  }
897
900
  function resolveChildren(children) {
898
901
  if (typeof children === "function" && !children.length) return resolveChildren(children());
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.9",
4
+ "version": "1.3.12",
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": "939e87af354cdd5f4fcc85d2e1c5df86eecec773"
147
+ "gitHead": "e7671349791bd239fbe20c54c266ae085a7f09f2"
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,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 = {
@@ -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 = {
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;