@croct/plug-nuxt 0.2.0 → 0.2.1

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.0.0"
6
6
  },
7
- "version": "0.2.0",
7
+ "version": "0.2.1",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
package/dist/module.mjs CHANGED
@@ -68,8 +68,7 @@ const module = defineNuxtModule({
68
68
  getContents: () => clientOptionsCode
69
69
  });
70
70
  nuxt.options.alias["#croct/client-options"] = join(nuxt.options.buildDir, "croct/client-options");
71
- addPlugin(resolver.resolve("./runtime/plugin.server"));
72
- addPlugin(resolver.resolve("./runtime/plugin.client"));
71
+ addPlugin(resolver.resolve("./runtime/plugin"));
73
72
  addServerHandler({
74
73
  handler: resolver.resolve("./runtime/server/middleware/croct"),
75
74
  middleware: true
@@ -1,12 +1,14 @@
1
1
  import { createCroct } from "@croct/plug-vue";
2
- import { defineNuxtPlugin, useRuntimeConfig, useState } from "#app";
2
+ import { defineNuxtPlugin, useRuntimeConfig, useRequestEvent, useState } from "#app";
3
3
  import { urlSanitizer } from "#croct/client-options";
4
4
  export default defineNuxtPlugin((nuxtApp) => {
5
5
  const config = useRuntimeConfig().public.croct;
6
- const resolvedAppId = useState("croct:app-id").value;
7
- const appId = resolvedAppId !== void 0 && resolvedAppId !== "" ? resolvedAppId : config.appId;
6
+ const appId = useState("croct:app-id", () => {
7
+ const event = useRequestEvent();
8
+ return event?.context.croctCredentials?.appId ?? config.appId;
9
+ });
8
10
  const plugin = createCroct({
9
- appId,
11
+ appId: appId.value !== void 0 && appId.value !== "" ? appId.value : config.appId,
10
12
  disableCidMirroring: true,
11
13
  ...config.debug === true ? { debug: true } : {},
12
14
  ...config.test === true ? { test: true } : {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@croct/plug-nuxt",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Nuxt module to plug your Nuxt 3 applications into Croct.",
5
5
  "author": {
6
6
  "name": "Croct",
@@ -1,2 +0,0 @@
1
- declare const _default: import("#app").Plugin<Record<string, unknown>> & import("#app").ObjectPlugin<Record<string, unknown>>;
2
- export default _default;
@@ -1,6 +0,0 @@
1
- import { defineNuxtPlugin, useRuntimeConfig, useRequestEvent, useState } from "#app";
2
- export default defineNuxtPlugin(() => {
3
- const event = useRequestEvent();
4
- const fallback = useRuntimeConfig().public.croct.appId;
5
- useState("croct:app-id", () => event?.context.croctCredentials?.appId ?? fallback);
6
- });