@vitejs/devtools 0.1.10 → 0.1.13
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/{DockStandalone-CX4RwLuJ.js → DockStandalone-kfuGuU1K.js} +128 -21
- package/dist/{LogItem-Ca0SsU39.js → LogItem-DOamSzjc.js} +1 -1
- package/dist/{ViewBuiltinLogs-B_CLlali.js → ViewBuiltinLogs-BW-Z3LV1.js} +35 -25
- package/dist/{ViewBuiltinTerminals-ZrMObMte.js → ViewBuiltinTerminals-D_aHYGk9.js} +1 -1
- package/dist/{ViewJsonRender-Cc5BPfnv.js → ViewJsonRender-BlN5HDyU.js} +1 -1
- package/dist/{build-static-Cb3vKjJS.js → build-static-SRf6Mx0K.js} +4 -4
- package/dist/cli-commands.js +8 -5
- package/dist/client/inject.js +3 -3
- package/dist/client/standalone/assets/DockIcon-Bn9P0BA3.js +1 -0
- package/dist/client/standalone/assets/DockStandalone-BNVMXM6t.js +3 -0
- package/dist/client/standalone/assets/DockStandalone-GABFNqKk.js +1 -0
- package/dist/client/standalone/assets/{LogItem-BnVhub2j.js → LogItem-B2zhdfw_.js} +1 -1
- package/dist/client/standalone/assets/ViewBuiltinLogs-Bv93zOX9.js +1 -0
- package/dist/client/standalone/assets/{ViewBuiltinTerminals-DqaYBA6Q.js → ViewBuiltinTerminals-DPB8d-Q0.js} +4 -4
- package/dist/client/standalone/assets/{ViewJsonRender-De5eeIha.js → ViewJsonRender-CSnziLMr.js} +1 -1
- package/dist/client/standalone/assets/dist-DIiIv9-S.js +5 -0
- package/dist/client/standalone/assets/index-C05Px9az.css +1 -0
- package/dist/client/standalone/assets/index-C9nheAgG.js +1 -0
- package/dist/client/standalone/assets/runtime-core.esm-bundler-Dfaj58fA.js +1 -0
- package/dist/client/standalone/index.html +8 -6
- package/dist/client/webcomponents.js +3 -3
- package/dist/{context-BWju7fup.js → context-WJ5shSfy.js} +564 -506
- package/dist/{dist-CCdqIez-.js → dist-DD29zy1v.js} +390 -5
- package/dist/index.d.ts +90 -87
- package/dist/index.js +3 -3
- package/dist/{plugins-Dhpm6Ql_.js → plugins-D8NH18dj.js} +6 -4
- package/dist/{popup-DgYOsFy3.js → popup-D4DzCx7h.js} +1 -1
- package/dist/{server-DSh-GQIq.js → server-CE1QMUPY.js} +4 -4
- package/dist/server-Cz5aS6Hb.js +2 -0
- package/dist/{server-ZWEvQMOm.js → server-kLW_T-bo.js} +3 -3
- package/dist/{standalone-D_6Gsoqw.js → standalone-eqACht_F.js} +2 -2
- package/package.json +17 -14
- package/dist/client/standalone/assets/DockStandalone-BvXvOkmY.js +0 -1
- package/dist/client/standalone/assets/ViewBuiltinLogs-rU-E-8qT.js +0 -1
- package/dist/client/standalone/assets/dist-CAaP5Isp.js +0 -1
- package/dist/client/standalone/assets/index-2_yFTdkG.js +0 -3
- package/dist/client/standalone/assets/index-DtZFMvER.css +0 -1
- package/dist/client/standalone/assets/runtime-core.esm-bundler-Bvz2jy0O.js +0 -1
- package/dist/server-BQ4s1VXj.js +0 -2
- /package/dist/client/standalone/assets/{iconify-C-CPDXMf.js → iconify-DTCjcGxu.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { computed, customRef, getCurrentInstance, getCurrentScope, hasInjectionContext, inject, isRef, nextTick, onMounted, onScopeDispose, readonly, ref, shallowReadonly, shallowRef, toRef, toValue, unref, watch, watchEffect } from "vue";
|
|
2
|
-
//#region ../../node_modules/.pnpm/@vueuse+shared@14.2.1_vue@3.5.
|
|
1
|
+
import { computed, customRef, getCurrentInstance, getCurrentScope, hasInjectionContext, inject, isRef, nextTick, onMounted, onScopeDispose, readonly, ref, shallowReadonly, shallowRef, toRaw, toRef, toRefs, toValue, unref, watch, watchEffect } from "vue";
|
|
2
|
+
//#region ../../node_modules/.pnpm/@vueuse+shared@14.2.1_vue@3.5.31_typescript@6.0.2_/node_modules/@vueuse/shared/dist/index.js
|
|
3
3
|
/**
|
|
4
4
|
* Call onScopeDispose() if it's inside an effect scope lifecycle, if not, do nothing
|
|
5
5
|
*
|
|
@@ -137,6 +137,31 @@ function pausableFilter(extendFilter = bypassFilter, options = {}) {
|
|
|
137
137
|
};
|
|
138
138
|
}
|
|
139
139
|
/**
|
|
140
|
+
* Create singleton promise function
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```
|
|
144
|
+
* const promise = createSingletonPromise(async () => { ... })
|
|
145
|
+
*
|
|
146
|
+
* await promise()
|
|
147
|
+
* await promise() // all of them will be bind to a single promise instance
|
|
148
|
+
* await promise() // and be resolved together
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
function createSingletonPromise(fn) {
|
|
152
|
+
let _promise;
|
|
153
|
+
function wrapper() {
|
|
154
|
+
if (!_promise) _promise = fn();
|
|
155
|
+
return _promise;
|
|
156
|
+
}
|
|
157
|
+
wrapper.reset = async () => {
|
|
158
|
+
const _prev = _promise;
|
|
159
|
+
_promise = void 0;
|
|
160
|
+
if (_prev) await _prev;
|
|
161
|
+
};
|
|
162
|
+
return wrapper;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
140
165
|
* Get a px value for SSR use, do not rely on this method outside of SSR as REM unit is assumed at 16px, which might not be the case on the client
|
|
141
166
|
*/
|
|
142
167
|
function pxValue(px) {
|
|
@@ -194,6 +219,39 @@ function watchPausable(source, cb, options = {}) {
|
|
|
194
219
|
};
|
|
195
220
|
}
|
|
196
221
|
/**
|
|
222
|
+
* Extended `toRefs` that also accepts refs of an object.
|
|
223
|
+
*
|
|
224
|
+
* @see https://vueuse.org/toRefs
|
|
225
|
+
* @param objectRef A ref or normal object or array.
|
|
226
|
+
* @param options Options
|
|
227
|
+
*/
|
|
228
|
+
function toRefs$1(objectRef, options = {}) {
|
|
229
|
+
if (!isRef(objectRef)) return toRefs(objectRef);
|
|
230
|
+
const result = Array.isArray(objectRef.value) ? Array.from({ length: objectRef.value.length }) : {};
|
|
231
|
+
for (const key in objectRef.value) result[key] = customRef(() => ({
|
|
232
|
+
get() {
|
|
233
|
+
return objectRef.value[key];
|
|
234
|
+
},
|
|
235
|
+
set(v) {
|
|
236
|
+
var _toValue;
|
|
237
|
+
if ((_toValue = toValue(options.replaceRef)) !== null && _toValue !== void 0 ? _toValue : true) if (Array.isArray(objectRef.value)) {
|
|
238
|
+
const copy = [...objectRef.value];
|
|
239
|
+
copy[key] = v;
|
|
240
|
+
objectRef.value = copy;
|
|
241
|
+
} else {
|
|
242
|
+
const newObject = {
|
|
243
|
+
...objectRef.value,
|
|
244
|
+
[key]: v
|
|
245
|
+
};
|
|
246
|
+
Object.setPrototypeOf(newObject, Object.getPrototypeOf(objectRef.value));
|
|
247
|
+
objectRef.value = newObject;
|
|
248
|
+
}
|
|
249
|
+
else objectRef.value[key] = v;
|
|
250
|
+
}
|
|
251
|
+
}));
|
|
252
|
+
return result;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
197
255
|
* Call onMounted() if it's inside a component lifecycle, if not, just call the function
|
|
198
256
|
*
|
|
199
257
|
* @param fn
|
|
@@ -246,6 +304,48 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
|
|
|
246
304
|
resume
|
|
247
305
|
};
|
|
248
306
|
}
|
|
307
|
+
/**
|
|
308
|
+
* Wrapper for `setTimeout` with controls.
|
|
309
|
+
*
|
|
310
|
+
* @param cb
|
|
311
|
+
* @param interval
|
|
312
|
+
* @param options
|
|
313
|
+
*/
|
|
314
|
+
function useTimeoutFn(cb, interval, options = {}) {
|
|
315
|
+
const { immediate = true, immediateCallback = false } = options;
|
|
316
|
+
const isPending = shallowRef(false);
|
|
317
|
+
let timer;
|
|
318
|
+
function clear() {
|
|
319
|
+
if (timer) {
|
|
320
|
+
clearTimeout(timer);
|
|
321
|
+
timer = void 0;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
function stop() {
|
|
325
|
+
isPending.value = false;
|
|
326
|
+
clear();
|
|
327
|
+
}
|
|
328
|
+
function start(...args) {
|
|
329
|
+
if (immediateCallback) cb();
|
|
330
|
+
clear();
|
|
331
|
+
isPending.value = true;
|
|
332
|
+
timer = setTimeout(() => {
|
|
333
|
+
isPending.value = false;
|
|
334
|
+
timer = void 0;
|
|
335
|
+
cb(...args);
|
|
336
|
+
}, toValue(interval));
|
|
337
|
+
}
|
|
338
|
+
if (immediate) {
|
|
339
|
+
isPending.value = true;
|
|
340
|
+
if (isClient) start();
|
|
341
|
+
}
|
|
342
|
+
tryOnScopeDispose(stop);
|
|
343
|
+
return {
|
|
344
|
+
isPending: shallowReadonly(isPending),
|
|
345
|
+
start,
|
|
346
|
+
stop
|
|
347
|
+
};
|
|
348
|
+
}
|
|
249
349
|
function watchDebounced(source, cb, options = {}) {
|
|
250
350
|
const { debounce = 0, maxWait = void 0, ...watchOptions } = options;
|
|
251
351
|
return watchWithFilter(source, cb, {
|
|
@@ -265,10 +365,10 @@ function watchImmediate(source, cb, options) {
|
|
|
265
365
|
});
|
|
266
366
|
}
|
|
267
367
|
//#endregion
|
|
268
|
-
//#region ../../node_modules/.pnpm/@vueuse+core@14.2.1_vue@3.5.
|
|
368
|
+
//#region ../../node_modules/.pnpm/@vueuse+core@14.2.1_vue@3.5.31_typescript@6.0.2_/node_modules/@vueuse/core/dist/index.js
|
|
269
369
|
const defaultWindow = isClient ? window : void 0;
|
|
270
370
|
isClient && window.document;
|
|
271
|
-
isClient
|
|
371
|
+
const defaultNavigator = isClient ? window.navigator : void 0;
|
|
272
372
|
isClient && window.location;
|
|
273
373
|
/**
|
|
274
374
|
* Get the dom element of a ref of element or Vue component instance
|
|
@@ -566,6 +666,101 @@ function useMediaQuery(query, options = {}) {
|
|
|
566
666
|
useEventListener(mediaQuery, "change", handler, { passive: true });
|
|
567
667
|
return computed(() => matches.value);
|
|
568
668
|
}
|
|
669
|
+
/**
|
|
670
|
+
* Reactive Permissions API.
|
|
671
|
+
*
|
|
672
|
+
* @see https://vueuse.org/usePermission
|
|
673
|
+
*
|
|
674
|
+
* @__NO_SIDE_EFFECTS__
|
|
675
|
+
*/
|
|
676
|
+
function usePermission(permissionDesc, options = {}) {
|
|
677
|
+
const { controls = false, navigator: navigator$1 = defaultNavigator } = options;
|
|
678
|
+
const isSupported = /* @__PURE__ */ useSupported(() => navigator$1 && "permissions" in navigator$1);
|
|
679
|
+
const permissionStatus = shallowRef();
|
|
680
|
+
const desc = typeof permissionDesc === "string" ? { name: permissionDesc } : permissionDesc;
|
|
681
|
+
const state = shallowRef();
|
|
682
|
+
const update = () => {
|
|
683
|
+
var _permissionStatus$val, _permissionStatus$val2;
|
|
684
|
+
state.value = (_permissionStatus$val = (_permissionStatus$val2 = permissionStatus.value) === null || _permissionStatus$val2 === void 0 ? void 0 : _permissionStatus$val2.state) !== null && _permissionStatus$val !== void 0 ? _permissionStatus$val : "prompt";
|
|
685
|
+
};
|
|
686
|
+
useEventListener(permissionStatus, "change", update, { passive: true });
|
|
687
|
+
const query = createSingletonPromise(async () => {
|
|
688
|
+
if (!isSupported.value) return;
|
|
689
|
+
if (!permissionStatus.value) try {
|
|
690
|
+
permissionStatus.value = await navigator$1.permissions.query(desc);
|
|
691
|
+
} catch (_unused) {
|
|
692
|
+
permissionStatus.value = void 0;
|
|
693
|
+
} finally {
|
|
694
|
+
update();
|
|
695
|
+
}
|
|
696
|
+
if (controls) return toRaw(permissionStatus.value);
|
|
697
|
+
});
|
|
698
|
+
query();
|
|
699
|
+
if (controls) return {
|
|
700
|
+
state,
|
|
701
|
+
isSupported,
|
|
702
|
+
query
|
|
703
|
+
};
|
|
704
|
+
else return state;
|
|
705
|
+
}
|
|
706
|
+
function useClipboard(options = {}) {
|
|
707
|
+
const { navigator: navigator$1 = defaultNavigator, read = false, source, copiedDuring = 1500, legacy = false } = options;
|
|
708
|
+
const isClipboardApiSupported = /* @__PURE__ */ useSupported(() => navigator$1 && "clipboard" in navigator$1);
|
|
709
|
+
const permissionRead = usePermission("clipboard-read");
|
|
710
|
+
const permissionWrite = usePermission("clipboard-write");
|
|
711
|
+
const isSupported = computed(() => isClipboardApiSupported.value || legacy);
|
|
712
|
+
const text = shallowRef("");
|
|
713
|
+
const copied = shallowRef(false);
|
|
714
|
+
const timeout = useTimeoutFn(() => copied.value = false, copiedDuring, { immediate: false });
|
|
715
|
+
async function updateText() {
|
|
716
|
+
let useLegacy = !(isClipboardApiSupported.value && isAllowed(permissionRead.value));
|
|
717
|
+
if (!useLegacy) try {
|
|
718
|
+
text.value = await navigator$1.clipboard.readText();
|
|
719
|
+
} catch (_unused) {
|
|
720
|
+
useLegacy = true;
|
|
721
|
+
}
|
|
722
|
+
if (useLegacy) text.value = legacyRead();
|
|
723
|
+
}
|
|
724
|
+
if (isSupported.value && read) useEventListener(["copy", "cut"], updateText, { passive: true });
|
|
725
|
+
async function copy(value = toValue(source)) {
|
|
726
|
+
if (isSupported.value && value != null) {
|
|
727
|
+
let useLegacy = !(isClipboardApiSupported.value && isAllowed(permissionWrite.value));
|
|
728
|
+
if (!useLegacy) try {
|
|
729
|
+
await navigator$1.clipboard.writeText(value);
|
|
730
|
+
} catch (_unused2) {
|
|
731
|
+
useLegacy = true;
|
|
732
|
+
}
|
|
733
|
+
if (useLegacy) legacyCopy(value);
|
|
734
|
+
text.value = value;
|
|
735
|
+
copied.value = true;
|
|
736
|
+
timeout.start();
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
function legacyCopy(value) {
|
|
740
|
+
const ta = document.createElement("textarea");
|
|
741
|
+
ta.value = value;
|
|
742
|
+
ta.style.position = "absolute";
|
|
743
|
+
ta.style.opacity = "0";
|
|
744
|
+
ta.setAttribute("readonly", "");
|
|
745
|
+
document.body.appendChild(ta);
|
|
746
|
+
ta.select();
|
|
747
|
+
document.execCommand("copy");
|
|
748
|
+
ta.remove();
|
|
749
|
+
}
|
|
750
|
+
function legacyRead() {
|
|
751
|
+
var _document$getSelectio, _document, _document$getSelectio2;
|
|
752
|
+
return (_document$getSelectio = (_document = document) === null || _document === void 0 || (_document$getSelectio2 = _document.getSelection) === null || _document$getSelectio2 === void 0 || (_document$getSelectio2 = _document$getSelectio2.call(_document)) === null || _document$getSelectio2 === void 0 ? void 0 : _document$getSelectio2.toString()) !== null && _document$getSelectio !== void 0 ? _document$getSelectio : "";
|
|
753
|
+
}
|
|
754
|
+
function isAllowed(status) {
|
|
755
|
+
return status === "granted" || status === "prompt";
|
|
756
|
+
}
|
|
757
|
+
return {
|
|
758
|
+
isSupported,
|
|
759
|
+
text: readonly(text),
|
|
760
|
+
copied: readonly(copied),
|
|
761
|
+
copy
|
|
762
|
+
};
|
|
763
|
+
}
|
|
569
764
|
const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
570
765
|
const globalKey = "__vueuse_ssr_handlers__";
|
|
571
766
|
const handlers = /* @__PURE__ */ getHandlers();
|
|
@@ -891,6 +1086,196 @@ function useDark(options = {}) {
|
|
|
891
1086
|
}
|
|
892
1087
|
});
|
|
893
1088
|
}
|
|
1089
|
+
const defaultScrollConfig = {
|
|
1090
|
+
speed: 2,
|
|
1091
|
+
margin: 30,
|
|
1092
|
+
direction: "both"
|
|
1093
|
+
};
|
|
1094
|
+
function clampContainerScroll(container) {
|
|
1095
|
+
if (container.scrollLeft > container.scrollWidth - container.clientWidth) container.scrollLeft = Math.max(0, container.scrollWidth - container.clientWidth);
|
|
1096
|
+
if (container.scrollTop > container.scrollHeight - container.clientHeight) container.scrollTop = Math.max(0, container.scrollHeight - container.clientHeight);
|
|
1097
|
+
}
|
|
1098
|
+
/**
|
|
1099
|
+
* Make elements draggable.
|
|
1100
|
+
*
|
|
1101
|
+
* @see https://vueuse.org/useDraggable
|
|
1102
|
+
* @param target
|
|
1103
|
+
* @param options
|
|
1104
|
+
*/
|
|
1105
|
+
function useDraggable(target, options = {}) {
|
|
1106
|
+
var _toValue, _toValue2, _toValue3, _scrollConfig$directi;
|
|
1107
|
+
const { pointerTypes, preventDefault: preventDefault$1, stopPropagation, exact, onMove, onEnd, onStart, initialValue, axis = "both", draggingElement = defaultWindow, containerElement, handle: draggingHandle = target, buttons = [0], restrictInView, autoScroll = false } = options;
|
|
1108
|
+
const position = ref((_toValue = toValue(initialValue)) !== null && _toValue !== void 0 ? _toValue : {
|
|
1109
|
+
x: 0,
|
|
1110
|
+
y: 0
|
|
1111
|
+
});
|
|
1112
|
+
const pressedDelta = ref();
|
|
1113
|
+
const filterEvent = (e) => {
|
|
1114
|
+
if (pointerTypes) return pointerTypes.includes(e.pointerType);
|
|
1115
|
+
return true;
|
|
1116
|
+
};
|
|
1117
|
+
const handleEvent = (e) => {
|
|
1118
|
+
if (toValue(preventDefault$1)) e.preventDefault();
|
|
1119
|
+
if (toValue(stopPropagation)) e.stopPropagation();
|
|
1120
|
+
};
|
|
1121
|
+
const scrollConfig = toValue(autoScroll);
|
|
1122
|
+
const scrollSettings = typeof scrollConfig === "object" ? {
|
|
1123
|
+
speed: (_toValue2 = toValue(scrollConfig.speed)) !== null && _toValue2 !== void 0 ? _toValue2 : defaultScrollConfig.speed,
|
|
1124
|
+
margin: (_toValue3 = toValue(scrollConfig.margin)) !== null && _toValue3 !== void 0 ? _toValue3 : defaultScrollConfig.margin,
|
|
1125
|
+
direction: (_scrollConfig$directi = scrollConfig.direction) !== null && _scrollConfig$directi !== void 0 ? _scrollConfig$directi : defaultScrollConfig.direction
|
|
1126
|
+
} : defaultScrollConfig;
|
|
1127
|
+
const getScrollAxisValues = (value) => typeof value === "number" ? [value, value] : [value.x, value.y];
|
|
1128
|
+
const handleAutoScroll = (container, targetRect, position$1) => {
|
|
1129
|
+
const { clientWidth, clientHeight, scrollLeft, scrollTop, scrollWidth, scrollHeight } = container;
|
|
1130
|
+
const [marginX, marginY] = getScrollAxisValues(scrollSettings.margin);
|
|
1131
|
+
const [speedX, speedY] = getScrollAxisValues(scrollSettings.speed);
|
|
1132
|
+
let deltaX = 0;
|
|
1133
|
+
let deltaY = 0;
|
|
1134
|
+
if (scrollSettings.direction === "x" || scrollSettings.direction === "both") {
|
|
1135
|
+
if (position$1.x < marginX && scrollLeft > 0) deltaX = -speedX;
|
|
1136
|
+
else if (position$1.x + targetRect.width > clientWidth - marginX && scrollLeft < scrollWidth - clientWidth) deltaX = speedX;
|
|
1137
|
+
}
|
|
1138
|
+
if (scrollSettings.direction === "y" || scrollSettings.direction === "both") {
|
|
1139
|
+
if (position$1.y < marginY && scrollTop > 0) deltaY = -speedY;
|
|
1140
|
+
else if (position$1.y + targetRect.height > clientHeight - marginY && scrollTop < scrollHeight - clientHeight) deltaY = speedY;
|
|
1141
|
+
}
|
|
1142
|
+
if (deltaX || deltaY) container.scrollBy({
|
|
1143
|
+
left: deltaX,
|
|
1144
|
+
top: deltaY,
|
|
1145
|
+
behavior: "auto"
|
|
1146
|
+
});
|
|
1147
|
+
};
|
|
1148
|
+
let autoScrollInterval = null;
|
|
1149
|
+
const startAutoScroll = () => {
|
|
1150
|
+
const container = toValue(containerElement);
|
|
1151
|
+
if (container && !autoScrollInterval) autoScrollInterval = setInterval(() => {
|
|
1152
|
+
const targetRect = toValue(target).getBoundingClientRect();
|
|
1153
|
+
const { x, y } = position.value;
|
|
1154
|
+
const relativePosition = {
|
|
1155
|
+
x: x - container.scrollLeft,
|
|
1156
|
+
y: y - container.scrollTop
|
|
1157
|
+
};
|
|
1158
|
+
if (relativePosition.x >= 0 && relativePosition.y >= 0) {
|
|
1159
|
+
handleAutoScroll(container, targetRect, relativePosition);
|
|
1160
|
+
relativePosition.x += container.scrollLeft;
|
|
1161
|
+
relativePosition.y += container.scrollTop;
|
|
1162
|
+
position.value = relativePosition;
|
|
1163
|
+
}
|
|
1164
|
+
}, 1e3 / 60);
|
|
1165
|
+
};
|
|
1166
|
+
const stopAutoScroll = () => {
|
|
1167
|
+
if (autoScrollInterval) {
|
|
1168
|
+
clearInterval(autoScrollInterval);
|
|
1169
|
+
autoScrollInterval = null;
|
|
1170
|
+
}
|
|
1171
|
+
};
|
|
1172
|
+
const isPointerNearEdge = (pointer, container, margin, targetRect) => {
|
|
1173
|
+
const [marginX, marginY] = typeof margin === "number" ? [margin, margin] : [margin.x, margin.y];
|
|
1174
|
+
const { clientWidth, clientHeight } = container;
|
|
1175
|
+
return pointer.x < marginX || pointer.x + targetRect.width > clientWidth - marginX || pointer.y < marginY || pointer.y + targetRect.height > clientHeight - marginY;
|
|
1176
|
+
};
|
|
1177
|
+
const checkAutoScroll = () => {
|
|
1178
|
+
if (toValue(options.disabled) || !pressedDelta.value) return;
|
|
1179
|
+
const container = toValue(containerElement);
|
|
1180
|
+
if (!container) return;
|
|
1181
|
+
const targetRect = toValue(target).getBoundingClientRect();
|
|
1182
|
+
const { x, y } = position.value;
|
|
1183
|
+
if (isPointerNearEdge({
|
|
1184
|
+
x: x - container.scrollLeft,
|
|
1185
|
+
y: y - container.scrollTop
|
|
1186
|
+
}, container, scrollSettings.margin, targetRect)) startAutoScroll();
|
|
1187
|
+
else stopAutoScroll();
|
|
1188
|
+
};
|
|
1189
|
+
if (toValue(autoScroll)) watch(position, checkAutoScroll);
|
|
1190
|
+
const start = (e) => {
|
|
1191
|
+
var _container$getBoundin;
|
|
1192
|
+
if (!toValue(buttons).includes(e.button)) return;
|
|
1193
|
+
if (toValue(options.disabled) || !filterEvent(e)) return;
|
|
1194
|
+
if (toValue(exact) && e.target !== toValue(target)) return;
|
|
1195
|
+
const container = toValue(containerElement);
|
|
1196
|
+
const containerRect = container === null || container === void 0 || (_container$getBoundin = container.getBoundingClientRect) === null || _container$getBoundin === void 0 ? void 0 : _container$getBoundin.call(container);
|
|
1197
|
+
const targetRect = toValue(target).getBoundingClientRect();
|
|
1198
|
+
const pos = {
|
|
1199
|
+
x: e.clientX - (container ? targetRect.left - containerRect.left + (autoScroll ? 0 : container.scrollLeft) : targetRect.left),
|
|
1200
|
+
y: e.clientY - (container ? targetRect.top - containerRect.top + (autoScroll ? 0 : container.scrollTop) : targetRect.top)
|
|
1201
|
+
};
|
|
1202
|
+
if ((onStart === null || onStart === void 0 ? void 0 : onStart(pos, e)) === false) return;
|
|
1203
|
+
pressedDelta.value = pos;
|
|
1204
|
+
handleEvent(e);
|
|
1205
|
+
};
|
|
1206
|
+
const move = (e) => {
|
|
1207
|
+
if (toValue(options.disabled) || !filterEvent(e)) return;
|
|
1208
|
+
if (!pressedDelta.value) return;
|
|
1209
|
+
const container = toValue(containerElement);
|
|
1210
|
+
if (container instanceof HTMLElement) clampContainerScroll(container);
|
|
1211
|
+
const targetRect = toValue(target).getBoundingClientRect();
|
|
1212
|
+
let { x, y } = position.value;
|
|
1213
|
+
if (axis === "x" || axis === "both") {
|
|
1214
|
+
x = e.clientX - pressedDelta.value.x;
|
|
1215
|
+
if (container) x = Math.min(Math.max(0, x), container.scrollWidth - targetRect.width);
|
|
1216
|
+
}
|
|
1217
|
+
if (axis === "y" || axis === "both") {
|
|
1218
|
+
y = e.clientY - pressedDelta.value.y;
|
|
1219
|
+
if (container) y = Math.min(Math.max(0, y), container.scrollHeight - targetRect.height);
|
|
1220
|
+
}
|
|
1221
|
+
if (toValue(autoScroll) && container) {
|
|
1222
|
+
if (autoScrollInterval === null) handleAutoScroll(container, targetRect, {
|
|
1223
|
+
x,
|
|
1224
|
+
y
|
|
1225
|
+
});
|
|
1226
|
+
x += container.scrollLeft;
|
|
1227
|
+
y += container.scrollTop;
|
|
1228
|
+
}
|
|
1229
|
+
if (container && (restrictInView || autoScroll)) {
|
|
1230
|
+
if (axis !== "y") {
|
|
1231
|
+
const relativeX = x - container.scrollLeft;
|
|
1232
|
+
if (relativeX < 0) x = container.scrollLeft;
|
|
1233
|
+
else if (relativeX > container.clientWidth - targetRect.width) x = container.clientWidth - targetRect.width + container.scrollLeft;
|
|
1234
|
+
}
|
|
1235
|
+
if (axis !== "x") {
|
|
1236
|
+
const relativeY = y - container.scrollTop;
|
|
1237
|
+
if (relativeY < 0) y = container.scrollTop;
|
|
1238
|
+
else if (relativeY > container.clientHeight - targetRect.height) y = container.clientHeight - targetRect.height + container.scrollTop;
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
position.value = {
|
|
1242
|
+
x,
|
|
1243
|
+
y
|
|
1244
|
+
};
|
|
1245
|
+
onMove === null || onMove === void 0 || onMove(position.value, e);
|
|
1246
|
+
handleEvent(e);
|
|
1247
|
+
};
|
|
1248
|
+
const end = (e) => {
|
|
1249
|
+
if (toValue(options.disabled) || !filterEvent(e)) return;
|
|
1250
|
+
if (!pressedDelta.value) return;
|
|
1251
|
+
pressedDelta.value = void 0;
|
|
1252
|
+
if (autoScroll) stopAutoScroll();
|
|
1253
|
+
onEnd === null || onEnd === void 0 || onEnd(position.value, e);
|
|
1254
|
+
handleEvent(e);
|
|
1255
|
+
};
|
|
1256
|
+
if (isClient) {
|
|
1257
|
+
const config = () => {
|
|
1258
|
+
var _options$capture;
|
|
1259
|
+
return {
|
|
1260
|
+
capture: (_options$capture = options.capture) !== null && _options$capture !== void 0 ? _options$capture : true,
|
|
1261
|
+
passive: !toValue(preventDefault$1)
|
|
1262
|
+
};
|
|
1263
|
+
};
|
|
1264
|
+
useEventListener(draggingHandle, "pointerdown", start, config);
|
|
1265
|
+
useEventListener(draggingElement, "pointermove", move, config);
|
|
1266
|
+
useEventListener(draggingElement, "pointerup", end, config);
|
|
1267
|
+
}
|
|
1268
|
+
return {
|
|
1269
|
+
...toRefs$1(position),
|
|
1270
|
+
position,
|
|
1271
|
+
isDragging: computed(() => !!pressedDelta.value),
|
|
1272
|
+
style: computed(() => `
|
|
1273
|
+
left: ${position.value.x}px;
|
|
1274
|
+
top: ${position.value.y}px;
|
|
1275
|
+
${autoScroll ? "text-wrap: nowrap;" : ""}
|
|
1276
|
+
`)
|
|
1277
|
+
};
|
|
1278
|
+
}
|
|
894
1279
|
/**
|
|
895
1280
|
* Reports changes to the dimensions of an Element's content or the border-box
|
|
896
1281
|
*
|
|
@@ -1233,4 +1618,4 @@ function useWindowSize(options = {}) {
|
|
|
1233
1618
|
};
|
|
1234
1619
|
}
|
|
1235
1620
|
//#endregion
|
|
1236
|
-
export {
|
|
1621
|
+
export { useElementBounding as a, useScreenSafeArea as c, useDebounceFn as d, watchDebounced as f, useDraggable as i, useTimeAgo as l, useClipboard as n, useEventListener as o, watchImmediate as p, useDark as r, useLocalStorage as s, onClickOutside as t, useWindowSize as u };
|