@tomorrowevening/theatre-dataverse 1.0.0 → 1.0.1

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 (38) hide show
  1. package/dist/Atom.d.ts +85 -127
  2. package/dist/Atom.d.ts.map +1 -1
  3. package/dist/Atom.test.d.ts +2 -0
  4. package/dist/Atom.test.d.ts.map +1 -0
  5. package/dist/PointerProxy.d.ts +33 -33
  6. package/dist/Ticker.d.ts +105 -105
  7. package/dist/Ticker.test.d.ts +2 -0
  8. package/dist/Ticker.test.d.ts.map +1 -0
  9. package/dist/atom.typeTest.d.ts +2 -2
  10. package/dist/dataverse.test.d.ts +2 -0
  11. package/dist/dataverse.test.d.ts.map +1 -0
  12. package/dist/index.d.ts +19 -19
  13. package/dist/index.js +30 -13
  14. package/dist/index.js.map +2 -2
  15. package/dist/integration.test.d.ts +2 -0
  16. package/dist/integration.test.d.ts.map +1 -0
  17. package/dist/pointer.d.ts +107 -107
  18. package/dist/pointer.test.d.ts +2 -0
  19. package/dist/pointer.test.d.ts.map +1 -0
  20. package/dist/pointer.typeTest.d.ts +2 -2
  21. package/dist/pointerToPrism.d.ts +20 -20
  22. package/dist/prism/Interface.d.ts +33 -33
  23. package/dist/prism/asyncIterateOver.d.ts +1 -1
  24. package/dist/prism/discoveryMechanism.d.ts +4 -4
  25. package/dist/prism/iterateAndCountTicks.d.ts +7 -7
  26. package/dist/prism/iterateOver.d.ts +4 -4
  27. package/dist/prism/iterateOver.test.d.ts +2 -0
  28. package/dist/prism/iterateOver.test.d.ts.map +1 -0
  29. package/dist/prism/prism.d.ts +1 -1
  30. package/dist/prism/prism.test.d.ts +2 -0
  31. package/dist/prism/prism.test.d.ts.map +1 -0
  32. package/dist/setupTestEnv.d.ts +2 -2
  33. package/dist/types.d.ts +6 -6
  34. package/dist/utils/Stack.d.ts +16 -16
  35. package/dist/utils/typeTestUtils.d.ts +11 -11
  36. package/dist/utils/updateDeep.d.ts +3 -3
  37. package/dist/val.d.ts +14 -14
  38. package/package.json +7 -10
