@floegence/redevplugin-ui 3.0.21 → 3.0.22
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/plugin.d.ts +1 -1
- package/dist/surface.d.ts +13 -1
- package/dist/surface.js +48 -1
- package/package.json +2 -2
package/dist/plugin.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ export { PluginBridgeClient } from "./surface.js";
|
|
|
2
2
|
export { PluginBridgeError } from "./errors.js";
|
|
3
3
|
export { pluginAPIMajor } from "./contracts.gen.js";
|
|
4
4
|
export { callCapabilityOperation, callCapabilityStream, callCapabilitySync, isCapabilityBusinessError, } from "./capability-client.js";
|
|
5
|
-
export type { BridgeLifecycleEvent, MessagePortLike, PluginBridgeClientOptions, PluginBridgeRequestOptions, PluginCanvasAccessibilityState, PluginCanvasInputEvent, PluginCanvasKeyEvent, PluginCanvasPointerEvent, PluginCanvasResizeEvent, PluginCanvasSurface, PluginJSONObject, PluginJSONValue, PluginMethodResult, PluginExecutionFailureCode, PluginExecutionSnapshot, PluginExecutionProgress, PluginExecutionEvent, PluginExecutionEventList, PluginSurfaceContext, PluginUIActionEvent, PluginUIAttributeValue, PluginUIElementVNode, PluginUIPatchOperation, PluginUIVNode, } from "./surface.js";
|
|
5
|
+
export type { BridgeLifecycleEvent, MessagePortLike, PluginBridgeClientOptions, PluginBridgeRequestOptions, PluginCanvasAccessibilityState, PluginCanvasInputEvent, PluginCanvasKeyEvent, PluginCanvasPointerEvent, PluginCanvasWheelEvent, PluginCanvasResizeEvent, PluginCanvasSurface, PluginJSONObject, PluginJSONValue, PluginMethodResult, PluginExecutionFailureCode, PluginExecutionSnapshot, PluginExecutionProgress, PluginExecutionEvent, PluginExecutionEventList, PluginSurfaceContext, PluginUIActionEvent, PluginUIAttributeValue, PluginUIElementVNode, PluginUIPatchOperation, PluginUIVNode, } from "./surface.js";
|
|
6
6
|
export type { PluginCapabilitySchema, PluginCapabilityEffect, PluginCapabilityOperationContract, PluginCapabilityStreamContract, PluginCapabilitySyncContract, PluginCapabilityStreamEvent, PluginCapabilityStreamReadResult, PluginExecution, PluginExecutionTerminalStatus, PluginExecutionWaitOptions, PluginStream, } from "./capability-client.js";
|
package/dist/surface.d.ts
CHANGED
|
@@ -136,7 +136,19 @@ export type PluginCanvasPointerEvent = {
|
|
|
136
136
|
y: number;
|
|
137
137
|
pressure: number;
|
|
138
138
|
};
|
|
139
|
-
export type
|
|
139
|
+
export type PluginCanvasWheelEvent = {
|
|
140
|
+
type: "wheel";
|
|
141
|
+
x: number;
|
|
142
|
+
y: number;
|
|
143
|
+
deltaX: number;
|
|
144
|
+
deltaY: number;
|
|
145
|
+
deltaMode: 0 | 1 | 2;
|
|
146
|
+
altKey: boolean;
|
|
147
|
+
ctrlKey: boolean;
|
|
148
|
+
metaKey: boolean;
|
|
149
|
+
shiftKey: boolean;
|
|
150
|
+
};
|
|
151
|
+
export type PluginCanvasInputEvent = PluginCanvasFocusEvent | PluginCanvasResizeEvent | PluginCanvasKeyEvent | PluginCanvasPointerEvent | PluginCanvasWheelEvent;
|
|
140
152
|
export type PluginMethodResult<T = unknown> = {
|
|
141
153
|
data: T;
|
|
142
154
|
execution_id?: string;
|
package/dist/surface.js
CHANGED
|
@@ -937,7 +937,12 @@ export function createOpaquePluginBootstrapHTML(options = {}) {
|
|
|
937
937
|
};
|
|
938
938
|
document.addEventListener("pointerdown", (event) => sendInteraction("activation", event.target), true);
|
|
939
939
|
document.addEventListener("focusin", (event) => sendInteraction("focus", event.target), true);
|
|
940
|
-
|
|
940
|
+
const ownsCanvasWheel = (target) => {
|
|
941
|
+
const element = target instanceof Element ? target.closest("canvas[data-redevplugin-canvas]") : null;
|
|
942
|
+
const canvasID = element?.getAttribute("data-redevplugin-canvas");
|
|
943
|
+
return validResourceIdentifier(canvasID) && canvasRuntimes.has(canvasID);
|
|
944
|
+
};
|
|
945
|
+
document.addEventListener("wheel", (event) => sendInteraction("wheel", event.target, { localScroll: ownsCanvasWheel(event.target) || ownsLocalScroll(event) }), { capture: true, passive: true });
|
|
941
946
|
document.addEventListener("selectionchange", () => {
|
|
942
947
|
const selection = document.getSelection();
|
|
943
948
|
const target = selection?.anchorNode instanceof Element ? selection.anchorNode : selection?.anchorNode?.parentElement;
|
|
@@ -2159,8 +2164,25 @@ export function createOpaquePluginBootstrapHTML(options = {}) {
|
|
|
2159
2164
|
shift_key: Boolean(event.shiftKey),
|
|
2160
2165
|
});
|
|
2161
2166
|
};
|
|
2167
|
+
const handleWheel = (event) => {
|
|
2168
|
+
event.preventDefault();
|
|
2169
|
+
const rect = canvas.getBoundingClientRect();
|
|
2170
|
+
sendInput({
|
|
2171
|
+
type: "wheel",
|
|
2172
|
+
x: Math.min(32768, Math.max(-16384, event.clientX - rect.left)),
|
|
2173
|
+
y: Math.min(32768, Math.max(-16384, event.clientY - rect.top)),
|
|
2174
|
+
delta_x: Math.min(32768, Math.max(-32768, Number.isFinite(event.deltaX) ? event.deltaX : 0)),
|
|
2175
|
+
delta_y: Math.min(32768, Math.max(-32768, Number.isFinite(event.deltaY) ? event.deltaY : 0)),
|
|
2176
|
+
delta_mode: [0, 1, 2].includes(event.deltaMode) ? event.deltaMode : 0,
|
|
2177
|
+
alt_key: Boolean(event.altKey),
|
|
2178
|
+
ctrl_key: Boolean(event.ctrlKey),
|
|
2179
|
+
meta_key: Boolean(event.metaKey),
|
|
2180
|
+
shift_key: Boolean(event.shiftKey),
|
|
2181
|
+
});
|
|
2182
|
+
};
|
|
2162
2183
|
for (const type of ["pointerdown", "pointermove", "pointerup", "pointercancel"]) listen(type, handlePointer);
|
|
2163
2184
|
for (const type of ["keydown", "keyup"]) listen(type, handleKey);
|
|
2185
|
+
listen("wheel", handleWheel);
|
|
2164
2186
|
listen("focus", () => sendInput({ type: "focus" }));
|
|
2165
2187
|
listen("blur", () => sendInput({ type: "blur" }));
|
|
2166
2188
|
const observer = new ResizeObserver(() => {
|
|
@@ -4298,6 +4320,28 @@ function publicCanvasInputMessage(value) {
|
|
|
4298
4320
|
},
|
|
4299
4321
|
};
|
|
4300
4322
|
}
|
|
4323
|
+
if (hasExactKeys(event, ["type", "x", "y", "delta_x", "delta_y", "delta_mode", "alt_key", "ctrl_key", "meta_key", "shift_key"]) &&
|
|
4324
|
+
event.type === "wheel" && validCanvasCoordinate(event.x) && validCanvasCoordinate(event.y) &&
|
|
4325
|
+
validCanvasWheelDelta(event.delta_x) && validCanvasWheelDelta(event.delta_y) &&
|
|
4326
|
+
(event.delta_mode === 0 || event.delta_mode === 1 || event.delta_mode === 2) &&
|
|
4327
|
+
typeof event.alt_key === "boolean" && typeof event.ctrl_key === "boolean" &&
|
|
4328
|
+
typeof event.meta_key === "boolean" && typeof event.shift_key === "boolean") {
|
|
4329
|
+
return {
|
|
4330
|
+
canvasId: value.canvas_id,
|
|
4331
|
+
event: {
|
|
4332
|
+
type: "wheel",
|
|
4333
|
+
x: event.x,
|
|
4334
|
+
y: event.y,
|
|
4335
|
+
deltaX: event.delta_x,
|
|
4336
|
+
deltaY: event.delta_y,
|
|
4337
|
+
deltaMode: event.delta_mode,
|
|
4338
|
+
altKey: event.alt_key,
|
|
4339
|
+
ctrlKey: event.ctrl_key,
|
|
4340
|
+
metaKey: event.meta_key,
|
|
4341
|
+
shiftKey: event.shift_key,
|
|
4342
|
+
},
|
|
4343
|
+
};
|
|
4344
|
+
}
|
|
4301
4345
|
return undefined;
|
|
4302
4346
|
}
|
|
4303
4347
|
function isOffscreenCanvasLike(value) {
|
|
@@ -4317,6 +4361,9 @@ function validDevicePixelRatio(value) {
|
|
|
4317
4361
|
function validCanvasCoordinate(value) {
|
|
4318
4362
|
return typeof value === "number" && Number.isFinite(value) && value >= -16384 && value <= 32768;
|
|
4319
4363
|
}
|
|
4364
|
+
function validCanvasWheelDelta(value) {
|
|
4365
|
+
return typeof value === "number" && Number.isFinite(value) && value >= -32768 && value <= 32768;
|
|
4366
|
+
}
|
|
4320
4367
|
function isMessagePortLike(value) {
|
|
4321
4368
|
return isRecord(value) &&
|
|
4322
4369
|
typeof value.postMessage === "function" &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@floegence/redevplugin-ui",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.22",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"dist"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@floegence/redevplugin-contracts": "3.0.
|
|
43
|
+
"@floegence/redevplugin-contracts": "3.0.22"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|