@lumikmz/kmz-file 0.2.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/LICENSE +21 -0
- package/README.md +258 -0
- package/dist/index.d.mts +48 -0
- package/dist/index.mjs +1140 -0
- package/dist/wasm_kmz.d.ts +80 -0
- package/dist/wasm_kmz.js +432 -0
- package/dist/wasm_kmz_bg.wasm +0 -0
- package/dist/wasm_kmz_bg.wasm.d.ts +12 -0
- package/package.json +36 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/** Result of parsing a KMZ file */
|
|
5
|
+
export interface KmzParseResult {
|
|
6
|
+
/** JSON string of template.kml contents */
|
|
7
|
+
template: string;
|
|
8
|
+
/** JSON string of waylines.wpml contents */
|
|
9
|
+
waylines: string;
|
|
10
|
+
/** Resource files bundled in the KMZ */
|
|
11
|
+
resources: Array<{ path: string; data: Uint8Array }>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Parse a KMZ file (as Uint8Array) and return template + waylines as JSON strings.
|
|
16
|
+
* Throws on invalid KMZ, missing template.kml or waylines.wpml, or XML parse errors.
|
|
17
|
+
*/
|
|
18
|
+
export function kmzToJson(kmzData: Uint8Array): KmzParseResult;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Pack template + waylines JSON strings and optional resource files into a KMZ Uint8Array.
|
|
22
|
+
* Resources should be the array returned by kmzToJson (or compatible objects).
|
|
23
|
+
* Throws on invalid JSON or serialization errors.
|
|
24
|
+
*/
|
|
25
|
+
export function jsonToKmz(
|
|
26
|
+
templateJson: string,
|
|
27
|
+
waylinesJson: string,
|
|
28
|
+
resources?: Array<{ path: string; data: Uint8Array }>
|
|
29
|
+
): Uint8Array;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Parse an XML string to a JSON string (1:1 mapping).
|
|
33
|
+
* Throws on XML parse errors.
|
|
34
|
+
*/
|
|
35
|
+
export function xmlToJson(xmlString: string): string;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Convert a JSON string (from xmlToJson) back to an XML string.
|
|
39
|
+
* Throws on invalid JSON or serialization errors.
|
|
40
|
+
*/
|
|
41
|
+
export function jsonToXml(jsonString: string): string;
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
46
|
+
|
|
47
|
+
export interface InitOutput {
|
|
48
|
+
readonly memory: WebAssembly.Memory;
|
|
49
|
+
readonly jsonToKmz: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
50
|
+
readonly jsonToXml: (a: number, b: number, c: number) => void;
|
|
51
|
+
readonly kmzToJson: (a: number, b: number, c: number) => void;
|
|
52
|
+
readonly xmlToJson: (a: number, b: number, c: number) => void;
|
|
53
|
+
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
54
|
+
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
55
|
+
readonly __wbindgen_export3: (a: number) => void;
|
|
56
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
57
|
+
readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
64
|
+
* a precompiled `WebAssembly.Module`.
|
|
65
|
+
*
|
|
66
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
67
|
+
*
|
|
68
|
+
* @returns {InitOutput}
|
|
69
|
+
*/
|
|
70
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
74
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
75
|
+
*
|
|
76
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
77
|
+
*
|
|
78
|
+
* @returns {Promise<InitOutput>}
|
|
79
|
+
*/
|
|
80
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/dist/wasm_kmz.js
ADDED
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
/* @ts-self-types="./wasm_kmz.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {string} template_json
|
|
5
|
+
* @param {string} waylines_json
|
|
6
|
+
* @param {any} resources
|
|
7
|
+
* @returns {Uint8Array}
|
|
8
|
+
*/
|
|
9
|
+
export function jsonToKmz(template_json, waylines_json, resources) {
|
|
10
|
+
try {
|
|
11
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
12
|
+
const ptr0 = passStringToWasm0(template_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
13
|
+
const len0 = WASM_VECTOR_LEN;
|
|
14
|
+
const ptr1 = passStringToWasm0(waylines_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
15
|
+
const len1 = WASM_VECTOR_LEN;
|
|
16
|
+
wasm.jsonToKmz(retptr, ptr0, len0, ptr1, len1, addHeapObject(resources));
|
|
17
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
18
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
19
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
20
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
21
|
+
if (r3) {
|
|
22
|
+
throw takeObject(r2);
|
|
23
|
+
}
|
|
24
|
+
var v3 = getArrayU8FromWasm0(r0, r1).slice();
|
|
25
|
+
wasm.__wbindgen_export4(r0, r1 * 1, 1);
|
|
26
|
+
return v3;
|
|
27
|
+
} finally {
|
|
28
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @param {string} json_string
|
|
34
|
+
* @returns {string}
|
|
35
|
+
*/
|
|
36
|
+
export function jsonToXml(json_string) {
|
|
37
|
+
let deferred3_0;
|
|
38
|
+
let deferred3_1;
|
|
39
|
+
try {
|
|
40
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
41
|
+
const ptr0 = passStringToWasm0(json_string, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
42
|
+
const len0 = WASM_VECTOR_LEN;
|
|
43
|
+
wasm.jsonToXml(retptr, ptr0, len0);
|
|
44
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
45
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
46
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
47
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
48
|
+
var ptr2 = r0;
|
|
49
|
+
var len2 = r1;
|
|
50
|
+
if (r3) {
|
|
51
|
+
ptr2 = 0; len2 = 0;
|
|
52
|
+
throw takeObject(r2);
|
|
53
|
+
}
|
|
54
|
+
deferred3_0 = ptr2;
|
|
55
|
+
deferred3_1 = len2;
|
|
56
|
+
return getStringFromWasm0(ptr2, len2);
|
|
57
|
+
} finally {
|
|
58
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
59
|
+
wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @param {Uint8Array} kmz_data
|
|
65
|
+
* @returns {any}
|
|
66
|
+
*/
|
|
67
|
+
export function kmzToJson(kmz_data) {
|
|
68
|
+
try {
|
|
69
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
70
|
+
const ptr0 = passArray8ToWasm0(kmz_data, wasm.__wbindgen_export);
|
|
71
|
+
const len0 = WASM_VECTOR_LEN;
|
|
72
|
+
wasm.kmzToJson(retptr, ptr0, len0);
|
|
73
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
74
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
75
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
76
|
+
if (r2) {
|
|
77
|
+
throw takeObject(r1);
|
|
78
|
+
}
|
|
79
|
+
return takeObject(r0);
|
|
80
|
+
} finally {
|
|
81
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @param {string} xml_string
|
|
87
|
+
* @returns {string}
|
|
88
|
+
*/
|
|
89
|
+
export function xmlToJson(xml_string) {
|
|
90
|
+
let deferred3_0;
|
|
91
|
+
let deferred3_1;
|
|
92
|
+
try {
|
|
93
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
94
|
+
const ptr0 = passStringToWasm0(xml_string, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
95
|
+
const len0 = WASM_VECTOR_LEN;
|
|
96
|
+
wasm.xmlToJson(retptr, ptr0, len0);
|
|
97
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
98
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
99
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
100
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
101
|
+
var ptr2 = r0;
|
|
102
|
+
var len2 = r1;
|
|
103
|
+
if (r3) {
|
|
104
|
+
ptr2 = 0; len2 = 0;
|
|
105
|
+
throw takeObject(r2);
|
|
106
|
+
}
|
|
107
|
+
deferred3_0 = ptr2;
|
|
108
|
+
deferred3_1 = len2;
|
|
109
|
+
return getStringFromWasm0(ptr2, len2);
|
|
110
|
+
} finally {
|
|
111
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
112
|
+
wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function __wbg_get_imports() {
|
|
116
|
+
const import0 = {
|
|
117
|
+
__proto__: null,
|
|
118
|
+
__wbg_Error_bce6d499ff0a4aff: function(arg0, arg1) {
|
|
119
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
120
|
+
return addHeapObject(ret);
|
|
121
|
+
},
|
|
122
|
+
__wbg___wbindgen_is_null_2042690d351e14f0: function(arg0) {
|
|
123
|
+
const ret = getObject(arg0) === null;
|
|
124
|
+
return ret;
|
|
125
|
+
},
|
|
126
|
+
__wbg___wbindgen_is_undefined_35bb9f4c7fd651d5: function(arg0) {
|
|
127
|
+
const ret = getObject(arg0) === undefined;
|
|
128
|
+
return ret;
|
|
129
|
+
},
|
|
130
|
+
__wbg___wbindgen_string_get_d109740c0d18f4d7: function(arg0, arg1) {
|
|
131
|
+
const obj = getObject(arg1);
|
|
132
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
133
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
134
|
+
var len1 = WASM_VECTOR_LEN;
|
|
135
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
136
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
137
|
+
},
|
|
138
|
+
__wbg___wbindgen_throw_9c31b086c2b26051: function(arg0, arg1) {
|
|
139
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
140
|
+
},
|
|
141
|
+
__wbg_from_fa561fa561dc8031: function(arg0) {
|
|
142
|
+
const ret = Array.from(getObject(arg0));
|
|
143
|
+
return addHeapObject(ret);
|
|
144
|
+
},
|
|
145
|
+
__wbg_get_dcf82ab8aad1a593: function() { return handleError(function (arg0, arg1) {
|
|
146
|
+
const ret = Reflect.get(getObject(arg0), getObject(arg1));
|
|
147
|
+
return addHeapObject(ret);
|
|
148
|
+
}, arguments); },
|
|
149
|
+
__wbg_get_unchecked_1dfe6d05ad91d9b7: function(arg0, arg1) {
|
|
150
|
+
const ret = getObject(arg0)[arg1 >>> 0];
|
|
151
|
+
return addHeapObject(ret);
|
|
152
|
+
},
|
|
153
|
+
__wbg_length_2591a0f4f659a55c: function(arg0) {
|
|
154
|
+
const ret = getObject(arg0).length;
|
|
155
|
+
return ret;
|
|
156
|
+
},
|
|
157
|
+
__wbg_length_56fcd3e2b7e0299d: function(arg0) {
|
|
158
|
+
const ret = getObject(arg0).length;
|
|
159
|
+
return ret;
|
|
160
|
+
},
|
|
161
|
+
__wbg_new_02d162bc6cf02f60: function() {
|
|
162
|
+
const ret = new Object();
|
|
163
|
+
return addHeapObject(ret);
|
|
164
|
+
},
|
|
165
|
+
__wbg_new_310879b66b6e95e1: function() {
|
|
166
|
+
const ret = new Array();
|
|
167
|
+
return addHeapObject(ret);
|
|
168
|
+
},
|
|
169
|
+
__wbg_new_7ddec6de44ff8f5d: function(arg0) {
|
|
170
|
+
const ret = new Uint8Array(getObject(arg0));
|
|
171
|
+
return addHeapObject(ret);
|
|
172
|
+
},
|
|
173
|
+
__wbg_new_from_slice_269e35316ed2d061: function(arg0, arg1) {
|
|
174
|
+
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
175
|
+
return addHeapObject(ret);
|
|
176
|
+
},
|
|
177
|
+
__wbg_prototypesetcall_5f9bdc8d75e07276: function(arg0, arg1, arg2) {
|
|
178
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
179
|
+
},
|
|
180
|
+
__wbg_push_b77c476b01548d0a: function(arg0, arg1) {
|
|
181
|
+
const ret = getObject(arg0).push(getObject(arg1));
|
|
182
|
+
return ret;
|
|
183
|
+
},
|
|
184
|
+
__wbg_set_a0e911be3da02782: function() { return handleError(function (arg0, arg1, arg2) {
|
|
185
|
+
const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
|
|
186
|
+
return ret;
|
|
187
|
+
}, arguments); },
|
|
188
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
189
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
190
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
191
|
+
return addHeapObject(ret);
|
|
192
|
+
},
|
|
193
|
+
__wbindgen_object_drop_ref: function(arg0) {
|
|
194
|
+
takeObject(arg0);
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
return {
|
|
198
|
+
__proto__: null,
|
|
199
|
+
"./wasm_kmz_bg.js": import0,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function addHeapObject(obj) {
|
|
204
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
205
|
+
const idx = heap_next;
|
|
206
|
+
heap_next = heap[idx];
|
|
207
|
+
|
|
208
|
+
heap[idx] = obj;
|
|
209
|
+
return idx;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function dropObject(idx) {
|
|
213
|
+
if (idx < 1028) return;
|
|
214
|
+
heap[idx] = heap_next;
|
|
215
|
+
heap_next = idx;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
219
|
+
ptr = ptr >>> 0;
|
|
220
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
let cachedDataViewMemory0 = null;
|
|
224
|
+
function getDataViewMemory0() {
|
|
225
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
226
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
227
|
+
}
|
|
228
|
+
return cachedDataViewMemory0;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function getStringFromWasm0(ptr, len) {
|
|
232
|
+
return decodeText(ptr >>> 0, len);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
let cachedUint8ArrayMemory0 = null;
|
|
236
|
+
function getUint8ArrayMemory0() {
|
|
237
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
238
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
239
|
+
}
|
|
240
|
+
return cachedUint8ArrayMemory0;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function getObject(idx) { return heap[idx]; }
|
|
244
|
+
|
|
245
|
+
function handleError(f, args) {
|
|
246
|
+
try {
|
|
247
|
+
return f.apply(this, args);
|
|
248
|
+
} catch (e) {
|
|
249
|
+
wasm.__wbindgen_export3(addHeapObject(e));
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
let heap = new Array(1024).fill(undefined);
|
|
254
|
+
heap.push(undefined, null, true, false);
|
|
255
|
+
|
|
256
|
+
let heap_next = heap.length;
|
|
257
|
+
|
|
258
|
+
function isLikeNone(x) {
|
|
259
|
+
return x === undefined || x === null;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
263
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
264
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
265
|
+
WASM_VECTOR_LEN = arg.length;
|
|
266
|
+
return ptr;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
270
|
+
if (realloc === undefined) {
|
|
271
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
272
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
273
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
274
|
+
WASM_VECTOR_LEN = buf.length;
|
|
275
|
+
return ptr;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
let len = arg.length;
|
|
279
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
280
|
+
|
|
281
|
+
const mem = getUint8ArrayMemory0();
|
|
282
|
+
|
|
283
|
+
let offset = 0;
|
|
284
|
+
|
|
285
|
+
for (; offset < len; offset++) {
|
|
286
|
+
const code = arg.charCodeAt(offset);
|
|
287
|
+
if (code > 0x7F) break;
|
|
288
|
+
mem[ptr + offset] = code;
|
|
289
|
+
}
|
|
290
|
+
if (offset !== len) {
|
|
291
|
+
if (offset !== 0) {
|
|
292
|
+
arg = arg.slice(offset);
|
|
293
|
+
}
|
|
294
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
295
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
296
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
297
|
+
|
|
298
|
+
offset += ret.written;
|
|
299
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
WASM_VECTOR_LEN = offset;
|
|
303
|
+
return ptr;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function takeObject(idx) {
|
|
307
|
+
const ret = getObject(idx);
|
|
308
|
+
dropObject(idx);
|
|
309
|
+
return ret;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
313
|
+
cachedTextDecoder.decode();
|
|
314
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
315
|
+
let numBytesDecoded = 0;
|
|
316
|
+
function decodeText(ptr, len) {
|
|
317
|
+
numBytesDecoded += len;
|
|
318
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
319
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
320
|
+
cachedTextDecoder.decode();
|
|
321
|
+
numBytesDecoded = len;
|
|
322
|
+
}
|
|
323
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
const cachedTextEncoder = new TextEncoder();
|
|
327
|
+
|
|
328
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
329
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
330
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
331
|
+
view.set(buf);
|
|
332
|
+
return {
|
|
333
|
+
read: arg.length,
|
|
334
|
+
written: buf.length
|
|
335
|
+
};
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
let WASM_VECTOR_LEN = 0;
|
|
340
|
+
|
|
341
|
+
let wasmModule, wasmInstance, wasm;
|
|
342
|
+
function __wbg_finalize_init(instance, module) {
|
|
343
|
+
wasmInstance = instance;
|
|
344
|
+
wasm = instance.exports;
|
|
345
|
+
wasmModule = module;
|
|
346
|
+
cachedDataViewMemory0 = null;
|
|
347
|
+
cachedUint8ArrayMemory0 = null;
|
|
348
|
+
return wasm;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
async function __wbg_load(module, imports) {
|
|
352
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
353
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
354
|
+
try {
|
|
355
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
356
|
+
} catch (e) {
|
|
357
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
358
|
+
|
|
359
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
360
|
+
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);
|
|
361
|
+
|
|
362
|
+
} else { throw e; }
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
const bytes = await module.arrayBuffer();
|
|
367
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
368
|
+
} else {
|
|
369
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
370
|
+
|
|
371
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
372
|
+
return { instance, module };
|
|
373
|
+
} else {
|
|
374
|
+
return instance;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function expectedResponseType(type) {
|
|
379
|
+
switch (type) {
|
|
380
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
381
|
+
}
|
|
382
|
+
return false;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function initSync(module) {
|
|
387
|
+
if (wasm !== undefined) return wasm;
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
if (module !== undefined) {
|
|
391
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
392
|
+
({module} = module)
|
|
393
|
+
} else {
|
|
394
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
const imports = __wbg_get_imports();
|
|
399
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
400
|
+
module = new WebAssembly.Module(module);
|
|
401
|
+
}
|
|
402
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
403
|
+
return __wbg_finalize_init(instance, module);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
async function __wbg_init(module_or_path) {
|
|
407
|
+
if (wasm !== undefined) return wasm;
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
if (module_or_path !== undefined) {
|
|
411
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
412
|
+
({module_or_path} = module_or_path)
|
|
413
|
+
} else {
|
|
414
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
if (module_or_path === undefined) {
|
|
419
|
+
module_or_path = new URL('wasm_kmz_bg.wasm', import.meta.url);
|
|
420
|
+
}
|
|
421
|
+
const imports = __wbg_get_imports();
|
|
422
|
+
|
|
423
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
424
|
+
module_or_path = fetch(module_or_path);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
428
|
+
|
|
429
|
+
return __wbg_finalize_init(instance, module);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const jsonToKmz: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
5
|
+
export const jsonToXml: (a: number, b: number, c: number) => void;
|
|
6
|
+
export const kmzToJson: (a: number, b: number, c: number) => void;
|
|
7
|
+
export const xmlToJson: (a: number, b: number, c: number) => void;
|
|
8
|
+
export const __wbindgen_export: (a: number, b: number) => number;
|
|
9
|
+
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
10
|
+
export const __wbindgen_export3: (a: number) => void;
|
|
11
|
+
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
12
|
+
export const __wbindgen_export4: (a: number, b: number, c: number) => void;
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lumikmz/kmz-file",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "DJI KMZ file pack/unpack — Rust WASM + spec-aligned TypeScript codec",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist/index.mjs",
|
|
8
|
+
"dist/index.d.mts",
|
|
9
|
+
"dist/wasm_kmz.js",
|
|
10
|
+
"dist/wasm_kmz.d.ts",
|
|
11
|
+
"dist/wasm_kmz_bg.wasm",
|
|
12
|
+
"dist/wasm_kmz_bg.wasm.d.ts"
|
|
13
|
+
],
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "./dist/index.mjs",
|
|
16
|
+
"types": "./dist/index.d.mts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.mts",
|
|
20
|
+
"import": "./dist/index.mjs",
|
|
21
|
+
"default": "./dist/index.mjs"
|
|
22
|
+
},
|
|
23
|
+
"./wasm": "./dist/wasm_kmz_bg.wasm",
|
|
24
|
+
"./package.json": "./package.json"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@lumikmz/kmz": "0.2.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"vite-plus": "latest",
|
|
31
|
+
"vitest": "npm:@voidzero-dev/vite-plus-test@^0.1.20"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "node scripts/build.js"
|
|
35
|
+
}
|
|
36
|
+
}
|