@stacksjs/stx 0.2.190 → 0.2.192
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 +55 -55
- package/dist/types/config-types.d.ts +11 -0
- package/dist/utils.js +16 -2
- 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
|
@@ -577,7 +577,8 @@ ${triedPaths.map((p) => ` - ${p}`).join(`
|
|
|
577
577
|
"__originalFilePath",
|
|
578
578
|
"__importedComponents",
|
|
579
579
|
COMPONENT_CLIENT_FACTORIES_CONTEXT_KEY,
|
|
580
|
-
"__stx_client_signal_names"
|
|
580
|
+
"__stx_client_signal_names",
|
|
581
|
+
"__stxServeContext"
|
|
581
582
|
]), filteredParentContext = {};
|
|
582
583
|
for (const [key, val] of Object.entries(parentContext))
|
|
583
584
|
if (!key.startsWith("__") || internalKeysToPreserve.has(key))
|
|
@@ -823,7 +824,7 @@ export async function resolveTemplatePath(templatePath, currentFilePath, options
|
|
|
823
824
|
const safeUnderCwd = assertInsideRoot(result, process.cwd());
|
|
824
825
|
if (safeUnderCwd)
|
|
825
826
|
return safeUnderCwd;
|
|
826
|
-
const trustedDirs = [options.root, options.layoutsDir, options.componentsDir, options.partialsDir, options.pagesDir].filter((d) => typeof d === "string" && d.length > 0);
|
|
827
|
+
const trustedDirs = [options.root, options.layoutsDir, options.fallbackLayoutsDir, options.componentsDir, options.partialsDir, options.pagesDir].filter((d) => typeof d === "string" && d.length > 0);
|
|
827
828
|
for (const dir of trustedDirs) {
|
|
828
829
|
const resolvedDir = path.isAbsolute(dir) ? dir : path.resolve(process.cwd(), dir);
|
|
829
830
|
if (assertInsideRoot(result, resolvedDir))
|
|
@@ -892,6 +893,19 @@ async function resolveTemplatePathInner(templatePath, currentFilePath, options,
|
|
|
892
893
|
if (found)
|
|
893
894
|
return found;
|
|
894
895
|
}
|
|
896
|
+
if (options.fallbackLayoutsDir) {
|
|
897
|
+
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)];
|
|
898
|
+
if (!templatePath.endsWith(".stx"))
|
|
899
|
+
candidates.push(`${candidates[0]}.stx`);
|
|
900
|
+
for (const candidate of candidates)
|
|
901
|
+
if (await fileExists(candidate)) {
|
|
902
|
+
if (options.debug)
|
|
903
|
+
console.log(`Found in options.fallbackLayoutsDir: ${candidate}`);
|
|
904
|
+
if (dependencies)
|
|
905
|
+
dependencies.add(candidate);
|
|
906
|
+
return candidate;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
895
909
|
if (templatePath.startsWith("layouts/") || templatePath.includes("/layouts/")) {
|
|
896
910
|
const parts = templatePath.split("layouts/"), layoutsPath = path.join(options.partialsDir || dirPath, "layouts", parts[1]);
|
|
897
911
|
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.192",
|
|
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.192",
|
|
121
|
+
"@stacksjs/sanitizer": "0.2.192",
|
|
122
122
|
"@stacksjs/ts-i18n": "^0.1.11",
|
|
123
|
-
"bun-plugin-stx": "0.2.
|
|
123
|
+
"bun-plugin-stx": "0.2.192",
|
|
124
124
|
"bunfig": "^0.15.17",
|
|
125
|
-
"stx-router": "0.2.
|
|
125
|
+
"stx-router": "0.2.192",
|
|
126
126
|
"ts-broadcasting": "^0.0.9",
|
|
127
127
|
"ts-images": "^0.2.11",
|
|
128
128
|
"ts-syntax-highlighter": "^0.2.1"
|