@prospective.co/procss 0.1.8

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.
Files changed (41) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +45 -0
  3. package/package.json +31 -0
  4. package/src/ast/flat_ruleset.rs +52 -0
  5. package/src/ast/ruleset/mod.rs +229 -0
  6. package/src/ast/ruleset/rule.rs +114 -0
  7. package/src/ast/selector/attribute.rs +90 -0
  8. package/src/ast/selector/combinator.rs +58 -0
  9. package/src/ast/selector/mod.rs +115 -0
  10. package/src/ast/selector/selector_path.rs +230 -0
  11. package/src/ast/selector/selector_term.rs +325 -0
  12. package/src/ast/token/mod.rs +18 -0
  13. package/src/ast/token/space.rs +157 -0
  14. package/src/ast/token/string.rs +59 -0
  15. package/src/ast/token/symbol.rs +32 -0
  16. package/src/ast/tree_ruleset.rs +252 -0
  17. package/src/ast.rs +216 -0
  18. package/src/builder.rs +189 -0
  19. package/src/js_builder.rs +59 -0
  20. package/src/lib.rs +151 -0
  21. package/src/main.rs +40 -0
  22. package/src/parser.rs +36 -0
  23. package/src/render.rs +84 -0
  24. package/src/transform.rs +14 -0
  25. package/src/transformers/apply_import.rs +53 -0
  26. package/src/transformers/apply_mixin.rs +73 -0
  27. package/src/transformers/apply_var.rs +41 -0
  28. package/src/transformers/dedupe.rs +35 -0
  29. package/src/transformers/filter_refs.rs +27 -0
  30. package/src/transformers/flat_self.rs +30 -0
  31. package/src/transformers/inline_url.rs +52 -0
  32. package/src/transformers/mod.rs +43 -0
  33. package/src/utils.rs +90 -0
  34. package/target/cjs/procss.d.ts +22 -0
  35. package/target/cjs/procss.js +217 -0
  36. package/target/cjs/procss_bg.wasm +0 -0
  37. package/target/cjs/procss_bg.wasm.d.ts +12 -0
  38. package/target/esm/procss.d.ts +58 -0
  39. package/target/esm/procss.js +283 -0
  40. package/target/esm/procss_bg.wasm +0 -0
  41. package/target/esm/procss_bg.wasm.d.ts +12 -0
