@volter/world-runtime 3.0.18 → 3.0.20
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/dist/src/served-world.d.ts +11 -0
- package/dist/src/served-world.js +27 -0
- package/package.json +4 -4
- package/src/served-world.ts +20 -0
|
@@ -375,6 +375,17 @@ export declare class WorldDoors {
|
|
|
375
375
|
vendor: string;
|
|
376
376
|
hosts: string[];
|
|
377
377
|
}>>;
|
|
378
|
+
/** What a twin asks an application (`ctx.ask`) that this World can answer truthfully, where no process routes it (a
|
|
379
|
+
* hosted World's isolate): a GET or HEAD of a URL whose hostname one of this World's twins answers (its hostsClaimed
|
|
380
|
+
* door: a Cloudflare twin's Worker route or custom domain) is that twin's answer, read as a browser reads the site
|
|
381
|
+
* here (`site`). Any other question (another method, a hostname no twin claims) is undefined: it goes on as it would
|
|
382
|
+
* without this router (the application route, the World's egress rule, the network), never a World-made answer
|
|
383
|
+
* dressed as the application's (architecture, "What an author writes, and how"). Given to each twin's fetch as its
|
|
384
|
+
* `application` by apps/cloud. */
|
|
385
|
+
askInWorld(target: string, init: RequestInit): Promise<{
|
|
386
|
+
status: number;
|
|
387
|
+
body: string;
|
|
388
|
+
} | undefined>;
|
|
378
389
|
/** A hostname one of this World's twins answers (its hostsClaimed door lists it), read as a browser reads it there:
|
|
379
390
|
* the request goes to that twin with the hostname as its original host, as the injector routes it inside the World.
|
|
380
391
|
* Reads only: the site is the twin's state as the World holds it, never a way to write it. */
|
package/dist/src/served-world.js
CHANGED
|
@@ -1038,6 +1038,33 @@ export class WorldDoors {
|
|
|
1038
1038
|
}
|
|
1039
1039
|
return out;
|
|
1040
1040
|
}
|
|
1041
|
+
/** What a twin asks an application (`ctx.ask`) that this World can answer truthfully, where no process routes it (a
|
|
1042
|
+
* hosted World's isolate): a GET or HEAD of a URL whose hostname one of this World's twins answers (its hostsClaimed
|
|
1043
|
+
* door: a Cloudflare twin's Worker route or custom domain) is that twin's answer, read as a browser reads the site
|
|
1044
|
+
* here (`site`). Any other question (another method, a hostname no twin claims) is undefined: it goes on as it would
|
|
1045
|
+
* without this router (the application route, the World's egress rule, the network), never a World-made answer
|
|
1046
|
+
* dressed as the application's (architecture, "What an author writes, and how"). Given to each twin's fetch as its
|
|
1047
|
+
* `application` by apps/cloud. */
|
|
1048
|
+
async askInWorld(target, init) {
|
|
1049
|
+
const method = (init.method ?? 'GET').toUpperCase();
|
|
1050
|
+
if (method !== 'GET' && method !== 'HEAD')
|
|
1051
|
+
return undefined;
|
|
1052
|
+
let url;
|
|
1053
|
+
try {
|
|
1054
|
+
url = new URL(target);
|
|
1055
|
+
}
|
|
1056
|
+
catch {
|
|
1057
|
+
return undefined;
|
|
1058
|
+
}
|
|
1059
|
+
if (url.protocol !== 'https:' && url.protocol !== 'http:')
|
|
1060
|
+
return undefined;
|
|
1061
|
+
const host = url.hostname.toLowerCase().replace(/\.$/, '');
|
|
1062
|
+
const claimed = await this.claimedHosts(url.origin);
|
|
1063
|
+
if (!claimed.some(({ hosts }) => hosts.includes(host)))
|
|
1064
|
+
return undefined;
|
|
1065
|
+
const answer = await this.site(new Request(url, { method, headers: init.headers ?? {} }), host);
|
|
1066
|
+
return { status: answer.status, body: await answer.text() };
|
|
1067
|
+
}
|
|
1041
1068
|
/** A hostname one of this World's twins answers (its hostsClaimed door lists it), read as a browser reads it there:
|
|
1042
1069
|
* the request goes to that twin with the hostname as its original host, as the injector routes it inside the World.
|
|
1043
1070
|
* Reads only: the site is the twin's state as the World holds it, never a way to write it. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volter/world-runtime",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.20",
|
|
4
4
|
"description": "World configs for twins: boot named local runtimes, allocate ports, generate world.env/instance.json, and run apps against fake-key twin worlds.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"twin",
|
|
@@ -68,14 +68,14 @@
|
|
|
68
68
|
"node": ">=22.3"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
|
-
"@volter/world-core": "3.0.
|
|
72
|
-
"@volter/world-console": "3.0.
|
|
71
|
+
"@volter/world-core": "3.0.20",
|
|
72
|
+
"@volter/world-console": "3.0.15"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"@electric-sql/pglite": "0.5.8",
|
|
76
76
|
"@electric-sql/pglite-pgvector": "0.0.9",
|
|
77
77
|
"@volter/world-access": "3.0.1",
|
|
78
|
-
"@volter/world-core": "3.0.
|
|
78
|
+
"@volter/world-core": "3.0.20",
|
|
79
79
|
"pg-gateway": "0.3.0-beta.4",
|
|
80
80
|
"smol-toml": "^1.8.0",
|
|
81
81
|
"yaml": "2.9.0"
|
package/src/served-world.ts
CHANGED
|
@@ -940,6 +940,26 @@ export class WorldDoors {
|
|
|
940
940
|
return out;
|
|
941
941
|
}
|
|
942
942
|
|
|
943
|
+
/** What a twin asks an application (`ctx.ask`) that this World can answer truthfully, where no process routes it (a
|
|
944
|
+
* hosted World's isolate): a GET or HEAD of a URL whose hostname one of this World's twins answers (its hostsClaimed
|
|
945
|
+
* door: a Cloudflare twin's Worker route or custom domain) is that twin's answer, read as a browser reads the site
|
|
946
|
+
* here (`site`). Any other question (another method, a hostname no twin claims) is undefined: it goes on as it would
|
|
947
|
+
* without this router (the application route, the World's egress rule, the network), never a World-made answer
|
|
948
|
+
* dressed as the application's (architecture, "What an author writes, and how"). Given to each twin's fetch as its
|
|
949
|
+
* `application` by apps/cloud. */
|
|
950
|
+
async askInWorld(target: string, init: RequestInit): Promise<{ status: number; body: string } | undefined> {
|
|
951
|
+
const method = (init.method ?? 'GET').toUpperCase();
|
|
952
|
+
if (method !== 'GET' && method !== 'HEAD') return undefined;
|
|
953
|
+
let url: URL;
|
|
954
|
+
try { url = new URL(target); } catch { return undefined; }
|
|
955
|
+
if (url.protocol !== 'https:' && url.protocol !== 'http:') return undefined;
|
|
956
|
+
const host = url.hostname.toLowerCase().replace(/\.$/, '');
|
|
957
|
+
const claimed = await this.claimedHosts(url.origin);
|
|
958
|
+
if (!claimed.some(({ hosts }) => hosts.includes(host))) return undefined;
|
|
959
|
+
const answer = await this.site(new Request(url, { method, headers: init.headers ?? {} }), host);
|
|
960
|
+
return { status: answer.status, body: await answer.text() };
|
|
961
|
+
}
|
|
962
|
+
|
|
943
963
|
/** A hostname one of this World's twins answers (its hostsClaimed door lists it), read as a browser reads it there:
|
|
944
964
|
* the request goes to that twin with the hostname as its original host, as the injector routes it inside the World.
|
|
945
965
|
* Reads only: the site is the twin's state as the World holds it, never a way to write it. */
|