@vueless/nuxt 0.0.9-beta.2 → 0.0.9-beta.20

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.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.13.0"
6
6
  },
7
- "version": "0.0.9-beta.2",
7
+ "version": "0.0.9-beta.20",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
package/dist/module.mjs CHANGED
@@ -1,10 +1,21 @@
1
+ import path from 'node:path';
2
+ import { cwd } from 'node:process';
3
+ import fs from 'node:fs';
1
4
  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 { TailwindCSS, Vueless } from 'vueless/plugin-vite.js';
5
6
  import { getNuxtDirs } from 'vueless/utils/node/helper.js';
6
7
  import { createTailwindSafelist } from 'vueless/utils/node/tailwindSafelist.js';
8
+ import { COMPONENTS, VUELESS_CONFIG_FILE_NAME } from 'vueless/constants.js';
7
9
 
10
+
11
+
12
+ // -- Unbuild CommonJS Shims --
13
+ import __cjs_url__ from 'url';
14
+ import __cjs_path__ from 'path';
15
+ import __cjs_mod__ from 'module';
16
+ const __filename = __cjs_url__.fileURLToPath(import.meta.url);
17
+ const __dirname = __cjs_path__.dirname(__filename);
18
+ const require = __cjs_mod__.createRequire(import.meta.url);
8
19
  const module = defineNuxtModule({
9
20
  meta: {
10
21
  name: "@vueless/nuxt",
@@ -21,13 +32,14 @@ const module = defineNuxtModule({
21
32
  const { resolve } = createResolver(import.meta.url);
22
33
  const { mirrorCacheDir, debug } = _options;
23
34
  _nuxt.options.build.transpile.push("vueless");
24
- _nuxt.hook("vite:extendConfig", (config) => {
35
+ _nuxt.hook("vite:extendConfig", async (config) => {
25
36
  config.plugins = config.plugins || [];
26
37
  config.plugins.push(
27
38
  TailwindCSS(),
28
39
  Vueless({ mode: "nuxt-module", mirrorCacheDir, debug })
29
40
  );
30
41
  });
42
+ _nuxt.options.runtimeConfig.public.vueless = await getVuelessConfig();
31
43
  await createTailwindSafelist({
32
44
  targetFiles: getNuxtDirs()
33
45
  });
@@ -42,5 +54,28 @@ const module = defineNuxtModule({
42
54
  addImportsDir("vueless/utils");
43
55
  }
44
56
  });
57
+ async function getVuelessConfig() {
58
+ const esbuildPath = require.resolve("esbuild");
59
+ const esbuild = await import(esbuildPath);
60
+ const esbuildConfig = {
61
+ bundle: true,
62
+ platform: "node",
63
+ format: "esm",
64
+ target: "ESNext",
65
+ loader: { ".ts": "ts" },
66
+ write: false
67
+ };
68
+ const configPathJs = path.join(cwd(), `${VUELESS_CONFIG_FILE_NAME}.js`);
69
+ const configPathTs = path.join(cwd(), `${VUELESS_CONFIG_FILE_NAME}.ts`);
70
+ let result = null;
71
+ if (fs.existsSync(configPathJs)) {
72
+ result = await esbuild.build({ ...esbuildConfig, entryPoints: [configPathJs] });
73
+ }
74
+ if (fs.existsSync(configPathTs)) {
75
+ result = await esbuild.build({ ...esbuildConfig, entryPoints: [configPathTs] });
76
+ }
77
+ const code = result?.outputFiles?.[0]?.text || "";
78
+ return (await import(`data:text/javascript,${encodeURIComponent(code)}`)).default || {};
79
+ }
45
80
 
46
81
  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.2",
3
+ "version": "0.0.9-beta.20",
4
4
  "license": "MIT",
5
5
  "description": "Nuxt Styleless UI Component Library, powered by Tailwind CSS.",
6
6
  "keywords": [
@@ -58,7 +58,7 @@
58
58
  "@nuxt/kit": "^3.13.1",
59
59
  "@tailwindcss/vite": "^4.0.14",
60
60
  "tailwindcss": "^4.0.14",
61
- "vueless": "^0.0.825-beta.7"
61
+ "vueless": "^0.0.825-beta.60"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@material-symbols/svg-500": "^0.29.1",
@@ -70,7 +70,7 @@
70
70
  "@types/node": "latest",
71
71
  "changelogen": "^0.5.5",
72
72
  "eslint": "^9.12.0",
73
- "nuxt": "^3.15.4",
73
+ "nuxt": "^3.16.1",
74
74
  "release-it": "^17.6.0",
75
75
  "typescript": "latest",
76
76
  "vitest": "^3.0.5",
@@ -1,16 +1,37 @@
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";
3
+ import { ColorMode } from "vueless/types";
2
4
  import vClickOutside from "vueless/directives/clickOutside/vClickOutside";
3
5
  import vTooltip from "vueless/directives/tooltip/vTooltip";
6
+ import { useRuntimeConfig } from "#imports";
4
7
  import { defineNuxtPlugin } from "#app";
8
+ function parseCookies(cookieHeader) {
9
+ if (!cookieHeader) return {};
10
+ return cookieHeader.split(";").reduce((acc, cookie) => {
11
+ const [key, value] = cookie.trim().split("=");
12
+ if (key) acc[key] = value;
13
+ return acc;
14
+ }, {});
15
+ }
5
16
  export default defineNuxtPlugin((_nuxtApp) => {
6
- const vueless = createVueless();
17
+ const config = useRuntimeConfig().public.vueless;
18
+ const vueless = createVueless(config);
7
19
  _nuxtApp.vueApp.use(vueless, []);
8
20
  _nuxtApp.vueApp.directive("clickOutside", vClickOutside);
9
21
  _nuxtApp.vueApp.directive("tooltip", vTooltip);
10
22
  if (import.meta.server) {
11
- const themeRootVariables = setTheme();
23
+ const event = _nuxtApp.ssrContext?.event;
24
+ const cookies = parseCookies(event?.node.req.headers.cookie);
25
+ const primary = cookies?.[PRIMARY_COLOR_KEY];
26
+ const neutral = cookies?.[NEUTRAL_COLOR_KEY];
27
+ const rounding = cookies?.[ROUNDING_KEY];
28
+ const colorMode = cookies?.[COLOR_MODE_KEY];
29
+ const isCachedAutoMode = Boolean(Number(cookies?.[AUTO_MODE_KEY]));
30
+ const themeRootVariables = setTheme({ primary, neutral, rounding, colorMode }, isCachedAutoMode);
31
+ const colorModeClass = colorMode === ColorMode.Dark ? DARK_MODE_SELECTOR : LIGHT_MODE_SELECTOR;
12
32
  _nuxtApp.ssrContext?.head.push({
13
- style: [{ innerHTML: themeRootVariables }]
33
+ style: [{ innerHTML: themeRootVariables }],
34
+ htmlAttrs: { class: colorModeClass }
14
35
  });
15
36
  }
16
37
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vueless/nuxt",
3
- "version": "0.0.9-beta.2",
3
+ "version": "0.0.9-beta.20",
4
4
  "license": "MIT",
5
5
  "description": "Nuxt Styleless UI Component Library, powered by Tailwind CSS.",
6
6
  "keywords": [
@@ -58,7 +58,7 @@
58
58
  "@nuxt/kit": "^3.13.1",
59
59
  "@tailwindcss/vite": "^4.0.14",
60
60
  "tailwindcss": "^4.0.14",
61
- "vueless": "^0.0.825-beta.7"
61
+ "vueless": "^0.0.825-beta.60"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@material-symbols/svg-500": "^0.29.1",
@@ -70,7 +70,7 @@
70
70
  "@types/node": "latest",
71
71
  "changelogen": "^0.5.5",
72
72
  "eslint": "^9.12.0",
73
- "nuxt": "^3.15.4",
73
+ "nuxt": "^3.16.1",
74
74
  "release-it": "^17.6.0",
75
75
  "typescript": "latest",
76
76
  "vitest": "^3.0.5",