@vueless/nuxt 0.0.9-beta.9 → 1.0.1-beta.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/module.d.mts CHANGED
@@ -1,9 +1,11 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
 
3
3
  declare const _default: _nuxt_schema.NuxtModule<{
4
+ include: never[];
4
5
  mirrorCacheDir: string;
5
6
  debug: boolean;
6
7
  }, {
8
+ include: never[];
7
9
  mirrorCacheDir: string;
8
10
  debug: boolean;
9
11
  }, false>;
package/dist/module.json CHANGED
@@ -4,9 +4,9 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.13.0"
6
6
  },
7
- "version": "0.0.9-beta.9",
7
+ "version": "1.0.1-beta.0",
8
8
  "builder": {
9
- "@nuxt/module-builder": "0.8.4",
10
- "unbuild": "2.0.0"
9
+ "@nuxt/module-builder": "1.0.1",
10
+ "unbuild": "3.5.0"
11
11
  }
12
12
  }
package/dist/module.mjs CHANGED
@@ -1,9 +1,10 @@
1
- import { defineNuxtModule, createResolver, addPlugin, addComponent, addImportsDir } from '@nuxt/kit';
2
- import TailwindCSS from '@tailwindcss/vite';
3
- import { COMPONENTS } from 'vueless/constants.js';
4
- import { Vueless } from 'vueless/plugin-vite.js';
5
- import { getNuxtDirs } from 'vueless/utils/node/helper.js';
6
- import { createTailwindSafelist } from 'vueless/utils/node/tailwindSafelist.js';
1
+ import path from 'node:path';
2
+ import { cwd } from 'node:process';
3
+ import fs from 'node:fs';
4
+ import { defineNuxtModule, createResolver, hasNuxtModule, addPlugin, addComponent, addImportsDir } from '@nuxt/kit';
5
+ import { TailwindCSS, Vueless } from 'vueless/plugin-vite.js';
6
+ import { cacheMergedConfigs } from 'vueless/utils/node/helper.js';
7
+ import { NUXT_MODULE_ENV, VUELESS_PACKAGE_DIR, COMPONENTS, VUELESS_CONFIG_FILE_NAME } from 'vueless/constants.js';
7
8
 
