@dirwell/share-image 0.0.1-alpha → 0.0.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/README.md +34 -1
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -1,7 +1,38 @@
|
|
|
1
1
|
# @dirwell/share-image
|
|
2
2
|
|
|
3
|
+
Requires Node.js 22.12 or later. [Read the guide](https://vp-tw.github.io/dirwell/metadata/).
|
|
4
|
+
|
|
3
5
|
Optional build-time metadata and 1200 × 630 PNG images. Install this package only when share metadata or image rendering is needed. Core, Plain and the rich themes do not depend on it.
|
|
4
6
|
|
|
7
|
+
## Save a share image
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @dirwell/share-image@0.0.1
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Save this as `image.mjs`, then run `node image.mjs`:
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import { writeFile } from "node:fs/promises";
|
|
17
|
+
import { createShareImage } from "@dirwell/share-image";
|
|
18
|
+
const image = await createShareImage({
|
|
19
|
+
theme: "plain",
|
|
20
|
+
title: "Sample downloads",
|
|
21
|
+
description: "Release files and reports",
|
|
22
|
+
});
|
|
23
|
+
await writeFile("share.png", new Uint8Array(await image.arrayBuffer()));
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The result is a local 1200 × 630 PNG. No explorer build or browser runtime is required.
|
|
27
|
+
|
|
28
|
+
## Add metadata to an explorer
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
npm install @dirwell/core@0.0.1 @dirwell/theme-plain@0.0.1 @dirwell/share-image@0.0.1
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Create `files/note.txt`, save the following as `build.mjs` and run `node build.mjs`. Serve the complete `public/downloads` folder over HTTP; its pages reference the generated metadata/image assets.
|
|
35
|
+
|
|
5
36
|
```js
|
|
6
37
|
import { generateExplorer } from "@dirwell/core";
|
|
7
38
|
import { createPlainTheme } from "@dirwell/theme-plain";
|
|
@@ -20,4 +51,6 @@ await generateExplorer({
|
|
|
20
51
|
|
|
21
52
|
Omit `imageTheme` for text-only metadata. `image: false` disables any preset; a local File/path/file URL or async callback supplies a custom image. `createShareImage({ theme, title, description })` returns a PNG File. Rendering is lazy, uses bundled Adobe fonts without network/system-font lookup, and retains at most 32 rendered PNGs per process. The existing renderer requires bundled glyph coverage; unsupported text fails instead of silently emitting missing glyphs. Use a custom renderer for other scripts. Per-build image loading is deduplicated; image output paths are validated and conflicting bytes are rejected.
|
|
22
53
|
|
|
23
|
-
This is a static-build provider. No server image route or runtime image service is implied.
|
|
54
|
+
This is a static-build provider. No server image route or runtime image service is implied.
|
|
55
|
+
|
|
56
|
+
The 0.0.x API may evolve. Pin your qualified version and upgrade the official family together. See [support and verification](https://vp-tw.github.io/dirwell/support/) for host, browser and device boundaries.
|
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dirwell/share-image",
|
|
3
|
-
"version": "0.0.1
|
|
3
|
+
"version": "0.0.1",
|
|
4
4
|
"description": "Optional build-time metadata and PNG share-image rendering.",
|
|
5
|
+
"homepage": "https://vp-tw.github.io/dirwell/metadata/",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/vp-tw/dirwell/issues"
|
|
8
|
+
},
|
|
5
9
|
"license": "MIT",
|
|
6
10
|
"repository": {
|
|
7
11
|
"type": "git",
|
|
@@ -24,10 +28,10 @@
|
|
|
24
28
|
"publishConfig": {
|
|
25
29
|
"access": "public",
|
|
26
30
|
"provenance": true,
|
|
27
|
-
"tag": "
|
|
31
|
+
"tag": "latest"
|
|
28
32
|
},
|
|
29
33
|
"dependencies": {
|
|
30
|
-
"@dirwell/core": "0.0.1
|
|
34
|
+
"@dirwell/core": "0.0.1",
|
|
31
35
|
"@resvg/resvg-js": "2.6.2",
|
|
32
36
|
"fontkit": "2.0.4"
|
|
33
37
|
},
|