@planet-matrix/mobius-model 0.1.4 → 0.3.0

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 (77) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +21 -0
  3. package/dist/index.d.ts +1 -1
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +2 -2
  6. package/dist/index.js.map +12 -6
  7. package/dist/reactor/index.d.ts +3 -0
  8. package/dist/reactor/index.d.ts.map +1 -0
  9. package/dist/reactor/reactor-core/flags.d.ts.map +1 -0
  10. package/dist/reactor/reactor-core/index.d.ts.map +1 -0
  11. package/dist/reactor/reactor-core/primitive.d.ts +276 -0
  12. package/dist/reactor/reactor-core/primitive.d.ts.map +1 -0
  13. package/dist/{signal/signal-core → reactor/reactor-core}/reactive-system.d.ts +102 -22
  14. package/dist/reactor/reactor-core/reactive-system.d.ts.map +1 -0
  15. package/dist/reactor/reactor-operators/branch.d.ts +19 -0
  16. package/dist/reactor/reactor-operators/branch.d.ts.map +1 -0
  17. package/dist/reactor/reactor-operators/convert.d.ts +30 -0
  18. package/dist/reactor/reactor-operators/convert.d.ts.map +1 -0
  19. package/dist/reactor/reactor-operators/create.d.ts +26 -0
  20. package/dist/reactor/reactor-operators/create.d.ts.map +1 -0
  21. package/dist/reactor/reactor-operators/filter.d.ts +269 -0
  22. package/dist/reactor/reactor-operators/filter.d.ts.map +1 -0
  23. package/dist/reactor/reactor-operators/index.d.ts +8 -0
  24. package/dist/reactor/reactor-operators/index.d.ts.map +1 -0
  25. package/dist/reactor/reactor-operators/join.d.ts +48 -0
  26. package/dist/reactor/reactor-operators/join.d.ts.map +1 -0
  27. package/dist/reactor/reactor-operators/map.d.ts +165 -0
  28. package/dist/reactor/reactor-operators/map.d.ts.map +1 -0
  29. package/dist/reactor/reactor-operators/utility.d.ts +48 -0
  30. package/dist/reactor/reactor-operators/utility.d.ts.map +1 -0
  31. package/package.json +9 -9
  32. package/src/index.ts +1 -1
  33. package/src/reactor/README.md +18 -0
  34. package/src/reactor/index.ts +2 -0
  35. package/src/reactor/reactor-core/primitive.ts +1046 -0
  36. package/src/{signal/signal-core → reactor/reactor-core}/reactive-system.ts +392 -93
  37. package/src/reactor/reactor-operators/branch.ts +66 -0
  38. package/src/reactor/reactor-operators/convert.ts +70 -0
  39. package/src/reactor/reactor-operators/create.ts +66 -0
  40. package/src/reactor/reactor-operators/filter.ts +988 -0
  41. package/src/reactor/reactor-operators/index.ts +7 -0
  42. package/src/reactor/reactor-operators/join.ts +174 -0
  43. package/src/reactor/reactor-operators/map.ts +599 -0
  44. package/src/reactor/reactor-operators/utility.ts +102 -0
  45. package/tests/unit/{signal/computed.spec.ts → reactor/alien-signals-computed.spec.ts} +15 -10
  46. package/tests/unit/reactor/alien-signals-effect-scope.spec.ts +86 -0
  47. package/tests/unit/reactor/alien-signals-effect.spec.ts +395 -0
  48. package/tests/unit/reactor/alien-signals-topology.spec.ts +361 -0
  49. package/tests/unit/reactor/alien-signals-trigger.spec.ts +75 -0
  50. package/tests/unit/reactor/alien-signals-untrack.spec.ts +91 -0
  51. package/tests/unit/reactor/preact-signal.spec.ts +73 -0
  52. package/tests/unit/reactor/reactor-core.spec.ts +219 -0
  53. package/tests/unit/reactor/reactor-operators-branch.spec.ts +33 -0
  54. package/tests/unit/reactor/reactor-operators-convert.spec.ts +31 -0
  55. package/tests/unit/reactor/reactor-operators-create.spec.ts +47 -0
  56. package/tests/unit/reactor/reactor-operators-filter.spec.ts +604 -0
  57. package/tests/unit/reactor/reactor-operators-join.spec.ts +94 -0
  58. package/tests/unit/reactor/reactor-operators-map.spec.ts +327 -0
  59. package/tests/unit/reactor/reactor-operators-utility.spec.ts +55 -0
  60. package/dist/signal/index.d.ts +0 -3
  61. package/dist/signal/index.d.ts.map +0 -1
  62. package/dist/signal/signal-core/flags.d.ts.map +0 -1
  63. package/dist/signal/signal-core/index.d.ts.map +0 -1
  64. package/dist/signal/signal-core/primitive.d.ts +0 -67
  65. package/dist/signal/signal-core/primitive.d.ts.map +0 -1
  66. package/dist/signal/signal-core/reactive-system.d.ts.map +0 -1
  67. package/dist/signal/signal-operators/index.d.ts +0 -4
  68. package/dist/signal/signal-operators/index.d.ts.map +0 -1
  69. package/src/signal/index.ts +0 -2
  70. package/src/signal/signal-core/README.md +0 -4
  71. package/src/signal/signal-core/primitive.ts +0 -275
  72. package/src/signal/signal-operators/index.ts +0 -19
  73. package/tests/unit/signal/effect.spec.ts +0 -108
  74. /package/dist/{signal/signal-core → reactor/reactor-core}/flags.d.ts +0 -0
  75. /package/dist/{signal/signal-core → reactor/reactor-core}/index.d.ts +0 -0
  76. /package/src/{signal/signal-core → reactor/reactor-core}/flags.ts +0 -0
  77. /package/src/{signal/signal-core → reactor/reactor-core}/index.ts +0 -0
