Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
510d74e
feat(compiler-sfc): add EditedString built on muggle-string
cursoragent Nov 4, 2026
0c7439c
refactor(compiler-sfc): edit scripts with EditedString
cursoragent Nov 4, 2026
f40d4f3
perf(compiler-sfc): merge inline maps from decoded segments
cursoragent Nov 4, 2026
0355f89
perf(compiler-sfc): skip the inline template map without maps
cursoragent Nov 4, 2026
5dc25dc
chore: remove unused magic-string devDependency
johnsoncodehk Nov 4, 2026
e82ba5c
test(compiler-sfc): keep only EditedString's own source map tests
johnsoncodehk Nov 4, 2026
40520aa
refactor(compiler): remove source-map-js
johnsoncodehk Nov 4, 2026
f9c3dd0
perf(compiler): render template source maps from muggle-string pieces…
johnsoncodehk Nov 4, 2026
805e0d0
refactor(compiler-sfc): remove EditedString (#20)
johnsoncodehk Nov 4, 2026
c472118
chore(sfc-playground): give the repl module compiler its string editor
cursoragent Nov 4, 2026
9a4e1b0
Revert "chore(sfc-playground): give the repl module compiler its stri…
cursoragent Nov 4, 2026
587ae56
refactor(compiler-sfc): place template pieces in the SFC instead of r…
johnsoncodehk Nov 4, 2026
12c999d
fix(compiler-core): map closing lines to their node (#22)
johnsoncodehk Nov 4, 2026
6733d9e
refactor(compiler-sfc): place the template in the SFC by its AST, not…
johnsoncodehk Nov 4, 2026
36364c9
perf(compiler): render no template map for a caller that renders the …
johnsoncodehk Nov 4, 2026
1fb793e
chore(playground): use the @vue/repl build from repl main
cursoragent Nov 4, 2026
0b1a7e3
fix(compiler): name the identifiers template source maps rename
cursoragent Nov 4, 2026
2f995ed
fix(compiler-core): give a slot function the loc of its slot
cursoragent Nov 4, 2026
e2066d0
fix(compiler-vapor): map the display string call to the node that dis…
cursoragent Nov 4, 2026
d3a5cdb
chore(compiler-core): mark the piece exports for the other compilers …
cursoragent Nov 4, 2026
afe4eca
refactor(compiler-sfc): place the code at the start of the output and…
cursoragent Nov 4, 2026
36c8600
fix(compiler-sfc): nest the code after an await outside that of the a…
cursoragent Nov 4, 2026
7c29e32
fix(compiler-sfc): leave awaits in macro arguments hoisted outside of…
cursoragent Nov 4, 2026
d275d08
fix(compiler-sfc): error on an await in a destructured prop default w…
cursoragent Nov 4, 2026
fc83941
fix(compiler-sfc): map macro arguments hoisted outside of setup()
cursoragent Nov 4, 2026
702775a
fix(compiler-sfc): evaluate defineModel options once when they can't …
cursoragent Nov 4, 2026
058aa2d
refactor(compiler-sfc): inline the render function by its pieces
cursoragent Nov 5, 2026
148f199
build(deps): use muggle-string ^1.0.2
cursoragent Nov 5, 2026
36eb520
refactor(compiler-core): deprecate NewlineType and the newlineIndex o…
cursoragent Nov 5, 2026
cf5c146
fix(compiler-vapor): map text without a location as core does
cursoragent Nov 5, 2026
2c1842a
fix(compiler-core): type the version of RawSourceMap as the number it is
cursoragent Nov 5, 2026
3f041ad
test: scan the source of @vue/compiler-core for browser dependencies
cursoragent Nov 5, 2026
75b3b80
test(compiler-sfc): expect the map of a template compiler without pieces
cursoragent Nov 5, 2026
6ebdcde
test(compiler-sfc): mark the source map of a preprocessed template ex…
cursoragent Nov 5, 2026
027c836
test: read source maps with @jridgewell/trace-mapping instead of sour…
cursoragent Nov 5, 2026
e84987f
chore(template-explorer): map positions with @jridgewell/trace-mapping
cursoragent Nov 5, 2026
18e558c
Revert "chore(template-explorer): map positions with @jridgewell/trac…
cursoragent Nov 5, 2026
b265e55
Revert "test: read source maps with @jridgewell/trace-mapping instead…
cursoragent Nov 5, 2026
078914e
test: read source maps with the decoder of muggle-string instead of s…
cursoragent Nov 5, 2026
045fae5
chore(template-explorer): read the source map with muggle-string
cursoragent Nov 5, 2026
12138ba
chore(compiler-sfc): indent the code of a nested await by its depth
cursoragent Nov 5, 2026
c38da1c
chore: merge upstream minor into cursor/muggle-string-0eaa
cursoragent Nov 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
{
groupName: 'compiler',
matchPackageNames: ['magic-string', '@babel{/,}**', 'postcss{/,}**'],
matchPackageNames: ['@babel{/,}**', 'postcss{/,}**'],
},
{
groupName: 'build',
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
"fast-glob": "^3.3.2",
"jsdom": "^30.0.1",
"lodash": "^4.18.1",
"magic-string": "^0.30.21",
"markdown-table": "^3.1.0",
"marked": "13.0.3",
"npm-run-all2": "^9.0.4",
Expand Down
2 changes: 1 addition & 1 deletion packages-private/sfc-playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"vite": "catalog:"
},
"dependencies": {
"@vue/repl": "^4.7.2",
"@vue/repl": "https://pkg.pr.new/vuejs/repl/@vue/repl@59212b9",
"file-saver": "^2.0.5",
"jszip": "^3.10.2",
"vue": "workspace:*"
Expand Down
2 changes: 1 addition & 1 deletion packages-private/template-explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"dependencies": {
"@vue/compiler-vapor": "workspace:^",
"monaco-editor": "^0.57.0",
"source-map-js": "^1.2.2"
"muggle-string": "catalog:"
}
}
88 changes: 71 additions & 17 deletions packages-private/template-explorer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
vaporMode,
} from './options'
import { toRaw, watchEffect } from '@vue/runtime-dom'
import { SourceMapConsumer } from 'source-map-js'
import { type SourceMapSegment, decodeMappings } from 'muggle-string'
import theme from './theme'

declare global {
Expand Down Expand Up @@ -75,7 +75,8 @@ window.init = () => {
}

let lastSuccessfulCode: string
let lastSuccessfulMap: SourceMapConsumer | undefined = undefined
let lastSuccessfulMap: SourceMapSegment[][] | undefined = undefined
let templateSource = -1
function compileCode(source: string): string {
console.clear()
try {
Expand Down Expand Up @@ -105,8 +106,8 @@ window.init = () => {
console.log(`AST: `, ast)
console.log(`Options: `, toRaw(compilerOptions))
lastSuccessfulCode = code + `\n\n// Check the console for the AST`
lastSuccessfulMap = new SourceMapConsumer(map!)
lastSuccessfulMap!.computeColumnSpans()
lastSuccessfulMap = decodeMappings(map!.mappings)
templateSource = map!.sources.indexOf('ExampleTemplate.vue')
} catch (e: any) {
lastSuccessfulCode = `/* ERROR: ${e.message} (see console for more info) */`
console.error(e)
Expand Down Expand Up @@ -194,19 +195,20 @@ window.init = () => {
debounce(e => {
clearEditorDecos()
if (lastSuccessfulMap) {
const pos = lastSuccessfulMap.generatedPositionFor({
source: 'ExampleTemplate.vue',
line: e.position.lineNumber,
column: e.position.column - 1,
})
if (pos.line != null && pos.column != null) {
const pos = generatedSpanFor(
lastSuccessfulMap,
templateSource,
e.position.lineNumber,
e.position.column - 1,
)
if (pos) {
prevOutputDecos = output.deltaDecorations(prevOutputDecos, [
{
range: new monaco.Range(
pos.line,
pos.column + 1,
pos.line,
pos.lastColumn ? pos.lastColumn + 2 : pos.column + 2,
pos.end + 1,
),
options: {
inlineClassName: `highlight`,
Expand All @@ -233,13 +235,13 @@ window.init = () => {
debounce(e => {
clearOutputDecos()
if (lastSuccessfulMap) {
const pos = lastSuccessfulMap.originalPositionFor({
line: e.position.lineNumber,
column: e.position.column - 1,
})
const pos = originalPositionFor(
lastSuccessfulMap,
e.position.lineNumber,
e.position.column - 1,
)
if (
pos.line != null &&
pos.column != null &&
pos &&
!(
// ignore mock location
pos.line === 1 && pos.column === 0
Expand Down Expand Up @@ -290,3 +292,55 @@ function debounce<T extends (...args: any[]) => any>(
}, delay)
}) as T
}

// the output of the mapping of `source` on `line` (from 1) that starts last at
// or before `column`, the earliest in the output if several; it spans up to
// the next mapping on its line
function generatedSpanFor(
mappings: SourceMapSegment[][],
source: number,
line: number,
column: number,
): { line: number; column: number; end: number } | undefined {
let span: { line: number; column: number; end: number } | undefined
let spanColumn = -1
mappings.forEach((segments, generatedLine) => {
segments.forEach(([start, segmentSource, sourceLine, sourceColumn], i) => {
if (
sourceColumn !== undefined &&
segmentSource === source &&
sourceLine === line - 1 &&
sourceColumn <= column &&
sourceColumn > spanColumn
) {
spanColumn = sourceColumn
const next = segments[i + 1]
span = {
line: generatedLine + 1,
column: start,
end: next ? next[0] : Infinity,
}
}
})
})
return span
}

// the source position of the mapping on `line` (from 1) of the output that
// starts last at or before `column`
function originalPositionFor(
mappings: SourceMapSegment[][],
line: number,
column: number,
): { line: number; column: number } | undefined {
let found: SourceMapSegment | undefined
for (const segment of mappings[line - 1] || []) {
if (segment[0] > column) break
if (!found || segment[0] > found[0]) found = segment
}
if (!found) return
const [, , sourceLine, sourceColumn] = found
return sourceLine === undefined || sourceColumn === undefined
? undefined
: { line: sourceLine + 1, column: sourceColumn }
}
Loading