8
9
  const module = defineNuxtModule({
9
10
  meta: {
@@ -14,23 +15,45 @@ const module = defineNuxtModule({
14
15
  }
15
16
  },
16
17
  defaults: {
18
+ include: [],
17
19
  mirrorCacheDir: "",
18
20
  debug: false
19
21
  },
20
22
  async setup(_options, _nuxt) {
23
+ const { include, mirrorCacheDir, debug } = _options;
21
24
  const { resolve } = createResolver(import.meta.url);
22
- const { mirrorCacheDir, debug } = _options;
25
+ const { vuelessConfig, dependencies } = await getVuelessConfig();
26
+ _nuxt.options.runtimeConfig.public.vueless = vuelessConfig;
23
27
  _nuxt.options.build.transpile.push("vueless");
24
- _nuxt.hook("vite:extendConfig", (config) => {
28
+ if (hasNuxtModule("@nuxtjs/i18n")) {
29
+ _nuxt.hook("i18n:registerModule", (register) => {
30
+ register({
31
+ langDir: resolve("../node_modules/vueless/locales"),
32
+ locales: [
33
+ { code: "en", name: "English", file: "en.json" }
34
+ ]
35
+ });
36
+ });
37
+ }
38
+ _nuxt.hook("vite:extendConfig", async (config) => {
25
39
  config.plugins = config.plugins || [];
26
40
  config.plugins.push(
27
41
  TailwindCSS(),
28
- Vueless({ mode: "nuxt-module", mirrorCacheDir, debug })
42
+ Vueless({ env: NUXT_MODULE_ENV, mirrorCacheDir, debug, include })
29
43
  );
30
44
  });
31
- await createTailwindSafelist({
32
- targetFiles: getNuxtDirs()
33
- });
45
+ if (_nuxt.options.dev) {
46
+ const chokidarPath = require.resolve("chokidar");
47
+ const chokidar = await import(chokidarPath);
48
+ const watcher = chokidar.watch(dependencies, { ignoreInitial: true });
49
+ watcher.on("change", async () => {
50
+ const { dependencies: newDependencies } = await getVuelessConfig();
51
+ watcher.unwatch(dependencies);
52
+ watcher.add(newDependencies);
53
+ _nuxt.callHook("restart");
54
+ });
55
+ }
56
+ await cacheMergedConfigs(VUELESS_PACKAGE_DIR);
34
57
  addPlugin(resolve("./runtime/plugin"));
35
58
  for (const componentName in COMPONENTS) {
36
59
  addComponent({
@@ -42,5 +65,33 @@ const module = defineNuxtModule({
42
65
  addImportsDir("vueless/utils");
43
66
  }
44
67
  });
68
+ async function getVuelessConfig() {
69
+ const esbuildPath = require.resolve("esbuild");
70
+ const esbuild = await import(esbuildPath);
71
+ const esbuildConfig = {
72
+ bundle: true,
73
+ platform: "node",
74
+ format: "esm",
75
+ target: "ESNext",
76
+ loader: { ".ts": "ts" },
77
+ write: false,
78
+ metafile: true
79
+ // Generate dependency tree
80
+ };
81
+ const configPathJs = path.join(cwd(), `${VUELESS_CONFIG_FILE_NAME}.js`);
82
+ const configPathTs = path.join(cwd(), `${VUELESS_CONFIG_FILE_NAME}.ts`);
83
+ let result = null;
84
+ if (fs.existsSync(configPathJs)) {
85
+ result = await esbuild.build({ ...esbuildConfig, entryPoints: [configPathJs] });
86
+ }
87
+ if (fs.existsSync(configPathTs)) {
88
+ result = await esbuild.build({ ...esbuildConfig, entryPoints: [configPathTs] });
89
+ }
90
+ const code = result?.outputFiles?.[0]?.text || "";
91
+ return {
92
+ vuelessConfig: (await import(`data:text/javascript,${encodeURIComponent(code)}`)).default || {},
93
+ dependencies: Object.keys(result?.metafile?.inputs || {})
94
+ };
95
+ }
45
96
 
46
97
  export { module as default };
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vueless/nuxt",
3
- "version": "0.0.9-beta.9",
3
+ "version": "1.0.1-beta.0",
4
4
  "license": "MIT",
5
5
  "description": "Nuxt Styleless UI Component Library, powered by Tailwind CSS.",
6
6
  "keywords": [
@@ -27,54 +27,51 @@
27
27
  },
28
28
  "exports": {
29
29
  ".": {
30
- "types": "./dist/types.d.ts",
30
+ "types": "./dist/types.d.mts",
31
31
  "import": "./dist/module.mjs",
32
- "require": "./dist/module.cjs"
32
+ "require": "./dist/module.mjs"
33
33
  }
34
34
  },
35
- "main": "./dist/module.cjs",
36
- "types": "./dist/types.d.ts",
35
+ "main": "./dist/module.mjs",
37
36
  "files": [
38
37
  "dist"
39
38
  ],
40
39
  "scripts": {
41
- "dev": "nuxi dev playground",
40
+ "dev": "npm run dev:prepare && nuxi dev playground",
41
+ "dev:prepare": "nuxi cleanup && nuxi prepare && nuxi cleanup playground && nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
42
42
  "dev:build": "nuxi build playground",
43
43
  "dev:preview": "nuxi preview playground",
44
- "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
45
- "prepack": "nuxt-module-build build && cp package.json LICENSE README.md dist/",
44
+ "prepack": "nuxi prepare && nuxt-module-build build && cp package.json LICENSE README.md dist/",
46
45
  "release:beta": "release-it --ci --npm.publish --preRelease=beta --increment=prerelease",
47
46
  "release:patch": "release-it patch --ci --npm.publish",
48
47
  "release:minor": "release-it minor --ci --npm.publish --git.tag --github.release",
49
48
  "release:major": "release-it major --ci --npm.publish --git.tag --github.release",
50
- "lint": "eslint .",
51
- "lint:ci": "eslint --no-fix --max-warnings=0",
49
+ "lint": "eslint . --no-fix",
50
+ "lint:fix": "eslint . --fix",
51
+ "lint:ci": "eslint . --no-fix --max-warnings=0",
52
52
  "test": "vitest run",
53
53
  "test:watch": "vitest watch",
54
- "test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
55
- "install": "npx nuxi prepare"
54
+ "test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
56
55
  },
57
56
  "dependencies": {
58
- "@nuxt/kit": "^3.13.1",
59
- "@tailwindcss/vite": "^4.0.14",
60
- "tailwindcss": "^4.0.14",
61
- "vueless": "^0.0.825-beta.47"
57
+ "@nuxt/kit": "^3.17.4",
58
+ "vueless": "^1.0.1"
62
59
  },
63
60
  "devDependencies": {
64
- "@material-symbols/svg-500": "^0.29.1",
65
- "@nuxt/devtools": "^1.4.1",
66
- "@nuxt/eslint-config": "^0.5.7",
67
- "@nuxt/module-builder": "^0.8.4",
68
- "@nuxt/schema": "^3.13.2",
69
- "@nuxt/test-utils": "^3.14.1",
61
+ "@material-symbols/svg-500": "^0.31.4",
62
+ "@nuxt/devtools": "^2.4.1",
63
+ "@nuxt/eslint-config": "^1.4.1",
64
+ "@nuxt/module-builder": "^1.0.1",
65
+ "@nuxt/schema": "^3.17.4",
66
+ "@nuxt/test-utils": "^3.19.1",
70
67
  "@types/node": "latest",
71
68
  "changelogen": "^0.5.5",
72
- "eslint": "^9.12.0",
73
- "nuxt": "^3.15.4",
74
- "release-it": "^17.6.0",
69
+ "eslint": "^9.27.0",
70
+ "nuxt": "^3.17.4",
71
+ "release-it": "^19.0.2",
75
72
  "typescript": "latest",
76
- "vitest": "^3.0.5",
77
- "vue-tsc": "^2.1.6"
73
+ "vitest": "^3.1.4",
74
+ "vue-tsc": "^2.2.10"
78
75
  },
79
76
  "repository": {
80
77
  "type": "git",
@@ -82,6 +79,5 @@
82
79
  },
83
80
  "bugs": {
84
81
  "url": "https://github.com/vuelessjs/vueless-module-nuxt/issues"
85
- },
86
- "web-types": "./node_modules/vueless/web-types.json"
82
+ }
87
83
  }
@@ -1,8 +1,22 @@
1
1
  import { createVueless, setTheme } from "vueless";
2
- import { COLOR_MODE_KEY, AUTO_MODE_KEY, LIGHT_MODE_SELECTOR, DARK_MODE_SELECTOR, PRIMARY_COLOR_KEY, NEUTRAL_COLOR_KEY, ROUNDING_KEY } from "vueless/constants";
2
+ import createVueI18nAdapter from "vueless/adapter.locale/vue-i18n";
3
+ import {
4
+ TEXT,
5
+ OUTLINE,
6
+ ROUNDING,
7
+ PRIMARY_COLOR,
8
+ NEUTRAL_COLOR,
9
+ AUTO_MODE_KEY,
10
+ COLOR_MODE_KEY,
11
+ DARK_MODE_CLASS,
12
+ LIGHT_MODE_CLASS,
13
+ DISABLED_OPACITY
14
+ } from "vueless/constants";
3
15
  import { ColorMode } from "vueless/types";
4
16
  import vClickOutside from "vueless/directives/clickOutside/vClickOutside";
5
17
  import vTooltip from "vueless/directives/tooltip/vTooltip";
18
+ import { vuelessConfig } from "vueless/utils/ui";
19
+ import { useRuntimeConfig } from "#imports";
6
20
  import { defineNuxtPlugin } from "#app";
7
21
  function parseCookies(cookieHeader) {
8
22
  if (!cookieHeader) return {};
@@ -13,20 +27,43 @@ function parseCookies(cookieHeader) {
13
27
  }, {});
14
28
  }
15
29
  export default defineNuxtPlugin((_nuxtApp) => {
16
- const vueless = createVueless();
30
+ const config = useRuntimeConfig().public.vueless;
31
+ const vuelessOptions = { config };
32
+ if ("$i18n" in _nuxtApp) {
33
+ vuelessOptions.i18n = {
34
+ adapter: createVueI18nAdapter({ global: _nuxtApp.$i18n })
35
+ };
36
+ }
37
+ const vueless = createVueless(vuelessOptions);
17
38
  _nuxtApp.vueApp.use(vueless, []);
18
39
  _nuxtApp.vueApp.directive("clickOutside", vClickOutside);
19
40
  _nuxtApp.vueApp.directive("tooltip", vTooltip);
20
41
  if (import.meta.server) {
21
42
  const event = _nuxtApp.ssrContext?.event;
22
43
  const cookies = parseCookies(event?.node.req.headers.cookie);
23
- const primary = cookies?.[PRIMARY_COLOR_KEY];
24
- const neutral = cookies?.[NEUTRAL_COLOR_KEY];
25
- const rounding = cookies?.[ROUNDING_KEY];
26
- const colorMode = cookies?.[COLOR_MODE_KEY];
44
+ const primary = cookies?.[`vl-${PRIMARY_COLOR}`];
45
+ const neutral = cookies?.[`vl-${NEUTRAL_COLOR}`];
46
+ const text = {
47
+ xs: cookies?.[`vl-${TEXT}-xs`],
48
+ sm: cookies?.[`vl-${TEXT}-sm`],
49
+ md: cookies?.[`vl-${TEXT}-md`],
50
+ lg: cookies?.[`vl-${TEXT}-lg`]
51
+ };
52
+ const outline = {
53
+ sm: cookies?.[`vl-${OUTLINE}-sm`],
54
+ md: cookies?.[`vl-${OUTLINE}-md`],
55
+ lg: cookies?.[`vl-${OUTLINE}-lg`]
56
+ };
57
+ const rounding = {
58
+ sm: cookies?.[`vl-${ROUNDING}-sm`],
59
+ md: cookies?.[`vl-${ROUNDING}-md`],
60
+ lg: cookies?.[`vl-${ROUNDING}-lg`]
61
+ };
62
+ const disabledOpacity = cookies?.[`vl-${DISABLED_OPACITY}`];
63
+ const colorMode = cookies?.[COLOR_MODE_KEY] || vuelessConfig.colorMode || ColorMode.Light;
27
64
  const isCachedAutoMode = Boolean(Number(cookies?.[AUTO_MODE_KEY]));
28
- const themeRootVariables = setTheme({ primary, neutral, rounding, colorMode }, isCachedAutoMode);
29
- const colorModeClass = colorMode === ColorMode.Dark ? DARK_MODE_SELECTOR : LIGHT_MODE_SELECTOR;
65
+ const themeRootVariables = setTheme({ primary, neutral, text, outline, rounding, disabledOpacity, colorMode }, isCachedAutoMode);
66
+ const colorModeClass = colorMode === ColorMode.Dark ? DARK_MODE_CLASS : LIGHT_MODE_CLASS;
30
67
  _nuxtApp.ssrContext?.head.push({
31
68
  style: [{ innerHTML: themeRootVariables }],
32
69
  htmlAttrs: { class: colorModeClass }
package/dist/types.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { NuxtModule } from '@nuxt/schema'
2
2
 
3
- import type { default as Module } from './module.js'
3
+ import type { default as Module } from './module.mjs'
4
4
 
5
5
  export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
6
 
7
- export { default } from './module.js'
7
+ export { default } from './module.mjs'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vueless/nuxt",
3
- "version": "0.0.9-beta.9",
3
+ "version": "1.0.1-beta.0",
4
4
  "license": "MIT",
5
5
  "description": "Nuxt Styleless UI Component Library, powered by Tailwind CSS.",
6
6
  "keywords": [
@@ -27,54 +27,51 @@
27
27
  },
28
28
  "exports": {
29
29
  ".": {
30
- "types": "./dist/types.d.ts",
30
+ "types": "./dist/types.d.mts",
31
31
  "import": "./dist/module.mjs",
32
- "require": "./dist/module.cjs"
32
+ "require": "./dist/module.mjs"
33
33
  }
34
34
  },
35
- "main": "./dist/module.cjs",
36
- "types": "./dist/types.d.ts",
35
+ "main": "./dist/module.mjs",
37
36
  "files": [
38
37
  "dist"
39
38
  ],
40
39
  "scripts": {
41
- "dev": "nuxi dev playground",
40
+ "dev": "npm run dev:prepare && nuxi dev playground",
41
+ "dev:prepare": "nuxi cleanup && nuxi prepare && nuxi cleanup playground && nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
42
42
  "dev:build": "nuxi build playground",
43
43
  "dev:preview": "nuxi preview playground",
44
- "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
45
- "prepack": "nuxt-module-build build && cp package.json LICENSE README.md dist/",
44
+ "prepack": "nuxi prepare && nuxt-module-build build && cp package.json LICENSE README.md dist/",
46
45
  "release:beta": "release-it --ci --npm.publish --preRelease=beta --increment=prerelease",
47
46
  "release:patch": "release-it patch --ci --npm.publish",
48
47
  "release:minor": "release-it minor --ci --npm.publish --git.tag --github.release",
49
48
  "release:major": "release-it major --ci --npm.publish --git.tag --github.release",
50
- "lint": "eslint .",
51
- "lint:ci": "eslint --no-fix --max-warnings=0",
49
+ "lint": "eslint . --no-fix",
50
+ "lint:fix": "eslint . --fix",
51
+ "lint:ci": "eslint . --no-fix --max-warnings=0",
52
52
  "test": "vitest run",
53
53
  "test:watch": "vitest watch",
54
- "test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
55
- "install": "npx nuxi prepare"
54
+ "test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
56
55
  },
57
56
  "dependencies": {
58
- "@nuxt/kit": "^3.13.1",
59
- "@tailwindcss/vite": "^4.0.14",
60
- "tailwindcss": "^4.0.14",
61
- "vueless": "^0.0.825-beta.47"
57
+ "@nuxt/kit": "^3.17.4",
58
+ "vueless": "^1.0.1"
62
59
  },
63
60
  "devDependencies": {
64
- "@material-symbols/svg-500": "^0.29.1",
65
- "@nuxt/devtools": "^1.4.1",
66
- "@nuxt/eslint-config": "^0.5.7",
67
- "@nuxt/module-builder": "^0.8.4",
68
- "@nuxt/schema": "^3.13.2",
69
- "@nuxt/test-utils": "^3.14.1",
61
+ "@material-symbols/svg-500": "^0.31.4",
62
+ "@nuxt/devtools": "^2.4.1",
63
+ "@nuxt/eslint-config": "^1.4.1",
64
+ "@nuxt/module-builder": "^1.0.1",
65
+ "@nuxt/schema": "^3.17.4",
66
+ "@nuxt/test-utils": "^3.19.1",
70
67
  "@types/node": "latest",
71
68
  "changelogen": "^0.5.5",
72
- "eslint": "^9.12.0",
73
- "nuxt": "^3.15.4",
74
- "release-it": "^17.6.0",
69
+ "eslint": "^9.27.0",
70
+ "nuxt": "^3.17.4",
71
+ "release-it": "^19.0.2",
75
72
  "typescript": "latest",
76
- "vitest": "^3.0.5",
77
- "vue-tsc": "^2.1.6"
73
+ "vitest": "^3.1.4",
74
+ "vue-tsc": "^2.2.10"
78
75
  },
79
76
  "repository": {
80
77
  "type": "git",
@@ -82,6 +79,5 @@
82
79
  },
83
80
  "bugs": {
84
81
  "url": "https://github.com/vuelessjs/vueless-module-nuxt/issues"
85
- },
86
- "web-types": "./node_modules/vueless/web-types.json"
82
+ }
87
83
  }
package/dist/module.cjs DELETED
@@ -1,5 +0,0 @@
1
- module.exports = function(...args) {
2
- return import('./module.mjs').then(m => m.default.call(this, ...args))
3
- }
4
- const _meta = module.exports.meta = require('./module.json')
5
- module.exports.getMeta = () => Promise.resolve(_meta)
package/dist/module.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import * as _nuxt_schema from '@nuxt/schema';
2
-
3
- declare const _default: _nuxt_schema.NuxtModule<{
4
- mirrorCacheDir: string;
5
- debug: boolean;
6
- }, {
7
- mirrorCacheDir: string;
8
- debug: boolean;
9
- }, false>;
10
-
11
- export { _default as default };
package/dist/types.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import type { NuxtModule } from '@nuxt/schema'
2
-
3
- import type { default as Module } from './module'
4
-
5
- export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
-
7
- export { default } from './module'