craft-native 0.0.37
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/LICENSE.md +21 -0
- package/README.md +424 -0
- package/bin/cli.ts +937 -0
- package/dist/api/android-advanced.d.ts +737 -0
- package/dist/api/android-advanced.d.ts.map +1 -0
- package/dist/api/app.d.ts +432 -0
- package/dist/api/app.d.ts.map +1 -0
- package/dist/api/clipboard.d.ts +85 -0
- package/dist/api/clipboard.d.ts.map +1 -0
- package/dist/api/crypto.d.ts +79 -0
- package/dist/api/crypto.d.ts.map +1 -0
- package/dist/api/db.d.ts +427 -0
- package/dist/api/db.d.ts.map +1 -0
- package/dist/api/dialog.d.ts +141 -0
- package/dist/api/dialog.d.ts.map +1 -0
- package/dist/api/fs.d.ts +131 -0
- package/dist/api/fs.d.ts.map +1 -0
- package/dist/api/http.d.ts +196 -0
- package/dist/api/http.d.ts.map +1 -0
- package/dist/api/index.d.ts +38 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/ios-advanced.d.ts +833 -0
- package/dist/api/ios-advanced.d.ts.map +1 -0
- package/dist/api/macos-advanced.d.ts +721 -0
- package/dist/api/macos-advanced.d.ts.map +1 -0
- package/dist/api/media.d.ts +233 -0
- package/dist/api/media.d.ts.map +1 -0
- package/dist/api/mobile.d.ts +658 -0
- package/dist/api/mobile.d.ts.map +1 -0
- package/dist/api/process.d.ts +168 -0
- package/dist/api/process.d.ts.map +1 -0
- package/dist/api/sidebar.d.ts +125 -0
- package/dist/api/sidebar.d.ts.map +1 -0
- package/dist/api/tray.d.ts +410 -0
- package/dist/api/tray.d.ts.map +1 -0
- package/dist/api/window.d.ts +462 -0
- package/dist/api/window.d.ts.map +1 -0
- package/dist/api/windows-advanced.d.ts +719 -0
- package/dist/api/windows-advanced.d.ts.map +1 -0
- package/dist/assets/index.d.ts +69 -0
- package/dist/assets/index.d.ts.map +1 -0
- package/dist/binary-resolver.d.ts +39 -0
- package/dist/binary-resolver.d.ts.map +1 -0
- package/dist/bridge/android.d.ts +574 -0
- package/dist/bridge/android.d.ts.map +1 -0
- package/dist/bridge/core.d.ts +474 -0
- package/dist/bridge/core.d.ts.map +1 -0
- package/dist/bridge/ids.d.ts +18 -0
- package/dist/bridge/ids.d.ts.map +1 -0
- package/dist/bridge/ios.d.ts +528 -0
- package/dist/bridge/ios.d.ts.map +1 -0
- package/dist/bridge/webkit-pending.d.ts +50 -0
- package/dist/bridge/webkit-pending.d.ts.map +1 -0
- package/dist/build/bundle-optimizer.d.ts +69 -0
- package/dist/build/bundle-optimizer.d.ts.map +1 -0
- package/dist/components/index.d.ts +719 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/native.d.ts +728 -0
- package/dist/components/native.d.ts.map +1 -0
- package/dist/components/sidebar.d.ts +458 -0
- package/dist/components/sidebar.d.ts.map +1 -0
- package/dist/dev/devtools.d.ts +118 -0
- package/dist/dev/devtools.d.ts.map +1 -0
- package/dist/dev/error-overlay.d.ts +73 -0
- package/dist/dev/error-overlay.d.ts.map +1 -0
- package/dist/dev/hot-reload.d.ts +127 -0
- package/dist/dev/hot-reload.d.ts.map +1 -0
- package/dist/index.cjs +10253 -0
- package/dist/index.d.cts +59 -0
- package/dist/index.d.ts +59 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10240 -0
- package/dist/logging/index.d.ts +152 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/optimizations/index.d.ts +232 -0
- package/dist/optimizations/index.d.ts.map +1 -0
- package/dist/package.d.ts +90 -0
- package/dist/package.d.ts.map +1 -0
- package/dist/performance/runtime.d.ts +230 -0
- package/dist/performance/runtime.d.ts.map +1 -0
- package/dist/performance/startup.d.ts +223 -0
- package/dist/performance/startup.d.ts.map +1 -0
- package/dist/plugins/index.d.ts +114 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/security/index.d.ts +268 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/signing/index.d.ts +104 -0
- package/dist/signing/index.d.ts.map +1 -0
- package/dist/styles/headwind.d.ts +222 -0
- package/dist/styles/headwind.d.ts.map +1 -0
- package/dist/styles/index.d.ts +31 -0
- package/dist/styles/index.d.ts.map +1 -0
- package/dist/styles/sidebar-templates.d.ts +77 -0
- package/dist/styles/sidebar-templates.d.ts.map +1 -0
- package/dist/styles/sidebars.d.ts +194 -0
- package/dist/styles/sidebars.d.ts.map +1 -0
- package/dist/types.d.ts +1555 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/updater/index.d.ts +164 -0
- package/dist/updater/index.d.ts.map +1 -0
- package/dist/utils/audio.d.ts +40 -0
- package/dist/utils/audio.d.ts.map +1 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/native.d.ts +27 -0
- package/dist/utils/native.d.ts.map +1 -0
- package/dist/utils/react.d.ts +157 -0
- package/dist/utils/react.d.ts.map +1 -0
- package/dist/utils/storage.d.ts +35 -0
- package/dist/utils/storage.d.ts.map +1 -0
- package/dist/utils/svelte.d.ts +187 -0
- package/dist/utils/svelte.d.ts.map +1 -0
- package/dist/utils/timer.d.ts +57 -0
- package/dist/utils/timer.d.ts.map +1 -0
- package/dist/utils/vue.d.ts +157 -0
- package/dist/utils/vue.d.ts.map +1 -0
- package/package.json +78 -0
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Craft Native Bridge Core
|
|
3
|
+
* Bidirectional async communication, message queue, and type-safe protocols
|
|
4
|
+
*/
|
|
5
|
+
import { EventEmitter } from 'events';
|
|
6
|
+
interface WkWebKitGlobal {
|
|
7
|
+
messageHandlers?: {
|
|
8
|
+
craft?: {
|
|
9
|
+
postMessage(message: unknown): void;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
interface AndroidWebViewGlobal {
|
|
14
|
+
postMessage(message: string): void;
|
|
15
|
+
}
|
|
16
|
+
interface CraftIPCGlobal {
|
|
17
|
+
send(channel: string, message: unknown): void;
|
|
18
|
+
}
|
|
19
|
+
declare global {
|
|
20
|
+
interface Window {
|
|
21
|
+
webkit?: WkWebKitGlobal;
|
|
22
|
+
CraftBridge?: AndroidWebViewGlobal;
|
|
23
|
+
craftIPC?: CraftIPCGlobal;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Bridge error codes returned by the native layer.
|
|
28
|
+
* Used in BridgeMessage.error.code field.
|
|
29
|
+
*/
|
|
30
|
+
export declare const BridgeErrorCodes: {
|
|
31
|
+
/** Generic/unknown error */
|
|
32
|
+
readonly UNKNOWN: -1;
|
|
33
|
+
/** Operation timed out waiting for native response */
|
|
34
|
+
readonly TIMEOUT: -2;
|
|
35
|
+
/** Offline queue full, cannot enqueue more requests */
|
|
36
|
+
readonly QUEUE_FULL: -3;
|
|
37
|
+
/** Binary transfer not enabled */
|
|
38
|
+
readonly BINARY_DISABLED: -4;
|
|
39
|
+
/** Expected binary response but got non-binary */
|
|
40
|
+
readonly EXPECTED_BINARY: -5;
|
|
41
|
+
/** Bridge destroyed while requests were pending */
|
|
42
|
+
readonly BRIDGE_DESTROYED: -6;
|
|
43
|
+
/** Bridge in-flight request limit exceeded (backpressure) */
|
|
44
|
+
readonly BUSY: -7;
|
|
45
|
+
/** Native side speaks an incompatible bridge protocol version */
|
|
46
|
+
readonly PROTOCOL_MISMATCH: -8;
|
|
47
|
+
/** Bridge transitioned from connected to disconnected with requests in flight */
|
|
48
|
+
readonly DISCONNECTED: -9;
|
|
49
|
+
};
|
|
50
|
+
export type BridgeErrorCode = typeof BridgeErrorCodes[keyof typeof BridgeErrorCodes];
|
|
51
|
+
/**
|
|
52
|
+
* Bridge wire-protocol version. Bumped when the message envelope changes in a
|
|
53
|
+
* backwards-incompatible way. Native and SDK must agree, or the bridge will
|
|
54
|
+
* reject the handshake with PROTOCOL_MISMATCH.
|
|
55
|
+
*/
|
|
56
|
+
export declare const BRIDGE_PROTOCOL_VERSION = 1;
|
|
57
|
+
export interface BridgeMessage<T = unknown> {
|
|
58
|
+
id: string;
|
|
59
|
+
type: 'request' | 'response' | 'event' | 'stream';
|
|
60
|
+
method?: string;
|
|
61
|
+
params?: T;
|
|
62
|
+
result?: unknown;
|
|
63
|
+
error?: {
|
|
64
|
+
code: number;
|
|
65
|
+
message: string;
|
|
66
|
+
data?: unknown;
|
|
67
|
+
};
|
|
68
|
+
streamId?: string;
|
|
69
|
+
streamEvent?: 'data' | 'end' | 'error';
|
|
70
|
+
}
|
|
71
|
+
export interface BridgeConfig {
|
|
72
|
+
timeout?: number;
|
|
73
|
+
retries?: number;
|
|
74
|
+
retryDelay?: number;
|
|
75
|
+
queueSize?: number;
|
|
76
|
+
batchSize?: number;
|
|
77
|
+
batchDelay?: number;
|
|
78
|
+
enableOfflineQueue?: boolean;
|
|
79
|
+
enableBinaryTransfer?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Maximum number of in-flight requests before new requests are rejected
|
|
82
|
+
* with `BridgeErrorCodes.BUSY`. Prevents user code from DOSing the native
|
|
83
|
+
* layer with tight loops. Defaults to 10_000.
|
|
84
|
+
*/
|
|
85
|
+
maxConcurrentRequests?: number;
|
|
86
|
+
/**
|
|
87
|
+
* Origin to use when the bridge falls back to `window.parent.postMessage`
|
|
88
|
+
* (i.e. Craft is running inside a host iframe rather than a native
|
|
89
|
+
* webview). Defaults to `null`, which **disables** the postMessage path
|
|
90
|
+
* entirely — `'*'` was the old default and leaks bridge traffic to any
|
|
91
|
+
* cross-origin parent. Set this to your host page's exact origin
|
|
92
|
+
* (e.g. `'https://app.example.com'`) when embedding.
|
|
93
|
+
*/
|
|
94
|
+
parentOrigin?: string | null;
|
|
95
|
+
}
|
|
96
|
+
export interface StreamController<T> {
|
|
97
|
+
onData(callback: (data: T) => void): void;
|
|
98
|
+
onEnd(callback: () => void): void;
|
|
99
|
+
onError(callback: (error: Error) => void): void;
|
|
100
|
+
cancel(): void;
|
|
101
|
+
}
|
|
102
|
+
export declare class NativeBridge extends EventEmitter {
|
|
103
|
+
private config;
|
|
104
|
+
private pendingRequests;
|
|
105
|
+
private offlineQueue;
|
|
106
|
+
private connected;
|
|
107
|
+
private streams;
|
|
108
|
+
private batchBuffer;
|
|
109
|
+
private batchTimer;
|
|
110
|
+
private destroyed;
|
|
111
|
+
private readonly idPrefix;
|
|
112
|
+
private idCounter;
|
|
113
|
+
private nextMessageId;
|
|
114
|
+
private boundHandleMessage;
|
|
115
|
+
private craftReadyHandler;
|
|
116
|
+
constructor(config?: BridgeConfig);
|
|
117
|
+
private setupBridge;
|
|
118
|
+
private teardownBridgeListeners;
|
|
119
|
+
private handleMessage;
|
|
120
|
+
/** True when the given id starts with this bridge's per-instance prefix. */
|
|
121
|
+
private isOwnId;
|
|
122
|
+
private handleResponse;
|
|
123
|
+
private handleEvent;
|
|
124
|
+
private handleStream;
|
|
125
|
+
/**
|
|
126
|
+
* Send a request to native and wait for response
|
|
127
|
+
*/
|
|
128
|
+
request<T = unknown, R = unknown>(method: string, params?: T, options?: {
|
|
129
|
+
timeout?: number;
|
|
130
|
+
}): Promise<R>;
|
|
131
|
+
private requestWithRetry;
|
|
132
|
+
private isRetryableError;
|
|
133
|
+
private sendRequest;
|
|
134
|
+
/**
|
|
135
|
+
* Negotiate the wire-protocol version with the native layer. Throws
|
|
136
|
+
* BridgeError(PROTOCOL_MISMATCH) if the native side reports a version we
|
|
137
|
+
* don't speak.
|
|
138
|
+
*
|
|
139
|
+
* This is **opt-in** — you must call it explicitly. It assumes the host
|
|
140
|
+
* registers a `_handshake` handler; the Zig core's
|
|
141
|
+
* `Bridge.registerDefaults()` does this for you. If you're embedding Craft
|
|
142
|
+
* inside a host that hasn't wired `_handshake`, do not call this method
|
|
143
|
+
* (the timeout path will reject with TIMEOUT, which is louder than a
|
|
144
|
+
* silent mismatch but still a failure).
|
|
145
|
+
*/
|
|
146
|
+
handshake(): Promise<{
|
|
147
|
+
nativeVersion: number;
|
|
148
|
+
}>;
|
|
149
|
+
/**
|
|
150
|
+
* Send a fire-and-forget message (no response expected)
|
|
151
|
+
*/
|
|
152
|
+
notify<T = unknown>(method: string, params?: T): void;
|
|
153
|
+
/**
|
|
154
|
+
* Create a stream for receiving multiple responses.
|
|
155
|
+
*
|
|
156
|
+
* @param method - native method name
|
|
157
|
+
* @param params - method params
|
|
158
|
+
* @param options.bufferLimit - max events buffered before consumer registers
|
|
159
|
+
* `onData`. Once exceeded the stream is failed with `BUFFER_OVERFLOW`
|
|
160
|
+
* instead of growing indefinitely. Defaults to 1000.
|
|
161
|
+
*/
|
|
162
|
+
stream<T = unknown>(method: string, params?: unknown, options?: {
|
|
163
|
+
bufferLimit?: number;
|
|
164
|
+
}): StreamController<T>;
|
|
165
|
+
/**
|
|
166
|
+
* Send binary data to native
|
|
167
|
+
*/
|
|
168
|
+
sendBinary(method: string, data: ArrayBuffer | Uint8Array): Promise<void>;
|
|
169
|
+
/**
|
|
170
|
+
* Receive binary data from native
|
|
171
|
+
*/
|
|
172
|
+
receiveBinary(method: string, params?: unknown): Promise<ArrayBuffer>;
|
|
173
|
+
/**
|
|
174
|
+
* Batch multiple requests
|
|
175
|
+
*/
|
|
176
|
+
batch<T extends Array<{
|
|
177
|
+
method: string;
|
|
178
|
+
params?: unknown;
|
|
179
|
+
}>>(requests: T): Promise<Array<{
|
|
180
|
+
result?: unknown;
|
|
181
|
+
error?: {
|
|
182
|
+
code: number;
|
|
183
|
+
message: string;
|
|
184
|
+
};
|
|
185
|
+
}>>;
|
|
186
|
+
/**
|
|
187
|
+
* Add request to batch buffer (auto-flushed)
|
|
188
|
+
*/
|
|
189
|
+
addToBatch<T = unknown>(method: string, params?: T): void;
|
|
190
|
+
private flushBatch;
|
|
191
|
+
/**
|
|
192
|
+
* Set connection status. Emits `'connected'` / `'disconnected'`. On
|
|
193
|
+
* disconnect, every outstanding pending request is rejected with
|
|
194
|
+
* `BridgeErrorCodes.DISCONNECTED` immediately — previously they sat
|
|
195
|
+
* until `timeout` (default 30s) expired, hanging the calling app.
|
|
196
|
+
*/
|
|
197
|
+
setConnected(connected: boolean): void;
|
|
198
|
+
private flushOfflineQueue;
|
|
199
|
+
/**
|
|
200
|
+
* Dispatch a message to whichever native transport is available. Returns
|
|
201
|
+
* `true` when the message was handed off to a transport, `false` when no
|
|
202
|
+
* transport could be found — the caller (only `sendRequest` cares) can
|
|
203
|
+
* use that to fail fast instead of waiting for the request timeout.
|
|
204
|
+
*/
|
|
205
|
+
private send;
|
|
206
|
+
/**
|
|
207
|
+
* Reject the pending entry corresponding to `message.id` with `error`,
|
|
208
|
+
* if any. Used by `send()` when serialization or transport throws so
|
|
209
|
+
* the caller's promise rejects immediately.
|
|
210
|
+
*/
|
|
211
|
+
private failPendingForMessage;
|
|
212
|
+
private delay;
|
|
213
|
+
private arrayBufferToBase64;
|
|
214
|
+
private base64ToArrayBuffer;
|
|
215
|
+
/**
|
|
216
|
+
* Destroy the bridge. Idempotent.
|
|
217
|
+
*/
|
|
218
|
+
destroy(): void;
|
|
219
|
+
}
|
|
220
|
+
export declare class BridgeError extends Error {
|
|
221
|
+
code: number;
|
|
222
|
+
data?: unknown;
|
|
223
|
+
constructor(message: string, code: number, data?: unknown);
|
|
224
|
+
}
|
|
225
|
+
export interface BridgeMethod<P = void, R = void> {
|
|
226
|
+
method: string;
|
|
227
|
+
params: P;
|
|
228
|
+
result: R;
|
|
229
|
+
}
|
|
230
|
+
export type InferParams<T> = T extends BridgeMethod<infer P, unknown> ? P : never;
|
|
231
|
+
export type InferResult<T> = T extends BridgeMethod<unknown, infer R> ? R : never;
|
|
232
|
+
export declare function createTypedBridge<T extends Record<string, BridgeMethod<any, any>>>(bridge: NativeBridge): { [K in keyof T]: (params: InferParams<T[K]>) => Promise<InferResult<T[K]>>; };
|
|
233
|
+
export interface MenuItem {
|
|
234
|
+
id: string;
|
|
235
|
+
label: string;
|
|
236
|
+
accelerator?: string;
|
|
237
|
+
type?: 'normal' | 'separator' | 'checkbox' | 'radio';
|
|
238
|
+
checked?: boolean;
|
|
239
|
+
enabled?: boolean;
|
|
240
|
+
visible?: boolean;
|
|
241
|
+
icon?: string;
|
|
242
|
+
submenu?: MenuItem[];
|
|
243
|
+
}
|
|
244
|
+
export declare class NativeMenus {
|
|
245
|
+
private bridge;
|
|
246
|
+
constructor(bridge: NativeBridge);
|
|
247
|
+
/**
|
|
248
|
+
* Set application menu
|
|
249
|
+
*/
|
|
250
|
+
setApplicationMenu(menu: MenuItem[]): Promise<void>;
|
|
251
|
+
/**
|
|
252
|
+
* Show context menu
|
|
253
|
+
*/
|
|
254
|
+
showContextMenu(menu: MenuItem[], position?: {
|
|
255
|
+
x: number;
|
|
256
|
+
y: number;
|
|
257
|
+
}): Promise<string | null>;
|
|
258
|
+
/**
|
|
259
|
+
* Update menu item
|
|
260
|
+
*/
|
|
261
|
+
updateMenuItem(id: string, updates: Partial<MenuItem>): Promise<void>;
|
|
262
|
+
/**
|
|
263
|
+
* Listen for menu item clicks
|
|
264
|
+
*/
|
|
265
|
+
onMenuClick(callback: (id: string) => void): () => void;
|
|
266
|
+
}
|
|
267
|
+
export interface OpenDialogOptions {
|
|
268
|
+
title?: string;
|
|
269
|
+
defaultPath?: string;
|
|
270
|
+
buttonLabel?: string;
|
|
271
|
+
filters?: Array<{
|
|
272
|
+
name: string;
|
|
273
|
+
extensions: string[];
|
|
274
|
+
}>;
|
|
275
|
+
properties?: Array<'openFile' | 'openDirectory' | 'multiSelections' | 'showHiddenFiles' | 'createDirectory' | 'promptToCreate' | 'noResolveAliases' | 'treatPackageAsDirectory' | 'dontAddToRecent'>;
|
|
276
|
+
message?: string;
|
|
277
|
+
}
|
|
278
|
+
export interface SaveDialogOptions {
|
|
279
|
+
title?: string;
|
|
280
|
+
defaultPath?: string;
|
|
281
|
+
buttonLabel?: string;
|
|
282
|
+
filters?: Array<{
|
|
283
|
+
name: string;
|
|
284
|
+
extensions: string[];
|
|
285
|
+
}>;
|
|
286
|
+
properties?: Array<'showHiddenFiles' | 'createDirectory' | 'showOverwriteConfirmation' | 'dontAddToRecent'>;
|
|
287
|
+
message?: string;
|
|
288
|
+
nameFieldLabel?: string;
|
|
289
|
+
showsTagField?: boolean;
|
|
290
|
+
}
|
|
291
|
+
export interface MessageBoxOptions {
|
|
292
|
+
type?: 'none' | 'info' | 'error' | 'question' | 'warning';
|
|
293
|
+
buttons?: string[];
|
|
294
|
+
defaultId?: number;
|
|
295
|
+
cancelId?: number;
|
|
296
|
+
title?: string;
|
|
297
|
+
message: string;
|
|
298
|
+
detail?: string;
|
|
299
|
+
checkboxLabel?: string;
|
|
300
|
+
checkboxChecked?: boolean;
|
|
301
|
+
icon?: string;
|
|
302
|
+
}
|
|
303
|
+
export declare class NativeDialogs {
|
|
304
|
+
private bridge;
|
|
305
|
+
constructor(bridge: NativeBridge);
|
|
306
|
+
/**
|
|
307
|
+
* Show open file dialog
|
|
308
|
+
*/
|
|
309
|
+
showOpenDialog(options?: OpenDialogOptions): Promise<{
|
|
310
|
+
canceled: boolean;
|
|
311
|
+
filePaths: string[];
|
|
312
|
+
}>;
|
|
313
|
+
/**
|
|
314
|
+
* Show save file dialog
|
|
315
|
+
*/
|
|
316
|
+
showSaveDialog(options?: SaveDialogOptions): Promise<{
|
|
317
|
+
canceled: boolean;
|
|
318
|
+
filePath?: string;
|
|
319
|
+
}>;
|
|
320
|
+
/**
|
|
321
|
+
* Show message box
|
|
322
|
+
*/
|
|
323
|
+
showMessageBox(options: MessageBoxOptions): Promise<{
|
|
324
|
+
response: number;
|
|
325
|
+
checkboxChecked?: boolean;
|
|
326
|
+
}>;
|
|
327
|
+
/**
|
|
328
|
+
* Show error box
|
|
329
|
+
*/
|
|
330
|
+
showErrorBox(title: string, content: string): Promise<void>;
|
|
331
|
+
/**
|
|
332
|
+
* Show color picker
|
|
333
|
+
*/
|
|
334
|
+
showColorPicker(options?: {
|
|
335
|
+
defaultColor?: string;
|
|
336
|
+
title?: string;
|
|
337
|
+
}): Promise<string | null>;
|
|
338
|
+
/**
|
|
339
|
+
* Show font picker
|
|
340
|
+
*/
|
|
341
|
+
showFontPicker(options?: {
|
|
342
|
+
defaultFont?: {
|
|
343
|
+
family: string;
|
|
344
|
+
size: number;
|
|
345
|
+
};
|
|
346
|
+
title?: string;
|
|
347
|
+
}): Promise<{
|
|
348
|
+
family: string;
|
|
349
|
+
size: number;
|
|
350
|
+
} | null>;
|
|
351
|
+
}
|
|
352
|
+
export interface NativeComponent {
|
|
353
|
+
id: string;
|
|
354
|
+
type: string;
|
|
355
|
+
props: Record<string, unknown>;
|
|
356
|
+
}
|
|
357
|
+
export declare class NativeComponentBridge {
|
|
358
|
+
private bridge;
|
|
359
|
+
private components;
|
|
360
|
+
constructor(bridge: NativeBridge);
|
|
361
|
+
private handleComponentEvent;
|
|
362
|
+
/**
|
|
363
|
+
* Create a native sidebar
|
|
364
|
+
*/
|
|
365
|
+
createSidebar(config: {
|
|
366
|
+
width?: number;
|
|
367
|
+
minWidth?: number;
|
|
368
|
+
maxWidth?: number;
|
|
369
|
+
position?: 'left' | 'right';
|
|
370
|
+
collapsible?: boolean;
|
|
371
|
+
collapsed?: boolean;
|
|
372
|
+
variant?: 'tahoe' | 'vibrancy' | 'solid' | 'transparent' | 'workspace' | 'desktop';
|
|
373
|
+
material?: 'auto' | 'sidebar' | 'hud' | 'popover' | 'content';
|
|
374
|
+
backgroundEffect?: 'none' | 'vibrancy' | 'shimmer';
|
|
375
|
+
allowsVibrancy?: boolean;
|
|
376
|
+
sections?: Array<{
|
|
377
|
+
id: string;
|
|
378
|
+
label?: string;
|
|
379
|
+
title?: string;
|
|
380
|
+
items?: Array<{
|
|
381
|
+
id: string;
|
|
382
|
+
label: string;
|
|
383
|
+
icon?: string;
|
|
384
|
+
href?: string;
|
|
385
|
+
badge?: string | number;
|
|
386
|
+
}>;
|
|
387
|
+
}>;
|
|
388
|
+
}): Promise<string>;
|
|
389
|
+
/**
|
|
390
|
+
* Create a native file browser
|
|
391
|
+
*/
|
|
392
|
+
createFileBrowser(config: {
|
|
393
|
+
rootPath?: string;
|
|
394
|
+
showHidden?: boolean;
|
|
395
|
+
selectionMode?: 'single' | 'multiple';
|
|
396
|
+
fileFilter?: Array<{
|
|
397
|
+
name: string;
|
|
398
|
+
extensions: string[];
|
|
399
|
+
}>;
|
|
400
|
+
}): Promise<string>;
|
|
401
|
+
/**
|
|
402
|
+
* Create a native split view
|
|
403
|
+
*/
|
|
404
|
+
createSplitView(config: {
|
|
405
|
+
orientation?: 'horizontal' | 'vertical';
|
|
406
|
+
dividerStyle?: 'thin' | 'thick' | 'paneSplitter';
|
|
407
|
+
initialPosition?: number;
|
|
408
|
+
minPositions?: [number, number];
|
|
409
|
+
}): Promise<string>;
|
|
410
|
+
/**
|
|
411
|
+
* Update component props
|
|
412
|
+
*/
|
|
413
|
+
updateComponent(componentId: string, props: Record<string, unknown>): Promise<void>;
|
|
414
|
+
/**
|
|
415
|
+
* Destroy component
|
|
416
|
+
*/
|
|
417
|
+
destroyComponent(componentId: string): Promise<void>;
|
|
418
|
+
/**
|
|
419
|
+
* Listen for component events
|
|
420
|
+
*/
|
|
421
|
+
onComponentEvent(componentId: string, eventType: string, callback: (data: unknown) => void): () => void;
|
|
422
|
+
/**
|
|
423
|
+
* Get selection from file browser
|
|
424
|
+
*/
|
|
425
|
+
getFileBrowserSelection(componentId: string): Promise<string[]>;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Get the process-wide singleton bridge, constructing it on first call.
|
|
429
|
+
*
|
|
430
|
+
* **Caveats for multi-window apps:**
|
|
431
|
+
* - The first caller's `config` wins; later calls receive the existing
|
|
432
|
+
* instance regardless of the config they pass — and we now log a
|
|
433
|
+
* `console.warn` when a follow-up caller passes a config that differs
|
|
434
|
+
* from the original (so silently-discarded configs are at least
|
|
435
|
+
* visible during development).
|
|
436
|
+
* - Calling `destroy()` on the returned bridge tears down state for
|
|
437
|
+
* every consumer, not just the caller.
|
|
438
|
+
*
|
|
439
|
+
* If your app opens more than one window or test harness, prefer
|
|
440
|
+
* {@link createBridge} to create independent instances and pass them
|
|
441
|
+
* explicitly to the components that need them.
|
|
442
|
+
*/
|
|
443
|
+
export declare function getBridge(config?: BridgeConfig): NativeBridge;
|
|
444
|
+
/**
|
|
445
|
+
* Create an independent bridge instance. Use this in multi-window apps and
|
|
446
|
+
* tests where the singleton from {@link getBridge} would cause two callers
|
|
447
|
+
* to share state.
|
|
448
|
+
*/
|
|
449
|
+
export declare function createBridge(config?: BridgeConfig): NativeBridge;
|
|
450
|
+
/**
|
|
451
|
+
* Reset the global bridge. Intended for tests that need to start from a
|
|
452
|
+
* known state — call `destroy()` on the previous instance first if you
|
|
453
|
+
* created any pending work.
|
|
454
|
+
*/
|
|
455
|
+
export declare function resetGlobalBridge(): void;
|
|
456
|
+
export declare function getMenus(): NativeMenus;
|
|
457
|
+
export declare function getDialogs(): NativeDialogs;
|
|
458
|
+
export declare function getComponents(): NativeComponentBridge;
|
|
459
|
+
declare const bridgeCore: {
|
|
460
|
+
NativeBridge: typeof NativeBridge;
|
|
461
|
+
BridgeError: typeof BridgeError;
|
|
462
|
+
BridgeErrorCodes: typeof BridgeErrorCodes;
|
|
463
|
+
createTypedBridge: typeof createTypedBridge;
|
|
464
|
+
NativeMenus: typeof NativeMenus;
|
|
465
|
+
NativeDialogs: typeof NativeDialogs;
|
|
466
|
+
NativeComponentBridge: typeof NativeComponentBridge;
|
|
467
|
+
getBridge: typeof getBridge;
|
|
468
|
+
createBridge: typeof createBridge;
|
|
469
|
+
getMenus: typeof getMenus;
|
|
470
|
+
getDialogs: typeof getDialogs;
|
|
471
|
+
getComponents: typeof getComponents;
|
|
472
|
+
};
|
|
473
|
+
export default bridgeCore;
|
|
474
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/bridge/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAOrC,U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AAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAGtE;AAMD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,SAAS,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,YAAY,CAoB7D;AAaD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,YAAY,CAEhE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAGxC;AAGD,wBAAgB,QAAQ,IAAI,WAAW,CAEtC;AAED,wBAAgB,UAAU,IAAI,aAAa,CAE1C;AAED,wBAAgB,aAAa,IAAI,qBAAqB,CAErD;AAED,QAAA,MAAM,UAAU,EAAE;IAChB,YAAY,EAAE,OAAO,YAAY,CAAA;IACjC,WAAW,EAAE,OAAO,WAAW,CAAA;IAC/B,gBAAgB,EAAE,OAAO,gBAAgB,CAAA;IACzC,iBAAiB,EAAE,OAAO,iBAAiB,CAAA;IAC3C,WAAW,EAAE,OAAO,WAAW,CAAA;IAC/B,aAAa,EAAE,OAAO,aAAa,CAAA;IACnC,qBAAqB,EAAE,OAAO,qBAAqB,CAAA;IACnD,SAAS,EAAE,OAAO,SAAS,CAAA;IAC3B,YAAY,EAAE,OAAO,YAAY,CAAA;IACjC,QAAQ,EAAE,OAAO,QAAQ,CAAA;IACzB,UAAU,EAAE,OAAO,UAAU,CAAA;IAC7B,aAAa,EAAE,OAAO,aAAa,CAAA;CAcpC,CAAA;AAED,eAAe,UAAU,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cryptographically-secure ID helpers shared across the bridge implementations.
|
|
3
|
+
*
|
|
4
|
+
* Math.random() is not safe for IDs that are routed back to the page (callback
|
|
5
|
+
* IDs, webview IDs) — predictable IDs let injected JS hijack pending callbacks.
|
|
6
|
+
* Use these helpers instead.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Returns a v4 UUID string. Falls back to crypto.getRandomValues when
|
|
10
|
+
* randomUUID is unavailable. Throws if no Web Crypto is available at all,
|
|
11
|
+
* which would indicate a non-browser, non-Node environment we don't support.
|
|
12
|
+
*/
|
|
13
|
+
export declare function secureUUID(): string;
|
|
14
|
+
/**
|
|
15
|
+
* Returns a prefixed, secure ID, e.g. `webview_3f7a…`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function secureId(prefix: string): string;
|
|
18
|
+
//# sourceMappingURL=ids.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../../src/bridge/ids.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;GAIG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAcnC;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE/C"}
|