typescript-svelte-plugin
Advanced tools
Comparing version 0.3.36 to 0.3.37
@@ -29,2 +29,8 @@ "use strict"; | ||
}); | ||
if (completions.optionalReplacementSpan) { | ||
completions.optionalReplacementSpan = { | ||
...completions.optionalReplacementSpan, | ||
start: toOriginalPos(completions.optionalReplacementSpan.start).pos | ||
}; | ||
} | ||
} | ||
@@ -31,0 +37,0 @@ } |
@@ -126,3 +126,4 @@ "use strict"; | ||
messageText: `Invalid export '${exportName}' (valid exports are ${validExports.join(', ')}, or anything with a '_' prefix)`, | ||
category: ts.DiagnosticCategory.Error, | ||
// make it a warning in case people are stuck on old versions and new exports are added to SvelteKit | ||
category: ts.DiagnosticCategory.Warning, | ||
code: 71001 // arbitrary | ||
@@ -129,0 +130,0 @@ }); |
@@ -21,6 +21,4 @@ "use strict"; | ||
const name = node.text; | ||
if (name in sveltekit_1.kitExports) { | ||
quickInfo.documentation = !quickInfo.documentation?.length | ||
? sveltekit_1.kitExports[name].documentation | ||
: quickInfo.documentation; | ||
if (name in sveltekit_1.kitExports && !quickInfo.documentation?.length) { | ||
quickInfo.documentation = sveltekit_1.kitExports[name].documentation; | ||
} | ||
@@ -27,0 +25,0 @@ } |
@@ -18,2 +18,3 @@ "use strict"; | ||
const file_references_1 = require("./file-references"); | ||
const move_to_file_1 = require("./move-to-file"); | ||
const patchedProject = new Set(); | ||
@@ -48,2 +49,3 @@ function isPatched(project) { | ||
(0, file_references_1.decorateFileReferences)(ls, snapshotManager); | ||
(0, move_to_file_1.decorateMoveToRefactoringFileSuggestions)(ls); | ||
decorateDispose(ls, info.project, onDispose); | ||
@@ -50,0 +52,0 @@ return ls; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -473,2 +450,14 @@ exports.getVirtualLS = exports.isKitRouteExportAllowedIn = exports.kitExports = void 0; | ||
] | ||
}, | ||
reroute: { | ||
allowedIn: [], | ||
displayParts: [], | ||
documentation: [ | ||
{ | ||
text: `This function allows you to change how URLs are translated into routes. ` + | ||
`The returned pathname (which defaults to url.pathname) is used to select the route and its parameters. ` + | ||
`More info: https://kit.svelte.dev/docs/hooks#universal-hooks-reroute`, | ||
kind: 'text' | ||
} | ||
] | ||
} | ||
@@ -492,2 +481,8 @@ }; | ||
exports.isKitRouteExportAllowedIn = isKitRouteExportAllowedIn; | ||
const kitFilesSettings = { | ||
paramsPath: 'src/params', | ||
clientHooksPath: 'src/hooks.client', | ||
serverHooksPath: 'src/hooks.server', | ||
universalHooksPath: 'src/hooks' | ||
}; | ||
function getProxiedLanguageService(info, ts, logger) { | ||
@@ -507,5 +502,2 @@ const cachedProxiedLanguageService = cache.get(info); | ||
this.files = {}; | ||
this.paramsPath = 'src/params'; | ||
this.serverHooksPath = 'src/hooks.server'; | ||
this.clientHooksPath = 'src/hooks.client'; | ||
this.resolveModuleNames = originalLanguageServiceHost.resolveModuleNames | ||
@@ -548,25 +540,36 @@ ? (...args) => { | ||
: undefined; | ||
const configPath = info.project.getCurrentDirectory() + '/svelte.config.js'; | ||
Promise.resolve(`${configPath}`).then(s => __importStar(require(s))).then((module) => { | ||
const config = module.default; | ||
if (config.kit && config.kit.files) { | ||
if (config.kit.files.params) { | ||
this.paramsPath = config.kit.files.params; | ||
} | ||
if (config.kit.files.hooks) { | ||
this.serverHooksPath ||= config.kit.files.hooks.server; | ||
this.clientHooksPath ||= config.kit.files.hooks.client; | ||
} | ||
// We could be more sophisticated with only removing the files that are actually | ||
// wrong but this is good enough given how rare it is that this setting is used | ||
Object.keys(this.files) | ||
.filter((name) => { | ||
return !name.includes('src/hooks') && !name.includes('src/params'); | ||
}) | ||
.forEach((name) => { | ||
delete this.files[name]; | ||
}); | ||
} | ||
}) | ||
.catch(() => { }); | ||
// This never worked due to configPath being the wrong format and due to https://github.com/microsoft/TypeScript/issues/43329 . | ||
// Noone has complained about this not working, so this is commented out for now, revisit if it ever comes up. | ||
// const configPath = info.project.getCurrentDirectory() + '/svelte.config.js'; | ||
// (import(configPath)) as Promise<any>) | ||
// .then((module) => { | ||
// const config = module.default; | ||
// if (config.kit && config.kit.files) { | ||
// if (config.kit.files.params) { | ||
// this.paramsPath = config.kit.files.params; | ||
// } | ||
// if (config.kit.files.hooks) { | ||
// this.serverHooksPath ||= config.kit.files.hooks.server; | ||
// this.clientHooksPath ||= config.kit.files.hooks.client; | ||
// this.universalHooksPath ||= config.kit.files.hooks.universal; | ||
// } | ||
// logger?.log( | ||
// `Using SvelteKit files config: ${JSON.stringify( | ||
// config.kit.files.hooks | ||
// )}` | ||
// ); | ||
// // We could be more sophisticated with only removing the files that are actually | ||
// // wrong but this is good enough given how rare it is that this setting is used | ||
// Object.keys(this.files) | ||
// .filter((name) => { | ||
// return !name.includes('src/hooks') && !name.includes('src/params'); | ||
// }) | ||
// .forEach((name) => { | ||
// delete this.files[name]; | ||
// }); | ||
// } | ||
// }) | ||
// .catch((e) => { | ||
// logger?.log('error loading SvelteKit file', e); | ||
// }); | ||
} | ||
@@ -615,7 +618,3 @@ log() { } | ||
upsertKitFile(fileName) { | ||
const result = svelte2tsx_1.internalHelpers.upsertKitFile(ts, fileName, { | ||
clientHooksPath: this.clientHooksPath, | ||
paramsPath: this.paramsPath, | ||
serverHooksPath: this.serverHooksPath | ||
}, () => info.languageService.getProgram()?.getSourceFile(fileName)); | ||
const result = svelte2tsx_1.internalHelpers.upsertKitFile(ts, fileName, kitFilesSettings, () => info.languageService.getProgram()?.getSourceFile(fileName)); | ||
if (!result) { | ||
@@ -654,3 +653,3 @@ return; | ||
const languageServiceHost = new ProxiedLanguageServiceHost(); | ||
const languageService = ts.createLanguageService(languageServiceHost, createProxyRegistry(ts, originalLanguageServiceHost, languageServiceHost)); | ||
const languageService = ts.createLanguageService(languageServiceHost, createProxyRegistry(ts, originalLanguageServiceHost, kitFilesSettings)); | ||
cache.set(info, { languageService, languageServiceHost }); | ||
@@ -657,0 +656,0 @@ return { |
{ | ||
"name": "typescript-svelte-plugin", | ||
"version": "0.3.36", | ||
"version": "0.3.37", | ||
"description": "A TypeScript Plugin providing Svelte intellisense", | ||
@@ -20,3 +20,3 @@ "main": "dist/src/index.js", | ||
"@jridgewell/sourcemap-codec": "^1.4.14", | ||
"svelte2tsx": "~0.6.8" | ||
"svelte2tsx": "~0.7.0" | ||
}, | ||
@@ -23,0 +23,0 @@ "scripts": { |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
147558
54
3375
3
+ Addedsvelte2tsx@0.7.35(transitive)
- Removedsvelte2tsx@0.6.27(transitive)
Updatedsvelte2tsx@~0.7.0