content-tag
Advanced tools
+24
| const { Preprocessor: WasmPreprocessor } = require("./node/content_tag.cjs"); | ||
| const defaultOptions = { | ||
| inline_source_map: false, | ||
| filename: null | ||
| }; | ||
| 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 }); | ||
| } | ||
| } | ||
| module.exports.Preprocessor = Preprocessor; |
+4
-4
| { | ||
| "name": "content-tag", | ||
| "version": "1.2.2", | ||
| "version": "2.0.0", | ||
| "description": "A rust program that uses a fork of swc to parse and transform Javascript containing the content-tag proposal", | ||
@@ -16,7 +16,7 @@ "repository": { | ||
| "browser": "./pkg/standalone.js", | ||
| "default": "./pkg/node/content_tag.cjs" | ||
| "default": "./pkg/node.cjs" | ||
| }, | ||
| "require": { | ||
| "types": "./index.d.ts", | ||
| "default": "./pkg/node/content_tag.cjs" | ||
| "default": "./pkg/node.cjs" | ||
| } | ||
@@ -35,3 +35,3 @@ } | ||
| "prepack": "./build.sh", | ||
| "ci:node": "mocha", | ||
| "ci:node": "mocha 'test/*.{js,cjs}'", | ||
| "lint": "concurrently \"npm:lint:*(!fix)\" --names \"lint:\"", | ||
@@ -38,0 +38,0 @@ "lint:package": "publint", |
@@ -6,4 +6,4 @@ /* tslint:disable */ | ||
| export function preprocessor_new(): number; | ||
| export function preprocessor_process(a: number, b: number, c: number, d: number, e: number, f: number): void; | ||
| export function preprocessor_parse(a: number, b: number, c: number, d: number, e: number, f: number): void; | ||
| export function preprocessor_process(a: number, b: number, c: number, d: number, e: number): void; | ||
| export function preprocessor_parse(a: number, b: number, c: number, d: number, e: number): void; | ||
| export function __wbindgen_malloc(a: number, b: number): number; | ||
@@ -10,0 +10,0 @@ export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number; |
+171
-97
@@ -53,67 +53,2 @@ let imports = {}; | ||
| function debugString(val) { | ||
| // primitive types | ||
| const type = typeof val; | ||
| if (type == 'number' || type == 'boolean' || val == null) { | ||
| return `${val}`; | ||
| } | ||
| if (type == 'string') { | ||
| return `"${val}"`; | ||
| } | ||
| if (type == 'symbol') { | ||
| const description = val.description; | ||
| if (description == null) { | ||
| return 'Symbol'; | ||
| } else { | ||
| return `Symbol(${description})`; | ||
| } | ||
| } | ||
| if (type == 'function') { | ||
| const name = val.name; | ||
| if (typeof name == 'string' && name.length > 0) { | ||
| return `Function(${name})`; | ||
| } else { | ||
| return 'Function'; | ||
| } | ||
| } | ||
| // objects | ||
| if (Array.isArray(val)) { | ||
| const length = val.length; | ||
| let debug = '['; | ||
| if (length > 0) { | ||
| debug += debugString(val[0]); | ||
| } | ||
| for(let i = 1; i < length; i++) { | ||
| debug += ', ' + debugString(val[i]); | ||
| } | ||
| debug += ']'; | ||
| return debug; | ||
| } | ||
| // Test for built-in | ||
| const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); | ||
| let className; | ||
| if (builtInMatches.length > 1) { | ||
| className = builtInMatches[1]; | ||
| } else { | ||
| // Failed to match the standard '[object ClassName]' | ||
| return toString.call(val); | ||
| } | ||
| if (className == 'Object') { | ||
| // we're a user defined class or Object | ||
| // JSON.stringify avoids problems with cycles, and is generally much | ||
| // easier than looping through ownProperties of `val`. | ||
| try { | ||
| return 'Object(' + JSON.stringify(val) + ')'; | ||
| } catch (_) { | ||
| return 'Object'; | ||
| } | ||
| } | ||
| // errors | ||
| if (val instanceof Error) { | ||
| return `${val.name}: ${val.message}\n${val.stack}`; | ||
| } | ||
| // TODO we could test for more things here, like `Set`s and `Map`s. | ||
| return className; | ||
| } | ||
| let WASM_VECTOR_LEN = 0; | ||
@@ -174,2 +109,6 @@ | ||
| function isLikeNone(x) { | ||
| return x === undefined || x === null; | ||
| } | ||
| let cachedInt32Memory0 = null; | ||
@@ -184,6 +123,76 @@ | ||
| function isLikeNone(x) { | ||
| return x === undefined || x === null; | ||
| let cachedFloat64Memory0 = null; | ||
| function getFloat64Memory0() { | ||
| if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { | ||
| cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); | ||
| } | ||
| return cachedFloat64Memory0; | ||
| } | ||
| function debugString(val) { | ||
| // primitive types | ||
| const type = typeof val; | ||
| if (type == 'number' || type == 'boolean' || val == null) { | ||
| return `${val}`; | ||
| } | ||
| if (type == 'string') { | ||
| return `"${val}"`; | ||
| } | ||
| if (type == 'symbol') { | ||
| const description = val.description; | ||
| if (description == null) { | ||
| return 'Symbol'; | ||
| } else { | ||
| return `Symbol(${description})`; | ||
| } | ||
| } | ||
| if (type == 'function') { | ||
| const name = val.name; | ||
| if (typeof name == 'string' && name.length > 0) { | ||
| return `Function(${name})`; | ||
| } else { | ||
| return 'Function'; | ||
| } | ||
| } | ||
| // objects | ||
| if (Array.isArray(val)) { | ||
| const length = val.length; | ||
| let debug = '['; | ||
| if (length > 0) { | ||
| debug += debugString(val[0]); | ||
| } | ||
| for(let i = 1; i < length; i++) { | ||
| debug += ', ' + debugString(val[i]); | ||
| } | ||
| debug += ']'; | ||
| return debug; | ||
| } | ||
| // Test for built-in | ||
| const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); | ||
| let className; | ||
| if (builtInMatches.length > 1) { | ||
| className = builtInMatches[1]; | ||
| } else { | ||
| // Failed to match the standard '[object ClassName]' | ||
| return toString.call(val); | ||
| } | ||
| if (className == 'Object') { | ||
| // we're a user defined class or Object | ||
| // JSON.stringify avoids problems with cycles, and is generally much | ||
| // easier than looping through ownProperties of `val`. | ||
| try { | ||
| return 'Object(' + JSON.stringify(val) + ')'; | ||
| } catch (_) { | ||
| return 'Object'; | ||
| } | ||
| } | ||
| // errors | ||
| if (val instanceof Error) { | ||
| return `${val.name}: ${val.message}\n${val.stack}`; | ||
| } | ||
| // TODO we could test for more things here, like `Set`s and `Map`s. | ||
| return className; | ||
| } | ||
| function handleError(f, args) { | ||
@@ -229,8 +238,8 @@ try { | ||
| * @param {string} src | ||
| * @param {string | undefined} filename | ||
| * @param {any} options | ||
| * @returns {string} | ||
| */ | ||
| process(src, filename) { | ||
| let deferred4_0; | ||
| let deferred4_1; | ||
| process(src, options) { | ||
| let deferred3_0; | ||
| let deferred3_1; | ||
| try { | ||
@@ -240,5 +249,3 @@ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
| const len0 = WASM_VECTOR_LEN; | ||
| var ptr1 = isLikeNone(filename) ? 0 : passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
| var len1 = WASM_VECTOR_LEN; | ||
| wasm.preprocessor_process(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1); | ||
| wasm.preprocessor_process(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(options)); | ||
| var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
@@ -248,14 +255,14 @@ var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
| var r3 = getInt32Memory0()[retptr / 4 + 3]; | ||
| var ptr3 = r0; | ||
| var len3 = r1; | ||
| var ptr2 = r0; | ||
| var len2 = r1; | ||
| if (r3) { | ||
| ptr3 = 0; len3 = 0; | ||
| ptr2 = 0; len2 = 0; | ||
| throw takeObject(r2); | ||
| } | ||
| deferred4_0 = ptr3; | ||
| deferred4_1 = len3; | ||
| return getStringFromWasm0(ptr3, len3); | ||
| deferred3_0 = ptr2; | ||
| deferred3_1 = len2; | ||
| return getStringFromWasm0(ptr2, len2); | ||
| } finally { | ||
| wasm.__wbindgen_add_to_stack_pointer(16); | ||
| wasm.__wbindgen_free(deferred4_0, deferred4_1, 1); | ||
| wasm.__wbindgen_free(deferred3_0, deferred3_1, 1); | ||
| } | ||
@@ -265,6 +272,6 @@ } | ||
| * @param {string} src | ||
| * @param {string | undefined} filename | ||
| * @param {any} options | ||
| * @returns {any} | ||
| */ | ||
| parse(src, filename) { | ||
| parse(src, options) { | ||
| try { | ||
@@ -274,5 +281,3 @@ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
| const len0 = WASM_VECTOR_LEN; | ||
| var ptr1 = isLikeNone(filename) ? 0 : passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
| var len1 = WASM_VECTOR_LEN; | ||
| wasm.preprocessor_parse(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1); | ||
| wasm.preprocessor_parse(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(options)); | ||
| var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
@@ -301,2 +306,33 @@ var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
| module.exports.__wbindgen_is_undefined = function(arg0) { | ||
| const ret = getObject(arg0) === undefined; | ||
| return ret; | ||
| }; | ||
| module.exports.__wbindgen_in = function(arg0, arg1) { | ||
| const ret = getObject(arg0) in getObject(arg1); | ||
| return ret; | ||
| }; | ||
| module.exports.__wbindgen_boolean_get = function(arg0) { | ||
| const v = getObject(arg0); | ||
| const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; | ||
| return ret; | ||
| }; | ||
| 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_Error_58015c683709e145 = function(arg0) { | ||
@@ -307,2 +343,7 @@ const ret = Error(takeObject(arg0)); | ||
| module.exports.__wbindgen_object_clone_ref = function(arg0) { | ||
| const ret = getObject(arg0); | ||
| return addHeapObject(ret); | ||
| }; | ||
| module.exports.__wbg_parse_181a91d066d1f7fe = function(arg0) { | ||
@@ -313,8 +354,24 @@ const ret = JSON.parse(takeObject(arg0)); | ||
| module.exports.__wbindgen_is_object = function(arg0) { | ||
| const val = getObject(arg0); | ||
| const ret = typeof(val) === 'object' && val !== null; | ||
| 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); | ||
| }; | ||
| module.exports.__wbindgen_jsval_loose_eq = function(arg0, arg1) { | ||
| const ret = getObject(arg0) == getObject(arg1); | ||
| return ret; | ||
| }; | ||
| module.exports.__wbindgen_error_new = function(arg0, arg1) { | ||
| const ret = new Error(getStringFromWasm0(arg0, arg1)); | ||
| return addHeapObject(ret); | ||
| }; | ||
| module.exports.__wbg_getwithrefkey_15c62c2b8546208d = function(arg0, arg1) { | ||
| const ret = getObject(arg0)[getObject(arg1)]; | ||
| return addHeapObject(ret); | ||
| }; | ||
| module.exports.__wbg_crypto_c48a774b022d20ac = function(arg0) { | ||
@@ -388,7 +445,2 @@ const ret = getObject(arg0).crypto; | ||
| module.exports.__wbindgen_is_undefined = function(arg0) { | ||
| const ret = getObject(arg0) === undefined; | ||
| return ret; | ||
| }; | ||
| module.exports.__wbg_newnoargs_581967eacc0e2604 = function(arg0, arg1) { | ||
@@ -399,5 +451,11 @@ const ret = new Function(getStringFromWasm0(arg0, arg1)); | ||
| module.exports.__wbindgen_object_clone_ref = function(arg0) { | ||
| const ret = getObject(arg0); | ||
| 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; | ||
| }; | ||
@@ -435,2 +493,13 @@ | ||
| module.exports.__wbg_instanceof_Uint8Array_d8d9cb2b8e8ac1d4 = function(arg0) { | ||
| let result; | ||
| try { | ||
| result = getObject(arg0) instanceof Uint8Array; | ||
| } catch { | ||
| result = false; | ||
| } | ||
| const ret = result; | ||
| return ret; | ||
| }; | ||
| module.exports.__wbg_newwithlength_e5d69174d6984cd7 = function(arg0) { | ||
@@ -446,2 +515,7 @@ const ret = new Uint8Array(arg0 >>> 0); | ||
| module.exports.__wbg_length_72e2208bbc0efc61 = function(arg0) { | ||
| const ret = getObject(arg0).length; | ||
| return ret; | ||
| }; | ||
| module.exports.__wbg_set_5cf90238115182c3 = function(arg0, arg1, arg2) { | ||
@@ -448,0 +522,0 @@ getObject(arg0).set(getObject(arg1), arg2 >>> 0); |
@@ -12,12 +12,12 @@ /* tslint:disable */ | ||
| * @param {string} src | ||
| * @param {string | undefined} filename | ||
| * @param {any} options | ||
| * @returns {string} | ||
| */ | ||
| process(src: string, filename?: string): string; | ||
| process(src: string, options: any): string; | ||
| /** | ||
| * @param {string} src | ||
| * @param {string | undefined} filename | ||
| * @param {any} options | ||
| * @returns {any} | ||
| */ | ||
| parse(src: string, filename?: string): any; | ||
| parse(src: string, options: any): any; | ||
| } |
+21
-1
| import init from "./standalone/content_tag.js"; | ||
| import { Preprocessor as WasmPreprocessor } from "./standalone/content_tag.js"; | ||
| await init(); | ||
| export { Preprocessor } from "./standalone/content_tag.js"; | ||
| 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 }); | ||
| } | ||
| } |
@@ -6,4 +6,4 @@ /* tslint:disable */ | ||
| export function preprocessor_new(): number; | ||
| export function preprocessor_process(a: number, b: number, c: number, d: number, e: number, f: number): void; | ||
| export function preprocessor_parse(a: number, b: number, c: number, d: number, e: number, f: number): void; | ||
| export function preprocessor_process(a: number, b: number, c: number, d: number, e: number): void; | ||
| export function preprocessor_parse(a: number, b: number, c: number, d: number, e: number): void; | ||
| export function __wbindgen_malloc(a: number, b: number): number; | ||
@@ -10,0 +10,0 @@ export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number; |
@@ -12,12 +12,12 @@ /* tslint:disable */ | ||
| * @param {string} src | ||
| * @param {string | undefined} filename | ||
| * @param {any} options | ||
| * @returns {string} | ||
| */ | ||
| process(src: string, filename?: string): string; | ||
| process(src: string, options: any): string; | ||
| /** | ||
| * @param {string} src | ||
| * @param {string | undefined} filename | ||
| * @param {any} options | ||
| * @returns {any} | ||
| */ | ||
| parse(src: string, filename?: string): any; | ||
| parse(src: string, options: any): any; | ||
| } | ||
@@ -31,4 +31,4 @@ | ||
| readonly preprocessor_new: () => number; | ||
| readonly preprocessor_process: (a: number, b: number, c: number, d: number, e: number, f: number) => void; | ||
| readonly preprocessor_parse: (a: number, b: number, c: number, d: number, e: number, f: number) => void; | ||
| readonly preprocessor_process: (a: number, b: number, c: number, d: number, e: number) => void; | ||
| readonly preprocessor_parse: (a: number, b: number, c: number, d: number, e: number) => void; | ||
| readonly __wbindgen_malloc: (a: number, b: number) => number; | ||
@@ -35,0 +35,0 @@ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number; |
@@ -50,67 +50,2 @@ let wasm; | ||
| function debugString(val) { | ||
| // primitive types | ||
| const type = typeof val; | ||
| if (type == 'number' || type == 'boolean' || val == null) { | ||
| return `${val}`; | ||
| } | ||
| if (type == 'string') { | ||
| return `"${val}"`; | ||
| } | ||
| if (type == 'symbol') { | ||
| const description = val.description; | ||
| if (description == null) { | ||
| return 'Symbol'; | ||
| } else { | ||
| return `Symbol(${description})`; | ||
| } | ||
| } | ||
| if (type == 'function') { | ||
| const name = val.name; | ||
| if (typeof name == 'string' && name.length > 0) { | ||
| return `Function(${name})`; | ||
| } else { | ||
| return 'Function'; | ||
| } | ||
| } | ||
| // objects | ||
| if (Array.isArray(val)) { | ||
| const length = val.length; | ||
| let debug = '['; | ||
| if (length > 0) { | ||
| debug += debugString(val[0]); | ||
| } | ||
| for(let i = 1; i < length; i++) { | ||
| debug += ', ' + debugString(val[i]); | ||
| } | ||
| debug += ']'; | ||
| return debug; | ||
| } | ||
| // Test for built-in | ||
| const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); | ||
| let className; | ||
| if (builtInMatches.length > 1) { | ||
| className = builtInMatches[1]; | ||
| } else { | ||
| // Failed to match the standard '[object ClassName]' | ||
| return toString.call(val); | ||
| } | ||
| if (className == 'Object') { | ||
| // we're a user defined class or Object | ||
| // JSON.stringify avoids problems with cycles, and is generally much | ||
| // easier than looping through ownProperties of `val`. | ||
| try { | ||
| return 'Object(' + JSON.stringify(val) + ')'; | ||
| } catch (_) { | ||
| return 'Object'; | ||
| } | ||
| } | ||
| // errors | ||
| if (val instanceof Error) { | ||
| return `${val.name}: ${val.message}\n${val.stack}`; | ||
| } | ||
| // TODO we could test for more things here, like `Set`s and `Map`s. | ||
| return className; | ||
| } | ||
| let WASM_VECTOR_LEN = 0; | ||
@@ -171,2 +106,6 @@ | ||
| function isLikeNone(x) { | ||
| return x === undefined || x === null; | ||
| } | ||
| let cachedInt32Memory0 = null; | ||
@@ -181,6 +120,76 @@ | ||
| function isLikeNone(x) { | ||
| return x === undefined || x === null; | ||
| let cachedFloat64Memory0 = null; | ||
| function getFloat64Memory0() { | ||
| if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { | ||
| cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); | ||
| } | ||
| return cachedFloat64Memory0; | ||
| } | ||
| function debugString(val) { | ||
| // primitive types | ||
| const type = typeof val; | ||
| if (type == 'number' || type == 'boolean' || val == null) { | ||
| return `${val}`; | ||
| } | ||
| if (type == 'string') { | ||
| return `"${val}"`; | ||
| } | ||
| if (type == 'symbol') { | ||
| const description = val.description; | ||
| if (description == null) { | ||
| return 'Symbol'; | ||
| } else { | ||
| return `Symbol(${description})`; | ||
| } | ||
| } | ||
| if (type == 'function') { | ||
| const name = val.name; | ||
| if (typeof name == 'string' && name.length > 0) { | ||
| return `Function(${name})`; | ||
| } else { | ||
| return 'Function'; | ||
| } | ||
| } | ||
| // objects | ||
| if (Array.isArray(val)) { | ||
| const length = val.length; | ||
| let debug = '['; | ||
| if (length > 0) { | ||
| debug += debugString(val[0]); | ||
| } | ||
| for(let i = 1; i < length; i++) { | ||
| debug += ', ' + debugString(val[i]); | ||
| } | ||
| debug += ']'; | ||
| return debug; | ||
| } | ||
| // Test for built-in | ||
| const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); | ||
| let className; | ||
| if (builtInMatches.length > 1) { | ||
| className = builtInMatches[1]; | ||
| } else { | ||
| // Failed to match the standard '[object ClassName]' | ||
| return toString.call(val); | ||
| } | ||
| if (className == 'Object') { | ||
| // we're a user defined class or Object | ||
| // JSON.stringify avoids problems with cycles, and is generally much | ||
| // easier than looping through ownProperties of `val`. | ||
| try { | ||
| return 'Object(' + JSON.stringify(val) + ')'; | ||
| } catch (_) { | ||
| return 'Object'; | ||
| } | ||
| } | ||
| // errors | ||
| if (val instanceof Error) { | ||
| return `${val.name}: ${val.message}\n${val.stack}`; | ||
| } | ||
| // TODO we could test for more things here, like `Set`s and `Map`s. | ||
| return className; | ||
| } | ||
| function handleError(f, args) { | ||
@@ -226,8 +235,8 @@ try { | ||
| * @param {string} src | ||
| * @param {string | undefined} filename | ||
| * @param {any} options | ||
| * @returns {string} | ||
| */ | ||
| process(src, filename) { | ||
| let deferred4_0; | ||
| let deferred4_1; | ||
| process(src, options) { | ||
| let deferred3_0; | ||
| let deferred3_1; | ||
| try { | ||
@@ -237,5 +246,3 @@ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
| const len0 = WASM_VECTOR_LEN; | ||
| var ptr1 = isLikeNone(filename) ? 0 : passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
| var len1 = WASM_VECTOR_LEN; | ||
| wasm.preprocessor_process(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1); | ||
| wasm.preprocessor_process(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(options)); | ||
| var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
@@ -245,14 +252,14 @@ var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
| var r3 = getInt32Memory0()[retptr / 4 + 3]; | ||
| var ptr3 = r0; | ||
| var len3 = r1; | ||
| var ptr2 = r0; | ||
| var len2 = r1; | ||
| if (r3) { | ||
| ptr3 = 0; len3 = 0; | ||
| ptr2 = 0; len2 = 0; | ||
| throw takeObject(r2); | ||
| } | ||
| deferred4_0 = ptr3; | ||
| deferred4_1 = len3; | ||
| return getStringFromWasm0(ptr3, len3); | ||
| deferred3_0 = ptr2; | ||
| deferred3_1 = len2; | ||
| return getStringFromWasm0(ptr2, len2); | ||
| } finally { | ||
| wasm.__wbindgen_add_to_stack_pointer(16); | ||
| wasm.__wbindgen_free(deferred4_0, deferred4_1, 1); | ||
| wasm.__wbindgen_free(deferred3_0, deferred3_1, 1); | ||
| } | ||
@@ -262,6 +269,6 @@ } | ||
| * @param {string} src | ||
| * @param {string | undefined} filename | ||
| * @param {any} options | ||
| * @returns {any} | ||
| */ | ||
| parse(src, filename) { | ||
| parse(src, options) { | ||
| try { | ||
@@ -271,5 +278,3 @@ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
| const len0 = WASM_VECTOR_LEN; | ||
| var ptr1 = isLikeNone(filename) ? 0 : passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
| var len1 = WASM_VECTOR_LEN; | ||
| wasm.preprocessor_parse(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1); | ||
| wasm.preprocessor_parse(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(options)); | ||
| var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
@@ -329,2 +334,28 @@ var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
| }; | ||
| 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; | ||
| 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) { | ||
@@ -334,2 +365,6 @@ const ret = Error(takeObject(arg0)); | ||
| }; | ||
| imports.wbg.__wbindgen_object_clone_ref = function(arg0) { | ||
| const ret = getObject(arg0); | ||
| return addHeapObject(ret); | ||
| }; | ||
| imports.wbg.__wbg_parse_181a91d066d1f7fe = function(arg0) { | ||
@@ -339,7 +374,20 @@ const ret = JSON.parse(takeObject(arg0)); | ||
| }; | ||
| imports.wbg.__wbindgen_is_object = function(arg0) { | ||
| const val = getObject(arg0); | ||
| const ret = typeof(val) === 'object' && val !== null; | ||
| 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); | ||
| 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) { | ||
@@ -399,6 +447,2 @@ 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) { | ||
@@ -408,5 +452,11 @@ const ret = new Function(getStringFromWasm0(arg0, arg1)); | ||
| }; | ||
| imports.wbg.__wbindgen_object_clone_ref = function(arg0) { | ||
| const ret = getObject(arg0); | ||
| 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; | ||
| }; | ||
@@ -437,2 +487,12 @@ imports.wbg.__wbg_call_cb65541d95d71282 = function() { return handleError(function (arg0, arg1) { | ||
| }; | ||
| 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) { | ||
@@ -446,2 +506,6 @@ 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) { | ||
@@ -475,2 +539,3 @@ getObject(arg0).set(getObject(arg1), arg2 >>> 0); | ||
| __wbg_init.__wbindgen_wasm_module = module; | ||
| cachedFloat64Memory0 = null; | ||
| cachedInt32Memory0 = null; | ||
@@ -477,0 +542,0 @@ cachedUint8Memory0 = null; |
+104
-0
@@ -46,2 +46,106 @@ # content-tag | ||
| ## API | ||
| ### `Preprocessor` | ||
| All `content-tag` public API lives on the `Preprocessor` object. | ||
| ### `Preprocessor.process(src: string, options?: PreprocessorOptions): string;` | ||
| Parses a given source code string using the `content-tag` spec into standard | ||
| JavaScript. | ||
| ```ts | ||
| import { Preprocessor } from 'content-tag'; | ||
| let p = new Preprocessor(); | ||
| let output = p.process('<template>Hi</template>'); | ||
| ``` | ||
| ### `Preprocessor.parse(src: string, options?: PreprocessorOptions): Parsed[];` | ||
| Parses a given source code string using the `content-tag` spec into an array of | ||
| `Parsed` content tag objects. | ||
| ```ts | ||
| import { Preprocessor } from 'content-tag'; | ||
| let p = new Preprocessor(); | ||
| let output = p.parse('<template>Hi</template>'); | ||
| ``` | ||
| #### `PreprocessorOptions` | ||
| ````ts | ||
| interface PreprocessorOptions { | ||
| /** Default is `false` */ | ||
| inline_source_map?: boolean; | ||
| filename?: string; | ||
| } | ||
| ```` | ||
| #### `Parsed` | ||
| NOTE: All ranges are in bytes, not characters. | ||
| ````ts | ||
| interface Parsed { | ||
| /** | ||
| * The type for the content tag. | ||
| * | ||
| * 'expression' corresponds to a tag in an expression position, e.g. | ||
| * ``` | ||
| * const HiComponent = <template>Hi</template>; | ||
| * ``` | ||
| * | ||
| * 'class-member' corresponds to a tag in a class-member position, e.g. | ||
| * ``` | ||
| * export default class HiComponent extends Component { | ||
| * <template>Hi</template> | ||
| * } | ||
| * ``` | ||
| */ | ||
| type: "expression" | "class-member"; | ||
| /** | ||
| * Currently, only template tags are parsed. | ||
| */ | ||
| tagName: "template"; | ||
| /** Raw template contents. */ | ||
| contents: string; | ||
| /** | ||
| * Byte range of the contents, inclusive of inclusive of the | ||
| * `<template></template>` tags. | ||
| */ | ||
| range: { | ||
| start: number; | ||
| end: number; | ||
| }; | ||
| /** | ||
| * Byte range of the template contents, not inclusive of the | ||
| * `<template></template>` tags. | ||
| */ | ||
| contentRange: { | ||
| start: number; | ||
| end: number; | ||
| }; | ||
| /** Byte range of the opening `<template>` tag. */ | ||
| startRange: { | ||
| end: number; | ||
| start: number; | ||
| }; | ||
| /** Byte range of the closing `</template>` tag. */ | ||
| endRange: { | ||
| start: number; | ||
| end: number; | ||
| }; | ||
| } | ||
| ```` | ||
| ## Contributing | ||
@@ -48,0 +152,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2641088
1.04%14
7.69%1137
16.26%154
208%