@growth-labs/video 0.3.3 → 0.3.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@growth-labs/video",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -7,6 +7,7 @@ import {
7
7
  posterUrl,
8
8
  premiumManifestUrl,
9
9
  } from '@growth-labs/video/utils'
10
+ import { buildPlayerBooleanAttrs } from './player-boolean-attrs'
10
11
 
11
12
  interface Props {
12
13
  videoId: string
@@ -48,6 +49,14 @@ const chaptersSrc = showChapters ? chaptersUrl(config.publicDomain, videoId) : n
48
49
  const captionsSrc = showCaptions
49
50
  ? captionsUrl(config.publicDomain, videoId, captionsLang)
50
51
  : null
52
+
53
+ // Custom elements treat attribute *presence* as truthy. Spread only the
54
+ // keys that resolve to true so SSR for `autoplay: false` / `muted: false`
55
+ // omits the attributes entirely — see player-boolean-attrs.ts.
56
+ const playerBoolAttrs = buildPlayerBooleanAttrs({
57
+ autoplay: Astro.props.autoplay ?? config.player.autoplay,
58
+ muted: Astro.props.muted ?? config.player.muted,
59
+ })
51
60
  ---
52
61
 
53
62
  <media-player
@@ -63,9 +72,8 @@ const captionsSrc = showCaptions
63
72
  src={premium ? undefined : src}
64
73
  poster={poster}
65
74
  preload={config.player.preload}
66
- autoplay={Astro.props.autoplay ?? config.player.autoplay}
67
- muted={Astro.props.muted ?? config.player.muted}
68
75
  class={`gl-video ${className ?? ''}`.trim()}
76
+ {...playerBoolAttrs}
69
77
  >
70
78
  <media-provider>
71
79
  {captionsSrc && (
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Build the subset of boolean-presence attributes for a `<media-player>`
3
+ * element. Custom elements (including Vidstack's `media-player`) treat
4
+ * attribute *presence* as truthy regardless of the string value — so
5
+ * `autoplay="false"` is read as truthy by `hasAttribute('autoplay')` and
6
+ * triggers autoplay. Astro renders interpolated booleans as the literal
7
+ * strings `"true"` / `"false"` for custom elements (it has no allowlist
8
+ * of HTML-spec'd boolean attrs on non-HTMLElement tags), so we cannot
9
+ * write `autoplay={resolvedAutoplay}` directly. Instead we spread an
10
+ * attrs object that only contains the key when the value is truthy.
11
+ *
12
+ * The returned shape is `Record<string, true>` so a downstream
13
+ * `<media-player {...attrs}>` emits `autoplay` / `muted` as bare
14
+ * presence attributes when set, and emits nothing for them when not.
15
+ */
16
+ export function buildPlayerBooleanAttrs(input: {
17
+ autoplay: boolean
18
+ muted: boolean
19
+ }): Record<string, true> {
20
+ const attrs: Record<string, true> = {}
21
+ if (input.autoplay) attrs.autoplay = true
22
+ if (input.muted) attrs.muted = true
23
+ return attrs
24
+ }
@@ -1,16 +0,0 @@
1
- import type { APIContext } from 'astro';
2
- export interface AccessCheckParams {
3
- videoId: string;
4
- request: Request;
5
- env: Record<string, unknown>;
6
- }
7
- export interface AccessResult {
8
- allowed: boolean;
9
- reason?: string;
10
- subjectId?: string;
11
- }
12
- export type AccessCheck = (params: AccessCheckParams, context: APIContext) => Promise<AccessResult>;
13
- export declare function registerAccessCheck(check: AccessCheck): void;
14
- export declare function getAccessCheck(): AccessCheck | null;
15
- export declare function _resetAccessRegistry(): void;
16
- //# sourceMappingURL=access-registry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"access-registry.d.ts","sourceRoot":"","sources":["../src/access-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEvC,MAAM,WAAW,iBAAiB;IACjC,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC5B;AAED,MAAM,WAAW,YAAY;IAC5B,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,UAAU,KAAK,OAAO,CAAC,YAAY,CAAC,CAAA;AAInG,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAK5D;AAED,wBAAgB,cAAc,IAAI,WAAW,GAAG,IAAI,CAEnD;AAGD,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C"}
@@ -1,15 +0,0 @@
1
- let registered = null;
2
- export function registerAccessCheck(check) {
3
- if (registered) {
4
- console.warn('@growth-labs/video: access check replaced (previous registration overwritten)');
5
- }
6
- registered = check;
7
- }
8
- export function getAccessCheck() {
9
- return registered;
10
- }
11
- // Test-only reset. Not exported from the package's public surface.
12
- export function _resetAccessRegistry() {
13
- registered = null;
14
- }
15
- //# sourceMappingURL=access-registry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"access-registry.js","sourceRoot":"","sources":["../src/access-registry.ts"],"names":[],"mappings":"AAgBA,IAAI,UAAU,GAAuB,IAAI,CAAA;AAEzC,MAAM,UAAU,mBAAmB,CAAC,KAAkB;IACrD,IAAI,UAAU,EAAE,CAAC;QAChB,OAAO,CAAC,IAAI,CAAC,+EAA+E,CAAC,CAAA;IAC9F,CAAC;IACD,UAAU,GAAG,KAAK,CAAA;AACnB,CAAC;AAED,MAAM,UAAU,cAAc;IAC7B,OAAO,UAAU,CAAA;AAClB,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,oBAAoB;IACnC,UAAU,GAAG,IAAI,CAAA;AAClB,CAAC"}