@teacss/engine 0.8.5-alpha.4 → 0.9.0-alpha.3
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/binding-header.d.ts +20 -0
- package/binding.d.ts +19 -1
- package/binding.js +54 -54
- package/contract.d.ts +246 -0
- package/dist/facade/config-view.d.ts +27 -0
- package/dist/facade/config-view.js +96 -0
- package/dist/facade/constants.d.ts +22 -0
- package/{src/facade/constants.mjs → dist/facade/constants.js} +10 -11
- package/dist/facade/countable-set.d.ts +43 -0
- package/dist/facade/countable-set.js +149 -0
- package/dist/facade/errors.d.ts +11 -0
- package/dist/facade/errors.js +18 -0
- package/dist/facade/generator.d.ts +153 -0
- package/dist/facade/generator.js +777 -0
- package/dist/facade/index.d.ts +6 -0
- package/dist/facade/index.js +9 -0
- package/dist/facade/result.d.ts +68 -0
- package/dist/facade/result.js +134 -0
- package/dist/facade/select.d.ts +175 -0
- package/dist/facade/select.js +680 -0
- package/dist/facade/transformer.d.ts +44 -0
- package/dist/facade/transformer.js +59 -0
- package/dist/facade/ts-fallback.d.ts +32 -0
- package/dist/facade/ts-fallback.js +78 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/index.d.ts +1 -387
- package/index.js +1 -1
- package/package.json +42 -23
- package/src/facade/config-view.mjs +0 -82
- package/src/facade/countable-set.mjs +0 -179
- package/src/facade/errors.mjs +0 -22
- package/src/facade/generator.mjs +0 -812
- package/src/facade/index.mjs +0 -19
- package/src/facade/result.mjs +0 -157
- package/src/facade/select.mjs +0 -635
- package/src/facade/transformer.mjs +0 -56
- package/src/facade/ts-fallback.mjs +0 -88
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teacss/engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0-alpha.3",
|
|
4
4
|
"description": "In-process Rust engine for TeaCSS 0.9 (napi-rs binding and 0.8.x-compatible facade)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -22,22 +22,27 @@
|
|
|
22
22
|
"default": "./binding.js"
|
|
23
23
|
},
|
|
24
24
|
"./facade": {
|
|
25
|
-
"types": "./index.d.ts",
|
|
26
|
-
"default": "./
|
|
25
|
+
"types": "./dist/facade/index.d.ts",
|
|
26
|
+
"default": "./dist/facade/index.js"
|
|
27
27
|
},
|
|
28
28
|
"./select": {
|
|
29
|
-
"types": "./
|
|
30
|
-
"default": "./
|
|
29
|
+
"types": "./dist/facade/select.d.ts",
|
|
30
|
+
"default": "./dist/facade/select.js"
|
|
31
31
|
},
|
|
32
32
|
"./package.json": "./package.json"
|
|
33
33
|
},
|
|
34
|
+
"imports": {
|
|
35
|
+
"#facade/*": "./dist/facade/*"
|
|
36
|
+
},
|
|
34
37
|
"files": [
|
|
35
38
|
"index.js",
|
|
36
39
|
"index.d.ts",
|
|
40
|
+
"contract.d.ts",
|
|
37
41
|
"binding.js",
|
|
38
42
|
"binding.d.ts",
|
|
39
|
-
"
|
|
40
|
-
"
|
|
43
|
+
"binding-header.d.ts",
|
|
44
|
+
"dist/**/*.js",
|
|
45
|
+
"dist/**/*.d.ts",
|
|
41
46
|
"README.md"
|
|
42
47
|
],
|
|
43
48
|
"sideEffects": false,
|
|
@@ -47,6 +52,7 @@
|
|
|
47
52
|
"napi": {
|
|
48
53
|
"binaryName": "teacss-engine",
|
|
49
54
|
"packageName": "@teacss/engine",
|
|
55
|
+
"dtsHeaderFile": "binding-header.d.ts",
|
|
50
56
|
"targets": [
|
|
51
57
|
"aarch64-apple-darwin",
|
|
52
58
|
"x86_64-apple-darwin",
|
|
@@ -68,18 +74,18 @@
|
|
|
68
74
|
}
|
|
69
75
|
},
|
|
70
76
|
"optionalDependencies": {
|
|
71
|
-
"@teacss/engine-darwin-arm64": "0.
|
|
72
|
-
"@teacss/engine-darwin-x64": "0.
|
|
73
|
-
"@teacss/engine-linux-
|
|
74
|
-
"@teacss/engine-linux-
|
|
75
|
-
"@teacss/engine-linux-
|
|
76
|
-
"@teacss/engine-linux-
|
|
77
|
-
"@teacss/engine-win32-
|
|
78
|
-
"@teacss/engine-win32-
|
|
77
|
+
"@teacss/engine-darwin-arm64": "0.9.0-alpha.3",
|
|
78
|
+
"@teacss/engine-darwin-x64": "0.9.0-alpha.3",
|
|
79
|
+
"@teacss/engine-linux-arm64-gnu": "0.9.0-alpha.3",
|
|
80
|
+
"@teacss/engine-linux-arm64-musl": "0.9.0-alpha.3",
|
|
81
|
+
"@teacss/engine-linux-x64-gnu": "0.9.0-alpha.3",
|
|
82
|
+
"@teacss/engine-linux-x64-musl": "0.9.0-alpha.3",
|
|
83
|
+
"@teacss/engine-win32-arm64-msvc": "0.9.0-alpha.3",
|
|
84
|
+
"@teacss/engine-win32-x64-msvc": "0.9.0-alpha.3"
|
|
79
85
|
},
|
|
80
86
|
"peerDependencies": {
|
|
81
|
-
"@teacss/
|
|
82
|
-
"@teacss/
|
|
87
|
+
"@teacss/config": ">=0.8.5 <0.10.0 || >=0.9.0-alpha.0 <0.10.0",
|
|
88
|
+
"@teacss/core": ">=0.8.5 <0.10.0 || >=0.9.0-alpha.0 <0.10.0"
|
|
83
89
|
},
|
|
84
90
|
"peerDependenciesMeta": {
|
|
85
91
|
"@teacss/core": {
|
|
@@ -91,6 +97,7 @@
|
|
|
91
97
|
},
|
|
92
98
|
"devDependencies": {
|
|
93
99
|
"@napi-rs/cli": "3.10.8",
|
|
100
|
+
"@types/node": "^22.20.5",
|
|
94
101
|
"emnapi": "1.11.3",
|
|
95
102
|
"magic-string": "^0.30.17",
|
|
96
103
|
"typescript": "^5.9.3"
|
|
@@ -101,12 +108,24 @@
|
|
|
101
108
|
"build:debug": "napi build --platform --esm --js binding.js --dts binding.d.ts --output-dir . --manifest-path ../../crates/teacss-napi/Cargo.toml -- --locked",
|
|
102
109
|
"artifacts": "napi artifacts --output-dir ../../artifacts --npm-dir npm",
|
|
103
110
|
"create-npm-dirs": "napi create-npm-dirs",
|
|
104
|
-
"prepublishOnly": "node scripts/check-publish.
|
|
105
|
-
"test": "npm run check:
|
|
106
|
-
"check:
|
|
107
|
-
"check:
|
|
108
|
-
"
|
|
109
|
-
"
|
|
111
|
+
"prepublishOnly": "npm run build:ts && node build/scripts/check-publish.js",
|
|
112
|
+
"test": "npm run build:ts && npm run check:types && node --expose-gc --test \"build/test/**/*.test.js\"",
|
|
113
|
+
"check:version": "npm run build:ts && node build/scripts/sync-version.js --check",
|
|
114
|
+
"check:size": "node build/scripts/size-budget.js",
|
|
115
|
+
"version": "napi version && npm run build:ts && node build/scripts/sync-version.js --write && git add npm/*/package.json ../../Cargo.toml ../../Cargo.lock",
|
|
116
|
+
"build:ts": "tsc -p tsconfig.json && tsc -p tsconfig.test.json",
|
|
117
|
+
"check:types": "tsc -p test/consumer/tsconfig.json --noEmit",
|
|
118
|
+
"check:publish": "node build/scripts/check-publish.js",
|
|
119
|
+
"check:tag": "node build/scripts/check-tag.js",
|
|
120
|
+
"inspect-binding": "node build/scripts/inspect-binding.js",
|
|
121
|
+
"collect-artifacts": "node build/scripts/collect-artifacts.js",
|
|
122
|
+
"release:bundle": "node build/scripts/release-bundle.js",
|
|
123
|
+
"release:notes": "node build/scripts/release-notes.js",
|
|
124
|
+
"release:evidence": "node build/scripts/release-evidence.js",
|
|
125
|
+
"publish:npm": "node build/scripts/publish.js",
|
|
126
|
+
"dist-tag": "node build/scripts/dist-tag.js",
|
|
127
|
+
"qualify": "node build/scripts/qualify.js",
|
|
128
|
+
"setup-wasi-sdk": "node build/scripts/setup-wasi-sdk.js"
|
|
110
129
|
},
|
|
111
130
|
"publishConfig": {
|
|
112
131
|
"access": "public",
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
// The facade's `generator.config`: a plain object whose keys follow the oracle `resolveConfig`
|
|
3
|
-
// (core/config.ts:260-288), which spreads the merged config and then sets its own fields.
|
|
4
|
-
|
|
5
|
-
import { tsNotReadyError } from "./errors.mjs";
|
|
6
|
-
|
|
7
|
-
/** Fields the TypeScript generator provides; reading one before materialize throws `E_TS_REQUIRED`. */
|
|
8
|
-
export const TS_ONLY_FIELDS = Object.freeze(["configResolved", "extendTheme", "preprocess", "postprocess", "preflights", "autocomplete", "rules", "rulesDynamic", "rulesStaticMap", "variants"]);
|
|
9
|
-
/** Fields copied from the Rust `ResolvedConfigView`. */
|
|
10
|
-
export const VIEW_FIELDS = Object.freeze(["layers", "theme", "shortcuts", "safelist", "blocklist", "separators", "envMode", "unmatched", "shortcutsLayer", "virtualModulePrefix", "mergeSelectors", "warn", "details", "outputToCssLayers", "rulesSize"]);
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* The keys `resolveConfig` always sets, in its order (config.ts:262-288); `configResolved`,
|
|
14
|
-
* `extendTheme`, `extractorDefault` and `virtualModulePrefix` appear only through the spread.
|
|
15
|
-
*/
|
|
16
|
-
const RESOLVED_KEYS = Object.freeze([
|
|
17
|
-
"mergeSelectors", "warn", "unmatched", "outputToCssLayers", "sortLayers", "blocklist", "presets", "envMode", "shortcutsLayer", "layers", "theme", "rules", "rulesSize",
|
|
18
|
-
"rulesDynamic", "rulesStaticMap", "preprocess", "postprocess", "preflights", "autocomplete", "variants", "shortcuts", "extractors", "safelist", "separators", "details",
|
|
19
|
-
"content", "transformers",
|
|
20
|
-
]);
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @param {{ view: Record<string, any>, request: object, presets: object[], userConfig: Record<string, unknown>, transformers: object[], host: { core?: { extractorSplit: object } | undefined }, fallback: { peek(): { config: Record<string, unknown> } | null }, engine?: { compileClassShortcuts(): unknown[] } }} args
|
|
24
|
-
* `userConfig` is the merged config (`mergeDefinedConfig(defaults, userConfig)`) the oracle spreads.
|
|
25
|
-
* @returns {Record<string, unknown>}
|
|
26
|
-
*/
|
|
27
|
-
export function createConfigView({ view, presets, userConfig, transformers, host, fallback, engine }) {
|
|
28
|
-
/** @type {Record<string, unknown>} */
|
|
29
|
-
const config = {};
|
|
30
|
-
/** @param {string} key @param {unknown} value */
|
|
31
|
-
const data = (key, value) => Object.defineProperty(config, key, { value, enumerable: true, configurable: true, writable: true });
|
|
32
|
-
/** @param {string} key */
|
|
33
|
-
const tsOnly = (key) =>
|
|
34
|
-
Object.defineProperty(config, key, {
|
|
35
|
-
enumerable: true,
|
|
36
|
-
configurable: true,
|
|
37
|
-
get() {
|
|
38
|
-
const ts = fallback.peek();
|
|
39
|
-
if (!ts) throw tsNotReadyError(`config.${key}`);
|
|
40
|
-
return ts.config[key];
|
|
41
|
-
},
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
const extractors = host.core ? [host.core.extractorSplit] : [{ name: view.extractors?.[0]?.name ?? "@teacss/core/extractor-split" }];
|
|
45
|
-
/** @type {Record<string, () => void>} */
|
|
46
|
-
const fields = {
|
|
47
|
-
presets: () => data("presets", presets),
|
|
48
|
-
content: () => data("content", view.content ?? {}),
|
|
49
|
-
transformers: () => data("transformers", transformers),
|
|
50
|
-
extractors: () => data("extractors", extractors),
|
|
51
|
-
extractorDefault: () => data("extractorDefault", extractors[0]),
|
|
52
|
-
sortLayers: () => data("sortLayers", (/** @type {string[]} */ layers) => layers),
|
|
53
|
-
};
|
|
54
|
-
for (const key of VIEW_FIELDS) fields[key] = () => data(key, view[key]);
|
|
55
|
-
if (engine) {
|
|
56
|
-
// compile-class.ts:84-106 pushes each definition onto `config.shortcuts` and splices it out
|
|
57
|
-
// when its last module drops it; the definitions live in the Engine, so one array is kept in
|
|
58
|
-
// step on every read.
|
|
59
|
-
const shortcuts = [...(view.shortcuts ?? [])];
|
|
60
|
-
const configured = shortcuts.length;
|
|
61
|
-
fields.shortcuts = () =>
|
|
62
|
-
Object.defineProperty(config, "shortcuts", {
|
|
63
|
-
enumerable: true,
|
|
64
|
-
configurable: true,
|
|
65
|
-
get() {
|
|
66
|
-
shortcuts.length = configured;
|
|
67
|
-
shortcuts.push(...engine.compileClassShortcuts());
|
|
68
|
-
return shortcuts;
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
for (const key of TS_ONLY_FIELDS) fields[key] = () => tsOnly(key);
|
|
73
|
-
|
|
74
|
-
for (const key of Object.keys(userConfig ?? {})) {
|
|
75
|
-
if (key === "engine") continue;
|
|
76
|
-
if (Object.hasOwn(fields, key)) fields[key]();
|
|
77
|
-
else data(key, userConfig[key]);
|
|
78
|
-
}
|
|
79
|
-
// Redefining a spread key keeps its position, as the object literal does.
|
|
80
|
-
for (const key of RESOLVED_KEYS) fields[key]();
|
|
81
|
-
return config;
|
|
82
|
-
}
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
// Token collections the facade shares with `@teacss/core`: CountableSet (core/utils/countable-set.ts),
|
|
3
|
-
// expandInputGroups (core/generator.ts:517-535) and the FIFO caches of core/bounded-cache.ts.
|
|
4
|
-
|
|
5
|
-
import { expandClassGroups, splitClassTokens } from "../../binding.js";
|
|
6
|
-
|
|
7
|
-
export const MAX_RUNTIME_CACHE_ENTRIES = 10_000;
|
|
8
|
-
|
|
9
|
-
/** @template K @extends {Set<K>} */
|
|
10
|
-
export class CountableSet extends Set {
|
|
11
|
-
/** @type {Map<K, number>} */
|
|
12
|
-
_map = new Map();
|
|
13
|
-
|
|
14
|
-
/** @param {Iterable<K>} [values] */
|
|
15
|
-
constructor(values) {
|
|
16
|
-
super();
|
|
17
|
-
if (values) for (const key of values) this.add(key);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/** @param {K} key */
|
|
21
|
-
add(key) {
|
|
22
|
-
this._map.set(key, (this._map.get(key) ?? 0) + 1);
|
|
23
|
-
return super.add(key);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** @param {K} key */
|
|
27
|
-
delete(key) {
|
|
28
|
-
if (!this._map.has(key)) return false;
|
|
29
|
-
this._map.delete(key);
|
|
30
|
-
return super.delete(key);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
clear() {
|
|
34
|
-
this._map.clear();
|
|
35
|
-
super.clear();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** @param {K} key */
|
|
39
|
-
getCount(key) {
|
|
40
|
-
return this._map.get(key) ?? 0;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** @param {K} key @param {number} count */
|
|
44
|
-
setCount(key, count) {
|
|
45
|
-
this._map.set(key, count);
|
|
46
|
-
return super.add(key);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/** @param {unknown} value @returns {value is CountableSet<string>} */
|
|
51
|
-
export function isCountableSet(value) {
|
|
52
|
-
return value instanceof CountableSet;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/** @template K @param {CountableSet<K>} input */
|
|
56
|
-
export function copyCountableSet(input) {
|
|
57
|
-
const copied = new CountableSet();
|
|
58
|
-
for (const key of input) copied.setCount(key, input.getCount(key));
|
|
59
|
-
return copied;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Expands the tokens holding a `{…}` group in place; the parts go to the end, and a counted
|
|
64
|
-
* group's count carries over to each part.
|
|
65
|
-
* @template {Set<string>} T @param {T} tokens @returns {T}
|
|
66
|
-
*/
|
|
67
|
-
export function expandInputGroups(tokens) {
|
|
68
|
-
const expanded = [...tokens].filter((token) => token.includes("{"));
|
|
69
|
-
if (expanded.length === 0) return tokens;
|
|
70
|
-
for (const token of expanded) {
|
|
71
|
-
const parts = splitClassTokens(expandClassGroups(token));
|
|
72
|
-
if (parts.length === 1 && parts[0] === token) continue;
|
|
73
|
-
const count = isCountableSet(tokens) ? tokens.getCount(token) : 1;
|
|
74
|
-
tokens.delete(token);
|
|
75
|
-
for (const part of parts) {
|
|
76
|
-
if (isCountableSet(tokens)) tokens.setCount(part, tokens.getCount(part) + count);
|
|
77
|
-
else tokens.add(part);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return tokens;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* The part of the oracle `BoundedMap` the facade uses: ordinary keys are evicted oldest first,
|
|
85
|
-
* retained keys never count toward the limit.
|
|
86
|
-
* @template V @extends {Map<string, V>}
|
|
87
|
-
*/
|
|
88
|
-
export class BoundedTokenCache extends Map {
|
|
89
|
-
/** @param {number} [maxEntries] */
|
|
90
|
-
constructor(maxEntries = MAX_RUNTIME_CACHE_ENTRIES) {
|
|
91
|
-
super();
|
|
92
|
-
this.maxEntries = maxEntries;
|
|
93
|
-
/** @type {Set<string>} */
|
|
94
|
-
this.retained = new Set();
|
|
95
|
-
/** Ordinary keys in insertion order, the order the native map iterates them. @type {Set<string>} */
|
|
96
|
-
this.order = new Set();
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
get retainedSize() {
|
|
100
|
-
return this.retained.size;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/** @param {string} key */
|
|
104
|
-
isRetained(key) {
|
|
105
|
-
return this.retained.has(key);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/** @param {string} key @param {V} value */
|
|
109
|
-
set(key, value) {
|
|
110
|
-
const exists = super.has(key);
|
|
111
|
-
super.set(key, value);
|
|
112
|
-
if (!exists && !this.retained.has(key)) this.order.add(key);
|
|
113
|
-
this.#enforceLimit();
|
|
114
|
-
return this;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/** @param {string} key */
|
|
118
|
-
delete(key) {
|
|
119
|
-
const deleted = super.delete(key);
|
|
120
|
-
this.order.delete(key);
|
|
121
|
-
this.retained.delete(key);
|
|
122
|
-
return deleted;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
clear() {
|
|
126
|
-
super.clear();
|
|
127
|
-
this.order.clear();
|
|
128
|
-
this.retained.clear();
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Replaces the retained entries (bounded-cache.ts:188-205 without the revision check).
|
|
133
|
-
* @param {Iterable<readonly [string, V]>} entries
|
|
134
|
-
*/
|
|
135
|
-
replaceRetained(entries) {
|
|
136
|
-
const next = new Map(entries);
|
|
137
|
-
for (const key of this.retained) {
|
|
138
|
-
if (next.has(key)) continue;
|
|
139
|
-
super.delete(key);
|
|
140
|
-
this.retained.delete(key);
|
|
141
|
-
}
|
|
142
|
-
for (const [key, value] of next) {
|
|
143
|
-
this.order.delete(key);
|
|
144
|
-
super.set(key, value);
|
|
145
|
-
this.retained.add(key);
|
|
146
|
-
}
|
|
147
|
-
this.#enforceLimit();
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
#enforceLimit() {
|
|
151
|
-
while (this.size - this.retained.size > this.maxEntries) {
|
|
152
|
-
const oldest = this.order.values().next();
|
|
153
|
-
if (oldest.done) break;
|
|
154
|
-
this.order.delete(oldest.value);
|
|
155
|
-
super.delete(oldest.value);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/** FIFO bounded Set (the oracle `BoundedSet` without its `assumeNoPrototypeBypass` fast path). @extends {Set<string>} */
|
|
161
|
-
export class BoundedSet extends Set {
|
|
162
|
-
/** @param {number} [maxEntries] @param {Iterable<string>} [values] */
|
|
163
|
-
constructor(maxEntries = MAX_RUNTIME_CACHE_ENTRIES, values) {
|
|
164
|
-
super();
|
|
165
|
-
this.maxEntries = maxEntries;
|
|
166
|
-
if (values) for (const value of values) this.add(value);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/** @param {string} value */
|
|
170
|
-
add(value) {
|
|
171
|
-
super.add(value);
|
|
172
|
-
while (this.size > this.maxEntries) {
|
|
173
|
-
const oldest = this.values().next();
|
|
174
|
-
if (oldest.done) break;
|
|
175
|
-
super.delete(oldest.value);
|
|
176
|
-
}
|
|
177
|
-
return this;
|
|
178
|
-
}
|
|
179
|
-
}
|
package/src/facade/errors.mjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
/** Errors the facade raises itself; an `Error` from napi (code `E_*`) passes through unwrapped. */
|
|
4
|
-
export class TeacssEngineError extends Error {
|
|
5
|
-
/** @param {string} code @param {string} message @param {Record<string, unknown>} [details] */
|
|
6
|
-
constructor(code, message, details = {}) {
|
|
7
|
-
super(message);
|
|
8
|
-
this.name = "TeacssEngineError";
|
|
9
|
-
this.code = code;
|
|
10
|
-
this.details = details;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/** v02.9 §2.1: the member needs `@teacss/core`, which is not installed. @param {string} member */
|
|
15
|
-
export function tsRequiredError(member) {
|
|
16
|
-
return new TeacssEngineError("E_TS_REQUIRED", `[@teacss/engine] ${member} requires @teacss/core (optional peer) to be installed`, { member });
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/** v02.9 §3.3: the member needs the TypeScript engine, which has not been materialized. @param {string} member */
|
|
20
|
-
export function tsNotReadyError(member) {
|
|
21
|
-
return new TeacssEngineError("E_TS_REQUIRED", `[@teacss/engine] ${member} needs the TypeScript engine; await generator[Symbol.for('@teacss/engine/materialize')]() first or set engine: 'ts'`, { member });
|
|
22
|
-
}
|