@adcops/autocore-react 3.0.34 → 3.0.38

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.
Files changed (173) hide show
  1. package/dist/assets/BlocklyLogo.js +1 -9
  2. package/dist/assets/Distance.js +1 -5
  3. package/dist/assets/JogLong.js +1 -3
  4. package/dist/assets/JogMedium.js +1 -3
  5. package/dist/assets/JogShort.js +1 -3
  6. package/dist/assets/PythonLogo.js +1 -21
  7. package/dist/assets/Rotation3D.js +1 -3
  8. package/dist/assets/RotationCcw.js +1 -10
  9. package/dist/assets/RotationCcwA.js +1 -16
  10. package/dist/assets/RotationCcwB.js +1 -16
  11. package/dist/assets/RotationCcwC.js +1 -16
  12. package/dist/assets/RotationCw.js +1 -10
  13. package/dist/assets/RotationCwA.js +1 -16
  14. package/dist/assets/RotationCwB.js +1 -16
  15. package/dist/assets/RotationCwC.js +1 -16
  16. package/dist/assets/Run.js +1 -3
  17. package/dist/assets/Speed.js +1 -5
  18. package/dist/assets/SpeedFast.js +1 -3
  19. package/dist/assets/SpeedMedium.js +1 -3
  20. package/dist/assets/SpeedNone.js +1 -3
  21. package/dist/assets/SpeedSlow.js +1 -3
  22. package/dist/assets/Walk.js +1 -3
  23. package/dist/assets/index.js +1 -22
  24. package/dist/components/BlocklyEditor.css +71 -2
  25. package/dist/components/BlocklyEditor.js +1 -508
  26. package/dist/components/CodeEditor.js +1 -108
  27. package/dist/components/FileList.js +1 -218
  28. package/dist/components/FileSelect.js +1 -63
  29. package/dist/components/FitText.js +1 -13
  30. package/dist/components/Indicator.js +1 -113
  31. package/dist/components/IndicatorButton.js +1 -187
  32. package/dist/components/IndicatorRect.js +1 -93
  33. package/dist/components/JogPanel.js +1 -295
  34. package/dist/components/Lamp.js +1 -161
  35. package/dist/components/Osk.js +1 -125
  36. package/dist/components/OskDialog.js +1 -128
  37. package/dist/components/ProgressBarWithValue.js +1 -18
  38. package/dist/components/TextInput.js +1 -139
  39. package/dist/components/ToggleGroup.js +1 -204
  40. package/dist/components/ValueDisplay.js +1 -160
  41. package/dist/components/ValueIndicator.js +1 -38
  42. package/dist/components/ValueInput.js +1 -158
  43. package/dist/core/ActionMode.js +1 -18
  44. package/dist/core/EventEmitterContext.js +1 -252
  45. package/dist/core/IndicatorButtonState.js +1 -9
  46. package/dist/core/IndicatorColor.js +1 -36
  47. package/dist/core/MaskPatterns.js +1 -80
  48. package/dist/core/NumerableTypes.js +1 -10
  49. package/dist/core/PositionContext.js +1 -24
  50. package/dist/core/UniqueId.js +1 -32
  51. package/dist/core/ValueSimulator.js +1 -233
  52. package/dist/core/hoc.js +1 -44
  53. package/dist/hooks/adsHooks.js +1 -253
  54. package/dist/hooks/commandHooks.js +1 -252
  55. package/dist/hooks/index.js +1 -10
  56. package/dist/hooks/useScaledValue.js +1 -86
  57. package/dist/hub/CommandMessage.js +1 -9
  58. package/dist/hub/HubBase.js +1 -310
  59. package/dist/hub/HubSimulate.js +1 -46
  60. package/dist/hub/HubTauri.js +1 -130
  61. package/dist/hub/HubWebSocket.js +1 -240
  62. package/dist/hub/index.js +1 -57
  63. package/dist/themes/adc-dark/blue/fonts/AtkinsonHyperlegibleMono-Italic-VariableFont_wght.ttf +0 -0
  64. package/dist/themes/adc-dark/blue/fonts/AtkinsonHyperlegibleMono-VariableFont_wght.ttf +0 -0
  65. package/dist/themes/adc-dark/blue/fonts/AtkinsonHyperlegibleNext-Italic-VariableFont_wght.ttf +0 -0
  66. package/dist/themes/adc-dark/blue/fonts/AtkinsonHyperlegibleNext-Regular.woff2 +0 -0
  67. package/dist/themes/adc-dark/blue/fonts/AtkinsonHyperlegibleNext-RegularItalic.woff2 +0 -0
  68. package/dist/themes/adc-dark/blue/fonts/AtkinsonHyperlegibleNext-VariableFont_wght.ttf +0 -0
  69. package/dist/themes/adc-dark/blue/theme.css +7097 -0
  70. package/dist/themes/adc-dark/blue/theme.css.map +1 -0
  71. package/package.json +8 -2
  72. package/src/components/BlocklyEditor.css +71 -2
  73. package/src/themes/adc-dark/_extensions.scss +166 -0
  74. package/src/themes/adc-dark/_variables.scss +913 -0
  75. package/src/themes/adc-dark/blue/_fonts.scss +24 -0
  76. package/src/themes/adc-dark/blue/adc_theme.scss +32 -0
  77. package/src/themes/adc-dark/blue/fonts/AtkinsonHyperlegibleMono-Italic-VariableFont_wght.ttf +0 -0
  78. package/src/themes/adc-dark/blue/fonts/AtkinsonHyperlegibleMono-VariableFont_wght.ttf +0 -0
  79. package/src/themes/adc-dark/blue/fonts/AtkinsonHyperlegibleNext-Italic-VariableFont_wght.ttf +0 -0
  80. package/src/themes/adc-dark/blue/fonts/AtkinsonHyperlegibleNext-Regular.woff2 +0 -0
  81. package/src/themes/adc-dark/blue/fonts/AtkinsonHyperlegibleNext-RegularItalic.woff2 +0 -0
  82. package/src/themes/adc-dark/blue/fonts/AtkinsonHyperlegibleNext-VariableFont_wght.ttf +0 -0
  83. package/src/themes/adc-dark/blue/theme.scss +14 -0
  84. package/src/themes/theme-base/_colors.scss +18 -0
  85. package/src/themes/theme-base/_common.scss +75 -0
  86. package/src/themes/theme-base/_components.scss +111 -0
  87. package/src/themes/theme-base/_mixins.scss +243 -0
  88. package/src/themes/theme-base/components/button/_button.scss +644 -0
  89. package/src/themes/theme-base/components/button/_speeddial.scss +91 -0
  90. package/src/themes/theme-base/components/button/_splitbutton.scss +359 -0
  91. package/src/themes/theme-base/components/data/_carousel.scss +39 -0
  92. package/src/themes/theme-base/components/data/_datascroller.scss +47 -0
  93. package/src/themes/theme-base/components/data/_datatable.scss +389 -0
  94. package/src/themes/theme-base/components/data/_dataview.scss +47 -0
  95. package/src/themes/theme-base/components/data/_filter.scss +138 -0
  96. package/src/themes/theme-base/components/data/_orderlist.scss +86 -0
  97. package/src/themes/theme-base/components/data/_organizationchart.scss +50 -0
  98. package/src/themes/theme-base/components/data/_paginator.scss +91 -0
  99. package/src/themes/theme-base/components/data/_picklist.scss +74 -0
  100. package/src/themes/theme-base/components/data/_timeline.scss +38 -0
  101. package/src/themes/theme-base/components/data/_tree.scss +184 -0
  102. package/src/themes/theme-base/components/data/_treetable.scss +431 -0
  103. package/src/themes/theme-base/components/file/_fileupload.scss +41 -0
  104. package/src/themes/theme-base/components/input/_autocomplete.scss +95 -0
  105. package/src/themes/theme-base/components/input/_calendar.scss +251 -0
  106. package/src/themes/theme-base/components/input/_cascadeselect.scss +107 -0
  107. package/src/themes/theme-base/components/input/_checkbox.scss +181 -0
  108. package/src/themes/theme-base/components/input/_chips.scss +102 -0
  109. package/src/themes/theme-base/components/input/_colorpicker.scss +18 -0
  110. package/src/themes/theme-base/components/input/_dropdown.scss +252 -0
  111. package/src/themes/theme-base/components/input/_editor.scss +122 -0
  112. package/src/themes/theme-base/components/input/_iconfield.scss +10 -0
  113. package/src/themes/theme-base/components/input/_inputgroup.scss +74 -0
  114. package/src/themes/theme-base/components/input/_inputicon.scss +15 -0
  115. package/src/themes/theme-base/components/input/_inputnumber.scss +5 -0
  116. package/src/themes/theme-base/components/input/_inputotp.scss +10 -0
  117. package/src/themes/theme-base/components/input/_inputswitch.scss +100 -0
  118. package/src/themes/theme-base/components/input/_inputtext.scss +101 -0
  119. package/src/themes/theme-base/components/input/_listbox.scss +139 -0
  120. package/src/themes/theme-base/components/input/_mention.scss +31 -0
  121. package/src/themes/theme-base/components/input/_multiselect.scss +278 -0
  122. package/src/themes/theme-base/components/input/_password.scss +33 -0
  123. package/src/themes/theme-base/components/input/_radiobutton.scss +170 -0
  124. package/src/themes/theme-base/components/input/_rating.scss +81 -0
  125. package/src/themes/theme-base/components/input/_selectbutton.scss +50 -0
  126. package/src/themes/theme-base/components/input/_slider.scss +49 -0
  127. package/src/themes/theme-base/components/input/_togglebutton.scss +99 -0
  128. package/src/themes/theme-base/components/input/_treeselect.scss +151 -0
  129. package/src/themes/theme-base/components/input/_tristatecheckbox.scss +46 -0
  130. package/src/themes/theme-base/components/menu/_breadcrumb.scss +42 -0
  131. package/src/themes/theme-base/components/menu/_contextmenu.scss +39 -0
  132. package/src/themes/theme-base/components/menu/_dock.scss +109 -0
  133. package/src/themes/theme-base/components/menu/_megamenu.scss +141 -0
  134. package/src/themes/theme-base/components/menu/_menu.scss +33 -0
  135. package/src/themes/theme-base/components/menu/_menubar.scss +216 -0
  136. package/src/themes/theme-base/components/menu/_panelmenu.scss +153 -0
  137. package/src/themes/theme-base/components/menu/_slidemenu.scss +60 -0
  138. package/src/themes/theme-base/components/menu/_steps.scss +57 -0
  139. package/src/themes/theme-base/components/menu/_tabmenu.scss +50 -0
  140. package/src/themes/theme-base/components/menu/_tieredmenu.scss +43 -0
  141. package/src/themes/theme-base/components/messages/_inlinemessage.scss +69 -0
  142. package/src/themes/theme-base/components/messages/_message.scss +107 -0
  143. package/src/themes/theme-base/components/messages/_toast.scss +100 -0
  144. package/src/themes/theme-base/components/misc/_avatar.scss +34 -0
  145. package/src/themes/theme-base/components/misc/_badge.scss +77 -0
  146. package/src/themes/theme-base/components/misc/_blockui.scss +0 -0
  147. package/src/themes/theme-base/components/misc/_chip.scss +39 -0
  148. package/src/themes/theme-base/components/misc/_inplace.scss +17 -0
  149. package/src/themes/theme-base/components/misc/_metergroup.scss +81 -0
  150. package/src/themes/theme-base/components/misc/_progressbar.scss +17 -0
  151. package/src/themes/theme-base/components/misc/_scrolltop.scss +25 -0
  152. package/src/themes/theme-base/components/misc/_skeleton.scss +8 -0
  153. package/src/themes/theme-base/components/misc/_tag.scss +40 -0
  154. package/src/themes/theme-base/components/misc/_terminal.scss +12 -0
  155. package/src/themes/theme-base/components/multimedia/_galleria.scss +153 -0
  156. package/src/themes/theme-base/components/multimedia/_image.scss +54 -0
  157. package/src/themes/theme-base/components/overlay/_confirmpopup.scss +72 -0
  158. package/src/themes/theme-base/components/overlay/_dialog.scss +78 -0
  159. package/src/themes/theme-base/components/overlay/_overlaypanel.scss +64 -0
  160. package/src/themes/theme-base/components/overlay/_sidebar.scss +23 -0
  161. package/src/themes/theme-base/components/overlay/_tooltip.scss +33 -0
  162. package/src/themes/theme-base/components/panel/_accordion.scss +118 -0
  163. package/src/themes/theme-base/components/panel/_card.scss +30 -0
  164. package/src/themes/theme-base/components/panel/_divider.scss +31 -0
  165. package/src/themes/theme-base/components/panel/_fieldset.scss +47 -0
  166. package/src/themes/theme-base/components/panel/_panel.scss +47 -0
  167. package/src/themes/theme-base/components/panel/_scrollpanel.scss +10 -0
  168. package/src/themes/theme-base/components/panel/_splitter.scss +23 -0
  169. package/src/themes/theme-base/components/panel/_stepper.scss +136 -0
  170. package/src/themes/theme-base/components/panel/_tabview.scss +147 -0
  171. package/src/themes/theme-base/components/panel/_toolbar.scss +11 -0
  172. package/tools/build-themes.cjs +66 -0
  173. package/tools/copy-distribution-files.cjs +20 -16
