@ng-org/alien-deepsignals 0.1.2-alpha.2 → 0.1.2-alpha.4

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.
Files changed (63) hide show
  1. package/dist/deepSignal.d.ts.map +1 -1
  2. package/dist/deepSignal.js +244 -100
  3. package/dist/hooks/react/useDeepSignal.d.ts +4 -4
  4. package/dist/hooks/react/useDeepSignal.d.ts.map +1 -1
  5. package/dist/hooks/react/useDeepSignal.js +22 -15
  6. package/dist/hooks/svelte/useDeepSignal.svelte.d.ts +3 -7
  7. package/dist/hooks/svelte/useDeepSignal.svelte.d.ts.map +1 -1
  8. package/dist/hooks/svelte/useDeepSignal.svelte.js +34 -18
  9. package/dist/hooks/vue/useDeepSignal.d.ts +4 -3
  10. package/dist/hooks/vue/useDeepSignal.d.ts.map +1 -1
  11. package/dist/hooks/vue/useDeepSignal.js +52 -24
  12. package/dist/test/frontend/astro-app/src/components/PerfSuiteClient.d.ts +4 -0
  13. package/dist/test/frontend/astro-app/src/components/PerfSuiteClient.d.ts.map +1 -0
  14. package/dist/test/frontend/astro-app/src/components/PerfSuiteClient.js +225 -0
  15. package/dist/test/frontend/astro-app/src/components/ReactPanel.d.ts +4 -0
  16. package/dist/test/frontend/astro-app/src/components/ReactPanel.d.ts.map +1 -0
  17. package/dist/test/frontend/astro-app/src/components/ReactPanel.js +227 -0
  18. package/dist/test/frontend/astro-app/src/components/perf/react/ReactPerfDeep.d.ts +4 -0
  19. package/dist/test/frontend/astro-app/src/components/perf/react/ReactPerfDeep.d.ts.map +1 -0
  20. package/dist/test/frontend/astro-app/src/components/perf/react/ReactPerfDeep.js +150 -0
  21. package/dist/test/frontend/astro-app/src/components/perf/react/ReactPerfNative.d.ts +4 -0
  22. package/dist/test/frontend/astro-app/src/components/perf/react/ReactPerfNative.d.ts.map +1 -0
  23. package/dist/test/frontend/astro-app/src/components/perf/react/ReactPerfNative.js +184 -0
  24. package/dist/test/frontend/playwright/crossFrameworkHooks.spec.d.ts +2 -0
  25. package/dist/test/frontend/playwright/crossFrameworkHooks.spec.d.ts.map +1 -0
  26. package/dist/test/frontend/playwright/crossFrameworkHooks.spec.js +171 -0
  27. package/dist/test/frontend/playwright/perfSuite.spec.d.ts +2 -0
  28. package/dist/test/frontend/playwright/perfSuite.spec.d.ts.map +1 -0
  29. package/dist/test/frontend/playwright/perfSuite.spec.js +128 -0
  30. package/dist/test/frontend/utils/mockData.d.ts +53 -0
  31. package/dist/test/frontend/utils/mockData.d.ts.map +1 -0
  32. package/dist/test/frontend/utils/mockData.js +78 -0
  33. package/dist/test/frontend/utils/paths.d.ts +4 -0
  34. package/dist/test/frontend/utils/paths.d.ts.map +1 -0
  35. package/dist/test/frontend/utils/paths.js +28 -0
  36. package/dist/test/frontend/utils/perfScenarios.d.ts +15 -0
  37. package/dist/test/frontend/utils/perfScenarios.d.ts.map +1 -0
  38. package/dist/test/frontend/utils/perfScenarios.js +287 -0
  39. package/dist/test/frontend/utils/renderMetrics.d.ts +13 -0
  40. package/dist/test/frontend/utils/renderMetrics.d.ts.map +1 -0
  41. package/dist/test/frontend/utils/renderMetrics.js +45 -0
  42. package/dist/test/frontend/utils/state.d.ts +57 -0
  43. package/dist/test/frontend/utils/state.d.ts.map +1 -0
  44. package/dist/test/frontend/utils/state.js +79 -0
  45. package/dist/test/lib/core.test.d.ts +2 -0
  46. package/dist/test/lib/core.test.d.ts.map +1 -0
  47. package/dist/test/lib/core.test.js +53 -0
  48. package/dist/test/lib/deepSignalOptions.test.d.ts +2 -0
  49. package/dist/test/lib/deepSignalOptions.test.d.ts.map +1 -0
  50. package/dist/test/lib/deepSignalOptions.test.js +230 -0
  51. package/dist/test/lib/index.test.d.ts +2 -0
  52. package/dist/test/lib/index.test.d.ts.map +1 -0
  53. package/dist/test/lib/index.test.js +807 -0
  54. package/dist/test/lib/misc.test.d.ts +2 -0
  55. package/dist/test/lib/misc.test.d.ts.map +1 -0
  56. package/dist/test/lib/misc.test.js +140 -0
  57. package/dist/test/lib/watch.test.d.ts +2 -0
  58. package/dist/test/lib/watch.test.d.ts.map +1 -0
  59. package/dist/test/lib/watch.test.js +1280 -0
  60. package/dist/types.d.ts +1 -1
  61. package/dist/types.d.ts.map +1 -1
  62. package/package.json +36 -19
  63. package/src/index.ts +5 -0
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=misc.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"misc.test.d.ts","sourceRoot":"","sources":["../../../src/test/lib/misc.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ // Copyright (c) 2025 Laurin Weger, Par le Peuple, NextGraph.org developers
3
+ // All rights reserved.
4
+ // Licensed under the Apache License, Version 2.0
5
+ // <LICENSE-APACHE2 or http://www.apache.org/licenses/LICENSE-2.0>
6
+ // or the MIT license <LICENSE-MIT or http://opensource.org/licenses/MIT>,
7
+ // at your option. All files in the project carrying such
8
+ // notice may not be copied, modified, or distributed except
9
+ // according to those terms.
10
+ // SPDX-License-Identifier: Apache-2.0 OR MIT
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const vitest_1 = require("vitest");
13
+ const deepSignal_1 = require("../../deepSignal");
14
+ const watch_1 = require("../../watch");
15
+ (0, vitest_1.describe)("watch advanced", () => {
16
+ (0, vitest_1.it)("basic patch watcher fires on deep mutations", async () => {
17
+ const st = (0, deepSignal_1.deepSignal)({ a: { b: { c: 1 } } });
18
+ let batches = 0;
19
+ (0, watch_1.watch)(st, ({ patches }) => {
20
+ if (patches.length)
21
+ batches++;
22
+ });
23
+ st.a.b.c = 2;
24
+ st.a.b = { c: 3 };
25
+ await Promise.resolve();
26
+ (0, vitest_1.expect)(batches).toBeGreaterThan(0);
27
+ });
28
+ (0, vitest_1.it)("watch once option still stops after first batch", async () => {
29
+ const st = (0, deepSignal_1.deepSignal)({ a: 1 });
30
+ let count = 0;
31
+ (0, watch_1.watch)(st, () => {
32
+ count++;
33
+ }, { once: true, immediate: true });
34
+ st.a = 2;
35
+ st.a = 3;
36
+ await Promise.resolve();
37
+ (0, vitest_1.expect)(count).toBe(1);
38
+ });
39
+ });
40
+ (0, vitest_1.describe)("patches & root ids", () => {
41
+ (0, vitest_1.it)("root ids are unique", () => {
42
+ const a = (0, deepSignal_1.deepSignal)({});
43
+ const b = (0, deepSignal_1.deepSignal)({});
44
+ (0, vitest_1.expect)((0, deepSignal_1.getDeepSignalRootId)(a)).not.toBe((0, deepSignal_1.getDeepSignalRootId)(b));
45
+ });
46
+ // legacy watchPatches API removed; patch mode only valid for deepSignal roots
47
+ (0, vitest_1.it)("watch throws on non-deepSignal input", () => {
48
+ (0, vitest_1.expect)(() => (0, watch_1.watch)({}, () => { })).toThrow();
49
+ });
50
+ (0, vitest_1.it)("Map unsupported does not emit patches", async () => {
51
+ const m = new Map();
52
+ const st = (0, deepSignal_1.deepSignal)({ m });
53
+ const patches = [];
54
+ const { stopListening: stop } = (0, watch_1.watch)(st, ({ patches: batch }) => patches.push(batch));
55
+ m.set("a", 1);
56
+ await Promise.resolve();
57
+ await Promise.resolve();
58
+ (0, vitest_1.expect)(patches.length).toBe(0);
59
+ stop();
60
+ });
61
+ });
62
+ (0, vitest_1.describe)("tier3: Set iteration variants", () => {
63
+ (0, vitest_1.it)("entries() iteration proxies nested mutation", async () => {
64
+ const st = (0, deepSignal_1.deepSignal)({ s: new Set() }, {
65
+ syntheticIdPropertyName: "id",
66
+ propGenerator: ({ object }) => ({ syntheticId: object.id }),
67
+ });
68
+ st.s.add({ id: "eEnt", inner: { v: 1 } });
69
+ const paths = [];
70
+ const { stopListening: stop } = (0, watch_1.watch)(st, ({ patches }) => paths.push(...patches.map((pp) => pp.path.join("."))));
71
+ for (const [val] of st.s.entries()) {
72
+ val.inner.v;
73
+ } // ensure proxy
74
+ for (const [val] of st.s.entries()) {
75
+ val.inner.v = 2;
76
+ }
77
+ await Promise.resolve();
78
+ await Promise.resolve();
79
+ (0, vitest_1.expect)(paths.some((p) => p.endsWith("eEnt.inner.v"))).toBe(true);
80
+ stop();
81
+ });
82
+ (0, vitest_1.it)("forEach iteration proxies nested mutation", async () => {
83
+ const st = (0, deepSignal_1.deepSignal)({ s: new Set() }, {
84
+ syntheticIdPropertyName: "id",
85
+ propGenerator: ({ object }) => ({ syntheticId: object.id }),
86
+ });
87
+ st.s.add({ id: "fe1", data: { n: 1 } });
88
+ const { stopListening: stop } = (0, watch_1.watch)(st, () => { });
89
+ st.s.forEach((e) => e.data.n); // access
90
+ st.s.forEach((e) => {
91
+ e.data.n = 2;
92
+ });
93
+ await Promise.resolve();
94
+ await Promise.resolve();
95
+ stop();
96
+ });
97
+ (0, vitest_1.it)("keys() iteration returns proxies", async () => {
98
+ const st = (0, deepSignal_1.deepSignal)({ s: new Set() }, {
99
+ syntheticIdPropertyName: "id",
100
+ propGenerator: ({ object }) => ({ syntheticId: object.id }),
101
+ });
102
+ st.s.add({ id: "k1", foo: { x: 1 } });
103
+ const { stopListening: stop } = (0, watch_1.watch)(st, () => { });
104
+ for (const e of st.s.keys()) {
105
+ e.foo.x = 2;
106
+ }
107
+ await Promise.resolve();
108
+ await Promise.resolve();
109
+ stop();
110
+ });
111
+ (0, vitest_1.it)("iterator helpers exist on Set iterators and the root Set", () => {
112
+ const st = (0, deepSignal_1.deepSignal)({ s: new Set([1, 2, 3]) });
113
+ const viaIterator = st.s
114
+ .values()
115
+ .map((value) => value * 2)
116
+ .filter((value) => value > 2)
117
+ .toArray();
118
+ (0, vitest_1.expect)(viaIterator).to.deep.equal([4, 6]);
119
+ const viaRoot = st.s
120
+ .map((value) => value + 1)
121
+ .take(2)
122
+ .toArray();
123
+ (0, vitest_1.expect)(viaRoot).to.deep.equal([2, 3]);
124
+ });
125
+ (0, vitest_1.it)("set iterator helpers return proxied objects", async () => {
126
+ const st = (0, deepSignal_1.deepSignal)({ s: new Set() }, {
127
+ syntheticIdPropertyName: "id",
128
+ propGenerator: ({ object }) => ({ syntheticId: object.id }),
129
+ });
130
+ st.s.add({ id: "obj1", nested: { value: 1 } });
131
+ const [entry] = st.s.map((value) => value).toArray();
132
+ const paths = [];
133
+ const { stopListening: stop } = (0, watch_1.watch)(st, ({ patches }) => paths.push(...patches.map((pp) => pp.path.join("."))));
134
+ entry.nested.value = 5;
135
+ await Promise.resolve();
136
+ await Promise.resolve();
137
+ (0, vitest_1.expect)(paths.some((p) => p.endsWith("obj1.nested.value"))).to.equal(true);
138
+ stop();
139
+ });
140
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=watch.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watch.test.d.ts","sourceRoot":"","sources":["../../../src/test/lib/watch.test.ts"],"names":[],"mappings":""}