@nervur.org/installer-node 0.0.0-stage → 0.37.1
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/LICENSE +105 -0
- package/README.md +158 -2
- package/SECURITY.md +8 -0
- package/bin/nervur.js +5 -0
- package/cargo/emscripten-module.wasm +0 -0
- package/cargo/manifest.json +1 -0
- package/cargo/sqlite3.wasm +0 -0
- package/cargo/table-i-i.wasm +0 -0
- package/cargo/table-i-ii.wasm +0 -0
- package/cargo/table-i-iii.wasm +0 -0
- package/cargo/table-i-iiii.wasm +0 -0
- package/cargo/table-i-iiiii.wasm +0 -0
- package/cargo/table-i-iiij.wasm +0 -0
- package/cargo/table-i-ij.wasm +0 -0
- package/cargo/table-v-ii.wasm +0 -0
- package/cargo/table-v-iii.wasm +0 -0
- package/cargo/worker.js +30756 -0
- package/organs/console/node/guard.d.ts +10 -0
- package/organs/console/node/guard.js +52 -0
- package/organs/console/node/index.d.ts +4 -0
- package/organs/console/node/index.js +5 -0
- package/organs/console/node/line.d.ts +16 -0
- package/organs/console/node/line.js +150 -0
- package/organs/console/node/main.js +51 -0
- package/organs/console/node/program.d.ts +1 -0
- package/organs/console/node/program.js +5 -0
- package/organs/console/node/proof.d.ts +15 -0
- package/organs/console/node/proof.js +84 -0
- package/organs/console/node/socket.d.ts +15 -0
- package/organs/console/node/socket.js +99 -0
- package/organs/disk/index.d.ts +1 -0
- package/organs/disk/index.js +2 -0
- package/organs/disk/node/files.js +162 -0
- package/organs/disk/node/main.js +20 -0
- package/organs/disk/node/program.d.ts +1 -0
- package/organs/disk/node/program.js +5 -0
- package/organs/disk/organ.d.ts +5 -0
- package/organs/disk/organ.js +69 -0
- package/organs/network/node/fill.d.ts +21 -0
- package/organs/network/node/fill.js +195 -0
- package/organs/network/node/flows.js +66 -0
- package/organs/network/node/half.js +260 -0
- package/organs/network/node/lines.d.ts +29 -0
- package/organs/network/node/lines.js +236 -0
- package/organs/network/node/link.d.ts +24 -0
- package/organs/network/node/link.js +215 -0
- package/organs/network/node/main.js +41 -0
- package/organs/network/node/moved.d.ts +2 -0
- package/organs/network/node/moved.js +20 -0
- package/organs/network/node/near.d.ts +63 -0
- package/organs/network/node/near.js +263 -0
- package/organs/network/node/program.d.ts +1 -0
- package/organs/network/node/program.js +5 -0
- package/organs/network/node/schemes.d.ts +1 -0
- package/organs/network/node/schemes.js +2 -0
- package/organs/network/node/sent.d.ts +13 -0
- package/organs/network/node/sent.js +101 -0
- package/organs/network/node/served.d.ts +19 -0
- package/organs/network/node/served.js +237 -0
- package/organs/screen/node/client.js +3 -0
- package/organs/screen/node/follow.js +266 -0
- package/organs/screen/node/frames.js +26 -0
- package/organs/screen/node/held.js +27 -0
- package/organs/screen/node/http.js +179 -0
- package/organs/screen/node/lay.js +116 -0
- package/organs/screen/node/leave.js +27 -0
- package/organs/screen/node/linked.js +69 -0
- package/organs/screen/node/listen.js +61 -0
- package/organs/screen/node/look.js +121 -0
- package/organs/screen/node/loop.js +154 -0
- package/organs/screen/node/main.js +74 -0
- package/organs/screen/node/mirror.js +112 -0
- package/organs/screen/node/notice.js +44 -0
- package/organs/screen/node/presser.js +11 -0
- package/organs/screen/node/presses.js +108 -0
- package/organs/screen/node/program.d.ts +1 -0
- package/organs/screen/node/program.js +5 -0
- package/organs/screen/node/shown.js +205 -0
- package/organs/screen/node/standing.js +29 -0
- package/organs/screen/node/state.js +80 -0
- package/organs/screen/node/tell.js +47 -0
- package/organs/screen/node/uid.js +65 -0
- package/organs/screen/node/worn.js +23 -0
- package/organs/shell/index.d.ts +1 -0
- package/organs/shell/index.js +2 -0
- package/organs/shell/node/main.js +26 -0
- package/organs/shell/node/output.js +70 -0
- package/organs/shell/node/pressure.js +14 -0
- package/organs/shell/node/program.d.ts +1 -0
- package/organs/shell/node/program.js +5 -0
- package/organs/shell/node/runs.js +220 -0
- package/organs/shell/node/told.js +70 -0
- package/organs/shell/organ.d.ts +5 -0
- package/organs/shell/organ.js +59 -0
- package/package.json +43 -4
- package/src/command/act.d.ts +31 -0
- package/src/command/act.js +256 -0
- package/src/command/answers.d.ts +3 -0
- package/src/command/answers.js +232 -0
- package/src/command/args.d.ts +14 -0
- package/src/command/args.js +220 -0
- package/src/command/arrive.d.ts +2 -0
- package/src/command/arrive.js +21 -0
- package/src/command/asked.d.ts +18 -0
- package/src/command/asked.js +49 -0
- package/src/command/backup.d.ts +18 -0
- package/src/command/backup.js +261 -0
- package/src/command/before.d.ts +41 -0
- package/src/command/before.js +237 -0
- package/src/command/born.d.ts +27 -0
- package/src/command/born.js +103 -0
- package/src/command/bridge.d.ts +19 -0
- package/src/command/bridge.js +152 -0
- package/src/command/chain.d.ts +9 -0
- package/src/command/chain.js +48 -0
- package/src/command/channel.d.ts +29 -0
- package/src/command/channel.js +263 -0
- package/src/command/choices.d.ts +35 -0
- package/src/command/choices.js +173 -0
- package/src/command/claim.d.ts +12 -0
- package/src/command/claim.js +46 -0
- package/src/command/commands.d.ts +16 -0
- package/src/command/commands.js +257 -0
- package/src/command/ends.d.ts +16 -0
- package/src/command/ends.js +78 -0
- package/src/command/follow.d.ts +12 -0
- package/src/command/follow.js +66 -0
- package/src/command/given.d.ts +39 -0
- package/src/command/given.js +53 -0
- package/src/command/held.d.ts +15 -0
- package/src/command/held.js +56 -0
- package/src/command/index.d.ts +1 -0
- package/src/command/index.js +203 -0
- package/src/command/jailer.d.ts +28 -0
- package/src/command/jailer.js +135 -0
- package/src/command/laid.d.ts +6 -0
- package/src/command/laid.js +31 -0
- package/src/command/left.d.ts +9 -0
- package/src/command/left.js +34 -0
- package/src/command/line.d.ts +7 -0
- package/src/command/line.js +39 -0
- package/src/command/link.d.ts +30 -0
- package/src/command/link.js +123 -0
- package/src/command/lobes.d.ts +1 -0
- package/src/command/lobes.js +10 -0
- package/src/command/locks.d.ts +17 -0
- package/src/command/locks.js +76 -0
- package/src/command/mcp/calls.d.ts +27 -0
- package/src/command/mcp/calls.js +155 -0
- package/src/command/mcp/notices.d.ts +22 -0
- package/src/command/mcp/notices.js +203 -0
- package/src/command/mcp/resources.d.ts +31 -0
- package/src/command/mcp/resources.js +108 -0
- package/src/command/mcp/server.d.ts +19 -0
- package/src/command/mcp/server.js +149 -0
- package/src/command/mcp/tools.d.ts +39 -0
- package/src/command/mcp/tools.js +131 -0
- package/src/command/mcp.d.ts +8 -0
- package/src/command/mcp.js +39 -0
- package/src/command/noticed.d.ts +11 -0
- package/src/command/noticed.js +55 -0
- package/src/command/older.d.ts +11 -0
- package/src/command/older.js +45 -0
- package/src/command/open.d.ts +24 -0
- package/src/command/open.js +107 -0
- package/src/command/passphrase.d.ts +6 -0
- package/src/command/passphrase.js +82 -0
- package/src/command/reclaim.d.ts +7 -0
- package/src/command/reclaim.js +47 -0
- package/src/command/refused.d.ts +4 -0
- package/src/command/refused.js +27 -0
- package/src/command/release.d.ts +27 -0
- package/src/command/release.js +153 -0
- package/src/command/repo.d.ts +31 -0
- package/src/command/repo.js +133 -0
- package/src/command/rewrap.d.ts +16 -0
- package/src/command/rewrap.js +175 -0
- package/src/command/runtime.d.ts +25 -0
- package/src/command/runtime.js +175 -0
- package/src/command/salvage.d.ts +4 -0
- package/src/command/salvage.js +42 -0
- package/src/command/screen.d.ts +14 -0
- package/src/command/screen.js +62 -0
- package/src/command/spawn.d.ts +23 -0
- package/src/command/spawn.js +213 -0
- package/src/command/start.d.ts +34 -0
- package/src/command/start.js +246 -0
- package/src/command/state.d.ts +5 -0
- package/src/command/state.js +39 -0
- package/src/command/token.d.ts +1 -0
- package/src/command/token.js +9 -0
- package/src/command/trial.d.ts +17 -0
- package/src/command/trial.js +92 -0
- package/src/command/vouch.d.ts +1 -0
- package/src/command/vouch.js +15 -0
- package/src/command/windows-processes.d.ts +2 -0
- package/src/command/windows-processes.js +22 -0
- package/src/command/wipe.d.ts +9 -0
- package/src/command/wipe.js +105 -0
- package/src/command/words.d.ts +5 -0
- package/src/command/words.js +53 -0
- package/src/door/claim.d.ts +5 -0
- package/src/door/claim.js +21 -0
- package/src/door/claimed.d.ts +7 -0
- package/src/door/claimed.js +110 -0
- package/src/door/configuration.d.ts +40 -0
- package/src/door/configuration.js +206 -0
- package/src/door/design.d.ts +13 -0
- package/src/door/design.js +71 -0
- package/src/door/digests.d.ts +7 -0
- package/src/door/digests.js +36 -0
- package/src/door/distribution.d.ts +25 -0
- package/src/door/distribution.js +88 -0
- package/src/door/door.d.ts +41 -0
- package/src/door/door.js +219 -0
- package/src/door/dressed.d.ts +34 -0
- package/src/door/dressed.js +182 -0
- package/src/door/faculties.d.ts +29 -0
- package/src/door/faculties.js +88 -0
- package/src/door/longest.d.ts +6 -0
- package/src/door/longest.js +25 -0
- package/src/fills/account-only.d.ts +3 -0
- package/src/fills/account-only.js +24 -0
- package/src/fills/boot-key.d.ts +21 -0
- package/src/fills/boot-key.js +70 -0
- package/src/fills/boot-move.d.ts +25 -0
- package/src/fills/boot-move.js +86 -0
- package/src/fills/bridge.d.ts +13 -0
- package/src/fills/bridge.js +86 -0
- package/src/fills/chance.d.ts +2 -0
- package/src/fills/chance.js +7 -0
- package/src/fills/crypto.d.ts +2 -0
- package/src/fills/crypto.js +94 -0
- package/src/fills/flushed.d.ts +9 -0
- package/src/fills/flushed.js +80 -0
- package/src/fills/hardware.d.ts +18 -0
- package/src/fills/hardware.js +70 -0
- package/src/fills/held.d.ts +31 -0
- package/src/fills/held.js +171 -0
- package/src/fills/keepers.d.ts +23 -0
- package/src/fills/keepers.js +151 -0
- package/src/fills/keyring.d.ts +19 -0
- package/src/fills/keyring.js +131 -0
- package/src/fills/pages.d.ts +3 -0
- package/src/fills/pages.js +260 -0
- package/src/fills/reserve.d.ts +11 -0
- package/src/fills/reserve.js +72 -0
- package/src/fills/time.d.ts +2 -0
- package/src/fills/time.js +29 -0
- package/src/fills/unlocker.d.ts +6 -0
- package/src/fills/unlocker.js +26 -0
- package/src/fills/vitals.d.ts +8 -0
- package/src/fills/vitals.js +100 -0
- package/src/fills/windows-start.d.ts +2 -0
- package/src/fills/windows-start.js +21 -0
- package/src/halves/build.d.ts +10 -0
- package/src/halves/build.js +219 -0
- package/src/halves/end.d.ts +17 -0
- package/src/halves/end.js +157 -0
- package/src/halves/genome.d.ts +3 -0
- package/src/halves/genome.js +21 -0
- package/src/halves/handler.d.ts +8 -0
- package/src/halves/handler.js +40 -0
- package/src/halves/index.d.ts +5 -0
- package/src/halves/index.js +6 -0
- package/src/halves/laid.d.ts +12 -0
- package/src/halves/laid.js +103 -0
- package/src/halves/lent.d.ts +6 -0
- package/src/halves/lent.js +147 -0
- package/src/halves/native.d.ts +12 -0
- package/src/halves/native.js +53 -0
- package/src/halves/statements.d.ts +23 -0
- package/src/halves/statements.js +165 -0
- package/src/halves/tokens.d.ts +22 -0
- package/src/halves/tokens.js +135 -0
- package/src/link/link.d.ts +4 -0
- package/src/link/link.js +4 -0
- package/src/link/placeholder.d.ts +1 -0
- package/src/link/placeholder.js +21 -0
- package/src/link/steps.d.ts +52 -0
- package/src/link/steps.js +118 -0
- package/src/lobes/calls.d.ts +76 -0
- package/src/lobes/calls.js +61 -0
- package/src/lobes/channel.d.ts +76 -0
- package/src/lobes/channel.js +202 -0
- package/src/lobes/index.d.ts +1 -0
- package/src/lobes/index.js +2 -0
- package/src/lobes/lobes.d.ts +15 -0
- package/src/lobes/lobes.js +244 -0
- package/src/lobes/main.js +107 -0
- package/src/lobes/thread.d.ts +22 -0
- package/src/lobes/thread.js +270 -0
- package/src/organism/act.d.ts +8 -0
- package/src/organism/act.js +63 -0
- package/src/organism/beat.d.ts +5 -0
- package/src/organism/beat.js +45 -0
- package/src/organism/compiled.d.ts +2 -0
- package/src/organism/compiled.js +24 -0
- package/src/organism/folder.d.ts +88 -0
- package/src/organism/folder.js +259 -0
- package/src/organism/main.d.ts +1 -0
- package/src/organism/main.js +11 -0
- package/src/organism/organism.d.ts +1 -0
- package/src/organism/organism.js +219 -0
- package/src/organism/said.d.ts +12 -0
- package/src/organism/said.js +30 -0
- package/src/organism/told.d.ts +5 -0
- package/src/organism/told.js +110 -0
- package/src/organism/unlock.d.ts +8 -0
- package/src/organism/unlock.js +95 -0
- package/src/organism/upgrade.d.ts +24 -0
- package/src/organism/upgrade.js +145 -0
- package/src/organism/via.d.ts +7 -0
- package/src/organism/via.js +20 -0
- package/src/service/body.d.ts +8 -0
- package/src/service/body.js +34 -0
- package/src/service/handler.d.ts +20 -0
- package/src/service/handler.js +128 -0
- package/src/service/index.d.ts +4 -0
- package/src/service/index.js +16 -0
- package/src/service/manager.d.ts +18 -0
- package/src/service/manager.js +185 -0
- package/src/service/service.d.ts +24 -0
- package/src/service/service.js +200 -0
- package/src/service/swap.d.ts +12 -0
- package/src/service/swap.js +74 -0
- package/src/service/watchdog.d.ts +6 -0
- package/src/service/watchdog.js +31 -0
- package/src/tcp/crowd.d.ts +18 -0
- package/src/tcp/crowd.js +85 -0
- package/src/tcp/dial.d.ts +23 -0
- package/src/tcp/dial.js +102 -0
- package/src/tcp/frame.d.ts +23 -0
- package/src/tcp/frame.js +159 -0
- package/src/tcp/listen.d.ts +50 -0
- package/src/tcp/listen.js +207 -0
- package/src/tcp/source.d.ts +2 -0
- package/src/tcp/source.js +26 -0
- package/src/version/index.d.ts +1 -0
- package/src/version/index.js +2 -0
- package/src/version/version.d.ts +1 -0
- package/src/version/version.js +2 -0
- package/src/work/first.d.ts +11 -0
- package/src/work/first.js +91 -0
- package/src/work/index.d.ts +2 -0
- package/src/work/index.js +15 -0
- package/src/work/work.d.ts +20 -0
- package/src/work/work.js +136 -0
- package/src/ws/dial.d.ts +7 -0
- package/src/ws/dial.js +252 -0
- package/src/ws/dialing.d.ts +50 -0
- package/src/ws/dialing.js +72 -0
- package/src/ws/frame.d.ts +32 -0
- package/src/ws/frame.js +124 -0
- package/src/ws/handshake.d.ts +4 -0
- package/src/ws/handshake.js +27 -0
- package/src/ws/line.d.ts +45 -0
- package/src/ws/line.js +250 -0
- package/src/ws/listen.d.ts +42 -0
- package/src/ws/listen.js +272 -0
- package/src/ws/rfc6455.d.ts +18 -0
- package/src/ws/rfc6455.js +187 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// SPDX-License-Identifier: FSL-1.1-ALv2
|
|
2
|
+
import { error, isFields, readText, result, } from '@nervur.org/genome/standard';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
import { standingsOf } from './standing.js';
|
|
6
|
+
import { joinInvitation, lookLink, takeLink, } from '../../../src/link/steps.js';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
const recordOf = (value ) =>
|
|
19
|
+
typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
20
|
+
? Object.fromEntries(Object.entries(value))
|
|
21
|
+
: null;
|
|
22
|
+
|
|
23
|
+
export const linkingOf = (fields ) => {
|
|
24
|
+
const link = recordOf(fields['link']);
|
|
25
|
+
if (link !== null && typeof link['text'] === 'string')
|
|
26
|
+
return { link: { text: link['text'], ...(link['look'] === true ? { look: true } : {}) } };
|
|
27
|
+
const accept = recordOf(fields['accept']);
|
|
28
|
+
if (accept === null) return null;
|
|
29
|
+
const { invitation, domain } = accept;
|
|
30
|
+
return typeof invitation === 'string' && (domain === null || typeof domain === 'string')
|
|
31
|
+
? { accept: { invitation, domain } }
|
|
32
|
+
: null;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const quoOf = (askWindow ) => ({
|
|
36
|
+
offer: (card, reference, domain) =>
|
|
37
|
+
askWindow('offer', { card: { ward: card.ward, at: [...card.at] }, reference, domain }),
|
|
38
|
+
redeem: (card, reference, domain) =>
|
|
39
|
+
askWindow('redeem', { card: { ward: card.ward, at: [...card.at] }, reference, domain }),
|
|
40
|
+
accept: (by, placeholder, note) => askWindow('accept', { invitation: by.invitation, placeholder, note }),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export const heldOf =
|
|
44
|
+
(askWindow ) =>
|
|
45
|
+
async () =>
|
|
46
|
+
(await standingsOf(askWindow))?.map((one) => one.relation) ?? null;
|
|
47
|
+
|
|
48
|
+
export const answerOf = (reply ) => {
|
|
49
|
+
if (reply.status === 204) return result(null);
|
|
50
|
+
const read = reply.body === undefined ? null : readText(reply.body);
|
|
51
|
+
const said = read !== null && 'data' in read && isFields(read.data) ? read.data['error'] : undefined;
|
|
52
|
+
if (isFields(said) && typeof said['code'] === 'string' && typeof said['message'] === 'string')
|
|
53
|
+
return error(said['code'], said['message']);
|
|
54
|
+
return error('refused', reply.body?.trim() || `the screen answered ${reply.status}`);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
export const linking = async (request , linked ) => {
|
|
63
|
+
if ('link' in request) {
|
|
64
|
+
const taken = await (request.link.look === true ? lookLink : takeLink)(request.link.text, linked.ports);
|
|
65
|
+
return 'why' in taken ? error('refused', taken.why) : result(taken);
|
|
66
|
+
}
|
|
67
|
+
const done = await joinInvitation(request.accept.invitation, request.accept.domain, {}, linked.ports);
|
|
68
|
+
return 'why' in done ? error('refused', done.why) : result(done);
|
|
69
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// SPDX-License-Identifier: FSL-1.1-ALv2
|
|
2
|
+
import { createServer, } from 'node:net';
|
|
3
|
+
import { surfaceServer, } from './http.js';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
const admitted = async (socket , own , uidOf ) => {
|
|
16
|
+
const { remotePort, localPort, remoteAddress } = socket;
|
|
17
|
+
if (remotePort === undefined || localPort === undefined || remoteAddress !== '127.0.0.1') return false;
|
|
18
|
+
try {
|
|
19
|
+
return (await uidOf(remotePort, localPort)) === own;
|
|
20
|
+
} catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const listenSurface = ({ port, own, uidOf, routes } ) => {
|
|
26
|
+
if (own === undefined)
|
|
27
|
+
return Promise.resolve({
|
|
28
|
+
why: 'this host names no uid for its account, so no connection to the surface could be known',
|
|
29
|
+
});
|
|
30
|
+
let bound = port;
|
|
31
|
+
const http = surfaceServer(routes, () => bound);
|
|
32
|
+
const open = new Set ();
|
|
33
|
+
const tcp = createServer({ pauseOnConnect: true }, (socket) => {
|
|
34
|
+
open.add(socket);
|
|
35
|
+
socket.on('close', () => void open.delete(socket));
|
|
36
|
+
socket.on('error', () => undefined);
|
|
37
|
+
void admitted(socket, own, uidOf).then((ok) => {
|
|
38
|
+
if (!ok || socket.destroyed) {
|
|
39
|
+
socket.destroy();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
http.emit('connection', socket);
|
|
43
|
+
socket.resume();
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
return new Promise((done) => {
|
|
47
|
+
tcp.once('error', (failed) => done({ why: `the surface cannot listen on 127.0.0.1:${port}: ${failed.message}` }));
|
|
48
|
+
tcp.listen(port, '127.0.0.1', () => {
|
|
49
|
+
const at = tcp.address();
|
|
50
|
+
bound = typeof at === 'object' && at !== null ? at.port : port;
|
|
51
|
+
done({
|
|
52
|
+
port: bound,
|
|
53
|
+
close: () =>
|
|
54
|
+
new Promise((closed) => {
|
|
55
|
+
for (const socket of open) socket.destroy();
|
|
56
|
+
tcp.close(() => closed());
|
|
57
|
+
}),
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// SPDX-License-Identifier: FSL-1.1-ALv2
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { isFields, } from '@nervur.org/genome/standard';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export const WINDOW_WITHIN = 6000;
|
|
8
|
+
|
|
9
|
+
export const ROOT = '~window';
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export const surfaced = ({ theme, lang } ) => ({
|
|
16
|
+
theme,
|
|
17
|
+
...(lang === undefined ? {} : { lang }),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
const seenOf = (data ) => {
|
|
62
|
+
if (!isFields(data)) return { why: 'the window saw nothing' };
|
|
63
|
+
const { text, tree, main, version, design, channel, way, world } = data;
|
|
64
|
+
if (typeof text !== 'string' || tree === undefined || !isFields(main)) return { why: 'the window saw no page' };
|
|
65
|
+
const { lobe, over, args } = main;
|
|
66
|
+
if (typeof lobe !== 'string' || (over !== null && typeof over !== 'string') || args === undefined)
|
|
67
|
+
return { why: 'the window named no lobe for its page' };
|
|
68
|
+
return {
|
|
69
|
+
text,
|
|
70
|
+
tree,
|
|
71
|
+
main: { lobe, over, args },
|
|
72
|
+
version: typeof version === 'string' ? version : null,
|
|
73
|
+
design: typeof design === 'string' ? design : null,
|
|
74
|
+
...(isFields(channel) ? { channel } : {}),
|
|
75
|
+
...(isFields(way) ? { way } : {}),
|
|
76
|
+
...(isFields(world) ? { world } : {}),
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const openOver =
|
|
81
|
+
(ask ) =>
|
|
82
|
+
async (route, told) => {
|
|
83
|
+
const answer = await ask('open', {
|
|
84
|
+
route: route.map((step) => ({ ...step })),
|
|
85
|
+
...(told === undefined ? {} : { told: { ...told } }),
|
|
86
|
+
});
|
|
87
|
+
if ('error' in answer) return { why: answer.error.message };
|
|
88
|
+
const text = isFields(answer.result) ? answer.result['text'] : undefined;
|
|
89
|
+
return typeof text === 'string' ? { text } : { why: 'the window answered no route' };
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const windowOver = (ask ) => ({
|
|
93
|
+
open: openOver(ask),
|
|
94
|
+
see: async ({ route, cursor, cells, ...surface }) => {
|
|
95
|
+
const args = { cursor, cells, ...surfaced(surface) };
|
|
96
|
+
const answer = await ask(
|
|
97
|
+
'see',
|
|
98
|
+
route === undefined ? { args } : { route: route.map((step) => ({ ...step })), args },
|
|
99
|
+
);
|
|
100
|
+
return 'error' in answer ? { why: answer.error.message } : seenOf(answer.result);
|
|
101
|
+
},
|
|
102
|
+
show: async (lobe, args, over) => {
|
|
103
|
+
const answer = await ask('show', over === null ? { lobe, args } : { lobe, args, over });
|
|
104
|
+
if ('error' in answer) return { refused: answer.error.message };
|
|
105
|
+
return isFields(answer.result)
|
|
106
|
+
? { tree: answer.result['tree'] ?? null }
|
|
107
|
+
: { refused: 'the window answered no tree' };
|
|
108
|
+
},
|
|
109
|
+
post: (method, args) => ask(method, args),
|
|
110
|
+
press: (lobe, method, args, to, over, values = {}) =>
|
|
111
|
+
ask('press', {
|
|
112
|
+
lobe,
|
|
113
|
+
method,
|
|
114
|
+
args,
|
|
115
|
+
...(Object.keys(values).length === 0 ? {} : { values }),
|
|
116
|
+
...(to === undefined ? {} : { to }),
|
|
117
|
+
...(over === null ? {} : { over }),
|
|
118
|
+
}),
|
|
119
|
+
worn: () => ask('worn', {}),
|
|
120
|
+
wear: (design) => ask('wear', { design }),
|
|
121
|
+
});
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// SPDX-License-Identifier: FSL-1.1-ALv2
|
|
2
|
+
import { routeOf, routeText, toldOf } from '@nervur.org/genome/screen';
|
|
3
|
+
import { dataText, error, isFields, readData, result, } from '@nervur.org/genome/standard';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import { answerOf, heldOf, linking, linkingOf, quoOf, } from './linked.js';
|
|
7
|
+
|
|
8
|
+
import { giveFile } from './follow.js';
|
|
9
|
+
import { makeMirror } from './mirror.js';
|
|
10
|
+
import { noticed } from './notice.js';
|
|
11
|
+
import { assetOf, sheetOf } from './worn.js';
|
|
12
|
+
import { makePresses } from './presses.js';
|
|
13
|
+
import { makeShown, } from './shown.js';
|
|
14
|
+
|
|
15
|
+
import { freshState, } from './state.js';
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
const makePump = (once ) => {
|
|
20
|
+
let again = false;
|
|
21
|
+
let whole = false;
|
|
22
|
+
let running = null;
|
|
23
|
+
const loop = async () => {
|
|
24
|
+
while (again) {
|
|
25
|
+
again = false;
|
|
26
|
+
const everything = whole;
|
|
27
|
+
whole = false;
|
|
28
|
+
await once(everything).catch(() => undefined);
|
|
29
|
+
}
|
|
30
|
+
running = null;
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
stepped: (everything ) => {
|
|
34
|
+
again = true;
|
|
35
|
+
whole ||= everything;
|
|
36
|
+
running ??= loop();
|
|
37
|
+
return running;
|
|
38
|
+
},
|
|
39
|
+
settled: () => running ?? Promise.resolve(),
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const told = async (window , state , tell , shows ) => {
|
|
44
|
+
if (tell.width !== undefined) state.surface.width = tell.width;
|
|
45
|
+
if (tell.language !== undefined) state.surface.language = tell.language;
|
|
46
|
+
if (tell.reduced !== undefined) state.reduced = tell.reduced;
|
|
47
|
+
if (tell.theme !== undefined) state.theme = tell.theme;
|
|
48
|
+
const read = tell.route === undefined ? null : routeOf(tell.route);
|
|
49
|
+
if (read === null) return { status: 204 };
|
|
50
|
+
if ('why' in read) return { status: 404, body: dataText(error('refused', read.why)) };
|
|
51
|
+
const text = routeText(read.route);
|
|
52
|
+
state.walks += 1;
|
|
53
|
+
const walk = state.walks;
|
|
54
|
+
if ('text' in text && text.text !== state.route) shows(text.text);
|
|
55
|
+
const opened = await window.open(read.route, toldOf(state.surface));
|
|
56
|
+
if (walk !== state.walks) return { status: 204 };
|
|
57
|
+
if ('why' in opened) return { status: 422, body: dataText(error('refused', opened.why)) };
|
|
58
|
+
if (opened.text !== state.route) state.cursor = null;
|
|
59
|
+
state.route = opened.text;
|
|
60
|
+
return { status: 204 };
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const servedOf = (state ) => ({
|
|
64
|
+
sheet: (digest ) => Promise.resolve(sheetOf(state, digest)),
|
|
65
|
+
asset: (name ) =>
|
|
66
|
+
Promise.resolve(assetOf(state, name) ?? state.kept.files.get(name) ?? null),
|
|
67
|
+
file: async (bytes ) => {
|
|
68
|
+
const given = await giveFile(state.kept, bytes);
|
|
69
|
+
return typeof given === 'string' ? { status: 204 } : { status: 413, body: dataText(error('refused', given.why)) };
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
const nowhere = (window ) => ({
|
|
76
|
+
vouch: () => Promise.resolve(null),
|
|
77
|
+
now: () => new Date().toISOString(),
|
|
78
|
+
askWindow: window.post,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const linksOver = (world , walkTo , laid ) => {
|
|
82
|
+
const quo = quoOf(world.askWindow);
|
|
83
|
+
const linked = {
|
|
84
|
+
ports: {
|
|
85
|
+
vouch: world.vouch,
|
|
86
|
+
now: world.now,
|
|
87
|
+
offer: quo.offer,
|
|
88
|
+
redeem: quo.redeem,
|
|
89
|
+
held: heldOf(world.askWindow),
|
|
90
|
+
accept: async (by, placeholder, note) => {
|
|
91
|
+
const accepted = await quo.accept(by, placeholder, note);
|
|
92
|
+
const text = 'result' in accepted && isFields(accepted.result) ? accepted.result['text'] : undefined;
|
|
93
|
+
if (typeof text !== 'string') return accepted;
|
|
94
|
+
const walked = await walkTo({ route: text });
|
|
95
|
+
return walked.status === 204 ? accepted : answerOf(walked);
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
askWindow: world.askWindow,
|
|
99
|
+
};
|
|
100
|
+
return async (body ) => {
|
|
101
|
+
const read = readData(body);
|
|
102
|
+
const fields = 'data' in read && isFields(read.data) ? read.data : null;
|
|
103
|
+
if (fields?.['room'] === true) {
|
|
104
|
+
const lay = await laid();
|
|
105
|
+
return { status: 200, body: dataText(result({ sheets: [...(lay?.home.sheets ?? [])] })) };
|
|
106
|
+
}
|
|
107
|
+
const request = fields === null ? null : linkingOf(fields);
|
|
108
|
+
if (request === null) return { status: 400, body: dataText(error('refused', 'a link names what is asked of it')) };
|
|
109
|
+
return { status: 200, body: dataText(await linking(request, linked)) };
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export const makeLoop = (window , world = nowhere(window), size ) => {
|
|
114
|
+
const state = freshState(size);
|
|
115
|
+
const streams = new Set();
|
|
116
|
+
const mirror = makeMirror();
|
|
117
|
+
const { step, walk, laid } = makeShown(window, state, mirror, streams);
|
|
118
|
+
const { stepped, settled } = makePump(step);
|
|
119
|
+
const pressed = makePresses(window, state, mirror);
|
|
120
|
+
let opening = Promise.resolve();
|
|
121
|
+
const look = (everything ) => (streams.size === 0 ? Promise.resolve() : stepped(everything));
|
|
122
|
+
const heard = async (tell ) => {
|
|
123
|
+
const reply = await told(window, state, tell, walk);
|
|
124
|
+
void look(false);
|
|
125
|
+
return reply;
|
|
126
|
+
};
|
|
127
|
+
return {
|
|
128
|
+
moved: (args ) => {
|
|
129
|
+
const answer = noticed(state.told, args);
|
|
130
|
+
if ('result' in answer) void look(false);
|
|
131
|
+
return answer;
|
|
132
|
+
},
|
|
133
|
+
open: (send , tell ) => {
|
|
134
|
+
streams.add(send);
|
|
135
|
+
opening = told(window, state, tell, walk).then(() => stepped(true));
|
|
136
|
+
return () => void streams.delete(send);
|
|
137
|
+
},
|
|
138
|
+
tell: heard,
|
|
139
|
+
link: linksOver(world, heard, laid),
|
|
140
|
+
press: async (body ) => {
|
|
141
|
+
const reply = await pressed(body);
|
|
142
|
+
const everything = state.redraw;
|
|
143
|
+
state.redraw = false;
|
|
144
|
+
if (reply.status === 200 || reply.status === 204 || reply.status === 422) void look(everything);
|
|
145
|
+
return reply;
|
|
146
|
+
},
|
|
147
|
+
...servedOf(state),
|
|
148
|
+
settled: async () => {
|
|
149
|
+
await opening;
|
|
150
|
+
await settled();
|
|
151
|
+
await state.kept.pending;
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// SPDX-License-Identifier: FSL-1.1-ALv2
|
|
2
|
+
import { SCREEN } from '@nervur.org/genome';
|
|
3
|
+
import { error, isFields, readText, } from '@nervur.org/genome/standard';
|
|
4
|
+
import { vouchOf } from '../../../src/command/vouch.js';
|
|
5
|
+
import { sizeOf } from '../../../src/door/dressed.js';
|
|
6
|
+
import { LONGEST_TIMEOUT } from '../../../src/door/longest.js';
|
|
7
|
+
import { processIo, refuseHalf, serveHalf, speaker } from '../../../src/halves/index.js';
|
|
8
|
+
import { listenSurface } from './listen.js';
|
|
9
|
+
import { windowOver, WINDOW_WITHIN } from './look.js';
|
|
10
|
+
import { makeLoop, } from './loop.js';
|
|
11
|
+
import { uidReaderOf } from './uid.js';
|
|
12
|
+
|
|
13
|
+
const none = () => undefined;
|
|
14
|
+
const io = processIo();
|
|
15
|
+
const reach = readText(process.argv[2] ?? '');
|
|
16
|
+
const named = 'data' in reach && isFields(reach.data) ? reach.data : null;
|
|
17
|
+
const port = named?.['port'];
|
|
18
|
+
const size = sizeOf(named?.['size']) ?? undefined;
|
|
19
|
+
if (typeof port !== 'number' || !Number.isInteger(port) || port < 0 || port > 65_535) {
|
|
20
|
+
refuseHalf(io, 'the screen is started with its port as its reach');
|
|
21
|
+
process.exitCode = 1;
|
|
22
|
+
} else {
|
|
23
|
+
const serving = Promise.withResolvers ();
|
|
24
|
+
const moved = (args ) => serving.promise.then((loop) => loop.moved(args));
|
|
25
|
+
const listened = await listenSurface({
|
|
26
|
+
port,
|
|
27
|
+
own: process.getuid?.(),
|
|
28
|
+
uidOf: uidReaderOf(process.platform),
|
|
29
|
+
routes: {
|
|
30
|
+
sheet: (digest) => serving.promise.then((loop) => loop.sheet(digest)),
|
|
31
|
+
asset: (name) => serving.promise.then((loop) => loop.asset(name)),
|
|
32
|
+
stream: (send, tell) => {
|
|
33
|
+
const held = { closed: false, close: none };
|
|
34
|
+
void serving.promise.then((loop) => {
|
|
35
|
+
if (!held.closed) held.close = loop.open(send, tell);
|
|
36
|
+
});
|
|
37
|
+
return () => {
|
|
38
|
+
held.closed = true;
|
|
39
|
+
held.close();
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
tell: (tell) => serving.promise.then((loop) => loop.tell(tell)),
|
|
43
|
+
press: (body) => serving.promise.then((loop) => loop.press(body)),
|
|
44
|
+
file: (bytes) => serving.promise.then((loop) => loop.file(bytes)),
|
|
45
|
+
link: (body) => serving.promise.then((loop) => loop.link(body)),
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
if ('why' in listened) {
|
|
49
|
+
refuseHalf(io, listened.why);
|
|
50
|
+
process.exitCode = 1;
|
|
51
|
+
} else {
|
|
52
|
+
const stop = () => void listened.close().then(() => process.exit(0));
|
|
53
|
+
process.on('SIGTERM', stop);
|
|
54
|
+
const end = serveHalf(
|
|
55
|
+
io,
|
|
56
|
+
SCREEN.blueprint,
|
|
57
|
+
(method, args) => (method === 'moved' ? moved(args) : error('unavailable', `the screen answers no ${method}`)),
|
|
58
|
+
stop,
|
|
59
|
+
);
|
|
60
|
+
const speak = speaker(end, 'the screen');
|
|
61
|
+
const world = {
|
|
62
|
+
vouch: vouchOf,
|
|
63
|
+
now: () => new Date().toISOString(),
|
|
64
|
+
askWindow: (method, args) => speak((handler) => end.ask(handler, method, args, LONGEST_TIMEOUT)),
|
|
65
|
+
};
|
|
66
|
+
serving.resolve(
|
|
67
|
+
makeLoop(
|
|
68
|
+
windowOver((method, args) => speak((handler) => end.ask(handler, method, args, WINDOW_WITHIN))),
|
|
69
|
+
world,
|
|
70
|
+
size,
|
|
71
|
+
),
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// SPDX-License-Identifier: FSL-1.1-ALv2
|
|
2
|
+
import { shapeOf, } from '@nervur.org/genome/screen';
|
|
3
|
+
import { HOST, isFields, } from '@nervur.org/genome/standard';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
const pressOf = (data ) => {
|
|
11
|
+
if (!isFields(data)) return null;
|
|
12
|
+
const { method, args, to } = data;
|
|
13
|
+
if (typeof method !== 'string') return null;
|
|
14
|
+
return typeof to === 'string' ? { method, args: args ?? {}, to } : { method, args: args ?? {} };
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const detached = (entries , id ) => {
|
|
18
|
+
const entry = entries.get(id);
|
|
19
|
+
if (entry?.parent === undefined || entry.parent === null) return;
|
|
20
|
+
entries.get(entry.parent)?.children.delete(id);
|
|
21
|
+
entry.parent = null;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const attached = (entries , id , parent ) => {
|
|
25
|
+
const entry = entries.get(id);
|
|
26
|
+
if (entry === undefined) return;
|
|
27
|
+
entry.parent = parent;
|
|
28
|
+
entries.get(parent)?.children.add(id);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const forgotten = (entries , id ) => {
|
|
32
|
+
detached(entries, id);
|
|
33
|
+
const entry = entries.get(id);
|
|
34
|
+
if (entry === undefined) return;
|
|
35
|
+
for (const child of entry.children) forgotten(entries, child);
|
|
36
|
+
entries.delete(id);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const made = (entries , shape , parent ) => {
|
|
40
|
+
const { id, node } = shape;
|
|
41
|
+
const entry = { parent: null, children: new Set() };
|
|
42
|
+
if (typeof node !== 'string') {
|
|
43
|
+
if (node.t === HOST && typeof node.a['data-lobe'] === 'string') entry.lobe = node.a['data-lobe'];
|
|
44
|
+
if (node.press !== undefined) entry.press = node.press;
|
|
45
|
+
}
|
|
46
|
+
entries.set(id, entry);
|
|
47
|
+
attached(entries, id, parent);
|
|
48
|
+
if (shape.s !== undefined) {
|
|
49
|
+
entries.set(shape.s.root, { parent: null, children: new Set() });
|
|
50
|
+
attached(entries, shape.s.root, id);
|
|
51
|
+
made(entries, shape.s.shape, shape.s.root);
|
|
52
|
+
}
|
|
53
|
+
for (const child of shape.c) made(entries, child, id);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const applied = (entries , op ) => {
|
|
57
|
+
switch (op[0]) {
|
|
58
|
+
case 'make':
|
|
59
|
+
made(entries, shapeOf(op[3], { next: op[4] }), op[1]);
|
|
60
|
+
return;
|
|
61
|
+
case 'drop':
|
|
62
|
+
case 'forget':
|
|
63
|
+
forgotten(entries, op[1]);
|
|
64
|
+
return;
|
|
65
|
+
case 'park':
|
|
66
|
+
detached(entries, op[1]);
|
|
67
|
+
return;
|
|
68
|
+
case 'revive':
|
|
69
|
+
attached(entries, op[2], op[1]);
|
|
70
|
+
return;
|
|
71
|
+
case 'attr': {
|
|
72
|
+
const entry = entries.get(op[1]);
|
|
73
|
+
if (entry === undefined || op[2] !== 'data-lobe') return;
|
|
74
|
+
if (op[3] === null) delete entry.lobe;
|
|
75
|
+
else entry.lobe = op[3];
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
case 'press': {
|
|
79
|
+
const entry = entries.get(op[1]);
|
|
80
|
+
const press = pressOf(op[2]);
|
|
81
|
+
if (entry === undefined) return;
|
|
82
|
+
if (press === null) delete entry.press;
|
|
83
|
+
else entry.press = press;
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
default:
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const lobeAbove = (entries , id ) => {
|
|
91
|
+
for (let at = entries.get(id), up = 0; at !== undefined && up <= entries.size; up += 1) {
|
|
92
|
+
if (at.lobe !== undefined) return at.lobe;
|
|
93
|
+
if (at.parent === null) return null;
|
|
94
|
+
at = entries.get(at.parent);
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export const makeMirror = () => {
|
|
100
|
+
const entries = new Map();
|
|
101
|
+
return {
|
|
102
|
+
apply: (ops ) => {
|
|
103
|
+
for (const op of ops) applied(entries, op);
|
|
104
|
+
},
|
|
105
|
+
reset: () => entries.clear(),
|
|
106
|
+
find: (id ) => {
|
|
107
|
+
const press = entries.get(id)?.press;
|
|
108
|
+
const lobe = press === undefined ? null : lobeAbove(entries, id);
|
|
109
|
+
return press === undefined || lobe === null ? null : { lobe, press };
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// SPDX-License-Identifier: FSL-1.1-ALv2
|
|
2
|
+
import { capsOf } from '@nervur.org/genome/screen';
|
|
3
|
+
import { error, isFields, } from '@nervur.org/genome/standard';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
const textsIn = (data ) => {
|
|
15
|
+
if (!isFields(data)) return null;
|
|
16
|
+
const read = {};
|
|
17
|
+
for (const [key, value] of Object.entries(data)) {
|
|
18
|
+
if (typeof value !== 'string') return null;
|
|
19
|
+
read[key] = value;
|
|
20
|
+
}
|
|
21
|
+
return read;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const noticed = (told , args ) => {
|
|
25
|
+
const lobes = isFields(args) && isFields(args['lobes']) ? args['lobes'] : null;
|
|
26
|
+
if (lobes === null) return error('refused', 'moved names its lobes');
|
|
27
|
+
for (const [id, one] of Object.entries(lobes)) {
|
|
28
|
+
if (!isFields(one)) continue;
|
|
29
|
+
const { faculty, cells, road } = one;
|
|
30
|
+
const wires = textsIn(one['wires'] ?? null);
|
|
31
|
+
if (typeof faculty !== 'string' || typeof cells !== 'string' || typeof road !== 'string' || wires === null)
|
|
32
|
+
continue;
|
|
33
|
+
const caps = capsOf(one['caps']);
|
|
34
|
+
told.set(id, {
|
|
35
|
+
faculty,
|
|
36
|
+
cells,
|
|
37
|
+
wires,
|
|
38
|
+
road,
|
|
39
|
+
...(caps === undefined ? {} : { caps }),
|
|
40
|
+
told: (told.get(id)?.told ?? 0) + 1,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return { result: null };
|
|
44
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// SPDX-License-Identifier: FSL-1.1-ALv2
|
|
2
|
+
import { ROOT } from './look.js';
|
|
3
|
+
import { overOf, } from './state.js';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export const presserOf = (state , lobe ) => {
|
|
8
|
+
if (lobe === ROOT) return { lobe: state.worn.designLobe ?? ROOT, over: null };
|
|
9
|
+
if (lobe.startsWith('~')) return { why: `no press is carried from ${lobe}` };
|
|
10
|
+
return { lobe, over: overOf(state, lobe) };
|
|
11
|
+
};
|