lecodes-sdk 2.0.9 → 2.0.11
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/dist/global.d.ts +1 -0
- package/dist/host.d.ts +6 -2
- package/dist/types/gl/Light.d.ts +0 -11
- package/dist/types/runtime/misc.d.ts +4 -0
- package/dist/types/ui/UITabs.d.ts +16 -3
- package/dist/types/version.d.ts +1 -1
- package/dist/types.json +1 -1
- package/package.json +1 -1
- package/prompts/core.md +1 -1
- package/prompts/ui.md +5 -7
- package/src/compile/assetMacro.ts +69 -4
- package/src/compile/bundler.ts +10 -3
- package/src/gl/Light.ts +257 -270
- package/src/host.d.ts +6 -2
- package/src/runtime/misc.ts +4 -0
- package/src/ui/UIPager.ts +2 -0
- package/src/ui/UITabs.ts +43 -5
- package/src/version.ts +1 -1
package/src/ui/UITabs.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PagerElement, type UIPager } from "./UIPager"
|
|
1
|
+
import { PagerElement, _activePagers, type UIPager } from "./UIPager"
|
|
2
2
|
import { ScreenElement, UIScreen } from "./UIScreen"
|
|
3
3
|
import { UIButton } from "./UIButton"
|
|
4
4
|
import { UIRow, UIColumn, type UIRow as UIRowType } from "./UIContainer"
|
|
@@ -63,6 +63,9 @@ export interface UITabs extends UIScreen {
|
|
|
63
63
|
readonly bar: UIRowType,
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
/** The tabs by the pager each owns — what `UITabs.current` resolves through the active pagers. */
|
|
67
|
+
const _byPager = new WeakMap<PagerElement, TabsElement>()
|
|
68
|
+
|
|
66
69
|
export class TabsElement extends ScreenElement {
|
|
67
70
|
private readonly ids: string[]
|
|
68
71
|
private readonly _pagerEl: PagerElement
|
|
@@ -80,6 +83,7 @@ export class TabsElement extends ScreenElement {
|
|
|
80
83
|
if (this.ids.length === 0) console.warn("UITabs: no tabs declared")
|
|
81
84
|
|
|
82
85
|
this._pagerEl = new PagerElement({ flexGrow: 1 }, this.ids.map((id) => defs[id].screen))
|
|
86
|
+
_byPager.set(this._pagerEl, this)
|
|
83
87
|
|
|
84
88
|
const buttons = this.ids.map((id, i) => {
|
|
85
89
|
const def = defs[id]
|
|
@@ -173,10 +177,44 @@ export class TabsElement extends ScreenElement {
|
|
|
173
177
|
}
|
|
174
178
|
}
|
|
175
179
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
+
export interface UITabsConstructor {
|
|
181
|
+
/** Create the standard bottom-tab shell — see {@link UITabs}. Keys are tab ids in tab order;
|
|
182
|
+
* each tab needs a `label` and its root `screen` (plus an optional `icon`). */
|
|
183
|
+
(tabs: Record<string, UITabDef>): UITabs
|
|
184
|
+
/** The tabs whose page is currently visible, or `null` when the visible screen is not a tab
|
|
185
|
+
* of any — the twin of `UIPager.current`, so a screen switches tabs with no reference
|
|
186
|
+
* threading: `UITabs.current?.select("services")`. With tabs nested inside a tab's page,
|
|
187
|
+
* resolves to the innermost. */
|
|
188
|
+
readonly current: UITabs | null
|
|
189
|
+
/** `UITabs.current.select(id)` — switch the visible tabs to `id`; a console warning and no-op
|
|
190
|
+
* when no tabs are on screen. */
|
|
191
|
+
select(id: string, animated?: boolean): void
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const tabsFactory = (tabs: Record<string, UITabDef>): UITabs => new TabsElement(tabs) as unknown as UITabs
|
|
195
|
+
|
|
196
|
+
/** Create the standard bottom-tab shell — see {@link UITabs}; `UITabs.current` / `UITabs.select(id)`
|
|
197
|
+
* reach the visible tabs from anywhere. */
|
|
198
|
+
export const UITabs = tabsFactory as unknown as UITabsConstructor
|
|
199
|
+
|
|
200
|
+
const _resolveCurrent = (): TabsElement | null => {
|
|
201
|
+
const pagers = _activePagers()
|
|
202
|
+
for (let i = pagers.length - 1; i >= 0; i--) {
|
|
203
|
+
const tabs = _byPager.get(pagers[i])
|
|
204
|
+
if (tabs) return tabs
|
|
205
|
+
}
|
|
206
|
+
return null
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// The ambient statics, attached the way UIPager's are (a statement that mutates a binding this
|
|
210
|
+
// module declares is kept by chisel iff `UITabs` is reached — see UIPager.ts).
|
|
211
|
+
Object.defineProperty(UITabs, "current", {
|
|
212
|
+
get: () => (_resolveCurrent() ?? null) as unknown as UITabs | null,
|
|
213
|
+
})
|
|
214
|
+
;(UITabs as any).select = (id: string, animated?: boolean) => {
|
|
215
|
+
const tabs = _resolveCurrent()
|
|
216
|
+
if (!tabs) { console.warn("UITabs.select: no tabs on the current screen"); return }
|
|
217
|
+
tabs.select(id, animated)
|
|
180
218
|
}
|
|
181
219
|
|
|
182
220
|
// ---- defineTabs — the design-stage twin ---------------------------------------------------------
|
package/src/version.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// same manifest). Its MAJOR is the bundle ↔ runtime contract: a bundle's `// sdk:` header line
|
|
5
5
|
// and a host's embedded version must agree on the major for the host to run the bundle; minor
|
|
6
6
|
// and patch never gate anything (features are detected, never versioned).
|
|
7
|
-
export const SDK_VERSION = "2.0.
|
|
7
|
+
export const SDK_VERSION = "2.0.11"
|
|
8
8
|
|
|
9
9
|
/** The major of a semver string, or null when it is not one. */
|
|
10
10
|
export const sdkMajor = (version: string | null | undefined): number | null => {
|