@css-inline/css-inline-wasm 0.13.1 → 0.14.0

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/index.d.ts CHANGED
@@ -19,6 +19,7 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
19
19
  */
20
20
  export declare const initWasm: (module_or_path: Promise<InitInput> | InitInput) => Promise<void>;
21
21
  export declare function inline(html: string, options?: InlineOptions): string;
22
+ export declare function inlineFragment(html: string, css: string, options?: InlineOptions): string;
22
23
  export declare function version(): string;
23
24
 
24
25
  export {};
package/index.js CHANGED
@@ -22,6 +22,7 @@ var wasm_binding_exports = {};
22
22
  __export(wasm_binding_exports, {
23
23
  initWasm: () => initWasm,
24
24
  inline: () => inline2,
25
+ inlineFragment: () => inlineFragment2,
25
26
  version: () => version2
26
27
  });
27
28
  module.exports = __toCommonJS(wasm_binding_exports);
@@ -33,7 +34,12 @@ heap.push(void 0, null, true, false);
33
34
  function getObject(idx) {
34
35
  return heap[idx];
35
36
  }
36
- var WASM_VECTOR_LEN = 0;
37
+ var cachedTextDecoder = typeof TextDecoder !== "undefined" ? new TextDecoder("utf-8", { ignoreBOM: true, fatal: true }) : { decode: () => {
38
+ throw Error("TextDecoder not available");
39
+ } };
40
+ if (typeof TextDecoder !== "undefined") {
41
+ cachedTextDecoder.decode();
42
+ }
37
43
  var cachedUint8Memory0 = null;
38
44
  function getUint8Memory0() {
39
45
  if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
@@ -41,6 +47,20 @@ function getUint8Memory0() {
41
47
  }
42
48
  return cachedUint8Memory0;
43
49
  }
50
+ function getStringFromWasm0(ptr, len) {
51
+ ptr = ptr >>> 0;
52
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
53
+ }
54
+ var heap_next = heap.length;
55
+ function addHeapObject(obj) {
56
+ if (heap_next === heap.length)
57
+ heap.push(heap.length + 1);
58
+ const idx = heap_next;
59
+ heap_next = heap[idx];
60
+ heap[idx] = obj;
61
+ return idx;
62
+ }
63
+ var WASM_VECTOR_LEN = 0;
44
64
  var cachedTextEncoder = typeof TextEncoder !== "undefined" ? new TextEncoder("utf-8") : { encode: () => {
45
65
  throw Error("TextEncoder not available");
46
66
  } };
@@ -80,6 +100,7 @@ function passStringToWasm0(arg, malloc, realloc) {
80
100
  const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
81
101
  const ret = encodeString(arg, view);
82
102
  offset += ret.written;
103
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
83
104
  }
84
105
  WASM_VECTOR_LEN = offset;
85
106
  return ptr;
@@ -94,25 +115,6 @@ function getInt32Memory0() {
94
115
  }
95
116
  return cachedInt32Memory0;
96
117
  }
97
- var cachedTextDecoder = typeof TextDecoder !== "undefined" ? new TextDecoder("utf-8", { ignoreBOM: true, fatal: true }) : { decode: () => {
98
- throw Error("TextDecoder not available");
99
- } };
100
- if (typeof TextDecoder !== "undefined") {
101
- cachedTextDecoder.decode();
102
- }
103
- function getStringFromWasm0(ptr, len) {
104
- ptr = ptr >>> 0;
105
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
106
- }
107
- var heap_next = heap.length;
108
- function addHeapObject(obj) {
109
- if (heap_next === heap.length)
110
- heap.push(heap.length + 1);
111
- const idx = heap_next;
112
- heap_next = heap[idx];
113
- heap[idx] = obj;
114
- return idx;
115
- }
116
118
  function dropObject(idx) {
117
119
  if (idx < 132)
118
120
  return;
@@ -214,6 +216,35 @@ function inline(html, options) {
214
216
  wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
215
217
  }
216
218
  }
