@effect/tsgo 0.14.5 → 0.15.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.
package/README.md CHANGED
@@ -22,7 +22,7 @@ This will guide you through the installation process, which includes:
22
22
  4. Hinting at any additional editor configuration needed to ensure the LSP is active.
23
23
 
24
24
  > [!NOTE]
25
- > At the moment, you still need the standard native TypeScript install (`@typescript/native-preview`) alongside `@effect/tsgo`.
25
+ > At the moment, you still need a native TypeScript install alongside `@effect/tsgo` — either `@typescript/native-preview` (nightlies) or `typescript` >= 7 (e.g. the 7.0 RC, `typescript@rc`). `effect-tsgo patch` and `effect-tsgo setup` detect and use whichever one is installed.
26
26
 
27
27
  ## Diagnostic Status
28
28
 
@@ -204437,17 +204437,47 @@ var FileReadError = class extends TaggedError("FileReadError") {
204437
204437
  //#endregion
204438
204438
  //#region package.json
204439
204439
  var name = "@effect/tsgo";
204440
- var version = "0.14.5";
204440
+ var version = "0.15.0";
204441
204441
 
204442
204442
  //#endregion
204443
204443
  //#region src/setup/consts.ts
204444
204444
  const LSP_PACKAGE_NAME = name;
204445
204445
  const LSP_PLUGIN_NAME = "@effect/language-service";
204446
204446
  const NATIVE_PREVIEW_PACKAGE_NAME = "@typescript/native-preview";
204447
+ const TYPESCRIPT_PACKAGE_NAME = "typescript";
204447
204448
  const PATCH_COMMAND = "effect-tsgo patch";
204448
204449
  const DEFAULT_LSP_VERSION = version;
204449
204450
  const DEFAULT_NATIVE_PREVIEW_VERSION = "latest";
204450
204451
  const TSCONFIG_SCHEMA_URL = "https://raw.githubusercontent.com/Effect-TS/tsgo/refs/heads/main/schema.json";
204452
+ /**
204453
+ * `typescript` package versions >= 7 ship the native Go-ported binary that this
204454
+ * tool patches. Older `typescript` releases (<= 6) are the JS compiler and must
204455
+ * not be treated as a native backend.
204456
+ */
204457
+ const isNativeTypescriptVersion = (version) => {
204458
+ const match = /\d+/.exec(version.trim());
204459
+ return match !== null && Number(match[0]) >= 7;
204460
+ };
204461
+ /** The `@typescript/native-preview` nightly backend (back-compat default). */
204462
+ const nativePreviewBackend = {
204463
+ packageName: NATIVE_PREVIEW_PACKAGE_NAME,
204464
+ platformPackagePrefix: "@typescript/native-preview",
204465
+ binaryName: "tsgo"
204466
+ };
204467
+ /** The `typescript` >= 7 backend (stable/RC releases). */
204468
+ const typescriptBackend = {
204469
+ packageName: TYPESCRIPT_PACKAGE_NAME,
204470
+ platformPackagePrefix: "@typescript/typescript",
204471
+ binaryName: "tsc",
204472
+ versionCheck: (pkg) => isNativeTypescriptVersion(pkg.version ?? "0")
204473
+ };
204474
+ /**
204475
+ * Resolve the VS Code `typescript.native-preview.tsdk` folder for a backend.
204476
+ * The "TypeScript (Native Preview)" extension reads the native install from
204477
+ * this path; for `@typescript/native-preview` it is `node_modules/<pkg>`, and
204478
+ * for `typescript` >= 7 it is `node_modules/typescript`.
204479
+ */
204480
+ const nativeBackendTsdkPath = (packageName) => "node_modules/" + packageName;
204451
204481
 
204452
204482
  //#endregion
204453
204483
  //#region src/setup/assessment.ts
@@ -204503,7 +204533,14 @@ const assessPackageJson = (input) => {
204503
204533
  return none$3();
204504
204534
  };
204505
204535
  const lspVersion = assessDependency(LSP_PACKAGE_NAME);
204506
- const nativePreviewVersion = assessDependency(NATIVE_PREVIEW_PACKAGE_NAME);
204536
+ const nativePreviewVersion = orElse(assessDependency(NATIVE_PREVIEW_PACKAGE_NAME), () => {
204537
+ const typescriptDep = assessDependency(TYPESCRIPT_PACKAGE_NAME);
204538
+ if (isSome(typescriptDep) && isNativeTypescriptVersion(typescriptDep.value.version)) return some({
204539
+ ...typescriptDep.value,
204540
+ packageName: TYPESCRIPT_PACKAGE_NAME
204541
+ });
204542
+ return none$3();
204543
+ });
204507
204544
  const prepareScript = "prepare" in (parsed.scripts ?? {}) ? some({
204508
204545
  script: parsed.scripts.prepare,
204509
204546
  hasPatch: parsed.scripts.prepare.toLowerCase().includes(PATCH_COMMAND)
@@ -204853,13 +204890,17 @@ const computePackageJsonChanges = (current, target) => {
204853
204890
  if (!rootObj) return emptyFileChangesResult();
204854
204891
  const ctx = createTrackerContext();
204855
204892
  const fileChange = tsInternal.textChanges.ChangeTracker.with(ctx, (tracker) => {
204893
+ const nativeBackendPackageName = match$8(target.nativePreviewVersion, {
204894
+ onNone: () => NATIVE_PREVIEW_PACKAGE_NAME,
204895
+ onSome: (dep) => dep.packageName ?? NATIVE_PREVIEW_PACKAGE_NAME
204896
+ });
204856
204897
  const shouldAddNativePreviewWithDependencyType = (dependencyType) => isSome(target.nativePreviewVersion) && isNone(current.nativePreviewVersion) && target.nativePreviewVersion.value.dependencyType === dependencyType;
204857
204898
  const ensureNativePreviewDependency = () => {
204858
204899
  if (isNone(target.nativePreviewVersion) || isSome(current.nativePreviewVersion)) return;
204859
204900
  const targetNativePreview = target.nativePreviewVersion.value;
204860
204901
  if (!findDependencyCollectionProperty(rootObj, targetNativePreview.dependencyType) && isSome(target.lspVersion) && target.lspVersion.value.dependencyType === targetNativePreview.dependencyType) return;
204861
- descriptions.push(`Add ${NATIVE_PREVIEW_PACKAGE_NAME}@${targetNativePreview.version} to ${targetNativePreview.dependencyType}`);
204862
- upsertDependency(tracker, current.sourceFile, rootObj, NATIVE_PREVIEW_PACKAGE_NAME, targetNativePreview);
204902
+ descriptions.push(`Add ${nativeBackendPackageName}@${targetNativePreview.version} to ${targetNativePreview.dependencyType}`);
204903
+ upsertDependency(tracker, current.sourceFile, rootObj, nativeBackendPackageName, targetNativePreview);
204863
204904
  };
204864
204905
  if (isSome(target.lspVersion)) {
204865
204906
  const targetDepType = target.lspVersion.value.dependencyType;
@@ -204879,7 +204920,7 @@ const computePackageJsonChanges = (current, target) => {
204879
204920
  const dependencyProperties = [import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral(LSP_PACKAGE_NAME), import_typescript.factory.createStringLiteral(targetVersion))];
204880
204921
  if (shouldAddNativePreviewWithDependencyType(targetDepType)) {
204881
204922
  const targetNativePreview = target.nativePreviewVersion.pipe(getOrUndefined);
204882
- if (targetNativePreview) dependencyProperties.push(import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral(NATIVE_PREVIEW_PACKAGE_NAME), import_typescript.factory.createStringLiteral(targetNativePreview.version)));
204923
+ if (targetNativePreview) dependencyProperties.push(import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral(nativeBackendPackageName), import_typescript.factory.createStringLiteral(targetNativePreview.version)));
204883
204924
  }
204884
204925
  const newDepsProp = import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral(targetDepType), import_typescript.factory.createObjectLiteralExpression(dependencyProperties, false));
204885
204926
  insertNodeAtEndOfList(tracker, current.sourceFile, rootObj.properties, newDepsProp);
@@ -204899,7 +204940,7 @@ const computePackageJsonChanges = (current, target) => {
204899
204940
  const dependencyProperties = [import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral(LSP_PACKAGE_NAME), import_typescript.factory.createStringLiteral(targetVersion))];
204900
204941
  if (shouldAddNativePreviewWithDependencyType(targetDepType)) {
204901
204942
  const targetNativePreview = target.nativePreviewVersion.pipe(getOrUndefined);
204902
- if (targetNativePreview) dependencyProperties.push(import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral(NATIVE_PREVIEW_PACKAGE_NAME), import_typescript.factory.createStringLiteral(targetNativePreview.version)));
204943
+ if (targetNativePreview) dependencyProperties.push(import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral(nativeBackendPackageName), import_typescript.factory.createStringLiteral(targetNativePreview.version)));
204903
204944
  }
204904
204945
  const newDepsProp = import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral(targetDepType), import_typescript.factory.createObjectLiteralExpression(dependencyProperties, false));
204905
204946
  insertNodeAtEndOfList(tracker, current.sourceFile, rootObj.properties, newDepsProp);
@@ -207320,8 +207361,12 @@ const gatherTargetState = (assessment, context) => gen(function* () {
207320
207361
  }
207321
207362
  ]
207322
207363
  });
