lecodes-sdk 2.4.5 → 2.4.6
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/types/runtime/app.d.ts +14 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/types.json +1 -1
- package/package.json +1 -1
- package/src/bridges/app.d.ts +8 -1
- package/src/runtime/app.ts +14 -0
- package/src/version.ts +1 -1
package/package.json
CHANGED
package/src/bridges/app.d.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// `?` on a method = an optional slot: a host that leaves it null gets no such JS method, so the SDK's
|
|
12
12
|
// `typeof` feature-detects stay honest. The `HostApp` interface below adds the slots the runtime
|
|
13
13
|
// calls that JS never sees (notifications to the host).
|
|
14
|
-
import type { bytes, i32 } from "./types"
|
|
14
|
+
import type { bytes, f64, i32 } from "./types"
|
|
15
15
|
|
|
16
16
|
declare global {
|
|
17
17
|
// ---- World control (run/restart/quit — the platform's `location` analog) ----------------------
|
|
@@ -58,6 +58,13 @@ declare global {
|
|
|
58
58
|
/** Collect garbage, drain the release queue and report the live owned records per kind
|
|
59
59
|
* (`{"live":{"tree":n,…},"pending":n}`) — the read behind checks/owned. @custom */
|
|
60
60
|
ownedStats(): string
|
|
61
|
+
/** Collect garbage and drain the release queue now, logging `[gc] app.gc: <ms>, heap …, next at
|
|
62
|
+
* …, <n> owned resources freed`. `headroomMB` (> 0) puts the next automatic pass at least that
|
|
63
|
+
* many megabytes above the heap the pass left (QuickJS; until that pass). On JavaScriptCore a
|
|
64
|
+
* request (the engine collects on its own schedule, the drain follows: on iOS the line says 0;
|
|
65
|
+
* no headroom); the wasm arm collects only under Bun, in a browser page it is the drain alone.
|
|
66
|
+
* Web Lite has no such member. Backs app.gc. @custom */
|
|
67
|
+
gc?(headroomMB?: f64): void
|
|
61
68
|
/** Current lifecycle state: "active" | "background". Surfaced as app.state. */
|
|
62
69
|
state?(): string
|
|
63
70
|
/** Current connectivity (navigator.onLine semantics — best-effort: false only when the platform
|
package/src/runtime/app.ts
CHANGED
|
@@ -113,6 +113,20 @@ export const app = {
|
|
|
113
113
|
quit(): void {
|
|
114
114
|
_creatorApp.quit?.()
|
|
115
115
|
},
|
|
116
|
+
/** Collect garbage now: what the app no longer references — a finished level's nodes, its
|
|
117
|
+
* textures and materials — is freed before this returns, not whenever the collector next runs.
|
|
118
|
+
* Call it where a pause is invisible (a loading screen, between levels), after dropping the
|
|
119
|
+
* references; never during play — a collection walks the whole heap. It also puts the next
|
|
120
|
+
* automatic collection at half again the heap it leaves: the room the next stretch of play has.
|
|
121
|
+
* `headroomMB` asks for more room when the play ahead allocates more than that — a drive that
|
|
122
|
+
* streams in hundreds of megabytes of terrain buffers: `app.gc({ headroomMB: 512 })` keeps the
|
|
123
|
+
* next collection at least 512 MB away (until it comes; then the engine's rule again). The log's
|
|
124
|
+
* `[gc]` line says what it took, what it freed and where the next one is. On iOS a request the
|
|
125
|
+
* engine serves on its own schedule, without the headroom; a no-op in the browser, where a page
|
|
126
|
+
* cannot ask for a collection. */
|
|
127
|
+
gc(options?: { headroomMB?: number }): void {
|
|
128
|
+
_creatorApp.gc?.(options?.headroomMB)
|
|
129
|
+
},
|
|
116
130
|
/** Global back-press fallback (Android back button/gesture — iOS has no system back). Fires
|
|
117
131
|
* only when nothing else consumed the press: no open widget/modal claimed it, the current
|
|
118
132
|
* screen has no `onBack`, every pager is at its tab root and the router is at its
|
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.4.
|
|
7
|
+
export const SDK_VERSION = "2.4.6"
|
|
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 => {
|