lecodes-sdk 2.4.1 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/types/core/Aspect.d.ts +34 -5
  2. package/dist/types/g2/OneWay2D.d.ts +0 -1
  3. package/dist/types/g2/Physics2D.d.ts +8 -6
  4. package/dist/types/g2/Scene2D.d.ts +1 -1
  5. package/dist/types/g2/Shape2D.d.ts +43 -15
  6. package/dist/types/gl/Model.d.ts +3 -2
  7. package/dist/types/gl/Scene.d.ts +1 -1
  8. package/dist/types/gl/animation/DynamicBone.d.ts +99 -35
  9. package/dist/types/gl/animation/IK.d.ts +0 -1
  10. package/dist/types/gl/nav/NavAgent.d.ts +3 -2
  11. package/dist/types/gl/physics/Physics.d.ts +4 -5
  12. package/dist/types/gl/physics/Shape.d.ts +40 -15
  13. package/dist/types/gl/vehicle/Vehicle.d.ts +54 -35
  14. package/dist/types/gl/vehicle/Wheel.d.ts +31 -10
  15. package/dist/types/plugins/gen/ar/contract.d.ts +152 -0
  16. package/dist/types/plugins/gen/ar/sdk/ar.d.ts +47 -21
  17. package/dist/types/plugins/gen/ar/sdk/ar.gen.d.ts +17 -3
  18. package/dist/types/plugins/gen/audio-recorder/contract.d.ts +64 -0
  19. package/dist/types/plugins/gen/browser/contract.d.ts +108 -0
  20. package/dist/types/plugins/gen/camera/contract.d.ts +27 -0
  21. package/dist/types/plugins/gen/geolocation/contract.d.ts +52 -0
  22. package/dist/types/plugins/gen/map/contract.d.ts +144 -0
  23. package/dist/types/plugins/gen/push/contract.d.ts +83 -0
  24. package/dist/types/plugins/gen/qr-scanner/contract.d.ts +16 -0
  25. package/dist/types/plugins/gen/speech/contract.d.ts +67 -0
  26. package/dist/types/plugins/gen/webrtc/contract.d.ts +342 -0
  27. package/dist/types/version.d.ts +1 -1
  28. package/dist/types.json +1 -1
  29. package/package.json +1 -1
  30. package/src/bridges/gl.d.ts +5 -3
  31. package/src/compile/compileProject.ts +45 -10
  32. package/src/compile/index.ts +7 -0
  33. package/src/compile/webHalf.ts +255 -0
  34. package/src/core/Aspect.ts +118 -35
  35. package/src/g2/OneWay2D.ts +0 -2
  36. package/src/g2/Physics2D.ts +8 -16
  37. package/src/g2/Scene2D.ts +1 -1
  38. package/src/g2/Shape2D.ts +51 -22
  39. package/src/gl/Model.ts +3 -2
  40. package/src/gl/Scene.ts +1 -1
  41. package/src/gl/animation/DynamicBone.ts +549 -486
  42. package/src/gl/animation/IK.ts +0 -2
  43. package/src/gl/nav/NavAgent.ts +14 -12
  44. package/src/gl/physics/Physics.ts +4 -5
  45. package/src/gl/physics/Shape.ts +49 -23
  46. package/src/gl/vehicle/Vehicle.ts +102 -58
  47. package/src/gl/vehicle/Wheel.ts +45 -11
  48. package/src/plugins/gen/ar/contract.d.ts +35 -1
  49. package/src/plugins/gen/ar/sdk/ar.gen.ts +25 -6
  50. package/src/plugins/gen/ar/sdk/ar.ts +102 -35
  51. package/src/version.ts +1 -1
