solid-js 1.9.12 → 1.9.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
@@ -666,20 +666,23 @@ function readSignal() {
666
666
  }
667
667
  }
668
668
  if (Listener) {
669
- const sSlot = this.observers ? this.observers.length : 0;
670
- if (!Listener.sources) {
671
- Listener.sources = [this];
672
- Listener.sourceSlots = [sSlot];
673
- } else {
674
- Listener.sources.push(this);
675
- Listener.sourceSlots.push(sSlot);
676
- }
677
- if (!this.observers) {
678
- this.observers = [Listener];
679
- this.observerSlots = [Listener.sources.length - 1];
680
- } else {
681
- this.observers.push(Listener);
682
- this.observerSlots.push(Listener.sources.length - 1);
669
+ const observers = this.observers;
670
+ if (!observers || observers[observers.length - 1] !== Listener) {
671
+ const sSlot = observers ? observers.length : 0;
672
+ if (!Listener.sources) {
673
+ Listener.sources = [this];
674
+ Listener.sourceSlots = [sSlot];
675
+ } else {
676
+ Listener.sources.push(this);
677
+ Listener.sourceSlots.push(sSlot);
678
+ }
679
+ if (!observers) {
680
+ this.observers = [Listener];
681
+ this.observerSlots = [Listener.sources.length - 1];
682
+ } else {
683
+ observers.push(Listener);
684
+ this.observerSlots.push(Listener.sources.length - 1);
685
+ }
683
686
  }
684
687
  }
685
688
  if (runningTransition && Transition.sources.has(this)) return this.tValue;
@@ -1052,7 +1055,11 @@ function resolveChildren(children) {
1052
1055
  const results = [];
1053
1056
  for (let i = 0; i < children.length; i++) {
1054
1057
  const result = resolveChildren(children[i]);
1055
- Array.isArray(result) ? results.push.apply(results, result) : results.push(result);
1058
+ if (Array.isArray(result)) {
1059
+ if (result.length < 32768) results.push.apply(results, result);else for (let j = 0; j < result.length; j++) results.push(result[j]);
1060
+ } else {
1061
+ results.push(result);
1062
+ }
1056
1063
  }
1057
1064
  return results;
1058
1065
  }
package/dist/dev.js CHANGED
@@ -664,20 +664,23 @@ function readSignal() {
664
664
  }
665
665
  }
666
666
  if (Listener) {
667
- const sSlot = this.observers ? this.observers.length : 0;
668
- if (!Listener.sources) {
669
- Listener.sources = [this];
670
- Listener.sourceSlots = [sSlot];
671
- } else {
672
- Listener.sources.push(this);
673
- Listener.sourceSlots.push(sSlot);
674
- }
675
- if (!this.observers) {
676
- this.observers = [Listener];
677
- this.observerSlots = [Listener.sources.length - 1];
678
- } else {
679
- this.observers.push(Listener);
680
- this.observerSlots.push(Listener.sources.length - 1);
667
+ const observers = this.observers;
668
+ if (!observers || observers[observers.length - 1] !== Listener) {
669
+ const sSlot = observers ? observers.length : 0;
670
+ if (!Listener.sources) {
671
+ Listener.sources = [this];
672
+ Listener.sourceSlots = [sSlot];
673
+ } else {
674
+ Listener.sources.push(this);
675
+ Listener.sourceSlots.push(sSlot);
676
+ }
677
+ if (!observers) {
678
+ this.observers = [Listener];
679
+ this.observerSlots = [Listener.sources.length - 1];
680
+ } else {
681
+ observers.push(Listener);
682
+ this.observerSlots.push(Listener.sources.length - 1);
683
+ }
681
684
  }
682
685
  }
683
686
  if (runningTransition && Transition.sources.has(this)) return this.tValue;
@@ -1050,7 +1053,11 @@ function resolveChildren(children) {
1050
1053
  const results = [];
1051
1054
  for (let i = 0; i < children.length; i++) {
1052
1055
  const result = resolveChildren(children[i]);
1053
- Array.isArray(result) ? results.push.apply(results, result) : results.push(result);
1056
+ if (Array.isArray(result)) {
1057
+ if (result.length < 32768) results.push.apply(results, result);else for (let j = 0; j < result.length; j++) results.push(result[j]);
1058
+ } else {
1059
+ results.push(result);
1060
+ }
1054
1061
  }
1055
1062
  return results;
1056
1063
  }
package/dist/server.cjs CHANGED
@@ -192,7 +192,11 @@ function resolveChildren(children) {
192
192
  const results = [];
193
193
  for (let i = 0; i < children.length; i++) {
194
194
  const result = resolveChildren(children[i]);
195
- Array.isArray(result) ? results.push.apply(results, result) : results.push(result);
195
+ if (Array.isArray(result)) {
196
+ if (result.length < 32768) results.push.apply(results, result);else for (let j = 0; j < result.length; j++) results.push(result[j]);
197
+ } else {
198
+ results.push(result);
199
+ }
196
200
  }
197
201
  return results;
198
202
  }
package/dist/server.js CHANGED
@@ -190,7 +190,11 @@ function resolveChildren(children) {
190
190
  const results = [];
191
191
  for (let i = 0; i < children.length; i++) {
192
192
  const result = resolveChildren(children[i]);
193
- Array.isArray(result) ? results.push.apply(results, result) : results.push(result);
193
+ if (Array.isArray(result)) {
194
+ if (result.length < 32768) results.push.apply(results, result);else for (let j = 0; j < result.length; j++) results.push(result[j]);
195
+ } else {
196
+ results.push(result);
197
+ }
194
198
  }
195
199
  return results;
196
200
  }
package/dist/solid.cjs CHANGED
@@ -623,20 +623,23 @@ function readSignal() {
623
623
  }
624
624
  }
