@vrtmrz/livesync-commonlib 0.4.3 → 0.5.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 +2 -2
- package/dist/interfaces/StorageAccess.d.ts +8 -2
- package/dist/platform/FilePathIndex.d.ts +110 -0
- package/dist/platform/FilePathIndex.js +146 -0
- package/dist/replication/trystero/LiveSyncTrysteroReplicator.d.ts +3 -3
- package/dist/replication/trystero/P2PAutomationCoordinator.d.ts +1 -1
- package/dist/replication/trystero/P2PReplicationWire.d.ts +1 -1
- package/dist/replication/trystero/TrysteroReplicator/changeRelay.d.ts +133 -0
- package/dist/replication/trystero/TrysteroReplicator/changeRelay.js +176 -0
- package/dist/replication/trystero/TrysteroReplicator/configurationExchange.d.ts +55 -0
- package/dist/replication/trystero/TrysteroReplicator/configurationExchange.js +99 -0
- package/dist/replication/trystero/TrysteroReplicator/configuredTargets.d.ts +83 -0
- package/dist/replication/trystero/TrysteroReplicator/configuredTargets.js +121 -0
- package/dist/replication/trystero/TrysteroReplicator/peerAgreement.d.ts +75 -0
- package/dist/replication/trystero/TrysteroReplicator/peerAgreement.js +131 -0
- package/dist/replication/trystero/TrysteroReplicator/progress.d.ts +57 -0
- package/dist/replication/trystero/TrysteroReplicator/progress.js +84 -0
- package/dist/replication/trystero/TrysteroReplicator/relayControl.d.ts +20 -0
- package/dist/replication/trystero/TrysteroReplicator/relayControl.js +25 -0
- package/dist/replication/trystero/TrysteroReplicator/transfers.d.ts +125 -0
- package/dist/replication/trystero/TrysteroReplicator/transfers.js +278 -0
- package/dist/replication/trystero/TrysteroReplicator.d.ts +65 -483
- package/dist/replication/trystero/TrysteroReplicator.js +240 -673
- package/dist/replication/trystero/TrysteroReplicatorP2PClient.d.ts +19 -6
- package/dist/replication/trystero/TrysteroReplicatorP2PClient.js +29 -25
- package/dist/replication/trystero/TrysteroReplicatorP2PServer/peerAdmission.d.ts +66 -0
- package/dist/replication/trystero/TrysteroReplicatorP2PServer/peerAdmission.js +142 -0
- package/dist/replication/trystero/TrysteroReplicatorP2PServer.d.ts +19 -16
- package/dist/replication/trystero/TrysteroReplicatorP2PServer.js +33 -93
- package/dist/replication/trystero/p2pReplicationDiagnostics.d.ts +1 -1
- package/dist/replication/trystero/p2pReplicationProgress.d.ts +2 -11
- package/dist/replication/trystero/replicationTypes.d.ts +88 -0
- package/dist/replication/trystero/replicationTypes.js +0 -0
- package/dist/replication/trystero/rpcSessionProvider.d.ts +13 -0
- package/dist/replication/trystero/rpcSessionProvider.js +0 -0
- package/dist/rpc/RpcRoom/pendingInvocations.d.ts +141 -0
- package/dist/rpc/RpcRoom/pendingInvocations.js +225 -0
- package/dist/rpc/RpcRoom.d.ts +9 -4
- package/dist/rpc/RpcRoom.js +73 -118
- package/dist/rpc/RpcSession.d.ts +6 -0
- package/dist/rpc/RpcSession.js +11 -0
- package/dist/rpc/types.d.ts +2 -0
- package/dist/serviceFeatures/targetFilter.d.ts +1 -1
- package/dist/serviceFeatures/targetFilter.js +8 -38
- package/dist/serviceModules/FileAccessBase.d.ts +4 -0
- package/dist/serviceModules/FileAccessBase.js +10 -0
- package/dist/serviceModules/Rebuilder.js +1 -1
- package/dist/serviceModules/ServiceFileAccessBase/fileNames.d.ts +54 -0
- package/dist/serviceModules/ServiceFileAccessBase/fileNames.js +57 -0
- package/dist/serviceModules/ServiceFileAccessBase.d.ts +5 -1
- package/dist/serviceModules/ServiceFileAccessBase.js +18 -3
- package/dist/serviceModules/adapters/IFileSystemAdapter.d.ts +3 -0
- package/dist/storage.d.ts +2 -0
- package/dist/storage.js +2 -0
- package/docs/development.md +103 -0
- package/docs/p2p-transport-lifecycle.md +24 -0
- package/docs/platform-storage.md +22 -0
- package/docs/releasing.md +6 -0
- package/docs/settings-lifecycle.md +4 -2
- package/package.json +1 -1
package/dist/storage.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/** Host-neutral path identity, namespace, and storage resolution contracts. */
|
|
2
2
|
export type { FilePath, DocumentPath, StoragePath, PathComparisonKey, PathComparisonSettings, DocumentPathParts, DirectoryEntry, ReadDirectory, ResolvedRename, StorageEntry, StoragePathResolver, StoragePathResolverOptions, } from "./platform/pathTypes.js";
|
|
3
|
+
export { FilePathIndex } from "./platform/FilePathIndex.js";
|
|
4
|
+
export type { FileNameLookup, FileNameReadOptions, FilePathDelta } from "./platform/FilePathIndex.js";
|
|
3
5
|
export { parseFilePath, parseDocumentPath, splitDocumentPath, joinDocumentPath, getStoragePathComparisonKey, getDocumentPathComparisonKey, } from "./platform/pathComparison.js";
|
|
4
6
|
export { createStoragePathResolver, AmbiguousNormalisedPathError } from "./platform/storagePathResolution.js";
|
package/dist/storage.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FilePathIndex } from "./platform/FilePathIndex.js";
|
|
1
2
|
import {
|
|
2
3
|
parseFilePath,
|
|
3
4
|
parseDocumentPath,
|
|
@@ -9,6 +10,7 @@ import {
|
|
|
9
10
|
import { createStoragePathResolver, AmbiguousNormalisedPathError } from "./platform/storagePathResolution.js";
|
|
10
11
|
export {
|
|
11
12
|
AmbiguousNormalisedPathError,
|
|
13
|
+
FilePathIndex,
|
|
12
14
|
createStoragePathResolver,
|
|
13
15
|
getDocumentPathComparisonKey,
|
|
14
16
|
getStoragePathComparisonKey,
|
package/docs/development.md
CHANGED
|
@@ -76,6 +76,109 @@ class. Its extracted functions and their focused tests live in
|
|
|
76
76
|
`src/managers/StorageEventManager/`. These organise the event lifecycle separately
|
|
77
77
|
from the file handler's database and storage effects.
|
|
78
78
|
|
|
79
|
+
## P2P and RPC implementation
|
|
80
|
+
|
|
81
|
+
`src/replication/trystero/TrysteroReplicator.ts` retains the existing replicator
|
|
82
|
+
interface, wire command assembly, peer-arrival policy, and host lifecycle. Its
|
|
83
|
+
internal modules use narrow capabilities rather than the complete replicator:
|
|
84
|
+
|
|
85
|
+
| Module under `TrysteroReplicator/` | Responsibility |
|
|
86
|
+
| --- | --- |
|
|
87
|
+
| `changeRelay.ts` | Own the changes feed, broadcast state, followed peers, and last sequence; schedule notifications and request pulls. |
|
|
88
|
+
| `peerAgreement.ts` | Request authentication and compare tweak, path-identity, and ID-derivation agreement without exposing the ID key. |
|
|
89
|
+
| `configurationExchange.ts` | Prepare shared settings, obtain passphrases, encrypt or decrypt configuration, and validate imported ID settings. |
|
|
90
|
+
| `progress.ts` | Own acknowledged-attempt state and module-realm attempt numbering, project progress events, and report progress to the peer. |
|
|
91
|
+
| `configuredTargets.ts` | Resolve configured peer names, wait for discovery with listener cleanup, and aggregate sequential baseline synchronisation results. |
|
|
92
|
+
| `transfers.ts` | Own available and active peer sets, apply transfer gates, run the shared replication engine, and finalise progress. |
|
|
93
|
+
| `relayControl.ts` | Adapt shared Trystero relay controls and disconnect a captured socket set without changing host-stop ordering. |
|
|
94
|
+
|
|
95
|
+
The facade's existing relay accessors refer to the relay's single state object.
|
|
96
|
+
Agreement and configuration operations obtain snapshot settings and current
|
|
97
|
+
policy at their documented stages. The host retains peer acceptance, database
|
|
98
|
+
validation, transport binding, and finite-transfer ownership. Public method
|
|
99
|
+
dispatch remains dynamic so host overrides continue to apply. The operations
|
|
100
|
+
use `octagonal-wheels/context` to bind named, standalone functions. Each function
|
|
101
|
+
declares only the dependencies and state it uses, or accepts a composed operation
|
|
102
|
+
instead of that operation's dependencies. Factories allocate state and connect
|
|
103
|
+
these functions; construction starts no database or RPC work. State-bearing
|
|
104
|
+
bindings retain the owner object so existing facade setters remain effective.
|
|
105
|
+
|
|
106
|
+
Shared result, progress, acknowledgement, and peer-admission data contracts live
|
|
107
|
+
in `src/replication/trystero/replicationTypes.ts`, independently of their operation
|
|
108
|
+
owners. The facade, projection, diagnostic, and wire adapters import that leaf
|
|
109
|
+
rather than importing types back from the implementations they support. Local
|
|
110
|
+
failures retain their original error values; the separate wire result uses
|
|
111
|
+
JSON-safe RPC error data. Existing type export paths remain available as
|
|
112
|
+
re-exports. Transfer methods borrow the session owner's
|
|
113
|
+
signal and retain dynamic public dispatch for pull and reverse-sync requests.
|
|
114
|
+
Progress attempts remain ordered across room replacement within one module
|
|
115
|
+
realm; peer departure removes one acknowledgement history, and close clears all
|
|
116
|
+
histories and active transfer sets. Configured-target discovery releases event,
|
|
117
|
+
abort, and timeout hooks before continuing into per-target processing.
|
|
118
|
+
|
|
119
|
+
`TrysteroReplicatorP2PClient` accepts the neutral `rpcSessionProvider.ts`
|
|
120
|
+
capabilities and retains the supplied provider type through its generic parameter.
|
|
121
|
+
Each operation resolves the provider's current room, including calls made through
|
|
122
|
+
a cached database facade. Closing clears the provider and cached facade; `remoteDB`
|
|
123
|
+
then returns `undefined`, while `getRemoteDB()` throws
|
|
124
|
+
`Error('Not connected to any room')`. Calls through an earlier facade also reject.
|
|
125
|
+
Existing call timeouts, notification semantics, and method namespaces remain unchanged.
|
|
126
|
+
|
|
127
|
+
`TrysteroReplicatorP2PServer/peerAdmission.ts` contains the named decision,
|
|
128
|
+
prompt, policy, and admission functions. The Server retains its persisted store,
|
|
129
|
+
temporary decisions, advertisements, and pattern caches; getter capabilities
|
|
130
|
+
keep replacements and public method overrides visible. Policy tests require no
|
|
131
|
+
database, room, or complete host environment. Decision types remain available
|
|
132
|
+
through their previous Server exports.
|
|
133
|
+
|
|
134
|
+
The Server's optional third constructor argument accepts `createRoom`, defaulting
|
|
135
|
+
to Trystero's `joinRoom`. It is called at the original point after diagnostic
|
|
136
|
+
subscriptions, and real `RpcRoom` instances still own message and peer-event
|
|
137
|
+
subscriptions. Registration and the synchronous `beforeAdvertisement` hook
|
|
138
|
+
precede advertisement sending. A separate boundary spec uses real RPC rooms and
|
|
139
|
+
paired fake Trystero rooms to verify calls, notifications, cancellation, and close.
|
|
140
|
+
The replicator facade's optional fourth constructor argument supplies relay
|
|
141
|
+
controls, preserving its third finite-operation-owner argument. Disconnection
|
|
142
|
+
reads sockets, pauses reconnection, closes the captured set, and starts the public
|
|
143
|
+
host-stop operation in the original order. Default controls use the shared
|
|
144
|
+
Trystero registry.
|
|
145
|
+
|
|
146
|
+
`src/rpc/RpcRoom.ts` retains registrations, inbound request routing, transport,
|
|
147
|
+
and chunk state. `RpcRoom/pendingInvocations.ts` owns outbound response waits,
|
|
148
|
+
deadlines, abort subscriptions, settlement, and request-before-cancel ordering.
|
|
149
|
+
The room supplies transport, request IDs, timing, and warning callbacks, and
|
|
150
|
+
forwards peer departure and close events. Notifications bypass this coordinator.
|
|
151
|
+
|
|
152
|
+
The internal modules have focused unit tests beside their implementations.
|
|
153
|
+
Direct function tests supply only the capabilities used by that operation;
|
|
154
|
+
factory tests retain coverage of state sharing and lifetime integration.
|
|
155
|
+
Configured-target discovery returns a Promise to adapt advertisement, abort,
|
|
156
|
+
and timeout callbacks. Registration and the initial predicate run inside its
|
|
157
|
+
executor so setup exceptions remain rejections, while cleanup remains synchronous.
|
|
158
|
+
Their lifetime boundaries retain the existing feed stop boundaries and synchronous
|
|
159
|
+
invocation-wait cleanup. They add no consumer entry points, persistent state,
|
|
160
|
+
retry policy, or new queue policy. Function comments record settings provenance,
|
|
161
|
+
secret exclusions, completion meaning, error boundaries, and cancellation order.
|
|
162
|
+
|
|
163
|
+
## File-name lookup implementation
|
|
164
|
+
|
|
165
|
+
`ServiceFileAccessBase.ts` forwards name queries to the host adapter or its
|
|
166
|
+
package-private `ServiceFileAccessBase/fileNames.ts` fallback. The fallback
|
|
167
|
+
retains one typed request for the active storage-event count and comparison
|
|
168
|
+
policy, shares its pending listing, and uses `FilePathIndex` to select candidates.
|
|
169
|
+
A fresh read retires that request before listing again. Older completions remain
|
|
170
|
+
visible to their original callers without replacing a newer retained request.
|
|
171
|
+
`StorageAccess` inherits the name-query methods from the shared `FileNameLookup`
|
|
172
|
+
contract. The host adapter's indexed capability remains optional; the facade's
|
|
173
|
+
fallback keeps both methods available without redeclaring their signatures.
|
|
174
|
+
|
|
175
|
+
The fallback factory owns only its active-request state. Index creation, request
|
|
176
|
+
reuse, candidate selection, and rejection retirement are named module-level
|
|
177
|
+
operations with explicit state and dependency parameters. Listing-only operations
|
|
178
|
+
accept just `getFileNames`; observation counting is required only by candidate
|
|
179
|
+
selection. Direct operation tests cover promise sharing, re-entrant invalidation,
|
|
180
|
+
older request rejection, and policy snapshots alongside the factory contract tests.
|
|
181
|
+
|
|
79
182
|
## Service composition and state ownership
|
|
80
183
|
|
|
81
184
|
Commonlib uses four related forms of composition. Choose between them by ownership and dependency direction, not merely by whether an implementation has mutable state.
|
|
@@ -126,6 +126,30 @@ batch still supplies final sequences and counts. Older peers can ignore the extr
|
|
|
126
126
|
argument and continue using sequence progress. No handshake, retry, heartbeat, or
|
|
127
127
|
persistent replication state is added.
|
|
128
128
|
|
|
129
|
+
## Best-effort change notifications
|
|
130
|
+
|
|
131
|
+
Implementation note: this notification path is unreleased, reviewed against
|
|
132
|
+
Commonlib 0.4.3 and Self-hosted LiveSync 1.0.49. It does not change the published
|
|
133
|
+
status of the lifecycle and diagnostics described elsewhere in this document.
|
|
134
|
+
|
|
135
|
+
P2P change notifications ask a following peer to fetch database changes; they do
|
|
136
|
+
not carry Vault data or confirm that a transfer has succeeded. The sender uses
|
|
137
|
+
`RpcSession.notify()` through the peer client, so it waits only for transport
|
|
138
|
+
sending and does not register a pending RPC invocation or a response timeout.
|
|
139
|
+
A notification rejected before admission therefore cannot block later change
|
|
140
|
+
notifications, and a long-running pull does not delay the sender's next notification.
|
|
141
|
+
|
|
142
|
+
The `change-notification-sent` observation records transport sending, not peer
|
|
143
|
+
admission, completed replication, or Vault reflection. Pull outcomes remain
|
|
144
|
+
separate observations. A missed final notification is not retried automatically;
|
|
145
|
+
a later notification or explicit synchronisation can initiate a fresh comparison.
|
|
146
|
+
|
|
147
|
+
The optional request field `expectsResponse: false` suppresses both successful
|
|
148
|
+
and failed RPC responses on updated receivers. An older receiver may still reply;
|
|
149
|
+
the sender ignores that response because it has no pending invocation. Existing
|
|
150
|
+
request admission, handler execution, cancellation, and room ownership remain in
|
|
151
|
+
force. This change does not make not-ready or busy replication succeed.
|
|
152
|
+
|
|
129
153
|
## Latest diagnostic observations
|
|
130
154
|
|
|
131
155
|
The optional `P2PDiagnostics.getDiagnosticSnapshot()` and
|
package/docs/platform-storage.md
CHANGED
|
@@ -122,6 +122,28 @@ version. Its ordinary case-mismatch check remains separate from path-version
|
|
|
122
122
|
admission. See [Unicode path identity](unicode-path-identity.md#supported-hosts)
|
|
123
123
|
for the current publication and host-adoption boundaries.
|
|
124
124
|
|
|
125
|
+
## File-name candidate lookup
|
|
126
|
+
|
|
127
|
+
These file-name APIs are an unreleased Commonlib change. `FilePathIndex`,
|
|
128
|
+
exported from `/storage`, keeps original file names and groups
|
|
129
|
+
all candidates under an explicit Unicode and case policy. It performs no I/O
|
|
130
|
+
and owns no watcher or readiness state. The host owns the index lifetime,
|
|
131
|
+
initial listing, supported-path rules, and membership updates; use
|
|
132
|
+
`replaceAll()` for an initial snapshot and `apply({ removed, added })` for a
|
|
133
|
+
membership change. Content-only events do not require an index update.
|
|
134
|
+
|
|
135
|
+
Hosts can expose an asynchronous `FileNameLookup` through the optional
|
|
136
|
+
`fileNameLookup` property of `IFileSystemAdapter`. When `{ fresh: true }` is
|
|
137
|
+
supplied, `getFileNames()` must ask the host's supported listing authority
|
|
138
|
+
again. `findPathIdentityCandidates(path, policy)` returns every matching original
|
|
139
|
+
path whose comparison key matches the requested identity. Multiple results are
|
|
140
|
+
candidates for the caller's collision decision. Keep fresh listing guarantees
|
|
141
|
+
host-specific. A host without this
|
|
142
|
+
capability continues to list through `getFiles()` and uses the storage-access
|
|
143
|
+
fallback.
|
|
144
|
+
Direct `StorageAccess` implementations must also implement the required
|
|
145
|
+
`findPathIdentityCandidates()` method when adopting this pre-1.0 interface.
|
|
146
|
+
|
|
125
147
|
## Bundling boundary
|
|
126
148
|
|
|
127
149
|
Browser consumers import only `@vrtmrz/livesync-commonlib/browser`. Packed-package tests build that entry with browser conditions and verify that the Node implementation is absent. Node consumers import `@vrtmrz/livesync-commonlib/node`; the root and context entries do not load Node built-ins.
|
package/docs/releasing.md
CHANGED
|
@@ -73,6 +73,12 @@ implementations must also provide `registerCleanup(callback: () => void): void`;
|
|
|
73
73
|
subclasses of `APIService` inherit its default terminal-unload implementation.
|
|
74
74
|
These changes use the next minor version under the compatibility policy.
|
|
75
75
|
|
|
76
|
+
Version 0.5.0 adds the required `findPathIdentityCandidates()` method to
|
|
77
|
+
`StorageAccess`. Direct implementations must supply it; implementations based
|
|
78
|
+
on `ServiceFileAccessBase` inherit the adapter or listing fallback. The P2P
|
|
79
|
+
client also exposes its closed provider state explicitly in its types. These
|
|
80
|
+
source compatibility changes use the next minor version under the policy.
|
|
81
|
+
|
|
76
82
|
## Preparing a release
|
|
77
83
|
|
|
78
84
|
Choose the version explicitly. For the 0.2 line, start at 0.2.0. A stable candidate can use its final version on the `next` dist-tag, then be checked by exact source revision and tarball SHA-256 before the same version is promoted to `latest`. No `-next.N` or `-rc.N` version is required; use a separate prerelease version only when it is useful for a distinct candidate. Package-proof versions are local artefacts and cannot be staged.
|
|
@@ -8,9 +8,11 @@ Commonlib separates three values which older integrations commonly treated as on
|
|
|
8
8
|
|
|
9
9
|
`DEFAULT_SETTINGS` remains an alias of `SETTINGS_SCHEMA_DEFAULTS` for compatibility. New code should choose the named contract which matches its operation.
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Plaintext acceptance setting (Commonlib 0.4.3)
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Available in [Commonlib 0.4.3](https://www.npmjs.com/package/@vrtmrz/livesync-commonlib/v/0.4.3). The corresponding Self-hosted LiveSync dialogue changes are available in [Self-hosted LiveSync 1.0.49](https://github.com/vrtmrz/obsidian-livesync/releases/tag/1.0.49).
|
|
14
|
+
|
|
15
|
+
The `acceptUnencryptedContent` setting defaults to `false`; only the boolean value `true` enables it. With E2EE enabled, it permits receipt of unencrypted file content from third-party tools which do not use the E2EE passphrase. Content sent by the plug-in remains encrypted. Complete Setup URI and QR imports normalise a missing or invalid value to `false`. Settings Markdown includes the value regardless of credential-sharing choice; a partial Markdown import preserves the current value when the field is absent and treats an explicitly invalid value as `false`.
|
|
14
16
|
|
|
15
17
|
## Starting a new Vault
|
|
16
18
|
|
package/package.json
CHANGED