@shopify/shop-minis-react 0.0.21 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/___vite-browser-external.js +7 -0
- package/dist/_virtual/___vite-browser-external.js.map +1 -0
- package/dist/_virtual/__vite-browser-external.js +5 -0
- package/dist/_virtual/__vite-browser-external.js.map +1 -0
- package/dist/_virtual/_commonjsHelpers.js +24 -4
- package/dist/_virtual/_commonjsHelpers.js.map +1 -1
- package/dist/_virtual/browser-index.js +8 -0
- package/dist/_virtual/browser-index.js.map +1 -0
- package/dist/_virtual/browser-index2.js +5 -0
- package/dist/_virtual/browser-index2.js.map +1 -0
- package/dist/_virtual/clock.js +6 -0
- package/dist/_virtual/clock.js.map +1 -0
- package/dist/_virtual/conventions.js +5 -0
- package/dist/_virtual/conventions.js.map +1 -0
- package/dist/_virtual/document.js +8 -0
- package/dist/_virtual/document.js.map +1 -0
- package/dist/_virtual/dom-parser.js +5 -0
- package/dist/_virtual/dom-parser.js.map +1 -0
- package/dist/_virtual/dom.js +5 -0
- package/dist/_virtual/dom.js.map +1 -0
- package/dist/_virtual/entities.js +5 -0
- package/dist/_virtual/entities.js.map +1 -0
- package/dist/_virtual/extends.js +5 -0
- package/dist/_virtual/extends.js.map +1 -0
- package/dist/_virtual/index10.js +5 -0
- package/dist/_virtual/index10.js.map +1 -0
- package/dist/_virtual/index11.js +5 -0
- package/dist/_virtual/index11.js.map +1 -0
- package/dist/_virtual/index2.js +5 -2
- package/dist/_virtual/index2.js.map +1 -1
- package/dist/_virtual/index3.js +5 -3
- package/dist/_virtual/index3.js.map +1 -1
- package/dist/_virtual/index5.js +6 -0
- package/dist/_virtual/index5.js.map +1 -0
- package/dist/_virtual/index6.js +6 -0
- package/dist/_virtual/index6.js.map +1 -0
- package/dist/_virtual/index7.js +5 -0
- package/dist/_virtual/index7.js.map +1 -0
- package/dist/_virtual/index8.js +5 -0
- package/dist/_virtual/index8.js.map +1 -0
- package/dist/_virtual/index9.js +5 -0
- package/dist/_virtual/index9.js.map +1 -0
- package/dist/_virtual/parse-sidx.js +8 -0
- package/dist/_virtual/parse-sidx.js.map +1 -0
- package/dist/_virtual/sax.js +5 -0
- package/dist/_virtual/sax.js.map +1 -0
- package/dist/_virtual/window.js +8 -0
- package/dist/_virtual/window.js.map +1 -0
- package/dist/components/atoms/video-player.js +121 -0
- package/dist/components/atoms/video-player.js.map +1 -0
- package/dist/components/commerce/merchant-card.js +236 -106
- package/dist/components/commerce/merchant-card.js.map +1 -1
- package/dist/index.js +199 -192
- package/dist/index.js.map +1 -1
- package/dist/mocks.js +114 -87
- package/dist/mocks.js.map +1 -1
- package/dist/shop-minis-react/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/extends.js +20 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/extends.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@radix-ui_react-use-is-hydrated@0.1.0_@types_react@19.1.6_react@19.1.0/node_modules/@radix-ui/react-use-is-hydrated/dist/index.js +1 -1
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/byte-helpers.js +79 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/byte-helpers.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/codecs.js +102 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/codecs.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/containers.js +149 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/containers.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/decode-b64-to-uint8-array.js +13 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/decode-b64-to-uint8-array.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/ebml-helpers.js +77 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/ebml-helpers.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/id3-helpers.js +15 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/id3-helpers.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/media-groups.js +13 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/media-groups.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/media-types.js +7 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/media-types.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/mp4-helpers.js +31 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/mp4-helpers.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/nal-helpers.js +39 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/nal-helpers.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/resolve-url.js +14 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/resolve-url.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/stream.js +33 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/stream.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_xhr@2.7.0/node_modules/@videojs/xhr/lib/http-handler.js +42 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_xhr@2.7.0/node_modules/@videojs/xhr/lib/http-handler.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_xhr@2.7.0/node_modules/@videojs/xhr/lib/index.js +169 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_xhr@2.7.0/node_modules/@videojs/xhr/lib/index.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_xhr@2.7.0/node_modules/@videojs/xhr/lib/interceptors.js +75 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_xhr@2.7.0/node_modules/@videojs/xhr/lib/interceptors.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_xhr@2.7.0/node_modules/@videojs/xhr/lib/retry.js +70 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@videojs_xhr@2.7.0/node_modules/@videojs/xhr/lib/retry.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@xmldom_xmldom@0.8.10/node_modules/@xmldom/xmldom/lib/conventions.js +124 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@xmldom_xmldom@0.8.10/node_modules/@xmldom/xmldom/lib/conventions.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@xmldom_xmldom@0.8.10/node_modules/@xmldom/xmldom/lib/dom-parser.js +151 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@xmldom_xmldom@0.8.10/node_modules/@xmldom/xmldom/lib/dom-parser.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@xmldom_xmldom@0.8.10/node_modules/@xmldom/xmldom/lib/dom.js +993 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@xmldom_xmldom@0.8.10/node_modules/@xmldom/xmldom/lib/dom.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@xmldom_xmldom@0.8.10/node_modules/@xmldom/xmldom/lib/entities.js +2146 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@xmldom_xmldom@0.8.10/node_modules/@xmldom/xmldom/lib/entities.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@xmldom_xmldom@0.8.10/node_modules/@xmldom/xmldom/lib/index.js +14 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@xmldom_xmldom@0.8.10/node_modules/@xmldom/xmldom/lib/index.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@xmldom_xmldom@0.8.10/node_modules/@xmldom/xmldom/lib/sax.js +346 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@xmldom_xmldom@0.8.10/node_modules/@xmldom/xmldom/lib/sax.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/conversions.js +308 -0
- package/dist/shop-minis-react/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/conversions.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/index.js +41 -0
- package/dist/shop-minis-react/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/index.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/route.js +53 -0
- package/dist/shop-minis-react/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/route.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/color-name@1.1.4/node_modules/color-name/index.js +157 -0
- package/dist/shop-minis-react/node_modules/.pnpm/color-name@1.1.4/node_modules/color-name/index.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/color-string@1.9.1/node_modules/color-string/index.js +103 -0
- package/dist/shop-minis-react/node_modules/.pnpm/color-string@1.9.1/node_modules/color-string/index.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/color@4.2.3/node_modules/color/index.js +269 -0
- package/dist/shop-minis-react/node_modules/.pnpm/color@4.2.3/node_modules/color/index.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/global@4.4.0/node_modules/global/document.js +13 -0
- package/dist/shop-minis-react/node_modules/.pnpm/global@4.4.0/node_modules/global/document.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/global@4.4.0/node_modules/global/window.js +12 -0
- package/dist/shop-minis-react/node_modules/.pnpm/global@4.4.0/node_modules/global/window.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/is-arrayish@0.3.2/node_modules/is-arrayish/index.js +10 -0
- package/dist/shop-minis-react/node_modules/.pnpm/is-arrayish@0.3.2/node_modules/is-arrayish/index.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/is-function@1.0.2/node_modules/is-function/index.js +18 -0
- package/dist/shop-minis-react/node_modules/.pnpm/is-function@1.0.2/node_modules/is-function/index.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/m3u8-parser@7.2.0/node_modules/m3u8-parser/dist/m3u8-parser.es.js +855 -0
- package/dist/shop-minis-react/node_modules/.pnpm/m3u8-parser@7.2.0/node_modules/m3u8-parser/dist/m3u8-parser.es.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/mpd-parser@1.3.1/node_modules/mpd-parser/dist/mpd-parser.es.js +1102 -0
- package/dist/shop-minis-react/node_modules/.pnpm/mpd-parser@1.3.1/node_modules/mpd-parser/dist/mpd-parser.es.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/mux.js@7.1.0/node_modules/mux.js/lib/tools/parse-sidx.js +32 -0
- package/dist/shop-minis-react/node_modules/.pnpm/mux.js@7.1.0/node_modules/mux.js/lib/tools/parse-sidx.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/mux.js@7.1.0/node_modules/mux.js/lib/utils/clock.js +34 -0
- package/dist/shop-minis-react/node_modules/.pnpm/mux.js@7.1.0/node_modules/mux.js/lib/utils/clock.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/mux.js@7.1.0/node_modules/mux.js/lib/utils/numbers.js +17 -0
- package/dist/shop-minis-react/node_modules/.pnpm/mux.js@7.1.0/node_modules/mux.js/lib/utils/numbers.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/querystringify@2.2.0/node_modules/querystringify/index.js +1 -1
- package/dist/shop-minis-react/node_modules/.pnpm/simple-swizzle@0.2.2/node_modules/simple-swizzle/index.js +23 -0
- package/dist/shop-minis-react/node_modules/.pnpm/simple-swizzle@0.2.2/node_modules/simple-swizzle/index.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/use-sync-external-store@1.5.0_react@19.1.0/node_modules/use-sync-external-store/shim/index.js +1 -1
- package/dist/shop-minis-react/node_modules/.pnpm/video.js@8.23.3/node_modules/video.js/dist/video.es.js +27824 -0
- package/dist/shop-minis-react/node_modules/.pnpm/video.js@8.23.3/node_modules/video.js/dist/video.es.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/videojs-vtt.js@0.15.5/node_modules/videojs-vtt.js/lib/browser-index.js +26 -0
- package/dist/shop-minis-react/node_modules/.pnpm/videojs-vtt.js@0.15.5/node_modules/videojs-vtt.js/lib/browser-index.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/videojs-vtt.js@0.15.5/node_modules/videojs-vtt.js/lib/vtt.js +802 -0
- package/dist/shop-minis-react/node_modules/.pnpm/videojs-vtt.js@0.15.5/node_modules/videojs-vtt.js/lib/vtt.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/videojs-vtt.js@0.15.5/node_modules/videojs-vtt.js/lib/vttcue.js +188 -0
- package/dist/shop-minis-react/node_modules/.pnpm/videojs-vtt.js@0.15.5/node_modules/videojs-vtt.js/lib/vttcue.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/videojs-vtt.js@0.15.5/node_modules/videojs-vtt.js/lib/vttregion.js +104 -0
- package/dist/shop-minis-react/node_modules/.pnpm/videojs-vtt.js@0.15.5/node_modules/videojs-vtt.js/lib/vttregion.js.map +1 -0
- package/dist/shop-minis-react.css +1 -1
- package/dist/utils/colors.js +6 -0
- package/dist/utils/colors.js.map +1 -0
- package/dist/utils/merchant-card.js +44 -0
- package/dist/utils/merchant-card.js.map +1 -0
- package/package.json +5 -1
- package/src/components/atoms/video-player.tsx +213 -0
- package/src/components/commerce/merchant-card.tsx +219 -49
- package/src/components/index.ts +1 -0
- package/src/mocks.ts +148 -16
- package/src/stories/MerchantCard.stories.tsx +63 -9
- package/src/utils/colors.ts +5 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/merchant-card.ts +99 -0
- package/src/hooks/navigation/useCloseMini.doc.ts +0 -32
- package/src/hooks/navigation/useCloseMini.example.tsx +0 -7
- package/src/hooks/navigation/useDeeplink.doc.ts +0 -32
- package/src/hooks/navigation/useDeeplink.example.tsx +0 -7
- package/src/hooks/navigation/useShopNavigation.doc.ts +0 -32
- package/src/hooks/navigation/useShopNavigation.example.tsx +0 -32
- package/src/hooks/product/useCuratedProducts.doc.ts +0 -32
- package/src/hooks/product/useCuratedProducts.example.tsx +0 -10
- package/src/hooks/product/useProductList.doc.ts +0 -32
- package/src/hooks/product/useProductList.example.tsx +0 -9
- package/src/hooks/product/useProductListActions.doc.ts +0 -32
- package/src/hooks/product/useProductListActions.example.tsx +0 -60
- package/src/hooks/product/useProductLists.doc.ts +0 -32
- package/src/hooks/product/useProductLists.example.tsx +0 -9
- package/src/hooks/product/useProductSearch.doc.ts +0 -32
- package/src/hooks/product/useProductSearch.example.tsx +0 -13
- package/src/hooks/product/useRecommendedProducts.doc.ts +0 -32
- package/src/hooks/product/useRecommendedProducts.example.tsx +0 -7
- package/src/hooks/shop/useRecommendedShops.doc.ts +0 -32
- package/src/hooks/shop/useRecommendedShops.example.tsx +0 -7
- package/src/hooks/shop/useShop.doc.ts +0 -31
- package/src/hooks/shop/useShop.example.tsx +0 -7
- package/src/hooks/shop/useShopCartActions.doc.ts +0 -32
- package/src/hooks/shop/useShopCartActions.example.tsx +0 -28
- package/src/hooks/storage/useAsyncStorage.doc.ts +0 -32
- package/src/hooks/storage/useAsyncStorage.example.tsx +0 -30
- package/src/hooks/storage/useImageUpload.doc.ts +0 -32
- package/src/hooks/storage/useImageUpload.example.tsx +0 -20
- package/src/hooks/storage/useSecureStorage.doc.ts +0 -32
- package/src/hooks/storage/useSecureStorage.example.tsx +0 -23
- package/src/hooks/user/useBuyerAttributes.doc.ts +0 -32
- package/src/hooks/user/useBuyerAttributes.example.tsx +0 -14
- package/src/hooks/user/useCurrentUser.doc.ts +0 -31
- package/src/hooks/user/useCurrentUser.example.tsx +0 -7
- package/src/hooks/user/useFollowedShopsActions.doc.ts +0 -32
- package/src/hooks/user/useFollowedShopsActions.example.tsx +0 -16
- package/src/hooks/user/useOrders.doc.ts +0 -32
- package/src/hooks/user/useOrders.example.tsx +0 -7
- package/src/hooks/user/useRecentProducts.doc.ts +0 -32
- package/src/hooks/user/useRecentProducts.example.tsx +0 -13
- package/src/hooks/user/useSavedProducts.doc.ts +0 -32
- package/src/hooks/user/useSavedProducts.example.tsx +0 -13
- package/src/hooks/user/useSavedProductsActions.doc.ts +0 -32
- package/src/hooks/user/useSavedProductsActions.example.tsx +0 -32
- package/src/hooks/util/useErrorScreen.doc.ts +0 -32
- package/src/hooks/util/useErrorScreen.example.tsx +0 -15
- package/src/hooks/util/useErrorToast.doc.ts +0 -32
- package/src/hooks/util/useErrorToast.example.tsx +0 -15
- package/src/hooks/util/useImagePicker.example.tsx +0 -77
|
@@ -0,0 +1,1102 @@
|
|
|
1
|
+
import L from "../../../../@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/resolve-url.js";
|
|
2
|
+
import T from "../../../../../../../_virtual/window.js";
|
|
3
|
+
import { forEachMediaGroup as Z } from "../../../../@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/media-groups.js";
|
|
4
|
+
import J from "../../../../@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/decode-b64-to-uint8-array.js";
|
|
5
|
+
import { l as Q } from "../../../../../../../_virtual/index5.js";
|
|
6
|
+
/*! @name mpd-parser @version 1.3.1 @license Apache-2.0 */
|
|
7
|
+
const w = (e) => !!e && typeof e == "object", E = (...e) => e.reduce((n, t) => (typeof t != "object" || Object.keys(t).forEach((r) => {
|
|
8
|
+
Array.isArray(n[r]) && Array.isArray(t[r]) ? n[r] = n[r].concat(t[r]) : w(n[r]) && w(t[r]) ? n[r] = E(n[r], t[r]) : n[r] = t[r];
|
|
9
|
+
}), n), {}), q = (e) => Object.keys(e).map((n) => e[n]), ee = (e, n) => {
|
|
10
|
+
const t = [];
|
|
11
|
+
for (let r = e; r < n; r++)
|
|
12
|
+
t.push(r);
|
|
13
|
+
return t;
|
|
14
|
+
}, P = (e) => e.reduce((n, t) => n.concat(t), []), W = (e) => {
|
|
15
|
+
if (!e.length)
|
|
16
|
+
return [];
|
|
17
|
+
const n = [];
|
|
18
|
+
for (let t = 0; t < e.length; t++)
|
|
19
|
+
n.push(e[t]);
|
|
20
|
+
return n;
|
|
21
|
+
}, te = (e, n) => e.reduce((t, r, i) => (r[n] && t.push(i), t), []), ne = (e, n) => q(e.reduce((t, r) => (r.forEach((i) => {
|
|
22
|
+
t[n(i)] = i;
|
|
23
|
+
}), t), {}));
|
|
24
|
+
var R = {
|
|
25
|
+
INVALID_NUMBER_OF_PERIOD: "INVALID_NUMBER_OF_PERIOD",
|
|
26
|
+
DASH_EMPTY_MANIFEST: "DASH_EMPTY_MANIFEST",
|
|
27
|
+
DASH_INVALID_XML: "DASH_INVALID_XML",
|
|
28
|
+
NO_BASE_URL: "NO_BASE_URL",
|
|
29
|
+
SEGMENT_TIME_UNSPECIFIED: "SEGMENT_TIME_UNSPECIFIED",
|
|
30
|
+
UNSUPPORTED_UTC_TIMING_SCHEME: "UNSUPPORTED_UTC_TIMING_SCHEME"
|
|
31
|
+
};
|
|
32
|
+
const O = ({
|
|
33
|
+
baseUrl: e = "",
|
|
34
|
+
source: n = "",
|
|
35
|
+
range: t = "",
|
|
36
|
+
indexRange: r = ""
|
|
37
|
+
}) => {
|
|
38
|
+
const i = {
|
|
39
|
+
uri: n,
|
|
40
|
+
resolvedUri: L(e || "", n)
|
|
41
|
+
};
|
|
42
|
+
if (t || r) {
|
|
43
|
+
const s = (t || r).split("-");
|
|
44
|
+
let c = T.BigInt ? T.BigInt(s[0]) : parseInt(s[0], 10), a = T.BigInt ? T.BigInt(s[1]) : parseInt(s[1], 10);
|
|
45
|
+
c < Number.MAX_SAFE_INTEGER && typeof c == "bigint" && (c = Number(c)), a < Number.MAX_SAFE_INTEGER && typeof a == "bigint" && (a = Number(a));
|
|
46
|
+
let u;
|
|
47
|
+
typeof a == "bigint" || typeof c == "bigint" ? u = T.BigInt(a) - T.BigInt(c) + T.BigInt(1) : u = a - c + 1, typeof u == "bigint" && u < Number.MAX_SAFE_INTEGER && (u = Number(u)), i.byterange = {
|
|
48
|
+
length: u,
|
|
49
|
+
offset: c
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return i;
|
|
53
|
+
}, re = (e) => {
|
|
54
|
+
let n;
|
|
55
|
+
return typeof e.offset == "bigint" || typeof e.length == "bigint" ? n = T.BigInt(e.offset) + T.BigInt(e.length) - T.BigInt(1) : n = e.offset + e.length - 1, `${e.offset}-${n}`;
|
|
56
|
+
}, F = (e) => (e && typeof e != "number" && (e = parseInt(e, 10)), isNaN(e) ? null : e), ie = {
|
|
57
|
+
/**
|
|
58
|
+
* Returns the entire range of available segments for a static MPD
|
|
59
|
+
*
|
|
60
|
+
* @param {Object} attributes
|
|
61
|
+
* Inheritied MPD attributes
|
|
62
|
+
* @return {{ start: number, end: number }}
|
|
63
|
+
* The start and end numbers for available segments
|
|
64
|
+
*/
|
|
65
|
+
static(e) {
|
|
66
|
+
const {
|
|
67
|
+
duration: n,
|
|
68
|
+
timescale: t = 1,
|
|
69
|
+
sourceDuration: r,
|
|
70
|
+
periodDuration: i
|
|
71
|
+
} = e, o = F(e.endNumber), s = n / t;
|
|
72
|
+
return typeof o == "number" ? {
|
|
73
|
+
start: 0,
|
|
74
|
+
end: o
|
|
75
|
+
} : typeof i == "number" ? {
|
|
76
|
+
start: 0,
|
|
77
|
+
end: i / s
|
|
78
|
+
} : {
|
|
79
|
+
start: 0,
|
|
80
|
+
end: r / s
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
/**
|
|
84
|
+
* Returns the current live window range of available segments for a dynamic MPD
|
|
85
|
+
*
|
|
86
|
+
* @param {Object} attributes
|
|
87
|
+
* Inheritied MPD attributes
|
|
88
|
+
* @return {{ start: number, end: number }}
|
|
89
|
+
* The start and end numbers for available segments
|
|
90
|
+
*/
|
|
91
|
+
dynamic(e) {
|
|
92
|
+
const {
|
|
93
|
+
NOW: n,
|
|
94
|
+
clientOffset: t,
|
|
95
|
+
availabilityStartTime: r,
|
|
96
|
+
timescale: i = 1,
|
|
97
|
+
duration: o,
|
|
98
|
+
periodStart: s = 0,
|
|
99
|
+
minimumUpdatePeriod: c = 0,
|
|
100
|
+
timeShiftBufferDepth: a = 1 / 0
|
|
101
|
+
} = e, u = F(e.endNumber), m = (n + t) / 1e3, d = r + s, h = m + c - d, l = Math.ceil(h * i / o), g = Math.floor((m - d - a) * i / o), I = Math.floor((m - d) * i / o);
|
|
102
|
+
return {
|
|
103
|
+
start: Math.max(0, g),
|
|
104
|
+
end: typeof u == "number" ? u : Math.min(l, I)
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}, oe = (e) => (n) => {
|
|
108
|
+
const {
|
|
109
|
+
duration: t,
|
|
110
|
+
timescale: r = 1,
|
|
111
|
+
periodStart: i,
|
|
112
|
+
startNumber: o = 1
|
|
113
|
+
} = e;
|
|
114
|
+
return {
|
|
115
|
+
number: o + n,
|
|
116
|
+
duration: t / r,
|
|
117
|
+
timeline: i,
|
|
118
|
+
time: n * t
|
|
119
|
+
};
|
|
120
|
+
}, C = (e) => {
|
|
121
|
+
const {
|
|
122
|
+
type: n,
|
|
123
|
+
duration: t,
|
|
124
|
+
timescale: r = 1,
|
|
125
|
+
periodDuration: i,
|
|
126
|
+
sourceDuration: o
|
|
127
|
+
} = e, {
|
|
128
|
+
start: s,
|
|
129
|
+
end: c
|
|
130
|
+
} = ie[n](e), a = ee(s, c).map(oe(e));
|
|
131
|
+
if (n === "static") {
|
|
132
|
+
const u = a.length - 1, m = typeof i == "number" ? i : o;
|
|
133
|
+
a[u].duration = m - t / r * u;
|
|
134
|
+
}
|
|
135
|
+
return a;
|
|
136
|
+
}, Y = (e) => {
|
|
137
|
+
const {
|
|
138
|
+
baseUrl: n,
|
|
139
|
+
initialization: t = {},
|
|
140
|
+
sourceDuration: r,
|
|
141
|
+
indexRange: i = "",
|
|
142
|
+
periodStart: o,
|
|
143
|
+
presentationTime: s,
|
|
144
|
+
number: c = 0,
|
|
145
|
+
duration: a
|
|
146
|
+
} = e;
|
|
147
|
+
if (!n)
|
|
148
|
+
throw new Error(R.NO_BASE_URL);
|
|
149
|
+
const u = O({
|
|
150
|
+
baseUrl: n,
|
|
151
|
+
source: t.sourceURL,
|
|
152
|
+
range: t.range
|
|
153
|
+
}), m = O({
|
|
154
|
+
baseUrl: n,
|
|
155
|
+
source: n,
|
|
156
|
+
indexRange: i
|
|
157
|
+
});
|
|
158
|
+
if (m.map = u, a) {
|
|
159
|
+
const d = C(e);
|
|
160
|
+
d.length && (m.duration = d[0].duration, m.timeline = d[0].timeline);
|
|
161
|
+
} else r && (m.duration = r, m.timeline = o);
|
|
162
|
+
return m.presentationTime = s || o, m.number = c, [m];
|
|
163
|
+
}, se = (e, n, t) => {
|
|
164
|
+
const r = e.sidx.map ? e.sidx.map : null, i = e.sidx.duration, o = e.timeline || 0, s = e.sidx.byterange, c = s.offset + s.length, a = n.timescale, u = n.references.filter((I) => I.referenceType !== 1), m = [], d = e.endList ? "static" : "dynamic", p = e.sidx.timeline;
|
|
165
|
+
let h = p, l = e.mediaSequence || 0, g;
|
|
166
|
+
typeof n.firstOffset == "bigint" ? g = T.BigInt(c) + n.firstOffset : g = c + n.firstOffset;
|
|
167
|
+
for (let I = 0; I < u.length; I++) {
|
|
168
|
+
const U = n.references[I], D = U.referencedSize, N = U.subsegmentDuration;
|
|
169
|
+
let b;
|
|
170
|
+
typeof g == "bigint" ? b = g + T.BigInt(D) - T.BigInt(1) : b = g + D - 1;
|
|
171
|
+
const k = `${g}-${b}`, x = Y({
|
|
172
|
+
baseUrl: t,
|
|
173
|
+
timescale: a,
|
|
174
|
+
timeline: o,
|
|
175
|
+
periodStart: p,
|
|
176
|
+
presentationTime: h,
|
|
177
|
+
number: l,
|
|
178
|
+
duration: N,
|
|
179
|
+
sourceDuration: i,
|
|
180
|
+
indexRange: k,
|
|
181
|
+
type: d
|
|
182
|
+
})[0];
|
|
183
|
+
r && (x.map = r), m.push(x), typeof g == "bigint" ? g += T.BigInt(D) : g += D, h += N / a, l++;
|
|
184
|
+
}
|
|
185
|
+
return e.segments = m, e;
|
|
186
|
+
}, ae = ["AUDIO", "SUBTITLES"], ce = 1 / 60, X = (e) => ne(e, ({
|
|
187
|
+
timeline: n
|
|
188
|
+
}) => n).sort((n, t) => n.timeline > t.timeline ? 1 : -1), ue = (e, n) => {
|
|
189
|
+
for (let t = 0; t < e.length; t++)
|
|
190
|
+
if (e[t].attributes.NAME === n)
|
|
191
|
+
return e[t];
|
|
192
|
+
return null;
|
|
193
|
+
}, G = (e) => {
|
|
194
|
+
let n = [];
|
|
195
|
+
return Z(e, ae, (t, r, i, o) => {
|
|
196
|
+
n = n.concat(t.playlists || []);
|
|
197
|
+
}), n;
|
|
198
|
+
}, z = ({
|
|
199
|
+
playlist: e,
|
|
200
|
+
mediaSequence: n
|
|
201
|
+
}) => {
|
|
202
|
+
e.mediaSequence = n, e.segments.forEach((t, r) => {
|
|
203
|
+
t.number = e.mediaSequence + r;
|
|
204
|
+
});
|
|
205
|
+
}, me = ({
|
|
206
|
+
oldPlaylists: e,
|
|
207
|
+
newPlaylists: n,
|
|
208
|
+
timelineStarts: t
|
|
209
|
+
}) => {
|
|
210
|
+
n.forEach((r) => {
|
|
211
|
+
r.discontinuitySequence = t.findIndex(function({
|
|
212
|
+
timeline: a
|
|
213
|
+
}) {
|
|
214
|
+
return a === r.timeline;
|
|
215
|
+
});
|
|
216
|
+
const i = ue(e, r.attributes.NAME);
|
|
217
|
+
if (!i || r.sidx)
|
|
218
|
+
return;
|
|
219
|
+
const o = r.segments[0], s = i.segments.findIndex(function(a) {
|
|
220
|
+
return Math.abs(a.presentationTime - o.presentationTime) < ce;
|
|
221
|
+
});
|
|
222
|
+
if (s === -1) {
|
|
223
|
+
z({
|
|
224
|
+
playlist: r,
|
|
225
|
+
mediaSequence: i.mediaSequence + i.segments.length
|
|
226
|
+
}), r.segments[0].discontinuity = !0, r.discontinuityStarts.unshift(0), (!i.segments.length && r.timeline > i.timeline || i.segments.length && r.timeline > i.segments[i.segments.length - 1].timeline) && r.discontinuitySequence--;
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
i.segments[s].discontinuity && !o.discontinuity && (o.discontinuity = !0, r.discontinuityStarts.unshift(0), r.discontinuitySequence--), z({
|
|
230
|
+
playlist: r,
|
|
231
|
+
mediaSequence: i.segments[s].number
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
}, de = ({
|
|
235
|
+
oldManifest: e,
|
|
236
|
+
newManifest: n
|
|
237
|
+
}) => {
|
|
238
|
+
const t = e.playlists.concat(G(e)), r = n.playlists.concat(G(n));
|
|
239
|
+
return n.timelineStarts = X([e.timelineStarts, n.timelineStarts]), me({
|
|
240
|
+
oldPlaylists: t,
|
|
241
|
+
newPlaylists: r,
|
|
242
|
+
timelineStarts: n.timelineStarts
|
|
243
|
+
}), n;
|
|
244
|
+
}, le = (e) => e && e.uri + "-" + re(e.byterange), M = (e) => {
|
|
245
|
+
const n = e.reduce(function(r, i) {
|
|
246
|
+
return r[i.attributes.baseUrl] || (r[i.attributes.baseUrl] = []), r[i.attributes.baseUrl].push(i), r;
|
|
247
|
+
}, {});
|
|
248
|
+
let t = [];
|
|
249
|
+
return Object.values(n).forEach((r) => {
|
|
250
|
+
const i = q(r.reduce((o, s) => {
|
|
251
|
+
const c = s.attributes.id + (s.attributes.lang || "");
|
|
252
|
+
return o[c] ? (s.segments && (s.segments[0] && (s.segments[0].discontinuity = !0), o[c].segments.push(...s.segments)), s.attributes.contentProtection && (o[c].attributes.contentProtection = s.attributes.contentProtection)) : (o[c] = s, o[c].attributes.timelineStarts = []), o[c].attributes.timelineStarts.push({
|
|
253
|
+
// Although they represent the same number, it's important to have both to make it
|
|
254
|
+
// compatible with HLS potentially having a similar attribute.
|
|
255
|
+
start: s.attributes.periodStart,
|
|
256
|
+
timeline: s.attributes.periodStart
|
|
257
|
+
}), o;
|
|
258
|
+
}, {}));
|
|
259
|
+
t = t.concat(i);
|
|
260
|
+
}), t.map((r) => (r.discontinuityStarts = te(r.segments || [], "discontinuity"), r));
|
|
261
|
+
}, B = (e, n) => {
|
|
262
|
+
const t = le(e.sidx), r = t && n[t] && n[t].sidx;
|
|
263
|
+
return r && se(e, r, e.sidx.resolvedUri), e;
|
|
264
|
+
}, fe = (e, n = {}) => {
|
|
265
|
+
if (!Object.keys(n).length)
|
|
266
|
+
return e;
|
|
267
|
+
for (const t in e)
|
|
268
|
+
e[t] = B(e[t], n);
|
|
269
|
+
return e;
|
|
270
|
+
}, ge = ({
|
|
271
|
+
attributes: e,
|
|
272
|
+
segments: n,
|
|
273
|
+
sidx: t,
|
|
274
|
+
mediaSequence: r,
|
|
275
|
+
discontinuitySequence: i,
|
|
276
|
+
discontinuityStarts: o
|
|
277
|
+
}, s) => {
|
|
278
|
+
const c = {
|
|
279
|
+
attributes: {
|
|
280
|
+
NAME: e.id,
|
|
281
|
+
BANDWIDTH: e.bandwidth,
|
|
282
|
+
CODECS: e.codecs,
|
|
283
|
+
"PROGRAM-ID": 1
|
|
284
|
+
},
|
|
285
|
+
uri: "",
|
|
286
|
+
endList: e.type === "static",
|
|
287
|
+
timeline: e.periodStart,
|
|
288
|
+
resolvedUri: e.baseUrl || "",
|
|
289
|
+
targetDuration: e.duration,
|
|
290
|
+
discontinuitySequence: i,
|
|
291
|
+
discontinuityStarts: o,
|
|
292
|
+
timelineStarts: e.timelineStarts,
|
|
293
|
+
mediaSequence: r,
|
|
294
|
+
segments: n
|
|
295
|
+
};
|
|
296
|
+
return e.contentProtection && (c.contentProtection = e.contentProtection), e.serviceLocation && (c.attributes.serviceLocation = e.serviceLocation), t && (c.sidx = t), s && (c.attributes.AUDIO = "audio", c.attributes.SUBTITLES = "subs"), c;
|
|
297
|
+
}, pe = ({
|
|
298
|
+
attributes: e,
|
|
299
|
+
segments: n,
|
|
300
|
+
mediaSequence: t,
|
|
301
|
+
discontinuityStarts: r,
|
|
302
|
+
discontinuitySequence: i
|
|
303
|
+
}) => {
|
|
304
|
+
typeof n > "u" && (n = [{
|
|
305
|
+
uri: e.baseUrl,
|
|
306
|
+
timeline: e.periodStart,
|
|
307
|
+
resolvedUri: e.baseUrl || "",
|
|
308
|
+
duration: e.sourceDuration,
|
|
309
|
+
number: 0
|
|
310
|
+
}], e.duration = e.sourceDuration);
|
|
311
|
+
const o = {
|
|
312
|
+
NAME: e.id,
|
|
313
|
+
BANDWIDTH: e.bandwidth,
|
|
314
|
+
"PROGRAM-ID": 1
|
|
315
|
+
};
|
|
316
|
+
e.codecs && (o.CODECS = e.codecs);
|
|
317
|
+
const s = {
|
|
318
|
+
attributes: o,
|
|
319
|
+
uri: "",
|
|
320
|
+
endList: e.type === "static",
|
|
321
|
+
timeline: e.periodStart,
|
|
322
|
+
resolvedUri: e.baseUrl || "",
|
|
323
|
+
targetDuration: e.duration,
|
|
324
|
+
timelineStarts: e.timelineStarts,
|
|
325
|
+
discontinuityStarts: r,
|
|
326
|
+
discontinuitySequence: i,
|
|
327
|
+
mediaSequence: t,
|
|
328
|
+
segments: n
|
|
329
|
+
};
|
|
330
|
+
return e.serviceLocation && (s.attributes.serviceLocation = e.serviceLocation), s;
|
|
331
|
+
}, Se = (e, n = {}, t = !1) => {
|
|
332
|
+
let r;
|
|
333
|
+
const i = e.reduce((o, s) => {
|
|
334
|
+
const c = s.attributes.role && s.attributes.role.value || "", a = s.attributes.lang || "";
|
|
335
|
+
let u = s.attributes.label || "main";
|
|
336
|
+
if (a && !s.attributes.label) {
|
|
337
|
+
const d = c ? ` (${c})` : "";
|
|
338
|
+
u = `${s.attributes.lang}${d}`;
|
|
339
|
+
}
|
|
340
|
+
o[u] || (o[u] = {
|
|
341
|
+
language: a,
|
|
342
|
+
autoselect: !0,
|
|
343
|
+
default: c === "main",
|
|
344
|
+
playlists: [],
|
|
345
|
+
uri: ""
|
|
346
|
+
});
|
|
347
|
+
const m = B(ge(s, t), n);
|
|
348
|
+
return o[u].playlists.push(m), typeof r > "u" && c === "main" && (r = s, r.default = !0), o;
|
|
349
|
+
}, {});
|
|
350
|
+
if (!r) {
|
|
351
|
+
const o = Object.keys(i)[0];
|
|
352
|
+
i[o].default = !0;
|
|
353
|
+
}
|
|
354
|
+
return i;
|
|
355
|
+
}, he = (e, n = {}) => e.reduce((t, r) => {
|
|
356
|
+
const i = r.attributes.label || r.attributes.lang || "text", o = r.attributes.lang || "und";
|
|
357
|
+
return t[i] || (t[i] = {
|
|
358
|
+
language: o,
|
|
359
|
+
default: !1,
|
|
360
|
+
autoselect: !1,
|
|
361
|
+
playlists: [],
|
|
362
|
+
uri: ""
|
|
363
|
+
}), t[i].playlists.push(B(pe(r), n)), t;
|
|
364
|
+
}, {}), Ie = (e) => e.reduce((n, t) => (t && t.forEach((r) => {
|
|
365
|
+
const {
|
|
366
|
+
channel: i,
|
|
367
|
+
language: o
|
|
368
|
+
} = r;
|
|
369
|
+
n[o] = {
|
|
370
|
+
autoselect: !1,
|
|
371
|
+
default: !1,
|
|
372
|
+
instreamId: i,
|
|
373
|
+
language: o
|
|
374
|
+
}, r.hasOwnProperty("aspectRatio") && (n[o].aspectRatio = r.aspectRatio), r.hasOwnProperty("easyReader") && (n[o].easyReader = r.easyReader), r.hasOwnProperty("3D") && (n[o]["3D"] = r["3D"]);
|
|
375
|
+
}), n), {}), Ee = ({
|
|
376
|
+
attributes: e,
|
|
377
|
+
segments: n,
|
|
378
|
+
sidx: t,
|
|
379
|
+
discontinuityStarts: r
|
|
380
|
+
}) => {
|
|
381
|
+
const i = {
|
|
382
|
+
attributes: {
|
|
383
|
+
NAME: e.id,
|
|
384
|
+
AUDIO: "audio",
|
|
385
|
+
SUBTITLES: "subs",
|
|
386
|
+
RESOLUTION: {
|
|
387
|
+
width: e.width,
|
|
388
|
+
height: e.height
|
|
389
|
+
},
|
|
390
|
+
CODECS: e.codecs,
|
|
391
|
+
BANDWIDTH: e.bandwidth,
|
|
392
|
+
"PROGRAM-ID": 1
|
|
393
|
+
},
|
|
394
|
+
uri: "",
|
|
395
|
+
endList: e.type === "static",
|
|
396
|
+
timeline: e.periodStart,
|
|
397
|
+
resolvedUri: e.baseUrl || "",
|
|
398
|
+
targetDuration: e.duration,
|
|
399
|
+
discontinuityStarts: r,
|
|
400
|
+
timelineStarts: e.timelineStarts,
|
|
401
|
+
segments: n
|
|
402
|
+
};
|
|
403
|
+
return e.frameRate && (i.attributes["FRAME-RATE"] = e.frameRate), e.contentProtection && (i.contentProtection = e.contentProtection), e.serviceLocation && (i.attributes.serviceLocation = e.serviceLocation), t && (i.sidx = t), i;
|
|
404
|
+
}, Te = ({
|
|
405
|
+
attributes: e
|
|
406
|
+
}) => e.mimeType === "video/mp4" || e.mimeType === "video/webm" || e.contentType === "video", De = ({
|
|
407
|
+
attributes: e
|
|
408
|
+
}) => e.mimeType === "audio/mp4" || e.mimeType === "audio/webm" || e.contentType === "audio", Ue = ({
|
|
409
|
+
attributes: e
|
|
410
|
+
}) => e.mimeType === "text/vtt" || e.contentType === "text", Ne = (e, n) => {
|
|
411
|
+
e.forEach((t) => {
|
|
412
|
+
t.mediaSequence = 0, t.discontinuitySequence = n.findIndex(function({
|
|
413
|
+
timeline: r
|
|
414
|
+
}) {
|
|
415
|
+
return r === t.timeline;
|
|
416
|
+
}), t.segments && t.segments.forEach((r, i) => {
|
|
417
|
+
r.number = i;
|
|
418
|
+
});
|
|
419
|
+
});
|
|
420
|
+
}, $ = (e) => e ? Object.keys(e).reduce((n, t) => {
|
|
421
|
+
const r = e[t];
|
|
422
|
+
return n.concat(r.playlists);
|
|
423
|
+
}, []) : [], be = ({
|
|
424
|
+
dashPlaylists: e,
|
|
425
|
+
locations: n,
|
|
426
|
+
contentSteering: t,
|
|
427
|
+
sidxMapping: r = {},
|
|
428
|
+
previousManifest: i,
|
|
429
|
+
eventStream: o
|
|
430
|
+
}) => {
|
|
431
|
+
if (!e.length)
|
|
432
|
+
return {};
|
|
433
|
+
const {
|
|
434
|
+
sourceDuration: s,
|
|
435
|
+
type: c,
|
|
436
|
+
suggestedPresentationDelay: a,
|
|
437
|
+
minimumUpdatePeriod: u
|
|
438
|
+
} = e[0].attributes, m = M(e.filter(Te)).map(Ee), d = M(e.filter(De)), p = M(e.filter(Ue)), h = e.map((b) => b.attributes.captionServices).filter(Boolean), l = {
|
|
439
|
+
allowCache: !0,
|
|
440
|
+
discontinuityStarts: [],
|
|
441
|
+
segments: [],
|
|
442
|
+
endList: !0,
|
|
443
|
+
mediaGroups: {
|
|
444
|
+
AUDIO: {},
|
|
445
|
+
VIDEO: {},
|
|
446
|
+
"CLOSED-CAPTIONS": {},
|
|
447
|
+
SUBTITLES: {}
|
|
448
|
+
},
|
|
449
|
+
uri: "",
|
|
450
|
+
duration: s,
|
|
451
|
+
playlists: fe(m, r)
|
|
452
|
+
};
|
|
453
|
+
u >= 0 && (l.minimumUpdatePeriod = u * 1e3), n && (l.locations = n), t && (l.contentSteering = t), c === "dynamic" && (l.suggestedPresentationDelay = a), o && o.length > 0 && (l.eventStream = o);
|
|
454
|
+
const g = l.playlists.length === 0, I = d.length ? Se(d, r, g) : null, U = p.length ? he(p, r) : null, D = m.concat($(I), $(U)), N = D.map(({
|
|
455
|
+
timelineStarts: b
|
|
456
|
+
}) => b);
|
|
457
|
+
return l.timelineStarts = X(N), Ne(D, l.timelineStarts), I && (l.mediaGroups.AUDIO.audio = I), U && (l.mediaGroups.SUBTITLES.subs = U), h.length && (l.mediaGroups["CLOSED-CAPTIONS"].cc = Ie(h)), i ? de({
|
|
458
|
+
oldManifest: i,
|
|
459
|
+
newManifest: l
|
|
460
|
+
}) : l;
|
|
461
|
+
}, ye = (e, n, t) => {
|
|
462
|
+
const {
|
|
463
|
+
NOW: r,
|
|
464
|
+
clientOffset: i,
|
|
465
|
+
availabilityStartTime: o,
|
|
466
|
+
timescale: s = 1,
|
|
467
|
+
periodStart: c = 0,
|
|
468
|
+
minimumUpdatePeriod: a = 0
|
|
469
|
+
} = e, u = (r + i) / 1e3, m = o + c, p = u + a - m;
|
|
470
|
+
return Math.ceil((p * s - n) / t);
|
|
471
|
+
}, j = (e, n) => {
|
|
472
|
+
const {
|
|
473
|
+
type: t,
|
|
474
|
+
minimumUpdatePeriod: r = 0,
|
|
475
|
+
media: i = "",
|
|
476
|
+
sourceDuration: o,
|
|
477
|
+
timescale: s = 1,
|
|
478
|
+
startNumber: c = 1,
|
|
479
|
+
periodStart: a
|
|
480
|
+
} = e, u = [];
|
|
481
|
+
let m = -1;
|
|
482
|
+
for (let d = 0; d < n.length; d++) {
|
|
483
|
+
const p = n[d], h = p.d, l = p.r || 0, g = p.t || 0;
|
|
484
|
+
m < 0 && (m = g), g && g > m && (m = g);
|
|
485
|
+
let I;
|
|
486
|
+
if (l < 0) {
|
|
487
|
+
const N = d + 1;
|
|
488
|
+
N === n.length ? t === "dynamic" && r > 0 && i.indexOf("$Number$") > 0 ? I = ye(e, m, h) : I = (o * s - m) / h : I = (n[N].t - m) / h;
|
|
489
|
+
} else
|
|
490
|
+
I = l + 1;
|
|
491
|
+
const U = c + u.length + I;
|
|
492
|
+
let D = c + u.length;
|
|
493
|
+
for (; D < U; )
|
|
494
|
+
u.push({
|
|
495
|
+
number: D,
|
|
496
|
+
duration: h / s,
|
|
497
|
+
time: m,
|
|
498
|
+
timeline: a
|
|
499
|
+
}), m += h, D++;
|
|
500
|
+
}
|
|
501
|
+
return u;
|
|
502
|
+
}, Pe = /\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g, Re = (e) => (n, t, r, i) => {
|
|
503
|
+
if (n === "$$")
|
|
504
|
+
return "$";
|
|
505
|
+
if (typeof e[t] > "u")
|
|
506
|
+
return n;
|
|
507
|
+
const o = "" + e[t];
|
|
508
|
+
return t === "RepresentationID" || (r ? i = parseInt(i, 10) : i = 1, o.length >= i) ? o : `${new Array(i - o.length + 1).join("0")}${o}`;
|
|
509
|
+
}, H = (e, n) => e.replace(Pe, Re(n)), Oe = (e, n) => !e.duration && !n ? [{
|
|
510
|
+
number: e.startNumber || 1,
|
|
511
|
+
duration: e.sourceDuration,
|
|
512
|
+
time: 0,
|
|
513
|
+
timeline: e.periodStart
|
|
514
|
+
}] : e.duration ? C(e) : j(e, n), Ae = (e, n) => {
|
|
515
|
+
const t = {
|
|
516
|
+
RepresentationID: e.id,
|
|
517
|
+
Bandwidth: e.bandwidth || 0
|
|
518
|
+
}, {
|
|
519
|
+
initialization: r = {
|
|
520
|
+
sourceURL: "",
|
|
521
|
+
range: ""
|
|
522
|
+
}
|
|
523
|
+
} = e, i = O({
|
|
524
|
+
baseUrl: e.baseUrl,
|
|
525
|
+
source: H(r.sourceURL, t),
|
|
526
|
+
range: r.range
|
|
527
|
+
});
|
|
528
|
+
return Oe(e, n).map((s) => {
|
|
529
|
+
t.Number = s.number, t.Time = s.time;
|
|
530
|
+
const c = H(e.media || "", t), a = e.timescale || 1, u = e.presentationTimeOffset || 0, m = (
|
|
531
|
+
// Even if the @t attribute is not specified for the segment, segment.time is
|
|
532
|
+
// calculated in mpd-parser prior to this, so it's assumed to be available.
|
|
533
|
+
e.periodStart + (s.time - u) / a
|
|
534
|
+
);
|
|
535
|
+
return {
|
|
536
|
+
uri: c,
|
|
537
|
+
timeline: s.timeline,
|
|
538
|
+
duration: s.duration,
|
|
539
|
+
resolvedUri: L(e.baseUrl || "", c),
|
|
540
|
+
map: i,
|
|
541
|
+
number: s.number,
|
|
542
|
+
presentationTime: m
|
|
543
|
+
};
|
|
544
|
+
});
|
|
545
|
+
}, _e = (e, n) => {
|
|
546
|
+
const {
|
|
547
|
+
baseUrl: t,
|
|
548
|
+
initialization: r = {}
|
|
549
|
+
} = e, i = O({
|
|
550
|
+
baseUrl: t,
|
|
551
|
+
source: r.sourceURL,
|
|
552
|
+
range: r.range
|
|
553
|
+
}), o = O({
|
|
554
|
+
baseUrl: t,
|
|
555
|
+
source: n.media,
|
|
556
|
+
range: n.mediaRange
|
|
557
|
+
});
|
|
558
|
+
return o.map = i, o;
|
|
559
|
+
}, Me = (e, n) => {
|
|
560
|
+
const {
|
|
561
|
+
duration: t,
|
|
562
|
+
segmentUrls: r = [],
|
|
563
|
+
periodStart: i
|
|
564
|
+
} = e;
|
|
565
|
+
if (!t && !n || t && n)
|
|
566
|
+
throw new Error(R.SEGMENT_TIME_UNSPECIFIED);
|
|
567
|
+
const o = r.map((a) => _e(e, a));
|
|
568
|
+
let s;
|
|
569
|
+
return t && (s = C(e)), n && (s = j(e, n)), s.map((a, u) => {
|
|
570
|
+
if (o[u]) {
|
|
571
|
+
const m = o[u], d = e.timescale || 1, p = e.presentationTimeOffset || 0;
|
|
572
|
+
return m.timeline = a.timeline, m.duration = a.duration, m.number = a.number, m.presentationTime = i + (a.time - p) / d, m;
|
|
573
|
+
}
|
|
574
|
+
}).filter((a) => a);
|
|
575
|
+
}, Le = ({
|
|
576
|
+
attributes: e,
|
|
577
|
+
segmentInfo: n
|
|
578
|
+
}) => {
|
|
579
|
+
let t, r;
|
|
580
|
+
n.template ? (r = Ae, t = E(e, n.template)) : n.base ? (r = Y, t = E(e, n.base)) : n.list && (r = Me, t = E(e, n.list));
|
|
581
|
+
const i = {
|
|
582
|
+
attributes: e
|
|
583
|
+
};
|
|
584
|
+
if (!r)
|
|
585
|
+
return i;
|
|
586
|
+
const o = r(t, n.segmentTimeline);
|
|
587
|
+
if (t.duration) {
|
|
588
|
+
const {
|
|
589
|
+
duration: s,
|
|
590
|
+
timescale: c = 1
|
|
591
|
+
} = t;
|
|
592
|
+
t.duration = s / c;
|
|
593
|
+
} else o.length ? t.duration = o.reduce((s, c) => Math.max(s, Math.ceil(c.duration)), 0) : t.duration = 0;
|
|
594
|
+
return i.attributes = t, i.segments = o, n.base && t.indexRange && (i.sidx = o[0], i.segments = []), i;
|
|
595
|
+
}, Ce = (e) => e.map(Le), f = (e, n) => W(e.childNodes).filter(({
|
|
596
|
+
tagName: t
|
|
597
|
+
}) => t === n), A = (e) => e.textContent.trim(), Be = (e) => parseFloat(e.split("/").reduce((n, t) => n / t)), y = (e) => {
|
|
598
|
+
const c = /P(?:(\d*)Y)?(?:(\d*)M)?(?:(\d*)D)?(?:T(?:(\d*)H)?(?:(\d*)M)?(?:([\d.]*)S)?)?/.exec(e);
|
|
599
|
+
if (!c)
|
|
600
|
+
return 0;
|
|
601
|
+
const [a, u, m, d, p, h] = c.slice(1);
|
|
602
|
+
return parseFloat(a || 0) * 31536e3 + parseFloat(u || 0) * 2592e3 + parseFloat(m || 0) * 86400 + parseFloat(d || 0) * 3600 + parseFloat(p || 0) * 60 + parseFloat(h || 0);
|
|
603
|
+
}, ve = (e) => (/^\d+-\d+-\d+T\d+:\d+:\d+(\.\d+)?$/.test(e) && (e += "Z"), Date.parse(e)), V = {
|
|
604
|
+
/**
|
|
605
|
+
* Specifies the duration of the entire Media Presentation. Format is a duration string
|
|
606
|
+
* as specified in ISO 8601
|
|
607
|
+
*
|
|
608
|
+
* @param {string} value
|
|
609
|
+
* value of attribute as a string
|
|
610
|
+
* @return {number}
|
|
611
|
+
* The duration in seconds
|
|
612
|
+
*/
|
|
613
|
+
mediaPresentationDuration(e) {
|
|
614
|
+
return y(e);
|
|
615
|
+
},
|
|
616
|
+
/**
|
|
617
|
+
* Specifies the Segment availability start time for all Segments referred to in this
|
|
618
|
+
* MPD. For a dynamic manifest, it specifies the anchor for the earliest availability
|
|
619
|
+
* time. Format is a date string as specified in ISO 8601
|
|
620
|
+
*
|
|
621
|
+
* @param {string} value
|
|
622
|
+
* value of attribute as a string
|
|
623
|
+
* @return {number}
|
|
624
|
+
* The date as seconds from unix epoch
|
|
625
|
+
*/
|
|
626
|
+
availabilityStartTime(e) {
|
|
627
|
+
return ve(e) / 1e3;
|
|
628
|
+
},
|
|
629
|
+
/**
|
|
630
|
+
* Specifies the smallest period between potential changes to the MPD. Format is a
|
|
631
|
+
* duration string as specified in ISO 8601
|
|
632
|
+
*
|
|
633
|
+
* @param {string} value
|
|
634
|
+
* value of attribute as a string
|
|
635
|
+
* @return {number}
|
|
636
|
+
* The duration in seconds
|
|
637
|
+
*/
|
|
638
|
+
minimumUpdatePeriod(e) {
|
|
639
|
+
return y(e);
|
|
640
|
+
},
|
|
641
|
+
/**
|
|
642
|
+
* Specifies the suggested presentation delay. Format is a
|
|
643
|
+
* duration string as specified in ISO 8601
|
|
644
|
+
*
|
|
645
|
+
* @param {string} value
|
|
646
|
+
* value of attribute as a string
|
|
647
|
+
* @return {number}
|
|
648
|
+
* The duration in seconds
|
|
649
|
+
*/
|
|
650
|
+
suggestedPresentationDelay(e) {
|
|
651
|
+
return y(e);
|
|
652
|
+
},
|
|
653
|
+
/**
|
|
654
|
+
* specifices the type of mpd. Can be either "static" or "dynamic"
|
|
655
|
+
*
|
|
656
|
+
* @param {string} value
|
|
657
|
+
* value of attribute as a string
|
|
658
|
+
*
|
|
659
|
+
* @return {string}
|
|
660
|
+
* The type as a string
|
|
661
|
+
*/
|
|
662
|
+
type(e) {
|
|
663
|
+
return e;
|
|
664
|
+
},
|
|
665
|
+
/**
|
|
666
|
+
* Specifies the duration of the smallest time shifting buffer for any Representation
|
|
667
|
+
* in the MPD. Format is a duration string as specified in ISO 8601
|
|
668
|
+
*
|
|
669
|
+
* @param {string} value
|
|
670
|
+
* value of attribute as a string
|
|
671
|
+
* @return {number}
|
|
672
|
+
* The duration in seconds
|
|
673
|
+
*/
|
|
674
|
+
timeShiftBufferDepth(e) {
|
|
675
|
+
return y(e);
|
|
676
|
+
},
|
|
677
|
+
/**
|
|
678
|
+
* Specifies the PeriodStart time of the Period relative to the availabilityStarttime.
|
|
679
|
+
* Format is a duration string as specified in ISO 8601
|
|
680
|
+
*
|
|
681
|
+
* @param {string} value
|
|
682
|
+
* value of attribute as a string
|
|
683
|
+
* @return {number}
|
|
684
|
+
* The duration in seconds
|
|
685
|
+
*/
|
|
686
|
+
start(e) {
|
|
687
|
+
return y(e);
|
|
688
|
+
},
|
|
689
|
+
/**
|
|
690
|
+
* Specifies the width of the visual presentation
|
|
691
|
+
*
|
|
692
|
+
* @param {string} value
|
|
693
|
+
* value of attribute as a string
|
|
694
|
+
* @return {number}
|
|
695
|
+
* The parsed width
|
|
696
|
+
*/
|
|
697
|
+
width(e) {
|
|
698
|
+
return parseInt(e, 10);
|
|
699
|
+
},
|
|
700
|
+
/**
|
|
701
|
+
* Specifies the height of the visual presentation
|
|
702
|
+
*
|
|
703
|
+
* @param {string} value
|
|
704
|
+
* value of attribute as a string
|
|
705
|
+
* @return {number}
|
|
706
|
+
* The parsed height
|
|
707
|
+
*/
|
|
708
|
+
height(e) {
|
|
709
|
+
return parseInt(e, 10);
|
|
710
|
+
},
|
|
711
|
+
/**
|
|
712
|
+
* Specifies the bitrate of the representation
|
|
713
|
+
*
|
|
714
|
+
* @param {string} value
|
|
715
|
+
* value of attribute as a string
|
|
716
|
+
* @return {number}
|
|
717
|
+
* The parsed bandwidth
|
|
718
|
+
*/
|
|
719
|
+
bandwidth(e) {
|
|
720
|
+
return parseInt(e, 10);
|
|
721
|
+
},
|
|
722
|
+
/**
|
|
723
|
+
* Specifies the frame rate of the representation
|
|
724
|
+
*
|
|
725
|
+
* @param {string} value
|
|
726
|
+
* value of attribute as a string
|
|
727
|
+
* @return {number}
|
|
728
|
+
* The parsed frame rate
|
|
729
|
+
*/
|
|
730
|
+
frameRate(e) {
|
|
731
|
+
return Be(e);
|
|
732
|
+
},
|
|
733
|
+
/**
|
|
734
|
+
* Specifies the number of the first Media Segment in this Representation in the Period
|
|
735
|
+
*
|
|
736
|
+
* @param {string} value
|
|
737
|
+
* value of attribute as a string
|
|
738
|
+
* @return {number}
|
|
739
|
+
* The parsed number
|
|
740
|
+
*/
|
|
741
|
+
startNumber(e) {
|
|
742
|
+
return parseInt(e, 10);
|
|
743
|
+
},
|
|
744
|
+
/**
|
|
745
|
+
* Specifies the timescale in units per seconds
|
|
746
|
+
*
|
|
747
|
+
* @param {string} value
|
|
748
|
+
* value of attribute as a string
|
|
749
|
+
* @return {number}
|
|
750
|
+
* The parsed timescale
|
|
751
|
+
*/
|
|
752
|
+
timescale(e) {
|
|
753
|
+
return parseInt(e, 10);
|
|
754
|
+
},
|
|
755
|
+
/**
|
|
756
|
+
* Specifies the presentationTimeOffset.
|
|
757
|
+
*
|
|
758
|
+
* @param {string} value
|
|
759
|
+
* value of the attribute as a string
|
|
760
|
+
*
|
|
761
|
+
* @return {number}
|
|
762
|
+
* The parsed presentationTimeOffset
|
|
763
|
+
*/
|
|
764
|
+
presentationTimeOffset(e) {
|
|
765
|
+
return parseInt(e, 10);
|
|
766
|
+
},
|
|
767
|
+
/**
|
|
768
|
+
* Specifies the constant approximate Segment duration
|
|
769
|
+
* NOTE: The <Period> element also contains an @duration attribute. This duration
|
|
770
|
+
* specifies the duration of the Period. This attribute is currently not
|
|
771
|
+
* supported by the rest of the parser, however we still check for it to prevent
|
|
772
|
+
* errors.
|
|
773
|
+
*
|
|
774
|
+
* @param {string} value
|
|
775
|
+
* value of attribute as a string
|
|
776
|
+
* @return {number}
|
|
777
|
+
* The parsed duration
|
|
778
|
+
*/
|
|
779
|
+
duration(e) {
|
|
780
|
+
const n = parseInt(e, 10);
|
|
781
|
+
return isNaN(n) ? y(e) : n;
|
|
782
|
+
},
|
|
783
|
+
/**
|
|
784
|
+
* Specifies the Segment duration, in units of the value of the @timescale.
|
|
785
|
+
*
|
|
786
|
+
* @param {string} value
|
|
787
|
+
* value of attribute as a string
|
|
788
|
+
* @return {number}
|
|
789
|
+
* The parsed duration
|
|
790
|
+
*/
|
|
791
|
+
d(e) {
|
|
792
|
+
return parseInt(e, 10);
|
|
793
|
+
},
|
|
794
|
+
/**
|
|
795
|
+
* Specifies the MPD start time, in @timescale units, the first Segment in the series
|
|
796
|
+
* starts relative to the beginning of the Period
|
|
797
|
+
*
|
|
798
|
+
* @param {string} value
|
|
799
|
+
* value of attribute as a string
|
|
800
|
+
* @return {number}
|
|
801
|
+
* The parsed time
|
|
802
|
+
*/
|
|
803
|
+
t(e) {
|
|
804
|
+
return parseInt(e, 10);
|
|
805
|
+
},
|
|
806
|
+
/**
|
|
807
|
+
* Specifies the repeat count of the number of following contiguous Segments with the
|
|
808
|
+
* same duration expressed by the value of @d
|
|
809
|
+
*
|
|
810
|
+
* @param {string} value
|
|
811
|
+
* value of attribute as a string
|
|
812
|
+
* @return {number}
|
|
813
|
+
* The parsed number
|
|
814
|
+
*/
|
|
815
|
+
r(e) {
|
|
816
|
+
return parseInt(e, 10);
|
|
817
|
+
},
|
|
818
|
+
/**
|
|
819
|
+
* Specifies the presentationTime.
|
|
820
|
+
*
|
|
821
|
+
* @param {string} value
|
|
822
|
+
* value of the attribute as a string
|
|
823
|
+
*
|
|
824
|
+
* @return {number}
|
|
825
|
+
* The parsed presentationTime
|
|
826
|
+
*/
|
|
827
|
+
presentationTime(e) {
|
|
828
|
+
return parseInt(e, 10);
|
|
829
|
+
},
|
|
830
|
+
/**
|
|
831
|
+
* Default parser for all other attributes. Acts as a no-op and just returns the value
|
|
832
|
+
* as a string
|
|
833
|
+
*
|
|
834
|
+
* @param {string} value
|
|
835
|
+
* value of attribute as a string
|
|
836
|
+
* @return {string}
|
|
837
|
+
* Unparsed value
|
|
838
|
+
*/
|
|
839
|
+
DEFAULT(e) {
|
|
840
|
+
return e;
|
|
841
|
+
}
|
|
842
|
+
}, S = (e) => e && e.attributes ? W(e.attributes).reduce((n, t) => {
|
|
843
|
+
const r = V[t.name] || V.DEFAULT;
|
|
844
|
+
return n[t.name] = r(t.value), n;
|
|
845
|
+
}, {}) : {}, xe = {
|
|
846
|
+
"urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b": "org.w3.clearkey",
|
|
847
|
+
"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed": "com.widevine.alpha",
|
|
848
|
+
"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95": "com.microsoft.playready",
|
|
849
|
+
"urn:uuid:f239e769-efa3-4850-9c16-a903c6932efb": "com.adobe.primetime",
|
|
850
|
+
// ISO_IEC 23009-1_2022 5.8.5.2.2 The mp4 Protection Scheme
|
|
851
|
+
"urn:mpeg:dash:mp4protection:2011": "mp4protection"
|
|
852
|
+
}, _ = (e, n) => n.length ? P(e.map(function(t) {
|
|
853
|
+
return n.map(function(r) {
|
|
854
|
+
const i = A(r), o = L(t.baseUrl, i), s = E(S(r), {
|
|
855
|
+
baseUrl: o
|
|
856
|
+
});
|
|
857
|
+
return o !== i && !s.serviceLocation && t.serviceLocation && (s.serviceLocation = t.serviceLocation), s;
|
|
858
|
+
});
|
|
859
|
+
})) : e, v = (e) => {
|
|
860
|
+
const n = f(e, "SegmentTemplate")[0], t = f(e, "SegmentList")[0], r = t && f(t, "SegmentURL").map((d) => E({
|
|
861
|
+
tag: "SegmentURL"
|
|
862
|
+
}, S(d))), i = f(e, "SegmentBase")[0], o = t || n, s = o && f(o, "SegmentTimeline")[0], c = t || i || n, a = c && f(c, "Initialization")[0], u = n && S(n);
|
|
863
|
+
u && a ? u.initialization = a && S(a) : u && u.initialization && (u.initialization = {
|
|
864
|
+
sourceURL: u.initialization
|
|
865
|
+
});
|
|
866
|
+
const m = {
|
|
867
|
+
template: u,
|
|
868
|
+
segmentTimeline: s && f(s, "S").map((d) => S(d)),
|
|
869
|
+
list: t && E(S(t), {
|
|
870
|
+
segmentUrls: r,
|
|
871
|
+
initialization: S(a)
|
|
872
|
+
}),
|
|
873
|
+
base: i && E(S(i), {
|
|
874
|
+
initialization: S(a)
|
|
875
|
+
})
|
|
876
|
+
};
|
|
877
|
+
return Object.keys(m).forEach((d) => {
|
|
878
|
+
m[d] || delete m[d];
|
|
879
|
+
}), m;
|
|
880
|
+
}, we = (e, n, t) => (r) => {
|
|
881
|
+
const i = f(r, "BaseURL"), o = _(n, i), s = E(e, S(r)), c = v(r);
|
|
882
|
+
return o.map((a) => ({
|
|
883
|
+
segmentInfo: E(t, c),
|
|
884
|
+
attributes: E(s, a)
|
|
885
|
+
}));
|
|
886
|
+
}, Fe = (e) => e.reduce((n, t) => {
|
|
887
|
+
const r = S(t);
|
|
888
|
+
r.schemeIdUri && (r.schemeIdUri = r.schemeIdUri.toLowerCase());
|
|
889
|
+
const i = xe[r.schemeIdUri];
|
|
890
|
+
if (i) {
|
|
891
|
+
n[i] = {
|
|
892
|
+
attributes: r
|
|
893
|
+
};
|
|
894
|
+
const o = f(t, "cenc:pssh")[0];
|
|
895
|
+
if (o) {
|
|
896
|
+
const s = A(o);
|
|
897
|
+
n[i].pssh = s && J(s);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
return n;
|
|
901
|
+
}, {}), Ge = (e) => {
|
|
902
|
+
if (e.schemeIdUri === "urn:scte:dash:cc:cea-608:2015")
|
|
903
|
+
return (typeof e.value != "string" ? [] : e.value.split(";")).map((t) => {
|
|
904
|
+
let r, i;
|
|
905
|
+
return i = t, /^CC\d=/.test(t) ? [r, i] = t.split("=") : /^CC\d$/.test(t) && (r = t), {
|
|
906
|
+
channel: r,
|
|
907
|
+
language: i
|
|
908
|
+
};
|
|
909
|
+
});
|
|
910
|
+
if (e.schemeIdUri === "urn:scte:dash:cc:cea-708:2015")
|
|
911
|
+
return (typeof e.value != "string" ? [] : e.value.split(";")).map((t) => {
|
|
912
|
+
const r = {
|
|
913
|
+
// service or channel number 1-63
|
|
914
|
+
channel: void 0,
|
|
915
|
+
// language is a 3ALPHA per ISO 639.2/B
|
|
916
|
+
// field is required
|
|
917
|
+
language: void 0,
|
|
918
|
+
// BIT 1/0 or ?
|
|
919
|
+
// default value is 1, meaning 16:9 aspect ratio, 0 is 4:3, ? is unknown
|
|
920
|
+
aspectRatio: 1,
|
|
921
|
+
// BIT 1/0
|
|
922
|
+
// easy reader flag indicated the text is tailed to the needs of beginning readers
|
|
923
|
+
// default 0, or off
|
|
924
|
+
easyReader: 0,
|
|
925
|
+
// BIT 1/0
|
|
926
|
+
// If 3d metadata is present (CEA-708.1) then 1
|
|
927
|
+
// default 0
|
|
928
|
+
"3D": 0
|
|
929
|
+
};
|
|
930
|
+
if (/=/.test(t)) {
|
|
931
|
+
const [i, o = ""] = t.split("=");
|
|
932
|
+
r.channel = i, r.language = t, o.split(",").forEach((s) => {
|
|
933
|
+
const [c, a] = s.split(":");
|
|
934
|
+
c === "lang" ? r.language = a : c === "er" ? r.easyReader = Number(a) : c === "war" ? r.aspectRatio = Number(a) : c === "3D" && (r["3D"] = Number(a));
|
|
935
|
+
});
|
|
936
|
+
} else
|
|
937
|
+
r.language = t;
|
|
938
|
+
return r.channel && (r.channel = "SERVICE" + r.channel), r;
|
|
939
|
+
});
|
|
940
|
+
}, ze = (e) => P(f(e.node, "EventStream").map((n) => {
|
|
941
|
+
const t = S(n), r = t.schemeIdUri;
|
|
942
|
+
return f(n, "Event").map((i) => {
|
|
943
|
+
const o = S(i), s = o.presentationTime || 0, c = t.timescale || 1, a = o.duration || 0, u = s / c + e.attributes.start;
|
|
944
|
+
return {
|
|
945
|
+
schemeIdUri: r,
|
|
946
|
+
value: t.value,
|
|
947
|
+
id: o.id,
|
|
948
|
+
start: u,
|
|
949
|
+
end: u + a / c,
|
|
950
|
+
messageData: A(i) || o.messageData,
|
|
951
|
+
contentEncoding: t.contentEncoding,
|
|
952
|
+
presentationTimeOffset: t.presentationTimeOffset || 0
|
|
953
|
+
};
|
|
954
|
+
});
|
|
955
|
+
})), $e = (e, n, t) => (r) => {
|
|
956
|
+
const i = S(r), o = _(n, f(r, "BaseURL")), s = f(r, "Role")[0], c = {
|
|
957
|
+
role: S(s)
|
|
958
|
+
};
|
|
959
|
+
let a = E(e, i, c);
|
|
960
|
+
const u = f(r, "Accessibility")[0], m = Ge(S(u));
|
|
961
|
+
m && (a = E(a, {
|
|
962
|
+
captionServices: m
|
|
963
|
+
}));
|
|
964
|
+
const d = f(r, "Label")[0];
|
|
965
|
+
if (d && d.childNodes.length) {
|
|
966
|
+
const I = d.childNodes[0].nodeValue.trim();
|
|
967
|
+
a = E(a, {
|
|
968
|
+
label: I
|
|
969
|
+
});
|
|
970
|
+
}
|
|
971
|
+
const p = Fe(f(r, "ContentProtection"));
|
|
972
|
+
Object.keys(p).length && (a = E(a, {
|
|
973
|
+
contentProtection: p
|
|
974
|
+
}));
|
|
975
|
+
const h = v(r), l = f(r, "Representation"), g = E(t, h);
|
|
976
|
+
return P(l.map(we(a, o, g)));
|
|
977
|
+
}, He = (e, n) => (t, r) => {
|
|
978
|
+
const i = _(n, f(t.node, "BaseURL")), o = E(e, {
|
|
979
|
+
periodStart: t.attributes.start
|
|
980
|
+
});
|
|
981
|
+
typeof t.attributes.duration == "number" && (o.periodDuration = t.attributes.duration);
|
|
982
|
+
const s = f(t.node, "AdaptationSet"), c = v(t.node);
|
|
983
|
+
return P(s.map($e(o, i, c)));
|
|
984
|
+
}, Ve = (e, n) => {
|
|
985
|
+
if (e.length > 1 && n({
|
|
986
|
+
type: "warn",
|
|
987
|
+
message: "The MPD manifest should contain no more than one ContentSteering tag"
|
|
988
|
+
}), !e.length)
|
|
989
|
+
return null;
|
|
990
|
+
const t = E({
|
|
991
|
+
serverURL: A(e[0])
|
|
992
|
+
}, S(e[0]));
|
|
993
|
+
return t.queryBeforeStart = t.queryBeforeStart === "true", t;
|
|
994
|
+
}, qe = ({
|
|
995
|
+
attributes: e,
|
|
996
|
+
priorPeriodAttributes: n,
|
|
997
|
+
mpdType: t
|
|
998
|
+
}) => typeof e.start == "number" ? e.start : n && typeof n.start == "number" && typeof n.duration == "number" ? n.start + n.duration : !n && t === "static" ? 0 : null, We = (e, n = {}) => {
|
|
999
|
+
const {
|
|
1000
|
+
manifestUri: t = "",
|
|
1001
|
+
NOW: r = Date.now(),
|
|
1002
|
+
clientOffset: i = 0,
|
|
1003
|
+
// TODO: For now, we are expecting an eventHandler callback function
|
|
1004
|
+
// to be passed into the mpd parser as an option.
|
|
1005
|
+
// In the future, we should enable stream parsing by using the Stream class from vhs-utils.
|
|
1006
|
+
// This will support new features including a standardized event handler.
|
|
1007
|
+
// See the m3u8 parser for examples of how stream parsing is currently used for HLS parsing.
|
|
1008
|
+
// https://github.com/videojs/vhs-utils/blob/88d6e10c631e57a5af02c5a62bc7376cd456b4f5/src/stream.js#L9
|
|
1009
|
+
eventHandler: o = function() {
|
|
1010
|
+
}
|
|
1011
|
+
} = n, s = f(e, "Period");
|
|
1012
|
+
if (!s.length)
|
|
1013
|
+
throw new Error(R.INVALID_NUMBER_OF_PERIOD);
|
|
1014
|
+
const c = f(e, "Location"), a = S(e), u = _([{
|
|
1015
|
+
baseUrl: t
|
|
1016
|
+
}], f(e, "BaseURL")), m = f(e, "ContentSteering");
|
|
1017
|
+
a.type = a.type || "static", a.sourceDuration = a.mediaPresentationDuration || 0, a.NOW = r, a.clientOffset = i, c.length && (a.locations = c.map(A));
|
|
1018
|
+
const d = [];
|
|
1019
|
+
return s.forEach((p, h) => {
|
|
1020
|
+
const l = S(p), g = d[h - 1];
|
|
1021
|
+
l.start = qe({
|
|
1022
|
+
attributes: l,
|
|
1023
|
+
priorPeriodAttributes: g ? g.attributes : null,
|
|
1024
|
+
mpdType: a.type
|
|
1025
|
+
}), d.push({
|
|
1026
|
+
node: p,
|
|
1027
|
+
attributes: l
|
|
1028
|
+
});
|
|
1029
|
+
}), {
|
|
1030
|
+
locations: a.locations,
|
|
1031
|
+
contentSteeringInfo: Ve(m, o),
|
|
1032
|
+
// TODO: There are occurences where this `representationInfo` array contains undesired
|
|
1033
|
+
// duplicates. This generally occurs when there are multiple BaseURL nodes that are
|
|
1034
|
+
// direct children of the MPD node. When we attempt to resolve URLs from a combination of the
|
|
1035
|
+
// parent BaseURL and a child BaseURL, and the value does not resolve,
|
|
1036
|
+
// we end up returning the child BaseURL multiple times.
|
|
1037
|
+
// We need to determine a way to remove these duplicates in a safe way.
|
|
1038
|
+
// See: https://github.com/videojs/mpd-parser/pull/17#discussion_r162750527
|
|
1039
|
+
representationInfo: P(d.map(He(a, u))),
|
|
1040
|
+
eventStream: P(d.map(ze))
|
|
1041
|
+
};
|
|
1042
|
+
}, K = (e) => {
|
|
1043
|
+
if (e === "")
|
|
1044
|
+
throw new Error(R.DASH_EMPTY_MANIFEST);
|
|
1045
|
+
const n = new Q.DOMParser();
|
|
1046
|
+
let t, r;
|
|
1047
|
+
try {
|
|
1048
|
+
t = n.parseFromString(e, "application/xml"), r = t && t.documentElement.tagName === "MPD" ? t.documentElement : null;
|
|
1049
|
+
} catch {
|
|
1050
|
+
}
|
|
1051
|
+
if (!r || r && r.getElementsByTagName("parsererror").length > 0)
|
|
1052
|
+
throw new Error(R.DASH_INVALID_XML);
|
|
1053
|
+
return r;
|
|
1054
|
+
}, Ye = (e) => {
|
|
1055
|
+
const n = f(e, "UTCTiming")[0];
|
|
1056
|
+
if (!n)
|
|
1057
|
+
return null;
|
|
1058
|
+
const t = S(n);
|
|
1059
|
+
switch (t.schemeIdUri) {
|
|
1060
|
+
case "urn:mpeg:dash:utc:http-head:2014":
|
|
1061
|
+
case "urn:mpeg:dash:utc:http-head:2012":
|
|
1062
|
+
t.method = "HEAD";
|
|
1063
|
+
break;
|
|
1064
|
+
case "urn:mpeg:dash:utc:http-xsdate:2014":
|
|
1065
|
+
case "urn:mpeg:dash:utc:http-iso:2014":
|
|
1066
|
+
case "urn:mpeg:dash:utc:http-xsdate:2012":
|
|
1067
|
+
case "urn:mpeg:dash:utc:http-iso:2012":
|
|
1068
|
+
t.method = "GET";
|
|
1069
|
+
break;
|
|
1070
|
+
case "urn:mpeg:dash:utc:direct:2014":
|
|
1071
|
+
case "urn:mpeg:dash:utc:direct:2012":
|
|
1072
|
+
t.method = "DIRECT", t.value = Date.parse(t.value);
|
|
1073
|
+
break;
|
|
1074
|
+
case "urn:mpeg:dash:utc:http-ntp:2014":
|
|
1075
|
+
case "urn:mpeg:dash:utc:ntp:2014":
|
|
1076
|
+
case "urn:mpeg:dash:utc:sntp:2014":
|
|
1077
|
+
default:
|
|
1078
|
+
throw new Error(R.UNSUPPORTED_UTC_TIMING_SCHEME);
|
|
1079
|
+
}
|
|
1080
|
+
return t;
|
|
1081
|
+
}, Qe = (e, n = {}) => {
|
|
1082
|
+
const t = We(K(e), n), r = Ce(t.representationInfo);
|
|
1083
|
+
return be({
|
|
1084
|
+
dashPlaylists: r,
|
|
1085
|
+
locations: t.locations,
|
|
1086
|
+
contentSteering: t.contentSteeringInfo,
|
|
1087
|
+
sidxMapping: n.sidxMapping,
|
|
1088
|
+
previousManifest: n.previousManifest,
|
|
1089
|
+
eventStream: t.eventStream
|
|
1090
|
+
});
|
|
1091
|
+
}, et = (e) => Ye(K(e));
|
|
1092
|
+
export {
|
|
1093
|
+
se as addSidxSegmentsToPlaylist,
|
|
1094
|
+
le as generateSidxKey,
|
|
1095
|
+
We as inheritAttributes,
|
|
1096
|
+
Qe as parse,
|
|
1097
|
+
et as parseUTCTiming,
|
|
1098
|
+
K as stringToMpdXml,
|
|
1099
|
+
be as toM3u8,
|
|
1100
|
+
Ce as toPlaylists
|
|
1101
|
+
};
|
|
1102
|
+
//# sourceMappingURL=mpd-parser.es.js.map
|