@almadar/ui 1.0.30 → 1.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/KaTeX_AMS-Regular-CYEKBG2K.woff +0 -0
- package/dist/KaTeX_AMS-Regular-JKX5W2C4.ttf +0 -0
- package/dist/KaTeX_AMS-Regular-U6PRYMIZ.woff2 +0 -0
- package/dist/KaTeX_Caligraphic-Bold-5QL5CMTE.woff2 +0 -0
- package/dist/KaTeX_Caligraphic-Bold-WZ3QSGD3.woff +0 -0
- package/dist/KaTeX_Caligraphic-Bold-ZTS3R3HK.ttf +0 -0
- package/dist/KaTeX_Caligraphic-Regular-3LKEU76G.woff +0 -0
- package/dist/KaTeX_Caligraphic-Regular-A7XRTZ5Q.ttf +0 -0
- package/dist/KaTeX_Caligraphic-Regular-KX5MEWCF.woff2 +0 -0
- package/dist/KaTeX_Fraktur-Bold-2QVFK6NQ.woff2 +0 -0
- package/dist/KaTeX_Fraktur-Bold-T4SWXBMT.woff +0 -0
- package/dist/KaTeX_Fraktur-Bold-WGHVTYOR.ttf +0 -0
- package/dist/KaTeX_Fraktur-Regular-2PEIFJSJ.woff2 +0 -0
- package/dist/KaTeX_Fraktur-Regular-5U4OPH2X.ttf +0 -0
- package/dist/KaTeX_Fraktur-Regular-PQMHCIK6.woff +0 -0
- package/dist/KaTeX_Main-Bold-2GA4IZIN.woff +0 -0
- package/dist/KaTeX_Main-Bold-W5FBVCZM.ttf +0 -0
- package/dist/KaTeX_Main-Bold-YP5VVQRP.woff2 +0 -0
- package/dist/KaTeX_Main-BoldItalic-4P4C7HJH.woff +0 -0
- package/dist/KaTeX_Main-BoldItalic-N4V3DX7S.woff2 +0 -0
- package/dist/KaTeX_Main-BoldItalic-ODMLBJJQ.ttf +0 -0
- package/dist/KaTeX_Main-Italic-I43T2HSR.ttf +0 -0
- package/dist/KaTeX_Main-Italic-RELBIK7M.woff2 +0 -0
- package/dist/KaTeX_Main-Italic-SASNQFN2.woff +0 -0
- package/dist/KaTeX_Main-Regular-ARRPAO67.woff2 +0 -0
- package/dist/KaTeX_Main-Regular-P5I74A2A.woff +0 -0
- package/dist/KaTeX_Main-Regular-W74P5G27.ttf +0 -0
- package/dist/KaTeX_Math-BoldItalic-6EBV3DK5.woff +0 -0
- package/dist/KaTeX_Math-BoldItalic-K4WTGH3J.woff2 +0 -0
- package/dist/KaTeX_Math-BoldItalic-VB447A4D.ttf +0 -0
- package/dist/KaTeX_Math-Italic-6KGCHLFN.woff2 +0 -0
- package/dist/KaTeX_Math-Italic-KKK3USB2.woff +0 -0
- package/dist/KaTeX_Math-Italic-SON4MRCA.ttf +0 -0
- package/dist/KaTeX_SansSerif-Bold-RRNVJFFW.woff2 +0 -0
- package/dist/KaTeX_SansSerif-Bold-STQ6RXC7.ttf +0 -0
- package/dist/KaTeX_SansSerif-Bold-X5M5EMOD.woff +0 -0
- package/dist/KaTeX_SansSerif-Italic-HMPFTM52.woff2 +0 -0
- package/dist/KaTeX_SansSerif-Italic-PSN4QKYX.woff +0 -0
- package/dist/KaTeX_SansSerif-Italic-WTBAZBGY.ttf +0 -0
- package/dist/KaTeX_SansSerif-Regular-2TL3USAE.ttf +0 -0
- package/dist/KaTeX_SansSerif-Regular-OQCII6EP.woff +0 -0
- package/dist/KaTeX_SansSerif-Regular-XIQ62X4E.woff2 +0 -0
- package/dist/KaTeX_Script-Regular-72OLXYNA.ttf +0 -0
- package/dist/KaTeX_Script-Regular-A5IFOEBS.woff +0 -0
- package/dist/KaTeX_Script-Regular-APUWIHLP.woff2 +0 -0
- package/dist/KaTeX_Size1-Regular-4HRHTS65.woff +0 -0
- package/dist/KaTeX_Size1-Regular-5LRUTBFT.woff2 +0 -0
- package/dist/KaTeX_Size1-Regular-7K6AASVL.ttf +0 -0
- package/dist/KaTeX_Size2-Regular-222HN3GT.ttf +0 -0
- package/dist/KaTeX_Size2-Regular-K5ZHAIS6.woff +0 -0
- package/dist/KaTeX_Size2-Regular-LELKET5D.woff2 +0 -0
- package/dist/KaTeX_Size3-Regular-TLFPAHDE.woff +0 -0
- package/dist/KaTeX_Size3-Regular-UFCO6WCA.ttf +0 -0
- package/dist/KaTeX_Size3-Regular-WQRQ47UD.woff2 +0 -0
- package/dist/KaTeX_Size4-Regular-7PGNVPQK.ttf +0 -0
- package/dist/KaTeX_Size4-Regular-CDMV7U5C.woff2 +0 -0
- package/dist/KaTeX_Size4-Regular-PKMWZHNC.woff +0 -0
- package/dist/KaTeX_Typewriter-Regular-3F5K6SQ6.ttf +0 -0
- package/dist/KaTeX_Typewriter-Regular-MJMFSK64.woff +0 -0
- package/dist/KaTeX_Typewriter-Regular-VBYJ4NRC.woff2 +0 -0
- package/dist/{ThemeContext-lI5bo85E.d.ts → ThemeContext-D9xUORq5.d.ts} +2 -0
- package/dist/chunk-45CTDYBT.js +174 -0
- package/dist/{chunk-4UFNDD6B.js → chunk-BTXQJGFB.js} +41 -8
- package/dist/chunk-N6DJVKZ6.js +747 -0
- package/dist/chunk-PE2H3NAW.js +383 -0
- package/dist/{chunk-7IYF4RUG.js → chunk-RFD6G3ZR.js} +23 -68
- package/dist/chunk-UCXZS2YJ.js +9501 -0
- package/dist/chunk-YXZM3WCF.js +222 -0
- package/dist/cn-BoBXsxuX.d.ts +194 -0
- package/dist/components/index.css +1154 -0
- package/dist/components/index.d.ts +1082 -673
- package/dist/components/index.js +8935 -16486
- package/dist/components/organisms/game/three/index.css +315 -0
- package/dist/components/organisms/game/three/index.d.ts +1162 -0
- package/dist/components/organisms/game/three/index.js +2378 -0
- package/dist/context/index.d.ts +4 -4
- package/dist/context/index.js +2 -3
- package/dist/{event-bus-types-8-cjyMxw.d.ts → event-bus-types-CjJduURa.d.ts} +8 -0
- package/dist/hooks/index.d.ts +120 -106
- package/dist/hooks/index.js +4 -3
- package/dist/isometric-ynNHVPZx.d.ts +111 -0
- package/dist/lib/index.d.ts +117 -153
- package/dist/lib/index.js +4 -683
- package/dist/providers/index.css +1154 -0
- package/dist/providers/index.d.ts +84 -4
- package/dist/providers/index.js +165 -8
- package/dist/{useUISlots-mnggE9X9.d.ts → useUISlots-D0mttBSP.d.ts} +0 -20
- package/package.json +32 -11
- package/dist/chunk-HY5EFCOK.js +0 -419
- package/dist/chunk-W5YTXLXL.js +0 -29
- package/dist/cn-mqkxz8Sd.d.ts +0 -9
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
import { useEventBus } from './chunk-YXZM3WCF.js';
|
|
2
|
+
import React, { createContext, useContext, useState, useMemo, useCallback, useEffect } from 'react';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
var I18nContext = createContext({
|
|
6
|
+
locale: "en",
|
|
7
|
+
direction: "ltr",
|
|
8
|
+
t: (key) => key
|
|
9
|
+
// passthrough fallback
|
|
10
|
+
});
|
|
11
|
+
I18nContext.displayName = "I18nContext";
|
|
12
|
+
var I18nProvider = I18nContext.Provider;
|
|
13
|
+
function useTranslate() {
|
|
14
|
+
return useContext(I18nContext);
|
|
15
|
+
}
|
|
16
|
+
function createTranslate(messages) {
|
|
17
|
+
return (key, params) => {
|
|
18
|
+
let msg = messages[key] ?? key;
|
|
19
|
+
if (params) {
|
|
20
|
+
for (const [k, v] of Object.entries(params)) {
|
|
21
|
+
msg = msg.split(`{{${k}}}`).join(String(v));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return msg;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
var queryStores = /* @__PURE__ */ new Map();
|
|
28
|
+
function getOrCreateStore(query) {
|
|
29
|
+
if (!queryStores.has(query)) {
|
|
30
|
+
queryStores.set(query, {
|
|
31
|
+
search: "",
|
|
32
|
+
filters: {},
|
|
33
|
+
sortField: void 0,
|
|
34
|
+
sortDirection: void 0,
|
|
35
|
+
listeners: /* @__PURE__ */ new Set()
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return queryStores.get(query);
|
|
39
|
+
}
|
|
40
|
+
function useQuerySingleton(query) {
|
|
41
|
+
const [, forceUpdate] = useState({});
|
|
42
|
+
if (!query) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const store = useMemo(() => getOrCreateStore(query), [query]);
|
|
46
|
+
useMemo(() => {
|
|
47
|
+
const listener = () => forceUpdate({});
|
|
48
|
+
store.listeners.add(listener);
|
|
49
|
+
return () => {
|
|
50
|
+
store.listeners.delete(listener);
|
|
51
|
+
};
|
|
52
|
+
}, [store]);
|
|
53
|
+
const notifyListeners = useCallback(() => {
|
|
54
|
+
store.listeners.forEach((listener) => listener());
|
|
55
|
+
}, [store]);
|
|
56
|
+
const setSearch = useCallback((value) => {
|
|
57
|
+
store.search = value;
|
|
58
|
+
notifyListeners();
|
|
59
|
+
}, [store, notifyListeners]);
|
|
60
|
+
const setFilter = useCallback((key, value) => {
|
|
61
|
+
store.filters = { ...store.filters, [key]: value };
|
|
62
|
+
notifyListeners();
|
|
63
|
+
}, [store, notifyListeners]);
|
|
64
|
+
const clearFilters = useCallback(() => {
|
|
65
|
+
store.filters = {};
|
|
66
|
+
store.search = "";
|
|
67
|
+
notifyListeners();
|
|
68
|
+
}, [store, notifyListeners]);
|
|
69
|
+
const setSort = useCallback((field, direction) => {
|
|
70
|
+
store.sortField = field;
|
|
71
|
+
store.sortDirection = direction;
|
|
72
|
+
notifyListeners();
|
|
73
|
+
}, [store, notifyListeners]);
|
|
74
|
+
return {
|
|
75
|
+
search: store.search,
|
|
76
|
+
setSearch,
|
|
77
|
+
filters: store.filters,
|
|
78
|
+
setFilter,
|
|
79
|
+
clearFilters,
|
|
80
|
+
sortField: store.sortField,
|
|
81
|
+
sortDirection: store.sortDirection,
|
|
82
|
+
setSort
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function parseQueryBinding(binding) {
|
|
86
|
+
const cleaned = binding.startsWith("@") ? binding.slice(1) : binding;
|
|
87
|
+
const parts = cleaned.split(".");
|
|
88
|
+
return {
|
|
89
|
+
query: parts[0],
|
|
90
|
+
field: parts.length > 1 ? parts.slice(1).join(".") : void 0
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
var EntityDataContext = createContext(null);
|
|
94
|
+
function EntityDataProvider({
|
|
95
|
+
adapter,
|
|
96
|
+
children
|
|
97
|
+
}) {
|
|
98
|
+
return React.createElement(
|
|
99
|
+
EntityDataContext.Provider,
|
|
100
|
+
{ value: adapter },
|
|
101
|
+
children
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
function useEntityDataAdapter() {
|
|
105
|
+
return useContext(EntityDataContext);
|
|
106
|
+
}
|
|
107
|
+
var entityDataKeys = {
|
|
108
|
+
all: ["entities"],
|
|
109
|
+
lists: () => [...entityDataKeys.all, "list"],
|
|
110
|
+
list: (entity, filters) => [...entityDataKeys.lists(), entity, filters],
|
|
111
|
+
details: () => [...entityDataKeys.all, "detail"],
|
|
112
|
+
detail: (entity, id) => [...entityDataKeys.details(), entity, id]
|
|
113
|
+
};
|
|
114
|
+
function useEntityList(entity, options = {}) {
|
|
115
|
+
const { skip = false } = options;
|
|
116
|
+
const adapter = useContext(EntityDataContext);
|
|
117
|
+
const adapterData = useMemo(() => {
|
|
118
|
+
if (!adapter || !entity || skip) return [];
|
|
119
|
+
return adapter.getData(entity);
|
|
120
|
+
}, [adapter, entity, skip, adapter?.isLoading]);
|
|
121
|
+
const [stubData, setStubData] = useState([]);
|
|
122
|
+
const [stubLoading, setStubLoading] = useState(!skip && !!entity && !adapter);
|
|
123
|
+
const [stubError, setStubError] = useState(null);
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
if (adapter || skip || !entity) {
|
|
126
|
+
setStubLoading(false);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
setStubLoading(true);
|
|
130
|
+
const t = setTimeout(() => {
|
|
131
|
+
setStubData([]);
|
|
132
|
+
setStubLoading(false);
|
|
133
|
+
}, 100);
|
|
134
|
+
return () => clearTimeout(t);
|
|
135
|
+
}, [entity, skip, adapter]);
|
|
136
|
+
if (adapter) {
|
|
137
|
+
return {
|
|
138
|
+
data: adapterData,
|
|
139
|
+
isLoading: adapter.isLoading,
|
|
140
|
+
error: adapter.error ? new Error(adapter.error) : null,
|
|
141
|
+
refetch: () => {
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
return { data: stubData, isLoading: stubLoading, error: stubError, refetch: () => {
|
|
146
|
+
} };
|
|
147
|
+
}
|
|
148
|
+
function useEntity(entity, id) {
|
|
149
|
+
const adapter = useContext(EntityDataContext);
|
|
150
|
+
const adapterData = useMemo(() => {
|
|
151
|
+
if (!adapter || !entity || !id) return null;
|
|
152
|
+
return adapter.getById(entity, id) ?? null;
|
|
153
|
+
}, [adapter, entity, id, adapter?.isLoading]);
|
|
154
|
+
const [stubData, setStubData] = useState(null);
|
|
155
|
+
const [stubLoading, setStubLoading] = useState(!!entity && !!id && !adapter);
|
|
156
|
+
const [stubError, setStubError] = useState(null);
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
if (adapter || !entity || !id) {
|
|
159
|
+
setStubLoading(false);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
setStubLoading(true);
|
|
163
|
+
const t = setTimeout(() => {
|
|
164
|
+
setStubData(null);
|
|
165
|
+
setStubLoading(false);
|
|
166
|
+
}, 100);
|
|
167
|
+
return () => clearTimeout(t);
|
|
168
|
+
}, [entity, id, adapter]);
|
|
169
|
+
if (adapter) {
|
|
170
|
+
return {
|
|
171
|
+
data: adapterData,
|
|
172
|
+
isLoading: adapter.isLoading,
|
|
173
|
+
error: adapter.error ? new Error(adapter.error) : null
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
return { data: stubData, isLoading: stubLoading, error: stubError };
|
|
177
|
+
}
|
|
178
|
+
function useEntityDetail(entity, id) {
|
|
179
|
+
const result = useEntity(entity, id);
|
|
180
|
+
return { ...result, refetch: () => {
|
|
181
|
+
} };
|
|
182
|
+
}
|
|
183
|
+
var suspenseCache = /* @__PURE__ */ new Map();
|
|
184
|
+
function getSuspenseCacheKey(entity, type, id) {
|
|
185
|
+
return id ? `${type}:${entity}:${id}` : `${type}:${entity}`;
|
|
186
|
+
}
|
|
187
|
+
function useEntityListSuspense(entity) {
|
|
188
|
+
const adapter = useContext(EntityDataContext);
|
|
189
|
+
if (adapter) {
|
|
190
|
+
if (adapter.isLoading) {
|
|
191
|
+
const cacheKey2 = getSuspenseCacheKey(entity, "list");
|
|
192
|
+
let entry2 = suspenseCache.get(cacheKey2);
|
|
193
|
+
if (!entry2 || entry2.status === "resolved") {
|
|
194
|
+
let resolve;
|
|
195
|
+
const promise = new Promise((r) => {
|
|
196
|
+
resolve = r;
|
|
197
|
+
});
|
|
198
|
+
entry2 = { promise, status: "pending" };
|
|
199
|
+
suspenseCache.set(cacheKey2, entry2);
|
|
200
|
+
const check = setInterval(() => {
|
|
201
|
+
if (!adapter.isLoading) {
|
|
202
|
+
clearInterval(check);
|
|
203
|
+
entry2.status = "resolved";
|
|
204
|
+
resolve();
|
|
205
|
+
}
|
|
206
|
+
}, 50);
|
|
207
|
+
}
|
|
208
|
+
if (entry2.status === "pending") {
|
|
209
|
+
throw entry2.promise;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
if (adapter.error) {
|
|
213
|
+
throw new Error(adapter.error);
|
|
214
|
+
}
|
|
215
|
+
return {
|
|
216
|
+
data: adapter.getData(entity),
|
|
217
|
+
refetch: () => {
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
const cacheKey = getSuspenseCacheKey(entity, "list");
|
|
222
|
+
let entry = suspenseCache.get(cacheKey);
|
|
223
|
+
if (!entry) {
|
|
224
|
+
let resolve;
|
|
225
|
+
const promise = new Promise((r) => {
|
|
226
|
+
resolve = r;
|
|
227
|
+
setTimeout(() => {
|
|
228
|
+
entry.status = "resolved";
|
|
229
|
+
resolve();
|
|
230
|
+
}, 100);
|
|
231
|
+
});
|
|
232
|
+
entry = { promise, status: "pending" };
|
|
233
|
+
suspenseCache.set(cacheKey, entry);
|
|
234
|
+
}
|
|
235
|
+
if (entry.status === "pending") {
|
|
236
|
+
throw entry.promise;
|
|
237
|
+
}
|
|
238
|
+
return { data: [], refetch: () => {
|
|
239
|
+
} };
|
|
240
|
+
}
|
|
241
|
+
function useEntitySuspense(entity, id) {
|
|
242
|
+
const adapter = useContext(EntityDataContext);
|
|
243
|
+
if (adapter) {
|
|
244
|
+
if (adapter.isLoading) {
|
|
245
|
+
const cacheKey2 = getSuspenseCacheKey(entity, "detail", id);
|
|
246
|
+
let entry2 = suspenseCache.get(cacheKey2);
|
|
247
|
+
if (!entry2 || entry2.status === "resolved") {
|
|
248
|
+
let resolve;
|
|
249
|
+
const promise = new Promise((r) => {
|
|
250
|
+
resolve = r;
|
|
251
|
+
});
|
|
252
|
+
entry2 = { promise, status: "pending" };
|
|
253
|
+
suspenseCache.set(cacheKey2, entry2);
|
|
254
|
+
const check = setInterval(() => {
|
|
255
|
+
if (!adapter.isLoading) {
|
|
256
|
+
clearInterval(check);
|
|
257
|
+
entry2.status = "resolved";
|
|
258
|
+
resolve();
|
|
259
|
+
}
|
|
260
|
+
}, 50);
|
|
261
|
+
}
|
|
262
|
+
if (entry2.status === "pending") {
|
|
263
|
+
throw entry2.promise;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
if (adapter.error) {
|
|
267
|
+
throw new Error(adapter.error);
|
|
268
|
+
}
|
|
269
|
+
return {
|
|
270
|
+
data: adapter.getById(entity, id) ?? null,
|
|
271
|
+
refetch: () => {
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
const cacheKey = getSuspenseCacheKey(entity, "detail", id);
|
|
276
|
+
let entry = suspenseCache.get(cacheKey);
|
|
277
|
+
if (!entry) {
|
|
278
|
+
let resolve;
|
|
279
|
+
const promise = new Promise((r) => {
|
|
280
|
+
resolve = r;
|
|
281
|
+
setTimeout(() => {
|
|
282
|
+
entry.status = "resolved";
|
|
283
|
+
resolve();
|
|
284
|
+
}, 100);
|
|
285
|
+
});
|
|
286
|
+
entry = { promise, status: "pending" };
|
|
287
|
+
suspenseCache.set(cacheKey, entry);
|
|
288
|
+
}
|
|
289
|
+
if (entry.status === "pending") {
|
|
290
|
+
throw entry.promise;
|
|
291
|
+
}
|
|
292
|
+
return { data: null, refetch: () => {
|
|
293
|
+
} };
|
|
294
|
+
}
|
|
295
|
+
var SelectionContext = createContext(null);
|
|
296
|
+
var defaultCompareEntities = (a, b) => {
|
|
297
|
+
if (a === b) return true;
|
|
298
|
+
if (!a || !b) return false;
|
|
299
|
+
if (typeof a === "object" && typeof b === "object") {
|
|
300
|
+
const aId = a.id;
|
|
301
|
+
const bId = b.id;
|
|
302
|
+
return aId !== void 0 && aId === bId;
|
|
303
|
+
}
|
|
304
|
+
return false;
|
|
305
|
+
};
|
|
306
|
+
function SelectionProvider({
|
|
307
|
+
children,
|
|
308
|
+
debug = false,
|
|
309
|
+
compareEntities = defaultCompareEntities
|
|
310
|
+
}) {
|
|
311
|
+
const eventBus = useEventBus();
|
|
312
|
+
const [selected, setSelectedState] = useState(null);
|
|
313
|
+
const setSelected = useCallback(
|
|
314
|
+
(entity) => {
|
|
315
|
+
setSelectedState(entity);
|
|
316
|
+
if (debug) {
|
|
317
|
+
console.log("[SelectionProvider] Selection set:", entity);
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
[debug]
|
|
321
|
+
);
|
|
322
|
+
const clearSelection = useCallback(() => {
|
|
323
|
+
setSelectedState(null);
|
|
324
|
+
if (debug) {
|
|
325
|
+
console.log("[SelectionProvider] Selection cleared");
|
|
326
|
+
}
|
|
327
|
+
}, [debug]);
|
|
328
|
+
const isSelected = useCallback(
|
|
329
|
+
(entity) => {
|
|
330
|
+
return compareEntities(selected, entity);
|
|
331
|
+
},
|
|
332
|
+
[selected, compareEntities]
|
|
333
|
+
);
|
|
334
|
+
useEffect(() => {
|
|
335
|
+
const handleSelect = (event) => {
|
|
336
|
+
const row = event.payload?.row;
|
|
337
|
+
if (row) {
|
|
338
|
+
setSelected(row);
|
|
339
|
+
if (debug) {
|
|
340
|
+
console.log(`[SelectionProvider] ${event.type} received:`, row);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
const handleDeselect = (event) => {
|
|
345
|
+
clearSelection();
|
|
346
|
+
if (debug) {
|
|
347
|
+
console.log(`[SelectionProvider] ${event.type} received - clearing selection`);
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
const unsubView = eventBus.on("UI:VIEW", handleSelect);
|
|
351
|
+
const unsubSelect = eventBus.on("UI:SELECT", handleSelect);
|
|
352
|
+
const unsubClose = eventBus.on("UI:CLOSE", handleDeselect);
|
|
353
|
+
const unsubDeselect = eventBus.on("UI:DESELECT", handleDeselect);
|
|
354
|
+
const unsubCancel = eventBus.on("UI:CANCEL", handleDeselect);
|
|
355
|
+
return () => {
|
|
356
|
+
unsubView();
|
|
357
|
+
unsubSelect();
|
|
358
|
+
unsubClose();
|
|
359
|
+
unsubDeselect();
|
|
360
|
+
unsubCancel();
|
|
361
|
+
};
|
|
362
|
+
}, [eventBus, setSelected, clearSelection, debug]);
|
|
363
|
+
const contextValue = {
|
|
364
|
+
selected,
|
|
365
|
+
setSelected,
|
|
366
|
+
clearSelection,
|
|
367
|
+
isSelected
|
|
368
|
+
};
|
|
369
|
+
return /* @__PURE__ */ jsx(SelectionContext.Provider, { value: contextValue, children });
|
|
370
|
+
}
|
|
371
|
+
function useSelection() {
|
|
372
|
+
const context = useContext(SelectionContext);
|
|
373
|
+
if (!context) {
|
|
374
|
+
throw new Error("useSelection must be used within a SelectionProvider");
|
|
375
|
+
}
|
|
376
|
+
return context;
|
|
377
|
+
}
|
|
378
|
+
function useSelectionOptional() {
|
|
379
|
+
const context = useContext(SelectionContext);
|
|
380
|
+
return context;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
export { EntityDataProvider, I18nProvider, SelectionContext, SelectionProvider, createTranslate, entityDataKeys, parseQueryBinding, useEntity, useEntityDataAdapter, useEntityDetail, useEntityList, useEntityListSuspense, useEntitySuspense, useQuerySingleton, useSelection, useSelectionOptional, useTranslate };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { apiClient } from './chunk-XSEDIUM6.js';
|
|
2
|
-
import {
|
|
2
|
+
import { SelectionContext, entityDataKeys, useEntityList } from './chunk-PE2H3NAW.js';
|
|
3
3
|
import { subscribe, getSnapshot, clearEntities, removeEntity, updateSingleton, updateEntity, spawnEntity, getSingleton, getAllEntities, getByType, getEntity } from './chunk-N7MVUW4R.js';
|
|
4
|
+
import { useEventBus } from './chunk-YXZM3WCF.js';
|
|
4
5
|
import { useCallback, useState, useEffect, useMemo, useContext, useSyncExternalStore } from 'react';
|
|
5
6
|
import { useQueryClient, useMutation, useQuery } from '@tanstack/react-query';
|
|
6
7
|
|
|
@@ -987,72 +988,6 @@ function useSelectionContext() {
|
|
|
987
988
|
const context = useContext(SelectionContext);
|
|
988
989
|
return context;
|
|
989
990
|
}
|
|
990
|
-
var queryStores = /* @__PURE__ */ new Map();
|
|
991
|
-
function getOrCreateStore(query) {
|
|
992
|
-
if (!queryStores.has(query)) {
|
|
993
|
-
queryStores.set(query, {
|
|
994
|
-
search: "",
|
|
995
|
-
filters: {},
|
|
996
|
-
sortField: void 0,
|
|
997
|
-
sortDirection: void 0,
|
|
998
|
-
listeners: /* @__PURE__ */ new Set()
|
|
999
|
-
});
|
|
1000
|
-
}
|
|
1001
|
-
return queryStores.get(query);
|
|
1002
|
-
}
|
|
1003
|
-
function useQuerySingleton(query) {
|
|
1004
|
-
const [, forceUpdate] = useState({});
|
|
1005
|
-
if (!query) {
|
|
1006
|
-
return null;
|
|
1007
|
-
}
|
|
1008
|
-
const store = useMemo(() => getOrCreateStore(query), [query]);
|
|
1009
|
-
useMemo(() => {
|
|
1010
|
-
const listener = () => forceUpdate({});
|
|
1011
|
-
store.listeners.add(listener);
|
|
1012
|
-
return () => {
|
|
1013
|
-
store.listeners.delete(listener);
|
|
1014
|
-
};
|
|
1015
|
-
}, [store]);
|
|
1016
|
-
const notifyListeners = useCallback(() => {
|
|
1017
|
-
store.listeners.forEach((listener) => listener());
|
|
1018
|
-
}, [store]);
|
|
1019
|
-
const setSearch = useCallback((value) => {
|
|
1020
|
-
store.search = value;
|
|
1021
|
-
notifyListeners();
|
|
1022
|
-
}, [store, notifyListeners]);
|
|
1023
|
-
const setFilter = useCallback((key, value) => {
|
|
1024
|
-
store.filters = { ...store.filters, [key]: value };
|
|
1025
|
-
notifyListeners();
|
|
1026
|
-
}, [store, notifyListeners]);
|
|
1027
|
-
const clearFilters = useCallback(() => {
|
|
1028
|
-
store.filters = {};
|
|
1029
|
-
store.search = "";
|
|
1030
|
-
notifyListeners();
|
|
1031
|
-
}, [store, notifyListeners]);
|
|
1032
|
-
const setSort = useCallback((field, direction) => {
|
|
1033
|
-
store.sortField = field;
|
|
1034
|
-
store.sortDirection = direction;
|
|
1035
|
-
notifyListeners();
|
|
1036
|
-
}, [store, notifyListeners]);
|
|
1037
|
-
return {
|
|
1038
|
-
search: store.search,
|
|
1039
|
-
setSearch,
|
|
1040
|
-
filters: store.filters,
|
|
1041
|
-
setFilter,
|
|
1042
|
-
clearFilters,
|
|
1043
|
-
sortField: store.sortField,
|
|
1044
|
-
sortDirection: store.sortDirection,
|
|
1045
|
-
setSort
|
|
1046
|
-
};
|
|
1047
|
-
}
|
|
1048
|
-
function parseQueryBinding(binding) {
|
|
1049
|
-
const cleaned = binding.startsWith("@") ? binding.slice(1) : binding;
|
|
1050
|
-
const parts = cleaned.split(".");
|
|
1051
|
-
return {
|
|
1052
|
-
query: parts[0],
|
|
1053
|
-
field: parts.length > 1 ? parts.slice(1).join(".") : void 0
|
|
1054
|
-
};
|
|
1055
|
-
}
|
|
1056
991
|
var ENTITY_EVENTS = {
|
|
1057
992
|
CREATE: "ENTITY_CREATE",
|
|
1058
993
|
UPDATE: "ENTITY_UPDATE",
|
|
@@ -1388,6 +1323,26 @@ function useInput() {
|
|
|
1388
1323
|
}, [input?.id]);
|
|
1389
1324
|
return { input, updateInput: update };
|
|
1390
1325
|
}
|
|
1326
|
+
function useResolvedEntity(entity, data) {
|
|
1327
|
+
const shouldFetch = !data && !!entity;
|
|
1328
|
+
const fetched = useEntityList(entity, { skip: !shouldFetch });
|
|
1329
|
+
return useMemo(() => {
|
|
1330
|
+
if (data) {
|
|
1331
|
+
return {
|
|
1332
|
+
data,
|
|
1333
|
+
isLocal: true,
|
|
1334
|
+
isLoading: false,
|
|
1335
|
+
error: null
|
|
1336
|
+
};
|
|
1337
|
+
}
|
|
1338
|
+
return {
|
|
1339
|
+
data: fetched.data,
|
|
1340
|
+
isLocal: false,
|
|
1341
|
+
isLoading: fetched.isLoading,
|
|
1342
|
+
error: fetched.error
|
|
1343
|
+
};
|
|
1344
|
+
}, [data, fetched.data, fetched.isLoading, fetched.error]);
|
|
1345
|
+
}
|
|
1391
1346
|
|
|
1392
1347
|
// hooks/useAuthContext.ts
|
|
1393
1348
|
function useAuthContext() {
|
|
@@ -1474,4 +1429,4 @@ function useGitHubBranches(owner, repo, enabled = true) {
|
|
|
1474
1429
|
});
|
|
1475
1430
|
}
|
|
1476
1431
|
|
|
1477
|
-
export { ENTITY_EVENTS,
|
|
1432
|
+
export { ENTITY_EVENTS, useAgentChat, useAuthContext, useCompile, useConnectGitHub, useCreateEntity, useDeepAgentGeneration, useDeleteEntity, useDisconnectGitHub, useEntities, useEntitiesByType, useEntity, useEntityMutations, useExtensions, useFileEditor, useFileSystem, useGitHubBranches, useGitHubRepo, useGitHubRepos, useGitHubStatus, useInput, useOrbitalHistory, useOrbitalMutations, usePhysics, usePlayer, usePreview, useResolvedEntity, useSelectedEntity, useSendOrbitalEvent, useSingletonEntity, useUIEvents, useUpdateEntity, useValidation };
|