@plumeria/compiler 0.14.9 → 0.15.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.
- package/dist/extract.js +24 -2
- package/package.json +10 -13
package/dist/extract.js
CHANGED
|
@@ -144,6 +144,21 @@ function extractCssProps(code) {
|
|
|
144
144
|
}
|
|
145
145
|
return propsMatches;
|
|
146
146
|
}
|
|
147
|
+
function extractStaticStringLiteralVariable(code) {
|
|
148
|
+
const matches = [];
|
|
149
|
+
const regex = /\b(?:var|let|const)\s+[a-zA-Z_$][\w$]*\s*=\s*(['"])(.*?)\1\s*;?/gm;
|
|
150
|
+
let match;
|
|
151
|
+
while ((match = regex.exec(code))) {
|
|
152
|
+
const index = match.index;
|
|
153
|
+
if (isInComment(code, index) ||
|
|
154
|
+
isInString(code, index) ||
|
|
155
|
+
isInHtmlText(code, index)) {
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
matches.push(match[0]);
|
|
159
|
+
}
|
|
160
|
+
return matches.join('\n');
|
|
161
|
+
}
|
|
147
162
|
function extractCssCreate(code) {
|
|
148
163
|
const cssCreateMatches = [];
|
|
149
164
|
const regex = /(?:(?:\s*const\s+[a-zA-Z0-9_$]+\s*=\s*css\.create\([\s\S]*?\);\s*))/g;
|
|
@@ -226,12 +241,16 @@ async function extractVueAndSvelte(filePath) {
|
|
|
226
241
|
const importRegex = /^(\s*import\s[^;]+;\s*)+/m;
|
|
227
242
|
const importMatch = tsCode.match(importRegex);
|
|
228
243
|
const importSection = importMatch ? importMatch[0] : '';
|
|
229
|
-
const
|
|
230
|
-
const
|
|
244
|
+
const staticVariableSection = extractStaticStringLiteralVariable(tsCode);
|
|
245
|
+
const cssCreateSection = extractCssCreate(tsCode);
|
|
246
|
+
const cssGlobalSection = extractCssGlobal(tsCode);
|
|
231
247
|
let finalCode = '';
|
|
232
248
|
if (importSection) {
|
|
233
249
|
finalCode += importSection + '\n';
|
|
234
250
|
}
|
|
251
|
+
if (staticVariableSection) {
|
|
252
|
+
finalCode += staticVariableSection + '\n';
|
|
253
|
+
}
|
|
235
254
|
if (cssGlobalSection) {
|
|
236
255
|
finalCode += cssGlobalSection + '\n';
|
|
237
256
|
}
|
|
@@ -251,6 +270,7 @@ async function extractTSFile(filePath) {
|
|
|
251
270
|
const importRegex = /^(?:\s*import\s[^;]+;\s*)+/m;
|
|
252
271
|
const importMatch = code.match(importRegex);
|
|
253
272
|
const importSection = importMatch ? importMatch[0] : '';
|
|
273
|
+
const staticVariableSection = extractStaticStringLiteralVariable(code);
|
|
254
274
|
const cssCreateSection = extractCssCreate(code);
|
|
255
275
|
const cssGlobalSection = extractCssGlobal(code);
|
|
256
276
|
const propsMatches = extractCssProps(code);
|
|
@@ -261,6 +281,8 @@ async function extractTSFile(filePath) {
|
|
|
261
281
|
let finalCode = '';
|
|
262
282
|
if (importSection)
|
|
263
283
|
finalCode += importSection + '\n';
|
|
284
|
+
if (staticVariableSection)
|
|
285
|
+
finalCode += staticVariableSection + '\n';
|
|
264
286
|
if (cssGlobalSection)
|
|
265
287
|
finalCode += cssGlobalSection + '\n';
|
|
266
288
|
if (cssCreateSection)
|
package/package.json
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/compiler",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
"compiler"
|
|
11
|
-
],
|
|
12
|
-
"repository": "github:zss-in-js/plumeria",
|
|
3
|
+
"version": "0.15.1",
|
|
4
|
+
"description": "Plumeria Rust-based compiler",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/zss-in-js/plumeria.git",
|
|
8
|
+
"directory": "packages/compiler"
|
|
9
|
+
},
|
|
13
10
|
"license": "MIT",
|
|
14
11
|
"files": [
|
|
15
12
|
"bin/",
|
|
@@ -19,13 +16,13 @@
|
|
|
19
16
|
"css": "./bin/css.js"
|
|
20
17
|
},
|
|
21
18
|
"dependencies": {
|
|
22
|
-
"@rust-gear/glob": "^0.2.2",
|
|
23
19
|
"@swc/core": "^1.11.24",
|
|
20
|
+
"@rust-gear/glob": "^0.2.2",
|
|
21
|
+
"rscute": "^0.2.7",
|
|
24
22
|
"lightningcss": "^1.29.3",
|
|
25
23
|
"postcss": "^8.5.3",
|
|
26
24
|
"postcss-combine-duplicated-selectors": "^10.0.3",
|
|
27
|
-
"postcss-combine-media-query": "^2.0.0"
|
|
28
|
-
"rscute": "^0.2.7"
|
|
25
|
+
"postcss-combine-media-query": "^2.0.0"
|
|
29
26
|
},
|
|
30
27
|
"publishConfig": {
|
|
31
28
|
"access": "public"
|