document-model 1.0.21 → 1.0.22

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 (183) hide show
  1. package/dist/browser/document-model.cjs +1 -0
  2. package/dist/browser/document-model.d.ts +1 -0
  3. package/dist/browser/document-model.js +16 -0
  4. package/dist/browser/document.cjs +1 -0
  5. package/dist/browser/document.d.ts +1 -0
  6. package/dist/browser/document.js +14 -0
  7. package/dist/browser/index.cjs +1 -0
  8. package/dist/browser/index.d.ts +3 -0
  9. package/dist/browser/index.js +17 -0
  10. package/dist/browser/internal/index-BGvdUwMj.js +1 -0
  11. package/dist/browser/internal/index-ZaSXpgfR.js +22 -0
  12. package/dist/browser/internal/index-k0_xGFJa.js +1926 -0
  13. package/dist/browser/internal/index-vHDbgY8i.js +34 -0
  14. package/dist/browser/internal/object-fIfH8K9b.js +6 -0
  15. package/dist/browser/internal/object-wtPuW7QY.js +1781 -0
  16. package/dist/browser/jest.config.d.ts +8 -0
  17. package/dist/browser/src/document/actions/creators.d.ts +46 -0
  18. package/dist/browser/src/document/actions/index.d.ts +10 -0
  19. package/dist/browser/src/document/actions/types.d.ts +8 -0
  20. package/dist/browser/src/document/index.d.ts +6 -0
  21. package/dist/browser/src/document/object.d.ts +391 -0
  22. package/dist/browser/src/document/reducer.d.ts +16 -0
  23. package/dist/browser/src/document/schema/index.d.ts +2 -0
  24. package/dist/browser/src/document/schema/types.d.ts +174 -0
  25. package/dist/browser/src/document/schema/zod.d.ts +113 -0
  26. package/dist/browser/src/document/signal.d.ts +22 -0
  27. package/dist/browser/src/document/types.d.ts +190 -0
  28. package/dist/browser/src/document/utils/base.d.ts +61 -0
  29. package/dist/browser/src/document/utils/file.d.ts +47 -0
  30. package/dist/browser/src/document/utils/index.d.ts +2 -0
  31. package/dist/browser/src/document/utils/node.d.ts +9 -0
  32. package/dist/browser/src/document-model/custom/reducers/header.d.ts +2 -0
  33. package/dist/browser/src/document-model/custom/reducers/module.d.ts +2 -0
  34. package/dist/browser/src/document-model/custom/reducers/operation-error.d.ts +2 -0
  35. package/dist/browser/src/document-model/custom/reducers/operation-example.d.ts +2 -0
  36. package/dist/browser/src/document-model/custom/reducers/operation.d.ts +2 -0
  37. package/dist/browser/src/document-model/custom/reducers/state.d.ts +2 -0
  38. package/dist/browser/src/document-model/custom/reducers/versioning.d.ts +7 -0
  39. package/dist/browser/src/document-model/custom/utils.d.ts +1 -0
  40. package/dist/browser/src/document-model/gen/actions.d.ts +15 -0
  41. package/dist/browser/src/document-model/gen/creators.d.ts +7 -0
  42. package/dist/browser/src/document-model/gen/document-model.d.ts +2 -0
  43. package/dist/browser/src/document-model/gen/header/actions.d.ts +9 -0
  44. package/dist/browser/src/document-model/gen/header/creators.d.ts +8 -0
  45. package/dist/browser/src/document-model/gen/header/object.d.ts +11 -0
  46. package/dist/browser/src/document-model/gen/header/operations.d.ts +10 -0
  47. package/dist/browser/src/document-model/gen/index.d.ts +5 -0
  48. package/dist/browser/src/document-model/gen/module/actions.d.ts +8 -0
  49. package/dist/browser/src/document-model/gen/module/creators.d.ts +7 -0
  50. package/dist/browser/src/document-model/gen/module/object.d.ts +10 -0
  51. package/dist/browser/src/document-model/gen/module/operations.d.ts +9 -0
  52. package/dist/browser/src/document-model/gen/object.d.ts +28 -0
  53. package/dist/browser/src/document-model/gen/operation/actions.d.ts +13 -0
  54. package/dist/browser/src/document-model/gen/operation/creators.d.ts +12 -0
  55. package/dist/browser/src/document-model/gen/operation/object.d.ts +15 -0
  56. package/dist/browser/src/document-model/gen/operation/operations.d.ts +14 -0
  57. package/dist/browser/src/document-model/gen/operation-error/actions.d.ts +10 -0
  58. package/dist/browser/src/document-model/gen/operation-error/creators.d.ts +9 -0
  59. package/dist/browser/src/document-model/gen/operation-error/object.d.ts +12 -0
  60. package/dist/browser/src/document-model/gen/operation-error/operations.d.ts +11 -0
  61. package/dist/browser/src/document-model/gen/operation-example/actions.d.ts +7 -0
  62. package/dist/browser/src/document-model/gen/operation-example/creators.d.ts +6 -0
  63. package/dist/browser/src/document-model/gen/operation-example/object.d.ts +9 -0
  64. package/dist/browser/src/document-model/gen/operation-example/operations.d.ts +8 -0
  65. package/dist/browser/src/document-model/gen/reducer.d.ts +3 -0
  66. package/dist/browser/src/document-model/gen/schema/index.d.ts +2 -0
  67. package/dist/browser/src/document-model/gen/schema/types.d.ts +453 -0
  68. package/dist/browser/src/document-model/gen/schema/zod.d.ts +453 -0
  69. package/dist/browser/src/document-model/gen/state/actions.d.ts +9 -0
  70. package/dist/browser/src/document-model/gen/state/creators.d.ts +8 -0
  71. package/dist/browser/src/document-model/gen/state/object.d.ts +11 -0
  72. package/dist/browser/src/document-model/gen/state/operations.d.ts +10 -0
  73. package/dist/browser/src/document-model/gen/types.d.ts +8 -0
  74. package/dist/browser/src/document-model/gen/utils.d.ts +6 -0
  75. package/dist/browser/src/document-model/gen/versioning/actions.d.ts +8 -0
  76. package/dist/browser/src/document-model/gen/versioning/creators.d.ts +7 -0
  77. package/dist/browser/src/document-model/gen/versioning/object.d.ts +10 -0
  78. package/dist/browser/src/document-model/gen/versioning/operations.d.ts +9 -0
  79. package/dist/browser/src/document-model/index.d.ts +74 -0
  80. package/dist/browser/src/index.d.ts +25 -0
  81. package/dist/browser/test/document/local.test.d.ts +1 -0
  82. package/dist/browser/test/document/object.test.d.ts +1 -0
  83. package/dist/browser/test/document/prune.test.d.ts +1 -0
  84. package/dist/browser/test/document/redo.test.d.ts +1 -0
  85. package/dist/browser/test/document/reducer.test.d.ts +1 -0
  86. package/dist/browser/test/document/undo.test.d.ts +1 -0
  87. package/dist/browser/test/document/utils.test.d.ts +1 -0
  88. package/dist/browser/test/document-model/object.test.d.ts +1 -0
  89. package/dist/browser/test/document-model/zip.test.d.ts +1 -0
  90. package/dist/browser/test/helpers.d.ts +29 -0
  91. package/dist/browser/vite.config.d.ts +2 -0
  92. package/dist/node/document-model.cjs +1 -0
  93. package/dist/node/document-model.d.ts +1 -0
  94. package/dist/node/document-model.js +20 -0
  95. package/dist/node/document.cjs +1 -0
  96. package/dist/node/document.d.ts +1 -0
  97. package/dist/node/document.js +18 -0
  98. package/dist/node/index.cjs +1 -0
  99. package/dist/node/index.d.ts +3 -0
  100. package/dist/node/index.js +21 -0
  101. package/dist/node/internal/index-3_D7m254.js +34 -0
  102. package/dist/node/internal/index-ffEJwj4v.js +22 -0
  103. package/dist/node/internal/index-frYzO4l6.js +1 -0
  104. package/dist/node/internal/index-vqhz-N10.js +1930 -0
  105. package/dist/node/internal/object-Vf10stKL.js +1 -0
  106. package/dist/node/internal/object-yzJ3jRpE.js +783 -0
  107. package/dist/node/jest.config.d.ts +8 -0
  108. package/dist/node/src/document/actions/creators.d.ts +46 -0
  109. package/dist/node/src/document/actions/index.d.ts +10 -0
  110. package/dist/node/src/document/actions/types.d.ts +8 -0
  111. package/dist/node/src/document/index.d.ts +6 -0
  112. package/dist/node/src/document/object.d.ts +391 -0
  113. package/dist/node/src/document/reducer.d.ts +16 -0
  114. package/dist/node/src/document/schema/index.d.ts +2 -0
  115. package/dist/node/src/document/schema/types.d.ts +174 -0
  116. package/dist/node/src/document/schema/zod.d.ts +113 -0
  117. package/dist/node/src/document/signal.d.ts +22 -0
  118. package/dist/node/src/document/types.d.ts +190 -0
  119. package/dist/node/src/document/utils/base.d.ts +61 -0
  120. package/dist/node/src/document/utils/file.d.ts +47 -0
  121. package/dist/node/src/document/utils/index.d.ts +2 -0
  122. package/dist/node/src/document/utils/node.d.ts +9 -0
  123. package/dist/node/src/document-model/custom/reducers/header.d.ts +2 -0
  124. package/dist/node/src/document-model/custom/reducers/module.d.ts +2 -0
  125. package/dist/node/src/document-model/custom/reducers/operation-error.d.ts +2 -0
  126. package/dist/node/src/document-model/custom/reducers/operation-example.d.ts +2 -0
  127. package/dist/node/src/document-model/custom/reducers/operation.d.ts +2 -0
  128. package/dist/node/src/document-model/custom/reducers/state.d.ts +2 -0
  129. package/dist/node/src/document-model/custom/reducers/versioning.d.ts +7 -0
  130. package/dist/node/src/document-model/custom/utils.d.ts +1 -0
  131. package/dist/node/src/document-model/gen/actions.d.ts +15 -0
  132. package/dist/node/src/document-model/gen/creators.d.ts +7 -0
  133. package/dist/node/src/document-model/gen/document-model.d.ts +2 -0
  134. package/dist/node/src/document-model/gen/header/actions.d.ts +9 -0
  135. package/dist/node/src/document-model/gen/header/creators.d.ts +8 -0
  136. package/dist/node/src/document-model/gen/header/object.d.ts +11 -0
  137. package/dist/node/src/document-model/gen/header/operations.d.ts +10 -0
  138. package/dist/node/src/document-model/gen/index.d.ts +5 -0
  139. package/dist/node/src/document-model/gen/module/actions.d.ts +8 -0
  140. package/dist/node/src/document-model/gen/module/creators.d.ts +7 -0
  141. package/dist/node/src/document-model/gen/module/object.d.ts +10 -0
  142. package/dist/node/src/document-model/gen/module/operations.d.ts +9 -0
  143. package/dist/node/src/document-model/gen/object.d.ts +28 -0
  144. package/dist/node/src/document-model/gen/operation/actions.d.ts +13 -0
  145. package/dist/node/src/document-model/gen/operation/creators.d.ts +12 -0
  146. package/dist/node/src/document-model/gen/operation/object.d.ts +15 -0
  147. package/dist/node/src/document-model/gen/operation/operations.d.ts +14 -0
  148. package/dist/node/src/document-model/gen/operation-error/actions.d.ts +10 -0
  149. package/dist/node/src/document-model/gen/operation-error/creators.d.ts +9 -0
  150. package/dist/node/src/document-model/gen/operation-error/object.d.ts +12 -0
  151. package/dist/node/src/document-model/gen/operation-error/operations.d.ts +11 -0
  152. package/dist/node/src/document-model/gen/operation-example/actions.d.ts +7 -0
  153. package/dist/node/src/document-model/gen/operation-example/creators.d.ts +6 -0
  154. package/dist/node/src/document-model/gen/operation-example/object.d.ts +9 -0
  155. package/dist/node/src/document-model/gen/operation-example/operations.d.ts +8 -0
  156. package/dist/node/src/document-model/gen/reducer.d.ts +3 -0
  157. package/dist/node/src/document-model/gen/schema/index.d.ts +2 -0
  158. package/dist/node/src/document-model/gen/schema/types.d.ts +453 -0
  159. package/dist/node/src/document-model/gen/schema/zod.d.ts +453 -0
  160. package/dist/node/src/document-model/gen/state/actions.d.ts +9 -0
  161. package/dist/node/src/document-model/gen/state/creators.d.ts +8 -0
  162. package/dist/node/src/document-model/gen/state/object.d.ts +11 -0
  163. package/dist/node/src/document-model/gen/state/operations.d.ts +10 -0
  164. package/dist/node/src/document-model/gen/types.d.ts +8 -0
  165. package/dist/node/src/document-model/gen/utils.d.ts +6 -0
  166. package/dist/node/src/document-model/gen/versioning/actions.d.ts +8 -0
  167. package/dist/node/src/document-model/gen/versioning/creators.d.ts +7 -0
  168. package/dist/node/src/document-model/gen/versioning/object.d.ts +10 -0
  169. package/dist/node/src/document-model/gen/versioning/operations.d.ts +9 -0
  170. package/dist/node/src/document-model/index.d.ts +74 -0
  171. package/dist/node/src/index.d.ts +25 -0
  172. package/dist/node/test/document/local.test.d.ts +1 -0
  173. package/dist/node/test/document/object.test.d.ts +1 -0
  174. package/dist/node/test/document/prune.test.d.ts +1 -0
  175. package/dist/node/test/document/redo.test.d.ts +1 -0
  176. package/dist/node/test/document/reducer.test.d.ts +1 -0
  177. package/dist/node/test/document/undo.test.d.ts +1 -0
  178. package/dist/node/test/document/utils.test.d.ts +1 -0
  179. package/dist/node/test/document-model/object.test.d.ts +1 -0
  180. package/dist/node/test/document-model/zip.test.d.ts +1 -0
  181. package/dist/node/test/helpers.d.ts +29 -0
  182. package/dist/node/vite.config.d.ts +2 -0
  183. package/package.json +1 -1
