@codella-software/react 2.2.1 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +17 -2289
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +9 -2281
- package/dist/index.mjs.map +1 -1
- package/dist/react/src/filters-and-sort/useFiltersAndSort.d.ts +1 -1
- package/dist/react/src/filters-and-sort/useFiltersAndSort.d.ts.map +1 -1
- package/dist/react/src/form-builder/useFormBuilder.d.ts +1 -1
- package/dist/react/src/form-builder/useFormBuilder.d.ts.map +1 -1
- package/dist/react/src/rich-content/useRichContent.d.ts.map +1 -1
- package/dist/react/src/table-builder/useTableService.d.ts +1 -1
- package/dist/react/src/table-builder/useTableService.d.ts.map +1 -1
- package/dist/react/src/useFiltersAndSort.d.ts +1 -1
- package/dist/react/src/useFiltersAndSort.d.ts.map +1 -1
- package/dist/react/src/useFormBuilder.d.ts +1 -1
- package/dist/react/src/useFormBuilder.d.ts.map +1 -1
- package/dist/react/src/useTableService.d.ts +1 -1
- package/dist/react/src/useTableService.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const react = require("react");
|
|
4
|
-
const
|
|
4
|
+
const utils = require("@codella-software/utils");
|
|
5
5
|
const jsxRuntime = require("react/jsx-runtime");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
6
|
+
const liveUpdates = require("@codella/core/live-updates");
|
|
7
|
+
const richContent = require("@codella/core/rich-content");
|
|
8
|
+
const tabs = require("@codella/core/tabs");
|
|
8
9
|
function useFiltersAndSort(options) {
|
|
9
10
|
const { service } = options;
|
|
10
11
|
const [state, setState] = react.useState(() => {
|
|
@@ -109,1387 +110,6 @@ function useFormBuilder(options) {
|
|
|
109
110
|
}), [builder, state, isSubmitting]);
|
|
110
111
|
return memoizedReturn;
|
|
111
112
|
}
|
|
112
|
-
class LiveUpdateService {
|
|
113
|
-
constructor(wsService, sseService) {
|
|
114
|
-
this.wsService = wsService;
|
|
115
|
-
this.sseService = sseService;
|
|
116
|
-
this.activeType = null;
|
|
117
|
-
this.isInitialized = false;
|
|
118
|
-
this.eventMappings = {};
|
|
119
|
-
}
|
|
120
|
-
initialize(config2) {
|
|
121
|
-
if (this.isInitialized) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
this.eventMappings = config2.eventMappings ?? {};
|
|
125
|
-
if (config2.sseEnabled) {
|
|
126
|
-
this.activeType = "SSE";
|
|
127
|
-
this.sseService.connect().catch((error) => {
|
|
128
|
-
console.error("[LiveUpdateService] SSE connection failed:", error);
|
|
129
|
-
if (config2.wsEnabled) {
|
|
130
|
-
this.activeType = "WebSocket";
|
|
131
|
-
this.wsService.connect();
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
} else if (config2.wsEnabled) {
|
|
135
|
-
this.activeType = "WebSocket";
|
|
136
|
-
this.wsService.connect();
|
|
137
|
-
}
|
|
138
|
-
this.isInitialized = true;
|
|
139
|
-
}
|
|
140
|
-
get type() {
|
|
141
|
-
return this.activeType;
|
|
142
|
-
}
|
|
143
|
-
get isConnected$() {
|
|
144
|
-
switch (this.activeType) {
|
|
145
|
-
case "SSE":
|
|
146
|
-
return this.sseService.isConnected$;
|
|
147
|
-
case "WebSocket":
|
|
148
|
-
return this.wsService.isConnected$;
|
|
149
|
-
default:
|
|
150
|
-
return rxjs.of(false);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
get canSend() {
|
|
154
|
-
return this.activeType === "WebSocket";
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Subscribe to a named event using configured mappings
|
|
158
|
-
*/
|
|
159
|
-
on(eventName) {
|
|
160
|
-
const mapping = this.eventMappings[eventName];
|
|
161
|
-
if (!mapping) {
|
|
162
|
-
console.warn(`[LiveUpdateService] No mapping found for event: ${eventName}`);
|
|
163
|
-
return rxjs.EMPTY;
|
|
164
|
-
}
|
|
165
|
-
switch (this.activeType) {
|
|
166
|
-
case "SSE":
|
|
167
|
-
if (mapping.sseEvent) {
|
|
168
|
-
return this.sseService.on(mapping.sseEvent);
|
|
169
|
-
}
|
|
170
|
-
break;
|
|
171
|
-
case "WebSocket":
|
|
172
|
-
if (mapping.wsAction) {
|
|
173
|
-
return this.wsService.on(mapping.wsAction);
|
|
174
|
-
}
|
|
175
|
-
break;
|
|
176
|
-
}
|
|
177
|
-
return rxjs.EMPTY;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Send a message via WebSocket (if available)
|
|
181
|
-
*/
|
|
182
|
-
send(action, payload) {
|
|
183
|
-
if (!this.canSend) {
|
|
184
|
-
console.warn("[LiveUpdateService] WebSocket not available for sending");
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
this.wsService.sendMessage(action, payload);
|
|
188
|
-
}
|
|
189
|
-
disconnect() {
|
|
190
|
-
this.sseService.disconnect();
|
|
191
|
-
this.wsService.disconnect();
|
|
192
|
-
this.activeType = null;
|
|
193
|
-
this.isInitialized = false;
|
|
194
|
-
}
|
|
195
|
-
destroy() {
|
|
196
|
-
this.sseService.destroy();
|
|
197
|
-
this.wsService.destroy();
|
|
198
|
-
this.activeType = null;
|
|
199
|
-
this.isInitialized = false;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
const DEFAULT_CONFIG = {
|
|
203
|
-
maxReconnectAttempts: 5,
|
|
204
|
-
initialReconnectDelay: 1e3,
|
|
205
|
-
maxReconnectDelay: 3e4
|
|
206
|
-
};
|
|
207
|
-
class BaseConnectionService {
|
|
208
|
-
constructor(config2 = {}) {
|
|
209
|
-
this.destroySubject$ = new rxjs.Subject();
|
|
210
|
-
this.messagesSubject$ = new rxjs.Subject();
|
|
211
|
-
this.connectionStatusSubject$ = new rxjs.BehaviorSubject(false);
|
|
212
|
-
this.reconnectAttempts = 0;
|
|
213
|
-
this.messages$ = this.messagesSubject$.asObservable();
|
|
214
|
-
this.isConnected$ = this.connectionStatusSubject$.asObservable();
|
|
215
|
-
this.config = { ...DEFAULT_CONFIG, ...config2 };
|
|
216
|
-
}
|
|
217
|
-
getReconnectDelay(attempt) {
|
|
218
|
-
return Math.min(
|
|
219
|
-
this.config.initialReconnectDelay * Math.pow(2, attempt),
|
|
220
|
-
this.config.maxReconnectDelay
|
|
221
|
-
);
|
|
222
|
-
}
|
|
223
|
-
scheduleReconnect(connectFn) {
|
|
224
|
-
if (this.reconnectAttempts >= this.config.maxReconnectAttempts) {
|
|
225
|
-
console.error(`[${this.serviceName}] Max reconnection attempts reached`);
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
const delay = this.getReconnectDelay(this.reconnectAttempts);
|
|
229
|
-
this.reconnectAttempts++;
|
|
230
|
-
console.log(
|
|
231
|
-
`[${this.serviceName}] Reconnecting in ${delay}ms (attempt ${this.reconnectAttempts})`
|
|
232
|
-
);
|
|
233
|
-
rxjs.timer(delay).pipe(operators.take(1), operators.takeUntil(this.destroySubject$)).subscribe(() => connectFn());
|
|
234
|
-
}
|
|
235
|
-
resetReconnectAttempts() {
|
|
236
|
-
this.reconnectAttempts = 0;
|
|
237
|
-
}
|
|
238
|
-
destroy() {
|
|
239
|
-
this.disconnect();
|
|
240
|
-
this.destroySubject$.next();
|
|
241
|
-
this.destroySubject$.complete();
|
|
242
|
-
this.messagesSubject$.complete();
|
|
243
|
-
this.connectionStatusSubject$.complete();
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
class FetchEventSource {
|
|
247
|
-
constructor(url, headers) {
|
|
248
|
-
this.url = url;
|
|
249
|
-
this.headers = headers;
|
|
250
|
-
this.eventTarget = new EventTarget();
|
|
251
|
-
this.abortController = null;
|
|
252
|
-
}
|
|
253
|
-
async connect() {
|
|
254
|
-
var _a;
|
|
255
|
-
this.abortController = new AbortController();
|
|
256
|
-
try {
|
|
257
|
-
const response = await fetch(this.url, {
|
|
258
|
-
method: "GET",
|
|
259
|
-
headers: this.headers,
|
|
260
|
-
signal: this.abortController.signal
|
|
261
|
-
});
|
|
262
|
-
if (!response.ok) {
|
|
263
|
-
const error = new Event("error");
|
|
264
|
-
this.eventTarget.dispatchEvent(error);
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
const openEvent = new Event("open");
|
|
268
|
-
this.eventTarget.dispatchEvent(openEvent);
|
|
269
|
-
const reader = (_a = response.body) == null ? void 0 : _a.getReader();
|
|
270
|
-
if (!reader) {
|
|
271
|
-
const error = new Event("error");
|
|
272
|
-
this.eventTarget.dispatchEvent(error);
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
const decoder = new TextDecoder();
|
|
276
|
-
let buffer = "";
|
|
277
|
-
while (true) {
|
|
278
|
-
const { done, value } = await reader.read();
|
|
279
|
-
if (done) break;
|
|
280
|
-
buffer += decoder.decode(value, { stream: true });
|
|
281
|
-
const lines = buffer.split("\n");
|
|
282
|
-
for (let i = 0; i < lines.length - 1; i++) {
|
|
283
|
-
this.processLine(lines[i]);
|
|
284
|
-
}
|
|
285
|
-
buffer = lines[lines.length - 1];
|
|
286
|
-
}
|
|
287
|
-
if (buffer.length > 0) {
|
|
288
|
-
this.processLine(buffer);
|
|
289
|
-
}
|
|
290
|
-
} catch (error) {
|
|
291
|
-
if (error instanceof Error && error.name !== "AbortError") {
|
|
292
|
-
const errorEvent = new Event("error");
|
|
293
|
-
this.eventTarget.dispatchEvent(errorEvent);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
processLine(line) {
|
|
298
|
-
line = line.trim();
|
|
299
|
-
if (line === "" || line.startsWith(":")) {
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
const colonIndex = line.indexOf(":");
|
|
303
|
-
if (colonIndex === -1) {
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
const field = line.substring(0, colonIndex);
|
|
307
|
-
let value = line.substring(colonIndex + 1);
|
|
308
|
-
if (value.startsWith(" ")) {
|
|
309
|
-
value = value.substring(1);
|
|
310
|
-
}
|
|
311
|
-
if (field === "data") {
|
|
312
|
-
const event = new MessageEvent("message", {
|
|
313
|
-
data: value
|
|
314
|
-
});
|
|
315
|
-
this.eventTarget.dispatchEvent(event);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
addEventListener(type, listener) {
|
|
319
|
-
this.eventTarget.addEventListener(type, listener);
|
|
320
|
-
}
|
|
321
|
-
removeEventListener(type, listener) {
|
|
322
|
-
this.eventTarget.removeEventListener(type, listener);
|
|
323
|
-
}
|
|
324
|
-
get onopen() {
|
|
325
|
-
return this.eventTarget.onopen;
|
|
326
|
-
}
|
|
327
|
-
set onopen(handler) {
|
|
328
|
-
if (this.eventTarget.onopen) {
|
|
329
|
-
this.eventTarget.removeEventListener("open", this.eventTarget.onopen);
|
|
330
|
-
}
|
|
331
|
-
if (handler) {
|
|
332
|
-
this.eventTarget.addEventListener("open", handler);
|
|
333
|
-
this.eventTarget.onopen = handler;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
get onerror() {
|
|
337
|
-
return this.eventTarget.onerror;
|
|
338
|
-
}
|
|
339
|
-
set onerror(handler) {
|
|
340
|
-
if (this.eventTarget.onerror) {
|
|
341
|
-
this.eventTarget.removeEventListener("error", this.eventTarget.onerror);
|
|
342
|
-
}
|
|
343
|
-
if (handler) {
|
|
344
|
-
this.eventTarget.addEventListener("error", handler);
|
|
345
|
-
this.eventTarget.onerror = handler;
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
close() {
|
|
349
|
-
var _a;
|
|
350
|
-
(_a = this.abortController) == null ? void 0 : _a.abort();
|
|
351
|
-
this.abortController = null;
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
class SSEService extends BaseConnectionService {
|
|
355
|
-
constructor(config2) {
|
|
356
|
-
super();
|
|
357
|
-
this.eventSource = null;
|
|
358
|
-
this.sseConfig = {
|
|
359
|
-
headerName: "Authorization",
|
|
360
|
-
headerPrefix: "Bearer",
|
|
361
|
-
...config2
|
|
362
|
-
};
|
|
363
|
-
}
|
|
364
|
-
get serviceName() {
|
|
365
|
-
return "SSE";
|
|
366
|
-
}
|
|
367
|
-
async connect() {
|
|
368
|
-
if (this.eventSource) {
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
try {
|
|
372
|
-
if (!this.sseConfig.authProvider.isAuthenticated()) {
|
|
373
|
-
console.error("[SSE] Not authenticated");
|
|
374
|
-
return;
|
|
375
|
-
}
|
|
376
|
-
const idToken = await this.sseConfig.authProvider.getIdToken();
|
|
377
|
-
if (!idToken) {
|
|
378
|
-
console.error("[SSE] No auth token available");
|
|
379
|
-
return;
|
|
380
|
-
}
|
|
381
|
-
const headers = {
|
|
382
|
-
[this.sseConfig.headerName]: `${this.sseConfig.headerPrefix} ${idToken}`
|
|
383
|
-
};
|
|
384
|
-
const url = new URL(this.sseConfig.url);
|
|
385
|
-
this.eventSource = new FetchEventSource(url.toString(), headers);
|
|
386
|
-
this.setupEventListeners();
|
|
387
|
-
await this.eventSource.connect();
|
|
388
|
-
} catch (error) {
|
|
389
|
-
console.error("[SSE] Connection error:", error);
|
|
390
|
-
this.scheduleReconnect(() => this.connect());
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
setupEventListeners() {
|
|
394
|
-
if (!this.eventSource) return;
|
|
395
|
-
this.eventSource.onopen = () => {
|
|
396
|
-
console.log("[SSE] Connected");
|
|
397
|
-
this.connectionStatusSubject$.next(true);
|
|
398
|
-
this.resetReconnectAttempts();
|
|
399
|
-
};
|
|
400
|
-
this.eventSource.onerror = (event) => {
|
|
401
|
-
console.error("[SSE] Error:", event);
|
|
402
|
-
this.connectionStatusSubject$.next(false);
|
|
403
|
-
this.cleanup();
|
|
404
|
-
this.scheduleReconnect(() => this.connect());
|
|
405
|
-
};
|
|
406
|
-
rxjs.fromEvent(this.eventSource, "message").pipe(
|
|
407
|
-
operators.takeUntil(this.destroySubject$),
|
|
408
|
-
operators.map((event) => {
|
|
409
|
-
try {
|
|
410
|
-
return JSON.parse(event.data);
|
|
411
|
-
} catch (error) {
|
|
412
|
-
console.error("[SSE] Parse error:", error);
|
|
413
|
-
return null;
|
|
414
|
-
}
|
|
415
|
-
}),
|
|
416
|
-
operators.filter((msg) => msg !== null)
|
|
417
|
-
).subscribe((message) => {
|
|
418
|
-
this.messagesSubject$.next(message);
|
|
419
|
-
});
|
|
420
|
-
}
|
|
421
|
-
cleanup() {
|
|
422
|
-
var _a;
|
|
423
|
-
(_a = this.eventSource) == null ? void 0 : _a.close();
|
|
424
|
-
this.eventSource = null;
|
|
425
|
-
}
|
|
426
|
-
on(eventType) {
|
|
427
|
-
return this.messages$.pipe(
|
|
428
|
-
operators.filter((msg) => msg.eventType === eventType),
|
|
429
|
-
operators.map((msg) => msg.data)
|
|
430
|
-
);
|
|
431
|
-
}
|
|
432
|
-
disconnect() {
|
|
433
|
-
this.cleanup();
|
|
434
|
-
this.connectionStatusSubject$.next(false);
|
|
435
|
-
this.resetReconnectAttempts();
|
|
436
|
-
}
|
|
437
|
-
destroy() {
|
|
438
|
-
this.cleanup();
|
|
439
|
-
this.destroySubject$.next();
|
|
440
|
-
this.destroySubject$.complete();
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
var extendStatics = function(d, b) {
|
|
444
|
-
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
445
|
-
d2.__proto__ = b2;
|
|
446
|
-
} || function(d2, b2) {
|
|
447
|
-
for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p];
|
|
448
|
-
};
|
|
449
|
-
return extendStatics(d, b);
|
|
450
|
-
};
|
|
451
|
-
function __extends(d, b) {
|
|
452
|
-
if (typeof b !== "function" && b !== null)
|
|
453
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
454
|
-
extendStatics(d, b);
|
|
455
|
-
function __() {
|
|
456
|
-
this.constructor = d;
|
|
457
|
-
}
|
|
458
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
459
|
-
}
|
|
460
|
-
var __assign = function() {
|
|
461
|
-
__assign = Object.assign || function __assign2(t) {
|
|
462
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
463
|
-
s = arguments[i];
|
|
464
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
465
|
-
}
|
|
466
|
-
return t;
|
|
467
|
-
};
|
|
468
|
-
return __assign.apply(this, arguments);
|
|
469
|
-
};
|
|
470
|
-
function __values(o) {
|
|
471
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
472
|
-
if (m) return m.call(o);
|
|
473
|
-
if (o && typeof o.length === "number") return {
|
|
474
|
-
next: function() {
|
|
475
|
-
if (o && i >= o.length) o = void 0;
|
|
476
|
-
return { value: o && o[i++], done: !o };
|
|
477
|
-
}
|
|
478
|
-
};
|
|
479
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
480
|
-
}
|
|
481
|
-
function __read(o, n) {
|
|
482
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
483
|
-
if (!m) return o;
|
|
484
|
-
var i = m.call(o), r, ar = [], e;
|
|
485
|
-
try {
|
|
486
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
487
|
-
} catch (error) {
|
|
488
|
-
e = { error };
|
|
489
|
-
} finally {
|
|
490
|
-
try {
|
|
491
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
492
|
-
} finally {
|
|
493
|
-
if (e) throw e.error;
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
return ar;
|
|
497
|
-
}
|
|
498
|
-
function __spreadArray(to, from, pack) {
|
|
499
|
-
if (arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
500
|
-
if (ar || !(i in from)) {
|
|
501
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
502
|
-
ar[i] = from[i];
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
506
|
-
}
|
|
507
|
-
typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
|
|
508
|
-
var e = new Error(message);
|
|
509
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
510
|
-
};
|
|
511
|
-
function isFunction(value) {
|
|
512
|
-
return typeof value === "function";
|
|
513
|
-
}
|
|
514
|
-
function createErrorClass(createImpl) {
|
|
515
|
-
var _super = function(instance) {
|
|
516
|
-
Error.call(instance);
|
|
517
|
-
instance.stack = new Error().stack;
|
|
518
|
-
};
|
|
519
|
-
var ctorFunc = createImpl(_super);
|
|
520
|
-
ctorFunc.prototype = Object.create(Error.prototype);
|
|
521
|
-
ctorFunc.prototype.constructor = ctorFunc;
|
|
522
|
-
return ctorFunc;
|
|
523
|
-
}
|
|
524
|
-
var UnsubscriptionError = createErrorClass(function(_super) {
|
|
525
|
-
return function UnsubscriptionErrorImpl(errors) {
|
|
526
|
-
_super(this);
|
|
527
|
-
this.message = errors ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function(err, i) {
|
|
528
|
-
return i + 1 + ") " + err.toString();
|
|
529
|
-
}).join("\n ") : "";
|
|
530
|
-
this.name = "UnsubscriptionError";
|
|
531
|
-
this.errors = errors;
|
|
532
|
-
};
|
|
533
|
-
});
|
|
534
|
-
function arrRemove(arr, item) {
|
|
535
|
-
if (arr) {
|
|
536
|
-
var index = arr.indexOf(item);
|
|
537
|
-
0 <= index && arr.splice(index, 1);
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
var Subscription = (function() {
|
|
541
|
-
function Subscription2(initialTeardown) {
|
|
542
|
-
this.initialTeardown = initialTeardown;
|
|
543
|
-
this.closed = false;
|
|
544
|
-
this._parentage = null;
|
|
545
|
-
this._finalizers = null;
|
|
546
|
-
}
|
|
547
|
-
Subscription2.prototype.unsubscribe = function() {
|
|
548
|
-
var e_1, _a, e_2, _b;
|
|
549
|
-
var errors;
|
|
550
|
-
if (!this.closed) {
|
|
551
|
-
this.closed = true;
|
|
552
|
-
var _parentage = this._parentage;
|
|
553
|
-
if (_parentage) {
|
|
554
|
-
this._parentage = null;
|
|
555
|
-
if (Array.isArray(_parentage)) {
|
|
556
|
-
try {
|
|
557
|
-
for (var _parentage_1 = __values(_parentage), _parentage_1_1 = _parentage_1.next(); !_parentage_1_1.done; _parentage_1_1 = _parentage_1.next()) {
|
|
558
|
-
var parent_1 = _parentage_1_1.value;
|
|
559
|
-
parent_1.remove(this);
|
|
560
|
-
}
|
|
561
|
-
} catch (e_1_1) {
|
|
562
|
-
e_1 = { error: e_1_1 };
|
|
563
|
-
} finally {
|
|
564
|
-
try {
|
|
565
|
-
if (_parentage_1_1 && !_parentage_1_1.done && (_a = _parentage_1.return)) _a.call(_parentage_1);
|
|
566
|
-
} finally {
|
|
567
|
-
if (e_1) throw e_1.error;
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
} else {
|
|
571
|
-
_parentage.remove(this);
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
var initialFinalizer = this.initialTeardown;
|
|
575
|
-
if (isFunction(initialFinalizer)) {
|
|
576
|
-
try {
|
|
577
|
-
initialFinalizer();
|
|
578
|
-
} catch (e) {
|
|
579
|
-
errors = e instanceof UnsubscriptionError ? e.errors : [e];
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
var _finalizers = this._finalizers;
|
|
583
|
-
if (_finalizers) {
|
|
584
|
-
this._finalizers = null;
|
|
585
|
-
try {
|
|
586
|
-
for (var _finalizers_1 = __values(_finalizers), _finalizers_1_1 = _finalizers_1.next(); !_finalizers_1_1.done; _finalizers_1_1 = _finalizers_1.next()) {
|
|
587
|
-
var finalizer = _finalizers_1_1.value;
|
|
588
|
-
try {
|
|
589
|
-
execFinalizer(finalizer);
|
|
590
|
-
} catch (err) {
|
|
591
|
-
errors = errors !== null && errors !== void 0 ? errors : [];
|
|
592
|
-
if (err instanceof UnsubscriptionError) {
|
|
593
|
-
errors = __spreadArray(__spreadArray([], __read(errors)), __read(err.errors));
|
|
594
|
-
} else {
|
|
595
|
-
errors.push(err);
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
} catch (e_2_1) {
|
|
600
|
-
e_2 = { error: e_2_1 };
|
|
601
|
-
} finally {
|
|
602
|
-
try {
|
|
603
|
-
if (_finalizers_1_1 && !_finalizers_1_1.done && (_b = _finalizers_1.return)) _b.call(_finalizers_1);
|
|
604
|
-
} finally {
|
|
605
|
-
if (e_2) throw e_2.error;
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
if (errors) {
|
|
610
|
-
throw new UnsubscriptionError(errors);
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
};
|
|
614
|
-
Subscription2.prototype.add = function(teardown) {
|
|
615
|
-
var _a;
|
|
616
|
-
if (teardown && teardown !== this) {
|
|
617
|
-
if (this.closed) {
|
|
618
|
-
execFinalizer(teardown);
|
|
619
|
-
} else {
|
|
620
|
-
if (teardown instanceof Subscription2) {
|
|
621
|
-
if (teardown.closed || teardown._hasParent(this)) {
|
|
622
|
-
return;
|
|
623
|
-
}
|
|
624
|
-
teardown._addParent(this);
|
|
625
|
-
}
|
|
626
|
-
(this._finalizers = (_a = this._finalizers) !== null && _a !== void 0 ? _a : []).push(teardown);
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
};
|
|
630
|
-
Subscription2.prototype._hasParent = function(parent) {
|
|
631
|
-
var _parentage = this._parentage;
|
|
632
|
-
return _parentage === parent || Array.isArray(_parentage) && _parentage.includes(parent);
|
|
633
|
-
};
|
|
634
|
-
Subscription2.prototype._addParent = function(parent) {
|
|
635
|
-
var _parentage = this._parentage;
|
|
636
|
-
this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;
|
|
637
|
-
};
|
|
638
|
-
Subscription2.prototype._removeParent = function(parent) {
|
|
639
|
-
var _parentage = this._parentage;
|
|
640
|
-
if (_parentage === parent) {
|
|
641
|
-
this._parentage = null;
|
|
642
|
-
} else if (Array.isArray(_parentage)) {
|
|
643
|
-
arrRemove(_parentage, parent);
|
|
644
|
-
}
|
|
645
|
-
};
|
|
646
|
-
Subscription2.prototype.remove = function(teardown) {
|
|
647
|
-
var _finalizers = this._finalizers;
|
|
648
|
-
_finalizers && arrRemove(_finalizers, teardown);
|
|
649
|
-
if (teardown instanceof Subscription2) {
|
|
650
|
-
teardown._removeParent(this);
|
|
651
|
-
}
|
|
652
|
-
};
|
|
653
|
-
Subscription2.EMPTY = (function() {
|
|
654
|
-
var empty = new Subscription2();
|
|
655
|
-
empty.closed = true;
|
|
656
|
-
return empty;
|
|
657
|
-
})();
|
|
658
|
-
return Subscription2;
|
|
659
|
-
})();
|
|
660
|
-
var EMPTY_SUBSCRIPTION = Subscription.EMPTY;
|
|
661
|
-
function isSubscription(value) {
|
|
662
|
-
return value instanceof Subscription || value && "closed" in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe);
|
|
663
|
-
}
|
|
664
|
-
function execFinalizer(finalizer) {
|
|
665
|
-
if (isFunction(finalizer)) {
|
|
666
|
-
finalizer();
|
|
667
|
-
} else {
|
|
668
|
-
finalizer.unsubscribe();
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
var config = {
|
|
672
|
-
Promise: void 0
|
|
673
|
-
};
|
|
674
|
-
var timeoutProvider = {
|
|
675
|
-
setTimeout: function(handler, timeout) {
|
|
676
|
-
var args = [];
|
|
677
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
678
|
-
args[_i - 2] = arguments[_i];
|
|
679
|
-
}
|
|
680
|
-
return setTimeout.apply(void 0, __spreadArray([handler, timeout], __read(args)));
|
|
681
|
-
},
|
|
682
|
-
clearTimeout: function(handle) {
|
|
683
|
-
return clearTimeout(handle);
|
|
684
|
-
},
|
|
685
|
-
delegate: void 0
|
|
686
|
-
};
|
|
687
|
-
function reportUnhandledError(err) {
|
|
688
|
-
timeoutProvider.setTimeout(function() {
|
|
689
|
-
{
|
|
690
|
-
throw err;
|
|
691
|
-
}
|
|
692
|
-
});
|
|
693
|
-
}
|
|
694
|
-
function noop() {
|
|
695
|
-
}
|
|
696
|
-
function errorContext(cb) {
|
|
697
|
-
{
|
|
698
|
-
cb();
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
var Subscriber = (function(_super) {
|
|
702
|
-
__extends(Subscriber2, _super);
|
|
703
|
-
function Subscriber2(destination) {
|
|
704
|
-
var _this = _super.call(this) || this;
|
|
705
|
-
_this.isStopped = false;
|
|
706
|
-
if (destination) {
|
|
707
|
-
_this.destination = destination;
|
|
708
|
-
if (isSubscription(destination)) {
|
|
709
|
-
destination.add(_this);
|
|
710
|
-
}
|
|
711
|
-
} else {
|
|
712
|
-
_this.destination = EMPTY_OBSERVER;
|
|
713
|
-
}
|
|
714
|
-
return _this;
|
|
715
|
-
}
|
|
716
|
-
Subscriber2.create = function(next, error, complete) {
|
|
717
|
-
return new SafeSubscriber(next, error, complete);
|
|
718
|
-
};
|
|
719
|
-
Subscriber2.prototype.next = function(value) {
|
|
720
|
-
if (this.isStopped) ;
|
|
721
|
-
else {
|
|
722
|
-
this._next(value);
|
|
723
|
-
}
|
|
724
|
-
};
|
|
725
|
-
Subscriber2.prototype.error = function(err) {
|
|
726
|
-
if (this.isStopped) ;
|
|
727
|
-
else {
|
|
728
|
-
this.isStopped = true;
|
|
729
|
-
this._error(err);
|
|
730
|
-
}
|
|
731
|
-
};
|
|
732
|
-
Subscriber2.prototype.complete = function() {
|
|
733
|
-
if (this.isStopped) ;
|
|
734
|
-
else {
|
|
735
|
-
this.isStopped = true;
|
|
736
|
-
this._complete();
|
|
737
|
-
}
|
|
738
|
-
};
|
|
739
|
-
Subscriber2.prototype.unsubscribe = function() {
|
|
740
|
-
if (!this.closed) {
|
|
741
|
-
this.isStopped = true;
|
|
742
|
-
_super.prototype.unsubscribe.call(this);
|
|
743
|
-
this.destination = null;
|
|
744
|
-
}
|
|
745
|
-
};
|
|
746
|
-
Subscriber2.prototype._next = function(value) {
|
|
747
|
-
this.destination.next(value);
|
|
748
|
-
};
|
|
749
|
-
Subscriber2.prototype._error = function(err) {
|
|
750
|
-
try {
|
|
751
|
-
this.destination.error(err);
|
|
752
|
-
} finally {
|
|
753
|
-
this.unsubscribe();
|
|
754
|
-
}
|
|
755
|
-
};
|
|
756
|
-
Subscriber2.prototype._complete = function() {
|
|
757
|
-
try {
|
|
758
|
-
this.destination.complete();
|
|
759
|
-
} finally {
|
|
760
|
-
this.unsubscribe();
|
|
761
|
-
}
|
|
762
|
-
};
|
|
763
|
-
return Subscriber2;
|
|
764
|
-
})(Subscription);
|
|
765
|
-
var ConsumerObserver = (function() {
|
|
766
|
-
function ConsumerObserver2(partialObserver) {
|
|
767
|
-
this.partialObserver = partialObserver;
|
|
768
|
-
}
|
|
769
|
-
ConsumerObserver2.prototype.next = function(value) {
|
|
770
|
-
var partialObserver = this.partialObserver;
|
|
771
|
-
if (partialObserver.next) {
|
|
772
|
-
try {
|
|
773
|
-
partialObserver.next(value);
|
|
774
|
-
} catch (error) {
|
|
775
|
-
handleUnhandledError(error);
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
};
|
|
779
|
-
ConsumerObserver2.prototype.error = function(err) {
|
|
780
|
-
var partialObserver = this.partialObserver;
|
|
781
|
-
if (partialObserver.error) {
|
|
782
|
-
try {
|
|
783
|
-
partialObserver.error(err);
|
|
784
|
-
} catch (error) {
|
|
785
|
-
handleUnhandledError(error);
|
|
786
|
-
}
|
|
787
|
-
} else {
|
|
788
|
-
handleUnhandledError(err);
|
|
789
|
-
}
|
|
790
|
-
};
|
|
791
|
-
ConsumerObserver2.prototype.complete = function() {
|
|
792
|
-
var partialObserver = this.partialObserver;
|
|
793
|
-
if (partialObserver.complete) {
|
|
794
|
-
try {
|
|
795
|
-
partialObserver.complete();
|
|
796
|
-
} catch (error) {
|
|
797
|
-
handleUnhandledError(error);
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
};
|
|
801
|
-
return ConsumerObserver2;
|
|
802
|
-
})();
|
|
803
|
-
var SafeSubscriber = (function(_super) {
|
|
804
|
-
__extends(SafeSubscriber2, _super);
|
|
805
|
-
function SafeSubscriber2(observerOrNext, error, complete) {
|
|
806
|
-
var _this = _super.call(this) || this;
|
|
807
|
-
var partialObserver;
|
|
808
|
-
if (isFunction(observerOrNext) || !observerOrNext) {
|
|
809
|
-
partialObserver = {
|
|
810
|
-
next: observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : void 0,
|
|
811
|
-
error: error !== null && error !== void 0 ? error : void 0,
|
|
812
|
-
complete: complete !== null && complete !== void 0 ? complete : void 0
|
|
813
|
-
};
|
|
814
|
-
} else {
|
|
815
|
-
{
|
|
816
|
-
partialObserver = observerOrNext;
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
_this.destination = new ConsumerObserver(partialObserver);
|
|
820
|
-
return _this;
|
|
821
|
-
}
|
|
822
|
-
return SafeSubscriber2;
|
|
823
|
-
})(Subscriber);
|
|
824
|
-
function handleUnhandledError(error) {
|
|
825
|
-
{
|
|
826
|
-
reportUnhandledError(error);
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
function defaultErrorHandler(err) {
|
|
830
|
-
throw err;
|
|
831
|
-
}
|
|
832
|
-
var EMPTY_OBSERVER = {
|
|
833
|
-
closed: true,
|
|
834
|
-
next: noop,
|
|
835
|
-
error: defaultErrorHandler,
|
|
836
|
-
complete: noop
|
|
837
|
-
};
|
|
838
|
-
var observable = (function() {
|
|
839
|
-
return typeof Symbol === "function" && Symbol.observable || "@@observable";
|
|
840
|
-
})();
|
|
841
|
-
function identity(x) {
|
|
842
|
-
return x;
|
|
843
|
-
}
|
|
844
|
-
function pipeFromArray(fns) {
|
|
845
|
-
if (fns.length === 0) {
|
|
846
|
-
return identity;
|
|
847
|
-
}
|
|
848
|
-
if (fns.length === 1) {
|
|
849
|
-
return fns[0];
|
|
850
|
-
}
|
|
851
|
-
return function piped(input) {
|
|
852
|
-
return fns.reduce(function(prev, fn) {
|
|
853
|
-
return fn(prev);
|
|
854
|
-
}, input);
|
|
855
|
-
};
|
|
856
|
-
}
|
|
857
|
-
var Observable = (function() {
|
|
858
|
-
function Observable2(subscribe) {
|
|
859
|
-
if (subscribe) {
|
|
860
|
-
this._subscribe = subscribe;
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
Observable2.prototype.lift = function(operator) {
|
|
864
|
-
var observable2 = new Observable2();
|
|
865
|
-
observable2.source = this;
|
|
866
|
-
observable2.operator = operator;
|
|
867
|
-
return observable2;
|
|
868
|
-
};
|
|
869
|
-
Observable2.prototype.subscribe = function(observerOrNext, error, complete) {
|
|
870
|
-
var _this = this;
|
|
871
|
-
var subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);
|
|
872
|
-
errorContext(function() {
|
|
873
|
-
var _a = _this, operator = _a.operator, source = _a.source;
|
|
874
|
-
subscriber.add(operator ? operator.call(subscriber, source) : source ? _this._subscribe(subscriber) : _this._trySubscribe(subscriber));
|
|
875
|
-
});
|
|
876
|
-
return subscriber;
|
|
877
|
-
};
|
|
878
|
-
Observable2.prototype._trySubscribe = function(sink) {
|
|
879
|
-
try {
|
|
880
|
-
return this._subscribe(sink);
|
|
881
|
-
} catch (err) {
|
|
882
|
-
sink.error(err);
|
|
883
|
-
}
|
|
884
|
-
};
|
|
885
|
-
Observable2.prototype.forEach = function(next, promiseCtor) {
|
|
886
|
-
var _this = this;
|
|
887
|
-
promiseCtor = getPromiseCtor(promiseCtor);
|
|
888
|
-
return new promiseCtor(function(resolve, reject) {
|
|
889
|
-
var subscriber = new SafeSubscriber({
|
|
890
|
-
next: function(value) {
|
|
891
|
-
try {
|
|
892
|
-
next(value);
|
|
893
|
-
} catch (err) {
|
|
894
|
-
reject(err);
|
|
895
|
-
subscriber.unsubscribe();
|
|
896
|
-
}
|
|
897
|
-
},
|
|
898
|
-
error: reject,
|
|
899
|
-
complete: resolve
|
|
900
|
-
});
|
|
901
|
-
_this.subscribe(subscriber);
|
|
902
|
-
});
|
|
903
|
-
};
|
|
904
|
-
Observable2.prototype._subscribe = function(subscriber) {
|
|
905
|
-
var _a;
|
|
906
|
-
return (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber);
|
|
907
|
-
};
|
|
908
|
-
Observable2.prototype[observable] = function() {
|
|
909
|
-
return this;
|
|
910
|
-
};
|
|
911
|
-
Observable2.prototype.pipe = function() {
|
|
912
|
-
var operations = [];
|
|
913
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
914
|
-
operations[_i] = arguments[_i];
|
|
915
|
-
}
|
|
916
|
-
return pipeFromArray(operations)(this);
|
|
917
|
-
};
|
|
918
|
-
Observable2.prototype.toPromise = function(promiseCtor) {
|
|
919
|
-
var _this = this;
|
|
920
|
-
promiseCtor = getPromiseCtor(promiseCtor);
|
|
921
|
-
return new promiseCtor(function(resolve, reject) {
|
|
922
|
-
var value;
|
|
923
|
-
_this.subscribe(function(x) {
|
|
924
|
-
return value = x;
|
|
925
|
-
}, function(err) {
|
|
926
|
-
return reject(err);
|
|
927
|
-
}, function() {
|
|
928
|
-
return resolve(value);
|
|
929
|
-
});
|
|
930
|
-
});
|
|
931
|
-
};
|
|
932
|
-
Observable2.create = function(subscribe) {
|
|
933
|
-
return new Observable2(subscribe);
|
|
934
|
-
};
|
|
935
|
-
return Observable2;
|
|
936
|
-
})();
|
|
937
|
-
function getPromiseCtor(promiseCtor) {
|
|
938
|
-
var _a;
|
|
939
|
-
return (_a = promiseCtor !== null && promiseCtor !== void 0 ? promiseCtor : config.Promise) !== null && _a !== void 0 ? _a : Promise;
|
|
940
|
-
}
|
|
941
|
-
function isObserver(value) {
|
|
942
|
-
return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);
|
|
943
|
-
}
|
|
944
|
-
function isSubscriber(value) {
|
|
945
|
-
return value && value instanceof Subscriber || isObserver(value) && isSubscription(value);
|
|
946
|
-
}
|
|
947
|
-
var ObjectUnsubscribedError = createErrorClass(function(_super) {
|
|
948
|
-
return function ObjectUnsubscribedErrorImpl() {
|
|
949
|
-
_super(this);
|
|
950
|
-
this.name = "ObjectUnsubscribedError";
|
|
951
|
-
this.message = "object unsubscribed";
|
|
952
|
-
};
|
|
953
|
-
});
|
|
954
|
-
var Subject = (function(_super) {
|
|
955
|
-
__extends(Subject2, _super);
|
|
956
|
-
function Subject2() {
|
|
957
|
-
var _this = _super.call(this) || this;
|
|
958
|
-
_this.closed = false;
|
|
959
|
-
_this.currentObservers = null;
|
|
960
|
-
_this.observers = [];
|
|
961
|
-
_this.isStopped = false;
|
|
962
|
-
_this.hasError = false;
|
|
963
|
-
_this.thrownError = null;
|
|
964
|
-
return _this;
|
|
965
|
-
}
|
|
966
|
-
Subject2.prototype.lift = function(operator) {
|
|
967
|
-
var subject = new AnonymousSubject(this, this);
|
|
968
|
-
subject.operator = operator;
|
|
969
|
-
return subject;
|
|
970
|
-
};
|
|
971
|
-
Subject2.prototype._throwIfClosed = function() {
|
|
972
|
-
if (this.closed) {
|
|
973
|
-
throw new ObjectUnsubscribedError();
|
|
974
|
-
}
|
|
975
|
-
};
|
|
976
|
-
Subject2.prototype.next = function(value) {
|
|
977
|
-
var _this = this;
|
|
978
|
-
errorContext(function() {
|
|
979
|
-
var e_1, _a;
|
|
980
|
-
_this._throwIfClosed();
|
|
981
|
-
if (!_this.isStopped) {
|
|
982
|
-
if (!_this.currentObservers) {
|
|
983
|
-
_this.currentObservers = Array.from(_this.observers);
|
|
984
|
-
}
|
|
985
|
-
try {
|
|
986
|
-
for (var _b = __values(_this.currentObservers), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
987
|
-
var observer = _c.value;
|
|
988
|
-
observer.next(value);
|
|
989
|
-
}
|
|
990
|
-
} catch (e_1_1) {
|
|
991
|
-
e_1 = { error: e_1_1 };
|
|
992
|
-
} finally {
|
|
993
|
-
try {
|
|
994
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
995
|
-
} finally {
|
|
996
|
-
if (e_1) throw e_1.error;
|
|
997
|
-
}
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
});
|
|
1001
|
-
};
|
|
1002
|
-
Subject2.prototype.error = function(err) {
|
|
1003
|
-
var _this = this;
|
|
1004
|
-
errorContext(function() {
|
|
1005
|
-
_this._throwIfClosed();
|
|
1006
|
-
if (!_this.isStopped) {
|
|
1007
|
-
_this.hasError = _this.isStopped = true;
|
|
1008
|
-
_this.thrownError = err;
|
|
1009
|
-
var observers = _this.observers;
|
|
1010
|
-
while (observers.length) {
|
|
1011
|
-
observers.shift().error(err);
|
|
1012
|
-
}
|
|
1013
|
-
}
|
|
1014
|
-
});
|
|
1015
|
-
};
|
|
1016
|
-
Subject2.prototype.complete = function() {
|
|
1017
|
-
var _this = this;
|
|
1018
|
-
errorContext(function() {
|
|
1019
|
-
_this._throwIfClosed();
|
|
1020
|
-
if (!_this.isStopped) {
|
|
1021
|
-
_this.isStopped = true;
|
|
1022
|
-
var observers = _this.observers;
|
|
1023
|
-
while (observers.length) {
|
|
1024
|
-
observers.shift().complete();
|
|
1025
|
-
}
|
|
1026
|
-
}
|
|
1027
|
-
});
|
|
1028
|
-
};
|
|
1029
|
-
Subject2.prototype.unsubscribe = function() {
|
|
1030
|
-
this.isStopped = this.closed = true;
|
|
1031
|
-
this.observers = this.currentObservers = null;
|
|
1032
|
-
};
|
|
1033
|
-
Object.defineProperty(Subject2.prototype, "observed", {
|
|
1034
|
-
get: function() {
|
|
1035
|
-
var _a;
|
|
1036
|
-
return ((_a = this.observers) === null || _a === void 0 ? void 0 : _a.length) > 0;
|
|
1037
|
-
},
|
|
1038
|
-
enumerable: false,
|
|
1039
|
-
configurable: true
|
|
1040
|
-
});
|
|
1041
|
-
Subject2.prototype._trySubscribe = function(subscriber) {
|
|
1042
|
-
this._throwIfClosed();
|
|
1043
|
-
return _super.prototype._trySubscribe.call(this, subscriber);
|
|
1044
|
-
};
|
|
1045
|
-
Subject2.prototype._subscribe = function(subscriber) {
|
|
1046
|
-
this._throwIfClosed();
|
|
1047
|
-
this._checkFinalizedStatuses(subscriber);
|
|
1048
|
-
return this._innerSubscribe(subscriber);
|
|
1049
|
-
};
|
|
1050
|
-
Subject2.prototype._innerSubscribe = function(subscriber) {
|
|
1051
|
-
var _this = this;
|
|
1052
|
-
var _a = this, hasError = _a.hasError, isStopped = _a.isStopped, observers = _a.observers;
|
|
1053
|
-
if (hasError || isStopped) {
|
|
1054
|
-
return EMPTY_SUBSCRIPTION;
|
|
1055
|
-
}
|
|
1056
|
-
this.currentObservers = null;
|
|
1057
|
-
observers.push(subscriber);
|
|
1058
|
-
return new Subscription(function() {
|
|
1059
|
-
_this.currentObservers = null;
|
|
1060
|
-
arrRemove(observers, subscriber);
|
|
1061
|
-
});
|
|
1062
|
-
};
|
|
1063
|
-
Subject2.prototype._checkFinalizedStatuses = function(subscriber) {
|
|
1064
|
-
var _a = this, hasError = _a.hasError, thrownError = _a.thrownError, isStopped = _a.isStopped;
|
|
1065
|
-
if (hasError) {
|
|
1066
|
-
subscriber.error(thrownError);
|
|
1067
|
-
} else if (isStopped) {
|
|
1068
|
-
subscriber.complete();
|
|
1069
|
-
}
|
|
1070
|
-
};
|
|
1071
|
-
Subject2.prototype.asObservable = function() {
|
|
1072
|
-
var observable2 = new Observable();
|
|
1073
|
-
observable2.source = this;
|
|
1074
|
-
return observable2;
|
|
1075
|
-
};
|
|
1076
|
-
Subject2.create = function(destination, source) {
|
|
1077
|
-
return new AnonymousSubject(destination, source);
|
|
1078
|
-
};
|
|
1079
|
-
return Subject2;
|
|
1080
|
-
})(Observable);
|
|
1081
|
-
var AnonymousSubject = (function(_super) {
|
|
1082
|
-
__extends(AnonymousSubject2, _super);
|
|
1083
|
-
function AnonymousSubject2(destination, source) {
|
|
1084
|
-
var _this = _super.call(this) || this;
|
|
1085
|
-
_this.destination = destination;
|
|
1086
|
-
_this.source = source;
|
|
1087
|
-
return _this;
|
|
1088
|
-
}
|
|
1089
|
-
AnonymousSubject2.prototype.next = function(value) {
|
|
1090
|
-
var _a, _b;
|
|
1091
|
-
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.next) === null || _b === void 0 ? void 0 : _b.call(_a, value);
|
|
1092
|
-
};
|
|
1093
|
-
AnonymousSubject2.prototype.error = function(err) {
|
|
1094
|
-
var _a, _b;
|
|
1095
|
-
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.call(_a, err);
|
|
1096
|
-
};
|
|
1097
|
-
AnonymousSubject2.prototype.complete = function() {
|
|
1098
|
-
var _a, _b;
|
|
1099
|
-
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.complete) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
1100
|
-
};
|
|
1101
|
-
AnonymousSubject2.prototype._subscribe = function(subscriber) {
|
|
1102
|
-
var _a, _b;
|
|
1103
|
-
return (_b = (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber)) !== null && _b !== void 0 ? _b : EMPTY_SUBSCRIPTION;
|
|
1104
|
-
};
|
|
1105
|
-
return AnonymousSubject2;
|
|
1106
|
-
})(Subject);
|
|
1107
|
-
var dateTimestampProvider = {
|
|
1108
|
-
now: function() {
|
|
1109
|
-
return (dateTimestampProvider.delegate || Date).now();
|
|
1110
|
-
},
|
|
1111
|
-
delegate: void 0
|
|
1112
|
-
};
|
|
1113
|
-
var ReplaySubject = (function(_super) {
|
|
1114
|
-
__extends(ReplaySubject2, _super);
|
|
1115
|
-
function ReplaySubject2(_bufferSize, _windowTime, _timestampProvider) {
|
|
1116
|
-
if (_bufferSize === void 0) {
|
|
1117
|
-
_bufferSize = Infinity;
|
|
1118
|
-
}
|
|
1119
|
-
if (_windowTime === void 0) {
|
|
1120
|
-
_windowTime = Infinity;
|
|
1121
|
-
}
|
|
1122
|
-
if (_timestampProvider === void 0) {
|
|
1123
|
-
_timestampProvider = dateTimestampProvider;
|
|
1124
|
-
}
|
|
1125
|
-
var _this = _super.call(this) || this;
|
|
1126
|
-
_this._bufferSize = _bufferSize;
|
|
1127
|
-
_this._windowTime = _windowTime;
|
|
1128
|
-
_this._timestampProvider = _timestampProvider;
|
|
1129
|
-
_this._buffer = [];
|
|
1130
|
-
_this._infiniteTimeWindow = true;
|
|
1131
|
-
_this._infiniteTimeWindow = _windowTime === Infinity;
|
|
1132
|
-
_this._bufferSize = Math.max(1, _bufferSize);
|
|
1133
|
-
_this._windowTime = Math.max(1, _windowTime);
|
|
1134
|
-
return _this;
|
|
1135
|
-
}
|
|
1136
|
-
ReplaySubject2.prototype.next = function(value) {
|
|
1137
|
-
var _a = this, isStopped = _a.isStopped, _buffer = _a._buffer, _infiniteTimeWindow = _a._infiniteTimeWindow, _timestampProvider = _a._timestampProvider, _windowTime = _a._windowTime;
|
|
1138
|
-
if (!isStopped) {
|
|
1139
|
-
_buffer.push(value);
|
|
1140
|
-
!_infiniteTimeWindow && _buffer.push(_timestampProvider.now() + _windowTime);
|
|
1141
|
-
}
|
|
1142
|
-
this._trimBuffer();
|
|
1143
|
-
_super.prototype.next.call(this, value);
|
|
1144
|
-
};
|
|
1145
|
-
ReplaySubject2.prototype._subscribe = function(subscriber) {
|
|
1146
|
-
this._throwIfClosed();
|
|
1147
|
-
this._trimBuffer();
|
|
1148
|
-
var subscription = this._innerSubscribe(subscriber);
|
|
1149
|
-
var _a = this, _infiniteTimeWindow = _a._infiniteTimeWindow, _buffer = _a._buffer;
|
|
1150
|
-
var copy = _buffer.slice();
|
|
1151
|
-
for (var i = 0; i < copy.length && !subscriber.closed; i += _infiniteTimeWindow ? 1 : 2) {
|
|
1152
|
-
subscriber.next(copy[i]);
|
|
1153
|
-
}
|
|
1154
|
-
this._checkFinalizedStatuses(subscriber);
|
|
1155
|
-
return subscription;
|
|
1156
|
-
};
|
|
1157
|
-
ReplaySubject2.prototype._trimBuffer = function() {
|
|
1158
|
-
var _a = this, _bufferSize = _a._bufferSize, _timestampProvider = _a._timestampProvider, _buffer = _a._buffer, _infiniteTimeWindow = _a._infiniteTimeWindow;
|
|
1159
|
-
var adjustedBufferSize = (_infiniteTimeWindow ? 1 : 2) * _bufferSize;
|
|
1160
|
-
_bufferSize < Infinity && adjustedBufferSize < _buffer.length && _buffer.splice(0, _buffer.length - adjustedBufferSize);
|
|
1161
|
-
if (!_infiniteTimeWindow) {
|
|
1162
|
-
var now = _timestampProvider.now();
|
|
1163
|
-
var last = 0;
|
|
1164
|
-
for (var i = 1; i < _buffer.length && _buffer[i] <= now; i += 2) {
|
|
1165
|
-
last = i;
|
|
1166
|
-
}
|
|
1167
|
-
last && _buffer.splice(0, last + 1);
|
|
1168
|
-
}
|
|
1169
|
-
};
|
|
1170
|
-
return ReplaySubject2;
|
|
1171
|
-
})(Subject);
|
|
1172
|
-
var DEFAULT_WEBSOCKET_CONFIG = {
|
|
1173
|
-
url: "",
|
|
1174
|
-
deserializer: function(e) {
|
|
1175
|
-
return JSON.parse(e.data);
|
|
1176
|
-
},
|
|
1177
|
-
serializer: function(value) {
|
|
1178
|
-
return JSON.stringify(value);
|
|
1179
|
-
}
|
|
1180
|
-
};
|
|
1181
|
-
var WEBSOCKETSUBJECT_INVALID_ERROR_OBJECT = "WebSocketSubject.error must be called with an object with an error code, and an optional reason: { code: number, reason: string }";
|
|
1182
|
-
var WebSocketSubject = (function(_super) {
|
|
1183
|
-
__extends(WebSocketSubject2, _super);
|
|
1184
|
-
function WebSocketSubject2(urlConfigOrSource, destination) {
|
|
1185
|
-
var _this = _super.call(this) || this;
|
|
1186
|
-
_this._socket = null;
|
|
1187
|
-
if (urlConfigOrSource instanceof Observable) {
|
|
1188
|
-
_this.destination = destination;
|
|
1189
|
-
_this.source = urlConfigOrSource;
|
|
1190
|
-
} else {
|
|
1191
|
-
var config2 = _this._config = __assign({}, DEFAULT_WEBSOCKET_CONFIG);
|
|
1192
|
-
_this._output = new Subject();
|
|
1193
|
-
if (typeof urlConfigOrSource === "string") {
|
|
1194
|
-
config2.url = urlConfigOrSource;
|
|
1195
|
-
} else {
|
|
1196
|
-
for (var key in urlConfigOrSource) {
|
|
1197
|
-
if (urlConfigOrSource.hasOwnProperty(key)) {
|
|
1198
|
-
config2[key] = urlConfigOrSource[key];
|
|
1199
|
-
}
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
|
-
if (!config2.WebSocketCtor && WebSocket) {
|
|
1203
|
-
config2.WebSocketCtor = WebSocket;
|
|
1204
|
-
} else if (!config2.WebSocketCtor) {
|
|
1205
|
-
throw new Error("no WebSocket constructor can be found");
|
|
1206
|
-
}
|
|
1207
|
-
_this.destination = new ReplaySubject();
|
|
1208
|
-
}
|
|
1209
|
-
return _this;
|
|
1210
|
-
}
|
|
1211
|
-
WebSocketSubject2.prototype.lift = function(operator) {
|
|
1212
|
-
var sock = new WebSocketSubject2(this._config, this.destination);
|
|
1213
|
-
sock.operator = operator;
|
|
1214
|
-
sock.source = this;
|
|
1215
|
-
return sock;
|
|
1216
|
-
};
|
|
1217
|
-
WebSocketSubject2.prototype._resetState = function() {
|
|
1218
|
-
this._socket = null;
|
|
1219
|
-
if (!this.source) {
|
|
1220
|
-
this.destination = new ReplaySubject();
|
|
1221
|
-
}
|
|
1222
|
-
this._output = new Subject();
|
|
1223
|
-
};
|
|
1224
|
-
WebSocketSubject2.prototype.multiplex = function(subMsg, unsubMsg, messageFilter) {
|
|
1225
|
-
var self = this;
|
|
1226
|
-
return new Observable(function(observer) {
|
|
1227
|
-
try {
|
|
1228
|
-
self.next(subMsg());
|
|
1229
|
-
} catch (err) {
|
|
1230
|
-
observer.error(err);
|
|
1231
|
-
}
|
|
1232
|
-
var subscription = self.subscribe({
|
|
1233
|
-
next: function(x) {
|
|
1234
|
-
try {
|
|
1235
|
-
if (messageFilter(x)) {
|
|
1236
|
-
observer.next(x);
|
|
1237
|
-
}
|
|
1238
|
-
} catch (err) {
|
|
1239
|
-
observer.error(err);
|
|
1240
|
-
}
|
|
1241
|
-
},
|
|
1242
|
-
error: function(err) {
|
|
1243
|
-
return observer.error(err);
|
|
1244
|
-
},
|
|
1245
|
-
complete: function() {
|
|
1246
|
-
return observer.complete();
|
|
1247
|
-
}
|
|
1248
|
-
});
|
|
1249
|
-
return function() {
|
|
1250
|
-
try {
|
|
1251
|
-
self.next(unsubMsg());
|
|
1252
|
-
} catch (err) {
|
|
1253
|
-
observer.error(err);
|
|
1254
|
-
}
|
|
1255
|
-
subscription.unsubscribe();
|
|
1256
|
-
};
|
|
1257
|
-
});
|
|
1258
|
-
};
|
|
1259
|
-
WebSocketSubject2.prototype._connectSocket = function() {
|
|
1260
|
-
var _this = this;
|
|
1261
|
-
var _a = this._config, WebSocketCtor = _a.WebSocketCtor, protocol = _a.protocol, url = _a.url, binaryType = _a.binaryType;
|
|
1262
|
-
var observer = this._output;
|
|
1263
|
-
var socket = null;
|
|
1264
|
-
try {
|
|
1265
|
-
socket = protocol ? new WebSocketCtor(url, protocol) : new WebSocketCtor(url);
|
|
1266
|
-
this._socket = socket;
|
|
1267
|
-
if (binaryType) {
|
|
1268
|
-
this._socket.binaryType = binaryType;
|
|
1269
|
-
}
|
|
1270
|
-
} catch (e) {
|
|
1271
|
-
observer.error(e);
|
|
1272
|
-
return;
|
|
1273
|
-
}
|
|
1274
|
-
var subscription = new Subscription(function() {
|
|
1275
|
-
_this._socket = null;
|
|
1276
|
-
if (socket && socket.readyState === 1) {
|
|
1277
|
-
socket.close();
|
|
1278
|
-
}
|
|
1279
|
-
});
|
|
1280
|
-
socket.onopen = function(evt) {
|
|
1281
|
-
var _socket = _this._socket;
|
|
1282
|
-
if (!_socket) {
|
|
1283
|
-
socket.close();
|
|
1284
|
-
_this._resetState();
|
|
1285
|
-
return;
|
|
1286
|
-
}
|
|
1287
|
-
var openObserver = _this._config.openObserver;
|
|
1288
|
-
if (openObserver) {
|
|
1289
|
-
openObserver.next(evt);
|
|
1290
|
-
}
|
|
1291
|
-
var queue = _this.destination;
|
|
1292
|
-
_this.destination = Subscriber.create(function(x) {
|
|
1293
|
-
if (socket.readyState === 1) {
|
|
1294
|
-
try {
|
|
1295
|
-
var serializer = _this._config.serializer;
|
|
1296
|
-
socket.send(serializer(x));
|
|
1297
|
-
} catch (e) {
|
|
1298
|
-
_this.destination.error(e);
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
}, function(err) {
|
|
1302
|
-
var closingObserver = _this._config.closingObserver;
|
|
1303
|
-
if (closingObserver) {
|
|
1304
|
-
closingObserver.next(void 0);
|
|
1305
|
-
}
|
|
1306
|
-
if (err && err.code) {
|
|
1307
|
-
socket.close(err.code, err.reason);
|
|
1308
|
-
} else {
|
|
1309
|
-
observer.error(new TypeError(WEBSOCKETSUBJECT_INVALID_ERROR_OBJECT));
|
|
1310
|
-
}
|
|
1311
|
-
_this._resetState();
|
|
1312
|
-
}, function() {
|
|
1313
|
-
var closingObserver = _this._config.closingObserver;
|
|
1314
|
-
if (closingObserver) {
|
|
1315
|
-
closingObserver.next(void 0);
|
|
1316
|
-
}
|
|
1317
|
-
socket.close();
|
|
1318
|
-
_this._resetState();
|
|
1319
|
-
});
|
|
1320
|
-
if (queue && queue instanceof ReplaySubject) {
|
|
1321
|
-
subscription.add(queue.subscribe(_this.destination));
|
|
1322
|
-
}
|
|
1323
|
-
};
|
|
1324
|
-
socket.onerror = function(e) {
|
|
1325
|
-
_this._resetState();
|
|
1326
|
-
observer.error(e);
|
|
1327
|
-
};
|
|
1328
|
-
socket.onclose = function(e) {
|
|
1329
|
-
if (socket === _this._socket) {
|
|
1330
|
-
_this._resetState();
|
|
1331
|
-
}
|
|
1332
|
-
var closeObserver = _this._config.closeObserver;
|
|
1333
|
-
if (closeObserver) {
|
|
1334
|
-
closeObserver.next(e);
|
|
1335
|
-
}
|
|
1336
|
-
if (e.wasClean) {
|
|
1337
|
-
observer.complete();
|
|
1338
|
-
} else {
|
|
1339
|
-
observer.error(e);
|
|
1340
|
-
}
|
|
1341
|
-
};
|
|
1342
|
-
socket.onmessage = function(e) {
|
|
1343
|
-
try {
|
|
1344
|
-
var deserializer = _this._config.deserializer;
|
|
1345
|
-
observer.next(deserializer(e));
|
|
1346
|
-
} catch (err) {
|
|
1347
|
-
observer.error(err);
|
|
1348
|
-
}
|
|
1349
|
-
};
|
|
1350
|
-
};
|
|
1351
|
-
WebSocketSubject2.prototype._subscribe = function(subscriber) {
|
|
1352
|
-
var _this = this;
|
|
1353
|
-
var source = this.source;
|
|
1354
|
-
if (source) {
|
|
1355
|
-
return source.subscribe(subscriber);
|
|
1356
|
-
}
|
|
1357
|
-
if (!this._socket) {
|
|
1358
|
-
this._connectSocket();
|
|
1359
|
-
}
|
|
1360
|
-
this._output.subscribe(subscriber);
|
|
1361
|
-
subscriber.add(function() {
|
|
1362
|
-
var _socket = _this._socket;
|
|
1363
|
-
if (_this._output.observers.length === 0) {
|
|
1364
|
-
if (_socket && (_socket.readyState === 1 || _socket.readyState === 0)) {
|
|
1365
|
-
_socket.close();
|
|
1366
|
-
}
|
|
1367
|
-
_this._resetState();
|
|
1368
|
-
}
|
|
1369
|
-
});
|
|
1370
|
-
return subscriber;
|
|
1371
|
-
};
|
|
1372
|
-
WebSocketSubject2.prototype.unsubscribe = function() {
|
|
1373
|
-
var _socket = this._socket;
|
|
1374
|
-
if (_socket && (_socket.readyState === 1 || _socket.readyState === 0)) {
|
|
1375
|
-
_socket.close();
|
|
1376
|
-
}
|
|
1377
|
-
this._resetState();
|
|
1378
|
-
_super.prototype.unsubscribe.call(this);
|
|
1379
|
-
};
|
|
1380
|
-
return WebSocketSubject2;
|
|
1381
|
-
})(AnonymousSubject);
|
|
1382
|
-
function webSocket(urlConfigOrSource) {
|
|
1383
|
-
return new WebSocketSubject(urlConfigOrSource);
|
|
1384
|
-
}
|
|
1385
|
-
class WebsocketService extends BaseConnectionService {
|
|
1386
|
-
constructor(config2) {
|
|
1387
|
-
super();
|
|
1388
|
-
this.socket$ = null;
|
|
1389
|
-
this.wsConfig = config2;
|
|
1390
|
-
}
|
|
1391
|
-
get serviceName() {
|
|
1392
|
-
return "WS";
|
|
1393
|
-
}
|
|
1394
|
-
connect() {
|
|
1395
|
-
if (this.socket$) {
|
|
1396
|
-
return;
|
|
1397
|
-
}
|
|
1398
|
-
this.socket$ = webSocket({
|
|
1399
|
-
url: this.wsConfig.url,
|
|
1400
|
-
openObserver: {
|
|
1401
|
-
next: () => {
|
|
1402
|
-
console.log("[WS] Connected");
|
|
1403
|
-
this.connectionStatusSubject$.next(true);
|
|
1404
|
-
this.resetReconnectAttempts();
|
|
1405
|
-
this.sendMessage("INIT_CONNECTION");
|
|
1406
|
-
}
|
|
1407
|
-
},
|
|
1408
|
-
closeObserver: {
|
|
1409
|
-
next: (event) => {
|
|
1410
|
-
console.log("[WS] Closed:", event.code, event.reason);
|
|
1411
|
-
this.connectionStatusSubject$.next(false);
|
|
1412
|
-
this.socket$ = null;
|
|
1413
|
-
if (event.code !== 1e3 && event.reason !== "Closing duplicate connection") {
|
|
1414
|
-
this.scheduleReconnect(() => this.connect());
|
|
1415
|
-
}
|
|
1416
|
-
}
|
|
1417
|
-
}
|
|
1418
|
-
});
|
|
1419
|
-
this.socket$.pipe(
|
|
1420
|
-
operators.takeUntil(this.destroySubject$),
|
|
1421
|
-
operators.tap({
|
|
1422
|
-
error: (err) => {
|
|
1423
|
-
console.error("[WS] Error:", err);
|
|
1424
|
-
this.connectionStatusSubject$.next(false);
|
|
1425
|
-
}
|
|
1426
|
-
})
|
|
1427
|
-
).subscribe({
|
|
1428
|
-
next: (message) => {
|
|
1429
|
-
if (this.isIncomingMessage(message)) {
|
|
1430
|
-
this.messagesSubject$.next(message);
|
|
1431
|
-
}
|
|
1432
|
-
},
|
|
1433
|
-
error: (err) => console.error("[WS] Stream error:", err)
|
|
1434
|
-
});
|
|
1435
|
-
}
|
|
1436
|
-
isIncomingMessage(msg) {
|
|
1437
|
-
return "action" in msg && !("Authorization" in msg);
|
|
1438
|
-
}
|
|
1439
|
-
async sendMessage(action, payload) {
|
|
1440
|
-
if (!this.socket$ || !this.connectionStatusSubject$.value) {
|
|
1441
|
-
console.warn("[WS] Cannot send message - not connected");
|
|
1442
|
-
return;
|
|
1443
|
-
}
|
|
1444
|
-
try {
|
|
1445
|
-
if (!this.wsConfig.authProvider.isAuthenticated()) {
|
|
1446
|
-
console.warn(`[WS] Cannot send message - not authenticated for action: ${action}`);
|
|
1447
|
-
return;
|
|
1448
|
-
}
|
|
1449
|
-
const idToken = await this.wsConfig.authProvider.getIdToken();
|
|
1450
|
-
if (!idToken) {
|
|
1451
|
-
console.warn(`[WS] Cannot send message - no auth token available for action: ${action}`);
|
|
1452
|
-
return;
|
|
1453
|
-
}
|
|
1454
|
-
this.socket$.next({
|
|
1455
|
-
Authorization: idToken,
|
|
1456
|
-
action,
|
|
1457
|
-
payload
|
|
1458
|
-
});
|
|
1459
|
-
} catch (error) {
|
|
1460
|
-
console.error("[WS] Error sending message:", error);
|
|
1461
|
-
}
|
|
1462
|
-
}
|
|
1463
|
-
on(action) {
|
|
1464
|
-
return this.messages$.pipe(
|
|
1465
|
-
operators.filter((msg) => msg.action === action),
|
|
1466
|
-
operators.map((msg) => msg.payload)
|
|
1467
|
-
);
|
|
1468
|
-
}
|
|
1469
|
-
request(sendAction, responseAction, payload) {
|
|
1470
|
-
return new rxjs.Observable((subscriber) => {
|
|
1471
|
-
const sub = this.on(responseAction).pipe(operators.take(1)).subscribe(subscriber);
|
|
1472
|
-
this.sendMessage(sendAction, payload);
|
|
1473
|
-
return () => sub.unsubscribe();
|
|
1474
|
-
});
|
|
1475
|
-
}
|
|
1476
|
-
disconnect() {
|
|
1477
|
-
var _a;
|
|
1478
|
-
(_a = this.socket$) == null ? void 0 : _a.complete();
|
|
1479
|
-
this.socket$ = null;
|
|
1480
|
-
this.connectionStatusSubject$.next(false);
|
|
1481
|
-
this.resetReconnectAttempts();
|
|
1482
|
-
}
|
|
1483
|
-
destroy() {
|
|
1484
|
-
var _a;
|
|
1485
|
-
(_a = this.socket$) == null ? void 0 : _a.complete();
|
|
1486
|
-
this.socket$ = null;
|
|
1487
|
-
this.destroySubject$.next();
|
|
1488
|
-
this.destroySubject$.complete();
|
|
1489
|
-
this.messagesSubject$.complete();
|
|
1490
|
-
this.connectionStatusSubject$.complete();
|
|
1491
|
-
}
|
|
1492
|
-
}
|
|
1493
113
|
const LiveUpdateContext = react.createContext(null);
|
|
1494
114
|
const useLiveUpdateContext = () => {
|
|
1495
115
|
const context = react.useContext(LiveUpdateContext);
|
|
@@ -1509,15 +129,15 @@ const LiveUpdateProvider = ({
|
|
|
1509
129
|
}) => {
|
|
1510
130
|
const [isConnected, setIsConnected] = react.useState(false);
|
|
1511
131
|
const [service] = react.useState(() => {
|
|
1512
|
-
const sseService = new SSEService({
|
|
132
|
+
const sseService = new liveUpdates.SSEService({
|
|
1513
133
|
url: sseUrl,
|
|
1514
134
|
authProvider
|
|
1515
135
|
});
|
|
1516
|
-
const wsService = new WebsocketService({
|
|
136
|
+
const wsService = new liveUpdates.WebsocketService({
|
|
1517
137
|
url: wsUrl,
|
|
1518
138
|
authProvider
|
|
1519
139
|
});
|
|
1520
|
-
return new LiveUpdateService(wsService, sseService);
|
|
140
|
+
return new liveUpdates.LiveUpdateService(wsService, sseService);
|
|
1521
141
|
});
|
|
1522
142
|
react.useEffect(() => {
|
|
1523
143
|
if (authProvider.isAuthenticated()) {
|
|
@@ -1631,693 +251,8 @@ const useLiveUpdates = (eventName) => {
|
|
|
1631
251
|
}, [eventName, service]);
|
|
1632
252
|
return { data, error };
|
|
1633
253
|
};
|
|
1634
|
-
class ContentModel {
|
|
1635
|
-
constructor(doc) {
|
|
1636
|
-
this.document = doc || this.createEmptyDocument();
|
|
1637
|
-
}
|
|
1638
|
-
/**
|
|
1639
|
-
* Create empty document with single empty paragraph
|
|
1640
|
-
*/
|
|
1641
|
-
static createEmpty() {
|
|
1642
|
-
return {
|
|
1643
|
-
type: "document",
|
|
1644
|
-
version: "1.0",
|
|
1645
|
-
children: [
|
|
1646
|
-
{
|
|
1647
|
-
type: "paragraph",
|
|
1648
|
-
children: [{ type: "text", text: "" }]
|
|
1649
|
-
}
|
|
1650
|
-
]
|
|
1651
|
-
};
|
|
1652
|
-
}
|
|
1653
|
-
/**
|
|
1654
|
-
* Get the current document
|
|
1655
|
-
*/
|
|
1656
|
-
getDocument() {
|
|
1657
|
-
return JSON.parse(JSON.stringify(this.document));
|
|
1658
|
-
}
|
|
1659
|
-
/**
|
|
1660
|
-
* Replace entire document
|
|
1661
|
-
*/
|
|
1662
|
-
setDocument(doc) {
|
|
1663
|
-
this.document = JSON.parse(JSON.stringify(doc));
|
|
1664
|
-
}
|
|
1665
|
-
/**
|
|
1666
|
-
* Get all text content as plain string
|
|
1667
|
-
*/
|
|
1668
|
-
getPlainText() {
|
|
1669
|
-
let text = "";
|
|
1670
|
-
const traverse = (node) => {
|
|
1671
|
-
if (node.type === "text") {
|
|
1672
|
-
text += node.text;
|
|
1673
|
-
} else if ("children" in node) {
|
|
1674
|
-
node.children.forEach(traverse);
|
|
1675
|
-
} else if (node.type === "image") {
|
|
1676
|
-
text += "[Image]";
|
|
1677
|
-
} else if (node.type === "mention") {
|
|
1678
|
-
text += `@${node.label}`;
|
|
1679
|
-
}
|
|
1680
|
-
};
|
|
1681
|
-
this.document.children.forEach(traverse);
|
|
1682
|
-
return text;
|
|
1683
|
-
}
|
|
1684
|
-
/**
|
|
1685
|
-
* Insert text at selection/cursor position
|
|
1686
|
-
*/
|
|
1687
|
-
insertText(text, marks) {
|
|
1688
|
-
const doc = this.cloneDocument();
|
|
1689
|
-
const firstPara = this.getFirstParagraph(doc);
|
|
1690
|
-
if (firstPara && firstPara.children.length > 0) {
|
|
1691
|
-
const firstChild = firstPara.children[0];
|
|
1692
|
-
if (firstChild.type === "text") {
|
|
1693
|
-
firstChild.text += text;
|
|
1694
|
-
if (marks) {
|
|
1695
|
-
firstChild.marks = marks;
|
|
1696
|
-
}
|
|
1697
|
-
}
|
|
1698
|
-
}
|
|
1699
|
-
return doc;
|
|
1700
|
-
}
|
|
1701
|
-
/**
|
|
1702
|
-
* Insert a paragraph at the end
|
|
1703
|
-
*/
|
|
1704
|
-
insertParagraph(content) {
|
|
1705
|
-
const doc = this.cloneDocument();
|
|
1706
|
-
doc.children.push({
|
|
1707
|
-
type: "paragraph",
|
|
1708
|
-
children: content || [{ type: "text", text: "" }]
|
|
1709
|
-
});
|
|
1710
|
-
return doc;
|
|
1711
|
-
}
|
|
1712
|
-
/**
|
|
1713
|
-
* Insert heading
|
|
1714
|
-
*/
|
|
1715
|
-
insertHeading(level, content) {
|
|
1716
|
-
const doc = this.cloneDocument();
|
|
1717
|
-
doc.children.push({
|
|
1718
|
-
type: "heading",
|
|
1719
|
-
level,
|
|
1720
|
-
children: content || [{ type: "text", text: "" }]
|
|
1721
|
-
});
|
|
1722
|
-
return doc;
|
|
1723
|
-
}
|
|
1724
|
-
/**
|
|
1725
|
-
* Insert image
|
|
1726
|
-
*/
|
|
1727
|
-
insertImage(url, attrs) {
|
|
1728
|
-
const doc = this.cloneDocument();
|
|
1729
|
-
const lastBlock = doc.children[doc.children.length - 1];
|
|
1730
|
-
if ((attrs == null ? void 0 : attrs.display) === "block") {
|
|
1731
|
-
doc.children.push({
|
|
1732
|
-
type: "paragraph",
|
|
1733
|
-
children: [
|
|
1734
|
-
{
|
|
1735
|
-
type: "image",
|
|
1736
|
-
url,
|
|
1737
|
-
attrs: attrs || {}
|
|
1738
|
-
}
|
|
1739
|
-
]
|
|
1740
|
-
});
|
|
1741
|
-
} else {
|
|
1742
|
-
if (lastBlock && lastBlock.type === "paragraph") {
|
|
1743
|
-
lastBlock.children.push({
|
|
1744
|
-
type: "image",
|
|
1745
|
-
url,
|
|
1746
|
-
attrs: attrs || {}
|
|
1747
|
-
});
|
|
1748
|
-
} else {
|
|
1749
|
-
doc.children.push({
|
|
1750
|
-
type: "paragraph",
|
|
1751
|
-
children: [
|
|
1752
|
-
{
|
|
1753
|
-
type: "image",
|
|
1754
|
-
url,
|
|
1755
|
-
attrs: attrs || {}
|
|
1756
|
-
}
|
|
1757
|
-
]
|
|
1758
|
-
});
|
|
1759
|
-
}
|
|
1760
|
-
}
|
|
1761
|
-
return doc;
|
|
1762
|
-
}
|
|
1763
|
-
/**
|
|
1764
|
-
* Insert mention
|
|
1765
|
-
*/
|
|
1766
|
-
insertMention(id, label, meta) {
|
|
1767
|
-
const doc = this.cloneDocument();
|
|
1768
|
-
const lastBlock = doc.children[doc.children.length - 1];
|
|
1769
|
-
if (lastBlock && lastBlock.type === "paragraph") {
|
|
1770
|
-
lastBlock.children.push({
|
|
1771
|
-
type: "mention",
|
|
1772
|
-
id,
|
|
1773
|
-
label,
|
|
1774
|
-
meta
|
|
1775
|
-
});
|
|
1776
|
-
}
|
|
1777
|
-
return doc;
|
|
1778
|
-
}
|
|
1779
|
-
/**
|
|
1780
|
-
* Insert list
|
|
1781
|
-
*/
|
|
1782
|
-
insertList(listType, items = [[]]) {
|
|
1783
|
-
const doc = this.cloneDocument();
|
|
1784
|
-
const children = items.map((item) => ({
|
|
1785
|
-
type: "list-item",
|
|
1786
|
-
children: item || [{ type: "text", text: "" }],
|
|
1787
|
-
depth: 0
|
|
1788
|
-
}));
|
|
1789
|
-
doc.children.push({
|
|
1790
|
-
type: "list",
|
|
1791
|
-
listType,
|
|
1792
|
-
children
|
|
1793
|
-
});
|
|
1794
|
-
return doc;
|
|
1795
|
-
}
|
|
1796
|
-
/**
|
|
1797
|
-
* Toggle a mark type on text in a range
|
|
1798
|
-
*/
|
|
1799
|
-
toggleMark(mark, selection) {
|
|
1800
|
-
var _a;
|
|
1801
|
-
const doc = this.cloneDocument();
|
|
1802
|
-
const firstPara = this.getFirstParagraph(doc);
|
|
1803
|
-
if (firstPara && ((_a = firstPara.children[0]) == null ? void 0 : _a.type) === "text") {
|
|
1804
|
-
const textNode = firstPara.children[0];
|
|
1805
|
-
if (!textNode.marks) {
|
|
1806
|
-
textNode.marks = [];
|
|
1807
|
-
}
|
|
1808
|
-
const existingMark = textNode.marks.findIndex((m) => m.type === mark);
|
|
1809
|
-
if (existingMark >= 0) {
|
|
1810
|
-
textNode.marks.splice(existingMark, 1);
|
|
1811
|
-
} else {
|
|
1812
|
-
textNode.marks.push({ type: mark });
|
|
1813
|
-
}
|
|
1814
|
-
}
|
|
1815
|
-
return doc;
|
|
1816
|
-
}
|
|
1817
|
-
/**
|
|
1818
|
-
* Check if a mark type is active at cursor
|
|
1819
|
-
*/
|
|
1820
|
-
isMarkActive(mark) {
|
|
1821
|
-
var _a, _b;
|
|
1822
|
-
const firstPara = this.getFirstParagraph(this.document);
|
|
1823
|
-
if (((_a = firstPara == null ? void 0 : firstPara.children[0]) == null ? void 0 : _a.type) === "text") {
|
|
1824
|
-
const textNode = firstPara.children[0];
|
|
1825
|
-
return ((_b = textNode.marks) == null ? void 0 : _b.some((m) => m.type === mark)) || false;
|
|
1826
|
-
}
|
|
1827
|
-
return false;
|
|
1828
|
-
}
|
|
1829
|
-
/**
|
|
1830
|
-
* Get active marks at cursor
|
|
1831
|
-
*/
|
|
1832
|
-
getActiveMarks() {
|
|
1833
|
-
var _a, _b;
|
|
1834
|
-
const firstPara = this.getFirstParagraph(this.document);
|
|
1835
|
-
if (((_a = firstPara == null ? void 0 : firstPara.children[0]) == null ? void 0 : _a.type) === "text") {
|
|
1836
|
-
const textNode = firstPara.children[0];
|
|
1837
|
-
return ((_b = textNode.marks) == null ? void 0 : _b.map((m) => m.type)) || [];
|
|
1838
|
-
}
|
|
1839
|
-
return [];
|
|
1840
|
-
}
|
|
1841
|
-
/**
|
|
1842
|
-
* Delete content (simplified - deletes last block)
|
|
1843
|
-
*/
|
|
1844
|
-
deleteContent(selection) {
|
|
1845
|
-
const doc = this.cloneDocument();
|
|
1846
|
-
if (doc.children.length > 1) {
|
|
1847
|
-
doc.children.pop();
|
|
1848
|
-
} else if (doc.children.length === 1 && doc.children[0].type === "paragraph") {
|
|
1849
|
-
doc.children[0].children = [{ type: "text", text: "" }];
|
|
1850
|
-
}
|
|
1851
|
-
return doc;
|
|
1852
|
-
}
|
|
1853
|
-
/**
|
|
1854
|
-
* Replace entire content
|
|
1855
|
-
*/
|
|
1856
|
-
replaceContent(nodes) {
|
|
1857
|
-
const doc = this.cloneDocument();
|
|
1858
|
-
doc.children = nodes;
|
|
1859
|
-
return doc;
|
|
1860
|
-
}
|
|
1861
|
-
/**
|
|
1862
|
-
* Clone document (deep copy)
|
|
1863
|
-
*/
|
|
1864
|
-
cloneDocument() {
|
|
1865
|
-
return JSON.parse(JSON.stringify(this.document));
|
|
1866
|
-
}
|
|
1867
|
-
/**
|
|
1868
|
-
* Get first paragraph in document
|
|
1869
|
-
*/
|
|
1870
|
-
getFirstParagraph(doc) {
|
|
1871
|
-
for (const block of doc.children) {
|
|
1872
|
-
if (block.type === "paragraph") {
|
|
1873
|
-
return block;
|
|
1874
|
-
}
|
|
1875
|
-
}
|
|
1876
|
-
return null;
|
|
1877
|
-
}
|
|
1878
|
-
/**
|
|
1879
|
-
* Find node by predicate
|
|
1880
|
-
*/
|
|
1881
|
-
findNode(predicate) {
|
|
1882
|
-
const search = (node) => {
|
|
1883
|
-
if (predicate(node)) {
|
|
1884
|
-
return node;
|
|
1885
|
-
}
|
|
1886
|
-
if ("children" in node) {
|
|
1887
|
-
for (const child of node.children) {
|
|
1888
|
-
const result = search(child);
|
|
1889
|
-
if (result) return result;
|
|
1890
|
-
}
|
|
1891
|
-
}
|
|
1892
|
-
return null;
|
|
1893
|
-
};
|
|
1894
|
-
for (const child of this.document.children) {
|
|
1895
|
-
const result = search(child);
|
|
1896
|
-
if (result) return result;
|
|
1897
|
-
}
|
|
1898
|
-
return null;
|
|
1899
|
-
}
|
|
1900
|
-
/**
|
|
1901
|
-
* Count all nodes of a type
|
|
1902
|
-
*/
|
|
1903
|
-
countNodes(type) {
|
|
1904
|
-
let count = 0;
|
|
1905
|
-
const traverse = (node) => {
|
|
1906
|
-
if (node.type === type) count++;
|
|
1907
|
-
if ("children" in node) {
|
|
1908
|
-
node.children.forEach(traverse);
|
|
1909
|
-
}
|
|
1910
|
-
};
|
|
1911
|
-
this.document.children.forEach(traverse);
|
|
1912
|
-
return count;
|
|
1913
|
-
}
|
|
1914
|
-
createEmptyDocument() {
|
|
1915
|
-
return ContentModel.createEmpty();
|
|
1916
|
-
}
|
|
1917
|
-
}
|
|
1918
|
-
class RichContentService {
|
|
1919
|
-
constructor(config2 = {}) {
|
|
1920
|
-
this.history = [];
|
|
1921
|
-
this.historyIndex = -1;
|
|
1922
|
-
this.adapter = null;
|
|
1923
|
-
this.defaultImageHandler = async (file) => {
|
|
1924
|
-
return new Promise((resolve) => {
|
|
1925
|
-
const reader = new FileReader();
|
|
1926
|
-
reader.onload = (e) => {
|
|
1927
|
-
var _a;
|
|
1928
|
-
resolve({ url: (_a = e.target) == null ? void 0 : _a.result });
|
|
1929
|
-
};
|
|
1930
|
-
reader.readAsDataURL(file);
|
|
1931
|
-
});
|
|
1932
|
-
};
|
|
1933
|
-
this.config = {
|
|
1934
|
-
initialContent: config2.initialContent || ContentModel.createEmpty(),
|
|
1935
|
-
allowedMarks: config2.allowedMarks || [
|
|
1936
|
-
"bold",
|
|
1937
|
-
"italic",
|
|
1938
|
-
"underline",
|
|
1939
|
-
"strikethrough",
|
|
1940
|
-
"code"
|
|
1941
|
-
],
|
|
1942
|
-
allowedBlocks: config2.allowedBlocks || [
|
|
1943
|
-
"document",
|
|
1944
|
-
"paragraph",
|
|
1945
|
-
"heading",
|
|
1946
|
-
"list",
|
|
1947
|
-
"blockquote",
|
|
1948
|
-
"code-block",
|
|
1949
|
-
"horizontal-rule"
|
|
1950
|
-
],
|
|
1951
|
-
maxListDepth: config2.maxListDepth ?? 3,
|
|
1952
|
-
imageUploadHandler: config2.imageUploadHandler || this.defaultImageHandler,
|
|
1953
|
-
mentionProvider: config2.mentionProvider || (() => Promise.resolve([])),
|
|
1954
|
-
middleware: config2.middleware || {},
|
|
1955
|
-
enableHistory: config2.enableHistory ?? true,
|
|
1956
|
-
maxHistorySteps: config2.maxHistorySteps ?? 100,
|
|
1957
|
-
placeholder: config2.placeholder || "",
|
|
1958
|
-
readOnly: config2.readOnly ?? false
|
|
1959
|
-
};
|
|
1960
|
-
this.middleware = this.config.middleware;
|
|
1961
|
-
this.contentModel = new ContentModel(this.config.initialContent);
|
|
1962
|
-
this.contentSubject = new rxjs.BehaviorSubject(
|
|
1963
|
-
this.contentModel.getDocument()
|
|
1964
|
-
);
|
|
1965
|
-
this.commandSubject = new rxjs.Subject();
|
|
1966
|
-
this.mentionSubject = new rxjs.Subject();
|
|
1967
|
-
this.stateSubject = new rxjs.BehaviorSubject({
|
|
1968
|
-
content: this.contentModel.getDocument(),
|
|
1969
|
-
selection: null,
|
|
1970
|
-
canUndo: false,
|
|
1971
|
-
canRedo: false,
|
|
1972
|
-
isFocused: false,
|
|
1973
|
-
isDirty: false,
|
|
1974
|
-
mentions: {
|
|
1975
|
-
isActive: false,
|
|
1976
|
-
query: "",
|
|
1977
|
-
position: { x: 0, y: 0 }
|
|
1978
|
-
},
|
|
1979
|
-
selectedFormats: /* @__PURE__ */ new Set()
|
|
1980
|
-
});
|
|
1981
|
-
if (this.config.enableHistory) {
|
|
1982
|
-
this.history.push({
|
|
1983
|
-
content: this.contentModel.getDocument(),
|
|
1984
|
-
timestamp: Date.now()
|
|
1985
|
-
});
|
|
1986
|
-
this.historyIndex = 0;
|
|
1987
|
-
}
|
|
1988
|
-
this.commandSubject.subscribe((cmd) => this.executeCommand(cmd));
|
|
1989
|
-
}
|
|
1990
|
-
/**
|
|
1991
|
-
* Create service from empty state
|
|
1992
|
-
*/
|
|
1993
|
-
static create(config2) {
|
|
1994
|
-
return new RichContentService(config2);
|
|
1995
|
-
}
|
|
1996
|
-
// =========================================================================
|
|
1997
|
-
// PUBLIC OBSERVABLES
|
|
1998
|
-
// =========================================================================
|
|
1999
|
-
/**
|
|
2000
|
-
* Get content$ observable
|
|
2001
|
-
*/
|
|
2002
|
-
getContent$() {
|
|
2003
|
-
return this.contentSubject.asObservable();
|
|
2004
|
-
}
|
|
2005
|
-
/**
|
|
2006
|
-
* Get full state$ observable
|
|
2007
|
-
*/
|
|
2008
|
-
getState$() {
|
|
2009
|
-
return this.stateSubject.asObservable();
|
|
2010
|
-
}
|
|
2011
|
-
/**
|
|
2012
|
-
* Get canUndo$ observable
|
|
2013
|
-
*/
|
|
2014
|
-
getCanUndo$() {
|
|
2015
|
-
return this.stateSubject.pipe(
|
|
2016
|
-
operators.map((s) => s.canUndo),
|
|
2017
|
-
operators.distinctUntilChanged()
|
|
2018
|
-
);
|
|
2019
|
-
}
|
|
2020
|
-
/**
|
|
2021
|
-
* Get canRedo$ observable
|
|
2022
|
-
*/
|
|
2023
|
-
getCanRedo$() {
|
|
2024
|
-
return this.stateSubject.pipe(
|
|
2025
|
-
operators.map((s) => s.canRedo),
|
|
2026
|
-
operators.distinctUntilChanged()
|
|
2027
|
-
);
|
|
2028
|
-
}
|
|
2029
|
-
/**
|
|
2030
|
-
* Get isFocused$ observable
|
|
2031
|
-
*/
|
|
2032
|
-
getIsFocused$() {
|
|
2033
|
-
return this.stateSubject.pipe(
|
|
2034
|
-
operators.map((s) => s.isFocused),
|
|
2035
|
-
operators.distinctUntilChanged()
|
|
2036
|
-
);
|
|
2037
|
-
}
|
|
2038
|
-
/**
|
|
2039
|
-
* Get mentions$ observable - for autocomplete dropdown
|
|
2040
|
-
*/
|
|
2041
|
-
getMentions$() {
|
|
2042
|
-
return this.mentionSubject.asObservable();
|
|
2043
|
-
}
|
|
2044
|
-
/**
|
|
2045
|
-
* Get selectedFormats$ observable
|
|
2046
|
-
*/
|
|
2047
|
-
getSelectedFormats$() {
|
|
2048
|
-
return this.stateSubject.pipe(
|
|
2049
|
-
operators.map((s) => s.selectedFormats || /* @__PURE__ */ new Set()),
|
|
2050
|
-
operators.distinctUntilChanged()
|
|
2051
|
-
);
|
|
2052
|
-
}
|
|
2053
|
-
// =========================================================================
|
|
2054
|
-
// STATE GETTERS
|
|
2055
|
-
// =========================================================================
|
|
2056
|
-
getContent() {
|
|
2057
|
-
return this.contentSubject.getValue();
|
|
2058
|
-
}
|
|
2059
|
-
getState() {
|
|
2060
|
-
return this.stateSubject.getValue();
|
|
2061
|
-
}
|
|
2062
|
-
getPlainText() {
|
|
2063
|
-
return this.contentModel.getPlainText();
|
|
2064
|
-
}
|
|
2065
|
-
canUndo() {
|
|
2066
|
-
return this.historyIndex > 0;
|
|
2067
|
-
}
|
|
2068
|
-
canRedo() {
|
|
2069
|
-
return this.historyIndex < this.history.length - 1;
|
|
2070
|
-
}
|
|
2071
|
-
isFocused() {
|
|
2072
|
-
return this.getState().isFocused;
|
|
2073
|
-
}
|
|
2074
|
-
// =========================================================================
|
|
2075
|
-
// ADAPTER MANAGEMENT
|
|
2076
|
-
// =========================================================================
|
|
2077
|
-
/**
|
|
2078
|
-
* Attach DOM adapter for contentEditable syncing
|
|
2079
|
-
*/
|
|
2080
|
-
attachAdapter(adapter) {
|
|
2081
|
-
this.adapter = adapter;
|
|
2082
|
-
const docFromDom = adapter.syncFromDOM();
|
|
2083
|
-
this.setContent(docFromDom);
|
|
2084
|
-
}
|
|
2085
|
-
/**
|
|
2086
|
-
* Detach adapter
|
|
2087
|
-
*/
|
|
2088
|
-
detachAdapter() {
|
|
2089
|
-
if (this.adapter) {
|
|
2090
|
-
this.adapter.unmount();
|
|
2091
|
-
this.adapter = null;
|
|
2092
|
-
}
|
|
2093
|
-
}
|
|
2094
|
-
/**
|
|
2095
|
-
* Get attached adapter
|
|
2096
|
-
*/
|
|
2097
|
-
getAdapter() {
|
|
2098
|
-
return this.adapter;
|
|
2099
|
-
}
|
|
2100
|
-
// =========================================================================
|
|
2101
|
-
// COMMAND EXECUTION
|
|
2102
|
-
// =========================================================================
|
|
2103
|
-
/**
|
|
2104
|
-
* Execute a command
|
|
2105
|
-
*/
|
|
2106
|
-
execute(command, payload) {
|
|
2107
|
-
const cmd = typeof command === "string" ? { type: command, payload } : command;
|
|
2108
|
-
this.commandSubject.next(cmd);
|
|
2109
|
-
}
|
|
2110
|
-
/**
|
|
2111
|
-
* Execute text insertion
|
|
2112
|
-
*/
|
|
2113
|
-
insertText(text, marks) {
|
|
2114
|
-
this.execute("insertText", { text, marks });
|
|
2115
|
-
}
|
|
2116
|
-
/**
|
|
2117
|
-
* Execute paragraph insertion
|
|
2118
|
-
*/
|
|
2119
|
-
insertParagraph() {
|
|
2120
|
-
this.execute("insertParagraph");
|
|
2121
|
-
}
|
|
2122
|
-
/**
|
|
2123
|
-
* Execute heading insertion
|
|
2124
|
-
*/
|
|
2125
|
-
insertHeading(level) {
|
|
2126
|
-
this.execute("insertHeading", { level });
|
|
2127
|
-
}
|
|
2128
|
-
/**
|
|
2129
|
-
* Execute image insertion
|
|
2130
|
-
*/
|
|
2131
|
-
insertImage(url, attrs) {
|
|
2132
|
-
this.execute("insertImage", { url, attrs });
|
|
2133
|
-
}
|
|
2134
|
-
/**
|
|
2135
|
-
* Execute image upload
|
|
2136
|
-
*/
|
|
2137
|
-
async uploadImage(file) {
|
|
2138
|
-
try {
|
|
2139
|
-
const result = await this.config.imageUploadHandler(file);
|
|
2140
|
-
this.insertImage(result.url, result.attrs);
|
|
2141
|
-
} catch (error) {
|
|
2142
|
-
console.error("Image upload failed:", error);
|
|
2143
|
-
throw error;
|
|
2144
|
-
}
|
|
2145
|
-
}
|
|
2146
|
-
/**
|
|
2147
|
-
* Execute mention insertion
|
|
2148
|
-
*/
|
|
2149
|
-
insertMention(id, label, meta) {
|
|
2150
|
-
this.execute("insertMention", { id, label, meta });
|
|
2151
|
-
}
|
|
2152
|
-
/**
|
|
2153
|
-
* Execute list insertion
|
|
2154
|
-
*/
|
|
2155
|
-
insertList(listType) {
|
|
2156
|
-
this.execute("insertList", { listType });
|
|
2157
|
-
}
|
|
2158
|
-
/**
|
|
2159
|
-
* Execute mark toggle (bold, italic, etc.)
|
|
2160
|
-
*/
|
|
2161
|
-
toggleMark(mark) {
|
|
2162
|
-
this.execute("toggleMark", { mark });
|
|
2163
|
-
}
|
|
2164
|
-
/**
|
|
2165
|
-
* Delete content
|
|
2166
|
-
*/
|
|
2167
|
-
deleteContent() {
|
|
2168
|
-
this.execute("deleteContent");
|
|
2169
|
-
}
|
|
2170
|
-
/**
|
|
2171
|
-
* Set focus state
|
|
2172
|
-
*/
|
|
2173
|
-
setFocus(focused) {
|
|
2174
|
-
const state = this.getState();
|
|
2175
|
-
state.isFocused = focused;
|
|
2176
|
-
this.stateSubject.next(state);
|
|
2177
|
-
}
|
|
2178
|
-
/**
|
|
2179
|
-
* Set selection
|
|
2180
|
-
*/
|
|
2181
|
-
setSelection(selection) {
|
|
2182
|
-
const state = this.getState();
|
|
2183
|
-
state.selection = selection;
|
|
2184
|
-
this.stateSubject.next(state);
|
|
2185
|
-
}
|
|
2186
|
-
/**
|
|
2187
|
-
* Set mention query (triggers autocomplete)
|
|
2188
|
-
*/
|
|
2189
|
-
setMentionQuery(query, position) {
|
|
2190
|
-
if (query.length > 0) {
|
|
2191
|
-
this.mentionSubject.next({ query, position });
|
|
2192
|
-
}
|
|
2193
|
-
}
|
|
2194
|
-
// =========================================================================
|
|
2195
|
-
// HISTORY (UNDO/REDO)
|
|
2196
|
-
// =========================================================================
|
|
2197
|
-
/**
|
|
2198
|
-
* Undo to previous state
|
|
2199
|
-
*/
|
|
2200
|
-
undo() {
|
|
2201
|
-
if (this.canUndo()) {
|
|
2202
|
-
this.historyIndex--;
|
|
2203
|
-
this.applyHistoryState();
|
|
2204
|
-
}
|
|
2205
|
-
}
|
|
2206
|
-
/**
|
|
2207
|
-
* Redo to next state
|
|
2208
|
-
*/
|
|
2209
|
-
redo() {
|
|
2210
|
-
if (this.canRedo()) {
|
|
2211
|
-
this.historyIndex++;
|
|
2212
|
-
this.applyHistoryState();
|
|
2213
|
-
}
|
|
2214
|
-
}
|
|
2215
|
-
/**
|
|
2216
|
-
* Clear history
|
|
2217
|
-
*/
|
|
2218
|
-
clearHistory() {
|
|
2219
|
-
this.history = [{ content: this.getContent(), timestamp: Date.now() }];
|
|
2220
|
-
this.historyIndex = 0;
|
|
2221
|
-
this.updateHistoryState();
|
|
2222
|
-
}
|
|
2223
|
-
// =========================================================================
|
|
2224
|
-
// PRIVATE METHODS
|
|
2225
|
-
// =========================================================================
|
|
2226
|
-
executeCommand(cmd) {
|
|
2227
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
2228
|
-
if (this.config.readOnly) {
|
|
2229
|
-
console.warn("Editor is in read-only mode");
|
|
2230
|
-
return;
|
|
2231
|
-
}
|
|
2232
|
-
this.getContent();
|
|
2233
|
-
let newContent;
|
|
2234
|
-
switch (cmd.type) {
|
|
2235
|
-
case "insertText":
|
|
2236
|
-
newContent = this.contentModel.insertText((_a = cmd.payload) == null ? void 0 : _a.text, (_b = cmd.payload) == null ? void 0 : _b.marks);
|
|
2237
|
-
break;
|
|
2238
|
-
case "insertParagraph":
|
|
2239
|
-
newContent = this.contentModel.insertParagraph((_c = cmd.payload) == null ? void 0 : _c.children);
|
|
2240
|
-
break;
|
|
2241
|
-
case "insertHeading":
|
|
2242
|
-
newContent = this.contentModel.insertHeading(
|
|
2243
|
-
((_d = cmd.payload) == null ? void 0 : _d.level) || 1,
|
|
2244
|
-
(_e = cmd.payload) == null ? void 0 : _e.children
|
|
2245
|
-
);
|
|
2246
|
-
break;
|
|
2247
|
-
case "insertImage":
|
|
2248
|
-
newContent = this.contentModel.insertImage((_f = cmd.payload) == null ? void 0 : _f.url, (_g = cmd.payload) == null ? void 0 : _g.attrs);
|
|
2249
|
-
break;
|
|
2250
|
-
case "insertMention":
|
|
2251
|
-
newContent = this.contentModel.insertMention(
|
|
2252
|
-
(_h = cmd.payload) == null ? void 0 : _h.id,
|
|
2253
|
-
(_i = cmd.payload) == null ? void 0 : _i.label,
|
|
2254
|
-
(_j = cmd.payload) == null ? void 0 : _j.meta
|
|
2255
|
-
);
|
|
2256
|
-
break;
|
|
2257
|
-
case "insertList":
|
|
2258
|
-
newContent = this.contentModel.insertList((_k = cmd.payload) == null ? void 0 : _k.listType, (_l = cmd.payload) == null ? void 0 : _l.items);
|
|
2259
|
-
break;
|
|
2260
|
-
case "toggleMark":
|
|
2261
|
-
newContent = this.contentModel.toggleMark((_m = cmd.payload) == null ? void 0 : _m.mark, (_n = cmd.payload) == null ? void 0 : _n.selection);
|
|
2262
|
-
break;
|
|
2263
|
-
case "deleteContent":
|
|
2264
|
-
newContent = this.contentModel.deleteContent((_o = cmd.payload) == null ? void 0 : _o.selection);
|
|
2265
|
-
break;
|
|
2266
|
-
case "replaceContent":
|
|
2267
|
-
newContent = this.contentModel.replaceContent((_p = cmd.payload) == null ? void 0 : _p.nodes);
|
|
2268
|
-
break;
|
|
2269
|
-
default:
|
|
2270
|
-
console.warn(`Unknown command type: ${cmd.type}`);
|
|
2271
|
-
return;
|
|
2272
|
-
}
|
|
2273
|
-
if (this.config.enableHistory) {
|
|
2274
|
-
this.history = this.history.slice(0, this.historyIndex + 1);
|
|
2275
|
-
this.history.push({
|
|
2276
|
-
content: newContent,
|
|
2277
|
-
timestamp: Date.now()
|
|
2278
|
-
});
|
|
2279
|
-
if (this.history.length > this.config.maxHistorySteps) {
|
|
2280
|
-
this.history.shift();
|
|
2281
|
-
} else {
|
|
2282
|
-
this.historyIndex++;
|
|
2283
|
-
}
|
|
2284
|
-
}
|
|
2285
|
-
this.setContent(newContent);
|
|
2286
|
-
}
|
|
2287
|
-
setContent(doc) {
|
|
2288
|
-
this.contentModel.setDocument(doc);
|
|
2289
|
-
this.contentSubject.next(doc);
|
|
2290
|
-
const state = this.getState();
|
|
2291
|
-
state.content = doc;
|
|
2292
|
-
state.isDirty = true;
|
|
2293
|
-
state.selectedFormats = new Set(this.contentModel.getActiveMarks());
|
|
2294
|
-
this.stateSubject.next(state);
|
|
2295
|
-
if (this.adapter) {
|
|
2296
|
-
this.adapter.syncToDOM(doc);
|
|
2297
|
-
}
|
|
2298
|
-
this.updateHistoryState();
|
|
2299
|
-
}
|
|
2300
|
-
applyHistoryState() {
|
|
2301
|
-
const entry = this.history[this.historyIndex];
|
|
2302
|
-
this.contentModel.setDocument(entry.content);
|
|
2303
|
-
this.contentSubject.next(entry.content);
|
|
2304
|
-
const state = this.getState();
|
|
2305
|
-
state.content = entry.content;
|
|
2306
|
-
this.stateSubject.next(state);
|
|
2307
|
-
if (this.adapter) {
|
|
2308
|
-
this.adapter.syncToDOM(entry.content);
|
|
2309
|
-
}
|
|
2310
|
-
this.updateHistoryState();
|
|
2311
|
-
}
|
|
2312
|
-
updateHistoryState() {
|
|
2313
|
-
const state = this.getState();
|
|
2314
|
-
state.canUndo = this.canUndo();
|
|
2315
|
-
state.canRedo = this.canRedo();
|
|
2316
|
-
this.stateSubject.next(state);
|
|
2317
|
-
}
|
|
2318
|
-
}
|
|
2319
254
|
function useRichContent(options = {}) {
|
|
2320
|
-
const service = react.useMemo(() => RichContentService.create(options), []);
|
|
255
|
+
const service = react.useMemo(() => richContent.RichContentService.create(options), []);
|
|
2321
256
|
const [content, setContent] = react.useState(service.getContent());
|
|
2322
257
|
const [state, setState] = react.useState(service.getState());
|
|
2323
258
|
const [isFocused, setIsFocused] = react.useState(false);
|
|
@@ -2408,12 +343,12 @@ function useRichContent(options = {}) {
|
|
|
2408
343
|
};
|
|
2409
344
|
}
|
|
2410
345
|
function useTableService(options) {
|
|
2411
|
-
const { config
|
|
346
|
+
const { config, data } = options;
|
|
2412
347
|
const builder = react.useMemo(() => {
|
|
2413
|
-
const tb = new
|
|
348
|
+
const tb = new utils.TableBuilder(config);
|
|
2414
349
|
tb.setData(data);
|
|
2415
350
|
return tb;
|
|
2416
|
-
}, [
|
|
351
|
+
}, [config]);
|
|
2417
352
|
const [state, setState] = react.useState(() => builder.getState());
|
|
2418
353
|
const [selectedRows, setSelectedRows] = react.useState([]);
|
|
2419
354
|
const [allSelected, setAllSelected] = react.useState(false);
|
|
@@ -2490,218 +425,11 @@ function useTableService(options) {
|
|
|
2490
425
|
}), [state, selectedRows, allSelected, memoizedMethods]);
|
|
2491
426
|
return memoizedReturn;
|
|
2492
427
|
}
|
|
2493
|
-
class TabsService {
|
|
2494
|
-
constructor(config2) {
|
|
2495
|
-
this.config = config2;
|
|
2496
|
-
this.urlParam = config2.urlParam || "tab";
|
|
2497
|
-
this.tabsSubject = new rxjs.BehaviorSubject(config2.tabs);
|
|
2498
|
-
const initialTabId = this.getInitialTabId();
|
|
2499
|
-
this.activeTabSubject = new rxjs.BehaviorSubject(initialTabId);
|
|
2500
|
-
this.tabChangeSubject = new rxjs.BehaviorSubject(null);
|
|
2501
|
-
if (this.config.enableUrlRouting) {
|
|
2502
|
-
this.setupUrlRouting();
|
|
2503
|
-
}
|
|
2504
|
-
}
|
|
2505
|
-
/**
|
|
2506
|
-
* Get initial tab ID from URL or config
|
|
2507
|
-
*/
|
|
2508
|
-
getInitialTabId() {
|
|
2509
|
-
var _a;
|
|
2510
|
-
if (this.config.enableUrlRouting && typeof window !== "undefined") {
|
|
2511
|
-
const params = new URLSearchParams(window.location.search);
|
|
2512
|
-
const urlTabId = params.get(this.urlParam);
|
|
2513
|
-
if (urlTabId && this.config.tabs.some((t) => t.id === urlTabId)) {
|
|
2514
|
-
return urlTabId;
|
|
2515
|
-
}
|
|
2516
|
-
}
|
|
2517
|
-
return this.config.defaultTabId || ((_a = this.config.tabs[0]) == null ? void 0 : _a.id) || "";
|
|
2518
|
-
}
|
|
2519
|
-
/**
|
|
2520
|
-
* Setup URL routing listener
|
|
2521
|
-
*/
|
|
2522
|
-
setupUrlRouting() {
|
|
2523
|
-
if (typeof window === "undefined") return;
|
|
2524
|
-
const handleUrlChange = () => {
|
|
2525
|
-
const params = new URLSearchParams(window.location.search);
|
|
2526
|
-
const urlTabId = params.get(this.urlParam);
|
|
2527
|
-
if (urlTabId && urlTabId !== this.activeTabSubject.value) {
|
|
2528
|
-
this.setActiveTab(urlTabId);
|
|
2529
|
-
}
|
|
2530
|
-
};
|
|
2531
|
-
window.addEventListener("popstate", handleUrlChange);
|
|
2532
|
-
}
|
|
2533
|
-
/**
|
|
2534
|
-
* Update URL with current active tab
|
|
2535
|
-
*/
|
|
2536
|
-
updateUrl(tabId) {
|
|
2537
|
-
if (!this.config.enableUrlRouting || typeof window === "undefined") return;
|
|
2538
|
-
const params = new URLSearchParams(window.location.search);
|
|
2539
|
-
params.set(this.urlParam, tabId);
|
|
2540
|
-
const newUrl = `${window.location.pathname}?${params.toString()}`;
|
|
2541
|
-
window.history.pushState({ tab: tabId }, "", newUrl);
|
|
2542
|
-
}
|
|
2543
|
-
/**
|
|
2544
|
-
* Set active tab by ID
|
|
2545
|
-
*/
|
|
2546
|
-
setActiveTab(tabId) {
|
|
2547
|
-
const tab = this.config.tabs.find((t) => t.id === tabId);
|
|
2548
|
-
if (!tab || tab.disabled) return;
|
|
2549
|
-
const previousTabId = this.activeTabSubject.value;
|
|
2550
|
-
this.activeTabSubject.next(tabId);
|
|
2551
|
-
if (this.config.enableUrlRouting) {
|
|
2552
|
-
this.updateUrl(tabId);
|
|
2553
|
-
}
|
|
2554
|
-
this.tabChangeSubject.next({
|
|
2555
|
-
previousTabId,
|
|
2556
|
-
currentTabId: tabId,
|
|
2557
|
-
tab
|
|
2558
|
-
});
|
|
2559
|
-
}
|
|
2560
|
-
/**
|
|
2561
|
-
* Set active tab by index
|
|
2562
|
-
*/
|
|
2563
|
-
setActiveTabByIndex(index) {
|
|
2564
|
-
const tab = this.config.tabs[index];
|
|
2565
|
-
if (tab) {
|
|
2566
|
-
this.setActiveTab(tab.id);
|
|
2567
|
-
}
|
|
2568
|
-
}
|
|
2569
|
-
/**
|
|
2570
|
-
* Get active tab ID
|
|
2571
|
-
*/
|
|
2572
|
-
getActiveTabId() {
|
|
2573
|
-
return this.activeTabSubject.value;
|
|
2574
|
-
}
|
|
2575
|
-
/**
|
|
2576
|
-
* Get active tab
|
|
2577
|
-
*/
|
|
2578
|
-
getActiveTab() {
|
|
2579
|
-
return this.config.tabs.find((t) => t.id === this.activeTabSubject.value);
|
|
2580
|
-
}
|
|
2581
|
-
/**
|
|
2582
|
-
* Get active tab index
|
|
2583
|
-
*/
|
|
2584
|
-
getActiveTabIndex() {
|
|
2585
|
-
return this.config.tabs.findIndex((t) => t.id === this.activeTabSubject.value);
|
|
2586
|
-
}
|
|
2587
|
-
/**
|
|
2588
|
-
* Get all tabs
|
|
2589
|
-
*/
|
|
2590
|
-
getTabs() {
|
|
2591
|
-
return this.tabsSubject.value;
|
|
2592
|
-
}
|
|
2593
|
-
/**
|
|
2594
|
-
* Observable of active tab ID
|
|
2595
|
-
*/
|
|
2596
|
-
getActiveTabId$() {
|
|
2597
|
-
return this.activeTabSubject.asObservable().pipe(operators.distinctUntilChanged());
|
|
2598
|
-
}
|
|
2599
|
-
/**
|
|
2600
|
-
* Observable of active tab
|
|
2601
|
-
*/
|
|
2602
|
-
getActiveTab$() {
|
|
2603
|
-
return this.activeTabSubject.asObservable().pipe(
|
|
2604
|
-
operators.distinctUntilChanged(),
|
|
2605
|
-
operators.map((tabId) => this.config.tabs.find((t) => t.id === tabId))
|
|
2606
|
-
);
|
|
2607
|
-
}
|
|
2608
|
-
/**
|
|
2609
|
-
* Observable of tab change events
|
|
2610
|
-
*/
|
|
2611
|
-
onTabChange$() {
|
|
2612
|
-
return this.tabChangeSubject.asObservable();
|
|
2613
|
-
}
|
|
2614
|
-
/**
|
|
2615
|
-
* Observable of all tabs
|
|
2616
|
-
*/
|
|
2617
|
-
getTabs$() {
|
|
2618
|
-
return this.tabsSubject.asObservable().pipe(operators.distinctUntilChanged());
|
|
2619
|
-
}
|
|
2620
|
-
/**
|
|
2621
|
-
* Update tabs
|
|
2622
|
-
*/
|
|
2623
|
-
updateTabs(tabs) {
|
|
2624
|
-
var _a;
|
|
2625
|
-
this.config.tabs = tabs;
|
|
2626
|
-
this.tabsSubject.next(tabs);
|
|
2627
|
-
if (!tabs.find((t) => t.id === this.activeTabSubject.value)) {
|
|
2628
|
-
const newActiveTabId = ((_a = tabs[0]) == null ? void 0 : _a.id) || "";
|
|
2629
|
-
this.setActiveTab(newActiveTabId);
|
|
2630
|
-
}
|
|
2631
|
-
}
|
|
2632
|
-
/**
|
|
2633
|
-
* Add a tab
|
|
2634
|
-
*/
|
|
2635
|
-
addTab(tab, index) {
|
|
2636
|
-
const tabs = [...this.config.tabs];
|
|
2637
|
-
if (index !== void 0) {
|
|
2638
|
-
tabs.splice(index, 0, tab);
|
|
2639
|
-
} else {
|
|
2640
|
-
tabs.push(tab);
|
|
2641
|
-
}
|
|
2642
|
-
this.updateTabs(tabs);
|
|
2643
|
-
}
|
|
2644
|
-
/**
|
|
2645
|
-
* Remove a tab
|
|
2646
|
-
*/
|
|
2647
|
-
removeTab(tabId) {
|
|
2648
|
-
const tabs = this.config.tabs.filter((t) => t.id !== tabId);
|
|
2649
|
-
this.updateTabs(tabs);
|
|
2650
|
-
}
|
|
2651
|
-
/**
|
|
2652
|
-
* Enable/disable a tab
|
|
2653
|
-
*/
|
|
2654
|
-
setTabDisabled(tabId, disabled) {
|
|
2655
|
-
const tabs = this.config.tabs.map(
|
|
2656
|
-
(t) => t.id === tabId ? { ...t, disabled } : t
|
|
2657
|
-
);
|
|
2658
|
-
this.updateTabs(tabs);
|
|
2659
|
-
if (disabled && this.activeTabSubject.value === tabId) {
|
|
2660
|
-
const enabledTab = tabs.find((t) => !t.disabled);
|
|
2661
|
-
if (enabledTab) {
|
|
2662
|
-
this.setActiveTab(enabledTab.id);
|
|
2663
|
-
}
|
|
2664
|
-
}
|
|
2665
|
-
}
|
|
2666
|
-
/**
|
|
2667
|
-
* Update tab badge
|
|
2668
|
-
*/
|
|
2669
|
-
setTabBadge(tabId, badge) {
|
|
2670
|
-
const tabs = this.config.tabs.map(
|
|
2671
|
-
(t) => t.id === tabId ? { ...t, badge } : t
|
|
2672
|
-
);
|
|
2673
|
-
this.updateTabs(tabs);
|
|
2674
|
-
}
|
|
2675
|
-
/**
|
|
2676
|
-
* Move to next tab
|
|
2677
|
-
*/
|
|
2678
|
-
nextTab() {
|
|
2679
|
-
const currentIndex = this.getActiveTabIndex();
|
|
2680
|
-
const nextIndex = (currentIndex + 1) % this.config.tabs.length;
|
|
2681
|
-
this.setActiveTabByIndex(nextIndex);
|
|
2682
|
-
}
|
|
2683
|
-
/**
|
|
2684
|
-
* Move to previous tab
|
|
2685
|
-
*/
|
|
2686
|
-
previousTab() {
|
|
2687
|
-
const currentIndex = this.getActiveTabIndex();
|
|
2688
|
-
const prevIndex = currentIndex === 0 ? this.config.tabs.length - 1 : currentIndex - 1;
|
|
2689
|
-
this.setActiveTabByIndex(prevIndex);
|
|
2690
|
-
}
|
|
2691
|
-
/**
|
|
2692
|
-
* Destroy service and cleanup
|
|
2693
|
-
*/
|
|
2694
|
-
destroy() {
|
|
2695
|
-
this.activeTabSubject.complete();
|
|
2696
|
-
this.tabsSubject.complete();
|
|
2697
|
-
this.tabChangeSubject.complete();
|
|
2698
|
-
}
|
|
2699
|
-
}
|
|
2700
428
|
const TabsContext = react.createContext(void 0);
|
|
2701
|
-
function TabsProvider({ config
|
|
2702
|
-
const [service] = react.useState(() => new TabsService(
|
|
429
|
+
function TabsProvider({ config, children }) {
|
|
430
|
+
const [service] = react.useState(() => new tabs.TabsService(config));
|
|
2703
431
|
const [activeTabId, setActiveTabId] = react.useState(() => service.getActiveTabId());
|
|
2704
|
-
const [tabs, setTabs] = react.useState(() => service.getTabs());
|
|
432
|
+
const [tabs$1, setTabs] = react.useState(() => service.getTabs());
|
|
2705
433
|
react.useEffect(() => {
|
|
2706
434
|
const activeTabSubscription = service.getActiveTabId$().subscribe(setActiveTabId);
|
|
2707
435
|
const tabsSubscription = service.getTabs$().subscribe(setTabs);
|
|
@@ -2715,7 +443,7 @@ function TabsProvider({ config: config2, children }) {
|
|
|
2715
443
|
service.destroy();
|
|
2716
444
|
};
|
|
2717
445
|
}, [service]);
|
|
2718
|
-
return /* @__PURE__ */ jsxRuntime.jsx(TabsContext.Provider, { value: { service, activeTabId, tabs }, children });
|
|
446
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TabsContext.Provider, { value: { service, activeTabId, tabs: tabs$1 }, children });
|
|
2719
447
|
}
|
|
2720
448
|
function useTabsContext() {
|
|
2721
449
|
const context = react.useContext(TabsContext);
|
|
@@ -2738,8 +466,8 @@ function useActiveTab() {
|
|
|
2738
466
|
return activeTab;
|
|
2739
467
|
}
|
|
2740
468
|
function useTabs() {
|
|
2741
|
-
const { tabs } = useTabsContext();
|
|
2742
|
-
return
|
|
469
|
+
const { tabs: tabs2 } = useTabsContext();
|
|
470
|
+
return tabs2;
|
|
2743
471
|
}
|
|
2744
472
|
function useTabChange() {
|
|
2745
473
|
const { service } = useTabsContext();
|