@svta/cml-cmsd 1.0.6 → 1.1.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.
- package/dist/index.d.ts +28 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -1
- package/dist/index.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -33,9 +33,17 @@ declare const CMSD_V1 = 1;
|
|
|
33
33
|
* revisions to this specification. Clients SHOULD use a reverse-DNS
|
|
34
34
|
* syntax when defining their own prefix.
|
|
35
35
|
*
|
|
36
|
+
* The type requires a lowercase hyphenated string. At runtime a key
|
|
37
|
+
* must also satisfy {@link isCmsdCustomKey} (a lowercase first
|
|
38
|
+
* letter, then characters from `a-z 0-9 . -`, with a hyphen that is
|
|
39
|
+
* neither the first nor the last character), the subset of the CMSD
|
|
40
|
+
* custom-key grammar that survives RFC 8941 key serialization. Keys
|
|
41
|
+
* failing it fail structured-field serialization at encode time.
|
|
42
|
+
* Lowercase reverse-DNS names satisfy all constraints.
|
|
43
|
+
*
|
|
36
44
|
* @public
|
|
37
45
|
*/
|
|
38
|
-
type CmsdCustomKey =
|
|
46
|
+
type CmsdCustomKey = Lowercase<`${string}-${string}`>;
|
|
39
47
|
//#endregion
|
|
40
48
|
//#region src/CmsdObjectType.d.ts
|
|
41
49
|
/**
|
|
@@ -432,5 +440,23 @@ declare function encodeCmsdDynamic(value: string, cmsd: CmsdDynamic): string;
|
|
|
432
440
|
*/
|
|
433
441
|
declare function encodeCmsdStatic(cmsd: CmsdStatic, options?: CmsdEncodeOptions): string;
|
|
434
442
|
//#endregion
|
|
435
|
-
|
|
443
|
+
//#region src/isCmsdCustomKey.d.ts
|
|
444
|
+
/**
|
|
445
|
+
* Check if a key is a valid custom key: a lowercase first letter, then
|
|
446
|
+
* characters from `a-z 0-9 . -`, with a hyphen that is neither the first
|
|
447
|
+
* nor the last character. These are the CMSD custom-key rules restricted
|
|
448
|
+
* to names that survive RFC 8941 key serialization.
|
|
449
|
+
*
|
|
450
|
+
* @param key - The key to check.
|
|
451
|
+
*
|
|
452
|
+
* @returns `true` if the key is a custom key, `false` otherwise.
|
|
453
|
+
*
|
|
454
|
+
* @public
|
|
455
|
+
*
|
|
456
|
+
* @example
|
|
457
|
+
* {@includeCode ../test/isCmsdCustomKey.test.ts#example}
|
|
458
|
+
*/
|
|
459
|
+
declare function isCmsdCustomKey(key: string): boolean;
|
|
460
|
+
//#endregion
|
|
461
|
+
export { CMSD_DYNAMIC, CMSD_STATIC, CMSD_V1, CmsdCustomKey, CmsdDynamic, CmsdDynamicParams, CmsdEncodeOptions, CmsdHeaderField, CmsdObjectType, CmsdStatic, CmsdStreamType, CmsdStreamingFormat, CmsdValue, decodeCmsdDynamic, decodeCmsdStatic, encodeCmsdDynamic, encodeCmsdStatic, isCmsdCustomKey };
|
|
436
462
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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":";;;;;;;;;;AAKa,cAAA,YAAA,GAAA,cAAA;;;;;;;;AAAA,cCAA,WAAA,GDAA,aAAA;;;;;;;;AAAA,cEAA,OAAA,GFAA,CAAA;;;;;;;;AAAb;;;
|
|
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","../src/isCmsdCustomKey.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAKa,cAAA,YAAA,GAAA,cAAA;;;;;;;;AAAA,cCAA,WAAA,GDAA,aAAA;;;;;;;;AAAA,cEAA,OAAA,GFAA,CAAA;;;;;;;;AAAb;;;;ACAA;;;;ACAA;;;KCWY,aAAA,GAAgB;;;;;;;AHX5B;;;;ACAa,cGKA,cHLA,EAAA,OGKwC,YHLxC;;;;ACAA,KEUD,cAAA,GAAiB,YFVhB;;;;;;;AFAb;;;;ACAa,cIKA,cJLA,EAAA,OIKwC,YJLxC;;;;ACAA,KGUD,cAAA,GAAiB,YHVhB;;;;;;;AFAb;;;;ACAa,cKKA,mBLLA,EAAA,OKKkD,iBLLlD;;;;ACAA,KIUD,mBAAA,GAAsB,iBJVrB;;;;AFAb;;;;ACAa,KMKD,SAAA,GAAY,cNLX,GMK4B,mBNL5B,GMKkD,cNLlD,GAAA,MAAA,GAAA,MAAA,GAAA,OAAA,GAAA,MAAA,GMKwG,ONLxG;;;;;;ADAb;;;;ACAa,KOKD,iBAAA,GPLC;;;;ACAb;UMUS,gBAAgB;;;ALCzB;;;;ACNA;AAKA;;;;ACLA;AAKA;;;;ACLA;AAKA;;;;ACLA;;;;;;;;;ACAA;;;;ACDA;;;;ECJA;;;;ACOA;AAiBA;;;;EChBA;;;;;;;;;;ACDA,CAAA;;;;;;;AbPA;;;KSIY,WAAA;ERJZ;;;;ECAA;;;UOaS;ANFT,CAA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USTOM_KEY_REGEX = /^[a-z][a-z0-9.-]*$/;
|
|
165
|
+
/**
|
|
166
|
+
* Check if a key is a valid custom key: a lowercase first letter, then
|
|
167
|
+
* characters from `a-z 0-9 . -`, with a hyphen that is neither the first
|
|
168
|
+
* nor the last character. These are the CMSD custom-key rules restricted
|
|
169
|
+
* to names that survive RFC 8941 key serialization.
|
|
170
|
+
*
|
|
171
|
+
* @param key - The key to check.
|
|
172
|
+
*
|
|
173
|
+
* @returns `true` if the key is a custom key, `false` otherwise.
|
|
174
|
+
*
|
|
175
|
+
* @public
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* {@includeCode ../test/isCmsdCustomKey.test.ts#example}
|
|
179
|
+
*/
|
|
180
|
+
function isCmsdCustomKey(key) {
|
|
181
|
+
const separator = key.indexOf("-", 1);
|
|
182
|
+
return separator > 0 && separator < key.length - 1 && CUSTOM_KEY_REGEX.test(key);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
//#endregion
|
|
186
|
+
export { CMSD_DYNAMIC, CMSD_STATIC, CMSD_V1, CmsdHeaderField, CmsdObjectType, CmsdStreamType, CmsdStreamingFormat, decodeCmsdDynamic, decodeCmsdStatic, encodeCmsdDynamic, encodeCmsdStatic, isCmsdCustomKey };
|
|
164
187
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["results: CmsdStatic"],"sources":["../src/CMSD_DYNAMIC.ts","../src/CMSD_STATIC.ts","../src/CMSD_V1.ts","../src/CmsdHeaderField.ts","../src/CmsdObjectType.ts","../src/CmsdStreamingFormat.ts","../src/CmsdStreamType.ts","../src/decodeCmsdDynamic.ts","../src/decodeCmsdStatic.ts","../src/encodeCmsdDynamic.ts","../src/utils/processCmsd.ts","../src/encodeCmsdStatic.ts"],"sourcesContent":["/**\n * CMSD dynamic header name.\n *\n * @public\n */\nexport const CMSD_DYNAMIC = 'CMSD-Dynamic'\n","/**\n * CMSD static header name.\n *\n * @public\n */\nexport const CMSD_STATIC = 'CMSD-Static'\n","/**\n * CMSD Version 1\n *\n * @public\n */\nexport const CMSD_V1 = 1\n","import type { ValueOf } from '@svta/cml-utils'\nimport { CMSD_DYNAMIC } from './CMSD_DYNAMIC.ts'\nimport { CMSD_STATIC } from './CMSD_STATIC.ts'\n\n/**\n * CMSD header fields.\n *\n *\n * @enum\n *\n * @public\n */\nexport const CmsdHeaderField = {\n\t/**\n\t * Keys whose values persist over multiple requests for the object.\n\t */\n\tSTATIC: CMSD_STATIC as typeof CMSD_STATIC,\n\n\t/**\n\t * Keys whose values apply only to the next transmission hop. Typically a\n\t * new CMSD-Dynamic header instance will be added by each intermediary\n\t * participating in the delivery.\n\t */\n\tDYNAMIC: CMSD_DYNAMIC as typeof CMSD_DYNAMIC,\n} as const\n\n/**\n * @public\n */\nexport type CmsdHeaderField = ValueOf<typeof CmsdHeaderField>;\n","import { CmObjectType } from '@svta/cml-cta'\n\n/**\n * Common Media Server Data Object Type\n *\n *\n * @enum\n *\n * @public\n */\nexport const CmsdObjectType = CmObjectType as typeof CmObjectType\n\n/**\n * @public\n */\nexport type CmsdObjectType = CmObjectType;\n","import { CmStreamingFormat } from '@svta/cml-cta'\n\n/**\n * Common Media Server Data Streaming Format\n *\n *\n * @enum\n *\n * @public\n */\nexport const CmsdStreamingFormat = CmStreamingFormat as typeof CmStreamingFormat\n\n/**\n * @public\n */\nexport type CmsdStreamingFormat = CmStreamingFormat;\n","import { CmStreamType } from '@svta/cml-cta'\n\n/**\n * Common Media Server Data Stream Type\n *\n *\n * @enum\n *\n * @public\n */\nexport const CmsdStreamType = CmStreamType as typeof CmStreamType\n\n/**\n * @public\n */\nexport type CmsdStreamType = CmStreamType;\n","import { decodeSfList } from '@svta/cml-structured-field-values'\nimport type { CmsdDynamic } from './CmsdDynamic.ts'\n\n/**\n * Decode a CMSD dynamic string to an object.\n *\n * @param cmsd - The CMSD string to decode.\n *\n * @returns The decoded CMSD object.\n *\n * @public\n */\nexport function decodeCmsdDynamic(cmsd: string): CmsdDynamic[] {\n\tif (!cmsd) {\n\t\treturn []\n\t}\n\n\tconst sfDict = decodeSfList(cmsd)\n\n\treturn sfDict as CmsdDynamic[]\n}\n","import { decodeSfDict, symbolToStr } from '@svta/cml-structured-field-values'\nimport type { CmsdStatic } from './CmsdStatic.ts'\n\n/**\n * Decode a CMSD Static dict string to an object.\n *\n * @param cmsd - The CMSD string to decode.\n *\n * @returns The decoded CMSD object.\n *\n * @public\n */\nexport function decodeCmsdStatic(cmsd: string): CmsdStatic {\n\tif (!cmsd) {\n\t\treturn {}\n\t}\n\n\treturn Object\n\t\t.entries(decodeSfDict(cmsd))\n\t\t.reduce((acc, [key, item]) => {\n\t\t\tconst { value }: any = item\n\t\t\tacc[key as any] = (typeof value === 'symbol' ? symbolToStr(value) : value) as any\n\t\t\treturn acc\n\t\t}, {} as CmsdStatic)\n}\n","import { encodeSfList, SfItem } from '@svta/cml-structured-field-values'\nimport type { CmsdDynamic } from './CmsdDynamic.ts'\n\n/**\n * Encode a list of CMSD Dynamic objects.\n *\n * @param value - The list of `SfItems` to encode.\n *\n * @returns The encoded CMSD string.\n *\n * @public\n */\nexport function encodeCmsdDynamic(value: SfItem[]): string;\n\n/**\n * Encode a single CMSD Dynamic object.\n *\n * @param value - The server name\n * @param cmsd - The CMSD object to encode.\n *\n * @returns The encoded CMSD string.\n *\n * @public\n */\nexport function encodeCmsdDynamic(value: string, cmsd: CmsdDynamic): string;\n\nexport function encodeCmsdDynamic(value: string | SfItem[], cmsd?: CmsdDynamic): string {\n\tif (!value) {\n\t\treturn ''\n\t}\n\n\tif (typeof value === 'string') {\n\t\tif (!cmsd) {\n\t\t\treturn ''\n\t\t}\n\n\t\tvalue = [new SfItem(value, cmsd as any)]\n\t}\n\n\treturn encodeSfList(value, { whitespace: false })\n}\n","import type { CmValue } from '@svta/cml-cta'\nimport { isTokenField, isValid } from '@svta/cml-cta'\nimport { SfToken } from '@svta/cml-structured-field-values'\nimport type { CmsdEncodeOptions } from '../CmsdEncodeOptions.ts'\nimport type { CmsdStatic } from '../CmsdStatic.ts'\n\nexport function processCmsd(obj: CmsdStatic, options?: CmsdEncodeOptions): CmsdStatic {\n\tconst results: CmsdStatic = {}\n\n\tif (obj == null || typeof obj !== 'object') {\n\t\treturn results\n\t}\n\n\tconst keys = Object.keys(obj) as (keyof CmsdStatic)[]\n\tconst useSymbol = options?.useSymbol !== false\n\n\tkeys.forEach(key => {\n\t\tlet value = obj[key] as CmValue\n\n\t\t// Version should only be reported if not equal to 1.\n\t\tif (key === 'v' && value === 1) {\n\t\t\treturn\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 = useSymbol ? Symbol.for(value) : new SfToken(value)\n\t\t}\n\n\t\tresults[key as any] = value as any\n\t})\n\n\treturn results\n}\n","import { encodeSfDict } from '@svta/cml-structured-field-values'\nimport type { CmsdEncodeOptions } from './CmsdEncodeOptions.ts'\nimport type { CmsdStatic } from './CmsdStatic.ts'\nimport { processCmsd } from './utils/processCmsd.ts'\n\n/**\n * Encode a CMSD Static object.\n *\n * @param cmsd - The CMSD object to encode.\n * @param options - Encoding options\n *\n * @returns The encoded CMSD string.\n *\n * @public\n */\nexport function encodeCmsdStatic(cmsd: CmsdStatic, options?: CmsdEncodeOptions): string {\n\tif (!cmsd) {\n\t\treturn ''\n\t}\n\n\treturn encodeSfDict(processCmsd(cmsd, options), { whitespace: false })\n}\n"],"mappings":";;;;;;;;;AAKA,MAAa,eAAe;;;;;;;;;ACA5B,MAAa,cAAc;;;;;;;;;ACA3B,MAAa,UAAU;;;;;;;;;;;;ACOvB,MAAa,kBAAkB;CAI9B,QAAQ;CAOR,SAAS;CACT;;;;;;;;;;;;ACdD,MAAa,iBAAiB;;;;;;;;;;;;ACA9B,MAAa,sBAAsB;;;;;;;;;;;;ACAnC,M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}
|
|
1
|
+
{"version":3,"file":"index.js","names":["results: CmsdStatic"],"sources":["../src/CMSD_DYNAMIC.ts","../src/CMSD_STATIC.ts","../src/CMSD_V1.ts","../src/CmsdHeaderField.ts","../src/CmsdObjectType.ts","../src/CmsdStreamingFormat.ts","../src/CmsdStreamType.ts","../src/decodeCmsdDynamic.ts","../src/decodeCmsdStatic.ts","../src/encodeCmsdDynamic.ts","../src/utils/processCmsd.ts","../src/encodeCmsdStatic.ts","../src/isCmsdCustomKey.ts"],"sourcesContent":["/**\n * CMSD dynamic header name.\n *\n * @public\n */\nexport const CMSD_DYNAMIC = 'CMSD-Dynamic'\n","/**\n * CMSD static header name.\n *\n * @public\n */\nexport const CMSD_STATIC = 'CMSD-Static'\n","/**\n * CMSD Version 1\n *\n * @public\n */\nexport const CMSD_V1 = 1\n","import type { ValueOf } from '@svta/cml-utils'\nimport { CMSD_DYNAMIC } from './CMSD_DYNAMIC.ts'\nimport { CMSD_STATIC } from './CMSD_STATIC.ts'\n\n/**\n * CMSD header fields.\n *\n *\n * @enum\n *\n * @public\n */\nexport const CmsdHeaderField = {\n\t/**\n\t * Keys whose values persist over multiple requests for the object.\n\t */\n\tSTATIC: CMSD_STATIC as typeof CMSD_STATIC,\n\n\t/**\n\t * Keys whose values apply only to the next transmission hop. Typically a\n\t * new CMSD-Dynamic header instance will be added by each intermediary\n\t * participating in the delivery.\n\t */\n\tDYNAMIC: CMSD_DYNAMIC as typeof CMSD_DYNAMIC,\n} as const\n\n/**\n * @public\n */\nexport type CmsdHeaderField = ValueOf<typeof CmsdHeaderField>;\n","import { CmObjectType } from '@svta/cml-cta'\n\n/**\n * Common Media Server Data Object Type\n *\n *\n * @enum\n *\n * @public\n */\nexport const CmsdObjectType = CmObjectType as typeof CmObjectType\n\n/**\n * @public\n */\nexport type CmsdObjectType = CmObjectType;\n","import { CmStreamingFormat } from '@svta/cml-cta'\n\n/**\n * Common Media Server Data Streaming Format\n *\n *\n * @enum\n *\n * @public\n */\nexport const CmsdStreamingFormat = CmStreamingFormat as typeof CmStreamingFormat\n\n/**\n * @public\n */\nexport type CmsdStreamingFormat = CmStreamingFormat;\n","import { CmStreamType } from '@svta/cml-cta'\n\n/**\n * Common Media Server Data Stream Type\n *\n *\n * @enum\n *\n * @public\n */\nexport const CmsdStreamType = CmStreamType as typeof CmStreamType\n\n/**\n * @public\n */\nexport type CmsdStreamType = CmStreamType;\n","import { decodeSfList } from '@svta/cml-structured-field-values'\nimport type { CmsdDynamic } from './CmsdDynamic.ts'\n\n/**\n * Decode a CMSD dynamic string to an object.\n *\n * @param cmsd - The CMSD string to decode.\n *\n * @returns The decoded CMSD object.\n *\n * @public\n */\nexport function decodeCmsdDynamic(cmsd: string): CmsdDynamic[] {\n\tif (!cmsd) {\n\t\treturn []\n\t}\n\n\tconst sfDict = decodeSfList(cmsd)\n\n\treturn sfDict as CmsdDynamic[]\n}\n","import { decodeSfDict, symbolToStr } from '@svta/cml-structured-field-values'\nimport type { CmsdStatic } from './CmsdStatic.ts'\n\n/**\n * Decode a CMSD Static dict string to an object.\n *\n * @param cmsd - The CMSD string to decode.\n *\n * @returns The decoded CMSD object.\n *\n * @public\n */\nexport function decodeCmsdStatic(cmsd: string): CmsdStatic {\n\tif (!cmsd) {\n\t\treturn {}\n\t}\n\n\treturn Object\n\t\t.entries(decodeSfDict(cmsd))\n\t\t.reduce((acc, [key, item]) => {\n\t\t\tconst { value }: any = item\n\t\t\tacc[key as any] = (typeof value === 'symbol' ? symbolToStr(value) : value) as any\n\t\t\treturn acc\n\t\t}, {} as CmsdStatic)\n}\n","import { encodeSfList, SfItem } from '@svta/cml-structured-field-values'\nimport type { CmsdDynamic } from './CmsdDynamic.ts'\n\n/**\n * Encode a list of CMSD Dynamic objects.\n *\n * @param value - The list of `SfItems` to encode.\n *\n * @returns The encoded CMSD string.\n *\n * @public\n */\nexport function encodeCmsdDynamic(value: SfItem[]): string;\n\n/**\n * Encode a single CMSD Dynamic object.\n *\n * @param value - The server name\n * @param cmsd - The CMSD object to encode.\n *\n * @returns The encoded CMSD string.\n *\n * @public\n */\nexport function encodeCmsdDynamic(value: string, cmsd: CmsdDynamic): string;\n\nexport function encodeCmsdDynamic(value: string | SfItem[], cmsd?: CmsdDynamic): string {\n\tif (!value) {\n\t\treturn ''\n\t}\n\n\tif (typeof value === 'string') {\n\t\tif (!cmsd) {\n\t\t\treturn ''\n\t\t}\n\n\t\tvalue = [new SfItem(value, cmsd as any)]\n\t}\n\n\treturn encodeSfList(value, { whitespace: false })\n}\n","import type { CmValue } from '@svta/cml-cta'\nimport { isTokenField, isValid } from '@svta/cml-cta'\nimport { SfToken } from '@svta/cml-structured-field-values'\nimport type { CmsdEncodeOptions } from '../CmsdEncodeOptions.ts'\nimport type { CmsdStatic } from '../CmsdStatic.ts'\n\nexport function processCmsd(obj: CmsdStatic, options?: CmsdEncodeOptions): CmsdStatic {\n\tconst results: CmsdStatic = {}\n\n\tif (obj == null || typeof obj !== 'object') {\n\t\treturn results\n\t}\n\n\tconst keys = Object.keys(obj) as (keyof CmsdStatic)[]\n\tconst useSymbol = options?.useSymbol !== false\n\n\tkeys.forEach(key => {\n\t\tlet value = obj[key] as CmValue\n\n\t\t// Version should only be reported if not equal to 1.\n\t\tif (key === 'v' && value === 1) {\n\t\t\treturn\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 = useSymbol ? Symbol.for(value) : new SfToken(value)\n\t\t}\n\n\t\tresults[key as any] = value as any\n\t})\n\n\treturn results\n}\n","import { encodeSfDict } from '@svta/cml-structured-field-values'\nimport type { CmsdEncodeOptions } from './CmsdEncodeOptions.ts'\nimport type { CmsdStatic } from './CmsdStatic.ts'\nimport { processCmsd } from './utils/processCmsd.ts'\n\n/**\n * Encode a CMSD Static object.\n *\n * @param cmsd - The CMSD object to encode.\n * @param options - Encoding options\n *\n * @returns The encoded CMSD string.\n *\n * @public\n */\nexport function encodeCmsdStatic(cmsd: CmsdStatic, options?: CmsdEncodeOptions): string {\n\tif (!cmsd) {\n\t\treturn ''\n\t}\n\n\treturn encodeSfDict(processCmsd(cmsd, options), { whitespace: false })\n}\n","// The CMSD custom-key charset restricted to RFC 8941 key serialization\n// (serializeKey): a lowercase first letter, then `a-z 0-9 . -`.\nconst CUSTOM_KEY_REGEX = /^[a-z][a-z0-9.-]*$/\n\n/**\n * Check if a key is a valid custom key: a lowercase first letter, then\n * characters from `a-z 0-9 . -`, with a hyphen that is neither the first\n * nor the last character. These are the CMSD custom-key rules restricted\n * to names that survive RFC 8941 key serialization.\n *\n * @param key - The key to check.\n *\n * @returns `true` if the key is a custom key, `false` otherwise.\n *\n * @public\n *\n * @example\n * {@includeCode ../test/isCmsdCustomKey.test.ts#example}\n */\nexport function isCmsdCustomKey(key: string): boolean {\n\t// The separator is checked outside the regex to keep matching linear (CodeQL js/polynomial-redos).\n\tconst separator = key.indexOf('-', 1)\n\treturn separator > 0 && separator < key.length - 1 && CUSTOM_KEY_REGEX.test(key)\n}\n"],"mappings":";;;;;;;;;AAKA,MAAa,eAAe;;;;;;;;;ACA5B,MAAa,cAAc;;;;;;;;;ACA3B,MAAa,UAAU;;;;;;;;;;;;ACOvB,MAAa,kBAAkB;CAI9B,QAAQ;CAOR,SAAS;CACT;;;;;;;;;;;;ACdD,MAAa,iBAAiB;;;;;;;;;;;;ACA9B,MAAa,sBAAsB;;;;;;;;;;;;ACAnC,MAAa,iBAAiB;;;;;;;;;;;;;ACE9B,SAAgB,kBAAkB,MAA6B;AAC9D,KAAI,CAAC,KACJ,QAAO,EAAE;AAKV,QAFe,aAAa,KAAK;;;;;;;;;;;;;;ACLlC,SAAgB,iBAAiB,MAA0B;AAC1D,KAAI,CAAC,KACJ,QAAO,EAAE;AAGV,QAAO,OACL,QAAQ,aAAa,KAAK,CAAC,CAC3B,QAAQ,KAAK,CAAC,KAAK,UAAU;EAC7B,MAAM,EAAE,UAAe;AACvB,M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-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Common Media Server Data (CMSD) 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": "1.0.
|
|
56
|
-
"@svta/cml-structured-field-values": "1.1.
|
|
57
|
-
"@svta/cml-utils": "1.
|
|
55
|
+
"@svta/cml-cta": "1.0.8",
|
|
56
|
+
"@svta/cml-structured-field-values": "1.1.5",
|
|
57
|
+
"@svta/cml-utils": "1.6.0"
|
|
58
58
|
}
|
|
59
59
|
}
|