@adminide-stack/extension-api 9.1.1-alpha.52 → 9.1.1-alpha.64
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/lib/connections/jsonrpc2/connection.js +11 -11
- package/lib/connections/remote-rpc/browser-remote-rpc.js +1 -1
- package/lib/react/components/view-component/ViewComponent.js +1 -1
- package/lib/utils/abortable-rx.js +9 -9
- package/lib/utils/rxjs/combineLatestOrDefault.d.ts +2 -2
- package/lib/utils/rxjs/combineLatestOrDefault.js +62 -66
- package/package.json +7 -24
@@ -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 */
|
@@ -155,7 +155,7 @@ function _createConnection(transports, logger) {
|
|
155
155
|
}
|
156
156
|
}
|
157
157
|
const callback = (message) => {
|
158
|
-
console.log(
|
158
|
+
console.log('[callback.ON_MESSAGE]: ', { transports, message });
|
159
159
|
try {
|
160
160
|
// We have received an abort signal. Check if the message is still in the queue and abort it if allowed
|
161
161
|
// to do so.
|
@@ -237,7 +237,8 @@ function _createConnection(transports, logger) {
|
|
237
237
|
transports.writer.write(message);
|
238
238
|
}
|
239
239
|
tracer.requestReceived(requestMessage);
|
240
|
-
const element = requestHandlers[requestMessage.method] ||
|
240
|
+
const element = requestHandlers[requestMessage.method] ||
|
241
|
+
requestHandlers[matchedStartActor(Object.keys(requestHandlers), requestMessage.method)];
|
241
242
|
const requestHandler = element && element.handler;
|
242
243
|
if (requestHandler || starRequestHandler) {
|
243
244
|
const abortController = new AbortController();
|
@@ -256,7 +257,7 @@ function _createConnection(transports, logger) {
|
|
256
257
|
const onComplete = () => {
|
257
258
|
delete requestAbortControllers[signalKey];
|
258
259
|
};
|
259
|
-
from(handlerResult).subscribe(value => reply(value, false), error => {
|
260
|
+
from(handlerResult).subscribe((value) => reply(value, false), (error) => {
|
260
261
|
onComplete();
|
261
262
|
if (error instanceof ResponseError) {
|
262
263
|
replyError(error);
|
@@ -470,15 +471,14 @@ function _createConnection(transports, logger) {
|
|
470
471
|
catch (e) {
|
471
472
|
responseObserver.observer.error(new ResponseError(ErrorCodes.MessageWriteError, e.message ? e.message : 'Unknown reason'));
|
472
473
|
}
|
473
|
-
return new Observable(observer => {
|
474
|
-
subject.subscribe(observer)
|
475
|
-
|
476
|
-
|
477
|
-
!responseObserver.complete &&
|
478
|
-
!responseObserver.observer.closed) {
|
474
|
+
return new Observable((observer) => {
|
475
|
+
const subscription = subject.subscribe(observer);
|
476
|
+
subscription.add(() => {
|
477
|
+
if (!isUnsubscribed() && responseObserver && !responseObserver.complete && !subscription.closed) {
|
479
478
|
sendNotification(ABORT_REQUEST_METHOD, [id]);
|
480
479
|
}
|
481
480
|
});
|
481
|
+
return subscription;
|
482
482
|
});
|
483
483
|
};
|
484
484
|
const connection = {
|
@@ -557,7 +557,7 @@ function setImmediateCompat(f) {
|
|
557
557
|
}
|
558
558
|
function matchedStartActor(requestHandlersKeys, method) {
|
559
559
|
try {
|
560
|
-
return requestHandlersKeys.filter(name => {
|
560
|
+
return requestHandlersKeys.filter((name) => {
|
561
561
|
let methodName = method.split('/')[0];
|
562
562
|
return `${methodName}/*` === name;
|
563
563
|
})[0];
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {QueueingSubject}from'queueing-subject';import {VSBuffer}from'@vscode-alt/monaco-editor/esm/vs/base/common/buffer.js';import {Emitter}from'@vscode-alt/monaco-editor/esm/vs/base/common/event.js';import makeWebSocketObservable,{normalClosureMessage}from'./rxjs-websockets.js';import {switchMap,share}from'rxjs
|
1
|
+
import {QueueingSubject}from'queueing-subject';import {VSBuffer}from'@vscode-alt/monaco-editor/esm/vs/base/common/buffer.js';import {Emitter}from'@vscode-alt/monaco-editor/esm/vs/base/common/event.js';import makeWebSocketObservable,{normalClosureMessage}from'./rxjs-websockets.js';import {switchMap,share}from'rxjs';class BrowserRemoteRPC {
|
2
2
|
// this subject queues as necessary to ensure every message is delivered
|
3
3
|
input$;
|
4
4
|
_localHostId;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import React__default,{useState,useEffect}from'react';import {Subscription
|
1
|
+
import React__default,{useState,useEffect}from'react';import {Subscription,map}from'rxjs';import {useExtensionController}from'../../useExtensionController.js';import {ContributableViewContainer}from'../../../interfaces/contributions/contribution.js';const ViewComponent = (props) => {
|
2
2
|
const [panelView, setPanelView] = useState(null);
|
3
3
|
const controller = useExtensionController();
|
4
4
|
const subscriptions = new Subscription();
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {Observable,Subscription,from
|
1
|
+
import {Observable,Subscription,from,switchMap as switchMap$1,concatMap as concatMap$1,mergeMap as mergeMap$1}from'rxjs';/**
|
2
2
|
* Copied from https://github.com/felixfbecker/abortable-rx/blob/master/src/index.ts
|
3
3
|
* To support esm
|
4
4
|
* @returns
|
@@ -12,7 +12,7 @@ const createAbortError = () => {
|
|
12
12
|
/**
|
13
13
|
* Creates an Observable just like RxJS `create`, but exposes an AbortSignal in addition to the subscriber
|
14
14
|
*/
|
15
|
-
const create = (subscribe) => new Observable(subscriber => {
|
15
|
+
const create = (subscribe) => new Observable((subscriber) => {
|
16
16
|
const abortController = new AbortController();
|
17
17
|
const subscription = new Subscription();
|
18
18
|
const teardown = subscribe && subscribe(subscriber, abortController.signal);
|
@@ -45,9 +45,9 @@ const toPromise = (observable, signal) => new Promise((resolve, reject) => {
|
|
45
45
|
}
|
46
46
|
};
|
47
47
|
let value;
|
48
|
-
subscription = observable.subscribe(val => {
|
48
|
+
subscription = observable.subscribe((val) => {
|
49
49
|
value = val;
|
50
|
-
}, err => {
|
50
|
+
}, (err) => {
|
51
51
|
cleanup();
|
52
52
|
reject(err);
|
53
53
|
}, () => {
|
@@ -77,7 +77,7 @@ const forEach = (source, next, signal) => new Promise((resolve, reject) => {
|
|
77
77
|
signal.removeEventListener('abort', listener);
|
78
78
|
}
|
79
79
|
};
|
80
|
-
subscription = source.subscribe(value => {
|
80
|
+
subscription = source.subscribe((value) => {
|
81
81
|
try {
|
82
82
|
next(value);
|
83
83
|
}
|
@@ -87,7 +87,7 @@ const forEach = (source, next, signal) => new Promise((resolve, reject) => {
|
|
87
87
|
subscription.unsubscribe();
|
88
88
|
}
|
89
89
|
}
|
90
|
-
}, err => {
|
90
|
+
}, (err) => {
|
91
91
|
cleanup();
|
92
92
|
reject(err);
|
93
93
|
}, () => {
|
@@ -101,12 +101,12 @@ const forEach = (source, next, signal) => new Promise((resolve, reject) => {
|
|
101
101
|
/**
|
102
102
|
* Like RxJS `switchMap`, but passes an AbortSignal that is aborted when the source emits another element.
|
103
103
|
*/
|
104
|
-
const switchMap = (project) => source => source.pipe(switchMap$1((value, index) => defer(abortSignal => project(value, index, abortSignal))));
|
104
|
+
const switchMap = (project) => (source) => source.pipe(switchMap$1((value, index) => defer((abortSignal) => project(value, index, abortSignal))));
|
105
105
|
/**
|
106
106
|
* Like RxJS `concatMap`, but passes an AbortSignal that is aborted when the returned Observable is unsubscribed from.
|
107
107
|
*/
|
108
|
-
const concatMap = (project) => source => source.pipe(concatMap$1((value, index) => defer(abortSignal => project(value, index, abortSignal))));
|
108
|
+
const concatMap = (project) => (source) => source.pipe(concatMap$1((value, index) => defer((abortSignal) => project(value, index, abortSignal))));
|
109
109
|
/**
|
110
110
|
* Like RxJS `mergeMap`, but passes an AbortSignal that is aborted when the returned Observable is unsubscribed from.
|
111
111
|
*/
|
112
|
-
const mergeMap = (project) => source => source.pipe(mergeMap$1((value, index) => defer(abortSignal => project(value, index, abortSignal))));export{concatMap,create,defer,forEach,mergeMap,switchMap,toPromise};
|
112
|
+
const mergeMap = (project) => (source) => source.pipe(mergeMap$1((value, index) => defer((abortSignal) => project(value, index, abortSignal))));export{concatMap,create,defer,forEach,mergeMap,switchMap,toPromise};
|
@@ -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}from'rxjs'
|
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,80 +21,77 @@ import {zip,of}from'rxjs';import {fromArray}from'rxjs-compat/observable/fromArra
|
|
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 OuterSubscriber {
|
50
|
-
defaultValue;
|
51
|
-
activeObservables = 0;
|
52
|
-
values = [];
|
53
|
-
observables = [];
|
54
|
-
scheduled = false;
|
55
|
-
constructor(observer, defaultValue) {
|
56
|
-
super(observer);
|
57
|
-
this.defaultValue = defaultValue;
|
58
|
-
}
|
59
|
-
_next(observable) {
|
60
|
-
if (this.defaultValue !== undefined) {
|
61
|
-
this.values.push(this.defaultValue);
|
62
|
-
}
|
63
|
-
this.observables.push(observable);
|
64
|
-
}
|
65
|
-
_complete() {
|
66
|
-
this.activeObservables = this.observables.length;
|
67
|
-
for (let i = 0; i < this.observables.length; i++) {
|
68
|
-
this.add(subscribeToResult(this, this.observables[i], this.observables[i], i));
|
69
|
-
}
|
70
|
-
}
|
71
|
-
notifyComplete() {
|
72
|
-
this.activeObservables--;
|
73
|
-
if (this.activeObservables === 0 && this.destination.complete) {
|
74
|
-
this.destination.complete();
|
75
|
-
}
|
76
|
-
}
|
77
|
-
notifyNext(_outerValue, innerValue, outerIndex) {
|
78
|
-
const values = this.values;
|
79
|
-
values[outerIndex] = innerValue;
|
80
|
-
if (this.activeObservables === 1) {
|
81
|
-
// Only 1 observable is active, so no need to buffer.
|
82
|
-
//
|
83
|
-
// This makes it possible to use RxJS's `of` in tests without specifying an explicit scheduler.
|
84
|
-
if (this.destination.next) {
|
85
|
-
this.destination.next(this.values.slice());
|
86
|
-
}
|
87
|
-
return;
|
88
36
|
}
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
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
|
+
}));
|
97
90
|
}
|
98
|
-
|
91
|
+
// When everything is done, clean up the values array
|
92
|
+
return () => {
|
93
|
+
values.length = 0;
|
94
|
+
};
|
99
95
|
});
|
100
96
|
}
|
101
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.64",
|
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.64",
|
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"
|
@@ -52,7 +35,7 @@
|
|
52
35
|
},
|
53
36
|
"peerDependencies": {
|
54
37
|
"@vscode-alt/monaco-editor": ">=0.17.1",
|
55
|
-
"rxjs": "^
|
38
|
+
"rxjs": "^7.8.1"
|
56
39
|
},
|
57
40
|
"publishConfig": {
|
58
41
|
"access": "public"
|
@@ -60,5 +43,5 @@
|
|
60
43
|
"typescript": {
|
61
44
|
"definition": "lib/index.d.ts"
|
62
45
|
},
|
63
|
-
"gitHead": "
|
46
|
+
"gitHead": "08d13dffd33130f335fd460aedb5e393d6fdb3eb"
|
64
47
|
}
|