@stacksjs/stx 0.2.99 → 0.2.100
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/README.md +1 -1
- package/dist/cli.js +550 -550
- package/dist/client-script-bundler.js +3 -2
- package/dist/component-processing.js +5 -2
- package/dist/component-renderer.js +2 -0
- package/dist/config.js +16 -1
- package/dist/dev-server/crosswind.js +2 -1
- package/dist/dev-server/serve-app.js +4 -3
- package/dist/dev-server/serve-file.js +2 -1
- package/dist/dev-server/serve-multi.js +2 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/pwa.js +281 -281
- package/dist/ssg.js +269 -269
- package/dist/state-dir.d.ts +36 -0
- package/dist/state-dir.js +22 -0
- package/dist/story/docs-generator.js +2 -1
- package/dist/story/snapshots.js +2 -1
- package/dist/story/testing.js +2 -1
- package/dist/story/visual-testing.js +3 -2
- package/dist/types/config-types.d.ts +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Records the `stateDir` coming from `stx.config.ts`.
|
|
3
|
+
*
|
|
4
|
+
* Called by the config loader. A nullish or blank value clears it, so a config
|
|
5
|
+
* without `stateDir` cannot inherit a stale value from a previously loaded one
|
|
6
|
+
* (the dev server loads a config per app directory).
|
|
7
|
+
*/
|
|
8
|
+
export declare function setStateDir(dir?: string | null): void;
|
|
9
|
+
/**
|
|
10
|
+
* The configured state directory, as written — relative or absolute.
|
|
11
|
+
*/
|
|
12
|
+
export declare function stateDirName(): string;
|
|
13
|
+
/**
|
|
14
|
+
* Absolute path to a file or directory inside the state directory.
|
|
15
|
+
*
|
|
16
|
+
* An absolute state directory wins over `root`, so a framework can pin every
|
|
17
|
+
* cache to one place no matter which directory a given code path happens to
|
|
18
|
+
* resolve against.
|
|
19
|
+
*/
|
|
20
|
+
export declare function stateDir(root?: string, ...segments: string[]): string;
|
|
21
|
+
/**
|
|
22
|
+
* Rewrites a config path that still carries the default `.stx/` prefix onto the
|
|
23
|
+
* configured state directory.
|
|
24
|
+
*
|
|
25
|
+
* The path-shaped config options (`cachePath`, `build.cacheDir`,
|
|
26
|
+
* `media.cache.directory`, `story.outDir`) default to somewhere under `.stx/`.
|
|
27
|
+
* Rather than make each one separately configurable, `stateDir` moves the whole
|
|
28
|
+
* family: anything under the default prefix follows it, and a path the user
|
|
29
|
+
* pointed somewhere else entirely is left alone.
|
|
30
|
+
*/
|
|
31
|
+
export declare function rebaseOntoStateDir(value: string): string;
|
|
32
|
+
export declare function rebaseOntoStateDir(value: string | undefined): string | undefined;
|
|
33
|
+
/** The directory used when nothing configures one. */
|
|
34
|
+
export declare const DEFAULT_STATE_DIR: '.stx';
|
|
35
|
+
/** Environment variable that overrides both the config and the default. */
|
|
36
|
+
export declare const STATE_DIR_ENV_VAR: 'STX_DIR';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
export const DEFAULT_STATE_DIR = ".stx", STATE_DIR_ENV_VAR = "STX_DIR";
|
|
3
|
+
let configuredStateDir = null;
|
|
4
|
+
export function setStateDir(dir) {
|
|
5
|
+
configuredStateDir = dir?.trim() || null;
|
|
6
|
+
}
|
|
7
|
+
export function stateDirName() {
|
|
8
|
+
return process.env[STATE_DIR_ENV_VAR]?.trim() || configuredStateDir || DEFAULT_STATE_DIR;
|
|
9
|
+
}
|
|
10
|
+
export function stateDir(root = process.cwd(), ...segments) {
|
|
11
|
+
const dir = stateDirName();
|
|
12
|
+
return path.isAbsolute(dir) ? path.join(dir, ...segments) : path.join(root, dir, ...segments);
|
|
13
|
+
}
|
|
14
|
+
export function rebaseOntoStateDir(value) {
|
|
15
|
+
if (!value || path.isAbsolute(value))
|
|
16
|
+
return value;
|
|
17
|
+
const normalized = value.replace(/\\/g, "/");
|
|
18
|
+
if (normalized !== DEFAULT_STATE_DIR && !normalized.startsWith(`${DEFAULT_STATE_DIR}/`))
|
|
19
|
+
return value;
|
|
20
|
+
const suffix = normalized.slice(DEFAULT_STATE_DIR.length + 1);
|
|
21
|
+
return suffix ? path.join(stateDirName(), suffix) : stateDirName();
|
|
22
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { stateDir } from "../state-dir.js";
|
|
3
4
|
export async function generateStoryDocs(ctx, components, options = {}) {
|
|
4
|
-
const outDir = options.outDir ||
|
|
5
|
+
const outDir = options.outDir || stateDir(ctx.root, "docs");
|
|
5
6
|
await fs.promises.mkdir(outDir, { recursive: !0 });
|
|
6
7
|
const indexContent = generateDocsIndex(components);
|
|
7
8
|
await fs.promises.writeFile(path.join(outDir, "README.md"), indexContent);
|
package/dist/story/snapshots.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { stateDir } from "../state-dir.js";
|
|
3
4
|
export function getSnapshotDir(ctx) {
|
|
4
|
-
return
|
|
5
|
+
return stateDir(ctx.root, "story", "snapshots");
|
|
5
6
|
}
|
|
6
7
|
function getVersionFilePath(snapshotDir, storyId) {
|
|
7
8
|
return path.join(snapshotDir, `${storyId}.versions.json`);
|
package/dist/story/testing.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { checkA11y } from "../a11y.js";
|
|
4
|
+
import { stateDir } from "../state-dir.js";
|
|
4
5
|
export async function runVisualTests(ctx, options = {}) {
|
|
5
6
|
const startTime = Date.now(), result = {
|
|
6
7
|
total: 0,
|
|
@@ -9,7 +10,7 @@ export async function runVisualTests(ctx, options = {}) {
|
|
|
9
10
|
new: 0,
|
|
10
11
|
failures: [],
|
|
11
12
|
duration: 0
|
|
12
|
-
}, snapshotDir = options.snapshotDir ||
|
|
13
|
+
}, snapshotDir = options.snapshotDir || stateDir(ctx.root, "story", "snapshots");
|
|
13
14
|
await fs.promises.mkdir(snapshotDir, { recursive: !0 });
|
|
14
15
|
let storyFiles = ctx.storyFiles;
|
|
15
16
|
if (options.filter && options.filter.length > 0)
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { stateDir } from "../state-dir.js";
|
|
3
4
|
export async function runScreenshotTests(ctx, options = {}) {
|
|
4
5
|
const startTime = performance.now(), {
|
|
5
6
|
update = !1,
|
|
6
7
|
threshold = 0.1,
|
|
7
|
-
snapshotDir =
|
|
8
|
+
snapshotDir = stateDir(ctx.root, "story", "snapshots"),
|
|
8
9
|
width = 800,
|
|
9
10
|
height = 600,
|
|
10
11
|
deviceScaleFactor = 1,
|
|
@@ -85,7 +86,7 @@ export async function runScreenshotTests(ctx, options = {}) {
|
|
|
85
86
|
async function runHtmlComparisonTests(ctx, options) {
|
|
86
87
|
const startTime = performance.now(), {
|
|
87
88
|
update = !1,
|
|
88
|
-
snapshotDir =
|
|
89
|
+
snapshotDir = stateDir(ctx.root, "story", "snapshots"),
|
|
89
90
|
filter
|
|
90
91
|
} = options, result = {
|
|
91
92
|
total: 0,
|
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.100",
|
|
5
5
|
"description": "A performant UI Framework. Powered by Bun.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -117,16 +117,16 @@
|
|
|
117
117
|
"dependencies": {
|
|
118
118
|
"@cwcss/crosswind": "^0.2.6",
|
|
119
119
|
"@stacksjs/clapp": "^0.2.0",
|
|
120
|
-
"@stacksjs/sanitizer": "0.2.
|
|
120
|
+
"@stacksjs/sanitizer": "0.2.100",
|
|
121
121
|
"@stacksjs/ts-i18n": "^0.1.11",
|
|
122
|
-
"bun-plugin-stx": "0.2.
|
|
122
|
+
"bun-plugin-stx": "0.2.100",
|
|
123
123
|
"bunfig": "^0.15.15",
|
|
124
|
-
"stx-router": "0.2.
|
|
124
|
+
"stx-router": "0.2.100",
|
|
125
125
|
"ts-broadcasting": "^0.0.8",
|
|
126
126
|
"ts-images": "^0.1.9",
|
|
127
127
|
"ts-syntax-highlighter": "^0.2.1"
|
|
128
128
|
},
|
|
129
129
|
"optionalDependencies": {
|
|
130
|
-
"@stacksjs/desktop": "0.2.
|
|
130
|
+
"@stacksjs/desktop": "0.2.100"
|
|
131
131
|
}
|
|
132
132
|
}
|