@lingfan-engine/create 0.3.3 → 0.3.4

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.
@@ -1,101 +0,0 @@
1
- /**
2
- * 组合根(桌面壳形态):与骨架只差两处——先装宿主桥,再把存档端口换成 Rust 实现。
3
- *
4
- * 为什么先装桥:`@lingfan-engine/adapters` 是给外部工程消费的源码包,包内不写
5
- * `@tauri-apps/api` 的模块名(写了会让纯 Web 形态在构建期解析失败,写成变量说明符又会在
6
- * 产物里残留裸模块名、WebView 执行时抛错)。模块名留在本文件这一层——本工程有这个依赖,
7
- * 且只在壳里跑到这里;`installTauriBridge` 把两个函数交给适配器,之后各端口工厂的
8
- * 缺省实现才可用。
9
- *
10
- * 为什么换存档:WebView 的 `localStorage` 落在系统给这个应用分配的 WebView 数据目录里,
11
- * 清缓存、换系统账户、重装都会带走存档;桌面工程的存档应当是可指路径上的文件。
12
- * 换法是把端口交给 `bootHost` 的 `ports.saves`,装配顺序与其余接线一行不改。
13
- *
14
- * 工程文件与资源**不换**:骨架的 `vite.config.ts` 把 `Resources/` 当静态根,
15
- * 打包时这些文件被复制进 `dist/`,所以打包后 `/project.json`、`/Stories/**`、
16
- * `/Audio/x.mp3` 仍按同一套路径取得到——桌面壳不需要为此多造一组 Rust 命令。
17
- *
18
- * 页面结构沿用骨架的 `index.html`(本层不带自己的),故节点解析与骨架同源。
19
- */
20
- import { MANIFEST_FILE } from "@lingfan-engine/core";
21
- import { DEFAULT_TEXT_CPS, DEFAULT_TOAST_MS } from "@lingfan-engine/ui";
22
- import {
23
- createTauriSavePort,
24
- installTauriBridge,
25
- } from "@lingfan-engine/adapters";
26
- import {
27
- bootHost,
28
- must,
29
- optional,
30
- reportBootFailure,
31
- type StageDom,
32
- } from "./host";
33
- import { STORIES } from "./stories";
34
- import { uis } from "./mounts";
35
-
36
- /**
37
- * 工程清单与故事文件:**都在应用资源根 `Resources/` 内**。
38
- * 打包后它们位于 `dist/` 顶层,路径与开发期一致。
39
- * 清单名取引擎契约里的 `MANIFEST_FILE`(组装、写回、定位资源根共用同一个声明);
40
- * 故事表在 `./stories`(唯一出口,各形态共用),内容由构建期扫描资源根得出。
41
- */
42
-
43
- /** 页面节点句柄表:每个 id 都必须存在于 index.html(缺一个 `must` 当场抛) */
44
- const dom: StageDom = {
45
- root: must("#stage-root"),
46
- stage: must("#stage"),
47
- dialogue: must("#dialogue"),
48
- speaker: must("#speaker"),
49
- text: must("#text"),
50
- hint: must("#hint"),
51
- nvl: must("#nvl"),
52
- choices: must("#choices"),
53
- notifications: must("#notifications"),
54
- toolbar: must("#toolbar"),
55
- slot: must<HTMLSelectElement>("#slot"),
56
- save: must<HTMLButtonElement>("#save"),
57
- load: must<HTMLButtonElement>("#load"),
58
- transition: must("#transition"),
59
- error: must("#error"),
60
- // 历史面板槽位(可选):骨架 index.html 里有,缺了也不影响启动
61
- history: optional("#history"),
62
- // 偏好面板槽位(可选):骨架 index.html 里有,缺了也不影响启动
63
- prefs: optional("#prefs"),
64
- // UI 挂载层槽位(可选):本层不给就 null,`mount` 命令只改状态、没有组件出现
65
- mounts: optional("#mounts"),
66
- };
67
-
68
- /**
69
- * 装配宿主桥并启动宿主。
70
- *
71
- * 静态说明符(不带 `@vite-ignore`)是刻意的:打包器据此把这两个模块打进产物,
72
- * 运行期不再需要解析裸模块名。
73
- */
74
- async function boot(): Promise<void> {
75
- const [{ invoke }, { listen }] = await Promise.all([
76
- import("@tauri-apps/api/core"),
77
- import("@tauri-apps/api/event"),
78
- ]);
79
- installTauriBridge({ invoke, listen });
80
-
81
- await bootHost({
82
- dom,
83
- manifestFile: MANIFEST_FILE,
84
- stories: STORIES,
85
- defaultCps: DEFAULT_TEXT_CPS,
86
- toastDurationMs: DEFAULT_TOAST_MS,
87
- historyContainer: dom.history,
88
- prefsContainer: dom.prefs,
89
- // UI 挂载槽位:壳层用骨架的原生渲染器(本层不引框架,`#mounts` 的子节点由宿主写)
90
- mountsContainer: dom.mounts,
91
- mountsTable: uis,
92
- ports: {
93
- // 存档落到应用数据目录的 saves/ 下,一槽一文件(加密与回档保护在 Rust 侧扩展)
94
- saves: createTauriSavePort(),
95
- },
96
- });
97
- }
98
-
99
- boot().catch((error: unknown) => {
100
- reportBootFailure(dom, error);
101
- });