@dsh-workbench/shared 0.3.6 → 0.3.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.
Files changed (136) hide show
  1. package/dist/api/context-ref.d.ts +0 -12
  2. package/dist/api/context-ref.js +0 -40
  3. package/dist/api/facts.d.ts +0 -6
  4. package/dist/api/facts.js +0 -8
  5. package/dist/components/ConfirmBar.css +26 -0
  6. package/dist/components/ConfirmBar.d.ts +36 -0
  7. package/dist/components/ConfirmBar.js +26 -0
  8. package/dist/components/Form.d.ts +7 -5
  9. package/dist/components/Form.js +5 -3
  10. package/dist/components/FormNodes.d.ts +17 -13
  11. package/dist/components/FormNodes.js +13 -5
  12. package/dist/components/FormTypes.d.ts +39 -14
  13. package/dist/components/MockStrip.css +11 -1
  14. package/dist/components/StateDot.d.ts +5 -0
  15. package/dist/components/StateDot.js +10 -0
  16. package/dist/config/constants.d.ts +2 -0
  17. package/dist/config/constants.js +2 -0
  18. package/dist/host/__tests__/fakes.d.ts +41 -0
  19. package/dist/host/__tests__/fakes.js +76 -0
  20. package/dist/host/__tests__/preflight-fixtures.d.ts +19 -0
  21. package/dist/host/__tests__/preflight-fixtures.js +47 -0
  22. package/dist/host/board-fact.d.ts +8 -0
  23. package/dist/host/board-fact.js +16 -0
  24. package/dist/host/browser-read.js +2 -1
  25. package/dist/host/context-inject.d.ts +24 -0
  26. package/dist/host/context-inject.js +74 -0
  27. package/dist/host/context-ref.d.ts +13 -0
  28. package/dist/host/context-ref.js +41 -0
  29. package/dist/host/diy-debug.d.ts +80 -0
  30. package/dist/host/diy-debug.js +88 -0
  31. package/dist/host/diy-record.d.ts +135 -0
  32. package/dist/host/diy-record.js +162 -0
  33. package/dist/host/events.d.ts +9 -0
  34. package/dist/host/events.js +70 -0
  35. package/dist/host/facts.d.ts +6 -0
  36. package/dist/host/facts.js +9 -0
  37. package/dist/host/git.js +1 -1
  38. package/dist/host/http.d.ts +2 -2
  39. package/dist/host/http.js +3 -3
  40. package/dist/host/long-task.d.ts +5 -0
  41. package/dist/host/long-task.js +3 -0
  42. package/dist/host/mount-units.d.ts +52 -0
  43. package/dist/host/mount-units.js +186 -0
  44. package/dist/host/opencli-runtime.js +1 -1
  45. package/dist/host/opencli-window.js +1 -1
  46. package/dist/host/opencli.js +2 -1
  47. package/dist/host/panel-state.d.ts +120 -0
  48. package/dist/host/panel-state.js +176 -0
  49. package/dist/host/plugin-source.js +1 -1
  50. package/dist/host/preflight.d.ts +58 -0
  51. package/dist/host/preflight.js +233 -0
  52. package/dist/host/probe-cache.d.ts +6 -0
  53. package/dist/host/probe-cache.js +19 -0
  54. package/dist/host/probe-libs.d.ts +45 -0
  55. package/dist/host/probe-libs.js +61 -0
  56. package/dist/host/probe-units.d.ts +17 -0
  57. package/dist/host/probe-units.js +102 -0
  58. package/dist/host/probe-verdict.d.ts +7 -0
  59. package/dist/host/probe-verdict.js +143 -0
  60. package/dist/host/shell-text.d.ts +13 -0
  61. package/dist/host/shell-text.js +20 -0
  62. package/dist/host/tool-scope.d.ts +32 -0
  63. package/dist/host/tool-scope.js +84 -0
  64. package/dist/host/unit-declaration.d.ts +65 -0
  65. package/dist/host/unit-declaration.js +213 -0
  66. package/dist/host/unit-readiness.d.ts +7 -0
  67. package/dist/host/unit-readiness.js +5 -0
  68. package/dist/host/unit-registry.d.ts +9 -0
  69. package/dist/host/unit-registry.js +33 -0
  70. package/dist/host/version-range.d.ts +2 -0
  71. package/dist/host/version-range.js +73 -0
  72. package/dist/host.d.ts +7 -4
  73. package/dist/host.js +7 -4
  74. package/dist/i18n/en.js +4 -0
  75. package/dist/i18n/index.d.ts +5 -1
  76. package/dist/i18n/zh.d.ts +4 -0
  77. package/dist/i18n/zh.js +4 -0
  78. package/dist/index.d.ts +1 -4
  79. package/dist/index.js +1 -4
  80. package/dist/lib/board-fact.d.ts +0 -7
  81. package/dist/lib/board-fact.js +0 -15
  82. package/dist/lib/diy-record.d.ts +38 -1
  83. package/dist/lib/diy-record.js +66 -0
  84. package/dist/lib/text.d.ts +0 -13
  85. package/dist/lib/text.js +0 -20
  86. package/dist/testing/declaration.js +1 -1
  87. package/package.json +1 -1
  88. package/src/api/__tests__/facts.test.ts +0 -13
  89. package/src/api/context-ref.ts +0 -39
  90. package/src/api/facts.ts +0 -9
  91. package/src/components/ConfirmBar.css +26 -0
  92. package/src/components/ConfirmBar.test.tsx +130 -0
  93. package/src/components/ConfirmBar.tsx +63 -0
  94. package/src/components/Form.test.tsx +15 -0
  95. package/src/components/Form.tsx +7 -5
  96. package/src/components/FormNodes.tsx +50 -26
  97. package/src/components/FormTypes.test.ts +31 -0
  98. package/src/components/FormTypes.ts +46 -15
  99. package/src/components/FormWiring.test.tsx +1 -0
  100. package/src/config/constants.ts +3 -0
  101. package/src/host/__tests__/board-fact.test.ts +47 -0
  102. package/src/{lib → host/__tests__}/diy-debug.test.ts +1 -1
  103. package/src/{lib → host/__tests__}/diy-record.test.ts +137 -1
  104. package/src/host/__tests__/facts.test.ts +13 -0
  105. package/src/host/__tests__/long-task.test.ts +42 -0
  106. package/src/{lib → host/__tests__}/panel-state.test.ts +1 -1
  107. package/src/host/__tests__/preflight-route.test.ts +33 -0
  108. package/src/host/__tests__/shell-text.test.ts +44 -0
  109. package/src/host/board-fact.ts +14 -0
  110. package/src/host/browser-read.ts +2 -1
  111. package/src/host/context-ref.ts +40 -0
  112. package/src/{lib → host}/diy-record.ts +95 -1
  113. package/src/host/facts.ts +10 -0
  114. package/src/host/git.ts +1 -1
  115. package/src/host/http.ts +4 -4
  116. package/src/host/long-task.ts +9 -0
  117. package/src/host/opencli-runtime.ts +1 -1
  118. package/src/host/opencli-window.ts +1 -1
  119. package/src/host/opencli.ts +2 -1
  120. package/src/host/plugin-source.ts +1 -1
  121. package/src/host/shell-text.ts +21 -0
  122. package/src/{api → host}/unit-declaration.ts +1 -1
  123. package/src/host.ts +7 -4
  124. package/src/i18n/en.ts +4 -0
  125. package/src/i18n/zh.ts +4 -0
  126. package/src/index.ts +1 -4
  127. package/src/lib/board-fact.test.ts +1 -33
  128. package/src/lib/board-fact.ts +0 -13
  129. package/src/lib/text.test.ts +1 -43
  130. package/src/lib/text.ts +0 -22
  131. package/src/testing/declaration.ts +1 -1
  132. package/dist/lib/lint-probe.d.ts +0 -1
  133. package/dist/lib/lint-probe.js +0 -6
  134. /package/src/{api → host}/__tests__/unit-declaration.test.ts +0 -0
  135. /package/src/{lib → host}/diy-debug.ts +0 -0
  136. /package/src/{lib → host}/panel-state.ts +0 -0
