lecodes-cli 0.18.0 → 0.18.2

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 (62) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +2013 -564
  3. package/package.json +4 -4
  4. package/runtime/scene-harness.json +1 -1
  5. package/runtime/sdk/core/Aspect.ts +512 -255
  6. package/runtime/sdk/core/compWrite.ts +42 -0
  7. package/runtime/sdk/core/fields.ts +1 -1
  8. package/runtime/sdk/core/time.ts +81 -0
  9. package/runtime/sdk/g2/Camera2D.ts +8 -1
  10. package/runtime/sdk/g2/CharacterController2D.ts +253 -53
  11. package/runtime/sdk/g2/Node2D.ts +80 -10
  12. package/runtime/sdk/g2/OneWay2D.ts +66 -0
  13. package/runtime/sdk/g2/Physics2D.ts +240 -30
  14. package/runtime/sdk/g2/Scene2D.ts +33 -1
  15. package/runtime/sdk/g2/Shape2D.ts +218 -22
  16. package/runtime/sdk/g2/Trigger2D.ts +42 -12
  17. package/runtime/sdk/g2/groups2d.ts +106 -0
  18. package/runtime/sdk/g2/loop.ts +15 -4
  19. package/runtime/sdk/gl/Camera.ts +40 -1
  20. package/runtime/sdk/gl/CameraPlace.ts +52 -51
  21. package/runtime/sdk/gl/CharacterController.ts +184 -56
  22. package/runtime/sdk/gl/Gearbox.ts +212 -0
  23. package/runtime/sdk/gl/Geometry.ts +70 -9
  24. package/runtime/sdk/gl/Light.ts +64 -2
  25. package/runtime/sdk/gl/Lightmap.ts +179 -0
  26. package/runtime/sdk/gl/Material.ts +25 -0
  27. package/runtime/sdk/gl/Mesh.ts +6 -23
  28. package/runtime/sdk/gl/Model.ts +16 -2
  29. package/runtime/sdk/gl/Node.ts +119 -39
  30. package/runtime/sdk/gl/Physics.ts +75 -24
  31. package/runtime/sdk/gl/Scene.ts +161 -5
  32. package/runtime/sdk/gl/Shape.ts +42 -3
  33. package/runtime/sdk/gl/Trigger.ts +45 -50
  34. package/runtime/sdk/gl/Vehicle.ts +276 -322
  35. package/runtime/sdk/gl/Wheel.ts +240 -0
  36. package/runtime/sdk/gl/scenarios.ts +4 -30
  37. package/runtime/sdk/gl/state.ts +6 -6
  38. package/runtime/sdk/inject.ts +186 -171
  39. package/runtime/sdk/runtime/device.ts +102 -1
  40. package/runtime/sdk/scene/defineScene.ts +108 -53
  41. package/runtime/sdk/scene/gizmos.ts +31 -11
  42. package/runtime/sdk/scene/material.ts +188 -0
  43. package/runtime/sdk-types.json +1 -1
  44. package/runtime/sdk/compile/aspectMacro.ts +0 -42
  45. package/runtime/sdk/compile/assetIconMacro.ts +0 -384
  46. package/runtime/sdk/compile/assetMacro.ts +0 -45
  47. package/runtime/sdk/compile/assetName.ts +0 -50
  48. package/runtime/sdk/compile/bundler.ts +0 -252
  49. package/runtime/sdk/compile/compileProject.ts +0 -129
  50. package/runtime/sdk/compile/detectEntry.ts +0 -128
  51. package/runtime/sdk/compile/fontMacro.ts +0 -459
  52. package/runtime/sdk/compile/fontRegistry.ts +0 -78
  53. package/runtime/sdk/compile/header.ts +0 -67
  54. package/runtime/sdk/compile/index.ts +0 -85
  55. package/runtime/sdk/compile/libraryImports.ts +0 -52
  56. package/runtime/sdk/compile/liteMaterial.ts +0 -247
  57. package/runtime/sdk/compile/sceneEditor.ts +0 -78
  58. package/runtime/sdk/compile/serverSplit.ts +0 -233
  59. package/runtime/sdk/compile/serverTypes.ts +0 -227
  60. package/runtime/sdk/compile/sfnt.ts +0 -98
  61. package/runtime/sdk/compile/shaderTargets.ts +0 -42
  62. package/runtime/sdk/compile/sourcemap.ts +0 -25
