@prospective.co/procss 0.1.15 → 0.1.16

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prospective.co/procss",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "description": "A simple CSS parsing and transformation framework.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,16 +16,16 @@
16
16
  "main": "target/esm/procss.js",
17
17
  "jsdelivr": "target/esm/procss.js",
18
18
  "exports": {
19
- ".": "./target/esm/procss.js",
20
- "./target/esm/*": "./target/esm/*",
21
- "./target/cjs/*": "./target/cjs/*",
22
- "./src/*": "./src/*",
23
- "./package.json": "./package.json"
19
+ ".": "./target/esm/procss.js",
20
+ "./target/esm/*": "./target/esm/*",
21
+ "./target/cjs/*": "./target/cjs/*",
22
+ "./src/*": "./src/*",
23
+ "./package.json": "./package.json"
24
24
  },
25
25
  "files": [
26
- "target/esm/**/*",
27
- "target/cjs/**/*",
28
- "src/**/*"
26
+ "target/esm/**/*",
27
+ "target/cjs/**/*",
28
+ "src/**/*"
29
29
  ],
30
30
  "types": "target/esm/procss.d.ts"
31
31
  }
@@ -17,6 +17,7 @@ use nom::bytes::complete::{is_not, tag};
17
17
  use nom::sequence::delimited;
18
18
 
19
19
  use crate::ast::{Css, Rule};
20
+ #[cfg(not(target_arch = "wasm32"))]
20
21
  use crate::utils::fs;
21
22
  #[cfg(feature = "iotest")]
22
23
  use crate::utils::IoTestFs;
