@lvce-editor/editor-worker 19.78.0 → 19.78.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4174,6 +4174,34 @@ const getTokensViewport = (editor, startLineIndex, endLineIndex) => {
4174
4174
  };
4175
4175
  };
4176
4176
 
4177
+ const state$c = {};
4178
+ const create$a = () => create$g({
4179
+ commandMap: {},
4180
+ send: port => invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, 'FileSystem.connect')
4181
+ });
4182
+ const invoke$b = async (method, ...args) => {
4183
+ state$c.rpcPromise ||= create$a();
4184
+ let rpc;
4185
+ try {
4186
+ const {
4187
+ rpcPromise
4188
+ } = state$c;
4189
+ rpc = await rpcPromise;
4190
+ } catch (error) {
4191
+ delete state$c.rpcPromise;
4192
+ throw error;
4193
+ }
4194
+ return rpc.invoke(method, ...args);
4195
+ };
4196
+
4197
+ const invoke$a = async (applicationId, method, ...args) => {
4198
+ return applicationId === undefined ? invoke$e(method, ...args) : invoke$e('Application.execute', applicationId, method, ...args);
4199
+ };
4200
+ const readFile$1 = async (applicationId, uri, encoding) => {
4201
+ const args = encoding === undefined ? [uri] : [uri, encoding];
4202
+ return applicationId === undefined ? invoke$b('FileSystem.readFile', ...args) : invoke$b('ApplicationFileSystem.execute', applicationId, 'readFile', ...args);
4203
+ };
4204
+
4177
4205
  const magic = 0x53_48_43_31;
4178
4206
  const maxBytes = 8 * 1024 * 1024;
