@solidjs/signals 2.0.0-beta.24 → 2.0.0-beta.26

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.
@@ -14,14 +14,21 @@ import { CONFIG_AUTO_DISPOSE } from "../core/constants.js";
14
14
 
15
15
  import { reconcile } from "./reconcile.js";
16
16
 
17
- import { storeSetter, $TARGET, STORE_WRAP, createStoreProxy, storeTraps, setWriteOverride, STORE_LOOKUP, STORE_FIREWALL } from "./store.js";
17
+ import { storeSetter, $TARGET, STORE_WRAP, createStoreProxy, storeTraps, setWriteOverride, STORE_LOOKUP, STORE_SHALLOW, markRawIngest, STORE_VALUE, STORE_FIREWALL } from "./store.js";
18
18
 
19
19
  function createProjectionInternal(e, r, t) {
20
20
  let o;
21
- const i = new WeakMap;
21
+ const n = new WeakMap;
22
+ // A shallow projection's children are raw and never wrapped, so the
23
+ // wrapper only ever runs for the root — flagging unconditionally is safe.
24
+ const i = !!t?.shallow;
22
25
  const wrapper = e => {
23
26
  e[STORE_WRAP] = wrapProjection;
24
- e[STORE_LOOKUP] = i;
27
+ e[STORE_LOOKUP] = n;
28
+ if (i) {
29
+ e[STORE_SHALLOW] = true;
30
+ markRawIngest(e[STORE_VALUE]);
31
+ }
25
32
  Object.defineProperty(e, STORE_FIREWALL, {
26
33
  get() {
27
34
  return o;
@@ -30,20 +37,20 @@ function createProjectionInternal(e, r, t) {
30
37
  });
31
38
  };
32
39
  const wrapProjection = e => {
33
- if (i.has(e)) return i.get(e);
40
+ if (n.has(e)) return n.get(e);
34
41
  if (e[$TARGET]?.[STORE_WRAP] === wrapProjection) return e;
35
42
  const r = createStoreProxy(e, storeTraps, wrapper);
36
- i.set(e, r);
43
+ n.set(e, r);
37
44
  return r;
38
45
  };
39
- const n = wrapProjection(r);
46
+ const c = wrapProjection(r);
40
47
  o = computed(() => {
41
48
  if (!o) o = getOwner();
42
- runProjectionComputed(n, e, t?.key || "id");
49
+ runProjectionComputed(c, e, t?.key || "id");
43
50
  }, undefined);
44
51
  o.T &= ~CONFIG_AUTO_DISPOSE;
45
52
  return {
46
- store: n,
53
+ store: c,
47
54
  node: o
48
55
  };
49
56
  }
@@ -106,22 +113,22 @@ function createProjectionInternal(e, r, t) {
106
113
  * re-enters `setProjectionWriteActive` so reconciles target `STORE_OVERRIDE`
107
114
  * instead of `STORE_OPTIMISTIC_OVERRIDE` even when an async yield fires outside
108
115
  * the outer `setProjectionWriteActive` scope.
109
- */ function runProjectionComputed(e, r, t, o, i) {
110
- const n = getOwner();
116
+ */ function runProjectionComputed(e, r, t, o, n) {
117
+ const i = getOwner();
111
118
  let c = false;
112
119
  let s;
113
- const u = new Proxy(e, createWriteTraps(() => !c || n.Te === s, i));
114
- storeSetter(u, i => {
115
- s = r(i);
120
+ const u = new Proxy(e, createWriteTraps(() => !c || i.Te === s, n));
121
+ storeSetter(u, n => {
122
+ s = r(n);
116
123
  c = true;
117
124
  const commit = r => {
118
- if (r === i || r === undefined) return;
125
+ if (r === n || r === undefined) return;
119
126
  const write = () => storeSetter(e, reconcile(r, t));
120
127
  o ? o(write) : write();
121
128
  };
122
- commit(handleAsync(n, s, commit));
129
+ commit(handleAsync(i, s, commit));
123
130
  });
124
- return n;
131
+ return i;
125
132
  }
126
133
 
127
134
  function createWriteTraps(e, r) {
@@ -151,12 +158,12 @@ function createWriteTraps(e, r) {
151
158
  }
152
159
  return t;
153
160
  },
154
- set(t, o, i) {
161
+ set(t, o, n) {
155
162
  if (e && !e()) return true;
156
163
  setWriteOverride(true);
157
164
  setProjectionWriteActive(true);
158
165
  try {
159
- t[o] = i;
166
+ t[o] = n;
160
167
  r?.();
161
168
  } finally {
162
169
  setWriteOverride(false);