dsh-plugin-core 0.10.0 → 0.11.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/README.md +4 -3
- package/dist/explorer/FileBrowser.d.ts.map +1 -1
- package/dist/explorer/FileBrowser.js +3 -2
- package/dist/explorer/FileBrowser.js.map +1 -1
- package/dist/explorer/open.d.ts.map +1 -1
- package/dist/explorer/open.js +7 -3
- package/dist/explorer/open.js.map +1 -1
- package/dist/explorer/preview/BytesPreview.d.ts.map +1 -1
- package/dist/explorer/preview/BytesPreview.js +3 -2
- package/dist/explorer/preview/BytesPreview.js.map +1 -1
- package/dist/explorer/preview/HtmlPreview.d.ts.map +1 -1
- package/dist/explorer/preview/HtmlPreview.js +3 -2
- package/dist/explorer/preview/HtmlPreview.js.map +1 -1
- package/dist/explorer/preview/OfficePreview.d.ts.map +1 -1
- package/dist/explorer/preview/OfficePreview.js +3 -2
- package/dist/explorer/preview/OfficePreview.js.map +1 -1
- package/dist/explorer/preview/TextPreview.d.ts.map +1 -1
- package/dist/explorer/preview/TextPreview.js +3 -2
- package/dist/explorer/preview/TextPreview.js.map +1 -1
- package/dist/session/SessionViewModal.d.ts.map +1 -1
- package/dist/session/SessionViewModal.js +3 -2
- package/dist/session/SessionViewModal.js.map +1 -1
- package/dist/session/mirror/ChatView.d.ts.map +1 -1
- package/dist/session/mirror/ChatView.js +3 -0
- package/dist/session/mirror/ChatView.js.map +1 -1
- package/dist/ui/AlertModal.d.ts.map +1 -1
- package/dist/ui/AlertModal.js +3 -0
- package/dist/ui/AlertModal.js.map +1 -1
- package/dist/ui/BackToTop.d.ts.map +1 -1
- package/dist/ui/BackToTop.js +4 -3
- package/dist/ui/BackToTop.js.map +1 -1
- package/dist/ui/Button.d.ts.map +1 -1
- package/dist/ui/Button.js +4 -3
- package/dist/ui/Button.js.map +1 -1
- package/dist/ui/Card.d.ts.map +1 -1
- package/dist/ui/Card.js +3 -2
- package/dist/ui/Card.js.map +1 -1
- package/dist/ui/Chip.d.ts.map +1 -1
- package/dist/ui/Chip.js +3 -2
- package/dist/ui/Chip.js.map +1 -1
- package/dist/ui/CodeViewer.d.ts.map +1 -1
- package/dist/ui/CodeViewer.js +3 -0
- package/dist/ui/CodeViewer.js.map +1 -1
- package/dist/ui/DateTimePicker.d.ts.map +1 -1
- package/dist/ui/DateTimePicker.js +4 -2
- package/dist/ui/DateTimePicker.js.map +1 -1
- package/dist/ui/Field.d.ts +10 -0
- package/dist/ui/Field.d.ts.map +1 -1
- package/dist/ui/Field.js +5 -4
- package/dist/ui/Field.js.map +1 -1
- package/dist/ui/FieldHint.d.ts.map +1 -1
- package/dist/ui/FieldHint.js +3 -2
- package/dist/ui/FieldHint.js.map +1 -1
- package/dist/ui/Loading.d.ts +17 -0
- package/dist/ui/Loading.d.ts.map +1 -1
- package/dist/ui/Loading.js +8 -7
- package/dist/ui/Loading.js.map +1 -1
- package/dist/ui/MarqueeText.d.ts.map +1 -1
- package/dist/ui/MarqueeText.js +3 -0
- package/dist/ui/MarqueeText.js.map +1 -1
- package/dist/ui/Modal.d.ts.map +1 -1
- package/dist/ui/Modal.js +3 -2
- package/dist/ui/Modal.js.map +1 -1
- package/dist/ui/ModelPicker.d.ts.map +1 -1
- package/dist/ui/ModelPicker.js +3 -2
- package/dist/ui/ModelPicker.js.map +1 -1
- package/dist/ui/PanelDock.d.ts.map +1 -1
- package/dist/ui/PanelDock.js +5 -2
- package/dist/ui/PanelDock.js.map +1 -1
- package/dist/ui/Picker.d.ts.map +1 -1
- package/dist/ui/Picker.js +5 -2
- package/dist/ui/Picker.js.map +1 -1
- package/dist/ui/Segmented.d.ts +24 -0
- package/dist/ui/Segmented.d.ts.map +1 -1
- package/dist/ui/Segmented.js +4 -27
- package/dist/ui/Segmented.js.map +1 -1
- package/dist/ui/SplitGroup.d.ts.map +1 -1
- package/dist/ui/SplitGroup.js +3 -2
- package/dist/ui/SplitGroup.js.map +1 -1
- package/dist/ui/Textarea.d.ts.map +1 -1
- package/dist/ui/Textarea.js +3 -2
- package/dist/ui/Textarea.js.map +1 -1
- package/dist/ui/chip-css.generated.d.ts +1 -1
- package/dist/ui/chip-css.generated.d.ts.map +1 -1
- package/dist/ui/chip-css.generated.js +1 -1
- package/dist/ui/chip-css.generated.js.map +1 -1
- package/dist/ui/controls/segmented-css.generated.d.ts +1 -1
- package/dist/ui/controls/segmented-css.generated.d.ts.map +1 -1
- package/dist/ui/controls/segmented-css.generated.js +1 -1
- package/dist/ui/controls/segmented-css.generated.js.map +1 -1
- package/dist/ui/css.d.ts +28 -5
- package/dist/ui/css.d.ts.map +1 -1
- package/dist/ui/css.js +31 -34
- package/dist/ui/css.js.map +1 -1
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +3 -2
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/loading-host.d.ts +5 -0
- package/dist/ui/loading-host.d.ts.map +1 -1
- package/dist/ui/loading-host.js +8 -0
- package/dist/ui/loading-host.js.map +1 -1
- package/docs/design/architecture.md +9 -5
- package/docs/design/style.md +50 -0
- package/docs/help/integration.doc.ts +2 -2
- package/docs/help/integration.md +2 -2
- package/docs/help/style.md +35 -0
- package/docs/help/ui.doc.ts +5 -4
- package/docs/help/ui.md +5 -4
- package/docs/requirements.md +7 -0
- package/package.json +1 -1
package/dist/ui/css.js
CHANGED
|
@@ -1,38 +1,15 @@
|
|
|
1
1
|
import { createStyleKit } from '../design/index.js';
|
|
2
|
-
import { BACK_TO_TOP_CSS, BUTTON_CSS, DATETIME_CSS, FIELD_CSS, HINT_CSS, LOADING_CSS, SEGMENTED_CSS, SPLIT_GROUP_CSS, } from './controls-css.js';
|
|
3
|
-
import { MARQUEE_CSS } from './marquee-css.js';
|
|
4
|
-
import { PICKER_CSS } from './picker-css.js';
|
|
5
|
-
import { FEEDBACK_CSS } from './feedback-css.js';
|
|
6
|
-
import { CARD_CSS } from './card-css.js';
|
|
7
|
-
import { CHIP_CSS } from './chip-css.js';
|
|
8
|
-
import { CODE_VIEWER_CSS } from './code-viewer-css.js';
|
|
9
|
-
import { PANEL_DOCK_CSS } from './panel-dock-css.js';
|
|
10
|
-
import { EXPLORER_CSS } from '../explorer/explorer-css.js';
|
|
11
|
-
import { SESSION_CSS } from '../session/session-css.js';
|
|
12
|
-
export const CONTROLS_DOMAIN = 'controls';
|
|
13
2
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
3
|
+
* 旧版「控件样式全量域」名。
|
|
4
|
+
*
|
|
5
|
+
* ⚠️ 2026-10-30 起这里**不再**聚合注入全部控件样式:当初是把 17 组 CSS 拼成
|
|
6
|
+
* `CONTROLS_CSS` 一把 `applyStyle(CONTROLS_DOMAIN, …)`,结果 `css.ts` 静态依赖了
|
|
7
|
+
* 每一份 CSS —— 打包器无法摇树,插件只用 Button 也会背上全部 71.7 KB 样式文本。
|
|
8
|
+
* 现在改成每个控件自注入自己那份(见 {@link ensureComponentStyles})。
|
|
9
|
+
*
|
|
10
|
+
* 保留导出只为向后兼容消费方可能引用过它这个常量,值不再参与注入。
|
|
16
11
|
*/
|
|
17
|
-
export const
|
|
18
|
-
SEGMENTED_CSS,
|
|
19
|
-
BUTTON_CSS,
|
|
20
|
-
FIELD_CSS,
|
|
21
|
-
LOADING_CSS,
|
|
22
|
-
BACK_TO_TOP_CSS,
|
|
23
|
-
HINT_CSS,
|
|
24
|
-
PICKER_CSS,
|
|
25
|
-
DATETIME_CSS,
|
|
26
|
-
FEEDBACK_CSS,
|
|
27
|
-
EXPLORER_CSS,
|
|
28
|
-
SESSION_CSS,
|
|
29
|
-
CARD_CSS,
|
|
30
|
-
CHIP_CSS,
|
|
31
|
-
MARQUEE_CSS,
|
|
32
|
-
PANEL_DOCK_CSS,
|
|
33
|
-
CODE_VIEWER_CSS,
|
|
34
|
-
SPLIT_GROUP_CSS,
|
|
35
|
-
].join('\n');
|
|
12
|
+
export const CONTROLS_DOMAIN = 'controls';
|
|
36
13
|
/**
|
|
37
14
|
* 当前插件的样式设施。
|
|
38
15
|
*
|
|
@@ -47,9 +24,29 @@ export function setStyleKit(kit) {
|
|
|
47
24
|
export function getStyleKit() {
|
|
48
25
|
return current;
|
|
49
26
|
}
|
|
50
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* 只登记 token 变量(幂等;不挂载 `<style>`)。
|
|
29
|
+
*
|
|
30
|
+
* 插件启动时调一次做预热是安全的,但**不是必需的** —— 任何控件首次渲染时
|
|
31
|
+
* 也会自行登记 token(见 {@link ensureComponentStyles})。token 域始终排在所有控件域之前
|
|
32
|
+
* (`style-kit.ts` 的 composeCss 强制),所以颜色 / 变量引用链不受拆分影响。
|
|
33
|
+
*/
|
|
51
34
|
export function ensureControls(kit = current) {
|
|
52
35
|
kit.registerStyle('tokens', kit.tokensCss);
|
|
53
|
-
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 确保某个控件自己的样式已登记、且 `<style>` 已挂载(幂等,可直接在 render 里调)。
|
|
39
|
+
*
|
|
40
|
+
* 每个控件**只传自己那份 CSS**:把它依赖的那 1~2 份传进来即可,绝不能顺手把别人的拼上去
|
|
41
|
+
* (一拼就又退化成全量,包体省不下来)。同理,若是某份 CSS 里带上下文限定的修饰
|
|
42
|
+
* (如 `.dshpc-split .dshpc-seg`),那份由提供上下文的控件自己负责,消费者不用管。
|
|
43
|
+
*
|
|
44
|
+
* @param domain 本控件的样式域,repo 内唯一。
|
|
45
|
+
* @param css 该控件自己的 CSS 文本。
|
|
46
|
+
* @param kit 样式设施(默认取当前插件的 kit)。
|
|
47
|
+
*/
|
|
48
|
+
export function ensureComponentStyles(domain, css, kit = current) {
|
|
49
|
+
kit.registerStyle('tokens', kit.tokensCss);
|
|
50
|
+
kit.applyStyle(domain, css);
|
|
54
51
|
}
|
|
55
52
|
//# sourceMappingURL=css.js.map
|
package/dist/ui/css.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css.js","sourceRoot":"","sources":["../../src/ui/css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiB,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"css.js","sourceRoot":"","sources":["../../src/ui/css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiB,MAAM,oBAAoB,CAAA;AAElE;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAAA;AAEzC;;;;;;GAMG;AACH,IAAI,OAAO,GAAa,cAAc,CAAC,EAAE,EAAE,EAAE,oBAAoB,EAAE,CAAC,CAAA;AAEpE,MAAM,UAAU,WAAW,CAAC,GAAa;IACvC,OAAO,GAAG,GAAG,CAAA;AACf,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,OAAO,OAAO,CAAA;AAChB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,MAAgB,OAAO;IACpD,GAAG,CAAC,aAAa,CAAC,QAAQ,EAAE,GAAG,CAAC,SAAS,CAAC,CAAA;AAC5C,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAc,EAAE,GAAW,EAAE,MAAgB,OAAO;IACxF,GAAG,CAAC,aAAa,CAAC,QAAQ,EAAE,GAAG,CAAC,SAAS,CAAC,CAAA;IAC1C,GAAG,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAC7B,CAAC"}
|
package/dist/ui/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACpF,OAAO,EACL,YAAY,EACZ,cAAc,EACd,OAAO,EACP,QAAQ,EACR,oBAAo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EACpB,KAAK,gBAAgB,EACrB,KAAK,cAAc,GACpB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/D,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,kBAAkB,EACvB,KAAK,eAAe,GACrB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/D,OAAO,EAAE,sBAAsB,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAA;AACzE,OAAO,EACL,SAAS,EACT,SAAS,EACT,eAAe,EACf,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,cAAc,GACpB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,aAAa,EACb,SAAS,EACT,WAAW,EACX,WAAW,EACX,MAAM,EACN,SAAS,EACT,WAAW,EACX,aAAa,EACb,KAAK,SAAS,EACd,KAAK,UAAU,GAChB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,KAAK,EACL,WAAW,EACX,aAAa,EACb,cAAc,EACd,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,GACxB,MAAM,YAAY,CAAA"}
|
package/dist/ui/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// ui —— 基础控件(依赖 design)。
|
|
2
|
-
// 使用前:插件启动时 `setStyleKit(createStyleKit({ id }))`
|
|
3
|
-
//
|
|
2
|
+
// 使用前:插件启动时 `setStyleKit(createStyleKit({ id }))` 一次。
|
|
3
|
+
// 控件样式**由各控件自注入**:每个控件只登记自己那份 CSS(幂等),用不到的控件其 CSS 不进包;
|
|
4
|
+
// `ensureControls()` 退化为可选的 token 预热,不再需要调。
|
|
4
5
|
export { CONTROLS_DOMAIN, ensureControls, getStyleKit, setStyleKit } from './css.js';
|
|
5
6
|
export { filterGroups, flattenOptions, groupOf, labelsOf, resolveTriggerSizing, toGroups, toggleValue, } from './picker-logic.js';
|
|
6
7
|
export { Picker } from './Picker.js';
|
package/dist/ui/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,sDAAsD;AACtD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,sDAAsD;AACtD,uDAAuD;AACvD,4CAA4C;AAC5C,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACpF,OAAO,EACL,YAAY,EACZ,cAAc,EACd,OAAO,EACP,QAAQ,EACR,oBAAoB,EACpB,QAAQ,EACR,WAAW,GAGZ,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,MAAM,EAAqC,MAAM,aAAa,CAAA;AACvE,OAAO,EACL,cAAc,GAIf,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,eAAe,EACf,eAAe,EACf,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,UAAU,EACV,aAAa,EACb,OAAO,EACP,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,UAAU,EACV,aAAa,GAQd,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,WAAW,EAAkD,MAAM,kBAAkB,CAAA;AAC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,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,SAAS,EAAuB,MAAM,gBAAgB,CAAA;AAC/D,OAAO,EAAE,sBAAsB,EAAsB,MAAM,cAAc,CAAA;AACzE,OAAO,EACL,SAAS,EACT,SAAS,EACT,eAAe,GAOhB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,aAAa,EACb,SAAS,EACT,WAAW,EACX,WAAW,EACX,MAAM,EACN,SAAS,EACT,WAAW,EACX,aAAa,GAGd,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,KAAK,EACL,WAAW,EACX,aAAa,EACb,cAAc,GAMf,MAAM,YAAY,CAAA"}
|
|
@@ -8,6 +8,11 @@ export type LoadingVariant = 'toast' | 'block';
|
|
|
8
8
|
/** 七向定位:与 Toast 的六向同名,另加 `center`。默认 `bottom-center`。 */
|
|
9
9
|
export type LoadingPosition = 'top-left' | 'top-center' | 'top-right' | 'center' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
10
10
|
/** 浮层定位类名(`center` 走基础规则,不需要修饰类)。 */
|
|
11
|
+
/**
|
|
12
|
+
* 为什么这里要自注入 `LOADING_CSS`:拿这个类名的调用方通常是**自己画**浮层
|
|
13
|
+
* (否则直接渲染 `Loading` 组件即可),那时 core 里没有任何组件被渲染 ⇒ 没人登记这份 CSS
|
|
14
|
+
* ⇒ 浮层会裸奔。类名出口处登记一次,任何拿类名自绘的路径都有样式(幂等)。
|
|
15
|
+
*/
|
|
11
16
|
export declare function loadingOverlayClass(position: LoadingPosition): string;
|
|
12
17
|
export interface LoadingRequest {
|
|
13
18
|
/** 文案;不传走内置字典 `loadingDefault`(数据加载中 / Loading)。 */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loading-host.d.ts","sourceRoot":"","sources":["../../src/ui/loading-host.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE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AI,CAAA;IAClC,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,aAAa,CAAA;CAC7C,CAmBA"}
|
package/dist/ui/loading-host.js
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
// 会在两处各冒一个。这里与 toast-host 同一手法:globalThis 上用 Symbol.for 的单例,
|
|
5
5
|
// 先到场的副本建浮层,其余副本把请求交给它 —— 所有调用落在**同一个屏幕位置**。
|
|
6
6
|
// 纯逻辑、零 DOM / React 依赖 ⇒ Node 单测可直接断言单例语义。
|
|
7
|
+
import { ensureComponentStyles } from './css.js';
|
|
8
|
+
import { LOADING_CSS } from './controls-css.js';
|
|
7
9
|
/** 全局注册表键:Symbol.for 跨 bundle 副本天然共享同一个符号。 */
|
|
8
10
|
export const LOADING_HOST_KEY = Symbol.for('dsh-plugin-core/loading-host');
|
|
9
11
|
/** 全局单例:已注册则直接返回(不触发 create),否则建一个并注册。 */
|
|
@@ -17,7 +19,13 @@ export function claimLoadingHost(create) {
|
|
|
17
19
|
return created;
|
|
18
20
|
}
|
|
19
21
|
/** 浮层定位类名(`center` 走基础规则,不需要修饰类)。 */
|
|
22
|
+
/**
|
|
23
|
+
* 为什么这里要自注入 `LOADING_CSS`:拿这个类名的调用方通常是**自己画**浮层
|
|
24
|
+
* (否则直接渲染 `Loading` 组件即可),那时 core 里没有任何组件被渲染 ⇒ 没人登记这份 CSS
|
|
25
|
+
* ⇒ 浮层会裸奔。类名出口处登记一次,任何拿类名自绘的路径都有样式(幂等)。
|
|
26
|
+
*/
|
|
20
27
|
export function loadingOverlayClass(position) {
|
|
28
|
+
ensureComponentStyles('loading', LOADING_CSS);
|
|
21
29
|
return `dshpc-loading-overlay dshpc-loading-overlay--${position}`;
|
|
22
30
|
}
|
|
23
31
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loading-host.js","sourceRoot":"","sources":["../../src/ui/loading-host.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,EAAE;AACF,o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IAAI,MAAM,GAAG,KAAK,CAAA;YAClB,OAAO;gBACL,KAAK;oBACH,qCAAqC;oBACrC,IAAI,MAAM,IAAI,OAAO,EAAE,EAAE,KAAK,EAAE;wBAAE,OAAM;oBACxC,MAAM,GAAG,IAAI,CAAA;oBACb,OAAO,GAAG,IAAI,CAAA;gBAChB,CAAC;aACF,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -44,8 +44,11 @@ utils(谁都不依赖,谁都可以用)
|
|
|
44
44
|
插件启动 ──▶ setStyleKit(createStyleKit({ id }))
|
|
45
45
|
│
|
|
46
46
|
▼
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
用到的控件首次渲染 ──▶ 自注入自己那份 CSS(幂等)
|
|
48
|
+
│
|
|
49
|
+
▼
|
|
50
|
+
往 <head> 插/更新一个 <style id="{id}">
|
|
51
|
+
内容 = tokens 域 + 各「已用到」的控件域拼成的 CSS 文本
|
|
49
52
|
```
|
|
50
53
|
|
|
51
54
|
为什么必须运行时注入:DSH 客户端产物是 `window.__ModuleLoader__.load({ id, factory })` 的
|
|
@@ -107,7 +110,8 @@ dist/** 产物形态不变,仍由 createStyleKit 拼成一份
|
|
|
107
110
|
|
|
108
111
|
## 触发关系
|
|
109
112
|
|
|
110
|
-
- `setStyleKit()
|
|
111
|
-
-
|
|
112
|
-
|
|
113
|
+
- `setStyleKit()`:插件启动时调一次;不调则走默认 kit(多插件同页会互相覆盖,务必调)。
|
|
114
|
+
- 控件样式**按需**:各控件首次渲染时自注入自己那份 CSS(幂等),没用到的控件其 CSS 不进包。
|
|
115
|
+
`ensureControls()` 现只剩「登记 token」一件事,是可选预热而非必需步骤。
|
|
116
|
+
- 自注入无 `document` 时静默跳过(SSR / 单测不炸)。
|
|
113
117
|
- `showToast()` 无 `document` 时静默跳过。
|
package/docs/design/style.md
CHANGED
|
@@ -17,6 +17,56 @@ What stays here is what you must honour when **changing styles in this repo**.
|
|
|
17
17
|
EN: The client bundle is a CJS closure loaded by `window.__ModuleLoader__.load`, so `import './x.css'` produces a
|
|
18
18
|
separate asset the kernel never loads — CSS must be injected at runtime as a TS string.
|
|
19
19
|
|
|
20
|
+
## 控件样式按需:每个控件只注入自己那份
|
|
21
|
+
|
|
22
|
+
> EN: Per-control styles: every control injects only its own
|
|
23
|
+
|
|
24
|
+
(2026-10-30 起)**注入是按控件的,不是一把全量**:每个控件在 render 里调
|
|
25
|
+
`ensureComponentStyles('<域>', <自己那份 CSS>)`(幂等,每次 render 调都安全),用不到的控件其 CSS
|
|
26
|
+
不进消费方的包 —— 实测只用 `Button` 时样式文本从 71.7 KB 降到 9.4 KB。
|
|
27
|
+
|
|
28
|
+
EN: Injection is per control, not one big blob. Each control calls `ensureComponentStyles('<domain>', <its own CSS>)`
|
|
29
|
+
during render (idempotent); CSS of controls you never use never reaches your bundle.
|
|
30
|
+
|
|
31
|
+
新增控件照做:import 自己那份 `*_CSS` 常量 + 在组件里调一次 `ensureComponentStyles`。
|
|
32
|
+
|
|
33
|
+
1. **不要顺手把别人的 CSS 一起传进去** —— 传了就退化成全量,包体省不下来。
|
|
34
|
+
2. **跨控件的修饰一律用更高特异性表达**(`.dshpc-split .dshpc-seg`),由提供上下文的那个控件
|
|
35
|
+
负责它自己那份;**绝不靠注入顺序** —— 顺序 = 控件首次渲染顺序,不固定。
|
|
36
|
+
有自检盯着:`test/css-contract.test.mjs` 禁止跨常量出现同名选择器(含 `@media` 内)。
|
|
37
|
+
3. **CSS 必须是 `export const X_CSS` 的字符串常量**(被显式引用的值):`package.json` 的
|
|
38
|
+
`sideEffects: false` 既不会误删它、又能让用不到的那份被摇掉。
|
|
39
|
+
**绝不能退回 `import './x.css'`** —— 那是副作用式导入,webpack 官方点名它会在 `sideEffects:false`
|
|
40
|
+
下被连样式一起摇掉(组件渲染出来没样式)。
|
|
41
|
+
|
|
42
|
+
EN: (1) never bundle someone else's CSS into your call; (2) express cross-control overrides with higher
|
|
43
|
+
specificity, never with injection order (order = first-render order, not fixed) — the contract test forbids
|
|
44
|
+
same-name selectors across constants; (3) keep CSS as exported string constants — never go back to
|
|
45
|
+
`import './x.css'`, which `sideEffects:false` would drop along with the styles.
|
|
46
|
+
|
|
47
|
+
### 为什么不用 `@layer` 分层(评估过,有意不做)
|
|
48
|
+
|
|
49
|
+
> EN: Why we deliberately do not use `@layer`
|
|
50
|
+
|
|
51
|
+
`@layer`(CSS Cascading and Inheritance L5,Baseline 2022-03)能让层序显式固定、不受注入时机影响,
|
|
52
|
+
听上去正好治「顺序不确定」。**但它在这里会适得其反**:
|
|
53
|
+
|
|
54
|
+
- **未分层样式压过任何层**:层级裁决优先于特异性。一旦把 dshpc 样式包进 `@layer dshpc`,
|
|
55
|
+
宿主任何**未分层的元素级重置**(`button { font-size: 14px }` 之类)就会反过来压过我们,
|
|
56
|
+
层内特异性再高也没用 ⇒ 控件被宿主皮肤吃掉。
|
|
57
|
+
- **不分层反而更稳**:现状下我们的 `.dshpc-btn`(0,1,0)靠特异性就能压过宿主的 `button`(0,0,1)。
|
|
58
|
+
|
|
59
|
+
所以「不分层」是**有意为之,不是遗漏**。真要分层,必须先把宿主的元素级样式摸清楚;而且只能整套一层
|
|
60
|
+
(`@layer dshpc`),**不能按组件拆层** —— 层间忽略特异性会直接打掉 `.dshpc-split .dshpc-seg` 这类
|
|
61
|
+
靠特异性生效的拼接定制。
|
|
62
|
+
|
|
63
|
+
EN: `@layer` would let layer order be explicit and immune to injection timing, but here it backfires:
|
|
64
|
+
unlayered styles beat anything inside a layer, and layer judgement precedes specificity. Wrapping our styles
|
|
65
|
+
in `@layer dshpc` would let the host's unlayered element resets (`button { font-size }`) override our rules no
|
|
66
|
+
matter how specific they are. Staying unlayered is deliberate — `.dshpc-btn` (0,1,0) already beats the host's
|
|
67
|
+
`button` (0,0,1) on specificity. If layering ever becomes necessary: one layer for the whole kit, never per
|
|
68
|
+
control.
|
|
69
|
+
|
|
20
70
|
## 交互态颜色(hover / active)
|
|
21
71
|
|
|
22
72
|
> EN: Interaction colors (hover / active)
|
|
@@ -4,11 +4,11 @@ import type { DocTopic } from '../design/doc-format.js'
|
|
|
4
4
|
const install = `pnpm add dsh-plugin-core`
|
|
5
5
|
const initStyle = `// 插件 client 入口
|
|
6
6
|
import { createStyleKit } from 'dsh-plugin-core/design'
|
|
7
|
-
import {
|
|
7
|
+
import { setStyleKit } from 'dsh-plugin-core/ui'
|
|
8
8
|
|
|
9
9
|
const kit = createStyleKit({ id: 'dsh-task-reminder-ui' })
|
|
10
10
|
setStyleKit(kit)
|
|
11
|
-
|
|
11
|
+
// 只需这一行:控件首次渲染时自注入自己那份 CSS,token 也一并登记。`
|
|
12
12
|
const useControl = `import { Button, Input, Picker, showToast } from 'dsh-plugin-core/ui'
|
|
13
13
|
|
|
14
14
|
h(Input, { value: name, onChange: setName, placeholder: '任务名', error: nameError })
|
package/docs/help/integration.md
CHANGED
|
@@ -47,11 +47,11 @@ pnpm add dsh-plugin-core
|
|
|
47
47
|
```ts id="integration-init-style"
|
|
48
48
|
// 插件 client 入口
|
|
49
49
|
import { createStyleKit } from 'dsh-plugin-core/design'
|
|
50
|
-
import {
|
|
50
|
+
import { setStyleKit } from 'dsh-plugin-core/ui'
|
|
51
51
|
|
|
52
52
|
const kit = createStyleKit({ id: 'dsh-task-reminder-ui' })
|
|
53
53
|
setStyleKit(kit)
|
|
54
|
-
|
|
54
|
+
// 只需这一行:控件首次渲染时自注入自己那份 CSS,token 也一并登记。
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
```tsx id="integration-use-control"
|
package/docs/help/style.md
CHANGED
|
@@ -78,3 +78,38 @@ or by grepping `tokens-css.ts`.
|
|
|
78
78
|
EN: Reskin by reassigning the same variables inside your own style domain (no fork needed). Add a domain with
|
|
79
79
|
`kit.registerStyle('widget', css)`; re-registering a domain overwrites it. The `tokens` domain always comes
|
|
80
80
|
first — core maintains that ordering. Skin lives in the caller’s domain; components only read tokens.
|
|
81
|
+
|
|
82
|
+
## 怎么应用:样式是按需的
|
|
83
|
+
|
|
84
|
+
> EN: How to apply it: styles are on demand
|
|
85
|
+
|
|
86
|
+
(2026-10-30 起)插件入口**只需 `setStyleKit` 一行**;控件首次渲染时自注入自己那份 CSS(幂等),
|
|
87
|
+
没用到的控件其 CSS 不进你的包。`ensureControls()` 现只登记 token,是**可选**预热,不必再调。
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
import { createStyleKit } from 'dsh-plugin-core/design'
|
|
91
|
+
import { setStyleKit } from 'dsh-plugin-core/ui'
|
|
92
|
+
|
|
93
|
+
setStyleKit(createStyleKit({ id: 'dsh-task-reminder-ui' }))
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
EN: Since 2026-10-30 the entry needs only `setStyleKit`; each control self-injects its own CSS on first render,
|
|
97
|
+
and CSS of controls you never use stays out of your bundle. `ensureControls()` now only registers tokens and is
|
|
98
|
+
optional.
|
|
99
|
+
|
|
100
|
+
## 避免什么
|
|
101
|
+
|
|
102
|
+
> EN: What to avoid
|
|
103
|
+
|
|
104
|
+
1. **不要 `import * as core from 'dsh-plugin-core/ui'` / `require('dsh-plugin-core/ui')`** —— 打包器无法摇树,
|
|
105
|
+
所有控件 CSS 全进你的包(实测差 62.3 KB)。一律**具名导入**。
|
|
106
|
+
2. **不要把多份 CSS 自己拼起来注册成一个域** —— 那等于重建全量注入,按需收益归零。
|
|
107
|
+
要加自己的皮肤,用 `kit.registerStyle('你的域', css)` 单独注册。
|
|
108
|
+
3. **不要写「靠注入顺序才对」的规则** —— 顺序 = 控件首次渲染顺序,不固定。
|
|
109
|
+
要覆盖就用更高特异性(多加一个类限定),跨来源的层次用 `@layer`。
|
|
110
|
+
4. **不要退回 `import './x.css'`** —— 客户端产物是 JS 闭包,`.css` 内核不加载;且在
|
|
111
|
+
`sideEffects: false` 下会被连样式一起摇掉。
|
|
112
|
+
|
|
113
|
+
EN: (1) Never namespace-import or `require` the barrel − it defeats tree-shaking (62.3 KB difference); use named
|
|
114
|
+
imports. (2) Do not concatenate several CSS constants into one domain − that rebuilds full injection. (3) Never
|
|
115
|
+
rely on injection order; override with higher specificity. (4) Never go back to `import './x.css'`.
|
package/docs/help/ui.doc.ts
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
import type { DocTopic } from '../design/doc-format.js'
|
|
3
3
|
|
|
4
4
|
const setup = `import { createStyleKit } from 'dsh-plugin-core/design'
|
|
5
|
-
import {
|
|
5
|
+
import { setStyleKit } from 'dsh-plugin-core/ui'
|
|
6
6
|
|
|
7
7
|
setStyleKit(createStyleKit({ id: 'dsh-task-reminder-ui' }))
|
|
8
|
-
|
|
8
|
+
// 控件样式不用你挂:每个控件首次渲染时自注入自己那份 CSS(幂等),
|
|
9
|
+
// 用不到的控件其 CSS 也不会进你的包。`
|
|
9
10
|
|
|
10
11
|
const cardExample = `import { Card, Chip, StripCard } from 'dsh-plugin-core/ui'
|
|
11
12
|
|
|
@@ -112,8 +113,8 @@ const doc: DocTopic = {
|
|
|
112
113
|
en: 'IconButton: variant plain|outline|danger (default plain), size (default lg), icon (required), label (required, doubles as a11y name and title).',
|
|
113
114
|
},
|
|
114
115
|
{
|
|
115
|
-
zh: 'Segmented:`items`(必填)支持单选 / 多选,`size`(默认 lg;三档总高 24 / 28 / 32)、`bordered`(1px 外框,总高不变)、`multiple`(多选)。外观只有一套:灰底轨道 + 白色选中片,选中片的描边环与阴影由宿主 elevation token 提供(离线兜底值没有那圈环)。选中片配色只经 `tone`:传内置色名(与 Chip 同名的 business / success / warning / danger / purple / pink / cyan / teal / orange / indigo / rose / slate)时底与字由核心定、深浅两主题各自成立;传 `{ bg, fg }` 时两个主题都用调用方这一对颜色(对比度由调用方负责)。段内 `count
|
|
116
|
-
en: 'Segmented: `items` (required) supports single or multiple selection; `size` (default lg; totals 24 / 28 / 32), `bordered` (1px outer frame, same total height), `multiple` (multi-select). One look only: grey track + white selected pill; its stroke ring and shadow come from the host elevation token (the offline fallback has no ring). The selected pill’s colors go through `tone` only: a built-in color name (business / success / warning / danger / purple / pink / cyan / teal / orange / indigo / rose / slate, same names as Chip) lets the core pick background and text per theme; `{ bg, fg }` uses that pair verbatim in both themes (contrast is the caller’s call). An item’s `count` (muted text) and `badge` (red pill) take `number | string`: numbers ≤0 render nothing, strings render as given (e.g. `\'1K\'` / `\'99+\'`).',
|
|
116
|
+
zh: 'Segmented:`items`(必填)支持单选 / 多选,`size`(默认 lg;三档总高 24 / 28 / 32)、`bordered`(1px 外框,总高不变)、`multiple`(多选)。外观只有一套:灰底轨道 + 白色选中片,选中片的描边环与阴影由宿主 elevation token 提供(离线兜底值没有那圈环)。选中片配色只经 `tone`:传内置色名(与 Chip 同名的 business / success / warning / danger / purple / pink / cyan / teal / orange / indigo / rose / slate)时底与字由核心定、深浅两主题各自成立;传 `{ bg, fg }` 时两个主题都用调用方这一对颜色(对比度由调用方负责)。段内 `count`(弱化灰字,选中段内自动跟着选中片字色提亮)/ `badge`(红角标)接受 `number | string`:数字 ≤0 不显示,字符串原样显示(如 `1K` / `99+`)。',
|
|
117
|
+
en: 'Segmented: `items` (required) supports single or multiple selection; `size` (default lg; totals 24 / 28 / 32), `bordered` (1px outer frame, same total height), `multiple` (multi-select). One look only: grey track + white selected pill; its stroke ring and shadow come from the host elevation token (the offline fallback has no ring). The selected pill’s colors go through `tone` only: a built-in color name (business / success / warning / danger / purple / pink / cyan / teal / orange / indigo / rose / slate, same names as Chip) lets the core pick background and text per theme; `{ bg, fg }` uses that pair verbatim in both themes (contrast is the caller’s call). An item’s `count` (muted text; auto-lightened to follow the selected pill’s text color while selected) and `badge` (red pill) take `number | string`: numbers ≤0 render nothing, strings render as given (e.g. `\'1K\'` / `\'99+\'`).',
|
|
117
118
|
},
|
|
118
119
|
],
|
|
119
120
|
api: [
|
package/docs/help/ui.md
CHANGED
|
@@ -24,10 +24,11 @@
|
|
|
24
24
|
|
|
25
25
|
```ts id="ui-setup"
|
|
26
26
|
import { createStyleKit } from 'dsh-plugin-core/design'
|
|
27
|
-
import {
|
|
27
|
+
import { setStyleKit } from 'dsh-plugin-core/ui'
|
|
28
28
|
|
|
29
29
|
setStyleKit(createStyleKit({ id: 'dsh-task-reminder-ui' }))
|
|
30
|
-
|
|
30
|
+
// 控件样式不用你挂:每个控件首次渲染时自注入自己那份 CSS(幂等),
|
|
31
|
+
// 用不到的控件其 CSS 也不会进你的包。
|
|
31
32
|
```
|
|
32
33
|
|
|
33
34
|
## Button / IconButton / Segmented
|
|
@@ -42,9 +43,9 @@ IconButton:variant: plain|outline|danger(默认 plain)、size(默认 lg
|
|
|
42
43
|
|
|
43
44
|
> EN: IconButton: variant plain|outline|danger (default plain), size (default lg), icon (required), label (required, doubles as a11y name and title).
|
|
44
45
|
|
|
45
|
-
Segmented:`items`(必填)支持单选 / 多选,`size`(默认 lg;三档总高 24 / 28 / 32)、`bordered`(1px 外框,总高不变)、`multiple`(多选)。外观只有一套:灰底轨道 + 白色选中片,选中片的描边环与阴影由宿主 elevation token 提供(离线兜底值没有那圈环)。选中片配色只经 `tone`:传内置色名(与 Chip 同名的 business / success / warning / danger / purple / pink / cyan / teal / orange / indigo / rose / slate)时底与字由核心定、深浅两主题各自成立;传 `{ bg, fg }` 时两个主题都用调用方这一对颜色(对比度由调用方负责)。段内 `count
|
|
46
|
+
Segmented:`items`(必填)支持单选 / 多选,`size`(默认 lg;三档总高 24 / 28 / 32)、`bordered`(1px 外框,总高不变)、`multiple`(多选)。外观只有一套:灰底轨道 + 白色选中片,选中片的描边环与阴影由宿主 elevation token 提供(离线兜底值没有那圈环)。选中片配色只经 `tone`:传内置色名(与 Chip 同名的 business / success / warning / danger / purple / pink / cyan / teal / orange / indigo / rose / slate)时底与字由核心定、深浅两主题各自成立;传 `{ bg, fg }` 时两个主题都用调用方这一对颜色(对比度由调用方负责)。段内 `count`(弱化灰字,选中段内自动跟着选中片字色提亮)/ `badge`(红角标)接受 `number | string`:数字 ≤0 不显示,字符串原样显示(如 `1K` / `99+`)。
|
|
46
47
|
|
|
47
|
-
> EN: Segmented: `items` (required) supports single or multiple selection; `size` (default lg; totals 24 / 28 / 32), `bordered` (1px outer frame, same total height), `multiple` (multi-select). One look only: grey track + white selected pill; its stroke ring and shadow come from the host elevation token (the offline fallback has no ring). The selected pill’s colors go through `tone` only: a built-in color name (business / success / warning / danger / purple / pink / cyan / teal / orange / indigo / rose / slate, same names as Chip) lets the core pick background and text per theme; `{ bg, fg }` uses that pair verbatim in both themes (contrast is the caller’s call). An item’s `count` (muted text) and `badge` (red pill) take `number | string`: numbers ≤0 render nothing, strings render as given (e.g. `'1K'` / `'99+'`).
|
|
48
|
+
> EN: Segmented: `items` (required) supports single or multiple selection; `size` (default lg; totals 24 / 28 / 32), `bordered` (1px outer frame, same total height), `multiple` (multi-select). One look only: grey track + white selected pill; its stroke ring and shadow come from the host elevation token (the offline fallback has no ring). The selected pill’s colors go through `tone` only: a built-in color name (business / success / warning / danger / purple / pink / cyan / teal / orange / indigo / rose / slate, same names as Chip) lets the core pick background and text per theme; `{ bg, fg }` uses that pair verbatim in both themes (contrast is the caller’s call). An item’s `count` (muted text; auto-lightened to follow the selected pill’s text color while selected) and `badge` (red pill) take `number | string`: numbers ≤0 render nothing, strings render as given (e.g. `'1K'` / `'99+'`).
|
|
48
49
|
|
|
49
50
|
| 参数 | 类型 | 默认 | 说明(zh) | 说明(en) |
|
|
50
51
|
|---|---|---|---|---|
|
package/docs/requirements.md
CHANGED
|
@@ -120,6 +120,12 @@ dsh-plugin-core/
|
|
|
120
120
|
|
|
121
121
|
⇒ 必须是 `createStyleKit({ id })`:每个插件调一次领一套自己的(`<style>` 标签 id 按插件唯一)。
|
|
122
122
|
|
|
123
|
+
**(2026-10-30)注入按控件粒度**:每个控件自注入自己那份 CSS(`ensureComponentStyles(domain, css)`,幂等),
|
|
124
|
+
**不许再聚合成一把全量**。全量聚合会让入口模块静态依赖所有 CSS,打包器无法摇树 —— 插件只用 Button 也会
|
|
125
|
+
背上全部 71.7 KB 样式文本。`ensureControls()` 因此收敛为「只登记 token」的可选预热。
|
|
126
|
+
配套约束:消费方须**具名导入**(`import * as` / CJS `require` 会让按需收益归零);跨控件修饰只许用
|
|
127
|
+
更高特异性表达,不许依赖注入顺序。
|
|
128
|
+
|
|
123
129
|
### 5.3 明暗色判据(别跟错)
|
|
124
130
|
|
|
125
131
|
- 判据 = **`body[data-ds-dark-theme]`**(宿主启动脚本 `toggleAttribute` 写入,
|
|
@@ -175,6 +181,7 @@ dsh-plugin-core/
|
|
|
175
181
|
| v2 | `explorer`(用户拍板要抽) | ✅ 已完成(浏览面板 + 预览;**选择器后移至 ui**,见 §2.4) |
|
|
176
182
|
| v2+ | `explorer` 重做(2026-10-20) | ✅ 已完成(FileBrowser 面板 + `openFilePreview` / `pickWorkspaceFile` 两能力 + 全量预览:md / 代码高亮 / HTML / PDF / Office;官方件经 `./ui/official` 子路径) |
|
|
177
183
|
| v3 | `session` | ⚠️ **半完成**:契约与三种承载已好,**官方会话 UI 镜像未搬**(只做最简渲染) |
|
|
184
|
+
| v3+ | 控件样式按需注入(2026-10-30) | ✅ 已完成(`css.ts` 停全量聚合;27 个组件各自注入自己那份;只 `import { Button }` 时 CSS 文本 71.7 KB → 9.4 KB。**不采用 `@layer`**:未分层样式压过任何层且层级裁决优先于特异性,包进层会被宿主元素级重置反压) |
|
|
178
185
|
| 文档 | README 接入指南 | ✅ 已完成 |
|
|
179
186
|
|
|
180
187
|
**未做**(按重要性):消费者插件接入 / 会话 UI 镜像 / 类名隔离 /
|
package/package.json
CHANGED