@@ -0,0 +1,283 @@
1
+
2
+ let wasm;
3
+
4
+ const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
5
+
6
+ cachedTextDecoder.decode();
7
+
8
+ let cachedUint8Memory0 = new Uint8Array();
9
+
10
+ function getUint8Memory0() {
11
+ if (cachedUint8Memory0.byteLength === 0) {
12
+ cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
13
+ }
14
+ return cachedUint8Memory0;
15
+ }
16
+
17
+ function getStringFromWasm0(ptr, len) {
18
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
19
+ }
20
+
21
+ const heap = new Array(32).fill(undefined);
22
+
23
+ heap.push(undefined, null, true, false);
24
+
25
+ let heap_next = heap.length;
26
+
27
+ function addHeapObject(obj) {
28
+ if (heap_next === heap.length) heap.push(heap.length + 1);
29
+ const idx = heap_next;
30
+ heap_next = heap[idx];
31
+
32
+ heap[idx] = obj;
33
+ return idx;
34
+ }
35
+
36
+ function getObject(idx) { return heap[idx]; }
37
+
38
+ function dropObject(idx) {
39
+ if (idx < 36) return;
40
+ heap[idx] = heap_next;
41
+ heap_next = idx;
42
+ }
43
+
44
+ function takeObject(idx) {
45
+ const ret = getObject(idx);
46
+ dropObject(idx);
47
+ return ret;
48
+ }
49
+
50
+ let WASM_VECTOR_LEN = 0;
51
+
52
+ const cachedTextEncoder = new TextEncoder('utf-8');
53
+
54
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
55
+ ? function (arg, view) {
56
+ return cachedTextEncoder.encodeInto(arg, view);
57
+ }
58
+ : function (arg, view) {
59
+ const buf = cachedTextEncoder.encode(arg);
60
+ view.set(buf);
61
+ return {
62
+ read: arg.length,
63
+ written: buf.length
64
+ };
65
+ });
66
+
67
+ function passStringToWasm0(arg, malloc, realloc) {
68
+
69
+ if (realloc === undefined) {
70
+ const buf = cachedTextEncoder.encode(arg);
71
+ const ptr = malloc(buf.length);
72
+ getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
73
+ WASM_VECTOR_LEN = buf.length;
74
+ return ptr;
75
+ }
76
+
77
+ let len = arg.length;
78
+ let ptr = malloc(len);
79
+
80
+ const mem = getUint8Memory0();
81
+
82
+ let offset = 0;
83
+
84
+ for (; offset < len; offset++) {
85
+ const code = arg.charCodeAt(offset);
86
+ if (code > 0x7F) break;
87
+ mem[ptr + offset] = code;
88
+ }
89
+
90
+ if (offset !== len) {
91
+ if (offset !== 0) {
92
+ arg = arg.slice(offset);
93
+ }
94
+ ptr = realloc(ptr, len, len = offset + arg.length * 3);
95
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
96
+ const ret = encodeString(arg, view);
97
+
98
+ offset += ret.written;
99
+ }
100
+
101
+ WASM_VECTOR_LEN = offset;
102
+ return ptr;
103
+ }
104
+
105
+ let cachedInt32Memory0 = new Int32Array();
106
+
107
+ function getInt32Memory0() {
108
+ if (cachedInt32Memory0.byteLength === 0) {
109
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
110
+ }
111
+ return cachedInt32Memory0;
112
+ }
113
+ /**
114
+ * An implementation of `BuildCss` which owns its data, suitable for use as an
115
+ * exported type in JavaScript.
116
+ */
117
+ export class BuildCss {
118
+
119
+ static __wrap(ptr) {
120
+ const obj = Object.create(BuildCss.prototype);
121
+ obj.ptr = ptr;
122
+
123
+ return obj;
124
+ }
125
+
126
+ __destroy_into_raw() {
127
+ const ptr = this.ptr;
128
+ this.ptr = 0;
129
+
130
+ return ptr;
131
+ }
132
+
133
+ free() {
134
+ const ptr = this.__destroy_into_raw();
135
+ wasm.__wbg_buildcss_free(ptr);
136
+ }
137
+ /**
138
+ * @param {string} rootdir
139
+ */
140
+ constructor(rootdir) {
141
+ const ptr0 = passStringToWasm0(rootdir, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
142
+ const len0 = WASM_VECTOR_LEN;
143
+ const ret = wasm.buildcss_new(ptr0, len0);
144
+ return BuildCss.__wrap(ret);
145
+ }
146
+ /**
147
+ * @param {string} path
148
+ * @param {string} content
149
+ */
150
+ add(path, content) {
151
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
152
+ const len0 = WASM_VECTOR_LEN;
153
+ const ptr1 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
154
+ const len1 = WASM_VECTOR_LEN;
155
+ wasm.buildcss_add(this.ptr, ptr0, len0, ptr1, len1);
156
+ }
157
+ /**
158
+ * @returns {any}
159
+ */
160
+ compile() {
161
+ try {
162
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
163
+ wasm.buildcss_compile(retptr, this.ptr);
164
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
165
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
166
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
167
+ if (r2) {
168
+ throw takeObject(r1);
169
+ }
170
+ return takeObject(r0);
171
+ } finally {
172
+ wasm.__wbindgen_add_to_stack_pointer(16);
173
+ }
174
+ }
175
+ }
176
+
177
+ async function load(module, imports) {
178
+ if (typeof Response === 'function' && module instanceof Response) {
179
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
180
+ try {
181
+ return await WebAssembly.instantiateStreaming(module, imports);
182
+
183
+ } catch (e) {
184
+ if (module.headers.get('Content-Type') != 'application/wasm') {
185
+ 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);
186
+
187
+ } else {
188
+ throw e;
189
+ }
190
+ }
191
+ }
192
+
193
+ const bytes = await module.arrayBuffer();
194
+ return await WebAssembly.instantiate(bytes, imports);
195
+
196
+ } else {
197
+ const instance = await WebAssembly.instantiate(module, imports);
198
+
199
+ if (instance instanceof WebAssembly.Instance) {
200
+ return { instance, module };
201
+
202
+ } else {
203
+ return instance;
204
+ }
205
+ }
206
+ }
207
+
208
+ function getImports() {
209
+ const imports = {};
210
+ imports.wbg = {};
211
+ imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
212
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
213
+ return addHeapObject(ret);
214
+ };
215
+ imports.wbg.__wbg_new_268f7b7dd3430798 = function() {
216
+ const ret = new Map();
217
+ return addHeapObject(ret);
218
+ };
219
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
220
+ const ret = getStringFromWasm0(arg0, arg1);
221
+ return addHeapObject(ret);
222
+ };
223
+ imports.wbg.__wbg_set_933729cf5b66ac11 = function(arg0, arg1, arg2) {
224
+ const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
225
+ return addHeapObject(ret);
226
+ };
227
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
228
+ takeObject(arg0);
229
+ };
230
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
231
+ throw new Error(getStringFromWasm0(arg0, arg1));
232
+ };
233
+
234
+ return imports;
235
+ }
236
+
237
+ function initMemory(imports, maybe_memory) {
238
+
239
+ }
240
+
241
+ function finalizeInit(instance, module) {
242
+ wasm = instance.exports;
243
+ init.__wbindgen_wasm_module = module;
244
+ cachedInt32Memory0 = new Int32Array();
245
+ cachedUint8Memory0 = new Uint8Array();
246
+
247
+ wasm.__wbindgen_start();
248
+ return wasm;
249
+ }
250
+
251
+ function initSync(module) {
252
+ const imports = getImports();
253
+
254
+ initMemory(imports);
255
+
256
+ if (!(module instanceof WebAssembly.Module)) {
257
+ module = new WebAssembly.Module(module);
258
+ }
259
+
260
+ const instance = new WebAssembly.Instance(module, imports);
261
+
262
+ return finalizeInit(instance, module);
263
+ }
264
+
265
+ async function init(input) {
266
+ if (typeof input === 'undefined') {
267
+ input = new URL('procss_bg.wasm', import.meta.url);
268
+ }
269
+ const imports = getImports();
270
+
271
+ if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
272
+ input = fetch(input);
273
+ }
274
+
275
+ initMemory(imports);
276
+
277
+ const { instance, module } = await load(await input, imports);
278
+
279
+ return finalizeInit(instance, module);
280
+ }
281
+
282
+ export { initSync }
283
+ export default init;
Binary file
@@ -0,0 +1,12 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export function main(a: number, b: number): number;
5
+ export function __wbg_buildcss_free(a: number): void;
6
+ export function buildcss_new(a: number, b: number): number;
7
+ export function buildcss_add(a: number, b: number, c: number, d: number, e: number): void;
8
+ export function buildcss_compile(a: number, b: number): void;
9
+ export function __wbindgen_malloc(a: number): number;
10
+ export function __wbindgen_realloc(a: number, b: number, c: number): number;
11
+ export function __wbindgen_add_to_stack_pointer(a: number): number;
12
+ export function __wbindgen_start(): void;