@pairdraw/core 0.16.0 → 0.16.1
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/README.md +1 -1
- package/dist/ai/providers.d.ts +6 -1
- package/dist/ai/providers.d.ts.map +1 -1
- package/dist/ai/providers.js +9 -0
- package/dist/ai/providers.js.map +1 -1
- package/dist/canvas/highlight-rect.d.ts +10 -1
- package/dist/canvas/highlight-rect.d.ts.map +1 -1
- package/dist/canvas/highlight-rect.js +16 -8
- package/dist/canvas/highlight-rect.js.map +1 -1
- package/dist/canvas/index.d.ts +2 -3
- package/dist/canvas/index.js +1 -2
- package/dist/canvas/issues/draw.d.ts +2 -6
- package/dist/canvas/issues/draw.d.ts.map +1 -1
- package/dist/canvas/issues/draw.js +2 -99
- package/dist/canvas/issues/draw.js.map +1 -1
- package/dist/canvas/issues/types.d.ts +2 -33
- package/dist/canvas/issues/types.d.ts.map +1 -1
- package/dist/canvas/overlays/{ai.d.ts → ai/draw.d.ts} +3 -3
- package/dist/canvas/overlays/ai/draw.d.ts.map +1 -0
- package/dist/canvas/overlays/ai/draw.js +102 -0
- package/dist/canvas/overlays/ai/draw.js.map +1 -0
- package/dist/canvas/overlays/ai/motion.d.ts +23 -0
- package/dist/canvas/overlays/ai/motion.d.ts.map +1 -0
- package/dist/canvas/overlays/ai/motion.js +32 -0
- package/dist/canvas/overlays/ai/motion.js.map +1 -0
- package/dist/canvas/renderer/methods.js +1 -1
- package/dist/canvas/renderer/methods.js.map +1 -1
- package/dist/canvas/renderer/overlay-pass.d.ts.map +1 -1
- package/dist/canvas/renderer/overlay-pass.js +2 -47
- package/dist/canvas/renderer/overlay-pass.js.map +1 -1
- package/dist/canvas/renderer/pipeline.js +1 -1
- package/dist/canvas/renderer/pipeline.js.map +1 -1
- package/dist/canvas/renderer/state.d.ts +5 -3
- package/dist/canvas/renderer/state.d.ts.map +1 -1
- package/dist/canvas/renderer/state.js +18 -6
- package/dist/canvas/renderer/state.js.map +1 -1
- package/dist/canvas/renderer/types.d.ts +2 -2
- package/dist/canvas/renderer/types.d.ts.map +1 -1
- package/dist/canvas/renderer.d.ts +12 -8
- package/dist/canvas/renderer.d.ts.map +1 -1
- package/dist/canvas/renderer.js +9 -9
- package/dist/canvas/renderer.js.map +1 -1
- package/dist/canvas/text/preparation/cache.d.ts +5 -0
- package/dist/canvas/text/preparation/cache.d.ts.map +1 -1
- package/dist/canvas/text/preparation/cache.js +8 -1
- package/dist/canvas/text/preparation/cache.js.map +1 -1
- package/dist/constants.d.ts +13 -18
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +16 -21
- package/dist/constants.js.map +1 -1
- package/dist/design-jsx/index.d.ts +2 -2
- package/dist/design-jsx/index.js +2 -2
- package/dist/design-jsx/preview/picture.d.ts +12 -5
- package/dist/design-jsx/preview/picture.d.ts.map +1 -1
- package/dist/design-jsx/preview/picture.js +40 -15
- package/dist/design-jsx/preview/picture.js.map +1 -1
- package/dist/editor/bridges/undo.d.ts +1 -1
- package/dist/editor/create.d.ts +3 -6
- package/dist/editor/create.d.ts.map +1 -1
- package/dist/editor/history/atomic-tool.d.ts.map +1 -1
- package/dist/editor/history/atomic-tool.js +11 -8
- package/dist/editor/history/atomic-tool.js.map +1 -1
- package/dist/editor/history/document-change.d.ts +9 -1
- package/dist/editor/history/document-change.d.ts.map +1 -1
- package/dist/editor/history/document-change.js +100 -2
- package/dist/editor/history/document-change.js.map +1 -1
- package/dist/editor/history/snapshot/graph.d.ts +15 -3
- package/dist/editor/history/snapshot/graph.d.ts.map +1 -1
- package/dist/editor/history/snapshot/graph.js +29 -8
- package/dist/editor/history/snapshot/graph.js.map +1 -1
- package/dist/editor/index.d.ts +3 -3
- package/dist/editor/index.js +3 -3
- package/dist/editor/issues.d.ts +1 -4
- package/dist/editor/issues.d.ts.map +1 -1
- package/dist/editor/issues.js +5 -44
- package/dist/editor/issues.js.map +1 -1
- package/dist/editor/nudge.js +3 -2
- package/dist/editor/nudge.js.map +1 -1
- package/dist/editor/read-only/actions.js +0 -3
- package/dist/editor/read-only/actions.js.map +1 -1
- package/dist/editor/state/shared.js +1 -1
- package/dist/editor/state/shared.js.map +1 -1
- package/dist/editor/types.d.ts +7 -4
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/io/formats/design-tokens/apply.d.ts +1 -1
- package/dist/io/subgraph.d.ts +5 -2
- package/dist/io/subgraph.d.ts.map +1 -1
- package/dist/io/subgraph.js +6 -2
- package/dist/io/subgraph.js.map +1 -1
- package/dist/layout/mutations.d.ts +1 -1
- package/dist/layout/mutations.d.ts.map +1 -1
- package/dist/layout/mutations.js +1 -1
- package/dist/layout/mutations.js.map +1 -1
- package/dist/text/font/faces.js +1 -1
- package/dist/text/font/faces.js.map +1 -1
- package/dist/text/web-font/providers.d.ts +2 -11
- package/dist/text/web-font/providers.d.ts.map +1 -1
- package/dist/text/web-font/providers.js +8 -7
- package/dist/text/web-font/providers.js.map +1 -1
- package/dist/tools/analyze/diff/jsx.d.ts +2 -1
- package/dist/tools/analyze/diff/jsx.d.ts.map +1 -1
- package/dist/tools/analyze/diff/jsx.js +4 -2
- package/dist/tools/analyze/diff/jsx.js.map +1 -1
- package/package.json +24 -9
- package/src/ai/providers.ts +15 -1
- package/src/canvas/highlight-rect.ts +30 -9
- package/src/canvas/index.ts +1 -15
- package/src/canvas/issues/draw.ts +2 -165
- package/src/canvas/issues/types.ts +1 -36
- package/src/canvas/overlays/ai/draw.ts +129 -0
- package/src/canvas/overlays/ai/motion.ts +46 -0
- package/src/canvas/renderer/methods.ts +1 -1
- package/src/canvas/renderer/overlay-pass.ts +2 -49
- package/src/canvas/renderer/pipeline.ts +1 -1
- package/src/canvas/renderer/state.ts +20 -5
- package/src/canvas/renderer/types.ts +2 -2
- package/src/canvas/renderer.ts +9 -10
- package/src/canvas/text/preparation/cache.ts +9 -1
- package/src/constants.ts +12 -17
- package/src/design-jsx/index.ts +1 -1
- package/src/design-jsx/preview/picture.ts +55 -18
- package/src/editor/history/atomic-tool.ts +15 -8
- package/src/editor/history/document-change.ts +117 -1
- package/src/editor/history/snapshot/graph.ts +48 -8
- package/src/editor/index.ts +10 -2
- package/src/editor/issues.ts +6 -36
- package/src/editor/nudge.ts +4 -2
- package/src/editor/read-only/actions.ts +0 -3
- package/src/editor/state/shared.ts +1 -1
- package/src/editor/types.ts +6 -4
- package/src/io/subgraph.ts +10 -5
- package/src/layout/mutations.ts +2 -2
- package/src/text/font/faces.ts +1 -1
- package/src/text/web-font/providers.ts +19 -13
- package/src/tools/analyze/diff/jsx.ts +10 -5
- package/dist/canvas/issues/layout.d.ts +0 -37
- package/dist/canvas/issues/layout.d.ts.map +0 -1
- package/dist/canvas/issues/layout.js +0 -303
- package/dist/canvas/issues/layout.js.map +0 -1
- package/dist/canvas/overlays/ai.d.ts.map +0 -1
- package/dist/canvas/overlays/ai.js +0 -26
- package/dist/canvas/overlays/ai.js.map +0 -1
- package/src/canvas/issues/layout.ts +0 -376
- package/src/canvas/overlays/ai.ts +0 -34
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","names":[],"sources":["../../../src/canvas/renderer/state.ts"],"sourcesContent":["import type { SceneNode } from '@pairdraw/scene-graph'\n\nimport type { SkiaRenderer } from '#core/canvas/renderer'\nimport { changesShaping } from '#core/canvas/text/paragraph/inputs'\n\nexport function invalidateScenePicture(r: SkiaRenderer): void {\n r.scenePicture?.delete()\n r.scenePicture = null\n r.scenePictureVersion = -1\n r.scenePictureFontGeneration = -1\n r.sceneBacking?.image.delete()\n r.sceneBacking = null\n r.sceneBackingBuild?.surface.delete()\n r.sceneBackingBuild = null\n}\n\nexport function clearSubtreePictureCache(r: SkiaRenderer): void {\n for (const entry of r.subtreePictureCache.values()) entry.picture.delete()\n r.subtreePictureCache.clear()\n r.subtreePictureCachePageId = null\n r.subtreePictureCacheSceneVersion = -1\n r.subtreePictureCachePositionPreviewVersion = -1\n r.subtreePictureCacheFontGeneration = -1\n}\n\nexport function invalidateAllPictures(r: SkiaRenderer): void {\n r.textPreparationCache.clear()\n invalidateScenePicture(r)\n r.tiledScene.invalidateStructure()\n for (const pic of r.nodePictureCache.values()) pic?.delete()\n r.nodePictureCache.clear()\n r.nodePictureCacheGenerations.clear()\n r.effectRasterCache.clear()\n clearSubtreePictureCache(r)\n}\n\nexport function invalidateNodePicture(\n r: SkiaRenderer,\n nodeId: string,\n changedKeys?: readonly (keyof SceneNode)[]\n): void {\n r.textPreparationCache.deleteNode(nodeId, {\n keepShaping: changedKeys !== undefined && !changesShaping(changedKeys)\n })\n r.effectRasterCache.delete(nodeId)\n const pic = r.nodePictureCache.get(nodeId)\n if (pic) {\n pic.delete()\n r.nodePictureCache.delete(nodeId)\n r.nodePictureCacheGenerations.delete(nodeId)\n }\n const subtree = r.subtreePictureCache.get(nodeId)\n if (subtree) {\n subtree.picture.delete()\n r.subtreePictureCache.delete(nodeId)\n }\n}\n\nexport function flashNode(r: SkiaRenderer, nodeId: string): void {\n r._flashes.push({ nodeId, startTime: performance.now() })\n}\n\nexport function aiMarkActive(r: SkiaRenderer, nodeIds: string[]): void {\n for (const id of nodeIds) r._aiActiveNodes.add(id)\n}\n\nexport function aiMarkDone(r: SkiaRenderer, nodeIds: string[]): void {\n const now = performance.now()\n for (const id of nodeIds) {\n if (r._aiActiveNodes.delete(id)) {\n r._aiDoneFlashes.push({ nodeId: id, startTime: now })\n }\n }\n}\n\nexport function aiFlashDone(r: SkiaRenderer, nodeIds: string[]): void {\n const now = performance.now()\n for (const id of nodeIds) {\n r._aiDoneFlashes.push({ nodeId: id, startTime: now })\n }\n}\n\nexport function
|
|
1
|
+
{"version":3,"file":"state.js","names":[],"sources":["../../../src/canvas/renderer/state.ts"],"sourcesContent":["import type { SceneNode } from '@pairdraw/scene-graph'\n\nimport { entranceDelays } from '#core/canvas/overlays/ai/motion'\nimport type { SkiaRenderer } from '#core/canvas/renderer'\nimport { changesShaping } from '#core/canvas/text/paragraph/inputs'\n\nexport function invalidateScenePicture(r: SkiaRenderer): void {\n r.scenePicture?.delete()\n r.scenePicture = null\n r.scenePictureVersion = -1\n r.scenePictureFontGeneration = -1\n r.sceneBacking?.image.delete()\n r.sceneBacking = null\n r.sceneBackingBuild?.surface.delete()\n r.sceneBackingBuild = null\n}\n\nexport function clearSubtreePictureCache(r: SkiaRenderer): void {\n for (const entry of r.subtreePictureCache.values()) entry.picture.delete()\n r.subtreePictureCache.clear()\n r.subtreePictureCachePageId = null\n r.subtreePictureCacheSceneVersion = -1\n r.subtreePictureCachePositionPreviewVersion = -1\n r.subtreePictureCacheFontGeneration = -1\n}\n\nexport function invalidateAllPictures(r: SkiaRenderer, { keepShapedText = false } = {}): void {\n if (keepShapedText) r.textPreparationCache.releaseLayers()\n else r.textPreparationCache.clear()\n invalidateScenePicture(r)\n r.tiledScene.invalidateStructure()\n for (const pic of r.nodePictureCache.values()) pic?.delete()\n r.nodePictureCache.clear()\n r.nodePictureCacheGenerations.clear()\n r.effectRasterCache.clear()\n clearSubtreePictureCache(r)\n}\n\nexport function invalidateNodePicture(\n r: SkiaRenderer,\n nodeId: string,\n changedKeys?: readonly (keyof SceneNode)[]\n): void {\n r.textPreparationCache.deleteNode(nodeId, {\n keepShaping: changedKeys !== undefined && !changesShaping(changedKeys)\n })\n r.effectRasterCache.delete(nodeId)\n const pic = r.nodePictureCache.get(nodeId)\n if (pic) {\n pic.delete()\n r.nodePictureCache.delete(nodeId)\n r.nodePictureCacheGenerations.delete(nodeId)\n }\n const subtree = r.subtreePictureCache.get(nodeId)\n if (subtree) {\n subtree.picture.delete()\n r.subtreePictureCache.delete(nodeId)\n }\n}\n\nexport function flashNode(r: SkiaRenderer, nodeId: string): void {\n r._flashes.push({ nodeId, startTime: performance.now() })\n}\n\nexport function aiMarkActive(r: SkiaRenderer, nodeIds: string[]): void {\n for (const id of nodeIds) r._aiActiveNodes.add(id)\n}\n\nexport function aiMarkDone(r: SkiaRenderer, nodeIds: string[]): void {\n const now = performance.now()\n for (const id of nodeIds) {\n if (r._aiActiveNodes.delete(id)) {\n r._aiDoneFlashes.push({ nodeId: id, startTime: now })\n }\n }\n}\n\nexport function aiFlashDone(r: SkiaRenderer, nodeIds: string[]): void {\n const now = performance.now()\n for (const id of nodeIds) {\n r._aiDoneFlashes.push({ nodeId: id, startTime: now })\n }\n}\n\nexport function aiEnter(r: SkiaRenderer, nodeIds: string[]): void {\n const now = performance.now()\n const entering = new Set(nodeIds)\n // A layer added again before it finished tracing starts over rather than tracing twice.\n r._aiEntrances = r._aiEntrances.filter((entrance) => !entering.has(entrance.nodeId))\n const delays = entranceDelays(nodeIds.length)\n nodeIds.forEach((nodeId, index) => {\n r._aiEntrances.push({ nodeId, startTime: now + (delays[index] ?? 0) })\n })\n}\n\nexport function aiClearAll(r: SkiaRenderer): void {\n r._aiActiveNodes.clear()\n r._aiDoneFlashes = []\n r._aiEntrances = []\n}\n\nexport function hasActiveFlashes(r: SkiaRenderer): boolean {\n return (\n r._flashes.length > 0 ||\n r._aiActiveNodes.size > 0 ||\n r._aiDoneFlashes.length > 0 ||\n r._aiEntrances.length > 0\n )\n}\n"],"mappings":";;;AAMA,SAAgB,uBAAuB,GAAuB;CAC5D,EAAE,cAAc,OAAO;CACvB,EAAE,eAAe;CACjB,EAAE,sBAAsB;CACxB,EAAE,6BAA6B;CAC/B,EAAE,cAAc,MAAM,OAAO;CAC7B,EAAE,eAAe;CACjB,EAAE,mBAAmB,QAAQ,OAAO;CACpC,EAAE,oBAAoB;AACxB;AAEA,SAAgB,yBAAyB,GAAuB;CAC9D,KAAK,MAAM,SAAS,EAAE,oBAAoB,OAAO,GAAG,MAAM,QAAQ,OAAO;CACzE,EAAE,oBAAoB,MAAM;CAC5B,EAAE,4BAA4B;CAC9B,EAAE,kCAAkC;CACpC,EAAE,4CAA4C;CAC9C,EAAE,oCAAoC;AACxC;AAEA,SAAgB,sBAAsB,GAAiB,EAAE,iBAAiB,UAAU,CAAC,GAAS;CAC5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EAAE,QAAQ;EAAI,WAAW;CAAI,CAAC;AAExD;AAEA,SAAgB,QAAQ,GAAiB,SAAyB;CAChE,MAAM,MAAM,YAAY,IAAI;CAC5B,MAAM,WAAW,IAAI,IAAI,OAAO;CAEhC,EAAE,eAAe,EAAE,aAAa,QAAQ,aAAa,CAAC,SAAS,IAAI,SAAS,MAAM,CAAC;CACnF,MAAM,SAAS,eAAe,QAAQ,MAAM;CAC5C,QAAQ,SAAS,QAAQ,UAAU;EACjC,EAAE,aAAa,KAAK;GAAE;GAAQ,WAAW,OAAO,OAAO,UAAU;EAAG,CAAC;CACvE,CAAC;AACH;AAEA,SAAgB,WAAW,GAAuB;CAChD,EAAE,eAAe,MAAM;CACvB,EAAE,iBAAiB,CAAC;CACpB,EAAE,eAAe,CAAC;AACpB;AAEA,SAAgB,iBAAiB,GAA0B;CACzD,OACE,EAAE,SAAS,SAAS,KACpB,EAAE,eAAe,OAAO,KACxB,EAAE,eAAe,SAAS,KAC1B,EAAE,aAAa,SAAS;AAE5B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GuideOverlayState } from "../guides/types.js";
|
|
2
|
-
import {
|
|
2
|
+
import { DesignIssueHighlight } from "../issues/types.js";
|
|
3
3
|
import { ConnectorTarget } from "../../editor/connectors/attach.js";
|
|
4
4
|
import { RotationPreview } from "../../geometry/types.js";
|
|
5
5
|
import "../../geometry/index.js";
|
|
@@ -120,7 +120,7 @@ interface RenderOverlays {
|
|
|
120
120
|
transformBox?: Vector[] | null;
|
|
121
121
|
} | null;
|
|
122
122
|
presenceCursors?: PresenceCursor[];
|
|
123
|
-
|
|
123
|
+
designIssueHighlight?: DesignIssueHighlight | null;
|
|
124
124
|
codeFocusNodeId?: string | null;
|
|
125
125
|
}
|
|
126
126
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/canvas/renderer/types.ts"],"mappings":";;;;;;;;;;;;UAYiB;EACf,OAAO;EACP,YAAY;;UAGG;EACf,YAAY;EACZ,MAAM;EACN,MAAM;;KAGI;;UAGK;;EAEf;EACA;EACA;;EAEA,OAAO;EACP;EACA;EACA;;EAEA,UAAU;;UAGK;;EAEf;;;EAGA,cAAc;EACd;;EAEA;;EAEA,eAAe;;EAEf,YAAY;EACZ;EACA,kBAAkB;EAClB;EACA;;EAEA;EACA,aAAa;EACb,UAAU;EACV,aAAa;EACb,SAAS;EACT,kBAAkB;EAClB;EACA;IACE;IACA;IACA;IACA;;EAEF;IACE;IACA;IACA;IACA;;;EAGF,mBAAmB;;EAEnB,kBAAkB;EAClB;IACE,UAAU;IACV,UAAU;MACR;MACA;MACA,cAAc;MACd,YAAY;;IAEd,aAAa;IACb,sBAAsB;IACtB;IACA;IACA;IACA;;EAEF,cAAc;EACd;IACE;IACA,UAAU;IACV,UAAU;MACR;MACA;MACA,cAAc;MACd,YAAY;;IAEd,SAAS;IACT,uBAAuB;IACvB,yBAAyB;IACzB,kBAAkB;IAClB;MAAsB;MAAsB;;;IAE5C;;IAEA,kBAAkB;;IAElB;;IAEA;;IAEA,eAAe;;EAEjB,kBAAkB;EAClB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/canvas/renderer/types.ts"],"mappings":";;;;;;;;;;;;UAYiB;EACf,OAAO;EACP,YAAY;;UAGG;EACf,YAAY;EACZ,MAAM;EACN,MAAM;;KAGI;;UAGK;;EAEf;EACA;EACA;;EAEA,OAAO;EACP;EACA;EACA;;EAEA,UAAU;;UAGK;;EAEf;;;EAGA,cAAc;EACd;;EAEA;;EAEA,eAAe;;EAEf,YAAY;EACZ;EACA,kBAAkB;EAClB;EACA;;EAEA;EACA,aAAa;EACb,UAAU;EACV,aAAa;EACb,SAAS;EACT,kBAAkB;EAClB;EACA;IACE;IACA;IACA;IACA;;EAEF;IACE;IACA;IACA;IACA;;;EAGF,mBAAmB;;EAEnB,kBAAkB;EAClB;IACE,UAAU;IACV,UAAU;MACR;MACA;MACA,cAAc;MACd,YAAY;;IAEd,aAAa;IACb,sBAAsB;IACtB;IACA;IACA;IACA;;EAEF,cAAc;EACd;IACE;IACA,UAAU;IACV,UAAU;MACR;MACA;MACA,cAAc;MACd,YAAY;;IAEd,SAAS;IACT,uBAAuB;IACvB,yBAAyB;IACzB,kBAAkB;IAClB;MAAsB;MAAsB;;;IAE5C;;IAEA,kBAAkB;;IAElB;;IAEA;;IAEA,eAAe;;EAEjB,kBAAkB;EAClB,uBAAuB;EACvB"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ResourceCache } from "../cache/resource.js";
|
|
2
|
-
import { PlacedIssueMarker } from "./issues/types.js";
|
|
3
2
|
import { ImagePreviewCache } from "./images/previews.js";
|
|
4
3
|
import { FontResolutionSnapshot } from "../text/resolver/types.js";
|
|
5
4
|
import { LabelParagraphCache } from "./labels/paragraph-cache.js";
|
|
@@ -25,7 +24,7 @@ import { TransientCanvasPreview } from "./renderer/transient-previews.js";
|
|
|
25
24
|
import { Blender, Canvas, CanvasKit, Font, FontMgr, Image, ImageFilter, MaskFilter, Paint, RuntimeEffect, SkPicture, Surface, TextureSource, TypefaceFontProvider } from "canvaskit-wasm";
|
|
26
25
|
import { Fill, SceneGraph, SceneNode, Stroke } from "@pairdraw/scene-graph";
|
|
27
26
|
import { RenderColorSpace, ResolvedRenderColor } from "@pairdraw/scene-graph/color";
|
|
28
|
-
import { Color as Color$1,
|
|
27
|
+
import { Color as Color$1, Vector } from "@pairdraw/scene-graph/primitives";
|
|
29
28
|
//#region src/canvas/renderer.d.ts
|
|
30
29
|
interface SubtreePictureCacheEntry {
|
|
31
30
|
picture: SkPicture;
|
|
@@ -185,12 +184,8 @@ declare class SkiaRenderer {
|
|
|
185
184
|
/** Selection chrome, set from editor state each frame through {@link setSelectionTheme}. */
|
|
186
185
|
selectionTheme: SelectionTheme;
|
|
187
186
|
pageId: string | null;
|
|
188
|
-
/** Issue markers placed in the last overlay pass; hit testing reads the same layout. */
|
|
189
|
-
issueMarkers: PlacedIssueMarker[];
|
|
190
187
|
/** Status labels drawn in the last label pass; clicks on them open the status menu. */
|
|
191
188
|
statusLabels: PlacedStatusLabel[];
|
|
192
|
-
/** Screen rectangles of UI floating over this canvas, which overlays such as edge pins avoid. */
|
|
193
|
-
overlayObstacles: readonly Rect[];
|
|
194
189
|
/**
|
|
195
190
|
* The most device pixels this canvas draws per CSS pixel; a low-power canvas caps it at 1 so a
|
|
196
191
|
* high-density display draws a quarter of the pixels. The canvas buffer must be sized the same.
|
|
@@ -222,6 +217,11 @@ declare class SkiaRenderer {
|
|
|
222
217
|
nodeId: string;
|
|
223
218
|
startTime: number;
|
|
224
219
|
}>;
|
|
220
|
+
/** Layers an agent added, each tracing in from its start, which may still be ahead. */
|
|
221
|
+
_aiEntrances: Array<{
|
|
222
|
+
nodeId: string;
|
|
223
|
+
startTime: number;
|
|
224
|
+
}>;
|
|
225
225
|
readonly DEFAULT_FONT_SIZE = 14;
|
|
226
226
|
readonly COMPONENT_SET_BORDER_WIDTH = 1.5;
|
|
227
227
|
readonly COMPONENT_SET_DASH = 6;
|
|
@@ -313,7 +313,10 @@ declare class SkiaRenderer {
|
|
|
313
313
|
prepareForExport(graph: SceneGraph, pageId: string, nodeIds: string[]): Promise<void>;
|
|
314
314
|
replaceSurface(surface: Surface): void;
|
|
315
315
|
invalidateScenePicture(): void;
|
|
316
|
-
|
|
316
|
+
/** Drop every cached picture; `keepShapedText` keeps the sizes identical text shaped to. */
|
|
317
|
+
invalidateAllPictures(options?: {
|
|
318
|
+
keepShapedText?: boolean;
|
|
319
|
+
}): void;
|
|
317
320
|
/**
|
|
318
321
|
* Draws `source` wherever the image `hash` is painted, until it is set to null, and redraws
|
|
319
322
|
* `nodeIds`, the layers that paint it. Frames of the same size reuse one texture. Returns
|
|
@@ -331,7 +334,8 @@ declare class SkiaRenderer {
|
|
|
331
334
|
aiMarkActive(nodeIds: string[]): void;
|
|
332
335
|
aiMarkDone(nodeIds: string[]): void;
|
|
333
336
|
aiFlashDone(nodeIds: string[]): void;
|
|
334
|
-
|
|
337
|
+
/** Traces in layers an agent added, one after another in the order given. */
|
|
338
|
+
aiEnter(nodeIds: string[]): void;
|
|
335
339
|
aiClearAll(): void;
|
|
336
340
|
get hasActiveFlashes(): boolean;
|
|
337
341
|
hitTestSectionTitle(graph: SceneGraph, canvasX: number, canvasY: number, preview?: RenderOverlays['rotationPreview']): SceneNode | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.d.ts","names":[],"sources":["../../src/canvas/renderer.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","names":[],"sources":["../../src/canvas/renderer.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;UAoEiB;EACf,SAAS;EACT;EACA;EACA;EACA;;UAGe;EACf,MAAM;EACN,MAAM;;;;;;;KAcI,kBACR,QAAQ;EAAiB;EAAe;KACxC;cAIS;EACX,IAAI;EACJ,SAAS;EACD,WAAW;EACnB,uBAAuB;EACvB,iBAAiB;EACjB,mBAAmB;EACnB,oBAAoB;EACZ,aAAa;EACb,gBAAgB;EAChB,oBAAoB;EACpB,WAAW;EACX,SAAS;EACT,WAAW;EACX,cAAc;EACd,kBAAkB;EAC1B,kBAAgB,YAAA;EAChB,iBAAe,YAAA;EACf,WAAS,aAAA;EACT,UAAQ,aAAA;EACR,UAAU;EACV,WAAW;EACX,UAAU;;EAEV,WAAW;EACX,kBAAkB;EAClB,oBAAoB;EACpB,SAAS;EACT,cAAc;EACd;EACA;EACA,2BACM,UAAU,wBAAwB;EAExC,kBAAgB,YAAA;EAChB,wBAAsB;IAA2B,MAAA;IAAwB;;WAChE,mBAAiB,YAAA;EAC1B,YAAU,sBAAA;;;;;WAKD,YAAU;IAA4B,OAAA;IAAgB,SAAA;;EAC/D;EACA,kBAAkB;EAClB;EACA;WACS,eAAa;EACtB,WAAS;;EAET,sBAFS,+CAEW;EACpB,uBAAqB,cAAA,WAAA,2CAAA;EAC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ACA,UAAU,oCACT;;MAcC;EAIJ,oBAAoB,QAAQ,QAAQ,OAAO,YAAY;EAIvD,sBACE,OAAO,aACP,OAAO,YACP,qBACA,uBACA,wBACA,sBACA,QAAO,aACP;EAiBF,OACE,OAAO,YACP,aAAa,aACb,WAAU,gBACV,uBACA,QAAO;EAKT,qBAAqB;EAIrB,gBAAgB,MAAM,WAAW;IAAsB;IAAe;;EAItE,kBAAkB,MAAM,YAAY;EAIpC,iBAAiB,MAAM;EAIvB,iBAAiB,MAAM,YAAY;EAInC,eACE,MAAM,WACN,QAAQ,cACR,OAAO,wBACN;EAIH,qBACE,MAAM,MACN,mBACA,MAAM,WACN,OAAO,aACN;EAUH,iBAAiB,MAAM,MAAM,mBAAmB,MAAM,WAAW,OAAO,aAAa;EAIrF,uBACE,QAAQ,QACR,qBACA,MAAM,WACN,OAAO,aACN;EAUH,mBACE,QAAQ,QACR,qBACA,MAAM,WACN,OAAO,aACN;EAUH,eAAe,YAAY,aAAa;;;;;;;EAaxC,qBACE,QAAQ,YACR,eACA,gBACA,wBACA,kBACC,WAAW;EA0Bd;EAEA"}
|
package/dist/canvas/renderer.js
CHANGED
|
@@ -11,7 +11,7 @@ import { labelHitOptions } from "./labels/style.js";
|
|
|
11
11
|
import { NodePathCaches } from "./paths/cache.js";
|
|
12
12
|
import { resolveFillColor, resolveFillColorInfo, resolveStrokeColor, resolveStrokeColorInfo } from "./renderer/colors.js";
|
|
13
13
|
import { getFontProvider, isTextPictureCurrent, loadFonts, prepareForExport, resolveLabelFontCoverage, syncFontGeneration, trackFontDemand } from "./renderer/fonts.js";
|
|
14
|
-
import {
|
|
14
|
+
import { aiClearAll, aiEnter, aiFlashDone, aiMarkActive, aiMarkDone, flashNode, hasActiveFlashes, invalidateAllPictures, invalidateNodePicture, invalidateScenePicture } from "./renderer/state.js";
|
|
15
15
|
import { destroyRenderer, releaseLiveImages } from "./renderer/lifecycle.js";
|
|
16
16
|
import { EffectRasterCache } from "./renderer/effect-raster-cache.js";
|
|
17
17
|
import { createDerivedGlyphPathCache, createGlyphSilhouetteCache } from "./text/derived.js";
|
|
@@ -127,12 +127,8 @@ var SkiaRenderer = class {
|
|
|
127
127
|
/** Selection chrome, set from editor state each frame through {@link setSelectionTheme}. */
|
|
128
128
|
selectionTheme = DEFAULT_SELECTION_THEME;
|
|
129
129
|
pageId = null;
|
|
130
|
-
/** Issue markers placed in the last overlay pass; hit testing reads the same layout. */
|
|
131
|
-
issueMarkers = [];
|
|
132
130
|
/** Status labels drawn in the last label pass; clicks on them open the status menu. */
|
|
133
131
|
statusLabels = [];
|
|
134
|
-
/** Screen rectangles of UI floating over this canvas, which overlays such as edge pins avoid. */
|
|
135
|
-
overlayObstacles = [];
|
|
136
132
|
/**
|
|
137
133
|
* The most device pixels this canvas draws per CSS pixel; a low-power canvas caps it at 1 so a
|
|
138
134
|
* high-density display draws a quarter of the pixels. The canvas buffer must be sized the same.
|
|
@@ -158,6 +154,8 @@ var SkiaRenderer = class {
|
|
|
158
154
|
_flashPaint = null;
|
|
159
155
|
_aiActiveNodes = /* @__PURE__ */ new Set();
|
|
160
156
|
_aiDoneFlashes = [];
|
|
157
|
+
/** Layers an agent added, each tracing in from its start, which may still be ahead. */
|
|
158
|
+
_aiEntrances = [];
|
|
161
159
|
DEFAULT_FONT_SIZE = 14;
|
|
162
160
|
COMPONENT_SET_BORDER_WIDTH = COMPONENT_SET_BORDER_WIDTH;
|
|
163
161
|
COMPONENT_SET_DASH = 6;
|
|
@@ -275,8 +273,9 @@ var SkiaRenderer = class {
|
|
|
275
273
|
invalidateScenePicture() {
|
|
276
274
|
invalidateScenePicture(this);
|
|
277
275
|
}
|
|
278
|
-
|
|
279
|
-
|
|
276
|
+
/** Drop every cached picture; `keepShapedText` keeps the sizes identical text shaped to. */
|
|
277
|
+
invalidateAllPictures(options) {
|
|
278
|
+
invalidateAllPictures(this, options);
|
|
280
279
|
}
|
|
281
280
|
/**
|
|
282
281
|
* Draws `source` wherever the image `hash` is painted, until it is set to null, and redraws
|
|
@@ -324,8 +323,9 @@ var SkiaRenderer = class {
|
|
|
324
323
|
aiFlashDone(nodeIds) {
|
|
325
324
|
aiFlashDone(this, nodeIds);
|
|
326
325
|
}
|
|
327
|
-
|
|
328
|
-
|
|
326
|
+
/** Traces in layers an agent added, one after another in the order given. */
|
|
327
|
+
aiEnter(nodeIds) {
|
|
328
|
+
aiEnter(this, nodeIds);
|
|
329
329
|
}
|
|
330
330
|
aiClearAll() {
|
|
331
331
|
aiClearAll(this);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.js","names":["RendererFonts.resolveLabelFontCoverage","RendererFonts.getFontProvider","RendererFonts.loadFonts","RendererFonts.isTextPictureCurrent","RendererFonts.prepareForExport","RendererState.hasActiveFlashes","LabelHitTest.hitTestSectionTitle","LabelHitTest.hitTestComponentLabel","LabelHitTest.hitTestFrameTitle","RenderText.measureTextNode","RenderText.nodeFontReadiness","RenderText.isNodeFontLoaded","RenderText.buildTextPicture","RenderText.buildParagraph","RenderColors.resolveFillColorInfo","RenderColors.resolveFillColor","RenderColors.resolveStrokeColorInfo","RenderColors.resolveStrokeColor"],"sources":["../../src/canvas/renderer.ts"],"sourcesContent":["import { isEqual } from 'es-toolkit'\nimport { toUint8Array } from 'js-base64'\n\nimport type { SceneNode, SceneGraph, Fill, Stroke } from '@pairdraw/scene-graph'\nimport type { RenderColorSpace, ResolvedRenderColor } from '@pairdraw/scene-graph/color'\nimport type { Color, Rect, Vector } from '@pairdraw/scene-graph/primitives'\nimport { slotPropertyId } from '@pairdraw/scene-graph/slots'\n\n/* eslint-disable max-lines -- SkiaRenderer facade owns CanvasKit state and delegates domain drawing */\nimport {\n DEFAULT_SELECTION_THEME,\n COMPONENT_COLOR,\n SLOT_COLOR,\n CANVAS_BG_COLOR,\n DEFAULT_FONT_SIZE,\n COMPONENT_SET_DASH,\n COMPONENT_SET_DASH_GAP,\n COMPONENT_SET_BORDER_WIDTH,\n IS_BROWSER\n} from '#core/constants'\nimport type { EditorState } from '#core/editor/types'\nimport { RenderProfiler } from '#core/profiler'\nimport type { FontResolutionSnapshot } from '#core/text/resolver'\n\nimport { createImageCache } from './images/cache'\nimport { ImagePreviewCache } from './images/previews'\nimport { LabelCache } from './labels/cache'\nimport * as LabelHitTest from './labels/hit-test'\nimport { LabelParagraphCache } from './labels/paragraph-cache'\nimport { labelHitOptions } from './labels/style'\nimport { NodePathCaches } from './paths/cache'\nimport * as RenderColors from './renderer/colors'\nimport * as RendererFonts from './renderer/fonts'\nimport { destroyRenderer, releaseLiveImages } from './renderer/lifecycle'\nimport { installRendererDomainMethods, type RendererDomainMethods } from './renderer/methods'\nimport { initializeRendererPaints, initializeSelectionPaintColors } from './renderer/paints'\nimport * as RenderPipeline from './renderer/pipeline'\nimport type { SceneBacking, SceneBackingBuild } from './renderer/retained-backing/types'\nimport * as RendererState from './renderer/state'\nimport * as RenderText from './text'\nimport type { SavedDecorationCache } from './text/decorations'\nimport { createDerivedGlyphPathCache, createGlyphSilhouetteCache } from './text/derived'\nimport { createEmojiImageCache } from './text/emoji'\nimport { TextPreparationCache } from './text/preparation/cache'\nexport type {\n MeasurementMode,\n PresenceCursor,\n RenderOverlays,\n RulerTheme,\n SelectionTheme\n} from './renderer/types'\nimport type {\n CanvasKit,\n Surface,\n Canvas,\n Blender,\n Paint,\n Font,\n FontMgr,\n TypefaceFontProvider,\n SkPicture,\n ImageFilter,\n MaskFilter,\n RuntimeEffect,\n Image,\n TextureSource\n} from 'canvaskit-wasm'\n\nexport interface SubtreePictureCacheEntry {\n picture: SkPicture\n pageId: string | null\n sceneVersion: number\n positionPreviewVersion: number\n fontGeneration: number\n}\n\nexport interface PendingFontNode {\n node: SceneNode\n keys: Set<string>\n}\n\nimport type { PlacedIssueMarker } from './issues/types'\nimport type { PlacedStatusLabel } from './labels/status'\nimport { EffectRasterCache } from './renderer/effect-raster-cache'\nimport { TiledSceneController } from './renderer/tiles'\nimport type { TransientCanvasPreview } from './renderer/transient-previews'\nimport type { RenderOverlays, RulerTheme, SelectionTheme } from './renderer/types'\n\n/**\n * A picture uploaded as a texture that knows its size: an `ImageBitmap`, or a canvas, which\n * WebGL uploads as it does an image though CanvasKit's types leave it out. A canvas is uploaded\n * as it is when this is called, so a WebGPU canvas is passed in the task that drew it.\n */\nexport type LiveImageSource =\n | Extract<TextureSource, { width: number; height: number }>\n | HTMLCanvasElement\n\nconst textureSource = (source: LiveImageSource) => source as TextureSource\n\nexport class SkiaRenderer {\n ck: CanvasKit\n surface: Surface\n declare fillPaint: Paint\n diamondGradientEffect: RuntimeEffect | null = null\n pixelGridEffect: RuntimeEffect | null = null\n linearBurnBlender: Blender | null = null\n linearDodgeBlender: Blender | null = null\n declare strokePaint: Paint\n declare selectionPaint: Paint\n declare parentOutlinePaint: Paint\n declare snapPaint: Paint\n declare auxFill: Paint\n declare auxStroke: Paint\n declare opacityPaint: Paint\n declare effectLayerPaint: Paint\n imageFilterCache = new Map<string, ImageFilter | null>()\n maskFilterCache = new Map<number, MaskFilter | null>()\n _tmpColor = new Float32Array(4)\n _tmpRect = new Float32Array(4)\n textFont: Font | null = null\n labelFont: Font | null = null\n sizeFont: Font | null = null\n /** Inter SemiBold at 11 px, which Figma sets the padding and gap values on the canvas in. */\n valueFont: Font | null = null\n sectionTitleFont: Font | null = null\n componentLabelFont: Font | null = null\n fontMgr: FontMgr | null = null\n fontProvider: TypefaceFontProvider | null = null\n fontsLoaded = false\n fontGeneration = 0\n onFontResolutionSettled:\n | ((snapshot: FontResolutionSnapshot, nodeIds: readonly string[]) => void)\n | undefined\n pendingFontNodes = new Map<string, PendingFontNode>()\n textPictureGenerations = new Map<string, { data: Uint8Array; generation: number }>()\n readonly transientPreviews = new Map<string, TransientCanvasPreview>()\n imageCache = createImageCache()\n /**\n * Images drawn in place of stored ones while they play, such as a shader's live frames, each\n * with the surface whose GL context holds its texture.\n */\n readonly liveImages = new Map<string, { image: Image; surface: Surface }>()\n viewportImageRendering = false\n imageMemoryGraph: SceneGraph | null = null\n imageMemoryPage: string | null = null\n onImagePreviewReady: (() => void) | null = null\n readonly imagePreviews = new ImagePreviewCache(() => this.onImagePreviewReady?.())\n nodePaths = new NodePathCaches()\n /** Path-text glyph silhouettes (stroke-and-union, font units) keyed by blob hash + relative weight. */\n glyphSilhouetteCache = createGlyphSilhouetteCache()\n derivedGlyphPathCache = createDerivedGlyphPathCache()\n derivedDecorationCache: SavedDecorationCache = new WeakMap()\n /** Images of the emoji saved text draws, by what drew them and the emoji. */\n emojiImageCache = createEmojiImageCache()\n renderingSceneBacking = false\n scenePicture: SkPicture | null = null\n scenePictureVersion = -1\n scenePictureFontGeneration = -1\n scenePicturePositionPreviewVersion = -1\n scenePicturePageId: string | null = null\n sceneBacking: SceneBacking | null = null\n sceneBackingPreviewUntil = 0\n sceneBackingNeedsCrispRender = false\n sceneBackingAllocationFailed = false\n sceneBackingBuild: SceneBackingBuild | null = null\n sceneBackingAverageRecordMs = 40\n sceneBackingAverageViewportIntervalMs = 80\n sceneBackingLastViewportEventAt = 0\n navigationPhase: EditorState['navigation']['phase'] = 'idle'\n navigationGeneration = 0\n /** Selections draw handles to drag; off while the canvas offers no edits. */\n editHandles = true\n tiledSceneEnabled = false\n /**\n * What an empty sticky note shows while it is edited on this canvas, in the interface language;\n * null for a canvas that draws only the document, such as an export.\n */\n stickyPlaceholder: string | null = null\n /** What an empty connector label shows while it is typed into; null draws nothing. */\n connectorLabelPlaceholder: string | null = null\n tracksSceneSettlement = true\n /** Colour space this renderer's surface presents; colours convert into it when painting. */\n presentationColorSpace: RenderColorSpace = 'srgb'\n tiledScenePending = false\n tiledSceneCovered = false\n lastSceneViewport: { panX: number; panY: number; zoom: number } | null = null\n nodePictureCache = new Map<string, SkPicture | null>()\n nodePictureCacheGenerations = new Map<string, number>()\n effectRasterCache = new EffectRasterCache()\n subtreePictureCache = new Map<string, SubtreePictureCacheEntry>()\n subtreePictureCachePageId: string | null = null\n subtreePictureCacheSceneVersion = -1\n subtreePictureCachePositionPreviewVersion = -1\n subtreePictureCacheFontGeneration = -1\n readonly labelCache = new LabelCache()\n readonly labelParagraphCache = new LabelParagraphCache(undefined, undefined, {\n onMissingGlyphs: (missing) => RendererFonts.resolveLabelFontCoverage(this, missing)\n })\n readonly textPreparationCache = new TextPreparationCache()\n readonly tiledScene = new TiledSceneController()\n readonly profiler: RenderProfiler\n\n declare rulerBgPaint: Paint\n declare rulerTickPaint: Paint\n declare rulerTextPaint: Paint\n declare rulerHlPaint: Paint\n declare rulerBadgePaint: Paint\n declare rulerLabelPaint: Paint\n declare penPathPaint: Paint\n declare penLiveStrokePaint: Paint\n /** The pencil stroke being drawn; its colour and width are set per frame. */\n declare pencilStrokePaint: Paint\n declare penHandlePaint: Paint\n declare penVertexFill: Paint\n declare penVertexStroke: Paint\n\n panX = 0\n panY = 0\n zoom = 1\n dpr = 1\n viewportWidth = 0\n viewportHeight = 0\n showRulers = true\n pageColor = CANVAS_BG_COLOR\n rulerTheme: RulerTheme | null = null\n /** Selection chrome, set from editor state each frame through {@link setSelectionTheme}. */\n selectionTheme: SelectionTheme = DEFAULT_SELECTION_THEME\n pageId: string | null = null\n /** Issue markers placed in the last overlay pass; hit testing reads the same layout. */\n issueMarkers: PlacedIssueMarker[] = []\n /** Status labels drawn in the last label pass; clicks on them open the status menu. */\n statusLabels: PlacedStatusLabel[] = []\n /** Screen rectangles of UI floating over this canvas, which overlays such as edge pins avoid. */\n overlayObstacles: readonly Rect[] = []\n\n /**\n * The most device pixels this canvas draws per CSS pixel; a low-power canvas caps it at 1 so a\n * high-density display draws a quarter of the pixels. The canvas buffer must be sized the same.\n */\n maxPixelRatio = Number.POSITIVE_INFINITY\n /**\n * Draws expensive effects cheaply on this canvas: background blurs and noise are left out, and\n * cached shadows keep one pixel per unit at any zoom. Exports still draw every effect.\n */\n reducedEffects = false\n /** Set while an export draws the document, so every effect is drawn whatever `reducedEffects` says. */\n drawingFullEffects = false\n boundEffectLayersToViewport = false\n worldViewport = { x: 0, y: 0, w: 0, h: 0 }\n _nodeCount = 0\n _culledCount = 0\n _flashes: Array<{ nodeId: string; startTime: number }> = []\n _flashPaint: Paint | null = null\n _aiActiveNodes: Set<string> = new Set()\n _aiDoneFlashes: Array<{ nodeId: string; startTime: number }> = []\n\n readonly DEFAULT_FONT_SIZE = DEFAULT_FONT_SIZE\n readonly COMPONENT_SET_BORDER_WIDTH = COMPONENT_SET_BORDER_WIDTH\n readonly COMPONENT_SET_DASH = COMPONENT_SET_DASH\n readonly COMPONENT_SET_DASH_GAP = COMPONENT_SET_DASH_GAP\n\n declare drawHoverHighlight: RendererDomainMethods['drawHoverHighlight']\n declare drawMeasurements: RendererDomainMethods['drawMeasurements']\n declare drawEnteredContainer: RendererDomainMethods['drawEnteredContainer']\n declare drawSelection: RendererDomainMethods['drawSelection']\n declare drawNodeSelection: RendererDomainMethods['drawNodeSelection']\n declare drawSelectionLabels: RendererDomainMethods['drawSelectionLabels']\n declare drawParentFrameOutlines: RendererDomainMethods['drawParentFrameOutlines']\n declare drawNodeOutline: RendererDomainMethods['drawNodeOutline']\n declare drawGroupBounds: RendererDomainMethods['drawGroupBounds']\n declare getRotatedCorners: RendererDomainMethods['getRotatedCorners']\n declare drawHandle: RendererDomainMethods['drawHandle']\n declare drawSnapGuides: RendererDomainMethods['drawSnapGuides']\n declare drawSnapMarks: RendererDomainMethods['drawSnapMarks']\n declare drawMarquee: RendererDomainMethods['drawMarquee']\n declare drawFlashes: RendererDomainMethods['drawFlashes']\n declare drawLayoutInsertIndicator: RendererDomainMethods['drawLayoutInsertIndicator']\n declare drawAutoLayoutHover: RendererDomainMethods['drawAutoLayoutHover']\n declare drawTextEditOverlay: RendererDomainMethods['drawTextEditOverlay']\n declare drawNodeEditOverlay: RendererDomainMethods['drawNodeEditOverlay']\n declare drawPenOverlay: RendererDomainMethods['drawPenOverlay']\n declare drawPencilOverlay: RendererDomainMethods['drawPencilOverlay']\n declare drawPresenceCursors: RendererDomainMethods['drawPresenceCursors']\n declare drawRulers: RendererDomainMethods['drawRulers']\n declare drawFrameTitles: RendererDomainMethods['drawFrameTitles']\n declare drawSectionTitles: RendererDomainMethods['drawSectionTitles']\n declare drawComponentLabels: RendererDomainMethods['drawComponentLabels']\n declare renderNodeSelf: RendererDomainMethods['renderNodeSelf']\n declare renderNode: RendererDomainMethods['renderNode']\n declare renderSection: RendererDomainMethods['renderSection']\n declare renderComponentSet: RendererDomainMethods['renderComponentSet']\n declare renderShape: RendererDomainMethods['renderShape']\n declare renderShapeUncached: RendererDomainMethods['renderShapeUncached']\n declare paintShapeContent: RendererDomainMethods['paintShapeContent']\n declare renderEffects: RendererDomainMethods['renderEffects']\n declare renderText: RendererDomainMethods['renderText']\n declare drawNodeFill: RendererDomainMethods['drawNodeFill']\n declare applyFill: RendererDomainMethods['applyFill']\n declare applyGradientFill: RendererDomainMethods['applyGradientFill']\n declare applyImageFill: RendererDomainMethods['applyImageFill']\n declare drawNodeStroke: RendererDomainMethods['drawNodeStroke']\n declare drawStrokeWithAlign: RendererDomainMethods['drawStrokeWithAlign']\n declare drawRRectStrokeWithAlign: RendererDomainMethods['drawRRectStrokeWithAlign']\n declare drawIndividualSideStrokes: RendererDomainMethods['drawIndividualSideStrokes']\n declare strokeNodeShape: RendererDomainMethods['strokeNodeShape']\n declare makeNodeShapePath: RendererDomainMethods['makeNodeShapePath']\n declare makePolygonPath: RendererDomainMethods['makePolygonPath']\n declare makeRRect: RendererDomainMethods['makeRRect']\n declare makeRRectWithSpread: RendererDomainMethods['makeRRectWithSpread']\n declare clipNodeShape: RendererDomainMethods['clipNodeShape']\n declare getVectorPaths: RendererDomainMethods['getVectorPaths']\n declare getFillGeometry: RendererDomainMethods['getFillGeometry']\n declare getStrokeGeometry: RendererDomainMethods['getStrokeGeometry']\n declare getCachedDropShadow: RendererDomainMethods['getCachedDropShadow']\n declare getCachedBlur: RendererDomainMethods['getCachedBlur']\n declare getCachedDecalBlur: RendererDomainMethods['getCachedDecalBlur']\n declare getCachedMaskBlur: RendererDomainMethods['getCachedMaskBlur']\n declare applyClippedBlur: RendererDomainMethods['applyClippedBlur']\n color4f(r: number, g: number, b: number, a: number): Float32Array {\n const c = this._tmpColor\n c[0] = r\n c[1] = g\n c[2] = b\n c[3] = a\n return c\n }\n\n ltrb(l: number, t: number, r: number, b: number): Float32Array {\n const rc = this._tmpRect\n rc[0] = l\n rc[1] = t\n rc[2] = r\n rc[3] = b\n return rc\n }\n\n selColor(alpha = 1) {\n const { r, g, b } = this.selectionTheme.color\n return this.ck.Color4f(r, g, b, alpha)\n }\n\n selForegroundColor() {\n const { r, g, b } = this.selectionTheme.foreground\n return this.ck.Color4f(r, g, b, 1)\n }\n\n /** Switches selection chrome to `theme`, repainting the paints that keep it between frames. */\n setSelectionTheme(theme: SelectionTheme = DEFAULT_SELECTION_THEME): void {\n if (isEqual(theme, this.selectionTheme)) return\n this.selectionTheme = { color: { ...theme.color }, foreground: { ...theme.foreground } }\n initializeSelectionPaintColors(this)\n }\n\n compColor(alpha = 1) {\n return this.ck.Color4f(COMPONENT_COLOR.r, COMPONENT_COLOR.g, COMPONENT_COLOR.b, alpha)\n }\n\n slotColor(alpha = 1) {\n return this.ck.Color4f(SLOT_COLOR.r, SLOT_COLOR.g, SLOT_COLOR.b, alpha)\n }\n\n /**\n * The outline colour for a node: pink for slots, purple for components, instances and every\n * layer inside them, as in Figma, blue otherwise.\n */\n outlineColor(node: SceneNode, graph: SceneGraph) {\n if (slotPropertyId(node)) return this.slotColor()\n return this.isInComponent(node, graph) ? this.compColor() : this.selColor()\n }\n\n /** Text drawn on {@link outlineColor}: white on slot and component colors, else the selection foreground. */\n outlineForegroundColor(node: SceneNode, graph: SceneGraph) {\n if (slotPropertyId(node) || this.isInComponent(node, graph)) return this.ck.WHITE\n return this.selForegroundColor()\n }\n\n /** A component, instance or set, or a layer inside one; content placed in a slot is not. */\n isInComponent(node: SceneNode, graph: SceneGraph): boolean {\n const owner = graph.closest(\n node.id,\n (layer) => this.isComponentType(layer.type) || slotPropertyId(layer) !== undefined\n )\n return owner !== undefined && !slotPropertyId(owner)\n }\n\n isComponentType(type: string): boolean {\n return type === 'COMPONENT' || type === 'COMPONENT_SET' || type === 'INSTANCE'\n }\n\n isRectangularType(type: string): boolean {\n return (\n type === 'FRAME' ||\n type === 'RECTANGLE' ||\n type === 'ROUNDED_RECTANGLE' ||\n type === 'COMPONENT' ||\n type === 'INSTANCE' ||\n type === 'SECTION' ||\n type === 'GROUP'\n )\n }\n\n effectOverflow(node: SceneNode): number {\n let expand = 0\n for (const e of node.effects) {\n // A shader effect has no radius, spread, or offset of its own.\n if (!e.visible || e.type === 'SHADER') continue\n const blur = e.radius\n const spread = e.spread\n const ox = Math.abs(e.offset.x)\n const oy = Math.abs(e.offset.y)\n expand = Math.max(expand, blur + spread + ox, blur + spread + oy)\n }\n return expand\n }\n\n constructor(ck: CanvasKit, surface: Surface, gl?: WebGL2RenderingContext | null) {\n this.ck = ck\n this.surface = surface\n this.profiler = new RenderProfiler(ck, gl ?? null)\n initializeRendererPaints(this)\n }\n\n getFontProvider(): TypefaceFontProvider | null {\n return RendererFonts.getFontProvider(this)\n }\n\n isDestroyed(): boolean {\n return this.destroyed\n }\n\n async loadFonts(onFallbackFontsLoaded?: () => void): Promise<void> {\n await RendererFonts.loadFonts(this, onFallbackFontsLoaded)\n }\n\n syncFontGeneration(): void {\n RendererFonts.syncFontGeneration(this)\n }\n\n trackFontDemand(node: SceneNode, key: string): void {\n RendererFonts.trackFontDemand(this, node, key)\n }\n\n isTextPictureCurrent(node: SceneNode): boolean {\n return RendererFonts.isTextPictureCurrent(this, node)\n }\n\n async prepareForExport(graph: SceneGraph, pageId: string, nodeIds: string[]): Promise<void> {\n return RendererFonts.prepareForExport(this, graph, pageId, nodeIds)\n }\n\n replaceSurface(surface: Surface): void {\n this.tiledScene.destroy()\n // Live textures belong to the old surface's context, so they go before it does.\n releaseLiveImages(this)\n this.surface.delete()\n this.surface = surface\n this.sceneBackingAllocationFailed = false\n this.invalidateScenePicture()\n }\n\n invalidateScenePicture(): void {\n RendererState.invalidateScenePicture(this)\n }\n\n invalidateAllPictures(): void {\n RendererState.invalidateAllPictures(this)\n }\n\n /**\n * Draws `source` wherever the image `hash` is painted, until it is set to null, and redraws\n * `nodeIds`, the layers that paint it. Frames of the same size reuse one texture. Returns\n * whether a live image is shown, which a browser that cannot upload `source` leaves false.\n */\n setLiveImage(\n hash: string,\n source: LiveImageSource | null,\n nodeIds: Iterable<string> = []\n ): boolean {\n const live = this.liveImages.get(hash)\n // A texture made on a surface since replaced has no context left to update or free it in.\n const current = live?.surface === this.surface ? live.image : null\n if (\n source &&\n current &&\n current.width() === source.width &&\n current.height() === source.height\n ) {\n this.surface.updateTextureFromSource(current, textureSource(source))\n } else {\n current?.delete()\n this.liveImages.delete(hash)\n const image = source && this.surface.makeImageFromTextureSource(textureSource(source))\n if (image) this.liveImages.set(hash, { image, surface: this.surface })\n }\n for (const id of nodeIds) this.invalidateNodePicture(id)\n return this.liveImages.has(hash)\n }\n\n /**\n * Forgets the decoded image `hash` after its bytes were replaced, such as a shader's frame\n * rendered again, and redraws whatever showed it. Previews notice new bytes themselves.\n */\n forgetImage(hash: string): void {\n const keys = Array.from(this.imageCache.entries(), ([key]) => key)\n for (const key of keys) {\n if (key === hash || key.startsWith(`${hash}:`)) this.imageCache.delete(key)\n }\n this.invalidateAllPictures()\n }\n\n /** Drops `nodeId`'s cached drawing; `changedKeys`, when known, lets text keep its glyph coverage. */\n invalidateNodePicture(nodeId: string, changedKeys?: readonly (keyof SceneNode)[]): void {\n RendererState.invalidateNodePicture(this, nodeId, changedKeys)\n }\n\n flashNode(nodeId: string): void {\n RendererState.flashNode(this, nodeId)\n }\n\n aiMarkActive(nodeIds: string[]): void {\n RendererState.aiMarkActive(this, nodeIds)\n }\n\n aiMarkDone(nodeIds: string[]): void {\n RendererState.aiMarkDone(this, nodeIds)\n }\n\n aiFlashDone(nodeIds: string[]): void {\n RendererState.aiFlashDone(this, nodeIds)\n }\n\n aiClearActive(): void {\n RendererState.aiClearActive(this)\n }\n\n aiClearAll(): void {\n RendererState.aiClearAll(this)\n }\n\n get hasActiveFlashes(): boolean {\n return RendererState.hasActiveFlashes(this)\n }\n\n hitTestSectionTitle(\n graph: SceneGraph,\n canvasX: number,\n canvasY: number,\n preview?: RenderOverlays['rotationPreview']\n ): SceneNode | null {\n return LabelHitTest.hitTestSectionTitle(\n graph,\n canvasX,\n canvasY,\n this.zoom,\n this.pageId ?? graph.rootId,\n this.sectionTitleFont,\n this.labelCache,\n labelHitOptions(this, graph, preview)\n )\n }\n\n hitTestComponentLabel(\n graph: SceneGraph,\n canvasX: number,\n canvasY: number,\n preview?: RenderOverlays['rotationPreview']\n ): SceneNode | null {\n return LabelHitTest.hitTestComponentLabel(\n graph,\n canvasX,\n canvasY,\n this.zoom,\n this.pageId ?? graph.rootId,\n this.componentLabelFont,\n this.labelCache,\n labelHitOptions(this, graph, preview)\n )\n }\n\n hitTestFrameTitle(\n graph: SceneGraph,\n canvasX: number,\n canvasY: number,\n preview?: RenderOverlays['rotationPreview']\n ): SceneNode | null {\n return LabelHitTest.hitTestFrameTitle(\n graph,\n canvasX,\n canvasY,\n this.zoom,\n this.pageId ?? graph.rootId,\n this.labelFont,\n this.labelCache,\n labelHitOptions(this, graph, preview)\n )\n }\n\n /** Whether effects are drawn cheaply right now: on a reduced-effects canvas, outside exports. */\n get effectsReduced(): boolean {\n return this.reducedEffects && !this.drawingFullEffects\n }\n\n renderSceneToCanvas(canvas: Canvas, graph: SceneGraph, pageId: string): void {\n RenderPipeline.renderSceneToCanvas(this, canvas, graph, pageId)\n }\n\n renderFromEditorState(\n state: EditorState,\n graph: SceneGraph,\n textEditor: unknown,\n viewportWidth: number,\n viewportHeight: number,\n showRulers = true,\n layer: RenderPipeline.RenderLayer = 'full',\n interactive = false\n ): void {\n const dpr = Math.min(IS_BROWSER ? window.devicePixelRatio || 1 : 1, this.maxPixelRatio)\n RenderPipeline.renderFromEditorState(\n this,\n state,\n graph,\n textEditor,\n viewportWidth,\n viewportHeight,\n showRulers,\n dpr,\n layer,\n interactive\n )\n }\n\n render(\n graph: SceneGraph,\n selectedIds: Set<string>,\n overlays: RenderOverlays = {},\n sceneVersion = -1,\n layer: RenderPipeline.RenderLayer = 'full'\n ): void {\n RenderPipeline.render(this, graph, selectedIds, overlays, sceneVersion, layer)\n }\n\n invalidateVectorPath(nodeId: string): void {\n this.nodePaths.invalidate(nodeId)\n }\n\n measureTextNode(node: SceneNode, maxWidth?: number): { width: number; height: number } | null {\n return RenderText.measureTextNode(this, node, maxWidth)\n }\n\n nodeFontReadiness(node: SceneNode): RenderText.NodeFontReadiness {\n return RenderText.nodeFontReadiness(this, node)\n }\n\n isNodeFontLoaded(node: SceneNode): boolean {\n return RenderText.isNodeFontLoaded(this, node)\n }\n\n buildTextPicture(node: SceneNode): Uint8Array | null {\n return RenderText.buildTextPicture(this, node)\n }\n\n buildParagraph(\n node: SceneNode,\n color?: Float32Array,\n opts?: RenderText.ParagraphBuildOptions\n ): RenderText.TextLayout {\n return RenderText.buildParagraph(this, node, color, opts)\n }\n\n resolveFillColorInfo(\n fill: Fill,\n fillIndex: number,\n node: SceneNode,\n graph: SceneGraph\n ): ResolvedRenderColor {\n return RenderColors.resolveFillColorInfo(\n fill,\n fillIndex,\n node,\n graph,\n this.presentationColorSpace\n )\n }\n\n resolveFillColor(fill: Fill, fillIndex: number, node: SceneNode, graph: SceneGraph): Color {\n return RenderColors.resolveFillColor(fill, fillIndex, node, graph, this.presentationColorSpace)\n }\n\n resolveStrokeColorInfo(\n stroke: Stroke,\n strokeIndex: number,\n node: SceneNode,\n graph: SceneGraph\n ): ResolvedRenderColor {\n return RenderColors.resolveStrokeColorInfo(\n stroke,\n strokeIndex,\n node,\n graph,\n this.presentationColorSpace\n )\n }\n\n resolveStrokeColor(\n stroke: Stroke,\n strokeIndex: number,\n node: SceneNode,\n graph: SceneGraph\n ): Color {\n return RenderColors.resolveStrokeColor(\n stroke,\n strokeIndex,\n node,\n graph,\n this.presentationColorSpace\n )\n }\n\n screenToCanvas(sx: number, sy: number): Vector {\n return {\n x: (sx - this.panX) / this.zoom,\n y: (sy - this.panY) / this.zoom\n }\n }\n\n /**\n * Browser fallback for raster formats CanvasKit cannot encode itself\n * (this build returns null from `encodeToBytes` for JPEG/WEBP). Routes the\n * RGBA pixels through an HTMLCanvasElement so `toDataURL` does the encoding.\n * Returns null outside the browser or if encoding fails.\n */\n encodeRasterFallback(\n pixels: Uint8Array,\n width: number,\n height: number,\n format: 'JPG' | 'WEBP',\n quality: number\n ): Uint8Array<ArrayBuffer> | null {\n if (!IS_BROWSER) return null\n try {\n const canvas = document.createElement('canvas')\n canvas.width = width\n canvas.height = height\n const ctx = canvas.getContext('2d')\n if (!ctx) return null\n const imageData = ctx.createImageData(width, height)\n imageData.data.set(pixels)\n ctx.putImageData(imageData, 0, 0)\n const mime = format === 'JPG' ? 'image/jpeg' : 'image/webp'\n const dataURL = canvas.toDataURL(mime, quality / 100)\n // Browsers silently return a PNG data URL when the requested encoder is\n // unsupported; reject that so we never write PNG bytes under a .jpg/.webp file.\n if (!dataURL.startsWith(`data:${mime}`)) return null\n const base64 = dataURL.split(',')[1]\n if (!base64) return null\n // js-base64 types its bytes as any buffer; a copy has the plain one a `Blob` takes.\n return new Uint8Array(toUint8Array(base64))\n } catch (err) {\n console.warn('Raster encode fallback failed:', err)\n return null\n }\n }\n\n destroyed: boolean = false\n\n destroy(): void {\n destroyRenderer(this)\n }\n}\n\ninstallRendererDomainMethods(SkiaRenderer.prototype)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAiGA,MAAM,iBAAiB,WAA4B;AAEnD,IAAa,eAAb,MAA0B;CACxB;CACA;CAEA,wBAA8C;CAC9C,kBAAwC;CACxC,oBAAoC;CACpC,qBAAqC;CASrC,mCAAmB,IAAI,IAAgC;CACvD,kCAAkB,IAAI,IAA+B;CACrD,4BAAY,IAAI,aAAa,CAAC;CAC9B,2BAAW,IAAI,aAAa,CAAC;C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qB;EACrB,OAAOC,uBACL,QACA,aACA,MACA,OACA,KAAK,sBACP;CACF;CAEA,mBACE,QACA,aACA,MACA,OACO;EACP,OAAOC,mBACL,QACA,aACA,MACA,OACA,KAAK,sBACP;CACF;CAEA,eAAe,IAAY,IAAoB;EAC7C,OAAO;GACL,IAAI,KAAK,KAAK,QAAQ,KAAK;GAC3B,IAAI,KAAK,KAAK,QAAQ,KAAK;EAC7B;CACF;;;;;;;CAQA,qBACE,QACA,OACA,QACA,QACA,SACgC;EAChC,IAAI,CAAC,YAAY,OAAO;EACxB,IAAI;GACF,MAAM,SAAS,SAAS,cAAc,QAAQ;GAC9C,OAAO,QAAQ;GACf,OAAO,SAAS;GAChB,MAAM,MAAM,OAAO,WAAW,IAAI;GAClC,IAAI,CAAC,KAAK,OAAO;GACjB,MAAM,YAAY,IAAI,gBAAgB,OAAO,MAAM;GACnD,UAAU,KAAK,IAAI,MAAM;GACzB,IAAI,aAAa,WAAW,GAAG,CAAC;GAChC,MAAM,OAAO,WAAW,QAAQ,eAAe;GAC/C,MAAM,UAAU,OAAO,UAAU,MAAM,UAAU,GAAG;GAGpD,IAAI,CAAC,QAAQ,WAAW,QAAQ,MAAM,GAAG,OAAO;GAChD,MAAM,SAAS,QAAQ,MAAM,GAAG,CAAC,CAAC;GAClC,IAAI,CAAC,QAAQ,OAAO;GAEpB,OAAO,IAAI,WAAW,aAAa,MAAM,CAAC;EAC5C,SAAS,KAAK;GACZ,QAAQ,KAAK,kCAAkC,GAAG;GAClD,OAAO;EACT;CACF;CAEA,YAAqB;CAErB,UAAgB;EACd,gBAAgB,IAAI;CACtB;AACF;AAEA,6BAA6B,aAAa,SAAS"}
|
|
1
|
+
{"version":3,"file":"renderer.js","names":["RendererFonts.resolveLabelFontCoverage","RendererFonts.getFontProvider","RendererFonts.loadFonts","RendererFonts.isTextPictureCurrent","RendererFonts.prepareForExport","RendererState.hasActiveFlashes","LabelHitTest.hitTestSectionTitle","LabelHitTest.hitTestComponentLabel","LabelHitTest.hitTestFrameTitle","RenderText.measureTextNode","RenderText.nodeFontReadiness","RenderText.isNodeFontLoaded","RenderText.buildTextPicture","RenderText.buildParagraph","RenderColors.resolveFillColorInfo","RenderColors.resolveFillColor","RenderColors.resolveStrokeColorInfo","RenderColors.resolveStrokeColor"],"sources":["../../src/canvas/renderer.ts"],"sourcesContent":["import { isEqual } from 'es-toolkit'\nimport { toUint8Array } from 'js-base64'\n\nimport type { SceneNode, SceneGraph, Fill, Stroke } from '@pairdraw/scene-graph'\nimport type { RenderColorSpace, ResolvedRenderColor } from '@pairdraw/scene-graph/color'\nimport type { Color, Vector } from '@pairdraw/scene-graph/primitives'\nimport { slotPropertyId } from '@pairdraw/scene-graph/slots'\n\n/* eslint-disable max-lines -- SkiaRenderer facade owns CanvasKit state and delegates domain drawing */\nimport {\n DEFAULT_SELECTION_THEME,\n COMPONENT_COLOR,\n SLOT_COLOR,\n CANVAS_BG_COLOR,\n DEFAULT_FONT_SIZE,\n COMPONENT_SET_DASH,\n COMPONENT_SET_DASH_GAP,\n COMPONENT_SET_BORDER_WIDTH,\n IS_BROWSER\n} from '#core/constants'\nimport type { EditorState } from '#core/editor/types'\nimport { RenderProfiler } from '#core/profiler'\nimport type { FontResolutionSnapshot } from '#core/text/resolver'\n\nimport { createImageCache } from './images/cache'\nimport { ImagePreviewCache } from './images/previews'\nimport { LabelCache } from './labels/cache'\nimport * as LabelHitTest from './labels/hit-test'\nimport { LabelParagraphCache } from './labels/paragraph-cache'\nimport { labelHitOptions } from './labels/style'\nimport { NodePathCaches } from './paths/cache'\nimport * as RenderColors from './renderer/colors'\nimport * as RendererFonts from './renderer/fonts'\nimport { destroyRenderer, releaseLiveImages } from './renderer/lifecycle'\nimport { installRendererDomainMethods, type RendererDomainMethods } from './renderer/methods'\nimport { initializeRendererPaints, initializeSelectionPaintColors } from './renderer/paints'\nimport * as RenderPipeline from './renderer/pipeline'\nimport type { SceneBacking, SceneBackingBuild } from './renderer/retained-backing/types'\nimport * as RendererState from './renderer/state'\nimport * as RenderText from './text'\nimport type { SavedDecorationCache } from './text/decorations'\nimport { createDerivedGlyphPathCache, createGlyphSilhouetteCache } from './text/derived'\nimport { createEmojiImageCache } from './text/emoji'\nimport { TextPreparationCache } from './text/preparation/cache'\nexport type {\n MeasurementMode,\n PresenceCursor,\n RenderOverlays,\n RulerTheme,\n SelectionTheme\n} from './renderer/types'\nimport type {\n CanvasKit,\n Surface,\n Canvas,\n Blender,\n Paint,\n Font,\n FontMgr,\n TypefaceFontProvider,\n SkPicture,\n ImageFilter,\n MaskFilter,\n RuntimeEffect,\n Image,\n TextureSource\n} from 'canvaskit-wasm'\n\nexport interface SubtreePictureCacheEntry {\n picture: SkPicture\n pageId: string | null\n sceneVersion: number\n positionPreviewVersion: number\n fontGeneration: number\n}\n\nexport interface PendingFontNode {\n node: SceneNode\n keys: Set<string>\n}\n\nimport type { PlacedStatusLabel } from './labels/status'\nimport { EffectRasterCache } from './renderer/effect-raster-cache'\nimport { TiledSceneController } from './renderer/tiles'\nimport type { TransientCanvasPreview } from './renderer/transient-previews'\nimport type { RenderOverlays, RulerTheme, SelectionTheme } from './renderer/types'\n\n/**\n * A picture uploaded as a texture that knows its size: an `ImageBitmap`, or a canvas, which\n * WebGL uploads as it does an image though CanvasKit's types leave it out. A canvas is uploaded\n * as it is when this is called, so a WebGPU canvas is passed in the task that drew it.\n */\nexport type LiveImageSource =\n | Extract<TextureSource, { width: number; height: number }>\n | HTMLCanvasElement\n\nconst textureSource = (source: LiveImageSource) => source as TextureSource\n\nexport class SkiaRenderer {\n ck: CanvasKit\n surface: Surface\n declare fillPaint: Paint\n diamondGradientEffect: RuntimeEffect | null = null\n pixelGridEffect: RuntimeEffect | null = null\n linearBurnBlender: Blender | null = null\n linearDodgeBlender: Blender | null = null\n declare strokePaint: Paint\n declare selectionPaint: Paint\n declare parentOutlinePaint: Paint\n declare snapPaint: Paint\n declare auxFill: Paint\n declare auxStroke: Paint\n declare opacityPaint: Paint\n declare effectLayerPaint: Paint\n imageFilterCache = new Map<string, ImageFilter | null>()\n maskFilterCache = new Map<number, MaskFilter | null>()\n _tmpColor = new Float32Array(4)\n _tmpRect = new Float32Array(4)\n textFont: Font | null = null\n labelFont: Font | null = null\n sizeFont: Font | null = null\n /** Inter SemiBold at 11 px, which Figma sets the padding and gap values on the canvas in. */\n valueFont: Font | null = null\n sectionTitleFont: Font | null = null\n componentLabelFont: Font | null = null\n fontMgr: FontMgr | null = null\n fontProvider: TypefaceFontProvider | null = null\n fontsLoaded = false\n fontGeneration = 0\n onFontResolutionSettled:\n | ((snapshot: FontResolutionSnapshot, nodeIds: readonly string[]) => void)\n | undefined\n pendingFontNodes = new Map<string, PendingFontNode>()\n textPictureGenerations = new Map<string, { data: Uint8Array; generation: number }>()\n readonly transientPreviews = new Map<string, TransientCanvasPreview>()\n imageCache = createImageCache()\n /**\n * Images drawn in place of stored ones while they play, such as a shader's live frames, each\n * with the surface whose GL context holds its texture.\n */\n readonly liveImages = new Map<string, { image: Image; surface: Surface }>()\n viewportImageRendering = false\n imageMemoryGraph: SceneGraph | null = null\n imageMemoryPage: string | null = null\n onImagePreviewReady: (() => void) | null = null\n readonly imagePreviews = new ImagePreviewCache(() => this.onImagePreviewReady?.())\n nodePaths = new NodePathCaches()\n /** Path-text glyph silhouettes (stroke-and-union, font units) keyed by blob hash + relative weight. */\n glyphSilhouetteCache = createGlyphSilhouetteCache()\n derivedGlyphPathCache = createDerivedGlyphPathCache()\n derivedDecorationCache: SavedDecorationCache = new WeakMap()\n /** Images of the emoji saved text draws, by what drew them and the emoji. */\n emojiImageCache = createEmojiImageCache()\n renderingSceneBacking = false\n scenePicture: SkPicture | null = null\n scenePictureVersion = -1\n scenePictureFontGeneration = -1\n scenePicturePositionPreviewVersion = -1\n scenePicturePageId: string | null = null\n sceneBacking: SceneBacking | null = null\n sceneBackingPreviewUntil = 0\n sceneBackingNeedsCrispRender = false\n sceneBackingAllocationFailed = false\n sceneBackingBuild: SceneBackingBuild | null = null\n sceneBackingAverageRecordMs = 40\n sceneBackingAverageViewportIntervalMs = 80\n sceneBackingLastViewportEventAt = 0\n navigationPhase: EditorState['navigation']['phase'] = 'idle'\n navigationGeneration = 0\n /** Selections draw handles to drag; off while the canvas offers no edits. */\n editHandles = true\n tiledSceneEnabled = false\n /**\n * What an empty sticky note shows while it is edited on this canvas, in the interface language;\n * null for a canvas that draws only the document, such as an export.\n */\n stickyPlaceholder: string | null = null\n /** What an empty connector label shows while it is typed into; null draws nothing. */\n connectorLabelPlaceholder: string | null = null\n tracksSceneSettlement = true\n /** Colour space this renderer's surface presents; colours convert into it when painting. */\n presentationColorSpace: RenderColorSpace = 'srgb'\n tiledScenePending = false\n tiledSceneCovered = false\n lastSceneViewport: { panX: number; panY: number; zoom: number } | null = null\n nodePictureCache = new Map<string, SkPicture | null>()\n nodePictureCacheGenerations = new Map<string, number>()\n effectRasterCache = new EffectRasterCache()\n subtreePictureCache = new Map<string, SubtreePictureCacheEntry>()\n subtreePictureCachePageId: string | null = null\n subtreePictureCacheSceneVersion = -1\n subtreePictureCachePositionPreviewVersion = -1\n subtreePictureCacheFontGeneration = -1\n readonly labelCache = new LabelCache()\n readonly labelParagraphCache = new LabelParagraphCache(undefined, undefined, {\n onMissingGlyphs: (missing) => RendererFonts.resolveLabelFontCoverage(this, missing)\n })\n readonly textPreparationCache = new TextPreparationCache()\n readonly tiledScene = new TiledSceneController()\n readonly profiler: RenderProfiler\n\n declare rulerBgPaint: Paint\n declare rulerTickPaint: Paint\n declare rulerTextPaint: Paint\n declare rulerHlPaint: Paint\n declare rulerBadgePaint: Paint\n declare rulerLabelPaint: Paint\n declare penPathPaint: Paint\n declare penLiveStrokePaint: Paint\n /** The pencil stroke being drawn; its colour and width are set per frame. */\n declare pencilStrokePaint: Paint\n declare penHandlePaint: Paint\n declare penVertexFill: Paint\n declare penVertexStroke: Paint\n\n panX = 0\n panY = 0\n zoom = 1\n dpr = 1\n viewportWidth = 0\n viewportHeight = 0\n showRulers = true\n pageColor = CANVAS_BG_COLOR\n rulerTheme: RulerTheme | null = null\n /** Selection chrome, set from editor state each frame through {@link setSelectionTheme}. */\n selectionTheme: SelectionTheme = DEFAULT_SELECTION_THEME\n pageId: string | null = null\n /** Status labels drawn in the last label pass; clicks on them open the status menu. */\n statusLabels: PlacedStatusLabel[] = []\n\n /**\n * The most device pixels this canvas draws per CSS pixel; a low-power canvas caps it at 1 so a\n * high-density display draws a quarter of the pixels. The canvas buffer must be sized the same.\n */\n maxPixelRatio = Number.POSITIVE_INFINITY\n /**\n * Draws expensive effects cheaply on this canvas: background blurs and noise are left out, and\n * cached shadows keep one pixel per unit at any zoom. Exports still draw every effect.\n */\n reducedEffects = false\n /** Set while an export draws the document, so every effect is drawn whatever `reducedEffects` says. */\n drawingFullEffects = false\n boundEffectLayersToViewport = false\n worldViewport = { x: 0, y: 0, w: 0, h: 0 }\n _nodeCount = 0\n _culledCount = 0\n _flashes: Array<{ nodeId: string; startTime: number }> = []\n _flashPaint: Paint | null = null\n _aiActiveNodes: Set<string> = new Set()\n _aiDoneFlashes: Array<{ nodeId: string; startTime: number }> = []\n /** Layers an agent added, each tracing in from its start, which may still be ahead. */\n _aiEntrances: Array<{ nodeId: string; startTime: number }> = []\n\n readonly DEFAULT_FONT_SIZE = DEFAULT_FONT_SIZE\n readonly COMPONENT_SET_BORDER_WIDTH = COMPONENT_SET_BORDER_WIDTH\n readonly COMPONENT_SET_DASH = COMPONENT_SET_DASH\n readonly COMPONENT_SET_DASH_GAP = COMPONENT_SET_DASH_GAP\n\n declare drawHoverHighlight: RendererDomainMethods['drawHoverHighlight']\n declare drawMeasurements: RendererDomainMethods['drawMeasurements']\n declare drawEnteredContainer: RendererDomainMethods['drawEnteredContainer']\n declare drawSelection: RendererDomainMethods['drawSelection']\n declare drawNodeSelection: RendererDomainMethods['drawNodeSelection']\n declare drawSelectionLabels: RendererDomainMethods['drawSelectionLabels']\n declare drawParentFrameOutlines: RendererDomainMethods['drawParentFrameOutlines']\n declare drawNodeOutline: RendererDomainMethods['drawNodeOutline']\n declare drawGroupBounds: RendererDomainMethods['drawGroupBounds']\n declare getRotatedCorners: RendererDomainMethods['getRotatedCorners']\n declare drawHandle: RendererDomainMethods['drawHandle']\n declare drawSnapGuides: RendererDomainMethods['drawSnapGuides']\n declare drawSnapMarks: RendererDomainMethods['drawSnapMarks']\n declare drawMarquee: RendererDomainMethods['drawMarquee']\n declare drawFlashes: RendererDomainMethods['drawFlashes']\n declare drawLayoutInsertIndicator: RendererDomainMethods['drawLayoutInsertIndicator']\n declare drawAutoLayoutHover: RendererDomainMethods['drawAutoLayoutHover']\n declare drawTextEditOverlay: RendererDomainMethods['drawTextEditOverlay']\n declare drawNodeEditOverlay: RendererDomainMethods['drawNodeEditOverlay']\n declare drawPenOverlay: RendererDomainMethods['drawPenOverlay']\n declare drawPencilOverlay: RendererDomainMethods['drawPencilOverlay']\n declare drawPresenceCursors: RendererDomainMethods['drawPresenceCursors']\n declare drawRulers: RendererDomainMethods['drawRulers']\n declare drawFrameTitles: RendererDomainMethods['drawFrameTitles']\n declare drawSectionTitles: RendererDomainMethods['drawSectionTitles']\n declare drawComponentLabels: RendererDomainMethods['drawComponentLabels']\n declare renderNodeSelf: RendererDomainMethods['renderNodeSelf']\n declare renderNode: RendererDomainMethods['renderNode']\n declare renderSection: RendererDomainMethods['renderSection']\n declare renderComponentSet: RendererDomainMethods['renderComponentSet']\n declare renderShape: RendererDomainMethods['renderShape']\n declare renderShapeUncached: RendererDomainMethods['renderShapeUncached']\n declare paintShapeContent: RendererDomainMethods['paintShapeContent']\n declare renderEffects: RendererDomainMethods['renderEffects']\n declare renderText: RendererDomainMethods['renderText']\n declare drawNodeFill: RendererDomainMethods['drawNodeFill']\n declare applyFill: RendererDomainMethods['applyFill']\n declare applyGradientFill: RendererDomainMethods['applyGradientFill']\n declare applyImageFill: RendererDomainMethods['applyImageFill']\n declare drawNodeStroke: RendererDomainMethods['drawNodeStroke']\n declare drawStrokeWithAlign: RendererDomainMethods['drawStrokeWithAlign']\n declare drawRRectStrokeWithAlign: RendererDomainMethods['drawRRectStrokeWithAlign']\n declare drawIndividualSideStrokes: RendererDomainMethods['drawIndividualSideStrokes']\n declare strokeNodeShape: RendererDomainMethods['strokeNodeShape']\n declare makeNodeShapePath: RendererDomainMethods['makeNodeShapePath']\n declare makePolygonPath: RendererDomainMethods['makePolygonPath']\n declare makeRRect: RendererDomainMethods['makeRRect']\n declare makeRRectWithSpread: RendererDomainMethods['makeRRectWithSpread']\n declare clipNodeShape: RendererDomainMethods['clipNodeShape']\n declare getVectorPaths: RendererDomainMethods['getVectorPaths']\n declare getFillGeometry: RendererDomainMethods['getFillGeometry']\n declare getStrokeGeometry: RendererDomainMethods['getStrokeGeometry']\n declare getCachedDropShadow: RendererDomainMethods['getCachedDropShadow']\n declare getCachedBlur: RendererDomainMethods['getCachedBlur']\n declare getCachedDecalBlur: RendererDomainMethods['getCachedDecalBlur']\n declare getCachedMaskBlur: RendererDomainMethods['getCachedMaskBlur']\n declare applyClippedBlur: RendererDomainMethods['applyClippedBlur']\n color4f(r: number, g: number, b: number, a: number): Float32Array {\n const c = this._tmpColor\n c[0] = r\n c[1] = g\n c[2] = b\n c[3] = a\n return c\n }\n\n ltrb(l: number, t: number, r: number, b: number): Float32Array {\n const rc = this._tmpRect\n rc[0] = l\n rc[1] = t\n rc[2] = r\n rc[3] = b\n return rc\n }\n\n selColor(alpha = 1) {\n const { r, g, b } = this.selectionTheme.color\n return this.ck.Color4f(r, g, b, alpha)\n }\n\n selForegroundColor() {\n const { r, g, b } = this.selectionTheme.foreground\n return this.ck.Color4f(r, g, b, 1)\n }\n\n /** Switches selection chrome to `theme`, repainting the paints that keep it between frames. */\n setSelectionTheme(theme: SelectionTheme = DEFAULT_SELECTION_THEME): void {\n if (isEqual(theme, this.selectionTheme)) return\n this.selectionTheme = { color: { ...theme.color }, foreground: { ...theme.foreground } }\n initializeSelectionPaintColors(this)\n }\n\n compColor(alpha = 1) {\n return this.ck.Color4f(COMPONENT_COLOR.r, COMPONENT_COLOR.g, COMPONENT_COLOR.b, alpha)\n }\n\n slotColor(alpha = 1) {\n return this.ck.Color4f(SLOT_COLOR.r, SLOT_COLOR.g, SLOT_COLOR.b, alpha)\n }\n\n /**\n * The outline colour for a node: pink for slots, purple for components, instances and every\n * layer inside them, as in Figma, blue otherwise.\n */\n outlineColor(node: SceneNode, graph: SceneGraph) {\n if (slotPropertyId(node)) return this.slotColor()\n return this.isInComponent(node, graph) ? this.compColor() : this.selColor()\n }\n\n /** Text drawn on {@link outlineColor}: white on slot and component colors, else the selection foreground. */\n outlineForegroundColor(node: SceneNode, graph: SceneGraph) {\n if (slotPropertyId(node) || this.isInComponent(node, graph)) return this.ck.WHITE\n return this.selForegroundColor()\n }\n\n /** A component, instance or set, or a layer inside one; content placed in a slot is not. */\n isInComponent(node: SceneNode, graph: SceneGraph): boolean {\n const owner = graph.closest(\n node.id,\n (layer) => this.isComponentType(layer.type) || slotPropertyId(layer) !== undefined\n )\n return owner !== undefined && !slotPropertyId(owner)\n }\n\n isComponentType(type: string): boolean {\n return type === 'COMPONENT' || type === 'COMPONENT_SET' || type === 'INSTANCE'\n }\n\n isRectangularType(type: string): boolean {\n return (\n type === 'FRAME' ||\n type === 'RECTANGLE' ||\n type === 'ROUNDED_RECTANGLE' ||\n type === 'COMPONENT' ||\n type === 'INSTANCE' ||\n type === 'SECTION' ||\n type === 'GROUP'\n )\n }\n\n effectOverflow(node: SceneNode): number {\n let expand = 0\n for (const e of node.effects) {\n // A shader effect has no radius, spread, or offset of its own.\n if (!e.visible || e.type === 'SHADER') continue\n const blur = e.radius\n const spread = e.spread\n const ox = Math.abs(e.offset.x)\n const oy = Math.abs(e.offset.y)\n expand = Math.max(expand, blur + spread + ox, blur + spread + oy)\n }\n return expand\n }\n\n constructor(ck: CanvasKit, surface: Surface, gl?: WebGL2RenderingContext | null) {\n this.ck = ck\n this.surface = surface\n this.profiler = new RenderProfiler(ck, gl ?? null)\n initializeRendererPaints(this)\n }\n\n getFontProvider(): TypefaceFontProvider | null {\n return RendererFonts.getFontProvider(this)\n }\n\n isDestroyed(): boolean {\n return this.destroyed\n }\n\n async loadFonts(onFallbackFontsLoaded?: () => void): Promise<void> {\n await RendererFonts.loadFonts(this, onFallbackFontsLoaded)\n }\n\n syncFontGeneration(): void {\n RendererFonts.syncFontGeneration(this)\n }\n\n trackFontDemand(node: SceneNode, key: string): void {\n RendererFonts.trackFontDemand(this, node, key)\n }\n\n isTextPictureCurrent(node: SceneNode): boolean {\n return RendererFonts.isTextPictureCurrent(this, node)\n }\n\n async prepareForExport(graph: SceneGraph, pageId: string, nodeIds: string[]): Promise<void> {\n return RendererFonts.prepareForExport(this, graph, pageId, nodeIds)\n }\n\n replaceSurface(surface: Surface): void {\n this.tiledScene.destroy()\n // Live textures belong to the old surface's context, so they go before it does.\n releaseLiveImages(this)\n this.surface.delete()\n this.surface = surface\n this.sceneBackingAllocationFailed = false\n this.invalidateScenePicture()\n }\n\n invalidateScenePicture(): void {\n RendererState.invalidateScenePicture(this)\n }\n\n /** Drop every cached picture; `keepShapedText` keeps the sizes identical text shaped to. */\n invalidateAllPictures(options?: { keepShapedText?: boolean }): void {\n RendererState.invalidateAllPictures(this, options)\n }\n\n /**\n * Draws `source` wherever the image `hash` is painted, until it is set to null, and redraws\n * `nodeIds`, the layers that paint it. Frames of the same size reuse one texture. Returns\n * whether a live image is shown, which a browser that cannot upload `source` leaves false.\n */\n setLiveImage(\n hash: string,\n source: LiveImageSource | null,\n nodeIds: Iterable<string> = []\n ): boolean {\n const live = this.liveImages.get(hash)\n // A texture made on a surface since replaced has no context left to update or free it in.\n const current = live?.surface === this.surface ? live.image : null\n if (\n source &&\n current &&\n current.width() === source.width &&\n current.height() === source.height\n ) {\n this.surface.updateTextureFromSource(current, textureSource(source))\n } else {\n current?.delete()\n this.liveImages.delete(hash)\n const image = source && this.surface.makeImageFromTextureSource(textureSource(source))\n if (image) this.liveImages.set(hash, { image, surface: this.surface })\n }\n for (const id of nodeIds) this.invalidateNodePicture(id)\n return this.liveImages.has(hash)\n }\n\n /**\n * Forgets the decoded image `hash` after its bytes were replaced, such as a shader's frame\n * rendered again, and redraws whatever showed it. Previews notice new bytes themselves.\n */\n forgetImage(hash: string): void {\n const keys = Array.from(this.imageCache.entries(), ([key]) => key)\n for (const key of keys) {\n if (key === hash || key.startsWith(`${hash}:`)) this.imageCache.delete(key)\n }\n this.invalidateAllPictures()\n }\n\n /** Drops `nodeId`'s cached drawing; `changedKeys`, when known, lets text keep its glyph coverage. */\n invalidateNodePicture(nodeId: string, changedKeys?: readonly (keyof SceneNode)[]): void {\n RendererState.invalidateNodePicture(this, nodeId, changedKeys)\n }\n\n flashNode(nodeId: string): void {\n RendererState.flashNode(this, nodeId)\n }\n\n aiMarkActive(nodeIds: string[]): void {\n RendererState.aiMarkActive(this, nodeIds)\n }\n\n aiMarkDone(nodeIds: string[]): void {\n RendererState.aiMarkDone(this, nodeIds)\n }\n\n aiFlashDone(nodeIds: string[]): void {\n RendererState.aiFlashDone(this, nodeIds)\n }\n\n /** Traces in layers an agent added, one after another in the order given. */\n aiEnter(nodeIds: string[]): void {\n RendererState.aiEnter(this, nodeIds)\n }\n\n aiClearAll(): void {\n RendererState.aiClearAll(this)\n }\n\n get hasActiveFlashes(): boolean {\n return RendererState.hasActiveFlashes(this)\n }\n\n hitTestSectionTitle(\n graph: SceneGraph,\n canvasX: number,\n canvasY: number,\n preview?: RenderOverlays['rotationPreview']\n ): SceneNode | null {\n return LabelHitTest.hitTestSectionTitle(\n graph,\n canvasX,\n canvasY,\n this.zoom,\n this.pageId ?? graph.rootId,\n this.sectionTitleFont,\n this.labelCache,\n labelHitOptions(this, graph, preview)\n )\n }\n\n hitTestComponentLabel(\n graph: SceneGraph,\n canvasX: number,\n canvasY: number,\n preview?: RenderOverlays['rotationPreview']\n ): SceneNode | null {\n return LabelHitTest.hitTestComponentLabel(\n graph,\n canvasX,\n canvasY,\n this.zoom,\n this.pageId ?? graph.rootId,\n this.componentLabelFont,\n this.labelCache,\n labelHitOptions(this, graph, preview)\n )\n }\n\n hitTestFrameTitle(\n graph: SceneGraph,\n canvasX: number,\n canvasY: number,\n preview?: RenderOverlays['rotationPreview']\n ): SceneNode | null {\n return LabelHitTest.hitTestFrameTitle(\n graph,\n canvasX,\n canvasY,\n this.zoom,\n this.pageId ?? graph.rootId,\n this.labelFont,\n this.labelCache,\n labelHitOptions(this, graph, preview)\n )\n }\n\n /** Whether effects are drawn cheaply right now: on a reduced-effects canvas, outside exports. */\n get effectsReduced(): boolean {\n return this.reducedEffects && !this.drawingFullEffects\n }\n\n renderSceneToCanvas(canvas: Canvas, graph: SceneGraph, pageId: string): void {\n RenderPipeline.renderSceneToCanvas(this, canvas, graph, pageId)\n }\n\n renderFromEditorState(\n state: EditorState,\n graph: SceneGraph,\n textEditor: unknown,\n viewportWidth: number,\n viewportHeight: number,\n showRulers = true,\n layer: RenderPipeline.RenderLayer = 'full',\n interactive = false\n ): void {\n const dpr = Math.min(IS_BROWSER ? window.devicePixelRatio || 1 : 1, this.maxPixelRatio)\n RenderPipeline.renderFromEditorState(\n this,\n state,\n graph,\n textEditor,\n viewportWidth,\n viewportHeight,\n showRulers,\n dpr,\n layer,\n interactive\n )\n }\n\n render(\n graph: SceneGraph,\n selectedIds: Set<string>,\n overlays: RenderOverlays = {},\n sceneVersion = -1,\n layer: RenderPipeline.RenderLayer = 'full'\n ): void {\n RenderPipeline.render(this, graph, selectedIds, overlays, sceneVersion, layer)\n }\n\n invalidateVectorPath(nodeId: string): void {\n this.nodePaths.invalidate(nodeId)\n }\n\n measureTextNode(node: SceneNode, maxWidth?: number): { width: number; height: number } | null {\n return RenderText.measureTextNode(this, node, maxWidth)\n }\n\n nodeFontReadiness(node: SceneNode): RenderText.NodeFontReadiness {\n return RenderText.nodeFontReadiness(this, node)\n }\n\n isNodeFontLoaded(node: SceneNode): boolean {\n return RenderText.isNodeFontLoaded(this, node)\n }\n\n buildTextPicture(node: SceneNode): Uint8Array | null {\n return RenderText.buildTextPicture(this, node)\n }\n\n buildParagraph(\n node: SceneNode,\n color?: Float32Array,\n opts?: RenderText.ParagraphBuildOptions\n ): RenderText.TextLayout {\n return RenderText.buildParagraph(this, node, color, opts)\n }\n\n resolveFillColorInfo(\n fill: Fill,\n fillIndex: number,\n node: SceneNode,\n graph: SceneGraph\n ): ResolvedRenderColor {\n return RenderColors.resolveFillColorInfo(\n fill,\n fillIndex,\n node,\n graph,\n this.presentationColorSpace\n )\n }\n\n resolveFillColor(fill: Fill, fillIndex: number, node: SceneNode, graph: SceneGraph): Color {\n return RenderColors.resolveFillColor(fill, fillIndex, node, graph, this.presentationColorSpace)\n }\n\n resolveStrokeColorInfo(\n stroke: Stroke,\n strokeIndex: number,\n node: SceneNode,\n graph: SceneGraph\n ): ResolvedRenderColor {\n return RenderColors.resolveStrokeColorInfo(\n stroke,\n strokeIndex,\n node,\n graph,\n this.presentationColorSpace\n )\n }\n\n resolveStrokeColor(\n stroke: Stroke,\n strokeIndex: number,\n node: SceneNode,\n graph: SceneGraph\n ): Color {\n return RenderColors.resolveStrokeColor(\n stroke,\n strokeIndex,\n node,\n graph,\n this.presentationColorSpace\n )\n }\n\n screenToCanvas(sx: number, sy: number): Vector {\n return {\n x: (sx - this.panX) / this.zoom,\n y: (sy - this.panY) / this.zoom\n }\n }\n\n /**\n * Browser fallback for raster formats CanvasKit cannot encode itself\n * (this build returns null from `encodeToBytes` for JPEG/WEBP). Routes the\n * RGBA pixels through an HTMLCanvasElement so `toDataURL` does the encoding.\n * Returns null outside the browser or if encoding fails.\n */\n encodeRasterFallback(\n pixels: Uint8Array,\n width: number,\n height: number,\n format: 'JPG' | 'WEBP',\n quality: number\n ): Uint8Array<ArrayBuffer> | null {\n if (!IS_BROWSER) return null\n try {\n const canvas = document.createElement('canvas')\n canvas.width = width\n canvas.height = height\n const ctx = canvas.getContext('2d')\n if (!ctx) return null\n const imageData = ctx.createImageData(width, height)\n imageData.data.set(pixels)\n ctx.putImageData(imageData, 0, 0)\n const mime = format === 'JPG' ? 'image/jpeg' : 'image/webp'\n const dataURL = canvas.toDataURL(mime, quality / 100)\n // Browsers silently return a PNG data URL when the requested encoder is\n // unsupported; reject that so we never write PNG bytes under a .jpg/.webp file.\n if (!dataURL.startsWith(`data:${mime}`)) return null\n const base64 = dataURL.split(',')[1]\n if (!base64) return null\n // js-base64 types its bytes as any buffer; a copy has the plain one a `Blob` takes.\n return new Uint8Array(toUint8Array(base64))\n } catch (err) {\n console.warn('Raster encode fallback failed:', err)\n return null\n }\n }\n\n destroyed: boolean = false\n\n destroy(): void {\n destroyRenderer(this)\n }\n}\n\ninstallRendererDomainMethods(SkiaRenderer.prototype)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAgGA,MAAM,iBAAiB,WAA4B;AAEnD,IAAa,eAAb,MAA0B;CACxB;CACA;CAEA,wBAA8C;CAC9C,kBAAwC;CACxC,oBAAoC;CACpC,qBAAqC;CASrC,mCAAmB,IAAI,IAAgC;CACvD,kCAAkB,IAAI,IAA+B;CACrD,4BAAY,IAAI,aAAa,CAAC;CAC9B,2BAAW,IAAI,aAAa,CAAC;CAC7B,WAAwB;CACxB,YAAyB;CACzB,WAAwB;;CAExB,YAAyB;CACzB,mBAAgC;CAChC,qBAAkC;CAClC,UAA0B;CAC1B,eAA4C;CAC5C,cAAc;CACd,iBAAiB;CACjB;CAGA,mCAAmB,IAAI,IAA6B;CACpD,yCAAyB,IAAI,IAAsD;CACnF,oCAA6B,IAAI,IAAoC;CACrE,aAAa,iBAAiB;;;;;CAK9B,6BAAsB,IAAI,IAAgD;CAC1E,yBAAyB;CACzB,mBAAsC;CACtC,kBAAiC;CACjC,sBAA2C;CAC3C,gBAAyB,IAAI,wBAAwB,KAAK,sBAAsB,CAAC;CACjF,YAAY,IAAI,eAAe;;CAE/B,uBAAuB,2BAA2B;CAClD,wBAAwB,4BAA4B;CACpD,yCAA+C,IAAI,QAAQ;;CAE3D,kBAAkB,sBAAsB;C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AY,IAAI,gBAAgB,OAAO,MAAM;GACnD,UAAU,KAAK,IAAI,MAAM;GACzB,IAAI,aAAa,WAAW,GAAG,CAAC;GAChC,MAAM,OAAO,WAAW,QAAQ,eAAe;GAC/C,MAAM,UAAU,OAAO,UAAU,MAAM,UAAU,GAAG;GAGpD,IAAI,CAAC,QAAQ,WAAW,QAAQ,MAAM,GAAG,OAAO;GAChD,MAAM,SAAS,QAAQ,MAAM,GAAG,CAAC,CAAC;GAClC,IAAI,CAAC,QAAQ,OAAO;GAEpB,OAAO,IAAI,WAAW,aAAa,MAAM,CAAC;EAC5C,SAAS,KAAK;GACZ,QAAQ,KAAK,kCAAkC,GAAG;GAClD,OAAO;EACT;CACF;CAEA,YAAqB;CAErB,UAAgB;EACd,gBAAgB,IAAI;CACtB;AACF;AAEA,6BAA6B,aAAa,SAAS"}
|
|
@@ -43,6 +43,11 @@ declare class TextPreparationCache {
|
|
|
43
43
|
private currentShaping;
|
|
44
44
|
private shapingFor;
|
|
45
45
|
clear(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Forget every layer, keeping what identical text shaped to, such as its sizes. For a renderer
|
|
48
|
+
* that draws a new graph each time, whose layer IDs can name different text from one to the next.
|
|
49
|
+
*/
|
|
50
|
+
releaseLayers(): void;
|
|
46
51
|
}
|
|
47
52
|
//#endregion
|
|
48
53
|
export { PreparedText, TextPreparationCache };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","names":[],"sources":["../../../../src/canvas/text/preparation/cache.ts"],"mappings":";;;;;;;UAwBiB;EACf,WAAW;EACX,gBAAgB,kBAAkB;;EAElC;IAAgB;IAAW,OAAO;;;cAyBvB;mBAiBQ;mBACA;mBAjBF;mBACA;UAIT;mBACS;mBAKA;UACT;UACA;EAGW,YAAA,qBACA;;EAgBnB,IAAI,GACF,MAAM,WACN,iBACA,oBACA,UAAU,sBACV,aAAa,YACb,UAAU,UAAU,iBAAiB,IACpC;EAmCH,iBAAiB,MAAM,WAAW,oBAAoB,UAAU;;EAOhE,oBAAoB,MAAM;;EAK1B,QACE,MAAM,WACN,qBACA,oBACA,UAAU,sBACV,eAAe,OACd;;;;;EAeH,WAAW,cAAc;;;UAajB;UAOA;UAoBA;EAeR"}
|
|
1
|
+
{"version":3,"file":"cache.d.ts","names":[],"sources":["../../../../src/canvas/text/preparation/cache.ts"],"mappings":";;;;;;;UAwBiB;EACf,WAAW;EACX,gBAAgB,kBAAkB;;EAElC;IAAgB;IAAW,OAAO;;;cAyBvB;mBAiBQ;mBACA;mBAjBF;mBACA;UAIT;mBACS;mBAKA;UACT;UACA;EAGW,YAAA,qBACA;;EAgBnB,IAAI,GACF,MAAM,WACN,iBACA,oBACA,UAAU,sBACV,aAAa,YACb,UAAU,UAAU,iBAAiB,IACpC;EAmCH,iBAAiB,MAAM,WAAW,oBAAoB,UAAU;;EAOhE,oBAAoB,MAAM;;EAK1B,QACE,MAAM,WACN,qBACA,oBACA,UAAU,sBACV,eAAe,OACd;;;;;EAeH,WAAW,cAAc;;;UAajB;UAOA;UAoBA;EAeR;;;;;EASA"}
|
|
@@ -141,10 +141,17 @@ var TextPreparationCache = class {
|
|
|
141
141
|
return created;
|
|
142
142
|
}
|
|
143
143
|
clear() {
|
|
144
|
+
this.releaseLayers();
|
|
145
|
+
this.results.clear();
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Forget every layer, keeping what identical text shaped to, such as its sizes. For a renderer
|
|
149
|
+
* that draws a new graph each time, whose layer IDs can name different text from one to the next.
|
|
150
|
+
*/
|
|
151
|
+
releaseLayers() {
|
|
144
152
|
this.nodeKeys.clear();
|
|
145
153
|
this.shaping = /* @__PURE__ */ new WeakMap();
|
|
146
154
|
this.invalidatedShaping.clear();
|
|
147
|
-
this.results.clear();
|
|
148
155
|
this.entries.clear();
|
|
149
156
|
}
|
|
150
157
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.js","names":[],"sources":["../../../../src/canvas/text/preparation/cache.ts"],"sourcesContent":["import type { TypefaceFontProvider } from 'canvaskit-wasm'\n\nimport type { SceneNode } from '@pairdraw/scene-graph'\nimport type { Size } from '@pairdraw/scene-graph/primitives'\n\nimport { ResourceCache } from '#core/cache/resource'\nimport type { missingGlyphOccurrences } from '#core/text/resolver'\n\n// Bound both the number of native paragraphs and the text retained by them.\n// Source UTF-16 units are a workload bound, not an estimate of native bytes.\nconst MAX_PREPARED_PARAGRAPHS = 1024\nconst MAX_PREPARED_TEXT_UNITS = 262_144\n// Layout measures a text at a few widths; more than this means the widths are not repeating.\nconst MAX_MEASURED_WIDTHS = 16\n// Bound the shapings layers share by their key length, which holds the text.\nconst MAX_SHARED_SHAPINGS = 8192\nconst MAX_SHARED_SHAPING_UNITS = 1_048_576\n\nimport type { TextDecorationRect } from '#core/canvas/text/decorations'\nimport type { TextLayout } from '#core/canvas/text/layout'\nimport { PARAGRAPH_INPUT_KEYS, shapingInputs } from '#core/canvas/text/paragraph/inputs'\n\ntype PreparationInput = SceneNode[(typeof PARAGRAPH_INPUT_KEYS)[number]]\n\nexport interface PreparedText {\n paragraph: TextLayout\n missingGlyphs?: ReturnType<typeof missingGlyphOccurrences>\n /** The underlines and strikethroughs drawn `y` below the text's top, found once per layout. */\n decorations?: { y: number; rects: TextDecorationRect[] }\n}\n\n/** What shaping a text showed: whether its faces cover it, and its size at each layout width. */\ninterface ShapingResult {\n covered: boolean\n sizes: Map<number, Size>\n}\n\n/**\n * A node's view of the shaping its text shows, valid while its `shapingInputs` stay the same. The\n * result is shared by every layer whose text shapes the same, such as an instance's copies.\n */\ninterface Shaping {\n inputs: PreparationInput[]\n key: string\n result: ShapingResult\n}\n\ninterface Entry extends PreparedText {\n nodeId: string\n inputs: PreparationInput[]\n units: number\n}\n\nexport class TextPreparationCache {\n private readonly entries: ResourceCache<string, Entry>\n private readonly nodeKeys = new Map<string, Set<string>>()\n // Coverage and measured sizes contain no native resources. Keep them independently of\n // paragraph LRU eviction: each node's view weakly owned by the node, the results it shares with\n // identical text bounded by their keys.\n private shaping = new WeakMap<SceneNode, Shaping>()\n private readonly results = new ResourceCache<string, ShapingResult>({\n maxEntries: MAX_SHARED_SHAPINGS,\n maxWeight: MAX_SHARED_SHAPING_UNITS,\n weight: (_result, key) => key.length\n })\n private readonly invalidatedShaping = new Set<string>()\n private generation = -1\n private provider: TypefaceFontProvider | null = null\n\n constructor(\n private readonly maxEntries = MAX_PREPARED_PARAGRAPHS,\n private readonly maxTextUnits = MAX_PREPARED_TEXT_UNITS\n ) {\n this.entries = new ResourceCache({\n maxEntries,\n maxWeight: maxTextUnits,\n weight: (entry) => entry.units,\n dispose: (entry, key) => {\n const keys = this.nodeKeys.get(entry.nodeId)\n keys?.delete(key)\n if (keys?.size === 0) this.nodeKeys.delete(entry.nodeId)\n entry.paragraph.delete()\n }\n })\n }\n\n /** Borrowed paragraphs must not be retained, deleted or relaid out by drawing callers. */\n use<T>(\n node: SceneNode,\n variant: string,\n generation: number,\n provider: TypefaceFontProvider,\n build: () => TextLayout,\n consume: (prepared: PreparedText) => T\n ): T {\n this.useScope(generation, provider)\n if (node.text.length > this.maxTextUnits || this.maxEntries <= 0) {\n const paragraph = build()\n try {\n return consume({ paragraph })\n } finally {\n paragraph.delete()\n }\n }\n const key = `${node.id}\\0${variant}`\n let entry = this.entries.get(key)\n if (\n entry &&\n !PARAGRAPH_INPUT_KEYS.every((prop, index) => entry?.inputs[index] === node[prop])\n ) {\n // Shaping compares its own inputs, so a change it doesn't see, such as a resize, keeps it.\n this.deleteNode(node.id, { keepShaping: true })\n entry = undefined\n }\n if (!entry) {\n entry = {\n nodeId: node.id,\n inputs: PARAGRAPH_INPUT_KEYS.map((prop) => node[prop]),\n paragraph: build(),\n units: node.text.length\n }\n this.entries.set(key, entry)\n const keys = this.nodeKeys.get(node.id) ?? new Set<string>()\n keys.add(key)\n this.nodeKeys.set(node.id, keys)\n }\n return consume(entry)\n }\n\n hasGlyphCoverage(node: SceneNode, generation: number, provider: TypefaceFontProvider): boolean {\n if (this.generation !== generation || this.provider !== provider) return false\n // A copy that has not shaped yet still finds what its source's identical text showed.\n return this.shapingFor(node).result.covered\n }\n\n /** Call only after observing complete coverage with this cache's current font scope. */\n recordGlyphCoverage(node: SceneNode): void {\n this.shapingFor(node).result.covered = true\n }\n\n /** The size of `node`'s text laid out at `layoutWidth`, measured once per shaping. */\n measure(\n node: SceneNode,\n layoutWidth: number,\n generation: number,\n provider: TypefaceFontProvider,\n compute: () => Size\n ): Size {\n this.useScope(generation, provider)\n const sizes = this.shapingFor(node).result.sizes\n const cached = sizes.get(layoutWidth)\n if (cached) return cached\n const size = compute()\n if (sizes.size >= MAX_MEASURED_WIDTHS) sizes.clear()\n sizes.set(layoutWidth, size)\n return size\n }\n\n /**\n * Drops `id`'s paragraphs and, unless `keepShaping`, its coverage and measured sizes. Keep\n * them only for changes `shapingInputs` compares, such as layout resizing the box.\n */\n deleteNode(id: string, { keepShaping = false } = {}): void {\n // Invalidation arrives by ID; don't add strong node ownership just to find\n // weak observations. Bound pending IDs and conservatively reset on overflow.\n if (!keepShaping) this.invalidatedShaping.add(id)\n if (this.invalidatedShaping.size > this.maxEntries) {\n this.shaping = new WeakMap()\n this.invalidatedShaping.clear()\n this.results.clear()\n }\n const keys = this.nodeKeys.get(id)\n if (keys) for (const key of keys) this.entries.delete(key)\n }\n\n private useScope(generation: number, provider: TypefaceFontProvider): void {\n if (this.generation === generation && this.provider === provider) return\n this.clear()\n this.generation = generation\n this.provider = provider\n }\n\n private currentShaping(node: SceneNode): Shaping | null {\n if (this.invalidatedShaping.delete(node.id)) {\n // An explicit invalidation covers what the inputs cannot show, so the shared result goes too.\n const invalidated = this.shaping.get(node)\n if (invalidated) this.results.delete(invalidated.key)\n this.shaping.delete(node)\n return null\n }\n const shaping = this.shaping.get(node)\n if (!shaping) return null\n const current = shapingInputs(node)\n if (\n current.length === shaping.inputs.length &&\n current.every((input, index) => input === shaping.inputs[index])\n )\n return shaping\n this.shaping.delete(node)\n return null\n }\n\n private shapingFor(node: SceneNode): Shaping {\n const existing = this.currentShaping(node)\n if (existing) return existing\n const inputs = shapingInputs(node)\n const key = JSON.stringify(inputs)\n let result = this.results.get(key)\n if (!result) {\n result = { covered: false, sizes: new Map() }\n this.results.set(key, result)\n }\n const created: Shaping = { inputs, key, result }\n this.shaping.set(node, created)\n return created\n }\n\n clear(): void {\n this.nodeKeys.clear()\n this.shaping = new WeakMap()\n this.invalidatedShaping.clear()\n this.results.clear()\n this.entries.clear()\n }\n}\n"],"mappings":";;;AAUA,MAAM,0BAA0B;AAChC,MAAM,0BAA0B;AAEhC,MAAM,sBAAsB;AAE5B,MAAM,sBAAsB;AAC5B,MAAM,2BAA2B;AAqCjC,IAAa,uBAAb,MAAkC;CAiBb;CACA;CAjBnB;CACA,2BAA4B,IAAI,IAAyB;CAIzD,0BAAkB,IAAI,QAA4B;CAClD,UAA2B,IAAI,cAAqC;EAClE,YAAY;EACZ,WAAW;EACX,SAAS,SAAS,QAAQ,IAAI;CAChC,CAAC;CACD,qCAAsC,IAAI,IAAY;CACtD,aAAqB;CACrB,WAAgD;CAEhD,YACE,aAA8B,yBAC9B,eAAgC,yBAChC;EAFiB,KAAA,aAAA;EACA,KAAA,eAAA;EAEjB,KAAK,UAAU,IAAI,cAAc;GAC/B;GACA,WAAW;GACX,SAAS,UAAU,MAAM;GACzB,UAAU,OAAO,QAAQ;IACvB,MAAM,OAAO,KAAK,SAAS,IAAI,MAAM,MAAM;IAC3C,MAAM,OAAO,GAAG;IAChB,IAAI,MAAM,SAAS,GAAG,KAAK,SAAS,OAAO,MAAM,MAAM;IACvD,MAAM,UAAU,OAAO;GACzB;EACF,CAAC;CACH;;CAGA,IACE,MACA,SACA,YACA,UACA,OACA,SACG;EACH,KAAK,SAAS,YAAY,QAAQ;EAClC,IAAI,KAAK,KAAK,SAAS,KAAK,gBAAgB,KAAK,cAAc,GAAG;GAChE,MAAM,YAAY,MAAM;GACxB,IAAI;IACF,OAAO,QAAQ,EAAE,U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,MAAM,UAAmB;GAAE;GAAQ;GAAK;EAAO;EAC/C,KAAK,QAAQ,IAAI,MAAM,OAAO;EAC9B,OAAO;CACT;CAEA,QAAc;EACZ,KAAK,SAAS,MAAM;EACpB,KAAK,0BAAU,IAAI,QAAQ;EAC3B,KAAK,mBAAmB,MAAM;EAC9B,KAAK,QAAQ,MAAM;EACnB,KAAK,QAAQ,MAAM;CACrB;AACF"}
|
|
1
|
+
{"version":3,"file":"cache.js","names":[],"sources":["../../../../src/canvas/text/preparation/cache.ts"],"sourcesContent":["import type { TypefaceFontProvider } from 'canvaskit-wasm'\n\nimport type { SceneNode } from '@pairdraw/scene-graph'\nimport type { Size } from '@pairdraw/scene-graph/primitives'\n\nimport { ResourceCache } from '#core/cache/resource'\nimport type { missingGlyphOccurrences } from '#core/text/resolver'\n\n// Bound both the number of native paragraphs and the text retained by them.\n// Source UTF-16 units are a workload bound, not an estimate of native bytes.\nconst MAX_PREPARED_PARAGRAPHS = 1024\nconst MAX_PREPARED_TEXT_UNITS = 262_144\n// Layout measures a text at a few widths; more than this means the widths are not repeating.\nconst MAX_MEASURED_WIDTHS = 16\n// Bound the shapings layers share by their key length, which holds the text.\nconst MAX_SHARED_SHAPINGS = 8192\nconst MAX_SHARED_SHAPING_UNITS = 1_048_576\n\nimport type { TextDecorationRect } from '#core/canvas/text/decorations'\nimport type { TextLayout } from '#core/canvas/text/layout'\nimport { PARAGRAPH_INPUT_KEYS, shapingInputs } from '#core/canvas/text/paragraph/inputs'\n\ntype PreparationInput = SceneNode[(typeof PARAGRAPH_INPUT_KEYS)[number]]\n\nexport interface PreparedText {\n paragraph: TextLayout\n missingGlyphs?: ReturnType<typeof missingGlyphOccurrences>\n /** The underlines and strikethroughs drawn `y` below the text's top, found once per layout. */\n decorations?: { y: number; rects: TextDecorationRect[] }\n}\n\n/** What shaping a text showed: whether its faces cover it, and its size at each layout width. */\ninterface ShapingResult {\n covered: boolean\n sizes: Map<number, Size>\n}\n\n/**\n * A node's view of the shaping its text shows, valid while its `shapingInputs` stay the same. The\n * result is shared by every layer whose text shapes the same, such as an instance's copies.\n */\ninterface Shaping {\n inputs: PreparationInput[]\n key: string\n result: ShapingResult\n}\n\ninterface Entry extends PreparedText {\n nodeId: string\n inputs: PreparationInput[]\n units: number\n}\n\nexport class TextPreparationCache {\n private readonly entries: ResourceCache<string, Entry>\n private readonly nodeKeys = new Map<string, Set<string>>()\n // Coverage and measured sizes contain no native resources. Keep them independently of\n // paragraph LRU eviction: each node's view weakly owned by the node, the results it shares with\n // identical text bounded by their keys.\n private shaping = new WeakMap<SceneNode, Shaping>()\n private readonly results = new ResourceCache<string, ShapingResult>({\n maxEntries: MAX_SHARED_SHAPINGS,\n maxWeight: MAX_SHARED_SHAPING_UNITS,\n weight: (_result, key) => key.length\n })\n private readonly invalidatedShaping = new Set<string>()\n private generation = -1\n private provider: TypefaceFontProvider | null = null\n\n constructor(\n private readonly maxEntries = MAX_PREPARED_PARAGRAPHS,\n private readonly maxTextUnits = MAX_PREPARED_TEXT_UNITS\n ) {\n this.entries = new ResourceCache({\n maxEntries,\n maxWeight: maxTextUnits,\n weight: (entry) => entry.units,\n dispose: (entry, key) => {\n const keys = this.nodeKeys.get(entry.nodeId)\n keys?.delete(key)\n if (keys?.size === 0) this.nodeKeys.delete(entry.nodeId)\n entry.paragraph.delete()\n }\n })\n }\n\n /** Borrowed paragraphs must not be retained, deleted or relaid out by drawing callers. */\n use<T>(\n node: SceneNode,\n variant: string,\n generation: number,\n provider: TypefaceFontProvider,\n build: () => TextLayout,\n consume: (prepared: PreparedText) => T\n ): T {\n this.useScope(generation, provider)\n if (node.text.length > this.maxTextUnits || this.maxEntries <= 0) {\n const paragraph = build()\n try {\n return consume({ paragraph })\n } finally {\n paragraph.delete()\n }\n }\n const key = `${node.id}\\0${variant}`\n let entry = this.entries.get(key)\n if (\n entry &&\n !PARAGRAPH_INPUT_KEYS.every((prop, index) => entry?.inputs[index] === node[prop])\n ) {\n // Shaping compares its own inputs, so a change it doesn't see, such as a resize, keeps it.\n this.deleteNode(node.id, { keepShaping: true })\n entry = undefined\n }\n if (!entry) {\n entry = {\n nodeId: node.id,\n inputs: PARAGRAPH_INPUT_KEYS.map((prop) => node[prop]),\n paragraph: build(),\n units: node.text.length\n }\n this.entries.set(key, entry)\n const keys = this.nodeKeys.get(node.id) ?? new Set<string>()\n keys.add(key)\n this.nodeKeys.set(node.id, keys)\n }\n return consume(entry)\n }\n\n hasGlyphCoverage(node: SceneNode, generation: number, provider: TypefaceFontProvider): boolean {\n if (this.generation !== generation || this.provider !== provider) return false\n // A copy that has not shaped yet still finds what its source's identical text showed.\n return this.shapingFor(node).result.covered\n }\n\n /** Call only after observing complete coverage with this cache's current font scope. */\n recordGlyphCoverage(node: SceneNode): void {\n this.shapingFor(node).result.covered = true\n }\n\n /** The size of `node`'s text laid out at `layoutWidth`, measured once per shaping. */\n measure(\n node: SceneNode,\n layoutWidth: number,\n generation: number,\n provider: TypefaceFontProvider,\n compute: () => Size\n ): Size {\n this.useScope(generation, provider)\n const sizes = this.shapingFor(node).result.sizes\n const cached = sizes.get(layoutWidth)\n if (cached) return cached\n const size = compute()\n if (sizes.size >= MAX_MEASURED_WIDTHS) sizes.clear()\n sizes.set(layoutWidth, size)\n return size\n }\n\n /**\n * Drops `id`'s paragraphs and, unless `keepShaping`, its coverage and measured sizes. Keep\n * them only for changes `shapingInputs` compares, such as layout resizing the box.\n */\n deleteNode(id: string, { keepShaping = false } = {}): void {\n // Invalidation arrives by ID; don't add strong node ownership just to find\n // weak observations. Bound pending IDs and conservatively reset on overflow.\n if (!keepShaping) this.invalidatedShaping.add(id)\n if (this.invalidatedShaping.size > this.maxEntries) {\n this.shaping = new WeakMap()\n this.invalidatedShaping.clear()\n this.results.clear()\n }\n const keys = this.nodeKeys.get(id)\n if (keys) for (const key of keys) this.entries.delete(key)\n }\n\n private useScope(generation: number, provider: TypefaceFontProvider): void {\n if (this.generation === generation && this.provider === provider) return\n this.clear()\n this.generation = generation\n this.provider = provider\n }\n\n private currentShaping(node: SceneNode): Shaping | null {\n if (this.invalidatedShaping.delete(node.id)) {\n // An explicit invalidation covers what the inputs cannot show, so the shared result goes too.\n const invalidated = this.shaping.get(node)\n if (invalidated) this.results.delete(invalidated.key)\n this.shaping.delete(node)\n return null\n }\n const shaping = this.shaping.get(node)\n if (!shaping) return null\n const current = shapingInputs(node)\n if (\n current.length === shaping.inputs.length &&\n current.every((input, index) => input === shaping.inputs[index])\n )\n return shaping\n this.shaping.delete(node)\n return null\n }\n\n private shapingFor(node: SceneNode): Shaping {\n const existing = this.currentShaping(node)\n if (existing) return existing\n const inputs = shapingInputs(node)\n const key = JSON.stringify(inputs)\n let result = this.results.get(key)\n if (!result) {\n result = { covered: false, sizes: new Map() }\n this.results.set(key, result)\n }\n const created: Shaping = { inputs, key, result }\n this.shaping.set(node, created)\n return created\n }\n\n clear(): void {\n this.releaseLayers()\n this.results.clear()\n }\n\n /**\n * Forget every layer, keeping what identical text shaped to, such as its sizes. For a renderer\n * that draws a new graph each time, whose layer IDs can name different text from one to the next.\n */\n releaseLayers(): void {\n this.nodeKeys.clear()\n this.shaping = new WeakMap()\n this.invalidatedShaping.clear()\n this.entries.clear()\n }\n}\n"],"mappings":";;;AAUA,MAAM,0BAA0B;AAChC,MAAM,0BAA0B;AAEhC,MAAM,sBAAsB;AAE5B,MAAM,sBAAsB;AAC5B,MAAM,2BAA2B;AAqCjC,IAAa,uBAAb,MAAkC;CAiBb;CACA;CAjBnB;CACA,2BAA4B,IAAI,IAAyB;CAIzD,0BAAkB,IAAI,QAA4B;CAClD,UAA2B,IAAI,cAAqC;EAClE,YAAY;EACZ,WAAW;EACX,SAAS,SAAS,QAAQ,IAAI;CAChC,CAAC;CACD,qCAAsC,IAAI,IAAY;CACtD,aAAqB;CACrB,WAAgD;CAEhD,YACE,aAA8B,yBAC9B,eAAgC,yBAChC;EAFiB,KAAA,aAAA;EACA,KAAA,eAAA;EAEjB,KAAK,UAAU,IAAI,cAAc;GAC/B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ClC,QAAQ,OAAO,OAAO,UAAU,UAAU,QAAQ,OAAO,MAAM,GAE/D,OAAO;EACT,KAAK,QAAQ,OAAO,IAAI;EACxB,OAAO;CACT;CAEA,WAAmB,MAA0B;EAC3C,MAAM,WAAW,KAAK,eAAe,IAAI;EACzC,IAAI,UAAU,OAAO;EACrB,MAAM,SAAS,cAAc,IAAI;EACjC,MAAM,MAAM,KAAK,UAAU,MAAM;EACjC,IAAI,SAAS,KAAK,QAAQ,IAAI,GAAG;EACjC,IAAI,CAAC,QAAQ;GACX,SAAS;IAAE,SAAS;IAAO,uBAAO,IAAI,IAAI;GAAE;GAC5C,KAAK,QAAQ,IAAI,KAAK,MAAM;EAC9B;EACA,MAAM,UAAmB;GAAE;GAAQ;GAAK;EAAO;EAC/C,KAAK,QAAQ,IAAI,MAAM,OAAO;EAC9B,OAAO;CACT;CAEA,QAAc;EACZ,KAAK,cAAc;EACnB,KAAK,QAAQ,MAAM;CACrB;;;;;CAMA,gBAAsB;EACpB,KAAK,SAAS,MAAM;EACpB,KAAK,0BAAU,IAAI,QAAQ;EAC3B,KAAK,mBAAmB,MAAM;EAC9B,KAAK,QAAQ,MAAM;CACrB;AACF"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -222,24 +222,10 @@ declare const ISSUE_INFO_COLOR: {
|
|
|
222
222
|
b: number;
|
|
223
223
|
a: number;
|
|
224
224
|
};
|
|
225
|
-
declare const ISSUE_MARKER_HEIGHT = 16;
|
|
226
|
-
declare const ISSUE_MARKER_PADDING_X = 5;
|
|
227
|
-
/** Gap between a layer's corner and its marker; clears the 8px selection handle. */
|
|
228
|
-
declare const ISSUE_MARKER_OFFSET = 4;
|
|
229
|
-
/** Markers closer than this merge into one. */
|
|
230
|
-
declare const ISSUE_MARKER_GAP = 2;
|
|
231
|
-
declare const ISSUE_MARKER_VIEWPORT_INSET = 4;
|
|
232
|
-
/** Layers smaller than this on screen pass their marker to an ancestor. */
|
|
233
|
-
declare const ISSUE_MARKER_MIN_TARGET = 24;
|
|
234
|
-
declare const ISSUE_MARKER_MAX_COUNT = 99;
|
|
235
|
-
/** Edge pins closer than this along the viewport edge merge into one. */
|
|
236
|
-
declare const ISSUE_EDGE_MERGE_GAP = 24;
|
|
237
|
-
/** Length of the chevron an edge pin points with, beyond its ring. */
|
|
238
|
-
declare const ISSUE_EDGE_ARROW = 5;
|
|
239
|
-
declare const ISSUE_MARKER_RING_WIDTH = 1.5;
|
|
240
225
|
declare const ISSUE_HIGHLIGHT_STROKE_WIDTH = 1.5;
|
|
241
226
|
declare const ISSUE_HIGHLIGHT_FILL_ALPHA = 0.08;
|
|
242
|
-
|
|
227
|
+
/** The violet AI agents show in everywhere, the app's `--color-agent`. */
|
|
228
|
+
declare const AI_AGENT_COLOR: {
|
|
243
229
|
r: number;
|
|
244
230
|
g: number;
|
|
245
231
|
b: number;
|
|
@@ -249,8 +235,17 @@ declare const AI_DONE_COLOR: {
|
|
|
249
235
|
g: number;
|
|
250
236
|
b: number;
|
|
251
237
|
};
|
|
252
|
-
declare const AI_PULSE_PERIOD_MS = 1500;
|
|
253
238
|
declare const AI_DONE_DURATION_MS = 800;
|
|
239
|
+
/** How long a layer an agent adds takes to trace in, once its turn comes. */
|
|
240
|
+
declare const AI_ENTER_DURATION_MS = 480;
|
|
241
|
+
/** The pause between the layers of one edit, so they appear one after another. */
|
|
242
|
+
declare const AI_ENTER_STAGGER_MS = 45;
|
|
243
|
+
/** The last layer of an edit starts within this, however many layers the edit adds. */
|
|
244
|
+
declare const AI_ENTER_MAX_DELAY_MS = 900;
|
|
245
|
+
/** One sweep of the light over an area an agent is working in. */
|
|
246
|
+
declare const AI_SHIMMER_PERIOD_MS = 1600;
|
|
247
|
+
/** Width of the sweeping light, in screen pixels. */
|
|
248
|
+
declare const AI_SHIMMER_BAND = 120;
|
|
254
249
|
/** Opacity of the selection color behind selected text while editing. */
|
|
255
250
|
declare const TEXT_SELECTION_ALPHA = 0.3;
|
|
256
251
|
/** The caret's colour where the text's fill gives it none, as Figma's. */
|
|
@@ -313,5 +308,5 @@ declare const DEFAULT_TEXT_HEIGHT = 24;
|
|
|
313
308
|
/** Space Figma leaves between a duplicated top-level frame and the layers to its left. */
|
|
314
309
|
declare const DUPLICATE_FRAME_GAP = 40;
|
|
315
310
|
//#endregion
|
|
316
|
-
export { ACPAgentDef, ACPAgentID, ACP_AGENTS, AIProviderDef, AIProviderID,
|
|
311
|
+
export { ACPAgentDef, ACPAgentID, ACP_AGENTS, AIProviderDef, AIProviderID, AI_AGENT_COLOR, AI_DONE_COLOR, AI_DONE_DURATION_MS, AI_ENTER_DURATION_MS, AI_ENTER_MAX_DELAY_MS, AI_ENTER_STAGGER_MS, AI_PROVIDERS, AI_SHIMMER_BAND, AI_SHIMMER_PERIOD_MS, AUTOMATION_HTTP_PORT, AUTO_LAYOUT_HOVER_BLUE, AUTO_LAYOUT_HOVER_BLUE_FILL, AUTO_LAYOUT_HOVER_GAP_PILL, AUTO_LAYOUT_HOVER_GAP_REGION_TOLERANCE, AUTO_LAYOUT_HOVER_MAGENTA, AUTO_LAYOUT_HOVER_MAGENTA_FILL, AUTO_LAYOUT_HOVER_PADDING_PILL, AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE, AUTO_LAYOUT_HOVER_STRIPE_GAP, AUTO_LAYOUT_HOVER_STRIPE_WIDTH, AUTO_LAYOUT_HOVER_STROKE_WIDTH, AUTO_LAYOUT_HOVER_TICK_HIT_TOLERANCE, AUTO_LAYOUT_HOVER_TICK_LENGTH, AUTO_LAYOUT_HOVER_VALUE_OFFSET, AUTO_LAYOUT_HOVER_VALUE_PILL_HEIGHT, AUTO_LAYOUT_HOVER_VALUE_PILL_PADDING_X, AUTO_LAYOUT_HOVER_VALUE_PILL_RADIUS, AUTO_LAYOUT_PADDING_EDITOR_OFFSET_X, AUTO_LAYOUT_PADDING_EDITOR_OFFSET_Y, BLACK, BOARD_GRID, BOARD_PAGE_BACKGROUND, CANVAS_BG_COLOR, CJK_FALLBACK_FAMILIES_LINUX, CJK_FALLBACK_FAMILIES_MACOS, CJK_FALLBACK_FAMILIES_WINDOWS, CJK_GOOGLE_FONTS, CODE_FOCUS_FILL_ALPHA, COMPONENT_COLOR, COMPONENT_LABEL_FONT_SIZE, COMPONENT_LABEL_GAP, COMPONENT_LABEL_ICON_GAP, COMPONENT_LABEL_ICON_SIZE, COMPONENT_SET_BORDER_WIDTH, COMPONENT_SET_DASH, COMPONENT_SET_DASH_GAP, COMPONENT_SET_OUTLINE_RADIUS, DEFAULT_AI_MODEL, DEFAULT_AI_PROVIDER, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_FRAME_FILL, DEFAULT_SELECTION_THEME, DEFAULT_SHADOW_COLOR, DEFAULT_SHAPE_FILL, DEFAULT_STROKE_MITER_LIMIT, DEFAULT_TEXT_HEIGHT, DEFAULT_TEXT_WIDTH, DROP_HIGHLIGHT_ALPHA, DROP_HIGHLIGHT_STROKE, DUPLICATE_FRAME_GAP, FLASH_ATTACK_MS, FLASH_HOLD_MS, FLASH_OVERSHOOT, FLASH_PADDING, FLASH_RADIUS, FLASH_RELEASE_MS, FLASH_STROKE_WIDTH, GOOGLE_FONTS_API_KEY, HANDLE_HALF_SIZE, HANDLE_HIT_RADIUS, HARNESS_PROVIDER_ID, ISSUE_ERROR_COLOR, ISSUE_HIGHLIGHT_FILL_ALPHA, ISSUE_HIGHLIGHT_STROKE_WIDTH, ISSUE_INFO_COLOR, ISSUE_WARNING_COLOR, IS_BROWSER, IS_TAURI, InterfaceTheme, LABEL_FONT_SIZE, LABEL_OFFSET_Y, LAYER_HIT_PAD, LAYOUT_INDICATOR_STROKE, LAYOUT_OUTLINE_DASH, LAYOUT_OUTLINE_GAP, MARQUEE_FILL_ALPHA, MCP_AGENT_HEADER, MCP_CHAT_HEADER, MEASUREMENT_COLOR, MEASUREMENT_PILL_HEIGHT, MEASUREMENT_PILL_PADDING_X, MEASUREMENT_PILL_RADIUS, MEASUREMENT_TEXT_BASELINE, ModelOption, PAGE_DEFAULT_BACKGROUNDS, PAIRDRAW_MCP_SERVER, PARENT_OUTLINE_ALPHA, PARENT_OUTLINE_DASH, PENCIL_STROKE_WEIGHT, PENCIL_TOLERANCE, PEN_ANCHOR_RADIUS, PEN_CLOSE_RADIUS_BOOST, PEN_CLOSE_THRESHOLD, PEN_HANDLE_RADIUS, PEN_PATH_STROKE_WIDTH, PEN_VERTEX_RADIUS, REASONING_EFFORTS, ROTATION_HANDLE_DISTANCE, ROTATION_SNAP_DEGREES, RULER_BADGE_EXCLUSION, RULER_BADGE_HEIGHT, RULER_BADGE_PADDING, RULER_BADGE_RADIUS, RULER_BG_COLOR, RULER_HIGHLIGHT_ALPHA, RULER_MAJOR_TICK, RULER_MAJOR_TOLERANCE, RULER_MINOR_TICK, RULER_SIZE, RULER_TARGET_PIXEL_SPACING, RULER_TEXT_BASELINE, RULER_TEXT_COLOR, RULER_TICK_COLOR, ReasoningEffort, SECTION_CORNER_RADIUS, SECTION_DEFAULT_FILLS, SECTION_DEFAULT_STROKE, SECTION_HOVER_STROKE_WIDTH, SECTION_TITLE_FONT_FAMILY, SECTION_TITLE_FONT_SIZE, SECTION_TITLE_FONT_URL, SECTION_TITLE_GAP, SECTION_TITLE_HEIGHT, SECTION_TITLE_PADDING_X, SECTION_TITLE_RADIUS, SELECTION_COLOR, SELECTION_DASH_ALPHA, SIZE_FONT_SIZE, SIZE_PILL_HEIGHT, SIZE_PILL_PADDING_X, SIZE_PILL_PADDING_Y, SIZE_PILL_RADIUS, SIZE_PILL_TEXT_OFFSET_Y, SLOT_COLOR, SLOT_EMPTY_FILL_ALPHA, SNAP_COLOR, SNAP_THRESHOLD_SCREEN_PX, SPACING_GUIDE_CAP, TEXT_CARET_COLOR, TEXT_CARET_WIDTH, TEXT_SELECTION_ALPHA, TRANSPARENT, VALUE_FONT_SIZE, VERTEX_SNAP_COLOR, VERTEX_SNAP_GUIDE_ALPHA, VERTEX_SNAP_MARK_RADIUS, ZOOM_DIVISOR, ZOOM_SCALE_MAX, ZOOM_SCALE_MIN };
|
|
317
312
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","names":[],"sources":["../src/constants.ts"],"mappings":";;;;;cAQa;cACA;cAEA,OAAO;cACP,aAAa;cACb,sBAAsB;cACtB;;;;;;;cAEA,yBAAyB,SAAS;cAIlC;;;;;;;cAEA;;;;;;cACA;cACA;;;;;;;cAEA;;;;;;cACA;cACA;;cAEA;cACA;;;;;;cACA;cACA;cACA;cACA;cACA;;;;;;cACA;;cAEA;cAEA;cACA;;;;;;cACA;;;;;;cACA;;;;;;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cAEA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;;cAEA;cACA;cACA;cAEA;cAEA;cACA;cACA;cACA;cACA;cACA;cAEA;cACA;;cAEA;cACA;cACA;cAEA;cACA;cACA;cACA;cACA;;cAEA;cACA;cACA;cAEA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;;;;;;cACA;;;;;;cACA;;;;;;cACA;;;;;;cAEA;;;;;;cACA;;;;;;cAEA;cACA;cACA;cACA;;;;;;cAMA;cACA;cACA;cACA;cAEA;cACA;cACA;;cAEA;cACA;cACA;cACA;cACA;cAEA;cACA;cAEA;cACA;cACA;cACA;cACA;cACA;cACA;cAEA;;;;;;cACA;;;;;;cACA;;;;;;cACA;cACA;;cAEA;;cAEA
|
|
1
|
+
{"version":3,"file":"constants.d.ts","names":[],"sources":["../src/constants.ts"],"mappings":";;;;;cAQa;cACA;cAEA,OAAO;cACP,aAAa;cACb,sBAAsB;cACtB;;;;;;;cAEA,yBAAyB,SAAS;cAIlC;;;;;;;cAEA;;;;;;cACA;cACA;;;;;;;cAEA;;;;;;cACA;cACA;;cAEA;cACA;;;;;;cACA;cACA;cACA;cACA;cACA;;;;;;cACA;;cAEA;cAEA;cACA;;;;;;cACA;;;;;;cACA;;;;;;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cAEA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;;cAEA;cACA;cACA;cAEA;cAEA;cACA;cACA;cACA;cACA;cACA;cAEA;cACA;;cAEA;cACA;cACA;cAEA;cACA;cACA;cACA;cACA;;cAEA;cACA;cACA;cAEA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;;;;;;cACA;;;;;;cACA;;;;;;cACA;;;;;;cAEA;;;;;;cACA;;;;;;cAEA;cACA;cACA;cACA;;;;;;cAMA;cACA;cACA;cACA;cAEA;cACA;cACA;;cAEA;cACA;cACA;cACA;cACA;cAEA;cACA;cAEA;cACA;cACA;cACA;cACA;cACA;cACA;cAEA;;;;;;cACA;;;;;;cACA;;;;;;cACA;cACA;;cAGA;;;;;cACA;;;;;cACA;;cAEA;;cAEA;;cAEA;;cAEA;;cAEA;;cAGA;;cAEA,kBAAgB;cAChB;cAEA;;;;;cAKA;;cAGA;;;;;cAMA;cAEA;cAEA;cASA;cAUA;cASA;;cAGA,oBAAoB;cAOpB,oBAAoB;;KAQrB;;cAGC,0BAA0B,OAAO,gBAAgB;;cAMjD;;;;;;;cAQA,uBAAuB,OAAO,gBAAgB;cAU9C,wBAAwB;cASxB;cAEA;cACA;cACA;cAEA;;;;;cAKA;;cAEA;cACA;cACA;;cAEA;cACA;cACA;cACA;;cAEA"}
|