@wailsio/runtime 3.0.0-alpha.76 → 3.0.0-alpha.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/event_types.js +0 -1
- package/dist/index.js +5 -1
- package/dist/system.js +0 -30
- package/dist/window.js +229 -74
- package/package.json +1 -1
- package/types/event_types.d.ts +0 -1
- package/types/system.d.ts +0 -9
- package/types/window.d.ts +22 -3
package/dist/event_types.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -23,7 +23,7 @@ import * as Flags from "./flags.js";
|
|
|
23
23
|
import * as Screens from "./screens.js";
|
|
24
24
|
import * as System from "./system.js";
|
|
25
25
|
import * as IOS from "./ios.js";
|
|
26
|
-
import Window from "./window.js";
|
|
26
|
+
import Window, { handleDragEnter, handleDragLeave, handleDragOver } from "./window.js";
|
|
27
27
|
import * as WML from "./wml.js";
|
|
28
28
|
export { Application, Browser, Call, Clipboard, Dialogs, Events, Flags, Screens, System, IOS, Window, WML };
|
|
29
29
|
/**
|
|
@@ -41,4 +41,8 @@ window._wails.invoke = System.invoke;
|
|
|
41
41
|
// Note: Window is the thisWindow instance (default export from window.ts)
|
|
42
42
|
// Binding ensures 'this' correctly refers to the current window instance
|
|
43
43
|
window._wails.handlePlatformFileDrop = Window.HandlePlatformFileDrop.bind(Window);
|
|
44
|
+
// Linux-specific drag handlers (GTK intercepts DOM drag events)
|
|
45
|
+
window._wails.handleDragEnter = handleDragEnter;
|
|
46
|
+
window._wails.handleDragLeave = handleDragLeave;
|
|
47
|
+
window._wails.handleDragOver = handleDragOver;
|
|
44
48
|
System.invoke("wails:runtime:ready");
|
package/dist/system.js
CHANGED
|
@@ -12,7 +12,6 @@ const call = newRuntimeCaller(objectNames.System);
|
|
|
12
12
|
const SystemIsDarkMode = 0;
|
|
13
13
|
const SystemEnvironment = 1;
|
|
14
14
|
const SystemCapabilities = 2;
|
|
15
|
-
const ApplicationFilesDroppedWithContext = 100; // New method ID for enriched drop event
|
|
16
15
|
const _invoke = (function () {
|
|
17
16
|
var _a, _b, _c, _d, _e, _f;
|
|
18
17
|
try {
|
|
@@ -123,32 +122,3 @@ export function IsDebug() {
|
|
|
123
122
|
var _a, _b;
|
|
124
123
|
return Boolean((_b = (_a = window._wails) === null || _a === void 0 ? void 0 : _a.environment) === null || _b === void 0 ? void 0 : _b.Debug);
|
|
125
124
|
}
|
|
126
|
-
/**
|
|
127
|
-
* Handles file drops originating from platform-specific code (e.g., macOS native drag-and-drop).
|
|
128
|
-
* Gathers information about the drop target element and sends it back to the Go backend.
|
|
129
|
-
*
|
|
130
|
-
* @param filenames - An array of file paths (strings) that were dropped.
|
|
131
|
-
* @param x - The x-coordinate of the drop event.
|
|
132
|
-
* @param y - The y-coordinate of the drop event.
|
|
133
|
-
*/
|
|
134
|
-
export function HandlePlatformFileDrop(filenames, x, y) {
|
|
135
|
-
const element = document.elementFromPoint(x, y);
|
|
136
|
-
const elementId = element ? element.id : '';
|
|
137
|
-
const classList = element ? Array.from(element.classList) : [];
|
|
138
|
-
const payload = {
|
|
139
|
-
filenames,
|
|
140
|
-
x,
|
|
141
|
-
y,
|
|
142
|
-
elementId,
|
|
143
|
-
classList,
|
|
144
|
-
};
|
|
145
|
-
call(ApplicationFilesDroppedWithContext, payload)
|
|
146
|
-
.then(() => {
|
|
147
|
-
// Optional: Log success or handle if needed
|
|
148
|
-
console.log("Platform file drop processed and sent to Go.");
|
|
149
|
-
})
|
|
150
|
-
.catch(err => {
|
|
151
|
-
// Optional: Log error
|
|
152
|
-
console.error("Error sending platform file drop to Go:", err);
|
|
153
|
-
});
|
|
154
|
-
}
|
package/dist/window.js
CHANGED
|
@@ -8,10 +8,10 @@ The electron alternative for Go
|
|
|
8
8
|
(c) Lea Anthony 2019-present
|
|
9
9
|
*/
|
|
10
10
|
import { newRuntimeCaller, objectNames } from "./runtime.js";
|
|
11
|
-
//
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
let
|
|
11
|
+
// Drop target constants
|
|
12
|
+
const DROP_TARGET_ATTRIBUTE = 'data-file-drop-target';
|
|
13
|
+
const DROP_TARGET_ACTIVE_CLASS = 'file-drop-target-active';
|
|
14
|
+
let currentDropTarget = null;
|
|
15
15
|
const PositionMethod = 0;
|
|
16
16
|
const CenterMethod = 1;
|
|
17
17
|
const CloseMethod = 2;
|
|
@@ -62,14 +62,98 @@ const ZoomInMethod = 46;
|
|
|
62
62
|
const ZoomOutMethod = 47;
|
|
63
63
|
const ZoomResetMethod = 48;
|
|
64
64
|
const SnapAssistMethod = 49;
|
|
65
|
-
const
|
|
66
|
-
|
|
65
|
+
const FilesDropped = 50;
|
|
66
|
+
const PrintMethod = 51;
|
|
67
|
+
/**
|
|
68
|
+
* Finds the nearest drop target element by walking up the DOM tree.
|
|
69
|
+
*/
|
|
70
|
+
function getDropTargetElement(element) {
|
|
67
71
|
if (!element) {
|
|
68
72
|
return null;
|
|
69
73
|
}
|
|
70
|
-
|
|
71
|
-
|
|
74
|
+
return element.closest(`[${DROP_TARGET_ATTRIBUTE}]`);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Check if we can use WebView2's postMessageWithAdditionalObjects (Windows)
|
|
78
|
+
* Also checks that EnableFileDrop is true for this window.
|
|
79
|
+
*/
|
|
80
|
+
function canResolveFilePaths() {
|
|
81
|
+
var _a, _b, _c, _d;
|
|
82
|
+
// Must have WebView2's postMessageWithAdditionalObjects API (Windows only)
|
|
83
|
+
if (((_b = (_a = window.chrome) === null || _a === void 0 ? void 0 : _a.webview) === null || _b === void 0 ? void 0 : _b.postMessageWithAdditionalObjects) == null) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
// Must have EnableFileDrop set to true for this window
|
|
87
|
+
// This flag is set by the Go backend during runtime initialization
|
|
88
|
+
return ((_d = (_c = window._wails) === null || _c === void 0 ? void 0 : _c.flags) === null || _d === void 0 ? void 0 : _d.enableFileDrop) === true;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Send file drop to backend via WebView2 (Windows only)
|
|
92
|
+
*/
|
|
93
|
+
function resolveFilePaths(x, y, files) {
|
|
94
|
+
var _a, _b;
|
|
95
|
+
if ((_b = (_a = window.chrome) === null || _a === void 0 ? void 0 : _a.webview) === null || _b === void 0 ? void 0 : _b.postMessageWithAdditionalObjects) {
|
|
96
|
+
window.chrome.webview.postMessageWithAdditionalObjects(`file:drop:${x}:${y}`, files);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// Native drag state (Linux/macOS intercept DOM drag events)
|
|
100
|
+
let nativeDragActive = false;
|
|
101
|
+
/**
|
|
102
|
+
* Cleans up native drag state and hover effects.
|
|
103
|
+
* Called on drop or when drag leaves the window.
|
|
104
|
+
*/
|
|
105
|
+
function cleanupNativeDrag() {
|
|
106
|
+
nativeDragActive = false;
|
|
107
|
+
if (currentDropTarget) {
|
|
108
|
+
currentDropTarget.classList.remove(DROP_TARGET_ACTIVE_CLASS);
|
|
109
|
+
currentDropTarget = null;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Called from Go when a file drag enters the window on Linux/macOS.
|
|
114
|
+
*/
|
|
115
|
+
function handleDragEnter() {
|
|
116
|
+
var _a, _b;
|
|
117
|
+
// Check if file drops are enabled for this window
|
|
118
|
+
if (((_b = (_a = window._wails) === null || _a === void 0 ? void 0 : _a.flags) === null || _b === void 0 ? void 0 : _b.enableFileDrop) === false) {
|
|
119
|
+
return; // File drops disabled, don't activate drag state
|
|
120
|
+
}
|
|
121
|
+
nativeDragActive = true;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Called from Go when a file drag leaves the window on Linux/macOS.
|
|
125
|
+
*/
|
|
126
|
+
function handleDragLeave() {
|
|
127
|
+
cleanupNativeDrag();
|
|
72
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Called from Go during file drag to update hover state on Linux/macOS.
|
|
131
|
+
* @param x - X coordinate in CSS pixels
|
|
132
|
+
* @param y - Y coordinate in CSS pixels
|
|
133
|
+
*/
|
|
134
|
+
function handleDragOver(x, y) {
|
|
135
|
+
var _a, _b;
|
|
136
|
+
if (!nativeDragActive)
|
|
137
|
+
return;
|
|
138
|
+
// Check if file drops are enabled for this window
|
|
139
|
+
if (((_b = (_a = window._wails) === null || _a === void 0 ? void 0 : _a.flags) === null || _b === void 0 ? void 0 : _b.enableFileDrop) === false) {
|
|
140
|
+
return; // File drops disabled, don't show hover effects
|
|
141
|
+
}
|
|
142
|
+
const targetElement = document.elementFromPoint(x, y);
|
|
143
|
+
const dropTarget = getDropTargetElement(targetElement);
|
|
144
|
+
if (currentDropTarget && currentDropTarget !== dropTarget) {
|
|
145
|
+
currentDropTarget.classList.remove(DROP_TARGET_ACTIVE_CLASS);
|
|
146
|
+
}
|
|
147
|
+
if (dropTarget) {
|
|
148
|
+
dropTarget.classList.add(DROP_TARGET_ACTIVE_CLASS);
|
|
149
|
+
currentDropTarget = dropTarget;
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
currentDropTarget = null;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// Export the handlers for use by Go via index.ts
|
|
156
|
+
export { handleDragEnter, handleDragLeave, handleDragOver };
|
|
73
157
|
// Private field names.
|
|
74
158
|
const callerSym = Symbol("caller");
|
|
75
159
|
class Window {
|
|
@@ -451,30 +535,32 @@ class Window {
|
|
|
451
535
|
return this[callerSym](ZoomResetMethod);
|
|
452
536
|
}
|
|
453
537
|
/**
|
|
454
|
-
* Handles file drops originating from platform-specific code (e.g., macOS native drag-and-drop).
|
|
538
|
+
* Handles file drops originating from platform-specific code (e.g., macOS/Linux native drag-and-drop).
|
|
455
539
|
* Gathers information about the drop target element and sends it back to the Go backend.
|
|
456
540
|
*
|
|
457
541
|
* @param filenames - An array of file paths (strings) that were dropped.
|
|
458
|
-
* @param x - The x-coordinate of the drop event.
|
|
459
|
-
* @param y - The y-coordinate of the drop event.
|
|
542
|
+
* @param x - The x-coordinate of the drop event (CSS pixels).
|
|
543
|
+
* @param y - The y-coordinate of the drop event (CSS pixels).
|
|
460
544
|
*/
|
|
461
545
|
HandlePlatformFileDrop(filenames, x, y) {
|
|
546
|
+
var _a, _b;
|
|
547
|
+
// Check if file drops are enabled for this window
|
|
548
|
+
if (((_b = (_a = window._wails) === null || _a === void 0 ? void 0 : _a.flags) === null || _b === void 0 ? void 0 : _b.enableFileDrop) === false) {
|
|
549
|
+
return; // File drops disabled, ignore the drop
|
|
550
|
+
}
|
|
462
551
|
const element = document.elementFromPoint(x, y);
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
console.log(`Wails Runtime: Drop on element (or no element) at ${x},${y} which is not a designated dropzone. Ignoring. Element:`, element);
|
|
467
|
-
// No need to call backend if not a valid dropzone target
|
|
552
|
+
const dropTarget = getDropTargetElement(element);
|
|
553
|
+
if (!dropTarget) {
|
|
554
|
+
// Drop was not on a designated drop target - ignore
|
|
468
555
|
return;
|
|
469
556
|
}
|
|
470
|
-
console.log(`Wails Runtime: Drop on designated dropzone. Element at (${x}, ${y}):`, element, 'Effective dropzone:', dropzoneTarget);
|
|
471
557
|
const elementDetails = {
|
|
472
|
-
id:
|
|
473
|
-
classList: Array.from(
|
|
558
|
+
id: dropTarget.id,
|
|
559
|
+
classList: Array.from(dropTarget.classList),
|
|
474
560
|
attributes: {},
|
|
475
561
|
};
|
|
476
|
-
for (let i = 0; i <
|
|
477
|
-
const attr =
|
|
562
|
+
for (let i = 0; i < dropTarget.attributes.length; i++) {
|
|
563
|
+
const attr = dropTarget.attributes[i];
|
|
478
564
|
elementDetails.attributes[attr.name] = attr.value;
|
|
479
565
|
}
|
|
480
566
|
const payload = {
|
|
@@ -483,7 +569,9 @@ class Window {
|
|
|
483
569
|
y,
|
|
484
570
|
elementDetails,
|
|
485
571
|
};
|
|
486
|
-
this[callerSym](
|
|
572
|
+
this[callerSym](FilesDropped, payload);
|
|
573
|
+
// Clean up native drag state after drop
|
|
574
|
+
cleanupNativeDrag();
|
|
487
575
|
}
|
|
488
576
|
/* Triggers Windows 11 Snap Assist feature (Windows only).
|
|
489
577
|
* This is equivalent to pressing Win+Z and shows snap layout options.
|
|
@@ -491,80 +579,147 @@ class Window {
|
|
|
491
579
|
SnapAssist() {
|
|
492
580
|
return this[callerSym](SnapAssistMethod);
|
|
493
581
|
}
|
|
582
|
+
/**
|
|
583
|
+
* Opens the print dialog for the window.
|
|
584
|
+
*/
|
|
585
|
+
Print() {
|
|
586
|
+
return this[callerSym](PrintMethod);
|
|
587
|
+
}
|
|
494
588
|
}
|
|
495
589
|
/**
|
|
496
590
|
* The window within which the script is running.
|
|
497
591
|
*/
|
|
498
592
|
const thisWindow = new Window('');
|
|
499
|
-
|
|
500
|
-
|
|
593
|
+
/**
|
|
594
|
+
* Sets up global drag and drop event listeners for file drops.
|
|
595
|
+
* Handles visual feedback (hover state) and file drop processing.
|
|
596
|
+
*/
|
|
597
|
+
function setupDropTargetListeners() {
|
|
501
598
|
const docElement = document.documentElement;
|
|
502
|
-
let dragEnterCounter = 0;
|
|
599
|
+
let dragEnterCounter = 0;
|
|
503
600
|
docElement.addEventListener('dragenter', (event) => {
|
|
504
|
-
|
|
505
|
-
if (event.dataTransfer
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
601
|
+
var _a, _b, _c;
|
|
602
|
+
if (!((_a = event.dataTransfer) === null || _a === void 0 ? void 0 : _a.types.includes('Files'))) {
|
|
603
|
+
return; // Only handle file drags, let other drags pass through
|
|
604
|
+
}
|
|
605
|
+
event.preventDefault(); // Always prevent default to stop browser navigation
|
|
606
|
+
// On Windows, check if file drops are enabled for this window
|
|
607
|
+
if (((_c = (_b = window._wails) === null || _b === void 0 ? void 0 : _b.flags) === null || _c === void 0 ? void 0 : _c.enableFileDrop) === false) {
|
|
608
|
+
event.dataTransfer.dropEffect = 'none'; // Show "no drop" cursor
|
|
609
|
+
return; // File drops disabled, don't show hover effects
|
|
610
|
+
}
|
|
611
|
+
dragEnterCounter++;
|
|
612
|
+
const targetElement = document.elementFromPoint(event.clientX, event.clientY);
|
|
613
|
+
const dropTarget = getDropTargetElement(targetElement);
|
|
614
|
+
// Update hover state
|
|
615
|
+
if (currentDropTarget && currentDropTarget !== dropTarget) {
|
|
616
|
+
currentDropTarget.classList.remove(DROP_TARGET_ACTIVE_CLASS);
|
|
617
|
+
}
|
|
618
|
+
if (dropTarget) {
|
|
619
|
+
dropTarget.classList.add(DROP_TARGET_ACTIVE_CLASS);
|
|
620
|
+
event.dataTransfer.dropEffect = 'copy';
|
|
621
|
+
currentDropTarget = dropTarget;
|
|
622
|
+
}
|
|
623
|
+
else {
|
|
624
|
+
event.dataTransfer.dropEffect = 'none';
|
|
625
|
+
currentDropTarget = null;
|
|
522
626
|
}
|
|
523
627
|
}, false);
|
|
524
628
|
docElement.addEventListener('dragover', (event) => {
|
|
525
|
-
|
|
526
|
-
if (event.dataTransfer
|
|
527
|
-
//
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
629
|
+
var _a, _b, _c;
|
|
630
|
+
if (!((_a = event.dataTransfer) === null || _a === void 0 ? void 0 : _a.types.includes('Files'))) {
|
|
631
|
+
return; // Only handle file drags
|
|
632
|
+
}
|
|
633
|
+
event.preventDefault(); // Always prevent default to stop browser navigation
|
|
634
|
+
// On Windows, check if file drops are enabled for this window
|
|
635
|
+
if (((_c = (_b = window._wails) === null || _b === void 0 ? void 0 : _b.flags) === null || _c === void 0 ? void 0 : _c.enableFileDrop) === false) {
|
|
636
|
+
event.dataTransfer.dropEffect = 'none'; // Show "no drop" cursor
|
|
637
|
+
return; // File drops disabled, don't show hover effects
|
|
638
|
+
}
|
|
639
|
+
// Update drop target as cursor moves
|
|
640
|
+
const targetElement = document.elementFromPoint(event.clientX, event.clientY);
|
|
641
|
+
const dropTarget = getDropTargetElement(targetElement);
|
|
642
|
+
if (currentDropTarget && currentDropTarget !== dropTarget) {
|
|
643
|
+
currentDropTarget.classList.remove(DROP_TARGET_ACTIVE_CLASS);
|
|
644
|
+
}
|
|
645
|
+
if (dropTarget) {
|
|
646
|
+
if (!dropTarget.classList.contains(DROP_TARGET_ACTIVE_CLASS)) {
|
|
647
|
+
dropTarget.classList.add(DROP_TARGET_ACTIVE_CLASS);
|
|
538
648
|
}
|
|
649
|
+
event.dataTransfer.dropEffect = 'copy';
|
|
650
|
+
currentDropTarget = dropTarget;
|
|
651
|
+
}
|
|
652
|
+
else {
|
|
653
|
+
event.dataTransfer.dropEffect = 'none';
|
|
654
|
+
currentDropTarget = null;
|
|
539
655
|
}
|
|
540
656
|
}, false);
|
|
541
657
|
docElement.addEventListener('dragleave', (event) => {
|
|
542
|
-
|
|
543
|
-
if (event.dataTransfer
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
658
|
+
var _a, _b, _c;
|
|
659
|
+
if (!((_a = event.dataTransfer) === null || _a === void 0 ? void 0 : _a.types.includes('Files'))) {
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
event.preventDefault(); // Always prevent default to stop browser navigation
|
|
663
|
+
// On Windows, check if file drops are enabled for this window
|
|
664
|
+
if (((_c = (_b = window._wails) === null || _b === void 0 ? void 0 : _b.flags) === null || _c === void 0 ? void 0 : _c.enableFileDrop) === false) {
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
667
|
+
// On Linux/WebKitGTK and macOS, dragleave fires immediately with relatedTarget=null when native
|
|
668
|
+
// drag handling is involved. Ignore these spurious events - we'll clean up on drop instead.
|
|
669
|
+
if (event.relatedTarget === null) {
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
dragEnterCounter--;
|
|
673
|
+
if (dragEnterCounter === 0 ||
|
|
674
|
+
(currentDropTarget && !currentDropTarget.contains(event.relatedTarget))) {
|
|
675
|
+
if (currentDropTarget) {
|
|
676
|
+
currentDropTarget.classList.remove(DROP_TARGET_ACTIVE_CLASS);
|
|
677
|
+
currentDropTarget = null;
|
|
552
678
|
}
|
|
679
|
+
dragEnterCounter = 0;
|
|
553
680
|
}
|
|
554
681
|
}, false);
|
|
555
682
|
docElement.addEventListener('drop', (event) => {
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
683
|
+
var _a, _b, _c;
|
|
684
|
+
if (!((_a = event.dataTransfer) === null || _a === void 0 ? void 0 : _a.types.includes('Files'))) {
|
|
685
|
+
return; // Only handle file drops
|
|
686
|
+
}
|
|
687
|
+
event.preventDefault(); // Always prevent default to stop browser navigation
|
|
688
|
+
// On Windows, check if file drops are enabled for this window
|
|
689
|
+
if (((_c = (_b = window._wails) === null || _b === void 0 ? void 0 : _b.flags) === null || _c === void 0 ? void 0 : _c.enableFileDrop) === false) {
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
dragEnterCounter = 0;
|
|
693
|
+
if (currentDropTarget) {
|
|
694
|
+
currentDropTarget.classList.remove(DROP_TARGET_ACTIVE_CLASS);
|
|
695
|
+
currentDropTarget = null;
|
|
696
|
+
}
|
|
697
|
+
// On Windows, handle file drops via JavaScript
|
|
698
|
+
// On macOS/Linux, native code will call HandlePlatformFileDrop
|
|
699
|
+
if (canResolveFilePaths()) {
|
|
700
|
+
const files = [];
|
|
701
|
+
if (event.dataTransfer.items) {
|
|
702
|
+
for (const item of event.dataTransfer.items) {
|
|
703
|
+
if (item.kind === 'file') {
|
|
704
|
+
const file = item.getAsFile();
|
|
705
|
+
if (file)
|
|
706
|
+
files.push(file);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
else if (event.dataTransfer.files) {
|
|
711
|
+
for (const file of event.dataTransfer.files) {
|
|
712
|
+
files.push(file);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
if (files.length > 0) {
|
|
716
|
+
resolveFilePaths(event.clientX, event.clientY, files);
|
|
717
|
+
}
|
|
561
718
|
}
|
|
562
|
-
// The actual drop processing is initiated by the native side calling HandlePlatformFileDrop
|
|
563
|
-
// HandlePlatformFileDrop will then check if the drop was on a valid zone.
|
|
564
719
|
}, false);
|
|
565
720
|
}
|
|
566
721
|
// Initialize listeners when the script loads
|
|
567
722
|
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
568
|
-
|
|
723
|
+
setupDropTargetListeners();
|
|
569
724
|
}
|
|
570
725
|
export default thisWindow;
|
package/package.json
CHANGED
package/types/event_types.d.ts
CHANGED
package/types/system.d.ts
CHANGED
|
@@ -81,12 +81,3 @@ export declare function IsARM64(): boolean;
|
|
|
81
81
|
* @returns True if the app is being run in debug mode.
|
|
82
82
|
*/
|
|
83
83
|
export declare function IsDebug(): boolean;
|
|
84
|
-
/**
|
|
85
|
-
* Handles file drops originating from platform-specific code (e.g., macOS native drag-and-drop).
|
|
86
|
-
* Gathers information about the drop target element and sends it back to the Go backend.
|
|
87
|
-
*
|
|
88
|
-
* @param filenames - An array of file paths (strings) that were dropped.
|
|
89
|
-
* @param x - The x-coordinate of the drop event.
|
|
90
|
-
* @param y - The y-coordinate of the drop event.
|
|
91
|
-
*/
|
|
92
|
-
export declare function HandlePlatformFileDrop(filenames: string[], x: number, y: number): void;
|
package/types/window.d.ts
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
import type { Screen } from "./screens.js";
|
|
2
|
+
/**
|
|
3
|
+
* Called from Go when a file drag enters the window on Linux/macOS.
|
|
4
|
+
*/
|
|
5
|
+
declare function handleDragEnter(): void;
|
|
6
|
+
/**
|
|
7
|
+
* Called from Go when a file drag leaves the window on Linux/macOS.
|
|
8
|
+
*/
|
|
9
|
+
declare function handleDragLeave(): void;
|
|
10
|
+
/**
|
|
11
|
+
* Called from Go during file drag to update hover state on Linux/macOS.
|
|
12
|
+
* @param x - X coordinate in CSS pixels
|
|
13
|
+
* @param y - Y coordinate in CSS pixels
|
|
14
|
+
*/
|
|
15
|
+
declare function handleDragOver(x: number, y: number): void;
|
|
16
|
+
export { handleDragEnter, handleDragLeave, handleDragOver };
|
|
2
17
|
/**
|
|
3
18
|
* A record describing the position of a window.
|
|
4
19
|
*/
|
|
@@ -289,15 +304,19 @@ declare class Window {
|
|
|
289
304
|
*/
|
|
290
305
|
ZoomReset(): Promise<void>;
|
|
291
306
|
/**
|
|
292
|
-
* Handles file drops originating from platform-specific code (e.g., macOS native drag-and-drop).
|
|
307
|
+
* Handles file drops originating from platform-specific code (e.g., macOS/Linux native drag-and-drop).
|
|
293
308
|
* Gathers information about the drop target element and sends it back to the Go backend.
|
|
294
309
|
*
|
|
295
310
|
* @param filenames - An array of file paths (strings) that were dropped.
|
|
296
|
-
* @param x - The x-coordinate of the drop event.
|
|
297
|
-
* @param y - The y-coordinate of the drop event.
|
|
311
|
+
* @param x - The x-coordinate of the drop event (CSS pixels).
|
|
312
|
+
* @param y - The y-coordinate of the drop event (CSS pixels).
|
|
298
313
|
*/
|
|
299
314
|
HandlePlatformFileDrop(filenames: string[], x: number, y: number): void;
|
|
300
315
|
SnapAssist(): Promise<void>;
|
|
316
|
+
/**
|
|
317
|
+
* Opens the print dialog for the window.
|
|
318
|
+
*/
|
|
319
|
+
Print(): Promise<void>;
|
|
301
320
|
}
|
|
302
321
|
/**
|
|
303
322
|
* The window within which the script is running.
|