@altano/astro-opengraph 0.1.0-alpha.4 → 0.1.1

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.
Files changed (40) hide show
  1. package/README.md +9 -0
  2. package/dist/config-CzK0JuaO.js +45 -0
  3. package/dist/config-CzK0JuaO.js.map +1 -0
  4. package/dist/config.d.ts +7 -3
  5. package/dist/config.js +3 -8
  6. package/dist/endpoint.d.ts +24 -11
  7. package/dist/endpoint.js +62 -85
  8. package/dist/endpoint.js.map +1 -0
  9. package/dist/index.d.ts +7 -2
  10. package/dist/index.js +41 -58
  11. package/dist/index.js.map +1 -0
  12. package/dist/toolbar/index.d.ts +6 -2
  13. package/dist/toolbar/index.js +359 -429
  14. package/dist/toolbar/index.js.map +1 -0
  15. package/dist/types-B1hoqgLx.d.ts +70 -0
  16. package/package.json +20 -17
  17. package/dist/chunk-DX3VCTOX.js +0 -49
  18. package/dist/image.d.ts +0 -7
  19. package/dist/integration.d.ts +0 -5
  20. package/dist/toolbar/components/CopyImageUrlButton.d.ts +0 -3
  21. package/dist/toolbar/components/Error.d.ts +0 -7
  22. package/dist/toolbar/components/ExternalLinkicon.d.ts +0 -7
  23. package/dist/toolbar/components/Image.d.ts +0 -6
  24. package/dist/toolbar/components/ImageSection.d.ts +0 -6
  25. package/dist/toolbar/components/ImageZoomToolbar.d.ts +0 -7
  26. package/dist/toolbar/components/LinkOrText.d.ts +0 -7
  27. package/dist/toolbar/components/MetaTags.d.ts +0 -3
  28. package/dist/toolbar/components/Summary.d.ts +0 -5
  29. package/dist/toolbar/components/ToolbarApp.d.ts +0 -3
  30. package/dist/toolbar/components/ToolbarAppWindow.d.ts +0 -3
  31. package/dist/toolbar/components/ToolbarSection.d.ts +0 -7
  32. package/dist/toolbar/components/ZoomButton.d.ts +0 -7
  33. package/dist/toolbar/components/ZoomLabel.d.ts +0 -4
  34. package/dist/toolbar/components/getRelativeUrl.d.ts +0 -2
  35. package/dist/toolbar/hooks/useHoverState.d.ts +0 -3
  36. package/dist/toolbar/hooks/useImageURL.d.ts +0 -3
  37. package/dist/toolbar/hooks/useMetaTagInfo.d.ts +0 -3
  38. package/dist/toolbar/styles.d.ts +0 -2
  39. package/dist/types.d.ts +0 -67
  40. package/dist/virtual-user-config.d.ts +0 -8
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["parsedMaybeLink: LinkOrTextType","tag: Element","setHoverState: (isHover: boolean) => void","handleClick: MouseEventHandler<DevToolbarButton>","Error","absoluteUrl: string","Error","app: DevToolbarApp","app"],"sources":["../../src/toolbar/styles.tsx","../../src/toolbar/components/Summary.tsx","../../src/toolbar/components/ExternalLinkicon.tsx","../../src/toolbar/components/LinkOrText.tsx","../../src/toolbar/hooks/useMetaTagInfo.tsx","../../src/toolbar/components/MetaTags.tsx","../../src/toolbar/hooks/useHoverState.tsx","../../src/toolbar/hooks/useImageURL.tsx","../../src/toolbar/components/Image.tsx","../../src/toolbar/components/ZoomLabel.tsx","../../src/toolbar/components/ZoomButton.tsx","../../src/toolbar/components/ToolbarSection.tsx","../../src/toolbar/components/ImageZoomToolbar.tsx","../../src/toolbar/components/CopyImageUrlButton.tsx","../../src/toolbar/components/ImageSection.tsx","../../src/toolbar/components/Error.tsx","../../src/toolbar/components/getRelativeUrl.tsx","../../src/toolbar/components/ToolbarApp.tsx","../../src/toolbar/components/ToolbarAppWindow.tsx","../../src/toolbar/index.tsx"],"sourcesContent":["export const styles = /* css */ `\n :host astro-dev-toolbar-window {\n max-height: calc(100vh - 80px);\n overflow-y: auto;\n }\n\n button {\n background: none;\n color: inherit;\n border: none;\n font: inherit;\n cursor: pointer;\n outline: inherit;\n }\n\n details {\n margin-block-end: 10px;\n }\n details:last-of-type {\n margin-block-end: 0;\n }\n\n details[open] summary, .image {\n margin-block-end: 7px;\n }\n\n .image img {\n transition: max-width 0.1s;\n }\n`;\n","import type Preact from \"preact\";\n\nexport function Summary({\n children,\n}: {\n children: string;\n}): Preact.JSX.Element {\n return (\n <summary\n style={{\n cursor: \"pointer\",\n fontWeight: 700,\n color: \"white\",\n }}\n >\n {children}\n </summary>\n );\n}\n","import type Preact from \"preact\";\n\nexport function ExternalLinkicon({\n width = 27,\n height = 27,\n fill = \"#020202\",\n}: {\n width?: number;\n height?: number;\n fill?: string;\n}): Preact.JSX.Element {\n return (\n <span\n style={{\n display: \"inline-block\",\n width,\n height,\n }}\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 120 120\">\n <path d=\"M120.09 16.696H60.256V.096L120.09.09z\" fill={fill} />\n <path\n d=\"M57.99 48.64l42.573-42.574 13.475 13.475-42.574 42.58z\"\n fill={fill}\n />\n <path\n d=\"M119.98.107l.02 59.83-16.59.013-.02-59.846zM3 23.5h17v87H3zm83.49 52.56h17V113h-17z\"\n fill={fill}\n />\n <path d=\"M3 16.692h40.655v17H3zM3 96h100.49v17H3z\" fill={fill} />\n </svg>\n </span>\n );\n}\n","import type Preact from \"preact\";\nimport { ExternalLinkicon } from \"./ExternalLinkicon.js\";\n\ntype LinkOrTextType = Preact.JSX.Element | string | null;\n\nexport function LinkOrText({\n maybeLinkText,\n}: {\n maybeLinkText: string | null;\n}): LinkOrTextType {\n let parsedMaybeLink: LinkOrTextType = null;\n try {\n if (maybeLinkText != null) {\n const url = new URL(maybeLinkText);\n parsedMaybeLink = (\n <a href={url.toString()} target=\"_blank\">\n {maybeLinkText}{\" \"}\n <ExternalLinkicon width={10} height={10} fill=\"white\" />\n </a>\n );\n }\n } catch (_) {\n parsedMaybeLink = maybeLinkText;\n }\n return parsedMaybeLink;\n}\n","import { useEffect, useRef, useState } from \"preact/hooks\";\n\nexport type MetaTagInfo = [content: string | null, property: string | null];\n\nconst useHeadObserver = (): React.RefObject<HTMLHeadElement | null> => {\n const [_generation, setGeneration] = useState<number>(0);\n const forceRerender = (): void => setGeneration((old) => ++old);\n const headRef = useRef(document.querySelector(\"head\"));\n\n // useEffect(() => {\n // console.log({ generation });\n // }, [generation]);\n\n useEffect(() => {\n // console.log({ \"headRef.current\": headRef.current });\n if (headRef.current == null) {\n // assume we must have a head by now, and if we don't, we will never get\n // one.\n return;\n }\n const observer = new MutationObserver(forceRerender);\n observer.observe(headRef.current, {\n attributes: true,\n characterData: true,\n childList: true,\n subtree: true,\n });\n return () => observer.disconnect();\n }, []);\n\n return headRef;\n};\n\nexport function useMetaTagInfo(): MetaTagInfo[] {\n const headRef = useHeadObserver();\n const opengraphMetaTags =\n headRef?.current?.querySelectorAll(\"meta[property^='og:']\") ?? [];\n // console.log({\n // opengraphMetaTags: opengraphMetaTags,\n // opengraphMetaTagsLength: opengraphMetaTags.length,\n // });\n return Array.from(opengraphMetaTags).map(\n (tag: Element): MetaTagInfo => [\n tag.getAttribute(\"content\"),\n tag.getAttribute(\"property\"),\n ],\n );\n}\n","import type Preact from \"preact\";\nimport { LinkOrText } from \"./LinkOrText.js\";\nimport { useMetaTagInfo, type MetaTagInfo } from \"../hooks/useMetaTagInfo.js\";\n\nexport function MetaTags(): Preact.JSX.Element {\n const tags = useMetaTagInfo();\n\n return (\n <dl\n data-testid=\"astro-opengraph-toolbar\"\n style={{\n margin: 0,\n display: \"grid\",\n gridTemplateColumns: \"max-content 1fr\",\n gap: 7,\n columnGap: 13,\n }}\n >\n {tags.map((tag) => (\n <MetaTagContent key={tag[1]} tag={tag} />\n ))}\n </dl>\n );\n}\n\nfunction MetaTagContent({ tag }: { tag: MetaTagInfo }): Preact.JSX.Element {\n const [content, property] = tag;\n return (\n <>\n <dt\n style={{\n color: \"white\",\n textAlign: \"right\",\n fontWeight: 500,\n }}\n >\n {property}\n </dt>\n <dd style={{ margin: 0 }}>\n <LinkOrText maybeLinkText={content} />\n </dd>\n </>\n );\n}\n","import type Preact from \"preact\";\nimport { useRef, useEffect } from \"preact/hooks\";\n\nexport function useHoverState<TElement extends HTMLElement>(\n setHoverState: (isHover: boolean) => void,\n): Preact.RefObject<TElement> {\n const ref = useRef<TElement>(null);\n\n useEffect(() => {\n const controller = new AbortController();\n const { signal } = controller;\n ref.current?.addEventListener(\"mouseenter\", () => setHoverState(true), {\n signal,\n });\n ref.current?.addEventListener(\"mouseleave\", () => setHoverState(false), {\n signal,\n });\n\n return () => controller.abort();\n }, [setHoverState]);\n\n return ref;\n}\n","import { useState } from \"preact/hooks\";\n\nexport function useImageURL(): string {\n const imageUrl = useImageURLIfAvailable();\n if (imageUrl == null) {\n throw new Error(\n `Shouldn't be rendering this component without an image URL`,\n );\n }\n return imageUrl;\n}\n\nexport function useImageURLIfAvailable(): string | null {\n const [imageUrlRef] = useState(() => {\n const meta = document.querySelector('meta[property=\"og:image\"]');\n return meta?.getAttribute(\"content\") ?? null;\n });\n return imageUrlRef;\n}\n","import type Preact from \"preact\";\nimport { useImageURL } from \"../hooks/useImageURL.js\";\n\nexport function Image({\n imageSize,\n handleLoadError,\n}: {\n imageSize: number;\n handleLoadError: () => void;\n}): Preact.JSX.Element {\n const imageUrl = useImageURL();\n return (\n <div className=\"image\">\n <a href={imageUrl} target=\"_blank\" title=\"Open image in new tab\">\n <img\n onError={handleLoadError}\n alt=\"Open Graph\"\n src={imageUrl}\n style={{\n maxHeight: \"100%\",\n maxWidth: `${imageSize}%`,\n }}\n />\n </a>\n </div>\n );\n}\n","export function ZoomLabel({ imageSize }: { imageSize: number }): string {\n const formattedNumber = (imageSize / 100).toLocaleString(undefined, {\n minimumFractionDigits: 2,\n });\n return `${formattedNumber}x`;\n}\n","import type Preact from \"preact\";\nimport { ZoomLabel } from \"./ZoomLabel.js\";\n\nexport function ZoomButton({\n value,\n imageSize,\n setImageSize,\n}: {\n value: number;\n imageSize: number;\n setImageSize: (size: number) => void;\n}): Preact.JSX.Element {\n const isSelected = value === imageSize;\n return (\n <astro-dev-toolbar-button\n size=\"small\"\n style={{ padding: 0, margin: 0 }}\n buttonStyle={isSelected ? \"gray\" : \"ghost\"}\n className=\"zoom-button\"\n role=\"radio\"\n onClick={() => setImageSize(value)}\n >\n <ZoomLabel imageSize={value} />\n </astro-dev-toolbar-button>\n );\n}\n","import type { ComponentChildren } from \"preact\";\nimport type Preact from \"preact\";\n\nexport function ToolbarSection({\n icon,\n children,\n}: {\n icon: Preact.JSX.Element;\n children: ComponentChildren;\n}): Preact.JSX.Element {\n return (\n <div\n style={{\n fontSize: 12,\n display: \"flex\",\n alignItems: \"center\",\n columnGap: 5,\n }}\n >\n <div\n style={{\n display: \"inline-block\",\n width: 12,\n height: 12,\n }}\n >\n {icon}\n </div>\n {children}\n </div>\n );\n}\n","import type Preact from \"preact\";\nimport { ZoomButton } from \"./ZoomButton.js\";\nimport { ToolbarSection } from \"./ToolbarSection.js\";\n\nexport function ImageZoomToolbar({\n isHovered,\n imageSize,\n setImageSize,\n}: {\n isHovered: boolean;\n imageSize: number;\n setImageSize: (size: number) => void;\n}): Preact.JSX.Element {\n return (\n <ToolbarSection icon={<astro-dev-toolbar-icon icon=\"gear\" />}>\n {!isHovered ? (\n <ZoomButton\n value={imageSize}\n imageSize={imageSize}\n setImageSize={setImageSize}\n />\n ) : (\n <>\n <ZoomButton\n value={25}\n imageSize={imageSize}\n setImageSize={setImageSize}\n />\n <ZoomButton\n value={50}\n imageSize={imageSize}\n setImageSize={setImageSize}\n />\n <ZoomButton\n value={75}\n imageSize={imageSize}\n setImageSize={setImageSize}\n />\n <ZoomButton\n value={100}\n imageSize={imageSize}\n setImageSize={setImageSize}\n />\n </>\n )}\n </ToolbarSection>\n );\n}\n","import { useState, useRef, useEffect, useCallback } from \"preact/hooks\";\nimport type Preact from \"preact\";\nimport type { MouseEventHandler } from \"preact/compat\";\nimport type { DevToolbarButton } from \"astro/runtime/client/dev-toolbar/ui-library/button.js\";\nimport { useImageURL } from \"../hooks/useImageURL.js\";\nimport { ToolbarSection } from \"./ToolbarSection.js\";\n\ntype Timer = ReturnType<typeof setTimeout>;\n\nexport function CopyImageUrlButton(): Preact.JSX.Element {\n const imageUrl = useImageURL();\n const [wasRecentlyClicked, setWasRecentlyClicked] = useState(false);\n const checkTimer = useRef<Timer | null>(null);\n\n useEffect(() => {\n if (wasRecentlyClicked && checkTimer.current == null) {\n checkTimer.current = setTimeout(() => {\n setWasRecentlyClicked(false);\n // TODO investigate\n // eslint-disable-next-line react-compiler/react-compiler\n checkTimer.current = null;\n }, 3_000);\n }\n }, [wasRecentlyClicked]);\n\n const handleClick: MouseEventHandler<DevToolbarButton> = useCallback(\n (evt) => {\n // Copy the text inside the text field\n void navigator.clipboard.writeText(imageUrl);\n setWasRecentlyClicked(true);\n evt.stopPropagation();\n evt.preventDefault();\n },\n [imageUrl],\n );\n\n return (\n <ToolbarSection icon={<astro-dev-toolbar-icon icon=\"copy\" />}>\n <div style={{ display: \"flex\", alignItems: \"center\" }}>\n <astro-dev-toolbar-button\n size=\"small\"\n buttonStyle=\"gray\"\n onClick={handleClick}\n >\n {wasRecentlyClicked ? \"Copied to clipboard\" : \"Copy image URL\"}\n </astro-dev-toolbar-button>\n </div>\n </ToolbarSection>\n );\n}\n","import { Image } from \"./Image.js\";\nimport { ImageZoomToolbar } from \"./ImageZoomToolbar.js\";\nimport { CopyImageUrlButton } from \"./CopyImageUrlButton.js\";\nimport type Preact from \"preact\";\nimport { useState } from \"preact/hooks\";\n\nexport function ImageSection({\n isHovered,\n handleLoadError,\n}: {\n isHovered: boolean;\n handleLoadError: () => void;\n}): Preact.JSX.Element {\n const [imageSize, setImageSize] = useState(100);\n\n return (\n <>\n <Image imageSize={imageSize} handleLoadError={handleLoadError} />\n <div\n data-testid=\"image-section-toolbar\"\n style={{\n display: \"flex\",\n flexDirection: \"row\",\n alignItems: \"center\",\n columnGap: 15,\n }}\n >\n <CopyImageUrlButton />\n <ImageZoomToolbar\n isHovered={isHovered}\n imageSize={imageSize}\n setImageSize={setImageSize}\n />\n </div>\n </>\n );\n}\n","import type { Icon } from \"astro/runtime/client/dev-toolbar/ui-library/icons.js\";\nimport type Preact from \"preact\";\n\nexport function Error({\n message,\n icon,\n}: {\n message: string;\n icon: Icon;\n}): Preact.JSX.Element {\n return (\n <div\n style={{\n display: \"flex\",\n gap: 10,\n alignItems: \"center\",\n }}\n >\n <astro-dev-toolbar-icon style={{ width: 24, height: 24 }} icon={icon} />{\" \"}\n {message}\n </div>\n );\n}\n","export function getRelativeUrl(absoluteUrl: string): string {\n const url = new URL(absoluteUrl);\n return url.pathname;\n}\n","import type Preact from \"preact\";\nimport { useState } from \"preact/hooks\";\nimport { Summary } from \"./Summary.js\";\nimport { MetaTags } from \"./MetaTags.js\";\nimport { useHoverState } from \"../hooks/useHoverState.js\";\nimport { useImageURLIfAvailable } from \"../hooks/useImageURL.js\";\nimport { ImageSection } from \"./ImageSection.js\";\nimport { Error } from \"./Error.js\";\nimport { getRelativeUrl } from \"./getRelativeUrl.js\";\n\nexport function ToolbarApp(): Preact.JSX.Element {\n const [isImageDetailsHovered, setIsImageDetailsHovered] = useState(false);\n const imageDetailsRef = useHoverState<HTMLDetailsElement>(\n setIsImageDetailsHovered,\n );\n const imageUrl = useImageURLIfAvailable();\n const [imageLoadStatus, setImageLoadStatus] = useState<\"pending\" | \"error\">(\n \"pending\",\n );\n\n if (imageUrl == null) {\n return (\n <Error icon=\"warning\" message=\"No Open Graph image found on this page\" />\n );\n } else if (imageLoadStatus === \"error\") {\n return (\n <Error\n icon=\"bug\"\n message={`Error loading image at ${getRelativeUrl(imageUrl)}`}\n />\n );\n }\n\n return (\n <>\n <details open className=\"image\" ref={imageDetailsRef}>\n <Summary>Image</Summary>\n <ImageSection\n isHovered={isImageDetailsHovered}\n handleLoadError={() => setImageLoadStatus(\"error\")}\n />\n </details>\n\n <details>\n <Summary>Meta Tags</Summary>\n <MetaTags />\n </details>\n </>\n );\n}\n","import type Preact from \"preact\";\nimport { styles } from \"../styles.js\";\nimport { ToolbarApp } from \"./ToolbarApp.js\";\n\nexport function ToolbarAppWindow(): Preact.JSX.Element {\n return (\n <astro-dev-toolbar-window>\n <style>{styles}</style>\n <ToolbarApp />\n </astro-dev-toolbar-window>\n );\n}\n","import { render } from \"preact\";\n\nimport { defineToolbarApp } from \"astro/toolbar\";\nimport { ToolbarAppWindow } from \"./components/ToolbarAppWindow.js\";\nimport type { DevToolbarApp } from \"astro\";\n\nconst SESSION_KEY_OPEN = \"@altano/astro-opengraph/toolbar:is-open\";\n\nconst app: DevToolbarApp = defineToolbarApp({\n init(canvas, app) {\n app.onToggled((event) => {\n if (event.state) {\n sessionStorage.setItem(SESSION_KEY_OPEN, \"true\");\n render(<ToolbarAppWindow />, canvas);\n } else {\n sessionStorage.removeItem(SESSION_KEY_OPEN);\n }\n });\n\n app.toggleNotification({\n state: document.querySelector('meta[property=\"og:image\"]') != null,\n level: \"info\",\n });\n\n if (sessionStorage.getItem(SESSION_KEY_OPEN) != null) {\n app.toggleState({ state: true });\n }\n },\n});\n\nexport default app;\n"],"mappings":";;;;;;AAAA,MAAa,UAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACEjC,SAAgB,QAAQ,EACtB,UAGD,EAAsB;AACrB,wBACE,IAAC;EACC,OAAO;GACL,QAAQ;GACR,YAAY;GACZ,OAAO;EACR;EAEA;GACO;AAEb;;;;AChBD,SAAgB,iBAAiB,EAC/B,QAAQ,IACR,SAAS,IACT,OAAO,WAKR,EAAsB;AACrB,wBACE,IAAC;EACC,OAAO;GACL,SAAS;GACT;GACA;EACD;4BAED,KAAC;GAAI,OAAM;GAA6B,SAAQ;;oBAC9C,IAAC;KAAK,GAAE;KAA8C;MAAQ;oBAC9D,IAAC;KACC,GAAE;KACI;MACN;oBACF,IAAC;KACC,GAAE;KACI;MACN;oBACF,IAAC;KAAK,GAAE;KAAiD;MAAQ;;IAC7D;GACD;AAEV;;;;AC5BD,SAAgB,WAAW,EACzB,eAGD,EAAkB;CACjB,IAAIA,kBAAkC;AACtC,KAAI;AACF,MAAI,iBAAiB,MAAM;GACzB,MAAM,MAAM,IAAI,IAAI;AACpB,qCACE,KAAC;IAAE,MAAM,IAAI,UAAU;IAAE,QAAO;;KAC7B;KAAe;qBAChB,IAAC;MAAiB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qBAAQ,cAAmB,kBAC5B,IAAC,aAAW,IACJ,IACT;AAEN;;;;AC7CD,SAAgB,mBAAuC;AACrD,wBACE,KAAC,yDACC,IAAC,qBAAO,SAAe,kBACvB,IAAC,eAAa,IACW;AAE9B;;;;ACLD,MAAM,mBAAmB;AAEzB,MAAMC,MAAqB,iBAAiB,EAC1C,KAAK,QAAQC,OAAK;AAChB,OAAI,UAAU,CAAC,UAAU;AACvB,MAAI,MAAM,OAAO;AACf,kBAAe,QAAQ,kBAAkB,OAAO;AAChD,0BAAO,IAAC,qBAAmB,EAAE,OAAO;EACrC,MACC,gBAAe,WAAW,iBAAiB;CAE9C,EAAC;AAEF,OAAI,mBAAmB;EACrB,OAAO,SAAS,cAAc,8BAA4B,IAAI;EAC9D,OAAO;CACR,EAAC;AAEF,KAAI,eAAe,QAAQ,iBAAiB,IAAI,KAC9C,OAAI,YAAY,EAAE,OAAO,KAAM,EAAC;AAEnC,EACF,EAAC;AAEF,sBAAe"}
@@ -0,0 +1,70 @@
1
+ import { SatoriOptions } from "satori";
2
+
3
+ //#region src/types.d.ts
4
+ type ImageOptions = SatoriOptions;
5
+ type FontWithBuffer = ImageOptions["fonts"][0];
6
+ type FontWithPath = Omit<FontWithBuffer, "data"> & {
7
+ path: string;
8
+ };
9
+ type ImageOptionsBase = {
10
+ width?: number;
11
+ height?: number;
12
+ debug?: boolean;
13
+ };
14
+ type ImageOptionsBaseResolved = {
15
+ width: number;
16
+ height: number;
17
+ debug?: boolean;
18
+ };
19
+ type ImageOptionsWithFontPaths = ImageOptionsBase & {
20
+ fonts: FontWithPath[];
21
+ };
22
+ type ImageOptionsWithFontBuffers = ImageOptionsBase & {
23
+ fonts: FontWithBuffer[];
24
+ };
25
+ type ImageOptionsWithFontBuffersResolved = ImageOptionsBaseResolved & {
26
+ fonts: FontWithBuffer[];
27
+ };
28
+ type ComponentMetaTagFallbacks = {
29
+ "og:title"?: string;
30
+ "og:description"?: string;
31
+ "og:image"?: string;
32
+ };
33
+ type MetaTagDefaults = {
34
+ "og:image": string;
35
+ };
36
+ type OpengraphImageConfig = {
37
+ /**
38
+ * Options to use for the image file that is generated. Most importantly, fonts
39
+ * must be provided.
40
+ */
41
+ getImageOptions(): Promise<ImageOptionsWithFontPaths>;
42
+ /**
43
+ * Defaults to use in the component for tags you don't manually set.
44
+ */
45
+ componentMetaTagFallbacks?: ComponentMetaTagFallbacks;
46
+ };
47
+ type AstroConfigSetupHookOptions = Parameters<Astro.IntegrationHooks["astro:config:setup"]>[0];
48
+ type Command = AstroConfigSetupHookOptions["command"];
49
+ /**
50
+ * This must remain JSON-serializable!
51
+ */
52
+ type OpengraphImageConfigSerializable = {
53
+ imageOptions: ImageOptionsWithFontPaths;
54
+ componentMetaTagFallbacks?: ComponentMetaTagFallbacks;
55
+ command: Command;
56
+ };
57
+ type OpengraphImageConfigSerializableMaybeMocked = OpengraphImageConfigSerializable | (() => OpengraphImageConfigSerializable);
58
+ type OpengraphImageConfigDeserialized = {
59
+ imageOptions: ImageOptionsWithFontBuffers;
60
+ componentMetaTagFallbacks?: ComponentMetaTagFallbacks | undefined;
61
+ command: Command;
62
+ };
63
+ type OpengraphImageConfigResolved = {
64
+ imageOptions: ImageOptionsWithFontBuffersResolved;
65
+ componentMetaTagFallbacks: ComponentMetaTagFallbacks & MetaTagDefaults;
66
+ command: Command;
67
+ };
68
+ //#endregion
69
+ export { ComponentMetaTagFallbacks, ImageOptions, ImageOptionsWithFontPaths, OpengraphImageConfig, OpengraphImageConfigDeserialized, OpengraphImageConfigResolved, OpengraphImageConfigSerializableMaybeMocked };
70
+ //# sourceMappingURL=types-B1hoqgLx.d.ts.map
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "@altano/astro-opengraph",
3
- "version": "0.1.0-alpha.4",
3
+ "version": "0.1.1",
4
4
  "description": "Open Graph Tools for Astro",
