nuxt-toastflow 1.0.0 โ 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 +86 -70
- package/dist/module.d.mts +20 -0
- package/dist/module.d.ts +20 -0
- package/dist/module.js +176 -0
- package/dist/module.json +12 -0
- package/{src/module.ts โ dist/module.mjs} +31 -64
- package/dist/runtime/composables/toast.d.ts +4 -0
- package/dist/runtime/composables/toast.js +14 -0
- package/dist/runtime/plugin.d.ts +2 -0
- package/dist/runtime/plugin.js +11 -0
- package/dist/types.d.mts +9 -0
- package/package.json +26 -11
- package/tsconfig.json +0 -4
package/README.md
CHANGED
|
@@ -1,70 +1,86 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="../../assets/banner.png" alt="Toastflow" width="100%" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">๐ nuxt-toastflow</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>Nuxt module for Toastflow</strong> โ auto-imports, SSR support, and zero-config setup.
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/nuxt-toastflow"><img src="https://img.shields.io/npm/v/nuxt-toastflow?color=00dc82&style=flat-square" alt="npm version" /></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/nuxt-toastflow"><img src="https://img.shields.io/npm/dm/nuxt-toastflow?style=flat-square" alt="npm downloads" /></a>
|
|
14
|
+
<a href="../../LICENSE"><img src="https://img.shields.io/github/license/adrianjanocko/toastflow?style=flat-square" alt="License" /></a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<p align="center">
|
|
18
|
+
<a href="https://docs.toastflow.top/">๐ Docs</a> ยท <a href="https://toastflow.top/">๐ฎ Playground</a> ยท <a href="https://docs.toastflow.top/comparisons/overview">โ๏ธ Comparisons</a>
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## ๐ Quick Start
|
|
24
|
+
|
|
25
|
+
**1. Install**
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pnpm add nuxt-toastflow
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**2. Add the module**
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
// nuxt.config.ts
|
|
35
|
+
export default defineNuxtConfig({
|
|
36
|
+
modules: ["nuxt-toastflow"],
|
|
37
|
+
toastflow: {
|
|
38
|
+
config: {
|
|
39
|
+
position: "top-right",
|
|
40
|
+
duration: 5000,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**3. Toast away ๐**
|
|
47
|
+
|
|
48
|
+
```vue
|
|
49
|
+
<!-- app.vue -->
|
|
50
|
+
<script setup lang="ts">
|
|
51
|
+
toast.success({
|
|
52
|
+
title: "Saved",
|
|
53
|
+
description: "Your changes are live.",
|
|
54
|
+
});
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<template>
|
|
58
|
+
<ToastContainer />
|
|
59
|
+
<NuxtPage />
|
|
60
|
+
</template>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
> ๐ก Both `toast` and `useToast()` are auto-imported โ no manual imports needed!
|
|
64
|
+
|
|
65
|
+
## โ๏ธ Module Options
|
|
66
|
+
|
|
67
|
+
| Option | Type | Default | Description |
|
|
68
|
+
| :----------------- | :--------------------- | :----------------: | :----------------------------------------- |
|
|
69
|
+
| ๐ ๏ธ `config` | `Partial<ToastConfig>` | `{}` | Toast configuration passed to the plugin |
|
|
70
|
+
| ๐จ `css` | `boolean` | `true` | Include default styles |
|
|
71
|
+
| ๐งฑ `componentName` | `string \| false` | `"ToastContainer"` | Auto-registered client-only component name |
|
|
72
|
+
|
|
73
|
+
<details>
|
|
74
|
+
<summary>๐ก <strong>How does it work under the hood?</strong></summary>
|
|
75
|
+
|
|
76
|
+
<br />
|
|
77
|
+
|
|
78
|
+
- `ToastContainer` is auto-registered as a **client-only** component
|
|
79
|
+
- `toast` and `useToast()` are **auto-imported** โ use either one
|
|
80
|
+
- Styles are injected automatically unless `css: false`
|
|
81
|
+
|
|
82
|
+
</details>
|
|
83
|
+
|
|
84
|
+
## ๐ License
|
|
85
|
+
|
|
86
|
+
[MIT](../../LICENSE) โ made with โค๏ธ by [@adrianjanocko](https://github.com/adrianjanocko)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
import { ToastConfig } from 'vue-toastflow';
|
|
3
|
+
|
|
4
|
+
interface NuxtToastflowOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Global Toastflow config passed to createToastflow.
|
|
7
|
+
*/
|
|
8
|
+
config: Partial<ToastConfig>;
|
|
9
|
+
/**
|
|
10
|
+
* Automatically include Toastflow CSS.
|
|
11
|
+
*/
|
|
12
|
+
css: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Auto-register ToastContainer under this name. Set false to disable.
|
|
15
|
+
*/
|
|
16
|
+
componentName: string | false;
|
|
17
|
+
}
|
|
18
|
+
declare const _default: _nuxt_schema.NuxtModule<NuxtToastflowOptions, NuxtToastflowOptions, false>;
|
|
19
|
+
|
|
20
|
+
export { type NuxtToastflowOptions, _default as default };
|
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
import { ToastConfig } from 'vue-toastflow';
|
|
3
|
+
|
|
4
|
+
interface NuxtToastflowOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Global Toastflow config passed to createToastflow.
|
|
7
|
+
*/
|
|
8
|
+
config: Partial<ToastConfig>;
|
|
9
|
+
/**
|
|
10
|
+
* Automatically include Toastflow CSS.
|
|
11
|
+
*/
|
|
12
|
+
css: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Auto-register ToastContainer under this name. Set false to disable.
|
|
15
|
+
*/
|
|
16
|
+
componentName: string | false;
|
|
17
|
+
}
|
|
18
|
+
declare const _default: _nuxt_schema.NuxtModule<NuxtToastflowOptions, NuxtToastflowOptions, false>;
|
|
19
|
+
|
|
20
|
+
export { type NuxtToastflowOptions, _default as default };
|
package/dist/module.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/module.ts
|
|
21
|
+
var module_exports = {};
|
|
22
|
+
__export(module_exports, {
|
|
23
|
+
default: () => module_default
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(module_exports);
|
|
26
|
+
var import_kit = require("@nuxt/kit");
|
|
27
|
+
function containsFunction(value, visited = /* @__PURE__ */ new Set()) {
|
|
28
|
+
if (typeof value === "function") {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
if (!value || typeof value !== "object") {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
if (visited.has(value)) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
visited.add(value);
|
|
38
|
+
if (Array.isArray(value)) {
|
|
39
|
+
return value.some(function(item) {
|
|
40
|
+
return containsFunction(item, visited);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
const objectValues = Object.values(value);
|
|
44
|
+
return objectValues.some(function(item) {
|
|
45
|
+
return containsFunction(item, visited);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
var module_default = (0, import_kit.defineNuxtModule)({
|
|
49
|
+
meta: {
|
|
50
|
+
name: "nuxt-toastflow",
|
|
51
|
+
configKey: "toastflow",
|
|
52
|
+
compatibility: {
|
|
53
|
+
nuxt: "^3.0.0 || ^4.0.0"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
defaults: {
|
|
57
|
+
config: {},
|
|
58
|
+
css: true,
|
|
59
|
+
componentName: "ToastContainer"
|
|
60
|
+
},
|
|
61
|
+
setup(options, nuxt) {
|
|
62
|
+
if (containsFunction(options.config)) {
|
|
63
|
+
console.warn(
|
|
64
|
+
"[nuxt-toastflow] Functions in `toastflow.config` are not serializable in nuxt.config and will be omitted."
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
let serializedConfig = "{}";
|
|
68
|
+
try {
|
|
69
|
+
serializedConfig = JSON.stringify(options.config ?? {}, null, 2) ?? "{}";
|
|
70
|
+
} catch {
|
|
71
|
+
throw new Error(
|
|
72
|
+
"[nuxt-toastflow] `toastflow.config` must be JSON-serializable."
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
(0, import_kit.addPluginTemplate)({
|
|
76
|
+
filename: "toastflow.mjs",
|
|
77
|
+
mode: "client",
|
|
78
|
+
getContents: function() {
|
|
79
|
+
return [
|
|
80
|
+
'import { createToastflow, toast } from "vue-toastflow";',
|
|
81
|
+
"",
|
|
82
|
+
"export default defineNuxtPlugin((nuxtApp) => {",
|
|
83
|
+
` nuxtApp.vueApp.use(createToastflow(${serializedConfig}));`,
|
|
84
|
+
"",
|
|
85
|
+
" return {",
|
|
86
|
+
" provide: {",
|
|
87
|
+
" toast,",
|
|
88
|
+
" },",
|
|
89
|
+
" };",
|
|
90
|
+
"});",
|
|
91
|
+
""
|
|
92
|
+
].join("\n");
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
const toastTemplate = (0, import_kit.addTemplate)({
|
|
96
|
+
filename: "toastflow/toast.ts",
|
|
97
|
+
getContents: function() {
|
|
98
|
+
return [
|
|
99
|
+
'import { useNuxtApp } from "#app";',
|
|
100
|
+
"",
|
|
101
|
+
'type ToastApi = typeof import("vue-toastflow")["toast"];',
|
|
102
|
+
"",
|
|
103
|
+
"export function useToast(): ToastApi {",
|
|
104
|
+
" return useNuxtApp().$toast;",
|
|
105
|
+
"}",
|
|
106
|
+
"",
|
|
107
|
+
"export const toast: ToastApi = new Proxy({} as ToastApi, {",
|
|
108
|
+
" get(_target, key) {",
|
|
109
|
+
" const currentToast = useNuxtApp().$toast as Record<PropertyKey, unknown>;",
|
|
110
|
+
" const value = currentToast[key];",
|
|
111
|
+
' if (typeof value === "function") {',
|
|
112
|
+
" return (value as (...args: unknown[]) => unknown).bind(currentToast);",
|
|
113
|
+
" }",
|
|
114
|
+
" return value;",
|
|
115
|
+
" },",
|
|
116
|
+
"});",
|
|
117
|
+
""
|
|
118
|
+
].join("\n");
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
(0, import_kit.addImports)({
|
|
122
|
+
name: "useToast",
|
|
123
|
+
from: toastTemplate.dst
|
|
124
|
+
});
|
|
125
|
+
(0, import_kit.addImports)({
|
|
126
|
+
name: "toast",
|
|
127
|
+
from: toastTemplate.dst
|
|
128
|
+
});
|
|
129
|
+
(0, import_kit.addTypeTemplate)({
|
|
130
|
+
filename: "types/nuxt-toastflow.d.ts",
|
|
131
|
+
getContents: function() {
|
|
132
|
+
return [
|
|
133
|
+
'type ToastApi = typeof import("vue-toastflow")["toast"];',
|
|
134
|
+
"",
|
|
135
|
+
'declare module "#app" {',
|
|
136
|
+
" interface NuxtApp {",
|
|
137
|
+
" $toast: ToastApi;",
|
|
138
|
+
" }",
|
|
139
|
+
"}",
|
|
140
|
+
"",
|
|
141
|
+
'declare module "vue" {',
|
|
142
|
+
" interface ComponentCustomProperties {",
|
|
143
|
+
" $toast: ToastApi;",
|
|
144
|
+
" }",
|
|
145
|
+
"}",
|
|
146
|
+
"",
|
|
147
|
+
"export {};",
|
|
148
|
+
""
|
|
149
|
+
].join("\n");
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
if (options.componentName) {
|
|
153
|
+
(0, import_kit.addComponent)({
|
|
154
|
+
name: options.componentName,
|
|
155
|
+
export: "ToastContainer",
|
|
156
|
+
filePath: "vue-toastflow",
|
|
157
|
+
mode: "client"
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
if (options.css) {
|
|
161
|
+
const cssEntry = "vue-toastflow/styles.css";
|
|
162
|
+
const hasCssEntry = nuxt.options.css.some(function(entry) {
|
|
163
|
+
if (typeof entry === "string") {
|
|
164
|
+
return entry === cssEntry;
|
|
165
|
+
}
|
|
166
|
+
if (Array.isArray(entry) && typeof entry[0] === "string") {
|
|
167
|
+
return entry[0] === cssEntry;
|
|
168
|
+
}
|
|
169
|
+
return false;
|
|
170
|
+
});
|
|
171
|
+
if (!hasCssEntry) {
|
|
172
|
+
nuxt.options.css.push(cssEntry);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
});
|
package/dist/module.json
ADDED
|
@@ -1,91 +1,64 @@
|
|
|
1
|
-
|
|
1
|
+
// src/module.ts
|
|
2
2
|
import {
|
|
3
3
|
addComponent,
|
|
4
4
|
addImports,
|
|
5
5
|
addPluginTemplate,
|
|
6
6
|
addTemplate,
|
|
7
7
|
addTypeTemplate,
|
|
8
|
-
defineNuxtModule
|
|
8
|
+
defineNuxtModule
|
|
9
9
|
} from "@nuxt/kit";
|
|
10
|
-
|
|
11
|
-
export interface NuxtToastflowOptions {
|
|
12
|
-
/**
|
|
13
|
-
* Global Toastflow config passed to createToastflow.
|
|
14
|
-
*/
|
|
15
|
-
config: Partial<ToastConfig>;
|
|
16
|
-
/**
|
|
17
|
-
* Automatically include Toastflow CSS.
|
|
18
|
-
*/
|
|
19
|
-
css: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Auto-register ToastContainer under this name. Set false to disable.
|
|
22
|
-
*/
|
|
23
|
-
componentName: string | false;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function containsFunction(
|
|
27
|
-
value: unknown,
|
|
28
|
-
visited: Set<unknown> = new Set(),
|
|
29
|
-
): boolean {
|
|
10
|
+
function containsFunction(value, visited = /* @__PURE__ */ new Set()) {
|
|
30
11
|
if (typeof value === "function") {
|
|
31
12
|
return true;
|
|
32
13
|
}
|
|
33
|
-
|
|
34
14
|
if (!value || typeof value !== "object") {
|
|
35
15
|
return false;
|
|
36
16
|
}
|
|
37
|
-
|
|
38
17
|
if (visited.has(value)) {
|
|
39
18
|
return false;
|
|
40
19
|
}
|
|
41
20
|
visited.add(value);
|
|
42
|
-
|
|
43
21
|
if (Array.isArray(value)) {
|
|
44
|
-
return value.some(function
|
|
22
|
+
return value.some(function(item) {
|
|
45
23
|
return containsFunction(item, visited);
|
|
46
24
|
});
|
|
47
25
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return objectValues.some(function (item: unknown): boolean {
|
|
26
|
+
const objectValues = Object.values(value);
|
|
27
|
+
return objectValues.some(function(item) {
|
|
52
28
|
return containsFunction(item, visited);
|
|
53
29
|
});
|
|
54
30
|
}
|
|
55
|
-
|
|
56
|
-
export default defineNuxtModule<NuxtToastflowOptions>({
|
|
31
|
+
var module_default = defineNuxtModule({
|
|
57
32
|
meta: {
|
|
58
33
|
name: "nuxt-toastflow",
|
|
59
34
|
configKey: "toastflow",
|
|
60
35
|
compatibility: {
|
|
61
|
-
nuxt: "^3.0.0 || ^4.0.0"
|
|
62
|
-
}
|
|
36
|
+
nuxt: "^3.0.0 || ^4.0.0"
|
|
37
|
+
}
|
|
63
38
|
},
|
|
64
39
|
defaults: {
|
|
65
40
|
config: {},
|
|
66
41
|
css: true,
|
|
67
|
-
componentName: "ToastContainer"
|
|
42
|
+
componentName: "ToastContainer"
|
|
68
43
|
},
|
|
69
44
|
setup(options, nuxt) {
|
|
70
45
|
if (containsFunction(options.config)) {
|
|
71
46
|
console.warn(
|
|
72
|
-
"[nuxt-toastflow] Functions in `toastflow.config` are not serializable in nuxt.config and will be omitted."
|
|
47
|
+
"[nuxt-toastflow] Functions in `toastflow.config` are not serializable in nuxt.config and will be omitted."
|
|
73
48
|
);
|
|
74
49
|
}
|
|
75
|
-
|
|
76
50
|
let serializedConfig = "{}";
|
|
77
51
|
try {
|
|
78
52
|
serializedConfig = JSON.stringify(options.config ?? {}, null, 2) ?? "{}";
|
|
79
53
|
} catch {
|
|
80
54
|
throw new Error(
|
|
81
|
-
"[nuxt-toastflow] `toastflow.config` must be JSON-serializable."
|
|
55
|
+
"[nuxt-toastflow] `toastflow.config` must be JSON-serializable."
|
|
82
56
|
);
|
|
83
57
|
}
|
|
84
|
-
|
|
85
58
|
addPluginTemplate({
|
|
86
59
|
filename: "toastflow.mjs",
|
|
87
60
|
mode: "client",
|
|
88
|
-
getContents: function
|
|
61
|
+
getContents: function() {
|
|
89
62
|
return [
|
|
90
63
|
'import { createToastflow, toast } from "vue-toastflow";',
|
|
91
64
|
"",
|
|
@@ -98,14 +71,13 @@ export default defineNuxtModule<NuxtToastflowOptions>({
|
|
|
98
71
|
" },",
|
|
99
72
|
" };",
|
|
100
73
|
"});",
|
|
101
|
-
""
|
|
74
|
+
""
|
|
102
75
|
].join("\n");
|
|
103
|
-
}
|
|
76
|
+
}
|
|
104
77
|
});
|
|
105
|
-
|
|
106
78
|
const toastTemplate = addTemplate({
|
|
107
79
|
filename: "toastflow/toast.ts",
|
|
108
|
-
getContents: function
|
|
80
|
+
getContents: function() {
|
|
109
81
|
return [
|
|
110
82
|
'import { useNuxtApp } from "#app";',
|
|
111
83
|
"",
|
|
@@ -119,30 +91,27 @@ export default defineNuxtModule<NuxtToastflowOptions>({
|
|
|
119
91
|
" get(_target, key) {",
|
|
120
92
|
" const currentToast = useNuxtApp().$toast as Record<PropertyKey, unknown>;",
|
|
121
93
|
" const value = currentToast[key];",
|
|
122
|
-
|
|
94
|
+
' if (typeof value === "function") {',
|
|
123
95
|
" return (value as (...args: unknown[]) => unknown).bind(currentToast);",
|
|
124
96
|
" }",
|
|
125
97
|
" return value;",
|
|
126
98
|
" },",
|
|
127
99
|
"});",
|
|
128
|
-
""
|
|
100
|
+
""
|
|
129
101
|
].join("\n");
|
|
130
|
-
}
|
|
102
|
+
}
|
|
131
103
|
});
|
|
132
|
-
|
|
133
104
|
addImports({
|
|
134
105
|
name: "useToast",
|
|
135
|
-
from: toastTemplate.dst
|
|
106
|
+
from: toastTemplate.dst
|
|
136
107
|
});
|
|
137
|
-
|
|
138
108
|
addImports({
|
|
139
109
|
name: "toast",
|
|
140
|
-
from: toastTemplate.dst
|
|
110
|
+
from: toastTemplate.dst
|
|
141
111
|
});
|
|
142
|
-
|
|
143
112
|
addTypeTemplate({
|
|
144
113
|
filename: "types/nuxt-toastflow.d.ts",
|
|
145
|
-
getContents: function
|
|
114
|
+
getContents: function() {
|
|
146
115
|
return [
|
|
147
116
|
'type ToastApi = typeof import("vue-toastflow")["toast"];',
|
|
148
117
|
"",
|
|
@@ -159,37 +128,35 @@ export default defineNuxtModule<NuxtToastflowOptions>({
|
|
|
159
128
|
"}",
|
|
160
129
|
"",
|
|
161
130
|
"export {};",
|
|
162
|
-
""
|
|
131
|
+
""
|
|
163
132
|
].join("\n");
|
|
164
|
-
}
|
|
133
|
+
}
|
|
165
134
|
});
|
|
166
|
-
|
|
167
135
|
if (options.componentName) {
|
|
168
136
|
addComponent({
|
|
169
137
|
name: options.componentName,
|
|
170
138
|
export: "ToastContainer",
|
|
171
139
|
filePath: "vue-toastflow",
|
|
172
|
-
mode: "client"
|
|
140
|
+
mode: "client"
|
|
173
141
|
});
|
|
174
142
|
}
|
|
175
|
-
|
|
176
143
|
if (options.css) {
|
|
177
|
-
const cssEntry = "vue-toastflow/
|
|
178
|
-
const hasCssEntry = nuxt.options.css.some(function
|
|
144
|
+
const cssEntry = "vue-toastflow/styles.css";
|
|
145
|
+
const hasCssEntry = nuxt.options.css.some(function(entry) {
|
|
179
146
|
if (typeof entry === "string") {
|
|
180
147
|
return entry === cssEntry;
|
|
181
148
|
}
|
|
182
|
-
|
|
183
149
|
if (Array.isArray(entry) && typeof entry[0] === "string") {
|
|
184
150
|
return entry[0] === cssEntry;
|
|
185
151
|
}
|
|
186
|
-
|
|
187
152
|
return false;
|
|
188
153
|
});
|
|
189
|
-
|
|
190
154
|
if (!hasCssEntry) {
|
|
191
155
|
nuxt.options.css.push(cssEntry);
|
|
192
156
|
}
|
|
193
157
|
}
|
|
194
|
-
}
|
|
158
|
+
}
|
|
195
159
|
});
|
|
160
|
+
export {
|
|
161
|
+
module_default as default
|
|
162
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useNuxtApp } from "#app";
|
|
2
|
+
export function useToast() {
|
|
3
|
+
return useNuxtApp().$toast;
|
|
4
|
+
}
|
|
5
|
+
export const toast = new Proxy({}, {
|
|
6
|
+
get(_target, key) {
|
|
7
|
+
const currentToast = useNuxtApp().$toast;
|
|
8
|
+
const value = currentToast[key];
|
|
9
|
+
if (typeof value === "function") {
|
|
10
|
+
return value.bind(currentToast);
|
|
11
|
+
}
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createToastflow, toast } from "vue-toastflow";
|
|
2
|
+
export default defineNuxtPlugin((nuxtApp) => {
|
|
3
|
+
const runtimeConfig = useRuntimeConfig();
|
|
4
|
+
const toastflowConfig = runtimeConfig.public.__nuxtToastflow ?? {};
|
|
5
|
+
nuxtApp.vueApp.use(createToastflow(toastflowConfig));
|
|
6
|
+
return {
|
|
7
|
+
provide: {
|
|
8
|
+
toast
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
});
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ModulePublicRuntimeConfig } from './module.mjs'
|
|
2
|
+
|
|
3
|
+
declare module '@nuxt/schema' {
|
|
4
|
+
interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export { default } from './module.mjs'
|
|
8
|
+
|
|
9
|
+
export { type ModuleOptions, type ModulePublicRuntimeConfig, type NuxtToastflowOptions } from './module.mjs'
|
package/package.json
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-toastflow",
|
|
3
3
|
"author": "adrianjanocko",
|
|
4
|
-
"description": "Nuxt
|
|
4
|
+
"description": "Nuxt module for Toastflow โ accessible, customizable toast notifications with auto-imports, SSR support, and CSS-first theming.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nuxt",
|
|
7
|
+
"nuxt-module",
|
|
7
8
|
"toast",
|
|
8
9
|
"toastflow",
|
|
10
|
+
"notifications",
|
|
9
11
|
"notification",
|
|
10
|
-
"
|
|
12
|
+
"toast-notifications",
|
|
13
|
+
"toaster",
|
|
14
|
+
"vue",
|
|
15
|
+
"typescript"
|
|
11
16
|
],
|
|
12
17
|
"license": "MIT",
|
|
13
18
|
"homepage": "https://toastflow.top/",
|
|
@@ -16,22 +21,32 @@
|
|
|
16
21
|
"url": "https://github.com/adrianjanocko/toastflow.git",
|
|
17
22
|
"directory": "packages/nuxt"
|
|
18
23
|
},
|
|
19
|
-
"version": "1.0.
|
|
20
|
-
"main": "
|
|
21
|
-
"module": "
|
|
22
|
-
"types": "
|
|
24
|
+
"version": "1.0.1",
|
|
25
|
+
"main": "./dist/module.js",
|
|
26
|
+
"module": "./dist/module.mjs",
|
|
27
|
+
"types": "./dist/module.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"import": {
|
|
31
|
+
"types": "./dist/module.d.mts",
|
|
32
|
+
"default": "./dist/module.mjs"
|
|
33
|
+
},
|
|
34
|
+
"require": {
|
|
35
|
+
"types": "./dist/module.d.ts",
|
|
36
|
+
"default": "./dist/module.js"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
23
40
|
"files": [
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"tsconfig.json",
|
|
27
|
-
"src"
|
|
41
|
+
"dist",
|
|
42
|
+
"README.md"
|
|
28
43
|
],
|
|
29
44
|
"peerDependencies": {
|
|
30
45
|
"nuxt": "^3.0.0 || ^4.0.0"
|
|
31
46
|
},
|
|
32
47
|
"dependencies": {
|
|
33
48
|
"@nuxt/kit": "^3.17.5",
|
|
34
|
-
"vue-toastflow": "^1.1.
|
|
49
|
+
"vue-toastflow": "^1.1.9"
|
|
35
50
|
},
|
|
36
51
|
"devDependencies": {
|
|
37
52
|
"tsup": "^8.5.1",
|
package/tsconfig.json
DELETED