From 657dd7e77c63f7211562a3525a2f3932c5b24c8b Mon Sep 17 00:00:00 2001 From: Harvey Zack Date: Sat, 16 Aug 2025 17:00:01 +0800 Subject: [PATCH] refactor: improve document Picture-in-Picture support checks and update type definitions - Renamed variable `dpipOK` to `isSupported` for clarity in checking Document Picture-in-Picture support. - Updated the `open` function to use the new `isSupported` variable. - Removed redundant checks in the `close` function related to Document Picture-in-Picture support. - Added `isSupported` and `isActive` properties to the plugin's result interface in TypeScript definitions. - Cleaned up the code for better readability and maintainability. --- docs/assets/ts/artplayer-plugin-document-pip.d.ts | 9 ++------- .../compiled/artplayer-plugin-document-pip.esm.js | 2 +- .../artplayer-plugin-document-pip.esm.js.map | 2 +- docs/compiled/artplayer-plugin-document-pip.js | 2 +- .../artplayer-plugin-document-pip.legacy.js | 2 +- .../artplayer-plugin-document-pip/index.js | 15 ++++++++------- .../artplayer-plugin-document-pip/index.js.map | 2 +- .../dist/artplayer-plugin-document-pip.esm.js | 2 +- .../dist/artplayer-plugin-document-pip.esm.js.map | 2 +- .../dist/artplayer-plugin-document-pip.js | 2 +- .../dist/artplayer-plugin-document-pip.legacy.js | 2 +- .../artplayer-plugin-document-pip/src/index.js | 12 ++++-------- .../types/artplayer-plugin-document-pip.d.ts | 9 ++------- 13 files changed, 25 insertions(+), 38 deletions(-) diff --git a/docs/assets/ts/artplayer-plugin-document-pip.d.ts b/docs/assets/ts/artplayer-plugin-document-pip.d.ts index 592448187..dee9d2c41 100644 --- a/docs/assets/ts/artplayer-plugin-document-pip.d.ts +++ b/docs/assets/ts/artplayer-plugin-document-pip.d.ts @@ -7,16 +7,11 @@ interface Option { interface Result { name: 'artplayerPluginDocumentPip' + isSupported: boolean + isActive: boolean open: () => void close: () => void toggle: () => void - state: { - win: Window | null - originalParent: Element | null - originalNext: Element | null - currentDoc: Document | null - placeholder: Element | null - } } declare const artplayerPluginDocumentPip: (option: Option) => (art: Artplayer) => Result diff --git a/docs/compiled/artplayer-plugin-document-pip.esm.js b/docs/compiled/artplayer-plugin-document-pip.esm.js index 8b9281452..814b90537 100644 --- a/docs/compiled/artplayer-plugin-document-pip.esm.js +++ b/docs/compiled/artplayer-plugin-document-pip.esm.js @@ -5,5 +5,5 @@ * (c) 2017-2025 Harvey Zack * Released under the MIT License. */ -!function(e,t,n,r,i,o,l,d){var c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},a="function"==typeof c[r]&&c[r],u=a.i||{},p=a.cache||{},f="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function s(t,n){if(!p[t]){if(!e[t]){if(i[t])return i[t];var o="function"==typeof c[r]&&c[r];if(!n&&o)return o(t,!0);if(a)return a(t,!0);if(f&&"string"==typeof t)return f(t);var l=Error("Cannot find module '"+t+"'");throw l.code="MODULE_NOT_FOUND",l}u.resolve=function(n){var r=e[t][1][n];return null!=r?r:n},u.cache={};var d=p[t]=new s.Module(t);e[t][0].call(d.exports,u,d,d.exports,c)}return p[t].exports;function u(e){var t=u.resolve(e);return!1===t?{}:s(t)}}s.isParcelRequire=!0,s.Module=function(e){this.id=e,this.bundle=s,this.require=f,this.exports={}},s.modules=e,s.cache=p,s.parent=a,s.distDir=void 0,s.publicUrl=void 0,s.devServer=void 0,s.i=u,s.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(s,"root",{get:function(){return c[r]}}),c[r]=s;for(var h=0;h{let n="documentPictureInPicture"in window&&"function"==typeof window.documentPictureInPicture?.requestWindow,{proxy:r,icons:i,i18n:o,template:{$container:l},constructor:{utils:{append:d,tooltip:c,addClass:a,removeClass:u}}}=e,p={win:null,originalParent:null,originalNext:null,currentDoc:null,placeholder:null};async function f(){if(!n&&t.fallbackToVideoPiP){e.pip=!0,console.warn("[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture");return}if(!p.win)try{let n=await window.documentPictureInPicture.requestWindow({width:t.width,height:t.height});p.win=n,p.currentDoc=n.document,p.placeholder=document.createElement("div"),p.placeholder.className="artplayer-pip-placeholder",p.placeholder.style.cssText="display:flex;justify-content:center;align-items:center;width:100%;height:100%;",p.placeholder.textContent=t.placeholder,p.originalParent=l.parentNode,p.originalNext=l.nextSibling,p.originalParent.insertBefore(p.placeholder,p.originalNext);let i=n.document.createElement("div");i.id="__art_dpip_root",n.document.body.appendChild(i);var r=n.document;let o=r.createElement("style");if(o.textContent=` html, body { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; } #__art_dpip_root { position:absolute; inset:0; display:flex; } #__art_dpip_root > * { width:100% !important; height:100% !important; } `,r.head.appendChild(o),!r.querySelector('meta[name="viewport"]')){let e=r.createElement("meta");e.name="viewport",e.content="width=device-width,initial-scale=1",r.head.appendChild(e)}try{document.querySelectorAll('link[rel="stylesheet"]').forEach(e=>{let t=r.createElement("link");t.rel="stylesheet",t.href=e.href,e.media&&(t.media=e.media),e.crossOrigin&&(t.crossOrigin=e.crossOrigin),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),r.head.appendChild(t)})}catch{}try{document.querySelectorAll("style").forEach(e=>{let t=r.createElement("style");t.textContent=e.textContent,r.head.appendChild(t)})}catch{}let d=n.document.adoptNode(l);i.appendChild(d),p.currentDoc=n.document;let c=()=>e.resize?.(),u=()=>s();n.addEventListener("resize",c),n.addEventListener("pagehide",u),n.addEventListener("unload",u),p.cleanup=()=>{n.removeEventListener("resize",c),n.removeEventListener("pagehide",u),n.removeEventListener("unload",u)},a(l,"artplayer-document-pip"),e.emit("document-pip",!0)}catch(t){e.notice.show="Document Picture-in-Picture open failed",console.warn("[artplayer-plugin-document-pip] open failed:",t)}}function s(){if(!n&&t.fallbackToVideoPiP){e.pip=!1;return}if(p.win)try{p.cleanup?.(),function(){if(!p.placeholder)return;let e=p.placeholder.ownerDocument||document,t=e.adoptNode(l);p.originalParent.insertBefore(t,p.placeholder),p.placeholder.remove(),p.placeholder=null,p.currentDoc=e}(),p.win.close(),p.win=null,u(l,"artplayer-document-pip"),e.emit("document-pip",!1)}catch(t){e.notice.show="Document Picture-in-Picture close failed",console.warn("[artplayer-plugin-document-pip] close failed:",t)}}function h(){p.win?s():f()}return e.controls.add({name:"document-pip",position:"right",index:40,tooltip:e.i18n.get("PIP Mode"),mounted:t=>{d(t,i.pip),r(t,"click",h),e.on("document-pip",e=>{c(t,o.get(e?"Exit PIP Mode":"PIP Mode"))})}}),e.on("destroy",s),{name:"artplayerPluginDocumentPip",state:p,open:f,close:s,toggle:h}}}i.defineInteropFlag(n),i.export(n,"default",()=>o),"undefined"!=typeof window&&(window.artplayerPluginDocumentPip=o)},{"@parcel/transformer-js/src/esmodule-helpers.js":"5lQoW"}],"5lQoW":[function(e,t,n,r){n.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},n.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.exportAll=function(e,t){return Object.keys(e).forEach(function(n){"default"===n||"__esModule"===n||Object.prototype.hasOwnProperty.call(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[n]}})}),t},n.export=function(e,t,n){Object.defineProperty(e,t,{enumerable:!0,get:n})}},{}]},["bKI9O"],"bKI9O","parcelRequire4dc0",{});let{default:e}=parcelRequire4dc0("bKI9O");export{e as default}; +!function(e,t,n,r,i,o,l,d){var c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},u="function"==typeof c[r]&&c[r],a=u.i||{},p=u.cache||{},f="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function s(t,n){if(!p[t]){if(!e[t]){if(i[t])return i[t];var o="function"==typeof c[r]&&c[r];if(!n&&o)return o(t,!0);if(u)return u(t,!0);if(f&&"string"==typeof t)return f(t);var l=Error("Cannot find module '"+t+"'");throw l.code="MODULE_NOT_FOUND",l}a.resolve=function(n){var r=e[t][1][n];return null!=r?r:n},a.cache={};var d=p[t]=new s.Module(t);e[t][0].call(d.exports,a,d,d.exports,c)}return p[t].exports;function a(e){var t=a.resolve(e);return!1===t?{}:s(t)}}s.isParcelRequire=!0,s.Module=function(e){this.id=e,this.bundle=s,this.require=f,this.exports={}},s.modules=e,s.cache=p,s.parent=u,s.distDir=void 0,s.publicUrl=void 0,s.devServer=void 0,s.i=a,s.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(s,"root",{get:function(){return c[r]}}),c[r]=s;for(var h=0;h{let n="documentPictureInPicture"in window&&"function"==typeof window.documentPictureInPicture?.requestWindow,{proxy:r,icons:i,i18n:o,template:{$container:l},constructor:{utils:{append:d,tooltip:c,addClass:u,removeClass:a}}}=e,p={win:null,originalParent:null,originalNext:null,currentDoc:null,placeholder:null};async function f(){if(!n&&t.fallbackToVideoPiP){e.pip=!0,console.warn("[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture");return}if(!p.win)try{let n=await window.documentPictureInPicture.requestWindow({width:t.width,height:t.height});p.win=n,p.currentDoc=n.document,p.placeholder=document.createElement("div"),p.placeholder.className="artplayer-pip-placeholder",p.placeholder.style.cssText="display:flex;justify-content:center;align-items:center;width:100%;height:100%;",p.placeholder.textContent=t.placeholder,p.originalParent=l.parentNode,p.originalNext=l.nextSibling,p.originalParent.insertBefore(p.placeholder,p.originalNext);let i=n.document.createElement("div");i.id="__art_dpip_root",n.document.body.appendChild(i);var r=n.document;let o=r.createElement("style");if(o.textContent=` html, body { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; } #__art_dpip_root { position:absolute; inset:0; display:flex; } #__art_dpip_root > * { width:100% !important; height:100% !important; } `,r.head.appendChild(o),!r.querySelector('meta[name="viewport"]')){let e=r.createElement("meta");e.name="viewport",e.content="width=device-width,initial-scale=1",r.head.appendChild(e)}try{document.querySelectorAll('link[rel="stylesheet"]').forEach(e=>{let t=r.createElement("link");t.rel="stylesheet",t.href=e.href,e.media&&(t.media=e.media),e.crossOrigin&&(t.crossOrigin=e.crossOrigin),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),r.head.appendChild(t)})}catch{}try{document.querySelectorAll("style").forEach(e=>{let t=r.createElement("style");t.textContent=e.textContent,r.head.appendChild(t)})}catch{}let d=n.document.adoptNode(l);i.appendChild(d),p.currentDoc=n.document;let c=()=>e.resize?.(),a=()=>s();n.addEventListener("resize",c),n.addEventListener("pagehide",a),n.addEventListener("unload",a),p.cleanup=()=>{n.removeEventListener("resize",c),n.removeEventListener("pagehide",a),n.removeEventListener("unload",a)},u(l,"artplayer-document-pip"),e.emit("document-pip",!0)}catch(t){e.notice.show="Document Picture-in-Picture open failed",console.warn("[artplayer-plugin-document-pip] open failed:",t)}}function s(){if(p.win)try{p.cleanup?.(),function(){if(!p.placeholder)return;let e=p.placeholder.ownerDocument||document,t=e.adoptNode(l);p.originalParent.insertBefore(t,p.placeholder),p.placeholder.remove(),p.placeholder=null,p.currentDoc=e}(),p.win.close(),p.win=null,a(l,"artplayer-document-pip"),e.emit("document-pip",!1)}catch(t){e.notice.show="Document Picture-in-Picture close failed",console.warn("[artplayer-plugin-document-pip] close failed:",t)}}function h(){p.win?s():f()}return e.controls.add({name:"document-pip",position:"right",index:40,tooltip:e.i18n.get("PIP Mode"),mounted:t=>{d(t,i.pip),r(t,"click",h),e.on("document-pip",e=>{c(t,o.get(e?"Exit PIP Mode":"PIP Mode"))})}}),e.on("destroy",s),{name:"artplayerPluginDocumentPip",get isSupported(){return n},get isActive(){return!!p.win},open:f,close:s,toggle:h}}}i.defineInteropFlag(n),i.export(n,"default",()=>o),"undefined"!=typeof window&&(window.artplayerPluginDocumentPip=o)},{"@parcel/transformer-js/src/esmodule-helpers.js":"5lQoW"}],"5lQoW":[function(e,t,n,r){n.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},n.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.exportAll=function(e,t){return Object.keys(e).forEach(function(n){"default"===n||"__esModule"===n||Object.prototype.hasOwnProperty.call(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[n]}})}),t},n.export=function(e,t,n){Object.defineProperty(e,t,{enumerable:!0,get:n})}},{}]},["bKI9O"],"bKI9O","parcelRequire4dc0",{});let{default:e}=parcelRequire4dc0("bKI9O");export{e as default}; //# sourceMappingURL=artplayer-plugin-document-pip.esm.js.map \ No newline at end of file diff --git a/docs/compiled/artplayer-plugin-document-pip.esm.js.map b/docs/compiled/artplayer-plugin-document-pip.esm.js.map index 27ba1763e..70777dd9a 100644 --- a/docs/compiled/artplayer-plugin-document-pip.esm.js.map +++ b/docs/compiled/artplayer-plugin-document-pip.esm.js.map @@ -1 +1 @@ -{"mappings":"C,A,S,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,E,I,E,A,a,O,W,W,A,a,O,K,K,A,a,O,O,O,A,a,O,O,O,C,E,E,A,Y,O,C,C,E,E,C,C,E,C,E,E,C,E,C,E,E,E,K,E,C,E,E,A,a,O,Q,A,Y,O,O,O,E,O,O,C,I,C,Q,S,E,C,C,C,E,G,C,C,C,E,C,C,G,C,C,C,E,C,C,G,C,C,E,C,O,C,C,E,C,I,E,A,Y,O,C,C,E,E,C,C,E,C,G,C,G,E,O,E,E,C,G,G,E,O,E,E,C,G,G,G,A,U,O,E,O,E,G,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,O,C,S,C,E,I,E,C,C,E,C,E,C,E,C,O,A,M,E,E,C,E,E,K,C,C,E,I,E,C,C,E,C,I,E,M,C,G,C,C,E,C,E,C,I,C,E,O,C,E,E,E,O,C,E,C,O,C,C,E,C,O,C,S,E,C,E,I,E,E,O,C,G,M,A,C,I,E,C,E,E,E,C,C,E,e,C,C,E,E,M,C,S,C,E,I,C,E,C,E,I,C,M,C,E,I,C,O,C,E,I,C,O,C,C,C,E,E,O,C,E,E,K,C,E,E,M,C,E,E,O,C,K,E,E,S,C,K,E,E,S,C,K,E,E,C,C,E,E,Q,C,S,C,C,C,E,C,C,E,C,C,S,C,C,C,E,E,O,C,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U,CACpC,WAAY,CAAA,EACZ,IAAK,CACP,EACF,C,E,C,E,E,C,Q,C,Q,oB,C,G,G,C,Q,C,C,C,kB,gB,K,O","sources":["","packages/artplayer-plugin-document-pip/src/index.js","node_modules/@parcel/transformer-js/src/esmodule-helpers.js"],"sourcesContent":["// modules are defined as an array\n// [ module function, map of requires ]\n//\n// map of requires is short require name -> numeric require\n//\n// anything defined in a previous bundle is accessed via the\n// orig method which is the require for previous bundles\n\n(function (\n modules,\n entry,\n mainEntry,\n parcelRequireName,\n externals,\n distDir,\n publicUrl,\n devServer\n) {\n /* eslint-disable no-undef */\n var globalObject =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n /* eslint-enable no-undef */\n\n // Save the require from previous bundle to this closure if any\n var previousRequire =\n typeof globalObject[parcelRequireName] === 'function' &&\n globalObject[parcelRequireName];\n\n var importMap = previousRequire.i || {};\n var cache = previousRequire.cache || {};\n // Do not use `require` to prevent Webpack from trying to bundle this call\n var nodeRequire =\n typeof module !== 'undefined' &&\n typeof module.require === 'function' &&\n module.require.bind(module);\n\n function newRequire(name, jumped) {\n if (!cache[name]) {\n if (!modules[name]) {\n if (externals[name]) {\n return externals[name];\n }\n // if we cannot find the module within our internal map or\n // cache jump to the current global require ie. the last bundle\n // that was added to the page.\n var currentRequire =\n typeof globalObject[parcelRequireName] === 'function' &&\n globalObject[parcelRequireName];\n if (!jumped && currentRequire) {\n return currentRequire(name, true);\n }\n\n // If there are other bundles on this page the require from the\n // previous one is saved to 'previousRequire'. Repeat this as\n // many times as there are bundles until the module is found or\n // we exhaust the require chain.\n if (previousRequire) {\n return previousRequire(name, true);\n }\n\n // Try the node require function if it exists.\n if (nodeRequire && typeof name === 'string') {\n return nodeRequire(name);\n }\n\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n }\n\n localRequire.resolve = resolve;\n localRequire.cache = {};\n\n var module = (cache[name] = new newRequire.Module(name));\n\n modules[name][0].call(\n module.exports,\n localRequire,\n module,\n module.exports,\n globalObject\n );\n }\n\n return cache[name].exports;\n\n function localRequire(x) {\n var res = localRequire.resolve(x);\n return res === false ? {} : newRequire(res);\n }\n\n function resolve(x) {\n var id = modules[name][1][x];\n return id != null ? id : x;\n }\n }\n\n function Module(moduleName) {\n this.id = moduleName;\n this.bundle = newRequire;\n this.require = nodeRequire;\n this.exports = {};\n }\n\n newRequire.isParcelRequire = true;\n newRequire.Module = Module;\n newRequire.modules = modules;\n newRequire.cache = cache;\n newRequire.parent = previousRequire;\n newRequire.distDir = distDir;\n newRequire.publicUrl = publicUrl;\n newRequire.devServer = devServer;\n newRequire.i = importMap;\n newRequire.register = function (id, exports) {\n modules[id] = [\n function (require, module) {\n module.exports = exports;\n },\n {},\n ];\n };\n\n // Only insert newRequire.load when it is actually used.\n // The code in this file is linted against ES5, so dynamic import is not allowed.\n // INSERT_LOAD_HERE\n\n Object.defineProperty(newRequire, 'root', {\n get: function () {\n return globalObject[parcelRequireName];\n },\n });\n\n globalObject[parcelRequireName] = newRequire;\n\n for (var i = 0; i < entry.length; i++) {\n newRequire(entry[i]);\n }\n\n if (mainEntry) {\n // Expose entry point to Node, AMD or browser globals\n // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js\n var mainExports = newRequire(mainEntry);\n\n // CommonJS\n if (typeof exports === 'object' && typeof module !== 'undefined') {\n module.exports = mainExports;\n\n // RequireJS\n } else if (typeof define === 'function' && define.amd) {\n define(function () {\n return mainExports;\n });\n }\n }\n})({\"bKI9O\":[function(require,module,exports,__globalThis) {\nvar parcelHelpers = require(\"@parcel/transformer-js/src/esmodule-helpers.js\");\nparcelHelpers.defineInteropFlag(exports);\nparcelHelpers.export(exports, \"default\", ()=>artplayerPluginDocumentPip);\nfunction artplayerPluginDocumentPip(userOptions = {}) {\n const options = {\n width: 480,\n height: 270,\n fallbackToVideoPiP: true,\n placeholder: `Playing in Document Picture-in-Picture`,\n ...userOptions\n };\n return (art)=>{\n const dpipOK = 'documentPictureInPicture' in window && typeof window.documentPictureInPicture?.requestWindow === 'function';\n const { proxy, icons, i18n, template: { $container }, constructor: { utils: { append, tooltip, addClass, removeClass } } } = art;\n const state = {\n win: null,\n originalParent: null,\n originalNext: null,\n currentDoc: null,\n placeholder: null\n };\n function copyStylesTo(targetDoc) {\n const base = targetDoc.createElement('style');\n base.textContent = `\n html, body { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; }\n #__art_dpip_root { position:absolute; inset:0; display:flex; }\n #__art_dpip_root > * { width:100% !important; height:100% !important; }\n `;\n targetDoc.head.appendChild(base);\n if (!targetDoc.querySelector('meta[name=\"viewport\"]')) {\n const meta = targetDoc.createElement('meta');\n meta.name = 'viewport';\n meta.content = 'width=device-width,initial-scale=1';\n targetDoc.head.appendChild(meta);\n }\n try {\n document.querySelectorAll('link[rel=\"stylesheet\"]').forEach((link)=>{\n const clone = targetDoc.createElement('link');\n clone.rel = 'stylesheet';\n clone.href = link.href;\n if (link.media) clone.media = link.media;\n if (link.crossOrigin) clone.crossOrigin = link.crossOrigin;\n if (link.referrerPolicy) clone.referrerPolicy = link.referrerPolicy;\n targetDoc.head.appendChild(clone);\n });\n } catch {}\n try {\n document.querySelectorAll('style').forEach((style)=>{\n const clone = targetDoc.createElement('style');\n clone.textContent = style.textContent;\n targetDoc.head.appendChild(clone);\n });\n } catch {}\n }\n async function open() {\n if (!dpipOK && options.fallbackToVideoPiP) {\n art.pip = true;\n console.warn('[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture');\n return;\n }\n if (state.win) return;\n try {\n const pipWin = await window.documentPictureInPicture.requestWindow({\n width: options.width,\n height: options.height\n });\n state.win = pipWin;\n state.currentDoc = pipWin.document;\n state.placeholder = document.createElement('div');\n state.placeholder.className = 'artplayer-pip-placeholder';\n state.placeholder.style.cssText = `display:flex;justify-content:center;align-items:center;width:100%;height:100%;`;\n state.placeholder.textContent = options.placeholder;\n state.originalParent = $container.parentNode;\n state.originalNext = $container.nextSibling;\n state.originalParent.insertBefore(state.placeholder, state.originalNext);\n const root = pipWin.document.createElement('div');\n root.id = '__art_dpip_root';\n pipWin.document.body.appendChild(root);\n copyStylesTo(pipWin.document);\n const adopted = pipWin.document.adoptNode($container);\n root.appendChild(adopted);\n state.currentDoc = pipWin.document;\n const onResize = ()=>art.resize?.();\n const onClose = ()=>close();\n pipWin.addEventListener('resize', onResize);\n pipWin.addEventListener('pagehide', onClose);\n pipWin.addEventListener('unload', onClose);\n state.cleanup = ()=>{\n pipWin.removeEventListener('resize', onResize);\n pipWin.removeEventListener('pagehide', onClose);\n pipWin.removeEventListener('unload', onClose);\n };\n addClass($container, 'artplayer-document-pip');\n art.emit('document-pip', true);\n } catch (err) {\n art.notice.show = 'Document Picture-in-Picture open failed';\n console.warn('[artplayer-plugin-document-pip] open failed:', err);\n }\n }\n function restoreToOriginalDocument() {\n if (!state.placeholder) return;\n const backDoc = state.placeholder.ownerDocument || document;\n const adoptedBack = backDoc.adoptNode($container);\n state.originalParent.insertBefore(adoptedBack, state.placeholder);\n state.placeholder.remove();\n state.placeholder = null;\n state.currentDoc = backDoc;\n }\n function close() {\n if (!dpipOK && options.fallbackToVideoPiP) {\n art.pip = false;\n return;\n }\n if (!state.win) return;\n try {\n state.cleanup?.();\n restoreToOriginalDocument();\n state.win.close();\n state.win = null;\n removeClass($container, 'artplayer-document-pip');\n art.emit('document-pip', false);\n } catch (err) {\n art.notice.show = 'Document Picture-in-Picture close failed';\n console.warn('[artplayer-plugin-document-pip] close failed:', err);\n }\n }\n function toggle() {\n if (state.win) close();\n else open();\n }\n art.controls.add({\n name: 'document-pip',\n position: 'right',\n index: 40,\n tooltip: art.i18n.get('PIP Mode'),\n mounted: ($control)=>{\n append($control, icons.pip);\n proxy($control, 'click', toggle);\n art.on('document-pip', (value)=>{\n tooltip($control, i18n.get(value ? 'Exit PIP Mode' : 'PIP Mode'));\n });\n }\n });\n art.on('destroy', close);\n return {\n name: 'artplayerPluginDocumentPip',\n state,\n open,\n close,\n toggle\n };\n };\n}\nif (typeof window !== 'undefined') window.artplayerPluginDocumentPip = artplayerPluginDocumentPip;\n\n},{\"@parcel/transformer-js/src/esmodule-helpers.js\":\"5lQoW\"}],\"5lQoW\":[function(require,module,exports,__globalThis) {\nexports.interopDefault = function(a) {\n return a && a.__esModule ? a : {\n default: a\n };\n};\nexports.defineInteropFlag = function(a) {\n Object.defineProperty(a, '__esModule', {\n value: true\n });\n};\nexports.exportAll = function(source, dest) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule' || Object.prototype.hasOwnProperty.call(dest, key)) return;\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function() {\n return source[key];\n }\n });\n });\n return dest;\n};\nexports.export = function(dest, destName, get) {\n Object.defineProperty(dest, destName, {\n enumerable: true,\n get: get\n });\n};\n\n},{}]},[\"bKI9O\"], \"bKI9O\", \"parcelRequire4dc0\", {})\nlet {default: _default, } = parcelRequire4dc0(\"bKI9O\");\nexport {_default as default, };\n\n//# sourceMappingURL=index.js.map\n","export default function artplayerPluginDocumentPip(userOptions = {}) {\n const options = {\n width: 480,\n height: 270,\n fallbackToVideoPiP: true,\n placeholder: `Playing in Document Picture-in-Picture`,\n ...userOptions,\n }\n\n return (art) => {\n const dpipOK = 'documentPictureInPicture' in window\n && typeof window.documentPictureInPicture?.requestWindow === 'function'\n\n const { proxy, icons, i18n, template: { $container }, constructor: { utils: { append, tooltip, addClass, removeClass } } } = art\n\n const state = {\n win: null,\n originalParent: null,\n originalNext: null,\n currentDoc: null,\n placeholder: null,\n }\n\n function copyStylesTo(targetDoc) {\n const base = targetDoc.createElement('style')\n base.textContent = `\n html, body { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; }\n #__art_dpip_root { position:absolute; inset:0; display:flex; }\n #__art_dpip_root > * { width:100% !important; height:100% !important; }\n `\n targetDoc.head.appendChild(base)\n if (!targetDoc.querySelector('meta[name=\"viewport\"]')) {\n const meta = targetDoc.createElement('meta')\n meta.name = 'viewport'\n meta.content = 'width=device-width,initial-scale=1'\n targetDoc.head.appendChild(meta)\n }\n\n try {\n document.querySelectorAll('link[rel=\"stylesheet\"]').forEach((link) => {\n const clone = targetDoc.createElement('link')\n clone.rel = 'stylesheet'\n clone.href = link.href\n if (link.media)\n clone.media = link.media\n if (link.crossOrigin)\n clone.crossOrigin = link.crossOrigin\n if (link.referrerPolicy)\n clone.referrerPolicy = link.referrerPolicy\n targetDoc.head.appendChild(clone)\n })\n }\n catch { }\n\n try {\n document.querySelectorAll('style').forEach((style) => {\n const clone = targetDoc.createElement('style')\n clone.textContent = style.textContent\n targetDoc.head.appendChild(clone)\n })\n }\n catch { }\n }\n\n async function open() {\n if (!dpipOK && options.fallbackToVideoPiP) {\n art.pip = true\n console.warn('[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture')\n return\n }\n\n if (state.win)\n return\n\n try {\n const pipWin = await window.documentPictureInPicture.requestWindow({\n width: options.width,\n height: options.height,\n })\n\n state.win = pipWin\n state.currentDoc = pipWin.document\n\n state.placeholder = document.createElement('div')\n state.placeholder.className = 'artplayer-pip-placeholder'\n state.placeholder.style.cssText = `display:flex;justify-content:center;align-items:center;width:100%;height:100%;`\n state.placeholder.textContent = options.placeholder\n state.originalParent = $container.parentNode\n state.originalNext = $container.nextSibling\n state.originalParent.insertBefore(state.placeholder, state.originalNext)\n\n const root = pipWin.document.createElement('div')\n root.id = '__art_dpip_root'\n pipWin.document.body.appendChild(root)\n\n copyStylesTo(pipWin.document)\n\n const adopted = pipWin.document.adoptNode($container)\n root.appendChild(adopted)\n state.currentDoc = pipWin.document\n\n const onResize = () => art.resize?.()\n const onClose = () => close()\n\n pipWin.addEventListener('resize', onResize)\n pipWin.addEventListener('pagehide', onClose)\n pipWin.addEventListener('unload', onClose)\n\n state.cleanup = () => {\n pipWin.removeEventListener('resize', onResize)\n pipWin.removeEventListener('pagehide', onClose)\n pipWin.removeEventListener('unload', onClose)\n }\n\n addClass($container, 'artplayer-document-pip')\n art.emit('document-pip', true)\n }\n catch (err) {\n art.notice.show = 'Document Picture-in-Picture open failed'\n console.warn('[artplayer-plugin-document-pip] open failed:', err)\n }\n }\n\n function restoreToOriginalDocument() {\n if (!state.placeholder)\n return\n const backDoc = state.placeholder.ownerDocument || document\n const adoptedBack = backDoc.adoptNode($container)\n state.originalParent.insertBefore(adoptedBack, state.placeholder)\n state.placeholder.remove()\n state.placeholder = null\n state.currentDoc = backDoc\n }\n\n function close() {\n if (!dpipOK && options.fallbackToVideoPiP) {\n art.pip = false\n return\n }\n\n if (!state.win)\n return\n try {\n state.cleanup?.()\n restoreToOriginalDocument()\n state.win.close()\n state.win = null\n removeClass($container, 'artplayer-document-pip')\n art.emit('document-pip', false)\n }\n catch (err) {\n art.notice.show = 'Document Picture-in-Picture close failed'\n console.warn('[artplayer-plugin-document-pip] close failed:', err)\n }\n }\n\n function toggle() {\n if (state.win) {\n close()\n }\n else {\n open()\n }\n }\n\n art.controls.add({\n name: 'document-pip',\n position: 'right',\n index: 40,\n tooltip: art.i18n.get('PIP Mode'),\n mounted: ($control) => {\n append($control, icons.pip)\n proxy($control, 'click', toggle)\n art.on('document-pip', (value) => {\n tooltip($control, i18n.get(value ? 'Exit PIP Mode' : 'PIP Mode'))\n })\n },\n })\n\n art.on('destroy', close)\n\n return {\n name: 'artplayerPluginDocumentPip',\n state,\n open,\n close,\n toggle,\n }\n }\n}\n\nif (typeof window !== 'undefined') {\n window.artplayerPluginDocumentPip = artplayerPluginDocumentPip\n}\n","exports.interopDefault = function (a) {\n return a && a.__esModule ? a : {default: a};\n};\n\nexports.defineInteropFlag = function (a) {\n Object.defineProperty(a, '__esModule', {value: true});\n};\n\nexports.exportAll = function (source, dest) {\n Object.keys(source).forEach(function (key) {\n if (\n key === 'default' ||\n key === '__esModule' ||\n Object.prototype.hasOwnProperty.call(dest, key)\n ) {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function () {\n return source[key];\n },\n });\n });\n\n return dest;\n};\n\nexports.export = function (dest, destName, get) {\n Object.defineProperty(dest, destName, {\n enumerable: true,\n get: get,\n });\n};\n"],"names":["modules","entry","mainEntry","parcelRequireName","externals","distDir","publicUrl","devServer","globalObject","globalThis","self","window","global","previousRequire","importMap","i","cache","nodeRequire","module","require","bind","newRequire","name","jumped","currentRequire","err","Error","code","localRequire","resolve","x","id","Module","call","exports","res","isParcelRequire","moduleName","bundle","parent","register","Object","defineProperty","get","length","mainExports","define","amd","__globalThis","parcelHelpers","artplayerPluginDocumentPip","userOptions","options","width","height","fallbackToVideoPiP","placeholder","art","dpipOK","documentPictureInPicture","requestWindow","proxy","icons","i18n","template","$container","utils","append","tooltip","addClass","removeClass","state","win","originalParent","originalNext","currentDoc","open","pip","console","warn","pipWin","document","createElement","className","style","cssText","textContent","parentNode","nextSibling","insertBefore","root","body","appendChild","targetDoc","base","head","querySelector","meta","content","querySelectorAll","forEach","link","clone","rel","href","media","crossOrigin","referrerPolicy","adopted","adoptNode","onResize","resize","onClose","close","addEventListener","cleanup","removeEventListener","emit","notice","show","restoreToOriginalDocument","backDoc","ownerDocument","adoptedBack","remove","toggle","controls","add","position","index","mounted","$control","on","value","defineInteropFlag","export","interopDefault","a","__esModule","default","exportAll","source","dest","keys","key","prototype","hasOwnProperty","enumerable","destName","_default","parcelRequire4dc0"],"version":3,"file":"index.js.map"} \ No newline at end of file +{"mappings":"C,A,S,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,E,I,E,A,a,O,W,W,A,a,O,K,K,A,a,O,O,O,A,a,O,O,O,C,E,E,A,Y,O,C,C,E,E,C,C,E,C,E,E,C,E,C,E,E,E,K,E,C,E,E,A,a,O,Q,A,Y,O,O,O,E,O,O,C,I,C,Q,S,E,C,C,C,E,G,C,C,C,E,C,C,G,C,C,C,E,C,C,G,C,C,E,C,O,C,C,E,C,I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S,CAAC,CAC5C,EAEA,EAAQ,iBAAiB,CAAG,SAAU,CAAC,EACrC,OAAO,cAAc,CAAC,EAAG,aAAc,CAAC,MAAO,CAAA,CAAI,EACrD,EAEA,EAAQ,SAAS,CAAG,SAAU,CAAM,CAAE,CAAI,EAkBxC,OAjBA,OAAO,IAAI,CAAC,GAAQ,OAAO,CAAC,SAAU,CAAG,EAE7B,YAAR,GACA,AAAQ,eAAR,GACA,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,EAAM,IAK7C,OAAO,cAAc,CAAC,EAAM,EAAK,CAC/B,WAAY,CAAA,EACZ,IAAK,WACH,OAAO,CAAM,CAAC,EAAI,AACpB,CACF,EACF,GAEO,CACT,EAEA,EAAQ,MAAM,CAAG,SAAU,CAAI,CAAE,CAAQ,CAAE,CAAG,EAC5C,OAAO,cAAc,CAAC,EAAM,EAAU,CACpC,WAAY,CAAA,EACZ,IAAK,CACP,EACF,C,E,C,E,E,C,Q,C,Q,oB,C,G,G,C,Q,C,C,C,kB,gB,K,O","sources":["","packages/artplayer-plugin-document-pip/src/index.js","node_modules/@parcel/transformer-js/src/esmodule-helpers.js"],"sourcesContent":["// modules are defined as an array\n// [ module function, map of requires ]\n//\n// map of requires is short require name -> numeric require\n//\n// anything defined in a previous bundle is accessed via the\n// orig method which is the require for previous bundles\n\n(function (\n modules,\n entry,\n mainEntry,\n parcelRequireName,\n externals,\n distDir,\n publicUrl,\n devServer\n) {\n /* eslint-disable no-undef */\n var globalObject =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n /* eslint-enable no-undef */\n\n // Save the require from previous bundle to this closure if any\n var previousRequire =\n typeof globalObject[parcelRequireName] === 'function' &&\n globalObject[parcelRequireName];\n\n var importMap = previousRequire.i || {};\n var cache = previousRequire.cache || {};\n // Do not use `require` to prevent Webpack from trying to bundle this call\n var nodeRequire =\n typeof module !== 'undefined' &&\n typeof module.require === 'function' &&\n module.require.bind(module);\n\n function newRequire(name, jumped) {\n if (!cache[name]) {\n if (!modules[name]) {\n if (externals[name]) {\n return externals[name];\n }\n // if we cannot find the module within our internal map or\n // cache jump to the current global require ie. the last bundle\n // that was added to the page.\n var currentRequire =\n typeof globalObject[parcelRequireName] === 'function' &&\n globalObject[parcelRequireName];\n if (!jumped && currentRequire) {\n return currentRequire(name, true);\n }\n\n // If there are other bundles on this page the require from the\n // previous one is saved to 'previousRequire'. Repeat this as\n // many times as there are bundles until the module is found or\n // we exhaust the require chain.\n if (previousRequire) {\n return previousRequire(name, true);\n }\n\n // Try the node require function if it exists.\n if (nodeRequire && typeof name === 'string') {\n return nodeRequire(name);\n }\n\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n }\n\n localRequire.resolve = resolve;\n localRequire.cache = {};\n\n var module = (cache[name] = new newRequire.Module(name));\n\n modules[name][0].call(\n module.exports,\n localRequire,\n module,\n module.exports,\n globalObject\n );\n }\n\n return cache[name].exports;\n\n function localRequire(x) {\n var res = localRequire.resolve(x);\n return res === false ? {} : newRequire(res);\n }\n\n function resolve(x) {\n var id = modules[name][1][x];\n return id != null ? id : x;\n }\n }\n\n function Module(moduleName) {\n this.id = moduleName;\n this.bundle = newRequire;\n this.require = nodeRequire;\n this.exports = {};\n }\n\n newRequire.isParcelRequire = true;\n newRequire.Module = Module;\n newRequire.modules = modules;\n newRequire.cache = cache;\n newRequire.parent = previousRequire;\n newRequire.distDir = distDir;\n newRequire.publicUrl = publicUrl;\n newRequire.devServer = devServer;\n newRequire.i = importMap;\n newRequire.register = function (id, exports) {\n modules[id] = [\n function (require, module) {\n module.exports = exports;\n },\n {},\n ];\n };\n\n // Only insert newRequire.load when it is actually used.\n // The code in this file is linted against ES5, so dynamic import is not allowed.\n // INSERT_LOAD_HERE\n\n Object.defineProperty(newRequire, 'root', {\n get: function () {\n return globalObject[parcelRequireName];\n },\n });\n\n globalObject[parcelRequireName] = newRequire;\n\n for (var i = 0; i < entry.length; i++) {\n newRequire(entry[i]);\n }\n\n if (mainEntry) {\n // Expose entry point to Node, AMD or browser globals\n // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js\n var mainExports = newRequire(mainEntry);\n\n // CommonJS\n if (typeof exports === 'object' && typeof module !== 'undefined') {\n module.exports = mainExports;\n\n // RequireJS\n } else if (typeof define === 'function' && define.amd) {\n define(function () {\n return mainExports;\n });\n }\n }\n})({\"bKI9O\":[function(require,module,exports,__globalThis) {\nvar parcelHelpers = require(\"@parcel/transformer-js/src/esmodule-helpers.js\");\nparcelHelpers.defineInteropFlag(exports);\nparcelHelpers.export(exports, \"default\", ()=>artplayerPluginDocumentPip);\nfunction artplayerPluginDocumentPip(userOptions = {}) {\n const options = {\n width: 480,\n height: 270,\n fallbackToVideoPiP: true,\n placeholder: `Playing in Document Picture-in-Picture`,\n ...userOptions\n };\n return (art)=>{\n const isSupported = 'documentPictureInPicture' in window && typeof window.documentPictureInPicture?.requestWindow === 'function';\n const { proxy, icons, i18n, template: { $container }, constructor: { utils: { append, tooltip, addClass, removeClass } } } = art;\n const state = {\n win: null,\n originalParent: null,\n originalNext: null,\n currentDoc: null,\n placeholder: null\n };\n function copyStylesTo(targetDoc) {\n const base = targetDoc.createElement('style');\n base.textContent = `\n html, body { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; }\n #__art_dpip_root { position:absolute; inset:0; display:flex; }\n #__art_dpip_root > * { width:100% !important; height:100% !important; }\n `;\n targetDoc.head.appendChild(base);\n if (!targetDoc.querySelector('meta[name=\"viewport\"]')) {\n const meta = targetDoc.createElement('meta');\n meta.name = 'viewport';\n meta.content = 'width=device-width,initial-scale=1';\n targetDoc.head.appendChild(meta);\n }\n try {\n document.querySelectorAll('link[rel=\"stylesheet\"]').forEach((link)=>{\n const clone = targetDoc.createElement('link');\n clone.rel = 'stylesheet';\n clone.href = link.href;\n if (link.media) clone.media = link.media;\n if (link.crossOrigin) clone.crossOrigin = link.crossOrigin;\n if (link.referrerPolicy) clone.referrerPolicy = link.referrerPolicy;\n targetDoc.head.appendChild(clone);\n });\n } catch {}\n try {\n document.querySelectorAll('style').forEach((style)=>{\n const clone = targetDoc.createElement('style');\n clone.textContent = style.textContent;\n targetDoc.head.appendChild(clone);\n });\n } catch {}\n }\n async function open() {\n if (!isSupported && options.fallbackToVideoPiP) {\n art.pip = true;\n console.warn('[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture');\n return;\n }\n if (state.win) return;\n try {\n const pipWin = await window.documentPictureInPicture.requestWindow({\n width: options.width,\n height: options.height\n });\n state.win = pipWin;\n state.currentDoc = pipWin.document;\n state.placeholder = document.createElement('div');\n state.placeholder.className = 'artplayer-pip-placeholder';\n state.placeholder.style.cssText = `display:flex;justify-content:center;align-items:center;width:100%;height:100%;`;\n state.placeholder.textContent = options.placeholder;\n state.originalParent = $container.parentNode;\n state.originalNext = $container.nextSibling;\n state.originalParent.insertBefore(state.placeholder, state.originalNext);\n const root = pipWin.document.createElement('div');\n root.id = '__art_dpip_root';\n pipWin.document.body.appendChild(root);\n copyStylesTo(pipWin.document);\n const adopted = pipWin.document.adoptNode($container);\n root.appendChild(adopted);\n state.currentDoc = pipWin.document;\n const onResize = ()=>art.resize?.();\n const onClose = ()=>close();\n pipWin.addEventListener('resize', onResize);\n pipWin.addEventListener('pagehide', onClose);\n pipWin.addEventListener('unload', onClose);\n state.cleanup = ()=>{\n pipWin.removeEventListener('resize', onResize);\n pipWin.removeEventListener('pagehide', onClose);\n pipWin.removeEventListener('unload', onClose);\n };\n addClass($container, 'artplayer-document-pip');\n art.emit('document-pip', true);\n } catch (err) {\n art.notice.show = 'Document Picture-in-Picture open failed';\n console.warn('[artplayer-plugin-document-pip] open failed:', err);\n }\n }\n function restoreToOriginalDocument() {\n if (!state.placeholder) return;\n const backDoc = state.placeholder.ownerDocument || document;\n const adoptedBack = backDoc.adoptNode($container);\n state.originalParent.insertBefore(adoptedBack, state.placeholder);\n state.placeholder.remove();\n state.placeholder = null;\n state.currentDoc = backDoc;\n }\n function close() {\n if (!state.win) return;\n try {\n state.cleanup?.();\n restoreToOriginalDocument();\n state.win.close();\n state.win = null;\n removeClass($container, 'artplayer-document-pip');\n art.emit('document-pip', false);\n } catch (err) {\n art.notice.show = 'Document Picture-in-Picture close failed';\n console.warn('[artplayer-plugin-document-pip] close failed:', err);\n }\n }\n function toggle() {\n if (state.win) close();\n else open();\n }\n art.controls.add({\n name: 'document-pip',\n position: 'right',\n index: 40,\n tooltip: art.i18n.get('PIP Mode'),\n mounted: ($control)=>{\n append($control, icons.pip);\n proxy($control, 'click', toggle);\n art.on('document-pip', (value)=>{\n tooltip($control, i18n.get(value ? 'Exit PIP Mode' : 'PIP Mode'));\n });\n }\n });\n art.on('destroy', close);\n return {\n name: 'artplayerPluginDocumentPip',\n get isSupported () {\n return isSupported;\n },\n get isActive () {\n return !!state.win;\n },\n open,\n close,\n toggle\n };\n };\n}\nif (typeof window !== 'undefined') window.artplayerPluginDocumentPip = artplayerPluginDocumentPip;\n\n},{\"@parcel/transformer-js/src/esmodule-helpers.js\":\"5lQoW\"}],\"5lQoW\":[function(require,module,exports,__globalThis) {\nexports.interopDefault = function(a) {\n return a && a.__esModule ? a : {\n default: a\n };\n};\nexports.defineInteropFlag = function(a) {\n Object.defineProperty(a, '__esModule', {\n value: true\n });\n};\nexports.exportAll = function(source, dest) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule' || Object.prototype.hasOwnProperty.call(dest, key)) return;\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function() {\n return source[key];\n }\n });\n });\n return dest;\n};\nexports.export = function(dest, destName, get) {\n Object.defineProperty(dest, destName, {\n enumerable: true,\n get: get\n });\n};\n\n},{}]},[\"bKI9O\"], \"bKI9O\", \"parcelRequire4dc0\", {})\nlet {default: _default, } = parcelRequire4dc0(\"bKI9O\");\nexport {_default as default, };\n\n//# sourceMappingURL=index.js.map\n","export default function artplayerPluginDocumentPip(userOptions = {}) {\n const options = {\n width: 480,\n height: 270,\n fallbackToVideoPiP: true,\n placeholder: `Playing in Document Picture-in-Picture`,\n ...userOptions,\n }\n\n return (art) => {\n const isSupported = 'documentPictureInPicture' in window\n && typeof window.documentPictureInPicture?.requestWindow === 'function'\n\n const { proxy, icons, i18n, template: { $container }, constructor: { utils: { append, tooltip, addClass, removeClass } } } = art\n\n const state = {\n win: null,\n originalParent: null,\n originalNext: null,\n currentDoc: null,\n placeholder: null,\n }\n\n function copyStylesTo(targetDoc) {\n const base = targetDoc.createElement('style')\n base.textContent = `\n html, body { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; }\n #__art_dpip_root { position:absolute; inset:0; display:flex; }\n #__art_dpip_root > * { width:100% !important; height:100% !important; }\n `\n targetDoc.head.appendChild(base)\n if (!targetDoc.querySelector('meta[name=\"viewport\"]')) {\n const meta = targetDoc.createElement('meta')\n meta.name = 'viewport'\n meta.content = 'width=device-width,initial-scale=1'\n targetDoc.head.appendChild(meta)\n }\n\n try {\n document.querySelectorAll('link[rel=\"stylesheet\"]').forEach((link) => {\n const clone = targetDoc.createElement('link')\n clone.rel = 'stylesheet'\n clone.href = link.href\n if (link.media)\n clone.media = link.media\n if (link.crossOrigin)\n clone.crossOrigin = link.crossOrigin\n if (link.referrerPolicy)\n clone.referrerPolicy = link.referrerPolicy\n targetDoc.head.appendChild(clone)\n })\n }\n catch { }\n\n try {\n document.querySelectorAll('style').forEach((style) => {\n const clone = targetDoc.createElement('style')\n clone.textContent = style.textContent\n targetDoc.head.appendChild(clone)\n })\n }\n catch { }\n }\n\n async function open() {\n if (!isSupported && options.fallbackToVideoPiP) {\n art.pip = true\n console.warn('[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture')\n return\n }\n\n if (state.win)\n return\n\n try {\n const pipWin = await window.documentPictureInPicture.requestWindow({\n width: options.width,\n height: options.height,\n })\n\n state.win = pipWin\n state.currentDoc = pipWin.document\n\n state.placeholder = document.createElement('div')\n state.placeholder.className = 'artplayer-pip-placeholder'\n state.placeholder.style.cssText = `display:flex;justify-content:center;align-items:center;width:100%;height:100%;`\n state.placeholder.textContent = options.placeholder\n state.originalParent = $container.parentNode\n state.originalNext = $container.nextSibling\n state.originalParent.insertBefore(state.placeholder, state.originalNext)\n\n const root = pipWin.document.createElement('div')\n root.id = '__art_dpip_root'\n pipWin.document.body.appendChild(root)\n\n copyStylesTo(pipWin.document)\n\n const adopted = pipWin.document.adoptNode($container)\n root.appendChild(adopted)\n state.currentDoc = pipWin.document\n\n const onResize = () => art.resize?.()\n const onClose = () => close()\n\n pipWin.addEventListener('resize', onResize)\n pipWin.addEventListener('pagehide', onClose)\n pipWin.addEventListener('unload', onClose)\n\n state.cleanup = () => {\n pipWin.removeEventListener('resize', onResize)\n pipWin.removeEventListener('pagehide', onClose)\n pipWin.removeEventListener('unload', onClose)\n }\n\n addClass($container, 'artplayer-document-pip')\n art.emit('document-pip', true)\n }\n catch (err) {\n art.notice.show = 'Document Picture-in-Picture open failed'\n console.warn('[artplayer-plugin-document-pip] open failed:', err)\n }\n }\n\n function restoreToOriginalDocument() {\n if (!state.placeholder)\n return\n const backDoc = state.placeholder.ownerDocument || document\n const adoptedBack = backDoc.adoptNode($container)\n state.originalParent.insertBefore(adoptedBack, state.placeholder)\n state.placeholder.remove()\n state.placeholder = null\n state.currentDoc = backDoc\n }\n\n function close() {\n if (!state.win)\n return\n try {\n state.cleanup?.()\n restoreToOriginalDocument()\n state.win.close()\n state.win = null\n removeClass($container, 'artplayer-document-pip')\n art.emit('document-pip', false)\n }\n catch (err) {\n art.notice.show = 'Document Picture-in-Picture close failed'\n console.warn('[artplayer-plugin-document-pip] close failed:', err)\n }\n }\n\n function toggle() {\n if (state.win) {\n close()\n }\n else {\n open()\n }\n }\n\n art.controls.add({\n name: 'document-pip',\n position: 'right',\n index: 40,\n tooltip: art.i18n.get('PIP Mode'),\n mounted: ($control) => {\n append($control, icons.pip)\n proxy($control, 'click', toggle)\n art.on('document-pip', (value) => {\n tooltip($control, i18n.get(value ? 'Exit PIP Mode' : 'PIP Mode'))\n })\n },\n })\n\n art.on('destroy', close)\n\n return {\n name: 'artplayerPluginDocumentPip',\n get isSupported() { return isSupported },\n get isActive() { return !!state.win },\n open,\n close,\n toggle,\n }\n }\n}\n\nif (typeof window !== 'undefined') {\n window.artplayerPluginDocumentPip = artplayerPluginDocumentPip\n}\n","exports.interopDefault = function (a) {\n return a && a.__esModule ? a : {default: a};\n};\n\nexports.defineInteropFlag = function (a) {\n Object.defineProperty(a, '__esModule', {value: true});\n};\n\nexports.exportAll = function (source, dest) {\n Object.keys(source).forEach(function (key) {\n if (\n key === 'default' ||\n key === '__esModule' ||\n Object.prototype.hasOwnProperty.call(dest, key)\n ) {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function () {\n return source[key];\n },\n });\n });\n\n return dest;\n};\n\nexports.export = function (dest, destName, get) {\n Object.defineProperty(dest, destName, {\n enumerable: true,\n get: get,\n });\n};\n"],"names":["modules","entry","mainEntry","parcelRequireName","externals","distDir","publicUrl","devServer","globalObject","globalThis","self","window","global","previousRequire","importMap","i","cache","nodeRequire","module","require","bind","newRequire","name","jumped","currentRequire","err","Error","code","localRequire","resolve","x","id","Module","call","exports","res","isParcelRequire","moduleName","bundle","parent","register","Object","defineProperty","get","length","mainExports","define","amd","__globalThis","parcelHelpers","artplayerPluginDocumentPip","userOptions","options","width","height","fallbackToVideoPiP","placeholder","art","isSupported","documentPictureInPicture","requestWindow","proxy","icons","i18n","template","$container","utils","append","tooltip","addClass","removeClass","state","win","originalParent","originalNext","currentDoc","open","pip","console","warn","pipWin","document","createElement","className","style","cssText","textContent","parentNode","nextSibling","insertBefore","root","body","appendChild","targetDoc","base","head","querySelector","meta","content","querySelectorAll","forEach","link","clone","rel","href","media","crossOrigin","referrerPolicy","adopted","adoptNode","onResize","resize","onClose","close","addEventListener","cleanup","removeEventListener","emit","notice","show","restoreToOriginalDocument","backDoc","ownerDocument","adoptedBack","remove","toggle","controls","add","position","index","mounted","$control","on","value","isActive","defineInteropFlag","export","interopDefault","a","__esModule","default","exportAll","source","dest","keys","key","prototype","hasOwnProperty","enumerable","destName","_default","parcelRequire4dc0"],"version":3,"file":"index.js.map"} \ No newline at end of file diff --git a/docs/compiled/artplayer-plugin-document-pip.js b/docs/compiled/artplayer-plugin-document-pip.js index 64826e0ec..a7cc112a7 100644 --- a/docs/compiled/artplayer-plugin-document-pip.js +++ b/docs/compiled/artplayer-plugin-document-pip.js @@ -5,4 +5,4 @@ * (c) 2017-2025 Harvey Zack * Released under the MIT License. */ -!function(e,t,n,r,i,o,l,c){var d="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},a="function"==typeof d[r]&&d[r],u=a.i||{},p=a.cache||{},f="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function s(t,n){if(!p[t]){if(!e[t]){if(i[t])return i[t];var o="function"==typeof d[r]&&d[r];if(!n&&o)return o(t,!0);if(a)return a(t,!0);if(f&&"string"==typeof t)return f(t);var l=Error("Cannot find module '"+t+"'");throw l.code="MODULE_NOT_FOUND",l}u.resolve=function(n){var r=e[t][1][n];return null!=r?r:n},u.cache={};var c=p[t]=new s.Module(t);e[t][0].call(c.exports,u,c,c.exports,d)}return p[t].exports;function u(e){var t=u.resolve(e);return!1===t?{}:s(t)}}s.isParcelRequire=!0,s.Module=function(e){this.id=e,this.bundle=s,this.require=f,this.exports={}},s.modules=e,s.cache=p,s.parent=a,s.distDir=void 0,s.publicUrl=void 0,s.devServer=void 0,s.i=u,s.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(s,"root",{get:function(){return d[r]}}),d[r]=s;for(var h=0;h{let n="documentPictureInPicture"in window&&"function"==typeof window.documentPictureInPicture?.requestWindow,{proxy:r,icons:i,i18n:o,template:{$container:l},constructor:{utils:{append:c,tooltip:d,addClass:a,removeClass:u}}}=e,p={win:null,originalParent:null,originalNext:null,currentDoc:null,placeholder:null};async function f(){if(!n&&t.fallbackToVideoPiP){e.pip=!0,console.warn("[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture");return}if(!p.win)try{let n=await window.documentPictureInPicture.requestWindow({width:t.width,height:t.height});p.win=n,p.currentDoc=n.document,p.placeholder=document.createElement("div"),p.placeholder.className="artplayer-pip-placeholder",p.placeholder.style.cssText="display:flex;justify-content:center;align-items:center;width:100%;height:100%;",p.placeholder.textContent=t.placeholder,p.originalParent=l.parentNode,p.originalNext=l.nextSibling,p.originalParent.insertBefore(p.placeholder,p.originalNext);let i=n.document.createElement("div");i.id="__art_dpip_root",n.document.body.appendChild(i);var r=n.document;let o=r.createElement("style");if(o.textContent=` html, body { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; } #__art_dpip_root { position:absolute; inset:0; display:flex; } #__art_dpip_root > * { width:100% !important; height:100% !important; } `,r.head.appendChild(o),!r.querySelector('meta[name="viewport"]')){let e=r.createElement("meta");e.name="viewport",e.content="width=device-width,initial-scale=1",r.head.appendChild(e)}try{document.querySelectorAll('link[rel="stylesheet"]').forEach(e=>{let t=r.createElement("link");t.rel="stylesheet",t.href=e.href,e.media&&(t.media=e.media),e.crossOrigin&&(t.crossOrigin=e.crossOrigin),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),r.head.appendChild(t)})}catch{}try{document.querySelectorAll("style").forEach(e=>{let t=r.createElement("style");t.textContent=e.textContent,r.head.appendChild(t)})}catch{}let c=n.document.adoptNode(l);i.appendChild(c),p.currentDoc=n.document;let d=()=>e.resize?.(),u=()=>s();n.addEventListener("resize",d),n.addEventListener("pagehide",u),n.addEventListener("unload",u),p.cleanup=()=>{n.removeEventListener("resize",d),n.removeEventListener("pagehide",u),n.removeEventListener("unload",u)},a(l,"artplayer-document-pip"),e.emit("document-pip",!0)}catch(t){e.notice.show="Document Picture-in-Picture open failed",console.warn("[artplayer-plugin-document-pip] open failed:",t)}}function s(){if(!n&&t.fallbackToVideoPiP){e.pip=!1;return}if(p.win)try{p.cleanup?.(),function(){if(!p.placeholder)return;let e=p.placeholder.ownerDocument||document,t=e.adoptNode(l);p.originalParent.insertBefore(t,p.placeholder),p.placeholder.remove(),p.placeholder=null,p.currentDoc=e}(),p.win.close(),p.win=null,u(l,"artplayer-document-pip"),e.emit("document-pip",!1)}catch(t){e.notice.show="Document Picture-in-Picture close failed",console.warn("[artplayer-plugin-document-pip] close failed:",t)}}function h(){p.win?s():f()}return e.controls.add({name:"document-pip",position:"right",index:40,tooltip:e.i18n.get("PIP Mode"),mounted:t=>{c(t,i.pip),r(t,"click",h),e.on("document-pip",e=>{d(t,o.get(e?"Exit PIP Mode":"PIP Mode"))})}}),e.on("destroy",s),{name:"artplayerPluginDocumentPip",state:p,open:f,close:s,toggle:h}}}i.defineInteropFlag(n),i.export(n,"default",()=>o),"undefined"!=typeof window&&(window.artplayerPluginDocumentPip=o)},{"@parcel/transformer-js/src/esmodule-helpers.js":"6ykb1"}],"6ykb1":[function(e,t,n,r){n.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},n.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.exportAll=function(e,t){return Object.keys(e).forEach(function(n){"default"===n||"__esModule"===n||Object.prototype.hasOwnProperty.call(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[n]}})}),t},n.export=function(e,t,n){Object.defineProperty(e,t,{enumerable:!0,get:n})}},{}]},["eo8f0"],"eo8f0","parcelRequire4dc0",{}); \ No newline at end of file +!function(e,t,n,r,i,o,l,c){var d="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},u="function"==typeof d[r]&&d[r],a=u.i||{},p=u.cache||{},f="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function s(t,n){if(!p[t]){if(!e[t]){if(i[t])return i[t];var o="function"==typeof d[r]&&d[r];if(!n&&o)return o(t,!0);if(u)return u(t,!0);if(f&&"string"==typeof t)return f(t);var l=Error("Cannot find module '"+t+"'");throw l.code="MODULE_NOT_FOUND",l}a.resolve=function(n){var r=e[t][1][n];return null!=r?r:n},a.cache={};var c=p[t]=new s.Module(t);e[t][0].call(c.exports,a,c,c.exports,d)}return p[t].exports;function a(e){var t=a.resolve(e);return!1===t?{}:s(t)}}s.isParcelRequire=!0,s.Module=function(e){this.id=e,this.bundle=s,this.require=f,this.exports={}},s.modules=e,s.cache=p,s.parent=u,s.distDir=void 0,s.publicUrl=void 0,s.devServer=void 0,s.i=a,s.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(s,"root",{get:function(){return d[r]}}),d[r]=s;for(var h=0;h{let n="documentPictureInPicture"in window&&"function"==typeof window.documentPictureInPicture?.requestWindow,{proxy:r,icons:i,i18n:o,template:{$container:l},constructor:{utils:{append:c,tooltip:d,addClass:u,removeClass:a}}}=e,p={win:null,originalParent:null,originalNext:null,currentDoc:null,placeholder:null};async function f(){if(!n&&t.fallbackToVideoPiP){e.pip=!0,console.warn("[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture");return}if(!p.win)try{let n=await window.documentPictureInPicture.requestWindow({width:t.width,height:t.height});p.win=n,p.currentDoc=n.document,p.placeholder=document.createElement("div"),p.placeholder.className="artplayer-pip-placeholder",p.placeholder.style.cssText="display:flex;justify-content:center;align-items:center;width:100%;height:100%;",p.placeholder.textContent=t.placeholder,p.originalParent=l.parentNode,p.originalNext=l.nextSibling,p.originalParent.insertBefore(p.placeholder,p.originalNext);let i=n.document.createElement("div");i.id="__art_dpip_root",n.document.body.appendChild(i);var r=n.document;let o=r.createElement("style");if(o.textContent=` html, body { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; } #__art_dpip_root { position:absolute; inset:0; display:flex; } #__art_dpip_root > * { width:100% !important; height:100% !important; } `,r.head.appendChild(o),!r.querySelector('meta[name="viewport"]')){let e=r.createElement("meta");e.name="viewport",e.content="width=device-width,initial-scale=1",r.head.appendChild(e)}try{document.querySelectorAll('link[rel="stylesheet"]').forEach(e=>{let t=r.createElement("link");t.rel="stylesheet",t.href=e.href,e.media&&(t.media=e.media),e.crossOrigin&&(t.crossOrigin=e.crossOrigin),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),r.head.appendChild(t)})}catch{}try{document.querySelectorAll("style").forEach(e=>{let t=r.createElement("style");t.textContent=e.textContent,r.head.appendChild(t)})}catch{}let c=n.document.adoptNode(l);i.appendChild(c),p.currentDoc=n.document;let d=()=>e.resize?.(),a=()=>s();n.addEventListener("resize",d),n.addEventListener("pagehide",a),n.addEventListener("unload",a),p.cleanup=()=>{n.removeEventListener("resize",d),n.removeEventListener("pagehide",a),n.removeEventListener("unload",a)},u(l,"artplayer-document-pip"),e.emit("document-pip",!0)}catch(t){e.notice.show="Document Picture-in-Picture open failed",console.warn("[artplayer-plugin-document-pip] open failed:",t)}}function s(){if(p.win)try{p.cleanup?.(),function(){if(!p.placeholder)return;let e=p.placeholder.ownerDocument||document,t=e.adoptNode(l);p.originalParent.insertBefore(t,p.placeholder),p.placeholder.remove(),p.placeholder=null,p.currentDoc=e}(),p.win.close(),p.win=null,a(l,"artplayer-document-pip"),e.emit("document-pip",!1)}catch(t){e.notice.show="Document Picture-in-Picture close failed",console.warn("[artplayer-plugin-document-pip] close failed:",t)}}function h(){p.win?s():f()}return e.controls.add({name:"document-pip",position:"right",index:40,tooltip:e.i18n.get("PIP Mode"),mounted:t=>{c(t,i.pip),r(t,"click",h),e.on("document-pip",e=>{d(t,o.get(e?"Exit PIP Mode":"PIP Mode"))})}}),e.on("destroy",s),{name:"artplayerPluginDocumentPip",get isSupported(){return n},get isActive(){return!!p.win},open:f,close:s,toggle:h}}}i.defineInteropFlag(n),i.export(n,"default",()=>o),"undefined"!=typeof window&&(window.artplayerPluginDocumentPip=o)},{"@parcel/transformer-js/src/esmodule-helpers.js":"6ykb1"}],"6ykb1":[function(e,t,n,r){n.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},n.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.exportAll=function(e,t){return Object.keys(e).forEach(function(n){"default"===n||"__esModule"===n||Object.prototype.hasOwnProperty.call(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[n]}})}),t},n.export=function(e,t,n){Object.defineProperty(e,t,{enumerable:!0,get:n})}},{}]},["eo8f0"],"eo8f0","parcelRequire4dc0",{}); \ No newline at end of file diff --git a/docs/compiled/artplayer-plugin-document-pip.legacy.js b/docs/compiled/artplayer-plugin-document-pip.legacy.js index 6ef74aec0..02e1724f0 100644 --- a/docs/compiled/artplayer-plugin-document-pip.legacy.js +++ b/docs/compiled/artplayer-plugin-document-pip.legacy.js @@ -5,4 +5,4 @@ * (c) 2017-2025 Harvey Zack * Released under the MIT License. */ -!function(e,t,r,n,o,i,c,a){var u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},l="function"==typeof u[n]&&u[n],s=l.i||{},f=l.cache||{},p="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function d(t,r){if(!f[t]){if(!e[t]){if(o[t])return o[t];var i="function"==typeof u[n]&&u[n];if(!r&&i)return i(t,!0);if(l)return l(t,!0);if(p&&"string"==typeof t)return p(t);var c=Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}s.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},s.cache={};var a=f[t]=new d.Module(t);e[t][0].call(a.exports,s,a,a.exports,u)}return f[t].exports;function s(e){var t=s.resolve(e);return!1===t?{}:d(t)}}d.isParcelRequire=!0,d.Module=function(e){this.id=e,this.bundle=d,this.require=p,this.exports={}},d.modules=e,d.cache=f,d.parent=l,d.distDir=void 0,d.publicUrl=void 0,d.devServer=void 0,d.i=s,d.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(d,"root",{get:function(){return u[n]}}),u[n]=d;for(var y=0;y0&&void 0!==arguments[0]?arguments[0]:{},t=(0,c._)({width:480,height:270,fallbackToVideoPiP:!0,placeholder:"Playing in Document Picture-in-Picture"},e);return function(e){var r,n="documentPictureInPicture"in window&&"function"==typeof(null==(r=window.documentPictureInPicture)?void 0:r.requestWindow),o=e.proxy,c=e.icons,u=e.i18n,l=e.template.$container,s=e.constructor.utils,f=s.append,p=s.tooltip,d=s.addClass,y=s.removeClass,h={win:null,originalParent:null,originalNext:null,currentDoc:null,placeholder:null};function _(){return(0,i._)(function(){var r,o,i,c,u,s;return(0,a._)(this,function(a){switch(a.label){case 0:if(!n&&t.fallbackToVideoPiP)return e.pip=!0,console.warn("[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture"),[2];if(h.win)return[2];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,window.documentPictureInPicture.requestWindow({width:t.width,height:t.height})];case 2:h.win=r=a.sent(),h.currentDoc=r.document,h.placeholder=document.createElement("div"),h.placeholder.className="artplayer-pip-placeholder",h.placeholder.style.cssText="display:flex;justify-content:center;align-items:center;width:100%;height:100%;",h.placeholder.textContent=t.placeholder,h.originalParent=l.parentNode,h.originalNext=l.nextSibling,h.originalParent.insertBefore(h.placeholder,h.originalNext),(o=r.document.createElement("div")).id="__art_dpip_root",r.document.body.appendChild(o);var f=r.document,p=f.createElement("style");if(p.textContent="\n html, body { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; }\n #__art_dpip_root { position:absolute; inset:0; display:flex; }\n #__art_dpip_root > * { width:100% !important; height:100% !important; }\n ",f.head.appendChild(p),!f.querySelector('meta[name="viewport"]')){var y=f.createElement("meta");y.name="viewport",y.content="width=device-width,initial-scale=1",f.head.appendChild(y)}try{document.querySelectorAll('link[rel="stylesheet"]').forEach(function(e){var t=f.createElement("link");t.rel="stylesheet",t.href=e.href,e.media&&(t.media=e.media),e.crossOrigin&&(t.crossOrigin=e.crossOrigin),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),f.head.appendChild(t)})}catch(e){}try{document.querySelectorAll("style").forEach(function(e){var t=f.createElement("style");t.textContent=e.textContent,f.head.appendChild(t)})}catch(e){}return i=r.document.adoptNode(l),o.appendChild(i),h.currentDoc=r.document,c=function(){var t;return null==(t=e.resize)?void 0:t.call(e)},u=function(){return v()},r.addEventListener("resize",c),r.addEventListener("pagehide",u),r.addEventListener("unload",u),h.cleanup=function(){r.removeEventListener("resize",c),r.removeEventListener("pagehide",u),r.removeEventListener("unload",u)},d(l,"artplayer-document-pip"),e.emit("document-pip",!0),[3,4];case 3:return s=a.sent(),e.notice.show="Document Picture-in-Picture open failed",console.warn("[artplayer-plugin-document-pip] open failed:",s),[3,4];case 4:return[2]}})})()}function v(){if(!n&&t.fallbackToVideoPiP){e.pip=!1;return}if(h.win)try{var r;if(null==(r=h.cleanup)||r.call(h),h.placeholder){var o=h.placeholder.ownerDocument||document,i=o.adoptNode(l);h.originalParent.insertBefore(i,h.placeholder),h.placeholder.remove(),h.placeholder=null,h.currentDoc=o}h.win.close(),h.win=null,y(l,"artplayer-document-pip"),e.emit("document-pip",!1)}catch(t){e.notice.show="Document Picture-in-Picture close failed",console.warn("[artplayer-plugin-document-pip] close failed:",t)}}function m(){h.win?v():_()}return e.controls.add({name:"document-pip",position:"right",index:40,tooltip:e.i18n.get("PIP Mode"),mounted:function(t){f(t,c.pip),o(t,"click",m),e.on("document-pip",function(e){p(t,u.get(e?"Exit PIP Mode":"PIP Mode"))})}}),e.on("destroy",v),{name:"artplayerPluginDocumentPip",state:h,open:_,close:v,toggle:m}}}"undefined"!=typeof window&&(window.artplayerPluginDocumentPip=u)},{"@swc/helpers/cjs/_async_to_generator.cjs":"cZn0e","@swc/helpers/cjs/_object_spread.cjs":"kyoEj","@swc/helpers/cjs/_ts_generator.cjs":"eltGh","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],cZn0e:[function(e,t,r,n){"use strict";function o(e,t,r,n,o,i,c){try{var a=e[i](c),u=a.value}catch(e){r(e);return}a.done?t(u):Promise.resolve(u).then(n,o)}r._=function(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var c=e.apply(t,r);function a(e){o(c,n,i,a,u,"next",e)}function u(e){o(c,n,i,a,u,"throw",e)}a(void 0)})}}},{}],kyoEj:[function(e,t,r,n){"use strict";var o=e("9f9b8a24218ee51e");r._=function(e){for(var t=1;tt.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var o=0,n=Object.getOwnPropertySymbols(e);ot.indexOf(n[o])&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]]);return r}function s(e,t,r,n){var o,c=arguments.length,a=c<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if(("undefined"==typeof Reflect?"undefined":(0,i._)(Reflect))==="object"&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var u=e.length-1;u>=0;u--)(o=e[u])&&(a=(c<3?o(a):c>3?o(t,r,a):o(t,r))||a);return c>3&&a&&Object.defineProperty(t,r,a),a}function f(e,t){return function(r,n){t(r,n,e)}}function p(e,t,r,n,o,c){function a(e){if(void 0!==e&&"function"!=typeof e)throw TypeError("Function expected");return e}for(var u,l=n.kind,s="getter"===l?"get":"setter"===l?"set":"value",f=!t&&e?n.static?e:e.prototype:null,p=t||(f?Object.getOwnPropertyDescriptor(f,n.name):{}),d=!1,y=r.length-1;y>=0;y--){var h={};for(var _ in n)h[_]="access"===_?{}:n[_];for(var _ in n.access)h.access[_]=n.access[_];h.addInitializer=function(e){if(d)throw TypeError("Cannot add initializers after decoration has completed");c.push(a(e||null))};var v=(0,r[y])("accessor"===l?{get:p.get,set:p.set}:p[s],h);if("accessor"===l){if(void 0===v)continue;if(null===v||(void 0===v?"undefined":(0,i._)(v))!=="object")throw TypeError("Object expected");(u=a(v.get))&&(p.get=u),(u=a(v.set))&&(p.set=u),(u=a(v.init))&&o.unshift(u)}else(u=a(v))&&("field"===l?o.unshift(u):p[s]=u)}f&&Object.defineProperty(f,n.name,p),d=!0}function d(e,t,r){for(var n=arguments.length>2,o=0;o0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function P(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)c.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return c}function j(){for(var e=[],t=0;t1||a(e,t)})},t&&(n[e]=t(n[e])))}function a(e,t){try{var r;(r=o[e](t)).value instanceof E?Promise.resolve(r.value.v).then(u,l):s(i[0][2],r)}catch(e){s(i[0][3],e)}}function u(e){a("next",e)}function l(e){a("throw",e)}function s(e,t){e(t),i.shift(),i.length&&a(i[0][0],i[0][1])}}function D(e){var t,r;return t={},n("next"),n("throw",function(e){throw e}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,o){t[n]=e[n]?function(t){return(r=!r)?{value:E(e[n](t)),done:!1}:o?o(t):t}:o}}function I(e){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=g(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise(function(n,o){var i,c,a;i=n,c=o,a=(t=e[r](t)).done,Promise.resolve(t.value).then(function(e){i({value:e,done:a})},c)})}}}function T(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var k=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},C=function(e){return(C=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t})(e)};function M(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=C(e),n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=(0,c._)({width:480,height:270,fallbackToVideoPiP:!0,placeholder:"Playing in Document Picture-in-Picture"},e);return function(e){var r,n="documentPictureInPicture"in window&&"function"==typeof(null==(r=window.documentPictureInPicture)?void 0:r.requestWindow),o=e.proxy,c=e.icons,u=e.i18n,l=e.template.$container,s=e.constructor.utils,f=s.append,p=s.tooltip,d=s.addClass,y=s.removeClass,h={win:null,originalParent:null,originalNext:null,currentDoc:null,placeholder:null};function _(){return(0,i._)(function(){var r,o,i,c,u,s;return(0,a._)(this,function(a){switch(a.label){case 0:if(!n&&t.fallbackToVideoPiP)return e.pip=!0,console.warn("[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture"),[2];if(h.win)return[2];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,window.documentPictureInPicture.requestWindow({width:t.width,height:t.height})];case 2:h.win=r=a.sent(),h.currentDoc=r.document,h.placeholder=document.createElement("div"),h.placeholder.className="artplayer-pip-placeholder",h.placeholder.style.cssText="display:flex;justify-content:center;align-items:center;width:100%;height:100%;",h.placeholder.textContent=t.placeholder,h.originalParent=l.parentNode,h.originalNext=l.nextSibling,h.originalParent.insertBefore(h.placeholder,h.originalNext),(o=r.document.createElement("div")).id="__art_dpip_root",r.document.body.appendChild(o);var f=r.document,p=f.createElement("style");if(p.textContent="\n html, body { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; }\n #__art_dpip_root { position:absolute; inset:0; display:flex; }\n #__art_dpip_root > * { width:100% !important; height:100% !important; }\n ",f.head.appendChild(p),!f.querySelector('meta[name="viewport"]')){var y=f.createElement("meta");y.name="viewport",y.content="width=device-width,initial-scale=1",f.head.appendChild(y)}try{document.querySelectorAll('link[rel="stylesheet"]').forEach(function(e){var t=f.createElement("link");t.rel="stylesheet",t.href=e.href,e.media&&(t.media=e.media),e.crossOrigin&&(t.crossOrigin=e.crossOrigin),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),f.head.appendChild(t)})}catch(e){}try{document.querySelectorAll("style").forEach(function(e){var t=f.createElement("style");t.textContent=e.textContent,f.head.appendChild(t)})}catch(e){}return i=r.document.adoptNode(l),o.appendChild(i),h.currentDoc=r.document,c=function(){var t;return null==(t=e.resize)?void 0:t.call(e)},u=function(){return v()},r.addEventListener("resize",c),r.addEventListener("pagehide",u),r.addEventListener("unload",u),h.cleanup=function(){r.removeEventListener("resize",c),r.removeEventListener("pagehide",u),r.removeEventListener("unload",u)},d(l,"artplayer-document-pip"),e.emit("document-pip",!0),[3,4];case 3:return s=a.sent(),e.notice.show="Document Picture-in-Picture open failed",console.warn("[artplayer-plugin-document-pip] open failed:",s),[3,4];case 4:return[2]}})})()}function v(){if(h.win)try{var t;if(null==(t=h.cleanup)||t.call(h),h.placeholder){var r=h.placeholder.ownerDocument||document,n=r.adoptNode(l);h.originalParent.insertBefore(n,h.placeholder),h.placeholder.remove(),h.placeholder=null,h.currentDoc=r}h.win.close(),h.win=null,y(l,"artplayer-document-pip"),e.emit("document-pip",!1)}catch(t){e.notice.show="Document Picture-in-Picture close failed",console.warn("[artplayer-plugin-document-pip] close failed:",t)}}function m(){h.win?v():_()}return e.controls.add({name:"document-pip",position:"right",index:40,tooltip:e.i18n.get("PIP Mode"),mounted:function(t){f(t,c.pip),o(t,"click",m),e.on("document-pip",function(e){p(t,u.get(e?"Exit PIP Mode":"PIP Mode"))})}}),e.on("destroy",v),{name:"artplayerPluginDocumentPip",get isSupported(){return n},get isActive(){return!!h.win},open:_,close:v,toggle:m}}}"undefined"!=typeof window&&(window.artplayerPluginDocumentPip=u)},{"@swc/helpers/cjs/_async_to_generator.cjs":"cZn0e","@swc/helpers/cjs/_object_spread.cjs":"kyoEj","@swc/helpers/cjs/_ts_generator.cjs":"eltGh","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],cZn0e:[function(e,t,r,n){"use strict";function o(e,t,r,n,o,i,c){try{var a=e[i](c),u=a.value}catch(e){r(e);return}a.done?t(u):Promise.resolve(u).then(n,o)}r._=function(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var c=e.apply(t,r);function a(e){o(c,n,i,a,u,"next",e)}function u(e){o(c,n,i,a,u,"throw",e)}a(void 0)})}}},{}],kyoEj:[function(e,t,r,n){"use strict";var o=e("9f9b8a24218ee51e");r._=function(e){for(var t=1;tt.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var o=0,n=Object.getOwnPropertySymbols(e);ot.indexOf(n[o])&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]]);return r}function s(e,t,r,n){var o,c=arguments.length,a=c<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if(("undefined"==typeof Reflect?"undefined":(0,i._)(Reflect))==="object"&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var u=e.length-1;u>=0;u--)(o=e[u])&&(a=(c<3?o(a):c>3?o(t,r,a):o(t,r))||a);return c>3&&a&&Object.defineProperty(t,r,a),a}function f(e,t){return function(r,n){t(r,n,e)}}function p(e,t,r,n,o,c){function a(e){if(void 0!==e&&"function"!=typeof e)throw TypeError("Function expected");return e}for(var u,l=n.kind,s="getter"===l?"get":"setter"===l?"set":"value",f=!t&&e?n.static?e:e.prototype:null,p=t||(f?Object.getOwnPropertyDescriptor(f,n.name):{}),d=!1,y=r.length-1;y>=0;y--){var h={};for(var _ in n)h[_]="access"===_?{}:n[_];for(var _ in n.access)h.access[_]=n.access[_];h.addInitializer=function(e){if(d)throw TypeError("Cannot add initializers after decoration has completed");c.push(a(e||null))};var v=(0,r[y])("accessor"===l?{get:p.get,set:p.set}:p[s],h);if("accessor"===l){if(void 0===v)continue;if(null===v||(void 0===v?"undefined":(0,i._)(v))!=="object")throw TypeError("Object expected");(u=a(v.get))&&(p.get=u),(u=a(v.set))&&(p.set=u),(u=a(v.init))&&o.unshift(u)}else(u=a(v))&&("field"===l?o.unshift(u):p[s]=u)}f&&Object.defineProperty(f,n.name,p),d=!0}function d(e,t,r){for(var n=arguments.length>2,o=0;o0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function P(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)c.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return c}function j(){for(var e=[],t=0;t1||a(e,t)})},t&&(n[e]=t(n[e])))}function a(e,t){try{var r;(r=o[e](t)).value instanceof E?Promise.resolve(r.value.v).then(u,l):s(i[0][2],r)}catch(e){s(i[0][3],e)}}function u(e){a("next",e)}function l(e){a("throw",e)}function s(e,t){e(t),i.shift(),i.length&&a(i[0][0],i[0][1])}}function D(e){var t,r;return t={},n("next"),n("throw",function(e){throw e}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,o){t[n]=e[n]?function(t){return(r=!r)?{value:E(e[n](t)),done:!1}:o?o(t):t}:o}}function I(e){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=g(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise(function(n,o){var i,c,a;i=n,c=o,a=(t=e[r](t)).done,Promise.resolve(t.value).then(function(e){i({value:e,done:a})},c)})}}}function T(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var k=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},C=function(e){return(C=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t})(e)};function M(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=C(e),n=0;n{ - const dpipOK = 'documentPictureInPicture' in window && typeof window.documentPictureInPicture?.requestWindow === 'function'; + const isSupported = 'documentPictureInPicture' in window && typeof window.documentPictureInPicture?.requestWindow === 'function'; const { proxy, icons, i18n, template: { $container }, constructor: { utils: { append, tooltip, addClass, removeClass } } } = art; const state = { win: null, @@ -216,7 +216,7 @@ function artplayerPluginDocumentPip(userOptions = {}) { } catch {} } async function open() { - if (!dpipOK && options.fallbackToVideoPiP) { + if (!isSupported && options.fallbackToVideoPiP) { art.pip = true; console.warn('[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture'); return; @@ -270,10 +270,6 @@ function artplayerPluginDocumentPip(userOptions = {}) { state.currentDoc = backDoc; } function close() { - if (!dpipOK && options.fallbackToVideoPiP) { - art.pip = false; - return; - } if (!state.win) return; try { state.cleanup?.(); @@ -307,7 +303,12 @@ function artplayerPluginDocumentPip(userOptions = {}) { art.on('destroy', close); return { name: 'artplayerPluginDocumentPip', - state, + get isSupported () { + return isSupported; + }, + get isActive () { + return !!state.win; + }, open, close, toggle diff --git a/docs/uncompiled/artplayer-plugin-document-pip/index.js.map b/docs/uncompiled/artplayer-plugin-document-pip/index.js.map index c5c5c2fb7..363d280ab 100644 --- a/docs/uncompiled/artplayer-plugin-document-pip/index.js.map +++ b/docs/uncompiled/artplayer-plugin-document-pip/index.js.map @@ -1 +1 @@ -{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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CAAC;YACf,MAAM;YACN,UAAU;YACV,OAAO;YACP,SAAS,IAAI,IAAI,CAAC,GAAG,CAAC;YACtB,SAAS,CAAC;gBACR,OAAO,UAAU,MAAM,GAAG;gBAC1B,MAAM,UAAU,SAAS;gBACzB,IAAI,EAAE,CAAC,gBAAgB,CAAC;oBACtB,QAAQ,UAAU,KAAK,GAAG,CAAC,QAAQ,kBAAkB;gBACvD;YACF;QACF;QAEA,IAAI,EAAE,CAAC,WAAW;QAElB,OAAO;YACL,MAAM;YACN;YACA;YACA;YACA;QACF;IACF;AACF;AAEA,IAAI,OAAO,WAAW,aACpB,OAAO,0BAA0B,GAAG;;;AChMtC,QAAQ,cAAc,GAAG,SAAU,CAAC;IAClC,OAAO,KAAK,EAAE,UAAU,GAAG,IAAI;QAAC,SAAS;IAAC;AAC5C;AAEA,QAAQ,iBAAiB,GAAG,SAAU,CAAC;IACrC,OAAO,cAAc,CAAC,GAAG,cAAc;QAAC,OAAO;IAAI;AACrD;AAEA,QAAQ,SAAS,GAAG,SAAU,MAAM,EAAE,IAAI;IACxC,OAAO,IAAI,CAAC,QAAQ,OAAO,CAAC,SAAU,GAAG;QACvC,IACE,QAAQ,aACR,QAAQ,gBACR,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,MAE3C;QAGF,OAAO,cAAc,CAAC,MAAM,KAAK;YAC/B,YAAY;YACZ,KAAK;gBACH,OAAO,MAAM,CAAC,IAAI;YACpB;QACF;IACF;IAEA,OAAO;AACT;AAEA,QAAQ,MAAM,GAAG,SAAU,IAAI,EAAE,QAAQ,EAAE,GAAG;IAC5C,OAAO,cAAc,CAAC,MAAM,UAAU;QACpC,YAAY;QACZ,KAAK;IACP;AACF","sources":["packages/artplayer-plugin-document-pip/src/index.js","node_modules/@parcel/transformer-js/src/esmodule-helpers.js"],"sourcesContent":["export default function artplayerPluginDocumentPip(userOptions = {}) {\n const options = {\n width: 480,\n height: 270,\n fallbackToVideoPiP: true,\n placeholder: `Playing in Document Picture-in-Picture`,\n ...userOptions,\n }\n\n return (art) => {\n const dpipOK = 'documentPictureInPicture' in window\n && typeof window.documentPictureInPicture?.requestWindow === 'function'\n\n const { proxy, icons, i18n, template: { $container }, constructor: { utils: { append, tooltip, addClass, removeClass } } } = art\n\n const state = {\n win: null,\n originalParent: null,\n originalNext: null,\n currentDoc: null,\n placeholder: null,\n }\n\n function copyStylesTo(targetDoc) {\n const base = targetDoc.createElement('style')\n base.textContent = `\n html, body { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; }\n #__art_dpip_root { position:absolute; inset:0; display:flex; }\n #__art_dpip_root > * { width:100% !important; height:100% !important; }\n `\n targetDoc.head.appendChild(base)\n if (!targetDoc.querySelector('meta[name=\"viewport\"]')) {\n const meta = targetDoc.createElement('meta')\n meta.name = 'viewport'\n meta.content = 'width=device-width,initial-scale=1'\n targetDoc.head.appendChild(meta)\n }\n\n try {\n document.querySelectorAll('link[rel=\"stylesheet\"]').forEach((link) => {\n const clone = targetDoc.createElement('link')\n clone.rel = 'stylesheet'\n clone.href = link.href\n if (link.media)\n clone.media = link.media\n if (link.crossOrigin)\n clone.crossOrigin = link.crossOrigin\n if (link.referrerPolicy)\n clone.referrerPolicy = link.referrerPolicy\n targetDoc.head.appendChild(clone)\n })\n }\n catch { }\n\n try {\n document.querySelectorAll('style').forEach((style) => {\n const clone = targetDoc.createElement('style')\n clone.textContent = style.textContent\n targetDoc.head.appendChild(clone)\n })\n }\n catch { }\n }\n\n async function open() {\n if (!dpipOK && options.fallbackToVideoPiP) {\n art.pip = true\n console.warn('[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture')\n return\n }\n\n if (state.win)\n return\n\n try {\n const pipWin = await window.documentPictureInPicture.requestWindow({\n width: options.width,\n height: options.height,\n })\n\n state.win = pipWin\n state.currentDoc = pipWin.document\n\n state.placeholder = document.createElement('div')\n state.placeholder.className = 'artplayer-pip-placeholder'\n state.placeholder.style.cssText = `display:flex;justify-content:center;align-items:center;width:100%;height:100%;`\n state.placeholder.textContent = options.placeholder\n state.originalParent = $container.parentNode\n state.originalNext = $container.nextSibling\n state.originalParent.insertBefore(state.placeholder, state.originalNext)\n\n const root = pipWin.document.createElement('div')\n root.id = '__art_dpip_root'\n pipWin.document.body.appendChild(root)\n\n copyStylesTo(pipWin.document)\n\n const adopted = pipWin.document.adoptNode($container)\n root.appendChild(adopted)\n state.currentDoc = pipWin.document\n\n const onResize = () => art.resize?.()\n const onClose = () => close()\n\n pipWin.addEventListener('resize', onResize)\n pipWin.addEventListener('pagehide', onClose)\n pipWin.addEventListener('unload', onClose)\n\n state.cleanup = () => {\n pipWin.removeEventListener('resize', onResize)\n pipWin.removeEventListener('pagehide', onClose)\n pipWin.removeEventListener('unload', onClose)\n }\n\n addClass($container, 'artplayer-document-pip')\n art.emit('document-pip', true)\n }\n catch (err) {\n art.notice.show = 'Document Picture-in-Picture open failed'\n console.warn('[artplayer-plugin-document-pip] open failed:', err)\n }\n }\n\n function restoreToOriginalDocument() {\n if (!state.placeholder)\n return\n const backDoc = state.placeholder.ownerDocument || document\n const adoptedBack = backDoc.adoptNode($container)\n state.originalParent.insertBefore(adoptedBack, state.placeholder)\n state.placeholder.remove()\n state.placeholder = null\n state.currentDoc = backDoc\n }\n\n function close() {\n if (!dpipOK && options.fallbackToVideoPiP) {\n art.pip = false\n return\n }\n\n if (!state.win)\n return\n try {\n state.cleanup?.()\n restoreToOriginalDocument()\n state.win.close()\n state.win = null\n removeClass($container, 'artplayer-document-pip')\n art.emit('document-pip', false)\n }\n catch (err) {\n art.notice.show = 'Document Picture-in-Picture close failed'\n console.warn('[artplayer-plugin-document-pip] close failed:', err)\n }\n }\n\n function toggle() {\n if (state.win) {\n close()\n }\n else {\n open()\n }\n }\n\n art.controls.add({\n name: 'document-pip',\n position: 'right',\n index: 40,\n tooltip: art.i18n.get('PIP Mode'),\n mounted: ($control) => {\n append($control, icons.pip)\n proxy($control, 'click', toggle)\n art.on('document-pip', (value) => {\n tooltip($control, i18n.get(value ? 'Exit PIP Mode' : 'PIP Mode'))\n })\n },\n })\n\n art.on('destroy', close)\n\n return {\n name: 'artplayerPluginDocumentPip',\n state,\n open,\n close,\n toggle,\n }\n }\n}\n\nif (typeof window !== 'undefined') {\n window.artplayerPluginDocumentPip = artplayerPluginDocumentPip\n}\n","exports.interopDefault = function (a) {\n return a && a.__esModule ? a : {default: a};\n};\n\nexports.defineInteropFlag = function (a) {\n Object.defineProperty(a, '__esModule', {value: true});\n};\n\nexports.exportAll = function (source, dest) {\n Object.keys(source).forEach(function (key) {\n if (\n key === 'default' ||\n key === '__esModule' ||\n Object.prototype.hasOwnProperty.call(dest, key)\n ) {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function () {\n return source[key];\n },\n });\n });\n\n return dest;\n};\n\nexports.export = function (dest, destName, get) {\n Object.defineProperty(dest, destName, {\n enumerable: true,\n get: get,\n });\n};\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../../../"} \ No newline at end of file +{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6CAAwB;AAAT,SAAS,2BAA2B,cAAc,CAAC,CAAC;IACjE,MAAM,UAAU;QACd,OAAO;QACP,QAAQ;QACR,oBAAoB;QACpB,aAAa,CAAC,sCAAsC,CAAC;QACrD,GAAG,WAAW;IAChB;IAEA,OAAO,CAAC;QACN,MAAM,cAAc,8BAA8B,UAC7C,OAAO,OAAO,wBAAwB,EAAE,kBAAkB;QAE/D,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,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,EAAE,UAAU,GAAG,IAAI;QAAC,SAAS;IAAC;AAC5C;AAEA,QAAQ,iBAAiB,GAAG,SAAU,CAAC;IACrC,OAAO,cAAc,CAAC,GAAG,cAAc;QAAC,OAAO;IAAI;AACrD;AAEA,QAAQ,SAAS,GAAG,SAAU,MAAM,EAAE,IAAI;IACxC,OAAO,IAAI,CAAC,QAAQ,OAAO,CAAC,SAAU,GAAG;QACvC,IACE,QAAQ,aACR,QAAQ,gBACR,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,MAE3C;QAGF,OAAO,cAAc,CAAC,MAAM,KAAK;YAC/B,YAAY;YACZ,KAAK;gBACH,OAAO,MAAM,CAAC,IAAI;YACpB;QACF;IACF;IAEA,OAAO;AACT;AAEA,QAAQ,MAAM,GAAG,SAAU,IAAI,EAAE,QAAQ,EAAE,GAAG;IAC5C,OAAO,cAAc,CAAC,MAAM,UAAU;QACpC,YAAY;QACZ,KAAK;IACP;AACF","sources":["packages/artplayer-plugin-document-pip/src/index.js","node_modules/@parcel/transformer-js/src/esmodule-helpers.js"],"sourcesContent":["export default function artplayerPluginDocumentPip(userOptions = {}) {\n const options = {\n width: 480,\n height: 270,\n fallbackToVideoPiP: true,\n placeholder: `Playing in Document Picture-in-Picture`,\n ...userOptions,\n }\n\n return (art) => {\n const isSupported = 'documentPictureInPicture' in window\n && typeof window.documentPictureInPicture?.requestWindow === 'function'\n\n const { proxy, icons, i18n, template: { $container }, constructor: { utils: { append, tooltip, addClass, removeClass } } } = art\n\n const state = {\n win: null,\n originalParent: null,\n originalNext: null,\n currentDoc: null,\n placeholder: null,\n }\n\n function copyStylesTo(targetDoc) {\n const base = targetDoc.createElement('style')\n base.textContent = `\n html, body { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; }\n #__art_dpip_root { position:absolute; inset:0; display:flex; }\n #__art_dpip_root > * { width:100% !important; height:100% !important; }\n `\n targetDoc.head.appendChild(base)\n if (!targetDoc.querySelector('meta[name=\"viewport\"]')) {\n const meta = targetDoc.createElement('meta')\n meta.name = 'viewport'\n meta.content = 'width=device-width,initial-scale=1'\n targetDoc.head.appendChild(meta)\n }\n\n try {\n document.querySelectorAll('link[rel=\"stylesheet\"]').forEach((link) => {\n const clone = targetDoc.createElement('link')\n clone.rel = 'stylesheet'\n clone.href = link.href\n if (link.media)\n clone.media = link.media\n if (link.crossOrigin)\n clone.crossOrigin = link.crossOrigin\n if (link.referrerPolicy)\n clone.referrerPolicy = link.referrerPolicy\n targetDoc.head.appendChild(clone)\n })\n }\n catch { }\n\n try {\n document.querySelectorAll('style').forEach((style) => {\n const clone = targetDoc.createElement('style')\n clone.textContent = style.textContent\n targetDoc.head.appendChild(clone)\n })\n }\n catch { }\n }\n\n async function open() {\n if (!isSupported && options.fallbackToVideoPiP) {\n art.pip = true\n console.warn('[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture')\n return\n }\n\n if (state.win)\n return\n\n try {\n const pipWin = await window.documentPictureInPicture.requestWindow({\n width: options.width,\n height: options.height,\n })\n\n state.win = pipWin\n state.currentDoc = pipWin.document\n\n state.placeholder = document.createElement('div')\n state.placeholder.className = 'artplayer-pip-placeholder'\n state.placeholder.style.cssText = `display:flex;justify-content:center;align-items:center;width:100%;height:100%;`\n state.placeholder.textContent = options.placeholder\n state.originalParent = $container.parentNode\n state.originalNext = $container.nextSibling\n state.originalParent.insertBefore(state.placeholder, state.originalNext)\n\n const root = pipWin.document.createElement('div')\n root.id = '__art_dpip_root'\n pipWin.document.body.appendChild(root)\n\n copyStylesTo(pipWin.document)\n\n const adopted = pipWin.document.adoptNode($container)\n root.appendChild(adopted)\n state.currentDoc = pipWin.document\n\n const onResize = () => art.resize?.()\n const onClose = () => close()\n\n pipWin.addEventListener('resize', onResize)\n pipWin.addEventListener('pagehide', onClose)\n pipWin.addEventListener('unload', onClose)\n\n state.cleanup = () => {\n pipWin.removeEventListener('resize', onResize)\n pipWin.removeEventListener('pagehide', onClose)\n pipWin.removeEventListener('unload', onClose)\n }\n\n addClass($container, 'artplayer-document-pip')\n art.emit('document-pip', true)\n }\n catch (err) {\n art.notice.show = 'Document Picture-in-Picture open failed'\n console.warn('[artplayer-plugin-document-pip] open failed:', err)\n }\n }\n\n function restoreToOriginalDocument() {\n if (!state.placeholder)\n return\n const backDoc = state.placeholder.ownerDocument || document\n const adoptedBack = backDoc.adoptNode($container)\n state.originalParent.insertBefore(adoptedBack, state.placeholder)\n state.placeholder.remove()\n state.placeholder = null\n state.currentDoc = backDoc\n }\n\n function close() {\n if (!state.win)\n return\n try {\n state.cleanup?.()\n restoreToOriginalDocument()\n state.win.close()\n state.win = null\n removeClass($container, 'artplayer-document-pip')\n art.emit('document-pip', false)\n }\n catch (err) {\n art.notice.show = 'Document Picture-in-Picture close failed'\n console.warn('[artplayer-plugin-document-pip] close failed:', err)\n }\n }\n\n function toggle() {\n if (state.win) {\n close()\n }\n else {\n open()\n }\n }\n\n art.controls.add({\n name: 'document-pip',\n position: 'right',\n index: 40,\n tooltip: art.i18n.get('PIP Mode'),\n mounted: ($control) => {\n append($control, icons.pip)\n proxy($control, 'click', toggle)\n art.on('document-pip', (value) => {\n tooltip($control, i18n.get(value ? 'Exit PIP Mode' : 'PIP Mode'))\n })\n },\n })\n\n art.on('destroy', close)\n\n return {\n name: 'artplayerPluginDocumentPip',\n get isSupported() { return isSupported },\n get isActive() { return !!state.win },\n open,\n close,\n toggle,\n }\n }\n}\n\nif (typeof window !== 'undefined') {\n window.artplayerPluginDocumentPip = artplayerPluginDocumentPip\n}\n","exports.interopDefault = function (a) {\n return a && a.__esModule ? a : {default: a};\n};\n\nexports.defineInteropFlag = function (a) {\n Object.defineProperty(a, '__esModule', {value: true});\n};\n\nexports.exportAll = function (source, dest) {\n Object.keys(source).forEach(function (key) {\n if (\n key === 'default' ||\n key === '__esModule' ||\n Object.prototype.hasOwnProperty.call(dest, key)\n ) {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function () {\n return source[key];\n },\n });\n });\n\n return dest;\n};\n\nexports.export = function (dest, destName, get) {\n Object.defineProperty(dest, destName, {\n enumerable: true,\n get: get,\n });\n};\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../../../"} \ No newline at end of file diff --git a/packages/artplayer-plugin-document-pip/dist/artplayer-plugin-document-pip.esm.js b/packages/artplayer-plugin-document-pip/dist/artplayer-plugin-document-pip.esm.js index 8b9281452..814b90537 100644 --- a/packages/artplayer-plugin-document-pip/dist/artplayer-plugin-document-pip.esm.js +++ b/packages/artplayer-plugin-document-pip/dist/artplayer-plugin-document-pip.esm.js @@ -5,5 +5,5 @@ * (c) 2017-2025 Harvey Zack * Released under the MIT License. */ -!function(e,t,n,r,i,o,l,d){var c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},a="function"==typeof c[r]&&c[r],u=a.i||{},p=a.cache||{},f="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function s(t,n){if(!p[t]){if(!e[t]){if(i[t])return i[t];var o="function"==typeof c[r]&&c[r];if(!n&&o)return o(t,!0);if(a)return a(t,!0);if(f&&"string"==typeof t)return f(t);var l=Error("Cannot find module '"+t+"'");throw l.code="MODULE_NOT_FOUND",l}u.resolve=function(n){var r=e[t][1][n];return null!=r?r:n},u.cache={};var d=p[t]=new s.Module(t);e[t][0].call(d.exports,u,d,d.exports,c)}return p[t].exports;function u(e){var t=u.resolve(e);return!1===t?{}:s(t)}}s.isParcelRequire=!0,s.Module=function(e){this.id=e,this.bundle=s,this.require=f,this.exports={}},s.modules=e,s.cache=p,s.parent=a,s.distDir=void 0,s.publicUrl=void 0,s.devServer=void 0,s.i=u,s.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(s,"root",{get:function(){return c[r]}}),c[r]=s;for(var h=0;h{let n="documentPictureInPicture"in window&&"function"==typeof window.documentPictureInPicture?.requestWindow,{proxy:r,icons:i,i18n:o,template:{$container:l},constructor:{utils:{append:d,tooltip:c,addClass:a,removeClass:u}}}=e,p={win:null,originalParent:null,originalNext:null,currentDoc:null,placeholder:null};async function f(){if(!n&&t.fallbackToVideoPiP){e.pip=!0,console.warn("[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture");return}if(!p.win)try{let n=await window.documentPictureInPicture.requestWindow({width:t.width,height:t.height});p.win=n,p.currentDoc=n.document,p.placeholder=document.createElement("div"),p.placeholder.className="artplayer-pip-placeholder",p.placeholder.style.cssText="display:flex;justify-content:center;align-items:center;width:100%;height:100%;",p.placeholder.textContent=t.placeholder,p.originalParent=l.parentNode,p.originalNext=l.nextSibling,p.originalParent.insertBefore(p.placeholder,p.originalNext);let i=n.document.createElement("div");i.id="__art_dpip_root",n.document.body.appendChild(i);var r=n.document;let o=r.createElement("style");if(o.textContent=` html, body { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; } #__art_dpip_root { position:absolute; inset:0; display:flex; } #__art_dpip_root > * { width:100% !important; height:100% !important; } `,r.head.appendChild(o),!r.querySelector('meta[name="viewport"]')){let e=r.createElement("meta");e.name="viewport",e.content="width=device-width,initial-scale=1",r.head.appendChild(e)}try{document.querySelectorAll('link[rel="stylesheet"]').forEach(e=>{let t=r.createElement("link");t.rel="stylesheet",t.href=e.href,e.media&&(t.media=e.media),e.crossOrigin&&(t.crossOrigin=e.crossOrigin),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),r.head.appendChild(t)})}catch{}try{document.querySelectorAll("style").forEach(e=>{let t=r.createElement("style");t.textContent=e.textContent,r.head.appendChild(t)})}catch{}let d=n.document.adoptNode(l);i.appendChild(d),p.currentDoc=n.document;let c=()=>e.resize?.(),u=()=>s();n.addEventListener("resize",c),n.addEventListener("pagehide",u),n.addEventListener("unload",u),p.cleanup=()=>{n.removeEventListener("resize",c),n.removeEventListener("pagehide",u),n.removeEventListener("unload",u)},a(l,"artplayer-document-pip"),e.emit("document-pip",!0)}catch(t){e.notice.show="Document Picture-in-Picture open failed",console.warn("[artplayer-plugin-document-pip] open failed:",t)}}function s(){if(!n&&t.fallbackToVideoPiP){e.pip=!1;return}if(p.win)try{p.cleanup?.(),function(){if(!p.placeholder)return;let e=p.placeholder.ownerDocument||document,t=e.adoptNode(l);p.originalParent.insertBefore(t,p.placeholder),p.placeholder.remove(),p.placeholder=null,p.currentDoc=e}(),p.win.close(),p.win=null,u(l,"artplayer-document-pip"),e.emit("document-pip",!1)}catch(t){e.notice.show="Document Picture-in-Picture close failed",console.warn("[artplayer-plugin-document-pip] close failed:",t)}}function h(){p.win?s():f()}return e.controls.add({name:"document-pip",position:"right",index:40,tooltip:e.i18n.get("PIP Mode"),mounted:t=>{d(t,i.pip),r(t,"click",h),e.on("document-pip",e=>{c(t,o.get(e?"Exit PIP Mode":"PIP Mode"))})}}),e.on("destroy",s),{name:"artplayerPluginDocumentPip",state:p,open:f,close:s,toggle:h}}}i.defineInteropFlag(n),i.export(n,"default",()=>o),"undefined"!=typeof window&&(window.artplayerPluginDocumentPip=o)},{"@parcel/transformer-js/src/esmodule-helpers.js":"5lQoW"}],"5lQoW":[function(e,t,n,r){n.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},n.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.exportAll=function(e,t){return Object.keys(e).forEach(function(n){"default"===n||"__esModule"===n||Object.prototype.hasOwnProperty.call(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[n]}})}),t},n.export=function(e,t,n){Object.defineProperty(e,t,{enumerable:!0,get:n})}},{}]},["bKI9O"],"bKI9O","parcelRequire4dc0",{});let{default:e}=parcelRequire4dc0("bKI9O");export{e as default}; +!function(e,t,n,r,i,o,l,d){var c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},u="function"==typeof c[r]&&c[r],a=u.i||{},p=u.cache||{},f="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function s(t,n){if(!p[t]){if(!e[t]){if(i[t])return i[t];var o="function"==typeof c[r]&&c[r];if(!n&&o)return o(t,!0);if(u)return u(t,!0);if(f&&"string"==typeof t)return f(t);var l=Error("Cannot find module '"+t+"'");throw l.code="MODULE_NOT_FOUND",l}a.resolve=function(n){var r=e[t][1][n];return null!=r?r:n},a.cache={};var d=p[t]=new s.Module(t);e[t][0].call(d.exports,a,d,d.exports,c)}return p[t].exports;function a(e){var t=a.resolve(e);return!1===t?{}:s(t)}}s.isParcelRequire=!0,s.Module=function(e){this.id=e,this.bundle=s,this.require=f,this.exports={}},s.modules=e,s.cache=p,s.parent=u,s.distDir=void 0,s.publicUrl=void 0,s.devServer=void 0,s.i=a,s.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(s,"root",{get:function(){return c[r]}}),c[r]=s;for(var h=0;h{let n="documentPictureInPicture"in window&&"function"==typeof window.documentPictureInPicture?.requestWindow,{proxy:r,icons:i,i18n:o,template:{$container:l},constructor:{utils:{append:d,tooltip:c,addClass:u,removeClass:a}}}=e,p={win:null,originalParent:null,originalNext:null,currentDoc:null,placeholder:null};async function f(){if(!n&&t.fallbackToVideoPiP){e.pip=!0,console.warn("[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture");return}if(!p.win)try{let n=await window.documentPictureInPicture.requestWindow({width:t.width,height:t.height});p.win=n,p.currentDoc=n.document,p.placeholder=document.createElement("div"),p.placeholder.className="artplayer-pip-placeholder",p.placeholder.style.cssText="display:flex;justify-content:center;align-items:center;width:100%;height:100%;",p.placeholder.textContent=t.placeholder,p.originalParent=l.parentNode,p.originalNext=l.nextSibling,p.originalParent.insertBefore(p.placeholder,p.originalNext);let i=n.document.createElement("div");i.id="__art_dpip_root",n.document.body.appendChild(i);var r=n.document;let o=r.createElement("style");if(o.textContent=` html, body { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; } #__art_dpip_root { position:absolute; inset:0; display:flex; } #__art_dpip_root > * { width:100% !important; height:100% !important; } `,r.head.appendChild(o),!r.querySelector('meta[name="viewport"]')){let e=r.createElement("meta");e.name="viewport",e.content="width=device-width,initial-scale=1",r.head.appendChild(e)}try{document.querySelectorAll('link[rel="stylesheet"]').forEach(e=>{let t=r.createElement("link");t.rel="stylesheet",t.href=e.href,e.media&&(t.media=e.media),e.crossOrigin&&(t.crossOrigin=e.crossOrigin),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),r.head.appendChild(t)})}catch{}try{document.querySelectorAll("style").forEach(e=>{let t=r.createElement("style");t.textContent=e.textContent,r.head.appendChild(t)})}catch{}let d=n.document.adoptNode(l);i.appendChild(d),p.currentDoc=n.document;let c=()=>e.resize?.(),a=()=>s();n.addEventListener("resize",c),n.addEventListener("pagehide",a),n.addEventListener("unload",a),p.cleanup=()=>{n.removeEventListener("resize",c),n.removeEventListener("pagehide",a),n.removeEventListener("unload",a)},u(l,"artplayer-document-pip"),e.emit("document-pip",!0)}catch(t){e.notice.show="Document Picture-in-Picture open failed",console.warn("[artplayer-plugin-document-pip] open failed:",t)}}function s(){if(p.win)try{p.cleanup?.(),function(){if(!p.placeholder)return;let e=p.placeholder.ownerDocument||document,t=e.adoptNode(l);p.originalParent.insertBefore(t,p.placeholder),p.placeholder.remove(),p.placeholder=null,p.currentDoc=e}(),p.win.close(),p.win=null,a(l,"artplayer-document-pip"),e.emit("document-pip",!1)}catch(t){e.notice.show="Document Picture-in-Picture close failed",console.warn("[artplayer-plugin-document-pip] close failed:",t)}}function h(){p.win?s():f()}return e.controls.add({name:"document-pip",position:"right",index:40,tooltip:e.i18n.get("PIP Mode"),mounted:t=>{d(t,i.pip),r(t,"click",h),e.on("document-pip",e=>{c(t,o.get(e?"Exit PIP Mode":"PIP Mode"))})}}),e.on("destroy",s),{name:"artplayerPluginDocumentPip",get isSupported(){return n},get isActive(){return!!p.win},open:f,close:s,toggle:h}}}i.defineInteropFlag(n),i.export(n,"default",()=>o),"undefined"!=typeof window&&(window.artplayerPluginDocumentPip=o)},{"@parcel/transformer-js/src/esmodule-helpers.js":"5lQoW"}],"5lQoW":[function(e,t,n,r){n.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},n.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.exportAll=function(e,t){return Object.keys(e).forEach(function(n){"default"===n||"__esModule"===n||Object.prototype.hasOwnProperty.call(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[n]}})}),t},n.export=function(e,t,n){Object.defineProperty(e,t,{enumerable:!0,get:n})}},{}]},["bKI9O"],"bKI9O","parcelRequire4dc0",{});let{default:e}=parcelRequire4dc0("bKI9O");export{e as default}; //# sourceMappingURL=artplayer-plugin-document-pip.esm.js.map \ No newline at end of file diff --git a/packages/artplayer-plugin-document-pip/dist/artplayer-plugin-document-pip.esm.js.map b/packages/artplayer-plugin-document-pip/dist/artplayer-plugin-document-pip.esm.js.map index 27ba1763e..70777dd9a 100644 --- a/packages/artplayer-plugin-document-pip/dist/artplayer-plugin-document-pip.esm.js.map +++ b/packages/artplayer-plugin-document-pip/dist/artplayer-plugin-document-pip.esm.js.map @@ -1 +1 @@ -{"mappings":"C,A,S,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,E,I,E,A,a,O,W,W,A,a,O,K,K,A,a,O,O,O,A,a,O,O,O,C,E,E,A,Y,O,C,C,E,E,C,C,E,C,E,E,C,E,C,E,E,E,K,E,C,E,E,A,a,O,Q,A,Y,O,O,O,E,O,O,C,I,C,Q,S,E,C,C,C,E,G,C,C,C,E,C,C,G,C,C,C,E,C,C,G,C,C,E,C,O,C,C,E,C,I,E,A,Y,O,C,C,E,E,C,C,E,C,G,C,G,E,O,E,E,C,G,G,E,O,E,E,C,G,G,G,A,U,O,E,O,E,G,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,O,C,S,C,E,I,E,C,C,E,C,E,C,E,C,O,A,M,E,E,C,E,E,K,C,C,E,I,E,C,C,E,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,OAAO,CAAC,SAAU,CAAG,EAE7B,YAAR,GACA,AAAQ,eAAR,GACA,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,EAAM,IAK7C,OAAO,cAAc,CAAC,EAAM,EAAK,CAC/B,WAAY,CAAA,EACZ,IAAK,WACH,OAAO,CAAM,CAAC,EAAI,AACpB,CACF,EACF,GAEO,CACT,EAEA,EAAQ,MAAM,CAAG,SAAU,CAAI,CAAE,CAAQ,CAAE,CAAG,EAC5C,OAAO,cAAc,CAAC,EAAM,EAAU,CACpC,WAAY,CAAA,EACZ,IAAK,CACP,EACF,C,E,C,E,E,C,Q,C,Q,oB,C,G,G,C,Q,C,C,C,kB,gB,K,O","sources":["","packages/artplayer-plugin-document-pip/src/index.js","node_modules/@parcel/transformer-js/src/esmodule-helpers.js"],"sourcesContent":["// modules are defined as an array\n// [ module function, map of requires ]\n//\n// map of requires is short require name -> numeric require\n//\n// anything defined in a previous bundle is accessed via the\n// orig method which is the require for previous bundles\n\n(function (\n modules,\n entry,\n mainEntry,\n parcelRequireName,\n externals,\n distDir,\n publicUrl,\n devServer\n) {\n /* eslint-disable no-undef */\n var globalObject =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n /* eslint-enable no-undef */\n\n // Save the require from previous bundle to this closure if any\n var previousRequire =\n typeof globalObject[parcelRequireName] === 'function' &&\n globalObject[parcelRequireName];\n\n var importMap = previousRequire.i || {};\n var cache = previousRequire.cache || {};\n // Do not use `require` to prevent Webpack from trying to bundle this call\n var nodeRequire =\n typeof module !== 'undefined' &&\n typeof module.require === 'function' &&\n module.require.bind(module);\n\n function newRequire(name, jumped) {\n if (!cache[name]) {\n if (!modules[name]) {\n if (externals[name]) {\n return externals[name];\n }\n // if we cannot find the module within our internal map or\n // cache jump to the current global require ie. the last bundle\n // that was added to the page.\n var currentRequire =\n typeof globalObject[parcelRequireName] === 'function' &&\n globalObject[parcelRequireName];\n if (!jumped && currentRequire) {\n return currentRequire(name, true);\n }\n\n // If there are other bundles on this page the require from the\n // previous one is saved to 'previousRequire'. Repeat this as\n // many times as there are bundles until the module is found or\n // we exhaust the require chain.\n if (previousRequire) {\n return previousRequire(name, true);\n }\n\n // Try the node require function if it exists.\n if (nodeRequire && typeof name === 'string') {\n return nodeRequire(name);\n }\n\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n }\n\n localRequire.resolve = resolve;\n localRequire.cache = {};\n\n var module = (cache[name] = new newRequire.Module(name));\n\n modules[name][0].call(\n module.exports,\n localRequire,\n module,\n module.exports,\n globalObject\n );\n }\n\n return cache[name].exports;\n\n function localRequire(x) {\n var res = localRequire.resolve(x);\n return res === false ? {} : newRequire(res);\n }\n\n function resolve(x) {\n var id = modules[name][1][x];\n return id != null ? id : x;\n }\n }\n\n function Module(moduleName) {\n this.id = moduleName;\n this.bundle = newRequire;\n this.require = nodeRequire;\n this.exports = {};\n }\n\n newRequire.isParcelRequire = true;\n newRequire.Module = Module;\n newRequire.modules = modules;\n newRequire.cache = cache;\n newRequire.parent = previousRequire;\n newRequire.distDir = distDir;\n newRequire.publicUrl = publicUrl;\n newRequire.devServer = devServer;\n newRequire.i = importMap;\n newRequire.register = function (id, exports) {\n modules[id] = [\n function (require, module) {\n module.exports = exports;\n },\n {},\n ];\n };\n\n // Only insert newRequire.load when it is actually used.\n // The code in this file is linted against ES5, so dynamic import is not allowed.\n // INSERT_LOAD_HERE\n\n Object.defineProperty(newRequire, 'root', {\n get: function () {\n return globalObject[parcelRequireName];\n },\n });\n\n globalObject[parcelRequireName] = newRequire;\n\n for (var i = 0; i < entry.length; i++) {\n newRequire(entry[i]);\n }\n\n if (mainEntry) {\n // Expose entry point to Node, AMD or browser globals\n // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js\n var mainExports = newRequire(mainEntry);\n\n // CommonJS\n if (typeof exports === 'object' && typeof module !== 'undefined') {\n module.exports = mainExports;\n\n // RequireJS\n } else if (typeof define === 'function' && define.amd) {\n define(function () {\n return mainExports;\n });\n }\n }\n})({\"bKI9O\":[function(require,module,exports,__globalThis) {\nvar parcelHelpers = require(\"@parcel/transformer-js/src/esmodule-helpers.js\");\nparcelHelpers.defineInteropFlag(exports);\nparcelHelpers.export(exports, \"default\", ()=>artplayerPluginDocumentPip);\nfunction artplayerPluginDocumentPip(userOptions = {}) {\n const options = {\n width: 480,\n height: 270,\n fallbackToVideoPiP: true,\n placeholder: `Playing in Document Picture-in-Picture`,\n ...userOptions\n };\n return (art)=>{\n const dpipOK = 'documentPictureInPicture' in window && typeof window.documentPictureInPicture?.requestWindow === 'function';\n const { proxy, icons, i18n, template: { $container }, constructor: { utils: { append, tooltip, addClass, removeClass } } } = art;\n const state = {\n win: null,\n originalParent: null,\n originalNext: null,\n currentDoc: null,\n placeholder: null\n };\n function copyStylesTo(targetDoc) {\n const base = targetDoc.createElement('style');\n base.textContent = `\n html, body { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; }\n #__art_dpip_root { position:absolute; inset:0; display:flex; }\n #__art_dpip_root > * { width:100% !important; height:100% !important; }\n `;\n targetDoc.head.appendChild(base);\n if (!targetDoc.querySelector('meta[name=\"viewport\"]')) {\n const meta = targetDoc.createElement('meta');\n meta.name = 'viewport';\n meta.content = 'width=device-width,initial-scale=1';\n targetDoc.head.appendChild(meta);\n }\n try {\n document.querySelectorAll('link[rel=\"stylesheet\"]').forEach((link)=>{\n const clone = targetDoc.createElement('link');\n clone.rel = 'stylesheet';\n clone.href = link.href;\n if (link.media) clone.media = link.media;\n if (link.crossOrigin) clone.crossOrigin = link.crossOrigin;\n if (link.referrerPolicy) clone.referrerPolicy = link.referrerPolicy;\n targetDoc.head.appendChild(clone);\n });\n } catch {}\n try {\n document.querySelectorAll('style').forEach((style)=>{\n const clone = targetDoc.createElement('style');\n clone.textContent = style.textContent;\n targetDoc.head.appendChild(clone);\n });\n } catch {}\n }\n async function open() {\n if (!dpipOK && options.fallbackToVideoPiP) {\n art.pip = true;\n console.warn('[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture');\n return;\n }\n if (state.win) return;\n try {\n const pipWin = await window.documentPictureInPicture.requestWindow({\n width: options.width,\n height: options.height\n });\n state.win = pipWin;\n state.currentDoc = pipWin.document;\n state.placeholder = document.createElement('div');\n state.placeholder.className = 'artplayer-pip-placeholder';\n state.placeholder.style.cssText = `display:flex;justify-content:center;align-items:center;width:100%;height:100%;`;\n state.placeholder.textContent = options.placeholder;\n state.originalParent = $container.parentNode;\n state.originalNext = $container.nextSibling;\n state.originalParent.insertBefore(state.placeholder, state.originalNext);\n const root = pipWin.document.createElement('div');\n root.id = '__art_dpip_root';\n pipWin.document.body.appendChild(root);\n copyStylesTo(pipWin.document);\n const adopted = pipWin.document.adoptNode($container);\n root.appendChild(adopted);\n state.currentDoc = pipWin.document;\n const onResize = ()=>art.resize?.();\n const onClose = ()=>close();\n pipWin.addEventListener('resize', onResize);\n pipWin.addEventListener('pagehide', onClose);\n pipWin.addEventListener('unload', onClose);\n state.cleanup = ()=>{\n pipWin.removeEventListener('resize', onResize);\n pipWin.removeEventListener('pagehide', onClose);\n pipWin.removeEventListener('unload', onClose);\n };\n addClass($container, 'artplayer-document-pip');\n art.emit('document-pip', true);\n } catch (err) {\n art.notice.show = 'Document Picture-in-Picture open failed';\n console.warn('[artplayer-plugin-document-pip] open failed:', err);\n }\n }\n function restoreToOriginalDocument() {\n if (!state.placeholder) return;\n const backDoc = state.placeholder.ownerDocument || document;\n const adoptedBack = backDoc.adoptNode($container);\n state.originalParent.insertBefore(adoptedBack, state.placeholder);\n state.placeholder.remove();\n state.placeholder = null;\n state.currentDoc = backDoc;\n }\n function close() {\n if (!dpipOK && options.fallbackToVideoPiP) {\n art.pip = false;\n return;\n }\n if (!state.win) return;\n try {\n state.cleanup?.();\n restoreToOriginalDocument();\n state.win.close();\n state.win = null;\n removeClass($container, 'artplayer-document-pip');\n art.emit('document-pip', false);\n } catch (err) {\n art.notice.show = 'Document Picture-in-Picture close failed';\n console.warn('[artplayer-plugin-document-pip] close failed:', err);\n }\n }\n function toggle() {\n if (state.win) close();\n else open();\n }\n art.controls.add({\n name: 'document-pip',\n position: 'right',\n index: 40,\n tooltip: art.i18n.get('PIP Mode'),\n mounted: ($control)=>{\n append($control, icons.pip);\n proxy($control, 'click', toggle);\n art.on('document-pip', (value)=>{\n tooltip($control, i18n.get(value ? 'Exit PIP Mode' : 'PIP Mode'));\n });\n }\n });\n art.on('destroy', close);\n return {\n name: 'artplayerPluginDocumentPip',\n state,\n open,\n close,\n toggle\n };\n };\n}\nif (typeof window !== 'undefined') window.artplayerPluginDocumentPip = artplayerPluginDocumentPip;\n\n},{\"@parcel/transformer-js/src/esmodule-helpers.js\":\"5lQoW\"}],\"5lQoW\":[function(require,module,exports,__globalThis) {\nexports.interopDefault = function(a) {\n return a && a.__esModule ? a : {\n default: a\n };\n};\nexports.defineInteropFlag = function(a) {\n Object.defineProperty(a, '__esModule', {\n value: true\n });\n};\nexports.exportAll = function(source, dest) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule' || Object.prototype.hasOwnProperty.call(dest, key)) return;\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function() {\n return source[key];\n }\n });\n });\n return dest;\n};\nexports.export = function(dest, destName, get) {\n Object.defineProperty(dest, destName, {\n enumerable: true,\n get: get\n });\n};\n\n},{}]},[\"bKI9O\"], \"bKI9O\", \"parcelRequire4dc0\", {})\nlet {default: _default, } = parcelRequire4dc0(\"bKI9O\");\nexport {_default as default, };\n\n//# sourceMappingURL=index.js.map\n","export default function artplayerPluginDocumentPip(userOptions = {}) {\n const options = {\n width: 480,\n height: 270,\n fallbackToVideoPiP: true,\n placeholder: `Playing in Document Picture-in-Picture`,\n ...userOptions,\n }\n\n return (art) => {\n const dpipOK = 'documentPictureInPicture' in window\n && typeof window.documentPictureInPicture?.requestWindow === 'function'\n\n const { proxy, icons, i18n, template: { $container }, constructor: { utils: { append, tooltip, addClass, removeClass } } } = art\n\n const state = {\n win: null,\n originalParent: null,\n originalNext: null,\n currentDoc: null,\n placeholder: null,\n }\n\n function copyStylesTo(targetDoc) {\n const base = targetDoc.createElement('style')\n base.textContent = `\n html, body { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; }\n #__art_dpip_root { position:absolute; inset:0; display:flex; }\n #__art_dpip_root > * { width:100% !important; height:100% !important; }\n `\n targetDoc.head.appendChild(base)\n if (!targetDoc.querySelector('meta[name=\"viewport\"]')) {\n const meta = targetDoc.createElement('meta')\n meta.name = 'viewport'\n meta.content = 'width=device-width,initial-scale=1'\n targetDoc.head.appendChild(meta)\n }\n\n try {\n document.querySelectorAll('link[rel=\"stylesheet\"]').forEach((link) => {\n const clone = targetDoc.createElement('link')\n clone.rel = 'stylesheet'\n clone.href = link.href\n if (link.media)\n clone.media = link.media\n if (link.crossOrigin)\n clone.crossOrigin = link.crossOrigin\n if (link.referrerPolicy)\n clone.referrerPolicy = link.referrerPolicy\n targetDoc.head.appendChild(clone)\n })\n }\n catch { }\n\n try {\n document.querySelectorAll('style').forEach((style) => {\n const clone = targetDoc.createElement('style')\n clone.textContent = style.textContent\n targetDoc.head.appendChild(clone)\n })\n }\n catch { }\n }\n\n async function open() {\n if (!dpipOK && options.fallbackToVideoPiP) {\n art.pip = true\n console.warn('[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture')\n return\n }\n\n if (state.win)\n return\n\n try {\n const pipWin = await window.documentPictureInPicture.requestWindow({\n width: options.width,\n height: options.height,\n })\n\n state.win = pipWin\n state.currentDoc = pipWin.document\n\n state.placeholder = document.createElement('div')\n state.placeholder.className = 'artplayer-pip-placeholder'\n state.placeholder.style.cssText = `display:flex;justify-content:center;align-items:center;width:100%;height:100%;`\n state.placeholder.textContent = options.placeholder\n state.originalParent = $container.parentNode\n state.originalNext = $container.nextSibling\n state.originalParent.insertBefore(state.placeholder, state.originalNext)\n\n const root = pipWin.document.createElement('div')\n root.id = '__art_dpip_root'\n pipWin.document.body.appendChild(root)\n\n copyStylesTo(pipWin.document)\n\n const adopted = pipWin.document.adoptNode($container)\n root.appendChild(adopted)\n state.currentDoc = pipWin.document\n\n const onResize = () => art.resize?.()\n const onClose = () => close()\n\n pipWin.addEventListener('resize', onResize)\n pipWin.addEventListener('pagehide', onClose)\n pipWin.addEventListener('unload', onClose)\n\n state.cleanup = () => {\n pipWin.removeEventListener('resize', onResize)\n pipWin.removeEventListener('pagehide', onClose)\n pipWin.removeEventListener('unload', onClose)\n }\n\n addClass($container, 'artplayer-document-pip')\n art.emit('document-pip', true)\n }\n catch (err) {\n art.notice.show = 'Document Picture-in-Picture open failed'\n console.warn('[artplayer-plugin-document-pip] open failed:', err)\n }\n }\n\n function restoreToOriginalDocument() {\n if (!state.placeholder)\n return\n const backDoc = state.placeholder.ownerDocument || document\n const adoptedBack = backDoc.adoptNode($container)\n state.originalParent.insertBefore(adoptedBack, state.placeholder)\n state.placeholder.remove()\n state.placeholder = null\n state.currentDoc = backDoc\n }\n\n function close() {\n if (!dpipOK && options.fallbackToVideoPiP) {\n art.pip = false\n return\n }\n\n if (!state.win)\n return\n try {\n state.cleanup?.()\n restoreToOriginalDocument()\n state.win.close()\n state.win = null\n removeClass($container, 'artplayer-document-pip')\n art.emit('document-pip', false)\n }\n catch (err) {\n art.notice.show = 'Document Picture-in-Picture close failed'\n console.warn('[artplayer-plugin-document-pip] close failed:', err)\n }\n }\n\n function toggle() {\n if (state.win) {\n close()\n }\n else {\n open()\n }\n }\n\n art.controls.add({\n name: 'document-pip',\n position: 'right',\n index: 40,\n tooltip: art.i18n.get('PIP Mode'),\n mounted: ($control) => {\n append($control, icons.pip)\n proxy($control, 'click', toggle)\n art.on('document-pip', (value) => {\n tooltip($control, i18n.get(value ? 'Exit PIP Mode' : 'PIP Mode'))\n })\n },\n })\n\n art.on('destroy', close)\n\n return {\n name: 'artplayerPluginDocumentPip',\n state,\n open,\n close,\n toggle,\n }\n }\n}\n\nif (typeof window !== 'undefined') {\n window.artplayerPluginDocumentPip = artplayerPluginDocumentPip\n}\n","exports.interopDefault = function (a) {\n return a && a.__esModule ? a : {default: a};\n};\n\nexports.defineInteropFlag = function (a) {\n Object.defineProperty(a, '__esModule', {value: true});\n};\n\nexports.exportAll = function (source, dest) {\n Object.keys(source).forEach(function (key) {\n if (\n key === 'default' ||\n key === '__esModule' ||\n Object.prototype.hasOwnProperty.call(dest, key)\n ) {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function () {\n return source[key];\n },\n });\n });\n\n return dest;\n};\n\nexports.export = function (dest, destName, get) {\n Object.defineProperty(dest, destName, {\n enumerable: true,\n get: get,\n });\n};\n"],"names":["modules","entry","mainEntry","parcelRequireName","externals","distDir","publicUrl","devServer","globalObject","globalThis","self","window","global","previousRequire","importMap","i","cache","nodeRequire","module","require","bind","newRequire","name","jumped","currentRequire","err","Error","code","localRequire","resolve","x","id","Module","call","exports","res","isParcelRequire","moduleName","bundle","parent","register","Object","defineProperty","get","length","mainExports","define","amd","__globalThis","parcelHelpers","artplayerPluginDocumentPip","userOptions","options","width","height","fallbackToVideoPiP","placeholder","art","dpipOK","documentPictureInPicture","requestWindow","proxy","icons","i18n","template","$container","utils","append","tooltip","addClass","removeClass","state","win","originalParent","originalNext","currentDoc","open","pip","console","warn","pipWin","document","createElement","className","style","cssText","textContent","parentNode","nextSibling","insertBefore","root","body","appendChild","targetDoc","base","head","querySelector","meta","content","querySelectorAll","forEach","link","clone","rel","href","media","crossOrigin","referrerPolicy","adopted","adoptNode","onResize","resize","onClose","close","addEventListener","cleanup","removeEventListener","emit","notice","show","restoreToOriginalDocument","backDoc","ownerDocument","adoptedBack","remove","toggle","controls","add","position","index","mounted","$control","on","value","defineInteropFlag","export","interopDefault","a","__esModule","default","exportAll","source","dest","keys","key","prototype","hasOwnProperty","enumerable","destName","_default","parcel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AC,CAAC,EAAM,GAAG,AAAC,EACpC,KAAA,EACA,MAAA,EACA,OAAA,CACF,CACF,CACF,C,E,iB,C,GAzLwB,EAAA,MAAA,CAAA,EAAA,UAAA,IAAA,GA2LpB,AAAkB,aAAlB,OAAO,QACT,CAAA,OAAO,0BAA0B,CAAG,CADtC,C,E,C,iD,O,E,C,Q,C,S,C,C,C,C,C,C,C,EC3LA,EAAQ,cAAc,CAAG,SAAU,CAAC,EAClC,OAAO,GAAK,EAAE,UAAU,CAAG,EAAI,CAAC,QAAS,CAAC,CAC5C,EAEA,EAAQ,iBAAiB,CAAG,SAAU,CAAC,EACrC,OAAO,cAAc,CAAC,EAAG,aAAc,CAAC,MAAO,CAAA,CAAI,EACrD,EAEA,EAAQ,SAAS,CAAG,SAAU,CAAM,CAAE,CAAI,EAkBxC,OAjBA,OAAO,IAAI,CAAC,GAAQ,OAAO,CAAC,SAAU,CAAG,EAE7B,YAAR,GACA,AAAQ,eAAR,GACA,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,EAAM,IAK7C,OAAO,cAAc,CAAC,EAAM,EAAK,CAC/B,WAAY,CAAA,EACZ,IAAK,WACH,OAAO,CAAM,CAAC,EAAI,AACpB,CACF,EACF,GAEO,CACT,EAEA,EAAQ,MAAM,CAAG,SAAU,CAAI,CAAE,CAAQ,CAAE,CAAG,EAC5C,OAAO,cAAc,CAAC,EAAM,EAAU,CACpC,WAAY,CAAA,EACZ,IAAK,CACP,EACF,C,E,C,E,E,C,Q,C,Q,oB,C,G,G,C,Q,C,C,C,kB,gB,K,O","sources":["","packages/artplayer-plugin-document-pip/src/index.js","node_modules/@parcel/transformer-js/src/esmodule-helpers.js"],"sourcesContent":["// modules are defined as an array\n// [ module function, map of requires ]\n//\n// map of requires is short require name -> numeric require\n//\n// anything defined in a previous bundle is accessed via the\n// orig method which is the require for previous bundles\n\n(function (\n modules,\n entry,\n mainEntry,\n parcelRequireName,\n externals,\n distDir,\n publicUrl,\n devServer\n) {\n /* eslint-disable no-undef */\n var globalObject =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n /* eslint-enable no-undef */\n\n // Save the require from previous bundle to this closure if any\n var previousRequire =\n typeof globalObject[parcelRequireName] === 'function' &&\n globalObject[parcelRequireName];\n\n var importMap = previousRequire.i || {};\n var cache = previousRequire.cache || {};\n // Do not use `require` to prevent Webpack from trying to bundle this call\n var nodeRequire =\n typeof module !== 'undefined' &&\n typeof module.require === 'function' &&\n module.require.bind(module);\n\n function newRequire(name, jumped) {\n if (!cache[name]) {\n if (!modules[name]) {\n if (externals[name]) {\n return externals[name];\n }\n // if we cannot find the module within our internal map or\n // cache jump to the current global require ie. the last bundle\n // that was added to the page.\n var currentRequire =\n typeof globalObject[parcelRequireName] === 'function' &&\n globalObject[parcelRequireName];\n if (!jumped && currentRequire) {\n return currentRequire(name, true);\n }\n\n // If there are other bundles on this page the require from the\n // previous one is saved to 'previousRequire'. Repeat this as\n // many times as there are bundles until the module is found or\n // we exhaust the require chain.\n if (previousRequire) {\n return previousRequire(name, true);\n }\n\n // Try the node require function if it exists.\n if (nodeRequire && typeof name === 'string') {\n return nodeRequire(name);\n }\n\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n }\n\n localRequire.resolve = resolve;\n localRequire.cache = {};\n\n var module = (cache[name] = new newRequire.Module(name));\n\n modules[name][0].call(\n module.exports,\n localRequire,\n module,\n module.exports,\n globalObject\n );\n }\n\n return cache[name].exports;\n\n function localRequire(x) {\n var res = localRequire.resolve(x);\n return res === false ? {} : newRequire(res);\n }\n\n function resolve(x) {\n var id = modules[name][1][x];\n return id != null ? id : x;\n }\n }\n\n function Module(moduleName) {\n this.id = moduleName;\n this.bundle = newRequire;\n this.require = nodeRequire;\n this.exports = {};\n }\n\n newRequire.isParcelRequire = true;\n newRequire.Module = Module;\n newRequire.modules = modules;\n newRequire.cache = cache;\n newRequire.parent = previousRequire;\n newRequire.distDir = distDir;\n newRequire.publicUrl = publicUrl;\n newRequire.devServer = devServer;\n newRequire.i = importMap;\n newRequire.register = function (id, exports) {\n modules[id] = [\n function (require, module) {\n module.exports = exports;\n },\n {},\n ];\n };\n\n // Only insert newRequire.load when it is actually used.\n // The code in this file is linted against ES5, so dynamic import is not allowed.\n // INSERT_LOAD_HERE\n\n Object.defineProperty(newRequire, 'root', {\n get: function () {\n return globalObject[parcelRequireName];\n },\n });\n\n globalObject[parcelRequireName] = newRequire;\n\n for (var i = 0; i < entry.length; i++) {\n newRequire(entry[i]);\n }\n\n if (mainEntry) {\n // Expose entry point to Node, AMD or browser globals\n // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js\n var mainExports = newRequire(mainEntry);\n\n // CommonJS\n if (typeof exports === 'object' && typeof module !== 'undefined') {\n module.exports = mainExports;\n\n // RequireJS\n } else if (typeof define === 'function' && define.amd) {\n define(function () {\n return mainExports;\n });\n }\n }\n})({\"bKI9O\":[function(require,module,exports,__globalThis) {\nvar parcelHelpers = require(\"@parcel/transformer-js/src/esmodule-helpers.js\");\nparcelHelpers.defineInteropFlag(exports);\nparcelHelpers.export(exports, \"default\", ()=>artplayerPluginDocumentPip);\nfunction artplayerPluginDocumentPip(userOptions = {}) {\n const options = {\n width: 480,\n height: 270,\n fallbackToVideoPiP: true,\n placeholder: `Playing in Document Picture-in-Picture`,\n ...userOptions\n };\n return (art)=>{\n const isSupported = 'documentPictureInPicture' in window && typeof window.documentPictureInPicture?.requestWindow === 'function';\n const { proxy, icons, i18n, template: { $container }, constructor: { utils: { append, tooltip, addClass, removeClass } } } = art;\n const state = {\n win: null,\n originalParent: null,\n originalNext: null,\n currentDoc: null,\n placeholder: null\n };\n function copyStylesTo(targetDoc) {\n const base = targetDoc.createElement('style');\n base.textContent = `\n html, body { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; }\n #__art_dpip_root { position:absolute; inset:0; display:flex; }\n #__art_dpip_root > * { width:100% !important; height:100% !important; }\n `;\n targetDoc.head.appendChild(base);\n if (!targetDoc.querySelector('meta[name=\"viewport\"]')) {\n const meta = targetDoc.createElement('meta');\n meta.name = 'viewport';\n meta.content = 'width=device-width,initial-scale=1';\n targetDoc.head.appendChild(meta);\n }\n try {\n document.querySelectorAll('link[rel=\"stylesheet\"]').forEach((link)=>{\n const clone = targetDoc.createElement('link');\n clone.rel = 'stylesheet';\n clone.href = link.href;\n if (link.media) clone.media = link.media;\n if (link.crossOrigin) clone.crossOrigin = link.crossOrigin;\n if (link.referrerPolicy) clone.referrerPolicy = link.referrerPolicy;\n targetDoc.head.appendChild(clone);\n });\n } catch {}\n try {\n document.querySelectorAll('style').forEach((style)=>{\n const clone = targetDoc.createElement('style');\n clone.textContent = style.textContent;\n targetDoc.head.appendChild(clone);\n });\n } catch {}\n }\n async function open() {\n if (!isSupported && options.fallbackToVideoPiP) {\n art.pip = true;\n console.warn('[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture');\n return;\n }\n if (state.win) return;\n try {\n const pipWin = await window.documentPictureInPicture.requestWindow({\n width: options.width,\n height: options.height\n });\n state.win = pipWin;\n state.currentDoc = pipWin.document;\n state.placeholder = document.createElement('div');\n state.placeholder.className = 'artplayer-pip-placeholder';\n state.placeholder.style.cssText = `display:flex;justify-content:center;align-items:center;width:100%;height:100%;`;\n state.placeholder.textContent = options.placeholder;\n state.originalParent = $container.parentNode;\n state.originalNext = $container.nextSibling;\n state.originalParent.insertBefore(state.placeholder, state.originalNext);\n const root = pipWin.document.createElement('div');\n root.id = '__art_dpip_root';\n pipWin.document.body.appendChild(root);\n copyStylesTo(pipWin.document);\n const adopted = pipWin.document.adoptNode($container);\n root.appendChild(adopted);\n state.currentDoc = pipWin.document;\n const onResize = ()=>art.resize?.();\n const onClose = ()=>close();\n pipWin.addEventListener('resize', onResize);\n pipWin.addEventListener('pagehide', onClose);\n pipWin.addEventListener('unload', onClose);\n state.cleanup = ()=>{\n pipWin.removeEventListener('resize', onResize);\n pipWin.removeEventListener('pagehide', onClose);\n pipWin.removeEventListener('unload', onClose);\n };\n addClass($container, 'artplayer-document-pip');\n art.emit('document-pip', true);\n } catch (err) {\n art.notice.show = 'Document Picture-in-Picture open failed';\n console.warn('[artplayer-plugin-document-pip] open failed:', err);\n }\n }\n function restoreToOriginalDocument() {\n if (!state.placeholder) return;\n const backDoc = state.placeholder.ownerDocument || document;\n const adoptedBack = backDoc.adoptNode($container);\n state.originalParent.insertBefore(adoptedBack, state.placeholder);\n state.placeholder.remove();\n state.placeholder = null;\n state.currentDoc = backDoc;\n }\n function close() {\n if (!state.win) return;\n try {\n state.cleanup?.();\n restoreToOriginalDocument();\n state.win.close();\n state.win = null;\n removeClass($container, 'artplayer-document-pip');\n art.emit('document-pip', false);\n } catch (err) {\n art.notice.show = 'Document Picture-in-Picture close failed';\n console.warn('[artplayer-plugin-document-pip] close failed:', err);\n }\n }\n function toggle() {\n if (state.win) close();\n else open();\n }\n art.controls.add({\n name: 'document-pip',\n position: 'right',\n index: 40,\n tooltip: art.i18n.get('PIP Mode'),\n mounted: ($control)=>{\n append($control, icons.pip);\n proxy($control, 'click', toggle);\n art.on('document-pip', (value)=>{\n tooltip($control, i18n.get(value ? 'Exit PIP Mode' : 'PIP Mode'));\n });\n }\n });\n art.on('destroy', close);\n return {\n name: 'artplayerPluginDocumentPip',\n get isSupported () {\n return isSupported;\n },\n get isActive () {\n return !!state.win;\n },\n open,\n close,\n toggle\n };\n };\n}\nif (typeof window !== 'undefined') window.artplayerPluginDocumentPip = artplayerPluginDocumentPip;\n\n},{\"@parcel/transformer-js/src/esmodule-helpers.js\":\"5lQoW\"}],\"5lQoW\":[function(require,module,exports,__globalThis) {\nexports.interopDefault = function(a) {\n return a && a.__esModule ? a : {\n default: a\n };\n};\nexports.defineInteropFlag = function(a) {\n Object.defineProperty(a, '__esModule', {\n value: true\n });\n};\nexports.exportAll = function(source, dest) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule' || Object.prototype.hasOwnProperty.call(dest, key)) return;\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function() {\n return source[key];\n }\n });\n });\n return dest;\n};\nexports.export = function(dest, destName, get) {\n Object.defineProperty(dest, destName, {\n enumerable: true,\n get: get\n });\n};\n\n},{}]},[\"bKI9O\"], \"bKI9O\", \"parcelRequire4dc0\", {})\nlet {default: _default, } = parcelRequire4dc0(\"bKI9O\");\nexport {_default as default, };\n\n//# sourceMappingURL=index.js.map\n","export default function artplayerPluginDocumentPip(userOptions = {}) {\n const options = {\n width: 480,\n height: 270,\n fallbackToVideoPiP: true,\n placeholder: `Playing in Document Picture-in-Picture`,\n ...userOptions,\n }\n\n return (art) => {\n const isSupported = 'documentPictureInPicture' in window\n && typeof window.documentPictureInPicture?.requestWindow === 'function'\n\n const { proxy, icons, i18n, template: { $container }, constructor: { utils: { append, tooltip, addClass, removeClass } } } = art\n\n const state = {\n win: null,\n originalParent: null,\n originalNext: null,\n currentDoc: null,\n placeholder: null,\n }\n\n function copyStylesTo(targetDoc) {\n const base = targetDoc.createElement('style')\n base.textContent = `\n html, body { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; }\n #__art_dpip_root { position:absolute; inset:0; display:flex; }\n #__art_dpip_root > * { width:100% !important; height:100% !important; }\n `\n targetDoc.head.appendChild(base)\n if (!targetDoc.querySelector('meta[name=\"viewport\"]')) {\n const meta = targetDoc.createElement('meta')\n meta.name = 'viewport'\n meta.content = 'width=device-width,initial-scale=1'\n targetDoc.head.appendChild(meta)\n }\n\n try {\n document.querySelectorAll('link[rel=\"stylesheet\"]').forEach((link) => {\n const clone = targetDoc.createElement('link')\n clone.rel = 'stylesheet'\n clone.href = link.href\n if (link.media)\n clone.media = link.media\n if (link.crossOrigin)\n clone.crossOrigin = link.crossOrigin\n if (link.referrerPolicy)\n clone.referrerPolicy = link.referrerPolicy\n targetDoc.head.appendChild(clone)\n })\n }\n catch { }\n\n try {\n document.querySelectorAll('style').forEach((style) => {\n const clone = targetDoc.createElement('style')\n clone.textContent = style.textContent\n targetDoc.head.appendChild(clone)\n })\n }\n catch { }\n }\n\n async function open() {\n if (!isSupported && options.fallbackToVideoPiP) {\n art.pip = true\n console.warn('[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture')\n return\n }\n\n if (state.win)\n return\n\n try {\n const pipWin = await window.documentPictureInPicture.requestWindow({\n width: options.width,\n height: options.height,\n })\n\n state.win = pipWin\n state.currentDoc = pipWin.document\n\n state.placeholder = document.createElement('div')\n state.placeholder.className = 'artplayer-pip-placeholder'\n state.placeholder.style.cssText = `display:flex;justify-content:center;align-items:center;width:100%;height:100%;`\n state.placeholder.textContent = options.placeholder\n state.originalParent = $container.parentNode\n state.originalNext = $container.nextSibling\n state.originalParent.insertBefore(state.placeholder, state.originalNext)\n\n const root = pipWin.document.createElement('div')\n root.id = '__art_dpip_root'\n pipWin.document.body.appendChild(root)\n\n copyStylesTo(pipWin.document)\n\n const adopted = pipWin.document.adoptNode($container)\n root.appendChild(adopted)\n state.currentDoc = pipWin.document\n\n const onResize = () => art.resize?.()\n const onClose = () => close()\n\n pipWin.addEventListener('resize', onResize)\n pipWin.addEventListener('pagehide', onClose)\n pipWin.addEventListener('unload', onClose)\n\n state.cleanup = () => {\n pipWin.removeEventListener('resize', onResize)\n pipWin.removeEventListener('pagehide', onClose)\n pipWin.removeEventListener('unload', onClose)\n }\n\n addClass($container, 'artplayer-document-pip')\n art.emit('document-pip', true)\n }\n catch (err) {\n art.notice.show = 'Document Picture-in-Picture open failed'\n console.warn('[artplayer-plugin-document-pip] open failed:', err)\n }\n }\n\n function restoreToOriginalDocument() {\n if (!state.placeholder)\n return\n const backDoc = state.placeholder.ownerDocument || document\n const adoptedBack = backDoc.adoptNode($container)\n state.originalParent.insertBefore(adoptedBack, state.placeholder)\n state.placeholder.remove()\n state.placeholder = null\n state.currentDoc = backDoc\n }\n\n function close() {\n if (!state.win)\n return\n try {\n state.cleanup?.()\n restoreToOriginalDocument()\n state.win.close()\n state.win = null\n removeClass($container, 'artplayer-document-pip')\n art.emit('document-pip', false)\n }\n catch (err) {\n art.notice.show = 'Document Picture-in-Picture close failed'\n console.warn('[artplayer-plugin-document-pip] close failed:', err)\n }\n }\n\n function toggle() {\n if (state.win) {\n close()\n }\n else {\n open()\n }\n }\n\n art.controls.add({\n name: 'document-pip',\n position: 'right',\n index: 40,\n tooltip: art.i18n.get('PIP Mode'),\n mounted: ($control) => {\n append($control, icons.pip)\n proxy($control, 'click', toggle)\n art.on('document-pip', (value) => {\n tooltip($control, i18n.get(value ? 'Exit PIP Mode' : 'PIP Mode'))\n })\n },\n })\n\n art.on('destroy', close)\n\n return {\n name: 'artplayerPluginDocumentPip',\n get isSupported() { return isSupported },\n get isActive() { return !!state.win },\n open,\n close,\n toggle,\n }\n }\n}\n\nif (typeof window !== 'undefined') {\n window.artplayerPluginDocumentPip = artplayerPluginDocumentPip\n}\n","exports.interopDefault = function (a) {\n return a && a.__esModule ? a : {default: a};\n};\n\nexports.defineInteropFlag = function (a) {\n Object.defineProperty(a, '__esModule', {value: true});\n};\n\nexports.exportAll = function (source, dest) {\n Object.keys(source).forEach(function (key) {\n if (\n key === 'default' ||\n key === '__esModule' ||\n Object.prototype.hasOwnProperty.call(dest, key)\n ) {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function () {\n return source[key];\n },\n });\n });\n\n return dest;\n};\n\nexports.export = function (dest, destName, get) {\n Object.defineProperty(dest, destName, {\n enumerable: true,\n get: get,\n });\n};\n"],"names":["modules","entry","mainEntry","parcelRequireName","externals","distDir","publicUrl","devServer","globalObject","globalThis","self","window","global","previousRequire","importMap","i","cache","nodeRequire","module","require","bind","newRequire","name","jumped","currentRequire","err","Error","code","localRequire","resolve","x","id","Module","call","exports","res","isParcelRequire","moduleName","bundle","parent","register","Object","defineProperty","get","length","mainExports","define","amd","__globalThis","parcelHelpers","artplayerPluginDocumentPip","userOptions","options","width","height","fallbackToVideoPiP","placeholder","art","isSupported","documentPictureInPicture","requestWindow","proxy","icons","i18n","template","$container","utils","append","tooltip","addClass","removeClass","state","win","originalParent","originalNext","currentDoc","open","pip","console","warn","pipWin","document","createElement","className","style","cssText","textContent","parentNode","nextSibling","insertBefore","root","body","appendChild","targetDoc","base","head","querySelector","meta","content","querySelectorAll","forEach","link","clone","rel","href","media","crossOrigin","referrerPolicy","adopted","adoptNode","onResize","resize","onClose","close","addEventListener","cleanup","removeEventListener","emit","notice","show","restoreToOriginalDocument","backDoc","ownerDocument","adoptedBack","remove","toggle","controls","add","position","index","mounted","$control","on","value","isActive","defineInteropFlag","export","interopDefault","a","__esModule","default","exportAll","source","dest","keys","key","prototype","hasOwnProperty","enumerable","destName","_default","parcelRequire4dc0"],"version":3,"file":"index.js.map"} \ No newline at end of file diff --git a/packages/artplayer-plugin-document-pip/dist/artplayer-plugin-document-pip.js b/packages/artplayer-plugin-document-pip/dist/artplayer-plugin-document-pip.js index 64826e0ec..a7cc112a7 100644 --- a/packages/artplayer-plugin-document-pip/dist/artplayer-plugin-document-pip.js +++ b/packages/artplayer-plugin-document-pip/dist/artplayer-plugin-document-pip.js @@ -5,4 +5,4 @@ * (c) 2017-2025 Harvey Zack * Released under the MIT License. */ -!function(e,t,n,r,i,o,l,c){var d="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},a="function"==typeof d[r]&&d[r],u=a.i||{},p=a.cache||{},f="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function s(t,n){if(!p[t]){if(!e[t]){if(i[t])return i[t];var o="function"==typeof d[r]&&d[r];if(!n&&o)return o(t,!0);if(a)return a(t,!0);if(f&&"string"==typeof t)return f(t);var l=Error("Cannot find module '"+t+"'");throw l.code="MODULE_NOT_FOUND",l}u.resolve=function(n){var r=e[t][1][n];return null!=r?r:n},u.cache={};var c=p[t]=new s.Module(t);e[t][0].call(c.exports,u,c,c.exports,d)}return p[t].exports;function u(e){var t=u.resolve(e);return!1===t?{}:s(t)}}s.isParcelRequire=!0,s.Module=function(e){this.id=e,this.bundle=s,this.require=f,this.exports={}},s.modules=e,s.cache=p,s.parent=a,s.distDir=void 0,s.publicUrl=void 0,s.devServer=void 0,s.i=u,s.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(s,"root",{get:function(){return d[r]}}),d[r]=s;for(var h=0;h{let n="documentPictureInPicture"in window&&"function"==typeof window.documentPictureInPicture?.requestWindow,{proxy:r,icons:i,i18n:o,template:{$container:l},constructor:{utils:{append:c,tooltip:d,addClass:a,removeClass:u}}}=e,p={win:null,originalParent:null,originalNext:null,currentDoc:null,placeholder:null};async function f(){if(!n&&t.fallbackToVideoPiP){e.pip=!0,console.warn("[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture");return}if(!p.win)try{let n=await window.documentPictureInPicture.requestWindow({width:t.width,height:t.height});p.win=n,p.currentDoc=n.document,p.placeholder=document.createElement("div"),p.placeholder.className="artplayer-pip-placeholder",p.placeholder.style.cssText="display:flex;justify-content:center;align-items:center;width:100%;height:100%;",p.placeholder.textContent=t.placeholder,p.originalParent=l.parentNode,p.originalNext=l.nextSibling,p.originalParent.insertBefore(p.placeholder,p.originalNext);let i=n.document.createElement("div");i.id="__art_dpip_root",n.document.body.appendChild(i);var r=n.document;let o=r.createElement("style");if(o.textContent=` html, body { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; } #__art_dpip_root { position:absolute; inset:0; display:flex; } #__art_dpip_root > * { width:100% !important; height:100% !important; } `,r.head.appendChild(o),!r.querySelector('meta[name="viewport"]')){let e=r.createElement("meta");e.name="viewport",e.content="width=device-width,initial-scale=1",r.head.appendChild(e)}try{document.querySelectorAll('link[rel="stylesheet"]').forEach(e=>{let t=r.createElement("link");t.rel="stylesheet",t.href=e.href,e.media&&(t.media=e.media),e.crossOrigin&&(t.crossOrigin=e.crossOrigin),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),r.head.appendChild(t)})}catch{}try{document.querySelectorAll("style").forEach(e=>{let t=r.createElement("style");t.textContent=e.textContent,r.head.appendChild(t)})}catch{}let c=n.document.adoptNode(l);i.appendChild(c),p.currentDoc=n.document;let d=()=>e.resize?.(),u=()=>s();n.addEventListener("resize",d),n.addEventListener("pagehide",u),n.addEventListener("unload",u),p.cleanup=()=>{n.removeEventListener("resize",d),n.removeEventListener("pagehide",u),n.removeEventListener("unload",u)},a(l,"artplayer-document-pip"),e.emit("document-pip",!0)}catch(t){e.notice.show="Document Picture-in-Picture open failed",console.warn("[artplayer-plugin-document-pip] open failed:",t)}}function s(){if(!n&&t.fallbackToVideoPiP){e.pip=!1;return}if(p.win)try{p.cleanup?.(),function(){if(!p.placeholder)return;let e=p.placeholder.ownerDocument||document,t=e.adoptNode(l);p.originalParent.insertBefore(t,p.placeholder),p.placeholder.remove(),p.placeholder=null,p.currentDoc=e}(),p.win.close(),p.win=null,u(l,"artplayer-document-pip"),e.emit("document-pip",!1)}catch(t){e.notice.show="Document Picture-in-Picture close failed",console.warn("[artplayer-plugin-document-pip] close failed:",t)}}function h(){p.win?s():f()}return e.controls.add({name:"document-pip",position:"right",index:40,tooltip:e.i18n.get("PIP Mode"),mounted:t=>{c(t,i.pip),r(t,"click",h),e.on("document-pip",e=>{d(t,o.get(e?"Exit PIP Mode":"PIP Mode"))})}}),e.on("destroy",s),{name:"artplayerPluginDocumentPip",state:p,open:f,close:s,toggle:h}}}i.defineInteropFlag(n),i.export(n,"default",()=>o),"undefined"!=typeof window&&(window.artplayerPluginDocumentPip=o)},{"@parcel/transformer-js/src/esmodule-helpers.js":"6ykb1"}],"6ykb1":[function(e,t,n,r){n.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},n.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.exportAll=function(e,t){return Object.keys(e).forEach(function(n){"default"===n||"__esModule"===n||Object.prototype.hasOwnProperty.call(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[n]}})}),t},n.export=function(e,t,n){Object.defineProperty(e,t,{enumerable:!0,get:n})}},{}]},["eo8f0"],"eo8f0","parcelRequire4dc0",{}); \ No newline at end of file +!function(e,t,n,r,i,o,l,c){var d="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},u="function"==typeof d[r]&&d[r],a=u.i||{},p=u.cache||{},f="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function s(t,n){if(!p[t]){if(!e[t]){if(i[t])return i[t];var o="function"==typeof d[r]&&d[r];if(!n&&o)return o(t,!0);if(u)return u(t,!0);if(f&&"string"==typeof t)return f(t);var l=Error("Cannot find module '"+t+"'");throw l.code="MODULE_NOT_FOUND",l}a.resolve=function(n){var r=e[t][1][n];return null!=r?r:n},a.cache={};var c=p[t]=new s.Module(t);e[t][0].call(c.exports,a,c,c.exports,d)}return p[t].exports;function a(e){var t=a.resolve(e);return!1===t?{}:s(t)}}s.isParcelRequire=!0,s.Module=function(e){this.id=e,this.bundle=s,this.require=f,this.exports={}},s.modules=e,s.cache=p,s.parent=u,s.distDir=void 0,s.publicUrl=void 0,s.devServer=void 0,s.i=a,s.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(s,"root",{get:function(){return d[r]}}),d[r]=s;for(var h=0;h{let n="documentPictureInPicture"in window&&"function"==typeof window.documentPictureInPicture?.requestWindow,{proxy:r,icons:i,i18n:o,template:{$container:l},constructor:{utils:{append:c,tooltip:d,addClass:u,removeClass:a}}}=e,p={win:null,originalParent:null,originalNext:null,currentDoc:null,placeholder:null};async function f(){if(!n&&t.fallbackToVideoPiP){e.pip=!0,console.warn("[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture");return}if(!p.win)try{let n=await window.documentPictureInPicture.requestWindow({width:t.width,height:t.height});p.win=n,p.currentDoc=n.document,p.placeholder=document.createElement("div"),p.placeholder.className="artplayer-pip-placeholder",p.placeholder.style.cssText="display:flex;justify-content:center;align-items:center;width:100%;height:100%;",p.placeholder.textContent=t.placeholder,p.originalParent=l.parentNode,p.originalNext=l.nextSibling,p.originalParent.insertBefore(p.placeholder,p.originalNext);let i=n.document.createElement("div");i.id="__art_dpip_root",n.document.body.appendChild(i);var r=n.document;let o=r.createElement("style");if(o.textContent=` html, body { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; } #__art_dpip_root { position:absolute; inset:0; display:flex; } #__art_dpip_root > * { width:100% !important; height:100% !important; } `,r.head.appendChild(o),!r.querySelector('meta[name="viewport"]')){let e=r.createElement("meta");e.name="viewport",e.content="width=device-width,initial-scale=1",r.head.appendChild(e)}try{document.querySelectorAll('link[rel="stylesheet"]').forEach(e=>{let t=r.createElement("link");t.rel="stylesheet",t.href=e.href,e.media&&(t.media=e.media),e.crossOrigin&&(t.crossOrigin=e.crossOrigin),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),r.head.appendChild(t)})}catch{}try{document.querySelectorAll("style").forEach(e=>{let t=r.createElement("style");t.textContent=e.textContent,r.head.appendChild(t)})}catch{}let c=n.document.adoptNode(l);i.appendChild(c),p.currentDoc=n.document;let d=()=>e.resize?.(),a=()=>s();n.addEventListener("resize",d),n.addEventListener("pagehide",a),n.addEventListener("unload",a),p.cleanup=()=>{n.removeEventListener("resize",d),n.removeEventListener("pagehide",a),n.removeEventListener("unload",a)},u(l,"artplayer-document-pip"),e.emit("document-pip",!0)}catch(t){e.notice.show="Document Picture-in-Picture open failed",console.warn("[artplayer-plugin-document-pip] open failed:",t)}}function s(){if(p.win)try{p.cleanup?.(),function(){if(!p.placeholder)return;let e=p.placeholder.ownerDocument||document,t=e.adoptNode(l);p.originalParent.insertBefore(t,p.placeholder),p.placeholder.remove(),p.placeholder=null,p.currentDoc=e}(),p.win.close(),p.win=null,a(l,"artplayer-document-pip"),e.emit("document-pip",!1)}catch(t){e.notice.show="Document Picture-in-Picture close failed",console.warn("[artplayer-plugin-document-pip] close failed:",t)}}function h(){p.win?s():f()}return e.controls.add({name:"document-pip",position:"right",index:40,tooltip:e.i18n.get("PIP Mode"),mounted:t=>{c(t,i.pip),r(t,"click",h),e.on("document-pip",e=>{d(t,o.get(e?"Exit PIP Mode":"PIP Mode"))})}}),e.on("destroy",s),{name:"artplayerPluginDocumentPip",get isSupported(){return n},get isActive(){return!!p.win},open:f,close:s,toggle:h}}}i.defineInteropFlag(n),i.export(n,"default",()=>o),"undefined"!=typeof window&&(window.artplayerPluginDocumentPip=o)},{"@parcel/transformer-js/src/esmodule-helpers.js":"6ykb1"}],"6ykb1":[function(e,t,n,r){n.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},n.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.exportAll=function(e,t){return Object.keys(e).forEach(function(n){"default"===n||"__esModule"===n||Object.prototype.hasOwnProperty.call(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[n]}})}),t},n.export=function(e,t,n){Object.defineProperty(e,t,{enumerable:!0,get:n})}},{}]},["eo8f0"],"eo8f0","parcelRequire4dc0",{}); \ No newline at end of file diff --git a/packages/artplayer-plugin-document-pip/dist/artplayer-plugin-document-pip.legacy.js b/packages/artplayer-plugin-document-pip/dist/artplayer-plugin-document-pip.legacy.js index 6ef74aec0..02e1724f0 100644 --- a/packages/artplayer-plugin-document-pip/dist/artplayer-plugin-document-pip.legacy.js +++ b/packages/artplayer-plugin-document-pip/dist/artplayer-plugin-document-pip.legacy.js @@ -5,4 +5,4 @@ * (c) 2017-2025 Harvey Zack * Released under the MIT License. */ -!function(e,t,r,n,o,i,c,a){var u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},l="function"==typeof u[n]&&u[n],s=l.i||{},f=l.cache||{},p="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function d(t,r){if(!f[t]){if(!e[t]){if(o[t])return o[t];var i="function"==typeof u[n]&&u[n];if(!r&&i)return i(t,!0);if(l)return l(t,!0);if(p&&"string"==typeof t)return p(t);var c=Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}s.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},s.cache={};var a=f[t]=new d.Module(t);e[t][0].call(a.exports,s,a,a.exports,u)}return f[t].exports;function s(e){var t=s.resolve(e);return!1===t?{}:d(t)}}d.isParcelRequire=!0,d.Module=function(e){this.id=e,this.bundle=d,this.require=p,this.exports={}},d.modules=e,d.cache=f,d.parent=l,d.distDir=void 0,d.publicUrl=void 0,d.devServer=void 0,d.i=s,d.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(d,"root",{get:function(){return u[n]}}),u[n]=d;for(var y=0;y0&&void 0!==arguments[0]?arguments[0]:{},t=(0,c._)({width:480,height:270,fallbackToVideoPiP:!0,placeholder:"Playing in Document Picture-in-Picture"},e);return function(e){var r,n="documentPictureInPicture"in window&&"function"==typeof(null==(r=window.documentPictureInPicture)?void 0:r.requestWindow),o=e.proxy,c=e.icons,u=e.i18n,l=e.template.$container,s=e.constructor.utils,f=s.append,p=s.tooltip,d=s.addClass,y=s.removeClass,h={win:null,originalParent:null,originalNext:null,currentDoc:null,placeholder:null};function _(){return(0,i._)(function(){var r,o,i,c,u,s;return(0,a._)(this,function(a){switch(a.label){case 0:if(!n&&t.fallbackToVideoPiP)return e.pip=!0,console.warn("[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture"),[2];if(h.win)return[2];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,window.documentPictureInPicture.requestWindow({width:t.width,height:t.height})];case 2:h.win=r=a.sent(),h.currentDoc=r.document,h.placeholder=document.createElement("div"),h.placeholder.className="artplayer-pip-placeholder",h.placeholder.style.cssText="display:flex;justify-content:center;align-items:center;width:100%;height:100%;",h.placeholder.textContent=t.placeholder,h.originalParent=l.parentNode,h.originalNext=l.nextSibling,h.originalParent.insertBefore(h.placeholder,h.originalNext),(o=r.document.createElement("div")).id="__art_dpip_root",r.document.body.appendChild(o);var f=r.document,p=f.createElement("style");if(p.textContent="\n html, body { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; }\n #__art_dpip_root { position:absolute; inset:0; display:flex; }\n #__art_dpip_root > * { width:100% !important; height:100% !important; }\n ",f.head.appendChild(p),!f.querySelector('meta[name="viewport"]')){var y=f.createElement("meta");y.name="viewport",y.content="width=device-width,initial-scale=1",f.head.appendChild(y)}try{document.querySelectorAll('link[rel="stylesheet"]').forEach(function(e){var t=f.createElement("link");t.rel="stylesheet",t.href=e.href,e.media&&(t.media=e.media),e.crossOrigin&&(t.crossOrigin=e.crossOrigin),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),f.head.appendChild(t)})}catch(e){}try{document.querySelectorAll("style").forEach(function(e){var t=f.createElement("style");t.textContent=e.textContent,f.head.appendChild(t)})}catch(e){}return i=r.document.adoptNode(l),o.appendChild(i),h.currentDoc=r.document,c=function(){var t;return null==(t=e.resize)?void 0:t.call(e)},u=function(){return v()},r.addEventListener("resize",c),r.addEventListener("pagehide",u),r.addEventListener("unload",u),h.cleanup=function(){r.removeEventListener("resize",c),r.removeEventListener("pagehide",u),r.removeEventListener("unload",u)},d(l,"artplayer-document-pip"),e.emit("document-pip",!0),[3,4];case 3:return s=a.sent(),e.notice.show="Document Picture-in-Picture open failed",console.warn("[artplayer-plugin-document-pip] open failed:",s),[3,4];case 4:return[2]}})})()}function v(){if(!n&&t.fallbackToVideoPiP){e.pip=!1;return}if(h.win)try{var r;if(null==(r=h.cleanup)||r.call(h),h.placeholder){var o=h.placeholder.ownerDocument||document,i=o.adoptNode(l);h.originalParent.insertBefore(i,h.placeholder),h.placeholder.remove(),h.placeholder=null,h.currentDoc=o}h.win.close(),h.win=null,y(l,"artplayer-document-pip"),e.emit("document-pip",!1)}catch(t){e.notice.show="Document Picture-in-Picture close failed",console.warn("[artplayer-plugin-document-pip] close failed:",t)}}function m(){h.win?v():_()}return e.controls.add({name:"document-pip",position:"right",index:40,tooltip:e.i18n.get("PIP Mode"),mounted:function(t){f(t,c.pip),o(t,"click",m),e.on("document-pip",function(e){p(t,u.get(e?"Exit PIP Mode":"PIP Mode"))})}}),e.on("destroy",v),{name:"artplayerPluginDocumentPip",state:h,open:_,close:v,toggle:m}}}"undefined"!=typeof window&&(window.artplayerPluginDocumentPip=u)},{"@swc/helpers/cjs/_async_to_generator.cjs":"cZn0e","@swc/helpers/cjs/_object_spread.cjs":"kyoEj","@swc/helpers/cjs/_ts_generator.cjs":"eltGh","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],cZn0e:[function(e,t,r,n){"use strict";function o(e,t,r,n,o,i,c){try{var a=e[i](c),u=a.value}catch(e){r(e);return}a.done?t(u):Promise.resolve(u).then(n,o)}r._=function(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var c=e.apply(t,r);function a(e){o(c,n,i,a,u,"next",e)}function u(e){o(c,n,i,a,u,"throw",e)}a(void 0)})}}},{}],kyoEj:[function(e,t,r,n){"use strict";var o=e("9f9b8a24218ee51e");r._=function(e){for(var t=1;tt.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var o=0,n=Object.getOwnPropertySymbols(e);ot.indexOf(n[o])&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]]);return r}function s(e,t,r,n){var o,c=arguments.length,a=c<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if(("undefined"==typeof Reflect?"undefined":(0,i._)(Reflect))==="object"&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var u=e.length-1;u>=0;u--)(o=e[u])&&(a=(c<3?o(a):c>3?o(t,r,a):o(t,r))||a);return c>3&&a&&Object.defineProperty(t,r,a),a}function f(e,t){return function(r,n){t(r,n,e)}}function p(e,t,r,n,o,c){function a(e){if(void 0!==e&&"function"!=typeof e)throw TypeError("Function expected");return e}for(var u,l=n.kind,s="getter"===l?"get":"setter"===l?"set":"value",f=!t&&e?n.static?e:e.prototype:null,p=t||(f?Object.getOwnPropertyDescriptor(f,n.name):{}),d=!1,y=r.length-1;y>=0;y--){var h={};for(var _ in n)h[_]="access"===_?{}:n[_];for(var _ in n.access)h.access[_]=n.access[_];h.addInitializer=function(e){if(d)throw TypeError("Cannot add initializers after decoration has completed");c.push(a(e||null))};var v=(0,r[y])("accessor"===l?{get:p.get,set:p.set}:p[s],h);if("accessor"===l){if(void 0===v)continue;if(null===v||(void 0===v?"undefined":(0,i._)(v))!=="object")throw TypeError("Object expected");(u=a(v.get))&&(p.get=u),(u=a(v.set))&&(p.set=u),(u=a(v.init))&&o.unshift(u)}else(u=a(v))&&("field"===l?o.unshift(u):p[s]=u)}f&&Object.defineProperty(f,n.name,p),d=!0}function d(e,t,r){for(var n=arguments.length>2,o=0;o0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function P(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)c.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return c}function j(){for(var e=[],t=0;t1||a(e,t)})},t&&(n[e]=t(n[e])))}function a(e,t){try{var r;(r=o[e](t)).value instanceof E?Promise.resolve(r.value.v).then(u,l):s(i[0][2],r)}catch(e){s(i[0][3],e)}}function u(e){a("next",e)}function l(e){a("throw",e)}function s(e,t){e(t),i.shift(),i.length&&a(i[0][0],i[0][1])}}function D(e){var t,r;return t={},n("next"),n("throw",function(e){throw e}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,o){t[n]=e[n]?function(t){return(r=!r)?{value:E(e[n](t)),done:!1}:o?o(t):t}:o}}function I(e){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=g(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise(function(n,o){var i,c,a;i=n,c=o,a=(t=e[r](t)).done,Promise.resolve(t.value).then(function(e){i({value:e,done:a})},c)})}}}function T(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var k=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},C=function(e){return(C=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t})(e)};function M(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=C(e),n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=(0,c._)({width:480,height:270,fallbackToVideoPiP:!0,placeholder:"Playing in Document Picture-in-Picture"},e);return function(e){var r,n="documentPictureInPicture"in window&&"function"==typeof(null==(r=window.documentPictureInPicture)?void 0:r.requestWindow),o=e.proxy,c=e.icons,u=e.i18n,l=e.template.$container,s=e.constructor.utils,f=s.append,p=s.tooltip,d=s.addClass,y=s.removeClass,h={win:null,originalParent:null,originalNext:null,currentDoc:null,placeholder:null};function _(){return(0,i._)(function(){var r,o,i,c,u,s;return(0,a._)(this,function(a){switch(a.label){case 0:if(!n&&t.fallbackToVideoPiP)return e.pip=!0,console.warn("[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture"),[2];if(h.win)return[2];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,window.documentPictureInPicture.requestWindow({width:t.width,height:t.height})];case 2:h.win=r=a.sent(),h.currentDoc=r.document,h.placeholder=document.createElement("div"),h.placeholder.className="artplayer-pip-placeholder",h.placeholder.style.cssText="display:flex;justify-content:center;align-items:center;width:100%;height:100%;",h.placeholder.textContent=t.placeholder,h.originalParent=l.parentNode,h.originalNext=l.nextSibling,h.originalParent.insertBefore(h.placeholder,h.originalNext),(o=r.document.createElement("div")).id="__art_dpip_root",r.document.body.appendChild(o);var f=r.document,p=f.createElement("style");if(p.textContent="\n html, body { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; }\n #__art_dpip_root { position:absolute; inset:0; display:flex; }\n #__art_dpip_root > * { width:100% !important; height:100% !important; }\n ",f.head.appendChild(p),!f.querySelector('meta[name="viewport"]')){var y=f.createElement("meta");y.name="viewport",y.content="width=device-width,initial-scale=1",f.head.appendChild(y)}try{document.querySelectorAll('link[rel="stylesheet"]').forEach(function(e){var t=f.createElement("link");t.rel="stylesheet",t.href=e.href,e.media&&(t.media=e.media),e.crossOrigin&&(t.crossOrigin=e.crossOrigin),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),f.head.appendChild(t)})}catch(e){}try{document.querySelectorAll("style").forEach(function(e){var t=f.createElement("style");t.textContent=e.textContent,f.head.appendChild(t)})}catch(e){}return i=r.document.adoptNode(l),o.appendChild(i),h.currentDoc=r.document,c=function(){var t;return null==(t=e.resize)?void 0:t.call(e)},u=function(){return v()},r.addEventListener("resize",c),r.addEventListener("pagehide",u),r.addEventListener("unload",u),h.cleanup=function(){r.removeEventListener("resize",c),r.removeEventListener("pagehide",u),r.removeEventListener("unload",u)},d(l,"artplayer-document-pip"),e.emit("document-pip",!0),[3,4];case 3:return s=a.sent(),e.notice.show="Document Picture-in-Picture open failed",console.warn("[artplayer-plugin-document-pip] open failed:",s),[3,4];case 4:return[2]}})})()}function v(){if(h.win)try{var t;if(null==(t=h.cleanup)||t.call(h),h.placeholder){var r=h.placeholder.ownerDocument||document,n=r.adoptNode(l);h.originalParent.insertBefore(n,h.placeholder),h.placeholder.remove(),h.placeholder=null,h.currentDoc=r}h.win.close(),h.win=null,y(l,"artplayer-document-pip"),e.emit("document-pip",!1)}catch(t){e.notice.show="Document Picture-in-Picture close failed",console.warn("[artplayer-plugin-document-pip] close failed:",t)}}function m(){h.win?v():_()}return e.controls.add({name:"document-pip",position:"right",index:40,tooltip:e.i18n.get("PIP Mode"),mounted:function(t){f(t,c.pip),o(t,"click",m),e.on("document-pip",function(e){p(t,u.get(e?"Exit PIP Mode":"PIP Mode"))})}}),e.on("destroy",v),{name:"artplayerPluginDocumentPip",get isSupported(){return n},get isActive(){return!!h.win},open:_,close:v,toggle:m}}}"undefined"!=typeof window&&(window.artplayerPluginDocumentPip=u)},{"@swc/helpers/cjs/_async_to_generator.cjs":"cZn0e","@swc/helpers/cjs/_object_spread.cjs":"kyoEj","@swc/helpers/cjs/_ts_generator.cjs":"eltGh","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],cZn0e:[function(e,t,r,n){"use strict";function o(e,t,r,n,o,i,c){try{var a=e[i](c),u=a.value}catch(e){r(e);return}a.done?t(u):Promise.resolve(u).then(n,o)}r._=function(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var c=e.apply(t,r);function a(e){o(c,n,i,a,u,"next",e)}function u(e){o(c,n,i,a,u,"throw",e)}a(void 0)})}}},{}],kyoEj:[function(e,t,r,n){"use strict";var o=e("9f9b8a24218ee51e");r._=function(e){for(var t=1;tt.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var o=0,n=Object.getOwnPropertySymbols(e);ot.indexOf(n[o])&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]]);return r}function s(e,t,r,n){var o,c=arguments.length,a=c<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if(("undefined"==typeof Reflect?"undefined":(0,i._)(Reflect))==="object"&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var u=e.length-1;u>=0;u--)(o=e[u])&&(a=(c<3?o(a):c>3?o(t,r,a):o(t,r))||a);return c>3&&a&&Object.defineProperty(t,r,a),a}function f(e,t){return function(r,n){t(r,n,e)}}function p(e,t,r,n,o,c){function a(e){if(void 0!==e&&"function"!=typeof e)throw TypeError("Function expected");return e}for(var u,l=n.kind,s="getter"===l?"get":"setter"===l?"set":"value",f=!t&&e?n.static?e:e.prototype:null,p=t||(f?Object.getOwnPropertyDescriptor(f,n.name):{}),d=!1,y=r.length-1;y>=0;y--){var h={};for(var _ in n)h[_]="access"===_?{}:n[_];for(var _ in n.access)h.access[_]=n.access[_];h.addInitializer=function(e){if(d)throw TypeError("Cannot add initializers after decoration has completed");c.push(a(e||null))};var v=(0,r[y])("accessor"===l?{get:p.get,set:p.set}:p[s],h);if("accessor"===l){if(void 0===v)continue;if(null===v||(void 0===v?"undefined":(0,i._)(v))!=="object")throw TypeError("Object expected");(u=a(v.get))&&(p.get=u),(u=a(v.set))&&(p.set=u),(u=a(v.init))&&o.unshift(u)}else(u=a(v))&&("field"===l?o.unshift(u):p[s]=u)}f&&Object.defineProperty(f,n.name,p),d=!0}function d(e,t,r){for(var n=arguments.length>2,o=0;o0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function P(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)c.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return c}function j(){for(var e=[],t=0;t1||a(e,t)})},t&&(n[e]=t(n[e])))}function a(e,t){try{var r;(r=o[e](t)).value instanceof E?Promise.resolve(r.value.v).then(u,l):s(i[0][2],r)}catch(e){s(i[0][3],e)}}function u(e){a("next",e)}function l(e){a("throw",e)}function s(e,t){e(t),i.shift(),i.length&&a(i[0][0],i[0][1])}}function D(e){var t,r;return t={},n("next"),n("throw",function(e){throw e}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,o){t[n]=e[n]?function(t){return(r=!r)?{value:E(e[n](t)),done:!1}:o?o(t):t}:o}}function I(e){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=g(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise(function(n,o){var i,c,a;i=n,c=o,a=(t=e[r](t)).done,Promise.resolve(t.value).then(function(e){i({value:e,done:a})},c)})}}}function T(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var k=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},C=function(e){return(C=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t})(e)};function M(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=C(e),n=0;n { - const dpipOK = 'documentPictureInPicture' in window + const isSupported = 'documentPictureInPicture' in window && typeof window.documentPictureInPicture?.requestWindow === 'function' const { proxy, icons, i18n, template: { $container }, constructor: { utils: { append, tooltip, addClass, removeClass } } } = art @@ -63,7 +63,7 @@ export default function artplayerPluginDocumentPip(userOptions = {}) { } async function open() { - if (!dpipOK && options.fallbackToVideoPiP) { + if (!isSupported && options.fallbackToVideoPiP) { art.pip = true console.warn('[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture') return @@ -133,11 +133,6 @@ export default function artplayerPluginDocumentPip(userOptions = {}) { } function close() { - if (!dpipOK && options.fallbackToVideoPiP) { - art.pip = false - return - } - if (!state.win) return try { @@ -181,7 +176,8 @@ export default function artplayerPluginDocumentPip(userOptions = {}) { return { name: 'artplayerPluginDocumentPip', - state, + get isSupported() { return isSupported }, + get isActive() { return !!state.win }, open, close, toggle, diff --git a/packages/artplayer-plugin-document-pip/types/artplayer-plugin-document-pip.d.ts b/packages/artplayer-plugin-document-pip/types/artplayer-plugin-document-pip.d.ts index 77903af5f..56f36dfc4 100644 --- a/packages/artplayer-plugin-document-pip/types/artplayer-plugin-document-pip.d.ts +++ b/packages/artplayer-plugin-document-pip/types/artplayer-plugin-document-pip.d.ts @@ -9,16 +9,11 @@ interface Option { interface Result { name: 'artplayerPluginDocumentPip' + isSupported: boolean + isActive: boolean open: () => void close: () => void toggle: () => void - state: { - win: Window | null - originalParent: Element | null - originalNext: Element | null - currentDoc: Document | null - placeholder: Element | null - } } declare const artplayerPluginDocumentPip: (option: Option) => (art: Artplayer) => Result