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,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type layer: projects a `defineDb({ User: model({...}), … })` literal into marcidb's generic query
|
|
3
|
+
* types (./marci/query.ts — vendored from marcidb, see scripts/sync-marcidb.ts): each model becomes the
|
|
4
|
+
* `ModelTypes` bag marcidb's codegen would have emitted, and `db.<model>` is marcidb's own `Query<T>`.
|
|
5
|
+
* Everything here is type-only; the runtime lives in ./defineDb.ts.
|
|
6
|
+
*
|
|
7
|
+
* Naming: `S` = the schema record (model name → Model), `N` = a model name, `F` = a fields record.
|
|
8
|
+
*/
|
|
9
|
+
import type { Field, FieldMeta } from "./fields";
|
|
10
|
+
import type { CompareNumValue, CompareRefListValue, CompareRefValue, CompareStrValue, CompareValue, CustomSearchValue, FullTextSearch, JsonCondition, JsonPathWhere, Op, PrimitiveListUpdate, Query as MarciQuery, RefListUpdate, RefListUpdateOrdered, RefUpdate, RefUpdateStruct, Rows, Sub, UpdateNumValue, VectorSearch, WhereValue } from "./marci/query";
|
|
11
|
+
export type Fields = Record<string, Field<any, any>>;
|
|
12
|
+
export type Model<F extends Fields = Fields> = {
|
|
13
|
+
readonly fields: F;
|
|
14
|
+
readonly __model: true;
|
|
15
|
+
};
|
|
16
|
+
export type Schema = Record<string, Model<any>>;
|
|
17
|
+
export type FieldsOf<M> = M extends Model<infer F> ? F : never;
|
|
18
|
+
type TsOf<Fld> = Fld extends Field<infer T, any> ? T : never;
|
|
19
|
+
type StructFieldsOf<Fld> = TsOf<Fld> extends Fields ? TsOf<Fld> : never;
|
|
20
|
+
type MetaOf<Fld> = Fld extends Field<any, infer M> ? M : never;
|
|
21
|
+
type ModelName<S, Fld> = MetaOf<Fld>["model"] & keyof S & string;
|
|
22
|
+
type Nullable<M extends FieldMeta, T> = M["optional"] extends true ? T | null : T;
|
|
23
|
+
type Arr<M extends FieldMeta, T> = M["array"] extends true ? T[] : T;
|
|
24
|
+
type IsNum<M extends FieldMeta> = M["scalar"] extends "int" | "float" | "date" ? true : false;
|
|
25
|
+
/** Explicit `.id()` fields, or a field literally named `id`. */
|
|
26
|
+
type IdKeys<F extends Fields> = {
|
|
27
|
+
[K in keyof F]: MetaOf<F[K]>["isId"] extends true ? K : K extends "id" ? K : never;
|
|
28
|
+
}[keyof F];
|
|
29
|
+
type IdValue<S, Fld> = MetaOf<Fld>["kind"] extends "one" ? Id<S, ModelName<S, Fld>> : TsOf<Fld>;
|
|
30
|
+
/** The id object of a model: `{ id: number }` implicitly, or the declared key fields. */
|
|
31
|
+
export type Id<S, N extends keyof S> = [
|
|
32
|
+
IdKeys<FieldsOf<S[N]>>
|
|
33
|
+
] extends [never] ? {
|
|
34
|
+
id: number;
|
|
35
|
+
} : {
|
|
36
|
+
[K in IdKeys<FieldsOf<S[N]>>]: IdValue<S, FieldsOf<S[N]>[K]>;
|
|
37
|
+
};
|
|
38
|
+
/** What `update`/`delete` accept: the id object, or the bare value when the key is a single scalar. */
|
|
39
|
+
export type IdArg<S, N extends keyof S> = Id<S, N> | (Id<S, N> extends {
|
|
40
|
+
id: infer V;
|
|
41
|
+
} ? V : never);
|
|
42
|
+
type FieldRow<S, Fld, M extends FieldMeta = MetaOf<Fld>> = M["kind"] extends "one" ? Nullable<M, Row<S, ModelName<S, Fld>>> : M["kind"] extends "many" | "list" ? Row<S, ModelName<S, Fld>>[] : M["kind"] extends "struct" ? Nullable<M, StructRow<S, StructFieldsOf<Fld>>> : Nullable<M, Arr<M, TsOf<Fld>>>;
|
|
43
|
+
/** Full row type of a model (relations included) — the `TModel` marcidb's `GetResult` selects from. */
|
|
44
|
+
export type Row<S, N extends keyof S> = Id<S, N> & {
|
|
45
|
+
[K in Exclude<keyof FieldsOf<S[N]>, IdKeys<FieldsOf<S[N]>>>]: FieldRow<S, FieldsOf<S[N]>[K]>;
|
|
46
|
+
};
|
|
47
|
+
type StructRow<S, F extends Fields> = {
|
|
48
|
+
[K in keyof F]: FieldRow<S, F[K]>;
|
|
49
|
+
};
|
|
50
|
+
type ScalarKeys<F extends Fields> = {
|
|
51
|
+
[K in keyof F]: MetaOf<F[K]>["kind"] extends "scalar" | "enum" | "json" ? K : never;
|
|
52
|
+
}[keyof F];
|
|
53
|
+
type NumKeys<F extends Fields> = {
|
|
54
|
+
[K in keyof F]: IsNum<MetaOf<F[K]>> extends true ? (MetaOf<F[K]>["array"] extends true ? never : K) : never;
|
|
55
|
+
}[keyof F];
|
|
56
|
+
/** What an empty select returns: id + every scalar field. */
|
|
57
|
+
export type Scalars<S, N extends keyof S> = Pick<Row<S, N>, (ScalarKeys<FieldsOf<S[N]>> | keyof Id<S, N>) & keyof Row<S, N>>;
|
|
58
|
+
/** The same, as the `{ field: true }` select shape a query starts with. */
|
|
59
|
+
export type ScalarSelect<S, N extends keyof S> = {
|
|
60
|
+
[K in (ScalarKeys<FieldsOf<S[N]>> | keyof Id<S, N>) & keyof Row<S, N>]: true;
|
|
61
|
+
};
|
|
62
|
+
type FieldInsert<S, Fld, M extends FieldMeta = MetaOf<Fld>> = M["kind"] extends "one" ? Nullable<M, Id<S, ModelName<S, Fld>>> : M["kind"] extends "many" | "list" ? Id<S, ModelName<S, Fld>>[] : M["kind"] extends "struct" ? Nullable<M, StructInsert<S, StructFieldsOf<Fld>>> : Nullable<M, Arr<M, TsOf<Fld>>>;
|
|
63
|
+
type RequiredKeys<F extends Fields> = {
|
|
64
|
+
[K in keyof F]: K extends IdKeys<F> ? never : MetaOf<F[K]>["optional"] extends true ? never : MetaOf<F[K]>["hasDefault"] extends true ? never : MetaOf<F[K]>["kind"] extends "many" | "list" ? never : K;
|
|
65
|
+
}[keyof F];
|
|
66
|
+
type Simplify<T> = {
|
|
67
|
+
[K in keyof T]: T[K];
|
|
68
|
+
} & {};
|
|
69
|
+
type InsertOf<S, F extends Fields> = Simplify<{
|
|
70
|
+
[K in RequiredKeys<F>]: FieldInsert<S, F[K]>;
|
|
71
|
+
} & {
|
|
72
|
+
[K in Exclude<keyof F, RequiredKeys<F>>]?: FieldInsert<S, F[K]>;
|
|
73
|
+
}>;
|
|
74
|
+
export type Insert<S, N extends keyof S> = InsertOf<S, FieldsOf<S[N]>>;
|
|
75
|
+
type StructInsert<S, F extends Fields> = InsertOf<S, F>;
|
|
76
|
+
type FieldUpdate<S, Fld, M extends FieldMeta = MetaOf<Fld>> = M["kind"] extends "one" ? Nullable<M, RefUpdate<Id<S, ModelName<S, Fld>>>> : M["kind"] extends "many" ? RefListUpdate<Id<S, ModelName<S, Fld>>> : M["kind"] extends "list" ? RefListUpdateOrdered<Id<S, ModelName<S, Fld>>> : M["kind"] extends "struct" ? RefUpdateStruct<StructInsert<S, StructFieldsOf<Fld>>, UpdateOf<S, StructFieldsOf<Fld>>> | null : M["array"] extends true ? TsOf<Fld>[] | PrimitiveListUpdate<TsOf<Fld>> : Nullable<M, TsOf<Fld> | (IsNum<M> extends true ? UpdateNumValue : never)>;
|
|
77
|
+
type UpdateOf<S, F extends Fields> = {
|
|
78
|
+
[K in Exclude<keyof F, IdKeys<F>>]?: FieldUpdate<S, F[K]>;
|
|
79
|
+
};
|
|
80
|
+
export type Update<S, N extends keyof S> = UpdateOf<S, FieldsOf<S[N]>>;
|
|
81
|
+
type FieldSelect<S, Fld, M extends FieldMeta = MetaOf<Fld>> = M["kind"] extends "one" ? Select<S, ModelName<S, Fld>> | boolean | Sub<ModelName<S, Fld>> : M["kind"] extends "many" | "list" ? QueryObject<S, ModelName<S, Fld>> | AggregateQuery<S, ModelName<S, Fld>> | boolean | Sub<ModelName<S, Fld>> : M["kind"] extends "struct" ? StructSelect<S, StructFieldsOf<Fld>> | boolean : boolean;
|
|
82
|
+
export type Select<S, N extends keyof S> = {
|
|
83
|
+
[K in keyof Row<S, N>]?: K extends keyof FieldsOf<S[N]> ? FieldSelect<S, FieldsOf<S[N]>[K]> : boolean;
|
|
84
|
+
};
|
|
85
|
+
type StructSelect<S, F extends Fields> = {
|
|
86
|
+
[K in keyof F]?: FieldSelect<S, F[K]>;
|
|
87
|
+
};
|
|
88
|
+
type ScalarWhere<T, M extends FieldMeta> = Nullable<M, CompareValue<T>> | (IsNum<M> extends true ? CompareNumValue<T> : M["scalar"] extends "string" ? CompareStrValue<T> : never);
|
|
89
|
+
type FieldWhere<S, Fld, M extends FieldMeta = MetaOf<Fld>> = M["kind"] extends "one" ? CompareRefValue<Where<S, ModelName<S, Fld>> | null> : M["kind"] extends "many" | "list" ? CompareRefListValue<Where<S, ModelName<S, Fld>>> : M["kind"] extends "struct" ? CompareRefValue<WhereValue<StructWhereFields<S, StructFieldsOf<Fld>>> | null> : M["kind"] extends "json" ? JsonPathWhere | JsonCondition : M["array"] extends true ? CompareValue<TsOf<Fld>> : ScalarWhere<TsOf<Fld>, M> | CustomSearchValue<FullTextSearch> | CustomSearchValue<VectorSearch>;
|
|
90
|
+
type WhereFieldsOf<S, F extends Fields> = {
|
|
91
|
+
[K in keyof F]?: FieldWhere<S, F[K]>;
|
|
92
|
+
};
|
|
93
|
+
type IdWhere<S, N extends keyof S> = {
|
|
94
|
+
[K in keyof Id<S, N> as K extends keyof FieldsOf<S[N]> ? never : K]?: CompareValue<Id<S, N>[K]> | CompareNumValue<number>;
|
|
95
|
+
};
|
|
96
|
+
export type Where<S, N extends keyof S> = WhereValue<WhereFieldsOf<S, FieldsOf<S[N]>> & IdWhere<S, N>>;
|
|
97
|
+
type StructWhereFields<S, F extends Fields> = WhereFieldsOf<S, F>;
|
|
98
|
+
export type Order<S, N extends keyof S> = {
|
|
99
|
+
[K in (ScalarKeys<FieldsOf<S[N]>> | keyof Id<S, N>) & keyof Row<S, N>]?: "asc" | "desc";
|
|
100
|
+
};
|
|
101
|
+
/** The query object — marcidb's wire form: a select shape plus the `$`-clauses. */
|
|
102
|
+
export type QueryObject<S, N extends keyof S> = Select<S, N> & {
|
|
103
|
+
$where?: Where<S, N>;
|
|
104
|
+
$order?: Order<S, N>;
|
|
105
|
+
$limit?: number;
|
|
106
|
+
$skip?: number;
|
|
107
|
+
$cursor?: Id<S, N>;
|
|
108
|
+
};
|
|
109
|
+
export type AggregateQuery<S, N extends keyof S> = {
|
|
110
|
+
$where?: Where<S, N>;
|
|
111
|
+
$count?: true;
|
|
112
|
+
$sum?: NumKeys<FieldsOf<S[N]>> & string;
|
|
113
|
+
$avg?: NumKeys<FieldsOf<S[N]>> & string;
|
|
114
|
+
$min?: (ScalarKeys<FieldsOf<S[N]>> | keyof Id<S, N>) & string;
|
|
115
|
+
$max?: (ScalarKeys<FieldsOf<S[N]>> | keyof Id<S, N>) & string;
|
|
116
|
+
};
|
|
117
|
+
/** The per-model type bag marcidb's generic `Query<T>` is parametrised by (what its codegen emits as `UserTypes`). */
|
|
118
|
+
export type Types<S, N extends keyof S> = {
|
|
119
|
+
name: N & string;
|
|
120
|
+
model: Row<S, N>;
|
|
121
|
+
id: Id<S, N>;
|
|
122
|
+
scalars: ScalarSelect<S, N>;
|
|
123
|
+
select: Select<S, N>;
|
|
124
|
+
query: QueryObject<S, N>;
|
|
125
|
+
where: Where<S, N>;
|
|
126
|
+
order: Order<S, N>;
|
|
127
|
+
insert: Insert<S, N>;
|
|
128
|
+
update: Update<S, N>;
|
|
129
|
+
aggregate: AggregateQuery<S, N>;
|
|
130
|
+
reindex: false;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* `db.<model>` — marcidb's lazy, immutable query over one model: clauses (`where/order/limit/skip/after`)
|
|
134
|
+
* return a new query, `select(shape)` sets the projection, `await` runs it, `first/count/aggregate` terminate,
|
|
135
|
+
* `updateMany(data)`/`deleteMany()` write through the chain's `where`; a query placed in another query's
|
|
136
|
+
* select is a sub-query. `Sel` is the projection: id + scalars until `select(...)` sets a shape.
|
|
137
|
+
*/
|
|
138
|
+
export type Query<S, N extends keyof S, Sel = ScalarSelect<S, N>> = MarciQuery<Types<S, N>, Sel>;
|
|
139
|
+
/** The rows a query with projection `Q` resolves to (no field keys = id + scalars; sub-queries resolved). */
|
|
140
|
+
export type Result<S, N extends keyof S, Q> = Rows<Types<S, N>, Q>;
|
|
141
|
+
/** `db.<model>` — the root query of a model. */
|
|
142
|
+
export type Collection<S, N extends keyof S> = Query<S, N>;
|
|
143
|
+
export type Db<S extends Schema> = {
|
|
144
|
+
[N in keyof S & string as Uncapitalize<N>]: Query<S, N>;
|
|
145
|
+
} & {
|
|
146
|
+
/** Atomic batch: all ops commit or none. `ref("0.id")` feeds a generated id into a later op. */
|
|
147
|
+
$transaction<P extends readonly Op<any>[]>(ops: [...P]): Promise<{
|
|
148
|
+
[K in keyof P]: P[K] extends Op<infer T> ? T : never;
|
|
149
|
+
}>;
|
|
150
|
+
/** The `.marci` schema text this db syncs with. */
|
|
151
|
+
readonly $schema: string;
|
|
152
|
+
};
|
|
153
|
+
type RelKinds = "one" | "many" | "list";
|
|
154
|
+
type CheckField<S, Fld> = MetaOf<Fld>["kind"] extends RelKinds ? MetaOf<Fld>["model"] extends keyof S ? Fld : `Unknown model "${MetaOf<Fld>["model"]}" — not a key of defineDb({...})` : Fld;
|
|
155
|
+
/** Intersected with `S` in `defineDb`'s parameter: an unknown relation target fails to type-check on that field. */
|
|
156
|
+
export type ValidateRefs<S extends Schema> = {
|
|
157
|
+
[N in keyof S]: {
|
|
158
|
+
readonly fields: {
|
|
159
|
+
[K in keyof FieldsOf<S[N]>]: CheckField<S, FieldsOf<S[N]>[K]>;
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `throw new ApiError(404, "Not found")` inside an endpoint → the client's promise rejects with the
|
|
3
|
+
* same status + message. Any other throw is a 500 (message hidden, logged to the server console).
|
|
4
|
+
*/
|
|
5
|
+
export declare class ApiError extends Error {
|
|
6
|
+
readonly status: number;
|
|
7
|
+
constructor(status: number, message?: string);
|
|
8
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type PresentOptions } from "./presentable";
|
|
2
|
+
import { type BaseStyle, type DrawableStyle, type ElementStyle, type UIElementBase } from "./UINode";
|
|
3
|
+
export type UINativeViewStyle = ElementStyle & DrawableStyle;
|
|
4
|
+
/** An instance of a host-registered platform view (map, QR scanner, camera preview, …) —
|
|
5
|
+
* embeddable among a screen's children AND fullscreen-presentable (`open()`); one instance lives
|
|
6
|
+
* in one place at a time. Talk to it via the `call`/`on` channel. */
|
|
7
|
+
export interface NativeView extends UIElementBase<UINativeViewStyle, DrawableStyle & BaseStyle> {
|
|
8
|
+
readonly type: "native";
|
|
9
|
+
/** The registered view kind this instance resolves to (the `registerView` name). */
|
|
10
|
+
readonly viewName: string;
|
|
11
|
+
/** Creation params, passed to the host factory (JSON-serializable). */
|
|
12
|
+
readonly params: any;
|
|
13
|
+
/** Show fullscreen as the current destination (see Presentable). */
|
|
14
|
+
open(options?: PresentOptions): void;
|
|
15
|
+
/** Dismiss if this is the visible destination. */
|
|
16
|
+
close(): void;
|
|
17
|
+
/** Became the visible destination. */
|
|
18
|
+
onOpen(callback: () => void): this;
|
|
19
|
+
/** Stopped being the visible destination. */
|
|
20
|
+
onClose(callback: () => void): this;
|
|
21
|
+
/** Hardware/system back while current. */
|
|
22
|
+
onBackPressed(callback: () => void): this;
|
|
23
|
+
/** Invoke a method on the native view (`map.call("setCenter", [lng, lat])`). Args and the
|
|
24
|
+
* result are JSON-serialized. Rejects if the host has no such view/method. */
|
|
25
|
+
call(method: string, ...args: any[]): Promise<any>;
|
|
26
|
+
/** Subscribe to an event the native view emits (`map.on("markerTap", cb)`). */
|
|
27
|
+
on(event: string, callback: (data?: any) => void): this;
|
|
28
|
+
off(event: string, callback: (data?: any) => void): this;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Create an instance of a host-registered platform view. `NativeView.isSupported(name)` reports
|
|
32
|
+
* whether this host registered a factory for it. Style via the chained `.style()`.
|
|
33
|
+
*/
|
|
34
|
+
export declare const NativeView: {
|
|
35
|
+
(name: string, params?: object): NativeView;
|
|
36
|
+
/** Whether this host registered a `registerView` factory under `name`. */
|
|
37
|
+
isSupported(name: string): boolean;
|
|
38
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { UIButton, type UIButtonStyle } from './UIButton';
|
|
2
|
+
export { UIScreen, type UIScreenStyle } from './UIScreen';
|
|
3
|
+
export { UISpacer, type UISpacerStyle } from './UISpacer';
|
|
4
|
+
export { UIText, type UITextStyle } from './UIText';
|
|
5
|
+
export { registerFont } from './fonts';
|
|
6
|
+
export { UIImage, type UIImageStyle } from './UIImage';
|
|
7
|
+
export { UIVideo, type UIVideoStyle } from './UIVideo';
|
|
8
|
+
export { UIInput, UITextArea, type UIInputStyle } from './UIInput';
|
|
9
|
+
export { UIWidget, type UIWidgetStyle } from './UIWidget';
|
|
10
|
+
export { UIModal, type UIModalStyle } from './UIModal';
|
|
11
|
+
export { UIBottomSheet, type UIBottomSheetStyle } from './UIBottomSheet';
|
|
12
|
+
export { UIPopover, type UIPopoverStyle, type UIPopoverAnchor } from './UIPopover';
|
|
13
|
+
export { UIRow, UIColumn, UIBox, type UIContainerStyle } from './UIContainer';
|
|
14
|
+
export { UIScrollable, type UIScrollableStyle } from './UIScrollable';
|
|
15
|
+
export { UIPager, type UIPagerStyle } from './UIPager';
|
|
16
|
+
export { UITabs, type UITabDef, defineTabs, type TabDef, type TabsHandle } from './UITabs';
|
|
17
|
+
export { UIVirtualizedList } from './UIVirtualizedList';
|
|
18
|
+
export { Router } from './router';
|
|
19
|
+
export { NativeView, type UINativeViewStyle } from './NativeView';
|
|
20
|
+
export { Presentable } from './presentable';
|
|
21
|
+
export type { PresentOptions, Transition, TransitionName, TransitionSpec, TransitionTransform } from './presentable';
|
|
22
|
+
export { __uiMap } from './UINode';
|
|
23
|
+
export { __UIColumn, __UIRow, __UIBox } from './UIContainer';
|
|
24
|
+
export { __UIButton } from './UIButton';
|
|
25
|
+
export { __UIScreen } from './UIScreen';
|
|
26
|
+
export { __UIScrollable } from './UIScrollable';
|
|
27
|
+
export { __UIWidget } from './UIWidget';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ModalElement, type UIModalStyle } from "./UIModal";
|
|
2
|
+
import type { UIWidget } from "./UIWidget";
|
|
3
|
+
import { type ChildrenFn, type UIChildArg, type UINodeChild } from "./UINode";
|
|
4
|
+
export type UIBottomSheetStyle = UIModalStyle;
|
|
5
|
+
/**
|
|
6
|
+
* A bottom sheet: a `UIWidget` pinned to the bottom edge. By default it is **content-sized** —
|
|
7
|
+
* as tall as what's inside (capped at the screen), one position, drag down to dismiss (the
|
|
8
|
+
* action-sheet shape). Call `detents()` for the multi-position map-app model instead: snap
|
|
9
|
+
* positions the user drags between on native hosts. Ships as a widget node on the wire (no new
|
|
10
|
+
* node type — docs/bottom-sheet-plan.md): hosts without sheet support show a static bottom panel.
|
|
11
|
+
*
|
|
12
|
+
* With detents, content lays out at the HIGHEST detent's size; lower detents show the top
|
|
13
|
+
* slice. The scrim, `onOpen`/`onClose`, back-button and scrim-tap dismissal all come from the
|
|
14
|
+
* modal machinery.
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* const actions = UIBottomSheet({ bgColor: "#1c1c1e", borderRadius: 16 }, [rows]) // content-sized
|
|
18
|
+
*
|
|
19
|
+
* const mapSheet = UIBottomSheet({ bgColor: "#1c1c1e", borderRadius: 16 }, [results])
|
|
20
|
+
* .detents([0.3, 0.6, 1])
|
|
21
|
+
* .onDetentChange(i => map.setPadding(...))
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export interface UIBottomSheet extends UIWidget {
|
|
25
|
+
/** Snap positions as fractions of screen height, ascending. Also sizes the sheet: its box is
|
|
26
|
+
* the last (highest) detent; set this before `show()`. Without a `detents()` call the sheet
|
|
27
|
+
* is CONTENT-SIZED instead — one position, as tall as its children (up to the screen). */
|
|
28
|
+
detents(list: number[]): this;
|
|
29
|
+
/** Snap to a detent (animated). Clamped to the detents range; fires `onDetentChange`. */
|
|
30
|
+
setDetent(index: number): void;
|
|
31
|
+
/** Current detent index. */
|
|
32
|
+
readonly detent: number;
|
|
33
|
+
/** Fires on every settle: a finger snap on native hosts, or a `setDetent()` call. */
|
|
34
|
+
onDetentChange(callback: (index: number) => void): this;
|
|
35
|
+
/** Mount and slide in to the current detent. No-op while already open. */
|
|
36
|
+
show(): void;
|
|
37
|
+
/** Slide out, fade the scrim, then unmount. No-op while closed. */
|
|
38
|
+
hide(): void;
|
|
39
|
+
/** True from `show()` until `hide()` starts. */
|
|
40
|
+
readonly isOpen: boolean;
|
|
41
|
+
/** Called when `show()` mounts the sheet. */
|
|
42
|
+
onOpen(callback: () => void): this;
|
|
43
|
+
/** Called when the sheet starts closing — scrim tap, back button, drag-dismiss, or `hide()`. */
|
|
44
|
+
onClose(callback: () => void): this;
|
|
45
|
+
/** `dismissible(false)`: scrim taps, the back button and dragging below the lowest detent no
|
|
46
|
+
* longer close the sheet (a drag collapses to the lowest detent instead). Default `true`. */
|
|
47
|
+
dismissible(enabled: boolean): this;
|
|
48
|
+
}
|
|
49
|
+
export declare class BottomSheetElement extends ModalElement {
|
|
50
|
+
_detents: number[];
|
|
51
|
+
_detent: number;
|
|
52
|
+
/** Host-facing (the `sl`/`otl` contract): hosts read `dtl` at mount and call it with the
|
|
53
|
+
* settled detent index for GESTURE settles only — programmatic `setDetent` fires JS-side.
|
|
54
|
+
* `-1` = dragged below the lowest detent while dismissible. */
|
|
55
|
+
readonly dtl: any[];
|
|
56
|
+
readonly _detentListeners: ((index: number) => void)[];
|
|
57
|
+
constructor(style: UIBottomSheetStyle, children: UINodeChild[] | ChildrenFn);
|
|
58
|
+
detents(list: number[]): this;
|
|
59
|
+
get detent(): number;
|
|
60
|
+
setDetent(index: number): void;
|
|
61
|
+
onDetentChange(callback: (index: number) => void): this;
|
|
62
|
+
show(): void;
|
|
63
|
+
hide(): void;
|
|
64
|
+
dismissible(enabled: boolean): this;
|
|
65
|
+
}
|
|
66
|
+
/** Create a bottom sheet (see {@link UIBottomSheet}) — content-sized by default; call
|
|
67
|
+
* `.detents([...])` for snap positions. Same argument forms as `UIColumn`. */
|
|
68
|
+
export declare function UIBottomSheet(...children: UIChildArg[]): UIBottomSheet;
|
|
69
|
+
export declare function UIBottomSheet(children: UINodeChild[] | ChildrenFn): UIBottomSheet;
|
|
70
|
+
/** @deprecated Style as the first argument is legacy — use chained `.style({...})`. */
|
|
71
|
+
export declare function UIBottomSheet(style: UIBottomSheetStyle, children?: UINodeChild[] | ChildrenFn): UIBottomSheet;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ClickEvent as ClickEventType, TouchStartEvent as TouchStartEventType, LongPressEvent as LongPressEventType } from "../runtime/touch";
|
|
2
|
+
import { type ElementStyle, type ContainerStyle, type DrawableStyle, type UIChildArg, type UIContainerBase, type UINodeChild, type ChildrenFn, type BaseStyle, type Color } from "./UINode";
|
|
3
|
+
export type UIButtonStyle = ElementStyle & DrawableStyle & ContainerStyle & {
|
|
4
|
+
rippleColor?: Color | "default";
|
|
5
|
+
};
|
|
6
|
+
/** A tappable container — row + centered children by default. Press feedback via the `onPressed`
|
|
7
|
+
* style block, the `$pressed` class, or `rippleColor`. */
|
|
8
|
+
export interface UIButton extends UIContainerBase<UIButtonStyle & {
|
|
9
|
+
onPressed?: UIButtonStyle & {
|
|
10
|
+
duration?: number;
|
|
11
|
+
};
|
|
12
|
+
}, DrawableStyle & BaseStyle> {
|
|
13
|
+
readonly type: "button";
|
|
14
|
+
/** Fired on a completed tap/click. */
|
|
15
|
+
onClick(callback: (ev: ClickEventType<UIButton>) => void): this;
|
|
16
|
+
/** Fired when a touch begins; `ev.track(...)` takes over the rest of the gesture (dragging). */
|
|
17
|
+
onTouchStart(callback: (ev: TouchStartEventType<UIButton>) => void): this;
|
|
18
|
+
/** Fired when a finger is held on the button past the long-press threshold. The event can
|
|
19
|
+
* `ev.track(...)` the rest of the gesture (like `onTouchStart`), so a hold can flow straight into
|
|
20
|
+
* dragging the element. A handled long-press suppresses the click that would follow the release. */
|
|
21
|
+
onLongPress(callback: (ev: LongPressEventType<UIButton>) => void): this;
|
|
22
|
+
/** Is a finger currently down on the button? */
|
|
23
|
+
isPressed(): boolean;
|
|
24
|
+
}
|
|
25
|
+
/** Create a button (row + centered by default — the icon+label shape). Same argument forms as
|
|
26
|
+
* `UIColumn`; attach behavior with `.onClick(...)`. */
|
|
27
|
+
export declare function UIButton(...children: UIChildArg[]): UIButton;
|
|
28
|
+
export declare function UIButton(children: UINodeChild[] | ChildrenFn): UIButton;
|
|
29
|
+
/** @deprecated Style as the first argument is legacy — use chained `.style({...})`. */
|
|
30
|
+
export declare function UIButton(style: UIButtonStyle, children?: UINodeChild[] | ChildrenFn): UIButton;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type ChildrenFn, type ContainerStyle, type DrawableStyle, type ElementStyle, type UIChildArg, type UIContainerBase, type UINodeChild } from "./UINode";
|
|
2
|
+
export type UIContainerStyle = ElementStyle & DrawableStyle & ContainerStyle;
|
|
3
|
+
/** A vertical flex container — children stack top to bottom. */
|
|
4
|
+
export interface UIColumn extends UIContainerBase<UIContainerStyle> {
|
|
5
|
+
readonly type: "column";
|
|
6
|
+
}
|
|
7
|
+
export declare const __UIRow: (children: UINodeChild[] | ChildrenFn) => UIRow;
|
|
8
|
+
export declare const __UIBox: (children: UINodeChild[] | ChildrenFn) => UIBox;
|
|
9
|
+
/** Create a vertical flex container. Children are variadic — arrays flatten one level, falsy
|
|
10
|
+
* entries are skipped; a lone function makes the children reactive. */
|
|
11
|
+
export declare function UIColumn(...children: UIChildArg[]): UIColumn;
|
|
12
|
+
export declare function UIColumn(children: UINodeChild[] | ChildrenFn): UIColumn;
|
|
13
|
+
/** @deprecated Style as the first argument is legacy — use chained `.style({...})`. */
|
|
14
|
+
export declare function UIColumn(style: UIContainerStyle, children?: UINodeChild[] | ChildrenFn): UIColumn;
|
|
15
|
+
/** A horizontal flex container — children flow left to right. */
|
|
16
|
+
export interface UIRow extends UIContainerBase<UIContainerStyle> {
|
|
17
|
+
readonly type: "row";
|
|
18
|
+
}
|
|
19
|
+
/** Create a horizontal flex container (same argument forms as `UIColumn`). */
|
|
20
|
+
export declare function UIRow(...children: UIChildArg[]): UIRow;
|
|
21
|
+
export declare function UIRow(children: UINodeChild[] | ChildrenFn): UIRow;
|
|
22
|
+
/** @deprecated Style as the first argument is legacy — use chained `.style({...})`. */
|
|
23
|
+
export declare function UIRow(style: UIContainerStyle, children?: UINodeChild[] | ChildrenFn): UIRow;
|
|
24
|
+
/** A centering container — `justifyContent`/`alignItems` default to center. */
|
|
25
|
+
export interface UIBox extends UIContainerBase<UIContainerStyle> {
|
|
26
|
+
readonly type: "box";
|
|
27
|
+
}
|
|
28
|
+
/** Create a centering container — children are centered on both axes by default (icon badges,
|
|
29
|
+
* avatars, empty states). Same argument forms as `UIColumn`. */
|
|
30
|
+
export declare function UIBox(...children: UIChildArg[]): UIBox;
|
|
31
|
+
export declare function UIBox(children: UINodeChild[] | ChildrenFn): UIBox;
|
|
32
|
+
/** @deprecated Style as the first argument is legacy — use chained `.style({...})`. */
|
|
33
|
+
export declare function UIBox(style: UIContainerStyle, children?: UINodeChild[] | ChildrenFn): UIBox;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { FetchResponse } from "../runtime/fetch";
|
|
2
|
+
import type { SvgSourceValue as SvgSource } from "../runtime/misc";
|
|
3
|
+
import type { File } from "../runtime/fetch";
|
|
4
|
+
import { Canvas } from "../canvas/Canvas";
|
|
5
|
+
import { type Color, type ElementStyle, type UIElementBase } from "./UINode";
|
|
6
|
+
export type UIImageStyle = ElementStyle & {
|
|
7
|
+
borderRadius?: number;
|
|
8
|
+
objectFit?: "cover" | "contain" | "fill";
|
|
9
|
+
tintColor?: Color;
|
|
10
|
+
};
|
|
11
|
+
/** A baked Canvas surface as an image source. The UI backend resolves it to a UI texture — see
|
|
12
|
+
* docs/canvas-contract.md ("Pending"). */
|
|
13
|
+
export type CanvasImageSource = {
|
|
14
|
+
canvasSurface: number;
|
|
15
|
+
};
|
|
16
|
+
/** Accepted image sources. A Canvas is baked to a surface marker on assign. */
|
|
17
|
+
export type ImageSource = string | FetchResponse | File | SvgSource | Canvas;
|
|
18
|
+
/** The stored/resolved image source (a Canvas is resolved to a surface marker). */
|
|
19
|
+
export type ResolvedImageSource = string | FetchResponse | File | SvgSource | CanvasImageSource;
|
|
20
|
+
/** An image element. Sources: URL / `asset(...)`, fetch response / File, an SVG source
|
|
21
|
+
* (`assetIcon`), or a live Canvas (`canvas.update()` refreshes the node in place). */
|
|
22
|
+
export interface UIImage extends UIElementBase<UIImageStyle> {
|
|
23
|
+
readonly type: "image";
|
|
24
|
+
/** The image source — writable to swap the picture in place. */
|
|
25
|
+
get src(): ResolvedImageSource;
|
|
26
|
+
set src(value: ImageSource);
|
|
27
|
+
/** Render only a sub-rectangle of the source texture (texture pixels) — the atlas/spritesheet
|
|
28
|
+
* primitive: crop once, then swap the rect per frame for sprite animation. The rect's w/h
|
|
29
|
+
* become the node's intrinsic size and override `objectFit` — the cropped frame fills the box. */
|
|
30
|
+
setSourceRect(x: number, y: number, w: number, h: number): this;
|
|
31
|
+
}
|
|
32
|
+
/** Create an image element from a source (see {@link ImageSource}). */
|
|
33
|
+
export declare function UIImage(src: ImageSource): UIImage;
|
|
34
|
+
/** @deprecated Style as the first argument is legacy — use chained `.style({...})`. */
|
|
35
|
+
export declare function UIImage(style: UIImageStyle, src: ImageSource): UIImage;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { type ElementStyle, type DrawableStyle, type TextStyle, type Color, type BaseStyle, type UIElementBase } from "./UINode";
|
|
2
|
+
type InputStyle = {
|
|
3
|
+
placeholder?: string;
|
|
4
|
+
placeholderColor?: Color;
|
|
5
|
+
/**
|
|
6
|
+
* Keyboard hint, NOT a validator — `number` does not block pasted letters; validate in your own
|
|
7
|
+
* onChange. The phone-pad value is `phone` (LeCodes has no `tel`).
|
|
8
|
+
*
|
|
9
|
+
* `date` / `time` are PICKER kinds, not keyboards: the host opens its native picker in the
|
|
10
|
+
* keyboard slot (iOS wheels / browser calendar) and free typing is disabled. `value` is always
|
|
11
|
+
* canonical — `YYYY-MM-DD` for `date`, `HH:MM` (24h) for `time` — while the field displays a
|
|
12
|
+
* localized string; set/compare values in the canonical form only.
|
|
13
|
+
*/
|
|
14
|
+
type?: "text" | "password" | "search" | "phone" | "email" | "number" | "decimal" | "url" | "date" | "time";
|
|
15
|
+
/**
|
|
16
|
+
* What the layout does while the keyboard is up (decided by the FOCUSED input). `true` (default):
|
|
17
|
+
* the layout viewport shrinks to the area above the keyboard — one relayout. `false`: the keyboard
|
|
18
|
+
* overlays the UI with NO layout recalculation — for chat composers that manage their own inset
|
|
19
|
+
* (pair with `app.keyboardHeight` / the app `"keyboard"` event) and full-screen canvases where a
|
|
20
|
+
* reflow is worse than overlap.
|
|
21
|
+
*/
|
|
22
|
+
keyboardShrink?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Whether a tap on a non-interactive area dismisses the keyboard while THIS input is focused
|
|
25
|
+
* (like `keyboardShrink`, the policy of the focused input). `true` (default): tapping dead
|
|
26
|
+
* space blurs — but a tap on a button or another input NEVER dismisses; the control acts and
|
|
27
|
+
* focus stays. `false`: taps never dismiss — the chat-composer policy. `blur()`, the return
|
|
28
|
+
* key (per `enterKey`), and the platform's own gestures (iOS drag-down over the keyboard)
|
|
29
|
+
* still work in both modes. Scrolling never dismisses the keyboard on any setting.
|
|
30
|
+
*/
|
|
31
|
+
keyboardDismiss?: boolean;
|
|
32
|
+
/** Hard cap on the text length — enforced by the host while typing/pasting. */
|
|
33
|
+
maxLength?: number;
|
|
34
|
+
/** Auto-capitalization hint; omitted = platform default. */
|
|
35
|
+
autocapitalize?: "none" | "words" | "sentences" | "characters";
|
|
36
|
+
/** Enable/disable the platform autocorrection & suggestions; omitted = platform default. */
|
|
37
|
+
autocorrect?: boolean;
|
|
38
|
+
};
|
|
39
|
+
export type UIInputStyle = ElementStyle & DrawableStyle & TextStyle & InputStyle;
|
|
40
|
+
/** UIInput-only (a UITextArea's Enter is a newline, period): the return-key label. */
|
|
41
|
+
type SubmitStyle = {
|
|
42
|
+
/**
|
|
43
|
+
* Return-key label. On submit the keyboard dismisses UNLESS `enterKey` is `"next"` — then the
|
|
44
|
+
* app is expected to call `otherInput.focus()` from `onSubmit`, so the keyboard never blinks.
|
|
45
|
+
*/
|
|
46
|
+
enterKey?: "done" | "go" | "next" | "search" | "send";
|
|
47
|
+
};
|
|
48
|
+
/** A single-line text input. Keyboard/picker kind via the `type` style, return-key behavior via
|
|
49
|
+
* `enterKey` + `onSubmit`; keyboard policy on `keyboardShrink`/`keyboardDismiss`. */
|
|
50
|
+
export interface UIInput extends UIElementBase<UIInputStyle & SubmitStyle & {
|
|
51
|
+
onFocused?: UIInputStyle & {
|
|
52
|
+
duration?: number;
|
|
53
|
+
};
|
|
54
|
+
}, DrawableStyle & BaseStyle> {
|
|
55
|
+
readonly type: "input";
|
|
56
|
+
/**
|
|
57
|
+
* The field's text. Writable at any time — set it BEFORE the screen opens to pre-fill a form
|
|
58
|
+
* (settings, edit-profile); the value is stashed on the node and applied when the host builds
|
|
59
|
+
* it. Reads return the live text while the screen is open, and the last value you set while it
|
|
60
|
+
* isn't. The user's typing is not preserved across close/open (use `keepAlive()` for that).
|
|
61
|
+
*/
|
|
62
|
+
value: string;
|
|
63
|
+
/** The text changed — fires on every user edit. */
|
|
64
|
+
onChange(callback: (value: string) => void): UIInput;
|
|
65
|
+
/** Gained focus (keyboard opens). */
|
|
66
|
+
onFocus(callback: () => void): UIInput;
|
|
67
|
+
/** Lost focus. */
|
|
68
|
+
onBlur(callback: () => void): UIInput;
|
|
69
|
+
/** The keyboard's return key was pressed. `value` is the current text. See `enterKey`. */
|
|
70
|
+
onSubmit(callback: (value: string) => void): UIInput;
|
|
71
|
+
/** Focus the input (opens the keyboard). No-op before mount. */
|
|
72
|
+
focus(): void;
|
|
73
|
+
/** Release focus (dismisses the keyboard when this input held it). */
|
|
74
|
+
blur(): void;
|
|
75
|
+
}
|
|
76
|
+
/** A multi-line text field — see the {@link UITextArea} factory for the auto-grow contract. */
|
|
77
|
+
export interface UITextArea extends UIElementBase<UIInputStyle & {
|
|
78
|
+
onFocused?: UIInputStyle & {
|
|
79
|
+
duration?: number;
|
|
80
|
+
};
|
|
81
|
+
}, DrawableStyle & BaseStyle> {
|
|
82
|
+
readonly type: "textarea";
|
|
83
|
+
/** The field's text — same contract as {@link UIInput.value}: settable before mount to pre-fill. */
|
|
84
|
+
value: string;
|
|
85
|
+
/** The text changed — fires on every user edit. */
|
|
86
|
+
onChange(callback: (value: string) => void): UITextArea;
|
|
87
|
+
/** Gained focus (keyboard opens). */
|
|
88
|
+
onFocus(callback: () => void): UITextArea;
|
|
89
|
+
/** Lost focus. */
|
|
90
|
+
onBlur(callback: () => void): UITextArea;
|
|
91
|
+
/** Focus the text area (opens the keyboard). No-op before mount. */
|
|
92
|
+
focus(): void;
|
|
93
|
+
/** Release focus (dismisses the keyboard when this text area held it). */
|
|
94
|
+
blur(): void;
|
|
95
|
+
}
|
|
96
|
+
/** Create a single-line text input. Read/write the text via `.value`, listen with
|
|
97
|
+
* `onChange`/`onSubmit`; style keys `placeholder`, `type`, `enterKey`, … configure it. */
|
|
98
|
+
export declare function UIInput(): UIInput;
|
|
99
|
+
export declare function UIInput(style: UIInputStyle): UIInput;
|
|
100
|
+
/**
|
|
101
|
+
* Multi-line text field. Enter is a newline (submit lives on UIInput / your own button).
|
|
102
|
+
*
|
|
103
|
+
* Auto-grow: with no explicit `height` the field measures its own content and grows line by
|
|
104
|
+
* line — clamp the range with `minHeight` / `maxHeight` (past `maxHeight` the text scrolls
|
|
105
|
+
* inside). A fixed `height` opts out and scrolls internally from the start. Chat composers are
|
|
106
|
+
* the canonical use: a bare textarea in a padded pill, `maxHeight` at ~5 lines.
|
|
107
|
+
*/
|
|
108
|
+
export declare function UITextArea(): UITextArea;
|
|
109
|
+
export declare function UITextArea(style: UIInputStyle): UITextArea;
|
|
110
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type UIWidget, type UIWidgetStyle, WidgetElement } from "./UIWidget";
|
|
2
|
+
import { type BaseStyle, type ChildrenFn, type Color, type DrawableStyle, type UIChildArg, type UINodeChild } from "./UINode";
|
|
3
|
+
export type UIModalStyle = UIWidgetStyle;
|
|
4
|
+
/**
|
|
5
|
+
* The modal's hidden pose: `show()` animates from it, `hide()` animates to it. `duration` (ms)
|
|
6
|
+
* applies to both directions.
|
|
7
|
+
*/
|
|
8
|
+
export type UIModalTransition = DrawableStyle & BaseStyle & {
|
|
9
|
+
overlayColor?: Color | null;
|
|
10
|
+
duration?: number;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* A dialog: a `UIWidget` with the modal boilerplate built in. Comes with a scrim
|
|
14
|
+
* (`overlayColor: "rgba(0, 0, 0, 0.5)"` unless overridden), animates on `show()`/`hide()`
|
|
15
|
+
* (a 200 ms fade by default — swap the pose via `transition()`; the exit plays with
|
|
16
|
+
* `commit: false`, so the style is intact for the next show), and closes itself on a scrim tap
|
|
17
|
+
* or the Android back button (disable via `dismissible(false)`). Everything else is a plain
|
|
18
|
+
* widget — same styling, children, touch and `attachTo()` surface; create it **once** at module
|
|
19
|
+
* scope and reuse it.
|
|
20
|
+
*/
|
|
21
|
+
export interface UIModal extends UIWidget {
|
|
22
|
+
/** Mount as an overlay and play the entrance transition. No-op while already open. */
|
|
23
|
+
show(): void;
|
|
24
|
+
/** Play the exit transition, then unmount. No-op while closed or already closing. */
|
|
25
|
+
hide(): void;
|
|
26
|
+
/** True from `show()` until `hide()` starts (already false during the exit animation). */
|
|
27
|
+
readonly isOpen: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Replace the show/hide animation. `hidden` is the off-screen pose — `show()` animates from
|
|
30
|
+
* it, `hide()` animates to it. Default `{ opacity: 0, duration: 200 }` (a fade); the pose
|
|
31
|
+
* replaces it wholesale, so a slide without a fade is just the slide. The scrim keeps its own
|
|
32
|
+
* fade unless the pose sets `overlayColor` itself.
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* sheet.transition({ transform: "translateY(480px)", duration: 250 }) // bottom sheet
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
transition(hidden: UIModalTransition): this;
|
|
39
|
+
/** Called when `show()` mounts the modal. */
|
|
40
|
+
onOpen(callback: () => void): this;
|
|
41
|
+
/** Called when the modal starts closing — scrim tap, back button, or a `hide()` call. */
|
|
42
|
+
onClose(callback: () => void): this;
|
|
43
|
+
/** `dismissible(false)` keeps scrim taps and the back button from closing the modal
|
|
44
|
+
* (forced-choice dialogs). Default `true`. */
|
|
45
|
+
dismissible(enabled: boolean): this;
|
|
46
|
+
}
|
|
47
|
+
export declare class ModalElement extends WidgetElement {
|
|
48
|
+
_open: boolean;
|
|
49
|
+
_dismissible: boolean;
|
|
50
|
+
_transition: UIModalTransition;
|
|
51
|
+
_closeTimer?: ReturnType<typeof setTimeout>;
|
|
52
|
+
readonly _openListeners: (() => void)[];
|
|
53
|
+
readonly _closeListeners: (() => void)[];
|
|
54
|
+
constructor(style: UIModalStyle, children: UINodeChild[] | ChildrenFn);
|
|
55
|
+
private _pose;
|
|
56
|
+
private get _duration();
|
|
57
|
+
transition(hidden: UIModalTransition): this;
|
|
58
|
+
show(): void;
|
|
59
|
+
hide(): void;
|
|
60
|
+
get isOpen(): boolean;
|
|
61
|
+
onOpen(callback: () => void): this;
|
|
62
|
+
onClose(callback: () => void): this;
|
|
63
|
+
dismissible(enabled: boolean): this;
|
|
64
|
+
}
|
|
65
|
+
/** Create a modal dialog (see {@link UIModal}) — create once at module scope, then
|
|
66
|
+
* `show()`/`hide()`. Same argument forms as `UIColumn`. */
|
|
67
|
+
export declare function UIModal(...children: UIChildArg[]): UIModal;
|
|
68
|
+
export declare function UIModal(children: UINodeChild[] | ChildrenFn): UIModal;
|
|
69
|
+
/** @deprecated Style as the first argument is legacy — use chained `.style({...})`. */
|
|
70
|
+
export declare function UIModal(style: UIModalStyle, children?: UINodeChild[] | ChildrenFn): UIModal;
|