@pacem/pacem-networking 1.0.0-abel

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pacem-networking.js","sources":["../esm/hub-proxy.js","../esm/sse-proxy.js","../esm/index-iife.js"],"sourcesContent":["var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nimport { P, CustomElement, Watch, PropertyConverters, Utils, PropertyChangeEventName, CustomElementUtils, Components } from '@pacem/pacem-core';\n//namespace Pacem.Components.Networking {\nconst 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'\nconst consts = { API_JS };\nlet PacemHubListenerElement = class PacemHubListenerElement extends Components.PacemItemElement {\n constructor() {\n super(...arguments);\n this._receiveHandler = (...args) => {\n this.dispatchEvent(new CustomEvent('receive', { detail: Array.from(args) }));\n };\n this._completeHandler = () => {\n this.dispatchEvent(new Event('complete'));\n };\n this._errorHandler = (error) => {\n this.dispatchEvent(new CustomEvent('error', { detail: error }));\n };\n this._connectedHandler = (e) => {\n if (e.detail.propertyName === 'connected' && e.detail.currentValue === true) {\n this._start();\n }\n };\n }\n #streamSubscription;\n get _isConnected() {\n return this.container instanceof PacemHubProxyElement && this.container.connected || false;\n }\n get _connection() {\n return this.container instanceof PacemHubProxyElement && this.container.connection || null;\n }\n /** Start listening, if not disabled. */\n start() {\n if (!this.disabled) {\n this._start();\n }\n }\n /** Stop listening. */\n stop() {\n this._stop();\n }\n _stop(method = this.method, isStreaming = this.stream) {\n if (!this._isConnected) {\n return;\n }\n const conn = this._connection;\n if (!Utils.isNullOrEmpty(method)) {\n if (!isStreaming) {\n conn.off(method, this._receiveHandler);\n }\n else {\n this.#streamSubscription?.dispose();\n }\n }\n }\n _start(method = this.method, isStreaming = this.stream) {\n if (!this._isConnected) {\n return;\n }\n const conn = this._connection;\n if (!Utils.isNullOrEmpty(method)) {\n if (!isStreaming) {\n conn.on(method, this._receiveHandler);\n }\n else {\n const args = this.arguments || [];\n const streamResult = signalR.HubConnection.prototype.stream.apply(conn, [method].concat(args));\n this.#streamSubscription = streamResult.subscribe({\n next: this._receiveHandler,\n complete: this._completeHandler,\n error: this._errorHandler\n });\n }\n }\n }\n viewActivatedCallback() {\n super.viewActivatedCallback();\n const container = this.container;\n if (!Utils.isNull(container)) {\n container.addEventListener(PropertyChangeEventName, this._connectedHandler, false);\n }\n this.start();\n }\n disconnectedCallback() {\n const container = this.container;\n if (!Utils.isNull(container)) {\n container.removeEventListener(PropertyChangeEventName, this._connectedHandler, false);\n }\n super.disconnectedCallback();\n }\n propertyChangedCallback(name, old, val, first) {\n super.propertyChangedCallback(name, old, val, first);\n switch (name) {\n case 'arguments':\n this._stop();\n this._start();\n break;\n case 'method':\n if (!Utils.isNullOrEmpty(old)) {\n this._stop(old, this.stream);\n }\n if (!Utils.isNullOrEmpty(val)) {\n this._start(val, this.stream);\n }\n break;\n case 'stream':\n const m = this.method;\n if (!Utils.isNullOrEmpty(m)) {\n this._stop(m, old);\n this._start(m, val);\n }\n break;\n case 'disabled':\n if (!Utils.isNullOrEmpty(this.method)) {\n let toggle = val ? this._stop : this._start;\n toggle();\n }\n break;\n }\n }\n};\n__decorate([\n Watch({ emit: false, converter: PropertyConverters.String })\n], PacemHubListenerElement.prototype, \"method\", void 0);\n__decorate([\n Watch({ emit: false, converter: PropertyConverters.Boolean })\n], PacemHubListenerElement.prototype, \"stream\", void 0);\n__decorate([\n Watch({ emit: false, converter: PropertyConverters.Json })\n], PacemHubListenerElement.prototype, \"arguments\", void 0);\nPacemHubListenerElement = __decorate([\n CustomElement({ tagName: P + '-hub-listener' })\n], PacemHubListenerElement);\nexport { PacemHubListenerElement };\nlet PacemHubProxyElement = class PacemHubProxyElement extends Components.PacemItemsContainerElement {\n validate(item) {\n return item instanceof PacemHubListenerElement;\n }\n get connection() {\n return this._hub;\n }\n invoke(method, ...args) {\n if (this.connected) {\n return this._hub.invoke.apply(this._hub, arguments);\n }\n throw 'Hub is not connected. Cannot call `invoke` method.';\n }\n send(method, ...args) {\n if (this.connected) {\n return this._hub.send(method, ...args);\n }\n throw 'Hub is not connected. Cannot call `send` method.';\n }\n start() {\n return this._resetProxy();\n }\n async stop() {\n if (this.connected) {\n await this._hub.stop();\n }\n }\n propertyChangedCallback(name, old, val, first) {\n super.propertyChangedCallback(name, old, val, first);\n //\n if (first) {\n return;\n }\n if (name === 'url' || name === 'disabled' || name === 'accesstoken') {\n this._resetProxy();\n }\n }\n viewActivatedCallback() {\n super.viewActivatedCallback();\n this.start();\n }\n disconnectedCallback() {\n // this will (likely) never complete, being an asynchrounous call...\n // TODO: think about it.\n this.stop();\n super.disconnectedCallback();\n }\n async _resetProxy() {\n if (!Utils.isNull(this._hub)) {\n await this._hub.stop();\n //this.connected = false;\n }\n this._setupProxy();\n }\n async _initialize() {\n if ('signalR' in window) {\n // already available, skip import\n return;\n }\n await CustomElementUtils.importjs(consts.API_JS);\n }\n async _setupProxy() {\n const listeners = this.items || [];\n if (!this.disabled && !Utils.isNullOrEmpty(this.url)) {\n await this._initialize();\n const connBuilder = new signalR.HubConnectionBuilder();\n connBuilder.withUrl(this.url, {\n accessTokenFactory: () => this.accesstoken\n });\n const h = this._hub = connBuilder.build();\n h.onclose(() => {\n for (var item of listeners) {\n item.stop();\n }\n this.connected = false;\n this._hub = null;\n });\n await h.start();\n this.connected = true;\n }\n }\n};\n__decorate([\n Watch({ emit: false, converter: PropertyConverters.String })\n], PacemHubProxyElement.prototype, \"url\", void 0);\n__decorate([\n Watch({ emit: false, converter: PropertyConverters.String })\n], PacemHubProxyElement.prototype, \"accesstoken\", void 0);\n__decorate([\n Watch({ converter: PropertyConverters.Boolean })\n], PacemHubProxyElement.prototype, \"connected\", void 0);\nPacemHubProxyElement = __decorate([\n CustomElement({ tagName: P + '-hub-proxy' })\n], PacemHubProxyElement);\nexport { PacemHubProxyElement };\n","var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nimport { P, CustomElement, Watch, PropertyConverters, Utils, PropertyChangeEventName, Debounce, Components } from '@pacem/pacem-core';\n//namespace Pacem.Components.Networking {\nlet PacemServerSentEventsListenerElement = class PacemServerSentEventsListenerElement extends Components.PacemItemElement {\n constructor() {\n super(...arguments);\n this._receiveHandler = (e) => {\n this.dispatchEvent(new CustomEvent('receive', { detail: e.data }));\n };\n this._connectedHandler = (e) => {\n if (e.detail.propertyName === 'connected' && e.detail.currentValue === true) {\n this._start();\n }\n };\n }\n get _isConnected() {\n return this.container instanceof PacemServerSentEventsProxyElement && this.container.connected || false;\n }\n get _connection() {\n return this.container instanceof PacemServerSentEventsProxyElement && this.container.eventSource || null;\n }\n _stop(method = this.method) {\n if (!this._isConnected) {\n return;\n }\n const conn = this._connection;\n if (!Utils.isNullOrEmpty(method)) {\n conn.removeEventListener(method, this._receiveHandler);\n }\n }\n _start(method = this.method) {\n if (!this._isConnected) {\n return;\n }\n const conn = this._connection;\n if (!Utils.isNullOrEmpty(method)) {\n conn.addEventListener(method, this._receiveHandler);\n }\n }\n /** Start listening, if not disabled. */\n start() {\n if (!this.disabled) {\n this._start();\n }\n }\n /** Stop listening. */\n stop() {\n this._stop();\n }\n viewActivatedCallback() {\n super.viewActivatedCallback();\n const container = this.container;\n if (!Utils.isNull(container)) {\n container.addEventListener(PropertyChangeEventName, this._connectedHandler, false);\n }\n this.start();\n }\n disconnectedCallback() {\n const container = this.container;\n if (!Utils.isNull(container)) {\n container.removeEventListener(PropertyChangeEventName, this._connectedHandler, false);\n }\n super.disconnectedCallback();\n }\n propertyChangedCallback(name, old, val, first) {\n super.propertyChangedCallback(name, old, val, first);\n switch (name) {\n case 'method':\n if (!Utils.isNullOrEmpty(old)) {\n this._stop(old);\n }\n if (!Utils.isNullOrEmpty(val)) {\n this._start(val);\n }\n break;\n case 'disabled':\n if (!Utils.isNullOrEmpty(this.method)) {\n let toggle = val ? this._stop : this._start;\n toggle();\n }\n break;\n }\n }\n};\n__decorate([\n Watch({ emit: false, converter: PropertyConverters.String })\n], PacemServerSentEventsListenerElement.prototype, \"method\", void 0);\nPacemServerSentEventsListenerElement = __decorate([\n CustomElement({ tagName: P + '-sse-listener' })\n], PacemServerSentEventsListenerElement);\nexport { PacemServerSentEventsListenerElement };\nlet PacemServerSentEventsProxyElement = class PacemServerSentEventsProxyElement extends Components.PacemItemsContainerElement {\n constructor() {\n super(...arguments);\n this._connectHandler = (_) => {\n this.connected = true;\n this.#evtSource.onmessage = this._receiveHandler;\n };\n this._errorHandler = (_) => {\n this.connected = false;\n };\n this._receiveHandler = (e) => {\n this.dispatchEvent(new CustomEvent('receive', { detail: e.data }));\n };\n }\n validate(item) {\n return item instanceof PacemServerSentEventsListenerElement;\n }\n viewActivatedCallback() {\n super.viewActivatedCallback();\n this._start();\n }\n disconnectedCallback() {\n this._stop();\n super.disconnectedCallback();\n }\n propertyChangedCallback(name, old, val, first) {\n super.propertyChangedCallback(name, old, val, first);\n //\n if (first) {\n return;\n }\n if (name === 'url' || name === 'disabled') {\n this._restart();\n }\n }\n #evtSource;\n _restart() {\n this._stop();\n this._start();\n }\n _start(url = this.url) {\n if (!Utils.isNullOrEmpty(url) && !this.disabled) {\n const evtSource = this.#evtSource = new EventSource(url);\n evtSource.onopen = this._connectHandler;\n evtSource.onerror = this._errorHandler;\n }\n }\n get eventSource() {\n return this.#evtSource;\n }\n _stop() {\n const listeners = this.items || [];\n for (var item of listeners) {\n item.stop();\n }\n const evtSource = this.#evtSource;\n if (!Utils.isNull(evtSource)) {\n evtSource.onopen = null;\n evtSource.onerror = null;\n evtSource.onmessage = null;\n evtSource.close();\n }\n this.connected = false;\n this.#evtSource = null;\n }\n};\n__decorate([\n Watch({ emit: false, converter: PropertyConverters.String })\n], PacemServerSentEventsProxyElement.prototype, \"url\", void 0);\n__decorate([\n Watch({ converter: PropertyConverters.Boolean })\n], PacemServerSentEventsProxyElement.prototype, \"connected\", void 0);\n__decorate([\n Debounce(true)\n], PacemServerSentEventsProxyElement.prototype, \"_restart\", null);\nPacemServerSentEventsProxyElement = __decorate([\n CustomElement({ tagName: P + '-sse-proxy' })\n], PacemServerSentEventsProxyElement);\nexport { PacemServerSentEventsProxyElement };\n","import { DeepMerger } from '@pacem/pacem-foundation';\nimport * as Output from './index';\nDeepMerger.merge(Output);\n"],"names":["__decorate","this","Components","Utils","PropertyChangeEventName","Watch","PropertyConverters","CustomElement","P","CustomElementUtils","Debounce","DeepMerger"],"mappings":";;;IAAA,IAAIA,YAAU,GAAG,CAACC,SAAI,IAAIA,SAAI,CAAC,UAAU,KAAK,UAAU,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE;IACvF,IAAI,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,IAAI,KAAK,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC;IAChI,IAAI,IAAI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AAE,IAAI,CAAC;IACjE,iCAAiC,GAAG,UAAU,CAAC;IAC/C,IAAIH,uBAAa,CAAC,EAAE,OAAO,EAAEC,WAAC,GAAG,YAAY,EAAE;IAC/C,CAAC,EAAE,iCAAiC,CAAC;;;;;;;;;;;;;;;;;;;;AC3KrCG,8BAAU,CAAC,KAAK,CAAC,MAAM,CAAC;;;;;;"}
@@ -0,0 +1,2 @@
1
+ !function(t,e){"use strict";var s=function(t,e,s,n){var r,i=arguments.length,o=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,s):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,s,n);else for(var c=t.length-1;c>=0;c--)(r=t[c])&&(o=(i<3?r(o):i>3?r(e,s,o):r(e,s))||o);return i>3&&o&&Object.defineProperty(e,s,o),o};const n="https://cdn.jsdelivr.net/npm/@microsoft/signalr@10.0.0/dist/browser/signalr.min.js";let r=class extends e.Components.PacemItemElement{constructor(){super(...arguments),this._receiveHandler=(...t)=>{this.dispatchEvent(new CustomEvent("receive",{detail:Array.from(t)}))},this._completeHandler=()=>{this.dispatchEvent(new Event("complete"))},this._errorHandler=t=>{this.dispatchEvent(new CustomEvent("error",{detail:t}))},this._connectedHandler=t=>{"connected"===t.detail.propertyName&&!0===t.detail.currentValue&&this._start()}}#t;get _isConnected(){return this.container instanceof i&&this.container.connected||!1}get _connection(){return this.container instanceof i&&this.container.connection||null}start(){this.disabled||this._start()}stop(){this._stop()}_stop(t=this.method,s=this.stream){if(!this._isConnected)return;const n=this._connection;e.Utils.isNullOrEmpty(t)||(s?this.#t?.dispose():n.off(t,this._receiveHandler))}_start(t=this.method,s=this.stream){if(!this._isConnected)return;const n=this._connection;if(!e.Utils.isNullOrEmpty(t))if(s){const e=this.arguments||[],s=signalR.HubConnection.prototype.stream.apply(n,[t].concat(e));this.#t=s.subscribe({next:this._receiveHandler,complete:this._completeHandler,error:this._errorHandler})}else n.on(t,this._receiveHandler)}viewActivatedCallback(){super.viewActivatedCallback();const t=this.container;e.Utils.isNull(t)||t.addEventListener(e.PropertyChangeEventName,this._connectedHandler,!1),this.start()}disconnectedCallback(){const t=this.container;e.Utils.isNull(t)||t.removeEventListener(e.PropertyChangeEventName,this._connectedHandler,!1),super.disconnectedCallback()}propertyChangedCallback(t,s,n,r){switch(super.propertyChangedCallback(t,s,n,r),t){case"arguments":this._stop(),this._start();break;case"method":e.Utils.isNullOrEmpty(s)||this._stop(s,this.stream),e.Utils.isNullOrEmpty(n)||this._start(n,this.stream);break;case"stream":const t=this.method;e.Utils.isNullOrEmpty(t)||(this._stop(t,s),this._start(t,n));break;case"disabled":if(!e.Utils.isNullOrEmpty(this.method)){(n?this._stop:this._start)()}}}};s([e.Watch({emit:!1,converter:e.PropertyConverters.String})],r.prototype,"method",void 0),s([e.Watch({emit:!1,converter:e.PropertyConverters.Boolean})],r.prototype,"stream",void 0),s([e.Watch({emit:!1,converter:e.PropertyConverters.Json})],r.prototype,"arguments",void 0),r=s([e.CustomElement({tagName:e.P+"-hub-listener"})],r);let i=class extends e.Components.PacemItemsContainerElement{validate(t){return t instanceof r}get connection(){return this._hub}invoke(t,...e){if(this.connected)return this._hub.invoke.apply(this._hub,arguments);throw"Hub is not connected. Cannot call `invoke` method."}send(t,...e){if(this.connected)return this._hub.send(t,...e);throw"Hub is not connected. Cannot call `send` method."}start(){return this._resetProxy()}async stop(){this.connected&&await this._hub.stop()}propertyChangedCallback(t,e,s,n){super.propertyChangedCallback(t,e,s,n),n||"url"!==t&&"disabled"!==t&&"accesstoken"!==t||this._resetProxy()}viewActivatedCallback(){super.viewActivatedCallback(),this.start()}disconnectedCallback(){this.stop(),super.disconnectedCallback()}async _resetProxy(){e.Utils.isNull(this._hub)||await this._hub.stop(),this._setupProxy()}async _initialize(){"signalR"in window||await e.CustomElementUtils.importjs(n)}async _setupProxy(){const t=this.items||[];if(!this.disabled&&!e.Utils.isNullOrEmpty(this.url)){await this._initialize();const e=new signalR.HubConnectionBuilder;e.withUrl(this.url,{accessTokenFactory:()=>this.accesstoken});const s=this._hub=e.build();s.onclose(()=>{for(var e of t)e.stop();this.connected=!1,this._hub=null}),await s.start(),this.connected=!0}}};s([e.Watch({emit:!1,converter:e.PropertyConverters.String})],i.prototype,"url",void 0),s([e.Watch({emit:!1,converter:e.PropertyConverters.String})],i.prototype,"accesstoken",void 0),s([e.Watch({converter:e.PropertyConverters.Boolean})],i.prototype,"connected",void 0),i=s([e.CustomElement({tagName:e.P+"-hub-proxy"})],i);var o=function(t,e,s,n){var r,i=arguments.length,o=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,s):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,s,n);else for(var c=t.length-1;c>=0;c--)(r=t[c])&&(o=(i<3?r(o):i>3?r(e,s,o):r(e,s))||o);return i>3&&o&&Object.defineProperty(e,s,o),o};let c=class extends e.Components.PacemItemElement{constructor(){super(...arguments),this._receiveHandler=t=>{this.dispatchEvent(new CustomEvent("receive",{detail:t.data}))},this._connectedHandler=t=>{"connected"===t.detail.propertyName&&!0===t.detail.currentValue&&this._start()}}get _isConnected(){return this.container instanceof a&&this.container.connected||!1}get _connection(){return this.container instanceof a&&this.container.eventSource||null}_stop(t=this.method){if(!this._isConnected)return;const s=this._connection;e.Utils.isNullOrEmpty(t)||s.removeEventListener(t,this._receiveHandler)}_start(t=this.method){if(!this._isConnected)return;const s=this._connection;e.Utils.isNullOrEmpty(t)||s.addEventListener(t,this._receiveHandler)}start(){this.disabled||this._start()}stop(){this._stop()}viewActivatedCallback(){super.viewActivatedCallback();const t=this.container;e.Utils.isNull(t)||t.addEventListener(e.PropertyChangeEventName,this._connectedHandler,!1),this.start()}disconnectedCallback(){const t=this.container;e.Utils.isNull(t)||t.removeEventListener(e.PropertyChangeEventName,this._connectedHandler,!1),super.disconnectedCallback()}propertyChangedCallback(t,s,n,r){switch(super.propertyChangedCallback(t,s,n,r),t){case"method":e.Utils.isNullOrEmpty(s)||this._stop(s),e.Utils.isNullOrEmpty(n)||this._start(n);break;case"disabled":if(!e.Utils.isNullOrEmpty(this.method)){(n?this._stop:this._start)()}}}};o([e.Watch({emit:!1,converter:e.PropertyConverters.String})],c.prototype,"method",void 0),c=o([e.CustomElement({tagName:e.P+"-sse-listener"})],c);let a=class extends e.Components.PacemItemsContainerElement{constructor(){super(...arguments),this._connectHandler=t=>{this.connected=!0,this.#e.onmessage=this._receiveHandler},this._errorHandler=t=>{this.connected=!1},this._receiveHandler=t=>{this.dispatchEvent(new CustomEvent("receive",{detail:t.data}))}}validate(t){return t instanceof c}viewActivatedCallback(){super.viewActivatedCallback(),this._start()}disconnectedCallback(){this._stop(),super.disconnectedCallback()}propertyChangedCallback(t,e,s,n){super.propertyChangedCallback(t,e,s,n),n||"url"!==t&&"disabled"!==t||this._restart()}#e;_restart(){this._stop(),this._start()}_start(t=this.url){if(!e.Utils.isNullOrEmpty(t)&&!this.disabled){const e=this.#e=new EventSource(t);e.onopen=this._connectHandler,e.onerror=this._errorHandler}}get eventSource(){return this.#e}_stop(){const t=this.items||[];for(var s of t)s.stop();const n=this.#e;e.Utils.isNull(n)||(n.onopen=null,n.onerror=null,n.onmessage=null,n.close()),this.connected=!1,this.#e=null}};o([e.Watch({emit:!1,converter:e.PropertyConverters.String})],a.prototype,"url",void 0),o([e.Watch({converter:e.PropertyConverters.Boolean})],a.prototype,"connected",void 0),o([e.Debounce(!0)],a.prototype,"_restart",null),a=o([e.CustomElement({tagName:e.P+"-sse-proxy"})],a);var l=Object.freeze({__proto__:null,get PacemHubListenerElement(){return r},get PacemHubProxyElement(){return i},get PacemServerSentEventsListenerElement(){return c},get PacemServerSentEventsProxyElement(){return a}}),h=Object.freeze({__proto__:null,Networking:l}),d=Object.freeze({__proto__:null,Components:h});t.DeepMerger.merge(d)}(Pacem,Pacem);
2
+ //# sourceMappingURL=pacem-networking.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pacem-networking.min.js","sources":["../esm/hub-proxy.js","../esm/sse-proxy.js","../esm/index-iife.js"],"sourcesContent":["var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nimport { P, CustomElement, Watch, PropertyConverters, Utils, PropertyChangeEventName, CustomElementUtils, Components } from '@pacem/pacem-core';\n//namespace Pacem.Components.Networking {\nconst 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'\nconst consts = { API_JS };\nlet PacemHubListenerElement = class PacemHubListenerElement extends Components.PacemItemElement {\n constructor() {\n super(...arguments);\n this._receiveHandler = (...args) => {\n this.dispatchEvent(new CustomEvent('receive', { detail: Array.from(args) }));\n };\n this._completeHandler = () => {\n this.dispatchEvent(new Event('complete'));\n };\n this._errorHandler = (error) => {\n this.dispatchEvent(new CustomEvent('error', { detail: error }));\n };\n this._connectedHandler = (e) => {\n if (e.detail.propertyName === 'connected' && e.detail.currentValue === true) {\n this._start();\n }\n };\n }\n #streamSubscription;\n get _isConnected() {\n return this.container instanceof PacemHubProxyElement && this.container.connected || false;\n }\n get _connection() {\n return this.container instanceof PacemHubProxyElement && this.container.connection || null;\n }\n /** Start listening, if not disabled. */\n start() {\n if (!this.disabled) {\n this._start();\n }\n }\n /** Stop listening. */\n stop() {\n this._stop();\n }\n _stop(method = this.method, isStreaming = this.stream) {\n if (!this._isConnected) {\n return;\n }\n const conn = this._connection;\n if (!Utils.isNullOrEmpty(method)) {\n if (!isStreaming) {\n conn.off(method, this._receiveHandler);\n }\n else {\n this.#streamSubscription?.dispose();\n }\n }\n }\n _start(method = this.method, isStreaming = this.stream) {\n if (!this._isConnected) {\n return;\n }\n const conn = this._connection;\n if (!Utils.isNullOrEmpty(method)) {\n if (!isStreaming) {\n conn.on(method, this._receiveHandler);\n }\n else {\n const args = this.arguments || [];\n const streamResult = signalR.HubConnection.prototype.stream.apply(conn, [method].concat(args));\n this.#streamSubscription = streamResult.subscribe({\n next: this._receiveHandler,\n complete: this._completeHandler,\n error: this._errorHandler\n });\n }\n }\n }\n viewActivatedCallback() {\n super.viewActivatedCallback();\n const container = this.container;\n if (!Utils.isNull(container)) {\n container.addEventListener(PropertyChangeEventName, this._connectedHandler, false);\n }\n this.start();\n }\n disconnectedCallback() {\n const container = this.container;\n if (!Utils.isNull(container)) {\n container.removeEventListener(PropertyChangeEventName, this._connectedHandler, false);\n }\n super.disconnectedCallback();\n }\n propertyChangedCallback(name, old, val, first) {\n super.propertyChangedCallback(name, old, val, first);\n switch (name) {\n case 'arguments':\n this._stop();\n this._start();\n break;\n case 'method':\n if (!Utils.isNullOrEmpty(old)) {\n this._stop(old, this.stream);\n }\n if (!Utils.isNullOrEmpty(val)) {\n this._start(val, this.stream);\n }\n break;\n case 'stream':\n const m = this.method;\n if (!Utils.isNullOrEmpty(m)) {\n this._stop(m, old);\n this._start(m, val);\n }\n break;\n case 'disabled':\n if (!Utils.isNullOrEmpty(this.method)) {\n let toggle = val ? this._stop : this._start;\n toggle();\n }\n break;\n }\n }\n};\n__decorate([\n Watch({ emit: false, converter: PropertyConverters.String })\n], PacemHubListenerElement.prototype, \"method\", void 0);\n__decorate([\n Watch({ emit: false, converter: PropertyConverters.Boolean })\n], PacemHubListenerElement.prototype, \"stream\", void 0);\n__decorate([\n Watch({ emit: false, converter: PropertyConverters.Json })\n], PacemHubListenerElement.prototype, \"arguments\", void 0);\nPacemHubListenerElement = __decorate([\n CustomElement({ tagName: P + '-hub-listener' })\n], PacemHubListenerElement);\nexport { PacemHubListenerElement };\nlet PacemHubProxyElement = class PacemHubProxyElement extends Components.PacemItemsContainerElement {\n validate(item) {\n return item instanceof PacemHubListenerElement;\n }\n get connection() {\n return this._hub;\n }\n invoke(method, ...args) {\n if (this.connected) {\n return this._hub.invoke.apply(this._hub, arguments);\n }\n throw 'Hub is not connected. Cannot call `invoke` method.';\n }\n send(method, ...args) {\n if (this.connected) {\n return this._hub.send(method, ...args);\n }\n throw 'Hub is not connected. Cannot call `send` method.';\n }\n start() {\n return this._resetProxy();\n }\n async stop() {\n if (this.connected) {\n await this._hub.stop();\n }\n }\n propertyChangedCallback(name, old, val, first) {\n super.propertyChangedCallback(name, old, val, first);\n //\n if (first) {\n return;\n }\n if (name === 'url' || name === 'disabled' || name === 'accesstoken') {\n this._resetProxy();\n }\n }\n viewActivatedCallback() {\n super.viewActivatedCallback();\n this.start();\n }\n disconnectedCallback() {\n // this will (likely) never complete, being an asynchrounous call...\n // TODO: think about it.\n this.stop();\n super.disconnectedCallback();\n }\n async _resetProxy() {\n if (!Utils.isNull(this._hub)) {\n await this._hub.stop();\n //this.connected = false;\n }\n this._setupProxy();\n }\n async _initialize() {\n if ('signalR' in window) {\n // already available, skip import\n return;\n }\n await CustomElementUtils.importjs(consts.API_JS);\n }\n async _setupProxy() {\n const listeners = this.items || [];\n if (!this.disabled && !Utils.isNullOrEmpty(this.url)) {\n await this._initialize();\n const connBuilder = new signalR.HubConnectionBuilder();\n connBuilder.withUrl(this.url, {\n accessTokenFactory: () => this.accesstoken\n });\n const h = this._hub = connBuilder.build();\n h.onclose(() => {\n for (var item of listeners) {\n item.stop();\n }\n this.connected = false;\n this._hub = null;\n });\n await h.start();\n this.connected = true;\n }\n }\n};\n__decorate([\n Watch({ emit: false, converter: PropertyConverters.String })\n], PacemHubProxyElement.prototype, \"url\", void 0);\n__decorate([\n Watch({ emit: false, converter: PropertyConverters.String })\n], PacemHubProxyElement.prototype, \"accesstoken\", void 0);\n__decorate([\n Watch({ converter: PropertyConverters.Boolean })\n], PacemHubProxyElement.prototype, \"connected\", void 0);\nPacemHubProxyElement = __decorate([\n CustomElement({ tagName: P + '-hub-proxy' })\n], PacemHubProxyElement);\nexport { PacemHubProxyElement };\n","var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nimport { P, CustomElement, Watch, PropertyConverters, Utils, PropertyChangeEventName, Debounce, Components } from '@pacem/pacem-core';\n//namespace Pacem.Components.Networking {\nlet PacemServerSentEventsListenerElement = class PacemServerSentEventsListenerElement extends Components.PacemItemElement {\n constructor() {\n super(...arguments);\n this._receiveHandler = (e) => {\n this.dispatchEvent(new CustomEvent('receive', { detail: e.data }));\n };\n this._connectedHandler = (e) => {\n if (e.detail.propertyName === 'connected' && e.detail.currentValue === true) {\n this._start();\n }\n };\n }\n get _isConnected() {\n return this.container instanceof PacemServerSentEventsProxyElement && this.container.connected || false;\n }\n get _connection() {\n return this.container instanceof PacemServerSentEventsProxyElement && this.container.eventSource || null;\n }\n _stop(method = this.method) {\n if (!this._isConnected) {\n return;\n }\n const conn = this._connection;\n if (!Utils.isNullOrEmpty(method)) {\n conn.removeEventListener(method, this._receiveHandler);\n }\n }\n _start(method = this.method) {\n if (!this._isConnected) {\n return;\n }\n const conn = this._connection;\n if (!Utils.isNullOrEmpty(method)) {\n conn.addEventListener(method, this._receiveHandler);\n }\n }\n /** Start listening, if not disabled. */\n start() {\n if (!this.disabled) {\n this._start();\n }\n }\n /** Stop listening. */\n stop() {\n this._stop();\n }\n viewActivatedCallback() {\n super.viewActivatedCallback();\n const container = this.container;\n if (!Utils.isNull(container)) {\n container.addEventListener(PropertyChangeEventName, this._connectedHandler, false);\n }\n this.start();\n }\n disconnectedCallback() {\n const container = this.container;\n if (!Utils.isNull(container)) {\n container.removeEventListener(PropertyChangeEventName, this._connectedHandler, false);\n }\n super.disconnectedCallback();\n }\n propertyChangedCallback(name, old, val, first) {\n super.propertyChangedCallback(name, old, val, first);\n switch (name) {\n case 'method':\n if (!Utils.isNullOrEmpty(old)) {\n this._stop(old);\n }\n if (!Utils.isNullOrEmpty(val)) {\n this._start(val);\n }\n break;\n case 'disabled':\n if (!Utils.isNullOrEmpty(this.method)) {\n let toggle = val ? this._stop : this._start;\n toggle();\n }\n break;\n }\n }\n};\n__decorate([\n Watch({ emit: false, converter: PropertyConverters.String })\n], PacemServerSentEventsListenerElement.prototype, \"method\", void 0);\nPacemServerSentEventsListenerElement = __decorate([\n CustomElement({ tagName: P + '-sse-listener' })\n], PacemServerSentEventsListenerElement);\nexport { PacemServerSentEventsListenerElement };\nlet PacemServerSentEventsProxyElement = class PacemServerSentEventsProxyElement extends Components.PacemItemsContainerElement {\n constructor() {\n super(...arguments);\n this._connectHandler = (_) => {\n this.connected = true;\n this.#evtSource.onmessage = this._receiveHandler;\n };\n this._errorHandler = (_) => {\n this.connected = false;\n };\n this._receiveHandler = (e) => {\n this.dispatchEvent(new CustomEvent('receive', { detail: e.data }));\n };\n }\n validate(item) {\n return item instanceof PacemServerSentEventsListenerElement;\n }\n viewActivatedCallback() {\n super.viewActivatedCallback();\n this._start();\n }\n disconnectedCallback() {\n this._stop();\n super.disconnectedCallback();\n }\n propertyChangedCallback(name, old, val, first) {\n super.propertyChangedCallback(name, old, val, first);\n //\n if (first) {\n return;\n }\n if (name === 'url' || name === 'disabled') {\n this._restart();\n }\n }\n #evtSource;\n _restart() {\n this._stop();\n this._start();\n }\n _start(url = this.url) {\n if (!Utils.isNullOrEmpty(url) && !this.disabled) {\n const evtSource = this.#evtSource = new EventSource(url);\n evtSource.onopen = this._connectHandler;\n evtSource.onerror = this._errorHandler;\n }\n }\n get eventSource() {\n return this.#evtSource;\n }\n _stop() {\n const listeners = this.items || [];\n for (var item of listeners) {\n item.stop();\n }\n const evtSource = this.#evtSource;\n if (!Utils.isNull(evtSource)) {\n evtSource.onopen = null;\n evtSource.onerror = null;\n evtSource.onmessage = null;\n evtSource.close();\n }\n this.connected = false;\n this.#evtSource = null;\n }\n};\n__decorate([\n Watch({ emit: false, converter: PropertyConverters.String })\n], PacemServerSentEventsProxyElement.prototype, \"url\", void 0);\n__decorate([\n Watch({ converter: PropertyConverters.Boolean })\n], PacemServerSentEventsProxyElement.prototype, \"connected\", void 0);\n__decorate([\n Debounce(true)\n], PacemServerSentEventsProxyElement.prototype, \"_restart\", null);\nPacemServerSentEventsProxyElement = __decorate([\n CustomElement({ tagName: P + '-sse-proxy' })\n], PacemServerSentEventsProxyElement);\nexport { PacemServerSentEventsProxyElement };\n","import { DeepMerger } from '@pacem/pacem-foundation';\nimport * as Output from './index';\nDeepMerger.merge(Output);\n"],"names":["__decorate","decorators","target","key","desc","d","c","arguments","length","r","Object","getOwnPropertyDescriptor","Reflect","decorate","i","defineProperty","consts","PacemHubListenerElement","Components","PacemItemElement","constructor","super","this","_receiveHandler","args","dispatchEvent","CustomEvent","detail","Array","from","_completeHandler","Event","_errorHandler","error","_connectedHandler","e","propertyName","currentValue","_start","streamSubscription","_isConnected","container","PacemHubProxyElement","connected","_connection","connection","start","disabled","stop","_stop","method","isStreaming","stream","conn","Utils","isNullOrEmpty","dispose","off","streamResult","signalR","HubConnection","prototype","apply","concat","subscribe","next","complete","on","viewActivatedCallback","isNull","addEventListener","PropertyChangeEventName","disconnectedCallback","removeEventListener","propertyChangedCallback","name","old","val","first","m","Watch","emit","converter","PropertyConverters","String","Boolean","Json","CustomElement","tagName","P","PacemItemsContainerElement","validate","item","_hub","invoke","send","_resetProxy","_setupProxy","_initialize","window","CustomElementUtils","importjs","listeners","items","url","connBuilder","HubConnectionBuilder","withUrl","accessTokenFactory","accesstoken","h","build","onclose","PacemServerSentEventsListenerElement","data","PacemServerSentEventsProxyElement","eventSource","_connectHandler","_","evtSource","onmessage","_restart","EventSource","onopen","onerror","close","Debounce","DeepMerger","merge","Output"],"mappings":"4BAAA,IAAIA,EAA0C,SAAUC,EAAYC,EAAQC,EAAKC,GAC7E,IAA2HC,EAAvHC,EAAIC,UAAUC,OAAQC,EAAIH,EAAI,EAAIJ,EAAkB,OAATE,EAAgBA,EAAOM,OAAOC,yBAAyBT,EAAQC,GAAOC,EACrH,GAAuB,iBAAZQ,SAAoD,mBAArBA,QAAQC,SAAyBJ,EAAIG,QAAQC,SAASZ,EAAYC,EAAQC,EAAKC,QACpH,IAAK,IAAIU,EAAIb,EAAWO,OAAS,EAAGM,GAAK,EAAGA,KAAST,EAAIJ,EAAWa,MAAIL,GAAKH,EAAI,EAAID,EAAEI,GAAKH,EAAI,EAAID,EAAEH,EAAQC,EAAKM,GAAKJ,EAAEH,EAAQC,KAASM,GAChJ,OAAOH,EAAI,GAAKG,GAAKC,OAAOK,eAAeb,EAAQC,EAAKM,GAAIA,CAChE,EAGA,MACMO,EADS,qFAEf,IAAIC,EAA0B,cAAsCC,EAAAA,WAAWC,iBAC3E,WAAAC,GACIC,SAASd,WACTe,KAAKC,gBAAkB,IAAIC,KACvBF,KAAKG,cAAc,IAAIC,YAAY,UAAW,CAAEC,OAAQC,MAAMC,KAAKL,OAEvEF,KAAKQ,iBAAmB,KACpBR,KAAKG,cAAc,IAAIM,MAAM,cAEjCT,KAAKU,cAAiBC,IAClBX,KAAKG,cAAc,IAAIC,YAAY,QAAS,CAAEC,OAAQM,MAE1DX,KAAKY,kBAAqBC,IACQ,cAA1BA,EAAER,OAAOS,eAA0D,IAA1BD,EAAER,OAAOU,cAClDf,KAAKgB,SAGjB,CACAC,GACA,gBAAIC,GACA,OAAOlB,KAAKmB,qBAAqBC,GAAwBpB,KAAKmB,UAAUE,YAAa,CACzF,CACA,eAAIC,GACA,OAAOtB,KAAKmB,qBAAqBC,GAAwBpB,K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C,UACpD+B,EAAkCtD,UAAW,cAChD7D,EAAW,CACPgF,EAAAA,MAAM,CAAEE,UAAWC,EAAAA,mBAAmBE,WACvC8B,EAAkCtD,UAAW,oBAChD7D,EAAW,CACP8H,EAAAA,UAAS,IACVX,EAAkCtD,UAAW,WAAY,MAC5DsD,EAAoCnH,EAAW,CAC3CuF,EAAAA,cAAc,CAAEC,QAASC,EAAAA,EAAI,gBAC9B0B,2TC3KHY,EAAAA,WAAWC,MAAMC"}
@@ -0,0 +1 @@
1
+ var A=Object.defineProperty;var E=(i,e)=>{for(var t in e)A(i,t,{get:e[t],enumerable:!0})};var O={};E(O,{Networking:()=>y});var y={};E(y,{PacemHubListenerElement:()=>u,PacemHubProxyElement:()=>l,PacemServerSentEventsListenerElement:()=>v,PacemServerSentEventsProxyElement:()=>d});import{P,CustomElement as w,Watch as m,PropertyConverters as _,Utils as a,PropertyChangeEventName as g,CustomElementUtils as L,Components as H}from"@pacem/pacem-core";var h=function(i,e,t,n){var r=arguments.length,s=r<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(i,e,t,n);else for(var p=i.length-1;p>=0;p--)(o=i[p])&&(s=(r<3?o(s):r>3?o(e,t,s):o(e,t))||s);return r>3&&s&&Object.defineProperty(e,t,s),s},R="https://cdn.jsdelivr.net/npm/@microsoft/signalr@10.0.0/dist/browser/signalr.min.js",j={API_JS:R},u=class extends H.PacemItemElement{constructor(){super(...arguments),this._receiveHandler=(...e)=>{this.dispatchEvent(new CustomEvent("receive",{detail:Array.from(e)}))},this._completeHandler=()=>{this.dispatchEvent(new Event("complete"))},this._errorHandler=e=>{this.dispatchEvent(new CustomEvent("error",{detail:e}))},this._connectedHandler=e=>{e.detail.propertyName==="connected"&&e.detail.currentValue===!0&&this._start()}}#e;get _isConnected(){return this.container instanceof l&&this.container.connected||!1}get _connection(){return this.container instanceof l&&this.container.connection||null}start(){this.disabled||this._start()}stop(){this._stop()}_stop(e=this.method,t=this.stream){if(!this._isConnected)return;let n=this._connection;a.isNullOrEmpty(e)||(t?this.#e?.dispose():n.off(e,this._receiveHandler))}_start(e=this.method,t=this.stream){if(!this._isConnected)return;let n=this._connection;if(!a.isNullOrEmpty(e))if(!t)n.on(e,this._receiveHandler);else{let r=this.arguments||[],s=signalR.HubConnection.prototype.stream.apply(n,[e].concat(r));this.#e=s.subscribe({next:this._receiveHandler,complete:this._completeHandler,error:this._errorHandler})}}viewActivatedCallback(){super.viewActivatedCallback();let e=this.container;a.isNull(e)||e.addEventListener(g,this._connectedHandler,!1),this.start()}disconnectedCallback(){let e=this.container;a.isNull(e)||e.removeEventListener(g,this._connectedHandler,!1),super.disconnectedCallback()}propertyChangedCallback(e,t,n,r){switch(super.propertyChangedCallback(e,t,n,r),e){case"arguments":this._stop(),this._start();break;case"method":a.isNullOrEmpty(t)||this._stop(t,this.stream),a.isNullOrEmpty(n)||this._start(n,this.stream);break;case"stream":let s=this.method;a.isNullOrEmpty(s)||(this._stop(s,t),this._start(s,n));break;case"disabled":a.isNullOrEmpty(this.method)||(n?this._stop:this._start)();break}}};h([m({emit:!1,converter:_.String})],u.prototype,"method",void 0);h([m({emit:!1,converter:_.Boolean})],u.prototype,"stream",void 0);h([m({emit:!1,converter:_.Json})],u.prototype,"arguments",void 0);u=h([w({tagName:P+"-hub-listener"})],u);var l=class extends H.PacemItemsContainerElement{validate(e){return e instanceof u}get connection(){return this._hub}invoke(e,...t){if(this.connected)return this._hub.invoke.apply(this._hub,arguments);throw"Hub is not connected. Cannot call `invoke` method."}send(e,...t){if(this.connected)return this._hub.send(e,...t);throw"Hub is not connected. Cannot call `send` method."}start(){return this._resetProxy()}async stop(){this.connected&&await this._hub.stop()}propertyChangedCallback(e,t,n,r){super.propertyChangedCallback(e,t,n,r),!r&&(e==="url"||e==="disabled"||e==="accesstoken")&&this._resetProxy()}viewActivatedCallback(){super.viewActivatedCallback(),this.start()}disconnectedCallback(){this.stop(),super.disconnectedCallback()}async _resetProxy(){a.isNull(this._hub)||await this._hub.stop(),this._setupProxy()}async _initialize(){"signalR"in window||await L.importjs(j.API_JS)}async _setupProxy(){let e=this.items||[];if(!this.disabled&&!a.isNullOrEmpty(this.url)){await this._initialize();let t=new signalR.HubConnectionBuilder;t.withUrl(this.url,{accessTokenFactory:()=>this.accesstoken});let n=this._hub=t.build();n.onclose(()=>{for(var r of e)r.stop();this.connected=!1,this._hub=null}),await n.start(),this.connected=!0}}};h([m({emit:!1,converter:_.String})],l.prototype,"url",void 0);h([m({emit:!1,converter:_.String})],l.prototype,"accesstoken",void 0);h([m({converter:_.Boolean})],l.prototype,"connected",void 0);l=h([w({tagName:P+"-hub-proxy"})],l);import{P as N,CustomElement as x,Watch as b,PropertyConverters as C,Utils as c,PropertyChangeEventName as k,Debounce as I,Components as S}from"@pacem/pacem-core";var f=function(i,e,t,n){var r=arguments.length,s=r<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(i,e,t,n);else for(var p=i.length-1;p>=0;p--)(o=i[p])&&(s=(r<3?o(s):r>3?o(e,t,s):o(e,t))||s);return r>3&&s&&Object.defineProperty(e,t,s),s},v=class extends S.PacemItemElement{constructor(){super(...arguments),this._receiveHandler=e=>{this.dispatchEvent(new CustomEvent("receive",{detail:e.data}))},this._connectedHandler=e=>{e.detail.propertyName==="connected"&&e.detail.currentValue===!0&&this._start()}}get _isConnected(){return this.container instanceof d&&this.container.connected||!1}get _connection(){return this.container instanceof d&&this.container.eventSource||null}_stop(e=this.method){if(!this._isConnected)return;let t=this._connection;c.isNullOrEmpty(e)||t.removeEventListener(e,this._receiveHandler)}_start(e=this.method){if(!this._isConnected)return;let t=this._connection;c.isNullOrEmpty(e)||t.addEventListener(e,this._receiveHandler)}start(){this.disabled||this._start()}stop(){this._stop()}viewActivatedCallback(){super.viewActivatedCallback();let e=this.container;c.isNull(e)||e.addEventListener(k,this._connectedHandler,!1),this.start()}disconnectedCallback(){let e=this.container;c.isNull(e)||e.removeEventListener(k,this._connectedHandler,!1),super.disconnectedCallback()}propertyChangedCallback(e,t,n,r){switch(super.propertyChangedCallback(e,t,n,r),e){case"method":c.isNullOrEmpty(t)||this._stop(t),c.isNullOrEmpty(n)||this._start(n);break;case"disabled":c.isNullOrEmpty(this.method)||(n?this._stop:this._start)();break}}};f([b({emit:!1,converter:C.String})],v.prototype,"method",void 0);v=f([x({tagName:N+"-sse-listener"})],v);var d=class extends S.PacemItemsContainerElement{constructor(){super(...arguments),this._connectHandler=e=>{this.connected=!0,this.#e.onmessage=this._receiveHandler},this._errorHandler=e=>{this.connected=!1},this._receiveHandler=e=>{this.dispatchEvent(new CustomEvent("receive",{detail:e.data}))}}validate(e){return e instanceof v}viewActivatedCallback(){super.viewActivatedCallback(),this._start()}disconnectedCallback(){this._stop(),super.disconnectedCallback()}propertyChangedCallback(e,t,n,r){super.propertyChangedCallback(e,t,n,r),!r&&(e==="url"||e==="disabled")&&this._restart()}#e;_restart(){this._stop(),this._start()}_start(e=this.url){if(!c.isNullOrEmpty(e)&&!this.disabled){let t=this.#e=new EventSource(e);t.onopen=this._connectHandler,t.onerror=this._errorHandler}}get eventSource(){return this.#e}_stop(){let e=this.items||[];for(var t of e)t.stop();let n=this.#e;c.isNull(n)||(n.onopen=null,n.onerror=null,n.onmessage=null,n.close()),this.connected=!1,this.#e=null}};f([b({emit:!1,converter:C.String})],d.prototype,"url",void 0);f([b({converter:C.Boolean})],d.prototype,"connected",void 0);f([I(!0)],d.prototype,"_restart",null);d=f([x({tagName:N+"-sse-proxy"})],d);export{O as Components};
@@ -0,0 +1,422 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // packages/networking/dist/esm/index-components.js
8
+ var index_components_exports = {};
9
+ __export(index_components_exports, {
10
+ Networking: () => index_components_networking_exports
11
+ });
12
+
13
+ // packages/networking/dist/esm/index-components-networking.js
14
+ var index_components_networking_exports = {};
15
+ __export(index_components_networking_exports, {
16
+ PacemHubListenerElement: () => PacemHubListenerElement,
17
+ PacemHubProxyElement: () => PacemHubProxyElement,
18
+ PacemServerSentEventsListenerElement: () => PacemServerSentEventsListenerElement,
19
+ PacemServerSentEventsProxyElement: () => PacemServerSentEventsProxyElement
20
+ });
21
+
22
+ // packages/networking/dist/esm/hub-proxy.js
23
+ import { P, CustomElement, Watch, PropertyConverters, Utils, PropertyChangeEventName, CustomElementUtils, Components } from "@pacem/pacem-core";
24
+ var __decorate = function(decorators, target, key, desc) {
25
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
26
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
27
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
28
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
29
+ };
30
+ var API_JS = "https://cdn.jsdelivr.net/npm/@microsoft/signalr@10.0.0/dist/browser/signalr.min.js";
31
+ var consts = { API_JS };
32
+ var PacemHubListenerElement = class PacemHubListenerElement2 extends Components.PacemItemElement {
33
+ constructor() {
34
+ super(...arguments);
35
+ this._receiveHandler = (...args) => {
36
+ this.dispatchEvent(new CustomEvent("receive", { detail: Array.from(args) }));
37
+ };
38
+ this._completeHandler = () => {
39
+ this.dispatchEvent(new Event("complete"));
40
+ };
41
+ this._errorHandler = (error) => {
42
+ this.dispatchEvent(new CustomEvent("error", { detail: error }));
43
+ };
44
+ this._connectedHandler = (e) => {
45
+ if (e.detail.propertyName === "connected" && e.detail.currentValue === true) {
46
+ this._start();
47
+ }
48
+ };
49
+ }
50
+ #streamSubscription;
51
+ get _isConnected() {
52
+ return this.container instanceof PacemHubProxyElement && this.container.connected || false;
53
+ }
54
+ get _connection() {
55
+ return this.container instanceof PacemHubProxyElement && this.container.connection || null;
56
+ }
57
+ /** Start listening, if not disabled. */
58
+ start() {
59
+ if (!this.disabled) {
60
+ this._start();
61
+ }
62
+ }
63
+ /** Stop listening. */
64
+ stop() {
65
+ this._stop();
66
+ }
67
+ _stop(method = this.method, isStreaming = this.stream) {
68
+ if (!this._isConnected) {
69
+ return;
70
+ }
71
+ const conn = this._connection;
72
+ if (!Utils.isNullOrEmpty(method)) {
73
+ if (!isStreaming) {
74
+ conn.off(method, this._receiveHandler);
75
+ } else {
76
+ this.#streamSubscription?.dispose();
77
+ }
78
+ }
79
+ }
80
+ _start(method = this.method, isStreaming = this.stream) {
81
+ if (!this._isConnected) {
82
+ return;
83
+ }
84
+ const conn = this._connection;
85
+ if (!Utils.isNullOrEmpty(method)) {
86
+ if (!isStreaming) {
87
+ conn.on(method, this._receiveHandler);
88
+ } else {
89
+ const args = this.arguments || [];
90
+ const streamResult = signalR.HubConnection.prototype.stream.apply(conn, [method].concat(args));
91
+ this.#streamSubscription = streamResult.subscribe({
92
+ next: this._receiveHandler,
93
+ complete: this._completeHandler,
94
+ error: this._errorHandler
95
+ });
96
+ }
97
+ }
98
+ }
99
+ viewActivatedCallback() {
100
+ super.viewActivatedCallback();
101
+ const container = this.container;
102
+ if (!Utils.isNull(container)) {
103
+ container.addEventListener(PropertyChangeEventName, this._connectedHandler, false);
104
+ }
105
+ this.start();
106
+ }
107
+ disconnectedCallback() {
108
+ const container = this.container;
109
+ if (!Utils.isNull(container)) {
110
+ container.removeEventListener(PropertyChangeEventName, this._connectedHandler, false);
111
+ }
112
+ super.disconnectedCallback();
113
+ }
114
+ propertyChangedCallback(name, old, val, first) {
115
+ super.propertyChangedCallback(name, old, val, first);
116
+ switch (name) {
117
+ case "arguments":
118
+ this._stop();
119
+ this._start();
120
+ break;
121
+ case "method":
122
+ if (!Utils.isNullOrEmpty(old)) {
123
+ this._stop(old, this.stream);
124
+ }
125
+ if (!Utils.isNullOrEmpty(val)) {
126
+ this._start(val, this.stream);
127
+ }
128
+ break;
129
+ case "stream":
130
+ const m = this.method;
131
+ if (!Utils.isNullOrEmpty(m)) {
132
+ this._stop(m, old);
133
+ this._start(m, val);
134
+ }
135
+ break;
136
+ case "disabled":
137
+ if (!Utils.isNullOrEmpty(this.method)) {
138
+ let toggle = val ? this._stop : this._start;
139
+ toggle();
140
+ }
141
+ break;
142
+ }
143
+ }
144
+ };
145
+ __decorate([
146
+ Watch({ emit: false, converter: PropertyConverters.String })
147
+ ], PacemHubListenerElement.prototype, "method", void 0);
148
+ __decorate([
149
+ Watch({ emit: false, converter: PropertyConverters.Boolean })
150
+ ], PacemHubListenerElement.prototype, "stream", void 0);
151
+ __decorate([
152
+ Watch({ emit: false, converter: PropertyConverters.Json })
153
+ ], PacemHubListenerElement.prototype, "arguments", void 0);
154
+ PacemHubListenerElement = __decorate([
155
+ CustomElement({ tagName: P + "-hub-listener" })
156
+ ], PacemHubListenerElement);
157
+ var PacemHubProxyElement = class PacemHubProxyElement2 extends Components.PacemItemsContainerElement {
158
+ validate(item) {
159
+ return item instanceof PacemHubListenerElement;
160
+ }
161
+ get connection() {
162
+ return this._hub;
163
+ }
164
+ invoke(method, ...args) {
165
+ if (this.connected) {
166
+ return this._hub.invoke.apply(this._hub, arguments);
167
+ }
168
+ throw "Hub is not connected. Cannot call `invoke` method.";
169
+ }
170
+ send(method, ...args) {
171
+ if (this.connected) {
172
+ return this._hub.send(method, ...args);
173
+ }
174
+ throw "Hub is not connected. Cannot call `send` method.";
175
+ }
176
+ start() {
177
+ return this._resetProxy();
178
+ }
179
+ async stop() {
180
+ if (this.connected) {
181
+ await this._hub.stop();
182
+ }
183
+ }
184
+ propertyChangedCallback(name, old, val, first) {
185
+ super.propertyChangedCallback(name, old, val, first);
186
+ if (first) {
187
+ return;
188
+ }
189
+ if (name === "url" || name === "disabled" || name === "accesstoken") {
190
+ this._resetProxy();
191
+ }
192
+ }
193
+ viewActivatedCallback() {
194
+ super.viewActivatedCallback();
195
+ this.start();
196
+ }
197
+ disconnectedCallback() {
198
+ this.stop();
199
+ super.disconnectedCallback();
200
+ }
201
+ async _resetProxy() {
202
+ if (!Utils.isNull(this._hub)) {
203
+ await this._hub.stop();
204
+ }
205
+ this._setupProxy();
206
+ }
207
+ async _initialize() {
208
+ if ("signalR" in window) {
209
+ return;
210
+ }
211
+ await CustomElementUtils.importjs(consts.API_JS);
212
+ }
213
+ async _setupProxy() {
214
+ const listeners = this.items || [];
215
+ if (!this.disabled && !Utils.isNullOrEmpty(this.url)) {
216
+ await this._initialize();
217
+ const connBuilder = new signalR.HubConnectionBuilder();
218
+ connBuilder.withUrl(this.url, {
219
+ accessTokenFactory: () => this.accesstoken
220
+ });
221
+ const h = this._hub = connBuilder.build();
222
+ h.onclose(() => {
223
+ for (var item of listeners) {
224
+ item.stop();
225
+ }
226
+ this.connected = false;
227
+ this._hub = null;
228
+ });
229
+ await h.start();
230
+ this.connected = true;
231
+ }
232
+ }
233
+ };
234
+ __decorate([
235
+ Watch({ emit: false, converter: PropertyConverters.String })
236
+ ], PacemHubProxyElement.prototype, "url", void 0);
237
+ __decorate([
238
+ Watch({ emit: false, converter: PropertyConverters.String })
239
+ ], PacemHubProxyElement.prototype, "accesstoken", void 0);
240
+ __decorate([
241
+ Watch({ converter: PropertyConverters.Boolean })
242
+ ], PacemHubProxyElement.prototype, "connected", void 0);
243
+ PacemHubProxyElement = __decorate([
244
+ CustomElement({ tagName: P + "-hub-proxy" })
245
+ ], PacemHubProxyElement);
246
+
247
+ // packages/networking/dist/esm/sse-proxy.js
248
+ import { P as P2, CustomElement as CustomElement2, Watch as Watch2, PropertyConverters as PropertyConverters2, Utils as Utils2, PropertyChangeEventName as PropertyChangeEventName2, Debounce, Components as Components2 } from "@pacem/pacem-core";
249
+ var __decorate2 = function(decorators, target, key, desc) {
250
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
251
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
252
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
253
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
254
+ };
255
+ var PacemServerSentEventsListenerElement = class PacemServerSentEventsListenerElement2 extends Components2.PacemItemElement {
256
+ constructor() {
257
+ super(...arguments);
258
+ this._receiveHandler = (e) => {
259
+ this.dispatchEvent(new CustomEvent("receive", { detail: e.data }));
260
+ };
261
+ this._connectedHandler = (e) => {
262
+ if (e.detail.propertyName === "connected" && e.detail.currentValue === true) {
263
+ this._start();
264
+ }
265
+ };
266
+ }
267
+ get _isConnected() {
268
+ return this.container instanceof PacemServerSentEventsProxyElement && this.container.connected || false;
269
+ }
270
+ get _connection() {
271
+ return this.container instanceof PacemServerSentEventsProxyElement && this.container.eventSource || null;
272
+ }
273
+ _stop(method = this.method) {
274
+ if (!this._isConnected) {
275
+ return;
276
+ }
277
+ const conn = this._connection;
278
+ if (!Utils2.isNullOrEmpty(method)) {
279
+ conn.removeEventListener(method, this._receiveHandler);
280
+ }
281
+ }
282
+ _start(method = this.method) {
283
+ if (!this._isConnected) {
284
+ return;
285
+ }
286
+ const conn = this._connection;
287
+ if (!Utils2.isNullOrEmpty(method)) {
288
+ conn.addEventListener(method, this._receiveHandler);
289
+ }
290
+ }
291
+ /** Start listening, if not disabled. */
292
+ start() {
293
+ if (!this.disabled) {
294
+ this._start();
295
+ }
296
+ }
297
+ /** Stop listening. */
298
+ stop() {
299
+ this._stop();
300
+ }
301
+ viewActivatedCallback() {
302
+ super.viewActivatedCallback();
303
+ const container = this.container;
304
+ if (!Utils2.isNull(container)) {
305
+ container.addEventListener(PropertyChangeEventName2, this._connectedHandler, false);
306
+ }
307
+ this.start();
308
+ }
309
+ disconnectedCallback() {
310
+ const container = this.container;
311
+ if (!Utils2.isNull(container)) {
312
+ container.removeEventListener(PropertyChangeEventName2, this._connectedHandler, false);
313
+ }
314
+ super.disconnectedCallback();
315
+ }
316
+ propertyChangedCallback(name, old, val, first) {
317
+ super.propertyChangedCallback(name, old, val, first);
318
+ switch (name) {
319
+ case "method":
320
+ if (!Utils2.isNullOrEmpty(old)) {
321
+ this._stop(old);
322
+ }
323
+ if (!Utils2.isNullOrEmpty(val)) {
324
+ this._start(val);
325
+ }
326
+ break;
327
+ case "disabled":
328
+ if (!Utils2.isNullOrEmpty(this.method)) {
329
+ let toggle = val ? this._stop : this._start;
330
+ toggle();
331
+ }
332
+ break;
333
+ }
334
+ }
335
+ };
336
+ __decorate2([
337
+ Watch2({ emit: false, converter: PropertyConverters2.String })
338
+ ], PacemServerSentEventsListenerElement.prototype, "method", void 0);
339
+ PacemServerSentEventsListenerElement = __decorate2([
340
+ CustomElement2({ tagName: P2 + "-sse-listener" })
341
+ ], PacemServerSentEventsListenerElement);
342
+ var PacemServerSentEventsProxyElement = class PacemServerSentEventsProxyElement2 extends Components2.PacemItemsContainerElement {
343
+ constructor() {
344
+ super(...arguments);
345
+ this._connectHandler = (_) => {
346
+ this.connected = true;
347
+ this.#evtSource.onmessage = this._receiveHandler;
348
+ };
349
+ this._errorHandler = (_) => {
350
+ this.connected = false;
351
+ };
352
+ this._receiveHandler = (e) => {
353
+ this.dispatchEvent(new CustomEvent("receive", { detail: e.data }));
354
+ };
355
+ }
356
+ validate(item) {
357
+ return item instanceof PacemServerSentEventsListenerElement;
358
+ }
359
+ viewActivatedCallback() {
360
+ super.viewActivatedCallback();
361
+ this._start();
362
+ }
363
+ disconnectedCallback() {
364
+ this._stop();
365
+ super.disconnectedCallback();
366
+ }
367
+ propertyChangedCallback(name, old, val, first) {
368
+ super.propertyChangedCallback(name, old, val, first);
369
+ if (first) {
370
+ return;
371
+ }
372
+ if (name === "url" || name === "disabled") {
373
+ this._restart();
374
+ }
375
+ }
376
+ #evtSource;
377
+ _restart() {
378
+ this._stop();
379
+ this._start();
380
+ }
381
+ _start(url = this.url) {
382
+ if (!Utils2.isNullOrEmpty(url) && !this.disabled) {
383
+ const evtSource = this.#evtSource = new EventSource(url);
384
+ evtSource.onopen = this._connectHandler;
385
+ evtSource.onerror = this._errorHandler;
386
+ }
387
+ }
388
+ get eventSource() {
389
+ return this.#evtSource;
390
+ }
391
+ _stop() {
392
+ const listeners = this.items || [];
393
+ for (var item of listeners) {
394
+ item.stop();
395
+ }
396
+ const evtSource = this.#evtSource;
397
+ if (!Utils2.isNull(evtSource)) {
398
+ evtSource.onopen = null;
399
+ evtSource.onerror = null;
400
+ evtSource.onmessage = null;
401
+ evtSource.close();
402
+ }
403
+ this.connected = false;
404
+ this.#evtSource = null;
405
+ }
406
+ };
407
+ __decorate2([
408
+ Watch2({ emit: false, converter: PropertyConverters2.String })
409
+ ], PacemServerSentEventsProxyElement.prototype, "url", void 0);
410
+ __decorate2([
411
+ Watch2({ converter: PropertyConverters2.Boolean })
412
+ ], PacemServerSentEventsProxyElement.prototype, "connected", void 0);
413
+ __decorate2([
414
+ Debounce(true)
415
+ ], PacemServerSentEventsProxyElement.prototype, "_restart", null);
416
+ PacemServerSentEventsProxyElement = __decorate2([
417
+ CustomElement2({ tagName: P2 + "-sse-proxy" })
418
+ ], PacemServerSentEventsProxyElement);
419
+ export {
420
+ index_components_exports as Components
421
+ };
422
+ //# sourceMappingURL=pacem-networking.mjs.map