@mzzsfy/dsh-settings-nav-icons 0.4.0 → 0.4.2

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 CHANGED
@@ -124,3 +124,7 @@ node --test packages/dsh-settings-nav-icons/test/*.test.mjs
124
124
  ## License
125
125
 
126
126
  MIT
127
+
128
+ ## dsh 版本兼容
129
+
130
+ 三版本全部通过:导航图标接管。0.1.6 设置导航 5→6 标签(新增会话归档)属宿主演进,不构成不兼容。
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mzzsfy/dsh-settings-nav-icons",
3
3
  "description": "设置弹窗导航分区与插件市场卡片图标替换:按分区显示文本把回退齿轮换成专属图形,市场卡片头像槽换成插件图标,DOM 观察实现,卸载后重载页面恢复官方图标",
4
- "version": "0.4.0",
4
+ "version": "0.4.2",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
7
7
  "exports": {
package/src/client.js CHANGED
@@ -16,6 +16,8 @@ window.__ModuleLoader__.load({
16
16
  factory(require) {
17
17
  // ---- 官方 DOM 字面量标识(设置弹窗导航,CSS Modules 哈希前缀稳定) ----
18
18
 
19
+ // 注册 id 单点定义:样式 data-plugin 标记与装载归属同源,防字面量双写漂移
20
+ const PLUGIN_ID = '@mzzsfy/dsh-settings-nav-icons'
19
21
  const SELECTOR_CELL = 'button.VOzbGW_navCell'
20
22
  const SELECTOR_LABEL = '.VOzbGW_navLabel'
21
23
  const ATTR_MARK = 'data-navic'
@@ -268,6 +270,8 @@ window.__ModuleLoader__.load({
268
270
 
269
271
  function installOverlayStyle() {
270
272
  overlayStyle = document.createElement('style')
273
+ // 自带 data-plugin:缺失时宿主 claimStyles 会把它归属给后续材质化插件,其 HMR 重建即误删
274
+ overlayStyle.setAttribute('data-plugin', PLUGIN_ID)
271
275
  overlayStyle.textContent = OVERLAY_CSS
272
276
  document.head.appendChild(overlayStyle)
273
277
  if (slot !== null) slot.overlayStyle = overlayStyle
@@ -825,6 +829,8 @@ window.__ModuleLoader__.load({
825
829
 
826
830
  function installScrollStyle() {
827
831
  scrollStyle = document.createElement('style')
832
+ // 自带 data-plugin:缺失时宿主 claimStyles 会把它归属给后续材质化插件,其 HMR 重建即误删
833
+ scrollStyle.setAttribute('data-plugin', PLUGIN_ID)
828
834
  scrollStyle.textContent = NAVLIST_SCROLL_CSS
829
835
  document.head.appendChild(scrollStyle)
830
836
  if (slot !== null) slot.scrollStyle = scrollStyle
@@ -143,6 +143,8 @@ function fakeDocument() {
143
143
  value: '',
144
144
  placeholder: '',
145
145
  innerHTML: '',
146
+ attrs: {},
147
+ setAttribute(name, value) { el.attrs[name] = value },
146
148
  appendChild(child) { el.children.push(child) },
147
149
  focus() { el.focused = true },
148
150
  addEventListener(type, fn) { el.handlers[type] = fn },
@@ -250,6 +252,7 @@ test('启动样式:覆盖浮层样式与滚动样式注入 head,卸载移除,重
250
252
  assert.equal(doc.createdStyles.length, 2, '恰两次注入(浮层+滚动)')
251
253
  assert.ok(doc.createdStyles.some((el) => el.textContent.includes('sni-ov')), '浮层样式随启动注入')
252
254
  assert.ok(doc.createdStyles.some((el) => el.textContent === NAVLIST_SCROLL_CSS), '滚动规则与实现同源')
255
+ assert.ok(doc.createdStyles.every((el) => el.attrs['data-plugin'] === '@mzzsfy/dsh-settings-nav-icons'), '样式自带 data-plugin,防宿主 claimStyles 误归属后随他插件 HMR 整批误删')
253
256
  assert.equal(doc.head.children.length, 2, '样式挂载在 head')
254
257
  assert.deepEqual(doc.events, ['style', 'style', 'observe'], '样式注入先于观察器挂载')
255
258
  unload()