219
+ function inlineFragment(html, css, options) {
220
+ let deferred4_0;
221
+ let deferred4_1;
222
+ try {
223
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
224
+ const ptr0 = passStringToWasm0(html, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
225
+ const len0 = WASM_VECTOR_LEN;
226
+ const ptr1 = passStringToWasm0(css, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
227
+ const len1 = WASM_VECTOR_LEN;
228
+ wasm.inlineFragment(retptr, ptr0, len0, ptr1, len1, addHeapObject(options));
229
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
230
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
231
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
232
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
233
+ var ptr3 = r0;
234
+ var len3 = r1;
235
+ if (r3) {
236
+ ptr3 = 0;
237
+ len3 = 0;
238
+ throw takeObject(r2);
239
+ }
240
+ deferred4_0 = ptr3;
241
+ deferred4_1 = len3;
242
+ return getStringFromWasm0(ptr3, len3);
243
+ } finally {
244
+ wasm.__wbindgen_add_to_stack_pointer(16);
245
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
246
+ }
247
+ }
217
248
  function version() {
218
249
  let deferred1_0;
219
250
  let deferred1_1;
@@ -261,33 +292,20 @@ function __wbg_get_imports() {
261
292
  const ret = getObject(arg0) === void 0;
262
293
  return ret;
263
294
  };
264
- imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
265
- const obj = getObject(arg1);
266
- const ret = typeof obj === "string" ? obj : void 0;
267
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
268
- var len1 = WASM_VECTOR_LEN;
269
- getInt32Memory0()[arg0 / 4 + 1] = len1;
270
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
271
- };
272
- imports.wbg.__wbindgen_boolean_get = function(arg0) {
273
- const v = getObject(arg0);
274
- const ret = typeof v === "boolean" ? v ? 1 : 0 : 2;
275
- return ret;
295
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
296
+ const ret = getStringFromWasm0(arg0, arg1);
297
+ return addHeapObject(ret);
276
298
  };
277
299
  imports.wbg.__wbindgen_is_object = function(arg0) {
278
300
  const val = getObject(arg0);
279
301
  const ret = typeof val === "object" && val !== null;
280
302
  return ret;
281
303
  };
282
- imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
283
- const ret = getStringFromWasm0(arg0, arg1);
284
- return addHeapObject(ret);
285
- };
286
304
  imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
287
305
  const ret = getObject(arg0);
288
306
  return addHeapObject(ret);
289
307
  };
