@internetarchive/radio-player 0.0.3-a4 → 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 (60) 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
@@ -1,27 +1,27 @@
1
- import { Range } from '../../search-models';
2
- import { TranscriptIndexInterface } from '../../transcript-index-interface';
3
- import { SearchBackendInterface } from '../search-backend-interface';
4
- /**
5
- * The LocalSearchBackend is a simple browser-side search backend that
6
- * can be substituted for the FullTextSearchBackend. It implements
7
- * the `SearchBackendInterface` so you can inject it into the `SearchHandler`.
8
- */
9
- export declare class LocalSearchBackend implements SearchBackendInterface {
10
- /**
11
- * The TranscriptIndex allows quick lookup
12
- *
13
- * @private
14
- * @memberof LocalSearchBackend
15
- */
16
- private transcriptIndex;
17
- /**
18
- * Finds all of the ranges of all the search results across the entire transcript.
19
- *
20
- * @private
21
- * @param {string} query
22
- * @returns {Promise<Range[]>}
23
- * @memberof SearchBackendInterface
24
- */
25
- getSearchRanges(query: string): Promise<Range[]>;
26
- constructor(transcriptIndex: TranscriptIndexInterface);
27
- }
1
+ import { Range } from '../../search-models';
2
+ import { TranscriptIndexInterface } from '../../transcript-index-interface';
3
+ import { SearchBackendInterface } from '../search-backend-interface';
4
+ /**
5
+ * The LocalSearchBackend is a simple browser-side search backend that
6
+ * can be substituted for the FullTextSearchBackend. It implements
7
+ * the `SearchBackendInterface` so you can inject it into the `SearchHandler`.
8
+ */
9
+ export declare class LocalSearchBackend implements SearchBackendInterface {
10
+ /**
11
+ * The TranscriptIndex allows quick lookup
12
+ *
13
+ * @private
14
+ * @memberof LocalSearchBackend
15
+ */
16
+ private transcriptIndex;
17
+ /**
18
+ * Finds all of the ranges of all the search results across the entire transcript.
19
+ *
20
+ * @private
21
+ * @param {string} query
22
+ * @returns {Promise<Range[]>}
23
+ * @memberof SearchBackendInterface
24
+ */
25
+ getSearchRanges(query: string): Promise<Range[]>;
26
+ constructor(transcriptIndex: TranscriptIndexInterface);
27
+ }
@@ -1,43 +1,43 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { Range } from '../../search-models';
11
- /**
12
- * The LocalSearchBackend is a simple browser-side search backend that
13
- * can be substituted for the FullTextSearchBackend. It implements
14
- * the `SearchBackendInterface` so you can inject it into the `SearchHandler`.
15
- */
16
- export class LocalSearchBackend {
17
- constructor(transcriptIndex) {
18
- this.transcriptIndex = transcriptIndex;
19
- }
20
- /**
21
- * Finds all of the ranges of all the search results across the entire transcript.
22
- *
23
- * @private
24
- * @param {string} query
25
- * @returns {Promise<Range[]>}
26
- * @memberof SearchBackendInterface
27
- */
28
- getSearchRanges(query) {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- const ranges = [];
31
- const queryLowerCased = query.toLowerCase();
32
- let index = -1;
33
- /* eslint-disable no-cond-assign */
34
- while ((index = this.transcriptIndex.mergedTranscriptLowercased.indexOf(queryLowerCased, index + 1)) !== -1) {
35
- const newRange = new Range(index, index + queryLowerCased.length);
36
- ranges.push(newRange);
37
- }
38
- /* eslint-enable no-cond-assign */
39
- return new Promise(resolve => resolve(ranges));
40
- });
41
- }
42
- }
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { Range } from '../../search-models';
11
+ /**
12
+ * The LocalSearchBackend is a simple browser-side search backend that
13
+ * can be substituted for the FullTextSearchBackend. It implements
14
+ * the `SearchBackendInterface` so you can inject it into the `SearchHandler`.
15
+ */
16
+ export class LocalSearchBackend {
17
+ constructor(transcriptIndex) {
18
+ this.transcriptIndex = transcriptIndex;
19
+ }
20
+ /**
21
+ * Finds all of the ranges of all the search results across the entire transcript.
22
+ *
23
+ * @private
24
+ * @param {string} query
25
+ * @returns {Promise<Range[]>}
26
+ * @memberof SearchBackendInterface
27
+ */
28
+ getSearchRanges(query) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ const ranges = [];
31
+ const queryLowerCased = query.toLowerCase();
32
+ let index = -1;
33
+ /* eslint-disable no-cond-assign */
34
+ while ((index = this.transcriptIndex.mergedTranscriptLowercased.indexOf(queryLowerCased, index + 1)) !== -1) {
35
+ const newRange = new Range(index, index + queryLowerCased.length);
36
+ ranges.push(newRange);
37
+ }
38
+ /* eslint-enable no-cond-assign */
39
+ return new Promise(resolve => resolve(ranges));
40
+ });
41
+ }
42
+ }
43
43
  //# sourceMappingURL=local-search-backend.js.map
