@ethercorps/sveltekit-og 4.2.1 → 4.3.1-next.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/dist/fonts.d.ts CHANGED
@@ -17,18 +17,10 @@ export declare class BaseFont {
17
17
  */
18
18
  get data(): MayBePromise<Buffer | ArrayBuffer>;
19
19
  }
20
- /** * A helper class to load Custom fonts, typically from local files.
21
- * The input must be a function provided by the user (e.g., using $app/server/read).
22
- */
23
20
  export declare class CustomFont extends BaseFont {
24
21
  private promise?;
25
- /**
26
- * Creates an instance of CustomFont.
27
- * @param name The name of the font (for CSS font-family).
28
- * @param input Font data as ArrayBuffer or a function that resolves to ArrayBuffer (user must provide the loading logic).
29
- */
30
22
  constructor(name: string, input: MayBePromise<Buffer | ArrayBuffer> | (() => MayBePromise<Buffer | ArrayBuffer>), options?: BaseFontOptions);
31
- /** A promise which resolves to font data as `ArrayBuffer` (Lazy load) */
23
+ /** A promise which resolves to font data as `ArrayBuffer` (Lazy load and CACHED) */
32
24
  get data(): Promise<Buffer | ArrayBuffer>;
33
25
  }
34
26
  /** Loads Google font ArrayBuffer with caching. */
package/dist/fonts.js CHANGED
@@ -20,24 +20,24 @@ export class BaseFont {
20
20
  return this.input;
21
21
  }
22
22
  }
23
- /** * A helper class to load Custom fonts, typically from local files.
24
- * The input must be a function provided by the user (e.g., using $app/server/read).
25
- */
26
23
  export class CustomFont extends BaseFont {
27
24
  promise;
28
- /**
29
- * Creates an instance of CustomFont.
30
- * @param name The name of the font (for CSS font-family).
31
- * @param input Font data as ArrayBuffer or a function that resolves to ArrayBuffer (user must provide the loading logic).
32
- */
33
25
  constructor(name, input, options) {
34
26
  super(name, input, options);
35
27
  }
36
- /** A promise which resolves to font data as `ArrayBuffer` (Lazy load) */
28
+ /** A promise which resolves to font data as `ArrayBuffer` (Lazy load and CACHED) */
37
29
  get data() {
38
- // Defines the loading mechanism: execute the input function or resolve the promise/buffer.
39
- const fallback = async () => (typeof this.input === 'function' ? this.input() : this.input);
40
- // Memoization: ensures the input function is executed only once.
30
+ const cacheKey = `${this.name}-${this.weight}-${this.style}`;
31
+ const cachedData = FONT_CACHE_MAP.get(cacheKey);
32
+ if (cachedData) {
33
+ return Promise.resolve(cachedData);
34
+ }
35
+ const fallback = async () => {
36
+ const buffer = typeof this.input === 'function' ? this.input() : this.input;
37
+ const resolvedBuffer = await buffer;
38
+ FONT_CACHE_MAP.set(cacheKey, resolvedBuffer);
39
+ return resolvedBuffer;
40
+ };
41
41
  this.promise = this.promise?.then(null, fallback) ?? fallback();
42
42
  return this.promise;
43
43
  }
package/dist/plugin.js CHANGED
@@ -13,8 +13,8 @@ export function sveltekitOG(options) {
13
13
  return {
14
14
  build: {
15
15
  rollupOptions: {
16
- plugins: [rollupWasm(options)]
17
- }
16
+ plugins: [rollupWasm(options)],
17
+ },
18
18
  }
19
19
  };
20
20
  }
@@ -3,6 +3,6 @@ import { Resvg as _Resvg, initWasm } from '@resvg/resvg-wasm'
3
3
  export default {
4
4
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
5
5
  // @ts-ignore
6
- initWasmPromise: initWasm(import('./resvg.wasm?module').then(r => r.default || r)),
6
+ initWasmPromise: initWasm(import('@resvg/resvg-wasm/index_bg.wasm').then(r => r.default || r)),
7
7
  Resvg: _Resvg,
8
8
  }
package/package.json CHANGED
@@ -1,82 +1,81 @@
1
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
- }
2
+ "name": "@ethercorps/sveltekit-og",
3
+ "version": "4.3.1-next.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
+ "scripts": {
11
+ "dev": "vite dev",
12
+ "build": "vite build && npm run package",
13
+ "preview": "vite preview",
14
+ "package": "svelte-kit sync && svelte-package && publint",
15
+ "prepublishOnly": "npm run package",
16
+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
17
+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
18
+ "test": "vitest",
19
+ "lint": "prettier --plugin-search-dir . --check . && eslint .",
20
+ "format": "prettier --plugin-search-dir . --write .",
21
+ "publishBeta": "npm publish --tag beta"
22
+ },
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "svelte": "./dist/index.js",
27
+ "import": "./dist/index.js"
28
+ },
29
+ "./fonts": {
30
+ "types": "./dist/fonts.d.ts",
31
+ "import": "./dist/fonts.js"
32
+ },
33
+ "./plugin": {
34
+ "types": "./dist/plugin.d.ts",
35
+ "import": "./dist/plugin.js"
36
+ }
37
+ },
38
+ "files": [
39
+ "dist",
40
+ "!dist/**/*.test.*",
41
+ "!dist/**/*.spec.*"
42
+ ],
43
+ "devDependencies": {
44
+ "@sveltejs/adapter-vercel": "^5.10.2",
45
+ "@sveltejs/kit": "^2.48.5",
46
+ "@sveltejs/package": "^2.5.4",
47
+ "@sveltejs/vite-plugin-svelte": "^4.0.4",
48
+ "@types/node": "^24.7.1",
49
+ "@typescript-eslint/eslint-plugin": "^5.62.0",
50
+ "@typescript-eslint/parser": "^5.62.0",
51
+ "css-tree": "^2.3.1",
52
+ "eslint": "^8.57.1",
53
+ "eslint-config-prettier": "^8.10.0",
54
+ "eslint-plugin-svelte": "^2.46.1",
55
+ "prettier": "^3.6.2",
56
+ "prettier-plugin-svelte": "^3.4.0",
57
+ "publint": "^0.1.16",
58
+ "rollup-plugin-visualizer": "^5.14.0",
59
+ "svelte": "^5.43.12",
60
+ "svelte-check": "^4.3.2",
61
+ "tslib": "^2.8.1",
62
+ "typescript": "^5.9.3",
63
+ "vite": "^5.4.19",
64
+ "vitest": "^1.6.1"
65
+ },
66
+ "main": "./dist/index.js",
67
+ "svelte": "./dist/index.js",
68
+ "types": "./dist/index.d.ts",
69
+ "type": "module",
70
+ "dependencies": {
71
+ "@resvg/resvg-wasm": "^2.6.2",
72
+ "satori": "^0.10.14",
73
+ "satori-html": "0.3.2",
74
+ "std-env": "^3.9.0",
75
+ "unwasm": "^0.5.0"
76
+ },
77
+ "peerDependencies": {
78
+ "@sveltejs/kit": ">=2.0.0"
79
+ },
80
+ "packageManager": "pnpm@10.12.1"
82
81
  }