@ekrooh/bare 0.4.0 → 0.6.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 +139 -195
- package/dist/{index-DjulYFJL.d.mts → index-BkwUzwVt.d.mts} +94 -20
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -512
- package/dist/messages-CevD8qkV.mjs +851 -0
- package/dist/{plugins-1KweEBct.mjs → plugins-Ddp2AgOe.mjs} +51 -20
- package/dist/plugins-discovery-events.d.mts +5 -8
- package/dist/plugins-discovery-events.mjs +2 -3
- package/dist/plugins-health-events.d.mts +4 -7
- package/dist/plugins-health-events.mjs +2 -3
- package/dist/plugins-logs-events.d.mts +34 -0
- package/dist/plugins-logs-events.mjs +25 -0
- package/dist/plugins-media-events.d.mts +6 -11
- package/dist/plugins-media-events.mjs +2 -3
- package/dist/plugins-permissions-events.d.mts +7 -10
- package/dist/plugins-permissions-events.mjs +2 -3
- package/dist/plugins.d.mts +9 -11
- package/dist/plugins.mjs +1 -2
- package/dist/runtime.d.mts +75 -46
- package/dist/runtime.mjs +1314 -324
- package/dist/static-file-server-COxd-PFR.d.mts +120 -0
- package/dist/store-DTg1jN5E.mjs +49 -0
- package/dist/transports.d.mts +15 -14
- package/dist/transports.mjs +169 -82
- package/package.json +12 -8
- package/dist/static-file-server-DY9EKEVf.d.mts +0 -88
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ekrooh/bare",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "One soul, many platforms \u2014 the boring bootstrap for cross-platform apps on the Bare runtime: wire protocol, plugin kernel, RPC messenger, transports, and native host bridges.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"./plugins/discovery/events": "./dist/plugins-discovery-events.mjs",
|
|
24
24
|
"./plugins/permissions/events": "./dist/plugins-permissions-events.mjs",
|
|
25
25
|
"./plugins/media/events": "./dist/plugins-media-events.mjs",
|
|
26
|
+
"./plugins/logs/events": "./dist/plugins-logs-events.mjs",
|
|
26
27
|
"./transports": "./dist/transports.mjs",
|
|
27
28
|
"./package.json": "./package.json"
|
|
28
29
|
},
|
|
@@ -58,6 +59,8 @@
|
|
|
58
59
|
"build:core": "npm run build:bare:app",
|
|
59
60
|
"build:android-assets": "npm run build:core && npm run build:web",
|
|
60
61
|
"build:ios": "node scripts/build-ios-app.mjs",
|
|
62
|
+
"build:desktop": "node scripts/build-desktop-app.mjs",
|
|
63
|
+
"smoke:desktop": "node scripts/smoke-desktop.mjs",
|
|
61
64
|
"test:ios": "node scripts/test-ios.mjs",
|
|
62
65
|
"build:bare": "npm run build:core",
|
|
63
66
|
"build:bare:app": "esbuild core/main.core.ts --bundle --packages=external --platform=node --format=esm --outfile=core/main.core.gen.js",
|
|
@@ -73,10 +76,11 @@
|
|
|
73
76
|
},
|
|
74
77
|
"devDependencies": {
|
|
75
78
|
"@types/node": "^26.2.0",
|
|
76
|
-
"@vitest/coverage-v8": "^
|
|
79
|
+
"@vitest/coverage-v8": "^5.0.5",
|
|
77
80
|
"bare": "^1.28.0",
|
|
78
81
|
"bare-link": "^3.3.0",
|
|
79
82
|
"bare-pack": "^2.2.1",
|
|
83
|
+
"bare-pipe": "^4.4.0",
|
|
80
84
|
"bare-runtime": "^1.28.0",
|
|
81
85
|
"concurrently": "^10.0.4",
|
|
82
86
|
"corestore": "^7.12.0",
|
|
@@ -84,24 +88,24 @@
|
|
|
84
88
|
"hyperdrive": "^13.3.3",
|
|
85
89
|
"hyperswarm": "^4.17.0",
|
|
86
90
|
"typescript": "^7.0.2",
|
|
87
|
-
"vite": "npm:@voidzero-dev/vite-plus-core@
|
|
88
|
-
"vite-plus": "
|
|
91
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@1.4.0",
|
|
92
|
+
"vite-plus": "1.4.0"
|
|
89
93
|
},
|
|
90
94
|
"dependencies": {
|
|
91
95
|
"@mantaq/core": "^0.2.0",
|
|
92
|
-
"@mantaq/sugar": "^0.3.0",
|
|
93
96
|
"bare-crypto": "^1.15.3",
|
|
94
97
|
"bare-encoding": "^1.0.3",
|
|
95
98
|
"bare-env": "^3.0.0",
|
|
96
99
|
"bare-fs": "^4.8.0",
|
|
100
|
+
"bare-hrtime": "2.1.2",
|
|
97
101
|
"bare-http1": "^4.5.7",
|
|
98
102
|
"bare-path": "^3.1.1",
|
|
99
103
|
"bare-tcp": "^2.2.7",
|
|
100
|
-
"bare-ws": "^3.
|
|
104
|
+
"bare-ws": "^3.1.0",
|
|
101
105
|
"fs-native-extensions": "1.5.0",
|
|
102
106
|
"quickbit-native": "2.4.8",
|
|
103
107
|
"rabin-native": "2.0.0",
|
|
104
|
-
"rocksdb-native": "3.
|
|
108
|
+
"rocksdb-native": "3.19.1",
|
|
105
109
|
"simdle-native": "1.3.9",
|
|
106
110
|
"sodium-native": "5.1.0",
|
|
107
111
|
"udx-native": "1.21.0"
|
|
@@ -114,6 +118,6 @@
|
|
|
114
118
|
}
|
|
115
119
|
},
|
|
116
120
|
"overrides": {
|
|
117
|
-
"vite": "npm:@voidzero-dev/vite-plus-core@
|
|
121
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@1.4.0"
|
|
118
122
|
}
|
|
119
123
|
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { HTTPIncomingMessage, HTTPServerResponse } from "bare-http1";
|
|
2
|
-
//#region core/server/static-file-server.d.ts
|
|
3
|
-
/** Accumulates an HTTP request body into a UTF-8 string. Node http emits
|
|
4
|
-
* Buffers, bare-http1 emits Uint8Arrays, and a setEncoding'd stream emits
|
|
5
|
-
* strings — `String(uint8array)` would join bytes with commas, so decode
|
|
6
|
-
* explicitly (the `/login` token body must match byte-for-byte). */
|
|
7
|
-
declare function collectRequestBody(req: HTTPIncomingMessage): Promise<string>;
|
|
8
|
-
type WebSocketLike = {
|
|
9
|
-
on(event: 'data', listener: (chunk: unknown) => void): unknown;
|
|
10
|
-
on(event: 'close', listener: () => void): unknown;
|
|
11
|
-
on(event: 'error', listener: (err: Error) => void): unknown;
|
|
12
|
-
write(data: unknown): boolean;
|
|
13
|
-
destroy(): void;
|
|
14
|
-
};
|
|
15
|
-
/** Handler for a registered HTTP route on the loopback server. */
|
|
16
|
-
type LoopbackRouteHandler = (req: HTTPIncomingMessage, res: HTTPServerResponse) => void;
|
|
17
|
-
/** Minimal shape of the HTTP request object handed to WS upgrade handlers. */
|
|
18
|
-
type LoopbackRequest = {
|
|
19
|
-
url?: string;
|
|
20
|
-
method?: string;
|
|
21
|
-
headers: Record<string, string | number>;
|
|
22
|
-
};
|
|
23
|
-
type LoopbackConnectionHandler = (socket: WebSocketLike, request: LoopbackRequest) => void;
|
|
24
|
-
interface LoopbackServerOptions {
|
|
25
|
-
/** Bind address. Defaults to `127.0.0.1`. */
|
|
26
|
-
host?: string;
|
|
27
|
-
/** Port to bind; `0` picks an ephemeral port (on-device). */
|
|
28
|
-
port?: number;
|
|
29
|
-
/** Require the per-session token/cookie on every request and WS upgrade.
|
|
30
|
-
* The dev backend turns this off (the browser cannot know the token). */
|
|
31
|
-
auth?: boolean;
|
|
32
|
-
/** Fixed session token (dev/tests); otherwise a random 32-byte token is
|
|
33
|
-
* generated on first bind. */
|
|
34
|
-
token?: string;
|
|
35
|
-
/** Idle timeout (ms) after which an authenticated WebSocket connection is
|
|
36
|
-
* dropped. Defaults to 60s. */
|
|
37
|
-
wsIdleTimeoutMs?: number;
|
|
38
|
-
}
|
|
39
|
-
interface LoopbackServer {
|
|
40
|
-
/** Resolves to the server origin (`http://127.0.0.1:<port>`), binding on
|
|
41
|
-
* first use. */
|
|
42
|
-
origin(): Promise<string>;
|
|
43
|
-
/** Resolves to a URL for `path` (`<origin><path>`). The per-session cookie
|
|
44
|
-
* authorizes media loads; no token is embedded in the URL anymore. */
|
|
45
|
-
url(path: string): Promise<string>;
|
|
46
|
-
/** The per-session token (generated on first bind). */
|
|
47
|
-
token(): string;
|
|
48
|
-
/** Resolves to the bound origin, port and token — written to the handoff
|
|
49
|
-
* file for the host to read before loading the page. */
|
|
50
|
-
credentials(): Promise<{
|
|
51
|
-
origin: string;
|
|
52
|
-
port: number;
|
|
53
|
-
token: string;
|
|
54
|
-
}>;
|
|
55
|
-
/** Serves `filePath` at `http://<origin><path>` (exact match). */
|
|
56
|
-
mount(path: string, filePath: string): void;
|
|
57
|
-
unmount(path: string): void;
|
|
58
|
-
/** Serves every file under `dirPath` below `prefix` (longest-prefix match),
|
|
59
|
-
* with an SPA fallback to `dirPath/index.html` for unknown GET paths. */
|
|
60
|
-
mountDir(prefix: string, dirPath: string): void;
|
|
61
|
-
/** Registers a handler for authenticated, handshaken WebSocket connections
|
|
62
|
-
* (the protocol socket). */
|
|
63
|
-
onConnection(handler: LoopbackConnectionHandler): void;
|
|
64
|
-
/** Registers an HTTP route. `handler` runs before mount resolution, after
|
|
65
|
-
* the auth gate (device mode requires the session cookie/token). The route
|
|
66
|
-
* body is read with `collectRequestBody`. */
|
|
67
|
-
registerRoute(method: string, path: string, handler: LoopbackRouteHandler): void;
|
|
68
|
-
/** Writes a raw frame to the connected protocol socket (if any) — the
|
|
69
|
-
* server-initiated push seam (e.g. a `photos.changed` dispatch). */
|
|
70
|
-
push(frame: Uint8Array): boolean;
|
|
71
|
-
/** Stops accepting connections and closes the server. */
|
|
72
|
-
close(cb?: (err?: Error | null) => void): void;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* The single loopback HTTP+WS server for the worklet. One origin serves the
|
|
76
|
-
* web app (`/`), the media files mounted by plugins, and the framed-protocol
|
|
77
|
-
* WebSocket socket the page connects to. On device it binds `127.0.0.1` on an
|
|
78
|
-
* ephemeral port. The bundled web app (directory mounts) is public content — a
|
|
79
|
-
* fresh WebView must load the page before the page can `POST /login`. Mounted
|
|
80
|
-
* session files (media) and the WS upgrade are gated by a per-session token,
|
|
81
|
-
* accepted as a `bare_session` cookie (set via `POST /login`), the
|
|
82
|
-
* `X-Bare-Token` header, or a `?token=` query param — defense in depth for
|
|
83
|
-
* non-browser clients. All responses send `Referrer-Policy: no-referrer` so
|
|
84
|
-
* token-bearing URLs never leak through a Referer header.
|
|
85
|
-
*/
|
|
86
|
-
declare function createLoopbackServer(options?: LoopbackServerOptions): LoopbackServer;
|
|
87
|
-
//#endregion
|
|
88
|
-
export { createLoopbackServer as i, LoopbackServer as n, collectRequestBody as r, LoopbackRouteHandler as t };
|