@stacksjs/stx 0.2.190 → 0.2.191
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/dist/cli.js +66 -66
- package/dist/craft.js +99 -99
- package/dist/process.js +11 -7
- package/dist/pwa.js +75 -75
- package/dist/ssg.js +54 -54
- package/dist/types/config-types.d.ts +11 -0
- package/dist/utils.js +14 -1
- package/package.json +5 -5
|
@@ -624,6 +624,17 @@ export interface StxConfig {
|
|
|
624
624
|
_rootComponentsDir?: string;
|
|
625
625
|
/** Path to layouts directory, defaults to 'layouts' in the project root */
|
|
626
626
|
layoutsDir?: string;
|
|
627
|
+
/**
|
|
628
|
+
* Where to look for a layout `layoutsDir` does not have.
|
|
629
|
+
*
|
|
630
|
+
* For a framework that ships default layouts and lets an app override them
|
|
631
|
+
* by name: the app's own directory is `layoutsDir` and wins, and anything it
|
|
632
|
+
* does not define falls back here. Without it, an app that overrides one
|
|
633
|
+
* layout has to vendor every other layout it uses, and a page extending a
|
|
634
|
+
* framework layout renders with NO layout at all - a 200 with an empty body,
|
|
635
|
+
* which is far harder to diagnose than a 404.
|
|
636
|
+
*/
|
|
637
|
+
fallbackLayoutsDir?: string;
|
|
627
638
|
/**
|
|
628
639
|
* Path to the stores directory, resolved against `root`.
|
|
629
640
|
*
|
package/dist/utils.js
CHANGED
|
@@ -823,7 +823,7 @@ export async function resolveTemplatePath(templatePath, currentFilePath, options
|
|
|
823
823
|
const safeUnderCwd = assertInsideRoot(result, process.cwd());
|
|
824
824
|
if (safeUnderCwd)
|
|
825
825
|
return safeUnderCwd;
|
|
826
|
-
const trustedDirs = [options.root, options.layoutsDir, options.componentsDir, options.partialsDir, options.pagesDir].filter((d) => typeof d === "string" && d.length > 0);
|
|
826
|
+
const trustedDirs = [options.root, options.layoutsDir, options.fallbackLayoutsDir, options.componentsDir, options.partialsDir, options.pagesDir].filter((d) => typeof d === "string" && d.length > 0);
|
|
827
827
|
for (const dir of trustedDirs) {
|
|
828
828
|
const resolvedDir = path.isAbsolute(dir) ? dir : path.resolve(process.cwd(), dir);
|
|
829
829
|
if (assertInsideRoot(result, resolvedDir))
|
|
@@ -892,6 +892,19 @@ async function resolveTemplatePathInner(templatePath, currentFilePath, options,
|
|
|
892
892
|
if (found)
|
|
893
893
|
return found;
|
|
894
894
|
}
|
|
895
|
+
if (options.fallbackLayoutsDir) {
|
|
896
|
+
const resolvedFallback = path.isAbsolute(options.fallbackLayoutsDir) ? options.fallbackLayoutsDir : path.resolve(process.cwd(), options.fallbackLayoutsDir), strippedPath = templatePath.startsWith("layouts/") ? templatePath.slice(8) : templatePath, candidates = [path.join(resolvedFallback, strippedPath)];
|
|
897
|
+
if (!templatePath.endsWith(".stx"))
|
|
898
|
+
candidates.push(`${candidates[0]}.stx`);
|
|
899
|
+
for (const candidate of candidates)
|
|
900
|
+
if (await fileExists(candidate)) {
|
|
901
|
+
if (options.debug)
|
|
902
|
+
console.log(`Found in options.fallbackLayoutsDir: ${candidate}`);
|
|
903
|
+
if (dependencies)
|
|
904
|
+
dependencies.add(candidate);
|
|
905
|
+
return candidate;
|
|
906
|
+
}
|
|
907
|
+
}
|
|
895
908
|
if (templatePath.startsWith("layouts/") || templatePath.includes("/layouts/")) {
|
|
896
909
|
const parts = templatePath.split("layouts/"), layoutsPath = path.join(options.partialsDir || dirPath, "layouts", parts[1]);
|
|
897
910
|
if (await fileExists(layoutsPath)) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/stx",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.191",
|
|
5
5
|
"description": "A performant UI Framework. Powered by Bun.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -117,12 +117,12 @@
|
|
|
117
117
|
"dependencies": {
|
|
118
118
|
"@cwcss/crosswind": "^0.2.14",
|
|
119
119
|
"@stacksjs/clapp": "^0.2.0",
|
|
120
|
-
"@stacksjs/desktop": "0.2.
|
|
121
|
-
"@stacksjs/sanitizer": "0.2.
|
|
120
|
+
"@stacksjs/desktop": "0.2.191",
|
|
121
|
+
"@stacksjs/sanitizer": "0.2.191",
|
|
122
122
|
"@stacksjs/ts-i18n": "^0.1.11",
|
|
123
|
-
"bun-plugin-stx": "0.2.
|
|
123
|
+
"bun-plugin-stx": "0.2.191",
|
|
124
124
|
"bunfig": "^0.15.17",
|
|
125
|
-
"stx-router": "0.2.
|
|
125
|
+
"stx-router": "0.2.191",
|
|
126
126
|
"ts-broadcasting": "^0.0.9",
|
|
127
127
|
"ts-images": "^0.2.11",
|
|
128
128
|
"ts-syntax-highlighter": "^0.2.1"
|