jskelet 0.2.5 → 0.3.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.
Files changed (106) hide show
  1. package/AGENTS.md +132 -132
  2. package/CHANGELOG.md +403 -383
  3. package/LICENSE +21 -21
  4. package/bin/jskelet.mjs +103 -103
  5. package/docs/01-baslangic.md +285 -285
  6. package/docs/02-mimari.md +293 -287
  7. package/docs/03-routing.md +486 -480
  8. package/docs/04-render-ve-sablonlar.md +490 -490
  9. package/docs/05-islands.md +482 -482
  10. package/docs/06-cache.md +1231 -1209
  11. package/docs/07-yapilandirma.md +44 -21
  12. package/docs/08-build.md +366 -366
  13. package/docs/09-dev-araclari.md +335 -335
  14. package/docs/10-dagitim.md +329 -329
  15. package/docs/11-tasima.md +1 -0
  16. package/docs/12-panel-ve-oturum.md +384 -384
  17. package/docs/README.md +105 -105
  18. package/docs/en/01-getting-started.md +292 -292
  19. package/docs/en/02-architecture.md +311 -305
  20. package/docs/en/03-routing.md +503 -497
  21. package/docs/en/04-rendering.md +504 -504
  22. package/docs/en/05-islands.md +492 -492
  23. package/docs/en/06-caching.md +1197 -1198
  24. package/docs/en/07-configuration.md +1009 -986
  25. package/docs/en/08-build.md +383 -383
  26. package/docs/en/09-dev-tools.md +342 -342
  27. package/docs/en/10-deployment.md +332 -332
  28. package/docs/en/11-migration.md +360 -359
  29. package/docs/en/12-dashboards-and-sessions.md +392 -392
  30. package/docs/en/README.md +112 -112
  31. package/package.json +102 -102
  32. package/src/build/ensure-build.mjs +15 -15
  33. package/src/build/paths.mjs +143 -143
  34. package/src/build/resolve-peer.mjs +36 -36
  35. package/src/build/tasks/client.mjs +268 -268
  36. package/src/build/tasks/css.mjs +124 -124
  37. package/src/build/tasks/fonts.mjs +146 -146
  38. package/src/build/tasks/icons.mjs +224 -224
  39. package/src/build/tasks/images.mjs +244 -244
  40. package/src/build/tasks/precompress.mjs +78 -78
  41. package/src/client/{cache-panel → admin}/i18n.js +756 -670
  42. package/src/client/{cache-panel → admin}/login.html +74 -74
  43. package/src/client/{cache-panel → admin}/panel.css +804 -756
  44. package/src/client/admin/panel.html +486 -0
  45. package/src/client/{cache-panel → admin}/panel.js +1242 -915
  46. package/src/client/devtools/report.html +185 -185
  47. package/src/client/devtools/report.js +725 -725
  48. package/src/client/dom.js +95 -95
  49. package/src/client/form.js +192 -192
  50. package/src/client/index.js +35 -35
  51. package/src/client/registry.js +297 -297
  52. package/src/client/safe-image.js +91 -91
  53. package/src/client/store.js +36 -36
  54. package/src/client/swap.js +188 -188
  55. package/src/config/defaults.js +16 -7
  56. package/src/config/index.js +38 -22
  57. package/src/config/pattern.js +107 -107
  58. package/src/http/control-flow.js +71 -71
  59. package/src/http/cookies.js +257 -257
  60. package/src/http/request-cache.js +46 -46
  61. package/src/http/request-context.js +162 -162
  62. package/src/index.js +83 -83
  63. package/src/init.mjs +221 -221
  64. package/src/log.mjs +58 -0
  65. package/src/runtime/alias-hooks.mjs +119 -119
  66. package/src/runtime/register.mjs +4 -4
  67. package/src/server/admin/actions.js +229 -0
  68. package/src/server/admin/auth.js +125 -0
  69. package/src/server/admin/event-log.js +151 -0
  70. package/src/server/admin/gate.js +209 -0
  71. package/src/server/admin/inventory.js +188 -0
  72. package/src/server/admin/mount.js +56 -0
  73. package/src/server/admin/router.js +216 -0
  74. package/src/server/admin/snapshot.js +126 -0
  75. package/src/server/assets.js +147 -147
  76. package/src/server/cache-deps.js +42 -42
  77. package/src/server/cloudflare.js +607 -607
  78. package/src/server/create-app.js +295 -291
  79. package/src/server/data-cache.js +462 -462
  80. package/src/server/dev/report.js +369 -369
  81. package/src/server/dev/socket.js +170 -170
  82. package/src/server/dev/version-check.mjs +139 -139
  83. package/src/server/html-cache.js +817 -817
  84. package/src/server/metadata.js +102 -102
  85. package/src/server/middleware/compression.js +205 -205
  86. package/src/server/middleware/csrf.js +134 -134
  87. package/src/server/middleware/dev-gate.js +62 -62
  88. package/src/server/middleware/headers.js +37 -37
  89. package/src/server/middleware/redirects.js +32 -32
  90. package/src/server/middleware/static-precompressed.js +100 -100
  91. package/src/server/middleware/trailing-slash.js +53 -0
  92. package/src/server/middleware/upstream-proxy.js +141 -141
  93. package/src/server/prewarm.js +601 -601
  94. package/src/server/redis.js +569 -569
  95. package/src/server/router.js +128 -128
  96. package/src/server/status-page.js +164 -164
  97. package/src/server/upstream-limiter.js +376 -376
  98. package/src/server/upstream-tracking.js +166 -166
  99. package/src/start.mjs +7 -7
  100. package/src/templates/layout.ejs +44 -44
  101. package/src/version.mjs +31 -31
  102. package/src/views/components/loader.js +85 -85
  103. package/src/views/helpers/html.js +102 -102
  104. package/src/views/helpers/tags.js +245 -245
  105. package/src/client/cache-panel/panel.html +0 -308
  106. package/src/server/cache-panel.js +0 -759
