@lingfan-engine/create 0.0.0-stage → 0.1.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.
Files changed (122) hide show
  1. package/LICENSE +201 -0
  2. package/bin/create.mjs +18 -0
  3. package/package.json +44 -3
  4. package/src/cli/cli.ts +302 -0
  5. package/src/cli/prompts.ts +115 -0
  6. package/src/generate/dotfiles.ts +27 -0
  7. package/src/generate/index.ts +20 -0
  8. package/src/generate/project.ts +279 -0
  9. package/src/generate/replace.ts +91 -0
  10. package/src/index.ts +46 -0
  11. package/src/overlay/index.ts +10 -0
  12. package/src/overlay/merge.ts +143 -0
  13. package/src/registry/index.ts +15 -0
  14. package/src/registry/template-meta.ts +107 -0
  15. package/src/registry/versions.ts +109 -0
  16. package/src/shared/guards.ts +85 -0
  17. package/src/shared/index.ts +7 -0
  18. package/src/shared/texts.ts +55 -0
  19. package/template/README.md +138 -0
  20. package/template/__PROJECT__/Resources/Audio/.gitkeep +0 -0
  21. package/template/__PROJECT__/Resources/Fonts/README.md +10 -0
  22. package/template/__PROJECT__/Resources/Images/.gitkeep +0 -0
  23. package/template/__PROJECT__/Resources/Lang/.gitkeep +0 -0
  24. package/template/__PROJECT__/Resources/Stories/title/title_main.story +24 -0
  25. package/template/__PROJECT__/Resources/Video/.gitkeep +0 -0
  26. package/template/__PROJECT__/Resources/project.json +7 -0
  27. package/template/__PROJECT__/gitignore +8 -0
  28. package/template/__PROJECT__/index.html +34 -0
  29. package/template/__PROJECT__/package.json +22 -0
  30. package/template/__PROJECT__/pnpm-workspace.yaml +8 -0
  31. package/template/__PROJECT__/src/host/boot.ts +181 -0
  32. package/template/__PROJECT__/src/host/dialogue-view.ts +235 -0
  33. package/template/__PROJECT__/src/host/effects.ts +68 -0
  34. package/template/__PROJECT__/src/host/engine-wiring.ts +206 -0
  35. package/template/__PROJECT__/src/host/frame-loop.ts +42 -0
  36. package/template/__PROJECT__/src/host/index.ts +27 -0
  37. package/template/__PROJECT__/src/host/input-map.ts +51 -0
  38. package/template/__PROJECT__/src/host/layer-z.ts +50 -0
  39. package/template/__PROJECT__/src/host/save-slots.ts +38 -0
  40. package/template/__PROJECT__/src/host/stage-dom.ts +74 -0
  41. package/template/__PROJECT__/src/host/theme-fonts.ts +60 -0
  42. package/template/__PROJECT__/src/host/toast.ts +29 -0
  43. package/template/__PROJECT__/src/main.ts +61 -0
  44. package/template/__PROJECT__/src/styles/stage.css +183 -0
  45. package/template/__PROJECT__/src/vite-env.d.ts +14 -0
  46. package/template/__PROJECT__/tsconfig.json +19 -0
  47. package/template/__PROJECT__/tsconfig.node.json +14 -0
  48. package/template/__PROJECT__/vite.config.ts +64 -0
  49. package/template/overlays/README.md +70 -0
  50. package/template/overlays/miniprogram/README.md +104 -0
  51. package/template/overlays/miniprogram/index.html +15 -0
  52. package/template/overlays/miniprogram/package.patch.json +40 -0
  53. package/template/overlays/miniprogram/scripts/serve-project.mjs +273 -0
  54. package/template/overlays/miniprogram/src/App.vue +23 -0
  55. package/template/overlays/miniprogram/src/components/ChoiceLayer.vue +208 -0
  56. package/template/overlays/miniprogram/src/components/DialogueLayer.vue +183 -0
  57. package/template/overlays/miniprogram/src/components/NodeTree.vue +44 -0
  58. package/template/overlays/miniprogram/src/components/NoticeLayer.vue +87 -0
  59. package/template/overlays/miniprogram/src/components/SaveLoadBar.vue +168 -0
  60. package/template/overlays/miniprogram/src/components/StageView.vue +50 -0
  61. package/template/overlays/miniprogram/src/env.d.ts +1 -0
  62. package/template/overlays/miniprogram/src/main.ts +12 -0
  63. package/template/overlays/miniprogram/src/manifest.json +21 -0
  64. package/template/overlays/miniprogram/src/mp/frame.ts +51 -0
  65. package/template/overlays/miniprogram/src/mp/guards.ts +28 -0
  66. package/template/overlays/miniprogram/src/mp/host.ts +252 -0
  67. package/template/overlays/miniprogram/src/mp/index.ts +9 -0
  68. package/template/overlays/miniprogram/src/mp/platform.ts +210 -0
  69. package/template/overlays/miniprogram/src/mp/ports.ts +84 -0
  70. package/template/overlays/miniprogram/src/mp/project-source.ts +77 -0
  71. package/template/overlays/miniprogram/src/mp/slots.ts +64 -0
  72. package/template/overlays/miniprogram/src/mp/surface.ts +239 -0
  73. package/template/overlays/miniprogram/src/mp/video-surface.ts +104 -0
  74. package/template/overlays/miniprogram/src/mp/view.ts +91 -0
  75. package/template/overlays/miniprogram/src/pages/index/index.vue +299 -0
  76. package/template/overlays/miniprogram/src/pages.json +18 -0
  77. package/template/overlays/miniprogram/tsconfig.json +20 -0
  78. package/template/overlays/miniprogram/vite.config.ts +87 -0
  79. package/template/overlays/react/index.html +16 -0
  80. package/template/overlays/react/package.patch.json +18 -0
  81. package/template/overlays/react/src/App.tsx +32 -0
  82. package/template/overlays/react/src/main.tsx +74 -0
  83. package/template/overlays/react/src/vite-env.d.ts +14 -0
  84. package/template/overlays/react/tsconfig.json +20 -0
  85. package/template/overlays/react/vite.config.ts +67 -0
  86. package/template/overlays/tauri/README.md +59 -0
  87. package/template/overlays/tauri/package.patch.json +14 -0
  88. package/template/overlays/tauri/src/main.ts +58 -0
  89. package/template/overlays/tauri/src-tauri/Cargo.toml +16 -0
  90. package/template/overlays/tauri/src-tauri/build.rs +6 -0
  91. package/template/overlays/tauri/src-tauri/capabilities/default.json +7 -0
  92. package/template/overlays/tauri/src-tauri/icons/128x128.png +0 -0
  93. package/template/overlays/tauri/src-tauri/icons/128x128@2x.png +0 -0
  94. package/template/overlays/tauri/src-tauri/icons/32x32.png +0 -0
  95. package/template/overlays/tauri/src-tauri/icons/Square107x107Logo.png +0 -0
  96. package/template/overlays/tauri/src-tauri/icons/Square142x142Logo.png +0 -0
  97. package/template/overlays/tauri/src-tauri/icons/Square150x150Logo.png +0 -0
  98. package/template/overlays/tauri/src-tauri/icons/Square284x284Logo.png +0 -0
  99. package/template/overlays/tauri/src-tauri/icons/Square30x30Logo.png +0 -0
  100. package/template/overlays/tauri/src-tauri/icons/Square310x310Logo.png +0 -0
  101. package/template/overlays/tauri/src-tauri/icons/Square44x44Logo.png +0 -0
  102. package/template/overlays/tauri/src-tauri/icons/Square71x71Logo.png +0 -0
  103. package/template/overlays/tauri/src-tauri/icons/Square89x89Logo.png +0 -0
  104. package/template/overlays/tauri/src-tauri/icons/StoreLogo.png +0 -0
  105. package/template/overlays/tauri/src-tauri/icons/icon.icns +0 -0
  106. package/template/overlays/tauri/src-tauri/icons/icon.ico +0 -0
  107. package/template/overlays/tauri/src-tauri/icons/icon.png +0 -0
  108. package/template/overlays/tauri/src-tauri/src/lib.rs +26 -0
  109. package/template/overlays/tauri/src-tauri/src/main.rs +7 -0
  110. package/template/overlays/tauri/src-tauri/src/preferences.rs +50 -0
  111. package/template/overlays/tauri/src-tauri/src/save.rs +178 -0
  112. package/template/overlays/tauri/src-tauri/tauri.conf.json +35 -0
  113. package/template/overlays/vue/index.html +16 -0
  114. package/template/overlays/vue/package.patch.json +16 -0
  115. package/template/overlays/vue/src/App.vue +30 -0
  116. package/template/overlays/vue/src/main.ts +68 -0
  117. package/template/overlays/vue/src/vite-env.d.ts +24 -0
  118. package/template/overlays/vue/tsconfig.json +19 -0
  119. package/template/overlays/vue/vite.config.ts +67 -0
  120. package/template/pack-template.ps1 +65 -0
  121. package/template/template-meta.json +40 -0
  122. package/README.md +0 -3
