lecodes-cli 0.20.2 → 2.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.
Files changed (154) hide show
  1. package/README.md +56 -57
  2. package/dist/index.js +11052 -7592
  3. package/package.json +14 -8
  4. package/runtime/materials/decal-relief.mat +12 -1
  5. package/runtime/materials/decal.mat +17 -3
  6. package/runtime/materials/lightmap.mat +117 -138
  7. package/runtime/materials/particles-quad.mat +6 -2
  8. package/runtime/materials/terrain-lightmap.mat +123 -0
  9. package/runtime/materials/terrain.mat +36 -55
  10. package/runtime/sdk-types.json +1 -1
  11. package/runtime/web/VERSION.json +5 -0
  12. package/runtime/web/assets/camera-5XOM8eHl.js +1 -0
  13. package/runtime/web/assets/creator-2d-D9WKYM6h.js +1 -0
  14. package/runtime/web/assets/creator-2d-ukvEmNEp.wasm +0 -0
  15. package/runtime/web/assets/creator-full-BBXzQlhq.js +1 -0
  16. package/runtime/web/assets/creator-full-D2dSDdDj.wasm +0 -0
  17. package/runtime/web/assets/creator-full.js-BYswGsqR.symbols +8124 -0
  18. package/runtime/web/assets/creator-ui-DIc92ion.wasm +0 -0
  19. package/runtime/web/assets/creator-ui-_1Z_AX2M.js +1 -0
  20. package/runtime/web/assets/geolocation-BjTKN9_P.js +1 -0
  21. package/runtime/web/assets/inspect-C7x78PNs.js +2 -0
  22. package/runtime/web/assets/map-CyBxOSV0.js +1 -0
  23. package/runtime/web/assets/map-XzoOFt0E.js +2 -0
  24. package/runtime/web/assets/mapImpl-bxvQ2h1Z.js +823 -0
  25. package/runtime/web/assets/maplibre-gl-worker-B7LXXUkR.js +8 -0
  26. package/runtime/web/assets/materials-uri4FvPE.bin +0 -0
  27. package/runtime/web/assets/materials-world-CQWt8TAm.bin +0 -0
  28. package/runtime/web/assets/qr-scanner-CK_cYoJR.js +1 -0
  29. package/runtime/web/assets/uberarchive-DLH-kBhM.bin +0 -0
  30. package/runtime/web/index.html +36 -0
  31. package/runtime/web/player.js +21 -0
  32. package/runtime/web-page/index.html +41 -0
  33. package/runtime/web-page/page.css +1 -0
  34. package/runtime/web-page/page.js +31 -0
  35. package/src/api.ts +1 -302
  36. package/src/cli/args.ts +37 -0
  37. package/src/cli/command.ts +113 -0
  38. package/src/cli/errors.ts +13 -0
  39. package/src/cli/help.ts +158 -0
  40. package/src/cli/index.ts +7 -0
  41. package/src/cli/output.ts +102 -0
  42. package/src/cli/run.ts +106 -0
  43. package/src/commands/{appAndroid.ts → app/android.ts} +454 -43
  44. package/src/commands/{appDesktop.ts → app/desktop.ts} +64 -33
  45. package/src/commands/{appDesktopMac.ts → app/desktopMac.ts} +34 -27
  46. package/src/commands/{appIcon.ts → app/icon.ts} +11 -8
  47. package/src/commands/{app.ts → app/index.ts} +400 -290
  48. package/src/commands/{appShared.ts → app/shared.ts} +43 -44
  49. package/src/commands/{appTemplatesAndroid.ts → app/templates/android.ts} +72 -39
  50. package/src/commands/{appTemplatesGradlew.ts → app/templates/gradlew.ts} +1 -1
  51. package/src/commands/{appTemplates.ts → app/templates/ios.ts} +2 -2
  52. package/src/commands/assets.ts +23 -21
  53. package/src/commands/clone.ts +48 -51
  54. package/src/commands/compile.ts +76 -89
  55. package/src/commands/create.ts +46 -47
  56. package/src/commands/design/comments.ts +361 -0
  57. package/src/commands/design/context.ts +101 -0
  58. package/src/commands/design/index.ts +391 -0
  59. package/src/commands/design/snapshot.ts +134 -0
  60. package/src/commands/{designTemplates.ts → design/templates.ts} +4 -3
  61. package/src/commands/desktop.ts +94 -82
  62. package/src/commands/dev.ts +260 -182
  63. package/src/commands/diff.ts +39 -51
  64. package/src/commands/index.ts +64 -0
  65. package/src/commands/{init.ts → init/index.ts} +195 -191
  66. package/src/commands/{projectTemplates.ts → init/templates.ts} +64 -21
  67. package/src/commands/install.ts +80 -67
  68. package/src/commands/lightmap.ts +543 -252
  69. package/src/commands/link.ts +87 -94
  70. package/src/commands/login.ts +25 -23
  71. package/src/commands/navmesh.ts +169 -139
  72. package/src/commands/plugin.ts +46 -0
  73. package/src/commands/pn.ts +201 -244
  74. package/src/commands/pull.ts +49 -56
  75. package/src/commands/push.ts +48 -54
  76. package/src/commands/render.ts +176 -111
  77. package/src/commands/scene.ts +63 -55
  78. package/src/commands/serve.ts +58 -0
  79. package/src/commands/{shaders.ts → shaders/index.ts} +61 -42
  80. package/src/commands/{shadersNew.ts → shaders/new.ts} +3 -3
  81. package/src/commands/shared.ts +79 -0
  82. package/src/commands/status.ts +22 -26
  83. package/src/commands/test.ts +94 -63
  84. package/src/commands/thumbs.ts +185 -175
  85. package/src/commands/update/index.ts +226 -0
  86. package/src/commands/{types.ts → update/types.ts} +31 -22
  87. package/src/compile/collect.ts +5 -5
  88. package/src/compile/collectLocal.ts +3 -3
  89. package/src/compile/designCompile.ts +4 -4
  90. package/src/compile/headlessBundle.ts +16 -12
  91. package/src/compile/nativeStack.ts +1 -1
  92. package/src/compile/projectCompile.ts +12 -4
  93. package/src/compile/sceneCompile.ts +14 -26
  94. package/src/compile/screenEntry.ts +123 -127
  95. package/src/compile/shaders.ts +3 -3
  96. package/src/{lecodes-3d-editor.d.ts → declarations/lecodes-3d-editor.d.ts} +4 -0
  97. package/src/{lecodes-assets.d.ts → declarations/lecodes-assets.d.ts} +1 -1
  98. package/src/{lecodes-renderer.d.ts → declarations/lecodes-headless.d.ts} +3 -3
  99. package/src/dev/androidDev.ts +1 -1
  100. package/src/dev/clientTemplates.ts +18 -14
  101. package/src/dev/devServer.ts +78 -41
  102. package/src/dev/iosDev.ts +180 -0
  103. package/src/dev/webRunner.ts +83 -15
  104. package/src/{cmgenTool.ts → hosts/cmgenTool.ts} +2 -2
  105. package/src/{desktopRenderer.ts → hosts/desktopRenderer.ts} +104 -32
  106. package/src/{desktopScript.ts → hosts/desktopScript.ts} +151 -36
  107. package/src/{distRoot.ts → hosts/distRoot.ts} +9 -5
  108. package/src/{matcTool.ts → hosts/matcTool.ts} +2 -2
  109. package/src/{peerInstall.ts → hosts/peerInstall.ts} +7 -7
  110. package/src/{peers.ts → hosts/peers.ts} +2 -2
  111. package/src/{releases.ts → hosts/releases.ts} +1 -1
  112. package/src/index.ts +35 -480
  113. package/src/platform/api.ts +302 -0
  114. package/src/{browserAuth.ts → platform/browserAuth.ts} +1 -1
  115. package/src/{config.ts → platform/config.ts} +1 -1
  116. package/src/{serverDiff.ts → platform/serverDiff.ts} +3 -3
  117. package/src/plugin/contract.ts +438 -0
  118. package/src/plugin/emitKotlin.ts +357 -0
  119. package/src/plugin/emitSdk.ts +259 -0
  120. package/src/plugin/emitSwift.ts +336 -0
  121. package/src/plugin/emitWeb.ts +383 -0
  122. package/src/plugin/generate.ts +157 -0
  123. package/src/plugin/lines.ts +28 -0
  124. package/src/plugin/lower.ts +231 -0
  125. package/src/plugin/manifest.ts +192 -0
  126. package/src/{projectEnv.ts → project/env.ts} +33 -2
  127. package/src/{ignore.ts → project/ignore.ts} +164 -163
  128. package/src/{localFiles.ts → project/localFiles.ts} +1 -1
  129. package/src/{manifest.ts → project/manifest.ts} +1 -1
  130. package/src/{project.ts → project/materialize.ts} +2 -2
  131. package/src/project/paths.ts +20 -0
  132. package/src/{textDiff.ts → project/textDiff.ts} +1 -1
  133. package/src/{types.ts → project/types.ts} +0 -0
  134. package/runtime/materials/lightmap-baked-lite.mat +0 -175
  135. package/runtime/materials/lightmap-baked.mat +0 -176
  136. package/runtime/scene-harness.json +0 -1
  137. package/runtime/web/assets/__vite-browser-external-BIHI7g3E.js +0 -1
  138. package/runtime/web/assets/basis-C64VHDVD.js +0 -1
  139. package/runtime/web/assets/basis_transcoder-VXdx5NbI.wasm +0 -0
  140. package/runtime/web/assets/createViewerLite-Ct_PZdof.js +0 -852
  141. package/runtime/web/assets/draco-BiISTFcR.js +0 -118
  142. package/runtime/web/assets/draco_decoder-DsQ12WqX.wasm +0 -0
  143. package/runtime/web/assets/index-BMt7AnC5.js +0 -2
  144. package/runtime/web/assets/mapViewImpl-B2JcES8l.js +0 -810
  145. package/runtime/web/assets/maplibre-gl-worker-CJfwIrte.js +0 -8
  146. package/runtime/web/assets/worker-Caf-yYEI.js +0 -2
  147. package/runtime/web/embed.html +0 -32
  148. package/runtime/web/embed.js +0 -171
  149. package/src/commands/design.ts +0 -846
  150. package/src/commands/update.ts +0 -211
  151. package/src/util.ts +0 -146
  152. /package/src/{lecodes-design.d.ts → declarations/lecodes-design.d.ts} +0 -0
  153. /package/src/{qrcode-terminal.d.ts → declarations/qrcode-terminal.d.ts} +0 -0
  154. /package/src/{designMeta.ts → project/designMeta.ts} +0 -0
