inky-wasm 2.0.0-beta.2
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.
- package/inky_wasm.d.ts +65 -0
- package/inky_wasm.js +338 -0
- package/inky_wasm_bg.wasm +0 -0
- package/package.json +13 -0
package/inky_wasm.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Migrate v1 Inky syntax to v2.
|
|
6
|
+
* Returns the migrated HTML string.
|
|
7
|
+
*/
|
|
8
|
+
export function migrate(html: string): string;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Migrate v1 syntax and return a JSON object with `html` and `changes` fields.
|
|
12
|
+
*/
|
|
13
|
+
export function migrate_with_details(html: string): string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Convert HTML to plain text for multipart email.
|
|
17
|
+
*/
|
|
18
|
+
export function to_plain_text(html: string): string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Transform Inky HTML into email-safe table markup.
|
|
22
|
+
*/
|
|
23
|
+
export function transform(html: string): string;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Transform using hybrid output mode (div + MSO ghost tables).
|
|
27
|
+
*/
|
|
28
|
+
export function transform_hybrid(html: string): string;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Transform Inky HTML and inline CSS from `<style>` blocks.
|
|
32
|
+
* Falls back to plain transform if inlining fails.
|
|
33
|
+
*/
|
|
34
|
+
export function transform_inline(html: string): string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Transform with a custom column count.
|
|
38
|
+
*/
|
|
39
|
+
export function transform_with_config(html: string, column_count: number): string;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Transform Inky HTML with MiniJinja data merge, then inline CSS.
|
|
43
|
+
*
|
|
44
|
+
* `data_json` is a JSON string with merge variables.
|
|
45
|
+
* Missing keys render as empty strings (lenient mode).
|
|
46
|
+
* Falls back to plain transform if CSS inlining fails.
|
|
47
|
+
*/
|
|
48
|
+
export function transform_with_data(html: string, data_json: string): string;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Validate an Inky template and return diagnostics as JSON.
|
|
52
|
+
*
|
|
53
|
+
* Returns a JSON array of objects with `severity`, `rule`, and `message` fields.
|
|
54
|
+
*/
|
|
55
|
+
export function validate(html: string): string;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Validate with a custom column count.
|
|
59
|
+
*/
|
|
60
|
+
export function validate_with_config(html: string, column_count: number): string;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Get the Inky version.
|
|
64
|
+
*/
|
|
65
|
+
export function version(): string;
|
package/inky_wasm.js
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
/* @ts-self-types="./inky_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Migrate v1 Inky syntax to v2.
|
|
5
|
+
* Returns the migrated HTML string.
|
|
6
|
+
* @param {string} html
|
|
7
|
+
* @returns {string}
|
|
8
|
+
*/
|
|
9
|
+
function migrate(html) {
|
|
10
|
+
let deferred2_0;
|
|
11
|
+
let deferred2_1;
|
|
12
|
+
try {
|
|
13
|
+
const ptr0 = passStringToWasm0(html, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
14
|
+
const len0 = WASM_VECTOR_LEN;
|
|
15
|
+
const ret = wasm.migrate(ptr0, len0);
|
|
16
|
+
deferred2_0 = ret[0];
|
|
17
|
+
deferred2_1 = ret[1];
|
|
18
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
19
|
+
} finally {
|
|
20
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.migrate = migrate;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Migrate v1 syntax and return a JSON object with `html` and `changes` fields.
|
|
27
|
+
* @param {string} html
|
|
28
|
+
* @returns {string}
|
|
29
|
+
*/
|
|
30
|
+
function migrate_with_details(html) {
|
|
31
|
+
let deferred2_0;
|
|
32
|
+
let deferred2_1;
|
|
33
|
+
try {
|
|
34
|
+
const ptr0 = passStringToWasm0(html, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
35
|
+
const len0 = WASM_VECTOR_LEN;
|
|
36
|
+
const ret = wasm.migrate_with_details(ptr0, len0);
|
|
37
|
+
deferred2_0 = ret[0];
|
|
38
|
+
deferred2_1 = ret[1];
|
|
39
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
40
|
+
} finally {
|
|
41
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.migrate_with_details = migrate_with_details;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Convert HTML to plain text for multipart email.
|
|
48
|
+
* @param {string} html
|
|
49
|
+
* @returns {string}
|
|
50
|
+
*/
|
|
51
|
+
function to_plain_text(html) {
|
|
52
|
+
let deferred2_0;
|
|
53
|
+
let deferred2_1;
|
|
54
|
+
try {
|
|
55
|
+
const ptr0 = passStringToWasm0(html, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
56
|
+
const len0 = WASM_VECTOR_LEN;
|
|
57
|
+
const ret = wasm.to_plain_text(ptr0, len0);
|
|
58
|
+
deferred2_0 = ret[0];
|
|
59
|
+
deferred2_1 = ret[1];
|
|
60
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
61
|
+
} finally {
|
|
62
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.to_plain_text = to_plain_text;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Transform Inky HTML into email-safe table markup.
|
|
69
|
+
* @param {string} html
|
|
70
|
+
* @returns {string}
|
|
71
|
+
*/
|
|
72
|
+
function transform(html) {
|
|
73
|
+
let deferred2_0;
|
|
74
|
+
let deferred2_1;
|
|
75
|
+
try {
|
|
76
|
+
const ptr0 = passStringToWasm0(html, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
77
|
+
const len0 = WASM_VECTOR_LEN;
|
|
78
|
+
const ret = wasm.transform(ptr0, len0);
|
|
79
|
+
deferred2_0 = ret[0];
|
|
80
|
+
deferred2_1 = ret[1];
|
|
81
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
82
|
+
} finally {
|
|
83
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.transform = transform;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Transform using hybrid output mode (div + MSO ghost tables).
|
|
90
|
+
* @param {string} html
|
|
91
|
+
* @returns {string}
|
|
92
|
+
*/
|
|
93
|
+
function transform_hybrid(html) {
|
|
94
|
+
let deferred2_0;
|
|
95
|
+
let deferred2_1;
|
|
96
|
+
try {
|
|
97
|
+
const ptr0 = passStringToWasm0(html, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
98
|
+
const len0 = WASM_VECTOR_LEN;
|
|
99
|
+
const ret = wasm.transform_hybrid(ptr0, len0);
|
|
100
|
+
deferred2_0 = ret[0];
|
|
101
|
+
deferred2_1 = ret[1];
|
|
102
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
103
|
+
} finally {
|
|
104
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.transform_hybrid = transform_hybrid;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Transform Inky HTML and inline CSS from `<style>` blocks.
|
|
111
|
+
* Falls back to plain transform if inlining fails.
|
|
112
|
+
* @param {string} html
|
|
113
|
+
* @returns {string}
|
|
114
|
+
*/
|
|
115
|
+
function transform_inline(html) {
|
|
116
|
+
let deferred2_0;
|
|
117
|
+
let deferred2_1;
|
|
118
|
+
try {
|
|
119
|
+
const ptr0 = passStringToWasm0(html, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
120
|
+
const len0 = WASM_VECTOR_LEN;
|
|
121
|
+
const ret = wasm.transform_inline(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
|
+
exports.transform_inline = transform_inline;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Transform with a custom column count.
|
|
133
|
+
* @param {string} html
|
|
134
|
+
* @param {number} column_count
|
|
135
|
+
* @returns {string}
|
|
136
|
+
*/
|
|
137
|
+
function transform_with_config(html, column_count) {
|
|
138
|
+
let deferred2_0;
|
|
139
|
+
let deferred2_1;
|
|
140
|
+
try {
|
|
141
|
+
const ptr0 = passStringToWasm0(html, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
142
|
+
const len0 = WASM_VECTOR_LEN;
|
|
143
|
+
const ret = wasm.transform_with_config(ptr0, len0, column_count);
|
|
144
|
+
deferred2_0 = ret[0];
|
|
145
|
+
deferred2_1 = ret[1];
|
|
146
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
147
|
+
} finally {
|
|
148
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
exports.transform_with_config = transform_with_config;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Transform Inky HTML with MiniJinja data merge, then inline CSS.
|
|
155
|
+
*
|
|
156
|
+
* `data_json` is a JSON string with merge variables.
|
|
157
|
+
* Missing keys render as empty strings (lenient mode).
|
|
158
|
+
* Falls back to plain transform if CSS inlining fails.
|
|
159
|
+
* @param {string} html
|
|
160
|
+
* @param {string} data_json
|
|
161
|
+
* @returns {string}
|
|
162
|
+
*/
|
|
163
|
+
function transform_with_data(html, data_json) {
|
|
164
|
+
let deferred3_0;
|
|
165
|
+
let deferred3_1;
|
|
166
|
+
try {
|
|
167
|
+
const ptr0 = passStringToWasm0(html, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
168
|
+
const len0 = WASM_VECTOR_LEN;
|
|
169
|
+
const ptr1 = passStringToWasm0(data_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
170
|
+
const len1 = WASM_VECTOR_LEN;
|
|
171
|
+
const ret = wasm.transform_with_data(ptr0, len0, ptr1, len1);
|
|
172
|
+
deferred3_0 = ret[0];
|
|
173
|
+
deferred3_1 = ret[1];
|
|
174
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
175
|
+
} finally {
|
|
176
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
exports.transform_with_data = transform_with_data;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Validate an Inky template and return diagnostics as JSON.
|
|
183
|
+
*
|
|
184
|
+
* Returns a JSON array of objects with `severity`, `rule`, and `message` fields.
|
|
185
|
+
* @param {string} html
|
|
186
|
+
* @returns {string}
|
|
187
|
+
*/
|
|
188
|
+
function validate(html) {
|
|
189
|
+
let deferred2_0;
|
|
190
|
+
let deferred2_1;
|
|
191
|
+
try {
|
|
192
|
+
const ptr0 = passStringToWasm0(html, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
193
|
+
const len0 = WASM_VECTOR_LEN;
|
|
194
|
+
const ret = wasm.validate(ptr0, len0);
|
|
195
|
+
deferred2_0 = ret[0];
|
|
196
|
+
deferred2_1 = ret[1];
|
|
197
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
198
|
+
} finally {
|
|
199
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
exports.validate = validate;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Validate with a custom column count.
|
|
206
|
+
* @param {string} html
|
|
207
|
+
* @param {number} column_count
|
|
208
|
+
* @returns {string}
|
|
209
|
+
*/
|
|
210
|
+
function validate_with_config(html, column_count) {
|
|
211
|
+
let deferred2_0;
|
|
212
|
+
let deferred2_1;
|
|
213
|
+
try {
|
|
214
|
+
const ptr0 = passStringToWasm0(html, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
215
|
+
const len0 = WASM_VECTOR_LEN;
|
|
216
|
+
const ret = wasm.validate_with_config(ptr0, len0, column_count);
|
|
217
|
+
deferred2_0 = ret[0];
|
|
218
|
+
deferred2_1 = ret[1];
|
|
219
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
220
|
+
} finally {
|
|
221
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
exports.validate_with_config = validate_with_config;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Get the Inky version.
|
|
228
|
+
* @returns {string}
|
|
229
|
+
*/
|
|
230
|
+
function version() {
|
|
231
|
+
let deferred1_0;
|
|
232
|
+
let deferred1_1;
|
|
233
|
+
try {
|
|
234
|
+
const ret = wasm.version();
|
|
235
|
+
deferred1_0 = ret[0];
|
|
236
|
+
deferred1_1 = ret[1];
|
|
237
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
238
|
+
} finally {
|
|
239
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
exports.version = version;
|
|
243
|
+
|
|
244
|
+
function __wbg_get_imports() {
|
|
245
|
+
const import0 = {
|
|
246
|
+
__proto__: null,
|
|
247
|
+
__wbindgen_init_externref_table: function() {
|
|
248
|
+
const table = wasm.__wbindgen_externrefs;
|
|
249
|
+
const offset = table.grow(4);
|
|
250
|
+
table.set(0, undefined);
|
|
251
|
+
table.set(offset + 0, undefined);
|
|
252
|
+
table.set(offset + 1, null);
|
|
253
|
+
table.set(offset + 2, true);
|
|
254
|
+
table.set(offset + 3, false);
|
|
255
|
+
},
|
|
256
|
+
};
|
|
257
|
+
return {
|
|
258
|
+
__proto__: null,
|
|
259
|
+
"./inky_wasm_bg.js": import0,
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function getStringFromWasm0(ptr, len) {
|
|
264
|
+
ptr = ptr >>> 0;
|
|
265
|
+
return decodeText(ptr, len);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
let cachedUint8ArrayMemory0 = null;
|
|
269
|
+
function getUint8ArrayMemory0() {
|
|
270
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
271
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
272
|
+
}
|
|
273
|
+
return cachedUint8ArrayMemory0;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
277
|
+
if (realloc === undefined) {
|
|
278
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
279
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
280
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
281
|
+
WASM_VECTOR_LEN = buf.length;
|
|
282
|
+
return ptr;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
let len = arg.length;
|
|
286
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
287
|
+
|
|
288
|
+
const mem = getUint8ArrayMemory0();
|
|
289
|
+
|
|
290
|
+
let offset = 0;
|
|
291
|
+
|
|
292
|
+
for (; offset < len; offset++) {
|
|
293
|
+
const code = arg.charCodeAt(offset);
|
|
294
|
+
if (code > 0x7F) break;
|
|
295
|
+
mem[ptr + offset] = code;
|
|
296
|
+
}
|
|
297
|
+
if (offset !== len) {
|
|
298
|
+
if (offset !== 0) {
|
|
299
|
+
arg = arg.slice(offset);
|
|
300
|
+
}
|
|
301
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
302
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
303
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
304
|
+
|
|
305
|
+
offset += ret.written;
|
|
306
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
WASM_VECTOR_LEN = offset;
|
|
310
|
+
return ptr;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
314
|
+
cachedTextDecoder.decode();
|
|
315
|
+
function decodeText(ptr, len) {
|
|
316
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
const cachedTextEncoder = new TextEncoder();
|
|
320
|
+
|
|
321
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
322
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
323
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
324
|
+
view.set(buf);
|
|
325
|
+
return {
|
|
326
|
+
read: arg.length,
|
|
327
|
+
written: buf.length
|
|
328
|
+
};
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
let WASM_VECTOR_LEN = 0;
|
|
333
|
+
|
|
334
|
+
const wasmPath = `${__dirname}/inky_wasm_bg.wasm`;
|
|
335
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
336
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
337
|
+
let wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
|
|
338
|
+
wasm.__wbindgen_start();
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "inky-wasm",
|
|
3
|
+
"description": "WASM bindings for Inky",
|
|
4
|
+
"version": "2.0.0-beta.2",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"files": [
|
|
7
|
+
"inky_wasm_bg.wasm",
|
|
8
|
+
"inky_wasm.js",
|
|
9
|
+
"inky_wasm.d.ts"
|
|
10
|
+
],
|
|
11
|
+
"main": "inky_wasm.js",
|
|
12
|
+
"types": "inky_wasm.d.ts"
|
|
13
|
+
}
|