@svta/cml-cmcd 0.22.0 → 1.0.1
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/index.d.ts +23 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -39
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -295,15 +295,6 @@ declare const CMCD_EVENT_MODE = "event";
|
|
|
295
295
|
*/
|
|
296
296
|
declare const CMCD_REQUEST_MODE = "request";
|
|
297
297
|
//#endregion
|
|
298
|
-
//#region src/CMCD_RESPONSE_MODE.d.ts
|
|
299
|
-
/**
|
|
300
|
-
* CMCD response mode variable name.
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
* @beta
|
|
304
|
-
*/
|
|
305
|
-
declare const CMCD_RESPONSE_MODE = "response";
|
|
306
|
-
//#endregion
|
|
307
298
|
//#region src/CmcdReportingMode.d.ts
|
|
308
299
|
/**
|
|
309
300
|
* CMCD reporting mode types.
|
|
@@ -319,10 +310,6 @@ declare const CmcdReportingMode: {
|
|
|
319
310
|
*/
|
|
320
311
|
readonly REQUEST: typeof CMCD_REQUEST_MODE;
|
|
321
312
|
/**
|
|
322
|
-
* Response mode
|
|
323
|
-
*/
|
|
324
|
-
readonly RESPONSE: typeof CMCD_RESPONSE_MODE;
|
|
325
|
-
/**
|
|
326
313
|
* Event mode
|
|
327
314
|
*/
|
|
328
315
|
readonly EVENT: typeof CMCD_EVENT_MODE;
|
|
@@ -374,7 +361,7 @@ type CmcdFormatter = (value: CmcdValue, options: CmcdFormatterOptions) => number
|
|
|
374
361
|
*
|
|
375
362
|
* @beta
|
|
376
363
|
*/
|
|
377
|
-
type CmcdEventExcludedKeys = "
|
|
364
|
+
type CmcdEventExcludedKeys = "bsd" | "d" | "dl" | "nor" | "ot" | "rtp" | "sid" | "su";
|
|
378
365
|
//#endregion
|
|
379
366
|
//#region src/CmcdEventType.d.ts
|
|
380
367
|
/**
|
|
@@ -422,6 +409,10 @@ declare const CmcdEventType: {
|
|
|
422
409
|
* The player view was collapsed.
|
|
423
410
|
*/
|
|
424
411
|
readonly PLAYER_COLLAPSE: "pc";
|
|
412
|
+
/**
|
|
413
|
+
* The receipt of a response.
|
|
414
|
+
*/
|
|
415
|
+
readonly RESPONSE_RECEIVED: "rr";
|
|
425
416
|
};
|
|
426
417
|
/**
|
|
427
418
|
* @beta
|
|
@@ -980,6 +971,10 @@ type CmcdEncodeOptions = {
|
|
|
980
971
|
* The base URL to use for relative URLs.
|
|
981
972
|
*/
|
|
982
973
|
baseUrl?: string;
|
|
974
|
+
/**
|
|
975
|
+
* Array of event names to filter.
|
|
976
|
+
*/
|
|
977
|
+
events?: string[];
|
|
983
978
|
};
|
|
984
979
|
//#endregion
|
|
985
980
|
//#region src/appendCmcdHeaders.d.ts
|
|
@@ -1119,6 +1114,15 @@ declare const CMCD_REQUEST_KEYS: readonly ["d", "dl", "nor", "ot", "rtp", "su"];
|
|
|
1119
1114
|
*/
|
|
1120
1115
|
declare const CMCD_RESPONSE_KEYS: readonly ["cmsdd", "cmsds", "rc", "smrt", "ttfb", "ttfbb", "ttlb", "url"];
|
|
1121
1116
|
//#endregion
|
|
1117
|
+
//#region src/CMCD_RESPONSE_MODE.d.ts
|
|
1118
|
+
/**
|
|
1119
|
+
* CMCD response mode variable name.
|
|
1120
|
+
*
|
|
1121
|
+
*
|
|
1122
|
+
* @beta
|
|
1123
|
+
*/
|
|
1124
|
+
declare const CMCD_RESPONSE_MODE = "response";
|
|
1125
|
+
//#endregion
|
|
1122
1126
|
//#region src/CMCD_V1.d.ts
|
|
1123
1127
|
/**
|
|
1124
1128
|
* CMCD Version 1
|
|
@@ -1399,7 +1403,7 @@ declare function isCmcdEventKey(key: string): key is keyof CmcdEvent;
|
|
|
1399
1403
|
*/
|
|
1400
1404
|
declare function isCmcdRequestKey(key: string): key is keyof CmcdRequest;
|
|
1401
1405
|
//#endregion
|
|
1402
|
-
//#region src/
|
|
1406
|
+
//#region src/isCmcdResponseReceivedKey.d.ts
|
|
1403
1407
|
/**
|
|
1404
1408
|
* Check if a key is a valid CMCD response key.
|
|
1405
1409
|
*
|
|
@@ -1407,13 +1411,14 @@ declare function isCmcdRequestKey(key: string): key is keyof CmcdRequest;
|
|
|
1407
1411
|
*
|
|
1408
1412
|
* @returns `true` if the key is a valid CMCD request key, `false` otherwise.
|
|
1409
1413
|
*
|
|
1414
|
+
* @group CMCD
|
|
1410
1415
|
*
|
|
1411
1416
|
* @beta
|
|
1412
1417
|
*
|
|
1413
1418
|
* @example
|
|
1414
|
-
* {@includeCode
|
|
1419
|
+
* {@includeCode ../../test/cmcd/isCmcdResponseReceivedKey.test.ts#example}
|
|
1415
1420
|
*/
|
|
1416
|
-
declare function
|
|
1421
|
+
declare function isCmcdResponseReceivedKey(key: string): key is keyof CmcdResponse;
|
|
1417
1422
|
//#endregion
|
|
1418
1423
|
//#region src/isCmcdV1Key.d.ts
|
|
1419
1424
|
/**
|
|
@@ -1526,5 +1531,5 @@ declare function toCmcdReport(data: CmcdData, target: CmcdReportTarget): Request
|
|
|
1526
1531
|
*/
|
|
1527
1532
|
declare function toCmcdUrl(cmcd: Cmcd, options?: CmcdEncodeOptions): string;
|
|
1528
1533
|
//#endregion
|
|
1529
|
-
export { CMCD_COMMON_KEYS, CMCD_DEFAULT_TIME_INTERVAL, CMCD_EVENT_KEYS, CMCD_EVENT_MODE, CMCD_FORMATTER_MAP, CMCD_HEADERS, CMCD_JSON, CMCD_KEYS, CMCD_OBJECT, CMCD_PARAM, CMCD_QUERY, CMCD_REQUEST, CMCD_REQUEST_KEYS, CMCD_REQUEST_MODE, CMCD_RESPONSE_KEYS, CMCD_RESPONSE_MODE, CMCD_SESSION, CMCD_STATUS, CMCD_V1, CMCD_V1_KEYS, CMCD_V2, Cmcd, CmcdCustomKey, CmcdData, CmcdEncodeOptions, CmcdEncoding, CmcdEvent, CmcdEventExcludedKeys, CmcdEventType, CmcdFormatter, CmcdFormatterMap, CmcdFormatterOptions, CmcdFormatters, CmcdHeaderField, CmcdHeaderMap, CmcdHeadersMap, CmcdKey, CmcdObjectType, CmcdPlayerState, CmcdReportTarget, CmcdReportingMode, CmcdRequest, CmcdResponse, CmcdStreamType, CmcdStreamingFormat, CmcdTransmissionMode, CmcdValue, appendCmcdHeaders, appendCmcdQuery, decodeCmcd, encodeCmcd, fromCmcdHeaders, fromCmcdQuery, fromCmcdUrl, groupCmcdHeaders, isCmcdCustomKey, isCmcdEventKey, isCmcdRequestKey,
|
|
1534
|
+
export { CMCD_COMMON_KEYS, CMCD_DEFAULT_TIME_INTERVAL, CMCD_EVENT_KEYS, CMCD_EVENT_MODE, CMCD_FORMATTER_MAP, CMCD_HEADERS, CMCD_JSON, CMCD_KEYS, CMCD_OBJECT, CMCD_PARAM, CMCD_QUERY, CMCD_REQUEST, CMCD_REQUEST_KEYS, CMCD_REQUEST_MODE, CMCD_RESPONSE_KEYS, CMCD_RESPONSE_MODE, CMCD_SESSION, CMCD_STATUS, CMCD_V1, CMCD_V1_KEYS, CMCD_V2, Cmcd, CmcdCustomKey, CmcdData, CmcdEncodeOptions, CmcdEncoding, CmcdEvent, CmcdEventExcludedKeys, CmcdEventType, CmcdFormatter, CmcdFormatterMap, CmcdFormatterOptions, CmcdFormatters, CmcdHeaderField, CmcdHeaderMap, CmcdHeadersMap, CmcdKey, CmcdObjectType, CmcdPlayerState, CmcdReportTarget, CmcdReportingMode, CmcdRequest, CmcdResponse, CmcdStreamType, CmcdStreamingFormat, CmcdTransmissionMode, CmcdValue, appendCmcdHeaders, appendCmcdQuery, decodeCmcd, encodeCmcd, fromCmcdHeaders, fromCmcdQuery, fromCmcdUrl, groupCmcdHeaders, isCmcdCustomKey, isCmcdEventKey, isCmcdRequestKey, isCmcdResponseReceivedKey, isCmcdV1Key, prepareCmcdData, toCmcdHeaders, toCmcdJson, toCmcdQuery, toCmcdReport, toCmcdUrl };
|
|
1530
1535
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["CMCD_FORMATTER_MAP: Record<string, CmcdFormatter>","CMCD_KEYS: CmcdKey[]","CmcdEncoding: typeof CmcdTransmissionMode","CmcdFormatters: Record<string, CmcdFormatter>"],"sources":["../src/CmcdCustomKey.ts","../src/CmcdObjectType.ts","../src/CmcdStreamType.ts","../src/CmcdStreamingFormat.ts","../src/CmcdValue.ts","../src/Cmcd.ts","../src/CMCD_EVENT_MODE.ts","../src/CMCD_REQUEST_MODE.ts","../src/
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["CMCD_FORMATTER_MAP: Record<string, CmcdFormatter>","CMCD_KEYS: CmcdKey[]","CmcdEncoding: typeof CmcdTransmissionMode","CmcdFormatters: Record<string, CmcdFormatter>"],"sources":["../src/CmcdCustomKey.ts","../src/CmcdObjectType.ts","../src/CmcdStreamType.ts","../src/CmcdStreamingFormat.ts","../src/CmcdValue.ts","../src/Cmcd.ts","../src/CMCD_EVENT_MODE.ts","../src/CMCD_REQUEST_MODE.ts","../src/CmcdReportingMode.ts","../src/CmcdFormatterOptions.ts","../src/CmcdFormatter.ts","../src/CmcdEventExcludedKeys.ts","../src/CmcdEventType.ts","../src/CmcdPlayerState.ts","../src/CmcdRequest.ts","../src/CmcdEvent.ts","../src/CmcdResponse.ts","../src/CmcdData.ts","../src/CmcdKey.ts","../src/CmcdFormatterMap.ts","../src/CMCD_OBJECT.ts","../src/CMCD_REQUEST.ts","../src/CMCD_SESSION.ts","../src/CMCD_STATUS.ts","../src/CmcdHeaderField.ts","../src/CmcdHeaderMap.ts","../src/CmcdEncodeOptions.ts","../src/appendCmcdHeaders.ts","../src/appendCmcdQuery.ts","../src/CMCD_COMMON_KEYS.ts","../src/CMCD_DEFAULT_TIME_INTERVAL.ts","../src/CMCD_EVENT_KEYS.ts","../src/CMCD_FORMATTER_MAP.ts","../src/CMCD_HEADERS.ts","../src/CMCD_JSON.ts","../src/CMCD_KEYS.ts","../src/CMCD_PARAM.ts","../src/CMCD_QUERY.ts","../src/CMCD_REQUEST_KEYS.ts","../src/CMCD_RESPONSE_KEYS.ts","../src/CMCD_RESPONSE_MODE.ts","../src/CMCD_V1.ts","../src/CMCD_V1_KEYS.ts","../src/CMCD_V2.ts","../src/CmcdTransmissionMode.ts","../src/CmcdEncoding.ts","../src/CmcdFormatters.ts","../src/CmcdHeadersMap.ts","../src/CmcdReportTarget.ts","../src/decodeCmcd.ts","../src/encodeCmcd.ts","../src/fromCmcdHeaders.ts","../src/fromCmcdQuery.ts","../src/fromCmcdUrl.ts","../src/groupCmcdHeaders.ts","../src/isCmcdCustomKey.ts","../src/isCmcdEventKey.ts","../src/isCmcdRequestKey.ts","../src/isCmcdResponseReceivedKey.ts","../src/isCmcdV1Key.ts","../src/prepareCmcdData.ts","../src/toCmcdHeaders.ts","../src/toCmcdJson.ts","../src/toCmcdQuery.ts","../src/toCmcdReport.ts","../src/toCmcdUrl.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AASA;;;;ACCa,KDDD,aAAA,GCCyC,GAAA,MAAA,IAAA,MAAA,EAAA;;;;;;;ADDrD;;;;ACCa,cAAA,cAAwC,EAAA,OAAA,YAAA;AAKrD;;;KAAY,cAAA,GAAiB;;;;;;;ADN7B;;;;ACCa,cCAA,cDAwC,EAAA,OCAA,YDAA;AAKrD;;;KCAY,cAAA,GAAiB;;;;;;;AFN7B;;;;ACCa,cEAA,mBFAwC,EAAA,OEAU,iBFAV;AAKrD;;;KEAY,mBAAA,GAAsB;;;;AHNlC;;;;ACCA;AAKY,KGJA,SAAA,GACT,cHG0B,GGF1B,mBHE0B,GGD1B,cHC0B,GAAA,MAAA,GAAA,MAAA,EAAA,GAAA,MAAA,GAAA,MAAA,EAAA,GAAA,OAAA,GAAA,MAAA,GGM1B,OHN0B,GGO1B,MHP0B,GGQ1B,MHR0B,EAAA;;;;;AAL7B;AAKA;;;;ACLA;AAKY,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B,oBAAyB,OAAO;;;;;;A7DZvF;;;;ACCA;AAKA;;;;ACLA;AAKY,iB4DGI,UAAA,C5DHa,IAAA,E4DGI,I5DHJ,EAAA,OAAA,CAAA,E4DGoB,iB5DHpB,CAAA,EAAA,MAAA;;;;;;AFN7B;;;;ACCA;AAKA;;;;ACLA;AAKA;iB6DIgB,WAAA,OAAkB,gBAAe;;;;A/DVjD;;;;ACCA;AAKA;;;;ACLA;AAKA;;;iB8DWgB,YAAA,OAAmB,kBAAkB,mBAAmB;E7DhBxE,IAAa,E6DgB2E,I7DhB3E;AAKb,CAAA,CAAA,GAAY,IAAA;;;;;;AHNZ;;;;ACCA;AAKA;;;iBgEAgB,SAAA,OAAgB,gBAAe"}
|
package/dist/index.js
CHANGED
|
@@ -204,16 +204,6 @@ const CMCD_FORMATTER_MAP = {
|
|
|
204
204
|
*/
|
|
205
205
|
const CMCD_REQUEST_MODE = "request";
|
|
206
206
|
|
|
207
|
-
//#endregion
|
|
208
|
-
//#region src/CMCD_RESPONSE_MODE.ts
|
|
209
|
-
/**
|
|
210
|
-
* CMCD response mode variable name.
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
* @beta
|
|
214
|
-
*/
|
|
215
|
-
const CMCD_RESPONSE_MODE = "response";
|
|
216
|
-
|
|
217
207
|
//#endregion
|
|
218
208
|
//#region src/CMCD_COMMON_KEYS.ts
|
|
219
209
|
/**
|
|
@@ -265,6 +255,25 @@ const CMCD_COMMON_KEYS = [
|
|
|
265
255
|
*/
|
|
266
256
|
const CMCD_EVENT_KEYS = ["e"];
|
|
267
257
|
|
|
258
|
+
//#endregion
|
|
259
|
+
//#region src/CMCD_RESPONSE_KEYS.ts
|
|
260
|
+
/**
|
|
261
|
+
* CMCD v2 - Response-only and timing keys.
|
|
262
|
+
*
|
|
263
|
+
*
|
|
264
|
+
* @beta
|
|
265
|
+
*/
|
|
266
|
+
const CMCD_RESPONSE_KEYS = [
|
|
267
|
+
"cmsdd",
|
|
268
|
+
"cmsds",
|
|
269
|
+
"rc",
|
|
270
|
+
"smrt",
|
|
271
|
+
"ttfb",
|
|
272
|
+
"ttfbb",
|
|
273
|
+
"ttlb",
|
|
274
|
+
"url"
|
|
275
|
+
];
|
|
276
|
+
|
|
268
277
|
//#endregion
|
|
269
278
|
//#region src/isCmcdCustomKey.ts
|
|
270
279
|
const CUSTOM_KEY_REGEX = /^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;
|
|
@@ -298,7 +307,7 @@ function isCmcdCustomKey(key) {
|
|
|
298
307
|
* {@includeCode ../test/isCmcdEventKey.test.ts#example}
|
|
299
308
|
*/
|
|
300
309
|
function isCmcdEventKey(key) {
|
|
301
|
-
return CMCD_COMMON_KEYS.includes(key) || CMCD_EVENT_KEYS.includes(key) || isCmcdCustomKey(key);
|
|
310
|
+
return CMCD_COMMON_KEYS.includes(key) || CMCD_EVENT_KEYS.includes(key) || CMCD_RESPONSE_KEYS.includes(key) || isCmcdCustomKey(key);
|
|
302
311
|
}
|
|
303
312
|
|
|
304
313
|
//#endregion
|
|
@@ -338,26 +347,7 @@ function isCmcdRequestKey(key) {
|
|
|
338
347
|
}
|
|
339
348
|
|
|
340
349
|
//#endregion
|
|
341
|
-
//#region src/
|
|
342
|
-
/**
|
|
343
|
-
* CMCD v2 - Response-only and timing keys.
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
* @beta
|
|
347
|
-
*/
|
|
348
|
-
const CMCD_RESPONSE_KEYS = [
|
|
349
|
-
"cmsdd",
|
|
350
|
-
"cmsds",
|
|
351
|
-
"rc",
|
|
352
|
-
"smrt",
|
|
353
|
-
"ttfb",
|
|
354
|
-
"ttfbb",
|
|
355
|
-
"ttlb",
|
|
356
|
-
"url"
|
|
357
|
-
];
|
|
358
|
-
|
|
359
|
-
//#endregion
|
|
360
|
-
//#region src/isCmcdResponseKey.ts
|
|
350
|
+
//#region src/isCmcdResponseReceivedKey.ts
|
|
361
351
|
/**
|
|
362
352
|
* Check if a key is a valid CMCD response key.
|
|
363
353
|
*
|
|
@@ -365,14 +355,15 @@ const CMCD_RESPONSE_KEYS = [
|
|
|
365
355
|
*
|
|
366
356
|
* @returns `true` if the key is a valid CMCD request key, `false` otherwise.
|
|
367
357
|
*
|
|
358
|
+
* @group CMCD
|
|
368
359
|
*
|
|
369
360
|
* @beta
|
|
370
361
|
*
|
|
371
362
|
* @example
|
|
372
|
-
* {@includeCode
|
|
363
|
+
* {@includeCode ../../test/cmcd/isCmcdResponseReceivedKey.test.ts#example}
|
|
373
364
|
*/
|
|
374
|
-
function
|
|
375
|
-
return
|
|
365
|
+
function isCmcdResponseReceivedKey(key) {
|
|
366
|
+
return CMCD_RESPONSE_KEYS.includes(key);
|
|
376
367
|
}
|
|
377
368
|
|
|
378
369
|
//#endregion
|
|
@@ -426,7 +417,6 @@ function isCmcdV1Key(key) {
|
|
|
426
417
|
//#endregion
|
|
427
418
|
//#region src/prepareCmcdData.ts
|
|
428
419
|
const filterMap = {
|
|
429
|
-
[CMCD_RESPONSE_MODE]: isCmcdResponseKey,
|
|
430
420
|
[CMCD_EVENT_MODE]: isCmcdEventKey,
|
|
431
421
|
[CMCD_REQUEST_MODE]: isCmcdRequestKey
|
|
432
422
|
};
|
|
@@ -446,9 +436,10 @@ function prepareCmcdData(obj, options = {}) {
|
|
|
446
436
|
const reportingMode = options.reportingMode || CMCD_REQUEST_MODE;
|
|
447
437
|
const keyFilter = version === 1 ? isCmcdV1Key : filterMap[reportingMode];
|
|
448
438
|
let keys$1 = Object.keys(obj).filter(keyFilter);
|
|
439
|
+
if (obj["e"] && obj["e"] !== "rr") keys$1 = keys$1.filter((key) => !isCmcdResponseReceivedKey(key));
|
|
449
440
|
const filter = options.filter;
|
|
450
441
|
if (typeof filter === "function") keys$1 = keys$1.filter(filter);
|
|
451
|
-
const needsTimestamp = reportingMode ===
|
|
442
|
+
const needsTimestamp = reportingMode === CMCD_EVENT_MODE;
|
|
452
443
|
if (needsTimestamp && !keys$1.includes("ts")) keys$1.push("ts");
|
|
453
444
|
if (version > 1 && !keys$1.includes("v")) keys$1.push("v");
|
|
454
445
|
const formatters = Object.assign({}, CMCD_FORMATTER_MAP, options.formatters);
|
|
@@ -675,6 +666,16 @@ const CMCD_KEYS = Array.from(keySet);
|
|
|
675
666
|
*/
|
|
676
667
|
const CMCD_QUERY = "query";
|
|
677
668
|
|
|
669
|
+
//#endregion
|
|
670
|
+
//#region src/CMCD_RESPONSE_MODE.ts
|
|
671
|
+
/**
|
|
672
|
+
* CMCD response mode variable name.
|
|
673
|
+
*
|
|
674
|
+
*
|
|
675
|
+
* @beta
|
|
676
|
+
*/
|
|
677
|
+
const CMCD_RESPONSE_MODE = "response";
|
|
678
|
+
|
|
678
679
|
//#endregion
|
|
679
680
|
//#region src/CMCD_V1.ts
|
|
680
681
|
/**
|
|
@@ -746,7 +747,8 @@ const CmcdEventType = {
|
|
|
746
747
|
MUTE: "m",
|
|
747
748
|
UNMUTE: "um",
|
|
748
749
|
PLAYER_EXPAND: "pe",
|
|
749
|
-
PLAYER_COLLAPSE: "pc"
|
|
750
|
+
PLAYER_COLLAPSE: "pc",
|
|
751
|
+
RESPONSE_RECEIVED: "rr"
|
|
750
752
|
};
|
|
751
753
|
|
|
752
754
|
//#endregion
|
|
@@ -808,7 +810,6 @@ const CmcdPlayerState = {
|
|
|
808
810
|
*/
|
|
809
811
|
const CmcdReportingMode = {
|
|
810
812
|
REQUEST: CMCD_REQUEST_MODE,
|
|
811
|
-
RESPONSE: CMCD_RESPONSE_MODE,
|
|
812
813
|
EVENT: CMCD_EVENT_MODE
|
|
813
814
|
};
|
|
814
815
|
|
|
@@ -1000,5 +1001,5 @@ function toCmcdReport(data, target) {
|
|
|
1000
1001
|
}
|
|
1001
1002
|
|
|
1002
1003
|
//#endregion
|
|
1003
|
-
export { CMCD_COMMON_KEYS, CMCD_DEFAULT_TIME_INTERVAL, CMCD_EVENT_KEYS, CMCD_EVENT_MODE, CMCD_FORMATTER_MAP, CMCD_HEADERS, CMCD_JSON, CMCD_KEYS, CMCD_OBJECT, CMCD_PARAM, CMCD_QUERY, CMCD_REQUEST, CMCD_REQUEST_KEYS, CMCD_REQUEST_MODE, CMCD_RESPONSE_KEYS, CMCD_RESPONSE_MODE, CMCD_SESSION, CMCD_STATUS, CMCD_V1, CMCD_V1_KEYS, CMCD_V2, CmcdEncoding, CmcdEventType, CmcdFormatters, CmcdHeaderField, CmcdObjectType, CmcdPlayerState, CmcdReportingMode, CmcdStreamType, CmcdStreamingFormat, CmcdTransmissionMode, appendCmcdHeaders, appendCmcdQuery, decodeCmcd, encodeCmcd, fromCmcdHeaders, fromCmcdQuery, fromCmcdUrl, groupCmcdHeaders, isCmcdCustomKey, isCmcdEventKey, isCmcdRequestKey,
|
|
1004
|
+
export { CMCD_COMMON_KEYS, CMCD_DEFAULT_TIME_INTERVAL, CMCD_EVENT_KEYS, CMCD_EVENT_MODE, CMCD_FORMATTER_MAP, CMCD_HEADERS, CMCD_JSON, CMCD_KEYS, CMCD_OBJECT, CMCD_PARAM, CMCD_QUERY, CMCD_REQUEST, CMCD_REQUEST_KEYS, CMCD_REQUEST_MODE, CMCD_RESPONSE_KEYS, CMCD_RESPONSE_MODE, CMCD_SESSION, CMCD_STATUS, CMCD_V1, CMCD_V1_KEYS, CMCD_V2, CmcdEncoding, CmcdEventType, CmcdFormatters, CmcdHeaderField, CmcdObjectType, CmcdPlayerState, CmcdReportingMode, CmcdStreamType, CmcdStreamingFormat, CmcdTransmissionMode, appendCmcdHeaders, appendCmcdQuery, decodeCmcd, encodeCmcd, fromCmcdHeaders, fromCmcdQuery, fromCmcdUrl, groupCmcdHeaders, isCmcdCustomKey, isCmcdEventKey, isCmcdRequestKey, isCmcdResponseReceivedKey, isCmcdV1Key, prepareCmcdData, toCmcdHeaders, toCmcdJson, toCmcdQuery, toCmcdReport, toCmcdUrl };
|
|
1004
1005
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["CMCD_HEADER_MAP: Record<CmcdKey, CmcdHeaderField>","keys","CMCD_FORMATTER_MAP: Record<string, CmcdFormatter>","results: CmcdData","keys","formatterOptions: CmcdFormatterOptions","CMCD_KEYS: CmcdKey[]","CmcdEncoding: typeof CmcdTransmissionMode","CmcdFormatters: Record<string, CmcdFormatter>","options: CmcdEncodeOptions"],"sources":["../src/CMCD_OBJECT.ts","../src/CMCD_REQUEST.ts","../src/CMCD_SESSION.ts","../src/CMCD_STATUS.ts","../src/CMCD_HEADER_MAP.ts","../src/CmcdHeaderField.ts","../src/groupCmcdHeaders.ts","../src/CMCD_EVENT_MODE.ts","../src/CMCD_FORMATTER_MAP.ts","../src/CMCD_REQUEST_MODE.ts","../src/CMCD_RESPONSE_MODE.ts","../src/CMCD_COMMON_KEYS.ts","../src/CMCD_EVENT_KEYS.ts","../src/isCmcdCustomKey.ts","../src/isCmcdEventKey.ts","../src/CMCD_REQUEST_KEYS.ts","../src/isCmcdRequestKey.ts","../src/CMCD_RESPONSE_KEYS.ts","../src/isCmcdResponseKey.ts","../src/CMCD_V1_KEYS.ts","../src/isCmcdV1Key.ts","../src/prepareCmcdData.ts","../src/toCmcdHeaders.ts","../src/appendCmcdHeaders.ts","../src/CMCD_PARAM.ts","../src/encodeCmcd.ts","../src/toCmcdUrl.ts","../src/toCmcdQuery.ts","../src/appendCmcdQuery.ts","../src/CMCD_DEFAULT_TIME_INTERVAL.ts","../src/CMCD_HEADERS.ts","../src/CMCD_JSON.ts","../src/CMCD_KEYS.ts","../src/CMCD_QUERY.ts","../src/CMCD_V1.ts","../src/CMCD_V2.ts","../src/CmcdTransmissionMode.ts","../src/CmcdEncoding.ts","../src/CmcdEventType.ts","../src/CmcdFormatters.ts","../src/CmcdObjectType.ts","../src/CmcdPlayerState.ts","../src/CmcdReportingMode.ts","../src/CmcdStreamingFormat.ts","../src/CmcdStreamType.ts","../src/decodeCmcd.ts","../src/fromCmcdHeaders.ts","../src/fromCmcdQuery.ts","../src/fromCmcdUrl.ts","../src/toCmcdJson.ts","../src/toCmcdReport.ts"],"sourcesContent":["/**\n * CMCD object header name.\n *\n *\n * @beta\n */\nexport const CMCD_OBJECT = 'CMCD-Object'\n","/**\n * CMCD request header name.\n *\n *\n * @beta\n */\nexport const CMCD_REQUEST = 'CMCD-Request'\n","/**\n * CMCD session header name.\n *\n *\n * @beta\n */\nexport const CMCD_SESSION = 'CMCD-Session'\n","/**\n * CMCD status header name.\n *\n *\n * @beta\n */\nexport const CMCD_STATUS = 'CMCD-Status'\n","import { CMCD_OBJECT } from './CMCD_OBJECT.ts'\nimport { CMCD_REQUEST } from './CMCD_REQUEST.ts'\nimport { CMCD_SESSION } from './CMCD_SESSION.ts'\nimport { CMCD_STATUS } from './CMCD_STATUS.ts'\nimport type { CmcdHeaderField } from './CmcdHeaderField.ts'\nimport type { CmcdKey } from './CmcdKey.ts'\n\n/**\n * The map of CMCD keys to their appropriate header shard.\n *\n *\n * @internal\n */\nexport const CMCD_HEADER_MAP: Record<CmcdKey, CmcdHeaderField> = {\n\t// Object\n\tbr: CMCD_OBJECT,\n\tab: CMCD_OBJECT,\n\td: CMCD_OBJECT,\n\tot: CMCD_OBJECT,\n\ttb: CMCD_OBJECT,\n\ttpb: CMCD_OBJECT,\n\tlb: CMCD_OBJECT,\n\ttab: CMCD_OBJECT,\n\tlab: CMCD_OBJECT,\n\turl: CMCD_OBJECT,\n\n\t// Request\n\tpb: CMCD_REQUEST,\n\tbl: CMCD_REQUEST,\n\ttbl: CMCD_REQUEST,\n\tdl: CMCD_REQUEST,\n\tltc: CMCD_REQUEST,\n\tmtp: CMCD_REQUEST,\n\tnor: CMCD_REQUEST,\n\tnrr: CMCD_REQUEST,\n\trc: CMCD_REQUEST,\n\tsn: CMCD_REQUEST,\n\tsta: CMCD_REQUEST,\n\tsu: CMCD_REQUEST,\n\tttfb: CMCD_REQUEST,\n\tttfbb: CMCD_REQUEST,\n\tttlb: CMCD_REQUEST,\n\tcmsdd: CMCD_REQUEST,\n\tcmsds: CMCD_REQUEST,\n\tsmrt: CMCD_REQUEST,\n\tdf: CMCD_REQUEST,\n\tcs: CMCD_REQUEST,\n\n\t// TODO: Which header to put the `ts` field is not defined yet.\n\tts: CMCD_REQUEST,\n\n\t// Session\n\tcid: CMCD_SESSION,\n\tpr: CMCD_SESSION,\n\tsf: CMCD_SESSION,\n\tsid: CMCD_SESSION,\n\tst: CMCD_SESSION,\n\tv: CMCD_SESSION,\n\tmsd: CMCD_SESSION,\n\n\t// Status\n\tbs: CMCD_STATUS,\n\tbsd: CMCD_STATUS,\n\tcdn: CMCD_STATUS,\n\trtp: CMCD_STATUS,\n\tbg: CMCD_STATUS,\n\tpt: CMCD_STATUS,\n\tec: CMCD_STATUS,\n\te: CMCD_STATUS,\n}\n","import type { ValueOf } from '@svta/cml-utils'\nimport { CMCD_OBJECT } from './CMCD_OBJECT.ts'\nimport { CMCD_REQUEST } from './CMCD_REQUEST.ts'\nimport { CMCD_SESSION } from './CMCD_SESSION.ts'\nimport { CMCD_STATUS } from './CMCD_STATUS.ts'\n\n/**\n * CMCD header fields.\n *\n *\n * @enum\n *\n * @beta\n */\nexport const CmcdHeaderField = {\n\t/**\n\t * keys whose values vary with the object being requested.\n\t */\n\tOBJECT: CMCD_OBJECT as typeof CMCD_OBJECT,\n\n\t/**\n\t * keys whose values vary with each request.\n\t */\n\tREQUEST: CMCD_REQUEST as typeof CMCD_REQUEST,\n\n\t/**\n\t * keys whose values are expected to be invariant over the life of the session.\n\t */\n\tSESSION: CMCD_SESSION as typeof CMCD_SESSION,\n\n\t/**\n\t * keys whose values do not vary with every request or object.\n\t */\n\tSTATUS: CMCD_STATUS as typeof CMCD_STATUS,\n} as const\n\n/**\n * @beta\n */\nexport type CmcdHeaderField = ValueOf<typeof CmcdHeaderField>;\n","import { CMCD_HEADER_MAP } from './CMCD_HEADER_MAP.ts'\nimport type { CmcdData } from './CmcdData.ts'\nimport { CmcdHeaderField } from './CmcdHeaderField.ts'\nimport type { CmcdHeaderMap } from './CmcdHeaderMap.ts'\nimport type { CmcdKey } from './CmcdKey.ts'\n\nfunction createHeaderMap(headerMap: Partial<CmcdHeaderMap>): Record<CmcdKey, CmcdHeaderField> {\n\treturn Object.keys(headerMap)\n\t\t.reduce((acc, field) => {\n\t\t\theaderMap[field as CmcdHeaderField]?.forEach(key => acc[key] = field as CmcdHeaderField)\n\t\t\treturn acc\n\t\t}, {} as Record<CmcdKey, CmcdHeaderField>)\n}\n\n/**\n * Group a CMCD data object into header shards\n *\n * @param cmcd - The CMCD data object to convert.\n * @param customHeaderMap - A map of CMCD header fields to custom CMCD keys.\n *\n * @returns The CMCD header shards.\n *\n *\n * @beta\n */\nexport function groupCmcdHeaders(cmcd: CmcdData, customHeaderMap?: Partial<CmcdHeaderMap>): Record<CmcdHeaderField, CmcdData> {\n\tconst result = {} as Record<CmcdHeaderField, CmcdData>\n\n\tif (!cmcd) {\n\t\treturn result\n\t}\n\n\tconst keys = Object.keys(cmcd) as CmcdKey[]\n\tconst custom = customHeaderMap ? createHeaderMap(customHeaderMap) : {} as Record<CmcdKey, CmcdHeaderField>\n\n\treturn keys.reduce((acc: Record<CmcdHeaderField, CmcdData>, key: CmcdKey) => {\n\t\tconst field = CMCD_HEADER_MAP[key] || custom[key] || CmcdHeaderField.REQUEST\n\t\tconst data = acc[field] ??= {};\n\t\t(data as any)[key] = cmcd[key]\n\t\treturn acc\n\t}, result)\n}\n","/**\n * CMCD event mode variable name.\n *\n *\n * @beta\n */\nexport const CMCD_EVENT_MODE = 'event'\n","import { SfItem } from '@svta/cml-structured-field-values'\nimport { urlToRelativePath, type ValueOrArray } from '@svta/cml-utils'\nimport type { CmcdFormatter } from './CmcdFormatter.ts'\nimport type { CmcdFormatterOptions } from './CmcdFormatterOptions.ts'\nimport type { CmcdValue } from './CmcdValue.ts'\n\nconst toRounded = (value: CmcdValue) => Math.round(value as number)\n\nconst toUrlSafe = (value: CmcdValue, options: CmcdFormatterOptions): ValueOrArray<string> | ValueOrArray<SfItem> => {\n\tif (Array.isArray(value)) {\n\t\treturn value.map(item => toUrlSafe(item, options) as string)\n\t}\n\n\tif (value instanceof SfItem && typeof value.value === 'string') {\n\t\treturn new SfItem(toUrlSafe(value.value, options), value.params)\n\t}\n\telse {\n\t\tif (options.baseUrl) {\n\t\t\tvalue = urlToRelativePath(value as string, options.baseUrl)\n\t\t}\n\t\treturn options.version === 1 ? encodeURIComponent(value as string) : (value as string)\n\t}\n}\n\nconst toHundred = (value: CmcdValue) => toRounded(value as number / 100) * 100\n\nconst nor = (value: CmcdValue, options: CmcdFormatterOptions) => {\n\tlet norValue = value\n\n\tif (options.version >= 2) {\n\t\tif (value instanceof SfItem && typeof value.value === 'string') {\n\t\t\tnorValue = new SfItem([value])\n\t\t}\n\t\telse if (typeof value === 'string') {\n\t\t\tnorValue = [value]\n\t\t}\n\t}\n\n\treturn toUrlSafe(norValue, options)\n}\n\n/**\n * The default formatters for CMCD values.\n *\n *\n * @beta\n */\nexport const CMCD_FORMATTER_MAP: Record<string, CmcdFormatter> = {\n\t/**\n\t * Bitrate (kbps) rounded integer\n\t */\n\tbr: toRounded,\n\n\t/**\n\t * Duration (milliseconds) rounded integer\n\t */\n\td: toRounded,\n\n\t/**\n\t * Buffer Length (milliseconds) rounded nearest 100ms\n\t */\n\tbl: toHundred,\n\n\t/**\n\t * Deadline (milliseconds) rounded nearest 100ms\n\t */\n\tdl: toHundred,\n\n\t/**\n\t * Measured Throughput (kbps) rounded nearest 100kbps\n\t */\n\tmtp: toHundred,\n\n\t/**\n\t * Next Object Request URL encoded\n\t */\n\tnor,\n\n\t/**\n\t * Requested maximum throughput (kbps) rounded nearest 100kbps\n\t */\n\trtp: toHundred,\n\n\t/**\n\t * Top Bitrate (kbps) rounded integer\n\t */\n\ttb: toRounded,\n} as const\n","/**\n * CMCD request mode variable name.\n *\n *\n * @beta\n */\nexport const CMCD_REQUEST_MODE = 'request'\n","/**\n * CMCD response mode variable name.\n *\n *\n * @beta\n */\nexport const CMCD_RESPONSE_MODE = 'response'\n","/**\n * Defines the common keys for CMCD (Common Media Client Data) version 2.\n *\n *\n * @beta\n */\nexport const CMCD_COMMON_KEYS = [\n\t'ab',\n\t'bg',\n\t'bl',\n\t'br',\n\t'bs',\n\t'bsd',\n\t'cdn',\n\t'cid',\n\t'cs',\n\t'df',\n\t'ec',\n\t'lab',\n\t'lb',\n\t'ltc',\n\t'msd',\n\t'mtp',\n\t'pb',\n\t'pr',\n\t'pt',\n\t'sf',\n\t'sid',\n\t'sn',\n\t'st',\n\t'sta',\n\t'tab',\n\t'tb',\n\t'tbl',\n\t'tpb',\n\t'ts',\n\t'v',\n] as const\n","/**\n * Defines the event-specific keys for CMCD (Common Media Client Data) version 2.\n *\n *\n * @beta\n */\nexport const CMCD_EVENT_KEYS = [\n\t'e',\n] as const\n","import type { CmcdKey } from './CmcdKey.ts'\n\nconst CUSTOM_KEY_REGEX = /^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/\n\n/**\n * Check if a key is a custom key.\n *\n * @param key - The key to check.\n *\n * @returns `true` if the key is a custom key, `false` otherwise.\n *\n *\n * @beta\n */\nexport function isCmcdCustomKey(key: CmcdKey): boolean {\n\treturn CUSTOM_KEY_REGEX.test(key)\n}\n","import { CMCD_COMMON_KEYS } from './CMCD_COMMON_KEYS.ts'\nimport { CMCD_EVENT_KEYS } from './CMCD_EVENT_KEYS.ts'\nimport type { CmcdEvent } from './CmcdEvent.ts'\nimport { isCmcdCustomKey } from './isCmcdCustomKey.ts'\n\n/**\n * Check if a key is a valid CMCD event key.\n *\n * @param key - The key to check.\n *\n * @returns `true` if the key is a valid CMCD event key, `false` otherwise.\n *\n *\n * @beta\n *\n * @example\n * {@includeCode ../test/isCmcdEventKey.test.ts#example}\n */\nexport function isCmcdEventKey(key: string): key is keyof CmcdEvent {\n\treturn CMCD_COMMON_KEYS.includes(key as any) ||\n\t\tCMCD_EVENT_KEYS.includes(key as any) ||\n\t\tisCmcdCustomKey(key as any)\n}\n","/**\n * Defines the request-specific keys for CMCD (Common Media Client Data) version 2.\n *\n *\n * @beta\n */\nexport const CMCD_REQUEST_KEYS = [\n\t'd',\n\t'dl',\n\t'nor',\n\t'ot',\n\t'rtp',\n\t'su',\n] as const\n","import { CMCD_COMMON_KEYS } from './CMCD_COMMON_KEYS.ts'\nimport { CMCD_REQUEST_KEYS } from './CMCD_REQUEST_KEYS.ts'\nimport type { CmcdRequest } from './CmcdRequest.ts'\nimport { isCmcdCustomKey } from './isCmcdCustomKey.ts'\n\n/**\n * Check if a key is a valid CMCD request key.\n *\n * @param key - The key to check.\n *\n * @returns `true` if the key is a valid CMCD request key, `false` otherwise.\n *\n *\n * @beta\n *\n * @example\n * {@includeCode ../test/isCmcdRequestKey.test.ts#example}\n */\nexport function isCmcdRequestKey(key: string): key is keyof CmcdRequest {\n\treturn CMCD_COMMON_KEYS.includes(key as any) ||\n\t\tCMCD_REQUEST_KEYS.includes(key as any) ||\n\t\tisCmcdCustomKey(key as any)\n}\n","/**\n * CMCD v2 - Response-only and timing keys.\n *\n *\n * @beta\n */\nexport const CMCD_RESPONSE_KEYS = [\n\t'cmsdd',\n\t'cmsds',\n\t'rc',\n\t'smrt',\n\t'ttfb',\n\t'ttfbb',\n\t'ttlb',\n\t'url',\n] as const\n","import { CMCD_COMMON_KEYS } from './CMCD_COMMON_KEYS.ts'\nimport { CMCD_REQUEST_KEYS } from './CMCD_REQUEST_KEYS.ts'\nimport { CMCD_RESPONSE_KEYS } from './CMCD_RESPONSE_KEYS.ts'\nimport type { CmcdResponse } from './CmcdResponse.ts'\nimport { isCmcdCustomKey } from './isCmcdCustomKey.ts'\n\n/**\n * Check if a key is a valid CMCD response key.\n *\n * @param key - The key to check.\n *\n * @returns `true` if the key is a valid CMCD request key, `false` otherwise.\n *\n *\n * @beta\n *\n * @example\n * {@includeCode ../test/isCmcdResponseKey.test.ts#example}\n */\nexport function isCmcdResponseKey(key: string): key is keyof CmcdResponse {\n\treturn CMCD_COMMON_KEYS.includes(key as any) ||\n\t\tCMCD_REQUEST_KEYS.includes(key as any) ||\n\t\tCMCD_RESPONSE_KEYS.includes(key as any) ||\n\t\tisCmcdCustomKey(key as any)\n}\n","/**\n * Defines the keys for CMCD (Common Media Client Data) version 1.\n *\n *\n * @beta\n */\nexport const CMCD_V1_KEYS = [\n\t'bl',\n\t'br',\n\t'bs',\n\t'cid',\n\t'd',\n\t'dl',\n\t'mtp',\n\t'nor',\n\t'nrr',\n\t'ot',\n\t'pr',\n\t'rtp',\n\t'sf',\n\t'sid',\n\t'st',\n\t'su',\n\t'tb',\n\t'v',\n] as const\n","import { CMCD_V1_KEYS } from './CMCD_V1_KEYS.ts'\nimport type { Cmcd } from './Cmcd.ts'\nimport { isCmcdCustomKey } from './isCmcdCustomKey.ts'\n\n/**\n * Filter function for CMCD v1 keys.\n *\n * @param key - The CMCD key to filter.\n *\n * @returns `true` if the key should be included, `false` otherwise.\n *\n *\n * @beta\n *\n * @example\n * {@includeCode ../test/isCmcdV1Key.test.ts#example}\n */\nexport function isCmcdV1Key(key: string): key is keyof Cmcd {\n\treturn CMCD_V1_KEYS.includes(key as any) || isCmcdCustomKey(key as any)\n}\n","import { isTokenField, isValid } from '@svta/cml-cta'\nimport { SfToken } from '@svta/cml-structured-field-values'\nimport { CMCD_EVENT_MODE } from './CMCD_EVENT_MODE.ts'\nimport { CMCD_FORMATTER_MAP } from './CMCD_FORMATTER_MAP.ts'\nimport { CMCD_REQUEST_MODE } from './CMCD_REQUEST_MODE.ts'\nimport { CMCD_RESPONSE_MODE } from './CMCD_RESPONSE_MODE.ts'\nimport type { CmcdData } from './CmcdData.ts'\nimport type { CmcdEncodeOptions } from './CmcdEncodeOptions.ts'\nimport type { CmcdFormatterOptions } from './CmcdFormatterOptions.ts'\nimport type { CmcdValue } from './CmcdValue.ts'\nimport { isCmcdEventKey } from './isCmcdEventKey.ts'\nimport { isCmcdRequestKey } from './isCmcdRequestKey.ts'\nimport { isCmcdResponseKey } from './isCmcdResponseKey.ts'\nimport { isCmcdV1Key } from './isCmcdV1Key.ts'\n\nconst filterMap = {\n\t[CMCD_RESPONSE_MODE]: isCmcdResponseKey,\n\t[CMCD_EVENT_MODE]: isCmcdEventKey,\n\t[CMCD_REQUEST_MODE]: isCmcdRequestKey,\n}\n\n/**\n * Convert a generic object to CMCD data.\n *\n * @param obj - The CMCD object to process.\n * @param options - Options for encoding.\n *\n *\n * @beta\n */\nexport function prepareCmcdData(obj: Record<string, any>, options: CmcdEncodeOptions = {}): CmcdData {\n\tconst results: CmcdData = {}\n\n\tif (obj == null || typeof obj !== 'object') {\n\t\treturn results\n\t}\n\n\tconst version = options.version || (obj['v'] as number) || 1\n\tconst reportingMode = options.reportingMode || CMCD_REQUEST_MODE\n\tconst keyFilter = version === 1 ? isCmcdV1Key : filterMap[reportingMode]\n\n\t// Filter keys based on the version, reporting mode and options\n\tlet keys = Object.keys(obj).filter(keyFilter)\n\n\tconst filter = options.filter\n\tif (typeof filter === 'function') {\n\t\tkeys = keys.filter(filter)\n\t}\n\n\t// Ensure all required keys are present before sorting\n\tconst needsTimestamp = reportingMode === CMCD_RESPONSE_MODE || reportingMode === CMCD_EVENT_MODE\n\tif (needsTimestamp && !keys.includes('ts')) {\n\t\tkeys.push('ts')\n\t}\n\n\tif (version > 1 && !keys.includes('v')) {\n\t\tkeys.push('v')\n\t}\n\n\tconst formatters = Object.assign({}, CMCD_FORMATTER_MAP, options.formatters)\n\tconst formatterOptions: CmcdFormatterOptions = {\n\t\tversion,\n\t\treportingMode,\n\t\tbaseUrl: options.baseUrl,\n\t}\n\n\tkeys.sort().forEach(key => {\n\t\tlet value = obj[key] as CmcdValue\n\n\t\tconst formatter = formatters[key]\n\t\tif (typeof formatter === 'function') {\n\t\t\tvalue = formatter(value, formatterOptions)\n\t\t}\n\n\t\t// Version should only be reported if not equal to 1.\n\t\tif (key === 'v') {\n\t\t\tif (version === 1) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\telse {\n\t\t\t\tvalue = version\n\t\t\t}\n\t\t}\n\n\t\t// Playback rate should only be sent if not equal to 1.\n\t\tif (key == 'pr' && value === 1) {\n\t\t\treturn\n\t\t}\n\n\t\t// Ensure a timestamp is set for response and event modes\n\t\tif (needsTimestamp && key === 'ts' && !Number.isFinite(value)) {\n\t\t\tvalue = Date.now()\n\t\t}\n\n\t\t// ignore invalid values\n\t\tif (!isValid(value)) {\n\t\t\treturn\n\t\t}\n\n\t\tif (isTokenField(key) && typeof value === 'string') {\n\t\t\tvalue = new SfToken(value)\n\t\t}\n\n\t\t(results as any)[key] = value\n\t})\n\n\treturn results\n}\n","import { encodeSfDict } from '@svta/cml-structured-field-values'\nimport type { CmcdData } from './CmcdData.ts'\nimport type { CmcdEncodeOptions } from './CmcdEncodeOptions.ts'\nimport type { CmcdHeaderField } from './CmcdHeaderField.ts'\nimport { groupCmcdHeaders } from './groupCmcdHeaders.ts'\nimport { prepareCmcdData } from './prepareCmcdData.ts'\n\n/**\n * Convert a CMCD data object to request headers\n *\n * @param cmcd - The CMCD data object to convert.\n * @param options - Options for encoding the CMCD object.\n *\n * @returns The CMCD header shards.\n *\n *\n * @beta\n *\n * @example\n * {@includeCode ../test/toCmcdHeaders.test.ts#example}\n */\nexport function toCmcdHeaders(cmcd: CmcdData, options: CmcdEncodeOptions = {}): Record<CmcdHeaderField, string> {\n\tconst result = {} as Record<CmcdHeaderField, string>\n\n\tif (!cmcd) {\n\t\treturn result\n\t}\n\n\tconst data = prepareCmcdData(cmcd, options)\n\tconst shards = groupCmcdHeaders(data, options?.customHeaderMap)\n\n\treturn Object.entries(shards)\n\t\t.reduce((acc, [field, value]) => {\n\t\t\tconst shard = encodeSfDict(value, { whitespace: false })\n\t\t\tif (shard) {\n\t\t\t\tacc[field as CmcdHeaderField] = shard\n\t\t\t}\n\t\t\treturn acc\n\t\t}, result)\n}\n","import type { Cmcd } from './Cmcd.ts'\nimport type { CmcdEncodeOptions } from './CmcdEncodeOptions.ts'\nimport { toCmcdHeaders } from './toCmcdHeaders.ts'\n\n/**\n * Append CMCD query args to a header object.\n *\n * @param headers - The headers to append to.\n * @param cmcd - The CMCD object to append.\n * @param options - Encode options.\n *\n * @returns The headers with the CMCD header shards appended.\n *\n *\n * @beta\n *\n * @example\n * {@includeCode ../test/appendCmcdHeaders.test.ts#example}\n */\nexport function appendCmcdHeaders(headers: Record<string, string>, cmcd: Cmcd, options?: CmcdEncodeOptions): Record<string, string> {\n\treturn Object.assign(headers, toCmcdHeaders(cmcd, options))\n}\n","/**\n * CMCD parameter name.\n *\n *\n * @beta\n */\nexport const CMCD_PARAM = 'CMCD'\n","import { encodeSfDict } from '@svta/cml-structured-field-values'\nimport type { CmcdData } from './CmcdData.ts'\nimport type { CmcdEncodeOptions } from './CmcdEncodeOptions.ts'\nimport { prepareCmcdData } from './prepareCmcdData.ts'\n\n/**\n * Encode a CMCD object to a string.\n *\n * @param cmcd - The CMCD object to encode.\n * @param options - Options for encoding.\n *\n * @returns The encoded CMCD string.\n *\n *\n * @beta\n *\n * @example\n * {@includeCode ../test/encodeCmcd.test.ts#example}\n */\nexport function encodeCmcd(cmcd: CmcdData, options: CmcdEncodeOptions = {}): string {\n\tif (!cmcd) {\n\t\treturn ''\n\t}\n\n\treturn encodeSfDict(prepareCmcdData(cmcd, options), { whitespace: false })\n}\n","import type { Cmcd } from './Cmcd.ts'\nimport type { CmcdEncodeOptions } from './CmcdEncodeOptions.ts'\nimport { encodeCmcd } from './encodeCmcd.ts'\n\n/**\n * Convert a CMCD data object to a URL encoded string.\n *\n * @param cmcd - The CMCD object to convert.\n * @param options - Options for encoding the CMCD object.\n *\n * @returns The URL encoded CMCD data.\n *\n *\n * @beta\n */\nexport function toCmcdUrl(cmcd: Cmcd, options: CmcdEncodeOptions = {}): string {\n\tif (!cmcd) {\n\t\treturn ''\n\t}\n\n\tconst params = encodeCmcd(cmcd, options)\n\n\treturn encodeURIComponent(params)\n}\n","import { CMCD_PARAM } from './CMCD_PARAM.ts'\nimport type { Cmcd } from './Cmcd.ts'\nimport type { CmcdEncodeOptions } from './CmcdEncodeOptions.ts'\nimport { toCmcdUrl } from './toCmcdUrl.ts'\n\n/**\n * Convert a CMCD data object to a query arg.\n *\n * @param cmcd - The CMCD object to convert.\n * @param options - Options for encoding the CMCD object.\n *\n * @returns The CMCD query arg.\n *\n *\n * @beta\n *\n * @example\n * {@includeCode ../test/toCmcdQuery.test.ts#example}\n */\nexport function toCmcdQuery(cmcd: Cmcd, options: CmcdEncodeOptions = {}): string {\n\tif (!cmcd) {\n\t\treturn ''\n\t}\n\n\tconst value = toCmcdUrl(cmcd, options)\n\n\treturn `${CMCD_PARAM}=${value}`\n}\n","import type { Cmcd } from './Cmcd.ts'\nimport type { CmcdEncodeOptions } from './CmcdEncodeOptions.ts'\nimport { toCmcdQuery } from './toCmcdQuery.ts'\n\nconst REGEX = /CMCD=[^&#]+/\n\n/**\n * Append CMCD query args to a URL.\n *\n * @param url - The URL to append to.\n * @param cmcd - The CMCD object to append.\n * @param options - Options for encoding the CMCD object.\n *\n * @returns The URL with the CMCD query args appended.\n *\n *\n * @beta\n *\n * @example\n * {@includeCode ../test/appendCmcdQuery.test.ts#example}\n */\nexport function appendCmcdQuery(url: string, cmcd: Cmcd, options?: CmcdEncodeOptions): string {\n\t// TODO: Replace with URLSearchParams once we drop Safari < 10.1 & Chrome < 49 support.\n\t// https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams\n\n\tconst query = toCmcdQuery(cmcd, options)\n\tif (!query) {\n\t\treturn url\n\t}\n\n\tif (REGEX.test(url)) {\n\t\treturn url.replace(REGEX, query)\n\t}\n\n\tconst separator = url.includes('?') ? '&' : '?'\n\treturn `${url}${separator}${query}`\n}\n","/**\n * The default time interval in secondswhen using using event mode\n *\n *\n * @beta\n */\nexport const CMCD_DEFAULT_TIME_INTERVAL = 30\n","/**\n * CMCD `headers` transmission mode.\n *\n *\n * @beta\n */\nexport const CMCD_HEADERS = 'headers'\n","/**\n * CMCD `json` transmission mode.\n *\n *\n * @beta\n *\n * @deprecated JSON transmission mode is deprecated and will be removed in future versions.\n */\nexport const CMCD_JSON = 'json'\n","import { CMCD_COMMON_KEYS } from './CMCD_COMMON_KEYS.ts'\nimport { CMCD_EVENT_KEYS } from './CMCD_EVENT_KEYS.ts'\nimport { CMCD_REQUEST_KEYS } from './CMCD_REQUEST_KEYS.ts'\nimport { CMCD_RESPONSE_KEYS } from './CMCD_RESPONSE_KEYS.ts'\nimport { CMCD_V1_KEYS } from './CMCD_V1_KEYS.ts'\nimport type { CmcdKey } from './CmcdKey.ts'\n\nconst keySet = new Set([...CMCD_V1_KEYS, ...CMCD_COMMON_KEYS, ...CMCD_REQUEST_KEYS, ...CMCD_RESPONSE_KEYS, ...CMCD_EVENT_KEYS])\n\n/**\n * A list of all CMCD keys.\n *\n *\n * @beta\n */\nexport const CMCD_KEYS: CmcdKey[] = Array.from(keySet)\n","/**\n * CMCD `query` transmission mode.\n *\n *\n * @beta\n */\nexport const CMCD_QUERY = 'query'\n","/**\n * CMCD Version 1\n *\n *\n * @beta\n */\nexport const CMCD_V1 = 1\n","/**\n * CMCD Version 2\n *\n *\n * @beta\n */\nexport const CMCD_V2 = 2\n","import type { ValueOf } from '@svta/cml-utils'\nimport { CMCD_HEADERS } from './CMCD_HEADERS.ts'\nimport { CMCD_JSON } from './CMCD_JSON.ts'\nimport { CMCD_QUERY } from './CMCD_QUERY.ts'\n\n/**\n * CMCD transmission modes.\n *\n *\n * @enum\n *\n * @beta\n */\nexport const CmcdTransmissionMode = {\n\t/**\n\t * JSON\n\t *\n\t * @deprecated JSON transmission mode is deprecated and will be removed in future versions.\n\t */\n\tJSON: CMCD_JSON as typeof CMCD_JSON,\n\n\t/**\n\t * Query string\n\t */\n\tQUERY: CMCD_QUERY as typeof CMCD_QUERY,\n\n\t/**\n\t * Request headers\n\t */\n\tHEADERS: CMCD_HEADERS as typeof CMCD_HEADERS,\n\n} as const\n\n/**\n * @beta\n */\nexport type CmcdTransmissionMode = ValueOf<typeof CmcdTransmissionMode>;\n","import type { ValueOf } from '@svta/cml-utils'\nimport { CmcdTransmissionMode } from './CmcdTransmissionMode.ts'\n\n/**\n * CMCD encoding types.\n *\n *\n * @enum\n *\n * @beta\n *\n * @deprecated Use {@link CmcdTransmissionMode} instead.\n *\n * @see {@link CmcdTransmissionMode}\n */\nexport const CmcdEncoding: typeof CmcdTransmissionMode = CmcdTransmissionMode\n\n/**\n * @beta\n */\nexport type CmcdEncoding = ValueOf<typeof CmcdEncoding>;\n","import type { ValueOf } from '@svta/cml-utils'\n\n/**\n * CMCD event types for the 'e' key (event mode).\n *\n *\n * @enum\n *\n * @beta\n */\nexport const CmcdEventType = {\n\t/**\n\t * A change in the player state.\n\t */\n\tPLAY_STATE: 'ps',\n\n\t/**\n\t * An error event.\n\t */\n\tERROR: 'e',\n\n\t/**\n\t * A periodic report sent on a time interval.\n\t */\n\tTIME_INTERVAL: 't',\n\n\t/**\n\t * A change of the content ID.\n\t */\n\tCONTENT_ID: 'c',\n\n\t/**\n\t * A change in the application's backgrounded state.\n\t */\n\tBACKGROUNDED_MODE: 'b',\n\n\t/**\n\t * The player was muted.\n\t */\n\tMUTE: 'm',\n\n\t/**\n\t * Player unmuted.\n\t */\n\tUNMUTE: 'um',\n\n\t/**\n\t * The player view was expanded.\n\t */\n\tPLAYER_EXPAND: 'pe',\n\n\t/**\n\t * The player view was collapsed.\n\t */\n\tPLAYER_COLLAPSE: 'pc',\n} as const\n\n/**\n * @beta\n */\nexport type CmcdEventType = ValueOf<typeof CmcdEventType>;\n","import { CMCD_FORMATTER_MAP } from './CMCD_FORMATTER_MAP.ts'\nimport type { CmcdFormatter } from './CmcdFormatter.ts'\n\n/**\n * The default formatters for CMCD values.\n *\n *\n * @beta\n *\n * @deprecated Use `CMCD_FORMATTER_MAP` instead.\n */\nexport const CmcdFormatters: Record<string, CmcdFormatter> = CMCD_FORMATTER_MAP\n","import { CmObjectType } from '@svta/cml-cta'\n\n/**\n * Common Media Client Data Object Type\n *\n *\n * @beta\n *\n * @enum\n */\nexport const CmcdObjectType = CmObjectType as typeof CmObjectType\n\n/**\n * @beta\n */\nexport type CmcdObjectType = CmObjectType;\n","import type { ValueOf } from '@svta/cml-utils'\n\n/**\n * CMCD v2 player states for the 'sta' key.\n *\n *\n * @enum\n *\n * @beta\n */\nexport const CmcdPlayerState = {\n\t/**\n\t * Starting: Initial startup of the player.\n\t */\n\tSTARTING: 's',\n\n\t/**\n\t * Playing: The player is actively rendering content.\n\t */\n\tPLAYING: 'p',\n\n\t/**\n\t * Seeking: The player is seeking to a new position.\n\t */\n\tSEEKING: 'k',\n\n\t/**\n\t * Rebuffering: The player is buffering data during playback.\n\t */\n\tREBUFFERING: 'r',\n\n\t/**\n\t * Paused: The player is paused.\n\t */\n\tPAUSED: 'a',\n\n\t/**\n\t * Waiting: The player is waiting for a user action or another event.\n\t */\n\tWAITING: 'w',\n\n\t/**\n\t * Ended: The media has finished playing.\n\t */\n\tENDED: 'e',\n\n\t/**\n\t * Fatal Error: The player has encountered a fatal error.\n\t */\n\tFATAL_ERROR: 'f',\n\n\t/**\n\t * Quit: User initiated end of playback before media asset completion.\n\t */\n\tQUIT: 'q',\n\n\t/**\n\t * Preloading: The player is loading assets ahead of starting in order to provide a fast startup. The expectation is that playback will commence at a future time.\n\t */\n\tPRELOADING: 'd',\n} as const\n\n/**\n * @beta\n */\nexport type CmcdPlayerState = ValueOf<typeof CmcdPlayerState>;\n","import type { ValueOf } from '@svta/cml-utils'\nimport { CMCD_EVENT_MODE } from './CMCD_EVENT_MODE.ts'\nimport { CMCD_REQUEST_MODE } from './CMCD_REQUEST_MODE.ts'\nimport { CMCD_RESPONSE_MODE } from './CMCD_RESPONSE_MODE.ts'\n\n/**\n * CMCD reporting mode types.\n *\n *\n * @enum\n *\n * @beta\n */\nexport const CmcdReportingMode = {\n\t/**\n\t * Request mode\n\t */\n\tREQUEST: CMCD_REQUEST_MODE as typeof CMCD_REQUEST_MODE,\n\n\t/**\n\t * Response mode\n\t */\n\tRESPONSE: CMCD_RESPONSE_MODE as typeof CMCD_RESPONSE_MODE,\n\n\t/**\n\t * Event mode\n\t */\n\tEVENT: CMCD_EVENT_MODE as typeof CMCD_EVENT_MODE,\n} as const\n\n/**\n * @beta\n */\nexport type CmcdReportingMode = ValueOf<typeof CmcdReportingMode>;\n","import { CmStreamingFormat } from '@svta/cml-cta'\n\n/**\n * Common Media Client Data Streaming Format\n *\n *\n * @enum\n *\n * @beta\n */\nexport const CmcdStreamingFormat = CmStreamingFormat as typeof CmStreamingFormat\n\n/**\n * @beta\n */\nexport type CmcdStreamingFormat = CmStreamingFormat;\n","import { CmStreamType } from '@svta/cml-cta'\n\n/**\n * Common Media Client Data Stream Type\n *\n *\n * @enum\n *\n * @beta\n */\nexport const CmcdStreamType = CmStreamType as typeof CmStreamType\n\n/**\n * @beta\n */\nexport type CmcdStreamType = CmStreamType;\n","import type { SfBareItem } from '@svta/cml-structured-field-values'\nimport { decodeSfDict, SfItem, symbolToStr } from '@svta/cml-structured-field-values'\nimport type { CmcdData } from './CmcdData.ts'\nimport type { CmcdValue } from './CmcdValue.ts'\n\n// Define the input type for reduceValue\ntype ReduceValueInput = SfBareItem | SfItem | ReduceValueInput[];\n\n// Define the output type for reduceValue - matches what CMCD values can be, including arrays\ntype ReduceValueOutput = CmcdValue | ReduceValueOutput[];\n\nfunction reduceValue(value: ReduceValueInput): ReduceValueOutput {\n\tif (Array.isArray(value)) {\n\t\treturn value.map(reduceValue)\n\t}\n\n\tif (typeof value === 'symbol') {\n\t\treturn symbolToStr(value)\n\t}\n\n\tif (value instanceof SfItem && !value.params) {\n\t\treturn reduceValue(value.value)\n\t}\n\n\tif (typeof value === 'string') {\n\t\treturn decodeURIComponent(value)\n\t}\n\n\treturn value as ReduceValueOutput\n};\n\n/**\n * Decode a CMCD string to an object.\n *\n * @param cmcd - The CMCD string to decode.\n *\n * @returns The decoded CMCD object.\n *\n *\n * @beta\n *\n * @example\n * {@includeCode ../test/decodeCmcd.test.ts#example}\n */\nexport function decodeCmcd<T extends CmcdData = CmcdData>(cmcd: string): T {\n\tif (!cmcd) {\n\t\treturn {} as T\n\t}\n\n\tconst sfDict = decodeSfDict(cmcd)\n\n\treturn Object\n\t\t.entries<SfItem>(sfDict as any)\n\t\t.reduce((acc, [key, item]) => {\n\t\t\tacc[key as keyof T] = reduceValue(item.value) as T[keyof T]\n\t\t\treturn acc\n\t\t}, {} as T)\n}\n","import { CMCD_OBJECT } from './CMCD_OBJECT.ts'\nimport { CMCD_REQUEST } from './CMCD_REQUEST.ts'\nimport { CMCD_SESSION } from './CMCD_SESSION.ts'\nimport { CMCD_STATUS } from './CMCD_STATUS.ts'\nimport type { CmcdData } from './CmcdData.ts'\nimport { decodeCmcd } from './decodeCmcd.ts'\n\nconst keys = [CMCD_OBJECT, CMCD_REQUEST, CMCD_SESSION, CMCD_STATUS]\n\n/**\n * Decode CMCD data from request headers.\n *\n * @param headers - The request headers to decode.\n *\n * @returns The decoded CMCD data.\n *\n *\n * @beta\n *\n * @example\n * {@includeCode ../test/fromCmcdHeaders.test.ts#example}\n */\nexport function fromCmcdHeaders(headers: Record<string, string> | Headers): CmcdData {\n\tif (!(headers instanceof Headers)) {\n\t\theaders = new Headers(headers)\n\t}\n\n\treturn keys.reduce((acc, key) => {\n\t\tconst value = headers.get(key)\n\t\treturn Object.assign(acc, decodeCmcd(value as string))\n\t}, {} as CmcdData)\n}\n","import type { Cmcd } from './Cmcd.ts'\nimport { CMCD_PARAM } from './CMCD_PARAM.ts'\nimport { decodeCmcd } from './decodeCmcd.ts'\n\n/**\n * Decode CMCD data from a query string.\n *\n * @param query - The query string to decode.\n *\n * @returns The decoded CMCD data.\n *\n *\n * @beta\n *\n * @example\n * {@includeCode ../test/fromCmcdQuery.test.ts#example}\n */\nexport function fromCmcdQuery(query: string | URLSearchParams): Cmcd {\n\tif (typeof query === 'string') {\n\t\tquery = new URLSearchParams(query)\n\t}\n\n\tconst value = query.get(CMCD_PARAM)\n\n\treturn decodeCmcd(value as string)\n}\n","import type { Cmcd } from './Cmcd.ts'\nimport { decodeCmcd } from './decodeCmcd.ts'\n\n/**\n * Decode CMCD data from a url encoded string.\n *\n * @param url - The url encoded string to decode.\n *\n * @returns The decoded CMCD data.\n *\n *\n * @beta\n *\n * @example\n * {@includeCode ../test/fromCmcdUrl.test.ts#example}\n */\nexport function fromCmcdUrl(url: string): Cmcd {\n\treturn decodeCmcd(decodeURIComponent(url.replace(/^CMCD=/, '')))\n}\n","import { SfToken, symbolToStr } from '@svta/cml-structured-field-values'\nimport type { Cmcd } from './Cmcd.ts'\nimport type { CmcdEncodeOptions } from './CmcdEncodeOptions.ts'\nimport { prepareCmcdData } from './prepareCmcdData.ts'\n\n/**\n * Convert a CMCD data object to JSON.\n *\n * @param cmcd - The CMCD object to convert.\n * @param options - Options for encoding the CMCD object.\n *\n * @returns The CMCD JSON.\n *\n *\n * @beta\n *\n * @deprecated Sending CMCD as JSON objects is deprecated. Use `toCmcdUrl` to create an array of url strings instead.\n */\nexport function toCmcdJson(cmcd: Cmcd, options?: CmcdEncodeOptions): string {\n\tconst data = prepareCmcdData(cmcd, options)\n\n\treturn JSON.stringify(data, (_, value) => typeof value === 'symbol' || value instanceof SfToken ? symbolToStr(value) : value)\n}\n","import type { Request } from '@svta/cml-utils'\nimport type { Cmcd } from './Cmcd.ts'\nimport { CMCD_HEADERS } from './CMCD_HEADERS.ts'\nimport { CMCD_PARAM } from './CMCD_PARAM.ts'\nimport { CMCD_QUERY } from './CMCD_QUERY.ts'\nimport type { CmcdData } from './CmcdData.ts'\nimport type { CmcdEncodeOptions } from './CmcdEncodeOptions.ts'\nimport type { CmcdKey } from './CmcdKey.ts'\nimport type { CmcdReportTarget } from './CmcdReportTarget.ts'\nimport { encodeCmcd } from './encodeCmcd.ts'\nimport { toCmcdHeaders } from './toCmcdHeaders.ts'\n\n/**\n * Converts CMCD data into a report format.\n *\n * @param data - The CMCD data to be transformed into a report\n * @param target - The target configuration for the CMCD report\n *\n * @return A CMCD report object\n *\n *\n * @beta\n *\n * @example\n * {@includeCode ../test/toCmcdReport.test.ts#example}\n */\nexport function toCmcdReport(data: CmcdData, target: CmcdReportTarget): Request<{ cmcd: Cmcd }> | null {\n\tif (!target || !target.url) {\n\t\treturn null\n\t}\n\n\tconst url = new URL(target.url)\n\tconst method = target.method || 'GET'\n\tconst headers = {}\n\tconst transimissionMode = target.transmissionMode || CMCD_QUERY\n\tconst options: CmcdEncodeOptions = {\n\t\tversion: target.version,\n\t\treportingMode: target.reportingMode,\n\t}\n\n\tconst { enabledKeys } = target\n\tif (enabledKeys) {\n\t\toptions.filter = (key: CmcdKey) => enabledKeys.includes(key)\n\t}\n\n\tswitch (transimissionMode) {\n\t\tcase CMCD_QUERY:\n\t\t\tconst param = encodeCmcd(data, options)\n\t\t\tif (param) {\n\t\t\t\turl.searchParams.set(CMCD_PARAM, param)\n\t\t\t}\n\t\t\tbreak\n\n\t\tcase CMCD_HEADERS:\n\t\t\tObject.assign(headers, toCmcdHeaders(data, options))\n\t\t\tbreak\n\t}\n\n\treturn {\n\t\turl: url.toString(),\n\t\tmethod,\n\t\theaders,\n\t}\n}\n"],"mappings":";;;;;;;;;;;AAMA,MAAa,cAAc;;;;;;;;;;ACA3B,MAAa,eAAe;;;;;;;;;;ACA5B,MAAa,eAAe;;;;;;;;;;ACA5B,MAAa,cAAc;;;;;;;;;;ACO3B,MAAaA,kBAAoD;CAEhE,IAAI;CACJ,IAAI;CACJ,GAAG;CACH,IAAI;CACJ,IAAI;CACJ,KAAK;CACL,IAAI;CACJ,KAAK;CACL,KAAK;CACL,KAAK;CAGL,IAAI;CACJ,IAAI;CACJ,KAAK;CACL,IAAI;CACJ,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,IAAI;CACJ,IAAI;CACJ,KAAK;CACL,IAAI;CACJ,MAAM;CACN,OAAO;CACP,MAAM;CACN,OAAO;CACP,OAAO;CACP,MAAM;CACN,IAAI;CACJ,IAAI;CAGJ,IAAI;CAGJ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WAAW,CAED;;;;;;;;;;;;;;;;;;ACRnC,SAAgB,YAAY,KAAmB;AAC9C,QAAO,WAAW,mBAAmB,IAAI,QAAQ,UAAU,GAAG,CAAC,CAAC;;;;;;;;;;;;;;;;;;ACCjE,SAAgB,WAAW,MAAY,SAAqC;CAC3E,MAAM,OAAO,gBAAgB,MAAM,QAAQ;AAE3C,QAAO,KAAK,UAAU,OAAO,GAAG,UAAU,OAAO,UAAU,YAAY,iBAAiB,UAAU,YAAY,MAAM,GAAG,MAAM;;;;;;;;;;;;;;;;;;;ACK9H,SAAgB,aAAa,MAAgB,QAA0D;AACtG,KAAI,CAAC,UAAU,CAAC,OAAO,IACtB,QAAO;CAGR,MAAM,MAAM,IAAI,IAAI,OAAO,IAAI;CAC/B,MAAM,SAAS,OAAO,UAAU;CAChC,MAAM,UAAU,EAAE;CAClB,MAAM,oBAAoB,OAAO,oBAAoB;CACrD,MAAMC,UAA6B;EAClC,SAAS,OAAO;EAChB,eAAe,OAAO;EACtB;CAED,MAAM,EAAE,gBAAgB;AACxB,KAAI,YACH,SAAQ,UAAU,QAAiB,YAAY,SAAS,IAAI;AAG7D,SAAQ,mBAAR;EACC,KAAK;GACJ,MAAM,QAAQ,WAAW,MAAM,QAAQ;AACvC,OAAI,MACH,KAAI,aAAa,IAAI,YAAY,MAAM;AAExC;EAED,KAAK;AACJ,UAAO,OAAO,SAAS,cAAc,MAAM,QAAQ,CAAC;AACpD;;AAGF,QAAO;EACN,KAAK,IAAI,UAAU;EACnB;EACA;EACA"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["CMCD_HEADER_MAP: Record<CmcdKey, CmcdHeaderField>","keys","CMCD_FORMATTER_MAP: Record<string, CmcdFormatter>","results: CmcdData","keys","formatterOptions: CmcdFormatterOptions","CMCD_KEYS: CmcdKey[]","CmcdEncoding: typeof CmcdTransmissionMode","CmcdFormatters: Record<string, CmcdFormatter>","options: CmcdEncodeOptions"],"sources":["../src/CMCD_OBJECT.ts","../src/CMCD_REQUEST.ts","../src/CMCD_SESSION.ts","../src/CMCD_STATUS.ts","../src/CMCD_HEADER_MAP.ts","../src/CmcdHeaderField.ts","../src/groupCmcdHeaders.ts","../src/CMCD_EVENT_MODE.ts","../src/CMCD_FORMATTER_MAP.ts","../src/CMCD_REQUEST_MODE.ts","../src/CMCD_COMMON_KEYS.ts","../src/CMCD_EVENT_KEYS.ts","../src/CMCD_RESPONSE_KEYS.ts","../src/isCmcdCustomKey.ts","../src/isCmcdEventKey.ts","../src/CMCD_REQUEST_KEYS.ts","../src/isCmcdRequestKey.ts","../src/isCmcdResponseReceivedKey.ts","../src/CMCD_V1_KEYS.ts","../src/isCmcdV1Key.ts","../src/prepareCmcdData.ts","../src/toCmcdHeaders.ts","../src/appendCmcdHeaders.ts","../src/CMCD_PARAM.ts","../src/encodeCmcd.ts","../src/toCmcdUrl.ts","../src/toCmcdQuery.ts","../src/appendCmcdQuery.ts","../src/CMCD_DEFAULT_TIME_INTERVAL.ts","../src/CMCD_HEADERS.ts","../src/CMCD_JSON.ts","../src/CMCD_KEYS.ts","../src/CMCD_QUERY.ts","../src/CMCD_RESPONSE_MODE.ts","../src/CMCD_V1.ts","../src/CMCD_V2.ts","../src/CmcdTransmissionMode.ts","../src/CmcdEncoding.ts","../src/CmcdEventType.ts","../src/CmcdFormatters.ts","../src/CmcdObjectType.ts","../src/CmcdPlayerState.ts","../src/CmcdReportingMode.ts","../src/CmcdStreamingFormat.ts","../src/CmcdStreamType.ts","../src/decodeCmcd.ts","../src/fromCmcdHeaders.ts","../src/fromCmcdQuery.ts","../src/fromCmcdUrl.ts","../src/toCmcdJson.ts","../src/toCmcdReport.ts"],"sourcesContent":["/**\n * CMCD object header name.\n *\n *\n * @beta\n */\nexport const CMCD_OBJECT = 'CMCD-Object'\n","/**\n * CMCD request header name.\n *\n *\n * @beta\n */\nexport const CMCD_REQUEST = 'CMCD-Request'\n","/**\n * CMCD session header name.\n *\n *\n * @beta\n */\nexport const CMCD_SESSION = 'CMCD-Session'\n","/**\n * CMCD status header name.\n *\n *\n * @beta\n */\nexport const CMCD_STATUS = 'CMCD-Status'\n","import { CMCD_OBJECT } from './CMCD_OBJECT.ts'\nimport { CMCD_REQUEST } from './CMCD_REQUEST.ts'\nimport { CMCD_SESSION } from './CMCD_SESSION.ts'\nimport { CMCD_STATUS } from './CMCD_STATUS.ts'\nimport type { CmcdHeaderField } from './CmcdHeaderField.ts'\nimport type { CmcdKey } from './CmcdKey.ts'\n\n/**\n * The map of CMCD keys to their appropriate header shard.\n *\n *\n * @internal\n */\nexport const CMCD_HEADER_MAP: Record<CmcdKey, CmcdHeaderField> = {\n\t// Object\n\tbr: CMCD_OBJECT,\n\tab: CMCD_OBJECT,\n\td: CMCD_OBJECT,\n\tot: CMCD_OBJECT,\n\ttb: CMCD_OBJECT,\n\ttpb: CMCD_OBJECT,\n\tlb: CMCD_OBJECT,\n\ttab: CMCD_OBJECT,\n\tlab: CMCD_OBJECT,\n\turl: CMCD_OBJECT,\n\n\t// Request\n\tpb: CMCD_REQUEST,\n\tbl: CMCD_REQUEST,\n\ttbl: CMCD_REQUEST,\n\tdl: CMCD_REQUEST,\n\tltc: CMCD_REQUEST,\n\tmtp: CMCD_REQUEST,\n\tnor: CMCD_REQUEST,\n\tnrr: CMCD_REQUEST,\n\trc: CMCD_REQUEST,\n\tsn: CMCD_REQUEST,\n\tsta: CMCD_REQUEST,\n\tsu: CMCD_REQUEST,\n\tttfb: CMCD_REQUEST,\n\tttfbb: CMCD_REQUEST,\n\tttlb: CMCD_REQUEST,\n\tcmsdd: CMCD_REQUEST,\n\tcmsds: CMCD_REQUEST,\n\tsmrt: CMCD_REQUEST,\n\tdf: CMCD_REQUEST,\n\tcs: CMCD_REQUEST,\n\n\t// TODO: Which header to put the `ts` field is not defined yet.\n\tts: CMCD_REQUEST,\n\n\t// Session\n\tcid: CMCD_SESSION,\n\tpr: CMCD_SESSION,\n\tsf: CMCD_SESSION,\n\tsid: CMCD_SESSION,\n\tst: CMCD_SESSION,\n\tv: CMCD_SESSION,\n\tmsd: CMCD_SESSION,\n\n\t// Status\n\tbs: CMCD_STATUS,\n\tbsd: CMCD_STATUS,\n\tcdn: CMCD_STATUS,\n\trtp: CMCD_STATUS,\n\tbg: CMCD_STATUS,\n\tpt: CMCD_STATUS,\n\tec: CMCD_STATUS,\n\te: CMCD_STATUS,\n}\n","import type { ValueOf } from '@svta/cml-utils'\nimport { CMCD_OBJECT } from './CMCD_OBJECT.ts'\nimport { CMCD_REQUEST } from './CMCD_REQUEST.ts'\nimport { CMCD_SESSION } from './CMCD_SESSION.ts'\nimport { CMCD_STATUS } from './CMCD_STATUS.ts'\n\n/**\n * CMCD header fields.\n *\n *\n * @enum\n *\n * @beta\n */\nexport const CmcdHeaderField = {\n\t/**\n\t * keys whose values vary with the object being requested.\n\t */\n\tOBJECT: CMCD_OBJECT as typeof CMCD_OBJECT,\n\n\t/**\n\t * keys whose values vary with each request.\n\t */\n\tREQUEST: CMCD_REQUEST as typeof CMCD_REQUEST,\n\n\t/**\n\t * keys whose values are expected to be invariant over the life of the session.\n\t */\n\tSESSION: CMCD_SESSION as typeof CMCD_SESSION,\n\n\t/**\n\t * keys whose values do not vary with every request or object.\n\t */\n\tSTATUS: CMCD_STATUS as typeof CMCD_STATUS,\n} as const\n\n/**\n * @beta\n */\nexport type CmcdHeaderField = ValueOf<typeof CmcdHeaderField>;\n","import { CMCD_HEADER_MAP } from './CMCD_HEADER_MAP.ts'\nimport type { CmcdData } from './CmcdData.ts'\nimport { CmcdHeaderField } from './CmcdHeaderField.ts'\nimport type { CmcdHeaderMap } from './CmcdHeaderMap.ts'\nimport type { CmcdKey } from './CmcdKey.ts'\n\nfunction createHeaderMap(headerMap: Partial<CmcdHeaderMap>): Record<CmcdKey, CmcdHeaderField> {\n\treturn Object.keys(headerMap)\n\t\t.reduce((acc, field) => {\n\t\t\theaderMap[field as CmcdHeaderField]?.forEach(key => acc[key] = field as CmcdHeaderField)\n\t\t\treturn acc\n\t\t}, {} as Record<CmcdKey, CmcdHeaderField>)\n}\n\n/**\n * Group a CMCD data object into header shards\n *\n * @param cmcd - The CMCD data object to convert.\n * @param customHeaderMap - A map of CMCD header fields to custom CMCD keys.\n *\n * @returns The CMCD header shards.\n *\n *\n * @beta\n */\nexport function groupCmcdHeaders(cmcd: CmcdData, customHeaderMap?: Partial<CmcdHeaderMap>): Record<CmcdHeaderField, CmcdData> {\n\tconst result = {} as Record<CmcdHeaderField, CmcdData>\n\n\tif (!cmcd) {\n\t\treturn result\n\t}\n\n\tconst keys = Object.keys(cmcd) as CmcdKey[]\n\tconst custom = customHeaderMap ? createHeaderMap(customHeaderMap) : {} as Record<CmcdKey, CmcdHeaderField>\n\n\treturn keys.reduce((acc: Record<CmcdHeaderField, CmcdData>, key: CmcdKey) => {\n\t\tconst field = CMCD_HEADER_MAP[key] || custom[key] || CmcdHeaderField.REQUEST\n\t\tconst data = acc[field] ??= {};\n\t\t(data as any)[key] = cmcd[key]\n\t\treturn acc\n\t}, result)\n}\n","/**\n * CMCD event mode variable name.\n *\n *\n * @beta\n */\nexport const CMCD_EVENT_MODE = 'event'\n","import { SfItem } from '@svta/cml-structured-field-values'\nimport { urlToRelativePath, type ValueOrArray } from '@svta/cml-utils'\nimport type { CmcdFormatter } from './CmcdFormatter.ts'\nimport type { CmcdFormatterOptions } from './CmcdFormatterOptions.ts'\nimport type { CmcdValue } from './CmcdValue.ts'\n\nconst toRounded = (value: CmcdValue) => Math.round(value as number)\n\nconst toUrlSafe = (value: CmcdValue, options: CmcdFormatterOptions): ValueOrArray<string> | ValueOrArray<SfItem> => {\n\tif (Array.isArray(value)) {\n\t\treturn value.map(item => toUrlSafe(item, options) as string)\n\t}\n\n\tif (value instanceof SfItem && typeof value.value === 'string') {\n\t\treturn new SfItem(toUrlSafe(value.value, options), value.params)\n\t}\n\telse {\n\t\tif (options.baseUrl) {\n\t\t\tvalue = urlToRelativePath(value as string, options.baseUrl)\n\t\t}\n\t\treturn options.version === 1 ? encodeURIComponent(value as string) : (value as string)\n\t}\n}\n\nconst toHundred = (value: CmcdValue) => toRounded(value as number / 100) * 100\n\nconst nor = (value: CmcdValue, options: CmcdFormatterOptions) => {\n\tlet norValue = value\n\n\tif (options.version >= 2) {\n\t\tif (value instanceof SfItem && typeof value.value === 'string') {\n\t\t\tnorValue = new SfItem([value])\n\t\t}\n\t\telse if (typeof value === 'string') {\n\t\t\tnorValue = [value]\n\t\t}\n\t}\n\n\treturn toUrlSafe(norValue, options)\n}\n\n/**\n * The default formatters for CMCD values.\n *\n *\n * @beta\n */\nexport const CMCD_FORMATTER_MAP: Record<string, CmcdFormatter> = {\n\t/**\n\t * Bitrate (kbps) rounded integer\n\t */\n\tbr: toRounded,\n\n\t/**\n\t * Duration (milliseconds) rounded integer\n\t */\n\td: toRounded,\n\n\t/**\n\t * Buffer Length (milliseconds) rounded nearest 100ms\n\t */\n\tbl: toHundred,\n\n\t/**\n\t * Deadline (milliseconds) rounded nearest 100ms\n\t */\n\tdl: toHundred,\n\n\t/**\n\t * Measured Throughput (kbps) rounded nearest 100kbps\n\t */\n\tmtp: toHundred,\n\n\t/**\n\t * Next Object Request URL encoded\n\t */\n\tnor,\n\n\t/**\n\t * Requested maximum throughput (kbps) rounded nearest 100kbps\n\t */\n\trtp: toHundred,\n\n\t/**\n\t * Top Bitrate (kbps) rounded integer\n\t */\n\ttb: toRounded,\n} as const\n","/**\n * CMCD request mode variable name.\n *\n *\n * @beta\n */\nexport const CMCD_REQUEST_MODE = 'request'\n","/**\n * Defines the common keys for CMCD (Common Media Client Data) version 2.\n *\n *\n * @beta\n */\nexport const CMCD_COMMON_KEYS = [\n\t'ab',\n\t'bg',\n\t'bl',\n\t'br',\n\t'bs',\n\t'bsd',\n\t'cdn',\n\t'cid',\n\t'cs',\n\t'df',\n\t'ec',\n\t'lab',\n\t'lb',\n\t'ltc',\n\t'msd',\n\t'mtp',\n\t'pb',\n\t'pr',\n\t'pt',\n\t'sf',\n\t'sid',\n\t'sn',\n\t'st',\n\t'sta',\n\t'tab',\n\t'tb',\n\t'tbl',\n\t'tpb',\n\t'ts',\n\t'v',\n] as const\n","/**\n * Defines the event-specific keys for CMCD (Common Media Client Data) version 2.\n *\n *\n * @beta\n */\nexport const CMCD_EVENT_KEYS = [\n\t'e',\n] as const\n","/**\n * CMCD v2 - Response-only and timing keys.\n *\n *\n * @beta\n */\nexport const CMCD_RESPONSE_KEYS = [\n\t'cmsdd',\n\t'cmsds',\n\t'rc',\n\t'smrt',\n\t'ttfb',\n\t'ttfbb',\n\t'ttlb',\n\t'url',\n] as const\n","import type { CmcdKey } from './CmcdKey.ts'\n\nconst CUSTOM_KEY_REGEX = /^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/\n\n/**\n * Check if a key is a custom key.\n *\n * @param key - The key to check.\n *\n * @returns `true` if the key is a custom key, `false` otherwise.\n *\n *\n * @beta\n */\nexport function isCmcdCustomKey(key: CmcdKey): boolean {\n\treturn CUSTOM_KEY_REGEX.test(key)\n}\n","import { CMCD_COMMON_KEYS } from './CMCD_COMMON_KEYS.ts'\nimport { CMCD_EVENT_KEYS } from './CMCD_EVENT_KEYS.ts'\nimport { CMCD_RESPONSE_KEYS } from './CMCD_RESPONSE_KEYS.js'\nimport type { CmcdEvent } from './CmcdEvent.ts'\nimport { isCmcdCustomKey } from './isCmcdCustomKey.ts'\n\n/**\n * Check if a key is a valid CMCD event key.\n *\n * @param key - The key to check.\n *\n * @returns `true` if the key is a valid CMCD event key, `false` otherwise.\n *\n *\n * @beta\n *\n * @example\n * {@includeCode ../test/isCmcdEventKey.test.ts#example}\n */\nexport function isCmcdEventKey(key: string): key is keyof CmcdEvent {\n\treturn CMCD_COMMON_KEYS.includes(key as any) ||\n\t\tCMCD_EVENT_KEYS.includes(key as any) ||\n\t\tCMCD_RESPONSE_KEYS.includes(key as any) ||\n\t\tisCmcdCustomKey(key as any)\n}\n","/**\n * Defines the request-specific keys for CMCD (Common Media Client Data) version 2.\n *\n *\n * @beta\n */\nexport const CMCD_REQUEST_KEYS = [\n\t'd',\n\t'dl',\n\t'nor',\n\t'ot',\n\t'rtp',\n\t'su',\n] as const\n","import { CMCD_COMMON_KEYS } from './CMCD_COMMON_KEYS.ts'\nimport { CMCD_REQUEST_KEYS } from './CMCD_REQUEST_KEYS.ts'\nimport type { CmcdRequest } from './CmcdRequest.ts'\nimport { isCmcdCustomKey } from './isCmcdCustomKey.ts'\n\n/**\n * Check if a key is a valid CMCD request key.\n *\n * @param key - The key to check.\n *\n * @returns `true` if the key is a valid CMCD request key, `false` otherwise.\n *\n *\n * @beta\n *\n * @example\n * {@includeCode ../test/isCmcdRequestKey.test.ts#example}\n */\nexport function isCmcdRequestKey(key: string): key is keyof CmcdRequest {\n\treturn CMCD_COMMON_KEYS.includes(key as any) ||\n\t\tCMCD_REQUEST_KEYS.includes(key as any) ||\n\t\tisCmcdCustomKey(key as any)\n}\n","import { CMCD_RESPONSE_KEYS } from './CMCD_RESPONSE_KEYS.js'\nimport type { CmcdResponse } from './CmcdResponse.js'\n\n/**\n * Check if a key is a valid CMCD response key.\n *\n * @param key - The key to check.\n *\n * @returns `true` if the key is a valid CMCD request key, `false` otherwise.\n *\n * @group CMCD\n *\n * @beta\n *\n * @example\n * {@includeCode ../../test/cmcd/isCmcdResponseReceivedKey.test.ts#example}\n */\nexport function isCmcdResponseReceivedKey(key: string): key is keyof CmcdResponse {\n\treturn CMCD_RESPONSE_KEYS.includes(key as any)\n}\n","/**\n * Defines the keys for CMCD (Common Media Client Data) version 1.\n *\n *\n * @beta\n */\nexport const CMCD_V1_KEYS = [\n\t'bl',\n\t'br',\n\t'bs',\n\t'cid',\n\t'd',\n\t'dl',\n\t'mtp',\n\t'nor',\n\t'nrr',\n\t'ot',\n\t'pr',\n\t'rtp',\n\t'sf',\n\t'sid',\n\t'st',\n\t'su',\n\t'tb',\n\t'v',\n] as const\n","import { CMCD_V1_KEYS } from './CMCD_V1_KEYS.ts'\nimport type { Cmcd } from './Cmcd.ts'\nimport { isCmcdCustomKey } from './isCmcdCustomKey.ts'\n\n/**\n * Filter function for CMCD v1 keys.\n *\n * @param key - The CMCD key to filter.\n *\n * @returns `true` if the key should be included, `false` otherwise.\n *\n *\n * @beta\n *\n * @example\n * {@includeCode ../test/isCmcdV1Key.test.ts#example}\n */\nexport function isCmcdV1Key(key: string): key is keyof Cmcd {\n\treturn CMCD_V1_KEYS.includes(key as any) || isCmcdCustomKey(key as any)\n}\n","import { isTokenField, isValid } from '@svta/cml-cta'\nimport { SfToken } from '@svta/cml-structured-field-values'\nimport { CMCD_EVENT_MODE } from './CMCD_EVENT_MODE.ts'\nimport { CMCD_FORMATTER_MAP } from './CMCD_FORMATTER_MAP.ts'\nimport { CMCD_REQUEST_MODE } from './CMCD_REQUEST_MODE.ts'\nimport type { CmcdData } from './CmcdData.ts'\nimport type { CmcdEncodeOptions } from './CmcdEncodeOptions.ts'\nimport type { CmcdFormatterOptions } from './CmcdFormatterOptions.ts'\nimport type { CmcdValue } from './CmcdValue.ts'\nimport { isCmcdEventKey } from './isCmcdEventKey.ts'\nimport { isCmcdRequestKey } from './isCmcdRequestKey.ts'\nimport { isCmcdResponseReceivedKey } from './isCmcdResponseReceivedKey.ts'\nimport { isCmcdV1Key } from './isCmcdV1Key.ts'\n\nconst filterMap = {\n\t[CMCD_EVENT_MODE]: isCmcdEventKey,\n\t[CMCD_REQUEST_MODE]: isCmcdRequestKey,\n}\n\n/**\n * Convert a generic object to CMCD data.\n *\n * @param obj - The CMCD object to process.\n * @param options - Options for encoding.\n *\n *\n * @beta\n */\nexport function prepareCmcdData(obj: Record<string, any>, options: CmcdEncodeOptions = {}): CmcdData {\n\tconst results: CmcdData = {}\n\n\tif (obj == null || typeof obj !== 'object') {\n\t\treturn results\n\t}\n\n\tconst version = options.version || (obj['v'] as number) || 1\n\tconst reportingMode = options.reportingMode || CMCD_REQUEST_MODE\n\tconst keyFilter = version === 1 ? isCmcdV1Key : filterMap[reportingMode]\n\n\t// Filter keys based on the version, reporting mode and options\n\tlet keys = Object.keys(obj).filter(keyFilter)\n\n\tif (obj['e'] && obj['e'] !== 'rr') {\n\t\tkeys = keys.filter(key => !isCmcdResponseReceivedKey(key))\n\t}\n\n\tconst filter = options.filter\n\tif (typeof filter === 'function') {\n\t\tkeys = keys.filter(filter)\n\t}\n\n\t// Ensure all required keys are present before sorting\n\tconst needsTimestamp = reportingMode === CMCD_EVENT_MODE\n\tif (needsTimestamp && !keys.includes('ts')) {\n\t\tkeys.push('ts')\n\t}\n\n\tif (version > 1 && !keys.includes('v')) {\n\t\tkeys.push('v')\n\t}\n\n\tconst formatters = Object.assign({}, CMCD_FORMATTER_MAP, options.formatters)\n\tconst formatterOptions: CmcdFormatterOptions = {\n\t\tversion,\n\t\treportingMode,\n\t\tbaseUrl: options.baseUrl,\n\t}\n\n\tkeys.sort().forEach(key => {\n\t\tlet value = obj[key] as CmcdValue\n\n\t\tconst formatter = formatters[key]\n\t\tif (typeof formatter === 'function') {\n\t\t\tvalue = formatter(value, formatterOptions)\n\t\t}\n\n\t\t// Version should only be reported if not equal to 1.\n\t\tif (key === 'v') {\n\t\t\tif (version === 1) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\telse {\n\t\t\t\tvalue = version\n\t\t\t}\n\t\t}\n\n\t\t// Playback rate should only be sent if not equal to 1.\n\t\tif (key == 'pr' && value === 1) {\n\t\t\treturn\n\t\t}\n\n\t\t// Ensure a timestamp is set for response and event modes\n\t\tif (needsTimestamp && key === 'ts' && !Number.isFinite(value)) {\n\t\t\tvalue = Date.now()\n\t\t}\n\n\t\t// ignore invalid values\n\t\tif (!isValid(value)) {\n\t\t\treturn\n\t\t}\n\n\t\tif (isTokenField(key) && typeof value === 'string') {\n\t\t\tvalue = new SfToken(value)\n\t\t}\n\n\t\t(results as any)[key] = value\n\t})\n\n\treturn results\n}\n","import { encodeSfDict } from '@svta/cml-structured-field-values'\nimport type { CmcdData } from './CmcdData.ts'\nimport type { CmcdEncodeOptions } from './CmcdEncodeOptions.ts'\nimport type { CmcdHeaderField } from './CmcdHeaderField.ts'\nimport { groupCmcdHeaders } from './groupCmcdHeaders.ts'\nimport { prepareCmcdData } from './prepareCmcdData.ts'\n\n/**\n * Convert a CMCD data object to request headers\n *\n * @param cmcd - The CMCD data object to convert.\n * @param options - Options for encoding the CMCD object.\n *\n * @returns The CMCD header shards.\n *\n *\n * @beta\n *\n * @example\n * {@includeCode ../test/toCmcdHeaders.test.ts#example}\n */\nexport function toCmcdHeaders(cmcd: CmcdData, options: CmcdEncodeOptions = {}): Record<CmcdHeaderField, string> {\n\tconst result = {} as Record<CmcdHeaderField, string>\n\n\tif (!cmcd) {\n\t\treturn result\n\t}\n\n\tconst data = prepareCmcdData(cmcd, options)\n\tconst shards = groupCmcdHeaders(data, options?.customHeaderMap)\n\n\treturn Object.entries(shards)\n\t\t.reduce((acc, [field, value]) => {\n\t\t\tconst shard = encodeSfDict(value, { whitespace: false })\n\t\t\tif (shard) {\n\t\t\t\tacc[field as CmcdHeaderField] = shard\n\t\t\t}\n\t\t\treturn acc\n\t\t}, result)\n}\n","import type { Cmcd } from './Cmcd.ts'\nimport type { CmcdEncodeOptions } from './CmcdEncodeOptions.ts'\nimport { toCmcdHeaders } from './toCmcdHeaders.ts'\n\n/**\n * Append CMCD query args to a header object.\n *\n * @param headers - The headers to append to.\n * @param cmcd - The CMCD object to append.\n * @param options - Encode options.\n *\n * @returns The headers with the CMCD header shards appended.\n *\n *\n * @beta\n *\n * @example\n * {@includeCode ../test/appendCmcdHeaders.test.ts#example}\n */\nexport function appendCmcdHeaders(headers: Record<string, string>, cmcd: Cmcd, options?: CmcdEncodeOptions): Record<string, string> {\n\treturn Object.assign(headers, toCmcdHeaders(cmcd, options))\n}\n","/**\n * CMCD parameter name.\n *\n *\n * @beta\n */\nexport const CMCD_PARAM = 'CMCD'\n","import { encodeSfDict } from '@svta/cml-structured-field-values'\nimport type { CmcdData } from './CmcdData.ts'\nimport type { CmcdEncodeOptions } from './CmcdEncodeOptions.ts'\nimport { prepareCmcdData } from './prepareCmcdData.ts'\n\n/**\n * Encode a CMCD object to a string.\n *\n * @param cmcd - The CMCD object to encode.\n * @param options - Options for encoding.\n *\n * @returns The encoded CMCD string.\n *\n *\n * @beta\n *\n * @example\n * {@includeCode ../test/encodeCmcd.test.ts#example}\n */\nexport function encodeCmcd(cmcd: CmcdData, options: CmcdEncodeOptions = {}): string {\n\tif (!cmcd) {\n\t\treturn ''\n\t}\n\n\treturn encodeSfDict(prepareCmcdData(cmcd, options), { whitespace: false })\n}\n","import type { Cmcd } from './Cmcd.ts'\nimport type { CmcdEncodeOptions } from './CmcdEncodeOptions.ts'\nimport { encodeCmcd } from './encodeCmcd.ts'\n\n/**\n * Convert a CMCD data object to a URL encoded string.\n *\n * @param cmcd - The CMCD object to convert.\n * @param options - Options for encoding the CMCD object.\n *\n * @returns The URL encoded CMCD data.\n *\n *\n * @beta\n */\nexport function toCmcdUrl(cmcd: Cmcd, options: CmcdEncodeOptions = {}): string {\n\tif (!cmcd) {\n\t\treturn ''\n\t}\n\n\tconst params = encodeCmcd(cmcd, options)\n\n\treturn encodeURIComponent(params)\n}\n","import { CMCD_PARAM } from './CMCD_PARAM.ts'\nimport type { Cmcd } from './Cmcd.ts'\nimport type { CmcdEncodeOptions } from './CmcdEncodeOptions.ts'\nimport { toCmcdUrl } from './toCmcdUrl.ts'\n\n/**\n * Convert a CMCD data object to a query arg.\n *\n * @param cmcd - The CMCD object to convert.\n * @param options - Options for encoding the CMCD object.\n *\n * @returns The CMCD query arg.\n *\n *\n * @beta\n *\n * @example\n * {@includeCode ../test/toCmcdQuery.test.ts#example}\n */\nexport function toCmcdQuery(cmcd: Cmcd, options: CmcdEncodeOptions = {}): string {\n\tif (!cmcd) {\n\t\treturn ''\n\t}\n\n\tconst value = toCmcdUrl(cmcd, options)\n\n\treturn `${CMCD_PARAM}=${value}`\n}\n","import type { Cmcd } from './Cmcd.ts'\nimport type { CmcdEncodeOptions } from './CmcdEncodeOptions.ts'\nimport { toCmcdQuery } from './toCmcdQuery.ts'\n\nconst REGEX = /CMCD=[^&#]+/\n\n/**\n * Append CMCD query args to a URL.\n *\n * @param url - The URL to append to.\n * @param cmcd - The CMCD object to append.\n * @param options - Options for encoding the CMCD object.\n *\n * @returns The URL with the CMCD query args appended.\n *\n *\n * @beta\n *\n * @example\n * {@includeCode ../test/appendCmcdQuery.test.ts#example}\n */\nexport function appendCmcdQuery(url: string, cmcd: Cmcd, options?: CmcdEncodeOptions): string {\n\t// TODO: Replace with URLSearchParams once we drop Safari < 10.1 & Chrome < 49 support.\n\t// https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams\n\n\tconst query = toCmcdQuery(cmcd, options)\n\tif (!query) {\n\t\treturn url\n\t}\n\n\tif (REGEX.test(url)) {\n\t\treturn url.replace(REGEX, query)\n\t}\n\n\tconst separator = url.includes('?') ? '&' : '?'\n\treturn `${url}${separator}${query}`\n}\n","/**\n * The default time interval in secondswhen using using event mode\n *\n *\n * @beta\n */\nexport const CMCD_DEFAULT_TIME_INTERVAL = 30\n","/**\n * CMCD `headers` transmission mode.\n *\n *\n * @beta\n */\nexport const CMCD_HEADERS = 'headers'\n","/**\n * CMCD `json` transmission mode.\n *\n *\n * @beta\n *\n * @deprecated JSON transmission mode is deprecated and will be removed in future versions.\n */\nexport const CMCD_JSON = 'json'\n","import { CMCD_COMMON_KEYS } from './CMCD_COMMON_KEYS.ts'\nimport { CMCD_EVENT_KEYS } from './CMCD_EVENT_KEYS.ts'\nimport { CMCD_REQUEST_KEYS } from './CMCD_REQUEST_KEYS.ts'\nimport { CMCD_RESPONSE_KEYS } from './CMCD_RESPONSE_KEYS.ts'\nimport { CMCD_V1_KEYS } from './CMCD_V1_KEYS.ts'\nimport type { CmcdKey } from './CmcdKey.ts'\n\nconst keySet = new Set([...CMCD_V1_KEYS, ...CMCD_COMMON_KEYS, ...CMCD_REQUEST_KEYS, ...CMCD_RESPONSE_KEYS, ...CMCD_EVENT_KEYS])\n\n/**\n * A list of all CMCD keys.\n *\n *\n * @beta\n */\nexport const CMCD_KEYS: CmcdKey[] = Array.from(keySet)\n","/**\n * CMCD `query` transmission mode.\n *\n *\n * @beta\n */\nexport const CMCD_QUERY = 'query'\n","/**\n * CMCD response mode variable name.\n *\n *\n * @beta\n */\nexport const CMCD_RESPONSE_MODE = 'response'\n","/**\n * CMCD Version 1\n *\n *\n * @beta\n */\nexport const CMCD_V1 = 1\n","/**\n * CMCD Version 2\n *\n *\n * @beta\n */\nexport const CMCD_V2 = 2\n","import type { ValueOf } from '@svta/cml-utils'\nimport { CMCD_HEADERS } from './CMCD_HEADERS.ts'\nimport { CMCD_JSON } from './CMCD_JSON.ts'\nimport { CMCD_QUERY } from './CMCD_QUERY.ts'\n\n/**\n * CMCD transmission modes.\n *\n *\n * @enum\n *\n * @beta\n */\nexport const CmcdTransmissionMode = {\n\t/**\n\t * JSON\n\t *\n\t * @deprecated JSON transmission mode is deprecated and will be removed in future versions.\n\t */\n\tJSON: CMCD_JSON as typeof CMCD_JSON,\n\n\t/**\n\t * Query string\n\t */\n\tQUERY: CMCD_QUERY as typeof CMCD_QUERY,\n\n\t/**\n\t * Request headers\n\t */\n\tHEADERS: CMCD_HEADERS as typeof CMCD_HEADERS,\n\n} as const\n\n/**\n * @beta\n */\nexport type CmcdTransmissionMode = ValueOf<typeof CmcdTransmissionMode>;\n","import type { ValueOf } from '@svta/cml-utils'\nimport { CmcdTransmissionMode } from './CmcdTransmissionMode.ts'\n\n/**\n * CMCD encoding types.\n *\n *\n * @enum\n *\n * @beta\n *\n * @deprecated Use {@link CmcdTransmissionMode} instead.\n *\n * @see {@link CmcdTransmissionMode}\n */\nexport const CmcdEncoding: typeof CmcdTransmissionMode = CmcdTransmissionMode\n\n/**\n * @beta\n */\nexport type CmcdEncoding = ValueOf<typeof CmcdEncoding>;\n","import type { ValueOf } from '@svta/cml-utils'\n\n/**\n * CMCD event types for the 'e' key (event mode).\n *\n *\n * @enum\n *\n * @beta\n */\nexport const CmcdEventType = {\n\t/**\n\t * A change in the player state.\n\t */\n\tPLAY_STATE: 'ps',\n\n\t/**\n\t * An error event.\n\t */\n\tERROR: 'e',\n\n\t/**\n\t * A periodic report sent on a time interval.\n\t */\n\tTIME_INTERVAL: 't',\n\n\t/**\n\t * A change of the content ID.\n\t */\n\tCONTENT_ID: 'c',\n\n\t/**\n\t * A change in the application's backgrounded state.\n\t */\n\tBACKGROUNDED_MODE: 'b',\n\n\t/**\n\t * The player was muted.\n\t */\n\tMUTE: 'm',\n\n\t/**\n\t * Player unmuted.\n\t */\n\tUNMUTE: 'um',\n\n\t/**\n\t * The player view was expanded.\n\t */\n\tPLAYER_EXPAND: 'pe',\n\n\t/**\n\t * The player view was collapsed.\n\t */\n\tPLAYER_COLLAPSE: 'pc',\n\n\t/**\n\t * The receipt of a response.\n\t */\n\tRESPONSE_RECEIVED: 'rr',\n} as const\n\n/**\n * @beta\n */\nexport type CmcdEventType = ValueOf<typeof CmcdEventType>;\n","import { CMCD_FORMATTER_MAP } from './CMCD_FORMATTER_MAP.ts'\nimport type { CmcdFormatter } from './CmcdFormatter.ts'\n\n/**\n * The default formatters for CMCD values.\n *\n *\n * @beta\n *\n * @deprecated Use `CMCD_FORMATTER_MAP` instead.\n */\nexport const CmcdFormatters: Record<string, CmcdFormatter> = CMCD_FORMATTER_MAP\n","import { CmObjectType } from '@svta/cml-cta'\n\n/**\n * Common Media Client Data Object Type\n *\n *\n * @beta\n *\n * @enum\n */\nexport const CmcdObjectType = CmObjectType as typeof CmObjectType\n\n/**\n * @beta\n */\nexport type CmcdObjectType = CmObjectType;\n","import type { ValueOf } from '@svta/cml-utils'\n\n/**\n * CMCD v2 player states for the 'sta' key.\n *\n *\n * @enum\n *\n * @beta\n */\nexport const CmcdPlayerState = {\n\t/**\n\t * Starting: Initial startup of the player.\n\t */\n\tSTARTING: 's',\n\n\t/**\n\t * Playing: The player is actively rendering content.\n\t */\n\tPLAYING: 'p',\n\n\t/**\n\t * Seeking: The player is seeking to a new position.\n\t */\n\tSEEKING: 'k',\n\n\t/**\n\t * Rebuffering: The player is buffering data during playback.\n\t */\n\tREBUFFERING: 'r',\n\n\t/**\n\t * Paused: The player is paused.\n\t */\n\tPAUSED: 'a',\n\n\t/**\n\t * Waiting: The player is waiting for a user action or another event.\n\t */\n\tWAITING: 'w',\n\n\t/**\n\t * Ended: The media has finished playing.\n\t */\n\tENDED: 'e',\n\n\t/**\n\t * Fatal Error: The player has encountered a fatal error.\n\t */\n\tFATAL_ERROR: 'f',\n\n\t/**\n\t * Quit: User initiated end of playback before media asset completion.\n\t */\n\tQUIT: 'q',\n\n\t/**\n\t * Preloading: The player is loading assets ahead of starting in order to provide a fast startup. The expectation is that playback will commence at a future time.\n\t */\n\tPRELOADING: 'd',\n} as const\n\n/**\n * @beta\n */\nexport type CmcdPlayerState = ValueOf<typeof CmcdPlayerState>;\n","import type { ValueOf } from '@svta/cml-utils'\nimport { CMCD_EVENT_MODE } from './CMCD_EVENT_MODE.ts'\nimport { CMCD_REQUEST_MODE } from './CMCD_REQUEST_MODE.ts'\n\n/**\n * CMCD reporting mode types.\n *\n *\n * @enum\n *\n * @beta\n */\nexport const CmcdReportingMode = {\n\t/**\n\t * Request mode\n\t */\n\tREQUEST: CMCD_REQUEST_MODE as typeof CMCD_REQUEST_MODE,\n\n\t/**\n\t * Event mode\n\t */\n\tEVENT: CMCD_EVENT_MODE as typeof CMCD_EVENT_MODE,\n} as const\n\n/**\n * @beta\n */\nexport type CmcdReportingMode = ValueOf<typeof CmcdReportingMode>;\n","import { CmStreamingFormat } from '@svta/cml-cta'\n\n/**\n * Common Media Client Data Streaming Format\n *\n *\n * @enum\n *\n * @beta\n */\nexport const CmcdStreamingFormat = CmStreamingFormat as typeof CmStreamingFormat\n\n/**\n * @beta\n */\nexport type CmcdStreamingFormat = CmStreamingFormat;\n","import { CmStreamType } from '@svta/cml-cta'\n\n/**\n * Common Media Client Data Stream Type\n *\n *\n * @enum\n *\n * @beta\n */\nexport const CmcdStreamType = CmStreamType as typeof CmStreamType\n\n/**\n * @beta\n */\nexport type CmcdStreamType = CmStreamType;\n","import type { SfBareItem } from '@svta/cml-structured-field-values'\nimport { decodeSfDict, SfItem, symbolToStr } from '@svta/cml-structured-field-values'\nimport type { CmcdData } from './CmcdData.ts'\nimport type { CmcdValue } from './CmcdValue.ts'\n\n// Define the input type for reduceValue\ntype ReduceValueInput = SfBareItem | SfItem | ReduceValueInput[];\n\n// Define the output type for reduceValue - matches what CMCD values can be, including arrays\ntype ReduceValueOutput = CmcdValue | ReduceValueOutput[];\n\nfunction reduceValue(value: ReduceValueInput): ReduceValueOutput {\n\tif (Array.isArray(value)) {\n\t\treturn value.map(reduceValue)\n\t}\n\n\tif (typeof value === 'symbol') {\n\t\treturn symbolToStr(value)\n\t}\n\n\tif (value instanceof SfItem && !value.params) {\n\t\treturn reduceValue(value.value)\n\t}\n\n\tif (typeof value === 'string') {\n\t\treturn decodeURIComponent(value)\n\t}\n\n\treturn value as ReduceValueOutput\n};\n\n/**\n * Decode a CMCD string to an object.\n *\n * @param cmcd - The CMCD string to decode.\n *\n * @returns The decoded CMCD object.\n *\n *\n * @beta\n *\n * @example\n * {@includeCode ../test/decodeCmcd.test.ts#example}\n */\nexport function decodeCmcd<T extends CmcdData = CmcdData>(cmcd: string): T {\n\tif (!cmcd) {\n\t\treturn {} as T\n\t}\n\n\tconst sfDict = decodeSfDict(cmcd)\n\n\treturn Object\n\t\t.entries<SfItem>(sfDict as any)\n\t\t.reduce((acc, [key, item]) => {\n\t\t\tacc[key as keyof T] = reduceValue(item.value) as T[keyof T]\n\t\t\treturn acc\n\t\t}, {} as T)\n}\n","import { CMCD_OBJECT } from './CMCD_OBJECT.ts'\nimport { CMCD_REQUEST } from './CMCD_REQUEST.ts'\nimport { CMCD_SESSION } from './CMCD_SESSION.ts'\nimport { CMCD_STATUS } from './CMCD_STATUS.ts'\nimport type { CmcdData } from './CmcdData.ts'\nimport { decodeCmcd } from './decodeCmcd.ts'\n\nconst keys = [CMCD_OBJECT, CMCD_REQUEST, CMCD_SESSION, CMCD_STATUS]\n\n/**\n * Decode CMCD data from request headers.\n *\n * @param headers - The request headers to decode.\n *\n * @returns The decoded CMCD data.\n *\n *\n * @beta\n *\n * @example\n * {@includeCode ../test/fromCmcdHeaders.test.ts#example}\n */\nexport function fromCmcdHeaders(headers: Record<string, string> | Headers): CmcdData {\n\tif (!(headers instanceof Headers)) {\n\t\theaders = new Headers(headers)\n\t}\n\n\treturn keys.reduce((acc, key) => {\n\t\tconst value = headers.get(key)\n\t\treturn Object.assign(acc, decodeCmcd(value as string))\n\t}, {} as CmcdData)\n}\n","import type { Cmcd } from './Cmcd.ts'\nimport { CMCD_PARAM } from './CMCD_PARAM.ts'\nimport { decodeCmcd } from './decodeCmcd.ts'\n\n/**\n * Decode CMCD data from a query string.\n *\n * @param query - The query string to decode.\n *\n * @returns The decoded CMCD data.\n *\n *\n * @beta\n *\n * @example\n * {@includeCode ../test/fromCmcdQuery.test.ts#example}\n */\nexport function fromCmcdQuery(query: string | URLSearchParams): Cmcd {\n\tif (typeof query === 'string') {\n\t\tquery = new URLSearchParams(query)\n\t}\n\n\tconst value = query.get(CMCD_PARAM)\n\n\treturn decodeCmcd(value as string)\n}\n","import type { Cmcd } from './Cmcd.ts'\nimport { decodeCmcd } from './decodeCmcd.ts'\n\n/**\n * Decode CMCD data from a url encoded string.\n *\n * @param url - The url encoded string to decode.\n *\n * @returns The decoded CMCD data.\n *\n *\n * @beta\n *\n * @example\n * {@includeCode ../test/fromCmcdUrl.test.ts#example}\n */\nexport function fromCmcdUrl(url: string): Cmcd {\n\treturn decodeCmcd(decodeURIComponent(url.replace(/^CMCD=/, '')))\n}\n","import { SfToken, symbolToStr } from '@svta/cml-structured-field-values'\nimport type { Cmcd } from './Cmcd.ts'\nimport type { CmcdEncodeOptions } from './CmcdEncodeOptions.ts'\nimport { prepareCmcdData } from './prepareCmcdData.ts'\n\n/**\n * Convert a CMCD data object to JSON.\n *\n * @param cmcd - The CMCD object to convert.\n * @param options - Options for encoding the CMCD object.\n *\n * @returns The CMCD JSON.\n *\n *\n * @beta\n *\n * @deprecated Sending CMCD as JSON objects is deprecated. Use `toCmcdUrl` to create an array of url strings instead.\n */\nexport function toCmcdJson(cmcd: Cmcd, options?: CmcdEncodeOptions): string {\n\tconst data = prepareCmcdData(cmcd, options)\n\n\treturn JSON.stringify(data, (_, value) => typeof value === 'symbol' || value instanceof SfToken ? symbolToStr(value) : value)\n}\n","import type { Request } from '@svta/cml-utils'\nimport type { Cmcd } from './Cmcd.ts'\nimport { CMCD_HEADERS } from './CMCD_HEADERS.ts'\nimport { CMCD_PARAM } from './CMCD_PARAM.ts'\nimport { CMCD_QUERY } from './CMCD_QUERY.ts'\nimport type { CmcdData } from './CmcdData.ts'\nimport type { CmcdEncodeOptions } from './CmcdEncodeOptions.ts'\nimport type { CmcdKey } from './CmcdKey.ts'\nimport type { CmcdReportTarget } from './CmcdReportTarget.ts'\nimport { encodeCmcd } from './encodeCmcd.ts'\nimport { toCmcdHeaders } from './toCmcdHeaders.ts'\n\n/**\n * Converts CMCD data into a report format.\n *\n * @param data - The CMCD data to be transformed into a report\n * @param target - The target configuration for the CMCD report\n *\n * @return A CMCD report object\n *\n *\n * @beta\n *\n * @example\n * {@includeCode ../test/toCmcdReport.test.ts#example}\n */\nexport function toCmcdReport(data: CmcdData, target: CmcdReportTarget): Request<{ cmcd: Cmcd }> | null {\n\tif (!target || !target.url) {\n\t\treturn null\n\t}\n\n\tconst url = new URL(target.url)\n\tconst method = target.method || 'GET'\n\tconst headers = {}\n\tconst transimissionMode = target.transmissionMode || CMCD_QUERY\n\tconst options: CmcdEncodeOptions = {\n\t\tversion: target.version,\n\t\treportingMode: target.reportingMode,\n\t}\n\n\tconst { enabledKeys } = target\n\tif (enabledKeys) {\n\t\toptions.filter = (key: CmcdKey) => enabledKeys.includes(key)\n\t}\n\n\tswitch (transimissionMode) {\n\t\tcase CMCD_QUERY:\n\t\t\tconst param = encodeCmcd(data, options)\n\t\t\tif (param) {\n\t\t\t\turl.searchParams.set(CMCD_PARAM, param)\n\t\t\t}\n\t\t\tbreak\n\n\t\tcase CMCD_HEADERS:\n\t\t\tObject.assign(headers, toCmcdHeaders(data, options))\n\t\t\tbreak\n\t}\n\n\treturn {\n\t\turl: url.toString(),\n\t\tmethod,\n\t\theaders,\n\t}\n}\n"],"mappings":";;;;;;;;;;;AAMA,MAAa,cAAc;;;;;;;;;;ACA3B,MAAa,eAAe;;;;;;;;;;ACA5B,MAAa,eAAe;;;;;;;;;;ACA5B,MAAa,cAAc;;;;;;;;;;ACO3B,MAAaA,kBAAoD;CAEhE,IAAI;CACJ,IAAI;CACJ,GAAG;CACH,IAAI;CACJ,IAAI;CACJ,KAAK;CACL,IAAI;CACJ,KAAK;CACL,KAAK;CACL,KAAK;CAGL,IAAI;CACJ,IAAI;CACJ,KAAK;CACL,IAAI;CACJ,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,IAAI;CACJ,IAAI;CACJ,KAAK;CACL,IAAI;CACJ,MAAM;CACN,OAAO;CACP,MAAM;CACN,OAAO;CACP,OAAO;CACP,MAAM;CACN,IAAI;CACJ,IAAI;CAGJ,IAAI;CAGJ,KAAK;CACL,IAAI;CACJ,IAAI;CACJ,KAAK;CACL,IAAI;CACJ,GAAG;CACH,KAAK;CAGL,IAAI;CACJ,KAAK;CACL,KAAK;CACL,KAAK;CACL,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,GAAG;CACH;;;;;;;;;;;;ACvDD,MAAa,kBAAkB;CAI9B,QAAQ;CAKR,SAAS;CAKT,SAAS;CAKT,QAAQ;CACR;;;;AC5BD,SAAS,gBAAgB,WAAqE;AAC7F,QAAO,OAAO,KAAK,UAAU,CAC3B,QAAQ,KAAK,UAAU;AACvB,YAAU,QAA2B,SAAQ,QAAO,IAAI,OAAO,MAAyB;AACxF,SAAO;IACL,EAAE,CAAqC;;;;;;;;;;;;;AAc5C,SAAgB,iBAAiB,MAAgB,iBAA6E;CA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CAC/B,MAAM,SAAS,OAAO,UAAU;CAChC,MAAM,UAAU,EAAE;CAClB,MAAM,oBAAoB,OAAO,oBAAoB;CACrD,MAAMC,UAA6B;EAClC,SAAS,OAAO;EAChB,eAAe,OAAO;EACtB;CAED,MAAM,EAAE,gBAAgB;AACxB,KAAI,YACH,SAAQ,UAAU,QAAiB,YAAY,SAAS,IAAI;AAG7D,SAAQ,mBAAR;EACC,KAAK;GACJ,MAAM,QAAQ,WAAW,MAAM,QAAQ;AACvC,OAAI,MACH,KAAI,aAAa,IAAI,YAAY,MAAM;AAExC;EAED,KAAK;AACJ,UAAO,OAAO,SAAS,cAAc,MAAM,QAAQ,CAAC;AACpD;;AAGF,QAAO;EACN,KAAK,IAAI,UAAU;EACnB;EACA;EACA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@svta/cml-cmcd",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Common Media Client Data (CMCD) encoding and decoding",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@svta/cml-cta": "
|
|
56
|
-
"@svta/cml-structured-field-values": "
|
|
57
|
-
"@svta/cml-utils": "
|
|
55
|
+
"@svta/cml-cta": "1.0.1",
|
|
56
|
+
"@svta/cml-structured-field-values": "1.0.1",
|
|
57
|
+
"@svta/cml-utils": "1.0.1"
|
|
58
58
|
}
|
|
59
59
|
}
|