@vscode/markdown-editor 0.0.2-0

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 (62) hide show
  1. package/dist/commands/cursorCommands.d.ts +13 -0
  2. package/dist/commands/editCommands.d.ts +14 -0
  3. package/dist/commands/index.d.ts +4 -0
  4. package/dist/commands/selectionCommands.d.ts +6 -0
  5. package/dist/commands/types.d.ts +26 -0
  6. package/dist/core/geometry.d.ts +37 -0
  7. package/dist/core/index.d.ts +8 -0
  8. package/dist/core/lengthEdit.d.ts +38 -0
  9. package/dist/core/offsetRange.d.ts +26 -0
  10. package/dist/core/selection.d.ts +13 -0
  11. package/dist/core/sourceOffset.d.ts +1 -0
  12. package/dist/core/stringEdit.d.ts +27 -0
  13. package/dist/core/stringValue.d.ts +8 -0
  14. package/dist/core/wordUtils.d.ts +6 -0
  15. package/dist/highlighter/defaultMonacoSyntaxHighlighter.d.ts +20 -0
  16. package/dist/highlighter/index.d.ts +3 -0
  17. package/dist/highlighter/monacoSyntaxHighlighter.d.ts +38 -0
  18. package/dist/highlighter/syntaxHighlighter.d.ts +67 -0
  19. package/dist/index.d.ts +6 -0
  20. package/dist/index.js +4274 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/model/cursorNavigation.d.ts +7 -0
  23. package/dist/model/editorModel.d.ts +54 -0
  24. package/dist/model/index.d.ts +4 -0
  25. package/dist/model/measuredLayoutModel.d.ts +50 -0
  26. package/dist/observables.d.ts +1 -0
  27. package/dist/observables.js +463 -0
  28. package/dist/observables.js.map +1 -0
  29. package/dist/parser/_micromarkAdapter.d.ts +7 -0
  30. package/dist/parser/ast.d.ts +274 -0
  31. package/dist/parser/index.d.ts +4 -0
  32. package/dist/parser/parse.d.ts +2 -0
  33. package/dist/parser/parser.d.ts +14 -0
  34. package/dist/parser/reconcile.d.ts +33 -0
  35. package/dist/parser/test/getAnnotatedSource.d.ts +2 -0
  36. package/dist/parser/test/snapshot.d.ts +9 -0
  37. package/dist/parser/visualizeAst.d.ts +33 -0
  38. package/dist/runOnChange-owE1SMC0.js +1514 -0
  39. package/dist/runOnChange-owE1SMC0.js.map +1 -0
  40. package/dist/test/random.d.ts +16 -0
  41. package/dist/view/content/blockView.d.ts +179 -0
  42. package/dist/view/content/documentView.d.ts +41 -0
  43. package/dist/view/content/dom.d.ts +16 -0
  44. package/dist/view/content/katexEditableIdentifiers.d.ts +36 -0
  45. package/dist/view/content/viewNode.d.ts +93 -0
  46. package/dist/view/editorController.d.ts +34 -0
  47. package/dist/view/editorView.d.ts +100 -0
  48. package/dist/view/fixture/astViewerView.d.ts +27 -0
  49. package/dist/view/fixture/cyclingTsHighlighter.d.ts +17 -0
  50. package/dist/view/fixture/debugColors.d.ts +26 -0
  51. package/dist/view/fixture/monacoDebugPanel.d.ts +7 -0
  52. package/dist/view/index.d.ts +9 -0
  53. package/dist/view/measuredLayoutDebugView.d.ts +70 -0
  54. package/dist/view/parts/cursorView.d.ts +29 -0
  55. package/dist/view/parts/selectionView.d.ts +57 -0
  56. package/dist/view/viewData.d.ts +251 -0
  57. package/dist/view/visualLineMap.d.ts +157 -0
  58. package/dist/view/visualizeViewTree.d.ts +5 -0
  59. package/package.json +68 -0
  60. package/src/view/editor.css +517 -0
  61. package/src/view/themes/default.css +235 -0
  62. package/src/view/themes/github.css +308 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runOnChange-owE1SMC0.js","sources":["../../../external/vscode-observables/observables/dist/observableInternal/logging/logging.js","../../../external/vscode-observables/observables/dist/observableInternal/debugLocation.js","../../../external/vscode-observables/observables/dist/observableInternal/debugName.js","../../../external/vscode-observables/observables/dist/observableInternal/observables/baseObservable.js","../../../external/vscode-observables/observables/dist/observableInternal/commonFacade/deps.js","../../../external/vscode-observables/observables/dist/disposables.js","../../../external/vscode-observables/observables/dist/observableInternal/observables/derivedImpl.js","../../../external/vscode-observables/observables/dist/observableInternal/observables/derived.js","../../../external/vscode-observables/observables/dist/observableInternal/reactions/autorunImpl.js","../../../external/vscode-observables/observables/dist/observableInternal/reactions/autorun.js","../../../external/vscode-observables/observables/dist/observableInternal/base.js","../../../external/vscode-observables/observables/dist/observableInternal/transaction.js","../../../external/vscode-observables/observables/dist/observableInternal/observables/observableValue.js","../../../external/vscode-observables/observables/dist/observableInternal/observables/observableFromEvent.js","../../../external/vscode-observables/observables/dist/observableInternal/observables/observableSignal.js","../../../external/vscode-observables/observables/dist/observableInternal/utils/utils.js","../../../external/vscode-observables/observables/dist/observableInternal/logging/consoleObservableLogger.js","../../../external/vscode-observables/observables/dist/observableInternal/logging/debugGetDependencyGraph.js","../../../external/vscode-observables/observables/dist/observableInternal/index.js","../../../external/vscode-observables/observables/dist/observableInternal/commonFacade/cancellation.js","../../../external/vscode-observables/observables/dist/observableInternal/utils/runOnChange.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","/*---------------------------------------------------------------------------------------------\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 *--------------------------------------------------------------------------------------------*/\nvar DebugLocation;\n(function (DebugLocation) {\n let enabled = false;\n function enable() {\n enabled = true;\n }\n DebugLocation.enable = enable;\n function ofCaller() {\n return ofNthCaller(1);\n }\n DebugLocation.ofCaller = ofCaller;\n function ofNthCaller(n) {\n if (!enabled) {\n return undefined;\n }\n const Err = Error; // For the monaco editor checks, which don't have the nodejs types.\n const l = Err.stackTraceLimit;\n Err.stackTraceLimit = 3;\n const stack = new Error().stack;\n Err.stackTraceLimit = l;\n return DebugLocationImpl.fromStack(stack, n + 1);\n }\n DebugLocation.ofNthCaller = ofNthCaller;\n})(DebugLocation || (DebugLocation = {}));\nclass DebugLocationImpl {\n static fromStack(stack, parentIdx) {\n const lines = stack.split('\\n');\n const location = parseLine(lines[parentIdx + 1]);\n if (location) {\n return new DebugLocationImpl(location.fileName, location.line, location.column, location.id);\n }\n else {\n return undefined;\n }\n }\n constructor(fileName, line, column, id) {\n this.fileName = fileName;\n this.line = line;\n this.column = column;\n this.id = id;\n }\n}\nfunction parseLine(stackLine) {\n if (!stackLine) {\n return undefined;\n }\n const match = stackLine.match(/\\((.*):(\\d+):(\\d+)\\)/);\n if (match) {\n return {\n fileName: match[1],\n line: parseInt(match[2]),\n column: parseInt(match[3]),\n id: stackLine,\n };\n }\n const match2 = stackLine.match(/at ([^\\(\\)]*):(\\d+):(\\d+)/);\n if (match2) {\n return {\n fileName: match2[1],\n line: parseInt(match2[2]),\n column: parseInt(match2[3]),\n id: stackLine,\n };\n }\n return undefined;\n}\n\nexport { DebugLocation };\n//# sourceMappingURL=debugLocation.js.map\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 *--------------------------------------------------------------------------------------------*/\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 *--------------------------------------------------------------------------------------------*/\nclass DebugNameData {\n constructor(owner, debugNameSource, referenceFn) {\n this.owner = owner;\n this.debugNameSource = debugNameSource;\n this.referenceFn = referenceFn;\n }\n getDebugName(target) {\n return getDebugName(target, this);\n }\n}\nconst countPerName = new Map();\nconst cachedDebugName = new WeakMap();\nfunction getDebugName(target, data) {\n const cached = cachedDebugName.get(target);\n if (cached) {\n return cached;\n }\n const dbgName = computeDebugName(target, data);\n if (dbgName) {\n let count = countPerName.get(dbgName) ?? 0;\n count++;\n countPerName.set(dbgName, count);\n const result = count === 1 ? dbgName : `${dbgName}#${count}`;\n cachedDebugName.set(target, result);\n return result;\n }\n return undefined;\n}\nfunction computeDebugName(self, data) {\n const cached = cachedDebugName.get(self);\n if (cached) {\n return cached;\n }\n const ownerStr = data.owner ? formatOwner(data.owner) + `.` : '';\n let result;\n const debugNameSource = data.debugNameSource;\n if (debugNameSource !== undefined) {\n if (typeof debugNameSource === 'function') {\n result = debugNameSource();\n if (result !== undefined) {\n return ownerStr + result;\n }\n }\n else {\n return ownerStr + debugNameSource;\n }\n }\n const referenceFn = data.referenceFn;\n if (referenceFn !== undefined) {\n result = getFunctionName(referenceFn);\n if (result !== undefined) {\n return ownerStr + result;\n }\n }\n if (data.owner !== undefined) {\n const key = findKey(data.owner, self);\n if (key !== undefined) {\n return ownerStr + key;\n }\n }\n return undefined;\n}\nfunction findKey(obj, value) {\n for (const key in obj) {\n if (obj[key] === value) {\n return key;\n }\n }\n return undefined;\n}\nconst countPerClassName = new Map();\nconst ownerId = new WeakMap();\nfunction formatOwner(owner) {\n const id = ownerId.get(owner);\n if (id) {\n return id;\n }\n const className = getClassName(owner) ?? 'Object';\n let count = countPerClassName.get(className) ?? 0;\n count++;\n countPerClassName.set(className, count);\n const result = count === 1 ? className : `${className}#${count}`;\n ownerId.set(owner, result);\n return result;\n}\nfunction getClassName(obj) {\n const ctor = obj.constructor;\n if (ctor) {\n if (ctor.name === 'Object') {\n return undefined;\n }\n return ctor.name;\n }\n return undefined;\n}\nfunction getFunctionName(fn) {\n const fnSrc = fn.toString();\n // Pattern: /** @description ... */\n const regexp = /\\/\\*\\*\\s*@description\\s*([^*]*)\\*\\//;\n const match = regexp.exec(fnSrc);\n const result = match ? match[1] : undefined;\n return result?.trim();\n}\n\nexport { DebugNameData, getClassName, getDebugName, getFunctionName };\n//# sourceMappingURL=debugName.js.map\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 *--------------------------------------------------------------------------------------------*/\nimport { DebugLocation } from '../debugLocation.js';\nimport { getFunctionName } from '../debugName.js';\nimport { logObservable, getLogger } 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","/*---------------------------------------------------------------------------------------------\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 *--------------------------------------------------------------------------------------------*/\nfunction toDisposable(fn) {\n return {\n dispose: fn\n };\n}\nclass BugIndicatingError extends Error {\n constructor(message) {\n super(message || 'An unexpected bug occurred.');\n Object.setPrototypeOf(this, BugIndicatingError.prototype);\n // Because we know for sure only buggy code throws this,\n // we definitely want to break here and fix the bug.\n // eslint-disable-next-line no-debugger\n // debugger;\n }\n}\nfunction onBugIndicatingError(error) {\n // debugger;\n throw error;\n}\nfunction onUnexpectedError(error) {\n console.error('Unexpected error:', error);\n}\n/**\n * Compares two items for equality using strict equality.\n*/\nconst strictEquals = (a, b) => a === b;\n\nexport { BugIndicatingError, onBugIndicatingError, onUnexpectedError, strictEquals, toDisposable };\n//# sourceMappingURL=deps.js.map\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 *--------------------------------------------------------------------------------------------*/\nclass DisposableStore {\n constructor() {\n this.disposables = [];\n this._isDisposed = false;\n }\n get isDisposed() { return this._isDisposed; }\n dispose() {\n this.clear();\n this._isDisposed = true;\n }\n add(disposable) {\n if (disposable) {\n this.disposables.push(disposable);\n }\n return disposable;\n }\n remove(disposable) {\n if (!disposable) {\n return disposable;\n }\n const index = this.disposables.indexOf(disposable);\n if (index !== -1) {\n this.disposables.splice(index, 1);\n }\n return disposable;\n }\n clear() {\n for (const disposable of this.disposables) {\n disposable.dispose();\n }\n this.disposables = [];\n }\n leakItems() {\n this.disposables = [];\n }\n}\nclass Disposable {\n constructor() {\n this._store = new DisposableStore();\n }\n dispose() {\n this._store.dispose();\n }\n _register(t) {\n this._store.add(t);\n return t;\n }\n _registerOrDispose(t) {\n if (t) {\n if (this._store.isDisposed) {\n t.dispose();\n }\n else {\n this._store.add(t);\n }\n }\n return t;\n }\n}\n\nexport { Disposable, DisposableStore };\n//# sourceMappingURL=disposables.js.map\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 *--------------------------------------------------------------------------------------------*/\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","/*---------------------------------------------------------------------------------------------\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","/*---------------------------------------------------------------------------------------------\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 { onBugIndicatingError, BugIndicatingError } 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 autorunStateToString(state) {\n switch (state) {\n case 1 /* AutorunState.dependenciesMightHaveChanged */: return 'dependenciesMightHaveChanged';\n case 2 /* AutorunState.stale */: return 'stale';\n case 3 /* AutorunState.upToDate */: return 'upToDate';\n default: return '<unknown>';\n }\n}\nclass AutorunObserver {\n get debugName() {\n return this._debugNameData.getDebugName(this) ?? '(anonymous)';\n }\n constructor(_debugNameData, _runFn, _changeTracker, debugLocation) {\n this._debugNameData = _debugNameData;\n this._runFn = _runFn;\n this._changeTracker = _changeTracker;\n this._state = 2 /* AutorunState.stale */;\n this._updateCount = 0;\n this._disposed = false;\n this._dependencies = new Set();\n this._dependenciesToBeRemoved = new Set();\n this._isRunning = false;\n this._store = undefined;\n this._delayedStore = undefined;\n this._changeSummary = this._changeTracker?.createChangeSummary(undefined);\n getLogger()?.handleAutorunCreated(this, debugLocation);\n this._run();\n }\n dispose() {\n if (this._disposed) {\n return;\n }\n this._disposed = true;\n for (const o of this._dependencies) {\n o.removeObserver(this); // Warning: external call!\n }\n this._dependencies.clear();\n if (this._store !== undefined) {\n this._store.dispose();\n }\n if (this._delayedStore !== undefined) {\n this._delayedStore.dispose();\n }\n getLogger()?.handleAutorunDisposed(this);\n }\n _run() {\n const emptySet = this._dependenciesToBeRemoved;\n this._dependenciesToBeRemoved = this._dependencies;\n this._dependencies = emptySet;\n this._state = 3 /* AutorunState.upToDate */;\n try {\n if (!this._disposed) {\n getLogger()?.handleAutorunStarted(this);\n const changeSummary = this._changeSummary;\n const delayedStore = this._delayedStore;\n if (delayedStore !== undefined) {\n this._delayedStore = undefined;\n }\n try {\n this._isRunning = true;\n if (this._changeTracker) {\n this._changeTracker.beforeUpdate?.(this, changeSummary);\n this._changeSummary = this._changeTracker.createChangeSummary(changeSummary); // Warning: external call!\n }\n if (this._store !== undefined) {\n this._store.dispose();\n this._store = undefined;\n }\n this._runFn(this, changeSummary); // Warning: external call!\n }\n catch (e) {\n onBugIndicatingError(e);\n }\n finally {\n this._isRunning = false;\n if (delayedStore !== undefined) {\n delayedStore.dispose();\n }\n }\n }\n }\n finally {\n if (!this._disposed) {\n getLogger()?.handleAutorunFinished(this);\n }\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); // Warning: external call!\n }\n this._dependenciesToBeRemoved.clear();\n }\n }\n toString() {\n return `Autorun<${this.debugName}>`;\n }\n // IObserver implementation\n beginUpdate(_observable) {\n if (this._state === 3 /* AutorunState.upToDate */) {\n this._state = 1 /* AutorunState.dependenciesMightHaveChanged */;\n }\n this._updateCount++;\n }\n endUpdate(_observable) {\n try {\n if (this._updateCount === 1) {\n do {\n if (this._state === 1 /* AutorunState.dependenciesMightHaveChanged */) {\n this._state = 3 /* AutorunState.upToDate */;\n for (const d of this._dependencies) {\n d.reportChanges(); // Warning: external call!\n if (this._state === 2 /* AutorunState.stale */) {\n // The other dependencies will refresh on demand\n break;\n }\n }\n }\n if (this._state !== 3 /* AutorunState.upToDate */) {\n this._run(); // Warning: indirect external call!\n }\n } while (this._state !== 3 /* AutorunState.upToDate */);\n }\n }\n finally {\n this._updateCount--;\n }\n }\n handlePossibleChange(observable) {\n if (this._state === 3 /* AutorunState.upToDate */ && this._isDependency(observable)) {\n this._state = 1 /* AutorunState.dependenciesMightHaveChanged */;\n }\n }\n handleChange(observable, change) {\n if (this._isDependency(observable)) {\n getLogger()?.handleAutorunDependencyChanged(this, observable, change);\n try {\n // Warning: external call!\n const shouldReact = this._changeTracker ? this._changeTracker.handleChange({\n changedObservable: observable,\n change,\n didChange: (o) => o === observable,\n }, this._changeSummary) : true;\n if (shouldReact) {\n this._state = 2 /* AutorunState.stale */;\n }\n }\n catch (e) {\n onBugIndicatingError(e);\n }\n }\n }\n _isDependency(observable) {\n return this._dependencies.has(observable) && !this._dependenciesToBeRemoved.has(observable);\n }\n // IReader implementation\n _ensureNoRunning() {\n if (!this._isRunning) {\n throw new BugIndicatingError('The reader object cannot be used outside its compute function!');\n }\n }\n readObservable(observable) {\n this._ensureNoRunning();\n // In case the run action disposes the autorun\n if (this._disposed) {\n return observable.get(); // warning: external call!\n }\n observable.addObserver(this); // warning: external call!\n const value = observable.get(); // warning: external call!\n this._dependencies.add(observable);\n this._dependenciesToBeRemoved.delete(observable);\n return value;\n }\n get store() {\n this._ensureNoRunning();\n if (this._disposed) {\n throw new BugIndicatingError('Cannot access store after dispose');\n }\n if (this._store === undefined) {\n this._store = new DisposableStore();\n }\n return this._store;\n }\n get delayedStore() {\n this._ensureNoRunning();\n if (this._disposed) {\n throw new BugIndicatingError('Cannot access store after dispose');\n }\n if (this._delayedStore === undefined) {\n this._delayedStore = new DisposableStore();\n }\n return this._delayedStore;\n }\n debugGetState() {\n return {\n isRunning: this._isRunning,\n updateCount: this._updateCount,\n dependencies: this._dependencies,\n state: this._state,\n stateStr: autorunStateToString(this._state),\n };\n }\n debugRerun() {\n if (!this._isRunning) {\n this._run();\n }\n else {\n this._state = 2 /* AutorunState.stale */;\n }\n }\n}\n\nexport { AutorunObserver };\n//# sourceMappingURL=autorunImpl.js.map\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 *--------------------------------------------------------------------------------------------*/\nimport { toDisposable } from '../commonFacade/deps.js';\nimport { DebugNameData } from '../debugName.js';\nimport { AutorunObserver } from './autorunImpl.js';\nimport { DebugLocation } from '../debugLocation.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 *--------------------------------------------------------------------------------------------*/\n/**\n * Runs immediately and whenever a transaction ends and an observed observable changed.\n * {@link fn} should start with a JS Doc using `@description` to name the autorun.\n */\nfunction autorun(fn, debugLocation = DebugLocation.ofCaller()) {\n return new AutorunObserver(new DebugNameData(undefined, undefined, fn), fn, undefined, debugLocation);\n}\n/**\n * Runs immediately and whenever a transaction ends and an observed observable changed.\n * {@link fn} should start with a JS Doc using `@description` to name the autorun.\n */\nfunction autorunOpts(options, fn, debugLocation = DebugLocation.ofCaller()) {\n return new AutorunObserver(new DebugNameData(options.owner, options.debugName, options.debugReferenceFn ?? fn), fn, undefined, debugLocation);\n}\n/**\n * Runs immediately and whenever a transaction ends and an observed observable changed.\n * {@link fn} should start with a JS Doc using `@description` to name the autorun.\n *\n * Use `changeTracker.createChangeSummary` to create a \"change summary\" that can collect the changes.\n * Use `changeTracker.handleChange` to add a reported change to the change summary.\n * The run function is given the last change summary.\n * The change summary is discarded after the run function was called.\n *\n * @see autorun\n */\nfunction autorunHandleChanges(options, fn, debugLocation = DebugLocation.ofCaller()) {\n return new AutorunObserver(new DebugNameData(options.owner, options.debugName, options.debugReferenceFn ?? fn), fn, options.changeTracker, debugLocation);\n}\n/**\n * @see autorunHandleChanges (but with a disposable store that is cleared before the next run or on dispose)\n */\nfunction autorunWithStoreHandleChanges(options, fn) {\n const store = new DisposableStore();\n const disposable = autorunHandleChanges({\n owner: options.owner,\n debugName: options.debugName,\n debugReferenceFn: options.debugReferenceFn ?? fn,\n changeTracker: options.changeTracker,\n }, (reader, changeSummary) => {\n store.clear();\n fn(reader, changeSummary, store);\n });\n return toDisposable(() => {\n disposable.dispose();\n store.dispose();\n });\n}\n/**\n * @see autorun (but with a disposable store that is cleared before the next run or on dispose)\n *\n * @deprecated Use `autorun(reader => { reader.store.add(...) })` instead!\n */\nfunction autorunWithStore(fn) {\n const store = new DisposableStore();\n const disposable = autorunOpts({\n owner: undefined,\n debugName: undefined,\n debugReferenceFn: fn,\n }, reader => {\n store.clear();\n fn(reader, store);\n });\n return toDisposable(() => {\n disposable.dispose();\n store.dispose();\n });\n}\nfunction autorunDelta(observable, handler) {\n let _lastValue;\n return autorunOpts({ debugReferenceFn: handler }, (reader) => {\n const newValue = observable.read(reader);\n const lastValue = _lastValue;\n _lastValue = newValue;\n handler({ lastValue, newValue });\n });\n}\nfunction autorunIterableDelta(getValue, handler, getUniqueIdentifier = v => v) {\n const lastValues = new Map();\n return autorunOpts({ debugReferenceFn: getValue }, (reader) => {\n const newValues = new Map();\n const removedValues = new Map(lastValues);\n for (const value of getValue(reader)) {\n const id = getUniqueIdentifier(value);\n if (lastValues.has(id)) {\n removedValues.delete(id);\n }\n else {\n newValues.set(id, value);\n lastValues.set(id, value);\n }\n }\n for (const id of removedValues.keys()) {\n lastValues.delete(id);\n }\n if (newValues.size || removedValues.size) {\n handler({ addedValues: [...newValues.values()], removedValues: [...removedValues.values()] });\n }\n });\n}\n/**\n * An autorun with a `dispose()` method on its `reader` which cancels the autorun.\n * It it safe to call `dispose()` synchronously.\n */\nfunction autorunSelfDisposable(fn, debugLocation = DebugLocation.ofCaller()) {\n let ar;\n let disposed = false;\n // eslint-disable-next-line prefer-const\n ar = autorun(reader => {\n fn({\n delayedStore: reader.delayedStore,\n store: reader.store,\n readObservable: reader.readObservable.bind(reader),\n dispose: () => {\n ar?.dispose();\n disposed = true;\n }\n });\n }, debugLocation);\n if (disposed) {\n ar.dispose();\n }\n return ar;\n}\n\nexport { autorun, autorunDelta, autorunHandleChanges, autorunIterableDelta, autorunOpts, autorunSelfDisposable, autorunWithStore, autorunWithStoreHandleChanges };\n//# sourceMappingURL=autorun.js.map\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 *--------------------------------------------------------------------------------------------*/\nimport { onUnexpectedError } from './commonFacade/deps.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 *--------------------------------------------------------------------------------------------*/\n/**\n * This function is used to indicate that the caller recovered from an error that indicates a bug.\n*/\nfunction handleBugIndicatingErrorRecovery(message) {\n const err = new Error('BugIndicatingErrorRecovery: ' + message);\n onUnexpectedError(err);\n console.error('recovered from an error that indicates a bug', err);\n}\n\nexport { handleBugIndicatingErrorRecovery };\n//# sourceMappingURL=base.js.map\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 *--------------------------------------------------------------------------------------------*/\nimport { handleBugIndicatingErrorRecovery } from './base.js';\nimport { getFunctionName } from './debugName.js';\nimport { getLogger } 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 *--------------------------------------------------------------------------------------------*/\n/**\n * Starts a transaction in which many observables can be changed at once.\n * {@link fn} should start with a JS Doc using `@description` to give the transaction a debug name.\n * Reaction run on demand or when the transaction ends.\n */\nfunction transaction(fn, getDebugName) {\n const tx = new TransactionImpl(fn, getDebugName);\n try {\n fn(tx);\n }\n finally {\n tx.finish();\n }\n}\nlet _globalTransaction = undefined;\nfunction globalTransaction(fn) {\n if (_globalTransaction) {\n fn(_globalTransaction);\n }\n else {\n const tx = new TransactionImpl(fn, undefined);\n _globalTransaction = tx;\n try {\n fn(tx);\n }\n finally {\n tx.finish(); // During finish, more actions might be added to the transaction.\n // Which is why we only clear the global transaction after finish.\n _globalTransaction = undefined;\n }\n }\n}\n/** @deprecated */\nasync function asyncTransaction(fn, getDebugName) {\n const tx = new TransactionImpl(fn, getDebugName);\n try {\n await fn(tx);\n }\n finally {\n tx.finish();\n }\n}\n/**\n * Allows to chain transactions.\n */\nfunction subtransaction(tx, fn, getDebugName) {\n if (!tx) {\n transaction(fn, getDebugName);\n }\n else {\n fn(tx);\n }\n}\nclass TransactionImpl {\n constructor(_fn, _getDebugName) {\n this._fn = _fn;\n this._getDebugName = _getDebugName;\n this._updatingObservers = [];\n getLogger()?.handleBeginTransaction(this);\n }\n getDebugName() {\n if (this._getDebugName) {\n return this._getDebugName();\n }\n return getFunctionName(this._fn);\n }\n updateObserver(observer, observable) {\n if (!this._updatingObservers) {\n // This happens when a transaction is used in a callback or async function.\n // If an async transaction is used, make sure the promise awaits all users of the transaction (e.g. no race).\n handleBugIndicatingErrorRecovery('Transaction already finished!');\n // Error recovery\n transaction(tx => {\n tx.updateObserver(observer, observable);\n });\n return;\n }\n // When this gets called while finish is active, they will still get considered\n this._updatingObservers.push({ observer, observable });\n observer.beginUpdate(observable);\n }\n finish() {\n const updatingObservers = this._updatingObservers;\n if (!updatingObservers) {\n handleBugIndicatingErrorRecovery('transaction.finish() has already been called!');\n return;\n }\n for (let i = 0; i < updatingObservers.length; i++) {\n const { observer, observable } = updatingObservers[i];\n observer.endUpdate(observable);\n }\n // Prevent anyone from updating observers from now on.\n this._updatingObservers = null;\n getLogger()?.handleEndTransaction(this);\n }\n debugGetUpdatingObservers() {\n return this._updatingObservers;\n }\n}\n\nexport { TransactionImpl, asyncTransaction, globalTransaction, subtransaction, transaction };\n//# sourceMappingURL=transaction.js.map\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 *--------------------------------------------------------------------------------------------*/\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.map\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 *--------------------------------------------------------------------------------------------*/\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","/*---------------------------------------------------------------------------------------------\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 { transaction } from '../transaction.js';\nimport { DebugNameData } from '../debugName.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 observableSignal(debugNameOrOwner, debugLocation = DebugLocation.ofCaller()) {\n if (typeof debugNameOrOwner === 'string') {\n return new ObservableSignal(debugNameOrOwner, undefined, debugLocation);\n }\n else {\n return new ObservableSignal(undefined, debugNameOrOwner, debugLocation);\n }\n}\nclass ObservableSignal extends BaseObservable {\n get debugName() {\n return new DebugNameData(this._owner, this._debugName, undefined).getDebugName(this) ?? 'Observable Signal';\n }\n toString() {\n return this.debugName;\n }\n constructor(_debugName, _owner, debugLocation) {\n super(debugLocation);\n this._debugName = _debugName;\n this._owner = _owner;\n }\n trigger(tx, change) {\n if (!tx) {\n transaction(tx => {\n this.trigger(tx, change);\n }, () => `Trigger signal ${this.debugName}`);\n return;\n }\n for (const o of this._observers) {\n tx.updateObserver(o, this);\n o.handleChange(this, change);\n }\n }\n get() {\n // NO OP\n }\n}\n\nexport { observableSignal };\n//# sourceMappingURL=observableSignal.js.map\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 *--------------------------------------------------------------------------------------------*/\nimport { autorun } from '../reactions/autorun.js';\nimport { transaction } from '../transaction.js';\nimport { observableValue } from '../observables/observableValue.js';\nimport { toDisposable } from '../commonFacade/deps.js';\nimport { derivedOpts, derived } from '../observables/derived.js';\nimport { observableFromEvent } from '../observables/observableFromEvent.js';\nimport { observableSignal } from '../observables/observableSignal.js';\nimport { _setKeepObserved, _setRecomputeInitiallyAndOnChange } from '../observables/baseObservable.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 observableFromPromise(promise) {\n const observable = observableValue('promiseValue', {});\n promise.then((value) => {\n observable.set({ value }, undefined);\n });\n return observable;\n}\nfunction signalFromObservable(owner, observable) {\n return derivedOpts({\n owner,\n equalsFn: () => false,\n }, reader => {\n observable.read(reader);\n });\n}\n/**\n * @deprecated Use `debouncedObservable` instead.\n */\nfunction debouncedObservableDeprecated(observable, debounceMs, disposableStore) {\n const debouncedObservable = observableValue('debounced', undefined);\n let timeout = undefined;\n disposableStore.add(autorun(reader => {\n /** @description debounce */\n const value = observable.read(reader);\n if (timeout) {\n clearTimeout(timeout);\n }\n timeout = setTimeout(() => {\n transaction(tx => {\n debouncedObservable.set(value, tx);\n });\n }, debounceMs);\n }));\n return debouncedObservable;\n}\n/**\n * Creates an observable that debounces the input observable.\n */\nfunction debouncedObservable(observable, debounceMs) {\n let hasValue = false;\n let lastValue;\n let timeout = undefined;\n return observableFromEvent(cb => {\n const d = autorun(reader => {\n const value = observable.read(reader);\n if (!hasValue) {\n hasValue = true;\n lastValue = value;\n }\n else {\n if (timeout) {\n clearTimeout(timeout);\n }\n timeout = setTimeout(() => {\n lastValue = value;\n cb();\n }, debounceMs);\n }\n });\n return {\n dispose() {\n d.dispose();\n hasValue = false;\n lastValue = undefined;\n },\n };\n }, () => {\n if (hasValue) {\n return lastValue;\n }\n else {\n return observable.get();\n }\n });\n}\nfunction wasEventTriggeredRecently(event, timeoutMs, disposableStore) {\n const observable = observableValue('triggeredRecently', false);\n let timeout = undefined;\n disposableStore.add(event(() => {\n observable.set(true, undefined);\n if (timeout) {\n clearTimeout(timeout);\n }\n timeout = setTimeout(() => {\n observable.set(false, undefined);\n }, timeoutMs);\n }));\n return observable;\n}\n/**\n * This makes sure the observable is being observed and keeps its cache alive.\n */\nfunction keepObserved(observable) {\n const o = new KeepAliveObserver(false, undefined);\n observable.addObserver(o);\n return toDisposable(() => {\n observable.removeObserver(o);\n });\n}\n_setKeepObserved(keepObserved);\n/**\n * This converts the given observable into an autorun.\n */\nfunction recomputeInitiallyAndOnChange(observable, handleValue) {\n const o = new KeepAliveObserver(true, handleValue);\n observable.addObserver(o);\n try {\n o.beginUpdate(observable);\n }\n finally {\n o.endUpdate(observable);\n }\n return toDisposable(() => {\n observable.removeObserver(o);\n });\n}\n_setRecomputeInitiallyAndOnChange(recomputeInitiallyAndOnChange);\nclass KeepAliveObserver {\n constructor(_forceRecompute, _handleValue) {\n this._forceRecompute = _forceRecompute;\n this._handleValue = _handleValue;\n this._counter = 0;\n }\n beginUpdate(observable) {\n this._counter++;\n }\n endUpdate(observable) {\n if (this._counter === 1 && this._forceRecompute) {\n if (this._handleValue) {\n this._handleValue(observable.get());\n }\n else {\n observable.reportChanges();\n }\n }\n this._counter--;\n }\n handlePossibleChange(observable) {\n // NO OP\n }\n handleChange(observable, change) {\n // NO OP\n }\n}\nfunction derivedObservableWithCache(owner, computeFn) {\n let lastValue = undefined;\n const observable = derivedOpts({ owner, debugReferenceFn: computeFn }, reader => {\n lastValue = computeFn(reader, lastValue);\n return lastValue;\n });\n return observable;\n}\nfunction derivedObservableWithWritableCache(owner, computeFn) {\n let lastValue = undefined;\n const onChange = observableSignal('derivedObservableWithWritableCache');\n const observable = derived(owner, reader => {\n onChange.read(reader);\n lastValue = computeFn(reader, lastValue);\n return lastValue;\n });\n return Object.assign(observable, {\n clearCache: (tx) => {\n lastValue = undefined;\n onChange.trigger(tx);\n },\n setCache: (newValue, tx) => {\n lastValue = newValue;\n onChange.trigger(tx);\n }\n });\n}\n/**\n * When the items array changes, referential equal items are not mapped again.\n */\nfunction mapObservableArrayCached(owner, items, map, keySelector) {\n let m = new ArrayMap(map, keySelector);\n const self = derivedOpts({\n debugReferenceFn: map,\n owner,\n onLastObserverRemoved: () => {\n m.dispose();\n m = new ArrayMap(map);\n }\n }, (reader) => {\n m.setItems(items.read(reader));\n return m.getItems();\n });\n return self;\n}\nclass ArrayMap {\n constructor(_map, _keySelector) {\n this._map = _map;\n this._keySelector = _keySelector;\n this._cache = new Map();\n this._items = [];\n }\n dispose() {\n this._cache.forEach(entry => entry.store.dispose());\n this._cache.clear();\n }\n setItems(items) {\n const newItems = [];\n const itemsToRemove = new Set(this._cache.keys());\n for (const item of items) {\n const key = this._keySelector ? this._keySelector(item) : item;\n let entry = this._cache.get(key);\n if (!entry) {\n const store = new DisposableStore();\n const out = this._map(item, store);\n entry = { out, store };\n this._cache.set(key, entry);\n }\n else {\n itemsToRemove.delete(key);\n }\n newItems.push(entry.out);\n }\n for (const item of itemsToRemove) {\n const entry = this._cache.get(item);\n entry.store.dispose();\n this._cache.delete(item);\n }\n this._items = newItems;\n }\n getItems() {\n return this._items;\n }\n}\n\nexport { KeepAliveObserver, debouncedObservable, debouncedObservableDeprecated, derivedObservableWithCache, derivedObservableWithWritableCache, keepObserved, mapObservableArrayCached, observableFromPromise, recomputeInitiallyAndOnChange, signalFromObservable, wasEventTriggeredRecently };\n//# sourceMappingURL=utils.js.map\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 *--------------------------------------------------------------------------------------------*/\nimport { addLogger } from './logging.js';\nimport { getClassName } from '../debugName.js';\nimport { Derived } from '../observables/derivedImpl.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 consoleObservableLogger;\nfunction logObservableToConsole(obs) {\n if (!consoleObservableLogger) {\n consoleObservableLogger = new ConsoleObservableLogger();\n addLogger(consoleObservableLogger);\n }\n consoleObservableLogger.addFilteredObj(obs);\n}\nclass ConsoleObservableLogger {\n constructor() {\n this.indentation = 0;\n this.changedObservablesSets = new WeakMap();\n }\n addFilteredObj(obj) {\n if (!this._filteredObjects) {\n this._filteredObjects = new Set();\n }\n this._filteredObjects.add(obj);\n }\n _isIncluded(obj) {\n return this._filteredObjects?.has(obj) ?? true;\n }\n textToConsoleArgs(text) {\n return consoleTextToArgs([\n normalText(repeat('| ', this.indentation)),\n text,\n ]);\n }\n formatInfo(info) {\n if (!info.hadValue) {\n return [\n normalText(` `),\n styled(formatValue(info.newValue, 60), {\n color: 'green',\n }),\n normalText(` (initial)`),\n ];\n }\n return info.didChange\n ? [\n normalText(` `),\n styled(formatValue(info.oldValue, 70), {\n color: 'red',\n strikeThrough: true,\n }),\n normalText(` `),\n styled(formatValue(info.newValue, 60), {\n color: 'green',\n }),\n ]\n : [normalText(` (unchanged)`)];\n }\n handleObservableCreated(observable) {\n if (observable instanceof Derived) {\n const derived = observable;\n this.changedObservablesSets.set(derived, new Set());\n }\n }\n handleOnListenerCountChanged(observable, newCount) {\n }\n handleObservableUpdated(observable, info) {\n if (!this._isIncluded(observable)) {\n return;\n }\n if (observable instanceof Derived) {\n this._handleDerivedRecomputed(observable, info);\n return;\n }\n console.log(...this.textToConsoleArgs([\n formatKind('observable value changed'),\n styled(observable.debugName, { color: 'BlueViolet' }),\n ...this.formatInfo(info),\n ]));\n }\n formatChanges(changes) {\n if (changes.size === 0) {\n return undefined;\n }\n return styled(' (changed deps: ' +\n [...changes].map((o) => o.debugName).join(', ') +\n ')', { color: 'gray' });\n }\n handleDerivedDependencyChanged(derived, observable, change) {\n if (!this._isIncluded(derived)) {\n return;\n }\n this.changedObservablesSets.get(derived)?.add(observable);\n }\n _handleDerivedRecomputed(derived, info) {\n if (!this._isIncluded(derived)) {\n return;\n }\n const changedObservables = this.changedObservablesSets.get(derived);\n if (!changedObservables) {\n return;\n }\n console.log(...this.textToConsoleArgs([\n formatKind('derived recomputed'),\n styled(derived.debugName, { color: 'BlueViolet' }),\n ...this.formatInfo(info),\n this.formatChanges(changedObservables),\n { data: [{ fn: derived._debugNameData.referenceFn ?? derived._computeFn }] }\n ]));\n changedObservables.clear();\n }\n handleDerivedCleared(derived) {\n if (!this._isIncluded(derived)) {\n return;\n }\n console.log(...this.textToConsoleArgs([\n formatKind('derived cleared'),\n styled(derived.debugName, { color: 'BlueViolet' }),\n ]));\n }\n handleFromEventObservableTriggered(observable, info) {\n if (!this._isIncluded(observable)) {\n return;\n }\n console.log(...this.textToConsoleArgs([\n formatKind('observable from event triggered'),\n styled(observable.debugName, { color: 'BlueViolet' }),\n ...this.formatInfo(info),\n { data: [{ fn: observable._getValue }] }\n ]));\n }\n handleAutorunCreated(autorun) {\n if (!this._isIncluded(autorun)) {\n return;\n }\n this.changedObservablesSets.set(autorun, new Set());\n }\n handleAutorunDisposed(autorun) {\n }\n handleAutorunDependencyChanged(autorun, observable, change) {\n if (!this._isIncluded(autorun)) {\n return;\n }\n this.changedObservablesSets.get(autorun).add(observable);\n }\n handleAutorunStarted(autorun) {\n const changedObservables = this.changedObservablesSets.get(autorun);\n if (!changedObservables) {\n return;\n }\n if (this._isIncluded(autorun)) {\n console.log(...this.textToConsoleArgs([\n formatKind('autorun'),\n styled(autorun.debugName, { color: 'BlueViolet' }),\n this.formatChanges(changedObservables),\n { data: [{ fn: autorun._debugNameData.referenceFn ?? autorun._runFn }] }\n ]));\n }\n changedObservables.clear();\n this.indentation++;\n }\n handleAutorunFinished(autorun) {\n this.indentation--;\n }\n handleBeginTransaction(transaction) {\n let transactionName = transaction.getDebugName();\n if (transactionName === undefined) {\n transactionName = '';\n }\n if (this._isIncluded(transaction)) {\n console.log(...this.textToConsoleArgs([\n formatKind('transaction'),\n styled(transactionName, { color: 'BlueViolet' }),\n { data: [{ fn: transaction._fn }] }\n ]));\n }\n this.indentation++;\n }\n handleEndTransaction() {\n this.indentation--;\n }\n}\nfunction consoleTextToArgs(text) {\n const styles = new Array();\n const data = [];\n let firstArg = '';\n function process(t) {\n if ('length' in t) {\n for (const item of t) {\n if (item) {\n process(item);\n }\n }\n }\n else if ('text' in t) {\n firstArg += `%c${t.text}`;\n styles.push(t.style);\n if (t.data) {\n data.push(...t.data);\n }\n }\n else if ('data' in t) {\n data.push(...t.data);\n }\n }\n process(text);\n const result = [firstArg, ...styles];\n result.push(...data);\n return result;\n}\nfunction normalText(text) {\n return styled(text, { color: 'black' });\n}\nfunction formatKind(kind) {\n return styled(padStr(`${kind}: `, 10), { color: 'black', bold: true });\n}\nfunction styled(text, options = {\n color: 'black',\n}) {\n function objToCss(styleObj) {\n return Object.entries(styleObj).reduce((styleString, [propName, propValue]) => {\n return `${styleString}${propName}:${propValue};`;\n }, '');\n }\n const style = {\n color: options.color,\n };\n if (options.strikeThrough) {\n style['text-decoration'] = 'line-through';\n }\n if (options.bold) {\n style['font-weight'] = 'bold';\n }\n return {\n text,\n style: objToCss(style),\n };\n}\nfunction formatValue(value, availableLen) {\n try {\n return formatValueUnsafe(value, availableLen);\n }\n catch {\n // Value could not be formatted (e.g., a Proxy that throws on coercion)\n return '[[???]]';\n }\n}\nfunction formatValueUnsafe(value, availableLen) {\n switch (typeof value) {\n case 'number':\n return '' + value;\n case 'string':\n if (value.length + 2 <= availableLen) {\n return `\"${value}\"`;\n }\n return `\"${value.substr(0, availableLen - 7)}\"+...`;\n case 'boolean':\n return value ? 'true' : 'false';\n case 'undefined':\n return 'undefined';\n case 'object':\n if (value === null) {\n return 'null';\n }\n if (Array.isArray(value)) {\n return formatArray(value, availableLen);\n }\n return formatObject(value, availableLen);\n case 'symbol':\n return value.toString();\n case 'function':\n return `[[Function${value.name ? ' ' + value.name : ''}]]`;\n default:\n return '' + value;\n }\n}\nfunction formatArray(value, availableLen) {\n let result = '[ ';\n let first = true;\n for (const val of value) {\n if (!first) {\n result += ', ';\n }\n if (result.length - 5 > availableLen) {\n result += '...';\n break;\n }\n first = false;\n result += `${formatValue(val, availableLen - result.length)}`;\n }\n result += ' ]';\n return result;\n}\nfunction formatObject(value, availableLen) {\n // Avoid drilling into Proxies - wrap operations that could trigger traps\n try {\n if (typeof value.toString === 'function' && value.toString !== Object.prototype.toString) {\n const val = value.toString();\n if (val.length <= availableLen) {\n return val;\n }\n return val.substring(0, availableLen - 3) + '...';\n }\n }\n catch {\n // toString triggered a Proxy trap or threw - bail out\n return '[[Object]]';\n }\n const className = getClassName(value);\n let result = className ? className + '(' : '{ ';\n let first = true;\n let entries;\n try {\n entries = Object.entries(value);\n }\n catch {\n // Object.entries triggered a Proxy trap - bail out\n return className ? `${className}(...)` : '[[Object]]';\n }\n for (const [key, val] of entries) {\n if (!first) {\n result += ', ';\n }\n if (result.length - 5 > availableLen) {\n result += '...';\n break;\n }\n first = false;\n result += `${key}: ${formatValue(val, availableLen - result.length)}`;\n }\n result += className ? ')' : ' }';\n return result;\n}\nfunction repeat(str, count) {\n let result = '';\n for (let i = 1; i <= count; i++) {\n result += str;\n }\n return result;\n}\nfunction padStr(str, length) {\n while (str.length < length) {\n str += ' ';\n }\n return str;\n}\n\nexport { ConsoleObservableLogger, formatValue, logObservableToConsole };\n//# sourceMappingURL=consoleObservableLogger.js.map\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 *--------------------------------------------------------------------------------------------*/\nimport { Derived } from '../observables/derivedImpl.js';\nimport { FromEventObservable } from '../observables/observableFromEvent.js';\nimport { ObservableValue } from '../observables/observableValue.js';\nimport { AutorunObserver } from '../reactions/autorunImpl.js';\nimport { formatValue } from './consoleObservableLogger.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 debugGetDependencyGraph(obs, options) {\n const debugNamePostProcessor = options?.debugNamePostProcessor ?? ((str) => str);\n const info = Info.from(obs, debugNamePostProcessor);\n if (!info) {\n return '';\n }\n const alreadyListed = new Set();\n return formatObservableInfo(info, 0, alreadyListed).trim();\n}\nfunction formatObservableInfo(info, indentLevel, alreadyListed) {\n const indent = '\\t\\t'.repeat(indentLevel);\n const lines = [];\n const isAlreadyListed = alreadyListed.has(info.sourceObj);\n if (isAlreadyListed) {\n lines.push(`${indent}* ${info.type} ${info.name} (already listed)`);\n return lines.join('\\n');\n }\n alreadyListed.add(info.sourceObj);\n lines.push(`${indent}* ${info.type} ${info.name}:`);\n lines.push(`${indent} value: ${formatValue(info.value, 50)}`);\n lines.push(`${indent} state: ${info.state}`);\n if (info.dependencies.length > 0) {\n lines.push(`${indent} dependencies:`);\n for (const dep of info.dependencies) {\n lines.push(formatObservableInfo(dep, indentLevel + 1, alreadyListed));\n }\n }\n return lines.join('\\n');\n}\nclass Info {\n static from(obs, debugNamePostProcessor) {\n if (obs instanceof AutorunObserver) {\n const state = obs.debugGetState();\n return new Info(obs, debugNamePostProcessor(obs.debugName), 'autorun', undefined, state.stateStr, Array.from(state.dependencies).map(dep => Info.from(dep, debugNamePostProcessor) || Info.unknown(dep)));\n }\n else if (obs instanceof Derived) {\n const state = obs.debugGetState();\n return new Info(obs, debugNamePostProcessor(obs.debugName), 'derived', state.value, state.stateStr, Array.from(state.dependencies).map(dep => Info.from(dep, debugNamePostProcessor) || Info.unknown(dep)));\n }\n else if (obs instanceof ObservableValue) {\n const state = obs.debugGetState();\n return new Info(obs, debugNamePostProcessor(obs.debugName), 'observableValue', state.value, 'upToDate', []);\n }\n else if (obs instanceof FromEventObservable) {\n const state = obs.debugGetState();\n return new Info(obs, debugNamePostProcessor(obs.debugName), 'fromEvent', state.value, state.hasValue ? 'upToDate' : 'initial', []);\n }\n return undefined;\n }\n static unknown(obs) {\n return new Info(obs, '(unknown)', 'unknown', undefined, 'unknown', []);\n }\n constructor(sourceObj, name, type, value, state, dependencies) {\n this.sourceObj = sourceObj;\n this.name = name;\n this.type = type;\n this.value = value;\n this.state = state;\n this.dependencies = dependencies;\n }\n}\n\nexport { debugGetDependencyGraph };\n//# sourceMappingURL=debugGetDependencyGraph.js.map\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 *--------------------------------------------------------------------------------------------*/\nimport { setLogObservableFn } from './logging/logging.js';\nimport { _setDebugGetDependencyGraph } from './observables/baseObservable.js';\nexport { DebugLocation } from './debugLocation.js';\nexport { derived, derivedDisposable, derivedHandleChanges, derivedOpts, derivedWithSetter, derivedWithStore } from './observables/derived.js';\nexport { debouncedObservable, debouncedObservableDeprecated, derivedObservableWithCache, derivedObservableWithWritableCache, keepObserved, mapObservableArrayCached, observableFromPromise, recomputeInitiallyAndOnChange, signalFromObservable, wasEventTriggeredRecently } from './utils/utils.js';\nexport { observableFromEvent, observableFromEventOpts } from './observables/observableFromEvent.js';\nimport { logObservableToConsole } from './logging/consoleObservableLogger.js';\nimport { debugGetDependencyGraph } from './logging/debugGetDependencyGraph.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 *--------------------------------------------------------------------------------------------*/\n// This is a facade for the observable implementation. Only import from here!\n_setDebugGetDependencyGraph(debugGetDependencyGraph);\nsetLogObservableFn(logObservableToConsole);\n//# sourceMappingURL=index.js.map\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 *--------------------------------------------------------------------------------------------*/\nclass CancellationError extends Error {\n constructor(message = 'Operation was cancelled') {\n super(message);\n this.name = 'CancellationError';\n }\n}\nclass CancellationTokenSource {\n constructor() {\n this._isCancelled = false;\n this._listeners = new Set();\n }\n get token() {\n return {\n isCancellationRequested: this._isCancelled,\n onCancellationRequested: (listener) => {\n this._listeners.add(listener);\n if (this._isCancelled) {\n listener();\n }\n return {\n dispose: () => {\n this._listeners.delete(listener);\n }\n };\n }\n };\n }\n cancel() {\n if (!this._isCancelled) {\n this._isCancelled = true;\n for (const listener of this._listeners) {\n listener();\n }\n }\n }\n dispose() {\n this.cancel();\n this._listeners.clear();\n }\n}\n/**\n * Creates a CancellationToken that is cancelled when the given disposable is disposed.\n */\nfunction cancelOnDispose(disposable) {\n const source = new CancellationTokenSource();\n disposable.add(source);\n return source.token;\n}\n\nexport { CancellationError, CancellationTokenSource, cancelOnDispose };\n//# sourceMappingURL=cancellation.js.map\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 *--------------------------------------------------------------------------------------------*/\nimport { cancelOnDispose } from '../commonFacade/cancellation.js';\nimport { DisposableStore } from '../../disposables.js';\nimport { autorunWithStoreHandleChanges } from '../reactions/autorun.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 runOnChange(observable, cb) {\n let _previousValue;\n let _firstRun = true;\n return autorunWithStoreHandleChanges({\n changeTracker: {\n createChangeSummary: () => ({ deltas: [], didChange: false }),\n handleChange: (context, changeSummary) => {\n if (context.didChange(observable)) {\n const e = context.change;\n if (e !== undefined) {\n changeSummary.deltas.push(e);\n }\n changeSummary.didChange = true;\n }\n return true;\n },\n }\n }, (reader, changeSummary) => {\n const value = observable.read(reader);\n const previousValue = _previousValue;\n if (changeSummary.didChange) {\n _previousValue = value;\n // didChange can never be true on the first autorun, so we know previousValue is defined\n cb(value, previousValue, changeSummary.deltas);\n }\n if (_firstRun) {\n _firstRun = false;\n _previousValue = value;\n }\n });\n}\nfunction runOnChangeWithStore(observable, cb) {\n const store = new DisposableStore();\n const disposable = runOnChange(observable, (value, previousValue, deltas) => {\n store.clear();\n cb(value, previousValue, deltas, store);\n });\n return {\n dispose() {\n disposable.dispose();\n store.dispose();\n }\n };\n}\nfunction runOnChangeWithCancellationToken(observable, cb) {\n return runOnChangeWithStore(observable, (value, previousValue, deltas, store) => {\n cb(value, previousValue, deltas, cancelOnDispose(store));\n });\n}\n\nexport { runOnChange, runOnChangeWithCancellationToken, runOnChangeWithStore };\n//# sourceMappingURL=runOnChange.js.map\n"],"names":["globalObservableLogger","addLogger","logger","ComposedLogger","getLogger","globalObservableLoggerFn","setLogObservableFn","fn","logObservable","obs","loggers","observable","location","newCount","info","autorun","change","derived","transaction","DebugLocation","enabled","enable","ofCaller","ofNthCaller","n","Err","l","stack","DebugLocationImpl","parentIdx","lines","parseLine","fileName","line","column","id","stackLine","match","match2","DebugNameData","owner","debugNameSource","referenceFn","target","getDebugName","countPerName","cachedDebugName","data","cached","dbgName","computeDebugName","count","result","self","ownerStr","formatOwner","getFunctionName","key","findKey","obj","value","countPerClassName","ownerId","className","getClassName","ctor","fnSrc","_derived","_setDerivedOpts","_recomputeInitiallyAndOnChange","_setRecomputeInitiallyAndOnChange","recomputeInitiallyAndOnChange","_keepObserved","_setKeepObserved","keepObserved","_debugGetDependencyGraph","_setDebugGetDependencyGraph","debugGetDependencyGraph","ConvenientObservable","reader","fnOrOwner","fnOrUndefined","debugLocation","name","store","handleValue","BaseObservable","observer","len","deleted","hadLogger","toDisposable","BugIndicatingError","message","onBugIndicatingError","error","onUnexpectedError","strictEquals","a","b","DisposableStore","disposable","index","Disposable","t","derivedStateToString","state","Derived","_debugNameData","_computeFn","_changeTracker","_handleLastObserverRemoved","_equalityComparator","d","changeSummary","didChange","emptySet","hadValue","oldValue","delayedStore","o","e","r","_observable","propagateBeginUpdate","observers","shouldReact","wasUpToDate","shouldCallBeginUpdate","newValue","tx","DerivedWithSetter","debugNameData","computeFn","changeTracker","handleLastObserverRemoved","equalityComparator","set","computeFnOrOwner","derivedWithSetter","setter","derivedOpts","options","derivedHandleChanges","derivedWithStore","computeFnOrUndefined","derivedDisposable","autorunStateToString","AutorunObserver","_runFn","autorunOpts","autorunHandleChanges","autorunWithStoreHandleChanges","autorunWithStore","autorunDelta","handler","_lastValue","lastValue","autorunIterableDelta","getValue","getUniqueIdentifier","v","lastValues","newValues","removedValues","autorunSelfDisposable","ar","disposed","handleBugIndicatingErrorRecovery","err","TransactionImpl","_globalTransaction","globalTransaction","asyncTransaction","subtransaction","_fn","_getDebugName","updatingObservers","i","observableValue","nameOrOwner","initialValue","ObservableValue","_tx","disposableObservableValue","DisposableObservableValue","observableFromEvent","args","event","FromEventObservable","observableFromEventOpts","_getValue","_getTransaction","didRunTransaction","batchEventsGlobally","didSet","observableSignal","debugNameOrOwner","ObservableSignal","_debugName","_owner","observableFromPromise","promise","signalFromObservable","debouncedObservableDeprecated","debounceMs","disposableStore","debouncedObservable","timeout","hasValue","cb","wasEventTriggeredRecently","timeoutMs","KeepAliveObserver","_forceRecompute","_handleValue","derivedObservableWithCache","derivedObservableWithWritableCache","onChange","mapObservableArrayCached","items","map","keySelector","m","ArrayMap","_map","_keySelector","entry","newItems","itemsToRemove","item","consoleObservableLogger","logObservableToConsole","ConsoleObservableLogger","text","consoleTextToArgs","normalText","repeat","styled","formatValue","formatKind","changes","changedObservables","transactionName","styles","firstArg","process","kind","padStr","objToCss","styleObj","styleString","propName","propValue","style","availableLen","formatValueUnsafe","formatArray","formatObject","first","val","entries","str","length","debugNamePostProcessor","Info","formatObservableInfo","indentLevel","alreadyListed","indent","dep","sourceObj","type","dependencies","CancellationError","CancellationTokenSource","listener","cancelOnDispose","source","runOnChange","_previousValue","_firstRun","context","previousValue","runOnChangeWithStore","deltas","runOnChangeWithCancellationToken"],"mappings":"AAQA,IAAIA;AACJ,SAASC,GAAUC,GAAQ;AACvB,EAAKF,IAGIA,aAAkCG,IACvCH,EAAuB,QAAQ,KAAKE,CAAM,IAG1CF,IAAyB,IAAIG,EAAe,CAACH,GAAwBE,CAAM,CAAC,IAN5EF,IAAyBE;AAQjC;AACA,SAASE,IAAY;AACjB,SAAOJ;AACX;AACA,IAAIK;AACJ,SAASC,GAAmBC,GAAI;AAC5B,EAAAF,IAA2BE;AAC/B;AACA,SAASC,GAAcC,GAAK;AACxB,EAAIJ,KACAA,EAAyBI,CAAG;AAEpC;AACA,MAAMN,EAAe;AAAA,EACjB,YAAYO,GAAS;AACjB,SAAK,UAAUA;AAAA,EACnB;AAAA,EACA,wBAAwBC,GAAYC,GAAU;AAC1C,eAAWV,KAAU,KAAK;AACtB,MAAAA,EAAO,wBAAwBS,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,MACX;AAAA,IACZ;AAAA,EACA,GAAO,CAACnC,GAAQmC,MAAkB;AAC1B,UAAMtD,IAAQjD,EAAW,KAAKoE,CAAM,GAC9B4M,IAAgBH;AACtB,IAAItK,EAAc,cACdsK,IAAiB5N,GAEjBsJ,EAAGtJ,GAAO+N,GAAezK,EAAc,MAAM,IAE7CuK,MACAA,IAAY,IACZD,IAAiB5N;AAAA,EAEzB,CAAC;AACL;AACA,SAASgO,GAAqBjR,GAAYuM,GAAI;AAC1C,QAAM9H,IAAQ,IAAIgB,EAAe,GAC3BC,IAAakL,GAAY5Q,GAAY,CAACiD,GAAO+N,GAAeE,MAAW;AACzE,IAAAzM,EAAM,MAAK,GACX8H,EAAGtJ,GAAO+N,GAAeE,GAAQzM,CAAK;AAAA,EAC1C,CAAC;AACD,SAAO;AAAA,IACH,UAAU;AACN,MAAAiB,EAAW,QAAO,GAClBjB,EAAM,QAAO;AAAA,IACjB;AAAA,EACR;AACA;AACA,SAAS0M,GAAiCnR,GAAYuM,GAAI;AACtD,SAAO0E,GAAqBjR,GAAY,CAACiD,GAAO+N,GAAeE,GAAQzM,MAAU;AAC7E,IAAA8H,EAAGtJ,GAAO+N,GAAeE,GAAQR,GAAgBjM,CAAK,CAAC;AAAA,EAC3D,CAAC;AACL;"}
@@ -0,0 +1,16 @@
1
+ import { OffsetRange } from '../core/offsetRange.js';
2
+ import { StringEdit } from '../core/stringEdit.js';
3
+ /**
4
+ * Seeded RNG for deterministic fuzz tests. A small port of the `Random` helper
5
+ * used by VS Code's editor tests (`src/vs/editor/test/common/core/random.ts`),
6
+ * backed by a Mersenne Twister so a given seed always replays the same run.
7
+ */
8
+ export declare abstract class Random {
9
+ static readonly basicAlphabetMultiline = " \n\nabcdefghijklmnopqrstuvwxyz0123456789";
10
+ static create(seed: number): Random;
11
+ abstract nextIntRange(start: number, endExclusive: number): number;
12
+ nextString(length: number, alphabet?: string): string;
13
+ nextMultiLineString(lineCount: number, lineLength: OffsetRange, alphabet?: string): string;
14
+ /** A single random replacement over `target` (insert, delete or replace). */
15
+ nextSingleStringEdit(target: string, newTextAlphabet?: string): StringEdit;
16
+ }
@@ -0,0 +1,179 @@
1
+ import { BlockAstNode, ListItemAstNode } from '../../parser/ast.js';
2
+ import { AnyViewData, CodeBlockViewData } from '../viewData.js';
3
+ import { ISyntaxHighlighter } from '../../highlighter/syntaxHighlighter.js';
4
+ import { ViewNode } from './viewNode.js';
5
+ export interface BlockViewOptions {
6
+ readonly renderCustomCodeBlock?: (language: string, content: string) => HTMLElement | undefined;
7
+ readonly onToggleCheckbox?: (item: ListItemAstNode, newChecked: boolean) => void;
8
+ /**
9
+ * Opens a link's URL. Called when the user activates a link: a plain click
10
+ * while the link's block is inactive (rendered), or a Ctrl/Cmd+click while it
11
+ * is active (source shown). Defaults to `window.open(url, '_blank')`.
12
+ */
13
+ readonly onOpenLink?: (url: string, event: MouseEvent) => void;
14
+ /**
15
+ * Colours fenced code blocks. When set, a code block's content is rendered
16
+ * as a sequence of token spans instead of one plain text node. This is the
17
+ * non-incremental path: the snapshot is read once at render time.
18
+ */
19
+ readonly syntaxHighlighter?: ISyntaxHighlighter;
20
+ /**
21
+ * Pluggable renderer for the *inactive* (rendered) form of a math node —
22
+ * both `$$…$$` blocks and inline `$…$`. When set and it returns a result,
23
+ * its {@link MathRendering.dom} replaces the default opaque `katex.render`
24
+ * output, and its {@link MathRendering.segments} let parts of the rendered
25
+ * math (e.g. individual identifier glyphs) map back to source ranges so the
26
+ * caret can land inside them. Returning `undefined` falls back to the
27
+ * default whole-node KaTeX leaf. The active (source) form is unaffected.
28
+ *
29
+ * This is the seam used to explore in-place editing of rendered math (see
30
+ * `katexEditableIdentifiers.ts`).
31
+ */
32
+ readonly renderMath?: (request: MathRenderRequest) => MathRendering | undefined;
33
+ }
34
+ /** Input to a {@link BlockViewOptions.renderMath} renderer. */
35
+ export interface MathRenderRequest {
36
+ /** The LaTeX source of the math content (without the `$$`/`$` fences). */
37
+ readonly latex: string;
38
+ /** `true` for a `$$…$$` block, `false` for inline `$…$`. */
39
+ readonly displayMode: boolean;
40
+ /** CSS class the host element must carry (editor styling/measurement hooks). */
41
+ readonly className: string;
42
+ /** Full source length of the math node (fences/`$` included). */
43
+ readonly nodeLength: number;
44
+ /** Offset of {@link latex} within the node (i.e. after the opening fence/`$`). */
45
+ readonly contentStart: number;
46
+ }
47
+ /**
48
+ * A span of the rendered math output that maps to a slice of source. The
49
+ * renderer reports these for the parts it can map (e.g. identifier glyphs);
50
+ * the editor tiles the gaps between them so the whole math node stays mapped.
51
+ */
52
+ export interface MathSourceSegment {
53
+ /** A DOM node (ideally a Text node) within the rendered output. */
54
+ readonly dom: globalThis.Node;
55
+ /** Start offset of the mapped slice, relative to the math node's start. */
56
+ readonly start: number;
57
+ /** Source length of the mapped slice. */
58
+ readonly length: number;
59
+ }
60
+ /** Result of a {@link BlockViewOptions.renderMath} renderer. */
61
+ export interface MathRendering {
62
+ /** Host element to mount (the rendered math output). */
63
+ readonly dom: HTMLElement;
64
+ /** Source-mapped spans within {@link dom} (need not tile the whole node). */
65
+ readonly segments: readonly MathSourceSegment[];
66
+ }
67
+ /**
68
+ * Base view node for everything the editor renders, generic over the
69
+ * {@link AnyViewData view-data} it renders so subclasses get a precisely-typed
70
+ * {@link data} (e.g. `BlockViewNode<HeadingViewData>`). Every view-data kind has
71
+ * a subclass whose constructor builds the node's DOM and, recursively,
72
+ * constructs its child view nodes — so *constructing a node is rendering it*.
73
+ * There is no separate render pass: the view tree is the result of construction,
74
+ * and {@link createViewNode} is the single entry point that turns a `ViewData`
75
+ * into a node (reusing a `previous` node untouched when it still matches).
76
+ *
77
+ * The name is historical — it is the base for inline and leaf nodes too — but
78
+ * top-level blocks are always instances of it, and {@link element}/{@link block}
79
+ * are the conveniences {@link EditorView} uses for those.
80
+ */
81
+ export declare class BlockViewNode<T extends AnyViewData = AnyViewData> extends ViewNode {
82
+ readonly data: T;
83
+ constructor(data: T, dom: globalThis.Node, children: readonly ViewNode[]);
84
+ get block(): BlockAstNode;
85
+ get element(): HTMLElement;
86
+ /**
87
+ * Whether this already-built node can stand in for `data` unchanged. The
88
+ * builder preserves view-data identity for any subtree whose ast and
89
+ * selection-derived flags are unchanged (see `buildDocumentViewData`), so a
90
+ * single identity check captures "nothing in my subtree changed" — and its
91
+ * whole subtree, and any session it owns, are kept as-is.
92
+ */
93
+ canReuse(data: AnyViewData): boolean;
94
+ /**
95
+ * Called by the view after this block is mounted and measured, with the
96
+ * block's rendered height in px. The default is a no-op; subclasses whose
97
+ * active/inactive renderings have different intrinsic heights (e.g. a math
98
+ * block) override this to remember a height to reserve across the toggle.
99
+ */
100
+ recordMeasuredHeight(_height: number): void;
101
+ }
102
+ /**
103
+ * Turn a {@link AnyViewData view-data} node into its view node, reusing
104
+ * `previous` when it still renders the very same view-data object (see
105
+ * {@link BlockViewNode.canReuse}). Otherwise the matching subclass is
106
+ * constructed, which renders it and recursively constructs its children —
107
+ * threading `previous` down so an edited node can adopt its predecessor's DOM
108
+ * (and, for an edited {@link CodeBlockAstNode}, the highlighting session of the
109
+ * node it was derived from).
110
+ *
111
+ * On a rebuild `previous` is the view node {@link pairNodes} paired by stable id:
112
+ * identity-matched nodes (same view-data) short-circuit above, an edited node is
113
+ * paired with the node carrying its previous id, and any previous node whose id
114
+ * is gone is dropped (disposed by its container's reconcile) so its replacement
115
+ * is built with `previous === undefined`.
116
+ */
117
+ export declare function createViewNode(data: AnyViewData, options: BlockViewOptions | undefined, previous?: ViewNode): ViewNode;
118
+ /**
119
+ * Build the view children for `childData` and patch `parentDom`'s child DOM in
120
+ * place to match, in one step. Each new child-data is paired with the previous
121
+ * view child that should render it ({@link pairNodes}) — by stable node id, which
122
+ * covers both unchanged subtrees and edited nodes — so DOM and session adoption
123
+ * carry over; the
124
+ * `build` callback turns `(childData, prev)` into its view node (usually via
125
+ * {@link createViewNode}). Previous children left unpaired are disposed, then
126
+ * {@link _patchDomChildren} reorders/inserts/removes `parentDom`'s children so
127
+ * the DOM matches the new view nodes — moving reused child DOM into place
128
+ * rather than re-creating it. The returned array mirrors `childData` 1:1,
129
+ * preserving the source ↔ DOM mapping invariant.
130
+ */
131
+ export declare function reconcileDomChildren(parentDom: globalThis.Node, childData: readonly AnyViewData[], previousChildren: readonly ViewNode[] | undefined, build: (childData: AnyViewData, prev: ViewNode | undefined) => ViewNode): ViewNode[];
132
+ /**
133
+ * Like {@link _patchDomChildren} but over raw mount nodes, so a caller can mount
134
+ * a mix of view-node DOM and synthetic wrappers (e.g. a list item's gutter
135
+ * span) in place without detaching the nodes that stay put.
136
+ */
137
+ export declare function _patchDomNodes(parent: globalThis.Node, nodes: readonly globalThis.Node[]): void;
138
+ /**
139
+ * A fenced code block. It owns its incremental
140
+ * {@link ISyntaxHighlighterDocument} session: constructing the node creates (or
141
+ * adopts from `previous`) the session, and disposing the node disposes it, so
142
+ * colouring stays incremental across edits — the session is reused and
143
+ * `update`d rather than rebuilt. A node at any depth owns a session; the only
144
+ * difference today is that the parser links `getDiff` for top-level code blocks
145
+ * only, so a nested block currently builds a fresh session on each rebuild.
146
+ */
147
+ export declare class CodeBlockViewNode extends BlockViewNode<CodeBlockViewData> {
148
+ private _session;
149
+ /**
150
+ * Subscription that re-tokenises the rendered `<code>` in place whenever the
151
+ * session advances its {@link ISyntaxHighlighterDocument.snapshot} *without*
152
+ * a source edit (an async grammar finishing, a live recolour). It is tied to
153
+ * this node's lifetime, but like {@link _session} it must be disposed
154
+ * manually: a node reused as `previous` for a rebuild is never `dispose`d
155
+ * (see {@link reconcileDomChildren}), so the rebuilding constructor disposes
156
+ * its predecessor's subscription explicitly.
157
+ */
158
+ private _snapshotSub;
159
+ constructor(data: CodeBlockViewData, options: BlockViewOptions | undefined, previous: ViewNode | undefined);
160
+ dispose(): void;
161
+ }
162
+ /**
163
+ * Pair each new node with the previous view node that should render it, then
164
+ * report the previous nodes left over. Pairing is by {@link AstNode.id} — the
165
+ * stable identity the parser mints on construction and carries across edits (see
166
+ * `reconcile`). One key covers both reuse cases uniformly: an unchanged subtree
167
+ * keeps its node object (so, trivially, its id), and an edited node — e.g. a
168
+ * code block whose content changed — is rebuilt as a fresh object cloned with
169
+ * its previous id. So the previous view node (which owns any DOM and, for a code
170
+ * block, the highlighting session) is paired with the new view-data derived from
171
+ * it, and that DOM/session is adopted rather than rebuilt.
172
+ *
173
+ * Previous nodes whose id no longer appears are returned in `unused`; the caller
174
+ * disposes them (freeing any session they still own).
175
+ */
176
+ export declare function pairNodes(newData: readonly AnyViewData[], prevNodes: readonly ViewNode[]): {
177
+ paired: Map<AnyViewData, ViewNode>;
178
+ unused: ViewNode[];
179
+ };
@@ -0,0 +1,41 @@
1
+ import { DocumentViewData } from '../viewData.js';
2
+ import { BlockViewNode, BlockViewOptions } from './blockView.js';
3
+ import { ViewNode } from './viewNode.js';
4
+ /** A mounted block: its view node paired with where it starts in the source. */
5
+ export interface DocumentBlock {
6
+ readonly node: BlockViewNode;
7
+ readonly absoluteStart: number;
8
+ }
9
+ /**
10
+ * Immutable view of the document's block sequence — the document-level
11
+ * analogue of {@link BlockViewNode}. Each {@link create} maps the
12
+ * {@link DocumentViewData} (the AST overlaid with selection-derived flags) to
13
+ * the block sequence, reusing the previous node's blocks by view-data identity,
14
+ * rebuilding only what changed, and patching its {@link contentDomNode}'s
15
+ * children to match.
16
+ *
17
+ * Like a {@link BlockViewNode}, it owns its DOM: the first `create` allocates
18
+ * the content element, and every later `create` keeps the previous node's
19
+ * element rather than making a new one. The element is therefore stable
20
+ * across rebuilds:
21
+ *
22
+ * create(viewData, …, old).contentDomNode === old.contentDomNode
23
+ *
24
+ * so a parent can mount it once and never re-parent it.
25
+ *
26
+ * Because it is rebuilt rather than mutated, {@link EditorView} can hold the
27
+ * whole block cache as one value and simply swap it each frame, instead of
28
+ * carrying a mutable entry array and the reconcile bookkeeping itself.
29
+ *
30
+ * It is itself a {@link ViewNode} (the root of the view-node tree), so DOM ↔
31
+ * source mapping such as {@link ViewNode.resolveSource} is inherited: a hit on
32
+ * any descendant lifts up the parent chain to here, yielding an absolute
33
+ * document offset.
34
+ */
35
+ export declare class DocumentViewNode extends ViewNode {
36
+ readonly blocks: readonly DocumentBlock[];
37
+ static create(viewData: DocumentViewData, options: BlockViewOptions | undefined, previous: DocumentViewNode | undefined): DocumentViewNode;
38
+ private constructor();
39
+ /** The stable content element this document mounts its children into. */
40
+ get contentDomNode(): HTMLElement;
41
+ }