@@ -1,47 +1,5 @@
1
- import { execFileSync } from 'node:child_process';
2
1
  import { describe, expect, it } from 'vitest';
3
- import { excerpt, parseJsonLoose, quoteShellArg, tailLines } from './text.js';
4
-
5
- function shellSees(value: string): string {
6
- return execFileSync('/bin/sh', ['-c', `printf '%s' ${quoteShellArg(value)}`], {
7
- encoding: 'utf8',
8
- });
9
- }
10
-
11
- describe('quoteShellArg', () => {
12
- it('普通值原样往返', () => {
13
- expect(shellSees('example-monorepo')).toBe('example-monorepo');
14
- });
15
-
16
- it('含空格的路径不被拆成两个参数', () => {
17
- expect(shellSees('/Volumes/My Projects/app')).toBe('/Volumes/My Projects/app');
18
- });
19
-
20
- it('单引号被正确转义(否则就是注入面)', () => {
21
- expect(shellSees("it's")).toBe("it's");
22
- });
23
-
24
- it('shell 元字符按字面量传递', () => {
25
- for (const raw of ['$(whoami)', '`id`', 'a; rm -rf /', 'a && b', '*', '"double"', '\\n']) {
26
- expect(shellSees(raw), raw).toBe(raw);
27
- }
28
- });
29
- });
30
-
31
- describe('tailLines', () => {
32
- it('取末尾若干行并去掉首尾空行', () => {
33
- expect(tailLines('\n a \n b \n', 2)).toBe('a \n b');
34
- });
35
-
36
- it('行数不够时全给', () => {
37
- expect(tailLines('only', 6)).toBe('only');
38
- });
39
-
40
- it('空输入给空串', () => {
41
- expect(tailLines(undefined, 3)).toBe('');
42
- expect(tailLines(' ', 3)).toBe('');
43
- });
44
- });
2
+ import { excerpt, parseJsonLoose } from './text.js';
45
3
 
