@ethercorps/sveltekit-og 4.2.0 → 4.2.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.
- package/LICENSE +21 -0
- package/README.md +6 -2
- package/dist/helpers/create.d.ts +1 -2
- package/dist/helpers/create.js +1 -9
- package/dist/helpers/toJSX.d.ts +3 -0
- package/dist/helpers/toJSX.js +9 -0
- package/package.json +10 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Ethercorps
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
[](https://npmjs.com/package/bits-ui)
|
|
2
|
+
[](https://npmjs.com/package/@ethercorps/sveltekit-og)
|
|
3
|
+
[](https://github.com/ethercorps/sveltekit-og/blob/main/LICENSE)
|
|
4
|
+
|
|
1
5
|
# SvelteKit Open Graph Image Generation
|
|
2
6
|
|
|
3
7
|
Dynamically generate Open Graph images from an HTML+CSS template or Svelte component using fast and efficient conversion from HTML > SVG > PNG. Based on [Satori](https://github.com/vercel/satori#documentation). No headless browser required.
|
|
4
8
|
|
|
5
9
|
## Docs
|
|
6
|
-
- With sveltekit-og@4
|
|
10
|
+
- With `sveltekit-og@4`, we have [official documentation](https://sveltekit-og.dev).
|
|
7
11
|
|
|
8
12
|
## Installation
|
|
9
13
|
|
|
@@ -114,7 +118,7 @@ Then run `npm dev` and visit `localhost:5173/og` to view your generated PNG. Rem
|
|
|
114
118
|
|
|
115
119
|
## Example Output
|
|
116
120
|
|
|
117
|
-

|
|
118
122
|
|
|
119
123
|
## Headers
|
|
120
124
|
|
package/dist/helpers/create.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Component } from 'svelte';
|
|
2
|
-
import type { ComponentOptions, ImageOptions
|
|
3
|
-
export declare function createVNode(element: string | Component, componentOptions?: ComponentOptions): Promise<VNode>;
|
|
2
|
+
import type { ComponentOptions, ImageOptions } from '../types.js';
|
|
4
3
|
export declare function createSvg(element: string | Component, imageOptions: ImageOptions, componentOptions?: ComponentOptions): Promise<string>;
|
|
5
4
|
export declare function createPng(element: string | Component, imageOptions: ImageOptions, componentOptions?: ComponentOptions): Promise<Uint8Array<ArrayBufferLike>>;
|
package/dist/helpers/create.js
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
import { html } from 'satori-html';
|
|
2
1
|
import { loadDynamicAsset } from './emoji.js';
|
|
3
2
|
import { default_fonts, DEFAULT_WIDTH } from '../helpers/defaults.js';
|
|
4
3
|
import { useResvg, useSatori } from '../providers/instances.js';
|
|
5
|
-
import {
|
|
6
|
-
function svelteComponentToJsx(component, props = {}) {
|
|
7
|
-
const { body, head } = render(component, { props });
|
|
8
|
-
return html(body + head);
|
|
9
|
-
}
|
|
10
|
-
export async function createVNode(element, componentOptions) {
|
|
11
|
-
return typeof element === 'string' ? html(element.replaceAll('\n', '').trim()) : svelteComponentToJsx(element, componentOptions?.props);
|
|
12
|
-
}
|
|
4
|
+
import { createVNode } from './toJSX.js';
|
|
13
5
|
export async function createSvg(element, imageOptions, componentOptions) {
|
|
14
6
|
const [satori, vnodes] = await Promise.all([useSatori(), createVNode(element, componentOptions)]);
|
|
15
7
|
const satoriOptions = structuredClone(imageOptions);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { render } from 'svelte/server';
|
|
2
|
+
import { html } from 'satori-html';
|
|
3
|
+
function svelteComponentToHTML(component, props = {}) {
|
|
4
|
+
const { body, head } = render(component, { props });
|
|
5
|
+
return html(body + head);
|
|
6
|
+
}
|
|
7
|
+
export function createVNode(element, componentOptions) {
|
|
8
|
+
return typeof element === 'string' ? html(element.replaceAll('\n', '').trim()) : svelteComponentToHTML(element, componentOptions?.props);
|
|
9
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ethercorps/sveltekit-og",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.1",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"homepage": "https://sveltekit-og.dev",
|
|
6
|
+
"repository": "github:ethercorps/sveltekit-og",
|
|
7
|
+
"funding": "https://github.com/sponsors/ethercorps",
|
|
8
|
+
"author": "Shivam Meena <https://github.com/theetherGit>",
|
|
9
|
+
"description": "Dynamically generate Open Graph images from an HTML, CSS template or Svelte component using fast and efficient conversion from HTML > SVG > PNG",
|
|
4
10
|
"exports": {
|
|
5
11
|
".": {
|
|
6
12
|
"types": "./dist/index.d.ts",
|
|
@@ -50,6 +56,9 @@
|
|
|
50
56
|
"type": "module",
|
|
51
57
|
"dependencies": {
|
|
52
58
|
"@resvg/resvg-wasm": "^2.6.2",
|
|
59
|
+
"@takumi-rs/helpers": "^0.55.0",
|
|
60
|
+
"@takumi-rs/image-response": "^0.55.0",
|
|
61
|
+
"@takumi-rs/wasm": "^0.55.0",
|
|
53
62
|
"satori": "^0.10.14",
|
|
54
63
|
"satori-html": "0.3.2",
|
|
55
64
|
"std-env": "^3.9.0",
|