@astryxdesign/cli 0.7.10 → 0.7.11-canary.3df65bf
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/api/build/blocks/blocks.weights.json +1 -1
- package/api/build/build.doc.mjs +1 -1
- package/api/build/kit/rank.mjs +21 -4
- package/api/build/kit/signals.mjs +9 -3
- package/api/build/kit/start.d.mts +19 -0
- package/api/build/kit/start.mjs +49 -2
- package/api/build/kit/weights.d.mts +12 -0
- package/api/build/kit/weights.mjs +52 -16
- package/api/build/kit/words.d.mts +1 -0
- package/api/build/kit/words.mjs +1 -1
- package/api/docs/_adapter.mjs +2 -1
- package/api/doctor/_adapter.d.mts +28 -1
- package/api/doctor/_adapter.mjs +39 -2
- package/api/doctor/doctor.doc.mjs +1 -1
- package/api/doctor/doctor.mjs +9 -2
- package/api/doctor/theme-checks.d.mts +44 -3
- package/api/doctor/theme-checks.mjs +273 -6
- package/api/hook/hook.mjs +13 -0
- package/api/icon/_adapter.d.mts +3 -2
- package/api/icon/_adapter.mjs +8 -2
- package/api/icon/_authoring.d.mts +1 -0
- package/api/icon/_authoring.mjs +362 -38
- package/api/icon/_default-look.d.mts +155 -0
- package/api/icon/_default-look.mjs +474 -0
- package/api/icon/_records.d.mts +1 -1
- package/api/icon/_records.mjs +1 -0
- package/api/icon/add/add.mjs +224 -38
- package/api/icon/icon.type.d.mts +7 -2
- package/api/icon/icon.type.mjs +4 -2
- package/api/icon/iconAdd.doc.mjs +2 -2
- package/api/icon/iconNewDefinition.doc.mjs +3 -2
- package/api/icon/iconNewSet.doc.mjs +4 -4
- package/api/icon/search/search.mjs +10 -9
- package/api/integration/add-helpers.d.mts +2 -1
- package/api/integration/add-helpers.mjs +5 -2
- package/api/integration/authoring-checks.d.mts +0 -2
- package/api/integration/authoring-checks.mjs +1 -6
- package/api/integration/pack-check.d.mts +8 -6
- package/api/integration/pack-check.mjs +16 -6
- package/api/logger.mjs +2 -1
- package/api/render/_adapter.mjs +47 -1
- package/api/render/render.doc.mjs +2 -1
- package/api/search/_gather-components.mjs +2 -1
- package/api/swizzle/copy/copy.mjs +5 -1
- package/api/theme/build/build.mjs +15 -4
- package/assets/docs/author-a-theme.doc.mjs +2 -0
- package/assets/docs/getting-started.doc.mjs +20 -0
- package/assets/docs/tree/building-blocks.doc.mjs +1 -0
- package/assets/docs/tree/global-integrations.doc.mjs +1 -0
- package/assets/docs/tree/help.doc.mjs +1 -1
- package/assets/docs/tree/icon-sets.doc.mjs +9 -3
- package/assets/docs/tree/quick-start.doc.mjs +1 -0
- package/assets/docs/tree/render-pages.doc.mjs +1 -1
- package/assets/docs/tree/ship.doc.mjs +1 -1
- package/assets/docs/tree/tokens-color.doc.mjs +2 -2
- package/assets/templates/blocks/components/Table/TableLeadingMarkSelection.doc.mjs +15 -0
- package/assets/templates/blocks/components/Table/TableLeadingMarkSelection.tsx +134 -0
- package/authoring/doctypes/_schema.d.mts +1 -1
- package/clients/cli/commands/build.doc.mjs +3 -2
- package/clients/cli/commands/build.mjs +34 -5
- package/clients/cli/commands/experimental/icon.mjs +31 -10
- package/clients/cli/commands/experimental-icon-add.doc.mjs +1 -1
- package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +2 -1
- package/clients/cli/commands/experimental-icon-new-set.doc.mjs +2 -2
- package/clients/cli/index.mjs +36 -7
- package/foundation/discovery/authoring-self-docs.mjs +8 -3
- package/foundation/discovery/cli-self-docs.mjs +2 -1
- package/foundation/discovery/component-discovery.mjs +16 -0
- package/foundation/discovery/doc-types.mjs +9 -2
- package/foundation/discovery/docs-discovery.mjs +6 -4
- package/foundation/discovery/icon-definition-discovery.mjs +3 -3
- package/foundation/discovery/icon-ranking.d.mts +27 -3
- package/foundation/discovery/icon-ranking.mjs +125 -8
- package/foundation/discovery/icon-set-checks.mjs +40 -20
- package/foundation/discovery/icon-set-writer.d.mts +210 -16
- package/foundation/discovery/icon-set-writer.mjs +619 -79
- package/foundation/discovery/module-exports.d.mts +92 -4
- package/foundation/discovery/module-exports.mjs +410 -61
- package/foundation/discovery/template-adapter.mjs +5 -7
- package/foundation/discovery/theme-discovery.mjs +8 -10
- package/foundation/doc-compiler/tree.mjs +2 -2
- package/foundation/env/package-manager.d.mts +12 -4
- package/foundation/env/package-manager.mjs +15 -6
- package/foundation/env/semver.mjs +41 -9
- package/foundation/fs/listing-cache.d.mts +3 -1
- package/foundation/fs/listing-cache.mjs +63 -11
- package/foundation/fs/paths.mjs +2 -1
- package/foundation/release/notices.d.mts +16 -0
- package/foundation/release/notices.mjs +27 -6
- package/foundation/render/embedded-imports.d.mts +7 -0
- package/foundation/render/embedded-imports.mjs +1 -1
- package/foundation/render/page-worker.mjs +109 -4
- package/foundation/render/render-page.d.mts +16 -1
- package/foundation/render/render-page.mjs +25 -18
- package/foundation/render/served-packages.d.mts +33 -0
- package/foundation/render/served-packages.mjs +75 -0
- package/foundation/render/single-copy-hooks.d.mts +18 -0
- package/foundation/render/single-copy-hooks.mjs +44 -0
- package/foundation/text/shell-arg.d.mts +14 -0
- package/foundation/text/shell-arg.mjs +17 -0
- package/foundation/text/string-utils.mjs +25 -25
- package/package.json +6 -6
|
@@ -9,8 +9,18 @@
|
|
|
9
9
|
* 90 an exact match in the reading the searched sets favor (below)
|
|
10
10
|
* 80 an exact match in the other reading
|
|
11
11
|
* 60 one of its words starts with the query
|
|
12
|
-
* 40 a partial match: the id or a word contains the query
|
|
13
|
-
* word of the query starts one of the
|
|
12
|
+
* 40 a partial match: the id or a word contains the query (three
|
|
13
|
+
* letters or more), or every word of the query starts one of the
|
|
14
|
+
* icon's words or id parts
|
|
15
|
+
*
|
|
16
|
+
* A word matches a whole word: a word's plural or singular (`stars` for
|
|
17
|
+
* `star`) is an exact match, while a longer word that only starts with it
|
|
18
|
+
* (`start`) is a word-start match, and {@link answeringMatches} keeps
|
|
19
|
+
* word-start and partial matches only when nothing matches a whole word.
|
|
20
|
+
* A query is scored as typed first. Only when nothing answers it with a
|
|
21
|
+
* whole word are the words that only phrase it (`go`, `the`, `icon`) left
|
|
22
|
+
* out of a query of several words, so `go home` asks for `home` while
|
|
23
|
+
* `arrow up to line` still names `arrow-up-to-line`.
|
|
14
24
|
*
|
|
15
25
|
* An exact match is a NAME match when the query is the icon's id, or one of
|
|
16
26
|
* its words that is also a part of its id (`trash` for `trash-2`); it is a
|
|
@@ -26,7 +36,8 @@
|
|
|
26
36
|
*
|
|
27
37
|
* Equal scores keep the set order first (the project's set, then load
|
|
28
38
|
* order), so the project's set always leads at a score. Within one set, a
|
|
29
|
-
* name match on the whole id
|
|
39
|
+
* name match on the whole id (or its plural or singular) comes before one on
|
|
40
|
+
* a part of it, and a meaning
|
|
30
41
|
* match whose query sits earlier among the icon's tags comes first (sets list
|
|
31
42
|
* an icon's most telling tags first). Remaining ties keep id order, so the
|
|
32
43
|
* same installation always answers the same way.
|
|
@@ -93,7 +104,9 @@ const squash = value => value.toLowerCase().replace(/[\s_-]+/g, '');
|
|
|
93
104
|
* @property {boolean} meaning the query is one of the icon's tags (never
|
|
94
105
|
* both: a tag is a word that is not the id or one of its parts)
|
|
95
106
|
* @property {number} rank within-tier key, lower first: for a name match 0
|
|
96
|
-
* (whole id)
|
|
107
|
+
* (whole id), 1 (the whole id's plural or singular), 2 (an id part), or 3
|
|
108
|
+
* (an id part's plural or singular); for a meaning match the tag's
|
|
109
|
+
* position
|
|
97
110
|
* @property {string} reason
|
|
98
111
|
*/
|
|
99
112
|
|
|
@@ -127,10 +140,27 @@ export function matchIcon(query, icon, definitions = []) {
|
|
|
127
140
|
tier: 'exact',
|
|
128
141
|
name: wholeId || partWord,
|
|
129
142
|
meaning: !wholeId && !partWord,
|
|
130
|
-
rank: wholeId ? 0 : partWord ?
|
|
143
|
+
rank: wholeId ? 0 : partWord ? 2 : tagAt,
|
|
131
144
|
reason: wholeId ? `id "${icon.id}"` : `word "${query}"`,
|
|
132
145
|
};
|
|
133
146
|
}
|
|
147
|
+
const plural = icon.words.find(word => sameWord(word, query));
|
|
148
|
+
if (plural) {
|
|
149
|
+
const named = parts.has(plural);
|
|
150
|
+
return {
|
|
151
|
+
tier: 'exact',
|
|
152
|
+
name: named,
|
|
153
|
+
meaning: !named,
|
|
154
|
+
// The whole id's plural or singular right after the whole id, then
|
|
155
|
+
// after the word itself, wherever it sits.
|
|
156
|
+
rank: named
|
|
157
|
+
? plural === icon.id
|
|
158
|
+
? 1
|
|
159
|
+
: 3
|
|
160
|
+
: tags.length + tags.indexOf(plural),
|
|
161
|
+
reason: `word "${plural}"`,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
134
164
|
const prefix = icon.words.find(word => word.startsWith(query));
|
|
135
165
|
if (prefix) {
|
|
136
166
|
return {
|
|
@@ -141,7 +171,11 @@ export function matchIcon(query, icon, definitions = []) {
|
|
|
141
171
|
reason: `word "${prefix}" starts with "${query}"`,
|
|
142
172
|
};
|
|
143
173
|
}
|
|
144
|
-
|
|
174
|
+
// A letter or two inside a word (`x` in `box`) says nothing about it.
|
|
175
|
+
const contains =
|
|
176
|
+
query.replace(/\s+/gu, '').length >= 3
|
|
177
|
+
? [icon.id, ...icon.words].find(text => text.includes(query))
|
|
178
|
+
: undefined;
|
|
145
179
|
if (contains) {
|
|
146
180
|
return {
|
|
147
181
|
tier: 'partial',
|
|
@@ -170,6 +204,72 @@ export function matchIcon(query, icon, definitions = []) {
|
|
|
170
204
|
return null;
|
|
171
205
|
}
|
|
172
206
|
|
|
207
|
+
/**
|
|
208
|
+
* Whether two words are one word's singular and plural (`star`, `stars`;
|
|
209
|
+
* `box`, `boxes`), never the same word.
|
|
210
|
+
* @param {string} a
|
|
211
|
+
* @param {string} b
|
|
212
|
+
*/
|
|
213
|
+
function sameWord(a, b) {
|
|
214
|
+
if (a === b || /\s/u.test(a) || /\s/u.test(b)) return false;
|
|
215
|
+
const [short, long] = a.length < b.length ? [a, b] : [b, a];
|
|
216
|
+
return short.length >= 2 && (long === `${short}s` || long === `${short}es`);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Words that phrase a query without naming anything: left out of a query of
|
|
221
|
+
* several words that nothing answers as typed (`go home` asks for `home`).
|
|
222
|
+
*/
|
|
223
|
+
const FILLER_WORDS = new Set([
|
|
224
|
+
'a',
|
|
225
|
+
'an',
|
|
226
|
+
'the',
|
|
227
|
+
'go',
|
|
228
|
+
'to',
|
|
229
|
+
'my',
|
|
230
|
+
'of',
|
|
231
|
+
'for',
|
|
232
|
+
'icon',
|
|
233
|
+
'icons',
|
|
234
|
+
]);
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* A query as typed: trimmed and lower-case, one space between words.
|
|
238
|
+
* @param {string} query
|
|
239
|
+
*/
|
|
240
|
+
function typedQuery(query) {
|
|
241
|
+
return query.trim().toLowerCase().split(/\s+/u).filter(Boolean).join(' ');
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* The query without the words that only phrase it, when it has several
|
|
246
|
+
* words and some word names something; else the query as typed.
|
|
247
|
+
* @param {string} query
|
|
248
|
+
*/
|
|
249
|
+
export function iconQuery(query) {
|
|
250
|
+
const words = typedQuery(query).split(' ').filter(Boolean);
|
|
251
|
+
const named = words.filter(word => !FILLER_WORDS.has(word));
|
|
252
|
+
return (words.length > 1 && named.length > 0 ? named : words).join(' ');
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* The matches that answer a query: the whole-word ones (a definition or an
|
|
257
|
+
* exact match, 80 and up) when there are any, else word starts (60) when
|
|
258
|
+
* there are any, else partial matches. A longer word that only starts with
|
|
259
|
+
* the query (`start` for `star`) never stands beside a whole-word answer.
|
|
260
|
+
* @template {{score: number}} T
|
|
261
|
+
* @param {T[]} ranked best first
|
|
262
|
+
* @returns {T[]}
|
|
263
|
+
*/
|
|
264
|
+
export function answeringMatches(ranked) {
|
|
265
|
+
for (const floor of [80, 60]) {
|
|
266
|
+
if (ranked.some(each => each.score >= floor)) {
|
|
267
|
+
return ranked.filter(each => each.score >= floor);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return ranked;
|
|
271
|
+
}
|
|
272
|
+
|
|
173
273
|
/**
|
|
174
274
|
* The score of one match, given which exact reading leads.
|
|
175
275
|
* @param {IconMatch} match
|
|
@@ -249,13 +349,30 @@ export function withDefinitionWords(icon, definitions, lookup) {
|
|
|
249
349
|
}
|
|
250
350
|
|
|
251
351
|
/**
|
|
252
|
-
* Every icon in `sets` that answers the query, ranked
|
|
352
|
+
* Every icon in `sets` that answers the query, ranked. The query is
|
|
353
|
+
* scored as typed; when nothing answers it with a whole word (80 and up),
|
|
354
|
+
* it is scored again without its filler words ({@link iconQuery}).
|
|
253
355
|
* @param {DiscoveredIconSet[]} sets in tie order
|
|
254
356
|
* @param {string} query
|
|
255
357
|
* @returns {IconMatchEntry[]}
|
|
256
358
|
*/
|
|
257
359
|
export function rankIcons(sets, query) {
|
|
258
|
-
const
|
|
360
|
+
const typed = typedQuery(query);
|
|
361
|
+
const asTyped = rankTerm(sets, typed);
|
|
362
|
+
if (asTyped.some(each => each.score >= 80)) return asTyped;
|
|
363
|
+
const named = iconQuery(query);
|
|
364
|
+
if (named === typed) return asTyped;
|
|
365
|
+
const withoutFiller = rankTerm(sets, named);
|
|
366
|
+
return withoutFiller.length > 0 ? withoutFiller : asTyped;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* {@link rankIcons} for one normalized query.
|
|
371
|
+
* @param {DiscoveredIconSet[]} sets
|
|
372
|
+
* @param {string} term
|
|
373
|
+
* @returns {IconMatchEntry[]}
|
|
374
|
+
*/
|
|
375
|
+
function rankTerm(sets, term) {
|
|
259
376
|
const astryx = astryxDefinitionsByName();
|
|
260
377
|
/** @type {Array<{set: DiscoveredIconSet, icon: IconSetIcon, definitions: string[], match: IconMatch, setIndex: number}>} */
|
|
261
378
|
const hits = [];
|
|
@@ -57,6 +57,7 @@ import {
|
|
|
57
57
|
otherNamesOf,
|
|
58
58
|
generatedTypesText,
|
|
59
59
|
readGeneratedStatements,
|
|
60
|
+
generatedTypesMatch,
|
|
60
61
|
} from './icon-set-writer.mjs';
|
|
61
62
|
import {
|
|
62
63
|
exportValueKind,
|
|
@@ -67,6 +68,7 @@ import {
|
|
|
67
68
|
} from './module-exports.mjs';
|
|
68
69
|
import {astryxIconDefinitions} from './icon-definition-discovery.mjs';
|
|
69
70
|
import {rankIcons} from './icon-ranking.mjs';
|
|
71
|
+
import {shellArg} from '../text/shell-arg.mjs';
|
|
70
72
|
import {
|
|
71
73
|
issueError,
|
|
72
74
|
issueWarning,
|
|
@@ -276,16 +278,17 @@ function checkContract(set, packageName, pkg, unchecked) {
|
|
|
276
278
|
const actual = fs.existsSync(typesFile)
|
|
277
279
|
? fs.readFileSync(typesFile, 'utf-8')
|
|
278
280
|
: null;
|
|
279
|
-
// The
|
|
280
|
-
// the
|
|
281
|
-
|
|
282
|
-
text
|
|
283
|
-
.split('\n')
|
|
284
|
-
.filter(line => !line.startsWith('//'))
|
|
285
|
-
.join('\n');
|
|
281
|
+
// The declarations must match, statement by statement, however a
|
|
282
|
+
// formatter left the file; the header comment is the writer's and
|
|
283
|
+
// changes between releases.
|
|
286
284
|
if (
|
|
287
285
|
expected != null &&
|
|
288
|
-
(actual == null ||
|
|
286
|
+
(actual == null ||
|
|
287
|
+
!generatedTypesMatch(
|
|
288
|
+
actual,
|
|
289
|
+
expected,
|
|
290
|
+
/** @type {string} */ (typesRel),
|
|
291
|
+
))
|
|
289
292
|
) {
|
|
290
293
|
issues.push(
|
|
291
294
|
issueError(
|
|
@@ -359,12 +362,12 @@ function checkDefinitions(set) {
|
|
|
359
362
|
if (mapped.has(doc.name) || !doc.builtIn) continue;
|
|
360
363
|
const suggestion = suggestIcon(set, doc);
|
|
361
364
|
const hint = suggestion
|
|
362
|
-
? ` Suggested: astryx experimental icon map ${doc.name} ${suggestion.icon}.`
|
|
365
|
+
? ` Suggested: astryx experimental icon map ${doc.name} ${suggestion.icon} --set ${set.name}.`
|
|
363
366
|
: '';
|
|
364
367
|
issues.push(
|
|
365
368
|
issueError(
|
|
366
369
|
ICON_BUILTIN_DEFINITION_MISSING,
|
|
367
|
-
`${label} maps no icon to the built-in icon definition "${doc.name}" (${doc.description} Words: ${doc.words.join(', ')}.). Every set maps every built-in definition: run \`astryx experimental icon map ${doc.name} <icon id
|
|
370
|
+
`${label} maps no icon to the built-in icon definition "${doc.name}" (${doc.description} Words: ${doc.words.join(', ')}.). Every set maps every built-in definition: run \`astryx experimental icon map ${doc.name} <icon id> --set ${set.name}\` with the icon that draws it${findHint(set, doc)}.${hint}`,
|
|
368
371
|
),
|
|
369
372
|
);
|
|
370
373
|
}
|
|
@@ -382,7 +385,7 @@ function checkDefinitions(set) {
|
|
|
382
385
|
issues.push(
|
|
383
386
|
issueWarning(
|
|
384
387
|
ICON_DEFINITION_UNUSED,
|
|
385
|
-
`${label} declares the icon definition "${doc.name}", but "map" names no icon for it. Map it with \`astryx experimental icon map ${doc.name} <icon id
|
|
388
|
+
`${label} declares the icon definition "${doc.name}", but "map" names no icon for it. Map it with \`astryx experimental icon map ${doc.name} <icon id> --set ${set.name}\`, or remove definitions/${doc.name}.doc.mjs.${suggestion ? ` Suggested: astryx experimental icon map ${doc.name} ${suggestion.icon} --set ${set.name}.` : ''}`,
|
|
386
389
|
),
|
|
387
390
|
);
|
|
388
391
|
}
|
|
@@ -538,13 +541,7 @@ export function suggestedIcons(set, doc) {
|
|
|
538
541
|
...nameWords,
|
|
539
542
|
...wordIds.flatMap(id => id.split('-')).map(stem),
|
|
540
543
|
]);
|
|
541
|
-
const icons = set.data.icons
|
|
542
|
-
id: icon.id,
|
|
543
|
-
words: icon.id.split('-').map(stem),
|
|
544
|
-
raw: icon.id.split('-'),
|
|
545
|
-
// The library's other names for it, the same ones `map` accepts.
|
|
546
|
-
other: otherNamesOf(icon),
|
|
547
|
-
}));
|
|
544
|
+
const icons = suggestionIndex(set.data.icons);
|
|
548
545
|
/** How many of the definition's words an id has: more is a better fit. */
|
|
549
546
|
const fit = (/** @type {string[]} */ words) =>
|
|
550
547
|
words.filter(word => meaning.has(word)).length;
|
|
@@ -636,6 +633,29 @@ export function suggestedIcons(set, doc) {
|
|
|
636
633
|
return found.slice(0, SUGGESTIONS_PER_DEFINITION);
|
|
637
634
|
}
|
|
638
635
|
|
|
636
|
+
/**
|
|
637
|
+
* Each icon as the suggestion rules read it: its id's words as written and
|
|
638
|
+
* in singular form, and the library's other names for it (the same ones
|
|
639
|
+
* `map` accepts). Built once per list of icons, so suggesting for every
|
|
640
|
+
* definition of a large library reads each icon once.
|
|
641
|
+
* @type {WeakMap<object, Array<{id: string, words: string[], raw: string[], other: string[]}>>}
|
|
642
|
+
*/
|
|
643
|
+
const suggestionIndexes = new WeakMap();
|
|
644
|
+
|
|
645
|
+
/** @param {Array<{id: string, words?: string[]}>} list */
|
|
646
|
+
function suggestionIndex(list) {
|
|
647
|
+
const cached = suggestionIndexes.get(list);
|
|
648
|
+
if (cached) return cached;
|
|
649
|
+
const index = list.map(icon => ({
|
|
650
|
+
id: icon.id,
|
|
651
|
+
words: icon.id.split('-').map(stem),
|
|
652
|
+
raw: icon.id.split('-'),
|
|
653
|
+
other: otherNamesOf(icon),
|
|
654
|
+
}));
|
|
655
|
+
suggestionIndexes.set(list, index);
|
|
656
|
+
return index;
|
|
657
|
+
}
|
|
658
|
+
|
|
639
659
|
/**
|
|
640
660
|
* A word in its singular form, so a plural meets its singular and nothing
|
|
641
661
|
* else: `languages` meets `language`, `arrows` meets `arrow`. Only a
|
|
@@ -934,10 +954,10 @@ function findHint(set, doc) {
|
|
|
934
954
|
each => each.score >= FIND_FLOOR,
|
|
935
955
|
);
|
|
936
956
|
if (found.length > 0) {
|
|
937
|
-
return ` (icons matching "${query}": \`astryx experimental icon ${query} --set ${set.name}\`)`;
|
|
957
|
+
return ` (icons matching "${query}": \`astryx experimental icon ${shellArg(query)} --set ${set.name}\`)`;
|
|
938
958
|
}
|
|
939
959
|
}
|
|
940
|
-
return
|
|
960
|
+
return ` (no icon in the set has its name or words: pick the library icon that draws it; if the library has none, map the closest, or add your own artwork with \`astryx experimental icon add <Name> --from ./src/icons/<name>.js --definition ${doc.name} --set ${set.name}\`)`;
|
|
941
961
|
}
|
|
942
962
|
|
|
943
963
|
/**
|
|
@@ -166,29 +166,158 @@ export function modulePrefix(file: string, options?: {
|
|
|
166
166
|
adapter?: boolean;
|
|
167
167
|
exclude?: string[];
|
|
168
168
|
}): string[];
|
|
169
|
+
/**
|
|
170
|
+
* How a module names its icons: the library prefix every icon export shares
|
|
171
|
+
* ({@link modulePrefix}) and the look words its names end in
|
|
172
|
+
* ({@link lookPositions}), read from its icon exports once. A large module
|
|
173
|
+
* reports its reading, as {@link libraryIcons} does.
|
|
174
|
+
* @param {string} file
|
|
175
|
+
* @param {{adapter?: boolean, module?: string, progress?: (line: string) => void}} [options]
|
|
176
|
+
* `module`: the module as the author named it, for progress; `progress`:
|
|
177
|
+
* hears the reading of a large module
|
|
178
|
+
* @returns {{prefix: string[], positions: Array<Set<string>>}}
|
|
179
|
+
*/
|
|
180
|
+
export function moduleNaming(file: string, options?: {
|
|
181
|
+
adapter?: boolean;
|
|
182
|
+
module?: string;
|
|
183
|
+
progress?: (line: string) => void;
|
|
184
|
+
}): {
|
|
185
|
+
prefix: string[];
|
|
186
|
+
positions: Array<Set<string>>;
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* An export's id and set name ({@link iconNaming}) without the look words
|
|
190
|
+
* its library's names end in ({@link lookPositions}):
|
|
191
|
+
* `XOutline24WGHT500Icon` is `x`, `XIcon`.
|
|
192
|
+
* @param {string} name
|
|
193
|
+
* @param {{prefix: string[], positions: Array<Set<string>>}} naming
|
|
194
|
+
* @returns {{id: string, name: string}}
|
|
195
|
+
*/
|
|
196
|
+
export function iconNamingWithoutLook(name: string, { prefix, positions }: {
|
|
197
|
+
prefix: string[];
|
|
198
|
+
positions: Array<Set<string>>;
|
|
199
|
+
}): {
|
|
200
|
+
id: string;
|
|
201
|
+
name: string;
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* The trailing words a library encodes its looks with: a style, a size, a
|
|
205
|
+
* weight (`XOutline24WGHT500Icon` is `x` in the `outline`, `24`, `wght500`
|
|
206
|
+
* look). A trailing position is a look position when, across at least
|
|
207
|
+
* {@link LOOK_MIN_ICONS} icons, at most {@link LOOK_MAX_VALUES} words fill
|
|
208
|
+
* it, each on at least 5% of the icons and together on at least 90%, and
|
|
209
|
+
* those words name a look ({@link namesLook}); the positions are read from
|
|
210
|
+
* the end while they hold. Glyph names never meet that bar (`trash-2` and
|
|
211
|
+
* `clock-10` are a few icons each, and `up` and `down` are directions), so
|
|
212
|
+
* a library that encodes no looks has none. Reads each id once per
|
|
213
|
+
* position and keeps only counts.
|
|
214
|
+
* @param {string[]} ids every icon's id
|
|
215
|
+
* @returns {Array<Set<string>>} the look positions, the last word first
|
|
216
|
+
*/
|
|
217
|
+
export function lookPositions(ids: string[]): Array<Set<string>>;
|
|
218
|
+
/**
|
|
219
|
+
* An id's glyph words and its look words, by {@link lookPositions}:
|
|
220
|
+
* `x-outline-24-wght500` is `x` with `[wght500, 24, outline]`, null where
|
|
221
|
+
* the id has no look word.
|
|
222
|
+
* @param {string[]} words
|
|
223
|
+
* @param {Array<Set<string>>} positions
|
|
224
|
+
* @returns {{base: string[], look: Array<string | null>}}
|
|
225
|
+
*/
|
|
226
|
+
export function splitLook(words: string[], positions: Array<Set<string>>): {
|
|
227
|
+
base: string[];
|
|
228
|
+
look: Array<string | null>;
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* The word each look position prefers: a word of `prefer` it has (the set's
|
|
232
|
+
* default variant), else a usual default style word, else the middle of a
|
|
233
|
+
* series of numbered words (`wght300` … `wght700` gives `wght500`), else
|
|
234
|
+
* its first word in order.
|
|
235
|
+
* @param {Array<Set<string>>} positions
|
|
236
|
+
* @param {string[]} [prefer]
|
|
237
|
+
* @returns {string[]}
|
|
238
|
+
*/
|
|
239
|
+
export function preferredLook(positions: Array<Set<string>>, prefer?: string[]): string[];
|
|
240
|
+
/**
|
|
241
|
+
* One icon a library gives.
|
|
242
|
+
* @typedef {object} LibraryIcon
|
|
243
|
+
* @property {string} export the library export it reads
|
|
244
|
+
* @property {string} id
|
|
245
|
+
* @property {string} name the name the set exports it as
|
|
246
|
+
* @property {boolean} adapt
|
|
247
|
+
* @property {string[]} aliases the ids of the other names the library
|
|
248
|
+
* exports the icon as, leaving out the library's own name (`lucide-trash`)
|
|
249
|
+
* @property {Array<string | null>} [look] in a library that encodes looks:
|
|
250
|
+
* this export's look words by position, the last word first
|
|
251
|
+
* @property {string[]} [looks] in a library that encodes looks: every
|
|
252
|
+
* export that draws the glyph, this one included
|
|
253
|
+
*/
|
|
254
|
+
/**
|
|
255
|
+
* The words a library's looks are named by, and the look a set takes from
|
|
256
|
+
* it: what {@link libraryIcons} found, for the receipt.
|
|
257
|
+
* @typedef {object} LibraryLookSummary
|
|
258
|
+
* @property {string[][]} positions each position's words, sorted, the last
|
|
259
|
+
* word of a name first
|
|
260
|
+
* @property {string[]} preferred the word taken in each position
|
|
261
|
+
* @property {number} exports how many exports draw the icons
|
|
262
|
+
*/
|
|
169
263
|
/**
|
|
170
264
|
* Every icon a whole library exports, for wrapping it at once: one entry per
|
|
171
265
|
* component (and, with an adapter, per data export), read by its `…Icon`
|
|
172
266
|
* export when it has one (an alias of the same value is recorded once), with
|
|
173
267
|
* its id and the name the set exports it as from the name, the library
|
|
174
268
|
* prefix left out ({@link libraryPrefix}).
|
|
269
|
+
*
|
|
270
|
+
* A library that encodes looks in its export names ({@link lookPositions})
|
|
271
|
+
* gives one icon per glyph: the look {@link preferredLook} prefers, its id
|
|
272
|
+
* and name without the look words (`XOutline24WGHT500Icon` is `x`,
|
|
273
|
+
* `XIcon`), and its `looks`, every export that draws the glyph.
|
|
175
274
|
* @param {string} file
|
|
176
|
-
* @param {{adapter?: boolean, exclude?: string[]}} [options]
|
|
177
|
-
* whether the set declares one; `exclude`: export names that
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
275
|
+
* @param {{adapter?: boolean, exclude?: string[], prefer?: string[] | ((positions: Array<Set<string>>) => string[]), module?: string, progress?: (line: string) => void, summary?: (summary: LibraryLookSummary) => void}} [options]
|
|
276
|
+
* `adapter`: whether the set declares one; `exclude`: export names that
|
|
277
|
+
* are not icons; `prefer`: look words to prefer (the set's default
|
|
278
|
+
* variant), or a function that gives them from the library's look
|
|
279
|
+
* positions before any glyph is picked; `module`: the module as the author named it, for progress;
|
|
280
|
+
* `progress`: hears the reading of a large module;
|
|
281
|
+
* `summary`: hears the looks found, when the library has any
|
|
282
|
+
* @returns {LibraryIcon[]}
|
|
181
283
|
*/
|
|
182
284
|
export function libraryIcons(file: string, options?: {
|
|
183
285
|
adapter?: boolean;
|
|
184
286
|
exclude?: string[];
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
287
|
+
prefer?: string[] | ((positions: Array<Set<string>>) => string[]);
|
|
288
|
+
module?: string;
|
|
289
|
+
progress?: (line: string) => void;
|
|
290
|
+
summary?: (summary: LibraryLookSummary) => void;
|
|
291
|
+
}): LibraryIcon[];
|
|
292
|
+
/**
|
|
293
|
+
* The library's icons grouped by glyph when its export names encode looks
|
|
294
|
+
* ({@link libraryIcons}), with the look positions and the words preferred.
|
|
295
|
+
* Without look positions the icons are returned as they are.
|
|
296
|
+
* @param {LibraryIcon[]} all every icon, one per export
|
|
297
|
+
* @param {string[]} [prefer]
|
|
298
|
+
* @returns {{icons: LibraryIcon[], positions: Array<Set<string>>, preferred: string[]}}
|
|
299
|
+
*/
|
|
300
|
+
export function libraryLooks(all: LibraryIcon[], prefer?: string[]): {
|
|
301
|
+
icons: LibraryIcon[];
|
|
302
|
+
positions: Array<Set<string>>;
|
|
303
|
+
preferred: string[];
|
|
304
|
+
};
|
|
305
|
+
/**
|
|
306
|
+
* Every icon a library exports, one per export: {@link libraryIcons} before
|
|
307
|
+
* looks are grouped. A large module reports its reading, as
|
|
308
|
+
* {@link libraryIcons} does.
|
|
309
|
+
* @param {string} file
|
|
310
|
+
* @param {{adapter?: boolean, exclude?: string[], module?: string, progress?: (line: string) => void}} [options]
|
|
311
|
+
* `module`: the module as the author named it, for progress; `progress`:
|
|
312
|
+
* hears the reading of a large module
|
|
313
|
+
* @returns {LibraryIcon[]}
|
|
314
|
+
*/
|
|
315
|
+
export function everyLibraryIcon(file: string, options?: {
|
|
316
|
+
adapter?: boolean;
|
|
317
|
+
exclude?: string[];
|
|
318
|
+
module?: string;
|
|
319
|
+
progress?: (line: string) => void;
|
|
320
|
+
}): LibraryIcon[];
|
|
192
321
|
/**
|
|
193
322
|
* The source of one icon definition file, typed IconDefinitionDoc.
|
|
194
323
|
* @param {{name: string, description: string, words: string[]}} doc
|
|
@@ -199,13 +328,20 @@ export function iconDefinitionSource(doc: {
|
|
|
199
328
|
words: string[];
|
|
200
329
|
}): string;
|
|
201
330
|
/**
|
|
202
|
-
*
|
|
203
|
-
*
|
|
331
|
+
* A new definition's name as written in a command: camelCase as given, or
|
|
332
|
+
* kebab-case as the docs list definitions (`ai-helper` is `aiHelper`).
|
|
333
|
+
* @param {string} name
|
|
334
|
+
*/
|
|
335
|
+
export function definitionNameFromInput(name: string): string;
|
|
336
|
+
/**
|
|
337
|
+
* Check a new icon definition for a set: a camelCase name (or its kebab-case
|
|
338
|
+
* form, {@link definitionNameFromInput}) no Astryx definition has, a
|
|
339
|
+
* description, and at least one lower-case word.
|
|
204
340
|
* @param {DiscoveredIconSet} set
|
|
205
|
-
* @param {{name: string, description?: string, words?: string[]}}
|
|
341
|
+
* @param {{name: string, description?: string, words?: string[]}} given
|
|
206
342
|
* @returns {{name: string, description: string, words: string[]}}
|
|
207
343
|
*/
|
|
208
|
-
export function checkNewDefinition(set: DiscoveredIconSet,
|
|
344
|
+
export function checkNewDefinition(set: DiscoveredIconSet, given: {
|
|
209
345
|
name: string;
|
|
210
346
|
description?: string;
|
|
211
347
|
words?: string[];
|
|
@@ -232,6 +368,15 @@ export function writeDefinitionFile(set: DiscoveredIconSet, doc: {
|
|
|
232
368
|
description: string;
|
|
233
369
|
words: string[];
|
|
234
370
|
}): () => void;
|
|
371
|
+
/**
|
|
372
|
+
* Whether a generated declaration file declares what its generated module
|
|
373
|
+
* gives, statement by statement however a formatter left either file
|
|
374
|
+
* ({@link generatedStatements}); the header comment is ignored.
|
|
375
|
+
* @param {string} actual the declaration file as it is
|
|
376
|
+
* @param {string} expected {@link generatedTypesText} for the module
|
|
377
|
+
* @param {string} label the declaration file's path, for a parse error
|
|
378
|
+
*/
|
|
379
|
+
export function generatedTypesMatch(actual: string, expected: string, label: string): boolean;
|
|
235
380
|
/**
|
|
236
381
|
* The generated icons module of a set, from the package root: `generated`
|
|
237
382
|
* in its data file, else `<set directory>/<set>.generated.js`.
|
|
@@ -469,6 +614,55 @@ export class IconSetAuthoringError extends Error {
|
|
|
469
614
|
}
|
|
470
615
|
/** The theme map the generated module writes. */
|
|
471
616
|
export const THEME_MAP_NAME: "themeIcons";
|
|
617
|
+
/**
|
|
618
|
+
* One icon a library gives.
|
|
619
|
+
*/
|
|
620
|
+
export type LibraryIcon = {
|
|
621
|
+
/**
|
|
622
|
+
* the library export it reads
|
|
623
|
+
*/
|
|
624
|
+
export: string;
|
|
625
|
+
id: string;
|
|
626
|
+
/**
|
|
627
|
+
* the name the set exports it as
|
|
628
|
+
*/
|
|
629
|
+
name: string;
|
|
630
|
+
adapt: boolean;
|
|
631
|
+
/**
|
|
632
|
+
* the ids of the other names the library
|
|
633
|
+
* exports the icon as, leaving out the library's own name (`lucide-trash`)
|
|
634
|
+
*/
|
|
635
|
+
aliases: string[];
|
|
636
|
+
/**
|
|
637
|
+
* in a library that encodes looks:
|
|
638
|
+
* this export's look words by position, the last word first
|
|
639
|
+
*/
|
|
640
|
+
look?: (string | null)[] | undefined;
|
|
641
|
+
/**
|
|
642
|
+
* in a library that encodes looks: every
|
|
643
|
+
* export that draws the glyph, this one included
|
|
644
|
+
*/
|
|
645
|
+
looks?: string[] | undefined;
|
|
646
|
+
};
|
|
647
|
+
/**
|
|
648
|
+
* The words a library's looks are named by, and the look a set takes from
|
|
649
|
+
* it: what {@link libraryIcons} found, for the receipt.
|
|
650
|
+
*/
|
|
651
|
+
export type LibraryLookSummary = {
|
|
652
|
+
/**
|
|
653
|
+
* each position's words, sorted, the last
|
|
654
|
+
* word of a name first
|
|
655
|
+
*/
|
|
656
|
+
positions: string[][];
|
|
657
|
+
/**
|
|
658
|
+
* the word taken in each position
|
|
659
|
+
*/
|
|
660
|
+
preferred: string[];
|
|
661
|
+
/**
|
|
662
|
+
* how many exports draw the icons
|
|
663
|
+
*/
|
|
664
|
+
exports: number;
|
|
665
|
+
};
|
|
472
666
|
export type DiscoveredIconSet = import("./icon-set-discovery.mjs").DiscoveredIconSet;
|
|
473
667
|
export type IconSetData = import("../../authoring/doctypes/icon-set/type").IconSetData;
|
|
474
668
|
/**
|