@@ -1,171 +1,186 @@
1
- // THE aggregation point. Every public global the SDK provides is re-exported here under the exact
2
- // name user code uses it as. The bundler passes this file to esbuild's `inject:` option, so user
3
- // code references `Scene`, `Sprite`, `toast`, … with no imports; esbuild tree-shakes away whatever
4
- // a given project does not use (so a pure-2D project drops all 3D classes, and vice versa).
5
- //
6
- // Rule: this is the ONLY file that `export`s public names. Everything else is internal and imported
7
- // by it. Host-provided globals (setLoop, console, setTimeout, DEG2RAD, asset, …) are NOT here —
8
- // they live in src/host.d.ts as declarations and stay as free references at runtime.
9
-
10
- // ---- math ----
11
- export { Mathf } from "./math/Mathf"
12
- export { Vec2, Vec3 } from "./math/vec"
13
- export { Quat } from "./math/quat"
14
- export { Mat4 } from "./math/mat4"
15
- export { Color } from "./core/color"
16
-
17
- // ---- aspects (attachable node capabilities) ----
18
- export { Aspect, type With } from "./core/Aspect"
19
- export { InspectorUI } from "./core/InspectorUI"
20
-
21
- // ---- reactivity (signals; UI text/style props also accept `() => value` bindings) ----
22
- export { signal, computed, effect, type Signal, type Computed } from "./core/signals"
23
-
24
- // ---- canvas (core 2D drawing that bakes to a texture; shared by 2D/3D/UI) ----
25
- export { Canvas, Bitmap } from "./canvas/Canvas"
26
-
27
- // ---- platform runtime (injected globals; the host provides the lower-level _creator* bridges) ----
28
- export { toast, openURL, SvgSource } from "./runtime/misc"
29
- export { app, type AppState, type OrientationLock } from "./runtime/app"
30
- export { clipboard } from "./runtime/clipboard"
31
- export { date, type DateValue, type DateInput, type Unit, type Locale } from "./runtime/datetime"
32
- export { fetch, fetchLocal, FormData, File, type FetchResponse } from "./runtime/fetch"
33
- export { localStorage } from "./runtime/storage"
34
- export { device, type HapticStyle, type MotionOptions } from "./runtime/device"
35
- export { Input, InputChannel, type InputKeyEvent, type InputGamepadEvent, type InputEventName, type GamepadState, type GamepadAxisName } from "./runtime/input"
36
- export { WebSocket } from "./runtime/net"
37
- // App-backend transport: the compiler-generated stubs of `*.server.ts` modules call these; user code
38
- // only ever imports its server functions (docs/backend-plan.md §4).
39
- export { __rpc, __channel, __serverOnly, RpcError, type ClientChannel } from "./runtime/rpc"
40
- export { AudioPlayer, VideoPlayer } from "./runtime/media"
41
- export { openFilePicker } from "./runtime/files"
42
- export { share } from "./runtime/share"
43
- export { ClickEvent, TouchStartEvent, LongPressEvent } from "./runtime/touch"
44
-
45
- // ---- 2D engine (creator-2d) ----
46
- export { Scene2D } from "./g2/Scene2D"
47
- export { Node2D } from "./g2/Node2D"
48
- export { Camera2D } from "./g2/Camera2D"
49
- export { Sprite } from "./g2/Sprite"
50
- export { SpriteAnimation } from "./g2/SpriteAnimation"
51
- export { Shape2D } from "./g2/Shape2D"
52
- export { Physics2D } from "./g2/Physics2D"
53
- export { Trigger2D } from "./g2/Trigger2D"
54
- export { CharacterController2D } from "./g2/CharacterController2D"
55
- export { Tilemap } from "./g2/Tilemap"
56
- export { Texture2D } from "./g2/Texture2D"
57
- // sprite sheets as data (.sprite.ts files — see src/g2/SpriteSheet.ts)
58
- export { SpriteSheet, defineSpriteSheet } from "./g2/SpriteSheet"
59
- export type { SpriteSheetDef, SheetSprite, SpriteMakeOptions } from "./g2/SpriteSheet"
60
- // tilesets as data (.tiles.ts files — autotile materials, see src/g2/Tileset.ts + autotile.ts)
61
- export { Tileset, defineTileset, Autotile2D } from "./g2/Tileset"
62
- export { rawCell, isRawCell, rawIndex } from "./g2/autotile"
63
- export { rot90, rot180, rot270, flipX, packTile, tileIndex, tileTurns, tileFlip, tileOriented } from "./g2/autotile"
64
- export type {
65
- TilesetDef, TileMaterial, PatchMaterial, PathMaterial, PatchSlots, EdgeSlot, FillBlock, BlockEntry,
66
- TileBlock, TilePart,
67
- } from "./g2/autotile"
68
- // 2D scenes as data (.scene2d.ts files — see src/g2/defineScene2d.ts) + the cells('…') payload
69
- export { defineScene2d, Scene2dHandle } from "./g2/defineScene2d"
70
- export type { Scene2dDef, Scene2dNodeDef, Scene2dEnv, SpriteSourceDef, TilemapSourceDef, Camera2dNodeDef, LoadedScene2d } from "./g2/defineScene2d"
71
- export { cells, encodeCells, type CellsData } from "./g2/cells"
72
- // no-code 2D scenario aspects (attachable in scene files — see src/g2/scenarios2d.ts)
73
- export { CameraFollow } from "./g2/scenarios2d"
74
-
75
- // ---- UI (creator-ui) ----
76
- export {
77
- UIScreen, type UIScreenStyle,
78
- UIRow, UIColumn, UIBox, type UIContainerStyle,
79
- UIText, type UITextStyle,
80
- UIButton, type UIButtonStyle,
81
- UIImage, type UIImageStyle,
82
- UIVideo, type UIVideoStyle,
83
- UIInput, UITextArea, type UIInputStyle,
84
- UIScrollable, type UIScrollableStyle,
85
- UIPager, type UIPagerStyle,
86
- UITabs, type UITabDef,
87
- defineTabs, type TabDef, type TabsHandle,
88
- UIWidget, type UIWidgetStyle,
89
- UIModal, type UIModalStyle,
90
- UIBottomSheet, type UIBottomSheetStyle,
91
- UIPopover, type UIPopoverStyle,
92
- UISpacer, type UISpacerStyle,
93
- UIVirtualizedList,
94
- Router,
95
- NativeView, type UINativeViewStyle,
96
- registerFont,
97
- __uiMap,
98
- __UIColumn, __UIRow, __UIBox, __UIButton, __UIScreen, __UIScrollable, __UIWidget,
99
- } from "./ui/UI"
100
- // The Presentable navigation contract (docs/navigation-presentable-plan.md). `Presentable` is
101
- // interface + runtime companion (declaration merging): `Presentable.current` = what's on screen.
102
- export { Presentable } from "./ui/UI"
103
- export type { PresentOptions, Transition, TransitionName, TransitionSpec, TransitionTransform } from "./ui/UI"
104
- // The base node type + the union a container accepts as children — documented as the signature of
105
- // UIColumn/UIRow/append/etc., so they must be global (type-only; erased at runtime).
106
- export type { UINode, UINodeChild } from "./ui/UINode"
107
- // App theme variables (docs/ui-theme-plan.md): theme({...}) merges + returns typed var()
108
- // accessors; system vars are static props (theme.primaryColor, theme["comfort-top"], …).
109
- export { theme, type ThemeValues, type ThemeAccessors } from "./ui/theme"
110
-
111
- // ---- animate ----
112
- export { animate, animateMat4, stopAnimation, pauseAnimation, resumeAnimation } from "./animate/animate"
113
- export { cubicBezier } from "./animate/bezier"
114
- export { easeIn, easeOut, easeInOut } from "./animate/easings"
115
-
116
- // ---- plugins (optional, host-provided capabilities — typed NativeView/service wrappers, see src/plugins/) ----
117
- export { QRScanner } from "./plugins/qr"
118
- export { CameraView, type CameraFacing } from "./plugins/camera"
119
- export { Geolocation, type GeoPosition, type GeoOptions, type GeoWatch } from "./plugins/geolocation"
120
- export { Push, type PushPayload, type PushStatus, type PushRegisterOptions, type PushEvent } from "./plugins/push"
121
- export { OAuth, type OAuthCredential, type OAuthProviderName } from "./plugins/oauth"
122
- export { Service } from "./plugins/service"
123
-
124
- // ---- scenes as data (.scene.ts files — see src/scene/defineScene.ts) ----
125
- export { defineScene, use, ref, make, SceneHandle, applyEditorPose as __applyEditorPose } from "./scene/defineScene"
126
- export type { SceneDef, SceneNodeDef, MeshDef, LightDef, MaterialDef, CameraNodeDef, AspectEntry, MakeEntry, LoadedScene, SceneInstance } from "./scene/defineScene"
127
- export { CameraPlace } from "./gl/CameraPlace"
128
- export type { FieldMeta } from "./core/fields"
129
- // Editor-only line drawing from generator rebuild() / make() factories / tool hooks — drawn by the
130
- // scene editor's viewport overlay, a no-op everywhere else (see src/scene/gizmos.ts).
131
- export { Gizmos, GizmoBuffer as __GizmoBuffer, withGizmoScope as __withGizmoScope } from "./scene/gizmos"
132
- export type { GizmoStyle } from "./scene/gizmos"
133
-
134
- // ---- no-code scenario aspects (attachable in the scene editor — see src/gl/scenarios.ts) ----
135
- export { MoveTo, FollowPath, Spin, LookAt, PlayAnimation } from "./gl/scenarios"
136
-
137
- // ---- editor plugins (called from `*.editor.ts` files — editor bundles only; DCE'd from apps) ----
138
- export { registerEditorWindow, registerEditorTool, __editorPlugins } from "./scene/editorPlugins"
139
- export type { EditorApi, EditorRayHit, EditorToolHooks, EditorWindowFn } from "./scene/editorPlugins"
140
-
141
- // ---- 3D engine (creator-gl) ----
142
- export { Scene, ARScene, VRScene } from "./gl/Scene"
143
- export { Node } from "./gl/Node"
144
- export { Mesh } from "./gl/Mesh"
145
- export { Model } from "./gl/Model"
146
- export { Shape } from "./gl/Shape"
147
- export { Physics } from "./gl/Physics"
148
- export { Trigger } from "./gl/Trigger"
149
- export { CharacterController } from "./gl/CharacterController"
150
- export { Vehicle } from "./gl/Vehicle"
151
- export type { WheelConfig, WheelState, DriveLayout, SuspensionConfig, EngineConfig } from "./gl/Vehicle"
152
- export { AnimationClip } from "./gl/animation/AnimationClip"
153
- export type { ClipDef, ClipTrackDef, ClipKey } from "./gl/animation/AnimationClip"
154
- export { Animator } from "./gl/animation/Animator"
155
- export { Playback } from "./gl/animation/Playback"
156
- export { Loop } from "./gl/animation/Loop"
157
- export { Layer } from "./gl/animation/Layer"
158
- export type { PlayOptions, StopOptions, LayerOptions, LoopOptions, LoopDef, BlendPosition } from "./gl/animation/core"
159
- export { IK } from "./gl/IK"
160
- export type { IKTwoBone, IKLookAt } from "./gl/IK"
161
- export { Light } from "./gl/Light"
162
- export { Material } from "./gl/Material"
163
- export { Geometry } from "./gl/Geometry"
164
- export { InstancedMesh } from "./gl/InstancedMesh"
165
- export type { InstanceTransform } from "./gl/InstancedMesh"
166
- export { Texture } from "./gl/Texture"
167
- export { Camera } from "./gl/Camera"
168
- export { Ray } from "./gl/Ray"
169
- export { Plane } from "./gl/Plane"
170
- export { Noise } from "./gl/Noise"
171
- export { Particles, Trail, curve, colorCurve } from "./gl/Particles"
1
+ // THE aggregation point. Every public global the SDK provides is re-exported here under the exact
2
+ // name user code uses it as. The bundler passes this file to esbuild's `inject:` option, so user
3
+ // code references `Scene`, `Sprite`, `toast`, … with no imports; esbuild tree-shakes away whatever
4
+ // a given project does not use (so a pure-2D project drops all 3D classes, and vice versa).
5
+ //
6
+ // Rule: this is the ONLY file that `export`s public names. Everything else is internal and imported
7
+ // by it. Host-provided globals (setLoop, console, setTimeout, DEG2RAD, asset, …) are NOT here —
8
+ // they live in src/host.d.ts as declarations and stay as free references at runtime.
9
+
10
+ // ---- math ----
11
+ export { Mathf } from "./math/Mathf"
12
+ export { Vec2, Vec3 } from "./math/vec"
13
+ export { Quat } from "./math/quat"
14
+ export { Mat4 } from "./math/mat4"
15
+ export { Color } from "./core/color"
16
+
17
+ // ---- aspects (attachable node capabilities) ----
18
+ export { Aspect, System, type With, type SystemHost } from "./core/Aspect"
19
+ export { type EventMap } from "./core/events"
20
+ export { Time } from "./core/time"
21
+ export { InspectorUI } from "./core/InspectorUI"
22
+
23
+ // ---- reactivity (signals; UI text/style props also accept `() => value` bindings) ----
24
+ export { signal, computed, effect, type Signal, type Computed } from "./core/signals"
25
+ export { __compWrite, __compOp, type CompAxis, type CompWriter } from "./core/compWrite"
26
+
27
+ // ---- canvas (core 2D drawing that bakes to a texture; shared by 2D/3D/UI) ----
28
+ export { Canvas, Bitmap } from "./canvas/Canvas"
29
+
30
+ // ---- platform runtime (injected globals; the host provides the lower-level _creator* bridges) ----
31
+ export { toast, openURL, SvgSource } from "./runtime/misc"
32
+ export { app, type AppState, type OrientationLock } from "./runtime/app"
33
+ export { clipboard } from "./runtime/clipboard"
34
+ export { date, type DateValue, type DateInput, type Unit, type Locale } from "./runtime/datetime"
35
+ export { fetch, fetchLocal, FormData, File, type FetchResponse } from "./runtime/fetch"
36
+ export { localStorage } from "./runtime/storage"
37
+ export { device, type HapticStyle, type MotionOptions } from "./runtime/device"
38
+ export { Input, InputChannel, type InputKeyEvent, type InputGamepadEvent, type InputEventName, type GamepadState, type GamepadAxisName } from "./runtime/input"
39
+ export { WebSocket } from "./runtime/net"
40
+ // App-backend transport: the compiler-generated stubs of `*.server.ts` modules call these; user code
41
+ // only ever imports its server functions (docs/backend-plan.md §4).
42
+ export { __rpc, __channel, __serverOnly, RpcError, type ClientChannel } from "./runtime/rpc"
43
+ export { AudioPlayer, VideoPlayer } from "./runtime/media"
44
+ export { openFilePicker } from "./runtime/files"
45
+ export { share } from "./runtime/share"
46
+ export { ClickEvent, TouchStartEvent, LongPressEvent } from "./runtime/touch"
47
+
48
+ // ---- 2D engine (creator-2d) ----
49
+ export { Scene2D } from "./g2/Scene2D"
50
+ export { Node2D } from "./g2/Node2D"
51
+ export { Camera2D } from "./g2/Camera2D"
52
+ export { Sprite } from "./g2/Sprite"
53
+ export { SpriteAnimation } from "./g2/SpriteAnimation"
54
+ export { Shape2D } from "./g2/Shape2D"
55
+ export { Physics2D } from "./g2/Physics2D"
56
+ export { Trigger2D } from "./g2/Trigger2D"
57
+ export { CharacterController2D } from "./g2/CharacterController2D"
58
+ export { OneWay2D } from "./g2/OneWay2D"
59
+ export { PhysicsGroup2D } from "./g2/groups2d"
60
+ export { Tilemap } from "./g2/Tilemap"
61
+ export { Texture2D } from "./g2/Texture2D"
62
+ // sprite sheets as data (.sprite.ts files — see src/g2/SpriteSheet.ts)
63
+ export { SpriteSheet, defineSpriteSheet } from "./g2/SpriteSheet"
64
+ export type { SpriteSheetDef, SheetSprite, SpriteMakeOptions } from "./g2/SpriteSheet"
65
+ // tilesets as data (.tiles.ts files — autotile materials, see src/g2/Tileset.ts + autotile.ts)
66
+ export { Tileset, defineTileset, Autotile2D } from "./g2/Tileset"
67
+ export { rawCell, isRawCell, rawIndex } from "./g2/autotile"
68
+ export { rot90, rot180, rot270, flipX, packTile, tileIndex, tileTurns, tileFlip, tileOriented } from "./g2/autotile"
69
+ export type {
70
+ TilesetDef, TileMaterial, PatchMaterial, PathMaterial, PatchSlots, EdgeSlot, FillBlock, BlockEntry,
71
+ TileBlock, TilePart,
72
+ } from "./g2/autotile"
73
+ // 2D scenes as data (.scene2d.ts files — see src/g2/defineScene2d.ts) + the cells('…') payload
74
+ export { defineScene2d, Scene2dHandle } from "./g2/defineScene2d"
75
+ export type { Scene2dDef, Scene2dNodeDef, Scene2dEnv, SpriteSourceDef, TilemapSourceDef, Camera2dNodeDef, LoadedScene2d } from "./g2/defineScene2d"
76
+ export { cells, encodeCells, type CellsData } from "./g2/cells"
77
+ // no-code 2D scenario aspects (attachable in scene files — see src/g2/scenarios2d.ts)
78
+ export { CameraFollow } from "./g2/scenarios2d"
79
+
80
+ // ---- UI (creator-ui) ----
81
+ export {
82
+ UIScreen, type UIScreenStyle,
83
+ UIRow, UIColumn, UIBox, type UIContainerStyle,
84
+ UIText, type UITextStyle,
85
+ UIButton, type UIButtonStyle,
86
+ UIImage, type UIImageStyle,
87
+ UIVideo, type UIVideoStyle,
88
+ UIInput, UITextArea, type UIInputStyle,
89
+ UIScrollable, type UIScrollableStyle,
90
+ UIPager, type UIPagerStyle,
91
+ UITabs, type UITabDef,
92
+ defineTabs, type TabDef, type TabsHandle,
93
+ UIWidget, type UIWidgetStyle,
94
+ UIModal, type UIModalStyle,
95
+ UIBottomSheet, type UIBottomSheetStyle,
96
+ UIPopover, type UIPopoverStyle,
97
+ UISpacer, type UISpacerStyle,
98
+ UIVirtualizedList,
99
+ Router,
100
+ NativeView, type UINativeViewStyle,
101
+ registerFont,
102
+ __uiMap,
103
+ __UIColumn, __UIRow, __UIBox, __UIButton, __UIScreen, __UIScrollable, __UIWidget,
104
+ } from "./ui/UI"
105
+ // The Presentable navigation contract (docs/navigation-presentable-plan.md). `Presentable` is
106
+ // interface + runtime companion (declaration merging): `Presentable.current` = what's on screen.
107
+ export { Presentable } from "./ui/UI"
108
+ export type { PresentOptions, Transition, TransitionName, TransitionSpec, TransitionTransform } from "./ui/UI"
109
+ // The base node type + the union a container accepts as children — documented as the signature of
110
+ // UIColumn/UIRow/append/etc., so they must be global (type-only; erased at runtime).
111
+ export type { UINode, UINodeChild } from "./ui/UINode"
112
+ // App theme variables (docs/ui-theme-plan.md): theme({...}) merges + returns typed var()
113
+ // accessors; system vars are static props (theme.primaryColor, theme["comfort-top"], …).
114
+ export { theme, type ThemeValues, type ThemeAccessors } from "./ui/theme"
115
+
116
+ // ---- animate ----
117
+ export { animate, animateMat4, stopAnimation, pauseAnimation, resumeAnimation } from "./animate/animate"
118
+ export { cubicBezier } from "./animate/bezier"
119
+ export { easeIn, easeOut, easeInOut } from "./animate/easings"
120
+
121
+ // ---- plugins (optional, host-provided capabilities — typed NativeView/service wrappers, see src/plugins/) ----
122
+ export { QRScanner } from "./plugins/qr"
123
+ export { CameraView, type CameraFacing } from "./plugins/camera"
124
+ export { Geolocation, type GeoPosition, type GeoOptions, type GeoWatch } from "./plugins/geolocation"
125
+ export { Push, type PushPayload, type PushStatus, type PushRegisterOptions, type PushEvent } from "./plugins/push"
126
+ export { OAuth, type OAuthCredential, type OAuthProviderName } from "./plugins/oauth"
127
+ export { Service } from "./plugins/service"
128
+
129
+ // ---- scenes as data (.scene.ts files — see src/scene/defineScene.ts) ----
130
+ export { defineScene, use, ref, make, SceneHandle, applyEditorPose as __applyEditorPose } from "./scene/defineScene"
131
+ export {
132
+ defineMaterial, MaterialHandle,
133
+ // editor-harness helpers (the scene editor's live material paths — not app API)
134
+ assignMaterialDef as __assignMaterialDef, applyMaterialParam as __applyMaterialParam,
135
+ } from "./scene/material"
136
+ export type { MaterialData, MaterialParamValue, ShaderMaterialDef, LitMaterialDef, UnlitMaterialDef } from "./scene/material"
137
+ export type { SceneDef, SceneNodeDef, MeshDef, LightDef, MaterialDef, CameraNodeDef, AspectEntry, MakeEntry, LoadedScene, SceneInstance } from "./scene/defineScene"
138
+ export { CameraPlace } from "./gl/CameraPlace"
139
+ export type { FieldMeta } from "./core/fields"
140
+ // Editor-only line drawing from generator rebuild() / make() factories / tool hooks — drawn by the
141
+ // scene editor's viewport overlay, a no-op everywhere else (see src/scene/gizmos.ts).
142
+ export { Gizmos, GizmoBuffer as __GizmoBuffer, withGizmoScope as __withGizmoScope } from "./scene/gizmos"
143
+ export type { GizmoStyle, GizmoAnchor } from "./scene/gizmos"
144
+
145
+ // ---- no-code scenario aspects (attachable in the scene editor — see src/gl/scenarios.ts) ----
146
+ export { MoveTo, FollowPath, Spin, LookAt, PlayAnimation } from "./gl/scenarios"
147
+
148
+ // ---- editor plugins (called from `*.editor.ts` files — editor bundles only; DCE'd from apps) ----
149
+ export { registerEditorWindow, registerEditorTool, __editorPlugins } from "./scene/editorPlugins"
150
+ export type { EditorApi, EditorRayHit, EditorToolHooks, EditorWindowFn } from "./scene/editorPlugins"
151
+
152
+ // ---- 3D engine (creator-gl) ----
153
+ export { Scene, ARScene, VRScene } from "./gl/Scene"
154
+ export { Node } from "./gl/Node"
155
+ export { Mesh } from "./gl/Mesh"
156
+ export { Model } from "./gl/Model"
157
+ export { Shape } from "./gl/Shape"
158
+ export { Physics } from "./gl/Physics"
159
+ export { Trigger } from "./gl/Trigger"
160
+ export { CharacterController } from "./gl/CharacterController"
161
+ export { Vehicle } from "./gl/Vehicle"
162
+ export type { DriveLayout, DifferentialMode, EngineConfig, SteeringConfig, AeroConfig } from "./gl/Vehicle"
163
+ export { Wheel } from "./gl/Wheel"
164
+ export type { TireCurve, WheelSuspension, WheelTire, WheelVisual } from "./gl/Wheel"
165
+ export { Gearbox } from "./gl/Gearbox"
166
+ export { AnimationClip } from "./gl/animation/AnimationClip"
167
+ export type { ClipDef, ClipTrackDef, ClipKey } from "./gl/animation/AnimationClip"
168
+ export { Animator } from "./gl/animation/Animator"
169
+ export { Playback } from "./gl/animation/Playback"
170
+ export { Loop } from "./gl/animation/Loop"
171
+ export { Layer } from "./gl/animation/Layer"
172
+ export type { PlayOptions, StopOptions, LayerOptions, LoopOptions, LoopDef, BlendPosition } from "./gl/animation/core"
173
+ export { IK } from "./gl/IK"
174
+ export type { IKTwoBone, IKLookAt } from "./gl/IK"
175
+ export { Light } from "./gl/Light"
176
+ export { Lightmap } from "./gl/Lightmap"
177
+ export { Material } from "./gl/Material"
178
+ export { Geometry } from "./gl/Geometry"
179
+ export { InstancedMesh } from "./gl/InstancedMesh"
180
+ export type { InstanceTransform } from "./gl/InstancedMesh"
181
+ export { Texture } from "./gl/Texture"
182
+ export { Camera } from "./gl/Camera"
183
+ export { Ray } from "./gl/Ray"
184
+ export { Plane } from "./gl/Plane"
185
+ export { Noise } from "./gl/Noise"
186
+ export { Particles, Trail, curve, colorCurve } from "./gl/Particles"
@@ -7,12 +7,17 @@ import { appEventsOn, appEventsOff } from "./appEvents"
7
7
 
