@vscode/component-explorer-cli 0.1.1-0 → 0.1.1-1
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/browserPage.js +4 -2
- package/dist/browserPage.js.map +1 -1
- package/dist/commands/acceptCommand.d.ts +1 -0
- package/dist/commands/acceptCommand.d.ts.map +1 -1
- package/dist/commands/acceptCommand.js +8 -2
- package/dist/commands/acceptCommand.js.map +1 -1
- package/dist/commands/compareCommand.d.ts +1 -0
- package/dist/commands/compareCommand.d.ts.map +1 -1
- package/dist/commands/compareCommand.js +8 -2
- package/dist/commands/compareCommand.js.map +1 -1
- package/dist/commands/screenshotCommand.d.ts +1 -0
- package/dist/commands/screenshotCommand.d.ts.map +1 -1
- package/dist/commands/screenshotCommand.js +10 -4
- package/dist/commands/screenshotCommand.js.map +1 -1
- package/dist/commands/watchCommand.d.ts +1 -0
- package/dist/commands/watchCommand.d.ts.map +1 -1
- package/dist/commands/watchCommand.js +17 -8
- package/dist/commands/watchCommand.js.map +1 -1
- package/dist/componentExplorer.js +5 -2
- package/dist/componentExplorer.js.map +1 -1
- package/dist/dependencyInstaller.js +7 -4
- package/dist/dependencyInstaller.js.map +1 -1
- package/dist/explorerSession.js +6 -3
- package/dist/explorerSession.js.map +1 -1
- package/dist/external/vscode-observables/observables/dist/disposables.js +43 -0
- package/dist/external/vscode-observables/observables/dist/disposables.js.map +1 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/base.js +22 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/base.js.map +1 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/commonFacade/deps.js +40 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/commonFacade/deps.js.map +1 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/debugLocation.js +74 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/debugLocation.js.map +1 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/debugName.js +114 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/debugName.js.map +1 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/index.js +25 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/index.js.map +1 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/logging/consoleObservableLogger.js +332 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/logging/consoleObservableLogger.js.map +1 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/logging/debugGetDependencyGraph.js +79 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/logging/debugGetDependencyGraph.js.map +1 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/logging/debugger/debuggerRpc.js +72 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/logging/debugger/debuggerRpc.js.map +1 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/logging/debugger/devToolsLogger.js +447 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/logging/debugger/devToolsLogger.js.map +1 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/logging/debugger/rpc.js +64 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/logging/debugger/rpc.js.map +1 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/logging/debugger/utils.js +52 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/logging/debugger/utils.js.map +1 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/logging/logging.js +100 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/logging/logging.js.map +1 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/observables/baseObservable.js +143 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/observables/baseObservable.js.map +1 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/observables/derived.js +17 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/observables/derived.js.map +1 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/observables/derivedImpl.js +362 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/observables/derivedImpl.js.map +1 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/observables/observableFromEvent.js +123 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/observables/observableFromEvent.js.map +1 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/observables/observableValue.js +81 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/observables/observableValue.js.map +1 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/reactions/autorun.js +23 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/reactions/autorun.js.map +1 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/reactions/autorunImpl.js +226 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/reactions/autorunImpl.js.map +1 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/transaction.js +87 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/transaction.js.map +1 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/utils/utils.js +68 -0
- package/dist/external/vscode-observables/observables/dist/observableInternal/utils/utils.js.map +1 -0
- package/dist/git/gitCommitId.js +4 -2
- package/dist/git/gitCommitId.js.map +1 -1
- package/dist/git/gitCommitResolver.js +11 -3
- package/dist/git/gitCommitResolver.js.map +1 -1
- package/dist/git/gitService.js +5 -2
- package/dist/git/gitService.js.map +1 -1
- package/dist/git/gitUtils.js +9 -6
- package/dist/git/gitUtils.js.map +1 -1
- package/dist/git/gitWorktreeManager.js +5 -2
- package/dist/git/gitWorktreeManager.js.map +1 -1
- package/dist/httpServer.d.ts +3 -2
- package/dist/httpServer.d.ts.map +1 -1
- package/dist/httpServer.js +27 -10
- package/dist/httpServer.js.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +17 -1
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +43 -6
- package/dist/logger.js.map +1 -1
- package/dist/screenshotCache.js +7 -4
- package/dist/screenshotCache.js.map +1 -1
- package/dist/sourceTreeId.js +4 -2
- package/dist/sourceTreeId.js.map +1 -1
- package/dist/storage.js +5 -2
- package/dist/storage.js.map +1 -1
- package/dist/viteProjectRef.js +5 -2
- package/dist/viteProjectRef.js.map +1 -1
- package/dist/watchConfig.js +8 -5
- package/dist/watchConfig.js.map +1 -1
- package/package.json +7 -4
package/dist/external/vscode-observables/observables/dist/observableInternal/logging/logging.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/*---------------------------------------------------------------------------------------------
|
|
6
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
8
|
+
*--------------------------------------------------------------------------------------------*/
|
|
9
|
+
let globalObservableLogger;
|
|
10
|
+
function addLogger(logger) {
|
|
11
|
+
if (!globalObservableLogger) {
|
|
12
|
+
globalObservableLogger = logger;
|
|
13
|
+
}
|
|
14
|
+
else if (globalObservableLogger instanceof ComposedLogger) {
|
|
15
|
+
globalObservableLogger.loggers.push(logger);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
globalObservableLogger = new ComposedLogger([globalObservableLogger, logger]);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function getLogger() {
|
|
22
|
+
return globalObservableLogger;
|
|
23
|
+
}
|
|
24
|
+
let globalObservableLoggerFn = undefined;
|
|
25
|
+
function setLogObservableFn(fn) {
|
|
26
|
+
globalObservableLoggerFn = fn;
|
|
27
|
+
}
|
|
28
|
+
function logObservable(obs) {
|
|
29
|
+
if (globalObservableLoggerFn) {
|
|
30
|
+
globalObservableLoggerFn(obs);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
class ComposedLogger {
|
|
34
|
+
constructor(loggers) {
|
|
35
|
+
this.loggers = loggers;
|
|
36
|
+
}
|
|
37
|
+
handleObservableCreated(observable, location) {
|
|
38
|
+
for (const logger of this.loggers) {
|
|
39
|
+
logger.handleObservableCreated(observable, location);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
handleOnListenerCountChanged(observable, newCount) {
|
|
43
|
+
for (const logger of this.loggers) {
|
|
44
|
+
logger.handleOnListenerCountChanged(observable, newCount);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
handleObservableUpdated(observable, info) {
|
|
48
|
+
for (const logger of this.loggers) {
|
|
49
|
+
logger.handleObservableUpdated(observable, info);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
handleAutorunCreated(autorun, location) {
|
|
53
|
+
for (const logger of this.loggers) {
|
|
54
|
+
logger.handleAutorunCreated(autorun, location);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
handleAutorunDisposed(autorun) {
|
|
58
|
+
for (const logger of this.loggers) {
|
|
59
|
+
logger.handleAutorunDisposed(autorun);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
handleAutorunDependencyChanged(autorun, observable, change) {
|
|
63
|
+
for (const logger of this.loggers) {
|
|
64
|
+
logger.handleAutorunDependencyChanged(autorun, observable, change);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
handleAutorunStarted(autorun) {
|
|
68
|
+
for (const logger of this.loggers) {
|
|
69
|
+
logger.handleAutorunStarted(autorun);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
handleAutorunFinished(autorun) {
|
|
73
|
+
for (const logger of this.loggers) {
|
|
74
|
+
logger.handleAutorunFinished(autorun);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
handleDerivedDependencyChanged(derived, observable, change) {
|
|
78
|
+
for (const logger of this.loggers) {
|
|
79
|
+
logger.handleDerivedDependencyChanged(derived, observable, change);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
handleDerivedCleared(observable) {
|
|
83
|
+
for (const logger of this.loggers) {
|
|
84
|
+
logger.handleDerivedCleared(observable);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
handleBeginTransaction(transaction) {
|
|
88
|
+
for (const logger of this.loggers) {
|
|
89
|
+
logger.handleBeginTransaction(transaction);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
handleEndTransaction(transaction) {
|
|
93
|
+
for (const logger of this.loggers) {
|
|
94
|
+
logger.handleEndTransaction(transaction);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export { addLogger, getLogger, logObservable, setLogObservableFn };
|
|
100
|
+
//# sourceMappingURL=logging.js.map
|
package/dist/external/vscode-observables/observables/dist/observableInternal/logging/logging.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.js","sources":["../../../../../../../../../external/vscode-observables/observables/dist/observableInternal/logging/logging.js"],"sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\nlet globalObservableLogger;\nfunction addLogger(logger) {\n if (!globalObservableLogger) {\n globalObservableLogger = logger;\n }\n else if (globalObservableLogger instanceof ComposedLogger) {\n globalObservableLogger.loggers.push(logger);\n }\n else {\n globalObservableLogger = new ComposedLogger([globalObservableLogger, logger]);\n }\n}\nfunction getLogger() {\n return globalObservableLogger;\n}\nlet globalObservableLoggerFn = undefined;\nfunction setLogObservableFn(fn) {\n globalObservableLoggerFn = fn;\n}\nfunction logObservable(obs) {\n if (globalObservableLoggerFn) {\n globalObservableLoggerFn(obs);\n }\n}\nclass ComposedLogger {\n constructor(loggers) {\n this.loggers = loggers;\n }\n handleObservableCreated(observable, location) {\n for (const logger of this.loggers) {\n logger.handleObservableCreated(observable, location);\n }\n }\n handleOnListenerCountChanged(observable, newCount) {\n for (const logger of this.loggers) {\n logger.handleOnListenerCountChanged(observable, newCount);\n }\n }\n handleObservableUpdated(observable, info) {\n for (const logger of this.loggers) {\n logger.handleObservableUpdated(observable, info);\n }\n }\n handleAutorunCreated(autorun, location) {\n for (const logger of this.loggers) {\n logger.handleAutorunCreated(autorun, location);\n }\n }\n handleAutorunDisposed(autorun) {\n for (const logger of this.loggers) {\n logger.handleAutorunDisposed(autorun);\n }\n }\n handleAutorunDependencyChanged(autorun, observable, change) {\n for (const logger of this.loggers) {\n logger.handleAutorunDependencyChanged(autorun, observable, change);\n }\n }\n handleAutorunStarted(autorun) {\n for (const logger of this.loggers) {\n logger.handleAutorunStarted(autorun);\n }\n }\n handleAutorunFinished(autorun) {\n for (const logger of this.loggers) {\n logger.handleAutorunFinished(autorun);\n }\n }\n handleDerivedDependencyChanged(derived, observable, change) {\n for (const logger of this.loggers) {\n logger.handleDerivedDependencyChanged(derived, observable, change);\n }\n }\n handleDerivedCleared(observable) {\n for (const logger of this.loggers) {\n logger.handleDerivedCleared(observable);\n }\n }\n handleBeginTransaction(transaction) {\n for (const logger of this.loggers) {\n logger.handleBeginTransaction(transaction);\n }\n }\n handleEndTransaction(transaction) {\n for (const logger of this.loggers) {\n logger.handleEndTransaction(transaction);\n }\n }\n}\n\nexport { addLogger, getLogger, logObservable, setLogObservableFn };\n//# sourceMappingURL=logging.js.map\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,sBAAsB;AAC1B,SAAS,SAAS,CAAC,MAAM,EAAE;AAC3B,IAAI,IAAI,CAAC,sBAAsB,EAAE;AACjC,QAAQ,sBAAsB,GAAG,MAAM;AACvC,IAAI;AACJ,SAAS,IAAI,sBAAsB,YAAY,cAAc,EAAE;AAC/D,QAAQ,sBAAsB,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;AACnD,IAAI;AACJ,S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AACR,IAAI;AACJ,IAAI,sBAAsB,CAAC,WAAW,EAAE;AACxC,QAAQ,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE;AAC3C,YAAY,MAAM,CAAC,sBAAsB,CAAC,WAAW,CAAC;AACtD,QAAQ;AACR,IAAI;AACJ,IAAI,oBAAoB,CAAC,WAAW,EAAE;AACtC,QAAQ,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE;AAC3C,YAAY,MAAM,CAAC,oBAAoB,CAAC,WAAW,CAAC;AACpD,QAAQ;AACR,IAAI;AACJ;;;;"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { DebugLocation } from '../debugLocation.js';
|
|
2
|
+
import { getFunctionName } from '../debugName.js';
|
|
3
|
+
import { getLogger, logObservable } from '../logging/logging.js';
|
|
4
|
+
|
|
5
|
+
/*---------------------------------------------------------------------------------------------
|
|
6
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
8
|
+
*--------------------------------------------------------------------------------------------*/
|
|
9
|
+
|
|
10
|
+
/*---------------------------------------------------------------------------------------------
|
|
11
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
12
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
13
|
+
*--------------------------------------------------------------------------------------------*/
|
|
14
|
+
let _derived;
|
|
15
|
+
/**
|
|
16
|
+
* @internal
|
|
17
|
+
* This is to allow splitting files.
|
|
18
|
+
*/
|
|
19
|
+
function _setDerivedOpts(derived) {
|
|
20
|
+
_derived = derived;
|
|
21
|
+
}
|
|
22
|
+
let _recomputeInitiallyAndOnChange;
|
|
23
|
+
function _setRecomputeInitiallyAndOnChange(recomputeInitiallyAndOnChange) {
|
|
24
|
+
_recomputeInitiallyAndOnChange = recomputeInitiallyAndOnChange;
|
|
25
|
+
}
|
|
26
|
+
let _keepObserved;
|
|
27
|
+
function _setKeepObserved(keepObserved) {
|
|
28
|
+
_keepObserved = keepObserved;
|
|
29
|
+
}
|
|
30
|
+
let _debugGetDependencyGraph;
|
|
31
|
+
function _setDebugGetDependencyGraph(debugGetDependencyGraph) {
|
|
32
|
+
_debugGetDependencyGraph = debugGetDependencyGraph;
|
|
33
|
+
}
|
|
34
|
+
class ConvenientObservable {
|
|
35
|
+
get TChange() { return null; }
|
|
36
|
+
reportChanges() {
|
|
37
|
+
this.get();
|
|
38
|
+
}
|
|
39
|
+
/** @sealed */
|
|
40
|
+
read(reader) {
|
|
41
|
+
if (reader) {
|
|
42
|
+
return reader.readObservable(this);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
return this.get();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
map(fnOrOwner, fnOrUndefined, debugLocation = DebugLocation.ofCaller()) {
|
|
49
|
+
const owner = fnOrUndefined === undefined ? undefined : fnOrOwner;
|
|
50
|
+
const fn = fnOrUndefined === undefined ? fnOrOwner : fnOrUndefined;
|
|
51
|
+
return _derived({
|
|
52
|
+
owner,
|
|
53
|
+
debugName: () => {
|
|
54
|
+
const name = getFunctionName(fn);
|
|
55
|
+
if (name !== undefined) {
|
|
56
|
+
return name;
|
|
57
|
+
}
|
|
58
|
+
// regexp to match `x => x.y` or `x => x?.y` where x and y can be arbitrary identifiers (uses backref):
|
|
59
|
+
const regexp = /^\s*\(?\s*([a-zA-Z_$][a-zA-Z_$0-9]*)\s*\)?\s*=>\s*\1(?:\??)\.([a-zA-Z_$][a-zA-Z_$0-9]*)\s*$/;
|
|
60
|
+
const match = regexp.exec(fn.toString());
|
|
61
|
+
if (match) {
|
|
62
|
+
return `${this.debugName}.${match[2]}`;
|
|
63
|
+
}
|
|
64
|
+
if (!owner) {
|
|
65
|
+
return `${this.debugName} (mapped)`;
|
|
66
|
+
}
|
|
67
|
+
return undefined;
|
|
68
|
+
},
|
|
69
|
+
debugReferenceFn: fn,
|
|
70
|
+
}, (reader) => fn(this.read(reader), reader), debugLocation);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @sealed
|
|
74
|
+
* Converts an observable of an observable value into a direct observable of the value.
|
|
75
|
+
*/
|
|
76
|
+
flatten() {
|
|
77
|
+
return _derived({
|
|
78
|
+
owner: undefined,
|
|
79
|
+
debugName: () => `${this.debugName} (flattened)`,
|
|
80
|
+
}, (reader) => this.read(reader).read(reader));
|
|
81
|
+
}
|
|
82
|
+
recomputeInitiallyAndOnChange(store, handleValue) {
|
|
83
|
+
store.add(_recomputeInitiallyAndOnChange(this, handleValue));
|
|
84
|
+
return this;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Ensures that this observable is observed. This keeps the cache alive.
|
|
88
|
+
* However, in case of deriveds, it does not force eager evaluation (only when the value is read/get).
|
|
89
|
+
* Use `recomputeInitiallyAndOnChange` for eager evaluation.
|
|
90
|
+
*/
|
|
91
|
+
keepObserved(store) {
|
|
92
|
+
store.add(_keepObserved(this));
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
get debugValue() {
|
|
96
|
+
return this.get();
|
|
97
|
+
}
|
|
98
|
+
debugGetDependencyGraph() {
|
|
99
|
+
return _debugGetDependencyGraph(this);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
class BaseObservable extends ConvenientObservable {
|
|
103
|
+
constructor(debugLocation) {
|
|
104
|
+
super();
|
|
105
|
+
this._observers = new Set();
|
|
106
|
+
getLogger()?.handleObservableCreated(this, debugLocation);
|
|
107
|
+
}
|
|
108
|
+
addObserver(observer) {
|
|
109
|
+
const len = this._observers.size;
|
|
110
|
+
this._observers.add(observer);
|
|
111
|
+
if (len === 0) {
|
|
112
|
+
this.onFirstObserverAdded();
|
|
113
|
+
}
|
|
114
|
+
if (len !== this._observers.size) {
|
|
115
|
+
getLogger()?.handleOnListenerCountChanged(this, this._observers.size);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
removeObserver(observer) {
|
|
119
|
+
const deleted = this._observers.delete(observer);
|
|
120
|
+
if (deleted && this._observers.size === 0) {
|
|
121
|
+
this.onLastObserverRemoved();
|
|
122
|
+
}
|
|
123
|
+
if (deleted) {
|
|
124
|
+
getLogger()?.handleOnListenerCountChanged(this, this._observers.size);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
onFirstObserverAdded() { }
|
|
128
|
+
onLastObserverRemoved() { }
|
|
129
|
+
log() {
|
|
130
|
+
const hadLogger = !!getLogger();
|
|
131
|
+
logObservable(this);
|
|
132
|
+
if (!hadLogger) {
|
|
133
|
+
getLogger()?.handleObservableCreated(this, DebugLocation.ofCaller());
|
|
134
|
+
}
|
|
135
|
+
return this;
|
|
136
|
+
}
|
|
137
|
+
debugGetObservers() {
|
|
138
|
+
return this._observers;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export { BaseObservable, ConvenientObservable, _setDebugGetDependencyGraph, _setDerivedOpts, _setKeepObserved, _setRecomputeInitiallyAndOnChange };
|
|
143
|
+
//# sourceMappingURL=baseObservable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseObservable.js","sources":["../../../../../../../../../external/vscode-observables/observables/dist/observableInternal/observables/baseObservable.js"],"sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\nimport { DebugLocation } from '../debugLocation.js';\nimport { getFunctionName } from '../debugName.js';\nimport { getLogger, logObservable } from '../logging/logging.js';\n\n/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\nlet _derived;\n/**\n * @internal\n * This is to allow splitting files.\n*/\nfunction _setDerivedOpts(derived) {\n _derived = derived;\n}\nlet _recomputeInitiallyAndOnChange;\nfunction _setRecomputeInitiallyAndOnChange(recomputeInitiallyAndOnChange) {\n _recomputeInitiallyAndOnChange = recomputeInitiallyAndOnChange;\n}\nlet _keepObserved;\nfunction _setKeepObserved(keepObserved) {\n _keepObserved = keepObserved;\n}\nlet _debugGetDependencyGraph;\nfunction _setDebugGetDependencyGraph(debugGetDependencyGraph) {\n _debugGetDependencyGraph = debugGetDependencyGraph;\n}\nclass ConvenientObservable {\n get TChange() { return null; }\n reportChanges() {\n this.get();\n }\n /** @sealed */\n read(reader) {\n if (reader) {\n return reader.readObservable(this);\n }\n else {\n return this.get();\n }\n }\n map(fnOrOwner, fnOrUndefined, debugLocation = DebugLocation.ofCaller()) {\n const owner = fnOrUndefined === undefined ? undefined : fnOrOwner;\n const fn = fnOrUndefined === undefined ? fnOrOwner : fnOrUndefined;\n return _derived({\n owner,\n debugName: () => {\n const name = getFunctionName(fn);\n if (name !== undefined) {\n return name;\n }\n // regexp to match `x => x.y` or `x => x?.y` where x and y can be arbitrary identifiers (uses backref):\n const regexp = /^\\s*\\(?\\s*([a-zA-Z_$][a-zA-Z_$0-9]*)\\s*\\)?\\s*=>\\s*\\1(?:\\??)\\.([a-zA-Z_$][a-zA-Z_$0-9]*)\\s*$/;\n const match = regexp.exec(fn.toString());\n if (match) {\n return `${this.debugName}.${match[2]}`;\n }\n if (!owner) {\n return `${this.debugName} (mapped)`;\n }\n return undefined;\n },\n debugReferenceFn: fn,\n }, (reader) => fn(this.read(reader), reader), debugLocation);\n }\n /**\n * @sealed\n * Converts an observable of an observable value into a direct observable of the value.\n */\n flatten() {\n return _derived({\n owner: undefined,\n debugName: () => `${this.debugName} (flattened)`,\n }, (reader) => this.read(reader).read(reader));\n }\n recomputeInitiallyAndOnChange(store, handleValue) {\n store.add(_recomputeInitiallyAndOnChange(this, handleValue));\n return this;\n }\n /**\n * Ensures that this observable is observed. This keeps the cache alive.\n * However, in case of deriveds, it does not force eager evaluation (only when the value is read/get).\n * Use `recomputeInitiallyAndOnChange` for eager evaluation.\n */\n keepObserved(store) {\n store.add(_keepObserved(this));\n return this;\n }\n get debugValue() {\n return this.get();\n }\n debugGetDependencyGraph() {\n return _debugGetDependencyGraph(this);\n }\n}\nclass BaseObservable extends ConvenientObservable {\n constructor(debugLocation) {\n super();\n this._observers = new Set();\n getLogger()?.handleObservableCreated(this, debugLocation);\n }\n addObserver(observer) {\n const len = this._observers.size;\n this._observers.add(observer);\n if (len === 0) {\n this.onFirstObserverAdded();\n }\n if (len !== this._observers.size) {\n getLogger()?.handleOnListenerCountChanged(this, this._observers.size);\n }\n }\n removeObserver(observer) {\n const deleted = this._observers.delete(observer);\n if (deleted && this._observers.size === 0) {\n this.onLastObserverRemoved();\n }\n if (deleted) {\n getLogger()?.handleOnListenerCountChanged(this, this._observers.size);\n }\n }\n onFirstObserverAdded() { }\n onLastObserverRemoved() { }\n log() {\n const hadLogger = !!getLogger();\n logObservable(this);\n if (!hadLogger) {\n getLogger()?.handleObservableCreated(this, DebugLocation.ofCaller());\n }\n return this;\n }\n debugGetObservers() {\n return this._observers;\n }\n}\n\nexport { BaseObservable, ConvenientObservable, _setDebugGetDependencyGraph, _setDerivedOpts, _setKeepObserved, _setRecomputeInitiallyAndOnChange };\n//# sourceMappingURL=baseObservable.js.map\n"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA,IAAI,QAAQ;AACZ;AACA;AACA;AACA;AACA,SAAS,eAAe,CAAC,OAAO,EAAE;AAClC,IAAI,QAAQ,GAAG,OAAO;AACtB;AACA,IAAI,8BAA8B;AAClC,SAAS,iCAAiC,CAAC,6BAA6B,EAAE;AAC1E,IAAI,8BAA8B,GAAG,6BAA6B;AAClE;AACA,IAAI,aAAa;AACjB,SAAS,gBAAgB,CAAC,YAAY,EAAE;AACxC,IAAI,aAAa,GAAG,YAAY;AAChC;AACA,IAAI,wBAAwB;AAC5B,SAAS,2BAA2B,CAAC,uBAAuB,EAAE;AAC9D,IAAI,wBAAwB,GAAG,uBAAuB;AACtD;AACA,MAAM,oBAAoB,CAAC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IAAI,iBAAiB,GAAG;AACxB,QAAQ,OAAO,IAAI,CAAC,UAAU;AAC9B,IAAI;AACJ;;;;"}
|
package/dist/external/vscode-observables/observables/dist/observableInternal/observables/derived.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { strictEquals } from '../commonFacade/deps.js';
|
|
2
|
+
import { DebugLocation } from '../debugLocation.js';
|
|
3
|
+
import { DebugNameData } from '../debugName.js';
|
|
4
|
+
import { _setDerivedOpts } from './baseObservable.js';
|
|
5
|
+
import { Derived } from './derivedImpl.js';
|
|
6
|
+
|
|
7
|
+
/*---------------------------------------------------------------------------------------------
|
|
8
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
9
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
10
|
+
*--------------------------------------------------------------------------------------------*/
|
|
11
|
+
function derivedOpts(options, computeFn, debugLocation = DebugLocation.ofCaller()) {
|
|
12
|
+
return new Derived(new DebugNameData(options.owner, options.debugName, options.debugReferenceFn), computeFn, undefined, options.onLastObserverRemoved, options.equalsFn ?? strictEquals, debugLocation);
|
|
13
|
+
}
|
|
14
|
+
_setDerivedOpts(derivedOpts);
|
|
15
|
+
|
|
16
|
+
export { derivedOpts };
|
|
17
|
+
//# sourceMappingURL=derived.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derived.js","sources":["../../../../../../../../../external/vscode-observables/observables/dist/observableInternal/observables/derived.js"],"sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\nimport { strictEquals } from '../commonFacade/deps.js';\nimport { DebugLocation } from '../debugLocation.js';\nimport { DebugNameData } from '../debugName.js';\nimport { _setDerivedOpts } from './baseObservable.js';\nimport { Derived, DerivedWithSetter } from './derivedImpl.js';\nimport { DisposableStore } from '../../disposables.js';\n\n/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\nfunction derived(computeFnOrOwner, computeFn, debugLocation = DebugLocation.ofCaller()) {\n if (computeFn !== undefined) {\n return new Derived(new DebugNameData(computeFnOrOwner, undefined, computeFn), computeFn, undefined, undefined, strictEquals, debugLocation);\n }\n return new Derived(new DebugNameData(undefined, undefined, computeFnOrOwner), computeFnOrOwner, undefined, undefined, strictEquals, debugLocation);\n}\nfunction derivedWithSetter(owner, computeFn, setter, debugLocation = DebugLocation.ofCaller()) {\n return new DerivedWithSetter(new DebugNameData(owner, undefined, computeFn), computeFn, undefined, undefined, strictEquals, setter, debugLocation);\n}\nfunction derivedOpts(options, computeFn, debugLocation = DebugLocation.ofCaller()) {\n return new Derived(new DebugNameData(options.owner, options.debugName, options.debugReferenceFn), computeFn, undefined, options.onLastObserverRemoved, options.equalsFn ?? strictEquals, debugLocation);\n}\n_setDerivedOpts(derivedOpts);\n/**\n * Represents an observable that is derived from other observables.\n * The value is only recomputed when absolutely needed.\n *\n * {@link computeFn} should start with a JS Doc using `@description` to name the derived.\n *\n * Use `createEmptyChangeSummary` to create a \"change summary\" that can collect the changes.\n * Use `handleChange` to add a reported change to the change summary.\n * The compute function is given the last change summary.\n * The change summary is discarded after the compute function was called.\n *\n * @see derived\n */\nfunction derivedHandleChanges(options, computeFn, debugLocation = DebugLocation.ofCaller()) {\n return new Derived(new DebugNameData(options.owner, options.debugName, undefined), computeFn, options.changeTracker, undefined, options.equalityComparer ?? strictEquals, debugLocation);\n}\nfunction derivedWithStore(computeFnOrOwner, computeFnOrUndefined, debugLocation = DebugLocation.ofCaller()) {\n let computeFn;\n let owner;\n if (computeFnOrUndefined === undefined) {\n computeFn = computeFnOrOwner;\n owner = undefined;\n }\n else {\n owner = computeFnOrOwner;\n computeFn = computeFnOrUndefined;\n }\n // Intentionally re-assigned in case an inactive observable is re-used later\n // eslint-disable-next-line local/code-no-potentially-unsafe-disposables\n let store = new DisposableStore();\n return new Derived(new DebugNameData(owner, undefined, computeFn), r => {\n if (store.isDisposed) {\n store = new DisposableStore();\n }\n else {\n store.clear();\n }\n return computeFn(r, store);\n }, undefined, () => store.dispose(), strictEquals, debugLocation);\n}\nfunction derivedDisposable(computeFnOrOwner, computeFnOrUndefined, debugLocation = DebugLocation.ofCaller()) {\n let computeFn;\n let owner;\n if (computeFnOrUndefined === undefined) {\n computeFn = computeFnOrOwner;\n owner = undefined;\n }\n else {\n owner = computeFnOrOwner;\n computeFn = computeFnOrUndefined;\n }\n let store = undefined;\n return new Derived(new DebugNameData(owner, undefined, computeFn), r => {\n if (!store) {\n store = new DisposableStore();\n }\n else {\n store.clear();\n }\n const result = computeFn(r);\n if (result) {\n store.add(result);\n }\n return result;\n }, undefined, () => {\n if (store) {\n store.dispose();\n store = undefined;\n }\n }, strictEquals, debugLocation);\n}\n\nexport { derived, derivedDisposable, derivedHandleChanges, derivedOpts, derivedWithSetter, derivedWithStore };\n//# sourceMappingURL=derived.js.map\n"],"names":[],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AAqBA,SAAS,WAAW,CAAC,OAAO,EAAE,SAAS,EAAE,aAAa,GAAG,aAAa,CAAC,QAAQ,EAAE,EAAE;AACnF,IAAI,OAAO,IAAI,OAAO,CAAC,IAAI,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,gBAAgB,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,qBAAqB,EAAE,OAAO,CAAC,QAAQ,IAAI,YAAY,EAAE,aAAa,CAAC;AAC3M;AACA,eAAe,CAAC,WAAW,CAAC;;;;"}
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
import { BaseObservable } from './baseObservable.js';
|
|
2
|
+
import { onBugIndicatingError, BugIndicatingError } from '../commonFacade/deps.js';
|
|
3
|
+
import { getLogger } from '../logging/logging.js';
|
|
4
|
+
import { DisposableStore } from '../../disposables.js';
|
|
5
|
+
|
|
6
|
+
/*---------------------------------------------------------------------------------------------
|
|
7
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
9
|
+
*--------------------------------------------------------------------------------------------*/
|
|
10
|
+
|
|
11
|
+
/*---------------------------------------------------------------------------------------------
|
|
12
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
13
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
14
|
+
*--------------------------------------------------------------------------------------------*/
|
|
15
|
+
function derivedStateToString(state) {
|
|
16
|
+
switch (state) {
|
|
17
|
+
case 0 /* DerivedState.initial */: return 'initial';
|
|
18
|
+
case 1 /* DerivedState.dependenciesMightHaveChanged */: return 'dependenciesMightHaveChanged';
|
|
19
|
+
case 2 /* DerivedState.stale */: return 'stale';
|
|
20
|
+
case 3 /* DerivedState.upToDate */: return 'upToDate';
|
|
21
|
+
default: return '<unknown>';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
class Derived extends BaseObservable {
|
|
25
|
+
get debugName() {
|
|
26
|
+
return this._debugNameData.getDebugName(this) ?? '(anonymous)';
|
|
27
|
+
}
|
|
28
|
+
constructor(_debugNameData, _computeFn, _changeTracker, _handleLastObserverRemoved = undefined, _equalityComparator, debugLocation) {
|
|
29
|
+
super(debugLocation);
|
|
30
|
+
this._debugNameData = _debugNameData;
|
|
31
|
+
this._computeFn = _computeFn;
|
|
32
|
+
this._changeTracker = _changeTracker;
|
|
33
|
+
this._handleLastObserverRemoved = _handleLastObserverRemoved;
|
|
34
|
+
this._equalityComparator = _equalityComparator;
|
|
35
|
+
this._state = 0 /* DerivedState.initial */;
|
|
36
|
+
this._value = undefined;
|
|
37
|
+
this._updateCount = 0;
|
|
38
|
+
this._dependencies = new Set();
|
|
39
|
+
this._dependenciesToBeRemoved = new Set();
|
|
40
|
+
this._changeSummary = undefined;
|
|
41
|
+
this._isUpdating = false;
|
|
42
|
+
this._isComputing = false;
|
|
43
|
+
this._didReportChange = false;
|
|
44
|
+
this._isInBeforeUpdate = false;
|
|
45
|
+
this._isReaderValid = false;
|
|
46
|
+
this._store = undefined;
|
|
47
|
+
this._delayedStore = undefined;
|
|
48
|
+
this._removedObserverToCallEndUpdateOn = null;
|
|
49
|
+
this._changeSummary = this._changeTracker?.createChangeSummary(undefined);
|
|
50
|
+
}
|
|
51
|
+
onLastObserverRemoved() {
|
|
52
|
+
/**
|
|
53
|
+
* We are not tracking changes anymore, thus we have to assume
|
|
54
|
+
* that our cache is invalid.
|
|
55
|
+
*/
|
|
56
|
+
this._state = 0 /* DerivedState.initial */;
|
|
57
|
+
this._value = undefined;
|
|
58
|
+
getLogger()?.handleDerivedCleared(this);
|
|
59
|
+
for (const d of this._dependencies) {
|
|
60
|
+
d.removeObserver(this);
|
|
61
|
+
}
|
|
62
|
+
this._dependencies.clear();
|
|
63
|
+
if (this._store !== undefined) {
|
|
64
|
+
this._store.dispose();
|
|
65
|
+
this._store = undefined;
|
|
66
|
+
}
|
|
67
|
+
if (this._delayedStore !== undefined) {
|
|
68
|
+
this._delayedStore.dispose();
|
|
69
|
+
this._delayedStore = undefined;
|
|
70
|
+
}
|
|
71
|
+
this._handleLastObserverRemoved?.();
|
|
72
|
+
}
|
|
73
|
+
get() {
|
|
74
|
+
const checkEnabled = false; // TODO set to true
|
|
75
|
+
if (this._isComputing && checkEnabled) ;
|
|
76
|
+
if (this._observers.size === 0) {
|
|
77
|
+
let result;
|
|
78
|
+
// Without observers, we don't know when to clean up stuff.
|
|
79
|
+
// Thus, we don't cache anything to prevent memory leaks.
|
|
80
|
+
try {
|
|
81
|
+
this._isReaderValid = true;
|
|
82
|
+
let changeSummary = undefined;
|
|
83
|
+
if (this._changeTracker) {
|
|
84
|
+
changeSummary = this._changeTracker.createChangeSummary(undefined);
|
|
85
|
+
this._changeTracker.beforeUpdate?.(this, changeSummary);
|
|
86
|
+
}
|
|
87
|
+
result = this._computeFn(this, changeSummary);
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
this._isReaderValid = false;
|
|
91
|
+
}
|
|
92
|
+
// Clear new dependencies
|
|
93
|
+
this.onLastObserverRemoved();
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
do {
|
|
98
|
+
// We might not get a notification for a dependency that changed while it is updating,
|
|
99
|
+
// thus we also have to ask all our depedencies if they changed in this case.
|
|
100
|
+
if (this._state === 1 /* DerivedState.dependenciesMightHaveChanged */) {
|
|
101
|
+
for (const d of this._dependencies) {
|
|
102
|
+
/** might call {@link handleChange} indirectly, which could make us stale */
|
|
103
|
+
d.reportChanges();
|
|
104
|
+
if (this._state === 2 /* DerivedState.stale */) {
|
|
105
|
+
// The other dependencies will refresh on demand, so early break
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// We called report changes of all dependencies.
|
|
111
|
+
// If we are still not stale, we can assume to be up to date again.
|
|
112
|
+
if (this._state === 1 /* DerivedState.dependenciesMightHaveChanged */) {
|
|
113
|
+
this._state = 3 /* DerivedState.upToDate */;
|
|
114
|
+
}
|
|
115
|
+
if (this._state !== 3 /* DerivedState.upToDate */) {
|
|
116
|
+
this._recompute();
|
|
117
|
+
}
|
|
118
|
+
// In case recomputation changed one of our dependencies, we need to recompute again.
|
|
119
|
+
} while (this._state !== 3 /* DerivedState.upToDate */);
|
|
120
|
+
return this._value;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
_recompute() {
|
|
124
|
+
let didChange = false;
|
|
125
|
+
this._isComputing = true;
|
|
126
|
+
this._didReportChange = false;
|
|
127
|
+
const emptySet = this._dependenciesToBeRemoved;
|
|
128
|
+
this._dependenciesToBeRemoved = this._dependencies;
|
|
129
|
+
this._dependencies = emptySet;
|
|
130
|
+
try {
|
|
131
|
+
const changeSummary = this._changeSummary;
|
|
132
|
+
this._isReaderValid = true;
|
|
133
|
+
if (this._changeTracker) {
|
|
134
|
+
this._isInBeforeUpdate = true;
|
|
135
|
+
this._changeTracker.beforeUpdate?.(this, changeSummary);
|
|
136
|
+
this._isInBeforeUpdate = false;
|
|
137
|
+
this._changeSummary = this._changeTracker?.createChangeSummary(changeSummary);
|
|
138
|
+
}
|
|
139
|
+
const hadValue = this._state !== 0 /* DerivedState.initial */;
|
|
140
|
+
const oldValue = this._value;
|
|
141
|
+
this._state = 3 /* DerivedState.upToDate */;
|
|
142
|
+
const delayedStore = this._delayedStore;
|
|
143
|
+
if (delayedStore !== undefined) {
|
|
144
|
+
this._delayedStore = undefined;
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
if (this._store !== undefined) {
|
|
148
|
+
this._store.dispose();
|
|
149
|
+
this._store = undefined;
|
|
150
|
+
}
|
|
151
|
+
/** might call {@link handleChange} indirectly, which could invalidate us */
|
|
152
|
+
this._value = this._computeFn(this, changeSummary);
|
|
153
|
+
}
|
|
154
|
+
finally {
|
|
155
|
+
this._isReaderValid = false;
|
|
156
|
+
// We don't want our observed observables to think that they are (not even temporarily) not being observed.
|
|
157
|
+
// Thus, we only unsubscribe from observables that are definitely not read anymore.
|
|
158
|
+
for (const o of this._dependenciesToBeRemoved) {
|
|
159
|
+
o.removeObserver(this);
|
|
160
|
+
}
|
|
161
|
+
this._dependenciesToBeRemoved.clear();
|
|
162
|
+
if (delayedStore !== undefined) {
|
|
163
|
+
delayedStore.dispose();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
didChange = this._didReportChange || (hadValue && !(this._equalityComparator(oldValue, this._value)));
|
|
167
|
+
getLogger()?.handleObservableUpdated(this, {
|
|
168
|
+
oldValue,
|
|
169
|
+
newValue: this._value,
|
|
170
|
+
change: undefined,
|
|
171
|
+
didChange,
|
|
172
|
+
hadValue,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
catch (e) {
|
|
176
|
+
onBugIndicatingError(e);
|
|
177
|
+
}
|
|
178
|
+
this._isComputing = false;
|
|
179
|
+
if (!this._didReportChange && didChange) {
|
|
180
|
+
for (const r of this._observers) {
|
|
181
|
+
r.handleChange(this, undefined);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
this._didReportChange = false;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
toString() {
|
|
189
|
+
return `LazyDerived<${this.debugName}>`;
|
|
190
|
+
}
|
|
191
|
+
// IObserver Implementation
|
|
192
|
+
beginUpdate(_observable) {
|
|
193
|
+
if (this._isUpdating) {
|
|
194
|
+
throw new BugIndicatingError('Cyclic deriveds are not supported yet!');
|
|
195
|
+
}
|
|
196
|
+
this._updateCount++;
|
|
197
|
+
this._isUpdating = true;
|
|
198
|
+
try {
|
|
199
|
+
const propagateBeginUpdate = this._updateCount === 1;
|
|
200
|
+
if (this._state === 3 /* DerivedState.upToDate */) {
|
|
201
|
+
this._state = 1 /* DerivedState.dependenciesMightHaveChanged */;
|
|
202
|
+
// If we propagate begin update, that will already signal a possible change.
|
|
203
|
+
if (!propagateBeginUpdate) {
|
|
204
|
+
for (const r of this._observers) {
|
|
205
|
+
r.handlePossibleChange(this);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (propagateBeginUpdate) {
|
|
210
|
+
for (const r of this._observers) {
|
|
211
|
+
r.beginUpdate(this); // This signals a possible change
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
finally {
|
|
216
|
+
this._isUpdating = false;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
endUpdate(_observable) {
|
|
220
|
+
this._updateCount--;
|
|
221
|
+
if (this._updateCount === 0) {
|
|
222
|
+
// End update could change the observer list.
|
|
223
|
+
const observers = [...this._observers];
|
|
224
|
+
for (const r of observers) {
|
|
225
|
+
r.endUpdate(this);
|
|
226
|
+
}
|
|
227
|
+
if (this._removedObserverToCallEndUpdateOn) {
|
|
228
|
+
const observers = [...this._removedObserverToCallEndUpdateOn];
|
|
229
|
+
this._removedObserverToCallEndUpdateOn = null;
|
|
230
|
+
for (const r of observers) {
|
|
231
|
+
r.endUpdate(this);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
handlePossibleChange(observable) {
|
|
237
|
+
// In all other states, observers already know that we might have changed.
|
|
238
|
+
if (this._state === 3 /* DerivedState.upToDate */ && this._dependencies.has(observable) && !this._dependenciesToBeRemoved.has(observable)) {
|
|
239
|
+
this._state = 1 /* DerivedState.dependenciesMightHaveChanged */;
|
|
240
|
+
for (const r of this._observers) {
|
|
241
|
+
r.handlePossibleChange(this);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
handleChange(observable, change) {
|
|
246
|
+
if (this._dependencies.has(observable) && !this._dependenciesToBeRemoved.has(observable) || this._isInBeforeUpdate) {
|
|
247
|
+
getLogger()?.handleDerivedDependencyChanged(this, observable, change);
|
|
248
|
+
let shouldReact = false;
|
|
249
|
+
try {
|
|
250
|
+
shouldReact = this._changeTracker ? this._changeTracker.handleChange({
|
|
251
|
+
changedObservable: observable,
|
|
252
|
+
change,
|
|
253
|
+
didChange: (o) => o === observable,
|
|
254
|
+
}, this._changeSummary) : true;
|
|
255
|
+
}
|
|
256
|
+
catch (e) {
|
|
257
|
+
onBugIndicatingError(e);
|
|
258
|
+
}
|
|
259
|
+
const wasUpToDate = this._state === 3 /* DerivedState.upToDate */;
|
|
260
|
+
if (shouldReact && (this._state === 1 /* DerivedState.dependenciesMightHaveChanged */ || wasUpToDate)) {
|
|
261
|
+
this._state = 2 /* DerivedState.stale */;
|
|
262
|
+
if (wasUpToDate) {
|
|
263
|
+
for (const r of this._observers) {
|
|
264
|
+
r.handlePossibleChange(this);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
// IReader Implementation
|
|
271
|
+
_ensureReaderValid() {
|
|
272
|
+
if (!this._isReaderValid) {
|
|
273
|
+
throw new BugIndicatingError('The reader object cannot be used outside its compute function!');
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
readObservable(observable) {
|
|
277
|
+
this._ensureReaderValid();
|
|
278
|
+
// Subscribe before getting the value to enable caching
|
|
279
|
+
observable.addObserver(this);
|
|
280
|
+
/** This might call {@link handleChange} indirectly, which could invalidate us */
|
|
281
|
+
const value = observable.get();
|
|
282
|
+
// Which is why we only add the observable to the dependencies now.
|
|
283
|
+
this._dependencies.add(observable);
|
|
284
|
+
this._dependenciesToBeRemoved.delete(observable);
|
|
285
|
+
return value;
|
|
286
|
+
}
|
|
287
|
+
reportChange(change) {
|
|
288
|
+
this._ensureReaderValid();
|
|
289
|
+
this._didReportChange = true;
|
|
290
|
+
// TODO add logging
|
|
291
|
+
for (const r of this._observers) {
|
|
292
|
+
r.handleChange(this, change);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
get store() {
|
|
296
|
+
this._ensureReaderValid();
|
|
297
|
+
if (this._store === undefined) {
|
|
298
|
+
this._store = new DisposableStore();
|
|
299
|
+
}
|
|
300
|
+
return this._store;
|
|
301
|
+
}
|
|
302
|
+
get delayedStore() {
|
|
303
|
+
this._ensureReaderValid();
|
|
304
|
+
if (this._delayedStore === undefined) {
|
|
305
|
+
this._delayedStore = new DisposableStore();
|
|
306
|
+
}
|
|
307
|
+
return this._delayedStore;
|
|
308
|
+
}
|
|
309
|
+
addObserver(observer) {
|
|
310
|
+
const shouldCallBeginUpdate = !this._observers.has(observer) && this._updateCount > 0;
|
|
311
|
+
super.addObserver(observer);
|
|
312
|
+
if (shouldCallBeginUpdate) {
|
|
313
|
+
if (this._removedObserverToCallEndUpdateOn && this._removedObserverToCallEndUpdateOn.has(observer)) {
|
|
314
|
+
this._removedObserverToCallEndUpdateOn.delete(observer);
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
observer.beginUpdate(this);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
removeObserver(observer) {
|
|
322
|
+
if (this._observers.has(observer) && this._updateCount > 0) {
|
|
323
|
+
if (!this._removedObserverToCallEndUpdateOn) {
|
|
324
|
+
this._removedObserverToCallEndUpdateOn = new Set();
|
|
325
|
+
}
|
|
326
|
+
this._removedObserverToCallEndUpdateOn.add(observer);
|
|
327
|
+
}
|
|
328
|
+
super.removeObserver(observer);
|
|
329
|
+
}
|
|
330
|
+
debugGetState() {
|
|
331
|
+
return {
|
|
332
|
+
state: this._state,
|
|
333
|
+
stateStr: derivedStateToString(this._state),
|
|
334
|
+
updateCount: this._updateCount,
|
|
335
|
+
isComputing: this._isComputing,
|
|
336
|
+
dependencies: this._dependencies,
|
|
337
|
+
value: this._value,
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
debugSetValue(newValue) {
|
|
341
|
+
this._value = newValue;
|
|
342
|
+
}
|
|
343
|
+
debugRecompute() {
|
|
344
|
+
if (!this._isComputing) {
|
|
345
|
+
this._recompute();
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
this._state = 2 /* DerivedState.stale */;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
setValue(newValue, tx, change) {
|
|
352
|
+
this._value = newValue;
|
|
353
|
+
const observers = this._observers;
|
|
354
|
+
tx.updateObserver(this, this);
|
|
355
|
+
for (const d of observers) {
|
|
356
|
+
d.handleChange(this, change);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export { Derived };
|
|
362
|
+
//# sourceMappingURL=derivedImpl.js.map
|