lecodes-sdk 2.2.6 → 2.2.7

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 CHANGED
@@ -15,6 +15,7 @@ declare global {
15
15
  const AudioZone: typeof SDK.AudioZone
16
16
  const Autotile2D: typeof SDK.Autotile2D
17
17
  const Bitmap: typeof SDK.Bitmap
18
+ const Browser: typeof SDK.Browser
18
19
  const Bus: typeof SDK.Bus
19
20
  const Camera: typeof SDK.Camera
20
21
  const Camera2D: typeof SDK.Camera2D
@@ -144,6 +145,7 @@ declare global {
144
145
  const Voice: typeof SDK.Voice
145
146
  const Warp: typeof SDK.Warp
146
147
  const WebSocket: typeof SDK.WebSocket
148
+ const WebView: typeof SDK.WebView
147
149
  const Wheel: typeof SDK.Wheel
148
150
  const __UIBox: typeof SDK.__UIBox
149
151
  const __UIButton: typeof SDK.__UIButton
@@ -238,6 +240,7 @@ declare global {
238
240
  type BlendMember = SDK.BlendMember
239
241
  type BlendPosition = SDK.BlendPosition
240
242
  type BlockEntry = SDK.BlockEntry
243
+ type BrowserOpenOptions = SDK.BrowserOpenOptions
241
244
  type Bus = SDK.Bus
242
245
  type Camera = SDK.Camera
243
246
  type Camera2D = SDK.Camera2D
@@ -581,6 +584,9 @@ declare global {
581
584
  type Warp = SDK.Warp
582
585
  type WarpOptions = SDK.WarpOptions
583
586
  type WebSocket = SDK.WebSocket
587
+ type WebView = SDK.WebView
588
+ type WebViewEvents = SDK.WebViewEvents
589
+ type WebViewParams = SDK.WebViewParams
584
590
  type Wheel = SDK.Wheel
585
591
  type WheelSuspension = SDK.WheelSuspension
586
592
  type WidgetSet<Owner> = SDK.WidgetSet<Owner>
@@ -73,6 +73,7 @@ export { CameraView, type CameraFacing } from "./plugins/gen/camera/sdk/camera";
73
73
  export { Geolocation, type GeoPosition, type GeoOptions, type GeoWatch } from "./plugins/gen/geolocation/sdk/geolocation";
74
74
  export { MapView, type MapOptions, type MapStyle, type MapStyleName, type MapCamera, type MapTap, type LngLat, type CameraMove, type FitOptions, type MapPaddingValues, type MarkerItem, type MarkerTap, type MarkerLayer, type MarkerLayerOptions, type LineLayer, type LineLayerOptions, type UserLocationOptions, } from "./plugins/gen/map/sdk/map";
75
75
  export { Push, type PushPayload, type PushStatus, type PushRegisterOptions, type PushEvent } from "./plugins/gen/push/sdk/push";
76
+ export { Browser, WebView, type BrowserOpenOptions, type WebViewParams, type WebViewEvents } from "./plugins/gen/browser/sdk/browser";
76
77
  export { Service } from "./plugins/service";
77
78
  export { defineScene, use, ref, make, SceneHandle } from "./scene/defineScene";
78
79
  export { defineMaterial, MaterialHandle } from "./scene/material";
@@ -2,6 +2,8 @@ import { File as HostFile } from "./runtime/fetch";
2
2
  import { ServiceClient } from "./runtime/service";
3
3
  import { NativeViewElement } from "./ui/NativeView";
4
4
  export type { PresentOptions } from "./ui/presentable";
5
+ export { Presentable, Router, UIBox, UIButton, UIColumn, UIRow, UIScreen, UIText } from "./ui/UI";
6
+ export { theme } from "./ui/theme";
5
7
  export type { NativeView } from "./ui/NativeView";
6
8
  export type { FetchResponse } from "./runtime/fetch";
7
9
  /** Signed 32-bit integer on the wire. */
@@ -67,6 +69,9 @@ export declare class ServiceChannel<Events extends object = {}> extends ServiceC
67
69
  on<K extends keyof Events & string>(event: K, callback: Listener<Events, K>): this;
68
70
  off<K extends keyof Events & string>(event: K, callback: Listener<Events, K>): this;
69
71
  }
72
+ /** Hear the app's "url" events (a deep link while the app runs — an OAuth redirect, a checkout's
73
+ * return) until the returned function is called. The listener the `app` global fans out from. */
74
+ export declare const _onAppUrl: (callback: (url: string) => void) => (() => void);
70
75
  /** The text of a host buffer — what a bundled `asset()` is in a shell compile (`"id:N"`): the host
71
76
  * already holds the bytes. Empty when there is no such buffer. */
72
77
  export declare const bufferText: (systemId: number) => string;
@@ -0,0 +1,27 @@
1
+ import { ServiceChannel } from "../../../../plugin";
2
+ import type { BrowserEvents, BrowserOpenOptions, BrowserParams, BrowserResult } from "../contract";
3
+ /** What the halves register under. */
4
+ export declare const NAME = "browser";
5
+ /** The contract's version: the highest `@since` of its members. */
6
+ export declare const VERSION = 1;
7
+ /** Show `url` in the system's in-app browser sheet. Resolves when the sheet is dismissed — with
8
+ * the callback URL when the platform intercepted one. One sheet at a time.
9
+ * Rejects with "busy" / "invalid". */
10
+ export declare const show: (service: ServiceChannel<BrowserEvents>, url: string, options?: BrowserOpenOptions) => Promise<BrowserResult>;
11
+ /** Dismiss the sheet; a no-op without one. */
12
+ export declare const dismiss: (service: ServiceChannel<BrowserEvents>) => Promise<void>;
13
+ /** A method of the contract. */
14
+ export type Method = "show" | "dismiss";
15
+ /** Whether this host has the service "browser" — and, given a method, a half new enough for it
16
+ * (a method added after the first version of the contract is tagged `@since`). */
17
+ export declare const supports: (method?: Method) => boolean;
18
+ /** The service "browser" with the wire's methods as its own. */
19
+ export declare class BrowserBase extends ServiceChannel<BrowserEvents> {
20
+ constructor(params?: BrowserParams);
21
+ /** Show `url` in the system's in-app browser sheet. Resolves when the sheet is dismissed — with
22
+ * the callback URL when the platform intercepted one. One sheet at a time.
23
+ * Rejects with "busy" / "invalid". */
24
+ show(url: string, options?: BrowserOpenOptions): Promise<BrowserResult>;
25
+ /** Dismiss the sheet; a no-op without one. */
26
+ dismiss(): Promise<void>;
27
+ }
@@ -0,0 +1,61 @@
1
+ import { ViewChannel, type Json } from "../../../../plugin";
2
+ import type { WebViewEvents, WebViewParams } from "../contract";
3
+ /** What the halves register under. */
4
+ export declare const NAME = "webView";
5
+ /** The contract's version: the highest `@since` of its members. */
6
+ export declare const VERSION = 1;
7
+ /** Load `url`, with extra request headers for the first request.
8
+ * Rejects with "invalid". */
9
+ export declare const load: (view: ViewChannel<WebViewEvents>, url: string, headers?: {
10
+ [key: string]: string;
11
+ }) => Promise<void>;
12
+ /** Show `html` as the page; relative URLs in it resolve against `baseUrl`. */
13
+ export declare const loadHtml: (view: ViewChannel<WebViewEvents>, html: string, baseUrl?: string) => Promise<void>;
14
+ /** Replace the stop list (see WebViewParams.stops). */
15
+ export declare const setStops: (view: ViewChannel<WebViewEvents>, stops: string[]) => Promise<void>;
16
+ export declare const reload: (view: ViewChannel<WebViewEvents>) => Promise<void>;
17
+ /** Stop the current load. */
18
+ export declare const stopLoading: (view: ViewChannel<WebViewEvents>) => Promise<void>;
19
+ export declare const goBack: (view: ViewChannel<WebViewEvents>) => Promise<void>;
20
+ export declare const goForward: (view: ViewChannel<WebViewEvents>) => Promise<void>;
21
+ export declare const canGoBack: (view: ViewChannel<WebViewEvents>) => Promise<boolean>;
22
+ /** Run `js` in the page and return what it evaluates to, as JSON. On iOS this disables Apple Pay
23
+ * in the view until its next navigation.
24
+ * Rejects with "failed". */
25
+ export declare const evaluate: (view: ViewChannel<WebViewEvents>, js: string) => Promise<Json>;
26
+ /** Deliver `data` to the page's `window.lecodes.onMessage(data)` (with `bridge`). */
27
+ export declare const postMessage: (view: ViewChannel<WebViewEvents>, data: Json) => Promise<void>;
28
+ /** Clear the cookies and the storage of this view's session. */
29
+ export declare const clearData: (view: ViewChannel<WebViewEvents>) => Promise<void>;
30
+ /** A method of the contract. */
31
+ export type Method = "load" | "loadHtml" | "setStops" | "reload" | "stopLoading" | "goBack" | "goForward" | "canGoBack" | "evaluate" | "postMessage" | "clearData";
32
+ /** Whether this host has the view "webView" — and, given a method, a half new enough for it
33
+ * (a method added after the first version of the contract is tagged `@since`). */
34
+ export declare const supports: (method?: Method) => boolean;
35
+ /** The view "webView" with the wire's methods as its own. */
36
+ export declare class WebViewBase extends ViewChannel<WebViewEvents> {
37
+ constructor(params?: WebViewParams);
38
+ /** Load `url`, with extra request headers for the first request.
39
+ * Rejects with "invalid". */
40
+ load(url: string, headers?: {
41
+ [key: string]: string;
42
+ }): Promise<void>;
43
+ /** Show `html` as the page; relative URLs in it resolve against `baseUrl`. */
44
+ loadHtml(html: string, baseUrl?: string): Promise<void>;
45
+ /** Replace the stop list (see WebViewParams.stops). */
46
+ setStops(stops: string[]): Promise<void>;
47
+ reload(): Promise<void>;
48
+ /** Stop the current load. */
49
+ stopLoading(): Promise<void>;
50
+ goBack(): Promise<void>;
51
+ goForward(): Promise<void>;
52
+ canGoBack(): Promise<boolean>;
53
+ /** Run `js` in the page and return what it evaluates to, as JSON. On iOS this disables Apple Pay
54
+ * in the view until its next navigation.
55
+ * Rejects with "failed". */
56
+ evaluate(js: string): Promise<Json>;
57
+ /** Deliver `data` to the page's `window.lecodes.onMessage(data)` (with `bridge`). */
58
+ postMessage(data: Json): Promise<void>;
59
+ /** Clear the cookies and the storage of this view's session. */
60
+ clearData(): Promise<void>;
61
+ }
@@ -0,0 +1,71 @@
1
+ import { type Json, type Listener, type NativeView } from "../../../../plugin";
2
+ import { type Method as WebViewMethod } from "./browser.WebView.gen";
3
+ import type { WebViewEvents, WebViewParams } from "../contract";
4
+ export type { WebViewEvents, WebViewParams } from "../contract";
5
+ export interface BrowserOpenOptions {
6
+ /** What ends the page: a URL prefix, or several (a checkout's success and failure URLs). The
7
+ * promise resolves with the URL reached. In the sheet every prefix must share one scheme — the
8
+ * platform intercepts one; a custom scheme needs app.json `urlScheme`, an https one the app's
9
+ * verified links. */
10
+ returnUrl?: string | string[];
11
+ /** Run the page in an embedded WebView under a close bar instead of the system sheet. The
12
+ * WebView intercepts any return URL itself, https included. */
13
+ embedded?: boolean;
14
+ /** A private session: no cookies shared with the system browser, nothing kept after. */
15
+ ephemeral?: boolean;
16
+ /** The sheet's tint, "#RRGGBB". */
17
+ color?: string;
18
+ /** Embedded: the bar's title until the page reports its own. */
19
+ title?: string;
20
+ }
21
+ /** The embedded page — the element of the "webView" view: embeddable among a screen's children,
22
+ * presentable (`open()`, `Router.push`), with the page's controls and events. */
23
+ export interface WebView extends NativeView {
24
+ /** Load `url`, with extra request headers for the first request. Rejects "invalid" for a URL
25
+ * that is not a web one. */
26
+ load(url: string, headers?: {
27
+ [name: string]: string;
28
+ }): Promise<void>;
29
+ /** Show `html` as the page; relative URLs in it resolve against `baseUrl`. */
30
+ loadHtml(html: string, baseUrl?: string): Promise<void>;
31
+ /** Replace the URL prefixes that end a navigation with the `stop` event. */
32
+ setStops(stops: string[]): Promise<void>;
33
+ reload(): Promise<void>;
34
+ /** Stop the current load. */
35
+ stopLoading(): Promise<void>;
36
+ goBack(): Promise<void>;
37
+ goForward(): Promise<void>;
38
+ canGoBack(): Promise<boolean>;
39
+ /** Run `js` in the page and get what it evaluates to, as JSON. On iOS this disables Apple Pay
40
+ * in the view until its next navigation. */
41
+ evaluate(js: string): Promise<Json>;
42
+ /** Deliver `data` to the page's `window.lecodes.onMessage(data)` (a view created with `bridge`). */
43
+ postMessage(data: Json): Promise<void>;
44
+ /** Clear the cookies and the storage of this view's session. */
45
+ clearData(): Promise<void>;
46
+ /** The page's events: `navigate`, `load`, `error`, `stop`, `message`, `exit`. */
47
+ on<K extends keyof WebViewEvents & string>(event: K, callback: Listener<WebViewEvents, K>): this;
48
+ off<K extends keyof WebViewEvents & string>(event: K, callback: Listener<WebViewEvents, K>): this;
49
+ }
50
+ /**
51
+ * Web content inside the app. `Browser.isSupported` reports whether this host registered the
52
+ * system sheet; `WebView.isSupported` the embedded page.
53
+ */
54
+ export declare const Browser: {
55
+ /** Whether this host registered the "browser" service — the system sheet. */
56
+ readonly isSupported: boolean;
57
+ /** Open `url`: in the system sheet, or (`embedded`) in a WebView under a close bar. Resolves
58
+ * with the return URL reached (`returnUrl`), or null when the user left. */
59
+ open(url: string, options?: BrowserOpenOptions): Promise<string | null>;
60
+ };
61
+ /**
62
+ * Create an embedded page. `WebView.isSupported` reports whether this host has the capability —
63
+ * check it before offering the feature.
64
+ */
65
+ export declare const WebView: {
66
+ (params?: WebViewParams): WebView;
67
+ /** Whether this host registered a "webView" view. */
68
+ readonly isSupported: boolean;
69
+ /** Whether the host's half has `method`: false on a host whose half is older than it. */
70
+ supports(method: WebViewMethod): boolean;
71
+ };
@@ -1,4 +1,4 @@
1
- export declare const SDK_VERSION = "2.2.6";
1
+ export declare const SDK_VERSION = "2.2.7";
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