5
5
  "keywords": [
6
6
  "astro",
7
7
  "astro-integration",
8
+ "astro-component",
9
+ "devtools",
10
+ "image",
8
11
  "opengraph",
9
- "devtools"
12
+ "withastro"
10
13
  ],
11
14
  "homepage": "https://github.com/altano/npm-packages/tree/main/packages/astro-opengraph",
12
15
  "repository": {
@@ -33,6 +36,7 @@
33
36
  "assets",
34
37
  "components",
35
38
  "dist/**/*.js",
39
+ "dist/**/*.js.map",
36
40
  "dist/**/*.d.ts"
37
41
  ],
38
42
  "dependencies": {
@@ -46,28 +50,28 @@
46
50
  "@astrojs/svelte": "^7.0.9",
47
51
  "@astrojs/vue": "^5.0.9",
48
52
  "@inox-tools/astro-tests": "0.5.1",
49
- "@playwright/test": "1.47.0",
53
+ "@playwright/test": "1.51.1",
50
54
  "@types/he": "^1.2.3",
51
55
  "@types/jest-image-snapshot": "^6.4.0",
52
56
  "@types/node": "^22.13.10",
53
- "@vitest/coverage-v8": "^3.1.1",
54
- "astro": "^5.5.6",
57
+ "@vitest/coverage-v8": "^3.1.4",
58
+ "astro": "^5.10.1",
55
59
  "depcheck": "^1.4.7",
56
60
  "jest-image-snapshot": "^6.4.0",
57
61
  "preact": "^10.26.5",
58
62
  "sharp": "^0.33.1",
59
63
  "svelte": "^5.25.12",
60
- "tsup": "^8.4.0",
64
+ "tsdown": "^0.12.9",
61
65
  "typescript": "^5.8.2",
62
- "vite": "^6.2.5",
63
- "vitest": "^3.1.1",
66
+ "vite": "^6.2.6",
67
+ "vitest": "^3.1.4",
64
68
  "vue": "^3.5.13",
65
69
  "zx": "^8.5.2",
66
- "@altano/assets": "0.0.0",
67
- "@altano/testing": "0.0.0",
68
- "@altano/build-config": "0.0.0",
69
- "@altano/tsconfig": "0.0.0",
70
- "@altano/tiny-async-pool": "3.0.2",
70
+ "@altano/assets": "0.0.1",
71
+ "@altano/build-config": "0.0.1",
72
+ "@altano/testing": "0.0.1",
73
+ "@altano/tiny-async-pool": "4.0.1",
74
+ "@altano/tsconfig": "0.0.1",
71
75
  "@altano/vitest-plugins": "1.1.0"
72
76
  },
