@datocms/astro 0.1.3 → 0.1.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
@@ -2,7 +2,7 @@
2
2
  "name": "@datocms/astro",
3
3
  "description": "A set of components and utilities to work faster with DatoCMS in Astro projects.",
4
4
  "type": "module",
5
- "version": "0.1.3",
5
+ "version": "0.1.4",
6
6
  "sideEffects": false,
7
7
  "repository": {
8
8
  "type": "git",
@@ -21,17 +21,16 @@
21
21
  "ui"
22
22
  ],
23
23
  "exports": {
24
- ".": "./lib/index.ts",
25
- "./VideoPlayer": "./components/VideoPlayer/index.ts",
26
- "./Image": "./components/Image/index.ts"
24
+ ".": "./src/index.ts",
25
+ "./VideoPlayer": "./src/VideoPlayer/index.ts",
26
+ "./Image": "./src/Image/index.ts"
27
27
  },
28
28
  "engines": {
29
29
  "node": ">=18.0.0"
30
30
  },
31
- "files": ["components", "lib"],
32
- "scripts": {},
31
+ "files": ["src"],
33
32
  "dependencies": {
34
- "@astrojs/check": "^0.9.1",
33
+ "@mux/playback-core": "^0.25.1",
35
34
  "typescript": "^5.5.4"
36
35
  },
37
36
  "peerDependencies": {
@@ -45,7 +44,6 @@
45
44
  },
46
45
  "devDependencies": {
47
46
  "@mux/mux-player": "*",
48
- "@mux/playback-core": "^0.25.1",
49
47
  "astro": "^4.13.1"
50
48
  }
51
49
  }
@@ -1,7 +1,7 @@
1
1
  ---
2
- import type { ResponsiveImageType } from "../../lib/types";
3
- import { buildSrcSet } from './buildSrcSet';
4
2
  import type { JSX } from 'astro/jsx-runtime';
3
+ import type { ResponsiveImageType } from './types';
4
+ import { buildSrcSet } from './buildSrcSet';
5
5
 
6
6
  type StyleAttribute = JSX.HTMLAttributes['style'];
7
7
  type StyleAttributeAsObject = Exclude<StyleAttribute, string>;
@@ -79,7 +79,7 @@ const sizingStyle = {
79
79
  };
80
80
  ---
81
81
 
