@reqvire-org/ads-guard 0.0.0 → 0.5.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/LICENSE +21 -0
- package/README.md +145 -4
- package/dist/chunk-qm6jh9dj.mjs +642 -0
- package/dist/cli.mjs +57 -0
- package/dist/index.mjs +18 -0
- package/dist/types/analysis/compiler-options.d.mts +12 -0
- package/dist/types/analysis/context.d.mts +46 -0
- package/dist/types/analysis/design-usage.d.mts +72 -0
- package/dist/types/analysis/module-resolvers.d.mts +12 -0
- package/dist/types/analysis/semantic.d.mts +87 -0
- package/dist/types/analysis/syntax.d.mts +498 -0
- package/dist/types/design-usage.d.mts +33 -0
- package/dist/types/guard/config.d.mts +20 -0
- package/dist/types/guard/files.d.mts +16 -0
- package/dist/types/guard/index.d.mts +6 -0
- package/dist/types/guard/run.d.mts +20 -0
- package/dist/types/prose-model.d.mts +81 -0
- package/dist/types/result.d.mts +34 -0
- package/dist/types/unknown.d.mts +9 -0
- package/package.json +30 -4
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/** A prose element's name in a recipe, with the tags it selects. */
|
|
2
|
+
export declare const PROSE_ELEMENTS: {
|
|
3
|
+
readonly paragraph: readonly ["p"];
|
|
4
|
+
readonly heading1: readonly ["h1"];
|
|
5
|
+
readonly heading2: readonly ["h2"];
|
|
6
|
+
readonly heading3: readonly ["h3"];
|
|
7
|
+
readonly heading4: readonly ["h4"];
|
|
8
|
+
readonly heading5: readonly ["h5"];
|
|
9
|
+
readonly heading6: readonly ["h6"];
|
|
10
|
+
readonly list: readonly ["ul", "ol"];
|
|
11
|
+
readonly item: readonly ["li"];
|
|
12
|
+
readonly quote: readonly ["blockquote"];
|
|
13
|
+
readonly rule: readonly ["hr"];
|
|
14
|
+
readonly pre: readonly ["pre"];
|
|
15
|
+
readonly table: readonly ["table"];
|
|
16
|
+
readonly headerCell: readonly ["th"];
|
|
17
|
+
readonly cell: readonly ["td"];
|
|
18
|
+
readonly figure: readonly ["figure"];
|
|
19
|
+
readonly caption: readonly ["figcaption"];
|
|
20
|
+
readonly media: readonly ["img", "video", "iframe"];
|
|
21
|
+
readonly descriptions: readonly ["dl"];
|
|
22
|
+
readonly term: readonly ["dt"];
|
|
23
|
+
readonly definition: readonly ["dd"];
|
|
24
|
+
readonly link: readonly ["a"];
|
|
25
|
+
readonly strong: readonly ["strong", "b"];
|
|
26
|
+
readonly emphasis: readonly ["em", "i"];
|
|
27
|
+
readonly deleted: readonly ["del", "s"];
|
|
28
|
+
readonly code: readonly ["code"];
|
|
29
|
+
readonly sub: readonly ["sub"];
|
|
30
|
+
readonly sup: readonly ["sup"];
|
|
31
|
+
readonly kbd: readonly ["kbd"];
|
|
32
|
+
readonly mark: readonly ["mark"];
|
|
33
|
+
};
|
|
34
|
+
export type ProseElementName = keyof typeof PROSE_ELEMENTS;
|
|
35
|
+
export declare const PROSE_ELEMENT_NAMES: readonly ProseElementName[];
|
|
36
|
+
/** Every tag prose styles, with the element it belongs to. */
|
|
37
|
+
export declare const PROSE_TAGS: ReadonlyMap<string, ProseElementName>;
|
|
38
|
+
/**
|
|
39
|
+
* Tags that carry no design of their own but are part of content: a table's row groups and rows belong
|
|
40
|
+
* to its `table` element, and a line break belongs to any prose. The markup checks accept them as
|
|
41
|
+
* content; no rule is written for them.
|
|
42
|
+
*/
|
|
43
|
+
export declare const PROSE_STRUCTURE: ReadonlyMap<string, ProseElementName | null>;
|
|
44
|
+
/** Whether a tag can be content of a prose owner: a styled tag or a structural one. */
|
|
45
|
+
export declare const isProseTag: (tag: string) => boolean;
|
|
46
|
+
/** The content tags a recipe that declares `names` accepts: their own tags, and the structure that comes with them. */
|
|
47
|
+
export declare function proseContentTags(names: Iterable<ProseElementName>): ReadonlySet<string>;
|
|
48
|
+
/** Elements that stand as blocks in the flow: they take the rhythm before them. */
|
|
49
|
+
export declare const PROSE_BLOCKS: readonly ProseElementName[];
|
|
50
|
+
/** The elements whose text can sit directly inside `container`: what its background must carry. */
|
|
51
|
+
export declare function proseContents(container: ProseElementName): readonly ProseElementName[];
|
|
52
|
+
/** The selector of one tag inside the prose root: plain markup only. */
|
|
53
|
+
export declare const proseSelector: (tag: string) => string;
|
|
54
|
+
/** `&:hover` on an element's selector: the state is the element's own. */
|
|
55
|
+
export declare const proseState: (selector: string, condition: string) => string;
|
|
56
|
+
/** The first plain element of the root and of a plain container: its start margin is cancelled. */
|
|
57
|
+
export declare const PROSE_FIRST: readonly string[];
|
|
58
|
+
/**
|
|
59
|
+
* A component placed directly in the prose root (it has a class) is a block of the flow like any
|
|
60
|
+
* other: it takes the rhythm before it, unless it comes first. Space between siblings is the
|
|
61
|
+
* container's to give; the component's own design is untouched. A component inside a paragraph or
|
|
62
|
+
* another plain element is inline content and is left alone.
|
|
63
|
+
*/
|
|
64
|
+
export declare const PROSE_COMPONENT = "& > :not(:first-child)[class]";
|
|
65
|
+
type Values = Readonly<Record<string, string>>;
|
|
66
|
+
/**
|
|
67
|
+
* The browser defaults ADS replaces on an element, whatever the recipe declares for it: margins
|
|
68
|
+
* (the rhythm owns the space between blocks), a quote's and a figure's indent, a rule's inset border,
|
|
69
|
+
* media wider than its column, a table's doubled borders.
|
|
70
|
+
*/
|
|
71
|
+
export declare function proseDefaults(name: ProseElementName): Values;
|
|
72
|
+
/**
|
|
73
|
+
* The emitted record of a design system's prose owners, beside its public entry: exported name → the
|
|
74
|
+
* plain tags its recipe declares. The design-use check of application source reads it, because an
|
|
75
|
+
* emitted owner no longer carries its recipe.
|
|
76
|
+
*/
|
|
77
|
+
export declare const PROSE_MANIFEST = "ads-prose.json";
|
|
78
|
+
export declare const proseManifestText: (owners: ReadonlyMap<string, ReadonlySet<string>>) => string;
|
|
79
|
+
/** The owners a manifest text records; entries that are not a list of prose tags are dropped. */
|
|
80
|
+
export declare function parseProseManifest(text: string): ReadonlyMap<string, ReadonlySet<string>>;
|
|
81
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** A success or a typed failure. Failures are values, not thrown control flow. */
|
|
2
|
+
export type Result<T, E> = Ok<T> | Err<E>;
|
|
3
|
+
export interface Ok<T> {
|
|
4
|
+
readonly kind: "ok";
|
|
5
|
+
readonly value: T;
|
|
6
|
+
}
|
|
7
|
+
export interface Err<E> {
|
|
8
|
+
readonly kind: "err";
|
|
9
|
+
readonly error: E;
|
|
10
|
+
}
|
|
11
|
+
export declare const ok: <T>(value: T) => Ok<T>;
|
|
12
|
+
export declare const err: <E>(error: E) => Err<E>;
|
|
13
|
+
/** Exhaustiveness guard for `switch` over a discriminated union. */
|
|
14
|
+
export declare function assertNever(value: never, context: string): never;
|
|
15
|
+
/** Collects successes in order; returns the first failure unchanged. */
|
|
16
|
+
export declare function collect<T, E>(results: Iterable<Result<T, E>>): Result<readonly T[], E>;
|
|
17
|
+
/** Maps a success, leaving a failure unchanged. */
|
|
18
|
+
export declare function map<T, U, E>(result: Result<T, E>, transform: (value: T) => U): Result<U, E>;
|
|
19
|
+
/** Maps a failure, leaving a success unchanged. */
|
|
20
|
+
export declare function mapErr<T, E, F>(result: Result<T, E>, transform: (error: E) => F): Result<T, F>;
|
|
21
|
+
/** Stops the enclosing {@link attempt} with a typed failure. */
|
|
22
|
+
export type Reject<E> = (failure: E) => never;
|
|
23
|
+
/**
|
|
24
|
+
* Runs deeply nested validation that stops at its first failure, returning that
|
|
25
|
+
* failure as a value. The rejection is private to this call: an unrelated
|
|
26
|
+
* exception, or a rejection from another attempt, propagates unchanged.
|
|
27
|
+
*/
|
|
28
|
+
export declare function attempt<T, E>(run: (reject: Reject<E>) => T): Result<T, E>;
|
|
29
|
+
/** {@link attempt} for asynchronous work. */
|
|
30
|
+
export declare function attemptAsync<T, E>(run: (reject: Reject<E>) => Promise<T>): Promise<Result<T, E>>;
|
|
31
|
+
/** Unwraps a result inside an {@link attempt}, translating its failure. */
|
|
32
|
+
export declare function unwrapOr<T, E, F>(result: Result<T, E>, reject: Reject<F>, translate: (error: E) => F): T;
|
|
33
|
+
/** Message of an unknown thrown value, without assuming it is an Error. */
|
|
34
|
+
export declare function thrownMessage(thrown: unknown): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** A plain object (not an array or a Map). */
|
|
2
|
+
export declare const isRecord: (value: unknown) => value is Readonly<Record<string, unknown>>;
|
|
3
|
+
export type ExportKind = "function" | "object" | "string";
|
|
4
|
+
/**
|
|
5
|
+
* Verifies a loaded module (an object, or a CommonJS function export) and its named exports (and an optional structural check),
|
|
6
|
+
* then returns it under its declared shape. A mismatch is a defect: the
|
|
7
|
+
* boundary's declaration and the module disagree.
|
|
8
|
+
*/
|
|
9
|
+
export declare function checkedModule<T extends object>(module: unknown, label: string, exports: Readonly<Record<keyof T & string, ExportKind>>, valid?: (module: object) => boolean): T;
|
package/package.json
CHANGED
|
@@ -1,13 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reqvire-org/ads-guard",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.5.1",
|
|
4
|
+
"description": "Confirms that an application's source does no design of its own and uses its ADS design system only.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/reqvire-org/ads.git",
|
|
8
8
|
"directory": "packages/ads-guard"
|
|
9
9
|
},
|
|
10
|
+
"homepage": "https://github.com/reqvire-org/ads/tree/main/packages/ads-guard#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/reqvire-org/ads/issues"
|
|
13
|
+
},
|
|
10
14
|
"license": "MIT",
|
|
11
|
-
"
|
|
12
|
-
"
|
|
15
|
+
"type": "module",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=22.12.0"
|
|
18
|
+
},
|
|
19
|
+
"bin": {
|
|
20
|
+
"ads-guard": "./dist/cli.mjs"
|
|
21
|
+
},
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/types/guard/index.d.mts",
|
|
25
|
+
"default": "./dist/index.mjs"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"README.md",
|
|
31
|
+
"LICENSE"
|
|
32
|
+
],
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"typescript": "7.1.0-beta"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
}
|
|
13
39
|
}
|