@internetarchive/radio-player 0.0.3 → 0.0.4-alpha.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.
Files changed (93) hide show
  1. package/LICENSE +661 -661
  2. package/README.md +142 -142
  3. package/index.d.ts +15 -15
  4. package/index.js +28 -28
  5. package/lib/demo/full-text-search-service.d.ts +14 -14
  6. package/lib/demo/full-text-search-service.js +33 -33
  7. package/lib/demo/radio-player-controller.d.ts +41 -41
  8. package/lib/demo/radio-player-controller.js +199 -199
  9. package/lib/src/assets/img/left.d.ts +2 -2
  10. package/lib/src/assets/img/left.js +15 -15
  11. package/lib/src/assets/img/right.d.ts +2 -2
  12. package/lib/src/assets/img/right.js +15 -15
  13. package/lib/src/models/music-zone.d.ts +12 -12
  14. package/lib/src/models/music-zone.js +15 -15
  15. package/lib/src/models/radio-player-config.d.ts +26 -26
  16. package/lib/src/models/radio-player-config.js +27 -27
  17. package/lib/src/radio-player.d.ts +589 -589
  18. package/lib/src/radio-player.js +1338 -1338
  19. package/lib/src/search-handler/search-backends/full-text-search-backend/full-text-search-backend.d.ts +82 -82
  20. package/lib/src/search-handler/search-backends/full-text-search-backend/full-text-search-backend.js +107 -107
  21. package/lib/src/search-handler/search-backends/full-text-search-backend/full-text-search-response.d.ts +48 -48
  22. package/lib/src/search-handler/search-backends/full-text-search-backend/full-text-search-response.js +58 -58
  23. package/lib/src/search-handler/search-backends/full-text-search-backend/full-text-search-service-interface.d.ts +16 -16
  24. package/lib/src/search-handler/search-backends/full-text-search-backend/full-text-search-service-interface.js +1 -1
  25. package/lib/src/search-handler/search-backends/local-search-backend/local-search-backend.d.ts +27 -27
  26. package/lib/src/search-handler/search-backends/local-search-backend/local-search-backend.js +42 -42
  27. package/lib/src/search-handler/search-backends/search-backend-interface.d.ts +9 -9
  28. package/lib/src/search-handler/search-backends/search-backend-interface.js +1 -1
  29. package/lib/src/search-handler/search-handler-interface.d.ts +17 -17
  30. package/lib/src/search-handler/search-handler-interface.js +1 -1
  31. package/lib/src/search-handler/search-handler.d.ts +83 -83
  32. package/lib/src/search-handler/search-handler.js +177 -177
  33. package/lib/src/search-handler/search-helper.d.ts +12 -12
  34. package/lib/src/search-handler/search-helper.js +22 -22
  35. package/lib/src/search-handler/search-models.d.ts +45 -45
  36. package/lib/src/search-handler/search-models.js +49 -49
  37. package/lib/src/search-handler/transcript-index-interface.d.ts +38 -38
  38. package/lib/src/search-handler/transcript-index-interface.js +1 -1
  39. package/lib/src/search-handler/transcript-index.d.ts +53 -53
  40. package/lib/src/search-handler/transcript-index.js +80 -80
  41. package/lib/src/search-results-switcher.d.ts +58 -58
  42. package/lib/src/search-results-switcher.js +133 -133
  43. package/package.json +93 -93
  44. package/src/assets/img/left.ts +17 -17
  45. package/src/assets/img/right.ts +17 -17
  46. package/src/models/music-zone.ts +17 -17
  47. package/src/models/radio-player-config.ts +47 -47
  48. package/src/radio-player.ts +1402 -1402
  49. package/src/search-handler/search-backends/full-text-search-backend/full-text-search-backend.ts +140 -140
  50. package/src/search-handler/search-backends/full-text-search-backend/full-text-search-response.ts +110 -110
  51. package/src/search-handler/search-backends/full-text-search-backend/full-text-search-service-interface.ts +17 -17
  52. package/src/search-handler/search-backends/local-search-backend/local-search-backend.ts +50 -50
  53. package/src/search-handler/search-backends/search-backend-interface.ts +10 -10
  54. package/src/search-handler/search-handler-interface.ts +18 -18
  55. package/src/search-handler/search-handler.ts +217 -217
  56. package/src/search-handler/search-helper.ts +25 -25
  57. package/src/search-handler/search-models.ts +69 -69
  58. package/src/search-handler/transcript-index-interface.ts +42 -42
  59. package/src/search-handler/transcript-index.ts +93 -93
  60. package/src/search-results-switcher.ts +131 -131
  61. package/.eslintrc +0 -37
  62. package/.gitignore +0 -11
  63. package/.storybook/.babelrc +0 -15
  64. package/.storybook/addons.js +0 -7
  65. package/.storybook/config.js +0 -11
  66. package/.storybook/webpack.config.js +0 -5
  67. package/demo/full-text-search-service.ts +0 -32
  68. package/demo/index.html +0 -53
  69. package/demo/radio-player-controller.ts +0 -237
  70. package/karma.bs.config.js +0 -16
  71. package/karma.conf.js +0 -66
  72. package/package-lock.json +0 -51719
  73. package/stories/index.stories.js +0 -40
  74. package/stories/transcript.js +0 -683
  75. package/test/assets/arrow.mp3 +0 -0
  76. package/test/music-zone.test.js +0 -13
  77. package/test/promised-sleep.js +0 -3
  78. package/test/radio-player-config.test.js +0 -42
  79. package/test/radio-player.test.js +0 -1072
  80. package/test/sample_transcript.js +0 -1493
  81. package/test/search-handler/search-backends/full-text-sample-response-brackets.js +0 -60
  82. package/test/search-handler/search-backends/full-text-sample-response-em.js +0 -60
  83. package/test/search-handler/search-backends/full-text-search-backend.test.js +0 -74
  84. package/test/search-handler/search-backends/full-text-search-response.test.js +0 -14
  85. package/test/search-handler/search-backends/local-search-backend.test.js +0 -39
  86. package/test/search-handler/search-handler.test.js +0 -550
  87. package/test/search-handler/search-helper.test.js +0 -63
  88. package/test/search-handler/search-model.test.js +0 -56
  89. package/test/search-handler/transcript-index.test.js +0 -66
  90. package/test/search-results-switcher.test.js +0 -97
  91. package/tsconfig.build.json +0 -7
  92. package/tsconfig.json +0 -21
  93. package/yarn.lock +0 -14450
