@dsh-workbench/module-tools 0.3.10 → 1.0.0-beta.0
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/LICENSE +21 -0
- package/README.md +223 -177
- package/bin/dsh-wb-module.mjs +89 -34
- package/package.json +18 -3
- package/src/arch.mjs +158 -129
- package/src/build.mjs +6 -30
- package/src/changelog.mjs +167 -0
- package/src/check-flags.mjs +0 -7
- package/src/check.mjs +115 -53
- package/src/checks/alias.mjs +0 -9
- package/src/checks/arch.mjs +3 -25
- package/src/checks/bundles.mjs +2 -34
- package/src/checks/cards.mjs +26 -30
- package/src/checks/contracts.mjs +61 -222
- package/src/checks/kit.mjs +2 -42
- package/src/checks/lint.mjs +9 -82
- package/src/checks/markers.mjs +48 -17
- package/src/checks/primitives.mjs +0 -39
- package/src/checks/protocol.mjs +0 -18
- package/src/checks/source.mjs +163 -29
- package/src/checks/standalone.mjs +4 -14
- package/src/checks/style.mjs +71 -241
- package/src/css-injection.mjs +0 -11
- package/src/css-shell.mjs +3 -31
- package/src/datasource-file.mjs +104 -0
- package/src/declared-tools.mjs +0 -24
- package/src/design.mjs +116 -38
- package/src/discover.mjs +2 -10
- package/src/font-scale.mjs +1 -61
- package/src/init.mjs +2 -17
- package/src/lint.mjs +24 -144
- package/src/market-index.mjs +569 -0
- package/src/market-init.mjs +80 -0
- package/src/primitives-surface.mjs +2 -28
- package/src/publish.mjs +6 -24
- package/src/release-changelog.mjs +29 -0
- package/src/release-journal.mjs +131 -0
- package/src/release-report.mjs +99 -0
- package/src/release-util.mjs +80 -0
- package/src/release.mjs +1251 -0
- package/src/seed.mjs +0 -25
- package/src/shell-type-files.mjs +3 -30
- package/src/sync.mjs +41 -24
- package/template/AGENTS.md.tpl +33 -0
- package/template/CHANGELOG.md.tpl +7 -0
- package/template/README.md.tpl +6 -33
- package/template/package.json.tpl +2 -2
- package/template/src/client.tsx.tpl +1 -18
- package/template/src/host.ts.tpl +2 -15
- package/template/types/globals.d.ts +1 -14
- package/template-diy/AGENTS.md.tpl +33 -0
- package/template-diy/CHANGELOG.md.tpl +7 -0
- package/template-diy/README.md.tpl +4 -133
- package/template-diy/package.json.tpl +2 -2
- package/template-diy/src/client.tsx.tpl +1 -29
- package/template-diy/src/host.ts.tpl +1 -15
- package/template-diy/src/messages.ts.tpl +4 -4
- package/template-diy/src/plugin.test.ts.tpl +1 -1
- package/template-diy/types/globals.d.ts +1 -14
- package/template-diy/types/styles.d.ts +0 -10
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readdirSync, statSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
+
import type { HostContext, UnitModuleFace, UnitRegistry } from '@dsh-workbench/core/contract';
|
|
3
4
|
import type { OverviewFile, OverviewPayload } from './model/overview';
|
|
4
5
|
|
|
5
6
|
const UNIT_ID = '__UNIT__';
|
|
@@ -43,21 +44,6 @@ function limitOf(search: URLSearchParams): number {
|
|
|
43
44
|
return Math.min(MAX_LIMIT, Math.max(1, Math.trunc(parsed)));
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
interface UnitModuleFace {
|
|
47
|
-
readonly unit: string;
|
|
48
|
-
mount(): { routes: Record<string, RouteHandler>; registerTools(): Array<() => void> };
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
interface UnitRegistry {
|
|
52
|
-
register(face: UnitModuleFace): () => void;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
interface HostContext {
|
|
56
|
-
get<T = unknown>(name: string): T | undefined;
|
|
57
|
-
effect(effect: () => void | (() => void), label?: string): () => void;
|
|
58
|
-
logger?: { warn?(message: string): void } | undefined;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
47
|
const face: UnitModuleFace = {
|
|
62
48
|
unit: UNIT_ID,
|
|
63
49
|
mount: () => ({
|
|
@@ -3,9 +3,9 @@ export const messages = {
|
|
|
3
3
|
'__UNIT__.cardTitle': '目录概览',
|
|
4
4
|
'__UNIT__.needProject': '先打开一个项目',
|
|
5
5
|
'__UNIT__.loading': '正在读目录…',
|
|
6
|
-
'__UNIT__.loadingHint': '
|
|
6
|
+
'__UNIT__.loadingHint': '正在统计文件数、目录数与最大的几个文件',
|
|
7
7
|
'__UNIT__.errorTitle': '读不到这个目录',
|
|
8
|
-
'__UNIT__.errorHint': '
|
|
8
|
+
'__UNIT__.errorHint': '先确认这个目录还在、你也能读它,然后点右上角刷新重试',
|
|
9
9
|
'__UNIT__.empty': '这个目录是空的:没有文件,也没有子目录',
|
|
10
10
|
'__UNIT__.largest': '最大的几个文件',
|
|
11
11
|
'__UNIT__.fileUnit': ' 个文件',
|
|
@@ -15,9 +15,9 @@ export const messages = {
|
|
|
15
15
|
'__UNIT__.cardTitle': 'Directory overview',
|
|
16
16
|
'__UNIT__.needProject': 'Open a project first',
|
|
17
17
|
'__UNIT__.loading': 'Reading the directory…',
|
|
18
|
-
'__UNIT__.loadingHint': '
|
|
18
|
+
'__UNIT__.loadingHint': 'Counting files, folders, and the largest files',
|
|
19
19
|
'__UNIT__.errorTitle': 'Cannot read this directory',
|
|
20
|
-
'__UNIT__.errorHint': '
|
|
20
|
+
'__UNIT__.errorHint': 'Check that the folder still exists and you can read it, then hit refresh in the header',
|
|
21
21
|
'__UNIT__.empty': 'This directory is empty: no files and no subdirectories',
|
|
22
22
|
'__UNIT__.largest': 'Largest files',
|
|
23
23
|
'__UNIT__.fileUnit': ' files',
|
|
@@ -131,7 +131,7 @@ describe('宿主侧的只读路由', () => {
|
|
|
131
131
|
expect(answer.bytes).toBe(160);
|
|
132
132
|
expect(answer.largest.map((file) => file.name)).toEqual(['big.bin', 'mid.log']);
|
|
133
133
|
expect(answer.largest[0]?.bytes).toBe(100);
|
|
134
|
-
expect(
|
|
134
|
+
expect(answer.largest[0]?.mtime).toMatch(/^\d{4}-\d{2}-\d{2}T/);
|
|
135
135
|
});
|
|
136
136
|
|
|
137
137
|
it('limit 由查询参数管,越界会夹住', async () => {
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 浏览器半侧的运行时垫片。
|
|
3
|
-
*
|
|
4
|
-
* dsh 的客户端模块格式是 `window.__ModuleLoader__.load({ id, factory(require) })`,
|
|
5
|
-
* 所以 `require` 不来自模块系统,而是宿主给的作用域。
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* React 19 的 `@types/react` 移除了全局 `JSX` 命名空间,而本工程用的是
|
|
10
|
-
* **经典 JSX 运行时**(`jsxFactory: "h"`):`react/jsx-runtime` 不在浏览器模块表里,
|
|
11
|
-
* 所以不能切到自动运行时。这里把全局命名空间接到 `React.JSX` 上 —— 这是官方迁移说明
|
|
12
|
-
* 给经典运行时的做法,写完 JSX 就有完整类型,产出仍是 `h(...)`。
|
|
13
|
-
*/
|
|
14
1
|
import type * as ReactTypes from 'react';
|
|
15
2
|
|
|
16
3
|
declare global {
|
|
@@ -18,7 +5,7 @@ declare global {
|
|
|
18
5
|
interface Element extends ReactTypes.JSX.Element {}
|
|
19
6
|
interface ElementClass extends ReactTypes.JSX.ElementClass {}
|
|
20
7
|
interface IntrinsicElements extends ReactTypes.JSX.IntrinsicElements {}
|
|
21
|
-
|
|
8
|
+
|
|
22
9
|
type ElementType = ReactTypes.JSX.ElementType;
|
|
23
10
|
interface IntrinsicAttributes extends ReactTypes.JSX.IntrinsicAttributes {}
|
|
24
11
|
interface ElementAttributesProperty extends ReactTypes.JSX.ElementAttributesProperty {}
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 组件样式(CSS Modules)的类名表。
|
|
3
|
-
*
|
|
4
|
-
* 构建时类名会被哈希,`import styles from './X.module.css'` 拿到的是**表**而不是文本
|
|
5
|
-
* (构建让它进产物里的那份内联样式);少了这条声明,`styles.xxx` 会被当成 string 的属性,
|
|
6
|
-
* `pnpm typecheck` 直接红。
|
|
7
|
-
*
|
|
8
|
-
* 单独一个文件:`types/globals.d.ts` 里有 import,是模块,里面的 `declare module`
|
|
9
|
-
* 会变成模块增强而不是环境声明 —— 与外壳 `packages/workbench/types/assets.d.ts` 同一个理由。
|
|
10
|
-
*/
|
|
11
1
|
declare module '*.module.css' {
|
|
12
2
|
const classes: Record<string, string>;
|
|
13
3
|
export default classes;
|