@@ -1,240 +1 @@
1
- /*
2
- * Copyright (C) 2024 Automated Design Corp.. All Rights Reserved.
3
- * Created Date: 2024-04-17 09:13:07
4
- * -----
5
- * Last Modified: 2025-05-08 14:47:42
6
- * -----
7
- *
8
- */
9
- /** @file
10
- *
11
- * ## broadcast messages
12
- * The result field of CommandMessages used for broadcast must have
13
- * success set to true, and must contain the field "topic." The topic field, along
14
- * with the domain field of the CommandMessage will be combined for the topic used
15
- * by the websocket client.
16
- *
17
- * broadcast topic = `${CommandMessage.domain}/${CommandMessage.result["topic"]}
18
- *
19
- * So, to subscribe to a broadcast topic for GM.fReal that is served by the ADS client, the
20
- * topic will be: "ADS/GM.fReal"
21
- */
22
- import { HubBase } from './HubBase';
23
- /**
24
- * Converts a Base64 encoded string into a Blob object.
25
- *
26
- * This function is useful for handling binary data encoded in Base64 format,
27
- * especially when the data needs to be reconstructed into a binary format
28
- * such as when downloading files that were transferred as Base64 strings over
29
- * a network. The function slices the Base64 string, decodes it to binary,
30
- * and constructs a Blob from the resulting byte arrays.
31
- *
32
- * @param {string} b64Data The base64 encoded string you want to convert to a Blob.
33
- * @param {string} [contentType='application/octet-stream'] The MIME type of the Blob.
34
- * This parameter is optional and defaults to 'application/octet-stream'.
35
- * @param {number} [sliceSize=512] The size of each chunk used to slice the Base64 string.
36
- * Smaller slice sizes can improve the function's handling of large Base64 strings.
37
- * This parameter is optional and defaults to 512.
38
- *
39
- * @returns {Blob} A Blob object representing the decoded binary data.
40
- */
41
- function b64toBlob(b64Data, contentType = 'application/octet-stream', sliceSize = 512) {
42
- const byteCharacters = atob(b64Data);
43
- const byteArrays = [];
44
- for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
45
- const slice = byteCharacters.slice(offset, offset + sliceSize);
46
- const byteNumbers = new Array(slice.length);
47
- for (let i = 0; i < slice.length; i++) {
48
- byteNumbers[i] = slice.charCodeAt(i);
49
- }
50
- const byteArray = new Uint8Array(byteNumbers);
51
- byteArrays.push(byteArray);
52
- }
53
- const blob = new Blob(byteArrays, { type: contentType });
54
- return blob;
55
- }
56
- /**
57
- * Creates a temporary hyperlink in the document and programmatically triggers a download of the Blob provided.
58
- *
59
- * This function is useful for triggering downloads of binary data such as files, which are represented
60
- * by Blob objects in the browser. The function creates a URL from the Blob, sets it as the href of a
61
- * dynamically created anchor tag (`<a>`), sets the suggested filename, and then simulates a click on
62
- * this link to start the download. After the download is triggered, the link is removed and the URL
63
- * is revoked to free up memory.
64
- *
65
- * @param {Blob} blob The Blob object containing the data to be downloaded.
66
- * @param {string} filename The filename to be used for the downloaded file.
67
- */
68
- function downloadBlob(blob, filename) {
69
- // Create a URL for the blob object
70
- const url = window.URL.createObjectURL(blob);
71
- // Create a temporary anchor tag (`<a>`) element
72
- const a = document.createElement('a');
73
- a.href = url; // Set the href to the blob URL
74
- a.download = filename; // Suggest a filename for the downloaded file
75
- // Append the anchor tag to the body of the document
76
- document.body.appendChild(a);
77
- // Programmatically trigger a click on the anchor tag
78
- a.click();
79
- // Remove the anchor tag from the document
80
- document.body.removeChild(a);
81
- // Revoke the blob URL to free up resources
82
- window.URL.revokeObjectURL(url);
83
- }
84
- export class HubWebSocket extends HubBase {
85
- /**
86
- * Constructor. Creates and attempts to make the Websocket connection.
87
- */
88
- constructor() {
89
- super();
90
- Object.defineProperty(this, "socket", {
91
- enumerable: true,
92
- configurable: true,
93
- writable: true,
94
- value: void 0
95
- });
96
- Object.defineProperty(this, "requestId", {
97
- enumerable: true,
98
- configurable: true,
99
- writable: true,
100
- value: 0
101
- });
102
- Object.defineProperty(this, "pendingRequests", {
103
- enumerable: true,
104
- configurable: true,
105
- writable: true,
106
- value: new Map()
107
- });
108
- /**
109
- * Invoke a command in the remote webserver.
110
- * @param domain The domain of the Servelet supplying the functionality.
111
- * @param fname The name of the command to execute.
112
- * @param payload The arguments of the command.
113
- * @returns Promise<CommandMessageResult>
114
- */
115
- Object.defineProperty(this, "invoke", {
116
- enumerable: true,
117
- configurable: true,
118
- writable: true,
119
- value: (domain, fname, payload) => {
120
- return new Promise((resolve, reject) => {
121
- const id = ++this.requestId; // Increment and use the request ID
122
- this.pendingRequests.set(id, { resolve, reject });
123
- let cm = {
124
- request_id: id,
125
- domain: domain,
126
- fname: fname,
127
- args: payload,
128
- result: undefined
129
- };
130
- this.socket.send(JSON.stringify(cm));
131
- });
132
- }
133
- });
134
- Object.defineProperty(this, "handleUnsolicitedMessage", {
135
- enumerable: true,
136
- configurable: true,
137
- writable: true,
138
- value: (msg) => {
139
- // Handle messages that do not correspond to a pending request
140
- if (msg.fname === "BROADCAST"
141
- && msg.domain.length >= 1
142
- && msg.result !== undefined && msg.result !== null
143
- && msg.result.data !== undefined && msg.result.data !== null) {
144
- let topic = `${msg.domain}/${msg.result.data["topic"]}`;
145
- // console.log(`HUB PUBLISHING: ${topic} : ${JSON.stringify(msg.result.data)}`);
146
- this.publish(topic, msg.result.data);
147
- }
148
- else {
149
- console.error("INVALID BROADCAST RECEIVED!");
150
- }
151
- }
152
- });
153
- Object.defineProperty(this, "disconnect", {
154
- enumerable: true,
155
- configurable: true,
156
- writable: true,
157
- value: () => {
158
- this.socket.close();
159
- }
160
- });
161
- Object.defineProperty(this, "emit", {
162
- enumerable: true,
163
- configurable: true,
164
- writable: true,
165
- value: (eventName, payload) => {
166
- this.socket.send(JSON.stringify({ eventName, payload }));
167
- }
168
- });
169
- const host = window.location.hostname; // Get the hostname from the address bar
170
- // Default to using autocore-server.
171
- let port = undefined; // window.location.port; // Get the port from the address bar, if any
172
- const proto = window.location.protocol === 'https:' ? 'wss://' : 'ws://'; // Determine the protocol
173
- const wsUrl = `${proto}${host}${port ? ':' + port : ''}/ws/`; // Construct WebSocket URL
174
- this.socket = new WebSocket(wsUrl);
175
- let self = this;
176
- //
177
- // Websocket connection established.
178
- //
179
- this.socket.onopen = function () {
180
- console.log("WebSocket connection established.");
181
- self.publish("HUB/connected", true);
182
- self.setIsConnected(true);
183
- };
184
- // Message recevied via the websocket connection.
185
- //
186
- this.socket.onmessage = (event) => {
187
- const data = JSON.parse(event.data);
188
- // console.log(`MSG: ${JSON.stringify(data)}`);
189
- if (data.request_id && this.pendingRequests.has(data.request_id)) {
190
- const { resolve, reject } = this.pendingRequests.get(data.request_id);
191
- if (data.fname === "FILE_DOWNLOAD"
192
- && data.args["file_name"] !== undefined && data.args["file_name"] !== null
193
- && data.args["file_name"].length > 0) {
194
- // The file name was supplied in the original request
195
- let tokens = data.args["file_name"].split("/");
196
- const filename = tokens[tokens.length - 1];
197
- if (data.result && data.result.success) {
198
- const blob = b64toBlob(data.result.data);
199
- downloadBlob(blob, filename);
200
- // Don't send the whole file through; that's crazy.
201
- data.result.data = filename;
202
- // Signal the function that initiated the download that all is well.
203
- resolve(data.result);
204
- }
205
- else {
206
- // Signal the function that initiated the download that it failed.
207
- reject(new Error(data.result?.error_message));
208
- }
209
- }
210
- else {
211
- if (!data.result?.success) {
212
- // Return the result to the function that initiated the request.
213
- reject(new Error(data.result?.error_message));
214
- }
215
- else {
216
- // Send the error to the function that intiated the request.
217
- resolve(data.result);
218
- }
219
- }
220
- this.pendingRequests.delete(data.request_id);
221
- }
222
- else {
223
- this.handleUnsolicitedMessage(data);
224
- }
225
- };
226
- //
227
- // Error occurred in the Websocket connection.
228
- //
229
- this.socket.onerror = (error) => {
230
- console.error('WebSocket error:', error);
231
- };
232
- //
233
- // The Websocket connection has closed.
234
- //
235
- this.socket.onclose = () => {
236
- self.setIsConnected(false);
237
- console.log('WebSocket connection closed.');
238
- };
239
- }
240
- }
1
+ import{HubBase}from"./HubBase";function b64toBlob(e,t="application/octet-stream",s=512){const n=atob(e),o=[];for(let e=0;e<n.length;e+=s){const t=n.slice(e,e+s),r=new Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);const i=new Uint8Array(r);o.push(i)}return new Blob(o,{type:t})}function downloadBlob(e,t){const s=window.URL.createObjectURL(e),n=document.createElement("a");n.href=s,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n),window.URL.revokeObjectURL(s)}export class HubWebSocket extends HubBase{constructor(){super(),Object.defineProperty(this,"socket",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"requestId",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"pendingRequests",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"invoke",{enumerable:!0,configurable:!0,writable:!0,value:(e,t,s)=>new Promise(((n,o)=>{const r=++this.requestId;this.pendingRequests.set(r,{resolve:n,reject:o});let i={request_id:r,domain:e,fname:t,args:s,result:void 0};this.socket.send(JSON.stringify(i))}))}),Object.defineProperty(this,"handleUnsolicitedMessage",{enumerable:!0,configurable:!0,writable:!0,value:e=>{if("BROADCAST"===e.fname&&e.domain.length>=1&&void 0!==e.result&&null!==e.result&&void 0!==e.result.data&&null!==e.result.data){let t=`${e.domain}/${e.result.data.topic}`;this.publish(t,e.result.data)}}}),Object.defineProperty(this,"disconnect",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.socket.close()}}),Object.defineProperty(this,"emit",{enumerable:!0,configurable:!0,writable:!0,value:(e,t)=>{this.socket.send(JSON.stringify({eventName:e,payload:t}))}});const e=window.location.hostname;let t;const s=`${"https:"===window.location.protocol?"wss://":"ws://"}${e}${t?":"+t:""}/ws/`;this.socket=new WebSocket(s);let n=this;this.socket.onopen=function(){n.publish("HUB/connected",!0),n.setIsConnected(!0)},this.socket.onmessage=e=>{const t=JSON.parse(e.data);if(t.request_id&&this.pendingRequests.has(t.request_id)){const{resolve:e,reject:s}=this.pendingRequests.get(t.request_id);if("FILE_DOWNLOAD"===t.fname&&void 0!==t.args.file_name&&null!==t.args.file_name&&t.args.file_name.length>0){let n=t.args.file_name.split("/");const o=n[n.length-1];if(t.result&&t.result.success){downloadBlob(b64toBlob(t.result.data),o),t.result.data=o,e(t.result)}else s(new Error(t.result?.error_message))}else t.result?.success?e(t.result):s(new Error(t.result?.error_message));this.pendingRequests.delete(t.request_id)}else this.handleUnsolicitedMessage(t)},this.socket.onerror=e=>{},this.socket.onclose=()=>{n.setIsConnected(!1)}}}
package/dist/hub/index.js CHANGED
@@ -1,57 +1 @@
1
- /*
2
- * Copyright (C) 2024 Automated Design Corp. All Rights Reserved.
3
- * Created Date: 2024-01-16 21:07:29
4
- * -----
5
- * Last Modified: 2024-05-31 07:51:19
6
- * Modified By: ADC
7
- * -----
8
- *
9
- */
10
- import { HubTauri } from './HubTauri';
11
- import { HubWebSocket } from "./HubWebSocket";
12
- import { HubSimulate } from "./HubSimulate";
13
- let hubInstance = null;
14
- /**
15
- * Creates a connection to the backend.
16
- * @returns Hub
17
- */
18
- export function createHub() {
19
- if (!hubInstance) {
20
- if (window.__TAURI__ !== undefined && window.__TAURI__ !== null) {
21
- console.log("HUB: Starting link to Tauri backend.");
22
- hubInstance = new HubTauri();
23
- }
24
- else {
25
- console.log("HUB: Starting websocket connection.");
26
- hubInstance = new HubWebSocket();
27
- }
28
- }
29
- return hubInstance;
30
- // if (window.__TAURI__ !== undefined && window.__TAURI__ !== null) {
31
- // // Standalone Tauri application
32
- // console.log("HUB: Starting link to Tauri backend.");
33
- // return new HubTauri();
34
- // }
35
- // // else if (
36
- // // window.location.port !== undefined
37
- // // && window.location.port.length > 0
38
- // // && window.location.port !== '80'
39
- // // && window.location.port !== '8080'
40
- // // && window.location.port !== '443'
41
- // // ) {
42
- // // // We're loaded in some development environment
43
- // // console.log("HUB: Starting HUB SIMULATOR.");
44
- // // return new HubSimulate();
45
- // // }
46
- // else {
47
- // // A web-app that must communicate with a backend in another process.
48
- // console.log("HUB: Starting websocket connection.");
49
- // return new HubWebSocket();
50
- // }
51
- }
52
- // Export HubBase for convenience to save importing throughout the
53
- // application.
54
- export { HubBase as Hub } from './HubBase';
55
- export { HubTauri };
56
- export { HubWebSocket };
57
- export { HubSimulate };
1
+ import{HubTauri}from"./HubTauri";import{HubWebSocket}from"./HubWebSocket";import{HubSimulate}from"./HubSimulate";let hubInstance=null;export function createHub(){return hubInstance||(hubInstance=void 0!==window.__TAURI__&&null!==window.__TAURI__?new HubTauri:new HubWebSocket),hubInstance}export{HubBase as Hub}from"./HubBase";export{HubTauri};export{HubWebSocket};export{HubSimulate};