@@ -1,8 +1,8 @@
1
1
  import { execFileSync } from "node:child_process"
2
2
  import { appendFileSync, chmodSync, cpSync, existsSync, mkdirSync, readFileSync, realpathSync, rmSync, symlinkSync } from "node:fs"
3
3
  import { homedir } from "node:os"
4
- import { basename, delimiter, dirname, join, resolve, sep } from "node:path"
5
- import { c, CliError, flagBool, flagStr, log, success, warn, type Args } from "../util"
4
+ import { basename, delimiter, dirname, join, resolve } from "node:path"
5
+ import { CliError, bool, c, defineCommand, log, str, success, warn } from "../cli"
6
6
 
7
7
  /*
8
8
  * `lecodes install` — install this standalone build so `lecodes` is on your PATH.
@@ -17,15 +17,13 @@ import { c, CliError, flagBool, flagStr, log, success, warn, type Args } from ".
17
17
  * PATH is only edited on request (`--modify-path`); otherwise we place the files and print exactly how
18
18
  * to finish (a one-liner for this shell, a line for the rc file, or `--system` which lands in
19
19
  * /usr/local/bin and needs no PATH edit). Only meaningful for the release archive — from npm/monorepo
20
- * source process.execPath has no bundle beside it, so it refuses.
20
+ * source process.execPath has no bundle beside it, so it refuses. The registry hides the command
21
+ * unless the running binary IS such a bundle (src/index.ts decides).
21
22
  */
