@vscode/component-explorer-cli 0.1.1-0 → 0.1.1-2

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.
Files changed (139) hide show
  1. package/dist/browserPage.js +4 -2
  2. package/dist/browserPage.js.map +1 -1
  3. package/dist/commands/acceptCommand.d.ts +1 -0
  4. package/dist/commands/acceptCommand.d.ts.map +1 -1
  5. package/dist/commands/acceptCommand.js +8 -2
  6. package/dist/commands/acceptCommand.js.map +1 -1
  7. package/dist/commands/compareCommand.d.ts +1 -0
  8. package/dist/commands/compareCommand.d.ts.map +1 -1
  9. package/dist/commands/compareCommand.js +8 -2
  10. package/dist/commands/compareCommand.js.map +1 -1
  11. package/dist/commands/mcpCommand.d.ts +8 -0
  12. package/dist/commands/mcpCommand.d.ts.map +1 -0
  13. package/dist/commands/mcpCommand.js +24 -0
  14. package/dist/commands/mcpCommand.js.map +1 -0
  15. package/dist/commands/screenshotCommand.d.ts +1 -0
  16. package/dist/commands/screenshotCommand.d.ts.map +1 -1
  17. package/dist/commands/screenshotCommand.js +10 -4
  18. package/dist/commands/screenshotCommand.js.map +1 -1
  19. package/dist/commands/serveCommand.d.ts +16 -0
  20. package/dist/commands/serveCommand.d.ts.map +1 -0
  21. package/dist/commands/serveCommand.js +137 -0
  22. package/dist/commands/serveCommand.js.map +1 -0
  23. package/dist/commands/watchCommand.d.ts +1 -0
  24. package/dist/commands/watchCommand.d.ts.map +1 -1
  25. package/dist/commands/watchCommand.js +22 -10
  26. package/dist/commands/watchCommand.js.map +1 -1
  27. package/dist/componentExplorer.js +5 -2
  28. package/dist/componentExplorer.js.map +1 -1
  29. package/dist/daemon/DaemonService.d.ts +131 -0
  30. package/dist/daemon/DaemonService.d.ts.map +1 -0
  31. package/dist/daemon/DaemonService.js +450 -0
  32. package/dist/daemon/DaemonService.js.map +1 -0
  33. package/dist/daemon/approvalStore.d.ts +51 -0
  34. package/dist/daemon/approvalStore.d.ts.map +1 -0
  35. package/dist/daemon/approvalStore.js +58 -0
  36. package/dist/daemon/approvalStore.js.map +1 -0
  37. package/dist/daemon/lifecycle.d.ts +8 -0
  38. package/dist/daemon/lifecycle.d.ts.map +1 -0
  39. package/dist/daemon/lifecycle.js +51 -0
  40. package/dist/daemon/lifecycle.js.map +1 -0
  41. package/dist/daemon/pipeClient.d.ts +4 -0
  42. package/dist/daemon/pipeClient.d.ts.map +1 -0
  43. package/dist/daemon/pipeClient.js +97 -0
  44. package/dist/daemon/pipeClient.js.map +1 -0
  45. package/dist/daemon/pipeName.d.ts +2 -0
  46. package/dist/daemon/pipeName.d.ts.map +1 -0
  47. package/dist/daemon/pipeName.js +14 -0
  48. package/dist/daemon/pipeName.js.map +1 -0
  49. package/dist/daemon/pipeServer.d.ts +4 -0
  50. package/dist/daemon/pipeServer.d.ts.map +1 -0
  51. package/dist/daemon/pipeServer.js +23 -0
  52. package/dist/daemon/pipeServer.js.map +1 -0
  53. package/dist/dependencyInstaller.js +7 -4
  54. package/dist/dependencyInstaller.js.map +1 -1
  55. package/dist/explorerSession.d.ts +5 -3
  56. package/dist/explorerSession.d.ts.map +1 -1
  57. package/dist/explorerSession.js +11 -5
  58. package/dist/explorerSession.js.map +1 -1
  59. package/dist/external/vscode-observables/observables/dist/disposables.js +43 -0
  60. package/dist/external/vscode-observables/observables/dist/disposables.js.map +1 -0
  61. package/dist/external/vscode-observables/observables/dist/observableInternal/base.js +22 -0
  62. package/dist/external/vscode-observables/observables/dist/observableInternal/base.js.map +1 -0
  63. package/dist/external/vscode-observables/observables/dist/observableInternal/commonFacade/deps.js +40 -0
  64. package/dist/external/vscode-observables/observables/dist/observableInternal/commonFacade/deps.js.map +1 -0
  65. package/dist/external/vscode-observables/observables/dist/observableInternal/debugLocation.js +77 -0
  66. package/dist/external/vscode-observables/observables/dist/observableInternal/debugLocation.js.map +1 -0
  67. package/dist/external/vscode-observables/observables/dist/observableInternal/debugName.js +114 -0
  68. package/dist/external/vscode-observables/observables/dist/observableInternal/debugName.js.map +1 -0
  69. package/dist/external/vscode-observables/observables/dist/observableInternal/index.js +25 -0
  70. package/dist/external/vscode-observables/observables/dist/observableInternal/index.js.map +1 -0
  71. package/dist/external/vscode-observables/observables/dist/observableInternal/logging/consoleObservableLogger.js +332 -0
  72. package/dist/external/vscode-observables/observables/dist/observableInternal/logging/consoleObservableLogger.js.map +1 -0
  73. package/dist/external/vscode-observables/observables/dist/observableInternal/logging/debugGetDependencyGraph.js +79 -0
  74. package/dist/external/vscode-observables/observables/dist/observableInternal/logging/debugGetDependencyGraph.js.map +1 -0
  75. package/dist/external/vscode-observables/observables/dist/observableInternal/logging/debugger/debuggerRpc.js +72 -0
  76. package/dist/external/vscode-observables/observables/dist/observableInternal/logging/debugger/debuggerRpc.js.map +1 -0
  77. package/dist/external/vscode-observables/observables/dist/observableInternal/logging/debugger/devToolsLogger.js +447 -0
  78. package/dist/external/vscode-observables/observables/dist/observableInternal/logging/debugger/devToolsLogger.js.map +1 -0
  79. package/dist/external/vscode-observables/observables/dist/observableInternal/logging/debugger/rpc.js +64 -0
  80. package/dist/external/vscode-observables/observables/dist/observableInternal/logging/debugger/rpc.js.map +1 -0
  81. package/dist/external/vscode-observables/observables/dist/observableInternal/logging/debugger/utils.js +52 -0
  82. package/dist/external/vscode-observables/observables/dist/observableInternal/logging/debugger/utils.js.map +1 -0
  83. package/dist/external/vscode-observables/observables/dist/observableInternal/logging/logging.js +100 -0
  84. package/dist/external/vscode-observables/observables/dist/observableInternal/logging/logging.js.map +1 -0
  85. package/dist/external/vscode-observables/observables/dist/observableInternal/observables/baseObservable.js +143 -0
  86. package/dist/external/vscode-observables/observables/dist/observableInternal/observables/baseObservable.js.map +1 -0
  87. package/dist/external/vscode-observables/observables/dist/observableInternal/observables/derived.js +17 -0
  88. package/dist/external/vscode-observables/observables/dist/observableInternal/observables/derived.js.map +1 -0
  89. package/dist/external/vscode-observables/observables/dist/observableInternal/observables/derivedImpl.js +362 -0
  90. package/dist/external/vscode-observables/observables/dist/observableInternal/observables/derivedImpl.js.map +1 -0
  91. package/dist/external/vscode-observables/observables/dist/observableInternal/observables/observableFromEvent.js +123 -0
  92. package/dist/external/vscode-observables/observables/dist/observableInternal/observables/observableFromEvent.js.map +1 -0
  93. package/dist/external/vscode-observables/observables/dist/observableInternal/observables/observableValue.js +81 -0
  94. package/dist/external/vscode-observables/observables/dist/observableInternal/observables/observableValue.js.map +1 -0
  95. package/dist/external/vscode-observables/observables/dist/observableInternal/reactions/autorun.js +23 -0
  96. package/dist/external/vscode-observables/observables/dist/observableInternal/reactions/autorun.js.map +1 -0
  97. package/dist/external/vscode-observables/observables/dist/observableInternal/reactions/autorunImpl.js +226 -0
  98. package/dist/external/vscode-observables/observables/dist/observableInternal/reactions/autorunImpl.js.map +1 -0
  99. package/dist/external/vscode-observables/observables/dist/observableInternal/transaction.js +87 -0
  100. package/dist/external/vscode-observables/observables/dist/observableInternal/transaction.js.map +1 -0
  101. package/dist/external/vscode-observables/observables/dist/observableInternal/utils/utils.js +68 -0
  102. package/dist/external/vscode-observables/observables/dist/observableInternal/utils/utils.js.map +1 -0
  103. package/dist/git/gitCommitId.js +4 -2
  104. package/dist/git/gitCommitId.js.map +1 -1
  105. package/dist/git/gitCommitResolver.js +11 -3
  106. package/dist/git/gitCommitResolver.js.map +1 -1
  107. package/dist/git/gitService.js +5 -2
  108. package/dist/git/gitService.js.map +1 -1
  109. package/dist/git/gitUtils.js +9 -6
  110. package/dist/git/gitUtils.js.map +1 -1
  111. package/dist/git/gitWorktreeManager.js +5 -2
  112. package/dist/git/gitWorktreeManager.js.map +1 -1
  113. package/dist/httpServer.d.ts +9 -7
  114. package/dist/httpServer.d.ts.map +1 -1
  115. package/dist/httpServer.js +67 -10
  116. package/dist/httpServer.js.map +1 -1
  117. package/dist/index.js +6 -1
  118. package/dist/index.js.map +1 -1
  119. package/dist/logger.d.ts +17 -1
  120. package/dist/logger.d.ts.map +1 -1
  121. package/dist/logger.js +43 -6
  122. package/dist/logger.js.map +1 -1
  123. package/dist/mcp/McpServer.d.ts +28 -0
  124. package/dist/mcp/McpServer.d.ts.map +1 -0
  125. package/dist/mcp/McpServer.js +386 -0
  126. package/dist/mcp/McpServer.js.map +1 -0
  127. package/dist/screenshotCache.js +7 -4
  128. package/dist/screenshotCache.js.map +1 -1
  129. package/dist/sourceTreeId.js +4 -2
  130. package/dist/sourceTreeId.js.map +1 -1
  131. package/dist/storage.js +5 -2
  132. package/dist/storage.js.map +1 -1
  133. package/dist/viteProjectRef.js +5 -2
  134. package/dist/viteProjectRef.js.map +1 -1
  135. package/dist/watchConfig.d.ts +5 -0
  136. package/dist/watchConfig.d.ts.map +1 -1
  137. package/dist/watchConfig.js +22 -7
  138. package/dist/watchConfig.js.map +1 -1
  139. package/package.json +11 -4