4179
4207
  const checksum = buffer => {
@@ -4321,7 +4349,7 @@ const decode = (buffer, lineLengths, now) => {
4321
4349
  if (total !== lineLengths[i]) {
4322
4350
  return undefined;
4323
4351
  }
4324
- if (line.embeddedResultIndex !== undefined && (!embeddedResults[line.embeddedResultIndex] || line.embeddedLanguageStart === undefined || line.embeddedLanguageEnd === undefined || line.embeddedLanguageStart > line.embeddedLanguageEnd || line.embeddedLanguageEnd > lineLengths[i])) {
4352
+ if (line.embeddedResultIndex !== undefined && (!embeddedResults[line.embeddedResultIndex] || line.embeddedLanguageStart === undefined || line.embeddedLanguageEnd === undefined || line.embeddedLanguageStart > lineLengths[i] || line.embeddedLanguageStart > line.embeddedLanguageEnd && (embeddedResults[line.embeddedResultIndex].isFull || embeddedResults[line.embeddedResultIndex].result.tokens.length > 0) || line.embeddedLanguageEnd > lineLengths[i])) {
4325
4353
  return undefined;
4326
4354
  }
4327
4355
  }
@@ -11048,7 +11076,7 @@ function h() {
11048
11076
 
11049
11077
  // Hash the entire static module graph, including re-exports and literal dynamic
11050
11078
  // imports. Unknown import targets cannot produce a trustworthy persistent key.
11051
- const getFingerprint = async paths => {
11079
+ const getFingerprint = async (paths, readApplicationSource) => {
11052
11080
  await init();
11053
11081
  const sources = new Map();
11054
11082
  const signal = AbortSignal.timeout(5000);
@@ -11057,20 +11085,30 @@ const getFingerprint = async paths => {
11057
11085
  if (sources.has(url)) {
11058
11086
  return;
11059
11087
  }
11060
- if (!/^https?:/.test(url)) {
11088
+ if (!/^(?:https?|lvce-oss):/.test(url)) {
11061
11089
  throw new Error('Unsupported tokenizer URL');
11062
11090
  }
11063
11091
  if (sources.size >= 256) {
11064
11092
  throw new Error('Tokenizer module graph is too large');
11065
11093
  }
11066
- const response = await fetch(url, {
11067
- cache: 'no-cache',
11068
- signal
11069
- });
11070
- if (!response.ok) {
11071
- throw new Error('Cannot read tokenizer source');
11094
+ signal.throwIfAborted();
11095
+ let source;
11096
+ if (url.startsWith('lvce-oss:')) {
11097
+ if (!readApplicationSource) {
11098
+ throw new Error('No application source reader');
11099
+ }
11100
+ source = await readApplicationSource(url);
11101
+ } else {
11102
+ const response = await fetch(url, {
11103
+ cache: 'no-cache',
11104
+ signal
11105
+ });
11106
+ if (!response.ok) {
11107
+ throw new Error('Cannot read tokenizer source');
11108
+ }
11109
+ source = await response.text();
11072
11110
  }
11073
- const source = await response.text();
11111
+ signal.throwIfAborted();
11074
11112
  totalBytes += source.length * 2;
11075
11113
  if (totalBytes > 8 * 1024 * 1024) {
11076
11114
  throw new Error('Tokenizer module is too large');
@@ -11082,7 +11120,7 @@ const getFingerprint = async paths => {
11082
11120
  // import.meta can expose resources outside the parsed module graph.
11083
11121
  throw new Error('Tokenizer uses import.meta');
11084
11122
  }
11085
- if (!entry.specifier || !entry.specifier.startsWith('.') && !entry.specifier.startsWith('/') && !/^https?:/.test(entry.specifier)) {
11123
+ if (!entry.specifier || !entry.specifier.startsWith('.') && !entry.specifier.startsWith('/') && !/^(?:https?|lvce-oss):/.test(entry.specifier)) {
11086
11124
  throw new Error('Tokenizer has an unresolved dependency');
11087
11125
  }
11088
11126
  await visit(new URL(entry.specifier, url).href);
@@ -11113,12 +11151,16 @@ const getKey$2 = async (editor, start, end) => {
11113
11151
  }
11114
11152
  try {
11115
11153
  const paths = getTokenizePaths();
11116
- const catalog = JSON.stringify(paths);
11154
+ const catalog = JSON.stringify([editor.applicationId, paths]);
11117
11155
  let fingerprint = fingerprints.get(catalog);
11118
11156
  if (!fingerprint) {
11119
11157
  fingerprint = (async () => {
11120
11158
  try {
11121
- return await getFingerprint(paths);
11159
+ return await getFingerprint(paths, url => invoke$a(editor.applicationId, 'Ajax.getText', url, {
11160
+ cache: 'no-cache',
11161
+ retry: 0,
11162
+ timeout: 5000
11163
+ }));
11122
11164
  } catch {
11123
11165
  return '';
11124
11166
  }
@@ -11987,14 +12029,14 @@ const getVisible$1 = async (editor, syncIncremental) => {
11987
12029
  };
11988
12030
  };
11989
12031
 
11990
- const state$c = {
12032
+ const state$b = {
11991
12033
  enabled: false
11992
12034
  };
11993
12035
  const setEnabled = value => {
11994
- state$c.enabled = value;
12036
+ state$b.enabled = value;
11995
12037
  };
11996
12038
  const getEnabled = () => {
11997
- return state$c.enabled;
12039
+ return state$b.enabled;
11998
12040
  };
11999
12041
 
12000
12042
  // TODO this should be in a separate scrolling module
@@ -12325,7 +12367,7 @@ const send$2 = (rpcId, rpc, status) => {
12325
12367
  return delivery.running || start(delivery);
12326
12368
  };
12327
12369
 
12328
- const state$b = Object.create(null);
12370
+ const state$a = Object.create(null);
12329
12371
 
12330
12372
  /**
12331
12373
  * Register a listener for a specific event type
@@ -12335,13 +12377,13 @@ const state$b = Object.create(null);
12335
12377
  const registerListener$1 = (listenerType, rpcId) => {
12336
12378
  number(listenerType);
12337
12379
  number(rpcId);
12338
- if (!Object.hasOwn(state$b, listenerType)) {
12339
- state$b[listenerType] = [];
12380
+ if (!Object.hasOwn(state$a, listenerType)) {
12381
+ state$a[listenerType] = [];
12340
12382
  }
12341
12383
 
12342
12384
  // Avoid duplicate registrations
12343
- if (!state$b[listenerType].includes(rpcId)) {
12344
- state$b[listenerType].push(rpcId);
12385
+ if (!state$a[listenerType].includes(rpcId)) {
12386
+ state$a[listenerType].push(rpcId);
12345
12387
  }
12346
12388
  };
12347
12389
 
@@ -12356,10 +12398,10 @@ const unregisterListener$1 = (listenerType, rpcId) => {
12356
12398
  if (listenerType === EditorSelection$1) {
12357
12399
  dispose$5(rpcId);
12358
12400
  }
12359
- if (Object.hasOwn(state$b, listenerType)) {
12360
- const index = state$b[listenerType].indexOf(rpcId);
12401
+ if (Object.hasOwn(state$a, listenerType)) {
12402
+ const index = state$a[listenerType].indexOf(rpcId);
12361
12403
  if (index !== -1) {
12362
- state$b[listenerType].splice(index, 1);
12404
+ state$a[listenerType].splice(index, 1);
12363
12405
  }
12364
12406
  }
12365
12407
  };
@@ -12371,7 +12413,7 @@ const unregisterListener$1 = (listenerType, rpcId) => {
12371
12413
  */
12372
12414
  const getListeners = listenerType => {
12373
12415
  number(listenerType);
12374
- return state$b[listenerType] || [];
12416
+ return state$a[listenerType] || [];
12375
12417
  };
12376
12418
 
12377
12419
  /**
@@ -12470,34 +12512,6 @@ const splitLines = lines => {
12470
12512
  return lines.split('\n');
12471
12513
  };
12472
12514
 
12473
- const state$a = {};
12474
- const create$a = () => create$g({
12475
- commandMap: {},
12476
- send: port => invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, 'FileSystem.connect')
12477
- });
12478
- const invoke$b = async (method, ...args) => {
12479
- state$a.rpcPromise ||= create$a();
12480
- let rpc;
12481
- try {
12482
- const {
12483
- rpcPromise
12484
- } = state$a;
12485
- rpc = await rpcPromise;
12486
- } catch (error) {
12487
- delete state$a.rpcPromise;
12488
- throw error;
12489
- }
12490
- return rpc.invoke(method, ...args);
12491
- };
12492
-
12493
- const invoke$a = async (applicationId, method, ...args) => {
12494
- return applicationId === undefined ? invoke$e(method, ...args) : invoke$e('Application.execute', applicationId, method, ...args);
12495
- };
12496
- const readFile$1 = async (applicationId, uri, encoding) => {
12497
- const args = encoding === undefined ? [uri] : [uri, encoding];
12498
- return applicationId === undefined ? invoke$b('FileSystem.readFile', ...args) : invoke$b('ApplicationFileSystem.execute', applicationId, 'readFile', ...args);
12499
- };
12500
-
12501
12515
  const notifyTabModifiedStatusChange = async (uri, modified, applicationId) => {
12502
12516
  try {
12503
12517
  await invoke$a(applicationId, 'Main.handleModifiedStatusChange', uri, modified);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.78.0",
3
+ "version": "19.78.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"