@codingame/monaco-vscode-api 38.0.5 → 38.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +9 -9
- package/services.js +3 -3
- package/vscode/src/vs/base/common/hotReload.js +96 -0
- package/vscode/src/vs/base/common/hotReloadHelpers.js +36 -2
- package/vscode/src/vs/editor/browser/widget/diffEditor/diffEditorViewModel.js +7 -12
- package/vscode/src/vs/editor/browser/widget/diffEditor/diffEditorWidget.js +8 -8
- package/vscode/src/vs/editor/browser/widget/multiDiffEditor/multiDiffEditorWidget.js +3 -2
- package/vscode/src/vs/platform/domWidget/browser/domWidget.js +57 -6
- package/vscode/src/vs/platform/observable/common/wrapInHotClass.js +29 -2
- package/vscode/src/vs/platform/observable/common/wrapInReloadableClass.js +44 -3
- package/vscode/src/vs/platform/product/common/product.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-api",
|
|
3
|
-
"version": "38.0.
|
|
3
|
+
"version": "38.0.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "VSCode public API plugged on the monaco editor",
|
|
6
6
|
"keywords": [],
|
|
@@ -15,16 +15,16 @@
|
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@codingame/monaco-vscode-base-service-override": "38.0.
|
|
19
|
-
"@codingame/monaco-vscode-environment-service-override": "38.0.
|
|
20
|
-
"@codingame/monaco-vscode-extensions-service-override": "38.0.
|
|
21
|
-
"@codingame/monaco-vscode-files-service-override": "38.0.
|
|
22
|
-
"@codingame/monaco-vscode-host-service-override": "38.0.
|
|
23
|
-
"@codingame/monaco-vscode-layout-service-override": "38.0.
|
|
24
|
-
"@codingame/monaco-vscode-quickaccess-service-override": "38.0.
|
|
18
|
+
"@codingame/monaco-vscode-base-service-override": "38.0.7",
|
|
19
|
+
"@codingame/monaco-vscode-environment-service-override": "38.0.7",
|
|
20
|
+
"@codingame/monaco-vscode-extensions-service-override": "38.0.7",
|
|
21
|
+
"@codingame/monaco-vscode-files-service-override": "38.0.7",
|
|
22
|
+
"@codingame/monaco-vscode-host-service-override": "38.0.7",
|
|
23
|
+
"@codingame/monaco-vscode-layout-service-override": "38.0.7",
|
|
24
|
+
"@codingame/monaco-vscode-quickaccess-service-override": "38.0.7",
|
|
25
25
|
"@vscode/diff": "0.0.2-7",
|
|
26
26
|
"@vscode/iconv-lite-umd": "0.7.1",
|
|
27
|
-
"dompurify": "3.4.
|
|
27
|
+
"dompurify": "3.4.17",
|
|
28
28
|
"jschardet": "3.1.4",
|
|
29
29
|
"marked": "14.0.0"
|
|
30
30
|
},
|
package/services.js
CHANGED
|
@@ -571,10 +571,10 @@ export { IManagedSettingsPresentationService } from './vscode/src/vs/workbench/s
|
|
|
571
571
|
export { IWorkbenchGitHubService } from './vscode/src/vs/workbench/services/github/common/githubService.service.js';
|
|
572
572
|
export { IManagedSettingsUpdateService } from './vscode/src/vs/workbench/services/policies/common/managedSettingsUpdate.service.js';
|
|
573
573
|
|
|
574
|
-
if (window.monacoVscodeApiBuildId != null && window.monacoVscodeApiBuildId !== "1.142.0-
|
|
575
|
-
throw new Error(`Another version of monaco-vscode-api has already been loaded. Trying to load ${"1.142.0-
|
|
574
|
+
if (window.monacoVscodeApiBuildId != null && window.monacoVscodeApiBuildId !== "1.142.0-1f2935b8-04d5-4748-b96c-b102c34b46a7") {
|
|
575
|
+
throw new Error(`Another version of monaco-vscode-api has already been loaded. Trying to load ${"1.142.0-1f2935b8-04d5-4748-b96c-b102c34b46a7"}, ${window.monacoVscodeApiBuildId} is already loaded`);
|
|
576
576
|
}
|
|
577
|
-
window.monacoVscodeApiBuildId = "1.142.0-
|
|
577
|
+
window.monacoVscodeApiBuildId = "1.142.0-1f2935b8-04d5-4748-b96c-b102c34b46a7";
|
|
578
578
|
function registerCommands(options) {
|
|
579
579
|
function asMenuId(menu) {
|
|
580
580
|
switch (menu) {
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
let _isHotReloadEnabled = false;
|
|
4
|
+
function isHotReloadEnabled() {
|
|
5
|
+
return _isHotReloadEnabled;
|
|
6
|
+
}
|
|
7
|
+
function registerHotReloadHandler(handler) {
|
|
8
|
+
if (!isHotReloadEnabled()) {
|
|
9
|
+
return {
|
|
10
|
+
dispose() {}
|
|
11
|
+
};
|
|
12
|
+
} else {
|
|
13
|
+
const handlers = registerGlobalHotReloadHandler();
|
|
14
|
+
handlers.add(handler);
|
|
15
|
+
return {
|
|
16
|
+
dispose() {
|
|
17
|
+
handlers.delete(handler);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function registerGlobalHotReloadHandler() {
|
|
23
|
+
if (!hotReloadHandlers) {
|
|
24
|
+
hotReloadHandlers = ( new Set());
|
|
25
|
+
}
|
|
26
|
+
const g = globalThis;
|
|
27
|
+
if (!g.$hotReload_applyNewExports) {
|
|
28
|
+
g.$hotReload_applyNewExports = args => {
|
|
29
|
+
const args2 = {
|
|
30
|
+
config: {
|
|
31
|
+
mode: undefined
|
|
32
|
+
},
|
|
33
|
+
...args
|
|
34
|
+
};
|
|
35
|
+
const results = [];
|
|
36
|
+
for (const h of hotReloadHandlers) {
|
|
37
|
+
const result = h(args2);
|
|
38
|
+
if (result) {
|
|
39
|
+
results.push(result);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (results.length > 0) {
|
|
43
|
+
return newExports => {
|
|
44
|
+
let result = false;
|
|
45
|
+
for (const r of results) {
|
|
46
|
+
if (r(newExports)) {
|
|
47
|
+
result = true;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return undefined;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return hotReloadHandlers;
|
|
57
|
+
}
|
|
58
|
+
let hotReloadHandlers = undefined;
|
|
59
|
+
if (isHotReloadEnabled()) {
|
|
60
|
+
registerHotReloadHandler((
|
|
61
|
+
{
|
|
62
|
+
oldExports,
|
|
63
|
+
newSrc,
|
|
64
|
+
config
|
|
65
|
+
}
|
|
66
|
+
) => {
|
|
67
|
+
if (config.mode !== "patch-prototype") {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
return newExports => {
|
|
71
|
+
for (const key in newExports) {
|
|
72
|
+
const exportedItem = newExports[key];
|
|
73
|
+
console.log(`[hot-reload] Patching prototype methods of '${key}'`, {
|
|
74
|
+
exportedItem
|
|
75
|
+
});
|
|
76
|
+
if (typeof exportedItem === "function" && exportedItem.prototype) {
|
|
77
|
+
const oldExportedItem = oldExports[key];
|
|
78
|
+
if (oldExportedItem) {
|
|
79
|
+
for (const prop of Object.getOwnPropertyNames(exportedItem.prototype)) {
|
|
80
|
+
const descriptor = Object.getOwnPropertyDescriptor(exportedItem.prototype, prop);
|
|
81
|
+
const oldDescriptor = Object.getOwnPropertyDescriptor(oldExportedItem.prototype, prop);
|
|
82
|
+
if (descriptor?.value?.toString() !== oldDescriptor?.value?.toString()) {
|
|
83
|
+
console.log(`[hot-reload] Patching prototype method '${key}.${prop}'`);
|
|
84
|
+
}
|
|
85
|
+
Object.defineProperty(oldExportedItem.prototype, prop, descriptor);
|
|
86
|
+
}
|
|
87
|
+
newExports[key] = oldExportedItem;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return true;
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export { isHotReloadEnabled, registerHotReloadHandler };
|
|
@@ -1,14 +1,48 @@
|
|
|
1
1
|
|
|
2
|
+
import { isHotReloadEnabled, registerHotReloadHandler } from './hotReload.js';
|
|
2
3
|
import './observableInternal/index.js';
|
|
4
|
+
import { observableSignalFromEvent } from './observableInternal/observables/observableSignalFromEvent.js';
|
|
3
5
|
import { constObservable } from './observableInternal/observables/constObservable.js';
|
|
6
|
+
import { observableValue } from './observableInternal/observables/observableValue.js';
|
|
4
7
|
|
|
5
8
|
function readHotReloadableExport(value, reader) {
|
|
9
|
+
observeHotReloadableExports([value], reader);
|
|
6
10
|
return value;
|
|
7
11
|
}
|
|
12
|
+
function observeHotReloadableExports(values, reader) {
|
|
13
|
+
if (isHotReloadEnabled()) {
|
|
14
|
+
const o = observableSignalFromEvent("reload", event => registerHotReloadHandler((
|
|
15
|
+
{
|
|
16
|
+
oldExports
|
|
17
|
+
}
|
|
18
|
+
) => {
|
|
19
|
+
if (!( [...( Object.values(oldExports))].some(v => values.includes(v)))) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
return _newExports => {
|
|
23
|
+
event(undefined);
|
|
24
|
+
return true;
|
|
25
|
+
};
|
|
26
|
+
}));
|
|
27
|
+
o.read(reader);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const classes = ( new Map());
|
|
8
31
|
function createHotClass(clazz) {
|
|
9
|
-
{
|
|
32
|
+
if (!isHotReloadEnabled()) {
|
|
10
33
|
return constObservable(clazz);
|
|
11
34
|
}
|
|
35
|
+
const id = clazz.name;
|
|
36
|
+
let existing = classes.get(id);
|
|
37
|
+
if (!existing) {
|
|
38
|
+
existing = observableValue(id, clazz);
|
|
39
|
+
classes.set(id, existing);
|
|
40
|
+
} else {
|
|
41
|
+
setTimeout(() => {
|
|
42
|
+
existing.set(clazz, undefined);
|
|
43
|
+
}, 0);
|
|
44
|
+
}
|
|
45
|
+
return existing;
|
|
12
46
|
}
|
|
13
47
|
|
|
14
|
-
export { createHotClass, readHotReloadableExport };
|
|
48
|
+
export { createHotClass, observeHotReloadableExports, readHotReloadableExport };
|
|
@@ -6,23 +6,16 @@ import { Disposable, toDisposable } from '../../../../base/common/lifecycle.js';
|
|
|
6
6
|
import '../../../../base/common/observableInternal/index.js';
|
|
7
7
|
import { IDiffProviderFactoryService } from './diffProviderFactoryService.service.js';
|
|
8
8
|
import { filterWithPrevious } from './utils.js';
|
|
9
|
+
import { readHotReloadableExport } from '../../../../base/common/hotReloadHelpers.js';
|
|
9
10
|
import { LineRange, LineRangeSet } from '../../../common/core/ranges/lineRange.js';
|
|
10
|
-
import {
|
|
11
|
-
import { softAssert } from '../../../../base/common/assert.js';
|
|
12
|
-
import '../../../../base/common/errors.js';
|
|
13
|
-
import '../../../../base/common/strings.js';
|
|
14
|
-
import '../../../common/core/text/textLength.js';
|
|
15
|
-
import '../../../common/core/text/positionToOffsetImpl.js';
|
|
11
|
+
import { DefaultLinesDiffComputer } from '../../../common/diff/defaultLinesDiffComputer/defaultLinesDiffComputer.js';
|
|
16
12
|
import { LineRangeMapping, DetailedLineRangeMapping, RangeMapping } from '../../../common/diff/rangeMapping.js';
|
|
17
|
-
import '../../../common/diff/defaultLinesDiffComputer/algorithms/diffAlgorithm.js';
|
|
18
|
-
import '../../../common/diff/defaultLinesDiffComputer/utils.js';
|
|
19
|
-
import '../../../../base/common/arraysFind.js';
|
|
20
|
-
import '../../../../base/common/map.js';
|
|
21
|
-
import '../../../common/diff/defaultLinesDiffComputer/linesSliceCharSequence.js';
|
|
22
|
-
import '../../../../base/common/charCode.js';
|
|
23
13
|
import { TextEditInfo } from '../../../common/model/bracketPairsTextModelPart/bracketPairsTree/beforeEditPositionMapper.js';
|
|
24
14
|
import { combineTextEditInfos } from '../../../common/model/bracketPairsTextModelPart/bracketPairsTree/combineTextEditInfos.js';
|
|
15
|
+
import { optimizeSequenceDiffs } from '../../../common/diff/defaultLinesDiffComputer/heuristicSequenceOptimizations.js';
|
|
25
16
|
import { isDefined } from '../../../../base/common/types.js';
|
|
17
|
+
import { groupAdjacentBy } from '../../../../base/common/arrays.js';
|
|
18
|
+
import { softAssert } from '../../../../base/common/assert.js';
|
|
26
19
|
import { observableValue } from '../../../../base/common/observableInternal/observables/observableValue.js';
|
|
27
20
|
import { derived } from '../../../../base/common/observableInternal/observables/derived.js';
|
|
28
21
|
import { transaction } from '../../../../base/common/observableInternal/transaction.js';
|
|
@@ -237,6 +230,8 @@ let DiffEditorViewModel = class DiffEditorViewModel extends Disposable {
|
|
|
237
230
|
contentChangedSignal.read(reader);
|
|
238
231
|
const documentDiffProvider = this._diffProvider.read(reader);
|
|
239
232
|
documentDiffProvider.onChangeSignal.read(reader);
|
|
233
|
+
readHotReloadableExport(DefaultLinesDiffComputer, reader);
|
|
234
|
+
readHotReloadableExport(optimizeSequenceDiffs, reader);
|
|
240
235
|
this._isDiffUpToDate.set(false, undefined);
|
|
241
236
|
let originalTextEditInfos = [];
|
|
242
237
|
store.add(model.original.onDidChangeContent(e => {
|
|
@@ -298,7 +298,7 @@ let DiffEditorWidget = class DiffEditorWidget extends DelegatingEditor {
|
|
|
298
298
|
this._overviewRulerPart = derivedDisposable(
|
|
299
299
|
this,
|
|
300
300
|
reader => !this._options.renderOverviewRuler.read(reader) ? undefined : this._instantiationService.createInstance(
|
|
301
|
-
readHotReloadableExport(OverviewRulerFeature),
|
|
301
|
+
readHotReloadableExport(OverviewRulerFeature, reader),
|
|
302
302
|
this._editors,
|
|
303
303
|
this.elements.root,
|
|
304
304
|
this._diffModel,
|
|
@@ -327,7 +327,7 @@ let DiffEditorWidget = class DiffEditorWidget extends DelegatingEditor {
|
|
|
327
327
|
const unchangedRangesFeature = derivedDisposable(
|
|
328
328
|
this,
|
|
329
329
|
reader => this._instantiationService.createInstance(
|
|
330
|
-
readHotReloadableExport(HideUnchangedRegionsFeature),
|
|
330
|
+
readHotReloadableExport(HideUnchangedRegionsFeature, reader),
|
|
331
331
|
this._editors,
|
|
332
332
|
this._diffModel,
|
|
333
333
|
this._options,
|
|
@@ -339,7 +339,7 @@ let DiffEditorWidget = class DiffEditorWidget extends DelegatingEditor {
|
|
|
339
339
|
derivedDisposable(
|
|
340
340
|
this,
|
|
341
341
|
reader => this._instantiationService.createInstance(
|
|
342
|
-
readHotReloadableExport(DiffEditorDecorations),
|
|
342
|
+
readHotReloadableExport(DiffEditorDecorations, reader),
|
|
343
343
|
this._editors,
|
|
344
344
|
this._diffModel,
|
|
345
345
|
this._options,
|
|
@@ -352,7 +352,7 @@ let DiffEditorWidget = class DiffEditorWidget extends DelegatingEditor {
|
|
|
352
352
|
const viewZoneManager = derivedDisposable(
|
|
353
353
|
this,
|
|
354
354
|
reader => this._instantiationService.createInstance(
|
|
355
|
-
readHotReloadableExport(DiffEditorViewZones),
|
|
355
|
+
readHotReloadableExport(DiffEditorViewZones, reader),
|
|
356
356
|
getWindow(this._domElement),
|
|
357
357
|
this._editors,
|
|
358
358
|
this._diffModel,
|
|
@@ -391,7 +391,7 @@ let DiffEditorWidget = class DiffEditorWidget extends DelegatingEditor {
|
|
|
391
391
|
}, modViewZoneIdsToIgnore)
|
|
392
392
|
);
|
|
393
393
|
this._accessibleDiffViewer = derivedDisposable(this, reader => this._instantiationService.createInstance(
|
|
394
|
-
readHotReloadableExport(AccessibleDiffViewer),
|
|
394
|
+
readHotReloadableExport(AccessibleDiffViewer, reader),
|
|
395
395
|
this.elements.accessibleDiffViewer,
|
|
396
396
|
this._accessibleDiffViewerVisible,
|
|
397
397
|
(visible, tx) => this._accessibleDiffViewerShouldBeVisible.set(visible, tx),
|
|
@@ -415,7 +415,7 @@ let DiffEditorWidget = class DiffEditorWidget extends DelegatingEditor {
|
|
|
415
415
|
}));
|
|
416
416
|
this._gutter = derivedDisposable(this, reader => {
|
|
417
417
|
return this._options.shouldRenderGutterMenu.read(reader) ? this._instantiationService.createInstance(
|
|
418
|
-
readHotReloadableExport(DiffEditorGutter),
|
|
418
|
+
readHotReloadableExport(DiffEditorGutter, reader),
|
|
419
419
|
this.elements.root,
|
|
420
420
|
this._diffModel,
|
|
421
421
|
this._editors,
|
|
@@ -427,7 +427,7 @@ let DiffEditorWidget = class DiffEditorWidget extends DelegatingEditor {
|
|
|
427
427
|
this._register(recomputeInitiallyAndOnChange(this._layoutInfo));
|
|
428
428
|
derivedDisposable(
|
|
429
429
|
this,
|
|
430
|
-
reader => new (readHotReloadableExport(MovedBlocksLinesFeature))(
|
|
430
|
+
reader => new (readHotReloadableExport(MovedBlocksLinesFeature, reader))(
|
|
431
431
|
this.elements.root,
|
|
432
432
|
this._diffModel,
|
|
433
433
|
this._layoutInfo.map(i => i.originalEditor),
|
|
@@ -459,7 +459,7 @@ let DiffEditorWidget = class DiffEditorWidget extends DelegatingEditor {
|
|
|
459
459
|
}));
|
|
460
460
|
this._register(autorunWithStore((reader, store) => {
|
|
461
461
|
store.add(
|
|
462
|
-
new (readHotReloadableExport(RevertButtonsFeature))(this._editors, this._diffModel, this._options, this)
|
|
462
|
+
new (readHotReloadableExport(RevertButtonsFeature, reader))(this._editors, this._diffModel, this._options, this)
|
|
463
463
|
);
|
|
464
464
|
}));
|
|
465
465
|
this._register(autorunWithStore((reader, store) => {
|
|
@@ -6,7 +6,7 @@ import { Disposable, MutableDisposable } from '../../../../base/common/lifecycle
|
|
|
6
6
|
import '../../../../base/common/observableInternal/index.js';
|
|
7
7
|
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
|
|
8
8
|
import './colors.js';
|
|
9
|
-
import './diffEditorItemTemplate.js';
|
|
9
|
+
import { DiffEditorItemTemplate } from './diffEditorItemTemplate.js';
|
|
10
10
|
import { getMultiDiffEditorVariantConfiguration } from './multiDiffEditorOptions.js';
|
|
11
11
|
import { MultiDiffEditorViewModel } from './multiDiffEditorViewModel.js';
|
|
12
12
|
import { MultiDiffEditorWidgetImpl } from './multiDiffEditorWidgetImpl.js';
|
|
@@ -36,7 +36,8 @@ let MultiDiffEditorWidget = class MultiDiffEditorWidget extends Disposable {
|
|
|
36
36
|
this._widgetImpl = this._widgetImplValue;
|
|
37
37
|
let isInitialHotReloadRun = true;
|
|
38
38
|
this._register(autorun(reader => {
|
|
39
|
-
|
|
39
|
+
readHotReloadableExport(DiffEditorItemTemplate, reader);
|
|
40
|
+
const widgetImpl = readHotReloadableExport(MultiDiffEditorWidgetImpl, reader);
|
|
40
41
|
if (isInitialHotReloadRun) {
|
|
41
42
|
isInitialHotReloadRun = false;
|
|
42
43
|
return;
|
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
|
|
2
2
|
import { createElement } from '../../../base/browser/dom.js';
|
|
3
|
-
import {
|
|
3
|
+
import { isHotReloadEnabled } from '../../../base/common/hotReload.js';
|
|
4
|
+
import { Disposable, toDisposable } from '../../../base/common/lifecycle.js';
|
|
4
5
|
import '../../../base/common/observableInternal/index.js';
|
|
6
|
+
import { autorun } from '../../../base/common/observableInternal/reactions/autorun.js';
|
|
5
7
|
import { constObservable } from '../../../base/common/observableInternal/observables/constObservable.js';
|
|
8
|
+
import { derived } from '../../../base/common/observableInternal/observables/derived.js';
|
|
9
|
+
import { observableValue } from '../../../base/common/observableInternal/observables/observableValue.js';
|
|
6
10
|
|
|
7
11
|
class DomWidget extends Disposable {
|
|
8
12
|
static createAppend(dom, store, ...params) {
|
|
9
|
-
{
|
|
13
|
+
if (!isHotReloadEnabled()) {
|
|
10
14
|
const widget = new this(...params);
|
|
11
15
|
dom.appendChild(widget.element);
|
|
12
16
|
store.add(widget);
|
|
13
17
|
return;
|
|
14
18
|
}
|
|
19
|
+
const observable = this.createObservable(store, ...params);
|
|
20
|
+
store.add(autorun(reader => {
|
|
21
|
+
const widget = observable.read(reader);
|
|
22
|
+
dom.appendChild(widget.element);
|
|
23
|
+
reader.store.add(toDisposable(() => widget.element.remove()));
|
|
24
|
+
reader.store.add(widget);
|
|
25
|
+
}));
|
|
15
26
|
}
|
|
16
27
|
static createInContents(store, ...params) {
|
|
17
28
|
const div = createElement("div");
|
|
@@ -20,17 +31,38 @@ class DomWidget extends Disposable {
|
|
|
20
31
|
return div;
|
|
21
32
|
}
|
|
22
33
|
static createObservable(store, ...params) {
|
|
23
|
-
{
|
|
34
|
+
if (!isHotReloadEnabled()) {
|
|
35
|
+
return constObservable(new this(...params));
|
|
36
|
+
}
|
|
37
|
+
const id = this[_hotReloadId];
|
|
38
|
+
const observable = id ? hotReloadedWidgets.get(id) : undefined;
|
|
39
|
+
if (!observable) {
|
|
24
40
|
return constObservable(new this(...params));
|
|
25
41
|
}
|
|
42
|
+
return derived(reader => {
|
|
43
|
+
const Ctor = observable.read(reader);
|
|
44
|
+
return ( new Ctor(...params));
|
|
45
|
+
});
|
|
26
46
|
}
|
|
27
47
|
static instantiateAppend(instantiationService, dom, store, ...params) {
|
|
28
|
-
{
|
|
48
|
+
if (!isHotReloadEnabled()) {
|
|
29
49
|
const widget = instantiationService.createInstance(this, ...params);
|
|
30
50
|
dom.appendChild(widget.element);
|
|
31
51
|
store.add(widget);
|
|
32
52
|
return;
|
|
33
53
|
}
|
|
54
|
+
const observable = this.instantiateObservable(instantiationService, store, ...params);
|
|
55
|
+
let lastWidget = undefined;
|
|
56
|
+
store.add(autorun(reader => {
|
|
57
|
+
const widget = observable.read(reader);
|
|
58
|
+
if (lastWidget) {
|
|
59
|
+
lastWidget.element.replaceWith(widget.element);
|
|
60
|
+
} else {
|
|
61
|
+
dom.appendChild(widget.element);
|
|
62
|
+
}
|
|
63
|
+
lastWidget = widget;
|
|
64
|
+
reader.delayedStore.add(widget);
|
|
65
|
+
}));
|
|
34
66
|
}
|
|
35
67
|
static instantiateInContents(instantiationService, store, ...params) {
|
|
36
68
|
const div = createElement("div");
|
|
@@ -39,15 +71,34 @@ class DomWidget extends Disposable {
|
|
|
39
71
|
return div;
|
|
40
72
|
}
|
|
41
73
|
static instantiateObservable(instantiationService, store, ...params) {
|
|
42
|
-
{
|
|
74
|
+
if (!isHotReloadEnabled()) {
|
|
43
75
|
return constObservable(instantiationService.createInstance(this, ...params));
|
|
44
76
|
}
|
|
77
|
+
const id = this[_hotReloadId];
|
|
78
|
+
const observable = id ? hotReloadedWidgets.get(id) : undefined;
|
|
79
|
+
if (!observable) {
|
|
80
|
+
return constObservable(instantiationService.createInstance(this, ...params));
|
|
81
|
+
}
|
|
82
|
+
return derived(reader => {
|
|
83
|
+
const Ctor = observable.read(reader);
|
|
84
|
+
return instantiationService.createInstance(Ctor, ...params);
|
|
85
|
+
});
|
|
45
86
|
}
|
|
46
87
|
static registerWidgetHotReplacement(id) {
|
|
47
|
-
{
|
|
88
|
+
if (!isHotReloadEnabled()) {
|
|
48
89
|
return;
|
|
49
90
|
}
|
|
91
|
+
let observable = hotReloadedWidgets.get(id);
|
|
92
|
+
if (!observable) {
|
|
93
|
+
observable = observableValue(id, this);
|
|
94
|
+
hotReloadedWidgets.set(id, observable);
|
|
95
|
+
} else {
|
|
96
|
+
observable.set(this, undefined);
|
|
97
|
+
}
|
|
98
|
+
this[_hotReloadId] = id;
|
|
50
99
|
}
|
|
51
100
|
}
|
|
101
|
+
const _hotReloadId = Symbol("DomWidgetHotReloadId");
|
|
102
|
+
const hotReloadedWidgets = ( new Map());
|
|
52
103
|
|
|
53
104
|
export { DomWidget };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
|
|
2
|
+
import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
|
|
3
|
+
import { isHotReloadEnabled } from '../../../base/common/hotReload.js';
|
|
2
4
|
import '../../../base/common/observableInternal/index.js';
|
|
3
|
-
import '../../instantiation/common/instantiation.js';
|
|
5
|
+
import { IInstantiationService } from '../../instantiation/common/instantiation.js';
|
|
6
|
+
import { autorunWithStore } from '../../../base/common/observableInternal/reactions/autorun.js';
|
|
4
7
|
|
|
5
8
|
function hotClassGetOriginalInstance(value) {
|
|
6
9
|
if (value instanceof BaseClass) {
|
|
@@ -14,8 +17,32 @@ class BaseClass {
|
|
|
14
17
|
}
|
|
15
18
|
init(...params) {}
|
|
16
19
|
}
|
|
20
|
+
function createWrapper(clazz, B) {
|
|
21
|
+
return (class ReloadableWrapper extends B {
|
|
22
|
+
constructor() {
|
|
23
|
+
super(...arguments);
|
|
24
|
+
this._autorun = undefined;
|
|
25
|
+
}
|
|
26
|
+
init(...params) {
|
|
27
|
+
this._autorun = autorunWithStore((reader, store) => {
|
|
28
|
+
const clazz_ = clazz.read(reader);
|
|
29
|
+
this._instance = store.add(this.instantiationService.createInstance(clazz_, ...params));
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
dispose() {
|
|
33
|
+
this._autorun?.dispose();
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
17
37
|
function wrapInHotClass1(clazz) {
|
|
18
|
-
return clazz.get() ;
|
|
38
|
+
return !isHotReloadEnabled() ? clazz.get() : createWrapper(clazz, BaseClass1);
|
|
19
39
|
}
|
|
40
|
+
let BaseClass1 = class BaseClass1 extends BaseClass {
|
|
41
|
+
constructor(param1, i) {
|
|
42
|
+
super(i);
|
|
43
|
+
this.init(param1);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
BaseClass1 = ( __decorate([( __param(1, IInstantiationService))], BaseClass1));
|
|
20
47
|
|
|
21
48
|
export { hotClassGetOriginalInstance, wrapInHotClass1 };
|
|
@@ -1,12 +1,53 @@
|
|
|
1
1
|
|
|
2
|
+
import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
|
|
3
|
+
import { isHotReloadEnabled } from '../../../base/common/hotReload.js';
|
|
4
|
+
import { readHotReloadableExport } from '../../../base/common/hotReloadHelpers.js';
|
|
2
5
|
import '../../../base/common/observableInternal/index.js';
|
|
3
|
-
import '../../instantiation/common/instantiation.js';
|
|
6
|
+
import { IInstantiationService } from '../../instantiation/common/instantiation.js';
|
|
7
|
+
import { autorunWithStore } from '../../../base/common/observableInternal/reactions/autorun.js';
|
|
4
8
|
|
|
5
9
|
function wrapInReloadableClass0(getClass) {
|
|
6
|
-
return getClass() ;
|
|
10
|
+
return !isHotReloadEnabled() ? getClass() : createWrapper(getClass, BaseClass0);
|
|
7
11
|
}
|
|
12
|
+
class BaseClass {
|
|
13
|
+
constructor(instantiationService) {
|
|
14
|
+
this.instantiationService = instantiationService;
|
|
15
|
+
}
|
|
16
|
+
init(...params) {}
|
|
17
|
+
}
|
|
18
|
+
function createWrapper(getClass, B) {
|
|
19
|
+
return (class ReloadableWrapper extends B {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this._autorun = undefined;
|
|
23
|
+
}
|
|
24
|
+
init(...params) {
|
|
25
|
+
this._autorun = autorunWithStore((reader, store) => {
|
|
26
|
+
const clazz = readHotReloadableExport(getClass(), reader);
|
|
27
|
+
store.add(this.instantiationService.createInstance(clazz, ...params));
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
dispose() {
|
|
31
|
+
this._autorun?.dispose();
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
let BaseClass0 = class BaseClass0 extends BaseClass {
|
|
36
|
+
constructor(i) {
|
|
37
|
+
super(i);
|
|
38
|
+
this.init();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
BaseClass0 = ( __decorate([( __param(0, IInstantiationService))], BaseClass0));
|
|
8
42
|
function wrapInReloadableClass1(getClass) {
|
|
9
|
-
return getClass() ;
|
|
43
|
+
return !isHotReloadEnabled() ? getClass() : createWrapper(getClass, BaseClass1);
|
|
10
44
|
}
|
|
45
|
+
let BaseClass1 = class BaseClass1 extends BaseClass {
|
|
46
|
+
constructor(param1, i) {
|
|
47
|
+
super(i);
|
|
48
|
+
this.init(param1);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
BaseClass1 = ( __decorate([( __param(1, IInstantiationService))], BaseClass1));
|
|
11
52
|
|
|
12
53
|
export { wrapInReloadableClass0, wrapInReloadableClass1 };
|