ludicord 4.0.1 → 4.1.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/AGENTS.md +2 -0
- package/README.md +5 -1
- package/dist/compiler/build.js +9 -2
- package/dist/compiler/plugin-runtime.d.ts +5 -0
- package/dist/compiler/plugin-runtime.js +155 -0
- package/dist/compiler/server-bundle.d.ts +2 -1
- package/dist/compiler/server-bundle.js +4 -1
- package/dist/compiler/type-generation.js +18 -2
- package/dist/config/defaults.js +18 -0
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +1 -1
- package/dist/config/types.d.ts +32 -0
- package/dist/config/types.js +3 -0
- package/dist/docs/README.md +2 -1
- package/dist/docs/activity-rooms.md +1 -1
- package/dist/docs/ai-agents.md +1 -1
- package/dist/docs/api-reference.md +6 -2
- package/dist/docs/api-routes.md +1 -1
- package/dist/docs/build.md +1 -1
- package/dist/docs/cli.md +1 -1
- package/dist/docs/configuration.md +9 -1
- package/dist/docs/deployment.md +1 -1
- package/dist/docs/development.md +1 -1
- package/dist/docs/discord-developer-portal.md +1 -1
- package/dist/docs/discord-sdk.md +1 -1
- package/dist/docs/distribution.md +1 -1
- package/dist/docs/embeds.md +1 -1
- package/dist/docs/environment-variables.md +1 -1
- package/dist/docs/getting-started.md +1 -1
- package/dist/docs/installation.md +2 -2
- package/dist/docs/login.md +1 -1
- package/dist/docs/migration.md +5 -5
- package/dist/docs/mobile-layout.md +1 -1
- package/dist/docs/navigation.md +1 -1
- package/dist/docs/pages.md +1 -1
- package/dist/docs/participants.md +1 -1
- package/dist/docs/plugins.md +93 -0
- package/dist/docs/prefix-router.md +1 -1
- package/dist/docs/project-structure.md +2 -1
- package/dist/docs/recipes.md +1 -1
- package/dist/docs/security.md +1 -1
- package/dist/docs/start.md +1 -1
- package/dist/docs/state-and-effects.md +1 -1
- package/dist/docs/troubleshooting.md +1 -1
- package/dist/docs/voice-events.md +1 -1
- package/dist/docs/websockets.md +1 -1
- package/dist/lint/index.js +1 -1
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/wasm.d.ts +7 -0
- package/dist/plugins/wasm.js +52 -0
- package/dist/runtime/server/dev-server.js +3 -2
- package/dist/skills/ludicord/SKILL.md +8 -3
- package/dist/skills/ludicord/manifest.yaml +4 -1
- package/dist/skills/ludicord/references/config-deploy.md +6 -1
- package/dist/version.js +1 -1
- package/package.json +27 -1
package/AGENTS.md
CHANGED
|
@@ -8,4 +8,6 @@ Ludicord's unified router uses `page.tsx` for pages, `route.ts` for HTTP methods
|
|
|
8
8
|
Default to one root page and ordinary embeds. Create independent pathname scopes only for a large project's separate surfaces or an important requirement for distinct URLs, shells, or provider lifetimes; explain the requirement before adding that architecture.
|
|
9
9
|
|
|
10
10
|
Keep secrets and authorization on the server. Run the relevant lint, type, route, production-build, and behavior checks before finishing.
|
|
11
|
+
|
|
12
|
+
Register trusted compiler extensions through `plugins` in `ludicord.config.mjs`. Read `dist/docs/plugins.md` before using `definePlugin()` or the official `wasm()` plugin; do not add a Vite config.
|
|
11
13
|
<!-- END:ludicord-agent-rules -->
|
package/README.md
CHANGED
|
@@ -22,7 +22,9 @@ ludicord build
|
|
|
22
22
|
ludicord start
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
Public entry points include `ludicord`, `ludicord/config`, `ludicord/metadata`, `ludicord/navigation`, `ludicord/activity`, `ludicord/discord`, `ludicord/auth`, `ludicord/server`, `ludicord/security`, `ludicord/ws`, `ludicord/ws/client`, `ludicord/ws/server`, `ludicord/runtime` (client status), `ludicord/runtime/server` (server tooling), and `ludicord/testing`.
|
|
25
|
+
Public entry points include `ludicord`, `ludicord/config`, `ludicord/plugins`, `ludicord/plugins/wasm`, `ludicord/metadata`, `ludicord/navigation`, `ludicord/activity`, `ludicord/discord`, `ludicord/auth`, `ludicord/server`, `ludicord/security`, `ludicord/ws`, `ludicord/ws/client`, `ludicord/ws/server`, `ludicord/runtime` (client status), `ludicord/runtime/server` (server tooling), and `ludicord/testing`.
|
|
26
|
+
|
|
27
|
+
Projects can register typed compiler extensions in `ludicord.config.mjs`. The official `wasm()` plugin adds portable `.wasm` imports to browser components and server routes while Ludicord keeps ownership of the underlying compiler configuration. See [Plugins and WebAssembly](https://github.com/mrcholer/ludicord/blob/main/docs/plugins.md).
|
|
26
28
|
|
|
27
29
|
See the public [documentation](https://github.com/mrcholer/ludicord/blob/main/docs/README.md), [release history](https://github.com/mrcholer/ludicord/blob/main/CHANGELOG.md), and [issue tracker](https://github.com/mrcholer/ludicord/issues). The public repository contains documentation and release information, not the framework implementation.
|
|
28
30
|
|
|
@@ -40,6 +42,8 @@ V4 includes the production authentication, Activity-launch isolation, realtime r
|
|
|
40
42
|
|
|
41
43
|
V4 also accepts the configured application's exact `https://<clientId>.discordsays.com` proxy origin by default for HTTP and WebSocket requests, alongside normal same-origin traffic. The framework derives the hostname from the Discord Application ID and does not trust wildcard Activity origins.
|
|
42
44
|
|
|
45
|
+
Ludicord 4.1 adds trusted compiler plugins through `ludicord.config.mjs`. `definePlugin()` provides portable client/server hooks, and the official `wasm()` plugin adds typed precompiled WebAssembly imports in both environments without exposing Ludicord's underlying compiler configuration.
|
|
46
|
+
|
|
43
47
|
## Version-matched AI guidance
|
|
44
48
|
|
|
45
49
|
Ludicord 4 includes offline docs at `node_modules/ludicord/dist/docs/`, the
|
package/dist/compiler/build.js
CHANGED
|
@@ -15,6 +15,7 @@ import { loadProjectEnvironment } from "../config/environment.js";
|
|
|
15
15
|
import { clientContainsSecret } from "../security/secret-scan.js";
|
|
16
16
|
import { checkProjectTypes } from "../runtime/server/diagnostics.js";
|
|
17
17
|
import { createBundleReport } from "./bundle-report.js";
|
|
18
|
+
import { vitePluginAdapters } from "./plugin-runtime.js";
|
|
18
19
|
const VIRTUAL_BUILD_ENTRY = "virtual:ludicord-production-entry";
|
|
19
20
|
const RESOLVED_BUILD_ENTRY = "\0virtual:ludicord-production-entry";
|
|
20
21
|
export const LUDICORD_BUILD_SCHEMA_VERSION = 4;
|
|
@@ -150,7 +151,11 @@ async function buildClient(projectRoot, outputDirectory, manifests, config) {
|
|
|
150
151
|
publicDir: existsSync(path.join(projectRoot, "public"))
|
|
151
152
|
? path.join(projectRoot, "public")
|
|
152
153
|
: false,
|
|
153
|
-
plugins: [
|
|
154
|
+
plugins: [
|
|
155
|
+
buildPlugin(projectRoot, manifests, config),
|
|
156
|
+
...vitePluginAdapters(config.plugins, projectRoot, "production"),
|
|
157
|
+
...await clientPlugins(projectRoot),
|
|
158
|
+
],
|
|
154
159
|
resolve: { alias: ludicordClientAliases(projectRoot, config.imports.aliases), dedupe: ["react", "react-dom"] },
|
|
155
160
|
build: {
|
|
156
161
|
outDir: path.join(outputDirectory, "client"),
|
|
@@ -255,7 +260,7 @@ export async function buildLudicordProject(projectRoot) {
|
|
|
255
260
|
if (typeErrors.length > 0)
|
|
256
261
|
throw new Error(typeErrors.map((item) => `${item.file ?? "TypeScript"}:${item.line ?? 1}:${item.column ?? 1}\n${item.message}\n${item.frame ?? ""}`).join("\n\n"));
|
|
257
262
|
const { clientEntry, bundleReport } = await buildClient(root, temporaryDirectory, manifests, config);
|
|
258
|
-
const graph = await bundleServerGraph(root, path.join(temporaryDirectory, "server"), manifests, config.imports.aliases);
|
|
263
|
+
const graph = await bundleServerGraph(root, path.join(temporaryDirectory, "server"), manifests, config.imports.aliases, config.plugins, "production");
|
|
259
264
|
const api = graph.bundles.filter((route) => route.kind === "api").map((route) => ({ source: route.source, bundle: `server/${route.bundle}` }));
|
|
260
265
|
const websocket = graph.bundles.filter((route) => route.kind === "ws").map((route) => ({ source: route.source, bundle: `server/${route.bundle}` }));
|
|
261
266
|
const instrumentationRoute = graph.bundles.find((route) => route.kind === "instrumentation");
|
|
@@ -268,6 +273,8 @@ export async function buildLudicordProject(projectRoot) {
|
|
|
268
273
|
: { source: proxyRoute.source, bundle: `server/${proxyRoute.bundle}` };
|
|
269
274
|
writeManifests(manifests, path.join(temporaryDirectory, "manifests"));
|
|
270
275
|
mkdirSync(path.join(temporaryDirectory, "types"), { recursive: true });
|
|
276
|
+
writeFileSync(path.join(temporaryDirectory, "types", "routes.d.ts"), readFileSync(path.join(root, "ludicord.generated.d.ts"), "utf8"), "utf8");
|
|
277
|
+
writeFileSync(path.join(temporaryDirectory, "types", "plugins.d.ts"), readFileSync(path.join(root, "ludicord.plugins.generated.d.ts"), "utf8"), "utf8");
|
|
271
278
|
writeFileSync(path.join(temporaryDirectory, "bundle-report.json"), `${JSON.stringify(bundleReport, null, 2)}\n`, "utf8");
|
|
272
279
|
const metadata = buildMetadata(clientEntry, api, websocket, instrumentation, proxy, bundleReport, config);
|
|
273
280
|
writeFileSync(path.join(temporaryDirectory, "build.json"), `${JSON.stringify(metadata, null, 2)}\n`, "utf8");
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Plugin as EsbuildPlugin } from "esbuild";
|
|
2
|
+
import type { Plugin as VitePlugin } from "vite";
|
|
3
|
+
import type { LudicordPlugin, LudicordPluginMode } from "../config/types.js";
|
|
4
|
+
export declare function vitePluginAdapters(plugins: readonly LudicordPlugin[], projectRoot: string, mode: LudicordPluginMode): VitePlugin[];
|
|
5
|
+
export declare function esbuildPluginAdapter(plugins: readonly LudicordPlugin[], projectRoot: string, mode: LudicordPluginMode): EsbuildPlugin | undefined;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
function pluginError(plugin, hook, error) {
|
|
4
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
5
|
+
return new Error(`LUDICORD8001: Plugin "${plugin.name}" failed in ${hook}: ${message}`, {
|
|
6
|
+
cause: error,
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
function resultCode(result) {
|
|
10
|
+
if (typeof result === "string")
|
|
11
|
+
return result;
|
|
12
|
+
return result?.code;
|
|
13
|
+
}
|
|
14
|
+
function loaderForFile(file) {
|
|
15
|
+
const extension = path.extname(file).slice(1).toLowerCase();
|
|
16
|
+
if (["js", "jsx", "ts", "tsx", "json", "text", "css"].includes(extension)) {
|
|
17
|
+
return extension;
|
|
18
|
+
}
|
|
19
|
+
if (extension === "mjs" || extension === "cjs")
|
|
20
|
+
return "js";
|
|
21
|
+
if (extension === "mts" || extension === "cts")
|
|
22
|
+
return "ts";
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
function context(projectRoot, mode, target) {
|
|
26
|
+
return { projectRoot, mode, target };
|
|
27
|
+
}
|
|
28
|
+
function orderedPlugins(plugins) {
|
|
29
|
+
const rank = (plugin) => plugin.enforce === "pre" ? 0 : plugin.enforce === "post" ? 2 : 1;
|
|
30
|
+
return [...plugins].sort((left, right) => rank(left) - rank(right));
|
|
31
|
+
}
|
|
32
|
+
export function vitePluginAdapters(plugins, projectRoot, mode) {
|
|
33
|
+
const hookContext = context(projectRoot, mode, "client");
|
|
34
|
+
return orderedPlugins(plugins).map((plugin) => ({
|
|
35
|
+
name: `ludicord:user:${plugin.name}`,
|
|
36
|
+
...(plugin.enforce === undefined ? {} : { enforce: plugin.enforce }),
|
|
37
|
+
async resolveId(id, importer) {
|
|
38
|
+
if (plugin.resolveId === undefined)
|
|
39
|
+
return undefined;
|
|
40
|
+
try {
|
|
41
|
+
return await plugin.resolveId(id, importer, hookContext);
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
throw pluginError(plugin, "resolveId", error);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
async load(id) {
|
|
48
|
+
if (plugin.load === undefined)
|
|
49
|
+
return undefined;
|
|
50
|
+
try {
|
|
51
|
+
const result = await plugin.load(id, hookContext);
|
|
52
|
+
if (result === null || result === undefined)
|
|
53
|
+
return undefined;
|
|
54
|
+
return typeof result === "string" ? result : { code: result.code, map: result.map ?? null };
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
throw pluginError(plugin, "load", error);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
async transform(code, id) {
|
|
61
|
+
if (plugin.transform === undefined)
|
|
62
|
+
return undefined;
|
|
63
|
+
try {
|
|
64
|
+
const result = await plugin.transform(code, id, hookContext);
|
|
65
|
+
if (result === null || result === undefined)
|
|
66
|
+
return undefined;
|
|
67
|
+
return typeof result === "string" ? result : { code: result.code, map: result.map ?? null };
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
throw pluginError(plugin, "transform", error);
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
export function esbuildPluginAdapter(plugins, projectRoot, mode) {
|
|
76
|
+
if (plugins.length === 0)
|
|
77
|
+
return undefined;
|
|
78
|
+
const hookContext = context(projectRoot, mode, "server");
|
|
79
|
+
const ordered = orderedPlugins(plugins);
|
|
80
|
+
return {
|
|
81
|
+
name: "ludicord:user-plugins",
|
|
82
|
+
setup(build) {
|
|
83
|
+
if (ordered.some((plugin) => plugin.resolveId !== undefined)) {
|
|
84
|
+
build.onResolve({ filter: /.*/ }, async (args) => {
|
|
85
|
+
for (const plugin of ordered) {
|
|
86
|
+
if (plugin.resolveId === undefined)
|
|
87
|
+
continue;
|
|
88
|
+
try {
|
|
89
|
+
const result = await plugin.resolveId(args.path, args.importer || undefined, hookContext);
|
|
90
|
+
if (result !== null && result !== undefined) {
|
|
91
|
+
if (path.isAbsolute(result))
|
|
92
|
+
return { path: result };
|
|
93
|
+
if (result.startsWith("\0") || /^[a-z][a-z0-9+.-]*:/i.test(result)) {
|
|
94
|
+
return { path: result, namespace: "ludicord-plugin" };
|
|
95
|
+
}
|
|
96
|
+
return { path: path.resolve(args.resolveDir || projectRoot, result) };
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
return { errors: [{ text: pluginError(plugin, "resolveId", error).message }] };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return undefined;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
build.onLoad({ filter: /.*/ }, async (args) => {
|
|
107
|
+
let code;
|
|
108
|
+
let loader;
|
|
109
|
+
for (const plugin of ordered) {
|
|
110
|
+
if (plugin.load === undefined)
|
|
111
|
+
continue;
|
|
112
|
+
try {
|
|
113
|
+
const result = await plugin.load(args.path, hookContext);
|
|
114
|
+
const loaded = resultCode(result);
|
|
115
|
+
if (loaded !== undefined) {
|
|
116
|
+
code = loaded;
|
|
117
|
+
if (typeof result === "object" && result !== null && result.loader !== undefined) {
|
|
118
|
+
loader = result.loader;
|
|
119
|
+
}
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
return { errors: [{ text: pluginError(plugin, "load", error).message }] };
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const transformers = ordered.filter((plugin) => plugin.transform !== undefined);
|
|
128
|
+
if (code === undefined && transformers.length > 0) {
|
|
129
|
+
loader = loaderForFile(args.path);
|
|
130
|
+
if (loader === undefined || loader === "text")
|
|
131
|
+
return undefined;
|
|
132
|
+
code = await readFile(args.path, "utf8");
|
|
133
|
+
}
|
|
134
|
+
if (code === undefined)
|
|
135
|
+
return undefined;
|
|
136
|
+
for (const plugin of transformers) {
|
|
137
|
+
try {
|
|
138
|
+
const result = await plugin.transform?.(code, args.path, hookContext);
|
|
139
|
+
const transformed = resultCode(result);
|
|
140
|
+
if (transformed !== undefined) {
|
|
141
|
+
code = transformed;
|
|
142
|
+
if (typeof result === "object" && result !== null && result.loader !== undefined) {
|
|
143
|
+
loader = result.loader;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
return { errors: [{ text: pluginError(plugin, "transform", error).message }] };
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return { contents: code, loader: loader ?? "js", resolveDir: path.dirname(args.path) };
|
|
152
|
+
});
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { LudicordManifests } from "../manifests/types.js";
|
|
2
|
-
|
|
2
|
+
import type { LudicordPlugin, LudicordPluginMode } from "../config/types.js";
|
|
3
|
+
export declare function bundleServerGraph(root: string, output: string, manifests: LudicordManifests, projectAliases?: Readonly<Record<string, string>>, plugins?: readonly LudicordPlugin[], mode?: LudicordPluginMode): Promise<{
|
|
3
4
|
bundles: {
|
|
4
5
|
source: string;
|
|
5
6
|
bundle: string;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { pathToFileURL } from "node:url";
|
|
3
3
|
import { build } from "esbuild";
|
|
4
|
-
|
|
4
|
+
import { esbuildPluginAdapter } from "./plugin-runtime.js";
|
|
5
|
+
export async function bundleServerGraph(root, output, manifests, projectAliases = { "@": "." }, plugins = [], mode = "production") {
|
|
5
6
|
const routes = [...manifests.api.map((route, index) => ({ ...route, name: `api/${index}` })),
|
|
6
7
|
...manifests.websocket.map((route, index) => ({ ...route, name: `ws/${index}` })),
|
|
7
8
|
...(manifests.activity.instrumentation === undefined ? [] : [{
|
|
@@ -17,6 +18,7 @@ export async function bundleServerGraph(root, output, manifests, projectAliases
|
|
|
17
18
|
const bundles = routes.map((route) => ({ source: route.file, bundle: `${route.name}.mjs`, kind: route.kind }));
|
|
18
19
|
const dependencies = new Set();
|
|
19
20
|
if (routes.length > 0) {
|
|
21
|
+
const plugin = esbuildPluginAdapter(plugins, root, mode);
|
|
20
22
|
const result = await build({
|
|
21
23
|
absWorkingDir: root,
|
|
22
24
|
entryPoints: routes.map((route) => ({ in: path.join(root, route.file), out: route.name })),
|
|
@@ -24,6 +26,7 @@ export async function bundleServerGraph(root, output, manifests, projectAliases
|
|
|
24
26
|
chunkNames: "shared/[name]-[hash]", platform: "node", format: "esm", target: "node20",
|
|
25
27
|
bundle: true, splitting: true, sourcemap: true, packages: "external", logLevel: "silent", metafile: true,
|
|
26
28
|
alias: Object.fromEntries(Object.entries(projectAliases).map(([alias, target]) => [alias, path.resolve(root, target)])),
|
|
29
|
+
...(plugin === undefined ? {} : { plugins: [plugin] }),
|
|
27
30
|
});
|
|
28
31
|
for (const input of Object.keys(result.metafile.inputs))
|
|
29
32
|
dependencies.add(path.resolve(root, input));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync, } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
const LUDICORD_ENV_REFERENCE = '/// <reference path="./ludicord.generated.d.ts" />';
|
|
4
|
+
const LUDICORD_PLUGIN_ENV_REFERENCE = '/// <reference path="./ludicord.plugins.generated.d.ts" />';
|
|
4
5
|
function templateSegment(segment) {
|
|
5
6
|
if (segment.startsWith(":"))
|
|
6
7
|
return "${string}";
|
|
@@ -90,20 +91,35 @@ ${routeParams(manifests.websocket)}
|
|
|
90
91
|
function ensureLudicordEnv(projectRoot) {
|
|
91
92
|
const file = path.join(projectRoot, "ludicord-env.d.ts");
|
|
92
93
|
const current = existsSync(file) ? readFileSync(file, "utf8") : "";
|
|
93
|
-
|
|
94
|
+
const references = [LUDICORD_ENV_REFERENCE, LUDICORD_PLUGIN_ENV_REFERENCE]
|
|
95
|
+
.filter((reference) => !current.includes(reference));
|
|
96
|
+
if (references.length === 0)
|
|
94
97
|
return;
|
|
95
|
-
writeFileSync(file, `${
|
|
98
|
+
writeFileSync(file, `${references.join("\n")}\n${current === "" ? "" : `\n${current}`}`, "utf8");
|
|
99
|
+
}
|
|
100
|
+
function pluginDeclarations(config) {
|
|
101
|
+
const declarations = config.plugins
|
|
102
|
+
.map((plugin) => plugin.declarations?.trim())
|
|
103
|
+
.filter((declaration) => Boolean(declaration));
|
|
104
|
+
return `// Generated by Ludicord plugins. Changes will be replaced by ludicord dev or ludicord build.\n${declarations.join("\n\n")}${declarations.length === 0 ? "" : "\n"}`;
|
|
96
105
|
}
|
|
97
106
|
export function generateLudicordTypes(projectRoot, manifests, config) {
|
|
98
107
|
const root = path.resolve(projectRoot);
|
|
99
108
|
const source = generatedSource(manifests, config);
|
|
109
|
+
const pluginSource = pluginDeclarations(config);
|
|
100
110
|
const publicFile = path.join(root, "ludicord.generated.d.ts");
|
|
111
|
+
const publicPluginFile = path.join(root, "ludicord.plugins.generated.d.ts");
|
|
101
112
|
const internalFile = path.join(root, ".ludicord", "types", "routes.d.ts");
|
|
113
|
+
const internalPluginFile = path.join(root, ".ludicord", "types", "plugins.d.ts");
|
|
102
114
|
mkdirSync(path.dirname(internalFile), { recursive: true });
|
|
103
115
|
if (!existsSync(publicFile) || readFileSync(publicFile, "utf8") !== source)
|
|
104
116
|
writeFileSync(publicFile, source, "utf8");
|
|
117
|
+
if (!existsSync(publicPluginFile) || readFileSync(publicPluginFile, "utf8") !== pluginSource)
|
|
118
|
+
writeFileSync(publicPluginFile, pluginSource, "utf8");
|
|
105
119
|
if (!existsSync(internalFile) || readFileSync(internalFile, "utf8") !== source)
|
|
106
120
|
writeFileSync(internalFile, source, "utf8");
|
|
121
|
+
if (!existsSync(internalPluginFile) || readFileSync(internalPluginFile, "utf8") !== pluginSource)
|
|
122
|
+
writeFileSync(internalPluginFile, pluginSource, "utf8");
|
|
107
123
|
ensureLudicordEnv(root);
|
|
108
124
|
return publicFile;
|
|
109
125
|
}
|
package/dist/config/defaults.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export function resolveConfig(config = {}) {
|
|
2
2
|
const clientId = config.discord?.clientId ?? process.env.LUDICORD_DISCORD_CLIENT_ID;
|
|
3
|
+
const plugins = (config.plugins ?? []).filter((plugin) => Boolean(plugin));
|
|
3
4
|
const resolved = {
|
|
5
|
+
plugins,
|
|
4
6
|
discord: {
|
|
5
7
|
...(clientId === undefined ? {} : { clientId }),
|
|
6
8
|
scopes: [...(config.discord?.scopes ?? ["identify"])],
|
|
@@ -99,6 +101,22 @@ export function resolveConfig(config = {}) {
|
|
|
99
101
|
fail("discord.scopes");
|
|
100
102
|
if (resolved.discord.auth.activityInstanceVerification !== "auto" && typeof resolved.discord.auth.activityInstanceVerification !== "boolean")
|
|
101
103
|
fail("discord.auth.activityInstanceVerification");
|
|
104
|
+
const pluginNames = new Set();
|
|
105
|
+
for (const plugin of resolved.plugins) {
|
|
106
|
+
if (typeof plugin !== "object" || typeof plugin.name !== "string" || !/^[a-z0-9][a-z0-9:_./-]*$/i.test(plugin.name))
|
|
107
|
+
fail("plugins");
|
|
108
|
+
if (pluginNames.has(plugin.name))
|
|
109
|
+
fail(`plugins (duplicate ${plugin.name})`);
|
|
110
|
+
pluginNames.add(plugin.name);
|
|
111
|
+
if (plugin.enforce !== undefined && plugin.enforce !== "pre" && plugin.enforce !== "post")
|
|
112
|
+
fail(`plugins (${plugin.name}.enforce)`);
|
|
113
|
+
if (plugin.declarations !== undefined && typeof plugin.declarations !== "string")
|
|
114
|
+
fail(`plugins (${plugin.name}.declarations)`);
|
|
115
|
+
for (const hook of ["resolveId", "load", "transform"]) {
|
|
116
|
+
if (plugin[hook] !== undefined && typeof plugin[hook] !== "function")
|
|
117
|
+
fail(`plugins (${plugin.name}.${hook})`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
102
120
|
for (const [field, value] of Object.entries({ "discord.auth.required": resolved.discord.auth.required, "discord.auth.proxyVerification": resolved.discord.auth.proxyVerification, "react.strictMode": resolved.react.strictMode, "websocket.enabled": resolved.websocket.enabled, "websocket.compression": resolved.websocket.compression, "websocket.reconnect.enabled": resolved.websocket.reconnect.enabled })) {
|
|
103
121
|
if (typeof value !== "boolean")
|
|
104
122
|
fail(field);
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { defineConfig } from "./types.js";
|
|
2
|
-
export type { LudicordActivityConfig, LudicordAuthConfig, LudicordConfig, LudicordDiscordConfig, LudicordImportsConfig, LudicordReconnectConfig, LudicordServerConfig, LudicordServerLimits, LudicordWebSocketConfig, OutsideDiscordBehavior, ResolvedLudicordConfig, } from "./types.js";
|
|
1
|
+
export { defineConfig, definePlugin } from "./types.js";
|
|
2
|
+
export type { LudicordActivityConfig, LudicordAuthConfig, LudicordConfig, LudicordDiscordConfig, LudicordImportsConfig, LudicordPlugin, LudicordPluginContext, LudicordPluginHookResult, LudicordPluginLoadResult, LudicordPluginMode, LudicordPluginOption, LudicordPluginTarget, LudicordReconnectConfig, LudicordServerConfig, LudicordServerLimits, LudicordWebSocketConfig, OutsideDiscordBehavior, ResolvedLudicordConfig, } from "./types.js";
|
package/dist/config/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { defineConfig } from "./types.js";
|
|
1
|
+
export { defineConfig, definePlugin } from "./types.js";
|
package/dist/config/types.d.ts
CHANGED
|
@@ -71,7 +71,37 @@ export interface LudicordWebSocketConfig {
|
|
|
71
71
|
maxQueuedMessages?: number;
|
|
72
72
|
reconnect?: LudicordReconnectConfig;
|
|
73
73
|
}
|
|
74
|
+
export type LudicordPluginMode = "development" | "production";
|
|
75
|
+
export type LudicordPluginTarget = "client" | "server";
|
|
76
|
+
export interface LudicordPluginContext {
|
|
77
|
+
/** Absolute Activity project root. */
|
|
78
|
+
readonly projectRoot: string;
|
|
79
|
+
readonly mode: LudicordPluginMode;
|
|
80
|
+
readonly target: LudicordPluginTarget;
|
|
81
|
+
}
|
|
82
|
+
export interface LudicordPluginLoadResult {
|
|
83
|
+
readonly code: string;
|
|
84
|
+
/** Controls how server builds parse the returned module. Defaults to `js`. */
|
|
85
|
+
readonly loader?: "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "css";
|
|
86
|
+
/** JSON-encoded source map for transformed text modules. */
|
|
87
|
+
readonly map?: string;
|
|
88
|
+
}
|
|
89
|
+
export type LudicordPluginHookResult = string | LudicordPluginLoadResult | null | undefined;
|
|
90
|
+
/** A compiler extension registered through `ludicord.config.mjs`. */
|
|
91
|
+
export interface LudicordPlugin {
|
|
92
|
+
/** Stable, diagnostic-friendly plugin name. */
|
|
93
|
+
readonly name: string;
|
|
94
|
+
readonly enforce?: "pre" | "post";
|
|
95
|
+
/** Ambient declarations written into Ludicord's generated plugin types. */
|
|
96
|
+
readonly declarations?: string;
|
|
97
|
+
resolveId?(id: string, importer: string | undefined, context: LudicordPluginContext): string | null | undefined | Promise<string | null | undefined>;
|
|
98
|
+
load?(id: string, context: LudicordPluginContext): LudicordPluginHookResult | Promise<LudicordPluginHookResult>;
|
|
99
|
+
transform?(code: string, id: string, context: LudicordPluginContext): LudicordPluginHookResult | Promise<LudicordPluginHookResult>;
|
|
100
|
+
}
|
|
101
|
+
/** Falsey entries make environment-dependent plugin arrays easy to compose. */
|
|
102
|
+
export type LudicordPluginOption = LudicordPlugin | false | null | undefined;
|
|
74
103
|
export interface LudicordConfig {
|
|
104
|
+
plugins?: readonly LudicordPluginOption[];
|
|
75
105
|
discord?: LudicordDiscordConfig;
|
|
76
106
|
activity?: LudicordActivityConfig;
|
|
77
107
|
react?: LudicordReactConfig;
|
|
@@ -81,6 +111,7 @@ export interface LudicordConfig {
|
|
|
81
111
|
websocket?: LudicordWebSocketConfig;
|
|
82
112
|
}
|
|
83
113
|
export interface ResolvedLudicordConfig {
|
|
114
|
+
plugins: readonly LudicordPlugin[];
|
|
84
115
|
discord: {
|
|
85
116
|
clientId?: string;
|
|
86
117
|
scopes: readonly string[];
|
|
@@ -135,3 +166,4 @@ export interface ResolvedLudicordConfig {
|
|
|
135
166
|
};
|
|
136
167
|
}
|
|
137
168
|
export declare function defineConfig<const TConfig extends LudicordConfig>(config: TConfig): TConfig;
|
|
169
|
+
export declare function definePlugin<const TPlugin extends LudicordPlugin>(plugin: TPlugin): TPlugin;
|
package/dist/config/types.js
CHANGED
package/dist/docs/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Ludicord documentation
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
## Learn Ludicord
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
- [Getting Started](getting-started.md)
|
|
9
9
|
- [Installation](installation.md)
|
|
10
10
|
- [Project Structure](project-structure.md)
|
|
11
|
+
- [Plugins and WebAssembly](plugins.md)
|
|
11
12
|
- [AI coding agents and bundled docs](ai-agents.md)
|
|
12
13
|
- [Page scopes and optional prefix navigation](prefix-router.md)
|
|
13
14
|
- [Pages: page.tsx](pages.md)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Activity Rooms
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Every authenticated WebSocket client can join the Activity Instance room:
|
package/dist/docs/ai-agents.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# AI coding agents
|
|
2
2
|
|
|
3
|
-
Ludicord 4.0
|
|
3
|
+
Ludicord 4.1.0 ships documentation and agent skills with the npm package. They
|
|
4
4
|
are available offline and change together with the installed framework:
|
|
5
5
|
|
|
6
6
|
```text
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Public API reference
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
This page describes supported import paths and their purpose. The package includes TypeScript declarations for exact signatures and data shapes; use editor completion against the version you actually installed.
|
|
6
6
|
|
|
@@ -11,10 +11,14 @@ This page describes supported import paths and their purpose. The package includ
|
|
|
11
11
|
| `ludicord` | `LudicordActivity`, `EmbedOutlet`, `PrefixLink`, `prefixHref`, `useActivityPrefix`, error/loading/minimize APIs, generated prefix types, `LUDICORD_VERSION` |
|
|
12
12
|
| `ludicord/navigation` | `Link`, `PrefixLink`, `prefixHref`, `useEmbedRouter`, `useEmbedPath`, `useEmbedParams`, `usePageParams`, `useActivityPrefix`, and generated prefix/route/parameter types |
|
|
13
13
|
| `ludicord/runtime` | `useLudicordRuntime` for environment, version, Activity/Discord/WebSocket readiness and auth status |
|
|
14
|
-
| `ludicord/config` | `defineConfig` and configuration types |
|
|
14
|
+
| `ludicord/config` | `defineConfig`, `definePlugin`, plugin hook/context types, and configuration types |
|
|
15
|
+
| `ludicord/plugins` | Official plugin exports |
|
|
16
|
+
| `ludicord/plugins/wasm` | `wasm()` and `LudicordWasmPluginOptions` |
|
|
15
17
|
|
|
16
18
|
The compiler supplies the minimize provider for automatic files; do not manually wrap it just to use `app/minimize.tsx`. See [automatic files](pages.md) and [navigation](navigation.md).
|
|
17
19
|
|
|
20
|
+
Configured plugins may add generated ambient declarations in `ludicord.plugins.generated.d.ts`. The official WASM plugin types `.wasm` imports and supplies `instantiate`, `compile`, and `byteLength`. See [Plugins and WebAssembly](plugins.md).
|
|
21
|
+
|
|
18
22
|
`PrefixLink` and `prefixHref()` navigate between pathname-owned Activity pages. `Link` and `useEmbedRouter()` navigate among local embeds without remounting the active page. Read [Page scopes and unified routing](prefix-router.md) before constructing cross-page URLs.
|
|
19
23
|
|
|
20
24
|
## Authentication
|
package/dist/docs/api-routes.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# API Routes
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Create a `route.ts` anywhere under `app/`. For example, `app/api/hello/route.ts` serves `/api/hello`; `app/health/route.ts` serves `/health`. The `api/` directory is optional. Do not place another route file in the same directory.
|
package/dist/docs/build.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Build
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
```bash
|
package/dist/docs/cli.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# CLI reference
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
Run commands through your generated package scripts or the locally installed `ludicord` executable.
|
|
6
6
|
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
# Configuration reference
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
Create `ludicord.config.mjs` in the application root:
|
|
6
6
|
|
|
7
7
|
```js
|
|
8
8
|
import { defineConfig } from "ludicord/config";
|
|
9
|
+
import { wasm } from "ludicord/plugins/wasm";
|
|
9
10
|
|
|
10
11
|
export default defineConfig({
|
|
12
|
+
plugins: [wasm()],
|
|
11
13
|
discord: { scopes: ["identify", "guilds"] },
|
|
12
14
|
activity: { defaultEmbed: "home", outsideDiscord: "error" },
|
|
13
15
|
imports: {
|
|
@@ -23,6 +25,12 @@ export default defineConfig({
|
|
|
23
25
|
|
|
24
26
|
Client ID may come from `LUDICORD_DISCORD_CLIENT_ID`. Keep secrets in server environment variables, never config literals or client imports.
|
|
25
27
|
|
|
28
|
+
## Plugins
|
|
29
|
+
|
|
30
|
+
`plugins` accepts extensions created with `definePlugin()` as well as official plugins such as `wasm()`. False, null, and undefined entries are ignored so a plugin may be enabled conditionally. Plugin names must be unique. Plugins run in the browser and server compilers unless their hooks choose a target from the supplied context.
|
|
31
|
+
|
|
32
|
+
See [Plugins and WebAssembly](plugins.md) for the hook API, generated declarations, security boundary, and WASM imports. Do not create a Vite config; Ludicord owns its compiler configuration.
|
|
33
|
+
|
|
26
34
|
## Discord and Activity
|
|
27
35
|
|
|
28
36
|
| Setting | Default | Meaning |
|
package/dist/docs/deployment.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Deployment
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Deploy Ludicord to a Node.js 20.19+ environment that supports long-lived HTTP upgrades for WebSockets.
|
package/dist/docs/development.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Development runtime
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
`ludicord dev` owns the HTTP server, API routes, WebSockets, React hot updates, and diagnostics. It binds and announces the local URL before the initial compilation, then reports a clear `listening` → `compiling` → `ready` lifecycle. Requests wait for that first compilation instead of racing an incomplete server:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Discord Developer Portal Setup
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
1. Create a Discord application and enable Activities.
|
package/dist/docs/discord-sdk.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Discord SDK
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Ludicord uses the official `@discord/embedded-app-sdk` package and initializes one SDK instance per Activity. `LudicordActivity` waits for SDK readiness before authentication and reuses shared subscriptions rather than registering one listener per component.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Package distribution and automated releases
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
Ludicord uses a two-stage release pipeline so its public package links and npm provenance are correct without publishing the original TypeScript implementation.
|
|
6
6
|
|
package/dist/docs/embeds.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Embeds
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
An embed is an internal Activity screen owned by its nearest ancestor page. Create `app/home/embed.tsx` for the root page:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Environment Variables
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
```env
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Getting Started
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Create an Activity and start the development server:
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# Installation
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Node.js 20.19 or newer is required. A new project is the simplest installation:
|
|
7
7
|
|
|
8
|
-
The commands below install the latest **published** release. Confirm the registry reports 4.0
|
|
8
|
+
The commands below install the latest **published** release. Confirm the registry reports 4.1.0 before upgrading a production deployment.
|
|
9
9
|
|
|
10
10
|
```bash
|
|
11
11
|
npx create-ludicord-app my-activity
|
package/dist/docs/login.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Login and sessions
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Ludicord authentication follows the Embedded App SDK authorization-code flow:
|
package/dist/docs/migration.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
# Upgrading to Ludicord 4.0
|
|
1
|
+
# Upgrading to Ludicord 4.1.0
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
|
-
Check that both 4.0
|
|
5
|
+
Check that both 4.1.0 packages are available before upgrading:
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npm view ludicord version
|
|
9
9
|
npm view create-ludicord-app version
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
Update an existing application's framework dependency with `npm install ludicord@4.0
|
|
12
|
+
Update an existing application's framework dependency with `npm install ludicord@4.1.0` (or your package-manager equivalent), update its lockfile, and create a fresh production build. The generator is for new projects; do not run it over an existing non-empty application. Existing V3 trees remain supported through legacy compatibility mode; follow [the routing migration](migration-v4.md) before switching file conventions.
|
|
13
13
|
|
|
14
14
|
## Review your application
|
|
15
15
|
|
|
@@ -42,4 +42,4 @@ Update an existing application's framework dependency with `npm install ludicord
|
|
|
42
42
|
- Every expected prefix pathname and default embed URL returns the correct shell.
|
|
43
43
|
- Unknown production prefixes return 404 instead of falling through to an unrelated scope.
|
|
44
44
|
|
|
45
|
-
Back up your current lockfile and keep the last deployable build for rollback. Review the detailed [V4 migration guide](migration-v4.md), [
|
|
45
|
+
Back up your current lockfile and keep the last deployable build for rollback. Review the detailed [V4 migration guide](migration-v4.md), [plugins and WebAssembly](plugins.md), [4.1.0 release notes](https://github.com/mrcholer/ludicord/blob/main/releases/v4/4.1.0.md), [security](security.md), and [deployment](deployment.md).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Mobile and Layout
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Ludicord installs four CSS custom properties:
|
package/dist/docs/navigation.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Navigation and generated route types
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Inside one prefix scope, use the Ludicord embed router. The current local embed is synchronized through the hash (`#/profile/user-one`) for deep links and browser back/forward, and hashes are validated against that prefix's generated registry:
|
package/dist/docs/pages.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Pages: page.tsx
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
A default-exported React component in `app/page.tsx` renders at `/`. Nested `page.tsx` files render at their directory paths. A page can render plain UI without any embed:
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Participants
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
```tsx
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Plugins and WebAssembly
|
|
2
|
+
|
|
3
|
+
Ludicord plugins extend the compiler through the framework configuration. They run in development and production for both the browser graph and server routes, while Ludicord continues to own its compiler configuration.
|
|
4
|
+
|
|
5
|
+
## Add the WebAssembly plugin
|
|
6
|
+
|
|
7
|
+
The official WebAssembly plugin ships with `ludicord`:
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
// ludicord.config.mjs
|
|
11
|
+
import { defineConfig } from "ludicord/config";
|
|
12
|
+
import { wasm } from "ludicord/plugins/wasm";
|
|
13
|
+
|
|
14
|
+
export default defineConfig({
|
|
15
|
+
plugins: [wasm()],
|
|
16
|
+
});
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Import a precompiled `.wasm` file from a page, embed, component, API route, or WebSocket route:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import instantiate, { byteLength, compile } from "./physics.wasm";
|
|
23
|
+
|
|
24
|
+
const instance = await instantiate({
|
|
25
|
+
env: {
|
|
26
|
+
log(value: number) {
|
|
27
|
+
console.log(value);
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const exports = instance.exports;
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The default export instantiates the module and returns `Promise<WebAssembly.Instance>`. `compile()` returns a cached `WebAssembly.Module`, and `byteLength` reports the original binary size. Ludicord generates the `*.wasm` declaration automatically in `ludicord.plugins.generated.d.ts`.
|
|
36
|
+
|
|
37
|
+
WASM bytes are embedded in the compiled JavaScript module so the same import works in Discord's browser frame and Node server routes without a second asset URL or MIME-type requirement. The default maximum file size is 16 MiB. Raise it deliberately for a larger trusted module:
|
|
38
|
+
|
|
39
|
+
```js
|
|
40
|
+
plugins: [wasm({ maxFileSize: 32 * 1024 * 1024 })]
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Use dynamic `import()` for a large module that is not required during initial Activity startup so it can remain in a separate client chunk.
|
|
44
|
+
|
|
45
|
+
## Author a plugin
|
|
46
|
+
|
|
47
|
+
Use `definePlugin()` for a typed plugin object:
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
import { defineConfig, definePlugin } from "ludicord/config";
|
|
51
|
+
|
|
52
|
+
const messages = definePlugin({
|
|
53
|
+
name: "acme:messages",
|
|
54
|
+
declarations: `declare module "virtual:messages" {
|
|
55
|
+
const messages: Readonly<Record<string, string>>;
|
|
56
|
+
export default messages;
|
|
57
|
+
}`,
|
|
58
|
+
resolveId(id) {
|
|
59
|
+
if (id === "virtual:messages") return id;
|
|
60
|
+
},
|
|
61
|
+
load(id, context) {
|
|
62
|
+
if (id !== "virtual:messages") return;
|
|
63
|
+
return `export default ${JSON.stringify({
|
|
64
|
+
runtime: context.target,
|
|
65
|
+
mode: context.mode,
|
|
66
|
+
})}`;
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
export default defineConfig({
|
|
71
|
+
plugins: [messages],
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
A plugin has a unique `name`, optional `pre` or `post` enforcement, optional ambient `declarations`, and these hooks:
|
|
76
|
+
|
|
77
|
+
| Hook | Purpose |
|
|
78
|
+
| --- | --- |
|
|
79
|
+
| `resolveId(id, importer, context)` | Resolve a file or virtual module identifier |
|
|
80
|
+
| `load(id, context)` | Return module source for an identifier |
|
|
81
|
+
| `transform(code, id, context)` | Transform an already loaded text module |
|
|
82
|
+
|
|
83
|
+
The context contains the absolute `projectRoot`, `mode` (`development` or `production`), and `target` (`client` or `server`). A load or transform hook may return source text or `{ code, loader, map }`. Server loaders support `js`, `jsx`, `ts`, `tsx`, `json`, `text`, and `css`; source maps are JSON strings.
|
|
84
|
+
|
|
85
|
+
Conditional entries are supported:
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
plugins: [process.env.ANALYZE === "1" && analyzer()]
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Plugin code executes with the same local access as the config and build command. Install and enable only trusted plugins. Use plugin hooks instead of adding a Vite configuration file; Vite and the server compiler remain Ludicord implementation details.
|
|
92
|
+
|
|
93
|
+
Changing the plugin list or plugin options triggers the normal controlled development restart because `ludicord.config.mjs` changed. Installing or updating a plugin package still requires restarting the command.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Page scopes and optional prefix navigation
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
## Choose the simplest structure
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Project structure
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
The `app/` tree is the router. These four files define routes:
|
|
6
6
|
|
|
@@ -33,6 +33,7 @@ lib/ shared application code
|
|
|
33
33
|
public/ static assets
|
|
34
34
|
ludicord.config.mjs framework configuration
|
|
35
35
|
ludicord.generated.d.ts generated route and parameter types
|
|
36
|
+
ludicord.plugins.generated.d.ts generated plugin declarations
|
|
36
37
|
.ludicord/ generated build output
|
|
37
38
|
```
|
|
38
39
|
|
package/dist/docs/recipes.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Usage recipes
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
These small application examples illustrate the public API. They are not framework implementation or complete production applications.
|
|
6
6
|
|
package/dist/docs/security.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Security
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Ludicord encrypts and authenticates session cookies with AES-256-GCM, validates OAuth state, keeps server secrets out of React stores, requires sessions for API and WebSocket routes by default, and scans production client output for actual secret values.
|
package/dist/docs/start.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Start
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Build once, then run the existing output:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# React state and effects
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
Ludicord is React, so ordinary React state is the first choice for ordinary interface state. Framework hooks add Activity-aware lifecycles; they do not replace `useState`, `useReducer`, or correct effect cleanup.
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Troubleshooting
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Run the checks relevant to the failure:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Voice Events
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Request the `rpc.voice.read` scope, then use:
|
package/dist/docs/websockets.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# WebSockets
|
|
2
2
|
|
|
3
|
-
> Documentation for Ludicord 4.0.
|
|
3
|
+
> Documentation for Ludicord 4.1.0. See [release status](https://github.com/mrcholer/ludicord/blob/main/releases/README.md).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Create `app/ws/presence/socket.ts` for `/ws/presence`, or `app/live/socket.ts` for `/live`. The `ws/` folder is optional. A directory may contain only one route file. Use the full discovered URL in `useWS()`; no `/ws` prefix is added automatically.
|
package/dist/lint/index.js
CHANGED
|
@@ -45,7 +45,7 @@ export async function lintLudicordProject(projectRoot) {
|
|
|
45
45
|
ludicord: {
|
|
46
46
|
processors: {
|
|
47
47
|
conventions: {
|
|
48
|
-
meta: { name: "ludicord-conventions", version: "4.0
|
|
48
|
+
meta: { name: "ludicord-conventions", version: "4.1.0" },
|
|
49
49
|
preprocess: (source, filename) => [normalizeConventionComponent(source, filename)],
|
|
50
50
|
postprocess: (messages) => messages[0] ?? [],
|
|
51
51
|
supportsAutofix: false,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { wasm } from "./wasm.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LudicordPlugin } from "../config/types.js";
|
|
2
|
+
export interface LudicordWasmPluginOptions {
|
|
3
|
+
/** Maximum accepted module size. Defaults to 16 MiB. */
|
|
4
|
+
readonly maxFileSize?: number;
|
|
5
|
+
}
|
|
6
|
+
/** Adds typed, portable `.wasm` imports to client components and server routes. */
|
|
7
|
+
export declare function wasm(options?: LudicordWasmPluginOptions): LudicordPlugin;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { definePlugin } from "../config/types.js";
|
|
3
|
+
const WASM_DECLARATIONS = `declare module "*.wasm" {
|
|
4
|
+
export const byteLength: number;
|
|
5
|
+
export function compile(): Promise<WebAssembly.Module>;
|
|
6
|
+
export default function instantiate(
|
|
7
|
+
imports?: WebAssembly.Imports,
|
|
8
|
+
): Promise<WebAssembly.Instance>;
|
|
9
|
+
}`;
|
|
10
|
+
function wasmModuleSource(encoded, byteLength) {
|
|
11
|
+
return `const encoded = ${JSON.stringify(encoded)};
|
|
12
|
+
export const byteLength = ${byteLength};
|
|
13
|
+
let compiled;
|
|
14
|
+
function decode() {
|
|
15
|
+
const NodeBuffer = globalThis.Buffer;
|
|
16
|
+
if (NodeBuffer) return new Uint8Array(NodeBuffer.from(encoded, "base64"));
|
|
17
|
+
const binary = globalThis.atob(encoded);
|
|
18
|
+
const bytes = new Uint8Array(binary.length);
|
|
19
|
+
for (let index = 0; index < binary.length; index += 1) bytes[index] = binary.charCodeAt(index);
|
|
20
|
+
return bytes;
|
|
21
|
+
}
|
|
22
|
+
export function compile() {
|
|
23
|
+
compiled ??= WebAssembly.compile(decode());
|
|
24
|
+
return compiled;
|
|
25
|
+
}
|
|
26
|
+
export default async function instantiate(imports = {}) {
|
|
27
|
+
return WebAssembly.instantiate(await compile(), imports);
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
}
|
|
31
|
+
/** Adds typed, portable `.wasm` imports to client components and server routes. */
|
|
32
|
+
export function wasm(options = {}) {
|
|
33
|
+
const maxFileSize = options.maxFileSize ?? 16 * 1024 * 1024;
|
|
34
|
+
if (!Number.isSafeInteger(maxFileSize) || maxFileSize < 8) {
|
|
35
|
+
throw new TypeError("LUDICORD8002: wasm.maxFileSize must be an integer of at least 8 bytes.");
|
|
36
|
+
}
|
|
37
|
+
return definePlugin({
|
|
38
|
+
name: "ludicord:wasm",
|
|
39
|
+
enforce: "pre",
|
|
40
|
+
declarations: WASM_DECLARATIONS,
|
|
41
|
+
load(id) {
|
|
42
|
+
const [file, query] = id.split("?", 2);
|
|
43
|
+
if (query !== undefined || file === undefined || !file.toLowerCase().endsWith(".wasm"))
|
|
44
|
+
return undefined;
|
|
45
|
+
const source = readFileSync(file);
|
|
46
|
+
if (source.byteLength > maxFileSize) {
|
|
47
|
+
throw new Error(`LUDICORD8002: ${file} is ${source.byteLength} bytes; wasm.maxFileSize is ${maxFileSize} bytes.`);
|
|
48
|
+
}
|
|
49
|
+
return { code: wasmModuleSource(source.toString("base64"), source.byteLength), loader: "js" };
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
}
|
|
@@ -22,6 +22,7 @@ import { diagnostic, sourceFrame, watchProjectTypes } from "./diagnostics.js";
|
|
|
22
22
|
import { createProxyMiddleware } from "../../server/proxy.js";
|
|
23
23
|
import { createLudicordRequestSecurity } from "../../server/request-security.js";
|
|
24
24
|
import { formatPrefixTable, formatRouteTable, matchPageRoute, normalizeActivityPrefix } from "../../router/prefix.js";
|
|
25
|
+
import { vitePluginAdapters } from "../../compiler/plugin-runtime.js";
|
|
25
26
|
const ENTRY = "virtual:ludicord-activity-entry";
|
|
26
27
|
const RESOLVED_ENTRY = "\0" + ENTRY;
|
|
27
28
|
const PANEL = "virtual:ludicord-dev-panel";
|
|
@@ -220,7 +221,7 @@ export async function createLudicordDevServer(options) {
|
|
|
220
221
|
if (serverEntryCount > 0)
|
|
221
222
|
console.log("compiling " + name);
|
|
222
223
|
try {
|
|
223
|
-
const next = await bundleServerGraph(projectRoot, nextDirectory, candidateManifests, config.imports.aliases);
|
|
224
|
+
const next = await bundleServerGraph(projectRoot, nextDirectory, candidateManifests, config.imports.aliases, config.plugins, "development");
|
|
224
225
|
const instrumentationFile = candidateManifests.activity.instrumentation;
|
|
225
226
|
let nextInstrumentationCleanup;
|
|
226
227
|
let nextInstrumentation;
|
|
@@ -409,7 +410,7 @@ export async function createLudicordDevServer(options) {
|
|
|
409
410
|
],
|
|
410
411
|
},
|
|
411
412
|
resolve: { dedupe: ["react", "react-dom"], alias: clientAliases(projectRoot, config.imports.aliases) },
|
|
412
|
-
plugins: [plugin, ...await clientPlugins(projectRoot, (file, elapsed) => {
|
|
413
|
+
plugins: [plugin, ...vitePluginAdapters(config.plugins, projectRoot, "development"), ...await clientPlugins(projectRoot, (file, elapsed) => {
|
|
413
414
|
if (elapsed === undefined) {
|
|
414
415
|
updateStatus("compiling", file);
|
|
415
416
|
console.log("compiling " + file);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ludicord
|
|
3
|
-
description: "Build, modify, debug, review, or document Ludicord Discord Activities. Use for Activity roots, embeds, typed navigation, React state and effects, API or WebSocket routes, shared Activity state, Discord SDK data, participants, voice, authentication, security, configuration, development diagnostics, deployment, migration, and release compatibility."
|
|
3
|
+
description: "Build, modify, debug, review, or document Ludicord Discord Activities. Use for Activity roots, embeds, typed navigation, React state and effects, API or WebSocket routes, shared Activity state, Discord SDK data, participants, voice, authentication, security, configuration, compiler plugins, WebAssembly, development diagnostics, deployment, migration, and release compatibility."
|
|
4
4
|
metadata:
|
|
5
5
|
author: ludicord
|
|
6
|
-
version: "4.0
|
|
6
|
+
version: "4.1.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
# Ludicord
|
|
@@ -151,6 +151,11 @@ correct/incorrect pairs and the public guide behind it.
|
|
|
151
151
|
routes share `server.allowedHosts` and `server.allowedOrigins`.
|
|
152
152
|
- **Keep `ludicord.config.mjs` as the configuration source.** No Vite
|
|
153
153
|
config — Vite is an internal compiler detail.
|
|
154
|
+
- **Register compiler extensions through `plugins`.** Use `definePlugin()` for
|
|
155
|
+
a project or package plugin and `wasm()` from `ludicord/plugins/wasm` for
|
|
156
|
+
typed `.wasm` imports. Load only trusted plugins because config hooks execute
|
|
157
|
+
during development and builds. Read `dist/docs/plugins.md` before authoring
|
|
158
|
+
hooks; do not reach into Ludicord's Vite or esbuild configuration.
|
|
154
159
|
|
|
155
160
|
## Key Patterns
|
|
156
161
|
|
|
@@ -282,7 +287,7 @@ npx create-ludicord-app@latest my-activity --tailwind # scripted styling choice
|
|
|
282
287
|
npx create-ludicord-app@latest my-activity --no-tailwind
|
|
283
288
|
```
|
|
284
289
|
|
|
285
|
-
Generated 4.0
|
|
290
|
+
Generated 4.1.0 projects intentionally include only `dev`, `build`, and
|
|
286
291
|
`start` scripts. Run advanced commands with the project's package runner.
|
|
287
292
|
|
|
288
293
|
## Routed Intelligence References
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
schema: 1
|
|
2
|
-
framework_version: "4.0
|
|
2
|
+
framework_version: "4.1.0"
|
|
3
3
|
path_base: package-dist-or-repository-root
|
|
4
4
|
canonical_skill: skills/ludicord/SKILL.md
|
|
5
5
|
router: skills/ludicord/references/intelligence/skill-router.md
|
|
@@ -64,6 +64,9 @@ framework_references:
|
|
|
64
64
|
- id: prefix-router
|
|
65
65
|
path: skills/ludicord/references/prefix-router.md
|
|
66
66
|
activation: existing-prefix-work-or-justified-large-project-or-required-independent-pathname-shell
|
|
67
|
+
- id: plugins
|
|
68
|
+
path: skills/ludicord/references/config-deploy.md
|
|
69
|
+
activation: configured-plugin-custom-compiler-extension-or-webassembly-import
|
|
67
70
|
|
|
68
71
|
intelligence:
|
|
69
72
|
- id: project-analysis
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Read [configuration](https://github.com/mrcholer/ludicord/blob/main/docs/configuration.md),
|
|
4
4
|
[CLI reference](https://github.com/mrcholer/ludicord/blob/main/docs/cli.md), [deployment](https://github.com/mrcholer/ludicord/blob/main/docs/deployment.md),
|
|
5
|
-
[build](https://github.com/mrcholer/ludicord/blob/main/docs/build.md), [start](https://github.com/mrcholer/ludicord/blob/main/docs/start.md),
|
|
5
|
+
[build](https://github.com/mrcholer/ludicord/blob/main/docs/build.md), [start](https://github.com/mrcholer/ludicord/blob/main/docs/start.md),
|
|
6
|
+
[plugins](https://github.com/mrcholer/ludicord/blob/main/docs/plugins.md), and
|
|
6
7
|
[troubleshooting](https://github.com/mrcholer/ludicord/blob/main/docs/troubleshooting.md) for the full guides.
|
|
7
8
|
|
|
8
9
|
## Configuration
|
|
@@ -26,11 +27,15 @@ export default defineConfig({
|
|
|
26
27
|
- Never create `vite.config.*` — Vite is an internal compiler detail and
|
|
27
28
|
the file is ignored. Tailwind is detected from `@tailwindcss/vite` in the
|
|
28
29
|
app.
|
|
30
|
+
- Register trusted compiler extensions in `plugins`. Use `definePlugin()` for
|
|
31
|
+
custom hooks and `wasm()` from `ludicord/plugins/wasm` for typed, portable
|
|
32
|
+
`.wasm` imports in client and server modules.
|
|
29
33
|
|
|
30
34
|
Key settings:
|
|
31
35
|
|
|
32
36
|
| Setting | Default | Meaning |
|
|
33
37
|
| --- | --- | --- |
|
|
38
|
+
| `plugins` | `[]` | Trusted compiler extensions for client and server modules |
|
|
34
39
|
| `discord.clientId` | Environment value | Public Discord application ID |
|
|
35
40
|
| `discord.scopes` | `["identify"]` | Requested OAuth scopes |
|
|
36
41
|
| `discord.auth.required` | `true` | Require login for the Activity |
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LUDICORD_VERSION = "4.0
|
|
1
|
+
export const LUDICORD_VERSION = "4.1.0";
|
package/package.json
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ludicord",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Full-stack React framework for Discord Activities.",
|
|
5
5
|
"homepage": "https://github.com/mrcholer/ludicord#readme",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"discord",
|
|
8
|
+
"activities",
|
|
9
|
+
"react",
|
|
10
|
+
"framework",
|
|
11
|
+
"full-stack",
|
|
12
|
+
"typescript",
|
|
13
|
+
"vite",
|
|
14
|
+
"ws",
|
|
15
|
+
"express",
|
|
16
|
+
"discord-activities",
|
|
17
|
+
"discord-activity",
|
|
18
|
+
"discord-activity-sdk",
|
|
19
|
+
"discord-activity-sdk-react",
|
|
20
|
+
"framework-for-discord-activities"
|
|
21
|
+
],
|
|
6
22
|
"repository": {
|
|
7
23
|
"type": "git",
|
|
8
24
|
"url": "git+https://github.com/mrcholer/ludicord.git",
|
|
@@ -45,6 +61,16 @@
|
|
|
45
61
|
"import": "./dist/config/index.js",
|
|
46
62
|
"default": "./dist/config/index.js"
|
|
47
63
|
},
|
|
64
|
+
"./plugins": {
|
|
65
|
+
"types": "./dist/plugins/index.d.ts",
|
|
66
|
+
"import": "./dist/plugins/index.js",
|
|
67
|
+
"default": "./dist/plugins/index.js"
|
|
68
|
+
},
|
|
69
|
+
"./plugins/wasm": {
|
|
70
|
+
"types": "./dist/plugins/wasm.d.ts",
|
|
71
|
+
"import": "./dist/plugins/wasm.js",
|
|
72
|
+
"default": "./dist/plugins/wasm.js"
|
|
73
|
+
},
|
|
48
74
|
"./navigation": {
|
|
49
75
|
"types": "./dist/navigation/index.d.ts",
|
|
50
76
|
"import": "./dist/navigation/index.js",
|