jskelet 0.7.3 → 0.7.5
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/03-routing.md +1 -1
- package/docs/04-render-ve-sablonlar.md +11 -8
- package/docs/06-cache.md +35 -16
- package/docs/07-yapilandirma.md +10 -8
- package/docs/08-build.md +12 -6
- package/docs/en/03-routing.md +1 -1
- package/docs/en/04-rendering.md +8 -4
- package/docs/en/06-caching.md +34 -16
- package/docs/en/07-configuration.md +7 -4
- package/docs/en/08-build.md +13 -6
- package/package.json +1 -1
- package/src/build/tasks/css.mjs +11 -7
- package/src/client/admin/i18n.js +4 -0
- package/src/client/admin/panel.js +8 -2
- package/src/config/defaults.js +10 -2
- package/src/config/index.js +7 -1
- package/src/server/html-cache.js +90 -35
- package/src/server/redis.js +332 -10
- package/src/views/helpers/tags.js +12 -7
- package/types/config/defaults.d.ts +10 -2
- package/types/config/index.d.ts +7 -0
- package/types/server/dev/report.d.ts +2 -0
- package/types/server/redis.d.ts +43 -3
- package/types/views/helpers/tags.d.ts +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,13 @@ one is listed under a **Breaking** heading.
|
|
|
10
10
|
|
|
11
11
|
### Changed
|
|
12
12
|
|
|
13
|
+
- Page stylesheets are built as one asset containing global CSS followed by
|
|
14
|
+
page CSS. Routes that declare `styles` load the combined asset instead of
|
|
15
|
+
applying `app.css` and page utilities in separate cascade steps, preventing
|
|
16
|
+
the intermediate layout shifts that occur when those sheets arrive apart.
|
|
17
|
+
- Redis HTML is stored as a small JSON meta key, a raw brotli `:body` key, and
|
|
18
|
+
optional `:enc:br` / `:enc:gzip` keys on a second connection. HTML command
|
|
19
|
+
timeouts use their own circuit breaker and no longer bypass the data cache.
|
|
13
20
|
- `.jsk` codegen merges adjacent static HTML into fewer `+=` ops and drops
|
|
14
21
|
template indentation (newline-only whitespace). A lone space between
|
|
15
22
|
inline siblings is kept; `pre` / `textarea` / `script` / `style` / `code`
|
|
@@ -73,6 +80,9 @@ one is listed under a **Breaking** heading.
|
|
|
73
80
|
|
|
74
81
|
### Added
|
|
75
82
|
|
|
83
|
+
- `cache().redis.htmlCommandTimeoutMs` (default `2000`) limits only the HTML
|
|
84
|
+
Redis connection. `commandTimeoutMs` stays `200` for data, publish, and scan.
|
|
85
|
+
The admin Redis card shows both timeouts.
|
|
76
86
|
- `stylesheets({ blocking: false })` and `<Stylesheets :blocking="false" />`
|
|
77
87
|
emit each stylesheet with `media="print"` and an `onload` that switches it
|
|
78
88
|
to `all`, plus a `<noscript>` fallback, so the links do not block rendering.
|
package/docs/03-routing.md
CHANGED
|
@@ -219,7 +219,7 @@ Controller `async (ctx) => sayfa` biçimindedir ve şu alanları döndürebilir:
|
|
|
219
219
|
| `head` | `string` | `""` | `<head>`e olduğu gibi basılacak ham HTML (ör. LCP preload'ı). |
|
|
220
220
|
| `bodyClass` | `string` | `hooks.layoutContext().bodyClass ?? ""` | `<body class="…">`. |
|
|
221
221
|
| `entries` | `string[]` | `[]` | Bu sayfada ek olarak yüklenecek client entry adları: `["chart.js"]`. |
|
|
222
|
-
| `styles` | `string[]` | `[]` |
|
|
222
|
+
| `styles` | `string[]` | `[]` | Global CSS ile birleştirilip `app.css` yerine yüklenecek sayfa stylesheet adları: `["home.css"]` → `styles/pages/home.css`. |
|
|
223
223
|
|
|
224
224
|
`revalidate` **`route()`'un ikinci argümanıdır**, controller'ın döndürdüğü
|
|
225
225
|
nesnenin alanı değil.
|
|
@@ -182,12 +182,12 @@ Dikkat edilecek noktalar:
|
|
|
182
182
|
- **`extraHead` en başta.** Kaynak ipuçlarını (`preconnect`, LCP `preload`)
|
|
183
183
|
geciktirmek doğrudan LCP'ye yazılır.
|
|
184
184
|
- **Global `app.css` varsayılan olarak render-blocking** ve gerekçesi
|
|
185
|
-
[02-mimari.md](./02-mimari.md)'de. Controller `styles: [...]`
|
|
186
|
-
sheet'
|
|
187
|
-
(`stylesheets({ blocking: false })`)
|
|
188
|
-
ile basar; JS kapalıyken `<noscript>` yedeği
|
|
189
|
-
sheet gelince düzen kayabilir. Build çalışmadıysa
|
|
190
|
-
ve etiket hiç basılmaz.
|
|
185
|
+
[02-mimari.md](./02-mimari.md)'de. Controller `styles: [...]` verirse sayfa
|
|
186
|
+
sheet'i global CSS'i de içeren birleşik varlıktır ve `app.css` yerine basılır.
|
|
187
|
+
`<Stylesheets :blocking="false" />` (`stylesheets({ blocking: false })`)
|
|
188
|
+
linki `media="print"` + `onload` ile basar; JS kapalıyken `<noscript>` yedeği
|
|
189
|
+
uygulanır. Boyama beklenmez, sheet gelince düzen kayabilir. Build çalışmadıysa
|
|
190
|
+
`hasAsset` false olur ve etiket hiç basılmaz.
|
|
191
191
|
- **`hasAsset` kontrolleri** build eksikken sayfanın 404 veren dosyaları
|
|
192
192
|
istememesini sağlar (`Stylesheets` / `BodyScripts` içinde).
|
|
193
193
|
- **Devtools script'i** yalnızca `NODE_ENV=development` iken basılır; prod
|
|
@@ -437,7 +437,8 @@ icon({ name: "ArrowRight", weight: "bold", size: 20, class: "text-slate-500" });
|
|
|
437
437
|
|
|
438
438
|
### `stylesheets(props)`
|
|
439
439
|
|
|
440
|
-
Layout `<head>` içindeki global `app.css`
|
|
440
|
+
Layout `<head>` içindeki global `app.css` veya controller `styles` dizisindeki
|
|
441
|
+
birleşik sayfa sheet'leri.
|
|
441
442
|
Doğrudan çağırmak yerine yerleşik etiket kullanılır:
|
|
442
443
|
|
|
443
444
|
```jsk
|
|
@@ -451,7 +452,9 @@ stylesheets({ styles: ["home.css"], blocking: false });
|
|
|
451
452
|
```
|
|
452
453
|
|
|
453
454
|
- `styles` manifest anahtarlarıdır (`"home.css"` → `styles/pages/home.css`).
|
|
454
|
-
`
|
|
455
|
+
Geçerli en az bir sayfa sheet'i varsa `app.css` ayrıca basılmaz; her sayfa
|
|
456
|
+
çıktısı global CSS'i zaten içerir. Hiçbiri manifest'te yoksa `app.css`e
|
|
457
|
+
dönülür.
|
|
455
458
|
- `blocking` varsayılan `true`: `<link rel="stylesheet" data-jskelet-css="…">`.
|
|
456
459
|
Yalnızca boolean `false` beklemeyi kapatır. Çıktı `media="print"` ve
|
|
457
460
|
`onload="this.media='all'"` olur; eşleşmeyen media boyamayı bekletmez.
|
package/docs/06-cache.md
CHANGED
|
@@ -831,9 +831,11 @@ npm install ioredis
|
|
|
831
831
|
```
|
|
832
832
|
|
|
833
833
|
Kurulmadıysa ya da Redis'e bağlanılamıyorsa uyarı basılır ve site **bellek içi
|
|
834
|
-
önbellekle çalışmaya devam eder**. Redis çalışırken düşerse aynı şey olur:
|
|
835
|
-
|
|
836
|
-
her istek ağ zaman aşımı beklemez.
|
|
834
|
+
önbellekle çalışmaya devam eder**. Redis çalışırken düşerse aynı şey olur:
|
|
835
|
+
veri ve HTML için ayrı devre kesiciler vardır. Art arda beş hata ilgili
|
|
836
|
+
katmanı beş saniye baypas eder, böylece her istek ağ zaman aşımı beklemez.
|
|
837
|
+
HTML zaman aşımı veri sayacına yazılmaz; yavaş bir sayfa küçük veri
|
|
838
|
+
anahtarlarını kapatmaz.
|
|
837
839
|
|
|
838
840
|
### Ne kazanırsınız
|
|
839
841
|
|
|
@@ -852,6 +854,8 @@ her istek ağ zaman aşımı beklemez.
|
|
|
852
854
|
|
|
853
855
|
```
|
|
854
856
|
_jskelet:{namespace}:{buildId}:html:{vary|}{yol}?{query}
|
|
857
|
+
_jskelet:{namespace}:{buildId}:html:{vary|}{yol}?{query}:body
|
|
858
|
+
_jskelet:{namespace}:{buildId}:html:{vary|}{yol}?{query}:enc:{br|gzip}
|
|
855
859
|
_jskelet:{namespace}:{buildId}:data:{anahtar}
|
|
856
860
|
_jskelet:{namespace}:events
|
|
857
861
|
```
|
|
@@ -867,12 +871,25 @@ anahtarlar TTL ile ölür — elle temizlik ya da `FLUSHDB` gerekmez. Build
|
|
|
867
871
|
bilinçli olarak `buildId` **taşımaz**: deploy sırasında eski ve yeni sürüm yan
|
|
868
872
|
yana koşuyor ve bir purge ikisine de ulaşmalı.
|
|
869
873
|
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
874
|
+
HTML üç parçaya yazılır. Meta anahtarı küçük bir JSON'dur (`status`,
|
|
875
|
+
`storedAt`, `expiresAt`, `staleUntil`, `produceMs`, `deps`) ve gövde içermez.
|
|
876
|
+
`:body` HTML'in brotli baytıdır; base64 yoktur ve bu bayt bir JSON'un içine
|
|
877
|
+
ikinci kez sıkıştırılmaz. `storeEncoded` açıksa yanıt için üretilmiş brotli
|
|
878
|
+
veya gzip gövdesi `:enc:br` / `:enc:gzip` anahtarına olduğu gibi yazılır.
|
|
879
|
+
Okuma meta ile gövdeyi tek pipeline'da ister; parçalardan biri yoksa kayıt yok
|
|
880
|
+
sayılır ve sayfa render edilir.
|
|
881
|
+
|
|
882
|
+
Veri girdileri 1 KB ve üstünde düz JSON olarak durmaz: `JSK\x01` önekli brotli
|
|
883
|
+
gövde yazılır (kalite 5, metin modu — yanıt sıkıştırmasıyla aynı ayar). Daha
|
|
884
|
+
küçük veri kayıtları düz JSON kalır. HTML bu sarmalayıcıyı kullanmaz. zstd
|
|
885
|
+
kullanılmaz: `node:zlib` içindeki zstd 22.15'ten itibaren var, motor ise
|
|
886
|
+
`>=22`.
|
|
887
|
+
|
|
888
|
+
`commandTimeoutMs` (varsayılan 200) veri, yayın ve `SCAN` komutlarına
|
|
889
|
+
uygulanır. HTML okuma ve yazma ayrı bir bağlantıdadır; `htmlCommandTimeoutMs`
|
|
890
|
+
(varsayılan 2000) yalnız o bağlantının komutlarını sınırlar. ioredis zaman
|
|
891
|
+
aşımı istemci genelinde olduğu için iki süre tek bağlantıda ayrılamaz.
|
|
892
|
+
Uygulama bu alanı vermezse framework 2000 kullanır.
|
|
876
893
|
|
|
877
894
|
Redis kapalıyken (ya da bağlanamadığında) aynı gövde `.jskelet/cache/<buildId>/`
|
|
878
895
|
altına dosya olarak yazılır. Süreç yeniden açılınca L1 boştur ama diskteki
|
|
@@ -889,8 +906,8 @@ bir sonraki yazışta siler. `clearHtmlCache()` ve invalidation dosyayı da dü
|
|
|
889
906
|
dışındaki durum kodları da paylaşılmaz.
|
|
890
907
|
- **Sıkıştırılmış gövdeler varsayılan olarak paylaşılır.** `storeEncoded`
|
|
891
908
|
(varsayılan `true`) soğuk replica'nın L2 HIT'te yeniden brotli ödemesini
|
|
892
|
-
önler
|
|
893
|
-
için `storeEncoded: false` verin.
|
|
909
|
+
önler. Gövde `:enc:{br|gzip}` anahtarına ham bayt olarak yazılır; meta
|
|
910
|
+
JSON'unun içine base64 girmez. Kapatmak için `storeEncoded: false` verin.
|
|
894
911
|
- **Yumuşak invalidation Redis kopyasını siler.** Bayatlatmanın Redis karşılığı
|
|
895
912
|
her anahtar için oku-değiştir-yaz turu demek ve bir webhook binlerce anahtarı
|
|
896
913
|
birden düşürüyor. Silmenin bedeli, o yolu hiç görmemiş bir kopyanın bir kez
|
|
@@ -917,16 +934,18 @@ app.get("/api/healthcheck", (req, res) => {
|
|
|
917
934
|
```
|
|
918
935
|
|
|
919
936
|
Bağlantı kurulmamışken de güvenle çağrılır. Dönen nesne
|
|
920
|
-
`{ enabled, connected, keyPrefix, buildId, errors, bypassed
|
|
921
|
-
|
|
922
|
-
|
|
937
|
+
`{ enabled, connected, keyPrefix, buildId, errors, bypassed, htmlErrors, htmlBypassed }`.
|
|
938
|
+
`bypassed` veri katmanının, `htmlBypassed` HTML katmanının baypasta olduğunu
|
|
939
|
+
gösterir. `errors` veri komutlarının, `htmlErrors` HTML komutlarının toplam
|
|
940
|
+
hatasıdır. Aynı özet dev panelinin raporunda da var
|
|
941
|
+
([09-dev-araclari.md](./09-dev-araclari.md)).
|
|
923
942
|
|
|
924
943
|
İki teşhis yüzeyi daha var:
|
|
925
944
|
|
|
926
945
|
| Çağrı | Ne der |
|
|
927
946
|
| --- | --- |
|
|
928
947
|
| `getRedisDetails()` | Bağlantının **nereye** kurulduğu: adres, TLS, veritabanı, `namespace`, hangi türlerin paylaşıldığı, purge yayınına abone olunup olunmadığı. Şifre asla dönmez — bağlantı URL'i sır taşıyor olabilir. |
|
|
929
|
-
| `inspectRedis()` | Paylaşımlı kademede gerçekten ne durduğu: tür başına
|
|
948
|
+
| `inspectRedis()` | Paylaşımlı kademede gerçekten ne durduğu: tür başına kayıt sayısı (HTML'de gövde ve kodlama parçaları tek sayfa sayılır), `DBSIZE` ve `used_memory`. Bir `SCAN` turu olduğu için **istek yolunda çağrılmaz**; yönetim panelinde de ayrı bir düğmeye bağlı. |
|
|
930
949
|
|
|
931
950
|
Ayarların tam listesi: [07-yapilandirma.md](./07-yapilandirma.md).
|
|
932
951
|
|
|
@@ -1029,7 +1048,7 @@ değil.
|
|
|
1029
1048
|
| Clear HTML cache | `clearHtmlCache()` |
|
|
1030
1049
|
| Clear data cache (önek opsiyonel) | `clearDataCache(prefix)` |
|
|
1031
1050
|
| Drop shared keys | Redis'teki `html` ya da `data` isim alanını tarar ve düşürür |
|
|
1032
|
-
| Count keys in Redis | `inspectRedis()` — tür başına
|
|
1051
|
+
| Count keys in Redis | `inspectRedis()` — tür başına kayıt (HTML parçaları tek sayfa sayılır), `DBSIZE` ve `used_memory` |
|
|
1033
1052
|
| Prewarm | `prewarm()` — tur arkada koşar, ilerleme kartta görünür |
|
|
1034
1053
|
| Cloudflare purge (her şey / bellekteki URL'ler / prefix / host / tag) | `purgeCloudflare()` |
|
|
1035
1054
|
| Cloudflare ayarı ya da özelliği değiştirmek | Zone ayarları ve Tiered Cache / Cache Reserve |
|
package/docs/07-yapilandirma.md
CHANGED
|
@@ -960,15 +960,17 @@ kurulmadıysa ya da bağlanılamıyorsa uyarı basılır ve site bellek içi ön
|
|
|
960
960
|
| `keyPrefix` | `string` | `"_jskelet"` | Anahtar düzeninin kökü |
|
|
961
961
|
| `html` | `boolean` | `true` | HTML gövdeleri paylaşılsın mı |
|
|
962
962
|
| `data` | `boolean` | `true` | `withDataCache` girdileri paylaşılsın mı |
|
|
963
|
-
| `storeEncoded` | `boolean` | `true` | Brotli/gzip gövdeleri
|
|
963
|
+
| `storeEncoded` | `boolean` | `true` | Brotli/gzip gövdeleri ayrı `:enc:` anahtarına yazılsın mı |
|
|
964
964
|
| `events` | `boolean` | `true` | pub/sub üzerinden invalidation yayını |
|
|
965
|
-
| `commandTimeoutMs` | `number` | `200` |
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
`buildId`
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
965
|
+
| `commandTimeoutMs` | `number` | `200` | Veri, yayın ve `SCAN` için tek komutun tavanı |
|
|
966
|
+
| `htmlCommandTimeoutMs` | `number` | `2000` | Yalnızca HTML bağlantısının komut tavanı. Verilmezse 2000 |
|
|
967
|
+
|
|
968
|
+
Anahtarlar parçalıdır: `_jskelet:{namespace}:{buildId}:html:{yol}?{query}` küçük
|
|
969
|
+
meta JSON'u, aynı anahtarın `:body` soneki HTML'in brotli baytını, `:enc:br`
|
|
970
|
+
ve `:enc:gzip` ise yanıt kodlamasını tutar. `buildId` her build'de değişir,
|
|
971
|
+
böylece deploy sonrası eski HTML kendiliğinden geçersiz olur. Kişiye özel
|
|
972
|
+
(`storable: false`), `degraded` ve 200 dışındaki yanıtlar paylaşımlı kademeye
|
|
973
|
+
hiç yazılmaz. Takaslar ve teşhis: [06-cache.md](./06-cache.md).
|
|
972
974
|
|
|
973
975
|
```js
|
|
974
976
|
redis: {
|
package/docs/08-build.md
CHANGED
|
@@ -163,12 +163,18 @@ return {
|
|
|
163
163
|
Dizin, `paths.styles` dosyasının yanındaki `pages/` klasörüdür (`styles` taşınırsa
|
|
164
164
|
pages de yanında kalır). Dizin yoksa veya boşsa adım yalnızca global sheet üretir.
|
|
165
165
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
166
|
+
Her sayfa çıktısı **global derlenmiş CSS + sayfa derlenmiş CSS** içeren tek bir
|
|
167
|
+
dosyadır. Controller bir sayfa sheet'i bildirdiğinde layout `app.css`i ayrıca
|
|
168
|
+
basmaz; yalnızca birleşik sheet'i yükler. Böylece inline kritik CSS, `app.css`
|
|
169
|
+
ve page sheet içindeki aynı Tailwind utility katmanı üç ayrı anda uygulanmaz.
|
|
170
|
+
Örneğin global `.px-0` ile sayfadaki `.lg:px-4` çatışsa bile tarayıcı yalnızca
|
|
171
|
+
dosyanın son cascade sonucunu boyar ve ara düzen CLS üretmez.
|
|
172
|
+
|
|
173
|
+
Sayfa CSS'i sayfaya özel kurallar içindir. Bir route için tek sayfa dosyası
|
|
174
|
+
tercih edin; `styles` dizisinde birden fazla ad hâlâ desteklenir ama her biri
|
|
175
|
+
global CSS'i taşıdığı için gereksiz tekrar indirir. Sayfa adı manifest'te yoksa
|
|
176
|
+
layout güvenli biçimde `app.css`e döner. `blocking: false` birleşik linke
|
|
177
|
+
`media="print"` ve `onload` ekler.
|
|
172
178
|
|
|
173
179
|
### `@source` direktifleri zorunludur
|
|
174
180
|
|
package/docs/en/03-routing.md
CHANGED
|
@@ -222,7 +222,7 @@ fields:
|
|
|
222
222
|
| `head` | `string` | `""` | Raw HTML to be printed into `<head>` as-is (e.g. the LCP preload). |
|
|
223
223
|
| `bodyClass` | `string` | `hooks.layoutContext().bodyClass ?? ""` | `<body class="…">`. |
|
|
224
224
|
| `entries` | `string[]` | `[]` | The names of client entries to be loaded additionally on this page: `["chart.js"]`. |
|
|
225
|
-
| `styles` | `string[]` | `[]` |
|
|
225
|
+
| `styles` | `string[]` | `[]` | Page stylesheets combined with global CSS and loaded instead of `app.css`: `["home.css"]` → `styles/pages/home.css`. |
|
|
226
226
|
|
|
227
227
|
`revalidate` is **the second argument of `route()`**, not a field of the object
|
|
228
228
|
the controller returns.
|
package/docs/en/04-rendering.md
CHANGED
|
@@ -181,8 +181,9 @@ Points to watch:
|
|
|
181
181
|
- **`extraHead` comes first.** Delaying resource hints (`preconnect`, LCP
|
|
182
182
|
`preload`) writes straight into LCP.
|
|
183
183
|
- **`<Stylesheets />` emits global `app.css` render-blocking by default**,
|
|
184
|
-
|
|
185
|
-
[
|
|
184
|
+
with the reasoning in [02-architecture.md](./02-architecture.md). When a
|
|
185
|
+
controller provides `styles: [...]`, a page sheet is a combined asset that
|
|
186
|
+
already contains global CSS and is emitted instead of `app.css`.
|
|
186
187
|
`<Stylesheets :blocking="false" />` (`stylesheets({ blocking: false })`)
|
|
187
188
|
emits the links with `media="print"` plus `onload`, and a `<noscript>`
|
|
188
189
|
fallback when JS is off. Painting is not held, and the layout can shift
|
|
@@ -442,7 +443,8 @@ icon({ name: "ArrowRight", weight: "bold", size: 20, class: "text-slate-500" });
|
|
|
442
443
|
|
|
443
444
|
### `stylesheets(props)`
|
|
444
445
|
|
|
445
|
-
Global `app.css
|
|
446
|
+
Global `app.css`, or the combined page sheets in the controller `styles` list,
|
|
447
|
+
for the layout `<head>`.
|
|
446
448
|
The built-in tag is the usual call site:
|
|
447
449
|
|
|
448
450
|
```jsk
|
|
@@ -456,7 +458,9 @@ stylesheets({ styles: ["home.css"], blocking: false });
|
|
|
456
458
|
```
|
|
457
459
|
|
|
458
460
|
- `styles` are manifest keys (`"home.css"` → `styles/pages/home.css`). Names
|
|
459
|
-
for which `hasAsset` is false are omitted.
|
|
461
|
+
for which `hasAsset` is false are omitted. If at least one page sheet exists,
|
|
462
|
+
`app.css` is not emitted separately because every page output already
|
|
463
|
+
includes it. If none exists, the helper falls back to `app.css`.
|
|
460
464
|
- `blocking` defaults to `true`:
|
|
461
465
|
`<link rel="stylesheet" data-jskelet-css="…">`. Only the boolean `false`
|
|
462
466
|
turns waiting off. The output is `media="print"` and
|
package/docs/en/06-caching.md
CHANGED
|
@@ -849,8 +849,10 @@ npm install ioredis
|
|
|
849
849
|
|
|
850
850
|
If it is not installed, or Redis cannot be reached, a warning is printed and the
|
|
851
851
|
site **keeps running on the in-process cache**. The same happens if Redis goes
|
|
852
|
-
down while running:
|
|
853
|
-
|
|
852
|
+
down while running: data and HTML have separate circuit breakers. Five
|
|
853
|
+
consecutive failures bypass that tier for five seconds, so requests do not each
|
|
854
|
+
wait for a network timeout. An HTML timeout is not charged to the data counter,
|
|
855
|
+
so a slow page does not shut the small data keys.
|
|
854
856
|
|
|
855
857
|
### What you get
|
|
856
858
|
|
|
@@ -870,6 +872,8 @@ five consecutive failures, so requests do not each wait for a network timeout.
|
|
|
870
872
|
|
|
871
873
|
```
|
|
872
874
|
_jskelet:{namespace}:{buildId}:html:{vary|}{path}?{query}
|
|
875
|
+
_jskelet:{namespace}:{buildId}:html:{vary|}{path}?{query}:body
|
|
876
|
+
_jskelet:{namespace}:{buildId}:html:{vary|}{path}?{query}:enc:{br|gzip}
|
|
873
877
|
_jskelet:{namespace}:{buildId}:data:{key}
|
|
874
878
|
_jskelet:{namespace}:events
|
|
875
879
|
```
|
|
@@ -885,13 +889,25 @@ build has not been run the id is `dev`.
|
|
|
885
889
|
deliberately does **not** carry `buildId`: during a deploy the old and the new
|
|
886
890
|
version run side by side and a purge has to reach both.
|
|
887
891
|
|
|
888
|
-
HTML
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
892
|
+
HTML is stored as three parts. The meta key is a small JSON document
|
|
893
|
+
(`status`, `storedAt`, `expiresAt`, `staleUntil`, `produceMs`, `deps`) and does
|
|
894
|
+
not contain the body. `:body` is the brotli bytes of the HTML: no base64, and
|
|
895
|
+
those bytes are not compressed again inside JSON. When `storeEncoded` is on,
|
|
896
|
+
the brotli or gzip body produced for the response is written as-is to
|
|
897
|
+
`:enc:br` / `:enc:gzip`. A read pipelines meta and body; if either part is
|
|
898
|
+
missing the record counts as absent and the page is rendered.
|
|
899
|
+
|
|
900
|
+
Data entries of 1 KB or more are not stored as plain JSON. They are a brotli
|
|
901
|
+
body prefixed with `JSK\x01` (quality 5, text mode — the same settings as
|
|
902
|
+
response compression). Smaller data records stay plain JSON. HTML does not use
|
|
903
|
+
that wrapper. zstd is not used: `node:zlib` gained it in 22.15, while the
|
|
904
|
+
engine range is `>=22`.
|
|
905
|
+
|
|
906
|
+
`commandTimeoutMs` (default 200) applies to data, publish, and `SCAN`. HTML
|
|
907
|
+
reads and writes use a second connection; `htmlCommandTimeoutMs` (default
|
|
908
|
+
2000) limits only that connection. ioredis applies `commandTimeout` to the
|
|
909
|
+
whole client, so the two budgets cannot share one connection. When an
|
|
910
|
+
application omits the field, the framework uses 2000.
|
|
895
911
|
|
|
896
912
|
When Redis is off, or cannot connect, the same body is written under
|
|
897
913
|
`.jskelet/cache/<buildId>/`. After a restart L1 is empty, but a fresh file
|
|
@@ -908,8 +924,9 @@ file too.
|
|
|
908
924
|
tier: a leak would mean serving one user's HTML to the whole cluster.
|
|
909
925
|
`degraded` renders and non-200 status codes are not shared either.
|
|
910
926
|
- **Compressed bodies are shared by default.** `storeEncoded` (default `true`)
|
|
911
|
-
keeps a cold replica from paying brotli again on an L2 HIT
|
|
912
|
-
|
|
927
|
+
keeps a cold replica from paying brotli again on an L2 HIT. The body is
|
|
928
|
+
stored as raw bytes on an `:enc:{br|gzip}` key; it is not base64 inside the
|
|
929
|
+
meta JSON. Set `storeEncoded: false` to skip those keys.
|
|
913
930
|
- **A soft invalidation deletes the Redis copy.** Staling in Redis would mean a
|
|
914
931
|
read-modify-write round per key, and a webhook drops thousands of keys at
|
|
915
932
|
once. The cost of deleting is one render on a replica that never saw that
|
|
@@ -936,9 +953,10 @@ app.get("/api/healthcheck", (req, res) => {
|
|
|
936
953
|
```
|
|
937
954
|
|
|
938
955
|
Safe to call even with no connection. The returned object is
|
|
939
|
-
`{ enabled, connected, keyPrefix, buildId, errors, bypassed
|
|
940
|
-
|
|
941
|
-
|
|
956
|
+
`{ enabled, connected, keyPrefix, buildId, errors, bypassed, htmlErrors, htmlBypassed }`.
|
|
957
|
+
`bypassed` means the data tier is in its bypass window and `htmlBypassed` means
|
|
958
|
+
the HTML connection is. `errors` counts data-command failures and `htmlErrors`
|
|
959
|
+
counts HTML-command failures. The same summary is in the dev panel report
|
|
942
960
|
([09-dev-tools.md](./09-dev-tools.md)).
|
|
943
961
|
|
|
944
962
|
Two more diagnostic surfaces:
|
|
@@ -946,7 +964,7 @@ Two more diagnostic surfaces:
|
|
|
946
964
|
| Call | What it tells you |
|
|
947
965
|
| --- | --- |
|
|
948
966
|
| `getRedisDetails()` | **Where** the connection points: address, TLS, database, `namespace`, which kinds are shared, whether the purge channel is subscribed. The password is never returned — a connection URL may carry one. |
|
|
949
|
-
| `inspectRedis()` | What is actually in the shared tier:
|
|
967
|
+
| `inspectRedis()` | What is actually in the shared tier: records per kind (HTML body and encoding fragments count as one page), `DBSIZE` and `used_memory`. It runs a `SCAN`, so **never call it on the request path**; in the admin panel it sits behind its own button. |
|
|
950
968
|
|
|
951
969
|
The full list of settings: [07-configuration.md](./07-configuration.md).
|
|
952
970
|
|
|
@@ -1030,7 +1048,7 @@ export content.
|
|
|
1030
1048
|
| Clear HTML cache | `clearHtmlCache()` |
|
|
1031
1049
|
| Clear data cache (optional prefix) | `clearDataCache(prefix)` |
|
|
1032
1050
|
| Drop shared keys | Scans and unlinks the `html` or `data` namespace in Redis |
|
|
1033
|
-
| Count keys in Redis | `inspectRedis()` —
|
|
1051
|
+
| Count keys in Redis | `inspectRedis()` — records per kind (HTML fragments count as one page), `DBSIZE` and `used_memory` |
|
|
1034
1052
|
| Prewarm | `prewarm()` — the pass runs in the background, progress shows in the card |
|
|
1035
1053
|
| Cloudflare purge (everything / URLs held here / prefix / host / tag) | `purgeCloudflare()` |
|
|
1036
1054
|
| Change a Cloudflare setting or feature | Zone settings and Tiered Cache / Cache Reserve |
|
|
@@ -979,12 +979,15 @@ the site keeps running on the in-process cache.
|
|
|
979
979
|
| `keyPrefix` | `string` | `"_jskelet"` | Root of the key layout |
|
|
980
980
|
| `html` | `boolean` | `true` | Whether HTML bodies are shared |
|
|
981
981
|
| `data` | `boolean` | `true` | Whether `withDataCache` entries are shared |
|
|
982
|
-
| `storeEncoded` | `boolean` | `true` | Whether brotli/gzip bodies are
|
|
982
|
+
| `storeEncoded` | `boolean` | `true` | Whether brotli/gzip bodies are written to their own `:enc:` keys |
|
|
983
983
|
| `events` | `boolean` | `true` | Invalidation broadcast over pub/sub |
|
|
984
|
-
| `commandTimeoutMs` | `number` | `200` |
|
|
984
|
+
| `commandTimeoutMs` | `number` | `200` | Per-command ceiling for data, publish, and `SCAN` |
|
|
985
|
+
| `htmlCommandTimeoutMs` | `number` | `2000` | Per-command ceiling for the HTML connection only. `2000` when omitted |
|
|
985
986
|
|
|
986
|
-
Keys
|
|
987
|
-
|
|
987
|
+
Keys are split: `_jskelet:{namespace}:{buildId}:html:{path}?{query}` is the
|
|
988
|
+
small meta JSON, the `:body` suffix is the brotli bytes of the HTML, and
|
|
989
|
+
`:enc:br` / `:enc:gzip` hold the response encoding. `buildId` changes with
|
|
990
|
+
every build, so old HTML becomes invalid on its own after a deploy.
|
|
988
991
|
Personalised (`storable: false`), `degraded` and non-200 responses are never
|
|
989
992
|
written to the shared tier. Trade-offs and diagnosis:
|
|
990
993
|
[06-caching.md](./06-caching.md).
|
package/docs/en/08-build.md
CHANGED
|
@@ -168,12 +168,19 @@ The directory is `pages/` next to the `paths.styles` file (if `styles` moves,
|
|
|
168
168
|
pages stays beside it). If the directory is missing or empty, the step only
|
|
169
169
|
produces the global sheet.
|
|
170
170
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
171
|
+
Each page output is one file containing **compiled global CSS + compiled page
|
|
172
|
+
CSS**. When a controller declares a page sheet, the layout does not emit
|
|
173
|
+
`app.css` separately; it loads only the combined sheet. This prevents the same
|
|
174
|
+
Tailwind utility layer in inline critical CSS, `app.css`, and the page sheet
|
|
175
|
+
from taking effect at three different times. Even if global `.px-0` conflicts
|
|
176
|
+
with page `.lg:px-4`, the browser paints only the file's final cascade result
|
|
177
|
+
instead of an intermediate layout that causes CLS.
|
|
178
|
+
|
|
179
|
+
Page CSS is for page-specific rules. Prefer one page file per route; multiple
|
|
180
|
+
names in `styles` are still supported, but each carries the global CSS and
|
|
181
|
+
therefore downloads redundant bytes. If no requested page name exists in the
|
|
182
|
+
manifest, the layout safely falls back to `app.css`. `blocking: false` adds
|
|
183
|
+
`media="print"` and `onload` to the combined link.
|
|
177
184
|
|
|
178
185
|
### `@source` directives are mandatory
|
|
179
186
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jskelet",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"description": "A framework that feels like no framework: Express 5 + build-time .jsk SSR (optional EJS peer), vanilla JS islands, Tailwind v4 and an in-process HTML TTL cache.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/src/build/tasks/css.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Tailwind v4 → global `app.css` + isteğe bağlı sayfa stylesheet'leri.
|
|
3
3
|
*
|
|
4
|
-
* Global sheet
|
|
5
|
-
* `styles/pages/*.css` altındadır
|
|
6
|
-
*
|
|
4
|
+
* Global sheet `paths.styles` girdisinden üretilir. Sayfa sheet'leri
|
|
5
|
+
* `styles/pages/*.css` altındadır; her çıktı global CSS + sayfa CSS'ini tek
|
|
6
|
+
* dosyada taşır ve yalnızca controller `styles: ["home.css"]` bildiren
|
|
7
|
+
* sayfalarda basılır — island `entries` ile aynı sözleşme.
|
|
7
8
|
*
|
|
8
9
|
* Ayrı bir "critical CSS" üretilmez. Ölçümde inline kritik CSS ilk ekranı tam
|
|
9
10
|
* kapsamadığı için sheet gelince sayfa yeniden akıyordu (bir liste sayfasında
|
|
@@ -13,9 +14,11 @@
|
|
|
13
14
|
* varsayılan olarak render-blocking; yalnızca ilgili sayfada ek maliyet.
|
|
14
15
|
* Layout `stylesheets({ blocking: false })` ile bu beklemeyi kapatabilir.
|
|
15
16
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
17
|
+
* Birleşik çıktı önemli: inline kritik CSS, global utility'ler ve sayfa
|
|
18
|
+
* utility'leri ayrı ağ yanıtlarında sırayla uygulanırsa ara cascade düzeni
|
|
19
|
+
* boyanıp CLS üretebilir. Tarayıcı tek dosyayı ancak tamamı geldikten sonra
|
|
20
|
+
* uygular; sayfa dosyasındaki son kurallar yine global kuralları ezebilir ama
|
|
21
|
+
* kullanıcı ara durumu görmez.
|
|
19
22
|
*
|
|
20
23
|
* Tailwind'in sınıf taraması `globals.css` içindeki `@source` direktiflerine
|
|
21
24
|
* bağlıdır. Otomatik tespit yalnızca stylesheet'in bulunduğu dizini tarar,
|
|
@@ -130,7 +133,8 @@ export async function buildCss(config, { watch = false } = {}) {
|
|
|
130
133
|
|
|
131
134
|
for (const file of listPageStyles(pagesDir)) {
|
|
132
135
|
const name = path.basename(file);
|
|
133
|
-
const
|
|
136
|
+
const pageCss = applyCdnStaticUrls(await compile(file), config);
|
|
137
|
+
const css = `${appCss}\n${pageCss}`;
|
|
134
138
|
const url = writeAsset(name, css);
|
|
135
139
|
urls[name] = url;
|
|
136
140
|
bytes += Buffer.byteLength(css);
|
package/src/client/admin/i18n.js
CHANGED
|
@@ -90,7 +90,9 @@ export const MESSAGES = {
|
|
|
90
90
|
"redis.broadcast.publish": "publish only",
|
|
91
91
|
"redis.broadcast.local": "local only",
|
|
92
92
|
"redis.timeout": "Command timeout",
|
|
93
|
+
"redis.htmlTimeout": "HTML command timeout",
|
|
93
94
|
"redis.errors": "Command errors",
|
|
95
|
+
"redis.htmlErrors": "HTML command errors",
|
|
94
96
|
"redis.tier": "Tier",
|
|
95
97
|
"redis.tier.inProcess": "in-process only",
|
|
96
98
|
"redis.replicas": "Replicas sharing this cache",
|
|
@@ -394,7 +396,9 @@ export const MESSAGES = {
|
|
|
394
396
|
"redis.broadcast.publish": "yalnızca yayın",
|
|
395
397
|
"redis.broadcast.local": "yalnızca yerel",
|
|
396
398
|
"redis.timeout": "Komut zaman aşımı",
|
|
399
|
+
"redis.htmlTimeout": "HTML komut zaman aşımı",
|
|
397
400
|
"redis.errors": "Komut hatası",
|
|
401
|
+
"redis.htmlErrors": "HTML komut hatası",
|
|
398
402
|
"redis.tier": "Kademe",
|
|
399
403
|
"redis.tier.inProcess": "yalnızca süreç içi",
|
|
400
404
|
"redis.replicas": "Bu önbelleği paylaşan kopya",
|
|
@@ -556,8 +556,12 @@ function renderRedis(redis, state) {
|
|
|
556
556
|
[t("redis.buildId"), redis.buildId || "dev"],
|
|
557
557
|
[
|
|
558
558
|
t("redis.sharesHtml"),
|
|
559
|
-
redis.html
|
|
560
|
-
|
|
559
|
+
!redis.html
|
|
560
|
+
? t("state.no")
|
|
561
|
+
: redis.htmlBypassed
|
|
562
|
+
? t("state.bypassed")
|
|
563
|
+
: t("state.yes"),
|
|
564
|
+
redis.html && !redis.htmlBypassed ? "on" : "off",
|
|
561
565
|
],
|
|
562
566
|
[
|
|
563
567
|
t("redis.sharesData"),
|
|
@@ -579,7 +583,9 @@ function renderRedis(redis, state) {
|
|
|
579
583
|
redis.events && redis.subscribed ? "on" : "off",
|
|
580
584
|
],
|
|
581
585
|
[t("redis.timeout"), `${redis.commandTimeoutMs} ${t("unit.ms")}`],
|
|
586
|
+
[t("redis.htmlTimeout"), `${redis.htmlCommandTimeoutMs} ${t("unit.ms")}`],
|
|
582
587
|
[t("redis.errors"), String(redis.errors), redis.errors ? "bad" : "on"],
|
|
588
|
+
[t("redis.htmlErrors"), String(redis.htmlErrors ?? 0), redis.htmlErrors ? "bad" : "on"],
|
|
583
589
|
]
|
|
584
590
|
: [
|
|
585
591
|
[t("redis.tier"), t("redis.tier.inProcess")],
|
package/src/config/defaults.js
CHANGED
|
@@ -297,11 +297,19 @@ export const DEFAULT_REDIS = {
|
|
|
297
297
|
/** pub/sub üzerinden invalidation yayını. */
|
|
298
298
|
events: true,
|
|
299
299
|
/**
|
|
300
|
-
*
|
|
300
|
+
* Veri, yayın ve SCAN için tek komut tavanı. Önbellek okuması isteği
|
|
301
301
|
* bloklayan bir adım: Redis takıldığında render'a düşmek, ağı beklemekten
|
|
302
|
-
* iyidir.
|
|
302
|
+
* iyidir. HTML gövdesi bu süreye sığmaz; o bağlantının tavanı
|
|
303
|
+
* `htmlCommandTimeoutMs`.
|
|
303
304
|
*/
|
|
304
305
|
commandTimeoutMs: 200,
|
|
306
|
+
/**
|
|
307
|
+
* Yalnızca HTML bağlantısı. ioredis `commandTimeout` istemci genelinde
|
|
308
|
+
* olduğu için gövde ayrı bağlantıda durur. Verilmezse 2000: uygulama
|
|
309
|
+
* config'i değiştirmek zorunda kalmasın. Parçalı yazma normalde bunun
|
|
310
|
+
* altında biter; tavan, gövde beklenmedik büyürse diye durur.
|
|
311
|
+
*/
|
|
312
|
+
htmlCommandTimeoutMs: 2000,
|
|
305
313
|
};
|
|
306
314
|
|
|
307
315
|
/**
|
package/src/config/index.js
CHANGED
|
@@ -95,7 +95,8 @@ const CONFIG_FILE = "jskelet.config.mjs";
|
|
|
95
95
|
* @property {boolean} data Veri önbelleği paylaşılsın mı.
|
|
96
96
|
* @property {boolean} storeEncoded Sıkıştırılmış gövdeler de paylaşılsın mı.
|
|
97
97
|
* @property {boolean} events pub/sub invalidation yayını.
|
|
98
|
-
* @property {number} commandTimeoutMs
|
|
98
|
+
* @property {number} commandTimeoutMs Veri, yayın ve SCAN tavanı.
|
|
99
|
+
* @property {number} htmlCommandTimeoutMs Yalnızca HTML bağlantısının tavanı.
|
|
99
100
|
*/
|
|
100
101
|
|
|
101
102
|
/**
|
|
@@ -340,6 +341,7 @@ function normalizePriority(raw) {
|
|
|
340
341
|
function normalizeRedis(raw) {
|
|
341
342
|
const source = /** @type {Record<string, any>} */ (raw ?? {});
|
|
342
343
|
const timeout = Number(source.commandTimeoutMs);
|
|
344
|
+
const htmlTimeout = Number(source.htmlCommandTimeoutMs);
|
|
343
345
|
|
|
344
346
|
return {
|
|
345
347
|
enabled: source.enabled === true,
|
|
@@ -354,6 +356,10 @@ function normalizeRedis(raw) {
|
|
|
354
356
|
Number.isFinite(timeout) && timeout > 0
|
|
355
357
|
? Math.floor(timeout)
|
|
356
358
|
: DEFAULT_REDIS.commandTimeoutMs,
|
|
359
|
+
htmlCommandTimeoutMs:
|
|
360
|
+
Number.isFinite(htmlTimeout) && htmlTimeout > 0
|
|
361
|
+
? Math.floor(htmlTimeout)
|
|
362
|
+
: DEFAULT_REDIS.htmlCommandTimeoutMs,
|
|
357
363
|
};
|
|
358
364
|
}
|
|
359
365
|
|