207364
+ const nativeBackendPackage = match$8(assessment.packageJson.nativePreviewVersion, {
207365
+ onNone: () => NATIVE_PREVIEW_PACKAGE_NAME,
207366
+ onSome: (dep) => dep.packageName ?? NATIVE_PREVIEW_PACKAGE_NAME
207367
+ });
207323
207368
  const vscodeSettings = editors.includes("vscode") ? some({ settings: {
207324
- "typescript.native-preview.tsdk": "node_modules/@typescript/native-preview",
207369
+ "typescript.native-preview.tsdk": nativeBackendTsdkPath(nativeBackendPackage),
207325
207370
  "typescript.experimental.useTsgo": true,
207326
207371
  "js/ts.experimental.useTsgo": true
207327
207372
  } }) : none$3();
@@ -207357,19 +207402,19 @@ const setupCommand = make("setup").pipe(withDescription("Setup @effect/tsgo for
207357
207402
 
207358
207403
  //#endregion
207359
207404
  //#region src/cli.ts
207360
- var NativePreviewNotInstalledError = class extends TaggedError("NativePreviewNotInstalledError") {
207405
+ var NativeBackendNotInstalledError = class extends TaggedError("NativeBackendNotInstalledError") {
207361
207406
  get message() {
207362
- return "@typescript/native-preview is not installed. Please install it first: npm install @typescript/native-preview";
207407
+ return "No native TypeScript backend is installed. Install one of the following first: `@typescript/native-preview` or `typescript` (>= 7, e.g. `typescript@rc`).";
207363
207408
  }
207364
207409
  };
207365
207410
  var UnsupportedPlatformPackageError = class extends TaggedError("UnsupportedPlatformPackageError") {
207366
207411
  get message() {
207367
- return `Unable to resolve ${this.packageName}. Your platform may not be supported by @typescript/native-preview.`;
207412
+ return `Unable to resolve ${this.packageName}. Your platform may not be supported by the installed native TypeScript backend.`;
207368
207413
  }
207369
207414
  };
207370
207415
  var MissingTargetBinaryError = class extends TaggedError("MissingTargetBinaryError") {
207371
207416
  get message() {
207372
- return "TypeScript-Go binary not found at " + this.targetPath + ". Is @typescript/native-preview installed correctly?";
207417
+ return "Native TypeScript binary not found at " + this.targetPath + ". Is the native TypeScript backend installed correctly?";
207373
207418
  }
207374
207419
  };
207375
207420
  var ResolvePackagedBinaryError = class extends TaggedError("ResolvePackagedBinaryError") {
@@ -207397,24 +207442,74 @@ var VerificationFailedError = class extends TaggedError("VerificationFailedError
207397
207442
  return "Warning: verification failed for " + this.targetPath + ", but binary was patched. The binary may still work correctly.";
207398
207443
  }
207399
207444
  };
207400
- const getNativePreviewBinaryPath = gen(function* () {
207445
+ const probeBackend = (backend, cwdRequire, path) => {
207446
+ const isWin = process.platform === "win32";
207447
+ let mainPkg;
207448
+ try {
207449
+ mainPkg = cwdRequire(backend.packageName + "/package.json");
207450
+ } catch {
207451
+ return { _tag: "notInstalled" };
207452
+ }
207453
+ if (backend.versionCheck !== void 0 && !backend.versionCheck(mainPkg)) return { _tag: "notInstalled" };
207454
+ let mainPackageJsonPath;
207455
+ try {
207456
+ mainPackageJsonPath = cwdRequire.resolve(backend.packageName + "/package.json");
207457
+ } catch {
207458
+ return { _tag: "notInstalled" };
207459
+ }
207460
+ const backendRequire = node_module.createRequire(mainPackageJsonPath);
207461
+ const platformPackageName = backend.platformPackagePrefix + "-" + process.platform + "-" + process.arch;
207462
+ let platformPackageJsonPath;
207463
+ try {
207464
+ platformPackageJsonPath = backendRequire.resolve(platformPackageName + "/package.json");
207465
+ } catch {
207466
+ return {
207467
+ _tag: "unsupportedPlatform",
207468
+ packageName: platformPackageName
207469
+ };
207470
+ }
207471
+ const platformDir = path.dirname(platformPackageJsonPath);
207472
+ const binaryName = backend.binaryName + (isWin ? ".exe" : "");
207473
+ return {
207474
+ _tag: "resolved",
207475
+ path: path.join(platformDir, "lib", binaryName),
207476
+ binaryName: backend.binaryName
207477
+ };
207478
+ };
207479
+ /**
207480
+ * Resolve the native TypeScript binary to patch. The `@typescript/native-preview`
207481
+ * backend is tried first (back-compat), then the `typescript` >= 7 package so
207482
+ * that the TypeScript 7 RC/stable release is supported out of the box.
207483
+ *
207484
+ * Returns the target binary path plus the backend's base binary name (`tsgo` or
207485
+ * `tsc`); the latter selects the matching Effect-patched artifact from
207486
+ * `@effect/tsgo-*` (which ships separate `lib/tsgo` and `lib/tsc` builds).
207487
+ */
207488
+ const getNativeBackendBinaryPath = gen(function* () {
207401
207489
  const path = yield* Path;
207402
207490
  const cwdRequire = node_module.createRequire(path.join(process.cwd(), "noop.js"));
207403
- const nativePreviewPackageJsonPath = yield* try_({
207404
- try: () => cwdRequire.resolve("@typescript/native-preview/package.json"),
207405
- catch: () => new NativePreviewNotInstalledError({ details: "missing package" })
207406
- });
207407
- const nativePreviewRequire = node_module.createRequire(nativePreviewPackageJsonPath);
207408
- const platformPackageName = "@typescript/" + ("native-preview-" + process.platform + "-" + process.arch);
207409
- const platformPackageJsonPath = yield* try_({
207410
- try: () => nativePreviewRequire.resolve(platformPackageName + "/package.json"),
207411
- catch: () => new UnsupportedPlatformPackageError({ packageName: platformPackageName })
207412
- });
207413
- const platformDir = path.dirname(platformPackageJsonPath);
207414
- const binaryName = process.platform === "win32" ? "tsgo.exe" : "tsgo";
207415
- return path.join(platformDir, "lib", binaryName);
207491
+ const nativePreviewResult = probeBackend(nativePreviewBackend, cwdRequire, path);
207492
+ if (nativePreviewResult._tag === "resolved") return {
207493
+ targetPath: nativePreviewResult.path,
207494
+ binaryName: nativePreviewResult.binaryName
207495
+ };
207496
+ if (nativePreviewResult._tag === "unsupportedPlatform") return yield* fail(new UnsupportedPlatformPackageError({ packageName: nativePreviewResult.packageName }));
207497
+ const typescriptResult = probeBackend(typescriptBackend, cwdRequire, path);
207498
+ if (typescriptResult._tag === "resolved") return {
207499
+ targetPath: typescriptResult.path,
207500
+ binaryName: typescriptResult.binaryName
207501
+ };
207502
+ if (typescriptResult._tag === "unsupportedPlatform") return yield* fail(new UnsupportedPlatformPackageError({ packageName: typescriptResult.packageName }));
207503
+ return yield* fail(new NativeBackendNotInstalledError({ details: "no native backend found" }));
207416
207504
  });
207417
- const getPackagedBinaryPath = gen(function* () {
207505
+ /**
207506
+ * Resolve the Effect-patched binary to copy over the native target. The
207507
+ * `@effect/tsgo-*` platform package ships separate `lib/tsgo` (built from
207508
+ * `main`) and `lib/tsc` (built from `generated/stable`) artifacts; `binaryName`
207509
+ * selects the one matching the detected native backend so the correct build is
207510
+ * installed. Defaults to `tsgo` for the `get-exe-path` command.
207511
+ */
207512
+ const getPackagedBinaryPath = (binaryName = "tsgo") => gen(function* () {
207418
207513
  const fs = yield* FileSystem;
207419
207514
  const path = yield* Path;
207420
207515
  const packageName = "@effect/tsgo-" + process.platform + "-" + process.arch;
@@ -207424,17 +207519,17 @@ const getPackagedBinaryPath = gen(function* () {
207424
207519
  catch: () => new ResolvePackagedBinaryError({ reason: `Unable to resolve ${packageName}. Either your platform is unsupported, or the platform package is not installed.` })
207425
207520
  });
207426
207521
  const packageDir = path.dirname(packageJsonPath);
207427
- const binaryName = process.platform === "win32" ? "tsgo.exe" : "tsgo";
207428
- const exePath = path.join(packageDir, "lib", binaryName);
207522
+ const exeName = binaryName + (process.platform === "win32" ? ".exe" : "");
207523
+ const exePath = path.join(packageDir, "lib", exeName);
207429
207524
  if (!(yield* fs.exists(exePath))) return yield* fail(new ResolvePackagedBinaryError({ reason: "Executable not found: " + exePath }));
207430
207525
  return exePath;
207431
207526
  });
207432
207527
  const patch = gen(function* () {
207433
207528
  const fs = yield* FileSystem;
207434
207529
  const path = yield* Path;
207435
- const targetPath = yield* getNativePreviewBinaryPath;
207530
+ const { targetPath, binaryName } = yield* getNativeBackendBinaryPath;
207436
207531
  const backupPath = path.join(path.dirname(targetPath), path.basename(targetPath) + ".original");
207437
- const ourBinaryPath = yield* getPackagedBinaryPath;
207532
+ const ourBinaryPath = yield* getPackagedBinaryPath(binaryName);
207438
207533
  if (!(yield* fs.exists(targetPath))) return yield* fail(new MissingTargetBinaryError({ targetPath }));
207439
207534
  let actualBackupPath = backupPath;
207440
207535
  let counter = 1;
@@ -207464,7 +207559,7 @@ const patch = gen(function* () {
207464
207559
  const unpatch = gen(function* () {
207465
207560
  const fs = yield* FileSystem;
207466
207561
  const path = yield* Path;
207467
- const targetPath = yield* getNativePreviewBinaryPath;
207562
+ const { targetPath } = yield* getNativeBackendBinaryPath;
207468
207563
  const backupPath = path.join(path.dirname(targetPath), path.basename(targetPath) + ".original");
207469
207564
  if (!(yield* fs.exists(backupPath))) {
207470
207565
  yield* error("No backup found at " + backupPath + ". Nothing to restore.");
@@ -207483,7 +207578,7 @@ const unpatch = gen(function* () {
207483
207578
  });
207484
207579
  const patchCommand = make("patch").pipe(withDescription("Patch the Effect Language Service binary"), withHandler(() => patch));
207485
207580
  const unpatchCommand = make("unpatch").pipe(withDescription("Unpatch and restore the original TypeScript-Go binary"), withHandler(() => unpatch));
207486
- const getExePathCommand = make("get-exe-path").pipe(withDescription("Print the Effect Language Service executable path"), withHandler(() => getPackagedBinaryPath.pipe(flatMap((exePath) => log(exePath)))));
207581
+ const getExePathCommand = make("get-exe-path").pipe(withDescription("Print the Effect Language Service executable path"), withHandler(() => getPackagedBinaryPath().pipe(flatMap((exePath) => log(exePath)))));
207487
207582
  make("tsgo").pipe(withSubcommands([
207488
207583
  patchCommand,
207489
207584
  unpatchCommand,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect/tsgo",
3
- "version": "0.14.5",
3
+ "version": "0.15.0",
4
4
  "description": "Effect Language Service for TypeScript-Go — Effect-specific diagnostics and hover features.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -22,13 +22,13 @@
22
22
  "README.md"
23
23
  ],
24
24
  "optionalDependencies": {
25
- "@effect/tsgo-win32-x64": "0.14.5",
26
- "@effect/tsgo-win32-arm64": "0.14.5",
27
- "@effect/tsgo-linux-x64": "0.14.5",
28
- "@effect/tsgo-linux-arm64": "0.14.5",
29
- "@effect/tsgo-linux-arm": "0.14.5",
30
- "@effect/tsgo-darwin-x64": "0.14.5",
31
- "@effect/tsgo-darwin-arm64": "0.14.5"
25
+ "@effect/tsgo-win32-x64": "0.15.0",
26
+ "@effect/tsgo-win32-arm64": "0.15.0",
27
+ "@effect/tsgo-linux-x64": "0.15.0",
28
+ "@effect/tsgo-linux-arm64": "0.15.0",
29
+ "@effect/tsgo-linux-arm": "0.15.0",
30
+ "@effect/tsgo-darwin-x64": "0.15.0",
31
+ "@effect/tsgo-darwin-arm64": "0.15.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@effect/platform-node": "^4.0.0-beta.83",