@canmi/seam-engine 0.3.7

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,17 @@
1
+ //#region src/wasm-bridge.d.ts
2
+ interface InjectOptions {
3
+ skipDataScript?: boolean;
4
+ }
5
+ declare function renderPage(template: string, loaderDataJson: string, configJson: string, i18nOptsJson?: string): string;
6
+ declare function parseBuildOutput(manifestJson: string): string;
7
+ declare function parseI18nConfig(manifestJson: string): string;
8
+ declare function parseRpcHashMap(hashMapJson: string): string;
9
+ declare function asciiEscapeJson(json: string): string;
10
+ declare function i18nQuery(keysJson: string, locale: string, defaultLocale: string, messagesJson: string): string;
11
+ declare function inject(template: string, data: Record<string, unknown>, options?: InjectOptions): string;
12
+ declare function injectNoScript(template: string, dataJson: string): string;
13
+ //#endregion
14
+ //#region src/escape.d.ts
15
+ declare function escapeHtml(str: string): string;
16
+ //#endregion
17
+ export { type InjectOptions, asciiEscapeJson, escapeHtml, i18nQuery, inject, injectNoScript, parseBuildOutput, parseI18nConfig, parseRpcHashMap, renderPage };
package/dist/index.js ADDED
@@ -0,0 +1,303 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { dirname, resolve } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ //#region pkg/engine.js
6
+ /**
7
+ * @param {string} json
8
+ * @returns {string}
9
+ */
10
+ function ascii_escape_json(json) {
11
+ let deferred2_0;
12
+ let deferred2_1;
13
+ try {
14
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
15
+ const len0 = WASM_VECTOR_LEN;
16
+ const ret = wasm.ascii_escape_json(ptr0, len0);
17
+ deferred2_0 = ret[0];
18
+ deferred2_1 = ret[1];
19
+ return getStringFromWasm0(ret[0], ret[1]);
20
+ } finally {
21
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
22
+ }
23
+ }
24
+ /**
25
+ * @param {string} keys_json
26
+ * @param {string} locale
27
+ * @param {string} default_locale
28
+ * @param {string} messages_json
29
+ * @returns {string}
30
+ */
31
+ function i18n_query(keys_json, locale, default_locale, messages_json) {
32
+ let deferred5_0;
33
+ let deferred5_1;
34
+ try {
35
+ const ptr0 = passStringToWasm0(keys_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
36
+ const len0 = WASM_VECTOR_LEN;
37
+ const ptr1 = passStringToWasm0(locale, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
38
+ const len1 = WASM_VECTOR_LEN;
39
+ const ptr2 = passStringToWasm0(default_locale, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
40
+ const len2 = WASM_VECTOR_LEN;
41
+ const ptr3 = passStringToWasm0(messages_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
42
+ const len3 = WASM_VECTOR_LEN;
43
+ const ret = wasm.i18n_query(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
44
+ deferred5_0 = ret[0];
45
+ deferred5_1 = ret[1];
46
+ return getStringFromWasm0(ret[0], ret[1]);
47
+ } finally {
48
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
49
+ }
50
+ }
51
+ /**
52
+ * @param {string} template
53
+ * @param {string} data_json
54
+ * @returns {string}
55
+ */
56
+ function inject$1(template, data_json) {
57
+ let deferred3_0;
58
+ let deferred3_1;
59
+ try {
60
+ const ptr0 = passStringToWasm0(template, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
61
+ const len0 = WASM_VECTOR_LEN;
62
+ const ptr1 = passStringToWasm0(data_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
63
+ const len1 = WASM_VECTOR_LEN;
64
+ const ret = wasm.inject(ptr0, len0, ptr1, len1);
65
+ deferred3_0 = ret[0];
66
+ deferred3_1 = ret[1];
67
+ return getStringFromWasm0(ret[0], ret[1]);
68
+ } finally {
69
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
70
+ }
71
+ }
72
+ /**
73
+ * @param {string} template
74
+ * @param {string} data_json
75
+ * @returns {string}
76
+ */
77
+ function inject_no_script(template, data_json) {
78
+ let deferred3_0;
79
+ let deferred3_1;
80
+ try {
81
+ const ptr0 = passStringToWasm0(template, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
82
+ const len0 = WASM_VECTOR_LEN;
83
+ const ptr1 = passStringToWasm0(data_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
84
+ const len1 = WASM_VECTOR_LEN;
85
+ const ret = wasm.inject_no_script(ptr0, len0, ptr1, len1);
86
+ deferred3_0 = ret[0];
87
+ deferred3_1 = ret[1];
88
+ return getStringFromWasm0(ret[0], ret[1]);
89
+ } finally {
90
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
91
+ }
92
+ }
93
+ /**
94
+ * @param {string} manifest_json
95
+ * @returns {string}
96
+ */
97
+ function parse_build_output(manifest_json) {
98
+ let deferred2_0;
99
+ let deferred2_1;
100
+ try {
101
+ const ptr0 = passStringToWasm0(manifest_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
102
+ const len0 = WASM_VECTOR_LEN;
103
+ const ret = wasm.parse_build_output(ptr0, len0);
104
+ deferred2_0 = ret[0];
105
+ deferred2_1 = ret[1];
106
+ return getStringFromWasm0(ret[0], ret[1]);
107
+ } finally {
108
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
109
+ }
110
+ }
111
+ /**
112
+ * @param {string} manifest_json
113
+ * @returns {string}
114
+ */
115
+ function parse_i18n_config(manifest_json) {
116
+ let deferred2_0;
117
+ let deferred2_1;
118
+ try {
119
+ const ptr0 = passStringToWasm0(manifest_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
120
+ const len0 = WASM_VECTOR_LEN;
121
+ const ret = wasm.parse_i18n_config(ptr0, len0);
122
+ deferred2_0 = ret[0];
123
+ deferred2_1 = ret[1];
124
+ return getStringFromWasm0(ret[0], ret[1]);
125
+ } finally {
126
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
127
+ }
128
+ }
129
+ /**
130
+ * @param {string} hash_map_json
131
+ * @returns {string}
132
+ */
133
+ function parse_rpc_hash_map(hash_map_json) {
134
+ let deferred2_0;
135
+ let deferred2_1;
136
+ try {
137
+ const ptr0 = passStringToWasm0(hash_map_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
138
+ const len0 = WASM_VECTOR_LEN;
139
+ const ret = wasm.parse_rpc_hash_map(ptr0, len0);
140
+ deferred2_0 = ret[0];
141
+ deferred2_1 = ret[1];
142
+ return getStringFromWasm0(ret[0], ret[1]);
143
+ } finally {
144
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
145
+ }
146
+ }
147
+ /**
148
+ * @param {string} template
149
+ * @param {string} loader_data_json
150
+ * @param {string} config_json
151
+ * @param {string} i18n_opts_json
152
+ * @returns {string}
153
+ */
154
+ function render_page(template, loader_data_json, config_json, i18n_opts_json) {
155
+ let deferred5_0;
156
+ let deferred5_1;
157
+ try {
158
+ const ptr0 = passStringToWasm0(template, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
159
+ const len0 = WASM_VECTOR_LEN;
160
+ const ptr1 = passStringToWasm0(loader_data_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
161
+ const len1 = WASM_VECTOR_LEN;
162
+ const ptr2 = passStringToWasm0(config_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
163
+ const len2 = WASM_VECTOR_LEN;
164
+ const ptr3 = passStringToWasm0(i18n_opts_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
165
+ const len3 = WASM_VECTOR_LEN;
166
+ const ret = wasm.render_page(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
167
+ deferred5_0 = ret[0];
168
+ deferred5_1 = ret[1];
169
+ return getStringFromWasm0(ret[0], ret[1]);
170
+ } finally {
171
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
172
+ }
173
+ }
174
+ function __wbindgen_init_externref_table() {
175
+ const table = wasm.__wbindgen_externrefs;
176
+ const offset = table.grow(4);
177
+ table.set(0, void 0);
178
+ table.set(offset + 0, void 0);
179
+ table.set(offset + 1, null);
180
+ table.set(offset + 2, true);
181
+ table.set(offset + 3, false);
182
+ }
183
+ function getStringFromWasm0(ptr, len) {
184
+ ptr = ptr >>> 0;
185
+ return decodeText(ptr, len);
186
+ }
187
+ let cachedUint8ArrayMemory0 = null;
188
+ function getUint8ArrayMemory0() {
189
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
190
+ return cachedUint8ArrayMemory0;
191
+ }
192
+ function passStringToWasm0(arg, malloc, realloc) {
193
+ if (realloc === void 0) {
194
+ const buf = cachedTextEncoder.encode(arg);
195
+ const ptr = malloc(buf.length, 1) >>> 0;
196
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
197
+ WASM_VECTOR_LEN = buf.length;
198
+ return ptr;
199
+ }
200
+ let len = arg.length;
201
+ let ptr = malloc(len, 1) >>> 0;
202
+ const mem = getUint8ArrayMemory0();
203
+ let offset = 0;
204
+ for (; offset < len; offset++) {
205
+ const code = arg.charCodeAt(offset);
206
+ if (code > 127) break;
207
+ mem[ptr + offset] = code;
208
+ }
209
+ if (offset !== len) {
210
+ if (offset !== 0) arg = arg.slice(offset);
211
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
212
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
213
+ const ret = cachedTextEncoder.encodeInto(arg, view);
214
+ offset += ret.written;
215
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
216
+ }
217
+ WASM_VECTOR_LEN = offset;
218
+ return ptr;
219
+ }
220
+ let cachedTextDecoder = new TextDecoder("utf-8", {
221
+ ignoreBOM: true,
222
+ fatal: true
223
+ });
224
+ cachedTextDecoder.decode();
225
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
226
+ let numBytesDecoded = 0;
227
+ function decodeText(ptr, len) {
228
+ numBytesDecoded += len;
229
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
230
+ cachedTextDecoder = new TextDecoder("utf-8", {
231
+ ignoreBOM: true,
232
+ fatal: true
233
+ });
234
+ cachedTextDecoder.decode();
235
+ numBytesDecoded = len;
236
+ }
237
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
238
+ }
239
+ const cachedTextEncoder = new TextEncoder();
240
+ if (!("encodeInto" in cachedTextEncoder)) cachedTextEncoder.encodeInto = function(arg, view) {
241
+ const buf = cachedTextEncoder.encode(arg);
242
+ view.set(buf);
243
+ return {
244
+ read: arg.length,
245
+ written: buf.length
246
+ };
247
+ };
248
+ let WASM_VECTOR_LEN = 0;
249
+ let wasm;
250
+ function __wbg_set_wasm(val) {
251
+ wasm = val;
252
+ }
253
+
254
+ //#endregion
255
+ //#region src/wasm-bridge.ts
256
+ const wasmBytes = readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), "../pkg/engine.wasm"));
257
+ const wasmModule = new WebAssembly.Module(wasmBytes);
258
+ const wasmInstance = new WebAssembly.Instance(wasmModule, { "./seam_engine_wasm_bg.js": { __wbindgen_init_externref_table } });
259
+ __wbg_set_wasm(wasmInstance.exports);
260
+ const start = wasmInstance.exports.__wbindgen_start;
261
+ start();
262
+ function renderPage(template, loaderDataJson, configJson, i18nOptsJson) {
263
+ return render_page(template, loaderDataJson, configJson, i18nOptsJson ?? "");
264
+ }
265
+ function parseBuildOutput(manifestJson) {
266
+ return parse_build_output(manifestJson);
267
+ }
268
+ function parseI18nConfig(manifestJson) {
269
+ return parse_i18n_config(manifestJson);
270
+ }
271
+ function parseRpcHashMap(hashMapJson) {
272
+ return parse_rpc_hash_map(hashMapJson);
273
+ }
274
+ function asciiEscapeJson(json) {
275
+ return ascii_escape_json(json);
276
+ }
277
+ function i18nQuery(keysJson, locale, defaultLocale, messagesJson) {
278
+ return i18n_query(keysJson, locale, defaultLocale, messagesJson);
279
+ }
280
+ function inject(template, data, options) {
281
+ const json = JSON.stringify(data);
282
+ if (options?.skipDataScript) return inject_no_script(template, json);
283
+ return inject$1(template, json);
284
+ }
285
+ function injectNoScript(template, dataJson) {
286
+ return inject_no_script(template, dataJson);
287
+ }
288
+
289
+ //#endregion
290
+ //#region src/escape.ts
291
+ const ESCAPE_MAP = {
292
+ "&": "&amp;",
293
+ "<": "&lt;",
294
+ ">": "&gt;",
295
+ "\"": "&quot;",
296
+ "'": "&#x27;"
297
+ };
298
+ function escapeHtml(str) {
299
+ return str.replace(/[&<>"']/g, (ch) => ESCAPE_MAP[ch]);
300
+ }
301
+
302
+ //#endregion
303
+ export { asciiEscapeJson, escapeHtml, i18nQuery, inject, injectNoScript, parseBuildOutput, parseI18nConfig, parseRpcHashMap, renderPage };
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@canmi/seam-engine",
3
+ "version": "0.3.7",
4
+ "files": [
5
+ "dist",
6
+ "pkg"
7
+ ],
8
+ "type": "module",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./src/index.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "scripts": {
16
+ "build": "tsdown",
17
+ "test": "vitest run"
18
+ },
19
+ "devDependencies": {
20
+ "@types/node": "^22.0.0",
21
+ "tsdown": "^0.20.0",
22
+ "typescript": "^5.7.0",
23
+ "vitest": "^3.0.0"
24
+ }
25
+ }
@@ -0,0 +1,18 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export function ascii_escape_json(json: string): string;
5
+
6
+ export function i18n_query(keys_json: string, locale: string, default_locale: string, messages_json: string): string;
7
+
8
+ export function inject(template: string, data_json: string): string;
9
+
10
+ export function inject_no_script(template: string, data_json: string): string;
11
+
12
+ export function parse_build_output(manifest_json: string): string;
13
+
14
+ export function parse_i18n_config(manifest_json: string): string;
15
+
16
+ export function parse_rpc_hash_map(hash_map_json: string): string;
17
+
18
+ export function render_page(template: string, loader_data_json: string, config_json: string, i18n_opts_json: string): string;
package/pkg/bridge.js ADDED
@@ -0,0 +1,9 @@
1
+ /* @ts-self-types="./seam_engine_wasm.d.ts" */
2
+
3
+ import * as wasm from "./engine.wasm";
4
+ import { __wbg_set_wasm } from "./engine.js";
5
+ __wbg_set_wasm(wasm);
6
+ wasm.__wbindgen_start();
7
+ export {
8
+ ascii_escape_json, i18n_query, inject, inject_no_script, parse_build_output, parse_i18n_config, parse_rpc_hash_map, render_page
9
+ } from "./engine.js";
@@ -0,0 +1,20 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export function ascii_escape_json(json: string): string;
5
+
6
+ export function i18n_query(keys_json: string, locale: string, default_locale: string, messages_json: string): string;
7
+
8
+ export function inject(template: string, data_json: string): string;
9
+
10
+ export function inject_no_script(template: string, data_json: string): string;
11
+
12
+ export function parse_build_output(manifest_json: string): string;
13
+
14
+ export function parse_i18n_config(manifest_json: string): string;
15
+
16
+ export function parse_rpc_hash_map(hash_map_json: string): string;
17
+
18
+ export function render_page(template: string, loader_data_json: string, config_json: string, i18n_opts_json: string): string;
19
+ export function __wbindgen_init_externref_table(): void;
20
+ export function __wbg_set_wasm(val: WebAssembly.Exports): void;
package/pkg/engine.js ADDED
@@ -0,0 +1,268 @@
1
+ /**
2
+ * @param {string} json
3
+ * @returns {string}
4
+ */
5
+ export function ascii_escape_json(json) {
6
+ let deferred2_0;
7
+ let deferred2_1;
8
+ try {
9
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
10
+ const len0 = WASM_VECTOR_LEN;
11
+ const ret = wasm.ascii_escape_json(ptr0, len0);
12
+ deferred2_0 = ret[0];
13
+ deferred2_1 = ret[1];
14
+ return getStringFromWasm0(ret[0], ret[1]);
15
+ } finally {
16
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
17
+ }
18
+ }
19
+
20
+ /**
21
+ * @param {string} keys_json
22
+ * @param {string} locale
23
+ * @param {string} default_locale
24
+ * @param {string} messages_json
25
+ * @returns {string}
26
+ */
27
+ export function i18n_query(keys_json, locale, default_locale, messages_json) {
28
+ let deferred5_0;
29
+ let deferred5_1;
30
+ try {
31
+ const ptr0 = passStringToWasm0(keys_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
32
+ const len0 = WASM_VECTOR_LEN;
33
+ const ptr1 = passStringToWasm0(locale, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
34
+ const len1 = WASM_VECTOR_LEN;
35
+ const ptr2 = passStringToWasm0(default_locale, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
36
+ const len2 = WASM_VECTOR_LEN;
37
+ const ptr3 = passStringToWasm0(messages_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
38
+ const len3 = WASM_VECTOR_LEN;
39
+ const ret = wasm.i18n_query(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
40
+ deferred5_0 = ret[0];
41
+ deferred5_1 = ret[1];
42
+ return getStringFromWasm0(ret[0], ret[1]);
43
+ } finally {
44
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
45
+ }
46
+ }
47
+
48
+ /**
49
+ * @param {string} template
50
+ * @param {string} data_json
51
+ * @returns {string}
52
+ */
53
+ export function inject(template, data_json) {
54
+ let deferred3_0;
55
+ let deferred3_1;
56
+ try {
57
+ const ptr0 = passStringToWasm0(template, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
58
+ const len0 = WASM_VECTOR_LEN;
59
+ const ptr1 = passStringToWasm0(data_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
60
+ const len1 = WASM_VECTOR_LEN;
61
+ const ret = wasm.inject(ptr0, len0, ptr1, len1);
62
+ deferred3_0 = ret[0];
63
+ deferred3_1 = ret[1];
64
+ return getStringFromWasm0(ret[0], ret[1]);
65
+ } finally {
66
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
67
+ }
68
+ }
69
+
70
+ /**
71
+ * @param {string} template
72
+ * @param {string} data_json
73
+ * @returns {string}
74
+ */
75
+ export function inject_no_script(template, data_json) {
76
+ let deferred3_0;
77
+ let deferred3_1;
78
+ try {
79
+ const ptr0 = passStringToWasm0(template, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
80
+ const len0 = WASM_VECTOR_LEN;
81
+ const ptr1 = passStringToWasm0(data_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
82
+ const len1 = WASM_VECTOR_LEN;
83
+ const ret = wasm.inject_no_script(ptr0, len0, ptr1, len1);
84
+ deferred3_0 = ret[0];
85
+ deferred3_1 = ret[1];
86
+ return getStringFromWasm0(ret[0], ret[1]);
87
+ } finally {
88
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
89
+ }
90
+ }
91
+
92
+ /**
93
+ * @param {string} manifest_json
94
+ * @returns {string}
95
+ */
96
+ export function parse_build_output(manifest_json) {
97
+ let deferred2_0;
98
+ let deferred2_1;
99
+ try {
100
+ const ptr0 = passStringToWasm0(manifest_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
101
+ const len0 = WASM_VECTOR_LEN;
102
+ const ret = wasm.parse_build_output(ptr0, len0);
103
+ deferred2_0 = ret[0];
104
+ deferred2_1 = ret[1];
105
+ return getStringFromWasm0(ret[0], ret[1]);
106
+ } finally {
107
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
108
+ }
109
+ }
110
+
111
+ /**
112
+ * @param {string} manifest_json
113
+ * @returns {string}
114
+ */
115
+ export function parse_i18n_config(manifest_json) {
116
+ let deferred2_0;
117
+ let deferred2_1;
118
+ try {
119
+ const ptr0 = passStringToWasm0(manifest_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
120
+ const len0 = WASM_VECTOR_LEN;
121
+ const ret = wasm.parse_i18n_config(ptr0, len0);
122
+ deferred2_0 = ret[0];
123
+ deferred2_1 = ret[1];
124
+ return getStringFromWasm0(ret[0], ret[1]);
125
+ } finally {
126
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
127
+ }
128
+ }
129
+
130
+ /**
131
+ * @param {string} hash_map_json
132
+ * @returns {string}
133
+ */
134
+ export function parse_rpc_hash_map(hash_map_json) {
135
+ let deferred2_0;
136
+ let deferred2_1;
137
+ try {
138
+ const ptr0 = passStringToWasm0(hash_map_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
139
+ const len0 = WASM_VECTOR_LEN;
140
+ const ret = wasm.parse_rpc_hash_map(ptr0, len0);
141
+ deferred2_0 = ret[0];
142
+ deferred2_1 = ret[1];
143
+ return getStringFromWasm0(ret[0], ret[1]);
144
+ } finally {
145
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
146
+ }
147
+ }
148
+
149
+ /**
150
+ * @param {string} template
151
+ * @param {string} loader_data_json
152
+ * @param {string} config_json
153
+ * @param {string} i18n_opts_json
154
+ * @returns {string}
155
+ */
156
+ export function render_page(template, loader_data_json, config_json, i18n_opts_json) {
157
+ let deferred5_0;
158
+ let deferred5_1;
159
+ try {
160
+ const ptr0 = passStringToWasm0(template, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
161
+ const len0 = WASM_VECTOR_LEN;
162
+ const ptr1 = passStringToWasm0(loader_data_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
163
+ const len1 = WASM_VECTOR_LEN;
164
+ const ptr2 = passStringToWasm0(config_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
165
+ const len2 = WASM_VECTOR_LEN;
166
+ const ptr3 = passStringToWasm0(i18n_opts_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
167
+ const len3 = WASM_VECTOR_LEN;
168
+ const ret = wasm.render_page(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
169
+ deferred5_0 = ret[0];
170
+ deferred5_1 = ret[1];
171
+ return getStringFromWasm0(ret[0], ret[1]);
172
+ } finally {
173
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
174
+ }
175
+ }
176
+ export function __wbindgen_init_externref_table() {
177
+ const table = wasm.__wbindgen_externrefs;
178
+ const offset = table.grow(4);
179
+ table.set(0, undefined);
180
+ table.set(offset + 0, undefined);
181
+ table.set(offset + 1, null);
182
+ table.set(offset + 2, true);
183
+ table.set(offset + 3, false);
184
+ }
185
+ function getStringFromWasm0(ptr, len) {
186
+ ptr = ptr >>> 0;
187
+ return decodeText(ptr, len);
188
+ }
189
+
190
+ let cachedUint8ArrayMemory0 = null;
191
+ function getUint8ArrayMemory0() {
192
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
193
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
194
+ }
195
+ return cachedUint8ArrayMemory0;
196
+ }
197
+
198
+ function passStringToWasm0(arg, malloc, realloc) {
199
+ if (realloc === undefined) {
200
+ const buf = cachedTextEncoder.encode(arg);
201
+ const ptr = malloc(buf.length, 1) >>> 0;
202
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
203
+ WASM_VECTOR_LEN = buf.length;
204
+ return ptr;
205
+ }
206
+
207
+ let len = arg.length;
208
+ let ptr = malloc(len, 1) >>> 0;
209
+
210
+ const mem = getUint8ArrayMemory0();
211
+
212
+ let offset = 0;
213
+
214
+ for (; offset < len; offset++) {
215
+ const code = arg.charCodeAt(offset);
216
+ if (code > 0x7F) break;
217
+ mem[ptr + offset] = code;
218
+ }
219
+ if (offset !== len) {
220
+ if (offset !== 0) {
221
+ arg = arg.slice(offset);
222
+ }
223
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
224
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
225
+ const ret = cachedTextEncoder.encodeInto(arg, view);
226
+
227
+ offset += ret.written;
228
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
229
+ }
230
+
231
+ WASM_VECTOR_LEN = offset;
232
+ return ptr;
233
+ }
234
+
235
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
236
+ cachedTextDecoder.decode();
237
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
238
+ let numBytesDecoded = 0;
239
+ function decodeText(ptr, len) {
240
+ numBytesDecoded += len;
241
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
242
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
243
+ cachedTextDecoder.decode();
244
+ numBytesDecoded = len;
245
+ }
246
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
247
+ }
248
+
249
+ const cachedTextEncoder = new TextEncoder();
250
+
251
+ if (!('encodeInto' in cachedTextEncoder)) {
252
+ cachedTextEncoder.encodeInto = function (arg, view) {
253
+ const buf = cachedTextEncoder.encode(arg);
254
+ view.set(buf);
255
+ return {
256
+ read: arg.length,
257
+ written: buf.length
258
+ };
259
+ };
260
+ }
261
+
262
+ let WASM_VECTOR_LEN = 0;
263
+
264
+
265
+ let wasm;
266
+ export function __wbg_set_wasm(val) {
267
+ wasm = val;
268
+ }
Binary file
@@ -0,0 +1,16 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const ascii_escape_json: (a: number, b: number) => [number, number];
5
+ export const i18n_query: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
6
+ export const inject: (a: number, b: number, c: number, d: number) => [number, number];
7
+ export const inject_no_script: (a: number, b: number, c: number, d: number) => [number, number];
8
+ export const parse_build_output: (a: number, b: number) => [number, number];
9
+ export const parse_i18n_config: (a: number, b: number) => [number, number];
10
+ export const parse_rpc_hash_map: (a: number, b: number) => [number, number];
11
+ export const render_page: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
12
+ export const __wbindgen_externrefs: WebAssembly.Table;
13
+ export const __wbindgen_malloc: (a: number, b: number) => number;
14
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
15
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
16
+ export const __wbindgen_start: () => void;