@aseity/idocs-preview 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aseity/idocs-preview",
3
- "version": "0.2.0",
4
- "description": "Read-only browser preview for DOCX and iDocs source documents: Browser font measurements with layout in a Web Worker (WASM) and drawing in a Canvas page view.",
3
+ "version": "0.4.0",
4
+ "description": "Browser preview and editor for iDocs source documents, with DOCX preview and export, Web Worker layout, and Canvas rendering.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "exports": {
@@ -1,6 +1,25 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
 
4
+ export class WasmEditorSession {
5
+ free(): void;
6
+ [Symbol.dispose](): void;
7
+ apply(base: string, edit_json: string, assets: Map<any, any>, measure: Function): any;
8
+ dispose(): void;
9
+ exportDocx(assets: Map<any, any>, measure: Function): any;
10
+ markSaved(revision: string): any;
11
+ constructor();
12
+ open(source: string, file_name: string, assets: Map<any, any>, measure: Function): any;
13
+ range(base: string, start_json: string, end_json: string): any;
14
+ redo(base: string, assets: Map<any, any>, measure: Function): any;
15
+ refresh(base: string, source: string, assets: Map<any, any>, measure: Function): any;
16
+ render(assets: Map<any, any>, measure: Function): any;
17
+ snapshot(): any;
18
+ undo(base: string, assets: Map<any, any>, measure: Function): any;
19
+ }
20
+
21
+ export function exportDocx(bytes: Uint8Array, file_name: string, assets: Map<any, any>, measure: Function): any;
22
+
4
23
  /**
5
24
  * Returns `{status: "needs" | "ready" | "failed", json, data?, images}`; see
6
25
  * `web/src/core/protocol.ts` for the JSON shapes. `measure(family,
@@ -13,7 +32,21 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
13
32
 
14
33
  export interface InitOutput {
15
34
  readonly memory: WebAssembly.Memory;
35
+ readonly __wbg_wasmeditorsession_free: (a: number, b: number) => void;
36
+ readonly exportDocx: (a: number, b: number, c: number, d: number, e: any, f: any) => any;
16
37
  readonly openDocument: (a: number, b: number, c: number, d: number, e: number, f: number, g: any, h: any, i: number) => any;
38
+ readonly wasmeditorsession_apply: (a: number, b: number, c: number, d: number, e: number, f: any, g: any) => any;
39
+ readonly wasmeditorsession_dispose: (a: number) => void;
40
+ readonly wasmeditorsession_exportDocx: (a: number, b: any, c: any) => any;
41
+ readonly wasmeditorsession_markSaved: (a: number, b: number, c: number) => any;
42
+ readonly wasmeditorsession_new: () => number;
43
+ readonly wasmeditorsession_open: (a: number, b: number, c: number, d: number, e: number, f: any, g: any) => any;
44
+ readonly wasmeditorsession_range: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
45
+ readonly wasmeditorsession_redo: (a: number, b: number, c: number, d: any, e: any) => any;
46
+ readonly wasmeditorsession_refresh: (a: number, b: number, c: number, d: number, e: number, f: any, g: any) => any;
47
+ readonly wasmeditorsession_render: (a: number, b: any, c: any) => any;
48
+ readonly wasmeditorsession_snapshot: (a: number) => any;
49
+ readonly wasmeditorsession_undo: (a: number, b: number, c: number, d: any, e: any) => any;
17
50
  readonly __wbindgen_malloc: (a: number, b: number) => number;
18
51
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
19
52
  readonly __wbindgen_exn_store: (a: number) => void;
@@ -1,5 +1,164 @@
1
1
  /* @ts-self-types="./idocs_wasm.d.ts" */
2
2
 
