intl-segmenter-polyfill-rs
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -70,40 +70,1 @@ /* tslint:disable */ | ||
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; | ||
export interface InitOutput { | ||
readonly memory: WebAssembly.Memory; | ||
readonly __wbg_segmenter_free: (a: number) => void; | ||
readonly segmenter_: (a: number) => void; | ||
readonly segmenter_new: (a: number, b: number) => number; | ||
readonly segmenter_segment: (a: number, b: number, c: number) => number; | ||
readonly __wbg_segments_free: (a: number) => void; | ||
readonly segments_next: (a: number, b: number) => void; | ||
readonly start: () => void; | ||
readonly __wbindgen_malloc: (a: number, b: number) => number; | ||
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number; | ||
readonly __wbindgen_add_to_stack_pointer: (a: number) => number; | ||
readonly __wbindgen_free: (a: number, b: number, c: 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 {SyncInitInput} module | ||
* | ||
* @returns {InitOutput} | ||
*/ | ||
export function initSync(module: SyncInitInput): InitOutput; | ||
/** | ||
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and | ||
* for everything else, calls `WebAssembly.instantiate` directly. | ||
* | ||
* @param {InitInput | Promise<InitInput>} module_or_path | ||
* | ||
* @returns {Promise<InitOutput>} | ||
*/ | ||
export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>; |
@@ -1,4 +0,6 @@ | ||
import { __make_iter } from './snippets/intl-segmenter-polyfill-rs-87dd4e77192516c7/inline0.js'; | ||
let imports = {}; | ||
imports['__wbindgen_placeholder__'] = module.exports; | ||
let wasm; | ||
const { __make_iter } = require(String.raw`./snippets/intl-segmenter-polyfill-rs-ccb3439a48fc4c79/inline0.js`); | ||
const { TextDecoder, TextEncoder } = require(`util`); | ||
@@ -25,5 +27,5 @@ const heap = new Array(128).fill(undefined); | ||
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } ); | ||
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); | ||
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }; | ||
cachedTextDecoder.decode(); | ||
@@ -55,3 +57,3 @@ let cachedUint8Memory0 = null; | ||
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } ); | ||
let cachedTextEncoder = new TextEncoder('utf-8'); | ||
@@ -197,9 +199,9 @@ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' | ||
*/ | ||
export function start() { | ||
module.exports.start = function() { | ||
wasm.start(); | ||
} | ||
}; | ||
/** | ||
*/ | ||
export class Segmenter { | ||
class Segmenter { | ||
@@ -259,5 +261,6 @@ static __wrap(ptr) { | ||
} | ||
module.exports.Segmenter = Segmenter; | ||
/** | ||
*/ | ||
export class Segments { | ||
class Segments { | ||
@@ -302,248 +305,201 @@ static __wrap(ptr) { | ||
} | ||
module.exports.Segments = Segments; | ||
async function __wbg_load(module, imports) { | ||
if (typeof Response === 'function' && module instanceof Response) { | ||
if (typeof WebAssembly.instantiateStreaming === 'function') { | ||
try { | ||
return await WebAssembly.instantiateStreaming(module, imports); | ||
module.exports.__wbindgen_object_drop_ref = function(arg0) { | ||
takeObject(arg0); | ||
}; | ||
} catch (e) { | ||
if (module.headers.get('Content-Type') != 'application/wasm') { | ||
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); | ||
module.exports.__wbg_makeiter_211b28f7d6fc5ef7 = function(arg0) { | ||
__make_iter(getObject(arg0)); | ||
}; | ||
} else { | ||
throw e; | ||
} | ||
} | ||
} | ||
module.exports.__wbg_segments_new = function(arg0) { | ||
const ret = Segments.__wrap(arg0); | ||
return addHeapObject(ret); | ||
}; | ||
const bytes = await module.arrayBuffer(); | ||
return await WebAssembly.instantiate(bytes, imports); | ||
module.exports.__wbindgen_string_new = function(arg0, arg1) { | ||
const ret = getStringFromWasm0(arg0, arg1); | ||
return addHeapObject(ret); | ||
}; | ||
} else { | ||
const instance = await WebAssembly.instantiate(module, imports); | ||
module.exports.__wbindgen_is_undefined = function(arg0) { | ||
const ret = getObject(arg0) === undefined; | ||
return ret; | ||
}; | ||
if (instance instanceof WebAssembly.Instance) { | ||
return { instance, module }; | ||
module.exports.__wbindgen_in = function(arg0, arg1) { | ||
const ret = getObject(arg0) in getObject(arg1); | ||
return ret; | ||
}; | ||
} else { | ||
return instance; | ||
} | ||
module.exports.__wbindgen_string_get = function(arg0, arg1) { | ||
const obj = getObject(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; | ||
getInt32Memory0()[arg0 / 4 + 1] = len1; | ||
getInt32Memory0()[arg0 / 4 + 0] = ptr1; | ||
}; | ||
module.exports.__wbindgen_is_object = function(arg0) { | ||
const val = getObject(arg0); | ||
const ret = typeof(val) === 'object' && val !== null; | ||
return ret; | ||
}; | ||
module.exports.__wbg_new_abda76e883ba8a5f = function() { | ||
const ret = new Error(); | ||
return addHeapObject(ret); | ||
}; | ||
module.exports.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) { | ||
const ret = getObject(arg1).stack; | ||
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
const len1 = WASM_VECTOR_LEN; | ||
getInt32Memory0()[arg0 / 4 + 1] = len1; | ||
getInt32Memory0()[arg0 / 4 + 0] = ptr1; | ||
}; | ||
module.exports.__wbg_error_f851667af71bcfc6 = 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 __wbg_get_imports() { | ||
const imports = {}; | ||
imports.wbg = {}; | ||
imports.wbg.__wbindgen_object_drop_ref = function(arg0) { | ||
takeObject(arg0); | ||
}; | ||
imports.wbg.__wbg_makeiter_a960a0eac5f84710 = function(arg0) { | ||
__make_iter(getObject(arg0)); | ||
}; | ||
imports.wbg.__wbg_segments_new = function(arg0) { | ||
const ret = Segments.__wrap(arg0); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbindgen_string_new = function(arg0, arg1) { | ||
const ret = getStringFromWasm0(arg0, arg1); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbindgen_is_undefined = function(arg0) { | ||
const ret = getObject(arg0) === undefined; | ||
return ret; | ||
}; | ||
imports.wbg.__wbindgen_in = function(arg0, arg1) { | ||
const ret = getObject(arg0) in getObject(arg1); | ||
return ret; | ||
}; | ||
imports.wbg.__wbindgen_string_get = function(arg0, arg1) { | ||
const obj = getObject(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; | ||
getInt32Memory0()[arg0 / 4 + 1] = len1; | ||
getInt32Memory0()[arg0 / 4 + 0] = ptr1; | ||
}; | ||
imports.wbg.__wbindgen_is_object = function(arg0) { | ||
const val = getObject(arg0); | ||
const ret = typeof(val) === 'object' && val !== null; | ||
return ret; | ||
}; | ||
imports.wbg.__wbg_new_abda76e883ba8a5f = function() { | ||
const ret = new Error(); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) { | ||
const ret = getObject(arg1).stack; | ||
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
const len1 = WASM_VECTOR_LEN; | ||
getInt32Memory0()[arg0 / 4 + 1] = len1; | ||
getInt32Memory0()[arg0 / 4 + 0] = ptr1; | ||
}; | ||
imports.wbg.__wbg_error_f851667af71bcfc6 = 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); | ||
} | ||
}; | ||
imports.wbg.__wbindgen_number_new = function(arg0) { | ||
const ret = arg0; | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) { | ||
const ret = BigInt.asUintN(64, arg0); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbindgen_object_clone_ref = function(arg0) { | ||
const ret = getObject(arg0); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbindgen_jsval_loose_eq = function(arg0, arg1) { | ||
const ret = getObject(arg0) == getObject(arg1); | ||
return ret; | ||
}; | ||
imports.wbg.__wbindgen_boolean_get = function(arg0) { | ||
const v = getObject(arg0); | ||
const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; | ||
return ret; | ||
}; | ||
imports.wbg.__wbindgen_number_get = function(arg0, arg1) { | ||
const obj = getObject(arg1); | ||
const ret = typeof(obj) === 'number' ? obj : undefined; | ||
getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; | ||
getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); | ||
}; | ||
imports.wbg.__wbg_getwithrefkey_15c62c2b8546208d = function(arg0, arg1) { | ||
const ret = getObject(arg0)[getObject(arg1)]; | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_set_20cbc34131e76824 = function(arg0, arg1, arg2) { | ||
getObject(arg0)[takeObject(arg1)] = takeObject(arg2); | ||
}; | ||
imports.wbg.__wbindgen_error_new = function(arg0, arg1) { | ||
const ret = new Error(getStringFromWasm0(arg0, arg1)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_new_b51585de1b234aff = function() { | ||
const ret = new Object(); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_instanceof_ArrayBuffer_39ac22089b74fddb = function(arg0) { | ||
let result; | ||
try { | ||
result = getObject(arg0) instanceof ArrayBuffer; | ||
} catch { | ||
result = false; | ||
} | ||
const ret = result; | ||
return ret; | ||
}; | ||
imports.wbg.__wbg_getPrototypeOf_0953c64f6ba47b38 = function(arg0) { | ||
const ret = Object.getPrototypeOf(getObject(arg0)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_new_0d7da8e129c00c84 = function(arg0, arg1) { | ||
const ret = new TypeError(getStringFromWasm0(arg0, arg1)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_buffer_085ec1f694018c4f = function(arg0) { | ||
const ret = getObject(arg0).buffer; | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_new_8125e318e6245eed = function(arg0) { | ||
const ret = new Uint8Array(getObject(arg0)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_set_5cf90238115182c3 = function(arg0, arg1, arg2) { | ||
getObject(arg0).set(getObject(arg1), arg2 >>> 0); | ||
}; | ||
imports.wbg.__wbg_length_72e2208bbc0efc61 = function(arg0) { | ||
const ret = getObject(arg0).length; | ||
return ret; | ||
}; | ||
imports.wbg.__wbg_instanceof_Uint8Array_d8d9cb2b8e8ac1d4 = function(arg0) { | ||
let result; | ||
try { | ||
result = getObject(arg0) instanceof Uint8Array; | ||
} catch { | ||
result = false; | ||
} | ||
const ret = result; | ||
return ret; | ||
}; | ||
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) { | ||
const ret = debugString(getObject(arg1)); | ||
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
const len1 = WASM_VECTOR_LEN; | ||
getInt32Memory0()[arg0 / 4 + 1] = len1; | ||
getInt32Memory0()[arg0 / 4 + 0] = ptr1; | ||
}; | ||
imports.wbg.__wbindgen_throw = function(arg0, arg1) { | ||
throw new Error(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
imports.wbg.__wbindgen_memory = function() { | ||
const ret = wasm.memory; | ||
return addHeapObject(ret); | ||
}; | ||
module.exports.__wbindgen_number_new = function(arg0) { | ||
const ret = arg0; | ||
return addHeapObject(ret); | ||
}; | ||
return imports; | ||
} | ||
module.exports.__wbindgen_bigint_from_u64 = function(arg0) { | ||
const ret = BigInt.asUintN(64, arg0); | ||
return addHeapObject(ret); | ||
}; | ||
function __wbg_init_memory(imports, maybe_memory) { | ||
module.exports.__wbindgen_object_clone_ref = function(arg0) { | ||
const ret = getObject(arg0); | ||
return addHeapObject(ret); | ||
}; | ||
} | ||
module.exports.__wbindgen_jsval_loose_eq = function(arg0, arg1) { | ||
const ret = getObject(arg0) == getObject(arg1); | ||
return ret; | ||
}; | ||
function __wbg_finalize_init(instance, module) { | ||
wasm = instance.exports; | ||
__wbg_init.__wbindgen_wasm_module = module; | ||
cachedFloat64Memory0 = null; | ||
cachedInt32Memory0 = null; | ||
cachedUint8Memory0 = null; | ||
module.exports.__wbindgen_boolean_get = function(arg0) { | ||
const v = getObject(arg0); | ||
const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; | ||
return ret; | ||
}; | ||
wasm.__wbindgen_start(); | ||
return wasm; | ||
} | ||
module.exports.__wbindgen_number_get = function(arg0, arg1) { | ||
const obj = getObject(arg1); | ||
const ret = typeof(obj) === 'number' ? obj : undefined; | ||
getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; | ||
getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); | ||
}; | ||
function initSync(module) { | ||
if (wasm !== undefined) return wasm; | ||
module.exports.__wbg_getwithrefkey_15c62c2b8546208d = function(arg0, arg1) { | ||
const ret = getObject(arg0)[getObject(arg1)]; | ||
return addHeapObject(ret); | ||
}; | ||
const imports = __wbg_get_imports(); | ||
module.exports.__wbg_set_20cbc34131e76824 = function(arg0, arg1, arg2) { | ||
getObject(arg0)[takeObject(arg1)] = takeObject(arg2); | ||
}; | ||
__wbg_init_memory(imports); | ||
module.exports.__wbindgen_error_new = function(arg0, arg1) { | ||
const ret = new Error(getStringFromWasm0(arg0, arg1)); | ||
return addHeapObject(ret); | ||
}; | ||
if (!(module instanceof WebAssembly.Module)) { | ||
module = new WebAssembly.Module(module); | ||
module.exports.__wbg_new_b51585de1b234aff = function() { | ||
const ret = new Object(); | ||
return addHeapObject(ret); | ||
}; | ||
module.exports.__wbg_instanceof_ArrayBuffer_39ac22089b74fddb = function(arg0) { | ||
let result; | ||
try { | ||
result = getObject(arg0) instanceof ArrayBuffer; | ||
} catch { | ||
result = false; | ||
} | ||
const ret = result; | ||
return ret; | ||
}; | ||
const instance = new WebAssembly.Instance(module, imports); | ||
module.exports.__wbg_getPrototypeOf_0953c64f6ba47b38 = function(arg0) { | ||
const ret = Object.getPrototypeOf(getObject(arg0)); | ||
return addHeapObject(ret); | ||
}; | ||
return __wbg_finalize_init(instance, module); | ||
} | ||
module.exports.__wbg_new_0d7da8e129c00c84 = function(arg0, arg1) { | ||
const ret = new TypeError(getStringFromWasm0(arg0, arg1)); | ||
return addHeapObject(ret); | ||
}; | ||
async function __wbg_init(input) { | ||
if (wasm !== undefined) return wasm; | ||
module.exports.__wbg_buffer_085ec1f694018c4f = function(arg0) { | ||
const ret = getObject(arg0).buffer; | ||
return addHeapObject(ret); | ||
}; | ||
if (typeof input === 'undefined') { | ||
input = new URL('intl_segmenter_polyfill_rs_bg.wasm', import.meta.url); | ||
} | ||
const imports = __wbg_get_imports(); | ||
module.exports.__wbg_new_8125e318e6245eed = function(arg0) { | ||
const ret = new Uint8Array(getObject(arg0)); | ||
return addHeapObject(ret); | ||
}; | ||
if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) { | ||
input = fetch(input); | ||
module.exports.__wbg_set_5cf90238115182c3 = function(arg0, arg1, arg2) { | ||
getObject(arg0).set(getObject(arg1), arg2 >>> 0); | ||
}; | ||
module.exports.__wbg_length_72e2208bbc0efc61 = function(arg0) { | ||
const ret = getObject(arg0).length; | ||
return ret; | ||
}; | ||
module.exports.__wbg_instanceof_Uint8Array_d8d9cb2b8e8ac1d4 = function(arg0) { | ||
let result; | ||
try { | ||
result = getObject(arg0) instanceof Uint8Array; | ||
} catch { | ||
result = false; | ||
} | ||
const ret = result; | ||
return ret; | ||
}; | ||
__wbg_init_memory(imports); | ||
module.exports.__wbindgen_debug_string = function(arg0, arg1) { | ||
const ret = debugString(getObject(arg1)); | ||
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
const len1 = WASM_VECTOR_LEN; | ||
getInt32Memory0()[arg0 / 4 + 1] = len1; | ||
getInt32Memory0()[arg0 / 4 + 0] = ptr1; | ||
}; | ||
const { instance, module } = await __wbg_load(await input, imports); | ||
module.exports.__wbindgen_throw = function(arg0, arg1) { | ||
throw new Error(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
return __wbg_finalize_init(instance, module); | ||
} | ||
module.exports.__wbindgen_memory = function() { | ||
const ret = wasm.memory; | ||
return addHeapObject(ret); | ||
}; | ||
export { initSync } | ||
export default __wbg_init; | ||
const path = require('path').join(__dirname, 'intl_segmenter_polyfill_rs_bg.wasm'); | ||
const bytes = require('fs').readFileSync(path); | ||
const wasmModule = new WebAssembly.Module(bytes); | ||
const wasmInstance = new WebAssembly.Instance(wasmModule, imports); | ||
wasm = wasmInstance.exports; | ||
module.exports.__wasm = wasm; | ||
wasm.__wbindgen_start(); | ||
{ | ||
"name": "intl-segmenter-polyfill-rs", | ||
"description": "A polyfill for Intl.Segmenter", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"license": "MIT OR Apache-2.0", | ||
@@ -13,9 +13,5 @@ "repository": { | ||
], | ||
"module": "intl_segmenter_polyfill_rs.js", | ||
"main": "intl_segmenter_polyfill_rs.js", | ||
"homepage": "https://github.com/toeverything/intl-segmenter-polyfill-rs", | ||
"types": "intl_segmenter_polyfill_rs.d.ts", | ||
"sideEffects": [ | ||
"./snippets/*" | ||
], | ||
"type": "module" | ||
"types": "intl_segmenter_polyfill_rs.d.ts" | ||
} |
@@ -32,3 +32,3 @@ # Intl-Segmenter-Polyfill-rs | ||
``` | ||
wasm-pack build --target web --release | ||
wasm-pack build --target nodejs --release | ||
``` | ||
@@ -39,3 +39,3 @@ | ||
``` | ||
echo "$(jq '.type |= "module" | .files |= ["./*"]' pkg/package.json)" > pkg/package.json | ||
sh before-publish.sh | ||
``` | ||
@@ -42,0 +42,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
2508129
12
907
1
3
No