@singapore-editor/file-animation 0.2.13 → 0.2.15
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/dist/file-edit-animation.js.map +1 -1
- package/dist/file-transition.js.map +1 -1
- package/dist/measure.js.map +1 -1
- package/dist/morph-frame.js.map +1 -1
- package/dist/morph-match.js.map +1 -1
- package/dist/morph-run.js.map +1 -1
- package/dist/motion.js.map +1 -1
- package/dist/noise.js.map +1 -1
- package/dist/piece-span.js.map +1 -1
- package/dist/reveal-run.js.map +1 -1
- package/dist/row-cover.js.map +1 -1
- package/dist/row-moves.js.map +1 -1
- package/dist/transition-options.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-edit-animation.js","names":[],"sources":["../src/file-edit-animation.ts"],"sourcesContent":["import type {\n EditorContributionChange,\n EditorPlugin,\n EditorViewContribution,\n EditorViewContributionContext,\n EditorViewContributionUpdateKind,\n EditorViewSnapshot,\n} from '@singapore-editor/core/extensions'\nimport { EditorTokenStore } from '@singapore-editor/core/syntax'\nimport { TextMeasurer, canvasFont, renderedTabColumns } from './measure'\nimport { buildFrame, frameMoved, recolorFrame, type MorphFrame, type PaintRow } from './morph-frame'\nimport { matchPieces } from './morph-match'\nimport { MorphRun, restingPieces, springEasing, type MorphTiming } from './morph-run'\nimport { RowCover } from './row-cover'\nimport { RowMoves, rowMoves } from './row-moves'\nimport { drawableRows, reducedMotion, supportsLinearEasing, type TextOffsetRange } from './motion'\nimport './style.css'\n\nexport type FileEditAnimationPluginOptions = {\n /** Length of one morph in milliseconds. Defaults to `520`. */\n readonly durationMs?: number\n /** Spring overshoot of moving text, from `0` (none) to `0.5`. Defaults to `0.18`. */\n readonly bounce?: number\n /** Safety cap on pieces drawn; a larger viewport skips the morph. Defaults to `2500`. */\n readonly maxPieces?: number\n}\n\nconst ACTIVE_CLASS = 'editor-morph-active'\n\nconst TEXT_CHANGES = new Set(['edit', 'undo', 'redo', 'checkout', 'reconcile'])\n\n/**\n * Text changes animate from the old text to the new: text that survives the\n * change slides to its new place, removed text fades out, and new text streams\n * in. Every change morphs except keyboard text input, so typing stays instant.\n * Including this plugin turns the effect on.\n */\nexport function createFileEditAnimationPlugin(\n options: FileEditAnimationPluginOptions = {},\n): EditorPlugin {\n const resolved = {\n durationMs: positive(options.durationMs, 520),\n bounce: Math.min(0.5, Math.max(0, options.bounce ?? 0.18)),\n maxPieces: positive(options.maxPieces, 2500),\n }\n return {\n name: 'editor.fileEditAnimation',\n activate: (context) =>\n context.registerViewContribution({\n createContribution: (viewContext) =>\n new FileEditAnimationViewContribution(viewContext, resolved),\n }),\n }\n}\n\ntype ResolvedEditAnimationOptions = {\n readonly durationMs: number\n readonly bounce: number\n readonly maxPieces: number\n}\n\ntype EditFrame = Pick<EditorViewSnapshot, 'documentId' | 'textVersion' | 'tokens'> & {\n readonly visibleRows: readonly PaintRow[]\n}\n\nfunction editFrame(snapshot: EditorViewSnapshot): EditFrame | null {\n const visibleRows: PaintRow[] = []\n for (const row of snapshot.visibleRows) {\n const text = row.text\n // A horizontally windowed row cannot be replayed as a whole line.\n if (typeof text !== 'string') return null\n visibleRows.push({\n index: row.index,\n kind: row.kind,\n startOffset: row.startOffset,\n endOffset: row.endOffset,\n text,\n top: row.top,\n height: row.height,\n leftSpacerWidth: row.leftSpacerWidth,\n mountedPaintSupport: row.mountedPaintSupport,\n chunks: row.chunks.map((chunk) => ({\n text:\n typeof chunk.text === 'string'\n ? chunk.text\n : text.slice(chunk.rowLocalStart, chunk.rowLocalEnd),\n mountedPaint: chunk.mountedPaint,\n })),\n })\n }\n return {\n documentId: snapshot.documentId,\n textVersion: snapshot.textVersion,\n visibleRows,\n tokens: mountedTokens(snapshot.tokens, visibleRows),\n }\n}\n\nfunction addRowTokens(indices: Set<number>, tokens: EditorTokenStore, row: PaintRow): void {\n if (row.endOffset <= row.startOffset) return\n const end = tokens.firstStartingAtOrAfter(row.endOffset)\n for (let index = tokens.firstEndingAfter(row.startOffset, end); index < end; index++) {\n if (tokens.endAt(index) > row.startOffset) indices.add(index)\n }\n}\n\nfunction mountedTokens(tokens: EditorTokenStore, rows: readonly PaintRow[]): EditorTokenStore {\n const indices = new Set<number>()\n for (const row of rows) addRowTokens(indices, tokens, row)\n const selected = Array.from(indices)\n selected.sort((first, second) => first - second)\n return EditorTokenStore.fromTokens(\n selected.map((index) => {\n const { color, fontStyle, fontWeight } = tokens.styleAt(index)\n return {\n start: tokens.startAt(index),\n end: tokens.endAt(index),\n style: { color, fontStyle, fontWeight },\n }\n }),\n )\n}\n\nfunction mountedReplacements(\n ranges: readonly TextOffsetRange[],\n rows: readonly PaintRow[],\n): readonly TextOffsetRange[] {\n return ranges\n .filter((range) =>\n rows.some((row) => range.start < row.endOffset && range.end > row.startOffset),\n )\n .map(({ start, end }) => ({ start, end }))\n}\n\nclass FileEditAnimationViewContribution implements EditorViewContribution {\n public readonly inputs = ['content', 'tokens', 'viewport', 'layout', 'selection'] as const\n private latest: EditFrame | null = null\n /** Mounted paint before `latest`'s text, without its complete document source. */\n private before: EditFrame | null = null\n /** Text painted as something other than its source (chips, hidden markup), for each snapshot. */\n private latestReplaced: readonly TextOffsetRange[] = []\n private beforeReplaced: readonly TextOffsetRange[] = []\n private moves: RowMoves | null = null\n private measurer: TextMeasurer | null = null\n private run: MorphRun | null = null\n /** The snapshot the running morph settles on, and the rows its overlay covers. */\n private runSnapshot: EditorViewSnapshot | null = null\n private runRows: ReadonlySet<number> = new Set()\n private readonly cover: RowCover\n private timing: MorphTiming | null = null\n\n public constructor(\n private readonly context: EditorViewContributionContext,\n private readonly options: ResolvedEditAnimationOptions,\n ) {\n // Added to an editor that already shows a document, the first change still needs its before.\n this.cover = new RowCover(context)\n if (context.hasDocument()) this.latest = editFrame(context.getSnapshot())\n this.latestReplaced = mountedReplacements(\n context.getInlineReplacementRanges(),\n this.latest?.visibleRows ?? [],\n )\n }\n\n public update(\n snapshot: EditorViewSnapshot,\n kind: EditorViewContributionUpdateKind,\n change?: EditorContributionChange | null,\n ): void {\n if (kind === 'document' || kind === 'clear') {\n this.finish()\n this.before = null\n this.beforeReplaced = []\n this.latest = kind === 'clear' ? null : editFrame(snapshot)\n this.latestReplaced =\n kind === 'clear'\n ? []\n : mountedReplacements(\n this.context.getInlineReplacementRanges(),\n this.latest?.visibleRows ?? [],\n )\n return\n }\n const captured = editFrame(snapshot)\n if (!captured) {\n this.finish()\n this.latest = null\n this.before = null\n this.latestReplaced = []\n this.beforeReplaced = []\n return\n }\n // One pass can deliver the new text under several kinds, `viewport` before `content`.\n if (!this.latest || this.latest.textVersion !== snapshot.textVersion) {\n this.before = this.latest\n this.beforeReplaced = this.latestReplaced\n }\n this.latest = captured\n // Read while each snapshot is current: once the text changes, the old replacements are gone.\n if (kind !== 'viewport')\n this.latestReplaced = mountedReplacements(\n this.context.getInlineReplacementRanges(),\n captured.visibleRows,\n )\n const previous = this.before\n if (kind === 'layout') this.measurer = null\n if (kind !== 'content' || (change && !TEXT_CHANGES.has(change.kind))) {\n this.keepCovering(snapshot, kind)\n return\n }\n if (!previous || previous.textVersion === snapshot.textVersion) return\n if (!this.shouldMorph(previous, snapshot, change ?? null)) {\n this.finish()\n return\n }\n this.morph(previous, snapshot)\n }\n\n // Between changes: keep repainted rows hidden and the overlay coloured, or settle when the rows\n // moved under it (new metrics, a rewrap). Newer text waits for its `content` update to retarget.\n private keepCovering(snapshot: EditorViewSnapshot, kind: EditorViewContributionUpdateKind): void {\n const started = this.runSnapshot\n if (!this.run || !started) return\n if (snapshot.textVersion !== started.textVersion) {\n // A text change that is not a morph (a save sync) repaints rows the overlay no longer matches.\n if (kind === 'content') this.finish()\n return\n }\n if (frameMoved(started, snapshot, this.runRows)) {\n this.finish()\n return\n }\n this.cover.refresh(snapshot)\n if (kind === 'tokens') this.run.recolor(recolorFrame(this.run.targetFrame, snapshot.tokens))\n }\n\n public dispose(): void {\n this.finish()\n this.latest = null\n this.before = null\n this.latestReplaced = []\n this.beforeReplaced = []\n }\n\n private shouldMorph(\n previous: EditFrame,\n snapshot: EditorViewSnapshot,\n change: EditorContributionChange | null,\n ): boolean {\n if (reducedMotion(this.context)) return false\n if (previous.documentId !== snapshot.documentId) return false\n // `setContent` on an editor without a session re-renders the whole text with no change record.\n // Typed text shows at once: a keystroke settles any morph instead of joining it.\n return !change?.typing\n }\n\n // Rows painted as their source text morph on the overlay. The rest (rendered Markdown, chips)\n // stay real and move as whole rows, because the overlay cannot draw what they show.\n private morph(previous: EditFrame, snapshot: EditorViewSnapshot): void {\n const drawn = drawableRows(snapshot, this.latestReplaced)\n const real = new Set(Array.from(snapshot.visibleRows, (row) => row.index))\n for (const index of drawn) real.delete(index)\n const { moves, taken } = rowMoves(previous, snapshot, real)\n const rows = this.cover.collect(snapshot, drawn)\n const measurer = this.ensureMeasurer(snapshot, rows[0]?.presentation.element)\n const next = buildFrame(snapshot, measurer, this.options.maxPieces, undefined, (row) =>\n drawn.has(row.index),\n )\n const from = this.run ? this.run.visualPieces() : this.restingFrom(previous, measurer, taken)\n if (!next || !from) {\n for (const row of rows) row.presentation.dispose()\n this.finish()\n return\n }\n const pairs = matchPieces(from, next.pieces)\n\n this.run?.cancel()\n this.moves?.cancel()\n const timing = this.ensureTiming()\n this.run = new MorphRun(this.context.contentElement, next, from, pairs, timing, () =>\n this.settleOverlay(),\n )\n this.moves = new RowMoves(this.context, moves, timing)\n this.context.scrollElement.classList.add(ACTIVE_CLASS)\n this.runSnapshot = snapshot\n this.runRows = drawn\n this.cover.cover(rows)\n this.context.log({\n level: 'info',\n action: 'morph.start',\n pieceCount: next.pieces.length,\n movedCount: pairs.reduce((count, old) => count + (old >= 0 ? 1 : 0), 0),\n fromCount: from.length,\n })\n }\n\n private restingFrom(previous: EditFrame, measurer: TextMeasurer, moving: ReadonlySet<number>) {\n const drawn = drawableRows(previous, this.beforeReplaced)\n const frame: MorphFrame | null = buildFrame(\n previous,\n measurer,\n this.options.maxPieces,\n undefined,\n (row) => drawn.has(row.index) && !moving.has(row.index),\n )\n return frame ? restingPieces(frame) : null\n }\n\n private finish(): void {\n this.moves?.cancel()\n this.moves = null\n this.settleOverlay()\n }\n\n /** Drops the overlay; rows still moving on their own finish their motion. */\n private settleOverlay(): void {\n this.context.scrollElement.classList.remove(ACTIVE_CLASS)\n this.cover.showAll()\n this.runSnapshot = null\n this.runRows = new Set()\n this.run?.cancel()\n this.run = null\n }\n\n private ensureMeasurer(snapshot: EditorViewSnapshot, row: Element | undefined): TextMeasurer {\n const fontSource = row ?? this.context.contentElement\n const font = canvasFont(fontSource)\n const tabColumns = renderedTabColumns(this.context.scrollElement, snapshot.tabSize)\n if (this.measurer?.font === font && this.measurer.tabColumns === tabColumns)\n return this.measurer\n this.measurer = new TextMeasurer(\n this.context.scrollElement.ownerDocument,\n font,\n snapshot.metrics.characterWidth,\n tabColumns,\n )\n return this.measurer\n }\n\n private ensureTiming(): MorphTiming {\n this.timing ??= {\n durationMs: this.options.durationMs,\n moveEasing: springEasing(this.options.bounce, supportsLinearEasing(this.context)),\n }\n return this.timing\n }\n}\n\nfunction positive(value: number | undefined, fallback: number): number {\n if (value === undefined || !Number.isFinite(value) || value <= 0) return fallback\n return value\n}\n"],"mappings":";;;;;;;;;;AA2BA,IAAM,eAAe;AAErB,IAAM,+BAAe,IAAI,IAAI;CAAC;CAAQ;CAAQ;CAAQ;CAAY;AAAW,CAAC;;;;;;;AAQ9E,SAAgB,8BACd,UAA0C,CAAC,GAC7B;CACd,MAAM,WAAW;EACf,YAAY,SAAS,QAAQ,YAAY,GAAG;EAC5C,QAAQ,KAAK,IAAI,IAAK,KAAK,IAAI,GAAG,QAAQ,UAAU,GAAI,CAAC;EACzD,WAAW,SAAS,QAAQ,WAAW,IAAI;CAC7C;CACA,OAAO;EACL,MAAM;EACN,WAAW,YACT,QAAQ,yBAAyB,EAC/B,qBAAqB,gBACnB,IAAI,kCAAkC,aAAa,QAAQ,EAC/D,CAAC;CACL;AACF;AAYA,SAAS,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EACA,OAAO,KAAK;CACd;CAEA,eAAoC;EAClC,KAAK,WAAW;GACd,YAAY,KAAK,QAAQ;GACzB,YAAY,aAAa,KAAK,QAAQ,QAAQ,qBAAqB,KAAK,OAAO,CAAC;EAClF;EACA,OAAO,KAAK;CACd;AACF;AAEA,SAAS,SAAS,OAA2B,UAA0B;CACrE,IAAI,UAAU,KAAA,KAAa,CAAC,OAAO,SAAS,KAAK,KAAK,SAAS,GAAG,OAAO;CACzE,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-transition.js","names":[],"sources":["../src/file-transition.ts"],"sourcesContent":["import type {\n EditorPlugin,\n EditorViewContribution,\n EditorViewContributionContext,\n EditorViewContributionUpdateKind,\n EditorViewSnapshot,\n} from '@singapore-editor/core/extensions'\nimport { TextMeasurer, canvasFont, renderedTabColumns } from './measure'\nimport { buildFrame, frameMoved, recolorFrame } from './morph-frame'\nimport { matchPieces } from './morph-match'\nimport {\n MorphRun,\n restingPieces,\n springEasing,\n type MorphTiming,\n type VisualPiece,\n} from './morph-run'\nimport { drawableRows, reducedMotion, supportsLinearEasing, type TextOffsetRange } from './motion'\nimport { RowMoves, rowMoves, type ScreenShift } from './row-moves'\nimport {\n resolveTransitionOptions,\n type FileTransitionPluginOptions,\n type ResolvedTransitionOptions,\n} from './transition-options'\nimport { RevealRun } from './reveal-run'\nimport { RowCover } from './row-cover'\nimport './style.css'\n\nexport type { FileTransitionMode, FileTransitionPluginOptions } from './transition-options'\n\nconst ACTIVE_CLASS = 'editor-file-transition-active'\n// Input skips the reveal to its end. Scrolling does not: the overlay scrolls with the text.\nconst INPUT_EVENTS = ['keydown', 'pointerdown'] as const\n// A reveal draws at most this many pieces; a denser viewport opens without one.\nconst MAX_PIECES = 4000\n// One magic move, before the speed multiplier, and the spring overshoot of moving text.\nconst MAGIC_MOVE_MS = 640\nconst MAGIC_MOVE_BOUNCE = 0.18\n\n/**\n * File-open \"writes itself\" animation. Including this plugin turns the effect on;\n * removing it turns it off. There is no command, setting, or UI — presence is the switch.\n */\nexport function createFileTransitionPlugin(\n options: FileTransitionPluginOptions = {},\n): EditorPlugin {\n const resolved = resolveTransitionOptions(options)\n // Shared by every editor the plugin runs in: a magic move starts from the file opened last,\n // which may have been in another editor, such as the previous tab's.\n const handoff: Handoff = { last: null }\n return {\n name: 'editor.fileTransition',\n activate: (context) =>\n context.registerViewContribution({\n createContribution: (viewContext) =>\n new FileTransitionViewContribution(viewContext, resolved, handoff),\n }),\n }\n}\n\ntype Handoff = { last: LastFile | null }\n\n/**\n * What a magic move reads of the previous file. Only these fields are kept: a whole snapshot would\n * hold its document session alive for as long as the plugin exists.\n */\ntype FileFrame = Pick<\n EditorViewSnapshot,\n 'documentId' | 'visibleRows' | 'tokens' | 'gutterWidth' | 'viewport'\n>\n\nfunction fileFrame(snapshot: EditorViewSnapshot): FileFrame {\n const { documentId, visibleRows, tokens, gutterWidth, viewport } = snapshot\n return { documentId, visibleRows, tokens, gutterWidth, viewport }\n}\n\nfunction holdsOnlyText(frame: FileFrame) {\n return frame.visibleRows.every(\n (row) =>\n row.kind !== 'text' ||\n (typeof row.text === 'string' && row.chunks.every((chunk) => typeof chunk.text === 'string')),\n )\n}\n\n/** The file opened last, as its editor shows it now, and where that editor's viewport sat. */\ntype LastFile = {\n /** The editor showing it, until that editor goes. */\n readonly owner: FileTransitionViewContribution | null\n snapshot: FileFrame\n replaced: readonly TextOffsetRange[]\n viewport: ScreenPoint\n}\n\ntype ScreenPoint = { readonly left: number; readonly top: number }\n\nclass FileTransitionViewContribution implements EditorViewContribution {\n public readonly inputs = ['content', 'tokens', 'viewport', 'layout', 'selection'] as const\n private animatedDocumentId: string | null = null\n private latestReplaced: readonly TextOffsetRange[] = []\n private run: RevealRun | MorphRun | null = null\n private moves: RowMoves | null = null\n /** The rows the overlay covers, when it covers only some. */\n private runRows: ReadonlySet<number> | undefined\n private runFrame: ReturnType<typeof buildFrame> = null\n private runSnapshot: EditorViewSnapshot | null = null\n private measurer: TextMeasurer | null = null\n private readonly cover: RowCover\n private readonly options: ResolvedTransitionOptions\n\n public constructor(\n private readonly context: EditorViewContributionContext,\n options: ResolvedTransitionOptions,\n private readonly handoff: Handoff,\n ) {\n this.cover = new RowCover(context)\n this.options = scaleTimings(options)\n this.latestReplaced = context.getInlineReplacementRanges()\n // Added to an editor already showing a file, the next open still has one to move from.\n if (context.hasDocument() && !handoff.last) this.remember(context.getSnapshot())\n }\n\n public update(snapshot: EditorViewSnapshot, kind: EditorViewContributionUpdateKind): void {\n if (kind !== 'viewport') this.latestReplaced = this.context.getInlineReplacementRanges()\n if (kind === 'document') {\n const previous = this.handoff.last\n const other = previous?.snapshot.documentId === snapshot.documentId ? null : previous\n this.handleDocumentOpen(snapshot, other)\n if (snapshot.documentId) this.remember(snapshot)\n return\n }\n // The file opened last keeps up with its editor: its scroll and edits are where a move starts.\n // A tab switch clears the old editor first; the file it showed is still the one to move from.\n const last = this.handoff.last\n if (last?.owner === this && snapshot.documentId === last.snapshot.documentId) {\n last.snapshot = fileFrame(snapshot)\n last.replaced = this.latestReplaced\n }\n const started = this.runSnapshot\n if (!this.run || !started) return\n // New text or new metrics: the overlay no longer matches the rows under it.\n if (\n snapshot.textVersion !== started.textVersion ||\n frameMoved(started, snapshot, this.runRows)\n ) {\n this.finish()\n return\n }\n this.cover.refresh(snapshot)\n if (kind === 'tokens' && this.runFrame) {\n this.run.recolor(recolorFrame(this.runFrame, snapshot.tokens))\n }\n }\n\n public dispose(): void {\n this.finish()\n // The file stays the one to move from, but this editor and its view are let go. A row read\n // through its document (a long line) would keep that document alive, and a frame with one\n // cannot be drawn anyway, so such a file is not kept.\n const last = this.handoff.last\n if (last?.owner !== this) return\n this.handoff.last = holdsOnlyText(last.snapshot)\n ? { ...last, owner: null, viewport: this.viewportOrigin() ?? last.viewport }\n : null\n }\n\n /** Where this editor's viewport sits on screen, while it is on screen. */\n public viewportOrigin(): ScreenPoint | null {\n const element = this.context.scrollElement\n if (!element.isConnected) return null\n const rect = element.getBoundingClientRect()\n return { left: rect.left, top: rect.top }\n }\n\n private remember(snapshot: EditorViewSnapshot): void {\n // Only a magic move starts from the previous file; the reveals keep nothing.\n if (this.options.mode !== 'magicMove') return\n this.handoff.last = {\n owner: this,\n snapshot: fileFrame(snapshot),\n replaced: this.latestReplaced,\n viewport: this.viewportOrigin() ?? { left: 0, top: 0 },\n }\n }\n\n private handleDocumentOpen(snapshot: EditorViewSnapshot, previous: LastFile | null): void {\n const documentId = snapshot.documentId\n if (documentId !== null && documentId === this.animatedDocumentId) return\n // Any other document, empty or not, supersedes an in-flight reveal.\n this.finish()\n if (!documentId || snapshot.textSnapshot.length === 0) return\n if (reducedMotion(this.context)) return\n if (this.options.mode === 'magicMove') {\n this.animatedDocumentId = documentId\n this.magicMove(snapshot, previous)\n return\n }\n // Chips, hidden markup and phantom text are painted as something other than their source.\n if (this.context.getInlineReplacementRanges().length > 0) return\n this.animatedDocumentId = documentId\n const rows = this.cover.collect(snapshot)\n const measurer = this.ensureMeasurer(snapshot, rows[0]?.presentation.element)\n const frame = buildFrame(snapshot, measurer, MAX_PIECES, this.options.maxRows)\n if (!frame || frame.pieces.length === 0) {\n for (const row of rows) row.presentation.dispose()\n return\n }\n this.context.log({\n level: 'info',\n action: 'fileTransition.reveal',\n mode: this.options.mode,\n pieceCount: frame.pieces.length,\n rowCount: frame.rowCount,\n languageId: snapshot.languageId,\n highlightStatus: snapshot.initialHighlightStatus,\n })\n this.runFrame = frame\n this.runSnapshot = snapshot\n this.run = new RevealRun(\n this.context.contentElement,\n frame,\n this.options,\n (text) => measurer.width(text),\n () => this.finish(),\n )\n this.context.scrollElement.classList.add(ACTIVE_CLASS)\n this.cover.cover(rows)\n this.addInputListeners()\n }\n\n /**\n * The text the previous file shares with this one moves from where it stood on screen to where\n * it stands now; the rest of the old text leaves and the rest of the new enters. Rows painted as\n * something other than their source stay real and slide or fade in whole.\n */\n private magicMove(snapshot: EditorViewSnapshot, previous: LastFile | null): void {\n const drawn = drawableRows(snapshot, this.latestReplaced)\n const real = new Set(Array.from(snapshot.visibleRows, (row) => row.index))\n for (const index of drawn) real.delete(index)\n const shift = previous ? this.screenShift(previous, snapshot) : { dx: 0, dy: 0 }\n const { moves, taken } = rowMoves(previous?.snapshot ?? null, snapshot, real, shift)\n const rows = this.cover.collect(snapshot, drawn)\n const measurer = this.ensureMeasurer(snapshot, rows[0]?.presentation.element)\n const next = buildFrame(snapshot, measurer, MAX_PIECES, this.options.maxRows, (row) =>\n drawn.has(row.index),\n )\n const from = previous ? this.previousPieces(previous, measurer, taken, shift) : []\n if (!next || !from) {\n for (const row of rows) row.presentation.dispose()\n return\n }\n const timing: MorphTiming = {\n durationMs: MAGIC_MOVE_MS / this.options.speed,\n moveEasing: springEasing(MAGIC_MOVE_BOUNCE, supportsLinearEasing(this.context)),\n }\n const pairs = matchPieces(from, next.pieces)\n this.context.log({\n level: 'info',\n action: 'fileTransition.magicMove',\n pieceCount: next.pieces.length,\n movedCount: pairs.reduce((count, old) => count + (old >= 0 ? 1 : 0), 0),\n fromCount: from.length,\n languageId: snapshot.languageId,\n })\n this.runFrame = next\n this.runSnapshot = snapshot\n this.runRows = drawn\n // Rendered rows keep moving on their own after the overlay is done, which an overlay with no\n // pieces is at once.\n this.run = new MorphRun(this.context.contentElement, next, from, pairs, timing, () =>\n this.settleOverlay(),\n )\n this.moves = new RowMoves(this.context, moves, timing)\n this.context.scrollElement.classList.add(ACTIVE_CLASS)\n this.cover.cover(rows)\n this.addInputListeners()\n }\n\n /**\n * How far the previous file's content coordinates sit from this one's on screen: the two\n * viewports may be different editors, and each file has its own scroll and gutter.\n */\n private screenShift(previous: LastFile, snapshot: EditorViewSnapshot) {\n const before = previous.owner?.viewportOrigin() ?? previous.viewport\n const now = this.viewportOrigin() ?? before\n const old = previous.snapshot\n return {\n dx:\n before.left -\n now.left +\n old.gutterWidth -\n snapshot.gutterWidth +\n snapshot.viewport.scrollLeft -\n old.viewport.scrollLeft,\n dy: before.top - now.top + snapshot.viewport.scrollTop - old.viewport.scrollTop,\n }\n }\n\n /** The previous file's drawable text as resting pieces, placed where it stood on screen. */\n private previousPieces(\n previous: LastFile,\n measurer: TextMeasurer,\n moving: ReadonlySet<number>,\n shift: ScreenShift,\n ): VisualPiece[] | null {\n const drawn = drawableRows(previous.snapshot, previous.replaced)\n const frame = buildFrame(\n previous.snapshot,\n measurer,\n MAX_PIECES,\n this.options.maxRows,\n (row) => drawn.has(row.index) && !moving.has(row.index),\n )\n if (!frame) return null\n return restingPieces(frame).map((piece) => ({\n ...piece,\n x: piece.x + shift.dx,\n top: piece.top + shift.dy,\n }))\n }\n\n private finish(): void {\n this.moves?.cancel()\n this.moves = null\n this.settleOverlay()\n }\n\n private settleOverlay(): void {\n this.removeInputListeners()\n this.context.scrollElement.classList.remove(ACTIVE_CLASS)\n this.cover.showAll()\n this.run?.cancel()\n this.run = null\n this.runFrame = null\n this.runSnapshot = null\n this.runRows = undefined\n }\n\n private readonly finishOnInput = (): void => this.finish()\n\n private addInputListeners(): void {\n for (const type of INPUT_EVENTS) {\n this.context.scrollElement.addEventListener(type, this.finishOnInput, { capture: true })\n }\n }\n\n private removeInputListeners(): void {\n for (const type of INPUT_EVENTS) {\n this.context.scrollElement.removeEventListener(type, this.finishOnInput, { capture: true })\n }\n }\n\n private ensureMeasurer(snapshot: EditorViewSnapshot, fontSource: Element | undefined) {\n const font = canvasFont(fontSource ?? this.context.contentElement)\n const tabColumns = renderedTabColumns(this.context.scrollElement, snapshot.tabSize)\n if (this.measurer?.font === font && this.measurer.tabColumns === tabColumns)\n return this.measurer\n this.measurer = new TextMeasurer(\n this.context.scrollElement.ownerDocument,\n font,\n snapshot.metrics.characterWidth,\n tabColumns,\n )\n return this.measurer\n }\n}\n\n// Divide every time field by the speed multiplier (speed > 1 ⇒ shorter ⇒ faster).\nfunction scaleTimings(options: ResolvedTransitionOptions): ResolvedTransitionOptions {\n return {\n ...options,\n perCharMs: options.perCharMs / options.speed,\n perTokenMs: options.perTokenMs / options.speed,\n maxDurationMs: options.maxDurationMs / options.speed,\n staggerMs: options.staggerMs / options.speed,\n }\n}\n"],"mappings":";;;;;;;;;;;AA8BA,IAAM,eAAe;AAErB,IAAM,eAAe,CAAC,WAAW,aAAa;AAE9C,IAAM,aAAa;AAEnB,IAAM,gBAAgB;AACtB,IAAM,oBAAoB;;;;;AAM1B,SAAgB,2BACd,UAAuC,CAAC,GAC1B;CACd,MAAM,WAAW,yBAAyB,OAAO;CAGjD,MAAM,UAAmB,EAAE,MAAM,KAAK;CACtC,OAAO;EACL,MAAM;EACN,WAAW,YACT,QAAQ,yBAAyB,EAC/B,qBAAqB,gBACnB,IAAI,+BAA+B,aAAa,UAAU,OAAO,EACrE,CAAC;CACL;AACF;AAaA,SAAS,UAAU,UAAyC;CAC1D,MAAM,EAAE,YAAY,aAAa,QAAQ,aAAa,aAAa;CACnE,OAAO;EAAE;EAAY;EAAa;EAAQ;EAAa;CAAS;AAClE;AAEA,SAAS,cAAc,OAAkB;CACvC,OAAO,MAAM,YAAY,OACtB,QACC,IAAI,SAAS,UACZ,OAAO,IAAI,SAAS,YAAY,IAAI,OAAO,OAAO,UAAU,OAAO,MAAM,SAAS,QAAQ,CAC/F;AACF;AAaA,IAAM,iCAAN,MAAuE;CAelD;CAEA;CAhBnB,SAAyB;EAAC;EAAW;EAAU;EAAY;EAAU;CAAW;CAChF,qBAA4C;CAC5C,iBAAqD,CAAC;CACtD,MAA2C;CAC3C,QAAiC;;CAEjC;CACA,WAAkD;CAClD,cAAiD;CACjD,WAAwC;CACxC;CACA;CAEA,YACE,SACA,SACA,SACA;EAHiB,KAAA,UAAA;EAEA,KAAA,UAAA;EAEjB,KAAK,QAAQ,IAAI,SAAS,OAAO;EACjC,KAAK,UAAU,aAAa,OAAO;EACnC,KAAK,iBAAiB,QAAQ,2BAA2B;EAEzD,IAAI,QAAQ,YAAY,KAAK,CAAC,QAAQ,MAAM,KAAK,SAAS,QAAQ,YAAY,CAAC;CACjF;C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H,WAAW,QAAQ,YAAY,QAAQ;EACvC,YAAY,QAAQ,aAAa,QAAQ;EACzC,eAAe,QAAQ,gBAAgB,QAAQ;EAC/C,WAAW,QAAQ,YAAY,QAAQ;CACzC;AACF"}
|
package/dist/measure.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"measure.js","names":[],"sources":["../src/measure.ts"],"
|
|
1
|
+
{"version":3,"file":"measure.js","names":[],"sources":["../src/measure.ts"],"mappings":";;;;;;AAKA,IAAa,eAAb,MAA0B;CAMN;CACC;CAED;CARlB,yBAA0B,IAAI,IAAoB;CAClD;CAEA,YACE,UACA,MACA,mBAEA,YACA;EAJgB,KAAA,OAAA;EACC,KAAA,oBAAA;EAED,KAAA,aAAA;EAEhB,KAAK,UAAU,SAAS,cAAc,QAAQ,CAAC,CAAC,WAAW,IAAI;EAC/D,IAAI,KAAK,SAAS,KAAK,QAAQ,OAAO;CACxC;CAEA,IAAW,WAAmB;EAC5B,OAAO,KAAK,MAAM,GAAG,IAAI,KAAK;CAChC;CAEA,MAAa,MAAsB;EACjC,MAAM,SAAS,KAAK,OAAO,IAAI,IAAI;EACnC,IAAI,WAAW,KAAA,GAAW,OAAO;EACjC,MAAM,QAAQ,KAAK,UACf,KAAK,QAAQ,YAAY,IAAI,CAAC,CAAC,QAC/B,KAAK,SAAS,KAAK;EACvB,KAAK,OAAO,IAAI,MAAM,KAAK;EAC3B,OAAO;CACT;AACF;;AAGA,SAAgB,mBAAmB,eAAwB,UAA0B;CACnF,MAAM,QAAQ,cAAc,cAAc,aAAa,iBAAiB,aAAa;CACrF,MAAM,UAAU,OAAO,WAAW,OAAO,iBAAiB,mBAAmB,KAAK,EAAE;CACpF,OAAO,OAAO,SAAS,OAAO,KAAK,UAAU,IAAI,UAAU;AAC7D;;AAGA,SAAgB,WAAW,SAA0B;CACnD,MAAM,QAAQ,QAAQ,cAAc,aAAa,iBAAiB,OAAO;CACzE,IAAI,CAAC,OAAO,OAAO;CACnB,OAAO;EAAC,MAAM;EAAW,MAAM;EAAY,MAAM;EAAU,MAAM;CAAU,CAAC,CACzE,QAAQ,SAAS,QAAQ,SAAS,QAAQ,CAAC,CAC3C,KAAK,GAAG;AACb"}
|
package/dist/morph-frame.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"morph-frame.js","names":[],"sources":["../src/morph-frame.ts"],"sourcesContent":["import type { EditorViewSnapshot } from '@singapore-editor/core/extensions'\nimport type { TextMeasurer } from './measure'\n\n/** One visible run of text that moves, enters or leaves as a unit. */\nexport type MorphPiece = {\n readonly text: string\n readonly offset: number\n /** Left edge in content px, after the row's spacer; the layer adds the gutter. */\n readonly x: number\n readonly top: number\n readonly height: number\n /** Order of its row among the frame's rows, for staggering. */\n readonly row: number\n /** Whitespace stands between this piece and the one before it on its row. */\n readonly gapBefore: boolean\n readonly color: string | undefined\n readonly fontStyle: string | undefined\n readonly fontWeight: string | number | undefined\n}\n\nexport type MorphFrame = {\n readonly pieces: readonly MorphPiece[]\n readonly rowCount: number\n}\n\ntype Tokens = EditorViewSnapshot['tokens']\ntype VisibleRow = EditorViewSnapshot['visibleRows'][number]\nexport type PaintRow = Pick<\n VisibleRow,\n | 'index'\n | 'kind'\n | 'text'\n | 'startOffset'\n | 'endOffset'\n | 'leftSpacerWidth'\n | 'top'\n | 'height'\n | 'mountedPaintSupport'\n> & { readonly chunks: readonly Pick<VisibleRow['chunks'][number], 'text' | 'mountedPaint'>[] }\ntype TokenStyle = ReturnType<Tokens['styleAt']>\n\n// Words, runs of punctuation, and whitespace. Whitespace only advances x.\nconst PIECE = /[\\p{L}\\p{N}_$]+|[^\\p{L}\\p{N}_$\\s]+|\\s+/gu\nconst WHITESPACE = /^\\s+$/\n\n/**\n * The visible rows as positioned pieces, split at both syntax-token and word\n * boundaries so a piece never straddles two colours. Null when a mounted row\n * is a horizontal window of a long line, whose x origin is not the row start,\n * or carries paint the overlay cannot redraw. With `drawable`, rows it rejects\n * are left out instead, for a caller that leaves those rows uncovered.\n */\nexport function buildFrame(\n snapshot: { readonly visibleRows: readonly PaintRow[]; readonly tokens: Tokens },\n measurer: TextMeasurer,\n maxPieces: number,\n maxRows = Number.POSITIVE_INFINITY,\n drawable?: (row: PaintRow) => boolean,\n): MorphFrame | null {\n const pieces: MorphPiece[] = []\n const styleAt = tokenStyleLookup(snapshot.tokens)\n const tabWidth = measurer.tabWidth\n let row = 0\n for (const visible of snapshot.visibleRows) {\n if (visible.kind !== 'text') continue\n if (typeof visible.text !== 'string') return null\n if (drawable && !drawable(visible)) continue\n // Paint the overlay cannot redraw, such as plugin CSS or control-character boxes, would vanish\n // with the hidden row.\n if (!drawsAsPlainText(visible)) return null\n if (visible.text.length === 0) continue\n // Every mounted row gets covered, so a frame that cannot draw them all draws none.\n if (row >= maxRows) return null\n appendRowPieces(pieces, {\n text: visible.text,\n startOffset: visible.startOffset,\n left: visible.leftSpacerWidth,\n top: visible.top,\n height: visible.height,\n row,\n tabWidth,\n measurer,\n styleAt,\n })\n row += 1\n if (pieces.length > maxPieces) return null\n }\n return { pieces, rowCount: row }\n}\n\ntype RowInput = {\n readonly text: string\n readonly startOffset: number\n readonly left: number\n readonly top: number\n readonly height: number\n readonly row: number\n readonly tabWidth: number\n readonly measurer: TextMeasurer\n readonly styleAt: (offset: number) => { style: TokenStyle | undefined; end: number }\n}\n\nfunction appendRowPieces(pieces: MorphPiece[], input: RowInput): void {\n let x = 0\n let gapBefore = false\n for (const match of input.text.matchAll(PIECE)) {\n let segment = match[0]\n let column = match.index\n while (segment.length > 0) {\n const { style, end } = input.styleAt(input.startOffset + column)\n const length = Math.max(1, Math.min(segment.length, end - (input.startOffset + column)))\n const text = segment.slice(0, length)\n if (WHITESPACE.test(text)) {\n x = advanceWhitespace(x, text, input)\n gapBefore = true\n } else {\n pieces.push({\n text,\n offset: input.startOffset + column,\n x: input.left + x,\n top: input.top,\n height: input.height,\n row: input.row,\n gapBefore,\n color: style?.color,\n fontStyle: style?.fontStyle,\n fontWeight: style?.fontWeight,\n })\n x += input.measurer.width(text)\n gapBefore = false\n }\n segment = segment.slice(length)\n column += length\n }\n }\n}\n\n// Tabs advance to the next stop measured from the row's text origin, like CSS `tab-size`.\nfunction advanceWhitespace(x: number, text: string, input: RowInput): number {\n let next = x\n for (const char of text) {\n if (char === '\\t' && input.tabWidth > 0) {\n next = (Math.floor(next / input.tabWidth + 1e-6) + 1) * input.tabWidth\n continue\n }\n next += input.measurer.width(char)\n }\n return next\n}\n\n/**\n * Maps an offset to its token's style and the offset where that style ends.\n * Reads go forward within a row, so one advancing cursor serves the pass; a\n * jump backwards (the next row) re-seeks by bisection.\n */\nfunction tokenStyleLookup(\n tokens: Tokens,\n): (offset: number) => { style: TokenStyle | undefined; end: number } {\n let cursor = -1\n let last = -1\n return (offset) => {\n if (cursor < 0 || offset < last) cursor = tokens.firstEndingAfter(offset)\n last = offset\n while (cursor < tokens.length && tokens.endAt(cursor) <= offset) cursor += 1\n if (cursor >= tokens.length) return { style: undefined, end: Number.POSITIVE_INFINITY }\n const start = tokens.startAt(cursor)\n if (start > offset) return { style: undefined, end: start }\n return { style: tokens.styleAt(cursor), end: tokens.endAt(cursor) }\n }\n}\n\nexport function drawsAsPlainText(row: PaintRow): boolean {\n if (row.mountedPaintSupport !== 'replayable') return false\n return row.chunks.every(\n (chunk) =>\n chunk.mountedPaint.kind === 'replayable' &&\n chunk.mountedPaint.parts.every((part) => part.kind === 'text'),\n )\n}\n\n/**\n * Whether the rows a frame was built from now stand somewhere else, hold other text or paint it\n * differently: new metrics, a rewrap, a changed indent, an inline replacement landing. Rows only\n * one side mounts (a scroll) do not count, nor rows outside `rows` when it is given.\n */\nexport function frameMoved(\n before: EditorViewSnapshot,\n after: EditorViewSnapshot,\n rows?: ReadonlySet<number>,\n): boolean {\n if (\n before.metrics.rowHeight !== after.metrics.rowHeight ||\n before.metrics.characterWidth !== after.metrics.characterWidth\n ) {\n return true\n }\n const mounted = new Map(after.visibleRows.map((row) => [row.index, row]))\n return before.visibleRows.some((row) => {\n if (rows && !rows.has(row.index)) return false\n const now = mounted.get(row.index)\n if (!now) return false\n return (\n now.top !== row.top ||\n now.startOffset !== row.startOffset ||\n now.endOffset !== row.endOffset ||\n now.leftSpacerWidth !== row.leftSpacerWidth ||\n now.text !== row.text ||\n drawsAsPlainText(now) !== drawsAsPlainText(row)\n )\n })\n}\n\n/** Fresh colours for a frame's pieces from a later token pass, by offset. */\nexport function recolorFrame(frame: MorphFrame, tokens: Tokens): (string | undefined)[] {\n const styleAt = tokenStyleLookup(tokens)\n return frame.pieces.map((piece) => styleAt(piece.offset).style?.color)\n}\n"],"mappings":";AA0CA,IAAM,QAAQ;AACd,IAAM,aAAa;;;;;;;;AASnB,SAAgB,WACd,UACA,UACA,WACA,UAAU,OAAO,mBACjB,UACmB;CACnB,MAAM,SAAuB,CAAC;CAC9B,MAAM,UAAU,iBAAiB,SAAS,MAAM;CAChD,MAAM,WAAW,SAAS;CAC1B,IAAI,MAAM;CACV,KAAK,MAAM,WAAW,SAAS,aAAa;EAC1C,IAAI,QAAQ,SAAS,QAAQ;EAC7B,IAAI,OAAO,QAAQ,SAAS,UAAU,OAAO;EAC7C,IAAI,YAAY,CAAC,SAAS,OAAO,GAAG;EAGpC,IAAI,CAAC,iBAAiB,OAAO,GAAG,OAAO;EACvC,IAAI,QAAQ,KAAK,WAAW,GAAG;EAE/B,IAAI,OAAO,SAAS,OAAO;EAC3B,gBAAgB,QAAQ;GACtB,MAAM,QAAQ;GACd,aAAa,QAAQ;GACrB,MAAM,QAAQ;GACd,KAAK,QAAQ;GACb,QAAQ,QAAQ;GAChB;GACA;GACA;GACA;EACF,CAAC;EACD,OAAO;EACP,IAAI,OAAO,SAAS,WAAW,OAAO;CACxC;CACA,OAAO;EAAE;EAAQ,UAAU;CAAI;AACjC;AAcA,SAAS,gBAAgB,QAAsB,OAAuB;CACpE,IAAI,IAAI;CACR,IAAI,YAAY;CAChB,KAAK,MAAM,SAAS,MAAM,KAAK,S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SAAS,KAAK,SAAS,MAAM,CACjE;AACF;;;;;;AAOA,SAAgB,WACd,QACA,OACA,MACS;CACT,IACE,OAAO,QAAQ,cAAc,MAAM,QAAQ,aAC3C,OAAO,QAAQ,mBAAmB,MAAM,QAAQ,gBAEhD,OAAO;CAET,MAAM,UAAU,IAAI,IAAI,MAAM,YAAY,KAAK,QAAQ,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC;CACxE,OAAO,OAAO,YAAY,MAAM,QAAQ;EACtC,IAAI,QAAQ,CAAC,KAAK,IAAI,IAAI,KAAK,GAAG,OAAO;EACzC,MAAM,MAAM,QAAQ,IAAI,IAAI,KAAK;EACjC,IAAI,CAAC,KAAK,OAAO;EACjB,OACE,IAAI,QAAQ,IAAI,OAChB,IAAI,gBAAgB,IAAI,eACxB,IAAI,cAAc,IAAI,aACtB,IAAI,oBAAoB,IAAI,mBAC5B,IAAI,SAAS,IAAI,QACjB,iBAAiB,GAAG,MAAM,iBAAiB,GAAG;CAElD,CAAC;AACH;;AAGA,SAAgB,aAAa,OAAmB,QAAwC;CACtF,MAAM,UAAU,iBAAiB,MAAM;CACvC,OAAO,MAAM,OAAO,KAAK,UAAU,QAAQ,MAAM,MAAM,CAAC,CAAC,OAAO,KAAK;AACvE"}
|
package/dist/morph-match.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"morph-match.js","names":[],"sources":["../src/morph-match.ts"],"sourcesContent":["const WORD = /^[\\p{L}\\p{N}_$]{2,}$/u\n\n// Above this many cells an in-order pass is skipped and only the unique-text\n// pass pairs pieces. A full-viewport rewrite of ~1,500 pieces each side fits.\nconst MAX_TABLE_CELLS = 2_500_000\n\n/** What matching reads of a piece: its text, the top of the line it sits on, and any gap before it. */\nexport type MatchPiece = {\n readonly text: string\n readonly top: number\n readonly gapBefore?: boolean\n}\n\ntype Line = {\n /** The line's text with one space for each gap, the same however highlighting split it. */\n readonly key: string\n readonly pieces: readonly number[]\n /** Where each piece starts in `key`. */\n readonly starts: readonly number[]\n readonly hasWord: boolean\n}\n\n/**\n * Pairs each new piece with the old piece it continues, by text. Returns one\n * entry per new piece: the old index it moves from, or -1 when it enters.\n *\n * Lines go first, whole: an unchanged line keeps its identity in order, and a\n * line that moved travels as one piece of text, punctuation included, instead\n * of trading its common tokens with the line it swapped with. The pieces left\n * over then pair in order by text, and finally a word that appears the same\n * number of times on both sides pairs wherever it is. Lone punctuation takes\n * no part in moves: a bracket flying across the screen reads as noise.\n */\nexport function matchPieces(\n oldPieces: readonly MatchPiece[],\n newPieces: readonly MatchPiece[],\n): Int32Array {\n const pairs = new Int32Array(newPieces.length).fill(-1)\n const oldUsed = new Uint8Array(oldPieces.length)\n matchLines(linesOf(oldPieces), linesOf(newPieces), pairs, oldUsed)\n\n const oldRest = unpaired(oldPieces.length, (index) => oldUsed[index] === 1)\n const newRest = unpaired(newPieces.length, (index) => pairs[index] !== -1)\n matchInOrder(\n oldRest,\n newRest,\n (oldIndex, newIndex) => oldPieces[oldIndex]?.text === newPieces[newIndex]?.text,\n (oldIndex, newIndex) => pair(oldIndex, newIndex, pairs, oldUsed),\n )\n matchUniqueWords(oldPieces, newPieces, pairs, oldUsed)\n return pairs\n}\n\n/** Pieces grouped by line top, each line in piece order. */\nfunction linesOf(pieces: readonly MatchPiece[]): Line[] {\n const byTop = new Map<number, number[]>()\n pieces.forEach((piece, index) => {\n const line = byTop.get(piece.top)\n if (line) line.push(index)\n else byTop.set(piece.top, [index])\n })\n return Array.from(byTop.values(), (indices) => {\n const starts: number[] = []\n let key = ''\n for (const index of indices) {\n const piece = pieces[index]\n if (piece?.gapBefore && key.length > 0) key += ' '\n starts.push(key.length)\n key += piece?.text ?? ''\n }\n return {\n key,\n pieces: indices,\n starts,\n hasWord: indices.some((index) => WORD.test(pieces[index]?.text ?? '')),\n }\n })\n}\n\nfunction matchLines(\n oldLines: readonly Line[],\n newLines: readonly Line[],\n pairs: Int32Array,\n oldUsed: Uint8Array,\n): void {\n const oldLineUsed = new Uint8Array(oldLines.length)\n const newLineUsed = new Uint8Array(newLines.length)\n const pairLine = (oldLine: number, newLine: number) => {\n oldLineUsed[oldLine] = 1\n newLineUsed[newLine] = 1\n pairLinePieces(oldLines[oldLine], newLines[newLine], pairs, oldUsed)\n }\n matchInOrder(\n Array.from(oldLines, (_, index) => index),\n Array.from(newLines, (_, index) => index),\n (oldLine, newLine) => oldLines[oldLine]?.key === newLines[newLine]?.key,\n pairLine,\n )\n\n // A moved line pairs with the first unpaired old line that reads the same.\n const movedByKey = new Map<string, number[]>()\n oldLines.forEach((line, index) => {\n if (oldLineUsed[index] || !line.hasWord) return\n const list = movedByKey.get(line.key)\n if (list) list.push(index)\n else movedByKey.set(line.key, [index])\n })\n newLines.forEach((line, newLine) => {\n if (newLineUsed[newLine] || !line.hasWord) return\n const oldLine = movedByKey.get(line.key)?.shift()\n if (oldLine !== undefined) pairLine(oldLine, newLine)\n })\n}\n\n/**\n * Pairs the pieces of two lines that read the same by where each starts: highlighting may split\n * the two differently, and a new piece then moves from the old piece it starts at.\n */\nfunction pairLinePieces(\n from: Line | undefined,\n to: Line | undefined,\n pairs: Int32Array,\n oldUsed: Uint8Array,\n): void {\n if (!from || !to) return\n const byStart = new Map<number, number>()\n from.starts.forEach((start, order) => byStart.set(start, from.pieces[order] ?? -1))\n to.starts.forEach((start, order) => {\n const newIndex = to.pieces[order]\n if (newIndex !== undefined) pair(byStart.get(start) ?? -1, newIndex, pairs, oldUsed)\n })\n}\n\nfunction unpaired(length: number, used: (index: number) => boolean): number[] {\n const rest: number[] = []\n for (let index = 0; index < length; index += 1) if (!used(index)) rest.push(index)\n return rest\n}\n\nfunction pair(oldIndex: number, newIndex: number, pairs: Int32Array, oldUsed: Uint8Array): void {\n if (oldIndex < 0) return\n pairs[newIndex] = oldIndex\n oldUsed[oldIndex] = 1\n}\n\n/** Longest common subsequence of two index lists under `same`, after trimming the shared ends. */\nfunction matchInOrder(\n oldIndices: readonly number[],\n newIndices: readonly number[],\n same: (oldIndex: number, newIndex: number) => boolean,\n onPair: (oldIndex: number, newIndex: number) => void,\n): void {\n const sameAt = (i: number, j: number) => same(oldIndices[i] ?? -1, newIndices[j] ?? -1)\n const pairAt = (i: number, j: number) => onPair(oldIndices[i] ?? -1, newIndices[j] ?? -1)\n let start = 0\n while (start < oldIndices.length && start < newIndices.length && sameAt(start, start)) {\n pairAt(start, start)\n start += 1\n }\n let oldEnd = oldIndices.length\n let newEnd = newIndices.length\n while (oldEnd > start && newEnd > start && sameAt(oldEnd - 1, newEnd - 1)) {\n oldEnd -= 1\n newEnd -= 1\n pairAt(oldEnd, newEnd)\n }\n\n const rows = oldEnd - start\n const columns = newEnd - start\n if (rows === 0 || columns === 0) return\n if (rows * columns > MAX_TABLE_CELLS) return\n\n // lengths[i][j] = LCS of old[start+i..] and new[start+j..], filled back to front.\n const width = columns + 1\n const lengths = new Uint16Array((rows + 1) * width)\n for (let i = rows - 1; i >= 0; i -= 1) {\n for (let j = columns - 1; j >= 0; j -= 1) {\n const here = i * width + j\n lengths[here] = sameAt(start + i, start + j)\n ? (lengths[here + width + 1] ?? 0) + 1\n : Math.max(lengths[here + width] ?? 0, lengths[here + 1] ?? 0)\n }\n }\n\n let i = 0\n let j = 0\n while (i < rows && j < columns) {\n if (sameAt(start + i, start + j)) {\n pairAt(start + i, start + j)\n i += 1\n j += 1\n continue\n }\n if ((lengths[(i + 1) * width + j] ?? 0) >= (lengths[i * width + j + 1] ?? 0)) i += 1\n else j += 1\n }\n}\n\nfunction matchUniqueWords(\n oldPieces: readonly MatchPiece[],\n newPieces: readonly MatchPiece[],\n pairs: Int32Array,\n oldUsed: Uint8Array,\n): void {\n const oldByText = new Map<string, number[]>()\n oldPieces.forEach(({ text }, index) => {\n if (oldUsed[index] || !WORD.test(text)) return\n const list = oldByText.get(text)\n if (list) list.push(index)\n else oldByText.set(text, [index])\n })\n const newByText = new Map<string, number[]>()\n newPieces.forEach(({ text }, index) => {\n if (pairs[index] !== -1 || !WORD.test(text)) return\n const list = newByText.get(text)\n if (list) list.push(index)\n else newByText.set(text, [index])\n })\n\n for (const [text, newIndices] of newByText) {\n const oldIndices = oldByText.get(text)\n if (!oldIndices || oldIndices.length !== newIndices.length) continue\n newIndices.forEach((newIndex, order) => {\n pairs[newIndex] = oldIndices[order] ?? -1\n })\n }\n}\n"],"mappings":";AAAA,IAAM,OAAO;AAIb,IAAM,kBAAkB;;;;;;;;;;;;AA6BxB,SAAgB,YACd,WACA,WACY;CACZ,MAAM,QAAQ,IAAI,WAAW,UAAU,MAAM,CAAC,CAAC,KAAK,EAAE;CACtD,MAAM,UAAU,IAAI,WAAW,UAAU,MAAM;CAC/C,WAAW,QAAQ,SAAS,GAAG,QAAQ,SAAS,GAAG,OAAO,OAAO;CAIjE,aAFgB,SAAS,UAAU,SAAS,UAAU,QAAQ,WAAW,CAGvE,GAFc,SAAS,UAAU,SAAS,UAAU,MAAM,WAAW,EAGrE,IACC,UAAU,aAAa,UAAU,SAAS,EAAE,SAAS,UAAU,SAAS,EAAE,OAC1E,UAAU,aAAa,KAAK,UAAU,UAAU,OAAO,OAAO,CACjE;CACA,iBAAiB,WAAW,WAAW,OAAO,OAAO;CACrD,OAAO;AACT;;AAGA,SAAS,QAAQ,QAAuC;CACtD,MAAM,wBAAQ,IAAI,IAAsB;CACxC,OAAO,SAAS,OAAO,UAAU;EAC/B,MAAM,OAAO,MAAM,IAAI,MAAM,GAAG;EAChC,IAAI,MAAM,KAAK,KAAK,KAAK;OACpB,MAAM,IAAI,MAAM,KAAK,CAAC,KAAK,CAAC;CACnC,CAAC;CACD,OAAO,MAAM,KAAK,MAAM,OAAO,IAAI,YAAY;EAC7C,MAAM,SAAmB,CAAC;EAC1B,IAAI,MAAM;EACV,KAAK,MAAM,SAAS,SAAS;GAC3B,MAAM,QAAQ,OAAO;GACrB,IAAI,OAAO,aAAa,IAAI,SAAS,GAAG,OAAO;GAC/C,OAAO,KAAK,IAAI,MAAM;GACtB,OAAO,OAAO,QAAQ;EACxB;EAC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Q,OAAO,MAAM,CAAC;CACjE;CAGF,IAAI,IAAI;CACR,IAAI,IAAI;CACR,OAAO,IAAI,QAAQ,IAAI,SAAS;EAC9B,IAAI,OAAO,QAAQ,GAAG,QAAQ,CAAC,GAAG;GAChC,OAAO,QAAQ,GAAG,QAAQ,CAAC;GAC3B,KAAK;GACL,KAAK;GACL;EACF;EACA,KAAK,SAAS,IAAI,KAAK,QAAQ,MAAM,OAAO,QAAQ,IAAI,QAAQ,IAAI,MAAM,IAAI,KAAK;OAC9E,KAAK;CACZ;AACF;AAEA,SAAS,iBACP,WACA,WACA,OACA,SACM;CACN,MAAM,4BAAY,IAAI,IAAsB;CAC5C,UAAU,SAAS,EAAE,QAAQ,UAAU;EACrC,IAAI,QAAQ,UAAU,CAAC,KAAK,KAAK,IAAI,GAAG;EACxC,MAAM,OAAO,UAAU,IAAI,IAAI;EAC/B,IAAI,MAAM,KAAK,KAAK,KAAK;OACpB,UAAU,IAAI,MAAM,CAAC,KAAK,CAAC;CAClC,CAAC;CACD,MAAM,4BAAY,IAAI,IAAsB;CAC5C,UAAU,SAAS,EAAE,QAAQ,UAAU;EACrC,IAAI,MAAM,WAAW,MAAM,CAAC,KAAK,KAAK,IAAI,GAAG;EAC7C,MAAM,OAAO,UAAU,IAAI,IAAI;EAC/B,IAAI,MAAM,KAAK,KAAK,KAAK;OACpB,UAAU,IAAI,MAAM,CAAC,KAAK,CAAC;CAClC,CAAC;CAED,KAAK,MAAM,CAAC,MAAM,eAAe,WAAW;EAC1C,MAAM,aAAa,UAAU,IAAI,IAAI;EACrC,IAAI,CAAC,cAAc,WAAW,WAAW,WAAW,QAAQ;EAC5D,WAAW,SAAS,UAAU,UAAU;GACtC,MAAM,YAAY,WAAW,UAAU;EACzC,CAAC;CACH;AACF"}
|
package/dist/morph-run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"morph-run.js","names":[],"sources":["../src/morph-run.ts"],"sourcesContent":["import type { MorphFrame, MorphPiece } from './morph-frame'\nimport { appendPieceSpan, whenAllFinished, type SpanPiece } from './piece-span'\n\nconst LAYER_CLASS = 'editor-morph-layer'\n// Entering text starts this blurred (px) and this far below its row (share of the row height).\nconst ENTER_BLUR_PX = 3\nconst ENTER_DROP = 0.18\nconst LEAVE_BLUR_PX = 2\n\n/** Where a piece is on screen right now, which may be part way through an earlier morph. */\nexport type VisualPiece = {\n readonly text: string\n readonly gapBefore: boolean\n readonly x: number\n readonly top: number\n readonly height: number\n readonly opacity: number\n /** Gaussian blur radius in px. */\n readonly blur: number\n readonly color: string | undefined\n readonly fontStyle: string | undefined\n readonly fontWeight: string | number | undefined\n}\n\nexport type MorphTiming = {\n readonly durationMs: number\n /** A `linear()` spring when the browser supports it; the move curve. */\n readonly moveEasing: string\n}\n\ntype Target = {\n readonly piece: MorphPiece\n readonly span: HTMLElement\n /** Offset from the final spot, opacity and blur the piece starts from. */\n readonly fromX: number\n readonly fromY: number\n readonly fromOpacity: number\n readonly fromBlur: number\n readonly animation: Animation | null\n}\n\ntype Leaving = {\n readonly visual: VisualPiece\n readonly span: HTMLElement\n readonly animation: Animation | null\n}\n\n/**\n * One morph from what is on screen to a new frame, drawn on an overlay above\n * the hidden rows. Every motion is a two-keyframe WAAPI animation with its\n * curve on the effect, so `getComputedTiming().progress` is the eased progress\n * and the current position of any piece is arithmetic: a later morph starts\n * each piece from where it is, without reading layout.\n */\nexport class MorphRun {\n private readonly layer: HTMLElement\n private readonly targets: Target[] = []\n private readonly leaving: Leaving[] = []\n private canceled = false\n private colorFrame = 0\n\n public constructor(\n host: HTMLElement,\n private readonly frame: MorphFrame,\n from: readonly VisualPiece[],\n pairs: Int32Array,\n timing: MorphTiming,\n onDone: () => void,\n ) {\n const document = host.ownerDocument\n this.layer = document.createElement('div')\n this.layer.className = LAYER_CLASS\n this.layer.setAttribute('aria-hidden', 'true')\n\n const used = new Uint8Array(from.length)\n for (const old of pairs) if (old >= 0) used[old] = 1\n from.forEach((visual, index) => {\n if (used[index] || visual.opacity <= 0.01) return\n this.leaving.push(this.leave(visual, timing))\n })\n const enterCount = pairs.reduce((count, old) => count + (old < 0 ? 1 : 0), 0)\n let enterOrder = 0\n const recolor: [HTMLElement, string][] = []\n frame.pieces.forEach((piece, index) => {\n const old = from[pairs[index] ?? -1]\n if (!old) {\n this.targets.push(this.enter(piece, enterOrder, enterCount, timing))\n enterOrder += 1\n return\n }\n const target = this.move(piece, old, frame.rowCount, timing)\n this.targets.push(target)\n const color = piece.color ?? old.color\n if (color && color !== old.color) recolor.push([target.span, color])\n })\n host.appendChild(this.layer)\n this.scheduleRecolor(recolor)\n this.whenSettled(onDone)\n }\n\n /** Every piece where it is drawn now, for the next morph to start from. */\n public visualPieces(): VisualPiece[] {\n const pieces = this.targets.map((target) => {\n const progress = easedProgress(target.animation)\n const remaining = 1 - progress\n return {\n ...visualOf(target.piece, target.span),\n x: target.piece.x + target.fromX * remaining,\n top: target.piece.top + target.fromY * remaining,\n opacity: target.fromOpacity + (1 - target.fromOpacity) * progress,\n blur: target.fromBlur * remaining,\n }\n })\n const leaving = this.leaving.map((entry) => {\n const progress = easedProgress(entry.animation)\n return {\n ...entry.visual,\n opacity: entry.visual.opacity * (1 - progress),\n blur: entry.visual.blur + (LEAVE_BLUR_PX - entry.visual.blur) * progress,\n }\n })\n return pieces.concat(leaving)\n }\n\n /** The frame this run settles on. */\n public get targetFrame(): MorphFrame {\n return this.frame\n }\n\n /** A later token pass coloured the new text; fade the overlay to it. */\n public recolor(colors: readonly (string | undefined)[]): void {\n this.targets.forEach((target, index) => {\n const color = colors[index]\n if (color && target.span.style.color !== color) target.span.style.color = color\n })\n }\n\n public cancel(): void {\n this.canceled = true\n cancelAnimationFrame(this.colorFrame)\n for (const target of this.targets) target.animation?.cancel()\n for (const entry of this.leaving) entry.animation?.cancel()\n this.layer.remove()\n }\n\n private move(piece: MorphPiece, old: VisualPiece, rowCount: number, timing: MorphTiming): Target {\n const span = this.span(piece, old.color ?? piece.color)\n const fromX = old.x - piece.x\n const fromY = old.top - piece.top\n const fromOpacity = old.opacity\n const fromBlur = old.blur\n if (Math.abs(fromX) < 0.5 && Math.abs(fromY) < 0.5 && fromOpacity >= 0.99 && fromBlur < 0.05) {\n return { piece, span, fromX: 0, fromY: 0, fromOpacity: 1, fromBlur: 0, animation: null }\n }\n // A downward wave: rows lower in the frame set off slightly later.\n const wave = rowCount > 1 ? piece.row / (rowCount - 1) : 0\n const delay = timing.durationMs * 0.1 * wave\n const animation = span.animate(\n [\n {\n transform: `translate(${fromX}px, ${fromY}px)`,\n opacity: fromOpacity,\n filter: `blur(${fromBlur}px)`,\n },\n { transform: 'translate(0, 0)', opacity: 1, filter: 'blur(0)' },\n ],\n {\n duration: timing.durationMs * 0.85,\n delay,\n easing: timing.moveEasing,\n fill: 'both',\n },\n )\n return { piece, span, fromX, fromY, fromOpacity, fromBlur, animation }\n }\n\n // New text arrives in reading order, like a stream, after the old text has made room.\n private enter(piece: MorphPiece, order: number, count: number, timing: MorphTiming): Target {\n const span = this.span(piece, piece.color)\n const spread = count > 1 ? order / (count - 1) : 0\n const drop = piece.height * ENTER_DROP\n const animation = span.animate(\n [\n { opacity: 0, filter: `blur(${ENTER_BLUR_PX}px)`, transform: `translateY(${drop}px)` },\n { opacity: 1, filter: 'blur(0)', transform: 'translateY(0)' },\n ],\n {\n duration: timing.durationMs * 0.4,\n delay: timing.durationMs * (0.22 + 0.4 * spread),\n easing: 'cubic-bezier(0.2, 0, 0, 1)',\n fill: 'both',\n },\n )\n return {\n piece,\n span,\n fromX: 0,\n fromY: drop,\n fromOpacity: 0,\n fromBlur: ENTER_BLUR_PX,\n animation,\n }\n }\n\n private leave(visual: VisualPiece, timing: MorphTiming): Leaving {\n const span = this.span(visual, visual.color)\n const animation = span.animate(\n [\n { opacity: visual.opacity, filter: `blur(${visual.blur}px)` },\n { opacity: 0, filter: `blur(${LEAVE_BLUR_PX}px)` },\n ],\n { duration: timing.durationMs * 0.25, easing: 'cubic-bezier(0.2, 0, 0, 1)', fill: 'both' },\n )\n return { visual, span, animation }\n }\n\n private span(piece: SpanPiece, color: string | undefined): HTMLElement {\n return appendPieceSpan(this.layer, piece, color)\n }\n\n private scheduleRecolor(recolor: readonly [HTMLElement, string][]): void {\n if (recolor.length === 0) return\n /**\n * @justification Colour changes ride a CSS transition, which needs the starting colour painted\n * first. One frame per morph, cancelled with the run.\n */\n this.colorFrame = requestAnimationFrame(() => {\n for (const [span, color] of recolor) span.style.color = color\n })\n }\n\n private whenSettled(onDone: () => void): void {\n const animations = this.targets\n .map((target) => target.animation)\n .concat(this.leaving.map((entry) => entry.animation))\n .filter((animation): animation is Animation => animation !== null)\n whenAllFinished(animations, () => this.canceled, onDone)\n }\n}\n\n/** The frame's pieces as they would stand with nothing animating. */\nexport function restingPieces(frame: MorphFrame): VisualPiece[] {\n return frame.pieces.map((piece) => ({ ...piece, opacity: 1, blur: 0 }))\n}\n\nfunction visualOf(piece: MorphPiece, span: HTMLElement): Omit<VisualPiece, 'opacity' | 'blur'> {\n return {\n text: piece.text,\n gapBefore: piece.gapBefore,\n x: piece.x,\n top: piece.top,\n height: piece.height,\n color: span.style.color || piece.color,\n fontStyle: piece.fontStyle,\n fontWeight: piece.fontWeight,\n }\n}\n\nfunction easedProgress(animation: Animation | null): number {\n if (!animation) return 1\n const progress = animation.effect?.getComputedTiming().progress\n if (progress === null || progress === undefined) return animation.playState === 'finished' ? 1 : 0\n return progress\n}\n\n/**\n * A damped spring sampled into a CSS `linear()` curve: a slight overshoot that\n * settles by the end of the animation. Falls back to an ease-out curve where\n * `linear()` is unsupported.\n */\nexport function springEasing(bounce: number, supportsLinear: boolean): string {\n if (!supportsLinear) return 'cubic-bezier(0.2, 0, 0, 1)'\n const damping = Math.min(0.99, Math.max(0.3, 1 - bounce))\n // Settles to within 0.1% at t = 1.\n const omega = Math.log(1000) / damping\n const damped = omega * Math.sqrt(1 - damping * damping)\n const samples: string[] = []\n const count = 40\n for (let index = 0; index <= count; index += 1) {\n const t = index / count\n const decay = Math.exp(-damping * omega * t)\n const value =\n index === count\n ? 1\n : 1 - decay * (Math.cos(damped * t) + ((damping * omega) / damped) * Math.sin(damped * t))\n samples.push(value.toFixed(4))\n }\n return `linear(${samples.join(', ')})`\n}\n"],"mappings":";;AAGA,IAAM,cAAc;AAEpB,IAAM,gBAAgB;AACtB,IAAM,aAAa;AACnB,IAAM,gBAAgB;;;;;;;;AA+CtB,IAAa,WAAb,MAAsB;CASD;CARnB;CACA,UAAqC,CAAC;CACtC,UAAsC,CAAC;CACvC,WAAmB;CACnB,aAAqB;CAErB,YACE,MACA,OACA,MACA,OACA,QACA,QACA;EALiB,KAAA,QAAA;EAMjB,MAAM,WAAW,KAAK;EACtB,KAAK,QAAQ,SAAS,cAAc,KAAK;EACzC,KAAK,MAAM,YAAY;EACvB,KAAK,MAAM,aAAa,eAAe,MAAM;EAE7C,MAAM,OAAO,IAAI,WAAW,KAAK,MAAM;EACvC,KAAK,MAAM,OAAO,OAAO,IAAI,OAAO,GAAG,KAAK,OAAO;EACnD,KAAK,SAAS,QAAQ,UAAU;GAC9B,IAAI,KAAK,UAAU,OAAO,WAAW,KAAM;GAC3C,KAAK,QAAQ,KAAK,KAAK,MAAM,QAAQ,MAAM,CAAC;EAC9C,CAAC;EACD,MAAM,aAAa,MAAM,QAAQ,OAAO,QAAQ,SAAS,MAAM,IAAI,IAAI,IAAI,CAAC;EAC5E,IAAI,aAAa;EACjB,MAAM,UAAmC,CAAC;EAC1C,MAAM,OAAO,SAAS,OAAO,UAAU;GACrC,MAAM,MAAM,KAAK,MAAM,UAAU;GACjC,IAAI,CAAC,KAAK;IACR,KAAK,QAAQ,KAAK,KAAK,MAAM,OAAO,YAAY,YAAY,MAAM,CAAC;IACnE,cAAc;IACd;GACF;GACA,MAAM,SAAS,KAAK,KAAK,OAAO,KAAK,MAAM,UAAU,MAAM;GAC3D,KAAK,QAAQ,KAAK,MAAM;GACxB,MAAM,QAAQ,MAAM,SAAS,IAAI;GACjC,IAAI,SA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Q,CAAC;EAC3C,MAAM,QACJ,UAAU,QACN,IACA,IAAI,SAAS,KAAK,IAAI,SAAS,CAAC,IAAM,UAAU,QAAS,SAAU,KAAK,IAAI,SAAS,CAAC;EAC5F,QAAQ,KAAK,MAAM,QAAQ,CAAC,CAAC;CAC/B;CACA,OAAO,UAAU,QAAQ,KAAK,IAAI,EAAE;AACtC"}
|
package/dist/motion.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"motion.js","names":[],"sources":["../src/motion.ts"],"
|
|
1
|
+
{"version":3,"file":"motion.js","names":[],"sources":["../src/motion.ts"],"mappings":";;AAOA,SAAgB,cAAc,SAAiD;CAE7E,OADa,QAAQ,cAAc,cAAc,aACpC,aAAa,kCAAkC,CAAC,CAAC,WAAW;AAC3E;AAEA,SAAgB,qBAAqB,SAAiD;CAEpF,QADY,QAAQ,cAAc,cAAc,aAAa,IAAA,EACjD,WAAW,6BAA6B,cAAc,KAAK;AACzE;;AAGA,SAAgB,aACd,UACA,UACa;CACb,MAAM,uBAAO,IAAI,IAAY;CAC7B,KAAK,MAAM,OAAO,SAAS,aAAa;EACtC,IAAI,IAAI,SAAS,UAAU,CAAC,iBAAiB,GAAG,GAAG;EACnD,IAAI,SAAS,MAAM,UAAU,MAAM,QAAQ,IAAI,aAAa,MAAM,MAAM,IAAI,WAAW,GACrF;EACF,KAAK,IAAI,IAAI,KAAK;CACpB;CACA,OAAO;AACT"}
|
package/dist/noise.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noise.js","names":[],"sources":["../src/noise.ts"],"
|
|
1
|
+
{"version":3,"file":"noise.js","names":[],"sources":["../src/noise.ts"],"mappings":";AACA,IAAM,SACJ;;AAGF,SAAgB,OAAO,MAAsB;CAC3C,MAAM,IAAI,KAAK,IAAI,IAAI,IAAI;CAC3B,OAAO,IAAI,KAAK,MAAM,CAAC;AACzB;;AAGA,SAAgB,SAAS,MAAc,MAAsB;CAC3D,IAAI,MAAM;CACV,KAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS,GAAG;EACnD,MAAM,OAAO,KAAK,UAAU;EAC5B,IAAI,KAAK,KAAK,CAAC,CAAC,WAAW,GAAG;GAC5B,OAAO;GACP;EACF;EACA,OAAO,OAAO,KAAK,MAAM,OAAO,OAAO,SAAS,QAAQ,KAAK,IAAI,EAAa,MAAM;CACtF;CACA,OAAO;AACT;AAIA,SAAgB,aAAa,GAAW,GAAmB;CACzD,OAAO,MAAO,WAAW,GAAG,CAAC,IAAI,MAAO,WAAW,IAAI,IAAI,KAAK,IAAI,IAAI,GAAG;AAC7E;AAEA,SAAS,WAAW,GAAW,GAAmB;CAChD,MAAM,KAAK,KAAK,MAAM,CAAC;CACvB,MAAM,KAAK,KAAK,MAAM,CAAC;CACvB,MAAM,KAAK,WAAW,IAAI,EAAE;CAC5B,MAAM,KAAK,WAAW,IAAI,EAAE;CAG5B,OAAO,KAFK,KAAK,cAAc,IAAI,EAAE,GAAG,cAAc,KAAK,GAAG,EAAE,GAAG,EAEvD,GADG,KAAK,cAAc,IAAI,KAAK,CAAC,GAAG,cAAc,KAAK,GAAG,KAAK,CAAC,GAAG,EAC7D,GAAQ,EAAE;AAC7B;AAEA,SAAS,cAAc,IAAY,IAAoB;CACrD,OAAO,OAAO,KAAK,QAAQ,KAAK,QAAQ,EAAG;AAC7C;AAEA,SAAS,WAAW,GAAmB;CACrC,OAAO,IAAI,KAAK,IAAI,IAAI;AAC1B;AAEA,SAAS,KAAK,GAAW,GAAW,GAAmB;CACrD,OAAO,KAAK,IAAI,KAAK;AACvB"}
|
package/dist/piece-span.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"piece-span.js","names":[],"sources":["../src/piece-span.ts"],"
|
|
1
|
+
{"version":3,"file":"piece-span.js","names":[],"sources":["../src/piece-span.ts"],"mappings":";AAUA,IAAM,cAAc;;AAGpB,SAAgB,gBACd,OACA,OACA,OACA,OAAO,MAAM,MACA;CACb,MAAM,OAAO,MAAM,cAAc,cAAc,MAAM;CACrD,KAAK,YAAY;CACjB,KAAK,cAAc;CACnB,MAAM,QAAQ,KAAK;CACnB,MAAM,OAAO,GAAG,MAAM,EAAE;CACxB,MAAM,MAAM,GAAG,MAAM,IAAI;CACzB,MAAM,SAAS,GAAG,MAAM,OAAO;CAC/B,MAAM,aAAa,GAAG,MAAM,OAAO;CACnC,IAAI,OAAO,MAAM,QAAQ;CACzB,IAAI,MAAM,WAAW,MAAM,YAAY,MAAM;CAC7C,IAAI,MAAM,eAAe,KAAA,GAAW,MAAM,aAAa,OAAO,MAAM,UAAU;CAC9E,MAAM,YAAY,IAAI;CACtB,OAAO;AACT;;AAGA,SAAgB,gBACd,YACA,YACA,QACM;CACN,MAAM,aAAa;EACjB,IAAI,CAAC,WAAW,GAAG,OAAO;CAC5B;CACA,IAAI,WAAW,WAAW,GAAG;;;;;EAK3B,eAAe,IAAI;EACnB;CACF;CACA,QAAa,WAAW,WAAW,KAAK,cAAc,UAAU,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI;AACtF"}
|
package/dist/reveal-run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reveal-run.js","names":[],"sources":["../src/reveal-run.ts"],"sourcesContent":["import type { MorphFrame } from './morph-frame'\nimport { hash01, scramble, spatialNoise } from './noise'\nimport type { ResolvedTransitionOptions } from './transition-options'\nimport { appendPieceSpan, whenAllFinished } from './piece-span'\n\nconst LAYER_CLASS = 'editor-file-transition-layer'\nconst CARET_CLASS = 'editor-file-transition-caret'\nconst CARET_BAR_CLASS = 'editor-file-transition-caret-bar'\n\n// A typed piece blurs in over this long, so the stream reads as smooth rather than stamped.\nconst APPEAR_MS = 160\n// The caret lingers at the end of its stream before fading.\nconst CARET_TAIL_MS = 260\n// A pause at each line end, in characters' worth of typing.\nconst LINE_END_CHARS = 3\n// Diffusion: the share of the run each piece spends noisy before it locks, and the cluster size\n// of the resolve-order field, in characters and rows.\nconst BAND = 0.24\nconst CLUSTER_COLUMNS = 12\nconst CLUSTER_ROWS = 5\n\ntype CaretPoint = {\n readonly at: number\n readonly x: number\n readonly top: number\n readonly height: number\n}\n\n/**\n * A file-open reveal drawn on an overlay above the hidden rows, with every motion a WAAPI\n * animation on opacity, filter or transform, so it keeps time on the compositor while the page\n * is busy opening the file. The modes differ only in when each piece appears and how:\n * `autoregressive` streams pieces in reading order at the typing rate, `token` stamps one piece\n * per `perTokenMs`, `parallel` streams every row at once from staggered starts, and `diffusion`\n * resolves scrambled pieces in spatial clusters.\n */\nexport class RevealRun {\n private readonly layer: HTMLElement\n private readonly spans: HTMLElement[] = []\n private readonly animations: Animation[] = []\n private canceled = false\n\n public constructor(\n host: HTMLElement,\n frame: MorphFrame,\n options: ResolvedTransitionOptions,\n widthOf: (text: string) => number,\n onDone: () => void,\n ) {\n this.layer = host.ownerDocument.createElement('div')\n this.layer.className = LAYER_CLASS\n this.layer.setAttribute('aria-hidden', 'true')\n for (const piece of frame.pieces)\n this.spans.push(appendPieceSpan(this.layer, piece, piece.color))\n\n if (options.mode === 'diffusion') this.diffuse(frame, options, widthOf)\n else this.stream(frame, options, widthOf)\n\n host.appendChild(this.layer)\n whenAllFinished(this.animations, () => this.canceled, onDone)\n }\n\n /** A later token pass coloured the text; the overlay fades to it. */\n public recolor(colors: readonly (string | undefined)[]): void {\n this.spans.forEach((span, index) => {\n const color = colors[index]\n if (color && span.style.color !== color) span.style.color = color\n })\n }\n\n public cancel(): void {\n this.canceled = true\n for (const animation of this.animations) animation.cancel()\n this.layer.remove()\n }\n\n private stream(\n frame: MorphFrame,\n options: ResolvedTransitionOptions,\n widthOf: (text: string) => number,\n ): void {\n const times = capTimes(streamTimes(frame, options), options.maxDurationMs - APPEAR_MS)\n const stamped = options.mode === 'token'\n frame.pieces.forEach((_, index) => {\n const span = this.spans[index]\n if (!span) return\n this.animations.push(\n stamped\n ? span.animate([{ opacity: 0 }, { opacity: 1 }], {\n duration: 1,\n delay: times[index] ?? 0,\n easing: 'steps(1, jump-start)',\n fill: 'both',\n })\n : span.animate(\n [\n { opacity: 0, filter: 'blur(3px)', transform: 'translateY(0.15em)' },\n { opacity: 1, filter: 'blur(0)', transform: 'translateY(0)' },\n ],\n {\n duration: APPEAR_MS,\n delay: times[index] ?? 0,\n easing: 'cubic-bezier(0.2, 0, 0, 1)',\n fill: 'both',\n },\n ),\n )\n })\n for (const track of caretTracks(frame, times, options.mode, widthOf)) this.caret(track)\n }\n\n // Each piece shows two scrambles in turn while its cluster is noisy, then sharpens into its\n // text. The scrambles are fixed strings; only their opacity animates.\n private diffuse(\n frame: MorphFrame,\n options: ResolvedTransitionOptions,\n widthOf: (text: string) => number,\n ): void {\n const run = options.maxDurationMs\n const columnWidth = Math.max(1, widthOf('0'))\n frame.pieces.forEach((piece, index) => {\n const span = this.spans[index]\n if (!span) return\n const field = spatialNoise(piece.x / columnWidth / CLUSTER_COLUMNS, piece.row / CLUSTER_ROWS)\n const bandStart = (1 - BAND) * field * run\n const band = BAND * run\n const timing = { duration: band, delay: bandStart, fill: 'both' as const }\n for (const [variant, frames] of NOISE_FRAMES.entries()) {\n const noise = appendPieceSpan(\n this.layer,\n piece,\n piece.color,\n scramble(piece.text, index * 7 + variant),\n )\n this.animations.push(noise.animate(frames, timing))\n }\n this.animations.push(\n span.animate(\n [\n { opacity: 0, filter: 'blur(2px)', offset: 0 },\n { opacity: 0, filter: 'blur(2px)', offset: 0.62 },\n { opacity: 1, filter: 'blur(0)', offset: 1 },\n ],\n { ...timing, easing: 'cubic-bezier(0.2, 0, 0, 1)' },\n ),\n )\n })\n }\n\n private caret(track: readonly CaretPoint[]): void {\n const first = track[0]\n const last = track.at(-1)\n if (!first || !last) return\n const caret = this.layer.ownerDocument.createElement('div')\n caret.className = CARET_CLASS\n caret.style.height = `${first.height}px`\n const bar = this.layer.ownerDocument.createElement('div')\n bar.className = CARET_BAR_CLASS\n caret.appendChild(bar)\n this.layer.appendChild(caret)\n\n const start = first.at\n const span = Math.max(1, last.at - start + CARET_TAIL_MS)\n const keyframes: Keyframe[] = track.map((point) => ({\n transform: `translate(${point.x}px, ${point.top}px)`,\n offset: (point.at - start) / span,\n easing: 'step-end',\n }))\n keyframes.push({ transform: `translate(${last.x}px, ${last.top}px)`, offset: 1 })\n const timing = { duration: span, delay: start, fill: 'both' as const }\n this.animations.push(caret.animate(keyframes, timing))\n this.animations.push(\n caret.animate(\n [\n { opacity: 0, offset: 0 },\n { opacity: 1, offset: 0.02 },\n { opacity: 1, offset: 1 - CARET_TAIL_MS / span / 2 },\n { opacity: 0, offset: 1 },\n ],\n timing,\n ),\n )\n }\n}\n\n// Two scrambles, each shown for half the noisy band, faint then brighter as the piece resolves.\nconst NOISE_FRAMES: readonly Keyframe[][] = [\n [\n { opacity: 0, offset: 0 },\n { opacity: 0.35, offset: 0.08 },\n { opacity: 0.35, offset: 0.34 },\n { opacity: 0, offset: 0.34 },\n { opacity: 0, offset: 1 },\n ],\n [\n { opacity: 0, offset: 0 },\n { opacity: 0, offset: 0.34 },\n { opacity: 0.6, offset: 0.34 },\n { opacity: 0.6, offset: 0.62 },\n { opacity: 0, offset: 0.7 },\n { opacity: 0, offset: 1 },\n ],\n]\n\n/** When each piece starts to appear, before the cap. */\nfunction streamTimes(frame: MorphFrame, options: ResolvedTransitionOptions): number[] {\n if (options.mode === 'token') return frame.pieces.map((_, index) => index * options.perTokenMs)\n if (options.mode === 'parallel') return parallelTimes(frame, options)\n\n // Autoregressive: one typist, in reading order, the whitespace between pieces typed too.\n const times: number[] = []\n let typed = 0\n let row = -1\n let rowEnd = 0\n for (const piece of frame.pieces) {\n if (piece.row !== row) {\n if (row >= 0) typed += LINE_END_CHARS\n row = piece.row\n rowEnd = piece.offset\n }\n typed += piece.offset - rowEnd\n times.push(typed * options.perCharMs)\n typed += piece.text.length\n rowEnd = piece.offset + piece.text.length\n }\n return times\n}\n\n// Each row starts at a jittered offset and types at a slightly varied speed, so the rows'\n// carets scatter across columns instead of advancing in lockstep. A row starts typing at its\n// first piece, past the indent. The jitter is a hash of the row, never Math.random, so a reveal\n// is reproducible.\nfunction parallelTimes(frame: MorphFrame, options: ResolvedTransitionOptions): number[] {\n let row = -1\n let rowStart = 0\n return frame.pieces.map((piece) => {\n if (piece.row !== row) {\n row = piece.row\n rowStart = piece.offset\n }\n const start = hash01(row * 12.9898 + 1.3) * options.staggerMs\n const speed = 0.8 + 0.4 * hash01(row * 78.233 + 2.7)\n return start + (piece.offset - rowStart) * options.perCharMs * speed\n })\n}\n\n/** Scales every time down so the last piece starts by `limit`. */\nfunction capTimes(times: readonly number[], limit: number): number[] {\n const last = times.reduce((max, time) => Math.max(max, time), 0)\n if (last <= limit || last === 0) return times.slice()\n const factor = Math.max(0, limit) / last\n return times.map((time) => time * factor)\n}\n\n/** Where each stream's caret stands after each of its pieces appears. */\nfunction caretTracks(\n frame: MorphFrame,\n times: readonly number[],\n mode: ResolvedTransitionOptions['mode'],\n widthOf: (text: string) => number,\n): CaretPoint[][] {\n const tracks = new Map<number, CaretPoint[]>()\n frame.pieces.forEach((piece, index) => {\n const key = mode === 'parallel' ? piece.row : 0\n const track = tracks.get(key) ?? []\n if (track.length === 0) tracks.set(key, track)\n track.push({\n at: times[index] ?? 0,\n x: piece.x + widthOf(piece.text),\n top: piece.top,\n height: piece.height,\n })\n })\n return Array.from(tracks.values())\n}\n"],"mappings":";;;AAKA,IAAM,cAAc;AACpB,IAAM,cAAc;AACpB,IAAM,kBAAkB;AAGxB,IAAM,YAAY;AAElB,IAAM,gBAAgB;AAEtB,IAAM,iBAAiB;AAGvB,IAAM,OAAO;AACb,IAAM,kBAAkB;AACxB,IAAM,eAAe;;;;;;;;;AAiBrB,IAAa,YAAb,MAAuB;CACrB;CACA,QAAwC,CAAC;CACzC,aAA2C,CAAC;CAC5C,WAAmB;CAEnB,YACE,MACA,OACA,SACA,SACA,QACA;EACA,KAAK,QAAQ,KAAK,cAAc,cAAc,KAAK;EACnD,KAAK,MA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AO,KAAK,UAAU;EACjC,IAAI,MAAM,QAAQ,KAAK;GACrB,MAAM,MAAM;GACZ,WAAW,MAAM;EACnB;EACA,MAAM,QAAQ,OAAO,MAAM,UAAU,GAAG,IAAI,QAAQ;EACpD,MAAM,QAAQ,KAAM,KAAM,OAAO,MAAM,SAAS,GAAG;EACnD,OAAO,SAAS,MAAM,SAAS,YAAY,QAAQ,YAAY;CACjE,CAAC;AACH;;AAGA,SAAS,SAAS,OAA0B,OAAyB;CACnE,MAAM,OAAO,MAAM,QAAQ,KAAK,SAAS,KAAK,IAAI,KAAK,IAAI,GAAG,CAAC;CAC/D,IAAI,QAAQ,SAAS,SAAS,GAAG,OAAO,MAAM,MAAM;CACpD,MAAM,SAAS,KAAK,IAAI,GAAG,KAAK,IAAI;CACpC,OAAO,MAAM,KAAK,SAAS,OAAO,MAAM;AAC1C;;AAGA,SAAS,YACP,OACA,OACA,MACA,SACgB;CAChB,MAAM,yBAAS,IAAI,IAA0B;CAC7C,MAAM,OAAO,SAAS,OAAO,UAAU;EACrC,MAAM,MAAM,SAAS,aAAa,MAAM,MAAM;EAC9C,MAAM,QAAQ,OAAO,IAAI,GAAG,KAAK,CAAC;EAClC,IAAI,MAAM,WAAW,GAAG,OAAO,IAAI,KAAK,KAAK;EAC7C,MAAM,KAAK;GACT,IAAI,MAAM,UAAU;GACpB,GAAG,MAAM,IAAI,QAAQ,MAAM,IAAI;GAC/B,KAAK,MAAM;GACX,QAAQ,MAAM;EAChB,CAAC;CACH,CAAC;CACD,OAAO,MAAM,KAAK,OAAO,OAAO,CAAC;AACnC"}
|
package/dist/row-cover.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"row-cover.js","names":[],"sources":["../src/row-cover.ts"],"
|
|
1
|
+
{"version":3,"file":"row-cover.js","names":[],"sources":["../src/row-cover.ts"],"mappings":";;;;;;;;;;AA2BA,IAAa,WAAb,MAAsB;CAIgB;CAHpC,yBAA0B,IAAI,IAA4B;CAC1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O,GAAG;GAC5B,IAAI,aAAa,QAAQ;GACzB;EACF;EACA,MAAM,YAAY,QAAQ,QAAQ,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,GAAG;GAClE,UAAU,OAAO;GACjB,MAAM;EACR,CAAC;EACD,MAAM,QAAQ;GAAE,OAAO,IAAI;GAAO,cAAc,IAAI;GAAc;EAAU;EAC5E,KAAK,OAAO,IAAI,SAAS,KAAK;EAC9B,IAAI,aAAa,OAAO,iBAAiB,eAAe,KAAK,KAAK,SAAS,KAAK,GAAG,EACjF,MAAM,KACR,CAAC;CACH;CAEA,KAAa,SAAsB,OAAwB;EACzD,IAAI,KAAK,OAAO,IAAI,OAAO,MAAM,OAAO;EACxC,KAAK,OAAO,OAAO,OAAO;EAC1B,MAAM,UAAU,OAAO;EACvB,MAAM,aAAa,QAAQ;CAC7B;AACF"}
|
package/dist/row-moves.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"row-moves.js","names":[],"sources":["../src/row-moves.ts"],"
|
|
1
|
+
{"version":3,"file":"row-moves.js","names":[],"sources":["../src/row-moves.ts"],"mappings":";;;;;;AAaA,IAAa,WAAb,MAAsB;CACpB,WAA4C,CAAC;CAE7C,YACE,SACA,MACA,QACA;EACA,KAAK,MAAM,QAAQ,MAAM;GACvB,MAAM,eAAe,QAAQ,mBAAmB,KAAK,KAAK;GAC1D,IAAI,CAAC,cAAc;GACnB,MAAM,YAAY,WAAW,aAAa,SAAS,MAAM,MAAM;GAC/D,IAAI,CAAC,WAAW;IACd,aAAa,QAAQ;IACrB;GACF;GAEA,MAAM,gBAAgB;IACpB,UAAU,OAAO;IACjB,aAAa,QAAQ;GACvB;GACA,aAAa,OAAO,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;GACrE,UAAU,SAAS,WACX,aAAa,QAAQ,SACrB,KAAA,CACR;GACA,KAAK,SAAS,KAAK,OAAO;EAC5B;CACF;CAEA,SAAsB;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IAAI,IAAI,MAAM,MAAM,KAAK,IAAI;EAAI,IAAI;EAC1E,MAAM,KAAK;GAAE,OAAO,IAAI;GAAO;EAAO,CAAC;CACzC;CACA,OAAO;EAAE;EAAO;CAAM;AACxB;AAEA,SAAS,YACP,YACA,KACA,OACmB;CACnB,IAAI,OAA0B;CAC9B,KAAK,MAAM,aAAa,cAAc,CAAC,GAAG;EACxC,IAAI,MAAM,IAAI,UAAU,KAAK,GAAG;EAChC,IAAI,CAAC,QAAQ,KAAK,IAAI,UAAU,MAAM,GAAG,IAAI,KAAK,IAAI,KAAK,MAAM,GAAG,GAAG,OAAO;CAChF;CACA,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transition-options.js","names":[],"sources":["../src/transition-options.ts"],"
|
|
1
|
+
{"version":3,"file":"transition-options.js","names":[],"sources":["../src/transition-options.ts"],"mappings":";AA8CA,IAAM,WAAsC;CAC1C,MAAM;CAEN,WAAW;CAEX,YAAY;CACZ,OAAO;CACP,eAAe;CACf,WAAW;CACX,SAAS;AACX;AAEA,SAAgB,yBACd,SAC2B;CAC3B,OAAO;EACL,MAAM,YAAY,QAAQ,IAAI;EAC9B,WAAW,eAAe,QAAQ,WAAW,SAAS,SAAS;EAC/D,YAAY,eAAe,QAAQ,YAAY,SAAS,UAAU;EAClE,OAAO,eAAe,QAAQ,OAAO,SAAS,KAAK;EACnD,eAAe,eAAe,QAAQ,eAAe,SAAS,aAAa;EAC3E,WAAW,kBAAkB,QAAQ,WAAW,SAAS,SAAS;EAClE,SAAS,KAAK,MAAM,eAAe,QAAQ,SAAS,SAAS,OAAO,CAAC;CACvE;AACF;AAEA,SAAS,YAAY,MAA0D;CAC7E,IAAI,SAAS,cAAc,SAAS,eAAe,SAAS,WAAW,SAAS,aAC9E,OAAO;CACT,OAAO,SAAS;AAClB;AAEA,SAAS,eAAe,OAA2B,UAA0B;CAC3E,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,IAAI,CAAC,OAAO,SAAS,KAAK,KAAK,SAAS,GAAG,OAAO;CAClD,OAAO;AACT;AAEA,SAAS,kBAAkB,OAA2B,UAA0B;CAC9E,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,IAAI,CAAC,OAAO,SAAS,KAAK,KAAK,QAAQ,GAAG,OAAO;CACjD,OAAO;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@singapore-editor/file-animation",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.15",
|
|
4
4
|
"description": "Text reveal animations for documents opened in the Singapore editor.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"animation",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"format:check": "oxfmt --check ."
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@singapore-editor/core": "0.2.
|
|
52
|
+
"@singapore-editor/core": "0.2.14"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"happy-dom": "^20.14.5",
|