@terrazzo/parser 0.7.2 → 0.8.0
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/CHANGELOG.md +20 -0
- package/dist/index.d.ts +707 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4598 -12
- package/dist/index.js.map +1 -1
- package/package.json +11 -7
- package/rolldown.config.ts +24 -0
- package/src/build/index.ts +2 -2
- package/src/index.ts +76 -1
- package/src/parse/index.ts +72 -13
- package/src/parse/json.ts +35 -29
- package/src/parse/normalize.ts +4 -14
- package/src/parse/validate.ts +81 -68
- package/dist/build/index.d.ts +0 -20
- package/dist/build/index.d.ts.map +0 -1
- package/dist/build/index.js +0 -166
- package/dist/build/index.js.map +0 -1
- package/dist/config.d.ts +0 -8
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -290
- package/dist/config.js.map +0 -1
- package/dist/lib/code-frame.d.ts +0 -31
- package/dist/lib/code-frame.d.ts.map +0 -1
- package/dist/lib/code-frame.js +0 -108
- package/dist/lib/code-frame.js.map +0 -1
- package/dist/lint/index.d.ts +0 -12
- package/dist/lint/index.d.ts.map +0 -1
- package/dist/lint/index.js +0 -105
- package/dist/lint/index.js.map +0 -1
- package/dist/lint/plugin-core/index.d.ts +0 -13
- package/dist/lint/plugin-core/index.d.ts.map +0 -1
- package/dist/lint/plugin-core/index.js +0 -40
- package/dist/lint/plugin-core/index.js.map +0 -1
- package/dist/lint/plugin-core/lib/docs.d.ts +0 -2
- package/dist/lint/plugin-core/lib/docs.d.ts.map +0 -1
- package/dist/lint/plugin-core/lib/docs.js +0 -4
- package/dist/lint/plugin-core/lib/docs.js.map +0 -1
- package/dist/lint/plugin-core/rules/a11y-min-contrast.d.ts +0 -40
- package/dist/lint/plugin-core/rules/a11y-min-contrast.d.ts.map +0 -1
- package/dist/lint/plugin-core/rules/a11y-min-contrast.js +0 -58
- package/dist/lint/plugin-core/rules/a11y-min-contrast.js.map +0 -1
- package/dist/lint/plugin-core/rules/a11y-min-font-size.d.ts +0 -14
- package/dist/lint/plugin-core/rules/a11y-min-font-size.d.ts.map +0 -1
- package/dist/lint/plugin-core/rules/a11y-min-font-size.js +0 -45
- package/dist/lint/plugin-core/rules/a11y-min-font-size.js.map +0 -1
- package/dist/lint/plugin-core/rules/colorspace.d.ts +0 -15
- package/dist/lint/plugin-core/rules/colorspace.d.ts.map +0 -1
- package/dist/lint/plugin-core/rules/colorspace.js +0 -85
- package/dist/lint/plugin-core/rules/colorspace.js.map +0 -1
- package/dist/lint/plugin-core/rules/consistent-naming.d.ts +0 -12
- package/dist/lint/plugin-core/rules/consistent-naming.d.ts.map +0 -1
- package/dist/lint/plugin-core/rules/consistent-naming.js +0 -49
- package/dist/lint/plugin-core/rules/consistent-naming.js.map +0 -1
- package/dist/lint/plugin-core/rules/descriptions.d.ts +0 -10
- package/dist/lint/plugin-core/rules/descriptions.d.ts.map +0 -1
- package/dist/lint/plugin-core/rules/descriptions.js +0 -32
- package/dist/lint/plugin-core/rules/descriptions.js.map +0 -1
- package/dist/lint/plugin-core/rules/duplicate-values.d.ts +0 -10
- package/dist/lint/plugin-core/rules/duplicate-values.d.ts.map +0 -1
- package/dist/lint/plugin-core/rules/duplicate-values.js +0 -65
- package/dist/lint/plugin-core/rules/duplicate-values.js.map +0 -1
- package/dist/lint/plugin-core/rules/max-gamut.d.ts +0 -15
- package/dist/lint/plugin-core/rules/max-gamut.d.ts.map +0 -1
- package/dist/lint/plugin-core/rules/max-gamut.js +0 -101
- package/dist/lint/plugin-core/rules/max-gamut.js.map +0 -1
- package/dist/lint/plugin-core/rules/required-children.d.ts +0 -19
- package/dist/lint/plugin-core/rules/required-children.d.ts.map +0 -1
- package/dist/lint/plugin-core/rules/required-children.js +0 -78
- package/dist/lint/plugin-core/rules/required-children.js.map +0 -1
- package/dist/lint/plugin-core/rules/required-modes.d.ts +0 -14
- package/dist/lint/plugin-core/rules/required-modes.d.ts.map +0 -1
- package/dist/lint/plugin-core/rules/required-modes.js +0 -52
- package/dist/lint/plugin-core/rules/required-modes.js.map +0 -1
- package/dist/lint/plugin-core/rules/required-typography-properties.d.ts +0 -11
- package/dist/lint/plugin-core/rules/required-typography-properties.d.ts.map +0 -1
- package/dist/lint/plugin-core/rules/required-typography-properties.js +0 -38
- package/dist/lint/plugin-core/rules/required-typography-properties.js.map +0 -1
- package/dist/logger.d.ts +0 -77
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -136
- package/dist/logger.js.map +0 -1
- package/dist/parse/alias.d.ts +0 -34
- package/dist/parse/alias.d.ts.map +0 -1
- package/dist/parse/alias.js +0 -302
- package/dist/parse/alias.js.map +0 -1
- package/dist/parse/index.d.ts +0 -36
- package/dist/parse/index.d.ts.map +0 -1
- package/dist/parse/index.js +0 -226
- package/dist/parse/index.js.map +0 -1
- package/dist/parse/json.d.ts +0 -52
- package/dist/parse/json.d.ts.map +0 -1
- package/dist/parse/json.js +0 -161
- package/dist/parse/json.js.map +0 -1
- package/dist/parse/normalize.d.ts +0 -24
- package/dist/parse/normalize.d.ts.map +0 -1
- package/dist/parse/normalize.js +0 -185
- package/dist/parse/normalize.js.map +0 -1
- package/dist/parse/validate.d.ts +0 -63
- package/dist/parse/validate.d.ts.map +0 -1
- package/dist/parse/validate.js +0 -798
- package/dist/parse/validate.js.map +0 -1
- package/dist/types.d.ts +0 -265
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { isTokenMatch, tokenToCulori } from '@terrazzo/token-tools';
|
|
2
|
-
import { clampChroma } from 'culori';
|
|
3
|
-
import { docsLink } from '../lib/docs.js';
|
|
4
|
-
export const MAX_GAMUT = 'core/max-gamut';
|
|
5
|
-
const TOLERANCE = 0.000001; // threshold above which it counts as an error (take rounding errors into account)
|
|
6
|
-
/** is a Culori-parseable color within the specified gamut? */
|
|
7
|
-
function isWithinGamut(color, gamut) {
|
|
8
|
-
const parsed = tokenToCulori(color);
|
|
9
|
-
if (!parsed) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
if (['rgb', 'hsl', 'hsv', 'hwb'].includes(parsed.mode)) {
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
const clamped = clampChroma(parsed, parsed.mode, gamut === 'srgb' ? 'rgb' : gamut);
|
|
16
|
-
return isWithinThreshold(parsed, clamped);
|
|
17
|
-
}
|
|
18
|
-
/** is Color A close enough to Color B? */
|
|
19
|
-
function isWithinThreshold(a, b, tolerance = TOLERANCE) {
|
|
20
|
-
for (const k in a) {
|
|
21
|
-
if (k === 'mode' || k === 'alpha') {
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
if (!(k in b)) {
|
|
25
|
-
throw new Error(`Can’t compare ${a.mode} to ${b.mode}`);
|
|
26
|
-
}
|
|
27
|
-
if (Math.abs(a[k] - b[k]) > tolerance) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
const ERROR_COLOR = 'COLOR';
|
|
34
|
-
const ERROR_BORDER = 'BORDER';
|
|
35
|
-
const ERROR_GRADIENT = 'GRADIENT';
|
|
36
|
-
const ERROR_SHADOW = 'SHADOW';
|
|
37
|
-
const rule = {
|
|
38
|
-
meta: {
|
|
39
|
-
messages: {
|
|
40
|
-
[ERROR_COLOR]: 'Color {{ id }} is outside {{ gamut }} gamut',
|
|
41
|
-
[ERROR_BORDER]: 'Border {{ id }} is outside {{ gamut }} gamut',
|
|
42
|
-
[ERROR_GRADIENT]: 'Gradient {{ id }} is outside {{ gamut }} gamut',
|
|
43
|
-
[ERROR_SHADOW]: 'Shadow {{ id }} is outside {{ gamut }} gamut',
|
|
44
|
-
},
|
|
45
|
-
docs: {
|
|
46
|
-
description: 'Enforce colors are within the specified gamut.',
|
|
47
|
-
url: docsLink(MAX_GAMUT),
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
defaultOptions: { gamut: 'rec2020' },
|
|
51
|
-
create({ tokens, options, report }) {
|
|
52
|
-
if (!options?.gamut) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (options.gamut !== 'srgb' && options.gamut !== 'p3' && options.gamut !== 'rec2020') {
|
|
56
|
-
throw new Error(`Unknown gamut "${options.gamut}". Options are "srgb", "p3", or "rec2020"`);
|
|
57
|
-
}
|
|
58
|
-
for (const t of Object.values(tokens)) {
|
|
59
|
-
// skip ignored tokens
|
|
60
|
-
if (options.ignore && isTokenMatch(t.id, options.ignore)) {
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
// skip aliases
|
|
64
|
-
if (t.aliasOf) {
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
switch (t.$type) {
|
|
68
|
-
case 'color': {
|
|
69
|
-
if (!isWithinGamut(t.$value, options.gamut)) {
|
|
70
|
-
report({ messageId: ERROR_COLOR, data: { id: t.id, gamut: options.gamut }, node: t.source.node });
|
|
71
|
-
}
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
74
|
-
case 'border': {
|
|
75
|
-
if (!t.partialAliasOf?.color && !isWithinGamut(t.$value.color, options.gamut)) {
|
|
76
|
-
report({ messageId: ERROR_BORDER, data: { id: t.id, gamut: options.gamut }, node: t.source.node });
|
|
77
|
-
}
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
case 'gradient': {
|
|
81
|
-
for (let stopI = 0; stopI < t.$value.length; stopI++) {
|
|
82
|
-
if (!t.partialAliasOf?.[stopI]?.color && !isWithinGamut(t.$value[stopI].color, options.gamut)) {
|
|
83
|
-
report({ messageId: ERROR_GRADIENT, data: { id: t.id, gamut: options.gamut }, node: t.source.node });
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
case 'shadow': {
|
|
89
|
-
for (let shadowI = 0; shadowI < t.$value.length; shadowI++) {
|
|
90
|
-
if (!t.partialAliasOf?.[shadowI]?.color && !isWithinGamut(t.$value[shadowI].color, options.gamut)) {
|
|
91
|
-
report({ messageId: ERROR_SHADOW, data: { id: t.id, gamut: options.gamut }, node: t.source.node });
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
};
|
|
100
|
-
export default rule;
|
|
101
|
-
//# sourceMappingURL=max-gamut.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"max-gamut.js","sourceRoot":"","sources":["../../../../src/lint/plugin-core/rules/max-gamut.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC/F,OAAO,EAAc,WAAW,EAAE,MAAM,QAAQ,CAAC;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,CAAC,MAAM,SAAS,GAAG,gBAAgB,CAAC;AAS1C,MAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,kFAAkF;AAE9G,8DAA8D;AAC9D,SAAS,aAAa,CAAC,KAA2B,EAAE,KAAmC;IACrF,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IACpC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QACvD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACnF,OAAO,iBAAiB,CAAC,MAAM,EAAE,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AE,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;wBACrG,CAAC;oBACH,CAAC;oBACD,MAAM;gBACR,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { LintRule } from '../../../types.js';
|
|
2
|
-
export declare const REQUIRED_CHILDREN = "core/required-children";
|
|
3
|
-
export interface RequiredChildrenMatch {
|
|
4
|
-
/** Glob of tokens/groups to match */
|
|
5
|
-
match: string[];
|
|
6
|
-
/** Required token IDs to match (this only looks at the very last segment of a token ID!) */
|
|
7
|
-
requiredTokens?: string[];
|
|
8
|
-
/** Required groups to match (this only looks at the beginning/middle segments of a token ID!) */
|
|
9
|
-
requiredGroups?: string[];
|
|
10
|
-
}
|
|
11
|
-
export interface RuleRequiredChildrenOptions {
|
|
12
|
-
matches: RequiredChildrenMatch[];
|
|
13
|
-
}
|
|
14
|
-
export declare const ERROR_EMPTY_MATCH = "EMPTY_MATCH";
|
|
15
|
-
export declare const ERROR_MISSING_REQUIRED_TOKENS = "MISSING_REQUIRED_TOKENS";
|
|
16
|
-
export declare const ERROR_MISSING_REQUIRED_GROUP = "MISSING_REQUIRED_GROUP";
|
|
17
|
-
declare const rule: LintRule<typeof ERROR_EMPTY_MATCH | typeof ERROR_MISSING_REQUIRED_TOKENS | typeof ERROR_MISSING_REQUIRED_GROUP, RuleRequiredChildrenOptions>;
|
|
18
|
-
export default rule;
|
|
19
|
-
//# sourceMappingURL=required-children.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"required-children.d.ts","sourceRoot":"","sources":["../../../../src/lint/plugin-core/rules/required-children.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD,eAAO,MAAM,iBAAiB,2BAA2B,CAAC;AAE1D,MAAM,WAAW,qBAAqB;IACpC,qCAAqC;IACrC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,4FAA4F;IAC5F,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,iGAAiG;IACjG,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,qBAAqB,EAAE,CAAC;CAClC;AAED,eAAO,MAAM,iBAAiB,gBAAgB,CAAC;AAC/C,eAAO,MAAM,6BAA6B,4BAA4B,CAAC;AACvE,eAAO,MAAM,4BAA4B,2BAA2B,CAAC;AAErE,QAAA,MAAM,IAAI,EAAE,QAAQ,CAClB,OAAO,iBAAiB,GAAG,OAAO,6BAA6B,GAAG,OAAO,4BAA4B,EACrG,2BAA2B,CA4E5B,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { isTokenMatch } from '@terrazzo/token-tools';
|
|
2
|
-
import { docsLink } from '../lib/docs.js';
|
|
3
|
-
export const REQUIRED_CHILDREN = 'core/required-children';
|
|
4
|
-
export const ERROR_EMPTY_MATCH = 'EMPTY_MATCH';
|
|
5
|
-
export const ERROR_MISSING_REQUIRED_TOKENS = 'MISSING_REQUIRED_TOKENS';
|
|
6
|
-
export const ERROR_MISSING_REQUIRED_GROUP = 'MISSING_REQUIRED_GROUP';
|
|
7
|
-
const rule = {
|
|
8
|
-
meta: {
|
|
9
|
-
messages: {
|
|
10
|
-
[ERROR_EMPTY_MATCH]: 'No tokens matched {{ matcher }}',
|
|
11
|
-
[ERROR_MISSING_REQUIRED_TOKENS]: 'Match {{ index }}: some groups missing required token "{{ token }}"',
|
|
12
|
-
[ERROR_MISSING_REQUIRED_GROUP]: 'Match {{ index }}: some tokens missing required group "{{ group }}"',
|
|
13
|
-
},
|
|
14
|
-
docs: {
|
|
15
|
-
description: 'Enforce token groups have specific children, whether tokens and/or groups.',
|
|
16
|
-
url: docsLink(REQUIRED_CHILDREN),
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
defaultOptions: { matches: [] },
|
|
20
|
-
create({ tokens, options, report }) {
|
|
21
|
-
if (!options.matches?.length) {
|
|
22
|
-
throw new Error('Invalid config. Missing `matches: […]`');
|
|
23
|
-
}
|
|
24
|
-
// note: in many other rules, the operation can be completed in one iteration through all tokens
|
|
25
|
-
// in this rule, however, we have to scan all tokens every time per-match, because they may overlap
|
|
26
|
-
for (let matchI = 0; matchI < options.matches.length; matchI++) {
|
|
27
|
-
const { match, requiredTokens, requiredGroups } = options.matches[matchI];
|
|
28
|
-
// validate
|
|
29
|
-
if (!match.length) {
|
|
30
|
-
throw new Error(`Match ${matchI}: must declare \`match: […]\``);
|
|
31
|
-
}
|
|
32
|
-
if (!requiredTokens?.length && !requiredGroups?.length) {
|
|
33
|
-
throw new Error(`Match ${matchI}: must declare either \`requiredTokens: […]\` or \`requiredGroups: […]\``);
|
|
34
|
-
}
|
|
35
|
-
const matchGroups = [];
|
|
36
|
-
const matchTokens = [];
|
|
37
|
-
let tokensMatched = false;
|
|
38
|
-
for (const t of Object.values(tokens)) {
|
|
39
|
-
if (!isTokenMatch(t.id, match)) {
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
tokensMatched = true;
|
|
43
|
-
const groups = t.id.split('.');
|
|
44
|
-
matchTokens.push(groups.pop());
|
|
45
|
-
matchGroups.push(...groups);
|
|
46
|
-
}
|
|
47
|
-
if (!tokensMatched) {
|
|
48
|
-
report({
|
|
49
|
-
messageId: ERROR_EMPTY_MATCH,
|
|
50
|
-
data: { matcher: JSON.stringify(match) },
|
|
51
|
-
});
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
if (requiredTokens) {
|
|
55
|
-
for (const id of requiredTokens) {
|
|
56
|
-
if (!matchTokens.includes(id)) {
|
|
57
|
-
report({
|
|
58
|
-
messageId: ERROR_MISSING_REQUIRED_TOKENS,
|
|
59
|
-
data: { index: matchI, token: id },
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if (requiredGroups) {
|
|
65
|
-
for (const groupName of requiredGroups) {
|
|
66
|
-
if (!matchGroups.includes(groupName)) {
|
|
67
|
-
report({
|
|
68
|
-
messageId: ERROR_MISSING_REQUIRED_GROUP,
|
|
69
|
-
data: { index: matchI, group: groupName },
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
export default rule;
|
|
78
|
-
//# sourceMappingURL=required-children.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"required-children.js","sourceRoot":"","sources":["../../../../src/lint/plugin-core/rules/required-children.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,CAAC,MAAM,iBAAiB,GAAG,wBAAwB,CAAC;AAe1D,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAC/C,MAAM,CAAC,MAAM,6BAA6B,GAAG,yBAAyB,CAAC;AACvE,MAAM,CAAC,MAAM,4BAA4B,GAAG,wBAAwB,CAAC;AAErE,MAAM,IAAI,GAGN;IACF,IAAI,EAAE;QACJ,QAAQ,EAAE;YACR,CAAC,iBAAiB,CAAC,EAAE,iCAAiC;YACtD,CAAC,6BAA6B,CAAC,EAAE,qEAAqE;YACtG,CAAC,4BAA4B,CAAC,EAAE,qEAAqE;SACtG;QACD,IAAI,EAAE;YACJ,WAAW,EAAE,4EAA4E;YACzF,GAAG,EAAE,QAAQ,CAAC,iBAAiB,CAAC;SACjC;KACF;IACD,cAAc,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;IAC/B,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE;QAChC,IAAI,CA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M,CAAC;oBACL,SAAS,EAAE,iBAAiB;oBAC5B,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;iBACzC,CAAC,CAAC;gBACH,SAAS;YACX,CAAC;YAED,IAAI,cAAc,EAAE,CAAC;gBACnB,KAAK,MAAM,EAAE,IAAI,cAAc,EAAE,CAAC;oBAChC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;wBAC9B,MAAM,CAAC;4BACL,SAAS,EAAE,6BAA6B;4BACxC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE;yBACnC,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;YACH,CAAC;YACD,IAAI,cAAc,EAAE,CAAC;gBACnB,KAAK,MAAM,SAAS,IAAI,cAAc,EAAE,CAAC;oBACvC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;wBACrC,MAAM,CAAC;4BACL,SAAS,EAAE,4BAA4B;4BACvC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE;yBAC1C,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { LintRule } from '../../../types.js';
|
|
2
|
-
export declare const REQUIRED_MODES = "core/required-modes";
|
|
3
|
-
export type RequiredModesMatch = {
|
|
4
|
-
/** Glob of tokens/groups to match */
|
|
5
|
-
match: string[];
|
|
6
|
-
/** Required modes */
|
|
7
|
-
modes: string[];
|
|
8
|
-
};
|
|
9
|
-
export interface RuleRequiredModesOptions {
|
|
10
|
-
matches: RequiredModesMatch[];
|
|
11
|
-
}
|
|
12
|
-
declare const rule: LintRule<never, RuleRequiredModesOptions>;
|
|
13
|
-
export default rule;
|
|
14
|
-
//# sourceMappingURL=required-modes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"required-modes.d.ts","sourceRoot":"","sources":["../../../../src/lint/plugin-core/rules/required-modes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD,eAAO,MAAM,cAAc,wBAAwB,CAAC;AAEpD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,qCAAqC;IACrC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,qBAAqB;IACrB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAEF,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,kBAAkB,EAAE,CAAC;CAC/B;AAED,QAAA,MAAM,IAAI,EAAE,QAAQ,CAAC,KAAK,EAAE,wBAAwB,CAmDnD,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { isTokenMatch } from '@terrazzo/token-tools';
|
|
2
|
-
import { docsLink } from '../lib/docs.js';
|
|
3
|
-
export const REQUIRED_MODES = 'core/required-modes';
|
|
4
|
-
const rule = {
|
|
5
|
-
meta: {
|
|
6
|
-
docs: {
|
|
7
|
-
description: 'Enforce certain tokens have specific modes.',
|
|
8
|
-
url: docsLink(REQUIRED_MODES),
|
|
9
|
-
},
|
|
10
|
-
},
|
|
11
|
-
defaultOptions: { matches: [] },
|
|
12
|
-
create({ tokens, options, report }) {
|
|
13
|
-
if (!options?.matches?.length) {
|
|
14
|
-
throw new Error('Invalid config. Missing `matches: […]`');
|
|
15
|
-
}
|
|
16
|
-
// note: in many other rules, the operation can be completed in one iteration through all tokens
|
|
17
|
-
// in this rule, however, we have to scan all tokens every time per-match, because they may overlap
|
|
18
|
-
for (let matchI = 0; matchI < options.matches.length; matchI++) {
|
|
19
|
-
const { match, modes } = options.matches[matchI];
|
|
20
|
-
// validate
|
|
21
|
-
if (!match.length) {
|
|
22
|
-
throw new Error(`Match ${matchI}: must declare \`match: […]\``);
|
|
23
|
-
}
|
|
24
|
-
if (!modes?.length) {
|
|
25
|
-
throw new Error(`Match ${matchI}: must declare \`modes: […]\``);
|
|
26
|
-
}
|
|
27
|
-
let tokensMatched = false;
|
|
28
|
-
for (const t of Object.values(tokens)) {
|
|
29
|
-
if (!isTokenMatch(t.id, match)) {
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
tokensMatched = true;
|
|
33
|
-
for (const mode of modes) {
|
|
34
|
-
if (!t.mode?.[mode]) {
|
|
35
|
-
report({
|
|
36
|
-
message: `Token ${t.id}: missing required mode "${mode}"`,
|
|
37
|
-
node: t.source.node,
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
if (!tokensMatched) {
|
|
42
|
-
report({
|
|
43
|
-
message: `Match "${matchI}": no tokens matched ${JSON.stringify(match)}`,
|
|
44
|
-
node: t.source.node,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
export default rule;
|
|
52
|
-
//# sourceMappingURL=required-modes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"required-modes.js","sourceRoot":"","sources":["../../../../src/lint/plugin-core/rules/required-modes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,CAAC,MAAM,cAAc,GAAG,qBAAqB,CAAC;AAapD,MAAM,IAAI,GAA8C;IACtD,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,WAAW,EAAE,6CAA6C;YAC1D,GAAG,EAAE,QAAQ,CAAC,cAAc,CAAC;SAC9B;KACF;IACD,cAAc,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;IAC/B,MAAM,CAAC,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AE,CAAC;oBACnB,MAAM,CAAC;wBACL,OAAO,EAAE,UAAU,MAAM,wBAAwB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;wBACxE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI;qBACpB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { LintRule } from '../../../types.js';
|
|
2
|
-
export declare const REQUIRED_TYPOGRAPHY_PROPERTIES = "core/required-typography-properties";
|
|
3
|
-
export interface RuleRequiredTypographyPropertiesOptions {
|
|
4
|
-
/** Required typography properties */
|
|
5
|
-
properties: string[];
|
|
6
|
-
/** Token globs to ignore */
|
|
7
|
-
ignore?: string[];
|
|
8
|
-
}
|
|
9
|
-
declare const rule: LintRule<never, RuleRequiredTypographyPropertiesOptions>;
|
|
10
|
-
export default rule;
|
|
11
|
-
//# sourceMappingURL=required-typography-properties.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"required-typography-properties.d.ts","sourceRoot":"","sources":["../../../../src/lint/plugin-core/rules/required-typography-properties.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD,eAAO,MAAM,8BAA8B,wCAAwC,CAAC;AAEpF,MAAM,WAAW,uCAAuC;IACtD,qCAAqC;IACrC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,4BAA4B;IAC5B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,QAAA,MAAM,IAAI,EAAE,QAAQ,CAAC,KAAK,EAAE,uCAAuC,CAqClE,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { isTokenMatch } from '@terrazzo/token-tools';
|
|
2
|
-
import { docsLink } from '../lib/docs.js';
|
|
3
|
-
export const REQUIRED_TYPOGRAPHY_PROPERTIES = 'core/required-typography-properties';
|
|
4
|
-
const rule = {
|
|
5
|
-
meta: {
|
|
6
|
-
docs: {
|
|
7
|
-
description: 'Enforce typography tokens have required properties.',
|
|
8
|
-
url: docsLink(REQUIRED_TYPOGRAPHY_PROPERTIES),
|
|
9
|
-
},
|
|
10
|
-
},
|
|
11
|
-
defaultOptions: { properties: [] },
|
|
12
|
-
create({ tokens, options, report }) {
|
|
13
|
-
if (!options) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
if (!options.properties.length) {
|
|
17
|
-
throw new Error(`"properties" can’t be empty`);
|
|
18
|
-
}
|
|
19
|
-
for (const t of Object.values(tokens)) {
|
|
20
|
-
if (options.ignore && isTokenMatch(t.id, options.ignore)) {
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
if (t.$type !== 'typography') {
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
if (t.aliasOf) {
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
for (const p of options.properties) {
|
|
30
|
-
if (!t.partialAliasOf?.[p] && !(p in t.$value)) {
|
|
31
|
-
report({ message: `${t.id} missing required typographic property "${p}"`, node: t.source.node });
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
export default rule;
|
|
38
|
-
//# sourceMappingURL=required-typography-properties.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"required-typography-properties.js","sourceRoot":"","sources":["../../../../src/lint/plugin-core/rules/required-typography-properties.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,CAAC,MAAM,8BAA8B,GAAG,qCAAqC,CAAC;AASpF,MAAM,IAAI,GAA6D;IACrE,IAAI,EAAE;QACJ,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hocodes/momoa';
|
|
2
|
-
export declare const LOG_ORDER: readonly ["error", "warn", "info", "debug"];
|
|
3
|
-
export type LogSeverity = 'error' | 'warn' | 'info' | 'debug';
|
|
4
|
-
export type LogLevel = LogSeverity | 'silent';
|
|
5
|
-
export type LogGroup = 'config' | 'parser' | 'lint' | 'plugin' | 'server';
|
|
6
|
-
export interface LogEntry {
|
|
7
|
-
/** Originator of log message */
|
|
8
|
-
group: LogGroup;
|
|
9
|
-
/** Error message to be logged */
|
|
10
|
-
message: string;
|
|
11
|
-
/** Prefix message with label */
|
|
12
|
-
label?: string;
|
|
13
|
-
/** File in disk */
|
|
14
|
-
filename?: URL;
|
|
15
|
-
/**
|
|
16
|
-
* Continue on error?
|
|
17
|
-
* @default false
|
|
18
|
-
*/
|
|
19
|
-
continueOnError?: boolean;
|
|
20
|
-
/** Show a code frame for the erring node */
|
|
21
|
-
node?: AnyNode;
|
|
22
|
-
/** To show a code frame, provide the original source code */
|
|
23
|
-
src?: string;
|
|
24
|
-
}
|
|
25
|
-
export interface DebugEntry {
|
|
26
|
-
group: LogGroup;
|
|
27
|
-
/** Error message to be logged */
|
|
28
|
-
message: string;
|
|
29
|
-
/** Current subtask or submodule */
|
|
30
|
-
label?: string;
|
|
31
|
-
/** Show code below message */
|
|
32
|
-
codeFrame?: {
|
|
33
|
-
src: string;
|
|
34
|
-
line: number;
|
|
35
|
-
column: number;
|
|
36
|
-
};
|
|
37
|
-
/** Display performance timing */
|
|
38
|
-
timing?: number;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* @param {Entry} entry
|
|
42
|
-
* @param {Severity} severity
|
|
43
|
-
* @return {string}
|
|
44
|
-
*/
|
|
45
|
-
export declare function formatMessage(entry: LogEntry, severity: LogSeverity): string;
|
|
46
|
-
export default class Logger {
|
|
47
|
-
level: LogLevel;
|
|
48
|
-
debugScope: string;
|
|
49
|
-
errorCount: number;
|
|
50
|
-
warnCount: number;
|
|
51
|
-
infoCount: number;
|
|
52
|
-
debugCount: number;
|
|
53
|
-
constructor(options?: {
|
|
54
|
-
level?: LogLevel;
|
|
55
|
-
debugScope?: string;
|
|
56
|
-
});
|
|
57
|
-
setLevel(level: LogLevel): void;
|
|
58
|
-
/** Log an error message (always; can’t be silenced) */
|
|
59
|
-
error(entry: LogEntry): void;
|
|
60
|
-
/** Log an info message (if logging level permits) */
|
|
61
|
-
info(entry: LogEntry): void;
|
|
62
|
-
/** Log a warning message (if logging level permits) */
|
|
63
|
-
warn(entry: LogEntry): void;
|
|
64
|
-
/** Log a diagnostics message (if logging level permits) */
|
|
65
|
-
debug(entry: DebugEntry): void;
|
|
66
|
-
/** Get stats for current logger instance */
|
|
67
|
-
stats(): {
|
|
68
|
-
errorCount: number;
|
|
69
|
-
warnCount: number;
|
|
70
|
-
infoCount: number;
|
|
71
|
-
debugCount: number;
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
export declare class TokensJSONError extends Error {
|
|
75
|
-
constructor(message: string);
|
|
76
|
-
}
|
|
77
|
-
//# sourceMappingURL=logger.d.ts.map
|
package/dist/logger.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAKpD,eAAO,MAAM,SAAS,6CAA8C,CAAC;AAErE,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE9D,MAAM,MAAM,QAAQ,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE9C,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE1E,MAAM,WAAW,QAAQ;IACvB,gCAAgC;IAChC,KAAK,EAAE,QAAQ,CAAC;IAChB,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,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;;;;;CAQN;AAED,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI5B"}
|
package/dist/logger.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import pc from 'picocolors';
|
|
2
|
-
import wcmatch from 'wildcard-match';
|
|
3
|
-
import { codeFrameColumns } from './lib/code-frame.js';
|
|
4
|
-
export const LOG_ORDER = ['error', 'warn', 'info', 'debug'];
|
|
5
|
-
const MESSAGE_COLOR = { error: pc.red, warn: pc.yellow };
|
|
6
|
-
const timeFormatter = new Intl.DateTimeFormat('en-us', {
|
|
7
|
-
hour: 'numeric',
|
|
8
|
-
hour12: false,
|
|
9
|
-
minute: 'numeric',
|
|
10
|
-
second: 'numeric',
|
|
11
|
-
fractionalSecondDigits: 3,
|
|
12
|
-
});
|
|
13
|
-
/**
|
|
14
|
-
* @param {Entry} entry
|
|
15
|
-
* @param {Severity} severity
|
|
16
|
-
* @return {string}
|
|
17
|
-
*/
|
|
18
|
-
export function formatMessage(entry, severity) {
|
|
19
|
-
let message = entry.message;
|
|
20
|
-
message = `[${entry.group}${entry.label ? `:${entry.label}` : ''}] ${message}`;
|
|
21
|
-
if (severity in MESSAGE_COLOR) {
|
|
22
|
-
message = MESSAGE_COLOR[severity](message);
|
|
23
|
-
}
|
|
24
|
-
if (entry.src) {
|
|
25
|
-
const start = entry.node?.loc?.start ?? { line: 0, column: 0 };
|
|
26
|
-
// strip "file://" protocol, but not href
|
|
27
|
-
const loc = entry.filename
|
|
28
|
-
? `${entry.filename?.href.replace(/^file:\/\//, '')}:${start?.line ?? 0}:${start?.column ?? 0}\n\n`
|
|
29
|
-
: '';
|
|
30
|
-
const codeFrame = codeFrameColumns(entry.src, { start }, { highlightCode: false });
|
|
31
|
-
message = `${message}\n\n${loc}${codeFrame}`;
|
|
32
|
-
}
|
|
33
|
-
return message;
|
|
34
|
-
}
|
|
35
|
-
export default class Logger {
|
|
36
|
-
level = 'info';
|
|
37
|
-
debugScope = '*';
|
|
38
|
-
errorCount = 0;
|
|
39
|
-
warnCount = 0;
|
|
40
|
-
infoCount = 0;
|
|
41
|
-
debugCount = 0;
|
|
42
|
-
constructor(options) {
|
|
43
|
-
if (options?.level) {
|
|
44
|
-
this.level = options.level;
|
|
45
|
-
}
|
|
46
|
-
if (options?.debugScope) {
|
|
47
|
-
this.debugScope = options.debugScope;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
setLevel(level) {
|
|
51
|
-
this.level = level;
|
|
52
|
-
}
|
|
53
|
-
/** Log an error message (always; can’t be silenced) */
|
|
54
|
-
error(entry) {
|
|
55
|
-
this.errorCount++;
|
|
56
|
-
const message = formatMessage(entry, 'error');
|
|
57
|
-
if (entry.continueOnError) {
|
|
58
|
-
// biome-ignore lint/suspicious/noConsole: this is a logger
|
|
59
|
-
console.error(message);
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
if (entry.node) {
|
|
63
|
-
throw new TokensJSONError(message);
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
throw new Error(message);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
/** Log an info message (if logging level permits) */
|
|
70
|
-
info(entry) {
|
|
71
|
-
this.infoCount++;
|
|
72
|
-
if (this.level === 'silent' || LOG_ORDER.indexOf(this.level) < LOG_ORDER.indexOf('info')) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
const message = formatMessage(entry, 'info');
|
|
76
|
-
// biome-ignore lint/suspicious/noConsole: this is a logger
|
|
77
|
-
console.log(message);
|
|
78
|
-
}
|
|
79
|
-
/** Log a warning message (if logging level permits) */
|
|
80
|
-
warn(entry) {
|
|
81
|
-
this.warnCount++;
|
|
82
|
-
if (this.level === 'silent' || LOG_ORDER.indexOf(this.level) < LOG_ORDER.indexOf('warn')) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
const message = formatMessage(entry, 'warn');
|
|
86
|
-
// biome-ignore lint/suspicious/noConsole: this is a logger
|
|
87
|
-
console.warn(message);
|
|
88
|
-
}
|
|
89
|
-
/** Log a diagnostics message (if logging level permits) */
|
|
90
|
-
debug(entry) {
|
|
91
|
-
if (this.level === 'silent' || LOG_ORDER.indexOf(this.level) < LOG_ORDER.indexOf('debug')) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
this.debugCount++;
|
|
95
|
-
let message = formatMessage(entry, 'debug');
|
|
96
|
-
const debugPrefix = entry.label ? `${entry.group}:${entry.label}` : entry.group;
|
|
97
|
-
if (this.debugScope !== '*' && !wcmatch(this.debugScope)(debugPrefix)) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
// debug color
|
|
101
|
-
message
|
|
102
|
-
.replace(/\[config[^\]]+\]/, (match) => pc.green(match))
|
|
103
|
-
.replace(/\[parser[^\]]+\]/, (match) => pc.magenta(match))
|
|
104
|
-
.replace(/\[lint[^\]]+\]/, (match) => pc.yellow(match))
|
|
105
|
-
.replace(/\[plugin[^\]]+\]/, (match) => pc.cyan(match));
|
|
106
|
-
message = `${pc.dim(timeFormatter.format(performance.now()))} ${message}`;
|
|
107
|
-
if (typeof entry.timing === 'number') {
|
|
108
|
-
let timing = '';
|
|
109
|
-
if (entry.timing < 1_000) {
|
|
110
|
-
timing = `${Math.round(entry.timing * 100) / 100}ms`;
|
|
111
|
-
}
|
|
112
|
-
else if (entry.timing < 60_000) {
|
|
113
|
-
timing = `${Math.round(entry.timing * 100) / 100_000}s`;
|
|
114
|
-
}
|
|
115
|
-
message = `${message} ${pc.dim(`[${timing}]`)}`;
|
|
116
|
-
}
|
|
117
|
-
// biome-ignore lint/suspicious/noConsole: this is a logger
|
|
118
|
-
console.log(message);
|
|
119
|
-
}
|
|
120
|
-
/** Get stats for current logger instance */
|
|
121
|
-
stats() {
|
|
122
|
-
return {
|
|
123
|
-
errorCount: this.errorCount,
|
|
124
|
-
warnCount: this.warnCount,
|
|
125
|
-
infoCount: this.infoCount,
|
|
126
|
-
debugCount: this.debugCount,
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
export class TokensJSONError extends Error {
|
|
131
|
-
constructor(message) {
|
|
132
|
-
super(message);
|
|
133
|
-
this.name = 'TokensJSONError';
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
//# sourceMappingURL=logger.js.map
|
package/dist/logger.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAU,CAAC;AAwCrE,MAAM,aAAa,GAA8C,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC;AAEpG,MAAM,aAAa,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE;IACrD,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,KAAK;IACb,MAAM,EAAE,SAAS;IACjB,MAAM,EAAE,SAAS;IACjB,sBAAsB,EAAE,CAAC;CAC1B,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,KAAe,EAAE,QAAqB;IAClE,IAAI,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IAC5B,OAAO,GAAG,IAAI,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,OAAO,EAAE,CAAC;IAC/E,IAAI,QAAQ,IAAI,aAAa,EAAE,CAAC;QAC9B,OAAO,GAAG,aAAa,CAAC,QAAQ,CAAE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IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;YACrC,IAAI,MAAM,GAAG,EAAE,CAAC;YAChB,IAAI,KAAK,CAAC,MAAM,GAAG,KAAK,EAAE,CAAC;gBACzB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC;YACvD,CAAC;iBAAM,IAAI,KAAK,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC;gBACjC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC,GAAG,OAAO,GAAG,CAAC;YAC1D,CAAC;YACD,OAAO,GAAG,GAAG,OAAO,IAAI,EAAE,CAAC,GAAG,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QAClD,CAAC;QAED,2DAA2D;QAC3D,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC;IAED,4CAA4C;IAC5C,KAAK;QACH,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B,CAAC;IACJ,CAAC;CACF;AAED,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF"}
|
package/dist/parse/alias.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { ObjectNode } from '@humanwhocodes/momoa';
|
|
2
|
-
import { type TokenNormalized, type TokenNormalizedSet } from '@terrazzo/token-tools';
|
|
3
|
-
import type Logger from '../logger.js';
|
|
4
|
-
export interface ApplyAliasOptions {
|
|
5
|
-
tokensSet: TokenNormalizedSet;
|
|
6
|
-
filename: URL;
|
|
7
|
-
src: string;
|
|
8
|
-
node: ObjectNode;
|
|
9
|
-
logger: Logger;
|
|
10
|
-
}
|
|
11
|
-
export type PreAliased<T extends TokenNormalized> = {
|
|
12
|
-
$value: T['$value'] | string;
|
|
13
|
-
mode: Record<string, T['mode'][string] & {
|
|
14
|
-
$value: T['$value'] | string;
|
|
15
|
-
}>;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Resolve aliases and update the token nodes.
|
|
19
|
-
*
|
|
20
|
-
* Data structures are in an awkward in-between phase, where they have
|
|
21
|
-
* placeholders for data but we still need to resolve everything. As such,
|
|
22
|
-
* TypeScript will raise errors expecting the final shape.
|
|
23
|
-
*
|
|
24
|
-
* This is also a bit tricky because different token types alias slightly
|
|
25
|
-
* differently. For example, color tokens and other “primitive” tokens behave
|
|
26
|
-
* as-expected. But composite tokens like Typography, Gradient, Border, etc. can
|
|
27
|
-
* either fully- or partially-alias their values. Then we add modes to the mix,
|
|
28
|
-
* and we have to do the work all over again for each mode declared.
|
|
29
|
-
*
|
|
30
|
-
* All that to say, there are a generous amount of TypeScript overrides here rather
|
|
31
|
-
* than try to codify indeterminate shapes.
|
|
32
|
-
*/
|
|
33
|
-
export default function applyAliases(token: TokenNormalized, options: ApplyAliasOptions): void;
|
|
34
|
-
//# sourceMappingURL=alias.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"alias.d.ts","sourceRoot":"","sources":["../../src/parse/alias.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsB,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAKL,KAAK,eAAe,EACpB,KAAK,kBAAkB,EAKxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AAGvC,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,kBAAkB,CAAC;IAC9B,QAAQ,EAAE,GAAG,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,eAAe,IAAI;IAClD,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,GAAG;QAAE,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAA;KAAE,CAAC,CAAC;CAC5E,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,iBAAiB,GAAG,IAAI,CA4E7F"}
|