@dsh-plus/web-cache-headers 0.1.8 → 0.1.10
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/lib/client.js +46 -35
- package/lib/index.d.ts +4 -4
- package/lib/index.js +5 -5
- package/package.json +2 -2
- package/src/config.ts +4 -4
- package/src/index.ts +2 -2
- package/src/ns.ts +2 -2
package/lib/client.js
CHANGED
|
@@ -7,6 +7,42 @@ window.__ModuleLoader__.load({
|
|
|
7
7
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
8
|
let react = require("react");
|
|
9
9
|
require("@deepseek-ai/dsh-client-ui-primitives");
|
|
10
|
+
//#region ../shared/src/client/fields.tsx
|
|
11
|
+
/** 卡片按钮(与 CardChrome 页脚同一套类名与视觉)。 */
|
|
12
|
+
function Button(props) {
|
|
13
|
+
const p = props.prefix ?? "dshp";
|
|
14
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
15
|
+
type: "button",
|
|
16
|
+
className: `${p}-btn ${props.variant === "primary" ? `${p}-btnPrimary` : `${p}-btnGhost`}`,
|
|
17
|
+
disabled: props.disabled === true,
|
|
18
|
+
onClick: props.onClick,
|
|
19
|
+
children: props.label
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 勾选行:自绘圆角扁平开关(switch),对齐官方 WebUI 无原生 checkbox 的
|
|
24
|
+
* 设计语言(官方选择类控件全走胶囊/菜单,见 cardCss 的 -switch 规则)。
|
|
25
|
+
* 语义保持 checkbox(无障碍树与表单语义不变),视觉自绘。
|
|
26
|
+
*/
|
|
27
|
+
function CheckRow(props) {
|
|
28
|
+
const p = props.prefix ?? "dshp";
|
|
29
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
30
|
+
className: `${p}-checkRow`,
|
|
31
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
32
|
+
id: props.id,
|
|
33
|
+
type: "checkbox",
|
|
34
|
+
role: "switch",
|
|
35
|
+
"aria-checked": props.checked,
|
|
36
|
+
checked: props.checked,
|
|
37
|
+
disabled: props.disabled === true,
|
|
38
|
+
onChange: (event) => props.onEdit(event.target.checked)
|
|
39
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
40
|
+
htmlFor: props.id,
|
|
41
|
+
children: props.label
|
|
42
|
+
})]
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
10
46
|
//#region ../shared/src/client/card.tsx
|
|
11
47
|
const IDLE_STATUS = {
|
|
12
48
|
kind: "idle",
|
|
@@ -55,12 +91,12 @@ window.__ModuleLoader__.load({
|
|
|
55
91
|
className: `${p}-status${props.status.kind === "error" ? ` ${p}-statusError` : ""}`,
|
|
56
92
|
role: "status",
|
|
57
93
|
children: props.status.text
|
|
58
|
-
}) : null, props.actions.map((action) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
94
|
+
}) : null, props.actions.map((action) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
95
|
+
prefix: p,
|
|
96
|
+
label: action.label,
|
|
97
|
+
variant: action.variant,
|
|
98
|
+
disabled: action.disabled,
|
|
99
|
+
onClick: action.onClick
|
|
64
100
|
}, action.key))]
|
|
65
101
|
})
|
|
66
102
|
]
|
|
@@ -181,31 +217,6 @@ window.__ModuleLoader__.load({
|
|
|
181
217
|
};
|
|
182
218
|
}
|
|
183
219
|
//#endregion
|
|
184
|
-
//#region ../shared/src/client/fields.tsx
|
|
185
|
-
/**
|
|
186
|
-
* 勾选行:自绘圆角扁平开关(switch),对齐官方 WebUI 无原生 checkbox 的
|
|
187
|
-
* 设计语言(官方选择类控件全走胶囊/菜单,见 cardCss 的 -switch 规则)。
|
|
188
|
-
* 语义保持 checkbox(无障碍树与表单语义不变),视觉自绘。
|
|
189
|
-
*/
|
|
190
|
-
function CheckRow(props) {
|
|
191
|
-
const p = props.prefix ?? "dshp";
|
|
192
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
193
|
-
className: `${p}-checkRow`,
|
|
194
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
195
|
-
id: props.id,
|
|
196
|
-
type: "checkbox",
|
|
197
|
-
role: "switch",
|
|
198
|
-
"aria-checked": props.checked,
|
|
199
|
-
checked: props.checked,
|
|
200
|
-
disabled: props.disabled === true,
|
|
201
|
-
onChange: (event) => props.onEdit(event.target.checked)
|
|
202
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
203
|
-
htmlFor: props.id,
|
|
204
|
-
children: props.label
|
|
205
|
-
})]
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
//#endregion
|
|
209
220
|
//#region ../shared/src/client/i18n.ts
|
|
210
221
|
/** 卡片通用文案(save/discard/unsaved/loading 等四插件共有键)。 */
|
|
211
222
|
const commonZh = {
|
|
@@ -215,7 +226,7 @@ window.__ModuleLoader__.load({
|
|
|
215
226
|
unsaved: "未保存",
|
|
216
227
|
loading: "加载中…",
|
|
217
228
|
unavailable: "配置服务不可用。",
|
|
218
|
-
readOnly: "当前部署无 settings provider
|
|
229
|
+
readOnly: "当前部署无 settings provider,配置为只读;请在 profile 的 cordis.patch.yml 行级配置。",
|
|
219
230
|
invalidNumber: "请输入正整数。",
|
|
220
231
|
collapse: "收起",
|
|
221
232
|
expand: "展开",
|
|
@@ -232,7 +243,7 @@ window.__ModuleLoader__.load({
|
|
|
232
243
|
unsaved: "Unsaved",
|
|
233
244
|
loading: "Loading…",
|
|
234
245
|
unavailable: "Settings service unavailable.",
|
|
235
|
-
readOnly: "No settings provider in this deployment; config is read-only.
|
|
246
|
+
readOnly: "No settings provider in this deployment; config is read-only. Configure it at the profile row in cordis.patch.yml.",
|
|
236
247
|
invalidNumber: "Enter a positive integer.",
|
|
237
248
|
collapse: "Collapse",
|
|
238
249
|
expand: "Expand",
|
|
@@ -439,8 +450,8 @@ ${extra}
|
|
|
439
450
|
//#region src/ns.ts
|
|
440
451
|
/**
|
|
441
452
|
* settings 命名空间字面量(纯常量,零依赖)。
|
|
442
|
-
* 服务端以字面量注册 settings section(用户层配置落
|
|
443
|
-
*
|
|
453
|
+
* 服务端以字面量注册 settings section(用户层配置落 profile 行级覆盖层
|
|
454
|
+
* cordis.patch.yml,热生效);与行级 cordis Config 共用同一份 schema。
|
|
444
455
|
* @module @dsh-plus/web-cache-headers/ns
|
|
445
456
|
*/
|
|
446
457
|
const SETTINGS_NS = "dsh-plus-web-cache-headers";
|
package/lib/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
|
7
7
|
}>>, Schemastery.ObjectT<NoInfer<{
|
|
8
8
|
enabled: z<boolean, boolean, "volatile-defined">;
|
|
9
9
|
}>>, "plain">;
|
|
10
|
-
/** 活动字段形态(
|
|
10
|
+
/** 活动字段形态(loader 解析产物:volatile 字段为活动引用)。 */
|
|
11
11
|
type WebCacheHeadersConfigFields = Schemastery.TypeT<typeof Config>;
|
|
12
12
|
/** 平面配置形态(消费面的读取形态,由活动引用解包得到)。 */
|
|
13
13
|
type WebCacheHeadersConfig = UnwrapVolatile<WebCacheHeadersConfigFields>;
|
|
@@ -15,8 +15,8 @@ type WebCacheHeadersConfig = UnwrapVolatile<WebCacheHeadersConfigFields>;
|
|
|
15
15
|
//#region src/ns.d.ts
|
|
16
16
|
/**
|
|
17
17
|
* settings 命名空间字面量(纯常量,零依赖)。
|
|
18
|
-
* 服务端以字面量注册 settings section(用户层配置落
|
|
19
|
-
*
|
|
18
|
+
* 服务端以字面量注册 settings section(用户层配置落 profile 行级覆盖层
|
|
19
|
+
* cordis.patch.yml,热生效);与行级 cordis Config 共用同一份 schema。
|
|
20
20
|
* @module @dsh-plus/web-cache-headers/ns
|
|
21
21
|
*/
|
|
22
22
|
declare const SETTINGS_NS = "dsh-plus-web-cache-headers";
|
|
@@ -24,7 +24,7 @@ declare const SETTINGS_NS = "dsh-plus-web-cache-headers";
|
|
|
24
24
|
//#region src/index.d.ts
|
|
25
25
|
declare const name = "dsh-plus-web-cache-headers";
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* 装配补丁并接线配置源:配置为 loader 解析的 volatile 活动字段
|
|
28
28
|
* (用户层 override 并入行级 config,写入原位提交),enabled 翻转即时装/卸
|
|
29
29
|
* 补丁,无需 /reload;插件 dispose(profile 卸载 / live reload)保证卸下。
|
|
30
30
|
* @param ctx - 宿主上下文。
|
package/lib/index.js
CHANGED
|
@@ -88,8 +88,8 @@ function uninstallImmutableAssetsPatch() {
|
|
|
88
88
|
* 插件配置(schemastery):可调参数一律外部化,不在逻辑里硬编码。
|
|
89
89
|
*
|
|
90
90
|
* 与仓库既有约定一致:Config 由 cordis 行级 config 解析,部署方可在
|
|
91
|
-
* profile 的 cordis.patch.yml 覆盖;同时经 settings namespace
|
|
92
|
-
*
|
|
91
|
+
* profile 的 cordis.patch.yml 覆盖;同时经 settings namespace 暴露到用户层
|
|
92
|
+
* (同一 profile 行级覆盖层),修改热生效(无需 /reload)。
|
|
93
93
|
* @module @dsh-plus/web-cache-headers/config
|
|
94
94
|
*/
|
|
95
95
|
const Config = z.object({ enabled: z.boolean().description("总开关(false = 卸下补丁,响应头恢复 dsh 原生行为);development 环境恒禁用以保护 dev/HMR").default(true).volatile() });
|
|
@@ -97,8 +97,8 @@ const Config = z.object({ enabled: z.boolean().description("总开关(false =
|
|
|
97
97
|
//#region src/ns.ts
|
|
98
98
|
/**
|
|
99
99
|
* settings 命名空间字面量(纯常量,零依赖)。
|
|
100
|
-
* 服务端以字面量注册 settings section(用户层配置落
|
|
101
|
-
*
|
|
100
|
+
* 服务端以字面量注册 settings section(用户层配置落 profile 行级覆盖层
|
|
101
|
+
* cordis.patch.yml,热生效);与行级 cordis Config 共用同一份 schema。
|
|
102
102
|
* @module @dsh-plus/web-cache-headers/ns
|
|
103
103
|
*/
|
|
104
104
|
const SETTINGS_NS = "dsh-plus-web-cache-headers";
|
|
@@ -106,7 +106,7 @@ const SETTINGS_NS = "dsh-plus-web-cache-headers";
|
|
|
106
106
|
//#region src/index.ts
|
|
107
107
|
const name = "dsh-plus-web-cache-headers";
|
|
108
108
|
/**
|
|
109
|
-
*
|
|
109
|
+
* 装配补丁并接线配置源:配置为 loader 解析的 volatile 活动字段
|
|
110
110
|
* (用户层 override 并入行级 config,写入原位提交),enabled 翻转即时装/卸
|
|
111
111
|
* 补丁,无需 /reload;插件 dispose(profile 卸载 / live reload)保证卸下。
|
|
112
112
|
* @param ctx - 宿主上下文。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dsh-plus/web-cache-headers",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "dsh-plus service plugin: GUI 静态资源长缓存——为内容哈希的 /assets/* 响应补 `Cache-Control: immutable`(/plugins 官方已自带),消除每次刷新重复传输 ~1.4MB JS/CSS;进程级 writeHead 增量拦截,零路由注册、零 dsh 服务耦合,已有缓存头优先保证未来共存",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@dsh-plus/shared": "0.1.
|
|
34
|
+
"@dsh-plus/shared": "0.1.36"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@deepseek-ai/cordis": "^4.0.5-alpha.1",
|
package/src/config.ts
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* 插件配置(schemastery):可调参数一律外部化,不在逻辑里硬编码。
|
|
3
3
|
*
|
|
4
4
|
* 与仓库既有约定一致:Config 由 cordis 行级 config 解析,部署方可在
|
|
5
|
-
* profile 的 cordis.patch.yml 覆盖;同时经 settings namespace
|
|
6
|
-
*
|
|
5
|
+
* profile 的 cordis.patch.yml 覆盖;同时经 settings namespace 暴露到用户层
|
|
6
|
+
* (同一 profile 行级覆盖层),修改热生效(无需 /reload)。
|
|
7
7
|
* @module @dsh-plus/web-cache-headers/config
|
|
8
8
|
*/
|
|
9
9
|
import z from '@deepseek-ai/schemastery'
|
|
10
10
|
import type { UnwrapVolatile } from '@dsh-plus/shared'
|
|
11
11
|
|
|
12
|
-
//
|
|
12
|
+
// `.volatile()` 使条目进入 settings describe 视图(卡片可读写)并让
|
|
13
13
|
// loader 以活动引用原位提交热更新。
|
|
14
14
|
export const Config = z.object({
|
|
15
15
|
enabled: z
|
|
@@ -21,7 +21,7 @@ export const Config = z.object({
|
|
|
21
21
|
.volatile(),
|
|
22
22
|
})
|
|
23
23
|
|
|
24
|
-
/** 活动字段形态(
|
|
24
|
+
/** 活动字段形态(loader 解析产物:volatile 字段为活动引用)。 */
|
|
25
25
|
export type WebCacheHeadersConfigFields = Schemastery.TypeT<typeof Config>
|
|
26
26
|
/** 平面配置形态(消费面的读取形态,由活动引用解包得到)。 */
|
|
27
27
|
export type WebCacheHeadersConfig = UnwrapVolatile<WebCacheHeadersConfigFields>
|
package/src/index.ts
CHANGED
|
@@ -37,7 +37,7 @@ export { SETTINGS_NS } from './ns.ts'
|
|
|
37
37
|
export type { WebCacheHeadersConfig }
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* 装配补丁并接线配置源:配置为 loader 解析的 volatile 活动字段
|
|
41
41
|
* (用户层 override 并入行级 config,写入原位提交),enabled 翻转即时装/卸
|
|
42
42
|
* 补丁,无需 /reload;插件 dispose(profile 卸载 / live reload)保证卸下。
|
|
43
43
|
* @param ctx - 宿主上下文。
|
|
@@ -64,7 +64,7 @@ export function apply(
|
|
|
64
64
|
)
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
//
|
|
67
|
+
// 活动引用原位提交(替代已删除的 setSource/onChange):每次读现取平面快照,
|
|
68
68
|
// volatile 提交事件驱动 enabled 翻转装卸。
|
|
69
69
|
const current = (): WebCacheHeadersConfig => unwrapVolatile(config)
|
|
70
70
|
ctx.events.on('loader/volatile-update', () => sync(current().enabled))
|
package/src/ns.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* settings 命名空间字面量(纯常量,零依赖)。
|
|
3
|
-
* 服务端以字面量注册 settings section(用户层配置落
|
|
4
|
-
*
|
|
3
|
+
* 服务端以字面量注册 settings section(用户层配置落 profile 行级覆盖层
|
|
4
|
+
* cordis.patch.yml,热生效);与行级 cordis Config 共用同一份 schema。
|
|
5
5
|
* @module @dsh-plus/web-cache-headers/ns
|
|
6
6
|
*/
|
|
7
7
|
export const SETTINGS_NS = 'dsh-plus-web-cache-headers'
|