@silkweaver/build 1.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 ADDED
@@ -0,0 +1,20 @@
1
+ # @silkweaver/build
2
+
3
+ The Silkweaver toolchain — turns a project folder into a runnable game. It's the engine room behind
4
+ both the [`silkweaver` CLI](https://www.npmjs.com/package/@silkweaver/cli) and the IDE; most people
5
+ will reach for one of those rather than this directly.
6
+
7
+ It takes a project folder and produces a single self-contained `game.js` (the engine is inlined via
8
+ esbuild), and can package that into a portable HTML5 build or a desktop executable.
9
+
10
+ ```ts
11
+ import { build_preview, export_html5, export_executable } from '@silkweaver/build'
12
+
13
+ await export_html5('./my-game', './dist') // portable HTML5 folder
14
+ await export_executable('./my-game', './dist', 'win32', 'x64') // desktop build
15
+ ```
16
+
17
+ It also exposes `object_format` — the parse/patch layer the IDE's object editor uses to edit
18
+ class-per-object files surgically (preserving your hand-written code).
19
+
20
+ Pure Node. Part of [Silkweaver](https://github.com/NicoNicoCip/Silkweaver). License: GPL-3.0.
Binary file
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Game build / export logic for the Silkweaver desktop app.
3
+ *
4
+ * Pure Node code (fs/path/esbuild only — no electron imports) so it can be
5
+ * unit-tested and reused outside the IPC layer. main.ts wires these functions
6
+ * to the renderer over IPC.
7
+ *
8
+ * The engine, user scripts, and object code are all bundled into game.js by
9
+ * esbuild, so the ONLY difference between a preview build and an export build
10
+ * is how runtime asset URLs (sprite/background images) are resolved:
11
+ * - 'preview': absolute file:// URLs into the live project folder (runs in the IDE)
12
+ * - 'export': relative 'assets/...' URLs (assets are copied next to game.js)
13
+ */
14
+ import type { project_file as project_data } from '@silkweaver/project';
15
+ export type { project_data };
16
+ /** Reads and parses a project's project.json. */
17
+ export declare function read_project(project_folder: string): Promise<project_data>;
18
+ /**
19
+ * Builds the game to a single bundled game.js at out_path, for the in-IDE preview.
20
+ * @param out_path - Where to write game.js (the caller decides — e.g. exports/game.js)
21
+ */
22
+ export declare function build_preview(project_folder: string, out_path: string): Promise<void>;
23
+ /**
24
+ * Exports a portable, self-contained HTML5 build into out_dir:
25
+ * out_dir/game.js — minified, fully self-contained game (engine inlined)
26
+ * out_dir/index.html — standalone player page
27
+ * out_dir/assets/... — copied sprite/background assets (referenced relatively)
28
+ * @returns The export directory path.
29
+ */
30
+ export declare function export_html5(project_folder: string, out_dir: string): Promise<string>;
31
+ /**
32
+ * Exports a standalone desktop executable for the game.
33
+ *
34
+ * Stages a minimal Electron "player" app (a fixed main process that serves the
35
+ * exported game over a privileged `game://` protocol), then runs
36
+ * @electron/packager to produce a platform binary in out_dir.
37
+ *
38
+ * @param platform - 'win32' | 'darwin' | 'linux' (default 'win32')
39
+ * @param arch - 'x64' | 'arm64' (default 'x64')
40
+ * @returns Absolute path to the packaged application folder.
41
+ */
42
+ export declare function export_executable(project_folder: string, out_dir: string, platform?: string, arch?: string): Promise<string>;