ihiutch-grass 0.13.4
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/LICENSE +21 -0
- package/README.md +91 -0
- package/grass.d.ts +4 -0
- package/grass.js +248 -0
- package/grass_bg.wasm +0 -0
- package/package.json +26 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Connor Skees
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# grass
|
|
2
|
+
|
|
3
|
+
This crate aims to provide a high level interface for compiling [Sass](https://sass-lang.com/documentation/) into
|
|
4
|
+
plain CSS. It offers a very limited API, currently exposing only 2 functions.
|
|
5
|
+
|
|
6
|
+
In addition to a library, this crate also includes a binary that is intended to act as an invisible
|
|
7
|
+
replacement to the Sass commandline executable.
|
|
8
|
+
|
|
9
|
+
This crate aims to achieve complete feature parity with the `dart-sass` reference
|
|
10
|
+
implementation. A deviation from the `dart-sass` implementation can be considered
|
|
11
|
+
a bug except for in the case of error messages and error spans.
|
|
12
|
+
|
|
13
|
+
[Documentation](https://docs.rs/grass/)
|
|
14
|
+
[crates.io](https://crates.io/crates/grass)
|
|
15
|
+
|
|
16
|
+
## Status
|
|
17
|
+
|
|
18
|
+
`grass` has reached a stage where one can be quite confident in its output. For the average user there should not be perceptible differences from `dart-sass`.
|
|
19
|
+
|
|
20
|
+
Every commit of `grass` is tested against bootstrap v5.0.2, and every release is tested against the last 2,500 commits of bootstrap's `main` branch.
|
|
21
|
+
|
|
22
|
+
That said, there are a number of known missing features and bugs. The rough edges of `grass` largely include `@forward` and more complex uses of `@use`. We support basic usage of these rules, but more advanced features such as `@import`ing modules containing `@forward` with prefixes may not behave as expected.
|
|
23
|
+
|
|
24
|
+
All known missing features and bugs are tracked in [#19](https://github.com/connorskees/grass/issues/19).
|
|
25
|
+
|
|
26
|
+
`grass` is not a drop-in replacement for `libsass` and does not intend to be. If you are upgrading to `grass` from `libsass`, you may have to make modifications to your stylesheets, though these changes should not differ from those you would have to make if upgrading to `dart-sass`.
|
|
27
|
+
|
|
28
|
+
## Performance
|
|
29
|
+
|
|
30
|
+
`grass` is benchmarked against `dart-sass` and `sassc` (`libsass`) [here](https://github.com/connorskees/sass-perf). In general, `grass` appears to be ~2x faster than `dart-sass` and ~1.7x faster than `sassc`.
|
|
31
|
+
|
|
32
|
+
## Cargo Features
|
|
33
|
+
|
|
34
|
+
### commandline
|
|
35
|
+
|
|
36
|
+
(enabled by default): build a binary using clap
|
|
37
|
+
|
|
38
|
+
### random
|
|
39
|
+
|
|
40
|
+
(enabled by default): enable the builtin functions [`random([$limit])`](https://sass-lang.com/documentation/modules/math/#random) and [`unique-id()`](https://sass-lang.com/documentation/modules/string/#unique-id)
|
|
41
|
+
|
|
42
|
+
### macro
|
|
43
|
+
|
|
44
|
+
(disabled by default): enable the macro `grass::include!` for compiling Sass to
|
|
45
|
+
CSS at compile time
|
|
46
|
+
|
|
47
|
+
### nightly
|
|
48
|
+
|
|
49
|
+
(disabled by default): currently only used by `grass::include!` to enable
|
|
50
|
+
[proc_macro::tracked_path](https://github.com/rust-lang/rust/issues/99515)
|
|
51
|
+
|
|
52
|
+
## Testing
|
|
53
|
+
|
|
54
|
+
As much as possible this library attempts to follow the same [philosophy for testing as
|
|
55
|
+
`rust-analyzer`](https://internals.rust-lang.org/t/experience-report-contributing-to-rust-lang-rust/12012/17).
|
|
56
|
+
Namely, all one should have to do is run `cargo test` to run all its tests.
|
|
57
|
+
This library maintains a test suite distinct from the `sass-spec`, though it
|
|
58
|
+
does include some spec tests verbatim. This has the benefit of allowing tests
|
|
59
|
+
to be run without ruby as well as allowing the tests more granular than they
|
|
60
|
+
are in the official spec.
|
|
61
|
+
|
|
62
|
+
Having said that, to run the official test suite,
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# This script expects node >=v14.14.0. Check version with `node --version`
|
|
66
|
+
git clone https://github.com/connorskees/grass --recursive
|
|
67
|
+
cd grass && cargo b --release
|
|
68
|
+
cd sass-spec && npm install
|
|
69
|
+
npm run sass-spec -- --impl=dart-sass --command '../target/release/grass'
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The spec runner does not work on Windows.
|
|
73
|
+
|
|
74
|
+
Using a modified version of the spec runner that ignores warnings and error spans (but does include error messages), `grass` achieves the following results:
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
2023-07-09
|
|
78
|
+
PASSING: 6230
|
|
79
|
+
FAILING: 545
|
|
80
|
+
TOTAL: 6905
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The majority of the failing tests are purely aesthetic, relating to whitespace
|
|
84
|
+
around comments in expanded mode or error messages.
|
|
85
|
+
|
|
86
|
+
## Versioning
|
|
87
|
+
|
|
88
|
+
The minimum supported rust version (MSRV) of `grass` is `1.80.0`. An increase to the MSRV will correspond with a minor version bump. The current MSRV is not a hard minimum, but future bugfix
|
|
89
|
+
versions of `grass` are not guaranteed to work on versions prior to this.
|
|
90
|
+
|
|
91
|
+
`grass` currently targets `dart-sass` version `1.97.3`. An increase to this number will correspond to either a minor or bugfix version bump, depending on the changes.
|
package/grass.d.ts
ADDED
package/grass.js
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/* @ts-self-types="./grass.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {string} input
|
|
5
|
+
* @returns {string}
|
|
6
|
+
*/
|
|
7
|
+
function from_string(input) {
|
|
8
|
+
let deferred3_0;
|
|
9
|
+
let deferred3_1;
|
|
10
|
+
try {
|
|
11
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
12
|
+
const len0 = WASM_VECTOR_LEN;
|
|
13
|
+
const ret = wasm.from_string(ptr0, len0);
|
|
14
|
+
var ptr2 = ret[0];
|
|
15
|
+
var len2 = ret[1];
|
|
16
|
+
if (ret[3]) {
|
|
17
|
+
ptr2 = 0; len2 = 0;
|
|
18
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
19
|
+
}
|
|
20
|
+
deferred3_0 = ptr2;
|
|
21
|
+
deferred3_1 = len2;
|
|
22
|
+
return getStringFromWasm0(ptr2, len2);
|
|
23
|
+
} finally {
|
|
24
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.from_string = from_string;
|
|
28
|
+
|
|
29
|
+
function __wbg_get_imports() {
|
|
30
|
+
const import0 = {
|
|
31
|
+
__proto__: null,
|
|
32
|
+
__wbg___wbindgen_is_function_3c846841762788c1: function(arg0) {
|
|
33
|
+
const ret = typeof(arg0) === 'function';
|
|
34
|
+
return ret;
|
|
35
|
+
},
|
|
36
|
+
__wbg___wbindgen_is_object_781bc9f159099513: function(arg0) {
|
|
37
|
+
const val = arg0;
|
|
38
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
39
|
+
return ret;
|
|
40
|
+
},
|
|
41
|
+
__wbg___wbindgen_is_string_7ef6b97b02428fae: function(arg0) {
|
|
42
|
+
const ret = typeof(arg0) === 'string';
|
|
43
|
+
return ret;
|
|
44
|
+
},
|
|
45
|
+
__wbg___wbindgen_is_undefined_52709e72fb9f179c: function(arg0) {
|
|
46
|
+
const ret = arg0 === undefined;
|
|
47
|
+
return ret;
|
|
48
|
+
},
|
|
49
|
+
__wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
|
|
50
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
51
|
+
},
|
|
52
|
+
__wbg_call_2d781c1f4d5c0ef8: function() { return handleError(function (arg0, arg1, arg2) {
|
|
53
|
+
const ret = arg0.call(arg1, arg2);
|
|
54
|
+
return ret;
|
|
55
|
+
}, arguments); },
|
|
56
|
+
__wbg_crypto_38df2bab126b63dc: function(arg0) {
|
|
57
|
+
const ret = arg0.crypto;
|
|
58
|
+
return ret;
|
|
59
|
+
},
|
|
60
|
+
__wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
|
|
61
|
+
arg0.getRandomValues(arg1);
|
|
62
|
+
}, arguments); },
|
|
63
|
+
__wbg_length_ea16607d7b61445b: function(arg0) {
|
|
64
|
+
const ret = arg0.length;
|
|
65
|
+
return ret;
|
|
66
|
+
},
|
|
67
|
+
__wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
|
|
68
|
+
const ret = arg0.msCrypto;
|
|
69
|
+
return ret;
|
|
70
|
+
},
|
|
71
|
+
__wbg_new_with_length_825018a1616e9e55: function(arg0) {
|
|
72
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
73
|
+
return ret;
|
|
74
|
+
},
|
|
75
|
+
__wbg_node_84ea875411254db1: function(arg0) {
|
|
76
|
+
const ret = arg0.node;
|
|
77
|
+
return ret;
|
|
78
|
+
},
|
|
79
|
+
__wbg_process_44c7a14e11e9f69e: function(arg0) {
|
|
80
|
+
const ret = arg0.process;
|
|
81
|
+
return ret;
|
|
82
|
+
},
|
|
83
|
+
__wbg_prototypesetcall_d62e5099504357e6: function(arg0, arg1, arg2) {
|
|
84
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
85
|
+
},
|
|
86
|
+
__wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) {
|
|
87
|
+
arg0.randomFillSync(arg1);
|
|
88
|
+
}, arguments); },
|
|
89
|
+
__wbg_require_b4edbdcf3e2a1ef0: function() { return handleError(function () {
|
|
90
|
+
const ret = module.require;
|
|
91
|
+
return ret;
|
|
92
|
+
}, arguments); },
|
|
93
|
+
__wbg_static_accessor_GLOBAL_8adb955bd33fac2f: function() {
|
|
94
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
95
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
96
|
+
},
|
|
97
|
+
__wbg_static_accessor_GLOBAL_THIS_ad356e0db91c7913: function() {
|
|
98
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
99
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
100
|
+
},
|
|
101
|
+
__wbg_static_accessor_SELF_f207c857566db248: function() {
|
|
102
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
103
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
104
|
+
},
|
|
105
|
+
__wbg_static_accessor_WINDOW_bb9f1ba69d61b386: function() {
|
|
106
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
107
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
108
|
+
},
|
|
109
|
+
__wbg_subarray_a068d24e39478a8a: function(arg0, arg1, arg2) {
|
|
110
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
111
|
+
return ret;
|
|
112
|
+
},
|
|
113
|
+
__wbg_versions_276b2795b1c6a219: function(arg0) {
|
|
114
|
+
const ret = arg0.versions;
|
|
115
|
+
return ret;
|
|
116
|
+
},
|
|
117
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
118
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
119
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
120
|
+
return ret;
|
|
121
|
+
},
|
|
122
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
123
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
124
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
125
|
+
return ret;
|
|
126
|
+
},
|
|
127
|
+
__wbindgen_init_externref_table: function() {
|
|
128
|
+
const table = wasm.__wbindgen_externrefs;
|
|
129
|
+
const offset = table.grow(4);
|
|
130
|
+
table.set(0, undefined);
|
|
131
|
+
table.set(offset + 0, undefined);
|
|
132
|
+
table.set(offset + 1, null);
|
|
133
|
+
table.set(offset + 2, true);
|
|
134
|
+
table.set(offset + 3, false);
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
return {
|
|
138
|
+
__proto__: null,
|
|
139
|
+
"./grass_bg.js": import0,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function addToExternrefTable0(obj) {
|
|
144
|
+
const idx = wasm.__externref_table_alloc();
|
|
145
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
146
|
+
return idx;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
150
|
+
ptr = ptr >>> 0;
|
|
151
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function getStringFromWasm0(ptr, len) {
|
|
155
|
+
ptr = ptr >>> 0;
|
|
156
|
+
return decodeText(ptr, len);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
let cachedUint8ArrayMemory0 = null;
|
|
160
|
+
function getUint8ArrayMemory0() {
|
|
161
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
162
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
163
|
+
}
|
|
164
|
+
return cachedUint8ArrayMemory0;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function handleError(f, args) {
|
|
168
|
+
try {
|
|
169
|
+
return f.apply(this, args);
|
|
170
|
+
} catch (e) {
|
|
171
|
+
const idx = addToExternrefTable0(e);
|
|
172
|
+
wasm.__wbindgen_exn_store(idx);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function isLikeNone(x) {
|
|
177
|
+
return x === undefined || x === null;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
181
|
+
if (realloc === undefined) {
|
|
182
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
183
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
184
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
185
|
+
WASM_VECTOR_LEN = buf.length;
|
|
186
|
+
return ptr;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
let len = arg.length;
|
|
190
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
191
|
+
|
|
192
|
+
const mem = getUint8ArrayMemory0();
|
|
193
|
+
|
|
194
|
+
let offset = 0;
|
|
195
|
+
|
|
196
|
+
for (; offset < len; offset++) {
|
|
197
|
+
const code = arg.charCodeAt(offset);
|
|
198
|
+
if (code > 0x7F) break;
|
|
199
|
+
mem[ptr + offset] = code;
|
|
200
|
+
}
|
|
201
|
+
if (offset !== len) {
|
|
202
|
+
if (offset !== 0) {
|
|
203
|
+
arg = arg.slice(offset);
|
|
204
|
+
}
|
|
205
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
206
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
207
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
208
|
+
|
|
209
|
+
offset += ret.written;
|
|
210
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
WASM_VECTOR_LEN = offset;
|
|
214
|
+
return ptr;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function takeFromExternrefTable0(idx) {
|
|
218
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
219
|
+
wasm.__externref_table_dealloc(idx);
|
|
220
|
+
return value;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
224
|
+
cachedTextDecoder.decode();
|
|
225
|
+
function decodeText(ptr, len) {
|
|
226
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const cachedTextEncoder = new TextEncoder();
|
|
230
|
+
|
|
231
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
232
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
233
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
234
|
+
view.set(buf);
|
|
235
|
+
return {
|
|
236
|
+
read: arg.length,
|
|
237
|
+
written: buf.length
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
let WASM_VECTOR_LEN = 0;
|
|
243
|
+
|
|
244
|
+
const wasmPath = `${__dirname}/grass_bg.wasm`;
|
|
245
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
246
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
247
|
+
let wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
|
|
248
|
+
wasm.__wbindgen_start();
|
package/grass_bg.wasm
ADDED
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ihiutch-grass",
|
|
3
|
+
"collaborators": [
|
|
4
|
+
"Connor Skees <39542938+ConnorSkees@users.noreply.github.com>"
|
|
5
|
+
],
|
|
6
|
+
"description": "A Sass compiler written purely in Rust",
|
|
7
|
+
"version": "0.13.4",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/connorskees/grass"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"grass_bg.wasm",
|
|
15
|
+
"grass.js",
|
|
16
|
+
"grass.d.ts"
|
|
17
|
+
],
|
|
18
|
+
"main": "grass.js",
|
|
19
|
+
"types": "grass.d.ts",
|
|
20
|
+
"keywords": [
|
|
21
|
+
"scss",
|
|
22
|
+
"sass",
|
|
23
|
+
"css",
|
|
24
|
+
"web"
|
|
25
|
+
]
|
|
26
|
+
}
|