vinojs 0.1.0 → 0.1.2
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/client.mjs +1 -1
- package/dist/{compile-Lxl_tdxL.mjs → compile-glNMkyyx.mjs} +3 -47
- package/dist/compile-glNMkyyx.mjs.map +1 -0
- package/dist/{definePage-Ba4r-TFh.mjs → definePage--9Pz7rHs.mjs} +29 -7
- package/dist/definePage--9Pz7rHs.mjs.map +1 -0
- package/dist/defineServerFn-H-bz7xBX.mjs +47 -0
- package/dist/defineServerFn-H-bz7xBX.mjs.map +1 -0
- package/dist/factory-CVT0-OZw.d.mts +187 -0
- package/dist/factory-CVT0-OZw.d.mts.map +1 -0
- package/dist/factory.d.mts +2 -0
- package/dist/factory.mjs +153 -0
- package/dist/factory.mjs.map +1 -0
- package/dist/vino.d.mts +4 -103
- package/dist/vino.d.mts.map +1 -1
- package/dist/vino.mjs +8 -3
- package/dist/vino.mjs.map +1 -1
- package/dist/vite.mjs +3 -2
- package/dist/vite.mjs.map +1 -1
- package/package.json +5 -1
- package/dist/compile-Lxl_tdxL.mjs.map +0 -1
- package/dist/definePage-Ba4r-TFh.mjs.map +0 -1
- package/examples/basic/dist/client/.assetsignore +0 -2
- package/examples/basic/dist/client/about.html +0 -1
- package/examples/basic/dist/client/admin.html +0 -1
- package/examples/basic/dist/client/assets/Counter-BvqMZKON.js +0 -1
- package/examples/basic/dist/client/assets/_slug_-CYpOSbrn.js +0 -1
- package/examples/basic/dist/client/assets/about-BZXRzUyv.js +0 -1
- package/examples/basic/dist/client/assets/admin-DRE7uh2s.js +0 -1
- package/examples/basic/dist/client/assets/client-B6nFkut5.js +0 -1
- package/examples/basic/dist/client/assets/client-pages-Bc6cNZAm.js +0 -2
- package/examples/basic/dist/client/assets/components-DX9r6vHn.js +0 -1
- package/examples/basic/dist/client/assets/components-DsWJ6F73.js +0 -2
- package/examples/basic/dist/client/assets/counter-DBpvln_F.js +0 -1
- package/examples/basic/dist/client/assets/dom-B5sHIJ1E.js +0 -1
- package/examples/basic/dist/client/assets/honoto-9UtdLp4J.js +0 -33
- package/examples/basic/dist/client/assets/honoto-client-DEh86_WZ.css +0 -1
- package/examples/basic/dist/client/assets/honoto-client.js +0 -2
- package/examples/basic/dist/client/assets/hooks-Cz6AT21d.js +0 -1
- package/examples/basic/dist/client/assets/jsx-dev-runtime-92VDsVyo.js +0 -1
- package/examples/basic/dist/client/counter.html +0 -1
- package/examples/basic/dist/client/index.html +0 -1
- package/examples/basic/dist/client/jobs.html +0 -1
- package/examples/basic/dist/ssr/.vite/manifest.json +0 -140
- package/examples/basic/dist/ssr/assets/_slug_-CY3-kffX.js +0 -46
- package/examples/basic/dist/ssr/assets/about-CTDjNhkO.js +0 -15
- package/examples/basic/dist/ssr/assets/admin-DvS-UGJx.js +0 -26
- package/examples/basic/dist/ssr/assets/constants-UoriGYcX-CUecBFMT.js +0 -6
- package/examples/basic/dist/ssr/assets/counter-DfIbc9Sp.js +0 -30
- package/examples/basic/dist/ssr/assets/honoto-CA313cVy.js +0 -2129
- package/examples/basic/dist/ssr/assets/jobs-D9hh-UO9.js +0 -42
- package/examples/basic/dist/ssr/assets/jsx-CgYLQazd.js +0 -1080
- package/examples/basic/dist/ssr/assets/jsx-dev-runtime-BlUda7H8.js +0 -742
- package/examples/basic/dist/ssr/assets/jsx-renderer-CzZcZPnS.js +0 -65
- package/examples/basic/dist/ssr/assets/layout-DYvLwr2u.js +0 -53
- package/examples/basic/dist/ssr/assets/pages-DB6jeyrt.js +0 -53
- package/examples/basic/dist/ssr/assets/rolldown-runtime-D7D4PA-g.js +0 -13
- package/examples/basic/dist/ssr/assets/ssr-hooks-CBQr0cdH.js +0 -7
- package/examples/basic/dist/ssr/index.js +0 -22
- package/examples/basic/dist/ssr/wrangler.json +0 -1
- package/examples/full/dist/client/.assetsignore +0 -2
- package/examples/full/dist/client/assets/BookmarkButton-py0xGxgl.js +0 -1
- package/examples/full/dist/client/assets/_slug_-DZUFsE9O.js +0 -1
- package/examples/full/dist/client/assets/auth-client-D2Wtuobe.js +0 -1
- package/examples/full/dist/client/assets/bun-sqlite-dialect-C7ftEUSI-CsHdUKBY.js +0 -1
- package/examples/full/dist/client/assets/client-B6nFkut5.js +0 -1
- package/examples/full/dist/client/assets/client-pages-fshKs747.js +0 -2
- package/examples/full/dist/client/assets/components-DX9r6vHn.js +0 -1
- package/examples/full/dist/client/assets/components-S_-rWrKi.js +0 -2
- package/examples/full/dist/client/assets/d1-sqlite-dialect-BZmaVTp8-FPCaMZqX.js +0 -1
- package/examples/full/dist/client/assets/default-query-compiler-CUdqIu1h.js +0 -1
- package/examples/full/dist/client/assets/dist-BoGTNvkC.js +0 -1
- package/examples/full/dist/client/assets/dom-DCd3wYW7.js +0 -1
- package/examples/full/dist/client/assets/factory-Bgf4EtLx.js +0 -8
- package/examples/full/dist/client/assets/honoto-client-BSvNAnxN.css +0 -1
- package/examples/full/dist/client/assets/honoto-client.js +0 -2
- package/examples/full/dist/client/assets/hooks-Cz6AT21d.js +0 -1
- package/examples/full/dist/client/assets/jsx-dev-runtime-92VDsVyo.js +0 -1
- package/examples/full/dist/client/assets/kysely-adapter-BHhasAnc.js +0 -1
- package/examples/full/dist/client/assets/kysely-migration-tables-DFfmKhq--U5ujlMwE.js +0 -1
- package/examples/full/dist/client/assets/node-sqlite-dialect-DJDXH5Ot.js +0 -1
- package/examples/full/dist/client/assets/pages-CUQx6Eus.js +0 -1
- package/examples/full/dist/client/assets/saved-jIi74ncJ.js +0 -1
- package/examples/full/dist/client/assets/session-B-accyM3.js +0 -611
- package/examples/full/dist/client/assets/sign-in-BelI3gSs.js +0 -1
- package/examples/full/dist/client/assets/sign-up-pR94lfdu.js +0 -1
- package/examples/full/dist/client/index.html +0 -1
- package/examples/full/dist/client/saved.html +0 -1
- package/examples/full/dist/client/sign-in.html +0 -1
- package/examples/full/dist/client/sign-up.html +0 -1
- package/examples/full/dist/ssr/.dev.vars +0 -1
- package/examples/full/dist/ssr/.vite/manifest.json +0 -219
- package/examples/full/dist/ssr/assets/BookmarkButton-KS7z5_vi.js +0 -298
- package/examples/full/dist/ssr/assets/_slug_-rRStRaAN.js +0 -89
- package/examples/full/dist/ssr/assets/auth-DSFZ4iak.js +0 -31434
- package/examples/full/dist/ssr/assets/auth-client-BFSBVoML.js +0 -894
- package/examples/full/dist/ssr/assets/bun-sqlite-dialect-C7ftEUSI-BeXpIqKl.js +0 -162
- package/examples/full/dist/ssr/assets/compiled-query-DmoyCh28.js +0 -8410
- package/examples/full/dist/ssr/assets/d1-sqlite-dialect-BZmaVTp8-CjJdvL94.js +0 -114
- package/examples/full/dist/ssr/assets/default-query-compiler-D7xOzCCJ.js +0 -1727
- package/examples/full/dist/ssr/assets/dist-LmmDoNdk.js +0 -6832
- package/examples/full/dist/ssr/assets/dist-kFDN1l4Z.js +0 -342
- package/examples/full/dist/ssr/assets/factory-AD6s9SIW.js +0 -2079
- package/examples/full/dist/ssr/assets/jsx-renderer-mMLf5XLN.js +0 -1926
- package/examples/full/dist/ssr/assets/kysely-adapter-BCLenpM8.js +0 -2
- package/examples/full/dist/ssr/assets/kysely-migration-tables-DFfmKhq--BtVr6hRe.js +0 -17
- package/examples/full/dist/ssr/assets/layout-mVA7qP4j.js +0 -44
- package/examples/full/dist/ssr/assets/node-sqlite-dialect-D-wtYAD7.js +0 -162
- package/examples/full/dist/ssr/assets/pages-Do5kR_Ia.js +0 -147
- package/examples/full/dist/ssr/assets/saved-Dr4pP6B5.js +0 -111
- package/examples/full/dist/ssr/assets/session-BvIpX7tr.js +0 -13
- package/examples/full/dist/ssr/assets/sign-in-22pzTnJE.js +0 -115
- package/examples/full/dist/ssr/assets/sign-up-CN4j8Qg1.js +0 -117
- package/examples/full/dist/ssr/assets/sqlite-adapter-DVlms5wO.js +0 -79
- package/examples/full/dist/ssr/index.js +0 -97
- package/examples/full/dist/ssr/wrangler.json +0 -1
|
@@ -1,894 +0,0 @@
|
|
|
1
|
-
import { a as createFetch, c as getBaseURL, o as defu, s as isSafeUrlScheme } from "./auth-DSFZ4iak.js";
|
|
2
|
-
import { a as toKebabCase, i as capitalizeFirstLetter } from "./dist-LmmDoNdk.js";
|
|
3
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.1_@cloudflare+workers-types@4.20260702.1_drizzle-kit@0.31.10_drizzle-or_50a74384dde6bad88008886f8a6ac592/node_modules/better-auth/dist/client/broadcast-channel.mjs
|
|
4
|
-
var kBroadcastChannel = Symbol.for("better-auth:broadcast-channel");
|
|
5
|
-
var now$1 = () => Math.floor(Date.now() / 1e3);
|
|
6
|
-
var WindowBroadcastChannel = class {
|
|
7
|
-
listeners = /* @__PURE__ */ new Set();
|
|
8
|
-
name;
|
|
9
|
-
constructor(name = "better-auth.message") {
|
|
10
|
-
this.name = name;
|
|
11
|
-
}
|
|
12
|
-
subscribe(listener) {
|
|
13
|
-
this.listeners.add(listener);
|
|
14
|
-
return () => {
|
|
15
|
-
this.listeners.delete(listener);
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
post(message) {
|
|
19
|
-
if (typeof window === "undefined") return;
|
|
20
|
-
try {
|
|
21
|
-
localStorage.setItem(this.name, JSON.stringify({
|
|
22
|
-
...message,
|
|
23
|
-
timestamp: now$1()
|
|
24
|
-
}));
|
|
25
|
-
} catch {}
|
|
26
|
-
}
|
|
27
|
-
setup() {
|
|
28
|
-
if (typeof window === "undefined" || typeof window.addEventListener === "undefined") return () => {};
|
|
29
|
-
const handler = (event) => {
|
|
30
|
-
if (event.key !== this.name) return;
|
|
31
|
-
const message = JSON.parse(event.newValue ?? "{}");
|
|
32
|
-
if (message?.event !== "session" || !message?.data) return;
|
|
33
|
-
this.listeners.forEach((listener) => listener(message));
|
|
34
|
-
};
|
|
35
|
-
window.addEventListener("storage", handler);
|
|
36
|
-
return () => {
|
|
37
|
-
window.removeEventListener("storage", handler);
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
function getGlobalBroadcastChannel(name = "better-auth.message") {
|
|
42
|
-
if (!globalThis[kBroadcastChannel]) globalThis[kBroadcastChannel] = new WindowBroadcastChannel(name);
|
|
43
|
-
return globalThis[kBroadcastChannel];
|
|
44
|
-
}
|
|
45
|
-
//#endregion
|
|
46
|
-
//#region ../../node_modules/.pnpm/nanostores@1.5.2/node_modules/nanostores/atom/index.js
|
|
47
|
-
var listenerQueue = [];
|
|
48
|
-
var lqIndex = 0;
|
|
49
|
-
var batchSeen = null;
|
|
50
|
-
var QUEUE_ITEMS_PER_LISTENER = 4;
|
|
51
|
-
var nanostoresGlobal = globalThis.nanostoresGlobal ||= { epoch: 0 };
|
|
52
|
-
var drainQueue = () => {
|
|
53
|
-
let thrown;
|
|
54
|
-
for (lqIndex = 0; lqIndex < listenerQueue.length; lqIndex += QUEUE_ITEMS_PER_LISTENER) try {
|
|
55
|
-
listenerQueue[lqIndex](listenerQueue[lqIndex + 1].value, listenerQueue[lqIndex + 2], listenerQueue[lqIndex + 3]);
|
|
56
|
-
} catch (e) {
|
|
57
|
-
thrown = e;
|
|
58
|
-
}
|
|
59
|
-
listenerQueue.length = 0;
|
|
60
|
-
if (thrown) throw thrown;
|
|
61
|
-
};
|
|
62
|
-
var atom = /* @__NO_SIDE_EFFECTS__ */ (initialValue) => {
|
|
63
|
-
let listeners = [];
|
|
64
|
-
let $atom = {
|
|
65
|
-
eq: Object.is,
|
|
66
|
-
get() {
|
|
67
|
-
if (!$atom.lc) $atom.listen(() => {})();
|
|
68
|
-
return $atom.value;
|
|
69
|
-
},
|
|
70
|
-
init: initialValue,
|
|
71
|
-
lc: 0,
|
|
72
|
-
listen(listener) {
|
|
73
|
-
$atom.lc = listeners.push(listener);
|
|
74
|
-
return () => {
|
|
75
|
-
for (let i = lqIndex + QUEUE_ITEMS_PER_LISTENER; i < listenerQueue.length;) if (listenerQueue[i] === listener) listenerQueue.splice(i, QUEUE_ITEMS_PER_LISTENER);
|
|
76
|
-
else i += QUEUE_ITEMS_PER_LISTENER;
|
|
77
|
-
let index = listeners.indexOf(listener);
|
|
78
|
-
if (~index) {
|
|
79
|
-
listeners.splice(index, 1);
|
|
80
|
-
if (!--$atom.lc) $atom.off();
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
},
|
|
84
|
-
notify(oldValue, changedKey) {
|
|
85
|
-
nanostoresGlobal.epoch++;
|
|
86
|
-
let runListenerQueue = !listenerQueue.length && !batchSeen;
|
|
87
|
-
for (let listener of listeners) {
|
|
88
|
-
if (batchSeen?.has(listener)) continue;
|
|
89
|
-
batchSeen?.add(listener);
|
|
90
|
-
listenerQueue.push(listener, $atom, oldValue, batchSeen ? void 0 : changedKey);
|
|
91
|
-
}
|
|
92
|
-
if (runListenerQueue) drainQueue();
|
|
93
|
-
},
|
|
94
|
-
off() {},
|
|
95
|
-
set(newValue) {
|
|
96
|
-
let oldValue = $atom.value;
|
|
97
|
-
if (!$atom.eq(oldValue, newValue)) {
|
|
98
|
-
$atom.value = newValue;
|
|
99
|
-
$atom.notify(oldValue);
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
subscribe(listener) {
|
|
103
|
-
let unbind = $atom.listen(listener);
|
|
104
|
-
listener($atom.value);
|
|
105
|
-
return unbind;
|
|
106
|
-
},
|
|
107
|
-
value: initialValue
|
|
108
|
-
};
|
|
109
|
-
return $atom;
|
|
110
|
-
};
|
|
111
|
-
//#endregion
|
|
112
|
-
//#region ../../node_modules/.pnpm/nanostores@1.5.2/node_modules/nanostores/lifecycle/index.js
|
|
113
|
-
var SET = 2;
|
|
114
|
-
var MOUNT = 5;
|
|
115
|
-
var UNMOUNT = 6;
|
|
116
|
-
var REVERT_MUTATION = 10;
|
|
117
|
-
var on = (object, listener, eventKey, mutateStore) => {
|
|
118
|
-
object.events = object.events || {};
|
|
119
|
-
if (!object.events[eventKey + REVERT_MUTATION]) object.events[eventKey + REVERT_MUTATION] = mutateStore((eventProps) => {
|
|
120
|
-
object.events[eventKey].reduceRight((event, l) => (l(event), event), {
|
|
121
|
-
shared: {},
|
|
122
|
-
...eventProps
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
object.events[eventKey] = object.events[eventKey] || [];
|
|
126
|
-
object.events[eventKey].push(listener);
|
|
127
|
-
return () => {
|
|
128
|
-
let currentListeners = object.events[eventKey];
|
|
129
|
-
let index = currentListeners.indexOf(listener);
|
|
130
|
-
currentListeners.splice(index, 1);
|
|
131
|
-
if (!currentListeners.length) {
|
|
132
|
-
delete object.events[eventKey];
|
|
133
|
-
object.events[eventKey + REVERT_MUTATION]();
|
|
134
|
-
delete object.events[eventKey + REVERT_MUTATION];
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
};
|
|
138
|
-
var onSet = ($store, listener) => on($store, listener, SET, (runListeners) => {
|
|
139
|
-
let originSet = $store.set;
|
|
140
|
-
let originSetKey = $store.setKey;
|
|
141
|
-
if ($store.setKey) $store.setKey = (changed, changedValue) => {
|
|
142
|
-
let isAborted;
|
|
143
|
-
let abort = () => {
|
|
144
|
-
isAborted = true;
|
|
145
|
-
};
|
|
146
|
-
runListeners({
|
|
147
|
-
abort,
|
|
148
|
-
changed,
|
|
149
|
-
newValue: {
|
|
150
|
-
...$store.value,
|
|
151
|
-
[changed]: changedValue
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
if (!isAborted) return originSetKey(changed, changedValue);
|
|
155
|
-
};
|
|
156
|
-
$store.set = (newValue) => {
|
|
157
|
-
let isAborted;
|
|
158
|
-
let abort = () => {
|
|
159
|
-
isAborted = true;
|
|
160
|
-
};
|
|
161
|
-
runListeners({
|
|
162
|
-
abort,
|
|
163
|
-
newValue
|
|
164
|
-
});
|
|
165
|
-
if (!isAborted) return originSet(newValue);
|
|
166
|
-
};
|
|
167
|
-
return () => {
|
|
168
|
-
$store.set = originSet;
|
|
169
|
-
$store.setKey = originSetKey;
|
|
170
|
-
};
|
|
171
|
-
});
|
|
172
|
-
var STORE_UNMOUNT_DELAY = 1e3;
|
|
173
|
-
var onMount = ($store, initialize) => {
|
|
174
|
-
let listener = (payload) => {
|
|
175
|
-
let destroy = initialize(payload);
|
|
176
|
-
if (destroy) $store.events[UNMOUNT].push(destroy);
|
|
177
|
-
};
|
|
178
|
-
return on($store, listener, MOUNT, (runListeners) => {
|
|
179
|
-
let originListen = $store.listen;
|
|
180
|
-
$store.listen = (...args) => {
|
|
181
|
-
if (!$store.lc && !$store.active) {
|
|
182
|
-
$store.active = true;
|
|
183
|
-
runListeners();
|
|
184
|
-
}
|
|
185
|
-
return originListen(...args);
|
|
186
|
-
};
|
|
187
|
-
let originOff = $store.off;
|
|
188
|
-
$store.events[UNMOUNT] = [];
|
|
189
|
-
$store.off = () => {
|
|
190
|
-
originOff();
|
|
191
|
-
setTimeout(() => {
|
|
192
|
-
if ($store.active && !$store.lc) {
|
|
193
|
-
$store.active = false;
|
|
194
|
-
for (let destroy of $store.events[UNMOUNT]) destroy();
|
|
195
|
-
$store.events[UNMOUNT] = [];
|
|
196
|
-
}
|
|
197
|
-
}, STORE_UNMOUNT_DELAY);
|
|
198
|
-
};
|
|
199
|
-
return () => {
|
|
200
|
-
$store.listen = originListen;
|
|
201
|
-
$store.off = originOff;
|
|
202
|
-
};
|
|
203
|
-
});
|
|
204
|
-
};
|
|
205
|
-
//#endregion
|
|
206
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.1_@cloudflare+workers-types@4.20260702.1_drizzle-kit@0.31.10_drizzle-or_50a74384dde6bad88008886f8a6ac592/node_modules/better-auth/dist/client/equality.mjs
|
|
207
|
-
function isPlainObject(value) {
|
|
208
|
-
if (typeof value !== "object" || value === null) return false;
|
|
209
|
-
const prototype = Object.getPrototypeOf(value);
|
|
210
|
-
return prototype === Object.prototype || prototype === null;
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Deep structural equality for JSON-serializable values.
|
|
214
|
-
* Handles: primitives, null, arrays, and plain objects.
|
|
215
|
-
* Short-circuits on referential equality at every recursion level.
|
|
216
|
-
*/
|
|
217
|
-
function isJsonEqual(a, b) {
|
|
218
|
-
if (a === b) return true;
|
|
219
|
-
if (Array.isArray(a) && Array.isArray(b)) {
|
|
220
|
-
if (a.length !== b.length) return false;
|
|
221
|
-
for (let i = 0; i < a.length; i++) if (!isJsonEqual(a[i], b[i])) return false;
|
|
222
|
-
return true;
|
|
223
|
-
}
|
|
224
|
-
if (isPlainObject(a) && isPlainObject(b)) {
|
|
225
|
-
const keysA = Object.keys(a);
|
|
226
|
-
const keysB = Object.keys(b);
|
|
227
|
-
if (keysA.length !== keysB.length) return false;
|
|
228
|
-
for (const key of keysA) if (!(key in b) || !isJsonEqual(a[key], b[key])) return false;
|
|
229
|
-
return true;
|
|
230
|
-
}
|
|
231
|
-
return false;
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Attach an equality gate to a nanostores atom via `onSet`.
|
|
235
|
-
* When `isEqual(currentValue, newValue)` returns true, the `set()` call
|
|
236
|
-
* is aborted: no listeners fire, no framework re-renders occur.
|
|
237
|
-
*
|
|
238
|
-
* Returns the unsubscribe function from `onSet`.
|
|
239
|
-
*/
|
|
240
|
-
function withEquality(store, isEqual) {
|
|
241
|
-
return onSet(store, ({ newValue, abort }) => {
|
|
242
|
-
if (isEqual(store.value, newValue)) abort();
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
//#endregion
|
|
246
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.1_@cloudflare+workers-types@4.20260702.1_drizzle-kit@0.31.10_drizzle-or_50a74384dde6bad88008886f8a6ac592/node_modules/better-auth/dist/client/focus-manager.mjs
|
|
247
|
-
var kFocusManager = Symbol.for("better-auth:focus-manager");
|
|
248
|
-
var WindowFocusManager = class {
|
|
249
|
-
listeners = /* @__PURE__ */ new Set();
|
|
250
|
-
subscribe(listener) {
|
|
251
|
-
this.listeners.add(listener);
|
|
252
|
-
return () => {
|
|
253
|
-
this.listeners.delete(listener);
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
setFocused(focused) {
|
|
257
|
-
this.listeners.forEach((listener) => listener(focused));
|
|
258
|
-
}
|
|
259
|
-
setup() {
|
|
260
|
-
if (typeof window === "undefined" || typeof document === "undefined" || typeof window.addEventListener === "undefined") return () => {};
|
|
261
|
-
const visibilityHandler = () => {
|
|
262
|
-
if (document.visibilityState === "visible") this.setFocused(true);
|
|
263
|
-
};
|
|
264
|
-
document.addEventListener("visibilitychange", visibilityHandler, false);
|
|
265
|
-
return () => {
|
|
266
|
-
document.removeEventListener("visibilitychange", visibilityHandler, false);
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
|
-
function getGlobalFocusManager() {
|
|
271
|
-
if (!globalThis[kFocusManager]) globalThis[kFocusManager] = new WindowFocusManager();
|
|
272
|
-
return globalThis[kFocusManager];
|
|
273
|
-
}
|
|
274
|
-
//#endregion
|
|
275
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.1_@cloudflare+workers-types@4.20260702.1_drizzle-kit@0.31.10_drizzle-or_50a74384dde6bad88008886f8a6ac592/node_modules/better-auth/dist/client/online-manager.mjs
|
|
276
|
-
var kOnlineManager = Symbol.for("better-auth:online-manager");
|
|
277
|
-
var WindowOnlineManager = class {
|
|
278
|
-
listeners = /* @__PURE__ */ new Set();
|
|
279
|
-
isOnline = typeof navigator !== "undefined" ? navigator.onLine : true;
|
|
280
|
-
subscribe(listener) {
|
|
281
|
-
this.listeners.add(listener);
|
|
282
|
-
return () => {
|
|
283
|
-
this.listeners.delete(listener);
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
setOnline(online) {
|
|
287
|
-
this.isOnline = online;
|
|
288
|
-
this.listeners.forEach((listener) => listener(online));
|
|
289
|
-
}
|
|
290
|
-
setup() {
|
|
291
|
-
if (typeof window === "undefined" || typeof window.addEventListener === "undefined") return () => {};
|
|
292
|
-
const onOnline = () => this.setOnline(true);
|
|
293
|
-
const onOffline = () => this.setOnline(false);
|
|
294
|
-
window.addEventListener("online", onOnline, false);
|
|
295
|
-
window.addEventListener("offline", onOffline, false);
|
|
296
|
-
return () => {
|
|
297
|
-
window.removeEventListener("online", onOnline, false);
|
|
298
|
-
window.removeEventListener("offline", onOffline, false);
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
};
|
|
302
|
-
function getGlobalOnlineManager() {
|
|
303
|
-
if (!globalThis[kOnlineManager]) globalThis[kOnlineManager] = new WindowOnlineManager();
|
|
304
|
-
return globalThis[kOnlineManager];
|
|
305
|
-
}
|
|
306
|
-
//#endregion
|
|
307
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.1_@cloudflare+workers-types@4.20260702.1_drizzle-kit@0.31.10_drizzle-or_50a74384dde6bad88008886f8a6ac592/node_modules/better-auth/dist/client/parser.mjs
|
|
308
|
-
var PROTO_POLLUTION_PATTERNS = {
|
|
309
|
-
proto: /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,
|
|
310
|
-
constructor: /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,
|
|
311
|
-
protoShort: /"__proto__"\s*:/,
|
|
312
|
-
constructorShort: /"constructor"\s*:/
|
|
313
|
-
};
|
|
314
|
-
var JSON_SIGNATURE = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
|
|
315
|
-
var SPECIAL_VALUES = {
|
|
316
|
-
true: true,
|
|
317
|
-
false: false,
|
|
318
|
-
null: null,
|
|
319
|
-
undefined: void 0,
|
|
320
|
-
nan: NaN,
|
|
321
|
-
infinity: Number.POSITIVE_INFINITY,
|
|
322
|
-
"-infinity": Number.NEGATIVE_INFINITY
|
|
323
|
-
};
|
|
324
|
-
var ISO_DATE_REGEX = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;
|
|
325
|
-
function isValidDate(date) {
|
|
326
|
-
return date instanceof Date && !isNaN(date.getTime());
|
|
327
|
-
}
|
|
328
|
-
function parseISODate(value) {
|
|
329
|
-
const match = ISO_DATE_REGEX.exec(value);
|
|
330
|
-
if (!match) return null;
|
|
331
|
-
const [, year, month, day, hour, minute, second, ms, offsetSign, offsetHour, offsetMinute] = match;
|
|
332
|
-
const date = new Date(Date.UTC(parseInt(year, 10), parseInt(month, 10) - 1, parseInt(day, 10), parseInt(hour, 10), parseInt(minute, 10), parseInt(second, 10), ms ? parseInt(ms.padEnd(3, "0"), 10) : 0));
|
|
333
|
-
if (offsetSign) {
|
|
334
|
-
const offset = (parseInt(offsetHour, 10) * 60 + parseInt(offsetMinute, 10)) * (offsetSign === "+" ? -1 : 1);
|
|
335
|
-
date.setUTCMinutes(date.getUTCMinutes() + offset);
|
|
336
|
-
}
|
|
337
|
-
return isValidDate(date) ? date : null;
|
|
338
|
-
}
|
|
339
|
-
function betterJSONParse(value, options = {}) {
|
|
340
|
-
const { strict = false, warnings = false, reviver, parseDates = true } = options;
|
|
341
|
-
if (typeof value !== "string") return value;
|
|
342
|
-
const trimmed = value.trim();
|
|
343
|
-
const lowerValue = trimmed.toLowerCase();
|
|
344
|
-
if (lowerValue.length <= 9 && lowerValue in SPECIAL_VALUES) return SPECIAL_VALUES[lowerValue];
|
|
345
|
-
if (!JSON_SIGNATURE.test(trimmed)) {
|
|
346
|
-
if (strict) throw new SyntaxError("[better-json] Invalid JSON");
|
|
347
|
-
return value;
|
|
348
|
-
}
|
|
349
|
-
if (Object.entries(PROTO_POLLUTION_PATTERNS).some(([key, pattern]) => {
|
|
350
|
-
const matches = pattern.test(trimmed);
|
|
351
|
-
if (matches && warnings) console.warn(`[better-json] Detected potential prototype pollution attempt using ${key} pattern`);
|
|
352
|
-
return matches;
|
|
353
|
-
}) && strict) throw new Error("[better-json] Potential prototype pollution attempt detected");
|
|
354
|
-
try {
|
|
355
|
-
const secureReviver = (key, value) => {
|
|
356
|
-
if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) {
|
|
357
|
-
if (warnings) console.warn(`[better-json] Dropping "${key}" key to prevent prototype pollution`);
|
|
358
|
-
return;
|
|
359
|
-
}
|
|
360
|
-
if (parseDates && typeof value === "string") {
|
|
361
|
-
const date = parseISODate(value);
|
|
362
|
-
if (date) return date;
|
|
363
|
-
}
|
|
364
|
-
return reviver ? reviver(key, value) : value;
|
|
365
|
-
};
|
|
366
|
-
return JSON.parse(trimmed, secureReviver);
|
|
367
|
-
} catch (error) {
|
|
368
|
-
if (strict) throw error;
|
|
369
|
-
return value;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
function parseJSON(value, options = { strict: true }) {
|
|
373
|
-
return betterJSONParse(value, options);
|
|
374
|
-
}
|
|
375
|
-
//#endregion
|
|
376
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.1_@cloudflare+workers-types@4.20260702.1_drizzle-kit@0.31.10_drizzle-or_50a74384dde6bad88008886f8a6ac592/node_modules/better-auth/dist/client/session-refresh.mjs
|
|
377
|
-
var now = () => Math.floor(Date.now() / 1e3);
|
|
378
|
-
/**
|
|
379
|
-
* Rate limit: don't refetch on focus if a session request was made within this many seconds
|
|
380
|
-
*/
|
|
381
|
-
var FOCUS_REFETCH_RATE_LIMIT_SECONDS = 5;
|
|
382
|
-
function createSessionRefreshManager(opts) {
|
|
383
|
-
const { fetchSession, shouldPollSession = () => true, sessionSignal, options = {} } = opts;
|
|
384
|
-
const refetchInterval = options.sessionOptions?.refetchInterval ?? 0;
|
|
385
|
-
const refetchOnWindowFocus = options.sessionOptions?.refetchOnWindowFocus ?? true;
|
|
386
|
-
const refetchWhenOffline = options.sessionOptions?.refetchWhenOffline ?? false;
|
|
387
|
-
const state = {
|
|
388
|
-
isInitialized: false,
|
|
389
|
-
lastSessionRequest: 0
|
|
390
|
-
};
|
|
391
|
-
const shouldRefetch = () => {
|
|
392
|
-
return refetchWhenOffline || getGlobalOnlineManager().isOnline;
|
|
393
|
-
};
|
|
394
|
-
const triggerRefetch = (event) => {
|
|
395
|
-
if (!shouldRefetch()) return;
|
|
396
|
-
if (event?.event === "storage") {
|
|
397
|
-
fetchSession();
|
|
398
|
-
return;
|
|
399
|
-
}
|
|
400
|
-
if (event?.event === "poll") {
|
|
401
|
-
state.lastSessionRequest = now();
|
|
402
|
-
fetchSession();
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
if (event?.event === "visibilitychange") {
|
|
406
|
-
if (now() - state.lastSessionRequest < FOCUS_REFETCH_RATE_LIMIT_SECONDS) return;
|
|
407
|
-
state.lastSessionRequest = now();
|
|
408
|
-
fetchSession();
|
|
409
|
-
return;
|
|
410
|
-
}
|
|
411
|
-
fetchSession();
|
|
412
|
-
};
|
|
413
|
-
const broadcastSessionUpdate = (trigger) => {
|
|
414
|
-
getGlobalBroadcastChannel().post({
|
|
415
|
-
event: "session",
|
|
416
|
-
data: { trigger },
|
|
417
|
-
clientId: Math.random().toString(36).substring(7)
|
|
418
|
-
});
|
|
419
|
-
};
|
|
420
|
-
const setupPolling = () => {
|
|
421
|
-
if (refetchInterval && refetchInterval > 0) state.pollInterval = setInterval(() => {
|
|
422
|
-
if (shouldPollSession()) triggerRefetch({ event: "poll" });
|
|
423
|
-
}, refetchInterval * 1e3);
|
|
424
|
-
};
|
|
425
|
-
const setupBroadcast = () => {
|
|
426
|
-
state.unsubscribeBroadcast = getGlobalBroadcastChannel().subscribe(() => {
|
|
427
|
-
triggerRefetch({ event: "storage" });
|
|
428
|
-
});
|
|
429
|
-
};
|
|
430
|
-
const setupFocusRefetch = () => {
|
|
431
|
-
if (!refetchOnWindowFocus) return;
|
|
432
|
-
state.unsubscribeFocus = getGlobalFocusManager().subscribe(() => {
|
|
433
|
-
triggerRefetch({ event: "visibilitychange" });
|
|
434
|
-
});
|
|
435
|
-
};
|
|
436
|
-
const setupOnlineRefetch = () => {
|
|
437
|
-
state.unsubscribeOnline = getGlobalOnlineManager().subscribe((online) => {
|
|
438
|
-
if (online) triggerRefetch({ event: "visibilitychange" });
|
|
439
|
-
});
|
|
440
|
-
};
|
|
441
|
-
const setupSignalSubscription = () => {
|
|
442
|
-
state.unsubscribeSignal = sessionSignal.listen(() => {
|
|
443
|
-
fetchSession();
|
|
444
|
-
});
|
|
445
|
-
};
|
|
446
|
-
const init = () => {
|
|
447
|
-
if (state.isInitialized) return;
|
|
448
|
-
state.isInitialized = true;
|
|
449
|
-
setupPolling();
|
|
450
|
-
setupBroadcast();
|
|
451
|
-
setupFocusRefetch();
|
|
452
|
-
setupOnlineRefetch();
|
|
453
|
-
setupSignalSubscription();
|
|
454
|
-
state.cleanupBroadcastSetup = getGlobalBroadcastChannel().setup();
|
|
455
|
-
state.cleanupFocusSetup = getGlobalFocusManager().setup();
|
|
456
|
-
state.cleanupOnlineSetup = getGlobalOnlineManager().setup();
|
|
457
|
-
};
|
|
458
|
-
const cleanup = () => {
|
|
459
|
-
if (!state.isInitialized) return;
|
|
460
|
-
if (state.pollInterval) {
|
|
461
|
-
clearInterval(state.pollInterval);
|
|
462
|
-
state.pollInterval = void 0;
|
|
463
|
-
}
|
|
464
|
-
if (state.unsubscribeBroadcast) {
|
|
465
|
-
state.unsubscribeBroadcast();
|
|
466
|
-
state.unsubscribeBroadcast = void 0;
|
|
467
|
-
}
|
|
468
|
-
if (state.unsubscribeFocus) {
|
|
469
|
-
state.unsubscribeFocus();
|
|
470
|
-
state.unsubscribeFocus = void 0;
|
|
471
|
-
}
|
|
472
|
-
if (state.unsubscribeOnline) {
|
|
473
|
-
state.unsubscribeOnline();
|
|
474
|
-
state.unsubscribeOnline = void 0;
|
|
475
|
-
}
|
|
476
|
-
if (state.unsubscribeSignal) {
|
|
477
|
-
state.unsubscribeSignal();
|
|
478
|
-
state.unsubscribeSignal = void 0;
|
|
479
|
-
}
|
|
480
|
-
if (state.cleanupBroadcastSetup) {
|
|
481
|
-
state.cleanupBroadcastSetup();
|
|
482
|
-
state.cleanupBroadcastSetup = void 0;
|
|
483
|
-
}
|
|
484
|
-
if (state.cleanupFocusSetup) {
|
|
485
|
-
state.cleanupFocusSetup();
|
|
486
|
-
state.cleanupFocusSetup = void 0;
|
|
487
|
-
}
|
|
488
|
-
if (state.cleanupOnlineSetup) {
|
|
489
|
-
state.cleanupOnlineSetup();
|
|
490
|
-
state.cleanupOnlineSetup = void 0;
|
|
491
|
-
}
|
|
492
|
-
state.isInitialized = false;
|
|
493
|
-
state.lastSessionRequest = 0;
|
|
494
|
-
};
|
|
495
|
-
return {
|
|
496
|
-
init,
|
|
497
|
-
cleanup,
|
|
498
|
-
triggerRefetch,
|
|
499
|
-
broadcastSessionUpdate
|
|
500
|
-
};
|
|
501
|
-
}
|
|
502
|
-
//#endregion
|
|
503
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.1_@cloudflare+workers-types@4.20260702.1_drizzle-kit@0.31.10_drizzle-or_50a74384dde6bad88008886f8a6ac592/node_modules/better-auth/dist/client/fetch-plugins.mjs
|
|
504
|
-
var redirectPlugin = {
|
|
505
|
-
id: "redirect",
|
|
506
|
-
name: "Redirect",
|
|
507
|
-
hooks: { onSuccess(context) {
|
|
508
|
-
if (context.data?.url && context.data?.redirect && isSafeUrlScheme(context.data.url)) {
|
|
509
|
-
if (typeof window !== "undefined" && window.location) {
|
|
510
|
-
if (window.location) try {
|
|
511
|
-
window.location.href = context.data.url;
|
|
512
|
-
} catch {}
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
} }
|
|
516
|
-
};
|
|
517
|
-
//#endregion
|
|
518
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.1_@cloudflare+workers-types@4.20260702.1_drizzle-kit@0.31.10_drizzle-or_50a74384dde6bad88008886f8a6ac592/node_modules/better-auth/dist/client/session-atom.mjs
|
|
519
|
-
var isServer = () => typeof window === "undefined";
|
|
520
|
-
var SESSION_MOUNT_DEDUPE_INTERVAL = STORE_UNMOUNT_DELAY;
|
|
521
|
-
function hydrateSessionAtom(sessionAtom, session) {
|
|
522
|
-
if (typeof window === "undefined") return;
|
|
523
|
-
const currentSession = sessionAtom.get();
|
|
524
|
-
if (currentSession.data !== null || session === null) return;
|
|
525
|
-
sessionAtom.set({
|
|
526
|
-
...currentSession,
|
|
527
|
-
data: session,
|
|
528
|
-
error: null,
|
|
529
|
-
isPending: false
|
|
530
|
-
});
|
|
531
|
-
}
|
|
532
|
-
/**
|
|
533
|
-
* Normalize $fetch response: `throw: true` returns data directly,
|
|
534
|
-
* otherwise `{ data, error }`.
|
|
535
|
-
*/
|
|
536
|
-
function normalizeSessionResponse(res) {
|
|
537
|
-
if (typeof res === "object" && res !== null && "data" in res && "error" in res) return res;
|
|
538
|
-
return {
|
|
539
|
-
data: res,
|
|
540
|
-
error: null
|
|
541
|
-
};
|
|
542
|
-
}
|
|
543
|
-
function normalizeSessionData(data) {
|
|
544
|
-
if (!data) return null;
|
|
545
|
-
if (data.session === null && data.user === null) return null;
|
|
546
|
-
return data;
|
|
547
|
-
}
|
|
548
|
-
function isSessionAtomEqual(a, b) {
|
|
549
|
-
return isJsonEqual(a.data, b.data) && a.error === b.error && a.isPending === b.isPending && a.isRefetching === b.isRefetching && a.refetch === b.refetch;
|
|
550
|
-
}
|
|
551
|
-
function getSessionAtom($fetch, options) {
|
|
552
|
-
const $signal = /* @__PURE__ */ atom(false);
|
|
553
|
-
let flight;
|
|
554
|
-
let freshUntil = 0;
|
|
555
|
-
let sessionRevision = 0;
|
|
556
|
-
$signal.listen(() => {
|
|
557
|
-
sessionRevision++;
|
|
558
|
-
freshUntil = 0;
|
|
559
|
-
});
|
|
560
|
-
const refetch = (queryParams) => fetchSession(queryParams);
|
|
561
|
-
const session = /* @__PURE__ */ atom({
|
|
562
|
-
data: null,
|
|
563
|
-
error: null,
|
|
564
|
-
isPending: true,
|
|
565
|
-
isRefetching: false,
|
|
566
|
-
refetch
|
|
567
|
-
});
|
|
568
|
-
withEquality(session, isSessionAtomEqual);
|
|
569
|
-
const executeSessionFetch = async (signal, queryParams) => {
|
|
570
|
-
const current = session.value;
|
|
571
|
-
session.set({
|
|
572
|
-
...current,
|
|
573
|
-
isPending: current.data === null,
|
|
574
|
-
isRefetching: true,
|
|
575
|
-
error: null,
|
|
576
|
-
refetch
|
|
577
|
-
});
|
|
578
|
-
if (signal.aborted) return "aborted";
|
|
579
|
-
try {
|
|
580
|
-
const res = await $fetch("/get-session", {
|
|
581
|
-
method: "GET",
|
|
582
|
-
query: queryParams?.query,
|
|
583
|
-
signal
|
|
584
|
-
});
|
|
585
|
-
if (signal.aborted) return "aborted";
|
|
586
|
-
let { data, error } = normalizeSessionResponse(res);
|
|
587
|
-
let outcome = "fresh";
|
|
588
|
-
if (data?.needsRefresh) try {
|
|
589
|
-
const refreshRes = await $fetch("/get-session", {
|
|
590
|
-
method: "POST",
|
|
591
|
-
signal
|
|
592
|
-
});
|
|
593
|
-
if (signal.aborted) return "aborted";
|
|
594
|
-
({data, error} = normalizeSessionResponse(refreshRes));
|
|
595
|
-
} catch {
|
|
596
|
-
if (signal.aborted) return "aborted";
|
|
597
|
-
outcome = "stale";
|
|
598
|
-
}
|
|
599
|
-
if (error) {
|
|
600
|
-
const latest = session.value;
|
|
601
|
-
const isUnauthorized = error?.status === 401;
|
|
602
|
-
session.set({
|
|
603
|
-
data: isUnauthorized ? null : latest.data,
|
|
604
|
-
error,
|
|
605
|
-
isPending: false,
|
|
606
|
-
isRefetching: false,
|
|
607
|
-
refetch
|
|
608
|
-
});
|
|
609
|
-
return "failed";
|
|
610
|
-
}
|
|
611
|
-
const sessionData = normalizeSessionData(data);
|
|
612
|
-
const current = session.value;
|
|
613
|
-
const stableData = current.data != null && sessionData != null && isJsonEqual(current.data, sessionData) ? current.data : sessionData;
|
|
614
|
-
session.set({
|
|
615
|
-
data: stableData,
|
|
616
|
-
error: null,
|
|
617
|
-
isPending: false,
|
|
618
|
-
isRefetching: false,
|
|
619
|
-
refetch
|
|
620
|
-
});
|
|
621
|
-
return outcome;
|
|
622
|
-
} catch (fetchError) {
|
|
623
|
-
if (signal.aborted) return "aborted";
|
|
624
|
-
const latest = session.value;
|
|
625
|
-
session.set({
|
|
626
|
-
data: latest.data,
|
|
627
|
-
error: fetchError,
|
|
628
|
-
isPending: false,
|
|
629
|
-
isRefetching: false,
|
|
630
|
-
refetch
|
|
631
|
-
});
|
|
632
|
-
return "failed";
|
|
633
|
-
}
|
|
634
|
-
};
|
|
635
|
-
const getFreshUntil = () => {
|
|
636
|
-
const expiresAt = session.value.data?.session?.expiresAt;
|
|
637
|
-
const sessionExpiresAt = expiresAt instanceof Date ? expiresAt.getTime() : Number.POSITIVE_INFINITY;
|
|
638
|
-
return Math.min(Date.now() + SESSION_MOUNT_DEDUPE_INTERVAL, sessionExpiresAt);
|
|
639
|
-
};
|
|
640
|
-
const fetchSession = (queryParams) => {
|
|
641
|
-
freshUntil = 0;
|
|
642
|
-
flight?.cancel();
|
|
643
|
-
const controller = new AbortController();
|
|
644
|
-
const request = {
|
|
645
|
-
cancel: () => controller.abort(),
|
|
646
|
-
promise: Promise.resolve().then(() => {
|
|
647
|
-
if (controller.signal.aborted) return "aborted";
|
|
648
|
-
return executeSessionFetch(controller.signal, queryParams);
|
|
649
|
-
}),
|
|
650
|
-
revision: sessionRevision
|
|
651
|
-
};
|
|
652
|
-
flight = request;
|
|
653
|
-
const settleFlight = (outcome) => {
|
|
654
|
-
if (flight !== request) return;
|
|
655
|
-
flight = void 0;
|
|
656
|
-
if (outcome === "fresh" && request.revision === sessionRevision) freshUntil = getFreshUntil();
|
|
657
|
-
};
|
|
658
|
-
request.promise.then(settleFlight, () => settleFlight("failed"));
|
|
659
|
-
return request.promise.then(() => void 0);
|
|
660
|
-
};
|
|
661
|
-
const fetchSessionOnMount = () => {
|
|
662
|
-
if (flight?.revision === sessionRevision) return flight.promise.then(() => void 0);
|
|
663
|
-
if (Date.now() < freshUntil) return Promise.resolve();
|
|
664
|
-
return fetchSession();
|
|
665
|
-
};
|
|
666
|
-
let broadcastSessionUpdate = () => {};
|
|
667
|
-
onMount(session, () => {
|
|
668
|
-
let timeoutId;
|
|
669
|
-
if (!isServer()) timeoutId = setTimeout(() => {
|
|
670
|
-
fetchSessionOnMount();
|
|
671
|
-
}, 0);
|
|
672
|
-
const refreshManager = createSessionRefreshManager({
|
|
673
|
-
fetchSession,
|
|
674
|
-
shouldPollSession: () => session.value.data != null,
|
|
675
|
-
sessionSignal: $signal,
|
|
676
|
-
options
|
|
677
|
-
});
|
|
678
|
-
refreshManager.init();
|
|
679
|
-
broadcastSessionUpdate = refreshManager.broadcastSessionUpdate;
|
|
680
|
-
return () => {
|
|
681
|
-
if (timeoutId) clearTimeout(timeoutId);
|
|
682
|
-
refreshManager.cleanup();
|
|
683
|
-
};
|
|
684
|
-
});
|
|
685
|
-
return {
|
|
686
|
-
session,
|
|
687
|
-
$sessionSignal: $signal,
|
|
688
|
-
broadcastSessionUpdate: (trigger) => broadcastSessionUpdate(trigger)
|
|
689
|
-
};
|
|
690
|
-
}
|
|
691
|
-
//#endregion
|
|
692
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.1_@cloudflare+workers-types@4.20260702.1_drizzle-kit@0.31.10_drizzle-or_50a74384dde6bad88008886f8a6ac592/node_modules/better-auth/dist/client/config.mjs
|
|
693
|
-
var resolvePublicAuthUrl = (basePath) => {
|
|
694
|
-
if (typeof process === "undefined") return void 0;
|
|
695
|
-
const path = basePath ?? "/api/auth";
|
|
696
|
-
if (process.env.NEXT_PUBLIC_AUTH_URL) return process.env.NEXT_PUBLIC_AUTH_URL;
|
|
697
|
-
if (typeof window === "undefined") {
|
|
698
|
-
if (process.env.NEXTAUTH_URL) try {
|
|
699
|
-
return process.env.NEXTAUTH_URL;
|
|
700
|
-
} catch {}
|
|
701
|
-
if (process.env.VERCEL_URL) try {
|
|
702
|
-
const protocol = process.env.VERCEL_URL.startsWith("http") ? "" : "https://";
|
|
703
|
-
return `${new URL(`${protocol}${process.env.VERCEL_URL}`).origin}${path}`;
|
|
704
|
-
} catch {}
|
|
705
|
-
}
|
|
706
|
-
};
|
|
707
|
-
var getClientConfig = (options, loadEnv) => {
|
|
708
|
-
const isCredentialsSupported = "credentials" in Request.prototype;
|
|
709
|
-
const baseURL = getBaseURL(options?.baseURL, options?.basePath, void 0, loadEnv) ?? resolvePublicAuthUrl(options?.basePath) ?? "/api/auth";
|
|
710
|
-
const pluginsFetchPlugins = options?.plugins?.flatMap((plugin) => plugin.fetchPlugins).filter((pl) => pl !== void 0) || [];
|
|
711
|
-
const lifeCyclePlugin = {
|
|
712
|
-
id: "lifecycle-hooks",
|
|
713
|
-
name: "lifecycle-hooks",
|
|
714
|
-
hooks: {
|
|
715
|
-
onSuccess: options?.fetchOptions?.onSuccess,
|
|
716
|
-
onError: options?.fetchOptions?.onError,
|
|
717
|
-
onRequest: options?.fetchOptions?.onRequest,
|
|
718
|
-
onResponse: options?.fetchOptions?.onResponse
|
|
719
|
-
}
|
|
720
|
-
};
|
|
721
|
-
const { onSuccess: _onSuccess, onError: _onError, onRequest: _onRequest, onResponse: _onResponse, ...restOfFetchOptions } = options?.fetchOptions || {};
|
|
722
|
-
const $fetch = createFetch({
|
|
723
|
-
baseURL,
|
|
724
|
-
...isCredentialsSupported ? { credentials: "include" } : {},
|
|
725
|
-
method: "GET",
|
|
726
|
-
jsonParser(text) {
|
|
727
|
-
if (!text) return null;
|
|
728
|
-
return parseJSON(text, { strict: false });
|
|
729
|
-
},
|
|
730
|
-
customFetchImpl: fetch,
|
|
731
|
-
...restOfFetchOptions,
|
|
732
|
-
plugins: [
|
|
733
|
-
lifeCyclePlugin,
|
|
734
|
-
...restOfFetchOptions.plugins || [],
|
|
735
|
-
...options?.disableDefaultFetchPlugins ? [] : [redirectPlugin],
|
|
736
|
-
...pluginsFetchPlugins
|
|
737
|
-
]
|
|
738
|
-
});
|
|
739
|
-
const { $sessionSignal, session, broadcastSessionUpdate } = getSessionAtom($fetch, options);
|
|
740
|
-
let hasHydrated = false;
|
|
741
|
-
const hydrateSession = (sessionData) => {
|
|
742
|
-
if (hasHydrated || sessionData === null) return;
|
|
743
|
-
hasHydrated = true;
|
|
744
|
-
hydrateSessionAtom(session, sessionData);
|
|
745
|
-
};
|
|
746
|
-
const plugins = options?.plugins || [];
|
|
747
|
-
let pluginsActions = {};
|
|
748
|
-
const pluginsAtoms = {
|
|
749
|
-
$sessionSignal,
|
|
750
|
-
session
|
|
751
|
-
};
|
|
752
|
-
const pluginPathMethods = {
|
|
753
|
-
"/sign-out": "POST",
|
|
754
|
-
"/revoke-sessions": "POST",
|
|
755
|
-
"/revoke-other-sessions": "POST",
|
|
756
|
-
"/delete-user": "POST"
|
|
757
|
-
};
|
|
758
|
-
const atomListeners = [{
|
|
759
|
-
signal: "$sessionSignal",
|
|
760
|
-
matcher(path) {
|
|
761
|
-
return path === "/sign-out" || path === "/update-user" || path === "/update-session" || path === "/sign-up/email" || path === "/sign-in/email" || path === "/delete-user" || path === "/verify-email" || path === "/revoke-sessions" || path === "/revoke-session" || path === "/revoke-other-sessions" || path === "/change-email" || path === "/change-password";
|
|
762
|
-
},
|
|
763
|
-
callback(path) {
|
|
764
|
-
if (path === "/sign-out") broadcastSessionUpdate("signout");
|
|
765
|
-
else if (path === "/update-user" || path === "/update-session") broadcastSessionUpdate("updateUser");
|
|
766
|
-
}
|
|
767
|
-
}];
|
|
768
|
-
for (const plugin of plugins) {
|
|
769
|
-
if (plugin.getAtoms) Object.assign(pluginsAtoms, plugin.getAtoms?.($fetch));
|
|
770
|
-
if (plugin.pathMethods) Object.assign(pluginPathMethods, plugin.pathMethods);
|
|
771
|
-
if (plugin.atomListeners) atomListeners.push(...plugin.atomListeners);
|
|
772
|
-
}
|
|
773
|
-
const $store = {
|
|
774
|
-
notify: (signal) => {
|
|
775
|
-
pluginsAtoms[signal].set(!pluginsAtoms[signal].get());
|
|
776
|
-
},
|
|
777
|
-
listen: (signal, listener) => {
|
|
778
|
-
pluginsAtoms[signal].subscribe(listener);
|
|
779
|
-
},
|
|
780
|
-
atoms: pluginsAtoms
|
|
781
|
-
};
|
|
782
|
-
for (const plugin of plugins) if (plugin.getActions) pluginsActions = defu(plugin.getActions?.($fetch, $store, options) ?? {}, pluginsActions);
|
|
783
|
-
return {
|
|
784
|
-
get baseURL() {
|
|
785
|
-
return baseURL;
|
|
786
|
-
},
|
|
787
|
-
pluginsActions,
|
|
788
|
-
pluginsAtoms,
|
|
789
|
-
pluginPathMethods,
|
|
790
|
-
atomListeners,
|
|
791
|
-
hydrateSession,
|
|
792
|
-
$fetch,
|
|
793
|
-
$store
|
|
794
|
-
};
|
|
795
|
-
};
|
|
796
|
-
//#endregion
|
|
797
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.1_@cloudflare+workers-types@4.20260702.1_drizzle-kit@0.31.10_drizzle-or_50a74384dde6bad88008886f8a6ac592/node_modules/better-auth/dist/utils/is-atom.mjs
|
|
798
|
-
function isAtom(value) {
|
|
799
|
-
return typeof value === "object" && value !== null && "get" in value && typeof value.get === "function" && "lc" in value && typeof value.lc === "number";
|
|
800
|
-
}
|
|
801
|
-
//#endregion
|
|
802
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.1_@cloudflare+workers-types@4.20260702.1_drizzle-kit@0.31.10_drizzle-or_50a74384dde6bad88008886f8a6ac592/node_modules/better-auth/dist/client/proxy.mjs
|
|
803
|
-
function getMethod(path, knownPathMethods, args) {
|
|
804
|
-
const method = knownPathMethods[path];
|
|
805
|
-
const { fetchOptions, query: _query, ...body } = args || {};
|
|
806
|
-
if (method) return method;
|
|
807
|
-
if (fetchOptions?.method) return fetchOptions.method;
|
|
808
|
-
if (body && Object.keys(body).length > 0) return "POST";
|
|
809
|
-
return "GET";
|
|
810
|
-
}
|
|
811
|
-
function createDynamicPathProxy(routes, client, knownPathMethods, atoms, atomListeners) {
|
|
812
|
-
function createProxy(path = []) {
|
|
813
|
-
return new Proxy(function() {}, {
|
|
814
|
-
get(_, prop) {
|
|
815
|
-
if (typeof prop !== "string") return;
|
|
816
|
-
if (prop === "then" || prop === "catch" || prop === "finally") return;
|
|
817
|
-
const fullPath = [...path, prop];
|
|
818
|
-
let current = routes;
|
|
819
|
-
for (const segment of fullPath) if (current && typeof current === "object" && segment in current) current = current[segment];
|
|
820
|
-
else {
|
|
821
|
-
current = void 0;
|
|
822
|
-
break;
|
|
823
|
-
}
|
|
824
|
-
if (typeof current === "function") return current;
|
|
825
|
-
if (isAtom(current)) return current;
|
|
826
|
-
return createProxy(fullPath);
|
|
827
|
-
},
|
|
828
|
-
apply: async (_, __, args) => {
|
|
829
|
-
const routePath = "/" + path.map(toKebabCase).join("/");
|
|
830
|
-
const arg = args[0] || {};
|
|
831
|
-
const fetchOptions = args[1] || {};
|
|
832
|
-
const { query, fetchOptions: argFetchOptions, ...body } = arg;
|
|
833
|
-
const options = {
|
|
834
|
-
...fetchOptions,
|
|
835
|
-
...argFetchOptions
|
|
836
|
-
};
|
|
837
|
-
const method = getMethod(routePath, knownPathMethods, arg);
|
|
838
|
-
return await client(routePath, {
|
|
839
|
-
...options,
|
|
840
|
-
body: method === "GET" ? void 0 : {
|
|
841
|
-
...body,
|
|
842
|
-
...options?.body || {}
|
|
843
|
-
},
|
|
844
|
-
query: query || options?.query,
|
|
845
|
-
method,
|
|
846
|
-
async onSuccess(context) {
|
|
847
|
-
await options?.onSuccess?.(context);
|
|
848
|
-
if (!atomListeners || options.disableSignal) return;
|
|
849
|
-
/**
|
|
850
|
-
* We trigger listeners
|
|
851
|
-
*/
|
|
852
|
-
const matches = atomListeners.filter((s) => s.matcher(routePath));
|
|
853
|
-
if (!matches.length) return;
|
|
854
|
-
const visited = /* @__PURE__ */ new Set();
|
|
855
|
-
for (const match of matches) {
|
|
856
|
-
const signal = atoms[match.signal];
|
|
857
|
-
if (!signal) return;
|
|
858
|
-
if (visited.has(match.signal)) continue;
|
|
859
|
-
visited.add(match.signal);
|
|
860
|
-
/**
|
|
861
|
-
* To avoid race conditions we set the signal in a setTimeout
|
|
862
|
-
*/
|
|
863
|
-
const val = signal.get();
|
|
864
|
-
setTimeout(() => {
|
|
865
|
-
signal.set(!val);
|
|
866
|
-
}, 10);
|
|
867
|
-
match.callback?.(routePath);
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
});
|
|
871
|
-
}
|
|
872
|
-
});
|
|
873
|
-
}
|
|
874
|
-
return createProxy();
|
|
875
|
-
}
|
|
876
|
-
//#endregion
|
|
877
|
-
//#region ../../node_modules/.pnpm/better-auth@1.7.1_@cloudflare+workers-types@4.20260702.1_drizzle-kit@0.31.10_drizzle-or_50a74384dde6bad88008886f8a6ac592/node_modules/better-auth/dist/client/vanilla.mjs
|
|
878
|
-
function createAuthClient(options) {
|
|
879
|
-
const { pluginPathMethods, pluginsActions, pluginsAtoms, hydrateSession, $fetch, atomListeners, $store } = getClientConfig(options);
|
|
880
|
-
const resolvedHooks = {};
|
|
881
|
-
for (const [key, value] of Object.entries(pluginsAtoms)) resolvedHooks[`use${capitalizeFirstLetter(key)}`] = value;
|
|
882
|
-
return createDynamicPathProxy({
|
|
883
|
-
...pluginsActions,
|
|
884
|
-
...resolvedHooks,
|
|
885
|
-
hydrateSession,
|
|
886
|
-
$fetch,
|
|
887
|
-
$store
|
|
888
|
-
}, $fetch, pluginPathMethods, pluginsAtoms, atomListeners);
|
|
889
|
-
}
|
|
890
|
-
//#endregion
|
|
891
|
-
//#region src/lib/auth-client.ts
|
|
892
|
-
var authClient = createAuthClient();
|
|
893
|
-
//#endregion
|
|
894
|
-
export { authClient as t };
|