vue-screenfull 1.1.1 → 1.1.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
@@ -8,38 +8,33 @@
8
8
  [license-image]: https://img.shields.io/npm/l/vue-screenfull.svg
9
9
  [license-url]: https://github.com/chengchuu/vue-screenfull/blob/main/LICENSE
10
10
 
11
- Reactive, strongly typed, and SSR-safe fullscreen utilities for Vue 3, with an optional CSS
12
- pseudo-fullscreen fallback.
11
+ `vue-screenfull` provides reactive, strongly typed fullscreen controls for Vue 3, with SSR-safe
12
+ imports and an optional CSS fallback when native arbitrary-element fullscreen is unavailable.
13
13
 
14
14
  - [Project website](https://chengchuu.github.io/vue-screenfull/)
15
15
  - [Live playground](https://chengchuu.github.io/vue-screenfull/playground/)
16
16
  - [API documentation](https://chengchuu.github.io/vue-screenfull/api/)
17
17
 
18
- ## Features
19
-
20
- - Reactive Composition API state with automatic scope cleanup.
21
- - Standard, WebKit, Mozilla, and Microsoft-prefixed API detection.
22
- - Vue template refs, component refs, elements, and safe CSS selectors.
23
- - Structured results and actionable errors instead of swallowed rejections.
24
- - Renderless component, directive, optional plugin, and framework-neutral controller.
25
-
26
18
  ## Installation
27
19
 
20
+ Install the package in a Vue 3.3 or later project:
21
+
28
22
  ```bash
29
23
  npm install vue-screenfull
30
24
  ```
31
25
 
32
- `lib/vue-screenfull.min.js` exposes `VUE_SCREENFULL` and requires the global `Vue`. Although Vue is
33
- an optional peer dependency, package-root imports still require Vue 3 at runtime.
26
+ `vue-screenfull` provides the Vue composables, component, directive, and plugin, and requires Vue 3
27
+ at runtime. Vue remains an optional peer dependency so `vue-screenfull/browser` can run without it.
28
+ The browser IIFE, `lib/vue-screenfull.min.js`, exposes `VUE_SCREENFULL` and expects a global `Vue`.
34
29
 
35
30
  ## Basic Usage
36
31
 
37
32
  ```vue
38
33
  <script setup lang="ts">
39
- import { useTemplateRef } from "vue";
34
+ import { ref } from "vue";
40
35
  import { useScreenfull } from "vue-screenfull";
41
36
 
42
- const target = useTemplateRef<HTMLElement>("target");
37
+ const target = ref<HTMLElement | null>(null);
43
38
  const { isEnabled, isFullscreen, error, toggle } = useScreenfull();
44
39
  </script>
45
40
 
@@ -61,9 +56,10 @@ require transient user activation and can reject a request even when `isEnabled.
61
56
 
62
57
  ```vue
63
58
  <script setup lang="ts">
64
- import { useTemplateRef } from "vue";
59
+ import { ref } from "vue";
65
60
  import { useScreenfullTarget } from "vue-screenfull";
66
- const panel = useTemplateRef<HTMLElement>("panel");
61
+
62
+ const panel = ref<HTMLElement | null>(null);
67
63
  const { request, isFullscreen } = useScreenfullTarget(panel);
68
64
  </script>
69
65
  <template>
@@ -85,8 +81,10 @@ const result = await toggle(target, { navigationUI: "hide" });
85
81
  if (!result.ok) console.warn(result.error.code, result.error.suggestion);
86
82
  ```
87
83
 
88
- For image content, pass the image template ref. For a video, pass an `HTMLVideoElement` ref.
89
- Some mobile browsers offer video-only fullscreen independently of arbitrary-element fullscreen.
84
+ For image content, pass the image template ref. An `HTMLVideoElement` is also a valid target. If a
85
+ video presentation needs custom controls, target a wrapper that contains both the video and those
86
+ controls so they remain available in native or fallback fullscreen. Some mobile browsers offer
87
+ browser-managed video fullscreen independently of arbitrary-element fullscreen.
90
88
 
91
89
  ## Exit Fullscreen
92
90
 
@@ -94,9 +92,9 @@ Some mobile browsers offer video-only fullscreen independently of arbitrary-elem
94
92
  <button type="button" @click="exit">Exit fullscreen</button>
95
93
  ```
96
94
 
97
- Always include a visible exit button, particularly when fallback is enabled. Escape often exits
98
- fullscreen, but its browser behavior cannot be overridden reliably. Native change events reflect
99
- exits initiated through the browser UI.
95
+ Keep a visible exit button inside the fullscreen target, particularly when fallback is enabled.
96
+ Escape often exits fullscreen, but its browser behavior cannot be overridden reliably. Native
97
+ change events reflect exits initiated through the browser UI.
100
98
 
101
99
  ## Check Support
102
100
 
@@ -121,8 +119,8 @@ if (!result.ok) {
121
119
  }
122
120
  ```
123
121
 
124
- Errors distinguish unsupported/SSR environments, invalid or detached targets, user activation,
125
- permissions and iframe policy, pending transitions, native request/exit failures, and fallback
122
+ Errors distinguish unsupported or SSR environments, invalid or detached targets, user activation,
123
+ permissions, iframe policy, pending transitions, native request or exit failures, and fallback
126
124
  failures. `error` keeps the last error until `clearError()` is called.
127
125
 
128
126
  ## CSS Fallback
@@ -160,15 +158,17 @@ cleanup.
160
158
  v-slot="screenfull"
161
159
  @error="report"
162
160
  >
163
- <button type="button" @click="screenfull.toggle()">
164
- {{ screenfull.isFullscreen ? "Exit" : "Open article" }}
165
- </button>
166
- <button v-if="screenfull.isFullscreen" type="button" @click="screenfull.exit">Exit</button>
161
+ <article id="article">
162
+ <button type="button" @click="screenfull.toggle()">
163
+ {{ screenfull.isFullscreen.value ? "Exit" : "Open article" }}
164
+ </button>
165
+ </article>
167
166
  </Screenfull>
168
167
  ```
169
168
 
170
169
  The renderless component emits `change`, `enter`, `exit`, `error`, and `fallback`. Its default slot
171
- receives all composable refs and actions without imposing a visual system.
170
+ receives all composable refs and actions without imposing a visual system. Because `screenfull` is a
171
+ scoped-slot object, access its nested refs with `.value`.
172
172
 
173
173
  ## Directive Usage
174
174
 
@@ -467,8 +467,6 @@ so deployable website changes can be detected without precaching unversioned bun
467
467
 
468
468
  ## Development
469
469
 
470
- Node.js 22 is used in CI.
471
-
472
470
  ```bash
473
471
  npm install
474
472
  npm run typecheck
package/README.zh-CN.md CHANGED
@@ -8,31 +8,28 @@
8
8
  [license-image]: https://img.shields.io/npm/l/vue-screenfull.svg
9
9
  [license-url]: https://github.com/chengchuu/vue-screenfull/blob/main/LICENSE
10
10
 
11
- 专为 Vue 3 设计的响应式、强类型且支持 SSR 的全屏工具。
12
- 还提供可选的 CSS 伪全屏回退方案。
11
+ `vue-screenfull` 为 Vue 3 提供响应式、强类型的全屏控制。在服务端渲染
12
+ (Server-Side Rendering,SSR) 期间也可以安全导入该软件包。原生任意元素全屏不可用时,可以启用
13
+ CSS 伪全屏回退方案。
13
14
 
14
15
  - [项目网站](https://chengchuu.github.io/vue-screenfull/)
15
16
  - [在线演练场](https://chengchuu.github.io/vue-screenfull/playground/)
16
17
  - [API 文档](https://chengchuu.github.io/vue-screenfull/api/)
17
18
 
18
- ## 功能特性
19
-
20
- - 响应式 Composition API 状态,支持自动清理作用域。
21
- - 检测标准 API。
22
- - 检测带 WebKit、Mozilla、Microsoft 前缀的 API。
23
- - 支持 Vue 模板引用、组件引用、元素和安全的 CSS 选择器。
24
- - 返回结构化结果和可操作的错误,不会静默忽略 Promise 拒绝。
25
- - 提供无渲染组件、指令、可选插件和框架无关的控制器。
26
- - 提供适用于 npm、浏览器原生模块和经典脚本的无 Vue 浏览器入口。
27
- - 提供 CJS、ESM、浏览器 IIFE、源映射和类型声明。
28
-
29
19
  ## 安装
30
20
 
21
+ 在 Vue 3.3 或更高版本的项目中安装软件包:
22
+
31
23
  ```bash
32
24
  npm install vue-screenfull
33
25
  ```
34
26
 
35
- 浏览器包为 `lib/vue-screenfull.min.js`。它会暴露 `VUE_SCREENFULL`,并要求通过全局变量 `Vue` 访问 Vue。Vue 只在软件包安装层面标记为可选。通过软件包根入口导入 API 时,运行时仍需要 Vue 3。
27
+ 软件包根入口 `vue-screenfull` 提供 Vue 组合式函数、组件、指令和插件。该入口在运行时需要
28
+ Vue 3。Vue 被标记为可选的对等依赖,因此只使用框架无关入口 `vue-screenfull/browser` 的项目
29
+ 无需安装 Vue。
30
+
31
+ 默认浏览器 IIFE 位于 `lib/vue-screenfull.min.js`。它会暴露 `VUE_SCREENFULL`,并要求通过全局
32
+ 变量 `Vue` 访问 Vue。
36
33
 
37
34
  ### 无 Vue 浏览器入口
38
35
 
@@ -113,10 +110,10 @@ async function dispose() {
113
110
 
114
111
  ```vue
115
112
  <script setup lang="ts">
116
- import { useTemplateRef } from "vue";
113
+ import { ref } from "vue";
117
114
  import { useScreenfull } from "vue-screenfull";
118
115
 
119
- const target = useTemplateRef<HTMLElement>("target");
116
+ const target = ref<HTMLElement | null>(null);
120
117
  const { isEnabled, isFullscreen, error, toggle } = useScreenfull();
121
118
  </script>
122
119
 
@@ -137,9 +134,10 @@ const { isEnabled, isFullscreen, error, toggle } = useScreenfull();
137
134
 
138
135
  ```vue
139
136
  <script setup lang="ts">
140
- import { useTemplateRef } from "vue";
137
+ import { ref } from "vue";
141
138
  import { useScreenfullTarget } from "vue-screenfull";
142
- const panel = useTemplateRef<HTMLElement>("panel");
139
+
140
+ const panel = ref<HTMLElement | null>(null);
143
141
  const { request, isFullscreen } = useScreenfullTarget(panel);
144
142
  </script>
145
143
  <template>
@@ -159,7 +157,9 @@ const result = await toggle(target, { navigationUI: "hide" });
159
157
  if (!result.ok) console.warn(result.error.code, result.error.suggestion);
160
158
  ```
161
159
 
162
- 对于图片内容,请传入图片的模板引用。对于视频,请传入 `HTMLVideoElement` 引用。部分移动浏览器提供仅限视频的全屏功能,与任意元素全屏相互独立。
160
+ 对于图片内容,请传入图片的模板引用。`HTMLVideoElement` 也是有效目标。如果视频演示需要自定义
161
+ 控件,请将视频及其控件放入同一个容器,并将该容器设为目标。这样可以确保原生或回退全屏模式下
162
+ 仍能使用这些控件。部分移动浏览器提供由浏览器管理的视频全屏功能,该功能与任意元素全屏相互独立。
163
163
 
164
164
  ## 退出全屏
165
165
 
@@ -167,7 +167,7 @@ if (!result.ok) console.warn(result.error.code, result.error.suggestion);
167
167
  <button type="button" @click="exit">Exit fullscreen</button>
168
168
  ```
169
169
 
170
- 请始终提供可见的退出按钮,启用回退方案时尤其如此。Escape 键通常可以退出,但无法可靠地覆盖浏览器的 Escape 键行为。通过浏览器界面发起的退出操作会由原生变更事件反映。
170
+ 请在全屏目标内保留可见的退出按钮,启用回退方案时尤其如此。Escape 键通常可以退出,但无法可靠地覆盖浏览器的 Escape 键行为。通过浏览器界面发起的退出操作会由原生变更事件反映。
171
171
 
172
172
  ## 检查支持情况
173
173
 
@@ -224,14 +224,17 @@ CSS 回退方案会将 `HTMLElement` 固定到可视视口。它会保留自身
224
224
  v-slot="screenfull"
225
225
  @error="report"
226
226
  >
227
- <button type="button" @click="screenfull.toggle()">
228
- {{ screenfull.isFullscreen ? "Exit" : "Open article" }}
229
- </button>
230
- <button v-if="screenfull.isFullscreen" type="button" @click="screenfull.exit">Exit</button>
227
+ <article id="article">
228
+ <button type="button" @click="screenfull.toggle()">
229
+ {{ screenfull.isFullscreen.value ? "Exit" : "Open article" }}
230
+ </button>
231
+ </article>
231
232
  </Screenfull>
232
233
  ```
233
234
 
234
- 无渲染组件会触发 `change`、`enter`、`exit`、`error` 和 `fallback` 事件。其默认插槽接收组合式函数的所有引用和操作。组件不会施加任何视觉样式。
235
+ 无渲染组件会触发 `change`、`enter`、`exit`、`error` 和 `fallback` 事件。其默认插槽接收组合式
236
+ 函数的所有引用和操作。组件不会施加任何视觉样式。`screenfull` 是作用域插槽对象,因此需要使用
237
+ `.value` 访问其中嵌套的 `ref`。
235
238
 
236
239
  ## 指令用法
237
240
 
@@ -404,8 +407,6 @@ Worker 更新仍由用户控制。有新版本等待更新时,选择 **立即
404
407
 
405
408
  ## 开发
406
409
 
407
- CI 使用 Node.js 22。
408
-
409
410
  ```bash
410
411
  npm install
411
412
  npm run typecheck
@@ -32,7 +32,7 @@ permission. Confirm errors are visible, focus returns after library-driven exit,
32
32
  inline styles/body scroll, navigation and app switching do not leave stale state, and an accessible
33
33
  exit remains keyboard/touch reachable.
34
34
 
35
- ## iPhone Chrome video-wrapper check
35
+ ## iPhone Chrome video-card check
36
36
 
37
37
  This check requires a physical iPhone; desktop emulation and jsdom do not reproduce WebKit's native
38
38
  video and arbitrary-element fullscreen behavior reliably.
@@ -43,10 +43,10 @@ video and arbitrary-element fullscreen behavior reliably.
43
43
  element**, and **Document fullscreen element** from Diagnostics.
44
44
  4. Confirm **Exit video fullscreen** remains visible and touch-accessible in portrait and landscape,
45
45
  then use it to exit.
46
- 5. Confirm focus returns to **View video fullscreen**, the wrapper's fallback styles are removed, body
46
+ 5. Confirm focus returns to **View video fullscreen**, the card's fallback styles are removed, body
47
47
  scrolling is restored, and the page, element, and image examples still work.
48
48
 
49
- If the request reports `fallback`, the controller element should be the video wrapper and the document
49
+ If the request reports `fallback`, the controller element should be the video card and the document
50
50
  fullscreen element should be `none`. If it reports `native`, record both element fields and investigate
51
51
  WebKit-specific behavior separately before changing the shared controller.
52
52
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * vue-screenfull v1.1.1
2
+ * vue-screenfull v1.1.2
3
3
  * (c) 2018-2026 Cheng https://www.npmjs.com/package/vue-screenfull
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * vue-screenfull v1.1.1
2
+ * vue-screenfull v1.1.2
3
3
  * (c) 2018-2026 Cheng https://www.npmjs.com/package/vue-screenfull
4
4
  * Released under the MIT License.
5
5
  */
package/lib/browser.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * vue-screenfull v1.1.1
2
+ * vue-screenfull v1.1.2
3
3
  * (c) 2018-2026 Cheng https://www.npmjs.com/package/vue-screenfull
4
4
  * Released under the MIT License.
5
5
  */
package/lib/index.cjs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * vue-screenfull v1.1.1
2
+ * vue-screenfull v1.1.2
3
3
  * (c) 2018-2026 Cheng https://www.npmjs.com/package/vue-screenfull
4
4
  * Released under the MIT License.
5
5
  */
package/lib/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * vue-screenfull v1.1.1
2
+ * vue-screenfull v1.1.2
3
3
  * (c) 2018-2026 Cheng https://www.npmjs.com/package/vue-screenfull
4
4
  * Released under the MIT License.
5
5
  */
package/lib/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * vue-screenfull v1.1.1
2
+ * vue-screenfull v1.1.2
3
3
  * (c) 2018-2026 Cheng https://www.npmjs.com/package/vue-screenfull
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * vue-screenfull v1.1.1
2
+ * vue-screenfull v1.1.2
3
3
  * (c) 2018-2026 Cheng https://www.npmjs.com/package/vue-screenfull
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * vue-screenfull v1.1.1
2
+ * vue-screenfull v1.1.2
3
3
  * (c) 2018-2026 Cheng https://www.npmjs.com/package/vue-screenfull
4
4
  * Released under the MIT License.
5
5
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-screenfull",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Reactive, strongly typed, SSR-safe fullscreen utilities for Vue 3.",
5
5
  "main": "lib/index.cjs.js",
6
6
  "module": "lib/index.esm.js",