@ekrooh/bare 0.2.0 → 0.3.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 +21 -2
- package/dist/runtime.mjs +60 -5
- package/package.json +5 -3
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
|
@@ -51,8 +51,23 @@ declare function getIPC(): BareIPC;
|
|
|
51
51
|
* arguments. On-device hosts pass `["<webAssets>", "<storage>", "<cache>"]`,
|
|
52
52
|
* landing at `Bare.argv[0..2]`; the Bare CLI (dev) passes the binary and the
|
|
53
53
|
* script path instead, so a missing/absent config means dev mode (auth off,
|
|
54
|
-
* fixed port, no handoff file).
|
|
54
|
+
* fixed port, no handoff file). Falls back to the labeled CLI token syntax
|
|
55
|
+
* (see `resolveCliConfig`) when the positional shape doesn't match, so the
|
|
56
|
+
* same entry works for both device and dev runs. */
|
|
55
57
|
declare function resolveWorkletConfig(): WorkletRuntimeOptions;
|
|
58
|
+
/**
|
|
59
|
+
* Parses the dev/CLI labeled-token configuration from bare CLI arguments:
|
|
60
|
+
* `webassets=<dir>`, `storage=<dir>`, `cache=<dir>`, `host=<addr>`,
|
|
61
|
+
* `port=<n>`, `auth=<on|off|true|false|1|0>` — a single `key=value` separator.
|
|
62
|
+
* Unknown labels (e.g. `bootstrap=127.0.0.1:49737`) are ignored and stay
|
|
63
|
+
* consumer-owned.
|
|
64
|
+
*
|
|
65
|
+
* Returns the equivalent `WorkletRuntimeOptions` in **dev mode**: `deviceMode:
|
|
66
|
+
* false` (so a `storage=` token does not flip auth on or make the port
|
|
67
|
+
* ephemeral), `auth: false`, `port: 8080`, each overridable by a token. When
|
|
68
|
+
* no labeled tokens are present it returns `{}` (plain dev defaults).
|
|
69
|
+
*/
|
|
70
|
+
declare function resolveCliConfig(argv?: readonly string[]): WorkletRuntimeOptions;
|
|
56
71
|
type WorkletRuntimeOptions = {
|
|
57
72
|
/** Directory to serve at `/` (the built web app). */
|
|
58
73
|
webAssets?: string;
|
|
@@ -67,6 +82,10 @@ type WorkletRuntimeOptions = {
|
|
|
67
82
|
port?: number;
|
|
68
83
|
/** Require the per-session token/cookie. Defaults to on in device mode. */
|
|
69
84
|
auth?: boolean;
|
|
85
|
+
/** Explicit device-mode override. Defaults to on whenever `storage` is set
|
|
86
|
+
* (the on-device 3-arg contract); `resolveCliConfig` resolves it to false so
|
|
87
|
+
* a dev backend keeps auth off + fixed port even with a storage dir. */
|
|
88
|
+
deviceMode?: boolean;
|
|
70
89
|
/** Additional plugin manifests to register after the canonical defaults
|
|
71
90
|
* (consumer product plugins, e.g. `app.photos`). */
|
|
72
91
|
plugins?: PluginManifest[];
|
|
@@ -103,4 +122,4 @@ interface WorkletRuntime {
|
|
|
103
122
|
*/
|
|
104
123
|
declare function createWorkletRuntime(options?: WorkletRuntimeOptions): WorkletRuntime;
|
|
105
124
|
//#endregion
|
|
106
|
-
export { type LoopbackPush, type LoopbackRouteHandler, type LoopbackServer, WorkletRuntime, WorkletRuntimeConfig, WorkletRuntimeOptions, attachWebSocketProtocol, collectRequestBody, createLoopbackPush, createLoopbackServer, createWorkletRuntime, getIPC, resolveWorkletConfig };
|
|
125
|
+
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,18 @@ 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
554
|
* arguments. On-device hosts pass `["<webAssets>", "<storage>", "<cache>"]`,
|
|
552
555
|
* landing at `Bare.argv[0..2]`; the Bare CLI (dev) passes the binary and the
|
|
553
556
|
* script path instead, so a missing/absent config means dev mode (auth off,
|
|
554
|
-
* fixed port, no handoff file).
|
|
557
|
+
* fixed port, no handoff file). Falls back to the labeled CLI token syntax
|
|
558
|
+
* (see `resolveCliConfig`) when the positional shape doesn't match, so the
|
|
559
|
+
* same entry works for both device and dev runs. */
|
|
555
560
|
function resolveWorkletConfig() {
|
|
556
|
-
const argv =
|
|
561
|
+
const argv = readBareArgv();
|
|
557
562
|
const webAssets = argv[0];
|
|
558
563
|
const storage = argv[1];
|
|
559
564
|
const cache = argv[2];
|
|
@@ -569,7 +574,57 @@ function resolveWorkletConfig() {
|
|
|
569
574
|
};
|
|
570
575
|
}
|
|
571
576
|
} catch {}
|
|
572
|
-
return
|
|
577
|
+
return resolveCliConfig(argv);
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Parses the dev/CLI labeled-token configuration from bare CLI arguments:
|
|
581
|
+
* `webassets=<dir>`, `storage=<dir>`, `cache=<dir>`, `host=<addr>`,
|
|
582
|
+
* `port=<n>`, `auth=<on|off|true|false|1|0>` — a single `key=value` separator.
|
|
583
|
+
* Unknown labels (e.g. `bootstrap=127.0.0.1:49737`) are ignored and stay
|
|
584
|
+
* consumer-owned.
|
|
585
|
+
*
|
|
586
|
+
* Returns the equivalent `WorkletRuntimeOptions` in **dev mode**: `deviceMode:
|
|
587
|
+
* false` (so a `storage=` token does not flip auth on or make the port
|
|
588
|
+
* ephemeral), `auth: false`, `port: 8080`, each overridable by a token. When
|
|
589
|
+
* no labeled tokens are present it returns `{}` (plain dev defaults).
|
|
590
|
+
*/
|
|
591
|
+
function resolveCliConfig(argv = readBareArgv()) {
|
|
592
|
+
const parsed = {};
|
|
593
|
+
let matched = false;
|
|
594
|
+
for (const token of argv) {
|
|
595
|
+
const m = /^([A-Za-z][A-Za-z0-9]*)=(.*)$/.exec(token);
|
|
596
|
+
if (!m) continue;
|
|
597
|
+
const [, key, value] = m;
|
|
598
|
+
matched = true;
|
|
599
|
+
switch (key) {
|
|
600
|
+
case "webassets":
|
|
601
|
+
parsed.webAssets = value;
|
|
602
|
+
break;
|
|
603
|
+
case "storage":
|
|
604
|
+
parsed.storage = value;
|
|
605
|
+
break;
|
|
606
|
+
case "cache":
|
|
607
|
+
parsed.cache = value;
|
|
608
|
+
break;
|
|
609
|
+
case "host":
|
|
610
|
+
parsed.host = value;
|
|
611
|
+
break;
|
|
612
|
+
case "port": {
|
|
613
|
+
const n = Number(value);
|
|
614
|
+
if (Number.isInteger(n) && n >= 0 && n <= 65535) parsed.port = n;
|
|
615
|
+
else console.warn(`[bare] ignoring invalid port= token: "${value}"`);
|
|
616
|
+
break;
|
|
617
|
+
}
|
|
618
|
+
case "auth": parsed.auth = value !== "off" && value !== "false" && value !== "0";
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
if (!matched) return {};
|
|
622
|
+
return {
|
|
623
|
+
deviceMode: false,
|
|
624
|
+
auth: false,
|
|
625
|
+
port: 8080,
|
|
626
|
+
...parsed
|
|
627
|
+
};
|
|
573
628
|
}
|
|
574
629
|
function toUint8Array(data) {
|
|
575
630
|
if (data instanceof Uint8Array) return data;
|
|
@@ -587,7 +642,7 @@ function writeIpc(ipc, bytes) {
|
|
|
587
642
|
* wire p2p". Mirrors the reference wiring in `core/main.core.ts`.
|
|
588
643
|
*/
|
|
589
644
|
function createWorkletRuntime(options = {}) {
|
|
590
|
-
const deviceMode = options.storage !== void 0;
|
|
645
|
+
const deviceMode = options.deviceMode ?? options.storage !== void 0;
|
|
591
646
|
const auth = options.auth ?? deviceMode;
|
|
592
647
|
const port = options.port ?? (deviceMode ? 0 : 8080);
|
|
593
648
|
const protocol = new MessageProtocol({
|
|
@@ -670,4 +725,4 @@ function createWorkletRuntime(options = {}) {
|
|
|
670
725
|
};
|
|
671
726
|
}
|
|
672
727
|
//#endregion
|
|
673
|
-
export { attachWebSocketProtocol, collectRequestBody, createLoopbackPush, createLoopbackServer, createWorkletRuntime, getIPC, resolveWorkletConfig };
|
|
728
|
+
export { attachWebSocketProtocol, collectRequestBody, createLoopbackPush, createLoopbackServer, createWorkletRuntime, getIPC, resolveCliConfig, resolveWorkletConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ekrooh/bare",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "One soul, many platforms — 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",
|
|
@@ -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",
|