@paperclover/markodown 1.0.0-rc.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,416 @@
1
+ /* @ts-self-types="./markodown.d.ts" */
2
+
3
+ /**
4
+ * @enum {0 | 1}
5
+ */
6
+ export const OutputFormat = Object.freeze({
7
+ Html: 0, "0": "Html",
8
+ Marko: 1, "1": "Marko",
9
+ });
10
+
11
+ /**
12
+ * @param {string} src
13
+ * @param {OutputFormat | null | undefined} force_format
14
+ * @param {string | null | undefined} layout_import
15
+ * @param {any} component_imports
16
+ * @param {string | null | undefined} self_path
17
+ * @param {boolean | null | undefined} markdown_only
18
+ * @param {any} clover_extensions
19
+ * @returns {any}
20
+ */
21
+ export function transform(src, force_format, layout_import, component_imports, self_path, markdown_only, clover_extensions) {
22
+ const ptr0 = passStringToWasm0(src, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
23
+ const len0 = WASM_VECTOR_LEN;
24
+ var ptr1 = isLikeNone(layout_import) ? 0 : passStringToWasm0(layout_import, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
25
+ var len1 = WASM_VECTOR_LEN;
26
+ var ptr2 = isLikeNone(self_path) ? 0 : passStringToWasm0(self_path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
27
+ var len2 = WASM_VECTOR_LEN;
28
+ const ret = wasm.transform(ptr0, len0, isLikeNone(force_format) ? 2 : force_format, ptr1, len1, component_imports, ptr2, len2, isLikeNone(markdown_only) ? 0xFFFFFF : markdown_only ? 1 : 0, clover_extensions);
29
+ return ret;
30
+ }
31
+
32
+ function __wbg_get_imports() {
33
+ const import0 = {
34
+ __proto__: null,
35
+ __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
36
+ const ret = Error(getStringFromWasm0(arg0, arg1));
37
+ return ret;
38
+ },
39
+ __wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25: function(arg0) {
40
+ const v = arg0;
41
+ const ret = typeof(v) === 'boolean' ? v : undefined;
42
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
43
+ },
44
+ __wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
45
+ const ret = debugString(arg1);
46
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
47
+ const len1 = WASM_VECTOR_LEN;
48
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
49
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
50
+ },
51
+ __wbg___wbindgen_in_47fa6863be6f2f25: function(arg0, arg1) {
52
+ const ret = arg0 in arg1;
53
+ return ret;
54
+ },
55
+ __wbg___wbindgen_is_null_ac34f5003991759a: function(arg0) {
56
+ const ret = arg0 === null;
57
+ return ret;
58
+ },
59
+ __wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
60
+ const val = arg0;
61
+ const ret = typeof(val) === 'object' && val !== null;
62
+ return ret;
63
+ },
64
+ __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
65
+ const ret = arg0 === undefined;
66
+ return ret;
67
+ },
68
+ __wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811: function(arg0, arg1) {
69
+ const ret = arg0 == arg1;
70
+ return ret;
71
+ },
72
+ __wbg___wbindgen_number_get_8ff4255516ccad3e: function(arg0, arg1) {
73
+ const obj = arg1;
74
+ const ret = typeof(obj) === 'number' ? obj : undefined;
75
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
76
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
77
+ },
78
+ __wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
79
+ const obj = arg1;
80
+ const ret = typeof(obj) === 'string' ? obj : undefined;
81
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
82
+ var len1 = WASM_VECTOR_LEN;
83
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
84
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
85
+ },
86
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
87
+ throw new Error(getStringFromWasm0(arg0, arg1));
88
+ },
89
+ __wbg_get_with_ref_key_1dc361bd10053bfe: function(arg0, arg1) {
90
+ const ret = arg0[arg1];
91
+ return ret;
92
+ },
93
+ __wbg_instanceof_ArrayBuffer_c367199e2fa2aa04: function(arg0) {
94
+ let result;
95
+ try {
96
+ result = arg0 instanceof ArrayBuffer;
97
+ } catch (_) {
98
+ result = false;
99
+ }
100
+ const ret = result;
101
+ return ret;
102
+ },
103
+ __wbg_instanceof_Uint8Array_9b9075935c74707c: function(arg0) {
104
+ let result;
105
+ try {
106
+ result = arg0 instanceof Uint8Array;
107
+ } catch (_) {
108
+ result = false;
109
+ }
110
+ const ret = result;
111
+ return ret;
112
+ },
113
+ __wbg_length_32ed9a279acd054c: function(arg0) {
114
+ const ret = arg0.length;
115
+ return ret;
116
+ },
117
+ __wbg_new_361308b2356cecd0: function() {
118
+ const ret = new Object();
119
+ return ret;
120
+ },
121
+ __wbg_new_3eb36ae241fe6f44: function() {
122
+ const ret = new Array();
123
+ return ret;
124
+ },
125
+ __wbg_new_dd2b680c8bf6ae29: function(arg0) {
126
+ const ret = new Uint8Array(arg0);
127
+ return ret;
128
+ },
129
+ __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
130
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
131
+ },
132
+ __wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
133
+ arg0[arg1] = arg2;
134
+ },
135
+ __wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
136
+ arg0[arg1 >>> 0] = arg2;
137
+ },
138
+ __wbindgen_cast_0000000000000001: function(arg0) {
139
+ // Cast intrinsic for `F64 -> Externref`.
140
+ const ret = arg0;
141
+ return ret;
142
+ },
143
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
144
+ // Cast intrinsic for `Ref(String) -> Externref`.
145
+ const ret = getStringFromWasm0(arg0, arg1);
146
+ return ret;
147
+ },
148
+ __wbindgen_init_externref_table: function() {
149
+ const table = wasm.__wbindgen_externrefs;
150
+ const offset = table.grow(4);
151
+ table.set(0, undefined);
152
+ table.set(offset + 0, undefined);
153
+ table.set(offset + 1, null);
154
+ table.set(offset + 2, true);
155
+ table.set(offset + 3, false);
156
+ },
157
+ };
158
+ return {
159
+ __proto__: null,
160
+ "./markodown_bg.js": import0,
161
+ };
162
+ }
163
+
164
+ function debugString(val) {
165
+ // primitive types
166
+ const type = typeof val;
167
+ if (type == 'number' || type == 'boolean' || val == null) {
168
+ return `${val}`;
169
+ }
170
+ if (type == 'string') {
171
+ return `"${val}"`;
172
+ }
173
+ if (type == 'symbol') {
174
+ const description = val.description;
175
+ if (description == null) {
176
+ return 'Symbol';
177
+ } else {
178
+ return `Symbol(${description})`;
179
+ }
180
+ }
181
+ if (type == 'function') {
182
+ const name = val.name;
183
+ if (typeof name == 'string' && name.length > 0) {
184
+ return `Function(${name})`;
185
+ } else {
186
+ return 'Function';
187
+ }
188
+ }
189
+ // objects
190
+ if (Array.isArray(val)) {
191
+ const length = val.length;
192
+ let debug = '[';
193
+ if (length > 0) {
194
+ debug += debugString(val[0]);
195
+ }
196
+ for(let i = 1; i < length; i++) {
197
+ debug += ', ' + debugString(val[i]);
198
+ }
199
+ debug += ']';
200
+ return debug;
201
+ }
202
+ // Test for built-in
203
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
204
+ let className;
205
+ if (builtInMatches && builtInMatches.length > 1) {
206
+ className = builtInMatches[1];
207
+ } else {
208
+ // Failed to match the standard '[object ClassName]'
209
+ return toString.call(val);
210
+ }
211
+ if (className == 'Object') {
212
+ // we're a user defined class or Object
213
+ // JSON.stringify avoids problems with cycles, and is generally much
214
+ // easier than looping through ownProperties of `val`.
215
+ try {
216
+ return 'Object(' + JSON.stringify(val) + ')';
217
+ } catch (_) {
218
+ return 'Object';
219
+ }
220
+ }
221
+ // errors
222
+ if (val instanceof Error) {
223
+ return `${val.name}: ${val.message}\n${val.stack}`;
224
+ }
225
+ // TODO we could test for more things here, like `Set`s and `Map`s.
226
+ return className;
227
+ }
228
+
229
+ function getArrayU8FromWasm0(ptr, len) {
230
+ ptr = ptr >>> 0;
231
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
232
+ }
233
+
234
+ let cachedDataViewMemory0 = null;
235
+ function getDataViewMemory0() {
236
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
237
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
238
+ }
239
+ return cachedDataViewMemory0;
240
+ }
241
+
242
+ function getStringFromWasm0(ptr, len) {
243
+ ptr = ptr >>> 0;
244
+ return decodeText(ptr, len);
245
+ }
246
+
247
+ let cachedUint8ArrayMemory0 = null;
248
+ function getUint8ArrayMemory0() {
249
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
250
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
251
+ }
252
+ return cachedUint8ArrayMemory0;
253
+ }
254
+
255
+ function isLikeNone(x) {
256
+ return x === undefined || x === null;
257
+ }
258
+
259
+ function passStringToWasm0(arg, malloc, realloc) {
260
+ if (realloc === undefined) {
261
+ const buf = cachedTextEncoder.encode(arg);
262
+ const ptr = malloc(buf.length, 1) >>> 0;
263
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
264
+ WASM_VECTOR_LEN = buf.length;
265
+ return ptr;
266
+ }
267
+
268
+ let len = arg.length;
269
+ let ptr = malloc(len, 1) >>> 0;
270
+
271
+ const mem = getUint8ArrayMemory0();
272
+
273
+ let offset = 0;
274
+
275
+ for (; offset < len; offset++) {
276
+ const code = arg.charCodeAt(offset);
277
+ if (code > 0x7F) break;
278
+ mem[ptr + offset] = code;
279
+ }
280
+ if (offset !== len) {
281
+ if (offset !== 0) {
282
+ arg = arg.slice(offset);
283
+ }
284
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
285
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
286
+ const ret = cachedTextEncoder.encodeInto(arg, view);
287
+
288
+ offset += ret.written;
289
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
290
+ }
291
+
292
+ WASM_VECTOR_LEN = offset;
293
+ return ptr;
294
+ }
295
+
296
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
297
+ cachedTextDecoder.decode();
298
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
299
+ let numBytesDecoded = 0;
300
+ function decodeText(ptr, len) {
301
+ numBytesDecoded += len;
302
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
303
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
304
+ cachedTextDecoder.decode();
305
+ numBytesDecoded = len;
306
+ }
307
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
308
+ }
309
+
310
+ const cachedTextEncoder = new TextEncoder();
311
+
312
+ if (!('encodeInto' in cachedTextEncoder)) {
313
+ cachedTextEncoder.encodeInto = function (arg, view) {
314
+ const buf = cachedTextEncoder.encode(arg);
315
+ view.set(buf);
316
+ return {
317
+ read: arg.length,
318
+ written: buf.length
319
+ };
320
+ };
321
+ }
322
+
323
+ let WASM_VECTOR_LEN = 0;
324
+
325
+ let wasmModule, wasm;
326
+ function __wbg_finalize_init(instance, module) {
327
+ wasm = instance.exports;
328
+ wasmModule = module;
329
+ cachedDataViewMemory0 = null;
330
+ cachedUint8ArrayMemory0 = null;
331
+ wasm.__wbindgen_start();
332
+ return wasm;
333
+ }
334
+
335
+ async function __wbg_load(module, imports) {
336
+ if (typeof Response === 'function' && module instanceof Response) {
337
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
338
+ try {
339
+ return await WebAssembly.instantiateStreaming(module, imports);
340
+ } catch (e) {
341
+ const validResponse = module.ok && expectedResponseType(module.type);
342
+
343
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
344
+ 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);
345
+
346
+ } else { throw e; }
347
+ }
348
+ }
349
+
350
+ const bytes = await module.arrayBuffer();
351
+ return await WebAssembly.instantiate(bytes, imports);
352
+ } else {
353
+ const instance = await WebAssembly.instantiate(module, imports);
354
+
355
+ if (instance instanceof WebAssembly.Instance) {
356
+ return { instance, module };
357
+ } else {
358
+ return instance;
359
+ }
360
+ }
361
+
362
+ function expectedResponseType(type) {
363
+ switch (type) {
364
+ case 'basic': case 'cors': case 'default': return true;
365
+ }
366
+ return false;
367
+ }
368
+ }
369
+
370
+ function initSync(module) {
371
+ if (wasm !== undefined) return wasm;
372
+
373
+
374
+ if (module !== undefined) {
375
+ if (Object.getPrototypeOf(module) === Object.prototype) {
376
+ ({module} = module)
377
+ } else {
378
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
379
+ }
380
+ }
381
+
382
+ const imports = __wbg_get_imports();
383
+ if (!(module instanceof WebAssembly.Module)) {
384
+ module = new WebAssembly.Module(module);
385
+ }
386
+ const instance = new WebAssembly.Instance(module, imports);
387
+ return __wbg_finalize_init(instance, module);
388
+ }
389
+
390
+ async function __wbg_init(module_or_path) {
391
+ if (wasm !== undefined) return wasm;
392
+
393
+
394
+ if (module_or_path !== undefined) {
395
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
396
+ ({module_or_path} = module_or_path)
397
+ } else {
398
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
399
+ }
400
+ }
401
+
402
+ if (module_or_path === undefined) {
403
+ module_or_path = new URL('markodown_bg.wasm', import.meta.url);
404
+ }
405
+ const imports = __wbg_get_imports();
406
+
407
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
408
+ module_or_path = fetch(module_or_path);
409
+ }
410
+
411
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
412
+
413
+ return __wbg_finalize_init(instance, module);
414
+ }
415
+
416
+ export { initSync, __wbg_init as default };
@@ -0,0 +1,2 @@
1
+ declare const string: string;
2
+ export default string;