jskelet 0.6.4 → 0.6.6
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/CHANGELOG.md +10 -0
- package/docs/04-render-ve-sablonlar.md +33 -0
- package/docs/07-yapilandirma.md +41 -0
- package/docs/08-build.md +22 -2
- package/docs/10-dagitim.md +4 -1
- package/docs/en/04-rendering.md +33 -0
- package/docs/en/07-configuration.md +41 -0
- package/docs/en/08-build.md +22 -2
- package/docs/en/10-deployment.md +4 -0
- package/package.json +1 -1
- package/src/build/chunk-groups.mjs +331 -0
- package/src/build/tasks/client.mjs +53 -6
- package/src/config/defaults.js +25 -0
- package/src/config/index.js +125 -0
- package/src/server/og-image.js +621 -25
- package/src/server/og-raster.mjs +21 -0
- package/types/config/defaults.d.ts +24 -0
- package/types/config/index.d.ts +19 -0
- package/types/server/og-image.d.ts +46 -3
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Yüzlü OG PNG'si.
|
|
3
|
+
*
|
|
4
|
+
* fontconfig `FONTCONFIG_FILE`'ı süreç açılırken okur. Üst süreçte sonradan
|
|
5
|
+
* atanan ortam değişkeni (özellikle Windows CRT `getenv`) görünmez; bu yüzden
|
|
6
|
+
* çizim, dosyayı baştan gören bu süreçte yapılır.
|
|
7
|
+
*/
|
|
8
|
+
const sharpMod = await import(process.env.JSKELET_SHARP);
|
|
9
|
+
const sharp = sharpMod.default ?? sharpMod;
|
|
10
|
+
|
|
11
|
+
/** @type {Buffer[]} */
|
|
12
|
+
const chunks = [];
|
|
13
|
+
for await (const chunk of process.stdin) chunks.push(chunk);
|
|
14
|
+
|
|
15
|
+
const width = Number(process.env.JSKELET_OG_WIDTH);
|
|
16
|
+
const height = Number(process.env.JSKELET_OG_HEIGHT);
|
|
17
|
+
const body = await sharp(Buffer.concat(chunks))
|
|
18
|
+
.resize(width, height, { fit: "fill" })
|
|
19
|
+
.png()
|
|
20
|
+
.toBuffer();
|
|
21
|
+
process.stdout.write(body);
|
|
@@ -420,6 +420,30 @@ export declare const DEFAULT_SECURITY: {
|
|
|
420
420
|
headerName: string;
|
|
421
421
|
};
|
|
422
422
|
};
|
|
423
|
+
/**
|
|
424
|
+
* Client bundle (esbuild) ayarları.
|
|
425
|
+
*
|
|
426
|
+
* `groups` / `chunkGroup` esbuild'in native manualChunks'ı olmadığı için
|
|
427
|
+
* framework plugin'i ile uygulanır — ayrıntı `src/build/chunk-groups.mjs`.
|
|
428
|
+
*/
|
|
429
|
+
export declare const DEFAULT_BUILD: {
|
|
430
|
+
client: {
|
|
431
|
+
/** esbuild `splitting`; kapalıyken gruplama yok sayılır. */
|
|
432
|
+
splitting: boolean;
|
|
433
|
+
/**
|
|
434
|
+
* İsim → matcher listesi. Bare paket (`chart.js`), yol öneki
|
|
435
|
+
* (`./client/chrome/`) veya `@/` öneki.
|
|
436
|
+
* @type {Record<string, string[]>}
|
|
437
|
+
*/
|
|
438
|
+
groups: Record<string, string[]>;
|
|
439
|
+
/**
|
|
440
|
+
* Modül kimliğini (mutlak yol veya bare specifier) grup adına map eder.
|
|
441
|
+
* `groups` ile çakışınca hook kazanır.
|
|
442
|
+
* @type {((id: string) => string | null | undefined) | null}
|
|
443
|
+
*/
|
|
444
|
+
chunkGroup: ((id: string) => string | null | undefined) | null;
|
|
445
|
+
};
|
|
446
|
+
};
|
|
423
447
|
/**
|
|
424
448
|
* Build-zamanı görsel adımı + opsiyonel runtime uzak görsel proxy.
|
|
425
449
|
*
|
package/types/config/index.d.ts
CHANGED
|
@@ -220,6 +220,18 @@ export type ResolvedConfig = {
|
|
|
220
220
|
* Client bundle'a gömülecek env anahtarları.
|
|
221
221
|
*/
|
|
222
222
|
clientEnv: string[];
|
|
223
|
+
/**
|
|
224
|
+
* Client bundling (esbuild splitting / chunk groups).
|
|
225
|
+
*/
|
|
226
|
+
build: BuildConfig;
|
|
227
|
+
};
|
|
228
|
+
export type BuildClientConfig = {
|
|
229
|
+
splitting: boolean;
|
|
230
|
+
groups: Record<string, string[]>;
|
|
231
|
+
chunkGroup: ((id: string) => string | null | undefined) | null;
|
|
232
|
+
};
|
|
233
|
+
export type BuildConfig = {
|
|
234
|
+
client: BuildClientConfig;
|
|
223
235
|
};
|
|
224
236
|
export type ImagesRemoteConfig = {
|
|
225
237
|
enabled: boolean;
|
|
@@ -279,6 +291,13 @@ export type SecurityConfig = {
|
|
|
279
291
|
headerName: string;
|
|
280
292
|
};
|
|
281
293
|
};
|
|
294
|
+
/**
|
|
295
|
+
* Client build ayarları (`build.client`). Bozuk tipler uyarıyla varsayılana düşer.
|
|
296
|
+
*
|
|
297
|
+
* @param {unknown} raw
|
|
298
|
+
* @returns {BuildConfig}
|
|
299
|
+
*/
|
|
300
|
+
export declare function normalizeBuild(raw: unknown): BuildConfig;
|
|
282
301
|
/**
|
|
283
302
|
* Config'i okur, normalize eder ve modül durumuna yazar. Sunucu ve build
|
|
284
303
|
* süreçleri açılışta bir kez çağırır.
|
|
@@ -24,12 +24,31 @@ export type OgCardOptions = {
|
|
|
24
24
|
*/
|
|
25
25
|
accent?: string;
|
|
26
26
|
};
|
|
27
|
+
export type OgFontFace = {
|
|
28
|
+
/**
|
|
29
|
+
* Font dosyası. PNG için `ttf` veya `otf`
|
|
30
|
+
* (librsvg `woff` / `woff2` dosyasından kare basar). Uygulama köküne
|
|
31
|
+
* göreli ya da mutlak.
|
|
32
|
+
*/
|
|
33
|
+
path: string;
|
|
34
|
+
/**
|
|
35
|
+
* SVG `font-family` adı. Dosyanın içindeki adla
|
|
36
|
+
* aynı olmak zorunda değil.
|
|
37
|
+
*/
|
|
38
|
+
family: string;
|
|
39
|
+
/**
|
|
40
|
+
* Tek ağırlık (`700`) ya da aralık (`"100 900"`).
|
|
41
|
+
*/
|
|
42
|
+
weight?: number | string;
|
|
43
|
+
style?: 'normal' | 'italic' | 'oblique';
|
|
44
|
+
};
|
|
27
45
|
export type OgImageOptions = OgCardOptions & {
|
|
28
46
|
svg?: string;
|
|
29
47
|
width?: number;
|
|
30
48
|
height?: number;
|
|
31
49
|
format?: 'png' | 'svg';
|
|
32
50
|
cacheControl?: string;
|
|
51
|
+
fonts?: OgFontFace[];
|
|
33
52
|
};
|
|
34
53
|
export type OgImageResult = {
|
|
35
54
|
body: Buffer;
|
|
@@ -47,6 +66,19 @@ export type OgImageResult = {
|
|
|
47
66
|
* @property {string} [mutedColor] Açıklama / site adı
|
|
48
67
|
* @property {string} [accent] Sol şerit rengi
|
|
49
68
|
*/
|
|
69
|
+
/**
|
|
70
|
+
* OG metnine gömülen yüz. `path` + `family` yeter. PNG, dosyanın içindeki
|
|
71
|
+
* ağırlığı kullanır; `weight` yalnızca SVG yanıtındaki `@font-face` içindir.
|
|
72
|
+
*
|
|
73
|
+
* @typedef {object} OgFontFace
|
|
74
|
+
* @property {string} path Font dosyası. PNG için `ttf` veya `otf`
|
|
75
|
+
* (librsvg `woff` / `woff2` dosyasından kare basar). Uygulama köküne
|
|
76
|
+
* göreli ya da mutlak.
|
|
77
|
+
* @property {string} family SVG `font-family` adı. Dosyanın içindeki adla
|
|
78
|
+
* aynı olmak zorunda değil.
|
|
79
|
+
* @property {number | string} [weight] Tek ağırlık (`700`) ya da aralık (`"100 900"`).
|
|
80
|
+
* @property {'normal' | 'italic' | 'oblique'} [style]
|
|
81
|
+
*/
|
|
50
82
|
/**
|
|
51
83
|
* @typedef {OgCardOptions & {
|
|
52
84
|
* svg?: string,
|
|
@@ -54,6 +86,7 @@ export type OgImageResult = {
|
|
|
54
86
|
* height?: number,
|
|
55
87
|
* format?: 'png' | 'svg',
|
|
56
88
|
* cacheControl?: string,
|
|
89
|
+
* fonts?: OgFontFace[],
|
|
57
90
|
* }} OgImageOptions
|
|
58
91
|
*/
|
|
59
92
|
/**
|
|
@@ -79,15 +112,23 @@ export declare function escapeXml(value: unknown): string;
|
|
|
79
112
|
export declare function wrapText(text: string, maxChars: number, maxLines: number): string[];
|
|
80
113
|
/**
|
|
81
114
|
* Hazır kart SVG'si. Uygulama kendi SVG'sini vermek isterse `svg` kullanır.
|
|
82
|
-
* @param {OgCardOptions & { width?: number, height?: number }} options
|
|
115
|
+
* @param {OgCardOptions & { width?: number, height?: number, fontFamily?: string }} options
|
|
83
116
|
* @returns {string}
|
|
84
117
|
*/
|
|
85
118
|
export declare function buildOgSvg(options?: OgCardOptions & {
|
|
86
119
|
width?: number;
|
|
87
120
|
height?: number;
|
|
121
|
+
fontFamily?: string;
|
|
88
122
|
}): string;
|
|
89
123
|
/**
|
|
90
124
|
* SVG veya kart alanlarından PNG/SVG gövde üretir.
|
|
125
|
+
*
|
|
126
|
+
* PNG'de `ttf` / `otf` fontconfig'e eklenir ve kart bu `family` adlarını
|
|
127
|
+
* kullanır. `woff` / `woff2` yalnızca sharp yokken (ya da `format: "svg"`)
|
|
128
|
+
* `@font-face` olarak gömülür; librsvg onlardan kare basar. Dosya okunamazsa
|
|
129
|
+
* görsel yine üretilir, o yüz atlanır. Çalışma imajında `fontconfig` paketi
|
|
130
|
+
* gerekir.
|
|
131
|
+
*
|
|
91
132
|
* @param {OgImageOptions} [options]
|
|
92
133
|
* @returns {Promise<OgImageResult>}
|
|
93
134
|
*/
|
|
@@ -135,10 +176,12 @@ export declare function ogHandler(factory: (ctx: {
|
|
|
135
176
|
export declare class ImageResponse {
|
|
136
177
|
#private;
|
|
137
178
|
/**
|
|
138
|
-
* @param {string | OgCardOptions} element
|
|
179
|
+
* @param {string | (OgCardOptions & { fonts?: OgFontFace[] })} element
|
|
139
180
|
* @param {Omit<OgImageOptions, keyof OgCardOptions | 'svg'> & { width?: number, height?: number }} [init]
|
|
140
181
|
*/
|
|
141
|
-
constructor(element: string | OgCardOptions
|
|
182
|
+
constructor(element: string | (OgCardOptions & {
|
|
183
|
+
fonts?: OgFontFace[];
|
|
184
|
+
}), init?: Omit<OgImageOptions, keyof OgCardOptions | 'svg'> & {
|
|
142
185
|
width?: number;
|
|
143
186
|
height?: number;
|
|
144
187
|
});
|