@@ -0,0 +1,24 @@
1
+ /// <reference types="vite/client" />
2
+
3
+ /**
4
+ * 字体清单的宿主侧声明(脚手架工程自带,与 vite.config 的虚拟模块对应)。
5
+ */
6
+ declare module "virtual:story-fonts" {
7
+ /** 字体清单条目:file = 资源文件名,name = 字体名(文件名去扩展名) */
8
+ export interface StoryFontEntry {
9
+ file: string;
10
+ name: string;
11
+ }
12
+ /** 构建期扫描 Resources/Fonts 的字体清单(与 stories:build 注册表同源) */
13
+ export const storyFonts: readonly StoryFontEntry[];
14
+ }
15
+
16
+ /** 单文件组件的模块声明:`vue-tsc` 之外的工具读到 `.vue` 时不至于整片报错 */
17
+ declare module "*.vue" {
18
+ import type { DefineComponent } from "vue";
19
+ const component: DefineComponent<
20
+ Record<string, never>,
21
+ Record<string, never>
22
+ >;
23
+ export default component;
24
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
6
+ "moduleResolution": "bundler",
7
+ "types": ["vite/client"],
8
+ "allowImportingTsExtensions": true,
9
+ "resolveJsonModule": true,
10
+ "isolatedModules": true,
11
+ "noEmit": true,
12
+ "skipLibCheck": true,
13
+ "strict": true,
14
+ "noUnusedLocals": true,
15
+ "noUnusedParameters": true,
16
+ "noFallthroughCasesInSwitch": true
17
+ },
18
+ "include": ["src/**/*.ts", "src/**/*.vue"]
19
+ }
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Vite 配置(Vue 形态):在骨架配置上多一个 Vue 插件,其余逐项保留。
3
+ *
4
+ * 资源根仍是无条件镜像 `Resources`——纯 Web 工程就是「浏览器游戏模式」的交付正例,
5
+ * 不引入壳侧的开关判定(那属于 Tauri 壳的交付形态,见引擎仓库 `apps/playground`)。
6
+ */
7
+ import { existsSync, readdirSync } from "node:fs";
8
+ import { fileURLToPath } from "node:url";
9
+ import vue from "@vitejs/plugin-vue";
10
+ import { defineConfig, type Plugin } from "vite";
11
+
12
+ /** 字体文件扩展名集合(与 stories-build 的字体名注册表同口径) */
13
+ const FONT_EXTENSIONS = [".ttf", ".otf", ".woff", ".woff2"] as const;
14
+
15
+ /** 字体清单条目:file = 资源文件名,name = 字体名(文件名去扩展名) */
16
+ interface StoryFontEntry {
17
+ file: string;
18
+ name: string;
19
+ }
20
+
21
+ /** Resources/Fonts 扫描:点文件与未知扩展名跳过,文件名字典序稳定 */
22
+ function scanFonts(fontsDir: string): readonly StoryFontEntry[] {
23
+ if (!existsSync(fontsDir)) return [];
24
+ return readdirSync(fontsDir)
25
+ .filter((file) => {
26
+ const dot = file.lastIndexOf(".");
27
+ return (
28
+ dot > 0 &&
29
+ (FONT_EXTENSIONS as readonly string[]).includes(
30
+ file.slice(dot).toLowerCase(),
31
+ )
32
+ );
33
+ })
34
+ .sort()
35
+ .map((file) => ({ file, name: file.slice(0, file.lastIndexOf(".")) }));
36
+ }
37
+
38
+ /** 字体清单虚拟模块:构建期扫描 Resources/Fonts,与 stories:build 的注册表同源 */
39
+ function storyFontsVirtual(): Plugin {
40
+ const moduleId = "virtual:story-fonts";
41
+ const fontsDir = fileURLToPath(new URL("./Resources/Fonts", import.meta.url));
42
+ return {
43
+ name: "story-fonts",
44
+ resolveId(id) {
45
+ if (id === moduleId) return `\0${moduleId}`;
46
+ return null;
47
+ },
48
+ load(id) {
49
+ if (id === `\0${moduleId}`) {
50
+ return `export const storyFonts = ${JSON.stringify(scanFonts(fontsDir))};`;
51
+ }
52
+ return null;
53
+ },
54
+ };
55
+ }
56
+
57
+ /** 脚手架工程的 Vite 配置(Vue 形态) */
58
+ export default defineConfig({
59
+ // 项目资源根即静态根:故事里的逻辑路径 `Audio/x.mp3` 解析为 `/Audio/x.mp3`,
60
+ // 开发与打包产物一致,不依赖进程工作目录。资源根之外无隐式查找路径。
61
+ publicDir: "Resources",
62
+
63
+ // 宿主端口与 Tauri 约定一致;换平台壳时只改这里
64
+ server: { port: 1420, strictPort: true },
65
+
66
+ plugins: [vue(), storyFontsVirtual()],
67
+ });
@@ -0,0 +1,65 @@
1
+ # pack-template.ps1 — 把脚手架工程目录打包为 ZIP(排除依赖/产物/版本库/运行期存档)
2
+ # 跨平台:PowerShell 7(pwsh)在 Windows / Linux / macOS 均可用。
3
+ # 用法: pwsh -File pack-template.ps1 -SourceDir "./__PROJECT__" -OutputFile "./__PROJECT__.zip"
4
+ param(
5
+ [Parameter(Mandatory = $true)]
6
+ [string]$SourceDir,
7
+
8
+ [Parameter(Mandatory = $true)]
9
+ [string]$OutputFile
10
+ )
11
+
12
+ $ErrorActionPreference = 'Stop'
13
+
14
+ # 路径分隔符归一(调用方可能传入反斜杠)
15
+ $SourceDir = $SourceDir -replace '\\', '/'
16
+ $OutputFile = $OutputFile -replace '\\', '/'
17
+
18
+ # 排除目录:依赖、构建产物、版本库、运行期存档
19
+ $excludeDirs = @('node_modules', 'dist', '.git', 'Saves')
20
+
21
+ $sourcePath = Resolve-Path $SourceDir
22
+ $sourceRoot = $sourcePath.Path
23
+
24
+ $outputFull = [System.IO.Path]::GetFullPath($OutputFile)
25
+ $outputDir = Split-Path $outputFull -Parent
26
+ if ($outputDir -and -not (Test-Path $outputDir)) {
27
+ New-Item -ItemType Directory -Path $outputDir -Force | Out-Null
28
+ }
29
+ if (Test-Path $outputFull) { Remove-Item $outputFull -Force }
30
+
31
+ $tempBase = if ($env:TEMP) { $env:TEMP }
32
+ elseif ($env:TMPDIR) { $env:TMPDIR }
33
+ else { [System.IO.Path]::GetTempPath() }
34
+ $tempDir = Join-Path $tempBase "lingfan_template_$(Get-Random)"
35
+
36
+ try {
37
+ New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
38
+
39
+ Get-ChildItem -Path $sourceRoot -Recurse -Force | ForEach-Object {
40
+ $relative = $_.FullName.Substring($sourceRoot.Length).TrimStart('\', '/')
41
+ if (-not $relative) { return }
42
+
43
+ $segments = $relative -split '[\\/]'
44
+ foreach ($excluded in $excludeDirs) {
45
+ if ($segments -contains $excluded) { return }
46
+ }
47
+
48
+ $dest = Join-Path $tempDir $relative
49
+ if ($_.PSIsContainer) {
50
+ New-Item -ItemType Directory -Path $dest -Force | Out-Null
51
+ } else {
52
+ $destParent = Split-Path $dest -Parent
53
+ if (-not (Test-Path $destParent)) {
54
+ New-Item -ItemType Directory -Path $destParent -Force | Out-Null
55
+ }
56
+ Copy-Item -LiteralPath $_.FullName -Destination $dest -Force
57
+ }
58
+ }
59
+
60
+ Compress-Archive -Path (Join-Path $tempDir '*') -DestinationPath $outputFull -Force
61
+ Write-Host "已打包: $outputFull"
62
+ }
63
+ finally {
64
+ if (Test-Path $tempDir) { Remove-Item $tempDir -Recurse -Force }
65
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "version": "1.6.0",
3
+ "minEngineVersion": "0.1.0",
4
+ "placeholder": "__PROJECT__",
5
+ "frameworks": [
6
+ {
7
+ "id": "none",
8
+ "label": "原生(框架无关)",
9
+ "hint": "只用骨架,不叠加任何框架层"
10
+ },
11
+ {
12
+ "id": "vue",
13
+ "label": "Vue 3",
14
+ "hint": "页面结构换成单文件组件,装配与宿主不变"
15
+ },
16
+ {
17
+ "id": "react",
18
+ "label": "React",
19
+ "hint": "页面结构换成 JSX 组件,装配与宿主不变"
20
+ }
21
+ ],
22
+ "shells": [
23
+ {
24
+ "id": "browser",
25
+ "label": "浏览器",
26
+ "hint": "只生成 Web 端工程,用 vite 起本地服务"
27
+ },
28
+ {
29
+ "id": "miniprogram",
30
+ "label": "小程序(UniApp)",
31
+ "hint": "页面层换成 UniApp Vue 3 单文件组件,宿主装配走小程序端口"
32
+ },
33
+ {
34
+ "id": "tauri",
35
+ "label": "桌面(Tauri 2)",
36
+ "hint": "给浏览器形态再加一个桌面壳:存档落到应用数据目录,其余不变"
37
+ }
38
+ ],
39
+ "_comment": "模板版本唯一来源,独立于引擎版本:仅当 template/v1 内容真正变化时才手动 bump。placeholder 是目录/文件内的工程名占位符,生成时整体替换为工程名(对齐 _LingFanEngineTemplateTitle_ 占位符语义)。minEngineVersion 表示此模板要求的最低引擎版本。frameworks 与 shells 决定生成器会问什么、能叠哪些层,首项为缺省值;每一项的 id 对应 template/v1/overlays/<id> 目录(缺省层可以没有目录)。"
40
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.