@ng-org/alien-deepsignals 0.1.2-alpha.11 → 0.1.2-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.d.ts +5 -1
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +11 -11
- package/dist/deepSignal.d.ts +1 -1
- package/dist/deepSignal.d.ts.map +1 -1
- package/dist/deepSignal.js +16 -27
- package/dist/hooks/react/index.js +2 -8
- package/dist/hooks/react/useDeepSignal.d.ts +2 -2
- package/dist/hooks/react/useDeepSignal.d.ts.map +1 -1
- package/dist/hooks/react/useDeepSignal.js +11 -13
- package/dist/hooks/svelte/index.js +2 -8
- package/dist/hooks/svelte/useDeepSignal.svelte.d.ts +1 -1
- package/dist/hooks/svelte/useDeepSignal.svelte.d.ts.map +1 -1
- package/dist/hooks/svelte/useDeepSignal.svelte.js +6 -9
- package/dist/hooks/svelte4/index.js +2 -8
- package/dist/hooks/svelte4/useDeepSignal.svelte.d.ts +1 -1
- package/dist/hooks/svelte4/useDeepSignal.svelte.d.ts.map +1 -1
- package/dist/hooks/svelte4/useDeepSignal.svelte.js +14 -17
- package/dist/hooks/vue/index.d.ts +1 -1
- package/dist/hooks/vue/index.d.ts.map +1 -1
- package/dist/hooks/vue/index.js +2 -8
- package/dist/hooks/vue/useDeepSignal.d.ts +1 -1
- package/dist/hooks/vue/useDeepSignal.d.ts.map +1 -1
- package/dist/hooks/vue/useDeepSignal.js +6 -9
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -27
- package/dist/iteratorHelpers.js +2 -6
- package/dist/test/frontend/astro-app/src/components/ReactPanel.d.ts.map +1 -1
- package/dist/test/frontend/astro-app/src/components/ReactPanel.jsx +13 -51
- package/dist/test/frontend/playwright/crossFrameworkHooks.spec.js +24 -26
- package/dist/test/frontend/utils/mockData.js +16 -21
- package/dist/test/frontend/utils/paths.js +2 -6
- package/dist/test/frontend/utils/renderMetrics.js +5 -12
- package/dist/test/frontend/utils/state.d.ts +1 -1
- package/dist/test/frontend/utils/state.js +13 -17
- package/dist/test/lib/deepSignalOptions.test.js +66 -68
- package/dist/test/lib/index.test.js +373 -375
- package/dist/test/lib/misc.test.js +98 -100
- package/dist/test/lib/watch.test.js +355 -357
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -2
- package/dist/watch.d.ts +1 -1
- package/dist/watch.d.ts.map +1 -1
- package/dist/watch.js +6 -9
- package/package.json +2 -1
package/dist/core.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computed as alienComputed, signal as alienSignal_, effect as alienEffect } from "alien-signals";
|
|
1
|
+
import { computed as alienComputed, signal as alienSignal_, effect as alienEffect, effectScope as alienEffectScope } from "alien-signals";
|
|
2
2
|
/**
|
|
3
3
|
* Execute multiple signal writes in a single batched update frame.
|
|
4
4
|
* All downstream computed/effect re-evaluations are deferred until the function exits.
|
|
@@ -78,4 +78,8 @@ export declare const alienSignal: typeof alienSignal_;
|
|
|
78
78
|
*
|
|
79
79
|
*/
|
|
80
80
|
export declare const effect: typeof alienEffect;
|
|
81
|
+
/**
|
|
82
|
+
* Re-export of alien-signals [effectScope function](https://github.com/stackblitz/alien-signals#effect-scope).
|
|
83
|
+
*/
|
|
84
|
+
export declare const effectScope: typeof alienEffectScope;
|
|
81
85
|
//# sourceMappingURL=core.d.ts.map
|
package/dist/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAUA,OAAO,EAGH,QAAQ,IAAI,aAAa,EACzB,MAAM,IAAI,YAAY,EACtB,MAAM,IAAI,WAAW,
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAUA,OAAO,EAGH,QAAQ,IAAI,aAAa,EACzB,MAAM,IAAI,YAAY,EACtB,MAAM,IAAI,WAAW,EACrB,WAAW,IAAI,gBAAgB,EAClC,MAAM,eAAe,CAAC;AAEvB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAOvC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,eAAO,MAAM,QAAQ,sBAAgB,CAAC;AAEtC;;GAEG;AACH,eAAO,MAAM,WAAW,qBAAe,CAAC;AAExC;;;;;GAKG;AACH,eAAO,MAAM,MAAM,oBAAc,CAAC;AAElC;;GAEG;AACH,eAAO,MAAM,WAAW,yBAAmB,CAAC"}
|
package/dist/core.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright (c) 2025 Laurin Weger, Par le Peuple, NextGraph.org developers
|
|
3
2
|
// All rights reserved.
|
|
4
3
|
// Licensed under the Apache License, Version 2.0
|
|
@@ -8,10 +7,7 @@
|
|
|
8
7
|
// notice may not be copied, modified, or distributed except
|
|
9
8
|
// according to those terms.
|
|
10
9
|
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
11
|
-
|
|
12
|
-
exports.effect = exports.alienSignal = exports.computed = void 0;
|
|
13
|
-
exports.batch = batch;
|
|
14
|
-
const alien_signals_1 = require("alien-signals");
|
|
10
|
+
import { startBatch as alienStartBatch, endBatch as alienEndBatch, computed as alienComputed, signal as alienSignal_, effect as alienEffect, effectScope as alienEffectScope, } from "alien-signals";
|
|
15
11
|
/**
|
|
16
12
|
* Execute multiple signal writes in a single batched update frame.
|
|
17
13
|
* All downstream computed/effect re-evaluations are deferred until the function exits.
|
|
@@ -27,13 +23,13 @@ const alien_signals_1 = require("alien-signals");
|
|
|
27
23
|
* }); // effects observing both run only once
|
|
28
24
|
* ```
|
|
29
25
|
*/
|
|
30
|
-
function batch(fn) {
|
|
31
|
-
(
|
|
26
|
+
export function batch(fn) {
|
|
27
|
+
alienStartBatch();
|
|
32
28
|
try {
|
|
33
29
|
return fn();
|
|
34
30
|
}
|
|
35
31
|
finally {
|
|
36
|
-
(
|
|
32
|
+
alienEndBatch();
|
|
37
33
|
}
|
|
38
34
|
}
|
|
39
35
|
/**
|
|
@@ -87,15 +83,19 @@ function batch(fn) {
|
|
|
87
83
|
*
|
|
88
84
|
* ```
|
|
89
85
|
*/
|
|
90
|
-
|
|
86
|
+
export const computed = alienComputed;
|
|
91
87
|
/**
|
|
92
88
|
* Re-export of alien-signals `signal` function which creates a basic signal.
|
|
93
89
|
*/
|
|
94
|
-
|
|
90
|
+
export const alienSignal = alienSignal_;
|
|
95
91
|
/**
|
|
96
92
|
* Re-export of alien-signals effect function.
|
|
97
93
|
*
|
|
98
94
|
* Callback reruns on every signal modification that is used within its callback.
|
|
99
95
|
*
|
|
100
96
|
*/
|
|
101
|
-
|
|
97
|
+
export const effect = alienEffect;
|
|
98
|
+
/**
|
|
99
|
+
* Re-export of alien-signals [effectScope function](https://github.com/stackblitz/alien-signals#effect-scope).
|
|
100
|
+
*/
|
|
101
|
+
export const effectScope = alienEffectScope;
|
package/dist/deepSignal.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DeepPatchJITSubscriber, DeepPatchSubscriber, DeepSignal, DeepSignalOptions } from "./types";
|
|
1
|
+
import { DeepPatchJITSubscriber, DeepPatchSubscriber, DeepSignal, DeepSignalOptions } from "./types.ts";
|
|
2
2
|
/** Runtime guard that checks whether a value is a deepSignal proxy. */
|
|
3
3
|
export declare function isDeepSignal(value: unknown): value is DeepSignal<any>;
|
|
4
4
|
/**
|
package/dist/deepSignal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepSignal.d.ts","sourceRoot":"","sources":["../src/deepSignal.ts"],"names":[],"mappings":"AAWA,OAAO,EAGH,sBAAsB,EACtB,mBAAmB,EACnB,UAAU,EACV,iBAAiB,EAMpB,MAAM,
|
|
1
|
+
{"version":3,"file":"deepSignal.d.ts","sourceRoot":"","sources":["../src/deepSignal.ts"],"names":[],"mappings":"AAWA,OAAO,EAGH,sBAAsB,EACtB,mBAAmB,EACnB,UAAU,EACV,iBAAiB,EAMpB,MAAM,YAAY,CAAC;AAywCpB,uEAAuE;AACvE,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAAC,GAAG,CAAC,CAErE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EACvC,KAAK,EAAE,CAAC,EACR,cAAc,CAAC,EAAE,iBAAiB,GACnC,UAAU,CAAC,CAAC,CAAC,CAwCf;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAClC,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,EAAE,EAAE,mBAAmB,GAAG,sBAAsB,EAChD,gBAAgB,GAAE,OAAe,GAClC,MAAM,IAAI,CAoBZ;AAED,yEAAyE;AACzE,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,GAAG,SAAS,CAElE;AAED,6EAA6E;AAC7E,wBAAgB,oBAAoB,CAChC,IAAI,EAAE,MAAM,GAAG,MAAM,GACtB,MAAM,GAAG,SAAS,CAIpB;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAGnD;AAED,mFAAmF;AACnF,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,QAItE;AAED,2FAA2F;AAC3F,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,CAa1E;AAED,oDAAoD;AACpD,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,OAEhE"}
|
package/dist/deepSignal.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright (c) 2025 Laurin Weger, Par le Peuple, NextGraph.org developers
|
|
3
2
|
// All rights reserved.
|
|
4
3
|
// Licensed under the Apache License, Version 2.0
|
|
@@ -8,18 +7,8 @@
|
|
|
8
7
|
// notice may not be copied, modified, or distributed except
|
|
9
8
|
// according to those terms.
|
|
10
9
|
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
exports.deepSignal = deepSignal;
|
|
14
|
-
exports.subscribeDeepMutations = subscribeDeepMutations;
|
|
15
|
-
exports.getDeepSignalRootId = getDeepSignalRootId;
|
|
16
|
-
exports.getDeepSignalVersion = getDeepSignalVersion;
|
|
17
|
-
exports.shallow = shallow;
|
|
18
|
-
exports.setSetEntrySyntheticId = setSetEntrySyntheticId;
|
|
19
|
-
exports.addWithId = addWithId;
|
|
20
|
-
exports.getRaw = getRaw;
|
|
21
|
-
const core_1 = require("./core");
|
|
22
|
-
const iteratorHelpers_1 = require("./iteratorHelpers");
|
|
10
|
+
import { computed, alienSignal } from "./core.js";
|
|
11
|
+
import { createIteratorWithHelpers, iteratorHelperKeys, } from "./iteratorHelpers.js";
|
|
23
12
|
/** The current proxy object for the raw object (others might exist but are not the current / clean ones). */
|
|
24
13
|
const rawToProxy = new WeakMap();
|
|
25
14
|
const rawToMeta = new WeakMap();
|
|
@@ -82,7 +71,7 @@ function setSignalValue(meta, key, value) {
|
|
|
82
71
|
if (!signals.has(key)) {
|
|
83
72
|
// Add new signal.
|
|
84
73
|
signals.set(key, {
|
|
85
|
-
alienSignal:
|
|
74
|
+
alienSignal: alienSignal(value),
|
|
86
75
|
// Do not add external subscribers yet, they will be created on first read.
|
|
87
76
|
externalSubscribers: new Map(),
|
|
88
77
|
});
|
|
@@ -122,7 +111,7 @@ function ensureIterableSignal(meta, target) {
|
|
|
122
111
|
// Create new one if none exists.
|
|
123
112
|
if (!iterableSignals.has(target)) {
|
|
124
113
|
iterableSignals.set(target, {
|
|
125
|
-
alienSignal:
|
|
114
|
+
alienSignal: alienSignal(0),
|
|
126
115
|
externalSubscribers: new Map(),
|
|
127
116
|
});
|
|
128
117
|
}
|
|
@@ -146,7 +135,7 @@ function ensureProxiedGetter(signals, target, key, receiver) {
|
|
|
146
135
|
typeof Object.getOwnPropertyDescriptor(target, key)?.get === "function" // If we have a getter?
|
|
147
136
|
) {
|
|
148
137
|
signals.set(key, {
|
|
149
|
-
alienSignal:
|
|
138
|
+
alienSignal: computed(() => Reflect.get(target, key, receiver)),
|
|
150
139
|
externalSubscribers: new Map(),
|
|
151
140
|
});
|
|
152
141
|
}
|
|
@@ -804,7 +793,7 @@ function createSetIterator(target, receiver, mapValue) {
|
|
|
804
793
|
const meta = rawToMeta.get(target);
|
|
805
794
|
const iterator = target.values();
|
|
806
795
|
ensureIterableSignal(meta, target);
|
|
807
|
-
return
|
|
796
|
+
return createIteratorWithHelpers(() => {
|
|
808
797
|
const next = iterator.next();
|
|
809
798
|
if (next.done)
|
|
810
799
|
return next;
|
|
@@ -960,7 +949,7 @@ const setHandlers = {
|
|
|
960
949
|
]);
|
|
961
950
|
};
|
|
962
951
|
}
|
|
963
|
-
if (typeof key === "string" &&
|
|
952
|
+
if (typeof key === "string" && iteratorHelperKeys.has(key)) {
|
|
964
953
|
return function iteratorHelper(...args) {
|
|
965
954
|
const iterator = createSetIterator(target, receiver, (value) => value);
|
|
966
955
|
const helper = iterator[key];
|
|
@@ -1009,7 +998,7 @@ const setHandlers = {
|
|
|
1009
998
|
},
|
|
1010
999
|
};
|
|
1011
1000
|
/** Runtime guard that checks whether a value is a deepSignal proxy. */
|
|
1012
|
-
function isDeepSignal(value) {
|
|
1001
|
+
export function isDeepSignal(value) {
|
|
1013
1002
|
return !!value?.[RAW_KEY];
|
|
1014
1003
|
}
|
|
1015
1004
|
/**
|
|
@@ -1041,7 +1030,7 @@ function isDeepSignal(value) {
|
|
|
1041
1030
|
*
|
|
1042
1031
|
* @throws if provided with unsupported input types.
|
|
1043
1032
|
*/
|
|
1044
|
-
function deepSignal(input, specialOptions) {
|
|
1033
|
+
export function deepSignal(input, specialOptions) {
|
|
1045
1034
|
// Is the input already a signal?
|
|
1046
1035
|
if (isDeepSignal(input)) {
|
|
1047
1036
|
// Add possibly new external subscribers to existing ones.
|
|
@@ -1079,7 +1068,7 @@ function deepSignal(input, specialOptions) {
|
|
|
1079
1068
|
*
|
|
1080
1069
|
* Register a deep mutation subscriber for the provided root or proxy.
|
|
1081
1070
|
*/
|
|
1082
|
-
function subscribeDeepMutations(root, cb, triggerInstantly = false) {
|
|
1071
|
+
export function subscribeDeepMutations(root, cb, triggerInstantly = false) {
|
|
1083
1072
|
const rootId = typeof root === "symbol" ? root : getDeepSignalRootId(root);
|
|
1084
1073
|
if (!rootId)
|
|
1085
1074
|
throw new Error("subscribeDeepMutations() expects a deepSignal root");
|
|
@@ -1101,11 +1090,11 @@ function subscribeDeepMutations(root, cb, triggerInstantly = false) {
|
|
|
1101
1090
|
}
|
|
1102
1091
|
}
|
|
1103
1092
|
/** Return the root identifier symbol for a deepSignal proxy (if any). */
|
|
1104
|
-
function getDeepSignalRootId(value) {
|
|
1093
|
+
export function getDeepSignalRootId(value) {
|
|
1105
1094
|
return rawToMeta.get(value?.[RAW_KEY] ?? value)?.root;
|
|
1106
1095
|
}
|
|
1107
1096
|
/** Retrieve the current patch version for a deepSignal root (if tracked). */
|
|
1108
|
-
function getDeepSignalVersion(root) {
|
|
1097
|
+
export function getDeepSignalVersion(root) {
|
|
1109
1098
|
const rootId = typeof root === "symbol" ? root : getDeepSignalRootId(root);
|
|
1110
1099
|
if (!rootId)
|
|
1111
1100
|
return undefined;
|
|
@@ -1119,19 +1108,19 @@ function getDeepSignalVersion(root) {
|
|
|
1119
1108
|
* state.config = shallow({ huge: { blob: true } });
|
|
1120
1109
|
* ```
|
|
1121
1110
|
*/
|
|
1122
|
-
function shallow(obj) {
|
|
1111
|
+
export function shallow(obj) {
|
|
1123
1112
|
ignored.add(obj);
|
|
1124
1113
|
return obj;
|
|
1125
1114
|
}
|
|
1126
1115
|
/** Force a specific synthetic ID to be used for a Set entry prior to insertion. */
|
|
1127
|
-
function setSetEntrySyntheticId(obj, id) {
|
|
1116
|
+
export function setSetEntrySyntheticId(obj, id) {
|
|
1128
1117
|
if (!obj || typeof obj !== "object")
|
|
1129
1118
|
return;
|
|
1130
1119
|
// @ts-ignore
|
|
1131
1120
|
forcedSyntheticIds.set(obj[RAW_KEY] ?? obj, String(id));
|
|
1132
1121
|
}
|
|
1133
1122
|
/** Convenience helper to add an entry to a proxied Set with a pre-defined synthetic ID. */
|
|
1134
|
-
function addWithId(set, entry, id) {
|
|
1123
|
+
export function addWithId(set, entry, id) {
|
|
1135
1124
|
if (entry && typeof entry === "object") {
|
|
1136
1125
|
setSetEntrySyntheticId(entry, id);
|
|
1137
1126
|
}
|
|
@@ -1147,6 +1136,6 @@ function addWithId(set, entry, id) {
|
|
|
1147
1136
|
return entry;
|
|
1148
1137
|
}
|
|
1149
1138
|
/** Get the original, raw value of a deep signal. */
|
|
1150
|
-
function getRaw(value) {
|
|
1139
|
+
export function getRaw(value) {
|
|
1151
1140
|
return value?.[RAW_KEY] ?? value;
|
|
1152
1141
|
}
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useDeepSignal = void 0;
|
|
7
|
-
const useDeepSignal_js_1 = __importDefault(require("./useDeepSignal.js"));
|
|
8
|
-
exports.useDeepSignal = useDeepSignal_js_1.default;
|
|
1
|
+
import useDeepSignal from "./useDeepSignal.js";
|
|
2
|
+
export { useDeepSignal };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DeepSignalOptions } from "
|
|
1
|
+
import { DeepSignalOptions } from "../../index.ts";
|
|
2
2
|
/**
|
|
3
3
|
* Create or use an existing deepSignal object in your component.
|
|
4
4
|
* Modifications to the returned deepSignal object cause an immediate rerender.
|
|
@@ -9,6 +9,6 @@ import { DeepSignalOptions } from "../..";
|
|
|
9
9
|
* @param options When the object is not a deepSignal already, options passed to {@link deepSignal}.
|
|
10
10
|
* @returns The deepSignal object of the object param. On every change, the returned object will change (a new no-op proxy is created) around the deepSignal object.
|
|
11
11
|
*/
|
|
12
|
-
declare const useSignal: <T extends object>(object: T, deepSignalOptions?: DeepSignalOptions) => import("
|
|
12
|
+
declare const useSignal: <T extends object>(object: T, deepSignalOptions?: DeepSignalOptions) => import("../../types.ts").DeepSignal<T>;
|
|
13
13
|
export default useSignal;
|
|
14
14
|
//# sourceMappingURL=useDeepSignal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDeepSignal.d.ts","sourceRoot":"","sources":["../../../src/hooks/react/useDeepSignal.ts"],"names":[],"mappings":"AAYA,OAAO,EAAc,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"useDeepSignal.d.ts","sourceRoot":"","sources":["../../../src/hooks/react/useDeepSignal.ts"],"names":[],"mappings":"AAYA,OAAO,EAAc,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAE/D;;;;;;;;;GASG;AACH,QAAA,MAAM,SAAS,GAAI,CAAC,SAAS,MAAM,EAC/B,QAAQ,CAAC,EACT,oBAAoB,iBAAiB,2CAyCxC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright (c) 2025 Laurin Weger, Par le Peuple, NextGraph.org developers
|
|
3
2
|
// All rights reserved.
|
|
4
3
|
// Licensed under the Apache License, Version 2.0
|
|
@@ -8,10 +7,9 @@
|
|
|
8
7
|
// notice may not be copied, modified, or distributed except
|
|
9
8
|
// according to those terms.
|
|
10
9
|
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const __1 = require("../..");
|
|
10
|
+
import { watch } from "../../watch.js";
|
|
11
|
+
import { useCallback, useMemo, useRef, useSyncExternalStore } from "react";
|
|
12
|
+
import { deepSignal } from "../../index.js";
|
|
15
13
|
/**
|
|
16
14
|
* Create or use an existing deepSignal object in your component.
|
|
17
15
|
* Modifications to the returned deepSignal object cause an immediate rerender.
|
|
@@ -24,26 +22,26 @@ const __1 = require("../..");
|
|
|
24
22
|
*/
|
|
25
23
|
const useSignal = (object, deepSignalOptions) => {
|
|
26
24
|
// Create the actual deepSignal object from the raw object (if the object is a deepSignal object already, it returns itself).
|
|
27
|
-
const signal =
|
|
25
|
+
const signal = useMemo(() => deepSignal(object, {
|
|
28
26
|
replaceProxiesInBranchOnChange: true, // Set so that react can detect change in object hierarchy by equality comparison.
|
|
29
27
|
...deepSignalOptions,
|
|
30
28
|
}), [object, deepSignalOptions]);
|
|
31
29
|
// Create a shallow proxy of the original object which can be disposed and a new one
|
|
32
30
|
// recreated on rerenders so that react knows it changed on comparisons.
|
|
33
|
-
const proxyRef =
|
|
31
|
+
const proxyRef = useRef(new Proxy(signal, {}));
|
|
34
32
|
// Update proxy ref when shapeSignal changes
|
|
35
|
-
|
|
33
|
+
useMemo(() => {
|
|
36
34
|
proxyRef.current = new Proxy(signal, {});
|
|
37
35
|
}, [signal]);
|
|
38
|
-
const subscribe =
|
|
39
|
-
const { stopListening } =
|
|
36
|
+
const subscribe = useCallback((onStoreChange) => {
|
|
37
|
+
const { stopListening } = watch(signal, () => {
|
|
40
38
|
// Create a new shallow proxy and notify react about the change.
|
|
41
39
|
proxyRef.current = new Proxy(signal, {});
|
|
42
40
|
onStoreChange();
|
|
43
41
|
}, { triggerInstantly: true });
|
|
44
42
|
return stopListening;
|
|
45
43
|
}, [signal]);
|
|
46
|
-
const getSnapshot =
|
|
47
|
-
return
|
|
44
|
+
const getSnapshot = useCallback(() => proxyRef.current, []);
|
|
45
|
+
return useSyncExternalStore(subscribe, getSnapshot);
|
|
48
46
|
};
|
|
49
|
-
|
|
47
|
+
export default useSignal;
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useDeepSignal = void 0;
|
|
7
|
-
const useDeepSignal_svelte_js_1 = __importDefault(require("./useDeepSignal.svelte.js"));
|
|
8
|
-
exports.useDeepSignal = useDeepSignal_svelte_js_1.default;
|
|
1
|
+
import useDeepSignal from "./useDeepSignal.svelte.js";
|
|
2
|
+
export { useDeepSignal };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDeepSignal.svelte.d.ts","sourceRoot":"","sources":["../../../src/hooks/svelte/useDeepSignal.svelte.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,iBAAiB,EAAc,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"useDeepSignal.svelte.d.ts","sourceRoot":"","sources":["../../../src/hooks/svelte/useDeepSignal.svelte.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,iBAAiB,EAAc,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE3E;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,EAC1C,MAAM,EAAE,CAAC,EACT,OAAO,CAAC,EAAE,iBAAiB,GAab,CAAC,SAAS,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAC9D;AAyBD,eAAe,aAAa,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright (c) 2025 Laurin Weger, Par le Peuple, NextGraph.org developers
|
|
3
2
|
// All rights reserved.
|
|
4
3
|
// Licensed under the Apache License, Version 2.0
|
|
@@ -8,10 +7,8 @@
|
|
|
8
7
|
// notice may not be copied, modified, or distributed except
|
|
9
8
|
// according to those terms.
|
|
10
9
|
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const reactivity_1 = require("svelte/reactivity");
|
|
14
|
-
const index_1 = require("../../index");
|
|
10
|
+
import { createSubscriber } from "svelte/reactivity";
|
|
11
|
+
import { deepSignal } from "../../index.js";
|
|
15
12
|
/**
|
|
16
13
|
* Create a rune from a deepSignal object (creates one if it is just a regular object).
|
|
17
14
|
*
|
|
@@ -23,8 +20,8 @@ const index_1 = require("../../index");
|
|
|
23
20
|
* @param options Options passed to {@link deepSignal}.
|
|
24
21
|
* @returns A rune for using the deepSignal object in svelte.
|
|
25
22
|
*/
|
|
26
|
-
function useDeepSignal(object, options) {
|
|
27
|
-
const ret =
|
|
23
|
+
export function useDeepSignal(object, options) {
|
|
24
|
+
const ret = deepSignal(object, {
|
|
28
25
|
...options,
|
|
29
26
|
subscriberFactories: (options?.subscriberFactories ?? new Set()).union(new Set([subscriberFactory])),
|
|
30
27
|
});
|
|
@@ -43,7 +40,7 @@ const subscriberFactory = () => {
|
|
|
43
40
|
let onSet = () => {
|
|
44
41
|
setter?.();
|
|
45
42
|
};
|
|
46
|
-
const onGet =
|
|
43
|
+
const onGet = createSubscriber((update) => {
|
|
47
44
|
setter = () => {
|
|
48
45
|
update();
|
|
49
46
|
};
|
|
@@ -53,4 +50,4 @@ const subscriberFactory = () => {
|
|
|
53
50
|
onSet,
|
|
54
51
|
};
|
|
55
52
|
};
|
|
56
|
-
|
|
53
|
+
export default useDeepSignal;
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useDeepSignal = void 0;
|
|
7
|
-
const useDeepSignal_svelte_js_1 = __importDefault(require("./useDeepSignal.svelte.js"));
|
|
8
|
-
exports.useDeepSignal = useDeepSignal_svelte_js_1.default;
|
|
1
|
+
import useDeepSignal from "./useDeepSignal.svelte.js";
|
|
2
|
+
export { useDeepSignal };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Readable } from "svelte/store";
|
|
2
|
-
import { DeepSignalOptions, UnwrapDeepSignal } from "../../index";
|
|
2
|
+
import { DeepSignalOptions, UnwrapDeepSignal } from "../../index.ts";
|
|
3
3
|
/** Base result contract for a deepSignal-backed Svelte integration. */
|
|
4
4
|
export interface UseDeepSignalResult<T> extends Readable<T> {
|
|
5
5
|
/** Derive a nested selection; re-runs when the underlying tree version increments. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDeepSignal.svelte.d.ts","sourceRoot":"","sources":["../../../src/hooks/svelte4/useDeepSignal.svelte.ts"],"names":[],"mappings":"AAUA,OAAO,EAAqB,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEhE,OAAO,EAGH,iBAAiB,EAEjB,gBAAgB,EACnB,MAAM,
|
|
1
|
+
{"version":3,"file":"useDeepSignal.svelte.d.ts","sourceRoot":"","sources":["../../../src/hooks/svelte4/useDeepSignal.svelte.ts"],"names":[],"mappings":"AAUA,OAAO,EAAqB,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEhE,OAAO,EAGH,iBAAiB,EAEjB,gBAAgB,EACnB,MAAM,gBAAgB,CAAC;AAGxB,uEAAuE;AACvE,MAAM,WAAW,mBAAmB,CAAC,CAAC,CAAE,SAAQ,QAAQ,CAAC,CAAC,CAAC;IACvD,sFAAsF;IACtF,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IACjD,mFAAmF;IACnF,OAAO,IAAI,IAAI,CAAC;IAChB,sGAAsG;IACtG,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IAChC,4DAA4D;IAC5D,MAAM,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;CACnD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,EAC1C,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EACtB,OAAO,CAAC,EAAE,iBAAiB,GAC5B,mBAAmB,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAkE1C;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright (c) 2025 Laurin Weger, Par le Peuple, NextGraph.org developers
|
|
3
2
|
// All rights reserved.
|
|
4
3
|
// Licensed under the Apache License, Version 2.0
|
|
@@ -8,12 +7,10 @@
|
|
|
8
7
|
// notice may not be copied, modified, or distributed except
|
|
9
8
|
// according to those terms.
|
|
10
9
|
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const index_1 = require("../../index");
|
|
16
|
-
const deepSignal_1 = require("../../deepSignal");
|
|
10
|
+
import { derived, writable } from "svelte/store";
|
|
11
|
+
import { onDestroy } from "svelte";
|
|
12
|
+
import { subscribeDeepMutations, deepSignal, } from "../../index.js";
|
|
13
|
+
import { getDeepSignalRootId, getDeepSignalVersion } from "../../deepSignal.js";
|
|
17
14
|
/**
|
|
18
15
|
* Create a store from a deepSignal object (creates one if it is just a regular object).
|
|
19
16
|
*
|
|
@@ -25,18 +22,18 @@ const deepSignal_1 = require("../../deepSignal");
|
|
|
25
22
|
* @param options Options passed to {@link deepSignal}.
|
|
26
23
|
* @returns A store for using the deepSignal object in svelte.
|
|
27
24
|
*/
|
|
28
|
-
function useDeepSignal(object, options) {
|
|
29
|
-
const version =
|
|
25
|
+
export function useDeepSignal(object, options) {
|
|
26
|
+
const version = writable(-1);
|
|
30
27
|
let deepProxy;
|
|
31
28
|
let unsubscribe;
|
|
32
29
|
let isDestroyed = false;
|
|
33
30
|
const init = (obj) => {
|
|
34
31
|
if (isDestroyed)
|
|
35
32
|
return;
|
|
36
|
-
deepProxy =
|
|
37
|
-
const rootId =
|
|
38
|
-
const initialVersion =
|
|
39
|
-
unsubscribe =
|
|
33
|
+
deepProxy = deepSignal(obj, options);
|
|
34
|
+
const rootId = getDeepSignalRootId(deepProxy);
|
|
35
|
+
const initialVersion = getDeepSignalVersion(deepProxy) ?? 0;
|
|
36
|
+
unsubscribe = subscribeDeepMutations(deepProxy, (batch) => {
|
|
40
37
|
if (!rootId)
|
|
41
38
|
return;
|
|
42
39
|
if (batch.patches.length) {
|
|
@@ -56,9 +53,9 @@ function useDeepSignal(object, options) {
|
|
|
56
53
|
if (unsubscribe)
|
|
57
54
|
unsubscribe();
|
|
58
55
|
};
|
|
59
|
-
|
|
60
|
-
const deep =
|
|
61
|
-
const select = (selector) =>
|
|
56
|
+
onDestroy(dispose);
|
|
57
|
+
const deep = derived(version, () => deepProxy);
|
|
58
|
+
const select = (selector) => derived(deep, (t) => (t ? selector(t) : undefined));
|
|
62
59
|
// Expose Svelte store contract by delegating subscribe to deep store.
|
|
63
60
|
const applyReplacement = (next) => {
|
|
64
61
|
if (!deepProxy || !next || typeof next !== "object")
|
|
@@ -88,4 +85,4 @@ function useDeepSignal(object, options) {
|
|
|
88
85
|
};
|
|
89
86
|
return store;
|
|
90
87
|
}
|
|
91
|
-
|
|
88
|
+
export default useDeepSignal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/vue/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/vue/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/hooks/vue/index.js
CHANGED
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useDeepSignal = void 0;
|
|
7
|
-
const useDeepSignal_1 = __importDefault(require("./useDeepSignal"));
|
|
8
|
-
exports.useDeepSignal = useDeepSignal_1.default;
|
|
1
|
+
import useDeepSignal from "./useDeepSignal.js";
|
|
2
|
+
export { useDeepSignal };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type MaybeRefOrGetter } from "vue";
|
|
2
|
-
import { DeepSignal, DeepSignalOptions } from "../../";
|
|
2
|
+
import { DeepSignal, DeepSignalOptions } from "../../index.ts";
|
|
3
3
|
/**
|
|
4
4
|
* Create or use an existing (child) deepSignal object in your component.
|
|
5
5
|
* Modifications to the returned deepSignal object cause an immediate rerender.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDeepSignal.d.ts","sourceRoot":"","sources":["../../../src/hooks/vue/useDeepSignal.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,gBAAgB,EAAsB,MAAM,KAAK,CAAC;AAEhE,OAAO,
|
|
1
|
+
{"version":3,"file":"useDeepSignal.d.ts","sourceRoot":"","sources":["../../../src/hooks/vue/useDeepSignal.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,gBAAgB,EAAsB,MAAM,KAAK,CAAC;AAEhE,OAAO,EACH,UAAU,EAEV,iBAAiB,EAEpB,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,EAC1C,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAC3B,OAAO,CAAC,EAAE,iBAAiB,GAC5B,UAAU,CAAC,CAAC,CAAC,CAaf;AAkBD,eAAe,aAAa,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright (c) 2025 Laurin Weger, Par le Peuple, NextGraph.org developers
|
|
3
2
|
// All rights reserved.
|
|
4
3
|
// Licensed under the Apache License, Version 2.0
|
|
@@ -8,10 +7,8 @@
|
|
|
8
7
|
// notice may not be copied, modified, or distributed except
|
|
9
8
|
// according to those terms.
|
|
10
9
|
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const vue_1 = require("vue");
|
|
14
|
-
const __1 = require("../../");
|
|
10
|
+
import { toValue, customRef } from "vue";
|
|
11
|
+
import { deepSignal, } from "../../index.js";
|
|
15
12
|
/**
|
|
16
13
|
* Create or use an existing (child) deepSignal object in your component.
|
|
17
14
|
* Modifications to the returned deepSignal object cause an immediate rerender.
|
|
@@ -23,8 +20,8 @@ const __1 = require("../../");
|
|
|
23
20
|
* @returns The deepSignal object of the object param.
|
|
24
21
|
*
|
|
25
22
|
*/
|
|
26
|
-
function useDeepSignal(object, options) {
|
|
27
|
-
const deepProxy =
|
|
23
|
+
export function useDeepSignal(object, options) {
|
|
24
|
+
const deepProxy = deepSignal(toValue(object), {
|
|
28
25
|
...options,
|
|
29
26
|
subscriberFactories: (options?.subscriberFactories ?? new Set()).union(new Set([subscriberFactory])),
|
|
30
27
|
});
|
|
@@ -39,11 +36,11 @@ const subscriberFactory = () => {
|
|
|
39
36
|
let onSet;
|
|
40
37
|
// We don't use the actually returned value of the get/set.
|
|
41
38
|
// We only need it to notify Vue, since Dep is not exposed directly.
|
|
42
|
-
|
|
39
|
+
customRef((track, trigger) => {
|
|
43
40
|
onGet = track;
|
|
44
41
|
onSet = trigger;
|
|
45
42
|
return { get() { }, set() { } };
|
|
46
43
|
});
|
|
47
44
|
return { onGet: onGet, onSet: onSet };
|
|
48
45
|
};
|
|
49
|
-
|
|
46
|
+
export default useDeepSignal;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { addWithId, deepSignal, getRaw, isDeepSignal, shallow, subscribeDeepMutations, } from "./deepSignal";
|
|
2
|
-
export * from "./core";
|
|
3
|
-
export * from "./watch";
|
|
4
|
-
export * from "./types";
|
|
1
|
+
export { addWithId, deepSignal, getRaw, isDeepSignal, shallow, subscribeDeepMutations, } from "./deepSignal.ts";
|
|
2
|
+
export * from "./core.ts";
|
|
3
|
+
export * from "./watch.ts";
|
|
4
|
+
export * from "./types.ts";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,EACT,UAAU,EACV,MAAM,EACN,YAAY,EACZ,OAAO,EACP,sBAAsB,GACzB,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,EACT,UAAU,EACV,MAAM,EACN,YAAY,EACZ,OAAO,EACP,sBAAsB,GACzB,MAAM,iBAAiB,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,27 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.subscribeDeepMutations = exports.shallow = exports.isDeepSignal = exports.getRaw = exports.deepSignal = exports.addWithId = void 0;
|
|
18
|
-
var deepSignal_1 = require("./deepSignal");
|
|
19
|
-
Object.defineProperty(exports, "addWithId", { enumerable: true, get: function () { return deepSignal_1.addWithId; } });
|
|
20
|
-
Object.defineProperty(exports, "deepSignal", { enumerable: true, get: function () { return deepSignal_1.deepSignal; } });
|
|
21
|
-
Object.defineProperty(exports, "getRaw", { enumerable: true, get: function () { return deepSignal_1.getRaw; } });
|
|
22
|
-
Object.defineProperty(exports, "isDeepSignal", { enumerable: true, get: function () { return deepSignal_1.isDeepSignal; } });
|
|
23
|
-
Object.defineProperty(exports, "shallow", { enumerable: true, get: function () { return deepSignal_1.shallow; } });
|
|
24
|
-
Object.defineProperty(exports, "subscribeDeepMutations", { enumerable: true, get: function () { return deepSignal_1.subscribeDeepMutations; } });
|
|
25
|
-
__exportStar(require("./core"), exports);
|
|
26
|
-
__exportStar(require("./watch"), exports);
|
|
27
|
-
__exportStar(require("./types"), exports);
|
|
1
|
+
export { addWithId, deepSignal, getRaw, isDeepSignal, shallow, subscribeDeepMutations, } from "./deepSignal.js";
|
|
2
|
+
export * from "./core.js";
|
|
3
|
+
export * from "./watch.js";
|
|
4
|
+
export * from "./types.js";
|
package/dist/iteratorHelpers.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.iteratorHelperKeys = void 0;
|
|
4
|
-
exports.createIteratorWithHelpers = createIteratorWithHelpers;
|
|
5
1
|
function hasNativeIteratorHelpers() {
|
|
6
2
|
return (typeof Iterator !== "undefined" && typeof Iterator.from === "function");
|
|
7
3
|
}
|
|
8
|
-
|
|
4
|
+
export const iteratorHelperKeys = new Set([
|
|
9
5
|
"map",
|
|
10
6
|
"filter",
|
|
11
7
|
"take",
|
|
@@ -18,7 +14,7 @@ exports.iteratorHelperKeys = new Set([
|
|
|
18
14
|
"every",
|
|
19
15
|
"find",
|
|
20
16
|
]);
|
|
21
|
-
function createIteratorWithHelpers(nextImpl, sourceIterator) {
|
|
17
|
+
export function createIteratorWithHelpers(nextImpl, sourceIterator) {
|
|
22
18
|
const base = {
|
|
23
19
|
next: nextImpl,
|
|
24
20
|
[Symbol.iterator]() {
|