@@ -0,0 +1,342 @@
1
+ // GENERATED by scripts/vendor-plugins.ts from lecodes-plugins/plugins/webrtc/contract.d.ts — do not edit here.
2
+ // Change it in the plugin repo and run `bun run vendor:plugins`; `bun run check:plugins` fails when this copy is stale.
3
+ // webrtc — real-time audio, video and data between peers, over libwebrtc on iOS and Android and
4
+ // the browser's own stack on the web. The wire is the W3C API, cut at the objects: a peer
5
+ // connection is a SESSION of the "rtcPeerConnection" service (its params are the configuration,
6
+ // the SDK's close() is RTCPeerConnection.close()), the media devices are the "rtcMedia" service,
7
+ // and a track is drawn by the "rtcVideo" view. Tracks, senders, transceivers and data channels
8
+ // live in the host; what crosses is an id the host allocated. A remote track (the `track` event)
9
+ // is a track like any other: the view shows it, another connection can forward it.
10
+ //
11
+ // Signaling is NOT here: the app carries the descriptions and the candidates over its own
12
+ // channel (a WebSocket). The halves are dumb on purpose — no room, no call, no server — so that a
13
+ // client of an SFU (mediasoup-client, LiveKit's) can run in the app's bundle over this wire.
14
+ //
15
+ // The app-facing API (sdk/) is the browser's: RTCPeerConnection, MediaStream, MediaStreamTrack,
16
+ // RTCDataChannel, mediaDevices.getUserMedia(), plus RTCVideoView for the picture.
17
+
18
+ import type { Json, Service, View, f64, i32 } from "../../../plugin"
19
+
20
+ // ---- media ----------------------------------------------------------------------------------------
21
+
22
+ export type MediaKind = "audio" | "video"
23
+ /** The browser's facingMode values: "user" is the front camera, "environment" the back one. */
24
+ export type FacingMode = "user" | "environment"
25
+ export type DeviceKind = "audioinput" | "audiooutput" | "videoinput"
26
+ /** Where the call's audio plays on a phone. */
27
+ export type AudioOutput = "earpiece" | "speaker"
28
+
29
+ export interface AudioConstraints {
30
+ /** A device of enumerateDevices(); the default input when absent. */
31
+ deviceId?: string
32
+ /** Default true. */
33
+ echoCancellation?: boolean
34
+ /** Default true. */
35
+ noiseSuppression?: boolean
36
+ /** Default true. */
37
+ autoGainControl?: boolean
38
+ }
39
+
40
+ export interface VideoConstraints {
41
+ /** A device of enumerateDevices(); wins over facingMode. */
42
+ deviceId?: string
43
+ /** Default "user". */
44
+ facingMode?: FacingMode
45
+ /** The capture size wanted; the host picks the closest format the camera has. Default 1280×720. */
46
+ width?: i32
47
+ height?: i32
48
+ /** Default 30. */
49
+ frameRate?: f64
50
+ }
51
+
52
+ /** What to capture: a kind present = wanted (the wrapper turns the browser's `audio: true` into `{}`). */
53
+ export interface MediaConstraints {
54
+ audio?: AudioConstraints
55
+ video?: VideoConstraints
56
+ }
57
+
58
+ export interface TrackInfo {
59
+ /** The host's id of the track — what every call names it by. */
60
+ id: string
61
+ kind: MediaKind
62
+ /** The device's name for a local track, the remote msid for a received one. */
63
+ label: string
64
+ enabled: boolean
65
+ /** A received track the sender has muted (no media is arriving). Default false. */
66
+ muted?: boolean
67
+ }
68
+
69
+ export interface StreamInfo {
70
+ id: string
71
+ tracks: TrackInfo[]
72
+ }
73
+
74
+ export interface DeviceInfo {
75
+ deviceId: string
76
+ kind: DeviceKind
77
+ label: string
78
+ /** A camera's side, when the platform tells. */
79
+ facing?: FacingMode
80
+ }
81
+
82
+ /** What a local video track captures with, after the constraints were applied. */
83
+ export interface TrackSettings {
84
+ deviceId?: string
85
+ facingMode?: FacingMode
86
+ width?: i32
87
+ height?: i32
88
+ frameRate?: f64
89
+ }
90
+
91
+ export interface RtcMediaParams {}
92
+
93
+ export interface RtcMediaEvents {
94
+ /** A device was plugged in or removed (a headset, a camera). */
95
+ deviceChange: void
96
+ /** A local track ended on its own: the OS took the device (a call came in, the camera was claimed). */
97
+ trackEnded: { trackId: string }
98
+ }
99
+
100
+ /** The devices: capture, the device list, the audio route. One session for the app. */
101
+ export interface RtcMedia extends Service<"rtcMedia", RtcMediaParams, RtcMediaEvents> {
102
+ /** Capture: prompts for the permissions it needs, resolves with a stream of the new tracks.
103
+ * @rejects denied notFound failed */
104
+ getUserMedia(constraints: MediaConstraints): Promise<StreamInfo>
105
+ /** The devices the host can capture with (labels need a granted permission on the web). */
106
+ enumerateDevices(): Promise<DeviceInfo[]>
107
+ /** A disabled track sends silence / black frames and stays in every connection. @rejects notFound */
108
+ setTrackEnabled(trackId: string, enabled: boolean): Promise<void>
109
+ /** Re-aim a local video track: the other camera, another size or rate. The track and its id
110
+ * stay; every connection keeps sending it. @rejects notFound failed */
111
+ applyConstraints(trackId: string, constraints: VideoConstraints): Promise<void>
112
+ /** @rejects notFound */
113
+ getTrackSettings(trackId: string): Promise<TrackSettings>
114
+ /** End a track: the device is released once no track of it is left, every sender of it goes
115
+ * quiet, the id is forgotten. A no-op for an unknown id. */
116
+ stopTrack(trackId: string): Promise<void>
117
+ /** Route the audio of the call: the earpiece (the default while a wired or Bluetooth headset is
118
+ * not connected) or the loudspeaker. A no-op on the web. */
119
+ setAudioOutput(output: AudioOutput): Promise<void>
120
+ }
121
+
122
+ // ---- the peer connection --------------------------------------------------------------------------
123
+
124
+ export interface IceServer {
125
+ urls: string[]
126
+ username?: string
127
+ credential?: string
128
+ }
129
+
130
+ export type IceTransportPolicy = "all" | "relay"
131
+ export type BundlePolicy = "balanced" | "max-compat" | "max-bundle"
132
+
133
+ /** The RTCConfiguration — the params of a session, and what setConfiguration takes. */
134
+ export interface RtcConfiguration {
135
+ iceServers?: IceServer[]
136
+ /** Default "all". */
137
+ iceTransportPolicy?: IceTransportPolicy
138
+ /** Default "balanced". */
139
+ bundlePolicy?: BundlePolicy
140
+ /** Default 0. */
141
+ iceCandidatePoolSize?: i32
142
+ }
143
+
144
+ export type SdpType = "offer" | "answer" | "pranswer" | "rollback"
145
+
146
+ export interface SessionDescription {
147
+ type: SdpType
148
+ sdp: string
149
+ }
150
+
151
+ export interface IceCandidate {
152
+ candidate: string
153
+ sdpMid: string | null
154
+ sdpMLineIndex: i32 | null
155
+ usernameFragment?: string
156
+ }
157
+
158
+ export interface OfferOptions {
159
+ iceRestart?: boolean
160
+ offerToReceiveAudio?: boolean
161
+ offerToReceiveVideo?: boolean
162
+ }
163
+
164
+ export type SignalingState = "stable" | "have-local-offer" | "have-remote-offer" | "have-local-pranswer" | "have-remote-pranswer" | "closed"
165
+ export type IceGatheringState = "new" | "gathering" | "complete"
166
+ export type IceConnectionState = "new" | "checking" | "connected" | "completed" | "failed" | "disconnected" | "closed"
167
+ export type PeerConnectionState = "new" | "connecting" | "connected" | "disconnected" | "failed" | "closed"
168
+ export type TransceiverDirection = "sendrecv" | "sendonly" | "recvonly" | "inactive" | "stopped"
169
+
170
+ /** One encoding of a sender (a simulcast layer when there are several, each with a `rid`). */
171
+ export interface Encoding {
172
+ rid?: string
173
+ /** Default true. */
174
+ active?: boolean
175
+ /** Bits per second. */
176
+ maxBitrate?: i32
177
+ maxFramerate?: f64
178
+ /** 2 = half the width and the height. */
179
+ scaleResolutionDownBy?: f64
180
+ }
181
+
182
+ export interface SenderParameters {
183
+ encodings: Encoding[]
184
+ }
185
+
186
+ export interface TransceiverInit {
187
+ /** Default "sendrecv". */
188
+ direction?: TransceiverDirection
189
+ /** A local track to send from the start. */
190
+ trackId?: string
191
+ streamIds?: string[]
192
+ /** The simulcast layers (an SFU client's): one encoding each, with a rid. */
193
+ sendEncodings?: Encoding[]
194
+ }
195
+
196
+ export interface SenderInfo {
197
+ id: string
198
+ trackId: string | null
199
+ }
200
+
201
+ export interface TransceiverInfo {
202
+ id: string
203
+ mid: string | null
204
+ direction: TransceiverDirection
205
+ currentDirection: TransceiverDirection | null
206
+ sender: SenderInfo
207
+ /** The receiver's track exists from the start (before any media arrives). */
208
+ receiverTrack: TrackInfo
209
+ stopped: boolean
210
+ }
211
+
212
+ export interface DataChannelInit {
213
+ /** Default true. */
214
+ ordered?: boolean
215
+ maxPacketLifeTime?: i32
216
+ maxRetransmits?: i32
217
+ /** Default "". */
218
+ protocol?: string
219
+ /** Default false. */
220
+ negotiated?: boolean
221
+ /** The SCTP stream id of a negotiated channel. */
222
+ id?: i32
223
+ }
224
+
225
+ export type DataChannelState = "connecting" | "open" | "closing" | "closed"
226
+
227
+ export interface DataChannelInfo {
228
+ /** The host's id of the channel — what every call names it by. */
229
+ id: string
230
+ label: string
231
+ ordered: boolean
232
+ maxPacketLifeTime: i32 | null
233
+ maxRetransmits: i32 | null
234
+ protocol: string
235
+ negotiated: boolean
236
+ /** The SCTP stream id; null until the transport assigned one. */
237
+ streamId: i32 | null
238
+ readyState: DataChannelState
239
+ }
240
+
241
+ export interface RtcPeerConnectionEvents {
242
+ negotiationNeeded: void
243
+ /** A local candidate for the other side; null = the gathering of this round is complete. */
244
+ iceCandidate: { candidate: IceCandidate | null }
245
+ signalingStateChange: { state: SignalingState }
246
+ iceGatheringStateChange: { state: IceGatheringState }
247
+ iceConnectionStateChange: { state: IceConnectionState }
248
+ connectionStateChange: { state: PeerConnectionState }
249
+ /** A remote track arrived: the receiver's track of `transceiverId`, in the streams the other
250
+ * side put it in. */
251
+ track: { track: TrackInfo, streamIds: string[], transceiverId: string }
252
+ /** A received track went mute (nothing arrives) or came back. */
253
+ trackMute: { trackId: string, muted: boolean }
254
+ /** A received track ended: the other side removed it, or the connection closed. */
255
+ trackEnded: { trackId: string }
256
+ /** The other side opened a data channel. */
257
+ dataChannel: DataChannelInfo
258
+ dataChannelStateChange: { id: string, state: DataChannelState }
259
+ /** One message: `text` for a string, `binary` for bytes — exactly one of the two. */
260
+ dataChannelMessage: { id: string, text?: string, binary?: Uint8Array }
261
+ dataChannelError: { id: string, message: string }
262
+ /** The buffered amount fell to the threshold or under it. */
263
+ dataChannelBufferedAmountLow: { id: string }
264
+ }
265
+
266
+ /** One RTCPeerConnection: a session, created with its configuration, closed by the SDK's close(). */
267
+ export interface RtcPeerConnection extends Service<"rtcPeerConnection", RtcConfiguration, RtcPeerConnectionEvents> {
268
+ /** @rejects failed closed */
269
+ createOffer(options?: OfferOptions): Promise<SessionDescription>
270
+ /** @rejects failed closed */
271
+ createAnswer(): Promise<SessionDescription>
272
+ /** Without a description: the implicit form — an answer when a remote offer is pending, an
273
+ * offer otherwise. Resolves with the description now in force (the one to signal).
274
+ * @rejects failed closed */
275
+ setLocalDescription(description?: SessionDescription): Promise<SessionDescription>
276
+ /** @rejects failed closed */
277
+ setRemoteDescription(description: SessionDescription): Promise<void>
278
+ /** Without a candidate: the end of the remote candidates. @rejects failed closed */
279
+ addIceCandidate(candidate?: IceCandidate): Promise<void>
280
+ /** The next offer carries new ICE credentials. */
281
+ restartIce(): Promise<void>
282
+ /** @rejects failed */
283
+ setConfiguration(configuration: RtcConfiguration): Promise<void>
284
+ /** Send a local track, in the streams named (one is made up when none is). @rejects notFound failed closed */
285
+ addTrack(trackId: string, streamIds?: string[]): Promise<SenderInfo>
286
+ /** @rejects notFound closed */
287
+ removeTrack(senderId: string): Promise<void>
288
+ /** Swap what a sender sends without renegotiating; null = send nothing. @rejects notFound failed closed */
289
+ replaceTrack(senderId: string, trackId: string | null): Promise<void>
290
+ /** @rejects notFound */
291
+ getSenderParameters(senderId: string): Promise<SenderParameters>
292
+ /** The encodings' active / bitrate / scale; the layers themselves are set at addTransceiver. @rejects notFound failed */
293
+ setSenderParameters(senderId: string, parameters: SenderParameters): Promise<void>
294
+ /** @rejects notFound failed closed */
295
+ addTransceiver(kind: MediaKind, options?: TransceiverInit): Promise<TransceiverInfo>
296
+ getTransceivers(): Promise<TransceiverInfo[]>
297
+ /** @rejects notFound failed */
298
+ setTransceiverDirection(transceiverId: string, direction: TransceiverDirection): Promise<void>
299
+ /** @rejects notFound */
300
+ stopTransceiver(transceiverId: string): Promise<void>
301
+ /** The RTCStatsReport as an object: the stats id → the stats object (`type`, `timestamp` in ms,
302
+ * the fields of its type). For one track's senders / receivers when `trackId` is given. */
303
+ getStats(trackId?: string): Promise<Json>
304
+ /** @rejects failed closed */
305
+ createDataChannel(label: string, options?: DataChannelInit): Promise<DataChannelInfo>
306
+ /** @rejects notFound closed */
307
+ sendText(channelId: string, text: string): Promise<void>
308
+ /** @rejects notFound closed */
309
+ sendBinary(channelId: string, data: Uint8Array): Promise<void>
310
+ /** Bytes queued and not yet sent. @rejects notFound */
311
+ getBufferedAmount(channelId: string): Promise<f64>
312
+ /** @rejects notFound */
313
+ setBufferedAmountLowThreshold(channelId: string, threshold: f64): Promise<void>
314
+ /** A no-op for an unknown id. */
315
+ closeDataChannel(channelId: string): Promise<void>
316
+ }
317
+
318
+ // ---- the picture ----------------------------------------------------------------------------------
319
+
320
+ export type ObjectFit = "cover" | "contain"
321
+
322
+ export interface RtcVideoParams {
323
+ /** The track to draw; none = black. */
324
+ trackId?: string
325
+ /** Default "cover". */
326
+ objectFit?: ObjectFit
327
+ /** Flip horizontally — the front camera's preview. Default false. */
328
+ mirror?: boolean
329
+ }
330
+
331
+ export interface RtcVideoEvents {
332
+ /** The first frame was drawn, and every change of the picture's size after. */
333
+ resize: { width: i32, height: i32 }
334
+ }
335
+
336
+ /** A view drawing one video track, local or remote. */
337
+ export interface RtcVideo extends View<"rtcVideo", RtcVideoParams, RtcVideoEvents> {
338
+ /** Draw another track; null = black. @rejects notFound */
339
+ setTrack(trackId: string | null): Promise<void>
340
+ setObjectFit(fit: ObjectFit): Promise<void>
341
+ setMirror(mirror: boolean): Promise<void>
342
+ }
@@ -1,4 +1,4 @@
1
- export declare const SDK_VERSION = "2.4.1";
1
+ export declare const SDK_VERSION = "2.4.2";
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