@svta/cml-dash 1.0.8 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -22,10 +22,11 @@ const result = processUriTemplate(
22
22
  3, // Bandwidth
23
23
  4 // Time
24
24
  );
25
-
26
- assert(result === "http://example.com/rep1/1/2/3/04/$");
25
+ console.log(result);
26
+ // http://example.com/rep1/1/2/3/04/$
27
27
 
28
28
  // Parse frame rate
29
29
  const frameRate = parseFrameRate("24000/1001");
30
- assert(frameRate === 23.976023976023978);
30
+ console.log(frameRate);
31
+ // 23.976023976023978
31
32
  ```
package/dist/index.d.ts CHANGED
@@ -1,44 +1,43 @@
1
1
  //#region src/parseFrameRate.d.ts
2
2
  /**
3
- * Parses a DASH framerate string into a number.
4
- *
5
- * @param frameRate - The frame rate string to parse.
6
- * @returns The frame rate as a number.
7
- *
8
- * @public
9
- *
10
- * @example
11
- * {@includeCode ../test/parseFrameRate.test.ts#example}
12
- */
13
- declare function parseFrameRate(frameRate: string): number;
3
+ * Parses a DASH framerate string into a number.
4
+ *
5
+ * @param frameRate - The frame rate string to parse.
6
+ * @returns The frame rate as a number.
7
+ *
8
+ * @public
9
+ *
10
+ * @example
11
+ * {@includeCode ../test/parseFrameRate.test.ts#example}
12
+ */
13
+ export declare function parseFrameRate(frameRate: string): number;
14
14
  //#endregion
15
15
  //#region src/processUriTemplate.d.ts
16
16
  /**
17
- * Process a URI template used in `SegmentTemplate` nodes.
18
- *
19
- * @param uriTemplate - URI template to process.
20
- * @param representationId - Representation ID.
21
- * @param number - Number.
22
- * @param subNumber - Sub-number.
23
- * @param bandwidth - Bandwidth.
24
- * @param time - Time. Should be passed as a number unless the value is larger than `MAX_SAFE_INTEGER`, then it should be provided as a string. If the value is a string all format tags will be ignored.
25
- *
26
- * @returns Processed URI template.
27
- *
28
- * @public
29
- *
30
- * @example
31
- * {@includeCode ../test/processUriTemplate.test.ts#example}
32
- */
33
- declare function processUriTemplate(uriTemplate: string, representationId: string | null | undefined, number: number | null | undefined, subNumber: number | null | undefined, bandwidth: number | null | undefined, time: string | number | null | undefined): string;
17
+ * Process a URI template used in `SegmentTemplate` nodes.
18
+ *
19
+ * @param uriTemplate - URI template to process.
20
+ * @param representationId - Representation ID.
21
+ * @param number - Number.
22
+ * @param subNumber - Sub-number.
23
+ * @param bandwidth - Bandwidth.
24
+ * @param time - Time. Should be passed as a number unless the value is larger than `MAX_SAFE_INTEGER`, then it should be provided as a string. If the value is a string all format tags will be ignored.
25
+ *
26
+ * @returns Processed URI template.
27
+ *
28
+ * @public
29
+ *
30
+ * @example
31
+ * {@includeCode ../test/processUriTemplate.test.ts#example}
32
+ */
33
+ export declare function processUriTemplate(uriTemplate: string, representationId: string | null | undefined, number: number | null | undefined, subNumber: number | null | undefined, bandwidth: number | null | undefined, time: string | number | null | undefined): string;
34
34
  //#endregion
35
35
  //#region src/THUMBNAIL_TILE_SCHEME_ID_URI.d.ts
36
36
  /**
37
- * The scheme ID URI for thumbnail tiles in DASH.
38
- *
39
- * @public
40
- */
41
- declare const THUMBNAIL_TILE_SCHEME_ID_URI = "http://dashif.org/guidelines/thumbnail_tile";
37
+ * The scheme ID URI for thumbnail tiles in DASH.
38
+ *
39
+ * @public
40
+ */
41
+ export declare const THUMBNAIL_TILE_SCHEME_ID_URI = "http://dashif.org/guidelines/thumbnail_tile";
42
42
  //#endregion
43
- export { THUMBNAIL_TILE_SCHEME_ID_URI, parseFrameRate, processUriTemplate };
44
43
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/parseFrameRate.ts","../src/processUriTemplate.ts","../src/THUMBNAIL_TILE_SCHEME_ID_URI.ts"],"sourcesContent":[],"mappings":";;AAWA;;;;ACQA;;;;ACdA;;iBFMgB,cAAA;;;;AAAhB;;;;ACQA;;;;ACdA;;;;;;;;iBDcgB,kBAAA;;;;ADRhB;;;;ACQgB,cCdH,4BAAA,GDcG,6CAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/parseFrameRate.ts","../src/processUriTemplate.ts","../src/THUMBNAIL_TILE_SCHEME_ID_URI.ts"],"mappings":";;;;;;;;;;;;wBAWgB,eAAe;;;;;;;;;;;;;;;;;;;;wBCQf,mBACf,qBACA,6CACA,mCACA,sCACA,sCACA;;;;;;;;qBCpBY"}
package/dist/index.js CHANGED
@@ -16,7 +16,6 @@ function parseFrameRate(frameRate) {
16
16
  if (isNaN(numerator) || isNaN(denominator) || denominator === 0) return NaN;
17
17
  return numerator / denominator;
18
18
  }
19
-
20
19
  //#endregion
21
20
  //#region src/processUriTemplate.ts
22
21
  const TOKENS = /\$(RepresentationID|Number|SubNumber|Bandwidth|Time)?(?:%0([0-9]+)([diouxX]))?\$/g;
@@ -78,15 +77,12 @@ function processUriTemplate(uriTemplate, representationId, number, subNumber, ba
78
77
  case "X":
79
78
  valueString = value.toString(16).toUpperCase();
80
79
  break;
81
- default:
82
- valueString = value.toString();
83
- break;
80
+ default: valueString = value.toString();
84
81
  }
85
82
  const width = parseInt(widthStr, 10) || 1;
86
83
  return valueString.padStart(width, "0");
87
84
  });
88
85
  }
89
-
90
86
  //#endregion
91
87
  //#region src/THUMBNAIL_TILE_SCHEME_ID_URI.ts
92
88
  /**
@@ -95,7 +91,7 @@ function processUriTemplate(uriTemplate, representationId, number, subNumber, ba
95
91
  * @public
96
92
  */
97
93
  const THUMBNAIL_TILE_SCHEME_ID_URI = "http://dashif.org/guidelines/thumbnail_tile";
98
-
99
94
  //#endregion
100
95
  export { THUMBNAIL_TILE_SCHEME_ID_URI, parseFrameRate, processUriTemplate };
96
+
101
97
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["value: string | number | null | undefined","valueString: string"],"sources":["../src/parseFrameRate.ts","../src/processUriTemplate.ts","../src/THUMBNAIL_TILE_SCHEME_ID_URI.ts"],"sourcesContent":["/**\n * Parses a DASH framerate string into a number.\n *\n * @param frameRate - The frame rate string to parse.\n * @returns The frame rate as a number.\n *\n * @public\n *\n * @example\n * {@includeCode ../test/parseFrameRate.test.ts#example}\n */\nexport function parseFrameRate(frameRate: string): number {\n\tconst [numerator, denominator] = frameRate.split('/').map(value => parseInt(value, 10))\n\n\tif (denominator === undefined) {\n\t\treturn numerator\n\t}\n\n\tif (isNaN(numerator) || isNaN(denominator) || denominator === 0) {\n\t\treturn NaN\n\t}\n\n\treturn numerator / denominator\n}\n","const TOKENS = /\\$(RepresentationID|Number|SubNumber|Bandwidth|Time)?(?:%0([0-9]+)([diouxX]))?\\$/g\n\n/**\n * Process a URI template used in `SegmentTemplate` nodes.\n *\n * @param uriTemplate - URI template to process.\n * @param representationId - Representation ID.\n * @param number - Number.\n * @param subNumber - Sub-number.\n * @param bandwidth - Bandwidth.\n * @param time - Time. Should be passed as a number unless the value is larger than `MAX_SAFE_INTEGER`, then it should be provided as a string. If the value is a string all format tags will be ignored.\n *\n * @returns Processed URI template.\n *\n * @public\n *\n * @example\n * {@includeCode ../test/processUriTemplate.test.ts#example}\n */\nexport function processUriTemplate(\n\turiTemplate: string,\n\trepresentationId: string | null | undefined,\n\tnumber: number | null | undefined,\n\tsubNumber: number | null | undefined,\n\tbandwidth: number | null | undefined,\n\ttime: string | number | null | undefined,\n): string {\n\tconst uri = uriTemplate.replace(TOKENS, (match, name, widthStr, format) => {\n\t\tlet value: string | number | null | undefined\n\n\t\tswitch (name) {\n\t\t\tcase undefined: // $$ case\n\t\t\t\treturn '$'\n\n\t\t\tcase 'RepresentationID':\n\t\t\t\tvalue = representationId\n\t\t\t\tbreak\n\n\t\t\tcase 'Number':\n\t\t\t\tvalue = number\n\t\t\t\tbreak\n\n\t\t\tcase 'SubNumber':\n\t\t\t\tvalue = subNumber\n\t\t\t\tbreak\n\n\t\t\tcase 'Bandwidth':\n\t\t\t\tvalue = bandwidth\n\t\t\t\tbreak\n\n\t\t\tcase 'Time':\n\t\t\t\tif (typeof time === 'string') {\n\t\t\t\t\treturn time\n\t\t\t\t}\n\n\t\t\t\tvalue = time ? Math.round(time) : time\n\t\t\t\tbreak\n\n\t\t\tdefault:\n\t\t\t\tvalue = null\n\t\t}\n\n\t\tif (value == null) {\n\t\t\treturn match\n\t\t}\n\n\t\tlet valueString: string\n\n\t\tswitch (format) {\n\t\t\tcase undefined: // Happens if there is no format specifier.\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\tvalueString = value.toString()\n\t\t\t\tbreak\n\n\t\t\tcase 'o':\n\t\t\t\tvalueString = value.toString(8)\n\t\t\t\tbreak\n\n\t\t\tcase 'x':\n\t\t\t\tvalueString = value.toString(16)\n\t\t\t\tbreak\n\n\t\t\tcase 'X':\n\t\t\t\tvalueString = value.toString(16).toUpperCase()\n\t\t\t\tbreak\n\n\t\t\tdefault:\n\t\t\t\tvalueString = value.toString()\n\t\t\t\tbreak\n\t\t}\n\n\t\tconst width = parseInt(widthStr, 10) || 1\n\t\treturn valueString.padStart(width, '0')\n\t})\n\n\treturn uri\n}\n","/**\n * The scheme ID URI for thumbnail tiles in DASH.\n *\n * @public\n */\nexport const THUMBNAIL_TILE_SCHEME_ID_URI = 'http://dashif.org/guidelines/thumbnail_tile'\n"],"mappings":";;;;;;;;;;;;AAWA,SAAgB,eAAe,WAA2B;CACzD,MAAM,CAAC,WAAW,eAAe,UAAU,MAAM,IAAI,CAAC,KAAI,UAAS,SAAS,OAAO,GAAG,CAAC;AAEvF,KAAI,gBAAgB,OACnB,QAAO;AAGR,KAAI,MAAM,UAAU,IAAI,MAAM,YAAY,IAAI,gBAAgB,EAC7D,QAAO;AAGR,QAAO,YAAY;;;;;ACtBpB,MAAM,SAAS;;;;;;;;;;;;;;;;;;AAmBf,SAAgB,mBACf,aACA,kBACA,QACA,WACA,WACA,MACS;AAuET,QAtEY,YAAY,QAAQ,SAAS,OAAO,MAAM,UAAU,WAAW;EAC1E,IAAIA;AAEJ,UAAQ,MAAR;GACC,KAAK,OACJ,QAAO;GAER,KAAK;AACJ,YAAQ;AACR;GAED,KAAK;AACJ,YAAQ;AACR;GAED,KAAK;AACJ,YAAQ;AACR;GAED,KAAK;AACJ,YAAQ;AACR;GAED,KAAK;AACJ,QAAI,OAAO,SAAS,SACnB,QAAO;AAGR,YAAQ,OAAO,KAAK,MAAM,KAAK,GAAG;AAClC;GAED,QACC,SAAQ;;AAGV,MAAI,SAAS,KACZ,QAAO;EAGR,IAAIC;AAEJ,UAAQ,QAAR;GACC,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;AACJ,kBAAc,MAAM,UAAU;AAC9B;GAED,KAAK;AACJ,kBAAc,MAAM,SAAS,EAAE;AAC/B;GAED,KAAK;AACJ,kBAAc,MAAM,SAAS,GAAG;AAChC;GAED,KAAK;AACJ,kBAAc,MAAM,SAAS,GAAG,CAAC,aAAa;AAC9C;GAED;AACC,kBAAc,MAAM,UAAU;AAC9B;;EAGF,MAAM,QAAQ,SAAS,UAAU,GAAG,IAAI;AACxC,SAAO,YAAY,SAAS,OAAO,IAAI;GACtC;;;;;;;;;;AC1FH,MAAa,+BAA+B"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/parseFrameRate.ts","../src/processUriTemplate.ts","../src/THUMBNAIL_TILE_SCHEME_ID_URI.ts"],"sourcesContent":["/**\n * Parses a DASH framerate string into a number.\n *\n * @param frameRate - The frame rate string to parse.\n * @returns The frame rate as a number.\n *\n * @public\n *\n * @example\n * {@includeCode ../test/parseFrameRate.test.ts#example}\n */\nexport function parseFrameRate(frameRate: string): number {\n\tconst [numerator, denominator] = frameRate.split('/').map(value => parseInt(value, 10))\n\n\tif (denominator === undefined) {\n\t\treturn numerator\n\t}\n\n\tif (isNaN(numerator) || isNaN(denominator) || denominator === 0) {\n\t\treturn NaN\n\t}\n\n\treturn numerator / denominator\n}\n","const TOKENS = /\\$(RepresentationID|Number|SubNumber|Bandwidth|Time)?(?:%0([0-9]+)([diouxX]))?\\$/g\n\n/**\n * Process a URI template used in `SegmentTemplate` nodes.\n *\n * @param uriTemplate - URI template to process.\n * @param representationId - Representation ID.\n * @param number - Number.\n * @param subNumber - Sub-number.\n * @param bandwidth - Bandwidth.\n * @param time - Time. Should be passed as a number unless the value is larger than `MAX_SAFE_INTEGER`, then it should be provided as a string. If the value is a string all format tags will be ignored.\n *\n * @returns Processed URI template.\n *\n * @public\n *\n * @example\n * {@includeCode ../test/processUriTemplate.test.ts#example}\n */\nexport function processUriTemplate(\n\turiTemplate: string,\n\trepresentationId: string | null | undefined,\n\tnumber: number | null | undefined,\n\tsubNumber: number | null | undefined,\n\tbandwidth: number | null | undefined,\n\ttime: string | number | null | undefined,\n): string {\n\tconst uri = uriTemplate.replace(TOKENS, (match, name, widthStr, format) => {\n\t\tlet value: string | number | null | undefined\n\n\t\tswitch (name) {\n\t\t\tcase undefined: // $$ case\n\t\t\t\treturn '$'\n\n\t\t\tcase 'RepresentationID':\n\t\t\t\tvalue = representationId\n\t\t\t\tbreak\n\n\t\t\tcase 'Number':\n\t\t\t\tvalue = number\n\t\t\t\tbreak\n\n\t\t\tcase 'SubNumber':\n\t\t\t\tvalue = subNumber\n\t\t\t\tbreak\n\n\t\t\tcase 'Bandwidth':\n\t\t\t\tvalue = bandwidth\n\t\t\t\tbreak\n\n\t\t\tcase 'Time':\n\t\t\t\tif (typeof time === 'string') {\n\t\t\t\t\treturn time\n\t\t\t\t}\n\n\t\t\t\tvalue = time ? Math.round(time) : time\n\t\t\t\tbreak\n\n\t\t\tdefault:\n\t\t\t\tvalue = null\n\t\t}\n\n\t\tif (value == null) {\n\t\t\treturn match\n\t\t}\n\n\t\tlet valueString: string\n\n\t\tswitch (format) {\n\t\t\tcase undefined: // Happens if there is no format specifier.\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\tvalueString = value.toString()\n\t\t\t\tbreak\n\n\t\t\tcase 'o':\n\t\t\t\tvalueString = value.toString(8)\n\t\t\t\tbreak\n\n\t\t\tcase 'x':\n\t\t\t\tvalueString = value.toString(16)\n\t\t\t\tbreak\n\n\t\t\tcase 'X':\n\t\t\t\tvalueString = value.toString(16).toUpperCase()\n\t\t\t\tbreak\n\n\t\t\tdefault:\n\t\t\t\tvalueString = value.toString()\n\t\t\t\tbreak\n\t\t}\n\n\t\tconst width = parseInt(widthStr, 10) || 1\n\t\treturn valueString.padStart(width, '0')\n\t})\n\n\treturn uri\n}\n","/**\n * The scheme ID URI for thumbnail tiles in DASH.\n *\n * @public\n */\nexport const THUMBNAIL_TILE_SCHEME_ID_URI = 'http://dashif.org/guidelines/thumbnail_tile'\n"],"mappings":";;;;;;;;;;;;AAWA,SAAgB,eAAe,WAA2B;CACzD,MAAM,CAAC,WAAW,eAAe,UAAU,MAAM,GAAG,CAAC,CAAC,KAAI,UAAS,SAAS,OAAO,EAAE,CAAC;CAEtF,IAAI,gBAAgB,KAAA,GACnB,OAAO;CAGR,IAAI,MAAM,SAAS,KAAK,MAAM,WAAW,KAAK,gBAAgB,GAC7D,OAAO;CAGR,OAAO,YAAY;AACpB;;;ACvBA,MAAM,SAAS;;;;;;;;;;;;;;;;;;AAmBf,SAAgB,mBACf,aACA,kBACA,QACA,WACA,WACA,MACS;CAuET,OAtEY,YAAY,QAAQ,SAAS,OAAO,MAAM,UAAU,WAAW;EAC1E,IAAI;EAEJ,QAAQ,MAAR;GACC,KAAK,KAAA,GACJ,OAAO;GAER,KAAK;IACJ,QAAQ;IACR;GAED,KAAK;IACJ,QAAQ;IACR;GAED,KAAK;IACJ,QAAQ;IACR;GAED,KAAK;IACJ,QAAQ;IACR;GAED,KAAK;IACJ,IAAI,OAAO,SAAS,UACnB,OAAO;IAGR,QAAQ,OAAO,KAAK,MAAM,IAAI,IAAI;IAClC;GAED,SACC,QAAQ;EACV;EAEA,IAAI,SAAS,MACZ,OAAO;EAGR,IAAI;EAEJ,QAAQ,QAAR;GACC,KAAK,KAAA;GACL,KAAK;GACL,KAAK;GACL,KAAK;IACJ,cAAc,MAAM,SAAS;IAC7B;GAED,KAAK;IACJ,cAAc,MAAM,SAAS,CAAC;IAC9B;GAED,KAAK;IACJ,cAAc,MAAM,SAAS,EAAE;IAC/B;GAED,KAAK;IACJ,cAAc,MAAM,SAAS,EAAE,CAAC,CAAC,YAAY;IAC7C;GAED,SACC,cAAc,MAAM,SAAS;EAE/B;EAEA,MAAM,QAAQ,SAAS,UAAU,EAAE,KAAK;EACxC,OAAO,YAAY,SAAS,OAAO,GAAG;CACvC,CAES;AACV;;;;;;;;AC7FA,MAAa,+BAA+B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@svta/cml-dash",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "DASH manifest parsing functionality",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -51,6 +51,6 @@
51
51
  }
52
52
  },
53
53
  "peerDependencies": {
54
- "@svta/cml-utils": "1.6.0"
54
+ "@svta/cml-utils": "^1.6.2"
55
55
  }
56
56
  }