content-tag
Advanced tools
Comparing version 2.0.1 to 2.0.2
/* | ||
* wasm-pack doesn't give us correct enough types. | ||
* this file must be manually kept in sync with ./index.d.cts | ||
*/ | ||
interface Parsed { | ||
@@ -8,0 +7,0 @@ type: 'expression' | 'class-member'; |
{ | ||
"name": "content-tag", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "A rust program that uses a fork of swc to parse and transform Javascript containing the content-tag proposal", | ||
@@ -13,9 +13,8 @@ "repository": { | ||
".": { | ||
"import": { | ||
"browser": { | ||
"types": "./index.d.ts", | ||
"browser": "./pkg/standalone.js", | ||
"default": "./pkg/node.cjs" | ||
"default": "./pkg/standalone.js" | ||
}, | ||
"require": { | ||
"types": "./index.d.ts", | ||
"default": { | ||
"types": "./index.d.cts", | ||
"default": "./pkg/node.cjs" | ||
@@ -38,3 +37,3 @@ } | ||
"lint:package": "publint", | ||
"lint:published-types": "attw --pack --ignore-rules false-esm", | ||
"lint:published-types": "attw --pack", | ||
"start": "vite", | ||
@@ -45,3 +44,2 @@ "test": "npm run ci:node" | ||
"@arethetypeswrong/cli": "^0.13.2", | ||
"@vitest/browser": "^0.34.6", | ||
"chai": "^4.3.7", | ||
@@ -48,0 +46,0 @@ "code-equality-assertions": "github:mansona/code-equality-assertions#add-chai-build", |
import init from "./standalone/content_tag.js"; | ||
import { Preprocessor as WasmPreprocessor } from "./standalone/content_tag.js"; | ||
export { Preprocessor } from "./standalone/content_tag.js"; | ||
await init(); | ||
const defaultOptions = { | ||
inline_source_map: false, | ||
filename: null | ||
}; | ||
export class Preprocessor { | ||
#preprocessor; | ||
constructor() { | ||
this.#preprocessor = new WasmPreprocessor(); | ||
} | ||
process(str, options = {}) { | ||
return this.#preprocessor.process(str, { ...defaultOptions, ...options }); | ||
} | ||
parse(str, options = {}) { | ||
return this.#preprocessor.parse(str, { ...defaultOptions, ...options }); | ||
} | ||
} |
@@ -50,79 +50,2 @@ let wasm; | ||
let WASM_VECTOR_LEN = 0; | ||
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } ); | ||
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' | ||
? function (arg, view) { | ||
return cachedTextEncoder.encodeInto(arg, view); | ||
} | ||
: function (arg, view) { | ||
const buf = cachedTextEncoder.encode(arg); | ||
view.set(buf); | ||
return { | ||
read: arg.length, | ||
written: buf.length | ||
}; | ||
}); | ||
function passStringToWasm0(arg, malloc, realloc) { | ||
if (realloc === undefined) { | ||
const buf = cachedTextEncoder.encode(arg); | ||
const ptr = malloc(buf.length, 1) >>> 0; | ||
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); | ||
WASM_VECTOR_LEN = buf.length; | ||
return ptr; | ||
} | ||
let len = arg.length; | ||
let ptr = malloc(len, 1) >>> 0; | ||
const mem = getUint8Memory0(); | ||
let offset = 0; | ||
for (; offset < len; offset++) { | ||
const code = arg.charCodeAt(offset); | ||
if (code > 0x7F) break; | ||
mem[ptr + offset] = code; | ||
} | ||
if (offset !== len) { | ||
if (offset !== 0) { | ||
arg = arg.slice(offset); | ||
} | ||
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; | ||
const view = getUint8Memory0().subarray(ptr + offset, ptr + len); | ||
const ret = encodeString(arg, view); | ||
offset += ret.written; | ||
} | ||
WASM_VECTOR_LEN = offset; | ||
return ptr; | ||
} | ||
function isLikeNone(x) { | ||
return x === undefined || x === null; | ||
} | ||
let cachedInt32Memory0 = null; | ||
function getInt32Memory0() { | ||
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { | ||
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); | ||
} | ||
return cachedInt32Memory0; | ||
} | ||
let cachedFloat64Memory0 = null; | ||
function getFloat64Memory0() { | ||
if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { | ||
cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); | ||
} | ||
return cachedFloat64Memory0; | ||
} | ||
function debugString(val) { | ||
@@ -193,2 +116,66 @@ // primitive types | ||
let WASM_VECTOR_LEN = 0; | ||
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } ); | ||
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' | ||
? function (arg, view) { | ||
return cachedTextEncoder.encodeInto(arg, view); | ||
} | ||
: function (arg, view) { | ||
const buf = cachedTextEncoder.encode(arg); | ||
view.set(buf); | ||
return { | ||
read: arg.length, | ||
written: buf.length | ||
}; | ||
}); | ||
function passStringToWasm0(arg, malloc, realloc) { | ||
if (realloc === undefined) { | ||
const buf = cachedTextEncoder.encode(arg); | ||
const ptr = malloc(buf.length, 1) >>> 0; | ||
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); | ||
WASM_VECTOR_LEN = buf.length; | ||
return ptr; | ||
} | ||
let len = arg.length; | ||
let ptr = malloc(len, 1) >>> 0; | ||
const mem = getUint8Memory0(); | ||
let offset = 0; | ||
for (; offset < len; offset++) { | ||
const code = arg.charCodeAt(offset); | ||
if (code > 0x7F) break; | ||
mem[ptr + offset] = code; | ||
} | ||
if (offset !== len) { | ||
if (offset !== 0) { | ||
arg = arg.slice(offset); | ||
} | ||
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; | ||
const view = getUint8Memory0().subarray(ptr + offset, ptr + len); | ||
const ret = encodeString(arg, view); | ||
offset += ret.written; | ||
} | ||
WASM_VECTOR_LEN = offset; | ||
return ptr; | ||
} | ||
let cachedInt32Memory0 = null; | ||
function getInt32Memory0() { | ||
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { | ||
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); | ||
} | ||
return cachedInt32Memory0; | ||
} | ||
function handleError(f, args) { | ||
@@ -328,28 +315,9 @@ try { | ||
}; | ||
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_boolean_get = function(arg0) { | ||
const v = getObject(arg0); | ||
const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; | ||
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; | ||
imports.wbg.__wbg_String_d7c955520b66a733 = function(arg0, arg1) { | ||
const ret = String(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_is_object = function(arg0) { | ||
const val = getObject(arg0); | ||
const ret = typeof(val) === 'object' && val !== null; | ||
return ret; | ||
}; | ||
imports.wbg.__wbg_Error_58015c683709e145 = function(arg0) { | ||
@@ -359,5 +327,5 @@ const ret = Error(takeObject(arg0)); | ||
}; | ||
imports.wbg.__wbindgen_object_clone_ref = function(arg0) { | ||
const ret = getObject(arg0); | ||
return addHeapObject(ret); | ||
imports.wbg.__wbg_Boolean_ef3e29efb4629824 = function(arg0) { | ||
const ret = Boolean(getObject(arg0)); | ||
return ret; | ||
}; | ||
@@ -368,20 +336,7 @@ imports.wbg.__wbg_parse_181a91d066d1f7fe = function(arg0) { | ||
}; | ||
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.__wbindgen_jsval_loose_eq = function(arg0, arg1) { | ||
const ret = getObject(arg0) == getObject(arg1); | ||
imports.wbg.__wbindgen_is_object = function(arg0) { | ||
const val = getObject(arg0); | ||
const ret = typeof(val) === 'object' && val !== null; | ||
return ret; | ||
}; | ||
imports.wbg.__wbindgen_error_new = function(arg0, arg1) { | ||
const ret = new Error(getStringFromWasm0(arg0, arg1)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_getwithrefkey_15c62c2b8546208d = function(arg0, arg1) { | ||
const ret = getObject(arg0)[getObject(arg1)]; | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_crypto_c48a774b022d20ac = function(arg0) { | ||
@@ -441,2 +396,6 @@ const ret = getObject(arg0).crypto; | ||
}, arguments) }; | ||
imports.wbg.__wbindgen_is_undefined = function(arg0) { | ||
const ret = getObject(arg0) === undefined; | ||
return ret; | ||
}; | ||
imports.wbg.__wbg_newnoargs_581967eacc0e2604 = function(arg0, arg1) { | ||
@@ -446,11 +405,5 @@ const ret = new Function(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
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.__wbindgen_object_clone_ref = function(arg0) { | ||
const ret = getObject(arg0); | ||
return addHeapObject(ret); | ||
}; | ||
@@ -465,2 +418,6 @@ imports.wbg.__wbg_call_cb65541d95d71282 = function() { return handleError(function (arg0, arg1) { | ||
}, arguments) }; | ||
imports.wbg.__wbg_get_97b561fb56f034b5 = function() { return handleError(function (arg0, arg1) { | ||
const ret = Reflect.get(getObject(arg0), getObject(arg1)); | ||
return addHeapObject(ret); | ||
}, arguments) }; | ||
imports.wbg.__wbg_set_092e06b0f9d71865 = function() { return handleError(function (arg0, arg1, arg2) { | ||
@@ -482,12 +439,2 @@ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2)); | ||
}; | ||
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.__wbg_newwithlength_e5d69174d6984cd7 = function(arg0) { | ||
@@ -501,6 +448,2 @@ const ret = new Uint8Array(arg0 >>> 0); | ||
}; | ||
imports.wbg.__wbg_length_72e2208bbc0efc61 = function(arg0) { | ||
const ret = getObject(arg0).length; | ||
return ret; | ||
}; | ||
imports.wbg.__wbg_set_5cf90238115182c3 = function(arg0, arg1, arg2) { | ||
@@ -534,3 +477,2 @@ getObject(arg0).set(getObject(arg1), arg2 >>> 0); | ||
__wbg_init.__wbindgen_wasm_module = module; | ||
cachedFloat64Memory0 = null; | ||
cachedInt32Memory0 = null; | ||
@@ -537,0 +479,0 @@ cachedUint8Memory0 = null; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
10
15
2617404
1002