@algorandfoundation/puya-ts 1.0.1 → 1.0.2-beta.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.
package/README.md CHANGED
@@ -15,3 +15,4 @@ Algorand TypeScript is compiled for execution on the AVM by PuyaTs, a TypeScript
15
15
  - [CLI Guide](https://algorandfoundation.github.io/puya-ts/documents/Compiler_CLI_Guide.html)
16
16
  - [Contribution Guide](CONTRIBUTING.md)
17
17
  - [Releases Notes](https://github.com/algorandfoundation/puya-ts/releases)
18
+ - [Migration Guides to 1.0.1](https://algorandfoundation.github.io/puya-ts/documents/Algorand_TypeScript_Migration_Guides.html)
package/bin/puyats-ls.mjs CHANGED
@@ -14,6 +14,7 @@ import fs__default from 'fs';
14
14
  import require$$3 from 'child_process';
15
15
  import { L as LogLevel, k as distinct, C as Constants, I as InternalError, l as logger, a as LoggingContext, n as isIn, o as LogSource, z as zipStrict, r as resolvePuyaPath } from '../resolve-puya-path-LGppZCBg.js';
16
16
  import EventEmitter from 'node:events';
17
+ import { globSync } from 'glob';
17
18
  import 'arcsecond';
18
19
  import 'node:fs';
19
20
  import 'pathe';
@@ -25,7 +26,6 @@ import 'node:url';
25
26
  import 'cross-spawn';
26
27
  import 'change-case';
27
28
  import 'polytype';
28
- import 'glob';
29
29
  import 'minimatch';
30
30
  import 'chalk';
31
31
  import 'signal-exit';
@@ -11400,6 +11400,39 @@ function logCaughtExpression(e) {
11400
11400
  }
11401
11401
  }
11402
11402
 
11403
+ function normalisedUri(args) {
11404
+ if ('fsPath' in args) {
11405
+ const resolvedFileName = globSync(args.fsPath, { absolute: true })[0];
11406
+ return URI.file(resolvedFileName ?? args.fsPath);
11407
+ }
11408
+ else {
11409
+ const filePath = URI.parse(args.uri).fsPath;
11410
+ return normalisedUri({ fsPath: filePath });
11411
+ }
11412
+ }
11413
+ function createNormalisedTextDocumentConnection(connection) {
11414
+ return {
11415
+ onDidOpenTextDocument(handler) {
11416
+ return connection.onDidOpenTextDocument((params) => handler({ textDocument: { ...params.textDocument, uri: normalisedUri({ uri: params.textDocument.uri }).toString() } }));
11417
+ },
11418
+ onDidChangeTextDocument(handler) {
11419
+ return connection.onDidChangeTextDocument((params) => handler({ ...params, textDocument: { ...params.textDocument, uri: normalisedUri({ uri: params.textDocument.uri }).toString() } }));
11420
+ },
11421
+ onDidCloseTextDocument(handler) {
11422
+ return connection.onDidCloseTextDocument((params) => handler({ textDocument: { ...params.textDocument, uri: normalisedUri({ uri: params.textDocument.uri }).toString() } }));
11423
+ },
11424
+ onWillSaveTextDocument(handler) {
11425
+ return connection.onWillSaveTextDocument((params) => handler({ ...params, textDocument: { ...params.textDocument, uri: normalisedUri({ uri: params.textDocument.uri }).toString() } }));
11426
+ },
11427
+ onWillSaveTextDocumentWaitUntil(handler) {
11428
+ return connection.onWillSaveTextDocumentWaitUntil((params, edits) => handler({ ...params, textDocument: { ...params.textDocument, uri: normalisedUri({ uri: params.textDocument.uri }).toString() } }, edits));
11429
+ },
11430
+ onDidSaveTextDocument(handler) {
11431
+ return connection.onDidSaveTextDocument((params) => handler({ textDocument: { ...params.textDocument, uri: normalisedUri({ uri: params.textDocument.uri }).toString() } }));
11432
+ },
11433
+ };
11434
+ }
11435
+
11403
11436
  let CompileWorker = (() => {
11404
11437
  let _instanceExtraInitializers = [];
11405
11438
  let _stop_decorators;
@@ -11437,17 +11470,16 @@ let CompileWorker = (() => {
11437
11470
  try {
11438
11471
  const work = this.queue.tryDequeue();
11439
11472
  if (work) {
11440
- switch (work.type) {
11441
- case 'workspace':
11442
- this.activeBuild = new AbortController();
11443
- await this.compileWorkspaces(work, this.activeBuild.signal);
11444
- delete this.activeBuild;
11445
- break;
11446
- }
11473
+ logger.debug(undefined, `[Compile Worker] Found work ${work.workspaces.join(', ')}`);
11474
+ this.activeBuild = new AbortController();
11475
+ await this.compileWorkspaces(work, this.activeBuild.signal);
11476
+ delete this.activeBuild;
11447
11477
  }
11448
11478
  else {
11479
+ logger.debug(undefined, `[Compile Worker] No work, sleeping`);
11449
11480
  this.sleeping = Promise.withResolvers();
11450
11481
  await this.sleeping.promise;
11482
+ delete this.sleeping;
11451
11483
  }
11452
11484
  }
11453
11485
  catch (e) {
@@ -11463,8 +11495,14 @@ let CompileWorker = (() => {
11463
11495
  await this.stopped.promise;
11464
11496
  }
11465
11497
  onCompileTriggerQueueItemQueued() {
11466
- this.activeBuild?.abort('Build has been superseded');
11467
- this.sleeping?.resolve();
11498
+ if (this.activeBuild) {
11499
+ logger.debug(undefined, `[Compile Worker] New work, aborting active build`);
11500
+ this.activeBuild.abort('Build has been superseded');
11501
+ }
11502
+ else if (this.sleeping) {
11503
+ logger.debug(undefined, `[Compile Worker] New work, waking worker`);
11504
+ this.sleeping.resolve();
11505
+ }
11468
11506
  }
11469
11507
  async compileWorkspaces(workspaceTrigger, abortSignal) {
11470
11508
  logger.debug(undefined, `[Workspace Compile] \n${workspaceTrigger.workspaces.join('\n')}`);
@@ -11489,7 +11527,7 @@ let CompileWorker = (() => {
11489
11527
  sourceFileProvider({ readFile, fileExists }) {
11490
11528
  return {
11491
11529
  readFile(fileName) {
11492
- const fileUri = URI.file(fileName).toString();
11530
+ const fileUri = normalisedUri({ fsPath: fileName }).toString();
11493
11531
  const doc = documents.get(fileUri);
11494
11532
  if (doc) {
11495
11533
  documentVersions[fileUri] = doc.version;
@@ -11498,7 +11536,7 @@ let CompileWorker = (() => {
11498
11536
  return readFile(fileName);
11499
11537
  },
11500
11538
  fileExists(fileName) {
11501
- const fileUri = URI.file(fileName).toString();
11539
+ const fileUri = normalisedUri({ fsPath: fileName }).toString();
11502
11540
  return Boolean(documents.get(fileUri)) || fileExists(fileName);
11503
11541
  },
11504
11542
  };
@@ -11659,7 +11697,7 @@ let PuyaLanguageServer = (() => {
11659
11697
  connection.onShutdown(this.shutdown.bind(this));
11660
11698
  }
11661
11699
  start() {
11662
- this.documents.listen(this.connection);
11700
+ this.documents.listen(createNormalisedTextDocumentConnection(this.connection));
11663
11701
  this.connection.listen();
11664
11702
  this.compileWorker.start();
11665
11703
  }
@@ -11670,7 +11708,7 @@ let PuyaLanguageServer = (() => {
11670
11708
  logger.debug(undefined, '[PuyaLanguageServer] Shutdown');
11671
11709
  }
11672
11710
  initialize(params) {
11673
- this.workspaceFolders.push(...(params.workspaceFolders?.map((f) => f.uri) ?? []));
11711
+ this.workspaceFolders.push(...(params.workspaceFolders?.map((f) => normalisedUri({ uri: f.uri }).toString()) ?? []));
11674
11712
  this.triggers.enqueue({
11675
11713
  type: 'workspace',
11676
11714
  workspaces: this.workspaceFolders,
@@ -11699,8 +11737,9 @@ let PuyaLanguageServer = (() => {
11699
11737
  documentDidChangeContent(params) {
11700
11738
  if (this.stopping)
11701
11739
  return;
11702
- logger.debug(undefined, `[Document Changed]: ${params.document.uri}`);
11703
- this.diagnosticsMgr.setDiagnostics({ fileUri: params.document.uri, version: params.document.version, diagnostics: 'pending' });
11740
+ const normalizedDocumentUri = normalisedUri({ uri: params.document.uri }).toString();
11741
+ logger.debug(undefined, `[Document Changed]: ${normalizedDocumentUri}`);
11742
+ this.diagnosticsMgr.setDiagnostics({ fileUri: normalizedDocumentUri, version: params.document.version, diagnostics: 'pending' });
11704
11743
  this.triggers.enqueue({
11705
11744
  type: 'workspace',
11706
11745
  workspaces: this.workspaceFolders,