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

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 (36) hide show
  1. package/README.md +9 -0
  2. package/dist/config-CzK0JuaO.js +45 -0
  3. package/dist/config.d.ts +8 -3
  4. package/dist/config.js +3 -8
  5. package/dist/endpoint.d.ts +25 -11
  6. package/dist/endpoint.js +62 -85
  7. package/dist/index.d.ts +8 -2
  8. package/dist/index.js +41 -58
  9. package/dist/toolbar/index.d.ts +7 -2
  10. package/dist/toolbar/index.js +359 -429
  11. package/dist/types-Lk5HqHkQ.d.ts +71 -0
  12. package/package.json +19 -17
  13. package/dist/chunk-DX3VCTOX.js +0 -49
  14. package/dist/image.d.ts +0 -7
  15. package/dist/integration.d.ts +0 -5
  16. package/dist/toolbar/components/CopyImageUrlButton.d.ts +0 -3
  17. package/dist/toolbar/components/Error.d.ts +0 -7
  18. package/dist/toolbar/components/ExternalLinkicon.d.ts +0 -7
  19. package/dist/toolbar/components/Image.d.ts +0 -6
  20. package/dist/toolbar/components/ImageSection.d.ts +0 -6
  21. package/dist/toolbar/components/ImageZoomToolbar.d.ts +0 -7
  22. package/dist/toolbar/components/LinkOrText.d.ts +0 -7
  23. package/dist/toolbar/components/MetaTags.d.ts +0 -3
  24. package/dist/toolbar/components/Summary.d.ts +0 -5
  25. package/dist/toolbar/components/ToolbarApp.d.ts +0 -3
  26. package/dist/toolbar/components/ToolbarAppWindow.d.ts +0 -3
  27. package/dist/toolbar/components/ToolbarSection.d.ts +0 -7
  28. package/dist/toolbar/components/ZoomButton.d.ts +0 -7
  29. package/dist/toolbar/components/ZoomLabel.d.ts +0 -4
  30. package/dist/toolbar/components/getRelativeUrl.d.ts +0 -2
  31. package/dist/toolbar/hooks/useHoverState.d.ts +0 -3
  32. package/dist/toolbar/hooks/useImageURL.d.ts +0 -3
  33. package/dist/toolbar/hooks/useMetaTagInfo.d.ts +0 -3
  34. package/dist/toolbar/styles.d.ts +0 -2
  35. package/dist/types.d.ts +0 -67
  36. package/dist/virtual-user-config.d.ts +0 -8
@@ -0,0 +1,71 @@
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
+
69
+ //#endregion
70
+ export { ComponentMetaTagFallbacks, ImageOptions, ImageOptionsWithFontPaths, OpengraphImageConfig, OpengraphImageConfigDeserialized, OpengraphImageConfigResolved, OpengraphImageConfigSerializableMaybeMocked };
71
+ //# sourceMappingURL=types-Lk5HqHkQ.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.0",
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": {
@@ -46,28 +49,28 @@
46
49
  "@astrojs/svelte": "^7.0.9",
47
50
  "@astrojs/vue": "^5.0.9",
48
51
  "@inox-tools/astro-tests": "0.5.1",
49
- "@playwright/test": "1.47.0",
52
+ "@playwright/test": "1.51.1",
50
53
  "@types/he": "^1.2.3",
51
54
  "@types/jest-image-snapshot": "^6.4.0",
52
55
  "@types/node": "^22.13.10",
53
- "@vitest/coverage-v8": "^3.1.1",
54
- "astro": "^5.5.6",
56
+ "@vitest/coverage-v8": "^3.1.4",
57
+ "astro": "^5.8.0",
55
58
  "depcheck": "^1.4.7",
56
59
  "jest-image-snapshot": "^6.4.0",
57
60
  "preact": "^10.26.5",
58
61
  "sharp": "^0.33.1",
59
62
  "svelte": "^5.25.12",
60
- "tsup": "^8.4.0",
63
+ "tsdown": "^0.12.3",
61
64
  "typescript": "^5.8.2",
62
- "vite": "^6.2.5",
63
- "vitest": "^3.1.1",
65
+ "vite": "^6.2.6",
66
+ "vitest": "^3.1.4",
64
67
  "vue": "^3.5.13",
65
68
  "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",
69
+ "@altano/assets": "0.0.1",
70
+ "@altano/build-config": "0.0.1",
71
+ "@altano/testing": "0.0.1",
72
+ "@altano/tiny-async-pool": "4.0.0",
73
+ "@altano/tsconfig": "0.0.1",
71
74
  "@altano/vitest-plugins": "1.1.0"
72
75
  },
73
76
  "peerDependencies": {
@@ -78,14 +81,13 @@
78
81
  "access": "public"
79
82
  },
80
83
  "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",
84
+ "build": "tsdown",
85
+ "check:types:astro": "node --experimental-strip-types ./scripts/check-fixtures.ts",
84
86
  "check:types:src": "tsc --noEmit",
85
87
  "check:types:test": "tsc --noEmit --project ./tests/tsconfig.json",
86
88
  "check:unused-dependencies": "depcheck",
87
89
  "clean": "rm -rf .turbo && rm -rf .tsbuildinfo && rm -rf node_modules && rm -rf dist",
88
- "dev": "tsup --watch",
90
+ "dev": "tsdown --watch",
89
91
  "format": "prettier --write src",
90
92
  "lint": "eslint",
91
93
  "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