@nan0web/ui 1.12.1 → 1.12.3
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 +18 -345
- package/package.json +13 -8
- package/src/Model/index.js +2 -2
- package/src/core/GeneratorRunner.js +8 -0
- package/src/core/resolvePositionalArgs.js +51 -0
- package/src/domain/Content.js +5 -5
- package/src/domain/Document.js +1 -1
- package/src/domain/HeroModel.js +1 -1
- package/src/domain/ModelAsApp.js +310 -20
- package/src/domain/ModelAsApp.story.js +117 -0
- package/src/domain/app/GalleryCommand.js +9 -8
- package/src/domain/app/{GalleryRenderIntent.js → GalleryRenderCommand.js} +20 -20
- package/src/domain/app/SnapshotAuditor.js +81 -85
- package/src/domain/app/SnapshotRunner.js +1 -1
- package/src/domain/app/UIApp.js +12 -21
- package/src/index.js +4 -2
- package/src/inspect.js +1 -0
- package/src/testing/SnapshotRunner.js +2 -1
- package/src/testing/SpecRunner.js +37 -0
- package/types/Model/index.d.ts +2 -2
- package/types/core/resolvePositionalArgs.d.ts +24 -0
- package/types/docs/README.md.d.ts +1 -0
- package/types/domain/Content.d.ts +2 -2
- package/types/domain/Document.d.ts +2 -2
- package/types/domain/HeroModel.d.ts +2 -2
- package/types/domain/ModelAsApp.d.ts +49 -5
- package/types/domain/ModelAsApp.story.d.ts +1 -0
- package/types/domain/app/GalleryCommand.d.ts +6 -37
- package/types/domain/app/GalleryRenderCommand.d.ts +27 -0
- package/types/domain/app/SnapshotAuditor.d.ts +33 -23
- package/types/domain/app/SnapshotRunner.d.ts +2 -2
- package/types/domain/app/UIApp.d.ts +14 -11
- package/types/index.d.ts +4 -2
- package/types/inspect.d.ts +1 -0
- package/types/testing/SpecRunner.d.ts +22 -0
- package/types/testing/verifySnapshot.d.ts +1 -1
- package/types/domain/app/GalleryRenderIntent.d.ts +0 -31
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export class GalleryRenderCommand extends ModelAsApp {
|
|
2
|
+
static alias: string;
|
|
3
|
+
static UI: {
|
|
4
|
+
rendering: string;
|
|
5
|
+
success: string;
|
|
6
|
+
failed: string;
|
|
7
|
+
};
|
|
8
|
+
static dataDir: {
|
|
9
|
+
type: string;
|
|
10
|
+
default: string;
|
|
11
|
+
help: string;
|
|
12
|
+
};
|
|
13
|
+
static dir: {
|
|
14
|
+
type: string;
|
|
15
|
+
default: string;
|
|
16
|
+
help: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* @param {Partial<GalleryRenderCommand> | Record<string, any>} [data={}]
|
|
20
|
+
* @param {Partial<import('@nan0web/types').ModelOptions>} [options={}]
|
|
21
|
+
*/
|
|
22
|
+
constructor(data?: Partial<GalleryRenderCommand> | Record<string, any>, options?: Partial<import("@nan0web/types").ModelOptions>);
|
|
23
|
+
/** @type {string} */ dataDir: string;
|
|
24
|
+
/** @type {string} */ dir: string;
|
|
25
|
+
}
|
|
26
|
+
export default GalleryRenderCommand;
|
|
27
|
+
import { ModelAsApp } from '../index.js';
|
|
@@ -1,25 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* SnapshotAuditor — Zero-Hallucination Snapshot Validation (Model-as-Schema v2).
|
|
3
3
|
* Parses snapshots without evaluating the app logic and detects artifacts.
|
|
4
|
-
*
|
|
5
|
-
* @extends {AuditorModel}
|
|
6
4
|
*/
|
|
7
|
-
export class SnapshotAuditor {
|
|
5
|
+
export class SnapshotAuditor extends AuditorModel {
|
|
8
6
|
static alias: string;
|
|
9
|
-
static dir: {
|
|
10
|
-
type: string;
|
|
11
|
-
help: string;
|
|
12
|
-
positional: boolean;
|
|
13
|
-
default: string;
|
|
14
|
-
};
|
|
15
7
|
static data: {
|
|
16
8
|
type: string;
|
|
17
9
|
help: string;
|
|
18
10
|
default: string;
|
|
19
11
|
};
|
|
20
|
-
/** @type {Object<string, string>} Messages for UI */
|
|
21
12
|
static UI: {
|
|
22
|
-
|
|
13
|
+
title: string;
|
|
14
|
+
description: string;
|
|
15
|
+
icon: string;
|
|
16
|
+
starting: string;
|
|
17
|
+
noSnapshots: string;
|
|
18
|
+
doneSuccess: string;
|
|
19
|
+
doneErrors: string;
|
|
20
|
+
auditPassed: string;
|
|
21
|
+
auditFailed: string;
|
|
22
|
+
errorDb: string;
|
|
23
|
+
errorGlitch: string;
|
|
24
|
+
errorShort: string;
|
|
25
|
+
errorSyntax: string;
|
|
26
|
+
errorArtifact: string;
|
|
27
|
+
errorRouting: string;
|
|
28
|
+
errorUntranslated: string;
|
|
29
|
+
errorEnglishLeak: string;
|
|
30
|
+
errorEmptyRender: string;
|
|
31
|
+
errorForeignLeak: string;
|
|
23
32
|
};
|
|
24
33
|
/** @type {string[]} Common UI components that can be empty in render */
|
|
25
34
|
static EXEMPT_EMPTY: string[];
|
|
@@ -31,6 +40,14 @@ export class SnapshotAuditor {
|
|
|
31
40
|
static SUSPICIOUS_FILENAME: RegExp;
|
|
32
41
|
/** @type {number} Minimum filename length */
|
|
33
42
|
static MIN_FILENAME_LENGTH: number;
|
|
43
|
+
/** @type {string[]} Directories to ignore during scanning */
|
|
44
|
+
static IGNORE_DIRS: string[];
|
|
45
|
+
/**
|
|
46
|
+
* Checks if a directory or file should be ignored.
|
|
47
|
+
* @param {string} name
|
|
48
|
+
* @returns {boolean}
|
|
49
|
+
*/
|
|
50
|
+
static isIgnored(name: string): boolean;
|
|
34
51
|
/**
|
|
35
52
|
* Extracts all valid words from an object into a Set.
|
|
36
53
|
* @param {any} obj Node to extract from.
|
|
@@ -39,11 +56,11 @@ export class SnapshotAuditor {
|
|
|
39
56
|
static extractWords(obj: any, set: Set<string>): void;
|
|
40
57
|
/**
|
|
41
58
|
* Scans data directories to build a word set for each language.
|
|
42
|
-
* @param {
|
|
59
|
+
* @param {import('@nan0web/db').DB} fsDb FileSystem DB.
|
|
43
60
|
* @param {string} data
|
|
44
61
|
* @returns {Promise<Record<string, Set<string>>>}
|
|
45
62
|
*/
|
|
46
|
-
static buildDictionaries(fsDb:
|
|
63
|
+
static buildDictionaries(fsDb: import("@nan0web/db").DB, data?: string): Promise<Record<string, Set<string>>>;
|
|
47
64
|
/**
|
|
48
65
|
* Inspects a single snapshot text.
|
|
49
66
|
* @param {string} content Content of the file.
|
|
@@ -83,17 +100,10 @@ export class SnapshotAuditor {
|
|
|
83
100
|
}): void;
|
|
84
101
|
/**
|
|
85
102
|
* @param {Partial<SnapshotAuditor> | Record<string, any>} [data={}]
|
|
86
|
-
* @param {Partial<import('@nan0web/
|
|
103
|
+
* @param {Partial<import('@nan0web/ui').ModelAsAppOptions>} [options={}]
|
|
87
104
|
*/
|
|
88
|
-
constructor(data?: Partial<SnapshotAuditor> | Record<string, any>, options?: Partial<import("@nan0web/
|
|
89
|
-
/** @type {import('@nan0web/types').ModelOptions} */
|
|
90
|
-
options: import("@nan0web/types").ModelOptions;
|
|
91
|
-
/** @type {string} Target directory to audit */ dir: string;
|
|
105
|
+
constructor(data?: Partial<SnapshotAuditor> | Record<string, any>, options?: Partial<import("@nan0web/ui").ModelAsAppOptions>);
|
|
92
106
|
/** @type {string} Directory to scan for dictionaries */ data: string;
|
|
93
|
-
/**
|
|
94
|
-
* Run the snapshot audit inside the target directory.
|
|
95
|
-
* @returns {AsyncGenerator<import('@nan0web/ui').Intent, any, any>}
|
|
96
|
-
*/
|
|
97
|
-
run(): AsyncGenerator<import("@nan0web/ui").Intent, any, any>;
|
|
98
107
|
}
|
|
99
108
|
export default SnapshotAuditor;
|
|
109
|
+
import { AuditorModel } from '@nan0web/inspect/domain/AuditorModel';
|
|
@@ -26,9 +26,9 @@ export class SnapshotRunner extends Model {
|
|
|
26
26
|
};
|
|
27
27
|
/**
|
|
28
28
|
* @param {Partial<SnapshotRunner> | Record<string, any>} [data={}]
|
|
29
|
-
* @param {import('@nan0web/types').ModelOptions} [options={}]
|
|
29
|
+
* @param {Partial<import('@nan0web/types').ModelOptions>} [options={}]
|
|
30
30
|
*/
|
|
31
|
-
constructor(data?: Partial<SnapshotRunner> | Record<string, any>, options?: import("@nan0web/types").ModelOptions);
|
|
31
|
+
constructor(data?: Partial<SnapshotRunner> | Record<string, any>, options?: Partial<import("@nan0web/types").ModelOptions>);
|
|
32
32
|
/** @type {string} Directory containing snapshots */ snapshotsDir: string;
|
|
33
33
|
/** @type {string} Root data directory */ data: string;
|
|
34
34
|
/** @type {(compName: string) => string} */ getCategory: (compName: string) => string;
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @property {string[]} _positionals
|
|
3
|
+
* @property {string} command Type of command to run
|
|
4
|
+
* @property {boolean} help Show help message
|
|
5
|
+
*/
|
|
1
6
|
export class UIApp extends ModelAsApp {
|
|
2
7
|
static command: {
|
|
3
8
|
type: string;
|
|
@@ -10,19 +15,12 @@ export class UIApp extends ModelAsApp {
|
|
|
10
15
|
helpText: string;
|
|
11
16
|
unknownCommand: string;
|
|
12
17
|
};
|
|
13
|
-
static help: {
|
|
14
|
-
help: string;
|
|
15
|
-
default: boolean;
|
|
16
|
-
};
|
|
17
18
|
/**
|
|
18
19
|
* @param {Partial<UIApp> | Record<string, any>} [data={}]
|
|
19
|
-
* @param {import('@nan0web/types').ModelOptions} [options={}]
|
|
20
|
+
* @param {Partial<import('@nan0web/types').ModelOptions>} [options={}]
|
|
20
21
|
*/
|
|
21
|
-
constructor(data?: Partial<UIApp> | Record<string, any>, options?: import("@nan0web/types").ModelOptions);
|
|
22
|
-
|
|
23
|
-
/** @type {string} Type of command to run */ command: string;
|
|
24
|
-
/** @type {boolean} Show help message */ help: boolean;
|
|
25
|
-
run(): AsyncGenerator<import("../../core/Intent.js").ShowIntent | import("../../core/Intent.js").RenderIntent | (import("../../core/Intent.js").AskIntent & {
|
|
22
|
+
constructor(data?: Partial<UIApp> | Record<string, any>, options?: Partial<import("@nan0web/types").ModelOptions>);
|
|
23
|
+
run(): AsyncGenerator<import("../../core/Intent.js").ShowIntent | (import("../../core/Intent.js").AskIntent & {
|
|
26
24
|
$value?: any;
|
|
27
25
|
$success?: boolean;
|
|
28
26
|
$files?: Record<string, string>;
|
|
@@ -37,6 +35,11 @@ export class UIApp extends ModelAsApp {
|
|
|
37
35
|
$success?: boolean;
|
|
38
36
|
$files?: Record<string, string>;
|
|
39
37
|
$message?: string;
|
|
38
|
+
}) | (import("../../core/Intent.js").RenderIntent & {
|
|
39
|
+
$value?: any;
|
|
40
|
+
$success?: boolean;
|
|
41
|
+
$files?: Record<string, string>;
|
|
42
|
+
$message?: string;
|
|
40
43
|
}) | (import("../../core/Intent.js").AgentIntent & {
|
|
41
44
|
$value?: any;
|
|
42
45
|
$success?: boolean;
|
|
@@ -47,7 +50,7 @@ export class UIApp extends ModelAsApp {
|
|
|
47
50
|
$success?: boolean;
|
|
48
51
|
$files?: Record<string, string>;
|
|
49
52
|
$message?: string;
|
|
50
|
-
}),
|
|
53
|
+
}), import("../../core/Intent.js").ResultIntent, any>;
|
|
51
54
|
}
|
|
52
55
|
export default UIApp;
|
|
53
56
|
import { ModelAsApp } from '../ModelAsApp.js';
|
package/types/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export { default as UiForm } from "./core/Form/Form.js";
|
|
|
9
9
|
export { default as UiMessage } from "./core/Message/Message.js";
|
|
10
10
|
export { default as UiStream } from "./core/Stream.js";
|
|
11
11
|
export { default as UiAdapter } from "./core/UiAdapter.js";
|
|
12
|
+
export { resolvePositionalArgs } from "./core/resolvePositionalArgs.js";
|
|
12
13
|
export * from "./core/Intent.js";
|
|
13
14
|
export * from "./domain/index.js";
|
|
14
15
|
export { IntentErrorModel } from "./core/IntentErrorModel.js";
|
|
@@ -39,8 +40,9 @@ import StdIn from './StdIn.js';
|
|
|
39
40
|
import StdOut from './StdOut.js';
|
|
40
41
|
import View from './View/View.js';
|
|
41
42
|
import RenderOptions from './View/RenderOptions.js';
|
|
42
|
-
import Model from '
|
|
43
|
+
import { Model } from '@nan0web/types';
|
|
44
|
+
import Models from './Model/index.js';
|
|
43
45
|
import Component from './Component/index.js';
|
|
44
46
|
import App from './App/index.js';
|
|
45
|
-
export { Frame, FrameProps, Locale, StdIn, StdOut, View, RenderOptions, Model, Component, App };
|
|
47
|
+
export { Frame, FrameProps, Locale, StdIn, StdOut, View, RenderOptions, Model, Models, Component, App };
|
|
46
48
|
export { default as Error, CancelError } from "./core/Error/index.js";
|
package/types/inspect.d.ts
CHANGED
|
@@ -16,6 +16,28 @@ export class SpecRunner extends ModelAsApp {
|
|
|
16
16
|
running: string;
|
|
17
17
|
unhandledSteps: string;
|
|
18
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* Convenience method to load a .nan0 file and run a specific scenario.
|
|
21
|
+
*
|
|
22
|
+
* 💡 Note on Expectations:
|
|
23
|
+
* You do NOT need to write manual assertions when using this method.
|
|
24
|
+
* The `for await (const _ of runner.run()) {}` loop drives the generator,
|
|
25
|
+
* but ALL assertions are handled automatically inside `SpecAdapter.js`.
|
|
26
|
+
*
|
|
27
|
+
* Whenever the App yields an intent (`ask`, `show`, `result`), `SpecAdapter`
|
|
28
|
+
* intercepts it and compares it strictly against the next step in the `.nan0` file.
|
|
29
|
+
* - If it matches, the test continues (and `$value` is injected back into the App).
|
|
30
|
+
* - If it mismatches, it throws an `assert.fail()` which fails the Node.js test immediately.
|
|
31
|
+
* - If the App finishes early, it throws an `unhandledSteps` error.
|
|
32
|
+
*
|
|
33
|
+
* @param {string} fileDir The directory containing the file (e.g., import.meta.dirname)
|
|
34
|
+
* @param {string} fileName The name of the .nan0 file
|
|
35
|
+
* @param {string} scenarioName The name of the scenario to run
|
|
36
|
+
* @param {Record<string, any>} registry The Model Class registry
|
|
37
|
+
* @param {Partial<import('../index.js').ModelAsAppOptions>} [options={}] Additional runner context options
|
|
38
|
+
* @throws {Error} If the scenario is missing or if expectations fail during execution
|
|
39
|
+
*/
|
|
40
|
+
static executeFile(fileDir: string, fileName: string, scenarioName: string, registry: Record<string, any>, options?: Partial<import("../index.js").ModelAsAppOptions>): Promise<void>;
|
|
19
41
|
/**
|
|
20
42
|
* Run a Nan0Spec sequence programmatically (for unit tests).
|
|
21
43
|
*
|
|
@@ -10,5 +10,5 @@ export function verifySnapshot({ name, data, fs, path }: {
|
|
|
10
10
|
name: string;
|
|
11
11
|
data: Array<any>;
|
|
12
12
|
fs?: typeof import("node:fs/promises") | undefined;
|
|
13
|
-
path?: import("path")
|
|
13
|
+
path?: typeof import("node:path") | undefined;
|
|
14
14
|
}): Promise<void>;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export class GalleryRenderIntent extends Model {
|
|
2
|
-
static alias: string;
|
|
3
|
-
static UI: {
|
|
4
|
-
rendering: string;
|
|
5
|
-
success: string;
|
|
6
|
-
failed: string;
|
|
7
|
-
};
|
|
8
|
-
static dataDir: {
|
|
9
|
-
type: string;
|
|
10
|
-
default: string;
|
|
11
|
-
help: string;
|
|
12
|
-
};
|
|
13
|
-
static dir: {
|
|
14
|
-
type: string;
|
|
15
|
-
default: string;
|
|
16
|
-
help: string;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
* @param {Partial<GalleryRenderIntent> | Record<string, any>} [data={}]
|
|
21
|
-
|
|
22
|
-
* @param {import('@nan0web/types').ModelOptions} [options={}]
|
|
23
|
-
|
|
24
|
-
*/
|
|
25
|
-
constructor(data?: Partial<GalleryRenderIntent> | Record<string, any>, options?: import("@nan0web/types").ModelOptions);
|
|
26
|
-
/** @type {string} */ dataDir: string;
|
|
27
|
-
/** @type {string} */ dir: string;
|
|
28
|
-
run(): AsyncGenerator<import("../../core/Intent.js").ShowIntent, import("../../core/Intent.js").ResultIntent | undefined, unknown>;
|
|
29
|
-
}
|
|
30
|
-
export default GalleryRenderIntent;
|
|
31
|
-
import { Model } from '@nan0web/types';
|