@m4l/realtime-runtime 1.0.2-beta-m4lcom-715-ajustes-mf-22.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/contracts/index.d.ts +2 -0
- package/contracts/index.d.ts.map +1 -0
- package/contracts/types.d.ts +192 -0
- package/contracts/types.d.ts.map +1 -0
- package/engine/ObjectQueue.d.ts +19 -0
- package/engine/ObjectQueue.d.ts.map +1 -0
- package/engine/ObjectQueue.js +29 -0
- package/engine/index.d.ts +4 -0
- package/engine/index.d.ts.map +1 -0
- package/engine/runtimeCore.d.ts +16 -0
- package/engine/runtimeCore.d.ts.map +1 -0
- package/engine/runtimeCore.js +12 -0
- package/engine/runtimeRegistry.d.ts +20 -0
- package/engine/runtimeRegistry.d.ts.map +1 -0
- package/engine/runtimeRegistry.js +27 -0
- package/index.d.ts +9 -0
- package/index.d.ts.map +1 -0
- package/index.js +13 -0
- package/package.json +39 -0
- package/transport/SourceDataBase.d.ts +16 -0
- package/transport/SourceDataBase.d.ts.map +1 -0
- package/transport/SourceDataBase.js +14 -0
- package/transport/atmosphere/SourceDataAtmosphere.d.ts +38 -0
- package/transport/atmosphere/SourceDataAtmosphere.d.ts.map +1 -0
- package/transport/atmosphere/SourceDataAtmosphere.js +170 -0
- package/transport/atmosphere/createAtmosphereSourceData.d.ts +7 -0
- package/transport/atmosphere/createAtmosphereSourceData.d.ts.map +1 -0
- package/transport/atmosphere/createAtmosphereSourceData.js +11 -0
- package/transport/atmosphere/index.d.ts +4 -0
- package/transport/atmosphere/index.d.ts.map +1 -0
- package/transport/atmosphere/types.d.ts +29 -0
- package/transport/atmosphere/types.d.ts.map +1 -0
- package/transport/index.d.ts +4 -0
- package/transport/index.d.ts.map +1 -0
- package/web/constants.d.ts +2 -0
- package/web/constants.d.ts.map +1 -0
- package/web/constants.js +4 -0
- package/web/index.d.ts +8 -0
- package/web/index.d.ts.map +1 -0
- package/web/runtime.d.ts +42 -0
- package/web/runtime.d.ts.map +1 -0
- package/web/runtime.js +89 -0
- package/web/store.d.ts +16 -0
- package/web/store.d.ts.map +1 -0
- package/web/store.helpers.d.ts +22 -0
- package/web/store.helpers.d.ts.map +1 -0
- package/web/store.helpers.js +35 -0
- package/web/store.js +147 -0
- package/web/tools.d.ts +7 -0
- package/web/tools.d.ts.map +1 -0
- package/web/tools.js +13 -0
- package/web/types.d.ts +121 -0
- package/web/types.d.ts.map +1 -0
- package/web.d.ts +3 -0
- package/web.d.ts.map +1 -0
- package/web.js +12 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export type { OnMessagesStoreCallback, OnRealTimeProducerMetricCallback, OnRealTimeConsumerMessageCallback, OnRealtimeConsumerSubscribeCallback, RealTimeMessage, RealTimeMessagePayload, RealTimeProducerTools, RealTimeProducerMetricName, RealTimeResourceHash, RealTimeResourceSerialId, RealTimeResourceSourceMechanismConfig, RealTimeResourceSourceMechanismConfigAtmosphere, RealTimeResourceSourceMechanismConfigBase, RealTimeResourceType, RealTimeResourceTypeId, RealTimeStatus, ResourceTypeSourceDataMechanism, SubscribeOptions, Subscriber, } from './types';
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/realtime-runtime/src/contracts/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,uBAAuB,EACvB,gCAAgC,EAChC,iCAAiC,EACjC,mCAAmC,EACnC,eAAe,EACf,sBAAsB,EACtB,qBAAqB,EACrB,0BAA0B,EAC1B,oBAAoB,EACpB,wBAAwB,EACxB,qCAAqC,EACrC,+CAA+C,EAC/C,yCAAyC,EACzC,oBAAoB,EACpB,sBAAsB,EACtB,cAAc,EACd,+BAA+B,EAC/B,gBAAgB,EAChB,UAAU,GACX,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { SourceDataBase } from '../transport/SourceDataBase';
|
|
2
|
+
/**
|
|
3
|
+
* Realtime resource-type identifier.
|
|
4
|
+
*/
|
|
5
|
+
export type RealTimeResourceTypeId = string;
|
|
6
|
+
/**
|
|
7
|
+
* Realtime source-mechanism identifier.
|
|
8
|
+
*/
|
|
9
|
+
export type ResourceTypeSourceDataMechanism = string;
|
|
10
|
+
/**
|
|
11
|
+
* Realtime resource identifier.
|
|
12
|
+
*/
|
|
13
|
+
export type RealTimeResourceSerialId = number | string;
|
|
14
|
+
/**
|
|
15
|
+
* Realtime message payload.
|
|
16
|
+
*/
|
|
17
|
+
export type RealTimeMessagePayload = Record<string | number, unknown>;
|
|
18
|
+
/**
|
|
19
|
+
* Producer-side resource snapshot shared across neutral runtime APIs.
|
|
20
|
+
*/
|
|
21
|
+
export type RealTimeResourceHash = Record<RealTimeResourceSerialId, RealTimeMessagePayload>;
|
|
22
|
+
/**
|
|
23
|
+
* Realtime message.
|
|
24
|
+
*/
|
|
25
|
+
export interface RealTimeMessage {
|
|
26
|
+
type: 'new' | 'update' | 'delete';
|
|
27
|
+
resourceSerialId: RealTimeResourceSerialId;
|
|
28
|
+
readonly payload: RealTimeMessagePayload;
|
|
29
|
+
}
|
|
30
|
+
export type OnRealTimeConsumerMessageCallback = (resourceTypeId: RealTimeResourceTypeId, messages: RealTimeMessage[]) => void;
|
|
31
|
+
export type OnRealtimeConsumerSubscribeCallback = (resourceTypeId: RealTimeResourceTypeId, initialHashResources: RealTimeResourceHash) => void;
|
|
32
|
+
export type Subscriber = {
|
|
33
|
+
clientId: string;
|
|
34
|
+
/**
|
|
35
|
+
* Callbacks invoked when a batch of messages is processed.
|
|
36
|
+
*/
|
|
37
|
+
onMessageCallbacks: OnRealTimeConsumerMessageCallback[];
|
|
38
|
+
};
|
|
39
|
+
export interface SubscribeOptions extends Pick<Subscriber, 'clientId' | 'onMessageCallbacks'> {
|
|
40
|
+
/**
|
|
41
|
+
* Callbacks invoked on subscription with the current producer-side resource hash.
|
|
42
|
+
*/
|
|
43
|
+
onSubscribeCallbacks: OnRealtimeConsumerSubscribeCallback[];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Host-owned producer actions that consumers can use without depending on one React provider.
|
|
47
|
+
*/
|
|
48
|
+
export interface RealTimeProducerTools {
|
|
49
|
+
/**
|
|
50
|
+
* Subscribe one consumer client to a realtime resource type.
|
|
51
|
+
*/
|
|
52
|
+
subscribe: (resourceTypeId: RealTimeResourceTypeId, options: SubscribeOptions) => void;
|
|
53
|
+
/**
|
|
54
|
+
* Unsubscribe one consumer client from a realtime resource type.
|
|
55
|
+
*/
|
|
56
|
+
unsubscribe: (resourceTypeId: RealTimeResourceTypeId, clientId: string) => void;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Realtime connection state.
|
|
60
|
+
*/
|
|
61
|
+
export type RealTimeStatus = 'init' | 'conecting' | 'connected' | 'standby';
|
|
62
|
+
/**
|
|
63
|
+
* Shared realtime resource configuration.
|
|
64
|
+
*
|
|
65
|
+
* Keep the index signature open so domain adapters such as `@m4l/gclick` can
|
|
66
|
+
* extend the config with resource-specific metadata without changing the engine.
|
|
67
|
+
*/
|
|
68
|
+
export interface RealTimeResourceSourceMechanismConfigBase {
|
|
69
|
+
/**
|
|
70
|
+
* Realtime data-source mechanism used by this resource type.
|
|
71
|
+
*/
|
|
72
|
+
sourceDataMechanism: ResourceTypeSourceDataMechanism;
|
|
73
|
+
/**
|
|
74
|
+
* Resource type that emits the realtime messages.
|
|
75
|
+
*/
|
|
76
|
+
resourceTypeId: RealTimeResourceTypeId;
|
|
77
|
+
/**
|
|
78
|
+
* Initial producer-side resource hash for the configured resource type.
|
|
79
|
+
*/
|
|
80
|
+
initialHashResources?: RealTimeResourceHash;
|
|
81
|
+
/**
|
|
82
|
+
* Optional fallback TTL used when a resource disappears silently without an explicit delete message.
|
|
83
|
+
*/
|
|
84
|
+
staleResourceTtlMs?: number;
|
|
85
|
+
/**
|
|
86
|
+
* Interval used to scan for stale resources when TTL cleanup is enabled.
|
|
87
|
+
*/
|
|
88
|
+
staleResourceCleanupIntervalMs?: number;
|
|
89
|
+
[key: string]: unknown;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Atmosphere-specific realtime resource configuration.
|
|
93
|
+
*/
|
|
94
|
+
export interface RealTimeResourceSourceMechanismConfigAtmosphere extends RealTimeResourceSourceMechanismConfigBase {
|
|
95
|
+
/**
|
|
96
|
+
* Realtime data-source mechanism used by this resource type.
|
|
97
|
+
*/
|
|
98
|
+
sourceDataMechanism: 'atmosphere';
|
|
99
|
+
/**
|
|
100
|
+
* Atmosphere request host or host fragment. The runtime normalizes it to an
|
|
101
|
+
* HTTP(S) base URL so websocket and XHR fallback transports can share it.
|
|
102
|
+
*/
|
|
103
|
+
host: string;
|
|
104
|
+
/**
|
|
105
|
+
* Legacy transport field kept for backward compatibility with the existing config shape.
|
|
106
|
+
*/
|
|
107
|
+
port?: string;
|
|
108
|
+
/**
|
|
109
|
+
* Atmosphere websocket path.
|
|
110
|
+
*/
|
|
111
|
+
path: string;
|
|
112
|
+
/**
|
|
113
|
+
* Optional fallback transport used when websocket cannot be preserved.
|
|
114
|
+
*
|
|
115
|
+
* Use `'websocket'` for explicit websocket-only diagnostics.
|
|
116
|
+
*/
|
|
117
|
+
fallbackTransport?: 'long-polling' | 'websocket';
|
|
118
|
+
/**
|
|
119
|
+
* Atmosphere websocket topic.
|
|
120
|
+
*/
|
|
121
|
+
topic: string;
|
|
122
|
+
/**
|
|
123
|
+
* Current authenticated session id.
|
|
124
|
+
*/
|
|
125
|
+
sessionId: string;
|
|
126
|
+
/**
|
|
127
|
+
* Backend database namespace consumed by the Atmosphere subscription endpoint.
|
|
128
|
+
*/
|
|
129
|
+
database: string;
|
|
130
|
+
/**
|
|
131
|
+
* Consumer mode requested from the realtime backend.
|
|
132
|
+
*/
|
|
133
|
+
consumerType?: string;
|
|
134
|
+
/**
|
|
135
|
+
* Batch throttling value consumed by the realtime backend.
|
|
136
|
+
*/
|
|
137
|
+
rateLimit?: number;
|
|
138
|
+
/**
|
|
139
|
+
* Resource filter list requested from the realtime backend.
|
|
140
|
+
*/
|
|
141
|
+
resourcesId?: Array<RealTimeResourceSerialId | 'all'>;
|
|
142
|
+
/**
|
|
143
|
+
* Projection list requested from the realtime backend.
|
|
144
|
+
*/
|
|
145
|
+
projections?: unknown[];
|
|
146
|
+
/**
|
|
147
|
+
* Subscription contract version sent to the realtime backend.
|
|
148
|
+
*/
|
|
149
|
+
version?: string;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Generic realtime resource configuration accepted by the runtime engine.
|
|
153
|
+
*/
|
|
154
|
+
export type RealTimeResourceSourceMechanismConfig = RealTimeResourceSourceMechanismConfigBase;
|
|
155
|
+
/**
|
|
156
|
+
* Producer-side realtime resource descriptor.
|
|
157
|
+
*/
|
|
158
|
+
export interface RealTimeResourceType {
|
|
159
|
+
/**
|
|
160
|
+
* Resource configuration.
|
|
161
|
+
*/
|
|
162
|
+
config: RealTimeResourceSourceMechanismConfig;
|
|
163
|
+
/**
|
|
164
|
+
* Current connection state.
|
|
165
|
+
*/
|
|
166
|
+
status: RealTimeStatus;
|
|
167
|
+
/**
|
|
168
|
+
* Source data class responsible for realtime ingestion.
|
|
169
|
+
*/
|
|
170
|
+
sourceDataClass: SourceDataBase;
|
|
171
|
+
/**
|
|
172
|
+
* Producer-side resource hash.
|
|
173
|
+
*/
|
|
174
|
+
hasResources: RealTimeResourceHash;
|
|
175
|
+
/**
|
|
176
|
+
* Clients subscribed to the current resource type.
|
|
177
|
+
*/
|
|
178
|
+
subscribedClients: Record<string, Subscriber>;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Callback used by realtime source mechanisms to forward messages into the store.
|
|
182
|
+
*/
|
|
183
|
+
export type OnMessagesStoreCallback = (resourceTypeId: RealTimeResourceTypeId, message: RealTimeMessage[]) => void;
|
|
184
|
+
/**
|
|
185
|
+
* Producer-runtime metric names emitted by the generic engine.
|
|
186
|
+
*/
|
|
187
|
+
export type RealTimeProducerMetricName = 'producerIncomingBatch' | 'producerDrainSet';
|
|
188
|
+
/**
|
|
189
|
+
* Optional reporter used by platform or domain adapters to observe engine metrics.
|
|
190
|
+
*/
|
|
191
|
+
export type OnRealTimeProducerMetricCallback = (metricName: RealTimeProducerMetricName, value?: number) => void;
|
|
192
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../packages/realtime-runtime/src/contracts/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Queue implementation using an object as the underlying data structure.
|
|
3
|
+
*/
|
|
4
|
+
export declare class ObjectQueue<T = object> {
|
|
5
|
+
private items;
|
|
6
|
+
private head;
|
|
7
|
+
private tail;
|
|
8
|
+
/**
|
|
9
|
+
* Enqueues an element.
|
|
10
|
+
*/
|
|
11
|
+
enqueue(item: T): void;
|
|
12
|
+
/**
|
|
13
|
+
* Dequeues an element.
|
|
14
|
+
*/
|
|
15
|
+
dequeue(): T | undefined;
|
|
16
|
+
size(): number;
|
|
17
|
+
isEmpty(): boolean;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=ObjectQueue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObjectQueue.d.ts","sourceRoot":"","sources":["../../../../../packages/realtime-runtime/src/engine/ObjectQueue.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,WAAW,CAAC,CAAC,GAAG,MAAM;IACjC,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,IAAI,CAAK;IACjB,OAAO,CAAC,IAAI,CAAK;IACjB;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI;IAItB;;OAEG;IACH,OAAO,IAAI,CAAC,GAAG,SAAS;IASxB,IAAI,IAAI,MAAM;IAGd,OAAO,IAAI,OAAO;CAGnB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
class i {
|
|
2
|
+
items = {};
|
|
3
|
+
head = 0;
|
|
4
|
+
tail = 0;
|
|
5
|
+
/**
|
|
6
|
+
* Enqueues an element.
|
|
7
|
+
*/
|
|
8
|
+
enqueue(t) {
|
|
9
|
+
this.items[this.tail] = t, this.tail++;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Dequeues an element.
|
|
13
|
+
*/
|
|
14
|
+
dequeue() {
|
|
15
|
+
if (this.head === this.tail)
|
|
16
|
+
return;
|
|
17
|
+
const t = this.items[this.head];
|
|
18
|
+
return delete this.items[this.head], this.head++, t;
|
|
19
|
+
}
|
|
20
|
+
size() {
|
|
21
|
+
return this.tail - this.head;
|
|
22
|
+
}
|
|
23
|
+
isEmpty() {
|
|
24
|
+
return this.size() === 0;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
i as ObjectQueue
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/realtime-runtime/src/engine/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RealTimeResourceHash, RealTimeResourceTypeId, RealTimeStatus, SubscribeOptions } from '../contracts';
|
|
2
|
+
/**
|
|
3
|
+
* Neutral runtime API that should remain usable beyond one specific UI store adapter.
|
|
4
|
+
*/
|
|
5
|
+
export interface RealtimeRuntime {
|
|
6
|
+
dispose: () => void;
|
|
7
|
+
getSnapshot: (resourceTypeId: RealTimeResourceTypeId) => RealTimeResourceHash;
|
|
8
|
+
getStatus: (resourceTypeId: RealTimeResourceTypeId) => RealTimeStatus | undefined;
|
|
9
|
+
subscribe: (resourceTypeId: RealTimeResourceTypeId, options: SubscribeOptions) => void;
|
|
10
|
+
unsubscribe: (resourceTypeId: RealTimeResourceTypeId, clientId: string) => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Build the neutral runtime API from one adapter that already satisfies the runtime contract.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createRealtimeRuntimeApi(runtime: RealtimeRuntime): RealtimeRuntime;
|
|
16
|
+
//# sourceMappingURL=runtimeCore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtimeCore.d.ts","sourceRoot":"","sources":["../../../../../packages/realtime-runtime/src/engine/runtimeCore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,cAAc,EACd,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAEtB;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,WAAW,EAAE,CAAC,cAAc,EAAE,sBAAsB,KAAK,oBAAoB,CAAC;IAC9E,SAAS,EAAE,CAAC,cAAc,EAAE,sBAAsB,KAAK,cAAc,GAAG,SAAS,CAAC;IAClF,SAAS,EAAE,CAAC,cAAc,EAAE,sBAAsB,EAAE,OAAO,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACvF,WAAW,EAAE,CAAC,cAAc,EAAE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACjF;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,eAAe,GACvB,eAAe,CAQjB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RealtimeRuntime } from './runtimeCore';
|
|
2
|
+
declare global {
|
|
3
|
+
var __M4L_REALTIME_PRODUCER_RUNTIMES__: Record<string, RealtimeRuntime> | undefined;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Input contract used to lazily create or reuse one host-owned runtime.
|
|
7
|
+
*/
|
|
8
|
+
export interface EnsureRealtimeRuntimeProps<TCreateProps> {
|
|
9
|
+
createProps: TCreateProps;
|
|
10
|
+
runtimeKey: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Create one ensure helper around the provided runtime factory.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createEnsureRealtimeRuntime<TCreateProps, TRuntime extends RealtimeRuntime>(createRuntime: (props: TCreateProps) => TRuntime): (props: EnsureRealtimeRuntimeProps<TCreateProps>) => TRuntime;
|
|
16
|
+
/**
|
|
17
|
+
* Dispose one cached host-owned runtime and remove it from the registry.
|
|
18
|
+
*/
|
|
19
|
+
export declare function disposeRealtimeRuntime(storeKey: string): void;
|
|
20
|
+
//# sourceMappingURL=runtimeRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtimeRegistry.d.ts","sourceRoot":"","sources":["../../../../../packages/realtime-runtime/src/engine/runtimeRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAMrD,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,kCAAkC,EAClC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAC/B,SAAS,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B,CAAC,YAAY;IACtD,WAAW,EAAE,YAAY,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;CACpB;AAaD;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,YAAY,EAAE,QAAQ,SAAS,eAAe,EACxF,aAAa,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,QAAQ,IAM9C,OAAO,0BAA0B,CAAC,YAAY,CAAC,KAC9C,QAAQ,CAqBZ;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,QAgBtD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const R = globalThis;
|
|
2
|
+
function s() {
|
|
3
|
+
return R.__M4L_REALTIME_PRODUCER_RUNTIMES__ || (R.__M4L_REALTIME_PRODUCER_RUNTIMES__ = {}), R.__M4L_REALTIME_PRODUCER_RUNTIMES__;
|
|
4
|
+
}
|
|
5
|
+
function c(i) {
|
|
6
|
+
return function(t) {
|
|
7
|
+
const { createProps: n, runtimeKey: _ } = t, r = _.trim();
|
|
8
|
+
if (!r)
|
|
9
|
+
throw new Error("Realtime runtime requires a non-empty runtimeKey.");
|
|
10
|
+
const u = s(), m = u[r];
|
|
11
|
+
if (m)
|
|
12
|
+
return m;
|
|
13
|
+
const o = i(n);
|
|
14
|
+
return u[r] = o, o;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function E(i) {
|
|
18
|
+
const e = i.trim();
|
|
19
|
+
if (!e)
|
|
20
|
+
return;
|
|
21
|
+
const t = s(), n = t[e];
|
|
22
|
+
n && (n.dispose(), delete t[e]);
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
c as createEnsureRealtimeRuntime,
|
|
26
|
+
E as disposeRealtimeRuntime
|
|
27
|
+
};
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { ObjectQueue } from './engine';
|
|
2
|
+
export type { RealtimeRuntime } from './engine';
|
|
3
|
+
export { createEnsureRealtimeRuntime, disposeRealtimeRuntime, } from './engine';
|
|
4
|
+
export { SourceDataBase } from './transport';
|
|
5
|
+
export { createAtmosphereSourceData } from './transport';
|
|
6
|
+
export { SourceDataAtmosphere } from './transport';
|
|
7
|
+
export type { AtmosphereMessage } from './transport';
|
|
8
|
+
export type { OnMessagesStoreCallback, OnRealTimeProducerMetricCallback, OnRealTimeConsumerMessageCallback, OnRealtimeConsumerSubscribeCallback, RealTimeMessage, RealTimeMessagePayload, RealTimeProducerTools, RealTimeProducerMetricName, RealTimeResourceHash, RealTimeResourceSerialId, RealTimeResourceSourceMechanismConfig, RealTimeResourceSourceMechanismConfigAtmosphere, RealTimeResourceSourceMechanismConfigBase, RealTimeResourceType, RealTimeResourceTypeId, RealTimeStatus, ResourceTypeSourceDataMechanism, SubscribeOptions, Subscriber, } from './contracts';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/realtime-runtime/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,YAAY,EACV,uBAAuB,EACvB,gCAAgC,EAChC,iCAAiC,EACjC,mCAAmC,EACnC,eAAe,EACf,sBAAsB,EACtB,qBAAqB,EACrB,0BAA0B,EAC1B,oBAAoB,EACpB,wBAAwB,EACxB,qCAAqC,EACrC,+CAA+C,EAC/C,yCAAyC,EACzC,oBAAoB,EACpB,sBAAsB,EACtB,cAAc,EACd,+BAA+B,EAC/B,gBAAgB,EAChB,UAAU,GACX,MAAM,aAAa,CAAC"}
|
package/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ObjectQueue as t } from "./engine/ObjectQueue.js";
|
|
2
|
+
import { createEnsureRealtimeRuntime as a, disposeRealtimeRuntime as m } from "./engine/runtimeRegistry.js";
|
|
3
|
+
import { SourceDataBase as u } from "./transport/SourceDataBase.js";
|
|
4
|
+
import { createAtmosphereSourceData as s } from "./transport/atmosphere/createAtmosphereSourceData.js";
|
|
5
|
+
import { SourceDataAtmosphere as i } from "./transport/atmosphere/SourceDataAtmosphere.js";
|
|
6
|
+
export {
|
|
7
|
+
t as ObjectQueue,
|
|
8
|
+
i as SourceDataAtmosphere,
|
|
9
|
+
u as SourceDataBase,
|
|
10
|
+
s as createAtmosphereSourceData,
|
|
11
|
+
a as createEnsureRealtimeRuntime,
|
|
12
|
+
m as disposeRealtimeRuntime
|
|
13
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@m4l/realtime-runtime",
|
|
3
|
+
"version": "1.0.2-beta-m4lcom-715-ajustes-mf-22.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"type": "module",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"main": "./index.js",
|
|
10
|
+
"module": "./index.js",
|
|
11
|
+
"types": "./index.d.ts",
|
|
12
|
+
"files": [
|
|
13
|
+
"index.js",
|
|
14
|
+
"index.d.ts",
|
|
15
|
+
"*"
|
|
16
|
+
],
|
|
17
|
+
"exports": {
|
|
18
|
+
"./package.json": "./package.json",
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./index.d.ts",
|
|
21
|
+
"import": "./index.js",
|
|
22
|
+
"default": "./index.js"
|
|
23
|
+
},
|
|
24
|
+
"./web": {
|
|
25
|
+
"development": "./src/web.ts",
|
|
26
|
+
"types": "./web.d.ts",
|
|
27
|
+
"import": "./web.js",
|
|
28
|
+
"default": "./web.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"atmosphere.js": "4.0.1",
|
|
33
|
+
"camelcase-keys": "9.1.3",
|
|
34
|
+
"immer": "9.0.21",
|
|
35
|
+
"lodash-es": "4.17.23",
|
|
36
|
+
"tslib": "2.8.1",
|
|
37
|
+
"zustand": "4.3.6"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { OnMessagesStoreCallback, RealTimeResourceSourceMechanismConfig } from '../contracts';
|
|
2
|
+
/**
|
|
3
|
+
* Base contract implemented by one realtime source mechanism.
|
|
4
|
+
*/
|
|
5
|
+
export declare abstract class SourceDataBase {
|
|
6
|
+
protected onMessages: OnMessagesStoreCallback;
|
|
7
|
+
protected config: RealTimeResourceSourceMechanismConfig;
|
|
8
|
+
/**
|
|
9
|
+
* Store the shared source configuration and downstream message callback.
|
|
10
|
+
*/
|
|
11
|
+
constructor(config: RealTimeResourceSourceMechanismConfig, onMessages: OnMessagesStoreCallback);
|
|
12
|
+
abstract start(): void;
|
|
13
|
+
abstract stop(): void;
|
|
14
|
+
}
|
|
15
|
+
export default SourceDataBase;
|
|
16
|
+
//# sourceMappingURL=SourceDataBase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SourceDataBase.d.ts","sourceRoot":"","sources":["../../../../../packages/realtime-runtime/src/transport/SourceDataBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,qCAAqC,EAAE,MAAM,cAAc,CAAC;AAC9F;;GAEG;AACH,8BAAsB,cAAc;IAClC,SAAS,CAAC,UAAU,EAAE,uBAAuB,CAAC;IAC9C,SAAS,CAAC,MAAM,EAAE,qCAAqC,CAAC;IACxD;;OAEG;gBACS,MAAM,EAAE,qCAAqC,EAAE,UAAU,EAAE,uBAAuB;IAI9F,QAAQ,CAAC,KAAK,IAAI,IAAI;IACtB,QAAQ,CAAC,IAAI,IAAI,IAAI;CACtB;AACD,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { RealTimeResourceSourceMechanismConfigAtmosphere } from '../../contracts';
|
|
2
|
+
import { SourceDataBase } from '../SourceDataBase';
|
|
3
|
+
/**
|
|
4
|
+
* Normalize the Atmosphere request base URL so websocket upgrades and HTTP fallback transports share one safe origin.
|
|
5
|
+
*/
|
|
6
|
+
declare function resolveAtmosphereRequestUrl(config: RealTimeResourceSourceMechanismConfigAtmosphere): string;
|
|
7
|
+
/**
|
|
8
|
+
* Atmosphere-backed realtime source implementation used by the generic engine.
|
|
9
|
+
*/
|
|
10
|
+
export declare class SourceDataAtmosphere extends SourceDataBase {
|
|
11
|
+
private subSocket;
|
|
12
|
+
private stopped;
|
|
13
|
+
private reconnectTimeout;
|
|
14
|
+
private lastMessageTime;
|
|
15
|
+
/**
|
|
16
|
+
* Start the realtime transport connection.
|
|
17
|
+
*/
|
|
18
|
+
start(): void;
|
|
19
|
+
/**
|
|
20
|
+
* Send the subscribe payload expected by the Atmosphere backend.
|
|
21
|
+
*/
|
|
22
|
+
private sendSubscribe;
|
|
23
|
+
/**
|
|
24
|
+
* Connect to the realtime backend transport.
|
|
25
|
+
*/
|
|
26
|
+
private connect;
|
|
27
|
+
/**
|
|
28
|
+
* Schedule the next reconnect attempt unless the source has already stopped.
|
|
29
|
+
*/
|
|
30
|
+
private tryReconnect;
|
|
31
|
+
/**
|
|
32
|
+
* Stop the transport and cancel any pending reconnect attempt.
|
|
33
|
+
*/
|
|
34
|
+
stop(): void;
|
|
35
|
+
}
|
|
36
|
+
export default SourceDataAtmosphere;
|
|
37
|
+
export { resolveAtmosphereRequestUrl, };
|
|
38
|
+
//# sourceMappingURL=SourceDataAtmosphere.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SourceDataAtmosphere.d.ts","sourceRoot":"","sources":["../../../../../../packages/realtime-runtime/src/transport/atmosphere/SourceDataAtmosphere.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+CAA+C,EAAE,MAAM,iBAAiB,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAKnD;;GAEG;AACH,iBAAS,2BAA2B,CAClC,MAAM,EAAE,+CAA+C,UA0BxD;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,cAAc;IAEtD,OAAO,CAAC,SAAS,CAAmC;IACpD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,gBAAgB,CAAyD;IAEjF,OAAO,CAAC,eAAe,CAAqB;IAG5C;;OAEG;IACH,KAAK,IAAI,IAAI;IAKb;;OAEG;IACH,OAAO,CAAC,aAAa;IA+BrB;;OAEG;IACH,OAAO,CAAC,OAAO;IAwHf;;OAEG;IACH,OAAO,CAAC,YAAY;IAOpB;;OAEG;IACH,IAAI,IAAI,IAAI;CAeb;AAED,eAAe,oBAAoB,CAAC;AACpC,OAAO,EACL,2BAA2B,GAC5B,CAAC"}
|