@datocms/astro 0.1.2 → 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 +6 -11
- package/{components/Image/index.astro → src/Image/Image.astro} +4 -3
- package/src/Image/index.ts +2 -0
- package/{lib → src/Image}/types.ts +0 -19
- package/src/VideoPlayer/index.astro +37 -0
- package/src/VideoPlayer/index.ts +2 -0
- package/{components → src}/VideoPlayer/toHtmlArgs.ts +1 -0
- package/src/VideoPlayer/types.ts +20 -0
- package/src/index.ts +4 -0
- package/{lib → src}/useVideoPlayer/index.ts +1 -1
- package/components/VideoPlayer/index.astro +0 -104
- package/lib/astro.d.ts +0 -9
- package/lib/index.ts +0 -4
- /package/{components → src}/Image/buildSrcSet.ts +0 -0
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.
|
|
5
|
+
"version": "0.1.4",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -21,20 +21,16 @@
|
|
|
21
21
|
"ui"
|
|
22
22
|
],
|
|
23
23
|
"exports": {
|
|
24
|
-
".": "./
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"*": {
|
|
28
|
-
"*": ["lib/*"]
|
|
29
|
-
}
|
|
24
|
+
".": "./src/index.ts",
|
|
25
|
+
"./VideoPlayer": "./src/VideoPlayer/index.ts",
|
|
26
|
+
"./Image": "./src/Image/index.ts"
|
|
30
27
|
},
|
|
31
28
|
"engines": {
|
|
32
29
|
"node": ">=18.0.0"
|
|
33
30
|
},
|
|
34
|
-
"files": ["
|
|
35
|
-
"scripts": {},
|
|
31
|
+
"files": ["src"],
|
|
36
32
|
"dependencies": {
|
|
37
|
-
"@
|
|
33
|
+
"@mux/playback-core": "^0.25.1",
|
|
38
34
|
"typescript": "^5.5.4"
|
|
39
35
|
},
|
|
40
36
|
"peerDependencies": {
|
|
@@ -48,7 +44,6 @@
|
|
|
48
44
|
},
|
|
49
45
|
"devDependencies": {
|
|
50
46
|
"@mux/mux-player": "*",
|
|
51
|
-
"@mux/playback-core": "^0.25.1",
|
|
52
47
|
"astro": "^4.13.1"
|
|
53
48
|
}
|
|
54
49
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
---
|
|
2
|
-
import type {
|
|
2
|
+
import type { JSX } from 'astro/jsx-runtime';
|
|
3
|
+
import type { ResponsiveImageType } from './types';
|
|
3
4
|
import { buildSrcSet } from './buildSrcSet';
|
|
4
5
|
|
|
5
|
-
type StyleAttribute =
|
|
6
|
+
type StyleAttribute = JSX.HTMLAttributes['style'];
|
|
6
7
|
type StyleAttributeAsObject = Exclude<StyleAttribute, string>;
|
|
7
8
|
|
|
8
9
|
interface Props {
|
|
@@ -78,7 +79,7 @@ const sizingStyle = {
|
|
|
78
79
|
};
|
|
79
80
|
---
|
|
80
81
|
|
|
81
|
-
<picture
|
|
82
|
+
<picture class={pictureClass} style={pictureStyle}>
|
|
82
83
|
{
|
|
83
84
|
data.webpSrcSet && (
|
|
84
85
|
<source
|
|
@@ -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>
|
|
@@ -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
|
@@ -1,104 +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
|
-
|
|
16
|
-
type ValueOf<T> = T[keyof T];
|
|
17
|
-
|
|
18
|
-
type StyleAttribute = astroHTML.JSX.HTMLAttributes["style"];
|
|
19
|
-
|
|
20
|
-
interface Props {
|
|
21
|
-
data: Video;
|
|
22
|
-
class?: string;
|
|
23
|
-
style?: StyleAttribute;
|
|
24
|
-
|
|
25
|
-
_hlsConfig?: MuxPlayerElement["_hlsConfig"];
|
|
26
|
-
accentColor?: string;
|
|
27
|
-
audio?: boolean;
|
|
28
|
-
autoPlay?: boolean | string;
|
|
29
|
-
backwardSeekOffset?: number;
|
|
30
|
-
beaconCollectionDomain?: string;
|
|
31
|
-
crossOrigin?: string;
|
|
32
|
-
currentTime?: number;
|
|
33
|
-
customDomain?: string;
|
|
34
|
-
debug?: boolean;
|
|
35
|
-
defaultDuration?: number;
|
|
36
|
-
defaultHiddenCaptions?: boolean;
|
|
37
|
-
defaultShowRemainingTime?: boolean;
|
|
38
|
-
defaultStreamType?: ValueOf<StreamTypes>;
|
|
39
|
-
disableCookies?: boolean;
|
|
40
|
-
disablePictureInPicture?: boolean;
|
|
41
|
-
envKey?: string;
|
|
42
|
-
extraSourceParams?: Record<string, any>;
|
|
43
|
-
forwardSeekOffset?: number;
|
|
44
|
-
hotkeys?: string;
|
|
45
|
-
loop?: boolean;
|
|
46
|
-
maxResolution?: MaxResolutionValue;
|
|
47
|
-
metadata?: Record<string, any>;
|
|
48
|
-
metadataVideoId?: string;
|
|
49
|
-
metadataVideoTitle?: string;
|
|
50
|
-
metadataViewerUserId?: string;
|
|
51
|
-
minResolution?: MinResolutionValue;
|
|
52
|
-
muted?: boolean;
|
|
53
|
-
nohotkeys?: string;
|
|
54
|
-
noVolumePref?: boolean;
|
|
55
|
-
paused?: boolean;
|
|
56
|
-
placeholder?: string;
|
|
57
|
-
playbackId?: string;
|
|
58
|
-
playbackRate?: number;
|
|
59
|
-
playbackRates?: number[];
|
|
60
|
-
playerSoftwareName?: string;
|
|
61
|
-
playerSoftwareVersion?: string;
|
|
62
|
-
playsInline?: boolean;
|
|
63
|
-
poster?: string;
|
|
64
|
-
preferCmcd?: CmcdTypes;
|
|
65
|
-
preferPlayback?: PlaybackTypes;
|
|
66
|
-
preload?: string;
|
|
67
|
-
primaryColor?: string;
|
|
68
|
-
renditionOrder?: RenditionOrderValue;
|
|
69
|
-
secondaryColor?: string;
|
|
70
|
-
src?: string;
|
|
71
|
-
startTime?: number;
|
|
72
|
-
storyboardSrc?: string;
|
|
73
|
-
streamType: StreamTypes | "ll-live" | "live:dvr" | "ll-live:dvr";
|
|
74
|
-
argetLiveWindow?: number;
|
|
75
|
-
theme?: string;
|
|
76
|
-
themeProps?: Record<string, any>;
|
|
77
|
-
thumbnailTime?: number;
|
|
78
|
-
title?: string;
|
|
79
|
-
tokens?: Tokens;
|
|
80
|
-
volume?: number;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const {
|
|
84
|
-
data,
|
|
85
|
-
disableCookies = true,
|
|
86
|
-
preload = "metadata",
|
|
87
|
-
...otherProps
|
|
88
|
-
} = Astro.props;
|
|
89
|
-
|
|
90
|
-
const computedProps = {
|
|
91
|
-
...useVideoPlayer({ data }),
|
|
92
|
-
disableCookies,
|
|
93
|
-
preload,
|
|
94
|
-
};
|
|
95
|
-
---
|
|
96
|
-
|
|
97
|
-
<mux-player
|
|
98
|
-
stream-type="on-demand"
|
|
99
|
-
{...toHTMLAttrs(computedProps)}
|
|
100
|
-
{...toHTMLAttrs(otherProps)}></mux-player>
|
|
101
|
-
|
|
102
|
-
<script>
|
|
103
|
-
import "@mux/mux-player";
|
|
104
|
-
</script>
|
package/lib/astro.d.ts
DELETED
package/lib/index.ts
DELETED
|
File without changes
|