@harborclient/sdk 0.6.12 → 0.6.15
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/components/Resizable/useResizable.d.ts.map +1 -1
- package/dist/components/Resizable/useResizable.js +63 -0
- package/dist/runtime/contributionRegistry.js +83 -0
- package/dist/runtime/createBridgedPluginContext.js +855 -0
- package/dist/runtime/hcBridge.d.ts +26 -0
- package/dist/runtime/hcBridge.js +104 -0
- package/dist/runtime/reactHost.js +28 -0
- package/dist/runtime/view-host/index.d.ts +1 -0
- package/dist/runtime/view-host/index.js +3 -0
- package/dist/runtime/viewHost.js +124 -0
- package/dist/types.d.ts +35 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +7 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useResizable.d.ts","sourceRoot":"","sources":["../../../src/components/Resizable/useResizable.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,IAAI,kBAAkB,EAAE,UAAU,IAAI,eAAe,EAAE,MAAM,OAAO,CAAC;AAEhG,KAAK,IAAI,GAAG,GAAG,GAAG,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"useResizable.d.ts","sourceRoot":"","sources":["../../../src/components/Resizable/useResizable.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,IAAI,kBAAkB,EAAE,UAAU,IAAI,eAAe,EAAE,MAAM,OAAO,CAAC;AAEhG,KAAK,IAAI,GAAG,GAAG,GAAG,GAAG,CAAC;AAkDtB,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,IAAI,EAAE,IAAI,CAAC;IAEX;;OAEG;IACH,SAAS,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAElB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,MAAM,CAAC;IAE1B;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,aAAa,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IAChD,gBAAgB,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;CACvD;AAoCD;;GAEG;AACH,wBAAgB,YAAY,CAAC,EAC3B,IAAI,EACJ,SAAS,EACT,WAAW,EACX,OAAO,EACP,UAAU,EACV,UAAU,EACX,EAAE,mBAAmB,GAAG,kBAAkB,CAoJ1C"}
|
|
@@ -1,4 +1,48 @@
|
|
|
1
1
|
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from '@harborclient/sdk/react';
|
|
2
|
+
/** Id of the shared stylesheet injected during resize drags. */
|
|
3
|
+
const RESIZING_STYLE_ID = 'hc-resizable-drag-styles';
|
|
4
|
+
/**
|
|
5
|
+
* Injects shared CSS that neutralizes webviews/iframes and shows the resize cursor during drags.
|
|
6
|
+
* Electron webviews paint above normal DOM, so pointer-events must be disabled on the webview itself.
|
|
7
|
+
*/
|
|
8
|
+
function ensureResizingStylesheet() {
|
|
9
|
+
if (document.getElementById(RESIZING_STYLE_ID)) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const style = document.createElement('style');
|
|
13
|
+
style.id = RESIZING_STYLE_ID;
|
|
14
|
+
style.textContent = `
|
|
15
|
+
body[data-hc-resizing] webview,
|
|
16
|
+
body[data-hc-resizing] iframe {
|
|
17
|
+
pointer-events: none !important;
|
|
18
|
+
}
|
|
19
|
+
body[data-hc-resizing="y"] * {
|
|
20
|
+
cursor: row-resize !important;
|
|
21
|
+
}
|
|
22
|
+
body[data-hc-resizing="x"] * {
|
|
23
|
+
cursor: col-resize !important;
|
|
24
|
+
}
|
|
25
|
+
body[data-hc-resizing] {
|
|
26
|
+
user-select: none !important;
|
|
27
|
+
}
|
|
28
|
+
`.trim();
|
|
29
|
+
document.head.appendChild(style);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Marks the document as in an active resize drag so embedded webviews pass pointer events through.
|
|
33
|
+
*
|
|
34
|
+
* @param axis - Resize axis used for cursor styling.
|
|
35
|
+
*/
|
|
36
|
+
function setResizingState(axis) {
|
|
37
|
+
ensureResizingStylesheet();
|
|
38
|
+
document.body.dataset.hcResizing = axis;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Clears the active resize drag marker from the document body.
|
|
42
|
+
*/
|
|
43
|
+
function clearResizingState() {
|
|
44
|
+
delete document.body.dataset.hcResizing;
|
|
45
|
+
}
|
|
2
46
|
/**
|
|
3
47
|
* Loads a persisted size from localStorage.
|
|
4
48
|
*/
|
|
@@ -80,6 +124,7 @@ export function useResizable({ axis, direction, defaultSize, minSize, getMaxSize
|
|
|
80
124
|
resizingRef.current = true;
|
|
81
125
|
startPosRef.current = axis === 'x' ? event.clientX : event.clientY;
|
|
82
126
|
startSizeRef.current = sizeRef.current;
|
|
127
|
+
setResizingState(axis);
|
|
83
128
|
}, [axis]);
|
|
84
129
|
/**
|
|
85
130
|
* Nudges panel size from arrow keys using the same axis/direction math as drag.
|
|
@@ -136,6 +181,7 @@ export function useResizable({ axis, direction, defaultSize, minSize, getMaxSize
|
|
|
136
181
|
if (!resizingRef.current)
|
|
137
182
|
return;
|
|
138
183
|
resizingRef.current = false;
|
|
184
|
+
clearResizingState();
|
|
139
185
|
if (storageKey) {
|
|
140
186
|
persistSize(storageKey, sizeRef.current);
|
|
141
187
|
}
|
|
@@ -143,9 +189,26 @@ export function useResizable({ axis, direction, defaultSize, minSize, getMaxSize
|
|
|
143
189
|
window.addEventListener('mousemove', handleMouseMove);
|
|
144
190
|
window.addEventListener('mouseup', handleMouseUp);
|
|
145
191
|
return () => {
|
|
192
|
+
// Only detach listeners here. This effect re-runs whenever a dependency
|
|
193
|
+
// such as `getMaxSize` changes identity (callers often pass an inline
|
|
194
|
+
// function), which happens on every render the drag itself triggers via
|
|
195
|
+
// setSizeState. Resetting `resizingRef`/clearing state here would abort
|
|
196
|
+
// the drag after the first pointer move. Mid-drag teardown on real
|
|
197
|
+
// unmount is handled by the dedicated unmount effect below.
|
|
146
198
|
window.removeEventListener('mousemove', handleMouseMove);
|
|
147
199
|
window.removeEventListener('mouseup', handleMouseUp);
|
|
148
200
|
};
|
|
149
201
|
}, [axis, direction, getMaxSize, minSize, storageKey]);
|
|
202
|
+
/**
|
|
203
|
+
* Clears the document resize marker when the hook unmounts mid-drag.
|
|
204
|
+
*/
|
|
205
|
+
useEffect(() => {
|
|
206
|
+
return () => {
|
|
207
|
+
if (resizingRef.current) {
|
|
208
|
+
resizingRef.current = false;
|
|
209
|
+
clearResizingState();
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
}, []);
|
|
150
213
|
return { size, minSize, maxSize, setSize, onResizeStart, onKeyboardResize };
|
|
151
214
|
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory contribution registry for one plugin activation inside an isolated webview.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/** @type {Map<string, unknown>} */
|
|
6
|
+
const components = new Map();
|
|
7
|
+
|
|
8
|
+
/** @type {Map<string, unknown>} */
|
|
9
|
+
const indicators = new Map();
|
|
10
|
+
|
|
11
|
+
/** @type {Map<string, unknown>} */
|
|
12
|
+
const headerActions = new Map();
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Stores a UI contribution component keyed by manifest contribution id.
|
|
16
|
+
*
|
|
17
|
+
* @param {string} kind - Contribution bucket (requestTabs, sidebarPanels, etc.).
|
|
18
|
+
* @param {string} contributionId - Manifest contributes.* id.
|
|
19
|
+
* @param {unknown} component - React component reference.
|
|
20
|
+
*/
|
|
21
|
+
export function registerContributionComponent(kind, contributionId, component) {
|
|
22
|
+
components.set(`${kind}:${contributionId}`, component);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Stores an optional footer panel indicator component.
|
|
27
|
+
*
|
|
28
|
+
* @param {string} contributionId - Manifest footerPanels id.
|
|
29
|
+
* @param {unknown} component - React indicator component.
|
|
30
|
+
*/
|
|
31
|
+
export function registerContributionIndicator(contributionId, component) {
|
|
32
|
+
indicators.set(contributionId, component);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Stores an optional sidebar section headerActions component.
|
|
37
|
+
*
|
|
38
|
+
* @param {string} contributionId - Manifest sidebarSections id.
|
|
39
|
+
* @param {unknown} component - React headerActions component.
|
|
40
|
+
*/
|
|
41
|
+
export function registerContributionHeaderActions(contributionId, component) {
|
|
42
|
+
headerActions.set(contributionId, component);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Returns a registered contribution component.
|
|
47
|
+
*
|
|
48
|
+
* @param {string} kind - Contribution bucket.
|
|
49
|
+
* @param {string} contributionId - Manifest contributes.* id.
|
|
50
|
+
* @returns {unknown | undefined}
|
|
51
|
+
*/
|
|
52
|
+
export function getContributionComponent(kind, contributionId) {
|
|
53
|
+
return components.get(`${kind}:${contributionId}`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Returns a registered footer panel indicator component.
|
|
58
|
+
*
|
|
59
|
+
* @param {string} contributionId - Manifest footerPanels id.
|
|
60
|
+
* @returns {unknown | undefined}
|
|
61
|
+
*/
|
|
62
|
+
export function getContributionIndicator(contributionId) {
|
|
63
|
+
return indicators.get(contributionId);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Returns a registered sidebar section headerActions component.
|
|
68
|
+
*
|
|
69
|
+
* @param {string} contributionId - Manifest sidebarSections id.
|
|
70
|
+
* @returns {unknown | undefined}
|
|
71
|
+
*/
|
|
72
|
+
export function getContributionHeaderActions(contributionId) {
|
|
73
|
+
return headerActions.get(contributionId);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Clears all stored contribution components for a fresh activation.
|
|
78
|
+
*/
|
|
79
|
+
export function clearContributionRegistry() {
|
|
80
|
+
components.clear();
|
|
81
|
+
indicators.clear();
|
|
82
|
+
headerActions.clear();
|
|
83
|
+
}
|