@yuzhouu/canvas-standard 0.1.10 → 0.2.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.
- package/_vendor/plugin-draw/api.d.ts +1 -2
- package/_vendor/plugin-eraser/_vendor/signals/atom.d.ts +1 -1
- package/_vendor/plugin-eraser/_vendor/signals/computed.d.ts +1 -1
- package/_vendor/plugin-eraser/_vendor/signals/core.d.ts +3 -3
- package/_vendor/plugin-eraser/_vendor/signals/effect.d.ts +1 -1
- package/_vendor/plugin-eraser/_vendor/signals/types.d.ts +5 -3
- package/_vendor/plugin-eraser/eraserRuntime.d.ts +4 -4
- package/_vendor/plugin-flow/_vendor/plugin-image/image/api.d.ts +1 -2
- package/_vendor/plugin-flow/_vendor/plugin-image/image/mediaPresentation.d.ts +1 -2
- package/_vendor/plugin-flow/_vendor/plugin-text/api.d.ts +1 -2
- package/_vendor/plugin-flow/_vendor/plugin-text/geoLabelApi.d.ts +1 -2
- package/_vendor/plugin-flow/_vendor/plugin-text/host/textShapeRendererRuntime.d.ts +1 -1
- package/_vendor/plugin-flow/_vendor/plugin-text/host/useTextLabelLayout.d.ts +1 -1
- package/_vendor/plugin-flow/_vendor/plugin-text/textShapeHelpers.d.ts +1 -1
- package/_vendor/plugin-flow/_vendor/plugin-text/textShapeUtil.d.ts +2 -3
- package/_vendor/plugin-flow/api.d.ts +1 -2
- package/_vendor/plugin-flow/flowEdgeRuntime.d.ts +2 -2
- package/_vendor/plugin-flow/flowEdgeShapeUtil.d.ts +3 -7
- package/_vendor/plugin-flow/types.d.ts +1 -2
- package/_vendor/plugin-frame/api.d.ts +1 -2
- package/_vendor/plugin-frame/frameCreationRuntime.d.ts +1 -1
- package/_vendor/plugin-geo/_vendor/plugin-text/api.d.ts +1 -2
- package/_vendor/plugin-geo/_vendor/plugin-text/geoLabelApi.d.ts +1 -2
- package/_vendor/plugin-geo/_vendor/plugin-text/host/textShapeRendererRuntime.d.ts +1 -1
- package/_vendor/plugin-geo/_vendor/plugin-text/host/useTextLabelLayout.d.ts +1 -1
- package/_vendor/plugin-geo/_vendor/plugin-text/textShapeHelpers.d.ts +1 -1
- package/_vendor/plugin-geo/_vendor/plugin-text/textShapeUtil.d.ts +2 -3
- package/_vendor/plugin-geo/api.d.ts +1 -2
- package/_vendor/plugin-geo/geoCreationRuntime.d.ts +1 -1
- package/_vendor/plugin-html/api.d.ts +1 -2
- package/_vendor/plugin-image/image/api.d.ts +1 -2
- package/_vendor/plugin-image/image/mediaPresentation.d.ts +1 -2
- package/_vendor/plugin-laser/_vendor/signals/atom.d.ts +1 -1
- package/_vendor/plugin-laser/_vendor/signals/computed.d.ts +1 -1
- package/_vendor/plugin-laser/_vendor/signals/core.d.ts +3 -3
- package/_vendor/plugin-laser/_vendor/signals/effect.d.ts +1 -1
- package/_vendor/plugin-laser/_vendor/signals/types.d.ts +5 -3
- package/_vendor/plugin-laser/laserRuntime.d.ts +2 -2
- package/_vendor/plugin-path/api.d.ts +1 -2
- package/_vendor/plugin-path/pathShapeUtil.d.ts +2 -3
- package/_vendor/plugin-text/api.d.ts +1 -2
- package/_vendor/plugin-text/geoLabelApi.d.ts +1 -2
- package/_vendor/plugin-text/host/textShapeRendererRuntime.d.ts +1 -1
- package/_vendor/plugin-text/host/useTextLabelLayout.d.ts +1 -1
- package/_vendor/plugin-text/textShapeHelpers.d.ts +1 -1
- package/_vendor/plugin-text/textShapeUtil.d.ts +2 -3
- package/_vendor/plugin-video/video/api.d.ts +1 -2
- package/_vendor/plugin-video/video/mediaPresentation.d.ts +1 -2
- package/index.mjs +67 -67
- package/package.json +3 -3
- package/_vendor/canvas-export/_vendor/signals/atom.d.ts +0 -11
- package/_vendor/canvas-export/_vendor/signals/computed.d.ts +0 -13
- package/_vendor/canvas-export/_vendor/signals/core.d.ts +0 -35
- package/_vendor/canvas-export/_vendor/signals/effect.d.ts +0 -5
- package/_vendor/canvas-export/_vendor/signals/index.d.ts +0 -8
- package/_vendor/canvas-export/_vendor/signals/types.d.ts +0 -22
- package/_vendor/canvas-export/_vendor/store/diff.d.ts +0 -9
- package/_vendor/canvas-export/_vendor/store/history.d.ts +0 -22
- package/_vendor/canvas-export/_vendor/store/index.d.ts +0 -5
- package/_vendor/canvas-export/_vendor/store/store.d.ts +0 -40
- package/_vendor/canvas-export/_vendor/store/types.d.ts +0 -27
- package/_vendor/plugin-draw/_vendor/signals/atom.d.ts +0 -11
- package/_vendor/plugin-draw/_vendor/signals/computed.d.ts +0 -13
- package/_vendor/plugin-draw/_vendor/signals/core.d.ts +0 -35
- package/_vendor/plugin-draw/_vendor/signals/effect.d.ts +0 -5
- package/_vendor/plugin-draw/_vendor/signals/index.d.ts +0 -8
- package/_vendor/plugin-draw/_vendor/signals/types.d.ts +0 -22
- package/_vendor/plugin-draw/_vendor/store/diff.d.ts +0 -9
- package/_vendor/plugin-draw/_vendor/store/history.d.ts +0 -22
- package/_vendor/plugin-draw/_vendor/store/index.d.ts +0 -5
- package/_vendor/plugin-draw/_vendor/store/store.d.ts +0 -40
- package/_vendor/plugin-draw/_vendor/store/types.d.ts +0 -27
- package/_vendor/plugin-eraser/_vendor/store/diff.d.ts +0 -9
- package/_vendor/plugin-eraser/_vendor/store/history.d.ts +0 -22
- package/_vendor/plugin-eraser/_vendor/store/index.d.ts +0 -5
- package/_vendor/plugin-eraser/_vendor/store/store.d.ts +0 -40
- package/_vendor/plugin-eraser/_vendor/store/types.d.ts +0 -27
- package/_vendor/plugin-flow/_vendor/signals/atom.d.ts +0 -11
- package/_vendor/plugin-flow/_vendor/signals/computed.d.ts +0 -13
- package/_vendor/plugin-flow/_vendor/signals/core.d.ts +0 -35
- package/_vendor/plugin-flow/_vendor/signals/effect.d.ts +0 -5
- package/_vendor/plugin-flow/_vendor/signals/index.d.ts +0 -8
- package/_vendor/plugin-flow/_vendor/signals/types.d.ts +0 -22
- package/_vendor/plugin-flow/_vendor/store/diff.d.ts +0 -9
- package/_vendor/plugin-flow/_vendor/store/history.d.ts +0 -22
- package/_vendor/plugin-flow/_vendor/store/index.d.ts +0 -5
- package/_vendor/plugin-flow/_vendor/store/store.d.ts +0 -40
- package/_vendor/plugin-flow/_vendor/store/types.d.ts +0 -27
- package/_vendor/plugin-frame/_vendor/signals/atom.d.ts +0 -11
- package/_vendor/plugin-frame/_vendor/signals/computed.d.ts +0 -13
- package/_vendor/plugin-frame/_vendor/signals/core.d.ts +0 -35
- package/_vendor/plugin-frame/_vendor/signals/effect.d.ts +0 -5
- package/_vendor/plugin-frame/_vendor/signals/index.d.ts +0 -8
- package/_vendor/plugin-frame/_vendor/signals/types.d.ts +0 -22
- package/_vendor/plugin-frame/_vendor/store/diff.d.ts +0 -9
- package/_vendor/plugin-frame/_vendor/store/history.d.ts +0 -22
- package/_vendor/plugin-frame/_vendor/store/index.d.ts +0 -5
- package/_vendor/plugin-frame/_vendor/store/store.d.ts +0 -40
- package/_vendor/plugin-frame/_vendor/store/types.d.ts +0 -27
- package/_vendor/plugin-geo/_vendor/signals/atom.d.ts +0 -11
- package/_vendor/plugin-geo/_vendor/signals/computed.d.ts +0 -13
- package/_vendor/plugin-geo/_vendor/signals/core.d.ts +0 -35
- package/_vendor/plugin-geo/_vendor/signals/effect.d.ts +0 -5
- package/_vendor/plugin-geo/_vendor/signals/index.d.ts +0 -8
- package/_vendor/plugin-geo/_vendor/signals/types.d.ts +0 -22
- package/_vendor/plugin-geo/_vendor/store/diff.d.ts +0 -9
- package/_vendor/plugin-geo/_vendor/store/history.d.ts +0 -22
- package/_vendor/plugin-geo/_vendor/store/index.d.ts +0 -5
- package/_vendor/plugin-geo/_vendor/store/store.d.ts +0 -40
- package/_vendor/plugin-geo/_vendor/store/types.d.ts +0 -27
- package/_vendor/plugin-group/_vendor/signals/atom.d.ts +0 -11
- package/_vendor/plugin-group/_vendor/signals/computed.d.ts +0 -13
- package/_vendor/plugin-group/_vendor/signals/core.d.ts +0 -35
- package/_vendor/plugin-group/_vendor/signals/effect.d.ts +0 -5
- package/_vendor/plugin-group/_vendor/signals/index.d.ts +0 -8
- package/_vendor/plugin-group/_vendor/signals/types.d.ts +0 -22
- package/_vendor/plugin-group/_vendor/store/diff.d.ts +0 -9
- package/_vendor/plugin-group/_vendor/store/history.d.ts +0 -22
- package/_vendor/plugin-group/_vendor/store/index.d.ts +0 -5
- package/_vendor/plugin-group/_vendor/store/store.d.ts +0 -40
- package/_vendor/plugin-group/_vendor/store/types.d.ts +0 -27
- package/_vendor/plugin-html/_vendor/signals/atom.d.ts +0 -11
- package/_vendor/plugin-html/_vendor/signals/computed.d.ts +0 -13
- package/_vendor/plugin-html/_vendor/signals/core.d.ts +0 -35
- package/_vendor/plugin-html/_vendor/signals/effect.d.ts +0 -5
- package/_vendor/plugin-html/_vendor/signals/index.d.ts +0 -8
- package/_vendor/plugin-html/_vendor/signals/types.d.ts +0 -22
- package/_vendor/plugin-html/_vendor/store/diff.d.ts +0 -9
- package/_vendor/plugin-html/_vendor/store/history.d.ts +0 -22
- package/_vendor/plugin-html/_vendor/store/index.d.ts +0 -5
- package/_vendor/plugin-html/_vendor/store/store.d.ts +0 -40
- package/_vendor/plugin-html/_vendor/store/types.d.ts +0 -27
- package/_vendor/plugin-image/_vendor/signals/atom.d.ts +0 -11
- package/_vendor/plugin-image/_vendor/signals/computed.d.ts +0 -13
- package/_vendor/plugin-image/_vendor/signals/core.d.ts +0 -35
- package/_vendor/plugin-image/_vendor/signals/effect.d.ts +0 -5
- package/_vendor/plugin-image/_vendor/signals/index.d.ts +0 -8
- package/_vendor/plugin-image/_vendor/signals/types.d.ts +0 -22
- package/_vendor/plugin-image/_vendor/store/diff.d.ts +0 -9
- package/_vendor/plugin-image/_vendor/store/history.d.ts +0 -22
- package/_vendor/plugin-image/_vendor/store/index.d.ts +0 -5
- package/_vendor/plugin-image/_vendor/store/store.d.ts +0 -40
- package/_vendor/plugin-image/_vendor/store/types.d.ts +0 -27
- package/_vendor/plugin-laser/_vendor/store/diff.d.ts +0 -9
- package/_vendor/plugin-laser/_vendor/store/history.d.ts +0 -22
- package/_vendor/plugin-laser/_vendor/store/index.d.ts +0 -5
- package/_vendor/plugin-laser/_vendor/store/store.d.ts +0 -40
- package/_vendor/plugin-laser/_vendor/store/types.d.ts +0 -27
- package/_vendor/plugin-path/_vendor/signals/atom.d.ts +0 -11
- package/_vendor/plugin-path/_vendor/signals/computed.d.ts +0 -13
- package/_vendor/plugin-path/_vendor/signals/core.d.ts +0 -35
- package/_vendor/plugin-path/_vendor/signals/effect.d.ts +0 -5
- package/_vendor/plugin-path/_vendor/signals/index.d.ts +0 -8
- package/_vendor/plugin-path/_vendor/signals/types.d.ts +0 -22
- package/_vendor/plugin-path/_vendor/store/diff.d.ts +0 -9
- package/_vendor/plugin-path/_vendor/store/history.d.ts +0 -22
- package/_vendor/plugin-path/_vendor/store/index.d.ts +0 -5
- package/_vendor/plugin-path/_vendor/store/store.d.ts +0 -40
- package/_vendor/plugin-path/_vendor/store/types.d.ts +0 -27
- package/_vendor/plugin-text/_vendor/signals/atom.d.ts +0 -11
- package/_vendor/plugin-text/_vendor/signals/computed.d.ts +0 -13
- package/_vendor/plugin-text/_vendor/signals/core.d.ts +0 -35
- package/_vendor/plugin-text/_vendor/signals/effect.d.ts +0 -5
- package/_vendor/plugin-text/_vendor/signals/index.d.ts +0 -8
- package/_vendor/plugin-text/_vendor/signals/types.d.ts +0 -22
- package/_vendor/plugin-text/_vendor/store/diff.d.ts +0 -9
- package/_vendor/plugin-text/_vendor/store/history.d.ts +0 -22
- package/_vendor/plugin-text/_vendor/store/index.d.ts +0 -5
- package/_vendor/plugin-text/_vendor/store/store.d.ts +0 -40
- package/_vendor/plugin-text/_vendor/store/types.d.ts +0 -27
- package/_vendor/plugin-video/_vendor/signals/atom.d.ts +0 -11
- package/_vendor/plugin-video/_vendor/signals/computed.d.ts +0 -13
- package/_vendor/plugin-video/_vendor/signals/core.d.ts +0 -35
- package/_vendor/plugin-video/_vendor/signals/effect.d.ts +0 -5
- package/_vendor/plugin-video/_vendor/signals/index.d.ts +0 -8
- package/_vendor/plugin-video/_vendor/signals/types.d.ts +0 -22
- package/_vendor/plugin-video/_vendor/store/diff.d.ts +0 -9
- package/_vendor/plugin-video/_vendor/store/history.d.ts +0 -22
- package/_vendor/plugin-video/_vendor/store/index.d.ts +0 -5
- package/_vendor/plugin-video/_vendor/store/store.d.ts +0 -40
- package/_vendor/plugin-video/_vendor/store/types.d.ts +0 -27
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuzhouu/canvas-standard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Standard Land canvas profile with Arrow, Connector and Packaging kept as opt-in plugins.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.mjs",
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
"./style.css": "./styles.css"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@yuzhouu/canvas-kit": "^0.
|
|
22
|
+
"@yuzhouu/canvas-kit": "^0.2.0",
|
|
23
23
|
"polygon-clipping": "^0.15.7",
|
|
24
24
|
"@tiptap/core": "3.27.3",
|
|
25
25
|
"@tiptap/react": "3.27.3",
|
|
26
26
|
"@tiptap/pm": "3.27.3",
|
|
27
|
-
"@yuzhouu/canvas-host": "^0.
|
|
27
|
+
"@yuzhouu/canvas-host": "^0.2.0"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"react": "^19.0.0",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { SignalGraph } from "./core";
|
|
2
|
-
import type { Signal } from "./types";
|
|
3
|
-
export interface AtomOptions<T> {
|
|
4
|
-
isEqual?: (left: T, right: T) => boolean;
|
|
5
|
-
}
|
|
6
|
-
export interface Atom<T> extends Signal<T> {
|
|
7
|
-
set(value: T): T;
|
|
8
|
-
update(updater: (value: T) => T): T;
|
|
9
|
-
}
|
|
10
|
-
export declare function createAtom<T>(graph: SignalGraph, name: string, initialValue: T, options?: AtomOptions<T>): Atom<T>;
|
|
11
|
-
export declare function isAtom(value: unknown): value is Atom<unknown>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { SignalGraph } from "./core";
|
|
2
|
-
import type { Signal } from "./types";
|
|
3
|
-
declare const UNINITIALIZED_VALUE: unique symbol;
|
|
4
|
-
export type UNINITIALIZED = typeof UNINITIALIZED_VALUE;
|
|
5
|
-
export { UNINITIALIZED_VALUE as UNINITIALIZED };
|
|
6
|
-
export interface ComputedOptions<T> {
|
|
7
|
-
isEqual?: (left: T, right: T) => boolean;
|
|
8
|
-
}
|
|
9
|
-
export interface Computed<T> extends Signal<T> {
|
|
10
|
-
readonly isComputed: true;
|
|
11
|
-
}
|
|
12
|
-
export declare function createComputed<T>(graph: SignalGraph, name: string, derive: (previous: T | UNINITIALIZED) => T, options?: ComputedOptions<T>): Computed<T>;
|
|
13
|
-
export declare function isComputed(value: unknown): value is Computed<unknown>;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { type Atom, type AtomOptions } from "./atom";
|
|
2
|
-
import { type Computed, type ComputedOptions, type UNINITIALIZED } from "./computed";
|
|
3
|
-
import { type EffectSchedulerOptions } from "./effect";
|
|
4
|
-
import type { InternalSignal, ReactiveConsumer } from "./types";
|
|
5
|
-
interface InternalAtom<T> extends InternalSignal<T> {
|
|
6
|
-
__unsafe__isEqual(left: T, right: T): boolean;
|
|
7
|
-
__unsafe__restore(value: T, lastChangedEpoch: number): void;
|
|
8
|
-
}
|
|
9
|
-
export declare class SignalGraph {
|
|
10
|
-
private epoch;
|
|
11
|
-
private currentTransaction;
|
|
12
|
-
private captureStack;
|
|
13
|
-
readonly atom: <T>(name: string, initialValue: T, options?: AtomOptions<T>) => Atom<T>;
|
|
14
|
-
readonly computed: <T>(name: string, derive: (previous: T | UNINITIALIZED) => T, options?: ComputedOptions<T>) => Computed<T>;
|
|
15
|
-
readonly effect: (name: string, fn: () => void, options?: EffectSchedulerOptions) => (() => void);
|
|
16
|
-
readonly transact: (fn: () => void) => void;
|
|
17
|
-
getEpoch(): number;
|
|
18
|
-
isComputingSignal(): boolean;
|
|
19
|
-
/** @internal */
|
|
20
|
-
advanceEpoch(): number;
|
|
21
|
-
/** @internal */
|
|
22
|
-
noteInitialValue<T>(atom: InternalAtom<T>, previousValue: T, previousLastChangedEpoch: number): void;
|
|
23
|
-
/** @internal */
|
|
24
|
-
startCapture(consumer: ReactiveConsumer): void;
|
|
25
|
-
/** @internal */
|
|
26
|
-
stopCapture(): Set<InternalSignal<any>>;
|
|
27
|
-
/** @internal */
|
|
28
|
-
trackDependency(dependency: InternalSignal<any>): void;
|
|
29
|
-
/** @internal */
|
|
30
|
-
atomDidChange(atom: InternalAtom<any>): void;
|
|
31
|
-
private restoreInitialAtomSnapshots;
|
|
32
|
-
private flushChanges;
|
|
33
|
-
}
|
|
34
|
-
export declare function createSignalGraph(): SignalGraph;
|
|
35
|
-
export {};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { SignalGraph } from "./core";
|
|
2
|
-
export interface EffectSchedulerOptions {
|
|
3
|
-
scheduleEffect?: (execute: () => void) => void;
|
|
4
|
-
}
|
|
5
|
-
export declare function createEffect(graph: SignalGraph, name: string, fn: () => void, options?: EffectSchedulerOptions): () => void;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { isAtom } from "./atom";
|
|
2
|
-
export type { Atom, AtomOptions } from "./atom";
|
|
3
|
-
export { isComputed, UNINITIALIZED } from "./computed";
|
|
4
|
-
export type { Computed, ComputedOptions } from "./computed";
|
|
5
|
-
export type { EffectSchedulerOptions } from "./effect";
|
|
6
|
-
export { createSignalGraph, SignalGraph } from "./core";
|
|
7
|
-
export { RESET_VALUE } from "./types";
|
|
8
|
-
export type { Signal } from "./types";
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { SignalGraph } from "./core";
|
|
2
|
-
/** A readable node owned by one reactive graph. */
|
|
3
|
-
export interface Signal<T> {
|
|
4
|
-
readonly graph: SignalGraph;
|
|
5
|
-
readonly name: string;
|
|
6
|
-
get(): T;
|
|
7
|
-
peek(): T;
|
|
8
|
-
}
|
|
9
|
-
/** @internal */
|
|
10
|
-
export interface InternalSignal<T> extends Signal<T> {
|
|
11
|
-
lastChangedEpoch: number;
|
|
12
|
-
consumers: Set<ReactiveConsumer>;
|
|
13
|
-
}
|
|
14
|
-
export type ReactiveConsumer = {
|
|
15
|
-
type: "computed";
|
|
16
|
-
signal: InternalSignal<any>;
|
|
17
|
-
} | {
|
|
18
|
-
type: "effect";
|
|
19
|
-
notify(): void;
|
|
20
|
-
};
|
|
21
|
-
export declare const RESET_VALUE: unique symbol;
|
|
22
|
-
export type RESET_VALUE = typeof RESET_VALUE;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { RecordsDiff, StoreRecord } from "./types";
|
|
2
|
-
export declare function createEmptyRecordsDiff<TRecord extends StoreRecord>(): RecordsDiff<TRecord>;
|
|
3
|
-
export declare function isRecordsDiffEmpty<TRecord extends StoreRecord>(diff: RecordsDiff<TRecord>): boolean;
|
|
4
|
-
export declare function getRecordMap<TRecord extends StoreRecord>(records: Map<string, TRecord> | Iterable<TRecord>): Map<string, TRecord>;
|
|
5
|
-
export declare function getRecordsDiff<TRecord extends StoreRecord>(before: Map<string, TRecord> | Iterable<TRecord>, after: Map<string, TRecord> | Iterable<TRecord>): RecordsDiff<TRecord>;
|
|
6
|
-
export declare function invertRecordsDiff<TRecord extends StoreRecord>(diff: RecordsDiff<TRecord>): RecordsDiff<TRecord>;
|
|
7
|
-
export declare function composeRecordsDiff<TRecord extends StoreRecord, TNextRecord extends TRecord>(left: RecordsDiff<TRecord>, right: RecordsDiff<TNextRecord>): RecordsDiff<TRecord | TNextRecord>;
|
|
8
|
-
export declare function squashRecordsDiffs<TRecord extends StoreRecord, TNextRecord extends TRecord>(diffs: Iterable<RecordsDiff<TRecord> | RecordsDiff<TNextRecord>>): RecordsDiff<TRecord | TNextRecord>;
|
|
9
|
-
export declare function filterRecordsDiff<TRecord extends StoreRecord, TFilteredRecord extends TRecord>(diff: RecordsDiff<TRecord>, predicate: (record: TRecord) => record is TFilteredRecord): RecordsDiff<TFilteredRecord>;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { RecordsDiff, StoreRecord } from "./types";
|
|
2
|
-
export interface StoreHistoryEntry<TRecord extends StoreRecord = StoreRecord> {
|
|
3
|
-
forward: RecordsDiff<TRecord>;
|
|
4
|
-
inverse: RecordsDiff<TRecord>;
|
|
5
|
-
label: string;
|
|
6
|
-
}
|
|
7
|
-
export declare function createStoreHistoryEntry<TRecord extends StoreRecord>(label: string, forward: RecordsDiff<TRecord>): StoreHistoryEntry<TRecord>;
|
|
8
|
-
export declare class StoreHistoryBuffer<TRecord extends StoreRecord = StoreRecord> {
|
|
9
|
-
private readonly undoStack;
|
|
10
|
-
private readonly redoStack;
|
|
11
|
-
get canUndo(): boolean;
|
|
12
|
-
get canRedo(): boolean;
|
|
13
|
-
clear(): void;
|
|
14
|
-
append(diff: RecordsDiff<TRecord>, label?: string): void;
|
|
15
|
-
undo(): StoreHistoryEntry<TRecord> | null;
|
|
16
|
-
redo(): StoreHistoryEntry<TRecord> | null;
|
|
17
|
-
/** Restores only the cursor movement performed by undo(). */
|
|
18
|
-
rollbackUndo(entry: StoreHistoryEntry<TRecord>): void;
|
|
19
|
-
/** Restores only the cursor movement performed by redo(). */
|
|
20
|
-
rollbackRedo(entry: StoreHistoryEntry<TRecord>): void;
|
|
21
|
-
getEntries(): readonly StoreHistoryEntry<TRecord>[];
|
|
22
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { composeRecordsDiff, createEmptyRecordsDiff, filterRecordsDiff, getRecordMap, getRecordsDiff, invertRecordsDiff, isRecordsDiffEmpty, squashRecordsDiffs, } from "./diff";
|
|
2
|
-
export { createStoreHistoryEntry, StoreHistoryBuffer, } from "./history";
|
|
3
|
-
export { Store, type StoreOptions } from "./store";
|
|
4
|
-
export type { ChangeSource, RecordUpdate, RecordsDiff, ScopedStoreRecord, StoreRecord, StoreChange, StoreScopeOf, StoreSnapshot, } from "./types";
|
|
5
|
-
export type { StoreHistoryEntry } from "./history";
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { type Signal, type SignalGraph } from "../signals/index";
|
|
2
|
-
import type { ChangeSource, RecordsDiff, ScopedStoreRecord, StoreChange, StoreRecord, StoreScopeOf } from "./types";
|
|
3
|
-
type StoreListener<TRecord extends StoreRecord> = (change: StoreChange<TRecord>) => void;
|
|
4
|
-
export interface StoreOptions<TRecord extends StoreRecord> {
|
|
5
|
-
signals?: SignalGraph;
|
|
6
|
-
writeGuard?: (change: StoreChange<TRecord>) => void;
|
|
7
|
-
}
|
|
8
|
-
type ScopedRecord<TRecord extends StoreRecord> = Extract<TRecord, ScopedStoreRecord>;
|
|
9
|
-
export declare class Store<TRecord extends StoreRecord = StoreRecord> {
|
|
10
|
-
readonly signals: SignalGraph;
|
|
11
|
-
private readonly records;
|
|
12
|
-
private activeTransaction;
|
|
13
|
-
private readonly recordAtoms;
|
|
14
|
-
private readonly revisionAtom;
|
|
15
|
-
private readonly draftRevisionAtom;
|
|
16
|
-
private readonly listeners;
|
|
17
|
-
private readonly writeGuard?;
|
|
18
|
-
constructor(initialRecords: TRecord[], options?: StoreOptions<TRecord>);
|
|
19
|
-
get(id: string): TRecord | undefined;
|
|
20
|
-
getRevision(): number;
|
|
21
|
-
getActiveTransactionRevision(): number | null;
|
|
22
|
-
getActiveTransactionDiff(): RecordsDiff<TRecord>;
|
|
23
|
-
getRecordSignal(id: string): Signal<TRecord | undefined>;
|
|
24
|
-
getAll(): TRecord[];
|
|
25
|
-
getByScope<TScope extends StoreScopeOf<ScopedRecord<TRecord>>>(scope: TScope): Array<Extract<ScopedRecord<TRecord>, {
|
|
26
|
-
scope: TScope;
|
|
27
|
-
}>>;
|
|
28
|
-
listen(listener: StoreListener<TRecord>): () => void;
|
|
29
|
-
atomic(fn: () => void, source?: ChangeSource): void;
|
|
30
|
-
put(records: TRecord[], source?: ChangeSource): void;
|
|
31
|
-
remove(ids: string[], source?: ChangeSource): void;
|
|
32
|
-
applyDiff<TChangeRecord extends TRecord>(diff: RecordsDiff<TChangeRecord>, source?: ChangeSource): void;
|
|
33
|
-
private stageRecord;
|
|
34
|
-
private getReadableRecords;
|
|
35
|
-
private requireActiveTransaction;
|
|
36
|
-
private bumpDraftRevision;
|
|
37
|
-
private restoreTransactionSignals;
|
|
38
|
-
private notifyListeners;
|
|
39
|
-
}
|
|
40
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export type ChangeSource = "user" | "system" | "history";
|
|
2
|
-
export interface StoreRecord {
|
|
3
|
-
id: string;
|
|
4
|
-
}
|
|
5
|
-
export interface ScopedStoreRecord<TScope extends string = string> extends StoreRecord {
|
|
6
|
-
scope: TScope;
|
|
7
|
-
}
|
|
8
|
-
export type StoreScopeOf<TRecord> = TRecord extends {
|
|
9
|
-
scope: infer TScope extends string;
|
|
10
|
-
} ? TScope : never;
|
|
11
|
-
export interface StoreSnapshot<TRecord extends StoreRecord = StoreRecord, TSchemaVersion extends number = number> {
|
|
12
|
-
schemaVersion: TSchemaVersion;
|
|
13
|
-
records: TRecord[];
|
|
14
|
-
}
|
|
15
|
-
export interface RecordUpdate<TRecord extends StoreRecord = StoreRecord> {
|
|
16
|
-
before: TRecord;
|
|
17
|
-
after: TRecord;
|
|
18
|
-
}
|
|
19
|
-
export interface RecordsDiff<TRecord extends StoreRecord = StoreRecord> {
|
|
20
|
-
added: TRecord[];
|
|
21
|
-
updated: RecordUpdate<TRecord>[];
|
|
22
|
-
removed: TRecord[];
|
|
23
|
-
}
|
|
24
|
-
export interface StoreChange<TRecord extends StoreRecord = StoreRecord> {
|
|
25
|
-
source: ChangeSource;
|
|
26
|
-
diff: RecordsDiff<TRecord>;
|
|
27
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { SignalGraph } from "./core";
|
|
2
|
-
import type { Signal } from "./types";
|
|
3
|
-
export interface AtomOptions<T> {
|
|
4
|
-
isEqual?: (left: T, right: T) => boolean;
|
|
5
|
-
}
|
|
6
|
-
export interface Atom<T> extends Signal<T> {
|
|
7
|
-
set(value: T): T;
|
|
8
|
-
update(updater: (value: T) => T): T;
|
|
9
|
-
}
|
|
10
|
-
export declare function createAtom<T>(graph: SignalGraph, name: string, initialValue: T, options?: AtomOptions<T>): Atom<T>;
|
|
11
|
-
export declare function isAtom(value: unknown): value is Atom<unknown>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { SignalGraph } from "./core";
|
|
2
|
-
import type { Signal } from "./types";
|
|
3
|
-
declare const UNINITIALIZED_VALUE: unique symbol;
|
|
4
|
-
export type UNINITIALIZED = typeof UNINITIALIZED_VALUE;
|
|
5
|
-
export { UNINITIALIZED_VALUE as UNINITIALIZED };
|
|
6
|
-
export interface ComputedOptions<T> {
|
|
7
|
-
isEqual?: (left: T, right: T) => boolean;
|
|
8
|
-
}
|
|
9
|
-
export interface Computed<T> extends Signal<T> {
|
|
10
|
-
readonly isComputed: true;
|
|
11
|
-
}
|
|
12
|
-
export declare function createComputed<T>(graph: SignalGraph, name: string, derive: (previous: T | UNINITIALIZED) => T, options?: ComputedOptions<T>): Computed<T>;
|
|
13
|
-
export declare function isComputed(value: unknown): value is Computed<unknown>;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { type Atom, type AtomOptions } from "./atom";
|
|
2
|
-
import { type Computed, type ComputedOptions, type UNINITIALIZED } from "./computed";
|
|
3
|
-
import { type EffectSchedulerOptions } from "./effect";
|
|
4
|
-
import type { InternalSignal, ReactiveConsumer } from "./types";
|
|
5
|
-
interface InternalAtom<T> extends InternalSignal<T> {
|
|
6
|
-
__unsafe__isEqual(left: T, right: T): boolean;
|
|
7
|
-
__unsafe__restore(value: T, lastChangedEpoch: number): void;
|
|
8
|
-
}
|
|
9
|
-
export declare class SignalGraph {
|
|
10
|
-
private epoch;
|
|
11
|
-
private currentTransaction;
|
|
12
|
-
private captureStack;
|
|
13
|
-
readonly atom: <T>(name: string, initialValue: T, options?: AtomOptions<T>) => Atom<T>;
|
|
14
|
-
readonly computed: <T>(name: string, derive: (previous: T | UNINITIALIZED) => T, options?: ComputedOptions<T>) => Computed<T>;
|
|
15
|
-
readonly effect: (name: string, fn: () => void, options?: EffectSchedulerOptions) => (() => void);
|
|
16
|
-
readonly transact: (fn: () => void) => void;
|
|
17
|
-
getEpoch(): number;
|
|
18
|
-
isComputingSignal(): boolean;
|
|
19
|
-
/** @internal */
|
|
20
|
-
advanceEpoch(): number;
|
|
21
|
-
/** @internal */
|
|
22
|
-
noteInitialValue<T>(atom: InternalAtom<T>, previousValue: T, previousLastChangedEpoch: number): void;
|
|
23
|
-
/** @internal */
|
|
24
|
-
startCapture(consumer: ReactiveConsumer): void;
|
|
25
|
-
/** @internal */
|
|
26
|
-
stopCapture(): Set<InternalSignal<any>>;
|
|
27
|
-
/** @internal */
|
|
28
|
-
trackDependency(dependency: InternalSignal<any>): void;
|
|
29
|
-
/** @internal */
|
|
30
|
-
atomDidChange(atom: InternalAtom<any>): void;
|
|
31
|
-
private restoreInitialAtomSnapshots;
|
|
32
|
-
private flushChanges;
|
|
33
|
-
}
|
|
34
|
-
export declare function createSignalGraph(): SignalGraph;
|
|
35
|
-
export {};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { SignalGraph } from "./core";
|
|
2
|
-
export interface EffectSchedulerOptions {
|
|
3
|
-
scheduleEffect?: (execute: () => void) => void;
|
|
4
|
-
}
|
|
5
|
-
export declare function createEffect(graph: SignalGraph, name: string, fn: () => void, options?: EffectSchedulerOptions): () => void;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { isAtom } from "./atom";
|
|
2
|
-
export type { Atom, AtomOptions } from "./atom";
|
|
3
|
-
export { isComputed, UNINITIALIZED } from "./computed";
|
|
4
|
-
export type { Computed, ComputedOptions } from "./computed";
|
|
5
|
-
export type { EffectSchedulerOptions } from "./effect";
|
|
6
|
-
export { createSignalGraph, SignalGraph } from "./core";
|
|
7
|
-
export { RESET_VALUE } from "./types";
|
|
8
|
-
export type { Signal } from "./types";
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { SignalGraph } from "./core";
|
|
2
|
-
/** A readable node owned by one reactive graph. */
|
|
3
|
-
export interface Signal<T> {
|
|
4
|
-
readonly graph: SignalGraph;
|
|
5
|
-
readonly name: string;
|
|
6
|
-
get(): T;
|
|
7
|
-
peek(): T;
|
|
8
|
-
}
|
|
9
|
-
/** @internal */
|
|
10
|
-
export interface InternalSignal<T> extends Signal<T> {
|
|
11
|
-
lastChangedEpoch: number;
|
|
12
|
-
consumers: Set<ReactiveConsumer>;
|
|
13
|
-
}
|
|
14
|
-
export type ReactiveConsumer = {
|
|
15
|
-
type: "computed";
|
|
16
|
-
signal: InternalSignal<any>;
|
|
17
|
-
} | {
|
|
18
|
-
type: "effect";
|
|
19
|
-
notify(): void;
|
|
20
|
-
};
|
|
21
|
-
export declare const RESET_VALUE: unique symbol;
|
|
22
|
-
export type RESET_VALUE = typeof RESET_VALUE;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { RecordsDiff, StoreRecord } from "./types";
|
|
2
|
-
export declare function createEmptyRecordsDiff<TRecord extends StoreRecord>(): RecordsDiff<TRecord>;
|
|
3
|
-
export declare function isRecordsDiffEmpty<TRecord extends StoreRecord>(diff: RecordsDiff<TRecord>): boolean;
|
|
4
|
-
export declare function getRecordMap<TRecord extends StoreRecord>(records: Map<string, TRecord> | Iterable<TRecord>): Map<string, TRecord>;
|
|
5
|
-
export declare function getRecordsDiff<TRecord extends StoreRecord>(before: Map<string, TRecord> | Iterable<TRecord>, after: Map<string, TRecord> | Iterable<TRecord>): RecordsDiff<TRecord>;
|
|
6
|
-
export declare function invertRecordsDiff<TRecord extends StoreRecord>(diff: RecordsDiff<TRecord>): RecordsDiff<TRecord>;
|
|
7
|
-
export declare function composeRecordsDiff<TRecord extends StoreRecord, TNextRecord extends TRecord>(left: RecordsDiff<TRecord>, right: RecordsDiff<TNextRecord>): RecordsDiff<TRecord | TNextRecord>;
|
|
8
|
-
export declare function squashRecordsDiffs<TRecord extends StoreRecord, TNextRecord extends TRecord>(diffs: Iterable<RecordsDiff<TRecord> | RecordsDiff<TNextRecord>>): RecordsDiff<TRecord | TNextRecord>;
|
|
9
|
-
export declare function filterRecordsDiff<TRecord extends StoreRecord, TFilteredRecord extends TRecord>(diff: RecordsDiff<TRecord>, predicate: (record: TRecord) => record is TFilteredRecord): RecordsDiff<TFilteredRecord>;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { RecordsDiff, StoreRecord } from "./types";
|
|
2
|
-
export interface StoreHistoryEntry<TRecord extends StoreRecord = StoreRecord> {
|
|
3
|
-
forward: RecordsDiff<TRecord>;
|
|
4
|
-
inverse: RecordsDiff<TRecord>;
|
|
5
|
-
label: string;
|
|
6
|
-
}
|
|
7
|
-
export declare function createStoreHistoryEntry<TRecord extends StoreRecord>(label: string, forward: RecordsDiff<TRecord>): StoreHistoryEntry<TRecord>;
|
|
8
|
-
export declare class StoreHistoryBuffer<TRecord extends StoreRecord = StoreRecord> {
|
|
9
|
-
private readonly undoStack;
|
|
10
|
-
private readonly redoStack;
|
|
11
|
-
get canUndo(): boolean;
|
|
12
|
-
get canRedo(): boolean;
|
|
13
|
-
clear(): void;
|
|
14
|
-
append(diff: RecordsDiff<TRecord>, label?: string): void;
|
|
15
|
-
undo(): StoreHistoryEntry<TRecord> | null;
|
|
16
|
-
redo(): StoreHistoryEntry<TRecord> | null;
|
|
17
|
-
/** Restores only the cursor movement performed by undo(). */
|
|
18
|
-
rollbackUndo(entry: StoreHistoryEntry<TRecord>): void;
|
|
19
|
-
/** Restores only the cursor movement performed by redo(). */
|
|
20
|
-
rollbackRedo(entry: StoreHistoryEntry<TRecord>): void;
|
|
21
|
-
getEntries(): readonly StoreHistoryEntry<TRecord>[];
|
|
22
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { composeRecordsDiff, createEmptyRecordsDiff, filterRecordsDiff, getRecordMap, getRecordsDiff, invertRecordsDiff, isRecordsDiffEmpty, squashRecordsDiffs, } from "./diff";
|
|
2
|
-
export { createStoreHistoryEntry, StoreHistoryBuffer, } from "./history";
|
|
3
|
-
export { Store, type StoreOptions } from "./store";
|
|
4
|
-
export type { ChangeSource, RecordUpdate, RecordsDiff, ScopedStoreRecord, StoreRecord, StoreChange, StoreScopeOf, StoreSnapshot, } from "./types";
|
|
5
|
-
export type { StoreHistoryEntry } from "./history";
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { type Signal, type SignalGraph } from "../signals/index";
|
|
2
|
-
import type { ChangeSource, RecordsDiff, ScopedStoreRecord, StoreChange, StoreRecord, StoreScopeOf } from "./types";
|
|
3
|
-
type StoreListener<TRecord extends StoreRecord> = (change: StoreChange<TRecord>) => void;
|
|
4
|
-
export interface StoreOptions<TRecord extends StoreRecord> {
|
|
5
|
-
signals?: SignalGraph;
|
|
6
|
-
writeGuard?: (change: StoreChange<TRecord>) => void;
|
|
7
|
-
}
|
|
8
|
-
type ScopedRecord<TRecord extends StoreRecord> = Extract<TRecord, ScopedStoreRecord>;
|
|
9
|
-
export declare class Store<TRecord extends StoreRecord = StoreRecord> {
|
|
10
|
-
readonly signals: SignalGraph;
|
|
11
|
-
private readonly records;
|
|
12
|
-
private activeTransaction;
|
|
13
|
-
private readonly recordAtoms;
|
|
14
|
-
private readonly revisionAtom;
|
|
15
|
-
private readonly draftRevisionAtom;
|
|
16
|
-
private readonly listeners;
|
|
17
|
-
private readonly writeGuard?;
|
|
18
|
-
constructor(initialRecords: TRecord[], options?: StoreOptions<TRecord>);
|
|
19
|
-
get(id: string): TRecord | undefined;
|
|
20
|
-
getRevision(): number;
|
|
21
|
-
getActiveTransactionRevision(): number | null;
|
|
22
|
-
getActiveTransactionDiff(): RecordsDiff<TRecord>;
|
|
23
|
-
getRecordSignal(id: string): Signal<TRecord | undefined>;
|
|
24
|
-
getAll(): TRecord[];
|
|
25
|
-
getByScope<TScope extends StoreScopeOf<ScopedRecord<TRecord>>>(scope: TScope): Array<Extract<ScopedRecord<TRecord>, {
|
|
26
|
-
scope: TScope;
|
|
27
|
-
}>>;
|
|
28
|
-
listen(listener: StoreListener<TRecord>): () => void;
|
|
29
|
-
atomic(fn: () => void, source?: ChangeSource): void;
|
|
30
|
-
put(records: TRecord[], source?: ChangeSource): void;
|
|
31
|
-
remove(ids: string[], source?: ChangeSource): void;
|
|
32
|
-
applyDiff<TChangeRecord extends TRecord>(diff: RecordsDiff<TChangeRecord>, source?: ChangeSource): void;
|
|
33
|
-
private stageRecord;
|
|
34
|
-
private getReadableRecords;
|
|
35
|
-
private requireActiveTransaction;
|
|
36
|
-
private bumpDraftRevision;
|
|
37
|
-
private restoreTransactionSignals;
|
|
38
|
-
private notifyListeners;
|
|
39
|
-
}
|
|
40
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export type ChangeSource = "user" | "system" | "history";
|
|
2
|
-
export interface StoreRecord {
|
|
3
|
-
id: string;
|
|
4
|
-
}
|
|
5
|
-
export interface ScopedStoreRecord<TScope extends string = string> extends StoreRecord {
|
|
6
|
-
scope: TScope;
|
|
7
|
-
}
|
|
8
|
-
export type StoreScopeOf<TRecord> = TRecord extends {
|
|
9
|
-
scope: infer TScope extends string;
|
|
10
|
-
} ? TScope : never;
|
|
11
|
-
export interface StoreSnapshot<TRecord extends StoreRecord = StoreRecord, TSchemaVersion extends number = number> {
|
|
12
|
-
schemaVersion: TSchemaVersion;
|
|
13
|
-
records: TRecord[];
|
|
14
|
-
}
|
|
15
|
-
export interface RecordUpdate<TRecord extends StoreRecord = StoreRecord> {
|
|
16
|
-
before: TRecord;
|
|
17
|
-
after: TRecord;
|
|
18
|
-
}
|
|
19
|
-
export interface RecordsDiff<TRecord extends StoreRecord = StoreRecord> {
|
|
20
|
-
added: TRecord[];
|
|
21
|
-
updated: RecordUpdate<TRecord>[];
|
|
22
|
-
removed: TRecord[];
|
|
23
|
-
}
|
|
24
|
-
export interface StoreChange<TRecord extends StoreRecord = StoreRecord> {
|
|
25
|
-
source: ChangeSource;
|
|
26
|
-
diff: RecordsDiff<TRecord>;
|
|
27
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { RecordsDiff, StoreRecord } from "./types";
|
|
2
|
-
export declare function createEmptyRecordsDiff<TRecord extends StoreRecord>(): RecordsDiff<TRecord>;
|
|
3
|
-
export declare function isRecordsDiffEmpty<TRecord extends StoreRecord>(diff: RecordsDiff<TRecord>): boolean;
|
|
4
|
-
export declare function getRecordMap<TRecord extends StoreRecord>(records: Map<string, TRecord> | Iterable<TRecord>): Map<string, TRecord>;
|
|
5
|
-
export declare function getRecordsDiff<TRecord extends StoreRecord>(before: Map<string, TRecord> | Iterable<TRecord>, after: Map<string, TRecord> | Iterable<TRecord>): RecordsDiff<TRecord>;
|
|
6
|
-
export declare function invertRecordsDiff<TRecord extends StoreRecord>(diff: RecordsDiff<TRecord>): RecordsDiff<TRecord>;
|
|
7
|
-
export declare function composeRecordsDiff<TRecord extends StoreRecord, TNextRecord extends TRecord>(left: RecordsDiff<TRecord>, right: RecordsDiff<TNextRecord>): RecordsDiff<TRecord | TNextRecord>;
|
|
8
|
-
export declare function squashRecordsDiffs<TRecord extends StoreRecord, TNextRecord extends TRecord>(diffs: Iterable<RecordsDiff<TRecord> | RecordsDiff<TNextRecord>>): RecordsDiff<TRecord | TNextRecord>;
|
|
9
|
-
export declare function filterRecordsDiff<TRecord extends StoreRecord, TFilteredRecord extends TRecord>(diff: RecordsDiff<TRecord>, predicate: (record: TRecord) => record is TFilteredRecord): RecordsDiff<TFilteredRecord>;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { RecordsDiff, StoreRecord } from "./types";
|
|
2
|
-
export interface StoreHistoryEntry<TRecord extends StoreRecord = StoreRecord> {
|
|
3
|
-
forward: RecordsDiff<TRecord>;
|
|
4
|
-
inverse: RecordsDiff<TRecord>;
|
|
5
|
-
label: string;
|
|
6
|
-
}
|
|
7
|
-
export declare function createStoreHistoryEntry<TRecord extends StoreRecord>(label: string, forward: RecordsDiff<TRecord>): StoreHistoryEntry<TRecord>;
|
|
8
|
-
export declare class StoreHistoryBuffer<TRecord extends StoreRecord = StoreRecord> {
|
|
9
|
-
private readonly undoStack;
|
|
10
|
-
private readonly redoStack;
|
|
11
|
-
get canUndo(): boolean;
|
|
12
|
-
get canRedo(): boolean;
|
|
13
|
-
clear(): void;
|
|
14
|
-
append(diff: RecordsDiff<TRecord>, label?: string): void;
|
|
15
|
-
undo(): StoreHistoryEntry<TRecord> | null;
|
|
16
|
-
redo(): StoreHistoryEntry<TRecord> | null;
|
|
17
|
-
/** Restores only the cursor movement performed by undo(). */
|
|
18
|
-
rollbackUndo(entry: StoreHistoryEntry<TRecord>): void;
|
|
19
|
-
/** Restores only the cursor movement performed by redo(). */
|
|
20
|
-
rollbackRedo(entry: StoreHistoryEntry<TRecord>): void;
|
|
21
|
-
getEntries(): readonly StoreHistoryEntry<TRecord>[];
|
|
22
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { composeRecordsDiff, createEmptyRecordsDiff, filterRecordsDiff, getRecordMap, getRecordsDiff, invertRecordsDiff, isRecordsDiffEmpty, squashRecordsDiffs, } from "./diff";
|
|
2
|
-
export { createStoreHistoryEntry, StoreHistoryBuffer, } from "./history";
|
|
3
|
-
export { Store, type StoreOptions } from "./store";
|
|
4
|
-
export type { ChangeSource, RecordUpdate, RecordsDiff, ScopedStoreRecord, StoreRecord, StoreChange, StoreScopeOf, StoreSnapshot, } from "./types";
|
|
5
|
-
export type { StoreHistoryEntry } from "./history";
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { type Signal, type SignalGraph } from "../signals/index";
|
|
2
|
-
import type { ChangeSource, RecordsDiff, ScopedStoreRecord, StoreChange, StoreRecord, StoreScopeOf } from "./types";
|
|
3
|
-
type StoreListener<TRecord extends StoreRecord> = (change: StoreChange<TRecord>) => void;
|
|
4
|
-
export interface StoreOptions<TRecord extends StoreRecord> {
|
|
5
|
-
signals?: SignalGraph;
|
|
6
|
-
writeGuard?: (change: StoreChange<TRecord>) => void;
|
|
7
|
-
}
|
|
8
|
-
type ScopedRecord<TRecord extends StoreRecord> = Extract<TRecord, ScopedStoreRecord>;
|
|
9
|
-
export declare class Store<TRecord extends StoreRecord = StoreRecord> {
|
|
10
|
-
readonly signals: SignalGraph;
|
|
11
|
-
private readonly records;
|
|
12
|
-
private activeTransaction;
|
|
13
|
-
private readonly recordAtoms;
|
|
14
|
-
private readonly revisionAtom;
|
|
15
|
-
private readonly draftRevisionAtom;
|
|
16
|
-
private readonly listeners;
|
|
17
|
-
private readonly writeGuard?;
|
|
18
|
-
constructor(initialRecords: TRecord[], options?: StoreOptions<TRecord>);
|
|
19
|
-
get(id: string): TRecord | undefined;
|
|
20
|
-
getRevision(): number;
|
|
21
|
-
getActiveTransactionRevision(): number | null;
|
|
22
|
-
getActiveTransactionDiff(): RecordsDiff<TRecord>;
|
|
23
|
-
getRecordSignal(id: string): Signal<TRecord | undefined>;
|
|
24
|
-
getAll(): TRecord[];
|
|
25
|
-
getByScope<TScope extends StoreScopeOf<ScopedRecord<TRecord>>>(scope: TScope): Array<Extract<ScopedRecord<TRecord>, {
|
|
26
|
-
scope: TScope;
|
|
27
|
-
}>>;
|
|
28
|
-
listen(listener: StoreListener<TRecord>): () => void;
|
|
29
|
-
atomic(fn: () => void, source?: ChangeSource): void;
|
|
30
|
-
put(records: TRecord[], source?: ChangeSource): void;
|
|
31
|
-
remove(ids: string[], source?: ChangeSource): void;
|
|
32
|
-
applyDiff<TChangeRecord extends TRecord>(diff: RecordsDiff<TChangeRecord>, source?: ChangeSource): void;
|
|
33
|
-
private stageRecord;
|
|
34
|
-
private getReadableRecords;
|
|
35
|
-
private requireActiveTransaction;
|
|
36
|
-
private bumpDraftRevision;
|
|
37
|
-
private restoreTransactionSignals;
|
|
38
|
-
private notifyListeners;
|
|
39
|
-
}
|
|
40
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export type ChangeSource = "user" | "system" | "history";
|
|
2
|
-
export interface StoreRecord {
|
|
3
|
-
id: string;
|
|
4
|
-
}
|
|
5
|
-
export interface ScopedStoreRecord<TScope extends string = string> extends StoreRecord {
|
|
6
|
-
scope: TScope;
|
|
7
|
-
}
|
|
8
|
-
export type StoreScopeOf<TRecord> = TRecord extends {
|
|
9
|
-
scope: infer TScope extends string;
|
|
10
|
-
} ? TScope : never;
|
|
11
|
-
export interface StoreSnapshot<TRecord extends StoreRecord = StoreRecord, TSchemaVersion extends number = number> {
|
|
12
|
-
schemaVersion: TSchemaVersion;
|
|
13
|
-
records: TRecord[];
|
|
14
|
-
}
|
|
15
|
-
export interface RecordUpdate<TRecord extends StoreRecord = StoreRecord> {
|
|
16
|
-
before: TRecord;
|
|
17
|
-
after: TRecord;
|
|
18
|
-
}
|
|
19
|
-
export interface RecordsDiff<TRecord extends StoreRecord = StoreRecord> {
|
|
20
|
-
added: TRecord[];
|
|
21
|
-
updated: RecordUpdate<TRecord>[];
|
|
22
|
-
removed: TRecord[];
|
|
23
|
-
}
|
|
24
|
-
export interface StoreChange<TRecord extends StoreRecord = StoreRecord> {
|
|
25
|
-
source: ChangeSource;
|
|
26
|
-
diff: RecordsDiff<TRecord>;
|
|
27
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { SignalGraph } from "./core";
|
|
2
|
-
import type { Signal } from "./types";
|
|
3
|
-
export interface AtomOptions<T> {
|
|
4
|
-
isEqual?: (left: T, right: T) => boolean;
|
|
5
|
-
}
|
|
6
|
-
export interface Atom<T> extends Signal<T> {
|
|
7
|
-
set(value: T): T;
|
|
8
|
-
update(updater: (value: T) => T): T;
|
|
9
|
-
}
|
|
10
|
-
export declare function createAtom<T>(graph: SignalGraph, name: string, initialValue: T, options?: AtomOptions<T>): Atom<T>;
|
|
11
|
-
export declare function isAtom(value: unknown): value is Atom<unknown>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { SignalGraph } from "./core";
|
|
2
|
-
import type { Signal } from "./types";
|
|
3
|
-
declare const UNINITIALIZED_VALUE: unique symbol;
|
|
4
|
-
export type UNINITIALIZED = typeof UNINITIALIZED_VALUE;
|
|
5
|
-
export { UNINITIALIZED_VALUE as UNINITIALIZED };
|
|
6
|
-
export interface ComputedOptions<T> {
|
|
7
|
-
isEqual?: (left: T, right: T) => boolean;
|
|
8
|
-
}
|
|
9
|
-
export interface Computed<T> extends Signal<T> {
|
|
10
|
-
readonly isComputed: true;
|
|
11
|
-
}
|
|
12
|
-
export declare function createComputed<T>(graph: SignalGraph, name: string, derive: (previous: T | UNINITIALIZED) => T, options?: ComputedOptions<T>): Computed<T>;
|
|
13
|
-
export declare function isComputed(value: unknown): value is Computed<unknown>;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { type Atom, type AtomOptions } from "./atom";
|
|
2
|
-
import { type Computed, type ComputedOptions, type UNINITIALIZED } from "./computed";
|
|
3
|
-
import { type EffectSchedulerOptions } from "./effect";
|
|
4
|
-
import type { InternalSignal, ReactiveConsumer } from "./types";
|
|
5
|
-
interface InternalAtom<T> extends InternalSignal<T> {
|
|
6
|
-
__unsafe__isEqual(left: T, right: T): boolean;
|
|
7
|
-
__unsafe__restore(value: T, lastChangedEpoch: number): void;
|
|
8
|
-
}
|
|
9
|
-
export declare class SignalGraph {
|
|
10
|
-
private epoch;
|
|
11
|
-
private currentTransaction;
|
|
12
|
-
private captureStack;
|
|
13
|
-
readonly atom: <T>(name: string, initialValue: T, options?: AtomOptions<T>) => Atom<T>;
|
|
14
|
-
readonly computed: <T>(name: string, derive: (previous: T | UNINITIALIZED) => T, options?: ComputedOptions<T>) => Computed<T>;
|
|
15
|
-
readonly effect: (name: string, fn: () => void, options?: EffectSchedulerOptions) => (() => void);
|
|
16
|
-
readonly transact: (fn: () => void) => void;
|
|
17
|
-
getEpoch(): number;
|
|
18
|
-
isComputingSignal(): boolean;
|
|
19
|
-
/** @internal */
|
|
20
|
-
advanceEpoch(): number;
|
|
21
|
-
/** @internal */
|
|
22
|
-
noteInitialValue<T>(atom: InternalAtom<T>, previousValue: T, previousLastChangedEpoch: number): void;
|
|
23
|
-
/** @internal */
|
|
24
|
-
startCapture(consumer: ReactiveConsumer): void;
|
|
25
|
-
/** @internal */
|
|
26
|
-
stopCapture(): Set<InternalSignal<any>>;
|
|
27
|
-
/** @internal */
|
|
28
|
-
trackDependency(dependency: InternalSignal<any>): void;
|
|
29
|
-
/** @internal */
|
|
30
|
-
atomDidChange(atom: InternalAtom<any>): void;
|
|
31
|
-
private restoreInitialAtomSnapshots;
|
|
32
|
-
private flushChanges;
|
|
33
|
-
}
|
|
34
|
-
export declare function createSignalGraph(): SignalGraph;
|
|
35
|
-
export {};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { SignalGraph } from "./core";
|
|
2
|
-
export interface EffectSchedulerOptions {
|
|
3
|
-
scheduleEffect?: (execute: () => void) => void;
|
|
4
|
-
}
|
|
5
|
-
export declare function createEffect(graph: SignalGraph, name: string, fn: () => void, options?: EffectSchedulerOptions): () => void;
|