@pacem/pacem-networking 1.0.0-bessel → 1.0.0-dirac
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/browser/pacem-networking.js +22 -1
- package/dist/browser/pacem-networking.js.map +1 -1
- package/dist/browser/pacem-networking.min.js +1 -1
- package/dist/bundle/pacem-networking.min.mjs +1 -1
- package/dist/bundle/pacem-networking.mjs +18 -1
- package/dist/bundle/pacem-networking.mjs.map +2 -2
- package/dist/docs/pacem-networking.json +1798 -0
- package/dist/esm/hub-proxy.js +18 -1
- package/dist/esm/index-components-networking.js +1 -1
- package/dist/esm/index-components.js +1 -1
- package/dist/esm/index-iife.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/sse-proxy.js +5 -1
- package/package.json +2 -1
- package/typings/index.d.ts +27 -0
package/dist/esm/hub-proxy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-networking v1.0.0-
|
|
2
|
+
* @pacem/pacem-networking v1.0.0-dirac (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
@@ -13,6 +13,7 @@ import { P, CustomElement, Watch, PropertyConverters, Utils, PropertyChangeEvent
|
|
|
13
13
|
//namespace Pacem.Components.Networking {
|
|
14
14
|
const API_JS = 'https://cdn.jsdelivr.net/npm/@microsoft/signalr@10.0.0/dist/browser/signalr.min.js'; // 'https://cdnjs.cloudflare.com/ajax/libs/microsoft-signalr/10.0.0/signalr.min.js'
|
|
15
15
|
const consts = { API_JS };
|
|
16
|
+
/** Subscribes to a hub method (or stream) exposed by the ancestor {@link PacemHubProxyElement}, dispatching a `receive` event for every incoming message. */
|
|
16
17
|
let PacemHubListenerElement = class PacemHubListenerElement extends Components.PacemItemElement {
|
|
17
18
|
constructor() {
|
|
18
19
|
super(...arguments);
|
|
@@ -141,28 +142,44 @@ PacemHubListenerElement = __decorate([
|
|
|
141
142
|
CustomElement({ tagName: P + '-hub-listener' })
|
|
142
143
|
], PacemHubListenerElement);
|
|
143
144
|
export { PacemHubListenerElement };
|
|
145
|
+
/** Wraps a SignalR hub connection, dispatching its connection state and exposing `invoke`/`send` to registered {@link PacemHubListenerElement} children. */
|
|
144
146
|
let PacemHubProxyElement = class PacemHubProxyElement extends Components.PacemItemsContainerElement {
|
|
147
|
+
/** @inheritdoc */
|
|
145
148
|
validate(item) {
|
|
146
149
|
return item instanceof PacemHubListenerElement;
|
|
147
150
|
}
|
|
151
|
+
/** @readonly Gets the underlying `signalR.HubConnection` instance, if connected. */
|
|
148
152
|
get connection() {
|
|
149
153
|
return this._hub;
|
|
150
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Invokes a hub method and waits for a result from the server.
|
|
157
|
+
* @param method Name of the hub method to invoke
|
|
158
|
+
* @param args Arguments to pass to the hub method
|
|
159
|
+
* @returns A promise that resolves with the server response
|
|
160
|
+
*/
|
|
151
161
|
invoke(method, ...args) {
|
|
152
162
|
if (this.connected) {
|
|
153
163
|
return this._hub.invoke.apply(this._hub, arguments);
|
|
154
164
|
}
|
|
155
165
|
throw 'Hub is not connected. Cannot call `invoke` method.';
|
|
156
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* Invokes a hub method without waiting for a result from the server.
|
|
169
|
+
* @param method Name of the hub method to invoke
|
|
170
|
+
* @param args Arguments to pass to the hub method
|
|
171
|
+
*/
|
|
157
172
|
send(method, ...args) {
|
|
158
173
|
if (this.connected) {
|
|
159
174
|
return this._hub.send(method, ...args);
|
|
160
175
|
}
|
|
161
176
|
throw 'Hub is not connected. Cannot call `send` method.';
|
|
162
177
|
}
|
|
178
|
+
/** (Re)establishes the hub connection. */
|
|
163
179
|
start() {
|
|
164
180
|
return this._resetProxy();
|
|
165
181
|
}
|
|
182
|
+
/** Closes the hub connection, if connected. */
|
|
166
183
|
async stop() {
|
|
167
184
|
if (this.connected) {
|
|
168
185
|
await this._hub.stop();
|
package/dist/esm/index-iife.js
CHANGED
package/dist/esm/index.js
CHANGED
package/dist/esm/sse-proxy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-networking v1.0.0-
|
|
2
|
+
* @pacem/pacem-networking v1.0.0-dirac (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
@@ -11,6 +11,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
11
11
|
};
|
|
12
12
|
import { P, CustomElement, Watch, PropertyConverters, Utils, PropertyChangeEventName, Debounce, Components } from '@pacem/pacem-core';
|
|
13
13
|
//namespace Pacem.Components.Networking {
|
|
14
|
+
/** Subscribes to a named event exposed by the ancestor {@link PacemServerSentEventsProxyElement}'s `EventSource`, dispatching a `receive` event for every incoming message. */
|
|
14
15
|
let PacemServerSentEventsListenerElement = class PacemServerSentEventsListenerElement extends Components.PacemItemElement {
|
|
15
16
|
constructor() {
|
|
16
17
|
super(...arguments);
|
|
@@ -99,6 +100,7 @@ PacemServerSentEventsListenerElement = __decorate([
|
|
|
99
100
|
CustomElement({ tagName: P + '-sse-listener' })
|
|
100
101
|
], PacemServerSentEventsListenerElement);
|
|
101
102
|
export { PacemServerSentEventsListenerElement };
|
|
103
|
+
/** Wraps a browser `EventSource`, opening a Server-Sent Events connection and dispatching its connection state to registered {@link PacemServerSentEventsListenerElement} children. */
|
|
102
104
|
let PacemServerSentEventsProxyElement = class PacemServerSentEventsProxyElement extends Components.PacemItemsContainerElement {
|
|
103
105
|
constructor() {
|
|
104
106
|
super(...arguments);
|
|
@@ -113,6 +115,7 @@ let PacemServerSentEventsProxyElement = class PacemServerSentEventsProxyElement
|
|
|
113
115
|
this.dispatchEvent(new CustomEvent('receive', { detail: e.data }));
|
|
114
116
|
};
|
|
115
117
|
}
|
|
118
|
+
/** @inheritdoc */
|
|
116
119
|
validate(item) {
|
|
117
120
|
return item instanceof PacemServerSentEventsListenerElement;
|
|
118
121
|
}
|
|
@@ -146,6 +149,7 @@ let PacemServerSentEventsProxyElement = class PacemServerSentEventsProxyElement
|
|
|
146
149
|
evtSource.onerror = this._errorHandler;
|
|
147
150
|
}
|
|
148
151
|
}
|
|
152
|
+
/** @readonly Gets the underlying `EventSource` instance, if connected. */
|
|
149
153
|
get eventSource() {
|
|
150
154
|
return this.#evtSource;
|
|
151
155
|
}
|
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
"dist/browser/*.*",
|
|
5
5
|
"dist/bundle/*.*",
|
|
6
6
|
"dist/esm/*.*",
|
|
7
|
+
"dist/docs/*.*",
|
|
7
8
|
"typings/*.*",
|
|
8
9
|
"README.md",
|
|
9
10
|
"LICENSE",
|
|
@@ -24,7 +25,7 @@
|
|
|
24
25
|
"types": "./typings/index.d.ts"
|
|
25
26
|
}
|
|
26
27
|
},
|
|
27
|
-
"version": "1.0.0-
|
|
28
|
+
"version": "1.0.0-dirac",
|
|
28
29
|
"author": {
|
|
29
30
|
"name": "Pacem",
|
|
30
31
|
"url": "https://pacem.it"
|
package/typings/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare namespace Components {
|
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
/** Signature of a callback invoked when a hub method emits a value. */
|
|
10
11
|
declare type HubMethodCallback = (...args: any[]) => void;
|
|
11
12
|
|
|
12
13
|
export declare namespace Networking {
|
|
@@ -19,6 +20,7 @@ export declare namespace Networking {
|
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
|
|
23
|
+
/** Subscribes to a hub method (or stream) exposed by the ancestor {@link PacemHubProxyElement}, dispatching a `receive` event for every incoming message. */
|
|
22
24
|
declare class PacemHubListenerElement extends Components_2.PacemItemElement {
|
|
23
25
|
#private;
|
|
24
26
|
/** The method that the listener should subscribe to. */
|
|
@@ -44,16 +46,35 @@ declare class PacemHubListenerElement extends Components_2.PacemItemElement {
|
|
|
44
46
|
propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
|
|
45
47
|
}
|
|
46
48
|
|
|
49
|
+
/** Wraps a SignalR hub connection, dispatching its connection state and exposing `invoke`/`send` to registered {@link PacemHubListenerElement} children. */
|
|
47
50
|
declare class PacemHubProxyElement extends Components_2.PacemItemsContainerElement<PacemHubListenerElement> {
|
|
51
|
+
/** @inheritdoc */
|
|
48
52
|
validate(item: PacemHubListenerElement): boolean;
|
|
53
|
+
/** Gets or sets the url of the SignalR hub to connect to. */
|
|
49
54
|
url: string;
|
|
55
|
+
/** Gets or sets the access token used to authenticate against the hub. */
|
|
50
56
|
accesstoken: string;
|
|
57
|
+
/** @readonly Gets whether the hub connection is currently established. */
|
|
51
58
|
connected: boolean;
|
|
52
59
|
private _hub;
|
|
60
|
+
/** @readonly Gets the underlying `signalR.HubConnection` instance, if connected. */
|
|
53
61
|
get connection(): HubConnection;
|
|
62
|
+
/**
|
|
63
|
+
* Invokes a hub method and waits for a result from the server.
|
|
64
|
+
* @param method Name of the hub method to invoke
|
|
65
|
+
* @param args Arguments to pass to the hub method
|
|
66
|
+
* @returns A promise that resolves with the server response
|
|
67
|
+
*/
|
|
54
68
|
invoke(method: string, ...args: any[]): PromiseLike<any>;
|
|
69
|
+
/**
|
|
70
|
+
* Invokes a hub method without waiting for a result from the server.
|
|
71
|
+
* @param method Name of the hub method to invoke
|
|
72
|
+
* @param args Arguments to pass to the hub method
|
|
73
|
+
*/
|
|
55
74
|
send(method: string, ...args: any[]): PromiseLike<void>;
|
|
75
|
+
/** (Re)establishes the hub connection. */
|
|
56
76
|
start(): Promise<void>;
|
|
77
|
+
/** Closes the hub connection, if connected. */
|
|
57
78
|
stop(): Promise<void>;
|
|
58
79
|
propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
|
|
59
80
|
viewActivatedCallback(): void;
|
|
@@ -63,6 +84,7 @@ declare class PacemHubProxyElement extends Components_2.PacemItemsContainerEleme
|
|
|
63
84
|
private _setupProxy;
|
|
64
85
|
}
|
|
65
86
|
|
|
87
|
+
/** Subscribes to a named event exposed by the ancestor {@link PacemServerSentEventsProxyElement}'s `EventSource`, dispatching a `receive` event for every incoming message. */
|
|
66
88
|
declare class PacemServerSentEventsListenerElement extends Components_2.PacemItemElement {
|
|
67
89
|
/** The method that the listener should subscribe to. */
|
|
68
90
|
method: string;
|
|
@@ -81,16 +103,21 @@ declare class PacemServerSentEventsListenerElement extends Components_2.PacemIte
|
|
|
81
103
|
propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
|
|
82
104
|
}
|
|
83
105
|
|
|
106
|
+
/** Wraps a browser `EventSource`, opening a Server-Sent Events connection and dispatching its connection state to registered {@link PacemServerSentEventsListenerElement} children. */
|
|
84
107
|
declare class PacemServerSentEventsProxyElement extends Components_2.PacemItemsContainerElement<PacemServerSentEventsListenerElement> {
|
|
85
108
|
#private;
|
|
109
|
+
/** @inheritdoc */
|
|
86
110
|
validate(item: PacemServerSentEventsListenerElement): boolean;
|
|
111
|
+
/** Gets or sets the url of the Server-Sent Events endpoint to connect to. */
|
|
87
112
|
url: string;
|
|
113
|
+
/** @readonly Gets whether the event source connection is currently active. */
|
|
88
114
|
connected: boolean;
|
|
89
115
|
viewActivatedCallback(): void;
|
|
90
116
|
disconnectedCallback(): void;
|
|
91
117
|
propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
|
|
92
118
|
private _restart;
|
|
93
119
|
private _start;
|
|
120
|
+
/** @readonly Gets the underlying `EventSource` instance, if connected. */
|
|
94
121
|
get eventSource(): EventSource;
|
|
95
122
|
private _connectHandler;
|
|
96
123
|
private _errorHandler;
|