docs-i18n 0.7.3 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/admin/dist/client/assets/main-Ds-UH1id.js +17 -0
- package/admin/dist/client/assets/routes-C369Oboq.js +3 -0
- package/admin/dist/client/assets/styles-DJ6QEJmN.css +1 -0
- package/admin/dist/server/assets/_tanstack-start-manifest_v-mK4S3Lga.js +17 -0
- package/admin/dist/server/assets/chunk-CNvmzFzq.js +35 -0
- package/admin/dist/server/assets/createServerRpc-C3JHS5ky.js +12 -0
- package/admin/dist/server/assets/init-DJr2glb3.js +41707 -0
- package/admin/dist/server/assets/jobs-FXffC7LH.js +50 -0
- package/admin/dist/server/assets/misc-y6t3-UOP.js +94 -0
- package/admin/dist/server/assets/models-YNa3F3nn.js +49 -0
- package/admin/dist/server/assets/react-dom-BryASgrS.js +2159 -0
- package/admin/dist/server/assets/redirect-BHRifpCK.js +51 -0
- package/admin/dist/server/assets/router-CAX08MEI.js +897 -0
- package/admin/dist/server/assets/routes-Bk6XCM2I.js +2139 -0
- package/admin/dist/server/assets/routes-CMOVc2RM.js +2132 -0
- package/admin/dist/server/assets/start-3avuCbOL.js +4 -0
- package/admin/dist/server/assets/status-CM7Azp4n.js +81 -0
- package/admin/dist/server/server.js +16716 -0
- package/admin/package.json +7 -3
- package/admin/serve.mjs +87 -0
- package/admin/vite.config.ts +13 -0
- package/dist/cli.js +23 -11
- package/package.json +2 -2
- package/template/package.json +1 -1
|
@@ -0,0 +1,2139 @@
|
|
|
1
|
+
import { i as __toESM } from "./chunk-CNvmzFzq.js";
|
|
2
|
+
import { J as require_react, l as require_jsx_runtime } from "./react-dom-BryASgrS.js";
|
|
3
|
+
import { A as timeUntilStale, D as shallowEqualObjects, E as resolveStaleTime, L as useNavigate, M as focusManager, N as Subscribable, O as shouldThrowError, S as noop, T as resolveEnabled, _ as hashKey, a as getDefaultState, d as environmentManager, j as timeoutManager, l as notifyManager, r as useQueryClient, s as fetchState, t as Route, u as pendingThenable, w as replaceData, y as isValidTimeout } from "./routes-CMOVc2RM.js";
|
|
4
|
+
import { n as TSS_SERVER_FUNCTION, r as getServerFnById, t as createServerFn } from "../server.js";
|
|
5
|
+
//#region ../../node_modules/.bun/@tanstack+query-core@5.95.0/node_modules/@tanstack/query-core/build/modern/queryObserver.js
|
|
6
|
+
var QueryObserver = class extends Subscribable {
|
|
7
|
+
constructor(client, options) {
|
|
8
|
+
super();
|
|
9
|
+
this.options = options;
|
|
10
|
+
this.#client = client;
|
|
11
|
+
this.#selectError = null;
|
|
12
|
+
this.#currentThenable = pendingThenable();
|
|
13
|
+
this.bindMethods();
|
|
14
|
+
this.setOptions(options);
|
|
15
|
+
}
|
|
16
|
+
#client;
|
|
17
|
+
#currentQuery = void 0;
|
|
18
|
+
#currentQueryInitialState = void 0;
|
|
19
|
+
#currentResult = void 0;
|
|
20
|
+
#currentResultState;
|
|
21
|
+
#currentResultOptions;
|
|
22
|
+
#currentThenable;
|
|
23
|
+
#selectError;
|
|
24
|
+
#selectFn;
|
|
25
|
+
#selectResult;
|
|
26
|
+
#lastQueryWithDefinedData;
|
|
27
|
+
#staleTimeoutId;
|
|
28
|
+
#refetchIntervalId;
|
|
29
|
+
#currentRefetchInterval;
|
|
30
|
+
#trackedProps = /* @__PURE__ */ new Set();
|
|
31
|
+
bindMethods() {
|
|
32
|
+
this.refetch = this.refetch.bind(this);
|
|
33
|
+
}
|
|
34
|
+
onSubscribe() {
|
|
35
|
+
if (this.listeners.size === 1) {
|
|
36
|
+
this.#currentQuery.addObserver(this);
|
|
37
|
+
if (shouldFetchOnMount(this.#currentQuery, this.options)) this.#executeFetch();
|
|
38
|
+
else this.updateResult();
|
|
39
|
+
this.#updateTimers();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
onUnsubscribe() {
|
|
43
|
+
if (!this.hasListeners()) this.destroy();
|
|
44
|
+
}
|
|
45
|
+
shouldFetchOnReconnect() {
|
|
46
|
+
return shouldFetchOn(this.#currentQuery, this.options, this.options.refetchOnReconnect);
|
|
47
|
+
}
|
|
48
|
+
shouldFetchOnWindowFocus() {
|
|
49
|
+
return shouldFetchOn(this.#currentQuery, this.options, this.options.refetchOnWindowFocus);
|
|
50
|
+
}
|
|
51
|
+
destroy() {
|
|
52
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
53
|
+
this.#clearStaleTimeout();
|
|
54
|
+
this.#clearRefetchInterval();
|
|
55
|
+
this.#currentQuery.removeObserver(this);
|
|
56
|
+
}
|
|
57
|
+
setOptions(options) {
|
|
58
|
+
const prevOptions = this.options;
|
|
59
|
+
const prevQuery = this.#currentQuery;
|
|
60
|
+
this.options = this.#client.defaultQueryOptions(options);
|
|
61
|
+
if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof resolveEnabled(this.options.enabled, this.#currentQuery) !== "boolean") throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");
|
|
62
|
+
this.#updateQuery();
|
|
63
|
+
this.#currentQuery.setOptions(this.options);
|
|
64
|
+
if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) this.#client.getQueryCache().notify({
|
|
65
|
+
type: "observerOptionsUpdated",
|
|
66
|
+
query: this.#currentQuery,
|
|
67
|
+
observer: this
|
|
68
|
+
});
|
|
69
|
+
const mounted = this.hasListeners();
|
|
70
|
+
if (mounted && shouldFetchOptionally(this.#currentQuery, prevQuery, this.options, prevOptions)) this.#executeFetch();
|
|
71
|
+
this.updateResult();
|
|
72
|
+
if (mounted && (this.#currentQuery !== prevQuery || resolveEnabled(this.options.enabled, this.#currentQuery) !== resolveEnabled(prevOptions.enabled, this.#currentQuery) || resolveStaleTime(this.options.staleTime, this.#currentQuery) !== resolveStaleTime(prevOptions.staleTime, this.#currentQuery))) this.#updateStaleTimeout();
|
|
73
|
+
const nextRefetchInterval = this.#computeRefetchInterval();
|
|
74
|
+
if (mounted && (this.#currentQuery !== prevQuery || resolveEnabled(this.options.enabled, this.#currentQuery) !== resolveEnabled(prevOptions.enabled, this.#currentQuery) || nextRefetchInterval !== this.#currentRefetchInterval)) this.#updateRefetchInterval(nextRefetchInterval);
|
|
75
|
+
}
|
|
76
|
+
getOptimisticResult(options) {
|
|
77
|
+
const query = this.#client.getQueryCache().build(this.#client, options);
|
|
78
|
+
const result = this.createResult(query, options);
|
|
79
|
+
if (shouldAssignObserverCurrentProperties(this, result)) {
|
|
80
|
+
this.#currentResult = result;
|
|
81
|
+
this.#currentResultOptions = this.options;
|
|
82
|
+
this.#currentResultState = this.#currentQuery.state;
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
getCurrentResult() {
|
|
87
|
+
return this.#currentResult;
|
|
88
|
+
}
|
|
89
|
+
trackResult(result, onPropTracked) {
|
|
90
|
+
return new Proxy(result, { get: (target, key) => {
|
|
91
|
+
this.trackProp(key);
|
|
92
|
+
onPropTracked?.(key);
|
|
93
|
+
if (key === "promise") {
|
|
94
|
+
this.trackProp("data");
|
|
95
|
+
if (!this.options.experimental_prefetchInRender && this.#currentThenable.status === "pending") this.#currentThenable.reject(/* @__PURE__ */ new Error("experimental_prefetchInRender feature flag is not enabled"));
|
|
96
|
+
}
|
|
97
|
+
return Reflect.get(target, key);
|
|
98
|
+
} });
|
|
99
|
+
}
|
|
100
|
+
trackProp(key) {
|
|
101
|
+
this.#trackedProps.add(key);
|
|
102
|
+
}
|
|
103
|
+
getCurrentQuery() {
|
|
104
|
+
return this.#currentQuery;
|
|
105
|
+
}
|
|
106
|
+
refetch({ ...options } = {}) {
|
|
107
|
+
return this.fetch({ ...options });
|
|
108
|
+
}
|
|
109
|
+
fetchOptimistic(options) {
|
|
110
|
+
const defaultedOptions = this.#client.defaultQueryOptions(options);
|
|
111
|
+
const query = this.#client.getQueryCache().build(this.#client, defaultedOptions);
|
|
112
|
+
return query.fetch().then(() => this.createResult(query, defaultedOptions));
|
|
113
|
+
}
|
|
114
|
+
fetch(fetchOptions) {
|
|
115
|
+
return this.#executeFetch({
|
|
116
|
+
...fetchOptions,
|
|
117
|
+
cancelRefetch: fetchOptions.cancelRefetch ?? true
|
|
118
|
+
}).then(() => {
|
|
119
|
+
this.updateResult();
|
|
120
|
+
return this.#currentResult;
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
#executeFetch(fetchOptions) {
|
|
124
|
+
this.#updateQuery();
|
|
125
|
+
let promise = this.#currentQuery.fetch(this.options, fetchOptions);
|
|
126
|
+
if (!fetchOptions?.throwOnError) promise = promise.catch(noop);
|
|
127
|
+
return promise;
|
|
128
|
+
}
|
|
129
|
+
#updateStaleTimeout() {
|
|
130
|
+
this.#clearStaleTimeout();
|
|
131
|
+
const staleTime = resolveStaleTime(this.options.staleTime, this.#currentQuery);
|
|
132
|
+
if (environmentManager.isServer() || this.#currentResult.isStale || !isValidTimeout(staleTime)) return;
|
|
133
|
+
const timeout = timeUntilStale(this.#currentResult.dataUpdatedAt, staleTime) + 1;
|
|
134
|
+
this.#staleTimeoutId = timeoutManager.setTimeout(() => {
|
|
135
|
+
if (!this.#currentResult.isStale) this.updateResult();
|
|
136
|
+
}, timeout);
|
|
137
|
+
}
|
|
138
|
+
#computeRefetchInterval() {
|
|
139
|
+
return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(this.#currentQuery) : this.options.refetchInterval) ?? false;
|
|
140
|
+
}
|
|
141
|
+
#updateRefetchInterval(nextInterval) {
|
|
142
|
+
this.#clearRefetchInterval();
|
|
143
|
+
this.#currentRefetchInterval = nextInterval;
|
|
144
|
+
if (environmentManager.isServer() || resolveEnabled(this.options.enabled, this.#currentQuery) === false || !isValidTimeout(this.#currentRefetchInterval) || this.#currentRefetchInterval === 0) return;
|
|
145
|
+
this.#refetchIntervalId = timeoutManager.setInterval(() => {
|
|
146
|
+
if (this.options.refetchIntervalInBackground || focusManager.isFocused()) this.#executeFetch();
|
|
147
|
+
}, this.#currentRefetchInterval);
|
|
148
|
+
}
|
|
149
|
+
#updateTimers() {
|
|
150
|
+
this.#updateStaleTimeout();
|
|
151
|
+
this.#updateRefetchInterval(this.#computeRefetchInterval());
|
|
152
|
+
}
|
|
153
|
+
#clearStaleTimeout() {
|
|
154
|
+
if (this.#staleTimeoutId) {
|
|
155
|
+
timeoutManager.clearTimeout(this.#staleTimeoutId);
|
|
156
|
+
this.#staleTimeoutId = void 0;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
#clearRefetchInterval() {
|
|
160
|
+
if (this.#refetchIntervalId) {
|
|
161
|
+
timeoutManager.clearInterval(this.#refetchIntervalId);
|
|
162
|
+
this.#refetchIntervalId = void 0;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
createResult(query, options) {
|
|
166
|
+
const prevQuery = this.#currentQuery;
|
|
167
|
+
const prevOptions = this.options;
|
|
168
|
+
const prevResult = this.#currentResult;
|
|
169
|
+
const prevResultState = this.#currentResultState;
|
|
170
|
+
const prevResultOptions = this.#currentResultOptions;
|
|
171
|
+
const queryInitialState = query !== prevQuery ? query.state : this.#currentQueryInitialState;
|
|
172
|
+
const { state } = query;
|
|
173
|
+
let newState = { ...state };
|
|
174
|
+
let isPlaceholderData = false;
|
|
175
|
+
let data;
|
|
176
|
+
if (options._optimisticResults) {
|
|
177
|
+
const mounted = this.hasListeners();
|
|
178
|
+
const fetchOnMount = !mounted && shouldFetchOnMount(query, options);
|
|
179
|
+
const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions);
|
|
180
|
+
if (fetchOnMount || fetchOptionally) newState = {
|
|
181
|
+
...newState,
|
|
182
|
+
...fetchState(state.data, query.options)
|
|
183
|
+
};
|
|
184
|
+
if (options._optimisticResults === "isRestoring") newState.fetchStatus = "idle";
|
|
185
|
+
}
|
|
186
|
+
let { error, errorUpdatedAt, status } = newState;
|
|
187
|
+
data = newState.data;
|
|
188
|
+
let skipSelect = false;
|
|
189
|
+
if (options.placeholderData !== void 0 && data === void 0 && status === "pending") {
|
|
190
|
+
let placeholderData;
|
|
191
|
+
if (prevResult?.isPlaceholderData && options.placeholderData === prevResultOptions?.placeholderData) {
|
|
192
|
+
placeholderData = prevResult.data;
|
|
193
|
+
skipSelect = true;
|
|
194
|
+
} else placeholderData = typeof options.placeholderData === "function" ? options.placeholderData(this.#lastQueryWithDefinedData?.state.data, this.#lastQueryWithDefinedData) : options.placeholderData;
|
|
195
|
+
if (placeholderData !== void 0) {
|
|
196
|
+
status = "success";
|
|
197
|
+
data = replaceData(prevResult?.data, placeholderData, options);
|
|
198
|
+
isPlaceholderData = true;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (options.select && data !== void 0 && !skipSelect) if (prevResult && data === prevResultState?.data && options.select === this.#selectFn) data = this.#selectResult;
|
|
202
|
+
else try {
|
|
203
|
+
this.#selectFn = options.select;
|
|
204
|
+
data = options.select(data);
|
|
205
|
+
data = replaceData(prevResult?.data, data, options);
|
|
206
|
+
this.#selectResult = data;
|
|
207
|
+
this.#selectError = null;
|
|
208
|
+
} catch (selectError) {
|
|
209
|
+
this.#selectError = selectError;
|
|
210
|
+
}
|
|
211
|
+
if (this.#selectError) {
|
|
212
|
+
error = this.#selectError;
|
|
213
|
+
data = this.#selectResult;
|
|
214
|
+
errorUpdatedAt = Date.now();
|
|
215
|
+
status = "error";
|
|
216
|
+
}
|
|
217
|
+
const isFetching = newState.fetchStatus === "fetching";
|
|
218
|
+
const isPending = status === "pending";
|
|
219
|
+
const isError = status === "error";
|
|
220
|
+
const isLoading = isPending && isFetching;
|
|
221
|
+
const hasData = data !== void 0;
|
|
222
|
+
const nextResult = {
|
|
223
|
+
status,
|
|
224
|
+
fetchStatus: newState.fetchStatus,
|
|
225
|
+
isPending,
|
|
226
|
+
isSuccess: status === "success",
|
|
227
|
+
isError,
|
|
228
|
+
isInitialLoading: isLoading,
|
|
229
|
+
isLoading,
|
|
230
|
+
data,
|
|
231
|
+
dataUpdatedAt: newState.dataUpdatedAt,
|
|
232
|
+
error,
|
|
233
|
+
errorUpdatedAt,
|
|
234
|
+
failureCount: newState.fetchFailureCount,
|
|
235
|
+
failureReason: newState.fetchFailureReason,
|
|
236
|
+
errorUpdateCount: newState.errorUpdateCount,
|
|
237
|
+
isFetched: query.isFetched(),
|
|
238
|
+
isFetchedAfterMount: newState.dataUpdateCount > queryInitialState.dataUpdateCount || newState.errorUpdateCount > queryInitialState.errorUpdateCount,
|
|
239
|
+
isFetching,
|
|
240
|
+
isRefetching: isFetching && !isPending,
|
|
241
|
+
isLoadingError: isError && !hasData,
|
|
242
|
+
isPaused: newState.fetchStatus === "paused",
|
|
243
|
+
isPlaceholderData,
|
|
244
|
+
isRefetchError: isError && hasData,
|
|
245
|
+
isStale: isStale(query, options),
|
|
246
|
+
refetch: this.refetch,
|
|
247
|
+
promise: this.#currentThenable,
|
|
248
|
+
isEnabled: resolveEnabled(options.enabled, query) !== false
|
|
249
|
+
};
|
|
250
|
+
if (this.options.experimental_prefetchInRender) {
|
|
251
|
+
const hasResultData = nextResult.data !== void 0;
|
|
252
|
+
const isErrorWithoutData = nextResult.status === "error" && !hasResultData;
|
|
253
|
+
const finalizeThenableIfPossible = (thenable) => {
|
|
254
|
+
if (isErrorWithoutData) thenable.reject(nextResult.error);
|
|
255
|
+
else if (hasResultData) thenable.resolve(nextResult.data);
|
|
256
|
+
};
|
|
257
|
+
const recreateThenable = () => {
|
|
258
|
+
finalizeThenableIfPossible(this.#currentThenable = nextResult.promise = pendingThenable());
|
|
259
|
+
};
|
|
260
|
+
const prevThenable = this.#currentThenable;
|
|
261
|
+
switch (prevThenable.status) {
|
|
262
|
+
case "pending":
|
|
263
|
+
if (query.queryHash === prevQuery.queryHash) finalizeThenableIfPossible(prevThenable);
|
|
264
|
+
break;
|
|
265
|
+
case "fulfilled":
|
|
266
|
+
if (isErrorWithoutData || nextResult.data !== prevThenable.value) recreateThenable();
|
|
267
|
+
break;
|
|
268
|
+
case "rejected":
|
|
269
|
+
if (!isErrorWithoutData || nextResult.error !== prevThenable.reason) recreateThenable();
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return nextResult;
|
|
274
|
+
}
|
|
275
|
+
updateResult() {
|
|
276
|
+
const prevResult = this.#currentResult;
|
|
277
|
+
const nextResult = this.createResult(this.#currentQuery, this.options);
|
|
278
|
+
this.#currentResultState = this.#currentQuery.state;
|
|
279
|
+
this.#currentResultOptions = this.options;
|
|
280
|
+
if (this.#currentResultState.data !== void 0) this.#lastQueryWithDefinedData = this.#currentQuery;
|
|
281
|
+
if (shallowEqualObjects(nextResult, prevResult)) return;
|
|
282
|
+
this.#currentResult = nextResult;
|
|
283
|
+
const shouldNotifyListeners = () => {
|
|
284
|
+
if (!prevResult) return true;
|
|
285
|
+
const { notifyOnChangeProps } = this.options;
|
|
286
|
+
const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps;
|
|
287
|
+
if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !this.#trackedProps.size) return true;
|
|
288
|
+
const includedProps = new Set(notifyOnChangePropsValue ?? this.#trackedProps);
|
|
289
|
+
if (this.options.throwOnError) includedProps.add("error");
|
|
290
|
+
return Object.keys(this.#currentResult).some((key) => {
|
|
291
|
+
const typedKey = key;
|
|
292
|
+
return this.#currentResult[typedKey] !== prevResult[typedKey] && includedProps.has(typedKey);
|
|
293
|
+
});
|
|
294
|
+
};
|
|
295
|
+
this.#notify({ listeners: shouldNotifyListeners() });
|
|
296
|
+
}
|
|
297
|
+
#updateQuery() {
|
|
298
|
+
const query = this.#client.getQueryCache().build(this.#client, this.options);
|
|
299
|
+
if (query === this.#currentQuery) return;
|
|
300
|
+
const prevQuery = this.#currentQuery;
|
|
301
|
+
this.#currentQuery = query;
|
|
302
|
+
this.#currentQueryInitialState = query.state;
|
|
303
|
+
if (this.hasListeners()) {
|
|
304
|
+
prevQuery?.removeObserver(this);
|
|
305
|
+
query.addObserver(this);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
onQueryUpdate() {
|
|
309
|
+
this.updateResult();
|
|
310
|
+
if (this.hasListeners()) this.#updateTimers();
|
|
311
|
+
}
|
|
312
|
+
#notify(notifyOptions) {
|
|
313
|
+
notifyManager.batch(() => {
|
|
314
|
+
if (notifyOptions.listeners) this.listeners.forEach((listener) => {
|
|
315
|
+
listener(this.#currentResult);
|
|
316
|
+
});
|
|
317
|
+
this.#client.getQueryCache().notify({
|
|
318
|
+
query: this.#currentQuery,
|
|
319
|
+
type: "observerResultsUpdated"
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
function shouldLoadOnMount(query, options) {
|
|
325
|
+
return resolveEnabled(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && options.retryOnMount === false);
|
|
326
|
+
}
|
|
327
|
+
function shouldFetchOnMount(query, options) {
|
|
328
|
+
return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount);
|
|
329
|
+
}
|
|
330
|
+
function shouldFetchOn(query, options, field) {
|
|
331
|
+
if (resolveEnabled(options.enabled, query) !== false && resolveStaleTime(options.staleTime, query) !== "static") {
|
|
332
|
+
const value = typeof field === "function" ? field(query) : field;
|
|
333
|
+
return value === "always" || value !== false && isStale(query, options);
|
|
334
|
+
}
|
|
335
|
+
return false;
|
|
336
|
+
}
|
|
337
|
+
function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
|
|
338
|
+
return (query !== prevQuery || resolveEnabled(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
|
|
339
|
+
}
|
|
340
|
+
function isStale(query, options) {
|
|
341
|
+
return resolveEnabled(options.enabled, query) !== false && query.isStaleByTime(resolveStaleTime(options.staleTime, query));
|
|
342
|
+
}
|
|
343
|
+
function shouldAssignObserverCurrentProperties(observer, optimisticResult) {
|
|
344
|
+
if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) return true;
|
|
345
|
+
return false;
|
|
346
|
+
}
|
|
347
|
+
//#endregion
|
|
348
|
+
//#region ../../node_modules/.bun/@tanstack+query-core@5.95.0/node_modules/@tanstack/query-core/build/modern/mutationObserver.js
|
|
349
|
+
var MutationObserver = class extends Subscribable {
|
|
350
|
+
#client;
|
|
351
|
+
#currentResult = void 0;
|
|
352
|
+
#currentMutation;
|
|
353
|
+
#mutateOptions;
|
|
354
|
+
constructor(client, options) {
|
|
355
|
+
super();
|
|
356
|
+
this.#client = client;
|
|
357
|
+
this.setOptions(options);
|
|
358
|
+
this.bindMethods();
|
|
359
|
+
this.#updateResult();
|
|
360
|
+
}
|
|
361
|
+
bindMethods() {
|
|
362
|
+
this.mutate = this.mutate.bind(this);
|
|
363
|
+
this.reset = this.reset.bind(this);
|
|
364
|
+
}
|
|
365
|
+
setOptions(options) {
|
|
366
|
+
const prevOptions = this.options;
|
|
367
|
+
this.options = this.#client.defaultMutationOptions(options);
|
|
368
|
+
if (!shallowEqualObjects(this.options, prevOptions)) this.#client.getMutationCache().notify({
|
|
369
|
+
type: "observerOptionsUpdated",
|
|
370
|
+
mutation: this.#currentMutation,
|
|
371
|
+
observer: this
|
|
372
|
+
});
|
|
373
|
+
if (prevOptions?.mutationKey && this.options.mutationKey && hashKey(prevOptions.mutationKey) !== hashKey(this.options.mutationKey)) this.reset();
|
|
374
|
+
else if (this.#currentMutation?.state.status === "pending") this.#currentMutation.setOptions(this.options);
|
|
375
|
+
}
|
|
376
|
+
onUnsubscribe() {
|
|
377
|
+
if (!this.hasListeners()) this.#currentMutation?.removeObserver(this);
|
|
378
|
+
}
|
|
379
|
+
onMutationUpdate(action) {
|
|
380
|
+
this.#updateResult();
|
|
381
|
+
this.#notify(action);
|
|
382
|
+
}
|
|
383
|
+
getCurrentResult() {
|
|
384
|
+
return this.#currentResult;
|
|
385
|
+
}
|
|
386
|
+
reset() {
|
|
387
|
+
this.#currentMutation?.removeObserver(this);
|
|
388
|
+
this.#currentMutation = void 0;
|
|
389
|
+
this.#updateResult();
|
|
390
|
+
this.#notify();
|
|
391
|
+
}
|
|
392
|
+
mutate(variables, options) {
|
|
393
|
+
this.#mutateOptions = options;
|
|
394
|
+
this.#currentMutation?.removeObserver(this);
|
|
395
|
+
this.#currentMutation = this.#client.getMutationCache().build(this.#client, this.options);
|
|
396
|
+
this.#currentMutation.addObserver(this);
|
|
397
|
+
return this.#currentMutation.execute(variables);
|
|
398
|
+
}
|
|
399
|
+
#updateResult() {
|
|
400
|
+
const state = this.#currentMutation?.state ?? getDefaultState();
|
|
401
|
+
this.#currentResult = {
|
|
402
|
+
...state,
|
|
403
|
+
isPending: state.status === "pending",
|
|
404
|
+
isSuccess: state.status === "success",
|
|
405
|
+
isError: state.status === "error",
|
|
406
|
+
isIdle: state.status === "idle",
|
|
407
|
+
mutate: this.mutate,
|
|
408
|
+
reset: this.reset
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
#notify(action) {
|
|
412
|
+
notifyManager.batch(() => {
|
|
413
|
+
if (this.#mutateOptions && this.hasListeners()) {
|
|
414
|
+
const variables = this.#currentResult.variables;
|
|
415
|
+
const onMutateResult = this.#currentResult.context;
|
|
416
|
+
const context = {
|
|
417
|
+
client: this.#client,
|
|
418
|
+
meta: this.options.meta,
|
|
419
|
+
mutationKey: this.options.mutationKey
|
|
420
|
+
};
|
|
421
|
+
if (action?.type === "success") {
|
|
422
|
+
try {
|
|
423
|
+
this.#mutateOptions.onSuccess?.(action.data, variables, onMutateResult, context);
|
|
424
|
+
} catch (e) {
|
|
425
|
+
Promise.reject(e);
|
|
426
|
+
}
|
|
427
|
+
try {
|
|
428
|
+
this.#mutateOptions.onSettled?.(action.data, null, variables, onMutateResult, context);
|
|
429
|
+
} catch (e) {
|
|
430
|
+
Promise.reject(e);
|
|
431
|
+
}
|
|
432
|
+
} else if (action?.type === "error") {
|
|
433
|
+
try {
|
|
434
|
+
this.#mutateOptions.onError?.(action.error, variables, onMutateResult, context);
|
|
435
|
+
} catch (e) {
|
|
436
|
+
Promise.reject(e);
|
|
437
|
+
}
|
|
438
|
+
try {
|
|
439
|
+
this.#mutateOptions.onSettled?.(void 0, action.error, variables, onMutateResult, context);
|
|
440
|
+
} catch (e) {
|
|
441
|
+
Promise.reject(e);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
this.listeners.forEach((listener) => {
|
|
446
|
+
listener(this.#currentResult);
|
|
447
|
+
});
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
//#endregion
|
|
452
|
+
//#region ../../node_modules/.bun/@tanstack+react-query@5.95.0+b1ab299f0a400331/node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js
|
|
453
|
+
var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
|
|
454
|
+
var IsRestoringContext = import_react.createContext(false);
|
|
455
|
+
var useIsRestoring = () => import_react.useContext(IsRestoringContext);
|
|
456
|
+
IsRestoringContext.Provider;
|
|
457
|
+
//#endregion
|
|
458
|
+
//#region ../../node_modules/.bun/@tanstack+react-query@5.95.0+b1ab299f0a400331/node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js
|
|
459
|
+
var import_jsx_runtime = require_jsx_runtime();
|
|
460
|
+
function createValue() {
|
|
461
|
+
let isReset = false;
|
|
462
|
+
return {
|
|
463
|
+
clearReset: () => {
|
|
464
|
+
isReset = false;
|
|
465
|
+
},
|
|
466
|
+
reset: () => {
|
|
467
|
+
isReset = true;
|
|
468
|
+
},
|
|
469
|
+
isReset: () => {
|
|
470
|
+
return isReset;
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
var QueryErrorResetBoundaryContext = import_react.createContext(createValue());
|
|
475
|
+
var useQueryErrorResetBoundary = () => import_react.useContext(QueryErrorResetBoundaryContext);
|
|
476
|
+
//#endregion
|
|
477
|
+
//#region ../../node_modules/.bun/@tanstack+react-query@5.95.0+b1ab299f0a400331/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js
|
|
478
|
+
var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary, query) => {
|
|
479
|
+
const throwOnError = query?.state.error && typeof options.throwOnError === "function" ? shouldThrowError(options.throwOnError, [query.state.error, query]) : options.throwOnError;
|
|
480
|
+
if (options.suspense || options.experimental_prefetchInRender || throwOnError) {
|
|
481
|
+
if (!errorResetBoundary.isReset()) options.retryOnMount = false;
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
var useClearResetErrorBoundary = (errorResetBoundary) => {
|
|
485
|
+
import_react.useEffect(() => {
|
|
486
|
+
errorResetBoundary.clearReset();
|
|
487
|
+
}, [errorResetBoundary]);
|
|
488
|
+
};
|
|
489
|
+
var getHasError = ({ result, errorResetBoundary, throwOnError, query, suspense }) => {
|
|
490
|
+
return result.isError && !errorResetBoundary.isReset() && !result.isFetching && query && (suspense && result.data === void 0 || shouldThrowError(throwOnError, [result.error, query]));
|
|
491
|
+
};
|
|
492
|
+
//#endregion
|
|
493
|
+
//#region ../../node_modules/.bun/@tanstack+react-query@5.95.0+b1ab299f0a400331/node_modules/@tanstack/react-query/build/modern/suspense.js
|
|
494
|
+
var ensureSuspenseTimers = (defaultedOptions) => {
|
|
495
|
+
if (defaultedOptions.suspense) {
|
|
496
|
+
const MIN_SUSPENSE_TIME_MS = 1e3;
|
|
497
|
+
const clamp = (value) => value === "static" ? value : Math.max(value ?? MIN_SUSPENSE_TIME_MS, MIN_SUSPENSE_TIME_MS);
|
|
498
|
+
const originalStaleTime = defaultedOptions.staleTime;
|
|
499
|
+
defaultedOptions.staleTime = typeof originalStaleTime === "function" ? (...args) => clamp(originalStaleTime(...args)) : clamp(originalStaleTime);
|
|
500
|
+
if (typeof defaultedOptions.gcTime === "number") defaultedOptions.gcTime = Math.max(defaultedOptions.gcTime, MIN_SUSPENSE_TIME_MS);
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
var willFetch = (result, isRestoring) => result.isLoading && result.isFetching && !isRestoring;
|
|
504
|
+
var shouldSuspend = (defaultedOptions, result) => defaultedOptions?.suspense && result.isPending;
|
|
505
|
+
var fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).catch(() => {
|
|
506
|
+
errorResetBoundary.clearReset();
|
|
507
|
+
});
|
|
508
|
+
//#endregion
|
|
509
|
+
//#region ../../node_modules/.bun/@tanstack+react-query@5.95.0+b1ab299f0a400331/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js
|
|
510
|
+
function useBaseQuery(options, Observer, queryClient) {
|
|
511
|
+
const isRestoring = useIsRestoring();
|
|
512
|
+
const errorResetBoundary = useQueryErrorResetBoundary();
|
|
513
|
+
const client = useQueryClient(queryClient);
|
|
514
|
+
const defaultedOptions = client.defaultQueryOptions(options);
|
|
515
|
+
client.getDefaultOptions().queries?._experimental_beforeQuery?.(defaultedOptions);
|
|
516
|
+
const query = client.getQueryCache().get(defaultedOptions.queryHash);
|
|
517
|
+
defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic";
|
|
518
|
+
ensureSuspenseTimers(defaultedOptions);
|
|
519
|
+
ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary, query);
|
|
520
|
+
useClearResetErrorBoundary(errorResetBoundary);
|
|
521
|
+
const isNewCacheEntry = !client.getQueryCache().get(defaultedOptions.queryHash);
|
|
522
|
+
const [observer] = import_react.useState(() => new Observer(client, defaultedOptions));
|
|
523
|
+
const result = observer.getOptimisticResult(defaultedOptions);
|
|
524
|
+
const shouldSubscribe = !isRestoring && options.subscribed !== false;
|
|
525
|
+
import_react.useSyncExternalStore(import_react.useCallback((onStoreChange) => {
|
|
526
|
+
const unsubscribe = shouldSubscribe ? observer.subscribe(notifyManager.batchCalls(onStoreChange)) : noop;
|
|
527
|
+
observer.updateResult();
|
|
528
|
+
return unsubscribe;
|
|
529
|
+
}, [observer, shouldSubscribe]), () => observer.getCurrentResult(), () => observer.getCurrentResult());
|
|
530
|
+
import_react.useEffect(() => {
|
|
531
|
+
observer.setOptions(defaultedOptions);
|
|
532
|
+
}, [defaultedOptions, observer]);
|
|
533
|
+
if (shouldSuspend(defaultedOptions, result)) throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary);
|
|
534
|
+
if (getHasError({
|
|
535
|
+
result,
|
|
536
|
+
errorResetBoundary,
|
|
537
|
+
throwOnError: defaultedOptions.throwOnError,
|
|
538
|
+
query,
|
|
539
|
+
suspense: defaultedOptions.suspense
|
|
540
|
+
})) throw result.error;
|
|
541
|
+
client.getDefaultOptions().queries?._experimental_afterQuery?.(defaultedOptions, result);
|
|
542
|
+
if (defaultedOptions.experimental_prefetchInRender && !environmentManager.isServer() && willFetch(result, isRestoring)) (isNewCacheEntry ? fetchOptimistic(defaultedOptions, observer, errorResetBoundary) : query?.promise)?.catch(noop).finally(() => {
|
|
543
|
+
observer.updateResult();
|
|
544
|
+
});
|
|
545
|
+
return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;
|
|
546
|
+
}
|
|
547
|
+
//#endregion
|
|
548
|
+
//#region ../../node_modules/.bun/@tanstack+react-query@5.95.0+b1ab299f0a400331/node_modules/@tanstack/react-query/build/modern/useQuery.js
|
|
549
|
+
function useQuery(options, queryClient) {
|
|
550
|
+
return useBaseQuery(options, QueryObserver, queryClient);
|
|
551
|
+
}
|
|
552
|
+
//#endregion
|
|
553
|
+
//#region ../../node_modules/.bun/@tanstack+react-query@5.95.0+b1ab299f0a400331/node_modules/@tanstack/react-query/build/modern/useMutation.js
|
|
554
|
+
function useMutation(options, queryClient) {
|
|
555
|
+
const client = useQueryClient(queryClient);
|
|
556
|
+
const [observer] = import_react.useState(() => new MutationObserver(client, options));
|
|
557
|
+
import_react.useEffect(() => {
|
|
558
|
+
observer.setOptions(options);
|
|
559
|
+
}, [observer, options]);
|
|
560
|
+
const result = import_react.useSyncExternalStore(import_react.useCallback((onStoreChange) => observer.subscribe(notifyManager.batchCalls(onStoreChange)), [observer]), () => observer.getCurrentResult(), () => observer.getCurrentResult());
|
|
561
|
+
const mutate = import_react.useCallback((variables, mutateOptions) => {
|
|
562
|
+
observer.mutate(variables, mutateOptions).catch(noop);
|
|
563
|
+
}, [observer]);
|
|
564
|
+
if (result.error && shouldThrowError(observer.options.throwOnError, [result.error])) throw result.error;
|
|
565
|
+
return {
|
|
566
|
+
...result,
|
|
567
|
+
mutate,
|
|
568
|
+
mutateAsync: result.mutate
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
//#endregion
|
|
572
|
+
//#region app/lib/flags.ts
|
|
573
|
+
var FLAGS = {
|
|
574
|
+
en: "🇺🇸",
|
|
575
|
+
"zh-hans": "🇨🇳",
|
|
576
|
+
"zh-hant": "🇭🇰",
|
|
577
|
+
ja: "🇯🇵",
|
|
578
|
+
ar: "🇸🇦",
|
|
579
|
+
de: "🇩🇪",
|
|
580
|
+
es: "🇪🇸",
|
|
581
|
+
fr: "🇫🇷",
|
|
582
|
+
ru: "🇷🇺"
|
|
583
|
+
};
|
|
584
|
+
function pctColor(pct) {
|
|
585
|
+
if (pct >= 95) return "var(--green)";
|
|
586
|
+
if (pct > 50) return "var(--yellow)";
|
|
587
|
+
return "var(--red)";
|
|
588
|
+
}
|
|
589
|
+
function statusIcon(pct) {
|
|
590
|
+
if (pct >= 100) return "🟢";
|
|
591
|
+
if (pct > 0) return "🟡";
|
|
592
|
+
return "🔴";
|
|
593
|
+
}
|
|
594
|
+
function getSection(file) {
|
|
595
|
+
if (file.startsWith("docs/")) return "docs";
|
|
596
|
+
if (file.startsWith("blog/")) return "blog";
|
|
597
|
+
if (file.startsWith("learn/")) return "learn";
|
|
598
|
+
return "other";
|
|
599
|
+
}
|
|
600
|
+
//#endregion
|
|
601
|
+
//#region app/components/FileList.tsx
|
|
602
|
+
function filePct(f) {
|
|
603
|
+
return f.total > 0 ? f.translated / f.total * 100 : 100;
|
|
604
|
+
}
|
|
605
|
+
function fileStatus(f) {
|
|
606
|
+
const pct = filePct(f);
|
|
607
|
+
if (pct >= 100) return "complete";
|
|
608
|
+
if (pct > 0) return "partial";
|
|
609
|
+
return "missing";
|
|
610
|
+
}
|
|
611
|
+
function buildTree(files) {
|
|
612
|
+
const root = {
|
|
613
|
+
name: "",
|
|
614
|
+
path: "",
|
|
615
|
+
children: /* @__PURE__ */ new Map()
|
|
616
|
+
};
|
|
617
|
+
for (const f of files) {
|
|
618
|
+
const parts = f.file.split("/");
|
|
619
|
+
let node = root;
|
|
620
|
+
for (let i = 0; i < parts.length; i++) {
|
|
621
|
+
const part = parts[i];
|
|
622
|
+
if (!node.children.has(part)) node.children.set(part, {
|
|
623
|
+
name: part,
|
|
624
|
+
path: parts.slice(0, i + 1).join("/"),
|
|
625
|
+
children: /* @__PURE__ */ new Map()
|
|
626
|
+
});
|
|
627
|
+
node = node.children.get(part);
|
|
628
|
+
}
|
|
629
|
+
node.file = f;
|
|
630
|
+
}
|
|
631
|
+
return root;
|
|
632
|
+
}
|
|
633
|
+
function dirPct(node) {
|
|
634
|
+
let translated = 0;
|
|
635
|
+
let total = 0;
|
|
636
|
+
if (node.file) {
|
|
637
|
+
translated += node.file.translated;
|
|
638
|
+
total += node.file.total;
|
|
639
|
+
}
|
|
640
|
+
for (const child of node.children.values()) {
|
|
641
|
+
const sub = dirPct(child);
|
|
642
|
+
translated += sub.translated;
|
|
643
|
+
total += sub.total;
|
|
644
|
+
}
|
|
645
|
+
return {
|
|
646
|
+
translated,
|
|
647
|
+
total
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
function TreeRow({ node, depth, activeFile, selected, isEn, collapsed, onToggleCollapse, onSelect, onToggle }) {
|
|
651
|
+
const isDir = node.children.size > 0 && !node.file;
|
|
652
|
+
const isCollapsed = collapsed.has(node.path);
|
|
653
|
+
const children = [...node.children.values()].sort((a, b) => {
|
|
654
|
+
const aDir = a.children.size > 0 && !a.file;
|
|
655
|
+
if (aDir !== (b.children.size > 0 && !b.file)) return aDir ? -1 : 1;
|
|
656
|
+
return a.name.localeCompare(b.name);
|
|
657
|
+
});
|
|
658
|
+
if (isDir) {
|
|
659
|
+
const { translated, total } = dirPct(node);
|
|
660
|
+
const pct = total > 0 ? translated / total * 100 : 100;
|
|
661
|
+
const color = pct >= 100 ? "var(--green)" : pct > 0 ? "var(--yellow)" : "var(--red)";
|
|
662
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
663
|
+
className: "file-row tree-dir",
|
|
664
|
+
style: { paddingLeft: `${depth + .25}rem` },
|
|
665
|
+
onClick: () => onToggleCollapse(node.path),
|
|
666
|
+
children: [
|
|
667
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
668
|
+
className: "tree-arrow",
|
|
669
|
+
children: isCollapsed ? "▶" : "▼"
|
|
670
|
+
}),
|
|
671
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
672
|
+
className: "icon",
|
|
673
|
+
children: "📁"
|
|
674
|
+
}),
|
|
675
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
676
|
+
className: "path",
|
|
677
|
+
title: node.path,
|
|
678
|
+
children: [node.name, "/"]
|
|
679
|
+
}),
|
|
680
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
681
|
+
className: "pct",
|
|
682
|
+
children: [pct.toFixed(0), "%"]
|
|
683
|
+
}),
|
|
684
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
685
|
+
className: "mini-bar",
|
|
686
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
687
|
+
className: "mini-fill",
|
|
688
|
+
style: {
|
|
689
|
+
width: `${pct}%`,
|
|
690
|
+
background: color
|
|
691
|
+
}
|
|
692
|
+
})
|
|
693
|
+
})
|
|
694
|
+
]
|
|
695
|
+
}), !isCollapsed && children.map((child) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TreeRow, {
|
|
696
|
+
node: child,
|
|
697
|
+
depth: depth + 1,
|
|
698
|
+
activeFile,
|
|
699
|
+
selected,
|
|
700
|
+
isEn,
|
|
701
|
+
collapsed,
|
|
702
|
+
onToggleCollapse,
|
|
703
|
+
onSelect,
|
|
704
|
+
onToggle
|
|
705
|
+
}, child.path))] });
|
|
706
|
+
}
|
|
707
|
+
const f = node.file;
|
|
708
|
+
if (!f) return null;
|
|
709
|
+
f.total - f.translated;
|
|
710
|
+
const color = f.status === "complete" ? "var(--green)" : f.status === "partial" ? "var(--yellow)" : "var(--red)";
|
|
711
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
712
|
+
className: `file-row${activeFile === f.file ? " active" : ""}`,
|
|
713
|
+
style: { paddingLeft: `${depth + .25}rem` },
|
|
714
|
+
onClick: () => onSelect(f.file),
|
|
715
|
+
children: [
|
|
716
|
+
!isEn && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
717
|
+
type: "checkbox",
|
|
718
|
+
checked: selected.has(f.file),
|
|
719
|
+
onChange: (e) => {
|
|
720
|
+
e.stopPropagation();
|
|
721
|
+
onToggle(f.file);
|
|
722
|
+
},
|
|
723
|
+
onClick: (e) => e.stopPropagation()
|
|
724
|
+
}),
|
|
725
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
726
|
+
className: "icon",
|
|
727
|
+
children: statusIcon(f.pct)
|
|
728
|
+
}),
|
|
729
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
730
|
+
className: "path",
|
|
731
|
+
title: f.file,
|
|
732
|
+
children: node.name
|
|
733
|
+
}),
|
|
734
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
735
|
+
className: "pct",
|
|
736
|
+
children: [f.pct.toFixed(0), "%"]
|
|
737
|
+
}),
|
|
738
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
739
|
+
className: "mini-bar",
|
|
740
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
741
|
+
className: "mini-fill",
|
|
742
|
+
style: {
|
|
743
|
+
width: `${f.pct}%`,
|
|
744
|
+
background: color
|
|
745
|
+
}
|
|
746
|
+
})
|
|
747
|
+
})
|
|
748
|
+
]
|
|
749
|
+
}), !isCollapsed && children.map((child) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TreeRow, {
|
|
750
|
+
node: child,
|
|
751
|
+
depth: depth + 1,
|
|
752
|
+
activeFile,
|
|
753
|
+
selected,
|
|
754
|
+
isEn,
|
|
755
|
+
collapsed,
|
|
756
|
+
onToggleCollapse,
|
|
757
|
+
onSelect,
|
|
758
|
+
onToggle
|
|
759
|
+
}, child.path))] });
|
|
760
|
+
}
|
|
761
|
+
function FileList({ files, lang, activeFile, selected, statusFilter, sectionFilter, onStatusFilter, onSectionFilter, onSelect, onToggle, onSelectAll, onClear, onTranslateSelected }) {
|
|
762
|
+
const [viewMode, setViewMode] = (0, import_react.useState)("tree");
|
|
763
|
+
const [collapsed, setCollapsed] = (0, import_react.useState)(/* @__PURE__ */ new Set());
|
|
764
|
+
const [search, setSearch] = (0, import_react.useState)("");
|
|
765
|
+
const filtered = (0, import_react.useMemo)(() => {
|
|
766
|
+
let result = files.map((f) => ({
|
|
767
|
+
...f,
|
|
768
|
+
pct: filePct(f),
|
|
769
|
+
status: fileStatus(f),
|
|
770
|
+
section: getSection(f.file)
|
|
771
|
+
}));
|
|
772
|
+
if (statusFilter !== "all") result = result.filter((f) => f.status === statusFilter);
|
|
773
|
+
if (sectionFilter !== "all") result = result.filter((f) => f.section === sectionFilter);
|
|
774
|
+
if (search.trim()) {
|
|
775
|
+
const q = search.trim().toLowerCase();
|
|
776
|
+
result = result.filter((f) => f.file.toLowerCase().includes(q));
|
|
777
|
+
}
|
|
778
|
+
return result;
|
|
779
|
+
}, [
|
|
780
|
+
files,
|
|
781
|
+
statusFilter,
|
|
782
|
+
sectionFilter,
|
|
783
|
+
search
|
|
784
|
+
]);
|
|
785
|
+
const tree = (0, import_react.useMemo)(() => buildTree(filtered), [filtered]);
|
|
786
|
+
const toggleCollapse = (path) => {
|
|
787
|
+
setCollapsed((prev) => {
|
|
788
|
+
const next = new Set(prev);
|
|
789
|
+
if (next.has(path)) next.delete(path);
|
|
790
|
+
else next.add(path);
|
|
791
|
+
return next;
|
|
792
|
+
});
|
|
793
|
+
};
|
|
794
|
+
const isEn = lang === "en";
|
|
795
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
796
|
+
className: "file-list-wrap",
|
|
797
|
+
children: [
|
|
798
|
+
!isEn && selected.size > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
799
|
+
className: "sel-bar",
|
|
800
|
+
children: [
|
|
801
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [selected.size, " selected"] }),
|
|
802
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
803
|
+
type: "button",
|
|
804
|
+
className: "btn btn-sm",
|
|
805
|
+
onClick: onTranslateSelected,
|
|
806
|
+
children: "Translate Selected"
|
|
807
|
+
}),
|
|
808
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
809
|
+
type: "button",
|
|
810
|
+
className: "btn btn-sm btn-outline",
|
|
811
|
+
onClick: onClear,
|
|
812
|
+
children: "Clear"
|
|
813
|
+
})
|
|
814
|
+
]
|
|
815
|
+
}),
|
|
816
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
817
|
+
className: "file-search",
|
|
818
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
819
|
+
type: "text",
|
|
820
|
+
placeholder: "Search files...",
|
|
821
|
+
value: search,
|
|
822
|
+
onChange: (e) => setSearch(e.target.value)
|
|
823
|
+
}), search && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
824
|
+
type: "button",
|
|
825
|
+
className: "file-search-clear",
|
|
826
|
+
onClick: () => setSearch(""),
|
|
827
|
+
children: "✕"
|
|
828
|
+
})]
|
|
829
|
+
}),
|
|
830
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
831
|
+
className: "file-list-hdr",
|
|
832
|
+
children: [
|
|
833
|
+
!isEn && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
834
|
+
type: "checkbox",
|
|
835
|
+
checked: filtered.length > 0 && filtered.every((f) => selected.has(f.file)),
|
|
836
|
+
onChange: (e) => {
|
|
837
|
+
if (e.target.checked) onSelectAll(filtered.map((f) => f.file));
|
|
838
|
+
else onClear();
|
|
839
|
+
},
|
|
840
|
+
title: "Select all visible"
|
|
841
|
+
}),
|
|
842
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("strong", { children: [
|
|
843
|
+
lang,
|
|
844
|
+
" · ",
|
|
845
|
+
filtered.length,
|
|
846
|
+
" files"
|
|
847
|
+
] }),
|
|
848
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "spacer" }),
|
|
849
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
850
|
+
type: "button",
|
|
851
|
+
className: `btn btn-xs${viewMode === "list" ? " active" : ""}`,
|
|
852
|
+
onClick: () => setViewMode("list"),
|
|
853
|
+
title: "List view",
|
|
854
|
+
children: "☰"
|
|
855
|
+
}),
|
|
856
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
857
|
+
type: "button",
|
|
858
|
+
className: `btn btn-xs${viewMode === "tree" ? " active" : ""}`,
|
|
859
|
+
onClick: () => setViewMode("tree"),
|
|
860
|
+
title: "Tree view",
|
|
861
|
+
children: "🌲"
|
|
862
|
+
}),
|
|
863
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", {
|
|
864
|
+
value: statusFilter,
|
|
865
|
+
onChange: (e) => onStatusFilter(e.target.value),
|
|
866
|
+
children: [
|
|
867
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
|
|
868
|
+
value: "all",
|
|
869
|
+
children: "All"
|
|
870
|
+
}),
|
|
871
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
|
|
872
|
+
value: "complete",
|
|
873
|
+
children: "✅ Complete"
|
|
874
|
+
}),
|
|
875
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
|
|
876
|
+
value: "partial",
|
|
877
|
+
children: "🟡 Partial"
|
|
878
|
+
}),
|
|
879
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
|
|
880
|
+
value: "missing",
|
|
881
|
+
children: "🔴 Missing"
|
|
882
|
+
})
|
|
883
|
+
]
|
|
884
|
+
}),
|
|
885
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", {
|
|
886
|
+
value: sectionFilter,
|
|
887
|
+
onChange: (e) => onSectionFilter(e.target.value),
|
|
888
|
+
children: [
|
|
889
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
|
|
890
|
+
value: "all",
|
|
891
|
+
children: "All sections"
|
|
892
|
+
}),
|
|
893
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
|
|
894
|
+
value: "docs",
|
|
895
|
+
children: "docs"
|
|
896
|
+
}),
|
|
897
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
|
|
898
|
+
value: "blog",
|
|
899
|
+
children: "blog"
|
|
900
|
+
}),
|
|
901
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
|
|
902
|
+
value: "learn",
|
|
903
|
+
children: "learn"
|
|
904
|
+
})
|
|
905
|
+
]
|
|
906
|
+
})
|
|
907
|
+
]
|
|
908
|
+
}),
|
|
909
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
910
|
+
className: "file-list-body",
|
|
911
|
+
children: [
|
|
912
|
+
filtered.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
913
|
+
className: "loading",
|
|
914
|
+
children: "No files match filter"
|
|
915
|
+
}),
|
|
916
|
+
viewMode === "list" && filtered.map((f) => {
|
|
917
|
+
f.total - f.translated;
|
|
918
|
+
const color = f.status === "complete" ? "var(--green)" : f.status === "partial" ? "var(--yellow)" : "var(--red)";
|
|
919
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
920
|
+
className: `file-row${activeFile === f.file ? " active" : ""}`,
|
|
921
|
+
onClick: () => onSelect(f.file),
|
|
922
|
+
children: [
|
|
923
|
+
!isEn && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
924
|
+
type: "checkbox",
|
|
925
|
+
checked: selected.has(f.file),
|
|
926
|
+
onChange: (e) => {
|
|
927
|
+
e.stopPropagation();
|
|
928
|
+
onToggle(f.file);
|
|
929
|
+
},
|
|
930
|
+
onClick: (e) => e.stopPropagation()
|
|
931
|
+
}),
|
|
932
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
933
|
+
className: "icon",
|
|
934
|
+
children: statusIcon(f.pct)
|
|
935
|
+
}),
|
|
936
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
937
|
+
className: "path",
|
|
938
|
+
title: f.file,
|
|
939
|
+
children: f.file
|
|
940
|
+
}),
|
|
941
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
942
|
+
className: "pct",
|
|
943
|
+
children: [f.pct.toFixed(0), "%"]
|
|
944
|
+
}),
|
|
945
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
946
|
+
className: "mini-bar",
|
|
947
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
948
|
+
className: "mini-fill",
|
|
949
|
+
style: {
|
|
950
|
+
width: `${f.pct}%`,
|
|
951
|
+
background: color
|
|
952
|
+
}
|
|
953
|
+
})
|
|
954
|
+
})
|
|
955
|
+
]
|
|
956
|
+
}, f.file);
|
|
957
|
+
}),
|
|
958
|
+
viewMode === "tree" && [...tree.children.values()].sort((a, b) => a.name.localeCompare(b.name)).map((child) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TreeRow, {
|
|
959
|
+
node: child,
|
|
960
|
+
depth: 0,
|
|
961
|
+
activeFile,
|
|
962
|
+
selected,
|
|
963
|
+
isEn,
|
|
964
|
+
collapsed,
|
|
965
|
+
onToggleCollapse: toggleCollapse,
|
|
966
|
+
onSelect,
|
|
967
|
+
onToggle
|
|
968
|
+
}, child.path))
|
|
969
|
+
]
|
|
970
|
+
})
|
|
971
|
+
]
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
//#endregion
|
|
975
|
+
//#region ../../node_modules/.bun/@tanstack+start-server-core@1.167.2/node_modules/@tanstack/start-server-core/dist/esm/createSsrRpc.js
|
|
976
|
+
var createSsrRpc = (functionId, importer) => {
|
|
977
|
+
const url = "/_serverFn/" + functionId;
|
|
978
|
+
const serverFnMeta = { id: functionId };
|
|
979
|
+
const fn = async (...args) => {
|
|
980
|
+
return (importer ? await importer() : await getServerFnById(functionId))(...args);
|
|
981
|
+
};
|
|
982
|
+
return Object.assign(fn, {
|
|
983
|
+
url,
|
|
984
|
+
serverFnMeta,
|
|
985
|
+
[TSS_SERVER_FUNCTION]: true
|
|
986
|
+
});
|
|
987
|
+
};
|
|
988
|
+
//#endregion
|
|
989
|
+
//#region server/functions/status.ts
|
|
990
|
+
var fetchStatus = createServerFn({ method: "GET" }).handler(createSsrRpc("4e218d79545765572808c7eab33b7663d4496209c15406d0b449366905b6b83f"));
|
|
991
|
+
var fetchFileCoverage = createServerFn({ method: "GET" }).inputValidator((d) => d).handler(createSsrRpc("843cd8b59095708a5ae78198708db9850f89fd3dd3830ab236f0bd924417692f"));
|
|
992
|
+
var fetchFileBlocks = createServerFn({ method: "GET" }).inputValidator((d) => d).handler(createSsrRpc("e1e7281e45375c67dbe408c58452e7482b139da60e9e361615553227dce95ee0"));
|
|
993
|
+
var deleteCacheEntry = createServerFn({ method: "POST" }).inputValidator((d) => d).handler(createSsrRpc("e1d13d8602339a95f559345ccfc82e9f843dd375ce8e9f580637c241e7e44774"));
|
|
994
|
+
createServerFn({ method: "POST" }).inputValidator((d) => d).handler(createSsrRpc("1d8e3916f992485c62e62c3693083850b773fdff4ec54277de5a01eb98dab664"));
|
|
995
|
+
//#endregion
|
|
996
|
+
//#region server/functions/jobs.ts
|
|
997
|
+
var fetchJobs = createServerFn({ method: "GET" }).handler(createSsrRpc("421de02ce39dde6e27cf4689e837ec072cbd01e63f8cdd5c2a3f42f0bd5ca613"));
|
|
998
|
+
var createJob = createServerFn({ method: "POST" }).inputValidator((d) => d).handler(createSsrRpc("c08559ac758aa0d315deaca7a0d7d923a9a44d997c8cb811151417c1f221ddd6"));
|
|
999
|
+
createServerFn({ method: "GET" }).inputValidator((d) => d).handler(createSsrRpc("8a56694c9d7b29422a3e7d2f6b803be100d79d3853d92d465cb55ed572781e62"));
|
|
1000
|
+
var deleteJob = createServerFn({ method: "POST" }).inputValidator((d) => d).handler(createSsrRpc("88c2855c84e91504070bfecc50ddfa50339d22c305626800b6d9b05d79385d71"));
|
|
1001
|
+
//#endregion
|
|
1002
|
+
//#region server/functions/models.ts
|
|
1003
|
+
var fetchModels = createServerFn({ method: "GET" }).handler(createSsrRpc("5080dc3f2f2309ec6981b94c431969637130c657e8a1dfb10400b4614eecc1ea"));
|
|
1004
|
+
//#endregion
|
|
1005
|
+
//#region server/functions/misc.ts
|
|
1006
|
+
var fetchVersion = createServerFn({ method: "GET" }).handler(createSsrRpc("a3d81974aeece150d4b02be5b91590b8187442ebea56be4a89dcbf053626d22b"));
|
|
1007
|
+
var fetchLlmConfig = createServerFn({ method: "GET" }).handler(createSsrRpc("3bf4ba50ca8ccc3c8c60d8f2e53307a320940d68c478df494552066904c5cd74"));
|
|
1008
|
+
createServerFn({ method: "GET" }).handler(createSsrRpc("e0b4116f6b2c8d096830102e36458acf9c616a056fcdddda956a4d66984ef58c"));
|
|
1009
|
+
var openFile = createServerFn({ method: "POST" }).inputValidator((d) => d).handler(createSsrRpc("a054a04356fe9987891efee8b7a11cd2dedb00f6b2e8f26d1c642e001e553d53"));
|
|
1010
|
+
//#endregion
|
|
1011
|
+
//#region app/lib/api.ts
|
|
1012
|
+
var api = {
|
|
1013
|
+
version: () => fetchVersion(),
|
|
1014
|
+
llmConfig: () => fetchLlmConfig(),
|
|
1015
|
+
status: () => fetchStatus(),
|
|
1016
|
+
fileCoverage: (version, lang) => fetchFileCoverage({ data: {
|
|
1017
|
+
version,
|
|
1018
|
+
lang
|
|
1019
|
+
} }),
|
|
1020
|
+
fileBlocks: (version, lang, file) => fetchFileBlocks({ data: {
|
|
1021
|
+
version,
|
|
1022
|
+
lang,
|
|
1023
|
+
path: file
|
|
1024
|
+
} }),
|
|
1025
|
+
deleteCache: (version, lang, key) => deleteCacheEntry({ data: {
|
|
1026
|
+
version,
|
|
1027
|
+
lang,
|
|
1028
|
+
key
|
|
1029
|
+
} }),
|
|
1030
|
+
models: () => fetchModels(),
|
|
1031
|
+
jobs: () => fetchJobs(),
|
|
1032
|
+
createJob: (body) => createJob({ data: body }),
|
|
1033
|
+
deleteJob: (id) => deleteJob({ data: { id } })
|
|
1034
|
+
};
|
|
1035
|
+
//#endregion
|
|
1036
|
+
//#region app/components/JobDialog.tsx
|
|
1037
|
+
function formatPrice(price) {
|
|
1038
|
+
if (price === 0) return "Free";
|
|
1039
|
+
if (price < .01) return `$${price.toFixed(4)}`;
|
|
1040
|
+
return `$${price.toFixed(2)}`;
|
|
1041
|
+
}
|
|
1042
|
+
function ctxLabel(n) {
|
|
1043
|
+
if (n >= 1e6) return `${(n / 1e6).toFixed(1)}M`;
|
|
1044
|
+
return `${(n / 1e3).toFixed(0)}k`;
|
|
1045
|
+
}
|
|
1046
|
+
var CTX_STEPS = [
|
|
1047
|
+
0,
|
|
1048
|
+
8,
|
|
1049
|
+
16,
|
|
1050
|
+
32,
|
|
1051
|
+
64,
|
|
1052
|
+
128,
|
|
1053
|
+
200,
|
|
1054
|
+
512,
|
|
1055
|
+
1024,
|
|
1056
|
+
2048
|
|
1057
|
+
];
|
|
1058
|
+
function JobDialog({ langs, versions, defaultLang, defaultVersion, files, onClose, onSuccess }) {
|
|
1059
|
+
const [lang, setLang] = (0, import_react.useState)(defaultLang || langs[0]);
|
|
1060
|
+
const [version, setVersion] = (0, import_react.useState)(defaultVersion || versions[0]);
|
|
1061
|
+
const [max, setMax] = (0, import_react.useState)(files?.length || 999);
|
|
1062
|
+
const [concurrency, setConcurrency] = (0, import_react.useState)(3);
|
|
1063
|
+
const [error, setError] = (0, import_react.useState)(null);
|
|
1064
|
+
const [selectedModel, setSelectedModel] = (0, import_react.useState)("");
|
|
1065
|
+
const [search, setSearch] = (0, import_react.useState)("");
|
|
1066
|
+
const [sort, setSort] = (0, import_react.useState)("context-desc");
|
|
1067
|
+
const [ctxSlider, setCtxSlider] = (0, import_react.useState)(0);
|
|
1068
|
+
const [freeOnly, setFreeOnly] = (0, import_react.useState)(true);
|
|
1069
|
+
const [jsonOnly, setJsonOnly] = (0, import_react.useState)(false);
|
|
1070
|
+
const minCtx = CTX_STEPS[ctxSlider] * 1e3;
|
|
1071
|
+
const { data: llmConfig } = useQuery({
|
|
1072
|
+
queryKey: ["llmConfig"],
|
|
1073
|
+
queryFn: api.llmConfig,
|
|
1074
|
+
staleTime: 60 * 1e3
|
|
1075
|
+
});
|
|
1076
|
+
const { data: models, isLoading: modelsLoading } = useQuery({
|
|
1077
|
+
queryKey: ["models"],
|
|
1078
|
+
queryFn: api.models,
|
|
1079
|
+
staleTime: 300 * 1e3
|
|
1080
|
+
});
|
|
1081
|
+
const filtered = (0, import_react.useMemo)(() => {
|
|
1082
|
+
if (!models) return [];
|
|
1083
|
+
let result = models.filter((m) => {
|
|
1084
|
+
if (search) {
|
|
1085
|
+
const q = search.toLowerCase();
|
|
1086
|
+
if (!m.id.toLowerCase().includes(q) && !m.name.toLowerCase().includes(q)) return false;
|
|
1087
|
+
}
|
|
1088
|
+
if (freeOnly && !m.isFree) return false;
|
|
1089
|
+
if (minCtx > 0 && m.contextLength < minCtx) return false;
|
|
1090
|
+
if (jsonOnly && !m.supportsJson) return false;
|
|
1091
|
+
return true;
|
|
1092
|
+
});
|
|
1093
|
+
result = [...result];
|
|
1094
|
+
switch (sort) {
|
|
1095
|
+
case "price-asc":
|
|
1096
|
+
result.sort((a, b) => a.promptPrice - b.promptPrice);
|
|
1097
|
+
break;
|
|
1098
|
+
case "price-desc":
|
|
1099
|
+
result.sort((a, b) => b.promptPrice - a.promptPrice);
|
|
1100
|
+
break;
|
|
1101
|
+
case "context-desc":
|
|
1102
|
+
result.sort((a, b) => b.contextLength - a.contextLength);
|
|
1103
|
+
break;
|
|
1104
|
+
case "name":
|
|
1105
|
+
result.sort((a, b) => a.name.localeCompare(b.name));
|
|
1106
|
+
break;
|
|
1107
|
+
}
|
|
1108
|
+
return result;
|
|
1109
|
+
}, [
|
|
1110
|
+
models,
|
|
1111
|
+
search,
|
|
1112
|
+
freeOnly,
|
|
1113
|
+
minCtx,
|
|
1114
|
+
jsonOnly,
|
|
1115
|
+
sort
|
|
1116
|
+
]);
|
|
1117
|
+
const qc = useQueryClient();
|
|
1118
|
+
const create = useMutation({
|
|
1119
|
+
mutationFn: () => {
|
|
1120
|
+
return api.createJob({
|
|
1121
|
+
lang,
|
|
1122
|
+
version,
|
|
1123
|
+
max,
|
|
1124
|
+
concurrency,
|
|
1125
|
+
model: selectedModel || void 0,
|
|
1126
|
+
md5: true,
|
|
1127
|
+
files: files?.length ? files : void 0
|
|
1128
|
+
});
|
|
1129
|
+
},
|
|
1130
|
+
onSuccess: () => {
|
|
1131
|
+
qc.invalidateQueries({ queryKey: ["jobs"] });
|
|
1132
|
+
if (onSuccess) onSuccess(`✅ Job started: ${lang} / ${version}${files?.length ? ` (${files.length} files)` : ""}`);
|
|
1133
|
+
else onClose();
|
|
1134
|
+
},
|
|
1135
|
+
onError: (err) => setError(err.message)
|
|
1136
|
+
});
|
|
1137
|
+
const translatable = langs.filter((l) => l !== "en");
|
|
1138
|
+
const selectedModelInfo = selectedModel ? models?.find((m) => m.id === selectedModel) : null;
|
|
1139
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
1140
|
+
className: "dialog-overlay",
|
|
1141
|
+
onClick: (e) => {
|
|
1142
|
+
if (e.target === e.currentTarget) onClose();
|
|
1143
|
+
},
|
|
1144
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1145
|
+
className: "dialog dialog-wide",
|
|
1146
|
+
children: [
|
|
1147
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: "Start Translation Job" }),
|
|
1148
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
1149
|
+
className: "dialog-error",
|
|
1150
|
+
children: error
|
|
1151
|
+
}),
|
|
1152
|
+
llmConfig && !llmConfig.hasApiKey && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1153
|
+
className: "dialog-error",
|
|
1154
|
+
children: [
|
|
1155
|
+
"⚠ No API key found. Set ",
|
|
1156
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: "OPENROUTER_API_KEY" }),
|
|
1157
|
+
" in ",
|
|
1158
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: ".env" }),
|
|
1159
|
+
" or configure ",
|
|
1160
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: "llm.apiKey" }),
|
|
1161
|
+
" in config."
|
|
1162
|
+
]
|
|
1163
|
+
}),
|
|
1164
|
+
llmConfig?.model && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1165
|
+
className: "dialog-mode-hint",
|
|
1166
|
+
children: [
|
|
1167
|
+
"Default model: ",
|
|
1168
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: llmConfig.model }),
|
|
1169
|
+
llmConfig.provider && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
1170
|
+
" (",
|
|
1171
|
+
llmConfig.provider,
|
|
1172
|
+
")"
|
|
1173
|
+
] })
|
|
1174
|
+
]
|
|
1175
|
+
}),
|
|
1176
|
+
files?.length && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1177
|
+
className: "dialog-mode-hint",
|
|
1178
|
+
children: [
|
|
1179
|
+
"Translating ",
|
|
1180
|
+
files.length,
|
|
1181
|
+
" selected file",
|
|
1182
|
+
files.length > 1 ? "s" : ""
|
|
1183
|
+
]
|
|
1184
|
+
}),
|
|
1185
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1186
|
+
className: "dialog-grid",
|
|
1187
|
+
children: [
|
|
1188
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { children: "Language" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", {
|
|
1189
|
+
value: lang,
|
|
1190
|
+
onChange: (e) => setLang(e.target.value),
|
|
1191
|
+
children: translatable.map((l) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("option", {
|
|
1192
|
+
value: l,
|
|
1193
|
+
children: [
|
|
1194
|
+
FLAGS[l],
|
|
1195
|
+
" ",
|
|
1196
|
+
l
|
|
1197
|
+
]
|
|
1198
|
+
}, l))
|
|
1199
|
+
})] }),
|
|
1200
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { children: "Version" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", {
|
|
1201
|
+
value: version,
|
|
1202
|
+
onChange: (e) => setVersion(e.target.value),
|
|
1203
|
+
children: versions.map((v) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
|
|
1204
|
+
value: v,
|
|
1205
|
+
children: v
|
|
1206
|
+
}, v))
|
|
1207
|
+
})] }),
|
|
1208
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { children: "Max API calls" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
1209
|
+
type: "number",
|
|
1210
|
+
value: max,
|
|
1211
|
+
onChange: (e) => setMax(Number(e.target.value))
|
|
1212
|
+
})] }),
|
|
1213
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { children: "Concurrency" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
1214
|
+
type: "number",
|
|
1215
|
+
value: concurrency,
|
|
1216
|
+
onChange: (e) => setConcurrency(Number(e.target.value))
|
|
1217
|
+
})] })
|
|
1218
|
+
]
|
|
1219
|
+
}),
|
|
1220
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
1221
|
+
className: "dialog-section-hdr",
|
|
1222
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Model" })
|
|
1223
|
+
}),
|
|
1224
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1225
|
+
className: "model-filters",
|
|
1226
|
+
children: [
|
|
1227
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
1228
|
+
type: "text",
|
|
1229
|
+
placeholder: "Search models...",
|
|
1230
|
+
value: search,
|
|
1231
|
+
onChange: (e) => setSearch(e.target.value),
|
|
1232
|
+
className: "model-search-input"
|
|
1233
|
+
}),
|
|
1234
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", {
|
|
1235
|
+
value: sort,
|
|
1236
|
+
onChange: (e) => setSort(e.target.value),
|
|
1237
|
+
children: [
|
|
1238
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
|
|
1239
|
+
value: "context-desc",
|
|
1240
|
+
children: "Context ↓"
|
|
1241
|
+
}),
|
|
1242
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
|
|
1243
|
+
value: "price-asc",
|
|
1244
|
+
children: "Price ↑"
|
|
1245
|
+
}),
|
|
1246
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
|
|
1247
|
+
value: "price-desc",
|
|
1248
|
+
children: "Price ↓"
|
|
1249
|
+
}),
|
|
1250
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
|
|
1251
|
+
value: "name",
|
|
1252
|
+
children: "Name A-Z"
|
|
1253
|
+
})
|
|
1254
|
+
]
|
|
1255
|
+
}),
|
|
1256
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
|
|
1257
|
+
className: "model-filter-check",
|
|
1258
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
1259
|
+
type: "checkbox",
|
|
1260
|
+
checked: freeOnly,
|
|
1261
|
+
onChange: (e) => setFreeOnly(e.target.checked)
|
|
1262
|
+
}), "Free"]
|
|
1263
|
+
}),
|
|
1264
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
|
|
1265
|
+
className: "model-filter-check",
|
|
1266
|
+
title: "Structured JSON output — required for best translation quality",
|
|
1267
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
1268
|
+
type: "checkbox",
|
|
1269
|
+
checked: jsonOnly,
|
|
1270
|
+
onChange: (e) => setJsonOnly(e.target.checked)
|
|
1271
|
+
}), "JSON mode"]
|
|
1272
|
+
})
|
|
1273
|
+
]
|
|
1274
|
+
}),
|
|
1275
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1276
|
+
className: "model-slider-row",
|
|
1277
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
1278
|
+
className: "model-slider-label",
|
|
1279
|
+
children: ["Context ≥ ", minCtx === 0 ? "any" : ctxLabel(minCtx)]
|
|
1280
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
1281
|
+
type: "range",
|
|
1282
|
+
min: 0,
|
|
1283
|
+
max: CTX_STEPS.length - 1,
|
|
1284
|
+
value: ctxSlider,
|
|
1285
|
+
onChange: (e) => setCtxSlider(Number(e.target.value)),
|
|
1286
|
+
className: "model-slider"
|
|
1287
|
+
})]
|
|
1288
|
+
}),
|
|
1289
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1290
|
+
className: "model-list",
|
|
1291
|
+
children: [
|
|
1292
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
1293
|
+
className: `model-item${selectedModel === "" ? " active" : ""}`,
|
|
1294
|
+
onClick: () => setSelectedModel(""),
|
|
1295
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
1296
|
+
className: "model-name",
|
|
1297
|
+
children: "Default (from .env)"
|
|
1298
|
+
})
|
|
1299
|
+
}),
|
|
1300
|
+
modelsLoading && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
1301
|
+
className: "model-item disabled",
|
|
1302
|
+
children: "Loading models..."
|
|
1303
|
+
}),
|
|
1304
|
+
filtered.map((m) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModelRow, {
|
|
1305
|
+
m,
|
|
1306
|
+
mode: "single",
|
|
1307
|
+
active: selectedModel === m.id,
|
|
1308
|
+
onClick: () => setSelectedModel(m.id)
|
|
1309
|
+
}, m.id)),
|
|
1310
|
+
!modelsLoading && filtered.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
1311
|
+
className: "model-item disabled",
|
|
1312
|
+
children: "No models match filters"
|
|
1313
|
+
})
|
|
1314
|
+
]
|
|
1315
|
+
}),
|
|
1316
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1317
|
+
className: "model-count",
|
|
1318
|
+
children: [
|
|
1319
|
+
filtered.length,
|
|
1320
|
+
" model",
|
|
1321
|
+
filtered.length !== 1 ? "s" : "",
|
|
1322
|
+
models ? ` / ${models.length} total` : ""
|
|
1323
|
+
]
|
|
1324
|
+
}),
|
|
1325
|
+
selectedModelInfo && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1326
|
+
className: "model-info",
|
|
1327
|
+
children: [
|
|
1328
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: selectedModelInfo.name }),
|
|
1329
|
+
selectedModelInfo.isFree && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
1330
|
+
className: "badge-free",
|
|
1331
|
+
children: "FREE"
|
|
1332
|
+
}),
|
|
1333
|
+
selectedModelInfo.supportsJson && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
1334
|
+
className: "badge-json",
|
|
1335
|
+
children: "JSON"
|
|
1336
|
+
}),
|
|
1337
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
|
|
1338
|
+
"In: ",
|
|
1339
|
+
formatPrice(selectedModelInfo.promptPrice),
|
|
1340
|
+
"/M · Out:",
|
|
1341
|
+
" ",
|
|
1342
|
+
formatPrice(selectedModelInfo.completionPrice),
|
|
1343
|
+
"/M · Ctx:",
|
|
1344
|
+
" ",
|
|
1345
|
+
ctxLabel(selectedModelInfo.contextLength),
|
|
1346
|
+
selectedModelInfo.maxOutput > 0 && ` · Max out: ${ctxLabel(selectedModelInfo.maxOutput)}`
|
|
1347
|
+
]
|
|
1348
|
+
}),
|
|
1349
|
+
files && files.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1350
|
+
className: "file-list-preview",
|
|
1351
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("strong", { children: [files.length, " files selected:"] }), files.map((f) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: f }, f))]
|
|
1352
|
+
}),
|
|
1353
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1354
|
+
className: "actions",
|
|
1355
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
1356
|
+
type: "button",
|
|
1357
|
+
className: "btn btn-outline",
|
|
1358
|
+
onClick: onClose,
|
|
1359
|
+
children: "Cancel"
|
|
1360
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
1361
|
+
type: "button",
|
|
1362
|
+
className: "btn",
|
|
1363
|
+
disabled: create.isPending || llmConfig && !llmConfig.hasApiKey,
|
|
1364
|
+
onClick: () => create.mutate(),
|
|
1365
|
+
children: create.isPending ? "Starting..." : llmConfig && !llmConfig.hasApiKey ? "No API Key" : "Start Job →"
|
|
1366
|
+
})]
|
|
1367
|
+
})
|
|
1368
|
+
]
|
|
1369
|
+
})
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1372
|
+
function ModelRow({ m, mode, active, onClick }) {
|
|
1373
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1374
|
+
className: `model-item${active ? " active" : ""}`,
|
|
1375
|
+
onClick,
|
|
1376
|
+
children: [
|
|
1377
|
+
mode === "rotate" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
1378
|
+
type: "checkbox",
|
|
1379
|
+
checked: active,
|
|
1380
|
+
readOnly: true,
|
|
1381
|
+
className: "model-check"
|
|
1382
|
+
}),
|
|
1383
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
1384
|
+
className: "model-name",
|
|
1385
|
+
children: [m.isFree && "🆓 ", m.name]
|
|
1386
|
+
}),
|
|
1387
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
1388
|
+
className: "model-meta",
|
|
1389
|
+
children: [
|
|
1390
|
+
m.supportsJson ? "✓ " : "",
|
|
1391
|
+
ctxLabel(m.contextLength),
|
|
1392
|
+
" ·",
|
|
1393
|
+
" ",
|
|
1394
|
+
m.isFree ? "Free" : `${formatPrice(m.promptPrice)}/${formatPrice(m.completionPrice)}`
|
|
1395
|
+
]
|
|
1396
|
+
})
|
|
1397
|
+
]
|
|
1398
|
+
});
|
|
1399
|
+
}
|
|
1400
|
+
//#endregion
|
|
1401
|
+
//#region app/components/JobPanel.tsx
|
|
1402
|
+
function escapeHtml(s) {
|
|
1403
|
+
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1404
|
+
}
|
|
1405
|
+
function JobItem({ job }) {
|
|
1406
|
+
const qc = useQueryClient();
|
|
1407
|
+
const del = useMutation({
|
|
1408
|
+
mutationFn: () => api.deleteJob(job.id),
|
|
1409
|
+
onSuccess: () => qc.invalidateQueries({ queryKey: ["jobs"] })
|
|
1410
|
+
});
|
|
1411
|
+
const pct = job.toTranslate > 0 ? job.translatedFiles / job.toTranslate * 100 : job.status === "completed" ? 100 : 0;
|
|
1412
|
+
let progress = "";
|
|
1413
|
+
if (job.toTranslate > 0) {
|
|
1414
|
+
progress = `${job.translatedFiles}/${job.toTranslate} translated`;
|
|
1415
|
+
if (job.totalFiles) progress += ` (${job.totalFiles} total)`;
|
|
1416
|
+
} else if (job.totalFiles > 0) progress = `scanning ${job.totalFiles} files...`;
|
|
1417
|
+
if (job.errorFiles > 0) progress += ` · ${job.errorFiles} errors`;
|
|
1418
|
+
const running = job.status === "running";
|
|
1419
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1420
|
+
className: "job-item",
|
|
1421
|
+
children: [
|
|
1422
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1423
|
+
className: "hdr",
|
|
1424
|
+
children: [
|
|
1425
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
1426
|
+
className: `status-badge ${job.status}`,
|
|
1427
|
+
children: job.status
|
|
1428
|
+
}),
|
|
1429
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("strong", { children: [
|
|
1430
|
+
job.lang,
|
|
1431
|
+
"/",
|
|
1432
|
+
job.version
|
|
1433
|
+
] }),
|
|
1434
|
+
job.currentFile && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
1435
|
+
style: { color: "var(--fg2)" },
|
|
1436
|
+
children: job.currentFile
|
|
1437
|
+
}),
|
|
1438
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "spacer" }),
|
|
1439
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
1440
|
+
type: "button",
|
|
1441
|
+
className: "btn btn-sm btn-outline",
|
|
1442
|
+
onClick: () => del.mutate(),
|
|
1443
|
+
children: running ? "⏹" : "🗑"
|
|
1444
|
+
})
|
|
1445
|
+
]
|
|
1446
|
+
}),
|
|
1447
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
1448
|
+
className: "progress-bar",
|
|
1449
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
1450
|
+
className: "progress-fill",
|
|
1451
|
+
style: { width: `${Math.min(100, pct)}%` }
|
|
1452
|
+
})
|
|
1453
|
+
}),
|
|
1454
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1455
|
+
className: "job-meta",
|
|
1456
|
+
children: [
|
|
1457
|
+
progress,
|
|
1458
|
+
" · ",
|
|
1459
|
+
new Date(job.startedAt).toLocaleTimeString(),
|
|
1460
|
+
job.finishedAt && ` · done ${new Date(job.finishedAt).toLocaleTimeString()}`,
|
|
1461
|
+
job.exitCode != null && job.exitCode !== 0 && ` · exit ${job.exitCode}`
|
|
1462
|
+
]
|
|
1463
|
+
}),
|
|
1464
|
+
job.logLines && job.logLines.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1465
|
+
className: "log-viewer",
|
|
1466
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
1467
|
+
type: "button",
|
|
1468
|
+
className: "log-copy",
|
|
1469
|
+
title: "Copy logs",
|
|
1470
|
+
onClick: () => {
|
|
1471
|
+
navigator.clipboard.writeText(job.logLines.join("\n"));
|
|
1472
|
+
},
|
|
1473
|
+
children: "📋"
|
|
1474
|
+
}), job.logLines.map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
1475
|
+
className: line.includes("stderr") || line.includes("rror") ? "err" : void 0,
|
|
1476
|
+
dangerouslySetInnerHTML: { __html: escapeHtml(line) }
|
|
1477
|
+
}, i))]
|
|
1478
|
+
})
|
|
1479
|
+
]
|
|
1480
|
+
});
|
|
1481
|
+
}
|
|
1482
|
+
function JobPanel() {
|
|
1483
|
+
const qc = useQueryClient();
|
|
1484
|
+
const prevRunning = (0, import_react.useRef)(/* @__PURE__ */ new Set());
|
|
1485
|
+
const { data: jobs = [] } = useQuery({
|
|
1486
|
+
queryKey: ["jobs"],
|
|
1487
|
+
queryFn: api.jobs,
|
|
1488
|
+
refetchInterval: 3e3
|
|
1489
|
+
});
|
|
1490
|
+
(0, import_react.useEffect)(() => {
|
|
1491
|
+
const currentRunning = new Set(jobs.filter((j) => j.status === "running").map((j) => j.id));
|
|
1492
|
+
if ([...prevRunning.current].filter((id) => !currentRunning.has(id)).length > 0) {
|
|
1493
|
+
qc.invalidateQueries({ queryKey: ["files"] });
|
|
1494
|
+
qc.invalidateQueries({ queryKey: ["fileBlocks"] });
|
|
1495
|
+
qc.invalidateQueries({ queryKey: ["status"] });
|
|
1496
|
+
}
|
|
1497
|
+
prevRunning.current = currentRunning;
|
|
1498
|
+
}, [jobs, qc]);
|
|
1499
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1500
|
+
className: "jobs-panel",
|
|
1501
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: "Jobs" }), jobs.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
1502
|
+
style: {
|
|
1503
|
+
color: "var(--fg2)",
|
|
1504
|
+
fontSize: "0.85rem"
|
|
1505
|
+
},
|
|
1506
|
+
children: "No jobs"
|
|
1507
|
+
}) : jobs.map((j) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(JobItem, { job: j }, j.id))]
|
|
1508
|
+
});
|
|
1509
|
+
}
|
|
1510
|
+
//#endregion
|
|
1511
|
+
//#region app/components/ProgressBar.tsx
|
|
1512
|
+
function ProgressBar({ value, color, height = 4 }) {
|
|
1513
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
1514
|
+
className: "bar-bg",
|
|
1515
|
+
style: { height },
|
|
1516
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
1517
|
+
className: "bar-fill",
|
|
1518
|
+
style: {
|
|
1519
|
+
width: `${Math.min(100, value)}%`,
|
|
1520
|
+
background: color || "var(--accent)"
|
|
1521
|
+
}
|
|
1522
|
+
})
|
|
1523
|
+
});
|
|
1524
|
+
}
|
|
1525
|
+
//#endregion
|
|
1526
|
+
//#region app/components/LangGrid.tsx
|
|
1527
|
+
function LangGrid({ data, version, selectedLang, onSelect }) {
|
|
1528
|
+
const vData = data.data[version];
|
|
1529
|
+
if (!vData) return null;
|
|
1530
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
1531
|
+
className: "lang-grid",
|
|
1532
|
+
children: data.langs.map((lang) => {
|
|
1533
|
+
if (lang === "en") return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1534
|
+
className: `lang-card is-en${selectedLang === "en" ? " selected" : ""}`,
|
|
1535
|
+
onClick: () => onSelect("en"),
|
|
1536
|
+
children: [
|
|
1537
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1538
|
+
className: "name",
|
|
1539
|
+
children: [FLAGS.en, " en (source)"]
|
|
1540
|
+
}),
|
|
1541
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1542
|
+
className: "stats",
|
|
1543
|
+
children: [vData.enFileCount, " files"]
|
|
1544
|
+
}),
|
|
1545
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ProgressBar, {
|
|
1546
|
+
value: 100,
|
|
1547
|
+
color: "var(--green)"
|
|
1548
|
+
})
|
|
1549
|
+
]
|
|
1550
|
+
}, "en");
|
|
1551
|
+
const ls = vData.langs[lang];
|
|
1552
|
+
if (!ls) return null;
|
|
1553
|
+
const pct = ls.totalNodes > 0 ? ls.translatedNodes / ls.totalNodes * 100 : 0;
|
|
1554
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1555
|
+
className: `lang-card${selectedLang === lang ? " selected" : ""}`,
|
|
1556
|
+
onClick: () => onSelect(lang),
|
|
1557
|
+
children: [
|
|
1558
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1559
|
+
className: "name",
|
|
1560
|
+
children: [
|
|
1561
|
+
FLAGS[lang],
|
|
1562
|
+
" ",
|
|
1563
|
+
lang
|
|
1564
|
+
]
|
|
1565
|
+
}),
|
|
1566
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1567
|
+
className: "stats",
|
|
1568
|
+
children: [pct.toFixed(1), "%"]
|
|
1569
|
+
}),
|
|
1570
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ProgressBar, {
|
|
1571
|
+
value: pct,
|
|
1572
|
+
color: pctColor(pct)
|
|
1573
|
+
})
|
|
1574
|
+
]
|
|
1575
|
+
}, lang);
|
|
1576
|
+
})
|
|
1577
|
+
});
|
|
1578
|
+
}
|
|
1579
|
+
//#endregion
|
|
1580
|
+
//#region app/components/Preview.tsx
|
|
1581
|
+
function extractHeading(text, prefix, idx) {
|
|
1582
|
+
const m = text.split("\n")[0].match(/^(#{1,6})\s+(.+)/);
|
|
1583
|
+
if (!m) return null;
|
|
1584
|
+
const clean = m[2].replace(/\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/\[]\(#[^)]*\)/g, "").replace(/[`*[\]]/g, "").trim();
|
|
1585
|
+
return {
|
|
1586
|
+
id: `${prefix}-h-${idx}`,
|
|
1587
|
+
level: m[1].length,
|
|
1588
|
+
text: clean
|
|
1589
|
+
};
|
|
1590
|
+
}
|
|
1591
|
+
function getHeadings(blocks, prefix, useTranslation = false) {
|
|
1592
|
+
const headings = [];
|
|
1593
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
1594
|
+
const h = extractHeading(useTranslation && blocks[i].translation != null ? blocks[i].translation : blocks[i].source, prefix, i);
|
|
1595
|
+
if (h) headings.push(h);
|
|
1596
|
+
}
|
|
1597
|
+
return headings;
|
|
1598
|
+
}
|
|
1599
|
+
function Preview({ version, lang, file, viewMode, onViewMode, showToc, onToggleToc, showNodes, onToggleNodes, onClose }) {
|
|
1600
|
+
const bodyRef = (0, import_react.useRef)(null);
|
|
1601
|
+
const isEn = lang === "en";
|
|
1602
|
+
const mode = isEn ? "en" : viewMode;
|
|
1603
|
+
const [highlightMd5, setHighlightMd5] = (0, import_react.useState)(null);
|
|
1604
|
+
const [ctxMenu, setCtxMenu] = (0, import_react.useState)(null);
|
|
1605
|
+
const qc = useQueryClient();
|
|
1606
|
+
const deleteCache = useMutation({
|
|
1607
|
+
mutationFn: (key) => api.deleteCache(version, lang, key),
|
|
1608
|
+
onSuccess: () => {
|
|
1609
|
+
qc.invalidateQueries({ queryKey: [
|
|
1610
|
+
"fileBlocks",
|
|
1611
|
+
version,
|
|
1612
|
+
lang,
|
|
1613
|
+
file
|
|
1614
|
+
] });
|
|
1615
|
+
qc.invalidateQueries({ queryKey: ["files"] });
|
|
1616
|
+
qc.invalidateQueries({ queryKey: ["status"] });
|
|
1617
|
+
setCtxMenu(null);
|
|
1618
|
+
}
|
|
1619
|
+
});
|
|
1620
|
+
(0, import_react.useEffect)(() => {
|
|
1621
|
+
if (!ctxMenu) return;
|
|
1622
|
+
const close = () => setCtxMenu(null);
|
|
1623
|
+
window.addEventListener("click", close);
|
|
1624
|
+
return () => window.removeEventListener("click", close);
|
|
1625
|
+
}, [ctxMenu]);
|
|
1626
|
+
const { data: blocksData } = useQuery({
|
|
1627
|
+
queryKey: [
|
|
1628
|
+
"fileBlocks",
|
|
1629
|
+
version,
|
|
1630
|
+
lang,
|
|
1631
|
+
file
|
|
1632
|
+
],
|
|
1633
|
+
queryFn: () => api.fileBlocks(version, lang, file)
|
|
1634
|
+
});
|
|
1635
|
+
const blocks = blocksData?.blocks ?? [];
|
|
1636
|
+
const showEnCol = mode === "split" || mode === "en";
|
|
1637
|
+
const showTransCol = !isEn && (mode === "split" || mode === "lang");
|
|
1638
|
+
const enHeadings = (0, import_react.useMemo)(() => getHeadings(blocks, "b"), [blocks]);
|
|
1639
|
+
const transHeadings = (0, import_react.useMemo)(() => getHeadings(blocks, "b", true), [blocks]);
|
|
1640
|
+
const headings = showTransCol ? transHeadings : enHeadings;
|
|
1641
|
+
const showGutter = showNodes && blocks.length > 0;
|
|
1642
|
+
const translatableBlocks = (0, import_react.useMemo)(() => blocks.filter((b) => b.md5), [blocks]);
|
|
1643
|
+
const translatedCount = translatableBlocks.filter((b) => b.translation != null).length;
|
|
1644
|
+
const totalCount = translatableBlocks.length;
|
|
1645
|
+
function scrollToHeading(idx) {
|
|
1646
|
+
const h = headings[idx];
|
|
1647
|
+
if (h) document.getElementById(h.id)?.scrollIntoView({
|
|
1648
|
+
behavior: "smooth",
|
|
1649
|
+
block: "start"
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1652
|
+
const cols = [];
|
|
1653
|
+
if (showGutter) cols.push("4.5rem");
|
|
1654
|
+
if (showEnCol) cols.push("1fr");
|
|
1655
|
+
if (showTransCol) cols.push("1fr");
|
|
1656
|
+
const gridCols = cols.join(" ");
|
|
1657
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1658
|
+
className: "preview-wrap",
|
|
1659
|
+
children: [
|
|
1660
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1661
|
+
className: "preview-hdr",
|
|
1662
|
+
children: [
|
|
1663
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
|
|
1664
|
+
className: "preview-filename",
|
|
1665
|
+
href: "#",
|
|
1666
|
+
title: "Click to open in editor",
|
|
1667
|
+
onClick: (e) => {
|
|
1668
|
+
e.preventDefault();
|
|
1669
|
+
openFile({ data: { file: `content/${version}/${file}` } });
|
|
1670
|
+
},
|
|
1671
|
+
children: file
|
|
1672
|
+
}),
|
|
1673
|
+
!isEn && totalCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
1674
|
+
className: "preview-stats",
|
|
1675
|
+
children: [
|
|
1676
|
+
translatedCount,
|
|
1677
|
+
"/",
|
|
1678
|
+
totalCount,
|
|
1679
|
+
" (",
|
|
1680
|
+
Math.round(translatedCount / totalCount * 100),
|
|
1681
|
+
"%)"
|
|
1682
|
+
]
|
|
1683
|
+
}),
|
|
1684
|
+
onClose && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
1685
|
+
type: "button",
|
|
1686
|
+
className: "preview-close",
|
|
1687
|
+
onClick: onClose,
|
|
1688
|
+
title: "Close preview",
|
|
1689
|
+
children: "✕"
|
|
1690
|
+
}),
|
|
1691
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1692
|
+
className: "preview-toggle",
|
|
1693
|
+
children: [
|
|
1694
|
+
!isEn && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
1695
|
+
type: "button",
|
|
1696
|
+
className: showNodes ? "active" : "",
|
|
1697
|
+
onClick: onToggleNodes,
|
|
1698
|
+
title: "Toggle MD5",
|
|
1699
|
+
children: "#"
|
|
1700
|
+
}),
|
|
1701
|
+
!isEn && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
1702
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
1703
|
+
type: "button",
|
|
1704
|
+
className: mode === "split" ? "active" : "",
|
|
1705
|
+
onClick: () => onViewMode("split"),
|
|
1706
|
+
title: "Side by side",
|
|
1707
|
+
children: "◫"
|
|
1708
|
+
}),
|
|
1709
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
1710
|
+
type: "button",
|
|
1711
|
+
className: mode === "en" ? "active" : "",
|
|
1712
|
+
onClick: () => onViewMode("en"),
|
|
1713
|
+
title: "EN only",
|
|
1714
|
+
children: FLAGS.en
|
|
1715
|
+
}),
|
|
1716
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
1717
|
+
type: "button",
|
|
1718
|
+
className: mode === "lang" ? "active" : "",
|
|
1719
|
+
onClick: () => onViewMode("lang"),
|
|
1720
|
+
title: `${lang} only`,
|
|
1721
|
+
children: FLAGS[lang]
|
|
1722
|
+
})
|
|
1723
|
+
] }),
|
|
1724
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
1725
|
+
type: "button",
|
|
1726
|
+
className: showToc ? "active" : "",
|
|
1727
|
+
onClick: onToggleToc,
|
|
1728
|
+
title: "Toggle TOC",
|
|
1729
|
+
children: "☰"
|
|
1730
|
+
})
|
|
1731
|
+
]
|
|
1732
|
+
})
|
|
1733
|
+
]
|
|
1734
|
+
}),
|
|
1735
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1736
|
+
className: "preview-content-area",
|
|
1737
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1738
|
+
className: "preview-body-blocks",
|
|
1739
|
+
ref: bodyRef,
|
|
1740
|
+
children: [
|
|
1741
|
+
showGutter && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1742
|
+
className: "block-header",
|
|
1743
|
+
style: { gridTemplateColumns: gridCols },
|
|
1744
|
+
children: [
|
|
1745
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
1746
|
+
className: "col-hdr gutter-hdr",
|
|
1747
|
+
children: "MD5"
|
|
1748
|
+
}),
|
|
1749
|
+
showEnCol && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
1750
|
+
className: "col-hdr",
|
|
1751
|
+
children: "EN"
|
|
1752
|
+
}),
|
|
1753
|
+
showTransCol && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
1754
|
+
className: "col-hdr",
|
|
1755
|
+
children: lang
|
|
1756
|
+
})
|
|
1757
|
+
]
|
|
1758
|
+
}),
|
|
1759
|
+
blocks.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
1760
|
+
className: "preview-loading",
|
|
1761
|
+
children: "Loading..."
|
|
1762
|
+
}),
|
|
1763
|
+
blocks.map((block, i) => {
|
|
1764
|
+
const isGap = !block.md5;
|
|
1765
|
+
const isBlank = isGap && !block.source.trim();
|
|
1766
|
+
const isHighlighted = block.md5 && block.md5 === highlightMd5;
|
|
1767
|
+
const h = extractHeading(block.source, "b", i);
|
|
1768
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1769
|
+
id: block.md5 ? `block-${block.md5.slice(0, 8)}` : void 0,
|
|
1770
|
+
className: `block-row${isHighlighted ? " block-highlight" : ""}${isBlank ? " block-blank" : ""}${isGap && !isBlank ? " block-gap" : ""}`,
|
|
1771
|
+
style: { gridTemplateColumns: gridCols },
|
|
1772
|
+
children: [
|
|
1773
|
+
showGutter && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
1774
|
+
className: "block-gutter",
|
|
1775
|
+
children: block.md5 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", {
|
|
1776
|
+
className: `gutter-md5 ${block.translation != null ? "done" : "miss"}`,
|
|
1777
|
+
title: `${block.type} · ${block.md5}`,
|
|
1778
|
+
children: block.md5.slice(0, 6)
|
|
1779
|
+
}) : isBlank ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "gutter-blank" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
1780
|
+
className: "gutter-gap",
|
|
1781
|
+
children: block.type
|
|
1782
|
+
})
|
|
1783
|
+
}),
|
|
1784
|
+
showEnCol && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", {
|
|
1785
|
+
className: `block-cell${h ? " block-heading" : ""}`,
|
|
1786
|
+
id: h?.id,
|
|
1787
|
+
children: block.source
|
|
1788
|
+
}),
|
|
1789
|
+
showTransCol && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", {
|
|
1790
|
+
className: `block-cell${h ? " block-heading" : ""}${block.md5 && block.translation == null ? " block-missing" : ""}`,
|
|
1791
|
+
onContextMenu: (e) => {
|
|
1792
|
+
if (!block.md5 || isEn) return;
|
|
1793
|
+
e.preventDefault();
|
|
1794
|
+
setCtxMenu({
|
|
1795
|
+
x: e.clientX,
|
|
1796
|
+
y: e.clientY,
|
|
1797
|
+
md5: block.md5,
|
|
1798
|
+
type: block.type
|
|
1799
|
+
});
|
|
1800
|
+
},
|
|
1801
|
+
children: block.translation != null ? block.translation : block.source
|
|
1802
|
+
})
|
|
1803
|
+
]
|
|
1804
|
+
}, i);
|
|
1805
|
+
})
|
|
1806
|
+
]
|
|
1807
|
+
}), showToc && headings.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1808
|
+
className: "preview-toc",
|
|
1809
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
1810
|
+
className: "preview-toc-title",
|
|
1811
|
+
children: "On this page"
|
|
1812
|
+
}), headings.map((h, idx) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
|
|
1813
|
+
href: `#${h.id}`,
|
|
1814
|
+
className: `h${h.level}`,
|
|
1815
|
+
onClick: (e) => {
|
|
1816
|
+
e.preventDefault();
|
|
1817
|
+
scrollToHeading(idx);
|
|
1818
|
+
},
|
|
1819
|
+
children: h.text
|
|
1820
|
+
}, h.id))]
|
|
1821
|
+
})]
|
|
1822
|
+
}),
|
|
1823
|
+
ctxMenu && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1824
|
+
className: "ctx-menu",
|
|
1825
|
+
style: {
|
|
1826
|
+
left: ctxMenu.x,
|
|
1827
|
+
top: ctxMenu.y
|
|
1828
|
+
},
|
|
1829
|
+
onClick: (e) => e.stopPropagation(),
|
|
1830
|
+
children: [
|
|
1831
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1832
|
+
className: "ctx-menu-header",
|
|
1833
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("code", { children: [ctxMenu.md5.slice(0, 12), "…"] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
1834
|
+
className: "ctx-menu-type",
|
|
1835
|
+
children: ctxMenu.type
|
|
1836
|
+
})]
|
|
1837
|
+
}),
|
|
1838
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
1839
|
+
type: "button",
|
|
1840
|
+
onClick: () => {
|
|
1841
|
+
navigator.clipboard.writeText(ctxMenu.md5);
|
|
1842
|
+
setCtxMenu(null);
|
|
1843
|
+
},
|
|
1844
|
+
children: "📋 Copy MD5"
|
|
1845
|
+
}),
|
|
1846
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
1847
|
+
type: "button",
|
|
1848
|
+
className: "ctx-menu-danger",
|
|
1849
|
+
onClick: () => deleteCache.mutate(ctxMenu.md5),
|
|
1850
|
+
children: "🗑️ Delete cache"
|
|
1851
|
+
})
|
|
1852
|
+
]
|
|
1853
|
+
})
|
|
1854
|
+
]
|
|
1855
|
+
});
|
|
1856
|
+
}
|
|
1857
|
+
//#endregion
|
|
1858
|
+
//#region app/routes/index.tsx?tsr-split=component
|
|
1859
|
+
/**
|
|
1860
|
+
* Parse version keys into project/version structure.
|
|
1861
|
+
* Multi-project keys look like "query/v5", single-project keys look like "v5".
|
|
1862
|
+
*/
|
|
1863
|
+
function parseProjectVersions(versionKeys) {
|
|
1864
|
+
if (!versionKeys.some((k) => k.includes("/"))) return {
|
|
1865
|
+
projects: [{
|
|
1866
|
+
id: "_default",
|
|
1867
|
+
versions: versionKeys
|
|
1868
|
+
}],
|
|
1869
|
+
isMultiProject: false
|
|
1870
|
+
};
|
|
1871
|
+
const projectMap = /* @__PURE__ */ new Map();
|
|
1872
|
+
for (const key of versionKeys) {
|
|
1873
|
+
const slashIdx = key.indexOf("/");
|
|
1874
|
+
const projectId = slashIdx >= 0 ? key.slice(0, slashIdx) : "_default";
|
|
1875
|
+
const version = slashIdx >= 0 ? key.slice(slashIdx + 1) : key;
|
|
1876
|
+
if (!projectMap.has(projectId)) projectMap.set(projectId, []);
|
|
1877
|
+
projectMap.get(projectId).push(version);
|
|
1878
|
+
}
|
|
1879
|
+
return {
|
|
1880
|
+
projects: Array.from(projectMap.entries()).map(([id, versions]) => ({
|
|
1881
|
+
id,
|
|
1882
|
+
versions
|
|
1883
|
+
})),
|
|
1884
|
+
isMultiProject: true
|
|
1885
|
+
};
|
|
1886
|
+
}
|
|
1887
|
+
function AdminPage() {
|
|
1888
|
+
const search = Route.useSearch();
|
|
1889
|
+
const navigate = useNavigate({ from: "/" });
|
|
1890
|
+
const lang = search.lang || null;
|
|
1891
|
+
const file = search.file || null;
|
|
1892
|
+
const showFiles = search.files !== "0";
|
|
1893
|
+
const view = search.view || "lang";
|
|
1894
|
+
const toc = search.toc !== "0";
|
|
1895
|
+
const nodes = search.nodes === "1";
|
|
1896
|
+
const status = search.status || "all";
|
|
1897
|
+
const section = search.section || "all";
|
|
1898
|
+
const [theme, setThemeState] = (0, import_react.useState)(() => {
|
|
1899
|
+
if (typeof window === "undefined") return "dark";
|
|
1900
|
+
return localStorage.getItem("theme") === "light" ? "light" : "dark";
|
|
1901
|
+
});
|
|
1902
|
+
const [toast, setToast] = (0, import_react.useState)(null);
|
|
1903
|
+
(0, import_react.useEffect)(() => {
|
|
1904
|
+
document.documentElement.dataset.theme = theme;
|
|
1905
|
+
}, [theme]);
|
|
1906
|
+
(0, import_react.useEffect)(() => {
|
|
1907
|
+
if (!toast) return;
|
|
1908
|
+
const t = setTimeout(() => setToast(null), 3e3);
|
|
1909
|
+
return () => clearTimeout(t);
|
|
1910
|
+
}, [toast]);
|
|
1911
|
+
const updateSearch = (0, import_react.useCallback)((updates) => {
|
|
1912
|
+
navigate({
|
|
1913
|
+
search: (prev) => {
|
|
1914
|
+
const next = { ...prev };
|
|
1915
|
+
for (const [k, v] of Object.entries(updates)) if (v === null || v === void 0 || v === "") delete next[k];
|
|
1916
|
+
else next[k] = v;
|
|
1917
|
+
return next;
|
|
1918
|
+
},
|
|
1919
|
+
replace: true
|
|
1920
|
+
});
|
|
1921
|
+
}, [navigate]);
|
|
1922
|
+
const setProject = (0, import_react.useCallback)((p) => updateSearch({
|
|
1923
|
+
project: p || void 0,
|
|
1924
|
+
v: void 0,
|
|
1925
|
+
lang: void 0,
|
|
1926
|
+
file: void 0
|
|
1927
|
+
}), [updateSearch]);
|
|
1928
|
+
const setVersion = (0, import_react.useCallback)((v) => updateSearch({
|
|
1929
|
+
v: v || void 0,
|
|
1930
|
+
lang: void 0,
|
|
1931
|
+
file: void 0
|
|
1932
|
+
}), [updateSearch]);
|
|
1933
|
+
const setLang = (0, import_react.useCallback)((l) => updateSearch({ lang: l || void 0 }), [updateSearch]);
|
|
1934
|
+
const setFile = (0, import_react.useCallback)((f) => updateSearch({ file: f || void 0 }), [updateSearch]);
|
|
1935
|
+
const setShowFiles = (0, import_react.useCallback)((show) => updateSearch({ files: show ? void 0 : "0" }), [updateSearch]);
|
|
1936
|
+
const setView = (0, import_react.useCallback)((m) => updateSearch({ view: m === "lang" ? void 0 : m }), [updateSearch]);
|
|
1937
|
+
const setNodes = (0, import_react.useCallback)((show) => updateSearch({ nodes: show ? "1" : void 0 }), [updateSearch]);
|
|
1938
|
+
const setToc = (0, import_react.useCallback)((show) => updateSearch({ toc: show ? void 0 : "0" }), [updateSearch]);
|
|
1939
|
+
const setStatusFilter = (0, import_react.useCallback)((s) => updateSearch({ status: s === "all" ? void 0 : s }), [updateSearch]);
|
|
1940
|
+
const setSectionFilter = (0, import_react.useCallback)((s) => updateSearch({ section: s === "all" ? void 0 : s }), [updateSearch]);
|
|
1941
|
+
const [selected, setSelected] = (0, import_react.useState)(/* @__PURE__ */ new Set());
|
|
1942
|
+
const [showDialog, setShowDialog] = (0, import_react.useState)(false);
|
|
1943
|
+
const [dialogFiles, setDialogFiles] = (0, import_react.useState)();
|
|
1944
|
+
const { data: statusData } = useQuery({
|
|
1945
|
+
queryKey: ["status"],
|
|
1946
|
+
queryFn: api.status
|
|
1947
|
+
});
|
|
1948
|
+
const { data: versionInfo } = useQuery({
|
|
1949
|
+
queryKey: ["version"],
|
|
1950
|
+
queryFn: api.version,
|
|
1951
|
+
staleTime: Number.POSITIVE_INFINITY
|
|
1952
|
+
});
|
|
1953
|
+
const { projectList, isMultiProject, activeProject, activeVersions, version } = (0, import_react.useMemo)(() => {
|
|
1954
|
+
if (!statusData) return {
|
|
1955
|
+
projectList: [],
|
|
1956
|
+
isMultiProject: false,
|
|
1957
|
+
activeProject: null,
|
|
1958
|
+
activeVersions: [],
|
|
1959
|
+
version: "latest"
|
|
1960
|
+
};
|
|
1961
|
+
const parsed = parseProjectVersions(statusData.versions);
|
|
1962
|
+
const projectList = parsed.projects;
|
|
1963
|
+
const isMultiProject = parsed.isMultiProject;
|
|
1964
|
+
let activeProject = isMultiProject ? search.project || projectList[0]?.id || null : null;
|
|
1965
|
+
if (isMultiProject && activeProject && !projectList.find((p) => p.id === activeProject)) activeProject = projectList[0]?.id || null;
|
|
1966
|
+
const activeVersions = isMultiProject ? projectList.find((p) => p.id === activeProject)?.versions || [] : statusData.versions;
|
|
1967
|
+
const rawVersion = search.v || activeVersions[0] || "latest";
|
|
1968
|
+
const version = isMultiProject && activeProject ? `${activeProject}/${rawVersion}` : rawVersion;
|
|
1969
|
+
return {
|
|
1970
|
+
projectList,
|
|
1971
|
+
isMultiProject,
|
|
1972
|
+
activeProject,
|
|
1973
|
+
activeVersions,
|
|
1974
|
+
version
|
|
1975
|
+
};
|
|
1976
|
+
}, [
|
|
1977
|
+
statusData,
|
|
1978
|
+
search.project,
|
|
1979
|
+
search.v
|
|
1980
|
+
]);
|
|
1981
|
+
const displayVersion = isMultiProject && activeProject && version.startsWith(`${activeProject}/`) ? version.slice(activeProject.length + 1) : version;
|
|
1982
|
+
const { data: files } = useQuery({
|
|
1983
|
+
queryKey: [
|
|
1984
|
+
"files",
|
|
1985
|
+
version,
|
|
1986
|
+
lang
|
|
1987
|
+
],
|
|
1988
|
+
queryFn: () => api.fileCoverage(version, lang),
|
|
1989
|
+
enabled: !!lang
|
|
1990
|
+
});
|
|
1991
|
+
const handleSelectProject = (0, import_react.useCallback)((p) => {
|
|
1992
|
+
setProject(p);
|
|
1993
|
+
setSelected(/* @__PURE__ */ new Set());
|
|
1994
|
+
}, [setProject]);
|
|
1995
|
+
const handleSelectVersion = (0, import_react.useCallback)((v) => {
|
|
1996
|
+
setVersion(v);
|
|
1997
|
+
setSelected(/* @__PURE__ */ new Set());
|
|
1998
|
+
}, [setVersion]);
|
|
1999
|
+
const handleSelectLang = (0, import_react.useCallback)((l) => {
|
|
2000
|
+
setLang(l);
|
|
2001
|
+
setSelected(/* @__PURE__ */ new Set());
|
|
2002
|
+
}, [setLang]);
|
|
2003
|
+
const handleToggle = (0, import_react.useCallback)((f) => {
|
|
2004
|
+
setSelected((prev) => {
|
|
2005
|
+
const next = new Set(prev);
|
|
2006
|
+
if (next.has(f)) next.delete(f);
|
|
2007
|
+
else next.add(f);
|
|
2008
|
+
return next;
|
|
2009
|
+
});
|
|
2010
|
+
}, []);
|
|
2011
|
+
const handleSelectAll = (0, import_react.useCallback)((fileList) => setSelected(new Set(fileList)), []);
|
|
2012
|
+
const handleClear = (0, import_react.useCallback)(() => setSelected(/* @__PURE__ */ new Set()), []);
|
|
2013
|
+
const handleTranslateSelected = (0, import_react.useCallback)(() => {
|
|
2014
|
+
setDialogFiles([...selected]);
|
|
2015
|
+
setShowDialog(true);
|
|
2016
|
+
}, [selected]);
|
|
2017
|
+
const handleNewJob = (0, import_react.useCallback)(() => {
|
|
2018
|
+
setDialogFiles(void 0);
|
|
2019
|
+
setShowDialog(true);
|
|
2020
|
+
}, []);
|
|
2021
|
+
if (!statusData) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
2022
|
+
className: "loading",
|
|
2023
|
+
children: "Loading..."
|
|
2024
|
+
});
|
|
2025
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
2026
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("nav", { children: [
|
|
2027
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h1", { children: ["🌐 Translation Admin ", versionInfo?.version && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
2028
|
+
className: "version-badge",
|
|
2029
|
+
children: ["v", versionInfo.version]
|
|
2030
|
+
})] }),
|
|
2031
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "spacer" }),
|
|
2032
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
2033
|
+
type: "button",
|
|
2034
|
+
className: "btn",
|
|
2035
|
+
onClick: handleNewJob,
|
|
2036
|
+
children: "+ New Job"
|
|
2037
|
+
}),
|
|
2038
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
2039
|
+
type: "button",
|
|
2040
|
+
className: "btn btn-icon",
|
|
2041
|
+
onClick: () => {
|
|
2042
|
+
const next = theme === "light" ? "dark" : "light";
|
|
2043
|
+
setThemeState(next);
|
|
2044
|
+
localStorage.setItem("theme", next);
|
|
2045
|
+
},
|
|
2046
|
+
title: "Toggle theme",
|
|
2047
|
+
children: theme === "light" ? "🌙" : "☀️"
|
|
2048
|
+
})
|
|
2049
|
+
] }),
|
|
2050
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
2051
|
+
className: "container",
|
|
2052
|
+
children: [
|
|
2053
|
+
isMultiProject && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
2054
|
+
className: "project-tabs",
|
|
2055
|
+
children: projectList.map((p) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
2056
|
+
type: "button",
|
|
2057
|
+
className: `project-tab${p.id === activeProject ? " active" : ""}`,
|
|
2058
|
+
onClick: () => handleSelectProject(p.id),
|
|
2059
|
+
children: p.id
|
|
2060
|
+
}, p.id))
|
|
2061
|
+
}),
|
|
2062
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
2063
|
+
className: "tabs",
|
|
2064
|
+
children: activeVersions.map((v) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
2065
|
+
type: "button",
|
|
2066
|
+
className: `tab${v === displayVersion ? " active" : ""}`,
|
|
2067
|
+
onClick: () => handleSelectVersion(v),
|
|
2068
|
+
children: v
|
|
2069
|
+
}, v))
|
|
2070
|
+
}),
|
|
2071
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(LangGrid, {
|
|
2072
|
+
data: statusData,
|
|
2073
|
+
version,
|
|
2074
|
+
selectedLang: lang,
|
|
2075
|
+
onSelect: handleSelectLang
|
|
2076
|
+
}),
|
|
2077
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(JobPanel, {}),
|
|
2078
|
+
lang && files && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
2079
|
+
className: "file-panel-toolbar",
|
|
2080
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
2081
|
+
type: "button",
|
|
2082
|
+
className: `btn btn-sm${showFiles ? " active" : ""}`,
|
|
2083
|
+
onClick: () => setShowFiles(!showFiles),
|
|
2084
|
+
children: showFiles ? "◀ Hide files" : "▶ Show files"
|
|
2085
|
+
}), file && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
2086
|
+
className: "file-panel-current",
|
|
2087
|
+
children: file
|
|
2088
|
+
})]
|
|
2089
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
2090
|
+
className: `file-panel${!showFiles ? " no-list" : ""}${!file ? " no-preview" : ""}`,
|
|
2091
|
+
children: [showFiles && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FileList, {
|
|
2092
|
+
files,
|
|
2093
|
+
lang,
|
|
2094
|
+
activeFile: file,
|
|
2095
|
+
selected,
|
|
2096
|
+
statusFilter: status,
|
|
2097
|
+
sectionFilter: section,
|
|
2098
|
+
onStatusFilter: setStatusFilter,
|
|
2099
|
+
onSectionFilter: setSectionFilter,
|
|
2100
|
+
onSelect: setFile,
|
|
2101
|
+
onToggle: handleToggle,
|
|
2102
|
+
onSelectAll: handleSelectAll,
|
|
2103
|
+
onClear: handleClear,
|
|
2104
|
+
onTranslateSelected: handleTranslateSelected
|
|
2105
|
+
}), file && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Preview, {
|
|
2106
|
+
version,
|
|
2107
|
+
lang,
|
|
2108
|
+
file,
|
|
2109
|
+
viewMode: view,
|
|
2110
|
+
onViewMode: setView,
|
|
2111
|
+
showToc: toc,
|
|
2112
|
+
onToggleToc: () => setToc(!toc),
|
|
2113
|
+
showNodes: nodes,
|
|
2114
|
+
onToggleNodes: () => setNodes(!nodes),
|
|
2115
|
+
onClose: () => setFile(null)
|
|
2116
|
+
})]
|
|
2117
|
+
})] })
|
|
2118
|
+
]
|
|
2119
|
+
}),
|
|
2120
|
+
toast && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
2121
|
+
className: "toast",
|
|
2122
|
+
children: toast
|
|
2123
|
+
}),
|
|
2124
|
+
showDialog && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(JobDialog, {
|
|
2125
|
+
langs: statusData.langs,
|
|
2126
|
+
versions: statusData.versions,
|
|
2127
|
+
defaultLang: lang || void 0,
|
|
2128
|
+
defaultVersion: version,
|
|
2129
|
+
files: dialogFiles,
|
|
2130
|
+
onClose: () => setShowDialog(false),
|
|
2131
|
+
onSuccess: (msg) => {
|
|
2132
|
+
setShowDialog(false);
|
|
2133
|
+
setToast(msg);
|
|
2134
|
+
}
|
|
2135
|
+
})
|
|
2136
|
+
] });
|
|
2137
|
+
}
|
|
2138
|
+
//#endregion
|
|
2139
|
+
export { AdminPage as component };
|