typescript-svelte-plugin 0.3.47 → 0.3.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.decorateCallHierarchy = decorateCallHierarchy;
4
4
  const utils_1 = require("../utils");
5
+ const svelte2tsx_1 = require("svelte2tsx");
5
6
  const ENSURE_COMPONENT_HELPER = '__sveltets_2_ensureComponent';
6
7
  function decorateCallHierarchy(ls, snapshotManager, typescript) {
7
8
  // don't need to patch prepare. It's always a ts/js file
@@ -51,7 +52,7 @@ function decorateCallHierarchy(ls, snapshotManager, typescript) {
51
52
  const renderFunctionOffset = isComponentModulePosition(fileName, position) && sourceFile
52
53
  ? sourceFile.statements
53
54
  .find((statement) => typescript.isFunctionDeclaration(statement) &&
54
- statement.name?.getText() === 'render')
55
+ statement.name?.getText() === svelte2tsx_1.internalHelpers.renderName)
55
56
  ?.name?.getStart()
56
57
  : -1;
57
58
  const offset = renderFunctionOffset != null && renderFunctionOffset >= 0
@@ -121,7 +122,7 @@ function decorateCallHierarchy(ls, snapshotManager, typescript) {
121
122
  if ((0, utils_1.isGeneratedSvelteComponentName)(item.name)) {
122
123
  return toComponentCallHierarchyItem(snapshot, item.file);
123
124
  }
124
- if (item.name === 'render') {
125
+ if (item.name === svelte2tsx_1.internalHelpers.renderName) {
125
126
  const end = item.selectionSpan.start + item.selectionSpan.length;
126
127
  const renderFunction = sourceFile.statements.find((statement) => statement.getStart() <= item.selectionSpan.start && statement.getEnd() >= end);
127
128
  if (!renderFunction || !sourceFile.statements.includes(renderFunction)) {
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.decorateNavigateToItems = decorateNavigateToItems;
4
4
  const utils_1 = require("../utils");
5
+ const svelte2tsx_1 = require("svelte2tsx");
5
6
  function decorateNavigateToItems(ls, snapshotManager) {
6
7
  const getNavigateToItems = ls.getNavigateToItems;
7
8
  ls.getNavigateToItems = (...args) => {
@@ -12,12 +13,15 @@ function decorateNavigateToItems(ls, snapshotManager) {
12
13
  return item;
13
14
  }
14
15
  if (item.name.startsWith('__sveltets_') ||
15
- (item.name === 'render' && !item.containerName)) {
16
+ item.name === svelte2tsx_1.internalHelpers.renderName ||
17
+ item.name.startsWith('$$')) {
16
18
  return;
17
19
  }
18
- let textSpan = snapshotManager
19
- .get(item.fileName)
20
- ?.getOriginalTextSpan(item.textSpan);
20
+ const snapshot = snapshotManager.get(item.fileName);
21
+ if (!snapshot || !(0, utils_1.isNoTextSpanInGeneratedCode)(snapshot.getText(), item.textSpan)) {
22
+ return;
23
+ }
24
+ let textSpan = snapshot.getOriginalTextSpan(item.textSpan);
21
25
  if (!textSpan) {
22
26
  if ((0, utils_1.isGeneratedSvelteComponentName)(item.name)) {
23
27
  textSpan = { start: 0, length: 1 };
@@ -26,12 +30,24 @@ function decorateNavigateToItems(ls, snapshotManager) {
26
30
  return;
27
31
  }
28
32
  }
33
+ const containerName = item.containerName === svelte2tsx_1.internalHelpers.renderName || !item.containerName
34
+ ? isInScript(textSpan.start, snapshot.getOriginalText())
35
+ ? 'script'
36
+ : ''
37
+ : item.containerName;
29
38
  return {
30
39
  ...item,
40
+ containerName,
31
41
  textSpan
32
42
  };
33
43
  })
34
44
  .filter(utils_1.isNotNullOrUndefined);
35
45
  };
36
46
  }
47
+ function isInScript(offset, originalText) {
48
+ const text = originalText.slice(0, offset);
49
+ const lastScriptTag = text.lastIndexOf('<script');
50
+ const lastCloseTag = text.lastIndexOf('</script>');
51
+ return lastScriptTag > lastCloseTag;
52
+ }
37
53
  //# sourceMappingURL=navigate-to-items.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typescript-svelte-plugin",
3
- "version": "0.3.47",
3
+ "version": "0.3.48",
4
4
  "description": "A TypeScript Plugin providing Svelte intellisense",
5
5
  "main": "dist/src/index.js",
6
6
  "keywords": [