@@ -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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"derivedImpl.js","sources":["../../../../../../../../../external/vscode-observables/observables/dist/observableInternal/observables/derivedImpl.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 { BaseObservable } from './baseObservable.js';\nimport { BugIndicatingError, onBugIndicatingError } from '../commonFacade/deps.js';\nimport { getLogger } from '../logging/logging.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 derivedStateToString(state) {\n switch (state) {\n case 0 /* DerivedState.initial */: return 'initial';\n case 1 /* DerivedState.dependenciesMightHaveChanged */: return 'dependenciesMightHaveChanged';\n case 2 /* DerivedState.stale */: return 'stale';\n case 3 /* DerivedState.upToDate */: return 'upToDate';\n default: return '<unknown>';\n }\n}\nclass Derived extends BaseObservable {\n get debugName() {\n return this._debugNameData.getDebugName(this) ?? '(anonymous)';\n }\n constructor(_debugNameData, _computeFn, _changeTracker, _handleLastObserverRemoved = undefined, _equalityComparator, debugLocation) {\n super(debugLocation);\n this._debugNameData = _debugNameData;\n this._computeFn = _computeFn;\n this._changeTracker = _changeTracker;\n this._handleLastObserverRemoved = _handleLastObserverRemoved;\n this._equalityComparator = _equalityComparator;\n this._state = 0 /* DerivedState.initial */;\n this._value = undefined;\n this._updateCount = 0;\n this._dependencies = new Set();\n this._dependenciesToBeRemoved = new Set();\n this._changeSummary = undefined;\n this._isUpdating = false;\n this._isComputing = false;\n this._didReportChange = false;\n this._isInBeforeUpdate = false;\n this._isReaderValid = false;\n this._store = undefined;\n this._delayedStore = undefined;\n this._removedObserverToCallEndUpdateOn = null;\n this._changeSummary = this._changeTracker?.createChangeSummary(undefined);\n }\n onLastObserverRemoved() {\n /**\n * We are not tracking changes anymore, thus we have to assume\n * that our cache is invalid.\n */\n this._state = 0 /* DerivedState.initial */;\n this._value = undefined;\n getLogger()?.handleDerivedCleared(this);\n for (const d of this._dependencies) {\n d.removeObserver(this);\n }\n this._dependencies.clear();\n if (this._store !== undefined) {\n this._store.dispose();\n this._store = undefined;\n }\n if (this._delayedStore !== undefined) {\n this._delayedStore.dispose();\n this._delayedStore = undefined;\n }\n this._handleLastObserverRemoved?.();\n }\n get() {\n const checkEnabled = false; // TODO set to true\n if (this._isComputing && checkEnabled) {\n // investigate why this fails in the diff editor!\n throw new BugIndicatingError('Cyclic deriveds are not supported yet!');\n }\n if (this._observers.size === 0) {\n let result;\n // Without observers, we don't know when to clean up stuff.\n // Thus, we don't cache anything to prevent memory leaks.\n try {\n this._isReaderValid = true;\n let changeSummary = undefined;\n if (this._changeTracker) {\n changeSummary = this._changeTracker.createChangeSummary(undefined);\n this._changeTracker.beforeUpdate?.(this, changeSummary);\n }\n result = this._computeFn(this, changeSummary);\n }\n finally {\n this._isReaderValid = false;\n }\n // Clear new dependencies\n this.onLastObserverRemoved();\n return result;\n }\n else {\n do {\n // We might not get a notification for a dependency that changed while it is updating,\n // thus we also have to ask all our depedencies if they changed in this case.\n if (this._state === 1 /* DerivedState.dependenciesMightHaveChanged */) {\n for (const d of this._dependencies) {\n /** might call {@link handleChange} indirectly, which could make us stale */\n d.reportChanges();\n if (this._state === 2 /* DerivedState.stale */) {\n // The other dependencies will refresh on demand, so early break\n break;\n }\n }\n }\n // We called report changes of all dependencies.\n // If we are still not stale, we can assume to be up to date again.\n if (this._state === 1 /* DerivedState.dependenciesMightHaveChanged */) {\n this._state = 3 /* DerivedState.upToDate */;\n }\n if (this._state !== 3 /* DerivedState.upToDate */) {\n this._recompute();\n }\n // In case recomputation changed one of our dependencies, we need to recompute again.\n } while (this._state !== 3 /* DerivedState.upToDate */);\n return this._value;\n }\n }\n _recompute() {\n let didChange = false;\n this._isComputing = true;\n this._didReportChange = false;\n const emptySet = this._dependenciesToBeRemoved;\n this._dependenciesToBeRemoved = this._dependencies;\n this._dependencies = emptySet;\n try {\n const changeSummary = this._changeSummary;\n this._isReaderValid = true;\n if (this._changeTracker) {\n this._isInBeforeUpdate = true;\n this._changeTracker.beforeUpdate?.(this, changeSummary);\n this._isInBeforeUpdate = false;\n this._changeSummary = this._changeTracker?.createChangeSummary(changeSummary);\n }\n const hadValue = this._state !== 0 /* DerivedState.initial */;\n const oldValue = this._value;\n this._state = 3 /* DerivedState.upToDate */;\n const delayedStore = this._delayedStore;\n if (delayedStore !== undefined) {\n this._delayedStore = undefined;\n }\n try {\n if (this._store !== undefined) {\n this._store.dispose();\n this._store = undefined;\n }\n /** might call {@link handleChange} indirectly, which could invalidate us */\n this._value = this._computeFn(this, changeSummary);\n }\n finally {\n this._isReaderValid = false;\n // We don't want our observed observables to think that they are (not even temporarily) not being observed.\n // Thus, we only unsubscribe from observables that are definitely not read anymore.\n for (const o of this._dependenciesToBeRemoved) {\n o.removeObserver(this);\n }\n this._dependenciesToBeRemoved.clear();\n if (delayedStore !== undefined) {\n delayedStore.dispose();\n }\n }\n didChange = this._didReportChange || (hadValue && !(this._equalityComparator(oldValue, this._value)));\n getLogger()?.handleObservableUpdated(this, {\n oldValue,\n newValue: this._value,\n change: undefined,\n didChange,\n hadValue,\n });\n }\n catch (e) {\n onBugIndicatingError(e);\n }\n this._isComputing = false;\n if (!this._didReportChange && didChange) {\n for (const r of this._observers) {\n r.handleChange(this, undefined);\n }\n }\n else {\n this._didReportChange = false;\n }\n }\n toString() {\n return `LazyDerived<${this.debugName}>`;\n }\n // IObserver Implementation\n beginUpdate(_observable) {\n if (this._isUpdating) {\n throw new BugIndicatingError('Cyclic deriveds are not supported yet!');\n }\n this._updateCount++;\n this._isUpdating = true;\n try {\n const propagateBeginUpdate = this._updateCount === 1;\n if (this._state === 3 /* DerivedState.upToDate */) {\n this._state = 1 /* DerivedState.dependenciesMightHaveChanged */;\n // If we propagate begin update, that will already signal a possible change.\n if (!propagateBeginUpdate) {\n for (const r of this._observers) {\n r.handlePossibleChange(this);\n }\n }\n }\n if (propagateBeginUpdate) {\n for (const r of this._observers) {\n r.beginUpdate(this); // This signals a possible change\n }\n }\n }\n finally {\n this._isUpdating = false;\n }\n }\n endUpdate(_observable) {\n this._updateCount--;\n if (this._updateCount === 0) {\n // End update could change the observer list.\n const observers = [...this._observers];\n for (const r of observers) {\n r.endUpdate(this);\n }\n if (this._removedObserverToCallEndUpdateOn) {\n const observers = [...this._removedObserverToCallEndUpdateOn];\n this._removedObserverToCallEndUpdateOn = null;\n for (const r of observers) {\n r.endUpdate(this);\n }\n }\n }\n }\n handlePossibleChange(observable) {\n // In all other states, observers already know that we might have changed.\n if (this._state === 3 /* DerivedState.upToDate */ && this._dependencies.has(observable) && !this._dependenciesToBeRemoved.has(observable)) {\n this._state = 1 /* DerivedState.dependenciesMightHaveChanged */;\n for (const r of this._observers) {\n r.handlePossibleChange(this);\n }\n }\n }\n handleChange(observable, change) {\n if (this._dependencies.has(observable) && !this._dependenciesToBeRemoved.has(observable) || this._isInBeforeUpdate) {\n getLogger()?.handleDerivedDependencyChanged(this, observable, change);\n let shouldReact = false;\n try {\n shouldReact = this._changeTracker ? this._changeTracker.handleChange({\n changedObservable: observable,\n change,\n didChange: (o) => o === observable,\n }, this._changeSummary) : true;\n }\n catch (e) {\n onBugIndicatingError(e);\n }\n const wasUpToDate = this._state === 3 /* DerivedState.upToDate */;\n if (shouldReact && (this._state === 1 /* DerivedState.dependenciesMightHaveChanged */ || wasUpToDate)) {\n this._state = 2 /* DerivedState.stale */;\n if (wasUpToDate) {\n for (const r of this._observers) {\n r.handlePossibleChange(this);\n }\n }\n }\n }\n }\n // IReader Implementation\n _ensureReaderValid() {\n if (!this._isReaderValid) {\n throw new BugIndicatingError('The reader object cannot be used outside its compute function!');\n }\n }\n readObservable(observable) {\n this._ensureReaderValid();\n // Subscribe before getting the value to enable caching\n observable.addObserver(this);\n /** This might call {@link handleChange} indirectly, which could invalidate us */\n const value = observable.get();\n // Which is why we only add the observable to the dependencies now.\n this._dependencies.add(observable);\n this._dependenciesToBeRemoved.delete(observable);\n return value;\n }\n reportChange(change) {\n this._ensureReaderValid();\n this._didReportChange = true;\n // TODO add logging\n for (const r of this._observers) {\n r.handleChange(this, change);\n }\n }\n get store() {\n this._ensureReaderValid();\n if (this._store === undefined) {\n this._store = new DisposableStore();\n }\n return this._store;\n }\n get delayedStore() {\n this._ensureReaderValid();\n if (this._delayedStore === undefined) {\n this._delayedStore = new DisposableStore();\n }\n return this._delayedStore;\n }\n addObserver(observer) {\n const shouldCallBeginUpdate = !this._observers.has(observer) && this._updateCount > 0;\n super.addObserver(observer);\n if (shouldCallBeginUpdate) {\n if (this._removedObserverToCallEndUpdateOn && this._removedObserverToCallEndUpdateOn.has(observer)) {\n this._removedObserverToCallEndUpdateOn.delete(observer);\n }\n else {\n observer.beginUpdate(this);\n }\n }\n }\n removeObserver(observer) {\n if (this._observers.has(observer) && this._updateCount > 0) {\n if (!this._removedObserverToCallEndUpdateOn) {\n this._removedObserverToCallEndUpdateOn = new Set();\n }\n this._removedObserverToCallEndUpdateOn.add(observer);\n }\n super.removeObserver(observer);\n }\n debugGetState() {\n return {\n state: this._state,\n stateStr: derivedStateToString(this._state),\n updateCount: this._updateCount,\n isComputing: this._isComputing,\n dependencies: this._dependencies,\n value: this._value,\n };\n }\n debugSetValue(newValue) {\n this._value = newValue;\n }\n debugRecompute() {\n if (!this._isComputing) {\n this._recompute();\n }\n else {\n this._state = 2 /* DerivedState.stale */;\n }\n }\n setValue(newValue, tx, change) {\n this._value = newValue;\n const observers = this._observers;\n tx.updateObserver(this, this);\n for (const d of observers) {\n d.handleChange(this, change);\n }\n }\n}\nclass DerivedWithSetter extends Derived {\n constructor(debugNameData, computeFn, changeTracker, handleLastObserverRemoved = undefined, equalityComparator, set, debugLocation) {\n super(debugNameData, computeFn, changeTracker, handleLastObserverRemoved, equalityComparator, debugLocation);\n this.set = set;\n }\n}\n\nexport { Derived, DerivedWithSetter };\n//# sourceMappingURL=derivedImpl.js.map\n"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA,SAAS,oBAAoB,CAAC,KAAK,EAAE;AACrC,IAAI,QAAQ,KAAK;AACjB,QAAQ,KAAK,CAAC,6BAA6B,OAAO,SAAS;AAC3D,QAAQ,KAAK,CAAC,kDAAkD,OAAO,8BAA8B;AACrG,QAAQ,KAAK,CAAC,2BAA2B,OAAO,OAAO;AACvD,QAAQ,KAAK,CAAC,8BAA8B,OAAO,UAAU;AAC7D,QAAQ,SAAS,OAAO,WAAW;AACnC;AACA;AACA,MAAM,OAAO,SAAS,cAAc,CAAC;AACrC,IAAI,IAAI,SAAS,GAAG;AACpB,QAAQ,OAAO,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,aAAa;AACtE,IAAI;AACJ,IAAI,WAAW,CAAC,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,0BAA0B,GAAG,SAAS,EAAE,mBAAmB,EAAE,aAAa,EAAE;AACxI,QAAQ,KAAK,CAAC,aAAa,CAAC;AAC5B,QAAQ,IAAI,CAAC,cAAc,GAAG,cAAc;AAC5C,QAAQ,IAAI,CAAC,UAAU,GAAG,UAAU;AACpC,QAAQ,IAAI,CAAC,cAAc,GAAG,cAAc;AAC5C,QAAQ,IAAI,CAAC,0BAA0B,GAAG,0BAA0B;AACpE,QAAQ,IAAI,CAAC,mBAAmB,GAAG,mBAAmB;AACtD,QAAQ,IA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AE,IAAI,CAAC,MAAM;AAC9B,SAAS;AACT,IAAI;AACJ,IAAI,aAAa,CAAC,QAAQ,EAAE;AAC5B,QAAQ,IAAI,CAAC,MAAM,GAAG,QAAQ;AAC9B,IAAI;AACJ,IAAI,cAAc,GAAG;AACrB,QAAQ,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;AAChC,YAAY,IAAI,CAAC,UAAU,EAAE;AAC7B,QAAQ;AACR,aAAa;AACb,YAAY,IAAI,CAAC,MAAM,GAAG,CAAC;AAC3B,QAAQ;AACR,IAAI;AACJ,IAAI,QAAQ,CAAC,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE;AACnC,QAAQ,IAAI,CAAC,MAAM,GAAG,QAAQ;AAC9B,QAAQ,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU;AACzC,QAAQ,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC;AACrC,QAAQ,KAAK,MAAM,CAAC,IAAI,SAAS,EAAE;AACnC,YAAY,CAAC,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC;AACxC,QAAQ;AACR,IAAI;AACJ;;;;"}
@@ -0,0 +1,123 @@
1
+ import { subtransaction } from '../transaction.js';
2
+ import { strictEquals } from '../commonFacade/deps.js';
3
+ import { DebugNameData } from '../debugName.js';
4
+ import { getLogger } from '../logging/logging.js';
5
+ import { BaseObservable } from './baseObservable.js';
6
+ import { DebugLocation } from '../debugLocation.js';
7
+
8
+ /*---------------------------------------------------------------------------------------------
9
+ * Copyright (c) Microsoft Corporation. All rights reserved.
10
+ * Licensed under the MIT License. See License.txt in the project root for license information.
11
+ *--------------------------------------------------------------------------------------------*/
12
+
13
+ /*---------------------------------------------------------------------------------------------
14
+ * Copyright (c) Microsoft Corporation. All rights reserved.
15
+ * Licensed under the MIT License. See License.txt in the project root for license information.
16
+ *--------------------------------------------------------------------------------------------*/
17
+ function observableFromEvent(...args) {
18
+ let owner;
19
+ let event;
20
+ let getValue;
21
+ let debugLocation;
22
+ if (args.length === 2) {
23
+ [event, getValue] = args;
24
+ }
25
+ else {
26
+ [owner, event, getValue, debugLocation] = args;
27
+ }
28
+ return new FromEventObservable(new DebugNameData(owner, undefined, getValue), event, getValue, () => FromEventObservable.globalTransaction, strictEquals, debugLocation ?? DebugLocation.ofCaller());
29
+ }
30
+ class FromEventObservable extends BaseObservable {
31
+ constructor(_debugNameData, event, _getValue, _getTransaction, _equalityComparator, debugLocation) {
32
+ super(debugLocation);
33
+ this._debugNameData = _debugNameData;
34
+ this.event = event;
35
+ this._getValue = _getValue;
36
+ this._getTransaction = _getTransaction;
37
+ this._equalityComparator = _equalityComparator;
38
+ this._hasValue = false;
39
+ this.handleEvent = (args) => {
40
+ const newValue = this._getValue(args);
41
+ const oldValue = this._value;
42
+ const didChange = !this._hasValue || !(this._equalityComparator(oldValue, newValue));
43
+ let didRunTransaction = false;
44
+ if (didChange) {
45
+ this._value = newValue;
46
+ if (this._hasValue) {
47
+ didRunTransaction = true;
48
+ subtransaction(this._getTransaction(), (tx) => {
49
+ getLogger()?.handleObservableUpdated(this, { oldValue, newValue, change: undefined, didChange, hadValue: this._hasValue });
50
+ for (const o of this._observers) {
51
+ tx.updateObserver(o, this);
52
+ o.handleChange(this, undefined);
53
+ }
54
+ }, () => {
55
+ const name = this.getDebugName();
56
+ return 'Event fired' + (name ? `: ${name}` : '');
57
+ });
58
+ }
59
+ this._hasValue = true;
60
+ }
61
+ if (!didRunTransaction) {
62
+ getLogger()?.handleObservableUpdated(this, { oldValue, newValue, change: undefined, didChange, hadValue: this._hasValue });
63
+ }
64
+ };
65
+ }
66
+ getDebugName() {
67
+ return this._debugNameData.getDebugName(this);
68
+ }
69
+ get debugName() {
70
+ const name = this.getDebugName();
71
+ return 'From Event' + (name ? `: ${name}` : '');
72
+ }
73
+ onFirstObserverAdded() {
74
+ this._subscription = this.event(this.handleEvent);
75
+ }
76
+ onLastObserverRemoved() {
77
+ this._subscription.dispose();
78
+ this._subscription = undefined;
79
+ this._hasValue = false;
80
+ this._value = undefined;
81
+ }
82
+ get() {
83
+ if (this._subscription) {
84
+ if (!this._hasValue) {
85
+ this.handleEvent(undefined);
86
+ }
87
+ return this._value;
88
+ }
89
+ else {
90
+ // no cache, as there are no subscribers to keep it updated
91
+ const value = this._getValue(undefined);
92
+ return value;
93
+ }
94
+ }
95
+ debugSetValue(value) {
96
+ this._value = value;
97
+ }
98
+ debugGetState() {
99
+ return { value: this._value, hasValue: this._hasValue };
100
+ }
101
+ }
102
+ (function (observableFromEvent) {
103
+ observableFromEvent.Observer = FromEventObservable;
104
+ function batchEventsGlobally(tx, fn) {
105
+ let didSet = false;
106
+ if (FromEventObservable.globalTransaction === undefined) {
107
+ FromEventObservable.globalTransaction = tx;
108
+ didSet = true;
109
+ }
110
+ try {
111
+ fn();
112
+ }
113
+ finally {
114
+ if (didSet) {
115
+ FromEventObservable.globalTransaction = undefined;
116
+ }
117
+ }
118
+ }
119
+ observableFromEvent.batchEventsGlobally = batchEventsGlobally;
120
+ })(observableFromEvent || (observableFromEvent = {}));
121
+
122
+ export { FromEventObservable, observableFromEvent };
123
+ //# sourceMappingURL=observableFromEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observableFromEvent.js","sources":["../../../../../../../../../external/vscode-observables/observables/dist/observableInternal/observables/observableFromEvent.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 { subtransaction } from '../transaction.js';\nimport { strictEquals } from '../commonFacade/deps.js';\nimport { DebugNameData } from '../debugName.js';\nimport { getLogger } from '../logging/logging.js';\nimport { BaseObservable } from './baseObservable.js';\nimport { DebugLocation } from '../debugLocation.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 observableFromEvent(...args) {\n let owner;\n let event;\n let getValue;\n let debugLocation;\n if (args.length === 2) {\n [event, getValue] = args;\n }\n else {\n [owner, event, getValue, debugLocation] = args;\n }\n return new FromEventObservable(new DebugNameData(owner, undefined, getValue), event, getValue, () => FromEventObservable.globalTransaction, strictEquals, debugLocation ?? DebugLocation.ofCaller());\n}\nfunction observableFromEventOpts(options, event, getValue, debugLocation = DebugLocation.ofCaller()) {\n return new FromEventObservable(new DebugNameData(options.owner, options.debugName, options.debugReferenceFn ?? getValue), event, getValue, () => FromEventObservable.globalTransaction, options.equalsFn ?? strictEquals, debugLocation);\n}\nclass FromEventObservable extends BaseObservable {\n constructor(_debugNameData, event, _getValue, _getTransaction, _equalityComparator, debugLocation) {\n super(debugLocation);\n this._debugNameData = _debugNameData;\n this.event = event;\n this._getValue = _getValue;\n this._getTransaction = _getTransaction;\n this._equalityComparator = _equalityComparator;\n this._hasValue = false;\n this.handleEvent = (args) => {\n const newValue = this._getValue(args);\n const oldValue = this._value;\n const didChange = !this._hasValue || !(this._equalityComparator(oldValue, newValue));\n let didRunTransaction = false;\n if (didChange) {\n this._value = newValue;\n if (this._hasValue) {\n didRunTransaction = true;\n subtransaction(this._getTransaction(), (tx) => {\n getLogger()?.handleObservableUpdated(this, { oldValue, newValue, change: undefined, didChange, hadValue: this._hasValue });\n for (const o of this._observers) {\n tx.updateObserver(o, this);\n o.handleChange(this, undefined);\n }\n }, () => {\n const name = this.getDebugName();\n return 'Event fired' + (name ? `: ${name}` : '');\n });\n }\n this._hasValue = true;\n }\n if (!didRunTransaction) {\n getLogger()?.handleObservableUpdated(this, { oldValue, newValue, change: undefined, didChange, hadValue: this._hasValue });\n }\n };\n }\n getDebugName() {\n return this._debugNameData.getDebugName(this);\n }\n get debugName() {\n const name = this.getDebugName();\n return 'From Event' + (name ? `: ${name}` : '');\n }\n onFirstObserverAdded() {\n this._subscription = this.event(this.handleEvent);\n }\n onLastObserverRemoved() {\n this._subscription.dispose();\n this._subscription = undefined;\n this._hasValue = false;\n this._value = undefined;\n }\n get() {\n if (this._subscription) {\n if (!this._hasValue) {\n this.handleEvent(undefined);\n }\n return this._value;\n }\n else {\n // no cache, as there are no subscribers to keep it updated\n const value = this._getValue(undefined);\n return value;\n }\n }\n debugSetValue(value) {\n this._value = value;\n }\n debugGetState() {\n return { value: this._value, hasValue: this._hasValue };\n }\n}\n(function (observableFromEvent) {\n observableFromEvent.Observer = FromEventObservable;\n function batchEventsGlobally(tx, fn) {\n let didSet = false;\n if (FromEventObservable.globalTransaction === undefined) {\n FromEventObservable.globalTransaction = tx;\n didSet = true;\n }\n try {\n fn();\n }\n finally {\n if (didSet) {\n FromEventObservable.globalTransaction = undefined;\n }\n }\n }\n observableFromEvent.batchEventsGlobally = batchEventsGlobally;\n})(observableFromEvent || (observableFromEvent = {}));\n\nexport { FromEventObservable, observableFromEvent, observableFromEventOpts };\n//# sourceMappingURL=observableFromEvent.js.map\n"],"names":[],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA,SAAS,mBAAmB,CAAC,GAAG,IAAI,EAAE;AACtC,IAAI,IAAI,KAAK;AACb,IAAI,IAAI,KAAK;AACb,IAAI,IAAI,QAAQ;AAChB,IAAI,IAAI,aAAa;AACrB,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;AAC3B,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAI;AAChC,IAAI;AACJ,SAAS;AACT,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,CAAC,GAAG,IAAI;AACtD,IAAI;AACJ,IAAI,OAAO,IAAI,mBAAmB,CAAC,IAAI,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC,iBAAiB,EAAE,YAAY,EAAE,aAAa,IAAI,aAAa,CAAC,QAAQ,EAAE,CAAC;AACxM;AAIA,M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AmB,GAAG,mBAAmB;AACjE,CAAC,EAAE,mBAAmB,KAAK,mBAAmB,GAAG,EAAE,CAAC,CAAC;;;;"}
@@ -0,0 +1,81 @@
1
+ import { TransactionImpl } from '../transaction.js';
2
+ import { BaseObservable } from './baseObservable.js';
3
+ import { strictEquals } from '../commonFacade/deps.js';
4
+ import { DebugNameData } from '../debugName.js';
5
+ import { getLogger } from '../logging/logging.js';
6
+ import { DebugLocation } from '../debugLocation.js';
7
+
8
+ /*---------------------------------------------------------------------------------------------
9
+ * Copyright (c) Microsoft Corporation. All rights reserved.
10
+ * Licensed under the MIT License. See License.txt in the project root for license information.
11
+ *--------------------------------------------------------------------------------------------*/
12
+
13
+ /*---------------------------------------------------------------------------------------------
14
+ * Copyright (c) Microsoft Corporation. All rights reserved.
15
+ * Licensed under the MIT License. See License.txt in the project root for license information.
16
+ *--------------------------------------------------------------------------------------------*/
17
+ function observableValue(nameOrOwner, initialValue, debugLocation = DebugLocation.ofCaller()) {
18
+ let debugNameData;
19
+ if (typeof nameOrOwner === 'string') {
20
+ debugNameData = new DebugNameData(undefined, nameOrOwner, undefined);
21
+ }
22
+ else {
23
+ debugNameData = new DebugNameData(nameOrOwner, undefined, undefined);
24
+ }
25
+ return new ObservableValue(debugNameData, initialValue, strictEquals, debugLocation);
26
+ }
27
+ class ObservableValue extends BaseObservable {
28
+ get debugName() {
29
+ return this._debugNameData.getDebugName(this) ?? 'ObservableValue';
30
+ }
31
+ constructor(_debugNameData, initialValue, _equalityComparator, debugLocation) {
32
+ super(debugLocation);
33
+ this._debugNameData = _debugNameData;
34
+ this._equalityComparator = _equalityComparator;
35
+ this._value = initialValue;
36
+ getLogger()?.handleObservableUpdated(this, { hadValue: false, newValue: initialValue, change: undefined, didChange: true, oldValue: undefined });
37
+ }
38
+ get() {
39
+ return this._value;
40
+ }
41
+ set(value, tx, change) {
42
+ if (change === undefined && this._equalityComparator(this._value, value)) {
43
+ return;
44
+ }
45
+ let _tx;
46
+ if (!tx) {
47
+ tx = _tx = new TransactionImpl(() => { }, () => `Setting ${this.debugName}`);
48
+ }
49
+ try {
50
+ const oldValue = this._value;
51
+ this._setValue(value);
52
+ getLogger()?.handleObservableUpdated(this, { oldValue, newValue: value, change, didChange: true, hadValue: true });
53
+ for (const observer of this._observers) {
54
+ tx.updateObserver(observer, this);
55
+ observer.handleChange(this, change);
56
+ }
57
+ }
58
+ finally {
59
+ if (_tx) {
60
+ _tx.finish();
61
+ }
62
+ }
63
+ }
64
+ toString() {
65
+ return `${this.debugName}: ${this._value}`;
66
+ }
67
+ _setValue(newValue) {
68
+ this._value = newValue;
69
+ }
70
+ debugGetState() {
71
+ return {
72
+ value: this._value,
73
+ };
74
+ }
75
+ debugSetValue(value) {
76
+ this._value = value;
77
+ }
78
+ }
79
+
80
+ export { ObservableValue, observableValue };
81
+ //# sourceMappingURL=observableValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observableValue.js","sources":["../../../../../../../../../external/vscode-observables/observables/dist/observableInternal/observables/observableValue.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 { TransactionImpl } from '../transaction.js';\nimport { BaseObservable } from './baseObservable.js';\nimport { strictEquals } from '../commonFacade/deps.js';\nimport { DebugNameData } from '../debugName.js';\nimport { getLogger } from '../logging/logging.js';\nimport { DebugLocation } from '../debugLocation.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 observableValue(nameOrOwner, initialValue, debugLocation = DebugLocation.ofCaller()) {\n let debugNameData;\n if (typeof nameOrOwner === 'string') {\n debugNameData = new DebugNameData(undefined, nameOrOwner, undefined);\n }\n else {\n debugNameData = new DebugNameData(nameOrOwner, undefined, undefined);\n }\n return new ObservableValue(debugNameData, initialValue, strictEquals, debugLocation);\n}\nclass ObservableValue extends BaseObservable {\n get debugName() {\n return this._debugNameData.getDebugName(this) ?? 'ObservableValue';\n }\n constructor(_debugNameData, initialValue, _equalityComparator, debugLocation) {\n super(debugLocation);\n this._debugNameData = _debugNameData;\n this._equalityComparator = _equalityComparator;\n this._value = initialValue;\n getLogger()?.handleObservableUpdated(this, { hadValue: false, newValue: initialValue, change: undefined, didChange: true, oldValue: undefined });\n }\n get() {\n return this._value;\n }\n set(value, tx, change) {\n if (change === undefined && this._equalityComparator(this._value, value)) {\n return;\n }\n let _tx;\n if (!tx) {\n tx = _tx = new TransactionImpl(() => { }, () => `Setting ${this.debugName}`);\n }\n try {\n const oldValue = this._value;\n this._setValue(value);\n getLogger()?.handleObservableUpdated(this, { oldValue, newValue: value, change, didChange: true, hadValue: true });\n for (const observer of this._observers) {\n tx.updateObserver(observer, this);\n observer.handleChange(this, change);\n }\n }\n finally {\n if (_tx) {\n _tx.finish();\n }\n }\n }\n toString() {\n return `${this.debugName}: ${this._value}`;\n }\n _setValue(newValue) {\n this._value = newValue;\n }\n debugGetState() {\n return {\n value: this._value,\n };\n }\n debugSetValue(value) {\n this._value = value;\n }\n}\n/**\n * A disposable observable. When disposed, its value is also disposed.\n * When a new value is set, the previous value is disposed.\n */\nfunction disposableObservableValue(nameOrOwner, initialValue, debugLocation = DebugLocation.ofCaller()) {\n let debugNameData;\n if (typeof nameOrOwner === 'string') {\n debugNameData = new DebugNameData(undefined, nameOrOwner, undefined);\n }\n else {\n debugNameData = new DebugNameData(nameOrOwner, undefined, undefined);\n }\n return new DisposableObservableValue(debugNameData, initialValue, strictEquals, debugLocation);\n}\nclass DisposableObservableValue extends ObservableValue {\n _setValue(newValue) {\n if (this._value === newValue) {\n return;\n }\n if (this._value) {\n this._value.dispose();\n }\n this._value = newValue;\n }\n dispose() {\n this._value?.dispose();\n }\n}\n\nexport { DisposableObservableValue, ObservableValue, disposableObservableValue, observableValue };\n//# sourceMappingURL=observableValue.js.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