@ekrooh/bare 0.6.2 → 0.8.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 +3 -2
- package/dist/errors-Bl5w-m62.mjs +56 -0
- package/dist/events-wkidvYuN.mjs +40 -0
- package/dist/{index-Do-kTNXw.d.mts → index-B3AmX7mC.d.mts} +35 -146
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +3 -1
- package/dist/{messages-CMNIFMFY.mjs → messages-B5HQRbFA.mjs} +185 -76
- package/dist/plugin-a3LvQrmS.mjs +111 -0
- package/dist/plugins-BjPAr5r8.mjs +77 -0
- package/dist/plugins-discovery-events.d.mts +1 -1
- package/dist/plugins-discovery-events.mjs +1 -1
- package/dist/plugins-health-events.d.mts +1 -1
- package/dist/plugins-health-events.mjs +1 -1
- package/dist/plugins-logs-events.d.mts +2 -1
- package/dist/plugins-logs-events.mjs +1 -1
- package/dist/plugins-media-events.d.mts +1 -1
- package/dist/plugins-media-events.mjs +1 -26
- package/dist/plugins-permissions-events.d.mts +2 -1
- package/dist/plugins-permissions-events.mjs +11 -3
- package/dist/plugins.d.mts +7 -4
- package/dist/plugins.mjs +1 -1
- package/dist/runtime.d.mts +31 -7
- package/dist/runtime.mjs +657 -124
- package/dist/{static-file-server-COxd-PFR.d.mts → static-file-server-drT1AHqV.d.mts} +26 -4
- package/dist/{store-DTg1jN5E.mjs → store-Bd2wL58k.mjs} +11 -2
- package/dist/sync.d.mts +40 -0
- package/dist/sync.mjs +372 -0
- package/dist/transports.d.mts +34 -1
- package/dist/transports.mjs +348 -168
- package/dist/types-BC39OoZB.d.mts +152 -0
- package/package.json +10 -8
- package/dist/plugins-BnpdCi3A.mjs +0 -156
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as InvokeEnvelope } from "./types-BC39OoZB.mjs";
|
|
2
|
+
import { i as LogSource, n as LogEntry, r as LogLevel } from "./index-B3AmX7mC.mjs";
|
|
2
3
|
export type LogsViewArgs = {
|
|
3
4
|
/** Most-recent N matching entries. Defaults to a small window. */
|
|
4
5
|
tail?: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as InvokeEnvelope } from "./types-BC39OoZB.mjs";
|
|
2
2
|
export type MediaKind = 'image' | 'video';
|
|
3
3
|
export type MediaResult = {
|
|
4
4
|
/** URL served by the worklet's loopback HTTP server (no bytes on the wire). */
|
|
@@ -1,26 +1 @@
|
|
|
1
|
-
|
|
2
|
-
// plugins/media/events.ts
|
|
3
|
-
const MEDIA_INVOKE_TIMEOUT_MS = 3e5;
|
|
4
|
-
const mediaSpecs = {
|
|
5
|
-
pick: {
|
|
6
|
-
pluginId: "vendor.media",
|
|
7
|
-
name: "media.pick",
|
|
8
|
-
args: {},
|
|
9
|
-
result: {}
|
|
10
|
-
},
|
|
11
|
-
capture: {
|
|
12
|
-
pluginId: "vendor.media",
|
|
13
|
-
name: "media.capture",
|
|
14
|
-
args: {},
|
|
15
|
-
result: {}
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
const mediaEvents = { media: {
|
|
19
|
-
pick(kind = "image") {
|
|
20
|
-
return invokeEvent(mediaSpecs.pick, { kind }, null, MEDIA_INVOKE_TIMEOUT_MS);
|
|
21
|
-
},
|
|
22
|
-
capture(kind = "image") {
|
|
23
|
-
return invokeEvent(mediaSpecs.capture, { kind }, null, MEDIA_INVOKE_TIMEOUT_MS);
|
|
24
|
-
}
|
|
25
|
-
} };
|
|
26
|
-
export { mediaEvents, mediaSpecs };
|
|
1
|
+
export { t as mediaEvents, n as mediaSpecs } from "./events-wkidvYuN.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as InvokeEnvelope } from "./types-BC39OoZB.mjs";
|
|
2
2
|
/** Canonical permission ids. Hosts map each to their platform equivalent. */
|
|
3
3
|
export type PermissionId = 'storage' | 'camera';
|
|
4
4
|
export type PermissionStatus = 'granted' | 'denied' | 'notDetermined' | 'unsupported';
|
|
@@ -14,6 +14,7 @@ export declare const permissionSpecs: {
|
|
|
14
14
|
permission: PermissionId;
|
|
15
15
|
};
|
|
16
16
|
readonly result: PermissionResult;
|
|
17
|
+
readonly hostTimeoutMs: number;
|
|
17
18
|
};
|
|
18
19
|
readonly status: {
|
|
19
20
|
readonly pluginId: 'core.permissions';
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import { a as invokeEvent } from "./messages-
|
|
1
|
+
import { a as invokeEvent } from "./messages-B5HQRbFA.mjs";
|
|
2
2
|
// plugins/permissions/events.ts
|
|
3
|
+
/**
|
|
4
|
+
* A permission request shows a system prompt the user answers at their own pace
|
|
5
|
+
* (R-04). The page waits five minutes; the worklet waits slightly less for the
|
|
6
|
+
* host, so a host that never answers fails the call with a `TIMEOUT` the page can
|
|
7
|
+
* read before the page gives up on its own. Mirrors `vendor.media`.
|
|
8
|
+
*/
|
|
9
|
+
const PERMISSION_REQUEST_TIMEOUT_MS = 3e5;
|
|
3
10
|
const permissionSpecs = {
|
|
4
11
|
request: {
|
|
5
12
|
pluginId: "core.permissions",
|
|
6
13
|
name: "permissions.request",
|
|
7
14
|
args: {},
|
|
8
|
-
result: {}
|
|
15
|
+
result: {},
|
|
16
|
+
hostTimeoutMs: 295e3
|
|
9
17
|
},
|
|
10
18
|
status: {
|
|
11
19
|
pluginId: "core.permissions",
|
|
@@ -16,7 +24,7 @@ const permissionSpecs = {
|
|
|
16
24
|
};
|
|
17
25
|
const permissionEvents = { permissions: {
|
|
18
26
|
request(permission) {
|
|
19
|
-
return invokeEvent(permissionSpecs.request, { permission });
|
|
27
|
+
return invokeEvent(permissionSpecs.request, { permission }, null, PERMISSION_REQUEST_TIMEOUT_MS);
|
|
20
28
|
},
|
|
21
29
|
status(permission) {
|
|
22
30
|
return invokeEvent(permissionSpecs.status, { permission });
|
package/dist/plugins.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { _ as PluginInvokeResponseHeader, b as RuntimeTarget, g as PluginInvokeRequestHeader, t as CapabilityDescriptor, v as PluginManifest } from "./types-BC39OoZB.mjs";
|
|
2
|
+
import { a as LogStore } from "./index-B3AmX7mC.mjs";
|
|
3
|
+
import { n as LoopbackServer } from "./static-file-server-drT1AHqV.mjs";
|
|
3
4
|
type DiscoveryPluginDeps = {
|
|
4
5
|
listBareCapabilities: () => Array<{
|
|
5
6
|
pluginId: string;
|
|
@@ -16,8 +17,10 @@ type LogsPluginDeps = {
|
|
|
16
17
|
type MediaPluginDeps = {
|
|
17
18
|
/** Worklet-side loopback server exposing picked files to the web layer. */
|
|
18
19
|
staticServer: LoopbackServer;
|
|
19
|
-
/** Delegates the native pick/capture to the host (`HOST_INVOKE_REQUEST`).
|
|
20
|
-
|
|
20
|
+
/** Delegates the native pick/capture to the host (`HOST_INVOKE_REQUEST`).
|
|
21
|
+
* `timeoutMs` is how long to wait for the host; the media plugin passes a
|
|
22
|
+
* deadline just under the page's 5-minute invoke timeout. */
|
|
23
|
+
invokeOnHost: (header: PluginInvokeRequestHeader, payload: Uint8Array, timeoutMs?: number) => Promise<PluginInvokeResponseHeader | null>;
|
|
21
24
|
};
|
|
22
25
|
export type DefaultPluginsDeps = DiscoveryPluginDeps & MediaPluginDeps & LogsPluginDeps;
|
|
23
26
|
export declare function createDefaultPlugins(deps: DefaultPluginsDeps): PluginManifest[];
|
package/dist/plugins.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as createDefaultPlugins } from "./plugins-
|
|
1
|
+
export { t as createDefaultPlugins } from "./plugins-BjPAr5r8.mjs";
|
package/dist/runtime.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { _ as PluginInvokeResponseHeader, f as MessageHeader, g as PluginInvokeRequestHeader, t as CapabilityDescriptor, v as PluginManifest, x as WireMessage } from "./types-BC39OoZB.mjs";
|
|
2
|
+
import { C as createPluginRegistry, g as MessageProtocol, k as Platform, o as BareRuntimeContext, w as createPluginRouter } from "./index-B3AmX7mC.mjs";
|
|
3
|
+
import { i as createLoopbackServer, n as LoopbackServer, r as collectRequestBody, t as LoopbackRouteHandler } from "./static-file-server-drT1AHqV.mjs";
|
|
3
4
|
type BareIpcLike = {
|
|
4
5
|
write(data: Uint8Array | string): boolean;
|
|
5
6
|
};
|
|
@@ -9,9 +10,16 @@ declare function createHostIpcBridge(config: {
|
|
|
9
10
|
/** Worklet entry points pass `barePlatform`; Bare has no Web Crypto global. */
|
|
10
11
|
platform: Platform;
|
|
11
12
|
}): {
|
|
13
|
+
/** Stops the bridge (the runtime is closing): clears every pending timer,
|
|
14
|
+
* rejects every pending call with `reason`, and makes later calls reject
|
|
15
|
+
* at once instead of writing to a dead channel. */
|
|
16
|
+
close(reason?: string): void;
|
|
12
17
|
tryConsumeDownstream: (parsed: WireMessage) => boolean;
|
|
13
18
|
tryConsumeDownstreamFromHost(raw: Uint8Array | ArrayBuffer): boolean;
|
|
14
19
|
queryCapabilities(timeoutMs?: number): Promise<CapabilityDescriptor[]>;
|
|
20
|
+
/** Runs `header` on the host. `timeoutMs` bounds the wait (default
|
|
21
|
+
* 30 s); a user-mediated call (picker, camera, permission prompt) passes
|
|
22
|
+
* its own, longer deadline. */
|
|
15
23
|
invokeOnHost(header: PluginInvokeRequestHeader, payload: Uint8Array, timeoutMs?: number): Promise<PluginInvokeResponseHeader | null>;
|
|
16
24
|
};
|
|
17
25
|
/** Envelope encoder bound to a loopback server's connected protocol socket —
|
|
@@ -79,7 +87,8 @@ export type WorkletRuntimeOptions = {
|
|
|
79
87
|
* ephemeral port in device mode, 8080 in dev mode. */
|
|
80
88
|
port?: number;
|
|
81
89
|
/** Require the per-session token/cookie. Defaults to on in device mode and
|
|
82
|
-
* off in dev mode. The origin check applies either way.
|
|
90
|
+
* off in dev mode. The origin check applies either way. `false` is only
|
|
91
|
+
* accepted together with `deviceMode: false`. */
|
|
83
92
|
auth?: boolean;
|
|
84
93
|
/** Extra page origins allowed to call the loopback server, e.g. the Vite dev
|
|
85
94
|
* server (`http://localhost:5173`). The bound origin and its loopback
|
|
@@ -92,7 +101,8 @@ export type WorkletRuntimeOptions = {
|
|
|
92
101
|
handoffFile?: boolean;
|
|
93
102
|
/** Device mode (the default): auth on, an ephemeral port, and the handoff
|
|
94
103
|
* file when `storage` is set. Pass `false` (or the `mode=dev` CLI token) for
|
|
95
|
-
* the dev backend: auth off and port 8080 unless set explicitly.
|
|
104
|
+
* the dev backend: auth off and port 8080 unless set explicitly. Device mode
|
|
105
|
+
* cannot run with `auth: false`: that combination throws. */
|
|
96
106
|
deviceMode?: boolean;
|
|
97
107
|
/** Additional plugin manifests to register after the canonical defaults
|
|
98
108
|
* (consumer product plugins, e.g. `app.photos`). */
|
|
@@ -115,6 +125,13 @@ export type WorkletRuntimeOptions = {
|
|
|
115
125
|
/** Global cap on calls routed at once; calls over it fail with a
|
|
116
126
|
* `TRANSPORT_ERROR`. Defaults to 64. */
|
|
117
127
|
maxInflight?: number;
|
|
128
|
+
/** Cap on calls routed at once from one channel (the page socket, the host
|
|
129
|
+
* IPC), so one peer cannot take every slot. Defaults to three quarters of
|
|
130
|
+
* `maxInflight`. */
|
|
131
|
+
maxInflightPerChannel?: number;
|
|
132
|
+
/** Cap on calls routed at once to one plugin, so a slow plugin cannot take
|
|
133
|
+
* every slot. Defaults to `maxInflight` (no per-plugin cap). */
|
|
134
|
+
maxInflightPerPlugin?: number;
|
|
118
135
|
/** Plugin ids whose calls must run one at a time, in arrival order. All
|
|
119
136
|
* other plugins run concurrently, so one slow call never blocks the rest. */
|
|
120
137
|
serialPlugins?: readonly string[];
|
|
@@ -138,18 +155,25 @@ export interface WorkletRuntime {
|
|
|
138
155
|
hostBridge: ReturnType<typeof createHostIpcBridge> | null;
|
|
139
156
|
config: WorkletRuntimeConfig;
|
|
140
157
|
/** Binds the server, mounts the web app, attaches the protocol socket and
|
|
141
|
-
* (in device mode) writes the handoff file. Resolves to the credentials.
|
|
158
|
+
* (in device mode) writes the handoff file. Resolves to the credentials.
|
|
159
|
+
* Idempotent: later calls return the same promise. Rejects when the device
|
|
160
|
+
* handoff file cannot be written (a host would never find the origin) and
|
|
161
|
+
* after `close()`. */
|
|
142
162
|
start(): Promise<{
|
|
143
163
|
origin: string;
|
|
144
164
|
port: number;
|
|
145
165
|
token: string;
|
|
146
166
|
bootstrap: string;
|
|
147
167
|
}>;
|
|
168
|
+
/** Closes the server, detaches the host IPC listener, fails pending host
|
|
169
|
+
* calls and stops feeding this runtime's log store from the console.
|
|
170
|
+
* Idempotent. */
|
|
148
171
|
close(cb?: (err?: Error | null) => void): void;
|
|
149
172
|
}
|
|
150
173
|
/**
|
|
151
|
-
* Creates one worklet runtime — a per-instance
|
|
152
|
-
*
|
|
174
|
+
* Creates one worklet runtime — a per-instance factory (no hardcoded port;
|
|
175
|
+
* the only process-wide state is the shared console capture, which fans out
|
|
176
|
+
* to every live runtime's log store) so the dev/test backend can host
|
|
153
177
|
* N of them and a consumer worklet entry can be just "register plugins +
|
|
154
178
|
* wire p2p". Mirrors the reference wiring in `core/main.core.ts`.
|
|
155
179
|
*/
|