@venix-sistemas/jade 1.1.0 → 1.3.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.
Files changed (64) hide show
  1. package/README.md +555 -228
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +89 -13
  4. package/dist/runtime/components/VenixThemeSwitcher.d.vue.ts +3 -1
  5. package/dist/runtime/components/VenixThemeSwitcher.vue +592 -106
  6. package/dist/runtime/components/VenixThemeSwitcher.vue.d.ts +3 -1
  7. package/dist/runtime/composables/useThemeColors.d.ts +8 -2
  8. package/dist/runtime/composables/useThemeColors.js +24 -9
  9. package/dist/runtime/composables/useThemeCookies.d.ts +17 -2
  10. package/dist/runtime/composables/useThemeCookies.js +44 -7
  11. package/dist/runtime/composables/useThemeLocale.d.ts +7 -2
  12. package/dist/runtime/composables/useThemeLocale.js +2 -2
  13. package/dist/runtime/composables/useThemeSeasonal.d.ts +3 -3
  14. package/dist/runtime/composables/useThemeSeasonal.js +1 -1
  15. package/dist/runtime/composables/useVenixTheme.d.ts +40 -0
  16. package/dist/runtime/composables/useVenixTheme.js +249 -112
  17. package/dist/runtime/nitro/theme-init.js +8 -5
  18. package/dist/runtime/plugins/overlay-scrollbars.client.js +89 -0
  19. package/dist/runtime/plugins/theme-init.server.js +7 -12
  20. package/dist/runtime/plugins/vuetify-theme.js +8 -11
  21. package/dist/runtime/scripts/theme-init.d.ts +33 -11
  22. package/dist/runtime/scripts/theme-init.js +59 -88
  23. package/dist/shared/constants.d.ts +72 -3
  24. package/dist/shared/constants.js +26 -1
  25. package/dist/shared/css/cursor-svg.d.ts +10 -0
  26. package/dist/shared/css/cursor-svg.js +28 -0
  27. package/dist/shared/css/cursor.js +86 -34
  28. package/dist/shared/css/index.d.ts +1 -7
  29. package/dist/shared/css/index.js +5 -5
  30. package/dist/shared/css/scrollbar.js +61 -7
  31. package/dist/shared/css/transition.d.ts +1 -1
  32. package/dist/shared/css/typography.js +13 -0
  33. package/dist/shared/theme.json +308 -192
  34. package/dist/shared/types/color-options.d.ts +26 -2
  35. package/dist/shared/types/colors.d.ts +64 -12
  36. package/dist/shared/types/cursor.d.ts +34 -4
  37. package/dist/shared/types/index.d.ts +3 -3
  38. package/dist/shared/types/runtime-config.d.ts +5 -2
  39. package/dist/shared/types/scrollbar.d.ts +11 -0
  40. package/dist/shared/types/theme.d.ts +7 -0
  41. package/dist/shared/types/typography.d.ts +2 -1
  42. package/dist/shared/utils/icon-refs.d.ts +7 -3
  43. package/dist/shared/utils/icon.d.ts +4 -2
  44. package/dist/shared/utils/icon.js +6 -2
  45. package/dist/shared/utils/index.d.ts +5 -4
  46. package/dist/shared/utils/index.js +12 -6
  47. package/dist/shared/utils/inline-script.d.ts +6 -0
  48. package/dist/shared/utils/inline-script.js +3 -0
  49. package/dist/shared/utils/load.d.ts +2 -3
  50. package/dist/shared/utils/load.js +6 -12
  51. package/dist/shared/utils/merge-themes.d.ts +39 -9
  52. package/dist/shared/utils/merge-themes.js +101 -5
  53. package/dist/shared/utils/normalize.d.ts +0 -11
  54. package/dist/shared/utils/normalize.js +0 -12
  55. package/dist/shared/utils/theme-config.d.ts +15 -6
  56. package/dist/shared/utils/theme-config.js +28 -16
  57. package/dist/shared/utils/theme-resolve.d.ts +23 -22
  58. package/dist/shared/utils/theme-resolve.js +35 -66
  59. package/dist/shared/utils/theme-resolver.d.ts +47 -0
  60. package/dist/shared/utils/theme-resolver.js +140 -0
  61. package/package.json +22 -10
  62. package/README-default.md +0 -84
  63. package/dist/runtime/plugin.js +0 -3
  64. /package/dist/runtime/{plugin.d.ts → plugins/overlay-scrollbars.client.d.ts} +0 -0
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@venix-sistemas/jade",
3
3
  "configKey": "venixTheme",