46
4
  describe('parseJsonLoose', () => {
47
5
  it('干净 JSON 直接解析', () => {
package/src/lib/text.ts CHANGED
@@ -1,25 +1,3 @@
1
- /**
2
- * 把一个值裹成 shell 里的单引号字面量(值里的单引号一并转义),保证元字符按字面量传递。
3
- * @param value - 任意值;不是字符串的先 `String()`。
4
- * @returns 可安全拼进 `/bin/sh -c` 的一段文本 —— 含空格 / `$()` / `;` / 通配符的值都不会被当成语法。
5
- */
6
- export function quoteShellArg(value: unknown): string {
7
- return `'${String(value).replace(/'/g, `'\\''`)}'`;
8
- }
9
-
10
- /**
11
- * 取一段文本的末尾若干行(如命令输出),顺带去掉首尾空白。
12
- * @param text - 原文;`null` / `undefined` 当空串。
13
- * @param lines - 最多留几行,默认 6;0 给全篇、负数从开头砍掉那么多行(都是 `slice` 语义),调用方传正数。
14
- * @returns 末尾若干行、去首尾空行后的文本;原文行数不够就全给,空输入给空串。
15
- */
16
- export function tailLines(text: string | null | undefined, lines = 6): string {
17
- const all = String(text ?? '')
18
- .trim()
19
- .split('\n');
20
- return all.slice(-lines).join('\n');
21
- }
22
-
23
1
  function candidateStarts(raw: string): number[] {
24
2
  const starts: number[] = [];
25
3
  for (let index = 0; index < raw.length; index += 1) {
@@ -1,7 +1,7 @@
1
1
  import fs from 'node:fs';
2
2
  import { fileURLToPath } from 'node:url';
3
3
  import type { UnitManifest } from '../api/unit.js';
4
- import { readDeclaration } from '../api/unit-declaration.js';
4
+ import { readDeclaration } from '../host/unit-declaration.js';
5
5
 
6
6
  export function declarationOfPackage(pkg: string, packageJson: URL | string): UnitManifest {
7
7
  const at = typeof packageJson === 'string' ? packageJson : fileURLToPath(packageJson);
@@ -1 +0,0 @@
1
- export declare function useLintProbe(): number;
@@ -1,6 +0,0 @@
1
- import { useRef } from './react';
2
- export function useLintProbe() {
3
- const probeRef = useRef(0);
4
- probeRef.current = 1;
5
- return probeRef.current;
6
- }
File without changes
File without changes