@tbela99/rust-css-parser-wasm 0.0.0-stage → 2.3.1

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.
@@ -0,0 +1,124 @@
1
+ // Enums of the typescript API (data only). Generated by scripts/gen-enums.mjs.
2
+
3
+ export const MediaFeatureType = Object.freeze({
4
+ "BooleanType": "boolean",
5
+ "IntergerType": "integer",
6
+ "KeywordType": "keyword",
7
+ "LengthType": "length",
8
+ "NumberType": "number",
9
+ "RatioType": "ratio",
10
+ "ResolutionType": "resolution",
11
+ "StringType": "string",
12
+ });
13
+
14
+ export const ValidationSyntaxGroupEnum = Object.freeze({
15
+ "Declarations": "declarations",
16
+ "Functions": "functions",
17
+ "Syntaxes": "syntaxes",
18
+ "Types": "types",
19
+ "Selectors": "selectors",
20
+ "AtRules": "atRules",
21
+ "Units": "units",
22
+ "Languages": "languages",
23
+ "mediaFeatures": "mediaFeatures",
24
+ });
25
+
26
+ export const ValidationTokenEnum = Object.freeze({
27
+ "Root": 0,
28
+ "Keyword": 1,
29
+ "PropertyType": 2,
30
+ "DeclarationType": 3,
31
+ "AtRule": 4,
32
+ "FunctionDefinition": 5,
33
+ "OpenBracket": 6,
34
+ "CloseBracket": 7,
35
+ "OpenParenthesis": 8,
36
+ "CloseParenthesis": 9,
37
+ "Comma": 10,
38
+ "Pipe": 11,
39
+ "Column": 12,
40
+ "Star": 13,
41
+ "OpenCurlyBrace": 14,
42
+ "CloseCurlyBrace": 15,
43
+ "HashMark": 16,
44
+ "QuestionMark": 17,
45
+ "Function": 18,
46
+ "Number": 19,
47
+ "Whitespace": 20,
48
+ "Parenthesis": 21,
49
+ "Bracket": 22,
50
+ "Block": 23,
51
+ "Plus": 24,
52
+ "Separator": 25,
53
+ "Exclamation": 26,
54
+ "Ampersand": 27,
55
+ "PipeToken": 28,
56
+ "ColumnToken": 29,
57
+ "AmpersandToken": 30,
58
+ "Parens": 31,
59
+ "PseudoClassToken": 32,
60
+ "PseudoClassFunctionToken": 33,
61
+ "StringToken": 34,
62
+ "AtRuleDefinition": 35,
63
+ "DeclarationNameToken": 36,
64
+ "DeclarationDefinitionToken": 37,
65
+ "SemiColon": 38,
66
+ "Character": 39,
67
+ "InfinityToken": 40,
68
+ "LessThan": 41,
69
+ "GreaterThan": 42,
70
+ "EOF": 43,
71
+ "OptionalGroupToken": 44,
72
+ "Dimension": 45,
73
+ "DisallowWhitespace": 46,
74
+ "Colon": 47,
75
+ "0": "Root",
76
+ "1": "Keyword",
77
+ "2": "PropertyType",
78
+ "3": "DeclarationType",
79
+ "4": "AtRule",
80
+ "5": "FunctionDefinition",
81
+ "6": "OpenBracket",
82
+ "7": "CloseBracket",
83
+ "8": "OpenParenthesis",
84
+ "9": "CloseParenthesis",
85
+ "10": "Comma",
86
+ "11": "Pipe",
87
+ "12": "Column",
88
+ "13": "Star",
89
+ "14": "OpenCurlyBrace",
90
+ "15": "CloseCurlyBrace",
91
+ "16": "HashMark",
92
+ "17": "QuestionMark",
93
+ "18": "Function",
94
+ "19": "Number",
95
+ "20": "Whitespace",
96
+ "21": "Parenthesis",
97
+ "22": "Bracket",
98
+ "23": "Block",
99
+ "24": "Plus",
100
+ "25": "Separator",
101
+ "26": "Exclamation",
102
+ "27": "Ampersand",
103
+ "28": "PipeToken",
104
+ "29": "ColumnToken",
105
+ "30": "AmpersandToken",
106
+ "31": "Parens",
107
+ "32": "PseudoClassToken",
108
+ "33": "PseudoClassFunctionToken",
109
+ "34": "StringToken",
110
+ "35": "AtRuleDefinition",
111
+ "36": "DeclarationNameToken",
112
+ "37": "DeclarationDefinitionToken",
113
+ "38": "SemiColon",
114
+ "39": "Character",
115
+ "40": "InfinityToken",
116
+ "41": "LessThan",
117
+ "42": "GreaterThan",
118
+ "43": "EOF",
119
+ "44": "OptionalGroupToken",
120
+ "45": "Dimension",
121
+ "46": "DisallowWhitespace",
122
+ "47": "Colon",
123
+ });
124
+
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Version number
3
+ */
4
+ export const version = "2.3.1";
package/dist/web.js ADDED
@@ -0,0 +1,59 @@
1
+ // browser entry point (port of src/web.ts)
2
+ import { createApi } from "./api.js";
3
+ import { getRuntime } from "./core.js";
4
+ import { dirname, matchUrl, resolve } from "./fs/resolve.js";
5
+ import { ResponseType } from "./enums-extra.js";
6
+
7
+ export * from "./exports.js";
8
+ export { PropertyList } from "./parser/declaration/list.js";
9
+
10
+ export async function load(url, currentDirectory = ".", responseType = false) {
11
+ if (typeof responseType === "boolean") {
12
+ responseType = responseType ? ResponseType.ReadableStream : ResponseType.Text;
13
+ }
14
+
15
+ let t;
16
+
17
+ // outside of a browser (node, workers without location), the urls are resolved against the current directory
18
+ const origin = globalThis.location?.origin ?? "file://";
19
+
20
+ if (typeof url === "object") {
21
+ t = new URL(url.absolute, origin);
22
+ } else if (matchUrl.test(url)) {
23
+ t = new URL(url);
24
+ } else if (currentDirectory != null && matchUrl.test(currentDirectory)) {
25
+ t = new URL(url, currentDirectory);
26
+ } else {
27
+ t = new URL(resolve(url, currentDirectory).absolute, origin);
28
+ }
29
+
30
+ return fetch(t, t.origin !== origin ? { mode: "cors" } : {}).then(async (response) => {
31
+ if (!response.ok) {
32
+ throw new Error(`${response.status} ${response.statusText} ${response.url}`);
33
+ }
34
+
35
+ if (responseType === ResponseType.ArrayBuffer) {
36
+ return response.arrayBuffer();
37
+ }
38
+
39
+ if (responseType === ResponseType.JSON) {
40
+ return response.json();
41
+ }
42
+
43
+ return responseType === ResponseType.ReadableStream ? response.body : response.text();
44
+ });
45
+ }
46
+
47
+ function cwd() {
48
+ const location = globalThis.location;
49
+
50
+ // outside of a browser: the current directory of the process
51
+ if (location == null) {
52
+ return globalThis.process?.cwd?.() ?? "";
53
+ }
54
+
55
+ return location.pathname.endsWith("/") ? location.pathname : dirname(location.pathname);
56
+ }
57
+
58
+ // the web entry point always uses the WASM backend (in node too): its arenas are WASM arenas
59
+ export const { render, parse, parseSync, transform, transformSync } = createApi({ load, cwd, runtime: await getRuntime("wasm") });
package/package.json CHANGED
@@ -1,6 +1,65 @@
1
1
  {
2
2
  "name": "@tbela99/rust-css-parser-wasm",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "2.3.1",
4
+ "type": "module",
5
+ "sideEffects": false,
6
+ "license": "MIT",
7
+ "files": [
8
+ "dist",
9
+ "README.md",
10
+ "LICENSE.md"
11
+ ],
12
+ "description": "CSS parser, validator and minifier for node and the browsers: the rust port of @tbela99/css-parser as a WebAssembly module",
13
+ "main": "./dist/node.js",
14
+ "browser": "./dist/web.js",
15
+ "exports": {
16
+ ".": {
17
+ "node": "./dist/node.js",
18
+ "default": "./dist/web.js"
19
+ },
20
+ "./node": "./dist/node.js",
21
+ "./web": "./dist/web.js",
22
+ "./package.json": "./package.json"
23
+ },
24
+ "scripts": {
25
+ "build": "sh ../../build-bindings.sh wasm",
26
+ "test": "cd ../.. && npm run test:wasm && npm run test:web",
27
+ "prepublishOnly": "cd ../.. && npm run build:wasm && npm run test:wasm",
28
+ "prepare": "node ../../scripts/prepare-extension.mjs wasm"
29
+ },
30
+ "author": "Thierry Bela",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/tbela99/rust-css-parser.git"
34
+ },
35
+ "keywords": [
36
+ "parser",
37
+ "css",
38
+ "modules",
39
+ "css-modules",
40
+ "css-parser",
41
+ "node",
42
+ "ast",
43
+ "nesting",
44
+ "nested",
45
+ "compiler",
46
+ "browser",
47
+ "css-nesting",
48
+ "css-compiler",
49
+ "nested-css",
50
+ "walker",
51
+ "stream",
52
+ "streaming",
53
+ "streaming-parser",
54
+ "minifier",
55
+ "validator",
56
+ "rust",
57
+ "wasm",
58
+ "napi",
59
+ "webassembly",
60
+ "browser"
61
+ ],
62
+ "publishConfig": {
63
+ "access": "public"
64
+ }
65
+ }