@plumeria/vite-plugin 1.0.4 → 2.0.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/dist/index.js +13 -12
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { createFilter } from 'vite';
|
|
|
2
2
|
import { parseSync } from '@swc/core';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { transpile } from 'zss-engine';
|
|
5
|
-
import { createCSS,
|
|
5
|
+
import { createCSS, createTheme, collectLocalConsts, objectExpressionToObject, scanForCreateStatic, scanForCreateTheme, scanForKeyframes, scanForViewTransition, t, tables, traverse, } from '@plumeria/utils';
|
|
6
6
|
const TARGET_EXTENSIONS = ['ts', 'tsx', 'js', 'jsx', 'vue', 'svelte'];
|
|
7
7
|
const EXTENSION_PATTERN = /\.(ts|tsx|js|jsx|vue|svelte)$/;
|
|
8
8
|
export function plumeria(options = {}) {
|
|
@@ -76,16 +76,16 @@ export function plumeria(options = {}) {
|
|
|
76
76
|
dependencies.push(depPath);
|
|
77
77
|
this.addWatchFile(depPath);
|
|
78
78
|
};
|
|
79
|
-
tables.
|
|
79
|
+
tables.staticTable = scanForCreateStatic(addDependency);
|
|
80
80
|
const { keyframesHashTableLocal, keyframesObjectTableLocal } = scanForKeyframes(addDependency);
|
|
81
81
|
tables.keyframesHashTable = keyframesHashTableLocal;
|
|
82
82
|
tables.keyframesObjectTable = keyframesObjectTableLocal;
|
|
83
83
|
const { viewTransitionHashTableLocal, viewTransitionObjectTableLocal } = scanForViewTransition(addDependency);
|
|
84
84
|
tables.viewTransitionHashTable = viewTransitionHashTableLocal;
|
|
85
85
|
tables.viewTransitionObjectTable = viewTransitionObjectTableLocal;
|
|
86
|
-
const {
|
|
87
|
-
tables.
|
|
88
|
-
tables.
|
|
86
|
+
const { themeTableLocal, createThemeObjectTableLocal } = scanForCreateTheme(addDependency);
|
|
87
|
+
tables.themeTable = themeTableLocal;
|
|
88
|
+
tables.createThemeObjectTable = createThemeObjectTableLocal;
|
|
89
89
|
const extractedObjects = [];
|
|
90
90
|
let ast;
|
|
91
91
|
const scriptContents = getScriptContents(source, id);
|
|
@@ -105,7 +105,7 @@ export function plumeria(options = {}) {
|
|
|
105
105
|
continue;
|
|
106
106
|
}
|
|
107
107
|
const localConsts = collectLocalConsts(ast);
|
|
108
|
-
Object.assign(tables.
|
|
108
|
+
Object.assign(tables.staticTable, localConsts);
|
|
109
109
|
traverse(ast, {
|
|
110
110
|
CallExpression({ node }) {
|
|
111
111
|
const callee = node.callee;
|
|
@@ -116,7 +116,7 @@ export function plumeria(options = {}) {
|
|
|
116
116
|
if (callee.property.value === 'create' &&
|
|
117
117
|
args.length === 1 &&
|
|
118
118
|
t.isObjectExpression(args[0].expression)) {
|
|
119
|
-
const obj = objectExpressionToObject(args[0].expression, tables.
|
|
119
|
+
const obj = objectExpressionToObject(args[0].expression, tables.staticTable, tables.keyframesHashTable, tables.viewTransitionHashTable, tables.themeTable);
|
|
120
120
|
if (obj) {
|
|
121
121
|
extractedObjects.push(obj);
|
|
122
122
|
}
|
|
@@ -147,9 +147,10 @@ export function plumeria(options = {}) {
|
|
|
147
147
|
}, undefined, '--global').styleSheet)
|
|
148
148
|
.join('\n');
|
|
149
149
|
}
|
|
150
|
-
if (Object.keys(tables.
|
|
151
|
-
fileStyles.
|
|
152
|
-
.map((obj) => transpile(
|
|
150
|
+
if (Object.keys(tables.createThemeObjectTable).length > 0) {
|
|
151
|
+
fileStyles.themeStyles = Object.values(tables.createThemeObjectTable)
|
|
152
|
+
.map((obj) => transpile(createTheme(obj), undefined, '--global')
|
|
153
|
+
.styleSheet)
|
|
153
154
|
.join('\n');
|
|
154
155
|
}
|
|
155
156
|
const sections = [];
|
|
@@ -157,8 +158,8 @@ export function plumeria(options = {}) {
|
|
|
157
158
|
sections.push(fileStyles.keyframeStyles);
|
|
158
159
|
if (fileStyles.viewTransitionStyles?.trim())
|
|
159
160
|
sections.push(fileStyles.viewTransitionStyles);
|
|
160
|
-
if (fileStyles.
|
|
161
|
-
sections.push(fileStyles.
|
|
161
|
+
if (fileStyles.themeStyles?.trim())
|
|
162
|
+
sections.push(fileStyles.themeStyles);
|
|
162
163
|
if (fileStyles.baseStyles?.trim())
|
|
163
164
|
sections.push(fileStyles.baseStyles);
|
|
164
165
|
const generatedCSS = sections.join('\n');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/vite-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Plumeria Vite plugin",
|
|
6
6
|
"repository": {
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
"dist/"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@plumeria/utils": "^
|
|
18
|
+
"@plumeria/utils": "^2.0.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@swc/core": "1.15.2",
|
|
22
22
|
"vite": "^7.1.1",
|
|
23
|
-
"zss-engine": "1.
|
|
23
|
+
"zss-engine": "1.1.0"
|
|
24
24
|
},
|
|
25
25
|
"publishConfig": {
|
|
26
26
|
"access": "public",
|