@avion-block/nuxt-mongoose 1.1.0-dev.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.
Files changed (33) hide show
  1. package/README.md +139 -0
  2. package/dist/client/200.html +1 -0
  3. package/dist/client/404.html +1 -0
  4. package/dist/client/_nuxt/Be_8YVmd.js +1 -0
  5. package/dist/client/_nuxt/BgqxMV_S.js +1 -0
  6. package/dist/client/_nuxt/BhG4bLuH.js +1 -0
  7. package/dist/client/_nuxt/C1_0osGQ.js +4 -0
  8. package/dist/client/_nuxt/DKP8g6aG.js +1 -0
  9. package/dist/client/_nuxt/DLYYGG6i.js +1 -0
  10. package/dist/client/_nuxt/Dg51sM1p.js +1 -0
  11. package/dist/client/_nuxt/builds/latest.json +1 -0
  12. package/dist/client/_nuxt/builds/meta/9f2a79dd-102e-4943-be21-dd8083c43b3d.json +1 -0
  13. package/dist/client/_nuxt/entry.Cp4I88Tv.css +1 -0
  14. package/dist/client/_nuxt/error-404.Dmi5Qu-g.css +1 -0
  15. package/dist/client/_nuxt/error-500.BMT8OSvZ.css +1 -0
  16. package/dist/client/_nuxt/index.DZHRaZYA.css +1 -0
  17. package/dist/client/index.html +1 -0
  18. package/dist/module.d.mts +43 -0
  19. package/dist/module.json +9 -0
  20. package/dist/module.mjs +413 -0
  21. package/dist/runtime/server/plugins/mongoose.db.d.ts +2 -0
  22. package/dist/runtime/server/plugins/mongoose.db.js +4 -0
  23. package/dist/runtime/server/services/connection.d.ts +5 -0
  24. package/dist/runtime/server/services/connection.js +24 -0
  25. package/dist/runtime/server/services/discriminator.d.ts +9 -0
  26. package/dist/runtime/server/services/discriminator.js +18 -0
  27. package/dist/runtime/server/services/index.d.ts +3 -0
  28. package/dist/runtime/server/services/index.js +3 -0
  29. package/dist/runtime/server/services/model.d.ts +8 -0
  30. package/dist/runtime/server/services/model.js +17 -0
  31. package/dist/runtime/server/tsconfig.json +3 -0
  32. package/dist/types.d.mts +3 -0
  33. package/package.json +88 -0
