lecodes-cli 2.2.5 → 2.2.8

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 (31) hide show
  1. package/dist/index.js +14715 -7203
  2. package/package.json +8 -8
  3. package/runtime/sdk-types.json +1 -1
  4. package/runtime/web/VERSION.json +3 -3
  5. package/runtime/web/assets/browser-BpFb50ko.js +1 -0
  6. package/runtime/web/assets/{creator-2d-k3rhDQq0.js → creator-2d-CP3Nfpma.js} +1 -1
  7. package/runtime/web/assets/{creator-2d-B6_ePUJi.wasm → creator-2d-DLtO_8eE.wasm} +0 -0
  8. package/runtime/web/assets/{creator-full-CDPJ-dlP.js → creator-full-B13Tbmyv.js} +1 -1
  9. package/runtime/web/assets/{creator-full-DsGh9J_X.wasm → creator-full-D1sSItG6.wasm} +0 -0
  10. package/runtime/web/assets/{creator-ui-SzE0bPRt.wasm → creator-ui-ByVRKvqF.wasm} +0 -0
  11. package/runtime/web/assets/{creator-ui-CslN9PKJ.js → creator-ui-CQghF7sw.js} +1 -1
  12. package/runtime/web/assets/{inspect-CE4HRex9.js → inspect-FppKjiJX.js} +2 -2
  13. package/runtime/web/assets/uberarchive-Ok2HfJvn.bin +0 -0
  14. package/runtime/web/assets/webrtc-CbCltXvl.js +1 -0
  15. package/runtime/web/player.js +17 -17
  16. package/runtime/web-lite/lite.js +5 -5
  17. package/runtime/web-lite/plugins/browser/index-BpFb50ko.js +1 -0
  18. package/runtime/web-lite/plugins/webrtc/index-CbCltXvl.js +1 -0
  19. package/runtime/web-lite/plugins.json +3 -1
  20. package/src/commands/app/android.ts +30 -3
  21. package/src/commands/app/desktop.ts +3 -2
  22. package/src/commands/app/index.ts +4 -4
  23. package/src/commands/app/shared.ts +18 -0
  24. package/src/commands/app/templates/android.ts +14 -2
  25. package/src/commands/app/templates/ios.ts +35 -3
  26. package/src/commands/init/index.ts +195 -195
  27. package/src/commands/shared.ts +79 -79
  28. package/src/commands/thumbs.ts +185 -185
  29. package/src/compile/screenEntry.ts +123 -123
  30. package/src/project/ignore.ts +164 -164
  31. package/runtime/web/assets/uberarchive-DLH-kBhM.bin +0 -0
