@ethercorps/sveltekit-og 4.2.0-next.2 → 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 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
+ [![npm version](https://flat.badgen.net/npm/v/@ethercorps/sveltekit-og?color=orange)](https://npmjs.com/package/bits-ui)
2
+ [![npm downloads](https://flat.badgen.net/npm/dm/@ethercorps/sveltekit-og?color=orange)](https://npmjs.com/package/@ethercorps/sveltekit-og)
3
+ [![license](https://flat.badgen.net/github/license/ethercorps/sveltekit-og?color=orange)](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
- ## Disclaimer
6
- This project doesn't support edge services like vercel edge and cloudflare workers.
9
+ ## Docs
10
+ - With `sveltekit-og@4`, we have [official documentation](https://sveltekit-og.dev).
7
11
 
8
12
  ## Installation
9
13
 
@@ -13,12 +17,28 @@ pnpm install @ethercorps/sveltekit-og
13
17
 
14
18
  ## Usage
15
19
 
20
+ ### Vite (Recommended)
21
+
22
+ - Add vite plugin
23
+
24
+ ```typescript title="vite.cofig.js"
25
+ import { sveltekit } from '@sveltejs/kit/vite';
26
+ import { sveltekitOG } from '@ethercorps/sveltekit-og/plugin';
27
+ const config = {
28
+ plugins: [sveltekit(), sveltekitOG()]
29
+ };
30
+
31
+ export default config;
32
+ ```
33
+
34
+ ### Rollup (will be deprecated in v5)
16
35
  - Add `rollupWasm` to `build.rollupOptions.plugins` in `vite.cofig.js` file.
17
- -
18
- ```ts
36
+ - For more information, check [docs](https://sveltekit-og.dev/docs/getting-started)
37
+
38
+ ```ts title="vite.cofig.js"
19
39
  import { sveltekit } from '@sveltejs/kit/vite';
20
40
  import { defineConfig } from 'vitest/config';
21
- import { rollupWasm } from './src/lib/plugin.js';
41
+ import { rollupWasm } from '@ethercorps/sveltekit-og/plugin';
22
42
 
23
43
  export default defineConfig({
24
44
  plugins: [sveltekit()],
@@ -31,8 +51,13 @@ export default defineConfig({
31
51
  ```
32
52
 
33
53
  - For node adapter update config with `rollupWasm`
54
+ - Check node runtime [docs](https://sveltekit-og.dev/docs/runtime/node)
55
+
56
+ ```ts title="vite.cofig.js"
57
+ import { sveltekit } from '@sveltejs/kit/vite';
58
+ import { defineConfig } from 'vitest/config';
59
+ import { rollupWasm } from '@ethercorps/sveltekit-og/plugin';
34
60
 
35
- ```ts
36
61
  export default defineConfig({
37
62
  plugins: [sveltekit()],
38
63
  build: {
@@ -93,7 +118,7 @@ Then run `npm dev` and visit `localhost:5173/og` to view your generated PNG. Rem
93
118
 
94
119
  ## Example Output
95
120
 
96
- ![Rendered OG image](static/demo.png)
121
+ ![Rendered OG image](https://github.com/etherCorps/sveltekit-og/blob/main/static/og.png)
97
122
 
98
123
  ## Headers
99
124
 
@@ -199,6 +224,7 @@ This project will not be possible without the following projects:
199
224
 
200
225
  - [Satori & @vercel/og](https://github.com/vercel/satori)
201
226
  - [Noto by Google Fonts](https://fonts.google.com/noto)
227
+ - [fineshopdesign](https://github.com/fineshopdesign/cf-wasm)
202
228
 
203
229
  ## Authors
204
230
 
@@ -1,5 +1,4 @@
1
1
  import type { Component } from 'svelte';
2
- import type { ComponentOptions, ImageOptions, VNode } from '../types.js';
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>>;
@@ -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 { render } from 'svelte/server';
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,3 @@
1
+ import type { Component } from 'svelte';
2
+ import type { ComponentOptions, VNode } from '../types.js';
3
+ export declare function createVNode(element: string | Component, componentOptions?: ComponentOptions): VNode;
@@ -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,75 +1,82 @@
1
1
  {
2
- "name": "@ethercorps/sveltekit-og",
3
- "version": "4.2.0-next.2",
4
- "scripts": {
5
- "dev": "vite dev",
6
- "build": "vite build && npm run package",
7
- "preview": "vite preview",
8
- "package": "svelte-kit sync && svelte-package && publint",
9
- "prepublishOnly": "npm run package",
10
- "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
11
- "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
12
- "test": "vitest",
13
- "lint": "prettier --plugin-search-dir . --check . && eslint .",
14
- "format": "prettier --plugin-search-dir . --write .",
15
- "publishBeta": "npm publish --tag beta"
16
- },
17
- "exports": {
18
- ".": {
19
- "types": "./dist/index.d.ts",
20
- "svelte": "./dist/index.js",
21
- "import": "./dist/index.js"
22
- },
23
- "./fonts": {
24
- "types": "./dist/fonts.d.ts",
25
- "import": "./dist/fonts.js"
26
- },
27
- "./plugin": {
28
- "types": "./dist/plugin.d.ts",
29
- "import": "./dist/plugin.js"
30
- }
31
- },
32
- "files": [
33
- "dist",
34
- "!dist/**/*.test.*",
35
- "!dist/**/*.spec.*"
36
- ],
37
- "devDependencies": {
38
- "@sveltejs/adapter-vercel": "^5.10.2",
39
- "@sveltejs/kit": "^2.48.5",
40
- "@sveltejs/package": "^2.5.4",
41
- "@sveltejs/vite-plugin-svelte": "^4.0.4",
42
- "@types/node": "^24.7.1",
43
- "@typescript-eslint/eslint-plugin": "^5.62.0",
44
- "@typescript-eslint/parser": "^5.62.0",
45
- "css-tree": "^2.3.1",
46
- "eslint": "^8.57.1",
47
- "eslint-config-prettier": "^8.10.0",
48
- "eslint-plugin-svelte": "^2.46.1",
49
- "prettier": "^3.6.2",
50
- "prettier-plugin-svelte": "^3.4.0",
51
- "publint": "^0.1.16",
52
- "rollup-plugin-visualizer": "^5.14.0",
53
- "svelte": "^5.43.12",
54
- "svelte-check": "^4.3.2",
55
- "tslib": "^2.8.1",
56
- "typescript": "^5.9.3",
57
- "vite": "^5.4.19",
58
- "vitest": "^1.6.1"
59
- },
60
- "main": "./dist/index.js",
61
- "svelte": "./dist/index.js",
62
- "types": "./dist/index.d.ts",
63
- "type": "module",
64
- "dependencies": {
65
- "@resvg/resvg-wasm": "^2.6.2",
66
- "satori": "^0.10.14",
67
- "satori-html": "0.3.2",
68
- "std-env": "^3.9.0",
69
- "unwasm": "^0.5.0"
70
- },
71
- "peerDependencies": {
72
- "@sveltejs/kit": ">=2.0.0"
73
- },
74
- "packageManager": "pnpm@10.12.1"
2
+ "name": "@ethercorps/sveltekit-og",
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",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "svelte": "./dist/index.js",
14
+ "import": "./dist/index.js"
15
+ },
16
+ "./fonts": {
17
+ "types": "./dist/fonts.d.ts",
18
+ "import": "./dist/fonts.js"
19
+ },
20
+ "./plugin": {
21
+ "types": "./dist/plugin.d.ts",
22
+ "import": "./dist/plugin.js"
23
+ }
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "!dist/**/*.test.*",
28
+ "!dist/**/*.spec.*"
29
+ ],
30
+ "devDependencies": {
31
+ "@sveltejs/adapter-vercel": "^5.10.2",
32
+ "@sveltejs/kit": "^2.48.5",
33
+ "@sveltejs/package": "^2.5.4",
34
+ "@sveltejs/vite-plugin-svelte": "^4.0.4",
35
+ "@types/node": "^24.7.1",
36
+ "@typescript-eslint/eslint-plugin": "^5.62.0",
37
+ "@typescript-eslint/parser": "^5.62.0",
38
+ "css-tree": "^2.3.1",
39
+ "eslint": "^8.57.1",
40
+ "eslint-config-prettier": "^8.10.0",
41
+ "eslint-plugin-svelte": "^2.46.1",
42
+ "prettier": "^3.6.2",
43
+ "prettier-plugin-svelte": "^3.4.0",
44
+ "publint": "^0.1.16",
45
+ "rollup-plugin-visualizer": "^5.14.0",
46
+ "svelte": "^5.43.12",
47
+ "svelte-check": "^4.3.2",
48
+ "tslib": "^2.8.1",
49
+ "typescript": "^5.9.3",
50
+ "vite": "^5.4.19",
51
+ "vitest": "^1.6.1"
52
+ },
53
+ "main": "./dist/index.js",
54
+ "svelte": "./dist/index.js",
55
+ "types": "./dist/index.d.ts",
56
+ "type": "module",
57
+ "dependencies": {
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",
62
+ "satori": "^0.10.14",
63
+ "satori-html": "0.3.2",
64
+ "std-env": "^3.9.0",
65
+ "unwasm": "^0.5.0"
66
+ },
67
+ "peerDependencies": {
68
+ "@sveltejs/kit": ">=2.0.0"
69
+ },
70
+ "scripts": {
71
+ "dev": "vite dev",
72
+ "build": "vite build && npm run package",
73
+ "preview": "vite preview",
74
+ "package": "svelte-kit sync && svelte-package && publint",
75
+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
76
+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
77
+ "test": "vitest",
78
+ "lint": "prettier --plugin-search-dir . --check . && eslint .",
79
+ "format": "prettier --plugin-search-dir . --write .",
80
+ "publishBeta": "npm publish --tag beta"
81
+ }
75
82
  }