73
77
  "peerDependencies": {
@@ -78,14 +82,13 @@
78
82
  "access": "public"
79
83
  },
80
84
  "scripts": {
81
- "build": "tsup --config ./tsup.config.ts",
82
- "build:types": "tsc --project tsconfig.declarations.json",
83
- "check:types:astro-fixtures": "node --experimental-strip-types ./scripts/check-fixtures.ts",
85
+ "build": "tsdown",
86
+ "check:types:astro": "node --experimental-strip-types ./scripts/check-fixtures.ts",
84
87
  "check:types:src": "tsc --noEmit",
85
88
  "check:types:test": "tsc --noEmit --project ./tests/tsconfig.json",
86
89
  "check:unused-dependencies": "depcheck",
87
90
  "clean": "rm -rf .turbo && rm -rf .tsbuildinfo && rm -rf node_modules && rm -rf dist",
88
- "dev": "tsup --watch",
91
+ "dev": "tsdown --watch",
89
92
  "format": "prettier --write src",
90
93
  "lint": "eslint",
91
94
  "lint:fix": "TIMING=1 eslint src/**/*.ts* --fix",
@@ -1,49 +0,0 @@
1
- // src/config.ts
2
- import { readFile } from "node:fs/promises";
3
- async function deserializeVirtualConfig(configMaybeMocked) {
4
- const config = typeof configMaybeMocked === "function" ? configMaybeMocked() : configMaybeMocked;
5
- const fontsWithBuffers = await Promise.all(
6
- config.imageOptions.fonts.map(async (font) => {
7
- const data = await readFile(font.path);
8
- return {
9
- ...font,
10
- data
11
- };
12
- })
13
- );
14
- return {
15
- ...config,
16
- imageOptions: {
17
- ...config.imageOptions,
18
- fonts: fontsWithBuffers
19
- }
20
- };
21
- }
22
- var imageOptionDefaults = {
23
- width: 1200,
24
- height: 630
25
- };
26
- var metaTagDefaults = {
27
- "og:image": `/opengraph.png`
28
- };
29
- async function getResolvedConfig() {
30
- const module = await import("virtual:astro-opengraph/user-config");
31
- const lazyConfig = module.default;
32
- const deserialized = await deserializeVirtualConfig(lazyConfig);
33
- return {
34
- ...deserialized,
35
- imageOptions: {
36
- ...imageOptionDefaults,
37
- ...deserialized.imageOptions
38
- },
39
- componentMetaTagFallbacks: {
40
- ...deserialized.componentMetaTagFallbacks,
41
- ...metaTagDefaults
42
- }
43
- };
44
- }
45
-
46
- export {
47
- deserializeVirtualConfig,
48
- getResolvedConfig
49
- };
package/dist/image.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import { type SatoriOptions } from "satori";
2
- import type { LocalImageService } from "astro";
3
- /**
4
- * Convert an html string to an image
5
- */
6
- export declare function htmlToPNG(html: string, satoriOptions: SatoriOptions): Promise<ReturnType<LocalImageService["transform"]>>;
7
- //# sourceMappingURL=image.d.ts.map
@@ -1,5 +0,0 @@
1
- import type { AstroIntegration } from "astro";
2
- import type { OpengraphImageConfig } from "./types.js";
3
- declare const _default: (config: OpengraphImageConfig) => AstroIntegration;
4
- export default _default;
5
- //# sourceMappingURL=integration.d.ts.map
@@ -1,3 +0,0 @@
1
- import type Preact from "preact";
2
- export declare function CopyImageUrlButton(): Preact.JSX.Element;
3
- //# sourceMappingURL=CopyImageUrlButton.d.ts.map
@@ -1,7 +0,0 @@
1
- import type { Icon } from "astro/runtime/client/dev-toolbar/ui-library/icons.js";
2
- import type Preact from "preact";
3
- export declare function Error({ message, icon, }: {
4
- message: string;
5
- icon: Icon;
6
- }): Preact.JSX.Element;
7
- //# sourceMappingURL=Error.d.ts.map
@@ -1,7 +0,0 @@
1
- import type Preact from "preact";
2
- export declare function ExternalLinkicon({ width, height, fill, }: {
3
- width?: number;
4
- height?: number;
5
- fill?: string;
6
- }): Preact.JSX.Element;
7
- //# sourceMappingURL=ExternalLinkicon.d.ts.map
@@ -1,6 +0,0 @@
1
- import type Preact from "preact";
2
- export declare function Image({ imageSize, handleLoadError, }: {
3
- imageSize: number;
4
- handleLoadError: () => void;
5
- }): Preact.JSX.Element;
6
- //# sourceMappingURL=Image.d.ts.map
@@ -1,6 +0,0 @@
1
- import type Preact from "preact";
2
- export declare function ImageSection({ isHovered, handleLoadError, }: {
3
- isHovered: boolean;
4
- handleLoadError: () => void;
5
- }): Preact.JSX.Element;
6
- //# sourceMappingURL=ImageSection.d.ts.map
@@ -1,7 +0,0 @@
1
- import type Preact from "preact";
2
- export declare function ImageZoomToolbar({ isHovered, imageSize, setImageSize, }: {
3
- isHovered: boolean;
4
- imageSize: number;
5
- setImageSize: (size: number) => void;
6
- }): Preact.JSX.Element;
7
- //# sourceMappingURL=ImageZoomToolbar.d.ts.map
@@ -1,7 +0,0 @@
1
- import type Preact from "preact";
2
- type LinkOrTextType = Preact.JSX.Element | string | null;
3
- export declare function LinkOrText({ maybeLinkText, }: {
4
- maybeLinkText: string | null;
5
- }): LinkOrTextType;
6
- export {};
7
- //# sourceMappingURL=LinkOrText.d.ts.map
@@ -1,3 +0,0 @@
1
- import type Preact from "preact";
2
- export declare function MetaTags(): Preact.JSX.Element;
3
- //# sourceMappingURL=MetaTags.d.ts.map
@@ -1,5 +0,0 @@
1
- import type Preact from "preact";
2
- export declare function Summary({ children, }: {
3
- children: string;
4
- }): Preact.JSX.Element;
5
- //# sourceMappingURL=Summary.d.ts.map
@@ -1,3 +0,0 @@
1
- import type Preact from "preact";
2
- export declare function ToolbarApp(): Preact.JSX.Element;
3
- //# sourceMappingURL=ToolbarApp.d.ts.map
@@ -1,3 +0,0 @@
1
- import type Preact from "preact";
2
- export declare function ToolbarAppWindow(): Preact.JSX.Element;
3
- //# sourceMappingURL=ToolbarAppWindow.d.ts.map
@@ -1,7 +0,0 @@
1
- import type { ComponentChildren } from "preact";
2
- import type Preact from "preact";
3
- export declare function ToolbarSection({ icon, children, }: {
4
- icon: Preact.JSX.Element;
5
- children: ComponentChildren;
6
- }): Preact.JSX.Element;
7
- //# sourceMappingURL=ToolbarSection.d.ts.map
@@ -1,7 +0,0 @@
1
- import type Preact from "preact";
2
- export declare function ZoomButton({ value, imageSize, setImageSize, }: {
3
- value: number;
4
- imageSize: number;
5
- setImageSize: (size: number) => void;
6
- }): Preact.JSX.Element;
7
- //# sourceMappingURL=ZoomButton.d.ts.map
@@ -1,4 +0,0 @@
1
- export declare function ZoomLabel({ imageSize }: {
2
- imageSize: number;
3
- }): string;
4
- //# sourceMappingURL=ZoomLabel.d.ts.map
@@ -1,2 +0,0 @@
1
- export declare function getRelativeUrl(absoluteUrl: string): string;
2
- //# sourceMappingURL=getRelativeUrl.d.ts.map
@@ -1,3 +0,0 @@
1
- import type Preact from "preact";
2
- export declare function useHoverState<TElement extends HTMLElement>(setHoverState: (isHover: boolean) => void): Preact.RefObject<TElement>;
3
- //# sourceMappingURL=useHoverState.d.ts.map
@@ -1,3 +0,0 @@
1
- export declare function useImageURL(): string;
2
- export declare function useImageURLIfAvailable(): string | null;
3
- //# sourceMappingURL=useImageURL.d.ts.map
@@ -1,3 +0,0 @@
1
- export type MetaTagInfo = [content: string | null, property: string | null];
2
- export declare function useMetaTagInfo(): MetaTagInfo[];
3
- //# sourceMappingURL=useMetaTagInfo.d.ts.map
@@ -1,2 +0,0 @@
1
- export declare const styles = "\n :host astro-dev-toolbar-window {\n max-height: calc(100vh - 80px);\n overflow-y: auto;\n }\n\n button {\n background: none;\n color: inherit;\n border: none;\n font: inherit;\n cursor: pointer;\n outline: inherit;\n }\n\n details {\n margin-block-end: 10px;\n }\n details:last-of-type {\n margin-block-end: 0;\n }\n\n details[open] summary, .image {\n margin-block-end: 7px;\n }\n\n .image img {\n transition: max-width 0.1s;\n }\n";
2
- //# sourceMappingURL=styles.d.ts.map
package/dist/types.d.ts DELETED
@@ -1,67 +0,0 @@
1
- import type { SatoriOptions } from "satori";
2
- export type ImageOptions = SatoriOptions;
3
- export type FontWithBuffer = ImageOptions["fonts"][0];
4
- export type FontWithPath = Omit<FontWithBuffer, "data"> & {
5
- path: string;
6
- };
7
- type ImageOptionsBase = {
8
- width?: number;
9
- height?: number;
10
- debug?: boolean;
11
- };
12
- type ImageOptionsBaseResolved = {
13
- width: number;
14
- height: number;
15
- debug?: boolean;
16
- };
17
- export type ImageOptionsWithFontPaths = ImageOptionsBase & {
18
- fonts: FontWithPath[];
19
- };
20
- export type ImageOptionsWithFontBuffers = ImageOptionsBase & {
21
- fonts: FontWithBuffer[];
22
- };
23
- export type ImageOptionsWithFontBuffersResolved = ImageOptionsBaseResolved & {
24
- fonts: FontWithBuffer[];
25
- };
26
- export type ComponentMetaTagFallbacks = {
27
- "og:title"?: string;
28
- "og:description"?: string;
29
- "og:image"?: string;
30
- };
31
- export type MetaTagDefaults = {
32
- "og:image": string;
33
- };
34
- export type OpengraphImageConfig = {
35
- /**
36
- * Options to use for the image file that is generated. Most importantly, fonts
37
- * must be provided.
38
- */
39
- getImageOptions(): Promise<ImageOptionsWithFontPaths>;
40
- /**
41
- * Defaults to use in the component for tags you don't manually set.
42
- */
43
- componentMetaTagFallbacks?: ComponentMetaTagFallbacks;
44
- };
45
- type AstroConfigSetupHookOptions = Parameters<Astro.IntegrationHooks["astro:config:setup"]>[0];
46
- type Command = AstroConfigSetupHookOptions["command"];
47
- /**
48
- * This must remain JSON-serializable!
49
- */
50
- export type OpengraphImageConfigSerializable = {
51
- imageOptions: ImageOptionsWithFontPaths;
52
- componentMetaTagFallbacks?: ComponentMetaTagFallbacks;
53
- command: Command;
54
- };
55
- export type OpengraphImageConfigSerializableMaybeMocked = OpengraphImageConfigSerializable | (() => OpengraphImageConfigSerializable);
56
- export type OpengraphImageConfigDeserialized = {
57
- imageOptions: ImageOptionsWithFontBuffers;
58
- componentMetaTagFallbacks?: ComponentMetaTagFallbacks | undefined;
59
- command: Command;
60
- };
61
- export type OpengraphImageConfigResolved = {
62
- imageOptions: ImageOptionsWithFontBuffersResolved;
63
- componentMetaTagFallbacks: ComponentMetaTagFallbacks & MetaTagDefaults;
64
- command: Command;
65
- };
66
- export {};
67
- //# sourceMappingURL=types.d.ts.map
@@ -1,8 +0,0 @@
1
- import type { ViteUserConfig } from "astro";
2
- import type { OpengraphImageConfigSerializable } from "./types.js";
3
- /**
4
- * Vite plugin that exposes OpengraphImage user config and project context via
5
- * virtual modules.
6
- */
7
- export declare function vitePluginOpengraphImageUserConfig(config: OpengraphImageConfigSerializable): NonNullable<ViteUserConfig["plugins"]>[number];
8
- //# sourceMappingURL=virtual-user-config.d.ts.map