@@ -1,164 +1,164 @@
1
- import { existsSync, readFileSync, writeFileSync } from "node:fs"
2
- import { join } from "node:path"
3
-
4
- /*
5
- * `.lecodesignore` support — keeps scratch files (temp probes, render screenshots, logs) out of
6
- * `status` / `push` so they never land in a checkpoint. Syntax is a practical subset of .gitignore:
7
- * - blank lines and `# comments` are skipped
8
- * - `!pattern` re-includes something a previous pattern ignored
9
- * - a trailing `/` matches directories only
10
- * - a leading `/` (or any embedded `/`) anchors the pattern to the project root
11
- * - `*` matches within a path segment, `**` across segments, `?` a single char
12
- * - a slash-free pattern (e.g. `_*`, `*.png`) matches a basename at any depth
13
- *
14
- * IMPORTANT: ignores apply to UNTRACKED files only. A file already in the project (recorded in the
15
- * manifest) is always tracked, even if it matches a pattern — so ignoring `*.png` can never make an
16
- * existing image asset silently disappear from the project. Pruning happens in `scanLocal`.
17
- */
18
-
19
- export type IgnoreMatcher = (key: string, isDir: boolean) => boolean
20
-
21
- type Rule = { re: RegExp, negate: boolean, dirOnly: boolean }
22
-
23
- // Always applied, even with no .lecodesignore — only patterns that are never real project assets, so
24
- // they're safe as invisible defaults. Everything asset-shaped (*.png, *.json, …) is opt-in via the
25
- // file written at clone time (see DEFAULT_IGNORE_FILE). `.artifacts/` is `lecodes test`'s
26
- // failure-frame dump dir (tests/.artifacts/) — regenerated scratch, never a project asset.
27
- // `dist/` is `lecodes app build desktop`'s default output (<root>/dist/<slug>, appDesktop.ts) —
28
- // same class, but it must be ignored for a second, load-bearing reason: that folder holds a COPY of
29
- // the host's runtime assets (lit.filamat, uberarchive.bin, …). Collected as project assets they get
30
- // staged next to the bundle, and onFetchLocal searches the bundle's dir BEFORE the host's assets dir
31
- // (main.cpp) — so the copy shadows the host's own. Harmless while every host was OpenGL and the
32
- // bytes matched; fatal once a build output can come from the Vulkan host, where the shadowing
33
- // lit.filamat is SPIR-V and Filament aborts with "not built for any of the OpenGL backend's
34
- // supported shader languages".
35
- // `.env` / `.env.*`: the project's LECODES_* config (projectEnv.ts) — it holds tokens and keystore
36
- // passwords, so it never leaves the machine whatever .lecodesignore says.
37
- // `.lightmap/` = a bake's float debug layers (`lecodes lightmap bake --debug-dir`): gigabytes the compile scan must never read
38
- const BUILTIN_PATTERNS = ["node_modules/", ".git/", "_*", "*.log", ".DS_Store", ".artifacts/", "dist/", ".env", ".env.*", ".lightmap/"]
39
-
40
- /** Template `.lecodesignore` written on clone — the explicit, editable "what we don't push" list. */
41
- export const DEFAULT_IGNORE_FILE = `# Files matched here are NOT pushed to LeCodes.
42
- # Only untracked files are affected — assets already in the project stay tracked
43
- # even if they match a pattern. Built-in defaults (node_modules, _*, *.log, .artifacts)
44
- # always apply.
45
-
46
- # Render / preview outputs (the default \`lecodes render --png\` target)
47
- screenshot.png
48
- shots/
49
-
50
- # Design-board comments live on the platform; design/comments/ is the local mirror of the
51
- # open ones (\`lecodes design comments pull\`) — read by Claude, but pushing it back as
52
- # project files would only duplicate the database.
53
- design/comments/
54
-
55
- # Image & other binary assets ARE pushed by default — they're real project resources.
56
- # Uncomment a pattern below only if you want to keep some untracked ones out of pushes.
57
- # *.png
58
-
59
- # Local notes & dumps (uncomment to ignore)
60
- # *.json
61
- # notes.md
62
- `
63
-
64
- /** Translate a glob (one path segment's worth of `*`/`?`/`**`) into a regex fragment. */
65
- const translate = (glob: string): string => {
66
- let re = ""
67
- for (let i = 0; i < glob.length; i++) {
68
- const ch = glob[i]
69
- if (ch === "*") {
70
- if (glob[i + 1] === "*") { re += ".*"; i++; if (glob[i + 1] === "/") i++ } // `**/` spans dirs
71
- else re += "[^/]*"
72
- } else if (ch === "?") re += "[^/]"
73
- else if (ch === "/") re += "/"
74
- else if ("\\^$.|+()[]{}".includes(ch)) re += "\\" + ch
75
- else re += ch
76
- }
77
- return re
78
- }
79
-
80
- const compile = (raw: string): Rule | null => {
81
- let p = raw.trim()
82
- if (!p || p.startsWith("#")) return null
83
- let negate = false
84
- if (p.startsWith("!")) { negate = true; p = p.slice(1) }
85
- let dirOnly = false
86
- if (p.endsWith("/")) { dirOnly = true; p = p.slice(0, -1) }
87
- const anchored = p.startsWith("/") || p.includes("/")
88
- if (p.startsWith("/")) p = p.slice(1)
89
- if (!p) return null
90
- const body = translate(p)
91
- // `(/.*)?$` lets a directory pattern also match files nested under it, matching gitignore behavior
92
- // even without relying on directory pruning.
93
- const re = anchored ? new RegExp("^/" + body + "(/.*)?$") : new RegExp("(^|/)" + body + "(/.*)?$")
94
- return { re, negate, dirOnly }
95
- }
96
-
97
- const buildMatcher = (rules: Rule[]): IgnoreMatcher => (key, isDir) => {
98
- let ignored = false
99
- for (const r of rules) {
100
- if (r.dirOnly && !isDir) continue // a `foo/` rule only matches dirs directly (files via prune)
101
- if (r.re.test(key)) ignored = !r.negate
102
- }
103
- return ignored
104
- }
105
-
106
- /** Compile a standalone glob list (same syntax as .lecodesignore lines, including `!` re-includes)
107
- * into a file-path matcher — used for app.json's `resources.remote` patterns. */
108
- export const buildGlobMatcher = (patterns: string[]): ((path: string) => boolean) => {
109
- // Matching is over FILE paths — normalize `videos/` (dir-only, would match nothing here) to
110
- // `videos`, whose `(/.*)?$` tail matches everything under the directory.
111
- const rules = patterns.map((p) => compile(p.trim().replace(/\/+$/, ""))).filter((r): r is Rule => r !== null)
112
- const match = buildMatcher(rules)
113
- // Anchored rules compile to `^/…` — they expect the canonical leading-slash key form.
114
- return (path) => match(path.startsWith("/") ? path : "/" + path, false)
115
- }
116
-
117
- /** Read `<root>/.lecodesignore` (if any) and combine with the built-in defaults into a matcher. */
118
- export const loadIgnore = (root: string): IgnoreMatcher => {
119
- const lines = [...BUILTIN_PATTERNS]
120
- const file = join(root, ".lecodesignore")
121
- if (existsSync(file)) {
122
- try { lines.push(...readFileSync(file, "utf8").split(/\r?\n/)) } catch { /* unreadable → defaults only */ }
123
- }
124
- const rules = lines.map(compile).filter((r): r is Rule => r !== null)
125
- return buildMatcher(rules)
126
- }
127
-
128
- /** Write the template `.lecodesignore` if the project doesn't have one yet (used on clone). */
129
- export const writeDefaultIgnore = (root: string) => {
130
- const file = join(root, ".lecodesignore")
131
- if (!existsSync(file)) writeFileSync(file, DEFAULT_IGNORE_FILE)
132
- }
133
-
134
- /* `.gitignore` for the project's OWN git repo. `.lecodes/` is per-checkout state — regenerable IDE
135
- * types (`lecodes update`) + `manifest.json`, this machine's push cursor (baseHeadId + per-file shas).
136
- * Committing it makes collaborators fight over the cursor and ship stale types, so every scaffold
137
- * path (init / clone / link) makes sure it's ignored. Render outputs mirror DEFAULT_IGNORE_FILE. */
138
- export const DEFAULT_GITIGNORE = `# LeCodes per-checkout state: generated IDE types + this machine's sync cursor
139
- # (.lecodes/manifest.json). Regenerate with \`lecodes update\` / re-attach with \`lecodes link\`.
140
- .lecodes/
141
-
142
- # Render / preview outputs and test failure frames
143
- screenshot.png
144
- shots/
145
- tests/.artifacts/
146
- tests/.shots/
147
-
148
- node_modules/
149
-
150
- dist/
151
- `
152
-
153
- /** Create `.gitignore` if missing; if it exists but doesn't ignore `.lecodes/`, append that rule.
154
- * Returns what happened so callers can log it ("created" | "updated" | null). */
155
- export const ensureGitignore = (root: string): "created" | "updated" | null => {
156
- const file = join(root, ".gitignore")
157
- if (!existsSync(file)) { writeFileSync(file, DEFAULT_GITIGNORE); return "created" }
158
- const text = readFileSync(file, "utf8")
159
- const covered = text.split(/\r?\n/).some(l => /^\/?\.lecodes\/?\s*$/.test(l.trim()))
160
- if (covered) return null
161
- const sep = text.length === 0 || text.endsWith("\n") ? "" : "\n"
162
- writeFileSync(file, `${text}${sep}\n# LeCodes per-checkout state (generated types + sync cursor) — not source\n.lecodes/\n`)
163
- return "updated"
164
- }
1
+ import { existsSync, readFileSync, writeFileSync } from "node:fs"
2
+ import { join } from "node:path"
3
+
4
+ /*
5
+ * `.lecodesignore` support — keeps scratch files (temp probes, render screenshots, logs) out of
6
+ * `status` / `push` so they never land in a checkpoint. Syntax is a practical subset of .gitignore:
7
+ * - blank lines and `# comments` are skipped
8
+ * - `!pattern` re-includes something a previous pattern ignored
9
+ * - a trailing `/` matches directories only
10
+ * - a leading `/` (or any embedded `/`) anchors the pattern to the project root
11
+ * - `*` matches within a path segment, `**` across segments, `?` a single char
12
+ * - a slash-free pattern (e.g. `_*`, `*.png`) matches a basename at any depth
13
+ *
14
+ * IMPORTANT: ignores apply to UNTRACKED files only. A file already in the project (recorded in the
15
+ * manifest) is always tracked, even if it matches a pattern — so ignoring `*.png` can never make an
16
+ * existing image asset silently disappear from the project. Pruning happens in `scanLocal`.
17
+ */
18
+
19
+ export type IgnoreMatcher = (key: string, isDir: boolean) => boolean
20
+
21
+ type Rule = { re: RegExp, negate: boolean, dirOnly: boolean }
22
+
23
+ // Always applied, even with no .lecodesignore — only patterns that are never real project assets, so
24
+ // they're safe as invisible defaults. Everything asset-shaped (*.png, *.json, …) is opt-in via the
25
+ // file written at clone time (see DEFAULT_IGNORE_FILE). `.artifacts/` is `lecodes test`'s
26
+ // failure-frame dump dir (tests/.artifacts/) — regenerated scratch, never a project asset.
27
+ // `dist/` is `lecodes app build desktop`'s default output (<root>/dist/<slug>, appDesktop.ts) —
28
+ // same class, but it must be ignored for a second, load-bearing reason: that folder holds a COPY of
29
+ // the host's runtime assets (lit.filamat, uberarchive.bin, …). Collected as project assets they get
30
+ // staged next to the bundle, and onFetchLocal searches the bundle's dir BEFORE the host's assets dir
31
+ // (main.cpp) — so the copy shadows the host's own. Harmless while every host was OpenGL and the
32
+ // bytes matched; fatal once a build output can come from the Vulkan host, where the shadowing
33
+ // lit.filamat is SPIR-V and Filament aborts with "not built for any of the OpenGL backend's
34
+ // supported shader languages".
35
+ // `.env` / `.env.*`: the project's LECODES_* config (projectEnv.ts) — it holds tokens and keystore
36
+ // passwords, so it never leaves the machine whatever .lecodesignore says.
37
+ // `.lightmap/` = a bake's float debug layers (`lecodes lightmap bake --debug-dir`): gigabytes the compile scan must never read
38
+ const BUILTIN_PATTERNS = ["node_modules/", ".git/", "_*", "*.log", ".DS_Store", ".artifacts/", "dist/", ".env", ".env.*", ".lightmap/"]
39
+
40
+ /** Template `.lecodesignore` written on clone — the explicit, editable "what we don't push" list. */
41
+ export const DEFAULT_IGNORE_FILE = `# Files matched here are NOT pushed to LeCodes.
42
+ # Only untracked files are affected — assets already in the project stay tracked
43
+ # even if they match a pattern. Built-in defaults (node_modules, _*, *.log, .artifacts)
44
+ # always apply.
45
+
46
+ # Render / preview outputs (the default \`lecodes render --png\` target)
47
+ screenshot.png
48
+ shots/
49
+
50
+ # Design-board comments live on the platform; design/comments/ is the local mirror of the
51
+ # open ones (\`lecodes design comments pull\`) — read by Claude, but pushing it back as
52
+ # project files would only duplicate the database.
53
+ design/comments/
54
+
55
+ # Image & other binary assets ARE pushed by default — they're real project resources.
56
+ # Uncomment a pattern below only if you want to keep some untracked ones out of pushes.
57
+ # *.png
58
+
59
+ # Local notes & dumps (uncomment to ignore)
60
+ # *.json
61
+ # notes.md
62
+ `
63
+
64
+ /** Translate a glob (one path segment's worth of `*`/`?`/`**`) into a regex fragment. */
65
+ const translate = (glob: string): string => {
66
+ let re = ""
67
+ for (let i = 0; i < glob.length; i++) {
68
+ const ch = glob[i]
69
+ if (ch === "*") {
70
+ if (glob[i + 1] === "*") { re += ".*"; i++; if (glob[i + 1] === "/") i++ } // `**/` spans dirs
71
+ else re += "[^/]*"
72
+ } else if (ch === "?") re += "[^/]"
73
+ else if (ch === "/") re += "/"
74
+ else if ("\\^$.|+()[]{}".includes(ch)) re += "\\" + ch
75
+ else re += ch
76
+ }
77
+ return re
78
+ }
79
+
80
+ const compile = (raw: string): Rule | null => {
81
+ let p = raw.trim()
82
+ if (!p || p.startsWith("#")) return null
83
+ let negate = false
84
+ if (p.startsWith("!")) { negate = true; p = p.slice(1) }
85
+ let dirOnly = false
86
+ if (p.endsWith("/")) { dirOnly = true; p = p.slice(0, -1) }
87
+ const anchored = p.startsWith("/") || p.includes("/")
88
+ if (p.startsWith("/")) p = p.slice(1)
89
+ if (!p) return null
90
+ const body = translate(p)
91
+ // `(/.*)?$` lets a directory pattern also match files nested under it, matching gitignore behavior
92
+ // even without relying on directory pruning.
93
+ const re = anchored ? new RegExp("^/" + body + "(/.*)?$") : new RegExp("(^|/)" + body + "(/.*)?$")
94
+ return { re, negate, dirOnly }
95
+ }
96
+
97
+ const buildMatcher = (rules: Rule[]): IgnoreMatcher => (key, isDir) => {
98
+ let ignored = false
99
+ for (const r of rules) {
100
+ if (r.dirOnly && !isDir) continue // a `foo/` rule only matches dirs directly (files via prune)
101
+ if (r.re.test(key)) ignored = !r.negate
102
+ }
103
+ return ignored
104
+ }
105
+
106
+ /** Compile a standalone glob list (same syntax as .lecodesignore lines, including `!` re-includes)
107
+ * into a file-path matcher — used for app.json's `resources.remote` patterns. */
108
+ export const buildGlobMatcher = (patterns: string[]): ((path: string) => boolean) => {
109
+ // Matching is over FILE paths — normalize `videos/` (dir-only, would match nothing here) to
110
+ // `videos`, whose `(/.*)?$` tail matches everything under the directory.
111
+ const rules = patterns.map((p) => compile(p.trim().replace(/\/+$/, ""))).filter((r): r is Rule => r !== null)
112
+ const match = buildMatcher(rules)
113
+ // Anchored rules compile to `^/…` — they expect the canonical leading-slash key form.
114
+ return (path) => match(path.startsWith("/") ? path : "/" + path, false)
115
+ }
116
+
117
+ /** Read `<root>/.lecodesignore` (if any) and combine with the built-in defaults into a matcher. */
118
+ export const loadIgnore = (root: string): IgnoreMatcher => {
119
+ const lines = [...BUILTIN_PATTERNS]
120
+ const file = join(root, ".lecodesignore")
121
+ if (existsSync(file)) {
122
+ try { lines.push(...readFileSync(file, "utf8").split(/\r?\n/)) } catch { /* unreadable → defaults only */ }
123
+ }
124
+ const rules = lines.map(compile).filter((r): r is Rule => r !== null)
125
+ return buildMatcher(rules)
126
+ }
127
+
128
+ /** Write the template `.lecodesignore` if the project doesn't have one yet (used on clone). */
129
+ export const writeDefaultIgnore = (root: string) => {
130
+ const file = join(root, ".lecodesignore")
131
+ if (!existsSync(file)) writeFileSync(file, DEFAULT_IGNORE_FILE)
132
+ }
133
+
134
+ /* `.gitignore` for the project's OWN git repo. `.lecodes/` is per-checkout state — regenerable IDE
135
+ * types (`lecodes update`) + `manifest.json`, this machine's push cursor (baseHeadId + per-file shas).
136
+ * Committing it makes collaborators fight over the cursor and ship stale types, so every scaffold
137
+ * path (init / clone / link) makes sure it's ignored. Render outputs mirror DEFAULT_IGNORE_FILE. */
138
+ export const DEFAULT_GITIGNORE = `# LeCodes per-checkout state: generated IDE types + this machine's sync cursor
139
+ # (.lecodes/manifest.json). Regenerate with \`lecodes update\` / re-attach with \`lecodes link\`.
140
+ .lecodes/
141
+
142
+ # Render / preview outputs and test failure frames
143
+ screenshot.png
144
+ shots/
145
+ tests/.artifacts/
146
+ tests/.shots/
147
+
148
+ node_modules/
149
+
150
+ dist/
151
+ `
152
+
153
+ /** Create `.gitignore` if missing; if it exists but doesn't ignore `.lecodes/`, append that rule.
154
+ * Returns what happened so callers can log it ("created" | "updated" | null). */
155
+ export const ensureGitignore = (root: string): "created" | "updated" | null => {
156
+ const file = join(root, ".gitignore")
157
+ if (!existsSync(file)) { writeFileSync(file, DEFAULT_GITIGNORE); return "created" }
158
+ const text = readFileSync(file, "utf8")
159
+ const covered = text.split(/\r?\n/).some(l => /^\/?\.lecodes\/?\s*$/.test(l.trim()))
160
+ if (covered) return null
161
+ const sep = text.length === 0 || text.endsWith("\n") ? "" : "\n"
162
+ writeFileSync(file, `${text}${sep}\n# LeCodes per-checkout state (generated types + sync cursor) — not source\n.lecodes/\n`)
163
+ return "updated"
164
+ }