@sybz-components/utils 1.0.14 → 1.0.16

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/base.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  require('vue');
4
4
  require('consola');
5
5
  require('es-toolkit');
6
- const format = require('./shared/utils.Cp3n3FrB.cjs');
6
+ const format = require('./shared/utils.KWmfSH7h.cjs');
7
7
  require('./confirmSemantic.cjs');
8
8
  require('element-plus');
9
9
  require('axios');
package/dist/base.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import 'vue';
2
2
  import 'consola';
3
3
  import 'es-toolkit';
4
- export { $ as $toast, c as clearStorage, a as clone, b as configureUtils, d as confirm, e as copy, f as debounce, g as delay, h as getStorage, i as getType, j as getUtilsBuildTime, k as getVariable, l as isEmpty, m as log, n as merge, o as mockValue, p as processWidth, r as random, s as setStorage, t as test, q as throttle, u as toLine, v as tryCatch, w as validate, x as validateForm, y as validateOnSubmit } from './shared/utils.Dx5Dp11G.mjs';
4
+ export { $ as $toast, c as clearStorage, a as clone, b as configureUtils, d as confirm, e as copy, f as debounce, g as delay, h as getStorage, i as getType, j as getUtilsBuildTime, k as getVariable, l as isEmpty, m as log, n as merge, o as mockValue, p as processWidth, r as random, s as setStorage, t as test, q as throttle, u as toLine, v as tryCatch, w as validate, x as validateForm, y as validateOnSubmit } from './shared/utils.BVs9MJTE.mjs';
5
5
  import './confirmSemantic.mjs';
6
6
  import 'element-plus';
7
7
  import 'axios';
package/dist/format.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const format = require('./shared/utils.Cp3n3FrB.cjs');
3
+ const format = require('./shared/utils.KWmfSH7h.cjs');
4
4
  require('./is.cjs');
5
5
  require('consola');
6
6
  require('vue');
package/dist/format.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { z as formatBytes, A as formatBytesConvert, B as formatDurationTime, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed } from './shared/utils.Dx5Dp11G.mjs';
1
+ export { z as formatBytes, A as formatBytesConvert, B as formatDurationTime, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed } from './shared/utils.BVs9MJTE.mjs';
2
2
  import './is.mjs';
3
3
  import 'consola';
4
4
  import 'vue';
package/dist/http.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  require('axios');
4
- const format = require('./shared/utils.Cp3n3FrB.cjs');
4
+ const format = require('./shared/utils.KWmfSH7h.cjs');
5
5
  require('vue');
6
6
  require('consola');
7
7
  require('es-toolkit');
package/dist/http.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import 'axios';
2
- export { H as HttpError, G as configureHttp, I as createHttp, J as http } from './shared/utils.Dx5Dp11G.mjs';
2
+ export { H as HttpError, G as configureHttp, I as createHttp, J as http } from './shared/utils.BVs9MJTE.mjs';
3
3
  import 'vue';
4
4
  import 'consola';
5
5
  import 'es-toolkit';
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const format = require('./shared/utils.Cp3n3FrB.cjs');
3
+ const format = require('./shared/utils.KWmfSH7h.cjs');
4
4
  const confirmSemantic = require('./confirmSemantic.cjs');
5
5
  const is = require('./is.cjs');