@@ -52,9 +53,12 @@ fn into_data_uri<'a>(path: &Path) -> Option<Cow<'a, str>> {
52
53
  let contents = read_file_sync(path)?;
53
54
  let encoded = base64::encode(contents);
54
55
  let fff = path.extension().unwrap_or_default().to_string_lossy();
56
+ let ggg = path.to_string_lossy();
55
57
  let fmt = match fff.as_ref() {
56
58
  "png" => "png",
57
- _ => "svg+xml",
59
+ "gif" => "gif",
60
+ "svg" => "svg+xml",
61
+ _ => ggg.as_ref(),
58
62
  };
59
63
 
60
64
  Some(format!("url(\"data:image/{};base64,{}\")", fmt, encoded).into())
@@ -16,9 +16,7 @@ pub fn remove_var(css: &mut Css) {
16
16
  let reduced = css
17
17
  .iter()
18
18
  .filter(|&ruleset| match ruleset {
19
- Ruleset::QualRule(QualRule(name, Some(val))) if val.strip_prefix(':').is_some() => {
20
- false
21
- }
19
+ Ruleset::QualRule(QualRule(_, Some(val))) if val.strip_prefix(':').is_some() => false,
22
20
  _ => true,
23
21
  })
24
22
  .cloned();
@@ -4,6 +4,26 @@ let wasm;
4
4
  const { readFileSync } = require(`fs`);
5
5
  const { TextDecoder, TextEncoder } = require(`util`);
6
6
 
7
+ const heap = new Array(128).fill(undefined);
8
+
9
+ heap.push(undefined, null, true, false);
10
+
11
+ function getObject(idx) { return heap[idx]; }
12
+
13
+ let heap_next = heap.length;
14
+
15
+ function dropObject(idx) {
16
+ if (idx < 132) return;
17
+ heap[idx] = heap_next;
18
+ heap_next = idx;
19
+ }
20
+
21
+ function takeObject(idx) {
22
+ const ret = getObject(idx);
23
+ dropObject(idx);
24
+ return ret;
25
+ }
26
+
7
27
  let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
8
28
 
9
29
  cachedTextDecoder.decode();
@@ -22,12 +42,6 @@ function getStringFromWasm0(ptr, len) {
22
42
  return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
23
43
  }
24
44
 
25
- const heap = new Array(128).fill(undefined);
26
-
27
- heap.push(undefined, null, true, false);
28
-
29
- let heap_next = heap.length;
30
-
31
45
  function addHeapObject(obj) {
32
46
  if (heap_next === heap.length) heap.push(heap.length + 1);
33
47
  const idx = heap_next;
@@ -37,20 +51,6 @@ function addHeapObject(obj) {
37
51
  return idx;
38
52
  }
39
53
 
40
- function getObject(idx) { return heap[idx]; }
41
-
42
- function dropObject(idx) {
43
- if (idx < 132) return;
44
- heap[idx] = heap_next;
45
- heap_next = idx;
46
- }
47
-
48
- function takeObject(idx) {
49
- const ret = getObject(idx);
50
- dropObject(idx);
51
- return ret;
52
- }
53
-
54
54
  let WASM_VECTOR_LEN = 0;
55
55
 
56
56
  let cachedTextEncoder = new TextEncoder('utf-8');
@@ -188,18 +188,6 @@ class BuildCss {
188
188
  }
189
189
  module.exports.BuildCss = BuildCss;
190
190
 
191
- module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
192
- let deferred0_0;
193
- let deferred0_1;
194
- try {
195
- deferred0_0 = arg0;
196
- deferred0_1 = arg1;
197
- console.error(getStringFromWasm0(arg0, arg1));
198
- } finally {
199
- wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
200
- }
201
- };
202
-
203
191
  module.exports.__wbg_new_abda76e883ba8a5f = function() {
204
192
  const ret = new Error();
205
193
  return addHeapObject(ret);
@@ -213,22 +201,33 @@ module.exports.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
213
201
  getInt32Memory0()[arg0 / 4 + 0] = ptr1;
214
202
  };
215
203
 
216
- module.exports.__wbindgen_string_new = function(arg0, arg1) {
217
- const ret = getStringFromWasm0(arg0, arg1);
218
- return addHeapObject(ret);
204
+ module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
205
+ let deferred0_0;
206
+ let deferred0_1;
207
+ try {
208
+ deferred0_0 = arg0;
209
+ deferred0_1 = arg1;
210
+ console.error(getStringFromWasm0(arg0, arg1));
211
+ } finally {
212
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
213
+ }
219
214
  };
220
215
 
221
216
  module.exports.__wbindgen_object_drop_ref = function(arg0) {
222
217
  takeObject(arg0);
223
218
  };
224
219
 
225
- module.exports.__wbindgen_throw = function(arg0, arg1) {
226
- throw new Error(getStringFromWasm0(arg0, arg1));
227
- };
220
+ module.exports.__wbg_readFileSync_74d9a0fda9d26176 = function() { return handleError(function (arg0, arg1, arg2) {
221
+ const ret = readFileSync(getStringFromWasm0(arg1, arg2));
222
+ const ptr1 = passArray8ToWasm0(ret, wasm.__wbindgen_malloc);
223
+ const len1 = WASM_VECTOR_LEN;
224
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
225
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
226
+ }, arguments) };
228
227
 
229
- module.exports.__wbindgen_is_string = function(arg0) {
230
- const ret = typeof(getObject(arg0)) === 'string';
231
- return ret;
228
+ module.exports.__wbindgen_error_new = function(arg0, arg1) {
229
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
230
+ return addHeapObject(ret);
232
231
  };
233
232
 
234
233
  module.exports.__wbg_new_1b94180eeb48f2a2 = function() {
@@ -236,41 +235,20 @@ module.exports.__wbg_new_1b94180eeb48f2a2 = function() {
236
235
  return addHeapObject(ret);
237
236
  };
238
237
 
239
- module.exports.__wbg_set_3355b9f2d3092e3b = function(arg0, arg1, arg2) {
240
- const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
241
- return addHeapObject(ret);
242
- };
243
-
244
- module.exports.__wbg_new_c728d68b8b34487e = function() {
245
- const ret = new Object();
238
+ module.exports.__wbindgen_string_new = function(arg0, arg1) {
239
+ const ret = getStringFromWasm0(arg0, arg1);
246
240
  return addHeapObject(ret);
247
241
  };
248
242
 
249
- module.exports.__wbindgen_error_new = function(arg0, arg1) {
250
- const ret = new Error(getStringFromWasm0(arg0, arg1));
243
+ module.exports.__wbg_set_3355b9f2d3092e3b = function(arg0, arg1, arg2) {
244
+ const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
251
245
  return addHeapObject(ret);
252
246
  };
253
247
 
254
- module.exports.__wbg_String_91fba7ded13ba54c = function(arg0, arg1) {
255
- const ret = String(getObject(arg1));
256
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
257
- const len1 = WASM_VECTOR_LEN;
258
- getInt32Memory0()[arg0 / 4 + 1] = len1;
259
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
260
- };
261
-
262
- module.exports.__wbg_set_20cbc34131e76824 = function(arg0, arg1, arg2) {
263
- getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
248
+ module.exports.__wbindgen_throw = function(arg0, arg1) {
249
+ throw new Error(getStringFromWasm0(arg0, arg1));
264
250
  };
265
251
 
266
- module.exports.__wbg_readFileSync_8fc702e6693b9168 = function() { return handleError(function (arg0, arg1, arg2) {
267
- const ret = readFileSync(getStringFromWasm0(arg1, arg2));
268
- const ptr1 = passArray8ToWasm0(ret, wasm.__wbindgen_malloc);
269
- const len1 = WASM_VECTOR_LEN;
270
- getInt32Memory0()[arg0 / 4 + 1] = len1;
271
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
272
- }, arguments) };
273
-
274
252
  const path = require('path').join(__dirname, 'procss_bg.wasm');
275
253
  const bytes = require('fs').readFileSync(path);
276
254
 
Binary file
@@ -2,6 +2,26 @@ import { readFileSync } from 'fs';
2
2
 
3
3
  let wasm;
4
4
 
5
+ const heap = new Array(128).fill(undefined);
6
+
7
+ heap.push(undefined, null, true, false);
8
+
9
+ function getObject(idx) { return heap[idx]; }
10
+
11
+ let heap_next = heap.length;
12
+
13
+ function dropObject(idx) {
14
+ if (idx < 132) return;
15
+ heap[idx] = heap_next;
16
+ heap_next = idx;
17
+ }
18
+
19
+ function takeObject(idx) {
20
+ const ret = getObject(idx);
21
+ dropObject(idx);
22
+ return ret;
23
+ }
24
+
5
25
  const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
6
26
 
7
27
  if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
@@ -20,12 +40,6 @@ function getStringFromWasm0(ptr, len) {
20
40
  return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
21
41
  }
22
42
 
23
- const heap = new Array(128).fill(undefined);
24
-
25
- heap.push(undefined, null, true, false);
26
-
27
- let heap_next = heap.length;
28
-
29
43
  function addHeapObject(obj) {
30
44
  if (heap_next === heap.length) heap.push(heap.length + 1);
31
45
  const idx = heap_next;
@@ -35,20 +49,6 @@ function addHeapObject(obj) {
35
49
  return idx;
36
50
  }
37
51
 
38
- function getObject(idx) { return heap[idx]; }
39
-
40
- function dropObject(idx) {
41
- if (idx < 132) return;
42
- heap[idx] = heap_next;
43
- heap_next = idx;
44
- }
45
-
46
- function takeObject(idx) {
47
- const ret = getObject(idx);
48
- dropObject(idx);
49
- return ret;
50
- }
51
-
52
52
  let WASM_VECTOR_LEN = 0;
53
53
 
54
54
  const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
@@ -219,6 +219,17 @@ async function __wbg_load(module, imports) {
219
219
  function __wbg_get_imports() {
220
220
  const imports = {};
221
221
  imports.wbg = {};
222
+ imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
223
+ const ret = new Error();
224
+ return addHeapObject(ret);
225
+ };
226
+ imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
227
+ const ret = getObject(arg1).stack;
228
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
229
+ const len1 = WASM_VECTOR_LEN;
230
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
231
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
232
+ };
222
233
  imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
223
234
  let deferred0_0;
224
235
  let deferred0_1;
@@ -230,64 +241,35 @@ function __wbg_get_imports() {
230
241
  wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
231
242
  }
232
243
  };
233
- imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
234
- const ret = new Error();
235
- return addHeapObject(ret);
244
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
245
+ takeObject(arg0);
236
246
  };
237
- imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
238
- const ret = getObject(arg1).stack;
239
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
247
+ imports.wbg.__wbg_readFileSync_74d9a0fda9d26176 = function() { return handleError(function (arg0, arg1, arg2) {
248
+ const ret = readFileSync(getStringFromWasm0(arg1, arg2));
249
+ const ptr1 = passArray8ToWasm0(ret, wasm.__wbindgen_malloc);
240
250
  const len1 = WASM_VECTOR_LEN;
241
251
  getInt32Memory0()[arg0 / 4 + 1] = len1;
242
252
  getInt32Memory0()[arg0 / 4 + 0] = ptr1;
243
- };
244
- imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
245
- const ret = getStringFromWasm0(arg0, arg1);
253
+ }, arguments) };
254
+ imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
255
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
246
256
  return addHeapObject(ret);
247
257
  };
248
- imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
249
- takeObject(arg0);
250
- };
251
- imports.wbg.__wbindgen_throw = function(arg0, arg1) {
252
- throw new Error(getStringFromWasm0(arg0, arg1));
253
- };
254
- imports.wbg.__wbindgen_is_string = function(arg0) {
255
- const ret = typeof(getObject(arg0)) === 'string';
256
- return ret;
257
- };
258
258
  imports.wbg.__wbg_new_1b94180eeb48f2a2 = function() {
259
259
  const ret = new Map();
260
260
  return addHeapObject(ret);
261
261
  };
262
- imports.wbg.__wbg_set_3355b9f2d3092e3b = function(arg0, arg1, arg2) {
263
- const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
264
- return addHeapObject(ret);
265
- };
266
- imports.wbg.__wbg_new_c728d68b8b34487e = function() {
267
- const ret = new Object();
262
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
263
+ const ret = getStringFromWasm0(arg0, arg1);
268
264
  return addHeapObject(ret);
269
265
  };
270
- imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
271
- const ret = new Error(getStringFromWasm0(arg0, arg1));
266
+ imports.wbg.__wbg_set_3355b9f2d3092e3b = function(arg0, arg1, arg2) {
267
+ const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
272
268
  return addHeapObject(ret);
273
269
  };
274
- imports.wbg.__wbg_String_91fba7ded13ba54c = function(arg0, arg1) {
275
- const ret = String(getObject(arg1));
276
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
277
- const len1 = WASM_VECTOR_LEN;
278
- getInt32Memory0()[arg0 / 4 + 1] = len1;
279
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
280
- };
281
- imports.wbg.__wbg_set_20cbc34131e76824 = function(arg0, arg1, arg2) {
282
- getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
270
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
271
+ throw new Error(getStringFromWasm0(arg0, arg1));
283
272
  };
284
- imports.wbg.__wbg_readFileSync_8fc702e6693b9168 = function() { return handleError(function (arg0, arg1, arg2) {
285
- const ret = readFileSync(getStringFromWasm0(arg1, arg2));
286
- const ptr1 = passArray8ToWasm0(ret, wasm.__wbindgen_malloc);
287
- const len1 = WASM_VECTOR_LEN;
288
- getInt32Memory0()[arg0 / 4 + 1] = len1;
289
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
290
- }, arguments) };
291
273
 
292
274
  return imports;
293
275
  }
Binary file