@@ -0,0 +1,327 @@
1
+ import type { Signal } from '#Source/reactor/index.ts';
2
+ import { expect, test } from 'vitest';
3
+
4
+ import {
5
+ bufferByCount, bufferByDynamic, bufferByTime, bufferByToggle, bufferByTrigger,
6
+ contextualMap,
7
+ groupToArrayBy, groupToObjectBy, groupToSignalArrayBy, groupToSignalObjectBy,
8
+ interval, map,
9
+ mergeMap, pairwise, partition, scan, signal, switchMap, tap, withHistory,
10
+ } from '#Source/reactor/index.ts';
11
+
12
+ test("tap operator should work correctly", () => {
13
+ const logs: string[] = [];
14
+ const source = signal(() => 'start');
15
+ const tapped = tap({
16
+ target: source,
17
+ tapper: (value) => {
18
+ logs.push(`tapped: ${value}`);
19
+ }
20
+ });
21
+
22
+ expect(tapped.get()).toBe('start');
23
+ expect(logs).toEqual(['tapped: start']);
24
+
25
+ source.set('next');
26
+ expect(tapped.get()).toBe('next');
27
+ expect(logs).toEqual(['tapped: start', 'tapped: next']);
28
+ });
29
+
30
+ test("withHistory operator should work correctly", () => {
31
+ const a = signal(() => 1);
32
+ const aWithHistory = withHistory({ target: a });
33
+ expect(aWithHistory.get()).toEqual([1]);
34
+
35
+ a.set(2);
36
+ expect(aWithHistory.get()).toEqual([1, 2]);
37
+
38
+ a.set(3);
39
+ expect(aWithHistory.get()).toEqual([1, 2, 3]);
40
+ });
41
+
42
+ test("bufferByCount operator should work correctly", () => {
43
+ const source = signal(() => 1);
44
+ const buffered = bufferByCount({ target: source, count: 3 });
45
+
46
+ expect(buffered.get()).toEqual([]);
47
+
48
+ source.set(2);
49
+ expect(buffered.get()).toEqual([]);
50
+
51
+ source.set(3);
52
+ expect(buffered.get()).toEqual([1, 2, 3]);
53
+
54
+ source.set(4);
55
+ source.set(5);
56
+ source.set(6);
57
+ expect(buffered.get()).toEqual([4, 5, 6]);
58
+ });
59
+
60
+ test("bufferByTime operator should work correctly", async () => {
61
+ const source = signal(() => 1);
62
+ const buffered = bufferByTime({ target: source, time: 100 });
63
+
64
+ expect(buffered.get()).toEqual([]);
65
+
66
+ source.set(2);
67
+ source.set(3);
68
+ expect(buffered.get()).toEqual([]);
69
+
70
+ await new Promise((resolve) => {
71
+ setTimeout(resolve, 120);
72
+ });
73
+ expect(buffered.get()).toEqual([1, 2, 3]);
74
+
75
+ source.set(4);
76
+ source.set(5);
77
+ source.set(6);
78
+ expect(buffered.get()).toEqual([1, 2, 3]);
79
+
80
+ await new Promise((resolve) => {
81
+ setTimeout(resolve, 110)
82
+ });
83
+ expect(buffered.get()).toEqual([4, 5, 6]);
84
+ });
85
+
86
+ test("bufferByTrigger operator should work correctly", () => {
87
+ const source = signal(() => 1);
88
+ const trigger = signal(() => 0);
89
+ const buffered = bufferByTrigger({ target: source, trigger });
90
+
91
+ expect(buffered.get()).toEqual([1]);
92
+
93
+ source.set(2);
94
+ source.set(3);
95
+ expect(buffered.get()).toEqual([1]);
96
+
97
+ trigger.set(1);
98
+ expect(buffered.get()).toEqual([2, 3]);
99
+
100
+ source.set(4);
101
+ source.set(5);
102
+ source.set(6);
103
+ expect(buffered.get()).toEqual([2, 3]);
104
+
105
+ trigger.set(2);
106
+ expect(buffered.get()).toEqual([4, 5, 6]);
107
+ })
108
+
109
+ test("bufferByToggle operator should work correctly", () => {
110
+ const source = signal(() => 1);
111
+ const open = signal(() => []);
112
+ const close = signal(() => []);
113
+ const buffered = bufferByToggle({ target: source, open, close });
114
+
115
+ expect(buffered.get()).toEqual([1]);
116
+
117
+ source.set(2);
118
+ expect(buffered.get()).toEqual([1]);
119
+
120
+ open.set([]);
121
+ source.set(3);
122
+ source.set(4);
123
+ expect(buffered.get()).toEqual([1]);
124
+
125
+ close.set([]);
126
+ expect(buffered.get()).toEqual([3, 4]);
127
+
128
+ source.set(5);
129
+ expect(buffered.get()).toEqual([3, 4]);
130
+
131
+ open.set([]);
132
+ source.set(6);
133
+ source.set(7);
134
+ expect(buffered.get()).toEqual([3, 4]);
135
+ close.set([]);
136
+
137
+ expect(buffered.get()).toEqual([6, 7]);
138
+ });
139
+
140
+ test("bufferByDynamic operator should work correctly", async () => {
141
+ const source = signal(() => 1);
142
+ const dynamic = (): Signal<number> => interval({ interval: 100 })
143
+ const buffered = bufferByDynamic({ target: source, dynamic });
144
+
145
+ expect(buffered.get()).toEqual([1]);
146
+
147
+ source.set(2);
148
+ source.set(3);
149
+ expect(buffered.get()).toEqual([1]);
150
+
151
+ await new Promise((resolve) => {
152
+ setTimeout(resolve, 120);
153
+ });
154
+ expect(buffered.get()).toEqual([2, 3]);
155
+
156
+ source.set(4);
157
+ source.set(5);
158
+ source.set(6);
159
+ expect(buffered.get()).toEqual([2, 3]);
160
+
161
+ await new Promise((resolve) => {
162
+ setTimeout(resolve, 110)
163
+ });
164
+ expect(buffered.get()).toEqual([4, 5, 6]);
165
+ });
166
+
167
+ test("groupToArrayBy operator should work correctly", () => {
168
+ const source = signal(() => ({ id: 1, value: 'a' }));
169
+ const grouped = groupToArrayBy({ target: source, keyGetter: (item) => item.id });
170
+
171
+ expect(grouped.get().at(0)).toEqual([{ id: 1, value: 'a' }]);
172
+
173
+ source.set({ id: 2, value: 'b' });
174
+ expect(grouped.get().at(0)).toEqual([{ id: 1, value: 'a' }]);
175
+ expect(grouped.get().at(1)).toEqual([{ id: 2, value: 'b' }]);
176
+
177
+ source.set({ id: 1, value: 'c' });
178
+ expect(grouped.get().at(0)).toEqual([{ id: 1, value: 'a' }, { id: 1, value: 'c' }]);
179
+ expect(grouped.get().at(1)).toEqual([{ id: 2, value: 'b' }]);
180
+ });
181
+
182
+ test("groupToObjectBy operator should work correctly", () => {
183
+ const source = signal(() => ({ id: 'x', value: 10 }));
184
+ const grouped = groupToObjectBy({ target: source, keyGetter: (item) => item.id });
185
+
186
+ expect(grouped.get()['x']).toEqual([{ id: 'x', value: 10 }]);
187
+
188
+ source.set({ id: 'y', value: 20 });
189
+ expect(grouped.get()['x']).toEqual([{ id: 'x', value: 10 }]);
190
+ expect(grouped.get()['y']).toEqual([{ id: 'y', value: 20 }]);
191
+
192
+ source.set({ id: 'x', value: 30 });
193
+ expect(grouped.get()['x']).toEqual([{ id: 'x', value: 10 }, { id: 'x', value: 30 }]);
194
+ expect(grouped.get()['y']).toEqual([{ id: 'y', value: 20 }]);
195
+ });
196
+
197
+ test("groupToSignalArrayBy operator should work correctly", () => {
198
+ const source = signal(() => ({ id: 1, value: 'a' }));
199
+ const grouped = groupToSignalArrayBy(source, (item) => item.id);
200
+
201
+ expect(grouped.get().at(0)?.get()).toEqual([{ id: 1, value: 'a' }]);
202
+
203
+ source.set({ id: 2, value: 'b' });
204
+ expect(grouped.get().at(0)?.get()).toEqual([{ id: 1, value: 'a' }]);
205
+ expect(grouped.get().at(1)?.get()).toEqual([{ id: 2, value: 'b' }]);
206
+
207
+ source.set({ id: 1, value: 'c' });
208
+ expect(grouped.get().at(0)?.get()).toEqual([{ id: 1, value: 'a' }, { id: 1, value: 'c' }]);
209
+ expect(grouped.get().at(1)?.get()).toEqual([{ id: 2, value: 'b' }]);
210
+ });
211
+
212
+ test("groupToSignalObjectBy operator should work correctly", () => {
213
+ const source = signal(() => ({ id: 'x', value: 10 }));
214
+ const grouped = groupToSignalObjectBy({ target: source, keyGetter: (item) => item.id });
215
+
216
+ expect(grouped.get()['x']?.get()).toEqual([{ id: 'x', value: 10 }]);
217
+
218
+ source.set({ id: 'y', value: 20 });
219
+ expect(grouped.get()['x']?.get()).toEqual([{ id: 'x', value: 10 }]);
220
+ expect(grouped.get()['y']?.get()).toEqual([{ id: 'y', value: 20 }]);
221
+
222
+ source.set({ id: 'x', value: 30 });
223
+ expect(grouped.get()['x']?.get()).toEqual([{ id: 'x', value: 10 }, { id: 'x', value: 30 }]);
224
+ expect(grouped.get()['y']?.get()).toEqual([{ id: 'y', value: 20 }]);
225
+ });
226
+
227
+ test("map operator should work correctly", () => {
228
+ const source = signal(() => 2);
229
+ const mapped = map({ target: source, mapper: (value) => value * 3 });
230
+
231
+ expect(mapped.get()).toBe(6);
232
+
233
+ source.set(4);
234
+ expect(mapped.get()).toBe(12);
235
+
236
+ source.set(0);
237
+ expect(mapped.get()).toBe(0);
238
+ });
239
+
240
+ test("contextualMap operator should work correctly", () => {
241
+ const source = signal(() => 5);
242
+ const mapped = contextualMap({
243
+ target: source,
244
+ mapper: (context): number => {
245
+ if (context.isInitializingRun) {
246
+ return context.targetValue + 1;
247
+ } else {
248
+ return context.targetValue + context.previousMappedValue;
249
+ }
250
+ }
251
+ });
252
+ expect(mapped.get()).toBe(6);
253
+
254
+ source.set(10);
255
+ expect(mapped.get()).toBe(16);
256
+
257
+ source.set(3);
258
+ expect(mapped.get()).toBe(19);
259
+ });
260
+
261
+ test("mergeMap operator should work correctly", () => {
262
+ const source = signal(() => 1);
263
+ const merged = mergeMap({ target: source, mapper: (value) => signal(() => value * 10) });
264
+
265
+ expect(merged.get()).toBe(10);
266
+
267
+ source.set(3);
268
+ expect(merged.get()).toBe(30);
269
+
270
+ source.set(5);
271
+ expect(merged.get()).toBe(50);
272
+ });
273
+
274
+ test("switchMap operator should work correctly", () => {
275
+ const source = signal(() => 1);
276
+ const switched = switchMap({ target: source, mapper: (value) => signal(() => value + 5) });
277
+
278
+ expect(switched.get()).toBe(6);
279
+
280
+ source.set(4);
281
+ expect(switched.get()).toBe(9);
282
+
283
+ source.set(10);
284
+ expect(switched.get()).toBe(15);
285
+ });
286
+
287
+ test("scan operator should work correctly", () => {
288
+ const source = signal(() => 1);
289
+ const scanned = scan({ target: source, accumulator: (acc, value) => acc + value, seed: 0 });
290
+
291
+ expect(scanned.get()).toBe(1);
292
+
293
+ source.set(2);
294
+ expect(scanned.get()).toBe(3);
295
+
296
+ source.set(3);
297
+ expect(scanned.get()).toBe(6);
298
+ });
299
+
300
+ test("pairwise operator should work correctly", () => {
301
+ const source = signal(() => 1);
302
+ const paired = pairwise({ target: source });
303
+
304
+ expect(paired.get()).toEqual([undefined, 1]);
305
+
306
+ source.set(2);
307
+ expect(paired.get()).toEqual([1, 2]);
308
+
309
+ source.set(3);
310
+ expect(paired.get()).toEqual([2, 3]);
311
+ });
312
+
313
+ test("partition operator should work correctly", () => {
314
+ const source = signal(() => 1);
315
+ const [even, odd] = partition({ target: source, predicate: (value) => value % 2 === 0 });
316
+
317
+ expect(even.get()).toBe(undefined);
318
+ expect(odd.get()).toBe(1);
319
+
320
+ source.set(2);
321
+ expect(even.get()).toBe(2);
322
+ expect(odd.get()).toBe(1);
323
+
324
+ source.set(3);
325
+ expect(even.get()).toBe(2);
326
+ expect(odd.get()).toBe(3);
327
+ })
@@ -0,0 +1,55 @@
1
+ import { expect, test } from 'vitest';
2
+
3
+ import { getValuesInArray, getValuesInObject, signal, subscribe } from '#Source/reactor/index.ts';
4
+
5
+ test("subscribe operator should skip first value", () => {
6
+ const a = signal(() => 0);
7
+
8
+ let consumerRunTimes = 0;
9
+ const unsubscribe = subscribe({
10
+ target: a,
11
+ subscriber: (value) => {
12
+ consumerRunTimes = consumerRunTimes + 1;
13
+ expect(value).toBe(1);
14
+ }
15
+ });
16
+
17
+ a.set(1);
18
+ expect(consumerRunTimes).toBe(1);
19
+ unsubscribe();
20
+
21
+ a.set(2);
22
+ expect(consumerRunTimes).toBe(1);
23
+ });
24
+
25
+ test("getValuesInArray operator should work correctly", () => {
26
+ const a = signal(() => 1);
27
+ const b = signal(() => 2);
28
+ const c = signal(() => 3);
29
+
30
+ const values = getValuesInArray({ target: [a, b, c] });
31
+ expect(values).toEqual([1, 2, 3]);
32
+
33
+ a.set(4);
34
+ b.set(5);
35
+ c.set(6);
36
+
37
+ const newValues = getValuesInArray({ target: [a, b, c] });
38
+ expect(newValues).toEqual([4, 5, 6]);
39
+ });
40
+
41
+ test("getValuesInObject operator should work correctly", () => {
42
+ const a = signal(() => 1);
43
+ const b = signal(() => 2);
44
+ const c = signal(() => 3);
45
+
46
+ const values = getValuesInObject({ target: { a, b, c } });
47
+ expect(values).toEqual({ a: 1, b: 2, c: 3 });
48
+
49
+ a.set(4);
50
+ b.set(5);
51
+ c.set(6);
52
+
53
+ const newValues = getValuesInObject({ target: { a, b, c } });
54
+ expect(newValues).toEqual({ a: 4, b: 5, c: 6 });
55
+ });
@@ -1,3 +0,0 @@
1
- export * from "./signal-core/index.ts";
2
- export * from "./signal-operators/index.ts";
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signal/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA;AACtC,cAAc,6BAA6B,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"flags.d.ts","sourceRoot":"","sources":["../../../src/signal/signal-core/flags.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;IACpB;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAGH;;;;;;;;;;;;OAYG;;IAEH;;OAEG;;CAEK,CAAC;AAEX,eAAO,MAAM,UAAU,4BAEtB,CAAA;AACD,eAAO,MAAM,UAAU,wCAEtB,CAAA;AACD,eAAO,MAAM,YAAY,2BAExB,CAAA;AACD,eAAO,MAAM,aAAa,2BAEzB,CAAA;AACD,eAAO,MAAM,QAAQ,4BAEpB,CAAA;AACD,eAAO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IAAI,IAAI,CAGjB;IACD,YAAY,IAAI,IAAI,CAGnB;IACD,aAAa,IAAI,IAAI,CAGpB;IAED,WAAW,IAAI,OAAO,CAErB;IACD,WAAW,IAAI,IAAI,CAGlB;IACD,aAAa,IAAI,IAAI,CAGpB;IACD,cAAc,IAAI,IAAI,CAGrB;IAED,WAAW,IAAI,OAAO,CAErB;IACD,WAAW,IAAI,IAAI,CAGlB;IACD,aAAa,IAAI,IAAI,CAGpB;IACD,cAAc,IAAI,IAAI,CAGrB;IAED,kBAAkB,IAAI,OAAO,CAE5B;IACD,kBAAkB,IAAI,IAAI,CAGzB;IACD,oBAAoB,IAAI,IAAI,CAG3B;IACD,qBAAqB,IAAI,IAAI,CAG5B;IAED,QAAQ,IAAI,MAAM,CA2BjB;CACF;AAED,eAAO,MAAM,KAAK,uCAMjB,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signal/signal-core/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,sBAAsB,CAAA;AACpC,cAAc,gBAAgB,CAAA"}
@@ -1,67 +0,0 @@
1
- import type { Flags } from "./flags.ts";
2
- import type { Link, Node } from "./reactive-system.ts";
3
- export declare const startBatch: () => void;
4
- export declare const endBatch: () => void;
5
- /**
6
- * Signal 的值只有在被获取的时候才会更新。
7
- */
8
- export declare class Signal<T = unknown> implements Node {
9
- headSubLink: Link | undefined;
10
- tailSubLink: Link | undefined;
11
- flags: Flags;
12
- value: T;
13
- pendingValue: T;
14
- constructor(value: T);
15
- get(): T;
16
- set(value: T): void;
17
- /**
18
- * 返回值表示更新前后值是否变化。
19
- */
20
- update(): boolean;
21
- stop(): void;
22
- }
23
- /**
24
- * Computed 的值只有在被获取的时候才会更新。
25
- * Computed 的值只有在上游节点的值发生变化时才会更新。
26
- * Computed 的下游节点全部解除连接时会自动与所有上游节点解除连接,并回到初始状态。
27
- */
28
- export declare class Computed<T = unknown> implements Node {
29
- headDepLink: Link | undefined;
30
- tailDepLink: Link | undefined;
31
- headSubLink: Link | undefined;
32
- tailSubLink: Link | undefined;
33
- flags: Flags;
34
- value: T;
35
- getValue: () => T;
36
- constructor(getValue: () => T);
37
- get(): T;
38
- /**
39
- * 返回值表示更新前后值是否变化。
40
- */
41
- update(): boolean;
42
- stop(): void;
43
- }
44
- /**
45
- * Effect 会在创建时立即执行一次传入的函数。
46
- * Effect 会在每次上游节点的值发生变化时重新执行传入的函数。
47
- * Effect 在任意时刻最多只能一个待运行。
48
- * Effect 可以与 Effect 建立连接。
49
- * 作为上游节点的 Effect 在没有下游节点时会自动与所有上游节点解除连接,并将标记清空。
50
- */
51
- export declare class Effect implements Node {
52
- headDepLink: Link | undefined;
53
- tailDepLink: Link | undefined;
54
- headSubLink: Link | undefined;
55
- tailSubLink: Link | undefined;
56
- flags: Flags;
57
- fn: () => void;
58
- constructor(fn: () => void);
59
- notify(): void;
60
- run(): void;
61
- private internalRun;
62
- stop(): void;
63
- }
64
- export declare const signal: <T>(initialValue: T) => Signal<T>;
65
- export declare const computed: <T>(getter: () => T) => Computed<T>;
66
- export declare const effect: (fn: () => void) => Effect;
67
- //# sourceMappingURL=primitive.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"primitive.d.ts","sourceRoot":"","sources":["../../../src/signal/signal-core/primitive.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAGvC,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAYtD,eAAO,MAAM,UAAU,YAEtB,CAAA;AACD,eAAO,MAAM,QAAQ,YAKpB,CAAA;AAmCD;;GAEG;AACH,qBAAa,MAAM,CAAC,CAAC,GAAG,OAAO,CAAE,YAAW,IAAI;IAC9C,WAAW,EAAE,IAAI,GAAG,SAAS,CAAC;IAC9B,WAAW,EAAE,IAAI,GAAG,SAAS,CAAC;IAC9B,KAAK,EAAE,K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GAAI,CAAC,+BAEvB,CAAA;AACD,eAAO,MAAM,QAAQ,GAAI,CAAC,iCAEzB,CAAA;AACD,eAAO,MAAM,MAAM,4BAElB,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"reactive-system.d.ts","sourceRoot":"","sources":["../../../src/signal/signal-core/reactive-system.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAEvC,MAAM,WAAW,IAAI;IACnB;;OAEG;IACH,WAAW,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IAC/B;;OAEG;IACH,WAAW,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IAE/B;;OAEG;IACH,WAAW,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IAC/B;;OAEG;IACH,WAAW,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IAE/B;;OAEG;IACH,KAAK,EAAE,KAAK,CAAC;CACd;AACD;;;;;;;GAOG;AACH,MAAM,WAAW,IAAI;IACnB;;OAEG;IACH,GAAG,EAAE,IAAI,CAAC;IACV;;OAEG;IACH,WAAW,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IAC/B;;OAEG;IACH,WAAW,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IAE/B;;OAEG;IACH,GAAG,EAAE,IAAI,CAAC;IACV;;OAEG;IACH,WAAW,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IAC/B;;OAEG;IACH,WAAW,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;CAChC;AAED,MAAM,WAAW,2BAA2B;IAC1C;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,IAAI,GAAG,OAAO,CAAC;IAC3B;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;CAC7B;AACD,MAAM,WAAW,cAAc;IAC7B;;OA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AAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAC5C;;OAEG;IACH,4BAA4B,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,GAAG,IAAI,CAAC;IACzD;;OAEG;IACH,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAExB;;OAEG;IACH,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IACnC;;OAEG;IACH,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IACnC;;OAEG;IACH,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;CAClC;AACD,eAAO,MAAM,oBAAoB,0DA0ehC,CAAA"}
@@ -1,4 +0,0 @@
1
- import type { Signal } from "#Source/index.ts";
2
- export declare const withHistory: <T>(orginal: Signal<T>) => Signal<T[]>;
3
- export declare const zip: <T, U>(signal1: Signal<T>, signal2: Signal<U>) => Signal<[T, U]>;
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signal/signal-operators/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAG9C,eAAO,MAAM,WAAW,GAAI,CAAC,oCAO5B,CAAA;AAED,eAAO,MAAM,GAAG,GAAI,CAAC,EAAE,CAAC,2DAMvB,CAAA"}
@@ -1,2 +0,0 @@
1
- export * from "./signal-core/index.ts"
2
- export * from "./signal-operators/index.ts"
@@ -1,4 +0,0 @@
1
- # Signals
2
-
3
- - https://github.com/stackblitz/alien-signals
4
- - https://github.com/johnsoncodehk/alien-signals-starter