dsh-deck-touch 0.2.0 → 0.2.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.1
4
+
5
+ - Android WebView(UA 含 `; wv)`)里不再自持手势:宿主壳通常有自己的手势/返回实现,避免两边同时接一次滑动。
6
+ - 识别 dsh-mobile-apk 一类壳的旧返回契约(`window.__dshBack` / `__dshBackDepth`),见到就让路。
7
+ - 新增 `tabs` 配置(默认 true):设 false 可关掉“滑动切 tab”,只保留页面返回/侧栏行为。
8
+ - 新增对应单测。
9
+
3
10
  ## 0.2.0
4
11
 
5
12
  - 不再只等宿主调用:新增 hostBack / history / gestures 三个输入适配器,装到任意 DSH 网页壳都能生效。
package/README.en.md CHANGED
@@ -54,9 +54,23 @@ You can also disable self-managed gestures with data-deck-touch-gestures="off" o
54
54
  - dsh-mobile-apk keeps its own drawer gestures; the plugin steps aside and only wraps Back. Drags inside its settings sheet are still handled by that shell.
55
55
  - Trackpad two-finger swipes in desktop browsers are browser back/forward; not taken over by default. Set gestures: true to use mouse drags.
56
56
  - Browser back interception (browserBack: 'trap') is off by default; when enabled it consumes one back and closes the current layer.
57
+ - Inside Android WebViews (UA containing `wv`) the plugin leaves gestures to the host shell and only exposes `DeckShellNav`/`__deckTouch`; use `tabs: false` or `gestures: true` to override.
57
58
 
58
- ## Development
59
+ ## Release
60
+
61
+ npm version patch # or minor / major; bumps package.json and creates the tag
62
+ git push origin main --follow-tags
63
+
64
+ Pushing the tag runs tests, checks that the tag matches package.json, publishes to npm with provenance, and creates a GitHub release.
65
+
66
+ With npm staged publishing enabled, the version waits in the stage queue for a 2FA approval:
59
67
 
68
+ npm stage list
69
+ npm stage approve <stage-id>
70
+
71
+ Turn staged publishing off for the package to publish directly; npm is removing 2FA-bypass tokens for direct publishing, so this repo uses a Trusted Publisher (OIDC) setup.
72
+
73
+ ## Development
60
74
  npm test
61
75
 
62
76
  Apache-2.0
package/README.md CHANGED
@@ -54,7 +54,22 @@ Deck 与其它 DSH 壳(走 npm):
54
54
  - dsh-mobile-apk 自带抽屉手势,插件会让路,只接管返回键;设置弹窗内的拖动仍由它处理。
55
55
  - 桌面浏览器的双指手势是浏览器前进/后退,默认不接管;需要时设 gestures: true 用鼠标拖动。
56
56
  - 浏览器返回键拦截(browserBack: 'trap')默认关闭,开启后会吞掉一次返回并关闭当前层。
57
+ - Android WebView 壳(UA 含 `wv`)里插件会把手势让给宿主,自己只提供 `DeckShellNav`/`__deckTouch` 接口;需要时可以设 `tabs: false` 或 `gestures: true`。
57
58
 
59
+
60
+ ## 发版
61
+
62
+ npm version patch # 或 minor / major,改 package.json 并打 tag
63
+ git push origin main --follow-tags
64
+
65
+ 推 tag 后 GitHub Actions 会跑测试、校验 tag 与 package.json 一致、发布 npm(带 provenance),并创建 GitHub Release。
66
+
67
+ npm 账号开启 staged publishing 时,版本先进暂存队列,需要 2FA 批准:
68
+
69
+ npm stage list
70
+ npm stage approve <stage-id>
71
+
72
+ 在 npm 包设置里关掉 staged publishing 后即可全自动上线;npm 正在移除用绕过 2FA 的令牌直接发布的做法,推荐用 Trusted Publisher(OIDC),本仓库的 workflow 已按该方式配置。
58
73
  ## 开发
59
74
 
60
75
  npm test
package/lib/client.js CHANGED
@@ -19,7 +19,7 @@ window.__ModuleLoader__.load({id:`dsh-deck-touch`,factory:require=>{
19
19
  const inject = [];
20
20
 
21
21
  const CONTRACT_VERSION = '1';
22
- const PLUGIN_VERSION = '0.2.0';
22
+ const PLUGIN_VERSION = '0.2.1';
23
23
 
24
24
  // ---- config:宿主可在加载前用 window.__deckTouchConfig 覆盖,读一次后冻结 ----
25
25
 
@@ -31,6 +31,7 @@ window.__ModuleLoader__.load({id:`dsh-deck-touch`,factory:require=>{
31
31
  function readConfig() {
32
32
  const config = {
33
33
  gestures: 'auto',
34
+ tabs: true,
34
35
  back: true,
35
36
  browserBack: 'off',
36
37
  selectors: { tabs: DEFAULT_SELECTORS.tabs, settings: DEFAULT_SELECTORS.settings },
@@ -43,6 +44,7 @@ window.__ModuleLoader__.load({id:`dsh-deck-touch`,factory:require=>{
43
44
  }
44
45
  if (raw && typeof raw === 'object') {
45
46
  if (raw.gestures === true || raw.gestures === false || raw.gestures === 'auto') config.gestures = raw.gestures;
47
+ if (typeof raw.tabs === 'boolean') config.tabs = raw.tabs;
46
48
  if (typeof raw.back === 'boolean') config.back = raw.back;
47
49
  if (raw.browserBack === 'trap' || raw.browserBack === 'off') config.browserBack = raw.browserBack;
48
50
  if (raw.selectors && typeof raw.selectors === 'object') {
@@ -91,6 +93,7 @@ window.__ModuleLoader__.load({id:`dsh-deck-touch`,factory:require=>{
91
93
 
92
94
  /** 最靠上的可见 tab 组:ARIA tabs 优先,设置弹窗的 nav 兜底。 */
93
95
  function visibleTabs() {
96
+ if (!CONFIG.tabs) return null;
94
97
  const lists = queryAll(CONFIG.selectors.tabs);
95
98
  let best = null;
96
99
  for (let i = 0; i < lists.length; i += 1) {
@@ -499,6 +502,12 @@ window.__ModuleLoader__.load({id:`dsh-deck-touch`,factory:require=>{
499
502
  // Deck 的 deck-shell.js 会在页面注入 window.DeckShell;见到它就说明有原生手势。
500
503
  if (window.DeckShell && typeof window.DeckShell === 'object') return true;
501
504
  if (typeof window.__dshNavigationBack === 'function') return true;
505
+ // dsh-mobile-apk 一类壳的页面返回栈(旧契约同样说明宿主自己管手势)。
506
+ if (typeof window.__dshBack === 'function') return true;
507
+ if (typeof window.__dshBackDepth === 'number') return true;
508
+ // Android WebView:宿主壳几乎都有自己的手势/返回实现,自动让路。
509
+ if (typeof navigator !== 'undefined' && typeof navigator.userAgent === 'string' &&
510
+ /;\s*wv[);]/.test(navigator.userAgent)) return true;
502
511
  } catch (error) {
503
512
  return true;
504
513
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-deck-touch",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "DSH Deck touch navigation: swipe/back routing for the Deck WebShell",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",