@@ -1,38 +1,38 @@
1
- import { TranscriptEntryRange } from './search-models';
2
- /**
3
- * The TranscriptIndexInterface defines methods needed to access and rebuild the transcript.
4
- *
5
- * @export
6
- * @interface TranscriptIndexInterface
7
- */
8
- export interface TranscriptIndexInterface {
9
- /**
10
- * The merged transcript, combining all entries with a single space
11
- *
12
- * @type {string}
13
- * @memberof TranscriptIndexInterface
14
- */
15
- mergedTranscript: string;
16
- /**
17
- * The merged transcript lowercased for case-insensitive lookups
18
- *
19
- * @type {string}
20
- * @memberof TranscriptIndexInterface
21
- */
22
- mergedTranscriptLowercased: string;
23
- /**
24
- * An array of transcript entries with their associated character ranges
25
- *
26
- * @type {TranscriptEntryRange[]}
27
- * @memberof TranscriptIndexInterface
28
- */
29
- transcriptEntryRanges: TranscriptEntryRange[];
30
- /**
31
- * Get the TranscriptEntryRange at a given index
32
- *
33
- * @param {number} overallCharIndex
34
- * @returns {(TranscriptEntryRange | undefined)}
35
- * @memberof TranscriptIndexInterface
36
- */
37
- getTranscriptEntryAt(overallCharIndex: number): TranscriptEntryRange | undefined;
38
- }
1
+ import { TranscriptEntryRange } from './search-models';
2
+ /**
3
+ * The TranscriptIndexInterface defines methods needed to access and rebuild the transcript.
4
+ *
5
+ * @export
6
+ * @interface TranscriptIndexInterface
7
+ */
8
+ export interface TranscriptIndexInterface {
9
+ /**
10
+ * The merged transcript, combining all entries with a single space
11
+ *
12
+ * @type {string}
13
+ * @memberof TranscriptIndexInterface
14
+ */
15
+ mergedTranscript: string;
16
+ /**
17
+ * The merged transcript lowercased for case-insensitive lookups
18
+ *
19
+ * @type {string}
20
+ * @memberof TranscriptIndexInterface
21
+ */
22
+ mergedTranscriptLowercased: string;
23
+ /**
24
+ * An array of transcript entries with their associated character ranges
25
+ *
26
+ * @type {TranscriptEntryRange[]}
27
+ * @memberof TranscriptIndexInterface
28
+ */
29
+ transcriptEntryRanges: TranscriptEntryRange[];
30
+ /**
31
+ * Get the TranscriptEntryRange at a given index
32
+ *
33
+ * @param {number} overallCharIndex
34
+ * @returns {(TranscriptEntryRange | undefined)}
35
+ * @memberof TranscriptIndexInterface
36
+ */
37
+ getTranscriptEntryAt(overallCharIndex: number): TranscriptEntryRange | undefined;
38
+ }
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=transcript-index-interface.js.map
@@ -1,53 +1,53 @@
1
- import { TranscriptConfig } from '@internetarchive/transcript-view';
2
- import { TranscriptEntryRange } from './search-models';
3
- import { TranscriptIndexInterface } from './transcript-index-interface';
4
- /**
5
- * The TranscriptIndex takes the original transcript and indexes it to make
6
- * transcript entry lookups more efficient.
7
- */
8
- export declare class TranscriptIndex implements TranscriptIndexInterface {
9
- /** @inheritdoc */
10
- get mergedTranscript(): string;
11
- /** @inheritdoc */
12
- get mergedTranscriptLowercased(): string;
13
- /** @inheritdoc */
14
- get transcriptEntryRanges(): TranscriptEntryRange[];
15
- /** @inheritdoc */
16
- getTranscriptEntryAt(overallCharIndex: number): TranscriptEntryRange | undefined;
17
- /**
18
- * This gets populated as part of the search index build. It merges all of the transcript
19
- * entries together so we can search it as a single document instead of a bunch of
20
- * individual entries. This allows searches to cross over transcript entries.
21
- *
22
- * NOTE: When the mergedTranscript gets created, spaces are put between each transcript
23
- * entry, otherwise the words would run into each other. We account for this in the
24
- * indices above.
25
- *
26
- * @type {string}
27
- * @memberof TranscriptIndex
28
- */
29
- private mergedTranscriptCache;
30
- private mergedTranscriptLowercasedCache;
31
- /**
32
- * This gets populated as part of the search index build. It maps the start and end indicies
33
- * of all of the transcript entries so we can quickly look up where an entry is in the
34
- * overall transcript.
35
- *
36
- * @type {TranscriptEntryRange[]}
37
- * @memberof TranscriptIndex
38
- */
39
- private transcriptEntryRangesCache;
40
- constructor(transcriptConfig: TranscriptConfig);
41
- /**
42
- * Build the search index. This method does two things:
43
- * 1. Builds the "merged transcript" with all of the text combined into one long transcript.
44
- * This allows us to search the entire thing at once instead of entry by entry.
45
- * 2. For each entry, get the start and end index of that particular entry within the overall
46
- * transcript. This allows us to reconstruct the transcript later from the original transcript
47
- * and the search results.
48
- *
49
- * @private
50
- * @memberof TranscriptIndex
51
- */
52
- private buildIndex;
53
- }
1
+ import { TranscriptConfig } from '@internetarchive/transcript-view';
2
+ import { TranscriptEntryRange } from './search-models';
3
+ import { TranscriptIndexInterface } from './transcript-index-interface';
4
+ /**
5
+ * The TranscriptIndex takes the original transcript and indexes it to make
6
+ * transcript entry lookups more efficient.
7
+ */
8
+ export declare class TranscriptIndex implements TranscriptIndexInterface {
9
+ /** @inheritdoc */
10
+ get mergedTranscript(): string;
11
+ /** @inheritdoc */
12
+ get mergedTranscriptLowercased(): string;
13
+ /** @inheritdoc */
14
+ get transcriptEntryRanges(): TranscriptEntryRange[];
15
+ /** @inheritdoc */
16
+ getTranscriptEntryAt(overallCharIndex: number): TranscriptEntryRange | undefined;
17
+ /**
18
+ * This gets populated as part of the search index build. It merges all of the transcript
19
+ * entries together so we can search it as a single document instead of a bunch of
20
+ * individual entries. This allows searches to cross over transcript entries.
21
+ *
22
+ * NOTE: When the mergedTranscript gets created, spaces are put between each transcript
23
+ * entry, otherwise the words would run into each other. We account for this in the
24
+ * indices above.
25
+ *
26
+ * @type {string}
27
+ * @memberof TranscriptIndex
28
+ */
29
+ private mergedTranscriptCache;
30
+ private mergedTranscriptLowercasedCache;
31
+ /**
32
+ * This gets populated as part of the search index build. It maps the start and end indicies
33
+ * of all of the transcript entries so we can quickly look up where an entry is in the
34
+ * overall transcript.
35
+ *
36
+ * @type {TranscriptEntryRange[]}
37
+ * @memberof TranscriptIndex
38
+ */
39
+ private transcriptEntryRangesCache;
40
+ constructor(transcriptConfig: TranscriptConfig);
41
+ /**
42
+ * Build the search index. This method does two things:
43
+ * 1. Builds the "merged transcript" with all of the text combined into one long transcript.
44
+ * This allows us to search the entire thing at once instead of entry by entry.
45
+ * 2. For each entry, get the start and end index of that particular entry within the overall
46
+ * transcript. This allows us to reconstruct the transcript later from the original transcript
47
+ * and the search results.
48
+ *
49
+ * @private
50
+ * @memberof TranscriptIndex
51
+ */
52
+ private buildIndex;
53
+ }
@@ -1,81 +1,81 @@
1
- import { Range, TranscriptEntryRange } from './search-models';
2
- /**
3
- * The TranscriptIndex takes the original transcript and indexes it to make
4
- * transcript entry lookups more efficient.
5
- */
6
- export class TranscriptIndex {
7
- constructor(transcriptConfig) {
8
- /**
9
- * This gets populated as part of the search index build. It merges all of the transcript
10
- * entries together so we can search it as a single document instead of a bunch of
11
- * individual entries. This allows searches to cross over transcript entries.
12
- *
13
- * NOTE: When the mergedTranscript gets created, spaces are put between each transcript
14
- * entry, otherwise the words would run into each other. We account for this in the
15
- * indices above.
16
- *
17
- * @type {string}
18
- * @memberof TranscriptIndex
19
- */
20
- this.mergedTranscriptCache = '';
21
- this.mergedTranscriptLowercasedCache = '';
22
- /**
23
- * This gets populated as part of the search index build. It maps the start and end indicies
24
- * of all of the transcript entries so we can quickly look up where an entry is in the
25
- * overall transcript.
26
- *
27
- * @type {TranscriptEntryRange[]}
28
- * @memberof TranscriptIndex
29
- */
30
- this.transcriptEntryRangesCache = [];
31
- this.buildIndex(transcriptConfig);
32
- }
33
- /** @inheritdoc */
34
- get mergedTranscript() {
35
- return this.mergedTranscriptCache;
36
- }
37
- /** @inheritdoc */
38
- get mergedTranscriptLowercased() {
39
- return this.mergedTranscriptLowercasedCache;
40
- }
41
- /** @inheritdoc */
42
- get transcriptEntryRanges() {
43
- return this.transcriptEntryRangesCache;
44
- }
45
- /** @inheritdoc */
46
- getTranscriptEntryAt(overallCharIndex) {
47
- return this.transcriptEntryRanges.find((entry) => {
48
- const { range } = entry;
49
- return range.endIndex > overallCharIndex && range.startIndex <= overallCharIndex;
50
- });
51
- }
52
- /**
53
- * Build the search index. This method does two things:
54
- * 1. Builds the "merged transcript" with all of the text combined into one long transcript.
55
- * This allows us to search the entire thing at once instead of entry by entry.
56
- * 2. For each entry, get the start and end index of that particular entry within the overall
57
- * transcript. This allows us to reconstruct the transcript later from the original transcript
58
- * and the search results.
59
- *
60
- * @private
61
- * @memberof TranscriptIndex
62
- */
63
- buildIndex(transcriptConfig) {
64
- let startIndex = 0;
65
- const transcriptEntryRanges = [];
66
- let mergedTranscript = '';
67
- transcriptConfig.entries.forEach((entry) => {
68
- const { displayText } = entry;
69
- const indexMapRange = new Range(startIndex, startIndex + displayText.length);
70
- const indexMap = new TranscriptEntryRange(entry, indexMapRange);
71
- transcriptEntryRanges.push(indexMap);
72
- mergedTranscript += `${entry.rawText} `;
73
- startIndex = mergedTranscript.length;
74
- });
75
- mergedTranscript = mergedTranscript.trim();
76
- this.mergedTranscriptCache = mergedTranscript;
77
- this.mergedTranscriptLowercasedCache = mergedTranscript.toLowerCase();
78
- this.transcriptEntryRangesCache = transcriptEntryRanges;
79
- }
80
- }
1
+ import { Range, TranscriptEntryRange } from './search-models';
2
+ /**
3
+ * The TranscriptIndex takes the original transcript and indexes it to make
4
+ * transcript entry lookups more efficient.
5
+ */
6
+ export class TranscriptIndex {
7
+ constructor(transcriptConfig) {
8
+ /**
9
+ * This gets populated as part of the search index build. It merges all of the transcript
10
+ * entries together so we can search it as a single document instead of a bunch of
11
+ * individual entries. This allows searches to cross over transcript entries.
12
+ *
13
+ * NOTE: When the mergedTranscript gets created, spaces are put between each transcript
14
+ * entry, otherwise the words would run into each other. We account for this in the
15
+ * indices above.
16
+ *
17
+ * @type {string}
18
+ * @memberof TranscriptIndex
19
+ */
20
+ this.mergedTranscriptCache = '';
21
+ this.mergedTranscriptLowercasedCache = '';
22
+ /**
23
+ * This gets populated as part of the search index build. It maps the start and end indicies
24
+ * of all of the transcript entries so we can quickly look up where an entry is in the
25
+ * overall transcript.
26
+ *
27
+ * @type {TranscriptEntryRange[]}
28
+ * @memberof TranscriptIndex
29
+ */
30
+ this.transcriptEntryRangesCache = [];
31
+ this.buildIndex(transcriptConfig);
32
+ }
33
+ /** @inheritdoc */
34
+ get mergedTranscript() {
35
+ return this.mergedTranscriptCache;
36
+ }
37
+ /** @inheritdoc */
38
+ get mergedTranscriptLowercased() {
39
+ return this.mergedTranscriptLowercasedCache;
40
+ }
41
+ /** @inheritdoc */
42
+ get transcriptEntryRanges() {
43
+ return this.transcriptEntryRangesCache;
44
+ }
45
+ /** @inheritdoc */
46
+ getTranscriptEntryAt(overallCharIndex) {
47
+ return this.transcriptEntryRanges.find((entry) => {
48
+ const { range } = entry;
49
+ return range.endIndex > overallCharIndex && range.startIndex <= overallCharIndex;
50
+ });
51
+ }
52
+ /**
53
+ * Build the search index. This method does two things:
54
+ * 1. Builds the "merged transcript" with all of the text combined into one long transcript.
55
+ * This allows us to search the entire thing at once instead of entry by entry.
56
+ * 2. For each entry, get the start and end index of that particular entry within the overall
57
+ * transcript. This allows us to reconstruct the transcript later from the original transcript
58
+ * and the search results.
59
+ *
60
+ * @private
61
+ * @memberof TranscriptIndex
62
+ */
63
+ buildIndex(transcriptConfig) {
64
+ let startIndex = 0;
65
+ const transcriptEntryRanges = [];
66
+ let mergedTranscript = '';
67
+ transcriptConfig.entries.forEach((entry) => {
68
+ const { displayText } = entry;
69
+ const indexMapRange = new Range(startIndex, startIndex + displayText.length);
70
+ const indexMap = new TranscriptEntryRange(entry, indexMapRange);
71
+ transcriptEntryRanges.push(indexMap);
72
+ mergedTranscript += `${entry.rawText} `;
73
+ startIndex = mergedTranscript.length;
74
+ });
75
+ mergedTranscript = mergedTranscript.trim();
76
+ this.mergedTranscriptCache = mergedTranscript;
77
+ this.mergedTranscriptLowercasedCache = mergedTranscript.toLowerCase();
78
+ this.transcriptEntryRangesCache = transcriptEntryRanges;
79
+ }
80
+ }
81
81
  //# sourceMappingURL=transcript-index.js.map
