@fieldnotes/core 0.52.0 → 0.52.2
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 +705 -704
- package/dist/index.cjs +181 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +181 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -572,6 +572,7 @@ declare class Viewport {
|
|
|
572
572
|
readonly history: HistoryStack;
|
|
573
573
|
readonly domLayer: HTMLDivElement;
|
|
574
574
|
private readonly canvasEl;
|
|
575
|
+
private readonly paintStack;
|
|
575
576
|
private readonly wrapper;
|
|
576
577
|
private readonly unsubCamera;
|
|
577
578
|
private readonly unsubToolChange;
|
|
@@ -1157,6 +1158,6 @@ declare class LaserTool implements Tool {
|
|
|
1157
1158
|
private notifyOptionsChange;
|
|
1158
1159
|
}
|
|
1159
1160
|
|
|
1160
|
-
declare const VERSION = "0.52.
|
|
1161
|
+
declare const VERSION = "0.52.2";
|
|
1161
1162
|
|
|
1162
1163
|
export { type ActiveFormats, type AlignEdge, type ArrowElement, type ArrowStrokeStyle, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, type BackgroundOptions, type BackgroundPattern, type Binding, type Bounds, Camera, type CameraChangeInfo, type CameraOptions, type CanvasElement, type CanvasState, type Command, DEFAULT_NOTE_FONT_SIZE, type DistributeAxis, type ElementChangeMeta, ElementStore, type ElementStyle, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, type ExportAssetError, type ExportAssetErrorReason, type ExportImageOptions, type ExportResourceOptions, type ExportSvgOptions, type FontSizePreset, type GridElement, type GridInfo, HandTool, type HexOrientation, HistoryStack, type HistoryStackOptions, type HtmlElement, type HtmlExportError, type HtmlExportErrorReason, type HtmlExportOptions, type HtmlExportRenderer, type ImageElement, ImageTool, type ImageToolOptions, IndexedDBAdapter, type IndexedDBAdapterOptions, LaserTool, type LaserToolOptions, type Layer, LayerManager, LocalStorageAdapter, MeasureTool, type MeasureToolOptions, type Measurement, MemoryAdapter, type NoteElement, NoteTool, type NoteToolOptions, PencilTool, type PencilToolOptions, type Point, type PointerState, type RenderStatsSnapshot, type RotateDirection, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type ShortcutBindings, type ShortcutOptions, type ShortcutsApi, type Size, type StorageAdapter, type StrokeElement, type StrokePoint, type TemplateElement, type TemplateRenderStyle, type TemplateShape, TemplateTool, type TemplateToolOptions, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, VERSION, Viewport, type ViewportOptions, boundsIntersect, createArrow, createGrid, createHtmlElement, createImage, createNote, createShape, createStroke, createTemplate, createText, drawHexPath, exportImage, exportSvg, getActiveFormats, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getElementBounds, getElementStyle, getElementsBoundingBox, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInRectangle, getHexCellsInSquare, getHexDistance, isNearBezier, setFontSize, smartSnap, snapPoint, snapToHexCenter, styleToPatch, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline };
|
package/dist/index.d.ts
CHANGED
|
@@ -572,6 +572,7 @@ declare class Viewport {
|
|
|
572
572
|
readonly history: HistoryStack;
|
|
573
573
|
readonly domLayer: HTMLDivElement;
|
|
574
574
|
private readonly canvasEl;
|
|
575
|
+
private readonly paintStack;
|
|
575
576
|
private readonly wrapper;
|
|
576
577
|
private readonly unsubCamera;
|
|
577
578
|
private readonly unsubToolChange;
|
|
@@ -1157,6 +1158,6 @@ declare class LaserTool implements Tool {
|
|
|
1157
1158
|
private notifyOptionsChange;
|
|
1158
1159
|
}
|
|
1159
1160
|
|
|
1160
|
-
declare const VERSION = "0.52.
|
|
1161
|
+
declare const VERSION = "0.52.2";
|
|
1161
1162
|
|
|
1162
1163
|
export { type ActiveFormats, type AlignEdge, type ArrowElement, type ArrowStrokeStyle, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, type BackgroundOptions, type BackgroundPattern, type Binding, type Bounds, Camera, type CameraChangeInfo, type CameraOptions, type CanvasElement, type CanvasState, type Command, DEFAULT_NOTE_FONT_SIZE, type DistributeAxis, type ElementChangeMeta, ElementStore, type ElementStyle, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, type ExportAssetError, type ExportAssetErrorReason, type ExportImageOptions, type ExportResourceOptions, type ExportSvgOptions, type FontSizePreset, type GridElement, type GridInfo, HandTool, type HexOrientation, HistoryStack, type HistoryStackOptions, type HtmlElement, type HtmlExportError, type HtmlExportErrorReason, type HtmlExportOptions, type HtmlExportRenderer, type ImageElement, ImageTool, type ImageToolOptions, IndexedDBAdapter, type IndexedDBAdapterOptions, LaserTool, type LaserToolOptions, type Layer, LayerManager, LocalStorageAdapter, MeasureTool, type MeasureToolOptions, type Measurement, MemoryAdapter, type NoteElement, NoteTool, type NoteToolOptions, PencilTool, type PencilToolOptions, type Point, type PointerState, type RenderStatsSnapshot, type RotateDirection, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type ShortcutBindings, type ShortcutOptions, type ShortcutsApi, type Size, type StorageAdapter, type StrokeElement, type StrokePoint, type TemplateElement, type TemplateRenderStyle, type TemplateShape, TemplateTool, type TemplateToolOptions, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, VERSION, Viewport, type ViewportOptions, boundsIntersect, createArrow, createGrid, createHtmlElement, createImage, createNote, createShape, createStroke, createTemplate, createText, drawHexPath, exportImage, exportSvg, getActiveFormats, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getElementBounds, getElementStyle, getElementsBoundingBox, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInRectangle, getHexCellsInSquare, getHexDistance, isNearBezier, setFontSize, smartSnap, snapPoint, snapToHexCenter, styleToPatch, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline };
|
package/dist/index.js
CHANGED
|
@@ -896,6 +896,12 @@ function getElementBounds(element) {
|
|
|
896
896
|
}
|
|
897
897
|
return null;
|
|
898
898
|
}
|
|
899
|
+
function getElementVisualBounds(element) {
|
|
900
|
+
const bounds = getElementBounds(element);
|
|
901
|
+
if (!bounds) return null;
|
|
902
|
+
const rotation = element.rotation ?? 0;
|
|
903
|
+
return rotation === 0 ? bounds : rotatedAABB(bounds, rotation);
|
|
904
|
+
}
|
|
899
905
|
function getArrowBoundsAnalytical(from, to, bend) {
|
|
900
906
|
if (bend === 0) {
|
|
901
907
|
const minX2 = Math.min(from.x, to.x);
|
|
@@ -2667,10 +2673,7 @@ var ElementStore = class {
|
|
|
2667
2673
|
// Spatial index stores the rotation-expanded AABB so rotated elements remain
|
|
2668
2674
|
// broad-phase hit-test/marquee candidates; precise tests run against local bounds.
|
|
2669
2675
|
indexBounds(element) {
|
|
2670
|
-
|
|
2671
|
-
if (!bounds) return null;
|
|
2672
|
-
const angle = element.rotation ?? 0;
|
|
2673
|
-
return angle === 0 ? bounds : rotatedAABB(bounds, angle);
|
|
2676
|
+
return getElementVisualBounds(element);
|
|
2674
2677
|
}
|
|
2675
2678
|
add(element, meta) {
|
|
2676
2679
|
element = sanitizeRichText(element);
|
|
@@ -4834,6 +4837,57 @@ function createDomLayer() {
|
|
|
4834
4837
|
});
|
|
4835
4838
|
return el;
|
|
4836
4839
|
}
|
|
4840
|
+
function createPaintStack() {
|
|
4841
|
+
const el = createDomLayer();
|
|
4842
|
+
el.dataset["fieldnotesPaintStack"] = "";
|
|
4843
|
+
el.style.transformOrigin = "";
|
|
4844
|
+
return el;
|
|
4845
|
+
}
|
|
4846
|
+
|
|
4847
|
+
// src/canvas/hybrid-render-surface.ts
|
|
4848
|
+
var HybridRenderSurface = class {
|
|
4849
|
+
constructor(root) {
|
|
4850
|
+
this.root = root;
|
|
4851
|
+
}
|
|
4852
|
+
canvases = /* @__PURE__ */ new Map();
|
|
4853
|
+
beginFrame(activeOrders, width, height) {
|
|
4854
|
+
for (const [order, canvas] of this.canvases) {
|
|
4855
|
+
if (!activeOrders.has(order)) {
|
|
4856
|
+
canvas.remove();
|
|
4857
|
+
this.canvases.delete(order);
|
|
4858
|
+
}
|
|
4859
|
+
}
|
|
4860
|
+
for (const order of activeOrders) {
|
|
4861
|
+
const canvas = this.getCanvas(order);
|
|
4862
|
+
if (canvas.width !== width) canvas.width = width;
|
|
4863
|
+
if (canvas.height !== height) canvas.height = height;
|
|
4864
|
+
canvas.style.zIndex = String(order);
|
|
4865
|
+
}
|
|
4866
|
+
}
|
|
4867
|
+
getContext(order) {
|
|
4868
|
+
return this.getCanvas(order).getContext("2d");
|
|
4869
|
+
}
|
|
4870
|
+
clear() {
|
|
4871
|
+
for (const canvas of this.canvases.values()) canvas.remove();
|
|
4872
|
+
this.canvases.clear();
|
|
4873
|
+
}
|
|
4874
|
+
getCanvas(order) {
|
|
4875
|
+
let canvas = this.canvases.get(order);
|
|
4876
|
+
if (canvas) return canvas;
|
|
4877
|
+
canvas = document.createElement("canvas");
|
|
4878
|
+
canvas.dataset["paintOrder"] = String(order);
|
|
4879
|
+
Object.assign(canvas.style, {
|
|
4880
|
+
position: "absolute",
|
|
4881
|
+
inset: "0",
|
|
4882
|
+
width: "100%",
|
|
4883
|
+
height: "100%",
|
|
4884
|
+
pointerEvents: "none"
|
|
4885
|
+
});
|
|
4886
|
+
this.root.appendChild(canvas);
|
|
4887
|
+
this.canvases.set(order, canvas);
|
|
4888
|
+
return canvas;
|
|
4889
|
+
}
|
|
4890
|
+
};
|
|
4837
4891
|
|
|
4838
4892
|
// src/elements/arrow-label-editor.ts
|
|
4839
4893
|
var ArrowLabelEditor = class {
|
|
@@ -6452,6 +6506,7 @@ var DoubleTapDetector = class {
|
|
|
6452
6506
|
// src/canvas/dom-node-manager.ts
|
|
6453
6507
|
var DomNodeManager = class {
|
|
6454
6508
|
domNodes = /* @__PURE__ */ new Map();
|
|
6509
|
+
strata = /* @__PURE__ */ new Map();
|
|
6455
6510
|
htmlContent = /* @__PURE__ */ new Map();
|
|
6456
6511
|
domLayer;
|
|
6457
6512
|
onEditRequest;
|
|
@@ -6460,6 +6515,7 @@ var DomNodeManager = class {
|
|
|
6460
6515
|
lastSyncedVersion = /* @__PURE__ */ new Map();
|
|
6461
6516
|
lastSyncedZIndex = /* @__PURE__ */ new Map();
|
|
6462
6517
|
lastSyncedOpacity = /* @__PURE__ */ new Map();
|
|
6518
|
+
cameraTransform = "";
|
|
6463
6519
|
constructor(deps) {
|
|
6464
6520
|
this.domLayer = deps.domLayer;
|
|
6465
6521
|
this.onEditRequest = deps.onEditRequest;
|
|
@@ -6469,6 +6525,11 @@ var DomNodeManager = class {
|
|
|
6469
6525
|
getNode(id) {
|
|
6470
6526
|
return this.domNodes.get(id);
|
|
6471
6527
|
}
|
|
6528
|
+
setCameraTransform(transform) {
|
|
6529
|
+
if (transform === this.cameraTransform) return;
|
|
6530
|
+
this.cameraTransform = transform;
|
|
6531
|
+
for (const stratum of this.strata.values()) stratum.style.transform = transform;
|
|
6532
|
+
}
|
|
6472
6533
|
storeHtmlContent(elementId, dom) {
|
|
6473
6534
|
this.htmlContent.set(elementId, dom);
|
|
6474
6535
|
}
|
|
@@ -6496,7 +6557,7 @@ var DomNodeManager = class {
|
|
|
6496
6557
|
position: "absolute",
|
|
6497
6558
|
pointerEvents: "auto"
|
|
6498
6559
|
});
|
|
6499
|
-
this.
|
|
6560
|
+
this.getStratum(zIndex).appendChild(node);
|
|
6500
6561
|
this.domNodes.set(element.id, node);
|
|
6501
6562
|
} else if (this.getVersion) {
|
|
6502
6563
|
const currentVersion = this.getVersion(element.id);
|
|
@@ -6507,6 +6568,15 @@ var DomNodeManager = class {
|
|
|
6507
6568
|
return;
|
|
6508
6569
|
}
|
|
6509
6570
|
}
|
|
6571
|
+
if (node.parentElement !== this.getStratum(zIndex)) {
|
|
6572
|
+
const previousStratum = node.parentElement;
|
|
6573
|
+
this.getStratum(zIndex).appendChild(node);
|
|
6574
|
+
if (previousStratum?.childElementCount === 0) {
|
|
6575
|
+
const previousOrder = Number(previousStratum.dataset["paintOrder"]);
|
|
6576
|
+
previousStratum.remove();
|
|
6577
|
+
this.strata.delete(previousOrder);
|
|
6578
|
+
}
|
|
6579
|
+
}
|
|
6510
6580
|
if (this.getVersion) {
|
|
6511
6581
|
this.lastSyncedVersion.set(element.id, this.getVersion(element.id));
|
|
6512
6582
|
this.lastSyncedZIndex.set(element.id, zIndex);
|
|
@@ -6528,7 +6598,10 @@ var DomNodeManager = class {
|
|
|
6528
6598
|
}
|
|
6529
6599
|
hideDomNode(id) {
|
|
6530
6600
|
const node = this.domNodes.get(id);
|
|
6531
|
-
if (node)
|
|
6601
|
+
if (node) {
|
|
6602
|
+
node.style.display = "none";
|
|
6603
|
+
this.lastSyncedVersion.delete(id);
|
|
6604
|
+
}
|
|
6532
6605
|
}
|
|
6533
6606
|
removeDomNode(id) {
|
|
6534
6607
|
this.htmlContent.delete(id);
|
|
@@ -6537,8 +6610,14 @@ var DomNodeManager = class {
|
|
|
6537
6610
|
this.lastSyncedOpacity.delete(id);
|
|
6538
6611
|
const node = this.domNodes.get(id);
|
|
6539
6612
|
if (node) {
|
|
6613
|
+
const stratum = node.parentElement;
|
|
6540
6614
|
node.remove();
|
|
6541
6615
|
this.domNodes.delete(id);
|
|
6616
|
+
if (stratum?.childElementCount === 0) {
|
|
6617
|
+
const order = Number(stratum.dataset["paintOrder"]);
|
|
6618
|
+
stratum.remove();
|
|
6619
|
+
this.strata.delete(order);
|
|
6620
|
+
}
|
|
6542
6621
|
}
|
|
6543
6622
|
}
|
|
6544
6623
|
clearDomNodes() {
|
|
@@ -6548,6 +6627,27 @@ var DomNodeManager = class {
|
|
|
6548
6627
|
this.lastSyncedVersion.clear();
|
|
6549
6628
|
this.lastSyncedZIndex.clear();
|
|
6550
6629
|
this.lastSyncedOpacity.clear();
|
|
6630
|
+
for (const stratum of this.strata.values()) stratum.remove();
|
|
6631
|
+
this.strata.clear();
|
|
6632
|
+
}
|
|
6633
|
+
getStratum(order) {
|
|
6634
|
+
let stratum = this.strata.get(order);
|
|
6635
|
+
if (stratum) return stratum;
|
|
6636
|
+
stratum = document.createElement("div");
|
|
6637
|
+
stratum.dataset["paintOrder"] = String(order);
|
|
6638
|
+
Object.assign(stratum.style, {
|
|
6639
|
+
position: "absolute",
|
|
6640
|
+
inset: "0",
|
|
6641
|
+
width: "100%",
|
|
6642
|
+
height: "100%",
|
|
6643
|
+
pointerEvents: "none",
|
|
6644
|
+
transformOrigin: "0 0",
|
|
6645
|
+
transform: this.cameraTransform,
|
|
6646
|
+
zIndex: String(order)
|
|
6647
|
+
});
|
|
6648
|
+
this.domLayer.appendChild(stratum);
|
|
6649
|
+
this.strata.set(order, stratum);
|
|
6650
|
+
return stratum;
|
|
6551
6651
|
}
|
|
6552
6652
|
reattachHtmlContent(store) {
|
|
6553
6653
|
for (const el of store.getElementsByType("html")) {
|
|
@@ -6729,6 +6829,7 @@ var RenderLoop = class {
|
|
|
6729
6829
|
domNodeManager;
|
|
6730
6830
|
layerCache;
|
|
6731
6831
|
marginViewport;
|
|
6832
|
+
hybridSurface;
|
|
6732
6833
|
activeDrawingLayerId = null;
|
|
6733
6834
|
gridCacheDirty = true;
|
|
6734
6835
|
// set on recenter/viewport-change; consumed by the grid block
|
|
@@ -6748,6 +6849,7 @@ var RenderLoop = class {
|
|
|
6748
6849
|
this.domNodeManager = deps.domNodeManager;
|
|
6749
6850
|
this.layerCache = deps.layerCache;
|
|
6750
6851
|
this.marginViewport = deps.marginViewport;
|
|
6852
|
+
this.hybridSurface = deps.hybridSurface;
|
|
6751
6853
|
}
|
|
6752
6854
|
requestRender() {
|
|
6753
6855
|
this.needsRender = true;
|
|
@@ -6868,9 +6970,19 @@ var RenderLoop = class {
|
|
|
6868
6970
|
h: cullBounds.h + cullPad * 2
|
|
6869
6971
|
};
|
|
6870
6972
|
const allElements = this.store.getAll();
|
|
6973
|
+
const visibleElements = allElements.filter(
|
|
6974
|
+
(element) => this.layerManager.isLayerVisible(element.layerId)
|
|
6975
|
+
);
|
|
6976
|
+
const firstDomIndex = visibleElements.findIndex(
|
|
6977
|
+
(element) => this.renderer.isDomElement(element)
|
|
6978
|
+
);
|
|
6979
|
+
const hybridActive = firstDomIndex >= 0 && visibleElements.slice(firstDomIndex + 1).some((element) => !this.renderer.isDomElement(element));
|
|
6980
|
+
const hybridCanvasRuns = /* @__PURE__ */ new Map();
|
|
6981
|
+
const hybridOrders = /* @__PURE__ */ new Set();
|
|
6982
|
+
let activeHybridOrder = null;
|
|
6871
6983
|
this.layerGroups.clear();
|
|
6872
6984
|
const gridElements = [];
|
|
6873
|
-
let
|
|
6985
|
+
let paintOrder = 0;
|
|
6874
6986
|
for (const element of allElements) {
|
|
6875
6987
|
if (!this.layerManager.isLayerVisible(element.layerId)) {
|
|
6876
6988
|
if (this.renderer.isDomElement(element)) {
|
|
@@ -6878,14 +6990,27 @@ var RenderLoop = class {
|
|
|
6878
6990
|
}
|
|
6879
6991
|
continue;
|
|
6880
6992
|
}
|
|
6993
|
+
const order = ++paintOrder;
|
|
6881
6994
|
if (this.renderer.isDomElement(element)) {
|
|
6995
|
+
activeHybridOrder = null;
|
|
6882
6996
|
const layerOpacity = this.layerManager.getLayer?.(element.layerId)?.opacity ?? 1;
|
|
6883
|
-
const elBounds =
|
|
6997
|
+
const elBounds = getElementVisualBounds(element);
|
|
6884
6998
|
if (elBounds && !boundsIntersect(elBounds, cullingRect)) {
|
|
6885
6999
|
this.domNodeManager.hideDomNode(element.id);
|
|
6886
7000
|
} else {
|
|
6887
|
-
this.domNodeManager.syncDomNode(element,
|
|
7001
|
+
this.domNodeManager.syncDomNode(element, order, layerOpacity);
|
|
7002
|
+
}
|
|
7003
|
+
continue;
|
|
7004
|
+
}
|
|
7005
|
+
if (hybridActive && paintOrder > firstDomIndex + 1 && element.type !== "grid") {
|
|
7006
|
+
activeHybridOrder ??= order;
|
|
7007
|
+
let run = hybridCanvasRuns.get(activeHybridOrder);
|
|
7008
|
+
if (!run) {
|
|
7009
|
+
run = [];
|
|
7010
|
+
hybridCanvasRuns.set(activeHybridOrder, run);
|
|
7011
|
+
hybridOrders.add(activeHybridOrder);
|
|
6888
7012
|
}
|
|
7013
|
+
run.push(element);
|
|
6889
7014
|
continue;
|
|
6890
7015
|
}
|
|
6891
7016
|
if (element.type === "grid") {
|
|
@@ -6899,6 +7024,10 @@ var RenderLoop = class {
|
|
|
6899
7024
|
}
|
|
6900
7025
|
group.push(element);
|
|
6901
7026
|
}
|
|
7027
|
+
const activeTool = this.toolManager.activeTool;
|
|
7028
|
+
const overlayOrder = visibleElements.length + 1;
|
|
7029
|
+
if (hybridActive && activeTool?.renderOverlay) hybridOrders.add(overlayOrder);
|
|
7030
|
+
this.hybridSurface.beginFrame(hybridOrders, this.canvasEl.width, this.canvasEl.height);
|
|
6902
7031
|
for (const [layerId, elements] of this.layerGroups) {
|
|
6903
7032
|
const isActiveDrawingLayer = layerId === this.activeDrawingLayerId;
|
|
6904
7033
|
const layerOpacity = this.layerManager.getLayer?.(layerId)?.opacity ?? 1;
|
|
@@ -6922,7 +7051,7 @@ var RenderLoop = class {
|
|
|
6922
7051
|
offCtx.save();
|
|
6923
7052
|
this.marginViewport.applyRenderTransform(offCtx);
|
|
6924
7053
|
for (const element of elements) {
|
|
6925
|
-
const elBounds =
|
|
7054
|
+
const elBounds = getElementVisualBounds(element);
|
|
6926
7055
|
if (elBounds && !boundsIntersect(elBounds, cullingRect)) continue;
|
|
6927
7056
|
this.renderer.renderCanvasElement(offCtx, element);
|
|
6928
7057
|
}
|
|
@@ -6988,9 +7117,37 @@ var RenderLoop = class {
|
|
|
6988
7117
|
} else {
|
|
6989
7118
|
this.lastGridRefs = [];
|
|
6990
7119
|
}
|
|
7120
|
+
for (const [order, elements] of hybridCanvasRuns) {
|
|
7121
|
+
const hybridCtx = this.hybridSurface.getContext(order);
|
|
7122
|
+
if (!hybridCtx) continue;
|
|
7123
|
+
hybridCtx.clearRect(0, 0, this.canvasEl.width, this.canvasEl.height);
|
|
7124
|
+
hybridCtx.save();
|
|
7125
|
+
hybridCtx.scale(dpr, dpr);
|
|
7126
|
+
hybridCtx.translate(this.camera.position.x, this.camera.position.y);
|
|
7127
|
+
hybridCtx.scale(this.camera.zoom, this.camera.zoom);
|
|
7128
|
+
for (const element of elements) {
|
|
7129
|
+
const elBounds = getElementVisualBounds(element);
|
|
7130
|
+
if (elBounds && !boundsIntersect(elBounds, cullingRect)) continue;
|
|
7131
|
+
hybridCtx.save();
|
|
7132
|
+
hybridCtx.globalAlpha = this.layerManager.getLayer?.(element.layerId)?.opacity ?? 1;
|
|
7133
|
+
this.renderer.renderCanvasElement(hybridCtx, element);
|
|
7134
|
+
hybridCtx.restore();
|
|
7135
|
+
}
|
|
7136
|
+
hybridCtx.restore();
|
|
7137
|
+
}
|
|
6991
7138
|
const overlayT0 = performance.now();
|
|
6992
|
-
|
|
6993
|
-
|
|
7139
|
+
if (hybridActive && activeTool?.renderOverlay) {
|
|
7140
|
+
const overlayCtx = this.hybridSurface.getContext(overlayOrder);
|
|
7141
|
+
if (overlayCtx) {
|
|
7142
|
+
overlayCtx.clearRect(0, 0, this.canvasEl.width, this.canvasEl.height);
|
|
7143
|
+
overlayCtx.save();
|
|
7144
|
+
overlayCtx.scale(dpr, dpr);
|
|
7145
|
+
overlayCtx.translate(this.camera.position.x, this.camera.position.y);
|
|
7146
|
+
overlayCtx.scale(this.camera.zoom, this.camera.zoom);
|
|
7147
|
+
activeTool.renderOverlay(overlayCtx);
|
|
7148
|
+
overlayCtx.restore();
|
|
7149
|
+
}
|
|
7150
|
+
} else if (activeTool?.renderOverlay) {
|
|
6994
7151
|
activeTool.renderOverlay(ctx);
|
|
6995
7152
|
}
|
|
6996
7153
|
const overlayMs = performance.now() - overlayT0;
|
|
@@ -7741,8 +7898,11 @@ var Viewport = class {
|
|
|
7741
7898
|
});
|
|
7742
7899
|
this.wrapper = createWrapper();
|
|
7743
7900
|
this.canvasEl = createCanvas();
|
|
7901
|
+
this.paintStack = createPaintStack();
|
|
7744
7902
|
this.domLayer = createDomLayer();
|
|
7903
|
+
this.domLayer.style.zIndex = "2147483647";
|
|
7745
7904
|
this.wrapper.appendChild(this.canvasEl);
|
|
7905
|
+
this.wrapper.appendChild(this.paintStack);
|
|
7746
7906
|
this.wrapper.appendChild(this.domLayer);
|
|
7747
7907
|
this.container.appendChild(this.wrapper);
|
|
7748
7908
|
this.toolContext = {
|
|
@@ -7812,11 +7972,12 @@ var Viewport = class {
|
|
|
7812
7972
|
this.minimap.scheduleDraw();
|
|
7813
7973
|
}
|
|
7814
7974
|
this.domNodeManager = new DomNodeManager({
|
|
7815
|
-
domLayer: this.
|
|
7975
|
+
domLayer: this.paintStack,
|
|
7816
7976
|
onEditRequest: (id) => this.interactions.startEditingElement(id),
|
|
7817
7977
|
isEditingElement: (id) => this.noteEditor.isEditing && this.noteEditor.editingElementId === id,
|
|
7818
7978
|
getVersion: (id) => this.store.getVersion(id)
|
|
7819
7979
|
});
|
|
7980
|
+
this.domNodeManager.setCameraTransform(this.camera.toCSSTransform());
|
|
7820
7981
|
this.interactMode = new InteractMode({
|
|
7821
7982
|
getNode: (id) => this.domNodeManager.getNode(id)
|
|
7822
7983
|
});
|
|
@@ -7837,7 +7998,8 @@ var Viewport = class {
|
|
|
7837
7998
|
layerManager: this.layerManager,
|
|
7838
7999
|
domNodeManager: this.domNodeManager,
|
|
7839
8000
|
layerCache,
|
|
7840
|
-
marginViewport: this.marginViewport
|
|
8001
|
+
marginViewport: this.marginViewport,
|
|
8002
|
+
hybridSurface: new HybridRenderSurface(this.paintStack)
|
|
7841
8003
|
});
|
|
7842
8004
|
this.unsubCamera = this.camera.onChange(() => {
|
|
7843
8005
|
this.applyCameraTransform();
|
|
@@ -7924,6 +8086,7 @@ var Viewport = class {
|
|
|
7924
8086
|
history;
|
|
7925
8087
|
domLayer;
|
|
7926
8088
|
canvasEl;
|
|
8089
|
+
paintStack;
|
|
7927
8090
|
wrapper;
|
|
7928
8091
|
unsubCamera;
|
|
7929
8092
|
unsubToolChange;
|
|
@@ -8279,7 +8442,9 @@ var Viewport = class {
|
|
|
8279
8442
|
}
|
|
8280
8443
|
}
|
|
8281
8444
|
applyCameraTransform() {
|
|
8282
|
-
|
|
8445
|
+
const transform = this.camera.toCSSTransform();
|
|
8446
|
+
this.domLayer.style.transform = transform;
|
|
8447
|
+
this.domNodeManager.setCameraTransform(transform);
|
|
8283
8448
|
}
|
|
8284
8449
|
syncCanvasSize() {
|
|
8285
8450
|
const rect = this.container.getBoundingClientRect();
|
|
@@ -10960,7 +11125,7 @@ var LaserTool = class {
|
|
|
10960
11125
|
};
|
|
10961
11126
|
|
|
10962
11127
|
// src/index.ts
|
|
10963
|
-
var VERSION = "0.52.
|
|
11128
|
+
var VERSION = "0.52.2";
|
|
10964
11129
|
export {
|
|
10965
11130
|
ArrowTool,
|
|
10966
11131
|
AutoSave,
|