@effect/language-service 0.52.0 → 0.53.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
@@ -129,7 +129,8 @@ Few options can be provided alongside the initialization of the Language Service
129
129
  "topLevelNamedReexports": "ignore", // for namespaceImportPackages, how should top level named re-exports (e.g. {pipe} from "effect") be treated? "ignore" will leave them as is, "follow" will rewrite them to the re-exported module (e.g. {pipe} from "effect/Function")
130
130
  "importAliases": { "Array": "Arr" }, // allows to chose some different names for import name aliases (only when not chosing to import the whole module) (default: {})
131
131
  "noExternal": false, // disables features that provides links to external websites (such as links to mermaidchart.com) (default: false)
132
- "keyPatterns": [{ "target": "service", "pattern": "default", "skipLeadingPath": ["src/"] }] // configure the key patterns; recommended reading more on the section "Configuring Key Patterns"
132
+ "keyPatterns": [{ "target": "service", "pattern": "default", "skipLeadingPath": ["src/"] }], // configure the key patterns; recommended reading more on the section "Configuring Key Patterns"
133
+ "layerGraphFollowDepth": 0 // controls the depth level that the layer graph will follow when resolving layer dependencies, depth is counted only when exiting the currently hovered/analyzed layer definition (default: 0)
133
134
  }
134
135
  ]
135
136
  }
