vueFile.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.VueFile = void 0;
  4. const language_core_1 = require("@volar/language-core");
  5. const computedFiles_1 = require("./computedFiles");
  6. const computedMappings_1 = require("./computedMappings");
  7. const computedSfc_1 = require("./computedSfc");
  8. const computedVueSfc_1 = require("./computedVueSfc");
  9. const computeds_1 = require("computeds");
  10. const jsxReg = /^\.(js|ts)x?$/;
  11. class VueFile {
  12. get embeddedFiles() {
  13. return this.getEmbeddedFiles();
  14. }
  15. get mainScriptName() {
  16. let res = '';
  17. (0, language_core_1.forEachEmbeddedFile)(this, file => {
  18. if (file.kind === language_core_1.FileKind.TypeScriptHostFile && file.fileName.replace(this.fileName, '').match(jsxReg)) {
  19. res = file.fileName;
  20. }
  21. });
  22. return res;
  23. }
  24. get snapshot() {
  25. return this._snapshot();
  26. }
  27. get mappings() {
  28. return this.getMappings();
  29. }
  30. constructor(fileName, initSnapshot, vueCompilerOptions, plugins, ts, codegenStack) {
  31. this.fileName = fileName;
  32. this.initSnapshot = initSnapshot;
  33. this.vueCompilerOptions = vueCompilerOptions;
  34. this.plugins = plugins;
  35. this.ts = ts;
  36. this.codegenStack = codegenStack;
  37. // computeds
  38. this.getVueSfc = (0, computedVueSfc_1.computedVueSfc)(this.plugins, this.fileName, () => this._snapshot());
  39. this.sfc = (0, computedSfc_1.computedSfc)(this.ts, this.plugins, this.fileName, () => this._snapshot(), this.getVueSfc);
  40. this.getMappings = (0, computedMappings_1.computedMappings)(() => this._snapshot(), this.sfc);
  41. this.getEmbeddedFiles = (0, computedFiles_1.computedFiles)(this.plugins, this.fileName, this.sfc, this.codegenStack);
  42. // others
  43. this.capabilities = language_core_1.FileCapabilities.full;
  44. this.kind = language_core_1.FileKind.TextFile;
  45. this.codegenStacks = [];
  46. this._snapshot = (0, computeds_1.signal)(initSnapshot);
  47. }
  48. update(newSnapshot) {
  49. this._snapshot.set(newSnapshot);
  50. }
  51. }
  52. exports.VueFile = VueFile;
  53. //# sourceMappingURL=vueFile.js.map