document-model 1.0.20 → 1.0.21
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/package.json +16 -15
- package/dist/browser/document/actions/creators.d.ts +0 -46
- package/dist/browser/document/actions/index.d.ts +0 -10
- package/dist/browser/document/actions/types.d.ts +0 -8
- package/dist/browser/document/index.d.ts +0 -6
- package/dist/browser/document/object.d.ts +0 -391
- package/dist/browser/document/reducer.d.ts +0 -16
- package/dist/browser/document/schema/index.d.ts +0 -2
- package/dist/browser/document/schema/types.d.ts +0 -174
- package/dist/browser/document/schema/zod.d.ts +0 -113
- package/dist/browser/document/signal.d.ts +0 -22
- package/dist/browser/document/types.d.ts +0 -190
- package/dist/browser/document/utils/base.d.ts +0 -61
- package/dist/browser/document/utils/file.d.ts +0 -47
- package/dist/browser/document/utils/index.d.ts +0 -2
- package/dist/browser/document/utils/node.d.ts +0 -9
- package/dist/browser/document-model/custom/reducers/header.d.ts +0 -2
- package/dist/browser/document-model/custom/reducers/module.d.ts +0 -2
- package/dist/browser/document-model/custom/reducers/operation-error.d.ts +0 -2
- package/dist/browser/document-model/custom/reducers/operation-example.d.ts +0 -2
- package/dist/browser/document-model/custom/reducers/operation.d.ts +0 -2
- package/dist/browser/document-model/custom/reducers/state.d.ts +0 -2
- package/dist/browser/document-model/custom/reducers/versioning.d.ts +0 -7
- package/dist/browser/document-model/custom/utils.d.ts +0 -1
- package/dist/browser/document-model/gen/actions.d.ts +0 -15
- package/dist/browser/document-model/gen/creators.d.ts +0 -7
- package/dist/browser/document-model/gen/document-model.d.ts +0 -2
- package/dist/browser/document-model/gen/header/actions.d.ts +0 -9
- package/dist/browser/document-model/gen/header/creators.d.ts +0 -8
- package/dist/browser/document-model/gen/header/object.d.ts +0 -11
- package/dist/browser/document-model/gen/header/operations.d.ts +0 -10
- package/dist/browser/document-model/gen/index.d.ts +0 -5
- package/dist/browser/document-model/gen/module/actions.d.ts +0 -8
- package/dist/browser/document-model/gen/module/creators.d.ts +0 -7
- package/dist/browser/document-model/gen/module/object.d.ts +0 -10
- package/dist/browser/document-model/gen/module/operations.d.ts +0 -9
- package/dist/browser/document-model/gen/object.d.ts +0 -28
- package/dist/browser/document-model/gen/operation/actions.d.ts +0 -13
- package/dist/browser/document-model/gen/operation/creators.d.ts +0 -12
- package/dist/browser/document-model/gen/operation/object.d.ts +0 -15
- package/dist/browser/document-model/gen/operation/operations.d.ts +0 -14
- package/dist/browser/document-model/gen/operation-error/actions.d.ts +0 -10
- package/dist/browser/document-model/gen/operation-error/creators.d.ts +0 -9
- package/dist/browser/document-model/gen/operation-error/object.d.ts +0 -12
- package/dist/browser/document-model/gen/operation-error/operations.d.ts +0 -11
- package/dist/browser/document-model/gen/operation-example/actions.d.ts +0 -7
- package/dist/browser/document-model/gen/operation-example/creators.d.ts +0 -6
- package/dist/browser/document-model/gen/operation-example/object.d.ts +0 -9
- package/dist/browser/document-model/gen/operation-example/operations.d.ts +0 -8
- package/dist/browser/document-model/gen/reducer.d.ts +0 -3
- package/dist/browser/document-model/gen/schema/index.d.ts +0 -2
- package/dist/browser/document-model/gen/schema/types.d.ts +0 -453
- package/dist/browser/document-model/gen/schema/zod.d.ts +0 -453
- package/dist/browser/document-model/gen/state/actions.d.ts +0 -9
- package/dist/browser/document-model/gen/state/creators.d.ts +0 -8
- package/dist/browser/document-model/gen/state/object.d.ts +0 -11
- package/dist/browser/document-model/gen/state/operations.d.ts +0 -10
- package/dist/browser/document-model/gen/types.d.ts +0 -8
- package/dist/browser/document-model/gen/utils.d.ts +0 -6
- package/dist/browser/document-model/gen/versioning/actions.d.ts +0 -8
- package/dist/browser/document-model/gen/versioning/creators.d.ts +0 -7
- package/dist/browser/document-model/gen/versioning/object.d.ts +0 -10
- package/dist/browser/document-model/gen/versioning/operations.d.ts +0 -9
- package/dist/browser/document-model/index.d.ts +0 -74
- package/dist/browser/document-model.cjs +0 -1
- package/dist/browser/document-model.d.ts +0 -1
- package/dist/browser/document-model.js +0 -16
- package/dist/browser/document.cjs +0 -1
- package/dist/browser/document.d.ts +0 -1
- package/dist/browser/document.js +0 -14
- package/dist/browser/index.cjs +0 -1
- package/dist/browser/index.d.ts +0 -25
- package/dist/browser/index.js +0 -17
- package/dist/browser/internal/index-22f88bf2.js +0 -1926
- package/dist/browser/internal/index-3607fd07.js +0 -34
- package/dist/browser/internal/index-79fde5f3.js +0 -1
- package/dist/browser/internal/index-dda5d688.js +0 -22
- package/dist/browser/internal/object-32802eed.js +0 -6
- package/dist/browser/internal/object-d03c84c9.js +0 -1779
- package/dist/node/document/actions/creators.d.ts +0 -46
- package/dist/node/document/actions/index.d.ts +0 -10
- package/dist/node/document/actions/types.d.ts +0 -8
- package/dist/node/document/index.d.ts +0 -6
- package/dist/node/document/object.d.ts +0 -391
- package/dist/node/document/reducer.d.ts +0 -16
- package/dist/node/document/schema/index.d.ts +0 -2
- package/dist/node/document/schema/types.d.ts +0 -174
- package/dist/node/document/schema/zod.d.ts +0 -113
- package/dist/node/document/signal.d.ts +0 -22
- package/dist/node/document/types.d.ts +0 -190
- package/dist/node/document/utils/base.d.ts +0 -61
- package/dist/node/document/utils/file.d.ts +0 -47
- package/dist/node/document/utils/index.d.ts +0 -2
- package/dist/node/document/utils/node.d.ts +0 -9
- package/dist/node/document-model/custom/reducers/header.d.ts +0 -2
- package/dist/node/document-model/custom/reducers/module.d.ts +0 -2
- package/dist/node/document-model/custom/reducers/operation-error.d.ts +0 -2
- package/dist/node/document-model/custom/reducers/operation-example.d.ts +0 -2
- package/dist/node/document-model/custom/reducers/operation.d.ts +0 -2
- package/dist/node/document-model/custom/reducers/state.d.ts +0 -2
- package/dist/node/document-model/custom/reducers/versioning.d.ts +0 -7
- package/dist/node/document-model/custom/utils.d.ts +0 -1
- package/dist/node/document-model/gen/actions.d.ts +0 -15
- package/dist/node/document-model/gen/creators.d.ts +0 -7
- package/dist/node/document-model/gen/document-model.d.ts +0 -2
- package/dist/node/document-model/gen/header/actions.d.ts +0 -9
- package/dist/node/document-model/gen/header/creators.d.ts +0 -8
- package/dist/node/document-model/gen/header/object.d.ts +0 -11
- package/dist/node/document-model/gen/header/operations.d.ts +0 -10
- package/dist/node/document-model/gen/index.d.ts +0 -5
- package/dist/node/document-model/gen/module/actions.d.ts +0 -8
- package/dist/node/document-model/gen/module/creators.d.ts +0 -7
- package/dist/node/document-model/gen/module/object.d.ts +0 -10
- package/dist/node/document-model/gen/module/operations.d.ts +0 -9
- package/dist/node/document-model/gen/object.d.ts +0 -28
- package/dist/node/document-model/gen/operation/actions.d.ts +0 -13
- package/dist/node/document-model/gen/operation/creators.d.ts +0 -12
- package/dist/node/document-model/gen/operation/object.d.ts +0 -15
- package/dist/node/document-model/gen/operation/operations.d.ts +0 -14
- package/dist/node/document-model/gen/operation-error/actions.d.ts +0 -10
- package/dist/node/document-model/gen/operation-error/creators.d.ts +0 -9
- package/dist/node/document-model/gen/operation-error/object.d.ts +0 -12
- package/dist/node/document-model/gen/operation-error/operations.d.ts +0 -11
- package/dist/node/document-model/gen/operation-example/actions.d.ts +0 -7
- package/dist/node/document-model/gen/operation-example/creators.d.ts +0 -6
- package/dist/node/document-model/gen/operation-example/object.d.ts +0 -9
- package/dist/node/document-model/gen/operation-example/operations.d.ts +0 -8
- package/dist/node/document-model/gen/reducer.d.ts +0 -3
- package/dist/node/document-model/gen/schema/index.d.ts +0 -2
- package/dist/node/document-model/gen/schema/types.d.ts +0 -453
- package/dist/node/document-model/gen/schema/zod.d.ts +0 -453
- package/dist/node/document-model/gen/state/actions.d.ts +0 -9
- package/dist/node/document-model/gen/state/creators.d.ts +0 -8
- package/dist/node/document-model/gen/state/object.d.ts +0 -11
- package/dist/node/document-model/gen/state/operations.d.ts +0 -10
- package/dist/node/document-model/gen/types.d.ts +0 -8
- package/dist/node/document-model/gen/utils.d.ts +0 -6
- package/dist/node/document-model/gen/versioning/actions.d.ts +0 -8
- package/dist/node/document-model/gen/versioning/creators.d.ts +0 -7
- package/dist/node/document-model/gen/versioning/object.d.ts +0 -10
- package/dist/node/document-model/gen/versioning/operations.d.ts +0 -9
- package/dist/node/document-model/index.d.ts +0 -74
- package/dist/node/document-model.cjs +0 -1
- package/dist/node/document-model.d.ts +0 -1
- package/dist/node/document-model.js +0 -20
- package/dist/node/document.cjs +0 -1
- package/dist/node/document.d.ts +0 -1
- package/dist/node/document.js +0 -18
- package/dist/node/index.cjs +0 -1
- package/dist/node/index.d.ts +0 -25
- package/dist/node/index.js +0 -21
- package/dist/node/internal/index-14279b3a.js +0 -1930
- package/dist/node/internal/index-4b25c8a5.js +0 -1
- package/dist/node/internal/index-bfc402ef.js +0 -22
- package/dist/node/internal/index-e02d7854.js +0 -34
- package/dist/node/internal/object-ac706c4a.js +0 -1
- package/dist/node/internal/object-b97efc1b.js +0 -781
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "document-model",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.21",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"private": false,
|
|
6
6
|
"files": [
|
|
@@ -52,25 +52,26 @@
|
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@rollup/plugin-node-resolve": "^15.2.1",
|
|
55
|
-
"@
|
|
56
|
-
"@types/
|
|
57
|
-
"@types/
|
|
58
|
-
"@
|
|
59
|
-
"@typescript-eslint/
|
|
60
|
-
"eslint": "^
|
|
61
|
-
"eslint
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"prettier
|
|
55
|
+
"@total-typescript/ts-reset": "^0.5.1",
|
|
56
|
+
"@types/jest": "^29.5.11",
|
|
57
|
+
"@types/mime": "^3.0.4",
|
|
58
|
+
"@types/react": "^18.2.47",
|
|
59
|
+
"@typescript-eslint/eslint-plugin": "^6.18.1",
|
|
60
|
+
"@typescript-eslint/parser": "^6.18.1",
|
|
61
|
+
"eslint": "^8.56.0",
|
|
62
|
+
"eslint-config-prettier": "^9.1.0",
|
|
63
|
+
"jest": "^29.7.0",
|
|
64
|
+
"prettier": "^3.1.1",
|
|
65
|
+
"prettier-plugin-organize-imports": "^3.2.4",
|
|
65
66
|
"react": "^18.2.0",
|
|
66
67
|
"rollup-plugin-polyfill-node": "^0.12.0",
|
|
67
68
|
"sha.js": "^2.4.11",
|
|
68
69
|
"ts-jest": "^29.1.1",
|
|
69
|
-
"ts-node": "^10.9.
|
|
70
|
+
"ts-node": "^10.9.2",
|
|
70
71
|
"typescript": "^5.3.3",
|
|
71
|
-
"vite": "^
|
|
72
|
-
"vite-plugin-dts": "^3.
|
|
73
|
-
"vite-plugin-node-polyfills": "^0.
|
|
72
|
+
"vite": "^5.0.11",
|
|
73
|
+
"vite-plugin-dts": "^3.7.0",
|
|
74
|
+
"vite-plugin-node-polyfills": "^0.19.0"
|
|
74
75
|
},
|
|
75
76
|
"dependencies": {
|
|
76
77
|
"immer": "^10.0.2",
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { ExtendedState, OperationScope } from '../types';
|
|
2
|
-
import { LoadStateAction, PruneAction, RedoAction, SetNameAction, UndoAction } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Changes the name of the document.
|
|
5
|
-
*
|
|
6
|
-
* @param name - The name to be set in the document.
|
|
7
|
-
* @category Actions
|
|
8
|
-
*/
|
|
9
|
-
export declare const setName: (name: string) => SetNameAction;
|
|
10
|
-
/**
|
|
11
|
-
* Cancels the last `count` operations.
|
|
12
|
-
*
|
|
13
|
-
* @param count - Number of operations to cancel
|
|
14
|
-
* @category Actions
|
|
15
|
-
*/
|
|
16
|
-
export declare const undo: (count?: number, scope?: OperationScope) => UndoAction;
|
|
17
|
-
/**
|
|
18
|
-
* Cancels the last `count` {@link undo | UNDO} operations.
|
|
19
|
-
*
|
|
20
|
-
* @param count - Number of UNDO operations to cancel
|
|
21
|
-
* @category Actions
|
|
22
|
-
*/
|
|
23
|
-
export declare const redo: (count?: number, scope?: OperationScope) => RedoAction;
|
|
24
|
-
/**
|
|
25
|
-
* Joins multiple operations into a single {@link loadState | LOAD_STATE} operation.
|
|
26
|
-
*
|
|
27
|
-
* @remarks
|
|
28
|
-
* Useful to keep operations history smaller. Operations to prune are selected by index,
|
|
29
|
-
* similar to the {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice | slice} method in Arrays.
|
|
30
|
-
*
|
|
31
|
-
* @param start - Index of the first operation to prune
|
|
32
|
-
* @param end - Index of the last operation to prune
|
|
33
|
-
* @category Actions
|
|
34
|
-
*/
|
|
35
|
-
export declare const prune: (start?: number | undefined, end?: number | undefined, scope?: OperationScope) => PruneAction;
|
|
36
|
-
/**
|
|
37
|
-
* Replaces the state of the document.
|
|
38
|
-
*
|
|
39
|
-
* @remarks
|
|
40
|
-
* This action shouldn't be used directly. It is dispatched by the {@link prune} action.
|
|
41
|
-
*
|
|
42
|
-
* @param state - State to be set in the document.
|
|
43
|
-
* @param operations - Number of operations that were removed from the previous state.
|
|
44
|
-
* @category Actions
|
|
45
|
-
*/
|
|
46
|
-
export declare const loadState: <S, T>(state: Pick<ExtendedState<S, T>, "name" | "state">, operations: number) => LoadStateAction;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Action, Document, ImmutableStateReducer, PruneAction, RedoAction, State, UndoAction } from '../types';
|
|
2
|
-
export declare function setNameOperation<T>(document: T, name: string): T;
|
|
3
|
-
export declare function undoOperation<T, A extends Action, L>(document: Document<T, A, L>, action: UndoAction, wrappedReducer: ImmutableStateReducer<T, A, L>): Document<T, A, L>;
|
|
4
|
-
export declare function redoOperation<T, A extends Action, L>(document: Document<T, A, L>, action: RedoAction, wrappedReducer: ImmutableStateReducer<T, A, L>): Document<T, A, L>;
|
|
5
|
-
export declare function pruneOperation<T, A extends Action, L>(document: Document<T, A, L>, action: PruneAction, wrappedReducer: ImmutableStateReducer<T, A, L>): Document<T, A, L>;
|
|
6
|
-
export declare function loadStateOperation<T, A extends Action, L>(oldDocument: Document<T, A, L>, newDocument: {
|
|
7
|
-
name: string;
|
|
8
|
-
state?: State<T, L>;
|
|
9
|
-
}): Document<T, A, L>;
|
|
10
|
-
export * from './creators';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { BaseAction } from '../types';
|
|
2
|
-
export declare const SET_NAME = "SET_NAME";
|
|
3
|
-
export declare const UNDO = "UNDO";
|
|
4
|
-
export declare const REDO = "REDO";
|
|
5
|
-
export declare const PRUNE = "PRUNE";
|
|
6
|
-
export declare const LOAD_STATE = "LOAD_STATE";
|
|
7
|
-
export { LoadStateAction, PruneAction, RedoAction, SetNameAction, UndoAction, } from '../types';
|
|
8
|
-
export type { BaseAction };
|
|
@@ -1,391 +0,0 @@
|
|
|
1
|
-
import type { BaseAction } from './actions/types';
|
|
2
|
-
import type { SignalDispatch } from './signal';
|
|
3
|
-
import type { Action, AttachmentRef, Document, ExtendedState, OperationScope, Reducer } from './types';
|
|
4
|
-
/**
|
|
5
|
-
* This is an abstract class representing a document and provides methods
|
|
6
|
-
* for creating and manipulating documents.
|
|
7
|
-
* @typeparam T - The type of data stored in the document.
|
|
8
|
-
* @typeparam A - The type of action the document can take.
|
|
9
|
-
*/
|
|
10
|
-
export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
11
|
-
protected _document: Document<T, A, L>;
|
|
12
|
-
private _reducer;
|
|
13
|
-
private _signalDispatch?;
|
|
14
|
-
/**
|
|
15
|
-
* Constructs a BaseDocument instance with an initial state.
|
|
16
|
-
* @param reducer - The reducer function that updates the state.
|
|
17
|
-
* @param document - The initial state of the document.
|
|
18
|
-
*/
|
|
19
|
-
constructor(reducer: Reducer<T, A, L>, document: Document<T, A, L>, signalDispatch?: SignalDispatch);
|
|
20
|
-
/**
|
|
21
|
-
* Dispatches an action to update the state of the document.
|
|
22
|
-
* @param action - The action to dispatch.
|
|
23
|
-
* @returns The Document instance.
|
|
24
|
-
*/
|
|
25
|
-
protected dispatch(action: A | BaseAction): this;
|
|
26
|
-
/**
|
|
27
|
-
* Saves the state of the document to a file.
|
|
28
|
-
* @param path - The file path where the state should be saved.
|
|
29
|
-
* @param extension - The file extension to use when saving the state.
|
|
30
|
-
* @returns The file path where the state was saved.
|
|
31
|
-
*/
|
|
32
|
-
protected saveToFile(path: string, extension: string, name?: string): Promise<string>;
|
|
33
|
-
/**
|
|
34
|
-
* Loads the state of the document from a file.
|
|
35
|
-
* @param path - The file path where the state is stored.
|
|
36
|
-
*/
|
|
37
|
-
loadFromFile(path: string): Promise<void>;
|
|
38
|
-
/**
|
|
39
|
-
* Loads the state of the document from a file and returns it.
|
|
40
|
-
* @param path - The file path where the state is stored.
|
|
41
|
-
* @param reducer - The reducer function that updates the state.
|
|
42
|
-
* @returns The state of the document.
|
|
43
|
-
*/
|
|
44
|
-
protected static stateFromFile<T, A extends Action, L>(path: string, reducer: Reducer<T, A, L>): Promise<Document<T, A, L>>;
|
|
45
|
-
/**
|
|
46
|
-
* Gets the current state of the document.
|
|
47
|
-
*/
|
|
48
|
-
get state(): {
|
|
49
|
-
readonly global: import("immer").Immutable<T>;
|
|
50
|
-
readonly local: import("immer").Immutable<L>;
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Gets the list of operations performed on the document.
|
|
54
|
-
*/
|
|
55
|
-
get operations(): {
|
|
56
|
-
readonly global: readonly ({
|
|
57
|
-
readonly input: {
|
|
58
|
-
readonly operations: number;
|
|
59
|
-
readonly state: {
|
|
60
|
-
readonly data?: unknown;
|
|
61
|
-
readonly name: string;
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
readonly type: "LOAD_STATE";
|
|
65
|
-
readonly scope: OperationScope;
|
|
66
|
-
readonly index: number;
|
|
67
|
-
readonly timestamp: string;
|
|
68
|
-
readonly hash: string;
|
|
69
|
-
} | {
|
|
70
|
-
readonly input: {
|
|
71
|
-
readonly end?: import("./types").InputMaybe<number>;
|
|
72
|
-
readonly start?: import("./types").InputMaybe<number>;
|
|
73
|
-
};
|
|
74
|
-
readonly type: "PRUNE";
|
|
75
|
-
readonly scope: OperationScope;
|
|
76
|
-
readonly index: number;
|
|
77
|
-
readonly timestamp: string;
|
|
78
|
-
readonly hash: string;
|
|
79
|
-
} | {
|
|
80
|
-
readonly input: number;
|
|
81
|
-
readonly type: "REDO";
|
|
82
|
-
readonly scope: OperationScope;
|
|
83
|
-
readonly index: number;
|
|
84
|
-
readonly timestamp: string;
|
|
85
|
-
readonly hash: string;
|
|
86
|
-
} | {
|
|
87
|
-
readonly input: string;
|
|
88
|
-
readonly type: "SET_NAME";
|
|
89
|
-
readonly scope: "global";
|
|
90
|
-
readonly index: number;
|
|
91
|
-
readonly timestamp: string;
|
|
92
|
-
readonly hash: string;
|
|
93
|
-
} | {
|
|
94
|
-
readonly input: number;
|
|
95
|
-
readonly type: "UNDO";
|
|
96
|
-
readonly scope: OperationScope;
|
|
97
|
-
readonly index: number;
|
|
98
|
-
readonly timestamp: string;
|
|
99
|
-
readonly hash: string;
|
|
100
|
-
} | import("immer").Immutable<A & {
|
|
101
|
-
index: number;
|
|
102
|
-
timestamp: string;
|
|
103
|
-
hash: string;
|
|
104
|
-
}>)[];
|
|
105
|
-
readonly local: readonly ({
|
|
106
|
-
readonly input: {
|
|
107
|
-
readonly operations: number;
|
|
108
|
-
readonly state: {
|
|
109
|
-
readonly data?: unknown;
|
|
110
|
-
readonly name: string;
|
|
111
|
-
};
|
|
112
|
-
};
|
|
113
|
-
readonly type: "LOAD_STATE";
|
|
114
|
-
readonly scope: OperationScope;
|
|
115
|
-
readonly index: number;
|
|
116
|
-
readonly timestamp: string;
|
|
117
|
-
readonly hash: string;
|
|
118
|
-
} | {
|
|
119
|
-
readonly input: {
|
|
120
|
-
readonly end?: import("./types").InputMaybe<number>;
|
|
121
|
-
readonly start?: import("./types").InputMaybe<number>;
|
|
122
|
-
};
|
|
123
|
-
readonly type: "PRUNE";
|
|
124
|
-
readonly scope: OperationScope;
|
|
125
|
-
readonly index: number;
|
|
126
|
-
readonly timestamp: string;
|
|
127
|
-
readonly hash: string;
|
|
128
|
-
} | {
|
|
129
|
-
readonly input: number;
|
|
130
|
-
readonly type: "REDO";
|
|
131
|
-
readonly scope: OperationScope;
|
|
132
|
-
readonly index: number;
|
|
133
|
-
readonly timestamp: string;
|
|
134
|
-
readonly hash: string;
|
|
135
|
-
} | {
|
|
136
|
-
readonly input: string;
|
|
137
|
-
readonly type: "SET_NAME";
|
|
138
|
-
readonly scope: "global";
|
|
139
|
-
readonly index: number;
|
|
140
|
-
readonly timestamp: string;
|
|
141
|
-
readonly hash: string;
|
|
142
|
-
} | {
|
|
143
|
-
readonly input: number;
|
|
144
|
-
readonly type: "UNDO";
|
|
145
|
-
readonly scope: OperationScope;
|
|
146
|
-
readonly index: number;
|
|
147
|
-
readonly timestamp: string;
|
|
148
|
-
readonly hash: string;
|
|
149
|
-
} | import("immer").Immutable<A & {
|
|
150
|
-
index: number;
|
|
151
|
-
timestamp: string;
|
|
152
|
-
hash: string;
|
|
153
|
-
}>)[];
|
|
154
|
-
};
|
|
155
|
-
/**
|
|
156
|
-
* Gets the name of the document.
|
|
157
|
-
*/
|
|
158
|
-
get name(): string;
|
|
159
|
-
/**
|
|
160
|
-
* Gets the type of document.
|
|
161
|
-
*/
|
|
162
|
-
get documentType(): string;
|
|
163
|
-
/**
|
|
164
|
-
* Gets the timestamp of the date the document was created.
|
|
165
|
-
*/
|
|
166
|
-
get created(): string;
|
|
167
|
-
/**
|
|
168
|
-
* Gets the timestamp of the date the document was last modified.
|
|
169
|
-
*/
|
|
170
|
-
get lastModified(): string;
|
|
171
|
-
/**
|
|
172
|
-
* Gets the global revision number of the document.
|
|
173
|
-
*/
|
|
174
|
-
get revision(): number;
|
|
175
|
-
getRevision(scope: OperationScope): number;
|
|
176
|
-
/**
|
|
177
|
-
* Gets the initial state of the document.
|
|
178
|
-
*/
|
|
179
|
-
get initialState(): {
|
|
180
|
-
readonly name: string;
|
|
181
|
-
readonly revision: {
|
|
182
|
-
readonly global: number;
|
|
183
|
-
readonly local: number;
|
|
184
|
-
};
|
|
185
|
-
readonly documentType: string;
|
|
186
|
-
readonly created: string;
|
|
187
|
-
readonly lastModified: string;
|
|
188
|
-
readonly state: {
|
|
189
|
-
readonly global: import("immer").Immutable<T>;
|
|
190
|
-
readonly local: import("immer").Immutable<L>;
|
|
191
|
-
};
|
|
192
|
-
readonly attachments: {
|
|
193
|
-
readonly [x: string]: {
|
|
194
|
-
readonly data: string;
|
|
195
|
-
readonly mimeType: string;
|
|
196
|
-
readonly extension?: string | null | undefined;
|
|
197
|
-
readonly fileName?: string | null | undefined;
|
|
198
|
-
};
|
|
199
|
-
};
|
|
200
|
-
};
|
|
201
|
-
/**
|
|
202
|
-
* Returns the current document as an object
|
|
203
|
-
*/
|
|
204
|
-
toDocument(): {
|
|
205
|
-
readonly name: string;
|
|
206
|
-
readonly revision: {
|
|
207
|
-
readonly global: number;
|
|
208
|
-
readonly local: number;
|
|
209
|
-
};
|
|
210
|
-
readonly documentType: string;
|
|
211
|
-
readonly created: string;
|
|
212
|
-
readonly lastModified: string;
|
|
213
|
-
readonly state: {
|
|
214
|
-
readonly global: import("immer").Immutable<T>;
|
|
215
|
-
readonly local: import("immer").Immutable<L>;
|
|
216
|
-
};
|
|
217
|
-
readonly attachments: {
|
|
218
|
-
readonly [x: string]: {
|
|
219
|
-
readonly data: string;
|
|
220
|
-
readonly mimeType: string;
|
|
221
|
-
readonly extension?: string | null | undefined;
|
|
222
|
-
readonly fileName?: string | null | undefined;
|
|
223
|
-
};
|
|
224
|
-
};
|
|
225
|
-
readonly operations: {
|
|
226
|
-
readonly global: readonly ({
|
|
227
|
-
readonly input: {
|
|
228
|
-
readonly operations: number;
|
|
229
|
-
readonly state: {
|
|
230
|
-
readonly data?: unknown;
|
|
231
|
-
readonly name: string;
|
|
232
|
-
};
|
|
233
|
-
};
|
|
234
|
-
readonly type: "LOAD_STATE";
|
|
235
|
-
readonly scope: OperationScope;
|
|
236
|
-
readonly index: number;
|
|
237
|
-
readonly timestamp: string;
|
|
238
|
-
readonly hash: string;
|
|
239
|
-
} | {
|
|
240
|
-
readonly input: {
|
|
241
|
-
readonly end?: import("./types").InputMaybe<number>;
|
|
242
|
-
readonly start?: import("./types").InputMaybe<number>;
|
|
243
|
-
};
|
|
244
|
-
readonly type: "PRUNE";
|
|
245
|
-
readonly scope: OperationScope;
|
|
246
|
-
readonly index: number;
|
|
247
|
-
readonly timestamp: string;
|
|
248
|
-
readonly hash: string;
|
|
249
|
-
} | {
|
|
250
|
-
readonly input: number;
|
|
251
|
-
readonly type: "REDO";
|
|
252
|
-
readonly scope: OperationScope;
|
|
253
|
-
readonly index: number;
|
|
254
|
-
readonly timestamp: string;
|
|
255
|
-
readonly hash: string;
|
|
256
|
-
} | {
|
|
257
|
-
readonly input: string;
|
|
258
|
-
readonly type: "SET_NAME";
|
|
259
|
-
readonly scope: "global";
|
|
260
|
-
readonly index: number;
|
|
261
|
-
readonly timestamp: string;
|
|
262
|
-
readonly hash: string;
|
|
263
|
-
} | {
|
|
264
|
-
readonly input: number;
|
|
265
|
-
readonly type: "UNDO";
|
|
266
|
-
readonly scope: OperationScope;
|
|
267
|
-
readonly index: number;
|
|
268
|
-
readonly timestamp: string;
|
|
269
|
-
readonly hash: string;
|
|
270
|
-
} | import("immer").Immutable<A & {
|
|
271
|
-
index: number;
|
|
272
|
-
timestamp: string;
|
|
273
|
-
hash: string;
|
|
274
|
-
}>)[];
|
|
275
|
-
readonly local: readonly ({
|
|
276
|
-
readonly input: {
|
|
277
|
-
readonly operations: number;
|
|
278
|
-
readonly state: {
|
|
279
|
-
readonly data?: unknown;
|
|
280
|
-
readonly name: string;
|
|
281
|
-
};
|
|
282
|
-
};
|
|
283
|
-
readonly type: "LOAD_STATE";
|
|
284
|
-
readonly scope: OperationScope;
|
|
285
|
-
readonly index: number;
|
|
286
|
-
readonly timestamp: string;
|
|
287
|
-
readonly hash: string;
|
|
288
|
-
} | {
|
|
289
|
-
readonly input: {
|
|
290
|
-
readonly end?: import("./types").InputMaybe<number>;
|
|
291
|
-
readonly start?: import("./types").InputMaybe<number>;
|
|
292
|
-
};
|
|
293
|
-
readonly type: "PRUNE";
|
|
294
|
-
readonly scope: OperationScope;
|
|
295
|
-
readonly index: number;
|
|
296
|
-
readonly timestamp: string;
|
|
297
|
-
readonly hash: string;
|
|
298
|
-
} | {
|
|
299
|
-
readonly input: number;
|
|
300
|
-
readonly type: "REDO";
|
|
301
|
-
readonly scope: OperationScope;
|
|
302
|
-
readonly index: number;
|
|
303
|
-
readonly timestamp: string;
|
|
304
|
-
readonly hash: string;
|
|
305
|
-
} | {
|
|
306
|
-
readonly input: string;
|
|
307
|
-
readonly type: "SET_NAME";
|
|
308
|
-
readonly scope: "global";
|
|
309
|
-
readonly index: number;
|
|
310
|
-
readonly timestamp: string;
|
|
311
|
-
readonly hash: string;
|
|
312
|
-
} | {
|
|
313
|
-
readonly input: number;
|
|
314
|
-
readonly type: "UNDO";
|
|
315
|
-
readonly scope: OperationScope;
|
|
316
|
-
readonly index: number;
|
|
317
|
-
readonly timestamp: string;
|
|
318
|
-
readonly hash: string;
|
|
319
|
-
} | import("immer").Immutable<A & {
|
|
320
|
-
index: number;
|
|
321
|
-
timestamp: string;
|
|
322
|
-
hash: string;
|
|
323
|
-
}>)[];
|
|
324
|
-
};
|
|
325
|
-
readonly initialState: {
|
|
326
|
-
readonly name: string;
|
|
327
|
-
readonly revision: {
|
|
328
|
-
readonly global: number;
|
|
329
|
-
readonly local: number;
|
|
330
|
-
};
|
|
331
|
-
readonly documentType: string;
|
|
332
|
-
readonly created: string;
|
|
333
|
-
readonly lastModified: string;
|
|
334
|
-
readonly state: {
|
|
335
|
-
readonly global: import("immer").Immutable<T>;
|
|
336
|
-
readonly local: import("immer").Immutable<L>;
|
|
337
|
-
};
|
|
338
|
-
readonly attachments: {
|
|
339
|
-
readonly [x: string]: {
|
|
340
|
-
readonly data: string;
|
|
341
|
-
readonly mimeType: string;
|
|
342
|
-
readonly extension?: string | null | undefined;
|
|
343
|
-
readonly fileName?: string | null | undefined;
|
|
344
|
-
};
|
|
345
|
-
};
|
|
346
|
-
};
|
|
347
|
-
};
|
|
348
|
-
/**
|
|
349
|
-
* Gets the attachment associated with the given key.
|
|
350
|
-
* @param attachment - The key of the attachment to retrieve.
|
|
351
|
-
*/
|
|
352
|
-
getAttachment(attachment: AttachmentRef): import("./types").Attachment;
|
|
353
|
-
/**
|
|
354
|
-
* Sets the name of the document.
|
|
355
|
-
* @param name - The new name of the document.
|
|
356
|
-
*/
|
|
357
|
-
setName(name: string): this;
|
|
358
|
-
/**
|
|
359
|
-
* Reverts a number of actions from the document.
|
|
360
|
-
* @param count - The number of actions to revert.
|
|
361
|
-
*/
|
|
362
|
-
undo(count: number): this;
|
|
363
|
-
/**
|
|
364
|
-
* Reapplies a number of actions to the document.
|
|
365
|
-
* @param count - The number of actions to reapply.
|
|
366
|
-
*/
|
|
367
|
-
redo(count: number): this;
|
|
368
|
-
/**
|
|
369
|
-
* Removes a range of operations from the document.
|
|
370
|
-
* @param start - The starting index of the range to remove.
|
|
371
|
-
* @param end - The ending index of the range to remove.
|
|
372
|
-
*/
|
|
373
|
-
prune(start?: number | undefined, end?: number | undefined): this;
|
|
374
|
-
/**
|
|
375
|
-
* Loads a document state and a set of operations.
|
|
376
|
-
* @param state - The state to load.
|
|
377
|
-
* @param operations - The operations to apply to the document.
|
|
378
|
-
*/
|
|
379
|
-
loadState(state: Pick<ExtendedState<T, L>, 'state' | 'name'>, operations: number): this;
|
|
380
|
-
}
|
|
381
|
-
/**
|
|
382
|
-
* Applies multiple mixins to a base class.
|
|
383
|
-
* Used to have separate mixins to group methods by actions.
|
|
384
|
-
*
|
|
385
|
-
* @remarks
|
|
386
|
-
* {@link https://www.typescriptlang.org/docs/handbook/mixins.html#alternative-pattern}
|
|
387
|
-
*
|
|
388
|
-
* @param derivedCtor - The class to apply the mixins to.
|
|
389
|
-
* @param constructors - The constructors of the mixins.
|
|
390
|
-
*/
|
|
391
|
-
export declare function applyMixins(derivedCtor: any, constructors: any[]): void;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { BaseAction } from './actions/types';
|
|
2
|
-
import { Action, Document, ImmutableStateReducer } from './types';
|
|
3
|
-
import { SignalDispatch } from './signal';
|
|
4
|
-
/**
|
|
5
|
-
* Base document reducer that wraps a custom document reducer and handles
|
|
6
|
-
* document-level actions such as undo, redo, prune, and set name.
|
|
7
|
-
*
|
|
8
|
-
* @template T - The type of the state of the custom reducer.
|
|
9
|
-
* @template A - The type of the actions of the custom reducer.
|
|
10
|
-
* @param state - The current state of the document.
|
|
11
|
-
* @param action - The action object to apply to the state.
|
|
12
|
-
* @param customReducer - The custom reducer that implements the application logic
|
|
13
|
-
* specific to the document's state.
|
|
14
|
-
* @returns The new state of the document.
|
|
15
|
-
*/
|
|
16
|
-
export declare function baseReducer<T, A extends Action, L>(document: Document<T, A, L>, action: A | BaseAction, customReducer: ImmutableStateReducer<T, A, L>, dispatch?: SignalDispatch): Document<T, A, L>;
|