22
23
 
23
24
  const isWin = process.platform === "win32"
24
25
  const HOME = homedir()
25
26
 
26
- /** Display a path with the home dir collapsed to `~` (for copy-pasteable hints). */
27
- const tildify = (p: string): string => (p === HOME || p.startsWith(HOME + sep)) ? "~" + p.slice(HOME.length) : p
28
-
29
27
  const safeRealpath = (p: string): string => { try { return realpathSync(p) } catch { return resolve(p) } }
30
28
 
31
29
  /** True if `dir` is already an entry in PATH (compared by resolved path). */
@@ -37,25 +35,7 @@ const onPath = (dir: string): boolean => {
37
35
  })
38
36
  }
39
37
 
40
- export const install = async (args: Args): Promise<void> => {
41
- const bundle = dirname(process.execPath)
42
- const exeName = basename(process.execPath) // "lecodes" | "lecodes.exe"
43
- const chiselName = isWin ? "chisel.exe" : "chisel"
44
-
45
- // Guard: this must be the packaged standalone bundle (chisel + runtime/ sit next to the binary).
46
- // From npm / the monorepo, process.execPath is the bun/node binary and has no companions.
47
- if (!existsSync(join(bundle, "runtime")) || !existsSync(join(bundle, chiselName))) {
48
- throw new CliError(
49
- "`lecodes install` only works from the packaged release build (the archive containing lecodes + " +
50
- "chisel + runtime/). You appear to be running from source or an npm install — install globally " +
51
- "with your package manager there instead.",
52
- )
53
- }
54
-
55
- const companions = [exeName, chiselName, "runtime", "README.txt"].filter(f => existsSync(join(bundle, f)))
56
- if (isWin) return installWindows(args, bundle, companions)
57
- return installUnix(args, bundle, companions)
58
- }
38
+ type InstallOptions = { modifyPath: boolean, system: boolean, dir?: string, bin?: string }
59
39
 
