jskelet 0.3.5 → 0.4.1
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 +34 -0
- 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 +94 -9
- package/docs/06-cache.md +62 -0
- package/docs/07-yapilandirma.md +7 -5
- 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 +96 -12
- package/docs/en/06-caching.md +133 -71
- package/docs/en/07-configuration.md +5 -3
- 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 +17 -0
- package/src/compile/parse.js +485 -0
- package/src/compile/resolve.js +208 -0
- package/src/compile/scan-exports.js +51 -0
- package/src/config/defaults.js +6 -2
- package/src/config/index.js +7 -0
- package/src/dev-server.mjs +4 -2
- package/src/generate.mjs +163 -0
- package/src/init.mjs +8 -6
- package/src/server/render.js +153 -40
- package/src/server/router.js +26 -3
- package/src/views/components/loader.js +34 -18
|
@@ -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 = [
|
|
@@ -63,23 +60,42 @@ export async function loadComponents(dir) {
|
|
|
63
60
|
];
|
|
64
61
|
|
|
65
62
|
for (const file of files) {
|
|
66
|
-
const
|
|
63
|
+
const isBarrel = path.basename(file) === BARREL;
|
|
64
|
+
// Kimlik mutlak yol — çoklu components kökünde göreli ad çakışmasın.
|
|
65
|
+
const fileId = isBarrel ? BARREL : file.split(path.sep).join("/");
|
|
67
66
|
const module = await import(pathToFileURL(file).href);
|
|
68
67
|
|
|
69
68
|
for (const [name, value] of Object.entries(module)) {
|
|
70
69
|
if (name === "default") continue;
|
|
71
70
|
|
|
72
71
|
const previous = origin.get(name);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
// Barrel üzerine yazmak bilinçli; iki gerçek bileşen dosyası çakışması hata.
|
|
73
|
+
if (previous && previous !== BARREL && previous !== fileId) {
|
|
74
|
+
throw new Error(
|
|
75
|
+
`[components] '${name}' is defined twice: ${previous} and ${fileId}`,
|
|
76
76
|
);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
components[name] = value;
|
|
80
|
-
origin.set(name,
|
|
80
|
+
origin.set(name, fileId);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @param {string | string[]} dirs Tek dizin veya çoklu kök (feature/shared).
|
|
87
|
+
* @returns {Promise<Record<string, unknown>>}
|
|
88
|
+
*/
|
|
89
|
+
export async function loadComponents(dirs) {
|
|
90
|
+
/** @type {Record<string, unknown>} */
|
|
91
|
+
const components = {};
|
|
92
|
+
/** @type {Map<string, string>} */
|
|
93
|
+
const origin = new Map();
|
|
94
|
+
|
|
95
|
+
const list = Array.isArray(dirs) ? dirs : [dirs];
|
|
96
|
+
for (const dir of list) {
|
|
97
|
+
await loadDir(dir, components, origin);
|
|
98
|
+
}
|
|
83
99
|
|
|
84
100
|
return components;
|
|
85
101
|
}
|