csskit 0.0.30-canary.e2f3d18636 → 0.0.30
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/README.md +50 -3
- package/addon.js +42 -0
- package/bundle/csskit_wasm_bg.wasm +0 -0
- package/bundle/csskit_wasm_node.js +535 -0
- package/bundle.d.ts +32 -0
- package/bundle.js +13 -0
- package/index.d.ts +70 -15
- package/index.js +9 -537
- package/nodes.d.ts +1408 -0
- package/nodes.js +1408 -0
- package/om.js +66 -0
- package/package.json +32 -11
- package/csskit_wasm_bg.wasm +0 -0
- package/csskit_wasm_bg.wasm.d.ts +0 -17
package/om.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import addon from './addon.js';
|
|
2
|
+
import * as nodes from './nodes.js';
|
|
3
|
+
|
|
4
|
+
// Rust returns instances of one native class. Each node carries a `kindId`, an index into the table
|
|
5
|
+
// the addon reports at load. `adopt` uses that index to set the concrete class.
|
|
6
|
+
let byId = null;
|
|
7
|
+
|
|
8
|
+
function kindTable() {
|
|
9
|
+
if (byId === null) {
|
|
10
|
+
const byTag = new Map(Object.values(nodes).map((NodeClass) => [NodeClass.tag, NodeClass]));
|
|
11
|
+
byId = addon.nodeKinds().map((tag) => {
|
|
12
|
+
const NodeClass = byTag.get(tag);
|
|
13
|
+
if (!NodeClass) {
|
|
14
|
+
throw new Error(`csskit: no node class for '${tag}'; run \`mise run generate-node-classes\``);
|
|
15
|
+
}
|
|
16
|
+
return NodeClass;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return byId;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function adopt(node) {
|
|
23
|
+
return Object.setPrototypeOf(node, kindTable()[node.kindId].prototype);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** The base class of every AST node class. */
|
|
27
|
+
export class Node extends addon.Node {
|
|
28
|
+
/**
|
|
29
|
+
* Parses `source` as this class, as Rust's `parse_entirely::<T>()` does. A kind whose grammar
|
|
30
|
+
* exists only in context refuses to parse.
|
|
31
|
+
*/
|
|
32
|
+
static parse(source) {
|
|
33
|
+
return Object.setPrototypeOf(addon.parse(source, this.tag), this.prototype);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The class name of this node, for example `'StyleRule'`. */
|
|
37
|
+
get kind() {
|
|
38
|
+
return this.constructor.name;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The kebab-case tag of this node, for example `'style-rule'`. */
|
|
42
|
+
get tag() {
|
|
43
|
+
return this.constructor.tag;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The first descendant that matches `selector`, or `null`. */
|
|
47
|
+
querySelector(selector) {
|
|
48
|
+
const found = super.querySelector(selector);
|
|
49
|
+
return found === null ? null : adopt(found);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** All descendants that match `selector`, for example `'style-rule *[name=color]'`. */
|
|
53
|
+
querySelectorAll(selector) {
|
|
54
|
+
const found = super.querySelectorAll(selector);
|
|
55
|
+
for (let i = 0; i < found.length; i++) adopt(found[i]);
|
|
56
|
+
return found;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Runs the Rust visitor over this subtree. Calls `enter` and `exit` for each node. */
|
|
60
|
+
accept(enter, exit) {
|
|
61
|
+
return super.accept(
|
|
62
|
+
enter && ((node) => enter(adopt(node))),
|
|
63
|
+
exit && ((node) => exit(adopt(node))),
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "csskit",
|
|
3
|
-
"version": "0.0.30
|
|
3
|
+
"version": "0.0.30",
|
|
4
4
|
"description": "Refreshing CSS",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"repository": "https://github.com/csskit/csskit",
|
|
@@ -10,27 +10,48 @@
|
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"author": "Keith Cirkel (https://keithcirkel.co.uk)",
|
|
12
12
|
"exports": {
|
|
13
|
-
".":
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./index.d.ts",
|
|
15
|
+
"default": "./index.js"
|
|
16
|
+
},
|
|
17
|
+
"./nodes": {
|
|
18
|
+
"types": "./nodes.d.ts",
|
|
19
|
+
"default": "./nodes.js"
|
|
20
|
+
},
|
|
21
|
+
"./bundle": {
|
|
22
|
+
"types": "./bundle.d.ts",
|
|
23
|
+
"default": "./bundle.js"
|
|
24
|
+
},
|
|
14
25
|
"./bundler": "./bundle/csskit_wasm.js",
|
|
15
26
|
"./wasm": "./bundle/csskit_wasm_bg.wasm",
|
|
16
27
|
"./bin/csskit": "./bin/csskit"
|
|
17
28
|
},
|
|
18
29
|
"main": "./index.js",
|
|
19
|
-
"
|
|
30
|
+
"types": "./index.d.ts",
|
|
31
|
+
"type": "module",
|
|
32
|
+
"scripts": {
|
|
33
|
+
"test": "npm run test:napi && npm run test:wasm",
|
|
34
|
+
"test:napi": "node --test tests/om.test.js",
|
|
35
|
+
"test:wasm": "node --test tests/bundle.test.js"
|
|
36
|
+
},
|
|
20
37
|
"files": [
|
|
21
38
|
"./bin",
|
|
39
|
+
"./addon.js",
|
|
40
|
+
"./om.js",
|
|
41
|
+
"./nodes.js",
|
|
42
|
+
"./nodes.d.ts",
|
|
22
43
|
"./index.js",
|
|
23
44
|
"./index.d.ts",
|
|
24
|
-
"./
|
|
25
|
-
"./
|
|
45
|
+
"./bundle.js",
|
|
46
|
+
"./bundle.d.ts",
|
|
26
47
|
"./bundle"
|
|
27
48
|
],
|
|
28
49
|
"optionalDependencies": {
|
|
29
|
-
"csskit-darwin-arm64": "0.0.30
|
|
30
|
-
"csskit-darwin-x64": "0.0.30
|
|
31
|
-
"csskit-linux-arm64": "0.0.30
|
|
32
|
-
"csskit-linux-x64": "0.0.30
|
|
33
|
-
"csskit-win32-arm64": "0.0.30
|
|
34
|
-
"csskit-win32-x64": "0.0.30
|
|
50
|
+
"csskit-darwin-arm64": "0.0.30",
|
|
51
|
+
"csskit-darwin-x64": "0.0.30",
|
|
52
|
+
"csskit-linux-arm64": "0.0.30",
|
|
53
|
+
"csskit-linux-x64": "0.0.30",
|
|
54
|
+
"csskit-win32-arm64": "0.0.30",
|
|
55
|
+
"csskit-win32-x64": "0.0.30"
|
|
35
56
|
}
|
|
36
57
|
}
|
package/csskit_wasm_bg.wasm
DELETED
|
Binary file
|
package/csskit_wasm_bg.wasm.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
export const memory: WebAssembly.Memory;
|
|
4
|
-
export const __wbg_serializableparserresult_free: (a: number, b: number) => void;
|
|
5
|
-
export const format: (a: number, b: number, c: number, d: number) => void;
|
|
6
|
-
export const lex: (a: number, b: number, c: number) => void;
|
|
7
|
-
export const main: () => void;
|
|
8
|
-
export const minify: (a: number, b: number, c: number) => void;
|
|
9
|
-
export const parse: (a: number, b: number, c: number) => void;
|
|
10
|
-
export const parse_error_report: (a: number, b: number, c: number) => void;
|
|
11
|
-
export const serializableparserresult_ast: (a: number) => number;
|
|
12
|
-
export const serializableparserresult_diagnostics: (a: number, b: number) => void;
|
|
13
|
-
export const __wbindgen_export: (a: number, b: number) => number;
|
|
14
|
-
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
15
|
-
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
16
|
-
export const __wbindgen_export3: (a: number, b: number, c: number) => void;
|
|
17
|
-
export const __wbindgen_start: () => void;
|