@savvy-web/bundler 2.4.23 → 2.5.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.
- package/index.d.ts +2 -2
- package/og.d.ts +6 -2
- package/og.js +24 -2
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AmbientDtsEntry, BuildFormat, BuildPlatform, BuildReport, BuildTargetGroupsOptions, CssOptions, ExeConfig, GenerateMetaOptions, Json, JsxConfig, LooseFiles, MetaOptions, MetaResult, NextVersions, OgImageInfo, PublishTargets, RenderedOutput, RunExeBuildOptions, TargetGroupRef, TargetResolution, TsconfigJsx, TsdoctorMetaOptions, defaultManifestTransform, extractAmbientDts } from "@savvy-web/tsdown-plugins";
|
|
1
|
+
import { AmbientDtsEntry, BuildFormat, BuildPlatform, BuildReport, BuildTargetGroupsOptions, CssOptions, ExeConfig, GenerateMetaOptions, Json, JsxConfig, LooseFiles, MetaOptions, MetaResult, NextVersions, OgImageGenerator, OgImageInfo, PublishTargets, RenderedOutput, RunExeBuildOptions, TargetGroupRef, TargetResolution, TsconfigJsx, TsdoctorMetaOptions, defaultManifestTransform, extractAmbientDts } from "@savvy-web/tsdown-plugins";
|
|
2
2
|
import { Plugin, Plugin as Plugin$1 } from "rolldown";
|
|
3
3
|
//#region src/config.d.ts
|
|
4
4
|
/** @public */
|
|
@@ -290,5 +290,5 @@ export declare function runBuild(config: BuildConfig, options: RunOptions): Prom
|
|
|
290
290
|
*/
|
|
291
291
|
export declare function build(input?: BuildConfigInput, overrides?: Partial<RunOptions>): Promise<void>;
|
|
292
292
|
//#endregion
|
|
293
|
-
export { type AmbientDtsEntry, type BuildConfig, type BuildConfigInput, type BuildEntryOverride, type OgImageInfo, type OutputConfig, type ParsedArgs, type Plugin, type RunOptions, type TsdoctorMetaOptions, defaultManifestTransform, extractAmbientDts };
|
|
293
|
+
export { type AmbientDtsEntry, type BuildConfig, type BuildConfigInput, type BuildEntryOverride, type OgImageGenerator, type OgImageInfo, type OutputConfig, type ParsedArgs, type Plugin, type RunOptions, type TsdoctorMetaOptions, defaultManifestTransform, extractAmbientDts };
|
|
294
294
|
//# sourceMappingURL=index.d.ts.map
|
package/og.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OgImageGenerator } from "@savvy-web/tsdown-plugins";
|
|
2
2
|
//#region src/og.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Colors for the default Open Graph card.
|
|
@@ -19,6 +19,10 @@ export interface SatoriOgOptions {
|
|
|
19
19
|
* 1200×630 PNG, rendered through the optional peers `satori` and `@resvg/resvg-js`. The peers
|
|
20
20
|
* load lazily on first render, so a build that does not generate an image never needs them.
|
|
21
21
|
*
|
|
22
|
+
* The returned generator carries a `cacheSalt` (this package's version, the peers' versions and
|
|
23
|
+
* the colors), so its renders are cached across builds by default; `openGraph.cacheSalt: false`
|
|
24
|
+
* turns that off.
|
|
25
|
+
*
|
|
22
26
|
* @example
|
|
23
27
|
* ```ts
|
|
24
28
|
* import { defineBuild } from "@savvy-web/bundler";
|
|
@@ -32,7 +36,7 @@ export interface SatoriOgOptions {
|
|
|
32
36
|
* @public
|
|
33
37
|
*/
|
|
34
38
|
export declare const ogImage: {
|
|
35
|
-
satori(options?: SatoriOgOptions):
|
|
39
|
+
satori(options?: SatoriOgOptions): OgImageGenerator;
|
|
36
40
|
};
|
|
37
41
|
//#endregion
|
|
38
42
|
//# sourceMappingURL=og.d.ts.map
|
package/og.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
3
|
import { readFile } from "node:fs/promises";
|
|
3
4
|
import { fileURLToPath } from "node:url";
|
|
4
5
|
|
|
@@ -16,6 +17,15 @@ function fontPath() {
|
|
|
16
17
|
}
|
|
17
18
|
throw new Error("ogImage.satori() could not locate its bundled font assets/Inter-SemiBold.ttf");
|
|
18
19
|
}
|
|
20
|
+
/** The installed version of an optional renderer peer, or `"absent"` (rendering then fails, and nothing is cached). */
|
|
21
|
+
function peerVersion(name) {
|
|
22
|
+
try {
|
|
23
|
+
const manifest = createRequire(import.meta.url).resolve(`${name}/package.json`);
|
|
24
|
+
return JSON.parse(readFileSync(manifest, "utf-8")).version ?? "unknown";
|
|
25
|
+
} catch {
|
|
26
|
+
return "absent";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
19
29
|
async function loadRenderers() {
|
|
20
30
|
try {
|
|
21
31
|
const [{ default: satori }, { Resvg }] = await Promise.all([import("satori"), import("@resvg/resvg-js")]);
|
|
@@ -87,6 +97,10 @@ function card(info, colors) {
|
|
|
87
97
|
* 1200×630 PNG, rendered through the optional peers `satori` and `@resvg/resvg-js`. The peers
|
|
88
98
|
* load lazily on first render, so a build that does not generate an image never needs them.
|
|
89
99
|
*
|
|
100
|
+
* The returned generator carries a `cacheSalt` (this package's version, the peers' versions and
|
|
101
|
+
* the colors), so its renders are cached across builds by default; `openGraph.cacheSalt: false`
|
|
102
|
+
* turns that off.
|
|
103
|
+
*
|
|
90
104
|
* @example
|
|
91
105
|
* ```ts
|
|
92
106
|
* import { defineBuild } from "@savvy-web/bundler";
|
|
@@ -105,7 +119,14 @@ const ogImage = { satori(options = {}) {
|
|
|
105
119
|
background: options.background ?? "#0f172a",
|
|
106
120
|
foreground: options.foreground ?? "#f8fafc"
|
|
107
121
|
};
|
|
108
|
-
|
|
122
|
+
const cacheSalt = JSON.stringify({
|
|
123
|
+
renderer: "@savvy-web/bundler/og#satori",
|
|
124
|
+
version: "2.5.0",
|
|
125
|
+
satori: peerVersion("satori"),
|
|
126
|
+
resvg: peerVersion("@resvg/resvg-js"),
|
|
127
|
+
colors
|
|
128
|
+
});
|
|
129
|
+
const render = async (info) => {
|
|
109
130
|
const { satori, Resvg } = await loadRenderers();
|
|
110
131
|
const font = await readFile(fontPath());
|
|
111
132
|
const svg = await satori(card(info, colors), {
|
|
@@ -123,6 +144,7 @@ const ogImage = { satori(options = {}) {
|
|
|
123
144
|
value: 1200
|
|
124
145
|
} }).render().asPng());
|
|
125
146
|
};
|
|
147
|
+
return Object.assign(render, { cacheSalt });
|
|
126
148
|
} };
|
|
127
149
|
|
|
128
150
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@savvy-web/bundler",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Zero-config tsdown-based bundler for Silk Suite TypeScript packages",
|
|
6
6
|
"homepage": "https://github.com/savvy-web/systems/tree/main/packages/bundler",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"./package.json": "./package.json"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@savvy-web/tsdown-plugins": "2.
|
|
40
|
+
"@savvy-web/tsdown-plugins": "2.9.0",
|
|
41
41
|
"@tsdown/exe": "^0.23.0",
|
|
42
42
|
"effect": "^4.0.2",
|
|
43
43
|
"rolldown": "^1.2.12",
|