atom.io 0.6.3 → 0.6.5
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/index.d.mts +25 -13
- package/dist/index.d.ts +25 -13
- package/dist/index.js +106 -50
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +103 -47
- package/dist/index.mjs.map +1 -1
- package/json/package.json +13 -13
- package/package.json +23 -15
- package/react/dist/index.d.mts +1 -1
- package/react/dist/index.d.ts +1 -1
- package/react/dist/index.js +8 -4
- package/react/dist/index.js.map +1 -1
- package/react/dist/index.mjs +8 -4
- package/react/dist/index.mjs.map +1 -1
- package/react/package.json +13 -13
- package/react-devtools/dist/index.js +693 -181
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/dist/index.mjs +689 -177
- package/react-devtools/dist/index.mjs.map +1 -1
- package/react-devtools/package.json +13 -13
- package/realtime/dist/index.js.map +1 -1
- package/realtime/dist/index.mjs.map +1 -1
- package/realtime/package.json +13 -13
- package/realtime-react/dist/index.js +14 -10
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-react/dist/index.mjs +14 -10
- package/realtime-react/dist/index.mjs.map +1 -1
- package/realtime-react/package.json +13 -13
- package/realtime-testing/dist/index.d.mts +1 -1
- package/realtime-testing/dist/index.d.ts +1 -1
- package/realtime-testing/dist/index.js +14 -2
- package/realtime-testing/dist/index.js.map +1 -1
- package/realtime-testing/dist/index.mjs +14 -2
- package/realtime-testing/dist/index.mjs.map +1 -1
- package/realtime-testing/package.json +13 -13
- package/src/atom.ts +2 -3
- package/src/internal/atom-internal.ts +3 -3
- package/src/internal/families-internal.ts +4 -5
- package/src/internal/index.ts +1 -0
- package/src/internal/selector/create-read-write-selector.ts +2 -2
- package/src/internal/selector/create-readonly-selector.ts +2 -2
- package/src/internal/selector-internal.ts +3 -4
- package/src/internal/store.ts +10 -10
- package/src/internal/subject.ts +24 -0
- package/src/internal/timeline-internal.ts +3 -4
- package/src/internal/transaction-internal.ts +3 -3
- package/src/react/store-context.tsx +1 -2
- package/src/react/store-hooks.ts +1 -2
- package/src/react-devtools/AtomIODevtools.tsx +2 -3
- package/src/react-devtools/StateEditor.tsx +1 -2
- package/src/react-devtools/TokenList.tsx +2 -3
- package/src/react-explorer/AtomIOExplorer.tsx +1 -2
- package/src/react-explorer/explorer-effects.ts +3 -3
- package/src/react-explorer/space-states.ts +3 -3
- package/src/realtime-react/realtime-context.tsx +1 -2
- package/src/realtime-react/use-pull-family-member.ts +1 -2
- package/src/realtime-react/use-pull-family.ts +1 -2
- package/src/realtime-react/use-pull.ts +1 -2
- package/src/realtime-react/use-push.ts +1 -2
- package/src/realtime-react/use-server-action.ts +1 -2
- package/src/realtime-testing/setup-realtime-test.tsx +1 -2
- package/src/selector.ts +3 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as Rx from 'rxjs';
|
|
2
1
|
import { Hamt } from 'hamt_plus';
|
|
3
2
|
import { Refinement } from 'fp-ts/lib/Refinement';
|
|
4
3
|
|
|
@@ -85,10 +84,10 @@ interface Store {
|
|
|
85
84
|
transactions: Hamt<Transaction<any>, string>;
|
|
86
85
|
valueMap: Hamt<any, string>;
|
|
87
86
|
subject: {
|
|
88
|
-
atomCreation:
|
|
89
|
-
selectorCreation:
|
|
90
|
-
transactionCreation:
|
|
91
|
-
timelineCreation:
|
|
87
|
+
atomCreation: Subject<AtomToken<unknown>>;
|
|
88
|
+
selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
|
|
89
|
+
transactionCreation: Subject<TransactionToken<unknown>>;
|
|
90
|
+
timelineCreation: Subject<TimelineToken>;
|
|
92
91
|
};
|
|
93
92
|
operation: OperationProgress;
|
|
94
93
|
transactionStatus: TransactionStatus<ƒn>;
|
|
@@ -127,7 +126,7 @@ type AtomFamilyOptions<T, K extends Serializable> = {
|
|
|
127
126
|
type AtomFamily<T, K extends Serializable = Serializable> = ((key: K) => AtomToken<T>) & {
|
|
128
127
|
key: string;
|
|
129
128
|
type: `atom_family`;
|
|
130
|
-
subject:
|
|
129
|
+
subject: Subject<AtomToken<T>>;
|
|
131
130
|
};
|
|
132
131
|
declare function atomFamily<T, K extends Serializable>(options: AtomFamilyOptions<T, K>): AtomFamily<T, K>;
|
|
133
132
|
|
|
@@ -135,7 +134,7 @@ type Atom<T> = {
|
|
|
135
134
|
key: string;
|
|
136
135
|
type: `atom`;
|
|
137
136
|
family?: FamilyMetadata;
|
|
138
|
-
subject:
|
|
137
|
+
subject: Subject<{
|
|
139
138
|
newValue: T;
|
|
140
139
|
oldValue: T;
|
|
141
140
|
}>;
|
|
@@ -229,7 +228,7 @@ type Selector<T> = {
|
|
|
229
228
|
type: `selector`;
|
|
230
229
|
family?: FamilyMetadata;
|
|
231
230
|
install: (store: Store) => void;
|
|
232
|
-
subject:
|
|
231
|
+
subject: Subject<{
|
|
233
232
|
newValue: T;
|
|
234
233
|
oldValue: T;
|
|
235
234
|
}>;
|
|
@@ -241,7 +240,7 @@ type ReadonlySelector<T> = {
|
|
|
241
240
|
type: `readonly_selector`;
|
|
242
241
|
family?: FamilyMetadata;
|
|
243
242
|
install: (store: Store) => void;
|
|
244
|
-
subject:
|
|
243
|
+
subject: Subject<{
|
|
245
244
|
newValue: T;
|
|
246
245
|
oldValue: T;
|
|
247
246
|
}>;
|
|
@@ -290,6 +289,16 @@ declare const setAtomState: <T>(atom: Atom<T>, next: T | ((oldValue: T) => T), s
|
|
|
290
289
|
declare const setSelectorState: <T>(selector: Selector<T>, next: T | ((oldValue: T) => T), store?: Store) => void;
|
|
291
290
|
declare const setState__INTERNAL: <T>(state: Atom<T> | Selector<T>, value: T | ((oldValue: T) => T), store?: Store) => void;
|
|
292
291
|
|
|
292
|
+
type Subscriber<T> = (value: T) => void;
|
|
293
|
+
declare class Subject<T> {
|
|
294
|
+
subscribers: Subscriber<T>[];
|
|
295
|
+
subscribe(subscriber: Subscriber<T>): {
|
|
296
|
+
unsubscribe: () => void;
|
|
297
|
+
};
|
|
298
|
+
private unsubscribe;
|
|
299
|
+
next(value: T): void;
|
|
300
|
+
}
|
|
301
|
+
|
|
293
302
|
declare const prepareUpdate: <T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>, store: Store) => StateUpdate<T>;
|
|
294
303
|
declare const stowUpdate: <T>(state: Atom<T>, update: StateUpdate<T>, store: Store) => void;
|
|
295
304
|
declare const emitUpdate: <T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>, update: StateUpdate<T>, store: Store) => void;
|
|
@@ -324,7 +333,7 @@ type Timeline = {
|
|
|
324
333
|
selectorTime: number | null;
|
|
325
334
|
transactionKey: string | null;
|
|
326
335
|
install: (store: Store) => void;
|
|
327
|
-
subject:
|
|
336
|
+
subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate>;
|
|
328
337
|
};
|
|
329
338
|
declare function timeline__INTERNAL(options: TimelineOptions, store?: Store, data?: Timeline | null): TimelineToken;
|
|
330
339
|
|
|
@@ -332,7 +341,7 @@ type Transaction<ƒ extends ƒn> = {
|
|
|
332
341
|
key: string;
|
|
333
342
|
type: `transaction`;
|
|
334
343
|
install: (store: Store) => void;
|
|
335
|
-
subject:
|
|
344
|
+
subject: Subject<TransactionUpdate<ƒ>>;
|
|
336
345
|
run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
337
346
|
};
|
|
338
347
|
declare function transaction__INTERNAL<ƒ extends ƒn>(options: TransactionOptions<ƒ>, store?: Store): TransactionToken<ƒ>;
|
|
@@ -367,6 +376,8 @@ type index_ReadonlySelector<T> = ReadonlySelector<T>;
|
|
|
367
376
|
type index_Selector<T> = Selector<T>;
|
|
368
377
|
type index_Store = Store;
|
|
369
378
|
type index_StoreCore = StoreCore;
|
|
379
|
+
type index_Subject<T> = Subject<T>;
|
|
380
|
+
declare const index_Subject: typeof Subject;
|
|
370
381
|
declare const index_TRANSACTION_PHASES: typeof TRANSACTION_PHASES;
|
|
371
382
|
type index_Timeline = Timeline;
|
|
372
383
|
type index_TimelineAtomUpdate = TimelineAtomUpdate;
|
|
@@ -439,6 +450,7 @@ declare namespace index {
|
|
|
439
450
|
index_Selector as Selector,
|
|
440
451
|
index_Store as Store,
|
|
441
452
|
index_StoreCore as StoreCore,
|
|
453
|
+
index_Subject as Subject,
|
|
442
454
|
index_TRANSACTION_PHASES as TRANSACTION_PHASES,
|
|
443
455
|
index_Timeline as Timeline,
|
|
444
456
|
index_TimelineAtomUpdate as TimelineAtomUpdate,
|
|
@@ -532,12 +544,12 @@ type ReadonlySelectorFamilyOptions<T, K extends Serializable> = {
|
|
|
532
544
|
type SelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => SelectorToken<T>) & {
|
|
533
545
|
key: string;
|
|
534
546
|
type: `selector_family`;
|
|
535
|
-
subject:
|
|
547
|
+
subject: Subject<SelectorToken<T>>;
|
|
536
548
|
};
|
|
537
549
|
type ReadonlySelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => ReadonlySelectorToken<T>) & {
|
|
538
550
|
key: string;
|
|
539
551
|
type: `readonly_selector_family`;
|
|
540
|
-
subject:
|
|
552
|
+
subject: Subject<ReadonlySelectorToken<T>>;
|
|
541
553
|
};
|
|
542
554
|
declare function selectorFamily<T, K extends Serializable>(options: SelectorFamilyOptions<T, K>): SelectorFamily<T, K>;
|
|
543
555
|
declare function selectorFamily<T, K extends Serializable>(options: ReadonlySelectorFamilyOptions<T, K>): ReadonlySelectorFamily<T, K>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as Rx from 'rxjs';
|
|
2
1
|
import { Hamt } from 'hamt_plus';
|
|
3
2
|
import { Refinement } from 'fp-ts/lib/Refinement';
|
|
4
3
|
|
|
@@ -85,10 +84,10 @@ interface Store {
|
|
|
85
84
|
transactions: Hamt<Transaction<any>, string>;
|
|
86
85
|
valueMap: Hamt<any, string>;
|
|
87
86
|
subject: {
|
|
88
|
-
atomCreation:
|
|
89
|
-
selectorCreation:
|
|
90
|
-
transactionCreation:
|
|
91
|
-
timelineCreation:
|
|
87
|
+
atomCreation: Subject<AtomToken<unknown>>;
|
|
88
|
+
selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
|
|
89
|
+
transactionCreation: Subject<TransactionToken<unknown>>;
|
|
90
|
+
timelineCreation: Subject<TimelineToken>;
|
|
92
91
|
};
|
|
93
92
|
operation: OperationProgress;
|
|
94
93
|
transactionStatus: TransactionStatus<ƒn>;
|
|
@@ -127,7 +126,7 @@ type AtomFamilyOptions<T, K extends Serializable> = {
|
|
|
127
126
|
type AtomFamily<T, K extends Serializable = Serializable> = ((key: K) => AtomToken<T>) & {
|
|
128
127
|
key: string;
|
|
129
128
|
type: `atom_family`;
|
|
130
|
-
subject:
|
|
129
|
+
subject: Subject<AtomToken<T>>;
|
|
131
130
|
};
|
|
132
131
|
declare function atomFamily<T, K extends Serializable>(options: AtomFamilyOptions<T, K>): AtomFamily<T, K>;
|
|
133
132
|
|
|
@@ -135,7 +134,7 @@ type Atom<T> = {
|
|
|
135
134
|
key: string;
|
|
136
135
|
type: `atom`;
|
|
137
136
|
family?: FamilyMetadata;
|
|
138
|
-
subject:
|
|
137
|
+
subject: Subject<{
|
|
139
138
|
newValue: T;
|
|
140
139
|
oldValue: T;
|
|
141
140
|
}>;
|
|
@@ -229,7 +228,7 @@ type Selector<T> = {
|
|
|
229
228
|
type: `selector`;
|
|
230
229
|
family?: FamilyMetadata;
|
|
231
230
|
install: (store: Store) => void;
|
|
232
|
-
subject:
|
|
231
|
+
subject: Subject<{
|
|
233
232
|
newValue: T;
|
|
234
233
|
oldValue: T;
|
|
235
234
|
}>;
|
|
@@ -241,7 +240,7 @@ type ReadonlySelector<T> = {
|
|
|
241
240
|
type: `readonly_selector`;
|
|
242
241
|
family?: FamilyMetadata;
|
|
243
242
|
install: (store: Store) => void;
|
|
244
|
-
subject:
|
|
243
|
+
subject: Subject<{
|
|
245
244
|
newValue: T;
|
|
246
245
|
oldValue: T;
|
|
247
246
|
}>;
|
|
@@ -290,6 +289,16 @@ declare const setAtomState: <T>(atom: Atom<T>, next: T | ((oldValue: T) => T), s
|
|
|
290
289
|
declare const setSelectorState: <T>(selector: Selector<T>, next: T | ((oldValue: T) => T), store?: Store) => void;
|
|
291
290
|
declare const setState__INTERNAL: <T>(state: Atom<T> | Selector<T>, value: T | ((oldValue: T) => T), store?: Store) => void;
|
|
292
291
|
|
|
292
|
+
type Subscriber<T> = (value: T) => void;
|
|
293
|
+
declare class Subject<T> {
|
|
294
|
+
subscribers: Subscriber<T>[];
|
|
295
|
+
subscribe(subscriber: Subscriber<T>): {
|
|
296
|
+
unsubscribe: () => void;
|
|
297
|
+
};
|
|
298
|
+
private unsubscribe;
|
|
299
|
+
next(value: T): void;
|
|
300
|
+
}
|
|
301
|
+
|
|
293
302
|
declare const prepareUpdate: <T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>, store: Store) => StateUpdate<T>;
|
|
294
303
|
declare const stowUpdate: <T>(state: Atom<T>, update: StateUpdate<T>, store: Store) => void;
|
|
295
304
|
declare const emitUpdate: <T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>, update: StateUpdate<T>, store: Store) => void;
|
|
@@ -324,7 +333,7 @@ type Timeline = {
|
|
|
324
333
|
selectorTime: number | null;
|
|
325
334
|
transactionKey: string | null;
|
|
326
335
|
install: (store: Store) => void;
|
|
327
|
-
subject:
|
|
336
|
+
subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate>;
|
|
328
337
|
};
|
|
329
338
|
declare function timeline__INTERNAL(options: TimelineOptions, store?: Store, data?: Timeline | null): TimelineToken;
|
|
330
339
|
|
|
@@ -332,7 +341,7 @@ type Transaction<ƒ extends ƒn> = {
|
|
|
332
341
|
key: string;
|
|
333
342
|
type: `transaction`;
|
|
334
343
|
install: (store: Store) => void;
|
|
335
|
-
subject:
|
|
344
|
+
subject: Subject<TransactionUpdate<ƒ>>;
|
|
336
345
|
run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
337
346
|
};
|
|
338
347
|
declare function transaction__INTERNAL<ƒ extends ƒn>(options: TransactionOptions<ƒ>, store?: Store): TransactionToken<ƒ>;
|
|
@@ -367,6 +376,8 @@ type index_ReadonlySelector<T> = ReadonlySelector<T>;
|
|
|
367
376
|
type index_Selector<T> = Selector<T>;
|
|
368
377
|
type index_Store = Store;
|
|
369
378
|
type index_StoreCore = StoreCore;
|
|
379
|
+
type index_Subject<T> = Subject<T>;
|
|
380
|
+
declare const index_Subject: typeof Subject;
|
|
370
381
|
declare const index_TRANSACTION_PHASES: typeof TRANSACTION_PHASES;
|
|
371
382
|
type index_Timeline = Timeline;
|
|
372
383
|
type index_TimelineAtomUpdate = TimelineAtomUpdate;
|
|
@@ -439,6 +450,7 @@ declare namespace index {
|
|
|
439
450
|
index_Selector as Selector,
|
|
440
451
|
index_Store as Store,
|
|
441
452
|
index_StoreCore as StoreCore,
|
|
453
|
+
index_Subject as Subject,
|
|
442
454
|
index_TRANSACTION_PHASES as TRANSACTION_PHASES,
|
|
443
455
|
index_Timeline as Timeline,
|
|
444
456
|
index_TimelineAtomUpdate as TimelineAtomUpdate,
|
|
@@ -532,12 +544,12 @@ type ReadonlySelectorFamilyOptions<T, K extends Serializable> = {
|
|
|
532
544
|
type SelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => SelectorToken<T>) & {
|
|
533
545
|
key: string;
|
|
534
546
|
type: `selector_family`;
|
|
535
|
-
subject:
|
|
547
|
+
subject: Subject<SelectorToken<T>>;
|
|
536
548
|
};
|
|
537
549
|
type ReadonlySelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => ReadonlySelectorToken<T>) & {
|
|
538
550
|
key: string;
|
|
539
551
|
type: `readonly_selector_family`;
|
|
540
|
-
subject:
|
|
552
|
+
subject: Subject<ReadonlySelectorToken<T>>;
|
|
541
553
|
};
|
|
542
554
|
declare function selectorFamily<T, K extends Serializable>(options: SelectorFamilyOptions<T, K>): SelectorFamily<T, K>;
|
|
543
555
|
declare function selectorFamily<T, K extends Serializable>(options: ReadonlySelectorFamilyOptions<T, K>): ReadonlySelectorFamily<T, K>;
|
package/dist/index.js
CHANGED
|
@@ -89,6 +89,7 @@ var internal_exports = {};
|
|
|
89
89
|
__export(internal_exports, {
|
|
90
90
|
IMPLICIT: () => IMPLICIT,
|
|
91
91
|
META: () => meta_exports,
|
|
92
|
+
Subject: () => Subject,
|
|
92
93
|
TRANSACTION_PHASES: () => TRANSACTION_PHASES,
|
|
93
94
|
abortTransaction: () => abortTransaction,
|
|
94
95
|
applyTransaction: () => applyTransaction,
|
|
@@ -146,7 +147,6 @@ __export(internal_exports, {
|
|
|
146
147
|
|
|
147
148
|
// src/internal/atom-internal.ts
|
|
148
149
|
var import_hamt_plus5 = __toESM(require("hamt_plus"));
|
|
149
|
-
var Rx3 = __toESM(require("rxjs"));
|
|
150
150
|
|
|
151
151
|
// src/internal/get.ts
|
|
152
152
|
var import_hamt_plus = __toESM(require("hamt_plus"));
|
|
@@ -207,7 +207,6 @@ var import_hamt_plus3 = __toESM(require("hamt_plus"));
|
|
|
207
207
|
|
|
208
208
|
// src/internal/store.ts
|
|
209
209
|
var import_hamt_plus2 = __toESM(require("hamt_plus"));
|
|
210
|
-
var Rx = __toESM(require("rxjs"));
|
|
211
210
|
|
|
212
211
|
// ../anvl/src/function/index.ts
|
|
213
212
|
var doNothing = () => void 0;
|
|
@@ -216,8 +215,62 @@ var become = (nextVersionOfThing) => (originalThing) => nextVersionOfThing insta
|
|
|
216
215
|
) : nextVersionOfThing;
|
|
217
216
|
var pass = (...params) => (fn) => fn(...params);
|
|
218
217
|
|
|
219
|
-
//
|
|
220
|
-
|
|
218
|
+
// ../../node_modules/.pnpm/fp-ts@2.16.0/node_modules/fp-ts/es6/function.js
|
|
219
|
+
function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
|
|
220
|
+
switch (arguments.length) {
|
|
221
|
+
case 1:
|
|
222
|
+
return a;
|
|
223
|
+
case 2:
|
|
224
|
+
return ab(a);
|
|
225
|
+
case 3:
|
|
226
|
+
return bc(ab(a));
|
|
227
|
+
case 4:
|
|
228
|
+
return cd(bc(ab(a)));
|
|
229
|
+
case 5:
|
|
230
|
+
return de(cd(bc(ab(a))));
|
|
231
|
+
case 6:
|
|
232
|
+
return ef(de(cd(bc(ab(a)))));
|
|
233
|
+
case 7:
|
|
234
|
+
return fg(ef(de(cd(bc(ab(a))))));
|
|
235
|
+
case 8:
|
|
236
|
+
return gh(fg(ef(de(cd(bc(ab(a)))))));
|
|
237
|
+
case 9:
|
|
238
|
+
return hi(gh(fg(ef(de(cd(bc(ab(a))))))));
|
|
239
|
+
default: {
|
|
240
|
+
var ret = arguments[0];
|
|
241
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
242
|
+
ret = arguments[i](ret);
|
|
243
|
+
}
|
|
244
|
+
return ret;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// ../../node_modules/.pnpm/fp-ts@2.16.0/node_modules/fp-ts/es6/string.js
|
|
250
|
+
var Eq = {
|
|
251
|
+
equals: function(first, second) {
|
|
252
|
+
return first === second;
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
var Semigroup = {
|
|
256
|
+
concat: function(first, second) {
|
|
257
|
+
return first + second;
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
var empty = "";
|
|
261
|
+
var Monoid = {
|
|
262
|
+
concat: Semigroup.concat,
|
|
263
|
+
empty
|
|
264
|
+
};
|
|
265
|
+
var Ord = {
|
|
266
|
+
equals: Eq.equals,
|
|
267
|
+
compare: function(first, second) {
|
|
268
|
+
return first < second ? -1 : first > second ? 1 : 0;
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
var isString = function(u) {
|
|
272
|
+
return typeof u === "string";
|
|
273
|
+
};
|
|
221
274
|
|
|
222
275
|
// ../anvl/src/array/venn.ts
|
|
223
276
|
var includesAll = (items) => (array) => {
|
|
@@ -238,9 +291,6 @@ var addTo = (a) => (x) => a.includes(x) ? a : [...a, x];
|
|
|
238
291
|
var isEmptyArray = (input) => Array.isArray(input) && input.length === 0;
|
|
239
292
|
var isOneOf = (...args) => (input) => args.includes(input);
|
|
240
293
|
|
|
241
|
-
// ../anvl/src/object/refinement.ts
|
|
242
|
-
var import_function2 = require("fp-ts/function");
|
|
243
|
-
|
|
244
294
|
// ../anvl/src/object/access.ts
|
|
245
295
|
var access = (k) => Object.assign((obj) => obj[k], {
|
|
246
296
|
in: (obj) => obj[k]
|
|
@@ -251,8 +301,7 @@ var recordToEntries = (obj) => Object.entries(obj);
|
|
|
251
301
|
var entriesToRecord = (entries) => Object.fromEntries(entries);
|
|
252
302
|
|
|
253
303
|
// ../anvl/src/object/mapObject.ts
|
|
254
|
-
var
|
|
255
|
-
var mapObject = (obj, fn) => (0, import_function.pipe)(
|
|
304
|
+
var mapObject = (obj, fn) => pipe(
|
|
256
305
|
obj,
|
|
257
306
|
recordToEntries,
|
|
258
307
|
map(([key, val]) => [key, fn(val, key)]),
|
|
@@ -274,14 +323,14 @@ var hasProperties = (isValue, options = { allowExtraProperties: false }) => {
|
|
|
274
323
|
isValue
|
|
275
324
|
).map(([k, v]) => String(k) + `:` + v.name).join(`,`)}}`;
|
|
276
325
|
const _ = {
|
|
277
|
-
[name]: (input) => isPlainObject(input) &&
|
|
326
|
+
[name]: (input) => isPlainObject(input) && pipe(
|
|
278
327
|
isValue,
|
|
279
328
|
Object.entries,
|
|
280
329
|
every(([key, val]) => key in input || val(void 0))
|
|
281
|
-
) &&
|
|
330
|
+
) && pipe(
|
|
282
331
|
input,
|
|
283
332
|
mob(
|
|
284
|
-
(val, key) =>
|
|
333
|
+
(val, key) => pipe(
|
|
285
334
|
isValue,
|
|
286
335
|
access(key),
|
|
287
336
|
ifNullish(() => options.allowExtraProperties),
|
|
@@ -361,8 +410,8 @@ var isRelationData = ({
|
|
|
361
410
|
isContent
|
|
362
411
|
} = {}) => (input) => {
|
|
363
412
|
return hasExactProperties({
|
|
364
|
-
contents: isContent ? isRecord(
|
|
365
|
-
relations: isRecord(
|
|
413
|
+
contents: isContent ? isRecord(isString, isContent) : hasExactProperties({}),
|
|
414
|
+
relations: isRecord(isString, isArray(isString)),
|
|
366
415
|
relationType: isRelationType,
|
|
367
416
|
a: isLiteral(a),
|
|
368
417
|
b: isLiteral(b)
|
|
@@ -399,9 +448,6 @@ var makeJsonInterface = (join, ...params) => {
|
|
|
399
448
|
};
|
|
400
449
|
};
|
|
401
450
|
|
|
402
|
-
// ../anvl/src/join/relation-contents.ts
|
|
403
|
-
var import_function6 = require("fp-ts/function");
|
|
404
|
-
|
|
405
451
|
// ../anvl/src/join/relation-record.ts
|
|
406
452
|
var getRelationEntries = (relationMap, idA) => getRelatedIds(relationMap, idA).map((idB) => [
|
|
407
453
|
idB,
|
|
@@ -409,12 +455,7 @@ var getRelationEntries = (relationMap, idA) => getRelatedIds(relationMap, idA).m
|
|
|
409
455
|
]);
|
|
410
456
|
var getRelationRecord = (relationMap, id) => Object.fromEntries(getRelationEntries(relationMap, id));
|
|
411
457
|
|
|
412
|
-
// ../anvl/src/join/remove-relation.ts
|
|
413
|
-
var import_function5 = require("fp-ts/function");
|
|
414
|
-
var import_string2 = require("fp-ts/string");
|
|
415
|
-
|
|
416
458
|
// ../anvl/src/object/index.ts
|
|
417
|
-
var import_function4 = require("fp-ts/function");
|
|
418
459
|
var treeShake = (shouldDiscard = isUndefined) => (obj) => {
|
|
419
460
|
const newObj = {};
|
|
420
461
|
const entries = Object.entries(obj);
|
|
@@ -431,7 +472,7 @@ var split = (separator) => (str) => str.split(separator);
|
|
|
431
472
|
var removeSpecific = (current, idA, idB) => {
|
|
432
473
|
const isIdForRemoval = isOneOf(idA, idB);
|
|
433
474
|
return __spreadProps(__spreadValues({}, current), {
|
|
434
|
-
relations:
|
|
475
|
+
relations: pipe(
|
|
435
476
|
current.relations,
|
|
436
477
|
recordToEntries,
|
|
437
478
|
map(([id, relations]) => [
|
|
@@ -441,17 +482,17 @@ var removeSpecific = (current, idA, idB) => {
|
|
|
441
482
|
entriesToRecord,
|
|
442
483
|
treeShake(isEmptyArray)
|
|
443
484
|
),
|
|
444
|
-
contents:
|
|
485
|
+
contents: pipe(
|
|
445
486
|
current.contents,
|
|
446
487
|
treeShake(
|
|
447
|
-
(_, key) =>
|
|
488
|
+
(_, key) => isString(key) && pipe(key, split(`/`), comprises([idA, idB]))
|
|
448
489
|
)
|
|
449
490
|
)
|
|
450
491
|
});
|
|
451
492
|
};
|
|
452
493
|
var removeAll = (current, idToRemove) => {
|
|
453
494
|
const next = __spreadProps(__spreadValues({}, current), {
|
|
454
|
-
relations:
|
|
495
|
+
relations: pipe(
|
|
455
496
|
current.relations,
|
|
456
497
|
recordToEntries,
|
|
457
498
|
map(([id, relations]) => [
|
|
@@ -461,10 +502,10 @@ var removeAll = (current, idToRemove) => {
|
|
|
461
502
|
entriesToRecord,
|
|
462
503
|
treeShake((val, key) => key === idToRemove || isEmptyArray(val))
|
|
463
504
|
),
|
|
464
|
-
contents:
|
|
505
|
+
contents: pipe(
|
|
465
506
|
current.contents,
|
|
466
507
|
treeShake(
|
|
467
|
-
(_, key) =>
|
|
508
|
+
(_, key) => isString(key) && key.split(`/`).includes(idToRemove)
|
|
468
509
|
)
|
|
469
510
|
)
|
|
470
511
|
});
|
|
@@ -546,7 +587,7 @@ var getRelations = (relationMap, id) => getRelationEntries(relationMap, id).map(
|
|
|
546
587
|
var setRelations = (current, subject, relations) => {
|
|
547
588
|
const idA = subject[current.a];
|
|
548
589
|
const idB = subject[current.b];
|
|
549
|
-
return
|
|
590
|
+
return pipe(
|
|
550
591
|
current,
|
|
551
592
|
(relationData) => {
|
|
552
593
|
const relatedIds = getRelatedIds(current, idA);
|
|
@@ -674,10 +715,10 @@ var createStore = (name, store = null) => {
|
|
|
674
715
|
timelines: import_hamt_plus2.default.make(),
|
|
675
716
|
timelineAtoms: new Join({ relationType: `1:n` }).from(`timelineKey`).to(`atomKey`),
|
|
676
717
|
subject: __spreadValues({
|
|
677
|
-
atomCreation: new
|
|
678
|
-
selectorCreation: new
|
|
679
|
-
transactionCreation: new
|
|
680
|
-
timelineCreation: new
|
|
718
|
+
atomCreation: new Subject(),
|
|
719
|
+
selectorCreation: new Subject(),
|
|
720
|
+
transactionCreation: new Subject(),
|
|
721
|
+
timelineCreation: new Subject()
|
|
681
722
|
}, store == null ? void 0 : store.subject),
|
|
682
723
|
operation: __spreadValues({
|
|
683
724
|
open: false
|
|
@@ -695,7 +736,7 @@ var createStore = (name, store = null) => {
|
|
|
695
736
|
})
|
|
696
737
|
});
|
|
697
738
|
store == null ? void 0 : store.atoms.forEach((atom2) => {
|
|
698
|
-
const copiedAtom = __spreadProps(__spreadValues({}, atom2), { subject: new
|
|
739
|
+
const copiedAtom = __spreadProps(__spreadValues({}, atom2), { subject: new Subject() });
|
|
699
740
|
copiedStore.atoms = import_hamt_plus2.default.set(atom2.key, copiedAtom, copiedStore.atoms);
|
|
700
741
|
});
|
|
701
742
|
store == null ? void 0 : store.readonlySelectors.forEach((selector2) => {
|
|
@@ -818,7 +859,6 @@ var hasKeyBeenUsed = (key, store = IMPLICIT.STORE) => {
|
|
|
818
859
|
|
|
819
860
|
// src/internal/transaction-internal.ts
|
|
820
861
|
var import_hamt_plus4 = __toESM(require("hamt_plus"));
|
|
821
|
-
var Rx2 = __toESM(require("rxjs"));
|
|
822
862
|
function transaction__INTERNAL(options, store = IMPLICIT.STORE) {
|
|
823
863
|
const newTransaction = {
|
|
824
864
|
key: options.key,
|
|
@@ -843,7 +883,7 @@ function transaction__INTERNAL(options, store = IMPLICIT.STORE) {
|
|
|
843
883
|
}
|
|
844
884
|
},
|
|
845
885
|
install: (store2) => transaction__INTERNAL(options, store2),
|
|
846
|
-
subject: new
|
|
886
|
+
subject: new Subject()
|
|
847
887
|
};
|
|
848
888
|
const core = target(store);
|
|
849
889
|
core.transactions = import_hamt_plus4.default.set(
|
|
@@ -868,7 +908,7 @@ function atom__INTERNAL(options, family, store = IMPLICIT.STORE) {
|
|
|
868
908
|
);
|
|
869
909
|
return deposit(core.atoms.get(options.key));
|
|
870
910
|
}
|
|
871
|
-
const subject = new
|
|
911
|
+
const subject = new Subject();
|
|
872
912
|
const newAtom = __spreadValues(__spreadProps(__spreadValues({}, options), {
|
|
873
913
|
subject,
|
|
874
914
|
type: `atom`
|
|
@@ -888,16 +928,12 @@ function atom__INTERNAL(options, family, store = IMPLICIT.STORE) {
|
|
|
888
928
|
return token;
|
|
889
929
|
}
|
|
890
930
|
|
|
891
|
-
// src/internal/families-internal.ts
|
|
892
|
-
var Rx4 = __toESM(require("rxjs"));
|
|
893
|
-
|
|
894
931
|
// ../anvl/src/json/index.ts
|
|
895
|
-
var import_function8 = require("fp-ts/function");
|
|
896
932
|
var stringifyJson = (json) => JSON.stringify(json);
|
|
897
933
|
|
|
898
934
|
// src/internal/families-internal.ts
|
|
899
935
|
function atomFamily__INTERNAL(options, store = IMPLICIT.STORE) {
|
|
900
|
-
const subject = new
|
|
936
|
+
const subject = new Subject();
|
|
901
937
|
return Object.assign(
|
|
902
938
|
(key) => {
|
|
903
939
|
var _a;
|
|
@@ -926,7 +962,7 @@ function atomFamily__INTERNAL(options, store = IMPLICIT.STORE) {
|
|
|
926
962
|
}
|
|
927
963
|
function readonlySelectorFamily__INTERNAL(options, store) {
|
|
928
964
|
const core = target(store);
|
|
929
|
-
const subject = new
|
|
965
|
+
const subject = new Subject();
|
|
930
966
|
return Object.assign(
|
|
931
967
|
(key) => {
|
|
932
968
|
const subKey = stringifyJson(key);
|
|
@@ -958,7 +994,7 @@ function selectorFamily__INTERNAL(options, store = IMPLICIT.STORE) {
|
|
|
958
994
|
return readonlySelectorFamily__INTERNAL(options, store);
|
|
959
995
|
}
|
|
960
996
|
const core = target(store);
|
|
961
|
-
const subject = new
|
|
997
|
+
const subject = new Subject();
|
|
962
998
|
return Object.assign(
|
|
963
999
|
(key) => {
|
|
964
1000
|
const subKey = stringifyJson(key);
|
|
@@ -1106,10 +1142,9 @@ var import_hamt_plus9 = __toESM(require("hamt_plus"));
|
|
|
1106
1142
|
|
|
1107
1143
|
// src/internal/selector/create-read-write-selector.ts
|
|
1108
1144
|
var import_hamt_plus6 = __toESM(require("hamt_plus"));
|
|
1109
|
-
var Rx5 = __toESM(require("rxjs"));
|
|
1110
1145
|
var createReadWriteSelector = (options, family, store, core) => {
|
|
1111
1146
|
var _a;
|
|
1112
|
-
const subject = new
|
|
1147
|
+
const subject = new Subject();
|
|
1113
1148
|
const { get, set } = registerSelector(options.key, store);
|
|
1114
1149
|
const getSelf = () => {
|
|
1115
1150
|
const value = options.get({ get });
|
|
@@ -1149,7 +1184,6 @@ var createReadWriteSelector = (options, family, store, core) => {
|
|
|
1149
1184
|
|
|
1150
1185
|
// src/internal/selector/create-readonly-selector.ts
|
|
1151
1186
|
var import_hamt_plus8 = __toESM(require("hamt_plus"));
|
|
1152
|
-
var Rx6 = __toESM(require("rxjs"));
|
|
1153
1187
|
|
|
1154
1188
|
// src/internal/selector/lookup-selector-sources.ts
|
|
1155
1189
|
var lookupSelectorSources = (key, store) => target(store).selectorGraph.getRelations(key).filter(({ source }) => source !== key).map(({ source }) => lookup(source, store));
|
|
@@ -1326,7 +1360,7 @@ var registerSelector = (selectorKey, store = IMPLICIT.STORE) => ({
|
|
|
1326
1360
|
// src/internal/selector/create-readonly-selector.ts
|
|
1327
1361
|
var createReadonlySelector = (options, family, store, core) => {
|
|
1328
1362
|
var _a;
|
|
1329
|
-
const subject = new
|
|
1363
|
+
const subject = new Subject();
|
|
1330
1364
|
const { get } = registerSelector(options.key, store);
|
|
1331
1365
|
const getSelf = () => {
|
|
1332
1366
|
const value = options.get({ get });
|
|
@@ -1370,6 +1404,29 @@ function selector__INTERNAL(options, family, store = IMPLICIT.STORE) {
|
|
|
1370
1404
|
return createReadWriteSelector(options, family, store, core);
|
|
1371
1405
|
}
|
|
1372
1406
|
|
|
1407
|
+
// src/internal/subject.ts
|
|
1408
|
+
var Subject = class {
|
|
1409
|
+
constructor() {
|
|
1410
|
+
this.subscribers = [];
|
|
1411
|
+
}
|
|
1412
|
+
subscribe(subscriber) {
|
|
1413
|
+
this.subscribers.push(subscriber);
|
|
1414
|
+
const unsubscribe = () => this.unsubscribe(subscriber);
|
|
1415
|
+
return { unsubscribe };
|
|
1416
|
+
}
|
|
1417
|
+
unsubscribe(subscriber) {
|
|
1418
|
+
const subscriberIndex = this.subscribers.indexOf(subscriber);
|
|
1419
|
+
if (subscriberIndex !== -1) {
|
|
1420
|
+
this.subscribers.splice(subscriberIndex, 1);
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
next(value) {
|
|
1424
|
+
for (const subscriber of this.subscribers) {
|
|
1425
|
+
subscriber(value);
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
};
|
|
1429
|
+
|
|
1373
1430
|
// src/internal/subscribe-internal.ts
|
|
1374
1431
|
var prepareUpdate = (state, store) => {
|
|
1375
1432
|
const oldValue = recallState(state, store);
|
|
@@ -1509,7 +1566,6 @@ var undo__INTERNAL = (token, store = IMPLICIT.STORE) => {
|
|
|
1509
1566
|
|
|
1510
1567
|
// src/internal/timeline-internal.ts
|
|
1511
1568
|
var import_hamt_plus10 = __toESM(require("hamt_plus"));
|
|
1512
|
-
var Rx7 = __toESM(require("rxjs"));
|
|
1513
1569
|
|
|
1514
1570
|
// src/internal/timeline/add-atom-to-timeline.ts
|
|
1515
1571
|
var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
|
|
@@ -1657,7 +1713,7 @@ function timeline__INTERNAL(options, store = IMPLICIT.STORE, data = null) {
|
|
|
1657
1713
|
}, data), {
|
|
1658
1714
|
history: (_a = data == null ? void 0 : data.history.map((update) => __spreadValues({}, update))) != null ? _a : [],
|
|
1659
1715
|
install: (store2) => timeline__INTERNAL(options, store2, tl),
|
|
1660
|
-
subject: new
|
|
1716
|
+
subject: new Subject()
|
|
1661
1717
|
});
|
|
1662
1718
|
const core = target(store);
|
|
1663
1719
|
for (const tokenOrFamily of options.atoms) {
|