@lingfan-engine/create 0.1.4 → 0.2.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/LICENSE +201 -201
- package/package.json +1 -1
- package/src/cli/cli.ts +37 -7
- package/src/cli/prompts.ts +4 -2
- package/src/generate/index.ts +1 -0
- package/src/generate/project.ts +26 -4
- package/src/index.ts +1 -0
- package/src/overlay/merge.ts +56 -3
- package/src/registry/template-meta.ts +13 -3
- package/src/shared/texts.ts +4 -0
- package/template/README.md +21 -7
- package/template/__PROJECT__/src/host/dialogue-view.ts +21 -0
- package/template/__PROJECT__/src/host/engine-wiring.ts +2 -0
- package/template/__PROJECT__/src/host/save-slots.ts +1 -1
- package/template/__PROJECT__/src/main.ts +2 -3
- package/template/__PROJECT__/src/stories.ts +11 -0
- package/template/__PROJECT__/src/styles/stage.css +6 -0
- package/template/overlays/README.md +15 -4
- package/template/overlays/miniprogram/README.md +12 -5
- package/template/overlays/miniprogram/package.patch.json +2 -1
- package/template/overlays/miniprogram/tsconfig.json +1 -2
- package/template/overlays/react/src/main.tsx +2 -3
- package/template/overlays/tauri/src/main.ts +40 -16
- package/template/overlays/ts/Resources/Stories/title/look_around.json +16 -0
- package/template/overlays/ts/Resources/Stories/title/title_main.json +30 -0
- package/template/overlays/ts/Resources/project.json +8 -0
- package/template/overlays/ts/Stories.src/config.ts +18 -0
- package/template/overlays/ts/Stories.src/gen/font.gen.d.ts +5 -0
- package/template/overlays/ts/Stories.src/gen/script.gen.d.ts +5 -0
- package/template/overlays/ts/Stories.src/gen/state.gen.d.ts +5 -0
- package/template/overlays/ts/Stories.src/gen/stories.gen.d.ts +12 -0
- package/template/overlays/ts/Stories.src/title/look_around.ts +15 -0
- package/template/overlays/ts/Stories.src/title/title_main.ts +23 -0
- package/template/overlays/ts/package.patch.json +14 -0
- package/template/overlays/ts/src/stories.ts +10 -0
- package/template/overlays/ts/tsconfig.stories.json +25 -0
- package/template/overlays/vue/src/main.ts +2 -3
- package/template/template-meta.json +14 -2
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 四处看看:第二列,演示「一个函数就是一列」。
|
|
3
|
+
*
|
|
4
|
+
* 列与列之间靠名字跳转(`menu` 的选项值就是目标列 id),跨文件也可以——
|
|
5
|
+
* 本文件与 `title_main.ts` 同属 `config.ts` 里 `folders` 声明的目录,
|
|
6
|
+
* 因此互相跳转不需要 import。
|
|
7
|
+
*/
|
|
8
|
+
import { script } from "@lingfan-engine/editor";
|
|
9
|
+
|
|
10
|
+
const { say } = script;
|
|
11
|
+
|
|
12
|
+
export default function look_around(): void {
|
|
13
|
+
say("你绕着走了一圈,什么也没发生。", "旁白");
|
|
14
|
+
say("想加点东西,就打开 Stories.src/title/look_around.ts 改写这一列。");
|
|
15
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 入口故事列。
|
|
3
|
+
*
|
|
4
|
+
* 写法与运行时无关:这些函数在构建期被求值成命令序列,产物是
|
|
5
|
+
* `Resources/Stories/title/title_main.json`——引擎运行期读的是产物,不是本文件。
|
|
6
|
+
* 因此本文件可以随便用 TS 的能力(类型、函数、循环、import),只要最终落到
|
|
7
|
+
* `script` 提供的词上。词表与签名由 `@lingfan-engine/editor` 给出,编辑器里能补全。
|
|
8
|
+
*
|
|
9
|
+
* 一个函数就是一列(column):函数名即列 id。`config.ts` 的 `start` 指向本文件,
|
|
10
|
+
* 所以它是进入故事时执行的第一列。
|
|
11
|
+
*/
|
|
12
|
+
import { script } from "@lingfan-engine/editor";
|
|
13
|
+
|
|
14
|
+
const { menu, option, say } = script;
|
|
15
|
+
|
|
16
|
+
export default function title_main(): void {
|
|
17
|
+
say("这是用 TypeScript 写的故事列。", "旁白");
|
|
18
|
+
say("改完保存,在工程根跑 pnpm stories:build 就会重新生成故事文件。");
|
|
19
|
+
menu("接下来做什么?", [
|
|
20
|
+
option("四处看看", "look_around"),
|
|
21
|
+
option("重来一次", "title_main"),
|
|
22
|
+
]);
|
|
23
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"devDependencies": {
|
|
3
|
+
"@lingfan-engine/editor": "^0.1.0",
|
|
4
|
+
"@lingfan-engine/stories-build": "^0.1.0"
|
|
5
|
+
},
|
|
6
|
+
"scripts": {
|
|
7
|
+
"stories:build": "lingfan-stories-build .",
|
|
8
|
+
"stories:watch": "lingfan-stories-watch .",
|
|
9
|
+
"stories-typecheck": "tsc --noEmit -p tsconfig.stories.json"
|
|
10
|
+
},
|
|
11
|
+
"create": {
|
|
12
|
+
"remove": ["Resources/Stories"]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 本工程的故事文件表(相对资源根 `Resources/`)——**全工程唯一声明点**。
|
|
3
|
+
*
|
|
4
|
+
* 本工程走 TS 创作链:这里列的是 `Stories.src/` 编译出来的产物,
|
|
5
|
+
* 不要直接改 `Resources/Stories/**` 下的文件——它们是生成物,下次构建会被覆盖,
|
|
6
|
+
* 源里没有的旧列还会被清理掉。改故事请改 `Stories.src/`,然后 `pnpm stories:build`。
|
|
7
|
+
*
|
|
8
|
+
* 新增一列后记得回来把产物路径加进本表(Web 形态按显式清单取文件,不扫目录)。
|
|
9
|
+
*/
|
|
10
|
+
export const STORIES: readonly string[] = ["Stories/title/title_main.json"];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
/* Stories.src 的类型检查工程:与工程根的 tsconfig.json 分开。
|
|
3
|
+
理由:根 tsconfig 由框架层/壳层决定(Vue 要 vue-tsc、React 要 jsx),
|
|
4
|
+
而故事源只需要纯 tsc + 故事源自己的全局声明(defineVars / StoriesConfig /
|
|
5
|
+
script 的词表)。合并成一个工程会让两侧的 compilerOptions 互相打架。
|
|
6
|
+
|
|
7
|
+
构建(pnpm stories:build)不做类型检查——它只把 TS 编译成命令序列,
|
|
8
|
+
类型错了照样能生成故事文件。想让类型错误拦住你,就单独跑
|
|
9
|
+
pnpm stories-typecheck。 */
|
|
10
|
+
"compilerOptions": {
|
|
11
|
+
"target": "ES2022",
|
|
12
|
+
"module": "ESNext",
|
|
13
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
14
|
+
"moduleResolution": "bundler",
|
|
15
|
+
"allowImportingTsExtensions": true,
|
|
16
|
+
"isolatedModules": true,
|
|
17
|
+
"noEmit": true,
|
|
18
|
+
"skipLibCheck": true,
|
|
19
|
+
"strict": true,
|
|
20
|
+
"noUnusedLocals": true,
|
|
21
|
+
"noUnusedParameters": true,
|
|
22
|
+
"noFallthroughCasesInSwitch": true
|
|
23
|
+
},
|
|
24
|
+
"include": ["Stories.src/**/*.ts"]
|
|
25
|
+
}
|
|
@@ -11,16 +11,15 @@
|
|
|
11
11
|
import { createApp } from "vue";
|
|
12
12
|
import { DEFAULT_TEXT_CPS, DEFAULT_TOAST_MS } from "@lingfan-engine/ui";
|
|
13
13
|
import { bootHost, must, reportBootFailure, type StageDom } from "./host";
|
|
14
|
+
import { STORIES } from "./stories";
|
|
14
15
|
import App from "./App.vue";
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* 工程清单与故事文件:**都在应用资源根 `Resources/` 内**。
|
|
18
19
|
* 宿主把 `Resources` 作为静态根,故逻辑路径就是 `project.json` / `Stories/**`。
|
|
19
|
-
*
|
|
20
|
+
* 故事表在 `./stories`(唯一声明点,各形态共用)。
|
|
20
21
|
*/
|
|
21
22
|
const MANIFEST = "project.json";
|
|
22
|
-
/** 本工程的故事文件表(相对资源根;新增故事必须同步此表) */
|
|
23
|
-
const STORIES = ["Stories/title/title_main.story"];
|
|
24
23
|
|
|
25
24
|
/** 页面节点句柄表:每个 id 都必须由 `App.vue` 渲染(缺一个 `must` 当场抛) */
|
|
26
25
|
function readDom(): StageDom {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.7.0",
|
|
3
3
|
"minEngineVersion": "0.1.0",
|
|
4
4
|
"placeholder": "__PROJECT__",
|
|
5
5
|
"frameworks": [
|
|
@@ -36,5 +36,17 @@
|
|
|
36
36
|
"hint": "给浏览器形态再加一个桌面壳:存档落到应用数据目录,其余不变"
|
|
37
37
|
}
|
|
38
38
|
],
|
|
39
|
-
"
|
|
39
|
+
"sources": [
|
|
40
|
+
{
|
|
41
|
+
"id": "story",
|
|
42
|
+
"label": "故事文件(.story)",
|
|
43
|
+
"hint": "直接写引擎自带的文本故事格式,改完保存即生效"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"id": "ts",
|
|
47
|
+
"label": "TypeScript 源(Stories.src)",
|
|
48
|
+
"hint": "用 TS 写故事列:有类型补全与重构,构建时编译成故事文件"
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"_comment": "模板版本唯一来源,独立于引擎版本:仅当 template/v1 内容真正变化时才手动 bump。placeholder 是目录/文件内的工程名占位符,生成时整体替换为工程名(对齐 _LingFanEngineTemplateTitle_ 占位符语义)。minEngineVersion 表示此模板要求的最低引擎版本。frameworks / shells / sources 决定生成器会问什么、能叠哪些层,各自首项为缺省值;每一项的 id 对应 template/v1/overlays/<id> 目录(缺省层可以没有目录)。合并顺序为「骨架 → 框架 → 故事源 → 壳」,同路径文件由后一层覆盖前一层。"
|
|
40
52
|
}
|