625
625
  if (Listener) {
626
- const sSlot = this.observers ? this.observers.length : 0;
627
- if (!Listener.sources) {
628
- Listener.sources = [this];
629
- Listener.sourceSlots = [sSlot];
630
- } else {
631
- Listener.sources.push(this);
632
- Listener.sourceSlots.push(sSlot);
633
- }
634
- if (!this.observers) {
635
- this.observers = [Listener];
636
- this.observerSlots = [Listener.sources.length - 1];
637
- } else {
638
- this.observers.push(Listener);
639
- this.observerSlots.push(Listener.sources.length - 1);
626
+ const observers = this.observers;
627
+ if (!observers || observers[observers.length - 1] !== Listener) {
628
+ const sSlot = observers ? observers.length : 0;
629
+ if (!Listener.sources) {
630
+ Listener.sources = [this];
631
+ Listener.sourceSlots = [sSlot];
632
+ } else {
633
+ Listener.sources.push(this);
634
+ Listener.sourceSlots.push(sSlot);
635
+ }
636
+ if (!observers) {
637
+ this.observers = [Listener];
638
+ this.observerSlots = [Listener.sources.length - 1];
639
+ } else {
640
+ observers.push(Listener);
641
+ this.observerSlots.push(Listener.sources.length - 1);
642
+ }
640
643
  }
641
644
  }
642
645
  if (runningTransition && Transition.sources.has(this)) return this.tValue;
@@ -1006,7 +1009,11 @@ function resolveChildren(children) {
1006
1009
  const results = [];
1007
1010
  for (let i = 0; i < children.length; i++) {
1008
1011
  const result = resolveChildren(children[i]);
1009
- Array.isArray(result) ? results.push.apply(results, result) : results.push(result);
1012
+ if (Array.isArray(result)) {
1013
+ if (result.length < 32768) results.push.apply(results, result);else for (let j = 0; j < result.length; j++) results.push(result[j]);
1014
+ } else {
1015
+ results.push(result);
1016
+ }
1010
1017
  }
1011
1018
  return results;
1012
1019
  }
package/dist/solid.js CHANGED
@@ -621,20 +621,23 @@ function readSignal() {
621
621
  }
622
622
  }
