(svelteSource: string, options?: FindScriptTagsOptions | undefined): FoundScriptTags import {findScriptTags} from 'svelte-docinfo/svelte-scripts.js'; Find a component's script tags: the <script> tags at the top level of the
source, in source order. A <script> nested in an element, a block, or
<svelte:head> isn't one, matching Svelte, which reads only a top-level
tag as the instance or module script.
scanScriptTags finds the candidates. When it proves every one of them
top-level, which covers the usual component with its scripts ahead of the
template, that's the answer. Otherwise Svelte's parser decides: the source
is parsed with script and style content blanked, and the tags at the
offsets of the root's instance and module are kept. svelte2tsx parses
the same blanked source, but demotes only the tags the parser reads as
nested elements, so a tag spelled inside an expression string or an
attribute value is still a script to it and isn't one here.
Limits: a </script> or </style> inside a string or comment ends that
tag's blanked content early, and what's left over is parsed as template.
And svelte2tsx's own tag matcher is narrower in one spelling: it doesn't
take a closing tag with whitespace before the > (</script >), so there
its virtual doesn't have the scripts as written while this returns them. A
legacy component
written that way documents no props, with a svelte_prop_failed warning
for each export let; a runes one documents none, with no warning.
svelteSource
the full Svelte source code
stringoptions?
returns
FoundScriptTags the top-level script tags and how they were decided