4
- "version": "1.1.0",
4
+ "version": "1.3.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.3",
7
7
  "unbuild": "unknown"
package/dist/module.mjs CHANGED
@@ -1,11 +1,12 @@
1
- import { addComponent, addPlugin, addServerPlugin, addTemplate, installModule, addImports, defineNuxtModule, createResolver } from '@nuxt/kit';
1
+ import { addComponent, addPlugin, addServerPlugin, addTemplate, useLogger, installModule, addImports, defineNuxtModule, createResolver } from '@nuxt/kit';
2
2
  import { loadTheme } from '../dist/shared/utils/load.js';
3
- import { DEFAULT_THEME, DEFAULT_LOCALE_COOKIE_NAME, DEFAULT_LOCALE } from '../dist/shared/constants.js';
3
+ import { SWITCHER_ICONS, DEFAULT_THEME, DEFAULT_LOCALE_COOKIE_NAME, DEFAULT_LOCALE } from '../dist/shared/constants.js';
4
4
  import { resolveFeatureOption } from '../dist/shared/utils/options.js';
5
- import { mergeColorThemes } from '../dist/shared/utils/merge-themes.js';
5
+ import { findDeprecatedThemeEntries } from '../dist/shared/utils/merge-themes.js';
6
+ import { buildResolvedTheme, getBaseThemeEntries } from '../dist/shared/utils/theme-config.js';
6
7
  import { processTheme } from '../dist/shared/css/index.js';
7
- import { isColorTheme, getThemeHexColors } from '../dist/shared/utils/theme-resolve.js';
8
8
  import { createRequire } from 'node:module';
9
+ import { isColorTheme, getThemeHexColors } from '../dist/shared/utils/theme-resolve.js';
9
10
  import { realpathSync } from 'node:fs';
10
11
  import { fileURLToPath } from 'node:url';
11
12
  import { join } from 'node:path';
@@ -17,6 +18,14 @@ function customizeTheme(baseTheme, options) {
17
18
  customized.typography = resolveFeatureOption(options.typography, customized.typography);
18
19
  customized.customScrollbar = resolveFeatureOption(options.scrollbar, customized.customScrollbar);
19
20
  customized.customCursor = resolveFeatureOption(options.cursor, customized.customCursor);
21
+ const cursorOption = typeof options.cursor === "object" && options.cursor !== null ? options.cursor : void 0;
22
+ if (cursorOption?.cursors) {
23
+ customized.customCursor.defaultCursors = cursorOption.defaultCursors ?? cursorOption.cursors;
24
+ }
25
+ delete customized.customCursor.cursors;
26
+ if (cursorOption?.themeCursors) {
27
+ customized.customCursor.themeCursors = { ...baseTheme.customCursor.themeCursors, ...cursorOption.themeCursors };
28
+ }
20
29
  const colorOption = options.color;
21
30
  if (colorOption === false) {
22
31
  customized.colors.enabled = false;
@@ -24,10 +33,12 @@ function customizeTheme(baseTheme, options) {
24
33
  if (colorOption.enabled === false) {
25
34
  customized.colors.enabled = false;
26
35
  }
27
- if (colorOption.defaultColor) {
28
- customized.colors.defaultColor = colorOption.defaultColor;
29
- }
30
- customized.colors.themes = mergeColorThemes(customized.colors.themes, colorOption.themes);
36
+ const resolved = buildResolvedTheme({
37
+ defaultTheme: colorOption.defaultColor || customized.colors.defaultColor,
38
+ colorThemes: colorOption.themes,
39
+ seasonal: colorOption.seasonal
40
+ });
41
+ customized.colors = { ...resolved.colors, enabled: customized.colors.enabled };
31
42
  }
32
43
  return customized;
33
44
  }
@@ -37,7 +48,10 @@ function registerPublicAssets(nuxt, resolver) {
37
48
  nuxt.options.nitro.publicAssets = nuxt.options.nitro.publicAssets || [];
38
49
  nuxt.options.nitro.publicAssets.push({
39
50
  dir: resolver.resolve("./runtime/public"),
40
- maxAge: 60 * 60 * 24 * 365,
51
+ // A week, not a year: these files (cursor images, fonts) keep the same
52
+ // URL across releases (no content hash), so a long cache would keep
53
+ // serving the old file for months after an update.
54
+ maxAge: 60 * 60 * 24 * 7,
41
55
  baseURL: "/"
42
56
  });
43
57
  }
@@ -57,7 +71,6 @@ function registerThemePlugins(_nuxt, resolver, shouldApplyColors) {
57
71
  });
