branch-video-player-sdk 0.2.11 → 0.2.13

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.
@@ -1,7 +1,56 @@
1
1
  <!doctype html>
2
- <html lang="en">
3
- <head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>BranchVideo Player</title> <script type="module" crossorigin src="./assets/player-Bf_D5PLO.js"></script>
4
- <link rel="stylesheet" crossorigin href="./assets/player-Bi0QW1hL.css">
5
- </head>
6
- <body><div id="root"></div></body>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
6
+ <title>BranchVideo Player</title>
7
+ <style>
8
+ html, body, #root { width: 100%; height: 100%; margin: 0; background: #000; overflow: hidden; }
9
+ .bv-boot-overlay { position: fixed; inset: 0; display: flex; flex-direction: column; background: linear-gradient(135deg, #0a0a0f 0%, #1a1a2e 50%, #16213e 100%); }
10
+ .bv-boot-cover { position: absolute; inset: 0; background-position: center; background-repeat: no-repeat; background-size: cover; }
11
+ .bv-boot-bottom { position: absolute; left: 0; right: 0; bottom: 4.4vw; padding: 0 10%; color: #fff; font-family: sans-serif; }
12
+ .bv-boot-meta { display: flex; justify-content: space-between; align-items: baseline; }
13
+ .bv-boot-bar { height: 8px; margin: 8px 0; border: 1px solid #CEC1B6; background: rgba(107, 94, 82, 0.4); }
14
+ .bv-boot-bar > i { display: block; width: 0; height: 100%; background: #EB6728; }
15
+ .bv-boot-desc { text-align: center; font-weight: 700; }
16
+ </style>
17
+ <script type="module" crossorigin src="./assets/player-Dv33xIOl.js"></script>
18
+ <link rel="stylesheet" crossorigin href="./assets/player-Bi0QW1hL.css">
19
+ </head>
20
+ <body>
21
+ <div id="root">
22
+ <div class="bv-boot-overlay" aria-label="资源下载中">
23
+ <div class="bv-boot-cover" data-boot-cover aria-hidden="true"></div>
24
+ <div class="bv-boot-bottom">
25
+ <div class="bv-boot-row" data-testid="loading-progress-row">
26
+ <div class="bv-boot-meta">
27
+ <div>0%</div>
28
+ <div>0B / 0B</div>
29
+ </div>
30
+ <div class="bv-boot-bar"><i data-boot-progress></i></div>
31
+ </div>
32
+ <div class="bv-boot-desc">资源下载中</div>
33
+ </div>
34
+ </div>
35
+ </div>
36
+ <script>
37
+ (function () {
38
+ var search = new URLSearchParams(location.search)
39
+ var hashQuery = location.hash.indexOf('?') >= 0 ? new URLSearchParams(location.hash.slice(location.hash.indexOf('?') + 1)) : null
40
+ var cover = search.get('cover') || (hashQuery && hashQuery.get('cover')) || ''
41
+ if (/^https?:\/\//i.test(cover)) {
42
+ var layer = document.querySelector('[data-boot-cover]')
43
+ if (layer) layer.style.backgroundImage = 'url("' + cover.replace(/"/g, '') + '")'
44
+ }
45
+ var bar = document.querySelector('[data-boot-progress]')
46
+ if (!bar) return
47
+ var started = Date.now()
48
+ var timer = setInterval(function () {
49
+ var progress = Math.min(15, (Date.now() - started) / 4000 * 15)
50
+ bar.style.width = progress + '%'
51
+ }, 100)
52
+ window.addEventListener('pagehide', function () { clearInterval(timer) })
53
+ })()
54
+ </script>
55
+ </body>
7
56
  </html>
package/dist/url.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u="/branch-video-runtime/player.html",c=e=>/^\d+$/.test(e)&&Number(e)>0&&Number(e)<=65535,f=e=>{const t=e.split(".");return t.length===4&&t.every(r=>/^\d+$/.test(r)&&Number(r)<=255)},a=e=>{if(!/^[0-9a-f:]+$/i.test(e))return!1;const t=e.split("::");if(t.length>2)return!1;const r=t.flatMap(s=>s?s.split(":"):[]);return r.every(s=>/^[0-9a-f]{1,4}$/i.test(s))?t.length===2?r.length<8:r.length===8:!1},l=e=>{const t=e.endsWith(".")?e.slice(0,-1):e;return/^[\d.]+$/.test(t)?f(t):!!t&&!t.includes("..")&&t.split(".").every(r=>/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(r))},p=e=>{if(!e||e.includes("@"))return!1;if(e.startsWith("[")){const s=e.indexOf("]"),n=e.slice(1,s),i=e.slice(s+1);return s<=1||!a(n)?!1:!i||i.startsWith(":")&&c(i.slice(1))}const t=e.lastIndexOf(":");if(t===-1)return l(e);const r=e.slice(0,t);return l(r)&&!r.includes(":")&&c(e.slice(t+1))},d=e=>{const t=/^(https?):\/\/([^\s/?#]+)([/\?#].*)?$/i.exec(e);return!t||!p(t[2])?null:{authority:t[2],suffix:t[3]||""}},m=e=>d(e)!==null,o=(e,t)=>{if(!m(t)||e==="runtimeUrl"&&t.includes("#"))throw new TypeError(`${e} must be an absolute HTTP(S) URL`);return t},U=e=>{const t=d(e);if(!t||t.suffix&&t.suffix!=="/")throw new TypeError("parentOrigin must be an HTTP(S) origin");return e.endsWith("/")?e.slice(0,-1):e};function h(e){const t=e.runtimeUrl?o("runtimeUrl",e.runtimeUrl):u,r=o("scriptUrl",e.scriptUrl),s=e.parentOrigin===void 0?void 0:U(e.parentOrigin),n=[`script=${encodeURIComponent(r)}`,"embedPlatform=web_player_sdk","sdkProtocol=1"];s&&n.push(`parentOrigin=${encodeURIComponent(s)}`),e.cshost&&n.push(`cshost=${encodeURIComponent(e.cshost)}`),e.controls!==void 0&&n.push(`controls=${e.controls}`),e.debug!==void 0&&n.push(`debug=${e.debug}`);const i=t.includes("?")?"&":"?";return`${t}${i}${n.join("&")}`}exports.DEFAULT_RUNTIME_PATH=u;exports.buildBranchVideoPlayerUrl=h;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d="/branch-video-runtime/player.html",l=e=>/^\d+$/.test(e)&&Number(e)>0&&Number(e)<=65535,a=e=>{const r=e.split(".");return r.length===4&&r.every(t=>/^\d+$/.test(t)&&Number(t)<=255)},p=e=>{if(!/^[0-9a-f:]+$/i.test(e))return!1;const r=e.split("::");if(r.length>2)return!1;const t=r.flatMap(n=>n?n.split(":"):[]);return t.every(n=>/^[0-9a-f]{1,4}$/i.test(n))?r.length===2?t.length<8:t.length===8:!1},o=e=>{const r=e.endsWith(".")?e.slice(0,-1):e;return/^[\d.]+$/.test(r)?a(r):!!r&&!r.includes("..")&&r.split(".").every(t=>/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(t))},m=e=>{if(!e||e.includes("@"))return!1;if(e.startsWith("[")){const n=e.indexOf("]"),i=e.slice(1,n),s=e.slice(n+1);return n<=1||!p(i)?!1:!s||s.startsWith(":")&&l(s.slice(1))}const r=e.lastIndexOf(":");if(r===-1)return o(e);const t=e.slice(0,r);return o(t)&&!t.includes(":")&&l(e.slice(r+1))},u=e=>{const r=/^(https?):\/\/([^\s/?#]+)([/\?#].*)?$/i.exec(e);return!r||!m(r[2])?null:{authority:r[2],suffix:r[3]||""}},U=e=>u(e)!==null,c=(e,r)=>{if(!U(r)||e==="runtimeUrl"&&r.includes("#"))throw new TypeError(`${e} must be an absolute HTTP(S) URL`);return r},h=e=>{const r=u(e);if(!r||r.suffix&&r.suffix!=="/")throw new TypeError("parentOrigin must be an HTTP(S) origin");return e.endsWith("/")?e.slice(0,-1):e};function g(e){const r=e.runtimeUrl?c("runtimeUrl",e.runtimeUrl):d,t=c("scriptUrl",e.scriptUrl),n=e.cover===void 0?void 0:c("cover",e.cover),i=e.parentOrigin===void 0?void 0:h(e.parentOrigin),s=[`script=${encodeURIComponent(t)}`,"embedPlatform=web_player_sdk","sdkProtocol=1"];n&&s.push(`cover=${encodeURIComponent(n)}`),i&&s.push(`parentOrigin=${encodeURIComponent(i)}`),e.cshost&&s.push(`cshost=${encodeURIComponent(e.cshost)}`),e.controls!==void 0&&s.push(`controls=${e.controls}`),e.debug!==void 0&&s.push(`debug=${e.debug}`);const f=r.includes("?")?"&":"?";return`${r}${f}${s.join("&")}`}exports.DEFAULT_RUNTIME_PATH=d;exports.buildBranchVideoPlayerUrl=g;
package/dist/url.d.ts CHANGED
@@ -2,6 +2,7 @@ export interface BranchVideoPlayerUrlOptions {
2
2
  /** Runtime 入口地址。不传则使用 SDK 内置的 /branch-video-runtime/player.html */
3
3
  runtimeUrl?: string;
4
4
  scriptUrl: string;
5
+ cover?: string;
5
6
  parentOrigin?: string;
6
7
  cshost?: string;
7
8
  controls?: boolean;
package/dist/url.js CHANGED
@@ -1,47 +1,47 @@
1
- const d = "/branch-video-runtime/player.html", c = (t) => /^\d+$/.test(t) && Number(t) > 0 && Number(t) <= 65535, f = (t) => {
2
- const e = t.split(".");
3
- return e.length === 4 && e.every((r) => /^\d+$/.test(r) && Number(r) <= 255);
4
- }, p = (t) => {
5
- if (!/^[0-9a-f:]+$/i.test(t)) return !1;
6
- const e = t.split("::");
7
- if (e.length > 2) return !1;
8
- const r = e.flatMap((s) => s ? s.split(":") : []);
9
- return r.every((s) => /^[0-9a-f]{1,4}$/i.test(s)) ? e.length === 2 ? r.length < 8 : r.length === 8 : !1;
10
- }, l = (t) => {
11
- const e = t.endsWith(".") ? t.slice(0, -1) : t;
12
- return /^[\d.]+$/.test(e) ? f(e) : !!e && !e.includes("..") && e.split(".").every((r) => /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(r));
13
- }, a = (t) => {
14
- if (!t || t.includes("@")) return !1;
15
- if (t.startsWith("[")) {
16
- const s = t.indexOf("]"), n = t.slice(1, s), i = t.slice(s + 1);
17
- return s <= 1 || !p(n) ? !1 : !i || i.startsWith(":") && c(i.slice(1));
1
+ const f = "/branch-video-runtime/player.html", o = (e) => /^\d+$/.test(e) && Number(e) > 0 && Number(e) <= 65535, p = (e) => {
2
+ const r = e.split(".");
3
+ return r.length === 4 && r.every((t) => /^\d+$/.test(t) && Number(t) <= 255);
4
+ }, a = (e) => {
5
+ if (!/^[0-9a-f:]+$/i.test(e)) return !1;
6
+ const r = e.split("::");
7
+ if (r.length > 2) return !1;
8
+ const t = r.flatMap((n) => n ? n.split(":") : []);
9
+ return t.every((n) => /^[0-9a-f]{1,4}$/i.test(n)) ? r.length === 2 ? t.length < 8 : t.length === 8 : !1;
10
+ }, l = (e) => {
11
+ const r = e.endsWith(".") ? e.slice(0, -1) : e;
12
+ return /^[\d.]+$/.test(r) ? p(r) : !!r && !r.includes("..") && r.split(".").every((t) => /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(t));
13
+ }, m = (e) => {
14
+ if (!e || e.includes("@")) return !1;
15
+ if (e.startsWith("[")) {
16
+ const n = e.indexOf("]"), i = e.slice(1, n), s = e.slice(n + 1);
17
+ return n <= 1 || !a(i) ? !1 : !s || s.startsWith(":") && o(s.slice(1));
18
18
  }
19
- const e = t.lastIndexOf(":");
20
- if (e === -1) return l(t);
21
- const r = t.slice(0, e);
22
- return l(r) && !r.includes(":") && c(t.slice(e + 1));
23
- }, u = (t) => {
24
- const e = /^(https?):\/\/([^\s/?#]+)([/\?#].*)?$/i.exec(t);
25
- return !e || !a(e[2]) ? null : { authority: e[2], suffix: e[3] || "" };
26
- }, m = (t) => u(t) !== null, o = (t, e) => {
27
- if (!m(e) || t === "runtimeUrl" && e.includes("#")) throw new TypeError(`${t} must be an absolute HTTP(S) URL`);
28
- return e;
29
- }, h = (t) => {
30
- const e = u(t);
31
- if (!e || e.suffix && e.suffix !== "/") throw new TypeError("parentOrigin must be an HTTP(S) origin");
32
- return t.endsWith("/") ? t.slice(0, -1) : t;
19
+ const r = e.lastIndexOf(":");
20
+ if (r === -1) return l(e);
21
+ const t = e.slice(0, r);
22
+ return l(t) && !t.includes(":") && o(e.slice(r + 1));
23
+ }, d = (e) => {
24
+ const r = /^(https?):\/\/([^\s/?#]+)([/\?#].*)?$/i.exec(e);
25
+ return !r || !m(r[2]) ? null : { authority: r[2], suffix: r[3] || "" };
26
+ }, h = (e) => d(e) !== null, c = (e, r) => {
27
+ if (!h(r) || e === "runtimeUrl" && r.includes("#")) throw new TypeError(`${e} must be an absolute HTTP(S) URL`);
28
+ return r;
29
+ }, U = (e) => {
30
+ const r = d(e);
31
+ if (!r || r.suffix && r.suffix !== "/") throw new TypeError("parentOrigin must be an HTTP(S) origin");
32
+ return e.endsWith("/") ? e.slice(0, -1) : e;
33
33
  };
34
- function U(t) {
35
- const e = t.runtimeUrl ? o("runtimeUrl", t.runtimeUrl) : d, r = o("scriptUrl", t.scriptUrl), s = t.parentOrigin === void 0 ? void 0 : h(t.parentOrigin), n = [
36
- `script=${encodeURIComponent(r)}`,
34
+ function g(e) {
35
+ const r = e.runtimeUrl ? c("runtimeUrl", e.runtimeUrl) : f, t = c("scriptUrl", e.scriptUrl), n = e.cover === void 0 ? void 0 : c("cover", e.cover), i = e.parentOrigin === void 0 ? void 0 : U(e.parentOrigin), s = [
36
+ `script=${encodeURIComponent(t)}`,
37
37
  "embedPlatform=web_player_sdk",
38
38
  "sdkProtocol=1"
39
39
  ];
40
- s && n.push(`parentOrigin=${encodeURIComponent(s)}`), t.cshost && n.push(`cshost=${encodeURIComponent(t.cshost)}`), t.controls !== void 0 && n.push(`controls=${t.controls}`), t.debug !== void 0 && n.push(`debug=${t.debug}`);
41
- const i = e.includes("?") ? "&" : "?";
42
- return `${e}${i}${n.join("&")}`;
40
+ n && s.push(`cover=${encodeURIComponent(n)}`), i && s.push(`parentOrigin=${encodeURIComponent(i)}`), e.cshost && s.push(`cshost=${encodeURIComponent(e.cshost)}`), e.controls !== void 0 && s.push(`controls=${e.controls}`), e.debug !== void 0 && s.push(`debug=${e.debug}`);
41
+ const u = r.includes("?") ? "&" : "?";
42
+ return `${r}${u}${s.join("&")}`;
43
43
  }
44
44
  export {
45
- d as DEFAULT_RUNTIME_PATH,
46
- U as buildBranchVideoPlayerUrl
45
+ f as DEFAULT_RUNTIME_PATH,
46
+ g as buildBranchVideoPlayerUrl
47
47
  };
package/package.json CHANGED
@@ -1,30 +1,30 @@
1
- {
2
- "name": "branch-video-player-sdk",
3
- "version": "0.2.11",
4
- "type": "module",
5
- "main": "./dist/index.umd.cjs",
6
- "module": "./dist/index.js",
7
- "types": "./dist/index.d.ts",
8
- "unpkg": "./dist/index.umd.cjs",
9
- "exports": {
10
- ".": {
11
- "types": "./dist/index.d.ts",
12
- "import": "./dist/index.js",
13
- "require": "./dist/index.umd.cjs"
14
- },
15
- "./url": {
16
- "types": "./dist/url.d.ts",
17
- "import": "./dist/url.js",
18
- "require": "./dist/url.cjs"
19
- },
20
- "./vite": {
21
- "types": "./dist/vite.d.ts",
22
- "import": "./dist/vite.js",
23
- "require": "./dist/vite.cjs"
24
- }
25
- },
26
- "files": [
27
- "dist",
28
- "README.md"
29
- ]
30
- }
1
+ {
2
+ "name": "branch-video-player-sdk",
3
+ "version": "0.2.13",
4
+ "type": "module",
5
+ "main": "./dist/index.umd.cjs",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "unpkg": "./dist/index.umd.cjs",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.umd.cjs"
14
+ },
15
+ "./url": {
16
+ "types": "./dist/url.d.ts",
17
+ "import": "./dist/url.js",
18
+ "require": "./dist/url.cjs"
19
+ },
20
+ "./vite": {
21
+ "types": "./dist/vite.d.ts",
22
+ "import": "./dist/vite.js",
23
+ "require": "./dist/vite.cjs"
24
+ }
25
+ },
26
+ "files": [
27
+ "dist",
28
+ "README.md"
29
+ ]
30
+ }