@unseenco/theatre-dataverse 0.1.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 (58) hide show
  1. package/LICENSE +203 -0
  2. package/README.md +709 -0
  3. package/dist/Atom.d.ts +85 -0
  4. package/dist/Atom.d.ts.map +1 -0
  5. package/dist/Atom.test.d.ts +2 -0
  6. package/dist/Atom.test.d.ts.map +1 -0
  7. package/dist/PointerProxy.d.ts +33 -0
  8. package/dist/PointerProxy.d.ts.map +1 -0
  9. package/dist/Ticker.d.ts +105 -0
  10. package/dist/Ticker.d.ts.map +1 -0
  11. package/dist/Ticker.test.d.ts +2 -0
  12. package/dist/Ticker.test.d.ts.map +1 -0
  13. package/dist/atom.typeTest.d.ts +2 -0
  14. package/dist/atom.typeTest.d.ts.map +1 -0
  15. package/dist/dataverse.test.d.ts +2 -0
  16. package/dist/dataverse.test.d.ts.map +1 -0
  17. package/dist/index.d.ts +19 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +1572 -0
  20. package/dist/index.js.map +7 -0
  21. package/dist/integration.test.d.ts +2 -0
  22. package/dist/integration.test.d.ts.map +1 -0
  23. package/dist/pointer.d.ts +107 -0
  24. package/dist/pointer.d.ts.map +1 -0
  25. package/dist/pointer.test.d.ts +2 -0
  26. package/dist/pointer.test.d.ts.map +1 -0
  27. package/dist/pointer.typeTest.d.ts +2 -0
  28. package/dist/pointer.typeTest.d.ts.map +1 -0
  29. package/dist/pointerToPrism.d.ts +20 -0
  30. package/dist/pointerToPrism.d.ts.map +1 -0
  31. package/dist/prism/Interface.d.ts +33 -0
  32. package/dist/prism/Interface.d.ts.map +1 -0
  33. package/dist/prism/discoveryMechanism.d.ts +4 -0
  34. package/dist/prism/discoveryMechanism.d.ts.map +1 -0
  35. package/dist/prism/iterateAndCountTicks.d.ts +7 -0
  36. package/dist/prism/iterateAndCountTicks.d.ts.map +1 -0
  37. package/dist/prism/iterateOver.d.ts +4 -0
  38. package/dist/prism/iterateOver.d.ts.map +1 -0
  39. package/dist/prism/iterateOver.test.d.ts +2 -0
  40. package/dist/prism/iterateOver.test.d.ts.map +1 -0
  41. package/dist/prism/prism.d.ts +175 -0
  42. package/dist/prism/prism.d.ts.map +1 -0
  43. package/dist/prism/prism.test.d.ts +2 -0
  44. package/dist/prism/prism.test.d.ts.map +1 -0
  45. package/dist/setupTestEnv.d.ts +2 -0
  46. package/dist/setupTestEnv.d.ts.map +1 -0
  47. package/dist/tsdoc-metadata.json +11 -0
  48. package/dist/types.d.ts +6 -0
  49. package/dist/types.d.ts.map +1 -0
  50. package/dist/utils/Stack.d.ts +16 -0
  51. package/dist/utils/Stack.d.ts.map +1 -0
  52. package/dist/utils/typeTestUtils.d.ts +11 -0
  53. package/dist/utils/typeTestUtils.d.ts.map +1 -0
  54. package/dist/utils/updateDeep.d.ts +3 -0
  55. package/dist/utils/updateDeep.d.ts.map +1 -0
  56. package/dist/val.d.ts +14 -0
  57. package/dist/val.d.ts.map +1 -0
  58. package/package.json +47 -0