@@ -0,0 +1,113 @@
1
+ import { z } from 'zod';
2
+ import { Action, DocumentFile, LoadStateAction, LoadStateActionInput, LoadStateActionStateInput, Operation, PruneAction, PruneActionInput, RedoAction, SetNameAction, SetNameOperation, UndoAction } from '.';
3
+ import { OperationScope } from '../types';
4
+ type Properties<T> = Required<{
5
+ [K in keyof T]: z.ZodType<T[K], any, T[K]>;
6
+ }>;
7
+ type definedNonNullAny = {};
8
+ export declare const isDefinedNonNullAny: (v: any) => v is definedNonNullAny;
9
+ export declare const definedNonNullAnySchema: z.ZodEffects<z.ZodAny, any, any>;
10
+ export declare const Load_StateSchema: z.ZodEnum<["LOAD_STATE"]>;
11
+ export declare const PruneSchema: z.ZodEnum<["PRUNE"]>;
12
+ export declare const RedoSchema: z.ZodEnum<["REDO"]>;
13
+ export declare const Set_NameSchema: z.ZodEnum<["SET_NAME"]>;
14
+ export declare const UndoSchema: z.ZodEnum<["UNDO"]>;
15
+ export declare function ActionSchema(): z.ZodObject<Properties<Action>>;
16
+ export declare function OperationScopeSchema(): z.ZodType<OperationScope>;
17
+ export declare function BaseActionSchema(): z.ZodUnion<[z.ZodObject<Required<{
18
+ input: z.ZodType<LoadStateActionInput, any, LoadStateActionInput>;
19
+ type: z.ZodType<"LOAD_STATE", any, "LOAD_STATE">;
20
+ scope: z.ZodType<OperationScope, any, OperationScope>;
21
+ }>, z.UnknownKeysParam, z.ZodTypeAny, {
22
+ input: LoadStateActionInput;
23
+ type: "LOAD_STATE";
24
+ scope: "global" | "local";
25
+ }, {
26
+ input: LoadStateActionInput;
27
+ type: "LOAD_STATE";
28
+ scope: "global" | "local";
29
+ }>, z.ZodObject<Required<{
30
+ input: z.ZodType<PruneActionInput, any, PruneActionInput>;
31
+ type: z.ZodType<"PRUNE", any, "PRUNE">;
32
+ scope: z.ZodType<OperationScope, any, OperationScope>;
33
+ }>, z.UnknownKeysParam, z.ZodTypeAny, {
34
+ input: PruneActionInput;
35
+ type: "PRUNE";
36
+ scope: "global" | "local";
37
+ }, {
38
+ input: PruneActionInput;
39
+ type: "PRUNE";
40
+ scope: "global" | "local";
41
+ }>, z.ZodObject<Required<{
42
+ input: z.ZodType<number, any, number>;
43
+ type: z.ZodType<"REDO", any, "REDO">;
44
+ scope: z.ZodType<OperationScope, any, OperationScope>;
45
+ }>, z.UnknownKeysParam, z.ZodTypeAny, {
46
+ input: number;
47
+ type: "REDO";
48
+ scope: "global" | "local";
49
+ }, {
50
+ input: number;
51
+ type: "REDO";
52
+ scope: "global" | "local";
53
+ }>, z.ZodObject<Required<{
54
+ input: z.ZodType<string, any, string>;
55
+ type: z.ZodType<"SET_NAME", any, "SET_NAME">;
56
+ scope: z.ZodType<"global", any, "global">;
57
+ }>, z.UnknownKeysParam, z.ZodTypeAny, {
58
+ input: string;
59
+ type: "SET_NAME";
60
+ scope: "global";
61
+ }, {
62
+ input: string;
63
+ type: "SET_NAME";
64
+ scope: "global";
65
+ }>, z.ZodObject<Required<{
66
+ input: z.ZodType<number, any, number>;
67
+ type: z.ZodType<"UNDO", any, "UNDO">;
68
+ scope: z.ZodType<OperationScope, any, OperationScope>;
69
+ }>, z.UnknownKeysParam, z.ZodTypeAny, {
70
+ input: number;
71
+ type: "UNDO";
72
+ scope: "global" | "local";
73
+ }, {
74
+ input: number;
75
+ type: "UNDO";
76
+ scope: "global" | "local";
77
+ }>]>;
78
+ export declare function DocumentFileSchema(): z.ZodObject<Properties<DocumentFile>>;
79
+ export declare function LoadStateActionSchema(): z.ZodObject<Properties<LoadStateAction>>;
80
+ export declare function LoadStateActionInputSchema(): z.ZodObject<Properties<LoadStateActionInput>>;
81
+ export declare function LoadStateActionStateInputSchema(): z.ZodObject<Properties<LoadStateActionStateInput>>;
82
+ export declare function OperationSchema(): z.ZodObject<Properties<Operation>>;
83
+ export declare function PruneActionSchema(): z.ZodObject<Properties<PruneAction>>;
84
+ export declare function PruneActionInputSchema(): z.ZodObject<Properties<PruneActionInput>>;
85
+ export declare const RedoActionInputSchema: (params?: ({
86
+ errorMap?: z.ZodErrorMap | undefined;
87
+ invalid_type_error?: string | undefined;
88
+ required_error?: string | undefined;
89
+ description?: string | undefined;
90
+ } & {
91
+ coerce?: boolean | undefined;
92
+ }) | undefined) => z.ZodNumber;
93
+ export declare function RedoActionSchema(): z.ZodObject<Properties<RedoAction>>;
94
+ export declare const SetNameActionInputSchema: (params?: ({
95
+ errorMap?: z.ZodErrorMap | undefined;
96
+ invalid_type_error?: string | undefined;
97
+ required_error?: string | undefined;
98
+ description?: string | undefined;
99
+ } & {
100
+ coerce?: true | undefined;
101
+ }) | undefined) => z.ZodString;
102
+ export declare function SetNameActionSchema(): z.ZodObject<Properties<SetNameAction>>;
103
+ export declare function SetNameOperationSchema(): z.ZodObject<Properties<SetNameOperation>>;
104
+ export declare const UndoActionInputSchema: (params?: ({
105
+ errorMap?: z.ZodErrorMap | undefined;
106
+ invalid_type_error?: string | undefined;
107
+ required_error?: string | undefined;
108
+ description?: string | undefined;
109
+ } & {
110
+ coerce?: boolean | undefined;
111
+ }) | undefined) => z.ZodNumber;
112
+ export declare function UndoActionSchema(): z.ZodObject<Properties<UndoAction>>;
113
+ export {};
@@ -0,0 +1,22 @@
1
+ import { Document } from './types';
2
+ export interface ISignal<T extends string = string, I = unknown> {
3
+ type: T;
4
+ input: I;
5
+ }
6
+ export type CreateChildDocumentInput = {
7
+ id: string;
8
+ documentType: string;
9
+ document?: Document;
10
+ };
11
+ export type CreateChildDocumentSignal = ISignal<'CREATE_CHILD_DOCUMENT', CreateChildDocumentInput>;
12
+ export type DeleteChildDocumentInput = {
13
+ id: string;
14
+ };
15
+ export type DeleteChildDocumentSignal = ISignal<'DELETE_CHILD_DOCUMENT', DeleteChildDocumentInput>;
16
+ export type CopyChildDocumentInput = {
17
+ id: string;
18
+ newId: string;
19
+ };
20
+ export type CopyChildDocumentSignal = ISignal<'COPY_CHILD_DOCUMENT', CopyChildDocumentInput>;
21
+ export type Signal = CreateChildDocumentSignal | DeleteChildDocumentSignal | CopyChildDocumentSignal;
22
+ export type SignalDispatch = (signal: Signal) => void;
@@ -0,0 +1,190 @@
1
+ import type { Draft } from 'immer';
2
+ import type { FC } from 'react';
3
+ import type { DocumentModelState } from '../document-model/';
4
+ import type { BaseAction } from './actions/types';
5
+ import { BaseDocument } from './object';
6
+ import { FileInput } from './utils';
7
+ import { SignalDispatch } from './signal';
8
+ export { z } from './schema';
9
+ export type * from './schema/types';
10
+ export type { FileInput } from './utils';
11
+ export type { Immutable } from 'immer';
12
+ /**
13
+ * Defines the basic structure of an action.
14
+ *
15
+ * @typeParam T - The name of the action type. A `string` type by default.
16
+ */
17
+ export type Action<T extends string = string, I = unknown, S extends OperationScope = OperationScope> = {
18
+ /** The name of the action. */
19
+ type: T;
20
+ /** The payload of the action. */
21
+ input: I;
22
+ /** The scope of the action, can either be 'global' or 'local' */
23
+ scope: S;
24
+ /** The attachments included in the action. */
25
+ attachments?: AttachmentInput[] | undefined;
26
+ };
27
+ export type ActionWithAttachment<T extends string = string, I = unknown, S extends OperationScope = OperationScope> = Action<T, I, S> & {
28
+ attachments: AttachmentInput[];
29
+ };
30
+ /**
31
+ * A pure function that takes an action and the previous state
32
+ * of the document and returns the new state.
33
+ *
34
+ * @typeParam State - The type of the document data.
35
+ * @typeParam A - The type of the actions supported by the reducer.
36
+ */
37
+ export type Reducer<State, A extends Action, LocalState> = (state: Document<State, A, LocalState>, action: A | BaseAction, dispatch?: SignalDispatch) => Document<State, A, LocalState>;
38
+ /**
39
+ * A {@link Reducer} that prevents mutable code from changing the previous state.
40
+ *
41
+ * @remarks
42
+ * This reducer is wrapped with {@link https://immerjs.github.io/immer/ | Immer}.
43
+ * This allows the reducer code to be mutable, making it simpler and
44
+ * avoiding unintended changes in the provided state.
45
+ * The returned state will always be a new object.
46
+ *
47
+ * @typeParam State - The type of the document data.
48
+ * @typeParam A - The type of the actions supported by the reducer.
49
+ */
50
+ export type ImmutableReducer<State, A extends Action, LocalState> = (state: Draft<Document<State, A, LocalState>>, action: A | BaseAction, dispatch?: SignalDispatch) => Document<State, A, LocalState> | undefined;
51
+ export type ImmutableStateReducer<S, A extends Action, L = unknown> = (state: Draft<State<S, L>>, action: A, dispatch?: SignalDispatch) => State<S, L> | undefined;
52
+ /**
53
+ * Scope of an operation.
54
+ * Global: The operation is synchronized everywhere in the network. This is the default document operation.
55
+ * Local: The operation is applied only locally (to a local state). Used for local settings such as a drive's local path
56
+ */
57
+ export type OperationScope = 'global' | 'local';
58
+ /**
59
+ * An operation that was applied to a {@link Document}.
60
+ *
61
+ * @remarks
62
+ * Wraps an action with an index, to be added to the operations history of a Document.
63
+ * The `index` field is used to keep all operations in order and enable replaying the
64
+ * document's history from the beginning.
65
+ *
66
+ * @typeParam A - The type of the action.
67
+ */
68
+ export type Operation<A extends Action = Action> = A & {
69
+ /** Position of the operation in the history */
70
+ index: number;
71
+ /** Timestamp of when the operation was added */
72
+ timestamp: string;
73
+ /** Hash of the resulting document data after the operation */
74
+ hash: string;
75
+ };
76
+ /**
77
+ * The base attributes of a {@link Document}.
78
+ */
79
+ export type DocumentHeader = {
80
+ /** The name of the document. */
81
+ name: string;
82
+ /** The number of operations applied to the document. */
83
+ revision: Required<Record<OperationScope, number>>;
84
+ /** The type of the document model. */
85
+ documentType: string;
86
+ /** The timestamp of the creation date of the document. */
87
+ created: string;
88
+ /** The timestamp of the last change in the document. */
89
+ lastModified: string;
90
+ };
91
+ /**
92
+ * The attributes stored for a file. Namely, attachments of a document.
93
+ */
94
+ export type Attachment = {
95
+ /** The binary data of the attachment in Base64 */
96
+ data: string;
97
+ /** The MIME type of the attachment */
98
+ mimeType: string;
99
+ extension?: string | null;
100
+ fileName?: string | null;
101
+ };
102
+ export type AttachmentInput = Attachment & {
103
+ hash: string;
104
+ };
105
+ /**
106
+ * Object that indexes attachments of a Document.
107
+ *
108
+ * @remarks
109
+ * This is used to reduce memory usage to avoid
110
+ * multiple instances of the binary data of the attachments.
111
+ *
112
+ */
113
+ export type FileRegistry = Record<AttachmentRef, Attachment>;
114
+ export type State<GlobalState, LocalState> = {
115
+ global: GlobalState;
116
+ local: LocalState;
117
+ };
118
+ export type PartialState<S> = S | Partial<S>;
119
+ export type CreateState<S, L> = (state?: Partial<State<PartialState<S>, PartialState<L>>>) => State<S, L>;
120
+ export type ExtendedState<GlobalState, LocalState = unknown> = DocumentHeader & {
121
+ /** The document model specific state. */
122
+ state: State<GlobalState, LocalState>;
123
+ /** The index of document attachments. */
124
+ attachments: FileRegistry;
125
+ };
126
+ export type DocumentOperations<A extends Action> = Required<Record<OperationScope, Operation<A | BaseAction>[]>>;
127
+ /**
128
+ * The base type of a document model.
129
+ *
130
+ * @remarks
131
+ * This type is extended by all Document models.
132
+ *
133
+ * @typeParam Data - The type of the document data attribute.
134
+ * @typeParam A - The type of the actions supported by the Document.
135
+ */
136
+ export type Document<GlobalState = unknown, A extends Action = Action, LocalState = unknown> =
137
+ /** The document model specific state. */
138
+ ExtendedState<GlobalState, LocalState> & {
139
+ /** The operations history of the document. */
140
+ operations: DocumentOperations<A>;
141
+ /** The initial state of the document, enabling replaying operations. */
142
+ initialState: ExtendedState<GlobalState, LocalState>;
143
+ };
144
+ /**
145
+ * String type representing an attachment in a Document.
146
+ *
147
+ * @remarks
148
+ * Attachment string is formatted as `attachment://<filename>`.
149
+ */
150
+ export type AttachmentRef = string;
151
+ export interface DocumentClass<S, A extends Action = Action, L = unknown, C extends BaseDocument<S, A, L> = BaseDocument<S, A, L>> {
152
+ fileExtension: string;
153
+ fromFile: (path: string) => Promise<C>;
154
+ new (initialState?: ExtendedState<S, L>): C;
155
+ }
156
+ export type DocumentModelUtils<S = unknown, A extends Action = Action, L = unknown> = {
157
+ fileExtension: string;
158
+ createState: CreateState<S, L>;
159
+ createExtendedState: (extendedState?: Partial<ExtendedState<PartialState<S>, PartialState<L>>>, createState?: CreateState<S, L>) => ExtendedState<S, L>;
160
+ createDocument: (document?: Partial<ExtendedState<PartialState<S>, PartialState<L>>>, createState?: CreateState<S, L>) => Document<S, A, L>;
161
+ loadFromFile: (path: string) => Promise<Document<S, A, L>>;
162
+ loadFromInput: (input: FileInput) => Promise<Document<S, A, L>>;
163
+ saveToFile: (document: Document<S, A, L>, path: string, name?: string) => Promise<string>;
164
+ saveToFileHandle: (document: Document<S, A, L>, input: FileSystemFileHandle) => Promise<void>;
165
+ };
166
+ export type ActionCreator<A extends Action> = ((input: any) => A) | ((input: any, attachments: AttachmentInput[]) => A) | ((...input: any) => BaseAction);
167
+ export type DocumentModel<S = unknown, A extends Action = Action, L = unknown, C extends BaseDocument<S, A, L> = BaseDocument<S, A, L>> = {
168
+ Document: DocumentClass<S, A, L, C>;
169
+ reducer: Reducer<S, A, L>;
170
+ actions: Record<string, ActionCreator<A>>;
171
+ utils: DocumentModelUtils<S, A, L>;
172
+ documentModel: DocumentModelState;
173
+ };
174
+ export type EditorContext = {
175
+ theme: 'light' | 'dark';
176
+ debug?: boolean;
177
+ };
178
+ export type EditorProps<S, A extends Action, L> = {
179
+ document: Document<S, A, L>;
180
+ dispatch: (action: A | BaseAction) => void;
181
+ editorContext: EditorContext;
182
+ };
183
+ export type Editor<S = unknown, A extends Action = Action, L = unknown> = {
184
+ Component: FC<EditorProps<S, A, L>>;
185
+ documentTypes: string[];
186
+ };
187
+ export type DocumentModelLib = {
188
+ documentModels: DocumentModel[];
189
+ editors: Editor[];
190
+ };
@@ -0,0 +1,61 @@
1
+ import { baseReducer } from '../reducer';
2
+ import { Action, BaseAction, Document, ExtendedState, ImmutableStateReducer, Reducer, Immutable, OperationScope, State, CreateState, PartialState, DocumentOperations, DocumentHeader } from '../types';
3
+ import { SignalDispatch } from '../signal';
4
+ export declare function isBaseAction(action: Action): action is BaseAction;
5
+ /**
6
+ * Helper function to be used by action creators.
7
+ *
8
+ * @remarks
9
+ * Creates an action with the given type and input properties. The input
10
+ * properties default to an empty object.
11
+ *
12
+ * @typeParam A - Type of the action to be returned.
13
+ *
14
+ * @param type - The type of the action.
15
+ * @param input - The input properties of the action.
16
+ *
17
+ * @throws Error if the type is empty or not a string.
18
+ *
19
+ * @returns The new action.
20
+ */
21
+ export declare function createAction<A extends Action>(type: A['type'], input?: A['input'], attachments?: Action['attachments'], validator?: () => {
22
+ parse(v: unknown): A['input'];
23
+ }, scope?: OperationScope): A;
24
+ /**
25
+ * Helper function to create a document model reducer.
26
+ *
27
+ * @remarks
28
+ * This function creates a new reducer that wraps the provided `reducer` with
29
+ * `documentReducer`, adding support for document actions:
30
+ * - `SET_NAME`
31
+ * - `UNDO`
32
+ * - `REDO`
33
+ * - `PRUNE`
34
+ *
35
+ * It also updates the document-related attributes on every operation.
36
+ *
37
+ * @param reducer - The custom reducer to wrap.
38
+ * @param documentReducer - The document reducer to use.
39
+ *
40
+ * @returns The new reducer.
41
+ */
42
+ export declare function createReducer<S = unknown, A extends Action = Action, L = unknown>(reducer: ImmutableStateReducer<S, A, L>, documentReducer?: typeof baseReducer): Reducer<S, A, L>;
43
+ export declare const createExtendedState: <S, L>(initialState?: Partial<ExtendedState<PartialState<S>, PartialState<L>>> | undefined, createState?: CreateState<S, L> | undefined) => ExtendedState<S, L>;
44
+ /**
45
+ * Builds the initial document state from the provided data.
46
+ *
47
+ * @typeParam T - The type of the data.
48
+ * @typeParam A - The type of the actions.
49
+ *
50
+ * @param initialState - The initial state of the document. The `data` property
51
+ * is required, but all other properties are optional.
52
+ *
53
+ * @returns The new document state.
54
+ */
55
+ export declare const createDocument: <S, A extends Action, L = unknown>(initialState?: Partial<ExtendedState<PartialState<S>, PartialState<L>>> | undefined, createState?: ((state?: Partial<State<PartialState<S>, PartialState<L>>> | undefined) => State<S, L>) | undefined) => Document<S, A, L>;
56
+ export declare const hashDocument: (document: Pick<Document, 'state'>, scope?: OperationScope) => string;
57
+ export declare const hashKey: (date?: Date, randomLimit?: number) => string;
58
+ export declare function readOnly<T>(value: T): Immutable<T>;
59
+ export declare function sortOperations<A extends Action>(operations: DocumentOperations<A>): import("../types").Operation<BaseAction | A>[];
60
+ export declare function replayOperations<T, A extends Action, L>(initialState: ExtendedState<T, L>, operations: DocumentOperations<A>, reducer: ImmutableStateReducer<T, A, L>, dispatch?: SignalDispatch, header?: DocumentHeader, documentReducer?: typeof baseReducer): Document<T, A, L>;
61
+ export declare function replayDocument<T, A extends Action, L>(initialState: ExtendedState<T, L>, operations: DocumentOperations<A>, reducer: Reducer<T, A, L>, dispatch?: SignalDispatch, header?: DocumentHeader): Document<T, A, L>;
@@ -0,0 +1,47 @@
1
+ import JSZip from 'jszip';
2
+ import type { Action, AttachmentInput, Document, Reducer } from '../types';
3
+ export type FileInput = string | number[] | Uint8Array | ArrayBuffer | Blob;
4
+ export declare const createZip: (document: Document) => Promise<JSZip>;
5
+ /**
6
+ * Saves a document to a ZIP file.
7
+ *
8
+ * @remarks
9
+ * This function creates a ZIP file containing the document's state, operations,
10
+ * and file attachments. The file is saved to the specified path.
11
+ *
12
+ * @param document - The document to save to the file.
13
+ * @param path - The path to save the file to.
14
+ * @param extension - The extension to use for the file.
15
+ * @returns A promise that resolves to the path of the saved file.
16
+ */
17
+ export declare const saveToFile: (document: Document, path: string, extension: string, name?: string) => Promise<string>;
18
+ export declare const saveToFileHandle: (document: Document, input: FileSystemFileHandle) => Promise<void>;
19
+ /**
20
+ * Loads a document from a ZIP file.
21
+ *
22
+ * @remarks
23
+ * This function reads a ZIP file and returns the document state after
24
+ * applying all the operations. The reducer is used to apply the operations.
25
+ *
26
+ * @typeParam S - The type of the state object.
27
+ * @typeParam A - The type of the actions that can be applied to the state object.
28
+ *
29
+ * @param path - The path to the ZIP file.
30
+ * @param reducer - The reducer to apply the operations to the state object.
31
+ * @returns A promise that resolves to the document state after applying all the operations.
32
+ * @throws An error if the initial state or the operations history is not found in the ZIP file.
33
+ */
34
+ export declare const loadFromFile: <S, A extends Action, L>(path: string, reducer: Reducer<S, A, L>) => Promise<Document<S, A, L>>;
35
+ export declare const loadFromInput: <S, A extends Action, L>(input: FileInput, reducer: Reducer<S, A, L>) => Promise<Document<S, A, L>>;
36
+ /**
37
+ * Fetches an attachment from a URL and returns its base64-encoded data and MIME type.
38
+ * @param url - The URL of the attachment to fetch.
39
+ * @returns A Promise that resolves to an object containing the base64-encoded data and MIME type of the attachment.
40
+ */
41
+ export declare function getRemoteFile(url: string): Promise<AttachmentInput>;
42
+ /**
43
+ * Reads an attachment from a file and returns its base64-encoded data and MIME type.
44
+ * @param path - The path of the attachment file to read.
45
+ * @returns A Promise that resolves to an object containing the base64-encoded data and MIME type of the attachment.
46
+ */
47
+ export declare function getLocalFile(path: string): Promise<AttachmentInput>;
@@ -0,0 +1,2 @@
1
+ export * from './base';
2
+ export * from './file';
@@ -0,0 +1,9 @@
1
+ /// <reference types="node" />
2
+ export declare function writeFile(path: string, name: string, data: Uint8Array): Promise<string>;
3
+ export declare function readFile(path: string): Buffer;
4
+ export declare function fetchFile(url: string): Promise<{
5
+ buffer: Buffer;
6
+ mimeType?: string;
7
+ }>;
8
+ export declare const getFile: (file: string) => Promise<Buffer>;
9
+ export declare const hash: (data: string, algorithm?: string) => string;
@@ -0,0 +1,2 @@
1
+ import { DocumentModelHeaderOperations } from '../../gen/header/operations';
2
+ export declare const reducer: DocumentModelHeaderOperations;
@@ -0,0 +1,2 @@
1
+ import { DocumentModelModuleOperations } from '../../gen/module/operations';
2
+ export declare const reducer: DocumentModelModuleOperations;
@@ -0,0 +1,2 @@
1
+ import { DocumentModelOperationErrorOperations } from '../../gen/operation-error/operations';
2
+ export declare const reducer: DocumentModelOperationErrorOperations;
@@ -0,0 +1,2 @@
1
+ import { DocumentModelOperationExampleOperations } from '../../gen/operation-example/operations';
2
+ export declare const reducer: DocumentModelOperationExampleOperations;
@@ -0,0 +1,2 @@
1
+ import { DocumentModelOperationOperations } from '../../gen/operation/operations';
2
+ export declare const reducer: DocumentModelOperationOperations;
@@ -0,0 +1,2 @@
1
+ import { DocumentModelStateOperations } from '../../gen/state/operations';
2
+ export declare const reducer: DocumentModelStateOperations;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This is a scaffold file meant for customization:
3
+ * - modify it by implementing the reducer functions
4
+ * - delete the file and run the code generator again to have it reset
5
+ */
6
+ import { DocumentModelVersioningOperations } from '../../gen/versioning/operations';
7
+ export declare const reducer: DocumentModelVersioningOperations;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ import { DocumentModelHeaderAction } from './header/actions';
2
+ import { DocumentModelVersioningAction } from './versioning/actions';
3
+ import { DocumentModelModuleAction } from './module/actions';
4
+ import { DocumentModelOperationErrorAction } from './operation-error/actions';
5
+ import { DocumentModelOperationExampleAction } from './operation-example/actions';
6
+ import { DocumentModelOperationAction } from './operation/actions';
7
+ import { DocumentModelStateAction } from './state/actions';
8
+ export * from './header/actions';
9
+ export * from './versioning/actions';
10
+ export * from './module/actions';
11
+ export * from './operation-error/actions';
12
+ export * from './operation-example/actions';
13
+ export * from './operation/actions';
14
+ export * from './state/actions';
15
+ export type DocumentModelAction = DocumentModelHeaderAction | DocumentModelVersioningAction | DocumentModelModuleAction | DocumentModelOperationErrorAction | DocumentModelOperationExampleAction | DocumentModelOperationAction | DocumentModelStateAction;
@@ -0,0 +1,7 @@
1
+ export * from './header/creators';
2
+ export * from './versioning/creators';
3
+ export * from './module/creators';
4
+ export * from './operation-error/creators';
5
+ export * from './operation-example/creators';
6
+ export * from './operation/creators';
7
+ export * from './state/creators';
@@ -0,0 +1,2 @@
1
+ import type { DocumentModelState } from '..';
2
+ export declare const documentModel: DocumentModelState;
@@ -0,0 +1,9 @@
1
+ import { Action } from '../../../document';
2
+ import { SetModelNameInput, SetModelIdInput, SetModelExtensionInput, SetModelDescriptionInput, SetAuthorNameInput, SetAuthorWebsiteInput } from '../types';
3
+ export type SetModelNameAction = Action<'SET_MODEL_NAME', SetModelNameInput>;
4
+ export type SetModelIdAction = Action<'SET_MODEL_ID', SetModelIdInput>;
5
+ export type SetModelExtensionAction = Action<'SET_MODEL_EXTENSION', SetModelExtensionInput>;
6
+ export type SetModelDescriptionAction = Action<'SET_MODEL_DESCRIPTION', SetModelDescriptionInput>;
7
+ export type SetAuthorNameAction = Action<'SET_AUTHOR_NAME', SetAuthorNameInput>;
8
+ export type SetAuthorWebsiteAction = Action<'SET_AUTHOR_WEBSITE', SetAuthorWebsiteInput>;
9
+ export type DocumentModelHeaderAction = SetModelNameAction | SetModelIdAction | SetModelExtensionAction | SetModelDescriptionAction | SetAuthorNameAction | SetAuthorWebsiteAction;
@@ -0,0 +1,8 @@
1
+ import { SetModelNameInput, SetModelIdInput, SetModelExtensionInput, SetModelDescriptionInput, SetAuthorNameInput, SetAuthorWebsiteInput } from '../types';
2
+ import { SetModelNameAction, SetModelIdAction, SetModelExtensionAction, SetModelDescriptionAction, SetAuthorNameAction, SetAuthorWebsiteAction } from './actions';
3
+ export declare const setModelName: (input: SetModelNameInput) => SetModelNameAction;
4
+ export declare const setModelId: (input: SetModelIdInput) => SetModelIdAction;
5
+ export declare const setModelExtension: (input: SetModelExtensionInput) => SetModelExtensionAction;
6
+ export declare const setModelDescription: (input: SetModelDescriptionInput) => SetModelDescriptionAction;
7
+ export declare const setAuthorName: (input: SetAuthorNameInput) => SetAuthorNameAction;
8
+ export declare const setAuthorWebsite: (input: SetAuthorWebsiteInput) => SetAuthorWebsiteAction;
@@ -0,0 +1,11 @@
1
+ import { BaseDocument } from '../../../document/object';
2
+ import { SetModelNameInput, SetModelIdInput, SetModelExtensionInput, SetModelDescriptionInput, SetAuthorNameInput, SetAuthorWebsiteInput, DocumentModelState, DocumentModelLocalState } from '../types';
3
+ import { DocumentModelAction } from '../actions';
4
+ export default class DocumentModel_Header extends BaseDocument<DocumentModelState, DocumentModelAction, DocumentModelLocalState> {
5
+ setModelName(input: SetModelNameInput): this;
6
+ setModelId(input: SetModelIdInput): this;
7
+ setModelExtension(input: SetModelExtensionInput): this;
8
+ setModelDescription(input: SetModelDescriptionInput): this;
9
+ setAuthorName(input: SetAuthorNameInput): this;
10
+ setAuthorWebsite(input: SetAuthorWebsiteInput): this;
11
+ }
@@ -0,0 +1,10 @@
1
+ import { SetModelNameAction, SetModelIdAction, SetModelExtensionAction, SetModelDescriptionAction, SetAuthorNameAction, SetAuthorWebsiteAction } from './actions';
2
+ import { DocumentModelState } from '../types';
3
+ export interface DocumentModelHeaderOperations {
4
+ setModelNameOperation: (state: DocumentModelState, action: SetModelNameAction) => void;
5
+ setModelIdOperation: (state: DocumentModelState, action: SetModelIdAction) => void;
6
+ setModelExtensionOperation: (state: DocumentModelState, action: SetModelExtensionAction) => void;
7
+ setModelDescriptionOperation: (state: DocumentModelState, action: SetModelDescriptionAction) => void;
8
+ setAuthorNameOperation: (state: DocumentModelState, action: SetAuthorNameAction) => void;
9
+ setAuthorWebsiteOperation: (state: DocumentModelState, action: SetAuthorWebsiteAction) => void;
10
+ }
@@ -0,0 +1,5 @@
1
+ export * from './actions';
2
+ export * from './document-model';
3
+ export * from './object';
4
+ export * from './types';
5
+ export * as actions from './creators';
@@ -0,0 +1,8 @@
1
+ import { Action } from '../../../document';
2
+ import { AddModuleInput, SetModuleNameInput, SetModuleDescriptionInput, DeleteModuleInput, ReorderModulesInput } from '../types';
3
+ export type AddModuleAction = Action<'ADD_MODULE', AddModuleInput>;
4
+ export type SetModuleNameAction = Action<'SET_MODULE_NAME', SetModuleNameInput>;
5
+ export type SetModuleDescriptionAction = Action<'SET_MODULE_DESCRIPTION', SetModuleDescriptionInput>;
6
+ export type DeleteModuleAction = Action<'DELETE_MODULE', DeleteModuleInput>;
7
+ export type ReorderModulesAction = Action<'REORDER_MODULES', ReorderModulesInput>;
8
+ export type DocumentModelModuleAction = AddModuleAction | SetModuleNameAction | SetModuleDescriptionAction | DeleteModuleAction | ReorderModulesAction;
@@ -0,0 +1,7 @@
1
+ import { AddModuleInput, SetModuleNameInput, SetModuleDescriptionInput, DeleteModuleInput, ReorderModulesInput } from '../types';
2
+ import { AddModuleAction, SetModuleNameAction, SetModuleDescriptionAction, DeleteModuleAction, ReorderModulesAction } from './actions';
3
+ export declare const addModule: (input: AddModuleInput) => AddModuleAction;
4
+ export declare const setModuleName: (input: SetModuleNameInput) => SetModuleNameAction;
5
+ export declare const setModuleDescription: (input: SetModuleDescriptionInput) => SetModuleDescriptionAction;
6
+ export declare const deleteModule: (input: DeleteModuleInput) => DeleteModuleAction;
7
+ export declare const reorderModules: (input: ReorderModulesInput) => ReorderModulesAction;
@@ -0,0 +1,10 @@
1
+ import { BaseDocument } from '../../../document/object';
2
+ import { AddModuleInput, SetModuleNameInput, SetModuleDescriptionInput, DeleteModuleInput, ReorderModulesInput, DocumentModelState, DocumentModelLocalState } from '../types';
3
+ import { DocumentModelAction } from '../actions';
4
+ export default class DocumentModel_Module extends BaseDocument<DocumentModelState, DocumentModelAction, DocumentModelLocalState> {
5
+ addModule(input: AddModuleInput): this;
6
+ setModuleName(input: SetModuleNameInput): this;
7
+ setModuleDescription(input: SetModuleDescriptionInput): this;
8
+ deleteModule(input: DeleteModuleInput): this;
9
+ reorderModules(input: ReorderModulesInput): this;
10
+ }
@@ -0,0 +1,9 @@
1
+ import { AddModuleAction, SetModuleNameAction, SetModuleDescriptionAction, DeleteModuleAction, ReorderModulesAction } from './actions';
2
+ import { DocumentModelState } from '../types';
3
+ export interface DocumentModelModuleOperations {
4
+ addModuleOperation: (state: DocumentModelState, action: AddModuleAction) => void;
5
+ setModuleNameOperation: (state: DocumentModelState, action: SetModuleNameAction) => void;
6
+ setModuleDescriptionOperation: (state: DocumentModelState, action: SetModuleDescriptionAction) => void;
7
+ deleteModuleOperation: (state: DocumentModelState, action: DeleteModuleAction) => void;
8
+ reorderModulesOperation: (state: DocumentModelState, action: ReorderModulesAction) => void;
9
+ }
@@ -0,0 +1,28 @@
1
+ import { DocumentModelLocalState, DocumentModelState } from './types';
2
+ import { ExtendedState, PartialState, SignalDispatch } from '../../document';
3
+ import { BaseDocument } from '../../document/object';
4
+ import { DocumentModelAction } from './actions';
5
+ import DocumentModel_Header from './header/object';
6
+ import DocumentModel_Versioning from './versioning/object';
7
+ import DocumentModel_Module from './module/object';
8
+ import DocumentModel_OperationError from './operation-error/object';
9
+ import DocumentModel_OperationExample from './operation-example/object';
10
+ import DocumentModel_Operation from './operation/object';
11
+ import DocumentModel_State from './state/object';
12
+ export * from './header/object';
13
+ export * from './versioning/object';
14
+ export * from './module/object';
15
+ export * from './operation-error/object';
16
+ export * from './operation-example/object';
17
+ export * from './operation/object';
18
+ export * from './state/object';
19
+ interface DocumentModel extends DocumentModel_Header, DocumentModel_Versioning, DocumentModel_Module, DocumentModel_OperationError, DocumentModel_OperationExample, DocumentModel_Operation, DocumentModel_State {
20
+ }
21
+ declare class DocumentModel extends BaseDocument<DocumentModelState, DocumentModelAction, DocumentModelLocalState> {
22
+ static fileExtension: string;
23
+ constructor(initialState?: Partial<ExtendedState<PartialState<DocumentModelState>, PartialState<DocumentModelLocalState>>>, dispatch?: SignalDispatch);
24
+ saveToFile(path: string, name?: string): Promise<string>;
25
+ loadFromFile(path: string): Promise<void>;
26
+ static fromFile(path: string): Promise<DocumentModel>;
27
+ }
28
+ export { DocumentModel };