82
- <picture data-testid="picture" class={pictureClass} style={pictureStyle}>
82
+ <picture class={pictureClass} style={pictureStyle}>
83
83
  {
84
84
  data.webpSrcSet && (
85
85
  <source
@@ -0,0 +1,2 @@
1
+ import Component from "./Image.astro";
2
+ export default Component;
@@ -1,5 +1,4 @@
1
1
  type Maybe<T> = T | null;
2
- type Possibly<T> = Maybe<T> | undefined;
3
2
 
4
3
  export type ResponsiveImageType = {
5
4
  /** A base64-encoded thumbnail to offer during image loading */
@@ -25,21 +24,3 @@ export type ResponsiveImageType = {
25
24
  /** Title attribute (`title`) for the image */
26
25
  title?: Maybe<string>;
27
26
  };
28
-
29
- export type Video = {
30
- /** Title attribute (`title`) for the video */
31
- title?: Possibly<string>;
32
- /** The height of the video */
33
- height?: Possibly<number>;
34
- /** The width of the video */
35
- width?: Possibly<number>;
36
- /** The MUX playbaack ID */
37
- muxPlaybackId?: Possibly<string>;
38
- /** The MUX playbaack ID */
39
- playbackId?: Possibly<string>;
40
- /** A data: URI containing a blurhash for the video */
41
- blurUpThumb?: Possibly<string>;
42
- /** Other data can be passed, but they have no effect on rendering the player */
43
- // biome-ignore lint/suspicious/noExplicitAny: we intentionally want to allow to add any other value to this video object
44
- [k: string]: any;
45
- };
@@ -0,0 +1,37 @@
1
+ ---
2
+ import type { MuxMediaProps } from "@mux/playback-core";
3
+ import { toHTMLAttrs } from "./toHtmlArgs";
4
+ import type { JSX } from 'astro/jsx-runtime';
5
+ import { useVideoPlayer } from "useVideoPlayer";
6
+ import type { Video } from "./types";
7
+
8
+ type StyleAttribute = JSX.HTMLAttributes["style"];
9
+
10
+ interface Props extends MuxMediaProps {
11
+ data: Video;
12
+ class?: string;
13
+ style?: StyleAttribute;
14
+ };
15
+
16
+ const {
17
+ data,
18
+ disableCookies = true,
19
+ preload = "metadata",
20
+ ...otherProps
21
+ } = Astro.props;
22
+
23
+ const computedProps = {
24
+ ...useVideoPlayer({ data }),
25
+ disableCookies,
26
+ preload,
27
+ };
28
+ ---
29
+
30
+ <mux-player
31
+ stream-type="on-demand"
32
+ {...toHTMLAttrs(computedProps)}
33
+ {...toHTMLAttrs(otherProps)}></mux-player>
34
+
35
+ <script>
36
+ import "@mux/mux-player";
37
+ </script>
@@ -1,3 +1,4 @@
1
+ // Extracted from https://github.com/muxinc/elements/blob/main/packages/mux-player-react/src/common/utils.ts
1
2
 
2
3
  type KeyTypes = string | number | symbol;
3
4
  type Maybe<T> = T | null;
@@ -0,0 +1,20 @@
1
+ type Maybe<T> = T | null;
2
+ type Possibly<T> = Maybe<T> | undefined;
3
+
4
+ export type Video = {
5
+ /** Title attribute (`title`) for the video */
6
+ title?: Possibly<string>;
7
+ /** The height of the video */
8
+ height?: Possibly<number>;
9
+ /** The width of the video */
10
+ width?: Possibly<number>;
11
+ /** The MUX playbaack ID */
12
+ muxPlaybackId?: Possibly<string>;
13
+ /** The MUX playbaack ID */
14
+ playbackId?: Possibly<string>;
15
+ /** A data: URI containing a blurhash for the video */
16
+ blurUpThumb?: Possibly<string>;
17
+ /** Other data can be passed, but they have no effect on rendering the player */
18
+ // biome-ignore lint/suspicious/noExplicitAny: we intentionally want to allow to add any other value to this video object
19
+ [k: string]: any;
20
+ };
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ export { default as Image } from "./Image";
2
+ export { useVideoPlayer } from './useVideoPlayer';
3
+ export { default as VideoPlayer } from "./VideoPlayer";
4
+
@@ -1,4 +1,4 @@
1
- import type { Video } from '../types';
1
+ import type { Video } from "VideoPlayer/types";
2
2
 
3
3
  type Maybe<T> = T | null;
4
4
  type Possibly<T> = Maybe<T> | undefined;
@@ -1,105 +0,0 @@
1
- ---
2
- import type { Video } from "../../lib/types";
3
- import type {
4
- CmcdTypes,
5
- MaxResolutionValue,
6
- MinResolutionValue,
7
- PlaybackTypes,
8
- RenditionOrderValue,
9
- StreamTypes,
10
- } from "@mux/playback-core/.";
11
- import type MuxPlayerElement from "@mux/mux-player";
12
- import type { Tokens } from "@mux/mux-player";
13
- import { useVideoPlayer } from "../../lib";
14
- import { toHTMLAttrs } from "./toHtmlArgs";
15
- import type { JSX } from 'astro/jsx-runtime';
16
-
17
- type ValueOf<T> = T[keyof T];
18
-
19
- type StyleAttribute = JSX.HTMLAttributes["style"];
20
-
21
- interface Props {
22
- data: Video;
23
- class?: string;
24
- style?: StyleAttribute;
25
-
26
- _hlsConfig?: MuxPlayerElement["_hlsConfig"];
27
- accentColor?: string;
28
- audio?: boolean;
29
- autoPlay?: boolean | string;
30
- backwardSeekOffset?: number;
31
- beaconCollectionDomain?: string;
32
- crossOrigin?: string;
33
- currentTime?: number;
34
- customDomain?: string;
35
- debug?: boolean;
36
- defaultDuration?: number;
37
- defaultHiddenCaptions?: boolean;
38
- defaultShowRemainingTime?: boolean;
39
- defaultStreamType?: ValueOf<StreamTypes>;
40
- disableCookies?: boolean;
41
- disablePictureInPicture?: boolean;
42
- envKey?: string;
43
- extraSourceParams?: Record<string, any>;
44
- forwardSeekOffset?: number;
45
- hotkeys?: string;
46
- loop?: boolean;
47
- maxResolution?: MaxResolutionValue;
48
- metadata?: Record<string, any>;
49
- metadataVideoId?: string;
50
- metadataVideoTitle?: string;
51
- metadataViewerUserId?: string;
52
- minResolution?: MinResolutionValue;
53
- muted?: boolean;
54
- nohotkeys?: string;
55
- noVolumePref?: boolean;
56
- paused?: boolean;
57
- placeholder?: string;
58
- playbackId?: string;
59
- playbackRate?: number;
60
- playbackRates?: number[];
61
- playerSoftwareName?: string;
62
- playerSoftwareVersion?: string;
63
- playsInline?: boolean;
64
- poster?: string;
65
- preferCmcd?: CmcdTypes;
66
- preferPlayback?: PlaybackTypes;
67
- preload?: string;
68
- primaryColor?: string;
69
- renditionOrder?: RenditionOrderValue;
70
- secondaryColor?: string;
71
- src?: string;
72
- startTime?: number;
73
- storyboardSrc?: string;
74
- streamType: StreamTypes | "ll-live" | "live:dvr" | "ll-live:dvr";
75
- argetLiveWindow?: number;
76
- theme?: string;
77
- themeProps?: Record<string, any>;
78
- thumbnailTime?: number;
79
- title?: string;
80
- tokens?: Tokens;
81
- volume?: number;
82
- }
83
-
84
- const {
85
- data,
86
- disableCookies = true,
87
- preload = "metadata",
88
- ...otherProps
89
- } = Astro.props;
90
-
91
- const computedProps = {
92
- ...useVideoPlayer({ data }),
93
- disableCookies,
94
- preload,
95
- };
96
- ---
97
-
98
- <mux-player
99
- stream-type="on-demand"
100
- {...toHTMLAttrs(computedProps)}
101
- {...toHTMLAttrs(otherProps)}></mux-player>
102
-
103
- <script>
104
- import "@mux/mux-player";
105
- </script>
@@ -1,2 +0,0 @@
1
- import Component from "./index.astro";
2
- export default Component;
package/lib/index.ts DELETED
@@ -1,4 +0,0 @@
1
- export { default as Image } from "../components/Image";
2
- export { default as VideoPlayer } from "../components/VideoPlayer";
3
- export { useVideoPlayer } from './useVideoPlayer';
4
-
File without changes
File without changes