@@ -1,268 +1,268 @@
1
- /**
2
- * Island bundle'ı: esbuild, ESM, code splitting.
3
- *
4
- * `client/entries/*.js` içindeki her dosya bir entry'dir. `main.js` her sayfada
5
- * yüklenen ortak island bootstrap'ıdır; ek entry'ler yalnızca onları isteyen
6
- * sayfalarda (`controller` → `entries: ["chart.js"]`) yüklenir.
7
- *
8
- * Hedef tarayıcılar `package.json` → `browserslist` yerine burada sabit: ESM +
9
- * dinamik import + `IntersectionObserver` island modelinin zaten alt sınırı,
10
- * daha eskisine transpile etmek çıktıyı büyütüp hiçbir ziyaretçi kazandırmıyor.
11
- */
12
- import fs from "node:fs";
13
- import path from "node:path";
14
- import process from "node:process";
15
- import * as esbuild from "esbuild";
16
- import { paths, patchManifest, pruneAssets } from "../paths.mjs";
17
- import * as log from "../../log.mjs";
18
-
19
- /**
20
- * `@/` alias'ını proje köküne çözer — Node tarafındaki `alias-hooks.mjs` ile
21
- * aynı davranış, böylece `lib/` altındaki modüller hem sunucuda hem
22
- * tarayıcıda aynı import stilini kullanabilir.
23
- *
24
- * @param {string} root
25
- * @returns {esbuild.Plugin}
26
- */
27
- function aliasPlugin(root) {
28
- return {
29
- name: "jskelet-alias",
30
- setup(build) {
31
- build.onResolve({ filter: /^@\// }, (args) => ({
32
- path: resolveWithExtension(path.join(root, args.path.slice(2))),
33
- }));
34
- },
35
- };
36
- }
37
-
38
- /**
39
- * Tarayıcıda `process` yoktur; sunucuyla paylaşılan modüller yine de
40
- * `process.env` okur. `clientEnv` ile bildirilen anahtarlar build zamanında
41
- * gömülür — Next'teki `NEXT_PUBLIC_*` ile aynı sözleşme, ama hangi anahtarın
42
- * herkese açık olduğu isimden değil config'ten belli.
43
- *
44
- * `process.env`in tamamı tek nesne olarak define edilir: listede olmayan bir
45
- * anahtar okunduğunda çökme yerine `undefined` döner.
46
- *
47
- * @param {string[]} keys
48
- * @returns {Record<string, string>}
49
- */
50
- function publicEnv(keys) {
51
- /** @type {Record<string, string>} */
52
- const env = { NODE_ENV: process.env.NODE_ENV ?? "production" };
53
- for (const key of keys) {
54
- const value = process.env[key];
55
- if (value != null) env[key] = value;
56
- }
57
- return env;
58
- }
59
-
60
- /**
61
- * @param {string} base
62
- * @returns {string}
63
- */
64
- function resolveWithExtension(base) {
65
- const candidates = [
66
- base,
67
- `${base}.js`,
68
- `${base}.mjs`,
69
- `${base}.json`,
70
- path.join(base, "index.js"),
71
- ];
72
- for (const candidate of candidates) {
73
- if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) return candidate;
74
- }
75
- return base;
76
- }
77
-
78
- /**
79
- * @param {import('../../config/index.js').ResolvedConfig} config
80
- * @param {{ watch?: boolean }} [options]
81
- * @returns {Promise<Record<string, string>>}
82
- */
83
- export async function buildClient(config, { watch = false } = {}) {
84
- const entryDir = path.join(config.dirs.client, "entries");
85
- const outDir = path.join(paths.assets, "js");
86
-
87
- if (!fs.existsSync(entryDir)) {
88
- log.detail("no entries, skipped");
89
- return {};
90
- }
91
-
92
- const entryPoints = fs
93
- .readdirSync(entryDir)
94
- .filter((file) => file.endsWith(".js"))
95
- .map((file) => path.join(entryDir, file));
96
-
97
- if (!entryPoints.length) {
98
- log.detail("no entries, skipped");
99
- return {};
100
- }
101
-
102
- fs.rmSync(outDir, { recursive: true, force: true });
103
- pruneAssets(["js/"]);
104
-
105
- const entryRoot = path
106
- .relative(config.root, entryDir)
107
- .split(path.sep)
108
- .join("/");
109
-
110
- /** @type {esbuild.BuildOptions} */
111
- const options = {
112
- entryPoints,
113
- outdir: outDir,
114
- absWorkingDir: config.root,
115
- bundle: true,
116
- splitting: true,
117
- format: "esm",
118
- target: ["chrome111", "edge111", "firefox111", "safari16.4"],
119
- minify: true,
120
- sourcemap: true,
121
- metafile: true,
122
- entryNames: "[name].[hash]",
123
- chunkNames: "chunks/[name].[hash]",
124
- legalComments: "none",
125
- plugins: [aliasPlugin(config.root)],
126
- define: {
127
- "process.env": JSON.stringify(publicEnv(config.clientEnv)),
128
- },
129
- };
130
-
131
- if (watch) {
132
- const context = await esbuild.context({
133
- ...options,
134
- plugins: [...options.plugins, rebuildReporter(config, entryRoot)],
135
- });
136
- const result = await context.rebuild();
137
- await context.watch();
138
- writeMetafile(result.metafile);
139
- const manifest = toManifest(result.metafile, config, entryRoot);
140
- const entries = Object.keys(manifest).length;
141
- log.detail(`${entries} ${entries === 1 ? "entry" : "entries"}`);
142
- return manifest;
143
- }
144
-
145
- const result = await esbuild.build(options);
146
- writeMetafile(result.metafile);
147
- const manifest = toManifest(result.metafile, config, entryRoot);
148
- const bytes = Object.values(result.metafile.outputs).reduce(
149
- (sum, output) => sum + output.bytes,
150
- 0,
151
- );
152
- const entries = Object.keys(manifest).length;
153
- log.detail(`${entries} ${entries === 1 ? "entry" : "entries"}, ${log.size(bytes)}`);
154
- return manifest;
155
- }
156
-
157
- /**
158
- * Metafile diske yazılır: dev panelindeki chunk analizi giriş/çıkış
159
- * kırılımını buradan okur. Çalışma zamanı bu dosyaya bağımlı değildir.
160
- *
161
- * @param {esbuild.Metafile} [metafile]
162
- */
163
- function writeMetafile(metafile) {
164
- if (!metafile) return;
165
- try {
166
- fs.mkdirSync(paths.generated, { recursive: true });
167
- fs.writeFileSync(
168
- path.join(paths.generated, "metafile.json"),
169
- JSON.stringify(metafile),
170
- );
171
- } catch {
172
- // Analiz verisi en iyi çaba; build'i düşürmez.
173
- }
174
- }
175
-
176
- /**
177
- * Watch turlarını canlı olarak bildirir; ilk build zaten adım satırında görünür.
178
- *
179
- * @param {import('../../config/index.js').ResolvedConfig} config
180
- * @param {string} entryRoot
181
- * @returns {esbuild.Plugin}
182
- */
183
- function rebuildReporter(config, entryRoot) {
184
- // İlk `rebuild()` ve `watch()`'un kendi açılış turu adım satırında zaten
185
- // görünüyor; canlı bildirim gerçek değişikliklerle başlar.
186
- let skip = 2;
187
- let started = 0;
188
-
189
- return {
190
- name: "jskelet-rebuild-log",
191
- setup(build) {
192
- build.onStart(() => {
193
- started = Date.now();
194
- });
195
-
196
- build.onEnd((result) => {
197
- if (result.metafile) {
198
- writeMetafile(result.metafile);
199
- // Entry adları hash'li: yeni hash manifest'e yazılmazsa HTML eski
200
- // (artık var olmayan) bundle'ı ister ve island'ların hiçbiri açılmaz.
201
- for (const [key, url] of Object.entries(
202
- toManifest(result.metafile, config, entryRoot),
203
- )) {
204
- patchManifest(key, url);
205
- }
206
- }
207
-
208
- if (skip > 0) {
209
- skip -= 1;
210
- return;
211
- }
212
-
213
- if (result.errors.length) {
214
- const [first] = result.errors;
215
- log.errorBox({
216
- title: "Client Build Error",
217
- name: "BuildError",
218
- message: first.text,
219
- lines: [
220
- first.location
221
- ? `${first.location.file}:${first.location.line}:${first.location.column}`
222
- : "",
223
- result.errors.length > 1
224
- ? `+${result.errors.length - 1} more errors`
225
- : "",
226
- ].filter(Boolean),
227
- });
228
- return;
229
- }
230
-
231
- log.event({
232
- scope: "client",
233
- message: "rebuilt",
234
- time: Date.now() - started,
235
- });
236
- });
237
- },
238
- };
239
- }
240
-
241
- /**
242
- * esbuild metafile → { "main.js": "/assets/js/main.abc.js" }
243
- *
244
- * Dinamik import'lar da `entryPoint` taşır; yalnızca gerçek entry'ler
245
- * manifest'e girer, yoksa her island ayrı bir manifest anahtarı olurdu.
246
- *
247
- * @param {esbuild.Metafile} metafile
248
- * @param {import('../../config/index.js').ResolvedConfig} config
249
- * @param {string} entryRoot
250
- * @returns {Record<string, string>}
251
- */
252
- function toManifest(metafile, config, entryRoot) {
253
- /** @type {Record<string, string>} */
254
- const manifest = {};
255
-
256
- for (const [outputPath, output] of Object.entries(metafile.outputs)) {
257
- if (!output.entryPoint?.startsWith(entryRoot)) continue;
258
-
259
- const name = `${path.basename(output.entryPoint, ".js")}.js`;
260
- const absolute = path.resolve(config.root, outputPath);
261
- manifest[name] = `/${path
262
- .relative(config.dirs.public, absolute)
263
- .split(path.sep)
264
- .join("/")}`;
265
- }
266
-
267
- return manifest;
268
- }
1
+ /**
2
+ * Island bundle'ı: esbuild, ESM, code splitting.
3
+ *
4
+ * `client/entries/*.js` içindeki her dosya bir entry'dir. `main.js` her sayfada
5
+ * yüklenen ortak island bootstrap'ıdır; ek entry'ler yalnızca onları isteyen
6
+ * sayfalarda (`controller` → `entries: ["chart.js"]`) yüklenir.
7
+ *
8
+ * Hedef tarayıcılar `package.json` → `browserslist` yerine burada sabit: ESM +
9
+ * dinamik import + `IntersectionObserver` island modelinin zaten alt sınırı,
10
+ * daha eskisine transpile etmek çıktıyı büyütüp hiçbir ziyaretçi kazandırmıyor.
11
+ */
12
+ import fs from "node:fs";
13
+ import path from "node:path";
14
+ import process from "node:process";
15
+ import * as esbuild from "esbuild";
16
+ import { paths, patchManifest, pruneAssets } from "../paths.mjs";
17
+ import * as log from "../../log.mjs";
18
+
19
+ /**
20
+ * `@/` alias'ını proje köküne çözer — Node tarafındaki `alias-hooks.mjs` ile
21
+ * aynı davranış, böylece `lib/` altındaki modüller hem sunucuda hem
22
+ * tarayıcıda aynı import stilini kullanabilir.
23
+ *
24
+ * @param {string} root
25
+ * @returns {esbuild.Plugin}
26
+ */
27
+ function aliasPlugin(root) {
28
+ return {
29
+ name: "jskelet-alias",
30
+ setup(build) {
31
+ build.onResolve({ filter: /^@\// }, (args) => ({
32
+ path: resolveWithExtension(path.join(root, args.path.slice(2))),
33
+ }));
34
+ },
35
+ };
36
+ }
37
+
38
+ /**
39
+ * Tarayıcıda `process` yoktur; sunucuyla paylaşılan modüller yine de
40
+ * `process.env` okur. `clientEnv` ile bildirilen anahtarlar build zamanında
41
+ * gömülür — Next'teki `NEXT_PUBLIC_*` ile aynı sözleşme, ama hangi anahtarın
42
+ * herkese açık olduğu isimden değil config'ten belli.
43
+ *
44
+ * `process.env`in tamamı tek nesne olarak define edilir: listede olmayan bir
45
+ * anahtar okunduğunda çökme yerine `undefined` döner.
46
+ *
47
+ * @param {string[]} keys
48
+ * @returns {Record<string, string>}
49
+ */
50
+ function publicEnv(keys) {
51
+ /** @type {Record<string, string>} */
52
+ const env = { NODE_ENV: process.env.NODE_ENV ?? "production" };
53
+ for (const key of keys) {
54
+ const value = process.env[key];
55
+ if (value != null) env[key] = value;
56
+ }
57
+ return env;
58
+ }
59
+
60
+ /**
61
+ * @param {string} base
62
+ * @returns {string}
63
+ */
64
+ function resolveWithExtension(base) {
65
+ const candidates = [
66
+ base,
67
+ `${base}.js`,
68
+ `${base}.mjs`,
69
+ `${base}.json`,
70
+ path.join(base, "index.js"),
71
+ ];
72
+ for (const candidate of candidates) {
73
+ if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) return candidate;
74
+ }
75
+ return base;
76
+ }
77
+
78
+ /**
79
+ * @param {import('../../config/index.js').ResolvedConfig} config
80
+ * @param {{ watch?: boolean }} [options]
81
+ * @returns {Promise<Record<string, string>>}
82
+ */
83
+ export async function buildClient(config, { watch = false } = {}) {
84
+ const entryDir = path.join(config.dirs.client, "entries");
85
+ const outDir = path.join(paths.assets, "js");
86
+
87
+ if (!fs.existsSync(entryDir)) {
88
+ log.detail("no entries, skipped");
89
+ return {};
90
+ }
91
+
92
+ const entryPoints = fs
93
+ .readdirSync(entryDir)
94
+ .filter((file) => file.endsWith(".js"))
95
+ .map((file) => path.join(entryDir, file));
96
+
97
+ if (!entryPoints.length) {
98
+ log.detail("no entries, skipped");
99
+ return {};
100
+ }
101
+
102
+ fs.rmSync(outDir, { recursive: true, force: true });
103
+ pruneAssets(["js/"]);
104
+
105
+ const entryRoot = path
106
+ .relative(config.root, entryDir)
107
+ .split(path.sep)
108
+ .join("/");
109
+
110
+ /** @type {esbuild.BuildOptions} */
111
+ const options = {
112
+ entryPoints,
113
+ outdir: outDir,
114
+ absWorkingDir: config.root,
115
+ bundle: true,
116
+ splitting: true,
117
+ format: "esm",
118
+ target: ["chrome111", "edge111", "firefox111", "safari16.4"],
119
+ minify: true,
120
+ sourcemap: true,
121
+ metafile: true,
122
+ entryNames: "[name].[hash]",
123
+ chunkNames: "chunks/[name].[hash]",
124
+ legalComments: "none",
125
+ plugins: [aliasPlugin(config.root)],
126
+ define: {
127
+ "process.env": JSON.stringify(publicEnv(config.clientEnv)),
128
+ },
129
+ };
130
+
131
+ if (watch) {
132
+ const context = await esbuild.context({
133
+ ...options,
134
+ plugins: [...options.plugins, rebuildReporter(config, entryRoot)],
135
+ });
136
+ const result = await context.rebuild();
137
+ await context.watch();
138
+ writeMetafile(result.metafile);
139
+ const manifest = toManifest(result.metafile, config, entryRoot);
140
+ const entries = Object.keys(manifest).length;
141
+ log.detail(`${entries} ${entries === 1 ? "entry" : "entries"}`);
142
+ return manifest;
143
+ }
144
+
145
+ const result = await esbuild.build(options);
146
+ writeMetafile(result.metafile);
147
+ const manifest = toManifest(result.metafile, config, entryRoot);
148
+ const bytes = Object.values(result.metafile.outputs).reduce(
149
+ (sum, output) => sum + output.bytes,
150
+ 0,
151
+ );
152
+ const entries = Object.keys(manifest).length;
153
+ log.detail(`${entries} ${entries === 1 ? "entry" : "entries"}, ${log.size(bytes)}`);
154
+ return manifest;
155
+ }
156
+
157
+ /**
158
+ * Metafile diske yazılır: dev panelindeki chunk analizi giriş/çıkış
159
+ * kırılımını buradan okur. Çalışma zamanı bu dosyaya bağımlı değildir.
160
+ *
161
+ * @param {esbuild.Metafile} [metafile]
162
+ */
163
+ function writeMetafile(metafile) {
164
+ if (!metafile) return;
165
+ try {
166
+ fs.mkdirSync(paths.generated, { recursive: true });
167
+ fs.writeFileSync(
168
+ path.join(paths.generated, "metafile.json"),
169
+ JSON.stringify(metafile),
170
+ );
171
+ } catch {
172
+ // Analiz verisi en iyi çaba; build'i düşürmez.
173
+ }
174
+ }
175
+
176
+ /**
177
+ * Watch turlarını canlı olarak bildirir; ilk build zaten adım satırında görünür.
178
+ *
179
+ * @param {import('../../config/index.js').ResolvedConfig} config
180
+ * @param {string} entryRoot
181
+ * @returns {esbuild.Plugin}
182
+ */
183
+ function rebuildReporter(config, entryRoot) {
184
+ // İlk `rebuild()` ve `watch()`'un kendi açılış turu adım satırında zaten
185
+ // görünüyor; canlı bildirim gerçek değişikliklerle başlar.
186
+ let skip = 2;
187
+ let started = 0;
188
+
189
+ return {
190
+ name: "jskelet-rebuild-log",
191
+ setup(build) {
192
+ build.onStart(() => {
193
+ started = Date.now();
194
+ });
195
+
196
+ build.onEnd((result) => {
197
+ if (result.metafile) {
198
+ writeMetafile(result.metafile);
199
+ // Entry adları hash'li: yeni hash manifest'e yazılmazsa HTML eski
200
+ // (artık var olmayan) bundle'ı ister ve island'ların hiçbiri açılmaz.
201
+ for (const [key, url] of Object.entries(
202
+ toManifest(result.metafile, config, entryRoot),
203
+ )) {
204
+ patchManifest(key, url);
205
+ }
206
+ }
207
+
208
+ if (skip > 0) {
209
+ skip -= 1;
210
+ return;
211
+ }
212
+
213
+ if (result.errors.length) {
214
+ const [first] = result.errors;
215
+ log.errorBox({
216
+ title: "Client Build Error",
217
+ name: "BuildError",
218
+ message: first.text,
219
+ lines: [
220
+ first.location
221
+ ? `${first.location.file}:${first.location.line}:${first.location.column}`
222
+ : "",
223
+ result.errors.length > 1
224
+ ? `+${result.errors.length - 1} more errors`
225
+ : "",
226
+ ].filter(Boolean),
227
+ });
228
+ return;
229
+ }
230
+
231
+ log.event({
232
+ scope: "client",
233
+ message: "rebuilt",
234
+ time: Date.now() - started,
235
+ });
236
+ });
237
+ },
238
+ };
239
+ }
240
+
241
+ /**
242
+ * esbuild metafile → { "main.js": "/assets/js/main.abc.js" }
243
+ *
244
+ * Dinamik import'lar da `entryPoint` taşır; yalnızca gerçek entry'ler
245
+ * manifest'e girer, yoksa her island ayrı bir manifest anahtarı olurdu.
246
+ *
247
+ * @param {esbuild.Metafile} metafile
248
+ * @param {import('../../config/index.js').ResolvedConfig} config
249
+ * @param {string} entryRoot
250
+ * @returns {Record<string, string>}
251
+ */
252
+ function toManifest(metafile, config, entryRoot) {
253
+ /** @type {Record<string, string>} */
254
+ const manifest = {};
255
+
256
+ for (const [outputPath, output] of Object.entries(metafile.outputs)) {
257
+ if (!output.entryPoint?.startsWith(entryRoot)) continue;
258
+
259
+ const name = `${path.basename(output.entryPoint, ".js")}.js`;
260
+ const absolute = path.resolve(config.root, outputPath);
261
+ manifest[name] = `/${path
262
+ .relative(config.dirs.public, absolute)
263
+ .split(path.sep)
264
+ .join("/")}`;
265
+ }
266
+
267
+ return manifest;
268
+ }