@dsh-workbench/shared 0.1.4 → 0.1.6
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/CardHead.js +3 -3
- package/dist/host/http.js +15 -7
- package/dist/lib/ui.d.ts +0 -6
- package/dist/lib/ui.js +0 -6
- package/package.json +1 -1
- package/src/components/CardHead.tsx +3 -3
- package/src/host/http.ts +17 -7
- package/src/lib/ui.ts +0 -7
|
@@ -6,11 +6,11 @@ export function CardHead({ t, title, meta, refreshing, onRefresh, gear, gearOpen
|
|
|
6
6
|
return (h("header", { className: "wb-cardHead" },
|
|
7
7
|
h("h2", { className: "wb-cardTitle" }, title),
|
|
8
8
|
meta === undefined ? null : h("span", { className: "wb-cardMeta" }, meta),
|
|
9
|
-
platformHref === undefined || platform === undefined ? null : (h(Tooltip, { label: platformTitle ?? platform },
|
|
9
|
+
platformHref === undefined || platform === undefined ? null : (h(Tooltip, { side: "bottom", align: "end", gap: 6, portal: true, label: platformTitle ?? platform },
|
|
10
10
|
h("a", { className: "wb-iconButton wb-cardOpen", href: platformHref, target: "_blank", rel: "noreferrer noopener", "aria-label": platform },
|
|
11
11
|
h(IconRightUpOutlineRegular, { size: 14 })))),
|
|
12
|
-
h(Tooltip, { label: refreshLabel },
|
|
12
|
+
h(Tooltip, { side: "bottom", align: "end", gap: 6, portal: true, label: refreshLabel },
|
|
13
13
|
h(Button, { type: "button", size: "sm", variant: "ghost", className: `wb-cardRefresh${refreshing ? ' wb-spinning' : ''}`, "aria-label": refreshLabel, disabled: refreshing, icon: h(IconRefreshOutlineRegular, { size: 14 }), onClick: onRefresh })),
|
|
14
|
-
gear === undefined || onToggleGear === undefined ? null : (h(Tooltip, { label: gear },
|
|
14
|
+
gear === undefined || onToggleGear === undefined ? null : (h(Tooltip, { side: "bottom", align: "end", gap: 6, portal: true, label: gear },
|
|
15
15
|
h(Button, { type: "button", size: "sm", variant: "ghost", className: `wb-cardGear${gearOpen === true ? ' wb-iconButtonActive' : ''}`, "aria-label": gear, "aria-expanded": gearOpen === true, icon: h(IconSettingsOutlineRegular, { size: 15 }), onClick: onToggleGear })))));
|
|
16
16
|
}
|
package/dist/host/http.js
CHANGED
|
@@ -15,15 +15,23 @@ function sendJson(res, status, body) {
|
|
|
15
15
|
res.setHeader('cache-control', 'no-store');
|
|
16
16
|
res.end(JSON.stringify(body));
|
|
17
17
|
}
|
|
18
|
+
function isDataError(error) {
|
|
19
|
+
if (error instanceof WorkbenchDataError)
|
|
20
|
+
return true;
|
|
21
|
+
return (error instanceof Error &&
|
|
22
|
+
error.name === 'WorkbenchDataError' &&
|
|
23
|
+
typeof error.code === 'string');
|
|
24
|
+
}
|
|
18
25
|
function toErrorPayload(error) {
|
|
19
|
-
if (error
|
|
26
|
+
if (isDataError(error)) {
|
|
27
|
+
const data = error;
|
|
20
28
|
return {
|
|
21
|
-
code:
|
|
22
|
-
message:
|
|
23
|
-
...(
|
|
24
|
-
...(
|
|
25
|
-
...(
|
|
26
|
-
...(
|
|
29
|
+
code: data.code,
|
|
30
|
+
message: data.message,
|
|
31
|
+
...(data.detail === undefined ? {} : { detail: data.detail }),
|
|
32
|
+
...(data.hint === undefined ? {} : { hint: data.hint }),
|
|
33
|
+
...(data.helpUrl === undefined ? {} : { helpUrl: data.helpUrl }),
|
|
34
|
+
...(data.project === undefined ? {} : { project: data.project }),
|
|
27
35
|
};
|
|
28
36
|
}
|
|
29
37
|
return { code: 'internal', message: error instanceof Error ? error.message : String(error) };
|
package/dist/lib/ui.d.ts
CHANGED
|
@@ -2,10 +2,4 @@ export declare function cx(...parts: Array<string | false | null | undefined>):
|
|
|
2
2
|
export type TimeTranslate = (key: string, params?: Record<string, unknown>) => string;
|
|
3
3
|
export declare function relativeTime(epochMs: number, t: TimeTranslate): string;
|
|
4
4
|
export declare function shortenPath(path: unknown): string;
|
|
5
|
-
export declare const LINK_BUTTON_STYLE: {
|
|
6
|
-
readonly display: "inline-flex";
|
|
7
|
-
readonly alignItems: "center";
|
|
8
|
-
readonly gap: "var(--wb-gap-xs)";
|
|
9
|
-
readonly textDecoration: "none";
|
|
10
|
-
};
|
|
11
5
|
export declare function parseLocalTimestamp(text: string | null | undefined): number;
|
package/dist/lib/ui.js
CHANGED
|
@@ -22,12 +22,6 @@ export function shortenPath(path) {
|
|
|
22
22
|
const hit = path.match(/^\/Users\/[^/]+/);
|
|
23
23
|
return hit === null ? path : path.replace(hit[0], '~');
|
|
24
24
|
}
|
|
25
|
-
export const LINK_BUTTON_STYLE = {
|
|
26
|
-
display: 'inline-flex',
|
|
27
|
-
alignItems: 'center',
|
|
28
|
-
gap: 'var(--wb-gap-xs)',
|
|
29
|
-
textDecoration: 'none',
|
|
30
|
-
};
|
|
31
25
|
const LOCAL_TIMESTAMP = /^(\d{4})-(\d{2})-(\d{2})[ T](\d{2}):(\d{2}):(\d{2})$/;
|
|
32
26
|
export function parseLocalTimestamp(text) {
|
|
33
27
|
const raw = String(text ?? '').trim();
|
package/package.json
CHANGED
|
@@ -43,7 +43,7 @@ export function CardHead({
|
|
|
43
43
|
<h2 className="wb-cardTitle">{title}</h2>
|
|
44
44
|
{meta === undefined ? null : <span className="wb-cardMeta">{meta}</span>}
|
|
45
45
|
{platformHref === undefined || platform === undefined ? null : (
|
|
46
|
-
<Tooltip label={platformTitle ?? platform}>
|
|
46
|
+
<Tooltip side="bottom" align="end" gap={6} portal label={platformTitle ?? platform}>
|
|
47
47
|
<a
|
|
48
48
|
className="wb-iconButton wb-cardOpen"
|
|
49
49
|
href={platformHref}
|
|
@@ -55,7 +55,7 @@ export function CardHead({
|
|
|
55
55
|
</a>
|
|
56
56
|
</Tooltip>
|
|
57
57
|
)}
|
|
58
|
-
<Tooltip label={refreshLabel}>
|
|
58
|
+
<Tooltip side="bottom" align="end" gap={6} portal label={refreshLabel}>
|
|
59
59
|
<Button
|
|
60
60
|
type="button"
|
|
61
61
|
size="sm"
|
|
@@ -68,7 +68,7 @@ export function CardHead({
|
|
|
68
68
|
/>
|
|
69
69
|
</Tooltip>
|
|
70
70
|
{gear === undefined || onToggleGear === undefined ? null : (
|
|
71
|
-
<Tooltip label={gear}>
|
|
71
|
+
<Tooltip side="bottom" align="end" gap={6} portal label={gear}>
|
|
72
72
|
<Button
|
|
73
73
|
type="button"
|
|
74
74
|
size="sm"
|
package/src/host/http.ts
CHANGED
|
@@ -29,15 +29,25 @@ function sendJson(res: DshResponse, status: number, body: unknown): void {
|
|
|
29
29
|
res.end(JSON.stringify(body));
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
function isDataError(error: unknown): boolean {
|
|
33
|
+
if (error instanceof WorkbenchDataError) return true;
|
|
34
|
+
return (
|
|
35
|
+
error instanceof Error &&
|
|
36
|
+
error.name === 'WorkbenchDataError' &&
|
|
37
|
+
typeof (error as { code?: unknown }).code === 'string'
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
32
41
|
function toErrorPayload(error: unknown): Record<string, unknown> {
|
|
33
|
-
if (error
|
|
42
|
+
if (isDataError(error)) {
|
|
43
|
+
const data = error as WorkbenchDataError;
|
|
34
44
|
return {
|
|
35
|
-
code:
|
|
36
|
-
message:
|
|
37
|
-
...(
|
|
38
|
-
...(
|
|
39
|
-
...(
|
|
40
|
-
...(
|
|
45
|
+
code: data.code,
|
|
46
|
+
message: data.message,
|
|
47
|
+
...(data.detail === undefined ? {} : { detail: data.detail }),
|
|
48
|
+
...(data.hint === undefined ? {} : { hint: data.hint }),
|
|
49
|
+
...(data.helpUrl === undefined ? {} : { helpUrl: data.helpUrl }),
|
|
50
|
+
...(data.project === undefined ? {} : { project: data.project }),
|
|
41
51
|
};
|
|
42
52
|
}
|
|
43
53
|
return { code: 'internal', message: error instanceof Error ? error.message : String(error) };
|
package/src/lib/ui.ts
CHANGED
|
@@ -22,13 +22,6 @@ export function shortenPath(path: unknown): string {
|
|
|
22
22
|
return hit === null ? path : path.replace(hit[0], '~');
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export const LINK_BUTTON_STYLE = {
|
|
26
|
-
display: 'inline-flex',
|
|
27
|
-
alignItems: 'center',
|
|
28
|
-
gap: 'var(--wb-gap-xs)',
|
|
29
|
-
textDecoration: 'none',
|
|
30
|
-
} as const;
|
|
31
|
-
|
|
32
25
|
const LOCAL_TIMESTAMP = /^(\d{4})-(\d{2})-(\d{2})[ T](\d{2}):(\d{2}):(\d{2})$/;
|
|
33
26
|
|
|
34
27
|
export function parseLocalTimestamp(text: string | null | undefined): number {
|