@omerdlw/base-framework 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/LICENSE +1 -1
- package/README.md +121 -52
- package/dist/hooks/index.d.ts +1 -10
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +2 -538
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/types.d.ts +0 -53
- package/dist/hooks/types.d.ts.map +1 -1
- package/dist/hooks/use-global-event.d.ts +0 -2
- package/dist/hooks/use-global-event.d.ts.map +1 -1
- package/dist/index.js +138 -742
- package/dist/index.js.map +1 -1
- package/dist/kernel/index.js +3 -3
- package/dist/kernel/index.js.map +1 -1
- package/dist/modules/ambient/index.js.map +1 -1
- package/dist/modules/background/index.js +5 -5
- package/dist/modules/background/index.js.map +1 -1
- package/dist/modules/context-menu/index.js +4 -4
- package/dist/modules/context-menu/index.js.map +1 -1
- package/dist/modules/controls/index.js +3 -3
- package/dist/modules/controls/index.js.map +1 -1
- package/dist/modules/dock/cards.d.ts +1 -1
- package/dist/modules/dock/hooks.d.ts +1 -1
- package/dist/modules/dock/index.js +3 -3
- package/dist/modules/dock/index.js.map +1 -1
- package/dist/modules/index.js +34 -115
- package/dist/modules/index.js.map +1 -1
- package/dist/modules/loading/index.js +3 -3
- package/dist/modules/loading/index.js.map +1 -1
- package/dist/modules/media/index.js.map +1 -1
- package/dist/modules/modal/index.js +11 -95
- package/dist/modules/modal/index.js.map +1 -1
- package/dist/modules/notification/index.js +7 -5
- package/dist/modules/notification/index.js.map +1 -1
- package/dist/provider.js.map +1 -1
- package/dist/utils/dom.d.ts +0 -2
- package/dist/utils/dom.d.ts.map +1 -1
- package/dist/utils/index.d.ts +5 -6
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +19 -84
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/number.d.ts +0 -1
- package/dist/utils/number.d.ts.map +1 -1
- package/dist/utils/object.d.ts +0 -2
- package/dist/utils/object.d.ts.map +1 -1
- package/dist/utils/string.d.ts +0 -3
- package/dist/utils/string.d.ts.map +1 -1
- package/dist/utils/timing.d.ts +0 -1
- package/dist/utils/timing.d.ts.map +1 -1
- package/docs/README.md +124 -0
- package/docs/architecture-and-rules.md +129 -0
- package/docs/core-engine.md +196 -0
- package/docs/custom-modules.md +267 -0
- package/docs/getting-started.md +199 -0
- package/docs/modules/README.md +176 -0
- package/docs/modules/ambient.md +150 -0
- package/docs/modules/background.md +195 -0
- package/docs/modules/context-menu.md +248 -0
- package/docs/modules/controls.md +159 -0
- package/docs/modules/dock.md +734 -0
- package/docs/modules/error-boundary.md +160 -0
- package/docs/modules/kernel.md +266 -0
- package/docs/modules/loading.md +157 -0
- package/docs/modules/media.md +196 -0
- package/docs/modules/modal.md +229 -0
- package/docs/modules/notification.md +161 -0
- package/docs/modules/result.md +135 -0
- package/docs/testing.md +160 -0
- package/docs/theming.md +185 -0
- package/package.json +3 -1
- package/templates/AGENTS.md +165 -0
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
3
|
import { twMerge } from 'tailwind-merge';
|
|
4
|
-
import React2, { memo, createContext, createElement, isValidElement, cloneElement, Suspense, useState, useRef, useEffect, useMemo, useCallback, use, useSyncExternalStore, useContext,
|
|
4
|
+
import React2, { memo, createContext, createElement, isValidElement, cloneElement, Suspense, useState, useRef, useEffect, useMemo, useCallback, use, useSyncExternalStore, useContext, useId, Fragment as Fragment$1, useLayoutEffect, useInsertionEffect, Children, useReducer, lazy } from 'react';
|
|
5
5
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
6
6
|
import { usePathname, useRouter } from 'next/navigation';
|
|
7
7
|
import { Icon as Icon$1 } from '@iconify-icon/react';
|
|
@@ -91,43 +91,6 @@ var init_cn = __esm({
|
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
93
|
|
|
94
|
-
// src/utils/string.ts
|
|
95
|
-
function trimToNull(value) {
|
|
96
|
-
if (value === null || value === void 0) return null;
|
|
97
|
-
const trimmed = String(value).trim();
|
|
98
|
-
return trimmed.length > 0 ? trimmed : null;
|
|
99
|
-
}
|
|
100
|
-
function stripTrailingSlash(url) {
|
|
101
|
-
if (typeof url !== "string") return "";
|
|
102
|
-
return url.replace(/\/+$/, "");
|
|
103
|
-
}
|
|
104
|
-
function normalizePath(path) {
|
|
105
|
-
const trimmed = trimToNull(path);
|
|
106
|
-
if (!trimmed) return "";
|
|
107
|
-
if (trimmed === "/") return "/";
|
|
108
|
-
return stripTrailingSlash(trimmed);
|
|
109
|
-
}
|
|
110
|
-
function isImageIconSource(icon) {
|
|
111
|
-
return typeof icon === "string" && (icon.startsWith("http://") || icon.startsWith("https://") || icon.startsWith("/") || icon.startsWith("data:image/"));
|
|
112
|
-
}
|
|
113
|
-
function truncate(text, maxLength = 100, suffix = "...") {
|
|
114
|
-
if (typeof text !== "string") return "";
|
|
115
|
-
if (text.length <= maxLength) return text;
|
|
116
|
-
return `${text.slice(0, maxLength).trimEnd()}${suffix}`;
|
|
117
|
-
}
|
|
118
|
-
function capitalize(str) {
|
|
119
|
-
if (typeof str !== "string" || !str) return "";
|
|
120
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
121
|
-
}
|
|
122
|
-
function slugify(str) {
|
|
123
|
-
if (typeof str !== "string" || !str) return "";
|
|
124
|
-
return str.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
125
|
-
}
|
|
126
|
-
var init_string = __esm({
|
|
127
|
-
"src/utils/string.ts"() {
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
|
|
131
94
|
// src/utils/dom.ts
|
|
132
95
|
function acquireGlobalScrollLock() {
|
|
133
96
|
if (typeof document === "undefined") return () => {
|
|
@@ -158,25 +121,39 @@ function acquireGlobalScrollLock() {
|
|
|
158
121
|
globalScrollLockStyles = null;
|
|
159
122
|
};
|
|
160
123
|
}
|
|
161
|
-
function getSiteUrl() {
|
|
162
|
-
return stripTrailingSlash(
|
|
163
|
-
process.env.NEXT_PUBLIC_SITE_URL || "http://localhost:3000"
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
function getCurrentPath() {
|
|
167
|
-
if (!isBrowser) return "/";
|
|
168
|
-
return `${window.location.pathname}${window.location.search}`;
|
|
169
|
-
}
|
|
170
124
|
var isBrowser, globalScrollLockCount, globalScrollLockStyles;
|
|
171
125
|
var init_dom = __esm({
|
|
172
126
|
"src/utils/dom.ts"() {
|
|
173
|
-
init_string();
|
|
174
127
|
isBrowser = typeof window !== "undefined";
|
|
175
128
|
globalScrollLockCount = 0;
|
|
176
129
|
globalScrollLockStyles = null;
|
|
177
130
|
}
|
|
178
131
|
});
|
|
179
132
|
|
|
133
|
+
// src/utils/string.ts
|
|
134
|
+
function trimToNull(value) {
|
|
135
|
+
if (value === null || value === void 0) return null;
|
|
136
|
+
const trimmed = String(value).trim();
|
|
137
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
138
|
+
}
|
|
139
|
+
function stripTrailingSlash(url) {
|
|
140
|
+
if (typeof url !== "string") return "";
|
|
141
|
+
return url.replace(/\/+$/, "");
|
|
142
|
+
}
|
|
143
|
+
function normalizePath(path) {
|
|
144
|
+
const trimmed = trimToNull(path);
|
|
145
|
+
if (!trimmed) return "";
|
|
146
|
+
if (trimmed === "/") return "/";
|
|
147
|
+
return stripTrailingSlash(trimmed);
|
|
148
|
+
}
|
|
149
|
+
function isImageIconSource(icon) {
|
|
150
|
+
return typeof icon === "string" && (icon.startsWith("http://") || icon.startsWith("https://") || icon.startsWith("/") || icon.startsWith("data:image/"));
|
|
151
|
+
}
|
|
152
|
+
var init_string = __esm({
|
|
153
|
+
"src/utils/string.ts"() {
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
|
|
180
157
|
// src/utils/number.ts
|
|
181
158
|
function clamp(value, min, max) {
|
|
182
159
|
const num = Number(value);
|
|
@@ -187,11 +164,6 @@ function toFiniteNumber(value, fallback = 0) {
|
|
|
187
164
|
const parsed = Number(value);
|
|
188
165
|
return Number.isFinite(parsed) ? parsed : fallback;
|
|
189
166
|
}
|
|
190
|
-
function randomBetween(min, max) {
|
|
191
|
-
const lower = Math.ceil(min);
|
|
192
|
-
const upper = Math.floor(max);
|
|
193
|
-
return Math.floor(Math.random() * (upper - lower + 1)) + lower;
|
|
194
|
-
}
|
|
195
167
|
var init_number = __esm({
|
|
196
168
|
"src/utils/number.ts"() {
|
|
197
169
|
}
|
|
@@ -206,13 +178,6 @@ function isPlainObject(value) {
|
|
|
206
178
|
const proto = Object.getPrototypeOf(value);
|
|
207
179
|
return proto === Object.prototype || proto === null;
|
|
208
180
|
}
|
|
209
|
-
function isEmpty(value) {
|
|
210
|
-
if (value === null || value === void 0) return true;
|
|
211
|
-
if (typeof value === "string" || Array.isArray(value))
|
|
212
|
-
return value.length === 0;
|
|
213
|
-
if (isObject(value)) return Object.keys(value).length === 0;
|
|
214
|
-
return false;
|
|
215
|
-
}
|
|
216
181
|
function shallowEqual(a, b) {
|
|
217
182
|
if (Object.is(a, b)) return true;
|
|
218
183
|
if (typeof a !== "object" || a === null || typeof b !== "object" || b === null) {
|
|
@@ -235,26 +200,12 @@ function toArray(value) {
|
|
|
235
200
|
if (value === null || value === void 0) return [];
|
|
236
201
|
return Array.isArray(value) ? value : [value];
|
|
237
202
|
}
|
|
238
|
-
function dedupe(array, keyFn = null) {
|
|
239
|
-
if (!Array.isArray(array)) return [];
|
|
240
|
-
if (!keyFn) return [...new Set(array)];
|
|
241
|
-
const seen = /* @__PURE__ */ new Set();
|
|
242
|
-
return array.filter((item) => {
|
|
243
|
-
const key = keyFn(item);
|
|
244
|
-
if (seen.has(key)) return false;
|
|
245
|
-
seen.add(key);
|
|
246
|
-
return true;
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
203
|
var init_object = __esm({
|
|
250
204
|
"src/utils/object.ts"() {
|
|
251
205
|
}
|
|
252
206
|
});
|
|
253
207
|
|
|
254
208
|
// src/utils/timing.ts
|
|
255
|
-
function sleep(ms = 0) {
|
|
256
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
257
|
-
}
|
|
258
209
|
function debounce(func, wait = 300) {
|
|
259
210
|
let timeoutId = null;
|
|
260
211
|
function debounced(...args) {
|
|
@@ -303,27 +254,6 @@ var init_timing = __esm({
|
|
|
303
254
|
}
|
|
304
255
|
});
|
|
305
256
|
|
|
306
|
-
// src/utils/json.ts
|
|
307
|
-
function safeJsonParse(text, fallback = null) {
|
|
308
|
-
if (typeof text !== "string") return fallback;
|
|
309
|
-
try {
|
|
310
|
-
return JSON.parse(text);
|
|
311
|
-
} catch {
|
|
312
|
-
return fallback;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
function safeJsonStringify(value, fallback = "") {
|
|
316
|
-
try {
|
|
317
|
-
return JSON.stringify(value) ?? fallback;
|
|
318
|
-
} catch {
|
|
319
|
-
return fallback;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
var init_json = __esm({
|
|
323
|
-
"src/utils/json.ts"() {
|
|
324
|
-
}
|
|
325
|
-
});
|
|
326
|
-
|
|
327
257
|
// src/utils/report.ts
|
|
328
258
|
function report(scope, error, level = "error") {
|
|
329
259
|
if (sink) {
|
|
@@ -621,7 +551,6 @@ var init_utils = __esm({
|
|
|
621
551
|
init_number();
|
|
622
552
|
init_object();
|
|
623
553
|
init_timing();
|
|
624
|
-
init_json();
|
|
625
554
|
init_report();
|
|
626
555
|
init_user_message();
|
|
627
556
|
init_store();
|
|
@@ -1233,170 +1162,6 @@ var init_use_isomorphic_layout_effect = __esm({
|
|
|
1233
1162
|
useIsomorphicLayoutEffect = isBrowser ? useLayoutEffect : useEffect;
|
|
1234
1163
|
}
|
|
1235
1164
|
});
|
|
1236
|
-
function useDebounce(value, delay = 300) {
|
|
1237
|
-
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
1238
|
-
useEffect(() => {
|
|
1239
|
-
const timer = setTimeout(() => setDebouncedValue(value), delay);
|
|
1240
|
-
return () => clearTimeout(timer);
|
|
1241
|
-
}, [value, delay]);
|
|
1242
|
-
return debouncedValue;
|
|
1243
|
-
}
|
|
1244
|
-
var init_use_debounce = __esm({
|
|
1245
|
-
"src/hooks/use-debounce.ts"() {
|
|
1246
|
-
"use client";
|
|
1247
|
-
}
|
|
1248
|
-
});
|
|
1249
|
-
function useMounted() {
|
|
1250
|
-
return useSyncExternalStore(
|
|
1251
|
-
emptySubscribe,
|
|
1252
|
-
() => true,
|
|
1253
|
-
() => false
|
|
1254
|
-
);
|
|
1255
|
-
}
|
|
1256
|
-
var emptySubscribe;
|
|
1257
|
-
var init_use_mounted = __esm({
|
|
1258
|
-
"src/hooks/use-mounted.ts"() {
|
|
1259
|
-
"use client";
|
|
1260
|
-
emptySubscribe = () => () => {
|
|
1261
|
-
};
|
|
1262
|
-
}
|
|
1263
|
-
});
|
|
1264
|
-
function useMediaQuery(query, serverFallback = false) {
|
|
1265
|
-
const subscribe2 = useCallback(
|
|
1266
|
-
(onStoreChange) => {
|
|
1267
|
-
if (!isBrowser || !query || typeof window.matchMedia !== "function") {
|
|
1268
|
-
return () => {
|
|
1269
|
-
};
|
|
1270
|
-
}
|
|
1271
|
-
const mediaQueryList = window.matchMedia(query);
|
|
1272
|
-
mediaQueryList.addEventListener("change", onStoreChange);
|
|
1273
|
-
return () => mediaQueryList.removeEventListener("change", onStoreChange);
|
|
1274
|
-
},
|
|
1275
|
-
[query]
|
|
1276
|
-
);
|
|
1277
|
-
const getSnapshot2 = useCallback(() => {
|
|
1278
|
-
if (!isBrowser || !query || typeof window.matchMedia !== "function") {
|
|
1279
|
-
return serverFallback;
|
|
1280
|
-
}
|
|
1281
|
-
return window.matchMedia(query).matches;
|
|
1282
|
-
}, [query, serverFallback]);
|
|
1283
|
-
const getServerSnapshot = useCallback(() => serverFallback, [serverFallback]);
|
|
1284
|
-
return useSyncExternalStore(subscribe2, getSnapshot2, getServerSnapshot);
|
|
1285
|
-
}
|
|
1286
|
-
var init_use_media_query = __esm({
|
|
1287
|
-
"src/hooks/use-media-query.ts"() {
|
|
1288
|
-
"use client";
|
|
1289
|
-
init_utils();
|
|
1290
|
-
}
|
|
1291
|
-
});
|
|
1292
|
-
function useControllableState({
|
|
1293
|
-
defaultValue,
|
|
1294
|
-
onChange,
|
|
1295
|
-
value
|
|
1296
|
-
}) {
|
|
1297
|
-
const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);
|
|
1298
|
-
const isControlled = value !== void 0;
|
|
1299
|
-
const currentValue = isControlled ? value : uncontrolledValue;
|
|
1300
|
-
const valueRef = useRef(currentValue);
|
|
1301
|
-
const onChangeRef = useRef(onChange);
|
|
1302
|
-
useIsomorphicLayoutEffect(() => {
|
|
1303
|
-
valueRef.current = currentValue;
|
|
1304
|
-
onChangeRef.current = onChange;
|
|
1305
|
-
});
|
|
1306
|
-
const setValue = useCallback(
|
|
1307
|
-
(next) => {
|
|
1308
|
-
const resolvedNext = typeof next === "function" ? next(valueRef.current) : next;
|
|
1309
|
-
if (!Object.is(valueRef.current, resolvedNext)) {
|
|
1310
|
-
if (!isControlled) {
|
|
1311
|
-
setUncontrolledValue(resolvedNext);
|
|
1312
|
-
}
|
|
1313
|
-
onChangeRef.current?.(resolvedNext);
|
|
1314
|
-
}
|
|
1315
|
-
},
|
|
1316
|
-
[isControlled]
|
|
1317
|
-
);
|
|
1318
|
-
return [currentValue, setValue];
|
|
1319
|
-
}
|
|
1320
|
-
var init_use_controllable_state = __esm({
|
|
1321
|
-
"src/hooks/use-controllable-state.ts"() {
|
|
1322
|
-
"use client";
|
|
1323
|
-
init_use_isomorphic_layout_effect();
|
|
1324
|
-
}
|
|
1325
|
-
});
|
|
1326
|
-
function isEditableElement(target) {
|
|
1327
|
-
if (!target || typeof target.tagName !== "string") {
|
|
1328
|
-
return false;
|
|
1329
|
-
}
|
|
1330
|
-
const element = target;
|
|
1331
|
-
const tagName = element.tagName.toLowerCase();
|
|
1332
|
-
if (tagName === "input" || tagName === "textarea" || tagName === "select") {
|
|
1333
|
-
return true;
|
|
1334
|
-
}
|
|
1335
|
-
return Boolean(element.isContentEditable);
|
|
1336
|
-
}
|
|
1337
|
-
function matchesKeyCombo(event, combo) {
|
|
1338
|
-
const parts = combo.toLowerCase().split("+").map((p) => p.trim()).filter(Boolean);
|
|
1339
|
-
if (parts.length === 0) return false;
|
|
1340
|
-
const keyPart = parts[parts.length - 1];
|
|
1341
|
-
const modifiers = new Set(parts.slice(0, -1));
|
|
1342
|
-
const wantsMod = modifiers.has("mod") || modifiers.has("cmd") || modifiers.has("meta");
|
|
1343
|
-
const wantsCtrl = modifiers.has("ctrl") || modifiers.has("control");
|
|
1344
|
-
const wantsAlt = modifiers.has("alt") || modifiers.has("option");
|
|
1345
|
-
const wantsShift = modifiers.has("shift");
|
|
1346
|
-
const isModPressed = event.metaKey || event.ctrlKey;
|
|
1347
|
-
if (wantsMod && !isModPressed) return false;
|
|
1348
|
-
if (!wantsMod && !wantsCtrl && (event.metaKey || event.ctrlKey)) return false;
|
|
1349
|
-
if (wantsCtrl && !event.ctrlKey) return false;
|
|
1350
|
-
if (wantsAlt !== event.altKey) return false;
|
|
1351
|
-
if (wantsShift !== event.shiftKey) return false;
|
|
1352
|
-
const pressedKey = event.key.toLowerCase();
|
|
1353
|
-
if (keyPart === "esc" || keyPart === "escape") {
|
|
1354
|
-
return pressedKey === "escape" || pressedKey === "esc";
|
|
1355
|
-
}
|
|
1356
|
-
if (keyPart === "space") {
|
|
1357
|
-
return pressedKey === " " || pressedKey === "spacebar";
|
|
1358
|
-
}
|
|
1359
|
-
return pressedKey === keyPart;
|
|
1360
|
-
}
|
|
1361
|
-
function useHotkey(combo, callback, options) {
|
|
1362
|
-
const callbackRef = useRef(callback);
|
|
1363
|
-
useIsomorphicLayoutEffect(() => {
|
|
1364
|
-
callbackRef.current = callback;
|
|
1365
|
-
});
|
|
1366
|
-
const enabled = options?.enabled ?? true;
|
|
1367
|
-
const enableOnFormTags = options?.enableOnFormTags ?? false;
|
|
1368
|
-
const preventDefault = options?.preventDefault ?? true;
|
|
1369
|
-
const stopPropagation = options?.stopPropagation ?? false;
|
|
1370
|
-
useEffect(() => {
|
|
1371
|
-
if (!isBrowser || !enabled || !combo) return;
|
|
1372
|
-
const combos = (Array.isArray(combo) ? combo : [combo]).filter(Boolean);
|
|
1373
|
-
if (combos.length === 0) return;
|
|
1374
|
-
const handleKeyDown = (event) => {
|
|
1375
|
-
if (!enableOnFormTags && isEditableElement(event.target)) return;
|
|
1376
|
-
const matched = combos.some((c) => matchesKeyCombo(event, c));
|
|
1377
|
-
if (!matched) return;
|
|
1378
|
-
if (preventDefault) event.preventDefault();
|
|
1379
|
-
if (stopPropagation) event.stopPropagation();
|
|
1380
|
-
callbackRef.current?.(event);
|
|
1381
|
-
};
|
|
1382
|
-
window.addEventListener("keydown", handleKeyDown);
|
|
1383
|
-
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
1384
|
-
}, [combo, enabled, enableOnFormTags, preventDefault, stopPropagation]);
|
|
1385
|
-
}
|
|
1386
|
-
function useEscapeKey(callback, enabled = true) {
|
|
1387
|
-
useHotkey("escape", callback, {
|
|
1388
|
-
enabled,
|
|
1389
|
-
enableOnFormTags: true,
|
|
1390
|
-
preventDefault: false
|
|
1391
|
-
});
|
|
1392
|
-
}
|
|
1393
|
-
var init_use_hotkey = __esm({
|
|
1394
|
-
"src/hooks/use-hotkey.ts"() {
|
|
1395
|
-
"use client";
|
|
1396
|
-
init_utils();
|
|
1397
|
-
init_use_isomorphic_layout_effect();
|
|
1398
|
-
}
|
|
1399
|
-
});
|
|
1400
1165
|
|
|
1401
1166
|
// src/events.ts
|
|
1402
1167
|
var EVENT_TYPES, EventEmitter, GLOBAL_EVENTS_KEY, _global, globalEvents;
|
|
@@ -1540,48 +1305,6 @@ function useGlobalEvent(event, callback, options) {
|
|
|
1540
1305
|
};
|
|
1541
1306
|
}, [event, debounceMs, throttleMs]);
|
|
1542
1307
|
}
|
|
1543
|
-
function useEventState(event, initialValue, reducer) {
|
|
1544
|
-
const storeRef = useRef(null);
|
|
1545
|
-
if (storeRef.current == null) {
|
|
1546
|
-
storeRef.current = {
|
|
1547
|
-
value: initialValue,
|
|
1548
|
-
listeners: /* @__PURE__ */ new Set(),
|
|
1549
|
-
reducer
|
|
1550
|
-
};
|
|
1551
|
-
}
|
|
1552
|
-
useIsomorphicLayoutEffect(() => {
|
|
1553
|
-
if (storeRef.current != null) {
|
|
1554
|
-
storeRef.current.reducer = reducer;
|
|
1555
|
-
}
|
|
1556
|
-
});
|
|
1557
|
-
const subscribe2 = useCallback(
|
|
1558
|
-
(onStoreChange) => {
|
|
1559
|
-
if (!event || !storeRef.current) return () => {
|
|
1560
|
-
};
|
|
1561
|
-
storeRef.current.listeners.add(onStoreChange);
|
|
1562
|
-
const unsub = globalEvents.subscribe(event, (payload) => {
|
|
1563
|
-
if (!storeRef.current) return;
|
|
1564
|
-
const next = storeRef.current.reducer(storeRef.current.value, payload);
|
|
1565
|
-
if (!Object.is(storeRef.current.value, next)) {
|
|
1566
|
-
storeRef.current.value = next;
|
|
1567
|
-
storeRef.current.listeners.forEach((listener) => listener());
|
|
1568
|
-
}
|
|
1569
|
-
});
|
|
1570
|
-
return () => {
|
|
1571
|
-
storeRef.current?.listeners.delete(onStoreChange);
|
|
1572
|
-
unsub();
|
|
1573
|
-
};
|
|
1574
|
-
},
|
|
1575
|
-
[event]
|
|
1576
|
-
);
|
|
1577
|
-
const getSnapshot2 = useCallback(() => {
|
|
1578
|
-
return storeRef.current?.value ?? initialValue;
|
|
1579
|
-
}, [initialValue]);
|
|
1580
|
-
const getServerSnapshot = useCallback(() => {
|
|
1581
|
-
return initialValue;
|
|
1582
|
-
}, [initialValue]);
|
|
1583
|
-
return useSyncExternalStore(subscribe2, getSnapshot2, getServerSnapshot);
|
|
1584
|
-
}
|
|
1585
1308
|
var init_use_global_event = __esm({
|
|
1586
1309
|
"src/hooks/use-global-event.ts"() {
|
|
1587
1310
|
"use client";
|
|
@@ -1589,420 +1312,6 @@ var init_use_global_event = __esm({
|
|
|
1589
1312
|
init_use_isomorphic_layout_effect();
|
|
1590
1313
|
}
|
|
1591
1314
|
});
|
|
1592
|
-
|
|
1593
|
-
// src/result.ts
|
|
1594
|
-
function ok(data, code) {
|
|
1595
|
-
return { data, success: true, ...code ? { code } : {} };
|
|
1596
|
-
}
|
|
1597
|
-
function err(error, code) {
|
|
1598
|
-
return { error, success: false, ...code ? { code } : {} };
|
|
1599
|
-
}
|
|
1600
|
-
function isResult(value) {
|
|
1601
|
-
return typeof value === "object" && value !== null && "success" in value && typeof value.success === "boolean" && ("data" in value && value.success === true || "error" in value && value.success === false);
|
|
1602
|
-
}
|
|
1603
|
-
function isOk(result) {
|
|
1604
|
-
return result.success === true;
|
|
1605
|
-
}
|
|
1606
|
-
function isErr(result) {
|
|
1607
|
-
return result.success === false;
|
|
1608
|
-
}
|
|
1609
|
-
function unwrap(result) {
|
|
1610
|
-
if (result.success) {
|
|
1611
|
-
return result.data;
|
|
1612
|
-
}
|
|
1613
|
-
if (result.error instanceof Error) {
|
|
1614
|
-
throw result.error;
|
|
1615
|
-
}
|
|
1616
|
-
throw new Error(
|
|
1617
|
-
typeof result.error === "string" ? result.error : String(result.error)
|
|
1618
|
-
);
|
|
1619
|
-
}
|
|
1620
|
-
function unwrapOr(result, fallback) {
|
|
1621
|
-
return result.success ? result.data : fallback;
|
|
1622
|
-
}
|
|
1623
|
-
function map(result, fn) {
|
|
1624
|
-
return result.success ? ok(fn(result.data), result.code) : result;
|
|
1625
|
-
}
|
|
1626
|
-
function mapErr(result, fn) {
|
|
1627
|
-
return result.success ? result : err(fn(result.error), result.code);
|
|
1628
|
-
}
|
|
1629
|
-
function match(result, branches) {
|
|
1630
|
-
return result.success ? branches.ok(result.data) : branches.err(result.error);
|
|
1631
|
-
}
|
|
1632
|
-
function mapCaught(error, mapError) {
|
|
1633
|
-
if (!(error instanceof UserError)) report("Result", error);
|
|
1634
|
-
return mapError ? mapError(error) : toUserMessage(error);
|
|
1635
|
-
}
|
|
1636
|
-
async function tryCatch(promiseOrFn, mapError) {
|
|
1637
|
-
try {
|
|
1638
|
-
const data = typeof promiseOrFn === "function" ? await promiseOrFn() : await promiseOrFn;
|
|
1639
|
-
return ok(data);
|
|
1640
|
-
} catch (error) {
|
|
1641
|
-
return err(mapCaught(error, mapError));
|
|
1642
|
-
}
|
|
1643
|
-
}
|
|
1644
|
-
function createSafeAction(handler, options = {}) {
|
|
1645
|
-
const { errorCode, mapError, schema, validate } = options;
|
|
1646
|
-
return async (...args) => {
|
|
1647
|
-
try {
|
|
1648
|
-
let effectiveArgs = args;
|
|
1649
|
-
if (schema) {
|
|
1650
|
-
const parsed = schema.safeParse(args[0]);
|
|
1651
|
-
if (!parsed.success) {
|
|
1652
|
-
const issueMessage = parsed.error?.issues?.[0]?.message || parsed.error?.message || "Invalid input";
|
|
1653
|
-
return err(
|
|
1654
|
-
mapError ? mapError(issueMessage) : issueMessage,
|
|
1655
|
-
errorCode ?? "VALIDATION_ERROR"
|
|
1656
|
-
);
|
|
1657
|
-
}
|
|
1658
|
-
effectiveArgs = [parsed.data, ...args.slice(1)];
|
|
1659
|
-
}
|
|
1660
|
-
if (validate) {
|
|
1661
|
-
const validationResult = validate(...effectiveArgs);
|
|
1662
|
-
if (isResult(validationResult)) {
|
|
1663
|
-
if (isErr(validationResult)) {
|
|
1664
|
-
return validationResult;
|
|
1665
|
-
}
|
|
1666
|
-
} else if (validationResult === false) {
|
|
1667
|
-
return err(
|
|
1668
|
-
mapError ? mapError("Validation failed") : "Validation failed",
|
|
1669
|
-
errorCode ?? "VALIDATION_ERROR"
|
|
1670
|
-
);
|
|
1671
|
-
} else if (typeof validationResult === "string" && validationResult.length > 0) {
|
|
1672
|
-
return err(
|
|
1673
|
-
mapError ? mapError(validationResult) : validationResult,
|
|
1674
|
-
errorCode ?? "VALIDATION_ERROR"
|
|
1675
|
-
);
|
|
1676
|
-
}
|
|
1677
|
-
}
|
|
1678
|
-
const output = await handler(...effectiveArgs);
|
|
1679
|
-
if (isResult(output)) {
|
|
1680
|
-
return output;
|
|
1681
|
-
}
|
|
1682
|
-
return ok(output);
|
|
1683
|
-
} catch (error) {
|
|
1684
|
-
return err(mapCaught(error, mapError), errorCode);
|
|
1685
|
-
}
|
|
1686
|
-
};
|
|
1687
|
-
}
|
|
1688
|
-
var init_result = __esm({
|
|
1689
|
-
"src/result.ts"() {
|
|
1690
|
-
init_user_message();
|
|
1691
|
-
init_report();
|
|
1692
|
-
}
|
|
1693
|
-
});
|
|
1694
|
-
function useAsyncAction(actionFn, options = {}) {
|
|
1695
|
-
const {
|
|
1696
|
-
errorMessage = null,
|
|
1697
|
-
onError = null,
|
|
1698
|
-
onSuccess = null,
|
|
1699
|
-
successMessage = null,
|
|
1700
|
-
toast = null
|
|
1701
|
-
} = options;
|
|
1702
|
-
const [isPending, setIsPending] = useState(false);
|
|
1703
|
-
const [error, setError] = useState(null);
|
|
1704
|
-
const execute = useCallback(
|
|
1705
|
-
async (...args) => {
|
|
1706
|
-
setIsPending(true);
|
|
1707
|
-
setError(null);
|
|
1708
|
-
try {
|
|
1709
|
-
const result = await actionFn(...args);
|
|
1710
|
-
if (isResult(result) && isErr(result)) {
|
|
1711
|
-
setError(result.error);
|
|
1712
|
-
const resolvedMessage = errorMessage || toUserMessage(result.error);
|
|
1713
|
-
if (typeof toast === "function") {
|
|
1714
|
-
toast(resolvedMessage);
|
|
1715
|
-
}
|
|
1716
|
-
globalEvents.emit(EVENT_TYPES.APP_ERROR, {
|
|
1717
|
-
error: result.error,
|
|
1718
|
-
message: resolvedMessage,
|
|
1719
|
-
notify: toast === true
|
|
1720
|
-
});
|
|
1721
|
-
await onError?.(result.error);
|
|
1722
|
-
return result;
|
|
1723
|
-
}
|
|
1724
|
-
if (successMessage) {
|
|
1725
|
-
if (typeof toast === "function") {
|
|
1726
|
-
toast(successMessage);
|
|
1727
|
-
}
|
|
1728
|
-
globalEvents.emit(EVENT_TYPES.STATE_CHANGE, {
|
|
1729
|
-
message: successMessage,
|
|
1730
|
-
notify: toast === true,
|
|
1731
|
-
status: "success"
|
|
1732
|
-
});
|
|
1733
|
-
}
|
|
1734
|
-
await onSuccess?.(result);
|
|
1735
|
-
return result;
|
|
1736
|
-
} catch (err2) {
|
|
1737
|
-
setError(err2);
|
|
1738
|
-
const resolvedMessage = errorMessage || toUserMessage(err2);
|
|
1739
|
-
if (typeof toast === "function") {
|
|
1740
|
-
toast(resolvedMessage);
|
|
1741
|
-
}
|
|
1742
|
-
globalEvents.emit(EVENT_TYPES.APP_ERROR, {
|
|
1743
|
-
error: err2,
|
|
1744
|
-
message: resolvedMessage,
|
|
1745
|
-
notify: toast === true
|
|
1746
|
-
});
|
|
1747
|
-
await onError?.(err2);
|
|
1748
|
-
throw err2;
|
|
1749
|
-
} finally {
|
|
1750
|
-
setIsPending(false);
|
|
1751
|
-
}
|
|
1752
|
-
},
|
|
1753
|
-
[actionFn, errorMessage, onError, onSuccess, successMessage, toast]
|
|
1754
|
-
);
|
|
1755
|
-
return { error, execute, isPending };
|
|
1756
|
-
}
|
|
1757
|
-
var init_use_async_action = __esm({
|
|
1758
|
-
"src/hooks/use-async-action.ts"() {
|
|
1759
|
-
"use client";
|
|
1760
|
-
init_events();
|
|
1761
|
-
init_result();
|
|
1762
|
-
init_utils();
|
|
1763
|
-
}
|
|
1764
|
-
});
|
|
1765
|
-
function useServerAction(actionFn, options = {}) {
|
|
1766
|
-
const {
|
|
1767
|
-
errorMessage = null,
|
|
1768
|
-
onError = null,
|
|
1769
|
-
onSuccess = null,
|
|
1770
|
-
successMessage = null,
|
|
1771
|
-
toast = null
|
|
1772
|
-
} = options;
|
|
1773
|
-
const [isPending, startTransition] = useTransition();
|
|
1774
|
-
const [data, setData] = useState(null);
|
|
1775
|
-
const [error, setError] = useState(null);
|
|
1776
|
-
const reset = useCallback(() => {
|
|
1777
|
-
setData(null);
|
|
1778
|
-
setError(null);
|
|
1779
|
-
}, []);
|
|
1780
|
-
const execute = useCallback(
|
|
1781
|
-
(...args) => {
|
|
1782
|
-
return new Promise((resolve) => {
|
|
1783
|
-
startTransition(async () => {
|
|
1784
|
-
setError(null);
|
|
1785
|
-
try {
|
|
1786
|
-
const result = await actionFn(...args);
|
|
1787
|
-
if (isErr(result)) {
|
|
1788
|
-
setError(result.error);
|
|
1789
|
-
const resolvedMessage = errorMessage || toUserMessage(result.error);
|
|
1790
|
-
if (typeof toast === "function") {
|
|
1791
|
-
toast(resolvedMessage);
|
|
1792
|
-
}
|
|
1793
|
-
globalEvents.emit(EVENT_TYPES.APP_ERROR, {
|
|
1794
|
-
error: result.error,
|
|
1795
|
-
message: resolvedMessage,
|
|
1796
|
-
notify: toast === true
|
|
1797
|
-
});
|
|
1798
|
-
await onError?.(result.error);
|
|
1799
|
-
resolve(result);
|
|
1800
|
-
return;
|
|
1801
|
-
}
|
|
1802
|
-
setData(result.data);
|
|
1803
|
-
if (successMessage) {
|
|
1804
|
-
if (typeof toast === "function") {
|
|
1805
|
-
toast(successMessage);
|
|
1806
|
-
}
|
|
1807
|
-
globalEvents.emit(EVENT_TYPES.STATE_CHANGE, {
|
|
1808
|
-
message: successMessage,
|
|
1809
|
-
notify: toast === true,
|
|
1810
|
-
status: "success"
|
|
1811
|
-
});
|
|
1812
|
-
}
|
|
1813
|
-
await onSuccess?.(result.data);
|
|
1814
|
-
resolve(result);
|
|
1815
|
-
} catch (err2) {
|
|
1816
|
-
const mappedError = toUserMessage(err2);
|
|
1817
|
-
setError(mappedError);
|
|
1818
|
-
const resolvedMessage = errorMessage || mappedError;
|
|
1819
|
-
if (typeof toast === "function") {
|
|
1820
|
-
toast(resolvedMessage);
|
|
1821
|
-
}
|
|
1822
|
-
globalEvents.emit(EVENT_TYPES.APP_ERROR, {
|
|
1823
|
-
error: err2,
|
|
1824
|
-
message: resolvedMessage,
|
|
1825
|
-
notify: toast === true
|
|
1826
|
-
});
|
|
1827
|
-
await onError?.(mappedError);
|
|
1828
|
-
resolve(err(mappedError));
|
|
1829
|
-
}
|
|
1830
|
-
});
|
|
1831
|
-
});
|
|
1832
|
-
},
|
|
1833
|
-
[actionFn, errorMessage, onError, onSuccess, successMessage, toast]
|
|
1834
|
-
);
|
|
1835
|
-
return { data, error, execute, isPending, reset };
|
|
1836
|
-
}
|
|
1837
|
-
var init_use_server_action = __esm({
|
|
1838
|
-
"src/hooks/use-server-action.ts"() {
|
|
1839
|
-
"use client";
|
|
1840
|
-
init_events();
|
|
1841
|
-
init_result();
|
|
1842
|
-
init_utils();
|
|
1843
|
-
}
|
|
1844
|
-
});
|
|
1845
|
-
function getStorageInstance(type) {
|
|
1846
|
-
if (!isBrowser) return null;
|
|
1847
|
-
try {
|
|
1848
|
-
return type === "session" ? window.sessionStorage : window.localStorage;
|
|
1849
|
-
} catch {
|
|
1850
|
-
return null;
|
|
1851
|
-
}
|
|
1852
|
-
}
|
|
1853
|
-
function useStorageState(key, initialValue, options = {}) {
|
|
1854
|
-
const storageType = options.storage ?? "local";
|
|
1855
|
-
const serialize = options.serialize ?? JSON.stringify;
|
|
1856
|
-
const deserialize = options.deserialize ?? JSON.parse;
|
|
1857
|
-
const cacheRef = useRef({
|
|
1858
|
-
parsed: initialValue,
|
|
1859
|
-
raw: null
|
|
1860
|
-
});
|
|
1861
|
-
const getSnapshot2 = useCallback(() => {
|
|
1862
|
-
const storage = getStorageInstance(storageType);
|
|
1863
|
-
if (!storage) return initialValue;
|
|
1864
|
-
try {
|
|
1865
|
-
const raw = storage.getItem(key);
|
|
1866
|
-
if (raw === null) {
|
|
1867
|
-
cacheRef.current = { parsed: initialValue, raw: null };
|
|
1868
|
-
return initialValue;
|
|
1869
|
-
}
|
|
1870
|
-
if (cacheRef.current.raw === raw) {
|
|
1871
|
-
return cacheRef.current.parsed;
|
|
1872
|
-
}
|
|
1873
|
-
const parsed = deserialize(raw);
|
|
1874
|
-
cacheRef.current = { parsed, raw };
|
|
1875
|
-
return parsed;
|
|
1876
|
-
} catch {
|
|
1877
|
-
return initialValue;
|
|
1878
|
-
}
|
|
1879
|
-
}, [deserialize, initialValue, key, storageType]);
|
|
1880
|
-
const getServerSnapshot = useCallback(() => initialValue, [initialValue]);
|
|
1881
|
-
const subscribe2 = useCallback(
|
|
1882
|
-
(onStoreChange) => {
|
|
1883
|
-
if (!isBrowser) return () => {
|
|
1884
|
-
};
|
|
1885
|
-
const handleStorage = (event) => {
|
|
1886
|
-
if (event.key === key && event.storageArea === getStorageInstance(storageType)) {
|
|
1887
|
-
onStoreChange();
|
|
1888
|
-
}
|
|
1889
|
-
};
|
|
1890
|
-
const handleCustomSync = (event) => {
|
|
1891
|
-
const detail = event.detail;
|
|
1892
|
-
if (detail?.key === key && detail?.storageType === storageType) {
|
|
1893
|
-
onStoreChange();
|
|
1894
|
-
}
|
|
1895
|
-
};
|
|
1896
|
-
window.addEventListener("storage", handleStorage);
|
|
1897
|
-
window.addEventListener(STORAGE_SYNC_EVENT, handleCustomSync);
|
|
1898
|
-
return () => {
|
|
1899
|
-
window.removeEventListener("storage", handleStorage);
|
|
1900
|
-
window.removeEventListener(STORAGE_SYNC_EVENT, handleCustomSync);
|
|
1901
|
-
};
|
|
1902
|
-
},
|
|
1903
|
-
[key, storageType]
|
|
1904
|
-
);
|
|
1905
|
-
const state = useSyncExternalStore(subscribe2, getSnapshot2, getServerSnapshot);
|
|
1906
|
-
const stateRef = useRef(state);
|
|
1907
|
-
useIsomorphicLayoutEffect(() => {
|
|
1908
|
-
stateRef.current = state;
|
|
1909
|
-
});
|
|
1910
|
-
const setValue = useCallback(
|
|
1911
|
-
(next) => {
|
|
1912
|
-
const resolvedNext = typeof next === "function" ? next(stateRef.current) : next;
|
|
1913
|
-
stateRef.current = resolvedNext;
|
|
1914
|
-
const storage = getStorageInstance(storageType);
|
|
1915
|
-
if (!storage) return;
|
|
1916
|
-
try {
|
|
1917
|
-
const raw = serialize(resolvedNext);
|
|
1918
|
-
cacheRef.current = { parsed: resolvedNext, raw };
|
|
1919
|
-
storage.setItem(key, raw);
|
|
1920
|
-
window.dispatchEvent(
|
|
1921
|
-
new CustomEvent(STORAGE_SYNC_EVENT, {
|
|
1922
|
-
detail: { key, storageType }
|
|
1923
|
-
})
|
|
1924
|
-
);
|
|
1925
|
-
} catch {
|
|
1926
|
-
}
|
|
1927
|
-
},
|
|
1928
|
-
[key, serialize, storageType]
|
|
1929
|
-
);
|
|
1930
|
-
const removeValue = useCallback(() => {
|
|
1931
|
-
stateRef.current = initialValue;
|
|
1932
|
-
cacheRef.current = { parsed: initialValue, raw: null };
|
|
1933
|
-
const storage = getStorageInstance(storageType);
|
|
1934
|
-
if (!storage) return;
|
|
1935
|
-
try {
|
|
1936
|
-
storage.removeItem(key);
|
|
1937
|
-
window.dispatchEvent(
|
|
1938
|
-
new CustomEvent(STORAGE_SYNC_EVENT, {
|
|
1939
|
-
detail: { key, storageType }
|
|
1940
|
-
})
|
|
1941
|
-
);
|
|
1942
|
-
} catch {
|
|
1943
|
-
}
|
|
1944
|
-
}, [initialValue, key, storageType]);
|
|
1945
|
-
return [state, setValue, removeValue];
|
|
1946
|
-
}
|
|
1947
|
-
function useLocalStorage(key, initialValue, options) {
|
|
1948
|
-
return useStorageState(key, initialValue, { ...options, storage: "local" });
|
|
1949
|
-
}
|
|
1950
|
-
function useSessionStorage(key, initialValue, options) {
|
|
1951
|
-
return useStorageState(key, initialValue, { ...options, storage: "session" });
|
|
1952
|
-
}
|
|
1953
|
-
var STORAGE_SYNC_EVENT;
|
|
1954
|
-
var init_use_storage_state = __esm({
|
|
1955
|
-
"src/hooks/use-storage-state.ts"() {
|
|
1956
|
-
"use client";
|
|
1957
|
-
init_utils();
|
|
1958
|
-
init_use_isomorphic_layout_effect();
|
|
1959
|
-
STORAGE_SYNC_EVENT = "base-framework:storage-sync";
|
|
1960
|
-
}
|
|
1961
|
-
});
|
|
1962
|
-
function useIntersectionObserver(targetRef, options = {}) {
|
|
1963
|
-
const {
|
|
1964
|
-
enabled = true,
|
|
1965
|
-
freezeOnceVisible = false,
|
|
1966
|
-
onChange,
|
|
1967
|
-
root = null,
|
|
1968
|
-
rootMargin = "0px",
|
|
1969
|
-
threshold = 0
|
|
1970
|
-
} = options;
|
|
1971
|
-
const [entry, setEntry] = useState(null);
|
|
1972
|
-
const onChangeRef = useRef(onChange);
|
|
1973
|
-
useIsomorphicLayoutEffect(() => {
|
|
1974
|
-
onChangeRef.current = onChange;
|
|
1975
|
-
});
|
|
1976
|
-
const frozen = Boolean(entry?.isIntersecting && freezeOnceVisible);
|
|
1977
|
-
useEffect(() => {
|
|
1978
|
-
if (!isBrowser || !enabled || frozen || typeof IntersectionObserver === "undefined") {
|
|
1979
|
-
return;
|
|
1980
|
-
}
|
|
1981
|
-
const node = targetRef?.current;
|
|
1982
|
-
if (!node) return;
|
|
1983
|
-
const observer = new IntersectionObserver(
|
|
1984
|
-
([nextEntry]) => {
|
|
1985
|
-
if (!nextEntry) return;
|
|
1986
|
-
setEntry(nextEntry);
|
|
1987
|
-
onChangeRef.current?.(nextEntry);
|
|
1988
|
-
},
|
|
1989
|
-
{ root, rootMargin, threshold }
|
|
1990
|
-
);
|
|
1991
|
-
observer.observe(node);
|
|
1992
|
-
return () => observer.disconnect();
|
|
1993
|
-
}, [enabled, frozen, root, rootMargin, targetRef, threshold]);
|
|
1994
|
-
return {
|
|
1995
|
-
entry,
|
|
1996
|
-
isIntersecting: Boolean(entry?.isIntersecting)
|
|
1997
|
-
};
|
|
1998
|
-
}
|
|
1999
|
-
var init_use_intersection_observer = __esm({
|
|
2000
|
-
"src/hooks/use-intersection-observer.ts"() {
|
|
2001
|
-
"use client";
|
|
2002
|
-
init_utils();
|
|
2003
|
-
init_use_isomorphic_layout_effect();
|
|
2004
|
-
}
|
|
2005
|
-
});
|
|
2006
1315
|
function getDomSnapshot() {
|
|
2007
1316
|
if (typeof document === "undefined") {
|
|
2008
1317
|
return activeFullscreenStateIds.size > 0;
|
|
@@ -2080,16 +1389,7 @@ var init_hooks = __esm({
|
|
|
2080
1389
|
init_use_store();
|
|
2081
1390
|
init_use_click_outside();
|
|
2082
1391
|
init_use_isomorphic_layout_effect();
|
|
2083
|
-
init_use_debounce();
|
|
2084
|
-
init_use_mounted();
|
|
2085
|
-
init_use_media_query();
|
|
2086
|
-
init_use_controllable_state();
|
|
2087
|
-
init_use_hotkey();
|
|
2088
1392
|
init_use_global_event();
|
|
2089
|
-
init_use_async_action();
|
|
2090
|
-
init_use_server_action();
|
|
2091
|
-
init_use_storage_state();
|
|
2092
|
-
init_use_intersection_observer();
|
|
2093
1393
|
init_use_fullscreen_state();
|
|
2094
1394
|
}
|
|
2095
1395
|
});
|
|
@@ -3253,7 +2553,7 @@ function PageControllerProvider({ children }) {
|
|
|
3253
2553
|
function usePageController() {
|
|
3254
2554
|
const scopedContext = use(PageControllerContext);
|
|
3255
2555
|
const controllerStore = use(PageControllerStoreContext);
|
|
3256
|
-
const storeSubscribe = scopedContext ?
|
|
2556
|
+
const storeSubscribe = scopedContext ? emptySubscribe : controllerStore.subscribe;
|
|
3257
2557
|
const storeSnapshot = scopedContext ? getNullSnapshot : controllerStore.getSnapshot;
|
|
3258
2558
|
const storeController = useSyncExternalStore(
|
|
3259
2559
|
storeSubscribe,
|
|
@@ -3327,7 +2627,7 @@ function usePage(pageConfig = EMPTY_OBJECT, options) {
|
|
|
3327
2627
|
}, [controllerStore, instanceId]);
|
|
3328
2628
|
return controller;
|
|
3329
2629
|
}
|
|
3330
|
-
var EMPTY_OBJECT, fallbackStandaloneStore, noopHook, PassthroughProvider, PageControllerContext, PageControllerStoreContext,
|
|
2630
|
+
var EMPTY_OBJECT, fallbackStandaloneStore, noopHook, PassthroughProvider, PageControllerContext, PageControllerStoreContext, emptySubscribe, getNullSnapshot, FALLBACK_PAGE_CONTROLLER;
|
|
3331
2631
|
var init_page_controller = __esm({
|
|
3332
2632
|
"src/kernel/page-controller.tsx"() {
|
|
3333
2633
|
"use client";
|
|
@@ -3351,7 +2651,7 @@ var init_page_controller = __esm({
|
|
|
3351
2651
|
"PageControllerStoreContext",
|
|
3352
2652
|
fallbackStandaloneStore
|
|
3353
2653
|
);
|
|
3354
|
-
|
|
2654
|
+
emptySubscribe = () => () => {
|
|
3355
2655
|
};
|
|
3356
2656
|
getNullSnapshot = () => null;
|
|
3357
2657
|
FALLBACK_PAGE_CONTROLLER = Object.freeze({
|
|
@@ -4696,7 +3996,7 @@ function useModalModel() {
|
|
|
4696
3996
|
const topModalEntry = visibleModalStack[visibleModalStack.length - 1] || null;
|
|
4697
3997
|
const isModalVisible = Boolean(isOpen && topModalEntry);
|
|
4698
3998
|
const mounted = useSyncExternalStore(
|
|
4699
|
-
|
|
3999
|
+
emptySubscribe4,
|
|
4700
4000
|
() => true,
|
|
4701
4001
|
() => false
|
|
4702
4002
|
);
|
|
@@ -4755,7 +4055,7 @@ function useModalModel() {
|
|
|
4755
4055
|
theme: useTheme(modalTheme)
|
|
4756
4056
|
};
|
|
4757
4057
|
}
|
|
4758
|
-
var
|
|
4058
|
+
var emptySubscribe4;
|
|
4759
4059
|
var init_hooks3 = __esm({
|
|
4760
4060
|
"src/modules/modal/hooks.ts"() {
|
|
4761
4061
|
"use client";
|
|
@@ -4765,7 +4065,7 @@ var init_hooks3 = __esm({
|
|
|
4765
4065
|
init_constants2();
|
|
4766
4066
|
init_utils3();
|
|
4767
4067
|
init_context();
|
|
4768
|
-
|
|
4068
|
+
emptySubscribe4 = () => () => {
|
|
4769
4069
|
};
|
|
4770
4070
|
}
|
|
4771
4071
|
});
|
|
@@ -5094,7 +4394,106 @@ var init_overlay = __esm({
|
|
|
5094
4394
|
|
|
5095
4395
|
// src/index.ts
|
|
5096
4396
|
init_kernel();
|
|
5097
|
-
|
|
4397
|
+
|
|
4398
|
+
// src/result.ts
|
|
4399
|
+
init_user_message();
|
|
4400
|
+
init_report();
|
|
4401
|
+
function ok(data, code) {
|
|
4402
|
+
return { data, success: true, ...code ? { code } : {} };
|
|
4403
|
+
}
|
|
4404
|
+
function err(error, code) {
|
|
4405
|
+
return { error, success: false, ...code ? { code } : {} };
|
|
4406
|
+
}
|
|
4407
|
+
function isResult(value) {
|
|
4408
|
+
return typeof value === "object" && value !== null && "success" in value && typeof value.success === "boolean" && ("data" in value && value.success === true || "error" in value && value.success === false);
|
|
4409
|
+
}
|
|
4410
|
+
function isOk(result) {
|
|
4411
|
+
return result.success === true;
|
|
4412
|
+
}
|
|
4413
|
+
function isErr(result) {
|
|
4414
|
+
return result.success === false;
|
|
4415
|
+
}
|
|
4416
|
+
function unwrap(result) {
|
|
4417
|
+
if (result.success) {
|
|
4418
|
+
return result.data;
|
|
4419
|
+
}
|
|
4420
|
+
if (result.error instanceof Error) {
|
|
4421
|
+
throw result.error;
|
|
4422
|
+
}
|
|
4423
|
+
throw new Error(
|
|
4424
|
+
typeof result.error === "string" ? result.error : String(result.error)
|
|
4425
|
+
);
|
|
4426
|
+
}
|
|
4427
|
+
function unwrapOr(result, fallback) {
|
|
4428
|
+
return result.success ? result.data : fallback;
|
|
4429
|
+
}
|
|
4430
|
+
function map(result, fn) {
|
|
4431
|
+
return result.success ? ok(fn(result.data), result.code) : result;
|
|
4432
|
+
}
|
|
4433
|
+
function mapErr(result, fn) {
|
|
4434
|
+
return result.success ? result : err(fn(result.error), result.code);
|
|
4435
|
+
}
|
|
4436
|
+
function match(result, branches) {
|
|
4437
|
+
return result.success ? branches.ok(result.data) : branches.err(result.error);
|
|
4438
|
+
}
|
|
4439
|
+
function mapCaught(error, mapError) {
|
|
4440
|
+
if (!(error instanceof UserError)) report("Result", error);
|
|
4441
|
+
return mapError ? mapError(error) : toUserMessage(error);
|
|
4442
|
+
}
|
|
4443
|
+
async function tryCatch(promiseOrFn, mapError) {
|
|
4444
|
+
try {
|
|
4445
|
+
const data = typeof promiseOrFn === "function" ? await promiseOrFn() : await promiseOrFn;
|
|
4446
|
+
return ok(data);
|
|
4447
|
+
} catch (error) {
|
|
4448
|
+
return err(mapCaught(error, mapError));
|
|
4449
|
+
}
|
|
4450
|
+
}
|
|
4451
|
+
function createSafeAction(handler, options = {}) {
|
|
4452
|
+
const { errorCode, mapError, schema, validate } = options;
|
|
4453
|
+
return async (...args) => {
|
|
4454
|
+
try {
|
|
4455
|
+
let effectiveArgs = args;
|
|
4456
|
+
if (schema) {
|
|
4457
|
+
const parsed = schema.safeParse(args[0]);
|
|
4458
|
+
if (!parsed.success) {
|
|
4459
|
+
const issueMessage = parsed.error?.issues?.[0]?.message || parsed.error?.message || "Invalid input";
|
|
4460
|
+
return err(
|
|
4461
|
+
mapError ? mapError(issueMessage) : issueMessage,
|
|
4462
|
+
errorCode ?? "VALIDATION_ERROR"
|
|
4463
|
+
);
|
|
4464
|
+
}
|
|
4465
|
+
effectiveArgs = [parsed.data, ...args.slice(1)];
|
|
4466
|
+
}
|
|
4467
|
+
if (validate) {
|
|
4468
|
+
const validationResult = validate(...effectiveArgs);
|
|
4469
|
+
if (isResult(validationResult)) {
|
|
4470
|
+
if (isErr(validationResult)) {
|
|
4471
|
+
return validationResult;
|
|
4472
|
+
}
|
|
4473
|
+
} else if (validationResult === false) {
|
|
4474
|
+
return err(
|
|
4475
|
+
mapError ? mapError("Validation failed") : "Validation failed",
|
|
4476
|
+
errorCode ?? "VALIDATION_ERROR"
|
|
4477
|
+
);
|
|
4478
|
+
} else if (typeof validationResult === "string" && validationResult.length > 0) {
|
|
4479
|
+
return err(
|
|
4480
|
+
mapError ? mapError(validationResult) : validationResult,
|
|
4481
|
+
errorCode ?? "VALIDATION_ERROR"
|
|
4482
|
+
);
|
|
4483
|
+
}
|
|
4484
|
+
}
|
|
4485
|
+
const output = await handler(...effectiveArgs);
|
|
4486
|
+
if (isResult(output)) {
|
|
4487
|
+
return output;
|
|
4488
|
+
}
|
|
4489
|
+
return ok(output);
|
|
4490
|
+
} catch (error) {
|
|
4491
|
+
return err(mapCaught(error, mapError), errorCode);
|
|
4492
|
+
}
|
|
4493
|
+
};
|
|
4494
|
+
}
|
|
4495
|
+
|
|
4496
|
+
// src/index.ts
|
|
5098
4497
|
init_events();
|
|
5099
4498
|
init_theme();
|
|
5100
4499
|
init_tokens2();
|
|
@@ -8933,7 +8332,7 @@ function useMenuDismissal(menuRef, onClose) {
|
|
|
8933
8332
|
};
|
|
8934
8333
|
}, [menuRef, onClose]);
|
|
8935
8334
|
}
|
|
8936
|
-
var
|
|
8335
|
+
var emptySubscribe2 = () => () => {
|
|
8937
8336
|
};
|
|
8938
8337
|
function useContextMenuContentModel({
|
|
8939
8338
|
config,
|
|
@@ -9012,7 +8411,7 @@ function useContextMenuContentModel({
|
|
|
9012
8411
|
function useContextMenuRendererModel() {
|
|
9013
8412
|
const { closeMenu, config, context, isOpen, items, position } = useContextMenu();
|
|
9014
8413
|
const isMounted = useSyncExternalStore(
|
|
9015
|
-
|
|
8414
|
+
emptySubscribe2,
|
|
9016
8415
|
() => true,
|
|
9017
8416
|
() => false
|
|
9018
8417
|
);
|
|
@@ -9431,11 +8830,11 @@ function useControlsLayout() {
|
|
|
9431
8830
|
}, []);
|
|
9432
8831
|
return layout;
|
|
9433
8832
|
}
|
|
9434
|
-
var
|
|
8833
|
+
var emptySubscribe3 = () => () => {
|
|
9435
8834
|
};
|
|
9436
8835
|
function useControlsModel() {
|
|
9437
8836
|
const portalTarget = useSyncExternalStore(
|
|
9438
|
-
|
|
8837
|
+
emptySubscribe3,
|
|
9439
8838
|
() => typeof document !== "undefined" ? document.body : null,
|
|
9440
8839
|
() => null
|
|
9441
8840
|
);
|
|
@@ -20132,9 +19531,6 @@ function useNotificationState() {
|
|
|
20132
19531
|
);
|
|
20133
19532
|
return useStore(store);
|
|
20134
19533
|
}
|
|
20135
|
-
|
|
20136
|
-
// src/modules/notification/hooks.ts
|
|
20137
|
-
init_result();
|
|
20138
19534
|
init_utils();
|
|
20139
19535
|
init_events();
|
|
20140
19536
|
init_hooks();
|
|
@@ -20209,7 +19605,7 @@ function useToast(defaultDuration) {
|
|
|
20209
19605
|
[dismiss, dismissAllNotifications, fromResult, promise, triggerToast]
|
|
20210
19606
|
);
|
|
20211
19607
|
}
|
|
20212
|
-
var
|
|
19608
|
+
var emptySubscribe5 = () => () => {
|
|
20213
19609
|
};
|
|
20214
19610
|
function NotificationListener() {
|
|
20215
19611
|
const { showNotification } = useNotificationActions();
|
|
@@ -20237,7 +19633,7 @@ function useNotificationContainerModel() {
|
|
|
20237
19633
|
const { notifications } = useNotificationState();
|
|
20238
19634
|
const { dismissNotification } = useNotificationActions();
|
|
20239
19635
|
const isHydrated = useSyncExternalStore(
|
|
20240
|
-
|
|
19636
|
+
emptySubscribe5,
|
|
20241
19637
|
() => true,
|
|
20242
19638
|
() => false
|
|
20243
19639
|
);
|
|
@@ -20410,6 +19806,6 @@ var defaultModules = Object.freeze([
|
|
|
20410
19806
|
notificationModule
|
|
20411
19807
|
]);
|
|
20412
19808
|
|
|
20413
|
-
export { ACTION_TONE_CLASS, Button, COMPOSITOR_GPU_STYLE, ComponentError, Compose, CoreProvider, DEFAULT_DEDUPE_WINDOW, DURATION_TOKENS, EASING_CURVES, ERROR_LISTENER_CONFIG, ERROR_MESSAGES, EVENT_TYPES, ErrorBoundaryCore, EventEmitter, GlobalError, GlobalErrorListener, Icon, MAX_CONTEXT, MAX_FINGERPRINTS, MOTION_EASINGS, MOTION_TIERS, ModuleBoundary, ModuleError, ModuleHost, PageControllerProvider, REDUCED_MOTION_TRANSITION, REGISTRY_SOURCES, RegistryProvider, SPRING_PRESETS, SURFACE_CLASSES, Spinner, TAP_SCALE_SUBTLE, ThemeProvider, Tooltip, USER_MESSAGES, UserError, Z_INDEX, acquireGlobalScrollLock, ambientModule, applyRegistryConfig, backgroundModule,
|
|
19809
|
+
export { ACTION_TONE_CLASS, Button, COMPOSITOR_GPU_STYLE, ComponentError, Compose, CoreProvider, DEFAULT_DEDUPE_WINDOW, DURATION_TOKENS, EASING_CURVES, ERROR_LISTENER_CONFIG, ERROR_MESSAGES, EVENT_TYPES, ErrorBoundaryCore, EventEmitter, GlobalError, GlobalErrorListener, Icon, MAX_CONTEXT, MAX_FINGERPRINTS, MOTION_EASINGS, MOTION_TIERS, ModuleBoundary, ModuleError, ModuleHost, PageControllerProvider, REDUCED_MOTION_TRANSITION, REGISTRY_SOURCES, RegistryProvider, SPRING_PRESETS, SURFACE_CLASSES, Spinner, TAP_SCALE_SUBTLE, ThemeProvider, Tooltip, USER_MESSAGES, UserError, Z_INDEX, acquireGlobalScrollLock, ambientModule, applyRegistryConfig, backgroundModule, chip, clamp, cn, contentSwap, contentSwapTransitions, contextMenuModule, controlsModule, createConsoleHandler, createErrorContext, createModuleRegistryDefinitions, createRegistryApplyContext, createRegistryOperations, createRegistryStore, createReport, createSafeAction, createScheduler, createSentryHandler, createStore, debounce, defaultModules, defineModule, definePeer, defineTheme, defineThemeSpec, dockModule, dragDismiss, durationForDistance, err, errorTheme, fingerprint, getBrowserEnvironment, getErrorMessage, getErrorReporter, getRuntimePath, getUserAgent, globalEvents, gpuTransform, hasOwnProperty, isBrowser, isErr, isImageIconSource, isObject, isOk, isPlainObject, isResult, loadingModule, map, mapErr, match, mediaModule, modalModule, normalizeDedupeWindow, normalizePath, normalizeSampleRate, notificationModule, ok, overlaySurface, press, report, setReportSink, shallowEqual, shouldIgnoreError, sortModules, staggerDelay, staggerItem, stripTrailingSlash, surfaceResizeTransition, throttle, toArray, toFiniteNumber, toUserMessage, trimToNull, tryCatch, unwrap, unwrapOr, useClickOutside, useGlobalEvent, useIsFullscreenStateActive, useIsModuleInstalled, useIsomorphicLayoutEffect, useModule, useModuleRegistration, useModuleState, usePage, usePageController, useRegistryEntries, useRegistryValue, useRequiredContext, useStore, useTheme };
|
|
20414
19810
|
//# sourceMappingURL=index.js.map
|
|
20415
19811
|
//# sourceMappingURL=index.js.map
|