package/README.md ADDED
@@ -0,0 +1,139 @@
1
+ ![nuxt-mongoose](https://docs.arashsheyda.me/modules/nuxt-mongoose.jpg)
2
+
3
+ <div align="center">
4
+ <h1>Nuxt Mongoose</h1>
5
+
6
+ A Nuxt module for simplifying the use of Mongoose in your project.
7
+
8
+ </div>
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ npx nuxi@latest module add @avion-block/nuxt-mongoose
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ ### Setup
19
+
20
+ Add `@avion-block/nuxt-mongoose` to the `modules` section of your `nuxt.config.ts` file.
21
+
22
+ ```ts
23
+ export default defineNuxtConfig({
24
+ modules: ["@avion-block/nuxt-mongoose"],
25
+ });
26
+ ```
27
+
28
+ ### Configuration
29
+
30
+ You can configure the module by adding a `mongoose` section to your `nuxt.config` file:
31
+
32
+ ```ts
33
+ export default defineNuxtConfig({
34
+ mongoose: {
35
+ uri: process.env.MONGODB_URI,
36
+ options: {},
37
+ modelsDir: "models",
38
+ dnsServers: ["1.1.1.1", "1.0.0.1"],
39
+ },
40
+ });
41
+ ```
42
+
43
+ By default, `nuxt-mongoose` will auto-import your schemas from the `models` directory in the `server` directory. You can change this behavior by setting the `modelsDir` option.
44
+
45
+ ---
46
+
47
+ #### 🛠️ **Quick Setup Without Configuration**
48
+
49
+ If you prefer to use the default configuration, skip adding the `mongoose` section to your `nuxt.config.ts` file. Simply provide your MongoDB connection URI in a `.env` file like this:
50
+
51
+ ```env
52
+ MONGODB_URI="mongodb+srv://username:password@cluster0.mongodb.net/<database-name>?retryWrites=true&w=majority"
53
+ ```
54
+
55
+ > 🔹 Replace `username`, `password`, and `<database name>` with your MongoDB credentials and database name.
56
+
57
+ That's it! The module will automatically use the `MONGODB_URI` and default settings for your connection. No additional configuration is required.
58
+
59
+ ---
60
+
61
+ _For more details about connection options, check out the [Mongoose documentation](https://mongoosejs.com/docs/connections.html#options)._
62
+
63
+ ## API
64
+
65
+ ### defineMongooseConnection
66
+
67
+ This function creates a new Mongoose connection. Example usage:
68
+
69
+ ```ts
70
+ import { defineMongooseConnection } from "#nuxt/mongoose";
71
+
72
+ export const connection = defineMongooseConnection(
73
+ "mongodb://127.0.0.1/nuxt-mongoose",
74
+ );
75
+ ```
76
+
77
+ ### defineMongooseModel
78
+
79
+ This function creates a new Mongoose model with schema. Example usage:
80
+
81
+ ```ts
82
+ import { defineMongooseModel } from "#nuxt/mongoose";
83
+
84
+ export const User = defineMongooseModel("User", {
85
+ name: {
86
+ type: String,
87
+ required: true,
88
+ },
89
+ });
90
+ ```
91
+
92
+ **or you could use it like:**
93
+
94
+ ```ts
95
+ export const User = defineMongooseModel({
96
+ name: "User",
97
+ schema: {
98
+ name: {
99
+ type: String,
100
+ required: true,
101
+ },
102
+ },
103
+ });
104
+ ```
105
+
106
+ #### Connecting to an Existing Collection
107
+
108
+ If you need to connect to an **existing collection** in the database, you must specify the collection name using the `options` field. Otherwise, Mongoose will create a new collection based on the model name.
109
+
110
+ ```ts
111
+ import { defineMongooseModel } from "#nuxt/mongoose";
112
+
113
+ export const ProductSchema = defineMongooseModel({
114
+ name: "Product",
115
+ schema: {
116
+ name: { type: String, required: true },
117
+ price: { type: Number, required: true },
118
+ stock: { type: Number, default: 0 },
119
+ },
120
+ options: {
121
+ collection: "products_collection", // Ensure it uses the correct collection name
122
+ },
123
+ });
124
+ ```
125
+
126
+ ---
127
+
128
+ #### Important Notes
129
+
130
+ - Using the `options.collection` field ensures that the model interacts with the specified collection (`products_collection` in the example above).
131
+ - Without this option, a new collection will be created using the pluralized version of the model name (e.g., `Products`).
132
+
133
+ ### Configuration
134
+
135
+ For detailed [configuration](https://docs.arashsheyda.me/nuxt-mongoose/getting-started/configuration) and usage instructions, please refer to our [documentation](https://docs.arashsheyda.me/nuxt-mongoose).
136
+
137
+ ## License
138
+
139
+ [MIT License](./LICENSE)
@@ -0,0 +1 @@
1
+ <!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__nuxt-mongoose/_nuxt/entry.Cp4I88Tv.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-mongoose/_nuxt/C1_0osGQ.js"><script type="module" src="/__nuxt-mongoose/_nuxt/C1_0osGQ.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-mongoose",buildId:"9f2a79dd-102e-4943-be21-dd8083c43b3d",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1772769622174,false]</script></body></html>
@@ -0,0 +1 @@
1
+ <!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__nuxt-mongoose/_nuxt/entry.Cp4I88Tv.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-mongoose/_nuxt/C1_0osGQ.js"><script type="module" src="/__nuxt-mongoose/_nuxt/C1_0osGQ.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-mongoose",buildId:"9f2a79dd-102e-4943-be21-dd8083c43b3d",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1772769622174,false]</script></body></html>
@@ -0,0 +1 @@
1
+ import{_ as m,o as n,c as a,r as d,e as g,f as b,w as i,a as u,n as p,t as s,F as h,q as C,b as v,d as $,x as N,j as f}from"./C1_0osGQ.js";import{c as k,r as j}from"./BhG4bLuH.js";const w={},P={class:"n-card n-card-base"};function S(e,t){return n(),a("div",P,[d(e.$slots,"default")])}const B=Object.assign(m(w,[["render",S]]),{__name:"NCard"}),D={},G={class:"n-panel-grids-center"};function O(e,t){return n(),a("div",G,[d(e.$slots,"default")])}const V=Object.assign(m(D,[["render",O]]),{__name:"NPanelGrids"}),E={absolute:"","bottom-10":"","left-10":"","right-10":"",flex:"","justify-around":""},F=g({__name:"Connection",props:{code:{type:Number,default:0}},setup(e){const t=e,r=[{color:"text-red-5",border:"border-red-5",status:"Not Connected",description:"Please Check Your Connection!"},{color:"text-green-5",border:"border-green-5",status:"Connected",description:"Everything is Working Perfectly!"},{color:"text-yellow-5",border:"border-yellow-5",status:"Connecting",description:'Just a Moment, We"re Getting There!'},{color:"text-orange-5",border:"border-orange-5",status:"Disconnecting",description:"Preparing to Safely Disconnect!"}],o=N(()=>r[t.code]);return(l,q)=>{const x=B,y=V;return n(),b(y,null,{default:i(()=>[u("div",{flex:"~ gap-2","animate-pulse":"","items-center":"","text-lg":"","font-bold":"",class:p(o.value.color)}," ("+s(e.code)+"): "+s(o.value.status)+", "+s(o.value.description),3),u("div",E,[(n(),a(h,null,C(r,(c,_)=>v(x,{key:_,p2:"",class:p([c.color,c.status===o.value.status?c.border:""])},{default:i(()=>[$(" ("+s(_)+"): "+s(c.status),1)]),_:2},1032,["class"])),64))])]),_:1})}}}),T=Object.assign(F,{__name:"Connection"}),W={"h-full":"","of-auto":""},J=g({__name:"default",setup(e){const t=k(async()=>await j.value?.readyState());return(r,o)=>{const l=T;return n(),a("div",W,[f(t)===1?d(r.$slots,"default",{key:0}):(n(),b(l,{key:1,code:f(t)},null,8,["code"]))])}}});export{J as default};
@@ -0,0 +1 @@
1
+ import{_ as o,u as s,o as a,c as i,a as t,t as r}from"./C1_0osGQ.js";const u={class:"antialiased bg-white dark:bg-[#020420] dark:text-white font-sans grid min-h-screen overflow-hidden place-content-center text-[#020420] tracking-wide"},l={class:"max-w-520px text-center"},c=["textContent"],d=["textContent"],p=["textContent"],f={__name:"error-500",props:{appName:{type:String,default:"Nuxt"},status:{type:Number,default:500},statusText:{type:String,default:"Internal server error"},description:{type:String,default:"This page is temporarily unavailable."},refresh:{type:String,default:"Refresh this page"}},setup(e){const n=e;return s({title:`${n.status} - ${n.statusText} | ${n.appName}`,script:[{innerHTML:`!function(){const e=document.createElement("link").relList;if(!(e&&e.supports&&e.supports("modulepreload"))){for(const e of document.querySelectorAll('link[rel="modulepreload"]'))r(e);new MutationObserver(e=>{for(const o of e)if("childList"===o.type)for(const e of o.addedNodes)"LINK"===e.tagName&&"modulepreload"===e.rel&&r(e)}).observe(document,{childList:!0,subtree:!0})}function r(e){if(e.ep)return;e.ep=!0;const r=function(e){const r={};return e.integrity&&(r.integrity=e.integrity),e.referrerPolicy&&(r.referrerPolicy=e.referrerPolicy),"use-credentials"===e.crossOrigin?r.credentials="include":"anonymous"===e.crossOrigin?r.credentials="omit":r.credentials="same-origin",r}(e);fetch(e.href,r)}}();`}],style:[{innerHTML:'*,:after,:before{border-color:var(--un-default-border-color,#e5e7eb);border-style:solid;border-width:0;box-sizing:border-box}:after,:before{--un-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}h1,h2{font-size:inherit;font-weight:inherit}h1,h2,p{margin:0}*,:after,:before{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 transparent;--un-ring-shadow:0 0 transparent;--un-shadow-inset: ;--un-shadow:0 0 transparent;--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgba(147,197,253,.5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }'}]}),(h,m)=>(a(),i("div",u,[t("div",l,[t("h1",{class:"font-semibold leading-none mb-4 sm:text-[110px] tabular-nums text-[80px]",textContent:r(e.status)},null,8,c),t("h2",{class:"font-semibold mb-2 sm:text-3xl text-2xl",textContent:r(e.statusText)},null,8,d),t("p",{class:"mb-4 px-2 text-[#64748B] text-md",textContent:r(e.description)},null,8,p)])]))}},g=o(f,[["__scopeId","data-v-a4e04bd5"]]);export{g as default};
@@ -0,0 +1 @@
1
+ import{a5 as ie,W as x,a6 as _,a7 as re,a8 as se,p as N,C as G,I as j,B as k,a9 as V,N as ue,aa as ae,y as R,ab as le,x as C,k as ce,j as fe,ac as de}from"./C1_0osGQ.js";function X(e,t){return re()?(se(e,t),!0):!1}const B=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const ve=e=>typeof e<"u",pe=Object.prototype.toString,me=e=>pe.call(e)==="[object Object]",P=()=>{};function ge(...e){if(e.length!==1)return ue(...e);const t=e[0];return typeof t=="function"?V(ae(()=>({get:t,set:P}))):R(t)}function he(e,t){function o(...n){return new Promise((s,i)=>{Promise.resolve(e(()=>t.apply(this,n),{fn:t,thisArg:this,args:n})).then(s).catch(i)})}return o}const K=e=>e();function ye(e=K,t={}){const{initialState:o="active"}=t,n=ge(o==="active");function s(){n.value=!1}function i(){n.value=!0}const l=(...c)=>{n.value&&e(...c)};return{isActive:V(n),pause:s,resume:i,eventFilter:l}}function we(e){let t;function o(){return t||(t=e()),t}return o.reset=async()=>{const n=t;t=void 0,n&&await n},o}function D(e){return Array.isArray(e)?e:[e]}function Se(e){return k()}function be(e,t,o={}){const{eventFilter:n=K,...s}=o;return N(e,he(n,t),s)}function Ee(e,t,o={}){const{eventFilter:n,initialState:s="active",...i}=o,{eventFilter:l,pause:c,resume:h,isActive:p}=ye(n,{initialState:s});return{stop:be(e,t,{...i,eventFilter:l}),pause:c,resume:h,isActive:p}}function Q(e,t=!0,o){Se()?G(e,o):t?e():j(e)}function _e(e,t,o={}){const{immediate:n=!0,immediateCallback:s=!1}=o,i=x(!1);let l;function c(){l&&(clearTimeout(l),l=void 0)}function h(){i.value=!1,c()}function p(...m){s&&e(),c(),i.value=!0,l=setTimeout(()=>{i.value=!1,l=void 0,e(...m)},_(t))}return n&&(i.value=!0,B&&p()),X(h),{isPending:ie(i),start:p,stop:h}}function Oe(e,t,o){return N(e,t,{...o,immediate:!0})}function ke(e,t,o){var n;let s;ce(o)?s={evaluating:o}:s=o||{};const{lazy:i=!1,flush:l="sync",evaluating:c=void 0,shallow:h=!0,onError:p=(n=globalThis.reportError)!==null&&n!==void 0?n:P}=s,m=x(!i),r=h?x(t):R(t);let g=0;return le(async y=>{if(!m.value)return;g++;const w=g;let S=!1;c&&Promise.resolve().then(()=>{c.value=!0});try{const a=await e(f=>{y(()=>{c&&(c.value=!1),S||f()})});w===g&&(r.value=a)}catch(a){p(a)}finally{c&&w===g&&(c.value=!1),S=!0}},{flush:l}),i?C(()=>(m.value=!0,r.value)):r}const A=B?window:void 0,Y=B?window.navigator:void 0;function T(e){var t;const o=_(e);return(t=o?.$el)!==null&&t!==void 0?t:o}function $(...e){const t=(n,s,i,l)=>(n.addEventListener(s,i,l),()=>n.removeEventListener(s,i,l)),o=C(()=>{const n=D(_(e[0])).filter(s=>s!=null);return n.every(s=>typeof s!="string")?n:void 0});return Oe(()=>{var n,s;return[(n=(s=o.value)===null||s===void 0?void 0:s.map(i=>T(i)))!==null&&n!==void 0?n:[A].filter(i=>i!=null),D(_(o.value?e[1]:e[0])),D(fe(o.value?e[2]:e[1])),_(o.value?e[3]:e[2])]},([n,s,i,l],c,h)=>{if(!n?.length||!s?.length||!i?.length)return;const p=me(l)?{...l}:l,m=n.flatMap(r=>s.flatMap(g=>i.map(y=>t(r,g,y,p))));h(()=>{m.forEach(r=>r())})},{flush:"post"})}function Be(e,t,o={}){const{window:n=A,ignore:s=[],capture:i=!0,detectIframe:l=!1,controls:c=!1}=o;if(!n)return c?{stop:P,cancel:P,trigger:P}:P;let h=!0;const p=a=>_(s).some(f=>{if(typeof f=="string")return Array.from(n.document.querySelectorAll(f)).some(u=>u===a.target||a.composedPath().includes(u));{const u=T(f);return u&&(a.target===u||a.composedPath().includes(u))}});function m(a){const f=_(a);return f&&f.$.subTree.shapeFlag===16}function r(a,f){const u=_(a),v=u.$.subTree&&u.$.subTree.children;return v==null||!Array.isArray(v)?!1:v.some(b=>b.el===f.target||f.composedPath().includes(b.el))}const g=a=>{const f=T(e);if(a.target!=null&&!(!(f instanceof Element)&&m(e)&&r(e,a))&&!(!f||f===a.target||a.composedPath().includes(f))){if("detail"in a&&a.detail===0&&(h=!p(a)),!h){h=!0;return}t(a)}};let y=!1;const w=[$(n,"click",a=>{y||(y=!0,setTimeout(()=>{y=!1},0),g(a))},{passive:!0,capture:i}),$(n,"pointerdown",a=>{const f=T(e);h=!p(a)&&!!(f&&!a.composedPath().includes(f))},{passive:!0}),l&&$(n,"blur",a=>{setTimeout(()=>{var f;const u=T(e);((f=n.document.activeElement)===null||f===void 0?void 0:f.tagName)==="IFRAME"&&!u?.contains(n.document.activeElement)&&t(a)},0)},{passive:!0})].filter(Boolean),S=()=>w.forEach(a=>a());return c?{stop:S,cancel:()=>{h=!1},trigger:a=>{h=!0,g(a),h=!1}}:S}function Te(){const e=x(!1),t=k();return t&&G(()=>{e.value=!0},t),e}function J(e){const t=Te();return C(()=>(t.value,!!e()))}function H(e,t={}){const{controls:o=!1,navigator:n=Y}=t,s=J(()=>n&&"permissions"in n),i=x(),l=typeof e=="string"?{name:e}:e,c=x(),h=()=>{var m,r;c.value=(m=(r=i.value)===null||r===void 0?void 0:r.state)!==null&&m!==void 0?m:"prompt"};$(i,"change",h,{passive:!0});const p=we(async()=>{if(s.value){if(!i.value)try{i.value=await n.permissions.query(l)}catch{i.value=void 0}finally{h()}if(o)return de(i.value)}});return p(),o?{state:c,isSupported:s,query:p}:c}function Je(e={}){const{navigator:t=Y,read:o=!1,source:n,copiedDuring:s=1500,legacy:i=!1}=e,l=J(()=>t&&"clipboard"in t),c=H("clipboard-read"),h=H("clipboard-write"),p=C(()=>l.value||i),m=x(""),r=x(!1),g=_e(()=>r.value=!1,s,{immediate:!1});async function y(){let u=!(l.value&&f(c.value));if(!u)try{m.value=await t.clipboard.readText()}catch{u=!0}u&&(m.value=a())}p.value&&o&&$(["copy","cut"],y,{passive:!0});async function w(u=_(n)){if(p.value&&u!=null){let v=!(l.value&&f(h.value));if(!v)try{await t.clipboard.writeText(u)}catch{v=!0}v&&S(u),m.value=u,r.value=!0,g.start()}}function S(u){const v=document.createElement("textarea");v.value=u,v.style.position="absolute",v.style.opacity="0",v.setAttribute("readonly",""),document.body.appendChild(v),v.select(),document.execCommand("copy"),v.remove()}function a(){var u,v,b;return(u=(v=document)===null||v===void 0||(b=v.getSelection)===null||b===void 0||(b=b.call(v))===null||b===void 0?void 0:b.toString())!==null&&u!==void 0?u:""}function f(u){return u==="granted"||u==="prompt"}return{isSupported:p,text:V(m),copied:V(r),copy:w}}function xe(e){return JSON.parse(JSON.stringify(e))}const W=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},z="__vueuse_ssr_handlers__",Ae=Ce();function Ce(){return z in W||(W[z]=W[z]||{}),W[z]}function $e(e,t){return Ae[e]||t}function Ne(e){return e==null?"any":e instanceof Set?"set":e instanceof Map?"map":e instanceof Date?"date":typeof e=="boolean"?"boolean":typeof e=="string"?"string":typeof e=="object"?"object":Number.isNaN(e)?"any":"number"}const Re={boolean:{read:e=>e==="true",write:e=>String(e)},object:{read:e=>JSON.parse(e),write:e=>JSON.stringify(e)},number:{read:e=>Number.parseFloat(e),write:e=>String(e)},any:{read:e=>e,write:e=>String(e)},string:{read:e=>e,write:e=>String(e)},map:{read:e=>new Map(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e.entries()))},set:{read:e=>new Set(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e))},date:{read:e=>new Date(e),write:e=>e.toISOString()}},q="vueuse-storage";function Pe(e,t,o,n={}){var s;const{flush:i="pre",deep:l=!0,listenToStorageChanges:c=!0,writeDefaults:h=!0,mergeDefaults:p=!1,shallow:m,window:r=A,eventFilter:g,onError:y=d=>{console.error(d)},initOnMounted:w}=n,S=(m?x:R)(typeof t=="function"?t():t),a=C(()=>_(e));if(!o)try{o=$e("getDefaultStorage",()=>A?.localStorage)()}catch(d){y(d)}if(!o)return S;const f=_(t),u=Ne(f),v=(s=n.serializer)!==null&&s!==void 0?s:Re[u],{pause:b,resume:I}=Ee(S,d=>te(d),{flush:i,deep:l,eventFilter:g});N(a,()=>F(),{flush:i});let L=!1;const Z=d=>{w&&!L||F(d)},ee=d=>{w&&!L||oe(d)};r&&c&&(o instanceof Storage?$(r,"storage",Z,{passive:!0}):$(r,q,ee)),w?Q(()=>{L=!0,F()}):F();function U(d,E){if(r){const O={key:a.value,oldValue:d,newValue:E,storageArea:o};r.dispatchEvent(o instanceof Storage?new StorageEvent("storage",O):new CustomEvent(q,{detail:O}))}}function te(d){try{const E=o.getItem(a.value);if(d==null)U(E,null),o.removeItem(a.value);else{const O=v.write(d);E!==O&&(o.setItem(a.value,O),U(E,O))}}catch(E){y(E)}}function ne(d){const E=d?d.newValue:o.getItem(a.value);if(E==null)return h&&f!=null&&o.setItem(a.value,v.write(f)),f;if(!d&&p){const O=v.read(E);return typeof p=="function"?p(O,f):u==="object"&&!Array.isArray(O)?{...f,...O}:O}else return typeof E!="string"?E:v.read(E)}function F(d){if(!(d&&d.storageArea!==o)){if(d&&d.key==null){S.value=f;return}if(!(d&&d.key!==a.value)){b();try{const E=v.write(S.value);(d===void 0||d?.newValue!==E)&&(S.value=ne(d))}catch(E){y(E)}finally{d?j(I):I()}}}}function oe(d){F(d.detail)}return S}function Fe(e,t,o={}){const{window:n=A,...s}=o;let i;const l=J(()=>n&&"ResizeObserver"in n),c=()=>{i&&(i.disconnect(),i=void 0)},h=N(C(()=>{const m=_(e);return Array.isArray(m)?m.map(r=>T(r)):[T(m)]}),m=>{if(c(),l.value&&n){i=new ResizeObserver(t);for(const r of m)r&&i.observe(r,s)}},{immediate:!0,flush:"post"}),p=()=>{c(),h()};return X(p),{isSupported:l,stop:p}}function Ie(e,t={width:0,height:0},o={}){const{window:n=A,box:s="content-box"}=o,i=C(()=>{var r;return(r=T(e))===null||r===void 0||(r=r.namespaceURI)===null||r===void 0?void 0:r.includes("svg")}),l=x(t.width),c=x(t.height),{stop:h}=Fe(e,([r])=>{const g=s==="border-box"?r.borderBoxSize:s==="content-box"?r.contentBoxSize:r.devicePixelContentBoxSize;if(n&&i.value){const y=T(e);if(y){const w=y.getBoundingClientRect();l.value=w.width,c.value=w.height}}else if(g){const y=D(g);l.value=y.reduce((w,{inlineSize:S})=>w+S,0),c.value=y.reduce((w,{blockSize:S})=>w+S,0)}else l.value=r.contentRect.width,c.value=r.contentRect.height},o);Q(()=>{const r=T(e);r&&(l.value="offsetWidth"in r?r.offsetWidth:t.width,c.value="offsetHeight"in r?r.offsetHeight:t.height)});const p=N(()=>T(e),r=>{l.value=r?t.width:0,c.value=r?t.height:0});function m(){h(),p()}return{width:l,height:c,stop:m}}function Ue(e,t,o={}){const{window:n=A}=o;return Pe(e,t,n?.localStorage,o)}function He(e,t,o,n={}){var s,i;const{clone:l=!1,passive:c=!1,eventName:h,deep:p=!1,defaultValue:m,shouldEmit:r}=n,g=k(),y=o||g?.emit||(g==null||(s=g.$emit)===null||s===void 0?void 0:s.bind(g))||(g==null||(i=g.proxy)===null||i===void 0||(i=i.$emit)===null||i===void 0?void 0:i.bind(g?.proxy));let w=h;w=w||`update:${t.toString()}`;const S=u=>l?typeof l=="function"?l(u):xe(u):u,a=()=>ve(e[t])?S(e[t]):m,f=u=>{r?r(u)&&y(w,u):y(w,u)};if(c){const u=R(a());let v=!1;return N(()=>e[t],b=>{v||(v=!0,u.value=S(b),j(()=>v=!1))}),N(u,b=>{!v&&(b!==e[t]||p)&&f(b)},{deep:p}),u}else return C({get(){return a()},set(u){f(u)}})}let Me;const M=[];function We(e){if(M.push(e),!(typeof window>"u"))return window.__NUXT_DEVTOOLS__&&M.forEach(t=>t(window.__NUXT_DEVTOOLS__)),Object.defineProperty(window,"__NUXT_DEVTOOLS__",{set(t){t&&M.forEach(o=>o(t))},get(){return Me.value},configurable:!0}),()=>{M.splice(M.indexOf(e),1)}}const ze="nuxt-mongoose-rpc",De=R(),Ve=R(),Le=R();We(async e=>{Ve.value=e.devtools.rpc,De.value=e.devtools,Le.value=e.devtools.extendClientRpc(ze,{})});export{Je as a,Ue as b,ke as c,Ie as d,Be as o,Le as r,He as u};