nuxt-cap 0.1.0 → 0.1.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.0.0",
7
+ "version": "0.1.0",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
@@ -1,8 +1,8 @@
1
1
  import { useNuxtApp, useRuntimeConfig } from "#app";
2
2
  export function useCap(config, el) {
3
- if (!import.meta.client) return;
4
3
  const { $cap } = useNuxtApp();
5
4
  const { cap } = useRuntimeConfig().public;
5
+ if (!import.meta.client || !$cap) return;
6
6
  const capInstance = new $cap({ apiEndpoint: cap?.apiEndpoint, ...config }, el);
7
7
  return capInstance;
8
8
  }
@@ -1,7 +1,11 @@
1
- import Cap from '@cap.js/widget';
1
+ import type CapClass from '@cap.js/widget';
2
+ import '@cap.js/widget';
3
+ declare global {
4
+ var Cap: typeof CapClass;
5
+ }
2
6
  declare const _default: import("nuxt/app").Plugin<{
3
- cap: typeof Cap;
7
+ cap: typeof CapClass;
4
8
  }> & import("nuxt/app").ObjectPlugin<{
5
- cap: typeof Cap;
9
+ cap: typeof CapClass;
6
10
  }>;
7
11
  export default _default;
@@ -1,7 +1,10 @@
1
1
  import { defineNuxtPlugin } from "#imports";
2
- import Cap from "@cap.js/widget";
3
- export default defineNuxtPlugin(() => ({
4
- provide: {
5
- cap: Cap
6
- }
7
- }));
2
+ import "@cap.js/widget";
3
+ export default defineNuxtPlugin(() => {
4
+ const { Cap } = globalThis;
5
+ return {
6
+ provide: {
7
+ cap: Cap
8
+ }
9
+ };
10
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-cap",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "🧢 Integrate Cap into your Nuxt websites/applications.",
5
5
  "keywords": [
6
6
  "cbpf",