Skip to content

Commit

Permalink
Merge pull request #66 from streaming-video-technology-alliance/relea…
Browse files Browse the repository at this point in the history
…se/0.6.2

release/0.6.2

---------

Signed-off-by: Casey Occhialini <[email protected]>
  • Loading branch information
littlespex authored Jan 18, 2024
2 parents 503f310 + d367107 commit 525ef72
Show file tree
Hide file tree
Showing 37 changed files with 144 additions and 116 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]


## [0.6.2] - 2023-01-18

### Fixed
- Some imports are pulling in unnecessary files [#64](https://github.com/streaming-video-technology-alliance/common-media-library/issues/64)


## [0.6.1] - 2023-12-14

### Fixed
Expand Down Expand Up @@ -163,7 +169,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Bootstrap project [#2](https://github.com/streaming-video-technology-alliance/common-media-library/issues/2)


[Unreleased]\: https://github.com/streaming-video-technology-alliance/common-media-library/compare/v0.6.1...HEAD
[Unreleased]\: https://github.com/streaming-video-technology-alliance/common-media-library/compare/v0.6.2...HEAD
[0.6.2]\: https://github.com/streaming-video-technology-alliance/common-media-library/compare/v0.6.1...v0.6.2
[0.6.1]\: https://github.com/streaming-video-technology-alliance/common-media-library/compare/v0.6.0...v0.6.1
[0.6.0]\: https://github.com/streaming-video-technology-alliance/common-media-library/compare/v0.5.1...v0.6.0
[0.5.1]\: https://github.com/streaming-video-technology-alliance/common-media-library/compare/v0.5.0...v0.5.1
Expand Down
2 changes: 1 addition & 1 deletion dev/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@svta/common-media-library-dev",
"private": true,
"version": "0.6.1",
"version": "0.6.2",
"license": "Apache-2.0",
"type": "module",
"homepage": "https://github.com/streaming-video-technology-alliance/common-media-library",
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@svta/common-media-library-docs",
"private": true,
"version": "0.6.1",
"version": "0.6.2",
"license": "Apache-2.0",
"type": "module",
"homepage": "https://github.com/streaming-video-technology-alliance/common-media-library",
Expand Down
6 changes: 3 additions & 3 deletions lib/config/common-media-library.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ export const CMSD_V1 = 1;
export type CmsdCustomKey = CmCustomKey;

// @beta
export type CmsdDynamic = {
value: string;
export interface CmsdDynamic {
params: CmsdDynamicParams;
};
value: string;
}

// @beta
export interface CmsdDynamicParams {
Expand Down
2 changes: 1 addition & 1 deletion lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@svta/common-media-library",
"version": "0.6.1",
"version": "0.6.2",
"license": "Apache-2.0",
"type": "module",
"homepage": "https://github.com/streaming-video-technology-alliance/common-media-library",
Expand Down
2 changes: 2 additions & 0 deletions lib/src/cmcd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* A collection of tools for working with Common Media Client Data (CMCD).
*
* @packageDocumentation
*
* @beta
*/
export { CMCD_PARAM } from './cmcd/CMCD_PARAM.js';
export { CMCD_V1 } from './cmcd/CMCD_V1.js';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/cmcd/CmcdFormatters.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { urlToRelativePath } from '../utils.js';
import { urlToRelativePath } from '../utils/urlToRelativePath.js';
import { CmcdEncodeOptions } from './CmcdEncodeOptions.js';
import { CmcdFormatter } from './CmcdFormatter.js';
import { CmcdValue } from './CmcdValue.js';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/cmcd/decodeCmcd.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { symbolToStr } from '../cta/utils/symbolToStr.js';
import { SfItem } from '../structuredfield.js';
import { SfItem } from '../structuredfield/SfItem.js';
import { decodeSfDict } from '../structuredfield/decodeSfDict.js';
import { Cmcd } from './Cmcd.js';

Expand Down
2 changes: 1 addition & 1 deletion lib/src/cmcd/encodeCmcd.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { encodeSfDict } from '../structuredfield.js';
import { encodeSfDict } from '../structuredfield/encodeSfDict.js';
import { Cmcd } from './Cmcd.js';
import { CmcdEncodeOptions } from './CmcdEncodeOptions.js';
import { processCmcd } from './utils/processCmcd.js';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/cmcd/toCmcdJson.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { symbolToStr } from '../cta/utils/symbolToStr.js';
import { SfToken } from '../structuredfield.js';
import { SfToken } from '../structuredfield/SfToken.js';
import { Cmcd } from './Cmcd.js';
import { CmcdEncodeOptions } from './CmcdEncodeOptions.js';
import { processCmcd } from './utils/processCmcd.js';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/cmsd/CmsdDynamic.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CmsdDynamicParams } from './CmsdDynamicParams';
import { CmsdDynamicParams } from './CmsdDynamicParams.js';

/**
* Common Media Server Data (CMSD) dynamic response header fields.
Expand Down
4 changes: 2 additions & 2 deletions lib/src/cmsd/CmsdDynamicParams.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CmsdCustomKey } from './CmsdCustomKey';
import { CmsdValue } from './CmsdValue';
import { CmsdCustomKey } from './CmsdCustomKey.js';
import { CmsdValue } from './CmsdValue.js';

/**
* Common Media Server Data (CMSD) dynamic response header field parameters.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/cta/utils/isValid.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CmValue } from '../CmValue';
import { CmValue } from '../CmValue.js';

export const isValid = (value: CmValue) => {
if (typeof value === 'number') {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/cta/utils/symbolToStr.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SfToken } from '../../structuredfield/SfToken';
import { SfToken } from '../../structuredfield/SfToken.js';

export function symbolToStr(symbol: symbol | SfToken) {
return symbol.description || symbol.toString().slice(7, -1);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/id3/isId3TimestampFrame.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Id3Frame } from './Id3Frame';
import { Id3Frame } from './Id3Frame.js';

/**
* Returns true if the ID3 frame is an Elementary Stream timestamp frame
Expand Down
1 change: 0 additions & 1 deletion lib/src/id3/util/isId3Header.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Returns true if an ID3 header can be found at offset in data
*
Expand Down
2 changes: 1 addition & 1 deletion lib/src/request/CommonMediaRequest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Cmcd } from '../cmcd.js';
import { Cmcd } from '../cmcd/Cmcd.js';

/**
* Common request API.
Expand Down
1 change: 0 additions & 1 deletion lib/src/structuredfield/SfDecodeOptions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Options for decoding Structured Field values
*
Expand Down
1 change: 0 additions & 1 deletion lib/src/structuredfield/SfEncodeOptions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Options for encoding a structured field.
*
Expand Down
6 changes: 4 additions & 2 deletions lib/src/structuredfield/decodeSfItem.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { SfDecodeOptions } from './SfDecodeOptions.js';
import { parseError } from './parse/parseError.js';
import { parseItem } from './parse/parseItem.js';
import { ITEM } from './utils/ITEM.js';

// 4.2. Parsing Structured Fields
//
Expand Down Expand Up @@ -37,11 +38,12 @@ export function decodeSfItem(input: string, options?: SfDecodeOptions) {
try {
const { src, value } = parseItem(input.trim(), options);
if (src !== '') {
throw parseError(src, 'Item');
throw parseError(src, ITEM);
}

return value;
}
catch (cause) {
throw parseError(input, 'Item', cause);
throw parseError(input, ITEM, cause);
}
}
4 changes: 4 additions & 0 deletions lib/src/structuredfield/parse/ParsedValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ export type ParsedValue<T> = {
value: T;
src: string;
}

export function parsedValue<T>(value: T, src: string): ParsedValue<T> {
return { value, src };
}
16 changes: 7 additions & 9 deletions lib/src/structuredfield/parse/parseBoolean.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BOOLEAN } from '../utils/BOOLEAN.js';
import { ParsedValue } from './ParsedValue.js';
import { ParsedValue, parsedValue } from './ParsedValue.js';
import { parseError } from './parseError.js';

// 4.2.8. Parsing a Boolean
Expand All @@ -23,18 +23,16 @@ export function parseBoolean(src: string): ParsedValue<boolean> {
if (src[i] !== '?') {
throw parseError(src, BOOLEAN);
}

i++;

if (src[i] === '1') {
return {
value: true,
src: src.substring(++i),
};
return parsedValue(true, src.substring(++i));
}

if (src[i] === '0') {
return {
value: false,
src: src.substring(++i),
};
return parsedValue(false, src.substring(++i));
}

throw parseError(src, BOOLEAN);
}
11 changes: 7 additions & 4 deletions lib/src/structuredfield/parse/parseByteSequence.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { base64decode } from '../../utils/base64decode.js';
import { BYTES } from '../utils/BYTES.js';
import { ParsedValue } from './ParsedValue.js';
import { ParsedValue, parsedValue } from './ParsedValue.js';
import { parseError } from './parseError.js';

// 4.2.7. Parsing a Byte Sequence
Expand Down Expand Up @@ -47,16 +47,19 @@ export function parseByteSequence(src: string): ParsedValue<Uint8Array> {
if (src[0] !== ':') {
throw parseError(src, BYTES);
}

src = src.substring(1);
if (src.includes(':') === false) {
throw parseError(src, BYTES);
}

const re = /(^.*?)(:)/g;
const b64_content = (re.exec(src) as any)[1];
src = src.substring(re.lastIndex);

// pass b64_content char check step 6
return {
value: base64decode(b64_content),
return parsedValue(
base64decode(b64_content),
src,
};
);
}
13 changes: 8 additions & 5 deletions lib/src/structuredfield/parse/parseDate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DATE } from '../utils/DATE.js';
import { ParsedValue } from './ParsedValue.js';
import { ParsedValue, parsedValue } from './ParsedValue.js';
import { parseError } from './parseError.js';
import { parseIntegerOrDecimal } from './parseIntegerOrDecimal.js';

Expand All @@ -23,13 +23,16 @@ export function parseDate(src: string): ParsedValue<Date> {
if (src[i] !== '@') {
throw parseError(src, DATE);
}

i++;
const date = parseIntegerOrDecimal(src.substring(i));

if (Number.isInteger(date.value) === false) {
throw parseError(src, DATE);
}
return {
value: new Date(date.value * 1000),
src: date.src,
};

return parsedValue(
new Date(date.value * 1000),
date.src,
);
}
25 changes: 12 additions & 13 deletions lib/src/structuredfield/parse/parseDict.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { SfDictionary } from '../SfDictionary.js';
import { SfInnerList } from '../SfInnerList.js';
import { SfItem } from '../SfItem.js';
import { DICT } from '../utils/DICT.js';
import { ParsedValue } from './ParsedValue.js';
import { ParsedValue, parsedValue } from './ParsedValue.js';
import { parseError } from './parseError.js';
import { parseItemOrInnerList } from './parseItemOrInnerList.js';
import { parseKey } from './parseKey.js';
Expand Down Expand Up @@ -60,17 +60,14 @@ import { parseParameters } from './parseParameters.js';
// Note that when duplicate Dictionary keys are encountered, this has
// the effect of ignoring all but the last instance.
export function parseDict(src: string, options?: SfDecodeOptions): ParsedValue<SfDictionary> {
const value: [string, SfItem | SfInnerList][] = [];

function toDict(entries: [string, SfItem | SfInnerList][]) {
return Object.fromEntries(entries);
}
const value: SfDictionary = {};

while (src.length > 0) {
let member: SfItem | SfInnerList;
const parsedKey = parseKey(src);
const this_key = parsedKey.value;
const key = parsedKey.value;
src = parsedKey.src;

if (src[0] === '=') {
const parsedItemOrInnerList = parseItemOrInnerList(src.substring(1), options);
member = parsedItemOrInnerList.value;
Expand All @@ -81,21 +78,23 @@ export function parseDict(src: string, options?: SfDecodeOptions): ParsedValue<S
member = new SfItem(true, parsedParameters.value);
src = parsedParameters.src;
}
value.push([this_key, member]);

value[key] = member;

src = src.trim();
if (src.length === 0) {
return { src, value: toDict(value) };
return parsedValue(value, src);
}

if (src[0] !== ',') {
throw parseError(src, DICT);
}

src = src.substring(1).trim();
if (src.length === 0 || src[0] === ',') {
throw parseError(src, DICT);
}
}
return {
value: toDict(value),
src,
};

return parsedValue(value, src);
}
15 changes: 10 additions & 5 deletions lib/src/structuredfield/parse/parseInnerList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { SfDecodeOptions } from '../SfDecodeOptions.js';
import { SfInnerList } from '../SfInnerList.js';
import { SfItem } from '../SfItem.js';
import { INNER } from '../utils/INNER.js';
import { ParsedValue } from './ParsedValue.js';
import { ParsedValue, parsedValue } from './ParsedValue.js';
import { parseError } from './parseError.js';
import { parseItem } from './parseItem.js';
import { parseParameters } from './parseParameters.js';
Expand Down Expand Up @@ -44,24 +44,29 @@ export function parseInnerList(src: string, options?: SfDecodeOptions): ParsedVa
if (src[0] !== '(') {
throw parseError(src, INNER);
}

src = src.substring(1);
const innerList: SfItem[] = [];
while (src.length > 0) {
src = src.trim();
if (src[0] === ')') {
src = src.substring(1);
const parsedParameters = parseParameters(src, options);
return {
value: new SfItem(innerList, parsedParameters.value) as any,
src: parsedParameters.src,
};

return parsedValue(
new SfItem(innerList, parsedParameters.value) as any,
parsedParameters.src,
);
}

const parsedItem = parseItem(src, options);
innerList.push(parsedItem.value);
src = parsedItem.src;

if (src[0] !== ' ' && src[0] !== ')') {
throw parseError(src, INNER);
}
}

throw parseError(src, INNER);
}
Loading

0 comments on commit 525ef72

Please sign in to comment.