8
8
  type ResizeCallback = (width: number, height: number) => void
9
9
 
10
+ type HdrChangeCallback = (headroom: number) => void
11
+
10
12
  type DeviceEventMap = {
11
13
  resize: ResizeCallback
12
14
  /** Connectivity came back (best-effort, navigator.onLine semantics). */
13
15
  online: () => void
14
16
  /** Connectivity was lost. */
15
17
  offline: () => void
18
+ /** The headroom the 3D engine renders to moved (`device.hdr.headroom`): the display ramped up to
19
+ * its peak after launch, brightness changed, the window went to another screen. */
20
+ hdrchange: HdrChangeCallback
16
21
  }
17
22
 
18
23
  const resizeListeners: ResizeCallback[] = []
@@ -22,6 +27,25 @@ const onResize = (width: number, height: number): void => {
22
27
  for (const cb of resizeListeners.slice()) cb(width, height)
23
28
  }
24
29
 
30
+ // --- device.hdr state ---
31
+ // The 3D bridge is a free global that a 2D-only bundle never defines — reach it defensively. Hosts
32
+ // without the methods are SDR by definition; the look setters are remembered so the getters read
33
+ // back what the app asked for.
34
+ const gl = (): typeof _creator | undefined => (typeof _creator !== "undefined" ? _creator : undefined)
35
+ let hdrStrengthLocal = 0.35
36
+ let hdrPaperWhiteLocal = 1
37
+ // `hdrchange` is a poll: the engine quantises the headroom to half-stops, so a change is rare and
38
+ // a 4 Hz timer (only while someone listens) is cheaper than a per-frame bridge call.
39
+ const hdrListeners: HdrChangeCallback[] = []
40
+ let hdrPollTimer: ReturnType<typeof setInterval> | undefined
41
+ let hdrLastHeadroom = 1
42
+ const pollHdr = (): void => {
43
+ const h = device.hdr.headroom
44
+ if (h === hdrLastHeadroom) return
45
+ hdrLastHeadroom = h
46
+ for (const cb of hdrListeners.slice()) cb(h)
47
+ }
48
+
25
49
  /** Semantic haptic styles for `device.vibrate`. Impact styles (`light`/`medium`/`heavy`/`soft`/
26
50
  * `rigid`) are a physical "tap" of varying weight; notification styles (`success`/`warning`/`error`)
27
51
  * cue an outcome; `selection` is a light tick for a value change. Chosen to map 1:1 onto iOS
@@ -66,7 +90,10 @@ const orientedAttitude = (s: ArrayLike<number>): Quat => {
66
90
  }
67
91
 
68
92
  export const device = {
69
- get platform(): "web" | "android" | "ios" | string {
93
+ /** Which INPUT MODEL the app is running under — the thing to branch on when a build needs
94
+ * mouse-look instead of on-screen sticks. It is not the OS name: a Mac reports `"desktop"`,
95
+ * like Windows and Linux do (the OS/version detail is host-side, not here). */
96
+ get platform(): "web" | "android" | "ios" | "desktop" | string {
70
97
  return _creatorUtils.platform
71
98
  },
