@astrojs/ts-plugin
Advanced tools
Comparing version 0.3.0 to 0.4.0
# @astrojs/ts-plugin | ||
## 0.4.0 | ||
### Minor Changes | ||
- c8cdef9: Improved support for `.astro` imports inside JavaScript/TypeScript files: | ||
- Added support for finding file references inside Astro files | ||
- Added support for path completions for .astro, .md and .mdx files | ||
- Fixed cases where our TypeScript plugin would fail to load under certain circumstance | ||
- Fixed certain cases where Go to definition / implementation would fail | ||
## 0.3.0 | ||
@@ -4,0 +14,0 @@ |
@@ -1,44 +0,40 @@ | ||
var __create = Object.create; | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true}); | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, {get: all[name], enumerable: true}); | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __reExport = (target, module2, desc) => { | ||
if (module2 && typeof module2 === "object" || typeof module2 === "function") { | ||
for (let key of __getOwnPropNames(module2)) | ||
if (!__hasOwnProp.call(target, key) && key !== "default") | ||
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable}); | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return target; | ||
return to; | ||
}; | ||
var __toModule = (module2) => { | ||
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2); | ||
}; | ||
__markAsModule(exports); | ||
__export(exports, { | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var astro_snapshots_exports = {}; | ||
__export(astro_snapshots_exports, { | ||
AstroSnapshot: () => AstroSnapshot, | ||
AstroSnapshotManager: () => AstroSnapshotManager | ||
}); | ||
var import_astro2tsx = __toModule(require("./astro2tsx.js")); | ||
var import_source_mapper = __toModule(require("./source-mapper.js")); | ||
var import_utils = __toModule(require("./utils.js")); | ||
module.exports = __toCommonJS(astro_snapshots_exports); | ||
var import_trace_mapping = require("@jridgewell/trace-mapping"); | ||
var import_astro2tsx = require("./astro2tsx.js"); | ||
var import_utils = require("./utils.js"); | ||
class AstroSnapshot { | ||
constructor(typescript, fileName, astroCode, mapper, logger, isTsFile) { | ||
constructor(typescript, fileName, astroCode, traceMap, logger) { | ||
this.typescript = typescript; | ||
this.fileName = fileName; | ||
this.astroCode = astroCode; | ||
this.mapper = mapper; | ||
this.traceMap = traceMap; | ||
this.logger = logger; | ||
this.isTsFile = isTsFile; | ||
this.convertInternalCodePositions = false; | ||
} | ||
update(astroCode, mapper) { | ||
update(astroCode, traceMap) { | ||
this.astroCode = astroCode; | ||
this.mapper = mapper; | ||
this.traceMap = traceMap; | ||
this.lineOffsets = void 0; | ||
@@ -48,5 +44,2 @@ this.log("Updated Snapshot"); | ||
getOriginalTextSpan(textSpan) { | ||
if (!(0, import_utils.isNoTextSpanInGeneratedCode)(this.getText(), textSpan)) { | ||
return null; | ||
} | ||
const start = this.getOriginalOffset(textSpan.start); | ||
@@ -68,11 +61,11 @@ if (start === -1) { | ||
this.debug("try convert offset", generatedOffset, "/", lineOffset); | ||
const original = this.mapper.getOriginalPosition({ | ||
line: lineOffset.line - 1, | ||
character: lineOffset.offset - 1 | ||
const original = (0, import_trace_mapping.originalPositionFor)(this.traceMap, { | ||
line: lineOffset.line, | ||
column: lineOffset.offset | ||
}); | ||
this.toggleMappingMode(false); | ||
if (original.line === -1) { | ||
if (!original.line) { | ||
return -1; | ||
} | ||
const originalOffset = this.scriptInfo.lineOffsetToPosition(original.line + 1, original.character + 1); | ||
const originalOffset = this.scriptInfo.lineOffsetToPosition(original.line, original.column); | ||
this.debug("converted offset to", original, "/", originalOffset); | ||
@@ -92,3 +85,3 @@ return originalOffset; | ||
this.debug("positionToLineOffset for original code", position, lineOffset); | ||
return {line: lineOffset.line + 1, offset: lineOffset.character + 1}; | ||
return { line: lineOffset.line + 1, offset: lineOffset.character + 1 }; | ||
}; | ||
@@ -99,7 +92,7 @@ const lineOffsetToPosition = scriptInfo.lineOffsetToPosition.bind(scriptInfo); | ||
const position2 = lineOffsetToPosition(line, offset); | ||
this.debug("lineOffsetToPosition for generated code", {line, offset}, position2); | ||
this.debug("lineOffsetToPosition for generated code", { line, offset }, position2); | ||
return position2; | ||
} | ||
const position = this.offsetAt({line: line - 1, character: offset - 1}); | ||
this.debug("lineOffsetToPosition for original code", {line, offset}, position); | ||
const position = this.offsetAt({ line: line - 1, character: offset - 1 }); | ||
this.debug("lineOffsetToPosition for original code", { line, offset }, position); | ||
return position; | ||
@@ -116,3 +109,3 @@ }; | ||
if (high === 0) { | ||
return {line: 0, character: offset}; | ||
return { line: 0, character: offset }; | ||
} | ||
@@ -128,3 +121,3 @@ while (low < high) { | ||
const line = low - 1; | ||
return {line, character: offset - lineOffsets[line]}; | ||
return { line, character: offset - lineOffsets[line] }; | ||
} | ||
@@ -192,3 +185,3 @@ offsetAt(position) { | ||
this.logger = logger; | ||
this.snapshots = new Map(); | ||
this.snapshots = /* @__PURE__ */ new Map(); | ||
this.patchProjectServiceReadFile(); | ||
@@ -203,3 +196,6 @@ } | ||
} | ||
const scriptInfo = this.projectService.getOrCreateScriptInfoForNormalizedPath(this.typescript.server.toNormalizedPath(fileName), false); | ||
const scriptInfo = this.projectService.getOrCreateScriptInfoForNormalizedPath( | ||
this.typescript.server.toNormalizedPath(fileName), | ||
false | ||
); | ||
if (!scriptInfo) { | ||
@@ -230,12 +226,17 @@ this.logger.log("Was not able get snapshot for", fileName); | ||
try { | ||
const isTsFile = true; | ||
const result = (0, import_astro2tsx.astro2tsx)(astroCode, { | ||
filename: path.split("/").pop(), | ||
isTsFile | ||
}); | ||
const result = (0, import_astro2tsx.astro2tsx)(astroCode, path); | ||
const existingSnapshot = this.snapshots.get(path); | ||
if (existingSnapshot) { | ||
existingSnapshot.update(astroCode, new import_source_mapper.SourceMapper(result.map.mappings)); | ||
existingSnapshot.update(astroCode, new import_trace_mapping.TraceMap(result.map)); | ||
} else { | ||
this.snapshots.set(path, new AstroSnapshot(this.typescript, path, astroCode, new import_source_mapper.SourceMapper(result.map.mappings), this.logger, isTsFile)); | ||
this.snapshots.set( | ||
path, | ||
new AstroSnapshot( | ||
this.typescript, | ||
path, | ||
astroCode, | ||
new import_trace_mapping.TraceMap(result.map), | ||
this.logger | ||
) | ||
); | ||
} | ||
@@ -259,2 +260,2 @@ this.logger.log("Successfully read Astro file contents of", path); | ||
}); | ||
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3JjL2FzdHJvLXNuYXBzaG90cy50cyJdLAogICJtYXBwaW5ncyI6ICI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQ0EsdUJBQTBCO0FBRTFCLDJCQUE2QjtBQUM3QixtQkFBNkQ7QUFFdEQsb0JBQW9CO0FBQUEsRUFLMUIsWUFDUyxZQUNBLFVBQ0EsV0FDQSxRQUNBLFFBQ1EsVUFDZjtBQU5PO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDUTtBQVJULHdDQUErQjtBQUFBO0FBQUEsRUFXdkMsT0FBTyxXQUFtQixRQUFzQjtBQUMvQyxTQUFLLFlBQVk7QUFDakIsU0FBSyxTQUFTO0FBQ2QsU0FBSyxjQUFjO0FBQ25CLFNBQUssSUFBSTtBQUFBO0FBQUEsRUFHVixvQkF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JBQU8sT0FBTztBQUFBLFFBQ2YsU0FBUyxHQUFQO0FBQ0QsZUFBSyxPQUFPLElBQUksNkJBQTZCLElBQUk7QUFDakQsZUFBSyxPQUFPLE1BQU0sVUFBVSxDQUFDO0FBQUEsUUFDOUI7QUFBQSxNQUNELE9BQU87QUFDTixlQUFPLFNBQVMsSUFBSTtBQUFBLE1BQ3JCO0FBQUEsSUFDRDtBQUFBLEVBQ0Q7QUFDRDsiLAogICJuYW1lcyI6IFsibGluZU9mZnNldCIsICJwb3NpdGlvbiJdCn0K |
@@ -0,48 +1,35 @@ | ||
"use strict"; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __defProps = Object.defineProperties; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropDescs = Object.getOwnPropertyDescriptors; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value; | ||
var __spreadValues = (a, b) => { | ||
for (var prop in b || (b = {})) | ||
if (__hasOwnProp.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
if (__getOwnPropSymbols) | ||
for (var prop of __getOwnPropSymbols(b)) { | ||
if (__propIsEnum.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
} | ||
return a; | ||
}; | ||
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); | ||
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true}); | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, {get: all[name], enumerable: true}); | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __reExport = (target, module2, desc) => { | ||
if (module2 && typeof module2 === "object" || typeof module2 === "function") { | ||
for (let key of __getOwnPropNames(module2)) | ||
if (!__hasOwnProp.call(target, key) && key !== "default") | ||
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable}); | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return target; | ||
return to; | ||
}; | ||
var __toModule = (module2) => { | ||
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2); | ||
}; | ||
__markAsModule(exports); | ||
__export(exports, { | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var astro_sys_exports = {}; | ||
__export(astro_sys_exports, { | ||
createAstroSys: () => createAstroSys | ||
}); | ||
var import_typescript = __toModule(require("typescript")); | ||
var import_utils = __toModule(require("./utils.js")); | ||
module.exports = __toCommonJS(astro_sys_exports); | ||
var import_typescript = __toESM(require("typescript")); | ||
var import_utils = require("./utils.js"); | ||
function createAstroSys(logger) { | ||
const astroSys = __spreadProps(__spreadValues({}, import_typescript.default.sys), { | ||
const astroSys = { | ||
...import_typescript.default.sys, | ||
fileExists(path) { | ||
@@ -55,3 +42,3 @@ return import_typescript.default.sys.fileExists((0, import_utils.ensureRealAstroFilePath)(path)); | ||
} | ||
}); | ||
}; | ||
if (import_typescript.default.sys.realpath) { | ||
@@ -72,2 +59,2 @@ const realpath = import_typescript.default.sys.realpath; | ||
}); | ||
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3JjL2FzdHJvLXN5cy50cyJdLAogICJtYXBwaW5ncyI6ICI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUEsd0JBQWU7QUFFZixtQkFBcUY7QUFLOUUsd0JBQXdCLFFBQWdCO0FBQzlDLFFBQU0sV0FBc0IsaUNBQ3hCLDBCQUFHLE1BRHFCO0FBQUEsSUFFM0IsV0FBVyxNQUFjO0FBQ3hCLGFBQU8sMEJBQUcsSUFBSSxXQUFXLDBDQUF3QjtBQUFBO0FBQUEsSUFFbEQsY0FBYyxNQUFNLFlBQVksU0FBUyxTQUFTLE9BQU87QUFDeEQsWUFBTSxzQkFBdUIsbUNBQWMsSUFBSSxPQUFPO0FBRXRELGFBQU8sMEJBQUcsSUFBSSxjQUFjLE1BQU0scUJBQXFCLFNBQVMsU0FBUztBQUFBO0FBQUE7QUFJM0UsTUFBSSwwQkFBRyxJQUFJLFVBQVU7QUFDcEIsVUFBTSxXQUFXLDBCQUFHLElBQUk7QUFDeEIsYUFBUyxXQUFXLFNBQVUsTUFBTTtBQUNuQyxVQUFJLHlDQUF1QixPQUFPO0FBQ2pDLGVBQU8sU0FBUyxzQ0FBb0IsU0FBUztBQUFBO0FBRTlDLGFBQU8sU0FBUztBQUFBO0FBQUE7QUFJbEIsU0FBTztBQUFBOyIsCiAgIm5hbWVzIjogW10KfQo= | ||
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3JjL2FzdHJvLXN5cy50cyJdLAogICJtYXBwaW5ncyI6ICI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQSx3QkFBZTtBQUVmLG1CQUFxRjtBQUs5RSxTQUFTLGVBQWUsUUFBZ0I7QUFDOUMsUUFBTSxXQUFzQjtBQUFBLElBQzNCLEdBQUcsa0JBQUFBLFFBQUc7QUFBQSxJQUNOLFdBQVcsTUFBYztBQUN4QixhQUFPLGtCQUFBQSxRQUFHLElBQUksZUFBVyxzQ0FBd0IsSUFBSSxDQUFDO0FBQUEsSUFDdkQ7QUFBQSxJQUNBLGNBQWMsTUFBTSxZQUFZLFNBQVMsU0FBUyxPQUFPO0FBQ3hELFlBQU0sdUJBQXVCLGtDQUFjLENBQUMsR0FBRyxPQUFPLFFBQVE7QUFFOUQsYUFBTyxrQkFBQUEsUUFBRyxJQUFJLGNBQWMsTUFBTSxxQkFBcUIsU0FBUyxTQUFTLEtBQUs7QUFBQSxJQUMvRTtBQUFBLEVBQ0Q7QUFFQSxNQUFJLGtCQUFBQSxRQUFHLElBQUksVUFBVTtBQUNwQixVQUFNLFdBQVcsa0JBQUFBLFFBQUcsSUFBSTtBQUN4QixhQUFTLFdBQVcsU0FBVSxNQUFNO0FBQ25DLGNBQUkscUNBQXVCLElBQUksR0FBRztBQUNqQyxlQUFPLGFBQVMsa0NBQW9CLElBQUksQ0FBQyxJQUFJO0FBQUEsTUFDOUM7QUFDQSxhQUFPLFNBQVMsSUFBSTtBQUFBLElBQ3JCO0FBQUEsRUFDRDtBQUVBLFNBQU87QUFDUjsiLAogICJuYW1lcyI6IFsidHMiXQp9Cg== |
@@ -0,33 +1,29 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true}); | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, {get: all[name], enumerable: true}); | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
__markAsModule(exports); | ||
__export(exports, { | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var astro2tsx_exports = {}; | ||
__export(astro2tsx_exports, { | ||
astro2tsx: () => astro2tsx | ||
}); | ||
function astro2tsx(code, options) { | ||
const compiled = transformContent(code); | ||
const result = { | ||
code: compiled, | ||
map: { | ||
mappings: [] | ||
} | ||
}; | ||
return result; | ||
module.exports = __toCommonJS(astro2tsx_exports); | ||
var import_TSXService = require("./workers/TSXService"); | ||
function astro2tsx(content, fileName) { | ||
const tsx = (0, import_TSXService.convertToTSX)(content, { sourcefile: fileName }); | ||
return tsx; | ||
} | ||
function addProps(content) { | ||
let defaultExportType = "Record<string, any>"; | ||
if (/(interface|type) Props/.test(content)) { | ||
defaultExportType = "Props"; | ||
} | ||
return ` | ||
export default function (props: ${defaultExportType}): string;`; | ||
} | ||
function transformContent(content) { | ||
const ts = content.replace(/---/g, "///"); | ||
return ts + addProps(ts); | ||
} | ||
// Annotate the CommonJS export names for ESM import in node: | ||
@@ -37,2 +33,2 @@ 0 && (module.exports = { | ||
}); | ||
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3JjL2FzdHJvMnRzeC50cyJdLAogICJtYXBwaW5ncyI6ICI7Ozs7OztBQUFBO0FBQUE7QUFBQTtBQUFBO0FBaUJPLG1CQUFtQixNQUFjLFNBQTRDO0FBQ25GLFFBQU0sV0FBVyxpQkFBaUI7QUFFbEMsUUFBTSxTQUEwQjtBQUFBLElBQy9CLE1BQU07QUFBQSxJQUNOLEtBQUs7QUFBQSxNQUNKLFVBQVU7QUFBQTtBQUFBO0FBSVosU0FBTztBQUFBO0FBSVIsa0JBQWtCLFNBQXlCO0FBQzFDLE1BQUksb0JBQW9CO0FBRXhCLE1BQUkseUJBQXlCLEtBQUssVUFBVTtBQUMzQyx3QkFBb0I7QUFBQTtBQUdyQixTQUFPO0FBQUEsa0NBQTBDO0FBQUE7QUFHbEQsMEJBQTBCLFNBQWlCO0FBQzFDLFFBQU0sS0FBSyxRQUFRLFFBQVEsUUFBUTtBQUNuQyxTQUNDLEtBRUEsU0FBUztBQUFBOyIsCiAgIm5hbWVzIjogW10KfQo= | ||
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3JjL2FzdHJvMnRzeC50cyJdLAogICJtYXBwaW5ncyI6ICI7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFDQSx3QkFBNkI7QUFFdEIsU0FBUyxVQUFVLFNBQWlCLFVBQTZCO0FBQ3ZFLFFBQU0sVUFBTSxnQ0FBYSxTQUFTLEVBQUUsWUFBWSxTQUFTLENBQUM7QUFFMUQsU0FBTztBQUNSOyIsCiAgIm5hbWVzIjogW10KfQo= |
@@ -1,27 +0,15 @@ | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true}); | ||
var __reExport = (target, module2, desc) => { | ||
if (module2 && typeof module2 === "object" || typeof module2 === "function") { | ||
for (let key of __getOwnPropNames(module2)) | ||
if (!__hasOwnProp.call(target, key) && key !== "default") | ||
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable}); | ||
} | ||
return target; | ||
}; | ||
var __toModule = (module2) => { | ||
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2); | ||
}; | ||
var import_astro_snapshots = __toModule(require("./astro-snapshots.js")); | ||
var import_language_service = __toModule(require("./language-service/index.js")); | ||
var import_logger = __toModule(require("./logger.js")); | ||
var import_module_loader = __toModule(require("./module-loader.js")); | ||
"use strict"; | ||
var import_astro_snapshots = require("./astro-snapshots.js"); | ||
var import_language_service = require("./language-service/index.js"); | ||
var import_logger = require("./logger.js"); | ||
var import_module_loader = require("./module-loader.js"); | ||
var import_project_astro_files = require("./project-astro-files.js"); | ||
var import_utils = require("./utils.js"); | ||
function init(modules) { | ||
const ts = modules.typescript; | ||
function create(info) { | ||
var _a, _b; | ||
const logger = new import_logger.Logger(info.project.projectService.logger); | ||
if (!isAstroProject(info)) { | ||
const parsedCommandLine = (_b = (_a = info.languageServiceHost).getParsedCommandLine) == null ? void 0 : _b.call(_a, (0, import_utils.getConfigPathForProject)(info.project)); | ||
if (!isAstroProject(info.project, parsedCommandLine)) { | ||
logger.log("Detected that this is not an Astro project, abort patching TypeScript"); | ||
@@ -32,25 +20,36 @@ return info.languageService; | ||
const snapshotManager = new import_astro_snapshots.AstroSnapshotManager(modules.typescript, info.project.projectService, logger); | ||
patchCompilerOptions(info.project); | ||
if (parsedCommandLine) { | ||
new import_project_astro_files.ProjectAstroFilesManager( | ||
modules.typescript, | ||
info.project, | ||
info.serverHost, | ||
snapshotManager, | ||
parsedCommandLine | ||
); | ||
} | ||
(0, import_module_loader.patchModuleLoader)(logger, snapshotManager, modules.typescript, info.languageServiceHost, info.project); | ||
return (0, import_language_service.decorateLanguageService)(info.languageService, snapshotManager, logger); | ||
} | ||
function getExternalFiles(_project) { | ||
return []; | ||
function getExternalFiles(project) { | ||
var _a, _b; | ||
return (_b = (_a = import_project_astro_files.ProjectAstroFilesManager.getInstance(project.getProjectName())) == null ? void 0 : _a.getFiles()) != null ? _b : []; | ||
} | ||
function patchCompilerOptions(project) { | ||
var _a; | ||
const compilerOptions = project.getCompilerOptions(); | ||
compilerOptions.jsx = modules.typescript.JsxEmit.Preserve; | ||
if (!((_a = compilerOptions.jsxFactory) == null ? void 0 : _a.startsWith("astro"))) { | ||
compilerOptions.jsxFactory = "astro.createElement"; | ||
function isAstroProject(project, parsedCommandLine) { | ||
if (parsedCommandLine) { | ||
const astroFiles = (0, import_utils.readProjectAstroFilesFromFs)(ts, project, parsedCommandLine); | ||
if (astroFiles.length > 0) | ||
return true; | ||
} | ||
try { | ||
const compilerOptions = project.getCompilerOptions(); | ||
const hasAstroInstalled = typeof compilerOptions.configFilePath !== "string" || require.resolve("astro", { paths: [compilerOptions.configFilePath] }); | ||
return hasAstroInstalled; | ||
} catch (e) { | ||
project.projectService.logger.info(e); | ||
return false; | ||
} | ||
} | ||
function isAstroProject(info) { | ||
const compilerOptions = info.project.getCompilerOptions(); | ||
const isNoJsxProject = (!compilerOptions.jsx || compilerOptions.jsx === modules.typescript.JsxEmit.Preserve) && (!compilerOptions.jsxFactory || compilerOptions.jsxFactory.startsWith("astro")) && !compilerOptions.jsxFragmentFactory && !compilerOptions.jsxImportSource; | ||
return isNoJsxProject; | ||
} | ||
return {create, getExternalFiles}; | ||
return { create, getExternalFiles }; | ||
} | ||
module.exports = init; | ||
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3JjL2luZGV4LnRzIl0sCiAgIm1hcHBpbmdzIjogIjs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQ0EsNkJBQXFDO0FBQ3JDLDhCQUF3QztBQUN4QyxvQkFBdUI7QUFDdkIsMkJBQWtDO0FBRWxDLGNBQWMsU0FBb0M7QUFDakQsa0JBQWdCLE1BQWtDO0FBQ2pELFVBQU0sU0FBUyxJQUFJLHFCQUFPLEtBQUssU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RCLG1CQUFxRDtBQUN4RyxRQUFJLG1CQUFtQjtBQUN0QixZQUFNLGlCQUFhLDBDQUE0QixJQUFJLFNBQVMsaUJBQWlCO0FBRTdFLFVBQUksV0FBVyxTQUFTO0FBQUcsZUFBTztBQUFBLElBQ25DO0FBRUEsUUFBSTtBQUNILFlBQU0sa0JBQWtCLFFBQVEsbUJBQW1CO0FBQ25ELFlBQU0sb0JBQ0wsT0FBTyxnQkFBZ0IsbUJBQW1CLFlBQzFDLFFBQVEsUUFBUSxTQUFTLEVBQUUsT0FBTyxDQUFDLGdCQUFnQixjQUFjLEVBQUUsQ0FBQztBQUVyRSxhQUFPO0FBQUEsSUFDUixTQUFTLEdBQVA7QUFDRCxjQUFRLGVBQWUsT0FBTyxLQUFLLENBQVc7QUFDOUMsYUFBTztBQUFBLElBQ1I7QUFBQSxFQUNEO0FBRUEsU0FBTyxFQUFFLFFBQVEsaUJBQWlCO0FBQ25DO0FBRUEsaUJBQVM7IiwKICAibmFtZXMiOiBbXQp9Cg== |
@@ -1,45 +0,25 @@ | ||
var __create = Object.create; | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
var __defProps = Object.defineProperties; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropDescs = Object.getOwnPropertyDescriptors; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value; | ||
var __spreadValues = (a, b) => { | ||
for (var prop in b || (b = {})) | ||
if (__hasOwnProp.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
if (__getOwnPropSymbols) | ||
for (var prop of __getOwnPropSymbols(b)) { | ||
if (__propIsEnum.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
} | ||
return a; | ||
}; | ||
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); | ||
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true}); | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, {get: all[name], enumerable: true}); | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __reExport = (target, module2, desc) => { | ||
if (module2 && typeof module2 === "object" || typeof module2 === "function") { | ||
for (let key of __getOwnPropNames(module2)) | ||
if (!__hasOwnProp.call(target, key) && key !== "default") | ||
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable}); | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return target; | ||
return to; | ||
}; | ||
var __toModule = (module2) => { | ||
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2); | ||
}; | ||
__markAsModule(exports); | ||
__export(exports, { | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var completions_exports = {}; | ||
__export(completions_exports, { | ||
decorateCompletions: () => decorateCompletions | ||
}); | ||
var import_utils = __toModule(require("../utils.js")); | ||
module.exports = __toCommonJS(completions_exports); | ||
var import_utils = require("../utils.js"); | ||
const componentPostfix = "__AstroComponent_"; | ||
@@ -53,3 +33,4 @@ function decorateCompletions(ls, logger) { | ||
} | ||
return __spreadProps(__spreadValues({}, completions), { | ||
return { | ||
...completions, | ||
entries: completions.entries.map((entry) => { | ||
@@ -59,15 +40,34 @@ if (!(0, import_utils.isAstroFilePath)(entry.source || "") || !entry.name.endsWith(componentPostfix)) { | ||
} | ||
return __spreadProps(__spreadValues({}, entry), { | ||
return { | ||
...entry, | ||
name: entry.name.slice(0, -componentPostfix.length) | ||
}); | ||
}; | ||
}) | ||
}); | ||
}; | ||
}; | ||
const getCompletionEntryDetails = ls.getCompletionEntryDetails; | ||
ls.getCompletionEntryDetails = (fileName, position, entryName, formatOptions, source, preferences, data) => { | ||
const details = getCompletionEntryDetails(fileName, position, entryName, formatOptions, source, preferences, data); | ||
if (details || !(0, import_utils.isAstroFilePath)(source || "")) { | ||
return details; | ||
if (!(0, import_utils.isAstroFilePath)(source || "")) { | ||
const details = getCompletionEntryDetails( | ||
fileName, | ||
position, | ||
entryName, | ||
formatOptions, | ||
source, | ||
preferences, | ||
data | ||
); | ||
if (details) { | ||
return details; | ||
} | ||
} | ||
const astroDetails = getCompletionEntryDetails(fileName, position, entryName + componentPostfix, formatOptions, source, preferences, data); | ||
const astroDetails = getCompletionEntryDetails( | ||
fileName, | ||
position, | ||
entryName + componentPostfix, | ||
formatOptions, | ||
source, | ||
preferences, | ||
data | ||
); | ||
if (!astroDetails) { | ||
@@ -84,2 +84,2 @@ return void 0; | ||
}); | ||
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vc3JjL2xhbmd1YWdlLXNlcnZpY2UvY29tcGxldGlvbnMudHMiXSwKICAibWFwcGluZ3MiOiAiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUVBLG1CQUE2QztBQUU3QyxNQUFNLG1CQUFtQjtBQUVsQiw2QkFBNkIsSUFBd0IsUUFBc0I7QUFDakYsUUFBTSwyQkFBMkIsR0FBRztBQUNwQyxLQUFHLDJCQUEyQixDQUFDLFVBQVUsVUFBVSxZQUFZO0FBQzlELFVBQU0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ZTtBQUFBLE1BQ3BCO0FBQUEsTUFDQTtBQUFBLE1BQ0EsWUFBWTtBQUFBLE1BQ1o7QUFBQSxNQUNBO0FBQUEsTUFDQTtBQUFBLE1BQ0E7QUFBQSxJQUNEO0FBQ0EsUUFBSSxDQUFDLGNBQWM7QUFDbEIsYUFBTztBQUFBLElBQ1I7QUFDQSxXQUFPLE1BQU0saURBQWlEO0FBRTlELGVBQU8sMEJBQVksY0FBYyxrQkFBa0IsRUFBRTtBQUFBLEVBQ3REO0FBQ0Q7IiwKICAibmFtZXMiOiBbXQp9Cg== |
@@ -1,46 +0,26 @@ | ||
var __create = Object.create; | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
var __defProps = Object.defineProperties; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropDescs = Object.getOwnPropertyDescriptors; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value; | ||
var __spreadValues = (a, b) => { | ||
for (var prop in b || (b = {})) | ||
if (__hasOwnProp.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
if (__getOwnPropSymbols) | ||
for (var prop of __getOwnPropSymbols(b)) { | ||
if (__propIsEnum.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
} | ||
return a; | ||
}; | ||
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); | ||
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true}); | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, {get: all[name], enumerable: true}); | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __reExport = (target, module2, desc) => { | ||
if (module2 && typeof module2 === "object" || typeof module2 === "function") { | ||
for (let key of __getOwnPropNames(module2)) | ||
if (!__hasOwnProp.call(target, key) && key !== "default") | ||
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable}); | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return target; | ||
return to; | ||
}; | ||
var __toModule = (module2) => { | ||
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2); | ||
}; | ||
__markAsModule(exports); | ||
__export(exports, { | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var definition_exports = {}; | ||
__export(definition_exports, { | ||
decorateGetDefinition: () => decorateGetDefinition | ||
}); | ||
var import_utils = __toModule(require("../utils")); | ||
function decorateGetDefinition(ls, snapshotManager, logger) { | ||
module.exports = __toCommonJS(definition_exports); | ||
var import_utils = require("../utils"); | ||
function decorateGetDefinition(ls, snapshotManager) { | ||
const getDefinitionAndBoundSpan = ls.getDefinitionAndBoundSpan; | ||
@@ -52,3 +32,4 @@ ls.getDefinitionAndBoundSpan = (fileName, position) => { | ||
} | ||
return __spreadProps(__spreadValues({}, definition), { | ||
return { | ||
...definition, | ||
definitions: definition.definitions.map((def) => { | ||
@@ -61,5 +42,6 @@ var _a; | ||
if (!textSpan) { | ||
textSpan = {start: 0, length: 1}; | ||
textSpan = { start: 0, length: 1 }; | ||
} | ||
return __spreadProps(__spreadValues({}, def), { | ||
return { | ||
...def, | ||
textSpan, | ||
@@ -69,5 +51,5 @@ originalTextSpan: void 0, | ||
originalContextSpan: void 0 | ||
}); | ||
}; | ||
}).filter(import_utils.isNotNullOrUndefined) | ||
}); | ||
}; | ||
}; | ||
@@ -79,2 +61,2 @@ } | ||
}); | ||
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vc3JjL2xhbmd1YWdlLXNlcnZpY2UvZGVmaW5pdGlvbi50cyJdLAogICJtYXBwaW5ncyI6ICI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUFBO0FBQUE7QUFBQTtBQUFBO0FBR0EsbUJBQXNEO0FBRS9DLCtCQUNOLElBQ0EsaUJBQ0EsUUFDTztBQUNQLFFBQU0sNEJBQTRCLEdBQUc7QUFDckMsS0FBRyw0QkFBNEIsQ0FBQyxVQUFVLGFBQWE7QUFDdEQsVUFBTSxhQUFhLDBCQUEwQixVQUFVO0FBQ3ZELFFBQUksQ0FBQywwQ0FBWSxjQUFhO0FBQzdCLGFBQU87QUFBQTtBQUdSLFdBQU8saUNBQ0gsYUFERztBQUFBLE1BRU4sYUFBYSxXQUFXLFlBQ3RCLElBQUksQ0FBQyxRQUFRO0FBcEJsQjtBQXFCSyxZQUFJLENBQUMsa0NBQWdCLElBQUksV0FBVztBQUNuQyxpQkFBTztBQUFBO0FBR1IsWUFBSSxXQUFXLHNCQUFnQixJQUFJLElBQUksY0FBeEIsbUJBQW1DLG9CQUFvQixJQUFJO0FBQzFFLFlBQUksQ0FBQyxVQUFVO0FBR2QscUJBQVcsQ0FBRSxPQUFPLEdBQUcsUUFBUTtBQUFBO0FBRWhDLGVBQU8saUNBQ0gsTUFERztBQUFBLFVBRU47QUFBQSxVQUVBLGtCQUFrQjtBQUFBLFVBQ2xCLGFBQWE7QUFBQSxVQUNiLHFCQUFxQjtBQUFBO0FBQUEsU0FHdEIsT0FBTztBQUFBO0FBQUE7QUFBQTsiLAogICJuYW1lcyI6IFtdCn0K | ||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,26 @@ | ||
var __create = Object.create; | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true}); | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, {get: all[name], enumerable: true}); | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __reExport = (target, module2, desc) => { | ||
if (module2 && typeof module2 === "object" || typeof module2 === "function") { | ||
for (let key of __getOwnPropNames(module2)) | ||
if (!__hasOwnProp.call(target, key) && key !== "default") | ||
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable}); | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return target; | ||
return to; | ||
}; | ||
var __toModule = (module2) => { | ||
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2); | ||
}; | ||
__markAsModule(exports); | ||
__export(exports, { | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var diagnostics_exports = {}; | ||
__export(diagnostics_exports, { | ||
decorateDiagnostics: () => decorateDiagnostics | ||
}); | ||
var import_utils = __toModule(require("../utils.js")); | ||
function decorateDiagnostics(ls, logger) { | ||
module.exports = __toCommonJS(diagnostics_exports); | ||
var import_utils = require("../utils.js"); | ||
function decorateDiagnostics(ls) { | ||
decorateSyntacticDiagnostics(ls); | ||
@@ -64,2 +61,2 @@ decorateSemanticDiagnostics(ls); | ||
}); | ||
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vc3JjL2xhbmd1YWdlLXNlcnZpY2UvZGlhZ25vc3RpY3MudHMiXSwKICAibWFwcGluZ3MiOiAiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFFQSxtQkFBZ0M7QUFFekIsNkJBQTZCLElBQXdCLFFBQXNCO0FBQ2pGLCtCQUE2QjtBQUM3Qiw4QkFBNEI7QUFDNUIsZ0NBQThCO0FBQUE7QUFHL0Isc0NBQXNDLElBQThCO0FBQ25FLFFBQU0sMEJBQTBCLEdBQUc7QUFDbkMsS0FBRywwQkFBMEIsQ0FBQyxhQUFxQjtBQUdsRCxRQUFJLGtDQUFnQixXQUFXO0FBQzlCLGFBQU87QUFBQTtBQUVSLFdBQU8sd0JBQXdCO0FBQUE7QUFBQTtBQUlqQyxxQ0FBcUMsSUFBOEI7QUFDbEUsUUFBTSx5QkFBeUIsR0FBRztBQUNsQyxLQUFHLHlCQUF5QixDQUFDLGFBQXFCO0FBR2pELFFBQUksa0NBQWdCLFdBQVc7QUFDOUIsYUFBTztBQUFBO0FBRVIsV0FBTyx1QkFBdUI7QUFBQTtBQUFBO0FBSWhDLHVDQUF1QyxJQUE4QjtBQUNwRSxRQUFNLDJCQUEyQixHQUFHO0FBQ3BDLEtBQUcsMkJBQTJCLENBQUMsYUFBcUI7QUFHbkQsUUFBSSxrQ0FBZ0IsV0FBVztBQUM5QixhQUFPO0FBQUE7QUFFUixXQUFPLHlCQUF5QjtBQUFBO0FBQUE7IiwKICAibmFtZXMiOiBbXQp9Cg== | ||
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vc3JjL2xhbmd1YWdlLXNlcnZpY2UvZGlhZ25vc3RpY3MudHMiXSwKICAibWFwcGluZ3MiOiAiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQ0EsbUJBQWdDO0FBRXpCLFNBQVMsb0JBQW9CLElBQThCO0FBQ2pFLCtCQUE2QixFQUFFO0FBQy9CLDhCQUE0QixFQUFFO0FBQzlCLGdDQUE4QixFQUFFO0FBQ2pDO0FBRUEsU0FBUyw2QkFBNkIsSUFBOEI7QUFDbkUsUUFBTSwwQkFBMEIsR0FBRztBQUNuQyxLQUFHLDBCQUEwQixDQUFDLGFBQXFCO0FBR2xELFlBQUksOEJBQWdCLFFBQVEsR0FBRztBQUM5QixhQUFPLENBQUM7QUFBQSxJQUNUO0FBQ0EsV0FBTyx3QkFBd0IsUUFBUTtBQUFBLEVBQ3hDO0FBQ0Q7QUFFQSxTQUFTLDRCQUE0QixJQUE4QjtBQUNsRSxRQUFNLHlCQUF5QixHQUFHO0FBQ2xDLEtBQUcseUJBQXlCLENBQUMsYUFBcUI7QUFHakQsWUFBSSw4QkFBZ0IsUUFBUSxHQUFHO0FBQzlCLGFBQU8sQ0FBQztBQUFBLElBQ1Q7QUFDQSxXQUFPLHVCQUF1QixRQUFRO0FBQUEsRUFDdkM7QUFDRDtBQUVBLFNBQVMsOEJBQThCLElBQThCO0FBQ3BFLFFBQU0sMkJBQTJCLEdBQUc7QUFDcEMsS0FBRywyQkFBMkIsQ0FBQyxhQUFxQjtBQUduRCxZQUFJLDhCQUFnQixRQUFRLEdBQUc7QUFDOUIsYUFBTyxDQUFDO0FBQUEsSUFDVDtBQUNBLFdBQU8seUJBQXlCLFFBQVE7QUFBQSxFQUN6QztBQUNEOyIsCiAgIm5hbWVzIjogW10KfQo= |
@@ -1,45 +0,25 @@ | ||
var __create = Object.create; | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
var __defProps = Object.defineProperties; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropDescs = Object.getOwnPropertyDescriptors; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value; | ||
var __spreadValues = (a, b) => { | ||
for (var prop in b || (b = {})) | ||
if (__hasOwnProp.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
if (__getOwnPropSymbols) | ||
for (var prop of __getOwnPropSymbols(b)) { | ||
if (__propIsEnum.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
} | ||
return a; | ||
}; | ||
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); | ||
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true}); | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, {get: all[name], enumerable: true}); | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __reExport = (target, module2, desc) => { | ||
if (module2 && typeof module2 === "object" || typeof module2 === "function") { | ||
for (let key of __getOwnPropNames(module2)) | ||
if (!__hasOwnProp.call(target, key) && key !== "default") | ||
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable}); | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return target; | ||
return to; | ||
}; | ||
var __toModule = (module2) => { | ||
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2); | ||
}; | ||
__markAsModule(exports); | ||
__export(exports, { | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var find_references_exports = {}; | ||
__export(find_references_exports, { | ||
decorateFindReferences: () => decorateFindReferences | ||
}); | ||
var import_utils = __toModule(require("../utils.js")); | ||
module.exports = __toCommonJS(find_references_exports); | ||
var import_utils = require("../utils.js"); | ||
function decorateFindReferences(ls, snapshotManager, logger) { | ||
@@ -63,6 +43,7 @@ decorateGetReferencesAtPosition(ls, snapshotManager, logger); | ||
return { | ||
definition: __spreadProps(__spreadValues({}, reference.definition), { | ||
definition: { | ||
...reference.definition, | ||
textSpan, | ||
originalTextSpan: void 0 | ||
}), | ||
}, | ||
references: mapReferences(reference.references, snapshotManager, logger) | ||
@@ -91,3 +72,4 @@ }; | ||
logger.debug("Find references; map textSpan: changed", reference.textSpan, "to", textSpan); | ||
return __spreadProps(__spreadValues({}, reference), { | ||
return { | ||
...reference, | ||
textSpan, | ||
@@ -97,3 +79,3 @@ contextSpan: void 0, | ||
originalContextSpan: void 0 | ||
}); | ||
}; | ||
}).filter(import_utils.isNotNullOrUndefined); | ||
@@ -105,2 +87,2 @@ } | ||
}); | ||
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vc3JjL2xhbmd1YWdlLXNlcnZpY2UvZmluZC1yZWZlcmVuY2VzLnRzIl0sCiAgIm1hcHBpbmdzIjogIjs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFHQSxtQkFBc0Q7QUFFL0MsZ0NBQ04sSUFDQSxpQkFDQSxRQUNPO0FBQ1Asa0NBQWdDLElBQUksaUJBQWlCO0FBQ3JELDBCQUF3QixJQUFJLGlCQUFpQjtBQUFBO0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ixxQkFBcUI7QUFBQSxJQUN0QjtBQUFBLEVBQ0QsQ0FBQyxFQUNBLE9BQU8saUNBQW9CO0FBQzlCOyIsCiAgIm5hbWVzIjogW10KfQo= |
@@ -1,46 +0,26 @@ | ||
var __create = Object.create; | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
var __defProps = Object.defineProperties; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropDescs = Object.getOwnPropertyDescriptors; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value; | ||
var __spreadValues = (a, b) => { | ||
for (var prop in b || (b = {})) | ||
if (__hasOwnProp.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
if (__getOwnPropSymbols) | ||
for (var prop of __getOwnPropSymbols(b)) { | ||
if (__propIsEnum.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
} | ||
return a; | ||
}; | ||
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); | ||
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true}); | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, {get: all[name], enumerable: true}); | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __reExport = (target, module2, desc) => { | ||
if (module2 && typeof module2 === "object" || typeof module2 === "function") { | ||
for (let key of __getOwnPropNames(module2)) | ||
if (!__hasOwnProp.call(target, key) && key !== "default") | ||
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable}); | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return target; | ||
return to; | ||
}; | ||
var __toModule = (module2) => { | ||
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2); | ||
}; | ||
__markAsModule(exports); | ||
__export(exports, { | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var implementation_exports = {}; | ||
__export(implementation_exports, { | ||
decorateGetImplementation: () => decorateGetImplementation | ||
}); | ||
var import_utils = __toModule(require("../utils.js")); | ||
function decorateGetImplementation(ls, snapshotManager, logger) { | ||
module.exports = __toCommonJS(implementation_exports); | ||
var import_utils = require("../utils.js"); | ||
function decorateGetImplementation(ls, snapshotManager) { | ||
const getImplementationAtPosition = ls.getImplementationAtPosition; | ||
@@ -58,3 +38,4 @@ ls.getImplementationAtPosition = (fileName, position) => { | ||
} | ||
return __spreadProps(__spreadValues({}, impl), { | ||
return { | ||
...impl, | ||
textSpan, | ||
@@ -64,3 +45,3 @@ contextSpan: void 0, | ||
originalContextSpan: void 0 | ||
}); | ||
}; | ||
}).filter(import_utils.isNotNullOrUndefined); | ||
@@ -73,2 +54,2 @@ }; | ||
}); | ||
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vc3JjL2xhbmd1YWdlLXNlcnZpY2UvaW1wbGVtZW50YXRpb24udHMiXSwKICAibWFwcGluZ3MiOiAiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUdBLG1CQUFzRDtBQUUvQyxtQ0FDTixJQ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7QUFFQSxZQUFNLFlBQVcscUJBQWdCLElBQUksS0FBSyxRQUFRLE1BQWpDLG1CQUFvQyxvQkFBb0IsS0FBSztBQUM5RSxVQUFJLENBQUMsVUFBVTtBQUNkLGVBQU87QUFBQSxNQUNSO0FBRUEsYUFBTztBQUFBLFFBQ04sR0FBRztBQUFBLFFBQ0g7QUFBQSxRQUVBLGFBQWE7QUFBQSxRQUNiLGtCQUFrQjtBQUFBLFFBQ2xCLHFCQUFxQjtBQUFBLE1BQ3RCO0FBQUEsSUFDRCxHQUNDLE9BQU87QUFBQSxFQUNWO0FBQ0Q7IiwKICAibmFtZXMiOiBbXQp9Cg== |
@@ -1,59 +0,43 @@ | ||
var __create = Object.create; | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true}); | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, {get: all[name], enumerable: true}); | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __reExport = (target, module2, desc) => { | ||
if (module2 && typeof module2 === "object" || typeof module2 === "function") { | ||
for (let key of __getOwnPropNames(module2)) | ||
if (!__hasOwnProp.call(target, key) && key !== "default") | ||
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable}); | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return target; | ||
return to; | ||
}; | ||
var __toModule = (module2) => { | ||
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2); | ||
}; | ||
__markAsModule(exports); | ||
__export(exports, { | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var language_service_exports = {}; | ||
__export(language_service_exports, { | ||
decorateLanguageService: () => decorateLanguageService | ||
}); | ||
var import_utils = __toModule(require("../utils.js")); | ||
var import_completions = __toModule(require("./completions.js")); | ||
var import_definition = __toModule(require("./definition.js")); | ||
var import_diagnostics = __toModule(require("./diagnostics.js")); | ||
var import_find_references = __toModule(require("./find-references.js")); | ||
var import_implementation = __toModule(require("./implementation.js")); | ||
var import_rename = __toModule(require("./rename.js")); | ||
module.exports = __toCommonJS(language_service_exports); | ||
var import_completions = require("./completions.js"); | ||
var import_definition = require("./definition.js"); | ||
var import_diagnostics = require("./diagnostics.js"); | ||
var import_file_references = require("./file-references.js"); | ||
var import_find_references = require("./find-references.js"); | ||
var import_implementation = require("./implementation.js"); | ||
var import_line_column_offset = require("./line-column-offset.js"); | ||
var import_rename = require("./rename.js"); | ||
function decorateLanguageService(ls, snapshotManager, logger) { | ||
patchLineColumnOffset(ls, snapshotManager); | ||
(0, import_line_column_offset.decorateLineColumnOffset)(ls, snapshotManager); | ||
(0, import_rename.decorateRename)(ls, snapshotManager, logger); | ||
(0, import_diagnostics.decorateDiagnostics)(ls, logger); | ||
(0, import_diagnostics.decorateDiagnostics)(ls); | ||
(0, import_find_references.decorateFindReferences)(ls, snapshotManager, logger); | ||
(0, import_completions.decorateCompletions)(ls, logger); | ||
(0, import_definition.decorateGetDefinition)(ls, snapshotManager, logger); | ||
(0, import_implementation.decorateGetImplementation)(ls, snapshotManager, logger); | ||
(0, import_definition.decorateGetDefinition)(ls, snapshotManager); | ||
(0, import_implementation.decorateGetImplementation)(ls, snapshotManager); | ||
(0, import_file_references.decorateGetFileReferences)(ls, snapshotManager); | ||
return ls; | ||
} | ||
function patchLineColumnOffset(ls, snapshotManager) { | ||
if (!ls.toLineColumnOffset) { | ||
return; | ||
} | ||
const toLineColumnOffset = ls.toLineColumnOffset; | ||
ls.toLineColumnOffset = (fileName, position) => { | ||
if ((0, import_utils.isAstroFilePath)(fileName)) { | ||
const snapshot = snapshotManager.get(fileName); | ||
if (snapshot) { | ||
return snapshot.positionAt(position); | ||
} | ||
} | ||
return toLineColumnOffset(fileName, position); | ||
}; | ||
} | ||
// Annotate the CommonJS export names for ESM import in node: | ||
@@ -63,2 +47,2 @@ 0 && (module.exports = { | ||
}); | ||
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vc3JjL2xhbmd1YWdlLXNlcnZpY2UvaW5kZXgudHMiXSwKICAibWFwcGluZ3MiOiAiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFHQSxtQkFBZ0M7QUFDaEMseUJBQW9DO0FBQ3BDLHdCQUFzQztBQUN0Qyx5QkFBb0M7QUFDcEMsNkJBQXVDO0FBQ3ZDLDRCQUEwQztBQUMxQyxvQkFBK0I7QUFFeEIsaUNBQ04sSUFDQSxpQkFDQSxRQUNxQjtBQUNyQix3QkFBc0IsSUFBSTtBQUMxQixvQ0FBZSxJQUFJLGlCQUFpQjtBQUNwQyw4Q0FBb0IsSUFBSTtBQUN4QixxREFBdUIsSUFBSSxpQkFBaUI7QUFDNUMsOENBQW9CLElBQUk7QUFDeEIsK0NBQXNCLElBQUksaUJBQWlCO0FBQzNDLHVEQUEwQixJQUFJLGlCQUFpQjtBQUMvQyxTQUFPO0FBQUE7QUFHUiwrQkFBK0IsSUFBd0IsaUJBQXVDO0FBQzdGLE1BQUksQ0FBQyxHQUFHLG9CQUFvQjtBQUMzQjtBQUFBO0FBSUQsUUFBTSxxQkFBcUIsR0FBRztBQUM5QixLQUFHLHFCQUFxQixDQUFDLFVBQVUsYUFBYTtBQUMvQyxRQUFJLGtDQUFnQixXQUFXO0FBQzlCLFlBQU0sV0FBVyxnQkFBZ0IsSUFBSTtBQUNyQyxVQUFJLFVBQVU7QUFDYixlQUFPLFNBQVMsV0FBVztBQUFBO0FBQUE7QUFHN0IsV0FBTyxtQkFBbUIsVUFBVTtBQUFBO0FBQUE7IiwKICAibmFtZXMiOiBbXQp9Cg== | ||
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vc3JjL2xhbmd1YWdlLXNlcnZpY2UvaW5kZXgudHMiXSwKICAibWFwcGluZ3MiOiAiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBR0EseUJBQW9DO0FBQ3BDLHdCQUFzQztBQUN0Qyx5QkFBb0M7QUFDcEMsNkJBQTBDO0FBQzFDLDZCQUF1QztBQUN2Qyw0QkFBMEM7QUFDMUMsZ0NBQXlDO0FBQ3pDLG9CQUErQjtBQUV4QixTQUFTLHdCQUNmLElBQ0EsaUJBQ0EsUUFDcUI7QUFDckIsMERBQXlCLElBQUksZUFBZTtBQUM1QyxvQ0FBZSxJQUFJLGlCQUFpQixNQUFNO0FBQzFDLDhDQUFvQixFQUFFO0FBQ3RCLHFEQUF1QixJQUFJLGlCQUFpQixNQUFNO0FBQ2xELDhDQUFvQixJQUFJLE1BQU07QUFDOUIsK0NBQXNCLElBQUksZUFBZTtBQUN6Qyx1REFBMEIsSUFBSSxlQUFlO0FBQzdDLHdEQUEwQixJQUFJLGVBQWU7QUFFN0MsU0FBTztBQUNSOyIsCiAgIm5hbWVzIjogW10KfQo= |
@@ -1,49 +0,35 @@ | ||
var __create = Object.create; | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
var __defProps = Object.defineProperties; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropDescs = Object.getOwnPropertyDescriptors; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value; | ||
var __spreadValues = (a, b) => { | ||
for (var prop in b || (b = {})) | ||
if (__hasOwnProp.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
if (__getOwnPropSymbols) | ||
for (var prop of __getOwnPropSymbols(b)) { | ||
if (__propIsEnum.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
} | ||
return a; | ||
}; | ||
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); | ||
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true}); | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, {get: all[name], enumerable: true}); | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __reExport = (target, module2, desc) => { | ||
if (module2 && typeof module2 === "object" || typeof module2 === "function") { | ||
for (let key of __getOwnPropNames(module2)) | ||
if (!__hasOwnProp.call(target, key) && key !== "default") | ||
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable}); | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return target; | ||
return to; | ||
}; | ||
var __toModule = (module2) => { | ||
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2); | ||
}; | ||
__markAsModule(exports); | ||
__export(exports, { | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var rename_exports = {}; | ||
__export(rename_exports, { | ||
decorateRename: () => decorateRename | ||
}); | ||
var import_utils = __toModule(require("../utils.js")); | ||
module.exports = __toCommonJS(rename_exports); | ||
var import_utils = require("../utils.js"); | ||
function decorateRename(ls, snapshotManager, logger) { | ||
const findRenameLocations = ls.findRenameLocations; | ||
ls.findRenameLocations = (fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename) => { | ||
const renameLocations = findRenameLocations(fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename); | ||
const renameLocations = findRenameLocations( | ||
fileName, | ||
position, | ||
findInStrings, | ||
findInComments, | ||
providePrefixAndSuffixTextForRename | ||
); | ||
return renameLocations == null ? void 0 : renameLocations.map((renameLocation) => { | ||
@@ -58,5 +44,6 @@ const snapshot = snapshotManager.get(renameLocation.fileName); | ||
} | ||
const converted = __spreadProps(__spreadValues({}, renameLocation), { | ||
const converted = { | ||
...renameLocation, | ||
textSpan | ||
}); | ||
}; | ||
if (converted.contextSpan) { | ||
@@ -74,2 +61,2 @@ converted.contextSpan = void 0; | ||
}); | ||
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vc3JjL2xhbmd1YWdlLXNlcnZpY2UvcmVuYW1lLnRzIl0sCiAgIm1hcHBpbmdzIjogIjs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFHQSxtQkFBc0Q7QUFFL0Msd0JBQXdCLElBQXdCLGlCQUF1QyxRQUFzQjtBQUNuSCxRQUFNLHNCQUFzQixHQUFHO0FBQy9CLEtBQUcsc0JBQXNCLENBQUMsVUFBVSxVQUFVLGVBQWUsZ0JBQWdCLHdDQUF3QztB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CQUFtQjtBQUN6QixZQUFNLFdBQVcsZ0JBQWdCLElBQUksZUFBZSxRQUFRO0FBQzVELFVBQUksS0FBQyw4QkFBZ0IsZUFBZSxRQUFRLEtBQUssQ0FBQyxVQUFVO0FBQzNELGVBQU87QUFBQSxNQUNSO0FBR0EsWUFBTSxXQUFXLFNBQVMsb0JBQW9CLGVBQWUsUUFBUTtBQUNyRSxVQUFJLENBQUMsVUFBVTtBQUNkLGVBQU87QUFBQSxNQUNSO0FBRUEsWUFBTSxZQUFZO0FBQUEsUUFDakIsR0FBRztBQUFBLFFBQ0g7QUFBQSxNQUNEO0FBQ0EsVUFBSSxVQUFVLGFBQWE7QUFFMUIsa0JBQVUsY0FBYztBQUFBLE1BQ3pCO0FBQ0EsYUFBTyxNQUFNLDhCQUE4QixTQUFTO0FBQ3BELGFBQU87QUFBQSxJQUNSLEdBQ0MsT0FBTztBQUFBLEVBQ1Y7QUFDRDsiLAogICJuYW1lcyI6IFtdCn0K |
@@ -0,11 +1,24 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true}); | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, {get: all[name], enumerable: true}); | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
__markAsModule(exports); | ||
__export(exports, { | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var logger_exports = {}; | ||
__export(logger_exports, { | ||
Logger: () => Logger | ||
}); | ||
module.exports = __toCommonJS(logger_exports); | ||
class Logger { | ||
@@ -48,2 +61,2 @@ constructor(tsLogService, suppressNonAstroLogs = false, logDebug = false) { | ||
}); | ||
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3JjL2xvZ2dlci50cyJdLAogICJtYXBwaW5ncyI6ICI7Ozs7OztBQUFBO0FBQUE7QUFBQTtBQUFBO0FBRU8sYUFBYTtBQUFBLEVBQ25CLFlBQW9CLGNBQWdDLHVCQUF1QixPQUFlLFdBQVcsT0FBTztBQUF4RjtBQUFzRTtBQUN6RixRQUFJLHNCQUFzQjtBQUN6QixZQUFNLE1BQU0sS0FBSyxhQUFhLEtBQUssS0FBSyxLQUFLO0FBQzdDLFdBQUssYUFBYSxPQUFPLENBQUMsTUFBYztBQUN2QyxZQUFJLEVBQUUsV0FBVyxtQkFBbUI7QUFDbkMsY0FBSTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUEsRUFNUixPQUFPLE1BQWE7QUFDbkIsVUFBTSxNQUFNLEtBQ1YsSUFBSSxDQUFDLFFBQVE7QUFDYixVQUFJLE9BQU8sUUFBUSxVQUFVO0FBQzVCLFlBQUk7QUFDSCxpQkFBTyxLQUFLLFVBQVU7QUFBQSxpQkFDZCxHQUFQO0FBQ0QsaUJBQU87QUFBQTtBQUFBO0FBR1QsYUFBTztBQUFBLE9BRVAsS0FBSztBQUNQLFNBQUssYUFBYSxLQUFLLG9CQUFvQjtBQUFBO0FBQUEsRUFHNUMsU0FBUyxNQUFhO0FBQ3JCLFFBQUksQ0FBQyxLQUFLLFVBQVU7QUFDbkI7QUFBQTtBQUVELFNBQUssSUFBSSxHQUFHO0FBQUE7QUFBQTsiLAogICJuYW1lcyI6IFtdCn0K | ||
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3Jj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; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true}); | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, {get: all[name], enumerable: true}); | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __reExport = (target, module2, desc) => { | ||
if (module2 && typeof module2 === "object" || typeof module2 === "function") { | ||
for (let key of __getOwnPropNames(module2)) | ||
if (!__hasOwnProp.call(target, key) && key !== "default") | ||
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable}); | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return target; | ||
return to; | ||
}; | ||
var __toModule = (module2) => { | ||
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2); | ||
}; | ||
__markAsModule(exports); | ||
__export(exports, { | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var module_loader_exports = {}; | ||
__export(module_loader_exports, { | ||
patchModuleLoader: () => patchModuleLoader | ||
}); | ||
var import_astro_sys = __toModule(require("./astro-sys.js")); | ||
var import_utils = __toModule(require("./utils.js")); | ||
module.exports = __toCommonJS(module_loader_exports); | ||
var import_astro_sys = require("./astro-sys.js"); | ||
var import_utils = require("./utils.js"); | ||
class ModuleResolutionCache { | ||
constructor() { | ||
this.cache = new Map(); | ||
this.cache = /* @__PURE__ */ new Map(); | ||
} | ||
@@ -65,4 +62,8 @@ get(moduleName, containingFile) { | ||
}; | ||
const origReadDirectory = project.readDirectory.bind(project); | ||
project.readDirectory = (path, extensions, exclude, include, depth) => { | ||
const extensionsWithAstro = (extensions != null ? extensions : []).concat(".astro", ".md", ".mdx"); | ||
return origReadDirectory(path, extensionsWithAstro, exclude, include, depth); | ||
}; | ||
function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, compilerOptions) { | ||
logger.log("Resolving modules names for " + containingFile); | ||
const resolved = (origResolveModuleNames == null ? void 0 : origResolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, compilerOptions)) || Array.from(Array(moduleNames.length)); | ||
@@ -84,3 +85,8 @@ return resolved.map((moduleName, idx) => { | ||
function resolveModuleName(name, containingFile, compilerOptions) { | ||
const astroResolvedModule = typescript.resolveModuleName(name, containingFile, compilerOptions, astroSys).resolvedModule; | ||
const astroResolvedModule = typescript.resolveModuleName( | ||
name, | ||
containingFile, | ||
compilerOptions, | ||
astroSys | ||
).resolvedModule; | ||
if (!astroResolvedModule || !(0, import_utils.isVirtualAstroFilePath)(astroResolvedModule.resolvedFileName)) { | ||
@@ -96,3 +102,3 @@ return astroResolvedModule; | ||
const resolvedAstroModule = { | ||
extension: snapshot.isTsFile ? typescript.Extension.Tsx : typescript.Extension.Jsx, | ||
extension: typescript.Extension.Tsx, | ||
resolvedFileName | ||
@@ -107,2 +113,2 @@ }; | ||
}); | ||
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3JjL21vZHVsZS1sb2FkZXIudHMiXSwKICAibWFwcGluZ3MiOiAiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFFQSx1QkFBK0I7QUFFL0IsbUJBQWdFO0FBS2hFLDRCQUE0QjtBQUFBLEVBQTVCLGNBVEE7QUFVUyxpQkFBUSxJQUFJO0FBQUE7QUFBQSxFQUtwQixJQUFJLFlBQW9C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dBQVMsa0JBQ1IsTUFDQSxnQkFDQSxpQkFDZ0M7QUFDaEMsVUFBTSxzQkFBc0IsV0FBVztBQUFBLE1BQ3RDO0FBQUEsTUFDQTtBQUFBLE1BQ0E7QUFBQSxNQUNBO0FBQUEsSUFDRCxFQUFFO0FBQ0YsUUFBSSxDQUFDLHVCQUF1QixLQUFDLHFDQUF1QixvQkFBb0IsZ0JBQWdCLEdBQUc7QUFDMUYsYUFBTztBQUFBLElBQ1I7QUFFQSxVQUFNLHVCQUFtQixzQ0FBd0Isb0JBQW9CLGdCQUFnQjtBQUNyRixXQUFPLElBQUksWUFBWSxNQUFNLGlCQUFpQixnQkFBZ0I7QUFDOUQsVUFBTSxXQUFXLGdCQUFnQixPQUFPLGdCQUFnQjtBQUN4RCxRQUFJLENBQUMsVUFBVTtBQUNkLGFBQU87QUFBQSxJQUNSO0FBRUEsVUFBTSxzQkFBNkM7QUFBQSxNQUNsRCxXQUFXLFdBQVcsVUFBVTtBQUFBLE1BQ2hDO0FBQUEsSUFDRDtBQUNBLFdBQU87QUFBQSxFQUNSO0FBQ0Q7IiwKICAibmFtZXMiOiBbXQp9Cg== |
@@ -0,18 +1,31 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true}); | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, {get: all[name], enumerable: true}); | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
__markAsModule(exports); | ||
__export(exports, { | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var utils_exports = {}; | ||
__export(utils_exports, { | ||
ensureRealAstroFilePath: () => ensureRealAstroFilePath, | ||
getConfigPathForProject: () => getConfigPathForProject, | ||
isAstroFilePath: () => isAstroFilePath, | ||
isInGeneratedCode: () => isInGeneratedCode, | ||
isNoTextSpanInGeneratedCode: () => isNoTextSpanInGeneratedCode, | ||
isNotNullOrUndefined: () => isNotNullOrUndefined, | ||
isVirtualAstroFilePath: () => isVirtualAstroFilePath, | ||
readProjectAstroFilesFromFs: () => readProjectAstroFilesFromFs, | ||
replaceDeep: () => replaceDeep, | ||
toRealAstroFilePath: () => toRealAstroFilePath | ||
}); | ||
module.exports = __toCommonJS(utils_exports); | ||
function isAstroFilePath(filePath) { | ||
@@ -33,12 +46,2 @@ return filePath.endsWith(".astro"); | ||
} | ||
function isInGeneratedCode(text, start, end) { | ||
const lineStart = text.lastIndexOf("\n", start); | ||
const lineEnd = text.indexOf("\n", end); | ||
const lastStart = text.substring(lineStart, start).lastIndexOf("/*\u03A9ignore_start\u03A9*/"); | ||
const lastEnd = text.substring(lineStart, start).lastIndexOf("/*\u03A9ignore_end\u03A9*/"); | ||
return lastStart > lastEnd && text.substring(end, lineEnd).includes("/*\u03A9ignore_end\u03A9*/"); | ||
} | ||
function isNoTextSpanInGeneratedCode(text, span) { | ||
return !isInGeneratedCode(text, span.start, span.start + span.length); | ||
} | ||
function replaceDeep(obj, searchStr, replacementStr) { | ||
@@ -62,13 +65,25 @@ return _replaceDeep(obj); | ||
} | ||
function getConfigPathForProject(project) { | ||
var _a; | ||
return (_a = project.canonicalConfigFilePath) != null ? _a : project.getCompilerOptions().configFilePath; | ||
} | ||
function readProjectAstroFilesFromFs(ts, project, parsedCommandLine) { | ||
const fileSpec = parsedCommandLine.raw; | ||
const { include, exclude } = fileSpec; | ||
if ((include == null ? void 0 : include.length) === 0) { | ||
return []; | ||
} | ||
return ts.sys.readDirectory(project.getCurrentDirectory() || process.cwd(), [".astro"], exclude, include).map(ts.server.toNormalizedPath); | ||
} | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
ensureRealAstroFilePath, | ||
getConfigPathForProject, | ||
isAstroFilePath, | ||
isInGeneratedCode, | ||
isNoTextSpanInGeneratedCode, | ||
isNotNullOrUndefined, | ||
isVirtualAstroFilePath, | ||
readProjectAstroFilesFromFs, | ||
replaceDeep, | ||
toRealAstroFilePath | ||
}); | ||
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3JjL3V0aWxzLnRzIl0sCiAgIm1hcHBpbmdzIjogIjs7Ozs7O0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFPLHlCQUF5QixVQUFrQjtBQUNqRCxTQUFPLFNBQVMsU0FBUztBQUFBO0FBR25CLGdDQUFnQyxVQUFrQjtBQUN4RCxTQUFPLFNBQVMsU0FBUztBQUFBO0FBR25CLDZCQUE2QixVQUFrQjtBQUNyRCxTQUFPLFNBQVMsTUFBTSxHQUFHLENBQUMsTUFBTTtBQUFBO0FBRzFCLGlDQUFpQyxVQUFrQjtBQUN6RCxTQUFPLHVCQUF1QixZQUFZLG9CQUFvQixZQUFZO0FBQUE7QUFHcEUsOEJBQWlDLEtBQXFDO0FBQzVFLFNBQU8sUUFBUSxVQUFhLFFBQVE7QUFBQTtBQU85QiwyQkFBMkIsTUFBYyxPQUFlLEtBQWE7QUFDM0UsUUFBTSxZQUFZLEtBQUssWUFBWSxNQUFNO0FBQ3pDLFFBQU0sVUFBVSxLQUFLLFFBQVEsTUFBTTtBQUNuQyxRQUFNLFlBQVksS0FBSyxVQUFVLFdBQVcsT0FBTyxZQUFZO0FBQy9ELFFBQU0sVUFBVSxLQUFLLFVBQVUsV0FBVyxPQUFPL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QUMxQixXQUFPLENBQUM7QUFBQSxFQUNUO0FBRUEsU0FBTyxHQUFHLElBQ1IsY0FBYyxRQUFRLG9CQUFvQixLQUFLLFFBQVEsSUFBSSxHQUFHLENBQUMsUUFBUSxHQUFHLFNBQVMsT0FBTyxFQUMxRixJQUFJLEdBQUcsT0FBTyxnQkFBZ0I7QUFDakM7IiwKICAibmFtZXMiOiBbXQp9Cg== |
{ | ||
"name": "@astrojs/ts-plugin", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "A TypeScript Plugin providing Astro intellisense", | ||
@@ -13,16 +13,26 @@ "main": "dist/index.js", | ||
], | ||
"scripts": { | ||
"build": "astro-scripts build \"src/**/*.ts\"", | ||
"dev": "astro-scripts dev \"src/**/*.ts\"" | ||
}, | ||
"author": "withastro", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@astrojs/compiler": "^0.29.15", | ||
"@jridgewell/trace-mapping": "^0.3.15", | ||
"synckit": "^0.8.4" | ||
}, | ||
"devDependencies": { | ||
"@tsconfig/node12": "^1.0.0", | ||
"@types/node": "^13.9.0", | ||
"typescript": "*" | ||
"@types/chai": "^4.3.0", | ||
"@types/mocha": "^9.1.1", | ||
"@types/node": "^16.11.58", | ||
"@types/vscode": "^1.67.0", | ||
"@vscode/test-electron": "^2.1.5", | ||
"astro-scripts": "*", | ||
"chai": "^4.3.6", | ||
"glob": "^8.0.3", | ||
"mocha": "^9.2.2", | ||
"typescript": "~4.8.2" | ||
}, | ||
"dependencies": { | ||
"sourcemap-codec": "^1.4.8" | ||
"scripts": { | ||
"build": "astro-scripts build \"src/**/*.ts\"", | ||
"dev": "astro-scripts dev \"src/**/*.ts\"", | ||
"test": "node ./test/runTest.js" | ||
} | ||
} | ||
} |
@@ -0,6 +1,6 @@ | ||
import { EncodedSourceMap, originalPositionFor, TraceMap } from '@jridgewell/trace-mapping'; | ||
import type ts from 'typescript/lib/tsserverlibrary'; | ||
import { astro2tsx } from './astro2tsx.js'; | ||
import { Logger } from './logger.js'; | ||
import { SourceMapper } from './source-mapper.js'; | ||
import { isAstroFilePath, isNoTextSpanInGeneratedCode } from './utils.js'; | ||
import type { Logger } from './logger.js'; | ||
import { isAstroFilePath } from './utils.js'; | ||
@@ -16,10 +16,9 @@ export class AstroSnapshot { | ||
private astroCode: string, | ||
private mapper: SourceMapper, | ||
private logger: Logger, | ||
public readonly isTsFile: boolean | ||
private traceMap: TraceMap, | ||
private logger: Logger | ||
) {} | ||
update(astroCode: string, mapper: SourceMapper) { | ||
update(astroCode: string, traceMap: TraceMap) { | ||
this.astroCode = astroCode; | ||
this.mapper = mapper; | ||
this.traceMap = traceMap; | ||
this.lineOffsets = undefined; | ||
@@ -30,6 +29,2 @@ this.log('Updated Snapshot'); | ||
getOriginalTextSpan(textSpan: ts.TextSpan): ts.TextSpan | null { | ||
if (!isNoTextSpanInGeneratedCode(this.getText(), textSpan)) { | ||
return null; | ||
} | ||
const start = this.getOriginalOffset(textSpan.start); | ||
@@ -55,12 +50,13 @@ if (start === -1) { | ||
this.debug('try convert offset', generatedOffset, '/', lineOffset); | ||
const original = this.mapper.getOriginalPosition({ | ||
line: lineOffset.line - 1, | ||
character: lineOffset.offset - 1, | ||
const original = originalPositionFor(this.traceMap, { | ||
line: lineOffset.line, | ||
column: lineOffset.offset, | ||
}); | ||
this.toggleMappingMode(false); | ||
if (original.line === -1) { | ||
if (!original.line) { | ||
return -1; | ||
} | ||
const originalOffset = this.scriptInfo.lineOffsetToPosition(original.line + 1, original.character + 1); | ||
const originalOffset = this.scriptInfo.lineOffsetToPosition(original.line, original.column); | ||
this.debug('converted offset to', original, '/', originalOffset); | ||
@@ -256,10 +252,6 @@ return originalOffset; | ||
try { | ||
const isTsFile = true; | ||
const result = astro2tsx(astroCode, { | ||
filename: path.split('/').pop(), | ||
isTsFile, | ||
}); | ||
const result = astro2tsx(astroCode, path); | ||
const existingSnapshot = this.snapshots.get(path); | ||
if (existingSnapshot) { | ||
existingSnapshot.update(astroCode, new SourceMapper(result.map.mappings)); | ||
existingSnapshot.update(astroCode, new TraceMap(result.map as EncodedSourceMap)); | ||
} else { | ||
@@ -272,5 +264,4 @@ this.snapshots.set( | ||
astroCode, | ||
new SourceMapper(result.map.mappings), | ||
this.logger, | ||
isTsFile | ||
new TraceMap(result.map as EncodedSourceMap), | ||
this.logger | ||
) | ||
@@ -277,0 +268,0 @@ ); |
import ts from 'typescript'; | ||
import { Logger } from './logger.js'; | ||
import type { Logger } from './logger.js'; | ||
import { ensureRealAstroFilePath, isVirtualAstroFilePath, toRealAstroFilePath } from './utils.js'; | ||
@@ -4,0 +4,0 @@ |
@@ -1,49 +0,8 @@ | ||
import type { FileMapping } from './source-mapper'; | ||
import type { TSXResult } from '@astrojs/compiler/shared/types'; | ||
import { convertToTSX } from './workers/TSXService'; | ||
// Note that this is a bit of a hack until the new compiler with proper | ||
// source map support. | ||
export function astro2tsx(content: string, fileName: string): TSXResult { | ||
const tsx = convertToTSX(content, { sourcefile: fileName }); | ||
interface Astro2TSXOptions { | ||
filename: string | undefined; | ||
isTsFile: boolean; | ||
return tsx; | ||
} | ||
interface Astro2TSXResult { | ||
code: string; | ||
map: { | ||
mappings: FileMapping; | ||
}; | ||
} | ||
export function astro2tsx(code: string, options: Astro2TSXOptions): Astro2TSXResult { | ||
const compiled = transformContent(code); | ||
const result: Astro2TSXResult = { | ||
code: compiled, | ||
map: { | ||
mappings: [], | ||
}, | ||
}; | ||
return result; | ||
} | ||
// This is hacky but it works for now | ||
function addProps(content: string): string { | ||
let defaultExportType = 'Record<string, any>'; | ||
if (/(interface|type) Props/.test(content)) { | ||
defaultExportType = 'Props'; | ||
} | ||
return '\n' + `export default function (props: ${defaultExportType}): string;`; | ||
} | ||
function transformContent(content: string) { | ||
const ts = content.replace(/---/g, '///'); | ||
return ( | ||
ts + | ||
// Add TypeScript definitions | ||
addProps(ts) | ||
); | ||
} |
@@ -6,8 +6,13 @@ import type ts from 'typescript/lib/tsserverlibrary'; | ||
import { patchModuleLoader } from './module-loader.js'; | ||
import { ProjectAstroFilesManager } from './project-astro-files.js'; | ||
import { getConfigPathForProject, readProjectAstroFilesFromFs } from './utils.js'; | ||
function init(modules: { typescript: typeof ts }) { | ||
function create(info: ts.server.PluginCreateInfo) { | ||
function init(modules: { typescript: typeof import('typescript/lib/tsserverlibrary') }) { | ||
const ts = modules.typescript; | ||
function create(info: ts.server.PluginCreateInfo): ts.LanguageService { | ||
const logger = new Logger(info.project.projectService.logger); | ||
const parsedCommandLine = info.languageServiceHost.getParsedCommandLine?.(getConfigPathForProject(info.project)); | ||
if (!isAstroProject(info)) { | ||
if (!isAstroProject(info.project, parsedCommandLine)) { | ||
logger.log('Detected that this is not an Astro project, abort patching TypeScript'); | ||
@@ -20,4 +25,12 @@ return info.languageService; | ||
const snapshotManager = new AstroSnapshotManager(modules.typescript, info.project.projectService, logger); | ||
if (parsedCommandLine) { | ||
new ProjectAstroFilesManager( | ||
modules.typescript, | ||
info.project, | ||
info.serverHost, | ||
snapshotManager, | ||
parsedCommandLine | ||
); | ||
} | ||
patchCompilerOptions(info.project); | ||
patchModuleLoader(logger, snapshotManager, modules.typescript, info.languageServiceHost, info.project); | ||
@@ -27,37 +40,24 @@ return decorateLanguageService(info.languageService, snapshotManager, logger); | ||
function getExternalFiles(_project: ts.server.ConfiguredProject) { | ||
// Needed so the ambient definitions are known inside the tsx files | ||
/*const astroTsPath = dirname(require.resolve('astro2tsx')); | ||
const astroTsxFiles = [ | ||
'./astro-shims.d.ts', | ||
'./astro-jsx.d.ts', | ||
'./astro-native-jsx.d.ts' | ||
].map((f) => modules.typescript.sys.resolvePath(resolve(astroTsPath, f))); | ||
return astroTsxFiles;*/ | ||
return []; | ||
function getExternalFiles(project: ts.server.ConfiguredProject) { | ||
return ProjectAstroFilesManager.getInstance(project.getProjectName())?.getFiles() ?? []; | ||
} | ||
function patchCompilerOptions(project: ts.server.Project) { | ||
const compilerOptions = project.getCompilerOptions(); | ||
// Patch needed because astro2tsx creates jsx/tsx files | ||
compilerOptions.jsx = modules.typescript.JsxEmit.Preserve; | ||
function isAstroProject(project: ts.server.Project, parsedCommandLine: ts.ParsedCommandLine | undefined) { | ||
if (parsedCommandLine) { | ||
const astroFiles = readProjectAstroFilesFromFs(ts, project, parsedCommandLine); | ||
// detect which JSX namespace to use (astro | astronative) if not specified or not compatible | ||
if (!compilerOptions.jsxFactory?.startsWith('astro')) { | ||
// Default to regular astro, this causes the usage of the "astro.JSX" namespace | ||
// We don't need to add a switch for astro-native because the jsx is only relevant | ||
// within Astro files, which this plugin does not deal with. | ||
compilerOptions.jsxFactory = 'astro.createElement'; | ||
if (astroFiles.length > 0) return true; | ||
} | ||
} | ||
function isAstroProject(info: ts.server.PluginCreateInfo) { | ||
// Add more checks like "no Astro file found" or "no config file found"? | ||
const compilerOptions = info.project.getCompilerOptions(); | ||
const isNoJsxProject = | ||
(!compilerOptions.jsx || compilerOptions.jsx === modules.typescript.JsxEmit.Preserve) && | ||
(!compilerOptions.jsxFactory || compilerOptions.jsxFactory.startsWith('astro')) && | ||
!compilerOptions.jsxFragmentFactory && | ||
!compilerOptions.jsxImportSource; | ||
return isNoJsxProject; | ||
try { | ||
const compilerOptions = project.getCompilerOptions(); | ||
const hasAstroInstalled = | ||
typeof compilerOptions.configFilePath !== 'string' || | ||
require.resolve('astro', { paths: [compilerOptions.configFilePath] }); | ||
return hasAstroInstalled; | ||
} catch (e) { | ||
project.projectService.logger.info(e as string); | ||
return false; | ||
} | ||
} | ||
@@ -64,0 +64,0 @@ |
import type ts from 'typescript/lib/tsserverlibrary'; | ||
import { Logger } from '../logger.js'; | ||
import type { Logger } from '../logger.js'; | ||
import { isAstroFilePath, replaceDeep } from '../utils.js'; | ||
@@ -30,5 +30,16 @@ | ||
ls.getCompletionEntryDetails = (fileName, position, entryName, formatOptions, source, preferences, data) => { | ||
const details = getCompletionEntryDetails(fileName, position, entryName, formatOptions, source, preferences, data); | ||
if (details || !isAstroFilePath(source || '')) { | ||
return details; | ||
if (!isAstroFilePath(source || '')) { | ||
const details = getCompletionEntryDetails( | ||
fileName, | ||
position, | ||
entryName, | ||
formatOptions, | ||
source, | ||
preferences, | ||
data | ||
); | ||
if (details) { | ||
return details; | ||
} | ||
} | ||
@@ -35,0 +46,0 @@ |
import type ts from 'typescript/lib/tsserverlibrary'; | ||
import { AstroSnapshotManager } from '../astro-snapshots'; | ||
import { Logger } from '../logger'; | ||
import type { AstroSnapshotManager } from '../astro-snapshots'; | ||
import { isAstroFilePath, isNotNullOrUndefined } from '../utils'; | ||
export function decorateGetDefinition( | ||
ls: ts.LanguageService, | ||
snapshotManager: AstroSnapshotManager, | ||
logger: Logger | ||
): void { | ||
export function decorateGetDefinition(ls: ts.LanguageService, snapshotManager: AstroSnapshotManager): void { | ||
const getDefinitionAndBoundSpan = ls.getDefinitionAndBoundSpan; | ||
@@ -12,0 +7,0 @@ ls.getDefinitionAndBoundSpan = (fileName, position) => { |
import type ts from 'typescript/lib/tsserverlibrary'; | ||
import { Logger } from '../logger.js'; | ||
import { isAstroFilePath } from '../utils.js'; | ||
export function decorateDiagnostics(ls: ts.LanguageService, logger: Logger): void { | ||
export function decorateDiagnostics(ls: ts.LanguageService): void { | ||
decorateSyntacticDiagnostics(ls); | ||
@@ -7,0 +6,0 @@ decorateSemanticDiagnostics(ls); |
import type ts from 'typescript/lib/tsserverlibrary'; | ||
import { AstroSnapshotManager } from '../astro-snapshots.js'; | ||
import { Logger } from '../logger'; | ||
import type { AstroSnapshotManager } from '../astro-snapshots.js'; | ||
import type { Logger } from '../logger'; | ||
import { isAstroFilePath, isNotNullOrUndefined } from '../utils.js'; | ||
@@ -5,0 +5,0 @@ |
import type ts from 'typescript/lib/tsserverlibrary'; | ||
import { AstroSnapshotManager } from '../astro-snapshots.js'; | ||
import { Logger } from '../logger.js'; | ||
import type { AstroSnapshotManager } from '../astro-snapshots.js'; | ||
import { isAstroFilePath, isNotNullOrUndefined } from '../utils.js'; | ||
export function decorateGetImplementation( | ||
ls: ts.LanguageService, | ||
snapshotManager: AstroSnapshotManager, | ||
logger: Logger | ||
): void { | ||
export function decorateGetImplementation(ls: ts.LanguageService, snapshotManager: AstroSnapshotManager): void { | ||
const getImplementationAtPosition = ls.getImplementationAtPosition; | ||
@@ -12,0 +7,0 @@ ls.getImplementationAtPosition = (fileName, position) => { |
import type ts from 'typescript/lib/tsserverlibrary'; | ||
import { AstroSnapshotManager } from '../astro-snapshots.js'; | ||
import { Logger } from '../logger'; | ||
import { isAstroFilePath } from '../utils.js'; | ||
import type { AstroSnapshotManager } from '../astro-snapshots.js'; | ||
import type { Logger } from '../logger'; | ||
import { decorateCompletions } from './completions.js'; | ||
import { decorateGetDefinition } from './definition.js'; | ||
import { decorateDiagnostics } from './diagnostics.js'; | ||
import { decorateGetFileReferences } from './file-references.js'; | ||
import { decorateFindReferences } from './find-references.js'; | ||
import { decorateGetImplementation } from './implementation.js'; | ||
import { decorateLineColumnOffset } from './line-column-offset.js'; | ||
import { decorateRename } from './rename.js'; | ||
@@ -17,28 +18,12 @@ | ||
): ts.LanguageService { | ||
patchLineColumnOffset(ls, snapshotManager); | ||
decorateLineColumnOffset(ls, snapshotManager); | ||
decorateRename(ls, snapshotManager, logger); | ||
decorateDiagnostics(ls, logger); | ||
decorateDiagnostics(ls); | ||
decorateFindReferences(ls, snapshotManager, logger); | ||
decorateCompletions(ls, logger); | ||
decorateGetDefinition(ls, snapshotManager, logger); | ||
decorateGetImplementation(ls, snapshotManager, logger); | ||
decorateGetDefinition(ls, snapshotManager); | ||
decorateGetImplementation(ls, snapshotManager); | ||
decorateGetFileReferences(ls, snapshotManager); | ||
return ls; | ||
} | ||
function patchLineColumnOffset(ls: ts.LanguageService, snapshotManager: AstroSnapshotManager) { | ||
if (!ls.toLineColumnOffset) { | ||
return; | ||
} | ||
// We need to patch this because (according to source, only) getDefinition uses this | ||
const toLineColumnOffset = ls.toLineColumnOffset; | ||
ls.toLineColumnOffset = (fileName, position) => { | ||
if (isAstroFilePath(fileName)) { | ||
const snapshot = snapshotManager.get(fileName); | ||
if (snapshot) { | ||
return snapshot.positionAt(position); | ||
} | ||
} | ||
return toLineColumnOffset(fileName, position); | ||
}; | ||
} |
import type ts from 'typescript/lib/tsserverlibrary'; | ||
import { AstroSnapshotManager } from '../astro-snapshots.js'; | ||
import { Logger } from '../logger.js'; | ||
import type { AstroSnapshotManager } from '../astro-snapshots.js'; | ||
import type { Logger } from '../logger.js'; | ||
import { isAstroFilePath, isNotNullOrUndefined } from '../utils.js'; | ||
@@ -5,0 +5,0 @@ |
import type ts from 'typescript/lib/tsserverlibrary'; | ||
import { AstroSnapshotManager } from './astro-snapshots.js'; | ||
import type { AstroSnapshotManager } from './astro-snapshots.js'; | ||
import { createAstroSys } from './astro-sys.js'; | ||
import { Logger } from './logger.js'; | ||
import type { Logger } from './logger.js'; | ||
import { ensureRealAstroFilePath, isVirtualAstroFilePath } from './utils.js'; | ||
@@ -76,2 +76,9 @@ | ||
// Patch readDirectory so we get completions for .astro files | ||
const origReadDirectory = project.readDirectory.bind(project); | ||
project.readDirectory = (path, extensions, exclude, include, depth) => { | ||
const extensionsWithAstro = (extensions ?? []).concat('.astro', '.md', '.mdx'); | ||
return origReadDirectory(path, extensionsWithAstro, exclude, include, depth); | ||
}; | ||
function resolveModuleNames( | ||
@@ -84,3 +91,4 @@ moduleNames: string[], | ||
): Array<ts.ResolvedModule | undefined> { | ||
logger.log('Resolving modules names for ' + containingFile); | ||
// logger.log('Resolving modules names for ' + containingFile); | ||
// Try resolving all module names with the original method first. | ||
@@ -134,3 +142,3 @@ // The ones that are undefined will be re-checked if they are a | ||
const resolvedAstroModule: ts.ResolvedModuleFull = { | ||
extension: snapshot.isTsFile ? typescript.Extension.Tsx : typescript.Extension.Jsx, | ||
extension: typescript.Extension.Tsx, | ||
resolvedFileName, | ||
@@ -137,0 +145,0 @@ }; |
@@ -22,22 +22,2 @@ export function isAstroFilePath(filePath: string) { | ||
/** | ||
* Checks if this a section that should be completely ignored | ||
* because it's purely generated. | ||
*/ | ||
export function isInGeneratedCode(text: string, start: number, end: number) { | ||
const lineStart = text.lastIndexOf('\n', start); | ||
const lineEnd = text.indexOf('\n', end); | ||
const lastStart = text.substring(lineStart, start).lastIndexOf('/*Ωignore_startΩ*/'); | ||
const lastEnd = text.substring(lineStart, start).lastIndexOf('/*Ωignore_endΩ*/'); | ||
return lastStart > lastEnd && text.substring(end, lineEnd).includes('/*Ωignore_endΩ*/'); | ||
} | ||
/** | ||
* Checks that this isn't a text span that should be completely ignored | ||
* because it's purely generated. | ||
*/ | ||
export function isNoTextSpanInGeneratedCode(text: string, span: ts.TextSpan) { | ||
return !isInGeneratedCode(text, span.start, span.start + span.length); | ||
} | ||
/** | ||
* Replace all occurrences of a string within an object with another string, | ||
@@ -68,1 +48,30 @@ */ | ||
} | ||
export function getConfigPathForProject(project: ts.server.Project) { | ||
return ( | ||
(project as ts.server.ConfiguredProject).canonicalConfigFilePath ?? | ||
(project.getCompilerOptions() as any).configFilePath | ||
); | ||
} | ||
export function readProjectAstroFilesFromFs( | ||
ts: typeof import('typescript/lib/tsserverlibrary'), | ||
project: ts.server.Project, | ||
parsedCommandLine: ts.ParsedCommandLine | ||
) { | ||
const fileSpec: TsFilesSpec = parsedCommandLine.raw; | ||
const { include, exclude } = fileSpec; | ||
if (include?.length === 0) { | ||
return []; | ||
} | ||
return ts.sys | ||
.readDirectory(project.getCurrentDirectory() || process.cwd(), ['.astro'], exclude, include) | ||
.map(ts.server.toNormalizedPath); | ||
} | ||
export interface TsFilesSpec { | ||
include?: readonly string[]; | ||
exclude?: readonly string[]; | ||
} |
@@ -7,3 +7,4 @@ { | ||
"target": "ES2020", | ||
"module": "CommonJS" | ||
"module": "CommonJS", | ||
"importsNotUsedAsValues": "error" | ||
}, | ||
@@ -10,0 +11,0 @@ "include": ["src"], |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
128034
52
2706
3
10
2
1
+ Added@astrojs/compiler@^0.29.15
+ Addedsynckit@^0.8.4
+ Added@astrojs/compiler@0.29.19(transitive)
+ Added@jridgewell/resolve-uri@3.1.2(transitive)
+ Added@jridgewell/sourcemap-codec@1.5.0(transitive)
+ Added@jridgewell/trace-mapping@0.3.25(transitive)
+ Added@pkgr/core@0.1.1(transitive)
+ Addedsynckit@0.8.8(transitive)
+ Addedtslib@2.8.1(transitive)
- Removedsourcemap-codec@^1.4.8
- Removedsourcemap-codec@1.4.8(transitive)