@motionscript/code 0.0.0-stage → 0.1.0-alpha.0
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.
- package/CHANGELOG.md +5 -0
- package/LICENSE +201 -0
- package/README.md +76 -3
- package/dist/browser/chunks/chunk-HET2RCSD.js +2 -0
- package/dist/browser/chunks/chunk-HET2RCSD.js.map +7 -0
- package/dist/browser/chunks/chunk-SYZUZB3M.js +2 -0
- package/dist/browser/chunks/chunk-SYZUZB3M.js.map +7 -0
- package/dist/browser/chunks/dist-3F5TQHM6.js +2 -0
- package/dist/browser/chunks/dist-3F5TQHM6.js.map +7 -0
- package/dist/browser/chunks/dist-3SIR23P4.js +2 -0
- package/dist/browser/chunks/dist-3SIR23P4.js.map +7 -0
- package/dist/browser/chunks/dist-AQRNACF3.js +2 -0
- package/dist/browser/chunks/dist-AQRNACF3.js.map +7 -0
- package/dist/browser/chunks/dist-B46VH2YP.js +2 -0
- package/dist/browser/chunks/dist-B46VH2YP.js.map +7 -0
- package/dist/browser/chunks/dist-FH6BHJ6A.js +7 -0
- package/dist/browser/chunks/dist-FH6BHJ6A.js.map +7 -0
- package/dist/browser/chunks/dist-FQDUBZKU.js +2 -0
- package/dist/browser/chunks/dist-FQDUBZKU.js.map +7 -0
- package/dist/browser/chunks/dist-GPNEVCJI.js +2 -0
- package/dist/browser/chunks/dist-GPNEVCJI.js.map +7 -0
- package/dist/browser/chunks/dist-LRSXSDHT.js +2 -0
- package/dist/browser/chunks/dist-LRSXSDHT.js.map +7 -0
- package/dist/browser/chunks/dist-N4CNBNHL.js +2 -0
- package/dist/browser/chunks/dist-N4CNBNHL.js.map +7 -0
- package/dist/browser/chunks/dist-OXJDTPQ6.js +2 -0
- package/dist/browser/chunks/dist-OXJDTPQ6.js.map +7 -0
- package/dist/browser/chunks/dist-SH7H4MRK.js +2 -0
- package/dist/browser/chunks/dist-SH7H4MRK.js.map +7 -0
- package/dist/browser/chunks/dist-UG3NTKWL.js +2 -0
- package/dist/browser/chunks/dist-UG3NTKWL.js.map +7 -0
- package/dist/browser/chunks/dist-W5ZXIMV7.js +2 -0
- package/dist/browser/chunks/dist-W5ZXIMV7.js.map +7 -0
- package/dist/browser/index.js +8 -0
- package/dist/browser/index.js.map +7 -0
- package/dist/browser/manifest.json +11 -0
- package/dist/code-range.d.ts +69 -0
- package/dist/code-range.d.ts.map +1 -0
- package/dist/code-range.js +124 -0
- package/dist/code-range.js.map +1 -0
- package/dist/diff.d.ts +42 -0
- package/dist/diff.d.ts.map +1 -0
- package/dist/diff.js +179 -0
- package/dist/diff.js.map +1 -0
- package/dist/engine.d.ts +15 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +17 -0
- package/dist/engine.js.map +1 -0
- package/dist/highlight.d.ts +43 -0
- package/dist/highlight.d.ts.map +1 -0
- package/dist/highlight.js +243 -0
- package/dist/highlight.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/layout.d.ts +77 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +74 -0
- package/dist/layout.js.map +1 -0
- package/dist/measure-cache.d.ts +38 -0
- package/dist/measure-cache.d.ts.map +1 -0
- package/dist/measure-cache.js +0 -0
- package/dist/measure-cache.js.map +1 -0
- package/dist/node.d.ts +293 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +733 -0
- package/dist/node.js.map +1 -0
- package/dist/nodes.d.ts +18 -0
- package/dist/nodes.d.ts.map +1 -0
- package/dist/nodes.js +18 -0
- package/dist/nodes.js.map +1 -0
- package/dist/render.d.ts +28 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +223 -0
- package/dist/render.js.map +1 -0
- package/dist/style.d.ts +88 -0
- package/dist/style.d.ts.map +1 -0
- package/dist/style.js +203 -0
- package/dist/style.js.map +1 -0
- package/dist/tokens.d.ts +24 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +50 -0
- package/dist/tokens.js.map +1 -0
- package/dist/transitions.d.ts +115 -0
- package/dist/transitions.d.ts.map +1 -0
- package/dist/transitions.js +85 -0
- package/dist/transitions.js.map +1 -0
- package/package.json +82 -3
- package/registry.json +6 -0
- package/src/code-range.ts +156 -0
- package/src/diff.ts +216 -0
- package/src/engine.ts +21 -0
- package/src/highlight.ts +291 -0
- package/src/index.ts +3 -0
- package/src/layout.ts +157 -0
- package/src/measure-cache.ts +0 -0
- package/src/node.ts +834 -0
- package/src/nodes.ts +18 -0
- package/src/render.ts +247 -0
- package/src/style.ts +251 -0
- package/src/tokens.ts +75 -0
- package/src/transitions.ts +184 -0
package/dist/node.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACH,IAAI,EAC2B,IAAI,EACnC,MAAM,EACN,QAAQ,EAAE,SAAS,EAAE,UAAU,EAC/B,OAAO,EAAE,YAAY,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEH,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EAEjB,qBAAqB,EACrB,eAAe,EAIf,UAAU,EACV,gBAAgB,EAIhB,QAAQ,EACR,iBAAiB,EAEjB,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACZ,iBAAiB,EAEjB,qBAAqB,EACrB,QAAQ,GACX,MAAM,UAAU,CAAC;AAqDX,IAAM,IAAI,GAAV,MAAM,IAAK,SAAQ,MAAiB;IAmBvC,8EAA8E;IACtE,UAAU,GAAa,EAAE,CAAC;IAC1B,SAAS,GAAY,KAAK,CAAC;IAE3B,WAAW,GAAqB,EAAE,CAAC;IAE3C,oEAAoE;IACpE,kEAAkE;IAC1D,YAAY,GAAG,IAAI,iBAAiB,EAAE,CAAC;IAE/C,mEAAmE;IACnE,4EAA4E;IAC5E,sEAAsE;IACtE,8CAA8C;IACtC,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G,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;qCAiCzJ;AAOD;IADC,OAAO,EAAE;0CAqBT;AAheQ,IAAI;IAVhB,IAAI,CAAC;QACJ,GAAG,EAAE,MAAM;QACX,SAAS,EAAE,MAAM;QACjB,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE;YACN,gBAAgB,EAAE,KAAK;YACvB,iBAAiB,EAAE,KAAK;YACxB,eAAe,EAAE,KAAK;SACvB;KACF,CAAC;GACW,IAAI,CA8sBhB;;AAED;;;;;;GAMG;AACH,SAAS,mBAAmB,CAAC,SAA0C;IACnE,MAAM,aAAa,GAAG,SAAyC,CAAC;IAChE,IAAI,OAAO,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,UAAU,EAAE,CAAC;QACvD,OAAO,CAAC,GAAI,SAAiC,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,CAAC,SAAsB,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,cAAc,GAAG,IAAI,GAAG,EAA+B,CAAC;AAE9D,6EAA6E;AAC7E,6EAA6E;AAC7E,SAAS,aAAa,CAAC,QAAgB;IACnC,IAAI,IAAI,GAAG,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACxC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACrB,IAAI,GAAG,GAAG,EAAE,CAAC,iBAAiB,CAAC,SAAS,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;QACtD,cAAc,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import {\n node,\n RenderContext2D, RenderPass2D, Clip, EasingFunction, NodeConfig, Size2D, SizeConstraints,\n Node2D, Node2DProps, MeasureContext2D, InsetsResolved, InsetsProps,\n property, insetsOps, lerpNumber,\n command, driveCommand, type AssetScope, type Command, type CommandArgs, type Node, type TweenStepper, type Vector2,\n} from \"@motionscript/core\";\nimport {\n CodeRange,\n rangeToCharOffsets,\n charOffsetsToRange,\n TokenAdvanceCache,\n IdLine,\n tokenizeCodeToIdLines,\n defaultCodeDiff,\n type CodeDiffStrategy,\n CodeLayout,\n CodeMetrics,\n layoutCode,\n metricsSignature,\n AnimToken,\n CodeTransition,\n StructuralTransition,\n makeAnim,\n defaultCodePhases,\n type CodePhaseStrategy,\n resolveTokenStates,\n moveProgress,\n canHighlight,\n ensureHighlighter,\n CodeTheme,\n DefaultHighlightStyle,\n drawCode,\n} from \"./engine\";\n\n/**\n * A listing and nothing else — no paint slots, and no box behind the tokens.\n *\n * It did carry a `fill`/`overlay`/`stroke`/`shadow` set and the corner radius\n * that shaped them, so a block could draw its own panel. That was one node doing\n * two jobs, and the second one is a `Rect`'s: a listing set on a card is a `Code`\n * inside a hugging `Rect`, which tracks the block's size for the same reason\n * every other hugging container tracks its child's. What is left here is the\n * listing — its source, how it is coloured, the face it is set in, and the space\n * it keeps around itself.\n */\nexport interface CodeProps extends Node2DProps {\n code: string;\n language: string;\n fontSize: number;\n fontFamily: string;\n /** A built-in/registered theme name (e.g. `'github-dark'`), or a {@link CodeHighlightStyle} object. */\n theme: CodeTheme;\n lineHeight: number;\n letterSpacing: number;\n showLineNumbers: boolean;\n lineNumberGap: number;\n padding: InsetsProps;\n}\n\n/**\n * Construction-time-only options: pluggable engine behavior, set once when\n * the node is created. Deliberately *not* part of {@link CodeProps} — every\n * `@property` field accepts either a value or a zero-arg reactive binding\n * (`value | (() => value)`, see `PropInputs`), and the node's own reactive\n * write path (`_writeProp`) treats any function value as the latter. A\n * strategy *is* a function, so it can't be told apart from a binding that\n * computes one — it has to stay outside the reactive prop system entirely.\n */\nexport interface CodeStrategies {\n /** Decides which token became which across an edit. Defaults to `defaultCodeDiff`. */\n diffStrategy?: CodeDiffStrategy;\n /** Decides when (in normalized transition time) each part of an edit happens. Defaults to `defaultCodePhases`. */\n phaseStrategy?: CodePhaseStrategy;\n}\n\n@node({\n key: \"code\",\n parentKey: \"node\",\n forkable: true,\n layout: {\n defaultWidthMode: \"hug\",\n defaultHeightMode: \"hug\",\n acceptsChildren: false,\n },\n})\nexport class Code extends Node2D<CodeProps> {\n\n @property({ default: \"\" }) declare readonly code: string;\n @property({ default: \"typescript\" }) declare readonly language: string;\n @property({ default: \"Fira Mono\" }) declare readonly fontFamily: string;\n @property({ default: DefaultHighlightStyle.name }) declare readonly theme: CodeTheme;\n @property({ default: 16 }) declare readonly fontSize: number;\n @property({ default: 1.6 }) declare readonly lineHeight: number;\n // Extra horizontal space added after every glyph (in px), like CSS\n // letter-spacing. Folded into the advance a token is measured at, so\n // measurement and drawing stay in lockstep.\n @property({ default: 1.1 }) declare readonly letterSpacing: number;\n @property({ default: false }) declare readonly showLineNumbers: boolean;\n // Horizontal gap between the line-number column and the code text, expressed\n // in space-widths (so it scales with fontSize). Only applies when\n // showLineNumbers is on.\n @property({ default: 2 }) declare readonly lineNumberGap: number;\n @property({ default: 0, mapper: insetsOps.resolve, tween: insetsOps.lerp }) declare readonly padding: InsetsResolved;\n\n /** The settled structure. During an edit, the structure the edit lands on. */\n private tokenLines: IdLine[] = [];\n private tokenized: boolean = false;\n\n private transitions: CodeTransition[] = [];\n\n // Caches expensive scope.measureText() calls; cleared when the font\n // signature (fontSize|fontFamily) changes. See TokenAdvanceCache.\n private advanceCache = new TokenAdvanceCache();\n\n // Layout cache for *settled* frames. Bumped whenever tokenLines is\n // reassigned, so a cache hit only ever happens on identical content. Frames\n // inside a structural edit are served from that edit's own two cached\n // layouts instead (see StructuralTransition).\n private structureVersion = 0;\n private layoutCacheKey: string | null = null;\n private layoutCache: CodeLayout | null = null;\n\n // Persistent dim state set by highlight() — applied during render to all\n // tokens whose id is NOT in the highlight set. null means \"not highlighting\".\n private highlightDimOpacity: number | null = null;\n private highlightedIds: Set<number> = new Set();\n\n /**\n * Which token became which across an edit, and when each part of that\n * edit happens. Construction-time-only (see {@link CodeStrategies}) —\n * resolved once here rather than left as `?? defaultX` at every call site.\n */\n private readonly diffStrategy: CodeDiffStrategy;\n private readonly phaseStrategy: CodePhaseStrategy;\n\n constructor(props: NodeConfig<Code, CodeProps> & CodeStrategies) {\n super(props);\n this.diffStrategy = props.diffStrategy ?? defaultCodeDiff;\n this.phaseStrategy = props.phaseStrategy ?? defaultCodePhases;\n this.applyProp(\"width\", props.width ?? \"hug\");\n this.applyProp(\"height\", props.height ?? \"hug\");\n\n // Best-effort, for a highlighter constructed outside the asset pipeline\n // entirely (a bare `new Code(...)` in a test or a headless measure). On\n // the timeline the authoritative load is the one `declareAssets` declares,\n // which `AssetManager.loadAt` awaits *before* this node is laid out — so\n // there the tokens are right the first time rather than upgrading later.\n // (Theme is a synchronous color style; only the language parser loads.)\n ensureHighlighter(undefined, [this.language]).catch(() => { });\n this.tokenize();\n }\n\n set(props: { [K in keyof CodeProps]?: CodeProps[K] | (() => CodeProps[K]) }): void {\n super.set(props);\n if (props.code !== undefined || props.language !== undefined || props.theme !== undefined) {\n this.tokenized = false;\n }\n }\n\n private tokenize(): void {\n this.setLines(tokenizeCodeToIdLines(this.code, this.language, this.theme));\n // Only consider ourselves tokenized once we actually highlighted; while\n // the language is still loading we keep retrying on each render.\n this.tokenized = canHighlight(this.language, this.theme);\n }\n\n /**\n * Swap in a new settled structure, invalidating the layout cache.\n *\n * The one place `tokenLines` is written, because the cache key is a version\n * counter rather than a hash of the content — a write that skipped the bump\n * would keep serving the previous frame's geometry for the new listing.\n */\n private setLines(lines: IdLine[]): void {\n if (this.tokenLines === lines) return;\n this.tokenLines = lines;\n this.structureVersion++;\n this.layoutCache = null;\n this.layoutCacheKey = null;\n }\n\n /**\n * The monospaced face this block measures and draws with, and the syntax\n * grammar it tokenizes with.\n *\n * Both belong to *layout*: token x positions are measured against the face,\n * and how many tokens there are depends on the grammar. Declared here, the\n * grammar goes on the timeline as an ordinary asset: `AssetManager.loadAt`\n * waits for it before the frame is laid out, so the first measurement is the\n * right one. Nothing is freed on eviction — parsers are cheap to keep\n * resident. The loader touches no node: `renderContent` re-tokenizes once\n * the grammar is there.\n */\n override declareAssets(assets: AssetScope): void {\n super.declareAssets(assets);\n assets.font(this.fontFamily);\n assets.loader(`shiki:lang:${this.language}`, grammarLoader(this.language), { gate: \"layout\" });\n }\n\n // ── Geometry ────────────────────────────────────────────────────────────\n\n private metrics(): CodeMetrics {\n return {\n fontSize: this.fontSize,\n fontFamily: this.fontFamily,\n lineHeight: this.lineHeight,\n letterSpacing: this.letterSpacing,\n padding: this.padding,\n showLineNumbers: this.showLineNumbers,\n lineNumberGap: this.lineNumberGap,\n };\n }\n\n /** The structural edit currently in flight, if any. */\n private activeEdit(): StructuralTransition | null {\n for (let i = this.transitions.length - 1; i >= 0; i--) {\n const tr = this.transitions[i];\n if (tr.kind === \"structural\") return tr;\n }\n return null;\n }\n\n private settledLayout(m: CodeMetrics, scope: MeasureContext2D | RenderContext2D): CodeLayout {\n const key = `${this.structureVersion}|${metricsSignature(m)}|${this.advanceCache.signature(m.fontSize, m.fontFamily)}`;\n if (this.layoutCache && this.layoutCacheKey === key) return this.layoutCache;\n const layout = layoutCode(this.tokenLines, m, this.advanceCache, scope);\n this.layoutCache = layout;\n this.layoutCacheKey = key;\n return layout;\n }\n\n /**\n * The one or two layouts this frame is drawn from.\n *\n * A settled frame has one. A frame inside an edit has two — where every\n * token was, and where it is going — and the frame is a point between them.\n * That is the whole reason an insert no longer piles its glyphs at the left\n * margin: a token's destination is *computed*, not approximated by collapsing\n * the advance of everything around it.\n *\n * Both endpoints are fixed for the edit's duration, so they are built once\n * and cached on the transition rather than rebuilt per frame.\n */\n private frameLayout(scope: MeasureContext2D | RenderContext2D): {\n from: CodeLayout;\n to: CodeLayout;\n edit: StructuralTransition | null;\n } {\n const m = this.metrics();\n const edit = this.activeEdit();\n if (!edit) {\n const layout = this.settledLayout(m, scope);\n return { from: layout, to: layout, edit: null };\n }\n const key = `${metricsSignature(m)}|${this.advanceCache.signature(m.fontSize, m.fontFamily)}`;\n if (edit.layoutKey !== key || !edit.fromLayout || !edit.toLayout) {\n edit.fromLayout = layoutCode(edit.from, m, this.advanceCache, scope);\n edit.toLayout = layoutCode(edit.to, m, this.advanceCache, scope);\n edit.layoutKey = key;\n }\n return { from: edit.fromLayout, to: edit.toLayout, edit };\n }\n\n override measure(constraints: SizeConstraints, scope: MeasureContext2D): Partial<Size2D> {\n this.advanceCache.sync(this.advanceCache.signature(this.fontSize, this.fontFamily));\n const wm = this.width;\n const hm = this.height;\n\n const { from, to, edit } = this.frameLayout(scope);\n const t = moveProgress(edit);\n const innerW = edit ? lerpNumber(from.innerW, to.innerW, t) : to.innerW;\n const innerH = edit ? lerpNumber(from.innerH, to.innerH, t) : to.innerH;\n\n const resolvedW = typeof wm === \"number\"\n ? wm\n : wm === \"hug\"\n ? innerW + this.padding.left + this.padding.right\n : constraints.maxWidth ?? 0;\n\n const resolvedH = typeof hm === \"number\"\n ? hm\n : hm === \"hug\"\n ? innerH + this.padding.top + this.padding.bottom\n : constraints.maxHeight ?? 0;\n\n return { width: resolvedW, height: resolvedH };\n }\n\n protected override renderContent(ctx: RenderPass2D): void {\n // Refuse the ambient `<DefaultTextStyle>` / theme typography defaults for\n // everything drawn inside this node.\n //\n // Those defaults describe the *document's* prose — a display face, a\n // heading weight, a paragraph line-height — and a code block is not prose.\n // Its own props are the vocabulary: `fontFamily` defaults to a monospaced\n // face because column alignment depends on it, `letterSpacing` and\n // `lineHeight` are tuned against that face, and every token is laid out at\n // an x measured from those exact values. A scene-wide serif family or a\n // 700 weight arriving through the draw scope would shape glyphs the\n // geometry was never measured for, and the block would come apart\n // column-by-column rather than merely look different.\n ctx.pushTextStyle(null);\n try {\n // Keep retrying until the language+theme have actually loaded, so a frame\n // that rendered as plain text upgrades to full highlighting the moment the\n // asset loader resolves. Never mid-edit: re-tokenizing mints fresh ids,\n // and an in-flight transition is keyed by the ones it captured.\n if (!this.tokenized && !this.activeEdit() && canHighlight(this.language, this.theme)) {\n this.tokenize();\n }\n super.renderContent(ctx);\n } finally {\n ctx.popTextStyle();\n }\n }\n\n protected override renderSelf(ctx: RenderContext2D): void {\n this.drawSelf(ctx);\n }\n\n /** A listing holds a listing — `append`/`insert`/`erase` are how it grows. */\n protected override acceptsChild(_child: Node): boolean {\n return false;\n }\n\n /**\n * The node's laid-out rect as a clip outline, so `clip` and any backdrop\n * effect are confined to the block rather than to nothing — a listing set on\n * a card is exactly where a backdrop blur is asked for.\n */\n protected override clipSelf(): Clip {\n return new Clip().rect({\n width: this.layoutBounds.width,\n height: this.layoutBounds.height,\n });\n }\n\n /**\n * A listing is grabbed by its **text**, line by ragged line, rather than by\n * the rectangle the lines were laid out in.\n *\n * The default narrows a node's grab region to the outline it declares, and\n * this node's outline is a box it no longer paints anything into. Code is\n * mostly whitespace: a ten-line snippet with one long line is a rectangle\n * that is largely empty, and in an editor every one of those empty pixels\n * swallows a click meant for whatever sits behind or beneath it. Short of the\n * text itself there is nothing there to have clicked.\n *\n * So the region is the union of the lines' own extents — each a line-height\n * slot as wide as that line's ink — plus the gutter where line numbers are\n * showing, since those are drawn glyphs too.\n *\n * Answered from the **cached** layout, which is what the last frame drew\n * from, because a hit test arrives with no measurement scope and text cannot\n * be measured without one. Where there is no usable cache — before the first\n * frame, or mid-edit, when the geometry is an interpolation of two structures\n * held on the transition — the box is the honest answer rather than a\n * silhouette measured against stale metrics.\n */\n protected override hitTestSelf(local: Vector2, tolerance: number): boolean {\n const layout = this.hitLayout();\n if (!layout) return super.hitTestSelf(local, tolerance);\n\n // Never *wider* than the box: `hug` sizes to the ink, but a fixed width\n // narrower than the longest line would otherwise be hit outside itself.\n if (!super.hitTestSelf(local, tolerance)) return false;\n\n const half = (this.fontSize * this.lineHeight) / 2;\n // Line numbers sit in the gutter, to the left of every line's own start,\n // so a numbered blank line is still grabbable — by its number.\n const gutter = this.showLineNumbers ? layout.gutter : 0;\n const left = layout.startX - gutter - tolerance;\n for (let i = 0; i < layout.lineY.length; i++) {\n const width = (layout.lineW[i] ?? 0) + gutter;\n if (width <= 0) continue;\n if (Math.abs(local.y - layout.lineY[i]) > half + tolerance) continue;\n if (local.x >= left && local.x <= layout.startX + (layout.lineW[i] ?? 0) + tolerance) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * The layout a hit test may be answered from: the settled cache, and only\n * while it still matches the node's current metrics.\n *\n * The key is the one {@link settledLayout} writes minus its scope-dependent\n * half — every input to it (`metricsSignature`, the advance cache's own\n * signature) is readable without a measurer, which is precisely what makes\n * the check possible here.\n */\n private hitLayout(): CodeLayout | null {\n if (!this.layoutCache || this.activeEdit()) return null;\n const m = this.metrics();\n const key = `${this.structureVersion}|${metricsSignature(m)}|${this.advanceCache.signature(m.fontSize, m.fontFamily)}`;\n return this.layoutCacheKey === key ? this.layoutCache : null;\n }\n\n // ── Editing commands ────────────────────────────────────────────────────\n\n /**\n * Append `code` to the end of the listing.\n *\n * Stated as *what the source becomes*; {@link editTo} works out the rest —\n * which is why appending a line that closes a block re-highlights the lines\n * above it, instead of colouring the new text as its own program.\n */\n @command({ args: [{ key: \"code\", kind: \"text\", multiline: true }] })\n append(args: CommandArgs<{ code: string }> & { duration: number }): Command<Record<string, never>> {\n const { code } = args.data as { code: string };\n return this.editTo(this.joinedSource() + code, args.duration, args.easing);\n }\n\n /** Insert `code` above the listing. */\n @command({ args: [{ key: \"code\", kind: \"text\", multiline: true }] })\n prepend(args: CommandArgs<{ code: string }> & { duration: number }): Command<Record<string, never>> {\n const { code } = args.data as { code: string };\n return this.editTo(code + this.joinedSource(), args.duration, args.easing);\n }\n\n /**\n * Insert `code` at the given (line, col). Both are 1-indexed; col is the\n * column BEFORE which the new content is inserted (col=1 means start of\n * line). If `code` contains newlines, new lines are created in the middle\n * of the existing line.\n */\n @command({\n args: [\n // Two controls, one argument: the method takes a `[line, col]`\n // tuple, so the pair a host draws is declared *inside* the value it\n // composes into rather than flattened beside it.\n {\n key: \"position\", kind: \"point\", properties: {\n line: { kind: \"number\", default: 1, min: 1, step: 1 },\n col: { kind: \"number\", default: 1, min: 1, step: 1 },\n },\n },\n { key: \"code\", kind: \"text\", default: \"\", multiline: true },\n ],\n })\n insert(\n args: CommandArgs<{ position: [number, number]; code: string }> & { duration: number },\n ): Command<Record<string, never>> {\n const { position, code } = args.data as { position: [number, number]; code: string };\n const source = this.joinedSource();\n const offset = this.offsetAt(position);\n return this.editTo(source.slice(0, offset) + code + source.slice(offset), args.duration, args.easing);\n }\n\n /**\n * Erase the code in `codeRange`.\n *\n * Named `erase` rather than `remove` because a `Code` is also a node, and\n * `Node.remove(child)` takes a child out of the tree. Two methods spelled\n * the same on one object, doing entirely different things, is worse than one\n * of them having a slightly less obvious name.\n *\n * A range that covers whole lines takes their line breaks with it, so the\n * rows below close up; a range inside a line takes only the characters, and\n * the rest of the line reflows around the hole.\n */\n @command({ key: \"remove\", args: [{ key: \"target\", kind: \"selector\" }] })\n erase(\n args: CommandArgs<{ target: CodeRange }> & { duration: number },\n ): Command<Record<string, never>> {\n const { target: codeRange } = args.data as { target: CodeRange };\n const { duration, easing } = args;\n const source = this.joinedSource();\n let { start, end } = rangeToCharOffsets(codeRange, this.lineLengths());\n // `lines(2)` resolves to the *characters* of line 2, not to the row —\n // taking those alone would leave an empty line behind where an editor\n // would have closed the gap. This is also what makes a blank row\n // removable at all: it has no characters, so its range is empty, and\n // \"delete nothing\" is not what `lines(2)` was asking for.\n const atLineStart = start === 0 || source[start - 1] === \"\\n\";\n const atLineEnd = end === source.length || source[end] === \"\\n\";\n if (atLineStart && atLineEnd) {\n if (end < source.length) end += 1;\n else if (start > 0) start -= 1;\n } else if (end <= start) {\n return driveCommand(duration, () => { });\n }\n if (end <= start) return driveCommand(duration, () => { });\n return this.editTo(source.slice(0, start) + source.slice(end), duration, easing);\n }\n\n /** Replace the code in `codeRange` with `replacement`. */\n @command({ args: [{ key: \"target\", kind: \"selector\" }, { key: \"replacement\", kind: \"text\", default: \"\", multiline: true }] })\n replace(\n args: CommandArgs<{ target: CodeRange; replacement: string }> & { duration: number },\n ): Command<Record<string, never>> {\n const { target: codeRange, replacement } = args.data as { target: CodeRange; replacement: string };\n const source = this.joinedSource();\n const { start, end } = rangeToCharOffsets(codeRange, this.lineLengths());\n return this.editTo(source.slice(0, start) + replacement + source.slice(end), args.duration, args.easing);\n }\n\n /**\n * Highlight a range of code — or several at once (e.g.\n * `CodeRanges.lines(2).word(5, 1, 3)`) — highlighted as one set: tokens\n * within any of the ranges stay at opacity 1, tokens outside dim to\n * `dim`. Persistent — call resetHighlight() to undo, or call highlight()\n * again with a different range to cross-fade.\n */\n @command({ args: [{ key: \"target\", kind: \"selector\" }, { key: \"dim\", kind: \"number\", default: 0.4, min: 0, max: 1, step: 0.01, scale: 100, unit: \"%\" }] })\n highlight(\n args: CommandArgs<{ target: CodeRange | Iterable<CodeRange>; dim?: number }> & { duration: number },\n ): Command<Record<string, never>> {\n const { target: codeRange, dim } = args.data as { target: CodeRange | Iterable<CodeRange>; dim?: number };\n const { duration, easing } = args;\n const toDim = dim ?? 0.4;\n const matchIds = this.tokenIdsInRanges(normalizeCodeRanges(codeRange));\n if (matchIds.size === 0) return driveCommand(duration, () => { });\n\n const fromDim = this.highlightDimOpacity ?? 1;\n const hadPrevious = this.highlightedIds.size > 0;\n const previousIds = this.highlightedIds;\n\n const animTokens: AnimToken[] = [];\n for (const line of this.tokenLines) {\n for (const tok of line.tokens) {\n const wasHighlighted = !hadPrevious || previousIds.has(tok.id);\n const isHighlighted = matchIds.has(tok.id);\n const fromOp = wasHighlighted ? 1 : fromDim;\n const toOp = isHighlighted ? 1 : toDim;\n if (fromOp === toOp) continue;\n animTokens.push(makeAnim(tok.id, { keys: [0, 1], values: [fromOp, toOp] }));\n }\n }\n\n // Which tokens are dimmed is state the *next* highlight reads to know\n // what it is cross-fading from, so it is committed at the end and put\n // back below it — a `finally` could only ever have run forwards.\n return this.runDim(animTokens, duration, easing, (done) => {\n this.highlightDimOpacity = done ? toDim : (hadPrevious ? fromDim : null);\n this.highlightedIds = done ? matchIds : previousIds;\n });\n }\n\n /**\n * Fade all dimmed tokens back to opacity 1 and clear the persistent\n * highlight state.\n */\n @command()\n resetHighlight(args: CommandArgs<Record<string, never>> & { duration: number }): Command<Record<string, never>> {\n const { duration, easing } = args;\n if (this.highlightDimOpacity === null) return driveCommand(duration, () => { });\n\n const fromDim = this.highlightDimOpacity;\n const previousIds = this.highlightedIds;\n\n const animTokens: AnimToken[] = [];\n for (const line of this.tokenLines) {\n for (const tok of line.tokens) {\n const fromOp = previousIds.has(tok.id) ? 1 : fromDim;\n if (fromOp === 1) continue;\n animTokens.push(makeAnim(tok.id, { keys: [0, 1], values: [fromOp, 1] }));\n }\n }\n\n return this.runDim(animTokens, duration, easing, (done) => {\n this.highlightDimOpacity = done ? null : fromDim;\n this.highlightedIds = done ? new Set() : previousIds;\n });\n }\n\n /**\n * Animate the listing to a new source.\n *\n * The engine behind every editing command, and behind `to({ code })`. Every\n * edit is expressed as the source it produces, tokenized, and then *diffed*\n * against what is on screen — so a token that survived the edit keeps its\n * identity and simply travels to its new column, and only what genuinely\n * changed is faded.\n *\n * The result runs in three phases (see `phaseStrategy`): what is leaving\n * fades out, what stays reflows, and only then does what is new arrive.\n * Playing them together is what made a replacement read as a cross-dissolve\n * of two unrelated listings rather than as an edit being made.\n */\n private editTo(next: string, duration: number, easing?: EasingFunction): Command<Record<string, never>> {\n const from = this.tokenLines;\n const fromCode = this.joinedSource();\n if (next === fromCode) return driveCommand(duration, () => { });\n\n const edit = this.diffStrategy(from, tokenizeCodeToIdLines(next, this.language, this.theme));\n\n const transition: StructuralTransition = {\n kind: \"structural\",\n from,\n to: edit.lines,\n removedIds: edit.removedIds,\n addedIds: edit.addedIds,\n enteringLineIds: edit.newLineIds,\n fromColorById: edit.fromColorById,\n phases: this.phaseStrategy(edit.removedIds.size > 0, edit.addedIds.size > 0),\n progress: 0,\n layoutKey: null,\n fromLayout: null,\n toLayout: null,\n };\n\n // A tokenize triggered by the grammar landing mid-edit would mint fresh\n // ids underneath this transition, and the transition is keyed by the ones\n // it captured — so the retry in `onRender` is gated on there being no edit\n // in flight, which means this flag has to be honest now rather than once\n // the edit settles.\n this.tokenized = canHighlight(this.language, this.theme);\n\n return driveCommand(duration, (t) => {\n const running = t > 0 && t < 1;\n const index = this.transitions.indexOf(transition);\n if (running && index < 0) this.transitions.push(transition);\n else if (!running && index >= 0) this.transitions.splice(index, 1);\n\n transition.progress = easing ? easing(t) : t;\n\n // The settle, in both directions: asked for a time before the edit\n // starts, the listing is what preceded it; at or past the end, the\n // result. A `finally` could only ever have run forwards.\n if (t <= 0) {\n this.setLines(from);\n this._writeProp(\"code\", fromCode);\n } else {\n this.setLines(edit.lines);\n this._writeProp(\"code\", next);\n }\n });\n }\n\n /**\n * Put a dim transition on the stack, drive its progress, take it off and\n * commit at the end.\n *\n * A {@link Command} rather than a generator, which is what makes a listing\n * scrubbable: membership is a function of `t` (on the stack for `0 < t < 1`,\n * off it outside), `settle(done)` replaces the `finally` and takes *which\n * way*, and `progress` is assigned from `t` rather than accumulated.\n */\n private runDim(\n tokens: AnimToken[],\n duration: number,\n easing?: EasingFunction,\n settle?: (done: boolean) => void,\n ): Command<Record<string, never>> {\n const transition = { kind: \"dim\" as const, tokens, progress: 0 };\n\n return driveCommand(duration, (t) => {\n const running = t > 0 && t < 1;\n const index = this.transitions.indexOf(transition);\n if (running && index < 0) this.transitions.push(transition);\n else if (!running && index >= 0) this.transitions.splice(index, 1);\n\n transition.progress = easing ? easing(t) : t;\n settle?.(t >= 1);\n });\n }\n\n /**\n * Route a tweened `code` through the diff engine.\n *\n * `to({ code })` is the form an author reaches for first — it is how every\n * other prop is animated — and a bare string prop would otherwise land in the\n * generic tween's discrete-snap bucket and simply cut at the end. Intercepted\n * here it becomes the same three-phase edit the named commands produce, while\n * the rest of the step's props tween alongside it untouched.\n */\n override _prepareStep(\n to: Partial<CodeProps>,\n duration: number,\n easing?: EasingFunction,\n ): TweenStepper {\n const next = to.code;\n if (typeof next !== \"string\" || next === this.joinedSource()) {\n return super._prepareStep(to, duration, easing);\n }\n\n const rest: Partial<CodeProps> = { ...to };\n delete rest.code;\n // Prepared before the edit, so a step that also moves `fontSize` has\n // snapshotted its own start value against the listing that is still on\n // screen.\n const others = super._prepareStep(rest, duration, easing);\n const edit = this.editTo(next, duration, easing)._stepper();\n\n return {\n seek: (elapsed: number) => {\n others.seek(elapsed);\n edit.seek(elapsed);\n },\n advance: (dt: number): boolean => {\n const othersDone = others.advance(dt);\n const editDone = edit.advance(dt);\n return othersDone && editDone;\n },\n };\n }\n\n // ── Source queries ──────────────────────────────────────────────────────\n\n /**\n * Find every range matching the literal string `text` in the current\n * source. Multi-line matches are supported.\n */\n findAllRanges(text: string): CodeRange[] {\n const ranges: CodeRange[] = [];\n if (!text) return ranges;\n const source = this.joinedSource();\n const lineLens = this.lineLengths();\n let from = 0;\n while (true) {\n const idx = source.indexOf(text, from);\n if (idx === -1) break;\n ranges.push(charOffsetsToRange(idx, idx + text.length, lineLens));\n from = idx + Math.max(1, text.length);\n }\n return ranges;\n }\n\n /** Find the `index`th range matching `text`. Returns null if not found. */\n findRangeAt(text: string, index: number): CodeRange | null {\n const all = this.findAllRanges(text);\n return all[index] ?? null;\n }\n\n /** Find the first range matching `text`. Returns null if not found. */\n findFirstRange(text: string): CodeRange | null {\n return this.findRangeAt(text, 0);\n }\n\n private joinedSource(): string {\n return this.tokenLines\n .map(line => line.tokens.map(t => t.content).join(''))\n .join('\\n');\n }\n\n private lineLengths(): number[] {\n return this.tokenLines.map(line =>\n line.tokens.reduce((acc, t) => acc + t.content.length, 0),\n );\n }\n\n /** Character offset of a 1-indexed (line, col), clamped into the document. */\n private offsetAt(position: [number, number]): number {\n const lens = this.lineLengths();\n if (lens.length === 0) return 0;\n const [rawLine, rawCol] = position;\n const li = Math.max(0, Math.min(lens.length - 1, rawLine - 1));\n let offset = 0;\n for (let k = 0; k < li; k++) offset += lens[k] + 1;\n return offset + Math.max(0, Math.min(lens[li], rawCol - 1));\n }\n\n /**\n * Resolve one or more CodeRanges to the set of token ids whose content\n * overlaps any of them. Tokens that partially overlap are included.\n */\n private tokenIdsInRanges(codeRanges: CodeRange[]): Set<number> {\n const result = new Set<number>();\n const lineLens = this.lineLengths();\n if (lineLens.length === 0) return result;\n const offsets = codeRanges\n .map(r => rangeToCharOffsets(r, lineLens))\n .filter(({ start, end }) => end > start);\n if (offsets.length === 0) return result;\n\n // Walk tokens with running offsets in the joined string, testing each\n // token against every requested range's offsets.\n let off = 0;\n for (let li = 0; li < this.tokenLines.length; li++) {\n const line = this.tokenLines[li];\n for (const tok of line.tokens) {\n const tStart = off;\n const tEnd = off + tok.content.length;\n if (offsets.some(({ start, end }) => tEnd > start && tStart < end)) result.add(tok.id);\n off = tEnd;\n }\n if (li < this.tokenLines.length - 1) off += 1; // newline\n }\n return result;\n }\n\n // ── Drawing ─────────────────────────────────────────────────────────────\n\n /**\n * Thin delegator: everything about *how* a frame is painted (settled or\n * mid structural-edit, entry/exit motion, colour cross-fade) lives in\n * `drawCode` (the engine's `render.ts`) as a pure function over plain\n * state — this just gathers that state from the node's own instance\n * fields and caches.\n */\n protected drawSelf(draw: RenderContext2D): void {\n this.advanceCache.sync(this.advanceCache.signature(this.fontSize, this.fontFamily));\n drawCode(draw, {\n tokenLines: this.tokenLines,\n metrics: this.metrics(),\n advanceCache: this.advanceCache,\n ...this.frameLayout(draw),\n tokenStates: resolveTokenStates(this.tokenLines, this.transitions, this.highlightDimOpacity, this.highlightedIds),\n highlightActive: this.highlightDimOpacity !== null || this.transitions.some(tr => tr.kind === \"dim\"),\n });\n }\n}\n\n/**\n * Normalize `highlight()`'s `codeRange` argument to a plain array: a single\n * `CodeRange` (a plain object, not iterable) becomes a one-element array; a\n * `CodeRangeChain`/plain array of ranges spreads as-is. `CodeRange` and\n * `CodeRangeChain` are distinguished by iterability, not `instanceof` — a\n * bare array of `CodeRange`s (no chain) works the same way.\n */\nfunction normalizeCodeRanges(codeRange: CodeRange | Iterable<CodeRange>): CodeRange[] {\n const maybeIterable = codeRange as Partial<Iterable<CodeRange>>;\n if (typeof maybeIterable[Symbol.iterator] === \"function\") {\n return [...(codeRange as Iterable<CodeRange>)];\n }\n return [codeRange as CodeRange];\n}\n\nconst grammarLoaders = new Map<string, () => Promise<void>>();\n\n// One function per language: blocks sharing a grammar declare one key, and a\n// second load function for a key already declared is ignored with a warning.\nfunction grammarLoader(language: string): () => Promise<void> {\n let load = grammarLoaders.get(language);\n if (load === undefined) {\n load = () => ensureHighlighter(undefined, [language]);\n grammarLoaders.set(language, load);\n }\n return load;\n}\n\n"]}
|
package/dist/nodes.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Code } from "./node.js";
|
|
2
|
+
/**
|
|
3
|
+
* Every node type this package publishes.
|
|
4
|
+
*
|
|
5
|
+
* A host registers these by handing the array to an engine —
|
|
6
|
+
* `new Engine(platform, { nodes: NODES })` — which reads each class's `@node()`
|
|
7
|
+
* key. The decorator only *declares* that key: nothing is registered by the mere
|
|
8
|
+
* act of importing a module, so a registry holds exactly what its owner asked
|
|
9
|
+
* for and two engines in one process can differ about it.
|
|
10
|
+
*
|
|
11
|
+
* Listing class **values** is also what survives bundling. This package declares
|
|
12
|
+
* `sideEffects: false`, which licenses a bundler to drop a module nothing
|
|
13
|
+
* imports a value from, and a document names a node type by string — so
|
|
14
|
+
* `import "./node.js"` for its side effect is exactly what gets shaken out, where an
|
|
15
|
+
* array of bindings is a data dependency that cannot be.
|
|
16
|
+
*/
|
|
17
|
+
export declare const NODES: (typeof Code)[];
|
|
18
|
+
//# sourceMappingURL=nodes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../src/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,KAAK,iBAAS,CAAC"}
|
package/dist/nodes.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Code } from "./node.js";
|
|
2
|
+
/**
|
|
3
|
+
* Every node type this package publishes.
|
|
4
|
+
*
|
|
5
|
+
* A host registers these by handing the array to an engine —
|
|
6
|
+
* `new Engine(platform, { nodes: NODES })` — which reads each class's `@node()`
|
|
7
|
+
* key. The decorator only *declares* that key: nothing is registered by the mere
|
|
8
|
+
* act of importing a module, so a registry holds exactly what its owner asked
|
|
9
|
+
* for and two engines in one process can differ about it.
|
|
10
|
+
*
|
|
11
|
+
* Listing class **values** is also what survives bundling. This package declares
|
|
12
|
+
* `sideEffects: false`, which licenses a bundler to drop a module nothing
|
|
13
|
+
* imports a value from, and a document names a node type by string — so
|
|
14
|
+
* `import "./node.js"` for its side effect is exactly what gets shaken out, where an
|
|
15
|
+
* array of bindings is a data dependency that cannot be.
|
|
16
|
+
*/
|
|
17
|
+
export const NODES = [Code];
|
|
18
|
+
//# sourceMappingURL=nodes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodes.js","sourceRoot":"","sources":["../src/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC","sourcesContent":["import { Code } from \"./node\";\n\n/**\n * Every node type this package publishes.\n *\n * A host registers these by handing the array to an engine —\n * `new Engine(platform, { nodes: NODES })` — which reads each class's `@node()`\n * key. The decorator only *declares* that key: nothing is registered by the mere\n * act of importing a module, so a registry holds exactly what its owner asked\n * for and two engines in one process can differ about it.\n *\n * Listing class **values** is also what survives bundling. This package declares\n * `sideEffects: false`, which licenses a bundler to drop a module nothing\n * imports a value from, and a document names a node type by string — so\n * `import \"./node\"` for its side effect is exactly what gets shaken out, where an\n * array of bindings is a data dependency that cannot be.\n */\nexport const NODES = [Code];\n"]}
|
package/dist/render.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { RenderContext2D } from "@motionscript/core";
|
|
2
|
+
import type { CodeLayout, CodeMetrics } from "./layout.js";
|
|
3
|
+
import type { IdLine } from "./tokens.js";
|
|
4
|
+
import type { TokenState, StructuralTransition } from "./transitions.js";
|
|
5
|
+
import type { TokenAdvanceCache } from "./measure-cache.js";
|
|
6
|
+
/** Everything a `Code` node's own instance state supplies to draw one frame. */
|
|
7
|
+
export interface DrawCodeState {
|
|
8
|
+
tokenLines: IdLine[];
|
|
9
|
+
metrics: CodeMetrics;
|
|
10
|
+
advanceCache: TokenAdvanceCache;
|
|
11
|
+
/** The one or two layouts this frame draws from — see `frameLayout` in `layout.ts`. */
|
|
12
|
+
from: CodeLayout;
|
|
13
|
+
to: CodeLayout;
|
|
14
|
+
edit: StructuralTransition | null;
|
|
15
|
+
/** Per-token opacity from `resolveTokenStates` (persistent highlight + any active dim transition). */
|
|
16
|
+
tokenStates: Map<number, TokenState>;
|
|
17
|
+
/** Whether a highlight (persistent dim, or a highlight()/resetHighlight() cross-fade) is currently engaged. */
|
|
18
|
+
highlightActive: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Draw one frame of a code listing: the settled structure, or — mid
|
|
22
|
+
* structural edit — the two structures it is interpolating between (what
|
|
23
|
+
* stays reflows, what is leaving fades out where it was, what is arriving
|
|
24
|
+
* fades/slides in where it lands). Pure over `state`; touches nothing but
|
|
25
|
+
* `draw`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function drawCode(draw: RenderContext2D, state: DrawCodeState): void;
|
|
28
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAuD,MAAM,oBAAoB,CAAC;AAC1G,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AA+CzD,gFAAgF;AAChF,MAAM,WAAW,aAAa;IAC1B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,EAAE,WAAW,CAAC;IACrB,YAAY,EAAE,iBAAiB,CAAC;IAChC,uFAAuF;IACvF,IAAI,EAAE,UAAU,CAAC;IACjB,EAAE,EAAE,UAAU,CAAC;IACf,IAAI,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAClC,sGAAsG;IACtG,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACrC,+GAA+G;IAC/G,eAAe,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,aAAa,GAAG,IAAI,CA+H1E"}
|
package/dist/render.js
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { Graphics2D, parseColor, lerpNumber } from "@motionscript/core";
|
|
2
|
+
import { windowProgress, moveProgress } from "./transitions.js";
|
|
3
|
+
/** Colour of a token the grammar had no opinion about. */
|
|
4
|
+
const DEFAULT_TOKEN_COLOR = [0.82, 0.84, 0.86, 1];
|
|
5
|
+
/** Gutter line-number colour: a muted version of the standard text colour. */
|
|
6
|
+
const LINE_NUMBER_COLOR = [0.45, 0.5, 0.55, 1];
|
|
7
|
+
// `parseColor` walks a CSS string; a listing asks for the same handful of theme
|
|
8
|
+
// colours on every token of every frame, so the parse is memoized. Module-level,
|
|
9
|
+
// because the answer depends only on the string.
|
|
10
|
+
const colorCache = new Map();
|
|
11
|
+
function tokenColor(css) {
|
|
12
|
+
if (!css)
|
|
13
|
+
return DEFAULT_TOKEN_COLOR;
|
|
14
|
+
let hit = colorCache.get(css);
|
|
15
|
+
if (!hit) {
|
|
16
|
+
hit = parseColor(css);
|
|
17
|
+
colorCache.set(css, hit);
|
|
18
|
+
}
|
|
19
|
+
return hit;
|
|
20
|
+
}
|
|
21
|
+
function lerpColor(from, to, t) {
|
|
22
|
+
if (t <= 0)
|
|
23
|
+
return from;
|
|
24
|
+
if (t >= 1)
|
|
25
|
+
return to;
|
|
26
|
+
return [
|
|
27
|
+
from[0] + (to[0] - from[0]) * t,
|
|
28
|
+
from[1] + (to[1] - from[1]) * t,
|
|
29
|
+
from[2] + (to[2] - from[2]) * t,
|
|
30
|
+
from[3] + (to[3] - from[3]) * t,
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
// Opacity multiplier for a line's number under the active highlight. The
|
|
34
|
+
// number stays bright only when the WHOLE line is highlighted, so we take the
|
|
35
|
+
// min token opacity on the line. Returns 1 (no dimming) when no highlight is
|
|
36
|
+
// active, so an edit's entries don't drag the number down.
|
|
37
|
+
function lineHighlightOpacity(line, stateById, highlightActive) {
|
|
38
|
+
if (!highlightActive)
|
|
39
|
+
return 1;
|
|
40
|
+
let min = 1;
|
|
41
|
+
for (const tok of line.tokens) {
|
|
42
|
+
if (tok.content.length === 0)
|
|
43
|
+
continue;
|
|
44
|
+
const op = stateById.get(tok.id)?.opacity ?? 1;
|
|
45
|
+
if (op < min)
|
|
46
|
+
min = op;
|
|
47
|
+
}
|
|
48
|
+
return min;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Draw one frame of a code listing: the settled structure, or — mid
|
|
52
|
+
* structural edit — the two structures it is interpolating between (what
|
|
53
|
+
* stays reflows, what is leaving fades out where it was, what is arriving
|
|
54
|
+
* fades/slides in where it lands). Pure over `state`; touches nothing but
|
|
55
|
+
* `draw`.
|
|
56
|
+
*/
|
|
57
|
+
export function drawCode(draw, state) {
|
|
58
|
+
const { tokenLines, metrics, advanceCache, from, to, edit, tokenStates: dim } = state;
|
|
59
|
+
const progress = edit ? edit.progress : 1;
|
|
60
|
+
const pOut = edit ? windowProgress(edit.phases.out, progress) : 1;
|
|
61
|
+
const pMove = moveProgress(edit);
|
|
62
|
+
const pIn = edit ? windowProgress(edit.phases.in, progress) : 1;
|
|
63
|
+
const blockW = edit ? lerpNumber(from.blockW, to.blockW, pMove) : to.blockW;
|
|
64
|
+
const gutter = edit ? lerpNumber(from.gutter, to.gutter, pMove) : to.gutter;
|
|
65
|
+
const gutterGap = to.gutterGap || from.gutterGap;
|
|
66
|
+
// Right edge of the line-number column: one gap to the left of where the
|
|
67
|
+
// code text begins.
|
|
68
|
+
const numberRight = -blockW / 2 + metrics.padding.left + gutter - gutterGap;
|
|
69
|
+
const drawNumber = (label, y, opacity) => {
|
|
70
|
+
if (opacity <= 0)
|
|
71
|
+
return;
|
|
72
|
+
const labelW = advanceCache.advance(draw, label, metrics.fontSize, metrics.fontFamily, 0);
|
|
73
|
+
draw.draw(new Graphics2D()
|
|
74
|
+
.text({
|
|
75
|
+
text: label,
|
|
76
|
+
fontSize: metrics.fontSize,
|
|
77
|
+
fontFamily: metrics.fontFamily,
|
|
78
|
+
lineHeight: metrics.lineHeight,
|
|
79
|
+
x: numberRight - labelW / 2,
|
|
80
|
+
y,
|
|
81
|
+
textAlign: 'left',
|
|
82
|
+
})
|
|
83
|
+
.fill([{ type: "solid", color: LINE_NUMBER_COLOR, opacity }]));
|
|
84
|
+
};
|
|
85
|
+
const drawToken = (text, x, y, color, opacity) => {
|
|
86
|
+
if (opacity <= 0 || text.length === 0)
|
|
87
|
+
return;
|
|
88
|
+
const width = advanceCache.advance(draw, text, metrics.fontSize, metrics.fontFamily, metrics.letterSpacing);
|
|
89
|
+
draw.draw(new Graphics2D()
|
|
90
|
+
.text({
|
|
91
|
+
text,
|
|
92
|
+
fontSize: metrics.fontSize,
|
|
93
|
+
fontFamily: metrics.fontFamily,
|
|
94
|
+
lineHeight: metrics.lineHeight,
|
|
95
|
+
letterSpacing: metrics.letterSpacing,
|
|
96
|
+
// The renderer centres a single-token block on the (x, y) it is
|
|
97
|
+
// given, so every token is anchored at the centre of its cell
|
|
98
|
+
// rather than at its left edge. Passing lineHeight makes the
|
|
99
|
+
// block's height deterministic (fontSize × lineHeight) rather
|
|
100
|
+
// than the font's natural metrics, so the vertical centre
|
|
101
|
+
// lands exactly on the slot centre.
|
|
102
|
+
x: x + width / 2,
|
|
103
|
+
y,
|
|
104
|
+
textAlign: 'left',
|
|
105
|
+
})
|
|
106
|
+
.fill([{ type: "solid", color, opacity }]));
|
|
107
|
+
};
|
|
108
|
+
// What survived the edit, and what it brought with it — drawn from the
|
|
109
|
+
// structure the edit lands on.
|
|
110
|
+
for (let i = 0; i < tokenLines.length; i++) {
|
|
111
|
+
const line = tokenLines[i];
|
|
112
|
+
const toIndex = to.lineIndex.get(line.id);
|
|
113
|
+
if (toIndex === undefined)
|
|
114
|
+
continue;
|
|
115
|
+
const toY = to.lineY[toIndex];
|
|
116
|
+
const entering = edit?.enteringLineIds.has(line.id) ?? false;
|
|
117
|
+
let rowY = toY;
|
|
118
|
+
let rowAlpha = 1;
|
|
119
|
+
if (edit && entering) {
|
|
120
|
+
// A wholly new row fades as one piece, in the place it lands — the
|
|
121
|
+
// line arrives, it does not travel to get there, and it is not a
|
|
122
|
+
// spray of glyphs each finding its own way in. See
|
|
123
|
+
// `StructuralTransition.enteringLineIds`.
|
|
124
|
+
rowAlpha = pIn;
|
|
125
|
+
}
|
|
126
|
+
else if (edit) {
|
|
127
|
+
const fromIndex = from.lineIndex.get(line.id);
|
|
128
|
+
if (fromIndex !== undefined)
|
|
129
|
+
rowY = lerpNumber(from.lineY[fromIndex], toY, pMove);
|
|
130
|
+
}
|
|
131
|
+
for (const token of line.tokens) {
|
|
132
|
+
const box = to.tokens.get(token.id);
|
|
133
|
+
if (!box)
|
|
134
|
+
continue;
|
|
135
|
+
let x = box.x;
|
|
136
|
+
let alpha = rowAlpha;
|
|
137
|
+
let color = tokenColor(token.color);
|
|
138
|
+
if (edit && !entering) {
|
|
139
|
+
if (edit.addedIds.has(token.id)) {
|
|
140
|
+
// Spliced into a row that already existed: the reflow
|
|
141
|
+
// already opened the space, so this only has to appear.
|
|
142
|
+
alpha = pIn;
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
const was = from.tokens.get(token.id);
|
|
146
|
+
if (was)
|
|
147
|
+
x = lerpNumber(was.x, box.x, pMove);
|
|
148
|
+
if (edit.fromColorById.has(token.id)) {
|
|
149
|
+
color = lerpColor(tokenColor(edit.fromColorById.get(token.id)), color, pMove);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
drawToken(token.content, x, rowY, color, alpha * (dim.get(token.id)?.opacity ?? 1));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
// What the edit takes away, drawn from the structure it is leaving — it
|
|
157
|
+
// has no place in the new one, which is the whole reason it is fading.
|
|
158
|
+
if (edit && pOut < 1) {
|
|
159
|
+
for (let i = 0; i < edit.from.length; i++) {
|
|
160
|
+
const line = edit.from[i];
|
|
161
|
+
const fromIndex = from.lineIndex.get(line.id);
|
|
162
|
+
if (fromIndex === undefined)
|
|
163
|
+
continue;
|
|
164
|
+
const toIndex = to.lineIndex.get(line.id);
|
|
165
|
+
// A row that survived the edit is still moving, so its outgoing
|
|
166
|
+
// tokens travel with it; a deleted row stays where it was and
|
|
167
|
+
// dissolves while the rows below close over it.
|
|
168
|
+
const y = toIndex === undefined
|
|
169
|
+
? from.lineY[fromIndex]
|
|
170
|
+
: lerpNumber(from.lineY[fromIndex], to.lineY[toIndex], pMove);
|
|
171
|
+
for (const token of line.tokens) {
|
|
172
|
+
if (!edit.removedIds.has(token.id))
|
|
173
|
+
continue;
|
|
174
|
+
const box = from.tokens.get(token.id);
|
|
175
|
+
if (!box)
|
|
176
|
+
continue;
|
|
177
|
+
drawToken(token.content, box.x, y, tokenColor(token.color), 1 - pOut);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (metrics.showLineNumbers)
|
|
182
|
+
drawLineNumbers(state, drawNumber, pMove, pIn, pOut);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Draw the gutter — one number per *slot*, not one per row.
|
|
186
|
+
*
|
|
187
|
+
* That distinction is the whole of it. A line number is an ordinal of the
|
|
188
|
+
* block: "3" means the third line, and it is there for exactly as long as the
|
|
189
|
+
* listing has a third line. Drawing it alongside the row it labels — the
|
|
190
|
+
* obvious thing, since that is where it appears — tied it to the row's identity
|
|
191
|
+
* instead, so a line rewritten past the point the diff could pair it took its
|
|
192
|
+
* number down with it and brought an identical one back up. The number blinked
|
|
193
|
+
* although it had never gone away, and every substantially rewritten line did
|
|
194
|
+
* it at once.
|
|
195
|
+
*
|
|
196
|
+
* Numbering the slots means only the numbers at the end move at all: those the
|
|
197
|
+
* block grew to reach fade in, those it shrank past fade out, and every number
|
|
198
|
+
* both structures have simply travels to its new row height. Which is also the
|
|
199
|
+
* honest reading of the edit — inserting a line in the middle does not make a
|
|
200
|
+
* new number appear there, it makes the block one line longer.
|
|
201
|
+
*/
|
|
202
|
+
function drawLineNumbers(state, drawNumber, pMove, pIn, pOut) {
|
|
203
|
+
const { tokenLines, from, to, edit, tokenStates: dim, highlightActive } = state;
|
|
204
|
+
const toCount = tokenLines.length;
|
|
205
|
+
const fromCount = edit ? edit.from.length : toCount;
|
|
206
|
+
for (let i = 0; i < Math.max(fromCount, toCount); i++) {
|
|
207
|
+
const inFrom = i < fromCount;
|
|
208
|
+
const inTo = i < toCount;
|
|
209
|
+
// Highlight dimming follows whatever content occupies the slot, which
|
|
210
|
+
// is the new listing wherever there is one.
|
|
211
|
+
const line = inTo ? tokenLines[i] : edit?.from[i];
|
|
212
|
+
const dimming = line ? lineHighlightOpacity(line, dim, highlightActive) : 1;
|
|
213
|
+
if (!edit)
|
|
214
|
+
drawNumber(String(i + 1), to.lineY[i], dimming);
|
|
215
|
+
else if (inFrom && inTo)
|
|
216
|
+
drawNumber(String(i + 1), lerpNumber(from.lineY[i], to.lineY[i], pMove), dimming);
|
|
217
|
+
else if (inTo)
|
|
218
|
+
drawNumber(String(i + 1), to.lineY[i], pIn * dimming);
|
|
219
|
+
else
|
|
220
|
+
drawNumber(String(i + 1), from.lineY[i], (1 - pOut) * dimming);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,UAAU,EAAmB,UAAU,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAG1G,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAI7D,0DAA0D;AAC1D,MAAM,mBAAmB,GAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACnE,8EAA8E;AAC9E,MAAM,iBAAiB,GAAoB,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAEhE,gFAAgF;AAChF,iFAAiF;AACjF,iDAAiD;AACjD,MAAM,UAAU,GAAG,IAAI,GAAG,EAA2B,CAAC;AACtD,SAAS,UAAU,CAAC,GAAuB;IACvC,IAAI,CAAC,GAAG;QAAE,OAAO,mBAAmB,CAAC;IACrC,IAAI,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAI,CAAC,GAAG,EAAE,CAAC;QACP,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;QACtB,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC7B,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC;AAED,SAAS,SAAS,CAAC,IAAqB,EAAE,EAAmB,EAAE,CAAS;IACpE,IAAI,CAAC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KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC;aACtG,IAAI,IAAI;YAAE,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,CAAC;;YAChE,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC;IACxE,CAAC;AACL,CAAC","sourcesContent":["import { RenderContext2D, Graphics2D, NormalizedColor, parseColor, lerpNumber } from \"@motionscript/core\";\nimport type { CodeLayout, CodeMetrics } from \"./layout\";\nimport type { IdLine } from \"./tokens\";\nimport { windowProgress, moveProgress } from \"./transitions\";\nimport type { TokenState, StructuralTransition } from \"./transitions\";\nimport type { TokenAdvanceCache } from \"./measure-cache\";\n\n/** Colour of a token the grammar had no opinion about. */\nconst DEFAULT_TOKEN_COLOR: NormalizedColor = [0.82, 0.84, 0.86, 1];\n/** Gutter line-number colour: a muted version of the standard text colour. */\nconst LINE_NUMBER_COLOR: NormalizedColor = [0.45, 0.5, 0.55, 1];\n\n// `parseColor` walks a CSS string; a listing asks for the same handful of theme\n// colours on every token of every frame, so the parse is memoized. Module-level,\n// because the answer depends only on the string.\nconst colorCache = new Map<string, NormalizedColor>();\nfunction tokenColor(css: string | undefined): NormalizedColor {\n if (!css) return DEFAULT_TOKEN_COLOR;\n let hit = colorCache.get(css);\n if (!hit) {\n hit = parseColor(css);\n colorCache.set(css, hit);\n }\n return hit;\n}\n\nfunction lerpColor(from: NormalizedColor, to: NormalizedColor, t: number): NormalizedColor {\n if (t <= 0) return from;\n if (t >= 1) return to;\n return [\n from[0] + (to[0] - from[0]) * t,\n from[1] + (to[1] - from[1]) * t,\n from[2] + (to[2] - from[2]) * t,\n from[3] + (to[3] - from[3]) * t,\n ];\n}\n\n// Opacity multiplier for a line's number under the active highlight. The\n// number stays bright only when the WHOLE line is highlighted, so we take the\n// min token opacity on the line. Returns 1 (no dimming) when no highlight is\n// active, so an edit's entries don't drag the number down.\nfunction lineHighlightOpacity(line: IdLine, stateById: Map<number, TokenState>, highlightActive: boolean): number {\n if (!highlightActive) return 1;\n let min = 1;\n for (const tok of line.tokens) {\n if (tok.content.length === 0) continue;\n const op = stateById.get(tok.id)?.opacity ?? 1;\n if (op < min) min = op;\n }\n return min;\n}\n\n/** Everything a `Code` node's own instance state supplies to draw one frame. */\nexport interface DrawCodeState {\n tokenLines: IdLine[];\n metrics: CodeMetrics;\n advanceCache: TokenAdvanceCache;\n /** The one or two layouts this frame draws from — see `frameLayout` in `layout.ts`. */\n from: CodeLayout;\n to: CodeLayout;\n edit: StructuralTransition | null;\n /** Per-token opacity from `resolveTokenStates` (persistent highlight + any active dim transition). */\n tokenStates: Map<number, TokenState>;\n /** Whether a highlight (persistent dim, or a highlight()/resetHighlight() cross-fade) is currently engaged. */\n highlightActive: boolean;\n}\n\n/**\n * Draw one frame of a code listing: the settled structure, or — mid\n * structural edit — the two structures it is interpolating between (what\n * stays reflows, what is leaving fades out where it was, what is arriving\n * fades/slides in where it lands). Pure over `state`; touches nothing but\n * `draw`.\n */\nexport function drawCode(draw: RenderContext2D, state: DrawCodeState): void {\n const { tokenLines, metrics, advanceCache, from, to, edit, tokenStates: dim } = state;\n\n const progress = edit ? edit.progress : 1;\n const pOut = edit ? windowProgress(edit.phases.out, progress) : 1;\n const pMove = moveProgress(edit);\n const pIn = edit ? windowProgress(edit.phases.in, progress) : 1;\n\n const blockW = edit ? lerpNumber(from.blockW, to.blockW, pMove) : to.blockW;\n const gutter = edit ? lerpNumber(from.gutter, to.gutter, pMove) : to.gutter;\n const gutterGap = to.gutterGap || from.gutterGap;\n // Right edge of the line-number column: one gap to the left of where the\n // code text begins.\n const numberRight = -blockW / 2 + metrics.padding.left + gutter - gutterGap;\n\n const drawNumber = (label: string, y: number, opacity: number): void => {\n if (opacity <= 0) return;\n const labelW = advanceCache.advance(draw, label, metrics.fontSize, metrics.fontFamily, 0);\n draw.draw(new Graphics2D()\n .text({\n text: label,\n fontSize: metrics.fontSize,\n fontFamily: metrics.fontFamily,\n lineHeight: metrics.lineHeight,\n x: numberRight - labelW / 2,\n y,\n textAlign: 'left',\n })\n .fill([{ type: \"solid\", color: LINE_NUMBER_COLOR, opacity }]));\n };\n\n const drawToken = (text: string, x: number, y: number, color: NormalizedColor, opacity: number): void => {\n if (opacity <= 0 || text.length === 0) return;\n const width = advanceCache.advance(draw, text, metrics.fontSize, metrics.fontFamily, metrics.letterSpacing);\n draw.draw(new Graphics2D()\n .text({\n text,\n fontSize: metrics.fontSize,\n fontFamily: metrics.fontFamily,\n lineHeight: metrics.lineHeight,\n letterSpacing: metrics.letterSpacing,\n // The renderer centres a single-token block on the (x, y) it is\n // given, so every token is anchored at the centre of its cell\n // rather than at its left edge. Passing lineHeight makes the\n // block's height deterministic (fontSize × lineHeight) rather\n // than the font's natural metrics, so the vertical centre\n // lands exactly on the slot centre.\n x: x + width / 2,\n y,\n textAlign: 'left',\n })\n .fill([{ type: \"solid\", color, opacity }]));\n };\n\n // What survived the edit, and what it brought with it — drawn from the\n // structure the edit lands on.\n for (let i = 0; i < tokenLines.length; i++) {\n const line = tokenLines[i];\n const toIndex = to.lineIndex.get(line.id);\n if (toIndex === undefined) continue;\n const toY = to.lineY[toIndex];\n\n const entering = edit?.enteringLineIds.has(line.id) ?? false;\n let rowY = toY;\n let rowAlpha = 1;\n if (edit && entering) {\n // A wholly new row fades as one piece, in the place it lands — the\n // line arrives, it does not travel to get there, and it is not a\n // spray of glyphs each finding its own way in. See\n // `StructuralTransition.enteringLineIds`.\n rowAlpha = pIn;\n } else if (edit) {\n const fromIndex = from.lineIndex.get(line.id);\n if (fromIndex !== undefined) rowY = lerpNumber(from.lineY[fromIndex], toY, pMove);\n }\n\n for (const token of line.tokens) {\n const box = to.tokens.get(token.id);\n if (!box) continue;\n\n let x = box.x;\n let alpha = rowAlpha;\n let color = tokenColor(token.color);\n\n if (edit && !entering) {\n if (edit.addedIds.has(token.id)) {\n // Spliced into a row that already existed: the reflow\n // already opened the space, so this only has to appear.\n alpha = pIn;\n } else {\n const was = from.tokens.get(token.id);\n if (was) x = lerpNumber(was.x, box.x, pMove);\n if (edit.fromColorById.has(token.id)) {\n color = lerpColor(tokenColor(edit.fromColorById.get(token.id)), color, pMove);\n }\n }\n }\n\n drawToken(token.content, x, rowY, color, alpha * (dim.get(token.id)?.opacity ?? 1));\n }\n }\n\n // What the edit takes away, drawn from the structure it is leaving — it\n // has no place in the new one, which is the whole reason it is fading.\n if (edit && pOut < 1) {\n for (let i = 0; i < edit.from.length; i++) {\n const line = edit.from[i];\n const fromIndex = from.lineIndex.get(line.id);\n if (fromIndex === undefined) continue;\n const toIndex = to.lineIndex.get(line.id);\n // A row that survived the edit is still moving, so its outgoing\n // tokens travel with it; a deleted row stays where it was and\n // dissolves while the rows below close over it.\n const y = toIndex === undefined\n ? from.lineY[fromIndex]\n : lerpNumber(from.lineY[fromIndex], to.lineY[toIndex], pMove);\n\n for (const token of line.tokens) {\n if (!edit.removedIds.has(token.id)) continue;\n const box = from.tokens.get(token.id);\n if (!box) continue;\n drawToken(token.content, box.x, y, tokenColor(token.color), 1 - pOut);\n }\n }\n }\n\n if (metrics.showLineNumbers) drawLineNumbers(state, drawNumber, pMove, pIn, pOut);\n}\n\n/**\n * Draw the gutter — one number per *slot*, not one per row.\n *\n * That distinction is the whole of it. A line number is an ordinal of the\n * block: \"3\" means the third line, and it is there for exactly as long as the\n * listing has a third line. Drawing it alongside the row it labels — the\n * obvious thing, since that is where it appears — tied it to the row's identity\n * instead, so a line rewritten past the point the diff could pair it took its\n * number down with it and brought an identical one back up. The number blinked\n * although it had never gone away, and every substantially rewritten line did\n * it at once.\n *\n * Numbering the slots means only the numbers at the end move at all: those the\n * block grew to reach fade in, those it shrank past fade out, and every number\n * both structures have simply travels to its new row height. Which is also the\n * honest reading of the edit — inserting a line in the middle does not make a\n * new number appear there, it makes the block one line longer.\n */\nfunction drawLineNumbers(\n state: DrawCodeState,\n drawNumber: (label: string, y: number, opacity: number) => void,\n pMove: number,\n pIn: number,\n pOut: number,\n): void {\n const { tokenLines, from, to, edit, tokenStates: dim, highlightActive } = state;\n\n const toCount = tokenLines.length;\n const fromCount = edit ? edit.from.length : toCount;\n\n for (let i = 0; i < Math.max(fromCount, toCount); i++) {\n const inFrom = i < fromCount;\n const inTo = i < toCount;\n // Highlight dimming follows whatever content occupies the slot, which\n // is the new listing wherever there is one.\n const line = inTo ? tokenLines[i] : edit?.from[i];\n const dimming = line ? lineHighlightOpacity(line, dim, highlightActive) : 1;\n\n if (!edit) drawNumber(String(i + 1), to.lineY[i], dimming);\n else if (inFrom && inTo) drawNumber(String(i + 1), lerpNumber(from.lineY[i], to.lineY[i], pMove), dimming);\n else if (inTo) drawNumber(String(i + 1), to.lineY[i], pIn * dimming);\n else drawNumber(String(i + 1), from.lineY[i], (1 - pOut) * dimming);\n }\n}\n"]}
|
package/dist/style.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Highlighter, Tag } from "@lezer/highlight";
|
|
2
|
+
/**
|
|
3
|
+
* A single style rule: map one or more Lezer highlight {@link Tag}s to a color.
|
|
4
|
+
* This mirrors a `@codemirror/language` HighlightStyle entry, but instead of
|
|
5
|
+
* emitting CSS class names it carries the color directly — we render to a canvas,
|
|
6
|
+
* not the DOM, so there is no stylesheet to resolve against.
|
|
7
|
+
*/
|
|
8
|
+
export interface CodeStyleRule {
|
|
9
|
+
tag: Tag | readonly Tag[];
|
|
10
|
+
color: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A code theme: an ordered list of tag→color rules plus a fallback color for any
|
|
14
|
+
* text the parser produces no highlight tag for (operators, punctuation, plain
|
|
15
|
+
* identifiers in some grammars, etc.). Pass a custom one via the Code node's
|
|
16
|
+
* `theme` prop to recolor highlighting without touching the highlighter wiring.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* Later rules win when several match the same tag, matching how
|
|
20
|
+
* `@lezer/highlight`'s {@link tagHighlighter} resolves precedence.
|
|
21
|
+
*/
|
|
22
|
+
export interface CodeHighlightStyle {
|
|
23
|
+
/** Stable name, used as the highlighter cache key. */
|
|
24
|
+
name: string;
|
|
25
|
+
/** Color applied to text with no matching tag. */
|
|
26
|
+
defaultColor: string;
|
|
27
|
+
rules: CodeStyleRule[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Motion Canvas's default highlight palette (a Nord-derived theme), ported from
|
|
31
|
+
* `@motion-canvas/2d`'s DefaultHighlightStyle so highlighting matches Motion
|
|
32
|
+
* Canvas token-for-token. Colors and tag groupings are kept identical; only the
|
|
33
|
+
* shape changes (color strings in place of CSS rules).
|
|
34
|
+
*/
|
|
35
|
+
export declare const DefaultHighlightStyle: CodeHighlightStyle;
|
|
36
|
+
/**
|
|
37
|
+
* GitHub Dark highlight palette, adapted from `@uiw/codemirror-theme-github`.
|
|
38
|
+
* `defaultColor` is GitHub's editor foreground (`#c9d1d9`), used for any text the
|
|
39
|
+
* parser tags don't cover. DOM-only style props (backgroundColor, textDecoration,
|
|
40
|
+
* fontWeight, fontStyle) are dropped — we only color tokens on the canvas.
|
|
41
|
+
*/
|
|
42
|
+
export declare const GithubDarkStyle: CodeHighlightStyle;
|
|
43
|
+
/**
|
|
44
|
+
* GitHub Light highlight palette, adapted from `@uiw/codemirror-theme-github`.
|
|
45
|
+
* `defaultColor` is GitHub's editor foreground (`#24292e`). See {@link GithubDarkStyle}
|
|
46
|
+
* for the note on dropped DOM-only style props.
|
|
47
|
+
*/
|
|
48
|
+
export declare const GithubLightStyle: CodeHighlightStyle;
|
|
49
|
+
/**
|
|
50
|
+
* VS Code Dark+ highlight palette, adapted from the `@uiw/codemirror-theme-vscode`
|
|
51
|
+
* snippet. `defaultColor` is VS Code's editor foreground (`#9cdcfe`). DOM-only
|
|
52
|
+
* style props are dropped; later rules win, matching {@link tagHighlighter}.
|
|
53
|
+
*/
|
|
54
|
+
export declare const VscodeDarkStyle: CodeHighlightStyle;
|
|
55
|
+
/**
|
|
56
|
+
* VS Code Light+ highlight palette, adapted from the `@uiw/codemirror-theme-vscode`
|
|
57
|
+
* snippet. `defaultColor` is VS Code's editor foreground (`#383a42`). See
|
|
58
|
+
* {@link VscodeDarkStyle} for the note on dropped DOM-only style props.
|
|
59
|
+
*/
|
|
60
|
+
export declare const VscodeLightStyle: CodeHighlightStyle;
|
|
61
|
+
/**
|
|
62
|
+
* The built-in themes, keyed by their string name. {@link CodeThemeName} is the
|
|
63
|
+
* union of these keys — pass one of those strings (or any {@link CodeHighlightStyle}
|
|
64
|
+
* object) to a Code node's `theme` prop.
|
|
65
|
+
*/
|
|
66
|
+
export declare const BUILTIN_THEMES: {
|
|
67
|
+
"motion-canvas-default": CodeHighlightStyle;
|
|
68
|
+
"github-dark": CodeHighlightStyle;
|
|
69
|
+
"github-light": CodeHighlightStyle;
|
|
70
|
+
"vscode-dark": CodeHighlightStyle;
|
|
71
|
+
"vscode-light": CodeHighlightStyle;
|
|
72
|
+
};
|
|
73
|
+
/** Names of the built-in themes, e.g. `'github-dark' | 'github-light'`. */
|
|
74
|
+
export type CodeThemeName = keyof typeof BUILTIN_THEMES;
|
|
75
|
+
/**
|
|
76
|
+
* What a Code node's `theme` prop accepts: a built-in theme name (with
|
|
77
|
+
* autocomplete), any other registered theme name, or a {@link CodeHighlightStyle}
|
|
78
|
+
* object passed inline. The `string & {}` keeps the literal-name suggestions while
|
|
79
|
+
* still allowing arbitrary registered names.
|
|
80
|
+
*/
|
|
81
|
+
export type CodeTheme = CodeThemeName | (string & {}) | CodeHighlightStyle;
|
|
82
|
+
/**
|
|
83
|
+
* Compile a {@link CodeHighlightStyle} into a `@lezer/highlight` {@link Highlighter}
|
|
84
|
+
* whose "class" output is the literal color string for each tag. Cached by style
|
|
85
|
+
* name so repeated lookups (every tokenize) don't rebuild the matcher.
|
|
86
|
+
*/
|
|
87
|
+
export declare function compileStyle(style: CodeHighlightStyle): Highlighter;
|
|
88
|
+
//# sourceMappingURL=style.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../src/style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,GAAG,EAA6B,MAAM,kBAAkB,CAAC;AAE/E;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC1B,GAAG,EAAE,GAAG,GAAG,SAAS,GAAG,EAAE,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,kBAAkB;IAC/B,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,aAAa,EAAE,CAAC;CAC1B;AAED;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,kBAwCnC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,EAAE,kBAiB7B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,kBAkB9B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,kBAgC7B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,kBAgC9B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc;;;;;;CAQmB,CAAC;AAE/C,2EAA2E;AAC3E,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,cAAc,CAAC;AAExD;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,GAAG,kBAAkB,CAAC;AAM3E;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,kBAAkB,GAAG,WAAW,CAQnE"}
|