@ekrooh/bare 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.
@@ -0,0 +1,57 @@
1
+ import { B as InvokeEnvelope } from "./index-DjulYFJL.mjs";
2
+ //#region plugins/health/events.d.ts
3
+ declare const healthSpecs: {
4
+ readonly ping: {
5
+ readonly pluginId: 'core.health';
6
+ readonly name: 'health.ping';
7
+ readonly args: {
8
+ message?: string;
9
+ };
10
+ readonly result: {
11
+ message: string;
12
+ ts: number;
13
+ };
14
+ };
15
+ readonly payloadEcho: {
16
+ readonly pluginId: 'core.health';
17
+ readonly name: 'health.payloadEcho';
18
+ readonly args: {
19
+ label: string;
20
+ };
21
+ readonly result: {
22
+ label: string;
23
+ payloadSize: number;
24
+ };
25
+ };
26
+ readonly roundtrip: {
27
+ readonly pluginId: 'core.health';
28
+ readonly name: 'health.roundtrip';
29
+ readonly args: Record<string, never>;
30
+ readonly result: {
31
+ pong: true;
32
+ ts: number;
33
+ };
34
+ };
35
+ };
36
+ declare const healthEvents: {
37
+ health: {
38
+ ping(message?: string): InvokeEnvelope<'health.ping', {
39
+ message?: string;
40
+ }, {
41
+ message: string;
42
+ ts: number;
43
+ }>;
44
+ payloadEcho(label: string, payload: Uint8Array | ArrayBuffer | string): InvokeEnvelope<'health.payloadEcho', {
45
+ label: string;
46
+ }, {
47
+ label: string;
48
+ payloadSize: number;
49
+ }>;
50
+ roundtrip(): InvokeEnvelope<'health.roundtrip', Record<string, never>, {
51
+ pong: true;
52
+ ts: number;
53
+ }>;
54
+ };
55
+ };
56
+ //#endregion
57
+ export { healthEvents, healthSpecs };
@@ -0,0 +1,35 @@
1
+ import { invokeEvent } from "./index.mjs";
2
+ //#region plugins/health/events.ts
3
+ const healthSpecs = {
4
+ ping: {
5
+ pluginId: "core.health",
6
+ name: "health.ping",
7
+ args: {},
8
+ result: {}
9
+ },
10
+ payloadEcho: {
11
+ pluginId: "core.health",
12
+ name: "health.payloadEcho",
13
+ args: {},
14
+ result: {}
15
+ },
16
+ roundtrip: {
17
+ pluginId: "core.health",
18
+ name: "health.roundtrip",
19
+ args: {},
20
+ result: {}
21
+ }
22
+ };
23
+ const healthEvents = { health: {
24
+ ping(message = "ping") {
25
+ return invokeEvent(healthSpecs.ping, { message });
26
+ },
27
+ payloadEcho(label, payload) {
28
+ return invokeEvent(healthSpecs.payloadEcho, { label }, payload);
29
+ },
30
+ roundtrip() {
31
+ return invokeEvent(healthSpecs.roundtrip, {});
32
+ }
33
+ } };
34
+ //#endregion
35
+ export { healthEvents, healthSpecs };
@@ -0,0 +1,39 @@
1
+ import { B as InvokeEnvelope } from "./index-DjulYFJL.mjs";
2
+ //#region plugins/media/events.d.ts
3
+ type MediaKind = 'image' | 'video';
4
+ type MediaResult = {
5
+ /** URL served by the worklet's loopback HTTP server (no bytes on the wire). */
6
+ url: string;
7
+ /** Absolute filesystem path of the picked file on the host. */
8
+ path: string;
9
+ };
10
+ declare const mediaSpecs: {
11
+ readonly pick: {
12
+ readonly pluginId: 'vendor.media';
13
+ readonly name: 'media.pick';
14
+ readonly args: {
15
+ kind?: MediaKind;
16
+ };
17
+ readonly result: MediaResult;
18
+ };
19
+ readonly capture: {
20
+ readonly pluginId: 'vendor.media';
21
+ readonly name: 'media.capture';
22
+ readonly args: {
23
+ kind?: MediaKind;
24
+ };
25
+ readonly result: MediaResult;
26
+ };
27
+ };
28
+ declare const mediaEvents: {
29
+ media: {
30
+ pick(kind?: MediaKind): InvokeEnvelope<'media.pick', {
31
+ kind?: MediaKind;
32
+ }, MediaResult>;
33
+ capture(kind?: MediaKind): InvokeEnvelope<'media.capture', {
34
+ kind?: MediaKind;
35
+ }, MediaResult>;
36
+ };
37
+ };
38
+ //#endregion
39
+ export { MediaKind, MediaResult, mediaEvents, mediaSpecs };
@@ -0,0 +1,27 @@
1
+ import { invokeEvent } from "./index.mjs";
2
+ //#region 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
+ //#endregion
27
+ export { mediaEvents, mediaSpecs };
@@ -0,0 +1,39 @@
1
+ import { B as InvokeEnvelope } from "./index-DjulYFJL.mjs";
2
+ //#region plugins/permissions/events.d.ts
3
+ /** Canonical permission ids. Hosts map each to their platform equivalent. */
4
+ type PermissionId = 'storage' | 'camera';
5
+ type PermissionStatus = 'granted' | 'denied' | 'notDetermined' | 'unsupported';
6
+ type PermissionResult = {
7
+ permission: PermissionId;
8
+ status: PermissionStatus;
9
+ };
10
+ declare const permissionSpecs: {
11
+ readonly request: {
12
+ readonly pluginId: 'core.permissions';
13
+ readonly name: 'permissions.request';
14
+ readonly args: {
15
+ permission: PermissionId;
16
+ };
17
+ readonly result: PermissionResult;
18
+ };
19
+ readonly status: {
20
+ readonly pluginId: 'core.permissions';
21
+ readonly name: 'permissions.status';
22
+ readonly args: {
23
+ permission: PermissionId;
24
+ };
25
+ readonly result: PermissionResult;
26
+ };
27
+ };
28
+ declare const permissionEvents: {
29
+ permissions: {
30
+ request(permission: PermissionId): InvokeEnvelope<'permissions.request', {
31
+ permission: PermissionId;
32
+ }, PermissionResult>;
33
+ status(permission: PermissionId): InvokeEnvelope<'permissions.status', {
34
+ permission: PermissionId;
35
+ }, PermissionResult>;
36
+ };
37
+ };
38
+ //#endregion
39
+ export { PermissionId, PermissionResult, PermissionStatus, permissionEvents, permissionSpecs };
@@ -0,0 +1,26 @@
1
+ import { invokeEvent } from "./index.mjs";
2
+ //#region plugins/permissions/events.ts
3
+ const permissionSpecs = {
4
+ request: {
5
+ pluginId: "core.permissions",
6
+ name: "permissions.request",
7
+ args: {},
8
+ result: {}
9
+ },
10
+ status: {
11
+ pluginId: "core.permissions",
12
+ name: "permissions.status",
13
+ args: {},
14
+ result: {}
15
+ }
16
+ };
17
+ const permissionEvents = { permissions: {
18
+ request(permission) {
19
+ return invokeEvent(permissionSpecs.request, { permission });
20
+ },
21
+ status(permission) {
22
+ return invokeEvent(permissionSpecs.status, { permission });
23
+ }
24
+ } };
25
+ //#endregion
26
+ export { permissionEvents, permissionSpecs };
@@ -0,0 +1,26 @@
1
+ import { A as CapabilityDescriptor, G as PluginInvokeRequestHeader, K as PluginInvokeResponseHeader, Y as RuntimeTarget, q as PluginManifest } from "./index-DjulYFJL.mjs";
2
+ import { t as LoopbackServer } from "./static-file-server-CxeI_mQr.mjs";
3
+ //#region plugins/discovery/plugin.d.ts
4
+ type DiscoveryPluginDeps = {
5
+ listBareCapabilities: () => Array<{
6
+ pluginId: string;
7
+ capabilities: string[];
8
+ events: string[];
9
+ runtimes: RuntimeTarget[];
10
+ }>;
11
+ queryHostCapabilities: () => Promise<CapabilityDescriptor[]>;
12
+ };
13
+ //#endregion
14
+ //#region plugins/media/plugin.d.ts
15
+ type MediaPluginDeps = {
16
+ /** Worklet-side loopback server exposing picked files to the web layer. */
17
+ staticServer: LoopbackServer;
18
+ /** Delegates the native pick/capture to the host (`HOST_INVOKE_REQUEST`). */
19
+ invokeOnHost: (header: PluginInvokeRequestHeader, payload: Uint8Array) => Promise<PluginInvokeResponseHeader | null>;
20
+ };
21
+ //#endregion
22
+ //#region plugins/index.d.ts
23
+ type DefaultPluginsDeps = DiscoveryPluginDeps & MediaPluginDeps;
24
+ declare function createDefaultPlugins(deps: DefaultPluginsDeps): PluginManifest[];
25
+ //#endregion
26
+ export { DefaultPluginsDeps, type DiscoveryPluginDeps, type MediaPluginDeps, createDefaultPlugins };
@@ -0,0 +1,2 @@
1
+ import { t as createDefaultPlugins } from "./plugins-1KweEBct.mjs";
2
+ export { createDefaultPlugins };
@@ -0,0 +1,96 @@
1
+ import { A as CapabilityDescriptor, G as PluginInvokeRequestHeader, K as PluginInvokeResponseHeader, d as MessageProtocol, t as BareRuntimeContext, v as createPluginRegistry, y as createPluginRouter } from "./index-DjulYFJL.mjs";
2
+ import { n as createLoopbackServer, t as LoopbackServer } from "./static-file-server-CxeI_mQr.mjs";
3
+ //#region core/messages/host-ipc.d.ts
4
+ type BareIpcLike = {
5
+ write(data: Uint8Array | Buffer | string): boolean;
6
+ };
7
+ declare function createHostIpcBridge(config: {
8
+ ipc: BareIpcLike;
9
+ protocol: MessageProtocol;
10
+ }): {
11
+ tryConsumeDownstreamFromHost(raw: Uint8Array | ArrayBuffer | Buffer): boolean;
12
+ queryCapabilities(timeoutMs?: number): Promise<CapabilityDescriptor[]>;
13
+ invokeOnHost(header: PluginInvokeRequestHeader, payload: Uint8Array, timeoutMs?: number): Promise<PluginInvokeResponseHeader | null>;
14
+ };
15
+ //#endregion
16
+ //#region core/server/websocket-server.d.ts
17
+ /**
18
+ * Attaches the framed-protocol socket to the unified loopback server. The
19
+ * server owns the WebSocket upgrade (origin check, cookie/token auth, single
20
+ * client, idle timeout); this layer only routes decoded envelopes through the
21
+ * plugin router and writes responses back as raw frames.
22
+ */
23
+ declare function attachWebSocketProtocol(server: LoopbackServer, context: BareRuntimeContext): void;
24
+ //#endregion
25
+ //#region core/lib/get-ipc.d.ts
26
+ /**
27
+ * @fileoverview Bare IPC provider for Android (BareKit) and Sidecar (Bare.IPC)
28
+ */
29
+ interface BareIPC extends NodeJS.EventEmitter {
30
+ read(n?: number): Buffer | null;
31
+ write(data: Buffer | string): boolean;
32
+ resume?(): void;
33
+ pause?(): void;
34
+ }
35
+ /**
36
+ * Returns the active IPC channel.
37
+ * In BareKit (Android), it uses BareKit.IPC.
38
+ * In Bare (Sidecar), it uses Bare.IPC.
39
+ */
40
+ declare function getIPC(): BareIPC;
41
+ //#endregion
42
+ //#region core/runtime.d.ts
43
+ /** Resolves the host-provided worklet configuration from `start(...)`
44
+ * arguments. On-device hosts pass `["<webAssets>", "<storage>", "<cache>"]`,
45
+ * landing at `Bare.argv[0..2]`; the Bare CLI (dev) passes the binary and the
46
+ * script path instead, so a missing/absent config means dev mode (auth off,
47
+ * fixed port, no handoff file). */
48
+ declare function resolveWorkletConfig(): WorkletRuntimeOptions;
49
+ type WorkletRuntimeOptions = {
50
+ /** Directory to serve at `/` (the built web app). */
51
+ webAssets?: string;
52
+ /** Durable app-sandbox directory: `handoff.json` + the p2p corestore. */
53
+ storage?: string;
54
+ /** Ephemeral app-sandbox directory: asset-cache, photo spool, temp. */
55
+ cache?: string;
56
+ /** Bind address. Defaults to `127.0.0.1`. */
57
+ host?: string;
58
+ /** Port to bind; `0` picks an ephemeral port (on-device). Defaults to an
59
+ * ephemeral port in device mode, 8080 in dev mode. */
60
+ port?: number;
61
+ /** Require the per-session token/cookie. Defaults to on in device mode. */
62
+ auth?: boolean;
63
+ /** Idle timeout (ms) after which an authenticated WebSocket is dropped. */
64
+ wsIdleTimeoutMs?: number;
65
+ };
66
+ type WorkletRuntimeConfig = {
67
+ webAssets?: string;
68
+ storage?: string;
69
+ cache?: string;
70
+ deviceMode: boolean;
71
+ };
72
+ interface WorkletRuntime {
73
+ protocol: MessageProtocol;
74
+ pluginRegistry: ReturnType<typeof createPluginRegistry>;
75
+ pluginRouter: ReturnType<typeof createPluginRouter>;
76
+ server: LoopbackServer;
77
+ hostBridge: ReturnType<typeof createHostIpcBridge> | null;
78
+ config: WorkletRuntimeConfig;
79
+ /** Binds the server, mounts the web app, attaches the protocol socket and
80
+ * (in device mode) writes the handoff file. Resolves to the credentials. */
81
+ start(): Promise<{
82
+ origin: string;
83
+ port: number;
84
+ token: string;
85
+ }>;
86
+ close(cb?: (err?: Error | null) => void): void;
87
+ }
88
+ /**
89
+ * Creates one worklet runtime — a per-instance, stateless factory (no
90
+ * module-scope singletons, no hardcoded port) so the dev/test backend can host
91
+ * N of them and a consumer worklet entry can be just "register plugins +
92
+ * wire p2p". Mirrors the reference wiring in `core/main.core.ts`.
93
+ */
94
+ declare function createWorkletRuntime(options?: WorkletRuntimeOptions): WorkletRuntime;
95
+ //#endregion
96
+ export { type LoopbackServer, WorkletRuntime, WorkletRuntimeConfig, WorkletRuntimeOptions, attachWebSocketProtocol, createLoopbackServer, createWorkletRuntime, getIPC, resolveWorkletConfig };