document-model 1.0.15 → 1.0.16
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/dist/browser/document/actions/creators.d.ts +1 -1
- package/dist/browser/document/actions/index.d.ts +8 -8
- package/dist/browser/document/object.d.ts +123 -99
- package/dist/browser/document/reducer.d.ts +1 -1
- package/dist/browser/document/schema/types.d.ts +5 -0
- package/dist/browser/document/schema/zod.d.ts +15 -0
- package/dist/browser/document/types.d.ts +36 -27
- package/dist/browser/document/utils/base.d.ts +5 -5
- package/dist/browser/document/utils/file.d.ts +2 -2
- package/dist/browser/document-model/gen/reducer.d.ts +1 -1
- package/dist/browser/document-model/gen/schema/types.d.ts +5 -2
- package/dist/browser/document-model/index.d.ts +8 -8
- package/dist/browser/document-model.cjs +1 -1
- package/dist/browser/document-model.js +2 -2
- package/dist/browser/document.cjs +1 -1
- package/dist/browser/document.js +2 -2
- package/dist/browser/index.cjs +1 -1
- package/dist/browser/index.js +3 -3
- package/dist/browser/internal/{index-8142b58e.js → index-37753e74.js} +1 -1
- package/dist/{node/internal/index-0b0cb8c2.js → browser/internal/index-9b4d67fc.js} +1 -1
- package/dist/browser/internal/{index-cbe39f72.js → index-a5150e7e.js} +1 -1
- package/dist/{node/internal/index-c9d178be.js → browser/internal/index-f5587600.js} +1 -1
- package/dist/browser/internal/{object-4ec03a36.js → object-17aee7a9.js} +693 -659
- package/dist/browser/internal/object-28a1a8bf.js +6 -0
- package/dist/node/document/actions/creators.d.ts +1 -1
- package/dist/node/document/actions/index.d.ts +8 -8
- package/dist/node/document/object.d.ts +123 -99
- package/dist/node/document/reducer.d.ts +1 -1
- package/dist/node/document/schema/types.d.ts +5 -0
- package/dist/node/document/schema/zod.d.ts +15 -0
- package/dist/node/document/types.d.ts +36 -27
- package/dist/node/document/utils/base.d.ts +5 -5
- package/dist/node/document/utils/file.d.ts +2 -2
- package/dist/node/document-model/gen/reducer.d.ts +1 -1
- package/dist/node/document-model/gen/schema/types.d.ts +5 -2
- package/dist/node/document-model/index.d.ts +8 -8
- package/dist/node/document-model.cjs +1 -1
- package/dist/node/document-model.js +2 -2
- package/dist/node/document.cjs +1 -1
- package/dist/node/document.js +2 -2
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.js +3 -3
- package/dist/{browser/internal/index-cb990484.js → node/internal/index-0e7af6c6.js} +1 -1
- package/dist/{browser/internal/index-9f1cf811.js → node/internal/index-124bda95.js} +1 -1
- package/dist/node/internal/{index-63db4708.js → index-417115f1.js} +1 -1
- package/dist/node/internal/{index-0c87fbed.js → index-9037f83a.js} +1 -1
- package/dist/node/internal/object-f3dd289e.js +1 -0
- package/dist/node/internal/{object-89d9b82f.js → object-f7cd4777.js} +369 -337
- package/package.json +3 -3
- package/dist/browser/internal/object-5f03095e.js +0 -6
- package/dist/node/internal/object-397a9b23.js +0 -1
|
@@ -34,7 +34,7 @@ export type ActionWithAttachment<T extends string = string, I = unknown> = Actio
|
|
|
34
34
|
* @typeParam State - The type of the document data.
|
|
35
35
|
* @typeParam A - The type of the actions supported by the reducer.
|
|
36
36
|
*/
|
|
37
|
-
export type Reducer<State, A extends Action> = (state: Document<State, A>, action: A | BaseAction, dispatch?: SignalDispatch) => Document<State, A>;
|
|
37
|
+
export type Reducer<State, A extends Action, LocalState> = (state: Document<State, A, LocalState>, action: A | BaseAction, dispatch?: SignalDispatch) => Document<State, A, LocalState>;
|
|
38
38
|
/**
|
|
39
39
|
* A {@link Reducer} that prevents mutable code from changing the previous state.
|
|
40
40
|
*
|
|
@@ -47,8 +47,8 @@ export type Reducer<State, A extends Action> = (state: Document<State, A>, actio
|
|
|
47
47
|
* @typeParam State - The type of the document data.
|
|
48
48
|
* @typeParam A - The type of the actions supported by the reducer.
|
|
49
49
|
*/
|
|
50
|
-
export type ImmutableReducer<State, A extends Action> = (state: Draft<Document<State, A>>, action: A | BaseAction, dispatch?: SignalDispatch) => Document<State, A> | void;
|
|
51
|
-
export type ImmutableStateReducer<
|
|
50
|
+
export type ImmutableReducer<State, A extends Action, LocalState> = (state: Draft<Document<State, A, LocalState>>, action: A | BaseAction, dispatch?: SignalDispatch) => Document<State, A, LocalState> | void;
|
|
51
|
+
export type ImmutableStateReducer<S, A extends Action, L = unknown> = (state: Draft<State<S, L>>, action: A, dispatch?: SignalDispatch) => State<S, L> | void;
|
|
52
52
|
/**
|
|
53
53
|
* Scope of an operation.
|
|
54
54
|
* Global: The operation is synchronized everywhere in the network. This is the default document operation.
|
|
@@ -111,12 +111,21 @@ export type AttachmentInput = Attachment & {
|
|
|
111
111
|
*
|
|
112
112
|
*/
|
|
113
113
|
export type FileRegistry = Record<AttachmentRef, Attachment>;
|
|
114
|
-
export type
|
|
114
|
+
export type State<GlobalState, LocalState> = {
|
|
115
|
+
global: GlobalState;
|
|
116
|
+
local: LocalState;
|
|
117
|
+
};
|
|
118
|
+
export type CreateState<S, L> = (state?: Partial<State<Partial<S>, Partial<L>>>) => State<S, L>;
|
|
119
|
+
export type ExtendedState<GlobalState, LocalState = unknown> = DocumentHeader & {
|
|
115
120
|
/** The document model specific state. */
|
|
116
|
-
state: State
|
|
121
|
+
state: State<GlobalState, LocalState>;
|
|
117
122
|
/** The index of document attachments. */
|
|
118
123
|
attachments: FileRegistry;
|
|
119
124
|
};
|
|
125
|
+
export type DocumentOperations<A extends Action> = {
|
|
126
|
+
global: Operation<A | BaseAction>[];
|
|
127
|
+
local: Operation<A>[];
|
|
128
|
+
};
|
|
120
129
|
/**
|
|
121
130
|
* The base type of a document model.
|
|
122
131
|
*
|
|
@@ -126,13 +135,13 @@ export type ExtendedState<State = unknown> = DocumentHeader & {
|
|
|
126
135
|
* @typeParam Data - The type of the document data attribute.
|
|
127
136
|
* @typeParam A - The type of the actions supported by the Document.
|
|
128
137
|
*/
|
|
129
|
-
export type Document<
|
|
138
|
+
export type Document<GlobalState = unknown, A extends Action = Action, LocalState = unknown> =
|
|
130
139
|
/** The document model specific state. */
|
|
131
|
-
ExtendedState<
|
|
140
|
+
ExtendedState<GlobalState, LocalState> & {
|
|
132
141
|
/** The operations history of the document. */
|
|
133
|
-
operations:
|
|
142
|
+
operations: DocumentOperations<A>;
|
|
134
143
|
/** The initial state of the document, enabling replaying operations. */
|
|
135
|
-
initialState: ExtendedState<
|
|
144
|
+
initialState: ExtendedState<GlobalState, LocalState>;
|
|
136
145
|
};
|
|
137
146
|
/**
|
|
138
147
|
* String type representing an attachment in a Document.
|
|
@@ -141,40 +150,40 @@ ExtendedState<S> & {
|
|
|
141
150
|
* Attachment string is formatted as `attachment://<filename>`.
|
|
142
151
|
*/
|
|
143
152
|
export type AttachmentRef = string;
|
|
144
|
-
export interface DocumentClass<S, A extends Action = Action, C extends BaseDocument<S, A> = BaseDocument<S, A>> {
|
|
153
|
+
export interface DocumentClass<S, A extends Action = Action, L = unknown, C extends BaseDocument<S, A, L> = BaseDocument<S, A, L>> {
|
|
145
154
|
fileExtension: string;
|
|
146
155
|
fromFile: (path: string) => Promise<C>;
|
|
147
|
-
new (initialState?: ExtendedState<S>): C;
|
|
156
|
+
new (initialState?: ExtendedState<S, L>): C;
|
|
148
157
|
}
|
|
149
|
-
export type DocumentModelUtils<S = unknown, A extends Action = Action> = {
|
|
158
|
+
export type DocumentModelUtils<S = unknown, A extends Action = Action, L = unknown> = {
|
|
150
159
|
fileExtension: string;
|
|
151
|
-
createState:
|
|
152
|
-
createExtendedState: (extendedState?: Partial<ExtendedState<Partial<S>>>, createState?:
|
|
153
|
-
createDocument: (document?: Partial<ExtendedState<Partial<S>>>, createState?:
|
|
154
|
-
loadFromFile: (path: string) => Promise<Document<S, A>>;
|
|
155
|
-
loadFromInput: (input: FileInput) => Promise<Document<S, A>>;
|
|
156
|
-
saveToFile: (document: Document<S, A>, path: string, name?: string) => Promise<string>;
|
|
157
|
-
saveToFileHandle: (document: Document<S, A>, input: FileSystemFileHandle) => Promise<void>;
|
|
160
|
+
createState: CreateState<S, L>;
|
|
161
|
+
createExtendedState: (extendedState?: Partial<ExtendedState<Partial<S>, Partial<L>>>, createState?: CreateState<S, L>) => ExtendedState<S, L>;
|
|
162
|
+
createDocument: (document?: Partial<ExtendedState<Partial<S>, Partial<L>>>, createState?: CreateState<S, L>) => Document<S, A, L>;
|
|
163
|
+
loadFromFile: (path: string) => Promise<Document<S, A, L>>;
|
|
164
|
+
loadFromInput: (input: FileInput) => Promise<Document<S, A, L>>;
|
|
165
|
+
saveToFile: (document: Document<S, A, L>, path: string, name?: string) => Promise<string>;
|
|
166
|
+
saveToFileHandle: (document: Document<S, A, L>, input: FileSystemFileHandle) => Promise<void>;
|
|
158
167
|
};
|
|
159
168
|
export type ActionCreator<A extends Action> = ((input: any) => A) | ((input: any, attachments: AttachmentInput[]) => A) | ((...input: any) => BaseAction);
|
|
160
|
-
export type DocumentModel<S = unknown, A extends Action = Action, C extends BaseDocument<S, A> = BaseDocument<S, A>> = {
|
|
161
|
-
Document: DocumentClass<S, A, C>;
|
|
162
|
-
reducer: Reducer<S, A>;
|
|
169
|
+
export type DocumentModel<S = unknown, A extends Action = Action, L = unknown, C extends BaseDocument<S, A, L> = BaseDocument<S, A, L>> = {
|
|
170
|
+
Document: DocumentClass<S, A, L, C>;
|
|
171
|
+
reducer: Reducer<S, A, L>;
|
|
163
172
|
actions: Record<string, ActionCreator<A>>;
|
|
164
|
-
utils: DocumentModelUtils<S, A>;
|
|
173
|
+
utils: DocumentModelUtils<S, A, L>;
|
|
165
174
|
documentModel: DocumentModelState;
|
|
166
175
|
};
|
|
167
176
|
export type EditorContext = {
|
|
168
177
|
theme: 'light' | 'dark';
|
|
169
178
|
debug?: boolean;
|
|
170
179
|
};
|
|
171
|
-
export type EditorProps<S, A extends Action> = {
|
|
172
|
-
document: Document<S, A>;
|
|
180
|
+
export type EditorProps<S, A extends Action, L> = {
|
|
181
|
+
document: Document<S, A, L>;
|
|
173
182
|
dispatch: (action: A | BaseAction) => void;
|
|
174
183
|
editorContext: EditorContext;
|
|
175
184
|
};
|
|
176
|
-
export type Editor<S = unknown, A extends Action = Action> = {
|
|
177
|
-
Component: FC<EditorProps<S, A>>;
|
|
185
|
+
export type Editor<S = unknown, A extends Action = Action, L = unknown> = {
|
|
186
|
+
Component: FC<EditorProps<S, A, L>>;
|
|
178
187
|
documentTypes: string[];
|
|
179
188
|
};
|
|
180
189
|
export type DocumentModelLib = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { baseReducer } from '../reducer';
|
|
2
|
-
import { Action, BaseAction, Document, ExtendedState, ImmutableStateReducer, Reducer, Immutable, OperationScope } from '../types';
|
|
2
|
+
import { Action, BaseAction, Document, ExtendedState, ImmutableStateReducer, Reducer, Immutable, OperationScope, State, CreateState } from '../types';
|
|
3
3
|
export declare function isBaseAction(action: Action): action is BaseAction;
|
|
4
4
|
/**
|
|
5
5
|
* Helper function to be used by action creators.
|
|
@@ -38,8 +38,8 @@ export declare function createAction<A extends Action>(type: A['type'], input?:
|
|
|
38
38
|
*
|
|
39
39
|
* @returns The new reducer.
|
|
40
40
|
*/
|
|
41
|
-
export declare function createReducer<S = unknown, A extends Action = Action>(reducer: ImmutableStateReducer<S, A>, documentReducer?: typeof baseReducer): Reducer<S, A>;
|
|
42
|
-
export declare const createExtendedState: <S>(initialState?: Partial<ExtendedState<Partial<S>>> | undefined, createState?:
|
|
41
|
+
export declare function createReducer<S = unknown, A extends Action = Action, L = unknown>(reducer: ImmutableStateReducer<S, A, L>, documentReducer?: typeof baseReducer): Reducer<S, A, L>;
|
|
42
|
+
export declare const createExtendedState: <S, L>(initialState?: Partial<ExtendedState<Partial<S>, Partial<L>>> | undefined, createState?: CreateState<S, L> | undefined) => ExtendedState<S, L>;
|
|
43
43
|
/**
|
|
44
44
|
* Builds the initial document state from the provided data.
|
|
45
45
|
*
|
|
@@ -51,7 +51,7 @@ export declare const createExtendedState: <S>(initialState?: Partial<ExtendedSta
|
|
|
51
51
|
*
|
|
52
52
|
* @returns The new document state.
|
|
53
53
|
*/
|
|
54
|
-
export declare const createDocument: <S, A extends Action>(initialState?: Partial<ExtendedState<Partial<S>>> | undefined, createState?: ((state?: Partial<S
|
|
55
|
-
export declare const hashDocument: (document: Document) => string;
|
|
54
|
+
export declare const createDocument: <S, A extends Action, L = unknown>(initialState?: Partial<ExtendedState<Partial<S>, Partial<L>>> | undefined, createState?: ((state?: Partial<State<Partial<S>, Partial<L>>> | undefined) => State<S, L>) | undefined) => Document<S, A, L>;
|
|
55
|
+
export declare const hashDocument: (document: Document, scope?: OperationScope) => string;
|
|
56
56
|
export declare const hashKey: (date?: Date, randomLimit?: number) => string;
|
|
57
57
|
export declare function readOnly<T>(value: T): Immutable<T>;
|
|
@@ -31,8 +31,8 @@ export declare const saveToFileHandle: (document: Document, input: FileSystemFil
|
|
|
31
31
|
* @returns A promise that resolves to the document state after applying all the operations.
|
|
32
32
|
* @throws An error if the initial state or the operations history is not found in the ZIP file.
|
|
33
33
|
*/
|
|
34
|
-
export declare const loadFromFile: <S, A extends Action>(path: string, reducer: Reducer<S, A>) => Promise<Document<S, A>>;
|
|
35
|
-
export declare const loadFromInput: <S, A extends Action>(input: FileInput, reducer: Reducer<S, A>) => Promise<Document<S, A>>;
|
|
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
36
|
/**
|
|
37
37
|
* Fetches an attachment from a URL and returns its base64-encoded data and MIME type.
|
|
38
38
|
* @param url - The URL of the attachment to fetch.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { DocumentModelState } from './schema';
|
|
2
2
|
import { DocumentModelAction } from './actions';
|
|
3
|
-
export declare const reducer: import("../../document/types").Reducer<DocumentModelState, DocumentModelAction>;
|
|
3
|
+
export declare const reducer: import("../../document/types").Reducer<DocumentModelState, DocumentModelAction, unknown>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OperationScope } from
|
|
1
|
+
import { OperationScope } from '../../../document';
|
|
2
2
|
export type Maybe<T> = T | null;
|
|
3
3
|
export type InputMaybe<T> = T | null | undefined;
|
|
4
4
|
export type Exact<T extends {
|
|
@@ -126,7 +126,10 @@ export type DocumentSpecification = {
|
|
|
126
126
|
__typename?: 'DocumentSpecification';
|
|
127
127
|
changeLog: Array<Scalars['String']['output']>;
|
|
128
128
|
modules: Array<Module>;
|
|
129
|
-
state:
|
|
129
|
+
state: {
|
|
130
|
+
global: State;
|
|
131
|
+
local: State;
|
|
132
|
+
};
|
|
130
133
|
version: Scalars['Int']['output'];
|
|
131
134
|
};
|
|
132
135
|
export type Module = {
|
|
@@ -10,13 +10,13 @@ import { DocumentModelAction, DocumentModelState } from './gen/types';
|
|
|
10
10
|
declare const Document: typeof DocumentModel;
|
|
11
11
|
declare const utils: {
|
|
12
12
|
fileExtension: string;
|
|
13
|
-
createState: (
|
|
14
|
-
createExtendedState: (extendedState?: Partial<import("../document").ExtendedState<Partial<DocumentModelState>>> | undefined, createState?: (
|
|
15
|
-
createDocument: (document?: Partial<import("../document").ExtendedState<Partial<DocumentModelState>>> | undefined, createState?: (
|
|
16
|
-
loadFromFile: (path: string) => Promise<import("../document").Document<DocumentModelState, DocumentModelAction>>;
|
|
17
|
-
loadFromInput: (input: import("../document").FileInput) => Promise<import("../document").Document<DocumentModelState, DocumentModelAction>>;
|
|
18
|
-
saveToFile: (document: import("../document").Document<DocumentModelState, DocumentModelAction>, path: string, name?: string | undefined) => Promise<string>;
|
|
19
|
-
saveToFileHandle: (document: import("../document").Document<DocumentModelState, DocumentModelAction>, input: FileSystemFileHandle) => Promise<void>;
|
|
13
|
+
createState: import("../document").CreateState<DocumentModelState, unknown>;
|
|
14
|
+
createExtendedState: (extendedState?: Partial<import("../document").ExtendedState<Partial<DocumentModelState>, Partial<unknown>>> | undefined, createState?: import("../document").CreateState<DocumentModelState, unknown> | undefined) => import("../document").ExtendedState<DocumentModelState, unknown>;
|
|
15
|
+
createDocument: (document?: Partial<import("../document").ExtendedState<Partial<DocumentModelState>, Partial<unknown>>> | undefined, createState?: import("../document").CreateState<DocumentModelState, unknown> | undefined) => import("../document").Document<DocumentModelState, DocumentModelAction, unknown>;
|
|
16
|
+
loadFromFile: (path: string) => Promise<import("../document").Document<DocumentModelState, DocumentModelAction, unknown>>;
|
|
17
|
+
loadFromInput: (input: import("../document").FileInput) => Promise<import("../document").Document<DocumentModelState, DocumentModelAction, unknown>>;
|
|
18
|
+
saveToFile: (document: import("../document").Document<DocumentModelState, DocumentModelAction, unknown>, path: string, name?: string | undefined) => Promise<string>;
|
|
19
|
+
saveToFileHandle: (document: import("../document").Document<DocumentModelState, DocumentModelAction, unknown>, input: FileSystemFileHandle) => Promise<void>;
|
|
20
20
|
};
|
|
21
21
|
declare const actions: {
|
|
22
22
|
setModelName: (input: import("./gen").SetModelNameInput) => import("./gen").SetModelNameAction;
|
|
@@ -66,7 +66,7 @@ declare const actions: {
|
|
|
66
66
|
undo: (count?: number) => import("../document").UndoAction;
|
|
67
67
|
redo: (count?: number) => import("../document").RedoAction;
|
|
68
68
|
prune: (start?: number | undefined, end?: number | undefined) => import("../document").PruneAction;
|
|
69
|
-
loadState: (state: Pick<import("../document").ExtendedState, "name" | "state">, operations: number) => import("../document").LoadStateAction;
|
|
69
|
+
loadState: <S, T>(state: Pick<import("../document").ExtendedState<S, T>, "name" | "state">, operations: number) => import("../document").LoadStateAction;
|
|
70
70
|
};
|
|
71
71
|
export declare const module: _DocumentModel<DocumentModelState, DocumentModelAction, DocumentModel>;
|
|
72
72
|
export * from './custom/utils';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-f3dd289e.js");require("json-stringify-deterministic");require("immer");require("crypto");require("fs");require("https");require("path");require("jszip");const e=require("./internal/index-417115f1.js");require("zod");exports.Document=e.Document;exports.DocumentModel=e.DocumentModel$1;exports.actions=e.actions;exports.documentModel=e.documentModel;exports.module=e.module;exports.reducer=e.reducer;exports.utils=e.utils;exports.z=e.zod;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./internal/object-
|
|
1
|
+
import "./internal/object-f7cd4777.js";
|
|
2
2
|
import "json-stringify-deterministic";
|
|
3
3
|
import "immer";
|
|
4
4
|
import "crypto";
|
|
@@ -6,7 +6,7 @@ import "fs";
|
|
|
6
6
|
import "https";
|
|
7
7
|
import "path";
|
|
8
8
|
import "jszip";
|
|
9
|
-
import { b as d, a as l, c as n, d as D, m as M, r as b, u as f, z as x } from "./internal/index-
|
|
9
|
+
import { b as d, a as l, c as n, d as D, m as M, r as b, u as f, z as x } from "./internal/index-9037f83a.js";
|
|
10
10
|
import "zod";
|
|
11
11
|
export {
|
|
12
12
|
d as Document,
|
package/dist/node/document.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-f3dd289e.js"),r=require("./internal/index-0e7af6c6.js");require("json-stringify-deterministic");require("immer");require("jszip");require("crypto");require("fs");require("https");require("path");require("zod");exports.BaseDocument=e.BaseDocument;exports.actions=e.BaseActions;exports.applyMixins=e.applyMixins;exports.baseReducer=e.baseReducer;exports.z=e.zod;exports.utils=r.index;
|
package/dist/node/document.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as n, h as u, g as x, p as f, z as l } from "./internal/object-
|
|
2
|
-
import { i as b } from "./internal/index-
|
|
1
|
+
import { B as n, h as u, g as x, p as f, z as l } from "./internal/object-f7cd4777.js";
|
|
2
|
+
import { i as b } from "./internal/index-124bda95.js";
|
|
3
3
|
import "json-stringify-deterministic";
|
|
4
4
|
import "immer";
|
|
5
5
|
import "jszip";
|
package/dist/node/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./internal/index-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./internal/index-0e7af6c6.js"),o=require("./internal/index-417115f1.js");require("./internal/object-f3dd289e.js");require("json-stringify-deterministic");require("immer");require("jszip");require("crypto");require("fs");require("https");require("path");require("zod");const u={"powerhouse/document":e.Document,"powerhouse/document-model":o.DocumentModel},r={Document:e.Document,DocumentModel:o.DocumentModel};exports.Document=e.Document;exports.DocumentModel=o.DocumentModel;exports.DocumentModels=u;exports.default=r;
|
package/dist/node/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as o } from "./internal/index-
|
|
2
|
-
import { D as t } from "./internal/index-
|
|
3
|
-
import "./internal/object-
|
|
1
|
+
import { D as o } from "./internal/index-124bda95.js";
|
|
2
|
+
import { D as t } from "./internal/index-9037f83a.js";
|
|
3
|
+
import "./internal/object-f7cd4777.js";
|
|
4
4
|
import "json-stringify-deterministic";
|
|
5
5
|
import "immer";
|
|
6
6
|
import "jszip";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("./object-
|
|
1
|
+
"use strict";const e=require("./object-f3dd289e.js"),t=Object.freeze(Object.defineProperty({__proto__:null,createAction:e.createAction,createDocument:e.createDocument,createExtendedState:e.createExtendedState,createReducer:e.createReducer,createZip:e.createZip,getLocalFile:e.getLocalFile,getRemoteFile:e.getRemoteFile,hashDocument:e.hashDocument,hashKey:e.hashKey,isBaseAction:e.isBaseAction,loadFromFile:e.loadFromFile,loadFromInput:e.loadFromInput,readOnly:e.readOnly,saveToFile:e.saveToFile,saveToFileHandle:e.saveToFileHandle},Symbol.toStringTag,{value:"Module"})),o=Object.freeze(Object.defineProperty({__proto__:null,BaseDocument:e.BaseDocument,actions:e.BaseActions,applyMixins:e.applyMixins,baseReducer:e.baseReducer,utils:t,z:e.zod},Symbol.toStringTag,{value:"Module"}));exports.Document=o;exports.index=t;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as e, b as a, a as s, c as t, j as o, k as r, m as c, n as l, o as n, i, l as d, e as u, r as m, s as p, d as b, B as _, h as g, g as y, p as F, z as f } from "./object-
|
|
1
|
+
import { f as e, b as a, a as s, c as t, j as o, k as r, m as c, n as l, o as n, i, l as d, e as u, r as m, s as p, d as b, B as _, h as g, g as y, p as F, z as f } from "./object-f7cd4777.js";
|
|
2
2
|
const h = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3
3
|
__proto__: null,
|
|
4
4
|
createAction: e,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var dt=Object.defineProperty;var ut=(t,e,n)=>e in t?dt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var de=(t,e,n)=>(ut(t,typeof e!="symbol"?e+"":e,n),n);const s=require("./object-
|
|
1
|
+
"use strict";var dt=Object.defineProperty;var ut=(t,e,n)=>e in t?dt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var de=(t,e,n)=>(ut(t,typeof e!="symbol"?e+"":e,n),n);const s=require("./object-f3dd289e.js");require("json-stringify-deterministic");require("immer");require("crypto");require("fs");require("https");require("path");require("jszip");const r=require("zod"),mt=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),f={id:"powerhouse/document-model",name:"DocumentModel",extension:"phdm",description:"The Powerhouse Document Model describes the state and operations of a document type.",author:{name:"Powerhouse",website:"https://www.powerhouse.inc/"},specifications:[{version:1,changeLog:[],modules:[{name:"header",operations:[{name:"SetModelName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelId",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelExtension",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetAuthorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetAuthorWebsite",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"versioning",operations:[{name:"AddChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderChangeLogItems",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReleaseNewVersion",schema:null,id:"",description:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"module",operations:[{name:"AddModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModuleName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModuleDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderModules",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation-error",operations:[{name:"AddOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorCode",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderOperationErrors",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation-example",operations:[{name:"AddOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderOperationExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation",operations:[{name:"AddOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationReducer",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"MoveOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderModuleOperations",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"state",operations:[{name:"SetStateSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetInitialState",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"AddStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderStateExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""}],state:{schema:"",initialValue:`{
|
|
2
2
|
"id": "",
|
|
3
3
|
"name": "",
|
|
4
4
|
"extension": "",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var dt = Object.defineProperty;
|
|
2
2
|
var ct = (t, e, n) => e in t ? dt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
3
|
var pe = (t, e, n) => (ct(t, typeof e != "symbol" ? e + "" : e, n), n);
|
|
4
|
-
import { c as ut, i as mt, a as Et, b as ht, s as Ot, d as gt, l as St, e as ft, f as s, B as l, g as _t, h as It } from "./object-
|
|
4
|
+
import { c as ut, i as mt, a as Et, b as ht, s as Ot, d as gt, l as St, e as ft, f as s, B as l, g as _t, h as It } from "./object-f7cd4777.js";
|
|
5
5
|
import "json-stringify-deterministic";
|
|
6
6
|
import "immer";
|
|
7
7
|
import "crypto";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var st=Object.defineProperty;var lt=(t,e,i)=>e in t?st(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var f=(t,e,i)=>(lt(t,typeof e!="symbol"?e+"":e,i),i);const pt=require("json-stringify-deterministic"),x=require("immer"),q=require("jszip"),ct=require("crypto"),z=require("fs"),rt=require("https"),mt=require("path"),n=require("zod"),P=t=>t!=null,ut=n.z.any().refine(t=>P(t)),M=n.z.enum(["LOAD_STATE"]),R=n.z.enum(["PRUNE"]),L=n.z.enum(["REDO"]),I=n.z.enum(["SET_NAME"]),U=n.z.enum(["UNDO"]);function dt(){return n.z.object({__typename:n.z.literal("Action").optional(),type:n.z.string()})}function J(){return n.z.union([D(),k(),E(),A(),N()])}function xt(){return n.z.object({__typename:n.z.literal("DocumentFile").optional(),data:n.z.string(),extension:n.z.string().nullable(),fileName:n.z.string().nullable(),mimeType:n.z.string()})}function D(){return n.z.object({input:n.z.lazy(()=>B()),type:M,scope:n.z.literal("global")})}function B(){return n.z.object({operations:n.z.number(),state:n.z.lazy(()=>C())})}function C(){return n.z.object({data:n.z.unknown().nullish(),name:n.z.string()})}function gt(){return n.z.object({__typename:n.z.literal("Operation").optional(),hash:n.z.string(),index:n.z.number(),timestamp:n.z.string().datetime(),type:n.z.string()})}function k(){return n.z.object({input:n.z.lazy(()=>$()),type:R,scope:n.z.literal("global")})}function $(){return n.z.object({end:n.z.number().nullish(),start:n.z.number().nullish()})}function E(){return n.z.object({input:n.z.number(),type:L,scope:n.z.literal("global")})}function A(){return n.z.object({input:n.z.string(),type:I,scope:n.z.literal("global")})}function ft(){return n.z.object({__typename:n.z.literal("SetNameOperation").optional(),hash:n.z.string(),index:n.z.number(),input:n.z.string(),timestamp:n.z.string().datetime(),type:n.z.string()})}function N(){return n.z.object({input:n.z.number(),type:U,scope:n.z.literal("global")})}const ht=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:dt,BaseActionSchema:J,DocumentFileSchema:xt,LoadStateActionInputSchema:B,LoadStateActionSchema:D,LoadStateActionStateInputSchema:C,Load_StateSchema:M,OperationSchema:gt,PruneActionInputSchema:$,PruneActionSchema:k,PruneSchema:R,RedoActionSchema:E,RedoSchema:L,SetNameActionSchema:A,SetNameOperationSchema:ft,Set_NameSchema:I,UndoActionSchema:N,UndoSchema:U,definedNonNullAnySchema:ut,isDefinedNonNullAny:P},Symbol.toStringTag,{value:"Module"}));function bt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function b(){this._types=Object.create(null),this._extensions=Object.create(null);for(let t=0;t<arguments.length;t++)this.define(arguments[t]);this.define=this.define.bind(this),this.getType=this.getType.bind(this),this.getExtension=this.getExtension.bind(this)}b.prototype.define=function(t,e){for(let i in t){let a=t[i].map(function(o){return o.toLowerCase()});i=i.toLowerCase();for(let o=0;o<a.length;o++){const s=a[o];if(s[0]!=="*"){if(!e&&s in this._types)throw new Error('Attempt to change mapping for "'+s+'" extension from "'+this._types[s]+'" to "'+i+'". Pass `force=true` to allow this, otherwise remove "'+s+'" from the list of extensions for "'+i+'".');this._types[s]=i}}if(e||!this._extensions[i]){const o=a[0];this._extensions[i]=o[0]!=="*"?o:o.substr(1)}}};b.prototype.getType=function(t){t=String(t);let e=t.replace(/^.*[/\\]/,"").toLowerCase(),i=e.replace(/^.*\./,"").toLowerCase(),a=e.length<t.length;return(i.length<e.length-1||!a)&&this._types[i]||null};b.prototype.getExtension=function(t){return t=/^\s*([^;\s]*)/.test(t)&&RegExp.$1,t&&this._extensions[t.toLowerCase()]||null};var vt=b,yt={"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["es","ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js","mjs"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/trig":["trig"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avif":["avif"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]};let jt=vt;var wt=new jt(yt);const zt=bt(wt);function St(t,e,i){const a=mt.join(t,e);return z.mkdirSync(t,{recursive:!0}),new Promise((o,s)=>{try{z.writeFile(a,i,{},l=>{l?s(l):o(a)})}catch(l){s(l)}})}function Z(t){return z.readFileSync(t)}function _t(t){return new Promise((e,i)=>{rt.get(t,a=>{const o=[],s=a.headers["content-type"];a.on("data",l=>{o.push(l)}),a.on("end",()=>{e({buffer:Buffer.concat(o),mimeType:s})})}).on("error",a=>{i(a)})})}const Ot=async t=>Z(t),v=(t,e="sha1")=>ct.createHash(e).update(t).digest("base64"),T=async t=>{const e=new q,{name:i,revision:a,documentType:o,created:s,lastModified:l}=t,p={name:i,revision:a,documentType:o,created:s,lastModified:l};return e.file("header.json",JSON.stringify(p,null,2)),e.file("state.json",JSON.stringify(t.initialState||{},null,2)),e.file("operations.json",JSON.stringify(t.operations,null,2)),Object.keys(t.attachments).forEach(m=>{const{data:r,...w}=t.attachments[m];e.file(m,r,{base64:!0,createFolders:!0,comment:JSON.stringify(w)})}),e},H=async(t,e,i,a)=>{const s=await(await T(t)).generateAsync({type:"uint8array",streamFiles:!0}),l=a??t.name,p=`.${i}.zip`;return St(e,l.endsWith(p)?l:`${l}${p}`,s)},Dt=async(t,e)=>{const a=await(await T(t)).generateAsync({type:"blob"}),o=await e.createWritable();await o.write(a),await o.close()},S=async(t,e)=>{const i=Z(t);return K(i,e)},K=async(t,e)=>{const i=new q;return await i.loadAsync(t),kt(i,e)};async function kt(t,e){const i=t.file("state.json");if(!i)throw new Error("Initial state not found");const a=await i.async("string"),o=JSON.parse(a),s=t.file("header.json");let l=null;s&&(l=JSON.parse(await s.async("string")));const p=t.file("operations.json");if(!p)throw new Error("Operations history not found");const c=JSON.parse(await p.async("string")),m={...o,...l,initialState:o,operations:{global:[],local:[]},attachments:{...o.attachments}};let r=c.global.concat(c.local).slice(0,l==null?void 0:l.revision).reduce((w,nt)=>e(w,nt),m);return l&&(r={...r,...l,operations:{global:[...r.operations.global,...c.global.slice(l.revision)],local:r.operations.local}}),r}function W(t){const e=t.replace(/^.*\./,"")||void 0,i=t.replace(/^.*[/\\]/,"")||void 0;return{extension:e,fileName:i}}async function Et(t){const{buffer:e,mimeType:i="application/octet-stream"}=await _t(t),a=W(t),o=e.toString("base64");return{data:o,hash:v(o),mimeType:i,...a}}async function At(t){const e=await Ot(t),i=zt.getType(t)||"application/octet-stream",a=W(t),o=e.toString("base64");return{data:o,hash:v(o),mimeType:i,...a}}function h(t,e,i,a){const o=tt(t),s=X(i);return e.global.concat(e.local).reduce((l,p)=>s(l,p,a),o)}function Nt(t,e){return{...t,name:e}}function Tt(t,e,i){const a=Math.min(e,t.revision),o=t.operations.global.slice(0,t.revision-a);return{...h(t.initialState,{global:o,local:t.operations.local},i),operations:t.operations,revision:t.revision-a}}function Ft(t,e,i){const a=t.operations.global.length-t.revision;if(!a)throw new Error("There is no UNDO operation to REDO");const o=e<a?e:a,s=t.operations.global.slice(0,t.revision+o);return{...h(t.initialState,{global:s,local:t.operations.local},i),operations:t.operations,revision:t.revision+o}}function qt(t,e,i,a){e=e||0,i=i||t.operations.global.length;const o=t.operations.global.slice(e,i),s=t.operations.global.slice(0,e),l=t.operations.global.slice(i),p=h(t.initialState,{global:s.concat(o),local:t.operations.local},a),{name:c,state:m}=p;return h(t.initialState,{global:[...s,F({name:c,state:m},o.length),...l],local:t.operations.local},a)}function Pt(t,e){return{...t,name:e.name,state:e.state??{global:{},local:{}}}}const G="SET_NAME",y="UNDO",j="REDO",g="PRUNE",Q="LOAD_STATE";function Mt(t,e){return[y,j,g].includes(e.type)?t.revision:t.revision+1}function Rt(t,e){return{...t,revision:Mt(t,e),lastModified:new Date().toISOString()}}function Lt(t,e){if([y,j,g,g].includes(e.type))return t;const i=t.operations.global.slice(0,t.revision),a=t.operations.local.slice();return!e.scope||e.scope==="global"?i.push({...e,index:i.length,timestamp:new Date().toISOString(),hash:"",scope:"global"}):e.scope==="local"&&a.push({...e,index:a.length,timestamp:new Date().toISOString(),hash:"",scope:"local"}),{...t,operations:{global:i,local:a}}}function It(t,e){let i=Lt(t,e);return(!e.scope||e.scope==="global")&&(i=Rt(i,e)),i}function Ut(t,e,i){switch(J().parse(e),e.type){case G:return Nt(t,e.input);case y:return Tt(t,e.input,i);case j:return Ft(t,e.input,i);case g:return qt(t,e.input.start,e.input.end,i);case Q:return Pt(t,e.input.state);default:return t}}function V(t,e,i,a){let o=t;return _(e)&&(o=Ut(o,e,i)),o=It(o,e),o=x.produce(o,s=>{const l=i(s.state,e,a);if(l)return x.castDraft({...o,state:l})}),x.produce(o,s=>{!e.scope||e.scope==="global"?s.operations.global[s.operations.global.length-1].hash=O(s,"global"):e.scope==="local"&&(s.operations.local[s.operations.local.length-1].hash=O(s,"local")),!_(e)&&e.attachments&&e.attachments.forEach(l=>{const{hash:p,...c}=l;s.attachments[p]={...c}})})}function _(t){return[G,y,j,g,Q].includes(t.type)}function u(t,e,i,a,o="global"){if(!t)throw new Error("Empty action type");if(typeof t!="string")throw new Error(`Invalid action type: ${t}`);const s={type:t,input:e,scope:o};return i&&(s.attachments=i),a==null||a().parse(s),s}function X(t,e=V){return(i,a,o)=>e(i,a,t,o)}const Y=(t,e)=>({name:"",documentType:"",revision:0,created:new Date().toISOString(),lastModified:new Date().toISOString(),attachments:{},...t,state:(e==null?void 0:e(t==null?void 0:t.state))??(t==null?void 0:t.state)??{global:{},local:{}}}),tt=(t,e)=>{const i=Y(t,e);return{...i,initialState:i,operations:{global:[],local:[]}}},O=(t,e="global")=>v(pt(e==="local"?t.state.local:t.state.global)),Jt=(t,e=1e3)=>{const i=Math.random()*e;return v(`${(t??new Date).toISOString()}${i}`)};function d(t){return x.castImmutable(x.freeze(t,!0))}const et=t=>u("SET_NAME",t,void 0,A),it=(t=1)=>u("UNDO",t,void 0,N),at=(t=1)=>u("REDO",t,void 0,E),ot=(t,e)=>u("PRUNE",{start:t,end:e},void 0,k),F=(t,e)=>u("LOAD_STATE",{state:t,operations:e},void 0,D),Bt=Object.freeze(Object.defineProperty({__proto__:null,loadState:F,prune:ot,redo:at,setName:et,undo:it},Symbol.toStringTag,{value:"Module"}));class Ct{constructor(e,i,a){f(this,"_document");f(this,"_reducer");f(this,"_signalDispatch");this._reducer=e,this._document=i,this._signalDispatch=a}dispatch(e){return this._document=this._reducer(this._document,e,this._signalDispatch),this}saveToFile(e,i,a){return H(this._document,e,i,a)}async loadFromFile(e){this._document=await S(e,this._reducer)}static async stateFromFile(e,i){return await S(e,i)}get state(){return d(this._document.state)}get operations(){return d(this._document.operations)}get name(){return this._document.name}get documentType(){return this._document.documentType}get created(){return this._document.created}get lastModified(){return this._document.lastModified}get revision(){return this._document.revision}get initialState(){return d(this._document.initialState)}toDocument(){return d(this._document)}getAttachment(e){return this._document.attachments[e]}setName(e){return this.dispatch(et(e)),this}undo(e){return this.dispatch(it(e)),this}redo(e){return this.dispatch(at(e)),this}prune(e,i){return this.dispatch(ot(e,i)),this}loadState(e,i){return this.dispatch(F(e,i)),this}}function $t(t,e){e.forEach(i=>{Object.getOwnPropertyNames(i.prototype).forEach(a=>{Object.defineProperty(t.prototype,a,Object.getOwnPropertyDescriptor(i.prototype,a)||Object.create(null))})})}exports.BaseActions=Bt;exports.BaseDocument=Ct;exports.applyMixins=$t;exports.baseReducer=V;exports.createAction=u;exports.createDocument=tt;exports.createExtendedState=Y;exports.createReducer=X;exports.createZip=T;exports.getLocalFile=At;exports.getRemoteFile=Et;exports.hashDocument=O;exports.hashKey=Jt;exports.isBaseAction=_;exports.loadFromFile=S;exports.loadFromInput=K;exports.readOnly=d;exports.saveToFile=H;exports.saveToFileHandle=Dt;exports.zod=ht;
|