@@ -1,9 +1,9 @@
1
- import { Range } from '../search-models';
2
- /**
3
- * An interface to define the responsibilities of the SearchBackend.
4
- *
5
- * Search Backends are injected into the SearchHandler for different cases (offline, online, etc)
6
- */
7
- export interface SearchBackendInterface {
8
- getSearchRanges(query: string): Promise<Range[]>;
9
- }
1
+ import { Range } from '../search-models';
2
+ /**
3
+ * An interface to define the responsibilities of the SearchBackend.
4
+ *
5
+ * Search Backends are injected into the SearchHandler for different cases (offline, online, etc)
6
+ */
7
+ export interface SearchBackendInterface {
8
+ getSearchRanges(query: string): Promise<Range[]>;
9
+ }
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=search-backend-interface.js.map
@@ -1,17 +1,17 @@
1
- import { TranscriptConfig } from '@internetarchive/transcript-view';
2
- /**
3
- * Interface for defining Search Handler objects.
4
- *
5
- * Search Handlers are injected into the Radio Player to do the actual search work.
6
- */
7
- export interface SearchHandlerInterface {
8
- /**
9
- * Execute a search and return a `Promise` containing a `TranscriptConfig` that
10
- * has been modified to include the search results.
11
- *
12
- * @param {string} query
13
- * @returns {Promise<TranscriptConfig>}
14
- * @memberof SearchHandlerInterface
15
- */
16
- search(query: string): Promise<TranscriptConfig>;
17
- }
1
+ import { TranscriptConfig } from '@internetarchive/transcript-view';
2
+ /**
3
+ * Interface for defining Search Handler objects.
4
+ *
5
+ * Search Handlers are injected into the Radio Player to do the actual search work.
6
+ */
7
+ export interface SearchHandlerInterface {
8
+ /**
9
+ * Execute a search and return a `Promise` containing a `TranscriptConfig` that
10
+ * has been modified to include the search results.
11
+ *
12
+ * @param {string} query
13
+ * @returns {Promise<TranscriptConfig>}
14
+ * @memberof SearchHandlerInterface
15
+ */
16
+ search(query: string): Promise<TranscriptConfig>;
17
+ }
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=search-handler-interface.js.map
@@ -1,83 +1,83 @@
1
- import { TranscriptConfig } from '@internetarchive/transcript-view';
2
- import { SearchResult } from './search-models';
3
- import { SearchBackendInterface } from './search-backends/search-backend-interface';
4
- import { TranscriptIndexInterface } from './transcript-index-interface';
5
- import { SearchHandlerInterface } from './search-handler-interface';
6
- /**
7
- * This is the main entrypoint into transcript searching. It has a single
8
- * public method as defined by `SearchHandlerInterface`: `search(term: string)`,
9
- * that returns a `Promise<TranscriptConfig>` with a search-modified transcript.
10
- * This means the original transcript entries get merged with search results since
11
- * search results can span across transcript entries.
12
- *
13
- * It offloads the searching work to a `SearchBackendInterface` object that
14
- * is responsible for returning the search result `Range` objects based on some
15
- * backend search like the `LocalSearchBackend` or `FullTextSearchBackend`.
16
- *
17
- * It also uses a `TranscriptIndexInterface` object that is responsible for indexing
18
- * the transcipt to make reassembly much more efficient.
19
- */
20
- export declare class SearchHandler implements SearchHandlerInterface {
21
- /**
22
- * The SearchBackend used to executes searches.
23
- *
24
- * @private
25
- * @type {SearchBackendInterface}
26
- * @memberof SearchHandler
27
- */
28
- private searchBackend;
29
- /**
30
- * The TranscriptIndex to help with reassembly of the transcript.
31
- *
32
- * @private
33
- * @type {TranscriptIndexInterface}
34
- * @memberof SearchHandler
35
- */
36
- private transcriptIndex;
37
- constructor(searchBackend: SearchBackendInterface, transcriptIndex: TranscriptIndexInterface);
38
- /**
39
- * This is the main method in here. It takes a search term and returns a TranscriptConfig
40
- * that has been modified to insert the search results.
41
- *
42
- * @param {string} query
43
- * @returns {TranscriptConfig}
44
- * @memberof SearchHandler
45
- */
46
- search(query: string): Promise<TranscriptConfig>;
47
- /**
48
- * Copy a transcript entry but leave the text and search result index empty.
49
- *
50
- * @private
51
- * @param {TranscriptEntryConfig} sourceTranscriptConfig
52
- * @returns {TranscriptEntryConfig}
53
- * @memberof SearchHandler
54
- */
55
- private createBlankTranscriptEntryConfig;
56
- /**
57
- * Search the full transcript and split up by search results and non-results. For instance,
58
- * if the full transcript is `foo bar baz boop bump snap pop` and you search for `bump`,
59
- * you'll get an array of 3 results back:
60
- * 1. `foo bar baz boop `
61
- * 2. `bump` <-- the match
62
- * 3. ` snap pop`
63
- *
64
- * This is helpful when rebuilding the transcript later to be able to identify search results.
65
- *
66
- * @private
67
- * @param {string} query
68
- * @returns {SearchResult[]}
69
- * @memberof SearchHandler
70
- */
71
- getSearchSeparatedTranscript(query: string): Promise<SearchResult[]>;
72
- /**
73
- * Generate a SearchResult entry from a given Range and annotate it
74
- * with whether or not it is a search result match
75
- *
76
- * @private
77
- * @param {Range} range
78
- * @param {boolean} isSearchResult
79
- * @returns {SearchResult}
80
- * @memberof SearchHandler
81
- */
82
- private getSearchResult;
83
- }
1
+ import { TranscriptConfig } from '@internetarchive/transcript-view';
2
+ import { SearchResult } from './search-models';
3
+ import { SearchBackendInterface } from './search-backends/search-backend-interface';
4
+ import { TranscriptIndexInterface } from './transcript-index-interface';
5
+ import { SearchHandlerInterface } from './search-handler-interface';
6
+ /**
7
+ * This is the main entrypoint into transcript searching. It has a single
8
+ * public method as defined by `SearchHandlerInterface`: `search(term: string)`,
9
+ * that returns a `Promise<TranscriptConfig>` with a search-modified transcript.
10
+ * This means the original transcript entries get merged with search results since
11
+ * search results can span across transcript entries.
12
+ *
13
+ * It offloads the searching work to a `SearchBackendInterface` object that
14
+ * is responsible for returning the search result `Range` objects based on some
15
+ * backend search like the `LocalSearchBackend` or `FullTextSearchBackend`.
16
+ *
17
+ * It also uses a `TranscriptIndexInterface` object that is responsible for indexing
18
+ * the transcipt to make reassembly much more efficient.
19
+ */
20
+ export declare class SearchHandler implements SearchHandlerInterface {
21
+ /**
22
+ * The SearchBackend used to executes searches.
23
+ *
24
+ * @private
25
+ * @type {SearchBackendInterface}
26
+ * @memberof SearchHandler
27
+ */
28
+ private searchBackend;
29
+ /**
30
+ * The TranscriptIndex to help with reassembly of the transcript.
31
+ *
32
+ * @private
33
+ * @type {TranscriptIndexInterface}
34
+ * @memberof SearchHandler
35
+ */
36
+ private transcriptIndex;
37
+ constructor(searchBackend: SearchBackendInterface, transcriptIndex: TranscriptIndexInterface);
38
+ /**
39
+ * This is the main method in here. It takes a search term and returns a TranscriptConfig
40
+ * that has been modified to insert the search results.
41
+ *
42
+ * @param {string} query
43
+ * @returns {TranscriptConfig}
44
+ * @memberof SearchHandler
45
+ */
46
+ search(query: string): Promise<TranscriptConfig>;
47
+ /**
48
+ * Copy a transcript entry but leave the text and search result index empty.
49
+ *
50
+ * @private
51
+ * @param {TranscriptEntryConfig} sourceTranscriptConfig
52
+ * @returns {TranscriptEntryConfig}
53
+ * @memberof SearchHandler
54
+ */
55
+ private createBlankTranscriptEntryConfig;
56
+ /**
57
+ * Search the full transcript and split up by search results and non-results. For instance,
58
+ * if the full transcript is `foo bar baz boop bump snap pop` and you search for `bump`,
59
+ * you'll get an array of 3 results back:
60
+ * 1. `foo bar baz boop `
61
+ * 2. `bump` <-- the match
62
+ * 3. ` snap pop`
63
+ *
64
+ * This is helpful when rebuilding the transcript later to be able to identify search results.
65
+ *
66
+ * @private
67
+ * @param {string} query
68
+ * @returns {SearchResult[]}
69
+ * @memberof SearchHandler
70
+ */
71
+ getSearchSeparatedTranscript(query: string): Promise<SearchResult[]>;
72
+ /**
73
+ * Generate a SearchResult entry from a given Range and annotate it
74
+ * with whether or not it is a search result match
75
+ *
76
+ * @private
77
+ * @param {Range} range
78
+ * @param {boolean} isSearchResult
79
+ * @returns {SearchResult}
80
+ * @memberof SearchHandler
81
+ */
82
+ private getSearchResult;
83
+ }