@qontinui/ui-bridge-wrapper 0.1.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 +52 -0
- package/dist/base-transport.d.ts +54 -0
- package/dist/base-transport.d.ts.map +1 -0
- package/dist/create-transport.d.ts +12 -0
- package/dist/create-transport.d.ts.map +1 -0
- package/dist/handler-registry.d.ts +42 -0
- package/dist/handler-registry.d.ts.map +1 -0
- package/dist/helpers/auth.d.ts +18 -0
- package/dist/helpers/auth.d.ts.map +1 -0
- package/dist/helpers/retry.d.ts +28 -0
- package/dist/helpers/retry.d.ts.map +1 -0
- package/dist/helpers/schema.d.ts +35 -0
- package/dist/helpers/schema.d.ts.map +1 -0
- package/dist/index.cjs +655 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +641 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest-only.d.ts +100 -0
- package/dist/manifest-only.d.ts.map +1 -0
- package/dist/react/WrapperAppShell.d.ts +25 -0
- package/dist/react/WrapperAppShell.d.ts.map +1 -0
- package/dist/react/index.cjs +63 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.ts +13 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +59 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/useTransportSelector.d.ts +30 -0
- package/dist/react/useTransportSelector.d.ts.map +1 -0
- package/dist/react/useWrapperStatus.d.ts +11 -0
- package/dist/react/useWrapperStatus.d.ts.map +1 -0
- package/dist/transports/api.d.ts +39 -0
- package/dist/transports/api.d.ts.map +1 -0
- package/dist/transports/headed.d.ts +15 -0
- package/dist/transports/headed.d.ts.map +1 -0
- package/dist/transports/headless.d.ts +69 -0
- package/dist/transports/headless.d.ts.map +1 -0
- package/dist/transports/live.d.ts +97 -0
- package/dist/transports/live.d.ts.map +1 -0
- package/dist/types.d.ts +102 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HeadlessTransport
|
|
3
|
+
*
|
|
4
|
+
* Wraps `@qontinui/ui-bridge-headless`'s `launchHeadlessTab` to own a
|
|
5
|
+
* Playwright Chromium lifecycle. The transport's job is lifecycle only:
|
|
6
|
+
*
|
|
7
|
+
* - Launch the browser on `ready()` and navigate to `options.targetUrl`.
|
|
8
|
+
* - Expose the `page` / `context` / `browser` via a `HeadlessContext`
|
|
9
|
+
* that each handler receives.
|
|
10
|
+
* - Close everything on `close()`.
|
|
11
|
+
*
|
|
12
|
+
* Action code lives in the wrapper's handler registrations, not in the
|
|
13
|
+
* transport. Headless and headed differ only in the `headless` flag.
|
|
14
|
+
*/
|
|
15
|
+
import type { Browser, BrowserContext, Page } from 'playwright';
|
|
16
|
+
import { BaseTransport } from '../base-transport.js';
|
|
17
|
+
import { HandlerRegistry } from '../handler-registry.js';
|
|
18
|
+
import type { TransportConfig, WrapperTransportKind } from '../types.js';
|
|
19
|
+
/** Options extracted from `TransportConfig.options` for headless/headed. */
|
|
20
|
+
export interface HeadlessTransportOptions {
|
|
21
|
+
/** URL to navigate to on first `ready()`. Required. */
|
|
22
|
+
targetUrl: string;
|
|
23
|
+
/** Viewport width in px. Defaults to 1280. */
|
|
24
|
+
viewportWidth?: number;
|
|
25
|
+
/** Viewport height in px. Defaults to 720. */
|
|
26
|
+
viewportHeight?: number;
|
|
27
|
+
/**
|
|
28
|
+
* UI Bridge relay base URL. If provided, `ready()` blocks until the relay
|
|
29
|
+
* confirms the tab registered. Mirrors `launchHeadlessTab` behavior.
|
|
30
|
+
*/
|
|
31
|
+
uiBridgeBase?: string;
|
|
32
|
+
/** Max time to wait for UI Bridge registration. Defaults to 30 000. */
|
|
33
|
+
waitForUiBridgeMs?: number;
|
|
34
|
+
/** User agent override. */
|
|
35
|
+
userAgent?: string;
|
|
36
|
+
/** Forward browser console/page errors to the Node process stderr. */
|
|
37
|
+
forwardConsole?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/** Context shape delivered to each headless/headed handler. */
|
|
40
|
+
export interface HeadlessContext {
|
|
41
|
+
readonly kind: 'headless' | 'headed';
|
|
42
|
+
readonly page: Page;
|
|
43
|
+
readonly browserContext: BrowserContext;
|
|
44
|
+
readonly browser: Browser;
|
|
45
|
+
/** True once the UI Bridge relay confirmed the tab is registered. */
|
|
46
|
+
readonly uiBridgeRegistered: boolean;
|
|
47
|
+
/** Relay-assigned tab id, when known. */
|
|
48
|
+
readonly tabId: string | null;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Shared implementation used by both `HeadlessTransport` and
|
|
52
|
+
* `HeadedTransport` — they differ only in the `headless` launch flag and
|
|
53
|
+
* their reported `kind`.
|
|
54
|
+
*/
|
|
55
|
+
export declare class HeadlessTransport extends BaseTransport {
|
|
56
|
+
readonly kind: WrapperTransportKind;
|
|
57
|
+
protected readonly options: HeadlessTransportOptions;
|
|
58
|
+
protected readonly headless: boolean;
|
|
59
|
+
private tab;
|
|
60
|
+
constructor(config: TransportConfig, registry?: HandlerRegistry, overrides?: {
|
|
61
|
+
kind?: WrapperTransportKind;
|
|
62
|
+
headless?: boolean;
|
|
63
|
+
});
|
|
64
|
+
private parseOptions;
|
|
65
|
+
protected onReady(): Promise<void>;
|
|
66
|
+
protected onClose(): Promise<void>;
|
|
67
|
+
protected buildContext(): Promise<HeadlessContext>;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=headless.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headless.d.ts","sourceRoot":"","sources":["../../src/transports/headless.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,eA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,CAAC,EAAE,OAAO,CAAA;KAAO;IAQrE,OAAO,CAAC,YAAY;cA2BJ,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;cA4BxB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;cAOxB,YAAY,IAAI,OAAO,CAAC,eAAe,CAAC;CAgBzD"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LiveSessionTransport
|
|
3
|
+
*
|
|
4
|
+
* Connects to the qontinui runner's wrapper-session WebSocket endpoint,
|
|
5
|
+
* registers as a wrapper instance, and translates incoming `command`
|
|
6
|
+
* frames into local handler invocations. Responses flow back as
|
|
7
|
+
* `response` frames matched by `commandId`.
|
|
8
|
+
*
|
|
9
|
+
* Frame shapes match the Phase 1 runner protocol:
|
|
10
|
+
*
|
|
11
|
+
* client -> server:
|
|
12
|
+
* { "type": "register", "transport": "websocket",
|
|
13
|
+
* "appId", "appName", "appType",
|
|
14
|
+
* "framework"?, "version"?, "capabilities"?,
|
|
15
|
+
* "origin"?, "pageUrl"? }
|
|
16
|
+
* { "type": "response", "commandId", "success", "result"?, "error"? }
|
|
17
|
+
*
|
|
18
|
+
* server -> client:
|
|
19
|
+
* { "type": "registered", "appId", "connId", "acceptedAt" }
|
|
20
|
+
* { "type": "command", "commandId", "action", "payload"? }
|
|
21
|
+
*
|
|
22
|
+
* The transport also exposes `dispatch` for direct, self-issued commands —
|
|
23
|
+
* useful in tests and in wrappers that want to invoke their own actions
|
|
24
|
+
* without round-tripping through the runner.
|
|
25
|
+
*/
|
|
26
|
+
import { BaseTransport } from '../base-transport.js';
|
|
27
|
+
import { HandlerRegistry } from '../handler-registry.js';
|
|
28
|
+
import type { TransportConfig, WrapperTransportKind } from '../types.js';
|
|
29
|
+
/** Options extracted from `TransportConfig.options` for the live transport. */
|
|
30
|
+
export interface LiveTransportOptions {
|
|
31
|
+
/** Max time to wait for the server ack after `register`. Defaults to 10 000 ms. */
|
|
32
|
+
handshakeTimeoutMs?: number;
|
|
33
|
+
/** Bearer token for the `Authorization` header on the WebSocket upgrade. */
|
|
34
|
+
authToken?: string;
|
|
35
|
+
/**
|
|
36
|
+
* App-type identifier — required by the runner's `RegisterFrame` schema
|
|
37
|
+
* (`mcp/ws_relay.rs`). Common values: `"web"`, `"mobile"`, `"native"`,
|
|
38
|
+
* `"extension"`, `"wrapper"`. Defaults to `"wrapper"` when not provided.
|
|
39
|
+
*/
|
|
40
|
+
appType?: string;
|
|
41
|
+
/** UI framework hint forwarded to `app_registry` (e.g. `"react"`, `"vue"`). */
|
|
42
|
+
framework?: string;
|
|
43
|
+
/** Wrapper version forwarded to `app_registry`. */
|
|
44
|
+
version?: string;
|
|
45
|
+
/** Capability strings forwarded to `app_registry` (informational). */
|
|
46
|
+
capabilities?: string[];
|
|
47
|
+
/** Origin URL forwarded to `app_registry` (informational). */
|
|
48
|
+
origin?: string;
|
|
49
|
+
/** Page URL forwarded to `app_registry` (informational). */
|
|
50
|
+
pageUrl?: string;
|
|
51
|
+
}
|
|
52
|
+
/** Context delivered to live-session handlers. */
|
|
53
|
+
export interface LiveContext {
|
|
54
|
+
readonly kind: 'live';
|
|
55
|
+
/** commandId the runner attached to this dispatch, if any. */
|
|
56
|
+
readonly commandId: string | null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Minimal WebSocket contract, intersection of browser `WebSocket` and
|
|
60
|
+
* `ws.WebSocket`. Keeps the transport usable in both Node and browser
|
|
61
|
+
* without pulling `ws` as a hard dep.
|
|
62
|
+
*/
|
|
63
|
+
interface MinimalWebSocket {
|
|
64
|
+
readonly readyState: number;
|
|
65
|
+
send(data: string): void;
|
|
66
|
+
close(code?: number, reason?: string): void;
|
|
67
|
+
addEventListener(type: 'open', listener: () => void): void;
|
|
68
|
+
addEventListener(type: 'close', listener: () => void): void;
|
|
69
|
+
addEventListener(type: 'error', listener: (ev: unknown) => void): void;
|
|
70
|
+
addEventListener(type: 'message', listener: (ev: {
|
|
71
|
+
data: unknown;
|
|
72
|
+
}) => void): void;
|
|
73
|
+
}
|
|
74
|
+
type WebSocketCtor = new (url: string, protocols?: string | string[]) => MinimalWebSocket;
|
|
75
|
+
export declare class LiveSessionTransport extends BaseTransport {
|
|
76
|
+
readonly kind: WrapperTransportKind;
|
|
77
|
+
private readonly url;
|
|
78
|
+
private readonly appId?;
|
|
79
|
+
private readonly appName?;
|
|
80
|
+
private readonly opts;
|
|
81
|
+
private readonly wsCtor;
|
|
82
|
+
private ws;
|
|
83
|
+
private ackResolvers;
|
|
84
|
+
constructor(config: TransportConfig, registry?: HandlerRegistry, injected?: {
|
|
85
|
+
webSocketCtor?: WebSocketCtor;
|
|
86
|
+
});
|
|
87
|
+
protected onReady(): Promise<void>;
|
|
88
|
+
protected onClose(): Promise<void>;
|
|
89
|
+
protected buildContext(): Promise<LiveContext>;
|
|
90
|
+
private handleMessage;
|
|
91
|
+
private handleCommand;
|
|
92
|
+
private handleClose;
|
|
93
|
+
private handleError;
|
|
94
|
+
private extractErrorMessage;
|
|
95
|
+
}
|
|
96
|
+
export {};
|
|
97
|
+
//# sourceMappingURL=live.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live.d.ts","sourceRoot":"","sources":["../../src/transports/live.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGzE,+EAA+E;AAC/E,MAAM,WAAW,oBAAoB;IACnC,mFAAmF;IACnF,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+EAA+E;IAC/E,SAAS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C,IAAI,EAAE,oBAAoB,CAAU;IAE7C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAuB;IAC5C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IAEvC,OAAO,CAAC,EAAE,CAAiC;IAC3C,OAAO,CAAC,YAAY,CAIJ;gBAGd,MAAM,EAAE,eAAe,EACvB,QAAQ,CAAC,EAAE,eAAe,EAC1B,QAAQ,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,aAAa,CAAA;KAAE;cA2B9B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;cA6CxB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;cAmBxB,YAAY,IAAI,OAAO,CAAC,WAAW,CAAC;IAIpD,OAAO,CAAC,aAAa;YAqCP,aAAa;IA6B3B,OAAO,CAAC,WAAW;IAYnB,OAAO,CAAC,WAAW;IAanB,OAAO,CAAC,mBAAmB;CAQ5B"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public type surface for `@qontinui/ui-bridge-wrapper`.
|
|
3
|
+
*
|
|
4
|
+
* Wrapper apps pick a single transport (api / headless / headed / live) at
|
|
5
|
+
* runtime but ship the same action code against every one of them. Every
|
|
6
|
+
* concrete transport implements `WrapperTransport` and dispatches action
|
|
7
|
+
* ids to handlers registered on a shared `HandlerRegistry`.
|
|
8
|
+
*/
|
|
9
|
+
import type { HandlerRegistry, WrapperHandler } from './handler-registry.js';
|
|
10
|
+
/** Supported transport kinds for a wrapper runtime. */
|
|
11
|
+
export type WrapperTransportKind = 'api' | 'headless' | 'headed' | 'live';
|
|
12
|
+
/** Transport lifecycle states surfaced to callers (and React via `useWrapperStatus`). */
|
|
13
|
+
export type WrapperTransportStatus = 'idle' | 'connecting' | 'ready' | 'error' | 'closed';
|
|
14
|
+
/** Configuration accepted by `createTransport`. */
|
|
15
|
+
export interface TransportConfig {
|
|
16
|
+
/** Which transport to spin up. */
|
|
17
|
+
kind: WrapperTransportKind;
|
|
18
|
+
/**
|
|
19
|
+
* Runner WebSocket URL. Required for the `live` transport. Ignored by
|
|
20
|
+
* `api`, `headless`, and `headed` — they run locally.
|
|
21
|
+
*/
|
|
22
|
+
runnerUrl?: string;
|
|
23
|
+
/** Stable app id used on the runner registry (live transport). */
|
|
24
|
+
appId?: string;
|
|
25
|
+
/** Friendly display name used on the runner registry (live transport). */
|
|
26
|
+
appName?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Per-transport options. Shape depends on `kind`:
|
|
29
|
+
* - `api`: `{ handler?: (actionId, params) => unknown }` — convenience only;
|
|
30
|
+
* prefer registering handlers via the returned transport's
|
|
31
|
+
* `handlerRegistry.register(...)`.
|
|
32
|
+
* - `headless` / `headed`:
|
|
33
|
+
* `{ targetUrl: string; viewportWidth?: number; viewportHeight?: number;
|
|
34
|
+
* uiBridgeBase?: string; forwardConsole?: boolean }`
|
|
35
|
+
* - `live`: `{ handshakeTimeoutMs?: number; authToken?: string }`
|
|
36
|
+
*/
|
|
37
|
+
options?: Record<string, unknown>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Normalized response envelope. Transports may choose to use this as their
|
|
41
|
+
* dispatch return type for wrappers that prefer to branch on `success`
|
|
42
|
+
* rather than catch thrown errors. Our transports throw on error by default
|
|
43
|
+
* (closer to idiomatic JS); wrappers can wrap calls in `tryCommand` below
|
|
44
|
+
* if they want an envelope instead.
|
|
45
|
+
*/
|
|
46
|
+
export interface CommandResponse<T = unknown> {
|
|
47
|
+
success: boolean;
|
|
48
|
+
result?: T;
|
|
49
|
+
error?: {
|
|
50
|
+
code: string;
|
|
51
|
+
message: string;
|
|
52
|
+
retryable?: boolean;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Contract every transport implements.
|
|
57
|
+
*
|
|
58
|
+
* `dispatch` resolves with the handler's return value on success, or throws
|
|
59
|
+
* a `WrapperTransportError` on failure. Status transitions are observable
|
|
60
|
+
* via `onStatusChange`.
|
|
61
|
+
*/
|
|
62
|
+
export interface WrapperTransport {
|
|
63
|
+
readonly kind: WrapperTransportKind;
|
|
64
|
+
readonly status: WrapperTransportStatus;
|
|
65
|
+
/**
|
|
66
|
+
* The handler registry the transport dispatches through. Wrapper code
|
|
67
|
+
* registers action handlers here during setup:
|
|
68
|
+
*
|
|
69
|
+
* transport.handlerRegistry.register("list-unread", async (params, ctx) => {...});
|
|
70
|
+
*
|
|
71
|
+
* Equivalent to calling `transport.register(actionId, fn)` directly.
|
|
72
|
+
*/
|
|
73
|
+
readonly handlerRegistry: HandlerRegistry;
|
|
74
|
+
/** Convenience — delegates to `handlerRegistry.register`. */
|
|
75
|
+
register<TParams = unknown, TResult = unknown, TCtx = unknown>(actionId: string, fn: WrapperHandler<TParams, TResult, TCtx>): void;
|
|
76
|
+
/** Complete any async setup (browser launch, websocket handshake). */
|
|
77
|
+
ready(): Promise<void>;
|
|
78
|
+
/** Invoke a registered action by id. */
|
|
79
|
+
dispatch<TResult = unknown>(actionId: string, params?: unknown): Promise<TResult>;
|
|
80
|
+
/** Tear everything down. Safe to call multiple times. */
|
|
81
|
+
close(): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Subscribe to status transitions. Returns an unsubscribe function that
|
|
84
|
+
* consumers must call on unmount / shutdown.
|
|
85
|
+
*/
|
|
86
|
+
onStatusChange(listener: (s: WrapperTransportStatus) => void): () => void;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Structured error emitted by transport dispatch. Concrete transports
|
|
90
|
+
* throw these so callers can introspect `code` / `retryable` without
|
|
91
|
+
* string-matching error messages.
|
|
92
|
+
*/
|
|
93
|
+
export declare class WrapperTransportError extends Error {
|
|
94
|
+
readonly code: string;
|
|
95
|
+
readonly retryable: boolean;
|
|
96
|
+
readonly cause?: unknown;
|
|
97
|
+
constructor(code: string, message: string, options?: {
|
|
98
|
+
retryable?: boolean;
|
|
99
|
+
cause?: unknown;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE7E,uDAAuD;AACvD,MAAM,MAAM,oBAAoB,GAAG,KAAK,GAAG,UAAU,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE1E,yFAAyF;AACzF,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,YAAY,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE1F,mDAAmD;AACnD,MAAM,WAAW,eAAe;IAC9B,kCAAkC;IAClC,IAAI,EAAE,oBAAoB,CAAC;IAC3B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kEAAkE;IAClE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,OAAO;IAC1C,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,CAAC;IACX,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CAChE;AAED;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;I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for building UI Bridge wrapper apps — transport-agnostic semantic actions.",
|
|
5
|
+
"main": "./dist/index.cjs",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./react": {
|
|
16
|
+
"types": "./dist/react/index.d.ts",
|
|
17
|
+
"import": "./dist/react/index.js",
|
|
18
|
+
"require": "./dist/react/index.cjs"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"README.md"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsup && tsc -p tsconfig.build.json",
|
|
27
|
+
"dev": "tsup --watch",
|
|
28
|
+
"typecheck": "tsc --noEmit",
|
|
29
|
+
"test": "vitest run",
|
|
30
|
+
"clean": "rimraf dist"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"ui-bridge",
|
|
34
|
+
"wrapper",
|
|
35
|
+
"automation",
|
|
36
|
+
"transport",
|
|
37
|
+
"playwright",
|
|
38
|
+
"websocket"
|
|
39
|
+
],
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "https://github.com/qontinui/ui-bridge.git",
|
|
44
|
+
"directory": "packages/ui-bridge-wrapper"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"@qontinui/ui-bridge": "*",
|
|
48
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
49
|
+
},
|
|
50
|
+
"peerDependenciesMeta": {
|
|
51
|
+
"react": {
|
|
52
|
+
"optional": true
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@qontinui/ui-bridge-headless": "*"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@types/node": "^20.10.0",
|
|
60
|
+
"@types/react": "^19.0.0",
|
|
61
|
+
"react": "^19.0.0",
|
|
62
|
+
"rimraf": "^5.0.0",
|
|
63
|
+
"tsup": "^8.0.0",
|
|
64
|
+
"typescript": "^5.3.0",
|
|
65
|
+
"vitest": "^4.1.0"
|
|
66
|
+
},
|
|
67
|
+
"engines": {
|
|
68
|
+
"node": ">=18.0.0"
|
|
69
|
+
}
|
|
70
|
+
}
|