3
+ export class WasmEditorSession {
4
+ __destroy_into_raw() {
5
+ const ptr = this.__wbg_ptr;
6
+ this.__wbg_ptr = 0;
7
+ WasmEditorSessionFinalization.unregister(this);
8
+ return ptr;
9
+ }
10
+ free() {
11
+ const ptr = this.__destroy_into_raw();
12
+ wasm.__wbg_wasmeditorsession_free(ptr, 0);
13
+ }
14
+ /**
15
+ * @param {string} base
16
+ * @param {string} edit_json
17
+ * @param {Map<any, any>} assets
18
+ * @param {Function} measure
19
+ * @returns {any}
20
+ */
21
+ apply(base, edit_json, assets, measure) {
22
+ const ptr0 = passStringToWasm0(base, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
23
+ const len0 = WASM_VECTOR_LEN;
24
+ const ptr1 = passStringToWasm0(edit_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
25
+ const len1 = WASM_VECTOR_LEN;
26
+ const ret = wasm.wasmeditorsession_apply(this.__wbg_ptr, ptr0, len0, ptr1, len1, assets, measure);
27
+ return ret;
28
+ }
29
+ dispose() {
30
+ wasm.wasmeditorsession_dispose(this.__wbg_ptr);
31
+ }
32
+ /**
33
+ * @param {Map<any, any>} assets
34
+ * @param {Function} measure
35
+ * @returns {any}
36
+ */
37
+ exportDocx(assets, measure) {
38
+ const ret = wasm.wasmeditorsession_exportDocx(this.__wbg_ptr, assets, measure);
39
+ return ret;
40
+ }
41
+ /**
42
+ * @param {string} revision
43
+ * @returns {any}
44
+ */
45
+ markSaved(revision) {
46
+ const ptr0 = passStringToWasm0(revision, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
47
+ const len0 = WASM_VECTOR_LEN;
48
+ const ret = wasm.wasmeditorsession_markSaved(this.__wbg_ptr, ptr0, len0);
49
+ return ret;
50
+ }
51
+ constructor() {
52
+ const ret = wasm.wasmeditorsession_new();
53
+ this.__wbg_ptr = ret;
54
+ WasmEditorSessionFinalization.register(this, this.__wbg_ptr, this);
55
+ return this;
56
+ }
57
+ /**
58
+ * @param {string} source
59
+ * @param {string} file_name
60
+ * @param {Map<any, any>} assets
61
+ * @param {Function} measure
62
+ * @returns {any}
63
+ */
64
+ open(source, file_name, assets, measure) {
65
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
66
+ const len0 = WASM_VECTOR_LEN;
67
+ const ptr1 = passStringToWasm0(file_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
68
+ const len1 = WASM_VECTOR_LEN;
69
+ const ret = wasm.wasmeditorsession_open(this.__wbg_ptr, ptr0, len0, ptr1, len1, assets, measure);
70
+ return ret;
71
+ }
72
+ /**
73
+ * @param {string} base
74
+ * @param {string} start_json
75
+ * @param {string} end_json
76
+ * @returns {any}
77
+ */
78
+ range(base, start_json, end_json) {
79
+ const ptr0 = passStringToWasm0(base, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
80
+ const len0 = WASM_VECTOR_LEN;
81
+ const ptr1 = passStringToWasm0(start_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
82
+ const len1 = WASM_VECTOR_LEN;
83
+ const ptr2 = passStringToWasm0(end_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
84
+ const len2 = WASM_VECTOR_LEN;
85
+ const ret = wasm.wasmeditorsession_range(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
86
+ return ret;
87
+ }
88
+ /**
89
+ * @param {string} base
90
+ * @param {Map<any, any>} assets
91
+ * @param {Function} measure
92
+ * @returns {any}
93
+ */
94
+ redo(base, assets, measure) {
95
+ const ptr0 = passStringToWasm0(base, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
96
+ const len0 = WASM_VECTOR_LEN;
97
+ const ret = wasm.wasmeditorsession_redo(this.__wbg_ptr, ptr0, len0, assets, measure);
98
+ return ret;
99
+ }
100
+ /**
101
+ * @param {string} base
102
+ * @param {string} source
103
+ * @param {Map<any, any>} assets
104
+ * @param {Function} measure
105
+ * @returns {any}
106
+ */
107
+ refresh(base, source, assets, measure) {
108
+ const ptr0 = passStringToWasm0(base, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
109
+ const len0 = WASM_VECTOR_LEN;
110
+ const ptr1 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
111
+ const len1 = WASM_VECTOR_LEN;
112
+ const ret = wasm.wasmeditorsession_refresh(this.__wbg_ptr, ptr0, len0, ptr1, len1, assets, measure);
113
+ return ret;
114
+ }
115
+ /**
116
+ * @param {Map<any, any>} assets
117
+ * @param {Function} measure
118
+ * @returns {any}
119
+ */
120
+ render(assets, measure) {
121
+ const ret = wasm.wasmeditorsession_render(this.__wbg_ptr, assets, measure);
122
+ return ret;
123
+ }
124
+ /**
125
+ * @returns {any}
126
+ */
127
+ snapshot() {
128
+ const ret = wasm.wasmeditorsession_snapshot(this.__wbg_ptr);
129
+ return ret;
130
+ }
131
+ /**
132
+ * @param {string} base
133
+ * @param {Map<any, any>} assets
134
+ * @param {Function} measure
135
+ * @returns {any}
136
+ */
137
+ undo(base, assets, measure) {
138
+ const ptr0 = passStringToWasm0(base, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
139
+ const len0 = WASM_VECTOR_LEN;
140
+ const ret = wasm.wasmeditorsession_undo(this.__wbg_ptr, ptr0, len0, assets, measure);
141
+ return ret;
142
+ }
143
+ }
144
+ if (Symbol.dispose) WasmEditorSession.prototype[Symbol.dispose] = WasmEditorSession.prototype.free;
145
+
146
+ /**
147
+ * @param {Uint8Array} bytes
148
+ * @param {string} file_name
149
+ * @param {Map<any, any>} assets
150
+ * @param {Function} measure
151
+ * @returns {any}
152
+ */
153
+ export function exportDocx(bytes, file_name, assets, measure) {
154
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
155
+ const len0 = WASM_VECTOR_LEN;
156
+ const ptr1 = passStringToWasm0(file_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
157
+ const len1 = WASM_VECTOR_LEN;
158
+ const ret = wasm.exportDocx(ptr0, len0, ptr1, len1, assets, measure);
159
+ return ret;
160
+ }
161
+
3
162
  /**
4
163
  * Returns `{status: "needs" | "ready" | "failed", json, data?, images}`; see
5
164
  * `web/src/core/protocol.ts` for the JSON shapes. `measure(family,
@@ -124,6 +283,10 @@ function __wbg_get_imports() {
124
283
  };
125
284
  }
126
285
 
286
+ const WasmEditorSessionFinalization = (typeof FinalizationRegistry === 'undefined')
287
+ ? { register: () => {}, unregister: () => {} }
288
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmeditorsession_free(ptr, 1));
289
+
127
290
  function addToExternrefTable0(obj) {
128
291
  const idx = wasm.__externref_table_alloc();
129
292
  wasm.__wbindgen_externrefs.set(idx, obj);
Binary file
@@ -1,7 +1,21 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
+ export const __wbg_wasmeditorsession_free: (a: number, b: number) => void;
5
+ export const exportDocx: (a: number, b: number, c: number, d: number, e: any, f: any) => any;
4
6
  export const openDocument: (a: number, b: number, c: number, d: number, e: number, f: number, g: any, h: any, i: number) => any;
7
+ export const wasmeditorsession_apply: (a: number, b: number, c: number, d: number, e: number, f: any, g: any) => any;
8
+ export const wasmeditorsession_dispose: (a: number) => void;
9
+ export const wasmeditorsession_exportDocx: (a: number, b: any, c: any) => any;
10
+ export const wasmeditorsession_markSaved: (a: number, b: number, c: number) => any;
11
+ export const wasmeditorsession_new: () => number;
12
+ export const wasmeditorsession_open: (a: number, b: number, c: number, d: number, e: number, f: any, g: any) => any;
13
+ export const wasmeditorsession_range: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
14
+ export const wasmeditorsession_redo: (a: number, b: number, c: number, d: any, e: any) => any;
15
+ export const wasmeditorsession_refresh: (a: number, b: number, c: number, d: number, e: number, f: any, g: any) => any;
16
+ export const wasmeditorsession_render: (a: number, b: any, c: any) => any;
17
+ export const wasmeditorsession_snapshot: (a: number) => any;
18
+ export const wasmeditorsession_undo: (a: number, b: number, c: number, d: any, e: any) => any;
5
19
  export const __wbindgen_malloc: (a: number, b: number) => number;
6
20
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
7
21
  export const __wbindgen_exn_store: (a: number) => void;