623
623
  if (Listener) {
624
- const sSlot = this.observers ? this.observers.length : 0;
625
- if (!Listener.sources) {
626
- Listener.sources = [this];
627
- Listener.sourceSlots = [sSlot];
628
- } else {
629
- Listener.sources.push(this);
630
- Listener.sourceSlots.push(sSlot);
631
- }
632
- if (!this.observers) {
633
- this.observers = [Listener];
634
- this.observerSlots = [Listener.sources.length - 1];
635
- } else {
636
- this.observers.push(Listener);
637
- this.observerSlots.push(Listener.sources.length - 1);
624
+ const observers = this.observers;
625
+ if (!observers || observers[observers.length - 1] !== Listener) {
626
+ const sSlot = observers ? observers.length : 0;
627
+ if (!Listener.sources) {
628
+ Listener.sources = [this];
629
+ Listener.sourceSlots = [sSlot];
630
+ } else {
631
+ Listener.sources.push(this);
632
+ Listener.sourceSlots.push(sSlot);
633
+ }
634
+ if (!observers) {
635
+ this.observers = [Listener];
636
+ this.observerSlots = [Listener.sources.length - 1];
637
+ } else {
638
+ observers.push(Listener);
639
+ this.observerSlots.push(Listener.sources.length - 1);
640
+ }
638
641
  }
639
642
  }
640
643
  if (runningTransition && Transition.sources.has(this)) return this.tValue;
@@ -1004,7 +1007,11 @@ function resolveChildren(children) {
1004
1007
  const results = [];
1005
1008
  for (let i = 0; i < children.length; i++) {
1006
1009
  const result = resolveChildren(children[i]);
1007
- Array.isArray(result) ? results.push.apply(results, result) : results.push(result);
1010
+ if (Array.isArray(result)) {
1011
+ if (result.length < 32768) results.push.apply(results, result);else for (let j = 0; j < result.length; j++) results.push(result[j]);
1012
+ } else {
1013
+ results.push(result);
1014
+ }
1008
1015
  }
1009
1016
  return results;
1010
1017
  }
@@ -140,14 +140,13 @@ export namespace JSX {
140
140
  interface IntrinsicAttributes {
141
141
  ref?: unknown | ((e: unknown) => void) | undefined;
142
142
  }
143
+ export type ClassList = {
144
+ [k: string]: boolean | undefined;
145
+ };
143
146
  interface CustomAttributes<T> {
144
147
  ref?: T | ((el: T) => void) | undefined;
145
148
  children?: FunctionMaybe<Element | undefined>;
146
- classList?:
147
- | {
148
- [k: string]: boolean | undefined;
149
- }
150
- | undefined;
149
+ classList?: ClassList | undefined;
151
150
  $ServerOnly?: boolean | undefined;
152
151
  }
153
152
  type Accessor<T> = () => T;
@@ -1,4 +1,7 @@
1
1
  type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
2
+ export type ClassList = {
3
+ [k: string]: boolean | undefined;
4
+ };
2
5
  interface Runtime {
3
6
  effect<T>(fn: (prev?: T) => T, init?: T): any;
4
7
  untrack<T>(fn: () => T): T;
@@ -7,13 +10,7 @@ interface Runtime {
7
10
  createComponent(Comp: (props: any) => any, props: any): any;
8
11
  addEventListener(node: Element, name: string, handler: EventListener | EventListenerObject | (EventListenerObject & AddEventListenerOptions), delegate: boolean): void;
9
12
  delegateEvents(eventNames: string[]): void;
10
- classList(node: Element, value: {
11
- [k: string]: boolean;
12
- }, prev?: {
13
- [k: string]: boolean;
14
- }): {
15
- [k: string]: boolean;
16
- };
13
+ classList(node: Element, value: ClassList, prev?: ClassList): ClassList;
17
14
  style(node: Element, value: {
18
15
  [k: string]: string;
19
16
  }, prev?: {
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.9.12",
4
+ "version": "1.9.13",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
@@ -17,11 +17,20 @@ function wrap$1(value) {
17
17
  });
18
18
  if (!Array.isArray(value)) {
19
19
  const keys = Object.keys(value),
20
- desc = Object.getOwnPropertyDescriptors(value);
20
+ desc = Object.getOwnPropertyDescriptors(value),
21
+ proto = Object.getPrototypeOf(value);
22
+ const isClass = proto !== null && value !== null && typeof value === "object" && !Array.isArray(value) && proto !== Object.prototype;
23
+ if (isClass) {
24
+ const descriptors = Object.getOwnPropertyDescriptors(proto);
25
+ keys.push(...Object.keys(descriptors));
26
+ Object.assign(desc, descriptors);
27
+ }
21
28
  for (let i = 0, l = keys.length; i < l; i++) {
22
29
  const prop = keys[i];
30
+ if (isClass && prop === "constructor") continue;
23
31
  if (desc[prop].get) {
24
32
  Object.defineProperty(value, prop, {
33
+ configurable: true,
25
34
  enumerable: desc[prop].enumerable,
26
35
  get: desc[prop].get.bind(p)
27
36
  });
@@ -124,6 +133,10 @@ const proxyTraps$1 = {
124
133
  getOwnPropertyDescriptor: proxyDescriptor$1
125
134
  };
126
135
  function setProperty(state, property, value, deleting = false) {
136
+ if (property === "__proto__") {
137
+ console.warn(`Refusing to set "__proto__" on a store.`);
138
+ return;
139
+ }
127
140
  if (!deleting && state[property] === value) return;
128
141
  const prev = state[property],
129
142
  len = state.length;
@@ -148,9 +161,13 @@ function mergeStoreNode(state, value) {
148
161
  const keys = Object.keys(value);
149
162
  for (let i = 0; i < keys.length; i += 1) {
150
163
  const key = keys[i];
164
+ if (isUnsafeKey$1(key)) continue;
151
165
  setProperty(state, key, value[key]);
152
166
  }
153
167
  }
168
+ function isUnsafeKey$1(property) {
169
+ return property === "__proto__" || property === "constructor" || property === "prototype";
170
+ }
154
171
  function updateArray(current, next) {
155
172
  if (typeof next === "function") next = next(current);
156
173
  next = unwrap(next);
@@ -172,6 +189,10 @@ function updatePath(current, path, traversed = []) {
172
189
  part = path.shift();
173
190
  const partType = typeof part,
174
191
  isArray = Array.isArray(current);
192
+ if (partType === "string" && (part === "__proto__" || path.length > 1 && isUnsafeKey$1(part))) {
193
+ console.warn(`Refusing to traverse unsafe key "${part}" on a store.`);
194
+ return;
195
+ }
175
196
  if (Array.isArray(part)) {
176
197
  for (let i = 0; i < part.length; i++) {
177
198
  updatePath(current, [part[i]].concat(path), traversed);
@@ -329,7 +350,11 @@ function modifyMutable(state, modifier) {
329
350
  }
330
351
 
331
352
  const $ROOT = Symbol("store-root");
353
+ function isUnsafeKey(property) {
354
+ return property === "__proto__" || property === "constructor" || property === "prototype";
355
+ }
332
356
  function applyState(target, parent, property, merge, key) {
357
+ if (isUnsafeKey(property)) return;
333
358
  const previous = parent[property];
334
359
  if (target === previous) return;
335
360
  const isArray = Array.isArray(target);
@@ -391,6 +416,7 @@ function applyState(target, parent, property, merge, key) {
391
416
  }
392
417
  const targetKeys = Object.keys(target);
393
418
  for (let i = 0, len = targetKeys.length; i < len; i++) {
419
+ if (isUnsafeKey(targetKeys[i])) continue;
394
420
  applyState(target[targetKeys[i]], previous, targetKeys[i], merge, key);
395
421
  }
396
422
  const previousKeys = Object.keys(previous);
@@ -417,6 +443,7 @@ const setterTraps = {
417
443
  get(target, property) {
418
444
  if (property === $RAW) return target;
419
445
  const value = target[property];
446
+ if (property === solidJs.$PROXY || property === solidJs.$TRACK || property === $NODE || property === $HAS || property === "__proto__") return value;
420
447
  let proxy;
421
448
  return isWrappable(value) ? producers.get(value) || (producers.set(value, proxy = new Proxy(value, setterTraps)), proxy) : value;
422
449
  },
package/store/dist/dev.js CHANGED
@@ -15,11 +15,20 @@ function wrap$1(value) {
15
15
  });
16
16
  if (!Array.isArray(value)) {
17
17
  const keys = Object.keys(value),
18
- desc = Object.getOwnPropertyDescriptors(value);
18
+ desc = Object.getOwnPropertyDescriptors(value),
19
+ proto = Object.getPrototypeOf(value);
20
+ const isClass = proto !== null && value !== null && typeof value === "object" && !Array.isArray(value) && proto !== Object.prototype;
21
+ if (isClass) {
22
+ const descriptors = Object.getOwnPropertyDescriptors(proto);
23
+ keys.push(...Object.keys(descriptors));
24
+ Object.assign(desc, descriptors);
25
+ }
19
26
  for (let i = 0, l = keys.length; i < l; i++) {
20
27
  const prop = keys[i];
28
+ if (isClass && prop === "constructor") continue;
21
29
  if (desc[prop].get) {
22
30
  Object.defineProperty(value, prop, {
31
+ configurable: true,
23
32
  enumerable: desc[prop].enumerable,
24
33
  get: desc[prop].get.bind(p)
25
34
  });
@@ -122,6 +131,10 @@ const proxyTraps$1 = {
122
131
  getOwnPropertyDescriptor: proxyDescriptor$1
123
132
  };
124
133
  function setProperty(state, property, value, deleting = false) {
134
+ if (property === "__proto__") {
135
+ console.warn(`Refusing to set "__proto__" on a store.`);
136
+ return;
137
+ }
125
138
  if (!deleting && state[property] === value) return;
126
139
  const prev = state[property],
127
140
  len = state.length;
@@ -146,9 +159,13 @@ function mergeStoreNode(state, value) {
146
159
  const keys = Object.keys(value);
147
160
  for (let i = 0; i < keys.length; i += 1) {
148
161
  const key = keys[i];
162
+ if (isUnsafeKey$1(key)) continue;
149
163
  setProperty(state, key, value[key]);
150
164
  }
151
165
  }
166
+ function isUnsafeKey$1(property) {
167
+ return property === "__proto__" || property === "constructor" || property === "prototype";
168
+ }
152
169
  function updateArray(current, next) {
153
170
  if (typeof next === "function") next = next(current);
154
171
  next = unwrap(next);
@@ -170,6 +187,10 @@ function updatePath(current, path, traversed = []) {
170
187
  part = path.shift();
171
188
  const partType = typeof part,
172
189
  isArray = Array.isArray(current);
190
+ if (partType === "string" && (part === "__proto__" || path.length > 1 && isUnsafeKey$1(part))) {
191
+ console.warn(`Refusing to traverse unsafe key "${part}" on a store.`);
192
+ return;
193
+ }
173
194
  if (Array.isArray(part)) {
174
195
  for (let i = 0; i < part.length; i++) {
175
196
  updatePath(current, [part[i]].concat(path), traversed);
@@ -327,7 +348,11 @@ function modifyMutable(state, modifier) {
327
348
  }
328
349
 
329
350
  const $ROOT = Symbol("store-root");
351
+ function isUnsafeKey(property) {
352
+ return property === "__proto__" || property === "constructor" || property === "prototype";
353
+ }
330
354
  function applyState(target, parent, property, merge, key) {
355
+ if (isUnsafeKey(property)) return;
331
356
  const previous = parent[property];
332
357
  if (target === previous) return;
333
358
  const isArray = Array.isArray(target);
@@ -389,6 +414,7 @@ function applyState(target, parent, property, merge, key) {
389
414
  }
390
415
  const targetKeys = Object.keys(target);
391
416
  for (let i = 0, len = targetKeys.length; i < len; i++) {
417
+ if (isUnsafeKey(targetKeys[i])) continue;
392
418
  applyState(target[targetKeys[i]], previous, targetKeys[i], merge, key);
393
419
  }
394
420
  const previousKeys = Object.keys(previous);
@@ -415,6 +441,7 @@ const setterTraps = {
415
441
  get(target, property) {
416
442
  if (property === $RAW) return target;
417
443
  const value = target[property];
444
+ if (property === $PROXY || property === $TRACK || property === $NODE || property === $HAS || property === "__proto__") return value;
418
445
  let proxy;
419
446
  return isWrappable(value) ? producers.get(value) || (producers.set(value, proxy = new Proxy(value, setterTraps)), proxy) : value;
420
447
  },
@@ -8,6 +8,7 @@ function unwrap(item) {
8
8
  return item;
9
9
  }
10
10
  function setProperty(state, property, value, force) {
11
+ if (property === "__proto__") return;
11
12
  if (!force && state[property] === value) return;
12
13
  if (value === undefined) {
13
14
  delete state[property];
@@ -17,9 +18,13 @@ function mergeStoreNode(state, value, force) {
17
18
  const keys = Object.keys(value);
18
19
  for (let i = 0; i < keys.length; i += 1) {
19
20
  const key = keys[i];
21
+ if (isUnsafeKey(key)) continue;
20
22
  setProperty(state, key, value[key], force);
21
23
  }
22
24
  }
25
+ function isUnsafeKey(property) {
26
+ return property === "__proto__" || property === "constructor" || property === "prototype";
27
+ }
23
28
  function updateArray(current, next) {
24
29
  if (typeof next === "function") next = next(current);
25
30
  if (Array.isArray(next)) {
@@ -40,6 +45,7 @@ function updatePath(current, path, traversed = []) {
40
45
  part = path.shift();
41
46
  const partType = typeof part,
42
47
  isArray = Array.isArray(current);
48
+ if (partType === "string" && (part === "__proto__" || path.length > 1 && isUnsafeKey(part))) return;
43
49
  if (Array.isArray(part)) {
44
50
  for (let i = 0; i < part.length; i++) {
45
51
  updatePath(current, [part[i]].concat(path), traversed);
@@ -96,6 +102,7 @@ function reconcile(value, options = {}) {
96
102
  const targetKeys = Object.keys(value);
97
103
  for (let i = 0, len = targetKeys.length; i < len; i++) {
98
104
  const key = targetKeys[i];
105
+ if (isUnsafeKey(key)) continue;
99
106
  setProperty(state, key, value[key]);
100
107
  }
101
108
  const previousKeys = Object.keys(state);
@@ -6,6 +6,7 @@ function unwrap(item) {
6
6
  return item;
7
7
  }
8
8
  function setProperty(state, property, value, force) {
9
+ if (property === "__proto__") return;
9
10
  if (!force && state[property] === value) return;
10
11
  if (value === undefined) {
11
12
  delete state[property];
@@ -15,9 +16,13 @@ function mergeStoreNode(state, value, force) {
15
16
  const keys = Object.keys(value);
16
17
  for (let i = 0; i < keys.length; i += 1) {
17
18
  const key = keys[i];
19
+ if (isUnsafeKey(key)) continue;
18
20
  setProperty(state, key, value[key], force);
19
21
  }
20
22
  }
23
+ function isUnsafeKey(property) {
24
+ return property === "__proto__" || property === "constructor" || property === "prototype";
25
+ }
21
26
  function updateArray(current, next) {
22
27
  if (typeof next === "function") next = next(current);
23
28
  if (Array.isArray(next)) {
@@ -38,6 +43,7 @@ function updatePath(current, path, traversed = []) {
38
43
  part = path.shift();
39
44
  const partType = typeof part,
40
45
  isArray = Array.isArray(current);
46
+ if (partType === "string" && (part === "__proto__" || path.length > 1 && isUnsafeKey(part))) return;
41
47
  if (Array.isArray(part)) {
42
48
  for (let i = 0; i < part.length; i++) {
43
49
  updatePath(current, [part[i]].concat(path), traversed);
@@ -94,6 +100,7 @@ function reconcile(value, options = {}) {
94
100
  const targetKeys = Object.keys(value);
95
101
  for (let i = 0, len = targetKeys.length; i < len; i++) {
96
102
  const key = targetKeys[i];
103
+ if (isUnsafeKey(key)) continue;
97
104
  setProperty(state, key, value[key]);
98
105
  }
99
106
  const previousKeys = Object.keys(state);
@@ -14,11 +14,20 @@ function wrap$1(value) {
14
14
  });
15
15
  if (!Array.isArray(value)) {
16
16
  const keys = Object.keys(value),
17
- desc = Object.getOwnPropertyDescriptors(value);
17
+ desc = Object.getOwnPropertyDescriptors(value),
18
+ proto = Object.getPrototypeOf(value);
19
+ const isClass = proto !== null && value !== null && typeof value === "object" && !Array.isArray(value) && proto !== Object.prototype;
20
+ if (isClass) {
21
+ const descriptors = Object.getOwnPropertyDescriptors(proto);
22
+ keys.push(...Object.keys(descriptors));
23
+ Object.assign(desc, descriptors);
24
+ }
18
25
  for (let i = 0, l = keys.length; i < l; i++) {
19
26
  const prop = keys[i];
27
+ if (isClass && prop === "constructor") continue;
20
28
  if (desc[prop].get) {
21
29
  Object.defineProperty(value, prop, {
30
+ configurable: true,
22
31
  enumerable: desc[prop].enumerable,
23
32
  get: desc[prop].get.bind(p)
24
33
  });
@@ -119,6 +128,9 @@ const proxyTraps$1 = {
119
128
  getOwnPropertyDescriptor: proxyDescriptor$1
120
129
  };
121
130
  function setProperty(state, property, value, deleting = false) {
131
+ if (property === "__proto__") {
132
+ return;
133
+ }
122
134
  if (!deleting && state[property] === value) return;
123
135
  const prev = state[property],
124
136
  len = state.length;
@@ -142,9 +154,13 @@ function mergeStoreNode(state, value) {
142
154
  const keys = Object.keys(value);
143
155
  for (let i = 0; i < keys.length; i += 1) {
144
156
  const key = keys[i];
157
+ if (isUnsafeKey$1(key)) continue;
145
158
  setProperty(state, key, value[key]);
146
159
  }
147
160
  }
161
+ function isUnsafeKey$1(property) {
162
+ return property === "__proto__" || property === "constructor" || property === "prototype";
163
+ }
148
164
  function updateArray(current, next) {
149
165
  if (typeof next === "function") next = next(current);
150
166
  next = unwrap(next);
@@ -166,6 +182,9 @@ function updatePath(current, path, traversed = []) {
166
182
  part = path.shift();
167
183
  const partType = typeof part,
168
184
  isArray = Array.isArray(current);
185
+ if (partType === "string" && (part === "__proto__" || path.length > 1 && isUnsafeKey$1(part))) {
186
+ return;
187
+ }
169
188
  if (Array.isArray(part)) {
170
189
  for (let i = 0; i < part.length; i++) {
171
190
  updatePath(current, [part[i]].concat(path), traversed);
@@ -313,7 +332,11 @@ function modifyMutable(state, modifier) {
313
332
  }
314
333
 
315
334
  const $ROOT = Symbol("store-root");
335
+ function isUnsafeKey(property) {
336
+ return property === "__proto__" || property === "constructor" || property === "prototype";
337
+ }
316
338
  function applyState(target, parent, property, merge, key) {
339
+ if (isUnsafeKey(property)) return;
317
340
  const previous = parent[property];
318
341
  if (target === previous) return;
319
342
  const isArray = Array.isArray(target);
@@ -375,6 +398,7 @@ function applyState(target, parent, property, merge, key) {
375
398
  }
376
399
  const targetKeys = Object.keys(target);
377
400
  for (let i = 0, len = targetKeys.length; i < len; i++) {
401
+ if (isUnsafeKey(targetKeys[i])) continue;
378
402
  applyState(target[targetKeys[i]], previous, targetKeys[i], merge, key);
379
403
  }
380
404
  const previousKeys = Object.keys(previous);
@@ -401,6 +425,7 @@ const setterTraps = {
401
425
  get(target, property) {
402
426
  if (property === $RAW) return target;
403
427
  const value = target[property];
428
+ if (property === solidJs.$PROXY || property === solidJs.$TRACK || property === $NODE || property === $HAS || property === "__proto__") return value;
404
429
  let proxy;
405
430
  return isWrappable(value) ? producers.get(value) || (producers.set(value, proxy = new Proxy(value, setterTraps)), proxy) : value;
406
431
  },
@@ -12,11 +12,20 @@ function wrap$1(value) {
12
12
  });
13
13
  if (!Array.isArray(value)) {
14
14
  const keys = Object.keys(value),
15
- desc = Object.getOwnPropertyDescriptors(value);
15
+ desc = Object.getOwnPropertyDescriptors(value),
16
+ proto = Object.getPrototypeOf(value);
17
+ const isClass = proto !== null && value !== null && typeof value === "object" && !Array.isArray(value) && proto !== Object.prototype;
18
+ if (isClass) {
19
+ const descriptors = Object.getOwnPropertyDescriptors(proto);
20
+ keys.push(...Object.keys(descriptors));
21
+ Object.assign(desc, descriptors);
22
+ }
16
23
  for (let i = 0, l = keys.length; i < l; i++) {
17
24
  const prop = keys[i];
25
+ if (isClass && prop === "constructor") continue;
18
26
  if (desc[prop].get) {
19
27
  Object.defineProperty(value, prop, {
28
+ configurable: true,
20
29
  enumerable: desc[prop].enumerable,
21
30
  get: desc[prop].get.bind(p)
22
31
  });
@@ -117,6 +126,9 @@ const proxyTraps$1 = {
117
126
  getOwnPropertyDescriptor: proxyDescriptor$1
118
127
  };
119
128
  function setProperty(state, property, value, deleting = false) {
129
+ if (property === "__proto__") {
130
+ return;
131
+ }
120
132
  if (!deleting && state[property] === value) return;
121
133
  const prev = state[property],
122
134
  len = state.length;
@@ -140,9 +152,13 @@ function mergeStoreNode(state, value) {
140
152
  const keys = Object.keys(value);
141
153
  for (let i = 0; i < keys.length; i += 1) {
142
154
  const key = keys[i];
155
+ if (isUnsafeKey$1(key)) continue;
143
156
  setProperty(state, key, value[key]);
144
157
  }
145
158
  }
159
+ function isUnsafeKey$1(property) {
160
+ return property === "__proto__" || property === "constructor" || property === "prototype";
161
+ }
146
162
  function updateArray(current, next) {
147
163
  if (typeof next === "function") next = next(current);
148
164
  next = unwrap(next);
@@ -164,6 +180,9 @@ function updatePath(current, path, traversed = []) {
164
180
  part = path.shift();
165
181
  const partType = typeof part,
166
182
  isArray = Array.isArray(current);
183
+ if (partType === "string" && (part === "__proto__" || path.length > 1 && isUnsafeKey$1(part))) {
184
+ return;
185
+ }
167
186
  if (Array.isArray(part)) {
168
187
  for (let i = 0; i < part.length; i++) {
169
188
  updatePath(current, [part[i]].concat(path), traversed);
@@ -311,7 +330,11 @@ function modifyMutable(state, modifier) {
311
330
  }
312
331
 
313
332
  const $ROOT = Symbol("store-root");
333
+ function isUnsafeKey(property) {
334
+ return property === "__proto__" || property === "constructor" || property === "prototype";
335
+ }
314
336
  function applyState(target, parent, property, merge, key) {
337
+ if (isUnsafeKey(property)) return;
315
338
  const previous = parent[property];
316
339
  if (target === previous) return;
317
340
  const isArray = Array.isArray(target);
@@ -373,6 +396,7 @@ function applyState(target, parent, property, merge, key) {
373
396
  }
374
397
  const targetKeys = Object.keys(target);
375
398
  for (let i = 0, len = targetKeys.length; i < len; i++) {
399
+ if (isUnsafeKey(targetKeys[i])) continue;
376
400
  applyState(target[targetKeys[i]], previous, targetKeys[i], merge, key);
377
401
  }
378
402
  const previousKeys = Object.keys(previous);
@@ -399,6 +423,7 @@ const setterTraps = {
399
423
  get(target, property) {
400
424
  if (property === $RAW) return target;
401
425
  const value = target[property];
426
+ if (property === $PROXY || property === $TRACK || property === $NODE || property === $HAS || property === "__proto__") return value;
402
427
  let proxy;
403
428
  return isWrappable(value) ? producers.get(value) || (producers.set(value, proxy = new Proxy(value, setterTraps)), proxy) : value;
404
429
  },
@@ -1,5 +1,5 @@
1
1
  export { $RAW, createStore, unwrap } from "./store.js";
2
- export type { ArrayFilterFn, DeepMutable, DeepReadonly, NotWrappable, Part, SetStoreFunction, SolidStore, Store, StoreNode, StorePathRange, StoreSetter } from "./store.js";
2
+ export type { ArrayFilterFn, DeepMutable, DeepReadonly, NotWrappable, Part, SetStoreFunction, SolidStore, Store, StoreNode, StoreReturn, StorePathRange, StoreSetter } from "./store.js";
3
3
  export * from "./mutable.js";
4
4
  export * from "./modifiers.js";
5
5
  import { $NODE, isWrappable } from "./store.js";
@@ -1,11 +1,11 @@
1
- import type { SetStoreFunction, Store } from "./store.js";
2
- export type { ArrayFilterFn, DeepMutable, DeepReadonly, NotWrappable, Part, SetStoreFunction, SolidStore, Store, StoreNode, StorePathRange, StoreSetter } from "./store.js";
1
+ import type { Store, StoreReturn } from "./store.js";
2
+ export type { ArrayFilterFn, DeepMutable, DeepReadonly, NotWrappable, Part, SetStoreFunction, SolidStore, Store, StoreNode, StoreReturn, StorePathRange, StoreSetter } from "./store.js";
3
3
  export declare const $RAW: unique symbol;
4
4
  export declare function isWrappable(obj: any): boolean;
5
5
  export declare function unwrap<T>(item: T): T;
6
6
  export declare function setProperty(state: any, property: PropertyKey, value: any, force?: boolean): void;
7
7
  export declare function updatePath(current: any, path: any[], traversed?: PropertyKey[]): void;
8
- export declare function createStore<T>(state: T | Store<T>): [Store<T>, SetStoreFunction<T>];
8
+ export declare function createStore<T>(state: T | Store<T>): StoreReturn<T>;
9
9
  export declare function createMutable<T>(state: T | Store<T>): T;
10
10
  export declare function modifyMutable<T>(state: T, modifier: (state: T) => T): void;
11
11
  type ReconcileOptions = {
@@ -94,6 +94,7 @@ export interface SetStoreFunction<T> {
94
94
  (setter: StoreSetter<T, []>): void;
95
95
  <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;
96
96
  }
97
+ export type StoreReturn<T> = [get: Store<T>, set: SetStoreFunction<T>];
97
98
  /**
98
99
  * Creates a reactive store that can be read through a proxy object and written with a setter function
99
100
  *
@@ -103,5 +104,5 @@ export declare function createStore<T extends object = {}>(...[store, options]:
103
104
  name?: string;
104
105
  }] : [store: T | Store<T>, options?: {
105
106
  name?: string;
106
- }]): [get: Store<T>, set: SetStoreFunction<T>];
107
+ }]): StoreReturn<T>;
107
108
  export {};
package/types/jsx.d.ts CHANGED
@@ -137,14 +137,13 @@ export namespace JSX {
137
137
  interface IntrinsicAttributes {
138
138
  ref?: unknown | ((e: unknown) => void) | undefined;
139
139
  }
140
+ export type ClassList = {
141
+ [k: string]: boolean | undefined;
142
+ };
140
143
  interface CustomAttributes<T> {
141
144
  ref?: T | ((el: T) => void) | undefined;
142
145
  children?: Element | undefined;
143
- classList?:
144
- | {
145
- [k: string]: boolean | undefined;
146
- }
147
- | undefined;
146
+ classList?: ClassList | undefined;
148
147
  $ServerOnly?: boolean | undefined;
149
148
  }
150
149
  type Accessor<T> = () => T;
@@ -328,9 +328,13 @@ export type InitializedResourceReturn<T, R = unknown> = [
328
328
  *
329
329
  * @description https://docs.solidjs.com/reference/basic-reactivity/create-resource
330
330
  */
331
- export declare function createResource<T, R = unknown>(fetcher: ResourceFetcher<true, T, R>, options: InitializedResourceOptions<NoInfer<T>, true>): InitializedResourceReturn<T, R>;
331
+ export declare function createResource<T, R = unknown, I = T>(fetcher: (k: true, info: ResourceFetcherInfo<T | I, R>) => T | Promise<T>, options: ResourceOptions<T | I, true> & {
332
+ initialValue: I;
333
+ }): InitializedResourceReturn<T | I, R>;
332
334
  export declare function createResource<T, R = unknown>(fetcher: ResourceFetcher<true, T, R>, options?: ResourceOptions<NoInfer<T>, true>): ResourceReturn<T, R>;
333
- export declare function createResource<T, S, R = unknown>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T, R>, options: InitializedResourceOptions<NoInfer<T>, S>): InitializedResourceReturn<T, R>;
335
+ export declare function createResource<T, S, R = unknown, I = T>(source: ResourceSource<S>, fetcher: (k: S, info: ResourceFetcherInfo<T | I, R>) => T | Promise<T>, options: ResourceOptions<T | I, S> & {
336
+ initialValue: I;
337
+ }): InitializedResourceReturn<T | I, R>;
334
338
  export declare function createResource<T, S, R = unknown>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T, R>, options?: ResourceOptions<NoInfer<T>, S>): ResourceReturn<T, R>;
335
339
  export interface DeferredOptions<T> {
336
340
  equals?: false | ((prev: T, next: T) => boolean);
@@ -850,6 +850,7 @@ exports.addEventListener = notSup;
850
850
  exports.assign = notSup;
851
851
  exports.classList = notSup;
852
852
  exports.className = notSup;
853
+ exports.clearDelegatedEvents = notSup;
853
854
  exports.createDynamic = createDynamic;
854
855
  exports.delegateEvents = notSup;
855
856
  exports.dynamicProperty = notSup;
@@ -877,7 +878,9 @@ exports.resolveSSRNode = resolveSSRNode;
877
878
  exports.runHydrationEvents = notSup;
878
879
  exports.setAttribute = notSup;
879
880
  exports.setAttributeNS = notSup;
881
+ exports.setBoolAttribute = notSup;
880
882
  exports.setProperty = notSup;
883
+ exports.setStyleProperty = notSup;
881
884
  exports.spread = notSup;
882
885
  exports.ssr = ssr;
883
886
  exports.ssrAttribute = ssrAttribute;
@@ -889,4 +892,5 @@ exports.ssrStyle = ssrStyle;
889
892
  exports.ssrStyleProperty = ssrStyleProperty;
890
893
  exports.style = notSup;
891
894
  exports.template = notSup;
895
+ exports.use = notSup;
892
896
  exports.useAssets = useAssets;
@@ -779,4 +779,4 @@ function Portal(props) {
779
779
  return "";
780
780
  }
781
781
 
782
- export { Aliases, Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, Hydration, HydrationScript, NoHydration, Portal, Properties, RequestContext, SVGElements, SVGNamespace, notSup as addEventListener, notSup as assign, notSup as classList, notSup as className, createDynamic, notSup as delegateEvents, notSup as dynamicProperty, escape, generateHydrationScript, getAssets, getHydrationKey, notSup as getNextElement, notSup as getNextMarker, notSup as getNextMatch, getPropAlias, getRequestEvent, notSup as hydrate, notSup as insert, isDev, isServer, memo, pipeToNodeWritable, pipeToWritable, notSup as render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, notSup as runHydrationEvents, notSup as setAttribute, notSup as setAttributeNS, notSup as setProperty, notSup as spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrSpread, ssrStyle, ssrStyleProperty, notSup as style, notSup as template, useAssets };
782
+ export { Aliases, Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, Hydration, HydrationScript, NoHydration, Portal, Properties, RequestContext, SVGElements, SVGNamespace, notSup as addEventListener, notSup as assign, notSup as classList, notSup as className, notSup as clearDelegatedEvents, createDynamic, notSup as delegateEvents, notSup as dynamicProperty, escape, generateHydrationScript, getAssets, getHydrationKey, notSup as getNextElement, notSup as getNextMarker, notSup as getNextMatch, getPropAlias, getRequestEvent, notSup as hydrate, notSup as insert, isDev, isServer, memo, pipeToNodeWritable, pipeToWritable, notSup as render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, notSup as runHydrationEvents, notSup as setAttribute, notSup as setAttributeNS, notSup as setBoolAttribute, notSup as setProperty, notSup as setStyleProperty, notSup as spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrSpread, ssrStyle, ssrStyleProperty, notSup as style, notSup as template, notSup as use, useAssets };
@@ -56,9 +56,9 @@ export function addEventListener(
56
56
  ): void;
57
57
  export function classList(
58
58
  node: Element,
59
- value: { [k: string]: boolean },
60
- prev?: { [k: string]: boolean }
61
- ): { [k: string]: boolean };
59
+ value: JSX.ClassList,
60
+ prev?: JSX.ClassList
61
+ ): JSX.ClassList;
62
62
  export function style(
63
63
  node: Element,
64
64
  value: { [k: string]: string },
@@ -50,7 +50,7 @@ export function ssrElement(
50
50
  children: any,
51
51
  needsId: boolean
52
52
  ): { t: string };
53
- export function ssrClassList(value: { [k: string]: boolean }): string;
53
+ export function ssrClassList(value: JSX.ClassList): string;
54
54
  export function ssrStyle(value: { [k: string]: string }): string;
55
55
  export function ssrAttribute(key: string, value: any, isBoolean: boolean): string;
56
56
  export function ssrHydrationKey(): string;
@@ -107,9 +107,9 @@ export function untrack<T>(fn: () => T): T;
107
107
  /** @deprecated not supported on the server side */
108
108
  export function classList(
109
109
  node: Element,
110
- value: { [k: string]: boolean },
111
- prev?: { [k: string]: boolean }
112
- ): { [k: string]: boolean };
110
+ value: JSX.ClassList,
111
+ prev?: JSX.ClassList
112
+ ): JSX.ClassList;
113
113
 
114
114
  /** @deprecated not supported on the server side */
115
115
  export function style(
@@ -175,3 +175,13 @@ export function getNextElement(template?: HTMLTemplateElement): Element;
175
175
  export function getNextMatch(start: Node, elementName: string): Element;
176
176
  /** @deprecated not supported on the server side */
177
177
  export function getNextMarker(start: Node): [Node, Array<Node>];
178
+ /** @deprecated not supported on the server side */
179
+ export function runHydrationEvents(): void;
180
+ /** @deprecated not supported on the server side */
181
+ export function use<Arg, Ret>(fn: (node: Element, arg: Arg) => Ret, node: Element, arg?: Arg): Ret;
182
+ /** @deprecated not supported on the server side */
183
+ export function setBoolAttribute(node: Element, name: string, value: any): void;
184
+ /** @deprecated not supported on the server side */
185
+ export function setStyleProperty(node: Element, name: string, value: any): void;
186
+ /** @deprecated not supported on the server side */
187
+ export function clearDelegatedEvents(d?: Document): void;