ducjs 3.0.0 → 3.0.4
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/README.md +2 -3
- package/dist/ducjs_wasm.d.ts +125 -0
- package/dist/ducjs_wasm.js +797 -0
- package/dist/ducjs_wasm_bg.wasm +0 -0
- package/dist/ducjs_wasm_bg.wasm.d.ts +32 -0
- package/dist/lazy-files.js +7 -1
- package/dist/restore/restoreDataState.js +9 -1
- package/dist/technical/scopes.d.ts +1 -1
- package/dist/technical/scopes.js +28 -13
- package/dist/wasm.d.ts +1 -1
- package/dist/wasm.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# ducjs
|
|
2
|
+
|
|
1
3
|
<p align="center">
|
|
2
4
|
<br/>
|
|
3
5
|
<a href="https://duc.ducflair.com" target="_blank"><img width="256px" src="https://raw.githubusercontent.com/ducflair/assets/refs/heads/main/src/duc/duc-extended.png" /></a>
|
|
@@ -10,9 +12,6 @@
|
|
|
10
12
|
</p>
|
|
11
13
|
</p>
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
# ducjs
|
|
15
|
-
|
|
16
15
|
The `ducjs` package offers comprehensive TypeScript types and helper functions to work effortlessly with the `duc` CAD file format. Built with SQLite and optimized for performance, this package enables you to parse, validate, and manipulate `duc` files with ease.
|
|
17
16
|
|
|
18
17
|
## Documentation
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Parse a `.duc` file (Uint8Array) into a JS object (ExportedDataState).
|
|
5
|
+
*/
|
|
6
|
+
export function parseDuc(buf: Uint8Array): any;
|
|
7
|
+
/**
|
|
8
|
+
* Read the full VersionGraph from a `.duc` file buffer.
|
|
9
|
+
*
|
|
10
|
+
* Returns a JS object matching the `VersionGraph` TypeScript interface,
|
|
11
|
+
* or `undefined` if no version graph exists.
|
|
12
|
+
*/
|
|
13
|
+
export function readVersionGraph(duc_buf: Uint8Array): any;
|
|
14
|
+
/**
|
|
15
|
+
* Fetch a single external file from a `.duc` buffer by file ID.
|
|
16
|
+
*
|
|
17
|
+
* Returns the file entry as a JS object, or `undefined` if not found.
|
|
18
|
+
*/
|
|
19
|
+
export function getExternalFile(buf: Uint8Array, file_id: string): any;
|
|
20
|
+
/**
|
|
21
|
+
* Revert the document to a specific version, removing all newer versions.
|
|
22
|
+
*
|
|
23
|
+
* Returns a JS object `{ versionNumber, schemaVersion, data, fromCheckpoint }`.
|
|
24
|
+
*/
|
|
25
|
+
export function revertToVersion(duc_buf: Uint8Array, target_version: number): any;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the current version-control schema version defined in Rust.
|
|
28
|
+
*
|
|
29
|
+
* TypeScript should use this as the source of truth instead of hardcoding
|
|
30
|
+
* its own constant. When this value is bumped in Rust, the version control
|
|
31
|
+
* system will automatically handle migration bookkeeping (closing old chains,
|
|
32
|
+
* recording migrations) the next time a checkpoint or delta is created.
|
|
33
|
+
*/
|
|
34
|
+
export function getCurrentSchemaVersion(): number;
|
|
35
|
+
/**
|
|
36
|
+
* List all versions (checkpoints + deltas) from a `.duc` file buffer.
|
|
37
|
+
*
|
|
38
|
+
* Returns a JS array of `VersionEntry` objects (no heavy data blobs).
|
|
39
|
+
*/
|
|
40
|
+
export function listVersions(duc_buf: Uint8Array): any;
|
|
41
|
+
/**
|
|
42
|
+
* Restore the document state at `version_number` from a `.duc` file buffer.
|
|
43
|
+
*
|
|
44
|
+
* The `.duc` file is a SQLite database — this function opens it and queries
|
|
45
|
+
* the `checkpoints` / `deltas` tables directly for version restoration.
|
|
46
|
+
*
|
|
47
|
+
* Returns a JS object `{ versionNumber, schemaVersion, data, fromCheckpoint }`.
|
|
48
|
+
*/
|
|
49
|
+
export function restoreVersion(duc_buf: Uint8Array, version_number: number): any;
|
|
50
|
+
/**
|
|
51
|
+
* Serialize a JS object (ExportedDataState) into `.duc` bytes (Uint8Array).
|
|
52
|
+
*/
|
|
53
|
+
export function serializeDuc(data: any): Uint8Array;
|
|
54
|
+
/**
|
|
55
|
+
* Restore a specific checkpoint by its ID from a `.duc` file buffer.
|
|
56
|
+
*
|
|
57
|
+
* Returns a JS object `{ versionNumber, schemaVersion, data, fromCheckpoint }`.
|
|
58
|
+
*/
|
|
59
|
+
export function restoreCheckpoint(duc_buf: Uint8Array, checkpoint_id: string): any;
|
|
60
|
+
/**
|
|
61
|
+
* Parse a `.duc` file lazily — returns everything EXCEPT external file data blobs.
|
|
62
|
+
*
|
|
63
|
+
* Use `getExternalFile()` or `listExternalFiles()` for on-demand access.
|
|
64
|
+
*/
|
|
65
|
+
export function parseDucLazy(buf: Uint8Array): any;
|
|
66
|
+
/**
|
|
67
|
+
* List metadata for all external files (without loading the heavy data blobs).
|
|
68
|
+
*/
|
|
69
|
+
export function listExternalFiles(buf: Uint8Array): any;
|
|
70
|
+
|
|
71
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
72
|
+
|
|
73
|
+
export interface InitOutput {
|
|
74
|
+
readonly memory: WebAssembly.Memory;
|
|
75
|
+
readonly getCurrentSchemaVersion: () => number;
|
|
76
|
+
readonly getExternalFile: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
77
|
+
readonly listExternalFiles: (a: number, b: number) => [number, number, number];
|
|
78
|
+
readonly listVersions: (a: number, b: number) => [number, number, number];
|
|
79
|
+
readonly parseDuc: (a: number, b: number) => [number, number, number];
|
|
80
|
+
readonly parseDucLazy: (a: number, b: number) => [number, number, number];
|
|
81
|
+
readonly readVersionGraph: (a: number, b: number) => [number, number, number];
|
|
82
|
+
readonly restoreCheckpoint: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
83
|
+
readonly restoreVersion: (a: number, b: number, c: number) => [number, number, number];
|
|
84
|
+
readonly revertToVersion: (a: number, b: number, c: number) => [number, number, number];
|
|
85
|
+
readonly serializeDuc: (a: any) => [number, number, number, number];
|
|
86
|
+
readonly rust_sqlite_wasm_abort: () => void;
|
|
87
|
+
readonly rust_sqlite_wasm_assert_fail: (a: number, b: number, c: number, d: number) => void;
|
|
88
|
+
readonly rust_sqlite_wasm_calloc: (a: number, b: number) => number;
|
|
89
|
+
readonly rust_sqlite_wasm_malloc: (a: number) => number;
|
|
90
|
+
readonly rust_sqlite_wasm_free: (a: number) => void;
|
|
91
|
+
readonly rust_sqlite_wasm_getentropy: (a: number, b: number) => number;
|
|
92
|
+
readonly rust_sqlite_wasm_localtime: (a: number) => number;
|
|
93
|
+
readonly rust_sqlite_wasm_realloc: (a: number, b: number) => number;
|
|
94
|
+
readonly sqlite3_os_end: () => number;
|
|
95
|
+
readonly sqlite3_os_init: () => number;
|
|
96
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
97
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
98
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
99
|
+
readonly __externref_table_alloc: () => number;
|
|
100
|
+
readonly __wbindgen_export_4: WebAssembly.Table;
|
|
101
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
102
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
103
|
+
readonly __wbindgen_start: () => void;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
107
|
+
/**
|
|
108
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
109
|
+
* a precompiled `WebAssembly.Module`.
|
|
110
|
+
*
|
|
111
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
112
|
+
*
|
|
113
|
+
* @returns {InitOutput}
|
|
114
|
+
*/
|
|
115
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
119
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
120
|
+
*
|
|
121
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
122
|
+
*
|
|
123
|
+
* @returns {Promise<InitOutput>}
|
|
124
|
+
*/
|
|
125
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
@@ -0,0 +1,797 @@
|
|
|
1
|
+
let wasm;
|
|
2
|
+
|
|
3
|
+
let cachedUint8ArrayMemory0 = null;
|
|
4
|
+
|
|
5
|
+
function getUint8ArrayMemory0() {
|
|
6
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
7
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
8
|
+
}
|
|
9
|
+
return cachedUint8ArrayMemory0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
13
|
+
|
|
14
|
+
cachedTextDecoder.decode();
|
|
15
|
+
|
|
16
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
17
|
+
let numBytesDecoded = 0;
|
|
18
|
+
function decodeText(ptr, len) {
|
|
19
|
+
numBytesDecoded += len;
|
|
20
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
21
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
22
|
+
cachedTextDecoder.decode();
|
|
23
|
+
numBytesDecoded = len;
|
|
24
|
+
}
|
|
25
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function getStringFromWasm0(ptr, len) {
|
|
29
|
+
ptr = ptr >>> 0;
|
|
30
|
+
return decodeText(ptr, len);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let WASM_VECTOR_LEN = 0;
|
|
34
|
+
|
|
35
|
+
const cachedTextEncoder = new TextEncoder();
|
|
36
|
+
|
|
37
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
38
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
39
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
40
|
+
view.set(buf);
|
|
41
|
+
return {
|
|
42
|
+
read: arg.length,
|
|
43
|
+
written: buf.length
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
49
|
+
|
|
50
|
+
if (realloc === undefined) {
|
|
51
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
52
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
53
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
54
|
+
WASM_VECTOR_LEN = buf.length;
|
|
55
|
+
return ptr;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let len = arg.length;
|
|
59
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
60
|
+
|
|
61
|
+
const mem = getUint8ArrayMemory0();
|
|
62
|
+
|
|
63
|
+
let offset = 0;
|
|
64
|
+
|
|
65
|
+
for (; offset < len; offset++) {
|
|
66
|
+
const code = arg.charCodeAt(offset);
|
|
67
|
+
if (code > 0x7F) break;
|
|
68
|
+
mem[ptr + offset] = code;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (offset !== len) {
|
|
72
|
+
if (offset !== 0) {
|
|
73
|
+
arg = arg.slice(offset);
|
|
74
|
+
}
|
|
75
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
76
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
77
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
78
|
+
|
|
79
|
+
offset += ret.written;
|
|
80
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
WASM_VECTOR_LEN = offset;
|
|
84
|
+
return ptr;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
let cachedDataViewMemory0 = null;
|
|
88
|
+
|
|
89
|
+
function getDataViewMemory0() {
|
|
90
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
91
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
92
|
+
}
|
|
93
|
+
return cachedDataViewMemory0;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function addToExternrefTable0(obj) {
|
|
97
|
+
const idx = wasm.__externref_table_alloc();
|
|
98
|
+
wasm.__wbindgen_export_4.set(idx, obj);
|
|
99
|
+
return idx;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function handleError(f, args) {
|
|
103
|
+
try {
|
|
104
|
+
return f.apply(this, args);
|
|
105
|
+
} catch (e) {
|
|
106
|
+
const idx = addToExternrefTable0(e);
|
|
107
|
+
wasm.__wbindgen_exn_store(idx);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
112
|
+
ptr = ptr >>> 0;
|
|
113
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function isLikeNone(x) {
|
|
117
|
+
return x === undefined || x === null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function debugString(val) {
|
|
121
|
+
// primitive types
|
|
122
|
+
const type = typeof val;
|
|
123
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
124
|
+
return `${val}`;
|
|
125
|
+
}
|
|
126
|
+
if (type == 'string') {
|
|
127
|
+
return `"${val}"`;
|
|
128
|
+
}
|
|
129
|
+
if (type == 'symbol') {
|
|
130
|
+
const description = val.description;
|
|
131
|
+
if (description == null) {
|
|
132
|
+
return 'Symbol';
|
|
133
|
+
} else {
|
|
134
|
+
return `Symbol(${description})`;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (type == 'function') {
|
|
138
|
+
const name = val.name;
|
|
139
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
140
|
+
return `Function(${name})`;
|
|
141
|
+
} else {
|
|
142
|
+
return 'Function';
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// objects
|
|
146
|
+
if (Array.isArray(val)) {
|
|
147
|
+
const length = val.length;
|
|
148
|
+
let debug = '[';
|
|
149
|
+
if (length > 0) {
|
|
150
|
+
debug += debugString(val[0]);
|
|
151
|
+
}
|
|
152
|
+
for(let i = 1; i < length; i++) {
|
|
153
|
+
debug += ', ' + debugString(val[i]);
|
|
154
|
+
}
|
|
155
|
+
debug += ']';
|
|
156
|
+
return debug;
|
|
157
|
+
}
|
|
158
|
+
// Test for built-in
|
|
159
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
160
|
+
let className;
|
|
161
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
162
|
+
className = builtInMatches[1];
|
|
163
|
+
} else {
|
|
164
|
+
// Failed to match the standard '[object ClassName]'
|
|
165
|
+
return toString.call(val);
|
|
166
|
+
}
|
|
167
|
+
if (className == 'Object') {
|
|
168
|
+
// we're a user defined class or Object
|
|
169
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
170
|
+
// easier than looping through ownProperties of `val`.
|
|
171
|
+
try {
|
|
172
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
173
|
+
} catch (_) {
|
|
174
|
+
return 'Object';
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
// errors
|
|
178
|
+
if (val instanceof Error) {
|
|
179
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
180
|
+
}
|
|
181
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
182
|
+
return className;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
186
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
187
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
188
|
+
WASM_VECTOR_LEN = arg.length;
|
|
189
|
+
return ptr;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function takeFromExternrefTable0(idx) {
|
|
193
|
+
const value = wasm.__wbindgen_export_4.get(idx);
|
|
194
|
+
wasm.__externref_table_dealloc(idx);
|
|
195
|
+
return value;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Parse a `.duc` file (Uint8Array) into a JS object (ExportedDataState).
|
|
199
|
+
* @param {Uint8Array} buf
|
|
200
|
+
* @returns {any}
|
|
201
|
+
*/
|
|
202
|
+
export function parseDuc(buf) {
|
|
203
|
+
const ptr0 = passArray8ToWasm0(buf, wasm.__wbindgen_malloc);
|
|
204
|
+
const len0 = WASM_VECTOR_LEN;
|
|
205
|
+
const ret = wasm.parseDuc(ptr0, len0);
|
|
206
|
+
if (ret[2]) {
|
|
207
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
208
|
+
}
|
|
209
|
+
return takeFromExternrefTable0(ret[0]);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Read the full VersionGraph from a `.duc` file buffer.
|
|
214
|
+
*
|
|
215
|
+
* Returns a JS object matching the `VersionGraph` TypeScript interface,
|
|
216
|
+
* or `undefined` if no version graph exists.
|
|
217
|
+
* @param {Uint8Array} duc_buf
|
|
218
|
+
* @returns {any}
|
|
219
|
+
*/
|
|
220
|
+
export function readVersionGraph(duc_buf) {
|
|
221
|
+
const ptr0 = passArray8ToWasm0(duc_buf, wasm.__wbindgen_malloc);
|
|
222
|
+
const len0 = WASM_VECTOR_LEN;
|
|
223
|
+
const ret = wasm.readVersionGraph(ptr0, len0);
|
|
224
|
+
if (ret[2]) {
|
|
225
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
226
|
+
}
|
|
227
|
+
return takeFromExternrefTable0(ret[0]);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Fetch a single external file from a `.duc` buffer by file ID.
|
|
232
|
+
*
|
|
233
|
+
* Returns the file entry as a JS object, or `undefined` if not found.
|
|
234
|
+
* @param {Uint8Array} buf
|
|
235
|
+
* @param {string} file_id
|
|
236
|
+
* @returns {any}
|
|
237
|
+
*/
|
|
238
|
+
export function getExternalFile(buf, file_id) {
|
|
239
|
+
const ptr0 = passArray8ToWasm0(buf, wasm.__wbindgen_malloc);
|
|
240
|
+
const len0 = WASM_VECTOR_LEN;
|
|
241
|
+
const ptr1 = passStringToWasm0(file_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
242
|
+
const len1 = WASM_VECTOR_LEN;
|
|
243
|
+
const ret = wasm.getExternalFile(ptr0, len0, ptr1, len1);
|
|
244
|
+
if (ret[2]) {
|
|
245
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
246
|
+
}
|
|
247
|
+
return takeFromExternrefTable0(ret[0]);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Revert the document to a specific version, removing all newer versions.
|
|
252
|
+
*
|
|
253
|
+
* Returns a JS object `{ versionNumber, schemaVersion, data, fromCheckpoint }`.
|
|
254
|
+
* @param {Uint8Array} duc_buf
|
|
255
|
+
* @param {number} target_version
|
|
256
|
+
* @returns {any}
|
|
257
|
+
*/
|
|
258
|
+
export function revertToVersion(duc_buf, target_version) {
|
|
259
|
+
const ptr0 = passArray8ToWasm0(duc_buf, wasm.__wbindgen_malloc);
|
|
260
|
+
const len0 = WASM_VECTOR_LEN;
|
|
261
|
+
const ret = wasm.revertToVersion(ptr0, len0, target_version);
|
|
262
|
+
if (ret[2]) {
|
|
263
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
264
|
+
}
|
|
265
|
+
return takeFromExternrefTable0(ret[0]);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Returns the current version-control schema version defined in Rust.
|
|
270
|
+
*
|
|
271
|
+
* TypeScript should use this as the source of truth instead of hardcoding
|
|
272
|
+
* its own constant. When this value is bumped in Rust, the version control
|
|
273
|
+
* system will automatically handle migration bookkeeping (closing old chains,
|
|
274
|
+
* recording migrations) the next time a checkpoint or delta is created.
|
|
275
|
+
* @returns {number}
|
|
276
|
+
*/
|
|
277
|
+
export function getCurrentSchemaVersion() {
|
|
278
|
+
return 3000000;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* List all versions (checkpoints + deltas) from a `.duc` file buffer.
|
|
283
|
+
*
|
|
284
|
+
* Returns a JS array of `VersionEntry` objects (no heavy data blobs).
|
|
285
|
+
* @param {Uint8Array} duc_buf
|
|
286
|
+
* @returns {any}
|
|
287
|
+
*/
|
|
288
|
+
export function listVersions(duc_buf) {
|
|
289
|
+
const ptr0 = passArray8ToWasm0(duc_buf, wasm.__wbindgen_malloc);
|
|
290
|
+
const len0 = WASM_VECTOR_LEN;
|
|
291
|
+
const ret = wasm.listVersions(ptr0, len0);
|
|
292
|
+
if (ret[2]) {
|
|
293
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
294
|
+
}
|
|
295
|
+
return takeFromExternrefTable0(ret[0]);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Restore the document state at `version_number` from a `.duc` file buffer.
|
|
300
|
+
*
|
|
301
|
+
* The `.duc` file is a SQLite database — this function opens it and queries
|
|
302
|
+
* the `checkpoints` / `deltas` tables directly for version restoration.
|
|
303
|
+
*
|
|
304
|
+
* Returns a JS object `{ versionNumber, schemaVersion, data, fromCheckpoint }`.
|
|
305
|
+
* @param {Uint8Array} duc_buf
|
|
306
|
+
* @param {number} version_number
|
|
307
|
+
* @returns {any}
|
|
308
|
+
*/
|
|
309
|
+
export function restoreVersion(duc_buf, version_number) {
|
|
310
|
+
const ptr0 = passArray8ToWasm0(duc_buf, wasm.__wbindgen_malloc);
|
|
311
|
+
const len0 = WASM_VECTOR_LEN;
|
|
312
|
+
const ret = wasm.restoreVersion(ptr0, len0, version_number);
|
|
313
|
+
if (ret[2]) {
|
|
314
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
315
|
+
}
|
|
316
|
+
return takeFromExternrefTable0(ret[0]);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Serialize a JS object (ExportedDataState) into `.duc` bytes (Uint8Array).
|
|
321
|
+
* @param {any} data
|
|
322
|
+
* @returns {Uint8Array}
|
|
323
|
+
*/
|
|
324
|
+
export function serializeDuc(data) {
|
|
325
|
+
const ret = wasm.serializeDuc(data);
|
|
326
|
+
if (ret[3]) {
|
|
327
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
328
|
+
}
|
|
329
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
330
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
331
|
+
return v1;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Restore a specific checkpoint by its ID from a `.duc` file buffer.
|
|
336
|
+
*
|
|
337
|
+
* Returns a JS object `{ versionNumber, schemaVersion, data, fromCheckpoint }`.
|
|
338
|
+
* @param {Uint8Array} duc_buf
|
|
339
|
+
* @param {string} checkpoint_id
|
|
340
|
+
* @returns {any}
|
|
341
|
+
*/
|
|
342
|
+
export function restoreCheckpoint(duc_buf, checkpoint_id) {
|
|
343
|
+
const ptr0 = passArray8ToWasm0(duc_buf, wasm.__wbindgen_malloc);
|
|
344
|
+
const len0 = WASM_VECTOR_LEN;
|
|
345
|
+
const ptr1 = passStringToWasm0(checkpoint_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
346
|
+
const len1 = WASM_VECTOR_LEN;
|
|
347
|
+
const ret = wasm.restoreCheckpoint(ptr0, len0, ptr1, len1);
|
|
348
|
+
if (ret[2]) {
|
|
349
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
350
|
+
}
|
|
351
|
+
return takeFromExternrefTable0(ret[0]);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Parse a `.duc` file lazily — returns everything EXCEPT external file data blobs.
|
|
356
|
+
*
|
|
357
|
+
* Use `getExternalFile()` or `listExternalFiles()` for on-demand access.
|
|
358
|
+
* @param {Uint8Array} buf
|
|
359
|
+
* @returns {any}
|
|
360
|
+
*/
|
|
361
|
+
export function parseDucLazy(buf) {
|
|
362
|
+
const ptr0 = passArray8ToWasm0(buf, wasm.__wbindgen_malloc);
|
|
363
|
+
const len0 = WASM_VECTOR_LEN;
|
|
364
|
+
const ret = wasm.parseDucLazy(ptr0, len0);
|
|
365
|
+
if (ret[2]) {
|
|
366
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
367
|
+
}
|
|
368
|
+
return takeFromExternrefTable0(ret[0]);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* List metadata for all external files (without loading the heavy data blobs).
|
|
373
|
+
* @param {Uint8Array} buf
|
|
374
|
+
* @returns {any}
|
|
375
|
+
*/
|
|
376
|
+
export function listExternalFiles(buf) {
|
|
377
|
+
const ptr0 = passArray8ToWasm0(buf, wasm.__wbindgen_malloc);
|
|
378
|
+
const len0 = WASM_VECTOR_LEN;
|
|
379
|
+
const ret = wasm.listExternalFiles(ptr0, len0);
|
|
380
|
+
if (ret[2]) {
|
|
381
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
382
|
+
}
|
|
383
|
+
return takeFromExternrefTable0(ret[0]);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
|
|
387
|
+
|
|
388
|
+
async function __wbg_load(module, imports) {
|
|
389
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
390
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
391
|
+
try {
|
|
392
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
393
|
+
|
|
394
|
+
} catch (e) {
|
|
395
|
+
const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
|
|
396
|
+
|
|
397
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
398
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
399
|
+
|
|
400
|
+
} else {
|
|
401
|
+
throw e;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
const bytes = await module.arrayBuffer();
|
|
407
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
408
|
+
|
|
409
|
+
} else {
|
|
410
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
411
|
+
|
|
412
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
413
|
+
return { instance, module };
|
|
414
|
+
|
|
415
|
+
} else {
|
|
416
|
+
return instance;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
function __wbg_get_imports() {
|
|
422
|
+
const imports = {};
|
|
423
|
+
imports.wbg = {};
|
|
424
|
+
imports.wbg.__wbg_Error_e17e777aac105295 = function(arg0, arg1) {
|
|
425
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
426
|
+
return ret;
|
|
427
|
+
};
|
|
428
|
+
imports.wbg.__wbg_Number_998bea33bd87c3e0 = function(arg0) {
|
|
429
|
+
const ret = Number(arg0);
|
|
430
|
+
return ret;
|
|
431
|
+
};
|
|
432
|
+
imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
|
|
433
|
+
const ret = String(arg1);
|
|
434
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
435
|
+
const len1 = WASM_VECTOR_LEN;
|
|
436
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
437
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
438
|
+
};
|
|
439
|
+
imports.wbg.__wbg_call_13410aac570ffff7 = function() { return handleError(function (arg0, arg1) {
|
|
440
|
+
const ret = arg0.call(arg1);
|
|
441
|
+
return ret;
|
|
442
|
+
}, arguments) };
|
|
443
|
+
imports.wbg.__wbg_done_75ed0ee6dd243d9d = function(arg0) {
|
|
444
|
+
const ret = arg0.done;
|
|
445
|
+
return ret;
|
|
446
|
+
};
|
|
447
|
+
imports.wbg.__wbg_entries_2be2f15bd5554996 = function(arg0) {
|
|
448
|
+
const ret = Object.entries(arg0);
|
|
449
|
+
return ret;
|
|
450
|
+
};
|
|
451
|
+
imports.wbg.__wbg_from_88bc52ce20ba6318 = function(arg0) {
|
|
452
|
+
const ret = Array.from(arg0);
|
|
453
|
+
return ret;
|
|
454
|
+
};
|
|
455
|
+
imports.wbg.__wbg_getDate_9615e288fc892247 = function(arg0) {
|
|
456
|
+
const ret = arg0.getDate();
|
|
457
|
+
return ret;
|
|
458
|
+
};
|
|
459
|
+
imports.wbg.__wbg_getDay_c9c4f57fb4ef6fef = function(arg0) {
|
|
460
|
+
const ret = arg0.getDay();
|
|
461
|
+
return ret;
|
|
462
|
+
};
|
|
463
|
+
imports.wbg.__wbg_getFullYear_e351a9fa7d2fab83 = function(arg0) {
|
|
464
|
+
const ret = arg0.getFullYear();
|
|
465
|
+
return ret;
|
|
466
|
+
};
|
|
467
|
+
imports.wbg.__wbg_getHours_4cc14de357c9e723 = function(arg0) {
|
|
468
|
+
const ret = arg0.getHours();
|
|
469
|
+
return ret;
|
|
470
|
+
};
|
|
471
|
+
imports.wbg.__wbg_getMinutes_6cde8fdd08b0c2ec = function(arg0) {
|
|
472
|
+
const ret = arg0.getMinutes();
|
|
473
|
+
return ret;
|
|
474
|
+
};
|
|
475
|
+
imports.wbg.__wbg_getMonth_8cc234bce5c8bcac = function(arg0) {
|
|
476
|
+
const ret = arg0.getMonth();
|
|
477
|
+
return ret;
|
|
478
|
+
};
|
|
479
|
+
imports.wbg.__wbg_getRandomValues_933a06e2370405af = function() { return handleError(function (arg0, arg1) {
|
|
480
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
481
|
+
}, arguments) };
|
|
482
|
+
imports.wbg.__wbg_getSeconds_c2f02452d804ece0 = function(arg0) {
|
|
483
|
+
const ret = arg0.getSeconds();
|
|
484
|
+
return ret;
|
|
485
|
+
};
|
|
486
|
+
imports.wbg.__wbg_getTime_6bb3f64e0f18f817 = function(arg0) {
|
|
487
|
+
const ret = arg0.getTime();
|
|
488
|
+
return ret;
|
|
489
|
+
};
|
|
490
|
+
imports.wbg.__wbg_getTimezoneOffset_1e3ddc1382e7c8b0 = function(arg0) {
|
|
491
|
+
const ret = arg0.getTimezoneOffset();
|
|
492
|
+
return ret;
|
|
493
|
+
};
|
|
494
|
+
imports.wbg.__wbg_get_0da715ceaecea5c8 = function(arg0, arg1) {
|
|
495
|
+
const ret = arg0[arg1 >>> 0];
|
|
496
|
+
return ret;
|
|
497
|
+
};
|
|
498
|
+
imports.wbg.__wbg_get_458e874b43b18b25 = function() { return handleError(function (arg0, arg1) {
|
|
499
|
+
const ret = Reflect.get(arg0, arg1);
|
|
500
|
+
return ret;
|
|
501
|
+
}, arguments) };
|
|
502
|
+
imports.wbg.__wbg_getwithrefkey_1dc361bd10053bfe = function(arg0, arg1) {
|
|
503
|
+
const ret = arg0[arg1];
|
|
504
|
+
return ret;
|
|
505
|
+
};
|
|
506
|
+
imports.wbg.__wbg_instanceof_ArrayBuffer_67f3012529f6a2dd = function(arg0) {
|
|
507
|
+
let result;
|
|
508
|
+
try {
|
|
509
|
+
result = arg0 instanceof ArrayBuffer;
|
|
510
|
+
} catch (_) {
|
|
511
|
+
result = false;
|
|
512
|
+
}
|
|
513
|
+
const ret = result;
|
|
514
|
+
return ret;
|
|
515
|
+
};
|
|
516
|
+
imports.wbg.__wbg_instanceof_Map_ebb01a5b6b5ffd0b = function(arg0) {
|
|
517
|
+
let result;
|
|
518
|
+
try {
|
|
519
|
+
result = arg0 instanceof Map;
|
|
520
|
+
} catch (_) {
|
|
521
|
+
result = false;
|
|
522
|
+
}
|
|
523
|
+
const ret = result;
|
|
524
|
+
return ret;
|
|
525
|
+
};
|
|
526
|
+
imports.wbg.__wbg_instanceof_Uint8Array_9a8378d955933db7 = function(arg0) {
|
|
527
|
+
let result;
|
|
528
|
+
try {
|
|
529
|
+
result = arg0 instanceof Uint8Array;
|
|
530
|
+
} catch (_) {
|
|
531
|
+
result = false;
|
|
532
|
+
}
|
|
533
|
+
const ret = result;
|
|
534
|
+
return ret;
|
|
535
|
+
};
|
|
536
|
+
imports.wbg.__wbg_isArray_030cce220591fb41 = function(arg0) {
|
|
537
|
+
const ret = Array.isArray(arg0);
|
|
538
|
+
return ret;
|
|
539
|
+
};
|
|
540
|
+
imports.wbg.__wbg_isSafeInteger_1c0d1af5542e102a = function(arg0) {
|
|
541
|
+
const ret = Number.isSafeInteger(arg0);
|
|
542
|
+
return ret;
|
|
543
|
+
};
|
|
544
|
+
imports.wbg.__wbg_iterator_f370b34483c71a1c = function() {
|
|
545
|
+
const ret = Symbol.iterator;
|
|
546
|
+
return ret;
|
|
547
|
+
};
|
|
548
|
+
imports.wbg.__wbg_length_186546c51cd61acd = function(arg0) {
|
|
549
|
+
const ret = arg0.length;
|
|
550
|
+
return ret;
|
|
551
|
+
};
|
|
552
|
+
imports.wbg.__wbg_length_6bb7e81f9d7713e4 = function(arg0) {
|
|
553
|
+
const ret = arg0.length;
|
|
554
|
+
return ret;
|
|
555
|
+
};
|
|
556
|
+
imports.wbg.__wbg_new0_b0a0a38c201e6df5 = function() {
|
|
557
|
+
const ret = new Date();
|
|
558
|
+
return ret;
|
|
559
|
+
};
|
|
560
|
+
imports.wbg.__wbg_new_19c25a3f2fa63a02 = function() {
|
|
561
|
+
const ret = new Object();
|
|
562
|
+
return ret;
|
|
563
|
+
};
|
|
564
|
+
imports.wbg.__wbg_new_1f3a344cf3123716 = function() {
|
|
565
|
+
const ret = new Array();
|
|
566
|
+
return ret;
|
|
567
|
+
};
|
|
568
|
+
imports.wbg.__wbg_new_2ff1f68f3676ea53 = function() {
|
|
569
|
+
const ret = new Map();
|
|
570
|
+
return ret;
|
|
571
|
+
};
|
|
572
|
+
imports.wbg.__wbg_new_5a2ae4557f92b50e = function(arg0) {
|
|
573
|
+
const ret = new Date(arg0);
|
|
574
|
+
return ret;
|
|
575
|
+
};
|
|
576
|
+
imports.wbg.__wbg_new_638ebfaedbf32a5e = function(arg0) {
|
|
577
|
+
const ret = new Uint8Array(arg0);
|
|
578
|
+
return ret;
|
|
579
|
+
};
|
|
580
|
+
imports.wbg.__wbg_newfromslice_074c56947bd43469 = function(arg0, arg1) {
|
|
581
|
+
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
582
|
+
return ret;
|
|
583
|
+
};
|
|
584
|
+
imports.wbg.__wbg_newwithyearmonthday_9d5466a369f2521d = function(arg0, arg1, arg2) {
|
|
585
|
+
const ret = new Date(arg0 >>> 0, arg1, arg2);
|
|
586
|
+
return ret;
|
|
587
|
+
};
|
|
588
|
+
imports.wbg.__wbg_next_5b3530e612fde77d = function(arg0) {
|
|
589
|
+
const ret = arg0.next;
|
|
590
|
+
return ret;
|
|
591
|
+
};
|
|
592
|
+
imports.wbg.__wbg_next_692e82279131b03c = function() { return handleError(function (arg0) {
|
|
593
|
+
const ret = arg0.next();
|
|
594
|
+
return ret;
|
|
595
|
+
}, arguments) };
|
|
596
|
+
imports.wbg.__wbg_prototypesetcall_3d4a26c1ed734349 = function(arg0, arg1, arg2) {
|
|
597
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
598
|
+
};
|
|
599
|
+
imports.wbg.__wbg_random_7ed63a0b38ee3b75 = function() {
|
|
600
|
+
const ret = Math.random();
|
|
601
|
+
return ret;
|
|
602
|
+
};
|
|
603
|
+
imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
|
|
604
|
+
arg0[arg1] = arg2;
|
|
605
|
+
};
|
|
606
|
+
imports.wbg.__wbg_set_453345bcda80b89a = function() { return handleError(function (arg0, arg1, arg2) {
|
|
607
|
+
const ret = Reflect.set(arg0, arg1, arg2);
|
|
608
|
+
return ret;
|
|
609
|
+
}, arguments) };
|
|
610
|
+
imports.wbg.__wbg_set_90f6c0f7bd8c0415 = function(arg0, arg1, arg2) {
|
|
611
|
+
arg0[arg1 >>> 0] = arg2;
|
|
612
|
+
};
|
|
613
|
+
imports.wbg.__wbg_set_b7f1cf4fae26fe2a = function(arg0, arg1, arg2) {
|
|
614
|
+
const ret = arg0.set(arg1, arg2);
|
|
615
|
+
return ret;
|
|
616
|
+
};
|
|
617
|
+
imports.wbg.__wbg_value_dd9372230531eade = function(arg0) {
|
|
618
|
+
const ret = arg0.value;
|
|
619
|
+
return ret;
|
|
620
|
+
};
|
|
621
|
+
imports.wbg.__wbg_wbindgenbigintgetasi64_ac743ece6ab9bba1 = function(arg0, arg1) {
|
|
622
|
+
const v = arg1;
|
|
623
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
624
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
625
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
626
|
+
};
|
|
627
|
+
imports.wbg.__wbg_wbindgenbooleanget_3fe6f642c7d97746 = function(arg0) {
|
|
628
|
+
const v = arg0;
|
|
629
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
630
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
631
|
+
};
|
|
632
|
+
imports.wbg.__wbg_wbindgendebugstring_99ef257a3ddda34d = function(arg0, arg1) {
|
|
633
|
+
const ret = debugString(arg1);
|
|
634
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
635
|
+
const len1 = WASM_VECTOR_LEN;
|
|
636
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
637
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
638
|
+
};
|
|
639
|
+
imports.wbg.__wbg_wbindgenin_d7a1ee10933d2d55 = function(arg0, arg1) {
|
|
640
|
+
const ret = arg0 in arg1;
|
|
641
|
+
return ret;
|
|
642
|
+
};
|
|
643
|
+
imports.wbg.__wbg_wbindgenisbigint_ecb90cc08a5a9154 = function(arg0) {
|
|
644
|
+
const ret = typeof(arg0) === 'bigint';
|
|
645
|
+
return ret;
|
|
646
|
+
};
|
|
647
|
+
imports.wbg.__wbg_wbindgenisfunction_8cee7dce3725ae74 = function(arg0) {
|
|
648
|
+
const ret = typeof(arg0) === 'function';
|
|
649
|
+
return ret;
|
|
650
|
+
};
|
|
651
|
+
imports.wbg.__wbg_wbindgenisobject_307a53c6bd97fbf8 = function(arg0) {
|
|
652
|
+
const val = arg0;
|
|
653
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
654
|
+
return ret;
|
|
655
|
+
};
|
|
656
|
+
imports.wbg.__wbg_wbindgenisstring_d4fa939789f003b0 = function(arg0) {
|
|
657
|
+
const ret = typeof(arg0) === 'string';
|
|
658
|
+
return ret;
|
|
659
|
+
};
|
|
660
|
+
imports.wbg.__wbg_wbindgenisundefined_c4b71d073b92f3c5 = function(arg0) {
|
|
661
|
+
const ret = arg0 === undefined;
|
|
662
|
+
return ret;
|
|
663
|
+
};
|
|
664
|
+
imports.wbg.__wbg_wbindgenjsvaleq_e6f2ad59ccae1b58 = function(arg0, arg1) {
|
|
665
|
+
const ret = arg0 === arg1;
|
|
666
|
+
return ret;
|
|
667
|
+
};
|
|
668
|
+
imports.wbg.__wbg_wbindgenjsvallooseeq_9bec8c9be826bed1 = function(arg0, arg1) {
|
|
669
|
+
const ret = arg0 == arg1;
|
|
670
|
+
return ret;
|
|
671
|
+
};
|
|
672
|
+
imports.wbg.__wbg_wbindgennumberget_f74b4c7525ac05cb = function(arg0, arg1) {
|
|
673
|
+
const obj = arg1;
|
|
674
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
675
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
676
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
677
|
+
};
|
|
678
|
+
imports.wbg.__wbg_wbindgenstringget_0f16a6ddddef376f = function(arg0, arg1) {
|
|
679
|
+
const obj = arg1;
|
|
680
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
681
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
682
|
+
var len1 = WASM_VECTOR_LEN;
|
|
683
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
684
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
685
|
+
};
|
|
686
|
+
imports.wbg.__wbg_wbindgenthrow_451ec1a8469d7eb6 = function(arg0, arg1) {
|
|
687
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
688
|
+
};
|
|
689
|
+
imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
690
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
691
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
692
|
+
return ret;
|
|
693
|
+
};
|
|
694
|
+
imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
|
|
695
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
696
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
697
|
+
return ret;
|
|
698
|
+
};
|
|
699
|
+
imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
|
|
700
|
+
// Cast intrinsic for `I64 -> Externref`.
|
|
701
|
+
const ret = arg0;
|
|
702
|
+
return ret;
|
|
703
|
+
};
|
|
704
|
+
imports.wbg.__wbindgen_cast_cb9088102bce6b30 = function(arg0, arg1) {
|
|
705
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
706
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
707
|
+
return ret;
|
|
708
|
+
};
|
|
709
|
+
imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
|
|
710
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
711
|
+
const ret = arg0;
|
|
712
|
+
return ret;
|
|
713
|
+
};
|
|
714
|
+
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
715
|
+
const table = wasm.__wbindgen_export_4;
|
|
716
|
+
const offset = table.grow(4);
|
|
717
|
+
table.set(0, undefined);
|
|
718
|
+
table.set(offset + 0, undefined);
|
|
719
|
+
table.set(offset + 1, null);
|
|
720
|
+
table.set(offset + 2, true);
|
|
721
|
+
table.set(offset + 3, false);
|
|
722
|
+
;
|
|
723
|
+
};
|
|
724
|
+
|
|
725
|
+
return imports;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
function __wbg_init_memory(imports, memory) {
|
|
729
|
+
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
function __wbg_finalize_init(instance, module) {
|
|
733
|
+
wasm = instance.exports;
|
|
734
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
735
|
+
cachedDataViewMemory0 = null;
|
|
736
|
+
cachedUint8ArrayMemory0 = null;
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
wasm.__wbindgen_start();
|
|
740
|
+
return wasm;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
function initSync(module) {
|
|
744
|
+
if (wasm !== undefined) return wasm;
|
|
745
|
+
|
|
746
|
+
|
|
747
|
+
if (typeof module !== 'undefined') {
|
|
748
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
749
|
+
({module} = module)
|
|
750
|
+
} else {
|
|
751
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
const imports = __wbg_get_imports();
|
|
756
|
+
|
|
757
|
+
__wbg_init_memory(imports);
|
|
758
|
+
|
|
759
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
760
|
+
module = new WebAssembly.Module(module);
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
764
|
+
|
|
765
|
+
return __wbg_finalize_init(instance, module);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
async function __wbg_init(module_or_path) {
|
|
769
|
+
if (wasm !== undefined) return wasm;
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
if (typeof module_or_path !== 'undefined') {
|
|
773
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
774
|
+
({module_or_path} = module_or_path)
|
|
775
|
+
} else {
|
|
776
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
if (typeof module_or_path === 'undefined') {
|
|
781
|
+
module_or_path = new URL('ducjs_wasm_bg.wasm', import.meta.url);
|
|
782
|
+
}
|
|
783
|
+
const imports = __wbg_get_imports();
|
|
784
|
+
|
|
785
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
786
|
+
module_or_path = fetch(module_or_path);
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
__wbg_init_memory(imports);
|
|
790
|
+
|
|
791
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
792
|
+
|
|
793
|
+
return __wbg_finalize_init(instance, module);
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
export { initSync };
|
|
797
|
+
export default __wbg_init;
|
|
Binary file
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const getCurrentSchemaVersion: () => number;
|
|
5
|
+
export const getExternalFile: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
6
|
+
export const listExternalFiles: (a: number, b: number) => [number, number, number];
|
|
7
|
+
export const listVersions: (a: number, b: number) => [number, number, number];
|
|
8
|
+
export const parseDuc: (a: number, b: number) => [number, number, number];
|
|
9
|
+
export const parseDucLazy: (a: number, b: number) => [number, number, number];
|
|
10
|
+
export const readVersionGraph: (a: number, b: number) => [number, number, number];
|
|
11
|
+
export const restoreCheckpoint: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
12
|
+
export const restoreVersion: (a: number, b: number, c: number) => [number, number, number];
|
|
13
|
+
export const revertToVersion: (a: number, b: number, c: number) => [number, number, number];
|
|
14
|
+
export const serializeDuc: (a: any) => [number, number, number, number];
|
|
15
|
+
export const rust_sqlite_wasm_abort: () => void;
|
|
16
|
+
export const rust_sqlite_wasm_assert_fail: (a: number, b: number, c: number, d: number) => void;
|
|
17
|
+
export const rust_sqlite_wasm_calloc: (a: number, b: number) => number;
|
|
18
|
+
export const rust_sqlite_wasm_malloc: (a: number) => number;
|
|
19
|
+
export const rust_sqlite_wasm_free: (a: number) => void;
|
|
20
|
+
export const rust_sqlite_wasm_getentropy: (a: number, b: number) => number;
|
|
21
|
+
export const rust_sqlite_wasm_localtime: (a: number) => number;
|
|
22
|
+
export const rust_sqlite_wasm_realloc: (a: number, b: number) => number;
|
|
23
|
+
export const sqlite3_os_end: () => number;
|
|
24
|
+
export const sqlite3_os_init: () => number;
|
|
25
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
26
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
27
|
+
export const __wbindgen_exn_store: (a: number) => void;
|
|
28
|
+
export const __externref_table_alloc: () => number;
|
|
29
|
+
export const __wbindgen_export_4: WebAssembly.Table;
|
|
30
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
31
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
32
|
+
export const __wbindgen_start: () => void;
|
package/dist/lazy-files.js
CHANGED
|
@@ -65,7 +65,13 @@ export class LazyExternalFileStore {
|
|
|
65
65
|
const result = wasmGetExternalFile(this.buffer, fileId);
|
|
66
66
|
if (!result)
|
|
67
67
|
return null;
|
|
68
|
-
|
|
68
|
+
// WASM returns DucExternalFileEntry { key, value: DucExternalFileData }.
|
|
69
|
+
// Unwrap to get the actual file data.
|
|
70
|
+
const entry = result;
|
|
71
|
+
if (entry.value && typeof entry.value === "object") {
|
|
72
|
+
return entry.value;
|
|
73
|
+
}
|
|
74
|
+
return entry;
|
|
69
75
|
}
|
|
70
76
|
/** Fetch file data and return a copy of the data buffer (safe for transfer). */
|
|
71
77
|
getFileDataCopy(fileId) {
|
|
@@ -49,10 +49,15 @@ export const restoreFiles = (importedFiles) => {
|
|
|
49
49
|
const files = importedFiles;
|
|
50
50
|
for (const key in files) {
|
|
51
51
|
if (Object.prototype.hasOwnProperty.call(files, key)) {
|
|
52
|
-
|
|
52
|
+
let fileData = files[key];
|
|
53
53
|
if (!fileData || typeof fileData !== "object") {
|
|
54
54
|
continue;
|
|
55
55
|
}
|
|
56
|
+
// Handle the nested DucExternalFileEntry structure { key, value: { ... } }
|
|
57
|
+
// produced by Rust serde or legacy exports.
|
|
58
|
+
if (fileData.value && typeof fileData.value === "object") {
|
|
59
|
+
fileData = fileData.value;
|
|
60
|
+
}
|
|
56
61
|
const id = isValidExternalFileId(fileData.id);
|
|
57
62
|
const mimeType = isValidString(fileData.mimeType);
|
|
58
63
|
const created = isFiniteNumber(fileData.created)
|
|
@@ -805,6 +810,9 @@ export const isValidUint8Array = (value) => {
|
|
|
805
810
|
if (value instanceof Uint8Array) {
|
|
806
811
|
return value.byteLength > 0 ? value : undefined;
|
|
807
812
|
}
|
|
813
|
+
if (value instanceof ArrayBuffer) {
|
|
814
|
+
return value.byteLength > 0 ? new Uint8Array(value) : undefined;
|
|
815
|
+
}
|
|
808
816
|
if (typeof value === "string") {
|
|
809
817
|
let base64String = value;
|
|
810
818
|
if (value.startsWith("data:")) {
|
|
@@ -9,7 +9,7 @@ export declare const MAX_ZOOM = 1e+32;
|
|
|
9
9
|
export declare const NEUTRAL_SCOPE: SupportedMeasures;
|
|
10
10
|
export declare const metricMeasures: readonly ["qm", "rm", "ym", "zm", "am", "fm", "pm", "Å", "nm", "µm", "mm", "cm", "dm", "m", "dam", "hm", "km", "Mm", "Gm", "Tm", "Pm", "Em", "Zm", "Ym", "Rm", "Qm"];
|
|
11
11
|
export type MetricMeasure = typeof metricMeasures[number];
|
|
12
|
-
export declare const imperialMeasures: readonly ["th", "ln", "in", "h", "ft", "yd", "rd", "ch", "fur", "mi", "lea"];
|
|
12
|
+
export declare const imperialMeasures: readonly ["µin", "th", "mil", "ln", "in", "h", "ft", "yd", "rd", "ch", "fur", "mi", "lea", "au", "ly", "pc"];
|
|
13
13
|
export type ImperialMeasure = typeof imperialMeasures[number];
|
|
14
14
|
export type SupportedMeasures = MetricMeasure | ImperialMeasure;
|
|
15
15
|
export type CombinedMeasure = SupportedMeasures;
|
package/dist/technical/scopes.js
CHANGED
|
@@ -32,7 +32,9 @@ export const metricMeasures = [
|
|
|
32
32
|
'Qm', // Quettameter
|
|
33
33
|
];
|
|
34
34
|
export const imperialMeasures = [
|
|
35
|
-
'
|
|
35
|
+
'µin', // Microinches
|
|
36
|
+
'th', // Thou
|
|
37
|
+
'mil', // Mils
|
|
36
38
|
'ln', // Line
|
|
37
39
|
'in', // Inches
|
|
38
40
|
'h', // Hand
|
|
@@ -43,6 +45,9 @@ export const imperialMeasures = [
|
|
|
43
45
|
'fur', // Furlongs
|
|
44
46
|
'mi', // Miles
|
|
45
47
|
'lea', // Leagues
|
|
48
|
+
'au', // Astronomical Unit
|
|
49
|
+
'ly', // Light Year
|
|
50
|
+
'pc', // Parsec
|
|
46
51
|
];
|
|
47
52
|
// Define metric units - exponents represent powers of 10
|
|
48
53
|
export const metricUnits = [
|
|
@@ -76,17 +81,22 @@ export const metricUnits = [
|
|
|
76
81
|
// Define imperial units - exponents are now relative to meter as the base unit
|
|
77
82
|
// These values are log10 of their meter equivalents
|
|
78
83
|
export const imperialUnits = [
|
|
79
|
-
{ prefix: '
|
|
80
|
-
{ prefix: '
|
|
81
|
-
{ prefix: '
|
|
82
|
-
{ prefix: '
|
|
83
|
-
{ prefix: '
|
|
84
|
-
{ prefix: '
|
|
85
|
-
{ prefix: '
|
|
86
|
-
{ prefix: '
|
|
87
|
-
{ prefix: '
|
|
88
|
-
{ prefix: '
|
|
89
|
-
{ prefix: '
|
|
84
|
+
{ prefix: 'µin', unit: 'microinch', full: 'microinch', exponent: -7.595 }, // log10(2.54e-8)
|
|
85
|
+
{ prefix: 'th', unit: 'thou', full: 'thou', exponent: -4.595 }, // log10(0.0000254)
|
|
86
|
+
{ prefix: 'mil', unit: 'mil', full: 'mil', exponent: -4.595 }, // log10(0.0000254)
|
|
87
|
+
{ prefix: 'ln', unit: 'line', full: 'line', exponent: -2.674 }, // log10(0.00211667)
|
|
88
|
+
{ prefix: 'in', unit: 'inch', full: 'inch', exponent: -1.595 }, // log10(0.0254)
|
|
89
|
+
{ prefix: 'h', unit: 'hand', full: 'hand', exponent: -0.993 }, // log10(0.1016)
|
|
90
|
+
{ prefix: 'ft', unit: 'foot', full: 'foot', exponent: -0.516 }, // log10(0.3048)
|
|
91
|
+
{ prefix: 'yd', unit: 'yard', full: 'yard', exponent: -0.039 }, // log10(0.9144)
|
|
92
|
+
{ prefix: 'rd', unit: 'rod', full: 'rod', exponent: 0.701 }, // log10(5.0292)
|
|
93
|
+
{ prefix: 'ch', unit: 'chain', full: 'chain', exponent: 1.304 }, // log10(20.1168)
|
|
94
|
+
{ prefix: 'fur', unit: 'furlong', full: 'furlong', exponent: 2.304 }, // log10(201.168)
|
|
95
|
+
{ prefix: 'mi', unit: 'mile', full: 'mile', exponent: 3.207 }, // log10(1609.344)
|
|
96
|
+
{ prefix: 'lea', unit: 'league', full: 'league', exponent: 3.684 }, // log10(4828.032)
|
|
97
|
+
{ prefix: 'au', unit: 'au', full: 'Astronomical Unit', exponent: 11.175 }, // log10(1.496e11)
|
|
98
|
+
{ prefix: 'ly', unit: 'ly', full: 'Light Year', exponent: 15.976 }, // log10(9.461e15)
|
|
99
|
+
{ prefix: 'pc', unit: 'pc', full: 'Parsec', exponent: 16.489 }, // log10(3.086e16)
|
|
90
100
|
];
|
|
91
101
|
// Scale factors for unit conversions - using meter as the base unit
|
|
92
102
|
export const ScaleFactors = {
|
|
@@ -118,7 +128,9 @@ export const ScaleFactors = {
|
|
|
118
128
|
Rm: 1e27,
|
|
119
129
|
Qm: 1e30,
|
|
120
130
|
// Imperial scales
|
|
121
|
-
|
|
131
|
+
'µin': 2.54e-8, // Microinch
|
|
132
|
+
th: 0.0000254, // Thou (0.001 inch)
|
|
133
|
+
mil: 0.0000254, // Mil (same as Thou)
|
|
122
134
|
ln: 0.00211667, // 1/12 inch
|
|
123
135
|
in: 0.0254,
|
|
124
136
|
h: 0.1016, // 4 inches
|
|
@@ -129,6 +141,9 @@ export const ScaleFactors = {
|
|
|
129
141
|
fur: 201.168,
|
|
130
142
|
mi: 1609.344,
|
|
131
143
|
lea: 4828.032, // 3 miles
|
|
144
|
+
au: 149597870700, // Astronomical Unit
|
|
145
|
+
ly: 9460730472580800, // Light Year
|
|
146
|
+
pc: 30856775814913670, // Parsec
|
|
132
147
|
};
|
|
133
148
|
/**
|
|
134
149
|
* Determines if a measure belongs to the metric system.
|
package/dist/wasm.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getCurrentSchemaVersion as _getCurrentSchemaVersion, getExternalFile as _getExternalFile, listExternalFiles as _listExternalFiles, listVersions as _listVersions, parseDuc as _parseDuc, parseDucLazy as _parseDucLazy, readVersionGraph as _readVersionGraph, restoreCheckpoint as _restoreCheckpoint, restoreVersion as _restoreVersion, revertToVersion as _revertToVersion, serializeDuc as _serializeDuc } from "../
|
|
1
|
+
import { getCurrentSchemaVersion as _getCurrentSchemaVersion, getExternalFile as _getExternalFile, listExternalFiles as _listExternalFiles, listVersions as _listVersions, parseDuc as _parseDuc, parseDucLazy as _parseDucLazy, readVersionGraph as _readVersionGraph, restoreCheckpoint as _restoreCheckpoint, restoreVersion as _restoreVersion, revertToVersion as _revertToVersion, serializeDuc as _serializeDuc } from "../dist/ducjs_wasm";
|
|
2
2
|
export declare function ensureWasm(wasmUrl?: string | URL | BufferSource): Promise<void>;
|
|
3
3
|
/**
|
|
4
4
|
* Fetch the raw WASM binary as an ArrayBuffer.
|
package/dist/wasm.js
CHANGED
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import init, { getCurrentSchemaVersion as _getCurrentSchemaVersion, getExternalFile as _getExternalFile, listExternalFiles as _listExternalFiles, listVersions as _listVersions, parseDuc as _parseDuc, parseDucLazy as _parseDucLazy, readVersionGraph as _readVersionGraph, restoreCheckpoint as _restoreCheckpoint, restoreVersion as _restoreVersion, revertToVersion as _revertToVersion, serializeDuc as _serializeDuc, } from "../
|
|
10
|
+
import init, { getCurrentSchemaVersion as _getCurrentSchemaVersion, getExternalFile as _getExternalFile, listExternalFiles as _listExternalFiles, listVersions as _listVersions, parseDuc as _parseDuc, parseDucLazy as _parseDucLazy, readVersionGraph as _readVersionGraph, restoreCheckpoint as _restoreCheckpoint, restoreVersion as _restoreVersion, revertToVersion as _revertToVersion, serializeDuc as _serializeDuc, } from "../dist/ducjs_wasm";
|
|
11
11
|
let initialized = false;
|
|
12
12
|
let initPromise = null;
|
|
13
13
|
export function ensureWasm(wasmUrl) {
|
|
@@ -31,7 +31,7 @@ export function ensureWasm(wasmUrl) {
|
|
|
31
31
|
*/
|
|
32
32
|
export function getWasmBinary() {
|
|
33
33
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
const url = new URL('../
|
|
34
|
+
const url = new URL('../dist/ducjs_wasm_bg.wasm', import.meta.url);
|
|
35
35
|
const resp = yield fetch(url);
|
|
36
36
|
if (!resp.ok) {
|
|
37
37
|
throw new Error(`Failed to fetch WASM binary: ${resp.status} ${resp.statusText}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ducjs",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.4",
|
|
4
4
|
"description": "The duc 2D CAD file format is a cornerstone of our advanced design system, conceived to cater to professionals seeking precision and efficiency in their design work.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|