package/cli.js CHANGED
@@ -26990,6 +26990,7 @@ var getZshCompletions2 = (self, state = {
26990
26990
 
26991
26991
  // node_modules/.pnpm/@effect+cli@0.71.0_@effect+platform@0.92.1_@effect+printer-ansi@0.46.0_@effect+printer@0.46.0_effect@3.18.4/node_modules/@effect/cli/dist/esm/Options.js
26992
26992
  var all7 = all6;
26993
+ var boolean5 = boolean4;
26993
26994
  var choice3 = choice2;
26994
26995
  var directory2 = directory;
26995
26996
  var file3 = file2;
@@ -30956,7 +30957,8 @@ var getModuleFilePath = fn("getModuleFilePath")(
30956
30957
  var getTypeScriptApisUtils = fn("getTypeScriptApisFile")(
30957
30958
  function* (dirPath4) {
30958
30959
  const filePath = yield* getModuleFilePath(dirPath4, "typescript");
30959
- const sourceFile = yield* getUnpatchedSourceFile(filePath);
30960
+ const sourceText = yield* getSourceFileText(filePath);
30961
+ const sourceFile = yield* getUnpatchedSourceFile(filePath, sourceText);
30960
30962
  const bodyWithoutBundlerComment = yield* omitBundlerSourceFileComment(
30961
30963
  sourceFile.text.split("\n").map((line4) => ` ${line4}`).join("\n")
30962
30964
  );
@@ -31069,27 +31071,31 @@ var applyTextChanges = fn("applyTextChanges")(
31069
31071
  return newSourceText;
31070
31072
  }
31071
31073
  );
31072
- var getUnpatchedSourceFile = fn("getUnpatchedSourceFile")(function* (filePath) {
31074
+ var getSourceFileText = fn("getSourceFileText")(function* (filePath) {
31073
31075
  const fs = yield* FileSystem;
31074
- const ts = yield* getTypeScript;
31075
- const sourceText = yield* fs.readFileString(filePath);
31076
- const sourceFile = ts.createSourceFile(
31077
- filePath,
31078
- sourceText,
31079
- ts.ScriptTarget.ES2022,
31080
- true
31081
- );
31082
- const { revertChanges } = yield* extractAppliedEffectLspPatches(sourceFile);
31083
- if (revertChanges.length === 0) return sourceFile;
31084
- const newSourceText = yield* applyTextChanges(sourceText, revertChanges);
31085
- const newSourceFile = ts.createSourceFile(
31086
- filePath,
31087
- newSourceText,
31088
- ts.ScriptTarget.ES2022,
31089
- true
31090
- );
31091
- return newSourceFile;
31076
+ return yield* fs.readFileString(filePath);
31092
31077
  });
31078
+ var getUnpatchedSourceFile = fn("getUnpatchedSourceFile")(
31079
+ function* (filePath, sourceText) {
31080
+ const ts = yield* getTypeScript;
31081
+ const sourceFile = ts.createSourceFile(
31082
+ filePath,
31083
+ sourceText,
31084
+ ts.ScriptTarget.ES2022,
31085
+ true
31086
+ );
31087
+ const { revertChanges } = yield* extractAppliedEffectLspPatches(sourceFile);
31088
+ if (revertChanges.length === 0) return sourceFile;
31089
+ const newSourceText = yield* applyTextChanges(sourceText, revertChanges);
31090
+ const newSourceFile = ts.createSourceFile(
31091
+ filePath,
31092
+ newSourceText,
31093
+ ts.ScriptTarget.ES2022,
31094
+ true
31095
+ );
31096
+ return newSourceFile;
31097
+ }
31098
+ );
31093
31099
  var omitBundlerSourceFileComment = fn("omitBundlerSourceFileComment")(
31094
31100
  function* (originalSourceText) {
31095
31101
  const ts = yield* getTypeScript;
@@ -31199,7 +31205,8 @@ var defaults = {
31199
31205
  skipLeadingPath: ["src/"]
31200
31206
  }],
31201
31207
  extendedKeyDetection: false,
31202
- pipeableMinArgCount: 1
31208
+ pipeableMinArgCount: 1,
31209
+ layerGraphFollowDepth: 0
31203
31210
  };
31204
31211
  function parseKeyPatterns(patterns) {
31205
31212
  const result = [];
@@ -31235,7 +31242,8 @@ function parse4(config2) {
31235
31242
  noExternal: isObject(config2) && hasProperty(config2, "noExternal") && isBoolean(config2.noExternal) ? config2.noExternal : defaults.noExternal,
31236
31243
  keyPatterns: isObject(config2) && hasProperty(config2, "keyPatterns") && isArray(config2.keyPatterns) ? parseKeyPatterns(config2.keyPatterns) : defaults.keyPatterns,
31237
31244
  extendedKeyDetection: isObject(config2) && hasProperty(config2, "extendedKeyDetection") && isBoolean(config2.extendedKeyDetection) ? config2.extendedKeyDetection : defaults.extendedKeyDetection,
31238
- pipeableMinArgCount: isObject(config2) && hasProperty(config2, "pipeableMinArgCount") && isNumber(config2.pipeableMinArgCount) ? config2.pipeableMinArgCount : defaults.pipeableMinArgCount
31245
+ pipeableMinArgCount: isObject(config2) && hasProperty(config2, "pipeableMinArgCount") && isNumber(config2.pipeableMinArgCount) ? config2.pipeableMinArgCount : defaults.pipeableMinArgCount,
31246
+ layerGraphFollowDepth: isObject(config2) && hasProperty(config2, "layerGraphFollowDepth") && isNumber(config2.layerGraphFollowDepth) ? config2.layerGraphFollowDepth : defaults.layerGraphFollowDepth
31239
31247
  };
31240
31248
  }
31241
31249
 
@@ -35665,6 +35673,13 @@ var moduleNames = choice3("module", [
35665
35673
  repeated4,
35666
35674
  withDescription3("The name of the module to patch.")
35667
35675
  );
35676
+ var force = boolean5("force").pipe(
35677
+ withDefault3(false),
35678
+ withDescription3("Force patch even if already patched.")
35679
+ );
35680
+ var getPatchedMarker = (version) => {
35681
+ return `"use effect-lsp-patch-version ${version}";`;
35682
+ };
35668
35683
  var getPatchesForModule = fn("getPatchesForModule")(
35669
35684
  function* (moduleName, dirPath4, version, sourceFile) {
35670
35685
  const ts = yield* getTypeScript;
@@ -35827,6 +35842,16 @@ var getPatchesForModule = fn("getPatchesForModule")(
35827
35842
  version
35828
35843
  )
35829
35844
  );
35845
+ patches.push(
35846
+ yield* makeEffectLspPatchChange(
35847
+ sourceFile.text,
35848
+ insertCheckSourceFilePosition.value.position,
35849
+ insertCheckSourceFilePosition.value.position,
35850
+ getPatchedMarker(version) + "\n",
35851
+ "\n",
35852
+ version
35853
+ )
35854
+ );
35830
35855
  return patches;
35831
35856
  }
35832
35857
  );
@@ -35850,8 +35875,8 @@ var printRememberPrepareScript = fn("printRememberPrepareScript")(function* () {
35850
35875
  }, ignore2);
35851
35876
  var patch9 = make58(
35852
35877
  "patch",
35853
- { dirPath: dirPath2, moduleNames },
35854
- fn("patch")(function* ({ dirPath: dirPath4, moduleNames: moduleNames3 }) {
35878
+ { dirPath: dirPath2, moduleNames, force },
35879
+ fn("patch")(function* ({ dirPath: dirPath4, force: force2, moduleNames: moduleNames3 }) {
35855
35880
  const fs = yield* FileSystem;
35856
35881
  const { version: effectLspVersion } = yield* getPackageJsonData(__dirname);
35857
35882
  yield* logDebug2(`Searching for typescript in ${dirPath4}...`);
@@ -35862,7 +35887,16 @@ var patch9 = make58(
35862
35887
  yield* logDebug2(`Searching ${moduleName}...`);
35863
35888
  const filePath = yield* getModuleFilePath(dirPath4, moduleName);
35864
35889
  yield* logDebug2(`Reading ${moduleName} from ${filePath}...`);
35865
- const sourceFile = yield* getUnpatchedSourceFile(filePath);
35890
+ const sourceText = yield* getSourceFileText(filePath);
35891
+ yield* logDebug2(
35892
+ `Checking if ${filePath} is already patched with marker ${getPatchedMarker(effectLspVersion)}...`
35893
+ );
35894
+ if (!force2 && sourceText.indexOf(getPatchedMarker(effectLspVersion)) !== -1) {
35895
+ yield* logInfo2(`${filePath} is already patched with version ${effectLspVersion}, skipped.`);
35896
+ continue;
35897
+ }
35898
+ yield* logDebug2(`Parsing ${moduleName}...`);
35899
+ const sourceFile = yield* getUnpatchedSourceFile(filePath, sourceText);
35866
35900
  yield* logDebug2(`Collecting patches for ${moduleName}...`);
35867
35901
  const patches = yield* getPatchesForModule(moduleName, dirPath4, effectLspVersion, sourceFile);
35868
35902
  const newSourceText = yield* applyTextChanges(sourceFile.text, patches);
@@ -35896,8 +35930,10 @@ var unpatch = make58(
35896
35930
  for (const moduleName of modulesToUnpatch) {
35897
35931
  yield* logDebug2(`Resolving ${moduleName}...`);
35898
35932
  const filePath = yield* getModuleFilePath(dirPath4, moduleName);
35933
+ yield* logDebug2(`Reading ${moduleName} from ${filePath}...`);
35934
+ const sourceText = yield* getSourceFileText(filePath);
35899
35935
  yield* logDebug2(`Unpatching ${filePath}...`);
35900
- const sourceFile = yield* getUnpatchedSourceFile(filePath);
35936
+ const sourceFile = yield* getUnpatchedSourceFile(filePath, sourceText);
35901
35937
  yield* logDebug2(`Writing ${filePath}...`);
35902
35938
  yield* fs.writeFileString(filePath, sourceFile.text);
35903
35939
  yield* logInfo2(`${filePath} unpatched successfully.`);