jskelet 0.3.4 → 0.4.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/CHANGELOG.md +22 -6
- package/bin/jskelet.mjs +20 -7
- package/docs/02-mimari.md +3 -0
- package/docs/03-routing.md +19 -3
- package/docs/04-render-ve-sablonlar.md +60 -6
- package/docs/07-yapilandirma.md +17 -13
- package/docs/08-build.md +5 -0
- package/docs/en/02-architecture.md +3 -0
- package/docs/en/03-routing.md +19 -4
- package/docs/en/04-rendering.md +61 -9
- package/docs/en/07-configuration.md +14 -10
- package/docs/en/08-build.md +5 -0
- package/package.json +2 -2
- package/src/build/build.mjs +6 -0
- package/src/build/ensure-build.mjs +5 -1
- package/src/build/tasks/icons.mjs +2 -2
- package/src/build/tasks/templates.mjs +20 -0
- package/src/compile/codegen.js +332 -0
- package/src/compile/compile-all.js +158 -0
- package/src/compile/errors.js +66 -0
- package/src/compile/expr.js +404 -0
- package/src/compile/index.js +15 -0
- package/src/compile/parse.js +485 -0
- package/src/compile/resolve.js +159 -0
- package/src/config/defaults.js +7 -3
- package/src/config/index.js +71 -13
- package/src/dev-server.mjs +4 -2
- package/src/generate.mjs +163 -0
- package/src/init.mjs +8 -6
- package/src/server/logs/pipeline.js +6 -22
- package/src/server/render.js +153 -40
- package/src/server/router.js +26 -3
- package/src/views/components/loader.js +26 -13
package/src/server/router.js
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Sıra iki şekilde belirlenir:
|
|
11
11
|
* 1. `jskelet.config.mjs` → `routes: ["./routes/api.js", …]` (açık liste)
|
|
12
|
-
* 2. Liste yoksa `routes/`
|
|
13
|
-
*
|
|
12
|
+
* 2. Liste yoksa `routes/` alfabetik taranır, ardından her feature'ın
|
|
13
|
+
* `index.js` dosyası alfabetik eklenir. Catch-all'lar için sayısal önek.
|
|
14
14
|
*
|
|
15
15
|
* Modül sözleşmesi: default export ya da `register` adlı named export,
|
|
16
16
|
* `(app, api) => void | Promise<void>` imzasıyla. `api` içinde `route`,
|
|
@@ -61,6 +61,29 @@ function discover(dir, out = []) {
|
|
|
61
61
|
return out;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
* `features/<name>/index.js` (veya `.mjs`) — feature-first kayıt noktası.
|
|
66
|
+
* @param {string} featuresDir
|
|
67
|
+
* @returns {string[]}
|
|
68
|
+
*/
|
|
69
|
+
function discoverFeatures(featuresDir) {
|
|
70
|
+
if (!featuresDir || !fs.existsSync(featuresDir)) return [];
|
|
71
|
+
|
|
72
|
+
return fs
|
|
73
|
+
.readdirSync(featuresDir, { withFileTypes: true })
|
|
74
|
+
.filter((e) => e.isDirectory())
|
|
75
|
+
.map((e) => e.name)
|
|
76
|
+
.sort((a, b) => a.localeCompare(b))
|
|
77
|
+
.flatMap((name) => {
|
|
78
|
+
const dir = path.join(featuresDir, name);
|
|
79
|
+
for (const file of ["index.js", "index.mjs"]) {
|
|
80
|
+
const full = path.join(dir, file);
|
|
81
|
+
if (fs.existsSync(full)) return [full];
|
|
82
|
+
}
|
|
83
|
+
return [];
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
64
87
|
/**
|
|
65
88
|
* Route dosyalarına geçilen framework yüzeyi.
|
|
66
89
|
*/
|
|
@@ -84,7 +107,7 @@ export async function registerRoutes(app) {
|
|
|
84
107
|
|
|
85
108
|
const files = config.routes
|
|
86
109
|
? config.routes.map((entry) => path.resolve(config.root, entry))
|
|
87
|
-
: discover(config.dirs.routes);
|
|
110
|
+
: [...discover(config.dirs.routes), ...discoverFeatures(config.dirs.features)];
|
|
88
111
|
|
|
89
112
|
if (!files.length) {
|
|
90
113
|
console.warn(
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `views/components/**`
|
|
3
|
-
*
|
|
4
|
-
* böylece `<%- card({ … }) %>` gibi çağrılar import gerektirmeden çalışır.
|
|
2
|
+
* `views/components/**` (ve feature/shared köklerindeki eşleri) altındaki
|
|
3
|
+
* tüm modülleri yükler ve named export'larını tek bir nesnede birleştirir.
|
|
5
4
|
*
|
|
6
5
|
* Elle bakılan bir barrel dosyası yok: yeni bir bileşen eklemek için dosyayı
|
|
7
6
|
* oluşturmak yeterli.
|
|
@@ -44,17 +43,15 @@ function collect(dir, out = []) {
|
|
|
44
43
|
}
|
|
45
44
|
|
|
46
45
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* @
|
|
46
|
+
* Tek bir `components/` dizinini yükler.
|
|
47
|
+
*
|
|
48
|
+
* @param {string} dir
|
|
49
|
+
* @param {Record<string, unknown>} components
|
|
50
|
+
* @param {Map<string, string>} origin
|
|
51
|
+
* @returns {Promise<void>}
|
|
50
52
|
*/
|
|
51
|
-
|
|
52
|
-
if (!dir || !fs.existsSync(dir)) return
|
|
53
|
-
|
|
54
|
-
/** @type {Record<string, unknown>} */
|
|
55
|
-
const components = {};
|
|
56
|
-
/** @type {Map<string, string>} */
|
|
57
|
-
const origin = new Map();
|
|
53
|
+
async function loadDir(dir, components, origin) {
|
|
54
|
+
if (!dir || !fs.existsSync(dir)) return;
|
|
58
55
|
|
|
59
56
|
const barrel = path.join(dir, BARREL);
|
|
60
57
|
const files = [
|
|
@@ -80,6 +77,22 @@ export async function loadComponents(dir) {
|
|
|
80
77
|
origin.set(name, relative);
|
|
81
78
|
}
|
|
82
79
|
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* @param {string | string[]} dirs Tek dizin veya çoklu kök (feature/shared).
|
|
84
|
+
* @returns {Promise<Record<string, unknown>>}
|
|
85
|
+
*/
|
|
86
|
+
export async function loadComponents(dirs) {
|
|
87
|
+
/** @type {Record<string, unknown>} */
|
|
88
|
+
const components = {};
|
|
89
|
+
/** @type {Map<string, string>} */
|
|
90
|
+
const origin = new Map();
|
|
91
|
+
|
|
92
|
+
const list = Array.isArray(dirs) ? dirs : [dirs];
|
|
93
|
+
for (const dir of list) {
|
|
94
|
+
await loadDir(dir, components, origin);
|
|
95
|
+
}
|
|
83
96
|
|
|
84
97
|
return components;
|
|
85
98
|
}
|