@rainbowatcher/toml-edit-js
Advanced tools
| /* tslint:disable */ | ||
| /* eslint-disable */ | ||
| export const memory: WebAssembly.Memory; | ||
| export const edit: (a: number, b: number, c: number, d: number, e: any, f: number) => [number, number, number, number]; | ||
| export const init_panic_hook: () => void; | ||
| export const parse: (a: number, b: number) => [number, number, number]; | ||
| export const stringify: (a: any, b: number) => [number, number, number, number]; | ||
| export const edit: (a: number, b: number, c: number, d: number, e: any, f: number) => [number, number, number, number]; | ||
| export const __wbindgen_malloc: (a: number, b: number) => number; | ||
@@ -9,0 +9,0 @@ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number; |
+334
-331
@@ -1,7 +0,282 @@ | ||
| let wasm; | ||
| /* @ts-self-types="./index.d.ts" */ | ||
| function isLikeNone(x) { | ||
| return x === undefined || x === null; | ||
| /** | ||
| * Edits a TOML document by path and returns the updated text. | ||
| * | ||
| * Path segments support dotted keys and array index notation like `foo.bar.[0]`. | ||
| * @param {string} input | ||
| * @param {string} path | ||
| * @param {any} value | ||
| * @param {IEditOptions | null} [opts] | ||
| * @returns {string} | ||
| */ | ||
| export function edit(input, path, value, opts) { | ||
| let deferred4_0; | ||
| let deferred4_1; | ||
| try { | ||
| const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
| const len0 = WASM_VECTOR_LEN; | ||
| const ptr1 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
| const len1 = WASM_VECTOR_LEN; | ||
| const ret = wasm.edit(ptr0, len0, ptr1, len1, value, isLikeNone(opts) ? 0 : addToExternrefTable0(opts)); | ||
| var ptr3 = ret[0]; | ||
| var len3 = ret[1]; | ||
| if (ret[3]) { | ||
| ptr3 = 0; len3 = 0; | ||
| throw takeFromExternrefTable0(ret[2]); | ||
| } | ||
| deferred4_0 = ptr3; | ||
| deferred4_1 = len3; | ||
| return getStringFromWasm0(ptr3, len3); | ||
| } finally { | ||
| wasm.__wbindgen_free(deferred4_0, deferred4_1, 1); | ||
| } | ||
| } | ||
| /** | ||
| * Installs panic hooks for better browser console error output. | ||
| */ | ||
| export function init_panic_hook() { | ||
| wasm.init_panic_hook(); | ||
| } | ||
| /** | ||
| * Parses a TOML string into a JavaScript value tree. | ||
| * @param {string} input | ||
| * @returns {any} | ||
| */ | ||
| export function parse(input) { | ||
| const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
| const len0 = WASM_VECTOR_LEN; | ||
| const ret = wasm.parse(ptr0, len0); | ||
| if (ret[2]) { | ||
| throw takeFromExternrefTable0(ret[1]); | ||
| } | ||
| return takeFromExternrefTable0(ret[0]); | ||
| } | ||
| /** | ||
| * Serializes a JavaScript value into TOML text. | ||
| * | ||
| * The conversion strategy depends on value shape and stringify options. | ||
| * @param {any} input | ||
| * @param {IStringifyOptions | null} [opts] | ||
| * @returns {string} | ||
| */ | ||
| export function stringify(input, opts) { | ||
| let deferred2_0; | ||
| let deferred2_1; | ||
| try { | ||
| const ret = wasm.stringify(input, isLikeNone(opts) ? 0 : addToExternrefTable0(opts)); | ||
| var ptr1 = ret[0]; | ||
| var len1 = ret[1]; | ||
| if (ret[3]) { | ||
| ptr1 = 0; len1 = 0; | ||
| throw takeFromExternrefTable0(ret[2]); | ||
| } | ||
| deferred2_0 = ptr1; | ||
| deferred2_1 = len1; | ||
| return getStringFromWasm0(ptr1, len1); | ||
| } finally { | ||
| wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); | ||
| } | ||
| } | ||
| function __wbg_get_imports() { | ||
| const import0 = { | ||
| __proto__: null, | ||
| __wbg___wbindgen_boolean_get_c0f3f60bac5a78d1: function(arg0) { | ||
| const v = arg0; | ||
| const ret = typeof(v) === 'boolean' ? v : undefined; | ||
| return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0; | ||
| }, | ||
| __wbg___wbindgen_debug_string_5398f5bb970e0daa: function(arg0, arg1) { | ||
| const ret = debugString(arg1); | ||
| const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
| const len1 = WASM_VECTOR_LEN; | ||
| getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); | ||
| getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); | ||
| }, | ||
| __wbg___wbindgen_is_bigint_e2141d4f045b7eda: function(arg0) { | ||
| const ret = typeof(arg0) === 'bigint'; | ||
| return ret; | ||
| }, | ||
| __wbg___wbindgen_is_null_0b605fc6b167c56f: function(arg0) { | ||
| const ret = arg0 === null; | ||
| return ret; | ||
| }, | ||
| __wbg___wbindgen_is_object_781bc9f159099513: function(arg0) { | ||
| const val = arg0; | ||
| const ret = typeof(val) === 'object' && val !== null; | ||
| return ret; | ||
| }, | ||
| __wbg___wbindgen_is_undefined_52709e72fb9f179c: function(arg0) { | ||
| const ret = arg0 === undefined; | ||
| return ret; | ||
| }, | ||
| __wbg___wbindgen_number_get_34bb9d9dcfa21373: function(arg0, arg1) { | ||
| const obj = arg1; | ||
| const ret = typeof(obj) === 'number' ? obj : undefined; | ||
| getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true); | ||
| getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true); | ||
| }, | ||
| __wbg___wbindgen_string_get_395e606bd0ee4427: function(arg0, arg1) { | ||
| const obj = arg1; | ||
| const ret = typeof(obj) === 'string' ? obj : undefined; | ||
| var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
| var len1 = WASM_VECTOR_LEN; | ||
| getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); | ||
| getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); | ||
| }, | ||
| __wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) { | ||
| throw new Error(getStringFromWasm0(arg0, arg1)); | ||
| }, | ||
| __wbg_entries_e8a20ff8c9757101: function(arg0) { | ||
| const ret = Object.entries(arg0); | ||
| return ret; | ||
| }, | ||
| __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) { | ||
| let deferred0_0; | ||
| let deferred0_1; | ||
| try { | ||
| deferred0_0 = arg0; | ||
| deferred0_1 = arg1; | ||
| console.error(getStringFromWasm0(arg0, arg1)); | ||
| } finally { | ||
| wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); | ||
| } | ||
| }, | ||
| __wbg_fromEntries_8f078e02a548e8eb: function() { return handleError(function (arg0) { | ||
| const ret = Object.fromEntries(arg0); | ||
| return ret; | ||
| }, arguments); }, | ||
| __wbg_getUTCDate_6631790e483b8a07: function(arg0) { | ||
| const ret = arg0.getUTCDate(); | ||
| return ret; | ||
| }, | ||
| __wbg_getUTCFullYear_c7456d7c65c091ab: function(arg0) { | ||
| const ret = arg0.getUTCFullYear(); | ||
| return ret; | ||
| }, | ||
| __wbg_getUTCHours_d22b0e411df7740d: function(arg0) { | ||
| const ret = arg0.getUTCHours(); | ||
| return ret; | ||
| }, | ||
| __wbg_getUTCMilliseconds_2b13cdd75b1888cb: function(arg0) { | ||
| const ret = arg0.getUTCMilliseconds(); | ||
| return ret; | ||
| }, | ||
| __wbg_getUTCMinutes_bba14f1a86989110: function(arg0) { | ||
| const ret = arg0.getUTCMinutes(); | ||
| return ret; | ||
| }, | ||
| __wbg_getUTCMonth_0f9ba067ff5d2047: function(arg0) { | ||
| const ret = arg0.getUTCMonth(); | ||
| return ret; | ||
| }, | ||
| __wbg_getUTCSeconds_c21679a9ef6c2512: function(arg0) { | ||
| const ret = arg0.getUTCSeconds(); | ||
| return ret; | ||
| }, | ||
| __wbg_get_a8ee5c45dabc1b3b: function(arg0, arg1) { | ||
| const ret = arg0[arg1 >>> 0]; | ||
| return ret; | ||
| }, | ||
| __wbg_get_unchecked_329cfe50afab7352: function(arg0, arg1) { | ||
| const ret = arg0[arg1 >>> 0]; | ||
| return ret; | ||
| }, | ||
| __wbg_instanceof_Date_99b770f6ee1d16dd: function(arg0) { | ||
| let result; | ||
| try { | ||
| result = arg0 instanceof Date; | ||
| } catch (_) { | ||
| result = false; | ||
| } | ||
| const ret = result; | ||
| return ret; | ||
| }, | ||
| __wbg_instanceof_Object_be1962063fcc0c9f: function(arg0) { | ||
| let result; | ||
| try { | ||
| result = arg0 instanceof Object; | ||
| } catch (_) { | ||
| result = false; | ||
| } | ||
| const ret = result; | ||
| return ret; | ||
| }, | ||
| __wbg_isArray_33b91feb269ff46e: function(arg0) { | ||
| const ret = Array.isArray(arg0); | ||
| return ret; | ||
| }, | ||
| __wbg_isArray_42f3245bcac28e65: function(arg0) { | ||
| const ret = Array.isArray(arg0); | ||
| return ret; | ||
| }, | ||
| __wbg_length_b3416cf66a5452c8: function(arg0) { | ||
| const ret = arg0.length; | ||
| return ret; | ||
| }, | ||
| __wbg_new_227d7c05414eb861: function() { | ||
| const ret = new Error(); | ||
| return ret; | ||
| }, | ||
| __wbg_new_typed_bccac67128ed885a: function() { | ||
| const ret = new Array(); | ||
| return ret; | ||
| }, | ||
| __wbg_new_with_length_3259a525196bd8cc: function(arg0) { | ||
| const ret = new Array(arg0 >>> 0); | ||
| return ret; | ||
| }, | ||
| __wbg_push_e87b0e732085a946: function(arg0, arg1) { | ||
| const ret = arg0.push(arg1); | ||
| return ret; | ||
| }, | ||
| __wbg_set_282384002438957f: function(arg0, arg1, arg2) { | ||
| arg0[arg1 >>> 0] = arg2; | ||
| }, | ||
| __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) { | ||
| const ret = arg1.stack; | ||
| const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
| const len1 = WASM_VECTOR_LEN; | ||
| getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); | ||
| getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); | ||
| }, | ||
| __wbg_warn_69424c2d92a2fa73: function(arg0) { | ||
| console.warn(arg0); | ||
| }, | ||
| __wbindgen_cast_0000000000000001: function(arg0) { | ||
| // Cast intrinsic for `F64 -> Externref`. | ||
| const ret = arg0; | ||
| return ret; | ||
| }, | ||
| __wbindgen_cast_0000000000000002: function(arg0, arg1) { | ||
| // Cast intrinsic for `Ref(String) -> Externref`. | ||
| const ret = getStringFromWasm0(arg0, arg1); | ||
| return ret; | ||
| }, | ||
| __wbindgen_init_externref_table: function() { | ||
| const table = wasm.__wbindgen_externrefs; | ||
| const offset = table.grow(4); | ||
| table.set(0, undefined); | ||
| table.set(offset + 0, undefined); | ||
| table.set(offset + 1, null); | ||
| table.set(offset + 2, true); | ||
| table.set(offset + 3, false); | ||
| }, | ||
| }; | ||
| return { | ||
| __proto__: null, | ||
| "./index_bg.js": import0, | ||
| }; | ||
| } | ||
| function addToExternrefTable0(obj) { | ||
| const idx = wasm.__externref_table_alloc(); | ||
| wasm.__wbindgen_externrefs.set(idx, obj); | ||
| return idx; | ||
| } | ||
| function debugString(val) { | ||
@@ -72,6 +347,16 @@ // primitive types | ||
| let WASM_VECTOR_LEN = 0; | ||
| let cachedDataViewMemory0 = null; | ||
| function getDataViewMemory0() { | ||
| if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) { | ||
| cachedDataViewMemory0 = new DataView(wasm.memory.buffer); | ||
| } | ||
| return cachedDataViewMemory0; | ||
| } | ||
| function getStringFromWasm0(ptr, len) { | ||
| ptr = ptr >>> 0; | ||
| return decodeText(ptr, len); | ||
| } | ||
| let cachedUint8ArrayMemory0 = null; | ||
| function getUint8ArrayMemory0() { | ||
@@ -84,17 +369,16 @@ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) { | ||
| const cachedTextEncoder = new TextEncoder(); | ||
| if (!('encodeInto' in cachedTextEncoder)) { | ||
| cachedTextEncoder.encodeInto = function (arg, view) { | ||
| const buf = cachedTextEncoder.encode(arg); | ||
| view.set(buf); | ||
| return { | ||
| read: arg.length, | ||
| written: buf.length | ||
| }; | ||
| function handleError(f, args) { | ||
| try { | ||
| return f.apply(this, args); | ||
| } catch (e) { | ||
| const idx = addToExternrefTable0(e); | ||
| wasm.__wbindgen_exn_store(idx); | ||
| } | ||
| } | ||
| function isLikeNone(x) { | ||
| return x === undefined || x === null; | ||
| } | ||
| function passStringToWasm0(arg, malloc, realloc) { | ||
| if (realloc === undefined) { | ||
@@ -120,3 +404,2 @@ const buf = cachedTextEncoder.encode(arg); | ||
| } | ||
| if (offset !== len) { | ||
@@ -138,15 +421,10 @@ if (offset !== 0) { | ||
| let cachedDataViewMemory0 = null; | ||
| function getDataViewMemory0() { | ||
| if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) { | ||
| cachedDataViewMemory0 = new DataView(wasm.memory.buffer); | ||
| } | ||
| return cachedDataViewMemory0; | ||
| function takeFromExternrefTable0(idx) { | ||
| const value = wasm.__wbindgen_externrefs.get(idx); | ||
| wasm.__externref_table_dealloc(idx); | ||
| return value; | ||
| } | ||
| let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); | ||
| cachedTextDecoder.decode(); | ||
| const MAX_SAFARI_DECODE_BYTES = 2146435072; | ||
@@ -164,101 +442,27 @@ let numBytesDecoded = 0; | ||
| function getStringFromWasm0(ptr, len) { | ||
| ptr = ptr >>> 0; | ||
| return decodeText(ptr, len); | ||
| } | ||
| const cachedTextEncoder = new TextEncoder(); | ||
| function addToExternrefTable0(obj) { | ||
| const idx = wasm.__externref_table_alloc(); | ||
| wasm.__wbindgen_externrefs.set(idx, obj); | ||
| return idx; | ||
| if (!('encodeInto' in cachedTextEncoder)) { | ||
| cachedTextEncoder.encodeInto = function (arg, view) { | ||
| const buf = cachedTextEncoder.encode(arg); | ||
| view.set(buf); | ||
| return { | ||
| read: arg.length, | ||
| written: buf.length | ||
| }; | ||
| }; | ||
| } | ||
| function handleError(f, args) { | ||
| try { | ||
| return f.apply(this, args); | ||
| } catch (e) { | ||
| const idx = addToExternrefTable0(e); | ||
| wasm.__wbindgen_exn_store(idx); | ||
| } | ||
| } | ||
| let WASM_VECTOR_LEN = 0; | ||
| export function init_panic_hook() { | ||
| wasm.init_panic_hook(); | ||
| let wasmModule, wasm; | ||
| function __wbg_finalize_init(instance, module) { | ||
| wasm = instance.exports; | ||
| wasmModule = module; | ||
| cachedDataViewMemory0 = null; | ||
| cachedUint8ArrayMemory0 = null; | ||
| wasm.__wbindgen_start(); | ||
| return wasm; | ||
| } | ||
| function takeFromExternrefTable0(idx) { | ||
| const value = wasm.__wbindgen_externrefs.get(idx); | ||
| wasm.__externref_table_dealloc(idx); | ||
| return value; | ||
| } | ||
| /** | ||
| * @param {string} input | ||
| * @returns {any} | ||
| */ | ||
| export function parse(input) { | ||
| const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
| const len0 = WASM_VECTOR_LEN; | ||
| const ret = wasm.parse(ptr0, len0); | ||
| if (ret[2]) { | ||
| throw takeFromExternrefTable0(ret[1]); | ||
| } | ||
| return takeFromExternrefTable0(ret[0]); | ||
| } | ||
| /** | ||
| * @param {any} input | ||
| * @param {IStringifyOptions | null} [opts] | ||
| * @returns {string} | ||
| */ | ||
| export function stringify(input, opts) { | ||
| let deferred2_0; | ||
| let deferred2_1; | ||
| try { | ||
| const ret = wasm.stringify(input, isLikeNone(opts) ? 0 : addToExternrefTable0(opts)); | ||
| var ptr1 = ret[0]; | ||
| var len1 = ret[1]; | ||
| if (ret[3]) { | ||
| ptr1 = 0; len1 = 0; | ||
| throw takeFromExternrefTable0(ret[2]); | ||
| } | ||
| deferred2_0 = ptr1; | ||
| deferred2_1 = len1; | ||
| return getStringFromWasm0(ptr1, len1); | ||
| } finally { | ||
| wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); | ||
| } | ||
| } | ||
| /** | ||
| * @param {string} input | ||
| * @param {string} path | ||
| * @param {any} value | ||
| * @param {IEditOptions | null} [opts] | ||
| * @returns {string} | ||
| */ | ||
| export function edit(input, path, value, opts) { | ||
| let deferred4_0; | ||
| let deferred4_1; | ||
| try { | ||
| const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
| const len0 = WASM_VECTOR_LEN; | ||
| const ptr1 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
| const len1 = WASM_VECTOR_LEN; | ||
| const ret = wasm.edit(ptr0, len0, ptr1, len1, value, isLikeNone(opts) ? 0 : addToExternrefTable0(opts)); | ||
| var ptr3 = ret[0]; | ||
| var len3 = ret[1]; | ||
| if (ret[3]) { | ||
| ptr3 = 0; len3 = 0; | ||
| throw takeFromExternrefTable0(ret[2]); | ||
| } | ||
| deferred4_0 = ptr3; | ||
| deferred4_1 = len3; | ||
| return getStringFromWasm0(ptr3, len3); | ||
| } finally { | ||
| wasm.__wbindgen_free(deferred4_0, deferred4_1, 1); | ||
| } | ||
| } | ||
| const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']); | ||
| async function __wbg_load(module, imports) { | ||
@@ -269,5 +473,4 @@ if (typeof Response === 'function' && module instanceof Response) { | ||
| return await WebAssembly.instantiateStreaming(module, imports); | ||
| } catch (e) { | ||
| const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type); | ||
| const validResponse = module.ok && expectedResponseType(module.type); | ||
@@ -277,5 +480,3 @@ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') { | ||
| } else { | ||
| throw e; | ||
| } | ||
| } else { throw e; } | ||
| } | ||
@@ -286,3 +487,2 @@ } | ||
| return await WebAssembly.instantiate(bytes, imports); | ||
| } else { | ||
@@ -293,3 +493,2 @@ const instance = await WebAssembly.instantiate(module, imports); | ||
| return { instance, module }; | ||
| } else { | ||
@@ -299,203 +498,11 @@ return instance; | ||
| } | ||
| } | ||
| function __wbg_get_imports() { | ||
| const imports = {}; | ||
| imports.wbg = {}; | ||
| imports.wbg.__wbg___wbindgen_boolean_get_6d5a1ee65bab5f68 = function(arg0) { | ||
| const v = arg0; | ||
| const ret = typeof(v) === 'boolean' ? v : undefined; | ||
| return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0; | ||
| }; | ||
| imports.wbg.__wbg___wbindgen_debug_string_df47ffb5e35e6763 = function(arg0, arg1) { | ||
| const ret = debugString(arg1); | ||
| const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
| const len1 = WASM_VECTOR_LEN; | ||
| getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); | ||
| getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); | ||
| }; | ||
| imports.wbg.__wbg___wbindgen_is_bigint_cb320707dcd35f0b = function(arg0) { | ||
| const ret = typeof(arg0) === 'bigint'; | ||
| return ret; | ||
| }; | ||
| imports.wbg.__wbg___wbindgen_is_null_5e69f72e906cc57c = function(arg0) { | ||
| const ret = arg0 === null; | ||
| return ret; | ||
| }; | ||
| imports.wbg.__wbg___wbindgen_is_object_c818261d21f283a4 = function(arg0) { | ||
| const val = arg0; | ||
| const ret = typeof(val) === 'object' && val !== null; | ||
| return ret; | ||
| }; | ||
| imports.wbg.__wbg___wbindgen_is_undefined_2d472862bd29a478 = function(arg0) { | ||
| const ret = arg0 === undefined; | ||
| return ret; | ||
| }; | ||
| imports.wbg.__wbg___wbindgen_number_get_a20bf9b85341449d = function(arg0, arg1) { | ||
| const obj = arg1; | ||
| const ret = typeof(obj) === 'number' ? obj : undefined; | ||
| getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true); | ||
| getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true); | ||
| }; | ||
| imports.wbg.__wbg___wbindgen_string_get_e4f06c90489ad01b = function(arg0, arg1) { | ||
| const obj = arg1; | ||
| const ret = typeof(obj) === 'string' ? obj : undefined; | ||
| var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
| var len1 = WASM_VECTOR_LEN; | ||
| getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); | ||
| getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); | ||
| }; | ||
| imports.wbg.__wbg___wbindgen_throw_b855445ff6a94295 = function(arg0, arg1) { | ||
| throw new Error(getStringFromWasm0(arg0, arg1)); | ||
| }; | ||
| imports.wbg.__wbg_entries_e171b586f8f6bdbf = function(arg0) { | ||
| const ret = Object.entries(arg0); | ||
| return ret; | ||
| }; | ||
| imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) { | ||
| let deferred0_0; | ||
| let deferred0_1; | ||
| try { | ||
| deferred0_0 = arg0; | ||
| deferred0_1 = arg1; | ||
| console.error(getStringFromWasm0(arg0, arg1)); | ||
| } finally { | ||
| wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); | ||
| function expectedResponseType(type) { | ||
| switch (type) { | ||
| case 'basic': case 'cors': case 'default': return true; | ||
| } | ||
| }; | ||
| imports.wbg.__wbg_fromEntries_c7159f3787268c9f = function() { return handleError(function (arg0) { | ||
| const ret = Object.fromEntries(arg0); | ||
| return ret; | ||
| }, arguments) }; | ||
| imports.wbg.__wbg_getUTCDate_2e370a2582285f47 = function(arg0) { | ||
| const ret = arg0.getUTCDate(); | ||
| return ret; | ||
| }; | ||
| imports.wbg.__wbg_getUTCFullYear_ca931173566703b5 = function(arg0) { | ||
| const ret = arg0.getUTCFullYear(); | ||
| return ret; | ||
| }; | ||
| imports.wbg.__wbg_getUTCHours_91e83151adbfa7f1 = function(arg0) { | ||
| const ret = arg0.getUTCHours(); | ||
| return ret; | ||
| }; | ||
| imports.wbg.__wbg_getUTCMilliseconds_9d8be3e2d4c267dc = function(arg0) { | ||
| const ret = arg0.getUTCMilliseconds(); | ||
| return ret; | ||
| }; | ||
| imports.wbg.__wbg_getUTCMinutes_aa830beac26fad37 = function(arg0) { | ||
| const ret = arg0.getUTCMinutes(); | ||
| return ret; | ||
| }; | ||
| imports.wbg.__wbg_getUTCMonth_429626bf1df5ca4b = function(arg0) { | ||
| const ret = arg0.getUTCMonth(); | ||
| return ret; | ||
| }; | ||
| imports.wbg.__wbg_getUTCSeconds_fee927200975b51a = function(arg0) { | ||
| const ret = arg0.getUTCSeconds(); | ||
| return ret; | ||
| }; | ||
| imports.wbg.__wbg_get_7bed016f185add81 = function(arg0, arg1) { | ||
| const ret = arg0[arg1 >>> 0]; | ||
| return ret; | ||
| }; | ||
| imports.wbg.__wbg_instanceof_Date_79a0f671f36947f2 = function(arg0) { | ||
| let result; | ||
| try { | ||
| result = arg0 instanceof Date; | ||
| } catch (_) { | ||
| result = false; | ||
| } | ||
| const ret = result; | ||
| return ret; | ||
| }; | ||
| imports.wbg.__wbg_instanceof_Object_10bb762262230c68 = function(arg0) { | ||
| let result; | ||
| try { | ||
| result = arg0 instanceof Object; | ||
| } catch (_) { | ||
| result = false; | ||
| } | ||
| const ret = result; | ||
| return ret; | ||
| }; | ||
| imports.wbg.__wbg_isArray_643fafc484312e19 = function(arg0) { | ||
| const ret = Array.isArray(arg0); | ||
| return ret; | ||
| }; | ||
| imports.wbg.__wbg_isArray_96e0af9891d0945d = function(arg0) { | ||
| const ret = Array.isArray(arg0); | ||
| return ret; | ||
| }; | ||
| imports.wbg.__wbg_length_cdd215e10d9dd507 = function(arg0) { | ||
| const ret = arg0.length; | ||
| return ret; | ||
| }; | ||
| imports.wbg.__wbg_log_8cec76766b8c0e33 = function(arg0) { | ||
| console.log(arg0); | ||
| }; | ||
| imports.wbg.__wbg_new_8a6f238a6ece86ea = function() { | ||
| const ret = new Error(); | ||
| return ret; | ||
| }; | ||
| imports.wbg.__wbg_new_e17d9f43105b08be = function() { | ||
| const ret = new Array(); | ||
| return ret; | ||
| }; | ||
| imports.wbg.__wbg_new_with_length_31d2669cb75c5215 = function(arg0) { | ||
| const ret = new Array(arg0 >>> 0); | ||
| return ret; | ||
| }; | ||
| imports.wbg.__wbg_push_df81a39d04db858c = function(arg0, arg1) { | ||
| const ret = arg0.push(arg1); | ||
| return ret; | ||
| }; | ||
| imports.wbg.__wbg_set_c213c871859d6500 = function(arg0, arg1, arg2) { | ||
| arg0[arg1 >>> 0] = arg2; | ||
| }; | ||
| imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) { | ||
| const ret = arg1.stack; | ||
| const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
| const len1 = WASM_VECTOR_LEN; | ||
| getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); | ||
| getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); | ||
| }; | ||
| imports.wbg.__wbg_warn_1d74dddbe2fd1dbb = function(arg0) { | ||
| console.warn(arg0); | ||
| }; | ||
| imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) { | ||
| // Cast intrinsic for `Ref(String) -> Externref`. | ||
| const ret = getStringFromWasm0(arg0, arg1); | ||
| return ret; | ||
| }; | ||
| imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) { | ||
| // Cast intrinsic for `F64 -> Externref`. | ||
| const ret = arg0; | ||
| return ret; | ||
| }; | ||
| imports.wbg.__wbindgen_init_externref_table = function() { | ||
| const table = wasm.__wbindgen_externrefs; | ||
| const offset = table.grow(4); | ||
| table.set(0, undefined); | ||
| table.set(offset + 0, undefined); | ||
| table.set(offset + 1, null); | ||
| table.set(offset + 2, true); | ||
| table.set(offset + 3, false); | ||
| ; | ||
| }; | ||
| return imports; | ||
| return false; | ||
| } | ||
| } | ||
| function __wbg_finalize_init(instance, module) { | ||
| wasm = instance.exports; | ||
| __wbg_init.__wbindgen_wasm_module = module; | ||
| cachedDataViewMemory0 = null; | ||
| cachedUint8ArrayMemory0 = null; | ||
| wasm.__wbindgen_start(); | ||
| return wasm; | ||
| } | ||
| function initSync(module) { | ||
@@ -505,3 +512,3 @@ if (wasm !== undefined) return wasm; | ||
| if (typeof module !== 'undefined') { | ||
| if (module !== undefined) { | ||
| if (Object.getPrototypeOf(module) === Object.prototype) { | ||
@@ -515,9 +522,6 @@ ({module} = module) | ||
| const imports = __wbg_get_imports(); | ||
| if (!(module instanceof WebAssembly.Module)) { | ||
| module = new WebAssembly.Module(module); | ||
| } | ||
| const instance = new WebAssembly.Instance(module, imports); | ||
| return __wbg_finalize_init(instance, module); | ||
@@ -530,3 +534,3 @@ } | ||
| if (typeof module_or_path !== 'undefined') { | ||
| if (module_or_path !== undefined) { | ||
| if (Object.getPrototypeOf(module_or_path) === Object.prototype) { | ||
@@ -539,3 +543,3 @@ ({module_or_path} = module_or_path) | ||
| if (typeof module_or_path === 'undefined') { | ||
| if (module_or_path === undefined) { | ||
| module_or_path = new URL('index_bg.wasm', import.meta.url); | ||
@@ -554,3 +558,2 @@ } | ||
| export { initSync }; | ||
| export default __wbg_init; | ||
| export { initSync, __wbg_init as default }; |
+3
-2
| { | ||
| "name": "@rainbowatcher/toml-edit-js", | ||
| "type": "module", | ||
| "version": "0.6.4", | ||
| "version": "0.6.5", | ||
| "description": "Edit TOML files in JavaScript", | ||
@@ -19,3 +19,4 @@ "author": "rainbowatcher <rainobw-w@qq.com>", | ||
| ".": "./shims.js", | ||
| "./index": "./index.js" | ||
| "./index": "./index.js", | ||
| "./index_bg.wasm": "./index_bg.wasm" | ||
| }, | ||
@@ -22,0 +23,0 @@ "types": "shims.d.ts", |
+52
-31
| /* tslint:disable */ | ||
| /* eslint-disable */ | ||
| export function init_panic_hook(): void; | ||
| export function parse(input: string): any; | ||
| export function stringify(input: any, opts?: IStringifyOptions | null): string; | ||
| export function edit(input: string, path: string, value: any, opts?: IEditOptions | null): string; | ||
@@ -40,39 +36,64 @@ interface IEditOptions { | ||
| /** | ||
| * Edits a TOML document by path and returns the updated text. | ||
| * | ||
| * Path segments support dotted keys and array index notation like `foo.bar.[0]`. | ||
| */ | ||
| export function edit(input: string, path: string, value: any, opts?: IEditOptions | null): string; | ||
| /** | ||
| * Installs panic hooks for better browser console error output. | ||
| */ | ||
| export function init_panic_hook(): void; | ||
| /** | ||
| * Parses a TOML string into a JavaScript value tree. | ||
| */ | ||
| export function parse(input: string): any; | ||
| /** | ||
| * Serializes a JavaScript value into TOML text. | ||
| * | ||
| * The conversion strategy depends on value shape and stringify options. | ||
| */ | ||
| export function stringify(input: any, opts?: IStringifyOptions | null): string; | ||
| export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; | ||
| export interface InitOutput { | ||
| readonly memory: WebAssembly.Memory; | ||
| readonly init_panic_hook: () => void; | ||
| readonly parse: (a: number, b: number) => [number, number, number]; | ||
| readonly stringify: (a: any, b: number) => [number, number, number, number]; | ||
| readonly edit: (a: number, b: number, c: number, d: number, e: any, f: number) => [number, number, number, number]; | ||
| readonly __wbindgen_malloc: (a: number, b: number) => number; | ||
| readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number; | ||
| readonly __wbindgen_free: (a: number, b: number, c: number) => void; | ||
| readonly __wbindgen_exn_store: (a: number) => void; | ||
| readonly __externref_table_alloc: () => number; | ||
| readonly __wbindgen_externrefs: WebAssembly.Table; | ||
| readonly __externref_table_dealloc: (a: number) => void; | ||
| readonly __wbindgen_start: () => void; | ||
| readonly memory: WebAssembly.Memory; | ||
| readonly edit: (a: number, b: number, c: number, d: number, e: any, f: number) => [number, number, number, number]; | ||
| readonly init_panic_hook: () => void; | ||
| readonly parse: (a: number, b: number) => [number, number, number]; | ||
| readonly stringify: (a: any, b: number) => [number, number, number, number]; | ||
| readonly __wbindgen_malloc: (a: number, b: number) => number; | ||
| readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number; | ||
| readonly __wbindgen_free: (a: number, b: number, c: number) => void; | ||
| readonly __wbindgen_exn_store: (a: number) => void; | ||
| readonly __externref_table_alloc: () => number; | ||
| readonly __wbindgen_externrefs: WebAssembly.Table; | ||
| readonly __externref_table_dealloc: (a: number) => void; | ||
| readonly __wbindgen_start: () => void; | ||
| } | ||
| export type SyncInitInput = BufferSource | WebAssembly.Module; | ||
| /** | ||
| * Instantiates the given `module`, which can either be bytes or | ||
| * a precompiled `WebAssembly.Module`. | ||
| * | ||
| * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated. | ||
| * | ||
| * @returns {InitOutput} | ||
| */ | ||
| * Instantiates the given `module`, which can either be bytes or | ||
| * a precompiled `WebAssembly.Module`. | ||
| * | ||
| * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated. | ||
| * | ||
| * @returns {InitOutput} | ||
| */ | ||
| export function initSync(module?: { module: SyncInitInput } | SyncInitInput): InitOutput; | ||
| /** | ||
| * If `module_or_path` is {RequestInfo} or {URL}, makes a request and | ||
| * for everything else, calls `WebAssembly.instantiate` directly. | ||
| * | ||
| * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated. | ||
| * | ||
| * @returns {Promise<InitOutput>} | ||
| */ | ||
| * If `module_or_path` is {RequestInfo} or {URL}, makes a request and | ||
| * for everything else, calls `WebAssembly.instantiate` directly. | ||
| * | ||
| * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated. | ||
| * | ||
| * @returns {Promise<InitOutput>} | ||
| */ | ||
| export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>; |
+90
-44
| import originalInit, { initSync as originalInitSync } from "./index.js" | ||
| import { parse as original_parse, stringify as original_stringify, edit as original_edit } from "./index.js" | ||
| import { edit as original_edit, parse as original_parse, stringify as original_stringify } from "./index.js" | ||
| const wasmUrl = new URL("index_bg.wasm", import.meta.url); | ||
| let wasmBuffer, wasm, fs; | ||
| const isDeno = !!globalThis.Deno; | ||
| let wasmBuffer, wasm, nodeFs; | ||
| const isDeno = typeof globalThis.Deno !== "undefined"; | ||
| const isNode = globalThis.process?.release?.name === "node"; | ||
| const isBrowser = !!globalThis.window; | ||
| switch (wasmUrl.protocol) { | ||
| case "file:": { | ||
| if (isNode) { | ||
| fs = await import("node:fs"); | ||
| } | ||
| break | ||
| } | ||
| case "https:": | ||
| case "http:": { | ||
| break; | ||
| } | ||
| default: | ||
| throw new Error(`Unsupported protocol: ${wasmUrl.protocol}`); | ||
| const isBun = typeof globalThis.Bun !== "undefined"; | ||
| const isBrowser = typeof globalThis.window !== "undefined"; | ||
| const isFileProtocol = wasmUrl.protocol === "file:"; | ||
| if ((isNode || isBun) && isFileProtocol) { | ||
| nodeFs = await import("node:fs"); | ||
| } | ||
| function __initWasmCodeSync() { | ||
| if (isNode) { // bun should same as node | ||
| wasmBuffer = fs.readFileSync(wasmUrl); | ||
| if (isNode || isBun) { | ||
| if (!isFileProtocol) { | ||
| throw new Error("synchronous init only supports file protocol in node/bun"); | ||
| } | ||
| wasmBuffer = nodeFs.readFileSync(wasmUrl); | ||
| } else if (isDeno) { | ||
@@ -32,43 +26,95 @@ wasmBuffer = Deno.readFileSync(wasmUrl); | ||
| } | ||
| return wasmBuffer; | ||
| } | ||
| async function __initWasmCodeAsync() { | ||
| if (isNode) { // bun should same as node | ||
| wasmBuffer = await fs.promises.readFile(wasmUrl); | ||
| if (isNode || isBun) { | ||
| if (isFileProtocol) { | ||
| wasmBuffer = await nodeFs.promises.readFile(wasmUrl); | ||
| } else { | ||
| wasmBuffer = wasmUrl; | ||
| } | ||
| } else if (isDeno) { | ||
| wasmBuffer = await Deno.readFile(wasmUrl); | ||
| if (isFileProtocol) { | ||
| wasmBuffer = await Deno.readFile(wasmUrl); | ||
| } else { | ||
| wasmBuffer = wasmUrl; | ||
| } | ||
| } else if (isBrowser) { | ||
| wasmBuffer = await fetch(wasmUrl); | ||
| wasmBuffer = wasmUrl; | ||
| } else { | ||
| throw new Error("asynchronous init not support for current platform"); | ||
| } | ||
| return wasmBuffer; | ||
| } | ||
| export function initSync(module_or_path) { | ||
| if (wasm) return wasm; | ||
| if (wasmBuffer === undefined) { | ||
| if (module_or_path !== undefined | ||
| && module_or_path !== null | ||
| && typeof module_or_path === 'object' | ||
| && Object.keys(module_or_path).length > 0 | ||
| ) { | ||
| wasm = originalInitSync(module_or_path); | ||
| return | ||
| function wrapSyncInitArg(module_or_path) { | ||
| if (module_or_path === undefined) { | ||
| return undefined; | ||
| } | ||
| if ( | ||
| module_or_path !== null | ||
| && typeof module_or_path === "object" | ||
| ) { | ||
| if (Object.hasOwn(module_or_path, "module")) { | ||
| return module_or_path; | ||
| } | ||
| __initWasmCodeSync() | ||
| if (Object.keys(module_or_path).length === 0) { | ||
| return undefined; | ||
| } | ||
| } | ||
| originalInitSync({ module: wasmBuffer }); | ||
| return { module: module_or_path }; | ||
| } | ||
| export async function init() { | ||
| if (wasm) return wasm; | ||
| if (wasmBuffer === undefined) { | ||
| await __initWasmCodeAsync() | ||
| function wrapInitArg(module_or_path) { | ||
| if (module_or_path === undefined) { | ||
| return undefined; | ||
| } | ||
| if ( | ||
| module_or_path !== null | ||
| && typeof module_or_path === "object" | ||
| ) { | ||
| if (Object.hasOwn(module_or_path, "module_or_path")) { | ||
| return module_or_path; | ||
| } | ||
| if ( | ||
| Object.getPrototypeOf(module_or_path) === Object.prototype | ||
| && Object.keys(module_or_path).length === 0 | ||
| ) { | ||
| return undefined; | ||
| } | ||
| } | ||
| return { module_or_path }; | ||
| } | ||
| wasm = await originalInit({ module_or_path: wasmBuffer }) | ||
| function isInitialized() { | ||
| return wasm !== undefined; | ||
| } | ||
| export function initSync(module_or_path) { | ||
| if (isInitialized()) return wasm; | ||
| if (module_or_path === undefined) { | ||
| module_or_path = __initWasmCodeSync(); | ||
| } | ||
| const wrapped = wrapSyncInitArg(module_or_path); | ||
| wasm = wrapped === undefined | ||
| ? originalInitSync() | ||
| : originalInitSync(wrapped); | ||
| return wasm; | ||
| } | ||
| export async function init(module_or_path) { | ||
| if (isInitialized()) return wasm; | ||
| if (module_or_path === undefined) { | ||
| module_or_path = await __initWasmCodeAsync(); | ||
| } | ||
| const wrapped = wrapInitArg(module_or_path); | ||
| wasm = wrapped === undefined | ||
| ? await originalInit() | ||
| : await originalInit(wrapped); | ||
| return wasm; | ||
| } | ||
| function checkInit() { | ||
| if (wasmBuffer === undefined) { | ||
| if (!isInitialized()) { | ||
| throw new Error("WASM module not initialized"); | ||
@@ -80,6 +126,6 @@ } | ||
| export function parse(input) { checkInit(); if (typeof input !== "string") { throw new Error("Invalid parameter: input must be a string"); }; return original_parse(input); } | ||
| export function stringify(input, opts) { checkInit(); ; return original_stringify(input, opts); } | ||
| export function edit(input, path, value, opts) { checkInit(); if (typeof input !== "string") { throw new Error("Invalid parameter: input must be a string"); } | ||
| if (typeof path !== "string") { throw new Error("Invalid parameter: path must be a string"); } | ||
| ; return original_edit(input, path, value, opts); } | ||
| ; return original_edit(input, path, value, opts); } | ||
| export function parse(input) { checkInit(); if (typeof input !== "string") { throw new Error("Invalid parameter: input must be a string"); }; return original_parse(input); } | ||
| export function stringify(input, opts) { checkInit(); ; return original_stringify(input, opts); } |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
349733
4.56%714
12.09%