@ikonai/sdk-react-ui 0.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/base/base-div.d.ts +2 -0
- package/base/base-module.d.ts +5 -0
- package/ikon-ui-registry.d.ts +15 -0
- package/ikon-ui.d.ts +31 -0
- package/index.d.ts +9 -0
- package/index.js +1106 -0
- package/modules.d.ts +15 -0
- package/motion/motion-controller.d.ts +39 -0
- package/package.json +19 -0
- package/renderer/component-library.d.ts +31 -0
- package/renderer/index.d.ts +4 -0
- package/renderer/types.d.ts +21 -0
- package/renderer/ui-renderer.d.ts +11 -0
- package/renderer/use-ui-store.d.ts +3 -0
- package/surface.d.ts +18 -0
- package/use-ikon-styles.d.ts +9 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IkonUiComponentResolver, IkonUiModuleLoader, IkonUiRegistry } from '../ikon-ui-registry';
|
|
2
|
+
export declare const IKON_UI_BASE_MODULE = "base";
|
|
3
|
+
export declare function createBaseResolvers(): IkonUiComponentResolver[];
|
|
4
|
+
export declare const loadBaseModule: IkonUiModuleLoader;
|
|
5
|
+
export declare function registerBaseModule(registry: IkonUiRegistry): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { UiComponentLibrary, UiComponentRenderer, UiElementNode } from './renderer';
|
|
2
|
+
export type IkonUiComponentResolver = (node: UiElementNode) => UiComponentRenderer | undefined;
|
|
3
|
+
export type IkonUiModuleLoaderResult = IkonUiComponentResolver | IkonUiComponentResolver[] | undefined | void;
|
|
4
|
+
export type IkonUiModuleLoader = () => Promise<IkonUiModuleLoaderResult> | IkonUiModuleLoaderResult;
|
|
5
|
+
export declare class IkonUiRegistry implements UiComponentLibrary {
|
|
6
|
+
private readonly baseResolvers;
|
|
7
|
+
private readonly moduleLoaders;
|
|
8
|
+
private readonly moduleResolvers;
|
|
9
|
+
private activeModuleOrder;
|
|
10
|
+
registerResolvers(resolvers: IkonUiComponentResolver | IkonUiComponentResolver[]): void;
|
|
11
|
+
registerModule(name: string, loader: IkonUiModuleLoader): void;
|
|
12
|
+
loadRegisteredModules(): Promise<boolean>;
|
|
13
|
+
resolve(node: UiElementNode): UiComponentRenderer | undefined;
|
|
14
|
+
}
|
|
15
|
+
export declare function createIkonUiRegistry(): IkonUiRegistry;
|
package/ikon-ui.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { IkonClient } from '../../sdk/src/index.ts';
|
|
2
|
+
import { IkonUICore, IkonUiStreamListener, UiStyleListener, UiStylePayload } from '../../sdk-ui/src/index.ts';
|
|
3
|
+
import { IkonUiStoreEntry } from './surface';
|
|
4
|
+
export interface IkonUIConfig {
|
|
5
|
+
client?: IkonClient | null;
|
|
6
|
+
core?: IkonUICore;
|
|
7
|
+
}
|
|
8
|
+
type IkonUiListener = IkonUiStreamListener;
|
|
9
|
+
export declare class IkonUi {
|
|
10
|
+
private readonly core;
|
|
11
|
+
private readonly ownsCore;
|
|
12
|
+
private readonly stores;
|
|
13
|
+
private readonly listeners;
|
|
14
|
+
private readonly unsubscribeUpdates;
|
|
15
|
+
private readonly unsubscribeClears;
|
|
16
|
+
private readonly unsubscribeStoreChanges;
|
|
17
|
+
constructor(config?: IkonUIConfig);
|
|
18
|
+
dispose(): void;
|
|
19
|
+
getStores(): ReadonlyMap<string, IkonUiStoreEntry>;
|
|
20
|
+
getUiStyles(): readonly UiStylePayload[];
|
|
21
|
+
subscribe(listener: IkonUiListener): () => void;
|
|
22
|
+
subscribeToStyles(listener: UiStyleListener): () => void;
|
|
23
|
+
private handleUiUpdate;
|
|
24
|
+
private handleUiStreamCleared;
|
|
25
|
+
private syncStreamSnapshot;
|
|
26
|
+
private syncAllStreams;
|
|
27
|
+
private ensureStoreEntry;
|
|
28
|
+
private updateCategory;
|
|
29
|
+
private notify;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { IkonUi, type IkonUIConfig } from './ikon-ui';
|
|
2
|
+
export { IkonUiRegistry, createIkonUiRegistry, type IkonUiComponentResolver, type IkonUiModuleLoader, type IkonUiModuleLoaderResult, } from './ikon-ui-registry';
|
|
3
|
+
export { IkonUiSurface, IKON_UI_STREAM_CATEGORY, isIkonUiCategoryMatch, type IkonUiCategory, type IkonUiStoreEntry, } from './surface';
|
|
4
|
+
export { useIkonStyles, type IkonUiStyleSource } from './use-ikon-styles';
|
|
5
|
+
export { parseIkonUiInitPayload, normalizeIkonUiModuleList, readIkonUiModules, readIkonUiModulesFromSources, areIkonUiModuleListsEqual, type IkonUiInitInstruction, type IkonUiInitModulePayload, type IkonUiModuleList, } from './modules';
|
|
6
|
+
export { IKON_UI_BASE_MODULE, createBaseResolvers, loadBaseModule, registerBaseModule, } from './base/base-module';
|
|
7
|
+
export { UiRenderer, type UiRendererProps, UiComponentRegistry, createComponentLibrary, useUiStore, } from './renderer';
|
|
8
|
+
export type { UiComponentRenderer, UiComponentLibrary, UiElementNode, UiRenderContext, UiComponentRendererProps, ParsedUiUpdate, UiSnapshot, UiFullSnapshot, UiDiffSnapshot, UiElementDiffNode, TextDelta, UiElementProps, UiUpdateType, UiStoreSnapshot, UiOptimisticPatchState, } from './renderer';
|
|
9
|
+
export { UiStreamStore, type UiStylePayload } from '../../sdk-ui/src/index.ts';
|
package/index.js
ADDED
|
@@ -0,0 +1,1106 @@
|
|
|
1
|
+
import { createLogger as G } from "@ikonai/sdk";
|
|
2
|
+
import { IkonUICore as Te, UiStreamStore as Re } from "@ikonai/sdk-ui";
|
|
3
|
+
import { UiStreamStore as Mt } from "@ikonai/sdk-ui";
|
|
4
|
+
import Ce, { useSyncExternalStore as we, Fragment as Ne, useMemo as Oe, memo as ke, useCallback as re, useEffect as ne } from "react";
|
|
5
|
+
var z = { exports: {} }, j = {};
|
|
6
|
+
/**
|
|
7
|
+
* @license React
|
|
8
|
+
* react-jsx-runtime.production.js
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
11
|
+
*
|
|
12
|
+
* This source code is licensed under the MIT license found in the
|
|
13
|
+
* LICENSE file in the root directory of this source tree.
|
|
14
|
+
*/
|
|
15
|
+
var se;
|
|
16
|
+
function Ae() {
|
|
17
|
+
if (se) return j;
|
|
18
|
+
se = 1;
|
|
19
|
+
var n = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
|
|
20
|
+
function t(r, s, i) {
|
|
21
|
+
var a = null;
|
|
22
|
+
if (i !== void 0 && (a = "" + i), s.key !== void 0 && (a = "" + s.key), "key" in s) {
|
|
23
|
+
i = {};
|
|
24
|
+
for (var l in s)
|
|
25
|
+
l !== "key" && (i[l] = s[l]);
|
|
26
|
+
} else i = s;
|
|
27
|
+
return s = i.ref, {
|
|
28
|
+
$$typeof: n,
|
|
29
|
+
type: r,
|
|
30
|
+
key: a,
|
|
31
|
+
ref: s !== void 0 ? s : null,
|
|
32
|
+
props: i
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return j.Fragment = e, j.jsx = t, j.jsxs = t, j;
|
|
36
|
+
}
|
|
37
|
+
var I = {};
|
|
38
|
+
/**
|
|
39
|
+
* @license React
|
|
40
|
+
* react-jsx-runtime.development.js
|
|
41
|
+
*
|
|
42
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
43
|
+
*
|
|
44
|
+
* This source code is licensed under the MIT license found in the
|
|
45
|
+
* LICENSE file in the root directory of this source tree.
|
|
46
|
+
*/
|
|
47
|
+
var oe;
|
|
48
|
+
function _e() {
|
|
49
|
+
return oe || (oe = 1, process.env.NODE_ENV !== "production" && function() {
|
|
50
|
+
function n(o) {
|
|
51
|
+
if (o == null) return null;
|
|
52
|
+
if (typeof o == "function")
|
|
53
|
+
return o.$$typeof === be ? null : o.displayName || o.name || null;
|
|
54
|
+
if (typeof o == "string") return o;
|
|
55
|
+
switch (o) {
|
|
56
|
+
case b:
|
|
57
|
+
return "Fragment";
|
|
58
|
+
case h:
|
|
59
|
+
return "Profiler";
|
|
60
|
+
case f:
|
|
61
|
+
return "StrictMode";
|
|
62
|
+
case k:
|
|
63
|
+
return "Suspense";
|
|
64
|
+
case x:
|
|
65
|
+
return "SuspenseList";
|
|
66
|
+
case ge:
|
|
67
|
+
return "Activity";
|
|
68
|
+
}
|
|
69
|
+
if (typeof o == "object")
|
|
70
|
+
switch (typeof o.tag == "number" && console.error(
|
|
71
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
72
|
+
), o.$$typeof) {
|
|
73
|
+
case _:
|
|
74
|
+
return "Portal";
|
|
75
|
+
case C:
|
|
76
|
+
return (o.displayName || "Context") + ".Provider";
|
|
77
|
+
case y:
|
|
78
|
+
return (o._context.displayName || "Context") + ".Consumer";
|
|
79
|
+
case R:
|
|
80
|
+
var c = o.render;
|
|
81
|
+
return o = o.displayName, o || (o = c.displayName || c.name || "", o = o !== "" ? "ForwardRef(" + o + ")" : "ForwardRef"), o;
|
|
82
|
+
case Se:
|
|
83
|
+
return c = o.displayName || null, c !== null ? c : n(o.type) || "Memo";
|
|
84
|
+
case X:
|
|
85
|
+
c = o._payload, o = o._init;
|
|
86
|
+
try {
|
|
87
|
+
return n(o(c));
|
|
88
|
+
} catch {
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
function e(o) {
|
|
94
|
+
return "" + o;
|
|
95
|
+
}
|
|
96
|
+
function t(o) {
|
|
97
|
+
try {
|
|
98
|
+
e(o);
|
|
99
|
+
var c = !1;
|
|
100
|
+
} catch {
|
|
101
|
+
c = !0;
|
|
102
|
+
}
|
|
103
|
+
if (c) {
|
|
104
|
+
c = console;
|
|
105
|
+
var m = c.error, S = typeof Symbol == "function" && Symbol.toStringTag && o[Symbol.toStringTag] || o.constructor.name || "Object";
|
|
106
|
+
return m.call(
|
|
107
|
+
c,
|
|
108
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
109
|
+
S
|
|
110
|
+
), e(o);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function r(o) {
|
|
114
|
+
if (o === b) return "<>";
|
|
115
|
+
if (typeof o == "object" && o !== null && o.$$typeof === X)
|
|
116
|
+
return "<...>";
|
|
117
|
+
try {
|
|
118
|
+
var c = n(o);
|
|
119
|
+
return c ? "<" + c + ">" : "<...>";
|
|
120
|
+
} catch {
|
|
121
|
+
return "<...>";
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function s() {
|
|
125
|
+
var o = F.A;
|
|
126
|
+
return o === null ? null : o.getOwner();
|
|
127
|
+
}
|
|
128
|
+
function i() {
|
|
129
|
+
return Error("react-stack-top-frame");
|
|
130
|
+
}
|
|
131
|
+
function a(o) {
|
|
132
|
+
if (H.call(o, "key")) {
|
|
133
|
+
var c = Object.getOwnPropertyDescriptor(o, "key").get;
|
|
134
|
+
if (c && c.isReactWarning) return !1;
|
|
135
|
+
}
|
|
136
|
+
return o.key !== void 0;
|
|
137
|
+
}
|
|
138
|
+
function l(o, c) {
|
|
139
|
+
function m() {
|
|
140
|
+
K || (K = !0, console.error(
|
|
141
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
142
|
+
c
|
|
143
|
+
));
|
|
144
|
+
}
|
|
145
|
+
m.isReactWarning = !0, Object.defineProperty(o, "key", {
|
|
146
|
+
get: m,
|
|
147
|
+
configurable: !0
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function u() {
|
|
151
|
+
var o = n(this.type);
|
|
152
|
+
return Z[o] || (Z[o] = !0, console.error(
|
|
153
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
154
|
+
)), o = this.props.ref, o !== void 0 ? o : null;
|
|
155
|
+
}
|
|
156
|
+
function d(o, c, m, S, N, w, D, q) {
|
|
157
|
+
return m = w.ref, o = {
|
|
158
|
+
$$typeof: O,
|
|
159
|
+
type: o,
|
|
160
|
+
key: c,
|
|
161
|
+
props: w,
|
|
162
|
+
_owner: N
|
|
163
|
+
}, (m !== void 0 ? m : null) !== null ? Object.defineProperty(o, "ref", {
|
|
164
|
+
enumerable: !1,
|
|
165
|
+
get: u
|
|
166
|
+
}) : Object.defineProperty(o, "ref", { enumerable: !1, value: null }), o._store = {}, Object.defineProperty(o._store, "validated", {
|
|
167
|
+
configurable: !1,
|
|
168
|
+
enumerable: !1,
|
|
169
|
+
writable: !0,
|
|
170
|
+
value: 0
|
|
171
|
+
}), Object.defineProperty(o, "_debugInfo", {
|
|
172
|
+
configurable: !1,
|
|
173
|
+
enumerable: !1,
|
|
174
|
+
writable: !0,
|
|
175
|
+
value: null
|
|
176
|
+
}), Object.defineProperty(o, "_debugStack", {
|
|
177
|
+
configurable: !1,
|
|
178
|
+
enumerable: !1,
|
|
179
|
+
writable: !0,
|
|
180
|
+
value: D
|
|
181
|
+
}), Object.defineProperty(o, "_debugTask", {
|
|
182
|
+
configurable: !1,
|
|
183
|
+
enumerable: !1,
|
|
184
|
+
writable: !0,
|
|
185
|
+
value: q
|
|
186
|
+
}), Object.freeze && (Object.freeze(o.props), Object.freeze(o)), o;
|
|
187
|
+
}
|
|
188
|
+
function p(o, c, m, S, N, w, D, q) {
|
|
189
|
+
var g = c.children;
|
|
190
|
+
if (g !== void 0)
|
|
191
|
+
if (S)
|
|
192
|
+
if (ve(g)) {
|
|
193
|
+
for (S = 0; S < g.length; S++)
|
|
194
|
+
E(g[S]);
|
|
195
|
+
Object.freeze && Object.freeze(g);
|
|
196
|
+
} else
|
|
197
|
+
console.error(
|
|
198
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
199
|
+
);
|
|
200
|
+
else E(g);
|
|
201
|
+
if (H.call(c, "key")) {
|
|
202
|
+
g = n(o);
|
|
203
|
+
var M = Object.keys(c).filter(function(Ee) {
|
|
204
|
+
return Ee !== "key";
|
|
205
|
+
});
|
|
206
|
+
S = 0 < M.length ? "{key: someKey, " + M.join(": ..., ") + ": ...}" : "{key: someKey}", te[g + S] || (M = 0 < M.length ? "{" + M.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
207
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
208
|
+
let props = %s;
|
|
209
|
+
<%s {...props} />
|
|
210
|
+
React keys must be passed directly to JSX without using spread:
|
|
211
|
+
let props = %s;
|
|
212
|
+
<%s key={someKey} {...props} />`,
|
|
213
|
+
S,
|
|
214
|
+
g,
|
|
215
|
+
M,
|
|
216
|
+
g
|
|
217
|
+
), te[g + S] = !0);
|
|
218
|
+
}
|
|
219
|
+
if (g = null, m !== void 0 && (t(m), g = "" + m), a(c) && (t(c.key), g = "" + c.key), "key" in c) {
|
|
220
|
+
m = {};
|
|
221
|
+
for (var Y in c)
|
|
222
|
+
Y !== "key" && (m[Y] = c[Y]);
|
|
223
|
+
} else m = c;
|
|
224
|
+
return g && l(
|
|
225
|
+
m,
|
|
226
|
+
typeof o == "function" ? o.displayName || o.name || "Unknown" : o
|
|
227
|
+
), d(
|
|
228
|
+
o,
|
|
229
|
+
g,
|
|
230
|
+
w,
|
|
231
|
+
N,
|
|
232
|
+
s(),
|
|
233
|
+
m,
|
|
234
|
+
D,
|
|
235
|
+
q
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
function E(o) {
|
|
239
|
+
typeof o == "object" && o !== null && o.$$typeof === O && o._store && (o._store.validated = 1);
|
|
240
|
+
}
|
|
241
|
+
var T = Ce, O = Symbol.for("react.transitional.element"), _ = Symbol.for("react.portal"), b = Symbol.for("react.fragment"), f = Symbol.for("react.strict_mode"), h = Symbol.for("react.profiler"), y = Symbol.for("react.consumer"), C = Symbol.for("react.context"), R = Symbol.for("react.forward_ref"), k = Symbol.for("react.suspense"), x = Symbol.for("react.suspense_list"), Se = Symbol.for("react.memo"), X = Symbol.for("react.lazy"), ge = Symbol.for("react.activity"), be = Symbol.for("react.client.reference"), F = T.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, H = Object.prototype.hasOwnProperty, ve = Array.isArray, $ = console.createTask ? console.createTask : function() {
|
|
242
|
+
return null;
|
|
243
|
+
};
|
|
244
|
+
T = {
|
|
245
|
+
"react-stack-bottom-frame": function(o) {
|
|
246
|
+
return o();
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
var K, Z = {}, Q = T["react-stack-bottom-frame"].bind(
|
|
250
|
+
T,
|
|
251
|
+
i
|
|
252
|
+
)(), ee = $(r(i)), te = {};
|
|
253
|
+
I.Fragment = b, I.jsx = function(o, c, m, S, N) {
|
|
254
|
+
var w = 1e4 > F.recentlyCreatedOwnerStacks++;
|
|
255
|
+
return p(
|
|
256
|
+
o,
|
|
257
|
+
c,
|
|
258
|
+
m,
|
|
259
|
+
!1,
|
|
260
|
+
S,
|
|
261
|
+
N,
|
|
262
|
+
w ? Error("react-stack-top-frame") : Q,
|
|
263
|
+
w ? $(r(o)) : ee
|
|
264
|
+
);
|
|
265
|
+
}, I.jsxs = function(o, c, m, S, N) {
|
|
266
|
+
var w = 1e4 > F.recentlyCreatedOwnerStacks++;
|
|
267
|
+
return p(
|
|
268
|
+
o,
|
|
269
|
+
c,
|
|
270
|
+
m,
|
|
271
|
+
!0,
|
|
272
|
+
S,
|
|
273
|
+
N,
|
|
274
|
+
w ? Error("react-stack-top-frame") : Q,
|
|
275
|
+
w ? $(r(o)) : ee
|
|
276
|
+
);
|
|
277
|
+
};
|
|
278
|
+
}()), I;
|
|
279
|
+
}
|
|
280
|
+
var ie;
|
|
281
|
+
function Me() {
|
|
282
|
+
return ie || (ie = 1, process.env.NODE_ENV === "production" ? z.exports = Ae() : z.exports = _e()), z.exports;
|
|
283
|
+
}
|
|
284
|
+
var A = Me();
|
|
285
|
+
function je(n) {
|
|
286
|
+
return we(
|
|
287
|
+
(e) => n.subscribe(e),
|
|
288
|
+
() => n.getSnapshot(),
|
|
289
|
+
() => n.getSnapshot()
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
const Ie = G("UIRenderer");
|
|
293
|
+
function Pe(n) {
|
|
294
|
+
if (n === void 0)
|
|
295
|
+
return "{}";
|
|
296
|
+
if (typeof n == "string")
|
|
297
|
+
return n;
|
|
298
|
+
try {
|
|
299
|
+
return JSON.stringify(n);
|
|
300
|
+
} catch {
|
|
301
|
+
return "{}";
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
function me(n) {
|
|
305
|
+
const e = Le(n), t = Ue(n);
|
|
306
|
+
return e === n.children && t === n.styleIds ? n : {
|
|
307
|
+
...n,
|
|
308
|
+
...e !== n.children ? { children: e } : {},
|
|
309
|
+
...t !== n.styleIds ? { styleIds: t } : {}
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
function Ue(n) {
|
|
313
|
+
const e = n.styleIds;
|
|
314
|
+
return Array.isArray(e) ? e : [];
|
|
315
|
+
}
|
|
316
|
+
function Le(n) {
|
|
317
|
+
const e = n.children;
|
|
318
|
+
return Array.isArray(e) ? e : [];
|
|
319
|
+
}
|
|
320
|
+
function xe({ node: n, renderer: e, library: t, context: r, className: s }) {
|
|
321
|
+
const i = me(n), a = i.children.map((u) => L(u, t, r)), l = e;
|
|
322
|
+
return /* @__PURE__ */ A.jsx(
|
|
323
|
+
l,
|
|
324
|
+
{
|
|
325
|
+
node: i,
|
|
326
|
+
context: r,
|
|
327
|
+
children: a,
|
|
328
|
+
className: s,
|
|
329
|
+
styleIds: i.styleIds
|
|
330
|
+
}
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
function L(n, e, t) {
|
|
334
|
+
const r = me(n), s = r.children;
|
|
335
|
+
if (r.type === "root")
|
|
336
|
+
return /* @__PURE__ */ A.jsx(Ne, { children: s.map((u) => L(u, e, t)) }, r.id);
|
|
337
|
+
const i = e.resolve(r);
|
|
338
|
+
if (!i)
|
|
339
|
+
return Ie.warn(`No renderer for node type ${r.type}`), null;
|
|
340
|
+
const a = r.styleIds, l = a.length > 0 ? a.join(" ") : void 0;
|
|
341
|
+
return /* @__PURE__ */ A.jsx(
|
|
342
|
+
xe,
|
|
343
|
+
{
|
|
344
|
+
node: r,
|
|
345
|
+
renderer: i,
|
|
346
|
+
library: e,
|
|
347
|
+
context: t,
|
|
348
|
+
className: l
|
|
349
|
+
},
|
|
350
|
+
r.id
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
function ze({ store: n, library: e, containerId: t, emptyFallback: r = null, onAction: s }) {
|
|
354
|
+
const i = je(n), a = t ?? i.rootContainerId;
|
|
355
|
+
if (!a) return r;
|
|
356
|
+
const l = i.containers.get(a);
|
|
357
|
+
if (!l) return r;
|
|
358
|
+
const u = {
|
|
359
|
+
getPayload: (d) => i.payloads.get(d),
|
|
360
|
+
renderChildren: (d) => Array.isArray(d) ? d.map((p) => L(p, e, u)) : [],
|
|
361
|
+
renderContainer: (d) => {
|
|
362
|
+
const p = i.containers.get(d);
|
|
363
|
+
return p ? L(p, e, u) : null;
|
|
364
|
+
},
|
|
365
|
+
dispatchAction: (d, p) => {
|
|
366
|
+
if (!d)
|
|
367
|
+
return;
|
|
368
|
+
const E = Pe(p);
|
|
369
|
+
s?.(d, E);
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
return L(l, e, u);
|
|
373
|
+
}
|
|
374
|
+
class Be {
|
|
375
|
+
constructor(e, t) {
|
|
376
|
+
if (this.fallback = t, e)
|
|
377
|
+
for (const [r, s] of e)
|
|
378
|
+
this.renderers.set(r, s);
|
|
379
|
+
}
|
|
380
|
+
renderers = /* @__PURE__ */ new Map();
|
|
381
|
+
register(e, t) {
|
|
382
|
+
this.renderers.set(e, t);
|
|
383
|
+
}
|
|
384
|
+
setFallback(e) {
|
|
385
|
+
this.fallback = e;
|
|
386
|
+
}
|
|
387
|
+
resolve(e) {
|
|
388
|
+
return this.renderers.get(e.type) ?? this.fallback;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
function Et(n, e) {
|
|
392
|
+
const t = Object.entries(n);
|
|
393
|
+
return new Be(t, e);
|
|
394
|
+
}
|
|
395
|
+
const V = "ikon-ui";
|
|
396
|
+
function Fe(n, e) {
|
|
397
|
+
return n === e;
|
|
398
|
+
}
|
|
399
|
+
function Tt({ stores: n, library: e, category: t = V, version: r, onAction: s }) {
|
|
400
|
+
const i = Oe(() => {
|
|
401
|
+
const a = [];
|
|
402
|
+
for (const [l, u] of n) {
|
|
403
|
+
if (!Fe(u.category, t))
|
|
404
|
+
continue;
|
|
405
|
+
const d = u.store.getSnapshot();
|
|
406
|
+
!d.rootContainerId || !d.containers.has(d.rootContainerId) || a.push({ key: l, store: u.store });
|
|
407
|
+
}
|
|
408
|
+
return a;
|
|
409
|
+
}, [n, t, r]);
|
|
410
|
+
return i.length === 0 ? null : /* @__PURE__ */ A.jsx(A.Fragment, { children: i.map(({ key: a, store: l }) => /* @__PURE__ */ A.jsx(ze, { store: l, library: e, onAction: s }, a)) });
|
|
411
|
+
}
|
|
412
|
+
const ae = G("IkonUI");
|
|
413
|
+
class Rt {
|
|
414
|
+
core;
|
|
415
|
+
ownsCore;
|
|
416
|
+
stores = /* @__PURE__ */ new Map();
|
|
417
|
+
listeners = /* @__PURE__ */ new Set();
|
|
418
|
+
unsubscribeUpdates;
|
|
419
|
+
unsubscribeClears;
|
|
420
|
+
unsubscribeStoreChanges;
|
|
421
|
+
constructor(e) {
|
|
422
|
+
ae.debug("Created"), this.core = e?.core ?? new Te({ client: e?.client }), this.ownsCore = !e?.core, this.unsubscribeUpdates = this.core.subscribeToUiUpdates(this.handleUiUpdate), this.unsubscribeClears = this.core.subscribeToUiStreamCleared(this.handleUiStreamCleared), this.unsubscribeStoreChanges = this.core.uiStore.subscribe(this.syncStreamSnapshot), this.syncAllStreams();
|
|
423
|
+
}
|
|
424
|
+
dispose() {
|
|
425
|
+
this.unsubscribeUpdates(), this.unsubscribeClears(), this.unsubscribeStoreChanges(), this.ownsCore && this.core.dispose(), this.listeners.clear(), this.stores.clear(), ae.debug("Disposed");
|
|
426
|
+
}
|
|
427
|
+
getStores() {
|
|
428
|
+
return this.stores;
|
|
429
|
+
}
|
|
430
|
+
getUiStyles() {
|
|
431
|
+
return this.core.getUiStyles();
|
|
432
|
+
}
|
|
433
|
+
subscribe(e) {
|
|
434
|
+
return this.listeners.add(e), () => {
|
|
435
|
+
this.listeners.delete(e);
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
subscribeToStyles(e) {
|
|
439
|
+
return this.core.subscribeToUiStyles(e);
|
|
440
|
+
}
|
|
441
|
+
handleUiUpdate = (e, t) => {
|
|
442
|
+
const s = this.ensureStoreEntry(e).store.apply(t), i = this.updateCategory(e);
|
|
443
|
+
(s || i) && this.notify(e);
|
|
444
|
+
};
|
|
445
|
+
handleUiStreamCleared = (e) => {
|
|
446
|
+
this.stores.delete(e) && this.notify(e);
|
|
447
|
+
};
|
|
448
|
+
syncStreamSnapshot = (e) => {
|
|
449
|
+
const t = this.core.uiStore.getSnapshot(e);
|
|
450
|
+
if (!t || !t.rootContainerId) {
|
|
451
|
+
this.handleUiStreamCleared(e);
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
const r = t.containers.get(t.rootContainerId);
|
|
455
|
+
if (!r) {
|
|
456
|
+
this.handleUiStreamCleared(e);
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
const s = this.ensureStoreEntry(e), i = {
|
|
460
|
+
snapshot: {
|
|
461
|
+
type: "full",
|
|
462
|
+
version: t.version ?? 0,
|
|
463
|
+
metadata: { containerId: t.rootContainerId },
|
|
464
|
+
root: r
|
|
465
|
+
},
|
|
466
|
+
payloads: t.payloads
|
|
467
|
+
}, a = s.store.apply(i), l = this.updateCategory(e, t.category);
|
|
468
|
+
(a || l) && this.notify(e);
|
|
469
|
+
};
|
|
470
|
+
syncAllStreams() {
|
|
471
|
+
const e = this.core.uiStore.getSnapshots(), t = /* @__PURE__ */ new Set();
|
|
472
|
+
for (const r of e)
|
|
473
|
+
this.syncStreamSnapshot(r.streamId), t.add(r.streamId);
|
|
474
|
+
for (const r of this.stores.keys())
|
|
475
|
+
t.has(r) || (this.stores.delete(r), this.notify(r));
|
|
476
|
+
}
|
|
477
|
+
ensureStoreEntry(e) {
|
|
478
|
+
const t = this.stores.get(e);
|
|
479
|
+
if (t)
|
|
480
|
+
return t;
|
|
481
|
+
const r = {
|
|
482
|
+
category: V,
|
|
483
|
+
store: new Re()
|
|
484
|
+
};
|
|
485
|
+
return this.stores.set(e, r), r;
|
|
486
|
+
}
|
|
487
|
+
updateCategory(e, t) {
|
|
488
|
+
const r = this.stores.get(e);
|
|
489
|
+
if (!r)
|
|
490
|
+
return !1;
|
|
491
|
+
const s = t ?? this.core.uiStore.getSnapshot(e)?.category ?? V;
|
|
492
|
+
return r.category === s ? !1 : (this.stores.set(e, { ...r, category: s }), !0);
|
|
493
|
+
}
|
|
494
|
+
notify(e) {
|
|
495
|
+
for (const t of this.listeners)
|
|
496
|
+
t(e);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
function $e() {
|
|
500
|
+
const n = ke(function({ node: t, context: r, className: s }) {
|
|
501
|
+
const i = t.children?.length ? r.renderChildren(t.children) : void 0;
|
|
502
|
+
return /* @__PURE__ */ A.jsx("div", { className: s, children: i });
|
|
503
|
+
});
|
|
504
|
+
return ({ type: e }) => {
|
|
505
|
+
if (e === "common.div")
|
|
506
|
+
return n;
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
const De = "base";
|
|
510
|
+
function qe() {
|
|
511
|
+
return [$e()];
|
|
512
|
+
}
|
|
513
|
+
const Ye = async () => qe();
|
|
514
|
+
function We(n) {
|
|
515
|
+
n.registerModule(De, Ye);
|
|
516
|
+
}
|
|
517
|
+
const P = G("UIRegistry");
|
|
518
|
+
class Ve {
|
|
519
|
+
baseResolvers = [];
|
|
520
|
+
moduleLoaders = /* @__PURE__ */ new Map();
|
|
521
|
+
moduleResolvers = /* @__PURE__ */ new Map();
|
|
522
|
+
activeModuleOrder = [];
|
|
523
|
+
registerResolvers(e) {
|
|
524
|
+
const t = Array.isArray(e) ? e : [e];
|
|
525
|
+
this.baseResolvers.push(...t.filter(Boolean));
|
|
526
|
+
}
|
|
527
|
+
registerModule(e, t) {
|
|
528
|
+
const r = this.moduleLoaders.get(e);
|
|
529
|
+
if (!r) {
|
|
530
|
+
P.debug(`Register module ${e}`), this.moduleLoaders.set(e, t);
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
r !== t && (P.debug(`Register module ${e} (replacing loader)`), this.moduleLoaders.set(e, t), this.moduleResolvers.delete(e));
|
|
534
|
+
}
|
|
535
|
+
async loadRegisteredModules() {
|
|
536
|
+
let e = !1;
|
|
537
|
+
for (const [r, s] of this.moduleLoaders.entries())
|
|
538
|
+
if (!this.moduleResolvers.has(r))
|
|
539
|
+
try {
|
|
540
|
+
const i = await s(), a = Ge(i);
|
|
541
|
+
this.moduleResolvers.set(r, a), P.debug(`Loaded module ${r}`), e = !0;
|
|
542
|
+
} catch (i) {
|
|
543
|
+
P.error(`[IkonUiRegistry] Failed to load module '${r}'.`, i);
|
|
544
|
+
}
|
|
545
|
+
const t = [];
|
|
546
|
+
for (const r of this.moduleLoaders.keys())
|
|
547
|
+
this.moduleResolvers.has(r) && t.push(r);
|
|
548
|
+
return Xe(t, this.activeModuleOrder) || (this.activeModuleOrder = t, e = !0), e;
|
|
549
|
+
}
|
|
550
|
+
resolve(e) {
|
|
551
|
+
for (const t of this.baseResolvers) {
|
|
552
|
+
const r = t(e);
|
|
553
|
+
if (r) return r;
|
|
554
|
+
}
|
|
555
|
+
for (const t of this.activeModuleOrder) {
|
|
556
|
+
const r = this.moduleResolvers.get(t);
|
|
557
|
+
if (!r) {
|
|
558
|
+
P.warn(`Missing resolvers for module ${t}`);
|
|
559
|
+
continue;
|
|
560
|
+
}
|
|
561
|
+
for (const s of r) {
|
|
562
|
+
const i = s(e);
|
|
563
|
+
if (i) return i;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
function Ct() {
|
|
569
|
+
const n = new Ve();
|
|
570
|
+
return We(n), n.loadRegisteredModules(), n;
|
|
571
|
+
}
|
|
572
|
+
function Je(n) {
|
|
573
|
+
return Array.isArray(n) ? n : [n];
|
|
574
|
+
}
|
|
575
|
+
function Ge(n) {
|
|
576
|
+
return n ? Je(n).flatMap((e) => e ? Array.isArray(e) ? e.filter(Boolean) : [e] : []) : [];
|
|
577
|
+
}
|
|
578
|
+
function Xe(n, e) {
|
|
579
|
+
if (n.length !== e.length)
|
|
580
|
+
return !1;
|
|
581
|
+
for (let t = 0; t < n.length; t += 1)
|
|
582
|
+
if (n[t] !== e[t])
|
|
583
|
+
return !1;
|
|
584
|
+
return !0;
|
|
585
|
+
}
|
|
586
|
+
const ce = {
|
|
587
|
+
ease: [0.25, 0.1, 0.25, 1],
|
|
588
|
+
"ease-in": [0.42, 0, 1, 1],
|
|
589
|
+
"ease-out": [0, 0, 0.58, 1],
|
|
590
|
+
"ease-in-out": [0.42, 0, 0.58, 1],
|
|
591
|
+
"ease-in-sine": [0.47, 0, 0.745, 0.715],
|
|
592
|
+
"ease-out-sine": [0.39, 0.575, 0.565, 1],
|
|
593
|
+
"ease-in-out-sine": [0.445, 0.05, 0.55, 0.95],
|
|
594
|
+
"ease-in-quad": [0.55, 0.085, 0.68, 0.53],
|
|
595
|
+
"ease-out-quad": [0.25, 0.46, 0.45, 0.94],
|
|
596
|
+
"ease-in-out-quad": [0.455, 0.03, 0.515, 0.955],
|
|
597
|
+
"ease-in-cubic": [0.55, 0.055, 0.675, 0.19],
|
|
598
|
+
"ease-out-cubic": [0.215, 0.61, 0.355, 1],
|
|
599
|
+
"ease-in-out-cubic": [0.645, 0.045, 0.355, 1],
|
|
600
|
+
"ease-in-quart": [0.895, 0.03, 0.685, 0.22],
|
|
601
|
+
"ease-out-quart": [0.165, 0.84, 0.44, 1],
|
|
602
|
+
"ease-in-out-quart": [0.77, 0, 0.175, 1],
|
|
603
|
+
"ease-in-quint": [0.755, 0.05, 0.855, 0.06],
|
|
604
|
+
"ease-out-quint": [0.23, 1, 0.32, 1],
|
|
605
|
+
"ease-in-out-quint": [0.86, 0, 0.07, 1],
|
|
606
|
+
"ease-in-expo": [0.95, 0.05, 0.795, 0.035],
|
|
607
|
+
"ease-out-expo": [0.19, 1, 0.22, 1],
|
|
608
|
+
"ease-in-out-expo": [1, 0, 0, 1],
|
|
609
|
+
"ease-in-circ": [0.6, 0.04, 0.98, 0.335],
|
|
610
|
+
"ease-out-circ": [0.075, 0.82, 0.165, 1],
|
|
611
|
+
"ease-in-out-circ": [0.785, 0.135, 0.15, 0.86],
|
|
612
|
+
"ease-in-back": [0.6, -0.28, 0.735, 0.045],
|
|
613
|
+
"ease-out-back": [0.175, 0.885, 0.32, 1.275],
|
|
614
|
+
"ease-in-out-back": [0.68, -0.55, 0.265, 1.55]
|
|
615
|
+
};
|
|
616
|
+
function v(n) {
|
|
617
|
+
return n <= 0 ? 0 : n >= 1 ? 1 : n;
|
|
618
|
+
}
|
|
619
|
+
function le(n) {
|
|
620
|
+
if (n == null) return;
|
|
621
|
+
const e = `${n}`.trim();
|
|
622
|
+
if (!e) return;
|
|
623
|
+
const t = Number.parseFloat(e);
|
|
624
|
+
return Number.isFinite(t) ? t : void 0;
|
|
625
|
+
}
|
|
626
|
+
function ue(n) {
|
|
627
|
+
const e = globalThis.CSS;
|
|
628
|
+
return e?.escape ? e.escape(n) : n.replace(/[^a-zA-Z0-9_-]/g, (t) => `\\${t}`);
|
|
629
|
+
}
|
|
630
|
+
function de(n, e, t, r) {
|
|
631
|
+
const p = new Float32Array(11);
|
|
632
|
+
function E(f, h, y) {
|
|
633
|
+
return ((3 * h - 3 * y + 1) * f + (3 * y - 6 * h)) * f * f + 3 * h * f;
|
|
634
|
+
}
|
|
635
|
+
function T(f, h, y) {
|
|
636
|
+
return 3 * (3 * h - 3 * y + 1) * f * f + 2 * (3 * y - 6 * h) * f + 3 * h;
|
|
637
|
+
}
|
|
638
|
+
function O(f, h) {
|
|
639
|
+
for (let y = 0; y < 4; y += 1) {
|
|
640
|
+
const C = T(h, n, t);
|
|
641
|
+
if (C === 0)
|
|
642
|
+
return h;
|
|
643
|
+
const R = E(h, n, t) - f;
|
|
644
|
+
h -= R / C;
|
|
645
|
+
}
|
|
646
|
+
return h;
|
|
647
|
+
}
|
|
648
|
+
function _(f, h, y) {
|
|
649
|
+
let C = 0, R = 0, k = 0;
|
|
650
|
+
do
|
|
651
|
+
R = h + (y - h) / 2, C = E(R, n, t) - f, C > 0 ? y = R : h = R;
|
|
652
|
+
while (Math.abs(C) > 1e-7 && ++k < 10);
|
|
653
|
+
return R;
|
|
654
|
+
}
|
|
655
|
+
function b(f) {
|
|
656
|
+
let h = 0, y = 1;
|
|
657
|
+
const C = 10;
|
|
658
|
+
for (; y !== C && p[y] <= f; y += 1)
|
|
659
|
+
h += 0.1;
|
|
660
|
+
y -= 1;
|
|
661
|
+
const R = (f - p[y]) / (p[y + 1] - p[y]), k = h + R * 0.1, x = T(k, n, t);
|
|
662
|
+
return x >= 1e-3 ? O(f, k) : x === 0 ? k : _(f, h, h + 0.1);
|
|
663
|
+
}
|
|
664
|
+
for (let f = 0; f < 11; f += 1)
|
|
665
|
+
p[f] = E(f * 0.1, n, t);
|
|
666
|
+
return (f) => f <= 0 ? 0 : f >= 1 ? 1 : E(b(f), e, r);
|
|
667
|
+
}
|
|
668
|
+
function He(n) {
|
|
669
|
+
const e = /steps\(\s*([0-9]+)\s*(?:,\s*([a-z-]+)\s*)?\)/i.exec(n);
|
|
670
|
+
if (!e)
|
|
671
|
+
return (s) => v(s);
|
|
672
|
+
const t = Math.max(1, parseInt(e[1], 10)), r = (e[2] ?? "end").toLowerCase();
|
|
673
|
+
return r === "start" || r === "jump-start" ? (s) => v(Math.ceil(s * t) / t) : r === "none" || r === "jump-none" ? (s) => v(Math.round(s * t) / t) : r === "both" || r === "jump-both" ? (s) => v((Math.floor(s * t) + 0.5) / t) : (s) => v(Math.floor(s * t) / t);
|
|
674
|
+
}
|
|
675
|
+
function Ke(n) {
|
|
676
|
+
if (!n)
|
|
677
|
+
return (t) => v(t);
|
|
678
|
+
const e = n.trim().toLowerCase();
|
|
679
|
+
if (!e || e === "linear")
|
|
680
|
+
return (t) => v(t);
|
|
681
|
+
if (ce[e]) {
|
|
682
|
+
const [t, r, s, i] = ce[e], a = de(t, r, s, i);
|
|
683
|
+
return (l) => v(a(v(l)));
|
|
684
|
+
}
|
|
685
|
+
if (e.startsWith("cubic-bezier(") && e.endsWith(")")) {
|
|
686
|
+
const r = e.slice(13, -1).split(",").map((s) => Number.parseFloat(s.trim()));
|
|
687
|
+
if (r.length === 4 && r.every((s) => Number.isFinite(s))) {
|
|
688
|
+
const [s, i, a, l] = r, u = de(s, i, a, l);
|
|
689
|
+
return (d) => v(u(v(d)));
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
if (e.startsWith("steps(") && e.endsWith(")")) {
|
|
693
|
+
const t = He(e);
|
|
694
|
+
return (r) => t(v(r));
|
|
695
|
+
}
|
|
696
|
+
return (t) => v(t);
|
|
697
|
+
}
|
|
698
|
+
function Ze(n) {
|
|
699
|
+
if (!n)
|
|
700
|
+
return;
|
|
701
|
+
const e = /(-?\d+(?:\.\d+)?)\s*\.\.\s*(-?\d+(?:\.\d+)?)\s*->\s*(-?\d+(?:\.\d+)?)\s*\.\.\s*(-?\d+(?:\.\d+)?)/.exec(n);
|
|
702
|
+
if (!e)
|
|
703
|
+
return;
|
|
704
|
+
const [t, r, s, i] = e.slice(1).map((a) => Number.parseFloat(a));
|
|
705
|
+
if (![t, r, s, i].some((a) => !Number.isFinite(a)))
|
|
706
|
+
return { inStart: t, inEnd: r, outStart: s, outEnd: i };
|
|
707
|
+
}
|
|
708
|
+
class Qe {
|
|
709
|
+
bindingsByStyle = /* @__PURE__ */ new Map();
|
|
710
|
+
observer;
|
|
711
|
+
observeScheduled = !1;
|
|
712
|
+
pendingScanStyles = /* @__PURE__ */ new Set();
|
|
713
|
+
scanScheduled = !1;
|
|
714
|
+
elementStates = /* @__PURE__ */ new Map();
|
|
715
|
+
styleToElements = /* @__PURE__ */ new Map();
|
|
716
|
+
globalCleanups = /* @__PURE__ */ new Set();
|
|
717
|
+
registerStyle(e, t) {
|
|
718
|
+
if (!e)
|
|
719
|
+
return;
|
|
720
|
+
const r = this.parseMetadata(t);
|
|
721
|
+
if (!r) {
|
|
722
|
+
this.bindingsByStyle.delete(e), this.cleanupStyle(e);
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
this.bindingsByStyle.set(e, r), this.cleanupStyle(e), this.ensureObserver(), this.scheduleScan(e);
|
|
726
|
+
}
|
|
727
|
+
reset() {
|
|
728
|
+
for (const e of Array.from(this.globalCleanups))
|
|
729
|
+
try {
|
|
730
|
+
e();
|
|
731
|
+
} catch (t) {
|
|
732
|
+
console.warn("[MotionController] Failed to cleanup binding listener", t);
|
|
733
|
+
}
|
|
734
|
+
this.globalCleanups.clear(), this.elementStates.clear(), this.styleToElements.clear(), this.bindingsByStyle.clear(), this.pendingScanStyles.clear(), this.scanScheduled = !1, this.observer && (this.observer.disconnect(), this.observer = void 0);
|
|
735
|
+
}
|
|
736
|
+
parseMetadata(e) {
|
|
737
|
+
if (e)
|
|
738
|
+
try {
|
|
739
|
+
const r = (JSON.parse(e).motionBindings ?? []).map((s) => this.parseBinding(s)).filter((s) => s !== void 0);
|
|
740
|
+
return r.length === 0 ? void 0 : { bindings: r };
|
|
741
|
+
} catch (t) {
|
|
742
|
+
console.warn("[MotionController] Failed to parse motion metadata", t);
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
parseBinding(e) {
|
|
747
|
+
const t = e.source?.trim();
|
|
748
|
+
if (!t)
|
|
749
|
+
return;
|
|
750
|
+
const r = le(e.min) ?? 0, s = le(e.max), i = s === void 0 ? r + 100 : s, a = (e.clamp ?? "clamp").trim().toLowerCase(), l = !!e.reverse, u = Ke(e.ease), d = Ze(e.map), p = e.targetId?.trim() || void 0;
|
|
751
|
+
return Number.isNaN(r) || Number.isNaN(i) ? void 0 : {
|
|
752
|
+
source: t.toLowerCase(),
|
|
753
|
+
min: r,
|
|
754
|
+
max: i,
|
|
755
|
+
clamp: a === "freeze-start" || a === "freeze-end" || a === "unclamped" ? a : "clamp",
|
|
756
|
+
reverse: l,
|
|
757
|
+
ease: u,
|
|
758
|
+
map: d,
|
|
759
|
+
targetId: p
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
ensureObserver() {
|
|
763
|
+
if (typeof document > "u" || this.observer)
|
|
764
|
+
return;
|
|
765
|
+
const e = () => {
|
|
766
|
+
this.observer || typeof document > "u" || (this.observer = new MutationObserver((t) => this.handleMutations(t)), this.observer.observe(document.body, {
|
|
767
|
+
childList: !0,
|
|
768
|
+
subtree: !0,
|
|
769
|
+
attributes: !0,
|
|
770
|
+
attributeFilter: ["class"]
|
|
771
|
+
}));
|
|
772
|
+
};
|
|
773
|
+
document.readyState === "loading" ? this.observeScheduled || (this.observeScheduled = !0, document.addEventListener(
|
|
774
|
+
"DOMContentLoaded",
|
|
775
|
+
() => {
|
|
776
|
+
this.observeScheduled = !1, e();
|
|
777
|
+
},
|
|
778
|
+
{ once: !0 }
|
|
779
|
+
)) : e();
|
|
780
|
+
}
|
|
781
|
+
scheduleScan(e) {
|
|
782
|
+
if (typeof document > "u" || (this.pendingScanStyles.add(e), this.scanScheduled))
|
|
783
|
+
return;
|
|
784
|
+
const t = () => {
|
|
785
|
+
if (this.pendingScanStyles.size === 0) {
|
|
786
|
+
this.scanScheduled = !1;
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
const s = Array.from(this.pendingScanStyles);
|
|
790
|
+
this.pendingScanStyles.clear(), this.scanScheduled = !1;
|
|
791
|
+
for (const i of s)
|
|
792
|
+
this.scanExistingNodes(i);
|
|
793
|
+
}, r = () => {
|
|
794
|
+
this.scanScheduled = !0, typeof queueMicrotask == "function" ? queueMicrotask(t) : setTimeout(t, 0);
|
|
795
|
+
};
|
|
796
|
+
document.readyState === "loading" ? document.addEventListener(
|
|
797
|
+
"DOMContentLoaded",
|
|
798
|
+
() => {
|
|
799
|
+
r();
|
|
800
|
+
},
|
|
801
|
+
{ once: !0 }
|
|
802
|
+
) : r();
|
|
803
|
+
}
|
|
804
|
+
scanExistingNodes(e) {
|
|
805
|
+
const t = this.bindingsByStyle.get(e);
|
|
806
|
+
if (!t || typeof document > "u")
|
|
807
|
+
return;
|
|
808
|
+
const r = `.${ue(e)}`;
|
|
809
|
+
document.querySelectorAll(r).forEach((i) => this.applyStyleToElement(i, e, t));
|
|
810
|
+
}
|
|
811
|
+
applyStyleToElement(e, t, r) {
|
|
812
|
+
this.ensureStyleState(e, t) && this.attachBindings(e, t, r);
|
|
813
|
+
}
|
|
814
|
+
ensureStyleState(e, t) {
|
|
815
|
+
let r = this.elementStates.get(e);
|
|
816
|
+
if (r || (r = /* @__PURE__ */ new Map(), this.elementStates.set(e, r)), r.has(t))
|
|
817
|
+
return !1;
|
|
818
|
+
r.set(t, /* @__PURE__ */ new Set());
|
|
819
|
+
let s = this.styleToElements.get(t);
|
|
820
|
+
return s || (s = /* @__PURE__ */ new Set(), this.styleToElements.set(t, s)), s.add(e), !0;
|
|
821
|
+
}
|
|
822
|
+
attachBindings(e, t, r) {
|
|
823
|
+
for (const s of r.bindings)
|
|
824
|
+
this.attachBinding(e, t, s);
|
|
825
|
+
}
|
|
826
|
+
attachBinding(e, t, r) {
|
|
827
|
+
switch (r.source) {
|
|
828
|
+
case "scrolly":
|
|
829
|
+
this.attachScrollBinding(e, t, r);
|
|
830
|
+
break;
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
attachScrollBinding(e, t, r) {
|
|
834
|
+
const s = this.resolveScrollContainer(e, r);
|
|
835
|
+
if (!s)
|
|
836
|
+
return;
|
|
837
|
+
const i = () => {
|
|
838
|
+
this.applyBindingValues(e, r, s.scrollTop);
|
|
839
|
+
};
|
|
840
|
+
i();
|
|
841
|
+
const a = new AbortController();
|
|
842
|
+
s.addEventListener("scroll", i, { passive: !0, signal: a.signal }), this.registerCleanup(e, t, () => a.abort());
|
|
843
|
+
const l = () => i();
|
|
844
|
+
window.addEventListener("resize", l), this.registerCleanup(e, t, () => window.removeEventListener("resize", l));
|
|
845
|
+
}
|
|
846
|
+
resolveScrollContainer(e, t) {
|
|
847
|
+
if (t.targetId) {
|
|
848
|
+
const r = `[data-ikon-motion-source="${ue(t.targetId)}"]`, s = typeof document < "u" ? document.querySelector(r) : null;
|
|
849
|
+
if (s)
|
|
850
|
+
return s;
|
|
851
|
+
}
|
|
852
|
+
return e.closest('[data-ikon-container-type="scroll-view"]');
|
|
853
|
+
}
|
|
854
|
+
applyBindingValues(e, t, r) {
|
|
855
|
+
const s = t.max - t.min, i = s === 0 ? r > t.min ? 1 : 0 : (r - t.min) / s;
|
|
856
|
+
let a = this.applyClamp(i, t.clamp);
|
|
857
|
+
t.reverse && (a = 1 - a);
|
|
858
|
+
const l = t.ease(a), u = Number.isFinite(l) ? l : 0, d = u * 100;
|
|
859
|
+
if (e.style.setProperty("--tw-motion-bind-source-value", `${r}`), e.style.setProperty("--tw-motion-bind-progress-ratio", `${u}`), e.style.setProperty("--tw-motion-bind-progress", `${d}`), t.map) {
|
|
860
|
+
const p = this.applyMap(d, t.map);
|
|
861
|
+
p !== void 0 && e.style.setProperty("--tw-motion-bind-value", `${p}`);
|
|
862
|
+
} else
|
|
863
|
+
e.style.removeProperty("--tw-motion-bind-value");
|
|
864
|
+
}
|
|
865
|
+
applyClamp(e, t) {
|
|
866
|
+
if (!Number.isFinite(e))
|
|
867
|
+
return 0;
|
|
868
|
+
switch (t) {
|
|
869
|
+
case "freeze-start":
|
|
870
|
+
return e < 0 ? 0 : e;
|
|
871
|
+
case "freeze-end":
|
|
872
|
+
return e > 1 ? 1 : e;
|
|
873
|
+
case "unclamped":
|
|
874
|
+
return e;
|
|
875
|
+
default:
|
|
876
|
+
return v(e);
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
applyMap(e, t) {
|
|
880
|
+
const r = t.inEnd - t.inStart;
|
|
881
|
+
if (r === 0)
|
|
882
|
+
return t.outEnd;
|
|
883
|
+
const s = (e - t.inStart) / r;
|
|
884
|
+
return t.outStart + s * (t.outEnd - t.outStart);
|
|
885
|
+
}
|
|
886
|
+
registerCleanup(e, t, r) {
|
|
887
|
+
const i = this.elementStates.get(e)?.get(t);
|
|
888
|
+
i && (i.add(r), this.globalCleanups.add(r));
|
|
889
|
+
}
|
|
890
|
+
cleanupStyle(e) {
|
|
891
|
+
const t = this.styleToElements.get(e);
|
|
892
|
+
if (!t)
|
|
893
|
+
return;
|
|
894
|
+
const r = Array.from(t);
|
|
895
|
+
for (const s of r)
|
|
896
|
+
this.cleanupElementStyle(s, e);
|
|
897
|
+
this.styleToElements.delete(e);
|
|
898
|
+
}
|
|
899
|
+
cleanupElement(e) {
|
|
900
|
+
const t = this.elementStates.get(e);
|
|
901
|
+
if (!t)
|
|
902
|
+
return;
|
|
903
|
+
const r = Array.from(t.keys());
|
|
904
|
+
for (const s of r)
|
|
905
|
+
this.cleanupElementStyle(e, s);
|
|
906
|
+
}
|
|
907
|
+
cleanupElementStyle(e, t) {
|
|
908
|
+
const r = this.elementStates.get(e), s = r?.get(t);
|
|
909
|
+
if (!s)
|
|
910
|
+
return;
|
|
911
|
+
for (const a of s) {
|
|
912
|
+
try {
|
|
913
|
+
a();
|
|
914
|
+
} catch (l) {
|
|
915
|
+
console.warn("[MotionController] Failed to cleanup listener", l);
|
|
916
|
+
}
|
|
917
|
+
this.globalCleanups.delete(a);
|
|
918
|
+
}
|
|
919
|
+
s.clear(), r.delete(t);
|
|
920
|
+
const i = this.styleToElements.get(t);
|
|
921
|
+
i && (i.delete(e), i.size === 0 && this.styleToElements.delete(t)), r.size === 0 && (this.elementStates.delete(e), this.clearBindingProperties(e));
|
|
922
|
+
}
|
|
923
|
+
clearBindingProperties(e) {
|
|
924
|
+
e.style.removeProperty("--tw-motion-bind-source-value"), e.style.removeProperty("--tw-motion-bind-progress"), e.style.removeProperty("--tw-motion-bind-progress-ratio"), e.style.removeProperty("--tw-motion-bind-value");
|
|
925
|
+
}
|
|
926
|
+
handleMutations(e) {
|
|
927
|
+
for (const t of e)
|
|
928
|
+
t.type === "childList" ? (t.addedNodes.forEach((r) => this.scanNode(r)), t.removedNodes.forEach((r) => this.cleanupNode(r))) : t.type === "attributes" && t.target instanceof HTMLElement && this.handleClassMutation(t.target);
|
|
929
|
+
}
|
|
930
|
+
handleClassMutation(e) {
|
|
931
|
+
const t = this.elementStates.get(e);
|
|
932
|
+
if (!t) {
|
|
933
|
+
this.processElement(e);
|
|
934
|
+
return;
|
|
935
|
+
}
|
|
936
|
+
const r = new Set(Array.from(e.classList)), s = Array.from(t.keys());
|
|
937
|
+
for (const i of s)
|
|
938
|
+
r.has(i) || this.cleanupElementStyle(e, i);
|
|
939
|
+
this.processElement(e);
|
|
940
|
+
}
|
|
941
|
+
scanNode(e) {
|
|
942
|
+
if (!(e instanceof HTMLElement))
|
|
943
|
+
return;
|
|
944
|
+
this.processElement(e), e.querySelectorAll("[class]").forEach((r) => this.processElement(r));
|
|
945
|
+
}
|
|
946
|
+
cleanupNode(e) {
|
|
947
|
+
if (!(e instanceof HTMLElement))
|
|
948
|
+
return;
|
|
949
|
+
this.cleanupElement(e), e.querySelectorAll("[class]").forEach((r) => this.cleanupElement(r));
|
|
950
|
+
}
|
|
951
|
+
processElement(e) {
|
|
952
|
+
if (!(!e.classList || e.classList.length === 0))
|
|
953
|
+
for (const t of Array.from(e.classList)) {
|
|
954
|
+
const r = this.bindingsByStyle.get(t);
|
|
955
|
+
r && this.ensureStyleState(e, t) && this.attachBindings(e, t, r);
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
const fe = new Qe(), W = "ikon-ds";
|
|
960
|
+
function wt(n) {
|
|
961
|
+
const e = re(({ styleId: r, css: s, common: i }) => {
|
|
962
|
+
if (!r || typeof document > "u") return;
|
|
963
|
+
let a = document.getElementById(W);
|
|
964
|
+
a || (a = document.createElement("style"), a.id = W, document.head.appendChild(a)), s && (a.innerHTML += s), fe.registerStyle(r, i);
|
|
965
|
+
}, []), t = re(() => {
|
|
966
|
+
typeof document < "u" && document.getElementById(W)?.remove(), fe.reset();
|
|
967
|
+
}, []);
|
|
968
|
+
return ne(() => {
|
|
969
|
+
if (!n) return;
|
|
970
|
+
for (const s of n.getUiStyles())
|
|
971
|
+
e(s);
|
|
972
|
+
const r = n.subscribeToStyles(e);
|
|
973
|
+
return () => {
|
|
974
|
+
r?.(), t();
|
|
975
|
+
};
|
|
976
|
+
}, [n, t, e]), ne(() => () => t(), [t]), { setStyle: e, reset: t };
|
|
977
|
+
}
|
|
978
|
+
var et = typeof global == "object" && global && global.Object === Object && global, tt = typeof self == "object" && self && self.Object === Object && self, rt = et || tt || Function("return this")(), B = rt.Symbol, ye = Object.prototype, nt = ye.hasOwnProperty, st = ye.toString, U = B ? B.toStringTag : void 0;
|
|
979
|
+
function ot(n) {
|
|
980
|
+
var e = nt.call(n, U), t = n[U];
|
|
981
|
+
try {
|
|
982
|
+
n[U] = void 0;
|
|
983
|
+
var r = !0;
|
|
984
|
+
} catch {
|
|
985
|
+
}
|
|
986
|
+
var s = st.call(n);
|
|
987
|
+
return r && (e ? n[U] = t : delete n[U]), s;
|
|
988
|
+
}
|
|
989
|
+
var it = Object.prototype, at = it.toString;
|
|
990
|
+
function ct(n) {
|
|
991
|
+
return at.call(n);
|
|
992
|
+
}
|
|
993
|
+
var lt = "[object Null]", ut = "[object Undefined]", he = B ? B.toStringTag : void 0;
|
|
994
|
+
function dt(n) {
|
|
995
|
+
return n == null ? n === void 0 ? ut : lt : he && he in Object(n) ? ot(n) : ct(n);
|
|
996
|
+
}
|
|
997
|
+
function ft(n) {
|
|
998
|
+
return n != null && typeof n == "object";
|
|
999
|
+
}
|
|
1000
|
+
var ht = Array.isArray, pt = "[object String]";
|
|
1001
|
+
function mt(n) {
|
|
1002
|
+
return typeof n == "string" || !ht(n) && ft(n) && dt(n) == pt;
|
|
1003
|
+
}
|
|
1004
|
+
const pe = "ikonUiModules";
|
|
1005
|
+
function J(n) {
|
|
1006
|
+
return typeof n == "object" && n !== null && !Array.isArray(n);
|
|
1007
|
+
}
|
|
1008
|
+
function yt(n) {
|
|
1009
|
+
if (!Array.isArray(n))
|
|
1010
|
+
return;
|
|
1011
|
+
const e = /* @__PURE__ */ new Set();
|
|
1012
|
+
for (const t of n) {
|
|
1013
|
+
if (!mt(t)) continue;
|
|
1014
|
+
const r = t.trim();
|
|
1015
|
+
r && (e.has(r) || e.add(r));
|
|
1016
|
+
}
|
|
1017
|
+
return Array.from(e);
|
|
1018
|
+
}
|
|
1019
|
+
function Nt(n, e) {
|
|
1020
|
+
if (n === e)
|
|
1021
|
+
return !0;
|
|
1022
|
+
if (!n || !e)
|
|
1023
|
+
return !n && !e;
|
|
1024
|
+
if (n.length !== e.length)
|
|
1025
|
+
return !1;
|
|
1026
|
+
for (let t = 0; t < n.length; t += 1)
|
|
1027
|
+
if (n[t] !== e[t])
|
|
1028
|
+
return !1;
|
|
1029
|
+
return !0;
|
|
1030
|
+
}
|
|
1031
|
+
function St(n) {
|
|
1032
|
+
if (!(!J(n) || !Object.prototype.hasOwnProperty.call(n, pe)))
|
|
1033
|
+
return yt(n[pe]);
|
|
1034
|
+
}
|
|
1035
|
+
function Ot(...n) {
|
|
1036
|
+
for (const e of n) {
|
|
1037
|
+
const t = St(e);
|
|
1038
|
+
if (t !== void 0)
|
|
1039
|
+
return t;
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
function kt(n) {
|
|
1043
|
+
if (!J(n))
|
|
1044
|
+
return;
|
|
1045
|
+
const e = n, t = Object.keys(e).find((u) => u.toLowerCase() === "modules");
|
|
1046
|
+
if (!t)
|
|
1047
|
+
return;
|
|
1048
|
+
const r = e[t];
|
|
1049
|
+
if (r === null)
|
|
1050
|
+
return { resetToDefault: !0 };
|
|
1051
|
+
if (!Array.isArray(r))
|
|
1052
|
+
return;
|
|
1053
|
+
const s = [], i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set();
|
|
1054
|
+
for (const u of r) {
|
|
1055
|
+
if (typeof u == "string") {
|
|
1056
|
+
const b = u.trim();
|
|
1057
|
+
if (!b || a.has(b))
|
|
1058
|
+
continue;
|
|
1059
|
+
s.push(b), a.add(b);
|
|
1060
|
+
continue;
|
|
1061
|
+
}
|
|
1062
|
+
if (!J(u))
|
|
1063
|
+
continue;
|
|
1064
|
+
const d = u, p = Object.keys(d).find((b) => b.toLowerCase() === "name");
|
|
1065
|
+
if (!p)
|
|
1066
|
+
continue;
|
|
1067
|
+
const E = d[p];
|
|
1068
|
+
if (typeof E != "string")
|
|
1069
|
+
continue;
|
|
1070
|
+
const T = E.trim();
|
|
1071
|
+
if (!T)
|
|
1072
|
+
continue;
|
|
1073
|
+
const O = Object.keys(d).find((b) => b.toLowerCase() === "javascript"), _ = O ? d[O] : void 0;
|
|
1074
|
+
typeof _ == "string" && i.set(T, _), a.has(T) || (s.push(T), a.add(T));
|
|
1075
|
+
}
|
|
1076
|
+
if (!s.length && i.size === 0)
|
|
1077
|
+
return { modules: [] };
|
|
1078
|
+
const l = Array.from(i.entries()).map(([u, d]) => ({
|
|
1079
|
+
name: u,
|
|
1080
|
+
javascript: d
|
|
1081
|
+
}));
|
|
1082
|
+
return l.length > 0 ? { modules: s, inlineModules: l } : { modules: s };
|
|
1083
|
+
}
|
|
1084
|
+
export {
|
|
1085
|
+
De as IKON_UI_BASE_MODULE,
|
|
1086
|
+
V as IKON_UI_STREAM_CATEGORY,
|
|
1087
|
+
Rt as IkonUi,
|
|
1088
|
+
Ve as IkonUiRegistry,
|
|
1089
|
+
Tt as IkonUiSurface,
|
|
1090
|
+
Be as UiComponentRegistry,
|
|
1091
|
+
ze as UiRenderer,
|
|
1092
|
+
Mt as UiStreamStore,
|
|
1093
|
+
Nt as areIkonUiModuleListsEqual,
|
|
1094
|
+
qe as createBaseResolvers,
|
|
1095
|
+
Et as createComponentLibrary,
|
|
1096
|
+
Ct as createIkonUiRegistry,
|
|
1097
|
+
Fe as isIkonUiCategoryMatch,
|
|
1098
|
+
Ye as loadBaseModule,
|
|
1099
|
+
yt as normalizeIkonUiModuleList,
|
|
1100
|
+
kt as parseIkonUiInitPayload,
|
|
1101
|
+
St as readIkonUiModules,
|
|
1102
|
+
Ot as readIkonUiModulesFromSources,
|
|
1103
|
+
We as registerBaseModule,
|
|
1104
|
+
wt as useIkonStyles,
|
|
1105
|
+
je as useUiStore
|
|
1106
|
+
};
|
package/modules.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type IkonUiModuleList = readonly string[];
|
|
2
|
+
export interface IkonUiInitModulePayload {
|
|
3
|
+
name: string;
|
|
4
|
+
javascript: string;
|
|
5
|
+
}
|
|
6
|
+
export interface IkonUiInitInstruction {
|
|
7
|
+
modules?: string[];
|
|
8
|
+
inlineModules?: IkonUiInitModulePayload[];
|
|
9
|
+
resetToDefault?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function normalizeIkonUiModuleList(value: unknown): string[] | undefined;
|
|
12
|
+
export declare function areIkonUiModuleListsEqual(left: IkonUiModuleList | undefined, right: IkonUiModuleList | undefined): boolean;
|
|
13
|
+
export declare function readIkonUiModules(source: unknown): string[] | undefined;
|
|
14
|
+
export declare function readIkonUiModulesFromSources(...sources: unknown[]): string[] | undefined;
|
|
15
|
+
export declare function parseIkonUiInitPayload(payload: unknown): IkonUiInitInstruction | undefined;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { UiStylePayload } from '../../../sdk-ui/src/index.ts';
|
|
2
|
+
declare class MotionController {
|
|
3
|
+
private bindingsByStyle;
|
|
4
|
+
private observer?;
|
|
5
|
+
private observeScheduled;
|
|
6
|
+
private pendingScanStyles;
|
|
7
|
+
private scanScheduled;
|
|
8
|
+
private elementStates;
|
|
9
|
+
private styleToElements;
|
|
10
|
+
private globalCleanups;
|
|
11
|
+
registerStyle(styleId: string, payload?: UiStylePayload['common']): void;
|
|
12
|
+
reset(): void;
|
|
13
|
+
private parseMetadata;
|
|
14
|
+
private parseBinding;
|
|
15
|
+
private ensureObserver;
|
|
16
|
+
private scheduleScan;
|
|
17
|
+
private scanExistingNodes;
|
|
18
|
+
private applyStyleToElement;
|
|
19
|
+
private ensureStyleState;
|
|
20
|
+
private attachBindings;
|
|
21
|
+
private attachBinding;
|
|
22
|
+
private attachScrollBinding;
|
|
23
|
+
private resolveScrollContainer;
|
|
24
|
+
private applyBindingValues;
|
|
25
|
+
private applyClamp;
|
|
26
|
+
private applyMap;
|
|
27
|
+
private registerCleanup;
|
|
28
|
+
private cleanupStyle;
|
|
29
|
+
private cleanupElement;
|
|
30
|
+
private cleanupElementStyle;
|
|
31
|
+
private clearBindingProperties;
|
|
32
|
+
private handleMutations;
|
|
33
|
+
private handleClassMutation;
|
|
34
|
+
private scanNode;
|
|
35
|
+
private cleanupNode;
|
|
36
|
+
private processElement;
|
|
37
|
+
}
|
|
38
|
+
export declare const motionController: MotionController;
|
|
39
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ikonai/sdk-react-ui",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"types": "./index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./index.js",
|
|
10
|
+
"types": "./index.d.ts"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"peerDependencies": {
|
|
14
|
+
"@ikonai/sdk": "*",
|
|
15
|
+
"@ikonai/sdk-ui": "*",
|
|
16
|
+
"react": "*",
|
|
17
|
+
"react-dom": "*"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { UiComponentLibrary, UiComponentRenderer, UiElementNode } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Minimal, fixed registry of UI renderers keyed by element type.
|
|
4
|
+
*
|
|
5
|
+
* Use this when you have a known, static set of renderers (e.g. embedding
|
|
6
|
+
* your own component library) and do not need the dynamic module-loading
|
|
7
|
+
* capabilities of `IkonUiRegistry`.
|
|
8
|
+
*
|
|
9
|
+
+ Example:
|
|
10
|
+
* ```ts
|
|
11
|
+
* const library = createComponentLibrary({
|
|
12
|
+
* 'common.div': myDivRenderer,
|
|
13
|
+
* 'custom.card': myCardRenderer,
|
|
14
|
+
* });
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare class UiComponentRegistry implements UiComponentLibrary {
|
|
18
|
+
private fallback?;
|
|
19
|
+
private readonly renderers;
|
|
20
|
+
constructor(entries?: Iterable<[string, UiComponentRenderer]>, fallback?: UiComponentRenderer | undefined);
|
|
21
|
+
register(type: string, renderer: UiComponentRenderer): void;
|
|
22
|
+
setFallback(renderer: UiComponentRenderer | undefined): void;
|
|
23
|
+
resolve(node: UiElementNode): UiComponentRenderer | undefined;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Convenience factory to build a `UiComponentRegistry` from a plain object.
|
|
27
|
+
*
|
|
28
|
+
* Prefer this when you already have a simple mapping of element type to
|
|
29
|
+
* renderer. If you need dynamic module loading, use `IkonUiRegistry` instead.
|
|
30
|
+
*/
|
|
31
|
+
export declare function createComponentLibrary(components: Record<string, UiComponentRenderer>, fallback?: UiComponentRenderer): UiComponentLibrary;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { UiRenderer, type UiRendererProps } from './ui-renderer';
|
|
2
|
+
export { UiComponentRegistry, createComponentLibrary, } from './component-library';
|
|
3
|
+
export { useUiStore } from './use-ui-store';
|
|
4
|
+
export type { UiComponentRenderer, UiComponentLibrary, UiElementNode, UiRenderContext, UiComponentRendererProps, ParsedUiUpdate, UiSnapshot, UiFullSnapshot, UiDiffSnapshot, UiElementDiffNode, TextDelta, UiElementProps, UiUpdateType, UiStoreSnapshot, UiOptimisticPatchState, } from './types';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { UIPayload } from '../../../platform-generated/src/index.ts';
|
|
2
|
+
import { UiElementNode } from '../../../sdk-ui/src/index.ts';
|
|
3
|
+
import { ComponentType, ReactNode } from 'react';
|
|
4
|
+
export { type UiUpdateType, type UiElementProps, type UiElementNode, type UiElementDiffNode, type UiSnapshot, type UiFullSnapshot, type UiDiffSnapshot, type UiSnapshotMetadata, type UiOptimisticPatchMetadata, type UiOptimisticReconcileMetadata, type TextDelta, type ParsedUiUpdate, type UiStoreSnapshot, type UiOptimisticPatchState, } from '../../../sdk-ui/src/index.ts';
|
|
5
|
+
export interface UiRenderContext {
|
|
6
|
+
getPayload(key: string): UIPayload | undefined;
|
|
7
|
+
renderChildren(nodes: readonly UiElementNode[]): ReactNode;
|
|
8
|
+
renderContainer(containerId: string): ReactNode;
|
|
9
|
+
dispatchAction(actionId: string, payload?: unknown): void;
|
|
10
|
+
}
|
|
11
|
+
export interface UiComponentRendererProps {
|
|
12
|
+
readonly node: UiElementNode;
|
|
13
|
+
readonly context: UiRenderContext;
|
|
14
|
+
readonly children: readonly ReactNode[];
|
|
15
|
+
readonly className?: string;
|
|
16
|
+
readonly styleIds: readonly string[];
|
|
17
|
+
}
|
|
18
|
+
export type UiComponentRenderer = ComponentType<UiComponentRendererProps>;
|
|
19
|
+
export interface UiComponentLibrary {
|
|
20
|
+
resolve(node: UiElementNode): UiComponentRenderer | undefined;
|
|
21
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UiStreamStore } from '../../../sdk-ui/src/index.ts';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { UiComponentLibrary } from './types';
|
|
4
|
+
export interface UiRendererProps {
|
|
5
|
+
readonly store: UiStreamStore;
|
|
6
|
+
readonly library: UiComponentLibrary;
|
|
7
|
+
readonly containerId?: string;
|
|
8
|
+
readonly emptyFallback?: ReactNode;
|
|
9
|
+
readonly onAction?: (actionId: string, payloadJson: string) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function UiRenderer({ store, library, containerId, emptyFallback, onAction }: UiRendererProps): ReactNode;
|
package/surface.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { UIStreamCategories } from '../../platform-generated/src/index.ts';
|
|
2
|
+
import { UiStreamStore } from '../../sdk-ui/src/index.ts';
|
|
3
|
+
import { UiComponentLibrary } from './renderer';
|
|
4
|
+
export declare const IKON_UI_STREAM_CATEGORY: "ikon-ui";
|
|
5
|
+
export type IkonUiCategory = UIStreamCategories | typeof IKON_UI_STREAM_CATEGORY | (string & {});
|
|
6
|
+
export interface IkonUiStoreEntry {
|
|
7
|
+
category: IkonUiCategory;
|
|
8
|
+
store: UiStreamStore;
|
|
9
|
+
}
|
|
10
|
+
export declare function isIkonUiCategoryMatch(entryCategory: IkonUiCategory, targetCategory: IkonUiCategory): boolean;
|
|
11
|
+
export interface IkonUiSurfaceProps {
|
|
12
|
+
stores: ReadonlyMap<string, IkonUiStoreEntry>;
|
|
13
|
+
library: UiComponentLibrary;
|
|
14
|
+
category?: IkonUiCategory;
|
|
15
|
+
version?: number;
|
|
16
|
+
onAction?: (actionId: string, payload?: string) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare function IkonUiSurface({ stores, library, category, version, onAction }: IkonUiSurfaceProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UiStyleListener, UiStylePayload } from '../../sdk-ui/src/index.ts';
|
|
2
|
+
export interface IkonUiStyleSource {
|
|
3
|
+
getUiStyles(): Iterable<UiStylePayload> | readonly UiStylePayload[];
|
|
4
|
+
subscribeToStyles(listener: UiStyleListener): () => void;
|
|
5
|
+
}
|
|
6
|
+
export declare function useIkonStyles(source?: IkonUiStyleSource | null): {
|
|
7
|
+
setStyle: ({ styleId, css, common }: UiStylePayload) => void;
|
|
8
|
+
reset: () => void;
|
|
9
|
+
};
|