@shopify/shop-minis-react 0.0.20 → 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/hooks/storage/useImageUpload.js.map +1 -1
- package/dist/hooks/util/useErrorScreen.js.map +1 -1
- package/dist/hooks/util/useErrorToast.js.map +1 -1
- package/dist/index.js +205 -195
- 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 +6 -2
- package/src/components/atoms/video-player.tsx +213 -0
- package/src/components/commerce/merchant-card.tsx +219 -49
- package/src/components/index.ts +2 -0
- package/src/hooks/storage/useImageUpload.ts +3 -2
- package/src/hooks/util/useErrorScreen.ts +2 -1
- package/src/hooks/util/useErrorToast.ts +2 -1
- 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 -29
- 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 -57
- 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 -18
- 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 -30
- package/src/hooks/util/useErrorScreen.doc.ts +0 -32
- package/src/hooks/util/useErrorScreen.example.tsx +0 -16
- 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 -85
|
@@ -0,0 +1,855 @@
|
|
|
1
|
+
import O from "../../../../@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/stream.js";
|
|
2
|
+
import I from "../../../../@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/extends.js";
|
|
3
|
+
import U from "../../../../@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/decode-b64-to-uint8-array.js";
|
|
4
|
+
/*! @name m3u8-parser @version 7.2.0 @license Apache-2.0 */
|
|
5
|
+
class w extends O {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(), this.buffer = "";
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Add new data to be parsed.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} data the text to process
|
|
13
|
+
*/
|
|
14
|
+
push(n) {
|
|
15
|
+
let e;
|
|
16
|
+
for (this.buffer += n, e = this.buffer.indexOf(`
|
|
17
|
+
`); e > -1; e = this.buffer.indexOf(`
|
|
18
|
+
`))
|
|
19
|
+
this.trigger("data", this.buffer.substring(0, e)), this.buffer = this.buffer.substring(e + 1);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const x = " ", D = function(f) {
|
|
23
|
+
const n = /([0-9.]*)?@?([0-9.]*)?/.exec(f || ""), e = {};
|
|
24
|
+
return n[1] && (e.length = parseInt(n[1], 10)), n[2] && (e.offset = parseInt(n[2], 10)), e;
|
|
25
|
+
}, $ = function() {
|
|
26
|
+
const e = "(?:" + "[^=]*" + ")=(?:" + '"[^"]*"|[^,]*' + ")";
|
|
27
|
+
return new RegExp("(?:^|,)(" + e + ")");
|
|
28
|
+
}, h = function(f) {
|
|
29
|
+
const n = {};
|
|
30
|
+
if (!f)
|
|
31
|
+
return n;
|
|
32
|
+
const e = f.split($());
|
|
33
|
+
let t = e.length, a;
|
|
34
|
+
for (; t--; )
|
|
35
|
+
e[t] !== "" && (a = /([^=]*)=(.*)/.exec(e[t]).slice(1), a[0] = a[0].replace(/^\s+|\s+$/g, ""), a[1] = a[1].replace(/^\s+|\s+$/g, ""), a[1] = a[1].replace(/^['"](.*)['"]$/g, "$1"), n[a[0]] = a[1]);
|
|
36
|
+
return n;
|
|
37
|
+
}, M = (f) => {
|
|
38
|
+
const n = f.split("x"), e = {};
|
|
39
|
+
return n[0] && (e.width = parseInt(n[0], 10)), n[1] && (e.height = parseInt(n[1], 10)), e;
|
|
40
|
+
};
|
|
41
|
+
class G extends O {
|
|
42
|
+
constructor() {
|
|
43
|
+
super(), this.customParsers = [], this.tagMappers = [];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Parses an additional line of input.
|
|
47
|
+
*
|
|
48
|
+
* @param {string} line a single line of an M3U8 file to parse
|
|
49
|
+
*/
|
|
50
|
+
push(n) {
|
|
51
|
+
let e, t;
|
|
52
|
+
if (n = n.trim(), n.length === 0)
|
|
53
|
+
return;
|
|
54
|
+
if (n[0] !== "#") {
|
|
55
|
+
this.trigger("data", {
|
|
56
|
+
type: "uri",
|
|
57
|
+
uri: n
|
|
58
|
+
});
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
this.tagMappers.reduce((s, u) => {
|
|
62
|
+
const o = u(n);
|
|
63
|
+
return o === n ? s : s.concat([o]);
|
|
64
|
+
}, [n]).forEach((s) => {
|
|
65
|
+
for (let u = 0; u < this.customParsers.length; u++)
|
|
66
|
+
if (this.customParsers[u].call(this, s))
|
|
67
|
+
return;
|
|
68
|
+
if (s.indexOf("#EXT") !== 0) {
|
|
69
|
+
this.trigger("data", {
|
|
70
|
+
type: "comment",
|
|
71
|
+
text: s.slice(1)
|
|
72
|
+
});
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (s = s.replace("\r", ""), e = /^#EXTM3U/.exec(s), e) {
|
|
76
|
+
this.trigger("data", {
|
|
77
|
+
type: "tag",
|
|
78
|
+
tagType: "m3u"
|
|
79
|
+
});
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (e = /^#EXTINF:([0-9\.]*)?,?(.*)?$/.exec(s), e) {
|
|
83
|
+
t = {
|
|
84
|
+
type: "tag",
|
|
85
|
+
tagType: "inf"
|
|
86
|
+
}, e[1] && (t.duration = parseFloat(e[1])), e[2] && (t.title = e[2]), this.trigger("data", t);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (e = /^#EXT-X-TARGETDURATION:([0-9.]*)?/.exec(s), e) {
|
|
90
|
+
t = {
|
|
91
|
+
type: "tag",
|
|
92
|
+
tagType: "targetduration"
|
|
93
|
+
}, e[1] && (t.duration = parseInt(e[1], 10)), this.trigger("data", t);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (e = /^#EXT-X-VERSION:([0-9.]*)?/.exec(s), e) {
|
|
97
|
+
t = {
|
|
98
|
+
type: "tag",
|
|
99
|
+
tagType: "version"
|
|
100
|
+
}, e[1] && (t.version = parseInt(e[1], 10)), this.trigger("data", t);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (e = /^#EXT-X-MEDIA-SEQUENCE:(\-?[0-9.]*)?/.exec(s), e) {
|
|
104
|
+
t = {
|
|
105
|
+
type: "tag",
|
|
106
|
+
tagType: "media-sequence"
|
|
107
|
+
}, e[1] && (t.number = parseInt(e[1], 10)), this.trigger("data", t);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (e = /^#EXT-X-DISCONTINUITY-SEQUENCE:(\-?[0-9.]*)?/.exec(s), e) {
|
|
111
|
+
t = {
|
|
112
|
+
type: "tag",
|
|
113
|
+
tagType: "discontinuity-sequence"
|
|
114
|
+
}, e[1] && (t.number = parseInt(e[1], 10)), this.trigger("data", t);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (e = /^#EXT-X-PLAYLIST-TYPE:(.*)?$/.exec(s), e) {
|
|
118
|
+
t = {
|
|
119
|
+
type: "tag",
|
|
120
|
+
tagType: "playlist-type"
|
|
121
|
+
}, e[1] && (t.playlistType = e[1]), this.trigger("data", t);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (e = /^#EXT-X-BYTERANGE:(.*)?$/.exec(s), e) {
|
|
125
|
+
t = I(D(e[1]), {
|
|
126
|
+
type: "tag",
|
|
127
|
+
tagType: "byterange"
|
|
128
|
+
}), this.trigger("data", t);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (e = /^#EXT-X-ALLOW-CACHE:(YES|NO)?/.exec(s), e) {
|
|
132
|
+
t = {
|
|
133
|
+
type: "tag",
|
|
134
|
+
tagType: "allow-cache"
|
|
135
|
+
}, e[1] && (t.allowed = !/NO/.test(e[1])), this.trigger("data", t);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (e = /^#EXT-X-MAP:(.*)$/.exec(s), e) {
|
|
139
|
+
if (t = {
|
|
140
|
+
type: "tag",
|
|
141
|
+
tagType: "map"
|
|
142
|
+
}, e[1]) {
|
|
143
|
+
const u = h(e[1]);
|
|
144
|
+
u.URI && (t.uri = u.URI), u.BYTERANGE && (t.byterange = D(u.BYTERANGE));
|
|
145
|
+
}
|
|
146
|
+
this.trigger("data", t);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
if (e = /^#EXT-X-STREAM-INF:(.*)$/.exec(s), e) {
|
|
150
|
+
t = {
|
|
151
|
+
type: "tag",
|
|
152
|
+
tagType: "stream-inf"
|
|
153
|
+
}, e[1] && (t.attributes = h(e[1]), t.attributes.RESOLUTION && (t.attributes.RESOLUTION = M(t.attributes.RESOLUTION)), t.attributes.BANDWIDTH && (t.attributes.BANDWIDTH = parseInt(t.attributes.BANDWIDTH, 10)), t.attributes["FRAME-RATE"] && (t.attributes["FRAME-RATE"] = parseFloat(t.attributes["FRAME-RATE"])), t.attributes["PROGRAM-ID"] && (t.attributes["PROGRAM-ID"] = parseInt(t.attributes["PROGRAM-ID"], 10))), this.trigger("data", t);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (e = /^#EXT-X-MEDIA:(.*)$/.exec(s), e) {
|
|
157
|
+
t = {
|
|
158
|
+
type: "tag",
|
|
159
|
+
tagType: "media"
|
|
160
|
+
}, e[1] && (t.attributes = h(e[1])), this.trigger("data", t);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (e = /^#EXT-X-ENDLIST/.exec(s), e) {
|
|
164
|
+
this.trigger("data", {
|
|
165
|
+
type: "tag",
|
|
166
|
+
tagType: "endlist"
|
|
167
|
+
});
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (e = /^#EXT-X-DISCONTINUITY/.exec(s), e) {
|
|
171
|
+
this.trigger("data", {
|
|
172
|
+
type: "tag",
|
|
173
|
+
tagType: "discontinuity"
|
|
174
|
+
});
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (e = /^#EXT-X-PROGRAM-DATE-TIME:(.*)$/.exec(s), e) {
|
|
178
|
+
t = {
|
|
179
|
+
type: "tag",
|
|
180
|
+
tagType: "program-date-time"
|
|
181
|
+
}, e[1] && (t.dateTimeString = e[1], t.dateTimeObject = new Date(e[1])), this.trigger("data", t);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (e = /^#EXT-X-KEY:(.*)$/.exec(s), e) {
|
|
185
|
+
t = {
|
|
186
|
+
type: "tag",
|
|
187
|
+
tagType: "key"
|
|
188
|
+
}, e[1] && (t.attributes = h(e[1]), t.attributes.IV && (t.attributes.IV.substring(0, 2).toLowerCase() === "0x" && (t.attributes.IV = t.attributes.IV.substring(2)), t.attributes.IV = t.attributes.IV.match(/.{8}/g), t.attributes.IV[0] = parseInt(t.attributes.IV[0], 16), t.attributes.IV[1] = parseInt(t.attributes.IV[1], 16), t.attributes.IV[2] = parseInt(t.attributes.IV[2], 16), t.attributes.IV[3] = parseInt(t.attributes.IV[3], 16), t.attributes.IV = new Uint32Array(t.attributes.IV))), this.trigger("data", t);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (e = /^#EXT-X-START:(.*)$/.exec(s), e) {
|
|
192
|
+
t = {
|
|
193
|
+
type: "tag",
|
|
194
|
+
tagType: "start"
|
|
195
|
+
}, e[1] && (t.attributes = h(e[1]), t.attributes["TIME-OFFSET"] = parseFloat(t.attributes["TIME-OFFSET"]), t.attributes.PRECISE = /YES/.test(t.attributes.PRECISE)), this.trigger("data", t);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
if (e = /^#EXT-X-CUE-OUT-CONT:(.*)?$/.exec(s), e) {
|
|
199
|
+
t = {
|
|
200
|
+
type: "tag",
|
|
201
|
+
tagType: "cue-out-cont"
|
|
202
|
+
}, e[1] ? t.data = e[1] : t.data = "", this.trigger("data", t);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
if (e = /^#EXT-X-CUE-OUT:(.*)?$/.exec(s), e) {
|
|
206
|
+
t = {
|
|
207
|
+
type: "tag",
|
|
208
|
+
tagType: "cue-out"
|
|
209
|
+
}, e[1] ? t.data = e[1] : t.data = "", this.trigger("data", t);
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
if (e = /^#EXT-X-CUE-IN:?(.*)?$/.exec(s), e) {
|
|
213
|
+
t = {
|
|
214
|
+
type: "tag",
|
|
215
|
+
tagType: "cue-in"
|
|
216
|
+
}, e[1] ? t.data = e[1] : t.data = "", this.trigger("data", t);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
if (e = /^#EXT-X-SKIP:(.*)$/.exec(s), e && e[1]) {
|
|
220
|
+
t = {
|
|
221
|
+
type: "tag",
|
|
222
|
+
tagType: "skip"
|
|
223
|
+
}, t.attributes = h(e[1]), t.attributes.hasOwnProperty("SKIPPED-SEGMENTS") && (t.attributes["SKIPPED-SEGMENTS"] = parseInt(t.attributes["SKIPPED-SEGMENTS"], 10)), t.attributes.hasOwnProperty("RECENTLY-REMOVED-DATERANGES") && (t.attributes["RECENTLY-REMOVED-DATERANGES"] = t.attributes["RECENTLY-REMOVED-DATERANGES"].split(x)), this.trigger("data", t);
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
if (e = /^#EXT-X-PART:(.*)$/.exec(s), e && e[1]) {
|
|
227
|
+
t = {
|
|
228
|
+
type: "tag",
|
|
229
|
+
tagType: "part"
|
|
230
|
+
}, t.attributes = h(e[1]), ["DURATION"].forEach(function(u) {
|
|
231
|
+
t.attributes.hasOwnProperty(u) && (t.attributes[u] = parseFloat(t.attributes[u]));
|
|
232
|
+
}), ["INDEPENDENT", "GAP"].forEach(function(u) {
|
|
233
|
+
t.attributes.hasOwnProperty(u) && (t.attributes[u] = /YES/.test(t.attributes[u]));
|
|
234
|
+
}), t.attributes.hasOwnProperty("BYTERANGE") && (t.attributes.byterange = D(t.attributes.BYTERANGE)), this.trigger("data", t);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (e = /^#EXT-X-SERVER-CONTROL:(.*)$/.exec(s), e && e[1]) {
|
|
238
|
+
t = {
|
|
239
|
+
type: "tag",
|
|
240
|
+
tagType: "server-control"
|
|
241
|
+
}, t.attributes = h(e[1]), ["CAN-SKIP-UNTIL", "PART-HOLD-BACK", "HOLD-BACK"].forEach(function(u) {
|
|
242
|
+
t.attributes.hasOwnProperty(u) && (t.attributes[u] = parseFloat(t.attributes[u]));
|
|
243
|
+
}), ["CAN-SKIP-DATERANGES", "CAN-BLOCK-RELOAD"].forEach(function(u) {
|
|
244
|
+
t.attributes.hasOwnProperty(u) && (t.attributes[u] = /YES/.test(t.attributes[u]));
|
|
245
|
+
}), this.trigger("data", t);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
if (e = /^#EXT-X-PART-INF:(.*)$/.exec(s), e && e[1]) {
|
|
249
|
+
t = {
|
|
250
|
+
type: "tag",
|
|
251
|
+
tagType: "part-inf"
|
|
252
|
+
}, t.attributes = h(e[1]), ["PART-TARGET"].forEach(function(u) {
|
|
253
|
+
t.attributes.hasOwnProperty(u) && (t.attributes[u] = parseFloat(t.attributes[u]));
|
|
254
|
+
}), this.trigger("data", t);
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
if (e = /^#EXT-X-PRELOAD-HINT:(.*)$/.exec(s), e && e[1]) {
|
|
258
|
+
t = {
|
|
259
|
+
type: "tag",
|
|
260
|
+
tagType: "preload-hint"
|
|
261
|
+
}, t.attributes = h(e[1]), ["BYTERANGE-START", "BYTERANGE-LENGTH"].forEach(function(u) {
|
|
262
|
+
if (t.attributes.hasOwnProperty(u)) {
|
|
263
|
+
t.attributes[u] = parseInt(t.attributes[u], 10);
|
|
264
|
+
const o = u === "BYTERANGE-LENGTH" ? "length" : "offset";
|
|
265
|
+
t.attributes.byterange = t.attributes.byterange || {}, t.attributes.byterange[o] = t.attributes[u], delete t.attributes[u];
|
|
266
|
+
}
|
|
267
|
+
}), this.trigger("data", t);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if (e = /^#EXT-X-RENDITION-REPORT:(.*)$/.exec(s), e && e[1]) {
|
|
271
|
+
t = {
|
|
272
|
+
type: "tag",
|
|
273
|
+
tagType: "rendition-report"
|
|
274
|
+
}, t.attributes = h(e[1]), ["LAST-MSN", "LAST-PART"].forEach(function(u) {
|
|
275
|
+
t.attributes.hasOwnProperty(u) && (t.attributes[u] = parseInt(t.attributes[u], 10));
|
|
276
|
+
}), this.trigger("data", t);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
if (e = /^#EXT-X-DATERANGE:(.*)$/.exec(s), e && e[1]) {
|
|
280
|
+
t = {
|
|
281
|
+
type: "tag",
|
|
282
|
+
tagType: "daterange"
|
|
283
|
+
}, t.attributes = h(e[1]), ["ID", "CLASS"].forEach(function(o) {
|
|
284
|
+
t.attributes.hasOwnProperty(o) && (t.attributes[o] = String(t.attributes[o]));
|
|
285
|
+
}), ["START-DATE", "END-DATE"].forEach(function(o) {
|
|
286
|
+
t.attributes.hasOwnProperty(o) && (t.attributes[o] = new Date(t.attributes[o]));
|
|
287
|
+
}), ["DURATION", "PLANNED-DURATION"].forEach(function(o) {
|
|
288
|
+
t.attributes.hasOwnProperty(o) && (t.attributes[o] = parseFloat(t.attributes[o]));
|
|
289
|
+
}), ["END-ON-NEXT"].forEach(function(o) {
|
|
290
|
+
t.attributes.hasOwnProperty(o) && (t.attributes[o] = /YES/i.test(t.attributes[o]));
|
|
291
|
+
}), ["SCTE35-CMD", " SCTE35-OUT", "SCTE35-IN"].forEach(function(o) {
|
|
292
|
+
t.attributes.hasOwnProperty(o) && (t.attributes[o] = t.attributes[o].toString(16));
|
|
293
|
+
});
|
|
294
|
+
const u = /^X-([A-Z]+-)+[A-Z]+$/;
|
|
295
|
+
for (const o in t.attributes) {
|
|
296
|
+
if (!u.test(o))
|
|
297
|
+
continue;
|
|
298
|
+
const d = /[0-9A-Fa-f]{6}/g.test(t.attributes[o]), R = /^\d+(\.\d+)?$/.test(t.attributes[o]);
|
|
299
|
+
t.attributes[o] = d ? t.attributes[o].toString(16) : R ? parseFloat(t.attributes[o]) : String(t.attributes[o]);
|
|
300
|
+
}
|
|
301
|
+
this.trigger("data", t);
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
if (e = /^#EXT-X-INDEPENDENT-SEGMENTS/.exec(s), e) {
|
|
305
|
+
this.trigger("data", {
|
|
306
|
+
type: "tag",
|
|
307
|
+
tagType: "independent-segments"
|
|
308
|
+
});
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
if (e = /^#EXT-X-I-FRAMES-ONLY/.exec(s), e) {
|
|
312
|
+
this.trigger("data", {
|
|
313
|
+
type: "tag",
|
|
314
|
+
tagType: "i-frames-only"
|
|
315
|
+
});
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
if (e = /^#EXT-X-CONTENT-STEERING:(.*)$/.exec(s), e) {
|
|
319
|
+
t = {
|
|
320
|
+
type: "tag",
|
|
321
|
+
tagType: "content-steering"
|
|
322
|
+
}, t.attributes = h(e[1]), this.trigger("data", t);
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
if (e = /^#EXT-X-I-FRAME-STREAM-INF:(.*)$/.exec(s), e) {
|
|
326
|
+
t = {
|
|
327
|
+
type: "tag",
|
|
328
|
+
tagType: "i-frame-playlist"
|
|
329
|
+
}, t.attributes = h(e[1]), t.attributes.URI && (t.uri = t.attributes.URI), t.attributes.BANDWIDTH && (t.attributes.BANDWIDTH = parseInt(t.attributes.BANDWIDTH, 10)), t.attributes.RESOLUTION && (t.attributes.RESOLUTION = M(t.attributes.RESOLUTION)), t.attributes["AVERAGE-BANDWIDTH"] && (t.attributes["AVERAGE-BANDWIDTH"] = parseInt(t.attributes["AVERAGE-BANDWIDTH"], 10)), t.attributes["FRAME-RATE"] && (t.attributes["FRAME-RATE"] = parseFloat(t.attributes["FRAME-RATE"])), this.trigger("data", t);
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
if (e = /^#EXT-X-DEFINE:(.*)$/.exec(s), e) {
|
|
333
|
+
t = {
|
|
334
|
+
type: "tag",
|
|
335
|
+
tagType: "define"
|
|
336
|
+
}, t.attributes = h(e[1]), this.trigger("data", t);
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
this.trigger("data", {
|
|
340
|
+
type: "tag",
|
|
341
|
+
data: s.slice(4)
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Add a parser for custom headers
|
|
347
|
+
*
|
|
348
|
+
* @param {Object} options a map of options for the added parser
|
|
349
|
+
* @param {RegExp} options.expression a regular expression to match the custom header
|
|
350
|
+
* @param {string} options.customType the custom type to register to the output
|
|
351
|
+
* @param {Function} [options.dataParser] function to parse the line into an object
|
|
352
|
+
* @param {boolean} [options.segment] should tag data be attached to the segment object
|
|
353
|
+
*/
|
|
354
|
+
addParser({
|
|
355
|
+
expression: n,
|
|
356
|
+
customType: e,
|
|
357
|
+
dataParser: t,
|
|
358
|
+
segment: a
|
|
359
|
+
}) {
|
|
360
|
+
typeof t != "function" && (t = (s) => s), this.customParsers.push((s) => {
|
|
361
|
+
if (n.exec(s))
|
|
362
|
+
return this.trigger("data", {
|
|
363
|
+
type: "custom",
|
|
364
|
+
data: t(s),
|
|
365
|
+
customType: e,
|
|
366
|
+
segment: a
|
|
367
|
+
}), !0;
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Add a custom header mapper
|
|
372
|
+
*
|
|
373
|
+
* @param {Object} options
|
|
374
|
+
* @param {RegExp} options.expression a regular expression to match the custom header
|
|
375
|
+
* @param {Function} options.map function to translate tag into a different tag
|
|
376
|
+
*/
|
|
377
|
+
addTagMapper({
|
|
378
|
+
expression: n,
|
|
379
|
+
map: e
|
|
380
|
+
}) {
|
|
381
|
+
const t = (a) => n.test(a) ? e(a) : a;
|
|
382
|
+
this.tagMappers.push(t);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
const F = (f) => f.toLowerCase().replace(/-(\w)/g, (n) => n[1].toUpperCase()), c = function(f) {
|
|
386
|
+
const n = {};
|
|
387
|
+
return Object.keys(f).forEach(function(e) {
|
|
388
|
+
n[F(e)] = f[e];
|
|
389
|
+
}), n;
|
|
390
|
+
}, N = function(f) {
|
|
391
|
+
const {
|
|
392
|
+
serverControl: n,
|
|
393
|
+
targetDuration: e,
|
|
394
|
+
partTargetDuration: t
|
|
395
|
+
} = f;
|
|
396
|
+
if (!n)
|
|
397
|
+
return;
|
|
398
|
+
const a = "#EXT-X-SERVER-CONTROL", s = "holdBack", u = "partHoldBack", o = e && e * 3, d = t && t * 2;
|
|
399
|
+
e && !n.hasOwnProperty(s) && (n[s] = o, this.trigger("info", {
|
|
400
|
+
message: `${a} defaulting HOLD-BACK to targetDuration * 3 (${o}).`
|
|
401
|
+
})), o && n[s] < o && (this.trigger("warn", {
|
|
402
|
+
message: `${a} clamping HOLD-BACK (${n[s]}) to targetDuration * 3 (${o})`
|
|
403
|
+
}), n[s] = o), t && !n.hasOwnProperty(u) && (n[u] = t * 3, this.trigger("info", {
|
|
404
|
+
message: `${a} defaulting PART-HOLD-BACK to partTargetDuration * 3 (${n[u]}).`
|
|
405
|
+
})), t && n[u] < d && (this.trigger("warn", {
|
|
406
|
+
message: `${a} clamping PART-HOLD-BACK (${n[u]}) to partTargetDuration * 2 (${d}).`
|
|
407
|
+
}), n[u] = d);
|
|
408
|
+
};
|
|
409
|
+
class Y extends O {
|
|
410
|
+
constructor(n = {}) {
|
|
411
|
+
super(), this.lineStream = new w(), this.parseStream = new G(), this.lineStream.pipe(this.parseStream), this.mainDefinitions = n.mainDefinitions || {}, this.params = new URL(n.uri, "https://a.com").searchParams, this.lastProgramDateTime = null;
|
|
412
|
+
const e = this, t = [];
|
|
413
|
+
let a = {}, s, u, o = !1;
|
|
414
|
+
const d = function() {
|
|
415
|
+
}, R = {
|
|
416
|
+
AUDIO: {},
|
|
417
|
+
VIDEO: {},
|
|
418
|
+
"CLOSED-CAPTIONS": {},
|
|
419
|
+
SUBTITLES: {}
|
|
420
|
+
}, C = "urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";
|
|
421
|
+
let b = 0;
|
|
422
|
+
this.manifest = {
|
|
423
|
+
allowCache: !0,
|
|
424
|
+
discontinuityStarts: [],
|
|
425
|
+
dateRanges: [],
|
|
426
|
+
iFramePlaylists: [],
|
|
427
|
+
segments: []
|
|
428
|
+
};
|
|
429
|
+
let S = 0, A = 0;
|
|
430
|
+
const l = {};
|
|
431
|
+
this.on("end", () => {
|
|
432
|
+
a.uri || !a.parts && !a.preloadHints || (!a.map && s && (a.map = s), !a.key && u && (a.key = u), !a.timeline && typeof b == "number" && (a.timeline = b), this.manifest.preloadSegment = a);
|
|
433
|
+
}), this.parseStream.on("data", function(i) {
|
|
434
|
+
let P, p;
|
|
435
|
+
if (e.manifest.definitions) {
|
|
436
|
+
for (const g in e.manifest.definitions)
|
|
437
|
+
if (i.uri && (i.uri = i.uri.replace(`{$${g}}`, e.manifest.definitions[g])), i.attributes)
|
|
438
|
+
for (const r in i.attributes)
|
|
439
|
+
typeof i.attributes[r] == "string" && (i.attributes[r] = i.attributes[r].replace(`{$${g}}`, e.manifest.definitions[g]));
|
|
440
|
+
}
|
|
441
|
+
({
|
|
442
|
+
tag() {
|
|
443
|
+
({
|
|
444
|
+
version() {
|
|
445
|
+
i.version && (this.manifest.version = i.version);
|
|
446
|
+
},
|
|
447
|
+
"allow-cache"() {
|
|
448
|
+
this.manifest.allowCache = i.allowed, "allowed" in i || (this.trigger("info", {
|
|
449
|
+
message: "defaulting allowCache to YES"
|
|
450
|
+
}), this.manifest.allowCache = !0);
|
|
451
|
+
},
|
|
452
|
+
byterange() {
|
|
453
|
+
const g = {};
|
|
454
|
+
"length" in i && (a.byterange = g, g.length = i.length, "offset" in i || (i.offset = S)), "offset" in i && (a.byterange = g, g.offset = i.offset), S = g.offset + g.length;
|
|
455
|
+
},
|
|
456
|
+
endlist() {
|
|
457
|
+
this.manifest.endList = !0;
|
|
458
|
+
},
|
|
459
|
+
inf() {
|
|
460
|
+
"mediaSequence" in this.manifest || (this.manifest.mediaSequence = 0, this.trigger("info", {
|
|
461
|
+
message: "defaulting media sequence to zero"
|
|
462
|
+
})), "discontinuitySequence" in this.manifest || (this.manifest.discontinuitySequence = 0, this.trigger("info", {
|
|
463
|
+
message: "defaulting discontinuity sequence to zero"
|
|
464
|
+
})), i.title && (a.title = i.title), i.duration > 0 && (a.duration = i.duration), i.duration === 0 && (a.duration = 0.01, this.trigger("info", {
|
|
465
|
+
message: "updating zero segment duration to a small value"
|
|
466
|
+
})), this.manifest.segments = t;
|
|
467
|
+
},
|
|
468
|
+
key() {
|
|
469
|
+
if (!i.attributes) {
|
|
470
|
+
this.trigger("warn", {
|
|
471
|
+
message: "ignoring key declaration without attribute list"
|
|
472
|
+
});
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
if (i.attributes.METHOD === "NONE") {
|
|
476
|
+
u = null;
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
if (!i.attributes.URI) {
|
|
480
|
+
this.trigger("warn", {
|
|
481
|
+
message: "ignoring key declaration without URI"
|
|
482
|
+
});
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
if (i.attributes.KEYFORMAT === "com.apple.streamingkeydelivery") {
|
|
486
|
+
this.manifest.contentProtection = this.manifest.contentProtection || {}, this.manifest.contentProtection["com.apple.fps.1_0"] = {
|
|
487
|
+
attributes: i.attributes
|
|
488
|
+
};
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
if (i.attributes.KEYFORMAT === "com.microsoft.playready") {
|
|
492
|
+
this.manifest.contentProtection = this.manifest.contentProtection || {}, this.manifest.contentProtection["com.microsoft.playready"] = {
|
|
493
|
+
uri: i.attributes.URI
|
|
494
|
+
};
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
if (i.attributes.KEYFORMAT === C) {
|
|
498
|
+
if (["SAMPLE-AES", "SAMPLE-AES-CTR", "SAMPLE-AES-CENC"].indexOf(i.attributes.METHOD) === -1) {
|
|
499
|
+
this.trigger("warn", {
|
|
500
|
+
message: "invalid key method provided for Widevine"
|
|
501
|
+
});
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
if (i.attributes.METHOD === "SAMPLE-AES-CENC" && this.trigger("warn", {
|
|
505
|
+
message: "SAMPLE-AES-CENC is deprecated, please use SAMPLE-AES-CTR instead"
|
|
506
|
+
}), i.attributes.URI.substring(0, 23) !== "data:text/plain;base64,") {
|
|
507
|
+
this.trigger("warn", {
|
|
508
|
+
message: "invalid key URI provided for Widevine"
|
|
509
|
+
});
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
if (!(i.attributes.KEYID && i.attributes.KEYID.substring(0, 2) === "0x")) {
|
|
513
|
+
this.trigger("warn", {
|
|
514
|
+
message: "invalid key ID provided for Widevine"
|
|
515
|
+
});
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
this.manifest.contentProtection = this.manifest.contentProtection || {}, this.manifest.contentProtection["com.widevine.alpha"] = {
|
|
519
|
+
attributes: {
|
|
520
|
+
schemeIdUri: i.attributes.KEYFORMAT,
|
|
521
|
+
// remove '0x' from the key id string
|
|
522
|
+
keyId: i.attributes.KEYID.substring(2)
|
|
523
|
+
},
|
|
524
|
+
// decode the base64-encoded PSSH box
|
|
525
|
+
pssh: U(i.attributes.URI.split(",")[1])
|
|
526
|
+
};
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
i.attributes.METHOD || this.trigger("warn", {
|
|
530
|
+
message: "defaulting key method to AES-128"
|
|
531
|
+
}), u = {
|
|
532
|
+
method: i.attributes.METHOD || "AES-128",
|
|
533
|
+
uri: i.attributes.URI
|
|
534
|
+
}, typeof i.attributes.IV < "u" && (u.iv = i.attributes.IV);
|
|
535
|
+
},
|
|
536
|
+
"media-sequence"() {
|
|
537
|
+
if (!isFinite(i.number)) {
|
|
538
|
+
this.trigger("warn", {
|
|
539
|
+
message: "ignoring invalid media sequence: " + i.number
|
|
540
|
+
});
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
this.manifest.mediaSequence = i.number;
|
|
544
|
+
},
|
|
545
|
+
"discontinuity-sequence"() {
|
|
546
|
+
if (!isFinite(i.number)) {
|
|
547
|
+
this.trigger("warn", {
|
|
548
|
+
message: "ignoring invalid discontinuity sequence: " + i.number
|
|
549
|
+
});
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
this.manifest.discontinuitySequence = i.number, b = i.number;
|
|
553
|
+
},
|
|
554
|
+
"playlist-type"() {
|
|
555
|
+
if (!/VOD|EVENT/.test(i.playlistType)) {
|
|
556
|
+
this.trigger("warn", {
|
|
557
|
+
message: "ignoring unknown playlist type: " + i.playlist
|
|
558
|
+
});
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
this.manifest.playlistType = i.playlistType;
|
|
562
|
+
},
|
|
563
|
+
map() {
|
|
564
|
+
s = {}, i.uri && (s.uri = i.uri), i.byterange && (s.byterange = i.byterange), u && (s.key = u);
|
|
565
|
+
},
|
|
566
|
+
"stream-inf"() {
|
|
567
|
+
if (this.manifest.playlists = t, this.manifest.mediaGroups = this.manifest.mediaGroups || R, !i.attributes) {
|
|
568
|
+
this.trigger("warn", {
|
|
569
|
+
message: "ignoring empty stream-inf attributes"
|
|
570
|
+
});
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
a.attributes || (a.attributes = {}), I(a.attributes, i.attributes);
|
|
574
|
+
},
|
|
575
|
+
media() {
|
|
576
|
+
if (this.manifest.mediaGroups = this.manifest.mediaGroups || R, !(i.attributes && i.attributes.TYPE && i.attributes["GROUP-ID"] && i.attributes.NAME)) {
|
|
577
|
+
this.trigger("warn", {
|
|
578
|
+
message: "ignoring incomplete or missing media group"
|
|
579
|
+
});
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
const g = this.manifest.mediaGroups[i.attributes.TYPE];
|
|
583
|
+
g[i.attributes["GROUP-ID"]] = g[i.attributes["GROUP-ID"]] || {}, P = g[i.attributes["GROUP-ID"]], p = {
|
|
584
|
+
default: /yes/i.test(i.attributes.DEFAULT)
|
|
585
|
+
}, p.default ? p.autoselect = !0 : p.autoselect = /yes/i.test(i.attributes.AUTOSELECT), i.attributes.LANGUAGE && (p.language = i.attributes.LANGUAGE), i.attributes.URI && (p.uri = i.attributes.URI), i.attributes["INSTREAM-ID"] && (p.instreamId = i.attributes["INSTREAM-ID"]), i.attributes.CHARACTERISTICS && (p.characteristics = i.attributes.CHARACTERISTICS), i.attributes.FORCED && (p.forced = /yes/i.test(i.attributes.FORCED)), P[i.attributes.NAME] = p;
|
|
586
|
+
},
|
|
587
|
+
discontinuity() {
|
|
588
|
+
b += 1, a.discontinuity = !0, this.manifest.discontinuityStarts.push(t.length);
|
|
589
|
+
},
|
|
590
|
+
"program-date-time"() {
|
|
591
|
+
typeof this.manifest.dateTimeString > "u" && (this.manifest.dateTimeString = i.dateTimeString, this.manifest.dateTimeObject = i.dateTimeObject), a.dateTimeString = i.dateTimeString, a.dateTimeObject = i.dateTimeObject;
|
|
592
|
+
const {
|
|
593
|
+
lastProgramDateTime: g
|
|
594
|
+
} = this;
|
|
595
|
+
this.lastProgramDateTime = new Date(i.dateTimeString).getTime(), g === null && this.manifest.segments.reduceRight((r, E) => (E.programDateTime = r - E.duration * 1e3, E.programDateTime), this.lastProgramDateTime);
|
|
596
|
+
},
|
|
597
|
+
targetduration() {
|
|
598
|
+
if (!isFinite(i.duration) || i.duration < 0) {
|
|
599
|
+
this.trigger("warn", {
|
|
600
|
+
message: "ignoring invalid target duration: " + i.duration
|
|
601
|
+
});
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
this.manifest.targetDuration = i.duration, N.call(this, this.manifest);
|
|
605
|
+
},
|
|
606
|
+
start() {
|
|
607
|
+
if (!i.attributes || isNaN(i.attributes["TIME-OFFSET"])) {
|
|
608
|
+
this.trigger("warn", {
|
|
609
|
+
message: "ignoring start declaration without appropriate attribute list"
|
|
610
|
+
});
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
this.manifest.start = {
|
|
614
|
+
timeOffset: i.attributes["TIME-OFFSET"],
|
|
615
|
+
precise: i.attributes.PRECISE
|
|
616
|
+
};
|
|
617
|
+
},
|
|
618
|
+
"cue-out"() {
|
|
619
|
+
a.cueOut = i.data;
|
|
620
|
+
},
|
|
621
|
+
"cue-out-cont"() {
|
|
622
|
+
a.cueOutCont = i.data;
|
|
623
|
+
},
|
|
624
|
+
"cue-in"() {
|
|
625
|
+
a.cueIn = i.data;
|
|
626
|
+
},
|
|
627
|
+
skip() {
|
|
628
|
+
this.manifest.skip = c(i.attributes), this.warnOnMissingAttributes_("#EXT-X-SKIP", i.attributes, ["SKIPPED-SEGMENTS"]);
|
|
629
|
+
},
|
|
630
|
+
part() {
|
|
631
|
+
o = !0;
|
|
632
|
+
const g = this.manifest.segments.length, r = c(i.attributes);
|
|
633
|
+
a.parts = a.parts || [], a.parts.push(r), r.byterange && (r.byterange.hasOwnProperty("offset") || (r.byterange.offset = A), A = r.byterange.offset + r.byterange.length);
|
|
634
|
+
const E = a.parts.length - 1;
|
|
635
|
+
this.warnOnMissingAttributes_(`#EXT-X-PART #${E} for segment #${g}`, i.attributes, ["URI", "DURATION"]), this.manifest.renditionReports && this.manifest.renditionReports.forEach((m, T) => {
|
|
636
|
+
m.hasOwnProperty("lastPart") || this.trigger("warn", {
|
|
637
|
+
message: `#EXT-X-RENDITION-REPORT #${T} lacks required attribute(s): LAST-PART`
|
|
638
|
+
});
|
|
639
|
+
});
|
|
640
|
+
},
|
|
641
|
+
"server-control"() {
|
|
642
|
+
const g = this.manifest.serverControl = c(i.attributes);
|
|
643
|
+
g.hasOwnProperty("canBlockReload") || (g.canBlockReload = !1, this.trigger("info", {
|
|
644
|
+
message: "#EXT-X-SERVER-CONTROL defaulting CAN-BLOCK-RELOAD to false"
|
|
645
|
+
})), N.call(this, this.manifest), g.canSkipDateranges && !g.hasOwnProperty("canSkipUntil") && this.trigger("warn", {
|
|
646
|
+
message: "#EXT-X-SERVER-CONTROL lacks required attribute CAN-SKIP-UNTIL which is required when CAN-SKIP-DATERANGES is set"
|
|
647
|
+
});
|
|
648
|
+
},
|
|
649
|
+
"preload-hint"() {
|
|
650
|
+
const g = this.manifest.segments.length, r = c(i.attributes), E = r.type && r.type === "PART";
|
|
651
|
+
a.preloadHints = a.preloadHints || [], a.preloadHints.push(r), r.byterange && (r.byterange.hasOwnProperty("offset") || (r.byterange.offset = E ? A : 0, E && (A = r.byterange.offset + r.byterange.length)));
|
|
652
|
+
const m = a.preloadHints.length - 1;
|
|
653
|
+
if (this.warnOnMissingAttributes_(`#EXT-X-PRELOAD-HINT #${m} for segment #${g}`, i.attributes, ["TYPE", "URI"]), !!r.type)
|
|
654
|
+
for (let T = 0; T < a.preloadHints.length - 1; T++) {
|
|
655
|
+
const X = a.preloadHints[T];
|
|
656
|
+
X.type && X.type === r.type && this.trigger("warn", {
|
|
657
|
+
message: `#EXT-X-PRELOAD-HINT #${m} for segment #${g} has the same TYPE ${r.type} as preload hint #${T}`
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
},
|
|
661
|
+
"rendition-report"() {
|
|
662
|
+
const g = c(i.attributes);
|
|
663
|
+
this.manifest.renditionReports = this.manifest.renditionReports || [], this.manifest.renditionReports.push(g);
|
|
664
|
+
const r = this.manifest.renditionReports.length - 1, E = ["LAST-MSN", "URI"];
|
|
665
|
+
o && E.push("LAST-PART"), this.warnOnMissingAttributes_(`#EXT-X-RENDITION-REPORT #${r}`, i.attributes, E);
|
|
666
|
+
},
|
|
667
|
+
"part-inf"() {
|
|
668
|
+
this.manifest.partInf = c(i.attributes), this.warnOnMissingAttributes_("#EXT-X-PART-INF", i.attributes, ["PART-TARGET"]), this.manifest.partInf.partTarget && (this.manifest.partTargetDuration = this.manifest.partInf.partTarget), N.call(this, this.manifest);
|
|
669
|
+
},
|
|
670
|
+
daterange() {
|
|
671
|
+
this.manifest.dateRanges.push(c(i.attributes));
|
|
672
|
+
const g = this.manifest.dateRanges.length - 1;
|
|
673
|
+
this.warnOnMissingAttributes_(`#EXT-X-DATERANGE #${g}`, i.attributes, ["ID", "START-DATE"]);
|
|
674
|
+
const r = this.manifest.dateRanges[g];
|
|
675
|
+
r.endDate && r.startDate && new Date(r.endDate) < new Date(r.startDate) && this.trigger("warn", {
|
|
676
|
+
message: "EXT-X-DATERANGE END-DATE must be equal to or later than the value of the START-DATE"
|
|
677
|
+
}), r.duration && r.duration < 0 && this.trigger("warn", {
|
|
678
|
+
message: "EXT-X-DATERANGE DURATION must not be negative"
|
|
679
|
+
}), r.plannedDuration && r.plannedDuration < 0 && this.trigger("warn", {
|
|
680
|
+
message: "EXT-X-DATERANGE PLANNED-DURATION must not be negative"
|
|
681
|
+
});
|
|
682
|
+
const E = !!r.endOnNext;
|
|
683
|
+
if (E && !r.class && this.trigger("warn", {
|
|
684
|
+
message: "EXT-X-DATERANGE with an END-ON-NEXT=YES attribute must have a CLASS attribute"
|
|
685
|
+
}), E && (r.duration || r.endDate) && this.trigger("warn", {
|
|
686
|
+
message: "EXT-X-DATERANGE with an END-ON-NEXT=YES attribute must not contain DURATION or END-DATE attributes"
|
|
687
|
+
}), r.duration && r.endDate) {
|
|
688
|
+
const T = r.startDate.getTime() + r.duration * 1e3;
|
|
689
|
+
this.manifest.dateRanges[g].endDate = new Date(T);
|
|
690
|
+
}
|
|
691
|
+
if (!l[r.id])
|
|
692
|
+
l[r.id] = r;
|
|
693
|
+
else {
|
|
694
|
+
for (const T in l[r.id])
|
|
695
|
+
if (r[T] && JSON.stringify(l[r.id][T]) !== JSON.stringify(r[T])) {
|
|
696
|
+
this.trigger("warn", {
|
|
697
|
+
message: "EXT-X-DATERANGE tags with the same ID in a playlist must have the same attributes values"
|
|
698
|
+
});
|
|
699
|
+
break;
|
|
700
|
+
}
|
|
701
|
+
const m = this.manifest.dateRanges.findIndex((T) => T.id === r.id);
|
|
702
|
+
this.manifest.dateRanges[m] = I(this.manifest.dateRanges[m], r), l[r.id] = I(l[r.id], r), this.manifest.dateRanges.pop();
|
|
703
|
+
}
|
|
704
|
+
},
|
|
705
|
+
"independent-segments"() {
|
|
706
|
+
this.manifest.independentSegments = !0;
|
|
707
|
+
},
|
|
708
|
+
"i-frames-only"() {
|
|
709
|
+
this.manifest.iFramesOnly = !0, this.requiredCompatibilityversion(this.manifest.version, 4);
|
|
710
|
+
},
|
|
711
|
+
"content-steering"() {
|
|
712
|
+
this.manifest.contentSteering = c(i.attributes), this.warnOnMissingAttributes_("#EXT-X-CONTENT-STEERING", i.attributes, ["SERVER-URI"]);
|
|
713
|
+
},
|
|
714
|
+
/** @this {Parser} */
|
|
715
|
+
define() {
|
|
716
|
+
this.manifest.definitions = this.manifest.definitions || {};
|
|
717
|
+
const g = (r, E) => {
|
|
718
|
+
if (r in this.manifest.definitions) {
|
|
719
|
+
this.trigger("error", {
|
|
720
|
+
message: `EXT-X-DEFINE: Duplicate name ${r}`
|
|
721
|
+
});
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
this.manifest.definitions[r] = E;
|
|
725
|
+
};
|
|
726
|
+
if ("QUERYPARAM" in i.attributes) {
|
|
727
|
+
if ("NAME" in i.attributes || "IMPORT" in i.attributes) {
|
|
728
|
+
this.trigger("error", {
|
|
729
|
+
message: "EXT-X-DEFINE: Invalid attributes"
|
|
730
|
+
});
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
const r = this.params.get(i.attributes.QUERYPARAM);
|
|
734
|
+
if (!r) {
|
|
735
|
+
this.trigger("error", {
|
|
736
|
+
message: `EXT-X-DEFINE: No query param ${i.attributes.QUERYPARAM}`
|
|
737
|
+
});
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
g(i.attributes.QUERYPARAM, decodeURIComponent(r));
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
if ("NAME" in i.attributes) {
|
|
744
|
+
if ("IMPORT" in i.attributes) {
|
|
745
|
+
this.trigger("error", {
|
|
746
|
+
message: "EXT-X-DEFINE: Invalid attributes"
|
|
747
|
+
});
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
if (!("VALUE" in i.attributes) || typeof i.attributes.VALUE != "string") {
|
|
751
|
+
this.trigger("error", {
|
|
752
|
+
message: `EXT-X-DEFINE: No value for ${i.attributes.NAME}`
|
|
753
|
+
});
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
g(i.attributes.NAME, i.attributes.VALUE);
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
if ("IMPORT" in i.attributes) {
|
|
760
|
+
if (!this.mainDefinitions[i.attributes.IMPORT]) {
|
|
761
|
+
this.trigger("error", {
|
|
762
|
+
message: `EXT-X-DEFINE: No value ${i.attributes.IMPORT} to import, or IMPORT used on main playlist`
|
|
763
|
+
});
|
|
764
|
+
return;
|
|
765
|
+
}
|
|
766
|
+
g(i.attributes.IMPORT, this.mainDefinitions[i.attributes.IMPORT]);
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
this.trigger("error", {
|
|
770
|
+
message: "EXT-X-DEFINE: No attribute"
|
|
771
|
+
});
|
|
772
|
+
},
|
|
773
|
+
"i-frame-playlist"() {
|
|
774
|
+
this.manifest.iFramePlaylists.push({
|
|
775
|
+
attributes: i.attributes,
|
|
776
|
+
uri: i.uri,
|
|
777
|
+
timeline: b
|
|
778
|
+
}), this.warnOnMissingAttributes_("#EXT-X-I-FRAME-STREAM-INF", i.attributes, ["BANDWIDTH", "URI"]);
|
|
779
|
+
}
|
|
780
|
+
}[i.tagType] || d).call(e);
|
|
781
|
+
},
|
|
782
|
+
uri() {
|
|
783
|
+
a.uri = i.uri, t.push(a), this.manifest.targetDuration && !("duration" in a) && (this.trigger("warn", {
|
|
784
|
+
message: "defaulting segment duration to the target duration"
|
|
785
|
+
}), a.duration = this.manifest.targetDuration), u && (a.key = u), a.timeline = b, s && (a.map = s), A = 0, this.lastProgramDateTime !== null && (a.programDateTime = this.lastProgramDateTime, this.lastProgramDateTime += a.duration * 1e3), a = {};
|
|
786
|
+
},
|
|
787
|
+
comment() {
|
|
788
|
+
},
|
|
789
|
+
custom() {
|
|
790
|
+
i.segment ? (a.custom = a.custom || {}, a.custom[i.customType] = i.data) : (this.manifest.custom = this.manifest.custom || {}, this.manifest.custom[i.customType] = i.data);
|
|
791
|
+
}
|
|
792
|
+
})[i.type].call(e);
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
requiredCompatibilityversion(n, e) {
|
|
796
|
+
(n < e || !n) && this.trigger("warn", {
|
|
797
|
+
message: `manifest must be at least version ${e}`
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
warnOnMissingAttributes_(n, e, t) {
|
|
801
|
+
const a = [];
|
|
802
|
+
t.forEach(function(s) {
|
|
803
|
+
e.hasOwnProperty(s) || a.push(s);
|
|
804
|
+
}), a.length && this.trigger("warn", {
|
|
805
|
+
message: `${n} lacks required attribute(s): ${a.join(", ")}`
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* Parse the input string and update the manifest object.
|
|
810
|
+
*
|
|
811
|
+
* @param {string} chunk a potentially incomplete portion of the manifest
|
|
812
|
+
*/
|
|
813
|
+
push(n) {
|
|
814
|
+
this.lineStream.push(n);
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* Flush any remaining input. This can be handy if the last line of an M3U8
|
|
818
|
+
* manifest did not contain a trailing newline but the file has been
|
|
819
|
+
* completely received.
|
|
820
|
+
*/
|
|
821
|
+
end() {
|
|
822
|
+
this.lineStream.push(`
|
|
823
|
+
`), this.manifest.dateRanges.length && this.lastProgramDateTime === null && this.trigger("warn", {
|
|
824
|
+
message: "A playlist with EXT-X-DATERANGE tag must contain atleast one EXT-X-PROGRAM-DATE-TIME tag"
|
|
825
|
+
}), this.lastProgramDateTime = null, this.trigger("end");
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* Add an additional parser for non-standard tags
|
|
829
|
+
*
|
|
830
|
+
* @param {Object} options a map of options for the added parser
|
|
831
|
+
* @param {RegExp} options.expression a regular expression to match the custom header
|
|
832
|
+
* @param {string} options.customType the custom type to register to the output
|
|
833
|
+
* @param {Function} [options.dataParser] function to parse the line into an object
|
|
834
|
+
* @param {boolean} [options.segment] should tag data be attached to the segment object
|
|
835
|
+
*/
|
|
836
|
+
addParser(n) {
|
|
837
|
+
this.parseStream.addParser(n);
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* Add a custom header mapper
|
|
841
|
+
*
|
|
842
|
+
* @param {Object} options
|
|
843
|
+
* @param {RegExp} options.expression a regular expression to match the custom header
|
|
844
|
+
* @param {Function} options.map function to translate tag into a different tag
|
|
845
|
+
*/
|
|
846
|
+
addTagMapper(n) {
|
|
847
|
+
this.parseStream.addTagMapper(n);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
export {
|
|
851
|
+
w as LineStream,
|
|
852
|
+
G as ParseStream,
|
|
853
|
+
Y as Parser
|
|
854
|
+
};
|
|
855
|
+
//# sourceMappingURL=m3u8-parser.es.js.map
|