@teacss/engine 0.9.2 → 0.9.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/README.md +2 -1
- package/binding-header.d.ts +1 -0
- package/binding.d.ts +3 -0
- package/binding.js +54 -54
- package/contract.d.ts +7 -0
- package/dist/generator.js +12 -2
- package/dist/select.d.ts +8 -0
- package/dist/select.js +49 -0
- package/dist/ts-fallback.d.ts +10 -1
- package/dist/ts-fallback.js +3 -2
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -54,7 +54,8 @@ To keep TypeScript for any configuration, set `TEACSS_ENGINE=ts` (it covers ever
|
|
|
54
54
|
| `outputToCssLayers` | `outputToCssLayers` | Neither a boolean nor an object. | Use `true`, `false` or `{ allLayers }`. |
|
|
55
55
|
| `outputToCssLayers.cssLayerName` | `outputToCssLayers.cssLayerName` | A `cssLayerName` value; Rust does not support it. | Remove it. |
|
|
56
56
|
| `transformers` | `transformers` or `transformers[<n>]` | A transformer other than `@teacss/transformer-compile-class` and `@teacss/directives`, or a `transformers` value that is not an array. Other transformers run JavaScript over the source. | Remove the transformer, or keep TypeScript. |
|
|
57
|
-
| `
|
|
57
|
+
| `transformers.compile-class` | `transformers[<n>]` | The config lists its own `transformerCompileClass()` and the last Standard preset does not enable `compileClass`, or there is no Standard preset. Its options live in a closure, and the classes it registers never reach Rust. | Enable compile-class through `presetStandard({ compileClass })`, or keep TypeScript. |
|
|
58
|
+
| `shortcuts`, `safelist`, `blocklist`, `theme`, `layers` | the key and the item inside it | A value that is not static data: a shortcut whose expansion is not a string, or that has a regular expression or meta; a `safelist` or `blocklist` item that is not a string; a theme leaf that is not a string or number, the removed `rolePalettes` or `themes` theme key, or a `defaultMode` or mode name that is empty or holds a NUL or a lone surrogate (Standard rejects these; the TypeScript engine raises its error); a layer order that is not a number. | Replace the item with static data. |
|
|
58
59
|
| `preset-not-instantiated` | `presets[<n>]` | A preset that is a function, a promise or not an object. | Call the factory (`presetStandard()`, not `presetStandard`) and await it before passing it. |
|
|
59
60
|
| `preset-cycle` | `presets[<n>]…` | A preset that contains itself through nested `presets`. | Break the cycle. |
|
|
60
61
|
| `accessor` | the key | A getter or setter on the config, the defaults or a preset. Translation would run it once and the TypeScript engine again. | Use plain data properties. |
|
package/binding-header.d.ts
CHANGED
package/binding.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
EntryConfig,
|
|
7
7
|
EntryDiagnostic,
|
|
8
8
|
ExtractFileResult,
|
|
9
|
+
ExtractFilesUnionResult,
|
|
9
10
|
GenerateInput,
|
|
10
11
|
GenerateOptions,
|
|
11
12
|
GenerateResult,
|
|
@@ -41,6 +42,7 @@ export declare class Engine {
|
|
|
41
42
|
configFiles(): string[]
|
|
42
43
|
customThemeKeys(): string[]
|
|
43
44
|
updateModule(id: string, code: string): ModuleUpdateResult
|
|
45
|
+
updateModules(ids: string[], codes: string[]): ModuleUpdateResult[]
|
|
44
46
|
removeModule(id: string): boolean
|
|
45
47
|
clearModuleDefinitions(id: string): boolean
|
|
46
48
|
compileClassShortcuts(): Array<[string, string] | [string, string, { layer: string }]>
|
|
@@ -49,6 +51,7 @@ export declare class Engine {
|
|
|
49
51
|
extract(code: string, id?: string | undefined | null): string[]
|
|
50
52
|
extractCounted(code: string, id?: string | undefined | null): Array<{ token: string; count: number }>
|
|
51
53
|
extractFiles(paths: string[]): ExtractFileResult[]
|
|
54
|
+
extractFilesUnion(paths: string[]): ExtractFilesUnionResult
|
|
52
55
|
transformSource(id: string, code: string): TransformResult | null
|
|
53
56
|
transformStylesheet(id: string, code: string): TransformResult | null
|
|
54
57
|
generate(input: GenerateInput, options?: GenerateOptions | undefined | null): GenerateResult
|
package/binding.js
CHANGED
|
@@ -92,8 +92,8 @@ function requireNative() {
|
|
|
92
92
|
try {
|
|
93
93
|
const binding = require('@teacss/engine-android-arm64')
|
|
94
94
|
const bindingPackageVersion = require('@teacss/engine-android-arm64/package.json').version
|
|
95
|
-
if (bindingPackageVersion !== '0.9.
|
|
96
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
95
|
+
if (bindingPackageVersion !== '0.9.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
96
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
97
97
|
}
|
|
98
98
|
return binding
|
|
99
99
|
} catch (e) {
|
|
@@ -108,8 +108,8 @@ function requireNative() {
|
|
|
108
108
|
try {
|
|
109
109
|
const binding = require('@teacss/engine-android-arm-eabi')
|
|
110
110
|
const bindingPackageVersion = require('@teacss/engine-android-arm-eabi/package.json').version
|
|
111
|
-
if (bindingPackageVersion !== '0.9.
|
|
112
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
111
|
+
if (bindingPackageVersion !== '0.9.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
112
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
113
113
|
}
|
|
114
114
|
return binding
|
|
115
115
|
} catch (e) {
|
|
@@ -129,8 +129,8 @@ function requireNative() {
|
|
|
129
129
|
try {
|
|
130
130
|
const binding = require('@teacss/engine-win32-x64-gnu')
|
|
131
131
|
const bindingPackageVersion = require('@teacss/engine-win32-x64-gnu/package.json').version
|
|
132
|
-
if (bindingPackageVersion !== '0.9.
|
|
133
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
132
|
+
if (bindingPackageVersion !== '0.9.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
133
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
134
134
|
}
|
|
135
135
|
return binding
|
|
136
136
|
} catch (e) {
|
|
@@ -145,8 +145,8 @@ function requireNative() {
|
|
|
145
145
|
try {
|
|
146
146
|
const binding = require('@teacss/engine-win32-x64-msvc')
|
|
147
147
|
const bindingPackageVersion = require('@teacss/engine-win32-x64-msvc/package.json').version
|
|
148
|
-
if (bindingPackageVersion !== '0.9.
|
|
149
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
148
|
+
if (bindingPackageVersion !== '0.9.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
149
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
150
150
|
}
|
|
151
151
|
return binding
|
|
152
152
|
} catch (e) {
|
|
@@ -162,8 +162,8 @@ function requireNative() {
|
|
|
162
162
|
try {
|
|
163
163
|
const binding = require('@teacss/engine-win32-ia32-msvc')
|
|
164
164
|
const bindingPackageVersion = require('@teacss/engine-win32-ia32-msvc/package.json').version
|
|
165
|
-
if (bindingPackageVersion !== '0.9.
|
|
166
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
165
|
+
if (bindingPackageVersion !== '0.9.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
166
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
167
167
|
}
|
|
168
168
|
return binding
|
|
169
169
|
} catch (e) {
|
|
@@ -178,8 +178,8 @@ function requireNative() {
|
|
|
178
178
|
try {
|
|
179
179
|
const binding = require('@teacss/engine-win32-arm64-msvc')
|
|
180
180
|
const bindingPackageVersion = require('@teacss/engine-win32-arm64-msvc/package.json').version
|
|
181
|
-
if (bindingPackageVersion !== '0.9.
|
|
182
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
181
|
+
if (bindingPackageVersion !== '0.9.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
182
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
183
183
|
}
|
|
184
184
|
return binding
|
|
185
185
|
} catch (e) {
|
|
@@ -197,8 +197,8 @@ function requireNative() {
|
|
|
197
197
|
try {
|
|
198
198
|
const binding = require('@teacss/engine-darwin-universal')
|
|
199
199
|
const bindingPackageVersion = require('@teacss/engine-darwin-universal/package.json').version
|
|
200
|
-
if (bindingPackageVersion !== '0.9.
|
|
201
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
200
|
+
if (bindingPackageVersion !== '0.9.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
201
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
202
202
|
}
|
|
203
203
|
return binding
|
|
204
204
|
} catch (e) {
|
|
@@ -213,8 +213,8 @@ function requireNative() {
|
|
|
213
213
|
try {
|
|
214
214
|
const binding = require('@teacss/engine-darwin-x64')
|
|
215
215
|
const bindingPackageVersion = require('@teacss/engine-darwin-x64/package.json').version
|
|
216
|
-
if (bindingPackageVersion !== '0.9.
|
|
217
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
216
|
+
if (bindingPackageVersion !== '0.9.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
217
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
218
218
|
}
|
|
219
219
|
return binding
|
|
220
220
|
} catch (e) {
|
|
@@ -229,8 +229,8 @@ function requireNative() {
|
|
|
229
229
|
try {
|
|
230
230
|
const binding = require('@teacss/engine-darwin-arm64')
|
|
231
231
|
const bindingPackageVersion = require('@teacss/engine-darwin-arm64/package.json').version
|
|
232
|
-
if (bindingPackageVersion !== '0.9.
|
|
233
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
232
|
+
if (bindingPackageVersion !== '0.9.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
233
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
234
234
|
}
|
|
235
235
|
return binding
|
|
236
236
|
} catch (e) {
|
|
@@ -249,8 +249,8 @@ function requireNative() {
|
|
|
249
249
|
try {
|
|
250
250
|
const binding = require('@teacss/engine-freebsd-x64')
|
|
251
251
|
const bindingPackageVersion = require('@teacss/engine-freebsd-x64/package.json').version
|
|
252
|
-
if (bindingPackageVersion !== '0.9.
|
|
253
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
252
|
+
if (bindingPackageVersion !== '0.9.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
253
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
254
254
|
}
|
|
255
255
|
return binding
|
|
256
256
|
} catch (e) {
|
|
@@ -265,8 +265,8 @@ function requireNative() {
|
|
|
265
265
|
try {
|
|
266
266
|
const binding = require('@teacss/engine-freebsd-arm64')
|
|
267
267
|
const bindingPackageVersion = require('@teacss/engine-freebsd-arm64/package.json').version
|
|
268
|
-
if (bindingPackageVersion !== '0.9.
|
|
269
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
268
|
+
if (bindingPackageVersion !== '0.9.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
269
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
270
270
|
}
|
|
271
271
|
return binding
|
|
272
272
|
} catch (e) {
|
|
@@ -286,8 +286,8 @@ function requireNative() {
|
|
|
286
286
|
try {
|
|
287
287
|
const binding = require('@teacss/engine-linux-x64-musl')
|
|
288
288
|
const bindingPackageVersion = require('@teacss/engine-linux-x64-musl/package.json').version
|
|
289
|
-
if (bindingPackageVersion !== '0.9.
|
|
290
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
289
|
+
if (bindingPackageVersion !== '0.9.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
290
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
291
291
|
}
|
|
292
292
|
return binding
|
|
293
293
|
} catch (e) {
|
|
@@ -302,8 +302,8 @@ function requireNative() {
|
|
|
302
302
|
try {
|
|
303
303
|
const binding = require('@teacss/engine-linux-x64-gnu')
|
|
304
304
|
const bindingPackageVersion = require('@teacss/engine-linux-x64-gnu/package.json').version
|
|
305
|
-
if (bindingPackageVersion !== '0.9.
|
|
306
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
305
|
+
if (bindingPackageVersion !== '0.9.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
306
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
307
307
|
}
|
|
308
308
|
return binding
|
|
309
309
|
} catch (e) {
|
|
@@ -320,8 +320,8 @@ function requireNative() {
|
|
|
320
320
|
try {
|
|
321
321
|
const binding = require('@teacss/engine-linux-arm64-musl')
|
|
322
322
|
const bindingPackageVersion = require('@teacss/engine-linux-arm64-musl/package.json').version
|
|
323
|
-
if (bindingPackageVersion !== '0.9.
|
|
324
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
323
|
+
if (bindingPackageVersion !== '0.9.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
324
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
325
325
|
}
|
|
326
326
|
return binding
|
|
327
327
|
} catch (e) {
|
|
@@ -336,8 +336,8 @@ function requireNative() {
|
|
|
336
336
|
try {
|
|
337
337
|
const binding = require('@teacss/engine-linux-arm64-gnu')
|
|
338
338
|
const bindingPackageVersion = require('@teacss/engine-linux-arm64-gnu/package.json').version
|
|
339
|
-
if (bindingPackageVersion !== '0.9.
|
|
340
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
339
|
+
if (bindingPackageVersion !== '0.9.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
340
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
341
341
|
}
|
|
342
342
|
return binding
|
|
343
343
|
} catch (e) {
|
|
@@ -354,8 +354,8 @@ function requireNative() {
|
|
|
354
354
|
try {
|
|
355
355
|
const binding = require('@teacss/engine-linux-arm-musleabihf')
|
|
356
356
|
const bindingPackageVersion = require('@teacss/engine-linux-arm-musleabihf/package.json').version
|
|
357
|
-
if (bindingPackageVersion !== '0.9.
|
|
358
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
357
|
+
if (bindingPackageVersion !== '0.9.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
358
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
359
359
|
}
|
|
360
360
|
return binding
|
|
361
361
|
} catch (e) {
|
|
@@ -370,8 +370,8 @@ function requireNative() {
|
|
|
370
370
|
try {
|
|
371
371
|
const binding = require('@teacss/engine-linux-arm-gnueabihf')
|
|
372
372
|
const bindingPackageVersion = require('@teacss/engine-linux-arm-gnueabihf/package.json').version
|
|
373
|
-
if (bindingPackageVersion !== '0.9.
|
|
374
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
373
|
+
if (bindingPackageVersion !== '0.9.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
374
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
375
375
|
}
|
|
376
376
|
return binding
|
|
377
377
|
} catch (e) {
|
|
@@ -388,8 +388,8 @@ function requireNative() {
|
|
|
388
388
|
try {
|
|
389
389
|
const binding = require('@teacss/engine-linux-loong64-musl')
|
|
390
390
|
const bindingPackageVersion = require('@teacss/engine-linux-loong64-musl/package.json').version
|
|
391
|
-
if (bindingPackageVersion !== '0.9.
|
|
392
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
391
|
+
if (bindingPackageVersion !== '0.9.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
392
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
393
393
|
}
|
|
394
394
|
return binding
|
|
395
395
|
} catch (e) {
|
|
@@ -404,8 +404,8 @@ function requireNative() {
|
|
|
404
404
|
try {
|
|
405
405
|
const binding = require('@teacss/engine-linux-loong64-gnu')
|
|
406
406
|
const bindingPackageVersion = require('@teacss/engine-linux-loong64-gnu/package.json').version
|
|
407
|
-
if (bindingPackageVersion !== '0.9.
|
|
408
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
407
|
+
if (bindingPackageVersion !== '0.9.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
408
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
409
409
|
}
|
|
410
410
|
return binding
|
|
411
411
|
} catch (e) {
|
|
@@ -422,8 +422,8 @@ function requireNative() {
|
|
|
422
422
|
try {
|
|
423
423
|
const binding = require('@teacss/engine-linux-riscv64-musl')
|
|
424
424
|
const bindingPackageVersion = require('@teacss/engine-linux-riscv64-musl/package.json').version
|
|
425
|
-
if (bindingPackageVersion !== '0.9.
|
|
426
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
425
|
+
if (bindingPackageVersion !== '0.9.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
426
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
427
427
|
}
|
|
428
428
|
return binding
|
|
429
429
|
} catch (e) {
|
|
@@ -438,8 +438,8 @@ function requireNative() {
|
|
|
438
438
|
try {
|
|
439
439
|
const binding = require('@teacss/engine-linux-riscv64-gnu')
|
|
440
440
|
const bindingPackageVersion = require('@teacss/engine-linux-riscv64-gnu/package.json').version
|
|
441
|
-
if (bindingPackageVersion !== '0.9.
|
|
442
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
441
|
+
if (bindingPackageVersion !== '0.9.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
442
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
443
443
|
}
|
|
444
444
|
return binding
|
|
445
445
|
} catch (e) {
|
|
@@ -455,8 +455,8 @@ function requireNative() {
|
|
|
455
455
|
try {
|
|
456
456
|
const binding = require('@teacss/engine-linux-ppc64-gnu')
|
|
457
457
|
const bindingPackageVersion = require('@teacss/engine-linux-ppc64-gnu/package.json').version
|
|
458
|
-
if (bindingPackageVersion !== '0.9.
|
|
459
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
458
|
+
if (bindingPackageVersion !== '0.9.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
459
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
460
460
|
}
|
|
461
461
|
return binding
|
|
462
462
|
} catch (e) {
|
|
@@ -471,8 +471,8 @@ function requireNative() {
|
|
|
471
471
|
try {
|
|
472
472
|
const binding = require('@teacss/engine-linux-s390x-gnu')
|
|
473
473
|
const bindingPackageVersion = require('@teacss/engine-linux-s390x-gnu/package.json').version
|
|
474
|
-
if (bindingPackageVersion !== '0.9.
|
|
475
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
474
|
+
if (bindingPackageVersion !== '0.9.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
475
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
476
476
|
}
|
|
477
477
|
return binding
|
|
478
478
|
} catch (e) {
|
|
@@ -491,8 +491,8 @@ function requireNative() {
|
|
|
491
491
|
try {
|
|
492
492
|
const binding = require('@teacss/engine-openharmony-arm64')
|
|
493
493
|
const bindingPackageVersion = require('@teacss/engine-openharmony-arm64/package.json').version
|
|
494
|
-
if (bindingPackageVersion !== '0.9.
|
|
495
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
494
|
+
if (bindingPackageVersion !== '0.9.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
495
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
496
496
|
}
|
|
497
497
|
return binding
|
|
498
498
|
} catch (e) {
|
|
@@ -507,8 +507,8 @@ function requireNative() {
|
|
|
507
507
|
try {
|
|
508
508
|
const binding = require('@teacss/engine-openharmony-x64')
|
|
509
509
|
const bindingPackageVersion = require('@teacss/engine-openharmony-x64/package.json').version
|
|
510
|
-
if (bindingPackageVersion !== '0.9.
|
|
511
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
510
|
+
if (bindingPackageVersion !== '0.9.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
511
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
512
512
|
}
|
|
513
513
|
return binding
|
|
514
514
|
} catch (e) {
|
|
@@ -523,8 +523,8 @@ function requireNative() {
|
|
|
523
523
|
try {
|
|
524
524
|
const binding = require('@teacss/engine-openharmony-arm')
|
|
525
525
|
const bindingPackageVersion = require('@teacss/engine-openharmony-arm/package.json').version
|
|
526
|
-
if (bindingPackageVersion !== '0.9.
|
|
527
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
526
|
+
if (bindingPackageVersion !== '0.9.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
527
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
528
528
|
}
|
|
529
529
|
return binding
|
|
530
530
|
} catch (e) {
|
|
@@ -664,8 +664,8 @@ if (!nativeBinding || forceWasi) {
|
|
|
664
664
|
if (!candidateFailed) {
|
|
665
665
|
if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
666
666
|
const bindingPackageVersion = require('@teacss/engine-wasm32-wasi/package.json').version
|
|
667
|
-
if (bindingPackageVersion !== '0.9.
|
|
668
|
-
throw new Error(`WASI binding package version mismatch, expected 0.9.
|
|
667
|
+
if (bindingPackageVersion !== '0.9.4') {
|
|
668
|
+
throw new Error(`WASI binding package version mismatch, expected 0.9.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
669
669
|
}
|
|
670
670
|
}
|
|
671
671
|
wasiBinding = require('@teacss/engine-wasm32-wasi')
|
package/contract.d.ts
CHANGED
|
@@ -111,6 +111,13 @@ export interface ExtractFileResult {
|
|
|
111
111
|
error: string | null;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
export interface ExtractFilesUnionResult {
|
|
115
|
+
/** 成功读取的文件的 token 并集,顺序见 extractFilesUnion。 */
|
|
116
|
+
tokens: string[];
|
|
117
|
+
/** 读失败的文件,按输入顺序;error 与 ExtractFileResult.error 取值相同。 */
|
|
118
|
+
failed: Array<{ path: string; error: string }>;
|
|
119
|
+
}
|
|
120
|
+
|
|
114
121
|
export interface TransformResult {
|
|
115
122
|
code: string;
|
|
116
123
|
/** 从原文到 code 的替换序列,UTF-16 code unit 偏移,按 (start, end) 升序且互不重叠。facade 在宿主的 MagicString 上按顺序回放:`start === end ? s.appendLeft(start, text) : s.update(start, end, text)`(magic-string 1.x 的 `update` 与 `overwrite` 除 `storeName` 默认值外相同),使 runtime 生成的 source map 与 0.8.2 完全一致(v02.8 §7)。 */
|
package/dist/generator.js
CHANGED
|
@@ -305,6 +305,8 @@ export class FacadeGenerator {
|
|
|
305
305
|
#backend;
|
|
306
306
|
#disposed = false;
|
|
307
307
|
#held = null;
|
|
308
|
+
/** A TS candidate's own commit, run when another generator commits it. */
|
|
309
|
+
#commitTs = null;
|
|
308
310
|
#host;
|
|
309
311
|
#tsFallback;
|
|
310
312
|
/** The compile-class transformer: created once and handed to every candidate (v02.9 §5.2). */
|
|
@@ -748,7 +750,8 @@ export class FacadeGenerator {
|
|
|
748
750
|
else {
|
|
749
751
|
this.#reportFallback(translated);
|
|
750
752
|
const ts = await this.#tsFallback.create(userConfig, nextDefaults);
|
|
751
|
-
candidate = new FacadeGenerator({ ts, userConfig, defaults: nextDefaults, host: this.#host });
|
|
753
|
+
candidate = new FacadeGenerator({ ts: ts.generator, userConfig, defaults: nextDefaults, host: this.#host });
|
|
754
|
+
candidate.#commitTs = ts.commit;
|
|
752
755
|
}
|
|
753
756
|
const prepared = Object.freeze({ config: candidate.config, defaults: nextDefaults, generator: candidate, userConfig, version });
|
|
754
757
|
this.#prepared.add(prepared);
|
|
@@ -772,11 +775,18 @@ export class FacadeGenerator {
|
|
|
772
775
|
}
|
|
773
776
|
if (candidate.config !== prepared.config)
|
|
774
777
|
return false;
|
|
778
|
+
let next = candidate.#backend;
|
|
779
|
+
if (candidate.#commitTs) {
|
|
780
|
+
const committed = candidate.#commitTs();
|
|
781
|
+
if (!committed)
|
|
782
|
+
return false;
|
|
783
|
+
next = { kind: "ts", generator: committed };
|
|
784
|
+
}
|
|
775
785
|
const previous = this.#backend;
|
|
776
786
|
this.defaults = prepared.defaults;
|
|
777
787
|
this.userConfig = prepared.userConfig;
|
|
778
788
|
this.#clearRuntimeCaches();
|
|
779
|
-
this.#backend =
|
|
789
|
+
this.#backend = next;
|
|
780
790
|
if (candidate.#held)
|
|
781
791
|
candidate.#held.committed = true;
|
|
782
792
|
this.#tsFallback.invalidate(prepared.userConfig, prepared.defaults);
|
package/dist/select.d.ts
CHANGED
|
@@ -88,6 +88,14 @@ export declare const ALLOWED_TRANSFORMER_NAMES: Set<string>;
|
|
|
88
88
|
* checked per call (v02.9 §6.3), so none are read here.
|
|
89
89
|
*/
|
|
90
90
|
export declare function translateTransformers(list: unknown): Success<object[]> | Failure;
|
|
91
|
+
/**
|
|
92
|
+
* A config's own `transformerCompileClass(options)` keeps its options in a closure the facade
|
|
93
|
+
* cannot read, and it registers classes by pushing onto `config.shortcuts`, which never reaches
|
|
94
|
+
* the Engine. It is harmless only when the last Standard preset enables compileClass: the facade's
|
|
95
|
+
* Rust transformer then comes first and `uniqueNamed` drops it, as the oracle drops it after the
|
|
96
|
+
* preset's own. Otherwise it would run and its classes would generate no CSS, so it falls back.
|
|
97
|
+
*/
|
|
98
|
+
export declare function hostCompileClass(transformers: readonly object[], presetSpecs: readonly object[]): Failure | undefined;
|
|
91
99
|
export type EntryProvenance = {
|
|
92
100
|
base: string;
|
|
93
101
|
entryFile: string | undefined;
|
package/dist/select.js
CHANGED
|
@@ -294,6 +294,26 @@ export function translateShortcuts(value, path, reasonOnFail) {
|
|
|
294
294
|
}
|
|
295
295
|
return ok(pairs.length > 0 ? pairs : undefined);
|
|
296
296
|
}
|
|
297
|
+
/** context.ts `isContextName` behind its falsy check: no NUL and no lone surrogate. */
|
|
298
|
+
function isContextName(value) {
|
|
299
|
+
if (!value)
|
|
300
|
+
return false;
|
|
301
|
+
if (typeof value !== "string")
|
|
302
|
+
return true;
|
|
303
|
+
for (let index = 0; index < value.length; index++) {
|
|
304
|
+
const code = value.charCodeAt(index);
|
|
305
|
+
if (code === 0)
|
|
306
|
+
return false;
|
|
307
|
+
if (code >= 0xd800 && code <= 0xdbff) {
|
|
308
|
+
const next = value.charCodeAt(++index);
|
|
309
|
+
if (!(next >= 0xdc00 && next <= 0xdfff))
|
|
310
|
+
return false;
|
|
311
|
+
}
|
|
312
|
+
else if (code >= 0xdc00 && code <= 0xdfff)
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
return true;
|
|
316
|
+
}
|
|
297
317
|
/**
|
|
298
318
|
* v02.9 §4.5: a theme as dotted keys to string leaves (numbers stringified); empty objects vanish.
|
|
299
319
|
*
|
|
@@ -311,6 +331,16 @@ export function flattenTheme(theme, path, reasonOnFail) {
|
|
|
311
331
|
if (isPlainObject(values) && Object.hasOwn(values, "rolePalettes"))
|
|
312
332
|
return fail(reasonOnFail, `${path}.modes.${mode}.rolePalettes`);
|
|
313
333
|
}
|
|
334
|
+
// Standard's `validateContextNames` (context.ts) throws on these. Flattening drops an empty
|
|
335
|
+
// object and the binding replaces lone surrogates, so Rust cannot see them.
|
|
336
|
+
if (Object.hasOwn(theme, "themes"))
|
|
337
|
+
return fail(reasonOnFail, `${path}.themes`);
|
|
338
|
+
if (Object.hasOwn(theme, "defaultMode") && !isContextName(theme.defaultMode))
|
|
339
|
+
return fail(reasonOnFail, `${path}.defaultMode`);
|
|
340
|
+
for (const [mode] of modes) {
|
|
341
|
+
if (!isContextName(mode))
|
|
342
|
+
return fail(reasonOnFail, `${path}.modes.${mode}`);
|
|
343
|
+
}
|
|
314
344
|
const flat = {};
|
|
315
345
|
const visit = (object, prefix) => {
|
|
316
346
|
for (const [key, value] of Object.entries(object)) {
|
|
@@ -448,6 +478,22 @@ export function translateTransformers(list) {
|
|
|
448
478
|
}
|
|
449
479
|
return ok(kept);
|
|
450
480
|
}
|
|
481
|
+
/**
|
|
482
|
+
* A config's own `transformerCompileClass(options)` keeps its options in a closure the facade
|
|
483
|
+
* cannot read, and it registers classes by pushing onto `config.shortcuts`, which never reaches
|
|
484
|
+
* the Engine. It is harmless only when the last Standard preset enables compileClass: the facade's
|
|
485
|
+
* Rust transformer then comes first and `uniqueNamed` drops it, as the oracle drops it after the
|
|
486
|
+
* preset's own. Otherwise it would run and its classes would generate no CSS, so it falls back.
|
|
487
|
+
*/
|
|
488
|
+
export function hostCompileClass(transformers, presetSpecs) {
|
|
489
|
+
const index = transformers.findIndex((transformer) => transformer.name === "@teacss/transformer-compile-class");
|
|
490
|
+
if (index < 0)
|
|
491
|
+
return undefined;
|
|
492
|
+
const standard = presetSpecs.findLast((spec) => spec.kind === "standard");
|
|
493
|
+
if (standard && standard.options.compileClass !== false)
|
|
494
|
+
return undefined;
|
|
495
|
+
return fail("transformers.compile-class", `transformers[${index}]`);
|
|
496
|
+
}
|
|
451
497
|
export const scanners = {
|
|
452
498
|
load: null,
|
|
453
499
|
};
|
|
@@ -563,6 +609,9 @@ async function translate(userConfig, defaults) {
|
|
|
563
609
|
const transformers = translateTransformers(merged.transformers);
|
|
564
610
|
if (!transformers.ok)
|
|
565
611
|
return transformers;
|
|
612
|
+
const compileClass = hostCompileClass(transformers.value, presetSpecs);
|
|
613
|
+
if (compileClass)
|
|
614
|
+
return compileClass;
|
|
566
615
|
const inline = translateInline(merged);
|
|
567
616
|
if (!inline.ok)
|
|
568
617
|
return inline;
|
package/dist/ts-fallback.d.ts
CHANGED
|
@@ -16,7 +16,16 @@ export interface TsFallback {
|
|
|
16
16
|
invalidate(userConfig: object, defaults: object): void;
|
|
17
17
|
generator(member?: string): Promise<TsGenerator>;
|
|
18
18
|
peek(): TsGenerator | null;
|
|
19
|
-
create(userConfig: object, defaults: object): Promise<
|
|
19
|
+
create(userConfig: object, defaults: object): Promise<TsCandidate>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A prepared TS configuration. `commit` runs the base generator's own `commitConfig`, which
|
|
23
|
+
* re-reads in-place edits of the prepared config (generator.ts:2036-2063), and returns the
|
|
24
|
+
* generator that now serves it, or `null` when the TS generator refused the commit.
|
|
25
|
+
*/
|
|
26
|
+
export interface TsCandidate {
|
|
27
|
+
generator: TsGenerator;
|
|
28
|
+
commit(): TsGenerator | null;
|
|
20
29
|
}
|
|
21
30
|
/**
|
|
22
31
|
* `engine: "ts"` goes into the defaults, which take precedence over `config.engine`, so the TS
|
package/dist/ts-fallback.js
CHANGED
|
@@ -70,8 +70,9 @@ export function createTsFallback(host, committed) {
|
|
|
70
70
|
// translate it, so `createGenerator` resolves to TS and creates no Engine.
|
|
71
71
|
const base = await createTs(binding, typeof binding.createTsGenerator === "function" ? {} : userConfig, defaults);
|
|
72
72
|
if (ENGINE_INSTANCE in Object(base) || typeof base?.prepareConfig !== "function")
|
|
73
|
-
return base;
|
|
74
|
-
|
|
73
|
+
return { generator: base, commit: () => base };
|
|
74
|
+
const prepared = await base.prepareConfig(userConfig, tsDefaults);
|
|
75
|
+
return { generator: prepared.generator, commit: () => (base.commitConfig(prepared) ? base : null) };
|
|
75
76
|
},
|
|
76
77
|
};
|
|
77
78
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teacss/engine",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.4",
|
|
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",
|
|
@@ -72,14 +72,14 @@
|
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
74
|
"optionalDependencies": {
|
|
75
|
-
"@teacss/engine-darwin-arm64": "0.9.
|
|
76
|
-
"@teacss/engine-darwin-x64": "0.9.
|
|
77
|
-
"@teacss/engine-linux-arm64-gnu": "0.9.
|
|
78
|
-
"@teacss/engine-linux-arm64-musl": "0.9.
|
|
79
|
-
"@teacss/engine-linux-x64-gnu": "0.9.
|
|
80
|
-
"@teacss/engine-linux-x64-musl": "0.9.
|
|
81
|
-
"@teacss/engine-win32-arm64-msvc": "0.9.
|
|
82
|
-
"@teacss/engine-win32-x64-msvc": "0.9.
|
|
75
|
+
"@teacss/engine-darwin-arm64": "0.9.4",
|
|
76
|
+
"@teacss/engine-darwin-x64": "0.9.4",
|
|
77
|
+
"@teacss/engine-linux-arm64-gnu": "0.9.4",
|
|
78
|
+
"@teacss/engine-linux-arm64-musl": "0.9.4",
|
|
79
|
+
"@teacss/engine-linux-x64-gnu": "0.9.4",
|
|
80
|
+
"@teacss/engine-linux-x64-musl": "0.9.4",
|
|
81
|
+
"@teacss/engine-win32-arm64-msvc": "0.9.4",
|
|
82
|
+
"@teacss/engine-win32-x64-msvc": "0.9.4"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
85
|
"@teacss/config": ">=0.8.5 <0.10.0 || >=0.9.0-alpha.0 <0.10.0",
|