package/dist/Atom.d.ts ADDED
@@ -0,0 +1,85 @@
1
+ import type { Prism } from './prism/Interface';
2
+ import type { Pointer } from './pointer';
3
+ import type { PointerToPrismProvider } from './pointerToPrism';
4
+ /**
5
+ * Wraps an object whose (sub)properties can be individually tracked.
6
+ */
7
+ export default class Atom<State> implements PointerToPrismProvider {
8
+ private _currentState;
9
+ private readonly _rootScope;
10
+ /**
11
+ * Convenience property that gives you a pointer to the root of the atom.
12
+ *
13
+ * @remarks
14
+ * Equivalent to `pointer({ root: thisAtom, path: [] })`.
15
+ */
16
+ readonly pointer: Pointer<State>;
17
+ readonly prism: Prism<State>;
18
+ constructor(initialState: State);
19
+ /**
20
+ * Sets the state of the atom.
21
+ *
22
+ * @param newState - The new state of the atom.
23
+ */
24
+ set(newState: State): void;
25
+ get(): State;
26
+ /**
27
+ * Returns the value at the given pointer
28
+ *
29
+ * @param pointerOrFn - A pointer to the desired path. Could also be a function returning a pointer
30
+ *
31
+ * Example
32
+ * ```ts
33
+ * const atom = atom({ a: { b: 1 } })
34
+ * atom.getByPointer(atom.pointer.a.b) // 1
35
+ * atom.getByPointer((p) => p.a.b) // 1
36
+ * ```
37
+ */
38
+ getByPointer<S>(pointerOrFn: Pointer<S> | ((p: Pointer<State>) => Pointer<S>)): S;
39
+ /**
40
+ * Gets the state of the atom at `path`.
41
+ */
42
+ private _getIn;
43
+ reduce(fn: (state: State) => State): void;
44
+ /**
45
+ * Reduces the value at the given pointer
46
+ *
47
+ * @param pointerOrFn - A pointer to the desired path. Could also be a function returning a pointer
48
+ *
49
+ * Example
50
+ * ```ts
51
+ * const atom = atom({ a: { b: 1 } })
52
+ * atom.reduceByPointer(atom.pointer.a.b, (b) => b + 1) // atom.get().a.b === 2
53
+ * atom.reduceByPointer((p) => p.a.b, (b) => b + 1) // atom.get().a.b === 2
54
+ * ```
55
+ */
56
+ reduceByPointer<S>(pointerOrFn: Pointer<S> | ((p: Pointer<State>) => Pointer<S>), reducer: (s: S) => S): void;
57
+ /**
58
+ * Sets the value at the given pointer
59
+ *
60
+ * @param pointerOrFn - A pointer to the desired path. Could also be a function returning a pointer
61
+ *
62
+ * Example
63
+ * ```ts
64
+ * const atom = atom({ a: { b: 1 } })
65
+ * atom.setByPointer(atom.pointer.a.b, 2) // atom.get().a.b === 2
66
+ * atom.setByPointer((p) => p.a.b, 2) // atom.get().a.b === 2
67
+ * ```
68
+ */
69
+ setByPointer<S>(pointerOrFn: Pointer<S> | ((p: Pointer<State>) => Pointer<S>), val: S): void;
70
+ private _checkUpdates;
71
+ private _getOrCreateScopeForPath;
72
+ private _onPointerValueChange;
73
+ /**
74
+ * Returns a new prism of the value at the provided path.
75
+ *
76
+ * @param pointer - The path to create the prism at.
77
+ *
78
+ * ```ts
79
+ * const pr = atom({ a: { b: 1 } }).pointerToPrism(atom.pointer.a.b)
80
+ * pr.getValue() // 1
81
+ * ```
82
+ */
83
+ pointerToPrism<P>(pointer: Pointer<P>): Pr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;IAWtB;;;;;;;;;;;OAWG;IACH,YAAY,CAAC,CAAC,EACZ,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,EAC7D,GAAG,EAAE,CAAC;IAKR,OAAO,CAAC,aAAa;IAsBrB,OAAO,CAAC,wBAAwB;IAQhC,OAAO,CAAC,qBAAqB,CAW5B;IAED;;;;;;;;;OASG;IACH,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;CAWjD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Atom.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Atom.test.d.ts","sourceRoot":"","sources":["../src/Atom.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,33 @@
1
+ import type { Pointer } from './pointer';
2
+ import type { Prism } from './prism/Interface';
3
+ import type { PointerToPrismProvider } from './pointerToPrism';
4
+ /**
5
+ * Allows creating pointer-prisms where the pointer can be switched out.
6
+ *
7
+ * @remarks
8
+ * This allows reacting not just to value changes at a certain pointer, but changes
9
+ * to the proxied pointer too.
10
+ */
11
+ export default class PointerProxy<O extends {}> implements PointerToPrismProvider {
12
+ private readonly _currentPointerBox;
13
+ /**
14
+ * Convenience pointer pointing to the root of this PointerProxy.
15
+ *
16
+ * @remarks
17
+ * Allows convenient use of {@link pointerToPrism} and {@link val}.
18
+ */
19
+ readonly pointer: Pointer<O>;
20
+ constructor(currentPointer: Pointer<O>);
21
+ /**
22
+ * Sets the underlying pointer.
23
+ * @param p - The pointer to be proxied.
24
+ */
25
+ setPointer(p: Pointer<O>): void;
26
+ /**
27
+ * Returns a prism of the value at the provided sub-path of the proxied pointer.
28
+ *
29
+ * @param path - The path to create the prism at.
30
+ */
31
+ pointerToPrism<P>(pointer: Pointer<P>): Prism<P>;
32
+ }
33
+ //# sourceMappingURL=PointerProxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PointerProxy.d.ts","sourceRoot":"","sources":["../src/PointerProxy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AAKtC,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,mBAAmB,CAAA;AAC5C,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,kBAAkB,CAAA;AAE5D;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,YAAY,CAAC,CAAC,SAAS,EAAE,CAC5C,YAAW,sBAAsB;IAMjC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAkB;IACrD;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;gBAEhB,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC;IAKtC;;;OAGG;IACH,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;IAIxB;;;;OAIG;IACH,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;CAWjD"}
@@ -0,0 +1,105 @@
1
+ type ICallback = (t: number) => void;
2
+ /**
3
+ * The number of ticks that can pass without any scheduled callbacks before the Ticker goes dormant. This is to prevent
4
+ * the Ticker from staying active forever, even if there are no scheduled callbacks.
5
+ *
6
+ * Perhaps counting ticks vs. time is not the best way to do this. But it's a start.
7
+ */
8
+ export declare const EMPTY_TICKS_BEFORE_GOING_DORMANT: number;
9
+ /**
10
+ * The Ticker class helps schedule callbacks. Scheduled callbacks are executed per tick. Ticks can be triggered by an
11
+ * external scheduling strategy, e.g. a raf.
12
+ */
13
+ export default class Ticker {
14
+ private _conf?;
15
+ private _scheduledForThisOrNextTick;
16
+ private _scheduledForNextTick;
17
+ private _timeAtCurrentTick;
18
+ private _ticking;
19
+ /**
20
+ * Whether the Ticker is dormant
21
+ */
22
+ private _dormant;
23
+ private _numberOfDormantTicks;
24
+ /**
25
+ * Whether the Ticker is dormant
26
+ */
27
+ get dormant(): boolean;
28
+ /**
29
+ * Counts up for every tick executed.
30
+ * Internally, this is used to measure ticks per second.
31
+ *
32
+ * This is "public" to TypeScript, because it's a tool for performance measurements.
33
+ * Consider this as experimental, and do not rely on it always being here in future releases.
34
+ */
35
+ __ticks: number;
36
+ constructor(_conf?: {
37
+ /**
38
+ * This is called when the Ticker goes dormant.
39
+ */
40
+ onDormant?: (() => void) | undefined;
41
+ /**
42
+ * This is called when the Ticker goes active.
43
+ */
44
+ onActive?: (() => void) | undefined;
45
+ } | undefined);
46
+ /**
47
+ * Registers for fn to be called either on this tick or the next tick.
48
+ *
49
+ * If `onThisOrNextTick()` is called while `Ticker.tick()` is running, the
50
+ * side effect _will_ be called within the running tick. If you don't want this
51
+ * behavior, you can use `onNextTick()`.
52
+ *
53
+ * Note that `fn` will be added to a `Set()`. Which means, if you call `onThisOrNextTick(fn)`
54
+ * with the same fn twice in a single tick, it'll only run once.
55
+ *
56
+ * @param fn - The function to be registered.
57
+ *
58
+ * @see offThisOrNextTick
59
+ */
60
+ onThisOrNextTick(fn: ICallback): void;
61
+ /**
62
+ * Registers a side effect to be called on the next tick.
63
+ *
64
+ * @param fn - The function to be registered.
65
+ *
66
+ * @see onThisOrNextTick
67
+ * @see offNextTick
68
+ */
69
+ onNextTick(fn: ICallback): void;
70
+ /**
71
+ * De-registers a fn to be called either on this tick or the next tick.
72
+ *
73
+ * @param fn - The function to be de-registered.
74
+ *
75
+ * @see onThisOrNextTick
76
+ */
77
+ offThisOrNextTick(fn: ICallback): void;
78
+ /**
79
+ * De-registers a fn to be called on the next tick.
80
+ *
81
+ * @param fn - The function to be de-registered.
82
+ *
83
+ * @see onNextTick
84
+ */
85
+ offNextTick(fn: ICallback): void;
86
+ /**
87
+ * The time at the start of the current tick if there is a tick in progress, otherwise defaults to
88
+ * `performance.now()`.
89
+ */
90
+ get time(): number;
91
+ private _goActive;
92
+ private _goDormant;
93
+ /**
94
+ * Triggers a tick which starts executing the callbacks scheduled for this tick.
95
+ *
96
+ * @param t - The time at the tick.
97
+ *
98
+ * @see onThisOrNextTick
99
+ * @see onNextTick
100
+ */
101
+ tick(t?: number): void;
102
+ private _tick;
103
+ }
104
+ export {};
105
+ //# sourceMappingURL=Ticker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Ticker.d.ts","sourceRoot":"","sources":["../src/Ticker.ts"],"names":[],"mappings":"AAAA,KAAK,SAAS,GAAG,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;AAEpC;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,QAAiB,CAAA;AAE9D;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,MAAM;IA6BvB,OAAO,CAAC,KAAK,CAAC;IA5BhB,OAAO,CAAC,2BAA2B,CAAgB;IACnD,OAAO,CAAC,qBAAqB,CAAgB;IAC7C,OAAO,CAAC,kBAAkB,CAAQ;IAClC,OAAO,CAAC,QAAQ,CAAiB;IAEjC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAgB;IAEhC,OAAO,CAAC,qBAAqB,CAAI;IAEjC;;OAEG;IACH,IAAI,OAAO,IAAI,OAAO,CAErB;IACD;;;;;;OAMG;IACI,OAAO,SAAI;gBAGR,KAAK,CAAC;QACZ;;WAEG;2BACe,IAAI;QACtB;;WAEG;0BACc,IAAI;iBACtB;IAOH;;;;;;;;;;;;;OAaG;IACH,gBAAgB,CAAC,EAAE,EAAE,SAAS;IAO9B;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,EAAE,SAAS;IAOxB;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,EAAE,SAAS;IAI/B;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,EAAE,SAAS;IAIzB;;;OAGG;IACH,IAAI,IAAI,WAIP;IAED,OAAO,CAAC,SAAS;IAMjB,OAAO,CAAC,UAAU;IAOlB;;;;;;;OAOG;IACH,IAAI,CAAC,CAAC,GAAE,MAA0B;IAmClC,OAAO,CAAC,KAAK;CAqBd"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Ticker.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Ticker.test.d.ts","sourceRoot":"","sources":["../src/Ticker.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=atom.typeTest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atom.typeTest.d.ts","sourceRoot":"","sources":["../src/atom.typeTest.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=dataverse.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataverse.test.d.ts","sourceRoot":"","sources":["../src/dataverse.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The animation-optimized FRP library powering the internals of Theatre.js.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ export type { PointerToPrismProvider } from './pointerToPrism';
7
+ export { default as Atom } from './Atom';
8
+ export { val } from './val';
9
+ export { pointerToPrism } from './pointerToPrism';
10
+ export { isPrism } from './prism/Interface';
11
+ export type { Prism } from './prism/Interface';
12
+ export { default as iterateAndCountTicks } from './prism/iterateAndCountTicks';
13
+ export { default as iterateOver } from './prism/iterateOver';
14
+ export { default as prism } from './prism/prism';
15
+ export { default as pointer, getPointerParts, isPointer } from './pointer';
16
+ export type { Pointer, PointerType, PointerMeta } from './pointer';
17
+ export { default as Ticker } from './Ticker';
18
+ export { default as PointerProxy } from './PointerProxy';
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EAAC,sBAAsB,EAAC,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAC,OAAO,IAAI,IAAI,EAAC,MAAM,QAAQ,CAAA;AACtC,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAA;AACzB,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAA;AACzC,YAAY,EAAC,KAAK,EAAC,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAC,OAAO,IAAI,oBAAoB,EAAC,MAAM,8BAA8B,CAAA;AAC5E,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EAAC,OAAO,IAAI,KAAK,EAAC,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAC,OAAO,IAAI,OAAO,EAAE,eAAe,EAAE,SAAS,EAAC,MAAM,WAAW,CAAA;AACxE,YAAY,EAAC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAC,MAAM,WAAW,CAAA;AAChE,OAAO,EAAC,OAAO,IAAI,MAAM,EAAC,MAAM,UAAU,CAAA;AAC1C,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,gBAAgB,CAAA"}