@svta/cml-cmsd 0.19.0 → 0.21.0

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.
Files changed (79) hide show
  1. package/README.md +26 -0
  2. package/dist/index.d.ts +449 -21
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +168 -15
  5. package/dist/index.js.map +1 -1
  6. package/package.json +5 -24
  7. package/dist/CMSD_DYNAMIC.d.ts +0 -8
  8. package/dist/CMSD_DYNAMIC.d.ts.map +0 -1
  9. package/dist/CMSD_DYNAMIC.js +0 -8
  10. package/dist/CMSD_DYNAMIC.js.map +0 -1
  11. package/dist/CMSD_STATIC.d.ts +0 -8
  12. package/dist/CMSD_STATIC.d.ts.map +0 -1
  13. package/dist/CMSD_STATIC.js +0 -8
  14. package/dist/CMSD_STATIC.js.map +0 -1
  15. package/dist/CMSD_V1.d.ts +0 -8
  16. package/dist/CMSD_V1.d.ts.map +0 -1
  17. package/dist/CMSD_V1.js +0 -8
  18. package/dist/CMSD_V1.js.map +0 -1
  19. package/dist/CmsdCustomKey.d.ts +0 -11
  20. package/dist/CmsdCustomKey.d.ts.map +0 -1
  21. package/dist/CmsdCustomKey.js +0 -2
  22. package/dist/CmsdCustomKey.js.map +0 -1
  23. package/dist/CmsdDynamic.d.ts +0 -20
  24. package/dist/CmsdDynamic.d.ts.map +0 -1
  25. package/dist/CmsdDynamic.js +0 -2
  26. package/dist/CmsdDynamic.js.map +0 -1
  27. package/dist/CmsdDynamicParams.d.ts +0 -75
  28. package/dist/CmsdDynamicParams.d.ts.map +0 -1
  29. package/dist/CmsdDynamicParams.js +0 -2
  30. package/dist/CmsdDynamicParams.js.map +0 -1
  31. package/dist/CmsdEncodeOptions.d.ts +0 -15
  32. package/dist/CmsdEncodeOptions.d.ts.map +0 -1
  33. package/dist/CmsdEncodeOptions.js +0 -2
  34. package/dist/CmsdEncodeOptions.js.map +0 -1
  35. package/dist/CmsdHeaderField.d.ts +0 -28
  36. package/dist/CmsdHeaderField.d.ts.map +0 -1
  37. package/dist/CmsdHeaderField.js +0 -23
  38. package/dist/CmsdHeaderField.js.map +0 -1
  39. package/dist/CmsdObjectType.d.ts +0 -15
  40. package/dist/CmsdObjectType.d.ts.map +0 -1
  41. package/dist/CmsdObjectType.js +0 -11
  42. package/dist/CmsdObjectType.js.map +0 -1
  43. package/dist/CmsdStatic.d.ts +0 -154
  44. package/dist/CmsdStatic.d.ts.map +0 -1
  45. package/dist/CmsdStatic.js +0 -2
  46. package/dist/CmsdStatic.js.map +0 -1
  47. package/dist/CmsdStreamType.d.ts +0 -15
  48. package/dist/CmsdStreamType.d.ts.map +0 -1
  49. package/dist/CmsdStreamType.js +0 -11
  50. package/dist/CmsdStreamType.js.map +0 -1
  51. package/dist/CmsdStreamingFormat.d.ts +0 -15
  52. package/dist/CmsdStreamingFormat.d.ts.map +0 -1
  53. package/dist/CmsdStreamingFormat.js +0 -11
  54. package/dist/CmsdStreamingFormat.js.map +0 -1
  55. package/dist/CmsdValue.d.ts +0 -12
  56. package/dist/CmsdValue.d.ts.map +0 -1
  57. package/dist/CmsdValue.js +0 -2
  58. package/dist/CmsdValue.js.map +0 -1
  59. package/dist/decodeCmsdDynamic.d.ts +0 -13
  60. package/dist/decodeCmsdDynamic.d.ts.map +0 -1
  61. package/dist/decodeCmsdDynamic.js +0 -19
  62. package/dist/decodeCmsdDynamic.js.map +0 -1
  63. package/dist/decodeCmsdStatic.d.ts +0 -13
  64. package/dist/decodeCmsdStatic.d.ts.map +0 -1
  65. package/dist/decodeCmsdStatic.js +0 -25
  66. package/dist/decodeCmsdStatic.js.map +0 -1
  67. package/dist/encodeCmsdDynamic.d.ts +0 -26
  68. package/dist/encodeCmsdDynamic.d.ts.map +0 -1
  69. package/dist/encodeCmsdDynamic.js +0 -15
  70. package/dist/encodeCmsdDynamic.js.map +0 -1
  71. package/dist/encodeCmsdStatic.d.ts +0 -15
  72. package/dist/encodeCmsdStatic.d.ts.map +0 -1
  73. package/dist/encodeCmsdStatic.js +0 -20
  74. package/dist/encodeCmsdStatic.js.map +0 -1
  75. package/dist/tsconfig.tsbuildinfo +0 -1
  76. package/dist/utils/processCmsd.d.ts +0 -4
  77. package/dist/utils/processCmsd.d.ts.map +0 -1
  78. package/dist/utils/processCmsd.js +0 -28
  79. package/dist/utils/processCmsd.js.map +0 -1
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # @svta/cml-cmsd
2
+
3
+ Common Media Server Data (CMSD) encoding and decoding.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm i @svta/cml-cmsd
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { encodeCmsdStatic } from "@svta/cml-cmsd";
15
+
16
+ const input = Object.assign({}, CMSD_STATIC_OBJ, {
17
+ ot: new SfToken(CmsdObjectType.VIDEO),
18
+ sf: new SfToken(CmsdStreamingFormat.HLS),
19
+ st: new SfToken(CmsdStreamType.VOD),
20
+ });
21
+
22
+ assert(
23
+ encodeCmsdStatic(input) ===
24
+ `ot=v,sf=h,st=v,d=5000,br=2000,n="OriginProviderA"`
25
+ );
26
+ ```
package/dist/index.d.ts CHANGED
@@ -1,23 +1,451 @@
1
+ import { CmObjectType, CmStreamType, CmStreamingFormat } from "@svta/cml-cta";
2
+ import { SfItem, SfToken } from "@svta/cml-structured-field-values";
3
+ import { ValueOf } from "@svta/cml-utils";
4
+
5
+ //#region src/CMSD_DYNAMIC.d.ts
6
+
1
7
  /**
2
- * A collection of tools for working with Common Media Server Data (CMSD).
3
- *
4
- * @packageDocumentation
5
- */
6
- export * from './CMSD_DYNAMIC.js';
7
- export * from './CMSD_STATIC.js';
8
- export * from './CMSD_V1.js';
9
- export type * from './CmsdCustomKey.js';
10
- export type * from './CmsdDynamic.js';
11
- export type * from './CmsdDynamicParams.js';
12
- export type * from './CmsdEncodeOptions.js';
13
- export * from './CmsdHeaderField.js';
14
- export * from './CmsdObjectType.js';
15
- export type * from './CmsdStatic.js';
16
- export * from './CmsdStreamingFormat.js';
17
- export * from './CmsdStreamType.js';
18
- export type * from './CmsdValue.js';
19
- export * from './decodeCmsdDynamic.js';
20
- export * from './decodeCmsdStatic.js';
21
- export * from './encodeCmsdDynamic.js';
22
- export * from './encodeCmsdStatic.js';
8
+ * CMSD dynamic header name.
9
+ *
10
+ *
11
+ * @beta
12
+ */
13
+ declare const CMSD_DYNAMIC = "CMSD-Dynamic";
14
+ //#endregion
15
+ //#region src/CMSD_STATIC.d.ts
16
+ /**
17
+ * CMSD static header name.
18
+ *
19
+ *
20
+ * @beta
21
+ */
22
+ declare const CMSD_STATIC = "CMSD-Static";
23
+ //#endregion
24
+ //#region src/CMSD_V1.d.ts
25
+ /**
26
+ * CMSD Version 1
27
+ *
28
+ *
29
+ * @beta
30
+ */
31
+ declare const CMSD_V1 = 1;
32
+ //#endregion
33
+ //#region src/CmsdCustomKey.d.ts
34
+ /**
35
+ * A custom key for CMSD. Custom keys MUST carry a hyphenated prefix
36
+ * to ensure that there will not be a namespace collision with future
37
+ * revisions to this specification. Clients SHOULD use a reverse-DNS
38
+ * syntax when defining their own prefix.
39
+ *
40
+ *
41
+ * @beta
42
+ */
43
+ type CmsdCustomKey = `${string}-${string}`;
44
+ //#endregion
45
+ //#region src/CmsdObjectType.d.ts
46
+ /**
47
+ * Common Media Server Data Object Type
48
+ *
49
+ *
50
+ * @enum
51
+ *
52
+ * @beta
53
+ */
54
+ declare const CmsdObjectType: typeof CmObjectType;
55
+ /**
56
+ * @beta
57
+ */
58
+ type CmsdObjectType = CmObjectType;
59
+ //#endregion
60
+ //#region src/CmsdStreamType.d.ts
61
+ /**
62
+ * Common Media Server Data Stream Type
63
+ *
64
+ *
65
+ * @enum
66
+ *
67
+ * @beta
68
+ */
69
+ declare const CmsdStreamType: typeof CmStreamType;
70
+ /**
71
+ * @beta
72
+ */
73
+ type CmsdStreamType = CmStreamType;
74
+ //#endregion
75
+ //#region src/CmsdStreamingFormat.d.ts
76
+ /**
77
+ * Common Media Server Data Streaming Format
78
+ *
79
+ *
80
+ * @enum
81
+ *
82
+ * @beta
83
+ */
84
+ declare const CmsdStreamingFormat: typeof CmStreamingFormat;
85
+ /**
86
+ * @beta
87
+ */
88
+ type CmsdStreamingFormat = CmStreamingFormat;
89
+ //#endregion
90
+ //#region src/CmsdValue.d.ts
91
+ /**
92
+ * CMSD Value
93
+ *
94
+ *
95
+ * @beta
96
+ */
97
+ type CmsdValue = CmsdObjectType | CmsdStreamingFormat | CmsdStreamType | string | number | boolean | symbol | SfToken;
98
+ //#endregion
99
+ //#region src/CmsdDynamicParams.d.ts
100
+ /**
101
+ * Common Media Server Data (CMSD) dynamic response header field parameters.
102
+ *
103
+ * @see {@link https://cdn.cta.tech/cta/media/media/resources/standards/pdfs/cta-5006-final.pdf|CMSD Spec}
104
+ *
105
+ *
106
+ * @beta
107
+ */
108
+ type CmsdDynamicParams = {
109
+ /**
110
+ * Custom key names may be used, but they MUST carry a hyphenated prefix to ensure that there will not be a namespace collision
111
+ * with future revisions to this specification. Clients SHOULD use a reverse-DNS syntax when defining their own prefix.
112
+ */
113
+ [index: CmsdCustomKey]: CmsdValue;
114
+ /**
115
+ * Duress
116
+ *
117
+ * Key is included without a value if the server is under duress, due to cpu, memory, disk IO, network IO or other reasons. The
118
+ * thresholds for signaling duress are left to the discretion of the server operator. The intent is that the client will use this
119
+ * signal to move away to an alternate server if possible. This key MUST NOT be sent if it is false.
120
+ *
121
+ * Boolean
122
+ */
123
+ du?: boolean;
124
+ /**
125
+ * Estimated Throughput
126
+ *
127
+ * The throughput between the server and the client over the currently negotiated transport as estimated by the server at the start
128
+ * of the response. The value is expressed in units of kilobits per second and rounded to the nearest integer. The time window for
129
+ * this estimate is expected to be the duration of the current response at most. The throughput may vary during the response and the
130
+ * client SHOULD use this data as an adjunct to its own throughput estimates. As an informative example, this estimate could be
131
+ * derived in this way:
132
+ *
133
+ * etp = 8 * send_window / (rtt)
134
+ *
135
+ * where send_window = min (cwnd * mss, rwnd) with Congestion Window (cwnd) measured in packets, Maximum Segment Size (mss) in bytes,
136
+ * Receiver Window (rwnd) in bytes and rtt in milliseconds. Note that multiple client processes adjacent to the media player may pool
137
+ * their requests into the same connection to the server. In this case the server estimate of throughput will be against the entirety
138
+ * of the connection, not all of which will be accessible to the media player.
139
+ *
140
+ * Integer Kbps
141
+ */
142
+ etp?: number;
143
+ /**
144
+ * Max suggested bitrate
145
+ *
146
+ * The maximum bitrate value that the player SHOULD play in its Adaptive Bit Rate (ABR) ladder. If the player is playing a bitrate higher
147
+ * than this value, it SHOULD immediately switch to a bitrate lower than or equal to this value.
148
+ *
149
+ * Integer Kbps
150
+ */
151
+ mb?: number;
152
+ /**
153
+ * Response delay
154
+ *
155
+ * The time elapsed between the receipt of the request and when the first byte of the body becomes available to send to the client. The
156
+ * intention is for receivers to use this value to more accurately calculate the throughput of the connection [MHV22].
157
+ *
158
+ * Integer milliseconds
159
+ */
160
+ rd?: number;
161
+ /**
162
+ * Round Trip Time
163
+ *
164
+ * Estimated round trip time between client and server. This estimate may be derived from the transport handshake. For subsequent requests
165
+ * over the same connection, the value can be refined to be an exponentially weighted moving average of prior instantaneous values. An
166
+ * informative example algorithm for this averaging is provided by [18].
167
+ *
168
+ * Integer Kbps
169
+ */
170
+ rtt?: number;
171
+ };
172
+ //#endregion
173
+ //#region src/CmsdDynamic.d.ts
174
+ /**
175
+ * Common Media Server Data (CMSD) dynamic response header fields.
176
+ *
177
+ * @see {@link https://cdn.cta.tech/cta/media/media/resources/standards/pdfs/cta-5006-final.pdf|CMSD Spec}
178
+ *
179
+ *
180
+ * @beta
181
+ */
182
+ type CmsdDynamic = {
183
+ /**
184
+ * The server name.
185
+ */
186
+ value: string;
187
+ /**
188
+ * The CMSD dynamic parameters.
189
+ */
190
+ params: CmsdDynamicParams;
191
+ };
192
+ //#endregion
193
+ //#region src/CmsdEncodeOptions.d.ts
194
+ /**
195
+ * Options for encoding CMCD values.
196
+ *
197
+ *
198
+ * @beta
199
+ */
200
+ type CmsdEncodeOptions = {
201
+ /**
202
+ * Use Symbol to represent token values
203
+ *
204
+ * @defaultValue `true`
205
+ */
206
+ useSymbol?: boolean;
207
+ };
208
+ //#endregion
209
+ //#region src/CmsdHeaderField.d.ts
210
+ /**
211
+ * CMSD header fields.
212
+ *
213
+ *
214
+ * @enum
215
+ *
216
+ * @beta
217
+ */
218
+ declare const CmsdHeaderField: {
219
+ /**
220
+ * Keys whose values persist over multiple requests for the object.
221
+ */
222
+ readonly STATIC: typeof CMSD_STATIC;
223
+ /**
224
+ * Keys whose values apply only to the next transmission hop. Typically a
225
+ * new CMSD-Dynamic header instance will be added by each intermediary
226
+ * participating in the delivery.
227
+ */
228
+ readonly DYNAMIC: typeof CMSD_DYNAMIC;
229
+ };
230
+ /**
231
+ * @beta
232
+ */
233
+ type CmsdHeaderField = ValueOf<typeof CmsdHeaderField>;
234
+ //#endregion
235
+ //#region src/CmsdStatic.d.ts
236
+ /**
237
+ * Common Media Server Data (CMSD) static response header fields.
238
+ *
239
+ * @see {@link https://cdn.cta.tech/cta/media/media/resources/standards/pdfs/cta-5006-final.pdf|CMSD Spec}
240
+ *
241
+ *
242
+ * @beta
243
+ */
244
+ type CmsdStatic = {
245
+ /**
246
+ * Custom key names may be used, but they MUST carry a hyphenated prefix to ensure that there will not be a namespace collision
247
+ * with future revisions to this specification. Clients SHOULD use a reverse-DNS syntax when defining their own prefix.
248
+ */
249
+ [index: CmsdCustomKey]: CmsdValue;
250
+ /**
251
+ * Availability time
252
+ *
253
+ * The wallclock time at which the first byte of this object became available at the origin for successful request. The time is
254
+ * expressed as integer milliseconds since the Unix Epoch, i.e., the number of milliseconds that have elapsed since January 1,
255
+ * 1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970- 01-01T00:00:000Z).
256
+ *
257
+ * Integer Milliseconds
258
+ */
259
+ at?: number;
260
+ /**
261
+ * Encoded bitrate
262
+ *
263
+ * The encoded bitrate of the audio or video object being requested. If the instantaneous bitrate varies over the duration of the
264
+ * object, the average value over the duration of the object SHOULD be communicated. This key should only accompany objects that
265
+ * have an implicit bitrate.
266
+ *
267
+ * Integer kbps
268
+ */
269
+ br?: number;
270
+ /**
271
+ * Object duration
272
+ *
273
+ * The playback duration in milliseconds of the object being requested. If a partial segment is being requested, then this value
274
+ * MUST indicate the playback duration of that part and not that of its parent segment. This value can be an approximation of the
275
+ * estimated duration if the explicit value is not known.
276
+ *
277
+ * Integer milliseconds
278
+ */
279
+ d?: number;
280
+ /**
281
+ * Held time
282
+ *
283
+ * The number of milliseconds that this response was held back by an origin before returning. This is applicable to blocking responses
284
+ * under LL-HLS [HLSbis].
285
+ *
286
+ * Integer Milliseconds
287
+ */
288
+ ht?: number;
289
+ /**
290
+ * Intermediary identifier
291
+ *
292
+ * An identifier for the processing server. The value SHOULD identify both the organization and the intermediary that is writing the key.
293
+ * Identifiers SHOULD be as concise as possible to reduce log file and transferred size, while still remaining unique.
294
+ *
295
+ * String
296
+ */
297
+ n?: string;
298
+ /**
299
+ * Next object request
300
+ *
301
+ * Relative path of the next object to be requested. This can be used to trigger pre-fetching by the CDN. This MUST be a path relative to the current
302
+ * request. This string MUST be URLEncoded. The client SHOULD NOT depend upon any pre-fetch action being taken - it is merely a request for such a
303
+ * pre-fetch to take place.
304
+ *
305
+ * String
306
+ */
307
+ nor?: string;
308
+ /**
309
+ * Next range request
310
+ *
311
+ * If the next request will be a partial object request, then this string denotes the byte range to be requested. If the ‘nor’ field is not set, then the
312
+ * object is assumed to match the object currently being requested. The client SHOULD NOT depend upon any pre-fetch action being taken – it is merely a
313
+ * request for such a pre-fetch to take place. Formatting is similar to the HTTP Range header, except that the unit MUST be ‘byte’, the ‘Range:’ prefix is
314
+ * NOT required and specifying multiple ranges is NOT allowed. Valid combinations are:
315
+ *
316
+ * - `"\<range-start\>-"`
317
+ * - `"\<range-start\>-\<range-end\>"`
318
+ * - `"-\<suffix-length\>"`
319
+ *
320
+ * String
321
+ */
322
+ nrr?: string;
323
+ /**
324
+ * Object type
325
+ *
326
+ * The media type of the current object being requested:
327
+ * - `m` = text file, such as a manifest or playlist
328
+ * - `a` = audio only
329
+ * - `v` = video only
330
+ * - `av` = muxed audio and video
331
+ * - `i` = init segment
332
+ * - `c` = caption or subtitle
333
+ * - `tt` = ISOBMFF timed text track
334
+ * - `k` = cryptographic key, license or certificate.
335
+ * - `o` = other
336
+ *
337
+ * If the object type being requested is unknown, then this key MUST NOT be used.
338
+ *
339
+ * Token
340
+ */
341
+ ot?: CmsdObjectType;
342
+ /**
343
+ * Streaming format
344
+ *
345
+ * The streaming format that defines the current request.
346
+ *
347
+ * - `d` = MPEG DASH
348
+ * - `h` = HTTP Live Streaming (HLS)
349
+ * - `s` = Smooth Streaming
350
+ * - `o` = other
351
+ *
352
+ * If the streaming format being requested is unknown, then this key MUST NOT be used.
353
+ *
354
+ * Token
355
+ */
356
+ sf?: CmsdStreamingFormat;
357
+ /**
358
+ * Stream type
359
+ * - `v` = all segments are available – e.g., VOD
360
+ * - `l` = segments become available over time – e.g., LIVE
361
+ *
362
+ * Token
363
+ */
364
+ st?: CmsdStreamType;
365
+ /**
366
+ * Startup
367
+ *
368
+ * Key is included without a value if the object is needed urgently due to startup, seeking or recovery after a buffer-empty event. The media SHOULD not be
369
+ * rendering when this request is made. This key MUST not be sent if it is FALSE.
370
+ *
371
+ * Boolean
372
+ */
373
+ su?: boolean;
374
+ /**
375
+ * CMSD version
376
+ *
377
+ * The version of this specification used for interpreting the defined key names and values. If this key is omitted, the client and server MUST
378
+ * interpret the values as being defined by version 1. Client SHOULD omit this field if the version is 1.
379
+ *
380
+ * Integer
381
+ */
382
+ v?: number;
383
+ };
384
+ //#endregion
385
+ //#region src/decodeCmsdDynamic.d.ts
386
+ /**
387
+ * Decode a CMSD dynamic string to an object.
388
+ *
389
+ * @param cmsd - The CMSD string to decode.
390
+ *
391
+ * @returns The decoded CMSD object.
392
+ *
393
+ *
394
+ * @beta
395
+ */
396
+ declare function decodeCmsdDynamic(cmsd: string): CmsdDynamic[];
397
+ //#endregion
398
+ //#region src/decodeCmsdStatic.d.ts
399
+ /**
400
+ * Decode a CMSD Static dict string to an object.
401
+ *
402
+ * @param cmsd - The CMSD string to decode.
403
+ *
404
+ * @returns The decoded CMSD object.
405
+ *
406
+ *
407
+ * @beta
408
+ */
409
+ declare function decodeCmsdStatic(cmsd: string): CmsdStatic;
410
+ //#endregion
411
+ //#region src/encodeCmsdDynamic.d.ts
412
+ /**
413
+ * Encode a list of CMSD Dynamic objects.
414
+ *
415
+ * @param value - The list of `SfItems` to encode.
416
+ *
417
+ * @returns The encoded CMSD string.
418
+ *
419
+ *
420
+ * @beta
421
+ */
422
+ declare function encodeCmsdDynamic(value: SfItem[]): string;
423
+ /**
424
+ * Encode a single CMSD Dynamic object.
425
+ *
426
+ * @param value - The server name
427
+ * @param cmsd - The CMSD object to encode.
428
+ *
429
+ * @returns The encoded CMSD string.
430
+ *
431
+ *
432
+ * @beta
433
+ */
434
+ declare function encodeCmsdDynamic(value: string, cmsd: CmsdDynamic): string;
435
+ //#endregion
436
+ //#region src/encodeCmsdStatic.d.ts
437
+ /**
438
+ * Encode a CMSD Static object.
439
+ *
440
+ * @param cmsd - The CMSD object to encode.
441
+ * @param options - Encoding options
442
+ *
443
+ * @returns The encoded CMSD string.
444
+ *
445
+ *
446
+ * @beta
447
+ */
448
+ declare function encodeCmsdStatic(cmsd: CmsdStatic, options?: CmsdEncodeOptions): string;
449
+ //#endregion
450
+ export { CMSD_DYNAMIC, CMSD_STATIC, CMSD_V1, CmsdCustomKey, CmsdDynamic, CmsdDynamicParams, CmsdEncodeOptions, CmsdHeaderField, CmsdObjectType, CmsdStatic, CmsdStreamType, CmsdStreamingFormat, CmsdValue, decodeCmsdDynamic, decodeCmsdStatic, encodeCmsdDynamic, encodeCmsdStatic };
23
451
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,mBAAmB,oBAAoB,CAAC;AACxC,mBAAmB,kBAAkB,CAAC;AACtC,mBAAmB,wBAAwB,CAAC;AAC5C,mBAAmB,wBAAwB,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,mBAAmB,iBAAiB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,mBAAmB,gBAAgB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/CMSD_DYNAMIC.ts","../src/CMSD_STATIC.ts","../src/CMSD_V1.ts","../src/CmsdCustomKey.ts","../src/CmsdObjectType.ts","../src/CmsdStreamType.ts","../src/CmsdStreamingFormat.ts","../src/CmsdValue.ts","../src/CmsdDynamicParams.ts","../src/CmsdDynamic.ts","../src/CmsdEncodeOptions.ts","../src/CmsdHeaderField.ts","../src/CmsdStatic.ts","../src/decodeCmsdDynamic.ts","../src/decodeCmsdStatic.ts","../src/encodeCmsdDynamic.ts","../src/encodeCmsdStatic.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AAMA;cAAa,YAAA;;;;;;;;AAAb;cCAa,WAAA;;;;;;;;ADAb;cEAa,OAAA;;;;;;;;AFAb;;;;ACAa,KEGD,aAAA,GFHC,GAAA,MAAA,IAAA,MAAA,EAAA;;;;;;;ADAb;;;;ACAa,cGIA,cHJA,EAAA,OGIwC,YHJxC;;;;ACAA,KESD,cAAA,GAAiB,YFThB;;;;;;;AFAb;;;;ACAa,cIIA,cJJA,EAAA,OIIwC,YJJxC;;;;ACAA,KGSD,cAAA,GAAiB,YHThB;;;;;;;AFAb;;;;ACAa,cKIA,mBLJA,EAAA,OKIkD,iBLJlD;;;;ACAA,KISD,mBAAA,GAAsB,iBJTrB;;;;AFAb;;;;ACAA;KMKY,SAAA,GAAY,iBAAiB,sBAAsB,sDAAsD;;;;;;APLrH;;;;ACAA;KOKY,iBAAA;;;ANLZ;;UMUS,gBAAgB;;ALPzB;;;;ACCA;AAKA;;;;ECLA;AAKA;;;;ACLA;AAKA;;;;ACJA;;;;;;;;;ECAA;;;;ACDA;;;;ECJA,EAAA,CAAY,EAAA,MAAA;;;;ACMZ;AAiBA;;;;ECfA,EAAA,CAAY,EAAA,MAAA;EAMH;;;;;;;;;ECPT,GAAgB,CAAA,EAAA,MAAA;;;;;;;;AbPhB;;;;ACAa,KQID,WAAA,GRJC;;;;ECAb,KAAa,EAAA,MAAA;;;;ECGb,MAAY,EMUH,iBNVG;;;;;;;;;AHHZ;KUAY,iBAAA;;;ATAZ;;;;ACAA,CAAA;;;;;AFAA;;;;ACAA;;cUMa;;ATNb;;0BSU+B;;ARP/B;;;;ECCA,SAAa,OAAA,EAAA,OOaoB,YPboB;AAKrD,CAAA;;;;ACLa,KMmBD,eAAA,GAAkB,ONnBuB,CAAA,OMmBR,eNnBQ,CAAA;;;ALJrD;;;;ACAA;;;;ACAa,KUQD,UAAA,GVRC;;;;ACGb;USWS,gBAAgB;;;ARVzB;AAKA;;;;ACLA;AAKA;;;;ACLA;AAKA;;;;ACJA;;EAAyC,EAAA,CAAA,EAAA,MAAA;EAAsB;;;;;;ACA/D;;;;ECDA;;;;ACJA;;;;ECMA,EAAA,CAAa,EAAA,MAAA;EAiBb;;;;ACfA;;;;EA0HM,CAAA,CAAA,EAAA,MAAA;EASA;;;;;ACpIN;;;;ECAA,GAAgB,CAAA,EAAA,MAAA;;;;ACAhB;AAaA;;;;ACVA;;;;;;;;;;;;;;;;;;;;;;;;;OJwGM;;;;;;;;;;;;;;;OAgBA;;;;;;;;OASA;;;;;;;;;;;;;;;;;;;;;;;;;;AZ3IN;;;;ACAA;;iBYOgB,iBAAA,gBAAiC;;;;;;;AbPjD;;;;ACAA;;iBaOgB,gBAAA,gBAAgC;;;;;;AdPhD;;;;ACAA;;;iBcOgB,iBAAA,QAAyB;AbPzC;;;;ACGA;;;;ACCA;AAKA;;iBWWgB,iBAAA,sBAAuC;;;;;;AfpBvD;;;;ACAA;;;;ACAa,iBcUG,gBAAA,CdVH,IAAA,EcU0B,UdV1B,EAAA,OAAA,CAAA,EcUgD,iBdVhD,CAAA,EAAA,MAAA"}
package/dist/index.js CHANGED
@@ -1,17 +1,170 @@
1
+ import { CmObjectType, CmStreamType, CmStreamingFormat, isTokenField, isValid } from "@svta/cml-cta";
2
+ import { SfItem, SfToken, decodeSfDict, decodeSfList, encodeSfDict, encodeSfList, symbolToStr } from "@svta/cml-structured-field-values";
3
+
4
+ //#region src/CMSD_DYNAMIC.ts
1
5
  /**
2
- * A collection of tools for working with Common Media Server Data (CMSD).
3
- *
4
- * @packageDocumentation
5
- */
6
- export * from './CMSD_DYNAMIC.js';
7
- export * from './CMSD_STATIC.js';
8
- export * from './CMSD_V1.js';
9
- export * from './CmsdHeaderField.js';
10
- export * from './CmsdObjectType.js';
11
- export * from './CmsdStreamingFormat.js';
12
- export * from './CmsdStreamType.js';
13
- export * from './decodeCmsdDynamic.js';
14
- export * from './decodeCmsdStatic.js';
15
- export * from './encodeCmsdDynamic.js';
16
- export * from './encodeCmsdStatic.js';
6
+ * CMSD dynamic header name.
7
+ *
8
+ *
9
+ * @beta
10
+ */
11
+ const CMSD_DYNAMIC = "CMSD-Dynamic";
12
+
13
+ //#endregion
14
+ //#region src/CMSD_STATIC.ts
15
+ /**
16
+ * CMSD static header name.
17
+ *
18
+ *
19
+ * @beta
20
+ */
21
+ const CMSD_STATIC = "CMSD-Static";
22
+
23
+ //#endregion
24
+ //#region src/CMSD_V1.ts
25
+ /**
26
+ * CMSD Version 1
27
+ *
28
+ *
29
+ * @beta
30
+ */
31
+ const CMSD_V1 = 1;
32
+
33
+ //#endregion
34
+ //#region src/CmsdHeaderField.ts
35
+ /**
36
+ * CMSD header fields.
37
+ *
38
+ *
39
+ * @enum
40
+ *
41
+ * @beta
42
+ */
43
+ const CmsdHeaderField = {
44
+ STATIC: CMSD_STATIC,
45
+ DYNAMIC: CMSD_DYNAMIC
46
+ };
47
+
48
+ //#endregion
49
+ //#region src/CmsdObjectType.ts
50
+ /**
51
+ * Common Media Server Data Object Type
52
+ *
53
+ *
54
+ * @enum
55
+ *
56
+ * @beta
57
+ */
58
+ const CmsdObjectType = CmObjectType;
59
+
60
+ //#endregion
61
+ //#region src/CmsdStreamingFormat.ts
62
+ /**
63
+ * Common Media Server Data Streaming Format
64
+ *
65
+ *
66
+ * @enum
67
+ *
68
+ * @beta
69
+ */
70
+ const CmsdStreamingFormat = CmStreamingFormat;
71
+
72
+ //#endregion
73
+ //#region src/CmsdStreamType.ts
74
+ /**
75
+ * Common Media Server Data Stream Type
76
+ *
77
+ *
78
+ * @enum
79
+ *
80
+ * @beta
81
+ */
82
+ const CmsdStreamType = CmStreamType;
83
+
84
+ //#endregion
85
+ //#region src/decodeCmsdDynamic.ts
86
+ /**
87
+ * Decode a CMSD dynamic string to an object.
88
+ *
89
+ * @param cmsd - The CMSD string to decode.
90
+ *
91
+ * @returns The decoded CMSD object.
92
+ *
93
+ *
94
+ * @beta
95
+ */
96
+ function decodeCmsdDynamic(cmsd) {
97
+ if (!cmsd) return [];
98
+ return decodeSfList(cmsd);
99
+ }
100
+
101
+ //#endregion
102
+ //#region src/decodeCmsdStatic.ts
103
+ /**
104
+ * Decode a CMSD Static dict string to an object.
105
+ *
106
+ * @param cmsd - The CMSD string to decode.
107
+ *
108
+ * @returns The decoded CMSD object.
109
+ *
110
+ *
111
+ * @beta
112
+ */
113
+ function decodeCmsdStatic(cmsd) {
114
+ if (!cmsd) return {};
115
+ return Object.entries(decodeSfDict(cmsd)).reduce((acc, [key, item]) => {
116
+ const { value } = item;
117
+ acc[key] = typeof value === "symbol" ? symbolToStr(value) : value;
118
+ return acc;
119
+ }, {});
120
+ }
121
+
122
+ //#endregion
123
+ //#region src/encodeCmsdDynamic.ts
124
+ function encodeCmsdDynamic(value, cmsd) {
125
+ if (!value) return "";
126
+ if (typeof value === "string") {
127
+ if (!cmsd) return "";
128
+ value = [new SfItem(value, cmsd)];
129
+ }
130
+ return encodeSfList(value, { whitespace: false });
131
+ }
132
+
133
+ //#endregion
134
+ //#region src/utils/processCmsd.ts
135
+ function processCmsd(obj, options) {
136
+ const results = {};
137
+ if (obj == null || typeof obj !== "object") return results;
138
+ const keys = Object.keys(obj);
139
+ const useSymbol = options?.useSymbol !== false;
140
+ keys.forEach((key) => {
141
+ let value = obj[key];
142
+ if (key === "v" && value === 1) return;
143
+ if (!isValid(value)) return;
144
+ if (isTokenField(key) && typeof value === "string") value = useSymbol ? Symbol.for(value) : new SfToken(value);
145
+ results[key] = value;
146
+ });
147
+ return results;
148
+ }
149
+
150
+ //#endregion
151
+ //#region src/encodeCmsdStatic.ts
152
+ /**
153
+ * Encode a CMSD Static object.
154
+ *
155
+ * @param cmsd - The CMSD object to encode.
156
+ * @param options - Encoding options
157
+ *
158
+ * @returns The encoded CMSD string.
159
+ *
160
+ *
161
+ * @beta
162
+ */
163
+ function encodeCmsdStatic(cmsd, options) {
164
+ if (!cmsd) return "";
165
+ return encodeSfDict(processCmsd(cmsd, options), { whitespace: false });
166
+ }
167
+
168
+ //#endregion
169
+ export { CMSD_DYNAMIC, CMSD_STATIC, CMSD_V1, CmsdHeaderField, CmsdObjectType, CmsdStreamType, CmsdStreamingFormat, decodeCmsdDynamic, decodeCmsdStatic, encodeCmsdDynamic, encodeCmsdStatic };
17
170
  //# sourceMappingURL=index.js.map