From a510c490c28224d05336e37bf471e85ece789c60 Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Tue, 27 Aug 2024 21:10:54 +0200 Subject: [PATCH] chore: bump magic-string requires adjustments of mapping tests and a fix in the InlayHintProvider, because more things are mappable now --- .../typescript/features/InlayHintProvider.ts | 26 +- packages/svelte2tsx/package.json | 2 +- .../samples/action-directive/mappings.jsx | 30 +- .../samples/await-block/mappings.jsx | 62 ++- .../samples/component-props/mappings.jsx | 31 +- .../samples/each-block/mappings.jsx | 30 +- .../samples/element-attributes/mappings.jsx | 36 +- .../sourcemaps/samples/if-block/mappings.jsx | 12 +- .../samples/import-equal/mappings.jsx | 8 +- .../samples/large-sample-1/mappings.jsx | 371 +++++++++++++----- .../test/sourcemaps/samples/let/mappings.jsx | 8 +- .../samples/reactive-statements/mappings.jsx | 8 +- .../samples/reserved-variables/mappings.jsx | 22 +- .../sourcemaps/samples/slot-let/mappings.jsx | 14 +- .../sourcemaps/samples/slots/mappings.jsx | 18 +- pnpm-lock.yaml | 4 +- 16 files changed, 503 insertions(+), 179 deletions(-) diff --git a/packages/language-server/src/plugins/typescript/features/InlayHintProvider.ts b/packages/language-server/src/plugins/typescript/features/InlayHintProvider.ts index a11fb0f43..7db6f9f82 100644 --- a/packages/language-server/src/plugins/typescript/features/InlayHintProvider.ts +++ b/packages/language-server/src/plugins/typescript/features/InlayHintProvider.ts @@ -1,4 +1,4 @@ -import ts from 'typescript'; +import ts, { ArrowFunction } from 'typescript'; import { CancellationToken } from 'vscode-languageserver'; import { Position, @@ -69,6 +69,7 @@ export class InlayHintProviderImpl implements InlayHintProvider { inlayHint.position !== renderFunctionReturnTypeLocation && !this.isSvelte2tsxFunctionHints(sourceFile, inlayHint) && !this.isGeneratedVariableTypeHint(sourceFile, inlayHint) && + !this.isGeneratedAsyncFunctionReturnType(sourceFile, inlayHint) && !this.isGeneratedFunctionReturnType(sourceFile, inlayHint) ) .map(async (inlayHint) => ({ @@ -254,6 +255,29 @@ export class InlayHintProviderImpl implements InlayHintProvider { ); } + /** `true` if is one of the `async () => {...}` functions svelte2tsx generates */ + private isGeneratedAsyncFunctionReturnType(sourceFile: ts.SourceFile, inlayHint: ts.InlayHint) { + if (inlayHint.kind !== ts.InlayHintKind.Type) { + return false; + } + + const expression = findContainingNode( + sourceFile, + { start: inlayHint.position, length: 0 }, + (node): node is ArrowFunction => ts.isArrowFunction(node) + ); + + if ( + !expression?.modifiers?.some((m) => m.kind === ts.SyntaxKind.AsyncKeyword) || + !expression.parent?.parent || + !ts.isBlock(expression.parent.parent) + ) { + return false; + } + + return this.getTypeAnnotationPosition(expression) === inlayHint.position; + } + private isGeneratedFunctionReturnType(sourceFile: ts.SourceFile, inlayHint: ts.InlayHint) { if (inlayHint.kind !== ts.InlayHintKind.Type) { return false; diff --git a/packages/svelte2tsx/package.json b/packages/svelte2tsx/package.json index 97f42d5ea..258f5397e 100644 --- a/packages/svelte2tsx/package.json +++ b/packages/svelte2tsx/package.json @@ -31,7 +31,7 @@ "@types/vfile": "^3.0.2", "builtin-modules": "^3.3.0", "estree-walker": "^2.0.1", - "magic-string": "^0.27.0", + "magic-string": "^0.30.11", "mocha": "^9.2.0", "periscopic": "^2.0.2", "rollup": "3.7.5", diff --git a/packages/svelte2tsx/test/sourcemaps/samples/action-directive/mappings.jsx b/packages/svelte2tsx/test/sourcemaps/samples/action-directive/mappings.jsx index abaf91f05..9864b0bcc 100644 --- a/packages/svelte2tsx/test/sourcemaps/samples/action-directive/mappings.jsx +++ b/packages/svelte2tsx/test/sourcemaps/samples/action-directive/mappings.jsx @@ -7,10 +7,12 @@ async•()•=>•{•{const•$$action_0•=•__sveltets_2_ensureAction(action < action/ element su ↲ #================================================================== # Order-breaking mappings ↲ [original] line 1 +↲ [original] line 1 (rest generated at line 4) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 4 + ↲ +↲ [original] line 1 (rest generated at line 3) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {const $$action_0 = __sveltets_2_ensureAction(action(svelteHTML.mapElementTag('element')));{ svelteHTML.createElement("element", __sveltets_2_union($$action_0), { });}}{/** •{const•$$action_0•=•__sveltets_2_ensureAction(action(svelteHTML.mapElementTag('element')));{•svelteHTML.createElement("element",•__sveltets_2_union($$action_0),•{••});}}↲ [generated] line 5 @@ -30,27 +32,31 @@ async•()•=>•{•{const•$$action_0•=•__sveltets_2_ensureAction(action • ↲ [generated] subset / ↲ / ↲ -/>↲ [original] line 5 +/>↲ [original] line 5 (rest generated at line 6) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 6 + ↲ +/>↲ [original] line 5 (rest generated at line 5) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {const $$action_0 = __sveltets_2_ensureAction(action.nested.method(svelteHTML.mapElementTag('element'),(foo)));{ svelteHTML.createElement("element", __sveltets_2_union($$action_0), { });}}{/** ••{const•$$action_0•=•__sveltets_2_ensureAction(action.nested.method(svelteHTML.mapElementTag('element'),(foo)));{•svelteHTML.createElement("element",•__sveltets_2_union($$action_0),•{••});}}↲ [generated] line 7 <> action.nested.method= foo} element s{u ↲ #============================================== #=============================== # Order-breaking mappings ↲ -↲ [original] line 7 +↲ [original] line 7 (rest generated at line 8) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 8 + ↲ +↲ [original] line 7 (rest generated at line 7) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {const $$action_0 = __sveltets_2_ensureAction(action(svelteHTML.mapElementTag('element'),($foo)));{ svelteHTML.createElement("element", __sveltets_2_union($$action_0), { });}}{/** •{const•$$action_0•=•__sveltets_2_ensureAction(action(svelteHTML.mapElementTag('element'),($foo)));{•svelteHTML.createElement("element",•__sveltets_2_union($$action_0),•{•••});}}↲ [generated] line 9 • ↲ [generated] subset / ↲ / ↲ -/>↲ [original] line 11 +/>↲ [original] line 11 (rest generated at line 10) •{const•$$action_0•=•__sveltets_2_ensureAction(action(svelteHTML.mapElementTag('element'),($foo)));{•svelteHTML.createElement("element",•__sveltets_2_union($$action_0),•{•••});}}↲ [generated] line 9 •{const•$$action_0•=•__sveltets_2_ensureAction( element",•__sveltets_2_union($$action_0),•{ });}} [generated] subset @@ -66,7 +72,9 @@ async•()•=>•{•{const•$$action_0•=•__sveltets_2_ensureAction(action ╚use:action={$foo}↲ [original] line 10 ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 10 + ↲ +/>↲ [original] line 11 (rest generated at line 9) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {const $$action_0 = __sveltets_2_ensureAction(action(svelteHTML.mapElementTag('element'),({ foo })));{ svelteHTML.createElement("element", __sveltets_2_union($$action_0), { });}}{/** •{const•$$action_0•=•__sveltets_2_ensureAction(action(svelteHTML.mapElementTag('element'),({•foo•})));{•svelteHTML.createElement("element",•__sveltets_2_union($$action_0),•{•••});}}↲ [generated] line 11 @@ -86,10 +94,12 @@ async•()•=>•{•{const•$$action_0•=•__sveltets_2_ensureAction(action • ↲ [generated] subset / ↲ / ↲ -/>↲ [original] line 15 +/>↲ [original] line 15 (rest generated at line 12) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 12 + ↲ +/>↲ [original] line 15 (rest generated at line 11) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {const $$action_0 = __sveltets_2_ensureAction(action(svelteHTML.mapElementTag('element'),({ {/** •{const•$$action_0•=•__sveltets_2_ensureAction(action(svelteHTML.mapElementTag('element'),({•↲ [generated] line 13 diff --git a/packages/svelte2tsx/test/sourcemaps/samples/await-block/mappings.jsx b/packages/svelte2tsx/test/sourcemaps/samples/await-block/mappings.jsx index 35fff79b7..8e81cad42 100644 --- a/packages/svelte2tsx/test/sourcemaps/samples/await-block/mappings.jsx +++ b/packages/svelte2tsx/test/sourcemaps/samples/await-block/mappings.jsx @@ -8,17 +8,23 @@ async•()•=>•{•••{•const•$$_value•=•await•(promise);{•con {t promise• value} ↲ #=========================== Order-breaking mappings { promise•t value}↲ -{#await•promise•then•value}↲ [original] line 1 +{#await•promise•then•value}↲ [original] line 1 (rest generated at line 4) async•()•=>•{•••{•const•$$_value•=•await•(promise);{•const•value•=•$$_value;•↲ [generated] line 3 •{•const•$$_value•=•await•( [generated] subset a a -{/await}↲ [original] line 3 (rest generated at line 5) +{/await}↲ [original] line 3 (rest generated at lines 5, 6) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { svelteHTML.createElement("element", { "foo":value.bar,});} {/** -===# Originless mappings ••••••{•svelteHTML.createElement("element",•{•"foo":value.bar,});}↲ [generated] line 4 +•••• [generated] subset +↲ + ↲ +{#await•promise•then•value}↲ [original] line 1 (rest generated at line 3) + +••••••{•svelteHTML.createElement("element",•{•"foo":value.bar,});}↲ [generated] line 4 + ••{•svelteHTML.createElement("element",•{•"foo":value.bar,});}↲ [generated] subset <> element {f oo= value.bar} ↲ #============================ # Order-breaking mappings ↲ @@ -28,31 +34,39 @@ async•()•=>•{•••{•const•$$_value•=•await•(promise);{•con }}↲ [generated] line 5 { ↲ { ↲ -{/await}↲ [original] line 3 (rest generated at line 3) +{/await}↲ [original] line 3 (rest generated at lines 3, 6) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 6 + ↲ +{/await}↲ [original] line 3 (rest generated at lines 3, 5) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { {/** •••{•↲ [generated] line 7 • ↲ [generated] subset { ↲ { ↲ -{#await•promise}↲ [original] line 5 (rest generated at line 9) +{#await•promise}↲ [original] line 5 (rest generated at lines 8, 9) •••{•↲ [generated] line 7 • [generated] subset : -{:then}↲ [original] line 7 (rest generated at line 9) +{:then}↲ [original] line 7 (rest generated at lines 9, 10) •••{•↲ [generated] line 7 •{• [generated] subset a -{/await}↲ [original] line 9 (rest generated at line 11) +{/await}↲ [original] line 9 (rest generated at lines 11, 12) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { svelteHTML.createElement("element", {});} {/** - # Originless mappings ╚•{•svelteHTML.createElement("element",•{});}↲ [generated] line 8 + ╚ [generated] subset + ↲ + ↲ + {#await•promise}↲ [original] line 5 (rest generated at lines 7, 9) + + ╚•{•svelteHTML.createElement("element",•{});}↲ [generated] line 8 + •{•svelteHTML.createElement("element",•{});}↲ [generated] subset < element / ↲ ↲ [original] line 6 @@ -62,17 +76,23 @@ await•(promise);↲ [generated] line 9 promise); [generated] subset promise} promise} -{#await•promise}↲ [original] line 5 (rest generated at line 7) +{#await•promise}↲ [original] line 5 (rest generated at lines 7, 8) await•(promise);↲ [generated] line 9 await•( ↲ [generated] subset { ↲ { ↲ -{:then}↲ [original] line 7 (rest generated at line 7) +{:then}↲ [original] line 7 (rest generated at lines 7, 10) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { svelteHTML.createElement("element", {});} {/** - # Originless mappings ╚•{•svelteHTML.createElement("element",•{});}↲ [generated] line 10 + ╚ [generated] subset + ↲ + ↲ + {:then}↲ [original] line 7 (rest generated at lines 7, 9) + + ╚•{•svelteHTML.createElement("element",•{});}↲ [generated] line 10 + •{•svelteHTML.createElement("element",•{});}↲ [generated] subset < element / ↲ ↲ [original] line 8 @@ -81,17 +101,19 @@ await•( ↲ [generated] subset }↲ [generated] line 11 {↲ { ↲ -{/await}↲ [original] line 9 (rest generated at line 7) +{/await}↲ [original] line 9 (rest generated at lines 7, 12) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 12 + ↲ +{/await}↲ [original] line 9 (rest generated at lines 7, 11) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { {/** ••{•↲ [generated] line 13 • ↲ [generated] subset { ↲ { ↲ -{#await•$promise}↲ [original] line 11 (rest generated at line 15) +{#await•$promise}↲ [original] line 11 (rest generated at lines 14, 15) ••{•↲ [generated] line 13 •{• [generated] subset @@ -100,8 +122,14 @@ await•( ↲ [generated] subset {/await} [original] line 13 (rest generated at line 15) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { svelteHTML.createElement("element", {});} {/** - # Originless mappings ╚•{•svelteHTML.createElement("element",•{});}↲ [generated] line 14 + ╚ [generated] subset + ↲ + ↲ + {#await•$promise}↲ [original] line 11 (rest generated at lines 13, 15) + + ╚•{•svelteHTML.createElement("element",•{});}↲ [generated] line 14 + •{•svelteHTML.createElement("element",•{});}↲ [generated] subset < element / ↲ ↲ [original] line 12 @@ -111,7 +139,7 @@ await•($promise);}};↲ [generated] line 15 $promise);}};↲ [generated] subset $promise} $promise} -{#await•$promise}↲ [original] line 11 (rest generated at line 13) +{#await•$promise}↲ [original] line 11 (rest generated at lines 13, 14) await•($promise);}};↲ [generated] line 15 await•( [generated] subset diff --git a/packages/svelte2tsx/test/sourcemaps/samples/component-props/mappings.jsx b/packages/svelte2tsx/test/sourcemaps/samples/component-props/mappings.jsx index 86889cddc..e19b69c73 100644 --- a/packages/svelte2tsx/test/sourcemaps/samples/component-props/mappings.jsx +++ b/packages/svelte2tsx/test/sourcemaps/samples/component-props/mappings.jsx @@ -7,30 +7,37 @@ async•()•=>•{••{•const•$$_tnenopmoC0C•=•__sveltets_2_ensureCom <> Component f oo• ↲ #====================================================== Order-breaking mappings ↲ -↲ [original] line 1 +↲ [original] line 1 (rest generated at line 4) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 4 + ↲ +↲ [original] line 1 (rest generated at line 3) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { const $$_tnenopmoC0C = __sveltets_2_ensureComponent(Component); new $$_tnenopmoC0C({ target: __sveltets_2_any(), props: { "foo":`leet`,"bar":true,}});}{/** •{•const•$$_tnenopmoC0C•=•__sveltets_2_ensureComponent(Component);•new•$$_tnenopmoC0C({•target:•__sveltets_2_any(),•props:•{•"foo":`leet`,"bar":true,}});}↲ [generated] line 5 < Component "f oo= leet" b ar/ ↲ # Order-breaking mappings ↲ [original] line 3 +↲ [original] line 3 (rest generated at line 6) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - + ╚↲ [generated] line 6 + ↲ + ↲ + ↲ [original] line 3 (rest generated at line 5) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { const $$_tnenopmoC0C = __sveltets_2_ensureComponent(Component); new $$_tnenopmoC0C({ target: __sveltets_2_any(), props: { ...bar,}});} {/** •{•const•$$_tnenopmoC0C•=•__sveltets_2_ensureComponent(Component);•new•$$_tnenopmoC0C({•target:•__sveltets_2_any(),•props:•{•...bar,}});}↲ [generated] line 7 < Component /...bar} ↲ # Order-breaking mappings ↲ [original] line 5 +↲ [original] line 5 (rest generated at line 8) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 8 + ↲ +↲ [original] line 5 (rest generated at line 7) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { const $$_tnenopmoC0C = __sveltets_2_ensureComponent(Component); new $$_tnenopmoC0C({ target: __sveltets_2_any(), props: { ...bar,}});} {/** •{•const•$$_tnenopmoC0C•=•__sveltets_2_ensureComponent(Component);•new•$$_tnenopmoC0C({•target:•__sveltets_2_any(),•props:•{••...bar,}});}↲ [generated] line 9 @@ -49,10 +56,12 @@ async•()•=>•{••{•const•$$_tnenopmoC0C•=•__sveltets_2_ensureCom • ↲ [generated] subset / ↲ / ↲ -/>↲ [original] line 9 +/>↲ [original] line 9 (rest generated at line 10) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 10 + ↲ +/>↲ [original] line 9 (rest generated at line 9) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { const $$_tnenopmoC0C = __sveltets_2_ensureComponent(Component); new $$_tnenopmoC0C({ target: __sveltets_2_any(), props: { foo:bar,}});/*Ωignore_startΩ*/() => bar = __sveltets_2_any(null);/*Ωignore_endΩ*/}{/** •{•const•$$_tnenopmoC0C•=•__sveltets_2_ensureComponent(Component);•new•$$_tnenopmoC0C({•target:•__sveltets_2_any(),•props:•{•••foo:bar,}});/*Ωignore_startΩ*/()•=>•bar•=•__sveltets_2_any(null);/*Ωignore_endΩ*/}↲ [generated] line 11 @@ -72,10 +81,12 @@ async•()•=>•{••{•const•$$_tnenopmoC0C•=•__sveltets_2_ensureCom • ↲ [generated] subset / ↲ / ↲ -/>↲ [original] line 13 +/>↲ [original] line 13 (rest generated at line 12) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 12 + ↲ +/>↲ [original] line 13 (rest generated at line 11) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { const $$_tnenopmoC0C = __sveltets_2_ensureComponent(Component); const $$_tnenopmoC0 = new $$_tnenopmoC0C({ target: __sveltets_2_any(), props: { }});bar = $$_tnenopmoC0;}};{/** •{•const•$$_tnenopmoC0C•=•__sveltets_2_ensureComponent(Component);•const•$$_tnenopmoC0•=•new•$$_tnenopmoC0C({•target:•__sveltets_2_any(),•props:•{••}});bar•=•$$_tnenopmoC0;}};↲ [generated] line 13 diff --git a/packages/svelte2tsx/test/sourcemaps/samples/each-block/mappings.jsx b/packages/svelte2tsx/test/sourcemaps/samples/each-block/mappings.jsx index 4ae205f2d..7e934b571 100644 --- a/packages/svelte2tsx/test/sourcemaps/samples/each-block/mappings.jsx +++ b/packages/svelte2tsx/test/sourcemaps/samples/each-block/mappings.jsx @@ -19,10 +19,12 @@ async•()•=>•{••for(let•item•of•__sveltets_2_ensureArray(items)){ }↲ [generated] line 5 {↲ { ↲ -{/each}↲ [original] line 3 +{/each}↲ [original] line 3 (rest generated at line 6) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 6 + ↲ +{/each}↲ [original] line 3 (rest generated at line 5) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} for(let item of __sveltets_2_ensureArray(items)){let i = 1; {/** •••for(let•item•of•__sveltets_2_ensureArray(items)){let•i•=•1;↲ [generated] line 7 @@ -41,10 +43,12 @@ async•()•=>•{••for(let•item•of•__sveltets_2_ensureArray(items)){ }↲ [generated] line 9 {↲ { ↲ -{/each}↲ [original] line 7 +{/each}↲ [original] line 7 (rest generated at line 10) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 10 + ↲ +{/each}↲ [original] line 7 (rest generated at line 9) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} for(let { id, name, qty } of __sveltets_2_ensureArray(items)){let i = 1;id; {/** ••••for(let•{•id,•name,•qty•}•of•__sveltets_2_ensureArray(items)){let•i•=•1;id;↲ [generated] line 11 @@ -63,10 +67,12 @@ async•()•=>•{••for(let•item•of•__sveltets_2_ensureArray(items)){ }↲ [generated] line 13 {↲ { ↲ -{/each}↲ [original] line 11 +{/each}↲ [original] line 11 (rest generated at line 14) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 14 + ↲ +{/each}↲ [original] line 11 (rest generated at line 13) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} for(let { id, ...rest } of __sveltets_2_ensureArray(objects)){ {/** ••for(let•{•id,•...rest•}•of•__sveltets_2_ensureArray(objects)){↲ [generated] line 15 @@ -86,10 +92,12 @@ async•()•=>•{••for(let•item•of•__sveltets_2_ensureArray(items)){ }↲ [generated] line 17 {↲ { ↲ -{/each}↲ [original] line 15 +{/each}↲ [original] line 15 (rest generated at line 18) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 18 + ↲ +{/each}↲ [original] line 15 (rest generated at line 17) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} for(let [id, ...rest] of __sveltets_2_ensureArray(items)){ {/** ••for(let•[id,•...rest]•of•__sveltets_2_ensureArray(items)){↲ [generated] line 19 @@ -109,10 +117,12 @@ async•()•=>•{••for(let•item•of•__sveltets_2_ensureArray(items)){ }↲ [generated] line 21 {↲ { ↲ -{/each}↲ [original] line 19 +{/each}↲ [original] line 19 (rest generated at line 22) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 22 + ↲ +{/each}↲ [original] line 19 (rest generated at line 21) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} for(let todo of __sveltets_2_ensureArray(todos)){ {/** ••for(let•todo•of•__sveltets_2_ensureArray(todos)){↲ [generated] line 23 diff --git a/packages/svelte2tsx/test/sourcemaps/samples/element-attributes/mappings.jsx b/packages/svelte2tsx/test/sourcemaps/samples/element-attributes/mappings.jsx index 7ef16bb3f..b5a478a40 100644 --- a/packages/svelte2tsx/test/sourcemaps/samples/element-attributes/mappings.jsx +++ b/packages/svelte2tsx/test/sourcemaps/samples/element-attributes/mappings.jsx @@ -6,10 +6,12 @@ async () => { { svelteHTML.createElement("element", {"foo":true,});} async•()•=>•{•{•svelteHTML.createElement("element",•{"foo":true,});}↲ [generated] line 3 < element f oo/ ↲ ↲ [original] line 1 +↲ [original] line 1 (rest generated at line 4) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 4 + ↲ +↲ [original] line 1 (rest generated at line 3) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { svelteHTML.createElement("element", { "foo":true,});} {/** ••{•svelteHTML.createElement("element",•{•"foo":true,});}↲ [generated] line 5 @@ -28,10 +30,12 @@ async•()•=>•{•{•svelteHTML.createElement("element",•{"foo":true,});} •{•svelteHTML.createElement(" ↲ [generated] subset > ↲ >↲ -/>↲ [original] line 5 +/>↲ [original] line 5 (rest generated at line 6) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 6 + ↲ +/>↲ [original] line 5 (rest generated at line 5) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { svelteHTML.createElement("element", { "foo":`leet`,});} {/** •{•svelteHTML.createElement("element",•{•••"foo":`leet`,});}↲ [generated] line 7 @@ -50,10 +54,12 @@ async•()•=>•{•{•svelteHTML.createElement("element",•{"foo":true,});} •{•svelteHTML.createElement("element",•{•••"foo":`leet`,});}↲ [generated] line 7 ↲ [generated] subset ↲ -/>↲ [original] line 9 +/>↲ [original] line 9 (rest generated at line 8) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 8 + ↲ +/>↲ [original] line 9 (rest generated at line 7) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { svelteHTML.createElement("element", { foo,"bar":true,});} {/** ••{•svelteHTML.createElement("element",•{•foo,"bar":true,});}↲ [generated] line 9 @@ -72,10 +78,12 @@ async•()•=>•{•{•svelteHTML.createElement("element",•{"foo":true,});} •{•svelteHTML.createElement(" ↲ [generated] subset > ↲ >↲ -/>↲ [original] line 13 +/>↲ [original] line 13 (rest generated at line 10) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 10 + ↲ +/>↲ [original] line 13 (rest generated at line 9) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { svelteHTML.createElement("element", { foo,});} {/** •{•svelteHTML.createElement("element",•{••foo,});}↲ [generated] line 11 @@ -94,10 +102,12 @@ async•()•=>•{•{•svelteHTML.createElement("element",•{"foo":true,});} •{•svelteHTML.createElement("element",•{••foo,});}↲ [generated] line 11 ↲ [generated] subset ↲ -/>↲ [original] line 17 +/>↲ [original] line 17 (rest generated at line 12) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 12 + ↲ +/>↲ [original] line 17 (rest generated at line 11) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { svelteHTML.createElement("element", { "bind:foo":foo,});/*Ωignore_startΩ*/() => foo = __sveltets_2_any(null);/*Ωignore_endΩ*/} {/** •{•svelteHTML.createElement("element",•{••"bind:foo":foo,});/*Ωignore_startΩ*/()•=>•foo•=•__sveltets_2_any(null);/*Ωignore_endΩ*/}↲ [generated] line 13 @@ -116,10 +126,12 @@ async•()•=>•{•{•svelteHTML.createElement("element",•{"foo":true,});} • ↲ [generated] subset / ↲ / ↲ -/>↲ [original] line 21 +/>↲ [original] line 21 (rest generated at line 14) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 14 + ↲ +/>↲ [original] line 21 (rest generated at line 13) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { svelteHTML.createElement("element", { "bind:foo":bar,});/*Ωignore_startΩ*/() => bar = __sveltets_2_any(null);/*Ωignore_endΩ*/}}; {/** •{•svelteHTML.createElement("element",•{••"bind:foo":bar,});/*Ωignore_startΩ*/()•=>•bar•=•__sveltets_2_any(null);/*Ωignore_endΩ*/}};↲ [generated] line 15 diff --git a/packages/svelte2tsx/test/sourcemaps/samples/if-block/mappings.jsx b/packages/svelte2tsx/test/sourcemaps/samples/if-block/mappings.jsx index 080912ca8..f76cef7ba 100644 --- a/packages/svelte2tsx/test/sourcemaps/samples/if-block/mappings.jsx +++ b/packages/svelte2tsx/test/sourcemaps/samples/if-block/mappings.jsx @@ -18,19 +18,23 @@ async•()•=>•{if(foo){↲ [generated] line 3 }↲ [generated] line 5 {↲ { ↲ -{/if}↲ [original] line 3 +{/if}↲ [original] line 3 (rest generated at line 6) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 6 + ↲ +{/if}↲ [original] line 3 (rest generated at line 5) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} if($foo){ { svelteHTML.createElement("element", {});}} {/** if($foo){•{•svelteHTML.createElement("element",•{});}}↲ [generated] line 7 { $foo} < element / {↲ { $foo}{/if}↲ [original] line 5 +{#if•$foo}{/if}↲ [original] line 5 (rest generated at line 8) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 8 + ↲ +{#if•$foo}{/if}↲ [original] line 5 (rest generated at line 7) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} if(foo){ {/** if(foo){↲ [generated] line 9 diff --git a/packages/svelte2tsx/test/sourcemaps/samples/import-equal/mappings.jsx b/packages/svelte2tsx/test/sourcemaps/samples/import-equal/mappings.jsx index e122d928f..e1548fcb1 100644 --- a/packages/svelte2tsx/test/sourcemaps/samples/import-equal/mappings.jsx +++ b/packages/svelte2tsx/test/sourcemaps/samples/import-equal/mappings.jsx @@ -19,9 +19,13 @@ ; {/** ;↲ [generated] line 6 < - [original] line 4 + [original] line 4 (rest generated at line 7) +------------------------------------------------------------------------------------------------------------------------------------------------------ */} +async () => {}; {/** +async•()•=>•{};↲ [generated] line 7 +< + [original] line 4 (rest generated at line 6) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} -async () => {}; return { props: /** @type {Record} */ ({}), slots: {}, events: {} }} export default class Input__SvelteComponent_ extends __sveltets_2_createSvelte2TsxComponent(__sveltets_2_partial(__sveltets_2_with_any_event(render()))) { diff --git a/packages/svelte2tsx/test/sourcemaps/samples/large-sample-1/mappings.jsx b/packages/svelte2tsx/test/sourcemaps/samples/large-sample-1/mappings.jsx index dd6cc6ee5..44c3de9a8 100644 --- a/packages/svelte2tsx/test/sourcemaps/samples/large-sample-1/mappings.jsx +++ b/packages/svelte2tsx/test/sourcemaps/samples/large-sample-1/mappings.jsx @@ -23,7 +23,7 @@ ;;↲ [generated] line 15 ; [generated] subset < -↲ [original] line 14 (rest generated at line 119) +↲ [original] line 14 (rest generated at lines 119, 120) ;;↲ [generated] line 15 ;↲ [generated] subset @@ -251,69 +251,105 @@ s ; {/** ;↲ [generated] line 118 < -↲ [original] line 109 (rest generated at line 121) +↲ [original] line 109 (rest generated at lines 119, 121, 122) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} async () => { {/** -============# Originless mappings async•()•=>•{↲ [generated] line 119 - ↲ +async•()•=>•{ [generated] subset +< +↲ [original] line 109 (rest generated at lines 118, 121, 122) + +async•()•=>•{↲ [generated] line 119 + ↲ [generated] subset ↲ -↲ [original] line 14 (rest generated at line 15) +↲ [original] line 14 (rest generated at lines 15, 120) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 120 + ↲ +↲ [original] line 14 (rest generated at lines 15, 119) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** ↲ [generated] line 121 ↲ -↲ [original] line 109 (rest generated at line 118) +↲ [original] line 109 (rest generated at lines 118, 119, 122) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 122 + ↲ +↲ [original] line 109 (rest generated at lines 118, 119, 121) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** ↲ [generated] line 123 ↲ -↲ [original] line 259 +↲ [original] line 259 (rest generated at line 124) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 124 + ↲ +↲ [original] line 259 (rest generated at line 123) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { svelteHTML.createElement("svelte:head", {}); {/** •{•svelteHTML.createElement("svelte:head",•{});↲ [generated] line 125 s ↲ s ↲ -↲ [original] line 261 +↲ [original] line 261 (rest generated at line 126) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { svelteHTML.createElement("title", {});selected.section.title; selected.chapter.title; } {/** - # Originless mappings ╚•{•svelteHTML.createElement("title",•{});selected.section.title;••selected.chapter.title;••••}↲ [generated] line 126 + ╚ [generated] subset + ↲ + ↲ + ↲ [original] line 261 (rest generated at line 125) + + ╚•{•svelteHTML.createElement("title",•{});selected.section.title;••selected.chapter.title;••••}↲ [generated] line 126 + •{•svelteHTML.createElement("title",•{});selected.section.title;••selected.chapter.title;••••}↲ [generated] subset < title selected.section.title}• selected.chapter.title}• / ↲ {selected.section.title}•/•{selected.chapter.title}•••Svelte•Tutorial↲ [original] line 262 + ╚{selected.section.title}•/•{selected.chapter.title}•••Svelte•Tutorial↲ [original] line 262 (rest generated at lines 127, 128) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 127 + ↲ +╚{selected.section.title}•/•{selected.chapter.title}•••Svelte•Tutorial↲ [original] line 262 (rest generated at lines 126, 128) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { svelteHTML.createElement("meta", { "name":`twitter:title`,"content":`Svelte tutorial`,});} {/** - # Originless mappings ╚•{•svelteHTML.createElement("meta",•{•••"name":`twitter:title`,"content":`Svelte•tutorial`,});}↲ [generated] line 128 + ╚ [generated] subset + ↲ + ↲ + ╚{selected.section.title}•/•{selected.chapter.title}•••Svelte•Tutorial↲ [original] line 262 (rest generated at lines 126, 127) + + ╚•{•svelteHTML.createElement("meta",•{•••"name":`twitter:title`,"content":`Svelte•tutorial`,});}↲ [generated] line 128 + •{•svelteHTML.createElement("meta",•{•••"name":`twitter:title`,"content":`Svelte•tutorial`,});}↲ [generated] subset < meta "•"n ame= twitter:title" c ontent= Svelte•tutorial" ↲ # Order-breaking mappings ↲ [original] line 264 + ╚↲ [original] line 264 (rest generated at line 129) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { svelteHTML.createElement("meta", { "name":`twitter:description`,"content":`${selected.section.title} / ${selected.chapter.title}`,});} {/** - # Originless mappings ╚•{•svelteHTML.createElement("meta",•{•••"name":`twitter:description`,"content":`${selected.section.title}•/•${selected.chapter.title}`,});}↲ [generated] line 129 + ╚ [generated] subset + ↲ + ↲ + ╚↲ [original] line 264 (rest generated at line 128) + + ╚•{•svelteHTML.createElement("meta",•{•••"name":`twitter:description`,"content":`${selected.section.title}•/•${selected.chapter.title}`,});}↲ [generated] line 129 + •{•svelteHTML.createElement("meta",•{•••"name":`twitter:description`,"content":`${selected.section.title}•/•${selected.chapter.title}`,});}↲ [generated] subset < meta "•"n ame= twitter:description" c ontent= {selected.section.title}•/• {selected.chapter.title}" ↲ # Order-breaking mappings ↲ [original] line 265 + ╚↲ [original] line 265 (rest generated at line 130) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { svelteHTML.createElement("meta", { "name":`Description`,"content":`${selected.section.title} / ${selected.chapter.title}`,});} {/** - # Originless mappings ╚•{•svelteHTML.createElement("meta",•{•••"name":`Description`,"content":`${selected.section.title}•/•${selected.chapter.title}`,});}↲ [generated] line 130 + ╚ [generated] subset + ↲ + ↲ + ╚↲ [original] line 265 (rest generated at line 129) + + ╚•{•svelteHTML.createElement("meta",•{•••"name":`Description`,"content":`${selected.section.title}•/•${selected.chapter.title}`,});}↲ [generated] line 130 + •{•svelteHTML.createElement("meta",•{•••"name":`Description`,"content":`${selected.section.title}•/•${selected.chapter.title}`,});}↲ [generated] subset < meta "•"n ame= Description" c ontent= {selected.section.title}•/• {selected.chapter.title}" ↲ # Order-breaking mappings ↲ [original] line 267 +↲ [original] line 267 (rest generated at line 132) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 132 + ↲ +↲ [original] line 267 (rest generated at line 131) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { svelteHTML.createElement("svelte:window", { "bind:innerWidth":width,});/*Ωignore_startΩ*/() => width = __sveltets_2_any(null);/*Ωignore_endΩ*/} {/** ••{•svelteHTML.createElement("svelte:window",•{•"bind:innerWidth":width,});/*Ωignore_startΩ*/()•=>•width•=•__sveltets_2_any(null);/*Ωignore_endΩ*/}↲ [generated] line 133 <> ib width} ↲ #=============================================# Order-breaking mappings < bi width} >↲ -↲ [original] line 269 +↲ [original] line 269 (rest generated at line 134) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 134 + ↲ +↲ [original] line 269 (rest generated at line 133) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { svelteHTML.createElement("div", { "class":`tutorial-outer`,}); {/** •{•svelteHTML.createElement("div",•{•"class":`tutorial-outer`,});↲ [generated] line 135 < div "c lass= tutorial-outer" ↲ # Order-breaking mappings
↲ [original] line 271 +↲ [original] line 271 (rest generated at line 136) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { svelteHTML.createElement("div", { "class":`viewport offset-${offset}`,}); {/** - # Originless mappings ╚•{•svelteHTML.createElement("div",•{•"class":`viewport•offset-${offset}`,});↲ [generated] line 136 + ╚ [generated] subset + ↲ + ↲ + ↲ [original] line 271 (rest generated at line 135) + + ╚•{•svelteHTML.createElement("div",•{•"class":`viewport•offset-${offset}`,});↲ [generated] line 136 + •{•svelteHTML.createElement("div",•{•"class":`viewport•offset-${offset}`,});↲ [generated] subset < div "c lass= viewport•offset- {offset}" ↲ # Order-breaking mappings
↲ [original] line 272 + ╚↲ [original] line 272 (rest generated at line 137) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { svelteHTML.createElement("div", { "class":`tutorial-text`,}); {/** - =# Originless mappings ╚╚•{•svelteHTML.createElement("div",•{•"class":`tutorial-text`,});↲ [generated] line 137 + ╚╚ [generated] subset + ↲ + ↲ + ╚↲ [original] line 272 (rest generated at line 136) + + ╚╚•{•svelteHTML.createElement("div",•{•"class":`tutorial-text`,});↲ [generated] line 137 + •{•svelteHTML.createElement("div",•{•"class":`tutorial-text`,});↲ [generated] subset < div "c lass= tutorial-text" ↲ # Order-breaking mappings
↲ [original] line 273 + ╚╚↲ [original] line 273 (rest generated at line 138) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { svelteHTML.createElement("div", { "class":`table-of-contents`,}); {/** - ==# Originless mappings ╚╚╚•{•svelteHTML.createElement("div",•{•"class":`table-of-contents`,});↲ [generated] line 138 + ╚╚╚ [generated] subset + ↲ + ↲ + ╚╚↲ [original] line 273 (rest generated at line 137) + + ╚╚╚•{•svelteHTML.createElement("div",•{•"class":`table-of-contents`,});↲ [generated] line 138 + •{•svelteHTML.createElement("div",•{•"class":`table-of-contents`,});↲ [generated] subset < div "c lass= table-of-contents" ↲ # Order-breaking mappings
↲ [original] line 274 + ╚╚╚↲ [original] line 274 (rest generated at line 139) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { const $$_stnetnoCfOelbaT4C = __sveltets_2_ensureComponent(TableOfContents); new $$_stnetnoCfOelbaT4C({ target: __sveltets_2_any(), props: { sections,slug,selected,}});}{/** - ===# Originless mappings ╚╚╚╚••{•const•$$_stnetnoCfOelbaT4C•=•__sveltets_2_ensureComponent(TableOfContents);•new•$$_stnetnoCfOelbaT4C({•target:•__sveltets_2_any(),•props:•{••sections,slug,selected,}});}↲ [generated] line 139 + ╚╚╚╚ [generated] subset + ↲ + ↲ + ╚╚╚↲ [original] line 274 (rest generated at line 138) + + ╚╚╚╚••{•const•$$_stnetnoCfOelbaT4C•=•__sveltets_2_ensureComponent(TableOfContents);•new•$$_stnetnoCfOelbaT4C({•target:•__sveltets_2_any(),•props:•{••sections,slug,selected,}});}↲ [generated] line 139 + ••{•const•$$_stnetnoCfOelbaT4C•=•__sveltets_2_ensureComponent(TableOfContents);•new•$$_stnetnoCfOelbaT4C({•target:•__sveltets_2_any(),•props:•{••sections,slug,selected,}});}↲ [generated] subset <> TableOfContents ••sections}slug}selected} ↲ #============================================================ # Order-breaking mappings ↲ - ╚╚╚╚↲ [original] line 275 + ╚╚╚╚↲ [original] line 275 (rest generated at line 140) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} } {/** - ==# Originless mappings - ╚╚╚•}↲ [generated] line 140 + ╚╚╚•}↲ [generated] line 140 + ╚╚╚ [generated] subset + ↲ + ↲ + ╚╚╚╚↲ [original] line 275 (rest generated at line 139) + + ╚╚╚•}↲ [generated] line 140 + •}↲ [generated] subset / ↲ / ↲ - ╚╚╚
↲ [original] line 276 + ╚╚╚
↲ [original] line 276 (rest generated at lines 141, 142) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 141 + ↲ +╚╚╚
↲ [original] line 276 (rest generated at lines 140, 142) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { const $$_div3 = svelteHTML.createElement("div", { "class":`chapter-markup`,});scrollable = $$_div3; {/** - ==# Originless mappings ╚╚╚•{•const•$$_div3•=•svelteHTML.createElement("div",•{••"class":`chapter-markup`,});scrollable•=•$$_div3;↲ [generated] line 142 + ╚╚╚ [generated] subset + ↲ + ↲ + ╚╚╚
↲ [original] line 276 (rest generated at lines 140, 141) + + ╚╚╚•{•const•$$_div3•=•svelteHTML.createElement("div",•{••"class":`chapter-markup`,});scrollable•=•$$_div3;↲ [generated] line 142 + •{•const•$$_div3•=•svelteHTML.createElement("div",•{••"class":`chapter-markup`,});scrollable•=•$$_div3;↲ [generated] subset < div "•c lass= chapter-markup" scrollable} ↲ # Order-breaking mappings
↲ [original] line 278 + ╚╚╚↲ [original] line 278 (rest generated at line 143) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} chapter.html; {/** - ===# Originless mappings - ╚╚╚╚•chapter.html;↲ [generated] line 143 + ╚╚╚╚•chapter.html;↲ [generated] line 143 + ╚╚╚╚ [generated] subset + ↲ + ↲ + ╚╚╚↲ [original] line 278 (rest generated at line 142) + + ╚╚╚╚•chapter.html;↲ [generated] line 143 + •chapter.html;↲ [generated] subset {chapter.html}↲ { chapter.html}↲ - ╚╚╚╚{@html•chapter.html}↲ [original] line 279 + ╚╚╚╚{@html•chapter.html}↲ [original] line 279 (rest generated at lines 144, 145) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 144 + ↲ +╚╚╚╚{@html•chapter.html}↲ [original] line 279 (rest generated at lines 143, 145) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { svelteHTML.createElement("div", { "class":`controls`,}); {/** - ===# Originless mappings ╚╚╚╚•{•svelteHTML.createElement("div",•{•"class":`controls`,});↲ [generated] line 145 + ╚╚╚╚ [generated] subset + ↲ + ↲ + ╚╚╚╚{@html•chapter.html}↲ [original] line 279 (rest generated at lines 143, 144) + + ╚╚╚╚•{•svelteHTML.createElement("div",•{•"class":`controls`,});↲ [generated] line 145 + •{•svelteHTML.createElement("div",•{•"class":`controls`,});↲ [generated] subset < div "c lass= controls" ↲ # Order-breaking mappings
↲ [original] line 281 + ╚╚╚╚↲ [original] line 281 (rest generated at line 146) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} if(chapter.app_b){ {/** - ====# Originless mappings - ╚╚╚╚╚if(chapter.app_b){↲ [generated] line 146 + ╚╚╚╚╚if(chapter.app_b){↲ [generated] line 146 + ╚╚╚╚╚ [generated] subset + ↲ + ↲ + ╚╚╚╚↲ [original] line 281 (rest generated at line 145) + + ╚╚╚╚╚if(chapter.app_b){↲ [generated] line 146 + if(chapter.app_b){↲ [generated] subset { chapter.app_b} ↲ { chapter.app_b}↲ - ╚╚╚╚╚{#if•chapter.app_b}↲ [original] line 282 + ╚╚╚╚╚{#if•chapter.app_b}↲ [original] line 282 ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** ╚╚╚╚╚╚↲ [generated] line 147 @@ -429,42 +527,68 @@ s ↲ ╚╚╚╚╚╚↲ [generated] line 147 ↲ [generated] subset ↲ - ╚╚╚╚╚╚╚matches•the•expected•end•result•-->↲ [original] line 284 + ╚╚╚╚╚╚╚matches•the•expected•end•result•-->↲ [original] line 284 (rest generated at line 148) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { svelteHTML.createElement("button", { "class":`show`,"on:click":() => completed ? reset() : complete(),}); {/** - =====# Originless mappings ╚╚╚╚╚╚••{•svelteHTML.createElement("button",•{•••"class":`show`,"on:click":()•=>•completed•?•reset()•:•complete(),});↲ [generated] line 148 + ╚╚╚╚╚╚ [generated] subset + ↲ + ↲ + ╚╚╚╚╚╚╚matches•the•expected•end•result•-->↲ [original] line 284 (rest generated at line 147) + + ╚╚╚╚╚╚••{•svelteHTML.createElement("button",•{•••"class":`show`,"on:click":()•=>•completed•?•reset()•:•complete(),});↲ [generated] line 148 + ••{•svelteHTML.createElement("button",•{•••"class":`show`,"on:click":()•=>•completed•?•reset()•:•complete(),});↲ [generated] subset <> button "•"c lass= show" c lick =()•=>•completed•?•reset()•:•complete()} ↲ #============================ # Order-breaking mappings ↲ [original] line 287 + ╚╚╚╚╚╚↲ [original] line 287 ------------------------------------------------------------------------------------------------------------------------------------------------------ */} } {/** ╚╚╚╚╚}↲ [generated] line 151 ╚╚╚╚╚{↲ ╚╚╚╚╚{ ↲ - ╚╚╚╚╚{/if}↲ [original] line 288 + ╚╚╚╚╚{/if}↲ [original] line 288 (rest generated at lines 152, 153) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 152 + ↲ +╚╚╚╚╚{/if}↲ [original] line 288 (rest generated at lines 151, 153) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} if(selected.next){ {/** - ====# Originless mappings ╚╚╚╚╚if(selected.next){↲ [generated] line 153 + ╚╚╚╚╚ [generated] subset + ↲ + ↲ + ╚╚╚╚╚{/if}↲ [original] line 288 (rest generated at lines 151, 152) + + ╚╚╚╚╚if(selected.next){↲ [generated] line 153 + if(selected.next){↲ [generated] subset { selected.next} ↲ { selected.next}↲ ╚╚╚╚╚{#if•selected.next}↲ [original] line 290 @@ -480,68 +604,119 @@ s ↲ ╚╚╚╚╚}↲ [generated] line 155 ╚╚╚╚╚{↲ ╚╚╚╚╚{ ↲ - ╚╚╚╚╚{/if}↲ [original] line 292 + ╚╚╚╚╚{/if}↲ [original] line 292 (rest generated at line 156) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} } {/** - ===# Originless mappings ╚╚╚╚•}↲ [generated] line 156 + ╚╚╚╚ [generated] subset + ↲ + ↲ + ╚╚╚╚╚{/if}↲ [original] line 292 (rest generated at line 155) + + ╚╚╚╚•}↲ [generated] line 156 + •}↲ [generated] subset / ↲ / ↲ - ╚╚╚╚
↲ [original] line 293 + ╚╚╚╚
↲ [original] line 293 (rest generated at lines 157, 158) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 157 + ↲ +╚╚╚╚↲ [original] line 293 (rest generated at lines 156, 158) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { svelteHTML.createElement("div", { "class":`improve-chapter`,}); {/** - ===# Originless mappings ╚╚╚╚•{•svelteHTML.createElement("div",•{•"class":`improve-chapter`,});↲ [generated] line 158 + ╚╚╚╚ [generated] subset + ↲ + ↲ + ╚╚╚╚↲ [original] line 293 (rest generated at lines 156, 157) + + ╚╚╚╚•{•svelteHTML.createElement("div",•{•"class":`improve-chapter`,});↲ [generated] line 158 + •{•svelteHTML.createElement("div",•{•"class":`improve-chapter`,});↲ [generated] subset < div "c lass= improve-chapter" ↲ # Order-breaking mappings
↲ [original] line 295 + ╚╚╚╚↲ [original] line 295 (rest generated at line 159) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { svelteHTML.createElement("a", { "class":`no-underline`,"href":improve_link,}); } {/** - ====# Originless mappings ╚╚╚╚╚•{•svelteHTML.createElement("a",•{•••"class":`no-underline`,"href":improve_link,});•••}↲ [generated] line 159 + ╚╚╚╚╚ [generated] subset + ↲ + ↲ + ╚╚╚╚↲ [original] line 295 (rest generated at line 158) + + ╚╚╚╚╚•{•svelteHTML.createElement("a",•{•••"class":`no-underline`,"href":improve_link,});•••}↲ [generated] line 159 + •{•svelteHTML.createElement("a",•{•••"class":`no-underline`,"href":improve_link,});•••}↲ [generated] subset < a "•{c lass= no-underline" h ref= improve_link} E / ↲ # Order-breaking mappings Edit•this•chapter↲ [original] line 296 + ╚╚╚╚╚Edit•this•chapter↲ [original] line 296 (rest generated at line 160) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} } {/** - ===# Originless mappings - ╚╚╚╚•}↲ [generated] line 160 + ╚╚╚╚•}↲ [generated] line 160 + ╚╚╚╚ [generated] subset + ↲ + ↲ + ╚╚╚╚╚Edit•this•chapter↲ [original] line 296 (rest generated at line 159) + + ╚╚╚╚•}↲ [generated] line 160 + •}↲ [generated] subset / ↲ / ↲ - ╚╚╚╚
↲ [original] line 297 + ╚╚╚╚↲ [original] line 297 (rest generated at line 161) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} } {/** - ==# Originless mappings - ╚╚╚•}↲ [generated] line 161 + ╚╚╚•}↲ [generated] line 161 + ╚╚╚ [generated] subset + ↲ + ↲ + ╚╚╚╚↲ [original] line 297 (rest generated at line 160) + + ╚╚╚•}↲ [generated] line 161 + •}↲ [generated] subset / ↲ / ↲ - ╚╚╚↲ [original] line 298 + ╚╚╚↲ [original] line 298 (rest generated at line 162) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} } {/** - =# Originless mappings - ╚╚•}↲ [generated] line 162 + ╚╚•}↲ [generated] line 162 + ╚╚ [generated] subset + ↲ + ↲ + ╚╚╚↲ [original] line 298 (rest generated at line 161) + + ╚╚•}↲ [generated] line 162 + •}↲ [generated] subset / ↲ / ↲ - ╚╚↲ [original] line 299 + ╚╚↲ [original] line 299 (rest generated at lines 163, 164) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 163 + ↲ +╚╚↲ [original] line 299 (rest generated at lines 162, 164) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { svelteHTML.createElement("div", { "class":`tutorial-repl`,}); {/** - =# Originless mappings ╚╚•{•svelteHTML.createElement("div",•{•"class":`tutorial-repl`,});↲ [generated] line 164 + ╚╚ [generated] subset + ↲ + ↲ + ╚╚↲ [original] line 299 (rest generated at lines 162, 163) + + ╚╚•{•svelteHTML.createElement("div",•{•"class":`tutorial-repl`,});↲ [generated] line 164 + •{•svelteHTML.createElement("div",•{•"class":`tutorial-repl`,});↲ [generated] subset < div "c lass= tutorial-repl" ↲ # Order-breaking mappings
↲ [original] line 301 + ╚╚↲ [original] line 301 (rest generated at line 165) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { const $$_lpeR3C = __sveltets_2_ensureComponent(Repl); const $$_lpeR3 = new $$_lpeR3C({ target: __sveltets_2_any(), props: { "workersUrl":`workers`,svelteUrl,rollupUrl,"orientation":mobile ? 'columns' : 'rows',"fixed":mobile,"injectedJS":mapbox_setup,"relaxed":true,}});repl = $$_lpeR3;$$_lpeR3.$on("change", handle_change);}{/** - ==# Originless mappings + ╚╚╚•{•const•$$_lpeR3C•=•__sveltets_2_ensureComponent(Repl);•const•$$_lpeR3•=•new•$$_lpeR3C({•target:•__sveltets_2_any(),•props:•{•••••••••••••••"workersUrl":`workers`,svelteUrl,rollupUrl,"orientation":mobile•?•'columns'•:•'rows',"fixed":mobile,"injectedJS":mapbox_setup,"relaxed":true,}});repl•=•$$_lpeR3;$$_lpeR3.$on("change",•handle_change);}↲ [generated] line 165 + ╚╚╚ [generated] subset + ↲ + ↲ + ╚╚↲ [original] line 301 (rest generated at line 164) + ╚╚╚•{•const•$$_lpeR3C•=•__sveltets_2_ensureComponent(Repl);•const•$$_lpeR3•=•new•$$_lpeR3C({•target:•__sveltets_2_any(),•props:•{•••••••••••••••"workersUrl":`workers`,svelteUrl,rollupUrl,"orientation":mobile•?•'columns'•:•'rows',"fixed":mobile,"injectedJS":mapbox_setup,"relaxed":true,}});repl•=•$$_lpeR3;$$_lpeR3.$on("change",•handle_change);}↲ [generated] line 165 •{•const•$$_lpeR3C•=•__sveltets_2_ensureComponent(Repl);•const•$$_lpeR3•=•new•$$_lpeR3C({•target:•__sveltets_2_any(),•props:•{ [generated] subset < Repl @@ -614,28 +789,48 @@ s ↲ • ↲ [generated] subset ╚ ↲ ╚ ↲ - ╚╚╚/>↲ [original] line 312 + ╚╚╚/>↲ [original] line 312 (rest generated at line 166) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} } {/** - =# Originless mappings ╚╚•}↲ [generated] line 166 + ╚╚ [generated] subset + ↲ + ↲ + ╚╚╚/>↲ [original] line 312 (rest generated at line 165) + + ╚╚•}↲ [generated] line 166 + •}↲ [generated] subset / ↲ / ↲ - ╚╚
↲ [original] line 313 + ╚╚↲ [original] line 313 (rest generated at line 167) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} } {/** - # Originless mappings - ╚•}↲ [generated] line 167 + ╚•}↲ [generated] line 167 + ╚ [generated] subset + ↲ + ↲ + ╚╚↲ [original] line 313 (rest generated at line 166) + + ╚•}↲ [generated] line 167 + •}↲ [generated] subset / ↲ / ↲ - ╚↲ [original] line 314 + ╚↲ [original] line 314 (rest generated at lines 168, 169) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 168 + ↲ +╚↲ [original] line 314 (rest generated at lines 167, 169) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} if(mobile){ {/** - # Originless mappings ╚if(mobile){↲ [generated] line 169 + ╚ [generated] subset + ↲ + ↲ + ╚↲ [original] line 314 (rest generated at lines 167, 168) + + ╚if(mobile){↲ [generated] line 169 + if(mobile){↲ [generated] subset { mobile} ↲ { mobile}↲ ╚{#if•mobile}↲ [original] line 316 diff --git a/packages/svelte2tsx/test/sourcemaps/samples/let/mappings.jsx b/packages/svelte2tsx/test/sourcemaps/samples/let/mappings.jsx index 265203757..36af25336 100644 --- a/packages/svelte2tsx/test/sourcemaps/samples/let/mappings.jsx +++ b/packages/svelte2tsx/test/sourcemaps/samples/let/mappings.jsx @@ -19,9 +19,13 @@ ; {/** ;↲ [generated] line 5 < - [original] line 3 + [original] line 3 (rest generated at line 6) +------------------------------------------------------------------------------------------------------------------------------------------------------ */} +async () => {}; {/** +async•()•=>•{};↲ [generated] line 6 +< + [original] line 3 (rest generated at line 5) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} -async () => {}; return { props: /** @type {Record} */ ({}), slots: {}, events: {} }} export default class Input__SvelteComponent_ extends __sveltets_2_createSvelte2TsxComponent(__sveltets_2_partial(__sveltets_2_with_any_event(render()))) { diff --git a/packages/svelte2tsx/test/sourcemaps/samples/reactive-statements/mappings.jsx b/packages/svelte2tsx/test/sourcemaps/samples/reactive-statements/mappings.jsx index 8ef14e465..348d67a39 100644 --- a/packages/svelte2tsx/test/sourcemaps/samples/reactive-statements/mappings.jsx +++ b/packages/svelte2tsx/test/sourcemaps/samples/reactive-statements/mappings.jsx @@ -41,9 +41,13 @@ ; {/** ;↲ [generated] line 9 < - [original] line 7 + [original] line 7 (rest generated at line 10) +------------------------------------------------------------------------------------------------------------------------------------------------------ */} +async () => {}; {/** +async•()•=>•{};↲ [generated] line 10 +< + [original] line 7 (rest generated at line 9) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} -async () => {}; return { props: {prop: prop}, slots: {}, events: {} }} export default class Input__SvelteComponent_ extends __sveltets_2_createSvelte2TsxComponent(__sveltets_2_partial(__sveltets_2_with_any_event(render()))) { diff --git a/packages/svelte2tsx/test/sourcemaps/samples/reserved-variables/mappings.jsx b/packages/svelte2tsx/test/sourcemaps/samples/reserved-variables/mappings.jsx index 9ac4a75c6..9ff7d1c21 100644 --- a/packages/svelte2tsx/test/sourcemaps/samples/reserved-variables/mappings.jsx +++ b/packages/svelte2tsx/test/sourcemaps/samples/reserved-variables/mappings.jsx @@ -23,17 +23,18 @@ ; {/** ;↲ [generated] line 8 < -↲ [original] line 6 (rest generated at line 9) +↲ [original] line 6 (rest generated at lines 9, 10) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} async () => { {/** -============# Originless mappings async•()•=>•{↲ [generated] line 9 - ↲ - ↲ -↲ [original] line 6 (rest generated at line 8) +< ↲ +< ↲ +↲ [original] line 6 (rest generated at lines 8, 10) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 10 + ↲ +↲ [original] line 6 (rest generated at lines 8, 9) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} if($$slots.foo){ {/** if($$slots.foo){↲ [generated] line 11 @@ -45,10 +46,9 @@ if($$slots.foo){↲ [generated] line 11 ╚$$restProps.bar;↲ [generated] line 12 ╚$$restProps.bar}↲ ╚ $$restProps.bar}↲ - ╚{$$restProps.bar}↲ [original] line 9 + ╚{$$restProps.bar}↲ [original] line 9 (rest generated at line 13) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { const $$_tnenopmoC0C = __sveltets_2_ensureComponent(Component); new $$_tnenopmoC0C({ target: __sveltets_2_any(), props: { ...$$props,}});} {/** - # Originless mappings ╚•{•const•$$_tnenopmoC0C•=•__sveltets_2_ensureComponent(Component);•new•$$_tnenopmoC0C({•target:•__sveltets_2_any(),•props:•{••...$$props,}});}↲ [generated] line 13 • ...$$props,}});} [generated] subset ╚ ...$$props} @@ -61,6 +61,12 @@ if($$slots.foo){↲ [generated] line 11 ╚ ↲ ╚/>↲ [original] line 12 + ╚•{•const•$$_tnenopmoC0C•=•__sveltets_2_ensureComponent(Component);•new•$$_tnenopmoC0C({•target:•__sveltets_2_any(),•props:•{••...$$props,}});}↲ [generated] line 13 + ╚ [generated] subset + ↲ + ↲ + ╚{$$restProps.bar}↲ [original] line 9 (rest generated at line 12) + ╚•{•const•$$_tnenopmoC0C•=•__sveltets_2_ensureComponent(Component);•new•$$_tnenopmoC0C({•target:•__sveltets_2_any(),•props:•{••...$$props,}});}↲ [generated] line 13 •{•const•$$_tnenopmoC0C•=•__sveltets_2_ensureComponent(Component);•new•$$_tnenopmoC0C({•target:•__sveltets_2_any(),•props:•{ [generated] subset < Component diff --git a/packages/svelte2tsx/test/sourcemaps/samples/slot-let/mappings.jsx b/packages/svelte2tsx/test/sourcemaps/samples/slot-let/mappings.jsx index 2612247aa..a07171311 100644 --- a/packages/svelte2tsx/test/sourcemaps/samples/slot-let/mappings.jsx +++ b/packages/svelte2tsx/test/sourcemaps/samples/slot-let/mappings.jsx @@ -7,14 +7,20 @@ async•()•=>•{•{•const•$$_tnenopmoC0C•=•__sveltets_2_ensureCompon < Component el{•l hi•hi2=hi_2}hi3 ↲ # Order-breaking mappings ↲ [original] line 1 +↲ [original] line 1 (rest generated at line 4) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} hi;hi_2;hi3; {/** -===# Originless mappings -••••hi;hi_2;hi3;↲ [generated] line 4 +••••hi;hi_2;hi3;↲ [generated] line 4 +•••• [generated] subset +↲ + ↲ +↲ [original] line 1 (rest generated at line 3) + +••••hi;hi_2;hi3;↲ [generated] line 4 + hi;hi_2;hi3;↲ [generated] subset hi}hi_2}hi3}↲ hi} hi_2} hi3}↲ -••••{hi}{hi_2}{hi3}↲ [original] line 2 +••••{hi}{hi_2}{hi3}↲ [original] line 2 ------------------------------------------------------------------------------------------------------------------------------------------------------ */} }Component}}; {/** •}Component}};↲ [generated] line 5 diff --git a/packages/svelte2tsx/test/sourcemaps/samples/slots/mappings.jsx b/packages/svelte2tsx/test/sourcemaps/samples/slots/mappings.jsx index 86e0654ab..8353a45dd 100644 --- a/packages/svelte2tsx/test/sourcemaps/samples/slots/mappings.jsx +++ b/packages/svelte2tsx/test/sourcemaps/samples/slots/mappings.jsx @@ -7,30 +7,36 @@ async () => { { __sveltets_createSlot("default", {});} async•()•=>•{•{•__sveltets_createSlot("default",•{});}↲ [generated] line 4 < / ↲ < / ↲ -↲ [original] line 1 +↲ [original] line 1 (rest generated at line 5) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 5 + ↲ +↲ [original] line 1 (rest generated at line 4) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { __sveltets_createSlot("foo", { }); } {/** •{•__sveltets_createSlot("foo",•{•});••}↲ [generated] line 6 < f oo " an f/ ↲ #==# Order-breaking mappings < na foo" f / ↲ -fallback↲ [original] line 3 +fallback↲ [original] line 3 (rest generated at line 7) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 7 + ↲ +fallback↲ [original] line 3 (rest generated at line 6) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { __sveltets_createSlot("bar", { "foo":foo,baz,"leet":true,}); } {/** •{•__sveltets_createSlot("bar",•{••••"foo":foo,baz,"leet":true,});••}↲ [generated] line 8 < b ar " {•••f oo= foo}baz}l eet f/ ↲ #== # Order-breaking mappings < foo={foo}• bar"• baz}•leet f / ↲ -fallback↲ [original] line 5 +fallback↲ [original] line 5 (rest generated at line 9) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} {/** - +↲ [generated] line 9 + ↲ +fallback↲ [original] line 5 (rest generated at line 8) ------------------------------------------------------------------------------------------------------------------------------------------------------ */} { __sveltets_createSlot("bar", { "foo":foo,baz,"leet":true,}); {/** •{•__sveltets_createSlot("bar",•{•••••"foo":foo,baz,"leet":true,});↲ [generated] line 10 diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d60a88176..f1bc6d8f0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -266,8 +266,8 @@ importers: specifier: ^2.0.1 version: 2.0.2 magic-string: - specifier: ^0.27.0 - version: 0.27.0 + specifier: ^0.30.11 + version: 0.30.11 mocha: specifier: ^9.2.0 version: 9.2.2