solid-js 1.3.8 → 1.3.11

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());
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());
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.8",
4
+ "version": "1.3.11",
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": "6e7f0a80cd949e6dd5c0baaf45432ed2b0693119"
147
+ "gitHead": "f880eac70b79292cb3452bfbe27a9a94f283d605"
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);
@@ -215,7 +216,7 @@ const proxyTraps = {
215
216
  node = nodes[property] || (nodes[property] = createDataNode());
216
217
  node();
217
218
  }
218
- return wrappable ? wrap(value, target[$NAME] && `${target[$NAME]}:${property}`) : value;
219
+ return wrappable ? wrap(value, target[$NAME] && `${target[$NAME]}:${property.toString()}`) : value;
219
220
  },
220
221
  set(target, property, value) {
221
222
  setProperty(target, property, unwrap(value));
@@ -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);
@@ -211,7 +212,7 @@ const proxyTraps = {
211
212
  node = nodes[property] || (nodes[property] = createDataNode());
212
213
  node();
213
214
  }
214
- return wrappable ? wrap(value, target[$NAME] && `${target[$NAME]}:${property}`) : value;
215
+ return wrappable ? wrap(value, target[$NAME] && `${target[$NAME]}:${property.toString()}`) : value;
215
216
  },
216
217
  set(target, property, value) {
217
218
  setProperty(target, property, unwrap(value));
@@ -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);
@@ -77,7 +77,7 @@ function createMutable(state) {
77
77
  }