@@ -1,58 +1,58 @@
1
- import { LitElement, CSSResult, TemplateResult, PropertyValues } from 'lit';
2
- /**
3
- * A widget to switch between search results that looks like this:
4
- * < 3 / 7 >
5
- *
6
- * @export
7
- * @class SearchResultsSwitcher
8
- * @extends {LitElement}
9
- */
10
- export default class SearchResultsSwitcher extends LitElement {
11
- numberOfResults: number;
12
- currentResultIndex: number;
13
- /**
14
- * LitElement life cycle render method. Entrypoint for rendering the element.
15
- *
16
- * @returns {TemplateResult}
17
- * @memberof SearchResultsSwitcher
18
- */
19
- render(): TemplateResult;
20
- /**
21
- * LitElement life cycle CSS for this element
22
- *
23
- * @readonly
24
- * @static
25
- * @type {CSSResult}
26
- * @memberof SearchResultsSwitcher
27
- */
28
- static get styles(): CSSResult;
29
- /**
30
- * LitElement lifecycle updated method
31
- *
32
- * @param {PropertyValues} changedProperties
33
- * @memberof SearchResultsSwitcher
34
- */
35
- updated(changedProperties: PropertyValues): void;
36
- /**
37
- * Called when user clicks on the previous result button.
38
- * Loops around to the last result when we reach the first.
39
- *
40
- * @memberof SearchResultsSwitcher
41
- */
42
- goToPreviousResult(): void;
43
- /**
44
- * Called when user clicks on the next result button.
45
- * Loops around to the first result when we reach the last.
46
- *
47
- * @memberof SearchResultsSwitcher
48
- */
49
- goToNextResult(): void;
50
- /**
51
- * Emit an searchResultIndexChanged event that the index has been changed
52
- *
53
- * ie: `e.detail.searchResultIndex = 2`
54
- *
55
- * @memberof SearchResultsSwitcher
56
- */
57
- emitSearchResultIndexChangedEvent(): void;
58
- }
1
+ import { LitElement, CSSResult, TemplateResult, PropertyValues } from 'lit';
2
+ /**
3
+ * A widget to switch between search results that looks like this:
4
+ * < 3 / 7 >
5
+ *
6
+ * @export
7
+ * @class SearchResultsSwitcher
8
+ * @extends {LitElement}
9
+ */
10
+ export default class SearchResultsSwitcher extends LitElement {
11
+ numberOfResults: number;
12
+ currentResultIndex: number;
13
+ /**
14
+ * LitElement life cycle render method. Entrypoint for rendering the element.
15
+ *
16
+ * @returns {TemplateResult}
17
+ * @memberof SearchResultsSwitcher
18
+ */
19
+ render(): TemplateResult;
20
+ /**
21
+ * LitElement life cycle CSS for this element
22
+ *
23
+ * @readonly
24
+ * @static
25
+ * @type {CSSResult}
26
+ * @memberof SearchResultsSwitcher
27
+ */
28
+ static get styles(): CSSResult;
29
+ /**
30
+ * LitElement lifecycle updated method
31
+ *
32
+ * @param {PropertyValues} changedProperties
33
+ * @memberof SearchResultsSwitcher
34
+ */
35
+ updated(changedProperties: PropertyValues): void;
36
+ /**
37
+ * Called when user clicks on the previous result button.
38
+ * Loops around to the last result when we reach the first.
39
+ *
40
+ * @memberof SearchResultsSwitcher
41
+ */
42
+ goToPreviousResult(): void;
43
+ /**
44
+ * Called when user clicks on the next result button.
45
+ * Loops around to the first result when we reach the last.
46
+ *
47
+ * @memberof SearchResultsSwitcher
48
+ */
49
+ goToNextResult(): void;
50
+ /**
51
+ * Emit an searchResultIndexChanged event that the index has been changed
52
+ *
53
+ * ie: `e.detail.searchResultIndex = 2`
54
+ *
55
+ * @memberof SearchResultsSwitcher
56
+ */
57
+ emitSearchResultIndexChangedEvent(): void;
58
+ }