72
99
  get language(): string {
@@ -162,6 +189,63 @@ export const device = {
162
189
  return new Vec3(g.x, -g.y, g.z)
163
190
  },
164
191
  },
192
+ /** The display's extended dynamic range — HDR. On a screen with headroom above SDR white (Apple's
193
+ * XDR panels; the macOS host today) the 3D surface is float and the engine renders past 1.0:
194
+ * 1.0 is the white of the UI and of a diffuse white surface, and the sun, emissives and speculars
195
+ * climb up to `headroom` times that. Everywhere else it is SDR: `available` false, `headroom` 1,
196
+ * the look setters remembered but invisible.
197
+ *
198
+ * Branch content on `available`, not on `headroom` — the live value ramps up from 1 over the
199
+ * first seconds after launch and follows the brightness keys. Particle `emissive` is the thing
200
+ * to raise: it is in post-exposure units (1 = white on screen) and everything above that clips on
201
+ * SDR, so an HDR display is the only place a fireball peaking at 8 reads as one. */
202
+ hdr: {
203
+ /** Whether the surface can show anything above SDR white at all (`maxHeadroom > 1`). */
204
+ get available(): boolean {
205
+ return device.hdr.maxHeadroom > 1
206
+ },
207
+ /** The peak the display can reach, as a multiple of SDR white (a 1600-nit XDR panel reports up
208
+ * to 16). Constant for the surface; 1 on SDR. */
209
+ get maxHeadroom(): number {
210
+ const v = gl()?.getDisplayMaxHeadroom?.() ?? 1
211
+ return v > 1 ? v : 1
212
+ },
213
+ /** The headroom the engine renders to right now — the screen's current peak as a multiple of SDR
214
+ * white, quantised to half-stops. Moves with brightness and the screen under the window
215
+ * (`hdrchange` event); never below 1. */
216
+ get headroom(): number {
217
+ const v = gl()?.getDisplayHeadroom?.() ?? 1
218
+ return v > 1 ? v : 1
219
+ },
220
+ /** How much of the picture reaches for the headroom, 0..1 (default 0.35). 0 touches only what
221
+ * SDR clipped — faithful to the SDR grade, but a mostly-mid-tone frame then looks flat next to
222
+ * the one bright spot; 1 lifts nearly everything above black toward the peak. A sunlit exterior
223
+ * takes 1, a dim interior wants less. A host may pin it (`LECODES_HDR_STRENGTH`). */
224
+ get strength(): number {
225
+ return gl()?.getHdrStrength?.() ?? hdrStrengthLocal
226
+ },
227
+ set strength(v: number) {
228
+ const s = Number.isFinite(v) ? Math.min(1, Math.max(0, v)) : 0.35
229
+ hdrStrengthLocal = s
230
+ gl()?.setHdrStrength?.(s)
231
+ },
232
+ /** Where white lands, as a multiple of SDR white, 1..8 (default 1) — the "HDR brightness" of a
233
+ * console game's calibration screen, where paper white sits at ~200 nits against SDR's ~100.
234
+ * It scales the WHOLE picture: at 1 a white wall is as bright as the UI's white, at 2 it is
235
+ * twice that, and highlights still climb above it (the engine keeps `headroom / paperWhite` for
236
+ * them, clamped at the peak). `strength` decides how much of the picture reaches for the
237
+ * peak; this decides where the picture starts. 1.5–2 is the console norm; a game that wants to
238
+ * read as "HDR on" rather than "SDR with a brighter sun" wants this over `strength`. A host may
239
+ * pin it (`LECODES_HDR_PAPER_WHITE`). */
240
+ get paperWhite(): number {
241
+ return gl()?.getHdrPaperWhite?.() ?? hdrPaperWhiteLocal
242
+ },
243
+ set paperWhite(v: number) {
244
+ const p = Number.isFinite(v) ? Math.min(8, Math.max(1, v)) : 1
245
+ hdrPaperWhiteLocal = p
246
+ gl()?.setHdrPaperWhite?.(p)
247
+ },
248
+ },
165
249
  /** Current connectivity — best-effort navigator.onLine semantics: `false` only when the platform
166
250
  * is sure there's no network. `true` on hosts that don't track it. Change events: `"online"` /
167
251
  * `"offline"`. */
