@synra/protocol 0.0.0 → 0.0.3
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/index.d.mts +34 -3
- package/dist/index.mjs +16 -1
- package/package.json +1 -2
package/dist/index.d.mts
CHANGED
|
@@ -90,6 +90,17 @@ declare const DEVICE_PAIRING_PEER_RESET_EVENT: 'device.pairing.peer-reset';
|
|
|
90
90
|
declare const DEVICE_PAIRING_UNPAIR_REQUIRED_EVENT: 'device.pairing.unpair-required';
|
|
91
91
|
declare function isDevicePairingEvent(event: string): boolean;
|
|
92
92
|
//#endregion
|
|
93
|
+
//#region src/discovery-timing.d.ts
|
|
94
|
+
/** Single wall-clock budget for one LAN discovery run (mDNS/UDP window + Synra TCP probe slice). */
|
|
95
|
+
declare const DEFAULT_SYNRA_SCAN_BUDGET_MS = 2200;
|
|
96
|
+
/**
|
|
97
|
+
* Splits scan budget between native browse/broadcast and Synra probe without a second JS-level timeout knob.
|
|
98
|
+
*/
|
|
99
|
+
declare function synraDiscoveryTimeoutsFromBudget(scanBudgetMs: number): {
|
|
100
|
+
discoveryTimeoutMs: number;
|
|
101
|
+
probeTimeoutMs: number;
|
|
102
|
+
};
|
|
103
|
+
//#endregion
|
|
93
104
|
//#region src/index.d.ts
|
|
94
105
|
declare const PROTOCOL_VERSION: '1.0';
|
|
95
106
|
type DeviceId = string;
|
|
@@ -104,7 +115,7 @@ type ElectionMessageType = 'election.vote.request' | 'election.vote.response' |
|
|
|
104
115
|
type CustomMessageType = `custom.${string}`;
|
|
105
116
|
type SynraMessageType = LegacySynraMessageType | TransportMessageType | RelayMessageType | ClusterHostMessageType | ElectionMessageType | CustomMessageType;
|
|
106
117
|
type RuntimeMessageType = 'runtime.request' | 'runtime.received' | 'runtime.started' | 'runtime.finished' | 'runtime.error';
|
|
107
|
-
type PluginSyncMessageType = 'plugin.catalog.request' | 'plugin.catalog.response';
|
|
118
|
+
type PluginSyncMessageType = 'plugin.catalog.request' | 'plugin.catalog.response' | 'plugin.bundle.request' | 'plugin.bundle.chunk' | 'plugin.bundle.complete';
|
|
108
119
|
type ProtocolMessageType = RuntimeMessageType | PluginSyncMessageType;
|
|
109
120
|
type ShareDetectedPayload = {
|
|
110
121
|
inputType: 'text' | 'url' | 'file';
|
|
@@ -324,6 +335,23 @@ type PluginCatalogResponsePayload = {
|
|
|
324
335
|
plugins: PluginCatalogItem[];
|
|
325
336
|
generatedAt: number;
|
|
326
337
|
};
|
|
338
|
+
type PluginBundleRequestPayload = {
|
|
339
|
+
pluginId: string;
|
|
340
|
+
version: string;
|
|
341
|
+
};
|
|
342
|
+
type PluginBundleChunkPayload = {
|
|
343
|
+
pluginId: string;
|
|
344
|
+
version: string;
|
|
345
|
+
chunkIndex: number;
|
|
346
|
+
totalChunks: number;
|
|
347
|
+
chunkBase64: string;
|
|
348
|
+
};
|
|
349
|
+
type PluginBundleCompletePayload = {
|
|
350
|
+
pluginId: string;
|
|
351
|
+
version: string;
|
|
352
|
+
totalChunks: number;
|
|
353
|
+
sha256?: string;
|
|
354
|
+
};
|
|
327
355
|
type ProtocolPayloadByType = {
|
|
328
356
|
'runtime.request': RuntimeRequestPayload;
|
|
329
357
|
'runtime.received': RuntimeReceivedPayload;
|
|
@@ -332,10 +360,13 @@ type ProtocolPayloadByType = {
|
|
|
332
360
|
'runtime.error': RuntimeErrorPayload;
|
|
333
361
|
'plugin.catalog.request': PluginCatalogRequestPayload;
|
|
334
362
|
'plugin.catalog.response': PluginCatalogResponsePayload;
|
|
363
|
+
'plugin.bundle.request': PluginBundleRequestPayload;
|
|
364
|
+
'plugin.bundle.chunk': PluginBundleChunkPayload;
|
|
365
|
+
'plugin.bundle.complete': PluginBundleCompletePayload;
|
|
335
366
|
};
|
|
336
367
|
type MessageByType<K extends keyof ProtocolPayloadByType> = ProtocolEnvelope<K, ProtocolPayloadByType[K]>;
|
|
337
368
|
type SynraRuntimeMessage = MessageByType<'runtime.request'> | MessageByType<'runtime.received'> | MessageByType<'runtime.started'> | MessageByType<'runtime.finished'> | MessageByType<'runtime.error'>;
|
|
338
|
-
type SynraPluginSyncMessage = MessageByType<'plugin.catalog.request'> | MessageByType<'plugin.catalog.response'>;
|
|
369
|
+
type SynraPluginSyncMessage = MessageByType<'plugin.catalog.request'> | MessageByType<'plugin.catalog.response'> | MessageByType<'plugin.bundle.request'> | MessageByType<'plugin.bundle.chunk'> | MessageByType<'plugin.bundle.complete'>;
|
|
339
370
|
type SynraProtocolMessage = SynraRuntimeMessage | SynraPluginSyncMessage;
|
|
340
371
|
type SynraActionReceipt = {
|
|
341
372
|
ok: true;
|
|
@@ -359,4 +390,4 @@ declare function unknownToErrorMessage(error: unknown, fallback: string): string
|
|
|
359
390
|
declare function createMessage<TPayload>(input: Omit<SynraCrossDeviceMessage<SynraMessageType, TPayload>, 'protocolVersion'>): SynraCrossDeviceMessage<SynraMessageType, TPayload>;
|
|
360
391
|
declare function createProtocolMessage<TType extends keyof ProtocolPayloadByType>(input: Omit<ProtocolEnvelope<TType, ProtocolPayloadByType[TType]>, 'protocolVersion'>): ProtocolEnvelope<TType, ProtocolPayloadByType[TType]>;
|
|
361
392
|
//#endregion
|
|
362
|
-
export { ActionCompletedPayload, ActionExecutingPayload, ActionFailedPayload, ActionId, ActionProposedPayload, ClusterHostMessageType, CustomMessageType, DEVICE_DISPLAY_NAME_CHANGED_EVENT, DEVICE_HOST_RETIRE_EVENT, DEVICE_MEMBER_OFFLINE_EVENT, DEVICE_PAIRING_PEER_RESET_EVENT, DEVICE_PAIRING_PREFIX, DEVICE_PAIRING_REQUEST_EVENT, DEVICE_PAIRING_RESPONSE_EVENT, DEVICE_PAIRING_UNPAIR_REQUIRED_EVENT, DEVICE_TCP_ACK_EVENT, DEVICE_TCP_CLOSE_EVENT, DEVICE_TCP_CONNECT_ACK_EVENT, DEVICE_TCP_CONNECT_EVENT, DEVICE_TCP_ERROR_EVENT, DEVICE_TCP_HEARTBEAT_EVENT, DeviceId, ElectionMessageType, ElectionVoteRequestPayload, ElectionVoteResponsePayload, ElectionWinPayload, HostAnnouncePayload, HostHeartbeatPayload, HostMemberOfflinePayload, HostRetirePayload, LAN_WIRE_EVENT_NAMES, LanDeviceDisplayNameChangedPayload, LanPairingPeerResetPayload, LanPairingRequestPayload, LanPairingResponsePayload, LanPairingUnpairRequiredPayload, LanWireEventEnvelope, LanWireEventName, LegacySynraMessageType, MessageId, PROTOCOL_VERSION, PluginCatalogItem, PluginCatalogRequestPayload, PluginCatalogResponsePayload, PluginSyncMessageType, ProtocolEnvelope, ProtocolErrorCode, ProtocolErrorPayload, ProtocolMessageType, ProtocolPayloadByType, RelayAckPayload, RelayMessageType, RelayRequestPayload, RelayResultPayload, RuntimeErrorPayload, RuntimeFinishedPayload, RuntimeFinishedStatus, RuntimeMessageType, RuntimeReceivedPayload, RuntimeRequestPayload, RuntimeStartedPayload, ShareDetectedPayload, SynraActionReceipt, SynraActionRequest, SynraCrossDeviceMessage, SynraCrossDevicePayloadByType, SynraErrorCode, SynraMessageType, SynraPluginSyncMessage, SynraProtocolMessage, SynraRuntimeMessage, TraceId, TransportClosedPayload, TransportErrorPayload, TransportMessageAckPayload, TransportMessageReceivedPayload, TransportMessageType, TransportOpenedPayload, createMessage, createProtocolMessage, isDevicePairingEvent, isLanWireEventName, unknownToErrorMessage };
|
|
393
|
+
export { ActionCompletedPayload, ActionExecutingPayload, ActionFailedPayload, ActionId, ActionProposedPayload, ClusterHostMessageType, CustomMessageType, DEFAULT_SYNRA_SCAN_BUDGET_MS, DEVICE_DISPLAY_NAME_CHANGED_EVENT, DEVICE_HOST_RETIRE_EVENT, DEVICE_MEMBER_OFFLINE_EVENT, DEVICE_PAIRING_PEER_RESET_EVENT, DEVICE_PAIRING_PREFIX, DEVICE_PAIRING_REQUEST_EVENT, DEVICE_PAIRING_RESPONSE_EVENT, DEVICE_PAIRING_UNPAIR_REQUIRED_EVENT, DEVICE_TCP_ACK_EVENT, DEVICE_TCP_CLOSE_EVENT, DEVICE_TCP_CONNECT_ACK_EVENT, DEVICE_TCP_CONNECT_EVENT, DEVICE_TCP_ERROR_EVENT, DEVICE_TCP_HEARTBEAT_EVENT, DeviceId, ElectionMessageType, ElectionVoteRequestPayload, ElectionVoteResponsePayload, ElectionWinPayload, HostAnnouncePayload, HostHeartbeatPayload, HostMemberOfflinePayload, HostRetirePayload, LAN_WIRE_EVENT_NAMES, LanDeviceDisplayNameChangedPayload, LanPairingPeerResetPayload, LanPairingRequestPayload, LanPairingResponsePayload, LanPairingUnpairRequiredPayload, LanWireEventEnvelope, LanWireEventName, LegacySynraMessageType, MessageId, PROTOCOL_VERSION, PluginBundleChunkPayload, PluginBundleCompletePayload, PluginBundleRequestPayload, PluginCatalogItem, PluginCatalogRequestPayload, PluginCatalogResponsePayload, PluginSyncMessageType, ProtocolEnvelope, ProtocolErrorCode, ProtocolErrorPayload, ProtocolMessageType, ProtocolPayloadByType, RelayAckPayload, RelayMessageType, RelayRequestPayload, RelayResultPayload, RuntimeErrorPayload, RuntimeFinishedPayload, RuntimeFinishedStatus, RuntimeMessageType, RuntimeReceivedPayload, RuntimeRequestPayload, RuntimeStartedPayload, ShareDetectedPayload, SynraActionReceipt, SynraActionRequest, SynraCrossDeviceMessage, SynraCrossDevicePayloadByType, SynraErrorCode, SynraMessageType, SynraPluginSyncMessage, SynraProtocolMessage, SynraRuntimeMessage, TraceId, TransportClosedPayload, TransportErrorPayload, TransportMessageAckPayload, TransportMessageReceivedPayload, TransportMessageType, TransportOpenedPayload, createMessage, createProtocolMessage, isDevicePairingEvent, isLanWireEventName, synraDiscoveryTimeoutsFromBudget, unknownToErrorMessage };
|
package/dist/index.mjs
CHANGED
|
@@ -55,6 +55,21 @@ function isLanWireEventName(value) {
|
|
|
55
55
|
return LAN_WIRE_EVENT_NAMES.includes(value);
|
|
56
56
|
}
|
|
57
57
|
//#endregion
|
|
58
|
+
//#region src/discovery-timing.ts
|
|
59
|
+
/** Single wall-clock budget for one LAN discovery run (mDNS/UDP window + Synra TCP probe slice). */
|
|
60
|
+
const DEFAULT_SYNRA_SCAN_BUDGET_MS = 2200;
|
|
61
|
+
/**
|
|
62
|
+
* Splits scan budget between native browse/broadcast and Synra probe without a second JS-level timeout knob.
|
|
63
|
+
*/
|
|
64
|
+
function synraDiscoveryTimeoutsFromBudget(scanBudgetMs) {
|
|
65
|
+
const budget = Math.max(600, Math.floor(scanBudgetMs));
|
|
66
|
+
const probeTimeoutMs = Math.min(900, Math.max(350, Math.floor(budget * .38)));
|
|
67
|
+
return {
|
|
68
|
+
discoveryTimeoutMs: Math.max(200, budget - probeTimeoutMs - 80),
|
|
69
|
+
probeTimeoutMs
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
58
73
|
//#region src/index.ts
|
|
59
74
|
const PROTOCOL_VERSION = "1.0";
|
|
60
75
|
function unknownToErrorMessage(error, fallback) {
|
|
@@ -73,4 +88,4 @@ function createProtocolMessage(input) {
|
|
|
73
88
|
};
|
|
74
89
|
}
|
|
75
90
|
//#endregion
|
|
76
|
-
export { DEVICE_DISPLAY_NAME_CHANGED_EVENT, DEVICE_HOST_RETIRE_EVENT, DEVICE_MEMBER_OFFLINE_EVENT, DEVICE_PAIRING_PEER_RESET_EVENT, DEVICE_PAIRING_PREFIX, DEVICE_PAIRING_REQUEST_EVENT, DEVICE_PAIRING_RESPONSE_EVENT, DEVICE_PAIRING_UNPAIR_REQUIRED_EVENT, DEVICE_TCP_ACK_EVENT, DEVICE_TCP_CLOSE_EVENT, DEVICE_TCP_CONNECT_ACK_EVENT, DEVICE_TCP_CONNECT_EVENT, DEVICE_TCP_ERROR_EVENT, DEVICE_TCP_HEARTBEAT_EVENT, LAN_WIRE_EVENT_NAMES, PROTOCOL_VERSION, createMessage, createProtocolMessage, isDevicePairingEvent, isLanWireEventName, unknownToErrorMessage };
|
|
91
|
+
export { DEFAULT_SYNRA_SCAN_BUDGET_MS, DEVICE_DISPLAY_NAME_CHANGED_EVENT, DEVICE_HOST_RETIRE_EVENT, DEVICE_MEMBER_OFFLINE_EVENT, DEVICE_PAIRING_PEER_RESET_EVENT, DEVICE_PAIRING_PREFIX, DEVICE_PAIRING_REQUEST_EVENT, DEVICE_PAIRING_RESPONSE_EVENT, DEVICE_PAIRING_UNPAIR_REQUIRED_EVENT, DEVICE_TCP_ACK_EVENT, DEVICE_TCP_CLOSE_EVENT, DEVICE_TCP_CONNECT_ACK_EVENT, DEVICE_TCP_CONNECT_EVENT, DEVICE_TCP_ERROR_EVENT, DEVICE_TCP_HEARTBEAT_EVENT, LAN_WIRE_EVENT_NAMES, PROTOCOL_VERSION, createMessage, createProtocolMessage, isDevicePairingEvent, isLanWireEventName, synraDiscoveryTimeoutsFromBudget, unknownToErrorMessage };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synra/protocol",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Shared cross-device protocol contracts for Synra.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@types/node": "^25.6.0",
|
|
19
|
-
"bumpp": "^11.0.1",
|
|
20
19
|
"typescript": "^6.0.3",
|
|
21
20
|
"vite-plus": "^0.1.19"
|
|
22
21
|
},
|