@steve02081504/fount-p2p 0.0.24 → 0.0.25
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 +2 -2
- package/package.json +3 -3
- package/transport/node_scope/wire.mjs +20 -1
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ Shells talk to the **fount network** (`ensureLinkToNode` / `sendToNodeLink` / ro
|
|
|
34
34
|
|
|
35
35
|
Dial order is descending link **`level`**: `lan_tcp` → `webrtc` → `ble_gatt` → `nostr` (−∞ last resort). Discovery **`priority`** only orders handshake / presence media. Details: [docs/transports.md](./docs/transports.md).
|
|
36
36
|
|
|
37
|
-
Public transport subpaths: `link_registry`, `user_room`, `group_link_set`, `node_scope`, `room_scopes`, `remote_user_room`, `scoped_link`. Other `transport/*` modules are internal.
|
|
37
|
+
Public transport subpaths: `link_registry`, `user_room`, `group_link_set`, `node_scope/wire`, `node_scope/features`, `room_scopes`, `remote_user_room`, `scoped_link`. Other `transport/*` modules are internal.
|
|
38
38
|
|
|
39
39
|
## Infra relay (optional)
|
|
40
40
|
|
|
@@ -85,7 +85,7 @@ Facade entry: `index.mjs` (`startNode`, `createGroupLinkSet`, `registerDiscovery
|
|
|
85
85
|
| Module | Role |
|
|
86
86
|
|---|---|
|
|
87
87
|
| `link_registry.mjs` | fount-network facade: dial fallback, scope/overlay |
|
|
88
|
-
| `user_room.mjs` / `group_link_set.mjs` / `node_scope
|
|
88
|
+
| `user_room.mjs` / `group_link_set.mjs` / `node_scope/wire` + `node_scope/features` | rooms + composable node-scope wires (`registerNodeScopeWireHook`, attaches) |
|
|
89
89
|
| `room_scopes.mjs` / `remote_user_room.mjs` | scope constants / remote user slot |
|
|
90
90
|
|
|
91
91
|
`runtime_bootstrap`, `offer_answer` are **internal** (transport). Signal crypto / rendezvous live under `discovery/internal/signal_crypto.mjs` (used by discovery `nostr.mjs` / `adverts.mjs`; not a package export). The Nostr **link** provider (`link/providers/nostr.mjs`) reuses the same discovery signal path (`type: 'link'`) as a last-resort duplex pipe. `ensureRuntime` returns after registration and scheduling warm-up; it does not await lan_tcp listen, public relays, or Bluetooth. `setSignalingRuntimeConfig` → `reloadDiscoveryRelays`. See [docs/runtime.md](./docs/runtime.md) and [docs/transports.md](./docs/transports.md).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steve02081504/fount-p2p",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.25",
|
|
4
4
|
"description": "fount federation P2P layer — link, trust graph, mailbox, DAG, EVFS.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"network",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"type": "module",
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
|
-
"url": "https://github.com/steve02081504/fount-p2p.git",
|
|
14
|
+
"url": "git+https://github.com/steve02081504/fount-p2p.git",
|
|
15
15
|
"directory": "."
|
|
16
16
|
},
|
|
17
17
|
"engines": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"!scripts/**"
|
|
32
32
|
],
|
|
33
33
|
"bin": {
|
|
34
|
-
"fount-p2p": "
|
|
34
|
+
"fount-p2p": "infra/cli.mjs"
|
|
35
35
|
},
|
|
36
36
|
"exports": {
|
|
37
37
|
".": "./index.mjs",
|
|
@@ -6,6 +6,9 @@ import { subscribeScope, sendToNodeLink } from '../link_registry.mjs'
|
|
|
6
6
|
/** @type {Map<string, Set<(payload: unknown, peerId: string) => void>>} */
|
|
7
7
|
const nodeActionHandlers = new Map()
|
|
8
8
|
|
|
9
|
+
/** @type {Set<(context: NodeScopeContext, wire: NodeScopeWire) => void>} */
|
|
10
|
+
const nodeScopeWireHooks = new Set()
|
|
11
|
+
|
|
9
12
|
/** @type {NodeScopeContext} */
|
|
10
13
|
const nodeScopeContext = { replicaUsername: '' }
|
|
11
14
|
|
|
@@ -108,10 +111,26 @@ export function ensureNodeScope(options = {}) {
|
|
|
108
111
|
for (const handler of handlers)
|
|
109
112
|
try { handler(envelope.payload, senderNodeHash) } catch { /* ignore */ }
|
|
110
113
|
})
|
|
111
|
-
|
|
114
|
+
if (!nodeScopeWire) {
|
|
115
|
+
nodeScopeWire = createNodeScopeWire()
|
|
116
|
+
for (const hook of nodeScopeWireHooks)
|
|
117
|
+
try { hook(nodeScopeContext, nodeScopeWire) } catch { /* ignore */ }
|
|
118
|
+
}
|
|
112
119
|
return nodeScopeSubscribeCleanup
|
|
113
120
|
}
|
|
114
121
|
|
|
122
|
+
/**
|
|
123
|
+
* 在 node scope wire 创建时(或已存在时立即)回调;shell 用此挂自定义 action。
|
|
124
|
+
* @param {(context: NodeScopeContext, wire: NodeScopeWire) => void} hook - wire 就绪回调
|
|
125
|
+
* @returns {() => void} 取消注册的 dispose
|
|
126
|
+
*/
|
|
127
|
+
export function registerNodeScopeWireHook(hook) {
|
|
128
|
+
nodeScopeWireHooks.add(hook)
|
|
129
|
+
if (nodeScopeWire)
|
|
130
|
+
try { hook(nodeScopeContext, nodeScopeWire) } catch { /* ignore */ }
|
|
131
|
+
return () => nodeScopeWireHooks.delete(hook)
|
|
132
|
+
}
|
|
133
|
+
|
|
115
134
|
/**
|
|
116
135
|
* 卸掉 scope 订阅与 wire(feature 须先卸)。
|
|
117
136
|
* @returns {void}
|