@astryxdesign/cli 0.7.11-canary.3bbab18 → 0.7.11-canary.4e6e67d
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/icon/_authoring.mjs +228 -32
- package/api/icon/icon.type.d.mts +15 -0
- package/api/icon/icon.type.mjs +2 -0
- package/api/integration/add-helpers.d.mts +10 -1
- package/api/integration/add-helpers.mjs +1 -1
- package/api/swizzle/_adapter.d.mts +1 -0
- package/api/swizzle/_adapter.mjs +4 -1
- package/api/swizzle/_moduleGraph.d.mts +162 -0
- package/api/swizzle/_moduleGraph.mjs +754 -0
- package/api/swizzle/copy/copy.d.mts +2 -43
- package/api/swizzle/copy/copy.mjs +194 -314
- package/api/swizzle/swizzle.d.mts +0 -2
- package/api/swizzle/swizzle.doc.mjs +8 -4
- package/api/swizzle/swizzle.mjs +3 -7
- package/api/swizzle/swizzle.type.d.mts +1 -1
- package/api/swizzle/swizzle.type.mjs +2 -2
- package/assets/discover/official-packages.json +12 -0
- package/assets/docs/tree/icon-sets.doc.mjs +2 -2
- package/assets/templates/pages/file-explorer/page.tsx +103 -79
- package/clients/cli/commands/swizzle.doc.mjs +6 -3
- package/clients/cli/commands/swizzle.mjs +8 -9
- package/foundation/discovery/component-loader.d.mts +1 -1
- package/foundation/discovery/icon-set-checks.mjs +4 -15
- package/foundation/discovery/icon-set-discovery.d.mts +13 -0
- package/foundation/discovery/icon-set-discovery.mjs +25 -0
- package/foundation/discovery/icon-set-writer.d.mts +28 -0
- package/foundation/discovery/icon-set-writer.mjs +57 -0
- package/foundation/discovery/module-exports.mjs +57 -2
- package/foundation/fs/paths.d.mts +2 -1
- package/foundation/fs/paths.mjs +3 -4
- package/package.json +6 -6
package/api/icon/_authoring.mjs
CHANGED
|
@@ -48,6 +48,7 @@ import {
|
|
|
48
48
|
lookPositions,
|
|
49
49
|
moduleNaming,
|
|
50
50
|
nonIconExports,
|
|
51
|
+
packageRootMoves,
|
|
51
52
|
resolveIconSource,
|
|
52
53
|
peerNote,
|
|
53
54
|
typecheckNote,
|
|
@@ -61,6 +62,10 @@ import {
|
|
|
61
62
|
resolveDefaultLook,
|
|
62
63
|
} from './_default-look.mjs';
|
|
63
64
|
import {shellArg} from '../../foundation/text/shell-arg.mjs';
|
|
65
|
+
import {
|
|
66
|
+
hasLicenseNotice,
|
|
67
|
+
licenseNoticeFix,
|
|
68
|
+
} from '../../foundation/discovery/icon-set-discovery.mjs';
|
|
64
69
|
import {astryxIconDefinitions} from '../../foundation/discovery/icon-definition-discovery.mjs';
|
|
65
70
|
import {suggestedIcons} from '../../foundation/discovery/icon-set-checks.mjs';
|
|
66
71
|
import {
|
|
@@ -481,6 +486,11 @@ export async function addIconSet(name, options) {
|
|
|
481
486
|
writtenFiles,
|
|
482
487
|
dryRun,
|
|
483
488
|
);
|
|
489
|
+
const missingNotice = noticeToAdd(
|
|
490
|
+
library,
|
|
491
|
+
packageDir,
|
|
492
|
+
projectPath(path.relative(packageDir, setDir)),
|
|
493
|
+
);
|
|
484
494
|
{
|
|
485
495
|
result.data.icons = icons.length;
|
|
486
496
|
if (from != null) {
|
|
@@ -526,14 +536,38 @@ export async function addIconSet(name, options) {
|
|
|
526
536
|
...(from != null && lookFound.summary != null
|
|
527
537
|
? lookNotes(lookFound.summary, icons.length, from, looks, name)
|
|
528
538
|
: []),
|
|
539
|
+
...(missingNotice ? [missingNotice.note] : []),
|
|
529
540
|
...mappedNotes(map, name),
|
|
530
541
|
...suggestionNotes(suggestions, name),
|
|
531
542
|
'Run `astryx integration check` to see the icon definitions still to map.',
|
|
532
543
|
];
|
|
544
|
+
if (missingNotice) {
|
|
545
|
+
result.data.licenseNoticeMissing = missingNotice.receipt;
|
|
546
|
+
}
|
|
533
547
|
}
|
|
534
548
|
return result;
|
|
535
549
|
}
|
|
536
550
|
|
|
551
|
+
/**
|
|
552
|
+
* The license notice the author must add when the wrapped library ships no
|
|
553
|
+
* license file to copy and the package root has none. The CLI never writes
|
|
554
|
+
* it: the license text is the author's to state. Null when nothing is
|
|
555
|
+
* missing.
|
|
556
|
+
* @param {{package: string, version: string, notices: string[]} | null} library
|
|
557
|
+
* @param {string} packageDir
|
|
558
|
+
* @param {string} setDir the set directory, from the package root
|
|
559
|
+
* @returns {{note: string, receipt: {library: string, path: string}} | null}
|
|
560
|
+
*/
|
|
561
|
+
function noticeToAdd(library, packageDir, setDir) {
|
|
562
|
+
if (!library || library.notices.length > 0) return null;
|
|
563
|
+
if (hasLicenseNotice(packageDir)) return null;
|
|
564
|
+
const named = `${library.package}@${library.version}`;
|
|
565
|
+
return {
|
|
566
|
+
note: `${named} ships no LICENSE or NOTICE file to copy, so the set has no license notice. ${licenseNoticeFix(setDir, named)}`,
|
|
567
|
+
receipt: {library: named, path: `${setDir}/NOTICE`},
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
|
|
537
571
|
/**
|
|
538
572
|
* A set descriptor's source with `--display-name` and `--description`
|
|
539
573
|
* written into its fields; the rest as it was.
|
|
@@ -901,6 +935,70 @@ async function iconAuthoring(step) {
|
|
|
901
935
|
}
|
|
902
936
|
}
|
|
903
937
|
|
|
938
|
+
/**
|
|
939
|
+
* Whether an id is one an id rule derives from a library glyph: the glyph id,
|
|
940
|
+
* or its library export, broken into words another way (`squares-2-x2` for
|
|
941
|
+
* `squares-2x2`, `glyph-eye` for `glyphEye`). Any other id is the author's.
|
|
942
|
+
* @param {string} id
|
|
943
|
+
* @param {{id: string, export: string}} glyph
|
|
944
|
+
*/
|
|
945
|
+
function derivedId(id, glyph) {
|
|
946
|
+
const flat = (/** @type {string} */ text) =>
|
|
947
|
+
text.toLowerCase().replace(/[^a-z0-9]/gu, '');
|
|
948
|
+
return [glyph.id, glyph.export, glyph.export.replace(/Icon$/u, '')]
|
|
949
|
+
.map(flat)
|
|
950
|
+
.includes(flat(id));
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
/**
|
|
954
|
+
* Keep the root moves that give each root export to one export of the set.
|
|
955
|
+
* A root export that an export of the set already reads, or that an earlier
|
|
956
|
+
* move takes, stays where it is. The icon that would move keeps its own file,
|
|
957
|
+
* and its variants stay with it. Returns the kept moves and the ids of the
|
|
958
|
+
* icons that stay (with `(<variant>)` for a variant that stays).
|
|
959
|
+
* @param {{data: {module: string, icons: Array<{id: string, export: string, module?: string, variants?: Array<{variant: string, export: string}>}>}}} set
|
|
960
|
+
* @param {Map<string, {module: string, source: string}>} origins
|
|
961
|
+
* @param {string} root
|
|
962
|
+
* @param {Map<string, {source: string, from: string}>} moves
|
|
963
|
+
*/
|
|
964
|
+
function claimRootMoves(set, origins, root, moves) {
|
|
965
|
+
/** @type {Map<string, {source: string, from: string}>} */
|
|
966
|
+
const kept = new Map();
|
|
967
|
+
/** @type {string[]} */
|
|
968
|
+
const skipped = [];
|
|
969
|
+
const claimed = new Set(
|
|
970
|
+
[...origins.values()]
|
|
971
|
+
.filter(origin => sameIconModule(origin.module, root))
|
|
972
|
+
.map(origin => origin.source),
|
|
973
|
+
);
|
|
974
|
+
for (const icon of set.data.icons) {
|
|
975
|
+
if ((icon.module ?? set.data.module) !== set.data.module) continue;
|
|
976
|
+
const own = moves.get(icon.export);
|
|
977
|
+
const origin = origins.get(icon.export);
|
|
978
|
+
const readsRoot = origin != null && sameIconModule(origin.module, root);
|
|
979
|
+
if (own) {
|
|
980
|
+
if (claimed.has(own.source)) {
|
|
981
|
+
skipped.push(icon.id);
|
|
982
|
+
continue;
|
|
983
|
+
}
|
|
984
|
+
claimed.add(own.source);
|
|
985
|
+
kept.set(icon.export, own);
|
|
986
|
+
} else if (!readsRoot) continue;
|
|
987
|
+
for (const each of icon.variants ?? []) {
|
|
988
|
+
const move = moves.get(each.export);
|
|
989
|
+
if (!move) continue;
|
|
990
|
+
if (claimed.has(move.source)) {
|
|
991
|
+
skipped.push(`${icon.id} (${each.variant})`);
|
|
992
|
+
continue;
|
|
993
|
+
}
|
|
994
|
+
claimed.add(move.source);
|
|
995
|
+
kept.set(each.export, move);
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
skipped.sort();
|
|
999
|
+
return {moves: kept, skipped};
|
|
1000
|
+
}
|
|
1001
|
+
|
|
904
1002
|
/**
|
|
905
1003
|
* Wrap a library into an existing set again: its icons are replaced by what
|
|
906
1004
|
* the library exports now (an icon whose words the author extended keeps
|
|
@@ -972,9 +1070,27 @@ async function refreshIconSet(
|
|
|
972
1070
|
// map entries and variants.
|
|
973
1071
|
const generatedBefore = generatedModulePath(set, packageDir);
|
|
974
1072
|
const origins = generatedOrigins(packageDir, generatedBefore);
|
|
1073
|
+
// A refresh from a package root also supplies the exports that read one
|
|
1074
|
+
// file of that package, when the root exports the same icon. They move to
|
|
1075
|
+
// the root import, so the set has one import style.
|
|
1076
|
+
const {moves: rootMoves, skipped: skippedMoves} = claimRootMoves(
|
|
1077
|
+
set,
|
|
1078
|
+
origins,
|
|
1079
|
+
source.module,
|
|
1080
|
+
packageRootMoves(
|
|
1081
|
+
origins,
|
|
1082
|
+
source,
|
|
1083
|
+
everyIcon.map(icon => icon.export),
|
|
1084
|
+
where,
|
|
1085
|
+
),
|
|
1086
|
+
);
|
|
1087
|
+
/** @param {string} name the set's export */
|
|
1088
|
+
const libraryExportOf = name =>
|
|
1089
|
+
rootMoves.get(name)?.source ?? origins.get(name)?.source;
|
|
975
1090
|
/** @param {{export: string, module?: string}} icon */
|
|
976
1091
|
const suppliedHere = icon => {
|
|
977
1092
|
if ((icon.module ?? set.data.module) !== set.data.module) return false;
|
|
1093
|
+
if (rootMoves.has(icon.export)) return true;
|
|
978
1094
|
const origin = origins.get(icon.export);
|
|
979
1095
|
return origin != null && sameIconModule(origin.module, source.module);
|
|
980
1096
|
};
|
|
@@ -982,15 +1098,18 @@ async function refreshIconSet(
|
|
|
982
1098
|
const others = set.data.icons.filter(icon => !suppliedHere(icon));
|
|
983
1099
|
// An existing icon is the same icon when the library still exports it:
|
|
984
1100
|
// its identity is the library export its generated module re-exports
|
|
985
|
-
// (`HiSquares2X2Icon
|
|
986
|
-
// public names are derived, and a
|
|
987
|
-
// (`squares-2-x2` is now
|
|
988
|
-
//
|
|
989
|
-
//
|
|
1101
|
+
// (`HiSquares2X2Icon`, or the root export a per-file icon moves to), then
|
|
1102
|
+
// its public export, then its id. Ids and public names are derived, and a
|
|
1103
|
+
// newer rule may spell them differently (`squares-2-x2` is now
|
|
1104
|
+
// `squares-2x2`); an icon matched this way keeps its public export byte
|
|
1105
|
+
// for byte, every field it had (its variants, the words the author added,
|
|
1106
|
+
// its module), and its map entries. The same rule holds on every refresh,
|
|
1107
|
+
// so a second refresh changes nothing the first one wrote.
|
|
1108
|
+
const moving = new Set(supplied.filter(icon => rootMoves.has(icon.export)));
|
|
990
1109
|
const byId = new Map(supplied.map(icon => [icon.id, icon]));
|
|
991
1110
|
const byExport = new Map(supplied.map(icon => [icon.export, icon]));
|
|
992
1111
|
const bySource = new Map(
|
|
993
|
-
supplied.map(icon => [
|
|
1112
|
+
supplied.map(icon => [libraryExportOf(icon.export), icon]),
|
|
994
1113
|
);
|
|
995
1114
|
// One icon per glyph. A look the set already wraps keeps its icon and id.
|
|
996
1115
|
// A new glyph comes in once, in the preferred look. A new default variant
|
|
@@ -1003,15 +1122,20 @@ async function refreshIconSet(
|
|
|
1003
1122
|
const iconByExport = new Map(everyIcon.map(icon => [icon.export, icon]));
|
|
1004
1123
|
/** @type {string[]} the set's exports whose statement now names another look */
|
|
1005
1124
|
const repicked = [];
|
|
1125
|
+
/** @type {Map<string, (typeof supplied)[number]>} the new look's export → the icon it now draws */
|
|
1126
|
+
const repickedBy = new Map();
|
|
1006
1127
|
const found = looksOf.flatMap(icon => {
|
|
1007
1128
|
const wrapped = (icon.looks ?? []).filter(look => bySource.has(look));
|
|
1008
1129
|
if (wrapped.length === 0) return [icon];
|
|
1009
1130
|
return wrapped.map(look => {
|
|
1010
|
-
const prior = /** @type {
|
|
1131
|
+
const prior = /** @type {(typeof supplied)[number]} */ (
|
|
1011
1132
|
bySource.get(look)
|
|
1012
1133
|
);
|
|
1013
|
-
|
|
1134
|
+
// A moved icon is the glyph its root export draws, whatever its id.
|
|
1135
|
+
const sameGlyph = moving.has(prior) || prior.id === icon.id;
|
|
1136
|
+
if (moved && sameGlyph && !bySource.has(icon.export)) {
|
|
1014
1137
|
repicked.push(prior.export);
|
|
1138
|
+
repickedBy.set(icon.export, prior);
|
|
1015
1139
|
return icon;
|
|
1016
1140
|
}
|
|
1017
1141
|
const own = /** @type {(typeof everyIcon)[number]} */ (
|
|
@@ -1023,29 +1147,44 @@ async function refreshIconSet(
|
|
|
1023
1147
|
: own;
|
|
1024
1148
|
});
|
|
1025
1149
|
});
|
|
1026
|
-
/** @param {{export: string
|
|
1027
|
-
const
|
|
1028
|
-
bySource.get(
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
const
|
|
1033
|
-
const
|
|
1034
|
-
/** @type {string[]} library icons left out: an icon of
|
|
1150
|
+
/** @param {{export: string}} glyph */
|
|
1151
|
+
const resolvedPrior = glyph =>
|
|
1152
|
+
repickedBy.get(glyph.export) ?? bySource.get(glyph.export) ?? null;
|
|
1153
|
+
// An icon its library export already gives to one glyph is never given to
|
|
1154
|
+
// a second glyph by name or id: that glyph is left out.
|
|
1155
|
+
const resolved = new Set(found.map(resolvedPrior).filter(Boolean));
|
|
1156
|
+
const takenIds = new Set(others.map(icon => icon.id));
|
|
1157
|
+
const takenExports = new Set(others.map(icon => icon.export));
|
|
1158
|
+
/** @type {string[]} library icons left out: an icon of the set has the id or name */
|
|
1035
1159
|
const shadowed = [];
|
|
1036
1160
|
/** @type {Map<string, string>} old id → new id */
|
|
1037
1161
|
const renames = new Map();
|
|
1038
1162
|
/** @type {Map<string, string>} the library export → the set's export */
|
|
1039
1163
|
const publicName = new Map();
|
|
1040
1164
|
const fromLibrary = found.flatMap(icon => {
|
|
1041
|
-
const
|
|
1165
|
+
const byOrigin = resolvedPrior(icon);
|
|
1166
|
+
const byName = byOrigin
|
|
1167
|
+
? null
|
|
1168
|
+
: (byExport.get(icon.name) ?? byId.get(icon.id) ?? null);
|
|
1169
|
+
const prior = byOrigin ?? (resolved.has(byName) ? null : byName);
|
|
1042
1170
|
const name = prior?.export ?? icon.name;
|
|
1043
|
-
if (
|
|
1171
|
+
if (
|
|
1172
|
+
!prior &&
|
|
1173
|
+
(byName || takenIds.has(icon.id) || takenExports.has(name))
|
|
1174
|
+
) {
|
|
1044
1175
|
shadowed.push(icon.id);
|
|
1045
1176
|
return [];
|
|
1046
1177
|
}
|
|
1047
|
-
if (prior && prior.id !== icon.id) renames.set(prior.id, icon.id);
|
|
1048
1178
|
publicName.set(icon.export, name);
|
|
1179
|
+
if (prior && byOrigin && !derivedId(prior.id, icon)) {
|
|
1180
|
+
return [
|
|
1181
|
+
{
|
|
1182
|
+
...prior,
|
|
1183
|
+
words: [...new Set([...(prior.words ?? []), ...icon.aliases])],
|
|
1184
|
+
},
|
|
1185
|
+
];
|
|
1186
|
+
}
|
|
1187
|
+
if (prior && prior.id !== icon.id) renames.set(prior.id, icon.id);
|
|
1049
1188
|
// The words its old id gave are the old rule's, not the author's.
|
|
1050
1189
|
const oldIdWords =
|
|
1051
1190
|
prior && prior.id !== icon.id ? new Set(idWords(prior.id)) : new Set();
|
|
@@ -1065,6 +1204,32 @@ async function refreshIconSet(
|
|
|
1065
1204
|
];
|
|
1066
1205
|
});
|
|
1067
1206
|
const icons = [...fromLibrary, ...others];
|
|
1207
|
+
// An icon is listed under `moved` when it or one of its variants moves.
|
|
1208
|
+
/** @type {Array<{id: string, from: string, to: string}>} */
|
|
1209
|
+
const movedIcons = [];
|
|
1210
|
+
/** @type {import('../../foundation/discovery/icon-set-writer.mjs').GeneratedIcon[]} */
|
|
1211
|
+
const movedVariants = [];
|
|
1212
|
+
for (const icon of fromLibrary) {
|
|
1213
|
+
const variantMoves = (icon.variants ?? []).filter(each =>
|
|
1214
|
+
rootMoves.has(each.export),
|
|
1215
|
+
);
|
|
1216
|
+
for (const each of variantMoves) {
|
|
1217
|
+
const move = /** @type {{source: string, from: string}} */ (
|
|
1218
|
+
rootMoves.get(each.export)
|
|
1219
|
+
);
|
|
1220
|
+
movedVariants.push({
|
|
1221
|
+
name: each.export,
|
|
1222
|
+
from: source.module,
|
|
1223
|
+
source: move.source,
|
|
1224
|
+
adapt: iconByExport.get(move.source)?.adapt ?? false,
|
|
1225
|
+
});
|
|
1226
|
+
}
|
|
1227
|
+
const from = (
|
|
1228
|
+
rootMoves.get(icon.export) ?? rootMoves.get(variantMoves[0]?.export)
|
|
1229
|
+
)?.from;
|
|
1230
|
+
if (from) movedIcons.push({id: icon.id, from, to: source.module});
|
|
1231
|
+
}
|
|
1232
|
+
movedIcons.sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
1068
1233
|
// The icons this module supplied that it no longer exports: they leave
|
|
1069
1234
|
// the set and its generated module, and the receipt names them.
|
|
1070
1235
|
// Each is named for why it left: `--exclude` (or the data file's
|
|
@@ -1074,7 +1239,7 @@ async function refreshIconSet(
|
|
|
1074
1239
|
const keptExports = new Set(fromLibrary.map(each => each.export));
|
|
1075
1240
|
const gone = supplied.filter(icon => !keptExports.has(icon.export));
|
|
1076
1241
|
const isExcluded = (/** @type {{export: string}} */ icon) =>
|
|
1077
|
-
excludedNames.has(
|
|
1242
|
+
excludedNames.has(libraryExportOf(icon.export) ?? '') ||
|
|
1078
1243
|
excludedNames.has(icon.export);
|
|
1079
1244
|
const goneExcluded = gone.filter(isExcluded);
|
|
1080
1245
|
const goneMissing = gone.filter(icon => !isExcluded(icon));
|
|
@@ -1163,22 +1328,31 @@ async function refreshIconSet(
|
|
|
1163
1328
|
files.push(projectPath(path.relative(packageDir, target)));
|
|
1164
1329
|
}
|
|
1165
1330
|
if (!dryRun) {
|
|
1331
|
+
const rewritten = found
|
|
1332
|
+
.map(icon => ({
|
|
1333
|
+
name: publicName.get(icon.export) ?? icon.name,
|
|
1334
|
+
from: source.module,
|
|
1335
|
+
source: icon.export,
|
|
1336
|
+
adapt: icon.adapt,
|
|
1337
|
+
}))
|
|
1338
|
+
.filter(icon => publicName.has(icon.source))
|
|
1339
|
+
.concat(movedVariants);
|
|
1340
|
+
const rewrittenNames = new Set(rewritten.map(icon => icon.name));
|
|
1166
1341
|
const written = writeGeneratedIcons(
|
|
1167
1342
|
packageDir,
|
|
1168
1343
|
generated,
|
|
1169
1344
|
next,
|
|
1170
|
-
|
|
1171
|
-
.map(icon => ({
|
|
1172
|
-
name: publicName.get(icon.export) ?? icon.name,
|
|
1173
|
-
from: source.module,
|
|
1174
|
-
source: icon.export,
|
|
1175
|
-
adapt: icon.adapt,
|
|
1176
|
-
}))
|
|
1177
|
-
.filter(icon => publicName.has(icon.source)),
|
|
1345
|
+
rewritten,
|
|
1178
1346
|
// The icons the library no longer exports leave the module too; a
|
|
1179
1347
|
// renamed icon keeps its export. An icon moved to the new default
|
|
1180
|
-
// look keeps its export, which now names that look.
|
|
1181
|
-
|
|
1348
|
+
// look keeps its export, which now names that look. An export moved
|
|
1349
|
+
// to the root is written again with the root import. Every other
|
|
1350
|
+
// export stays as it is, because the data file still lists it.
|
|
1351
|
+
[
|
|
1352
|
+
...gone.map(icon => icon.export),
|
|
1353
|
+
...repicked,
|
|
1354
|
+
...[...rootMoves.keys()].filter(name => rewrittenNames.has(name)),
|
|
1355
|
+
],
|
|
1182
1356
|
);
|
|
1183
1357
|
files.push(...written.files);
|
|
1184
1358
|
try {
|
|
@@ -1230,13 +1404,30 @@ async function refreshIconSet(
|
|
|
1230
1404
|
if (renames.size > 0) {
|
|
1231
1405
|
result.data.renamed = [...renames].map(([from, to]) => ({from, to}));
|
|
1232
1406
|
}
|
|
1407
|
+
if (movedIcons.length > 0) result.data.moved = movedIcons;
|
|
1408
|
+
const missingNotice = hasLicenseNotice(set.dir)
|
|
1409
|
+
? null
|
|
1410
|
+
: noticeToAdd(
|
|
1411
|
+
library,
|
|
1412
|
+
packageDir,
|
|
1413
|
+
projectPath(path.relative(packageDir, set.dir)),
|
|
1414
|
+
);
|
|
1415
|
+
if (missingNotice) {
|
|
1416
|
+
result.data.licenseNoticeMissing = missingNotice.receipt;
|
|
1417
|
+
}
|
|
1233
1418
|
result.data.notes = [
|
|
1234
1419
|
...(licenseNote ? [licenseNote] : []),
|
|
1420
|
+
...(missingNotice ? [missingNotice.note] : []),
|
|
1235
1421
|
...(renames.size > 0
|
|
1236
1422
|
? [
|
|
1237
1423
|
`${renames.size} icons have a new id under this release's id rule, and keep their map entries, variants, and words: ${[...renames].map(([from, to]) => `${from} -> ${to}`).join(', ')}.`,
|
|
1238
1424
|
]
|
|
1239
1425
|
: []),
|
|
1426
|
+
...(movedIcons.length > 0
|
|
1427
|
+
? [
|
|
1428
|
+
`${movedIcons.length} icons now import from ${source.module} instead of one file each, and keep their ids, exports, map entries, variants, and words: ${movedIcons.map(each => each.id).join(', ')}.`,
|
|
1429
|
+
]
|
|
1430
|
+
: []),
|
|
1240
1431
|
...mappedNotes(byName, name),
|
|
1241
1432
|
...suggestionNotes(suggestions, name),
|
|
1242
1433
|
...(goneMissing.length > 0
|
|
@@ -1261,7 +1452,12 @@ async function refreshIconSet(
|
|
|
1261
1452
|
: []),
|
|
1262
1453
|
...(shadowed.length > 0
|
|
1263
1454
|
? [
|
|
1264
|
-
`Left out ${shadowed.length} library icons whose id or name an icon of
|
|
1455
|
+
`Left out ${shadowed.length} library icons whose id or name an icon of the set already has: ${shadowed.join(', ')}.`,
|
|
1456
|
+
]
|
|
1457
|
+
: []),
|
|
1458
|
+
...(skippedMoves.length > 0
|
|
1459
|
+
? [
|
|
1460
|
+
`${skippedMoves.length} icons stay on their own file, because another icon of the set already reads the same export of ${source.module}: ${skippedMoves.join(', ')}.`,
|
|
1265
1461
|
]
|
|
1266
1462
|
: []),
|
|
1267
1463
|
astryxIconDefinitions().definitions.every(({doc}) => map[doc.name])
|
package/api/icon/icon.type.d.mts
CHANGED
|
@@ -516,6 +516,21 @@ export type IconNewData = {
|
|
|
516
516
|
* - Without `from` on an existing set: its variants, default variant, display name, or description were updated in place, not created.
|
|
517
517
|
*/
|
|
518
518
|
updated?: boolean | undefined;
|
|
519
|
+
/**
|
|
520
|
+
* - On a refresh from a package root: the icons that read one file of that package (`from`) and now import from the root (`to`); each keeps its id, export, `map` entries, variants, and words.
|
|
521
|
+
*/
|
|
522
|
+
moved?: {
|
|
523
|
+
id: string;
|
|
524
|
+
from: string;
|
|
525
|
+
to: string;
|
|
526
|
+
}[] | undefined;
|
|
527
|
+
/**
|
|
528
|
+
* - With `from`: the wrapped library (`name@version`) ships no license file to copy and the set has none. `path` is where to add a NOTICE file that names the library and its license; the CLI never writes it.
|
|
529
|
+
*/
|
|
530
|
+
licenseNoticeMissing?: {
|
|
531
|
+
library: string;
|
|
532
|
+
path: string;
|
|
533
|
+
} | undefined;
|
|
519
534
|
/**
|
|
520
535
|
* - On a refresh: the icons whose id this release's id rule changes, matched by the export the library still has; each keeps its `map` entries, variants, and words.
|
|
521
536
|
*/
|
package/api/icon/icon.type.mjs
CHANGED
|
@@ -326,6 +326,8 @@
|
|
|
326
326
|
* @property {number} [icons] - With `from`: how many icons it wrote.
|
|
327
327
|
* @property {boolean} [refreshed] - With `from` on an existing set: the set was refreshed, not created.
|
|
328
328
|
* @property {boolean} [updated] - Without `from` on an existing set: its variants, default variant, display name, or description were updated in place, not created.
|
|
329
|
+
* @property {Array<{id: string, from: string, to: string}>} [moved] - On a refresh from a package root: the icons that read one file of that package (`from`) and now import from the root (`to`); each keeps its id, export, `map` entries, variants, and words.
|
|
330
|
+
* @property {{library: string, path: string}} [licenseNoticeMissing] - With `from`: the wrapped library (`name@version`) ships no license file to copy and the set has none. `path` is where to add a NOTICE file that names the library and its license; the CLI never writes it.
|
|
329
331
|
* @property {Array<{from: string, to: string}>} [renamed] - On a refresh: the icons whose id this release's id rule changes, matched by the export the library still has; each keeps its `map` entries, variants, and words.
|
|
330
332
|
* @property {Array<{definition: string, icon: string}>} [mapped] - With `from`: the `map` entries an icon with the definition's exact name gives (on a refresh, every such entry, kept or new); check each.
|
|
331
333
|
* @property {Array<{definition: string, icon: string, word: string}>} [suggestions] - With `from`: for each unmapped Astryx definition, up to three icons it might map to, best first: the definition's name in another spelling or as another name of an icon, ids that start with it, an id or another name that is one of its words, then two-word ids that are a one-word word sized, shaped, or numbered (`grid-2x2`); never a negated form, the opposite direction, or an icon already mapped. `word` is the name or word that matched. Never written.
|
|
@@ -92,7 +92,7 @@ export function loadCurrentManifest(manifestFile: string, manifestExists: boolea
|
|
|
92
92
|
* @param {string} manifestPath
|
|
93
93
|
* @param {string[]} files
|
|
94
94
|
* @param {boolean} dryRun
|
|
95
|
-
* @returns {{type: 'integration.add', data: Omit<import('./integration-authoring.type.mjs').IntegrationAddData, 'kind'> & {kind: K, icons?: number, refreshed?: boolean, updated?: boolean, renamed?: Array<{from: string, to: string}>, mapped?: Array<{definition: string, icon: string}>, suggestions?: Array<{definition: string, icon: string, word: string}>, notes?: string[]}}}
|
|
95
|
+
* @returns {{type: 'integration.add', data: Omit<import('./integration-authoring.type.mjs').IntegrationAddData, 'kind'> & {kind: K, icons?: number, refreshed?: boolean, updated?: boolean, renamed?: Array<{from: string, to: string}>, moved?: Array<{id: string, from: string, to: string}>, licenseNoticeMissing?: {library: string, path: string}, mapped?: Array<{definition: string, icon: string}>, suggestions?: Array<{definition: string, icon: string, word: string}>, notes?: string[]}}}
|
|
96
96
|
*/
|
|
97
97
|
export function receipt<K extends import("./integration-authoring.type.mjs").IntegrationAddData["kind"] | import("../icon/icon.type.mjs").IconNewData["kind"]>(kind: K, name: string, root: {
|
|
98
98
|
path: string;
|
|
@@ -108,6 +108,15 @@ export function receipt<K extends import("./integration-authoring.type.mjs").Int
|
|
|
108
108
|
from: string;
|
|
109
109
|
to: string;
|
|
110
110
|
}>;
|
|
111
|
+
moved?: Array<{
|
|
112
|
+
id: string;
|
|
113
|
+
from: string;
|
|
114
|
+
to: string;
|
|
115
|
+
}>;
|
|
116
|
+
licenseNoticeMissing?: {
|
|
117
|
+
library: string;
|
|
118
|
+
path: string;
|
|
119
|
+
};
|
|
111
120
|
mapped?: Array<{
|
|
112
121
|
definition: string;
|
|
113
122
|
icon: string;
|
|
@@ -486,7 +486,7 @@ export async function loadCurrentManifest(manifestFile, manifestExists) {
|
|
|
486
486
|
* @param {string} manifestPath
|
|
487
487
|
* @param {string[]} files
|
|
488
488
|
* @param {boolean} dryRun
|
|
489
|
-
* @returns {{type: 'integration.add', data: Omit<import('./integration-authoring.type.mjs').IntegrationAddData, 'kind'> & {kind: K, icons?: number, refreshed?: boolean, updated?: boolean, renamed?: Array<{from: string, to: string}>, mapped?: Array<{definition: string, icon: string}>, suggestions?: Array<{definition: string, icon: string, word: string}>, notes?: string[]}}}
|
|
489
|
+
* @returns {{type: 'integration.add', data: Omit<import('./integration-authoring.type.mjs').IntegrationAddData, 'kind'> & {kind: K, icons?: number, refreshed?: boolean, updated?: boolean, renamed?: Array<{from: string, to: string}>, moved?: Array<{id: string, from: string, to: string}>, licenseNoticeMissing?: {library: string, path: string}, mapped?: Array<{definition: string, icon: string}>, suggestions?: Array<{definition: string, icon: string, word: string}>, notes?: string[]}}}
|
|
490
490
|
*/
|
|
491
491
|
export function receipt(kind, name, root, manifestPath, files, dryRun) {
|
|
492
492
|
return {
|
package/api/swizzle/_adapter.mjs
CHANGED
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
* for its "component not found" suggestions. Resolving core + listing lives
|
|
10
10
|
* here once so neither leaf re-walks the filesystem. Throws AstryxError
|
|
11
11
|
* (ERR_CORE_NOT_FOUND) when core can't be located. The copy receipt's `gh`
|
|
12
|
-
* lookup is here too, on the shared search-path walk
|
|
12
|
+
* lookup is here too, on the shared search-path walk, and so is the copy's
|
|
13
|
+
* module graph (_moduleGraph.mjs), which reads the owner package's source.
|
|
13
14
|
*/
|
|
14
15
|
|
|
15
16
|
import {executablesOnSearchPath} from '../../foundation/env/search-path.mjs';
|
|
@@ -18,6 +19,8 @@ import {resolveComponentReplacements} from '../../foundation/discovery/component
|
|
|
18
19
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
19
20
|
import {AstryxError} from '../error.mjs';
|
|
20
21
|
|
|
22
|
+
export {planCopy, relativeSpecifierBetween, renderFile} from './_moduleGraph.mjs';
|
|
23
|
+
|
|
21
24
|
/**
|
|
22
25
|
* Whether an executable `gh` is on `PATH` (with a `PATHEXT` extension on
|
|
23
26
|
* Windows), found without running it. The copy receipt offers its
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A specifier that is either fixed (a public subpath) or computed from where
|
|
6
|
+
* two copied files land.
|
|
7
|
+
* @typedef {string | {from: string, to: string}} SpecifierChoice
|
|
8
|
+
*
|
|
9
|
+
* @typedef {object} PlannedEdit
|
|
10
|
+
* @property {number} start
|
|
11
|
+
* @property {number} end
|
|
12
|
+
* @property {(specifierOf: (choice: SpecifierChoice) => string) => string} render
|
|
13
|
+
*
|
|
14
|
+
* @typedef {object} CopyPlan
|
|
15
|
+
* @property {Map<string, {code: string, edits: PlannedEdit[]}>} files every
|
|
16
|
+
* file the copy holds (absolute source path), with the edits its imports need
|
|
17
|
+
* @property {Map<string, Set<string>>} dependsOn file -> carried files its
|
|
18
|
+
* computed specifiers point at
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Follow a component's module graph from its entry files and decide what the
|
|
22
|
+
* copy holds. A module inside the component folder is copied. A module
|
|
23
|
+
* outside it is reached through the owner package's public exports when every
|
|
24
|
+
* name taken from it is public there; otherwise the module that defines the
|
|
25
|
+
* name is copied, and imported by relative path. Tests, stories and docs are
|
|
26
|
+
* never reached, so they are never copied.
|
|
27
|
+
*
|
|
28
|
+
* @param {object} options
|
|
29
|
+
* @param {string} options.packageDir the owner package root
|
|
30
|
+
* @param {string} options.srcRoot its source root
|
|
31
|
+
* @param {string} options.componentDir
|
|
32
|
+
* @param {string} options.ownerPackage
|
|
33
|
+
* @param {string[]} options.entries absolute entry files of the component
|
|
34
|
+
* @returns {CopyPlan}
|
|
35
|
+
*/
|
|
36
|
+
export function planCopy({ packageDir, srcRoot, componentDir, ownerPackage, entries, }: {
|
|
37
|
+
packageDir: string;
|
|
38
|
+
srcRoot: string;
|
|
39
|
+
componentDir: string;
|
|
40
|
+
ownerPackage: string;
|
|
41
|
+
entries: string[];
|
|
42
|
+
}): CopyPlan;
|
|
43
|
+
/**
|
|
44
|
+
* The source of a planned file with its edits applied.
|
|
45
|
+
* @param {{code: string, edits: PlannedEdit[]}} planned
|
|
46
|
+
* @param {(choice: SpecifierChoice) => string} specifierOf
|
|
47
|
+
*/
|
|
48
|
+
export function renderFile(planned: {
|
|
49
|
+
code: string;
|
|
50
|
+
edits: PlannedEdit[];
|
|
51
|
+
}, specifierOf: (choice: SpecifierChoice) => string): string;
|
|
52
|
+
/**
|
|
53
|
+
* The relative specifier from one written file to another.
|
|
54
|
+
* @param {string} fromDest
|
|
55
|
+
* @param {string} toDest
|
|
56
|
+
*/
|
|
57
|
+
export function relativeSpecifierBetween(fromDest: string, toDest: string): string;
|
|
58
|
+
export type ImportSpecifier = {
|
|
59
|
+
/**
|
|
60
|
+
* the exported name (`default` for a default import)
|
|
61
|
+
*/
|
|
62
|
+
imported: string;
|
|
63
|
+
local: string;
|
|
64
|
+
typeOnly: boolean;
|
|
65
|
+
};
|
|
66
|
+
export type ModuleReference = {
|
|
67
|
+
kind: "named" | "namespace" | "sideEffect" | "dynamic" | "reexportAll" | "reexportNamed";
|
|
68
|
+
/**
|
|
69
|
+
* the specifier as written
|
|
70
|
+
*/
|
|
71
|
+
source: string;
|
|
72
|
+
/**
|
|
73
|
+
* statement (or, for `import()`, string literal) start
|
|
74
|
+
*/
|
|
75
|
+
start: number;
|
|
76
|
+
end: number;
|
|
77
|
+
/**
|
|
78
|
+
* the whole statement is `import type` / `export type`
|
|
79
|
+
*/
|
|
80
|
+
typeOnly: boolean;
|
|
81
|
+
specifiers: ImportSpecifier[];
|
|
82
|
+
/**
|
|
83
|
+
* the local name of `* as X`
|
|
84
|
+
*/
|
|
85
|
+
namespace?: string | undefined;
|
|
86
|
+
};
|
|
87
|
+
export type ParsedModule = {
|
|
88
|
+
code: string;
|
|
89
|
+
references: ModuleReference[];
|
|
90
|
+
/**
|
|
91
|
+
* names the module declares and exports
|
|
92
|
+
*/
|
|
93
|
+
declares: Set<string>;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* `value` reads runtime exports only;
|
|
97
|
+
* `type` reads type-only exports too
|
|
98
|
+
*/
|
|
99
|
+
export type ExportKind = "value" | "type";
|
|
100
|
+
/**
|
|
101
|
+
* every name a module exports, with where it is declared
|
|
102
|
+
*/
|
|
103
|
+
export type OriginsOf = (file: string, kind: ExportKind) => Map<string, {
|
|
104
|
+
file: string;
|
|
105
|
+
name: string;
|
|
106
|
+
}>;
|
|
107
|
+
/**
|
|
108
|
+
* `file#name` of a declaration -> the subpaths that export it, and as what
|
|
109
|
+
*/
|
|
110
|
+
export type ExportersByOrigin = Map<string, Array<{
|
|
111
|
+
subpath: string;
|
|
112
|
+
name: string;
|
|
113
|
+
}>>;
|
|
114
|
+
export type PublicSurface = {
|
|
115
|
+
/**
|
|
116
|
+
* the subpaths
|
|
117
|
+
* that export each declaration as a value, and as a value or a type
|
|
118
|
+
*/
|
|
119
|
+
byOrigin: Record<ExportKind, ExportersByOrigin>;
|
|
120
|
+
/**
|
|
121
|
+
* source file -> the subpath that
|
|
122
|
+
* exports exactly that file
|
|
123
|
+
*/
|
|
124
|
+
byFile: Map<string, string>;
|
|
125
|
+
exportsField: Record<string, unknown> | undefined;
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* A specifier that is either fixed (a public subpath) or computed from where
|
|
129
|
+
* two copied files land.
|
|
130
|
+
*/
|
|
131
|
+
export type SpecifierChoice = string | {
|
|
132
|
+
from: string;
|
|
133
|
+
to: string;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* A specifier that is either fixed (a public subpath) or computed from where
|
|
137
|
+
* two copied files land.
|
|
138
|
+
*/
|
|
139
|
+
export type PlannedEdit = {
|
|
140
|
+
start: number;
|
|
141
|
+
end: number;
|
|
142
|
+
render: (specifierOf: (choice: SpecifierChoice) => string) => string;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* A specifier that is either fixed (a public subpath) or computed from where
|
|
146
|
+
* two copied files land.
|
|
147
|
+
*/
|
|
148
|
+
export type CopyPlan = {
|
|
149
|
+
/**
|
|
150
|
+
* every
|
|
151
|
+
* file the copy holds (absolute source path), with the edits its imports need
|
|
152
|
+
*/
|
|
153
|
+
files: Map<string, {
|
|
154
|
+
code: string;
|
|
155
|
+
edits: PlannedEdit[];
|
|
156
|
+
}>;
|
|
157
|
+
/**
|
|
158
|
+
* file -> carried files its
|
|
159
|
+
* computed specifiers point at
|
|
160
|
+
*/
|
|
161
|
+
dependsOn: Map<string, Set<string>>;
|
|
162
|
+
};
|