6
6
  const theme = require('./theme.cjs');
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { $ as $toast, H as HttpError, c as clearStorage, a as clone, G as configureHttp, b as configureUtils, d as confirm, e as copy, I as createHttp, f as debounce, g as delay, z as formatBytes, A as formatBytesConvert, B as formatDurationTime, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed, h as getStorage, i as getType, j as getUtilsBuildTime, k as getVariable, J as http, l as isEmpty, m as log, n as merge, o as mockValue, p as processWidth, r as random, s as setStorage, t as test, q as throttle, u as toLine, v as tryCatch, w as validate, x as validateForm, y as validateOnSubmit } from './shared/utils.Dx5Dp11G.mjs';
1
+ export { $ as $toast, H as HttpError, c as clearStorage, a as clone, G as configureHttp, b as configureUtils, d as confirm, e as copy, I as createHttp, f as debounce, g as delay, z as formatBytes, A as formatBytesConvert, B as formatDurationTime, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed, h as getStorage, i as getType, j as getUtilsBuildTime, k as getVariable, J as http, l as isEmpty, m as log, n as merge, o as mockValue, p as processWidth, r as random, s as setStorage, t as test, q as throttle, u as toLine, v as tryCatch, w as validate, x as validateForm, y as validateOnSubmit } from './shared/utils.BVs9MJTE.mjs';
2
2
  export { resolveConfirmSemantic } from './confirmSemantic.mjs';
3
3
  export { isArray, isBoolean, isComponent, isDate, isEmptyObject, isFunction, isIOS, isMap, isNumber, isObject, isPlainObject, isPromise, isRegExp, isSVGElement, isSet, isString, isStringNumber, isSymbol, isUrl, objectToString, toRawType, toTypeString } from './is.mjs';
4
4
  export { SYBZ_THEME_PREFIX, isSybzTheme, resolveSybzComponentTheme } from './theme.mjs';
