@solidjs/signals 0.0.2 → 0.0.3
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.js +37 -24
- package/dist/node.cjs +188 -174
- package/dist/prod.js +188 -175
- package/dist/types/core/index.d.ts +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/map.d.ts +5 -4
- package/dist/types/signals.d.ts +31 -14
- package/dist/types/store/index.d.ts +1 -1
- package/dist/types/store/reconcile.d.ts +1 -1
- package/package.json +7 -2
package/dist/dev.js
CHANGED
|
@@ -852,15 +852,22 @@ var STORE_NODE = "n";
|
|
|
852
852
|
var STORE_HAS = "h";
|
|
853
853
|
function wrap(value) {
|
|
854
854
|
let p = value[$PROXY];
|
|
855
|
-
if (!p)
|
|
855
|
+
if (!p) {
|
|
856
|
+
let target;
|
|
857
|
+
if (Array.isArray(value)) {
|
|
858
|
+
target = [];
|
|
859
|
+
target.v = value;
|
|
860
|
+
} else
|
|
861
|
+
target = { v: value };
|
|
856
862
|
Object.defineProperty(value, $PROXY, {
|
|
857
|
-
value: p = new Proxy(
|
|
863
|
+
value: p = new Proxy(target, proxyTraps),
|
|
858
864
|
writable: true
|
|
859
865
|
});
|
|
866
|
+
}
|
|
860
867
|
return p;
|
|
861
868
|
}
|
|
862
869
|
function isWrappable(obj) {
|
|
863
|
-
return obj != null && typeof obj === "object";
|
|
870
|
+
return obj != null && typeof obj === "object" && !Object.isFrozen(obj);
|
|
864
871
|
}
|
|
865
872
|
function unwrap(item, deep = true, set) {
|
|
866
873
|
let result, unwrapped, v, prop;
|
|
@@ -912,8 +919,10 @@ function getNode(nodes, property, value, equals = isEqual) {
|
|
|
912
919
|
});
|
|
913
920
|
}
|
|
914
921
|
function proxyDescriptor(target, property) {
|
|
922
|
+
if (property === $PROXY)
|
|
923
|
+
return { value: target[$PROXY], writable: true, configurable: true };
|
|
915
924
|
const desc = Reflect.getOwnPropertyDescriptor(target[STORE_VALUE], property);
|
|
916
|
-
if (!desc || desc.get || !desc.configurable
|
|
925
|
+
if (!desc || desc.get || !desc.configurable)
|
|
917
926
|
return desc;
|
|
918
927
|
delete desc.value;
|
|
919
928
|
delete desc.writable;
|
|
@@ -979,7 +988,10 @@ var proxyTraps = {
|
|
|
979
988
|
return true;
|
|
980
989
|
},
|
|
981
990
|
ownKeys,
|
|
982
|
-
getOwnPropertyDescriptor: proxyDescriptor
|
|
991
|
+
getOwnPropertyDescriptor: proxyDescriptor,
|
|
992
|
+
getPrototypeOf(target) {
|
|
993
|
+
return Object.getPrototypeOf(target[STORE_VALUE]);
|
|
994
|
+
}
|
|
983
995
|
};
|
|
984
996
|
function setProperty(state, property, value, deleting = false) {
|
|
985
997
|
const prev = state[property];
|
|
@@ -1133,6 +1145,7 @@ function reconcile(value, key) {
|
|
|
1133
1145
|
if (keyFn(value) !== keyFn(state))
|
|
1134
1146
|
throw new Error("Cannot reconcile states with different identity");
|
|
1135
1147
|
applyState(value, state, keyFn);
|
|
1148
|
+
return state;
|
|
1136
1149
|
};
|
|
1137
1150
|
}
|
|
1138
1151
|
|
|
@@ -1287,24 +1300,19 @@ function omit(props, ...keys) {
|
|
|
1287
1300
|
// src/map.ts
|
|
1288
1301
|
function mapArray(list, map, options) {
|
|
1289
1302
|
const keyFn = typeof options?.keyed === "function" ? options.keyed : void 0;
|
|
1290
|
-
return
|
|
1291
|
-
new
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
_indexes: map.length > 1 ? [] : void 0
|
|
1304
|
-
}),
|
|
1305
|
-
options
|
|
1306
|
-
)
|
|
1307
|
-
);
|
|
1303
|
+
return updateKeyedMap.bind({
|
|
1304
|
+
_owner: new Owner(),
|
|
1305
|
+
_len: 0,
|
|
1306
|
+
_list: list,
|
|
1307
|
+
_items: [],
|
|
1308
|
+
_map: map,
|
|
1309
|
+
_mappings: [],
|
|
1310
|
+
_nodes: [],
|
|
1311
|
+
_key: keyFn,
|
|
1312
|
+
_rows: keyFn || options?.keyed === false ? [] : void 0,
|
|
1313
|
+
_indexes: map.length > 1 ? [] : void 0,
|
|
1314
|
+
_fallback: options?.fallback
|
|
1315
|
+
});
|
|
1308
1316
|
}
|
|
1309
1317
|
function updateKeyedMap() {
|
|
1310
1318
|
const newItems = this._list() || [], newLen = newItems.length;
|
|
@@ -1335,7 +1343,12 @@ function updateKeyedMap() {
|
|
|
1335
1343
|
this._rows && (this._rows = []);
|
|
1336
1344
|
this._indexes && (this._indexes = []);
|
|
1337
1345
|
}
|
|
1346
|
+
if (this._fallback && !this._mappings[0]) {
|
|
1347
|
+
this._mappings[0] = compute(this._nodes[0] = new Owner(), this._fallback, null);
|
|
1348
|
+
}
|
|
1338
1349
|
} else if (this._len === 0) {
|
|
1350
|
+
if (this._nodes[0])
|
|
1351
|
+
this._nodes[0].dispose();
|
|
1339
1352
|
this._mappings = new Array(newLen);
|
|
1340
1353
|
for (j = 0; j < newLen; j++) {
|
|
1341
1354
|
this._items[j] = newItems[j];
|
|
@@ -1403,4 +1416,4 @@ function compare(key, a, b) {
|
|
|
1403
1416
|
return key ? key(a) === key(b) : true;
|
|
1404
1417
|
}
|
|
1405
1418
|
|
|
1406
|
-
export { $PROXY, $RAW, $TARGET, $TRACK, Computation, ContextNotFoundError, NoOwnerError, NotReadyError, Owner, Queue, catchError, createAsync, createBoundary, createContext, createEffect, createMemo, createProjection, createRenderEffect, createRoot, createSignal, createStore, createSuspense, flushSync, getContext, getObserver, getOwner, hasContext, hasUpdated, isEqual, isPending, isWrappable, latest, mapArray, merge, omit, onCleanup, reconcile, runWithOwner, setContext, untrack, unwrap };
|
|
1419
|
+
export { $PROXY, $RAW, $TARGET, $TRACK, Computation, ContextNotFoundError, NoOwnerError, NotReadyError, Owner, Queue, SUPPORTS_PROXY, catchError, createAsync, createBoundary, createContext, createEffect, createMemo, createProjection, createRenderEffect, createRoot, createSignal, createStore, createSuspense, flushSync, getContext, getObserver, getOwner, hasContext, hasUpdated, isEqual, isPending, isWrappable, latest, mapArray, merge, omit, onCleanup, reconcile, runWithOwner, setContext, untrack, unwrap };
|