nuxt-cap 0.1.2 โ 1.0.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/README.md
CHANGED
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
<img src="https://img.shields.io/badge/gitmoji-%20๐%20๐-FFDD67" alt="Gitmoji"/>
|
|
13
13
|
</a>
|
|
14
14
|
</p>
|
|
15
|
+
<h2 align="center">
|
|
16
|
+
<a href="https://nuxt-cap.pages.dev/">
|
|
17
|
+
๐ Full Documentation
|
|
18
|
+
</a>
|
|
19
|
+
</h2>
|
|
15
20
|
|
|
16
21
|
## ๐ Setup
|
|
17
22
|
|
|
@@ -21,6 +26,25 @@ Install `nuxt-cap` dependency to your project:
|
|
|
21
26
|
npx nuxt module add nuxt-cap
|
|
22
27
|
```
|
|
23
28
|
|
|
29
|
+
Or manually
|
|
30
|
+
|
|
31
|
+
1. Install with your favorite package manager:
|
|
32
|
+
- **bun** : `bun add nuxt-cap`
|
|
33
|
+
- npm : `npm i nuxt-cap`
|
|
34
|
+
- pnpm : `pnpm add nuxt-cap`
|
|
35
|
+
- yarn : `yarn add nuxt-cap`
|
|
36
|
+
|
|
37
|
+
2. Add it to your `modules` section in your `nuxt.config`:
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
export default defineNuxtConfig({
|
|
41
|
+
modules: ['nuxt-cap'],
|
|
42
|
+
cap: {
|
|
43
|
+
// ...configs
|
|
44
|
+
},
|
|
45
|
+
})
|
|
46
|
+
```
|
|
47
|
+
|
|
24
48
|
## โ๏ธ Configuration
|
|
25
49
|
|
|
26
50
|
You can configure **nuxt-cap** in two ways:
|
|
@@ -55,8 +79,6 @@ This module auto-imports a component called:
|
|
|
55
79
|
<Cap />
|
|
56
80
|
```
|
|
57
81
|
|
|
58
|
-
---
|
|
59
|
-
|
|
60
82
|
## ๐ก Emits
|
|
61
83
|
|
|
62
84
|
The component exposes four events:
|
|
@@ -174,9 +196,9 @@ resetCap()
|
|
|
174
196
|
|
|
175
197
|
Calling `resetCap()` will reset the current widget state, allowing the challenge to be solved again.
|
|
176
198
|
|
|
177
|
-
##
|
|
199
|
+
## ๐ช useCap composable
|
|
178
200
|
|
|
179
|
-
|
|
201
|
+
You can use the `useCap()` composable for invisible mode.
|
|
180
202
|
|
|
181
203
|
It returns a Cap instance, similar to the one described in the official invisible guide:
|
|
182
204
|
|
package/dist/module.d.mts
CHANGED
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -2,7 +2,11 @@ import { defineNuxtModule, createResolver, addPlugin, addImports, addComponent }
|
|
|
2
2
|
|
|
3
3
|
const module$1 = defineNuxtModule({
|
|
4
4
|
meta: { name: "cap", configKey: "cap", compatibility: { nuxt: ">=3.0.0" } },
|
|
5
|
-
|
|
5
|
+
defaults: { enabled: true, apiEndpoint: "" },
|
|
6
|
+
setup({ enabled, apiEndpoint }, nuxt) {
|
|
7
|
+
if (!enabled) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
6
10
|
const resolver = createResolver(import.meta.url);
|
|
7
11
|
const { runtimeConfig } = nuxt.options;
|
|
8
12
|
runtimeConfig.public.cap ??= {};
|
|
@@ -9,6 +9,7 @@ const props = defineProps({
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const emit = defineEmits(["solve", "error", "reset", "progress"]);
|
|
12
|
+
const { cap } = useRuntimeConfig().public;
|
|
12
13
|
const capEl = ref();
|
|
13
14
|
function solve(event) {
|
|
14
15
|
emit("solve", event);
|
|
@@ -23,6 +24,11 @@ function progress(event) {
|
|
|
23
24
|
emit("progress", event);
|
|
24
25
|
}
|
|
25
26
|
onNuxtReady(() => {
|
|
27
|
+
if (!cap?.apiEndpoint) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
'[Cap] No API endpoint provided. Please set the "cap.apiEndpoint" runtime config or provide it in nuxt config.'
|
|
30
|
+
);
|
|
31
|
+
}
|
|
26
32
|
const el = capEl.value;
|
|
27
33
|
if (!el) return;
|
|
28
34
|
el.addEventListener("solve", solve);
|
|
@@ -38,7 +44,6 @@ onUnmounted(() => {
|
|
|
38
44
|
el.removeEventListener("reset", reset);
|
|
39
45
|
el.removeEventListener("progress", progress);
|
|
40
46
|
});
|
|
41
|
-
const { cap } = useRuntimeConfig().public;
|
|
42
47
|
</script>
|
|
43
48
|
|
|
44
49
|
<template>
|
|
@@ -3,6 +3,12 @@ export function useCap(config, el) {
|
|
|
3
3
|
const { $cap } = useNuxtApp();
|
|
4
4
|
const { cap } = useRuntimeConfig().public;
|
|
5
5
|
if (!import.meta.client || !$cap) return;
|
|
6
|
+
if (!cap?.apiEndpoint && !config?.apiEndpoint) {
|
|
7
|
+
console.error(
|
|
8
|
+
'[useCap] No API endpoint provided. Please set the "cap.apiEndpoint" runtime config or provide it in the config parameter.'
|
|
9
|
+
);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
6
12
|
const capInstance = new $cap({ apiEndpoint: cap?.apiEndpoint, ...config }, el);
|
|
7
13
|
return capInstance;
|
|
8
14
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { CapClass } from '../types/Cap.js';
|
|
2
2
|
import '@cap.js/widget';
|
|
3
3
|
declare global {
|
|
4
|
-
var Cap: CapClass;
|
|
4
|
+
var Cap: CapClass | undefined;
|
|
5
5
|
}
|
|
6
6
|
declare const _default: import("nuxt/app").Plugin<{
|
|
7
|
-
cap: typeof import("#imports").CapInstance;
|
|
7
|
+
cap: typeof import("#imports").CapInstance | undefined;
|
|
8
8
|
}> & import("nuxt/app").ObjectPlugin<{
|
|
9
|
-
cap: typeof import("#imports").CapInstance;
|
|
9
|
+
cap: typeof import("#imports").CapInstance | undefined;
|
|
10
10
|
}>;
|
|
11
11
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-cap",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "๐งข Integrate Cap into your Nuxt websites/applications.",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"
|
|
6
|
+
"cap",
|
|
7
7
|
"module",
|
|
8
8
|
"nuxt"
|
|
9
9
|
],
|
|
@@ -44,6 +44,8 @@
|
|
|
44
44
|
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
45
45
|
"dev:build": "nuxi build playground",
|
|
46
46
|
"build": "nuxt-module-build build",
|
|
47
|
+
"docs:dev": "vitepress dev docs",
|
|
48
|
+
"docs:build": "vitepress build docs",
|
|
47
49
|
"fmt": "oxfmt --check",
|
|
48
50
|
"fmt:fix": "oxfmt",
|
|
49
51
|
"lint": "oxlint --type-aware",
|
|
@@ -57,13 +59,15 @@
|
|
|
57
59
|
"@nuxt/kit": "^4.3.1"
|
|
58
60
|
},
|
|
59
61
|
"devDependencies": {
|
|
60
|
-
"@dethdkn/ox-config": "^1.0.
|
|
62
|
+
"@dethdkn/ox-config": "^1.0.12",
|
|
61
63
|
"@nuxt/module-builder": "^1.0.2",
|
|
62
64
|
"@nuxt/schema": "^4.3.1",
|
|
63
65
|
"@types/bun": "^1.3.9",
|
|
64
66
|
"bumpp": "^10.4.1",
|
|
65
67
|
"nuxt": "^4.3.1",
|
|
66
68
|
"typescript": "5.9.3",
|
|
69
|
+
"vitepress": "^1.6.4",
|
|
67
70
|
"vue-tsc": "^3.2.4"
|
|
68
|
-
}
|
|
71
|
+
},
|
|
72
|
+
"packageManager": "bun@1.3.9"
|
|
69
73
|
}
|