vite-plugin-sxo 0.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/README.md ADDED
@@ -0,0 +1,14 @@
1
+ # vite-plugin-sxo
2
+
3
+ SXO 设计系统的 Vite 插件。
4
+
5
+ ## 功能
6
+
7
+ - **自动导入**: 自动处理组件及其样式的按需导入。
8
+ - **主题热更新**: 在开发环境下支持主题实时预览和切换。
9
+
10
+ ## 安装
11
+
12
+ ```bash
13
+ pnpm add -D vite-plugin-sxo @sxo/engine @sxo/design
14
+ ```
package/dist/index.cjs ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("@sxo/design"),S=require("@sxo/engine");function h(t={}){const i=new S.StyleEngine(v.defaultTokens),o=new Set,d=new Set,a="virtual:sxo.css",c="\0"+a;let r;const f=(n,s)=>{const u=/([a-zA-Z0-9-:[\]/%]+)/g;let l,g=!1;for(;(l=u.exec(n))!==null;){const e=l[1];e.length<2||e.length>50||!o.has(e)&&!d.has(e)&&(i.generate(e)?(o.add(e),g=!0,t.debug&&console.log(`[SXO] Discovered: ${e} in ${s.split("/").pop()}`)):(e.includes("-")||e.includes(":"))&&(d.add(e),t.debug&&console.warn(`[SXO] Unknown/Invalid class: "${e}" in ${s.split("/").pop()}`)))}return g};return{name:"vite-plugin-sxo",buildStart(){t.debug&&console.log("[SXO] Plugin initialized with debug mode")},configureServer(n){r=n},resolveId(n){return n===a?c:null},load(n){if(n===c){const s=i.generateTokenCssVars(),u=i.generateSheet(o);return t.debug&&console.log(`[SXO] Generated ${o.size} classes`),`${s}
2
+
3
+ ${u}`}return null},transform(n,s){if(s.includes("node_modules")&&!s.includes("@sxo")||!/\.(vue|svelte|[jt]sx?|html)$/.test(s))return null;if(f(n,s)&&r){const l=r.moduleGraph.getModuleById(c);l&&r.reloadModule(l)}return null}}}exports.vitePluginSxo=h;
@@ -0,0 +1,5 @@
1
+ import { Plugin } from 'vite';
2
+ export interface VitePluginSxoOptions {
3
+ debug?: boolean;
4
+ }
5
+ export declare function vitePluginSxo(options?: VitePluginSxoOptions): Plugin;
package/dist/index.js ADDED
@@ -0,0 +1,48 @@
1
+ import { defaultTokens as v } from "@sxo/design";
2
+ import { StyleEngine as m } from "@sxo/engine";
3
+ function p(t = {}) {
4
+ const i = new m(v), o = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), a = "virtual:sxo.css", c = "\0" + a;
5
+ let r;
6
+ const g = (n, s) => {
7
+ const u = /([a-zA-Z0-9-:[\]/%]+)/g;
8
+ let l, f = !1;
9
+ for (; (l = u.exec(n)) !== null; ) {
10
+ const e = l[1];
11
+ e.length < 2 || e.length > 50 || !o.has(e) && !d.has(e) && (i.generate(e) ? (o.add(e), f = !0, t.debug && console.log(`[SXO] Discovered: ${e} in ${s.split("/").pop()}`)) : (e.includes("-") || e.includes(":")) && (d.add(e), t.debug && console.warn(`[SXO] Unknown/Invalid class: "${e}" in ${s.split("/").pop()}`)));
12
+ }
13
+ return f;
14
+ };
15
+ return {
16
+ name: "vite-plugin-sxo",
17
+ buildStart() {
18
+ t.debug && console.log("[SXO] Plugin initialized with debug mode");
19
+ },
20
+ configureServer(n) {
21
+ r = n;
22
+ },
23
+ resolveId(n) {
24
+ return n === a ? c : null;
25
+ },
26
+ load(n) {
27
+ if (n === c) {
28
+ const s = i.generateTokenCssVars(), u = i.generateSheet(o);
29
+ return t.debug && console.log(`[SXO] Generated ${o.size} classes`), `${s}
30
+
31
+ ${u}`;
32
+ }
33
+ return null;
34
+ },
35
+ transform(n, s) {
36
+ if (s.includes("node_modules") && !s.includes("@sxo") || !/\.(vue|svelte|[jt]sx?|html)$/.test(s))
37
+ return null;
38
+ if (g(n, s) && r) {
39
+ const l = r.moduleGraph.getModuleById(c);
40
+ l && r.reloadModule(l);
41
+ }
42
+ return null;
43
+ }
44
+ };
45
+ }
46
+ export {
47
+ p as vitePluginSxo
48
+ };
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "vite-plugin-sxo",
3
+ "version": "0.0.0",
4
+ "description": "Vite plugin for SXO Design System with auto-import and HMR support.",
5
+ "keywords": [
6
+ "sxo",
7
+ "design-system",
8
+ "ui",
9
+ "components"
10
+ ],
11
+ "license": "MIT",
12
+ "author": "sxo team",
13
+ "type": "module",
14
+ "main": "./dist/index.cjs",
15
+ "module": "./dist/index.js",
16
+ "types": "./dist/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "import": "./dist/index.js",
21
+ "require": "./dist/index.cjs"
22
+ }
23
+ },
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "dependencies": {
28
+ "vite": "^4.0.0",
29
+ "@sxo/design": "0.0.0",
30
+ "@sxo/engine": "0.0.0"
31
+ },
32
+ "peerDependencies": {
33
+ "vite": "^4.0.0"
34
+ },
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/doki-land/sxo-engine.git",
38
+ "directory": "adaptors/vite-plugin-sxo"
39
+ },
40
+ "bugs": {
41
+ "url": "https://github.com/doki-land/sxo-engine/issues"
42
+ },
43
+ "homepage": "https://github.com/doki-land/sxo-engine/tree/main/adaptors/vite-plugin-sxo#readme",
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "devDependencies": {
48
+ "vite": "^5.0.0",
49
+ "vite-plugin-dts": "^4.0.0",
50
+ "typescript": "^5.0.0"
51
+ },
52
+ "scripts": {
53
+ "build": "vite build",
54
+ "dev": "vite build --watch"
55
+ }
56
+ }