resuxjs 0.3.3 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +150 -892
- package/dist/cli.js +4 -3
- package/dist/cli.js.map +1 -1
- package/dist/compiler/implementation.js +12 -4
- package/dist/compiler/index.js.map +1 -1
- package/dist/core/config.d.ts +9 -0
- package/dist/core/config.js +16 -1
- package/dist/core/config.js.map +1 -1
- package/dist/core/hooks.js +4 -1
- package/dist/core/hooks.js.map +1 -1
- package/dist/create.js +34 -1
- package/dist/create.js.map +1 -1
- package/dist/deploy/common.js +9 -5
- package/dist/deploy/common.js.map +1 -1
- package/dist/deploy/vercel.js +35 -9
- package/dist/deploy/vercel.js.map +1 -1
- package/dist/halal-core/ai/classifyRuntimeContent.d.ts +3 -0
- package/dist/halal-core/ai/classifyRuntimeContent.js +123 -0
- package/dist/halal-core/ai/classifyRuntimeContent.js.map +1 -0
- package/dist/halal-core/index.d.ts +2 -0
- package/dist/halal-core/index.js +2 -0
- package/dist/halal-core/index.js.map +1 -1
- package/dist/halal-core/runtime/guard.d.ts +19 -0
- package/dist/halal-core/runtime/guard.js +203 -0
- package/dist/halal-core/runtime/guard.js.map +1 -0
- package/dist/halal-core/runtime/index.d.ts +4 -0
- package/dist/halal-core/runtime/index.js +5 -0
- package/dist/halal-core/runtime/index.js.map +1 -0
- package/dist/halal-core/runtime/reviewedMemory.d.ts +5 -0
- package/dist/halal-core/runtime/reviewedMemory.js +131 -0
- package/dist/halal-core/runtime/reviewedMemory.js.map +1 -0
- package/dist/halal-core/runtime/serializeRuntimeContent.d.ts +13 -0
- package/dist/halal-core/runtime/serializeRuntimeContent.js +170 -0
- package/dist/halal-core/runtime/serializeRuntimeContent.js.map +1 -0
- package/dist/halal-core/runtime/types.d.ts +57 -0
- package/dist/halal-core/runtime/types.js +2 -0
- package/dist/halal-core/runtime/types.js.map +1 -0
- package/dist/halal.d.ts +1 -0
- package/dist/halal.js +2 -0
- package/dist/halal.js.map +1 -0
- package/dist/i18n/index.js +3 -3
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/shared.js +15 -11
- package/dist/i18n/shared.js.map +1 -1
- package/dist/icons/index.d.ts +6 -6
- package/dist/kit/index.js +6 -11
- package/dist/kit/index.js.map +1 -1
- package/dist/reactivity/reactive.js +5 -1
- package/dist/reactivity/reactive.js.map +1 -1
- package/dist/reactivity/scheduler.js +13 -1
- package/dist/reactivity/scheduler.js.map +1 -1
- package/dist/runtime/index.js +334 -42
- package/dist/runtime/index.js.map +1 -1
- package/dist/ui/index.d.ts +29 -16
- package/dist/ui/index.js +274 -258
- package/dist/ui/index.js.map +1 -1
- package/package.json +2 -2
package/dist/runtime/index.js
CHANGED
|
@@ -3,8 +3,49 @@ import { normalizeI18nRuntimeConfig, resolveI18nRoute, translateRaw, translateTe
|
|
|
3
3
|
import { computed, isReactive, isReadonly, isRef, nextTick, reactive, readonly, ref, toRef, toRefs, unref, watch, watchEffect } from "../reactivity/index.js";
|
|
4
4
|
export { ref, reactive, computed, watch, watchEffect, readonly, toRef, toRefs, unref, isRef, isReactive, isReadonly, nextTick };
|
|
5
5
|
let activeResuxApp = null;
|
|
6
|
-
const
|
|
6
|
+
const fallbackResuxError = ref(null);
|
|
7
|
+
const resuxErrorByApp = new WeakMap();
|
|
8
|
+
const resuxAsyncContextStorage = createResuxAsyncContextStorage();
|
|
9
|
+
function createResuxAsyncContextStorage() {
|
|
10
|
+
const maybeProcess = typeof process !== "undefined"
|
|
11
|
+
? process
|
|
12
|
+
: undefined;
|
|
13
|
+
const getBuiltinModule = maybeProcess?.getBuiltinModule;
|
|
14
|
+
if (typeof getBuiltinModule !== "function") {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
const asyncHooks = getBuiltinModule.call(maybeProcess, "node:async_hooks");
|
|
19
|
+
const AsyncLocalStorage = asyncHooks?.AsyncLocalStorage;
|
|
20
|
+
return AsyncLocalStorage ? new AsyncLocalStorage() : null;
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function readActiveResuxApp() {
|
|
27
|
+
return resuxAsyncContextStorage?.getStore()
|
|
28
|
+
?? activeResuxApp
|
|
29
|
+
?? globalThis.__RESUX_APP__
|
|
30
|
+
?? null;
|
|
31
|
+
}
|
|
32
|
+
function readActiveResuxError() {
|
|
33
|
+
const app = readActiveResuxApp();
|
|
34
|
+
if (!app) {
|
|
35
|
+
return fallbackResuxError;
|
|
36
|
+
}
|
|
37
|
+
const existing = resuxErrorByApp.get(app);
|
|
38
|
+
if (existing) {
|
|
39
|
+
return existing;
|
|
40
|
+
}
|
|
41
|
+
const errorRef = ref(null);
|
|
42
|
+
resuxErrorByApp.set(app, errorRef);
|
|
43
|
+
return errorRef;
|
|
44
|
+
}
|
|
7
45
|
async function withActiveResuxApp(resuxApp, run) {
|
|
46
|
+
if (resuxAsyncContextStorage) {
|
|
47
|
+
return await resuxAsyncContextStorage.run(resuxApp, () => Promise.resolve(run()));
|
|
48
|
+
}
|
|
8
49
|
const previous = activeResuxApp;
|
|
9
50
|
activeResuxApp = resuxApp;
|
|
10
51
|
const previousGlobal = globalThis.__RESUX_APP__;
|
|
@@ -33,12 +74,9 @@ export function defineResuxRouteMiddleware(middleware) {
|
|
|
33
74
|
return middleware;
|
|
34
75
|
}
|
|
35
76
|
export function useResuxApp() {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const globalApp = globalThis.__RESUX_APP__;
|
|
40
|
-
if (globalApp) {
|
|
41
|
-
return globalApp;
|
|
77
|
+
const app = readActiveResuxApp();
|
|
78
|
+
if (app) {
|
|
79
|
+
return app;
|
|
42
80
|
}
|
|
43
81
|
console.error("useResuxApp error trace:");
|
|
44
82
|
console.trace();
|
|
@@ -60,7 +98,7 @@ export function parseUserAgent(ua) {
|
|
|
60
98
|
};
|
|
61
99
|
}
|
|
62
100
|
export function useDevice() {
|
|
63
|
-
const app =
|
|
101
|
+
const app = readActiveResuxApp();
|
|
64
102
|
const ua = app?.route?.userAgent || (typeof navigator !== "undefined" ? navigator.userAgent : "");
|
|
65
103
|
return parseUserAgent(ua);
|
|
66
104
|
}
|
|
@@ -131,16 +169,16 @@ export function createError(input) {
|
|
|
131
169
|
return error;
|
|
132
170
|
}
|
|
133
171
|
export function useError() {
|
|
134
|
-
return
|
|
172
|
+
return readActiveResuxError();
|
|
135
173
|
}
|
|
136
174
|
export function showError(input) {
|
|
137
175
|
const error = createError(input);
|
|
138
|
-
|
|
176
|
+
readActiveResuxError().value = error;
|
|
139
177
|
dispatchRuntimeErrorEvent("resux:app-error", error);
|
|
140
178
|
throw error;
|
|
141
179
|
}
|
|
142
180
|
export function clearError() {
|
|
143
|
-
|
|
181
|
+
readActiveResuxError().value = null;
|
|
144
182
|
dispatchRuntimeErrorEvent("resux:app-error-cleared", null);
|
|
145
183
|
}
|
|
146
184
|
function dispatchRuntimeErrorEvent(name, error) {
|
|
@@ -268,6 +306,7 @@ async function injectClientPackageCss(cssEntries, packageName) {
|
|
|
268
306
|
});
|
|
269
307
|
})
|
|
270
308
|
.catch((error) => {
|
|
309
|
+
resuxInjectedPackageCss.delete(href);
|
|
271
310
|
throw new Error(`Failed to load CSS entry "${href}" for package "${packageName}": ${error instanceof Error ? error.message : String(error)}`);
|
|
272
311
|
}));
|
|
273
312
|
resuxInjectedPackageCss.add(href);
|
|
@@ -353,6 +392,11 @@ export async function useLazyPackage(name, options = {}) {
|
|
|
353
392
|
}
|
|
354
393
|
})();
|
|
355
394
|
resuxLazyPackageCache.set(key, loader);
|
|
395
|
+
void loader.catch(() => {
|
|
396
|
+
if (resuxLazyPackageCache.get(key) === loader) {
|
|
397
|
+
resuxLazyPackageCache.delete(key);
|
|
398
|
+
}
|
|
399
|
+
});
|
|
356
400
|
return loader;
|
|
357
401
|
}
|
|
358
402
|
export async function useClientPackage(name, options = {}) {
|
|
@@ -1556,7 +1600,7 @@ class ResuxRenderer {
|
|
|
1556
1600
|
globalStateKeys,
|
|
1557
1601
|
asyncDataRefs
|
|
1558
1602
|
};
|
|
1559
|
-
return renderTemplateNodes(definition.template, {
|
|
1603
|
+
return withActiveResuxApp(this.resuxApp, () => renderTemplateNodes(definition.template, {
|
|
1560
1604
|
scope,
|
|
1561
1605
|
scopeId,
|
|
1562
1606
|
moduleId: definition.id,
|
|
@@ -1569,7 +1613,7 @@ class ResuxRenderer {
|
|
|
1569
1613
|
addHeadEntry: (entry) => insertHeadEntryWithPriority(this.headEntries, entry),
|
|
1570
1614
|
renderPage,
|
|
1571
1615
|
renderSlot
|
|
1572
|
-
});
|
|
1616
|
+
}));
|
|
1573
1617
|
}
|
|
1574
1618
|
collectComponentStyles(definition) {
|
|
1575
1619
|
for (const style of definition.styles ?? []) {
|
|
@@ -1619,6 +1663,89 @@ function setRegistryValue(registry, key, value) {
|
|
|
1619
1663
|
configurable: true
|
|
1620
1664
|
});
|
|
1621
1665
|
}
|
|
1666
|
+
function createFetchAsyncDataKey(url, init) {
|
|
1667
|
+
return `fetch:${hashFetchIdentity(serializeFetchRequestIdentity(url, init))}`;
|
|
1668
|
+
}
|
|
1669
|
+
function serializeFetchRequestIdentity(url, init) {
|
|
1670
|
+
const headers = [];
|
|
1671
|
+
if (typeof Headers !== "undefined") {
|
|
1672
|
+
try {
|
|
1673
|
+
new Headers(init?.headers).forEach((value, key) => headers.push([key, value]));
|
|
1674
|
+
headers.sort(([left], [right]) => left.localeCompare(right));
|
|
1675
|
+
}
|
|
1676
|
+
catch {
|
|
1677
|
+
// Invalid headers will be reported by fetch itself; keep the cache key deterministic.
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
const extended = (init ?? {});
|
|
1681
|
+
return JSON.stringify({
|
|
1682
|
+
url,
|
|
1683
|
+
method: String(init?.method ?? "GET").toUpperCase(),
|
|
1684
|
+
headers,
|
|
1685
|
+
body: serializeFetchRequestBody(init?.body),
|
|
1686
|
+
cache: init?.cache ?? "",
|
|
1687
|
+
credentials: init?.credentials ?? "",
|
|
1688
|
+
integrity: init?.integrity ?? "",
|
|
1689
|
+
keepalive: init?.keepalive ?? false,
|
|
1690
|
+
mode: init?.mode ?? "",
|
|
1691
|
+
redirect: init?.redirect ?? "",
|
|
1692
|
+
referrer: init?.referrer ?? "",
|
|
1693
|
+
referrerPolicy: init?.referrerPolicy ?? "",
|
|
1694
|
+
duplex: extended.duplex ?? "",
|
|
1695
|
+
priority: extended.priority ?? ""
|
|
1696
|
+
});
|
|
1697
|
+
}
|
|
1698
|
+
function serializeFetchRequestBody(body) {
|
|
1699
|
+
if (body === undefined || body === null)
|
|
1700
|
+
return null;
|
|
1701
|
+
if (typeof body === "string")
|
|
1702
|
+
return ["string", body];
|
|
1703
|
+
if (typeof URLSearchParams !== "undefined" && body instanceof URLSearchParams) {
|
|
1704
|
+
return ["url-search-params", body.toString()];
|
|
1705
|
+
}
|
|
1706
|
+
if (typeof FormData !== "undefined" && body instanceof FormData) {
|
|
1707
|
+
return ["form-data", ...Array.from(body.entries()).map(([key, value]) => [
|
|
1708
|
+
key,
|
|
1709
|
+
typeof value === "string"
|
|
1710
|
+
? ["string", value]
|
|
1711
|
+
: ["file", value.name, value.size, value.type, value.lastModified]
|
|
1712
|
+
])];
|
|
1713
|
+
}
|
|
1714
|
+
if (typeof Blob !== "undefined" && body instanceof Blob) {
|
|
1715
|
+
const file = body;
|
|
1716
|
+
return ["blob", file.name ?? "", body.size, body.type, file.lastModified ?? 0];
|
|
1717
|
+
}
|
|
1718
|
+
if (body instanceof ArrayBuffer) {
|
|
1719
|
+
const bytes = new Uint8Array(body);
|
|
1720
|
+
return ["array-buffer", bytes.byteLength, hashFetchBytes(bytes)];
|
|
1721
|
+
}
|
|
1722
|
+
if (ArrayBuffer.isView(body)) {
|
|
1723
|
+
const bytes = new Uint8Array(body.buffer, body.byteOffset, body.byteLength);
|
|
1724
|
+
return ["array-buffer-view", bytes.byteLength, hashFetchBytes(bytes)];
|
|
1725
|
+
}
|
|
1726
|
+
return ["body", Object.prototype.toString.call(body)];
|
|
1727
|
+
}
|
|
1728
|
+
function hashFetchBytes(bytes) {
|
|
1729
|
+
let first = 2166136261;
|
|
1730
|
+
let second = 2246822519;
|
|
1731
|
+
for (const byte of bytes) {
|
|
1732
|
+
first = Math.imul(first ^ byte, 16777619);
|
|
1733
|
+
second = Math.imul(second ^ byte, 3266489917);
|
|
1734
|
+
}
|
|
1735
|
+
return (first >>> 0).toString(16).padStart(8, "0")
|
|
1736
|
+
+ (second >>> 0).toString(16).padStart(8, "0");
|
|
1737
|
+
}
|
|
1738
|
+
function hashFetchIdentity(value) {
|
|
1739
|
+
let first = 2166136261;
|
|
1740
|
+
let second = 2246822519;
|
|
1741
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
1742
|
+
const code = value.charCodeAt(index);
|
|
1743
|
+
first = Math.imul(first ^ code, 16777619);
|
|
1744
|
+
second = Math.imul(second ^ code, 3266489917);
|
|
1745
|
+
}
|
|
1746
|
+
return (first >>> 0).toString(16).padStart(8, "0")
|
|
1747
|
+
+ (second >>> 0).toString(16).padStart(8, "0");
|
|
1748
|
+
}
|
|
1622
1749
|
export function createServerSetupContext(route, props, stateRefs, asyncDataRefs, headEntries, resuxApp, runtimeConfig, globalStateRefs = Object.create(null), globalStateKeys = new Set()) {
|
|
1623
1750
|
const apiURL = (url) => resolveServerApiURL(url, route, runtimeConfig);
|
|
1624
1751
|
const fetchJson = async (url, init) => {
|
|
@@ -1719,7 +1846,7 @@ export function createServerSetupContext(route, props, stateRefs, asyncDataRefs,
|
|
|
1719
1846
|
return createResuxImageBuilder(route, runtimeConfig, false);
|
|
1720
1847
|
},
|
|
1721
1848
|
useFetch(url, init) {
|
|
1722
|
-
const key =
|
|
1849
|
+
const key = createFetchAsyncDataKey(url, init);
|
|
1723
1850
|
if (hasOwnRegistryKey(asyncDataRefs, key)) {
|
|
1724
1851
|
return asyncDataRefs[key];
|
|
1725
1852
|
}
|
|
@@ -1732,7 +1859,7 @@ export function createServerSetupContext(route, props, stateRefs, asyncDataRefs,
|
|
|
1732
1859
|
return fetchJson(url, init);
|
|
1733
1860
|
},
|
|
1734
1861
|
useError() {
|
|
1735
|
-
return
|
|
1862
|
+
return readActiveResuxError();
|
|
1736
1863
|
},
|
|
1737
1864
|
clearError() {
|
|
1738
1865
|
clearError();
|
|
@@ -1793,9 +1920,9 @@ export function createServerSetupContext(route, props, stateRefs, asyncDataRefs,
|
|
|
1793
1920
|
return globalThis.__RESUX_USE_SWITCH_LOCALE_PATH__ ? globalThis.__RESUX_USE_SWITCH_LOCALE_PATH__() : (to) => to;
|
|
1794
1921
|
},
|
|
1795
1922
|
useDevice() {
|
|
1796
|
-
return
|
|
1923
|
+
return parseUserAgent(route.userAgent);
|
|
1797
1924
|
},
|
|
1798
|
-
$device:
|
|
1925
|
+
$device: parseUserAgent(route.userAgent),
|
|
1799
1926
|
$t(key, params) {
|
|
1800
1927
|
const i18nCandidate = runtimeConfig.public?.i18n;
|
|
1801
1928
|
const normalizedI18n = normalizeI18nRuntimeConfig(i18nCandidate);
|
|
@@ -1815,8 +1942,36 @@ export function createServerSetupContext(route, props, stateRefs, asyncDataRefs,
|
|
|
1815
1942
|
return globalThis.__RESUX_USE_I18N__ ? globalThis.__RESUX_USE_I18N__().tm(key) : key;
|
|
1816
1943
|
}
|
|
1817
1944
|
};
|
|
1818
|
-
|
|
1819
|
-
|
|
1945
|
+
const runtimeGlobals = globalThis;
|
|
1946
|
+
if (runtimeGlobals.__RESUX_SERVER_I18N_GLOBALS__ !== true) {
|
|
1947
|
+
runtimeGlobals.$t = (key, params) => {
|
|
1948
|
+
try {
|
|
1949
|
+
const app = useResuxApp();
|
|
1950
|
+
const normalizedI18n = normalizeI18nRuntimeConfig(app.$config.public?.i18n);
|
|
1951
|
+
if (!normalizedI18n)
|
|
1952
|
+
return key;
|
|
1953
|
+
const locale = resolveI18nRoute(app.route.path, normalizedI18n).locale.code;
|
|
1954
|
+
return translateText(normalizedI18n, locale, key, params);
|
|
1955
|
+
}
|
|
1956
|
+
catch {
|
|
1957
|
+
return key;
|
|
1958
|
+
}
|
|
1959
|
+
};
|
|
1960
|
+
runtimeGlobals.$tm = (key) => {
|
|
1961
|
+
try {
|
|
1962
|
+
const app = useResuxApp();
|
|
1963
|
+
const normalizedI18n = normalizeI18nRuntimeConfig(app.$config.public?.i18n);
|
|
1964
|
+
if (!normalizedI18n)
|
|
1965
|
+
return key;
|
|
1966
|
+
const locale = resolveI18nRoute(app.route.path, normalizedI18n).locale.code;
|
|
1967
|
+
return translateRaw(normalizedI18n, locale, key);
|
|
1968
|
+
}
|
|
1969
|
+
catch {
|
|
1970
|
+
return key;
|
|
1971
|
+
}
|
|
1972
|
+
};
|
|
1973
|
+
runtimeGlobals.__RESUX_SERVER_I18N_GLOBALS__ = true;
|
|
1974
|
+
}
|
|
1820
1975
|
return ctx;
|
|
1821
1976
|
}
|
|
1822
1977
|
function createPendingAsyncDataResource() {
|
|
@@ -6333,6 +6488,11 @@ async function useLazyPackage(name, options = {}) {
|
|
|
6333
6488
|
})();
|
|
6334
6489
|
|
|
6335
6490
|
resuxLazyPackageCache.set(key, loader);
|
|
6491
|
+
void loader.catch(() => {
|
|
6492
|
+
if (resuxLazyPackageCache.get(key) === loader) {
|
|
6493
|
+
resuxLazyPackageCache.delete(key);
|
|
6494
|
+
}
|
|
6495
|
+
});
|
|
6336
6496
|
return loader;
|
|
6337
6497
|
}
|
|
6338
6498
|
|
|
@@ -6899,6 +7059,8 @@ async function activateDeclaredClientEnhancements(root = document) {
|
|
|
6899
7059
|
}
|
|
6900
7060
|
|
|
6901
7061
|
|
|
7062
|
+
const __rxIterateKey = Symbol("iterate");
|
|
7063
|
+
|
|
6902
7064
|
function __rxIsObject(value) {
|
|
6903
7065
|
return value !== null && typeof value === "object";
|
|
6904
7066
|
}
|
|
@@ -6913,17 +7075,44 @@ function __rxQueueJob(job) {
|
|
|
6913
7075
|
return;
|
|
6914
7076
|
}
|
|
6915
7077
|
__rxFlushing = true;
|
|
6916
|
-
__rxFlushPromise = __rxResolvedPromise.then(
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
|
|
7078
|
+
__rxFlushPromise = __rxResolvedPromise.then(__rxFlushJobs);
|
|
7079
|
+
}
|
|
7080
|
+
|
|
7081
|
+
function __rxFlushJobs() {
|
|
7082
|
+
let didError = false;
|
|
7083
|
+
let firstError;
|
|
7084
|
+
const executionCounts = new Map();
|
|
7085
|
+
try {
|
|
7086
|
+
while (__rxQueue.size > 0) {
|
|
7087
|
+
const currentQueue = [...__rxQueue];
|
|
6922
7088
|
__rxQueue.clear();
|
|
6923
|
-
|
|
6924
|
-
|
|
7089
|
+
for (const job of currentQueue) {
|
|
7090
|
+
const count = executionCounts.get(job) || 0;
|
|
7091
|
+
if (count >= 100) {
|
|
7092
|
+
if (!didError) {
|
|
7093
|
+
didError = true;
|
|
7094
|
+
firstError = new Error("Resux scheduler stopped a recursively queued job after 100 executions.");
|
|
7095
|
+
}
|
|
7096
|
+
continue;
|
|
7097
|
+
}
|
|
7098
|
+
executionCounts.set(job, count + 1);
|
|
7099
|
+
try {
|
|
7100
|
+
job();
|
|
7101
|
+
} catch (error) {
|
|
7102
|
+
if (!didError) {
|
|
7103
|
+
didError = true;
|
|
7104
|
+
firstError = error;
|
|
7105
|
+
}
|
|
7106
|
+
}
|
|
7107
|
+
}
|
|
6925
7108
|
}
|
|
6926
|
-
}
|
|
7109
|
+
} finally {
|
|
7110
|
+
__rxFlushing = false;
|
|
7111
|
+
__rxFlushPromise = null;
|
|
7112
|
+
}
|
|
7113
|
+
if (didError) {
|
|
7114
|
+
throw firstError;
|
|
7115
|
+
}
|
|
6927
7116
|
}
|
|
6928
7117
|
|
|
6929
7118
|
function nextTick(fn) {
|
|
@@ -7029,16 +7218,21 @@ function __rxTrack(target, key) {
|
|
|
7029
7218
|
__rxActiveEffect.deps.push(dep);
|
|
7030
7219
|
}
|
|
7031
7220
|
|
|
7032
|
-
function __rxTrigger(target, key) {
|
|
7221
|
+
function __rxTrigger(target, key, type = "set") {
|
|
7033
7222
|
const depsMap = __rxTargetMap.get(target);
|
|
7034
7223
|
if (!depsMap) {
|
|
7035
7224
|
return;
|
|
7036
7225
|
}
|
|
7037
|
-
const
|
|
7038
|
-
|
|
7039
|
-
return;
|
|
7226
|
+
const effects = new Set();
|
|
7227
|
+
const addEffects = (dep) => {
|
|
7228
|
+
if (!dep) return;
|
|
7229
|
+
for (const effect of dep) effects.add(effect);
|
|
7230
|
+
};
|
|
7231
|
+
addEffects(depsMap.get(key));
|
|
7232
|
+
if (type === "add" || type === "delete") {
|
|
7233
|
+
addEffects(depsMap.get(__rxIterateKey));
|
|
7040
7234
|
}
|
|
7041
|
-
__rxTriggerEffects(
|
|
7235
|
+
__rxTriggerEffects(effects);
|
|
7042
7236
|
}
|
|
7043
7237
|
|
|
7044
7238
|
function reactive(target) {
|
|
@@ -7049,8 +7243,13 @@ function readonly(target) {
|
|
|
7049
7243
|
return __rxCreateReactiveObject(target, true, __rxReadonlyMap, false);
|
|
7050
7244
|
}
|
|
7051
7245
|
|
|
7246
|
+
function __rxCanUseBaseProxyHandlers(target) {
|
|
7247
|
+
const rawType = Object.prototype.toString.call(target);
|
|
7248
|
+
return rawType === "[object Object]" || rawType === "[object Array]";
|
|
7249
|
+
}
|
|
7250
|
+
|
|
7052
7251
|
function __rxCreateReactiveObject(target, isReadonlyValue, proxyMap, isShallow) {
|
|
7053
|
-
if (!__rxIsObject(target)) {
|
|
7252
|
+
if (!__rxIsObject(target) || !__rxCanUseBaseProxyHandlers(target)) {
|
|
7054
7253
|
return target;
|
|
7055
7254
|
}
|
|
7056
7255
|
const existing = proxyMap.get(target);
|
|
@@ -7081,11 +7280,12 @@ function __rxCreateReactiveObject(target, isReadonlyValue, proxyMap, isShallow)
|
|
|
7081
7280
|
if (isReadonlyValue) {
|
|
7082
7281
|
return true;
|
|
7083
7282
|
}
|
|
7283
|
+
const hadKey = Object.prototype.hasOwnProperty.call(rawTarget, key);
|
|
7084
7284
|
const oldValue = Reflect.get(rawTarget, key, receiver);
|
|
7085
7285
|
const oldLength = Array.isArray(rawTarget) ? rawTarget.length : 0;
|
|
7086
7286
|
const success = Reflect.set(rawTarget, key, value, receiver);
|
|
7087
|
-
if (success && __rxHasChanged(value, oldValue)) {
|
|
7088
|
-
__rxTrigger(rawTarget, key);
|
|
7287
|
+
if (success && (!hadKey || __rxHasChanged(value, oldValue))) {
|
|
7288
|
+
__rxTrigger(rawTarget, key, hadKey ? "set" : "add");
|
|
7089
7289
|
if (
|
|
7090
7290
|
Array.isArray(rawTarget)
|
|
7091
7291
|
&& key !== "length"
|
|
@@ -7098,14 +7298,20 @@ function __rxCreateReactiveObject(target, isReadonlyValue, proxyMap, isShallow)
|
|
|
7098
7298
|
}
|
|
7099
7299
|
return success;
|
|
7100
7300
|
},
|
|
7301
|
+
ownKeys(rawTarget) {
|
|
7302
|
+
if (!isReadonlyValue) {
|
|
7303
|
+
__rxTrack(rawTarget, __rxIterateKey);
|
|
7304
|
+
}
|
|
7305
|
+
return Reflect.ownKeys(rawTarget);
|
|
7306
|
+
},
|
|
7101
7307
|
deleteProperty(rawTarget, key) {
|
|
7102
7308
|
if (isReadonlyValue) {
|
|
7103
7309
|
return true;
|
|
7104
7310
|
}
|
|
7105
|
-
const hadKey =
|
|
7311
|
+
const hadKey = Object.prototype.hasOwnProperty.call(rawTarget, key);
|
|
7106
7312
|
const success = Reflect.deleteProperty(rawTarget, key);
|
|
7107
7313
|
if (hadKey && success) {
|
|
7108
|
-
__rxTrigger(rawTarget, key);
|
|
7314
|
+
__rxTrigger(rawTarget, key, "delete");
|
|
7109
7315
|
}
|
|
7110
7316
|
return success;
|
|
7111
7317
|
}
|
|
@@ -7186,7 +7392,7 @@ function toRef(object, key, defaultValue) {
|
|
|
7186
7392
|
}
|
|
7187
7393
|
|
|
7188
7394
|
function toRefs(object) {
|
|
7189
|
-
const output = {};
|
|
7395
|
+
const output = Array.isArray(object) ? new Array(object.length) : {};
|
|
7190
7396
|
for (const key of Object.keys(object)) {
|
|
7191
7397
|
output[key] = toRef(object, key);
|
|
7192
7398
|
}
|
|
@@ -7349,8 +7555,11 @@ function __rxTraverse(value, seen = new Set()) {
|
|
|
7349
7555
|
return value;
|
|
7350
7556
|
}
|
|
7351
7557
|
seen.add(value);
|
|
7352
|
-
for (const key of
|
|
7353
|
-
|
|
7558
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
7559
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
7560
|
+
if (descriptor?.enumerable) {
|
|
7561
|
+
__rxTraverse(value[key], seen);
|
|
7562
|
+
}
|
|
7354
7563
|
}
|
|
7355
7564
|
return value;
|
|
7356
7565
|
}
|
|
@@ -8013,6 +8222,89 @@ function setRegistryValue(registry, key, value) {
|
|
|
8013
8222
|
});
|
|
8014
8223
|
}
|
|
8015
8224
|
|
|
8225
|
+
function createFetchAsyncDataKey(url, init) {
|
|
8226
|
+
return "fetch:" + hashFetchIdentity(serializeFetchRequestIdentity(url, init));
|
|
8227
|
+
}
|
|
8228
|
+
|
|
8229
|
+
function serializeFetchRequestIdentity(url, init) {
|
|
8230
|
+
const headers = [];
|
|
8231
|
+
if (typeof Headers !== "undefined") {
|
|
8232
|
+
try {
|
|
8233
|
+
new Headers(init?.headers).forEach((value, key) => headers.push([key, value]));
|
|
8234
|
+
headers.sort(([left], [right]) => left.localeCompare(right));
|
|
8235
|
+
} catch {
|
|
8236
|
+
// Invalid headers will be reported by fetch itself; keep the cache key deterministic.
|
|
8237
|
+
}
|
|
8238
|
+
}
|
|
8239
|
+
return JSON.stringify({
|
|
8240
|
+
url,
|
|
8241
|
+
method: String(init?.method ?? "GET").toUpperCase(),
|
|
8242
|
+
headers,
|
|
8243
|
+
body: serializeFetchRequestBody(init?.body),
|
|
8244
|
+
cache: init?.cache ?? "",
|
|
8245
|
+
credentials: init?.credentials ?? "",
|
|
8246
|
+
integrity: init?.integrity ?? "",
|
|
8247
|
+
keepalive: init?.keepalive ?? false,
|
|
8248
|
+
mode: init?.mode ?? "",
|
|
8249
|
+
redirect: init?.redirect ?? "",
|
|
8250
|
+
referrer: init?.referrer ?? "",
|
|
8251
|
+
referrerPolicy: init?.referrerPolicy ?? "",
|
|
8252
|
+
duplex: init?.duplex ?? "",
|
|
8253
|
+
priority: init?.priority ?? ""
|
|
8254
|
+
});
|
|
8255
|
+
}
|
|
8256
|
+
|
|
8257
|
+
function serializeFetchRequestBody(body) {
|
|
8258
|
+
if (body === undefined || body === null) return null;
|
|
8259
|
+
if (typeof body === "string") return ["string", body];
|
|
8260
|
+
if (typeof URLSearchParams !== "undefined" && body instanceof URLSearchParams) {
|
|
8261
|
+
return ["url-search-params", body.toString()];
|
|
8262
|
+
}
|
|
8263
|
+
if (typeof FormData !== "undefined" && body instanceof FormData) {
|
|
8264
|
+
return ["form-data", ...Array.from(body.entries()).map(([key, value]) => [
|
|
8265
|
+
key,
|
|
8266
|
+
typeof value === "string"
|
|
8267
|
+
? ["string", value]
|
|
8268
|
+
: ["file", value.name, value.size, value.type, value.lastModified]
|
|
8269
|
+
])];
|
|
8270
|
+
}
|
|
8271
|
+
if (typeof Blob !== "undefined" && body instanceof Blob) {
|
|
8272
|
+
return ["blob", body.name ?? "", body.size, body.type, body.lastModified ?? 0];
|
|
8273
|
+
}
|
|
8274
|
+
if (body instanceof ArrayBuffer) {
|
|
8275
|
+
const bytes = new Uint8Array(body);
|
|
8276
|
+
return ["array-buffer", bytes.byteLength, hashFetchBytes(bytes)];
|
|
8277
|
+
}
|
|
8278
|
+
if (ArrayBuffer.isView(body)) {
|
|
8279
|
+
const bytes = new Uint8Array(body.buffer, body.byteOffset, body.byteLength);
|
|
8280
|
+
return ["array-buffer-view", bytes.byteLength, hashFetchBytes(bytes)];
|
|
8281
|
+
}
|
|
8282
|
+
return ["body", Object.prototype.toString.call(body)];
|
|
8283
|
+
}
|
|
8284
|
+
|
|
8285
|
+
function hashFetchBytes(bytes) {
|
|
8286
|
+
let first = 2166136261;
|
|
8287
|
+
let second = 2246822519;
|
|
8288
|
+
for (const byte of bytes) {
|
|
8289
|
+
first = Math.imul(first ^ byte, 16777619);
|
|
8290
|
+
second = Math.imul(second ^ byte, 3266489917);
|
|
8291
|
+
}
|
|
8292
|
+
return (first >>> 0).toString(16).padStart(8, "0")
|
|
8293
|
+
+ (second >>> 0).toString(16).padStart(8, "0");
|
|
8294
|
+
}
|
|
8295
|
+
|
|
8296
|
+
function hashFetchIdentity(value) {
|
|
8297
|
+
let first = 2166136261;
|
|
8298
|
+
let second = 2246822519;
|
|
8299
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
8300
|
+
const code = value.charCodeAt(index);
|
|
8301
|
+
first = Math.imul(first ^ code, 16777619);
|
|
8302
|
+
second = Math.imul(second ^ code, 3266489917);
|
|
8303
|
+
}
|
|
8304
|
+
return (first >>> 0).toString(16).padStart(8, "0")
|
|
8305
|
+
+ (second >>> 0).toString(16).padStart(8, "0");
|
|
8306
|
+
}
|
|
8307
|
+
|
|
8016
8308
|
export function createClientComponent(definition) {
|
|
8017
8309
|
return {
|
|
8018
8310
|
async createScope(serializedScope, route) {
|
|
@@ -8115,7 +8407,7 @@ export function createClientComponent(definition) {
|
|
|
8115
8407
|
return url;
|
|
8116
8408
|
},
|
|
8117
8409
|
useFetch(url, init) {
|
|
8118
|
-
const key =
|
|
8410
|
+
const key = createFetchAsyncDataKey(url, init);
|
|
8119
8411
|
return setupContext.useAsyncData(key, () => setupContext.$fetch(url, init));
|
|
8120
8412
|
},
|
|
8121
8413
|
async $fetch(url, init) {
|