From 108ada8e5a27f33c2723badc5f0bf0d4052fb7f9 Mon Sep 17 00:00:00 2001 From: Jeremy Karlsson Date: Thu, 21 Mar 2024 14:21:35 +0100 Subject: [PATCH 1/4] Add setEventSender to player module and export EventSender namespace as type/interface in common. --- packages/common/package.json | 1 + packages/common/src/eventSender.ts | 3 +++ packages/common/src/index.ts | 1 + packages/common/vite.config.ts | 8 +++++++- .../src/internal/handlers/set-event-sender.ts | 13 +++++++++++++ packages/player/src/internal/index.ts | 17 ++++++++++++++++- pnpm-lock.yaml | 5 ++++- 7 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 packages/common/src/eventSender.ts create mode 100644 packages/player/src/internal/handlers/set-event-sender.ts diff --git a/packages/common/package.json b/packages/common/package.json index 9a93486e..4bf0ad53 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -38,6 +38,7 @@ "@tidal-music/common": "workspace:*" }, "devDependencies": { + "@tidal-music/event-producer": "workspace:*", "@vitest/coverage-v8": "1.4.0", "@vitest/ui": "1.4.0", "typescript": "5.4.2", diff --git a/packages/common/src/eventSender.ts b/packages/common/src/eventSender.ts new file mode 100644 index 00000000..96d9c33d --- /dev/null +++ b/packages/common/src/eventSender.ts @@ -0,0 +1,3 @@ +import type * as _EventSender from '@tidal-music/event-producer'; + +export type EventSender = typeof _EventSender; diff --git a/packages/common/src/index.ts b/packages/common/src/index.ts index 7140264e..6d221eb3 100644 --- a/packages/common/src/index.ts +++ b/packages/common/src/index.ts @@ -4,3 +4,4 @@ export * from './retryableError'; export * from './tidalError'; export * from './tidalMessage'; export * from './credentialsProvider'; +export * from './eventSender'; diff --git a/packages/common/vite.config.ts b/packages/common/vite.config.ts index ecbc7fc6..b6ed6fc9 100644 --- a/packages/common/vite.config.ts +++ b/packages/common/vite.config.ts @@ -9,7 +9,13 @@ export default defineConfig({ formats: ['es'], }, }, - plugins: [dts({ rollupTypes: true, tsconfigPath: 'tsconfig.build.json' })], + plugins: [ + dts({ + // Bundle the event sender types from event-producer + bundledPackages: ['@tidal-music/event-producer'], + tsconfigPath: 'tsconfig.build.json', + }), + ], test: { coverage: { exclude: ['./src/index.ts'].concat(configDefaults.coverage.exclude ?? []), // ignore barrel file diff --git a/packages/player/src/internal/handlers/set-event-sender.ts b/packages/player/src/internal/handlers/set-event-sender.ts new file mode 100644 index 00000000..114ac1f7 --- /dev/null +++ b/packages/player/src/internal/handlers/set-event-sender.ts @@ -0,0 +1,13 @@ +import type { EventSender } from '@tidal-music/common'; + +import { eventSenderStore } from '../index'; + +/** + * Set the credentials provider TIDAL Player SDK should use for getting + * session information + * + * @param {CredentialsProvider} newCredentialsProvider + */ +export function setEventSender(newEventSender: EventSender) { + eventSenderStore.eventSender = newEventSender; +} diff --git a/packages/player/src/internal/index.ts b/packages/player/src/internal/index.ts index 080deb0d..58b5a6f4 100644 --- a/packages/player/src/internal/index.ts +++ b/packages/player/src/internal/index.ts @@ -1,9 +1,23 @@ -import type { CredentialsProvider } from '@tidal-music/common'; +import type { CredentialsProvider, EventSender } from '@tidal-music/common'; import * as Config from '../config'; import { waitForEvent } from './helpers/wait-for'; +class EventSenderStore extends EventTarget { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore - Setter + #eventSender: EventSender; + + set eventSender(newEventSender: EventSender) { + this.#eventSender = newEventSender; + } + + get eventSender() { + return this.#eventSender; + } +} + class CredentialsProviderStore extends EventTarget { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - Setter @@ -241,6 +255,7 @@ export async function isAuthorizedWithUser() { } export const credentialsProviderStore = new CredentialsProviderStore(); +export const eventSenderStore = new EventSenderStore(); /** * Starts streaming privileges and event code if the credentials allow it. diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c4c6ef99..becfab2c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -66,6 +66,9 @@ importers: specifier: workspace:* version: 'link:' devDependencies: + '@tidal-music/event-producer': + specifier: workspace:* + version: link:../event-producer '@vitest/coverage-v8': specifier: 1.4.0 version: 1.4.0(vitest@1.4.0) @@ -373,7 +376,7 @@ packages: dependencies: '@babel/types': 7.23.9 '@jridgewell/gen-mapping': 0.3.3 - '@jridgewell/trace-mapping': 0.3.19 + '@jridgewell/trace-mapping': 0.3.25 jsesc: 2.5.2 dev: true From c077b1138a5360a42685deb6d7bbd197ccbbceac Mon Sep 17 00:00:00 2001 From: Jeremy Karlsson Date: Mon, 6 May 2024 09:58:12 +0200 Subject: [PATCH 2/4] Update lockfile --- pnpm-lock.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4c3a843c..c4c55874 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -64,10 +64,6 @@ importers: version: 1.5.0(@types/node@20.12.7)(@vitest/ui@1.5.0)(happy-dom@14.7.1)(terser@5.17.4) packages/common: - dependencies: - '@tidal-music/common': - specifier: workspace:* - version: 'link:' devDependencies: '@tidal-music/event-producer': specifier: workspace:* From 82e790d7b5698e0f07eb690cabc4a2b4d80c6571 Mon Sep 17 00:00:00 2001 From: Jeremy Karlsson Date: Wed, 18 Sep 2024 10:13:10 +0200 Subject: [PATCH 3/4] Bump version and update changelog --- packages/player/CHANGELOG.md | 8 ++++++++ packages/player/package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/player/CHANGELOG.md b/packages/player/CHANGELOG.md index 65de6391..91e05a1e 100644 --- a/packages/player/CHANGELOG.md +++ b/packages/player/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.5.0] - 2024-09-18 + +### Changed + +- Use Shaka Preload API for preparing the next track, instead of dual instances of shaka. +- Removed mux.js dependency as shaka no longer requires that +- Add authorization header to Widevine license request, to enable playback for Open API clients + ## [0.4.3] - 2024-09-10 ### Changed diff --git a/packages/player/package.json b/packages/player/package.json index e8e261d7..6d55badc 100644 --- a/packages/player/package.json +++ b/packages/player/package.json @@ -1,6 +1,6 @@ { "name": "@tidal-music/player", - "version": "0.4.3", + "version": "0.5.0", "description": "Player logic for TIDAL", "type": "module", "exports": { From eae57fbafdbd42d9a4056c9368ef5324925e14aa Mon Sep 17 00:00:00 2001 From: Jeremy Karlsson Date: Mon, 23 Sep 2024 11:40:58 +0200 Subject: [PATCH 4/4] Fix dep --- packages/common/package.json | 1 + pnpm-lock.yaml | 40 ++++++++++++++++++------------------ 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/packages/common/package.json b/packages/common/package.json index 0c8c08a7..ad1cf029 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -32,6 +32,7 @@ "typecheck": "tsc" }, "devDependencies": { + "@tidal-music/event-producer": "workspace:*", "@vitest/coverage-v8": "2.0.4", "@vitest/ui": "2.0.4", "typescript": "5.6.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 06139e64..b7bd1a58 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6617,7 +6617,7 @@ snapshots: '@eslint/eslintrc@2.1.4': dependencies: ajv: 6.12.6 - debug: 4.3.7(supports-color@9.4.0) + debug: 4.3.7(supports-color@8.1.1) espree: 9.6.1 globals: 13.24.0 ignore: 5.3.2 @@ -6635,7 +6635,7 @@ snapshots: '@humanwhocodes/config-array@0.11.14': dependencies: '@humanwhocodes/object-schema': 2.0.3 - debug: 4.3.7(supports-color@9.4.0) + debug: 4.3.7(supports-color@8.1.1) minimatch: 3.1.2 transitivePeerDependencies: - supports-color @@ -6643,7 +6643,7 @@ snapshots: '@humanwhocodes/config-array@0.13.0': dependencies: '@humanwhocodes/object-schema': 2.0.3 - debug: 4.3.7(supports-color@9.4.0) + debug: 4.3.7(supports-color@8.1.1) minimatch: 3.1.2 transitivePeerDependencies: - supports-color @@ -7229,7 +7229,7 @@ snapshots: '@typescript-eslint/type-utils': 6.15.0(eslint@8.56.0)(typescript@5.3.3) '@typescript-eslint/utils': 6.15.0(eslint@8.56.0)(typescript@5.3.3) '@typescript-eslint/visitor-keys': 6.15.0 - debug: 4.3.7(supports-color@9.4.0) + debug: 4.3.7(supports-color@8.1.1) eslint: 8.56.0 graphemer: 1.4.0 ignore: 5.3.2 @@ -7247,7 +7247,7 @@ snapshots: '@typescript-eslint/types': 6.15.0 '@typescript-eslint/typescript-estree': 6.15.0(typescript@5.3.3) '@typescript-eslint/visitor-keys': 6.15.0 - debug: 4.3.7(supports-color@9.4.0) + debug: 4.3.7(supports-color@8.1.1) eslint: 8.56.0 optionalDependencies: typescript: 5.3.3 @@ -7273,7 +7273,7 @@ snapshots: dependencies: '@typescript-eslint/typescript-estree': 6.15.0(typescript@5.3.3) '@typescript-eslint/utils': 6.15.0(eslint@8.56.0)(typescript@5.3.3) - debug: 4.3.7(supports-color@9.4.0) + debug: 4.3.7(supports-color@8.1.1) eslint: 8.56.0 ts-api-utils: 1.3.0(typescript@5.3.3) optionalDependencies: @@ -7291,7 +7291,7 @@ snapshots: dependencies: '@typescript-eslint/types': 5.62.0 '@typescript-eslint/visitor-keys': 5.62.0 - debug: 4.3.7(supports-color@9.4.0) + debug: 4.3.7(supports-color@8.1.1) globby: 11.1.0 is-glob: 4.0.3 semver: 7.6.3 @@ -7305,7 +7305,7 @@ snapshots: dependencies: '@typescript-eslint/types': 6.15.0 '@typescript-eslint/visitor-keys': 6.15.0 - debug: 4.3.7(supports-color@9.4.0) + debug: 4.3.7(supports-color@8.1.1) globby: 11.1.0 is-glob: 4.0.3 semver: 7.6.3 @@ -7319,7 +7319,7 @@ snapshots: dependencies: '@typescript-eslint/types': 6.21.0 '@typescript-eslint/visitor-keys': 6.21.0 - debug: 4.3.7(supports-color@9.4.0) + debug: 4.3.7(supports-color@8.1.1) globby: 11.1.0 is-glob: 4.0.3 minimatch: 9.0.3 @@ -7394,7 +7394,7 @@ snapshots: dependencies: '@ampproject/remapping': 2.3.0 '@bcoe/v8-coverage': 0.2.3 - debug: 4.3.7(supports-color@9.4.0) + debug: 4.3.7(supports-color@8.1.1) istanbul-lib-coverage: 3.2.2 istanbul-lib-report: 3.0.1 istanbul-lib-source-maps: 5.0.6 @@ -7486,7 +7486,7 @@ snapshots: '@vitest/web-worker@2.0.4(vitest@2.0.4(@types/node@22.5.5)(@vitest/ui@2.0.4)(happy-dom@15.7.4)(terser@5.31.0))': dependencies: - debug: 4.3.7(supports-color@9.4.0) + debug: 4.3.7(supports-color@8.1.1) vitest: 2.0.4(@types/node@22.5.5)(@vitest/ui@2.0.4)(happy-dom@15.7.4)(terser@5.31.0) transitivePeerDependencies: - supports-color @@ -8674,7 +8674,7 @@ snapshots: eslint: 8.56.0 eslint-config-prettier: 9.1.0(eslint@8.56.0) eslint-config-xo: 0.43.1(eslint@8.56.0) - eslint-config-xo-react: 0.27.0(eslint-plugin-react-hooks@4.6.0(eslint@8.57.1))(eslint-plugin-react@7.33.2(eslint@8.56.0))(eslint@8.56.0) + eslint-config-xo-react: 0.27.0(eslint-plugin-react-hooks@4.6.0(eslint@8.56.0))(eslint-plugin-react@7.33.2(eslint@8.56.0))(eslint@8.56.0) eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@6.15.0(eslint@8.57.1)(typescript@5.3.3))(eslint-plugin-import@2.29.1)(eslint@8.56.0) eslint-plugin-cypress: 2.15.1(eslint@8.56.0) eslint-plugin-import: 2.29.1(@typescript-eslint/parser@6.15.0(eslint@8.57.1)(typescript@5.3.3))(eslint@8.57.1) @@ -8715,7 +8715,7 @@ snapshots: - terser - vue-eslint-parser - eslint-config-xo-react@0.27.0(eslint-plugin-react-hooks@4.6.0(eslint@8.57.1))(eslint-plugin-react@7.33.2(eslint@8.56.0))(eslint@8.56.0): + eslint-config-xo-react@0.27.0(eslint-plugin-react-hooks@4.6.0(eslint@8.56.0))(eslint-plugin-react@7.33.2(eslint@8.56.0))(eslint@8.56.0): dependencies: eslint: 8.56.0 eslint-plugin-react: 7.33.2(eslint@8.56.0) @@ -8736,7 +8736,7 @@ snapshots: eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@6.15.0(eslint@8.57.1)(typescript@5.3.3))(eslint-plugin-import@2.29.1)(eslint@8.56.0): dependencies: - debug: 4.3.7(supports-color@9.4.0) + debug: 4.3.7(supports-color@8.1.1) enhanced-resolve: 5.17.1 eslint: 8.56.0 eslint-module-utils: 2.11.0(@typescript-eslint/parser@6.15.0(eslint@8.57.1)(typescript@5.3.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@6.15.0(eslint@8.57.1)(typescript@5.3.3))(eslint-plugin-import@2.29.1)(eslint@8.56.0))(eslint@8.56.0) @@ -8806,7 +8806,7 @@ snapshots: '@es-joy/jsdoccomment': 0.48.0 are-docs-informative: 0.0.2 comment-parser: 1.4.1 - debug: 4.3.7(supports-color@9.4.0) + debug: 4.3.7(supports-color@8.1.1) escape-string-regexp: 4.0.0 eslint: 8.57.1 espree: 10.1.0 @@ -8935,7 +8935,7 @@ snapshots: ajv: 6.12.6 chalk: 4.1.2 cross-spawn: 7.0.3 - debug: 4.3.7(supports-color@9.4.0) + debug: 4.3.7(supports-color@8.1.1) doctrine: 3.0.0 escape-string-regexp: 4.0.0 eslint-scope: 7.2.2 @@ -8978,7 +8978,7 @@ snapshots: ajv: 6.12.6 chalk: 4.1.2 cross-spawn: 7.0.3 - debug: 4.3.7(supports-color@9.4.0) + debug: 4.3.7(supports-color@8.1.1) doctrine: 3.0.0 escape-string-regexp: 4.0.0 eslint-scope: 7.2.2 @@ -9618,7 +9618,7 @@ snapshots: istanbul-lib-source-maps@5.0.6: dependencies: '@jridgewell/trace-mapping': 0.3.25 - debug: 4.3.7(supports-color@9.4.0) + debug: 4.3.7(supports-color@8.1.1) istanbul-lib-coverage: 3.2.2 transitivePeerDependencies: - supports-color @@ -11099,7 +11099,7 @@ snapshots: vite-node@1.1.0(@types/node@22.5.5)(terser@5.31.0): dependencies: cac: 6.7.14 - debug: 4.3.7(supports-color@9.4.0) + debug: 4.3.7(supports-color@8.1.1) pathe: 1.1.2 picocolors: 1.1.0 vite: 5.4.6(@types/node@22.5.5)(terser@5.31.0) @@ -11181,7 +11181,7 @@ snapshots: acorn-walk: 8.3.4 cac: 6.7.14 chai: 4.5.0 - debug: 4.3.7(supports-color@9.4.0) + debug: 4.3.7(supports-color@8.1.1) execa: 8.0.1 local-pkg: 0.5.0 magic-string: 0.30.11