@@ -1196,7 +1196,7 @@ function getVariable(propertyName, fallback = "") {
1196
1196
  const DEFAULT_BUILD_TIME_FALLBACK = "\u672A\u6CE8\u5165";
1197
1197
  function getUtilsBuildTime(fallback = DEFAULT_BUILD_TIME_FALLBACK) {
1198
1198
  {
1199
- return "2026-09-23 17:35:43";
1199
+ return "2026-10-22 09:49:58";
1200
1200
  }
1201
1201
  }
1202
1202
  function test() {
@@ -1202,7 +1202,7 @@ function getVariable(propertyName, fallback = "") {
1202
1202
  const DEFAULT_BUILD_TIME_FALLBACK = "\u672A\u6CE8\u5165";
1203
1203
  function getUtilsBuildTime(fallback = DEFAULT_BUILD_TIME_FALLBACK) {
1204
1204
  {
1205
- return "2026-09-23 17:35:43";
1205
+ return "2026-10-22 09:49:58";
1206
1206
  }
1207
1207
  }
1208
1208
  function test() {
@@ -90,24 +90,59 @@ const configurePackageJson = (force) => {
90
90
  `, "utf8");
91
91
  console.log("\u66F4\u65B0 package.json scripts");
92
92
  };
93
+ const gitRoot = () => {
94
+ try {
95
+ return node_child_process.execFileSync("git", ["rev-parse", "--show-toplevel"], { cwd, encoding: "utf8" }).trim();
96
+ } catch {
97
+ throw new Error(`\u5F53\u524D\u76EE\u5F55\u4E0D\u5728 Git \u4ED3\u5E93\u4E2D\uFF0C\u65E0\u6CD5\u5B89\u88C5 Husky\uFF1A${cwd}`);
98
+ }
99
+ };
93
100
  const prepareHusky = () => {
94
- const result = husky__default();
95
- if (result) console.warn(result);
101
+ const root = gitRoot();
102
+ const original = process.cwd();
103
+ try {
104
+ process.chdir(root);
105
+ const result = husky__default();
106
+ if (result && result !== "HUSKY=0 skip install") throw new Error(`Husky \u5B89\u88C5\u5931\u8D25\uFF1A${result}`);
107
+ if (result) console.warn(result);
108
+ } finally {
109
+ process.chdir(original);
110
+ }
111
+ return root;
96
112
  };
113
+ const shellQuote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
97
114
  const configurePreCommit = () => {
98
- prepareHusky();
99
- const huskyDir = node_path.resolve(cwd, ".husky");
115
+ const root = prepareHusky();
116
+ const projectPath = node_path.relative(root, cwd);
117
+ const huskyDir = node_path.resolve(root, ".husky");
100
118
  const hookPath = node_path.resolve(huskyDir, "pre-commit");
101
- const command2 = "pnpm exec sybz-code-standard staged";
119
+ const oldCommand = "pnpm exec sybz-code-standard staged";
120
+ const command2 = projectPath ? `pnpm --dir ${shellQuote(projectPath)} exec sybz-code-standard staged` : oldCommand;
102
121
  node_fs.mkdirSync(huskyDir, { recursive: true });
103
122
  const current = node_fs.existsSync(hookPath) ? node_fs.readFileSync(hookPath, "utf8").trimEnd() : "";
104
- if (current.includes("sybz-code-standard staged")) return;
105
- node_fs.writeFileSync(hookPath, `${current ? `${current}
106
- ` : ""}${command2}
123
+ const lines = current ? current.split("\n") : [];
124
+ if (!lines.some((line) => line.trim() === command2)) {
125
+ const oldIndex = lines.findIndex((line) => line.trim() === oldCommand);
126
+ if (oldIndex >= 0) lines[oldIndex] = command2;
127
+ else lines.push(command2);
128
+ node_fs.writeFileSync(hookPath, `${lines.join("\n")}
107
129
  `, { encoding: "utf8", mode: 493 });
108
- console.log("\u66F4\u65B0 .husky/pre-commit");
130
+ console.log(`\u66F4\u65B0 ${node_path.relative(root, hookPath)}`);
131
+ }
132
+ if (projectPath) {
133
+ const obsoleteDir = node_path.resolve(cwd, ".husky");
134
+ const obsoleteHook = node_path.resolve(obsoleteDir, "pre-commit");
135
+ if (node_fs.existsSync(obsoleteHook) && node_fs.readFileSync(obsoleteHook, "utf8").trim() === oldCommand) {
136
+ node_fs.unlinkSync(obsoleteHook);
137
+ try {
138
+ node_fs.rmdirSync(obsoleteDir);
139
+ } catch {
140
+ }
141
+ }
142
+ }
109
143
  };
110
144
  const init = (args2) => {
145
+ gitRoot();
111
146
  const force = args2.includes("--force");
112
147
  configurePackageJson(force);
113
148
  for (const [filePath, content] of Object.entries(generatedFiles)) writeConfigFile(filePath, content, force);
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import { execFileSync } from 'node:child_process';
3
- import { existsSync, readFileSync, writeFileSync, mkdirSync, copyFileSync } from 'node:fs';
3
+ import { existsSync, readFileSync, writeFileSync, mkdirSync, unlinkSync, rmdirSync, copyFileSync } from 'node:fs';
4
4
  import { createRequire } from 'node:module';
5
- import { resolve } from 'node:path';
5
+ import { resolve, relative } from 'node:path';
6
6
  import husky from 'husky';
7
7
 
8
8
  const cwd = process.cwd();
@@ -83,24 +83,59 @@ const configurePackageJson = (force) => {
83
83
  `, "utf8");
84
84
  console.log("\u66F4\u65B0 package.json scripts");
85
85
  };
86
+ const gitRoot = () => {
87
+ try {
88
+ return execFileSync("git", ["rev-parse", "--show-toplevel"], { cwd, encoding: "utf8" }).trim();
89
+ } catch {
90
+ throw new Error(`\u5F53\u524D\u76EE\u5F55\u4E0D\u5728 Git \u4ED3\u5E93\u4E2D\uFF0C\u65E0\u6CD5\u5B89\u88C5 Husky\uFF1A${cwd}`);
91
+ }
92
+ };
86
93
  const prepareHusky = () => {
87
- const result = husky();
88
- if (result) console.warn(result);
94
+ const root = gitRoot();
95
+ const original = process.cwd();
96
+ try {
97
+ process.chdir(root);
98
+ const result = husky();
99
+ if (result && result !== "HUSKY=0 skip install") throw new Error(`Husky \u5B89\u88C5\u5931\u8D25\uFF1A${result}`);
100
+ if (result) console.warn(result);
101
+ } finally {
102
+ process.chdir(original);
103
+ }
104
+ return root;
89
105
  };
106
+ const shellQuote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
90
107
  const configurePreCommit = () => {
91
- prepareHusky();
92
- const huskyDir = resolve(cwd, ".husky");
108
+ const root = prepareHusky();
109
+ const projectPath = relative(root, cwd);
110
+ const huskyDir = resolve(root, ".husky");
93
111
  const hookPath = resolve(huskyDir, "pre-commit");
94
- const command2 = "pnpm exec sybz-code-standard staged";
112
+ const oldCommand = "pnpm exec sybz-code-standard staged";
113
+ const command2 = projectPath ? `pnpm --dir ${shellQuote(projectPath)} exec sybz-code-standard staged` : oldCommand;
95
114
  mkdirSync(huskyDir, { recursive: true });
96
115
  const current = existsSync(hookPath) ? readFileSync(hookPath, "utf8").trimEnd() : "";
97
- if (current.includes("sybz-code-standard staged")) return;
98
- writeFileSync(hookPath, `${current ? `${current}
99
- ` : ""}${command2}
116
+ const lines = current ? current.split("\n") : [];
117
+ if (!lines.some((line) => line.trim() === command2)) {
118
+ const oldIndex = lines.findIndex((line) => line.trim() === oldCommand);
119
+ if (oldIndex >= 0) lines[oldIndex] = command2;
120
+ else lines.push(command2);
121
+ writeFileSync(hookPath, `${lines.join("\n")}
100
122
  `, { encoding: "utf8", mode: 493 });
101
- console.log("\u66F4\u65B0 .husky/pre-commit");
123
+ console.log(`\u66F4\u65B0 ${relative(root, hookPath)}`);
124
+ }
125
+ if (projectPath) {
126
+ const obsoleteDir = resolve(cwd, ".husky");
127
+ const obsoleteHook = resolve(obsoleteDir, "pre-commit");
128
+ if (existsSync(obsoleteHook) && readFileSync(obsoleteHook, "utf8").trim() === oldCommand) {
129
+ unlinkSync(obsoleteHook);
130
+ try {
131
+ rmdirSync(obsoleteDir);
132
+ } catch {
133
+ }
134
+ }
135
+ }
102
136
  };
103
137
  const init = (args2) => {
138
+ gitRoot();
104
139
  const force = args2.includes("--force");
105
140
  configurePackageJson(force);
106
141
  for (const [filePath, content] of Object.entries(generatedFiles)) writeConfigFile(filePath, content, force);
package/dist/vite.cjs CHANGED
@@ -1,16 +1,48 @@
1
1
  'use strict';
2
2
 
3
+ const node_module = require('node:module');
3
4
  const codeInspectorPlugin = require('code-inspector-plugin');
4
5
  const tailwindcss = require('@tailwindcss/vite');
6
+ const vueJsx = require('@vitejs/plugin-vue-jsx');
5
7
  const gitCommitLog = require('./gitCommitLog.cjs');
6
8
  require('node:child_process');
7
9
  require('node:fs');
8
10
  require('node:path');
9
11
 
12
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
10
13
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
11
14
 
12
15
  const tailwindcss__default = /*#__PURE__*/_interopDefaultCompat(tailwindcss);
16
+ const vueJsx__default = /*#__PURE__*/_interopDefaultCompat(vueJsx);
13
17
 
18
+ const require2 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('vite.cjs', document.baseURI).href)));
19
+ const virtualTailwindId = "virtual:sybz-tailwind";
20
+ const resolvedVirtualTailwindId = `\0${virtualTailwindId}`;
21
+ const createTailwindEntry = () => {
22
+ const tailwindCssPath = require2.resolve("tailwindcss/index.css");
23
+ return {
24
+ name: "sybz-tailwind-entry",
25
+ resolveId(id) {
26
+ if (id === virtualTailwindId) return resolvedVirtualTailwindId;
27
+ },
28
+ load(id) {
29
+ if (id === resolvedVirtualTailwindId) return `import ${JSON.stringify(tailwindCssPath)}`;
30
+ },
31
+ transformIndexHtml: {
32
+ order: "pre",
33
+ handler() {
34
+ return [
35
+ {
36
+ tag: "script",
37
+ attrs: { type: "module" },
38
+ children: `import '${virtualTailwindId}'`,
39
+ injectTo: "head-prepend"
40
+ }
41
+ ];
42
+ }
43
+ }
44
+ };
45
+ };
14
46
  const createCodeInspector = (options = {}) => codeInspectorPlugin.codeInspectorPlugin({ editor: "code", ...options, bundler: "vite" });
15
47
  const formatBuildTime = (date) => {
16
48
  const pad = (value) => String(value).padStart(2, "0");
@@ -43,8 +75,12 @@ const createBuildTime = (metaName = "buildTime") => {
43
75
  };
44
76
  const sybzVitePlugins = (options = {}) => {
45
77
  const plugins = [];
78
+ if (options.vueJsx !== false) {
79
+ plugins.push(vueJsx__default(typeof options.vueJsx === "object" ? options.vueJsx : {}));
80
+ }
46
81
  if (options.tailwind !== false) {
47
82
  plugins.push(...tailwindcss__default(typeof options.tailwind === "object" ? options.tailwind : {}));
83
+ if (options.tailwindCss !== false) plugins.push(createTailwindEntry());
48
84
  }
49
85
  if (options.codeInspector !== false) {
50
86
  plugins.push(createCodeInspector(typeof options.codeInspector === "object" ? options.codeInspector : {}));
package/dist/vite.d.cts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { CodeInspectorPluginOptions } from 'code-inspector-plugin';
2
2
  import { PluginOptions } from '@tailwindcss/vite';
3
+ import { Options } from '@vitejs/plugin-vue-jsx';
3
4
  import { PluginOption } from 'vite';
4
5
  import { GitCommitLogOptions } from './gitCommitLog.cjs';
5
6
 
@@ -10,8 +11,12 @@ declare global {
10
11
  }
11
12
  type SybzCodeInspectorOptions = Omit<CodeInspectorPluginOptions, 'bundler'>;
12
13
  interface SybzVitePluginsOptions {
14
+ /** Vue JSX/TSX 插件配置;默认启用,设为 false 时关闭。 */
15
+ vueJsx?: boolean | Options;
13
16
  /** Tailwind CSS v4 Vite 插件配置;默认启用,设为 false 时关闭。 */
14
17
  tailwind?: boolean | PluginOptions;
18
+ /** 自动向 HTML 注入 Tailwind CSS;默认启用,已有手动 CSS 入口时可设为 false。 */
19
+ tailwindCss?: boolean;
15
20
  /** 代码定位插件配置;默认启用,设为 false 时关闭。 */
16
21
  codeInspector?: boolean | SybzCodeInspectorOptions;
17
22
  /** Git 提交信息插件配置;默认启用,设为 false 时关闭。 */
@@ -22,7 +27,7 @@ interface SybzVitePluginsOptions {
22
27
  };
23
28
  }
24
29
  /**
25
- * 创建 sybz 项目的 Vite 插件预设,默认包含 Tailwind CSS v4、代码定位、Git 提交信息和打包时间。
30
+ * 创建 sybz 项目的 Vite 插件预设,默认包含 Vue JSX/TSX、Tailwind CSS v4、代码定位、Git 提交信息和打包时间。
26
31
  * Vite 会自动扁平化插件数组,推荐直接写入 plugins,无需展开运算符。
27
32
  */
28
33
  declare const sybzVitePlugins: (options?: SybzVitePluginsOptions) => PluginOption;
package/dist/vite.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { CodeInspectorPluginOptions } from 'code-inspector-plugin';
2
2
  import { PluginOptions } from '@tailwindcss/vite';
3
+ import { Options } from '@vitejs/plugin-vue-jsx';
3
4
  import { PluginOption } from 'vite';
4
5
  import { GitCommitLogOptions } from './gitCommitLog.mjs';
5
6
 
@@ -10,8 +11,12 @@ declare global {
10
11
  }
11
12
  type SybzCodeInspectorOptions = Omit<CodeInspectorPluginOptions, 'bundler'>;
12
13
  interface SybzVitePluginsOptions {
14
+ /** Vue JSX/TSX 插件配置;默认启用,设为 false 时关闭。 */
15
+ vueJsx?: boolean | Options;
13
16
  /** Tailwind CSS v4 Vite 插件配置;默认启用,设为 false 时关闭。 */
14
17
  tailwind?: boolean | PluginOptions;
18
+ /** 自动向 HTML 注入 Tailwind CSS;默认启用,已有手动 CSS 入口时可设为 false。 */
19
+ tailwindCss?: boolean;
15
20
  /** 代码定位插件配置;默认启用,设为 false 时关闭。 */
16
21
  codeInspector?: boolean | SybzCodeInspectorOptions;
17
22
  /** Git 提交信息插件配置;默认启用,设为 false 时关闭。 */
@@ -22,7 +27,7 @@ interface SybzVitePluginsOptions {
22
27
  };
23
28
  }
24
29
  /**
25
- * 创建 sybz 项目的 Vite 插件预设,默认包含 Tailwind CSS v4、代码定位、Git 提交信息和打包时间。
30
+ * 创建 sybz 项目的 Vite 插件预设,默认包含 Vue JSX/TSX、Tailwind CSS v4、代码定位、Git 提交信息和打包时间。
26
31
  * Vite 会自动扁平化插件数组,推荐直接写入 plugins,无需展开运算符。
27
32
  */
28
33
  declare const sybzVitePlugins: (options?: SybzVitePluginsOptions) => PluginOption;
package/dist/vite.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { CodeInspectorPluginOptions } from 'code-inspector-plugin';
2
2
  import { PluginOptions } from '@tailwindcss/vite';
3
+ import { Options } from '@vitejs/plugin-vue-jsx';
3
4
  import { PluginOption } from 'vite';
4
5
  import { GitCommitLogOptions } from './gitCommitLog.js';
5
6
 
@@ -10,8 +11,12 @@ declare global {
10
11
  }
11
12
  type SybzCodeInspectorOptions = Omit<CodeInspectorPluginOptions, 'bundler'>;
12
13
  interface SybzVitePluginsOptions {
14
+ /** Vue JSX/TSX 插件配置;默认启用,设为 false 时关闭。 */
15
+ vueJsx?: boolean | Options;
13
16
  /** Tailwind CSS v4 Vite 插件配置;默认启用,设为 false 时关闭。 */
14
17
  tailwind?: boolean | PluginOptions;
18
+ /** 自动向 HTML 注入 Tailwind CSS;默认启用,已有手动 CSS 入口时可设为 false。 */
19
+ tailwindCss?: boolean;
15
20
  /** 代码定位插件配置;默认启用,设为 false 时关闭。 */
16
21
  codeInspector?: boolean | SybzCodeInspectorOptions;
17
22
  /** Git 提交信息插件配置;默认启用,设为 false 时关闭。 */
@@ -22,7 +27,7 @@ interface SybzVitePluginsOptions {
22
27
  };
23
28
  }
24
29
  /**
25
- * 创建 sybz 项目的 Vite 插件预设,默认包含 Tailwind CSS v4、代码定位、Git 提交信息和打包时间。
30
+ * 创建 sybz 项目的 Vite 插件预设,默认包含 Vue JSX/TSX、Tailwind CSS v4、代码定位、Git 提交信息和打包时间。
26
31
  * Vite 会自动扁平化插件数组,推荐直接写入 plugins,无需展开运算符。
27
32
  */
28
33
  declare const sybzVitePlugins: (options?: SybzVitePluginsOptions) => PluginOption;
package/dist/vite.mjs CHANGED
@@ -1,10 +1,40 @@
1
+ import { createRequire } from 'node:module';
1
2
  import { codeInspectorPlugin } from 'code-inspector-plugin';
2
3
  import tailwindcss from '@tailwindcss/vite';
4
+ import vueJsx from '@vitejs/plugin-vue-jsx';
3
5
  import { gitCommitLog } from './gitCommitLog.mjs';
4
6
  import 'node:child_process';
5
7
  import 'node:fs';
6
8
  import 'node:path';
7
9
 
10
+ const require2 = createRequire(import.meta.url);
11
+ const virtualTailwindId = "virtual:sybz-tailwind";
12
+ const resolvedVirtualTailwindId = `\0${virtualTailwindId}`;
13
+ const createTailwindEntry = () => {
14
+ const tailwindCssPath = require2.resolve("tailwindcss/index.css");
15
+ return {
16
+ name: "sybz-tailwind-entry",
17
+ resolveId(id) {
18
+ if (id === virtualTailwindId) return resolvedVirtualTailwindId;
19
+ },
20
+ load(id) {
21
+ if (id === resolvedVirtualTailwindId) return `import ${JSON.stringify(tailwindCssPath)}`;
22
+ },
23
+ transformIndexHtml: {
24
+ order: "pre",
25
+ handler() {
26
+ return [
27
+ {
28
+ tag: "script",
29
+ attrs: { type: "module" },
30
+ children: `import '${virtualTailwindId}'`,
31
+ injectTo: "head-prepend"
32
+ }
33
+ ];
34
+ }
35
+ }
36
+ };
37
+ };
8
38
  const createCodeInspector = (options = {}) => codeInspectorPlugin({ editor: "code", ...options, bundler: "vite" });
9
39
  const formatBuildTime = (date) => {
10
40
  const pad = (value) => String(value).padStart(2, "0");
@@ -37,8 +67,12 @@ const createBuildTime = (metaName = "buildTime") => {
37
67
  };
38
68
  const sybzVitePlugins = (options = {}) => {
39
69
  const plugins = [];
70
+ if (options.vueJsx !== false) {
71
+ plugins.push(vueJsx(typeof options.vueJsx === "object" ? options.vueJsx : {}));
72
+ }
40
73
  if (options.tailwind !== false) {
41
74
  plugins.push(...tailwindcss(typeof options.tailwind === "object" ? options.tailwind : {}));
75
+ if (options.tailwindCss !== false) plugins.push(createTailwindEntry());
42
76
  }
43
77
  if (options.codeInspector !== false) {
44
78
  plugins.push(createCodeInspector(typeof options.codeInspector === "object" ? options.codeInspector : {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sybz-components/utils",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "utils of sybz-components",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
@@ -58,6 +58,7 @@
58
58
  "@tailwindcss/vite": "^4.3.3",
59
59
  "@typescript-eslint/eslint-plugin": "8.62.0",
60
60
  "@typescript-eslint/parser": "8.62.0",
61
+ "@vitejs/plugin-vue-jsx": "^4.2.0",
61
62
  "@vue/reactivity": "^3.5.18",
62
63
  "@vue/shared": "^3.5.18",
63
64
  "axios": "^1.19.0",
@@ -78,6 +79,6 @@
78
79
  "vue-eslint-parser": "10.4.1"
79
80
  },
80
81
  "peerDependencies": {
81
- "vite": ">=5 <8"
82
+ "vite": ">=5 <7"
82
83
  }
83
84
  }