@adminide-stack/extension-api 9.1.1-alpha.62 → 9.1.1-alpha.72
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.
@@ -1,4 +1,4 @@
|
|
1
|
-
import*as abortableRx from'../../utils/abortable-rx.js';import {Subject,Observable,isObservable,from}from'rxjs';import {isPromise}from'../../utils/util.js';import'
|
1
|
+
import*as abortableRx from'../../utils/abortable-rx.js';import {Subject,Observable,isObservable,from}from'rxjs';import {isPromise}from'../../utils/util.js';import'@vscode-alt/monaco-editor/esm/vs/base/common/path.js';import {Emitter}from'./events.js';import {LinkedMap}from'./linkedMap.js';import AbortController from'abort-controller';import {isNotificationMessage,isRequestMessage,ErrorCodes,ResponseError,isResponseMessage}from'./messages.js';import {noopTracer}from'./trace.js';const { toPromise } = abortableRx; // to support vite esm
|
2
2
|
const NullLogger = Object.freeze({
|
3
3
|
error: () => {
|
4
4
|
/* noop */
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { type ObservableInput, Observable } from 'rxjs';
|
2
2
|
/**
|
3
3
|
* Like {@link combineLatest}, except that it does not wait for all Observables to emit before emitting an initial
|
4
4
|
* value. It emits whenever any of the source Observables emit.
|
@@ -22,7 +22,7 @@ import { Observable, ObservableInput } from 'rxjs';
|
|
22
22
|
* @param observables The source Observables.
|
23
23
|
* @param defaultValue The value to emit for a source Observable if it has not yet emitted a value by the time
|
24
24
|
* another Observable has emitted a value.
|
25
|
-
* @
|
25
|
+
* @returns An Observable of an array of the most recent values from each input Observable (or
|
26
26
|
* {@link defaultValue}).
|
27
27
|
*/
|
28
28
|
export declare function combineLatestOrDefault<T>(observables: ObservableInput<T>[], defaultValue?: T): Observable<T[]>;
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import {zip,of
|
2
|
-
/**
|
1
|
+
import {Observable,from,asapScheduler,zip,of}from'rxjs';/**
|
3
2
|
* Like {@link combineLatest}, except that it does not wait for all Observables to emit before emitting an initial
|
4
3
|
* value. It emits whenever any of the source Observables emit.
|
5
4
|
*
|
@@ -22,83 +21,77 @@ import {zip,of,Subscriber,Subscription}from'rxjs';import {fromArray}from'rxjs-co
|
|
22
21
|
* @param observables The source Observables.
|
23
22
|
* @param defaultValue The value to emit for a source Observable if it has not yet emitted a value by the time
|
24
23
|
* another Observable has emitted a value.
|
25
|
-
* @
|
24
|
+
* @returns An Observable of an array of the most recent values from each input Observable (or
|
26
25
|
* {@link defaultValue}).
|
27
26
|
*/
|
28
27
|
function combineLatestOrDefault(observables, defaultValue) {
|
29
28
|
switch (observables.length) {
|
30
|
-
case 0:
|
29
|
+
case 0: {
|
31
30
|
// No source observables: emit an empty array and complete
|
32
31
|
return of([]);
|
33
|
-
|
32
|
+
}
|
33
|
+
case 1: {
|
34
34
|
// Only one source observable: no need to handle emission accumulation or default values
|
35
35
|
return zip(...observables);
|
36
|
-
default:
|
37
|
-
return fromArray(observables).lift(new CombineLatestOperator(defaultValue));
|
38
|
-
}
|
39
|
-
}
|
40
|
-
class CombineLatestOperator {
|
41
|
-
defaultValue;
|
42
|
-
constructor(defaultValue) {
|
43
|
-
this.defaultValue = defaultValue;
|
44
|
-
}
|
45
|
-
call(subscriber, source) {
|
46
|
-
return source.subscribe(new CombineLatestSubscriber(subscriber, this.defaultValue));
|
47
|
-
}
|
48
|
-
}
|
49
|
-
class CombineLatestSubscriber extends Subscriber {
|
50
|
-
defaultValue;
|
51
|
-
activeObservables = 0;
|
52
|
-
values = [];
|
53
|
-
observables = [];
|
54
|
-
scheduled = false;
|
55
|
-
subscriptions = new Subscription();
|
56
|
-
constructor(destination, defaultValue) {
|
57
|
-
super(destination);
|
58
|
-
this.defaultValue = defaultValue;
|
59
|
-
if (!destination) {
|
60
|
-
throw new Error('Destination is required');
|
61
|
-
}
|
62
|
-
}
|
63
|
-
_next(observable) {
|
64
|
-
if (this.defaultValue !== undefined) {
|
65
|
-
this.values.push(this.defaultValue);
|
66
|
-
}
|
67
|
-
this.observables.push(observable);
|
68
|
-
}
|
69
|
-
_complete() {
|
70
|
-
this.activeObservables = this.observables.length;
|
71
|
-
// Use Observable's subscribe method directly
|
72
|
-
for (let i = 0; i < this.observables.length; i++) {
|
73
|
-
const observable = this.observables[i];
|
74
|
-
const subscription = observable.subscribe({
|
75
|
-
next: (value) => this.notifyNext(value, i),
|
76
|
-
complete: () => this.notifyComplete(),
|
77
|
-
});
|
78
|
-
this.subscriptions.add(subscription);
|
79
|
-
}
|
80
|
-
}
|
81
|
-
notifyComplete() {
|
82
|
-
this.activeObservables--;
|
83
|
-
if (this.activeObservables === 0 && this.destination) {
|
84
|
-
this.destination.complete();
|
85
|
-
}
|
86
|
-
}
|
87
|
-
notifyNext(value, index) {
|
88
|
-
this.values[index] = value;
|
89
|
-
if (this.activeObservables === 1) {
|
90
|
-
if (this.destination && this.destination.next) {
|
91
|
-
this.destination.next(this.values.slice());
|
92
|
-
}
|
93
|
-
return;
|
94
36
|
}
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
37
|
+
default: {
|
38
|
+
return new Observable((subscriber) => {
|
39
|
+
// The array of the most recent values from each input Observable.
|
40
|
+
// If a source Observable has not yet emitted a value, it will be represented by the
|
41
|
+
// defaultValue (if provided) or not at all (if not provided).
|
42
|
+
const values = defaultValue !== undefined ? observables.map(() => defaultValue) : [];
|
43
|
+
// Whether the emission of the values array has been scheduled
|
44
|
+
let scheduled = false;
|
45
|
+
let scheduledWork;
|
46
|
+
// The number of source Observables that have not yet completed
|
47
|
+
// (so that we know when to complete the output Observable)
|
48
|
+
let activeObservables = observables.length;
|
49
|
+
// When everything is done, clean up the values array
|
50
|
+
subscriber.add(() => {
|
51
|
+
values.length = 0;
|
52
|
+
});
|
53
|
+
// Subscribe to each source Observable. The index of the source Observable is used to
|
54
|
+
// keep track of the most recent value from that Observable in the values array.
|
55
|
+
for (let index = 0; index < observables.length; index++) {
|
56
|
+
subscriber.add(from(observables[index]).subscribe({
|
57
|
+
next: (value) => {
|
58
|
+
values[index] = value;
|
59
|
+
if (activeObservables === 1) {
|
60
|
+
// If only one source Observable is active, emit the values array immediately
|
61
|
+
// Abort any scheduled emission
|
62
|
+
scheduledWork?.unsubscribe();
|
63
|
+
scheduled = false;
|
64
|
+
subscriber.next(values.slice());
|
65
|
+
}
|
66
|
+
else if (!scheduled) {
|
67
|
+
scheduled = true;
|
68
|
+
// Use asapScheduler to emit the values array, so that all
|
69
|
+
// next values that are emitted at the same time are emitted together.
|
70
|
+
// This makes tests (using expectObservable) easier to write.
|
71
|
+
scheduledWork = asapScheduler.schedule(() => {
|
72
|
+
if (!subscriber.closed) {
|
73
|
+
subscriber.next(values.slice());
|
74
|
+
scheduled = false;
|
75
|
+
if (activeObservables === 0) {
|
76
|
+
subscriber.complete();
|
77
|
+
}
|
78
|
+
}
|
79
|
+
});
|
80
|
+
}
|
81
|
+
},
|
82
|
+
error: (error) => subscriber.error(error),
|
83
|
+
complete: () => {
|
84
|
+
activeObservables--;
|
85
|
+
if (activeObservables === 0 && !scheduled) {
|
86
|
+
subscriber.complete();
|
87
|
+
}
|
88
|
+
},
|
89
|
+
}));
|
100
90
|
}
|
101
|
-
|
91
|
+
// When everything is done, clean up the values array
|
92
|
+
return () => {
|
93
|
+
values.length = 0;
|
94
|
+
};
|
102
95
|
});
|
103
96
|
}
|
104
97
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@adminide-stack/extension-api",
|
3
|
-
"version": "9.1.1-alpha.
|
3
|
+
"version": "9.1.1-alpha.72",
|
4
4
|
"description": "Workbench core for higher packages to depend on",
|
5
5
|
"license": "ISC",
|
6
6
|
"author": "CDMBase LLC",
|
@@ -20,29 +20,12 @@
|
|
20
20
|
"test:watch": "npm test -- --watch",
|
21
21
|
"watch": "npm run build:lib:watch"
|
22
22
|
},
|
23
|
-
"jest": {
|
24
|
-
"moduleFileExtensions": [
|
25
|
-
"ts",
|
26
|
-
"tsx",
|
27
|
-
"js",
|
28
|
-
"json"
|
29
|
-
],
|
30
|
-
"roots": [
|
31
|
-
"src"
|
32
|
-
],
|
33
|
-
"testEnvironment": "node",
|
34
|
-
"testRegex": "/__tests__/.*test*\\.(ts|tsx|js)$",
|
35
|
-
"transform": {
|
36
|
-
"\\.(ts|tsx)$": "<rootDir>/../../node_modules/ts-jest/preprocessor.js"
|
37
|
-
}
|
38
|
-
},
|
39
23
|
"dependencies": {
|
40
|
-
"@adminide-stack/core": "9.1.1-alpha.
|
41
|
-
"@workbench-stack/core": "3.
|
42
|
-
"abort-controller": "^
|
43
|
-
"abortable-rx": "^1.0.9",
|
24
|
+
"@adminide-stack/core": "9.1.1-alpha.72",
|
25
|
+
"@workbench-stack/core": "3.9.5",
|
26
|
+
"abort-controller": "^3.0.0",
|
44
27
|
"cdeops": "9.1.1-alpha.43",
|
45
|
-
"minimatch": "^
|
28
|
+
"minimatch": "^10.0.0",
|
46
29
|
"queueing-subject": "0.3.4",
|
47
30
|
"utility-types": "^3.10.0",
|
48
31
|
"valid-url": "1.0.9"
|
@@ -60,5 +43,5 @@
|
|
60
43
|
"typescript": {
|
61
44
|
"definition": "lib/index.d.ts"
|
62
45
|
},
|
63
|
-
"gitHead": "
|
46
|
+
"gitHead": "20f2f1fe7f81d2e7de03303e022623eb0522fa8f"
|
64
47
|
}
|