@merkaly/nuxt 0.4.5 → 0.5.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
@@ -4,6 +4,10 @@ export { AdapterArgs, AdapterOptions } from '../dist/runtime/utils/withAdapter.j
4
4
  export { ApiOptions, HooksOptions, ParamsOptions, RefOptions } from '../dist/runtime/plugins/api.global.js';
5
5
 
6
6
  interface MerkalyModuleOptions {
7
+ api: {
8
+ url: string;
9
+ prefix?: string;
10
+ };
7
11
  auth0: {
8
12
  audience: string;
9
13
  callbackUrl: string;
@@ -17,12 +21,13 @@ interface MerkalyModuleOptions {
17
21
  domain: string;
18
22
  localhost: string;
19
23
  };
20
- api: {
21
- url: string;
22
- prefix?: string;
24
+ sentry: {
25
+ dsn: string;
26
+ project: string;
27
+ token: string;
23
28
  };
24
29
  }
25
- declare const _default: _nuxt_schema.NuxtModule<MerkalyModuleOptions, MerkalyModuleOptions, false>;
30
+ declare const merkalyModule: _nuxt_schema.NuxtModule<MerkalyModuleOptions, MerkalyModuleOptions, false>;
26
31
 
27
- export { _default as default };
32
+ export { merkalyModule as default };
28
33
  export type { MerkalyModuleOptions };
package/dist/module.json CHANGED
@@ -2,9 +2,9 @@
2
2
  "name": "@merkaly/nuxt",
3
3
  "configKey": "merkaly",
4
4
  "compatibility": {
5
- "nuxt": ">=3.0.0"
5
+ "nuxt": ">=3.14.0"
6
6
  },
7
- "version": "0.4.5",
7
+ "version": "0.5.0",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -1,83 +1,156 @@
1
- import { defineNuxtModule, createResolver, useLogger, addPlugin, addRouteMiddleware, addImportsDir, addComponentsDir, addTypeTemplate } from '@nuxt/kit';
2
- import { createJiti } from 'jiti';
1
+ import { defineNuxtModule, useLogger, createResolver, addPlugin, addRouteMiddleware, addImportsDir, addComponentsDir, addTypeTemplate } from '@nuxt/kit';
3
2
  import { defu } from 'defu';
3
+ import { createJiti } from 'jiti';
4
4
  import { existsSync } from 'node:fs';
5
5
  import svgLoader from 'vite-svg-loader';
6
6
  import 'reflect-metadata';
7
7
 
8
- const module = defineNuxtModule({
9
- defaults: {
10
- auth0: {
11
- audience: "",
12
- callbackUrl: "/auth",
13
- client: "",
14
- domain: "",
15
- logoutUrl: "/",
16
- params: {},
17
- requiresAuth: false
18
- },
19
- plausible: {
20
- domain: "",
21
- localhost: ""
22
- },
23
- api: {
24
- url: "/",
25
- prefix: "/"
26
- }
8
+ const defaultOptions = {
9
+ api: {
10
+ url: "/",
11
+ prefix: "/"
27
12
  },
28
- meta: { name: "@merkaly/nuxt", configKey: "merkaly", compatibility: { nuxt: ">=3.0.0" } },
29
- moduleDependencies(nuxt) {
30
- const dependencies = {
31
- "@bootstrap-vue-next/nuxt": {},
32
- "@nuxt/eslint": {},
33
- "@nuxt/fonts": {},
34
- "@nuxt/image": {},
35
- "@vueuse/nuxt": {}
36
- };
37
- if (nuxt.options.merkaly?.plausible) {
38
- dependencies["@nuxtjs/plausible"] = {};
39
- }
40
- return dependencies;
13
+ auth0: {
14
+ audience: "",
15
+ callbackUrl: "/auth",
16
+ client: "",
17
+ domain: "",
18
+ logoutUrl: "/",
19
+ params: {},
20
+ requiresAuth: false
41
21
  },
42
- async setup(options, nuxt) {
43
- const moduleResolver = createResolver(import.meta.url);
44
- const rootResolver = createResolver(nuxt.options.rootDir);
45
- nuxt.options.runtimeConfig.public.merkaly = defu(options, nuxt.options.runtimeConfig.public.merkaly || {});
46
- nuxt.options.plausible = defu({
22
+ plausible: {
23
+ domain: "",
24
+ localhost: ""
25
+ },
26
+ sentry: {
27
+ dsn: "",
28
+ project: "",
29
+ token: ""
30
+ }
31
+ };
32
+ function hasPlausibleConfig(options) {
33
+ return Boolean(options.plausible?.domain);
34
+ }
35
+ function buildModuleDependencies(options) {
36
+ const dependencies = {
37
+ "@bootstrap-vue-next/nuxt": {},
38
+ "@nuxt/eslint": {},
39
+ "@nuxt/fonts": {},
40
+ "@nuxt/image": {},
41
+ "@sentry/nuxt/module": {},
42
+ "@vueuse/nuxt": {}
43
+ };
44
+ if (hasPlausibleConfig(options)) {
45
+ dependencies["@nuxtjs/plausible"] = {};
46
+ }
47
+ const logger = useLogger("@merkaly/nuxt");
48
+ Object.keys(dependencies).forEach((it) => logger.info(`Loaded ${it} module`));
49
+ return dependencies;
50
+ }
51
+ function configureRuntimeConfig(nuxt, options) {
52
+ nuxt.options.runtimeConfig.public.merkaly = defu(
53
+ options,
54
+ nuxt.options.runtimeConfig.public.merkaly || {}
55
+ );
56
+ }
57
+ function configurePlausible(nuxt, options) {
58
+ nuxt.options.plausible = defu(
59
+ {
47
60
  apiHost: "https://analytics.merkaly.io",
48
61
  domain: options.plausible?.domain,
49
62
  enableAutoOutboundTracking: true,
50
63
  enableAutoPageviews: true,
51
- enabled: process.env.NODE_ENV === "production",
52
- // Solo en producción
53
- ignoredHostnames: ["localhost"].concat(options.plausible?.localhost || "").filter(Boolean)
54
- }, nuxt.options.plausible || {});
64
+ enabled: process.env.NODE_ENV === "production" && hasPlausibleConfig(options),
65
+ ignoredHostnames: ["localhost", options.plausible?.localhost].filter(Boolean)
66
+ },
67
+ nuxt.options.plausible || {}
68
+ );
69
+ }
70
+ function configureSentry(nuxt, options) {
71
+ nuxt.options.sentry = defu({
72
+ authToken: options.sentry.token,
73
+ org: "merkaly",
74
+ project: options.sentry.project
75
+ });
76
+ nuxt.options.sourcemap = { client: "hidden" };
77
+ }
78
+ async function loadBootstrapConfig(nuxt) {
79
+ const rootDirResolver = createResolver(nuxt.options.rootDir);
80
+ const bootstrapConfigPath = rootDirResolver.resolve("bootstrap.config.ts");
81
+ if (!existsSync(bootstrapConfigPath)) {
82
+ return {};
83
+ }
84
+ const jiti = createJiti(import.meta.url);
85
+ const imported = await jiti.import(bootstrapConfigPath).catch(() => ({}));
86
+ return imported.default || {};
87
+ }
88
+ function configureBootstrapVueNext(nuxt, components) {
89
+ nuxt.options.bootstrapVueNext = defu(
90
+ nuxt.options.bootstrapVueNext || {},
91
+ {
92
+ plugin: {
93
+ components
94
+ }
95
+ }
96
+ );
97
+ }
98
+ function registerRuntimeFeatures(nuxt, options, resolver) {
99
+ addPlugin({ src: resolver.resolve("./runtime/plugins/api.global") });
100
+ addPlugin({ src: resolver.resolve("./runtime/plugins/auth0.client") });
101
+ addPlugin({ src: resolver.resolve("./runtime/plugins/sentry.global") });
102
+ addRouteMiddleware({
103
+ global: options.auth0.requiresAuth,
104
+ name: "auth",
105
+ path: resolver.resolve("./runtime/middleware/auth")
106
+ });
107
+ addImportsDir(resolver.resolve("./runtime/composables"));
108
+ addImportsDir(resolver.resolve("./runtime/utils"));
109
+ addComponentsDir({
110
+ path: resolver.resolve("./runtime/components"),
111
+ prefix: "MK"
112
+ });
113
+ addTypeTemplate({
114
+ filename: "types/merkaly.d.ts",
115
+ src: resolver.resolve("./runtime/types/nuxt.d.ts")
116
+ });
117
+ }
118
+ function configureVite(nuxt) {
119
+ nuxt.options.vite = defu(
120
+ nuxt.options.vite || {},
121
+ {
122
+ plugins: [svgLoader()]
123
+ }
124
+ );
125
+ }
126
+ const merkalyModule = defineNuxtModule({
127
+ defaults: defaultOptions,
128
+ meta: {
129
+ name: "@merkaly/nuxt",
130
+ configKey: "merkaly",
131
+ compatibility: { nuxt: ">=3.14.0" }
132
+ },
133
+ moduleDependencies(nuxt) {
134
+ const options = defu(
135
+ nuxt.options.merkaly || {},
136
+ defaultOptions
137
+ );
138
+ return buildModuleDependencies(options);
139
+ },
140
+ async setup(options, nuxt) {
55
141
  const logger = useLogger("@merkaly/nuxt");
56
- const bootstrapConfigPath = rootResolver.resolve("bootstrap.config.ts");
57
- logger.info(`Loading bootstrap.config.ts from: ${bootstrapConfigPath} (exists: ${existsSync(bootstrapConfigPath)})`);
58
- const jiti = createJiti(import.meta.url);
59
- const BootstrapConfig = await jiti.import(bootstrapConfigPath).then((m) => m.default || {}).catch(() => ({}));
60
- logger.info(`Bootstrap config keys: ${Object.keys(BootstrapConfig).join(", ") || "(empty)"}`);
61
- nuxt.options["bootstrapVueNext"] = defu(nuxt.options["bootstrapVueNext"] || {}, { plugin: { components: BootstrapConfig } });
62
- addPlugin({ src: moduleResolver.resolve("./runtime/plugins/api.global") });
63
- addPlugin({ src: moduleResolver.resolve("./runtime/plugins/auth0.client"), mode: "client" });
64
- addRouteMiddleware({
65
- global: options.auth0.requiresAuth,
66
- name: "auth",
67
- path: moduleResolver.resolve("./runtime/middleware/auth")
68
- });
69
- addImportsDir(moduleResolver.resolve("./runtime/composables"));
70
- addImportsDir(moduleResolver.resolve("./runtime/utils"));
71
- addComponentsDir({
72
- path: moduleResolver.resolve("./runtime/components"),
73
- prefix: "MK"
74
- });
75
- nuxt.options["vite"] = defu(nuxt.options["vite"] || {}, { plugins: [svgLoader()] });
76
- addTypeTemplate({
77
- filename: "types/merkaly.d.ts",
78
- src: moduleResolver.resolve("./runtime/types/nuxt.d.ts")
79
- });
142
+ const resolver = createResolver(import.meta.url);
143
+ configureRuntimeConfig(nuxt, options);
144
+ configurePlausible(nuxt, options);
145
+ configureSentry(nuxt, options);
146
+ const bootstrapComponentsConfig = await loadBootstrapConfig(nuxt);
147
+ if (Object.keys(bootstrapComponentsConfig).length > 0) {
148
+ logger.info("Loading bootstrap.config.ts");
149
+ }
150
+ configureBootstrapVueNext(nuxt, bootstrapComponentsConfig);
151
+ registerRuntimeFeatures(nuxt, options, resolver);
152
+ configureVite(nuxt);
80
153
  }
81
154
  });
82
155
 
83
- export { module as default };
156
+ export { merkalyModule as default };
@@ -1,8 +1,8 @@
1
- declare var __VLS_11: {}, __VLS_13: {};
1
+ declare var __VLS_8: {}, __VLS_10: {};
2
2
  type __VLS_Slots = {} & {
3
- loading?: (props: typeof __VLS_11) => any;
3
+ loading?: (props: typeof __VLS_8) => any;
4
4
  } & {
5
- default?: (props: typeof __VLS_13) => any;
5
+ default?: (props: typeof __VLS_10) => any;
6
6
  };
7
7
  declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
8
8
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -3,9 +3,11 @@ import { useRoute } from "#app";
3
3
  import { useAuth, watchOnce, addRouteMiddleware, useNuxtApp } from "#imports";
4
4
  import AuthMiddleware from "../middleware/auth";
5
5
  import { useNavigation } from "../composables/useNavigation";
6
+ import { useColorMode } from "@vueuse/core";
6
7
  const $route = useRoute();
7
8
  const { isLoading } = useAuth();
8
9
  const { hook } = useNuxtApp();
10
+ useColorMode({ attribute: "data-bs-theme" });
9
11
  watchOnce(isLoading, () => AuthMiddleware($route, $route));
10
12
  const { defer, regenerate } = useNavigation();
11
13
  addRouteMiddleware("navigation", (to) => defer(to), { global: true });
@@ -13,10 +15,7 @@ hook("page:finish", () => regenerate());
13
15
  </script>
14
16
 
15
17
  <template>
16
- <main>
17
- <NuxtRouteAnnouncer />
18
- <BOrchestrator />
19
-
18
+ <BApp>
20
19
  <!-- Mostramos spinner mientras auth se carga -->
21
20
  <slot v-if="isLoading" name="loading" />
22
21
 
@@ -24,5 +23,5 @@ hook("page:finish", () => regenerate());
24
23
  <slot v-else>
25
24
  <NuxtPage />
26
25
  </slot>
27
- </main>
26
+ </BApp>
28
27
  </template>
@@ -1,8 +1,8 @@
1
- declare var __VLS_11: {}, __VLS_13: {};
1
+ declare var __VLS_8: {}, __VLS_10: {};
2
2
  type __VLS_Slots = {} & {
3
- loading?: (props: typeof __VLS_11) => any;
3
+ loading?: (props: typeof __VLS_8) => any;
4
4
  } & {
5
- default?: (props: typeof __VLS_13) => any;
5
+ default?: (props: typeof __VLS_10) => any;
6
6
  };
7
7
  declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
8
8
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;
@@ -0,0 +1,14 @@
1
+ import { defineNuxtPlugin } from "#app";
2
+ import { setUser } from "@sentry/nuxt";
3
+ export default defineNuxtPlugin(async ({ hook }) => {
4
+ hook("merkaly:auth", (user) => {
5
+ if (!user) {
6
+ return setUser(null);
7
+ }
8
+ return setUser({
9
+ id: user.sub,
10
+ email: user.email,
11
+ username: user.name
12
+ });
13
+ });
14
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@merkaly/nuxt",
3
- "version": "0.4.5",
3
+ "version": "0.5.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/merkaly-io/nuxt.git"
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@auth0/auth0-spa-js": "^2.17.0",
46
- "@bootstrap-vue-next/nuxt": "^0.43.0",
46
+ "@bootstrap-vue-next/nuxt": "^0.44.1",
47
47
  "@nuxt/devtools": "^3.2.1",
48
48
  "@nuxt/eslint": "1.15.1",
49
49
  "@nuxt/eslint-config": "^1.15.1",
@@ -51,6 +51,7 @@
51
51
  "@nuxt/image": "^2.0.0",
52
52
  "@nuxt/kit": "^4.4.2",
53
53
  "@nuxtjs/plausible": "^3.0.1",
54
+ "@sentry/nuxt": "^10.47.0",
54
55
  "@types/node": "latest",
55
56
  "@types/vue-select": "^3.16.8",
56
57
  "@vueuse/components": "^14.2.0",
@@ -58,7 +59,7 @@
58
59
  "@vueuse/integrations": "^14.2.0",
59
60
  "@vueuse/nuxt": "^14.2.0",
60
61
  "bootstrap": "^5.3.8",
61
- "bootstrap-vue-next": "^0.43.0",
62
+ "bootstrap-vue-next": "^0.44.1",
62
63
  "change-case": "^5",
63
64
  "class-transformer": "^0.5.1",
64
65
  "class-validator": "^0.15.1",