@vestra-player/sdk 1.5.29 → 1.5.30
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/CHANGELOG.md +12 -0
- package/dist/capabilities.d.ts +13 -3
- package/dist/capabilities.js +13 -3
- package/dist/commands.d.ts +49 -9
- package/dist/commands.js +49 -9
- package/dist/index.d.ts +6 -1
- package/dist/palettes.d.ts +16 -2
- package/dist/palettes.js +16 -2
- package/dist/plugin/bindings.d.ts +27 -3
- package/dist/plugin/bindings.js +27 -3
- package/dist/plugin/osd.d.ts +13 -1
- package/dist/plugin/osd.js +13 -1
- package/dist/plugin/services.d.ts +46 -6
- package/dist/plugin/services.js +46 -6
- package/dist/plugin/testing.d.ts +353 -62
- package/dist/plugin/testing.js +343 -61
- package/dist/plugin/types.d.ts +781 -164
- package/dist/plugin/values.d.ts +27 -3
- package/dist/plugin/values.js +27 -3
- package/dist/processing.d.ts +16 -4
- package/dist/source-resolvers.d.ts +33 -8
- package/dist/subtitles.d.ts +19 -9
- package/dist/wire.d.ts +12 -3
- package/dist/wire.js +12 -3
- package/llms-full.txt +3312 -20
- package/llms.txt +20 -20
- package/package.json +1 -1
package/dist/plugin/services.js
CHANGED
|
@@ -247,13 +247,31 @@ class Store {
|
|
|
247
247
|
* with the key and the request around the value). The player's tests check
|
|
248
248
|
* that these agree with the player.
|
|
249
249
|
*
|
|
250
|
-
* @example
|
|
250
|
+
* @example Remember a position per URL without breaking the limits
|
|
251
|
+
* The plugin keeps the last position of each URL for this player session
|
|
252
|
+
* and skips a URL too long to be a key. Keys are counted in UTF-8 bytes, so
|
|
253
|
+
* the length is measured with `Buffer.byteLength`, not `length`; a `set`
|
|
254
|
+
* that would take the plugin's entries over 1 MiB rejects with `limit` and
|
|
255
|
+
* changes nothing, so the plugin clears the old entries and goes on.
|
|
251
256
|
* ```ts
|
|
252
|
-
* import
|
|
257
|
+
* import type { Plugin, PluginError } from "@vestra-player/sdk";
|
|
258
|
+
* declare const plugin: Plugin;
|
|
259
|
+
* declare const url: string;
|
|
260
|
+
* declare const position: number;
|
|
261
|
+
* // ---cut---
|
|
253
262
|
* import { SESSION_STORAGE_LIMITS } from "@vestra-player/sdk/testing";
|
|
254
263
|
*
|
|
255
|
-
* const
|
|
256
|
-
*
|
|
264
|
+
* const session = plugin.storage.session;
|
|
265
|
+
* if (Buffer.byteLength(url) <= SESSION_STORAGE_LIMITS.keyBytes) {
|
|
266
|
+
* try {
|
|
267
|
+
* await session.set(url, position);
|
|
268
|
+
* } catch (error) {
|
|
269
|
+
* if ((error as PluginError).code !== "limit") throw error;
|
|
270
|
+
* // Full: start over rather than lose the newest position.
|
|
271
|
+
* for (const key of await session.keys()) await session.delete(key);
|
|
272
|
+
* await session.set(url, position);
|
|
273
|
+
* }
|
|
274
|
+
* }
|
|
257
275
|
* ```
|
|
258
276
|
*
|
|
259
277
|
* @since 1.5.25
|
|
@@ -390,11 +408,33 @@ export function system(scope) {
|
|
|
390
408
|
* fails with code `invalid`; a new name beyond `names` fails with `limit`.
|
|
391
409
|
* The player's tests check that these agree with the player.
|
|
392
410
|
*
|
|
393
|
-
* @example
|
|
411
|
+
* @example Store an API token only when it fits
|
|
412
|
+
* The plugin keeps a token the user pasted, or tells them it is empty or
|
|
413
|
+
* too long. Values are 1–1024 bytes counted in UTF-8, so the check uses
|
|
414
|
+
* `Buffer.byteLength`; `secrets.set` would refuse other values with
|
|
415
|
+
* `invalid`. The store itself can still refuse (`unsupported` without a
|
|
416
|
+
* system store, `unavailable` or `failed` when it denies access): only
|
|
417
|
+
* those codes get the "could not be saved" message, anything else (a
|
|
418
|
+
* missing `secrets` capability) is a bug and is thrown on.
|
|
394
419
|
* ```ts
|
|
420
|
+
* import type { Plugin, PluginError } from "@vestra-player/sdk";
|
|
421
|
+
* declare const plugin: Plugin;
|
|
422
|
+
* declare const token: string;
|
|
423
|
+
* // ---cut---
|
|
395
424
|
* import { SECRET_LIMITS } from "@vestra-player/sdk/testing";
|
|
396
425
|
*
|
|
397
|
-
*
|
|
426
|
+
* if (!token || Buffer.byteLength(token) > SECRET_LIMITS.valueBytes) {
|
|
427
|
+
* await plugin.osd.show("Paste a token of at most 1024 bytes.");
|
|
428
|
+
* } else {
|
|
429
|
+
* try {
|
|
430
|
+
* await plugin.secrets.set("api-token", token);
|
|
431
|
+
* } catch (error) {
|
|
432
|
+
* const { code } = error as PluginError;
|
|
433
|
+
* if (!["unsupported", "unavailable", "failed"].includes(code)) throw error;
|
|
434
|
+
* // No keychain or access denied: ask again next time.
|
|
435
|
+
* await plugin.osd.show("The token could not be saved.");
|
|
436
|
+
* }
|
|
437
|
+
* }
|
|
398
438
|
* ```
|
|
399
439
|
*
|
|
400
440
|
* @since 1.5.14
|