ludicord 2.2.5 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -4
- package/dist/activity/game-loop.d.ts +16 -0
- package/dist/activity/game-loop.js +33 -0
- package/dist/activity/index.d.ts +12 -0
- package/dist/activity/index.js +6 -0
- package/dist/activity/lifecycle.d.ts +11 -0
- package/dist/activity/lifecycle.js +41 -0
- package/dist/activity/presence.d.ts +10 -0
- package/dist/activity/presence.js +15 -0
- package/dist/activity/query.d.ts +21 -0
- package/dist/activity/query.js +148 -0
- package/dist/activity/shared-state.d.ts +10 -0
- package/dist/activity/shared-state.js +100 -0
- package/dist/activity/storage.d.ts +16 -0
- package/dist/activity/storage.js +88 -0
- package/dist/api/runtime.d.ts +5 -2
- package/dist/api/runtime.js +53 -10
- package/dist/auth/client.d.ts +0 -1
- package/dist/auth/client.js +3 -5
- package/dist/auth/index.d.ts +0 -1
- package/dist/auth/index.js +0 -1
- package/dist/auth/server.d.ts +2 -1
- package/dist/auth/server.js +161 -16
- package/dist/auth/types.d.ts +5 -1
- package/dist/auth/types.js +0 -1
- package/dist/cli/index.d.ts +0 -1
- package/dist/cli/index.js +116 -19
- package/dist/cli/project-commands.d.ts +1 -5
- package/dist/cli/project-commands.js +14 -162
- package/dist/compiler/build.d.ts +10 -1
- package/dist/compiler/build.js +124 -16
- package/dist/compiler/bundle-report.d.ts +17 -0
- package/dist/compiler/bundle-report.js +60 -0
- package/dist/compiler/client-entry.d.ts +0 -1
- package/dist/compiler/client-entry.js +28 -4
- package/dist/compiler/client-tooling.d.ts +0 -1
- package/dist/compiler/client-tooling.js +8 -2
- package/dist/compiler/index.d.ts +3 -1
- package/dist/compiler/index.js +2 -1
- package/dist/compiler/scanner.d.ts +0 -1
- package/dist/compiler/scanner.js +59 -4
- package/dist/compiler/server-bundle.d.ts +1 -2
- package/dist/compiler/server-bundle.js +11 -2
- package/dist/compiler/type-generation.d.ts +0 -1
- package/dist/compiler/type-generation.js +2 -1
- package/dist/compiler/write-manifests.d.ts +0 -1
- package/dist/compiler/write-manifests.js +0 -1
- package/dist/config/defaults.d.ts +0 -1
- package/dist/config/defaults.js +14 -2
- package/dist/config/environment.d.ts +0 -1
- package/dist/config/environment.js +0 -1
- package/dist/config/index.d.ts +0 -1
- package/dist/config/index.js +0 -1
- package/dist/config/loader.d.ts +0 -1
- package/dist/config/loader.js +0 -1
- package/dist/config/project-root.d.ts +0 -1
- package/dist/config/project-root.js +0 -1
- package/dist/config/types.d.ts +25 -1
- package/dist/config/types.js +0 -1
- package/dist/discord/assets.d.ts +5 -0
- package/dist/discord/assets.js +29 -0
- package/dist/discord/data.d.ts +38 -2
- package/dist/discord/data.js +178 -11
- package/dist/discord/events.d.ts +28 -2
- package/dist/discord/events.js +109 -39
- package/dist/discord/index.d.ts +6 -5
- package/dist/discord/index.js +3 -3
- package/dist/discord/payload.d.ts +6 -0
- package/dist/discord/payload.js +5 -0
- package/dist/discord/runtime.d.ts +0 -1
- package/dist/discord/runtime.js +0 -1
- package/dist/discord/safe-area.d.ts +0 -1
- package/dist/discord/safe-area.js +0 -1
- package/dist/discord/testing.d.ts +0 -1
- package/dist/discord/testing.js +0 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +3 -1
- package/dist/lint/index.d.ts +6 -0
- package/dist/lint/index.js +71 -0
- package/dist/manifests/types.d.ts +11 -1
- package/dist/manifests/types.js +0 -1
- package/dist/metadata/index.d.ts +13 -0
- package/dist/metadata/index.js +4 -0
- package/dist/navigation/index.d.ts +3 -1
- package/dist/navigation/index.js +1 -1
- package/dist/navigation/link.d.ts +8 -0
- package/dist/navigation/link.js +38 -0
- package/dist/router/match.d.ts +0 -1
- package/dist/router/match.js +0 -1
- package/dist/runtime/client/dev-panel.d.ts +0 -1
- package/dist/runtime/client/dev-panel.js +722 -38
- package/dist/runtime/client/embed-router.d.ts +8 -1
- package/dist/runtime/client/embed-router.js +116 -62
- package/dist/runtime/client/files.d.ts +5 -1
- package/dist/runtime/client/files.js +0 -1
- package/dist/runtime/client/minimize-card.d.ts +0 -1
- package/dist/runtime/client/minimize-card.js +0 -1
- package/dist/runtime/client/minimize.d.ts +0 -1
- package/dist/runtime/client/minimize.js +0 -1
- package/dist/runtime/client/root.d.ts +5 -3
- package/dist/runtime/client/root.js +28 -3
- package/dist/runtime/index.d.ts +1 -2
- package/dist/runtime/index.js +0 -1
- package/dist/runtime/server/dev-server.d.ts +0 -1
- package/dist/runtime/server/dev-server.js +187 -30
- package/dist/runtime/server/diagnostics.d.ts +1 -1
- package/dist/runtime/server/diagnostics.js +5 -4
- package/dist/runtime/server/index.d.ts +0 -1
- package/dist/runtime/server/index.js +0 -1
- package/dist/runtime/server/production-server.d.ts +2 -1
- package/dist/runtime/server/production-server.js +145 -25
- package/dist/security/discord.d.ts +0 -1
- package/dist/security/discord.js +0 -1
- package/dist/security/index.d.ts +0 -1
- package/dist/security/index.js +0 -1
- package/dist/security/secret-scan.d.ts +0 -1
- package/dist/security/secret-scan.js +0 -1
- package/dist/server/discord-rest.d.ts +42 -7
- package/dist/server/discord-rest.js +135 -18
- package/dist/server/index.d.ts +7 -2
- package/dist/server/index.js +3 -1
- package/dist/server/instrumentation.d.ts +16 -0
- package/dist/server/instrumentation.js +3 -0
- package/dist/server/proxy.d.ts +21 -0
- package/dist/server/proxy.js +76 -0
- package/dist/server/session.d.ts +0 -1
- package/dist/server/session.js +0 -1
- package/dist/server/types.d.ts +0 -1
- package/dist/server/types.js +0 -1
- package/dist/sessions/cookies.d.ts +0 -1
- package/dist/sessions/cookies.js +0 -1
- package/dist/sessions/crypto.d.ts +0 -1
- package/dist/sessions/crypto.js +0 -1
- package/dist/sessions/data-store.d.ts +18 -0
- package/dist/sessions/data-store.js +45 -0
- package/dist/shared/errors.d.ts +0 -1
- package/dist/shared/errors.js +0 -1
- package/dist/testing/index.d.ts +0 -1
- package/dist/testing/index.js +2 -2
- package/dist/version.d.ts +1 -2
- package/dist/version.js +1 -2
- package/dist/ws/client.d.ts +0 -1
- package/dist/ws/client.js +0 -1
- package/dist/ws/index.d.ts +3 -2
- package/dist/ws/index.js +1 -1
- package/dist/ws/server.d.ts +5 -3
- package/dist/ws/server.js +65 -19
- package/dist/ws/shared-state.d.ts +13 -0
- package/dist/ws/shared-state.js +137 -0
- package/package.json +14 -1
|
@@ -7,6 +7,14 @@ export interface LudicordEmbedModule {
|
|
|
7
7
|
export interface LudicordEmbedDefinition {
|
|
8
8
|
readonly route: string;
|
|
9
9
|
readonly load: () => Promise<LudicordEmbedModule>;
|
|
10
|
+
readonly loading?: ComponentType;
|
|
11
|
+
readonly error?: ComponentType<{
|
|
12
|
+
readonly error: Error;
|
|
13
|
+
readonly reset: () => void;
|
|
14
|
+
}>;
|
|
15
|
+
readonly layouts?: readonly ComponentType<{
|
|
16
|
+
readonly children: ReactNode;
|
|
17
|
+
}>[];
|
|
10
18
|
}
|
|
11
19
|
export interface LudicordActivityProps {
|
|
12
20
|
readonly defaultEmbed: string;
|
|
@@ -47,4 +55,3 @@ export declare function LudicordLoadingBoundary({ children, fallback, }: {
|
|
|
47
55
|
readonly fallback?: ReactNode;
|
|
48
56
|
}): import("react").JSX.Element;
|
|
49
57
|
export {};
|
|
50
|
-
//# sourceMappingURL=embed-router.d.ts.map
|
|
@@ -8,7 +8,9 @@ import { useOptionalLudicordMinimize } from "./minimize.js";
|
|
|
8
8
|
import { useLudicordFiles, isDevelopmentRuntime, reportClientError } from "./files.js";
|
|
9
9
|
import { installLudicordSafeAreaVariables } from "../../discord/safe-area.js";
|
|
10
10
|
const EmbedContext = createContext(null);
|
|
11
|
+
const HISTORY_INDEX = "__ludicordEmbedIndex";
|
|
11
12
|
const lazyComponentCache = new WeakMap();
|
|
13
|
+
const modulePromiseCache = new WeakMap();
|
|
12
14
|
export class LudicordEmbedNotFoundError extends Error {
|
|
13
15
|
code = "LUDICORD2001";
|
|
14
16
|
constructor(path) {
|
|
@@ -101,16 +103,29 @@ function globalDefinitions() {
|
|
|
101
103
|
const registry = globalThis.__LUDICORD_EMBEDS__;
|
|
102
104
|
if (registry === undefined)
|
|
103
105
|
return [];
|
|
104
|
-
return Object.entries(registry).map(([route,
|
|
106
|
+
return Object.entries(registry).map(([route, definition]) => typeof definition === "function"
|
|
107
|
+
? { route, load: definition }
|
|
108
|
+
: { route, ...definition });
|
|
105
109
|
}
|
|
106
110
|
function getLazyComponent(definition) {
|
|
107
111
|
const cached = lazyComponentCache.get(definition.load);
|
|
108
112
|
if (cached !== undefined)
|
|
109
113
|
return cached;
|
|
110
|
-
const component = lazy(definition
|
|
114
|
+
const component = lazy(() => loadEmbedModule(definition));
|
|
111
115
|
lazyComponentCache.set(definition.load, component);
|
|
112
116
|
return component;
|
|
113
117
|
}
|
|
118
|
+
function loadEmbedModule(definition) {
|
|
119
|
+
const cached = modulePromiseCache.get(definition.load);
|
|
120
|
+
if (cached !== undefined)
|
|
121
|
+
return cached;
|
|
122
|
+
const promise = definition.load().catch((error) => {
|
|
123
|
+
modulePromiseCache.delete(definition.load);
|
|
124
|
+
throw error;
|
|
125
|
+
});
|
|
126
|
+
modulePromiseCache.set(definition.load, promise);
|
|
127
|
+
return promise;
|
|
128
|
+
}
|
|
114
129
|
function useEmbedContext() {
|
|
115
130
|
const context = useContext(EmbedContext);
|
|
116
131
|
if (context === null) {
|
|
@@ -139,88 +154,104 @@ export function LudicordActivity({ defaultEmbed, children, embeds, loading = nul
|
|
|
139
154
|
const definitions = useMemo(() => [...(embeds ?? globalDefinitions())], [embeds]);
|
|
140
155
|
const initialPath = normalizeEmbedPath(defaultEmbed);
|
|
141
156
|
const [state, setState] = useState(() => {
|
|
142
|
-
|
|
143
|
-
try {
|
|
144
|
-
path = findMatch(definitions, hashEmbedPath(initialPath)).path;
|
|
145
|
-
}
|
|
146
|
-
catch {
|
|
147
|
-
if (typeof window !== "undefined")
|
|
148
|
-
window.history.replaceState(null, "", embedHash(initialPath, initialPath));
|
|
149
|
-
}
|
|
157
|
+
const path = hashEmbedPath(initialPath);
|
|
150
158
|
return { entries: [path], index: 0 };
|
|
151
159
|
});
|
|
152
160
|
useEffect(() => {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
161
|
+
const historyState = window.history.state;
|
|
162
|
+
window.history.replaceState(historyState !== null && typeof historyState === "object"
|
|
163
|
+
? { ...historyState, [HISTORY_INDEX]: 0 }
|
|
164
|
+
: { [HISTORY_INDEX]: 0 }, "", window.location.hash === "" ? "#/" : window.location.href);
|
|
165
|
+
const onLocationChange = (event) => {
|
|
156
166
|
const nextPath = hashEmbedPath(initialPath);
|
|
157
|
-
try {
|
|
158
|
-
findMatch(definitions, nextPath);
|
|
159
|
-
}
|
|
160
|
-
catch (cause) {
|
|
161
|
-
reportClientError(cause instanceof Error ? cause : new Error(String(cause)));
|
|
162
|
-
window.history.replaceState(null, "", embedHash(initialPath, initialPath));
|
|
163
|
-
setState({ entries: [initialPath], index: 0 });
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
167
|
setState((current) => {
|
|
168
|
+
const eventState = "state" in event ? event.state : undefined;
|
|
169
|
+
const historyIndex = eventState !== null &&
|
|
170
|
+
typeof eventState === "object" &&
|
|
171
|
+
typeof eventState[HISTORY_INDEX] === "number"
|
|
172
|
+
? eventState[HISTORY_INDEX]
|
|
173
|
+
: undefined;
|
|
174
|
+
if (historyIndex !== undefined &&
|
|
175
|
+
historyIndex >= 0 &&
|
|
176
|
+
historyIndex < current.entries.length &&
|
|
177
|
+
current.entries[historyIndex] === nextPath) {
|
|
178
|
+
return { ...current, index: historyIndex };
|
|
179
|
+
}
|
|
167
180
|
const currentPath = current.entries[current.index];
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
181
|
+
if (currentPath === nextPath)
|
|
182
|
+
return current;
|
|
183
|
+
const existingIndex = current.entries.lastIndexOf(nextPath);
|
|
184
|
+
if (existingIndex >= 0)
|
|
185
|
+
return { ...current, index: existingIndex };
|
|
186
|
+
const entries = [...current.entries.slice(0, current.index + 1), nextPath];
|
|
187
|
+
window.history.replaceState({ [HISTORY_INDEX]: entries.length - 1 }, "", window.location.href);
|
|
188
|
+
return { entries, index: entries.length - 1 };
|
|
174
189
|
});
|
|
175
190
|
};
|
|
176
|
-
window.addEventListener("hashchange",
|
|
177
|
-
|
|
178
|
-
|
|
191
|
+
window.addEventListener("hashchange", onLocationChange);
|
|
192
|
+
window.addEventListener("popstate", onLocationChange);
|
|
193
|
+
return () => {
|
|
194
|
+
window.removeEventListener("hashchange", onLocationChange);
|
|
195
|
+
window.removeEventListener("popstate", onLocationChange);
|
|
196
|
+
};
|
|
197
|
+
}, [initialPath]);
|
|
179
198
|
const currentPath = state.entries[state.index] ?? initialPath;
|
|
180
|
-
const match = useMemo(() =>
|
|
199
|
+
const match = useMemo(() => {
|
|
200
|
+
try {
|
|
201
|
+
return findMatch(definitions, currentPath);
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
if (error instanceof LudicordEmbedNotFoundError)
|
|
205
|
+
return null;
|
|
206
|
+
throw error;
|
|
207
|
+
}
|
|
208
|
+
}, [currentPath, definitions]);
|
|
181
209
|
const push = useCallback((path) => {
|
|
182
210
|
const normalized = normalizeEmbedPath(path);
|
|
183
211
|
findMatch(definitions, normalized);
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
})
|
|
190
|
-
}, [definitions, initialPath]);
|
|
212
|
+
const entries = [...state.entries.slice(0, state.index + 1), normalized];
|
|
213
|
+
const index = state.index + 1;
|
|
214
|
+
if (typeof window !== "undefined") {
|
|
215
|
+
window.history.pushState({ [HISTORY_INDEX]: index }, "", embedHash(normalized, initialPath));
|
|
216
|
+
}
|
|
217
|
+
setState({ entries, index });
|
|
218
|
+
}, [definitions, initialPath, state]);
|
|
191
219
|
const replace = useCallback((path) => {
|
|
192
220
|
const normalized = normalizeEmbedPath(path);
|
|
193
221
|
findMatch(definitions, normalized);
|
|
194
222
|
if (typeof window !== "undefined")
|
|
195
|
-
window.history.replaceState(
|
|
196
|
-
setState(
|
|
197
|
-
entries:
|
|
198
|
-
index:
|
|
199
|
-
}));
|
|
200
|
-
}, [definitions, initialPath]);
|
|
201
|
-
const back = useCallback(() => {
|
|
202
|
-
setState((current) => {
|
|
203
|
-
if (current.index === 0)
|
|
204
|
-
return current;
|
|
205
|
-
const previousPath = current.entries[current.index - 1];
|
|
206
|
-
if (previousPath !== undefined && typeof window !== "undefined") {
|
|
207
|
-
window.history.replaceState(null, "", embedHash(previousPath, initialPath));
|
|
208
|
-
}
|
|
209
|
-
return { ...current, index: current.index - 1 };
|
|
223
|
+
window.history.replaceState({ [HISTORY_INDEX]: state.index }, "", embedHash(normalized, initialPath));
|
|
224
|
+
setState({
|
|
225
|
+
entries: state.entries.map((entry, index) => index === state.index ? normalized : entry),
|
|
226
|
+
index: state.index,
|
|
210
227
|
});
|
|
211
|
-
}, [initialPath]);
|
|
228
|
+
}, [definitions, initialPath, state]);
|
|
229
|
+
const back = useCallback(() => {
|
|
230
|
+
if (state.index === 0)
|
|
231
|
+
return;
|
|
232
|
+
setState({ ...state, index: state.index - 1 });
|
|
233
|
+
if (typeof window !== "undefined")
|
|
234
|
+
window.history.back();
|
|
235
|
+
}, [state]);
|
|
236
|
+
const prefetch = useCallback(async (path) => {
|
|
237
|
+
const normalized = normalizeEmbedPath(path);
|
|
238
|
+
const selected = findMatch(definitions, normalized);
|
|
239
|
+
await loadEmbedModule(selected.definition);
|
|
240
|
+
}, [definitions]);
|
|
212
241
|
const router = useMemo(() => ({
|
|
213
242
|
push: push,
|
|
214
243
|
replace: replace,
|
|
244
|
+
prefetch: prefetch,
|
|
215
245
|
back,
|
|
216
246
|
canGoBack: state.index > 0,
|
|
217
|
-
}), [back, push, replace, state.index]);
|
|
247
|
+
}), [back, prefetch, push, replace, state.index]);
|
|
218
248
|
const value = useMemo(() => ({
|
|
219
249
|
router,
|
|
220
250
|
match,
|
|
251
|
+
path: currentPath,
|
|
221
252
|
loading: loading ?? (Loading === undefined ? null : _jsx(Loading, {})),
|
|
222
253
|
...(errorFallback !== undefined ? { errorFallback } : ErrorFile === undefined ? {} : { errorFallback: (error) => _jsx(ErrorFile, { error: error, reset: () => window.dispatchEvent(new Event("ludicord:recover")) }) }),
|
|
223
|
-
}), [errorFallback, loading, match, router, Loading, ErrorFile]);
|
|
254
|
+
}), [currentPath, errorFallback, loading, match, router, Loading, ErrorFile]);
|
|
224
255
|
return _jsx(EmbedContext.Provider, { value: value, children: _jsxs(ActivityAuthGate, { children: [_jsx("div", { hidden: minimized, style: { display: minimized ? "none" : "contents" }, children: children }), minimized && Minimized !== undefined ? _jsx(Minimized, {}) : null] }) });
|
|
225
256
|
}
|
|
226
257
|
function ActivityAuthGate({ children }) {
|
|
@@ -247,18 +278,42 @@ function ActivityAuthGate({ children }) {
|
|
|
247
278
|
return Loading === undefined ? _jsx("main", { role: "status", style: { padding: 24, fontFamily: "system-ui" }, children: "Connecting to Discord\u2026" }) : _jsx(Loading, {});
|
|
248
279
|
}
|
|
249
280
|
export function EmbedOutlet() {
|
|
250
|
-
const { match, loading, errorFallback } = useEmbedContext();
|
|
281
|
+
const { match, path, router, loading, errorFallback } = useEmbedContext();
|
|
282
|
+
const files = useLudicordFiles();
|
|
283
|
+
if (match === null) {
|
|
284
|
+
const NotFound = files.notFound;
|
|
285
|
+
return NotFound === undefined
|
|
286
|
+
? _jsx(DefaultNotFound, { path: path, router: router })
|
|
287
|
+
: _jsx(NotFound, {});
|
|
288
|
+
}
|
|
251
289
|
const Embed = getLazyComponent(match.definition);
|
|
252
|
-
|
|
290
|
+
const RouteLoading = match.definition.loading;
|
|
291
|
+
const RouteError = match.definition.error;
|
|
292
|
+
const reset = () => window.dispatchEvent(new Event("ludicord:recover"));
|
|
293
|
+
const routeFallback = RouteLoading === undefined ? loading : _jsx(RouteLoading, {});
|
|
294
|
+
const routeErrorFallback = RouteError === undefined
|
|
295
|
+
? errorFallback
|
|
296
|
+
: (error) => _jsx(RouteError, { error: error, reset: reset });
|
|
297
|
+
const content = (match.definition.layouts ?? []).reduceRight((children, Layout) => _jsx(Layout, { children: children }), _jsx(Embed, {}));
|
|
298
|
+
return (_jsx(LudicordErrorBoundary, { fallback: routeErrorFallback, resetKey: match.path, children: _jsx(LudicordLoadingBoundary, { fallback: routeFallback, children: content }) }));
|
|
253
299
|
}
|
|
254
300
|
export function useEmbedRouter() {
|
|
255
301
|
return useEmbedContext().router;
|
|
256
302
|
}
|
|
257
303
|
export function useEmbedPath() {
|
|
258
|
-
return useEmbedContext().
|
|
304
|
+
return useEmbedContext().path;
|
|
259
305
|
}
|
|
260
306
|
export function useEmbedParams() {
|
|
261
|
-
return useEmbedContext().match
|
|
307
|
+
return (useEmbedContext().match?.params ?? {});
|
|
308
|
+
}
|
|
309
|
+
function DefaultNotFound({ path, router }) {
|
|
310
|
+
const goBack = () => {
|
|
311
|
+
if (router.canGoBack)
|
|
312
|
+
router.back();
|
|
313
|
+
else if (typeof window !== "undefined")
|
|
314
|
+
window.history.back();
|
|
315
|
+
};
|
|
316
|
+
return _jsx("main", { "data-ludicord-not-found": "", style: { minHeight: "100vh", display: "grid", placeItems: "center", padding: 24, color: "#f5f5f5", background: "#0a0a0a", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }, children: _jsxs("section", { role: "alert", "aria-labelledby": "ludicord-not-found-title", style: { width: "min(100%, 320px)" }, children: [_jsxs("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", style: { marginBottom: 14 }, children: [_jsx("path", { d: "M12 3 2.8 20h18.4L12 3Z", stroke: "currentColor", strokeWidth: "1.8", strokeLinejoin: "round" }), _jsx("path", { d: "M12 9v5m0 3.2v.1", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round" })] }), _jsx("h1", { id: "ludicord-not-found-title", style: { margin: "0 0 8px", fontSize: 20, lineHeight: 1.35, letterSpacing: "-.02em" }, children: "This page couldn\u2019t load" }), _jsxs("p", { style: { margin: "0 0 18px", color: "#a3a3a3", fontSize: 13, lineHeight: 1.6 }, children: ["The Activity route ", _jsx("code", { style: { color: "#d4d4d4" }, children: path }), " wasn\u2019t found. Reload to try again, or go back."] }), _jsxs("div", { style: { display: "flex", gap: 8 }, children: [_jsx("button", { type: "button", onClick: () => window.location.reload(), style: { padding: "7px 12px", border: "1px solid #e5e5e5", borderRadius: 6, color: "#111", background: "#f5f5f5", font: "inherit", fontSize: 13, fontWeight: 600, cursor: "pointer" }, children: "Reload" }), _jsx("button", { type: "button", onClick: goBack, style: { padding: "7px 12px", border: "1px solid #292929", borderRadius: 6, color: "#e5e5e5", background: "#111", font: "inherit", fontSize: 13, cursor: "pointer" }, children: "Back" })] })] }) });
|
|
262
317
|
}
|
|
263
318
|
export class LudicordErrorBoundary extends Component {
|
|
264
319
|
state = { error: null };
|
|
@@ -292,4 +347,3 @@ export class LudicordErrorBoundary extends Component {
|
|
|
292
347
|
export function LudicordLoadingBoundary({ children, fallback = null, }) {
|
|
293
348
|
return _jsx(Suspense, { fallback: fallback, children: children });
|
|
294
349
|
}
|
|
295
|
-
//# sourceMappingURL=embed-router.js.map
|
|
@@ -8,6 +8,11 @@ export interface LudicordFileComponents {
|
|
|
8
8
|
readonly error: Error;
|
|
9
9
|
readonly reset: () => void;
|
|
10
10
|
}>;
|
|
11
|
+
readonly globalError?: ComponentType<{
|
|
12
|
+
readonly error: Error;
|
|
13
|
+
readonly reset: () => void;
|
|
14
|
+
}>;
|
|
15
|
+
readonly notFound?: ComponentType;
|
|
11
16
|
readonly minimize?: ComponentType;
|
|
12
17
|
readonly authLoading?: ComponentType;
|
|
13
18
|
readonly authError?: ComponentType<{
|
|
@@ -20,4 +25,3 @@ export declare const LudicordFilesContext: import("react").Context<LudicordFileC
|
|
|
20
25
|
export declare function useLudicordFiles(): LudicordFileComponents;
|
|
21
26
|
export declare function isDevelopmentRuntime(): boolean;
|
|
22
27
|
export declare function reportClientError(error: Error, componentStack?: string | null): void;
|
|
23
|
-
//# sourceMappingURL=files.d.ts.map
|
|
@@ -10,4 +10,3 @@ export interface MinimizeProps {
|
|
|
10
10
|
readonly children?: ReactNode;
|
|
11
11
|
}
|
|
12
12
|
export declare function Minimize({ heading, message, author: customAuthor, channelName: customChannelName, timestamp, avatar: customAvatar, card, children, }?: MinimizeProps): import("react").JSX.Element;
|
|
13
|
-
//# sourceMappingURL=minimize-card.d.ts.map
|
|
@@ -12,4 +12,3 @@ export interface LudicordMinimizeProviderProps {
|
|
|
12
12
|
export declare function LudicordMinimizeProvider({ children, defaultMinimized, }: LudicordMinimizeProviderProps): import("react").JSX.Element;
|
|
13
13
|
export declare function useLudicordMinimize(): LudicordMinimizeState;
|
|
14
14
|
export declare function useOptionalLudicordMinimize(): LudicordMinimizeState | null;
|
|
15
|
-
//# sourceMappingURL=minimize.d.ts.map
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { LudicordFileComponents } from "./files.js";
|
|
3
|
-
|
|
3
|
+
import type { LudicordMetadata } from "../../metadata/index.js";
|
|
4
|
+
export interface LudicordRootProps {
|
|
4
5
|
readonly children: ReactNode;
|
|
5
6
|
readonly files?: LudicordFileComponents;
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
readonly metadata?: LudicordMetadata;
|
|
8
|
+
}
|
|
9
|
+
export declare function LudicordRoot({ children, files, metadata }: LudicordRootProps): import("react").JSX.Element;
|
|
@@ -3,8 +3,34 @@ import { useEffect, useState } from "react";
|
|
|
3
3
|
import { LudicordErrorBoundary, LudicordLoadingBoundary } from "./embed-router.js";
|
|
4
4
|
import { LudicordMinimizeProvider } from "./minimize.js";
|
|
5
5
|
import { LudicordFilesContext } from "./files.js";
|
|
6
|
-
|
|
6
|
+
function metadataTitle(title) {
|
|
7
|
+
return typeof title === "string" ? title : title?.default;
|
|
8
|
+
}
|
|
9
|
+
function updateMeta(name, content) {
|
|
10
|
+
const selector = `meta[name="${name}"][data-ludicord-metadata]`;
|
|
11
|
+
const current = document.head.querySelector(selector);
|
|
12
|
+
if (content === undefined) {
|
|
13
|
+
current?.remove();
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const element = current ?? document.createElement("meta");
|
|
17
|
+
element.name = name;
|
|
18
|
+
element.content = content;
|
|
19
|
+
element.dataset.ludicordMetadata = "";
|
|
20
|
+
if (current === null)
|
|
21
|
+
document.head.append(element);
|
|
22
|
+
}
|
|
23
|
+
export function LudicordRoot({ children, files = {}, metadata }) {
|
|
7
24
|
const [revision, setRevision] = useState(0);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const title = metadataTitle(metadata?.title);
|
|
27
|
+
if (title !== undefined)
|
|
28
|
+
document.title = title;
|
|
29
|
+
updateMeta("description", metadata?.description);
|
|
30
|
+
updateMeta("application-name", metadata?.applicationName);
|
|
31
|
+
updateMeta("theme-color", metadata?.themeColor);
|
|
32
|
+
updateMeta("color-scheme", metadata?.colorScheme);
|
|
33
|
+
}, [metadata]);
|
|
8
34
|
useEffect(() => {
|
|
9
35
|
const recover = () => setRevision((value) => value + 1);
|
|
10
36
|
window.addEventListener("ludicord:recover", recover);
|
|
@@ -12,8 +38,7 @@ export function LudicordRoot({ children, files = {} }) {
|
|
|
12
38
|
}, []);
|
|
13
39
|
const Layout = files.layout;
|
|
14
40
|
const Loading = files.loading;
|
|
15
|
-
const ErrorFile = files.error;
|
|
41
|
+
const ErrorFile = files.globalError ?? files.error;
|
|
16
42
|
const reset = () => setRevision((value) => value + 1);
|
|
17
43
|
return _jsx(LudicordFilesContext.Provider, { value: files, children: _jsx(LudicordMinimizeProvider, { children: _jsx(LudicordErrorBoundary, { resetKey: String(revision), fallback: ErrorFile === undefined ? undefined : (error) => _jsx(ErrorFile, { error: error, reset: reset }), children: _jsx(LudicordLoadingBoundary, { fallback: Loading === undefined ? null : _jsx(Loading, {}), children: Layout === undefined ? children : _jsx(Layout, { children: children }) }) }) }) });
|
|
18
44
|
}
|
|
19
|
-
//# sourceMappingURL=root.js.map
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export declare function useLudicordRuntime(): {
|
|
2
2
|
readonly environment: string;
|
|
3
|
-
readonly version: "
|
|
3
|
+
readonly version: "3.0.0";
|
|
4
4
|
readonly activityReady: boolean;
|
|
5
5
|
readonly discordReady: boolean;
|
|
6
6
|
readonly authStatus: import("../auth/types.js").LudicordAuthStatus;
|
|
7
7
|
readonly wsReady: boolean;
|
|
8
8
|
};
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/runtime/index.js
CHANGED
|
@@ -12,4 +12,3 @@ export function useLudicordRuntime() {
|
|
|
12
12
|
const config = globalThis.__LUDICORD_PUBLIC_CONFIG__;
|
|
13
13
|
return { environment: config?.environment ?? "production", version: LUDICORD_VERSION, activityReady, discordReady: discord.status === "ready", authStatus, wsReady };
|
|
14
14
|
}
|
|
15
|
-
//# sourceMappingURL=index.js.map
|