@ekrooh/bare 0.2.0 → 0.4.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 +18 -0
- package/dist/runtime.d.mts +25 -5
- package/dist/runtime.mjs +65 -9
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -206,6 +206,24 @@ npm run build # core bundle + web assets
|
|
|
206
206
|
|
|
207
207
|
`./gradlew build` additionally runs the host library's JUnit tests.
|
|
208
208
|
|
|
209
|
+
### Consuming the published AAR
|
|
210
|
+
|
|
211
|
+
`io.github.anderscan.ekrooh:bare-host` is published to **Maven Central** (no auth) on the same
|
|
212
|
+
tag as the npm package — pin it to your `@ekrooh/bare` version:
|
|
213
|
+
|
|
214
|
+
```gradle
|
|
215
|
+
repositories {
|
|
216
|
+
mavenCentral() // default in modern Gradle; no credentials needed
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
dependencies {
|
|
220
|
+
implementation "io.github.anderscan.ekrooh:bare-host:<version>"
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
GitHub Packages (`maven.pkg.github.com/AndersCan/ekrooh`) remains a fallback
|
|
225
|
+
but requires a `read:packages` PAT — prefer Maven Central.
|
|
226
|
+
|
|
209
227
|
## iOS build
|
|
210
228
|
|
|
211
229
|
Prerequisites: Xcode (macOS), Bare Kit prebuilds, and `xcodegen`.
|
package/dist/runtime.d.mts
CHANGED
|
@@ -48,11 +48,27 @@ declare function getIPC(): BareIPC;
|
|
|
48
48
|
//#endregion
|
|
49
49
|
//#region core/runtime.d.ts
|
|
50
50
|
/** Resolves the host-provided worklet configuration from `start(...)`
|
|
51
|
-
* arguments. On-device hosts pass `["<webAssets>", "<storage>", "<cache>"]
|
|
52
|
-
* landing at `Bare.argv[0..2]`;
|
|
53
|
-
*
|
|
54
|
-
* fixed port, no handoff
|
|
51
|
+
* arguments. On-device hosts pass `["<webAssets>", "<storage>", "<cache>"]`
|
|
52
|
+
* (three existing directories, in that order), landing at `Bare.argv[0..2]`;
|
|
53
|
+
* the Bare CLI (dev) passes the binary and the script path instead, so a
|
|
54
|
+
* missing/absent config means dev mode (auth off, fixed port, no handoff
|
|
55
|
+
* file). Falls back to the labeled CLI token syntax (see `resolveCliConfig`)
|
|
56
|
+
* when the positional shape doesn't match, so the same entry works for both
|
|
57
|
+
* device and dev runs. */
|
|
55
58
|
declare function resolveWorkletConfig(): WorkletRuntimeOptions;
|
|
59
|
+
/**
|
|
60
|
+
* Parses the dev/CLI labeled-token configuration from bare CLI arguments:
|
|
61
|
+
* `webassets=<dir>`, `storage=<dir>`, `cache=<dir>`, `host=<addr>`,
|
|
62
|
+
* `port=<n>`, `auth=<on|off|true|false|1|0>` — a single `key=value` separator.
|
|
63
|
+
* Unknown labels (e.g. `bootstrap=127.0.0.1:49737`) are ignored and stay
|
|
64
|
+
* consumer-owned.
|
|
65
|
+
*
|
|
66
|
+
* Returns the equivalent `WorkletRuntimeOptions` in **dev mode**: `deviceMode:
|
|
67
|
+
* false` (so a `storage=` token does not flip auth on or make the port
|
|
68
|
+
* ephemeral), `auth: false`, `port: 8080`, each overridable by a token. When
|
|
69
|
+
* no labeled tokens are present it returns `{}` (plain dev defaults).
|
|
70
|
+
*/
|
|
71
|
+
declare function resolveCliConfig(argv?: readonly string[]): WorkletRuntimeOptions;
|
|
56
72
|
type WorkletRuntimeOptions = {
|
|
57
73
|
/** Directory to serve at `/` (the built web app). */
|
|
58
74
|
webAssets?: string;
|
|
@@ -67,6 +83,10 @@ type WorkletRuntimeOptions = {
|
|
|
67
83
|
port?: number;
|
|
68
84
|
/** Require the per-session token/cookie. Defaults to on in device mode. */
|
|
69
85
|
auth?: boolean;
|
|
86
|
+
/** Explicit device-mode override. Defaults to on whenever `storage` is set
|
|
87
|
+
* (the on-device 3-arg contract); `resolveCliConfig` resolves it to false so
|
|
88
|
+
* a dev backend keeps auth off + fixed port even with a storage dir. */
|
|
89
|
+
deviceMode?: boolean;
|
|
70
90
|
/** Additional plugin manifests to register after the canonical defaults
|
|
71
91
|
* (consumer product plugins, e.g. `app.photos`). */
|
|
72
92
|
plugins?: PluginManifest[];
|
|
@@ -103,4 +123,4 @@ interface WorkletRuntime {
|
|
|
103
123
|
*/
|
|
104
124
|
declare function createWorkletRuntime(options?: WorkletRuntimeOptions): WorkletRuntime;
|
|
105
125
|
//#endregion
|
|
106
|
-
export { type LoopbackPush, type LoopbackRouteHandler, type LoopbackServer, WorkletRuntime, WorkletRuntimeConfig, WorkletRuntimeOptions, attachWebSocketProtocol, collectRequestBody, createLoopbackPush, createLoopbackServer, createWorkletRuntime, getIPC, resolveWorkletConfig };
|
|
126
|
+
export { type LoopbackPush, type LoopbackRouteHandler, type LoopbackServer, WorkletRuntime, WorkletRuntimeConfig, WorkletRuntimeOptions, attachWebSocketProtocol, collectRequestBody, createLoopbackPush, createLoopbackServer, createWorkletRuntime, getIPC, resolveCliConfig, resolveWorkletConfig };
|
package/dist/runtime.mjs
CHANGED
|
@@ -547,13 +547,19 @@ function attachWebSocketProtocol(server, context) {
|
|
|
547
547
|
}
|
|
548
548
|
//#endregion
|
|
549
549
|
//#region core/runtime.ts
|
|
550
|
+
function readBareArgv() {
|
|
551
|
+
return typeof Bare !== "undefined" && Array.isArray(Bare.argv) ? Bare.argv : [];
|
|
552
|
+
}
|
|
550
553
|
/** Resolves the host-provided worklet configuration from `start(...)`
|
|
551
|
-
* arguments. On-device hosts pass `["<webAssets>", "<storage>", "<cache>"]
|
|
552
|
-
* landing at `Bare.argv[0..2]`;
|
|
553
|
-
*
|
|
554
|
-
* fixed port, no handoff
|
|
554
|
+
* arguments. On-device hosts pass `["<webAssets>", "<storage>", "<cache>"]`
|
|
555
|
+
* (three existing directories, in that order), landing at `Bare.argv[0..2]`;
|
|
556
|
+
* the Bare CLI (dev) passes the binary and the script path instead, so a
|
|
557
|
+
* missing/absent config means dev mode (auth off, fixed port, no handoff
|
|
558
|
+
* file). Falls back to the labeled CLI token syntax (see `resolveCliConfig`)
|
|
559
|
+
* when the positional shape doesn't match, so the same entry works for both
|
|
560
|
+
* device and dev runs. */
|
|
555
561
|
function resolveWorkletConfig() {
|
|
556
|
-
const argv =
|
|
562
|
+
const argv = readBareArgv();
|
|
557
563
|
const webAssets = argv[0];
|
|
558
564
|
const storage = argv[1];
|
|
559
565
|
const cache = argv[2];
|
|
@@ -561,7 +567,7 @@ function resolveWorkletConfig() {
|
|
|
561
567
|
const isDir = (p) => fs.statSync(p).isDirectory();
|
|
562
568
|
if (isDir(webAssets) && isDir(storage)) {
|
|
563
569
|
const cacheDir = typeof cache === "string" && isDir(cache) ? cache : storage;
|
|
564
|
-
if (cacheDir !== cache) console.warn("[bare] cache dir missing or not a directory; falling back to the storage dir");
|
|
570
|
+
if (cacheDir !== cache) console.warn("[bare] cache dir missing or not a directory; falling back to the storage dir. Pass three dirs in order to the worklet: [webAssets, storage, cache].");
|
|
565
571
|
return {
|
|
566
572
|
webAssets,
|
|
567
573
|
storage,
|
|
@@ -569,7 +575,57 @@ function resolveWorkletConfig() {
|
|
|
569
575
|
};
|
|
570
576
|
}
|
|
571
577
|
} catch {}
|
|
572
|
-
return
|
|
578
|
+
return resolveCliConfig(argv);
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Parses the dev/CLI labeled-token configuration from bare CLI arguments:
|
|
582
|
+
* `webassets=<dir>`, `storage=<dir>`, `cache=<dir>`, `host=<addr>`,
|
|
583
|
+
* `port=<n>`, `auth=<on|off|true|false|1|0>` — a single `key=value` separator.
|
|
584
|
+
* Unknown labels (e.g. `bootstrap=127.0.0.1:49737`) are ignored and stay
|
|
585
|
+
* consumer-owned.
|
|
586
|
+
*
|
|
587
|
+
* Returns the equivalent `WorkletRuntimeOptions` in **dev mode**: `deviceMode:
|
|
588
|
+
* false` (so a `storage=` token does not flip auth on or make the port
|
|
589
|
+
* ephemeral), `auth: false`, `port: 8080`, each overridable by a token. When
|
|
590
|
+
* no labeled tokens are present it returns `{}` (plain dev defaults).
|
|
591
|
+
*/
|
|
592
|
+
function resolveCliConfig(argv = readBareArgv()) {
|
|
593
|
+
const parsed = {};
|
|
594
|
+
let matched = false;
|
|
595
|
+
for (const token of argv) {
|
|
596
|
+
const m = /^([A-Za-z][A-Za-z0-9]*)=(.*)$/.exec(token);
|
|
597
|
+
if (!m) continue;
|
|
598
|
+
const [, key, value] = m;
|
|
599
|
+
matched = true;
|
|
600
|
+
switch (key) {
|
|
601
|
+
case "webassets":
|
|
602
|
+
parsed.webAssets = value;
|
|
603
|
+
break;
|
|
604
|
+
case "storage":
|
|
605
|
+
parsed.storage = value;
|
|
606
|
+
break;
|
|
607
|
+
case "cache":
|
|
608
|
+
parsed.cache = value;
|
|
609
|
+
break;
|
|
610
|
+
case "host":
|
|
611
|
+
parsed.host = value;
|
|
612
|
+
break;
|
|
613
|
+
case "port": {
|
|
614
|
+
const n = Number(value);
|
|
615
|
+
if (Number.isInteger(n) && n >= 0 && n <= 65535) parsed.port = n;
|
|
616
|
+
else console.warn(`[bare] ignoring invalid port= token: "${value}"`);
|
|
617
|
+
break;
|
|
618
|
+
}
|
|
619
|
+
case "auth": parsed.auth = value !== "off" && value !== "false" && value !== "0";
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
if (!matched) return {};
|
|
623
|
+
return {
|
|
624
|
+
deviceMode: false,
|
|
625
|
+
auth: false,
|
|
626
|
+
port: 8080,
|
|
627
|
+
...parsed
|
|
628
|
+
};
|
|
573
629
|
}
|
|
574
630
|
function toUint8Array(data) {
|
|
575
631
|
if (data instanceof Uint8Array) return data;
|
|
@@ -587,7 +643,7 @@ function writeIpc(ipc, bytes) {
|
|
|
587
643
|
* wire p2p". Mirrors the reference wiring in `core/main.core.ts`.
|
|
588
644
|
*/
|
|
589
645
|
function createWorkletRuntime(options = {}) {
|
|
590
|
-
const deviceMode = options.storage !== void 0;
|
|
646
|
+
const deviceMode = options.deviceMode ?? options.storage !== void 0;
|
|
591
647
|
const auth = options.auth ?? deviceMode;
|
|
592
648
|
const port = options.port ?? (deviceMode ? 0 : 8080);
|
|
593
649
|
const protocol = new MessageProtocol({
|
|
@@ -670,4 +726,4 @@ function createWorkletRuntime(options = {}) {
|
|
|
670
726
|
};
|
|
671
727
|
}
|
|
672
728
|
//#endregion
|
|
673
|
-
export { attachWebSocketProtocol, collectRequestBody, createLoopbackPush, createLoopbackServer, createWorkletRuntime, getIPC, resolveWorkletConfig };
|
|
729
|
+
export { attachWebSocketProtocol, collectRequestBody, createLoopbackPush, createLoopbackServer, createWorkletRuntime, getIPC, resolveCliConfig, resolveWorkletConfig };
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ekrooh/bare",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "One soul, many platforms
|
|
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",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"workspaces": [
|
|
12
12
|
"examples/*",
|
|
13
|
+
"examples/consumer-basic",
|
|
13
14
|
"e2e",
|
|
14
15
|
"apps/*"
|
|
15
16
|
],
|
|
@@ -36,9 +37,10 @@
|
|
|
36
37
|
"docs:preview": "vp run docs#preview",
|
|
37
38
|
"docs:check": "node scripts/docs-check.mjs",
|
|
38
39
|
"typecheck": "tsc --noEmit",
|
|
39
|
-
"test": "vp test && npm run test:e2e:web && npm run test:e2e:harness",
|
|
40
|
+
"test": "vp test && npm run test:e2e:web && npm run test:e2e:harness && npm run test:e2e:consumer",
|
|
40
41
|
"test:unit": "vp test",
|
|
41
42
|
"test:e2e:web": "node scripts/playwright-local-browsers.mjs test",
|
|
43
|
+
"test:e2e:consumer": "node scripts/playwright-local-browsers.mjs test --config examples/consumer-basic/playwright.config.ts",
|
|
42
44
|
"dev": "concurrently \"vp -C examples/web dev\" \"npm run dev:bare\"",
|
|
43
45
|
"predev": "npm run build:pkg",
|
|
44
46
|
"dev:bare": "node scripts/dev-bare.mjs",
|
|
@@ -87,7 +89,7 @@
|
|
|
87
89
|
},
|
|
88
90
|
"dependencies": {
|
|
89
91
|
"@mantaq/core": "^0.2.0",
|
|
90
|
-
"@mantaq/sugar": "^0.
|
|
92
|
+
"@mantaq/sugar": "^0.3.0",
|
|
91
93
|
"bare-crypto": "^1.15.3",
|
|
92
94
|
"bare-encoding": "^1.0.3",
|
|
93
95
|
"bare-env": "^3.0.0",
|