package/dist/Atom.d.ts CHANGED
@@ -1,127 +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
- /**
26
- * Returns the current state of the atom.
27
- */
28
- get(): State;
29
- /**
30
- * Returns the value at the given pointer
31
- *
32
- * @param pointerOrFn - A pointer to the desired path. Could also be a function returning a pointer
33
- *
34
- * Example
35
- * ```ts
36
- * const atom = atom({ a: { b: 1 } })
37
- * atom.getByPointer(atom.pointer.a.b) // 1
38
- * atom.getByPointer((p) => p.a.b) // 1
39
- * ```
40
- */
41
- getByPointer<S>(pointerOrFn: Pointer<S> | ((p: Pointer<State>) => Pointer<S>)): S;
42
- /**
43
- * Gets the state of the atom at `path`.
44
- */
45
- private _getIn;
46
- reduce(fn: (state: State) => State): void;
47
- /**
48
- * Reduces the value at the given pointer
49
- *
50
- * @param pointerOrFn - A pointer to the desired path. Could also be a function returning a pointer
51
- *
52
- * Example
53
- * ```ts
54
- * const atom = atom({ a: { b: 1 } })
55
- * atom.reduceByPointer(atom.pointer.a.b, (b) => b + 1) // atom.get().a.b === 2
56
- * atom.reduceByPointer((p) => p.a.b, (b) => b + 1) // atom.get().a.b === 2
57
- * ```
58
- */
59
- reduceByPointer<S>(pointerOrFn: Pointer<S> | ((p: Pointer<State>) => Pointer<S>), reducer: (s: S) => S): void;
60
- /**
61
- * Sets the value at the given pointer
62
- *
63
- * @param pointerOrFn - A pointer to the desired path. Could also be a function returning a pointer
64
- *
65
- * Example
66
- * ```ts
67
- * const atom = atom({ a: { b: 1 } })
68
- * atom.setByPointer(atom.pointer.a.b, 2) // atom.get().a.b === 2
69
- * atom.setByPointer((p) => p.a.b, 2) // atom.get().a.b === 2
70
- * ```
71
- */
72
- setByPointer<S>(pointerOrFn: Pointer<S> | ((p: Pointer<State>) => Pointer<S>), val: S): void;
73
- private _checkUpdates;
74
- private _getOrCreateScopeForPath;
75
- /**
76
- * Adds a listener that will be called whenever the value at the given pointer changes.
77
- * @param pointer - The pointer to listen to
78
- * @param cb - The callback to call when the value changes
79
- * @returns A function that can be called to unsubscribe from the listener
80
- *
81
- * **NOTE** Unlike {@link prism}s, `onChangeByPointer` and `onChange()` are traditional event listeners. They don't
82
- * provide any of the benefits of prisms. They don't compose, they can't be coordinated via a Ticker, their derivations
83
- * aren't cached, etc. You're almost always better off using a prism (which will internally use `onChangeByPointer`).
84
- *
85
- * ```ts
86
- * const a = atom({foo: 1})
87
- * const unsubscribe = a.onChangeByPointer(a.pointer.foo, (v) => {
88
- * console.log('foo changed to', v)
89
- * })
90
- * a.setByPointer(a.pointer.foo, 2) // logs 'foo changed to 2'
91
- * a.set({foo: 3}) // logs 'foo changed to 3'
92
- * unsubscribe()
93
- * ```
94
- */
95
- onChangeByPointer: <S>(pointerOrFn: Pointer<S> | ((p: Pointer<State>) => Pointer<S>), cb: (v: S) => void) => (() => void);
96
- /**
97
- * Adds a listener that will be called whenever the state of the atom changes.
98
- * @param cb - The callback to call when the value changes
99
- * @returns A function that can be called to unsubscribe from the listener
100
- *
101
- * **NOTE** Unlike {@link prism}s, `onChangeByPointer` and `onChange()` are traditional event listeners. They don't
102
- * provide any of the benefits of prisms. They don't compose, they can't be coordinated via a Ticker, their derivations
103
- * aren't cached, etc. You're almost always better off using a prism (which will internally use `onChangeByPointer`).
104
- *
105
- * ```ts
106
- * const a = atom({foo: 1})
107
- * const unsubscribe = a.onChange((v) => {
108
- * console.log('a changed to', v)
109
- * })
110
- * a.set({foo: 3}) // logs 'a changed to {foo: 3}'
111
- * unsubscribe()
112
- * ```
113
- */
114
- onChange(cb: (v: State) => void): () => void;
115
- /**
116
- * Returns a new prism of the value at the provided path.
117
- *
118
- * @param pointer - The path to create the prism at.
119
- *
120
- * ```ts
121
- * const pr = atom({ a: { b: 1 } }).pointerToPrism(atom.pointer.a.b)
122
- * pr.getValue() // 1
123
- * ```
124
- */
125
- pointerToPrism<P>(pointer: Pointer<P>): Prism<P>;
126
- }
127
- //# sourceMappingURL=Atom.d.ts.map
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>): Prism<P>;
84
+ }
85
+ //# sourceMappingURL=Atom.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Atom.d.ts","sourceRoot":"","sources":["../src/Atom.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,mBAAmB,CAAA;AAC5C,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AAOtC,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,kBA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C,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,KAAK;IAIlC;;;;;;;;;;;OAWG;IACH,eAAe,CAAC,CAAC,EACf,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,EAC7D,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;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":""}
@@ -1,33 +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
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
package/dist/Ticker.d.ts CHANGED
@@ -1,105 +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
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,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":""}
@@ -1,2 +1,2 @@
1
- export {};
2
- //# sourceMappingURL=atom.typeTest.d.ts.map
1
+ export {};
2
+ //# sourceMappingURL=atom.typeTest.d.ts.map
@@ -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":""}
package/dist/index.d.ts CHANGED
@@ -1,19 +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
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