@csszyx/unplugin 0.11.11 → 0.13.0
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 +1 -1
- package/dist/index.cjs +11 -7
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +4 -3
- package/dist/next-config.cjs +3 -0
- package/dist/next-config.d.cts +10 -0
- package/dist/next-config.d.mts +10 -0
- package/dist/next-config.mjs +3 -0
- package/dist/next-prebuild.cjs +12 -5
- package/dist/next-prebuild.d.cts +7 -0
- package/dist/next-prebuild.d.mts +7 -0
- package/dist/next-prebuild.mjs +12 -5
- package/dist/next-turbo-loader.cjs +29 -59
- package/dist/next-turbo-loader.d.cts +10 -0
- package/dist/next-turbo-loader.d.mts +10 -0
- package/dist/next-turbo-loader.mjs +28 -58
- package/dist/next-watcher.cjs +1 -1
- package/dist/next-watcher.mjs +1 -1
- package/dist/shared/unplugin.4du3qMst.cjs +529 -0
- package/dist/shared/unplugin.5l4RHMQh.mjs +578 -0
- package/dist/shared/unplugin.BB0iWSds.mjs +495 -0
- package/dist/shared/{unplugin.DMcbmP01.mjs → unplugin.BU0O4IkX.mjs} +4 -1
- package/dist/shared/{unplugin.CJcFsJcf.cjs → unplugin.Bf4fNbp7.cjs} +452 -504
- package/dist/shared/{unplugin.BZq6FKn2.cjs → unplugin.CUTa6bY9.cjs} +89 -1
- package/dist/shared/{unplugin.DblMogcN.cjs → unplugin.Cji6O5jv.cjs} +4 -1
- package/dist/shared/{unplugin.-yLpX1Ck.mjs → unplugin.CogPHmDs.mjs} +73 -3
- package/dist/shared/{unplugin.BK7BIeBn.d.cts → unplugin.DCT7DDG6.d.cts} +88 -26
- package/dist/shared/{unplugin.BK7BIeBn.d.mts → unplugin.DCT7DDG6.d.mts} +88 -26
- package/dist/shared/unplugin.X9a9SL_s.cjs +612 -0
- package/dist/shared/{unplugin.B2RUVK6Z.mjs → unplugin.ymMe428s.mjs} +426 -477
- package/dist/vite.cjs +4 -3
- package/dist/vite.d.cts +2 -2
- package/dist/vite.d.mts +1 -1
- package/dist/vite.mjs +4 -3
- package/dist/webpack.cjs +4 -3
- package/dist/webpack.d.cts +2 -2
- package/dist/webpack.d.mts +1 -1
- package/dist/webpack.mjs +4 -3
- package/package.json +13 -11
- package/dist/shared/unplugin.CKIOVNOg.cjs +0 -241
- package/dist/shared/unplugin.Cnxm1DcC.cjs +0 -53
- package/dist/shared/unplugin.Lhzkcj-A.mjs +0 -49
- package/dist/shared/unplugin.fOnGXWgS.mjs +0 -217
package/dist/vite.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const unplugin = require('./shared/unplugin.
|
|
5
|
+
const unplugin = require('./shared/unplugin.Bf4fNbp7.cjs');
|
|
6
6
|
require('node:crypto');
|
|
7
7
|
require('node:fs');
|
|
8
8
|
require('node:module');
|
|
@@ -16,12 +16,13 @@ require('@csszyx/svelte-adapter');
|
|
|
16
16
|
require('@csszyx/types');
|
|
17
17
|
require('@csszyx/vue-adapter');
|
|
18
18
|
require('unplugin');
|
|
19
|
-
require('./shared/unplugin.
|
|
19
|
+
require('./shared/unplugin.4du3qMst.cjs');
|
|
20
20
|
require('./css-mangler.cjs');
|
|
21
21
|
require('postcss');
|
|
22
22
|
require('postcss-selector-parser');
|
|
23
|
-
require('./shared/unplugin.
|
|
23
|
+
require('./shared/unplugin.X9a9SL_s.cjs');
|
|
24
24
|
require('./shared/unplugin.BkRah5Ot.cjs');
|
|
25
|
+
require('node:zlib');
|
|
25
26
|
require('postcss-value-parser');
|
|
26
27
|
|
|
27
28
|
|
package/dist/vite.d.cts
CHANGED
package/dist/vite.d.mts
CHANGED
package/dist/vite.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { $ as default } from './shared/unplugin.ymMe428s.mjs';
|
|
2
2
|
import 'node:crypto';
|
|
3
3
|
import 'node:fs';
|
|
4
4
|
import 'node:module';
|
|
@@ -12,10 +12,11 @@ import '@csszyx/svelte-adapter';
|
|
|
12
12
|
import '@csszyx/types';
|
|
13
13
|
import '@csszyx/vue-adapter';
|
|
14
14
|
import 'unplugin';
|
|
15
|
-
import './shared/unplugin.
|
|
15
|
+
import './shared/unplugin.BB0iWSds.mjs';
|
|
16
16
|
import './css-mangler.mjs';
|
|
17
17
|
import 'postcss';
|
|
18
18
|
import 'postcss-selector-parser';
|
|
19
|
-
import './shared/unplugin.
|
|
19
|
+
import './shared/unplugin.5l4RHMQh.mjs';
|
|
20
20
|
import './shared/unplugin.B3XoSRB8.mjs';
|
|
21
|
+
import 'node:zlib';
|
|
21
22
|
import 'postcss-value-parser';
|
package/dist/webpack.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const unplugin = require('./shared/unplugin.
|
|
5
|
+
const unplugin = require('./shared/unplugin.Bf4fNbp7.cjs');
|
|
6
6
|
require('node:crypto');
|
|
7
7
|
require('node:fs');
|
|
8
8
|
require('node:module');
|
|
@@ -16,12 +16,13 @@ require('@csszyx/svelte-adapter');
|
|
|
16
16
|
require('@csszyx/types');
|
|
17
17
|
require('@csszyx/vue-adapter');
|
|
18
18
|
require('unplugin');
|
|
19
|
-
require('./shared/unplugin.
|
|
19
|
+
require('./shared/unplugin.4du3qMst.cjs');
|
|
20
20
|
require('./css-mangler.cjs');
|
|
21
21
|
require('postcss');
|
|
22
22
|
require('postcss-selector-parser');
|
|
23
|
-
require('./shared/unplugin.
|
|
23
|
+
require('./shared/unplugin.X9a9SL_s.cjs');
|
|
24
24
|
require('./shared/unplugin.BkRah5Ot.cjs');
|
|
25
|
+
require('node:zlib');
|
|
25
26
|
require('postcss-value-parser');
|
|
26
27
|
|
|
27
28
|
|
package/dist/webpack.d.cts
CHANGED
package/dist/webpack.d.mts
CHANGED
package/dist/webpack.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { a0 as default } from './shared/unplugin.ymMe428s.mjs';
|
|
2
2
|
import 'node:crypto';
|
|
3
3
|
import 'node:fs';
|
|
4
4
|
import 'node:module';
|
|
@@ -12,10 +12,11 @@ import '@csszyx/svelte-adapter';
|
|
|
12
12
|
import '@csszyx/types';
|
|
13
13
|
import '@csszyx/vue-adapter';
|
|
14
14
|
import 'unplugin';
|
|
15
|
-
import './shared/unplugin.
|
|
15
|
+
import './shared/unplugin.BB0iWSds.mjs';
|
|
16
16
|
import './css-mangler.mjs';
|
|
17
17
|
import 'postcss';
|
|
18
18
|
import 'postcss-selector-parser';
|
|
19
|
-
import './shared/unplugin.
|
|
19
|
+
import './shared/unplugin.5l4RHMQh.mjs';
|
|
20
20
|
import './shared/unplugin.B3XoSRB8.mjs';
|
|
21
|
+
import 'node:zlib';
|
|
21
22
|
import 'postcss-value-parser';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@csszyx/unplugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Vite and Webpack integration for csszyx",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"csszyx",
|
|
@@ -112,31 +112,33 @@
|
|
|
112
112
|
"dist"
|
|
113
113
|
],
|
|
114
114
|
"dependencies": {
|
|
115
|
-
"postcss": "^8.5.
|
|
115
|
+
"postcss": "^8.5.23",
|
|
116
116
|
"postcss-selector-parser": "^7.1.4",
|
|
117
117
|
"postcss-value-parser": "^4.2.0",
|
|
118
118
|
"proper-lockfile": "^4.1.2",
|
|
119
119
|
"unplugin": "^3.3.0",
|
|
120
|
-
"@csszyx/compiler": "0.
|
|
121
|
-
"@csszyx/svelte-adapter": "0.
|
|
122
|
-
"@csszyx/
|
|
123
|
-
"@csszyx/
|
|
124
|
-
"@csszyx/
|
|
120
|
+
"@csszyx/compiler": "0.13.0",
|
|
121
|
+
"@csszyx/svelte-adapter": "0.13.0",
|
|
122
|
+
"@csszyx/types": "0.13.0",
|
|
123
|
+
"@csszyx/vue-adapter": "0.13.0",
|
|
124
|
+
"@csszyx/core": "0.13.0"
|
|
125
125
|
},
|
|
126
126
|
"peerDependencies": {
|
|
127
|
-
"@csszyx/runtime": "^0.
|
|
127
|
+
"@csszyx/runtime": "^0.13.0"
|
|
128
128
|
},
|
|
129
129
|
"devDependencies": {
|
|
130
130
|
"@tailwindcss/node": "4.3.3",
|
|
131
131
|
"@types/node": "^22.20.1",
|
|
132
132
|
"@types/proper-lockfile": "^4.1.4",
|
|
133
|
-
"esbuild": "
|
|
134
|
-
"rollup": "^4.62.
|
|
133
|
+
"esbuild": "0.28.1",
|
|
134
|
+
"rollup": "^4.62.3",
|
|
135
135
|
"typescript": "^6.0.3",
|
|
136
136
|
"unbuild": "^3.6.1",
|
|
137
137
|
"vite": "^8.1.5",
|
|
138
138
|
"vitest": "^4.1.10",
|
|
139
|
-
"webpack": "^5.
|
|
139
|
+
"webpack": "^5.109.0",
|
|
140
|
+
"@csszyx/runtime": "0.13.0",
|
|
141
|
+
"@csszyx/tooling-metadata": "0.13.0"
|
|
140
142
|
},
|
|
141
143
|
"sideEffects": false,
|
|
142
144
|
"engines": {
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const compiler = require('@csszyx/compiler');
|
|
4
|
-
const node_crypto = require('node:crypto');
|
|
5
|
-
const fs = require('node:fs');
|
|
6
|
-
const path = require('node:path');
|
|
7
|
-
|
|
8
|
-
function _interopNamespaceCompat(e) {
|
|
9
|
-
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
10
|
-
const n = Object.create(null);
|
|
11
|
-
if (e) {
|
|
12
|
-
for (const k in e) {
|
|
13
|
-
n[k] = e[k];
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
n.default = e;
|
|
17
|
-
return n;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const fs__namespace = /*#__PURE__*/_interopNamespaceCompat(fs);
|
|
21
|
-
const path__namespace = /*#__PURE__*/_interopNamespaceCompat(path);
|
|
22
|
-
|
|
23
|
-
const WINDOWS_PATH_SEPARATOR = String.fromCodePoint(92);
|
|
24
|
-
function normalizePathSeparators(value) {
|
|
25
|
-
return value.split(WINDOWS_PATH_SEPARATOR).join("/");
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function babelFallbackReason(error) {
|
|
29
|
-
if (error instanceof compiler.OxcNotImplementedError) {
|
|
30
|
-
return error.detail;
|
|
31
|
-
}
|
|
32
|
-
return error instanceof Error ? error.message : String(error);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const CACHE_SCHEMA_VERSION = 10;
|
|
36
|
-
function resolveTransformCacheDir(rootDir, cacheDir) {
|
|
37
|
-
return path__namespace.resolve(rootDir, cacheDir ?? ".csszyx/cache", "transform");
|
|
38
|
-
}
|
|
39
|
-
function createTransformCacheKey(input) {
|
|
40
|
-
const inputSha256 = node_crypto.createHash("sha256").update(input.source).digest("hex");
|
|
41
|
-
const globalVarAliases = normalizeGlobalVarAliasEntries(input.globalVarAliases);
|
|
42
|
-
const keyMaterial = [
|
|
43
|
-
`schema=${CACHE_SCHEMA_VERSION}`,
|
|
44
|
-
`plugin=${input.pluginVersion}`,
|
|
45
|
-
`compiler=${input.compilerVersion}`,
|
|
46
|
-
`native=${input.nativeIdentity ?? "none"}`,
|
|
47
|
-
`parser=${input.parserMode}`,
|
|
48
|
-
`producer=${input.producer}`,
|
|
49
|
-
`astBudget=${input.astBudget ?? "default"}`,
|
|
50
|
-
`mangleVars=${input.mangleVars === true}`,
|
|
51
|
-
`mangleVarHoistMaxDepth=${input.mangleVarHoistMaxDepth ?? "default"}`,
|
|
52
|
-
`globalVarAliases=${JSON.stringify(globalVarAliases)}`,
|
|
53
|
-
`filename=${input.filename}`,
|
|
54
|
-
`source=${inputSha256}`
|
|
55
|
-
].join("\n");
|
|
56
|
-
return {
|
|
57
|
-
key: node_crypto.createHash("sha256").update(keyMaterial).digest("hex").slice(0, 16),
|
|
58
|
-
inputSha256
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
function readTransformCache(cacheRoot, input, precomputedKey) {
|
|
62
|
-
const { key, inputSha256 } = precomputedKey ?? createTransformCacheKey(input);
|
|
63
|
-
const globalVarAliases = normalizeGlobalVarAliasEntries(input.globalVarAliases);
|
|
64
|
-
const file = cacheEntryPath(cacheRoot, key);
|
|
65
|
-
let entry;
|
|
66
|
-
try {
|
|
67
|
-
entry = JSON.parse(fs__namespace.readFileSync(file, "utf8"));
|
|
68
|
-
} catch {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
if (entry.version !== CACHE_SCHEMA_VERSION || entry.pluginVersion !== input.pluginVersion || entry.compilerVersion !== input.compilerVersion || entry.nativeIdentity !== (input.nativeIdentity ?? null) || entry.parserMode !== input.parserMode || entry.producer !== input.producer || entry.astBudget !== (input.astBudget ?? null) || entry.mangleVars !== (input.mangleVars === true) || entry.mangleVarHoistMaxDepth !== (input.mangleVarHoistMaxDepth ?? null) || !sameGlobalVarAliases(entry.globalVarAliases, globalVarAliases) || entry.filename !== input.filename || entry.inputSha256 !== inputSha256) {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
return deserializeResult(entry.result);
|
|
75
|
-
}
|
|
76
|
-
function writeTransformCache(cacheRoot, input, result, precomputedKey) {
|
|
77
|
-
const { key, inputSha256 } = precomputedKey ?? createTransformCacheKey(input);
|
|
78
|
-
const globalVarAliases = normalizeGlobalVarAliasEntries(input.globalVarAliases);
|
|
79
|
-
const file = cacheEntryPath(cacheRoot, key);
|
|
80
|
-
const dir = path__namespace.dirname(file);
|
|
81
|
-
const tmp = path__namespace.join(dir, `.tmp-${process.pid}-${Date.now()}-${node_crypto.randomUUID()}.json`);
|
|
82
|
-
const entry = {
|
|
83
|
-
version: CACHE_SCHEMA_VERSION,
|
|
84
|
-
pluginVersion: input.pluginVersion,
|
|
85
|
-
compilerVersion: input.compilerVersion,
|
|
86
|
-
nativeIdentity: input.nativeIdentity ?? null,
|
|
87
|
-
parserMode: input.parserMode,
|
|
88
|
-
producer: input.producer,
|
|
89
|
-
astBudget: input.astBudget ?? null,
|
|
90
|
-
mangleVars: input.mangleVars === true,
|
|
91
|
-
mangleVarHoistMaxDepth: input.mangleVarHoistMaxDepth ?? null,
|
|
92
|
-
globalVarAliases,
|
|
93
|
-
filename: input.filename,
|
|
94
|
-
inputSha256,
|
|
95
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
96
|
-
result: serializeResult(result)
|
|
97
|
-
};
|
|
98
|
-
try {
|
|
99
|
-
fs__namespace.mkdirSync(dir, { recursive: true });
|
|
100
|
-
fs__namespace.writeFileSync(tmp, JSON.stringify(entry), "utf8");
|
|
101
|
-
fs__namespace.renameSync(tmp, file);
|
|
102
|
-
} catch {
|
|
103
|
-
try {
|
|
104
|
-
fs__namespace.rmSync(tmp, { force: true });
|
|
105
|
-
} catch {
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
function evictOldTransformCacheEntries(cacheRoot, options) {
|
|
110
|
-
let deleted = 0;
|
|
111
|
-
const now = options.now ?? Date.now();
|
|
112
|
-
const survivors = [];
|
|
113
|
-
for (const file of listJsonFiles(cacheRoot)) {
|
|
114
|
-
try {
|
|
115
|
-
const entry = JSON.parse(fs__namespace.readFileSync(file, "utf8"));
|
|
116
|
-
const timestamp = typeof entry.timestamp === "string" ? Date.parse(entry.timestamp) : 0;
|
|
117
|
-
if (!Number.isFinite(timestamp) || now - timestamp > options.maxAgeMs) {
|
|
118
|
-
fs__namespace.rmSync(file, { force: true });
|
|
119
|
-
deleted++;
|
|
120
|
-
} else {
|
|
121
|
-
survivors.push({ file, timestamp });
|
|
122
|
-
}
|
|
123
|
-
} catch {
|
|
124
|
-
fs__namespace.rmSync(file, { force: true });
|
|
125
|
-
deleted++;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
const overflow = survivors.length - options.maxEntries ;
|
|
129
|
-
if (overflow > 0) {
|
|
130
|
-
survivors.sort((a, b) => a.timestamp - b.timestamp);
|
|
131
|
-
for (const survivor of survivors.slice(0, overflow)) {
|
|
132
|
-
fs__namespace.rmSync(survivor.file, { force: true });
|
|
133
|
-
deleted++;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return deleted;
|
|
137
|
-
}
|
|
138
|
-
function cacheEntryPath(cacheRoot, key) {
|
|
139
|
-
return path__namespace.join(cacheRoot, key.slice(0, 2), `${key.slice(2)}.json`);
|
|
140
|
-
}
|
|
141
|
-
function serializeResult(result) {
|
|
142
|
-
return {
|
|
143
|
-
code: result.code,
|
|
144
|
-
transformed: result.transformed,
|
|
145
|
-
usesRuntime: result.usesRuntime,
|
|
146
|
-
usesMerge: result.usesMerge,
|
|
147
|
-
usesSzcn: result.usesSzcn,
|
|
148
|
-
usesSzPart: result.usesSzPart,
|
|
149
|
-
usesColorVar: result.usesColorVar,
|
|
150
|
-
usesSpacingVar: result.usesSpacingVar,
|
|
151
|
-
usesUnitVar: result.usesUnitVar,
|
|
152
|
-
classes: [...result.classes],
|
|
153
|
-
rawClassNames: [...result.rawClassNames],
|
|
154
|
-
diagnostics: [...result.diagnostics],
|
|
155
|
-
recoveryTokens: [...result.recoveryTokens],
|
|
156
|
-
cssVariableMap: [...result.cssVariableMap ?? /* @__PURE__ */ new Map()]
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
function deserializeResult(result) {
|
|
160
|
-
return {
|
|
161
|
-
code: result.code,
|
|
162
|
-
transformed: result.transformed,
|
|
163
|
-
usesRuntime: result.usesRuntime,
|
|
164
|
-
usesMerge: result.usesMerge,
|
|
165
|
-
usesSzcn: result.usesSzcn,
|
|
166
|
-
usesSzPart: result.usesSzPart,
|
|
167
|
-
usesColorVar: result.usesColorVar,
|
|
168
|
-
usesSpacingVar: result.usesSpacingVar,
|
|
169
|
-
usesUnitVar: result.usesUnitVar,
|
|
170
|
-
classes: new Set(result.classes),
|
|
171
|
-
rawClassNames: new Set(result.rawClassNames),
|
|
172
|
-
diagnostics: [...result.diagnostics],
|
|
173
|
-
recoveryTokens: new Map(result.recoveryTokens),
|
|
174
|
-
cssVariableMap: new Map(result.cssVariableMap ?? [])
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
function normalizeGlobalVarAliasEntries(aliases) {
|
|
178
|
-
if (!aliases || aliases.length === 0) {
|
|
179
|
-
return [];
|
|
180
|
-
}
|
|
181
|
-
const normalized = /* @__PURE__ */ new Map();
|
|
182
|
-
for (const [original, alias] of aliases) {
|
|
183
|
-
if (typeof original === "string" && typeof alias === "string") {
|
|
184
|
-
normalized.set(original, alias);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
return [...normalized].sort(([left], [right]) => left.localeCompare(right));
|
|
188
|
-
}
|
|
189
|
-
function sameGlobalVarAliases(left, right) {
|
|
190
|
-
if (!Array.isArray(left) || left.length !== right.length) {
|
|
191
|
-
return false;
|
|
192
|
-
}
|
|
193
|
-
for (let index = 0; index < left.length; index++) {
|
|
194
|
-
const leftEntry = left[index];
|
|
195
|
-
const rightEntry = right[index];
|
|
196
|
-
if (leftEntry?.[0] !== rightEntry?.[0] || leftEntry?.[1] !== rightEntry?.[1]) {
|
|
197
|
-
return false;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
return true;
|
|
201
|
-
}
|
|
202
|
-
function listJsonFiles(dir) {
|
|
203
|
-
let entries;
|
|
204
|
-
try {
|
|
205
|
-
entries = fs__namespace.readdirSync(dir, { withFileTypes: true });
|
|
206
|
-
} catch {
|
|
207
|
-
return [];
|
|
208
|
-
}
|
|
209
|
-
const files = [];
|
|
210
|
-
for (const entry of entries) {
|
|
211
|
-
const fullPath = path__namespace.join(dir, entry.name);
|
|
212
|
-
if (entry.isDirectory()) {
|
|
213
|
-
files.push(...listJsonFiles(fullPath));
|
|
214
|
-
} else if (entry.isFile() && entry.name.endsWith(".json")) {
|
|
215
|
-
files.push(fullPath);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
return files;
|
|
219
|
-
}
|
|
220
|
-
function evictMemoryCacheToBudget(cache, totalCodeChars, maxEntries, maxCodeChars) {
|
|
221
|
-
let total = totalCodeChars;
|
|
222
|
-
while (cache.size > maxEntries || total > maxCodeChars && cache.size > 1) {
|
|
223
|
-
const oldest = cache.keys().next().value;
|
|
224
|
-
if (oldest === void 0) {
|
|
225
|
-
break;
|
|
226
|
-
}
|
|
227
|
-
const evicted = cache.get(oldest);
|
|
228
|
-
cache.delete(oldest);
|
|
229
|
-
total -= evicted?.code.length ?? 0;
|
|
230
|
-
}
|
|
231
|
-
return total;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
exports.babelFallbackReason = babelFallbackReason;
|
|
235
|
-
exports.createTransformCacheKey = createTransformCacheKey;
|
|
236
|
-
exports.evictMemoryCacheToBudget = evictMemoryCacheToBudget;
|
|
237
|
-
exports.evictOldTransformCacheEntries = evictOldTransformCacheEntries;
|
|
238
|
-
exports.normalizePathSeparators = normalizePathSeparators;
|
|
239
|
-
exports.readTransformCache = readTransformCache;
|
|
240
|
-
exports.resolveTransformCacheDir = resolveTransformCacheDir;
|
|
241
|
-
exports.writeTransformCache = writeTransformCache;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const LEADING_WHITESPACE_RE = /^\s+/;
|
|
4
|
-
const LINE_COMMENT_RE = /^\/\/[^\n]*(?:\n|$)/;
|
|
5
|
-
const BLOCK_COMMENT_RE = /^\/\*[\s\S]*?\*\//;
|
|
6
|
-
const USE_DIRECTIVE_RE = /^['"]use (?:client|server)['"];?\s*/;
|
|
7
|
-
function insertAfterUseDirective(code, insertion) {
|
|
8
|
-
let offset = 0;
|
|
9
|
-
while (offset < code.length) {
|
|
10
|
-
const triviaLength = leadingTriviaLength(code.slice(offset));
|
|
11
|
-
if (triviaLength === 0) break;
|
|
12
|
-
offset += triviaLength;
|
|
13
|
-
}
|
|
14
|
-
const directive = USE_DIRECTIVE_RE.exec(code.slice(offset));
|
|
15
|
-
if (!directive) return `${insertion}${code}`;
|
|
16
|
-
const insertionOffset = offset + directive[0].length;
|
|
17
|
-
return `${code.slice(0, insertionOffset)}${insertion}${code.slice(insertionOffset)}`;
|
|
18
|
-
}
|
|
19
|
-
function leadingTriviaLength(source) {
|
|
20
|
-
return LEADING_WHITESPACE_RE.exec(source)?.[0].length ?? LINE_COMMENT_RE.exec(source)?.[0].length ?? BLOCK_COMMENT_RE.exec(source)?.[0].length ?? 0;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const RUNTIME_IMPORT_CLAUSE_RE = /(?:import|export)\s+\{([^{}]*)\}\s*from\s*['"]@csszyx\/runtime['"]/g;
|
|
24
|
-
function clauseNames(clauseBody) {
|
|
25
|
-
const names = [];
|
|
26
|
-
for (const part of clauseBody.split(",")) {
|
|
27
|
-
const trimmed = part.trim();
|
|
28
|
-
if (!trimmed) {
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
const spaceAt = trimmed.search(/\s/);
|
|
32
|
-
names.push(spaceAt === -1 ? trimmed : trimmed.slice(0, spaceAt));
|
|
33
|
-
}
|
|
34
|
-
return names;
|
|
35
|
-
}
|
|
36
|
-
function importsRuntimeHelper(code, helper) {
|
|
37
|
-
RUNTIME_IMPORT_CLAUSE_RE.lastIndex = 0;
|
|
38
|
-
for (let match = RUNTIME_IMPORT_CLAUSE_RE.exec(code); match; match = RUNTIME_IMPORT_CLAUSE_RE.exec(code)) {
|
|
39
|
-
if (clauseNames(match[1]).includes(helper)) {
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
const RUNTIME_IMPORT_APPEND_RE = /(import\s+\{[^{}]*)\}\s*from\s*['"]@csszyx\/runtime['"]/;
|
|
46
|
-
function findRuntimeImportClause(code) {
|
|
47
|
-
const match = RUNTIME_IMPORT_APPEND_RE.exec(code);
|
|
48
|
-
return match ? { statement: match[0], prefixWithBody: match[1] } : null;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
exports.findRuntimeImportClause = findRuntimeImportClause;
|
|
52
|
-
exports.importsRuntimeHelper = importsRuntimeHelper;
|
|
53
|
-
exports.insertAfterUseDirective = insertAfterUseDirective;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
const LEADING_WHITESPACE_RE = /^\s+/;
|
|
2
|
-
const LINE_COMMENT_RE = /^\/\/[^\n]*(?:\n|$)/;
|
|
3
|
-
const BLOCK_COMMENT_RE = /^\/\*[\s\S]*?\*\//;
|
|
4
|
-
const USE_DIRECTIVE_RE = /^['"]use (?:client|server)['"];?\s*/;
|
|
5
|
-
function insertAfterUseDirective(code, insertion) {
|
|
6
|
-
let offset = 0;
|
|
7
|
-
while (offset < code.length) {
|
|
8
|
-
const triviaLength = leadingTriviaLength(code.slice(offset));
|
|
9
|
-
if (triviaLength === 0) break;
|
|
10
|
-
offset += triviaLength;
|
|
11
|
-
}
|
|
12
|
-
const directive = USE_DIRECTIVE_RE.exec(code.slice(offset));
|
|
13
|
-
if (!directive) return `${insertion}${code}`;
|
|
14
|
-
const insertionOffset = offset + directive[0].length;
|
|
15
|
-
return `${code.slice(0, insertionOffset)}${insertion}${code.slice(insertionOffset)}`;
|
|
16
|
-
}
|
|
17
|
-
function leadingTriviaLength(source) {
|
|
18
|
-
return LEADING_WHITESPACE_RE.exec(source)?.[0].length ?? LINE_COMMENT_RE.exec(source)?.[0].length ?? BLOCK_COMMENT_RE.exec(source)?.[0].length ?? 0;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const RUNTIME_IMPORT_CLAUSE_RE = /(?:import|export)\s+\{([^{}]*)\}\s*from\s*['"]@csszyx\/runtime['"]/g;
|
|
22
|
-
function clauseNames(clauseBody) {
|
|
23
|
-
const names = [];
|
|
24
|
-
for (const part of clauseBody.split(",")) {
|
|
25
|
-
const trimmed = part.trim();
|
|
26
|
-
if (!trimmed) {
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
const spaceAt = trimmed.search(/\s/);
|
|
30
|
-
names.push(spaceAt === -1 ? trimmed : trimmed.slice(0, spaceAt));
|
|
31
|
-
}
|
|
32
|
-
return names;
|
|
33
|
-
}
|
|
34
|
-
function importsRuntimeHelper(code, helper) {
|
|
35
|
-
RUNTIME_IMPORT_CLAUSE_RE.lastIndex = 0;
|
|
36
|
-
for (let match = RUNTIME_IMPORT_CLAUSE_RE.exec(code); match; match = RUNTIME_IMPORT_CLAUSE_RE.exec(code)) {
|
|
37
|
-
if (clauseNames(match[1]).includes(helper)) {
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
const RUNTIME_IMPORT_APPEND_RE = /(import\s+\{[^{}]*)\}\s*from\s*['"]@csszyx\/runtime['"]/;
|
|
44
|
-
function findRuntimeImportClause(code) {
|
|
45
|
-
const match = RUNTIME_IMPORT_APPEND_RE.exec(code);
|
|
46
|
-
return match ? { statement: match[0], prefixWithBody: match[1] } : null;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export { insertAfterUseDirective as a, findRuntimeImportClause as f, importsRuntimeHelper as i };
|