lecodes-sdk 1.2.0 → 2.0.1
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/README.md +5 -2
- package/dist/editor.d.ts +12 -0
- package/dist/global.d.ts +4 -8
- package/dist/host.d.ts +2 -3
- package/dist/types/animate/tween/Animation.d.ts +0 -3
- package/dist/types/animate/tween/animateValue.d.ts +4 -2
- package/dist/types/animate/tween/easing.d.ts +8 -0
- package/dist/types/animate/tween/spec.d.ts +15 -7
- package/dist/types/audio/audio.d.ts +2 -1
- package/dist/types/canvas/Canvas.d.ts +40 -108
- package/dist/types/canvas/gen/cssColor.d.ts +17 -0
- package/dist/types/canvas/gen/recorder.d.ts +118 -0
- package/dist/types/canvas/gen/spec.d.ts +144 -0
- package/dist/types/core/color.d.ts +3 -1
- package/dist/types/core/pins.d.ts +18 -0
- package/dist/types/g2/Node2D.d.ts +5 -8
- package/dist/types/g2/Scene2D.d.ts +6 -2
- package/dist/types/gl/Foliage.d.ts +30 -7
- package/dist/types/gl/Light.d.ts +8 -0
- package/dist/types/gl/Lightmap.d.ts +13 -2
- package/dist/types/gl/Material.d.ts +17 -3
- package/dist/types/gl/Model.d.ts +6 -2
- package/dist/types/gl/Node.d.ts +3 -6
- package/dist/types/gl/Scene.d.ts +41 -13
- package/dist/types/gl/Texture.d.ts +1 -1
- package/dist/types/gl/animation/Locomotion.d.ts +8 -1
- package/dist/types/inject.d.ts +11 -11
- package/dist/types/inject.editor.d.ts +1 -0
- package/dist/types/net/core.d.ts +7 -0
- package/dist/types/plugin.d.ts +76 -0
- package/dist/types/plugins/gen/camera/sdk/camera.d.ts +24 -0
- package/dist/types/plugins/gen/camera/sdk/camera.gen.d.ts +25 -0
- package/dist/types/plugins/{geolocation.d.ts → gen/geolocation/sdk/geolocation.d.ts} +2 -20
- package/dist/types/plugins/gen/geolocation/sdk/geolocation.gen.d.ts +31 -0
- package/dist/types/plugins/{map.d.ts → gen/map/sdk/map.d.ts} +9 -50
- package/dist/types/plugins/gen/map/sdk/map.gen.d.ts +53 -0
- package/dist/types/plugins/gen/push/sdk/push.d.ts +23 -0
- package/dist/types/plugins/gen/push/sdk/push.gen.d.ts +35 -0
- package/dist/types/plugins/{qr.d.ts → gen/qr-scanner/sdk/qr-scanner.d.ts} +2 -3
- package/dist/types/plugins/gen/qr-scanner/sdk/qr-scanner.gen.d.ts +15 -0
- package/dist/types/runtime/app.d.ts +9 -2
- package/dist/types/runtime/fetch.d.ts +2 -0
- package/dist/types/runtime/input.d.ts +1 -1
- package/dist/types/runtime/media.d.ts +6 -10
- package/dist/types/runtime/misc.d.ts +4 -1
- package/dist/types/runtime/net.d.ts +3 -2
- package/dist/types/runtime/touch.d.ts +32 -0
- package/dist/types/scene/defineScene.d.ts +43 -2
- package/dist/types/scene/editor.d.ts +52 -0
- package/dist/types/scene/gizmos.d.ts +7 -4
- package/dist/types/ui/NativeView.d.ts +6 -4
- package/dist/types/ui/UI.d.ts +1 -1
- package/dist/types/ui/UIBottomSheet.d.ts +6 -12
- package/dist/types/ui/UIButton.d.ts +12 -14
- package/dist/types/ui/UIContainer.d.ts +0 -6
- package/dist/types/ui/UIImage.d.ts +1 -4
- package/dist/types/ui/UIInput.d.ts +8 -24
- package/dist/types/ui/UIModal.d.ts +0 -2
- package/dist/types/ui/UINode.d.ts +70 -56
- package/dist/types/ui/UIPager.d.ts +28 -27
- package/dist/types/ui/UIPopover.d.ts +0 -2
- package/dist/types/ui/UIScreen.d.ts +12 -17
- package/dist/types/ui/UIScrollable.d.ts +1 -4
- package/dist/types/ui/UIText.d.ts +0 -2
- package/dist/types/ui/UIVideo.d.ts +3 -5
- package/dist/types/ui/UIVirtualizedList.d.ts +14 -16
- package/dist/types/ui/UIWidget.d.ts +10 -9
- package/dist/types/ui/colorKeys.gen.d.ts +9 -0
- package/dist/types/ui/presentable.d.ts +46 -32
- package/dist/types/ui/router.d.ts +18 -7
- package/dist/types/ui/styleColor.d.ts +1 -0
- package/dist/types/ui/transitions.d.ts +18 -0
- package/dist/types/ui/tree.d.ts +75 -0
- package/dist/types/version.d.ts +10 -0
- package/dist/types.json +1 -1
- package/package.json +12 -3
- package/prompts/2d.md +2 -6
- package/prompts/3d.md +1 -5
- package/prompts/README.md +1 -1
- package/prompts/canvas.md +9 -8
- package/prompts/compose.ts +1 -1
- package/prompts/core.md +3 -3
- package/prompts/design.md +1 -1
- package/prompts/dist/2d-game.md +473 -239
- package/prompts/dist/3d-app.md +553 -205
- package/prompts/dist/ar-app.md +435 -202
- package/prompts/dist/design.md +113 -95
- package/prompts/dist/ui-app.md +386 -170
- package/prompts/ui-design.md +2 -3
- package/prompts/ui.md +45 -37
- package/src/animate/tween/Animation.ts +34 -150
- package/src/animate/tween/Timeline.ts +175 -175
- package/src/animate/tween/animateValue.ts +6 -3
- package/src/animate/tween/easing.ts +10 -3
- package/src/animate/tween/spec.ts +41 -15
- package/src/audio/Sound.ts +3 -3
- package/src/audio/audio.ts +2 -1
- package/src/bridges/2d.d.ts +317 -0
- package/src/bridges/app.d.ts +91 -0
- package/src/bridges/audio.d.ts +97 -0
- package/src/bridges/canvas.d.ts +79 -0
- package/src/bridges/device.d.ts +72 -0
- package/src/bridges/fetch.d.ts +80 -0
- package/src/bridges/files.d.ts +70 -0
- package/src/bridges/gl.d.ts +1133 -0
- package/src/bridges/input.d.ts +72 -0
- package/src/bridges/media.d.ts +55 -0
- package/src/bridges/nav.d.ts +71 -0
- package/src/bridges/net.d.ts +52 -0
- package/src/bridges/service.d.ts +52 -0
- package/src/bridges/socket.d.ts +31 -0
- package/src/bridges/storage.d.ts +33 -0
- package/src/bridges/tree.d.ts +301 -0
- package/src/bridges/types.d.ts +49 -0
- package/src/canvas/Canvas.ts +114 -159
- package/src/canvas/gen/cssColor.ts +224 -0
- package/src/canvas/gen/recorder.ts +212 -0
- package/src/canvas/gen/spec.ts +201 -0
- package/src/chisel.ts +193 -0
- package/src/compile/assetMacro.ts +1 -1
- package/src/compile/bundler.ts +11 -2
- package/src/compile/compileProject.ts +43 -4
- package/src/compile/fontMacro.ts +3 -4
- package/src/compile/header.ts +26 -5
- package/src/compile/index.ts +3 -1
- package/src/compile/liteMaterial.ts +1 -1
- package/src/compile/sceneEditor.ts +11 -26
- package/src/core/color.ts +73 -30
- package/src/core/pins.ts +51 -0
- package/src/core/signals.ts +8 -1
- package/src/g2/CharacterController2D.ts +3 -3
- package/src/g2/Node2D.ts +57 -39
- package/src/g2/Physics2D.ts +2 -2
- package/src/g2/Scene2D.ts +35 -23
- package/src/g2/Texture2D.ts +1 -1
- package/src/g2/loop.ts +4 -4
- package/src/gl/CameraPlace.ts +52 -52
- package/src/gl/Foliage.ts +72 -17
- package/src/gl/Geometry.ts +1 -2
- package/src/gl/Light.ts +10 -0
- package/src/gl/Lightmap.ts +45 -29
- package/src/gl/Material.ts +95 -51
- package/src/gl/Mesh.ts +120 -120
- package/src/gl/Model.ts +21 -16
- package/src/gl/Node.ts +91 -24
- package/src/gl/Particles.ts +1 -1
- package/src/gl/Scene.ts +100 -44
- package/src/gl/Texture.ts +8 -7
- package/src/gl/animation/AnimationClip.ts +1 -1
- package/src/gl/animation/DynamicBone.ts +482 -482
- package/src/gl/animation/Locomotion.ts +8 -3
- package/src/gl/nav/NavMesh.ts +3 -4
- package/src/gl/physics/Physics.ts +2 -2
- package/src/gl/physics/physicsEvents.ts +3 -3
- package/src/gl/scenarios.ts +291 -291
- package/src/gl/terrain/Terrain.ts +4 -5
- package/src/gl/touch.ts +14 -15
- package/src/host.d.ts +2 -3
- package/src/inject.editor.ts +7 -0
- package/src/inject.ts +13 -16
- package/src/net/core.ts +6 -5
- package/src/net/index.ts +1 -1
- package/src/net/replication.ts +1 -1
- package/src/plugin.ts +191 -0
- package/src/plugins/gen/camera/contract.d.ts +27 -0
- package/src/plugins/gen/camera/sdk/camera.gen.ts +46 -0
- package/src/plugins/gen/camera/sdk/camera.ts +57 -0
- package/src/plugins/gen/geolocation/contract.d.ts +50 -0
- package/src/plugins/gen/geolocation/sdk/geolocation.gen.ts +54 -0
- package/src/plugins/{geolocation.ts → gen/geolocation/sdk/geolocation.ts} +22 -43
- package/src/plugins/gen/map/contract.d.ts +144 -0
- package/src/plugins/gen/map/sdk/map.gen.ts +88 -0
- package/src/plugins/{map.ts → gen/map/sdk/map.ts} +68 -102
- package/src/plugins/gen/push/contract.d.ts +61 -0
- package/src/plugins/gen/push/sdk/push.gen.ts +60 -0
- package/src/plugins/gen/push/sdk/push.ts +105 -0
- package/src/plugins/gen/qr-scanner/contract.d.ts +16 -0
- package/src/plugins/gen/qr-scanner/sdk/qr-scanner.gen.ts +29 -0
- package/src/plugins/gen/qr-scanner/sdk/qr-scanner.ts +52 -0
- package/src/plugins/permission.ts +5 -4
- package/src/runtime/app.ts +20 -9
- package/src/runtime/appEvents.ts +5 -4
- package/src/runtime/channel.ts +18 -15
- package/src/runtime/clipboard.ts +4 -3
- package/src/runtime/datetime.ts +2 -1
- package/src/runtime/device.ts +17 -15
- package/src/runtime/fetch.ts +30 -20
- package/src/runtime/files.ts +16 -15
- package/src/runtime/input.ts +12 -10
- package/src/runtime/media.ts +50 -46
- package/src/runtime/misc.ts +7 -3
- package/src/runtime/net.ts +8 -7
- package/src/runtime/rpc.ts +1 -3
- package/src/runtime/service.ts +19 -14
- package/src/runtime/share.ts +4 -3
- package/src/runtime/storage.ts +6 -4
- package/src/runtime/touch.ts +32 -0
- package/src/scene/defineScene.ts +61 -365
- package/src/scene/editor.ts +408 -0
- package/src/scene/editorPlugins.ts +3 -3
- package/src/scene/gizmos.ts +15 -9
- package/src/server/db/marci/query.ts +1 -1
- package/src/server/host.ts +1 -1
- package/src/server/runtime.ts +1 -1
- package/src/ui/NativeView.ts +72 -25
- package/src/ui/UI.ts +3 -3
- package/src/ui/UIBottomSheet.ts +16 -17
- package/src/ui/UIButton.ts +54 -16
- package/src/ui/UIContainer.ts +0 -6
- package/src/ui/UIImage.ts +34 -30
- package/src/ui/UIInput.ts +29 -37
- package/src/ui/UIModal.ts +1 -3
- package/src/ui/UINode.ts +347 -297
- package/src/ui/UIPager.ts +93 -78
- package/src/ui/UIPopover.ts +0 -2
- package/src/ui/UIScreen.ts +41 -36
- package/src/ui/UIScrollable.ts +19 -13
- package/src/ui/UISpacer.ts +1 -1
- package/src/ui/UITabs.ts +8 -6
- package/src/ui/UIText.ts +7 -17
- package/src/ui/UIVideo.ts +30 -27
- package/src/ui/UIVirtualizedList.ts +58 -59
- package/src/ui/UIWidget.ts +38 -18
- package/src/ui/colorKeys.gen.ts +37 -0
- package/src/ui/fonts.ts +2 -2
- package/src/ui/presentable.ts +59 -42
- package/src/ui/router.ts +52 -35
- package/src/ui/styleColor.ts +56 -0
- package/src/ui/theme.ts +7 -6
- package/src/ui/transitions.ts +249 -0
- package/src/ui/tree.ts +346 -0
- package/src/version.ts +24 -0
- package/tests/helpers/engineWorld.ts +11 -0
- package/tests/helpers/fakeTree.ts +353 -0
- package/tests/helpers/hostStubs.ts +31 -0
- package/tests/helpers/index.ts +14 -0
- package/tests/helpers/memoryMarci.ts +124 -0
- package/tests/helpers/phases.ts +23 -0
- package/tests/helpers/preload.ts +18 -0
- package/tests/helpers/stubApp.ts +2 -0
- package/tests/helpers/stubDevice.ts +2 -0
- package/tests/helpers/stubFetch.ts +2 -0
- package/tests/helpers/stubInput.ts +2 -0
- package/dist/inject.js +0 -4629
- package/dist/types/core/registry.d.ts +0 -7
- package/dist/types/plugins/camera.d.ts +0 -25
- package/dist/types/plugins/push.d.ts +0 -46
- package/src/bridges.d.ts +0 -1769
- package/src/compile/__tests__/assetIconMacro.test.ts +0 -219
- package/src/compile/__tests__/assetMacro.test.ts +0 -100
- package/src/compile/__tests__/assetName.test.ts +0 -55
- package/src/compile/__tests__/compile.test.ts +0 -310
- package/src/compile/__tests__/detectEntry.test.ts +0 -151
- package/src/compile/__tests__/fontMacro.test.ts +0 -199
- package/src/compile/__tests__/serverSplit.test.ts +0 -27
- package/src/core/__tests__/stateMachine.test.ts +0 -132
- package/src/core/registry.ts +0 -23
- package/src/plugins/camera.ts +0 -81
- package/src/plugins/push.ts +0 -132
- package/src/plugins/qr.ts +0 -73
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// The input bridge (`_creatorInput`): keyboard / mouse / gamepad behind the SDK `Input` global
|
|
2
|
+
// (docs/input-plan.md) and the on-screen keyboard inset behind `app.keyboardHeight`.
|
|
3
|
+
// Part of the host contract. A HOST bridge (`@host`, see ./app.d.ts): the native side is the
|
|
4
|
+
// `HostInput` table of runtime/native/include/creator-pkg/host.gen.h, generated from this file.
|
|
5
|
+
//
|
|
6
|
+
// Design: a BUTTON is anything that goes down and up — keyboard keys, mouse buttons, gamepad
|
|
7
|
+
// buttons — and they share ONE code vocabulary (KeyboardEvent.code + "MouseLeft|Right|Middle|
|
|
8
|
+
// Back|Forward" + the W3C standard-gamepad "GamepadSouth|East|West|North|L1|R1|L2|R2|Select|
|
|
9
|
+
// Start|L3|R3|Up|Down|Left|Right"), one held-poll and one event pair. Continuous signals (mouse
|
|
10
|
+
// motion, sticks, triggers) are numbered channels behind one poll. Bindings/axes/edge detection
|
|
11
|
+
// are SDK-side; hosts only report physical state. Every slot is optional: a touch-only host has
|
|
12
|
+
// no buttons, no pointer, no pads, and the SDK reads "nothing held, zero motion, lock refused".
|
|
13
|
+
// The push side (button events, keyboard frames) is `emitInputEvent` / `emitKeyboardEvent`:
|
|
14
|
+
// update the polls BEFORE emitting, so a handler reading a poll agrees with the event.
|
|
15
|
+
import type { f32, f64, i32 } from "./types"
|
|
16
|
+
|
|
17
|
+
declare global {
|
|
18
|
+
/** @host input */
|
|
19
|
+
var _creatorInput: {
|
|
20
|
+
/** Is this button held right now? `gamepad` (0..3) scopes a Gamepad* code to one pad; -1 =
|
|
21
|
+
* any connected pad. Keyboard/mouse codes ignore it. */
|
|
22
|
+
key?(code: string, gamepad: i32): boolean
|
|
23
|
+
/** Continuous input poll by channel id (SDK `InputChannel`): 0 MouseX, 1 MouseY (logical px,
|
|
24
|
+
* last known cursor position inside the viewport), 2 MouseDX, 3 MouseDY (motion accumulated
|
|
25
|
+
* during the PREVIOUS frame — unaccelerated/raw where the OS offers it, counts while locked),
|
|
26
|
+
* 4 WheelX, 5 WheelY (wheel notches, previous frame), 6 PointerLocked (0/1), 7 GamepadCount,
|
|
27
|
+
* 8 PointerOnUI (0/1: the primary pointer went DOWN on something the UI claimed — an
|
|
28
|
+
* interactive node, a scrollable, an editable, a modal backdrop — and is still held; stays 1
|
|
29
|
+
* wherever the cursor goes until the release, so a drag that started on a HUD control never
|
|
30
|
+
* becomes camera look; always 0 while pointer-locked and for touch-only hosts without a UI claim);
|
|
31
|
+
* gamepad p at 16 + 16·p: +0 Connected, +1 LeftX, +2 LeftY, +3 RightX, +4 RightY (−1..1,
|
|
32
|
+
* +Y = down like the web), +5 LeftTrigger, +6 RightTrigger (0..1). Unknown channel → 0.
|
|
33
|
+
* "Previous frame" = the host's own frame boundary (the event pump / rAF / fixed step), so
|
|
34
|
+
* every read within one frame agrees. */
|
|
35
|
+
read?(channel: i32): f64
|
|
36
|
+
/** Request (true) / release (false) pointer lock: hide + confine the cursor, keep MouseDX/DY
|
|
37
|
+
* flowing (FPS look). Returns whether the request was accepted now (web needs a user gesture);
|
|
38
|
+
* the eventual state is channel 6. Hosts release on focus loss and re-acquire on focus. */
|
|
39
|
+
setPointerLock?(on: boolean): boolean
|
|
40
|
+
/** Register THE input-event listener (single slot per JS world, like `_creatorApp.registerEvent`
|
|
41
|
+
* — the SDK fans out). kind: 0 keydown, 1 keyup, 2 gamepadconnected, 3 gamepaddisconnected.
|
|
42
|
+
* `code` is the button code above ("" for connect events); `gamepad` the pad index for Gamepad*
|
|
43
|
+
* codes / connect events, −1 otherwise; `repeat` 1 for an OS auto-repeat keydown. Delivered on
|
|
44
|
+
* the JS thread no later than the end of the frame it arrived in — i.e. always before the NEXT
|
|
45
|
+
* setLoop tick (the runtime drains its dispatch queue after the frame's timers, so a poll can
|
|
46
|
+
* see the new state one tick before the event; web/headless deliver synchronously). @custom */
|
|
47
|
+
registerEvent?(callback: (kind: number, code: string, gamepad: number, repeat: number) => void): void
|
|
48
|
+
/** Dual-motor rumble on pad `gamepad` (0..3) — the W3C "dual-rumble" effect. `strong` = the
|
|
49
|
+
* low-frequency (left, heavy) motor, `weak` = the high-frequency (right, light) one, both 0..1
|
|
50
|
+
* (hosts clamp); `durationMs` > 0, hosts cap it at 5000. A new call REPLACES the running effect
|
|
51
|
+
* on that pad; `strong = weak = 0` (any duration) stops it. The HOST owns the clock: the motors
|
|
52
|
+
* stop by themselves after `durationMs`, on focus loss, when the pad disconnects and when the
|
|
53
|
+
* world that started the effect is torn down — an app never has to clean up. Returns whether
|
|
54
|
+
* the pad took the command (false: no such pad, or it has no motors). */
|
|
55
|
+
rumble?(gamepad: i32, strong: f32, weak: f32, durationMs: i32): boolean
|
|
56
|
+
|
|
57
|
+
// ---- The on-screen keyboard (docs/input-upgrades-plan.md §7) ----------------------------------
|
|
58
|
+
/** On-screen keyboard height in logical px currently overlapping the app viewport, 0 when
|
|
59
|
+
* hidden. The RAW overlap, independent of the focused input's keyboardShrink policy (with
|
|
60
|
+
* shrink the layout already avoids it; the main consumer is overlay mode). Surfaced as
|
|
61
|
+
* app.keyboardHeight. Hosts without an on-screen keyboard leave it null. */
|
|
62
|
+
keyboardHeight?(): f64
|
|
63
|
+
/** Register THE keyboard listener (single slot per JS world, like registerEvent — the SDK fans
|
|
64
|
+
* out; a separate channel because the string one can't carry two numbers). Fires on every
|
|
65
|
+
* keyboard frame change with (height — as above, duration — the platform's animation duration
|
|
66
|
+
* in ms, 0 where none). Surfaced as the app "keyboard" event. The host pushes with
|
|
67
|
+
* `emitKeyboardEvent`. @custom */
|
|
68
|
+
registerKeyboardEvent?(callback: (height: number, duration: number) => void): void
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export {}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// The media bridge (`_creatorMedia`): the SDK `AudioPlayer` / `VideoPlayer` over the host's media
|
|
2
|
+
// players (the platform's decoders and network — game audio is `_creatorAudio`, the engine).
|
|
3
|
+
// Part of the host contract. A HOST bridge (`@host`, see ./app.d.ts): the native side is the
|
|
4
|
+
// `HostMedia` table of runtime/native/include/creator-pkg/host.gen.h, generated from this file —
|
|
5
|
+
// the `var` members below plus the `interface HostMedia` slots (a slot may repeat a `@custom`
|
|
6
|
+
// member's name: the JS wrapper is the runtime's, the slot is the host's).
|
|
7
|
+
// OPTIONAL AS A WHOLE (`@optional`): a host without media players (desktop, headless) provides no
|
|
8
|
+
// table and the global is absent — the SDK players are inert there. Only `createMediaPlayerTexture`
|
|
9
|
+
// stays on `_creator` (it imports a player's frames into the 3D engine).
|
|
10
|
+
//
|
|
11
|
+
// Ownership (owned handles, docs/plans/hosts-unification-plan.md phase 10): a player is an OWNED
|
|
12
|
+
// resource — `createAudio` / `createVideo` return a Handle; the runtime (host/media.cpp) counts a
|
|
13
|
+
// PLAYING player as natively owned, so a one-shot the app fires and forgets keeps playing to its
|
|
14
|
+
// end and is released then; a paused player the app dropped is released at once. The host's
|
|
15
|
+
// end-of-playback callback is the runtime's trampoline: the SDK hears it by id through `setEmitter`.
|
|
16
|
+
import type { f32, f64, i32 } from "./types"
|
|
17
|
+
|
|
18
|
+
declare global {
|
|
19
|
+
/** @host media @optional */
|
|
20
|
+
var _creatorMedia: {
|
|
21
|
+
/** A player for `src` as an owned Handle (null = the host failed to create one). @custom */
|
|
22
|
+
createAudio(src: string): Handle | null
|
|
23
|
+
/** @custom */
|
|
24
|
+
createVideo(src: string): Handle | null
|
|
25
|
+
setVolume(id: i32, volume: f32): void
|
|
26
|
+
/** @custom (the runtime remembers the loop flag: a looping end is not a stop) */
|
|
27
|
+
setLoop(id: i32, loop: boolean): void
|
|
28
|
+
/** @custom (the runtime counts playing as ownership) */
|
|
29
|
+
setPlaying(id: i32, playing: boolean): void
|
|
30
|
+
/** Playback position in seconds. */
|
|
31
|
+
time?(id: i32): f64
|
|
32
|
+
setTime?(id: i32, time: f64): void
|
|
33
|
+
/** Media length in seconds (0 until metadata has loaded). */
|
|
34
|
+
duration?(id: i32): f64
|
|
35
|
+
/** ONE listener per world for every player's end-of-playback (`id`): the SDK turns it into
|
|
36
|
+
* loopReached / completed. @custom */
|
|
37
|
+
setEmitter(callback: (id: number) => void): void
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The host's slots behind the `@custom` members above. */
|
|
42
|
+
export interface HostMedia {
|
|
43
|
+
/** A player for `src`; returns its id (-1 = failed). `onFinished` is the end-of-playback listener
|
|
44
|
+
* (the runtime's trampoline): the host keeps the handle and calls it (`dispatchBorrowedCall`) at
|
|
45
|
+
* every play-through end, and frees it (`jsFree`) on `remove`. */
|
|
46
|
+
createAudio(src: string, onFinished: () => void): i32
|
|
47
|
+
createVideo(src: string, onFinished: () => void): i32
|
|
48
|
+
setLoop(id: i32, loop: boolean): void
|
|
49
|
+
setPlaying(id: i32, playing: boolean): void
|
|
50
|
+
/** Release the player (decoder, network, buffers) and its `onFinished` handle. A host that leaves
|
|
51
|
+
* it null keeps players for the process. */
|
|
52
|
+
remove?(id: i32): void
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export {}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// The navmesh bridge (`_creatorNav`): engines/nav (Recast/Detour).
|
|
2
|
+
// Part of the host contract: every runtime implements this global (runtime/native in C++, the web
|
|
3
|
+
// runtimes in TS). Types are the PRECISE ones the native side reads (see ./types.d.ts); the SDK
|
|
4
|
+
// only sees numbers. The ABI checker (scripts/check-pkg-bridges.mjs) reads this folder.
|
|
5
|
+
import type { bytes, f32, i32, u32, u8 } from "./types"
|
|
6
|
+
|
|
7
|
+
declare global {
|
|
8
|
+
// ---- navigation meshes (creator-nav / Recast+Detour) -----------------------------------------
|
|
9
|
+
// Runtime only (docs/navmesh-plan.md §5): load a baked `.navmesh` (LNAV) from a fetch system id,
|
|
10
|
+
// query it, run a DetourCrowd of agents one fixed step at a time. Present on hosts built with
|
|
11
|
+
// CREATOR_PKG_NAV (desktop, the 3d/full Android variants, iOS) and on every web host through the
|
|
12
|
+
// wasm build; the SDK feature-detects it. Parameter blocks are fixed-order Float32Arrays
|
|
13
|
+
// (creator-nav.h CNAV_AGENT_* / CNAV_READ_*). Handles (meshId / crowdId, from 1) are the engine's
|
|
14
|
+
// own (creator-nav.h "handles"): a world swap unloads them all. Every method is one engine call.
|
|
15
|
+
/** @engine nav */
|
|
16
|
+
var _creatorNav: {
|
|
17
|
+
/** Web hosts only: loads the wasm lazily. Absent on native hosts — call it when present. @custom */
|
|
18
|
+
ready?(): Promise<void>
|
|
19
|
+
/** @c cnavLastError */
|
|
20
|
+
lastError(): string
|
|
21
|
+
/** LNAV bytes already fetched (the createGlb pattern) → meshId, 0 on failure. @c cnavLoad */
|
|
22
|
+
load(systemId: bytes): u32
|
|
23
|
+
/** @c cnavUnload */
|
|
24
|
+
unload(meshId: u32): void
|
|
25
|
+
/** The file's JSON header: agent size, cell, bounds, stats, `meta` (the CLI's provenance). @c cnavHeader */
|
|
26
|
+
header(meshId: u32): string
|
|
27
|
+
/** @c cnavPolyCount */
|
|
28
|
+
polyCount(meshId: u32): i32
|
|
29
|
+
/** @c cnavSetAreaCost */
|
|
30
|
+
setAreaCost(meshId: u32, area: u8, cost: f32): void
|
|
31
|
+
/** Straight path from → to into `out` (xyz per corner, up to out.length / 3 corners); returns the
|
|
32
|
+
* corner count, NEGATIVE when the path is partial (the target is unreachable — it ends at the
|
|
33
|
+
* closest polygon). `ex <= 0` = default search extents.
|
|
34
|
+
* @c cnavPath @pack fx 3 @pack tx 3 @pack ex 3 @count outCount=out */
|
|
35
|
+
findPath(meshId: u32, fx: f32, fy: f32, fz: f32, tx: f32, ty: f32, tz: f32, ex: f32, ey: f32, ez: f32, include: u32, exclude: u32, out: Float32Array): i32
|
|
36
|
+
/** @c cnavNearestPoint @pack x 3 @pack ex 3 */
|
|
37
|
+
nearest(meshId: u32, x: f32, y: f32, z: f32, ex: f32, ey: f32, ez: f32, include: u32, exclude: u32, out: Float32Array): boolean
|
|
38
|
+
/** Walkability ray along the surface; true = BLOCKED, out = [hit xyz, wall normal xyz].
|
|
39
|
+
* @c cnavRay @pack fx 3 @pack tx 3 */
|
|
40
|
+
raycast(meshId: u32, fx: f32, fy: f32, fz: f32, tx: f32, ty: f32, tz: f32, include: u32, exclude: u32, out: Float32Array): boolean
|
|
41
|
+
/** `radius <= 0` = anywhere on the mesh; deterministic per seed. @c cnavRandom @pack cx 3 */
|
|
42
|
+
randomPoint(meshId: u32, cx: f32, cy: f32, cz: f32, radius: f32, seed: u32, include: u32, exclude: u32, out: Float32Array): boolean
|
|
43
|
+
/** The polygon mesh as a triangle soup (xyz per vertex) for debug drawing. @c cnavTriangles @out sized*3 */
|
|
44
|
+
debugTriangles(meshId: u32): Float32Array
|
|
45
|
+
/** @c cnavCrowdNew */
|
|
46
|
+
crowdCreate(meshId: u32, maxAgents: i32, maxRadius: f32): u32
|
|
47
|
+
/** @c cnavCrowdFree */
|
|
48
|
+
crowdDestroy(crowdId: u32): void
|
|
49
|
+
/** → the agent's slot (0..maxAgents-1), -1 when full / off the mesh. @c cnavAgentAdd @pack x 3 */
|
|
50
|
+
crowdAdd(crowdId: u32, x: f32, y: f32, z: f32, params: Float32Array): i32
|
|
51
|
+
/** @c cnavAgentRemove */
|
|
52
|
+
crowdRemove(crowdId: u32, agent: i32): void
|
|
53
|
+
/** @c cnavAgentSetParams */
|
|
54
|
+
crowdSetParams(crowdId: u32, agent: i32, params: Float32Array): void
|
|
55
|
+
/** @c cnavAgentSetTarget @pack x 3 */
|
|
56
|
+
crowdSetTarget(crowdId: u32, agent: i32, x: f32, y: f32, z: f32): boolean
|
|
57
|
+
/** @c cnavAgentSetVelocity @pack vx 3 */
|
|
58
|
+
crowdSetVelocity(crowdId: u32, agent: i32, vx: f32, vy: f32, vz: f32): void
|
|
59
|
+
/** @c cnavAgentResetTarget */
|
|
60
|
+
crowdResetTarget(crowdId: u32, agent: i32): void
|
|
61
|
+
/** @c cnavAgentWarp @pack x 3 */
|
|
62
|
+
crowdWarp(crowdId: u32, agent: i32, x: f32, y: f32, z: f32): boolean
|
|
63
|
+
/** Once per fixed step. @c cnavCrowdStep */
|
|
64
|
+
crowdUpdate(crowdId: u32, dt: f32): void
|
|
65
|
+
/** Every slot into `out` (CNAV_AGENT_READ_STRIDE floats each); returns maxAgents, 0 when `out` is short.
|
|
66
|
+
* @c cnavCrowdReadAll */
|
|
67
|
+
crowdRead(crowdId: u32, out: Float32Array): i32
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export {}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// The multiplayer bridge (`_creatorNet`): engines/net (yojimbo UDP transport).
|
|
2
|
+
// Part of the host contract: every runtime implements this global (runtime/native in C++, the web
|
|
3
|
+
// runtimes in TS). Types are the PRECISE ones the native side reads (see ./types.d.ts); the SDK
|
|
4
|
+
// only sees numbers. The ABI checker (scripts/check-pkg-bridges.mjs) reads this folder.
|
|
5
|
+
import type { f32, i32 } from "./types"
|
|
6
|
+
|
|
7
|
+
// Object types of the contract (the generator's struct rule; `@c` names the engine's struct).
|
|
8
|
+
/** What the exe was launched as (`--server --port N` / `--connect ADDR`). @c cnetLaunch */
|
|
9
|
+
export type NetLaunch = { role: string, address: string, port: i32, maxClients: i32 }
|
|
10
|
+
/** Link statistics of a server slot (server) / the link (client). @c cnetStats */
|
|
11
|
+
export type NetStats = { rtt: f32, loss: f32, sentKbps: f32, receivedKbps: f32 }
|
|
12
|
+
|
|
13
|
+
declare global {
|
|
14
|
+
// ---- multiplayer transport (creator-net / yojimbo) -------------------------------------------
|
|
15
|
+
// A byte pipe pumped on the JS thread (docs/multiplayer-plan.md). Present only on hosts built
|
|
16
|
+
// with CREATOR_PKG_NET (desktop, the 3d/full Android variants, iOS); the SDK feature-detects it.
|
|
17
|
+
// One endpoint per process (creator-net.h "endpoint"): `listen` (server / host) or `connect`
|
|
18
|
+
// (client), never both. Only `send` / `poll` are hand-written: they turn JS payloads into bytes
|
|
19
|
+
// (a tag byte says text or binary) and records into JS values.
|
|
20
|
+
/** @engine net */
|
|
21
|
+
var _creatorNet: {
|
|
22
|
+
/** What the exe was launched as, or null. @c cnetGetLaunch */
|
|
23
|
+
launch(): NetLaunch | null
|
|
24
|
+
/** Serve on every interface at `port` (wildcard public address). @c cnetListen */
|
|
25
|
+
listen(port: i32, maxClients: i32): boolean
|
|
26
|
+
/** Insecure (dev / LAN) connect to "ip:port"; the outcome arrives as a poll record. @c cnetConnect */
|
|
27
|
+
connect(address: string): boolean
|
|
28
|
+
/** @c cnetDisconnect */
|
|
29
|
+
disconnect(): void
|
|
30
|
+
/** @c cnetKick */
|
|
31
|
+
kick(client: i32): void
|
|
32
|
+
/** Queue a payload: channel 0 reliable-ordered, 1 unreliable; `client` ignored on a client.
|
|
33
|
+
* A string travels as UTF-8 text and arrives as a string; bytes arrive as an ArrayBuffer. @custom */
|
|
34
|
+
send(client: i32, channel: i32, data: string | ArrayBuffer | Uint8Array): boolean
|
|
35
|
+
/** Pump once and return every record since the last call as a flat array of 4-tuples
|
|
36
|
+
* [kind, client, arg, payload] — kind 1 connected · 2 disconnected · 3 message · 4 connectFailed;
|
|
37
|
+
* arg = channel (message) or reason code; payload = string | ArrayBuffer | null. @custom */
|
|
38
|
+
poll(): any[] | null
|
|
39
|
+
/** 0 idle · 1 client · 2 server @c cnetMode */
|
|
40
|
+
mode(): i32
|
|
41
|
+
/** Client: 0 disconnected · 1 connecting · 2 connected · 3 failed. A listening server: 2. @c cnetState */
|
|
42
|
+
state(): i32
|
|
43
|
+
/** Statistics for a slot (server) / the link (client); null when that link is not connected. @c cnetStatsOf */
|
|
44
|
+
clientInfo(client: i32): NetStats | null
|
|
45
|
+
/** yojimbo network simulator on this side of the wire. @c cnetSimulate */
|
|
46
|
+
simulate(latencyMs: f32, jitterMs: f32, lossPercent: f32): void
|
|
47
|
+
/** @c cnetReasonString */
|
|
48
|
+
reasonString(reason: i32, serverSide: boolean): string
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export {}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// The service bridge (`_creatorService`): headless `registerService` capabilities
|
|
2
|
+
// (docs/service-channel-plan.md) — the UI-less sibling of the NativeView channel. The host registers
|
|
3
|
+
// named service factories (`registerService("geolocation", factory)`) and the SDK talks to them
|
|
4
|
+
// over the same call / event protocol as viewCall: values, not text (`value` of ./types).
|
|
5
|
+
// Part of the host contract. A HOST bridge (`@host`, see ./app.d.ts): the native side is the
|
|
6
|
+
// `HostService` table of runtime/native/include/creator-pkg/host.gen.h, generated from this file.
|
|
7
|
+
// OPTIONAL AS A WHOLE (`@optional`): a host that did not opt in provides no table and the global is
|
|
8
|
+
// absent — the SDK feature-detects with typeof. Sessions must open cheaply (no permission prompt, no
|
|
9
|
+
// I/O) — prompts belong in the first call that needs them, so a rejected call is the failure
|
|
10
|
+
// surface, never a hung open. The runtime tracks the sessions each world opened and closes them on
|
|
11
|
+
// the world's teardown (`open` / `close` are `@custom` for that bookkeeping).
|
|
12
|
+
import type { i32, value } from "./types"
|
|
13
|
+
|
|
14
|
+
declare global {
|
|
15
|
+
/** @host service @optional */
|
|
16
|
+
var _creatorService: {
|
|
17
|
+
/** Did the host register a factory under `name`? Backs `Service.isSupported(name)`. */
|
|
18
|
+
supported(name: string): boolean
|
|
19
|
+
/** The contract version the half registered as `name` was generated from; 1 for a half written
|
|
20
|
+
* by hand, 0 when there is none. On a host that does not say: 1 for a service it has. @custom */
|
|
21
|
+
version(name: string): i32
|
|
22
|
+
/** Open a session against the registered factory. `params` is a JSON string. Returns the
|
|
23
|
+
* host-allocated session id, or -1 when no factory is registered under `name`. `onEvent`
|
|
24
|
+
* delivers service events (the payload as a value, or omitted) until `close`. @custom */
|
|
25
|
+
open(name: string, params: string, onEvent: (event: string, data?: value) => void): i32
|
|
26
|
+
/** Invoke a method on a live session, exactly like viewCall: `args` is the array of the call's
|
|
27
|
+
* arguments; a value that cannot cross throws here. The host settles exactly one of
|
|
28
|
+
* `onComplete(result?)` / `onError(message)`. @custom */
|
|
29
|
+
call(serviceId: i32, method: string, args: value, onComplete: (result?: value) => void, onError: (err: string) => void): void
|
|
30
|
+
/** @custom */
|
|
31
|
+
close(serviceId: i32): void
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The slots of `HostService` the runtime calls and JS never sees. */
|
|
36
|
+
export interface HostService {
|
|
37
|
+
/** `_creatorService.open`: `onEvent` is a BORROWED heap handle (the socket `onMessage` model) —
|
|
38
|
+
* deliver with `dispatchBorrowedCall(onEvent, [event, data?])`, `jsFree` it when the session
|
|
39
|
+
* dies. Return -1 without taking the handle when `name` has no factory (the runtime frees it). */
|
|
40
|
+
open(name: string, params: string, onEvent: (event: string, data?: value) => void): i32
|
|
41
|
+
/** Destroy the session (the app's close AND the runtime's world-swap teardown). */
|
|
42
|
+
close(serviceId: i32): void
|
|
43
|
+
/** `_creatorService.version`: the contract version of the half registered as `name` (1 for one
|
|
44
|
+
* written by hand, 0 for none). */
|
|
45
|
+
version?(name: string): i32
|
|
46
|
+
/** `_creatorService.call`: `args` is the array of the call's arguments, valid for the call. Settle
|
|
47
|
+
* exactly one of the two callbacks through the dispatch bridge — `onComplete` with the result as
|
|
48
|
+
* ONE value, or with none. */
|
|
49
|
+
call(serviceId: i32, method: string, args: value, onComplete: (result?: value) => void, onError: (err: string) => void): void
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export {}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// The socket bridge (`_creatorSocket`): the SDK `WebSocket` over the host's own client.
|
|
2
|
+
// Part of the host contract. A HOST bridge (`@host`, see ./app.d.ts): the native side is the
|
|
3
|
+
// `HostSocket` table of runtime/native/include/creator-pkg/host.gen.h, generated from this file.
|
|
4
|
+
// The runtime tracks the sockets each world opened and closes them when the world is torn down
|
|
5
|
+
// (`open` / `close` are `@custom` for that bookkeeping); the host owns the connection.
|
|
6
|
+
import type { i32 } from "./types"
|
|
7
|
+
|
|
8
|
+
declare global {
|
|
9
|
+
/** @host socket */
|
|
10
|
+
var _creatorSocket: {
|
|
11
|
+
/** Open a connection; returns the host's socket id (≥ 0 — failures arrive as an "error"
|
|
12
|
+
* event). `onMessage(channel, data?)` is a long-lived listener the host keeps until the
|
|
13
|
+
* connection dies: channels "open", "message" (data = the text), "close" (data = the code),
|
|
14
|
+
* "error". @custom */
|
|
15
|
+
open(url: string, onMessage: (channel: string, data?: any) => void): i32
|
|
16
|
+
send(id: i32, message: string): void
|
|
17
|
+
/** @custom */
|
|
18
|
+
close(id: i32): void
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** The slots of `HostSocket` the runtime calls and JS never sees. */
|
|
23
|
+
export interface HostSocket {
|
|
24
|
+
/** `_creatorSocket.open`: `onMessage` is a BORROWED heap handle — deliver events with
|
|
25
|
+
* `dispatchBorrowedCall(onMessage, [channel, data?])` from any thread, and `jsFree` it exactly
|
|
26
|
+
* once when the connection dies (either side). */
|
|
27
|
+
open(url: string, onMessage: (channel: string, data?: any) => void): i32
|
|
28
|
+
close(id: i32): void
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export {}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// The storage bridge (`_creatorStorage`): the SDK `localStorage` — a key/value map per storage
|
|
2
|
+
// name, persisted by the host as one JSON document per name.
|
|
3
|
+
// Part of the host contract. A HOST bridge (`@host`, see ./app.d.ts): the native side is the
|
|
4
|
+
// `HostStorage` table of runtime/native/include/creator-pkg/host.gen.h, generated from this file.
|
|
5
|
+
// The RUNTIME owns the in-memory map, its lazy load and the debounced whole-map save (every method
|
|
6
|
+
// here is `@custom`); the host only loads and saves whole documents through the `HostStorage`
|
|
7
|
+
// slots. Both slots are optional: a host without them (a headless render, CREATOR_HIDDEN) keeps the
|
|
8
|
+
// map in memory only, and the global is present everywhere.
|
|
9
|
+
|
|
10
|
+
declare global {
|
|
11
|
+
/** @host storage */
|
|
12
|
+
var _creatorStorage: {
|
|
13
|
+
/** @custom */
|
|
14
|
+
get(key: string): string | null
|
|
15
|
+
/** @custom */
|
|
16
|
+
set(key: string, value: string): void
|
|
17
|
+
/** @custom */
|
|
18
|
+
remove(key: string): void
|
|
19
|
+
/** Switch to another storage name (a launcher isolating the project it is about to run). The
|
|
20
|
+
* map is dropped and lazily reloaded under the new name; "default" until called. @custom */
|
|
21
|
+
select?(name: string): void
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** The slots of `HostStorage` the runtime calls and JS never sees. */
|
|
26
|
+
export interface HostStorage {
|
|
27
|
+
/** The JSON document saved under `name`, or null when there is none. */
|
|
28
|
+
load?(name: string): string | null
|
|
29
|
+
/** Persist the JSON document under `name` (the whole map; called once per tick at most). */
|
|
30
|
+
save?(name: string, json: string): void
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export {}
|