pixiboardjs 0.1.0-alpha.7 → 0.1.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/browser.d.ts +17 -1
- package/dist/browser.js +10 -3
- package/dist/browser.js.map +1 -1
- package/dist/tsdoc-metadata.json +11 -0
- package/etc/pixiboardjs-browser.api.md +8 -0
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.0-alpha.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8866ba4: Add `onDropOnEmpty` to `attachConnections`: called with the source node and release point (world and client coordinates) when a connection drag ends on empty canvas, so hosts can open a menu or create nodes and then connect them. Port clicks without movement, releases over nodes, outside the surface, or over host UI do not trigger it.
|
|
8
|
+
|
|
3
9
|
## 0.1.0-alpha.7
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/dist/browser.d.ts
CHANGED
|
@@ -779,6 +779,15 @@ type BoardConnection = {
|
|
|
779
779
|
source: string;
|
|
780
780
|
target: string;
|
|
781
781
|
};
|
|
782
|
+
/** A connection drag released over empty canvas (no node under the pointer). */
|
|
783
|
+
type ConnectionDropInfo = {
|
|
784
|
+
/** Node the drag started from. */
|
|
785
|
+
source: string;
|
|
786
|
+
/** Release point in world coordinates, e.g. where to place new nodes. */
|
|
787
|
+
point: Point;
|
|
788
|
+
/** Release point in client (viewport) coordinates, e.g. where to anchor a host menu. */
|
|
789
|
+
client: Point;
|
|
790
|
+
};
|
|
782
791
|
type ConnectionsOptions = {
|
|
783
792
|
surface: HTMLElement;
|
|
784
793
|
overlay?: HTMLElement;
|
|
@@ -790,6 +799,13 @@ type ConnectionsOptions = {
|
|
|
790
799
|
canInteract?: () => boolean;
|
|
791
800
|
/** Native node media surfaces rendered outside the canvas element. */
|
|
792
801
|
interactionOverlays?: readonly HTMLElement[];
|
|
802
|
+
/**
|
|
803
|
+
* Called when a connection drag ends on empty canvas instead of a node. No edge is created;
|
|
804
|
+
* the host decides what to do (for example open a menu, create nodes, then call `create`).
|
|
805
|
+
* Short clicks on the port (pointer moved less than a few pixels) do not trigger it, and neither
|
|
806
|
+
* does releasing over a node that cannot be connected, outside the surface, or over host UI.
|
|
807
|
+
*/
|
|
808
|
+
onDropOnEmpty?: (info: ConnectionDropInfo) => void;
|
|
793
809
|
};
|
|
794
810
|
/** Native Pixi connections, with one reusable DOM source port. */
|
|
795
811
|
declare function attachConnections(board: PixiBoard, options: ConnectionsOptions): Promise<{
|
|
@@ -895,4 +911,4 @@ declare function indexedDbPersistence(options?: {
|
|
|
895
911
|
database?: string;
|
|
896
912
|
}): BrowserPersistenceAdapter;
|
|
897
913
|
|
|
898
|
-
export { type AdapterOperationOptions, type AssetBinaryVariant, type AssetGcOptions, type AssetGcResult, type AssetGcRoots, type AssetStorageLocation, AssetVariant, type BoardConnection, BoardDocument, BoardDocumentUpdate, BoardNode, type BrowserAdapterCapabilities, type BrowserAdapterContractEvidence, type BrowserAdapterContractHarness, type BrowserAsset, BrowserAssetBinaryMissingError, type BrowserAssetExport, BrowserAssetNotFoundError, type BrowserCleanupError, type BrowserCleanupOperation, type BrowserCommitImportOptions, BrowserDocumentConflictError, type BrowserDocumentMetadata, type BrowserDocumentRecord, type BrowserDownloadRequest, type BrowserExportOptions, type BrowserImportOptions, type BrowserImportResult, type BrowserImportSourceType, BrowserPersistenceAbortError, BrowserPersistenceAdapter, type BrowserPersistenceAdapterOptions, BrowserPersistenceDestroyedError, BrowserPersistenceError, type BrowserPrepareImportOptions, type BrowserPreparedImport, BrowserStorageCapabilityError, BrowserStorageKeyCollisionError, BrowserStorageQuotaError, ConnectionCurve, ConnectionStyle, type ConnectionsController, type ConnectionsOptions, DEFAULT_OPFS_THRESHOLD_BYTES, type DomTransformer, type DomTransformerOptions, type DownloadPort, type GetAssetOptions, type IndexedDbPort, JsonValue, type LabelOverlayOptions, NativeDownloadPort, type NativeDownloadPortOptions, NativeIndexedDbPort, type NativeIndexedDbPortOptions, NativeObjectUrlPort, NativeOpfsPort, type NativeOpfsPortOptions, type NodeAgentContext, type NodeAgentContextOptions, type NodeAgentOperation, type NodeAgentOptions, type NodeAgentRequest, type NodeAgentResource, type NodeAgentScope, type NodeAgentTarget, type ObjectUrlLease, type ObjectUrlPort, type OpfsPort, type OverlayAnchor, type OverlayBoundsResolver, type OverlayDeclutter, type OverlayItem, type OverlayLayer, type OverlayLayerOptions, type OverlayPlacement, type OverlayRenderContext, type OverlayScaleMode, PixiBoard, PixiBoardRenderer, Point, type PortLifecycle, type PutAssetOptions, ResizeHandle, type SaveBrowserDocumentInput, type SaveBrowserDocumentOptions, type SelectionOverlayOptions, type StoredAssetBinary, type StoredAssetEntry, ViewportSnapshot, WorldBounds, anchorRatio, anchorWorldPoint, attachConnections, attachDomTransformer, attachLabelOverlay, attachOverlayLayer, attachSelectionOverlay, buildNodeAgentPrompt, createNodeAgentController, createPixiApplicationFactory, indexedDbPersistence, isBrowserQuotaError, loadPixiRuntime, projectOverlayItem, resolveOverlayBounds, resolveScale, runBrowserAdapterContract };
|
|
914
|
+
export { type AdapterOperationOptions, type AssetBinaryVariant, type AssetGcOptions, type AssetGcResult, type AssetGcRoots, type AssetStorageLocation, AssetVariant, type BoardConnection, BoardDocument, BoardDocumentUpdate, BoardNode, type BrowserAdapterCapabilities, type BrowserAdapterContractEvidence, type BrowserAdapterContractHarness, type BrowserAsset, BrowserAssetBinaryMissingError, type BrowserAssetExport, BrowserAssetNotFoundError, type BrowserCleanupError, type BrowserCleanupOperation, type BrowserCommitImportOptions, BrowserDocumentConflictError, type BrowserDocumentMetadata, type BrowserDocumentRecord, type BrowserDownloadRequest, type BrowserExportOptions, type BrowserImportOptions, type BrowserImportResult, type BrowserImportSourceType, BrowserPersistenceAbortError, BrowserPersistenceAdapter, type BrowserPersistenceAdapterOptions, BrowserPersistenceDestroyedError, BrowserPersistenceError, type BrowserPrepareImportOptions, type BrowserPreparedImport, BrowserStorageCapabilityError, BrowserStorageKeyCollisionError, BrowserStorageQuotaError, ConnectionCurve, type ConnectionDropInfo, ConnectionStyle, type ConnectionsController, type ConnectionsOptions, DEFAULT_OPFS_THRESHOLD_BYTES, type DomTransformer, type DomTransformerOptions, type DownloadPort, type GetAssetOptions, type IndexedDbPort, JsonValue, type LabelOverlayOptions, NativeDownloadPort, type NativeDownloadPortOptions, NativeIndexedDbPort, type NativeIndexedDbPortOptions, NativeObjectUrlPort, NativeOpfsPort, type NativeOpfsPortOptions, type NodeAgentContext, type NodeAgentContextOptions, type NodeAgentOperation, type NodeAgentOptions, type NodeAgentRequest, type NodeAgentResource, type NodeAgentScope, type NodeAgentTarget, type ObjectUrlLease, type ObjectUrlPort, type OpfsPort, type OverlayAnchor, type OverlayBoundsResolver, type OverlayDeclutter, type OverlayItem, type OverlayLayer, type OverlayLayerOptions, type OverlayPlacement, type OverlayRenderContext, type OverlayScaleMode, PixiBoard, PixiBoardRenderer, Point, type PortLifecycle, type PutAssetOptions, ResizeHandle, type SaveBrowserDocumentInput, type SaveBrowserDocumentOptions, type SelectionOverlayOptions, type StoredAssetBinary, type StoredAssetEntry, ViewportSnapshot, WorldBounds, anchorRatio, anchorWorldPoint, attachConnections, attachDomTransformer, attachLabelOverlay, attachOverlayLayer, attachSelectionOverlay, buildNodeAgentPrompt, createNodeAgentController, createPixiApplicationFactory, indexedDbPersistence, isBrowserQuotaError, loadPixiRuntime, projectOverlayItem, resolveOverlayBounds, resolveScale, runBrowserAdapterContract };
|
package/dist/browser.js
CHANGED
|
@@ -1780,6 +1780,7 @@ var NativeOpfsPort = class {
|
|
|
1780
1780
|
var PREVIEW_ID = "__connection_preview__";
|
|
1781
1781
|
var PORT_OFFSET = 7;
|
|
1782
1782
|
var PORT_HOVER_RADIUS = 14;
|
|
1783
|
+
var DROP_MIN_DISTANCE = 6;
|
|
1783
1784
|
async function attachConnections(board, options) {
|
|
1784
1785
|
const layer = await board.createConnectionLayer();
|
|
1785
1786
|
const surface = options.surface;
|
|
@@ -2029,7 +2030,7 @@ async function attachConnections(board, options) {
|
|
|
2029
2030
|
event.stopPropagation();
|
|
2030
2031
|
board.focus();
|
|
2031
2032
|
ownsKeyboard = true;
|
|
2032
|
-
drag = { source: hover, pointerId: event.pointerId, point: board.viewport.toWorld(screen(event)) };
|
|
2033
|
+
drag = { source: hover, pointerId: event.pointerId, point: board.viewport.toWorld(screen(event)), client: { x: event.clientX, y: event.clientY } };
|
|
2033
2034
|
selected = void 0;
|
|
2034
2035
|
schedule();
|
|
2035
2036
|
});
|
|
@@ -2063,13 +2064,19 @@ async function attachConnections(board, options) {
|
|
|
2063
2064
|
});
|
|
2064
2065
|
const finish = (event) => {
|
|
2065
2066
|
if (!drag || event.pointerId !== drag.pointerId) return;
|
|
2066
|
-
const source = drag
|
|
2067
|
+
const { source, client } = drag;
|
|
2067
2068
|
drag = void 0;
|
|
2069
|
+
let dropped;
|
|
2068
2070
|
if (event.type === "pointerup" && canInteract() && withinSurface(event) && isCanvasTarget(event.target) && !hasModifiers(event)) {
|
|
2069
|
-
const
|
|
2071
|
+
const point = board.viewport.toWorld(screen(event));
|
|
2072
|
+
const target = hitNode(point);
|
|
2070
2073
|
if (canConnect(target)) create(source, target.id);
|
|
2074
|
+
else if (!target && Math.hypot(event.clientX - client.x, event.clientY - client.y) >= DROP_MIN_DISTANCE) {
|
|
2075
|
+
dropped = { source, point, client: { x: event.clientX, y: event.clientY } };
|
|
2076
|
+
}
|
|
2071
2077
|
}
|
|
2072
2078
|
schedule();
|
|
2079
|
+
if (dropped) options.onDropOnEmpty?.(dropped);
|
|
2073
2080
|
};
|
|
2074
2081
|
listen(window, "pointerup", finish);
|
|
2075
2082
|
listen(window, "pointercancel", finish);
|