lecodes-sdk 2.2.9 → 2.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/global.d.ts +42 -1
- package/dist/types/canvas/Canvas.d.ts +6 -6
- package/dist/types/gl/Camera.d.ts +5 -2
- package/dist/types/gl/Node.d.ts +0 -7
- package/dist/types/gl/Scene.d.ts +6 -24
- package/dist/types/inject.d.ts +5 -1
- package/dist/types/plugin.d.ts +27 -0
- package/dist/types/plugins/gen/ar/sdk/ar.d.ts +228 -0
- package/dist/types/plugins/gen/ar/sdk/ar.gen.d.ts +73 -0
- package/dist/types/plugins/gen/ar/sdk/controls.d.ts +28 -0
- package/dist/types/plugins/gen/audio-recorder/sdk/audio-recorder.d.ts +43 -0
- package/dist/types/plugins/gen/audio-recorder/sdk/audio-recorder.gen.d.ts +47 -0
- package/dist/types/plugins/gen/geolocation/sdk/geolocation.gen.d.ts +6 -2
- package/dist/types/plugins/gen/speech/sdk/speech.d.ts +44 -0
- package/dist/types/plugins/gen/speech/sdk/speech.gen.d.ts +39 -0
- package/dist/types/runtime/media.d.ts +3 -2
- package/dist/types/runtime/permissions.d.ts +16 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/types.json +1 -1
- package/package.json +1 -1
- package/prompts/ar.md +81 -48
- package/prompts/dist/2d-game.md +1567 -0
- package/prompts/dist/3d-app.md +1712 -0
- package/prompts/dist/ar-app.md +1585 -0
- package/prompts/dist/concept.md +49 -0
- package/prompts/dist/design.md +521 -0
- package/prompts/dist/ui-app.md +1175 -0
- package/prompts/index.md +3 -1
- package/src/animate/tween/Timeline.ts +175 -175
- package/src/bridges/device.d.ts +20 -6
- package/src/bridges/gl.d.ts +33 -19
- package/src/bridges/media.d.ts +3 -1
- package/src/canvas/Canvas.ts +6 -6
- package/src/compile/header.ts +11 -4
- package/src/gl/Camera.ts +5 -2
- package/src/gl/CameraPlace.ts +52 -52
- package/src/gl/Light.ts +257 -257
- package/src/gl/Mesh.ts +120 -120
- package/src/gl/Node.ts +0 -8
- package/src/gl/Scene.ts +14 -81
- package/src/gl/animation/DynamicBone.ts +482 -482
- package/src/gl/scenarios.ts +291 -291
- package/src/inject.ts +13 -1
- package/src/plugin.ts +45 -2
- package/src/plugins/gen/ar/contract.d.ts +118 -0
- package/src/plugins/gen/ar/sdk/ar.gen.ts +112 -0
- package/src/plugins/gen/ar/sdk/ar.ts +699 -0
- package/src/plugins/gen/ar/sdk/controls.ts +148 -0
- package/src/plugins/gen/audio-recorder/contract.d.ts +64 -0
- package/src/plugins/gen/audio-recorder/sdk/audio-recorder.gen.ts +76 -0
- package/src/plugins/gen/audio-recorder/sdk/audio-recorder.ts +113 -0
- package/src/plugins/gen/geolocation/contract.d.ts +7 -5
- package/src/plugins/gen/geolocation/sdk/geolocation.gen.ts +6 -2
- package/src/plugins/gen/speech/contract.d.ts +67 -0
- package/src/plugins/gen/speech/sdk/speech.gen.ts +64 -0
- package/src/plugins/gen/speech/sdk/speech.ts +104 -0
- package/src/runtime/media.ts +11 -4
- package/src/runtime/permissions.ts +40 -0
- package/src/server/auth/host.ts +1 -1
- package/src/ui/presentable.ts +5 -0
- package/src/ui/router.ts +4 -3
- package/src/version.ts +1 -1
- package/dist/types/gl/controls.d.ts +0 -19
- package/dist/types/plugins/permission.d.ts +0 -1
- package/src/gl/controls.ts +0 -95
- package/src/plugins/permission.ts +0 -8
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Emitter } from "../../../../plugin";
|
|
2
|
+
import type { EndReason, RecordOptions, Recording } from "../contract";
|
|
3
|
+
export type { EndReason, RecordOptions, Recording };
|
|
4
|
+
/** `"stopped"` = the recording ended on its own (`ended` fired): `stop()` still returns it. */
|
|
5
|
+
export type RecorderState = "inactive" | "recording" | "paused" | "stopped";
|
|
6
|
+
export type AudioRecorderEvents = {
|
|
7
|
+
/** The input level, 0..1, about ten times a second while recording — a meter, a waveform. */
|
|
8
|
+
level: (value: number) => void;
|
|
9
|
+
/** The recording stopped on its own: the limit, an interruption (a call came in), a failure.
|
|
10
|
+
* `stop()` returns what was recorded. */
|
|
11
|
+
ended: (reason: EndReason) => void;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Records the microphone to a file. `AudioRecorder.isSupported` reports whether this host
|
|
15
|
+
* registered the service — check it before showing a record button.
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* const recorder = new AudioRecorder()
|
|
19
|
+
* recorder.addEventListener('level', v => meter.style({ width: v * 100 }))
|
|
20
|
+
* await recorder.start({ maxDuration: 60_000 })
|
|
21
|
+
* const { file, duration, mimeType } = await recorder.stop()
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare class AudioRecorder extends Emitter<AudioRecorderEvents> {
|
|
25
|
+
/** Whether this host registered an "audioRecorder" service. */
|
|
26
|
+
static get isSupported(): boolean;
|
|
27
|
+
private _session;
|
|
28
|
+
private _state;
|
|
29
|
+
get state(): RecorderState;
|
|
30
|
+
/** Start a recording. The host asks for the microphone first; rejects `"denied"` when refused,
|
|
31
|
+
* `"failed"` when the recorder could not start, and before touching the host when it is not
|
|
32
|
+
* supported or a recording is under way. */
|
|
33
|
+
start(options?: RecordOptions): Promise<void>;
|
|
34
|
+
/** Pause: the level stops, the duration does not grow. */
|
|
35
|
+
pause(): Promise<void>;
|
|
36
|
+
resume(): Promise<void>;
|
|
37
|
+
/** Stop and get the recording — also after `ended`. Rejects `"failed"` when nothing could be
|
|
38
|
+
* encoded. The recorder is ready for another `start()` afterwards. */
|
|
39
|
+
stop(): Promise<Recording>;
|
|
40
|
+
/** Stop and discard. Nothing under way is not an error. */
|
|
41
|
+
cancel(): void;
|
|
42
|
+
private _drop;
|
|
43
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ServiceChannel } from "../../../../plugin";
|
|
2
|
+
import type { AudioRecorderEvents, AudioRecorderParams, RecordOptions, Recording } from "../contract";
|
|
3
|
+
/** What the halves register under. */
|
|
4
|
+
export declare const NAME = "audioRecorder";
|
|
5
|
+
/** The contract's version: the highest `@since` of its members. */
|
|
6
|
+
export declare const VERSION = 1;
|
|
7
|
+
/** Start recording. One recording per session: a second start rejects "busy".
|
|
8
|
+
* Needs the "microphone" permission: the host asks before the call, "denied" when refused.
|
|
9
|
+
* Rejects with "denied" / "busy" / "failed". */
|
|
10
|
+
export declare const start: (service: ServiceChannel<AudioRecorderEvents>, options?: RecordOptions) => Promise<void>;
|
|
11
|
+
/** Pause: the level stops, the duration does not grow. Rejects "notRecording" before a start
|
|
12
|
+
* or after the recording ended.
|
|
13
|
+
* Rejects with "notRecording" / "failed". */
|
|
14
|
+
export declare const pause: (service: ServiceChannel<AudioRecorderEvents>) => Promise<void>;
|
|
15
|
+
/** Rejects with "notRecording" / "failed". */
|
|
16
|
+
export declare const resume: (service: ServiceChannel<AudioRecorderEvents>) => Promise<void>;
|
|
17
|
+
/** Stop and get the recording (also after `ended`: the file was kept). Rejects "failed" when
|
|
18
|
+
* nothing could be encoded.
|
|
19
|
+
* Rejects with "notRecording" / "failed". */
|
|
20
|
+
export declare const stop: (service: ServiceChannel<AudioRecorderEvents>) => Promise<Recording>;
|
|
21
|
+
/** Stop and discard. Nothing to discard is not an error. */
|
|
22
|
+
export declare const cancel: (service: ServiceChannel<AudioRecorderEvents>) => Promise<void>;
|
|
23
|
+
/** A method of the contract. */
|
|
24
|
+
export type Method = "start" | "pause" | "resume" | "stop" | "cancel";
|
|
25
|
+
/** Whether this host has the service "audioRecorder" — and, given a method, a half new enough for it
|
|
26
|
+
* (a method added after the first version of the contract is tagged `@since`). */
|
|
27
|
+
export declare const supports: (method?: Method) => boolean;
|
|
28
|
+
/** The service "audioRecorder" with the wire's methods as its own. */
|
|
29
|
+
export declare class AudioRecorderBase extends ServiceChannel<AudioRecorderEvents> {
|
|
30
|
+
constructor(params?: AudioRecorderParams);
|
|
31
|
+
/** Start recording. One recording per session: a second start rejects "busy".
|
|
32
|
+
* Needs the "microphone" permission: the host asks before the call, "denied" when refused.
|
|
33
|
+
* Rejects with "denied" / "busy" / "failed". */
|
|
34
|
+
start(options?: RecordOptions): Promise<void>;
|
|
35
|
+
/** Pause: the level stops, the duration does not grow. Rejects "notRecording" before a start
|
|
36
|
+
* or after the recording ended.
|
|
37
|
+
* Rejects with "notRecording" / "failed". */
|
|
38
|
+
pause(): Promise<void>;
|
|
39
|
+
/** Rejects with "notRecording" / "failed". */
|
|
40
|
+
resume(): Promise<void>;
|
|
41
|
+
/** Stop and get the recording (also after `ended`: the file was kept). Rejects "failed" when
|
|
42
|
+
* nothing could be encoded.
|
|
43
|
+
* Rejects with "notRecording" / "failed". */
|
|
44
|
+
stop(): Promise<Recording>;
|
|
45
|
+
/** Stop and discard. Nothing to discard is not an error. */
|
|
46
|
+
cancel(): Promise<void>;
|
|
47
|
+
}
|
|
@@ -5,10 +5,12 @@ export declare const NAME = "geolocation";
|
|
|
5
5
|
/** The contract's version: the highest `@since` of its members. */
|
|
6
6
|
export declare const VERSION = 1;
|
|
7
7
|
/** One fix.
|
|
8
|
+
* Needs the "location" permission: the host asks before the call, "denied" when refused.
|
|
8
9
|
* Rejects with "denied" / "unavailable" / "timeout". */
|
|
9
10
|
export declare const getCurrent: (service: ServiceChannel<GeolocationEvents>, options?: GeoOptions) => Promise<GeoPosition>;
|
|
10
|
-
/** Start the session's watch; resolves once it is live (
|
|
11
|
+
/** Start the session's watch; resolves once it is live (the provider started).
|
|
11
12
|
* A second call while watching resolves at once and keeps the first call's options.
|
|
13
|
+
* Needs the "location" permission: the host asks before the call, "denied" when refused.
|
|
12
14
|
* Rejects with "denied" / "unavailable". */
|
|
13
15
|
export declare const startWatch: (service: ServiceChannel<GeolocationEvents>, options?: GeoOptions) => Promise<void>;
|
|
14
16
|
export declare const stopWatch: (service: ServiceChannel<GeolocationEvents>) => Promise<void>;
|
|
@@ -21,10 +23,12 @@ export declare const supports: (method?: Method) => boolean;
|
|
|
21
23
|
export declare class GeolocationBase extends ServiceChannel<GeolocationEvents> {
|
|
22
24
|
constructor(params?: GeolocationParams);
|
|
23
25
|
/** One fix.
|
|
26
|
+
* Needs the "location" permission: the host asks before the call, "denied" when refused.
|
|
24
27
|
* Rejects with "denied" / "unavailable" / "timeout". */
|
|
25
28
|
getCurrent(options?: GeoOptions): Promise<GeoPosition>;
|
|
26
|
-
/** Start the session's watch; resolves once it is live (
|
|
29
|
+
/** Start the session's watch; resolves once it is live (the provider started).
|
|
27
30
|
* A second call while watching resolves at once and keeps the first call's options.
|
|
31
|
+
* Needs the "location" permission: the host asks before the call, "denied" when refused.
|
|
28
32
|
* Rejects with "denied" / "unavailable". */
|
|
29
33
|
startWatch(options?: GeoOptions): Promise<void>;
|
|
30
34
|
stopWatch(): Promise<void>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Emitter } from "../../../../plugin";
|
|
2
|
+
import type { SpeechErrorCode, SpeechOptions, SpeechResult } from "../contract";
|
|
3
|
+
export type { SpeechErrorCode, SpeechOptions, SpeechResult };
|
|
4
|
+
export type SpeechRecognizerEvents = {
|
|
5
|
+
/** A result: partials while the user speaks (`interimResults`), then the final one. */
|
|
6
|
+
result: (result: SpeechResult) => void;
|
|
7
|
+
/** The user started speaking. */
|
|
8
|
+
speechStart: () => void;
|
|
9
|
+
/** The user stopped speaking: the final result follows. */
|
|
10
|
+
speechEnd: () => void;
|
|
11
|
+
/** The listening is over — after the final result, after `stop()` / `abort()`, after an error. */
|
|
12
|
+
end: () => void;
|
|
13
|
+
/** The listening failed; `end` follows. */
|
|
14
|
+
error: (code: SpeechErrorCode, message: string) => void;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Recognizes speech from the microphone. `SpeechRecognizer.isSupported` reports whether this host
|
|
18
|
+
* registered the service — check it before showing a dictation button.
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* const speech = new SpeechRecognizer()
|
|
22
|
+
* speech.addEventListener('result', r => input.value = r.transcript)
|
|
23
|
+
* speech.addEventListener('end', () => micButton.style({ opacity: 1 }))
|
|
24
|
+
* await speech.start({ language: 'en-US' })
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare class SpeechRecognizer extends Emitter<SpeechRecognizerEvents> {
|
|
28
|
+
/** Whether this host registered a "speech" service. */
|
|
29
|
+
static get isSupported(): boolean;
|
|
30
|
+
private _session;
|
|
31
|
+
/** Whether a listening is under way. */
|
|
32
|
+
get listening(): boolean;
|
|
33
|
+
/** Start listening. The host asks for the permissions first; rejects `"denied"` when refused,
|
|
34
|
+
* `"unavailable"` when there is no recognizer for the language or on the device, and before
|
|
35
|
+
* touching the host when the plugin is not there or a listening is under way. */
|
|
36
|
+
start(options?: SpeechOptions): Promise<void>;
|
|
37
|
+
/** Stop listening and finish: the final result of what was heard, then `end`. */
|
|
38
|
+
stop(): void;
|
|
39
|
+
/** Stop and drop what was heard: `end`, no result. */
|
|
40
|
+
abort(): void;
|
|
41
|
+
/** The languages this host recognizes (BCP-47), sorted; empty when it cannot say (the web). */
|
|
42
|
+
static supportedLanguages(): Promise<string[]>;
|
|
43
|
+
private _drop;
|
|
44
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ServiceChannel } from "../../../../plugin";
|
|
2
|
+
import type { SpeechEvents, SpeechOptions, SpeechParams } from "../contract";
|
|
3
|
+
/** What the halves register under. */
|
|
4
|
+
export declare const NAME = "speech";
|
|
5
|
+
/** The contract's version: the highest `@since` of its members. */
|
|
6
|
+
export declare const VERSION = 1;
|
|
7
|
+
/** Start listening. One listening per session: a second start rejects "busy". "unavailable":
|
|
8
|
+
* no recognizer on this device, or none for the language / on the device.
|
|
9
|
+
* Needs the "speech" and "microphone" permissions: the host asks before the call, "denied" when refused.
|
|
10
|
+
* Rejects with "denied" / "busy" / "unavailable" / "failed". */
|
|
11
|
+
export declare const start: (service: ServiceChannel<SpeechEvents>, options?: SpeechOptions) => Promise<void>;
|
|
12
|
+
/** Stop listening and finish: the final result of what was heard, then `end`. Not listening is
|
|
13
|
+
* not an error. */
|
|
14
|
+
export declare const stop: (service: ServiceChannel<SpeechEvents>) => Promise<void>;
|
|
15
|
+
/** Stop and drop what was heard: `end`, no result. */
|
|
16
|
+
export declare const abort: (service: ServiceChannel<SpeechEvents>) => Promise<void>;
|
|
17
|
+
/** The languages this host recognizes, BCP-47; empty when the host cannot say (the web). */
|
|
18
|
+
export declare const supportedLanguages: (service: ServiceChannel<SpeechEvents>) => Promise<string[]>;
|
|
19
|
+
/** A method of the contract. */
|
|
20
|
+
export type Method = "start" | "stop" | "abort" | "supportedLanguages";
|
|
21
|
+
/** Whether this host has the service "speech" — and, given a method, a half new enough for it
|
|
22
|
+
* (a method added after the first version of the contract is tagged `@since`). */
|
|
23
|
+
export declare const supports: (method?: Method) => boolean;
|
|
24
|
+
/** The service "speech" with the wire's methods as its own. */
|
|
25
|
+
export declare class SpeechBase extends ServiceChannel<SpeechEvents> {
|
|
26
|
+
constructor(params?: SpeechParams);
|
|
27
|
+
/** Start listening. One listening per session: a second start rejects "busy". "unavailable":
|
|
28
|
+
* no recognizer on this device, or none for the language / on the device.
|
|
29
|
+
* Needs the "speech" and "microphone" permissions: the host asks before the call, "denied" when refused.
|
|
30
|
+
* Rejects with "denied" / "busy" / "unavailable" / "failed". */
|
|
31
|
+
start(options?: SpeechOptions): Promise<void>;
|
|
32
|
+
/** Stop listening and finish: the final result of what was heard, then `end`. Not listening is
|
|
33
|
+
* not an error. */
|
|
34
|
+
stop(): Promise<void>;
|
|
35
|
+
/** Stop and drop what was heard: `end`, no result. */
|
|
36
|
+
abort(): Promise<void>;
|
|
37
|
+
/** The languages this host recognizes, BCP-47; empty when the host cannot say (the web). */
|
|
38
|
+
supportedLanguages(): Promise<string[]>;
|
|
39
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Emitter } from "../core/events";
|
|
2
2
|
import { Texture } from "../gl/Texture";
|
|
3
|
+
import type { File, FetchResponse } from "./fetch";
|
|
3
4
|
type MediaEvents = {
|
|
4
5
|
/** Fired at each loop boundary while `loop` is true. */
|
|
5
6
|
loopReached: () => void;
|
|
@@ -32,10 +33,10 @@ declare abstract class MediaPlayer extends Emitter<MediaEvents> {
|
|
|
32
33
|
dispose(): void;
|
|
33
34
|
}
|
|
34
35
|
export declare class AudioPlayer extends MediaPlayer {
|
|
35
|
-
constructor(src?: string);
|
|
36
|
+
constructor(src?: string | File | FetchResponse);
|
|
36
37
|
}
|
|
37
38
|
export declare class VideoPlayer extends MediaPlayer {
|
|
38
|
-
constructor(src?: string);
|
|
39
|
+
constructor(src?: string | File | FetchResponse);
|
|
39
40
|
/** A 3D Texture that samples this video (e.g. for a Material.video()). Owned by the player. */
|
|
40
41
|
get texture(): Texture;
|
|
41
42
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type PermissionKind = "camera" | "microphone" | "location" | "speech";
|
|
2
|
+
/** "prompt" = never asked: `request` shows the dialog. "denied" = refused, or restricted by the
|
|
3
|
+
* device's policy; the OS decides whether a `request` asks again (iOS never does: `openSettings`). */
|
|
4
|
+
export type PermissionState = "granted" | "denied" | "prompt";
|
|
5
|
+
export declare const permissions: {
|
|
6
|
+
/** The state of `kind` without a prompt. On the web the browser may not know before a request
|
|
7
|
+
* (Safari before 16, Firefox for the camera): "prompt" then. */
|
|
8
|
+
query(kind: PermissionKind): Promise<PermissionState>;
|
|
9
|
+
/** Ask for `kind`: the dialog when it was never asked, the state after it (or the state as it
|
|
10
|
+
* stands when the OS will not ask again). Ask where the user expects it — the first tap on the
|
|
11
|
+
* record button, not the start of the call. */
|
|
12
|
+
request(kind: PermissionKind): Promise<PermissionState>;
|
|
13
|
+
/** Open the app's own page of the system settings: where a denied permission is turned back on
|
|
14
|
+
* (iOS asks exactly once). A no-op where there is no such page (web). */
|
|
15
|
+
openSettings(): void;
|
|
16
|
+
};
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "2.2.
|
|
1
|
+
export declare const SDK_VERSION = "2.2.11";
|
|
2
2
|
/** The major of a semver string, or null when it is not one. */
|
|
3
3
|
export declare const sdkMajor: (version: string | null | undefined) => number | null;
|
|
4
4
|
/** The `// sdk: <version>` line of a compiled bundle's header (sdk/src/compile/header.ts), read from
|