@dsh-workbench/shared 0.1.5 → 0.1.7

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.
@@ -19,9 +19,19 @@
19
19
  display: inline-flex;
20
20
  align-items: center;
21
21
  gap: var(--wb-len-2);
22
+ color: var(--dsw-alias-label-secondary);
22
23
  text-decoration: none;
23
24
  white-space: nowrap;
24
25
  }
26
+ .wb-longTaskLink:hover,
27
+ .wb-longTaskLink:focus-visible {
28
+ color: var(--dsw-alias-label-primary);
29
+ text-decoration: none;
30
+ }
31
+ .wb-longTaskLink:focus-visible {
32
+ outline: var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
33
+ outline-offset: -2px;
34
+ }
25
35
 
26
36
  .wb-longTaskHeadline {
27
37
  margin: 0;
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 instanceof WorkbenchDataError) {
26
+ if (isDataError(error)) {
27
+ const data = error;
20
28
  return {
21
- code: error.code,
22
- message: error.message,
23
- ...(error.detail === undefined ? {} : { detail: error.detail }),
24
- ...(error.hint === undefined ? {} : { hint: error.hint }),
25
- ...(error.helpUrl === undefined ? {} : { helpUrl: error.helpUrl }),
26
- ...(error.project === undefined ? {} : { project: error.project }),
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dsh-workbench/shared",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "工作台与模块共享的纯代码与契约类型:类型、纯逻辑、哑组件、平台解析。宿主侧的东西从 /host 进(不影响浏览器产物)。",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -19,9 +19,19 @@
19
19
  display: inline-flex;
20
20
  align-items: center;
21
21
  gap: var(--wb-len-2);
22
+ color: var(--dsw-alias-label-secondary);
22
23
  text-decoration: none;
23
24
  white-space: nowrap;
24
25
  }
26
+ .wb-longTaskLink:hover,
27
+ .wb-longTaskLink:focus-visible {
28
+ color: var(--dsw-alias-label-primary);
29
+ text-decoration: none;
30
+ }
31
+ .wb-longTaskLink:focus-visible {
32
+ outline: var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
33
+ outline-offset: -2px;
34
+ }
25
35
 
26
36
  .wb-longTaskHeadline {
27
37
  margin: 0;
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 instanceof WorkbenchDataError) {
42
+ if (isDataError(error)) {
43
+ const data = error as WorkbenchDataError;
34
44
  return {
35
- code: error.code,
36
- message: error.message,
37
- ...(error.detail === undefined ? {} : { detail: error.detail }),
38
- ...(error.hint === undefined ? {} : { hint: error.hint }),
39
- ...(error.helpUrl === undefined ? {} : { helpUrl: error.helpUrl }),
40
- ...(error.project === undefined ? {} : { project: error.project }),
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) };