78
78
  function reconcile(value, options = {}) {
79
79
  return state => {
80
- if (!isWrappable(state)) return value;
80
+ if (!isWrappable(state) || !isWrappable(value)) return value;
81
81
  const targetKeys = Object.keys(value);
82
82
  for (let i = 0, len = targetKeys.length; i < len; i++) {
83
83
  const key = targetKeys[i];
@@ -87,6 +87,7 @@ function reconcile(value, options = {}) {
87
87
  for (let i = 0, len = previousKeys.length; i < len; i++) {
88
88
  if (value[previousKeys[i]] === undefined) setProperty(state, previousKeys[i], undefined);
89
89
  }
90
+ return state;
90
91
  };
91
92
  }
92
93
  function produce(fn) {
@@ -73,7 +73,7 @@ function createMutable(state) {
73
73
  }
74
74
  function reconcile(value, options = {}) {
75
75
  return state => {
76
- if (!isWrappable(state)) return value;
76
+ if (!isWrappable(state) || !isWrappable(value)) return value;
77
77
  const targetKeys = Object.keys(value);
78
78
  for (let i = 0, len = targetKeys.length; i < len; i++) {
79
79
  const key = targetKeys[i];
@@ -83,6 +83,7 @@ function reconcile(value, options = {}) {
83
83
  for (let i = 0, len = previousKeys.length; i < len; i++) {
84
84
  if (value[previousKeys[i]] === undefined) setProperty(state, previousKeys[i], undefined);
85
85
  }
86
+ return state;
86
87
  };
87
88
  }
88
89
  function produce(fn) {
@@ -1,4 +1,4 @@
1
1
  export { createStore, unwrap, $RAW } from "./store";
2
- export type { Store, SetStoreFunction, NotWrappable, StoreNode, StoreSetter, StorePathRange, ArrayFilterFn, Part, Next, WrappableNext, DeepReadonly } from "./store";
2
+ export type { Store, SetStoreFunction, NotWrappable, 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 { Store } from "./store";
1
+ import { DeepMutable, NotWrappable } from "./store";
2
2
  export declare type ReconcileOptions = {
3
3
  key?: string | null;
4
4
  merge?: boolean;
5
5
  };
6
- export declare function reconcile<T>(value: T, options?: ReconcileOptions): (state: unknown) => Store<T>;
7
- export declare function produce<T>(fn: (state: T) => void): (state: Store<T>) => Store<T>;
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;
@@ -1,15 +1,15 @@
1
- import { SetStoreFunction, Store } from "store";
1
+ import type { DeepMutable, SetStoreFunction, Store } from "store";
2
2
  export declare const $RAW: unique symbol;
3
3
  export declare function isWrappable(obj: any): boolean;
4
4
  export declare function unwrap<T>(item: any): T;
5
- export declare function setProperty(state: any, property: string | number, value: any, force?: boolean): void;
6
- export declare function updatePath(current: any, path: any[], traversed?: (number | string)[]): void;
5
+ export declare function setProperty(state: any, property: PropertyKey, value: any, force?: boolean): void;
6
+ export declare function updatePath(current: any, path: any[], traversed?: PropertyKey[]): void;
7
7
  export declare function createStore<T>(state: T | Store<T>): [Store<T>, SetStoreFunction<T>];
8
- export declare function createMutable<T>(state: T | Store<T>): Store<T>;
8
+ export declare function createMutable<T>(state: T | Store<T>): T;
9
9
  declare type ReconcileOptions = {
10
10
  key?: string | null;
11
11
  merge?: boolean;
12
12
  };
13
- export declare function reconcile<T>(value: T | Store<T>, options?: ReconcileOptions): (state: Store<T>) => void;
14
- export declare function produce<T>(fn: (state: T) => void): (state: Store<T>) => Store<T>;
13
+ export declare function reconcile<T extends U, U>(value: T, options?: ReconcileOptions): (state: U) => T;
14
+ export declare function produce<T>(fn: (state: DeepMutable<T>) => void): (state: T) => T;
15
15
  export {};
@@ -1,44 +1,45 @@
1
1
  import { Accessor } from "../..";
2
2
  export declare const $RAW: unique symbol, $NODE: unique symbol, $NAME: unique symbol;
3
- export declare type StoreNode = Record<keyof any, any>;
3
+ export declare type StoreNode = Record<PropertyKey, any>;
4
4
  export declare type NotWrappable = string | number | bigint | symbol | boolean | Function | null | undefined;
5
5
  export declare type Store<T> = DeepReadonly<T>;
6
6
  export declare function isWrappable(obj: any): any;
7
7
  export declare function unwrap<T extends StoreNode>(item: any, set?: Set<unknown>): T;
8
8
  export declare function getDataNodes(target: StoreNode): any;
9
- export declare function proxyDescriptor(target: StoreNode, property: keyof any): PropertyDescriptor | undefined;
9
+ export declare function proxyDescriptor(target: StoreNode, property: PropertyKey): PropertyDescriptor | undefined;
10
10
  export declare function ownKeys(target: StoreNode): (string | symbol)[];
11
11
  export declare function createDataNode(): Accessor<void> & {
12
12
  $: () => void;
13
13
  };
14
- export declare function setProperty(state: StoreNode, property: keyof any, value: any): void;
15
- export declare function updatePath(current: StoreNode, path: any[], traversed?: (keyof any)[]): void;
16
- export declare type DeepReadonly<T> = {
14
+ export declare function setProperty(state: StoreNode, property: PropertyKey, value: any): void;
15
+ export declare function updatePath(current: StoreNode, path: any[], traversed?: PropertyKey[]): void;
16
+ export declare type DeepReadonly<T> = 0 extends 1 & T ? T : {
17
17
  readonly [K in keyof T]: T[K] extends NotWrappable ? T[K] : DeepReadonly<T[K]>;
18
18
  };
19
- export declare type StoreSetter<T> = T | Partial<T> | ((prevState: T, traversed?: (keyof any)[]) => Partial<T> | void);
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]>;
21
+ };
20
22
  export declare type StorePathRange = {
21
23
  from?: number;
22
24
  to?: number;
23
25
  by?: number;
24
26
  };
25
- export declare type ArrayFilterFn<T> = (item: T, index: number) => boolean;
26
- export declare type Part<T> = [T] extends [never] ? never : [keyof T] extends [never] ? never : keyof T | (keyof T)[] | (number extends keyof T ? ArrayFilterFn<T[number]> | StorePathRange : never);
27
- export declare type Next<T, K extends Part<T>> = [K] extends [never] ? never : K extends keyof T ? T[K] : K extends (keyof T)[] ? T[K[number]] : number extends keyof T ? T[number] : never;
28
- export declare type WrappableNext<T, K extends Part<T>> = Exclude<Next<T, K>, NotWrappable>;
29
- declare type DistributeRest<T, K extends Part<T>> = K extends K ? [K, ...Rest<Next<T, K>>] : never;
30
- export declare type Rest<T> = 0 extends 1 & T ? [...(keyof any)[], any] : [StoreSetter<T>] | (T extends NotWrappable ? never : DistributeRest<T, Part<T>>);
31
- export declare type SetStoreFunction<T> = _SetStoreFunction<Store<T>>;
32
- interface _SetStoreFunction<T> {
33
- <K1 extends Part<T>, K2 extends Part<T1>, K3 extends Part<T2>, K4 extends Part<T3>, K5 extends Part<T4>, K6 extends Part<T5>, K7 extends Part<T6>, T1 extends WrappableNext<T, K1>, T2 extends WrappableNext<T1, K2>, T3 extends WrappableNext<T2, K3>, T4 extends WrappableNext<T3, K4>, T5 extends WrappableNext<T4, K5>, T6 extends WrappableNext<T5, K6>>(k1: K1, k2: K2, k3: K3, k4: K4, k5: K5, k6: K6, k7: K7, ...rest: Rest<Next<T6, K7>>): void;
34
- <K1 extends Part<T>, K2 extends Part<T1>, K3 extends Part<T2>, K4 extends Part<T3>, K5 extends Part<T4>, K6 extends Part<T5>, K7 extends Part<T6>, T1 extends WrappableNext<T, K1>, T2 extends WrappableNext<T1, K2>, T3 extends WrappableNext<T2, K3>, T4 extends WrappableNext<T3, K4>, T5 extends WrappableNext<T4, K5>, T6 extends WrappableNext<T5, K6>>(k1: K1, k2: K2, k3: K3, k4: K4, k5: K5, k6: K6, k7: K7, setter: StoreSetter<Next<T6, K7>>): void;
35
- <K1 extends Part<T>, K2 extends Part<T1>, K3 extends Part<T2>, K4 extends Part<T3>, K5 extends Part<T4>, K6 extends Part<T5>, T1 extends WrappableNext<T, K1>, T2 extends WrappableNext<T1, K2>, T3 extends WrappableNext<T2, K3>, T4 extends WrappableNext<T3, K4>, T5 extends WrappableNext<T4, K5>>(k1: K1, k2: K2, k3: K3, k4: K4, k5: K5, k6: K6, setter: StoreSetter<Next<T5, K6>>): void;
36
- <K1 extends Part<T>, K2 extends Part<T1>, K3 extends Part<T2>, K4 extends Part<T3>, K5 extends Part<T4>, T1 extends WrappableNext<T, K1>, T2 extends WrappableNext<T1, K2>, T3 extends WrappableNext<T2, K3>, T4 extends WrappableNext<T3, K4>>(k1: K1, k2: K2, k3: K3, k4: K4, k5: K5, setter: StoreSetter<Next<T4, K5>>): void;
37
- <K1 extends Part<T>, K2 extends Part<T1>, K3 extends Part<T2>, K4 extends Part<T3>, T1 extends WrappableNext<T, K1>, T2 extends WrappableNext<T1, K2>, T3 extends WrappableNext<T2, K3>>(k1: K1, k2: K2, k3: K3, k4: K4, setter: StoreSetter<Next<T3, K4>>): void;
38
- <K1 extends Part<T>, K2 extends Part<T1>, K3 extends Part<T2>, T1 extends WrappableNext<T, K1>, T2 extends WrappableNext<T1, K2>>(k1: K1, k2: K2, k3: K3, setter: StoreSetter<Next<T2, K3>>): void;
39
- <K1 extends Part<T>, K2 extends Part<T1>, T1 extends WrappableNext<T, K1>>(k1: K1, k2: K2, setter: StoreSetter<Next<T1, K2>>): void;
40
- <K extends Part<T>>(k: K, setter: StoreSetter<Next<T, K>>): void;
41
- (setter: StoreSetter<T>): void;
27
+ 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);
30
+ 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;
32
+ 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
+ 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
+ export interface SetStoreFunction<T> {
35
+ <K1 extends KeyOf<W<T>>, K2 extends KeyOf<W<W<T>[K1]>>, K3 extends KeyOf<W<W<W<T>[K1]>[K2]>>, K4 extends KeyOf<W<W<W<W<T>[K1]>[K2]>[K3]>>, K5 extends KeyOf<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>>, K6 extends KeyOf<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>>, K7 extends KeyOf<W<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>[K6]>>>(k1: Part<W<T>, K1>, k2: Part<W<W<T>[K1]>, K2>, k3: Part<W<W<W<T>[K1]>[K2]>, K3>, k4: Part<W<W<W<W<T>[K1]>[K2]>[K3]>, K4>, k5: Part<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>, K5>, k6: Part<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>, K6>, k7: Part<W<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>[K6]>, K7>, ...rest: Rest<W<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>[K6]>[K7], [K7, K6, K5, K4, K3, K2, K1]>): void;
36
+ <K1 extends KeyOf<W<T>>, K2 extends KeyOf<W<W<T>[K1]>>, K3 extends KeyOf<W<W<W<T>[K1]>[K2]>>, K4 extends KeyOf<W<W<W<W<T>[K1]>[K2]>[K3]>>, K5 extends KeyOf<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>>, K6 extends KeyOf<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>>>(k1: Part<W<T>, K1>, k2: Part<W<W<T>[K1]>, K2>, k3: Part<W<W<W<T>[K1]>[K2]>, K3>, k4: Part<W<W<W<W<T>[K1]>[K2]>[K3]>, K4>, k5: Part<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>, K5>, k6: Part<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>, K6>, setter: StoreSetter<W<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5]>[K6], [K6, K5, K4, K3, K2, K1]>): void;
37
+ <K1 extends KeyOf<W<T>>, K2 extends KeyOf<W<W<T>[K1]>>, K3 extends KeyOf<W<W<W<T>[K1]>[K2]>>, K4 extends KeyOf<W<W<W<W<T>[K1]>[K2]>[K3]>>, K5 extends KeyOf<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>>>(k1: Part<W<T>, K1>, k2: Part<W<W<T>[K1]>, K2>, k3: Part<W<W<W<T>[K1]>[K2]>, K3>, k4: Part<W<W<W<W<T>[K1]>[K2]>[K3]>, K4>, k5: Part<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>, K5>, setter: StoreSetter<W<W<W<W<W<T>[K1]>[K2]>[K3]>[K4]>[K5], [K5, K4, K3, K2, K1]>): void;
38
+ <K1 extends KeyOf<W<T>>, K2 extends KeyOf<W<W<T>[K1]>>, K3 extends KeyOf<W<W<W<T>[K1]>[K2]>>, K4 extends KeyOf<W<W<W<W<T>[K1]>[K2]>[K3]>>>(k1: Part<W<T>, K1>, k2: Part<W<W<T>[K1]>, K2>, k3: Part<W<W<W<T>[K1]>[K2]>, K3>, k4: Part<W<W<W<W<T>[K1]>[K2]>[K3]>, K4>, setter: StoreSetter<W<W<W<W<T>[K1]>[K2]>[K3]>[K4], [K4, K3, K2, K1]>): void;
39
+ <K1 extends KeyOf<W<T>>, K2 extends KeyOf<W<W<T>[K1]>>, K3 extends KeyOf<W<W<W<T>[K1]>[K2]>>>(k1: Part<W<T>, K1>, k2: Part<W<W<T>[K1]>, K2>, k3: Part<W<W<W<T>[K1]>[K2]>, K3>, setter: StoreSetter<W<W<W<T>[K1]>[K2]>[K3], [K3, K2, K1]>): void;
40
+ <K1 extends KeyOf<W<T>>, K2 extends KeyOf<W<W<T>[K1]>>>(k1: Part<W<T>, K1>, k2: Part<W<W<T>[K1]>, K2>, setter: StoreSetter<W<W<T>[K1]>[K2], [K2, K1]>): void;
41
+ <K1 extends KeyOf<W<T>>>(k1: Part<W<T>, K1>, setter: StoreSetter<W<T>[K1], [K1]>): void;
42
+ (setter: StoreSetter<T, []>): void;
42
43
  }
43
44
  /**
44
45
  * creates a reactive store that can be read through a proxy object and written with a setter function
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",
@@ -385,11 +385,10 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
385
385
  solidJs.createRenderEffect(() => current = insertExpression(parent, array, current, marker, true));
386
386
  return () => current;
387
387
  }
388
- if (solidJs.sharedConfig.context && current && current.length) {
388
+ if (solidJs.sharedConfig.context) {
389
389
  for (let i = 0; i < array.length; i++) {
390
390
  if (array[i].parentNode) return current = array;
391
391
  }
392
- return current;
393
392
  }
394
393
  if (array.length === 0) {
395
394
  current = cleanChildren(parent, current, marker);
@@ -404,7 +403,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
404
403
  }
405
404
  current = array;
406
405
  } else if (value instanceof Node) {
407
- if (solidJs.sharedConfig.context && current && current.length) return current = value.parentNode ? multi ? [value] : value : current;
406
+ if (solidJs.sharedConfig.context && value.parentNode) return current = multi ? [value] : value;
408
407
  if (Array.isArray(current)) {
409
408
  if (multi) return current = cleanChildren(parent, current, marker, value);
410
409
  cleanChildren(parent, current, null, 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",
@@ -382,11 +382,10 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
382
382
  createRenderEffect(() => current = insertExpression(parent, array, current, marker, true));
383
383
  return () => current;
384
384
  }
385
- if (sharedConfig.context && current && current.length) {
385
+ if (sharedConfig.context) {
386
386
  for (let i = 0; i < array.length; i++) {
387
387
  if (array[i].parentNode) return current = array;
388
388
  }
389
- return current;
390
389
  }
391
390
  if (array.length === 0) {
392
391
  current = cleanChildren(parent, current, marker);
@@ -401,7 +400,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
401
400
  }
402
401
  current = array;
403
402
  } else if (value instanceof Node) {
404
- if (sharedConfig.context && current && current.length) return current = value.parentNode ? multi ? [value] : value : current;
403
+ if (sharedConfig.context && value.parentNode) return current = multi ? [value] : value;
405
404
  if (Array.isArray(current)) {
406
405
  if (multi) return current = cleanChildren(parent, current, marker, value);
407
406
  cleanChildren(parent, current, null, value);
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",
@@ -384,11 +384,10 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
384
384
  solidJs.createRenderEffect(() => current = insertExpression(parent, array, current, marker, true));
385
385
  return () => current;
386
386
  }
387
- if (solidJs.sharedConfig.context && current && current.length) {
387
+ if (solidJs.sharedConfig.context) {
388
388
  for (let i = 0; i < array.length; i++) {
389
389
  if (array[i].parentNode) return current = array;
390
390
  }
391
- return current;
392
391
  }
393
392
  if (array.length === 0) {
394
393
  current = cleanChildren(parent, current, marker);
@@ -403,7 +402,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
403
402
  }
404
403
  current = array;
405
404
  } else if (value instanceof Node) {
406
- if (solidJs.sharedConfig.context && current && current.length) return current = value.parentNode ? multi ? [value] : value : current;
405
+ if (solidJs.sharedConfig.context && value.parentNode) return current = multi ? [value] : value;
407
406
  if (Array.isArray(current)) {
408
407
  if (multi) return current = cleanChildren(parent, current, marker, value);
409
408
  cleanChildren(parent, current, null, 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",
@@ -381,11 +381,10 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
381
381
  createRenderEffect(() => current = insertExpression(parent, array, current, marker, true));
382
382
  return () => current;
383
383
  }
384
- if (sharedConfig.context && current && current.length) {
384
+ if (sharedConfig.context) {
385
385
  for (let i = 0; i < array.length; i++) {
386
386
  if (array[i].parentNode) return current = array;
387
387
  }
388
- return current;
389
388
  }
390
389
  if (array.length === 0) {
391
390
  current = cleanChildren(parent, current, marker);
@@ -400,7 +399,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
400
399
  }
401
400
  current = array;
402
401
  } else if (value instanceof Node) {
403
- if (sharedConfig.context && current && current.length) return current = value.parentNode ? multi ? [value] : value : current;
402
+ if (sharedConfig.context && value.parentNode) return current = multi ? [value] : value;
404
403
  if (Array.isArray(current)) {
405
404
  if (multi) return current = cleanChildren(parent, current, marker, value);
406
405
  cleanChildren(parent, current, null, value);