@omerdlw/base-framework 1.0.0 → 1.0.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/LICENSE +1 -1
- package/README.md +121 -52
- package/dist/atoms/index.d.ts +0 -1
- package/dist/atoms/index.d.ts.map +1 -1
- package/dist/atoms/index.js +1 -64
- package/dist/atoms/index.js.map +1 -1
- package/dist/error/index.js +22 -25
- package/dist/error/index.js.map +1 -1
- package/dist/hooks/index.d.ts +2 -9
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +97 -540
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/types.d.ts +3 -45
- package/dist/hooks/types.d.ts.map +1 -1
- package/dist/hooks/use-controllable-state.d.ts +1 -1
- package/dist/hooks/use-controllable-state.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/hooks/use-hotkey.d.ts +1 -1
- package/dist/hooks/use-hotkey.d.ts.map +1 -1
- package/dist/index.js +11283 -11772
- package/dist/index.js.map +1 -1
- package/dist/kernel/adapters.d.ts.map +1 -1
- package/dist/kernel/index.d.ts +1 -0
- package/dist/kernel/index.d.ts.map +1 -1
- package/dist/kernel/index.js +10 -81
- package/dist/kernel/index.js.map +1 -1
- package/dist/kernel/installed.d.ts.map +1 -1
- package/dist/kernel/page-controller.d.ts.map +1 -1
- package/dist/kernel/provider.d.ts.map +1 -1
- package/dist/modules/ambient/constants.d.ts +1 -1
- package/dist/modules/ambient/constants.d.ts.map +1 -1
- package/dist/modules/ambient/index.js +180 -326
- package/dist/modules/ambient/index.js.map +1 -1
- package/dist/modules/ambient/module.d.ts.map +1 -1
- package/dist/modules/background/constants.d.ts +4 -2
- package/dist/modules/background/constants.d.ts.map +1 -1
- package/dist/modules/background/context.d.ts +3 -0
- package/dist/modules/background/context.d.ts.map +1 -1
- package/dist/modules/background/hooks.d.ts +1 -1
- package/dist/modules/background/index.d.ts +2 -2
- package/dist/modules/background/index.d.ts.map +1 -1
- package/dist/modules/background/index.js +1172 -1270
- package/dist/modules/background/index.js.map +1 -1
- package/dist/modules/background/overlay.d.ts +1 -1
- package/dist/modules/background/overlay.d.ts.map +1 -1
- package/dist/modules/background/types.d.ts +1 -1
- package/dist/modules/background/types.d.ts.map +1 -1
- package/dist/modules/context-menu/constants.d.ts +1 -1
- package/dist/modules/context-menu/constants.d.ts.map +1 -1
- package/dist/modules/context-menu/context.d.ts.map +1 -1
- package/dist/modules/context-menu/hooks.d.ts.map +1 -1
- package/dist/modules/context-menu/index.js +133 -238
- package/dist/modules/context-menu/index.js.map +1 -1
- package/dist/modules/controls/constants.d.ts +1 -1
- package/dist/modules/controls/constants.d.ts.map +1 -1
- package/dist/modules/controls/hooks.d.ts +1 -1
- package/dist/modules/controls/index.js +28 -162
- package/dist/modules/controls/index.js.map +1 -1
- package/dist/modules/controls/types.d.ts +1 -1
- package/dist/modules/controls/types.d.ts.map +1 -1
- package/dist/modules/dock/cards.d.ts +2 -2
- package/dist/modules/dock/constants.d.ts +1 -1
- package/dist/modules/dock/constants.d.ts.map +1 -1
- package/dist/modules/dock/context.d.ts +10 -6
- package/dist/modules/dock/context.d.ts.map +1 -1
- package/dist/modules/dock/hooks.d.ts +5 -5
- package/dist/modules/dock/hooks.d.ts.map +1 -1
- package/dist/modules/dock/index.d.ts +1 -1
- package/dist/modules/dock/index.d.ts.map +1 -1
- package/dist/modules/dock/index.js +2060 -2080
- package/dist/modules/dock/index.js.map +1 -1
- package/dist/modules/dock/runtime/dock.d.ts.map +1 -1
- package/dist/modules/dock/types.d.ts +1 -1
- package/dist/modules/dock/types.d.ts.map +1 -1
- package/dist/modules/index.js +10789 -11027
- package/dist/modules/index.js.map +1 -1
- package/dist/modules/loading/constants.d.ts +4 -2
- package/dist/modules/loading/constants.d.ts.map +1 -1
- package/dist/modules/loading/context.d.ts +3 -0
- package/dist/modules/loading/context.d.ts.map +1 -1
- package/dist/modules/loading/hooks.d.ts +1 -1
- package/dist/modules/loading/hooks.d.ts.map +1 -1
- package/dist/modules/loading/index.d.ts +2 -2
- package/dist/modules/loading/index.d.ts.map +1 -1
- package/dist/modules/loading/index.js +118 -222
- package/dist/modules/loading/index.js.map +1 -1
- package/dist/modules/loading/types.d.ts +1 -1
- package/dist/modules/loading/types.d.ts.map +1 -1
- package/dist/modules/media/constants.d.ts +2 -1
- package/dist/modules/media/constants.d.ts.map +1 -1
- package/dist/modules/media/context.d.ts +3 -0
- package/dist/modules/media/context.d.ts.map +1 -1
- package/dist/modules/media/index.d.ts +2 -2
- package/dist/modules/media/index.d.ts.map +1 -1
- package/dist/modules/media/index.js +61 -218
- package/dist/modules/media/index.js.map +1 -1
- package/dist/modules/modal/constants.d.ts +1 -1
- package/dist/modules/modal/constants.d.ts.map +1 -1
- package/dist/modules/modal/context.d.ts.map +1 -1
- package/dist/modules/modal/hooks.d.ts +2 -2
- package/dist/modules/modal/index.js +20 -366
- package/dist/modules/modal/index.js.map +1 -1
- package/dist/modules/notification/constants.d.ts +4 -2
- package/dist/modules/notification/constants.d.ts.map +1 -1
- package/dist/modules/notification/context.d.ts +4 -0
- package/dist/modules/notification/context.d.ts.map +1 -1
- package/dist/modules/notification/hooks.d.ts +1 -1
- package/dist/modules/notification/index.d.ts +2 -3
- package/dist/modules/notification/index.d.ts.map +1 -1
- package/dist/modules/notification/index.js +70 -154
- package/dist/modules/notification/index.js.map +1 -1
- package/dist/modules/notification/module.d.ts.map +1 -1
- package/dist/provider.js +255 -257
- package/dist/provider.js.map +1 -1
- package/dist/theme.d.ts +1 -0
- package/dist/theme.d.ts.map +1 -1
- package/dist/theme.js +2 -2
- package/dist/theme.js.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 +1 -57
- 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 +50 -2
- package/templates/AGENTS.md +165 -0
- package/dist/hooks/use-async-action.d.ts +0 -3
- package/dist/hooks/use-async-action.d.ts.map +0 -1
- package/dist/hooks/use-debounce.d.ts +0 -2
- package/dist/hooks/use-debounce.d.ts.map +0 -1
- package/dist/hooks/use-intersection-observer.d.ts +0 -4
- package/dist/hooks/use-intersection-observer.d.ts.map +0 -1
- package/dist/hooks/use-media-query.d.ts +0 -2
- package/dist/hooks/use-media-query.d.ts.map +0 -1
- package/dist/hooks/use-mounted.d.ts +0 -2
- package/dist/hooks/use-mounted.d.ts.map +0 -1
- package/dist/hooks/use-server-action.d.ts +0 -4
- package/dist/hooks/use-server-action.d.ts.map +0 -1
- package/dist/hooks/use-storage-state.d.ts +0 -5
- package/dist/hooks/use-storage-state.d.ts.map +0 -1
- package/dist/modules/theme.d.ts +0 -3
- package/dist/modules/theme.d.ts.map +0 -1
- package/dist/utils/json.d.ts +0 -3
- package/dist/utils/json.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installed.d.ts","sourceRoot":"","sources":["../../src/kernel/installed.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"installed.d.ts","sourceRoot":"","sources":["../../src/kernel/installed.ts"],"names":[],"mappings":"AAEA,OAAO,EAAO,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGhE,OAAO,KAAK,EACV,aAAa,EACb,UAAU,EAEV,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,iBAAiB,GAAG,aAAa,CAAC;IAC5C,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC,CAAC;AAEH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACzC,WAAW,EAAE,mBAAmB,CAAC;IACjC,OAAO,EAAE,SAAS,aAAa,EAAE,CAAC;CACnC;AAED,eAAO,MAAM,aAAa,EAAE,SAAS,aAAa,EAAsB,CAAC;AAEzE,eAAO,MAAM,mBAAmB,EAAE,iBACxB,CAAC;AAEX,eAAO,MAAM,iBAAiB,iDAC+C,CAAC;AAG9E,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,aAAa,EACzB,MAAM,EAAE,UAAU,GACjB,OAAO,CAKT;AAED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,SAAS,aAAa,EAAE,EACjC,MAAM,EAAE,UAAU,EAClB,QAAQ,GAAE,gBAAqB,GAC9B,UAAU,GAAG,IAAI,CAkBnB;AAID,wBAAgB,WAAW,CACzB,OAAO,EAAE,SAAS,aAAa,EAAE,GAChC,aAAa,EAAE,CAkCjB;AAED,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,SAAS,aAAa,EAAE,GAChC,mBAAmB,CAOrB;AAED,wBAAgB,mBAAmB,IAAI,SAAS,aAAa,EAAE,CAE9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-controller.d.ts","sourceRoot":"","sources":["../../src/kernel/page-controller.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"page-controller.d.ts","sourceRoot":"","sources":["../../src/kernel/page-controller.tsx"],"names":[],"mappings":"AAEA,OAAO,EASL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAQf,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EAId,WAAW,EACZ,MAAM,SAAS,CAAC;AAwGjB,wBAAgB,sBAAsB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,+BAS5E;AAaD,wBAAgB,iBAAiB,IAAI,cAAc,CAkBlD;AAED,wBAAgB,OAAO,CACrB,UAAU,GAAE,UAAyB,EACrC,OAAO,CAAC,EAAE,WAAW,GACpB,cAAc,CA8EhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/kernel/provider.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/kernel/provider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAIf,OAAO,KAAK,EACV,mBAAmB,EACnB,cAAc,EACd,aAAa,EACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAuB,KAAK,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAE3E,KAAK,eAAe,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,MAAM,cAAc,GACnE,cAAc,CAAC,CAAC,CAAC,GACjB,OAAO,CAAC;AAEZ,UAAU,oBAAoB;IAC5B,OAAO,EAAE,IAAI,CACX,aAAa,EACb,OAAO,GAAG,UAAU,GAAG,aAAa,GAAG,YAAY,CACpD,CAAC;IACF,YAAY,EAAE,IAAI,CAChB,aAAa,EACb,oBAAoB,GAAG,aAAa,GAAG,WAAW,CACnD,CAAC;CACH;AAQD,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,WAAW,EACX,cAAmB,GACpB,EAAE;IACD,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAClC,cAAc,CAAC,EAAE,sBAAsB,CAAC;CACzC,+BAuBA;AAED,wBAAgB,kBAAkB,IAAI,oBAAoB,CAAC,SAAS,CAAC,CAMpE;AAUD,wBAAgB,gBAAgB,CAC9B,CAAC,SAAS,MAAM,GAAG,MAAM,EACzB,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,EACtB,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAarC;AAED,wBAAgB,kBAAkB,CAChC,CAAC,SAAS,MAAM,GAAG,MAAM,EACzB,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,EACtB,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAa5B"}
|
|
@@ -19,5 +19,5 @@ export declare const COLOR_EXTRACT_CONFIG: Readonly<{
|
|
|
19
19
|
readonly minChroma: 0.03;
|
|
20
20
|
readonly sampleSize: 32;
|
|
21
21
|
}>;
|
|
22
|
-
export declare const ambientTheme: import("
|
|
22
|
+
export declare const ambientTheme: import("@/theme").ThemeSpec<"transition">;
|
|
23
23
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/modules/ambient/constants.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB;;;;;;EAMlB,CAAC;AAEZ,eAAO,MAAM,gBAAgB;;;EAGlB,CAAC;AAEZ,eAAO,MAAM,oBAAoB;;;;;;;;;EAStB,CAAC;AAEZ,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/modules/ambient/constants.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB;;;;;;EAMlB,CAAC;AAEZ,eAAO,MAAM,gBAAgB;;;EAGlB,CAAC;AAEZ,eAAO,MAAM,oBAAoB;;;;;;;;;EAStB,CAAC;AAEZ,eAAO,MAAM,YAAY,2CAA+C,CAAC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createContext, useState, useMemo, useEffect, use, useContext, useRef, useCallback, useSyncExternalStore } from 'react';
|
|
3
|
-
import 'clsx';
|
|
4
|
-
import 'tailwind-merge';
|
|
5
3
|
import { jsx } from 'react/jsx-runtime';
|
|
6
4
|
import 'next/navigation';
|
|
7
5
|
|
|
@@ -14,6 +12,140 @@ function getOrCreateGlobalContext(name, defaultValue) {
|
|
|
14
12
|
return store[sym];
|
|
15
13
|
}
|
|
16
14
|
|
|
15
|
+
// src/utils/object.ts
|
|
16
|
+
function shallowEqual(a, b) {
|
|
17
|
+
if (Object.is(a, b)) return true;
|
|
18
|
+
if (typeof a !== "object" || a === null || typeof b !== "object" || b === null) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
const keysA = Object.keys(a);
|
|
22
|
+
const keysB = Object.keys(b);
|
|
23
|
+
if (keysA.length !== keysB.length) return false;
|
|
24
|
+
for (const key of keysA) {
|
|
25
|
+
if (!Object.prototype.hasOwnProperty.call(b, key) || !Object.is(
|
|
26
|
+
a[key],
|
|
27
|
+
b[key]
|
|
28
|
+
)) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
function report(scope, error, level = "error") {
|
|
35
|
+
if (process.env.NODE_ENV === "production" && typeof window !== "undefined") {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
console[level](`[${scope}]`, error);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// src/utils/store.ts
|
|
42
|
+
function freezeStoreSnapshot(state) {
|
|
43
|
+
if (process.env.NODE_ENV === "production" || !state || typeof state !== "object") {
|
|
44
|
+
return state;
|
|
45
|
+
}
|
|
46
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
47
|
+
const freeze = (value) => {
|
|
48
|
+
if (seen.has(value) || Object.isFrozen(value)) return;
|
|
49
|
+
seen.add(value);
|
|
50
|
+
const prototype = Object.getPrototypeOf(value);
|
|
51
|
+
if (Array.isArray(value) || prototype === Object.prototype || prototype === null) {
|
|
52
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
53
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
54
|
+
if (descriptor && "value" in descriptor && descriptor.value !== null) {
|
|
55
|
+
if (typeof descriptor.value === "object") freeze(descriptor.value);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
Object.freeze(value);
|
|
60
|
+
};
|
|
61
|
+
freeze(state);
|
|
62
|
+
return state;
|
|
63
|
+
}
|
|
64
|
+
function createStore(initialState, { freezeSnapshots = true } = {}) {
|
|
65
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
66
|
+
const prepare = freezeSnapshots ? freezeStoreSnapshot : (state) => state;
|
|
67
|
+
let snapshot = prepare(initialState);
|
|
68
|
+
const publish = (nextStateOrUpdater) => {
|
|
69
|
+
const nextState = typeof nextStateOrUpdater === "function" ? nextStateOrUpdater(snapshot) : nextStateOrUpdater;
|
|
70
|
+
if (Object.is(snapshot, nextState)) return false;
|
|
71
|
+
snapshot = prepare(nextState);
|
|
72
|
+
for (const listener of listeners) {
|
|
73
|
+
try {
|
|
74
|
+
listener();
|
|
75
|
+
} catch (error) {
|
|
76
|
+
report("CoreStore subscriber", error, "warn");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return true;
|
|
80
|
+
};
|
|
81
|
+
const setState = (updater) => {
|
|
82
|
+
if (typeof updater === "function") {
|
|
83
|
+
return publish(updater);
|
|
84
|
+
}
|
|
85
|
+
if (snapshot && typeof snapshot === "object" && updater && typeof updater === "object") {
|
|
86
|
+
return publish({ ...snapshot, ...updater });
|
|
87
|
+
}
|
|
88
|
+
return publish(updater);
|
|
89
|
+
};
|
|
90
|
+
return Object.freeze({
|
|
91
|
+
getSnapshot() {
|
|
92
|
+
return snapshot;
|
|
93
|
+
},
|
|
94
|
+
publish,
|
|
95
|
+
setState,
|
|
96
|
+
subscribe(listener) {
|
|
97
|
+
if (typeof listener !== "function") return () => {
|
|
98
|
+
};
|
|
99
|
+
listeners.add(listener);
|
|
100
|
+
return () => listeners.delete(listener);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function useRequiredContext(context, hookName, providerName) {
|
|
105
|
+
const value = use(context);
|
|
106
|
+
if (value === null) {
|
|
107
|
+
throw new Error(`${hookName} must be used within ${providerName}`);
|
|
108
|
+
}
|
|
109
|
+
return value;
|
|
110
|
+
}
|
|
111
|
+
function useStore(store, selector = (state) => state, isEqual = Object.is) {
|
|
112
|
+
const cacheRef = useRef({
|
|
113
|
+
isEqual: null,
|
|
114
|
+
selected: void 0,
|
|
115
|
+
selector: null,
|
|
116
|
+
snapshot: null
|
|
117
|
+
});
|
|
118
|
+
const getSelectedSnapshot = useCallback(() => {
|
|
119
|
+
const snapshot = store.getSnapshot();
|
|
120
|
+
const cache = cacheRef.current;
|
|
121
|
+
if (cache.snapshot === snapshot && cache.selector === selector && cache.isEqual === isEqual) {
|
|
122
|
+
return cache.selected;
|
|
123
|
+
}
|
|
124
|
+
const selected = selector(snapshot);
|
|
125
|
+
if (cache.snapshot !== null && cache.isEqual === isEqual && isEqual(cache.selected, selected)) {
|
|
126
|
+
cache.snapshot = snapshot;
|
|
127
|
+
cache.selector = selector;
|
|
128
|
+
return cache.selected;
|
|
129
|
+
}
|
|
130
|
+
cacheRef.current = {
|
|
131
|
+
isEqual,
|
|
132
|
+
selected,
|
|
133
|
+
selector,
|
|
134
|
+
snapshot
|
|
135
|
+
};
|
|
136
|
+
return selected;
|
|
137
|
+
}, [isEqual, selector, store]);
|
|
138
|
+
return useSyncExternalStore(
|
|
139
|
+
store.subscribe,
|
|
140
|
+
getSelectedSnapshot,
|
|
141
|
+
getSelectedSnapshot
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
function defineModule(coreModule) {
|
|
145
|
+
return Object.freeze({ ...coreModule });
|
|
146
|
+
}
|
|
147
|
+
createStore(void 0);
|
|
148
|
+
|
|
17
149
|
// src/theme.tsx
|
|
18
150
|
function defineThemeSpec(id) {
|
|
19
151
|
return Object.freeze({ id });
|
|
@@ -24,7 +156,7 @@ function useTheme(spec) {
|
|
|
24
156
|
const config = useContext(ThemeContext).get(spec.id);
|
|
25
157
|
if (!config) {
|
|
26
158
|
throw new Error(
|
|
27
|
-
`Theme "${spec.id}" is missing.
|
|
159
|
+
`Theme "${spec.id}" is missing. Ensure its theme configuration is provided to <ThemeProvider themes={[...]}> (e.g. in src/config/ or your theme setup).`
|
|
28
160
|
);
|
|
29
161
|
}
|
|
30
162
|
return {
|
|
@@ -338,331 +470,55 @@ function resolvePageAmbientTheme(slice, posterUrl) {
|
|
|
338
470
|
return null;
|
|
339
471
|
}
|
|
340
472
|
|
|
341
|
-
// src/
|
|
342
|
-
var
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
473
|
+
// src/modules/background/constants.ts
|
|
474
|
+
var DEFAULT_BACKGROUND = Object.freeze({
|
|
475
|
+
animation: null,
|
|
476
|
+
className: "",
|
|
477
|
+
fadeEdges: null,
|
|
478
|
+
fit: null,
|
|
479
|
+
image: null,
|
|
480
|
+
imageStyle: {},
|
|
481
|
+
isPlaying: false,
|
|
482
|
+
noiseStyle: {},
|
|
483
|
+
overlay: false,
|
|
484
|
+
overlayColor: "var(--black)",
|
|
485
|
+
overlayOpacity: 0,
|
|
486
|
+
position: "center",
|
|
487
|
+
video: null,
|
|
488
|
+
videoClassName: "",
|
|
489
|
+
videoElement: null,
|
|
490
|
+
videoOptions: {
|
|
491
|
+
autoplay: true,
|
|
492
|
+
className: "",
|
|
493
|
+
corp: 0,
|
|
494
|
+
loop: false,
|
|
495
|
+
muted: true,
|
|
496
|
+
playbackRate: 1,
|
|
497
|
+
width: null
|
|
498
|
+
},
|
|
499
|
+
videoStyle: {},
|
|
500
|
+
width: null
|
|
346
501
|
});
|
|
347
|
-
var
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
"cleanup",
|
|
355
|
-
"cleanupDelayMs",
|
|
356
|
-
"instanceId",
|
|
357
|
-
"lifecycle",
|
|
358
|
-
"priority",
|
|
359
|
-
"source",
|
|
360
|
-
"scope",
|
|
361
|
-
"validation"
|
|
362
|
-
]);
|
|
363
|
-
Object.freeze({
|
|
364
|
-
[REGISTRY_SOURCES.STATIC]: 100,
|
|
365
|
-
[REGISTRY_SOURCES.DYNAMIC]: 200,
|
|
366
|
-
[REGISTRY_SOURCES.USER]: 300
|
|
367
|
-
});
|
|
368
|
-
Object.freeze({
|
|
369
|
-
[REGISTRY_SOURCES.STATIC]: 10,
|
|
370
|
-
[REGISTRY_SOURCES.DYNAMIC]: 20,
|
|
371
|
-
[REGISTRY_SOURCES.USER]: 30
|
|
372
|
-
});
|
|
373
|
-
new Set(
|
|
374
|
-
Object.values(REGISTRY_LIFECYCLES)
|
|
375
|
-
);
|
|
376
|
-
new Set(
|
|
377
|
-
REGISTRY_METADATA_KEYS
|
|
378
|
-
);
|
|
379
|
-
var REGISTRY_SCOPE_KINDS = Object.freeze({
|
|
380
|
-
APP: "app",
|
|
381
|
-
SESSION: "session",
|
|
382
|
-
ROUTE: "route",
|
|
383
|
-
INSTANCE: "instance",
|
|
384
|
-
WORKSPACE: "workspace"
|
|
502
|
+
var DEFAULT_BACKGROUND_COMPUTED = Object.freeze({
|
|
503
|
+
...DEFAULT_BACKGROUND,
|
|
504
|
+
hasBackground: false,
|
|
505
|
+
isVideo: false,
|
|
506
|
+
isYouTube: false,
|
|
507
|
+
posterUrl: null,
|
|
508
|
+
youtubeVideoId: null
|
|
385
509
|
});
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
// src/utils/object.ts
|
|
389
|
-
function shallowEqual(a, b) {
|
|
390
|
-
if (Object.is(a, b)) return true;
|
|
391
|
-
if (typeof a !== "object" || a === null || typeof b !== "object" || b === null) {
|
|
392
|
-
return false;
|
|
393
|
-
}
|
|
394
|
-
const keysA = Object.keys(a);
|
|
395
|
-
const keysB = Object.keys(b);
|
|
396
|
-
if (keysA.length !== keysB.length) return false;
|
|
397
|
-
for (const key of keysA) {
|
|
398
|
-
if (!Object.prototype.hasOwnProperty.call(b, key) || !Object.is(
|
|
399
|
-
a[key],
|
|
400
|
-
b[key]
|
|
401
|
-
)) {
|
|
402
|
-
return false;
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
return true;
|
|
406
|
-
}
|
|
407
|
-
function report(scope, error, level = "error") {
|
|
408
|
-
if (process.env.NODE_ENV === "production" && typeof window !== "undefined") {
|
|
409
|
-
return;
|
|
410
|
-
}
|
|
411
|
-
console[level](`[${scope}]`, error);
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
// src/utils/store.ts
|
|
415
|
-
function freezeStoreSnapshot(state) {
|
|
416
|
-
if (process.env.NODE_ENV === "production" || !state || typeof state !== "object") {
|
|
417
|
-
return state;
|
|
418
|
-
}
|
|
419
|
-
const seen = /* @__PURE__ */ new WeakSet();
|
|
420
|
-
const freeze = (value) => {
|
|
421
|
-
if (seen.has(value) || Object.isFrozen(value)) return;
|
|
422
|
-
seen.add(value);
|
|
423
|
-
const prototype = Object.getPrototypeOf(value);
|
|
424
|
-
if (Array.isArray(value) || prototype === Object.prototype || prototype === null) {
|
|
425
|
-
for (const key of Reflect.ownKeys(value)) {
|
|
426
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
427
|
-
if (descriptor && "value" in descriptor && descriptor.value !== null) {
|
|
428
|
-
if (typeof descriptor.value === "object") freeze(descriptor.value);
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
Object.freeze(value);
|
|
433
|
-
};
|
|
434
|
-
freeze(state);
|
|
435
|
-
return state;
|
|
436
|
-
}
|
|
437
|
-
function createStore(initialState, { freezeSnapshots = true } = {}) {
|
|
438
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
439
|
-
const prepare = freezeSnapshots ? freezeStoreSnapshot : (state) => state;
|
|
440
|
-
let snapshot = prepare(initialState);
|
|
441
|
-
const publish = (nextStateOrUpdater) => {
|
|
442
|
-
const nextState = typeof nextStateOrUpdater === "function" ? nextStateOrUpdater(snapshot) : nextStateOrUpdater;
|
|
443
|
-
if (Object.is(snapshot, nextState)) return false;
|
|
444
|
-
snapshot = prepare(nextState);
|
|
445
|
-
for (const listener of listeners) {
|
|
446
|
-
try {
|
|
447
|
-
listener();
|
|
448
|
-
} catch (error) {
|
|
449
|
-
report("CoreStore subscriber", error, "warn");
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
return true;
|
|
453
|
-
};
|
|
454
|
-
const setState = (updater) => {
|
|
455
|
-
if (typeof updater === "function") {
|
|
456
|
-
return publish(updater);
|
|
457
|
-
}
|
|
458
|
-
if (snapshot && typeof snapshot === "object" && updater && typeof updater === "object") {
|
|
459
|
-
return publish({ ...snapshot, ...updater });
|
|
460
|
-
}
|
|
461
|
-
return publish(updater);
|
|
462
|
-
};
|
|
463
|
-
return Object.freeze({
|
|
464
|
-
getSnapshot() {
|
|
465
|
-
return snapshot;
|
|
466
|
-
},
|
|
467
|
-
publish,
|
|
468
|
-
setState,
|
|
469
|
-
subscribe(listener) {
|
|
470
|
-
if (typeof listener !== "function") return () => {
|
|
471
|
-
};
|
|
472
|
-
listeners.add(listener);
|
|
473
|
-
return () => listeners.delete(listener);
|
|
474
|
-
}
|
|
475
|
-
});
|
|
476
|
-
}
|
|
477
|
-
function useRequiredContext(context, hookName, providerName) {
|
|
478
|
-
const value = use(context);
|
|
479
|
-
if (value === null) {
|
|
480
|
-
throw new Error(`${hookName} must be used within ${providerName}`);
|
|
481
|
-
}
|
|
482
|
-
return value;
|
|
483
|
-
}
|
|
484
|
-
function useStore(store, selector = (state) => state, isEqual = Object.is) {
|
|
485
|
-
const cacheRef = useRef({
|
|
486
|
-
isEqual: null,
|
|
487
|
-
selected: void 0,
|
|
488
|
-
selector: null,
|
|
489
|
-
snapshot: null
|
|
490
|
-
});
|
|
491
|
-
const getSelectedSnapshot = useCallback(() => {
|
|
492
|
-
const snapshot = store.getSnapshot();
|
|
493
|
-
const cache = cacheRef.current;
|
|
494
|
-
if (cache.snapshot === snapshot && cache.selector === selector && cache.isEqual === isEqual) {
|
|
495
|
-
return cache.selected;
|
|
496
|
-
}
|
|
497
|
-
const selected = selector(snapshot);
|
|
498
|
-
if (cache.snapshot !== null && cache.isEqual === isEqual && isEqual(cache.selected, selected)) {
|
|
499
|
-
cache.snapshot = snapshot;
|
|
500
|
-
cache.selector = selector;
|
|
501
|
-
return cache.selected;
|
|
502
|
-
}
|
|
503
|
-
cacheRef.current = {
|
|
504
|
-
isEqual,
|
|
505
|
-
selected,
|
|
506
|
-
selector,
|
|
507
|
-
snapshot
|
|
508
|
-
};
|
|
509
|
-
return selected;
|
|
510
|
-
}, [isEqual, selector, store]);
|
|
511
|
-
return useSyncExternalStore(
|
|
512
|
-
store.subscribe,
|
|
513
|
-
getSelectedSnapshot,
|
|
514
|
-
getSelectedSnapshot
|
|
515
|
-
);
|
|
516
|
-
}
|
|
517
|
-
var EventEmitter = class {
|
|
518
|
-
events = /* @__PURE__ */ new Map();
|
|
519
|
-
debounceTimers = /* @__PURE__ */ new Map();
|
|
520
|
-
subscribe(event, callback) {
|
|
521
|
-
if (typeof event !== "string" || !event || typeof callback !== "function") {
|
|
522
|
-
return () => {
|
|
523
|
-
};
|
|
524
|
-
}
|
|
525
|
-
const listeners = this.events.get(event) || /* @__PURE__ */ new Set();
|
|
526
|
-
listeners.add(callback);
|
|
527
|
-
this.events.set(event, listeners);
|
|
528
|
-
return () => {
|
|
529
|
-
listeners.delete(callback);
|
|
530
|
-
if (listeners.size === 0) this.events.delete(event);
|
|
531
|
-
};
|
|
532
|
-
}
|
|
533
|
-
emit(event, payload) {
|
|
534
|
-
const listeners = this.events.get(event);
|
|
535
|
-
if (!listeners || listeners.size === 0) return;
|
|
536
|
-
const snapshot = Array.from(listeners);
|
|
537
|
-
for (const callback of snapshot) {
|
|
538
|
-
try {
|
|
539
|
-
callback(payload);
|
|
540
|
-
} catch (error) {
|
|
541
|
-
report(`Event listener (${String(event)})`, error);
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
emitDebounced(event, payload, waitMs = 100) {
|
|
546
|
-
const existing = this.debounceTimers.get(event);
|
|
547
|
-
if (existing) clearTimeout(existing);
|
|
548
|
-
const timer = setTimeout(() => {
|
|
549
|
-
this.debounceTimers.delete(event);
|
|
550
|
-
this.emit(event, payload);
|
|
551
|
-
}, waitMs);
|
|
552
|
-
this.debounceTimers.set(event, timer);
|
|
553
|
-
}
|
|
554
|
-
cancelDebounced(event) {
|
|
555
|
-
if (event) {
|
|
556
|
-
const timer = this.debounceTimers.get(event);
|
|
557
|
-
if (timer) {
|
|
558
|
-
clearTimeout(timer);
|
|
559
|
-
this.debounceTimers.delete(event);
|
|
560
|
-
}
|
|
561
|
-
} else {
|
|
562
|
-
for (const timer of this.debounceTimers.values()) {
|
|
563
|
-
clearTimeout(timer);
|
|
564
|
-
}
|
|
565
|
-
this.debounceTimers.clear();
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
unsubscribeAll(event) {
|
|
569
|
-
this.cancelDebounced(event);
|
|
570
|
-
if (event) this.events.delete(event);
|
|
571
|
-
else this.events.clear();
|
|
572
|
-
}
|
|
573
|
-
hasListeners(event) {
|
|
574
|
-
return Boolean(this.events.get(event)?.size);
|
|
575
|
-
}
|
|
576
|
-
getListenerCount(event) {
|
|
577
|
-
return this.events.get(event)?.size || 0;
|
|
578
|
-
}
|
|
579
|
-
getAllEvents() {
|
|
580
|
-
return [...this.events.keys()];
|
|
581
|
-
}
|
|
582
|
-
};
|
|
583
|
-
var GLOBAL_EVENTS_KEY = /* @__PURE__ */ Symbol.for("__base_framework_global_events__");
|
|
584
|
-
var _global = globalThis;
|
|
585
|
-
_global[GLOBAL_EVENTS_KEY] ?? (_global[GLOBAL_EVENTS_KEY] = new EventEmitter());
|
|
586
|
-
function createNoopHandle(status = "rejected", reason = "unknown") {
|
|
587
|
-
const handle = Object.assign(() => false, {
|
|
588
|
-
active: false,
|
|
589
|
-
dispose: () => false,
|
|
590
|
-
instanceId: null,
|
|
591
|
-
key: "",
|
|
592
|
-
priority: 0,
|
|
593
|
-
reason,
|
|
594
|
-
source: "",
|
|
595
|
-
status,
|
|
596
|
-
type: "",
|
|
597
|
-
update: () => handle,
|
|
598
|
-
updatedAt: 0,
|
|
599
|
-
validation: "warn"
|
|
600
|
-
});
|
|
601
|
-
return handle;
|
|
602
|
-
}
|
|
603
|
-
createNoopHandle();
|
|
604
|
-
getOrCreateGlobalContext(
|
|
605
|
-
"RegistryContext",
|
|
510
|
+
var BackgroundContext = getOrCreateGlobalContext(
|
|
511
|
+
"BackgroundContext",
|
|
606
512
|
null
|
|
607
513
|
);
|
|
608
|
-
var
|
|
609
|
-
|
|
610
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
611
|
-
let stack = [];
|
|
612
|
-
const notify = () => {
|
|
613
|
-
listeners.forEach((listener) => {
|
|
614
|
-
try {
|
|
615
|
-
listener();
|
|
616
|
-
} catch (error) {
|
|
617
|
-
report("Page controller listener", error);
|
|
618
|
-
}
|
|
619
|
-
});
|
|
620
|
-
};
|
|
621
|
-
return {
|
|
622
|
-
getSnapshot() {
|
|
623
|
-
const top = stack[stack.length - 1];
|
|
624
|
-
return top?.controllerRef?.current || null;
|
|
625
|
-
},
|
|
626
|
-
notify,
|
|
627
|
-
register(id, controllerRef) {
|
|
628
|
-
stack = stack.filter((item) => item.id !== id);
|
|
629
|
-
stack.push({ controllerRef, id });
|
|
630
|
-
notify();
|
|
631
|
-
},
|
|
632
|
-
subscribe(listener) {
|
|
633
|
-
listeners.add(listener);
|
|
634
|
-
return () => {
|
|
635
|
-
listeners.delete(listener);
|
|
636
|
-
};
|
|
637
|
-
},
|
|
638
|
-
unregister(id) {
|
|
639
|
-
stack = stack.filter((item) => item.id !== id);
|
|
640
|
-
notify();
|
|
641
|
-
}
|
|
642
|
-
};
|
|
643
|
-
}
|
|
644
|
-
var fallbackStandaloneStore = createPageControllerStore();
|
|
645
|
-
getOrCreateGlobalContext(
|
|
646
|
-
"PageControllerContext",
|
|
647
|
-
null
|
|
648
|
-
);
|
|
649
|
-
getOrCreateGlobalContext(
|
|
650
|
-
"PageControllerStoreContext",
|
|
651
|
-
fallbackStandaloneStore
|
|
514
|
+
var NOOP_BACKGROUND_STORE = createStore(
|
|
515
|
+
DEFAULT_BACKGROUND_COMPUTED
|
|
652
516
|
);
|
|
653
|
-
function
|
|
654
|
-
|
|
655
|
-
}
|
|
656
|
-
function useModule(id) {
|
|
657
|
-
const coreModule = use(ModuleHostContext)?.byId.get(id);
|
|
658
|
-
return coreModule?.context ? use(coreModule.context) ?? null : null;
|
|
659
|
-
}
|
|
660
|
-
var NO_MODULE_STORE = createStore(void 0);
|
|
661
|
-
function useModuleState(id, selector, fallback, isEqual = Object.is) {
|
|
662
|
-
const runtime = useModule(id);
|
|
517
|
+
function useOptionalBackgroundState(selector, isEqual) {
|
|
518
|
+
const ctx = useContext(BackgroundContext);
|
|
663
519
|
return useStore(
|
|
664
|
-
|
|
665
|
-
|
|
520
|
+
ctx?.store ?? NOOP_BACKGROUND_STORE,
|
|
521
|
+
selector,
|
|
666
522
|
isEqual
|
|
667
523
|
);
|
|
668
524
|
}
|
|
@@ -836,10 +692,8 @@ function selectPageAmbient(config) {
|
|
|
836
692
|
};
|
|
837
693
|
}
|
|
838
694
|
function useAmbientPage(slice, page) {
|
|
839
|
-
const posterUrl =
|
|
840
|
-
|
|
841
|
-
(background) => background.posterUrl,
|
|
842
|
-
null
|
|
695
|
+
const posterUrl = useOptionalBackgroundState(
|
|
696
|
+
(background) => background.posterUrl
|
|
843
697
|
);
|
|
844
698
|
const theme = useMemo(
|
|
845
699
|
() => resolvePageAmbientTheme(slice, posterUrl),
|