58
72
  addServerPlugin(resolver.resolve("./runtime/nitro/theme-init"));
59
73
  }
60
- addPlugin(resolver.resolve("./runtime/plugin"));
61
74
  }
62
75
 
63
76
  function registerThemeCSS(nuxt, theme) {
@@ -72,6 +85,49 @@ function registerThemeCSS(nuxt, theme) {
72
85
  }
73
86
  }
74
87
 
88
+ const FONT_MIME_TYPES = {
89
+ woff2: "font/woff2",
90
+ woff: "font/woff",
91
+ truetype: "font/ttf",
92
+ opentype: "font/otf"
93
+ };
94
+ function getFontPreloadLinks(theme) {
95
+ if (theme.typography?.enabled === false) return [];
96
+ const links = [];
97
+ for (const font of theme.typography?.customFonts ?? []) {
98
+ if (!font.preload) continue;
99
+ const [format, href] = Object.entries(font.sources ?? {})[0] ?? [];
100
+ if (!format || !href) continue;
101
+ links.push({ rel: "preload", as: "font", href, type: FONT_MIME_TYPES[format] ?? `font/${format}`, crossorigin: "anonymous" });
102
+ }
103
+ return links;
104
+ }
105
+ function registerFontPreloads(nuxt, theme) {
106
+ const links = getFontPreloadLinks(theme);
107
+ if (!links.length) return;
108
+ nuxt.options.app.head.link = [...nuxt.options.app.head.link ?? [], ...links];
109
+ }
110
+
111
+ function resolveOverlayScrollbarsCSS() {
112
+ try {
113
+ return createRequire(import.meta.url).resolve("overlayscrollbars/overlayscrollbars.css");
114
+ } catch {
115
+ return null;
116
+ }
117
+ }
118
+ function registerOverlayScrollbars(nuxt, resolver, theme, resolveCSS = resolveOverlayScrollbarsCSS) {
119
+ const scrollbar = theme.customScrollbar;
120
+ if (scrollbar?.enabled === false || scrollbar?.overlay !== true) return;
121
+ const css = resolveCSS();
122
+ if (!css) {
123
+ useLogger("jade").warn("`scrollbar.overlay` needs the `overlayscrollbars` package, which isn't installed: run `pnpm add overlayscrollbars` (or npm/yarn). Using the CSS-styled native scrollbar meanwhile.");
124
+ scrollbar.overlay = false;
125
+ return;
126
+ }
127
+ nuxt.options.css.push(css);
128
+ addPlugin({ src: resolver.resolve("./runtime/plugins/overlay-scrollbars.client"), mode: "client" });
129
+ }
130
+
75
131
  function buildVuetifyThemes(colors) {
76
132
  const themes = {};
77
133
  for (const [name, themeColors] of Object.entries(colors.themes)) {
@@ -132,7 +188,12 @@ async function registerThemeIcon(nuxt, resolver, options, colors) {
132
188
  }
133
189
  const explicit = new Set(options.collections);
134
190
  const collections = options.collections.map((name) => loadFullCollection(name, projectRequire));
135
- const refs = extractIconRefs(colors.themes, options.aliases);
191
+ const labelled = [
192
+ ...Object.values(colors.groups ?? {}),
193
+ ...Object.values(colors.modes ?? {}),
194
+ ...Object.values(SWITCHER_ICONS).map((icon) => ({ icon }))
195
+ ];
196
+ const refs = extractIconRefs(labelled, options.aliases);
136
197
  for (const [name, iconNames] of refs) {
137
198
  if (explicit.has(name)) continue;
138
199
  collections.push(loadCollectionSubset(name, iconNames, projectRequire) ?? name);
@@ -182,8 +243,16 @@ const module$1 = defineNuxtModule({
182
243
  apply: true,
183
244
  defaultColor: theme.colors?.defaultColor || DEFAULT_THEME,
184
245
  themes: {},
185
- iconFormat: "svg"
246
+ iconFormat: "svg",
247
+ requireConsent: true,
248
+ seasonal: true
186
249
  });
250
+ for (const message of findDeprecatedThemeEntries(getBaseThemeEntries(), colorOptions.themes)) {
251
+ useLogger("jade").warn(message);
252
+ }
253
+ if (typeof options.cursor === "object" && options.cursor?.cursors) {
254
+ useLogger("jade").warn("`cursor.cursors` is deprecated and stops working in 2.0. Use `cursor.defaultCursors` instead.");
255
+ }
187
256
  const shouldApplyColors = colorOptions.enabled && colorOptions.apply && theme.colors?.defaults !== false;
188
257
  const translationOptions = resolveFeatureOption(options.translation, {
189
258
  enabled: true,
@@ -192,7 +261,9 @@ const module$1 = defineNuxtModule({
192
261
  cookieSync: DEFAULT_LOCALE_COOKIE_NAME,
193
262
  manageHtmlLang: false
194
263
  });
264
+ registerOverlayScrollbars(nuxt, resolver, theme);
195
265
  registerThemeCSS(nuxt, theme);
266
+ registerFontPreloads(nuxt, theme);
196
267
  registerThemePlugins(nuxt, resolver, shouldApplyColors);
197
268
  const vuetifyOptions = resolveFeatureOption(options.vuetify, {
198
269
  enabled: true
@@ -211,12 +282,17 @@ const module$1 = defineNuxtModule({
211
282
  localeCookie: translationOptions.cookieSync,
212
283
  defaultLocale: translationOptions.defaultLocale,
213
284
  locale: translationOptions.locale,
214
- iconFormat: colorOptions.iconFormat,
285
+ // Without the icon module, @nuxt/icon isn't installed — only emoji can render
286
+ iconFormat: iconOptions.enabled ? colorOptions.iconFormat : "emote",
287
+ requireConsent: colorOptions.requireConsent,
288
+ seasonal: colorOptions.seasonal,
215
289
  icon: {
216
290
  aliases: iconOptions.aliases
217
291
  },
218
292
  enabled: {
219
293
  typography: theme.typography?.enabled !== false,
294
+ // Something for the visitor to turn off (`font.available`)
295
+ customFont: theme.typography?.enabled !== false && !!theme.typography?.customFonts?.length,
220
296
  scrollbar: theme.customScrollbar?.enabled !== false,
221
297
  cursor: theme.customCursor?.enabled !== false,
222
298
  color: colorOptions.enabled,
@@ -1,8 +1,10 @@
1
1
  type __VLS_Props = {
2
2
  /** Accessible label for the button and the menu. Without a value, uses the component's own translation based on the current locale. */
3
3
  label?: string;
4
- /** Shows the active theme's name next to the icon on the button. */
4
+ /** Shows the active theme's and mode's names next to the icon on the button. */
5
5
  showLabel?: boolean;
6
+ /** Hides "Save changes" in the settings, for a site whose own cookie banner already records consent. */
7
+ hideConsent?: boolean;
6
8
  };
7
9
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
10
  declare const _default: typeof __VLS_export;