@@ -173,6 +257,14 @@ export const device = {
173
257
  appEventsOn(channel, callback as () => void)
174
258
  return
175
259
  }
260
+ if (channel === "hdrchange") {
261
+ hdrListeners.push(callback as HdrChangeCallback)
262
+ if (hdrPollTimer === undefined) {
263
+ hdrLastHeadroom = device.hdr.headroom
264
+ hdrPollTimer = setInterval(pollHdr, 250)
265
+ }
266
+ return
267
+ }
176
268
  if (channel !== "resize") return
177
269
  resizeListeners.push(callback as ResizeCallback)
178
270
  if (!resizeRegistered) {
@@ -185,6 +277,15 @@ export const device = {
185
277
  appEventsOff(channel, callback as () => void)
186
278
  return
187
279
  }
280
+ if (channel === "hdrchange") {
281
+ const i = hdrListeners.indexOf(callback as HdrChangeCallback)
282
+ if (i >= 0) hdrListeners.splice(i, 1)
283
+ if (hdrListeners.length === 0 && hdrPollTimer !== undefined) {
284
+ clearInterval(hdrPollTimer)
285
+ hdrPollTimer = undefined
286
+ }
287
+ return
288
+ }
188
289
  if (channel !== "resize") return
189
290
  const i = resizeListeners.indexOf(callback as ResizeCallback)
190
291
  if (i >= 0) resizeListeners.splice(i, 1)