290
- imports.wbg.__wbg_getwithrefkey_4a92a5eca60879b9 = function(arg0, arg1) {
308
+ imports.wbg.__wbg_getwithrefkey_edc2c8960f0f1191 = function(arg0, arg1) {
291
309
  const ret = getObject(arg0)[getObject(arg1)];
292
310
  return addHeapObject(ret);
293
311
  };
@@ -295,7 +313,7 @@ function __wbg_get_imports() {
295
313
  const ret = getObject(arg0) in getObject(arg1);
296
314
  return ret;
297
315
  };
298
- imports.wbg.__wbg_isSafeInteger_f93fde0dca9820f8 = function(arg0) {
316
+ imports.wbg.__wbg_isSafeInteger_f7b04ef02296c4d2 = function(arg0) {
299
317
  const ret = Number.isSafeInteger(getObject(arg0));
300
318
  return ret;
301
319
  };
@@ -303,7 +321,23 @@ function __wbg_get_imports() {
303
321
  const ret = +getObject(arg0);
304
322
  return ret;
305
323
  };
306
- imports.wbg.__wbg_length_1d25fa9e4ac21ce7 = function(arg0) {
324
+ imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
325
+ const obj = getObject(arg1);
326
+ const ret = typeof obj === "string" ? obj : void 0;
327
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
328
+ var len1 = WASM_VECTOR_LEN;
329
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
330
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
331
+ };
332
+ imports.wbg.__wbindgen_boolean_get = function(arg0) {
333
+ const v = getObject(arg0);
334
+ const ret = typeof v === "boolean" ? v ? 1 : 0 : 2;
335
+ return ret;
336
+ };
337
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
338
+ takeObject(arg0);
339
+ };
340
+ imports.wbg.__wbg_length_c20a40f15020d68a = function(arg0) {
307
341
  const ret = getObject(arg0).length;
308
342
  return ret;
309
343
  };
@@ -311,20 +345,17 @@ function __wbg_get_imports() {
311
345
  const ret = wasm.memory;
312
346
  return addHeapObject(ret);
313
347
  };
314
- imports.wbg.__wbg_buffer_a448f833075b71ba = function(arg0) {
348
+ imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) {
315
349
  const ret = getObject(arg0).buffer;
316
350
  return addHeapObject(ret);
317
351
  };
318
- imports.wbg.__wbg_new_8f67e318f15d7254 = function(arg0) {
352
+ imports.wbg.__wbg_new_63b92bc8671ed464 = function(arg0) {
319
353
  const ret = new Uint8Array(getObject(arg0));
320
354
  return addHeapObject(ret);
321
355
  };
322
- imports.wbg.__wbg_set_2357bf09366ee480 = function(arg0, arg1, arg2) {
356
+ imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) {
323
357
  getObject(arg0).set(getObject(arg1), arg2 >>> 0);
324
358
  };
325
- imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
326
- takeObject(arg0);
327
- };
328
359
  imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
329
360
  const ret = new Error(getStringFromWasm0(arg0, arg1));
330
361
  return addHeapObject(ret);
@@ -339,7 +370,7 @@ function __wbg_get_imports() {
339
370
  getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
340
371
  getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
341
372
  };
342
- imports.wbg.__wbg_instanceof_Uint8Array_bced6f43aed8c1aa = function(arg0) {
373
+ imports.wbg.__wbg_instanceof_Uint8Array_2b3bbecd033d19f6 = function(arg0) {
343
374
  let result;
344
375
  try {
345
376
  result = getObject(arg0) instanceof Uint8Array;
@@ -349,7 +380,7 @@ function __wbg_get_imports() {
349
380
  const ret = result;
350
381
  return ret;
351
382
  };
352
- imports.wbg.__wbg_instanceof_ArrayBuffer_e7d53d51371448e2 = function(arg0) {
383
+ imports.wbg.__wbg_instanceof_ArrayBuffer_836825be07d4c9d2 = function(arg0) {
353
384
  let result;
354
385
  try {
355
386
  result = getObject(arg0) instanceof ArrayBuffer;
@@ -411,6 +442,9 @@ var initWasm = async (module_or_path) => {
411
442
  function inline2(html, options) {
412
443
  return inline(html, options);
413
444
  }
445
+ function inlineFragment2(html, css, options) {
446
+ return inlineFragment(html, css, options);
447
+ }
414
448
  function version2() {
415
449
  return version();
416
450
  }
package/index.min.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var cssInline=(()=>{var S=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var B=(e,n)=>{for(var t in n)S(e,t,{get:n[t],enumerable:!0})},q=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of D(n))!N.call(e,i)&&i!==t&&S(e,i,{get:()=>n[i],enumerable:!(r=$(n,i))||r.enumerable});return e};var z=e=>q(S({},"__esModule",{value:!0}),e);var Y={};B(Y,{initWasm:()=>K,inline:()=>Q,version:()=>X});var c,b=new Array(128).fill(void 0);b.push(void 0,null,!0,!1);function o(e){return b[e]}var h=0,g=null;function A(){return(g===null||g.byteLength===0)&&(g=new Uint8Array(c.memory.buffer)),g}var I=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},C=typeof I.encodeInto=="function"?function(e,n){return I.encodeInto(e,n)}:function(e,n){let t=I.encode(e);return n.set(t),{read:e.length,written:t.length}};function W(e,n,t){if(t===void 0){let _=I.encode(e),a=n(_.length,1)>>>0;return A().subarray(a,a+_.length).set(_),h=_.length,a}let r=e.length,i=n(r,1)>>>0,f=A(),s=0;for(;s<r;s++){let _=e.charCodeAt(s);if(_>127)break;f[i+s]=_}if(s!==r){s!==0&&(e=e.slice(s)),i=t(i,r,r=s+e.length*3,1)>>>0;let _=A().subarray(i+s,i+r),a=C(e,_);s+=a.written}return h=s,i}function j(e){return e==null}var w=null;function u(){return(w===null||w.byteLength===0)&&(w=new Int32Array(c.memory.buffer)),w}var M=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&M.decode();function m(e,n){return e=e>>>0,M.decode(A().subarray(e,e+n))}var p=b.length;function l(e){p===b.length&&b.push(b.length+1);let n=p;return p=b[n],b[n]=e,n}function P(e){e<132||(b[e]=p,p=e)}function O(e){let n=o(e);return P(e),n}var y=null;function H(){return(y===null||y.byteLength===0)&&(y=new Float64Array(c.memory.buffer)),y}function E(e){let n=typeof e;if(n=="number"||n=="boolean"||e==null)return`${e}`;if(n=="string")return`"${e}"`;if(n=="symbol"){let i=e.description;return i==null?"Symbol":`Symbol(${i})`}if(n=="function"){let i=e.name;return typeof i=="string"&&i.length>0?`Function(${i})`:"Function"}if(Array.isArray(e)){let i=e.length,f="[";i>0&&(f+=E(e[0]));for(let s=1;s<i;s++)f+=", "+E(e[s]);return f+="]",f}let t=/\[object ([^\]]+)\]/.exec(toString.call(e)),r;if(t.length>1)r=t[1];else return toString.call(e);if(r=="Object")try{return"Object("+JSON.stringify(e)+")"}catch{return"Object"}return e instanceof Error?`${e.name}: ${e.message}
2
- ${e.stack}`:r}function T(e,n){let t,r;try{let d=c.__wbindgen_add_to_stack_pointer(-16),L=W(e,c.__wbindgen_malloc,c.__wbindgen_realloc),R=h;c.inline(d,L,R,l(n));var i=u()[d/4+0],f=u()[d/4+1],s=u()[d/4+2],_=u()[d/4+3],a=i,x=f;if(_)throw a=0,x=0,O(s);return t=a,r=x,m(a,x)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_free(t,r,1)}}function k(){let e,n;try{let i=c.__wbindgen_add_to_stack_pointer(-16);c.version(i);var t=u()[i/4+0],r=u()[i/4+1];return e=t,n=r,m(t,r)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_free(e,n,1)}}async function J(e,n){if(typeof Response=="function"&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,n)}catch(r){if(e.headers.get("Content-Type")!="application/wasm")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",r);else throw r}let t=await e.arrayBuffer();return await WebAssembly.instantiate(t,n)}else{let t=await WebAssembly.instantiate(e,n);return t instanceof WebAssembly.Instance?{instance:t,module:e}:t}}function V(){let e={};return e.wbg={},e.wbg.__wbindgen_is_undefined=function(n){return o(n)===void 0},e.wbg.__wbindgen_string_get=function(n,t){let r=o(t),i=typeof r=="string"?r:void 0;var f=j(i)?0:W(i,c.__wbindgen_malloc,c.__wbindgen_realloc),s=h;u()[n/4+1]=s,u()[n/4+0]=f},e.wbg.__wbindgen_boolean_get=function(n){let t=o(n);return typeof t=="boolean"?t?1:0:2},e.wbg.__wbindgen_is_object=function(n){let t=o(n);return typeof t=="object"&&t!==null},e.wbg.__wbindgen_string_new=function(n,t){let r=m(n,t);return l(r)},e.wbg.__wbindgen_object_clone_ref=function(n){let t=o(n);return l(t)},e.wbg.__wbg_getwithrefkey_4a92a5eca60879b9=function(n,t){let r=o(n)[o(t)];return l(r)},e.wbg.__wbindgen_in=function(n,t){return o(n)in o(t)},e.wbg.__wbg_isSafeInteger_f93fde0dca9820f8=function(n){return Number.isSafeInteger(o(n))},e.wbg.__wbindgen_as_number=function(n){return+o(n)},e.wbg.__wbg_length_1d25fa9e4ac21ce7=function(n){return o(n).length},e.wbg.__wbindgen_memory=function(){let n=c.memory;return l(n)},e.wbg.__wbg_buffer_a448f833075b71ba=function(n){let t=o(n).buffer;return l(t)},e.wbg.__wbg_new_8f67e318f15d7254=function(n){let t=new Uint8Array(o(n));return l(t)},e.wbg.__wbg_set_2357bf09366ee480=function(n,t,r){o(n).set(o(t),r>>>0)},e.wbg.__wbindgen_object_drop_ref=function(n){O(n)},e.wbg.__wbindgen_error_new=function(n,t){let r=new Error(m(n,t));return l(r)},e.wbg.__wbindgen_jsval_loose_eq=function(n,t){return o(n)==o(t)},e.wbg.__wbindgen_number_get=function(n,t){let r=o(t),i=typeof r=="number"?r:void 0;H()[n/8+1]=j(i)?0:i,u()[n/4+0]=!j(i)},e.wbg.__wbg_instanceof_Uint8Array_bced6f43aed8c1aa=function(n){let t;try{t=o(n)instanceof Uint8Array}catch{t=!1}return t},e.wbg.__wbg_instanceof_ArrayBuffer_e7d53d51371448e2=function(n){let t;try{t=o(n)instanceof ArrayBuffer}catch{t=!1}return t},e.wbg.__wbindgen_debug_string=function(n,t){let r=E(o(t)),i=W(r,c.__wbindgen_malloc,c.__wbindgen_realloc),f=h;u()[n/4+1]=f,u()[n/4+0]=i},e.wbg.__wbindgen_throw=function(n,t){throw new Error(m(n,t))},e}function G(e,n){return c=e.exports,U.__wbindgen_wasm_module=n,y=null,w=null,g=null,c}async function U(e){if(c!==void 0)return c;typeof e>"u"&&(e=new URL("index_bg.wasm",void 0));let n=V();(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)&&(e=fetch(e));let{instance:t,module:r}=await J(await e,n);return G(t,r)}var v=U;var F=!1,K=async e=>{if(F)throw new Error("Already initialized. The `initWasm()` function can be used only once.");await v(await e),F=!0};function Q(e,n){return T(e,n)}function X(){return k()}return z(Y);})();
1
+ "use strict";var cssInline=(()=>{var v=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var P=(n,e)=>{for(var t in e)v(n,t,{get:e[t],enumerable:!0})},H=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of z(e))!C.call(n,i)&&i!==t&&v(n,i,{get:()=>e[i],enumerable:!(r=q(e,i))||r.enumerable});return n};var J=n=>H(v({},"__esModule",{value:!0}),n);var rn={};P(rn,{initWasm:()=>Z,inline:()=>nn,inlineFragment:()=>en,version:()=>tn});var o,d=new Array(128).fill(void 0);d.push(void 0,null,!0,!1);function c(n){return d[n]}var M=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&M.decode();var p=null;function S(){return(p===null||p.byteLength===0)&&(p=new Uint8Array(o.memory.buffer)),p}function m(n,e){return n=n>>>0,M.decode(S().subarray(n,n+e))}var x=d.length;function l(n){x===d.length&&d.push(d.length+1);let e=x;return x=d[e],d[e]=n,e}var y=0,j=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},V=typeof j.encodeInto=="function"?function(n,e){return j.encodeInto(n,e)}:function(n,e){let t=j.encode(n);return e.set(t),{read:n.length,written:t.length}};function I(n,e,t){if(t===void 0){let a=j.encode(n),u=e(a.length,1)>>>0;return S().subarray(u,u+a.length).set(a),y=a.length,u}let r=n.length,i=e(r,1)>>>0,f=S(),s=0;for(;s<r;s++){let a=n.charCodeAt(s);if(a>127)break;f[i+s]=a}if(s!==r){s!==0&&(n=n.slice(s)),i=t(i,r,r=s+n.length*3,1)>>>0;let a=S().subarray(i+s,i+r),u=V(n,a);s+=u.written,i=t(i,r,s,1)>>>0}return y=s,i}function O(n){return n==null}var h=null;function _(){return(h===null||h.byteLength===0)&&(h=new Int32Array(o.memory.buffer)),h}function G(n){n<132||(d[n]=x,x=n)}function F(n){let e=c(n);return G(n),e}var A=null;function K(){return(A===null||A.byteLength===0)&&(A=new Float64Array(o.memory.buffer)),A}function E(n){let e=typeof n;if(e=="number"||e=="boolean"||n==null)return`${n}`;if(e=="string")return`"${n}"`;if(e=="symbol"){let i=n.description;return i==null?"Symbol":`Symbol(${i})`}if(e=="function"){let i=n.name;return typeof i=="string"&&i.length>0?`Function(${i})`:"Function"}if(Array.isArray(n)){let i=n.length,f="[";i>0&&(f+=E(n[0]));for(let s=1;s<i;s++)f+=", "+E(n[s]);return f+="]",f}let t=/\[object ([^\]]+)\]/.exec(toString.call(n)),r;if(t.length>1)r=t[1];else return toString.call(n);if(r=="Object")try{return"Object("+JSON.stringify(n)+")"}catch{return"Object"}return n instanceof Error?`${n.name}: ${n.message}
2
+ ${n.stack}`:r}function T(n,e){let t,r;try{let b=o.__wbindgen_add_to_stack_pointer(-16),w=I(n,o.__wbindgen_malloc,o.__wbindgen_realloc),W=y;o.inline(b,w,W,l(e));var i=_()[b/4+0],f=_()[b/4+1],s=_()[b/4+2],a=_()[b/4+3],u=i,g=f;if(a)throw u=0,g=0,F(s);return t=u,r=g,m(u,g)}finally{o.__wbindgen_add_to_stack_pointer(16),o.__wbindgen_free(t,r,1)}}function k(n,e,t){let r,i;try{let w=o.__wbindgen_add_to_stack_pointer(-16),W=I(n,o.__wbindgen_malloc,o.__wbindgen_realloc),D=y,N=I(e,o.__wbindgen_malloc,o.__wbindgen_realloc),B=y;o.inlineFragment(w,W,D,N,B,l(t));var f=_()[w/4+0],s=_()[w/4+1],a=_()[w/4+2],u=_()[w/4+3],g=f,b=s;if(u)throw g=0,b=0,F(a);return r=g,i=b,m(g,b)}finally{o.__wbindgen_add_to_stack_pointer(16),o.__wbindgen_free(r,i,1)}}function U(){let n,e;try{let i=o.__wbindgen_add_to_stack_pointer(-16);o.version(i);var t=_()[i/4+0],r=_()[i/4+1];return n=t,e=r,m(t,r)}finally{o.__wbindgen_add_to_stack_pointer(16),o.__wbindgen_free(n,e,1)}}async function Q(n,e){if(typeof Response=="function"&&n instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(n,e)}catch(r){if(n.headers.get("Content-Type")!="application/wasm")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",r);else throw r}let t=await n.arrayBuffer();return await WebAssembly.instantiate(t,e)}else{let t=await WebAssembly.instantiate(n,e);return t instanceof WebAssembly.Instance?{instance:t,module:n}:t}}function X(){let n={};return n.wbg={},n.wbg.__wbindgen_is_undefined=function(e){return c(e)===void 0},n.wbg.__wbindgen_string_new=function(e,t){let r=m(e,t);return l(r)},n.wbg.__wbindgen_is_object=function(e){let t=c(e);return typeof t=="object"&&t!==null},n.wbg.__wbindgen_object_clone_ref=function(e){let t=c(e);return l(t)},n.wbg.__wbg_getwithrefkey_edc2c8960f0f1191=function(e,t){let r=c(e)[c(t)];return l(r)},n.wbg.__wbindgen_in=function(e,t){return c(e)in c(t)},n.wbg.__wbg_isSafeInteger_f7b04ef02296c4d2=function(e){return Number.isSafeInteger(c(e))},n.wbg.__wbindgen_as_number=function(e){return+c(e)},n.wbg.__wbindgen_string_get=function(e,t){let r=c(t),i=typeof r=="string"?r:void 0;var f=O(i)?0:I(i,o.__wbindgen_malloc,o.__wbindgen_realloc),s=y;_()[e/4+1]=s,_()[e/4+0]=f},n.wbg.__wbindgen_boolean_get=function(e){let t=c(e);return typeof t=="boolean"?t?1:0:2},n.wbg.__wbindgen_object_drop_ref=function(e){F(e)},n.wbg.__wbg_length_c20a40f15020d68a=function(e){return c(e).length},n.wbg.__wbindgen_memory=function(){let e=o.memory;return l(e)},n.wbg.__wbg_buffer_12d079cc21e14bdb=function(e){let t=c(e).buffer;return l(t)},n.wbg.__wbg_new_63b92bc8671ed464=function(e){let t=new Uint8Array(c(e));return l(t)},n.wbg.__wbg_set_a47bac70306a19a7=function(e,t,r){c(e).set(c(t),r>>>0)},n.wbg.__wbindgen_error_new=function(e,t){let r=new Error(m(e,t));return l(r)},n.wbg.__wbindgen_jsval_loose_eq=function(e,t){return c(e)==c(t)},n.wbg.__wbindgen_number_get=function(e,t){let r=c(t),i=typeof r=="number"?r:void 0;K()[e/8+1]=O(i)?0:i,_()[e/4+0]=!O(i)},n.wbg.__wbg_instanceof_Uint8Array_2b3bbecd033d19f6=function(e){let t;try{t=c(e)instanceof Uint8Array}catch{t=!1}return t},n.wbg.__wbg_instanceof_ArrayBuffer_836825be07d4c9d2=function(e){let t;try{t=c(e)instanceof ArrayBuffer}catch{t=!1}return t},n.wbg.__wbindgen_debug_string=function(e,t){let r=E(c(t)),i=I(r,o.__wbindgen_malloc,o.__wbindgen_realloc),f=y;_()[e/4+1]=f,_()[e/4+0]=i},n.wbg.__wbindgen_throw=function(e,t){throw new Error(m(e,t))},n}function Y(n,e){return o=n.exports,L.__wbindgen_wasm_module=e,A=null,h=null,p=null,o}async function L(n){if(o!==void 0)return o;typeof n>"u"&&(n=new URL("index_bg.wasm",void 0));let e=X();(typeof n=="string"||typeof Request=="function"&&n instanceof Request||typeof URL=="function"&&n instanceof URL)&&(n=fetch(n));let{instance:t,module:r}=await Q(await n,e);return Y(t,r)}var R=L;var $=!1,Z=async n=>{if($)throw new Error("Already initialized. The `initWasm()` function can be used only once.");await R(await n),$=!0};function nn(n,e){return T(n,e)}function en(n,e,t){return k(n,e,t)}function tn(){return U()}return J(rn);})();
package/index.mjs CHANGED
@@ -5,7 +5,12 @@ heap.push(void 0, null, true, false);
5
5
  function getObject(idx) {
6
6
  return heap[idx];
7
7
  }
8
- var WASM_VECTOR_LEN = 0;
8
+ var cachedTextDecoder = typeof TextDecoder !== "undefined" ? new TextDecoder("utf-8", { ignoreBOM: true, fatal: true }) : { decode: () => {
9
+ throw Error("TextDecoder not available");
10
+ } };
11
+ if (typeof TextDecoder !== "undefined") {
12
+ cachedTextDecoder.decode();
13
+ }
9
14
  var cachedUint8Memory0 = null;
10
15
  function getUint8Memory0() {
11
16
  if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
@@ -13,6 +18,20 @@ function getUint8Memory0() {
13
18
  }
14
19
  return cachedUint8Memory0;
15
20
  }
21
+ function getStringFromWasm0(ptr, len) {
22
+ ptr = ptr >>> 0;
23
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
24
+ }
25
+ var heap_next = heap.length;
26
+ function addHeapObject(obj) {
27
+ if (heap_next === heap.length)
28
+ heap.push(heap.length + 1);
29
+ const idx = heap_next;
30
+ heap_next = heap[idx];
31
+ heap[idx] = obj;
32
+ return idx;
33
+ }
34
+ var WASM_VECTOR_LEN = 0;
16
35
  var cachedTextEncoder = typeof TextEncoder !== "undefined" ? new TextEncoder("utf-8") : { encode: () => {
17
36
  throw Error("TextEncoder not available");
18
37
  } };
@@ -52,6 +71,7 @@ function passStringToWasm0(arg, malloc, realloc) {
52
71
  const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
53
72
  const ret = encodeString(arg, view);
54
73
  offset += ret.written;
74
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
55
75
  }
56
76
  WASM_VECTOR_LEN = offset;
57
77
  return ptr;
@@ -66,25 +86,6 @@ function getInt32Memory0() {
66
86
  }
67
87
  return cachedInt32Memory0;
68
88
  }
69
- var cachedTextDecoder = typeof TextDecoder !== "undefined" ? new TextDecoder("utf-8", { ignoreBOM: true, fatal: true }) : { decode: () => {
70
- throw Error("TextDecoder not available");
71
- } };
72
- if (typeof TextDecoder !== "undefined") {
73
- cachedTextDecoder.decode();
74
- }
75
- function getStringFromWasm0(ptr, len) {
76
- ptr = ptr >>> 0;
77
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
78
- }
79
- var heap_next = heap.length;
80
- function addHeapObject(obj) {
81
- if (heap_next === heap.length)
82
- heap.push(heap.length + 1);
83
- const idx = heap_next;
84
- heap_next = heap[idx];
85
- heap[idx] = obj;
86
- return idx;
87
- }
88
89
  function dropObject(idx) {
89
90
  if (idx < 132)
90
91
  return;
@@ -186,6 +187,35 @@ function inline(html, options) {
186
187
  wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
187
188
  }
188
189
  }
190
+ function inlineFragment(html, css, options) {
191
+ let deferred4_0;
192
+ let deferred4_1;
193
+ try {
194
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
195
+ const ptr0 = passStringToWasm0(html, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
196
+ const len0 = WASM_VECTOR_LEN;
197
+ const ptr1 = passStringToWasm0(css, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
198
+ const len1 = WASM_VECTOR_LEN;
199
+ wasm.inlineFragment(retptr, ptr0, len0, ptr1, len1, addHeapObject(options));
200
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
201
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
202
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
203
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
204
+ var ptr3 = r0;
205
+ var len3 = r1;
206
+ if (r3) {
207
+ ptr3 = 0;
208
+ len3 = 0;
209
+ throw takeObject(r2);
210
+ }
211
+ deferred4_0 = ptr3;
212
+ deferred4_1 = len3;
213
+ return getStringFromWasm0(ptr3, len3);
214
+ } finally {
215
+ wasm.__wbindgen_add_to_stack_pointer(16);
216
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
217
+ }
218
+ }
189
219
  function version() {
190
220
  let deferred1_0;
191
221
  let deferred1_1;
@@ -233,33 +263,20 @@ function __wbg_get_imports() {
233
263
  const ret = getObject(arg0) === void 0;
234
264
  return ret;
235
265
  };
236
- imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
237
- const obj = getObject(arg1);
238
- const ret = typeof obj === "string" ? obj : void 0;
239
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
240
- var len1 = WASM_VECTOR_LEN;
241
- getInt32Memory0()[arg0 / 4 + 1] = len1;
242
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
243
- };
244
- imports.wbg.__wbindgen_boolean_get = function(arg0) {
245
- const v = getObject(arg0);
246
- const ret = typeof v === "boolean" ? v ? 1 : 0 : 2;
247
- return ret;
266
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
267
+ const ret = getStringFromWasm0(arg0, arg1);
268
+ return addHeapObject(ret);
248
269
  };
249
270
  imports.wbg.__wbindgen_is_object = function(arg0) {
250
271
  const val = getObject(arg0);
251
272
  const ret = typeof val === "object" && val !== null;
252
273
  return ret;
253
274
  };
254
- imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
255
- const ret = getStringFromWasm0(arg0, arg1);
256
- return addHeapObject(ret);
257
- };
258
275
  imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
259
276
  const ret = getObject(arg0);
260
277
  return addHeapObject(ret);
261
278
  };
262
- imports.wbg.__wbg_getwithrefkey_4a92a5eca60879b9 = function(arg0, arg1) {
279
+ imports.wbg.__wbg_getwithrefkey_edc2c8960f0f1191 = function(arg0, arg1) {
263
280
  const ret = getObject(arg0)[getObject(arg1)];
264
281
  return addHeapObject(ret);
265
282
  };
@@ -267,7 +284,7 @@ function __wbg_get_imports() {
267
284
  const ret = getObject(arg0) in getObject(arg1);
268
285
  return ret;
269
286
  };
270
- imports.wbg.__wbg_isSafeInteger_f93fde0dca9820f8 = function(arg0) {
287
+ imports.wbg.__wbg_isSafeInteger_f7b04ef02296c4d2 = function(arg0) {
271
288
  const ret = Number.isSafeInteger(getObject(arg0));
272
289
  return ret;
273
290
  };
@@ -275,7 +292,23 @@ function __wbg_get_imports() {
275
292
  const ret = +getObject(arg0);
276
293
  return ret;
277
294
  };
278
- imports.wbg.__wbg_length_1d25fa9e4ac21ce7 = function(arg0) {
295
+ imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
296
+ const obj = getObject(arg1);
297
+ const ret = typeof obj === "string" ? obj : void 0;
298
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
299
+ var len1 = WASM_VECTOR_LEN;
300
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
301
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
302
+ };
303
+ imports.wbg.__wbindgen_boolean_get = function(arg0) {
304
+ const v = getObject(arg0);
305
+ const ret = typeof v === "boolean" ? v ? 1 : 0 : 2;
306
+ return ret;
307
+ };
308
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
309
+ takeObject(arg0);
310
+ };
311
+ imports.wbg.__wbg_length_c20a40f15020d68a = function(arg0) {
279
312
  const ret = getObject(arg0).length;
280
313
  return ret;
281
314
  };
@@ -283,20 +316,17 @@ function __wbg_get_imports() {
283
316
  const ret = wasm.memory;
284
317
  return addHeapObject(ret);
285
318
  };
286
- imports.wbg.__wbg_buffer_a448f833075b71ba = function(arg0) {
319
+ imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) {
287
320
  const ret = getObject(arg0).buffer;
288
321
  return addHeapObject(ret);
289
322
  };
290
- imports.wbg.__wbg_new_8f67e318f15d7254 = function(arg0) {
323
+ imports.wbg.__wbg_new_63b92bc8671ed464 = function(arg0) {
291
324
  const ret = new Uint8Array(getObject(arg0));
292
325
  return addHeapObject(ret);
293
326
  };
294
- imports.wbg.__wbg_set_2357bf09366ee480 = function(arg0, arg1, arg2) {
327
+ imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) {
295
328
  getObject(arg0).set(getObject(arg1), arg2 >>> 0);
296
329
  };
297
- imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
298
- takeObject(arg0);
299
- };
300
330
  imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
301
331
  const ret = new Error(getStringFromWasm0(arg0, arg1));
302
332
  return addHeapObject(ret);
@@ -311,7 +341,7 @@ function __wbg_get_imports() {
311
341
  getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
312
342
  getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
313
343
  };
314
- imports.wbg.__wbg_instanceof_Uint8Array_bced6f43aed8c1aa = function(arg0) {
344
+ imports.wbg.__wbg_instanceof_Uint8Array_2b3bbecd033d19f6 = function(arg0) {
315
345
  let result;
316
346
  try {
317
347
  result = getObject(arg0) instanceof Uint8Array;
@@ -321,7 +351,7 @@ function __wbg_get_imports() {
321
351
  const ret = result;
322
352
  return ret;
323
353
  };
324
- imports.wbg.__wbg_instanceof_ArrayBuffer_e7d53d51371448e2 = function(arg0) {
354
+ imports.wbg.__wbg_instanceof_ArrayBuffer_836825be07d4c9d2 = function(arg0) {
325
355
  let result;
326
356
  try {
327
357
  result = getObject(arg0) instanceof ArrayBuffer;
@@ -383,11 +413,15 @@ var initWasm = async (module_or_path) => {
383
413
  function inline2(html, options) {
384
414
  return inline(html, options);
385
415
  }
416
+ function inlineFragment2(html, css, options) {
417
+ return inlineFragment(html, css, options);
418
+ }
386
419
  function version2() {
387
420
  return version();
388
421
  }
389
422
  export {
390
423
  initWasm,
391
424
  inline2 as inline,
425
+ inlineFragment2 as inlineFragment,
392
426
  version2 as version
393
427
  };
package/index_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@css-inline/css-inline-wasm",
3
- "version": "0.13.1",
3
+ "version": "0.14.0",
4
4
  "description": "High-performance library for inlining CSS into HTML 'style' attributes",
5
5
  "keywords": [
6
6
  "css",