60
40
  /** Copy the bundle's companion files into `target` (skipping the copy when target IS the bundle). */
61
41
  const copyBundle = (bundle: string, target: string, companions: string[]): void => {
@@ -79,29 +59,6 @@ const permError = (e: unknown, dir: string, system: boolean): CliError => {
79
59
  return new CliError(`Install failed: ${e instanceof Error ? e.message : String(e)}`)
80
60
  }
81
61
 
82
- const installUnix = (args: Args, bundle: string, companions: string[]): void => {
83
- const system = flagBool(args, "system")
84
- const libDir = resolve(flagStr(args, "dir") ?? (system ? "/usr/local/lib/lecodes-cli" : join(HOME, ".local", "lib", "lecodes-cli")))
85
- const binDir = resolve(flagStr(args, "bin") ?? (system ? "/usr/local/bin" : join(HOME, ".local", "bin")))
86
- const link = join(binDir, "lecodes")
87
-
88
- try {
89
- copyBundle(bundle, libDir, companions)
90
- chmodSync(join(libDir, "lecodes"), 0o755)
91
- chmodSync(join(libDir, "chisel"), 0o755)
92
- } catch (e) { throw permError(e, libDir, system) }
93
-
94
- try {
95
- mkdirSync(binDir, { recursive: true })
96
- rmSync(link, { force: true }) // replace a previous symlink/file
97
- symlinkSync(join(libDir, "lecodes"), link)
98
- } catch (e) { throw permError(e, binDir, system) }
99
-
100
- success(`Installed to ${c.bold(libDir)}`)
101
- log(` ${c.dim(link + " → " + join(libDir, "lecodes"))}`)
102
- finishPathUnix(args, binDir)
103
- }
104
-
105
62
  /** The shell startup file to persist PATH into, picked from $SHELL (bash/zsh handled; else ~/.profile,
106
63
  * which login shells read). Returns the absolute path and a ~-collapsed display name. */
107
64
  const shellRc = (): { file: string, name: string } => {
@@ -127,12 +84,12 @@ const appendPathToShellRc = (binDir: string): string | null => {
127
84
  }
128
85
 
129
86
  /** Put `binDir` on PATH: verify (already there), or `--modify-path` (edit the rc), or print how. */
130
- const finishPathUnix = (args: Args, binDir: string): void => {
87
+ const finishPathUnix = (modifyPath: boolean, binDir: string): void => {
131
88
  if (onPath(binDir)) {
132
89
  log(` Run ${c.bold("lecodes --version")} in a new shell to verify.`)
133
90
  return
134
91
  }
135
- if (flagBool(args, "modify-path")) {
92
+ if (modifyPath) {
136
93
  const rc = appendPathToShellRc(binDir)
137
94
  if (rc) {
138
95
  success(`Added ${c.bold(binDir)} to PATH in ${rc}.`)
@@ -151,8 +108,46 @@ const finishPathUnix = (args: Args, binDir: string): void => {
151
108
  log(` • or install system-wide (no PATH edit): ${c.bold("sudo lecodes install --system")}`)
152
109
  }
153
110
 
154
- const installWindows = (args: Args, bundle: string, companions: string[]): void => {
155
- const target = resolve(flagStr(args, "dir") ?? join(process.env.LOCALAPPDATA ?? join(HOME, "AppData", "Local"), "Programs", "lecodes-cli"))
111
+ const installUnix = (opts: InstallOptions, bundle: string, companions: string[]): void => {
112
+ const { system } = opts
113
+ const libDir = resolve(opts.dir ?? (system ? "/usr/local/lib/lecodes-cli" : join(HOME, ".local", "lib", "lecodes-cli")))
114
+ const binDir = resolve(opts.bin ?? (system ? "/usr/local/bin" : join(HOME, ".local", "bin")))
115
+ const link = join(binDir, "lecodes")
116
+
117
+ try {
118
+ copyBundle(bundle, libDir, companions)
119
+ chmodSync(join(libDir, "lecodes"), 0o755)
120
+ chmodSync(join(libDir, "chisel"), 0o755)
121
+ } catch (e) { throw permError(e, libDir, system) }
122
+
123
+ try {
124
+ mkdirSync(binDir, { recursive: true })
125
+ rmSync(link, { force: true }) // replace a previous symlink/file
126
+ symlinkSync(join(libDir, "lecodes"), link)
127
+ } catch (e) { throw permError(e, binDir, system) }
128
+
129
+ success(`Installed to ${c.bold(libDir)}`)
130
+ log(` ${c.dim(link + " → " + join(libDir, "lecodes"))}`)
131
+ finishPathUnix(opts.modifyPath, binDir)
132
+ }
133
+
134
+ /** Append `dir` to the current user's Path via the .NET env API (PowerShell). Unlike `setx` this never
135
+ * truncates a long Path. The dir is passed through an env var to avoid any quoting/injection. */
136
+ const addToUserPathWindows = (dir: string): boolean => {
137
+ const script =
138
+ "$d = $env:LECODES_INSTALL_DIR;" +
139
+ "$p = [Environment]::GetEnvironmentVariable('Path','User'); if (-not $p) { $p = '' };" +
140
+ "$parts = @($p.Split(';') | Where-Object { $_ -ne '' });" +
141
+ "if ($parts -notcontains $d) { [Environment]::SetEnvironmentVariable('Path', (@($parts + $d) -join ';'), 'User') }"
142
+ try {
143
+ execFileSync("powershell", ["-NoProfile", "-NonInteractive", "-Command", script],
144
+ { stdio: "ignore", env: { ...process.env, LECODES_INSTALL_DIR: dir } })
145
+ return true
146
+ } catch { return false }
147
+ }
148
+
149
+ const installWindows = (opts: InstallOptions, bundle: string, companions: string[]): void => {
150
+ const target = resolve(opts.dir ?? join(process.env.LOCALAPPDATA ?? join(HOME, "AppData", "Local"), "Programs", "lecodes-cli"))
156
151
 
157
152
  try {
158
153
  copyBundle(bundle, target, companions)
@@ -167,7 +162,7 @@ const installWindows = (args: Args, bundle: string, companions: string[]): void
167
162
  log(` Already on PATH — run ${c.bold("lecodes --version")} in a new terminal.`)
168
163
  return
169
164
  }
170
- if (flagBool(args, "modify-path")) {
165
+ if (opts.modifyPath) {
171
166
  if (addToUserPathWindows(target)) {
172
167
  success(`Added ${c.bold(target)} to your user PATH.`)
173
168
  log(` ${c.yellow("Open a NEW terminal")} for it to take effect, then run ${c.bold("lecodes --version")}.`)
@@ -182,17 +177,35 @@ const installWindows = (args: Args, bundle: string, companions: string[]): void
182
177
  log(` • or add the folder manually via System → Environment Variables.`)
183
178
  }
184
179
 
185
- /** Append `dir` to the current user's Path via the .NET env API (PowerShell). Unlike `setx` this never
186
- * truncates a long Path. The dir is passed through an env var to avoid any quoting/injection. */
187
- const addToUserPathWindows = (dir: string): boolean => {
188
- const script =
189
- "$d = $env:LECODES_INSTALL_DIR;" +
190
- "$p = [Environment]::GetEnvironmentVariable('Path','User'); if (-not $p) { $p = '' };" +
191
- "$parts = @($p.Split(';') | Where-Object { $_ -ne '' });" +
192
- "if ($parts -notcontains $d) { [Environment]::SetEnvironmentVariable('Path', (@($parts + $d) -join ';'), 'User') }"
193
- try {
194
- execFileSync("powershell", ["-NoProfile", "-NonInteractive", "-Command", script],
195
- { stdio: "ignore", env: { ...process.env, LECODES_INSTALL_DIR: dir } })
196
- return true
197
- } catch { return false }
198
- }
180
+ export default defineCommand({
181
+ name: "install",
182
+ summary: "Install this standalone build so `lecodes` is on your PATH",
183
+ description: "Copies the bundle (lecodes + chisel + runtime/) to a library folder and exposes the binary: a symlink in ~/.local/bin on Linux/macOS, the install folder itself on PATH on Windows. PATH is only edited with --modify-path; otherwise the command prints how to finish. Only works from the packaged release archive.",
184
+ flags: {
185
+ "modify-path": bool("also add it to PATH (edits your shell rc / user PATH)"),
186
+ system: bool("install for all users (Linux/macOS; needs sudo)"),
187
+ dir: str("override the install/library folder", { value: "<path>" }),
188
+ bin: str("override the symlink folder (Linux/macOS)", { value: "<path>" }),
189
+ },
190
+ examples: ["lecodes install --modify-path", "sudo lecodes install --system"],
191
+ run: ({ flags }) => {
192
+ const bundle = dirname(process.execPath)
193
+ const exeName = basename(process.execPath) // "lecodes" | "lecodes.exe"
194
+ const chiselName = isWin ? "chisel.exe" : "chisel"
195
+
196
+ // Guard: this must be the packaged standalone bundle (chisel + runtime/ sit next to the binary).
197
+ // From npm / the monorepo, process.execPath is the bun/node binary and has no companions.
198
+ if (!existsSync(join(bundle, "runtime")) || !existsSync(join(bundle, chiselName))) {
199
+ throw new CliError(
200
+ "`lecodes install` only works from the packaged release build (the archive containing lecodes + " +
201
+ "chisel + runtime/). You appear to be running from source or an npm install — install globally " +
202
+ "with your package manager there instead.",
203
+ )
204
+ }
205
+
206
+ const companions = [exeName, chiselName, "runtime", "README.txt"].filter(f => existsSync(join(bundle, f)))
207
+ const opts: InstallOptions = { modifyPath: flags["modify-path"], system: flags.system, dir: flags.dir, bin: flags.bin }
208
+ if (isWin) return installWindows(opts, bundle, companions)
209
+ return installUnix(opts, bundle, companions)
210
+ },
211
+ })