@adminiumjs/skin-kit 0.0.0-stage → 0.3.82
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 +44 -2
- package/dist/contract.d.ts +90 -0
- package/dist/contract.d.ts.map +1 -0
- package/dist/contract.js +216 -0
- package/dist/contract.js.map +1 -0
- package/dist/css.d.ts +51 -0
- package/dist/css.d.ts.map +1 -0
- package/dist/css.js +690 -0
- package/dist/css.js.map +1 -0
- package/dist/diff.d.ts +11 -0
- package/dist/diff.d.ts.map +1 -0
- package/dist/diff.js +122 -0
- package/dist/diff.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/loader.d.ts +92 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +199 -0
- package/dist/loader.js.map +1 -0
- package/dist/react.d.ts +87 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +346 -0
- package/dist/react.js.map +1 -0
- package/dist/testing.d.ts +39 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +107 -0
- package/dist/testing.js.map +1 -0
- package/dist/tokens.d.ts +149 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +367 -0
- package/dist/tokens.js.map +1 -0
- package/dist/validate.d.ts +154 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +621 -0
- package/dist/validate.js.map +1 -0
- package/dist/version.d.ts +22 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +41 -0
- package/dist/version.js.map +1 -0
- package/package.json +50 -4
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A SKIN PACKAGE'S `skin.json`, CHECKED AGAINST AN APP'S CONTRACT.
|
|
3
|
+
*
|
|
4
|
+
* The same function runs in the engine (when the package is attached and each
|
|
5
|
+
* time the shop's config is served) and in the shopper's browser (before a
|
|
6
|
+
* block is drawn), so Studio can say what the browser would refuse.
|
|
7
|
+
*
|
|
8
|
+
* What it holds a skin to:
|
|
9
|
+
* - the envelope: known keys only, the kit and contract versions it needs;
|
|
10
|
+
* - tokens: only the shared set, each value in its grammar, AA in both themes;
|
|
11
|
+
* - faces: a strict grammar, never a family the app owns;
|
|
12
|
+
* - blocks: nine types, each key typed; every `{hole}` names a prop the slot
|
|
13
|
+
* is given, of a kind that may go there (text into text nodes only, a
|
|
14
|
+
* picture only through `src`, a link target only through `to`);
|
|
15
|
+
* - hosts: only the slot's own, never repeated, never under `each` or `when`,
|
|
16
|
+
* every required group present;
|
|
17
|
+
* - limits on depth, size and count.
|
|
18
|
+
*
|
|
19
|
+
* Every problem names its place ("skin.json › home.featured › c.1: unknown
|
|
20
|
+
* prop `badge`", comp map CD26), so the owner can fix it.
|
|
21
|
+
*
|
|
22
|
+
* Pure.
|
|
23
|
+
*/
|
|
24
|
+
import { type PropSpec, type SkinContract } from './contract.js';
|
|
25
|
+
import { type ResolvedTokens, type ThemeTokens } from './tokens.js';
|
|
26
|
+
/** The nine block types. */
|
|
27
|
+
export declare const BLOCK_TYPES: readonly ["stack", "row", "grid", "heading", "text", "image", "link", "host", "icon"];
|
|
28
|
+
export type BlockType = (typeof BLOCK_TYPES)[number];
|
|
29
|
+
/** Container tags a stack, row or grid may be. */
|
|
30
|
+
export declare const CONTAINER_TAGS: readonly ["div", "section", "header", "footer", "nav", "article", "aside", "address", "ul", "ol", "li"];
|
|
31
|
+
/** Tags that may carry an accessible name (`label`). */
|
|
32
|
+
export declare const LABELLED_TAGS: ReadonlySet<string>;
|
|
33
|
+
/** Limits, shared by the engine and the browser. */
|
|
34
|
+
export declare const LIMITS: {
|
|
35
|
+
readonly depth: 24;
|
|
36
|
+
readonly blocksPerSlot: 2000;
|
|
37
|
+
readonly blocksPerPackage: 6000;
|
|
38
|
+
readonly children: 64;
|
|
39
|
+
readonly parts: 16;
|
|
40
|
+
readonly classes: 4;
|
|
41
|
+
readonly text: 300;
|
|
42
|
+
readonly faces: 8;
|
|
43
|
+
readonly words: 200;
|
|
44
|
+
readonly languages: 16;
|
|
45
|
+
readonly drawnPerSlot: 5000;
|
|
46
|
+
readonly eachDrawn: 200;
|
|
47
|
+
};
|
|
48
|
+
/** Package files: the data, CSS, fonts, pictures and licence texts. No script, no SVG, no HTML. */
|
|
49
|
+
export declare const ASSET_TYPES: Readonly<Record<string, string>>;
|
|
50
|
+
/** Byte caps per file type, and for the whole package. */
|
|
51
|
+
export declare const SIZE_CAPS: {
|
|
52
|
+
readonly json: number;
|
|
53
|
+
readonly css: number;
|
|
54
|
+
readonly cssTotal: number;
|
|
55
|
+
readonly woff2: number;
|
|
56
|
+
readonly image: number;
|
|
57
|
+
readonly txt: number;
|
|
58
|
+
readonly files: 64;
|
|
59
|
+
readonly total: number;
|
|
60
|
+
};
|
|
61
|
+
/** A package path: lower-case folders, a file name, an allowed extension; no `..`. */
|
|
62
|
+
export declare const ASSET_PATH_RE: RegExp;
|
|
63
|
+
/** The file type a package path has, or null when it isn't one a skin may carry. */
|
|
64
|
+
export declare function assetType(path: string): string | null;
|
|
65
|
+
/** The cap for one file of this path, in bytes. */
|
|
66
|
+
export declare function sizeCap(path: string): number;
|
|
67
|
+
export interface Part {
|
|
68
|
+
text: string;
|
|
69
|
+
mono?: boolean;
|
|
70
|
+
}
|
|
71
|
+
export interface Block {
|
|
72
|
+
t: BlockType;
|
|
73
|
+
tag?: string;
|
|
74
|
+
cls?: string;
|
|
75
|
+
c?: Block[];
|
|
76
|
+
text?: string;
|
|
77
|
+
parts?: Part[];
|
|
78
|
+
inline?: boolean;
|
|
79
|
+
level?: number;
|
|
80
|
+
src?: string;
|
|
81
|
+
alt?: string;
|
|
82
|
+
decorative?: boolean;
|
|
83
|
+
to?: string;
|
|
84
|
+
label?: string;
|
|
85
|
+
each?: string;
|
|
86
|
+
as?: string;
|
|
87
|
+
item?: Block | string;
|
|
88
|
+
when?: string;
|
|
89
|
+
on?: 'accent' | 'accent-2';
|
|
90
|
+
name?: string;
|
|
91
|
+
area?: string;
|
|
92
|
+
id?: string;
|
|
93
|
+
}
|
|
94
|
+
export interface Face {
|
|
95
|
+
family: string;
|
|
96
|
+
file: string;
|
|
97
|
+
weight?: string;
|
|
98
|
+
style?: 'normal' | 'italic';
|
|
99
|
+
unicodeRange?: string;
|
|
100
|
+
}
|
|
101
|
+
export interface SkinPackage {
|
|
102
|
+
kit: string;
|
|
103
|
+
of: {
|
|
104
|
+
app: string;
|
|
105
|
+
contract: string;
|
|
106
|
+
};
|
|
107
|
+
name: string;
|
|
108
|
+
defaultLanguage?: string;
|
|
109
|
+
tokens: {
|
|
110
|
+
light: ThemeTokens;
|
|
111
|
+
dark: ThemeTokens;
|
|
112
|
+
};
|
|
113
|
+
faces?: Face[];
|
|
114
|
+
words?: Record<string, Record<string, string>>;
|
|
115
|
+
slots: Record<string, Block>;
|
|
116
|
+
styles?: Record<string, string>;
|
|
117
|
+
}
|
|
118
|
+
export interface SkinProblem {
|
|
119
|
+
/** Where: `skin.json › <slot> › c.1 › item`. */
|
|
120
|
+
path: string;
|
|
121
|
+
message: string;
|
|
122
|
+
}
|
|
123
|
+
export interface ValidateOptions {
|
|
124
|
+
/** Every file the package declares besides skin.json (the manifest's `skin.assets`, or the config's `files`). */
|
|
125
|
+
files?: readonly string[];
|
|
126
|
+
/** Skip the AA check (only the kit's own tests). */
|
|
127
|
+
skipAa?: boolean;
|
|
128
|
+
}
|
|
129
|
+
export interface ValidationResult {
|
|
130
|
+
ok: boolean;
|
|
131
|
+
problems: SkinProblem[];
|
|
132
|
+
/** The package as checked, when ok. */
|
|
133
|
+
skin?: SkinPackage;
|
|
134
|
+
/** The tokens with dark's one-value tokens filled, when ok. */
|
|
135
|
+
tokens?: ResolvedTokens;
|
|
136
|
+
}
|
|
137
|
+
/** A text template's pieces: literal text and `{path}` holes. `{{` writes `{`. */
|
|
138
|
+
export type TemplatePiece = {
|
|
139
|
+
text: string;
|
|
140
|
+
} | {
|
|
141
|
+
hole: string[];
|
|
142
|
+
};
|
|
143
|
+
/** A template, read; a string saying what is wrong otherwise. */
|
|
144
|
+
export declare function parseTemplate(source: string): TemplatePiece[] | string;
|
|
145
|
+
/** A whole-value hole (`"{a.b}"`), read; null when the value is anything else. */
|
|
146
|
+
export declare function wholeHole(value: string): string[] | null;
|
|
147
|
+
/**
|
|
148
|
+
* The spec a hole names inside a slot (the renderer asks, to draw a figure in
|
|
149
|
+
* the app's own face); null when it names nothing.
|
|
150
|
+
*/
|
|
151
|
+
export declare function specAt(contract: SkinContract, slot: string, loops: Readonly<Record<string, PropSpec>>, path: readonly string[]): PropSpec | null;
|
|
152
|
+
/** Check a `skin.json` against an app's contract. */
|
|
153
|
+
export declare function validateSkin(input: unknown, contract: SkinContract, options?: ValidateOptions): ValidationResult;
|
|
154
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAA4D,KAAK,QAAQ,EAAE,KAAK,YAAY,EAAiB,MAAM,eAAe,CAAC;AAC1I,OAAO,EAAkH,KAAK,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAGpL,4BAA4B;AAC5B,eAAO,MAAM,WAAW,uFAAwF,CAAC;AACjH,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAErD,kDAAkD;AAClD,eAAO,MAAM,cAAc,yGAA0G,CAAC;AACtI,wDAAwD;AACxD,eAAO,MAAM,aAAa,EAAE,WAAW,CAAC,MAAM,CAAuE,CAAC;AAetH,oDAAoD;AACpD,eAAO,MAAM,MAAM;;;;;;;;;;;;;CAaT,CAAC;AAEX,mGAAmG;AACnG,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,MAAM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