@adminide-stack/extension-api 9.0.6-alpha.6 → 9.1.1-alpha.101

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 React__default,{useState,useEffect}from'react';import {Subscription}from'rxjs';import {map}from'rxjs/operators/index.js';import {useExtensionController}from'../../useExtensionController.js';import {ContributableViewContainer}from'../../../interfaces/contributions/contribution.js';const ViewComponent = (props) => {
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}from'rxjs';import {switchMap as switchMap$1,concatMap as concatMap$1,mergeMap as mergeMap$1}from'rxjs/operators/index.js';/**
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 { Observable, ObservableInput } from 'rxjs';
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
- * @return {Observable} An Observable of an array of the most recent values from each input Observable (or
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';import {fromArray}from'rxjs-compat/observable/fromArray.js';import {OuterSubscriber}from'rxjs-compat/OuterSubscriber.js';import {asap}from'rxjs-compat/scheduler/asap.js';import {subscribeToResult}from'rxjs-compat/util/subscribeToResult.js';// tslint:disable no-use-before-declare
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
- * @return {Observable} An Observable of an array of the most recent values from each input Observable (or
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
- case 1:
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
- // Buffer all next values that are emitted at the same time into one emission.
90
- //
91
- // This makes tests (using expectObservable) easier to write.
92
- if (!this.scheduled) {
93
- this.scheduled = true;
94
- asap.schedule(() => {
95
- if (this.scheduled && this.destination.next) {
96
- this.destination.next(this.values.slice());
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
- this.scheduled = false;
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.0.6-alpha.6",
3
+ "version": "9.1.1-alpha.101",
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.0.6-alpha.6",
41
- "@workbench-stack/core": "3.6.0",
42
- "abort-controller": "^2.0.0",
43
- "abortable-rx": "^1.0.9",
44
- "cdeops": "9.0.6-alpha.6",
45
- "minimatch": "^9.0.0",
24
+ "@adminide-stack/core": "9.1.1-alpha.101",
25
+ "@workbench-stack/core": "3.9.5",
26
+ "abort-controller": "^3.0.0",
27
+ "cdeops": "9.1.1-alpha.97",
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": "^6.3.3"
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": "4665163712a25b3c106ede1ef3a4eee5d337ea8e"
46
+ "gitHead": "b38b7112b3bbeaef36b7ee90c36fadb54ed4ca45"
64
47
  }