@csszyx/vue-adapter 0.11.7 → 0.11.8
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/index.cjs +3 -71
- package/dist/index.d.cts +4 -6
- package/dist/index.d.mts +4 -6
- package/dist/index.d.ts +4 -6
- package/dist/index.js +3 -71
- package/dist/index.mjs +4 -71
- package/package.json +2 -3
package/dist/index.cjs
CHANGED
|
@@ -11,76 +11,8 @@ exports.preprocess = preprocess;
|
|
|
11
11
|
exports.transformTemplate = transformTemplate;
|
|
12
12
|
exports.vitePlugin = vitePlugin;
|
|
13
13
|
var _compiler = require("@csszyx/compiler");
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
switch (node.type) {
|
|
17
|
-
case "Literal":
|
|
18
|
-
return node.value;
|
|
19
|
-
case "UnaryExpression":
|
|
20
|
-
if (node.operator === "-" && node.argument.type === "Literal" && typeof node.argument.value === "number") {
|
|
21
|
-
return -node.argument.value;
|
|
22
|
-
}
|
|
23
|
-
return void 0;
|
|
24
|
-
case "ArrayExpression":
|
|
25
|
-
{
|
|
26
|
-
const arr = [];
|
|
27
|
-
for (const el of node.elements ?? []) {
|
|
28
|
-
if (!el) {
|
|
29
|
-
arr.push(null);
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
const v = extractValue(el);
|
|
33
|
-
if (v === void 0) return void 0;
|
|
34
|
-
arr.push(v);
|
|
35
|
-
}
|
|
36
|
-
return arr;
|
|
37
|
-
}
|
|
38
|
-
case "ObjectExpression":
|
|
39
|
-
return extractObjectNode(node);
|
|
40
|
-
case "TemplateLiteral":
|
|
41
|
-
if ((node.expressions ?? []).length === 0) {
|
|
42
|
-
const quasis = node.quasis;
|
|
43
|
-
return quasis[0].value.cooked ?? void 0;
|
|
44
|
-
}
|
|
45
|
-
return void 0;
|
|
46
|
-
default:
|
|
47
|
-
return void 0;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function extractObjectNode(node) {
|
|
51
|
-
const obj = {};
|
|
52
|
-
for (const prop of node.properties ?? []) {
|
|
53
|
-
if (prop.type !== "Property") return void 0;
|
|
54
|
-
if (prop.computed) return void 0;
|
|
55
|
-
const key_node = prop.key;
|
|
56
|
-
let key;
|
|
57
|
-
if (key_node.type === "Identifier") {
|
|
58
|
-
key = key_node.name;
|
|
59
|
-
} else if (key_node.type === "Literal" && typeof key_node.value === "string") {
|
|
60
|
-
key = key_node.value;
|
|
61
|
-
} else if (key_node.type === "Literal" && typeof key_node.value === "number") {
|
|
62
|
-
key = String(key_node.value);
|
|
63
|
-
} else {
|
|
64
|
-
return void 0;
|
|
65
|
-
}
|
|
66
|
-
const value = extractValue(prop.value);
|
|
67
|
-
if (value === void 0) return void 0;
|
|
68
|
-
obj[key] = value;
|
|
69
|
-
}
|
|
70
|
-
return obj;
|
|
71
|
-
}
|
|
72
|
-
function parseObjectLiteral(objStr) {
|
|
73
|
-
try {
|
|
74
|
-
const src = `const _=${objStr.trim()}`;
|
|
75
|
-
const parsed = (0, _oxcParser.parseSync)("sz.js", src);
|
|
76
|
-
if (parsed.errors.length > 0) return null;
|
|
77
|
-
const decl = parsed.program.body;
|
|
78
|
-
const init = decl[0].declarations[0].init ?? null;
|
|
79
|
-
if (!init || init.type !== "ObjectExpression") return null;
|
|
80
|
-
return extractObjectNode(init) ?? null;
|
|
81
|
-
} catch {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
14
|
+
function parseObjectLiteral(source) {
|
|
15
|
+
return (0, _compiler.parseStaticObjectLiteral)(source);
|
|
84
16
|
}
|
|
85
17
|
function extractTemplate(source) {
|
|
86
18
|
const lowered = source.toLowerCase();
|
|
@@ -254,7 +186,7 @@ function vitePlugin(options = {}) {
|
|
|
254
186
|
return {
|
|
255
187
|
code: result.code,
|
|
256
188
|
map: null
|
|
257
|
-
//
|
|
189
|
+
// Source-map generation is not implemented yet.
|
|
258
190
|
};
|
|
259
191
|
}
|
|
260
192
|
};
|
package/dist/index.d.cts
CHANGED
|
@@ -33,13 +33,11 @@ export interface PreprocessResult {
|
|
|
33
33
|
count: number;
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
|
-
* Parse a JavaScript object literal
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* @param {string} objStr - Object literal string (e.g., "{ p: 4, bg: 'red-500' }")
|
|
40
|
-
* @returns {SzObject | null} Parsed object or null if invalid
|
|
36
|
+
* Parse a recursively static JavaScript object literal.
|
|
37
|
+
* @param source - Object literal source.
|
|
38
|
+
* @returns Parsed sz object, or null for dynamic/invalid syntax.
|
|
41
39
|
*/
|
|
42
|
-
export declare function parseObjectLiteral(
|
|
40
|
+
export declare function parseObjectLiteral(source: string): SzObject | null;
|
|
43
41
|
/**
|
|
44
42
|
* Extract the template section from a Vue SFC.
|
|
45
43
|
*
|
package/dist/index.d.mts
CHANGED
|
@@ -33,13 +33,11 @@ export interface PreprocessResult {
|
|
|
33
33
|
count: number;
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
|
-
* Parse a JavaScript object literal
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* @param {string} objStr - Object literal string (e.g., "{ p: 4, bg: 'red-500' }")
|
|
40
|
-
* @returns {SzObject | null} Parsed object or null if invalid
|
|
36
|
+
* Parse a recursively static JavaScript object literal.
|
|
37
|
+
* @param source - Object literal source.
|
|
38
|
+
* @returns Parsed sz object, or null for dynamic/invalid syntax.
|
|
41
39
|
*/
|
|
42
|
-
export declare function parseObjectLiteral(
|
|
40
|
+
export declare function parseObjectLiteral(source: string): SzObject | null;
|
|
43
41
|
/**
|
|
44
42
|
* Extract the template section from a Vue SFC.
|
|
45
43
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -33,13 +33,11 @@ export interface PreprocessResult {
|
|
|
33
33
|
count: number;
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
|
-
* Parse a JavaScript object literal
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* @param {string} objStr - Object literal string (e.g., "{ p: 4, bg: 'red-500' }")
|
|
40
|
-
* @returns {SzObject | null} Parsed object or null if invalid
|
|
36
|
+
* Parse a recursively static JavaScript object literal.
|
|
37
|
+
* @param source - Object literal source.
|
|
38
|
+
* @returns Parsed sz object, or null for dynamic/invalid syntax.
|
|
41
39
|
*/
|
|
42
|
-
export declare function parseObjectLiteral(
|
|
40
|
+
export declare function parseObjectLiteral(source: string): SzObject | null;
|
|
43
41
|
/**
|
|
44
42
|
* Extract the template section from a Vue SFC.
|
|
45
43
|
*
|
package/dist/index.js
CHANGED
|
@@ -11,76 +11,8 @@ exports.preprocess = preprocess;
|
|
|
11
11
|
exports.transformTemplate = transformTemplate;
|
|
12
12
|
exports.vitePlugin = vitePlugin;
|
|
13
13
|
var _compiler = require("@csszyx/compiler");
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
switch (node.type) {
|
|
17
|
-
case "Literal":
|
|
18
|
-
return node.value;
|
|
19
|
-
case "UnaryExpression":
|
|
20
|
-
if (node.operator === "-" && node.argument.type === "Literal" && typeof node.argument.value === "number") {
|
|
21
|
-
return -node.argument.value;
|
|
22
|
-
}
|
|
23
|
-
return void 0;
|
|
24
|
-
case "ArrayExpression":
|
|
25
|
-
{
|
|
26
|
-
const arr = [];
|
|
27
|
-
for (const el of node.elements ?? []) {
|
|
28
|
-
if (!el) {
|
|
29
|
-
arr.push(null);
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
const v = extractValue(el);
|
|
33
|
-
if (v === void 0) return void 0;
|
|
34
|
-
arr.push(v);
|
|
35
|
-
}
|
|
36
|
-
return arr;
|
|
37
|
-
}
|
|
38
|
-
case "ObjectExpression":
|
|
39
|
-
return extractObjectNode(node);
|
|
40
|
-
case "TemplateLiteral":
|
|
41
|
-
if ((node.expressions ?? []).length === 0) {
|
|
42
|
-
const quasis = node.quasis;
|
|
43
|
-
return quasis[0].value.cooked ?? void 0;
|
|
44
|
-
}
|
|
45
|
-
return void 0;
|
|
46
|
-
default:
|
|
47
|
-
return void 0;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function extractObjectNode(node) {
|
|
51
|
-
const obj = {};
|
|
52
|
-
for (const prop of node.properties ?? []) {
|
|
53
|
-
if (prop.type !== "Property") return void 0;
|
|
54
|
-
if (prop.computed) return void 0;
|
|
55
|
-
const key_node = prop.key;
|
|
56
|
-
let key;
|
|
57
|
-
if (key_node.type === "Identifier") {
|
|
58
|
-
key = key_node.name;
|
|
59
|
-
} else if (key_node.type === "Literal" && typeof key_node.value === "string") {
|
|
60
|
-
key = key_node.value;
|
|
61
|
-
} else if (key_node.type === "Literal" && typeof key_node.value === "number") {
|
|
62
|
-
key = String(key_node.value);
|
|
63
|
-
} else {
|
|
64
|
-
return void 0;
|
|
65
|
-
}
|
|
66
|
-
const value = extractValue(prop.value);
|
|
67
|
-
if (value === void 0) return void 0;
|
|
68
|
-
obj[key] = value;
|
|
69
|
-
}
|
|
70
|
-
return obj;
|
|
71
|
-
}
|
|
72
|
-
function parseObjectLiteral(objStr) {
|
|
73
|
-
try {
|
|
74
|
-
const src = `const _=${objStr.trim()}`;
|
|
75
|
-
const parsed = (0, _oxcParser.parseSync)("sz.js", src);
|
|
76
|
-
if (parsed.errors.length > 0) return null;
|
|
77
|
-
const decl = parsed.program.body;
|
|
78
|
-
const init = decl[0].declarations[0].init ?? null;
|
|
79
|
-
if (!init || init.type !== "ObjectExpression") return null;
|
|
80
|
-
return extractObjectNode(init) ?? null;
|
|
81
|
-
} catch {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
14
|
+
function parseObjectLiteral(source) {
|
|
15
|
+
return (0, _compiler.parseStaticObjectLiteral)(source);
|
|
84
16
|
}
|
|
85
17
|
function extractTemplate(source) {
|
|
86
18
|
const lowered = source.toLowerCase();
|
|
@@ -254,7 +186,7 @@ function vitePlugin(options = {}) {
|
|
|
254
186
|
return {
|
|
255
187
|
code: result.code,
|
|
256
188
|
map: null
|
|
257
|
-
//
|
|
189
|
+
// Source-map generation is not implemented yet.
|
|
258
190
|
};
|
|
259
191
|
}
|
|
260
192
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -1,73 +1,6 @@
|
|
|
1
|
-
import { transform } from "@csszyx/compiler";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
switch (node.type) {
|
|
5
|
-
case "Literal":
|
|
6
|
-
return node.value;
|
|
7
|
-
case "UnaryExpression":
|
|
8
|
-
if (node.operator === "-" && node.argument.type === "Literal" && typeof node.argument.value === "number") {
|
|
9
|
-
return -node.argument.value;
|
|
10
|
-
}
|
|
11
|
-
return void 0;
|
|
12
|
-
case "ArrayExpression": {
|
|
13
|
-
const arr = [];
|
|
14
|
-
for (const el of node.elements ?? []) {
|
|
15
|
-
if (!el) {
|
|
16
|
-
arr.push(null);
|
|
17
|
-
continue;
|
|
18
|
-
}
|
|
19
|
-
const v = extractValue(el);
|
|
20
|
-
if (v === void 0) return void 0;
|
|
21
|
-
arr.push(v);
|
|
22
|
-
}
|
|
23
|
-
return arr;
|
|
24
|
-
}
|
|
25
|
-
case "ObjectExpression":
|
|
26
|
-
return extractObjectNode(node);
|
|
27
|
-
case "TemplateLiteral":
|
|
28
|
-
if ((node.expressions ?? []).length === 0) {
|
|
29
|
-
const quasis = node.quasis;
|
|
30
|
-
return quasis[0].value.cooked ?? void 0;
|
|
31
|
-
}
|
|
32
|
-
return void 0;
|
|
33
|
-
default:
|
|
34
|
-
return void 0;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
function extractObjectNode(node) {
|
|
38
|
-
const obj = {};
|
|
39
|
-
for (const prop of node.properties ?? []) {
|
|
40
|
-
if (prop.type !== "Property") return void 0;
|
|
41
|
-
if (prop.computed) return void 0;
|
|
42
|
-
const key_node = prop.key;
|
|
43
|
-
let key;
|
|
44
|
-
if (key_node.type === "Identifier") {
|
|
45
|
-
key = key_node.name;
|
|
46
|
-
} else if (key_node.type === "Literal" && typeof key_node.value === "string") {
|
|
47
|
-
key = key_node.value;
|
|
48
|
-
} else if (key_node.type === "Literal" && typeof key_node.value === "number") {
|
|
49
|
-
key = String(key_node.value);
|
|
50
|
-
} else {
|
|
51
|
-
return void 0;
|
|
52
|
-
}
|
|
53
|
-
const value = extractValue(prop.value);
|
|
54
|
-
if (value === void 0) return void 0;
|
|
55
|
-
obj[key] = value;
|
|
56
|
-
}
|
|
57
|
-
return obj;
|
|
58
|
-
}
|
|
59
|
-
export function parseObjectLiteral(objStr) {
|
|
60
|
-
try {
|
|
61
|
-
const src = `const _=${objStr.trim()}`;
|
|
62
|
-
const parsed = parseSync("sz.js", src);
|
|
63
|
-
if (parsed.errors.length > 0) return null;
|
|
64
|
-
const decl = parsed.program.body;
|
|
65
|
-
const init = decl[0].declarations[0].init ?? null;
|
|
66
|
-
if (!init || init.type !== "ObjectExpression") return null;
|
|
67
|
-
return extractObjectNode(init) ?? null;
|
|
68
|
-
} catch {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
1
|
+
import { parseStaticObjectLiteral, transform } from "@csszyx/compiler";
|
|
2
|
+
export function parseObjectLiteral(source) {
|
|
3
|
+
return parseStaticObjectLiteral(source);
|
|
71
4
|
}
|
|
72
5
|
export function extractTemplate(source) {
|
|
73
6
|
const lowered = source.toLowerCase();
|
|
@@ -235,7 +168,7 @@ export function vitePlugin(options = {}) {
|
|
|
235
168
|
return {
|
|
236
169
|
code: result.code,
|
|
237
170
|
map: null
|
|
238
|
-
//
|
|
171
|
+
// Source-map generation is not implemented yet.
|
|
239
172
|
};
|
|
240
173
|
}
|
|
241
174
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@csszyx/vue-adapter",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.8",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Vue SFC preprocessor for csszyx - transform sz props to className",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,8 +24,7 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"
|
|
28
|
-
"@csszyx/compiler": "0.11.7"
|
|
27
|
+
"@csszyx/compiler": "0.11.8"
|
|
29
28
|
},
|
|
30
29
|
"peerDependencies": {
|
|
31
30
|
"vue": "^3.0.0"
|