@volar/language-server 1.4.0-alpha.0 → 1.4.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,4 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
1
+ "use strict";
10
2
  Object.defineProperty(exports, "__esModule", { value: true });
11
3
  exports.createWebFileSystemHost = void 0;
12
4
  const path = require("typesafe-path");
@@ -16,7 +8,6 @@ const vscode_uri_1 = require("vscode-uri");
16
8
  const protocol_1 = require("../protocol");
17
9
  const utilities_1 = require("./typescript/utilities");
18
10
  const uriMap_1 = require("../common/utils/uriMap");
19
- let currentCwd = '/';
20
11
  function createWebFileSystemHost(_0, _1, env, initOptions) {
21
12
  const instances = (0, uriMap_1.createUriMap)(env.fileNameToUri);
22
13
  const onDidChangeWatchedFilesCb = new Set();
@@ -91,45 +82,39 @@ function createWebFileSystemHost(_0, _1, env, initOptions) {
91
82
  realpath: path => path, // TODO: cannot implement with vscode
92
83
  };
93
84
  function resolvePath(fsPath) {
94
- if (currentCwd !== rootPath) {
95
- process.chdir(rootPath);
96
- currentCwd = rootPath;
97
- }
98
85
  return path.resolve(fsPath);
99
86
  }
100
87
  function fileExists(fsPath) {
101
- var _a, _b, _c;
102
88
  fsPath = resolvePath(fsPath);
103
89
  const uri = env.fileNameToUri(fsPath);
104
90
  const dirPath = path.dirname(fsPath);
105
- if (((_a = initOptions.typescript) === null || _a === void 0 ? void 0 : _a.cdn) && uri.startsWith(initOptions.typescript.cdn)) {
91
+ if (initOptions.typescript?.cdn && uri.startsWith(initOptions.typescript.cdn)) {
106
92
  if (!(uri.endsWith('.d.ts') || uri.endsWith('/package.json'))) {
107
93
  return false;
108
94
  }
109
95
  readFile(fsPath);
110
96
  const file = getDir(dirPath).files.get(path.basename(fsPath));
111
- return (_b = file === null || file === void 0 ? void 0 : file.exists) !== null && _b !== void 0 ? _b : false;
97
+ return file?.exists ?? false;
112
98
  }
113
99
  readDirectory(dirPath);
114
100
  const file = getDir(path.dirname(fsPath)).files.get(path.basename(fsPath));
115
- return (_c = file === null || file === void 0 ? void 0 : file.exists) !== null && _c !== void 0 ? _c : false;
101
+ return file?.exists ?? false;
116
102
  }
117
103
  function readFile(fsPath) {
118
- var _a, _b, _c, _d;
119
104
  fsPath = resolvePath(fsPath);
120
105
  const uri = env.fileNameToUri(fsPath);
121
106
  const dirPath = path.dirname(fsPath);
122
107
  const dir = getDir(dirPath);
123
108
  const name = path.basename(fsPath);
124
- if (((_a = initOptions.typescript) === null || _a === void 0 ? void 0 : _a.cdn) && uri.startsWith(initOptions.typescript.cdn)) {
109
+ if (initOptions.typescript?.cdn && uri.startsWith(initOptions.typescript.cdn)) {
125
110
  if (!(uri.endsWith('.d.ts') || uri.endsWith('/package.json'))) {
126
- return ((_b = dir.files.get(name)) === null || _b === void 0 ? void 0 : _b.text) || '';
111
+ return dir.files.get(name)?.text || '';
127
112
  }
128
113
  readFileWorker();
129
- return ((_c = dir.files.get(name)) === null || _c === void 0 ? void 0 : _c.text) || '';
114
+ return dir.files.get(name)?.text || '';
130
115
  }
131
116
  readFileWorker();
132
- return ((_d = dir.files.get(name)) === null || _d === void 0 ? void 0 : _d.text) || '';
117
+ return dir.files.get(name)?.text || '';
133
118
  function readFileWorker() {
134
119
  if (connection) {
135
120
  fetch('load', fsPath, readFileAsync(connection, fsPath, dir));
@@ -138,26 +123,24 @@ function createWebFileSystemHost(_0, _1, env, initOptions) {
138
123
  onReadyCb.push((connection) => fetch('load', fsPath, readFileAsync(connection, fsPath, dir)));
139
124
  }
140
125
  }
141
- function readFileAsync(connection, fsPath, dir) {
142
- return __awaiter(this, void 0, void 0, function* () {
143
- const name = path.basename(fsPath);
144
- if (!dir.files.has(name)) {
145
- dir.files.set(name, {});
146
- }
147
- const file = dir.files.get(name);
148
- if (file.requested) {
149
- return;
150
- }
151
- file.requested = true;
152
- const uri = env.fileNameToUri(fsPath);
153
- const data = yield connection.sendRequest(protocol_1.FsReadFileRequest.type, resolveRequestUrl(uri));
154
- const text = data ? new TextDecoder('utf8').decode(data) : undefined;
155
- if (text === null || text === void 0 ? void 0 : text.length) {
156
- file.exists = true;
157
- file.text = text;
158
- changes.push({ uri, type: vscode.FileChangeType.Changed });
159
- }
160
- });
126
+ async function readFileAsync(connection, fsPath, dir) {
127
+ const name = path.basename(fsPath);
128
+ if (!dir.files.has(name)) {
129
+ dir.files.set(name, {});
130
+ }
131
+ const file = dir.files.get(name);
132
+ if (file.requested) {
133
+ return;
134
+ }
135
+ file.requested = true;
136
+ const uri = env.fileNameToUri(fsPath);
137
+ const data = await connection.sendRequest(protocol_1.FsReadFileRequest.type, resolveRequestUrl(uri));
138
+ const text = data ? new TextDecoder('utf8').decode(data) : undefined;
139
+ if (text?.length) {
140
+ file.exists = true;
141
+ file.text = text;
142
+ changes.push({ uri, type: vscode.FileChangeType.Changed });
143
+ }
161
144
  }
162
145
  }
163
146
  function readDirectory(fsPath, extensions, exclude, include, depth) {
@@ -187,66 +170,61 @@ function createWebFileSystemHost(_0, _1, env, initOptions) {
187
170
  onReadyCb.push((connection) => fetch('directory', fsPath, readDirectoryAsync(connection, fsPath)));
188
171
  }
189
172
  }
190
- function readDirectoryAsync(connection, fsPath) {
191
- return __awaiter(this, void 0, void 0, function* () {
192
- const dir = getDir(fsPath);
193
- if (dir.requested) {
194
- return;
195
- }
196
- dir.requested = true;
197
- const uri = env.fileNameToUri(fsPath);
198
- const result = yield connection.sendRequest(protocol_1.FsReadDirectoryRequest.type, resolveRequestUrl(uri));
199
- for (const [name, fileType] of result) {
200
- if (fileType === vscode_html_languageservice_1.FileType.File || fileType === vscode_html_languageservice_1.FileType.SymbolicLink) {
201
- if (!dir.files.has(name)) {
202
- dir.files.set(name, {});
203
- }
204
- const file = dir.files.get(name);
205
- if (!file.exists) {
206
- file.exists = true;
207
- changes.push({
208
- uri: env.fileNameToUri(path.join(fsPath, name)),
209
- type: vscode.FileChangeType.Created,
210
- });
211
- }
173
+ async function readDirectoryAsync(connection, fsPath) {
174
+ const dir = getDir(fsPath);
175
+ if (dir.requested) {
176
+ return;
177
+ }
178
+ dir.requested = true;
179
+ const uri = env.fileNameToUri(fsPath);
180
+ const result = await connection.sendRequest(protocol_1.FsReadDirectoryRequest.type, resolveRequestUrl(uri));
181
+ for (const [name, fileType] of result) {
182
+ if (fileType === vscode_html_languageservice_1.FileType.File || fileType === vscode_html_languageservice_1.FileType.SymbolicLink) {
183
+ if (!dir.files.has(name)) {
184
+ dir.files.set(name, {});
212
185
  }
213
- else if (fileType === vscode_html_languageservice_1.FileType.Directory && !dir.dirs.has(name)) {
214
- const childDir = getDirFromDir(dir, name);
215
- childDir.exists = true;
186
+ const file = dir.files.get(name);
187
+ if (!file.exists) {
188
+ file.exists = true;
189
+ changes.push({
190
+ uri: env.fileNameToUri(path.join(fsPath, name)),
191
+ type: vscode.FileChangeType.Created,
192
+ });
216
193
  }
217
194
  }
218
- });
195
+ else if (fileType === vscode_html_languageservice_1.FileType.Directory && !dir.dirs.has(name)) {
196
+ const childDir = getDirFromDir(dir, name);
197
+ childDir.exists = true;
198
+ }
199
+ }
219
200
  }
220
201
  }
221
- function fetch(action, fileName, p) {
222
- return __awaiter(this, void 0, void 0, function* () {
223
- fetchTasks.push([action, fileName, p]);
224
- if (runningRead === false) {
225
- let toUpdate;
226
- runningRead = true;
227
- const progress = yield (connection === null || connection === void 0 ? void 0 : connection.window.createWorkDoneProgress());
228
- progress === null || progress === void 0 ? void 0 : progress.begin('');
229
- while (fetchTasks.length) {
230
- const current = fetchTasks.shift();
231
- updateProgress(current[0] + ' ' + vscode_uri_1.URI.parse(env.fileNameToUri(current[1])).fsPath);
232
- yield current[2];
233
- }
234
- progress === null || progress === void 0 ? void 0 : progress.done();
235
- runningRead = false;
236
- fireChanges();
237
- function updateProgress(text) {
238
- clearTimeout(toUpdate);
239
- toUpdate = setTimeout(() => {
240
- progress === null || progress === void 0 ? void 0 : progress.report(text);
241
- toUpdate = undefined;
242
- }, 0);
243
- }
202
+ async function fetch(action, fileName, p) {
203
+ fetchTasks.push([action, fileName, p]);
204
+ if (runningRead === false) {
205
+ let toUpdate;
206
+ runningRead = true;
207
+ const progress = await connection?.window.createWorkDoneProgress();
208
+ progress?.begin('');
209
+ while (fetchTasks.length) {
210
+ const current = fetchTasks.shift();
211
+ updateProgress(current[0] + ' ' + vscode_uri_1.URI.parse(env.fileNameToUri(current[1])).fsPath);
212
+ await current[2];
244
213
  }
245
- });
214
+ progress?.done();
215
+ runningRead = false;
216
+ fireChanges();
217
+ function updateProgress(text) {
218
+ clearTimeout(toUpdate);
219
+ toUpdate = setTimeout(() => {
220
+ progress?.report(text);
221
+ toUpdate = undefined;
222
+ }, 0);
223
+ }
224
+ }
246
225
  }
247
226
  function resolveRequestUrl(uri) {
248
- var _a;
249
- if (((_a = initOptions.typescript) === null || _a === void 0 ? void 0 : _a.cdn) && uri.startsWith(initOptions.typescript.cdn)) {
227
+ if (initOptions.typescript?.cdn && uri.startsWith(initOptions.typescript.cdn)) {
250
228
  let fileName = env.uriToFileName(uri);
251
229
  for (const [key, version] of Object.entries(initOptions.typescript.versions || {})) {
252
230
  if (fileName.startsWith(`/node_modules/${key}/`)) {
@@ -257,19 +235,17 @@ function createWebFileSystemHost(_0, _1, env, initOptions) {
257
235
  }
258
236
  return uri;
259
237
  }
260
- function fireChanges() {
261
- return __awaiter(this, void 0, void 0, function* () {
262
- if (runningRead || runningStat) {
263
- return;
264
- }
265
- const _changes = [...changes];
266
- changes.length = 0;
267
- for (const cb of [...onDidChangeWatchedFilesCb]) {
268
- if (onDidChangeWatchedFilesCb.has(cb)) {
269
- yield cb({ changes: _changes });
270
- }
238
+ async function fireChanges() {
239
+ if (runningRead || runningStat) {
240
+ return;
241
+ }
242
+ const _changes = [...changes];
243
+ changes.length = 0;
244
+ for (const cb of [...onDidChangeWatchedFilesCb]) {
245
+ if (onDidChangeWatchedFilesCb.has(cb)) {
246
+ await cb({ changes: _changes });
271
247
  }
272
- });
248
+ }
273
249
  }
274
250
  function getDir(dirPath) {
275
251
  const dirNames = [];
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2
3
  if (k2 === undefined) k2 = k;
3
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -12,15 +13,6 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
12
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
13
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
14
15
  };
15
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
16
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
17
- return new (P || (P = Promise))(function (resolve, reject) {
18
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
19
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
20
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
21
- step((generator = generator.apply(thisArg, _arguments || [])).next());
22
- });
23
- };
24
16
  Object.defineProperty(exports, "__esModule", { value: true });
25
17
  exports.startLanguageServer = exports.createConnection = void 0;
26
18
  const request_light_1 = require("request-light");
@@ -54,17 +46,15 @@ function startLanguageServer(connection, ...plugins) {
54
46
  loadTypescript() {
55
47
  return require('typescript'); // force bundle because not support load by user config in web
56
48
  },
57
- loadTypescriptLocalized(tsdk, locale) {
58
- return __awaiter(this, void 0, void 0, function* () {
59
- try {
60
- const uri = fileNameToUri(`${tsdk}/${locale}/diagnosticMessages.generated.json`);
61
- const json = yield (0, http_1.default)(uri);
62
- if (json) {
63
- return JSON.parse(json);
64
- }
49
+ async loadTypescriptLocalized(tsdk, locale) {
50
+ try {
51
+ const uri = fileNameToUri(`${tsdk}/${locale}/diagnosticMessages.generated.json`);
52
+ const json = await (0, http_1.default)(uri);
53
+ if (json) {
54
+ return JSON.parse(json);
65
55
  }
66
- catch (_a) { }
67
- });
56
+ }
57
+ catch { }
68
58
  },
69
59
  schemaRequestHandlers: {
70
60
  http: http_1.default,
@@ -78,17 +68,15 @@ function startLanguageServer(connection, ...plugins) {
78
68
  },
79
69
  };
80
70
  function uriToFileName(uri) {
81
- var _a;
82
71
  const parsed = vscode_uri_1.URI.parse(uri);
83
- if (((_a = options.typescript) === null || _a === void 0 ? void 0 : _a.cdn) && uri.startsWith(options.typescript.cdn)) {
72
+ if (options.typescript?.cdn && uri.startsWith(options.typescript.cdn)) {
84
73
  return parsed.toString(true).replace(options.typescript.cdn, '/node_modules/');
85
74
  }
86
75
  return `/${parsed.scheme}${parsed.authority ? '@' + parsed.authority : ''}${parsed.path}`;
87
76
  }
88
77
  ;
89
78
  function fileNameToUri(fileName) {
90
- var _a;
91
- if (fileName.startsWith('/node_modules/') && ((_a = options.typescript) === null || _a === void 0 ? void 0 : _a.cdn)) {
79
+ if (fileName.startsWith('/node_modules/') && options.typescript?.cdn) {
92
80
  return vscode_uri_1.URI.parse(fileName.replace('/node_modules/', options.typescript.cdn)).toString();
93
81
  }
94
82
  const parts = fileName.split('/');
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
3
  exports.startsWith = exports.createGetCanonicalFileName = exports.stringContains = exports.endsWith = exports.getStringComparer = exports.compareStringsCaseSensitive = exports.equateStringsCaseSensitive = exports.equateStringsCaseInsensitive = exports.last = exports.lastOrUndefined = exports.sort = exports.some = exports.flatMap = exports.flatten = exports.map = exports.indexOfAnyCharCode = exports.findIndex = exports.every = void 0;
3
4
  const emptyArray = [];
@@ -21,7 +22,7 @@ exports.every = every;
21
22
  function findIndex(array, predicate, startIndex) {
22
23
  if (array === undefined)
23
24
  return -1;
24
- for (let i = startIndex !== null && startIndex !== void 0 ? startIndex : 0; i < array.length; i++) {
25
+ for (let i = startIndex ?? 0; i < array.length; i++) {
25
26
  if (predicate(array[i], i)) {
26
27
  return i;
27
28
  }
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
3
  exports.Set = exports.Map = exports.version = exports.versionMajorMinor = void 0;
3
4
  // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
@@ -19,7 +20,7 @@ var NativeCollections;
19
20
  */
20
21
  function tryGetNativeMap() {
21
22
  // Internet Explorer's Map doesn't support iteration, so don't use it.
22
- const gMap = globals === null || globals === void 0 ? void 0 : globals.Map;
23
+ const gMap = globals?.Map;
23
24
  // eslint-disable-next-line local/no-in-operator
24
25
  const constructor = typeof gMap !== "undefined" && "entries" in gMap.prototype && new gMap([[0, 0]]).size === 1 ? gMap : undefined;
25
26
  if (!constructor) {
@@ -33,7 +34,7 @@ var NativeCollections;
33
34
  */
34
35
  function tryGetNativeSet() {
35
36
  // Internet Explorer's Set doesn't support iteration, so don't use it.
36
- const gSet = globals === null || globals === void 0 ? void 0 : globals.Set;
37
+ const gSet = globals?.Set;
37
38
  // eslint-disable-next-line local/no-in-operator
38
39
  const constructor = typeof gSet !== "undefined" && "entries" in gSet.prototype && new gSet([0]).size === 1 ? gSet : undefined;
39
40
  if (!constructor) {
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
3
  exports.containsPath = exports.removeTrailingDirectorySeparator = exports.normalizePath = exports.getNormalizedPathComponents = exports.combinePaths = exports.getDirectoryPath = exports.fileExtensionIsOneOf = exports.hasExtension = exports.isRootedDiskPath = exports.directorySeparator = void 0;
3
4
  const core_1 = require("./core");
@@ -1,2 +1,3 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
3
  //# sourceMappingURL=types.js.map
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
3
  exports.matchFiles = void 0;
3
4
  const core_1 = require("./core");
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
3
  exports.createCancellationTokenHost = void 0;
3
4
  const vscode = require("vscode-languageserver");
@@ -35,7 +36,7 @@ function createCancellationTokenHost(_cancellationPipeName) {
35
36
  try {
36
37
  return fs.statSync(cancellationPipeName).mtime.valueOf();
37
38
  }
38
- catch (_a) {
39
+ catch {
39
40
  return -1;
40
41
  }
41
42
  }
@@ -1,52 +1,37 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
1
+ "use strict";
10
2
  Object.defineProperty(exports, "__esModule", { value: true });
11
3
  exports.createConfigurationHost = void 0;
12
4
  const vscode = require("vscode-languageserver");
13
5
  function createConfigurationHost(params, connection) {
14
6
  const callbacks = [];
15
7
  const cache = new Map();
16
- connection.onDidChangeConfiguration(() => __awaiter(this, void 0, void 0, function* () {
8
+ connection.onDidChangeConfiguration(async () => {
17
9
  cache.clear();
18
10
  for (const cb of callbacks) {
19
11
  cb();
20
12
  }
21
- }));
13
+ });
22
14
  return {
23
15
  ready() {
24
- var _a, _b;
25
- if ((_b = (_a = params.capabilities.workspace) === null || _a === void 0 ? void 0 : _a.didChangeConfiguration) === null || _b === void 0 ? void 0 : _b.dynamicRegistration) {
16
+ if (params.capabilities.workspace?.didChangeConfiguration?.dynamicRegistration) {
26
17
  connection.client.register(vscode.DidChangeConfigurationNotification.type);
27
18
  }
28
19
  },
29
- getConfiguration(section, scopeUri) {
30
- var _a;
31
- return __awaiter(this, void 0, void 0, function* () {
32
- if (!scopeUri && ((_a = params.capabilities.workspace) === null || _a === void 0 ? void 0 : _a.didChangeConfiguration)) {
33
- if (!cache.has(section)) {
34
- cache.set(section, yield getConfigurationWorker(section, scopeUri));
35
- }
36
- return cache.get(section);
20
+ async getConfiguration(section, scopeUri) {
21
+ if (!scopeUri && params.capabilities.workspace?.didChangeConfiguration) {
22
+ if (!cache.has(section)) {
23
+ cache.set(section, await getConfigurationWorker(section, scopeUri));
37
24
  }
38
- return yield getConfigurationWorker(section, scopeUri);
39
- });
25
+ return cache.get(section);
26
+ }
27
+ return await getConfigurationWorker(section, scopeUri);
40
28
  },
41
29
  onDidChangeConfiguration(cb) {
42
30
  callbacks.push(cb);
43
31
  },
44
32
  };
45
- function getConfigurationWorker(section, scopeUri) {
46
- var _a;
47
- return __awaiter(this, void 0, void 0, function* () {
48
- return (_a = (yield connection.workspace.getConfiguration({ scopeUri, section }))) !== null && _a !== void 0 ? _a : undefined /* replace null to undefined */;
49
- });
33
+ async function getConfigurationWorker(section, scopeUri) {
34
+ return (await connection.workspace.getConfiguration({ scopeUri, section })) ?? undefined /* replace null to undefined */;
50
35
  }
51
36
  }
52
37
  exports.createConfigurationHost = createConfigurationHost;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
3
  exports.createDocuments = exports.combineContinuousChangeRanges = void 0;
3
4
  const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
@@ -47,7 +48,7 @@ class IncrementalScriptSnapshot {
47
48
  getLength: () => text.length,
48
49
  getChangeRange: (oldSnapshot) => {
49
50
  if (!cache.has(oldSnapshot)) {
50
- const oldIndex = this.changes.findIndex(change => { var _a; return ((_a = change.snapshot) === null || _a === void 0 ? void 0 : _a.deref()) === oldSnapshot; });
51
+ const oldIndex = this.changes.findIndex(change => change.snapshot?.deref() === oldSnapshot);
51
52
  if (oldIndex >= 0) {
52
53
  const start = oldIndex + 1;
53
54
  const end = this.changes.indexOf(lastChange) + 1;
@@ -75,12 +76,11 @@ class IncrementalScriptSnapshot {
75
76
  return this.document;
76
77
  }
77
78
  clearUnReferenceVersions() {
78
- var _a;
79
79
  let versionToApply;
80
80
  for (let i = 0; i <= this.changes.length - 2; i++) {
81
81
  const change = this.changes[i];
82
82
  const nextChange = this.changes[i + 1];
83
- if (!((_a = change.snapshot) === null || _a === void 0 ? void 0 : _a.deref())) {
83
+ if (!change.snapshot?.deref()) {
84
84
  if (change.version !== nextChange.version) {
85
85
  versionToApply = change.version;
86
86
  }