lecodes-sdk 0.19.0
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 +114 -0
- package/dist/global.d.ts +503 -0
- package/dist/host.d.ts +61 -0
- package/dist/inject.js +4730 -0
- package/dist/types/animate/animate.d.ts +20 -0
- package/dist/types/animate/bezier.d.ts +2 -0
- package/dist/types/animate/easings.d.ts +21 -0
- package/dist/types/canvas/Canvas.d.ts +168 -0
- package/dist/types/core/Aspect.d.ts +171 -0
- package/dist/types/core/InspectorUI.d.ts +88 -0
- package/dist/types/core/StateMachine.d.ts +81 -0
- package/dist/types/core/color.d.ts +13 -0
- package/dist/types/core/compWrite.d.ts +11 -0
- package/dist/types/core/events.d.ts +11 -0
- package/dist/types/core/fields.d.ts +58 -0
- package/dist/types/core/registry.d.ts +7 -0
- package/dist/types/core/signals.d.ts +29 -0
- package/dist/types/core/time.d.ts +31 -0
- package/dist/types/g2/Camera2D.d.ts +19 -0
- package/dist/types/g2/CharacterController2D.d.ts +134 -0
- package/dist/types/g2/Node2D.d.ts +91 -0
- package/dist/types/g2/OneWay2D.d.ts +24 -0
- package/dist/types/g2/Physics2D.d.ts +147 -0
- package/dist/types/g2/Scene2D.d.ts +72 -0
- package/dist/types/g2/Shape2D.d.ts +58 -0
- package/dist/types/g2/Sprite.d.ts +51 -0
- package/dist/types/g2/SpriteAnimation.d.ts +50 -0
- package/dist/types/g2/SpriteSheet.d.ts +69 -0
- package/dist/types/g2/Texture2D.d.ts +16 -0
- package/dist/types/g2/Tilemap.d.ts +20 -0
- package/dist/types/g2/Tileset.d.ts +32 -0
- package/dist/types/g2/Trigger2D.d.ts +20 -0
- package/dist/types/g2/autotile.d.ts +133 -0
- package/dist/types/g2/cells.d.ts +14 -0
- package/dist/types/g2/defineScene2d.d.ts +141 -0
- package/dist/types/g2/groups2d.d.ts +16 -0
- package/dist/types/g2/loop.d.ts +4 -0
- package/dist/types/g2/scenarios2d.d.ts +30 -0
- package/dist/types/g2/touch.d.ts +2 -0
- package/dist/types/gl/Camera.d.ts +79 -0
- package/dist/types/gl/CameraPlace.d.ts +26 -0
- package/dist/types/gl/CharacterController.d.ts +98 -0
- package/dist/types/gl/Gearbox.d.ts +86 -0
- package/dist/types/gl/Geometry.d.ts +39 -0
- package/dist/types/gl/IK.d.ts +53 -0
- package/dist/types/gl/InstancedMesh.d.ts +46 -0
- package/dist/types/gl/Light.d.ts +73 -0
- package/dist/types/gl/Lightmap.d.ts +85 -0
- package/dist/types/gl/Locomotion.d.ts +279 -0
- package/dist/types/gl/Material.d.ts +100 -0
- package/dist/types/gl/Mesh.d.ts +33 -0
- package/dist/types/gl/Model.d.ts +53 -0
- package/dist/types/gl/NavAgent.d.ts +99 -0
- package/dist/types/gl/NavMesh.d.ts +169 -0
- package/dist/types/gl/Node.d.ts +99 -0
- package/dist/types/gl/Noise.d.ts +20 -0
- package/dist/types/gl/Particles.d.ts +277 -0
- package/dist/types/gl/Physics.d.ts +91 -0
- package/dist/types/gl/Plane.d.ts +19 -0
- package/dist/types/gl/Ragdoll.d.ts +86 -0
- package/dist/types/gl/Ray.d.ts +8 -0
- package/dist/types/gl/Scene.d.ts +221 -0
- package/dist/types/gl/Shape.d.ts +122 -0
- package/dist/types/gl/Terrain.d.ts +280 -0
- package/dist/types/gl/Texture.d.ts +27 -0
- package/dist/types/gl/Trigger.d.ts +10 -0
- package/dist/types/gl/Vehicle.d.ts +191 -0
- package/dist/types/gl/Wheel.d.ts +95 -0
- package/dist/types/gl/animation/AnimationClip.d.ts +60 -0
- package/dist/types/gl/animation/Animator.d.ts +219 -0
- package/dist/types/gl/animation/Layer.d.ts +31 -0
- package/dist/types/gl/animation/Loop.d.ts +17 -0
- package/dist/types/gl/animation/Playback.d.ts +36 -0
- package/dist/types/gl/animation/core.d.ts +367 -0
- package/dist/types/gl/controls.d.ts +19 -0
- package/dist/types/gl/physicsEvents.d.ts +1 -0
- package/dist/types/gl/scenarios.d.ts +98 -0
- package/dist/types/gl/state.d.ts +5 -0
- package/dist/types/gl/terrainMesh.d.ts +46 -0
- package/dist/types/gl/touch.d.ts +2 -0
- package/dist/types/inject.d.ts +123 -0
- package/dist/types/math/Mathf.d.ts +39 -0
- package/dist/types/math/mat4.d.ts +66 -0
- package/dist/types/math/quat.d.ts +53 -0
- package/dist/types/math/vec.d.ts +129 -0
- package/dist/types/net/codec.d.ts +25 -0
- package/dist/types/net/core.d.ts +106 -0
- package/dist/types/net/index.d.ts +80 -0
- package/dist/types/net/replication.d.ts +101 -0
- package/dist/types/plugins/camera.d.ts +25 -0
- package/dist/types/plugins/geolocation.d.ts +39 -0
- package/dist/types/plugins/oauth.d.ts +25 -0
- package/dist/types/plugins/permission.d.ts +1 -0
- package/dist/types/plugins/push.d.ts +46 -0
- package/dist/types/plugins/qr.d.ts +21 -0
- package/dist/types/plugins/service.d.ts +33 -0
- package/dist/types/runtime/app.d.ts +67 -0
- package/dist/types/runtime/appEvents.d.ts +7 -0
- package/dist/types/runtime/channel.d.ts +1 -0
- package/dist/types/runtime/clipboard.d.ts +7 -0
- package/dist/types/runtime/datetime.d.ts +80 -0
- package/dist/types/runtime/device.d.ts +126 -0
- package/dist/types/runtime/fetch.d.ts +31 -0
- package/dist/types/runtime/files.d.ts +33 -0
- package/dist/types/runtime/input.d.ts +121 -0
- package/dist/types/runtime/media.d.ts +46 -0
- package/dist/types/runtime/misc.d.ts +11 -0
- package/dist/types/runtime/net.d.ts +15 -0
- package/dist/types/runtime/rpc.d.ts +44 -0
- package/dist/types/runtime/service.d.ts +1 -0
- package/dist/types/runtime/share.d.ts +2 -0
- package/dist/types/runtime/storage.d.ts +5 -0
- package/dist/types/runtime/touch.d.ts +56 -0
- package/dist/types/scene/defineScene.d.ts +296 -0
- package/dist/types/scene/editorPlugins.d.ts +82 -0
- package/dist/types/scene/gizmos.d.ts +56 -0
- package/dist/types/scene/grammar.d.ts +56 -0
- package/dist/types/scene/level.d.ts +98 -0
- package/dist/types/scene/material.d.ts +76 -0
- package/dist/types/server/auth/appConfig.d.ts +16 -0
- package/dist/types/server/auth/global.d.ts +56 -0
- package/dist/types/server/auth/models.d.ts +164 -0
- package/dist/types/server/auth/types.d.ts +56 -0
- package/dist/types/server/channel.d.ts +28 -0
- package/dist/types/server/context.d.ts +27 -0
- package/dist/types/server/db/defineDb.d.ts +36 -0
- package/dist/types/server/db/fields.d.ts +146 -0
- package/dist/types/server/db/index.d.ts +6 -0
- package/dist/types/server/db/marci/query.d.ts +326 -0
- package/dist/types/server/db/types.d.ts +163 -0
- package/dist/types/server/errors.d.ts +8 -0
- package/dist/types/server/inject.d.ts +5 -0
- package/dist/types/ui/NativeView.d.ts +38 -0
- package/dist/types/ui/UI.d.ts +27 -0
- package/dist/types/ui/UIBottomSheet.d.ts +71 -0
- package/dist/types/ui/UIButton.d.ts +30 -0
- package/dist/types/ui/UIContainer.d.ts +33 -0
- package/dist/types/ui/UIImage.d.ts +35 -0
- package/dist/types/ui/UIInput.d.ts +110 -0
- package/dist/types/ui/UIModal.d.ts +70 -0
- package/dist/types/ui/UINode.d.ts +363 -0
- package/dist/types/ui/UIPager.d.ts +123 -0
- package/dist/types/ui/UIPopover.d.ts +39 -0
- package/dist/types/ui/UIScreen.d.ts +57 -0
- package/dist/types/ui/UIScrollable.d.ts +40 -0
- package/dist/types/ui/UISpacer.d.ts +9 -0
- package/dist/types/ui/UITabs.d.ts +96 -0
- package/dist/types/ui/UIText.d.ts +19 -0
- package/dist/types/ui/UIVideo.d.ts +28 -0
- package/dist/types/ui/UIVirtualizedList.d.ts +97 -0
- package/dist/types/ui/UIWidget.d.ts +65 -0
- package/dist/types/ui/fonts.d.ts +9 -0
- package/dist/types/ui/presentable.d.ts +68 -0
- package/dist/types/ui/router.d.ts +40 -0
- package/dist/types/ui/theme.d.ts +26 -0
- package/dist/types.json +1 -0
- package/package.json +46 -0
- package/prompts/2d.md +395 -0
- package/prompts/3d-scene-files.md +113 -0
- package/prompts/3d-scene.md +119 -0
- package/prompts/3d.md +303 -0
- package/prompts/README.md +142 -0
- package/prompts/ar.md +109 -0
- package/prompts/canvas.md +27 -0
- package/prompts/compose.ts +46 -0
- package/prompts/concept.md +49 -0
- package/prompts/core-design.md +75 -0
- package/prompts/core.md +264 -0
- package/prompts/design.md +218 -0
- package/prompts/dist/2d-game.md +1530 -0
- package/prompts/dist/3d-app.md +1672 -0
- package/prompts/dist/ar-app.md +1548 -0
- package/prompts/dist/concept.md +49 -0
- package/prompts/dist/design.md +498 -0
- package/prompts/dist/ui-app.md +1134 -0
- package/prompts/index.md +37 -0
- package/prompts/intake-prompt.md +33 -0
- package/prompts/namer-prompt.md +12 -0
- package/prompts/router-prompt.md +50 -0
- package/prompts/select.ts +111 -0
- package/prompts/ui-design.md +203 -0
- package/prompts/ui.md +803 -0
- package/src/animate/animate.ts +238 -0
- package/src/animate/bezier.ts +138 -0
- package/src/animate/easings.ts +126 -0
- package/src/bridges.d.ts +1345 -0
- package/src/canvas/Canvas.ts +305 -0
- package/src/compile/__tests__/assetIconMacro.test.ts +219 -0
- package/src/compile/__tests__/assetMacro.test.ts +74 -0
- package/src/compile/__tests__/assetName.test.ts +55 -0
- package/src/compile/__tests__/compile.test.ts +287 -0
- package/src/compile/__tests__/detectEntry.test.ts +132 -0
- package/src/compile/__tests__/fontMacro.test.ts +199 -0
- package/src/compile/aspectMacro.ts +86 -0
- package/src/compile/assetIconMacro.ts +384 -0
- package/src/compile/assetMacro.ts +146 -0
- package/src/compile/assetName.ts +50 -0
- package/src/compile/bundler.ts +287 -0
- package/src/compile/compileProject.ts +127 -0
- package/src/compile/detectEntry.ts +128 -0
- package/src/compile/fontMacro.ts +459 -0
- package/src/compile/fontRegistry.ts +78 -0
- package/src/compile/header.ts +67 -0
- package/src/compile/index.ts +100 -0
- package/src/compile/libraryImports.ts +52 -0
- package/src/compile/liteMaterial.ts +247 -0
- package/src/compile/sceneEditor.ts +88 -0
- package/src/compile/serverSplit.ts +233 -0
- package/src/compile/serverTypes.ts +227 -0
- package/src/compile/sfnt.ts +98 -0
- package/src/compile/shaderSchema.ts +202 -0
- package/src/compile/shaderTargets.ts +77 -0
- package/src/compile/sourcemap.ts +25 -0
- package/src/core/Aspect.ts +568 -0
- package/src/core/InspectorUI.ts +212 -0
- package/src/core/StateMachine.ts +308 -0
- package/src/core/__tests__/stateMachine.test.ts +132 -0
- package/src/core/color.ts +66 -0
- package/src/core/compWrite.ts +42 -0
- package/src/core/events.ts +38 -0
- package/src/core/fields.ts +120 -0
- package/src/core/registry.ts +23 -0
- package/src/core/signals.ts +277 -0
- package/src/core/time.ts +84 -0
- package/src/g2/Camera2D.ts +40 -0
- package/src/g2/CharacterController2D.ts +276 -0
- package/src/g2/Node2D.ts +267 -0
- package/src/g2/OneWay2D.ts +66 -0
- package/src/g2/Physics2D.ts +346 -0
- package/src/g2/Scene2D.ts +209 -0
- package/src/g2/Shape2D.ts +259 -0
- package/src/g2/Sprite.ts +89 -0
- package/src/g2/SpriteAnimation.ts +171 -0
- package/src/g2/SpriteSheet.ts +166 -0
- package/src/g2/Texture2D.ts +47 -0
- package/src/g2/Tilemap.ts +41 -0
- package/src/g2/Tileset.ts +71 -0
- package/src/g2/Trigger2D.ts +77 -0
- package/src/g2/autotile.ts +433 -0
- package/src/g2/cells.ts +91 -0
- package/src/g2/defineScene2d.ts +381 -0
- package/src/g2/groups2d.ts +106 -0
- package/src/g2/loop.ts +50 -0
- package/src/g2/scenarios2d.ts +69 -0
- package/src/g2/touch.ts +83 -0
- package/src/gl/Camera.ts +160 -0
- package/src/gl/CameraPlace.ts +52 -0
- package/src/gl/CharacterController.ts +238 -0
- package/src/gl/Gearbox.ts +212 -0
- package/src/gl/Geometry.ts +279 -0
- package/src/gl/IK.ts +193 -0
- package/src/gl/InstancedMesh.ts +132 -0
- package/src/gl/Light.ts +135 -0
- package/src/gl/Lightmap.ts +402 -0
- package/src/gl/Locomotion.ts +498 -0
- package/src/gl/Material.ts +279 -0
- package/src/gl/Mesh.ts +83 -0
- package/src/gl/Model.ts +124 -0
- package/src/gl/NavAgent.ts +337 -0
- package/src/gl/NavMesh.ts +397 -0
- package/src/gl/Node.ts +350 -0
- package/src/gl/Noise.ts +30 -0
- package/src/gl/Particles.ts +676 -0
- package/src/gl/Physics.ts +222 -0
- package/src/gl/Plane.ts +53 -0
- package/src/gl/Ragdoll.ts +270 -0
- package/src/gl/Ray.ts +16 -0
- package/src/gl/Scene.ts +505 -0
- package/src/gl/Shape.ts +409 -0
- package/src/gl/Terrain.ts +1092 -0
- package/src/gl/Texture.ts +63 -0
- package/src/gl/Trigger.ts +45 -0
- package/src/gl/Vehicle.ts +473 -0
- package/src/gl/Wheel.ts +240 -0
- package/src/gl/animation/AnimationClip.ts +204 -0
- package/src/gl/animation/Animator.ts +329 -0
- package/src/gl/animation/Layer.ts +39 -0
- package/src/gl/animation/Loop.ts +31 -0
- package/src/gl/animation/Playback.ts +52 -0
- package/src/gl/animation/core.ts +670 -0
- package/src/gl/controls.ts +95 -0
- package/src/gl/physicsEvents.ts +20 -0
- package/src/gl/scenarios.ts +291 -0
- package/src/gl/state.ts +6 -0
- package/src/gl/terrainMesh.ts +219 -0
- package/src/gl/touch.ts +68 -0
- package/src/host.d.ts +61 -0
- package/src/inject.ts +203 -0
- package/src/math/Mathf.ts +118 -0
- package/src/math/mat4.ts +278 -0
- package/src/math/quat.ts +232 -0
- package/src/math/vec.ts +255 -0
- package/src/net/codec.ts +119 -0
- package/src/net/core.ts +384 -0
- package/src/net/index.ts +181 -0
- package/src/net/replication.ts +622 -0
- package/src/plugins/camera.ts +81 -0
- package/src/plugins/geolocation.ts +123 -0
- package/src/plugins/oauth.ts +61 -0
- package/src/plugins/permission.ts +7 -0
- package/src/plugins/push.ts +132 -0
- package/src/plugins/qr.ts +73 -0
- package/src/plugins/service.ts +47 -0
- package/src/runtime/app.ts +101 -0
- package/src/runtime/appEvents.ts +54 -0
- package/src/runtime/channel.ts +61 -0
- package/src/runtime/clipboard.ts +20 -0
- package/src/runtime/datetime.ts +329 -0
- package/src/runtime/device.ts +293 -0
- package/src/runtime/fetch.ts +77 -0
- package/src/runtime/files.ts +108 -0
- package/src/runtime/input.ts +175 -0
- package/src/runtime/media.ts +111 -0
- package/src/runtime/misc.ts +16 -0
- package/src/runtime/net.ts +36 -0
- package/src/runtime/rpc.ts +218 -0
- package/src/runtime/service.ts +83 -0
- package/src/runtime/share.ts +9 -0
- package/src/runtime/storage.ts +13 -0
- package/src/runtime/touch.ts +76 -0
- package/src/scene/defineScene.ts +1396 -0
- package/src/scene/editorPlugins.ts +110 -0
- package/src/scene/gizmos.ts +148 -0
- package/src/scene/grammar.ts +120 -0
- package/src/scene/level.ts +296 -0
- package/src/scene/material.ts +188 -0
- package/src/server/auth/appConfig.ts +12 -0
- package/src/server/auth/global.ts +80 -0
- package/src/server/auth/host.ts +318 -0
- package/src/server/auth/models.ts +83 -0
- package/src/server/auth/types.ts +50 -0
- package/src/server/channel.ts +56 -0
- package/src/server/context.ts +36 -0
- package/src/server/db/defineDb.ts +237 -0
- package/src/server/db/fields.ts +132 -0
- package/src/server/db/httpTransport.ts +93 -0
- package/src/server/db/index.ts +7 -0
- package/src/server/db/marci/query.ts +412 -0
- package/src/server/db/types.ts +202 -0
- package/src/server/errors.ts +12 -0
- package/src/server/host.ts +74 -0
- package/src/server/inject.ts +13 -0
- package/src/server/runtime.ts +133 -0
- package/src/server/validate.ts +87 -0
- package/src/ui/NativeView.ts +142 -0
- package/src/ui/UI.ts +39 -0
- package/src/ui/UIBottomSheet.ts +139 -0
- package/src/ui/UIButton.ts +101 -0
- package/src/ui/UIContainer.ts +60 -0
- package/src/ui/UIImage.ts +83 -0
- package/src/ui/UIInput.ts +185 -0
- package/src/ui/UIModal.ts +139 -0
- package/src/ui/UINode.ts +830 -0
- package/src/ui/UIPager.ts +362 -0
- package/src/ui/UIPopover.ts +100 -0
- package/src/ui/UIScreen.ts +123 -0
- package/src/ui/UIScrollable.ts +87 -0
- package/src/ui/UISpacer.ts +14 -0
- package/src/ui/UITabs.ts +236 -0
- package/src/ui/UIText.ts +51 -0
- package/src/ui/UIVideo.ts +88 -0
- package/src/ui/UIVirtualizedList.ts +241 -0
- package/src/ui/UIWidget.ts +127 -0
- package/src/ui/fonts.ts +13 -0
- package/src/ui/presentable.ts +117 -0
- package/src/ui/router.ts +132 -0
- package/src/ui/theme.ts +84 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Aspect } from "../core/Aspect";
|
|
2
|
+
import { Vec3 } from "../math/vec";
|
|
3
|
+
import type { Node } from "../gl/Node";
|
|
4
|
+
import { Scene } from "../gl/Scene";
|
|
5
|
+
import { type Layout } from "./codec";
|
|
6
|
+
import { NetPlayer } from "./core";
|
|
7
|
+
export type NetTransform = "pos" | "pos+rot" | "none";
|
|
8
|
+
/** The per-tick input layout: `const PlayerInput = Net.input({ moveX: 0, moveY: 0, jump: false })`. */
|
|
9
|
+
export type NetInput<T extends object = any> = {
|
|
10
|
+
readonly layout: Layout;
|
|
11
|
+
readonly defaults: T;
|
|
12
|
+
readonly __t?: T;
|
|
13
|
+
};
|
|
14
|
+
/** A replicated entity type: `const PlayerKind = Net.kind('player', { pos: [0,0,0], hp: 100 }, { transform: 'pos', client })`. */
|
|
15
|
+
export type NetKind<S extends object = any> = {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly layout: Layout;
|
|
18
|
+
readonly defaults: S;
|
|
19
|
+
/** Which state fields the SDK samples on the server and applies to a client proxy: `pos` (a
|
|
20
|
+
* `pos: [x,y,z]` field), `pos+rot` (+ a `rot: [x,y,z,w]` quaternion field), or `none`. */
|
|
21
|
+
readonly transform: NetTransform;
|
|
22
|
+
/** Births the client-side proxy on spawn; the SDK attaches `Replicated` to what it returns. */
|
|
23
|
+
readonly client?: (rep: NetEntity<S>, scene: Scene | null) => Node | void;
|
|
24
|
+
readonly __t?: S;
|
|
25
|
+
};
|
|
26
|
+
/** Live counters (`Net.stats`): how the clocks and the prediction are doing. */
|
|
27
|
+
export declare const stats: {
|
|
28
|
+
/** client: snapshots received */ snapshots: number;
|
|
29
|
+
/** client: how far ahead of the server's simulation our newest input was at the last snapshot */ ahead: number;
|
|
30
|
+
/** client: our tick minus the estimated server tick */ lead: number;
|
|
31
|
+
/** client: tick nudges (+1 / −1) by the lead control */ nudges: number;
|
|
32
|
+
/** owner: corrections applied, the largest one and their sum (metres) — `sum / corrections` = the typical one */ corrections: number;
|
|
33
|
+
maxCorrection: number;
|
|
34
|
+
sumCorrection: number;
|
|
35
|
+
/** server: inputs that arrived late (the last one was repeated), all clients */ missed: number;
|
|
36
|
+
/** bytes sent on the unreliable channel (snapshots / inputs) */ bytesOut: number;
|
|
37
|
+
};
|
|
38
|
+
export declare class NetEntity<S extends object = any> {
|
|
39
|
+
/** Session-unique id, assigned by the server. */
|
|
40
|
+
readonly netId: number;
|
|
41
|
+
readonly kind: NetKind<S>;
|
|
42
|
+
/** The owning player's id; 0 = the server's own (props, the game state). */
|
|
43
|
+
readonly ownerId: number;
|
|
44
|
+
/** Server: the authoritative state you write (`pos` is sampled from the node). Client remote:
|
|
45
|
+
* interpolated. Client owner: the newest authoritative state. */
|
|
46
|
+
readonly state: S;
|
|
47
|
+
/** The node carrying this entity (server: yours; client: what the kind's factory returned). */
|
|
48
|
+
node: Node | null;
|
|
49
|
+
/** Owner on a client: the visual offset left by the last correction, decaying to zero — add it to
|
|
50
|
+
* what you DRAW (a child mesh, the camera), never to physics. */
|
|
51
|
+
readonly correction: Vec3;
|
|
52
|
+
constructor(netId: number, kind: NetKind<S>, ownerId: number, s: S);
|
|
53
|
+
get owner(): NetPlayer | null;
|
|
54
|
+
/** Our own player owns it (offline: everything owned by `Net.me`). */
|
|
55
|
+
get isMine(): boolean;
|
|
56
|
+
/** This machine runs the simulation for it: the server always, a client for what it owns
|
|
57
|
+
* (prediction). A remote proxy on a client is interpolation only. */
|
|
58
|
+
get simulated(): boolean;
|
|
59
|
+
/** The owner's input for the tick being simulated — the ring entry on the server (the last one
|
|
60
|
+
* repeated when it is late), the local input on the owner / host / offline. */
|
|
61
|
+
input<T extends object>(inp: NetInput<T>): T;
|
|
62
|
+
/** Client: `state` was refreshed (a snapshot landed / the interpolation moved). */
|
|
63
|
+
on(event: "state", cb: (s: S) => void): this;
|
|
64
|
+
off(event: "state", cb: (s: S) => void): this;
|
|
65
|
+
}
|
|
66
|
+
export declare const declareKind: <S extends object>(name: string, defaults: S, opts?: {
|
|
67
|
+
transform?: NetTransform;
|
|
68
|
+
client?: NetKind<S>["client"];
|
|
69
|
+
}) => NetKind<S>;
|
|
70
|
+
export declare const declareInput: <T extends object>(defaults: T) => NetInput<T>;
|
|
71
|
+
export declare const setInput: <T extends object>(inp: NetInput<T>, values: Partial<T>) => void;
|
|
72
|
+
export declare const currentTick: () => number;
|
|
73
|
+
export declare const allEntities: () => NetEntity[];
|
|
74
|
+
export declare const entityById: (netId: number) => NetEntity | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* The server's handle on a replicated entity — attach it to the node that IS the entity:
|
|
77
|
+
* `new Node().aspect(Replicated, { kind: PlayerKind, owner: player })`. From then on the entity exists
|
|
78
|
+
* on every client (the kind's `client` factory births the proxy there, and the SDK attaches this same
|
|
79
|
+
* aspect to it), its state is packed into every snapshot, and `node.destroy()` despawns it everywhere.
|
|
80
|
+
* `node.replicated.state` / `.isMine` / `.simulated` / `.input()` are the same on both sides.
|
|
81
|
+
*/
|
|
82
|
+
export declare class Replicated extends Aspect<"replicated", Node> {
|
|
83
|
+
static readonly aspect = "replicated";
|
|
84
|
+
/** Server: the entity type (required). */
|
|
85
|
+
kind: NetKind<any>;
|
|
86
|
+
/** Server: the owning player, or null for the server's own. */
|
|
87
|
+
owner: NetPlayer | null;
|
|
88
|
+
protected onAttach(): void;
|
|
89
|
+
protected onDetach(): void;
|
|
90
|
+
/** The entity itself (what the client factory received). */
|
|
91
|
+
get entity(): NetEntity;
|
|
92
|
+
get netId(): number;
|
|
93
|
+
get state(): any;
|
|
94
|
+
get isMine(): boolean;
|
|
95
|
+
get simulated(): boolean;
|
|
96
|
+
get ownerPlayer(): NetPlayer | null;
|
|
97
|
+
get correction(): Vec3;
|
|
98
|
+
/** The owner's input for the tick being simulated (see `NetEntity.input`). */
|
|
99
|
+
input<T extends object>(inp: NetInput<T>): T;
|
|
100
|
+
}
|
|
101
|
+
export declare const installReplication: () => void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { File } from "../runtime/fetch";
|
|
2
|
+
import { type PresentOptions } from "../ui/presentable";
|
|
3
|
+
import { NativeView } from "../ui/NativeView";
|
|
4
|
+
export type CameraFacing = "front" | "back";
|
|
5
|
+
export interface CameraView extends NativeView {
|
|
6
|
+
/** Request camera permission, then present the preview. The current destination stays visible
|
|
7
|
+
* until the camera is ready; rejects if permission is denied, the host has no camera, or
|
|
8
|
+
* another navigation superseded this one. */
|
|
9
|
+
open(options?: PresentOptions): Promise<void>;
|
|
10
|
+
/** Capture a still frame as an image `File` (host-encoded). */
|
|
11
|
+
takePhoto(): Promise<File>;
|
|
12
|
+
/** Switch between the front and back camera while the preview is live. */
|
|
13
|
+
setFacingMode(facingMode: CameraFacing): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Create a camera view (default: the back camera). `CameraView.isSupported` reports whether this
|
|
17
|
+
* host has a camera capability — check it before offering the feature.
|
|
18
|
+
*/
|
|
19
|
+
export declare const CameraView: {
|
|
20
|
+
(options?: {
|
|
21
|
+
facingMode?: CameraFacing;
|
|
22
|
+
}): CameraView;
|
|
23
|
+
/** Whether this host registered a "camera" view. */
|
|
24
|
+
readonly isSupported: boolean;
|
|
25
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface GeoPosition {
|
|
2
|
+
latitude: number;
|
|
3
|
+
longitude: number;
|
|
4
|
+
/** Horizontal accuracy radius, meters. */
|
|
5
|
+
accuracy: number;
|
|
6
|
+
/** Meters above sea level, or null when the provider doesn't know. */
|
|
7
|
+
altitude: number | null;
|
|
8
|
+
/** Direction of travel in degrees clockwise from north, or null when stationary/unknown. */
|
|
9
|
+
heading: number | null;
|
|
10
|
+
/** Ground speed in m/s, or null when unknown. */
|
|
11
|
+
speed: number | null;
|
|
12
|
+
/** When this fix was taken, ms epoch. */
|
|
13
|
+
timestamp: number;
|
|
14
|
+
}
|
|
15
|
+
export interface GeoOptions {
|
|
16
|
+
/** Prefer the precise (GPS) provider — slower first fix, more battery. Default false. */
|
|
17
|
+
highAccuracy?: boolean;
|
|
18
|
+
/** getCurrent only: reject with "timeout" if no fix arrives in this many ms. */
|
|
19
|
+
timeout?: number;
|
|
20
|
+
}
|
|
21
|
+
/** A live `Geolocation.watch()` subscription — `stop()` it when the screen goes away. */
|
|
22
|
+
export interface GeoWatch {
|
|
23
|
+
stop(): void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The device position. `Geolocation.isSupported` reports whether this host registered the
|
|
27
|
+
* service — check it before offering location features.
|
|
28
|
+
*/
|
|
29
|
+
export declare const Geolocation: {
|
|
30
|
+
/** Whether this host registered a "geolocation" service. */
|
|
31
|
+
readonly isSupported: boolean;
|
|
32
|
+
/** One position fix. Prompts for permission on first use; rejects on denial ("denied"), no
|
|
33
|
+
* provider ("unavailable"), or `options.timeout` elapsing ("timeout"). */
|
|
34
|
+
getCurrent(options?: GeoOptions): Promise<GeoPosition>;
|
|
35
|
+
/** Continuous updates. Resolves once watching (permission granted + provider started) — so a
|
|
36
|
+
* denial is a rejection, never a silently dead callback. One host watch serves every
|
|
37
|
+
* subscriber; the options of the watch that starts it win. Always `stop()` when done. */
|
|
38
|
+
watch(callback: (position: GeoPosition) => void, options?: GeoOptions): Promise<GeoWatch>;
|
|
39
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type OAuthProviderName = "google" | "apple" | "yandex" | "vk";
|
|
2
|
+
/** What a native provider SDK yields — pass it verbatim to your endpoint / `auth.oauth.signIn`. */
|
|
3
|
+
export type OAuthCredential = {
|
|
4
|
+
provider: OAuthProviderName;
|
|
5
|
+
/** OAuth access token (Yandex, VK ID). */
|
|
6
|
+
accessToken?: string;
|
|
7
|
+
/** OpenID identity token (Google, Apple). */
|
|
8
|
+
idToken?: string;
|
|
9
|
+
/** Apple only sends the name once, on the first sign-in — forward it so the server can store it. */
|
|
10
|
+
name?: string;
|
|
11
|
+
email?: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Native provider sign-in. `OAuth.isSupported` reports whether this host registered the service;
|
|
15
|
+
* `OAuth.providers()` which providers it has SDKs for. Otherwise open `auth.oauth.url(provider)` (server)
|
|
16
|
+
* with `openURL` — the browser broker.
|
|
17
|
+
*/
|
|
18
|
+
export declare const OAuth: {
|
|
19
|
+
/** Whether this host registered an "oauth" service. */
|
|
20
|
+
readonly isSupported: boolean;
|
|
21
|
+
/** The providers this host can sign in with natively. */
|
|
22
|
+
providers(): Promise<OAuthProviderName[]>;
|
|
23
|
+
/** Run the provider's native sheet; resolves with the credential for `auth.oauth.signIn`. Rejects "cancelled" / "unavailable". */
|
|
24
|
+
signIn(provider: OAuthProviderName): Promise<OAuthCredential>;
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const _requestCameraPermission: () => Promise<void>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** A delivered notification, as the app sees it. */
|
|
2
|
+
export interface PushPayload {
|
|
3
|
+
title: string;
|
|
4
|
+
body?: string;
|
|
5
|
+
/** Deep link — also delivered through `app.launchUrl` / the app "url" event. */
|
|
6
|
+
url?: string;
|
|
7
|
+
/** The developer's own JSON, ≤ 2 KB serialized. */
|
|
8
|
+
data?: Record<string, any>;
|
|
9
|
+
badge?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface PushStatus {
|
|
12
|
+
/** OS notification permission for the host app. "prompt" = not asked yet. */
|
|
13
|
+
permission: "granted" | "denied" | "prompt";
|
|
14
|
+
/** Whether this device already holds a registration (an address) for this app. */
|
|
15
|
+
registered: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface PushRegisterOptions {
|
|
18
|
+
/** Your app's OWN user id ("external user id"): lets your server send to `users: ["u42"]`
|
|
19
|
+
* instead of storing addresses, fanning out to all the user's devices. CLIENT-ASSERTED and
|
|
20
|
+
* unverified — never target sensitive content by user. The registration reflects the latest
|
|
21
|
+
* `register()` call, so registering without `user` clears it (logout). */
|
|
22
|
+
user?: string;
|
|
23
|
+
}
|
|
24
|
+
export type PushEvent = "message" | "tap";
|
|
25
|
+
/**
|
|
26
|
+
* Remote push notifications. `Push.isSupported` reports whether this host registered the
|
|
27
|
+
* service — check it before offering notification features.
|
|
28
|
+
*/
|
|
29
|
+
export declare const Push: {
|
|
30
|
+
/** Whether this host registered a "push" service. */
|
|
31
|
+
readonly isSupported: boolean;
|
|
32
|
+
/** Permission + registration state. Never prompts. */
|
|
33
|
+
getStatus(): Promise<PushStatus>;
|
|
34
|
+
/** Ask for permission (first time) and register this device → the opaque address your server
|
|
35
|
+
* targets. Idempotent — safe to call every launch; rejects "denied" / "unavailable". */
|
|
36
|
+
register(options?: PushRegisterOptions): Promise<{
|
|
37
|
+
address: string;
|
|
38
|
+
}>;
|
|
39
|
+
/** Remove this device's registration (the address stops receiving). */
|
|
40
|
+
unregister(): Promise<void>;
|
|
41
|
+
/** The notification that cold-started this app run, or null. Stable across calls. */
|
|
42
|
+
getLaunch(): Promise<PushPayload | null>;
|
|
43
|
+
/** "message" = received while the app is open; "tap" = the user tapped one while it ran. */
|
|
44
|
+
addEventListener(event: PushEvent, callback: (payload: PushPayload) => void): void;
|
|
45
|
+
removeEventListener(event: PushEvent, callback: (payload: PushPayload) => void): void;
|
|
46
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type PresentOptions } from "../ui/presentable";
|
|
2
|
+
import { NativeView } from "../ui/NativeView";
|
|
3
|
+
export interface QRScanner extends NativeView {
|
|
4
|
+
/** Fires per decoded camera frame: the decoded string, or `null` for a frame with no readable
|
|
5
|
+
* code (expect those repeatedly while the user aims). The same code can be reported more than
|
|
6
|
+
* once — `close()` or debounce once you have what you need. */
|
|
7
|
+
onScan(callback: (data: string | null) => void): this;
|
|
8
|
+
/** Request camera permission, then present the scanner. The current destination (and its
|
|
9
|
+
* loading state) stays visible until the scanner is ready; rejects if the camera is denied,
|
|
10
|
+
* the host can't scan, or another navigation superseded this one. */
|
|
11
|
+
open(options?: PresentOptions): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Create a QR scanner view. `QRScanner.isSupported` reports whether this host can scan at all —
|
|
15
|
+
* check it before offering the feature.
|
|
16
|
+
*/
|
|
17
|
+
export declare const QRScanner: {
|
|
18
|
+
(): QRScanner;
|
|
19
|
+
/** Whether this host registered a "qrScanner" view. */
|
|
20
|
+
readonly isSupported: boolean;
|
|
21
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface Service {
|
|
2
|
+
/** Invoke a method on the service (`battery.call("level")`). Arguments and the result are
|
|
3
|
+
* JSON-serialized; rejects when the host has no such service or the method reports an
|
|
4
|
+
* error. The host session opens lazily on the first call. */
|
|
5
|
+
call(method: string, ...args: any[]): Promise<any>;
|
|
6
|
+
/** Subscribe to an event the service emits while a session is open
|
|
7
|
+
* (`battery.on("change", data => …)`). Payloads are JSON-decoded. */
|
|
8
|
+
on(event: string, callback: (data?: any) => void): this;
|
|
9
|
+
/** Remove a previously added listener. */
|
|
10
|
+
off(event: string, callback: (data?: any) => void): this;
|
|
11
|
+
/** Close the host session (stops whatever the service was doing). Listeners stay
|
|
12
|
+
* registered — a later `call()` opens a fresh session that delivers to them again. */
|
|
13
|
+
close(): void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A host-registered headless service — the UI-less sibling of `NativeView`. Use it for
|
|
17
|
+
* services without a typed wrapper: native code registered in your app shell
|
|
18
|
+
* (`engine.registerService("app.battery") { … }`) or a third-party plugin's channel.
|
|
19
|
+
* **Host-optional** — gate on `Service.isSupported` (the web editor registers none of them).
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* if (Service.isSupported("app.battery")) {
|
|
23
|
+
* const battery = Service("app.battery")
|
|
24
|
+
* battery.on("change", data => { level.text = data.level + "%" })
|
|
25
|
+
* const { level } = await battery.call("level")
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare const Service: {
|
|
30
|
+
(name: string, params?: any): Service;
|
|
31
|
+
/** Whether this host registered a service under `name`. */
|
|
32
|
+
isSupported(name: string): boolean;
|
|
33
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export type AppState = "active" | "background";
|
|
2
|
+
/** `"landscape"` — either landscape direction (sensor landscape), `"portrait"` — upright only,
|
|
3
|
+
* `"auto"` — released: the device's own rotation rules apply. */
|
|
4
|
+
export type OrientationLock = "auto" | "portrait" | "landscape";
|
|
5
|
+
type AppEventMap = {
|
|
6
|
+
/** The app left the foreground (home button, tab hidden, another app on top). Delivered before
|
|
7
|
+
* the host halts the frame loop — the last chance to persist state / pause work. */
|
|
8
|
+
pause: () => void;
|
|
9
|
+
/** The app returned to the foreground; frames are running again. */
|
|
10
|
+
resume: () => void;
|
|
11
|
+
/** A link arrived while the app was running (warm deep link). `app.launchUrl` is already
|
|
12
|
+
* updated to the same value when this fires. */
|
|
13
|
+
url: (url: string) => void;
|
|
14
|
+
/** The on-screen keyboard changed. `height` mirrors `app.keyboardHeight` (the raw overlap, see
|
|
15
|
+
* there); `duration` is the platform's keyboard animation duration in ms (0 where none) — pass
|
|
16
|
+
* it to `animateTo` to move a composer in sync with the keyboard. */
|
|
17
|
+
keyboard: (height: number, duration: number) => void;
|
|
18
|
+
};
|
|
19
|
+
export declare const app: {
|
|
20
|
+
/** Current lifecycle state. `"background"` while the app is not the foreground app / the tab is
|
|
21
|
+
* hidden. `"active"` on hosts that don't track it. */
|
|
22
|
+
readonly state: AppState;
|
|
23
|
+
/** The URL the app was (most recently) opened with — the deep link — or `null` for a plain
|
|
24
|
+
* launch. Warm links update it and fire the `"url"` event. */
|
|
25
|
+
readonly launchUrl: string | null;
|
|
26
|
+
/** On-screen keyboard height in logical px currently overlapping the app viewport, `0` when
|
|
27
|
+
* hidden. This is the RAW overlap, independent of the focused input's `keyboardShrink` policy —
|
|
28
|
+
* with the default shrink the layout already avoids the keyboard; the main consumer is overlay
|
|
29
|
+
* mode (`keyboardShrink: false`), e.g. a chat composer's `pb`. `0` on hosts without an
|
|
30
|
+
* on-screen keyboard. */
|
|
31
|
+
readonly keyboardHeight: number;
|
|
32
|
+
/** Lock the screen orientation — `"landscape"` for a horizontal game (the device rotates to
|
|
33
|
+
* landscape right away and stays there whichever way it is held), `"portrait"` for upright
|
|
34
|
+
* only, `"auto"` to release. Call it once at startup; the lock is per app run (it resets
|
|
35
|
+
* when the app quits or restarts), so there is nothing to undo. The rotation arrives as an
|
|
36
|
+
* ordinary resize — layouts reflow, a scene's viewport follows. Silent no-op on hosts
|
|
37
|
+
* without a rotatable screen (desktop, headless, web). */
|
|
38
|
+
setOrientation(mode: OrientationLock): void;
|
|
39
|
+
/** Re-run this app's bundle in a fresh world — the platform's `location.reload()`. Pass `url`
|
|
40
|
+
* to reboot with different launch arguments (the new run reads them via `app.launchUrl`),
|
|
41
|
+
* `null` to reboot with a cleared one, or omit it to replay the current one. No-op on hosts
|
|
42
|
+
* without world control (headless). */
|
|
43
|
+
restart(url?: string | null): void;
|
|
44
|
+
/** Leave this app. Inside the LeCodes viewer that returns to the launcher (the LeCodes home
|
|
45
|
+
* screen); a standalone-built app leaves to the platform instead — Android backgrounds it,
|
|
46
|
+
* iOS ignores the call (the platform forbids programmatic exit). */
|
|
47
|
+
quit(): void;
|
|
48
|
+
/** Global back-press fallback (Android back button/gesture — iOS has no system back). Fires
|
|
49
|
+
* only when nothing else consumed the press: no open widget/modal claimed it, the current
|
|
50
|
+
* screen has no `onBackPressed`, every pager is at its tab root and the router is at its
|
|
51
|
+
* stack root. The place for app-wide policy — e.g. double-press-to-quit:
|
|
52
|
+
*
|
|
53
|
+
* ```ts
|
|
54
|
+
* let armedAt = 0
|
|
55
|
+
* app.onBackPressed(() => {
|
|
56
|
+
* if (Date.now() - armedAt < 2000) { app.quit(); return }
|
|
57
|
+
* armedAt = Date.now()
|
|
58
|
+
* toast("Press back again to exit")
|
|
59
|
+
* })
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* Replaces the previous handler; pass `null` to remove. */
|
|
63
|
+
onBackPressed(callback: (() => void) | null): void;
|
|
64
|
+
addEventListener<E extends keyof AppEventMap>(event: E, callback: AppEventMap[E]): void;
|
|
65
|
+
removeEventListener<E extends keyof AppEventMap>(event: E, callback: AppEventMap[E]): void;
|
|
66
|
+
};
|
|
67
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type AppEventCallback = (data?: string) => void;
|
|
2
|
+
export declare const appEventsOn: (event: string, cb: AppEventCallback) => void;
|
|
3
|
+
export declare const appEventsOff: (event: string, cb: AppEventCallback) => void;
|
|
4
|
+
type KeyboardCallback = (height: number, duration: number) => void;
|
|
5
|
+
export declare const keyboardEventsOn: (cb: KeyboardCallback) => void;
|
|
6
|
+
export declare const keyboardEventsOff: (cb: KeyboardCallback) => void;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const clipboard: {
|
|
2
|
+
/** Put `text` on the system clipboard. Silent no-op on hosts without clipboard access. */
|
|
3
|
+
write(text: string): void;
|
|
4
|
+
/** Read text from the system clipboard. Rejects when the platform has no clipboard access, the
|
|
5
|
+
* user denied it, or there is nothing readable. */
|
|
6
|
+
read(): Promise<string>;
|
|
7
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export type Locale = "en" | "ru";
|
|
2
|
+
export type DateInput = Date | number | string | DateValue;
|
|
3
|
+
export type Unit = "ms" | "second" | "minute" | "hour" | "day" | "week" | "month" | "year";
|
|
4
|
+
/**
|
|
5
|
+
* An immutable moment in time — the value returned by [`date()`]. Wraps a single epoch-millisecond
|
|
6
|
+
* scalar (`t`); every method returns a new `DateValue` or a plain scalar, never mutating. Construct
|
|
7
|
+
* it with `date(...)`, not `new`.
|
|
8
|
+
*/
|
|
9
|
+
export declare class DateValue {
|
|
10
|
+
/** Epoch milliseconds — the one canonical scalar. Prefer `valueOf()`; this is public so `date(a)`
|
|
11
|
+
* can read it back cheaply and so tooling can treat it as the value's single component. */
|
|
12
|
+
readonly t: number;
|
|
13
|
+
constructor(ms: number);
|
|
14
|
+
/**
|
|
15
|
+
* Format against a `day.js`-style token pattern (default `"D MMMM YYYY"`). Locale defaults to the
|
|
16
|
+
* current device language.
|
|
17
|
+
*
|
|
18
|
+
* Tokens: `YYYY`/`YY` year · `MMMM`/`MMM`/`MM`/`M` month · `DD`/`D` day · `dddd`/`ddd` weekday ·
|
|
19
|
+
* `HH`/`H` 24-hour · `hh`/`h` 12-hour · `mm`/`m` minute · `ss`/`s` second · `A`/`a` AM/PM.
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* date().format() // "10 July 2026" / "10 июля 2026"
|
|
23
|
+
* date(ts).format("DD.MM.YYYY HH:mm") // "10.07.2026 14:05"
|
|
24
|
+
* date(ts).format("MMMM YYYY", "ru") // "Июль 2026" (nominative — no day token)
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
format(pattern?: string, locale?: Locale): string;
|
|
28
|
+
/**
|
|
29
|
+
* Human relative time vs `now` (default: the current time) — "5 minutes ago", "in 2 days",
|
|
30
|
+
* "5 минут назад", "через 2 дня". Reads as "just now" under ~45 seconds; handles Russian number
|
|
31
|
+
* agreement (`1 минуту` / `2 минуты` / `5 минут`). Locale defaults to the device language.
|
|
32
|
+
*/
|
|
33
|
+
timeAgo(locale?: Locale, now?: DateInput): string;
|
|
34
|
+
/** Add `n` of a unit, returning a new value. Linear units (`ms`…`week`) are scalar ms math;
|
|
35
|
+
* `month`/`year` are calendar-aware (clamp on short months, like day.js). */
|
|
36
|
+
add(n: number, unit: Unit): DateValue;
|
|
37
|
+
/** Subtract `n` of a unit. Equivalent to `add(-n, unit)`. */
|
|
38
|
+
subtract(n: number, unit: Unit): DateValue;
|
|
39
|
+
/** Snap down to the start of a unit (local time): start of day/hour/month/year, etc. */
|
|
40
|
+
startOf(unit: Unit): DateValue;
|
|
41
|
+
/** Snap up to the end of a unit (local time): the last millisecond of the day/hour/month/… */
|
|
42
|
+
endOf(unit: Unit): DateValue;
|
|
43
|
+
/** Epoch milliseconds. Enables `+date(x)`, `date(a) < date(b)`, `date(a) - date(b)` via coercion. */
|
|
44
|
+
valueOf(): number;
|
|
45
|
+
/** Whole seconds since the epoch (Unix time). */
|
|
46
|
+
unix(): number;
|
|
47
|
+
/** Signed difference to `other`, in whole `unit`s (default `ms`), truncated toward zero. */
|
|
48
|
+
diff(other: DateInput, unit?: Unit): number;
|
|
49
|
+
isBefore(other: DateInput): boolean;
|
|
50
|
+
isAfter(other: DateInput): boolean;
|
|
51
|
+
isSame(other: DateInput): boolean;
|
|
52
|
+
year(): number;
|
|
53
|
+
/** 0-based month (0 = January), matching `Date.getMonth`. */
|
|
54
|
+
month(): number;
|
|
55
|
+
/** Day of the month, 1–31. */
|
|
56
|
+
day(): number;
|
|
57
|
+
/** Day of the week, 0 (Sunday)–6 (Saturday), matching `Date.getDay`. */
|
|
58
|
+
weekday(): number;
|
|
59
|
+
hour(): number;
|
|
60
|
+
minute(): number;
|
|
61
|
+
second(): number;
|
|
62
|
+
/** A native `Date` snapshot of this value. */
|
|
63
|
+
toDate(): Date;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Create a `DateValue` — a locale-aware, immutable moment, dayjs-style. Accepts a `Date`, a
|
|
67
|
+
* millisecond timestamp (`Date.now()`), a parseable string, or another `DateValue`; with no argument
|
|
68
|
+
* it's the current time. Chain arithmetic and finish with `format` / `timeAgo`, both of which
|
|
69
|
+
* understand **English** and **Russian** and default to the current device language
|
|
70
|
+
* ([`device.language`](../runtime/device.ts)).
|
|
71
|
+
*
|
|
72
|
+
* ```ts
|
|
73
|
+
* date().format("dddd, D MMMM") // "Friday, 10 July" / "пятница, 10 июля"
|
|
74
|
+
* date(ts).timeAgo() // "5 minutes ago" / "5 минут назад"
|
|
75
|
+
* date().add(3, "day").startOf("day").format("D MMMM")
|
|
76
|
+
* date(a).diff(b, "hour") // signed whole hours
|
|
77
|
+
* date(a).isBefore(b) // boolean
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare const date: (value?: DateInput) => DateValue;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { Quat } from "../math/quat";
|
|
2
|
+
import { Vec3 } from "../math/vec";
|
|
3
|
+
type ResizeCallback = (width: number, height: number) => void;
|
|
4
|
+
type HdrChangeCallback = (headroom: number) => void;
|
|
5
|
+
type DeviceEventMap = {
|
|
6
|
+
resize: ResizeCallback;
|
|
7
|
+
/** Connectivity came back (best-effort, navigator.onLine semantics). */
|
|
8
|
+
online: () => void;
|
|
9
|
+
/** Connectivity was lost. */
|
|
10
|
+
offline: () => void;
|
|
11
|
+
/** The headroom the 3D engine renders to moved (`device.hdr.headroom`): the display ramped up to
|
|
12
|
+
* its peak after launch, brightness changed, the window went to another screen. */
|
|
13
|
+
hdrchange: HdrChangeCallback;
|
|
14
|
+
};
|
|
15
|
+
/** Semantic haptic styles for `device.vibrate`. Impact styles (`light`/`medium`/`heavy`/`soft`/
|
|
16
|
+
* `rigid`) are a physical "tap" of varying weight; notification styles (`success`/`warning`/`error`)
|
|
17
|
+
* cue an outcome; `selection` is a light tick for a value change. Chosen to map 1:1 onto iOS
|
|
18
|
+
* `UIFeedbackGenerator` and, on Android, `HapticFeedbackConstants` / `VibrationEffect` — so the same
|
|
19
|
+
* call feels native everywhere, rather than a duration that only web/Android can honor. */
|
|
20
|
+
export type HapticStyle = "light" | "medium" | "heavy" | "soft" | "rigid" | "success" | "warning" | "error" | "selection";
|
|
21
|
+
/** Options for `device.motion.start`. */
|
|
22
|
+
export interface MotionOptions {
|
|
23
|
+
/** Sensor update interval in seconds (default 1/60). The sensor fuses at ≥ this rate in the
|
|
24
|
+
* background; you poll the freshest sample each frame, so this is a floor, not a sync. */
|
|
25
|
+
interval?: number;
|
|
26
|
+
/** Frame the readables are delivered in. "world" (default): engine Y-up, screen-oriented — drops
|
|
27
|
+
* straight into `camera.quaternion` / any node. "device": the raw sensor frame, no conversion. */
|
|
28
|
+
frame?: "world" | "device";
|
|
29
|
+
}
|
|
30
|
+
export declare const device: {
|
|
31
|
+
/** Which INPUT MODEL the app is running under — the thing to branch on when a build needs
|
|
32
|
+
* mouse-look instead of on-screen sticks. It is not the OS name: a Mac reports `"desktop"`,
|
|
33
|
+
* like Windows and Linux do (the OS/version detail is host-side, not here). */
|
|
34
|
+
readonly platform: "web" | "android" | "ios" | "desktop" | string;
|
|
35
|
+
readonly language: string;
|
|
36
|
+
/** Display device-pixel ratio (physical px per logical/CSS px): 1 on standard displays, 2–3 on
|
|
37
|
+
* retina / iOS. Bake a Canvas at this ratio for crisp output without hardcoding, e.g.
|
|
38
|
+
* `new Canvas(w, h, { pixelRatio: device.pixelRatio })`. NOTE: the web 2D/GL surface currently
|
|
39
|
+
* renders at logical resolution, so on web this only helps UI canvases / is forward-looking for
|
|
40
|
+
* 2D; on iOS (physical surface) it makes 2D canvases crisp. Falls back to 1 if the host omits it. */
|
|
41
|
+
readonly pixelRatio: number;
|
|
42
|
+
/** Current display width in logical px — the same value the "resize" event delivers, but readable at
|
|
43
|
+
* any time (not only inside the listener). 0 until the host has reported a size. */
|
|
44
|
+
readonly width: number;
|
|
45
|
+
/** Current display height in logical px — the same value the "resize" event delivers, readable at any
|
|
46
|
+
* time. 0 until the host has reported a size. */
|
|
47
|
+
readonly height: number;
|
|
48
|
+
/** Opt into the precise-touch system where the platform supports it. OFF by default. When on, fast
|
|
49
|
+
* strokes are sampled at the touch digitizer's full rate (iOS coalesced touches, ≈120–240 Hz) instead
|
|
50
|
+
* of once per display frame (~60 Hz), so a pointer-heavy app (drawing, handwriting, dragging) gets more
|
|
51
|
+
* points and smoother lines. Leave it off for tap/button UIs. No-op on hosts without a coalesced-input
|
|
52
|
+
* concept (web already coalesces pointermove; headless). */
|
|
53
|
+
setPreciseTouch(enabled: boolean): void;
|
|
54
|
+
/** Fire a one-shot haptic of the given semantic `style` (default `"medium"`) — a physical tap on
|
|
55
|
+
* supported hardware (iOS Taptic Engine, Android vibrator). Chosen by meaning, not duration, so it
|
|
56
|
+
* feels native on each platform; see {@link HapticStyle}. Host-gated: a silent no-op where there's
|
|
57
|
+
* no haptic hardware (iPad, older iPhones, web, headless). */
|
|
58
|
+
vibrate(style?: HapticStyle): void;
|
|
59
|
+
/** Device-orientation sensor (gyro + accelerometer, fused) for tilt/steering and magic-window /
|
|
60
|
+
* 360° panoramas. Poll `attitude` / `gravity` inside setLoop; they return the freshest fused
|
|
61
|
+
* sample, so the sensor rate need not match your frame rate. Host-gated: a no-op with no sensor. */
|
|
62
|
+
motion: {
|
|
63
|
+
/** Whether this device has the motion sensors at all (no gyro → false; iPad/older, web, headless). */
|
|
64
|
+
readonly available: boolean;
|
|
65
|
+
/** Whether updates are currently running (start succeeded and stop hasn't been called). */
|
|
66
|
+
readonly enabled: boolean;
|
|
67
|
+
/** Begin sensor updates. Resolves to whether it actually started (false = no sensor / denied).
|
|
68
|
+
* Async so a web host can await its permission prompt; native resolves immediately. */
|
|
69
|
+
start(options?: MotionOptions): Promise<boolean>;
|
|
70
|
+
/** Stop sensor updates and release the sensor (battery). */
|
|
71
|
+
stop(): void;
|
|
72
|
+
/** Capture the current heading as "forward" — a yaw-only recenter (pitch/roll stay gravity-
|
|
73
|
+
* referenced, so the horizon stays level). No-op in the "device" frame. */
|
|
74
|
+
recenter(): void;
|
|
75
|
+
/** The device's current orientation as a `Quat`. In the "world" frame (default) it's engine Y-up
|
|
76
|
+
* and screen-oriented, so `camera.quaternion = device.motion.attitude` is a complete magic-window
|
|
77
|
+
* / panorama camera. `Quat.identity` until the first sample arrives / when not running. */
|
|
78
|
+
readonly attitude: Quat;
|
|
79
|
+
/** Gravity direction for tilt controls. In the "world" frame it's SCREEN space (x → right, y →
|
|
80
|
+
* down, matching clientX/clientY), orientation-aware — a 2D game reads `gravity.x / gravity.y`.
|
|
81
|
+
* `(0,0,0)` when not running. */
|
|
82
|
+
readonly gravity: Vec3;
|
|
83
|
+
};
|
|
84
|
+
/** The display's extended dynamic range — HDR. On a screen with headroom above SDR white (Apple's
|
|
85
|
+
* XDR panels; the macOS host today) the 3D surface is float and the engine renders past 1.0:
|
|
86
|
+
* 1.0 is the white of the UI and of a diffuse white surface, and the sun, emissives and speculars
|
|
87
|
+
* climb up to `headroom` times that. Everywhere else it is SDR: `available` false, `headroom` 1,
|
|
88
|
+
* the look setters remembered but invisible.
|
|
89
|
+
*
|
|
90
|
+
* Branch content on `available`, not on `headroom` — the live value ramps up from 1 over the
|
|
91
|
+
* first seconds after launch and follows the brightness keys. Particle `emissive` is the thing
|
|
92
|
+
* to raise: it is in post-exposure units (1 = white on screen) and everything above that clips on
|
|
93
|
+
* SDR, so an HDR display is the only place a fireball peaking at 8 reads as one. */
|
|
94
|
+
hdr: {
|
|
95
|
+
/** Whether the surface can show anything above SDR white at all (`maxHeadroom > 1`). */
|
|
96
|
+
readonly available: boolean;
|
|
97
|
+
/** The peak the display can reach, as a multiple of SDR white (a 1600-nit XDR panel reports up
|
|
98
|
+
* to 16). Constant for the surface; 1 on SDR. */
|
|
99
|
+
readonly maxHeadroom: number;
|
|
100
|
+
/** The headroom the engine renders to right now — the screen's current peak as a multiple of SDR
|
|
101
|
+
* white, quantised to half-stops. Moves with brightness and the screen under the window
|
|
102
|
+
* (`hdrchange` event); never below 1. */
|
|
103
|
+
readonly headroom: number;
|
|
104
|
+
/** How much of the picture reaches for the headroom, 0..1 (default 0.35). 0 touches only what
|
|
105
|
+
* SDR clipped — faithful to the SDR grade, but a mostly-mid-tone frame then looks flat next to
|
|
106
|
+
* the one bright spot; 1 lifts nearly everything above black toward the peak. A sunlit exterior
|
|
107
|
+
* takes 1, a dim interior wants less. A host may pin it (`LECODES_HDR_STRENGTH`). */
|
|
108
|
+
strength: number;
|
|
109
|
+
/** Where white lands, as a multiple of SDR white, 1..8 (default 1) — the "HDR brightness" of a
|
|
110
|
+
* console game's calibration screen, where paper white sits at ~200 nits against SDR's ~100.
|
|
111
|
+
* It scales the WHOLE picture: at 1 a white wall is as bright as the UI's white, at 2 it is
|
|
112
|
+
* twice that, and highlights still climb above it (the engine keeps `headroom / paperWhite` for
|
|
113
|
+
* them, clamped at the peak). `strength` decides how much of the picture reaches for the
|
|
114
|
+
* peak; this decides where the picture starts. 1.5–2 is the console norm; a game that wants to
|
|
115
|
+
* read as "HDR on" rather than "SDR with a brighter sun" wants this over `strength`. A host may
|
|
116
|
+
* pin it (`LECODES_HDR_PAPER_WHITE`). */
|
|
117
|
+
paperWhite: number;
|
|
118
|
+
};
|
|
119
|
+
/** Current connectivity — best-effort navigator.onLine semantics: `false` only when the platform
|
|
120
|
+
* is sure there's no network. `true` on hosts that don't track it. Change events: `"online"` /
|
|
121
|
+
* `"offline"`. */
|
|
122
|
+
readonly online: boolean;
|
|
123
|
+
addEventListener<E extends keyof DeviceEventMap>(channel: E, callback: DeviceEventMap[E]): void;
|
|
124
|
+
removeEventListener<E extends keyof DeviceEventMap>(channel: E, callback: DeviceEventMap[E]): void;
|
|
125
|
+
};
|
|
126
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type FetchOptions = {
|
|
2
|
+
body?: any;
|
|
3
|
+
method?: string;
|
|
4
|
+
headers?: Record<string, string>;
|
|
5
|
+
useOnce?: boolean;
|
|
6
|
+
onProgress?: (progress: {
|
|
7
|
+
loaded: number;
|
|
8
|
+
total?: number;
|
|
9
|
+
}) => void;
|
|
10
|
+
};
|
|
11
|
+
export interface FetchResponse {
|
|
12
|
+
readonly status: number;
|
|
13
|
+
json<T = any>(): T;
|
|
14
|
+
text(): string;
|
|
15
|
+
dispose(): void;
|
|
16
|
+
}
|
|
17
|
+
export declare const fetch: (url: string, options?: FetchOptions) => Promise<FetchResponse>;
|
|
18
|
+
export declare const fetchLocal: (path: string) => FetchResponse;
|
|
19
|
+
/** A handle to a picked / fetched file (see openFilePicker). */
|
|
20
|
+
export declare class File {
|
|
21
|
+
readonly name: string;
|
|
22
|
+
readonly size: number;
|
|
23
|
+
constructor(systemId: number, name: string, size: number);
|
|
24
|
+
}
|
|
25
|
+
type FormDataValue = string | number | boolean | File | FetchResponse;
|
|
26
|
+
export declare class FormData {
|
|
27
|
+
private _entries;
|
|
28
|
+
append(name: string, value: FormDataValue, filename?: string): void;
|
|
29
|
+
delete(name: string): void;
|
|
30
|
+
}
|
|
31
|
+
export {};
|