@driftime/sanity-plugin-icon 0.4.0 → 0.4.2
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/README.md +32 -0
- package/dist/index.d.ts +15 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +68 -36
- package/dist/index.js.map +1 -1
- package/dist/next-loader.d.ts.map +1 -1
- package/dist/next-loader.js +7 -6
- package/dist/next-loader.js.map +1 -1
- package/dist/next.d.ts.map +1 -1
- package/dist/next.js +3 -2
- package/dist/next.js.map +1 -1
- package/dist/{registry-dxVzo7ZX.js → registry-B0Dxiwhh.js} +12 -2
- package/dist/registry-B0Dxiwhh.js.map +1 -0
- package/dist/{sets-DVh8eYeP.js → sets-D5_YGFll.js} +2 -2
- package/dist/{sets-DVh8eYeP.js.map → sets-D5_YGFll.js.map} +1 -1
- package/dist/vite.js +2 -2
- package/package.json +1 -1
- package/dist/registry-dxVzo7ZX.js.map +0 -1
package/README.md
CHANGED
|
@@ -278,6 +278,37 @@ export const contactIcons: SanityIconName<"lucide">[] = ["mail", "phone", "globe
|
|
|
278
278
|
|
|
279
279
|
<br />
|
|
280
280
|
|
|
281
|
+
### Initial Values
|
|
282
|
+
|
|
283
|
+
A field's `initialValue` names the icon a new document starts with. Once the build step has run, the name completes as it's typed.
|
|
284
|
+
|
|
285
|
+
```typescript
|
|
286
|
+
defineField({
|
|
287
|
+
name: "icon",
|
|
288
|
+
type: "icon",
|
|
289
|
+
description: "Icon shown beside the contact method.",
|
|
290
|
+
options: { library: "lucide", icons: ["mail", "phone", "globe"] },
|
|
291
|
+
initialValue: { name: "mail" },
|
|
292
|
+
});
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
The initial value holds only the name. The first time the field is shown, the Studio finds the icon in the field's icon library and stores it with its icon library, style, and drawing. Until then, the stored icon has a name but no drawing, and it fails validation like any other icon in that state. A name the field doesn't offer is left as it is, and during development a message in the console names the field.
|
|
296
|
+
|
|
297
|
+
Names complete from every icon library the build step listed, not only the field's. A function that returns the initial value needs `SanityIconInitialValue` as its return type, so the name is checked rather than widened to a string.
|
|
298
|
+
|
|
299
|
+
```typescript
|
|
300
|
+
import type { SanityIconInitialValue } from "@driftime/sanity-plugin-icon";
|
|
301
|
+
|
|
302
|
+
defineField({
|
|
303
|
+
name: "icon",
|
|
304
|
+
type: "icon",
|
|
305
|
+
description: "Icon shown beside the contact method.",
|
|
306
|
+
initialValue: (): SanityIconInitialValue => ({ name: "mail" }),
|
|
307
|
+
});
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
<br />
|
|
311
|
+
|
|
281
312
|
### The Project's Own Icons
|
|
282
313
|
|
|
283
314
|
A folder of SVG files becomes an icon library of its own. It might hold a brand's marks, or a complete icon set drawn for a brand or a product. Pass the folder's path, relative to the project, to the build step under an identifier. Fields then name that identifier as their icon library.
|
|
@@ -460,6 +491,7 @@ The drawing is written with the name, which is what lets an icon render without
|
|
|
460
491
|
| `SanityIconConfig` | `@driftime/sanity-plugin-icon` | Everything `iconPlugin` accepts. |
|
|
461
492
|
| `SanityIconOptions` | `@driftime/sanity-plugin-icon` | The `options` an icon field accepts. |
|
|
462
493
|
| `SanityIconDefinition` | `@driftime/sanity-plugin-icon` | A field or array member of type `icon`. |
|
|
494
|
+
| `SanityIconInitialValue` | `@driftime/sanity-plugin-icon` | The icon a field starts with. |
|
|
463
495
|
| `SanityIconSelection` | `@driftime/sanity-plugin-icon` | An icon library with a style and icons checked against it. |
|
|
464
496
|
| `SanityIconLibrary` | `@driftime/sanity-plugin-icon` | The identifier of a supported icon library. |
|
|
465
497
|
| `SanityIconStyle` | `@driftime/sanity-plugin-icon` | The styles of an icon library, given its identifier. |
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as iconTypeName, t as SanityIcon } from "./types-qlHEYDoN.js";
|
|
2
2
|
import { t as SanityIconBuildOptions } from "./vite-ifICG8y9.js";
|
|
3
|
-
import { BaseSchemaTypeOptions, TypeAliasDefinition } from "sanity";
|
|
3
|
+
import { BaseSchemaTypeOptions, InitialValueProperty, TypeAliasDefinition } from "sanity";
|
|
4
4
|
import { ComponentProps } from "react";
|
|
5
5
|
import { SanityIconNames } from "@driftime/sanity-plugin-icon/names";
|
|
6
6
|
/**
|
|
@@ -72,14 +72,25 @@ type SanityIconOptions = BaseSchemaTypeOptions & (SanityIconSelection | {
|
|
|
72
72
|
icons?: undefined;
|
|
73
73
|
});
|
|
74
74
|
/**
|
|
75
|
-
*
|
|
75
|
+
* Icon a field starts with. The Studio saves its drawing from the field's library the first time the field is shown.
|
|
76
|
+
*
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
|
+
interface SanityIconInitialValue {
|
|
80
|
+
/** Name of the icon, from any library the build step has listed. */
|
|
81
|
+
name: SanityIconName<ListedLibraryId>;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Definition of a field or array member holding an icon, so its options and initial value are type-checked like a
|
|
76
85
|
* built-in type's.
|
|
77
86
|
*
|
|
78
87
|
* @public
|
|
79
88
|
*/
|
|
80
|
-
interface SanityIconDefinition extends Omit<TypeAliasDefinition<typeof iconTypeName, undefined>, "options"> {
|
|
89
|
+
interface SanityIconDefinition extends Omit<TypeAliasDefinition<typeof iconTypeName, undefined>, "options" | "initialValue"> {
|
|
81
90
|
/** Options for the field. */
|
|
82
91
|
options?: SanityIconOptions;
|
|
92
|
+
/** Icon the field starts with, or a function that returns one. */
|
|
93
|
+
initialValue?: InitialValueProperty<unknown, SanityIconInitialValue>;
|
|
83
94
|
}
|
|
84
95
|
/**
|
|
85
96
|
* Plugin configuration, naming the library every icon field uses unless it names its own.
|
|
@@ -120,5 +131,5 @@ type DrawingProps = Omit<ComponentProps<"svg">, "children"> & {
|
|
|
120
131
|
* @public
|
|
121
132
|
*/
|
|
122
133
|
export declare function createIconPreview(value: SanityIcon | undefined): (() => import("react").FunctionComponentElement<DrawingProps>) | undefined;
|
|
123
|
-
export type { SanityIconBuildOptions, SanityIconConfig, SanityIconDefinition, SanityIconLibrary, SanityIconName, SanityIconOptions, SanityIconSelection, SanityIconStyle };
|
|
134
|
+
export type { SanityIconBuildOptions, SanityIconConfig, SanityIconDefinition, SanityIconInitialValue, SanityIconLibrary, SanityIconName, SanityIconOptions, SanityIconSelection, SanityIconStyle };
|
|
124
135
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["SanityIconNames","BaseSchemaTypeOptions","TypeAliasDefinition","iconLibraryStyles","iconTypeName","_0","SanityIconDefinition","sideEffect","IconLibraryStyles","SanityIconLibrary","SanityIconStyle","Library","SanityIconName","ListedLibraryId","NonNullable","Extract","IconLibraryId","SanityIconSelection","SanityIconOptions","Omit","SanityIconConfig","iconPlugin","IconElement","Record","IconNode","IconRoot","IconDrawing","iconSvgAttributes","findDrawingProblem","root","node","parseIconNode","parseIconRoot","resolveIconDrawing","serializeIconDrawing","ComponentProps","IconDrawing","DrawingProps","Omit","Drawing","drawing","JSX","_$__components_drawing0","SanityIcon","createIconPreview","DrawingProps","_$__components_drawing0.DrawingProps"],"sources":["../src/lib/libraries.ts","../src/plugin.ts","../src/lib/nodes.ts","../src/components/drawing.tsx","../src/lib/preview.ts"],"mappings":";;;;;;;;;cAiEa;WACX;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;YC/DU;;IAER,
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["SanityIconNames","BaseSchemaTypeOptions","InitialValueProperty","TypeAliasDefinition","iconLibraryStyles","iconTypeName","_0","SanityIconDefinition","sideEffect","IconLibraryStyles","SanityIconLibrary","SanityIconStyle","Library","SanityIconName","ListedLibraryId","NonNullable","Extract","IconLibraryId","SanityIconSelection","SanityIconOptions","SanityIconInitialValue","Omit","SanityIconConfig","iconPlugin","IconElement","Record","IconNode","IconRoot","IconDrawing","iconSvgAttributes","findDrawingProblem","root","node","parseIconNode","parseIconRoot","resolveIconDrawing","serializeIconDrawing","ComponentProps","IconDrawing","DrawingProps","Omit","Drawing","drawing","JSX","_$__components_drawing0","SanityIcon","createIconPreview","DrawingProps","_$__components_drawing0.DrawingProps"],"sources":["../src/lib/libraries.ts","../src/plugin.ts","../src/lib/nodes.ts","../src/components/drawing.tsx","../src/lib/preview.ts"],"mappings":";;;;;;;;;cAiEa;WACX;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;YC/DU;;IAER,MAAMO;;;;KAKLE,2BAA2BL;;;;;;KAOpBM,0BAA0BD;;;;;;KAO1BE,gBAAgB,0BAA0BC,gBAAgBF,oBAClED,kBAAkBG;;;;;;KAQVC,eAAe,0BAA0BD,sBAAsBZ,kBACvEA,gBAAgBY;;KAIfE,yBAAyBd,4CACjBe,uBACTC,cAAchB;;KAGbiB,gBAAgBP,oBAAoBI;;;;;;KAO7BI,yBACT,WAAWD;;EAEV,SAASL;;EAET,QAAQD,gBAAgBC;;EAExB,QAAQC,eAAeD;KAEzBK;;;;;;;KAQUE,oBAAoBlB,yBAC7BiB;EAAwB;EAAqB;EAAmB;;;;;;;UAOlDE;;EAEf,MAAMP,eAAeC;;;;;;;;UASNP,6BAA6Bc,KAC5ClB,2BAA2BE;;EAI3B,UAAUc;;EAEV,eAAejB,8BAA8BkB;;;;;;;KAQnCE,mBAAmBJ;;;;;;;;;wBAiBfK,WAAW,QAAQD,oCAAgB;;KCzHvCE,eAAe,iBAAiB,YAAYC,wBAAwB,YAAYD;;KAGhFE,WAAWF;;KAGXG,WAAWF;;UAGNG;;EAEf,MAAMD;;EAEN,MAAMD;;KCuCIa,eAAeC,KAAKH;EAAuC,SAASC;;;;;;;;;wBC1ChEQ,kBAAkB,OAAOD,gDAAsB,yBAAtBD"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as pluginName, t as parseIconSet } from "./sets-kepuObH8.js";
|
|
1
|
+
import { n as logger, r as pluginName, t as parseIconSet } from "./sets-kepuObH8.js";
|
|
2
2
|
import { n as isDefined, t as convertCase } from "./utils-COPacfAq.js";
|
|
3
3
|
import { a as resolveIconDrawing, o as serializeIconDrawing } from "./nodes-DAzj56Xn.js";
|
|
4
4
|
import { t as Drawing } from "./drawing-ByrcBbWB.js";
|
|
@@ -941,6 +941,23 @@ function resolveIconOptions(options, config) {
|
|
|
941
941
|
/** Schema type name of the icon object. */
|
|
942
942
|
const iconTypeName = "icon";
|
|
943
943
|
/**
|
|
944
|
+
* Creates the patches that store an icon, with the library and style it was chosen from.
|
|
945
|
+
*
|
|
946
|
+
* @param icon - The icon.
|
|
947
|
+
* @param library - Identifier of the library, or undefined when none is set.
|
|
948
|
+
* @param style - Identifier of the style, or undefined for the library's default.
|
|
949
|
+
* @returns The patches.
|
|
950
|
+
*/
|
|
951
|
+
function createSelectionPatches(icon, library, style) {
|
|
952
|
+
return [
|
|
953
|
+
setIfMissing({ _type: iconTypeName }),
|
|
954
|
+
isDefined(library) ? set(library, ["library"]) : unset(["library"]),
|
|
955
|
+
isDefined(style) ? set(style, ["style"]) : unset(["style"]),
|
|
956
|
+
set(icon.name, ["name"]),
|
|
957
|
+
set(serializeIconDrawing(icon.drawing), ["node"])
|
|
958
|
+
];
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
944
961
|
* Creates the icon field input, bound to the plugin's configuration. A field's own icons replace the
|
|
945
962
|
* plugin's rather than adding to them.
|
|
946
963
|
*
|
|
@@ -949,39 +966,54 @@ const iconTypeName = "icon";
|
|
|
949
966
|
*/
|
|
950
967
|
function createInput(config) {
|
|
951
968
|
function Input(t0) {
|
|
952
|
-
let $ = c(
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
969
|
+
let $ = c(28), { id, schemaType, value, onChange, readOnly } = t0, { library: storedLibrary, name, node } = value ?? {}, [open, setOpen] = useState(!1), { library, style, icons } = resolveIconOptions(schemaType.options, config), selectedDrawing = resolveIconDrawing(node), selectedName = storedLibrary === library ? name : void 0, selectedLabel = isDefined(name) ? convertCase(name, "title") : void 0, undrawnName = isDefined(node) ? void 0 : name;
|
|
970
|
+
useEffect(() => {
|
|
971
|
+
let active = !0;
|
|
972
|
+
return (async function saveDrawing() {
|
|
973
|
+
if (!isDefined(undrawnName) || readOnly === !0) return;
|
|
974
|
+
let { icons: libraryIcons } = await requestLibrary(library, style);
|
|
975
|
+
if (!active || !isDefined(libraryIcons)) return;
|
|
976
|
+
let icon = selectIcons(libraryIcons, icons).find((candidate) => candidate.name === undrawnName);
|
|
977
|
+
if (!isDefined(icon)) {
|
|
978
|
+
logger.warn(`The icon field "${id}" starts with "${undrawnName}", which isn't one of its icons. Change its initialValue.`);
|
|
979
|
+
return;
|
|
980
|
+
}
|
|
981
|
+
onChange(createSelectionPatches(icon, library, style));
|
|
982
|
+
})(), () => {
|
|
983
|
+
active = !1;
|
|
984
|
+
};
|
|
985
|
+
}, [
|
|
986
|
+
id,
|
|
987
|
+
undrawnName,
|
|
988
|
+
readOnly,
|
|
989
|
+
library,
|
|
990
|
+
style,
|
|
991
|
+
icons,
|
|
992
|
+
onChange
|
|
993
|
+
]);
|
|
994
|
+
let handleSelect = function handleSelect(icon_0) {
|
|
995
|
+
onChange(createSelectionPatches(icon_0, library, style)), setOpen(!1);
|
|
996
|
+
}, T0 = Flex, T1 = Button, t4 = isDefined(selectedDrawing) ? /* @__PURE__ */ jsx(Drawing, {
|
|
965
997
|
drawing: selectedDrawing,
|
|
966
998
|
width: "1em",
|
|
967
999
|
height: "1em"
|
|
968
|
-
}) : /* @__PURE__ */ jsx(SquareDashedIcon, { ...defaultIconProps }),
|
|
969
|
-
$[
|
|
1000
|
+
}) : /* @__PURE__ */ jsx(SquareDashedIcon, { ...defaultIconProps }), t5 = selectedLabel ?? "Select icon", t6;
|
|
1001
|
+
$[0] === setOpen ? t6 = $[1] : (t6 = () => {
|
|
970
1002
|
setOpen(!0);
|
|
971
|
-
}, $[
|
|
972
|
-
let
|
|
973
|
-
$[
|
|
1003
|
+
}, $[0] = setOpen, $[1] = t6);
|
|
1004
|
+
let t7 = isDefined(selectedLabel) ? `${selectedLabel} currently selected` : "Select icon", t8;
|
|
1005
|
+
$[2] !== T1 || $[3] !== id || $[4] !== readOnly || $[5] !== t4 || $[6] !== t5 || $[7] !== t6 || $[8] !== t7 ? (t8 = /* @__PURE__ */ jsx(T1, {
|
|
974
1006
|
id,
|
|
975
1007
|
type: "button",
|
|
976
1008
|
mode: "ghost",
|
|
977
|
-
icon:
|
|
978
|
-
text:
|
|
1009
|
+
icon: t4,
|
|
1010
|
+
text: t5,
|
|
979
1011
|
disabled: readOnly,
|
|
980
|
-
onClick:
|
|
981
|
-
"aria-label":
|
|
982
|
-
}), $[
|
|
983
|
-
let
|
|
984
|
-
$[
|
|
1012
|
+
onClick: t6,
|
|
1013
|
+
"aria-label": t7
|
|
1014
|
+
}), $[2] = T1, $[3] = id, $[4] = readOnly, $[5] = t4, $[6] = t5, $[7] = t6, $[8] = t7, $[9] = t8) : t8 = $[9];
|
|
1015
|
+
let t9;
|
|
1016
|
+
$[10] !== onChange || $[11] !== readOnly || $[12] !== value ? (t9 = isDefined(value) && /* @__PURE__ */ jsx(Button, {
|
|
985
1017
|
type: "button",
|
|
986
1018
|
mode: "ghost",
|
|
987
1019
|
tone: "critical",
|
|
@@ -992,9 +1024,9 @@ function createInput(config) {
|
|
|
992
1024
|
onChange(unset());
|
|
993
1025
|
},
|
|
994
1026
|
"aria-label": "Clear the selected icon"
|
|
995
|
-
}), $[
|
|
996
|
-
let
|
|
997
|
-
$[
|
|
1027
|
+
}), $[10] = onChange, $[11] = readOnly, $[12] = value, $[13] = t9) : t9 = $[13];
|
|
1028
|
+
let t10;
|
|
1029
|
+
$[14] !== handleSelect || $[15] !== icons || $[16] !== id || $[17] !== library || $[18] !== open || $[19] !== selectedName || $[20] !== setOpen || $[21] !== style ? (t10 = open && /* @__PURE__ */ jsx(Picker, {
|
|
998
1030
|
id: `${id}-library`,
|
|
999
1031
|
library,
|
|
1000
1032
|
iconStyle: style,
|
|
@@ -1007,16 +1039,16 @@ function createInput(config) {
|
|
|
1007
1039
|
onClickOutside: () => {
|
|
1008
1040
|
setOpen(!1);
|
|
1009
1041
|
}
|
|
1010
|
-
}), $[
|
|
1011
|
-
let
|
|
1012
|
-
return $[
|
|
1042
|
+
}), $[14] = handleSelect, $[15] = icons, $[16] = id, $[17] = library, $[18] = open, $[19] = selectedName, $[20] = setOpen, $[21] = style, $[22] = t10) : t10 = $[22];
|
|
1043
|
+
let t11;
|
|
1044
|
+
return $[23] !== T0 || $[24] !== t10 || $[25] !== t8 || $[26] !== t9 ? (t11 = /* @__PURE__ */ jsxs(T0, {
|
|
1013
1045
|
gap: 2,
|
|
1014
1046
|
children: [
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1047
|
+
t8,
|
|
1048
|
+
t9,
|
|
1049
|
+
t10
|
|
1018
1050
|
]
|
|
1019
|
-
}), $[
|
|
1051
|
+
}), $[23] = T0, $[24] = t10, $[25] = t8, $[26] = t9, $[27] = t11) : t11 = $[27], t11;
|
|
1020
1052
|
}
|
|
1021
1053
|
return Input;
|
|
1022
1054
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["isDefined","useState","ArrayOfObjectsFormNode","ArrayOfObjectsMember","BaseFormNode","DocumentFieldActionNode","ObjectFieldProps","ObjectFormNode","ObjectMember","ChangeIndicator","FieldActionsProvider","FieldActionsResolver","FormField","getPublishedId","useFormValue","hasMembers","node","collectNodeValidation","validation","collectMemberValidation","members","flatMap","member","kind","field","fieldSet","item","FieldProps","Field","t0","$","_c","actions","schemaType","title","description","presence","level","inputId","path","changed","children","inputProps","t1","Symbol","for","headerActions","setHeaderActions","t2","documentId","fieldValidation","focused","t3","publishedId","undefined","t4","name","t5","readOnly","deprecated","t6","t7","_c","ComponentProps","ComponentType","createElement","defaultIconProps","width","height","strokeWidth","createSanityIcon","icon","props","Icon","SanityIcon","gridCellSize","gridRowGap","gridRowHeight","gridColumns","gridVisibleRows","gridHeight","gridOverscan","gridLayoutStyle","justifyItems","rowGap","const","Button","ComponentProps","Drawing","gridCellSize","LibraryIcon","CellProps","Omit","icon","selected","focusable","position","total","onSelect","onHover","element","HTMLElement","Cell","t0","$","_c","props","t1","t2","Symbol","for","width","height","t3","drawing","t4","t5","event","currentTarget","t6","label","_c","isDefined","Box","Button","Flex","Grid","Text","ComponentProps","RefObject","CellProps","Cell","gridColumns","gridHeight","gridLayoutStyle","gridRowHeight","getVisibleRows","LibraryIcon","LibraryProps","Omit","icons","rows","ReturnType","selected","activeIndex","activeCell","HTMLButtonElement","search","onSelect","icon","onHover","onClearSearch","Library","t0","$","_c","props","totalRows","firstRow","lastRow","T0","t1","t2","t3","t4","t5","t6","visible","slice","height","overflowY","undefined","paddingTop","paddingBottom","map","offset","index","name","length","t7","_c","WarningOutlineIcon","Card","Flex","Stack","Text","ComponentProps","LibraryProblem","CodeTextProps","Omit","text","CodeText","t0","$","_c","props","t1","t2","parts","split","map","part","index","start","slice","join","length","t3","ProblemProps","problem","Problem","Symbol","for","title","description","t4","t5","_c","Button","Flex","Grid","Stack","Text","ComponentProps","CellProps","Cell","gridColumns","gridLayoutStyle","LibraryIcon","RecentProps","Omit","icons","selected","onSelect","icon","onHover","onForget","Recent","t0","$","_c","props","t1","Symbol","for","t2","t3","t4","length","index","name","map","t5","_c","iconRegistry","convertCase","isDefined","IconDrawing","getIconSetKey","parseIconSet","LibraryIcon","name","label","tags","drawing","terms","LibraryProblem","title","description","LibraryResult","icons","problem","normalizeTerms","value","toLowerCase","replaceAll","trim","splitMatches","text","query","start","match","pattern","split","map","word","String","raw","join","parts","RegExp","part","index","slice","length","selectIcons","library","names","byName","Map","icon","Set","flatMap","get","formatList","identifiers","identifier","describeMissingLibrary","packageName","family","listed","sitePackage","readLibrary","style","Promise","ready","info","libraries","Object","keys","packagePrefix","styles","installed","resolvedStyle","loader","sets","module","set","default","keywords","node","root","libraryRequests","requestLibrary","key","request","result","isDefined","Stack","Text","Popover","CSSProperties","ComponentProps","LibraryIcon","splitMatches","HoveredIcon","icon","element","HTMLElement","tooltipMargins","matchStyle","background","color","textDecorationLine","textUnderlineOffset","HighlightProps","Omit","text","query","Highlight","t0","$","_c","props","t1","map","_temp","t2","part","match","start","TooltipProps","hovered","Tooltip","t3","Symbol","for","pointerEvents","t4","maxWidth","label","tags","t5","_c","_temp","useEffect","useState","LibraryResult","requestLibrary","useIconLibrary","library","style","$","_c","result","setResult","t0","t1","active","load","loaded","_c","isDefined","useEffect","useRef","useState","HoveredIcon","LibraryIcon","useIconTooltip","scrolling","$","_c","hovered","setHovered","hoverStart","undefined","scrolledOnto","t0","t1","Symbol","for","current","clearTimeout","t2","t3","landed","element","isConnected","matches","setTimeout","t4","clearHover","t5","handleHover","icon","t6","_c","storageKey","limit","getStorageKey","scope","readRecent","stored","JSON","parse","globalThis","localStorage","getItem","Array","isArray","filter","entry","writeRecent","name","updated","slice","setItem","stringify","clearRecent","removeItem","useState","clearRecent","readRecent","writeRecent","useRecentIcons","scope","$","_c","t0","recent","setRecent","t1","remember","name","t2","forget","t3","_c","gridColumns","gridHeight","gridOverscan","gridRowHeight","gridVisibleRows","getNextIndex","key","current","last","undefined","getVisibleRows","scrollRow","count","totalRows","Math","ceil","firstRow","max","lastRow","min","getCenteredScrollTop","index","floor","getRevealedScrollTop","scrollTop","top","isDefined","SearchIcon","Box","Dialog","Flex","Spinner","Stack","Text","TextInput","ChangeEvent","ComponentProps","KeyboardEvent","useEffect","useRef","useState","Library","Problem","Recent","Tooltip","gridHeight","gridRowHeight","useIconLibrary","useIconTooltip","useRecentIcons","getCenteredScrollTop","getNextIndex","getRevealedScrollTop","getVisibleRows","LibraryIcon","normalizeTerms","selectIcons","getIconSetKey","PickerProps","Omit","library","iconStyle","allowed","selected","onSelect","icon","Picker","t0","$","_c","libraryName","props","result","icons","t1","t2","t3","recent","remember","forget","search","setSearch","scrollRow","setScrollRow","movedIndex","setMovedIndex","scrolling","setScrolling","scroller","activeCell","focusIndex","undefined","scrollFrame","scrollStop","query","searching","results","filter","terms","includes","byName","Map","map","_temp","recentIcons","flatMap","entry","icon_1","get","hovered","handleHover","clearHover","rows","length","selectedIndex","findIndex","icon_2","name","activeIndex","Math","max","element","current","scrollTop","t4","t5","Symbol","for","cancelAnimationFrame","clearTimeout","t6","t7","focus","t8","handleSelect","icon_3","t9","clearSearch","handleSearch","event","currentTarget","value","selectActive","icon_4","handleSearchKeyDown","event_0","key","preventDefault","handleScroll","setTimeout","requestAnimationFrame","element_0","floor","handleGridKeyDown","event_1","last","next","index","min","element_1","T0","t10","t11","T1","t12","t13","t14","problem","t15","height","t16","t17","t18","toLocaleString","t19","t20","t21","t22","icon_0","_c","ComponentProps","SquareDashedIconProps","SquareDashedIcon","props","$","_c","t0","t1","t10","t11","t2","t3","t4","t5","t6","t7","t8","t9","Symbol","for","t12","_c","isDefined","SanityIconConfig","SanityIconOptions","SanityIconSelection","resolveIconOptions","options","config","library","style","icons","Partial","iconTypeName","SanityIcon","_type","library","style","name","node","defaultIconProps","convertCase","isDefined","CloseIcon","Button","Flex","useState","ObjectInputProps","ObjectSchemaType","set","setIfMissing","unset","Drawing","Picker","SquareDashedIcon","LibraryIcon","resolveIconDrawing","serializeIconDrawing","resolveIconOptions","SanityIconConfig","SanityIconOptions","SanityIcon","iconTypeName","IconSchemaType","options","InputProps","Partial","createInput","config","Input","t0","$","_c","id","schemaType","value","onChange","readOnly","library","storedLibrary","name","node","open","setOpen","t1","style","icons","selectedDrawing","selectedName","undefined","selectedLabel","t2","handleSelect","icon","_type","drawing","T0","t3","T1","t4","t5","t6","t7","t8","t9","t10","t11","t12","t13","_c","isDefined","createElement","Drawing","resolveIconDrawing","SanityIcon","createIconPreview","value","drawing","node","undefined","IconPreview","width","height","Field","createSanityIcon","convertCase","isDefined","defineField","defineType","createInput","SquareDashedIcon","createIconPreview","SanityIconConfig","SanityIcon","iconTypeName","createIconType","config","name","type","icon","description","components","field","input","validation","rule","custom","value","Partial","node","preview","select","prepare","selection","title","media","_type","fields","SanityIconNames","BaseSchemaTypeOptions","TypeAliasDefinition","definePlugin","pluginName","iconLibraryStyles","createIconType","iconTypeName","IntrinsicDefinitions","icon","SanityIconDefinition","IconLibraryStyles","SanityIconLibrary","SanityIconStyle","Library","SanityIconName","ListedLibraryId","NonNullable","Extract","IconLibraryId","SanityIconSelection","library","style","icons","SanityIconOptions","Omit","options","SanityIconConfig","plugin","config","name","schema","types","iconPlugin"],"sources":["../../@repo/components/field.tsx","../../@repo/lib/icons.ts","../src/config/grid.ts","../src/components/picker/cell.tsx","../src/components/picker/library.tsx","../src/components/picker/problem.tsx","../src/components/picker/recent.tsx","../src/lib/library.ts","../src/components/picker/tooltip.tsx","../src/hooks/use-icon-library.ts","../src/hooks/use-icon-tooltip.ts","../src/lib/recent.ts","../src/hooks/use-recent-icons.ts","../src/lib/grid.ts","../src/components/picker/picker.tsx","../src/icons/square-dashed.tsx","../src/lib/options.ts","../src/types.ts","../src/components/input.tsx","../src/lib/preview.ts","../src/schemas/types/icon.ts","../src/plugin.ts"],"sourcesContent":["import { isDefined } from \"@repo/lib/utils\";\nimport { useState } from \"react\";\nimport type {\n ArrayOfObjectsFormNode,\n ArrayOfObjectsMember,\n BaseFormNode,\n DocumentFieldActionNode,\n ObjectFieldProps,\n ObjectFormNode,\n ObjectMember,\n} from \"sanity\";\nimport {\n ChangeIndicator,\n FieldActionsProvider,\n FieldActionsResolver,\n FormField,\n getPublishedId,\n useFormValue,\n} from \"sanity\";\n\n/**\n * Checks whether a form node has members, as objects and arrays of objects do.\n *\n * @param node - The form node to check.\n * @returns True if the node has members.\n */\nfunction hasMembers(node: BaseFormNode): node is ObjectFormNode | ArrayOfObjectsFormNode {\n return \"members\" in node;\n}\n\n/**\n * Collects the validation on a form node and everything inside it.\n *\n * @param node - The form node.\n * @returns Every validation result on the node or inside it.\n */\nfunction collectNodeValidation(node: BaseFormNode): BaseFormNode[\"validation\"] {\n return [...node.validation, ...(hasMembers(node) ? collectMemberValidation(node.members) : [])];\n}\n\n/**\n * Collects the validation anywhere inside a field's members. The form only passes a field the\n * validation at its own path, so a field that hides its members would otherwise show none of theirs.\n *\n * @param members - The members.\n * @returns Every validation result on the members or inside them.\n */\nfunction collectMemberValidation(members: (ObjectMember | ArrayOfObjectsMember)[]): BaseFormNode[\"validation\"] {\n return members.flatMap((member) => {\n if (member.kind === \"field\") return collectNodeValidation(member.field);\n if (member.kind === \"fieldSet\") return collectMemberValidation(member.fieldSet.members);\n if (member.kind === \"item\") return collectNodeValidation(member.item);\n\n return [];\n });\n}\n\nexport type FieldProps = ObjectFieldProps;\n\nexport function Field({\n actions,\n schemaType,\n title,\n description,\n presence,\n validation,\n level,\n inputId,\n path,\n changed,\n children,\n inputProps,\n}: FieldProps) {\n const [headerActions, setHeaderActions] = useState<DocumentFieldActionNode[]>([]);\n\n const documentId = useFormValue([\"_id\"]);\n const publishedId = typeof documentId === \"string\" ? getPublishedId(documentId) : undefined;\n const focused = inputProps.focused === true;\n const fieldValidation = [...validation, ...collectMemberValidation(inputProps.members)];\n\n return (\n <>\n {isDefined(publishedId) && isDefined(actions) && (\n <FieldActionsResolver\n actions={actions}\n documentId={publishedId}\n documentType={schemaType.name}\n onActions={setHeaderActions}\n path={path}\n schemaType={schemaType}\n />\n )}\n <FieldActionsProvider actions={headerActions} focused={focused} path={path}>\n <FormField\n __unstable_headerActions={headerActions}\n __unstable_presence={presence}\n description={description}\n inputId={inputId}\n level={level}\n title={title}\n validation={fieldValidation}\n deprecated={schemaType.deprecated}\n path={path}\n readOnly={inputProps.readOnly}\n >\n <ChangeIndicator path={path} hasFocus={focused} isChanged={changed}>\n {children}\n </ChangeIndicator>\n </FormField>\n </FieldActionsProvider>\n </>\n );\n}\n","import type { ComponentProps, ComponentType } from \"react\";\nimport { createElement } from \"react\";\n\n/** Default props for the plugin's own icons. Icons from `@sanity/icons` already match the Studio. */\nexport const defaultIconProps: ComponentProps<\"svg\"> = { width: \"1em\", height: \"1em\", strokeWidth: 1.5 };\n\n/**\n * Wraps an SVG icon component for use in the Studio.\n *\n * @param icon - The icon to wrap.\n * @param props - Props that override the Studio icon defaults.\n * @returns An icon component.\n */\nexport function createSanityIcon(icon: ComponentType<ComponentProps<\"svg\">>, props?: ComponentProps<\"svg\">) {\n const Icon = icon;\n\n function SanityIcon() {\n return createElement(Icon, { ...defaultIconProps, ...props });\n }\n\n return SanityIcon;\n}\n","/** Cell size in pixels, fixed so the grid never reflows. */\nexport const gridCellSize = 40;\n\n/** Gap between rows in pixels. */\nconst gridRowGap = 4;\n\n/** Distance from one row to the next, used to position the rendered rows. */\nexport const gridRowHeight = gridCellSize + gridRowGap;\n\n/** Icons per row. */\nexport const gridColumns = 8;\n\n/** Rows visible at once. */\nexport const gridVisibleRows = 8;\n\n/** Height of the scrolling area. The last row has no gap after it. */\nexport const gridHeight = gridVisibleRows * gridRowHeight - gridRowGap;\n\n/** Extra rows rendered above and below the visible ones, so rows are already drawn as they scroll into view. */\nexport const gridOverscan = gridVisibleRows;\n\n/** Layout shared by both grids, so recent icons line up with the library's columns. */\nexport const gridLayoutStyle = { justifyItems: \"center\", rowGap: gridRowGap } as const;\n","import { Button } from \"@sanity/ui\";\nimport type { ComponentProps } from \"react\";\n\nimport { Drawing } from \"@/components/drawing\";\nimport { gridCellSize } from \"@/config/grid\";\nimport type { LibraryIcon } from \"@/lib/library\";\n\nexport type CellProps = Omit<\n ComponentProps<typeof Button>,\n \"icon\" | \"selected\" | \"onSelect\" | \"onClick\" | \"onMouseEnter\"\n> & {\n icon: LibraryIcon;\n selected: boolean;\n focusable: boolean;\n position: number;\n total: number;\n onSelect: (icon: LibraryIcon) => void;\n onHover: (icon: LibraryIcon, element: HTMLElement) => void;\n};\n\nexport function Cell({ icon, selected, focusable, position, total, onSelect, onHover, ...props }: CellProps) {\n return (\n <Button\n type=\"button\"\n role=\"option\"\n aria-selected={selected}\n aria-posinset={position}\n aria-setsize={total}\n tabIndex={focusable ? 0 : -1}\n mode=\"bleed\"\n selected={selected}\n padding={0}\n style={{ width: gridCellSize, height: gridCellSize }}\n icon={<Drawing drawing={icon.drawing} width=\"1.25em\" height=\"1.25em\" />}\n aria-label={icon.label}\n onClick={() => {\n onSelect(icon);\n }}\n onMouseEnter={(event) => {\n onHover(icon, event.currentTarget);\n }}\n {...props}\n />\n );\n}\n","import { isDefined } from \"@repo/lib/utils\";\nimport { Box, Button, Flex, Grid, Text } from \"@sanity/ui\";\nimport type { ComponentProps, RefObject } from \"react\";\n\nimport type { CellProps } from \"@/components/picker/cell\";\nimport { Cell } from \"@/components/picker/cell\";\nimport { gridColumns, gridHeight, gridLayoutStyle, gridRowHeight } from \"@/config/grid\";\nimport type { getVisibleRows } from \"@/lib/grid\";\nimport type { LibraryIcon } from \"@/lib/library\";\n\nexport type LibraryProps = Omit<ComponentProps<typeof Box>, \"children\" | \"onSelect\"> & {\n icons: LibraryIcon[];\n rows: ReturnType<typeof getVisibleRows>;\n selected: string | undefined;\n activeIndex: number;\n activeCell: RefObject<HTMLButtonElement | null>;\n search: string;\n onSelect: (icon: LibraryIcon) => void;\n onHover: CellProps[\"onHover\"];\n onClearSearch: () => void;\n};\n\nexport function Library({\n icons,\n rows,\n selected,\n activeIndex,\n activeCell,\n search,\n onSelect,\n onHover,\n onClearSearch,\n ...props\n}: LibraryProps) {\n const { totalRows, firstRow, lastRow } = rows;\n const visible = icons.slice(firstRow * gridColumns, lastRow * gridColumns);\n\n return (\n <Box\n role=\"listbox\"\n aria-label=\"Icon library\"\n style={isDefined(icons) ? { height: gridHeight, overflowY: \"auto\" } : undefined}\n {...props}\n >\n {!isDefined(icons) && (\n <Flex align=\"center\" justify=\"center\" direction=\"column\" gap={3} paddingTop={5} paddingBottom={6}>\n <Text size={1} muted>{`Nothing matches \"${search}\".`}</Text>\n <Button type=\"button\" mode=\"ghost\" text=\"Clear search\" onClick={onClearSearch} />\n </Flex>\n )}\n {isDefined(icons) && (\n <Grid\n gridTemplateColumns={gridColumns}\n style={{\n ...gridLayoutStyle,\n paddingTop: firstRow * gridRowHeight,\n paddingBottom: (totalRows - lastRow) * gridRowHeight,\n }}\n >\n {visible.map((icon, offset) => {\n const index = firstRow * gridColumns + offset;\n\n return (\n <Cell\n key={icon.name}\n ref={index === activeIndex ? activeCell : undefined}\n icon={icon}\n selected={icon.name === selected}\n focusable={index === activeIndex}\n position={index + 1}\n total={icons.length}\n onSelect={onSelect}\n onHover={onHover}\n />\n );\n })}\n </Grid>\n )}\n </Box>\n );\n}\n","import { WarningOutlineIcon } from \"@sanity/icons/WarningOutline\";\nimport { Card, Flex, Stack, Text } from \"@sanity/ui\";\nimport type { ComponentProps } from \"react\";\n\nimport type { LibraryProblem } from \"@/lib/library\";\n\nexport type CodeTextProps = Omit<ComponentProps<\"span\">, \"children\"> & {\n text: string;\n};\n\nexport function CodeText({ text, ...props }: CodeTextProps) {\n const parts = text.split(\"`\");\n\n return (\n <span {...props}>\n {parts.map((part, index) => {\n const start = parts.slice(0, index).join(\"`\").length;\n\n return index % 2 === 1 ? <code key={start}>{part}</code> : part;\n })}\n </span>\n );\n}\n\nexport type ProblemProps = Omit<ComponentProps<typeof Card>, \"children\"> & {\n problem: LibraryProblem;\n};\n\nexport function Problem({ problem, ...props }: ProblemProps) {\n return (\n <Card tone=\"caution\" padding={4} radius={2} border {...props}>\n <Flex gap={3}>\n <Text size={1}>\n <WarningOutlineIcon />\n </Text>\n <Stack gap={3}>\n <Text size={1} weight=\"medium\">\n <CodeText text={problem.title} />\n </Text>\n <Text size={1} muted>\n <CodeText text={problem.description} />\n </Text>\n </Stack>\n </Flex>\n </Card>\n );\n}\n","import { Button, Flex, Grid, Stack, Text } from \"@sanity/ui\";\nimport type { ComponentProps } from \"react\";\n\nimport type { CellProps } from \"@/components/picker/cell\";\nimport { Cell } from \"@/components/picker/cell\";\nimport { gridColumns, gridLayoutStyle } from \"@/config/grid\";\nimport type { LibraryIcon } from \"@/lib/library\";\n\nexport type RecentProps = Omit<ComponentProps<typeof Stack>, \"children\" | \"onSelect\"> & {\n icons: LibraryIcon[];\n selected: string | undefined;\n onSelect: (icon: LibraryIcon) => void;\n onHover: CellProps[\"onHover\"];\n onForget: () => void;\n};\n\nexport function Recent({ icons, selected, onSelect, onHover, onForget, ...props }: RecentProps) {\n return (\n <Stack gap={3} {...props}>\n <Flex align=\"center\" justify=\"space-between\" gap={2}>\n <Text size={1} weight=\"medium\" muted>\n Recent icons\n </Text>\n <Button\n type=\"button\"\n mode=\"bleed\"\n fontSize={1}\n padding={2}\n text=\"Clear\"\n onClick={onForget}\n aria-label=\"Clear recent icons\"\n />\n </Flex>\n <Grid role=\"listbox\" aria-label=\"Recent icons\" gridTemplateColumns={gridColumns} style={gridLayoutStyle}>\n {icons.map((icon, index) => (\n <Cell\n key={icon.name}\n icon={icon}\n selected={icon.name === selected}\n focusable\n position={index + 1}\n total={icons.length}\n onSelect={onSelect}\n onHover={onHover}\n />\n ))}\n </Grid>\n </Stack>\n );\n}\n","import { iconRegistry } from \"@driftime/sanity-plugin-icon/sets\";\nimport { convertCase, isDefined } from \"@repo/lib/utils\";\n\nimport type { IconDrawing } from \"@/lib/nodes\";\nimport { getIconSetKey } from \"@/lib/registry\";\nimport { parseIconSet } from \"@/lib/sets\";\n\n/** Icon in the library, with the terms a search matches against. */\nexport interface LibraryIcon {\n /** Name of the icon in its library. */\n name: string;\n /** Readable form of the name. */\n label: string;\n /** Keywords describing the icon, as a comma-separated list. */\n tags: string;\n /** The icon's shapes and the SVG attributes they're drawn inside. */\n drawing: IconDrawing;\n /** Name and keywords, normalised for search. */\n terms: string;\n}\n\n/** Why a library's icons can't be shown, and what to do about it, with code marked by backticks. */\nexport interface LibraryProblem {\n /** What's wrong, in a few words. */\n title: string;\n /** What to do about it. */\n description: string;\n}\n\n/** Outcome of loading a library: its icons, or why they can't be shown. */\nexport type LibraryResult =\n | { icons: LibraryIcon[]; problem?: undefined }\n | { icons?: undefined; problem: LibraryProblem };\n\n/**\n * Normalises text for search, so hyphenated names and multi-word keywords match the same way.\n *\n * @param value - The text.\n * @returns The normalised text.\n */\nexport function normalizeTerms(value: string) {\n return value\n .toLowerCase()\n .replaceAll(/[\\s-]+/gu, \" \")\n .trim();\n}\n\n/**\n * Splits text into the parts a search matches and the parts it doesn't, matching the way search does: ignoring case,\n * and treating spaces and hyphens alike.\n *\n * @param text - The text to split.\n * @param query - The normalised search.\n * @returns The parts in order, each with where it starts in the text and whether it matches.\n */\nexport function splitMatches(text: string, query: string) {\n if (!isDefined(query)) return [{ text, start: 0, match: false }];\n\n const pattern = query\n .split(\" \")\n .map((word) => word.replaceAll(/[$()*+.?[\\\\\\]^{|}]/gu, String.raw`\\$&`))\n .join(String.raw`[\\s-]+`);\n\n const parts = text.split(new RegExp(`(${pattern})`, \"giu\"));\n\n return parts.map((part, index) => ({\n text: part,\n start: parts.slice(0, index).join(\"\").length,\n match: index % 2 === 1,\n }));\n}\n\n/**\n * Narrows the library to the named icons, in the order given. Unknown names are skipped, so a list keeps working\n * across library releases.\n *\n * @param library - Every icon in the library.\n * @param names - The icons to offer, or undefined for all of them.\n * @returns The icons to offer.\n */\nexport function selectIcons(library: LibraryIcon[], names: string[] | undefined) {\n if (!isDefined(names)) return library;\n\n const byName = new Map(library.map((icon) => [icon.name, icon]));\n\n return [...new Set(names)].flatMap((name) => {\n const icon = byName.get(name);\n\n return isDefined(icon) ? [icon] : [];\n });\n}\n\n/**\n * Lists identifiers as inline code, separated by commas.\n *\n * @param identifiers - The identifiers.\n * @returns The list.\n */\nfunction formatList(identifiers: string[]) {\n return identifiers.map((identifier) => `\\`${identifier}\\``).join(\", \");\n}\n\n/**\n * Describes why a library the project hasn't installed can't be shown, and what to add.\n *\n * @param label - Readable name of the library.\n * @param packageName - Package the library is read from, or an example of one for a family of packages.\n * @param family - Whether the library is a family of packages, one per style.\n * @param listed - Whether the project's `package.json` lists the package.\n * @param sitePackage - Another package of the library the project lists, or undefined when there's none.\n * @returns The problem.\n */\nfunction describeMissingLibrary(\n label: string,\n packageName: string,\n family: boolean,\n listed: boolean,\n sitePackage: string | undefined,\n): LibraryProblem {\n if (listed) {\n return {\n title: `${label} isn't installed yet`,\n description: `\\`${packageName}\\` is in \\`package.json\\` but not in \\`node_modules\\`. Reinstall the project's dependencies.`,\n };\n }\n\n if (isDefined(sitePackage)) {\n return {\n title: `${label} needs \\`${packageName}\\``,\n description: `The Studio reads ${label} from \\`${packageName}\\`, not \\`${sitePackage}\\`. Add it as a dev dependency.`,\n };\n }\n\n return {\n title: `${label} isn't installed`,\n description: family\n ? `Install a ${label} style package, such as \\`${packageName}\\`.`\n : `Install \\`${packageName}\\` in the project.`,\n };\n}\n\n/**\n * Loads one library style from the sets the build step converted.\n *\n * @param library - Identifier of the library, or undefined when none is set.\n * @param style - Identifier of the style, or undefined for the library's default.\n * @returns The icons, or why they can't be shown.\n */\nasync function readLibrary(library: string | undefined, style: string | undefined): Promise<LibraryResult> {\n if (!isDefined(library)) {\n return {\n problem: {\n title: \"No icon library set\",\n description: \"Set `library` in the icon plugin's configuration or in the field's options.\",\n },\n };\n }\n\n if (!iconRegistry.ready) {\n return {\n problem: {\n title: \"Icons aren't set up\",\n description: \"Add `withIcons()` to the Studio's build configuration, then restart the Studio.\",\n },\n };\n }\n\n const info = iconRegistry.libraries[library];\n if (!isDefined(info)) {\n return {\n problem: {\n title: \"Unknown icon library\",\n description: `There's no icon library called \\`${library}\\`. Use one of: ${formatList(Object.keys(iconRegistry.libraries))}.`,\n },\n };\n }\n\n const { label, packageName, packagePrefix, styles, listed, installed, sitePackage } = info;\n if (!installed) {\n return { problem: describeMissingLibrary(label, packageName, isDefined(packagePrefix), listed, sitePackage) };\n }\n\n const resolvedStyle = style ?? styles[0] ?? \"\";\n const loader = iconRegistry.sets[getIconSetKey(library, resolvedStyle)];\n if (!isDefined(loader)) {\n return {\n problem: isDefined(packagePrefix)\n ? {\n title: `${label} style \\`${resolvedStyle}\\` isn't installed`,\n description: `Install \\`${packagePrefix}${resolvedStyle}\\` in the project.`,\n }\n : {\n title: `Unknown ${label} style`,\n description: `${label} has no \\`${resolvedStyle}\\` style. Use one of: ${formatList(styles)}.`,\n },\n };\n }\n\n const module = await loader();\n const set = parseIconSet(module.default);\n if (!isDefined(set)) {\n return { problem: { title: `Couldn't load ${label}`, description: \"Restart the Studio and try again.\" } };\n }\n\n return {\n icons: set.icons.map(({ name, keywords, node, root }) => ({\n name,\n label: convertCase(name, \"title\"),\n tags: keywords.join(\", \"),\n drawing: { root: root ?? set.root, node },\n terms: normalizeTerms([name, ...keywords].join(\" \")),\n })),\n };\n}\n\n/** Library requests shared by every field in the session, keyed by library and style, since the data never changes. */\nconst libraryRequests = new Map<string, Promise<LibraryResult>>();\n\n/**\n * Loads a library style, reusing a request already in progress.\n *\n * @param library - Identifier of the library, or undefined when none is set.\n * @param style - Identifier of the style, or undefined for the library's default.\n * @returns The icons, or why they can't be shown.\n */\nexport async function requestLibrary(library: string | undefined, style: string | undefined) {\n const key = getIconSetKey(library ?? \"\", style ?? \"\");\n let request = libraryRequests.get(key);\n\n if (!isDefined(request)) {\n request = readLibrary(library, style);\n libraryRequests.set(key, request);\n }\n\n const result = await request;\n\n return result;\n}\n","import { isDefined } from \"@repo/lib/utils\";\nimport { Stack, Text } from \"@sanity/ui\";\nimport { Popover } from \"@sanity/ui/popover\";\nimport type { CSSProperties, ComponentProps } from \"react\";\n\nimport type { LibraryIcon } from \"@/lib/library\";\nimport { splitMatches } from \"@/lib/library\";\n\n/** Icon under the cursor and the cell showing it. */\nexport interface HoveredIcon {\n /** Icon in the cell. */\n icon: LibraryIcon;\n /** Cell the tooltip points at. */\n element: HTMLElement;\n}\n\n/**\n * Gap between the tooltip and its cell, set through margins because `@sanity/ui` offers no other way.\n * Only the top is set, since the tooltip always appears above the cell.\n */\nconst tooltipMargins: [number, number, number, number] = [-4, 0, 0, 0];\n\n/** Underlines a search match in place of the browser's highlighter-pen look, keeping the text's own colour. */\nconst matchStyle: CSSProperties = {\n background: \"none\",\n color: \"inherit\",\n textDecorationLine: \"underline\",\n textUnderlineOffset: \"0.2em\",\n};\n\nexport type HighlightProps = Omit<ComponentProps<\"span\">, \"children\"> & {\n text: string;\n query: string;\n};\n\nexport function Highlight({ text, query, ...props }: HighlightProps) {\n return (\n <span {...props}>\n {splitMatches(text, query).map((part) =>\n part.match ? (\n <mark key={part.start} style={matchStyle}>\n {part.text}\n </mark>\n ) : (\n part.text\n ),\n )}\n </span>\n );\n}\n\nexport type TooltipProps = Omit<ComponentProps<typeof Popover>, \"open\" | \"referenceElement\" | \"content\"> & {\n hovered: HoveredIcon | undefined;\n query: string;\n};\n\nexport function Tooltip({ hovered, query, ...props }: TooltipProps) {\n return (\n <Popover\n open={isDefined(hovered)}\n referenceElement={hovered?.element ?? null}\n placement=\"top\"\n portal\n padding={3}\n __unstable_margins={tooltipMargins}\n style={{ pointerEvents: \"none\" }}\n content={\n isDefined(hovered) && (\n <Stack gap={3} style={{ maxWidth: \"16rem\" }}>\n <Text size={1} weight=\"medium\">\n <Highlight text={hovered.icon.label} query={query} />\n </Text>\n {isDefined(hovered.icon.tags) && (\n <Text size={1} muted>\n <Highlight text={hovered.icon.tags} query={query} />\n </Text>\n )}\n </Stack>\n )\n }\n {...props}\n />\n );\n}\n","import { useEffect, useState } from \"react\";\n\nimport type { LibraryResult } from \"@/lib/library\";\nimport { requestLibrary } from \"@/lib/library\";\n\n/**\n * Loads an icon library style. Only an open picker calls this, so a Studio that never opens one never loads it.\n *\n * @param library - Identifier of the library, or undefined when none is set.\n * @param style - Identifier of the style, or undefined for the library's default.\n * @returns The icons or why they can't be shown, or undefined while loading.\n */\nexport function useIconLibrary(library: string | undefined, style: string | undefined) {\n const [result, setResult] = useState<LibraryResult>();\n\n useEffect(() => {\n let active = true;\n\n async function load() {\n const loaded = await requestLibrary(library, style);\n if (active) setResult(loaded);\n }\n\n void load();\n\n return () => {\n active = false;\n };\n }, [library, style]);\n\n return result;\n}\n","import { isDefined } from \"@repo/lib/utils\";\nimport { useEffect, useRef, useState } from \"react\";\n\nimport type { HoveredIcon } from \"@/components/picker/tooltip\";\nimport type { LibraryIcon } from \"@/lib/library\";\n\n/**\n * Tracks the icon under the cursor, showing its tooltip after a short delay. Tooltips are held back while the grid\n * scrolls, and the icon left under the cursor gets its tooltip once scrolling stops.\n *\n * @param scrolling - Whether the grid is scrolling.\n * @returns The hovered icon, and functions to update and clear it.\n */\nexport function useIconTooltip(scrolling: boolean) {\n const [hovered, setHovered] = useState<HoveredIcon>();\n const hoverStart = useRef<ReturnType<typeof setTimeout>>(undefined);\n const scrolledOnto = useRef<HoveredIcon>(undefined);\n\n useEffect(\n () => () => {\n if (isDefined(hoverStart.current)) clearTimeout(hoverStart.current);\n },\n [],\n );\n\n useEffect(() => {\n const landed = scrolledOnto.current;\n if (scrolling || !isDefined(landed)) return;\n\n scrolledOnto.current = undefined;\n if (!landed.element.isConnected || !landed.element.matches(\":hover\")) return;\n\n hoverStart.current = setTimeout(() => {\n setHovered(landed);\n }, 200);\n }, [scrolling]);\n\n function clearHover() {\n if (isDefined(hoverStart.current)) clearTimeout(hoverStart.current);\n if (isDefined(hovered)) setHovered(undefined);\n }\n\n function handleHover(icon: LibraryIcon, element: HTMLElement) {\n if (scrolling) {\n scrolledOnto.current = { icon, element };\n\n return;\n }\n\n if (element === hovered?.element) return;\n\n if (isDefined(hoverStart.current)) clearTimeout(hoverStart.current);\n\n if (isDefined(hovered)) {\n setHovered({ icon, element });\n\n return;\n }\n\n hoverStart.current = setTimeout(() => {\n setHovered({ icon, element });\n }, 200);\n }\n\n return { hovered, handleHover, clearHover };\n}\n","/** Local storage key for recent icons, which are kept in the browser rather than the dataset. */\nconst storageKey = \"driftime:sanity-plugin-icon:recent\";\n\n/** Number of recent icons to keep. */\nconst limit = 8;\n\n/**\n * Builds the storage key for one library style.\n *\n * @param scope - The library and style, such as `phosphor/bold`.\n * @returns The storage key.\n */\nfunction getStorageKey(scope: string) {\n return `${storageKey}:${scope}`;\n}\n\n/**\n * Reads the recently chosen icons.\n *\n * @param scope - The library and style, such as `phosphor/bold`.\n * @returns The icon names, most recent first.\n */\nexport function readRecent(scope: string) {\n try {\n const stored: unknown = JSON.parse(globalThis.localStorage.getItem(getStorageKey(scope)) ?? \"[]\");\n if (!Array.isArray(stored)) return [];\n\n return stored.filter((entry: unknown) => typeof entry === \"string\");\n } catch {\n return [];\n }\n}\n\n/**\n * Adds an icon to the front of the recent list.\n *\n * @param scope - The library and style, such as `phosphor/bold`.\n * @param name - The chosen icon's name.\n * @returns The updated icon names, most recent first.\n */\nexport function writeRecent(scope: string, name: string) {\n const updated = [name, ...readRecent(scope).filter((entry) => entry !== name)].slice(0, limit);\n\n try {\n globalThis.localStorage.setItem(getStorageKey(scope), JSON.stringify(updated));\n } catch {\n // If storage is blocked, the icon just isn't remembered.\n }\n\n return updated;\n}\n\n/**\n * Clears the recent icons.\n *\n * @param scope - The library and style, such as `phosphor/bold`.\n */\nexport function clearRecent(scope: string) {\n try {\n globalThis.localStorage.removeItem(getStorageKey(scope));\n } catch {\n // If storage is blocked, there's nothing to clear.\n }\n}\n","import { useState } from \"react\";\n\nimport { clearRecent, readRecent, writeRecent } from \"@/lib/recent\";\n\n/**\n * Tracks the icons an author chose most recently from one library style. The list is read when the picker opens, so\n * choices made in another tab are included.\n *\n * @param scope - The library and style, such as `phosphor/bold`.\n * @returns The recent icon names, most recent first, and functions to add to and clear them.\n */\nexport function useRecentIcons(scope: string) {\n const [recent, setRecent] = useState<string[]>(() => readRecent(scope));\n\n function remember(name: string) {\n setRecent(writeRecent(scope, name));\n }\n\n function forget() {\n clearRecent(scope);\n setRecent([]);\n }\n\n return { recent, remember, forget };\n}\n","import { gridColumns, gridHeight, gridOverscan, gridRowHeight, gridVisibleRows } from \"@/config/grid\";\n\n/**\n * Works out which icon a key press moves to.\n *\n * @param key - The key pressed.\n * @param current - Index of the current icon.\n * @param last - Index of the last icon.\n * @returns The new index, or undefined when the key doesn't move.\n */\nexport function getNextIndex(key: string, current: number, last: number) {\n if (key === \"ArrowRight\") return current + 1;\n if (key === \"ArrowLeft\") return current - 1;\n if (key === \"ArrowDown\") return current + gridColumns;\n if (key === \"ArrowUp\") return current - gridColumns;\n if (key === \"Home\") return 0;\n if (key === \"End\") return last;\n\n return undefined;\n}\n\n/**\n * Works out which rows to render at a scroll position, so only icons near the viewport are mounted.\n * Padding replaces the other rows, so the scrollbar stays the right size.\n *\n * @param scrollRow - The row scrolled to.\n * @param count - Number of icons in the results.\n * @returns The first and last rows to render, and the total number of rows.\n */\nexport function getVisibleRows(scrollRow: number, count: number) {\n const totalRows = Math.ceil(count / gridColumns);\n const firstRow = Math.max(0, scrollRow - gridOverscan);\n const lastRow = Math.min(totalRows, firstRow + gridVisibleRows + gridOverscan * 2);\n\n return { totalRows, firstRow, lastRow };\n}\n\n/**\n * Works out the scroll position that centres an icon, for opening on the selected icon.\n *\n * @param index - Index of the icon.\n * @returns The scroll position.\n */\nexport function getCenteredScrollTop(index: number) {\n return Math.max(0, Math.floor(index / gridColumns) * gridRowHeight - gridHeight / 2);\n}\n\n/**\n * Works out the scroll position that brings an icon into view, keeping the current one if it's\n * already visible. It uses the index because Home and End can move to rows that aren't mounted.\n *\n * @param index - Index of the icon.\n * @param scrollTop - The current scroll position.\n * @returns The scroll position.\n */\nexport function getRevealedScrollTop(index: number, scrollTop: number) {\n const top = Math.floor(index / gridColumns) * gridRowHeight;\n\n if (top < scrollTop) return top;\n if (top + gridRowHeight > scrollTop + gridHeight) return top + gridRowHeight - gridHeight;\n\n return scrollTop;\n}\n","import { isDefined } from \"@repo/lib/utils\";\nimport { SearchIcon } from \"@sanity/icons/Search\";\nimport { Box, Dialog, Flex, Spinner, Stack, Text, TextInput } from \"@sanity/ui\";\nimport type { ChangeEvent, ComponentProps, KeyboardEvent } from \"react\";\nimport { useEffect, useRef, useState } from \"react\";\n\nimport { Library } from \"@/components/picker/library\";\nimport { Problem } from \"@/components/picker/problem\";\nimport { Recent } from \"@/components/picker/recent\";\nimport { Tooltip } from \"@/components/picker/tooltip\";\nimport { gridHeight, gridRowHeight } from \"@/config/grid\";\nimport { useIconLibrary } from \"@/hooks/use-icon-library\";\nimport { useIconTooltip } from \"@/hooks/use-icon-tooltip\";\nimport { useRecentIcons } from \"@/hooks/use-recent-icons\";\nimport { getCenteredScrollTop, getNextIndex, getRevealedScrollTop, getVisibleRows } from \"@/lib/grid\";\nimport type { LibraryIcon } from \"@/lib/library\";\nimport { normalizeTerms, selectIcons } from \"@/lib/library\";\nimport { getIconSetKey } from \"@/lib/registry\";\n\nexport type PickerProps = Omit<\n ComponentProps<typeof Dialog>,\n \"children\" | \"header\" | \"width\" | \"selected\" | \"onSelect\"\n> & {\n library: string | undefined;\n iconStyle: string | undefined;\n allowed: string[] | undefined;\n selected: string | undefined;\n onSelect: (icon: LibraryIcon) => void;\n};\n\nexport function Picker({ library: libraryName, iconStyle, allowed, selected, onSelect, ...props }: PickerProps) {\n const result = useIconLibrary(libraryName, iconStyle);\n const library = result?.icons;\n const icons = selectIcons(library ?? [], allowed);\n const { recent, remember, forget } = useRecentIcons(getIconSetKey(libraryName ?? \"\", iconStyle ?? \"default\"));\n\n const [search, setSearch] = useState(\"\");\n const [scrollRow, setScrollRow] = useState(0);\n const [movedIndex, setMovedIndex] = useState<number>();\n const [scrolling, setScrolling] = useState(false);\n\n const scroller = useRef<HTMLDivElement>(null);\n const activeCell = useRef<HTMLButtonElement>(null);\n const focusIndex = useRef<number>(undefined);\n const scrollFrame = useRef<number>(undefined);\n const scrollStop = useRef<ReturnType<typeof setTimeout>>(undefined);\n\n const query = normalizeTerms(search);\n const searching = isDefined(query);\n const results = icons.filter((icon) => !searching || icon.terms.includes(query));\n\n const byName = new Map(icons.map((icon) => [icon.name, icon]));\n const recentIcons = searching\n ? []\n : recent.flatMap((entry) => {\n const icon = byName.get(entry);\n\n return isDefined(icon) ? [icon] : [];\n });\n\n const { hovered, handleHover, clearHover } = useIconTooltip(scrolling);\n\n const rows = getVisibleRows(scrollRow, results.length);\n\n const selectedIndex = searching || !isDefined(selected) ? -1 : icons.findIndex((icon) => icon.name === selected);\n const activeIndex = movedIndex ?? Math.max(0, selectedIndex);\n\n useEffect(() => {\n const element = scroller.current;\n if (!isDefined(element) || selectedIndex === -1) return;\n\n element.scrollTop = getCenteredScrollTop(selectedIndex);\n }, [scroller, selectedIndex]);\n\n useEffect(\n () => () => {\n if (isDefined(scrollFrame.current)) cancelAnimationFrame(scrollFrame.current);\n if (isDefined(scrollStop.current)) clearTimeout(scrollStop.current);\n },\n [],\n );\n\n useEffect(() => {\n if (focusIndex.current !== activeIndex) return;\n\n focusIndex.current = undefined;\n if (isDefined(activeCell.current)) activeCell.current.focus();\n }, [activeIndex]);\n\n function handleSelect(icon: LibraryIcon) {\n remember(icon.name);\n onSelect(icon);\n }\n\n function clearSearch() {\n setSearch(\"\");\n setMovedIndex(undefined);\n }\n\n function handleSearch(event: ChangeEvent<HTMLInputElement>) {\n setSearch(event.currentTarget.value);\n setMovedIndex(undefined);\n\n if (isDefined(scroller.current)) scroller.current.scrollTop = 0;\n }\n\n function selectActive() {\n const icon = results[activeIndex];\n\n if (isDefined(icon)) handleSelect(icon);\n }\n\n function handleSearchKeyDown(event: KeyboardEvent<HTMLInputElement>) {\n if (event.key === \"Enter\") {\n event.preventDefault();\n selectActive();\n\n return;\n }\n\n if (event.key !== \"ArrowDown\") return;\n\n event.preventDefault();\n\n if (isDefined(activeCell.current)) activeCell.current.focus();\n }\n\n function handleScroll() {\n clearHover();\n if (!scrolling) setScrolling(true);\n\n if (isDefined(scrollStop.current)) clearTimeout(scrollStop.current);\n scrollStop.current = setTimeout(() => {\n setScrolling(false);\n }, 150);\n\n if (isDefined(scrollFrame.current)) return;\n\n scrollFrame.current = requestAnimationFrame(() => {\n scrollFrame.current = undefined;\n\n const element = scroller.current;\n if (isDefined(element)) setScrollRow(Math.floor(element.scrollTop / gridRowHeight));\n });\n }\n\n function handleGridKeyDown(event: KeyboardEvent<HTMLDivElement>) {\n const last = results.length - 1;\n if (last < 0) return;\n\n if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n selectActive();\n\n return;\n }\n\n const next = getNextIndex(event.key, activeIndex, last);\n if (!isDefined(next)) return;\n\n event.preventDefault();\n\n const index = Math.min(Math.max(next, 0), last);\n focusIndex.current = index;\n setMovedIndex(index);\n\n const element = scroller.current;\n if (!isDefined(element)) return;\n\n element.scrollTop = getRevealedScrollTop(index, element.scrollTop);\n }\n\n return (\n <Dialog header=\"Select icon\" width={1} {...props}>\n <Stack gap={4} padding={4}>\n {!isDefined(result?.problem) && (\n <TextInput\n type=\"search\"\n icon={<SearchIcon />}\n placeholder=\"Search by name or keyword\"\n value={search}\n onChange={handleSearch}\n onKeyDown={handleSearchKeyDown}\n disabled={!isDefined(library) || !isDefined(icons)}\n aria-label=\"Search the icon library\"\n />\n )}\n {!isDefined(result) && (\n <Flex align=\"center\" justify=\"center\" style={{ height: gridHeight }}>\n <Spinner muted />\n </Flex>\n )}\n {isDefined(result?.problem) && <Problem problem={result.problem} />}\n {isDefined(recentIcons) && (\n <Recent\n icons={recentIcons}\n selected={selected}\n onSelect={handleSelect}\n onHover={handleHover}\n onForget={forget}\n onMouseLeave={clearHover}\n />\n )}\n {isDefined(library) && (\n <Stack gap={3}>\n <Box paddingY={2}>\n <Text size={1} weight=\"medium\" muted>\n All icons ({results.length.toLocaleString(\"en-US\")})\n </Text>\n </Box>\n {!isDefined(icons) && (\n <Flex align=\"center\" justify=\"center\" paddingTop={5} paddingBottom={6}>\n <Text size={1} muted>\n No icons available.\n </Text>\n </Flex>\n )}\n {isDefined(icons) && (\n <Library\n ref={scroller}\n icons={results}\n rows={rows}\n selected={selected}\n activeIndex={activeIndex}\n activeCell={activeCell}\n search={search}\n onSelect={handleSelect}\n onHover={handleHover}\n onClearSearch={clearSearch}\n onScroll={handleScroll}\n onMouseLeave={clearHover}\n onKeyDown={handleGridKeyDown}\n />\n )}\n </Stack>\n )}\n <Tooltip key={hovered?.icon.name} hovered={hovered} query={query} />\n </Stack>\n </Dialog>\n );\n}\n","import type { ComponentProps } from \"react\";\n\nexport type SquareDashedIconProps = ComponentProps<\"svg\">;\n\nexport function SquareDashedIcon(props: SquareDashedIconProps) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width={24}\n height={24}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n {...props}\n >\n <path d=\"M5 3a2 2 0 0 0-2 2\" />\n <path d=\"M19 3a2 2 0 0 1 2 2\" />\n <path d=\"M21 19a2 2 0 0 1-2 2\" />\n <path d=\"M5 21a2 2 0 0 1-2-2\" />\n <path d=\"M9 3h1\" />\n <path d=\"M9 21h1\" />\n <path d=\"M14 3h1\" />\n <path d=\"M14 21h1\" />\n <path d=\"M3 9v1\" />\n <path d=\"M21 9v1\" />\n <path d=\"M3 14v1\" />\n <path d=\"M21 14v1\" />\n </svg>\n );\n}\n","import { isDefined } from \"@repo/lib/utils\";\n\nimport type { SanityIconConfig, SanityIconOptions, SanityIconSelection } from \"@/plugin\";\n\n/**\n * Resolves the library, style, and icons a field offers. A field that names a library replaces all three of the\n * plugin's, and one that doesn't uses the plugin's.\n *\n * @param options - The field's options.\n * @param config - The plugin configuration.\n * @returns The field's settings, whose library is undefined when neither the field nor the plugin names one.\n */\nexport function resolveIconOptions(options: SanityIconOptions | undefined, config: SanityIconConfig | undefined) {\n const { library, style, icons }: Partial<SanityIconSelection> =\n (isDefined(options?.library) ? options : config) ?? {};\n\n return { library, style, icons };\n}\n","/** Schema type name of the icon object. */\nexport const iconTypeName = \"icon\";\n\n/**\n * Stored icon: which library it came from, its name, and the shapes it's drawn from.\n *\n * @public\n */\nexport interface SanityIcon {\n _type: typeof iconTypeName;\n /** Identifier of the library the icon came from. */\n library?: string;\n /** Identifier of the library style the icon came from. */\n style?: string;\n /** Name of the icon in its library. */\n name?: string;\n /** Shapes the icon is drawn from, saved when it's chosen. */\n node?: string;\n}\n","import { defaultIconProps } from \"@repo/lib/icons\";\nimport { convertCase, isDefined } from \"@repo/lib/utils\";\nimport { CloseIcon } from \"@sanity/icons/Close\";\nimport { Button, Flex } from \"@sanity/ui\";\nimport { useState } from \"react\";\nimport type { ObjectInputProps, ObjectSchemaType } from \"sanity\";\nimport { set, setIfMissing, unset } from \"sanity\";\n\nimport { Drawing } from \"@/components/drawing\";\nimport { Picker } from \"@/components/picker/picker\";\nimport { SquareDashedIcon } from \"@/icons/square-dashed\";\nimport type { LibraryIcon } from \"@/lib/library\";\nimport { resolveIconDrawing, serializeIconDrawing } from \"@/lib/nodes\";\nimport { resolveIconOptions } from \"@/lib/options\";\nimport type { SanityIconConfig, SanityIconOptions } from \"@/plugin\";\nimport type { SanityIcon } from \"@/types\";\nimport { iconTypeName } from \"@/types\";\n\n/** Compiled icon field type, with the field's own options. */\ninterface IconSchemaType extends ObjectSchemaType {\n options?: SanityIconOptions;\n}\n\nexport type InputProps = ObjectInputProps<Partial<SanityIcon>, IconSchemaType>;\n\n/**\n * Creates the icon field input, bound to the plugin's configuration. A field's own icons replace the\n * plugin's rather than adding to them.\n *\n * @param config - The plugin configuration.\n * @returns The input component.\n */\nexport function createInput(config: SanityIconConfig) {\n function Input({ id, schemaType, value, onChange, readOnly }: InputProps) {\n const { library: storedLibrary, name, node } = value ?? {};\n\n const [open, setOpen] = useState(false);\n\n const { library, style, icons } = resolveIconOptions(schemaType.options, config);\n const selectedDrawing = resolveIconDrawing(node);\n const selectedName = storedLibrary === library ? name : undefined;\n const selectedLabel = isDefined(name) ? convertCase(name, \"title\") : undefined;\n\n function handleSelect(icon: LibraryIcon) {\n onChange([\n setIfMissing({ _type: iconTypeName satisfies SanityIcon[\"_type\"] }),\n isDefined(library)\n ? set(library, [\"library\" satisfies keyof SanityIcon])\n : unset([\"library\" satisfies keyof SanityIcon]),\n isDefined(style)\n ? set(style, [\"style\" satisfies keyof SanityIcon])\n : unset([\"style\" satisfies keyof SanityIcon]),\n set(icon.name, [\"name\" satisfies keyof SanityIcon]),\n set(serializeIconDrawing(icon.drawing), [\"node\" satisfies keyof SanityIcon]),\n ]);\n\n setOpen(false);\n }\n\n return (\n <Flex gap={2}>\n <Button\n id={id}\n type=\"button\"\n mode=\"ghost\"\n icon={\n isDefined(selectedDrawing) ? (\n <Drawing drawing={selectedDrawing} width=\"1em\" height=\"1em\" />\n ) : (\n <SquareDashedIcon {...defaultIconProps} />\n )\n }\n text={selectedLabel ?? \"Select icon\"}\n disabled={readOnly}\n onClick={() => {\n setOpen(true);\n }}\n aria-label={isDefined(selectedLabel) ? `${selectedLabel} currently selected` : \"Select icon\"}\n />\n {isDefined(value) && (\n <Button\n type=\"button\"\n mode=\"ghost\"\n tone=\"critical\"\n icon={<CloseIcon />}\n text=\"Clear\"\n disabled={readOnly}\n onClick={() => {\n onChange(unset());\n }}\n aria-label=\"Clear the selected icon\"\n />\n )}\n {open && (\n <Picker\n id={`${id}-library`}\n library={library}\n iconStyle={style}\n allowed={icons}\n selected={selectedName}\n onSelect={handleSelect}\n onClose={() => {\n setOpen(false);\n }}\n onClickOutside={() => {\n setOpen(false);\n }}\n />\n )}\n </Flex>\n );\n }\n\n return Input;\n}\n","import { isDefined } from \"@repo/lib/utils\";\nimport { createElement } from \"react\";\n\nimport { Drawing } from \"@/components/drawing\";\nimport { resolveIconDrawing } from \"@/lib/nodes\";\nimport type { SanityIcon } from \"@/types\";\n\n/**\n * Creates preview media for a stored icon, so each document shows its own icon instead of a placeholder.\n *\n * @param value - The stored icon.\n * @returns The media component, or undefined when nothing readable was stored.\n * @public\n */\nexport function createIconPreview(value: SanityIcon | undefined) {\n const drawing = resolveIconDrawing(value?.node);\n if (!isDefined(drawing)) return undefined;\n\n return function IconPreview() {\n return createElement(Drawing, { drawing, width: \"1em\", height: \"1em\" });\n };\n}\n","import { Field } from \"@repo/components/field\";\nimport { createSanityIcon } from \"@repo/lib/icons\";\nimport { convertCase, isDefined } from \"@repo/lib/utils\";\nimport { defineField, defineType } from \"sanity\";\n\nimport { createInput } from \"@/components/input\";\nimport { SquareDashedIcon } from \"@/icons/square-dashed\";\nimport { createIconPreview } from \"@/lib/preview\";\nimport type { SanityIconConfig } from \"@/plugin\";\nimport type { SanityIcon } from \"@/types\";\nimport { iconTypeName } from \"@/types\";\n\n/**\n * Creates the icon object type, offering the plugin's icons to fields that don't set their own.\n *\n * @param config - The plugin configuration.\n * @returns The icon type.\n */\nexport function createIconType(config: SanityIconConfig) {\n return defineType({\n name: iconTypeName satisfies SanityIcon[\"_type\"],\n type: \"object\",\n icon: createSanityIcon(SquareDashedIcon),\n description: \"Icon chosen from an icon library.\",\n // Uses a primitive field's flat frame on purpose, instead of Sanity's collapsible object fieldset.\n components: { field: Field, input: createInput(config) },\n validation: (rule) =>\n rule.custom((value: Partial<SanityIcon> | undefined) =>\n !isDefined(value?.name) || isDefined(value.node) ? true : \"Select the icon again to save its drawing.\",\n ),\n preview: {\n select: {\n name: \"name\",\n node: \"node\",\n },\n prepare(selection: { name?: string; node?: string }) {\n const { name, node } = selection;\n\n return {\n title: isDefined(name) ? convertCase(name, \"title\") : \"No icon\",\n media: createIconPreview({ _type: iconTypeName, name, node }),\n };\n },\n },\n fields: [\n defineField({\n name: \"library\" satisfies keyof SanityIcon,\n type: \"string\",\n description: \"Identifier of the library the icon came from.\",\n }),\n defineField({\n name: \"style\" satisfies keyof SanityIcon,\n type: \"string\",\n description: \"Identifier of the library style the icon came from.\",\n }),\n defineField({\n name: \"name\" satisfies keyof SanityIcon,\n type: \"string\",\n description: \"Name of the icon in its library.\",\n }),\n defineField({\n name: \"node\" satisfies keyof SanityIcon,\n type: \"text\",\n description: \"Shapes the icon is drawn from, saved when it's chosen.\",\n }),\n ],\n });\n}\n","import type { SanityIconNames } from \"@driftime/sanity-plugin-icon/names\";\nimport type { BaseSchemaTypeOptions, TypeAliasDefinition } from \"sanity\";\nimport { definePlugin } from \"sanity\";\n\nimport { pluginName } from \"@/config/defaults\";\nimport type { iconLibraryStyles } from \"@/lib/libraries\";\nimport { createIconType } from \"@/schemas/types/icon\";\nimport type { iconTypeName } from \"@/types\";\n\ndeclare module \"@sanity/types\" {\n interface IntrinsicDefinitions {\n /** Definition of a field of type `icon`. */\n icon: SanityIconDefinition;\n }\n}\n\n/** Styles of each supported library, from the plugin's own list. */\ntype IconLibraryStyles = typeof iconLibraryStyles;\n\n/**\n * Identifier of a library the plugin supports.\n *\n * @public\n */\nexport type SanityIconLibrary = keyof IconLibraryStyles;\n\n/**\n * Styles a library offers. The project's own icon folders have one style, `default`.\n *\n * @public\n */\nexport type SanityIconStyle<Library extends string> = Library extends SanityIconLibrary\n ? IconLibraryStyles[Library][number]\n : \"default\";\n\n/**\n * Names of a library's icons, once the build step has listed the installed version's, or any name before then.\n *\n * @public\n */\nexport type SanityIconName<Library extends string> = Library extends keyof SanityIconNames\n ? SanityIconNames[Library]\n : string;\n\n/** Libraries the build step has listed, or any identifier before it has, so the project's own folders can be named. */\ntype ListedLibraryId = [keyof SanityIconNames] extends [never]\n ? string & NonNullable<unknown>\n : Extract<keyof SanityIconNames, string>;\n\n/** Libraries a field can name: the supported ones, plus the project's own folders. */\ntype IconLibraryId = SanityIconLibrary | ListedLibraryId;\n\n/**\n * A choice of library, style, and icons, where the style and icons are checked against the library.\n *\n * @public\n */\nexport type SanityIconSelection = {\n [Library in IconLibraryId]: {\n /** Identifier of the icon library, such as `phosphor`. */\n library: Library;\n /** Identifier of the library style, such as `bold`. Defaults to the library's first style. */\n style?: SanityIconStyle<Library>;\n /** Icons authors can choose from, in the order listed. Defaults to every icon. */\n icons?: SanityIconName<Library>[];\n };\n}[IconLibraryId];\n\n/**\n * Options for an icon field. A field that names a library replaces the plugin's library, style, and icons, and one\n * that doesn't uses the plugin's.\n *\n * @public\n */\nexport type SanityIconOptions = BaseSchemaTypeOptions &\n (SanityIconSelection | { library?: undefined; style?: undefined; icons?: undefined });\n\n/**\n * Definition of a field or array member holding an icon, so its options are type-checked like a\n * built-in type's.\n *\n * @public\n */\nexport interface SanityIconDefinition extends Omit<TypeAliasDefinition<typeof iconTypeName, undefined>, \"options\"> {\n /** Options for the field. */\n options?: SanityIconOptions;\n}\n\n/**\n * Plugin configuration, naming the library every icon field uses unless it names its own.\n *\n * @public\n */\nexport type SanityIconConfig = SanityIconSelection;\n\nconst plugin = definePlugin<SanityIconConfig>((config) => ({\n name: pluginName,\n schema: {\n types: [createIconType(config)],\n },\n}));\n\n/**\n * Adds an icon field type to Sanity Studio, with a searchable picker for the installed icon libraries that\n * stores the chosen icon's drawing.\n *\n * @param config - The plugin configuration.\n * @returns The plugin.\n * @public\n */\nexport function iconPlugin(config: SanityIconConfig) {\n return plugin(config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0BA,SAASe,WAAWC,MAAqE;CACvF,OAAO,aAAaA;AACtB;;;;;;;AAQA,SAASC,sBAAsBD,MAAgD;CAC7E,OAAO,CAAC,GAAGA,KAAKE,YAAY,GAAIH,WAAWC,IAAI,IAAIG,wBAAwBH,KAAKI,OAAO,IAAI,CAAA,CAAG;AAChG;;;;;;;;AASA,SAASD,wBAAwBC,SAA8E;CAC7G,OAAOA,QAAQC,SAASC,WAClBA,OAAOC,SAAS,UAAgBN,sBAAsBK,OAAOE,KAAK,IAClEF,OAAOC,SAAS,aAAmBJ,wBAAwBG,OAAOG,SAASL,OAAO,IAClFE,OAAOC,SAAS,SAAeN,sBAAsBK,OAAOI,IAAI,IAE7D,CAAA,CACR;AACH;AAIA,SAAOE,MAAAC,IAAA;CAAA,IAAAC,IAAAC,EAAA,EAAA,GAAe,EAAAC,SAAAC,YAAAC,OAAAC,aAAAC,UAAAlB,YAAAmB,OAAAC,SAAAC,MAAAC,SAAAC,UAAAC,eAAAb,IAaTc;CAAA,AAAAb,EAAA,O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;EACAQ,QAAQ;GACN9B,YAAY;IACVU,MAAM;IACNC,MAAM;IACNE,aAAa;GACf,CAAC;GACDb,YAAY;IACVU,MAAM;IACNC,MAAM;IACNE,aAAa;GACf,CAAC;GACDb,YAAY;IACVU,MAAM;IACNC,MAAM;IACNE,aAAa;GACf,CAAC;GACDb,YAAY;IACVU,MAAM;IACNC,MAAM;IACNE,aAAa;GACf,CAAC;EAAC;CAEN,CAAC;AACH;AC4BA,MAAM8C,SAASzB,cAAgC0B,YAAY;CACzDC,MAAM1B;CACN2B,QAAQ,EACNC,OAAO,CAAC1B,eAAeuB,MAAM,CAAC,EAChC;AACF,EAAE;;;;;;;;;AAUF,SAAgBI,WAAWJ,QAA0B;CACnD,OAAOD,OAAOC,MAAM;AACtB"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["isDefined","useState","ArrayOfObjectsFormNode","ArrayOfObjectsMember","BaseFormNode","DocumentFieldActionNode","ObjectFieldProps","ObjectFormNode","ObjectMember","ChangeIndicator","FieldActionsProvider","FieldActionsResolver","FormField","getPublishedId","useFormValue","hasMembers","node","collectNodeValidation","validation","collectMemberValidation","members","flatMap","member","kind","field","fieldSet","item","FieldProps","Field","t0","$","_c","actions","schemaType","title","description","presence","level","inputId","path","changed","children","inputProps","t1","Symbol","for","headerActions","setHeaderActions","t2","documentId","fieldValidation","focused","t3","publishedId","undefined","t4","name","t5","readOnly","deprecated","t6","t7","_c","ComponentProps","ComponentType","createElement","defaultIconProps","width","height","strokeWidth","createSanityIcon","icon","props","Icon","SanityIcon","gridCellSize","gridRowGap","gridRowHeight","gridColumns","gridVisibleRows","gridHeight","gridOverscan","gridLayoutStyle","justifyItems","rowGap","const","Button","ComponentProps","Drawing","gridCellSize","LibraryIcon","CellProps","Omit","icon","selected","focusable","position","total","onSelect","onHover","element","HTMLElement","Cell","t0","$","_c","props","t1","t2","Symbol","for","width","height","t3","drawing","t4","t5","event","currentTarget","t6","label","_c","isDefined","Box","Button","Flex","Grid","Text","ComponentProps","RefObject","CellProps","Cell","gridColumns","gridHeight","gridLayoutStyle","gridRowHeight","getVisibleRows","LibraryIcon","LibraryProps","Omit","icons","rows","ReturnType","selected","activeIndex","activeCell","HTMLButtonElement","search","onSelect","icon","onHover","onClearSearch","Library","t0","$","_c","props","totalRows","firstRow","lastRow","T0","t1","t2","t3","t4","t5","t6","visible","slice","height","overflowY","undefined","paddingTop","paddingBottom","map","offset","index","name","length","t7","_c","WarningOutlineIcon","Card","Flex","Stack","Text","ComponentProps","LibraryProblem","CodeTextProps","Omit","text","CodeText","t0","$","_c","props","t1","t2","parts","split","map","part","index","start","slice","join","length","t3","ProblemProps","problem","Problem","Symbol","for","title","description","t4","t5","_c","Button","Flex","Grid","Stack","Text","ComponentProps","CellProps","Cell","gridColumns","gridLayoutStyle","LibraryIcon","RecentProps","Omit","icons","selected","onSelect","icon","onHover","onForget","Recent","t0","$","_c","props","t1","Symbol","for","t2","t3","t4","length","index","name","map","t5","_c","iconRegistry","convertCase","isDefined","IconDrawing","getIconSetKey","parseIconSet","LibraryIcon","name","label","tags","drawing","terms","LibraryProblem","title","description","LibraryResult","icons","problem","normalizeTerms","value","toLowerCase","replaceAll","trim","splitMatches","text","query","start","match","pattern","split","map","word","String","raw","join","parts","RegExp","part","index","slice","length","selectIcons","library","names","byName","Map","icon","Set","flatMap","get","formatList","identifiers","identifier","describeMissingLibrary","packageName","family","listed","sitePackage","readLibrary","style","Promise","ready","info","libraries","Object","keys","packagePrefix","styles","installed","resolvedStyle","loader","sets","module","set","default","keywords","node","root","libraryRequests","requestLibrary","key","request","result","isDefined","Stack","Text","Popover","CSSProperties","ComponentProps","LibraryIcon","splitMatches","HoveredIcon","icon","element","HTMLElement","tooltipMargins","matchStyle","background","color","textDecorationLine","textUnderlineOffset","HighlightProps","Omit","text","query","Highlight","t0","$","_c","props","t1","map","_temp","t2","part","match","start","TooltipProps","hovered","Tooltip","t3","Symbol","for","pointerEvents","t4","maxWidth","label","tags","t5","_c","_temp","useEffect","useState","LibraryResult","requestLibrary","useIconLibrary","library","style","$","_c","result","setResult","t0","t1","active","load","loaded","_c","isDefined","useEffect","useRef","useState","HoveredIcon","LibraryIcon","useIconTooltip","scrolling","$","_c","hovered","setHovered","hoverStart","undefined","scrolledOnto","t0","t1","Symbol","for","current","clearTimeout","t2","t3","landed","element","isConnected","matches","setTimeout","t4","clearHover","t5","handleHover","icon","t6","_c","storageKey","limit","getStorageKey","scope","readRecent","stored","JSON","parse","globalThis","localStorage","getItem","Array","isArray","filter","entry","writeRecent","name","updated","slice","setItem","stringify","clearRecent","removeItem","useState","clearRecent","readRecent","writeRecent","useRecentIcons","scope","$","_c","t0","recent","setRecent","t1","remember","name","t2","forget","t3","_c","gridColumns","gridHeight","gridOverscan","gridRowHeight","gridVisibleRows","getNextIndex","key","current","last","undefined","getVisibleRows","scrollRow","count","totalRows","Math","ceil","firstRow","max","lastRow","min","getCenteredScrollTop","index","floor","getRevealedScrollTop","scrollTop","top","isDefined","SearchIcon","Box","Dialog","Flex","Spinner","Stack","Text","TextInput","ChangeEvent","ComponentProps","KeyboardEvent","useEffect","useRef","useState","Library","Problem","Recent","Tooltip","gridHeight","gridRowHeight","useIconLibrary","useIconTooltip","useRecentIcons","getCenteredScrollTop","getNextIndex","getRevealedScrollTop","getVisibleRows","LibraryIcon","normalizeTerms","selectIcons","getIconSetKey","PickerProps","Omit","library","iconStyle","allowed","selected","onSelect","icon","Picker","t0","$","_c","libraryName","props","result","icons","t1","t2","t3","recent","remember","forget","search","setSearch","scrollRow","setScrollRow","movedIndex","setMovedIndex","scrolling","setScrolling","scroller","activeCell","focusIndex","undefined","scrollFrame","scrollStop","query","searching","results","filter","terms","includes","byName","Map","map","_temp","recentIcons","flatMap","entry","icon_1","get","hovered","handleHover","clearHover","rows","length","selectedIndex","findIndex","icon_2","name","activeIndex","Math","max","element","current","scrollTop","t4","t5","Symbol","for","cancelAnimationFrame","clearTimeout","t6","t7","focus","t8","handleSelect","icon_3","t9","clearSearch","handleSearch","event","currentTarget","value","selectActive","icon_4","handleSearchKeyDown","event_0","key","preventDefault","handleScroll","setTimeout","requestAnimationFrame","element_0","floor","handleGridKeyDown","event_1","last","next","index","min","element_1","T0","t10","t11","T1","t12","t13","t14","problem","t15","height","t16","t17","t18","toLocaleString","t19","t20","t21","t22","icon_0","_c","ComponentProps","SquareDashedIconProps","SquareDashedIcon","props","$","_c","t0","t1","t10","t11","t2","t3","t4","t5","t6","t7","t8","t9","Symbol","for","t12","_c","isDefined","SanityIconConfig","SanityIconOptions","SanityIconSelection","resolveIconOptions","options","config","library","style","icons","Partial","iconTypeName","SanityIcon","_type","library","style","name","node","defaultIconProps","convertCase","isDefined","CloseIcon","Button","Flex","useEffect","useState","ObjectInputProps","ObjectSchemaType","set","setIfMissing","unset","Drawing","Picker","logger","SquareDashedIcon","LibraryIcon","requestLibrary","selectIcons","resolveIconDrawing","serializeIconDrawing","resolveIconOptions","SanityIconConfig","SanityIconOptions","SanityIcon","iconTypeName","IconSchemaType","options","InputProps","Partial","createSelectionPatches","icon","library","style","_type","name","drawing","createInput","config","Input","t0","$","_c","id","schemaType","value","onChange","readOnly","storedLibrary","node","open","setOpen","icons","selectedDrawing","selectedName","undefined","selectedLabel","undrawnName","active","saveDrawing","libraryIcons","find","candidate","warn","handleSelect","icon_0","T0","t1","T1","t2","t3","t4","t5","t6","t7","t8","t9","t10","t11","_c","isDefined","createElement","Drawing","resolveIconDrawing","SanityIcon","createIconPreview","value","drawing","node","undefined","IconPreview","width","height","Field","createSanityIcon","convertCase","isDefined","defineField","defineType","createInput","SquareDashedIcon","createIconPreview","SanityIconConfig","SanityIcon","iconTypeName","createIconType","config","name","type","icon","description","components","field","input","validation","rule","custom","value","Partial","node","preview","select","prepare","selection","title","media","_type","fields","SanityIconNames","BaseSchemaTypeOptions","InitialValueProperty","TypeAliasDefinition","definePlugin","pluginName","iconLibraryStyles","createIconType","iconTypeName","IntrinsicDefinitions","icon","SanityIconDefinition","IconLibraryStyles","SanityIconLibrary","SanityIconStyle","Library","SanityIconName","ListedLibraryId","NonNullable","Extract","IconLibraryId","SanityIconSelection","library","style","icons","SanityIconOptions","SanityIconInitialValue","name","Omit","options","initialValue","SanityIconConfig","plugin","config","schema","types","iconPlugin"],"sources":["../../@repo/components/field.tsx","../../@repo/lib/icons.ts","../src/config/grid.ts","../src/components/picker/cell.tsx","../src/components/picker/library.tsx","../src/components/picker/problem.tsx","../src/components/picker/recent.tsx","../src/lib/library.ts","../src/components/picker/tooltip.tsx","../src/hooks/use-icon-library.ts","../src/hooks/use-icon-tooltip.ts","../src/lib/recent.ts","../src/hooks/use-recent-icons.ts","../src/lib/grid.ts","../src/components/picker/picker.tsx","../src/icons/square-dashed.tsx","../src/lib/options.ts","../src/types.ts","../src/components/input.tsx","../src/lib/preview.ts","../src/schemas/types/icon.ts","../src/plugin.ts"],"sourcesContent":["import { isDefined } from \"@repo/lib/utils\";\nimport { useState } from \"react\";\nimport type {\n ArrayOfObjectsFormNode,\n ArrayOfObjectsMember,\n BaseFormNode,\n DocumentFieldActionNode,\n ObjectFieldProps,\n ObjectFormNode,\n ObjectMember,\n} from \"sanity\";\nimport {\n ChangeIndicator,\n FieldActionsProvider,\n FieldActionsResolver,\n FormField,\n getPublishedId,\n useFormValue,\n} from \"sanity\";\n\n/**\n * Checks whether a form node has members, as objects and arrays of objects do.\n *\n * @param node - The form node to check.\n * @returns True if the node has members.\n */\nfunction hasMembers(node: BaseFormNode): node is ObjectFormNode | ArrayOfObjectsFormNode {\n return \"members\" in node;\n}\n\n/**\n * Collects the validation on a form node and everything inside it.\n *\n * @param node - The form node.\n * @returns Every validation result on the node or inside it.\n */\nfunction collectNodeValidation(node: BaseFormNode): BaseFormNode[\"validation\"] {\n return [...node.validation, ...(hasMembers(node) ? collectMemberValidation(node.members) : [])];\n}\n\n/**\n * Collects the validation anywhere inside a field's members. The form only passes a field the\n * validation at its own path, so a field that hides its members would otherwise show none of theirs.\n *\n * @param members - The members.\n * @returns Every validation result on the members or inside them.\n */\nfunction collectMemberValidation(members: (ObjectMember | ArrayOfObjectsMember)[]): BaseFormNode[\"validation\"] {\n return members.flatMap((member) => {\n if (member.kind === \"field\") return collectNodeValidation(member.field);\n if (member.kind === \"fieldSet\") return collectMemberValidation(member.fieldSet.members);\n if (member.kind === \"item\") return collectNodeValidation(member.item);\n\n return [];\n });\n}\n\nexport type FieldProps = ObjectFieldProps;\n\nexport function Field({\n actions,\n schemaType,\n title,\n description,\n presence,\n validation,\n level,\n inputId,\n path,\n changed,\n children,\n inputProps,\n}: FieldProps) {\n const [headerActions, setHeaderActions] = useState<DocumentFieldActionNode[]>([]);\n\n const documentId = useFormValue([\"_id\"]);\n const publishedId = typeof documentId === \"string\" ? getPublishedId(documentId) : undefined;\n const focused = inputProps.focused === true;\n const fieldValidation = [...validation, ...collectMemberValidation(inputProps.members)];\n\n return (\n <>\n {isDefined(publishedId) && isDefined(actions) && (\n <FieldActionsResolver\n actions={actions}\n documentId={publishedId}\n documentType={schemaType.name}\n onActions={setHeaderActions}\n path={path}\n schemaType={schemaType}\n />\n )}\n <FieldActionsProvider actions={headerActions} focused={focused} path={path}>\n <FormField\n __unstable_headerActions={headerActions}\n __unstable_presence={presence}\n description={description}\n inputId={inputId}\n level={level}\n title={title}\n validation={fieldValidation}\n deprecated={schemaType.deprecated}\n path={path}\n readOnly={inputProps.readOnly}\n >\n <ChangeIndicator path={path} hasFocus={focused} isChanged={changed}>\n {children}\n </ChangeIndicator>\n </FormField>\n </FieldActionsProvider>\n </>\n );\n}\n","import type { ComponentProps, ComponentType } from \"react\";\nimport { createElement } from \"react\";\n\n/** Default props for the plugin's own icons. Icons from `@sanity/icons` already match the Studio. */\nexport const defaultIconProps: ComponentProps<\"svg\"> = { width: \"1em\", height: \"1em\", strokeWidth: 1.5 };\n\n/**\n * Wraps an SVG icon component for use in the Studio.\n *\n * @param icon - The icon to wrap.\n * @param props - Props that override the Studio icon defaults.\n * @returns An icon component.\n */\nexport function createSanityIcon(icon: ComponentType<ComponentProps<\"svg\">>, props?: ComponentProps<\"svg\">) {\n const Icon = icon;\n\n function SanityIcon() {\n return createElement(Icon, { ...defaultIconProps, ...props });\n }\n\n return SanityIcon;\n}\n","/** Cell size in pixels, fixed so the grid never reflows. */\nexport const gridCellSize = 40;\n\n/** Gap between rows in pixels. */\nconst gridRowGap = 4;\n\n/** Distance from one row to the next, used to position the rendered rows. */\nexport const gridRowHeight = gridCellSize + gridRowGap;\n\n/** Icons per row. */\nexport const gridColumns = 8;\n\n/** Rows visible at once. */\nexport const gridVisibleRows = 8;\n\n/** Height of the scrolling area. The last row has no gap after it. */\nexport const gridHeight = gridVisibleRows * gridRowHeight - gridRowGap;\n\n/** Extra rows rendered above and below the visible ones, so rows are already drawn as they scroll into view. */\nexport const gridOverscan = gridVisibleRows;\n\n/** Layout shared by both grids, so recent icons line up with the library's columns. */\nexport const gridLayoutStyle = { justifyItems: \"center\", rowGap: gridRowGap } as const;\n","import { Button } from \"@sanity/ui\";\nimport type { ComponentProps } from \"react\";\n\nimport { Drawing } from \"@/components/drawing\";\nimport { gridCellSize } from \"@/config/grid\";\nimport type { LibraryIcon } from \"@/lib/library\";\n\nexport type CellProps = Omit<\n ComponentProps<typeof Button>,\n \"icon\" | \"selected\" | \"onSelect\" | \"onClick\" | \"onMouseEnter\"\n> & {\n icon: LibraryIcon;\n selected: boolean;\n focusable: boolean;\n position: number;\n total: number;\n onSelect: (icon: LibraryIcon) => void;\n onHover: (icon: LibraryIcon, element: HTMLElement) => void;\n};\n\nexport function Cell({ icon, selected, focusable, position, total, onSelect, onHover, ...props }: CellProps) {\n return (\n <Button\n type=\"button\"\n role=\"option\"\n aria-selected={selected}\n aria-posinset={position}\n aria-setsize={total}\n tabIndex={focusable ? 0 : -1}\n mode=\"bleed\"\n selected={selected}\n padding={0}\n style={{ width: gridCellSize, height: gridCellSize }}\n icon={<Drawing drawing={icon.drawing} width=\"1.25em\" height=\"1.25em\" />}\n aria-label={icon.label}\n onClick={() => {\n onSelect(icon);\n }}\n onMouseEnter={(event) => {\n onHover(icon, event.currentTarget);\n }}\n {...props}\n />\n );\n}\n","import { isDefined } from \"@repo/lib/utils\";\nimport { Box, Button, Flex, Grid, Text } from \"@sanity/ui\";\nimport type { ComponentProps, RefObject } from \"react\";\n\nimport type { CellProps } from \"@/components/picker/cell\";\nimport { Cell } from \"@/components/picker/cell\";\nimport { gridColumns, gridHeight, gridLayoutStyle, gridRowHeight } from \"@/config/grid\";\nimport type { getVisibleRows } from \"@/lib/grid\";\nimport type { LibraryIcon } from \"@/lib/library\";\n\nexport type LibraryProps = Omit<ComponentProps<typeof Box>, \"children\" | \"onSelect\"> & {\n icons: LibraryIcon[];\n rows: ReturnType<typeof getVisibleRows>;\n selected: string | undefined;\n activeIndex: number;\n activeCell: RefObject<HTMLButtonElement | null>;\n search: string;\n onSelect: (icon: LibraryIcon) => void;\n onHover: CellProps[\"onHover\"];\n onClearSearch: () => void;\n};\n\nexport function Library({\n icons,\n rows,\n selected,\n activeIndex,\n activeCell,\n search,\n onSelect,\n onHover,\n onClearSearch,\n ...props\n}: LibraryProps) {\n const { totalRows, firstRow, lastRow } = rows;\n const visible = icons.slice(firstRow * gridColumns, lastRow * gridColumns);\n\n return (\n <Box\n role=\"listbox\"\n aria-label=\"Icon library\"\n style={isDefined(icons) ? { height: gridHeight, overflowY: \"auto\" } : undefined}\n {...props}\n >\n {!isDefined(icons) && (\n <Flex align=\"center\" justify=\"center\" direction=\"column\" gap={3} paddingTop={5} paddingBottom={6}>\n <Text size={1} muted>{`Nothing matches \"${search}\".`}</Text>\n <Button type=\"button\" mode=\"ghost\" text=\"Clear search\" onClick={onClearSearch} />\n </Flex>\n )}\n {isDefined(icons) && (\n <Grid\n gridTemplateColumns={gridColumns}\n style={{\n ...gridLayoutStyle,\n paddingTop: firstRow * gridRowHeight,\n paddingBottom: (totalRows - lastRow) * gridRowHeight,\n }}\n >\n {visible.map((icon, offset) => {\n const index = firstRow * gridColumns + offset;\n\n return (\n <Cell\n key={icon.name}\n ref={index === activeIndex ? activeCell : undefined}\n icon={icon}\n selected={icon.name === selected}\n focusable={index === activeIndex}\n position={index + 1}\n total={icons.length}\n onSelect={onSelect}\n onHover={onHover}\n />\n );\n })}\n </Grid>\n )}\n </Box>\n );\n}\n","import { WarningOutlineIcon } from \"@sanity/icons/WarningOutline\";\nimport { Card, Flex, Stack, Text } from \"@sanity/ui\";\nimport type { ComponentProps } from \"react\";\n\nimport type { LibraryProblem } from \"@/lib/library\";\n\nexport type CodeTextProps = Omit<ComponentProps<\"span\">, \"children\"> & {\n text: string;\n};\n\nexport function CodeText({ text, ...props }: CodeTextProps) {\n const parts = text.split(\"`\");\n\n return (\n <span {...props}>\n {parts.map((part, index) => {\n const start = parts.slice(0, index).join(\"`\").length;\n\n return index % 2 === 1 ? <code key={start}>{part}</code> : part;\n })}\n </span>\n );\n}\n\nexport type ProblemProps = Omit<ComponentProps<typeof Card>, \"children\"> & {\n problem: LibraryProblem;\n};\n\nexport function Problem({ problem, ...props }: ProblemProps) {\n return (\n <Card tone=\"caution\" padding={4} radius={2} border {...props}>\n <Flex gap={3}>\n <Text size={1}>\n <WarningOutlineIcon />\n </Text>\n <Stack gap={3}>\n <Text size={1} weight=\"medium\">\n <CodeText text={problem.title} />\n </Text>\n <Text size={1} muted>\n <CodeText text={problem.description} />\n </Text>\n </Stack>\n </Flex>\n </Card>\n );\n}\n","import { Button, Flex, Grid, Stack, Text } from \"@sanity/ui\";\nimport type { ComponentProps } from \"react\";\n\nimport type { CellProps } from \"@/components/picker/cell\";\nimport { Cell } from \"@/components/picker/cell\";\nimport { gridColumns, gridLayoutStyle } from \"@/config/grid\";\nimport type { LibraryIcon } from \"@/lib/library\";\n\nexport type RecentProps = Omit<ComponentProps<typeof Stack>, \"children\" | \"onSelect\"> & {\n icons: LibraryIcon[];\n selected: string | undefined;\n onSelect: (icon: LibraryIcon) => void;\n onHover: CellProps[\"onHover\"];\n onForget: () => void;\n};\n\nexport function Recent({ icons, selected, onSelect, onHover, onForget, ...props }: RecentProps) {\n return (\n <Stack gap={3} {...props}>\n <Flex align=\"center\" justify=\"space-between\" gap={2}>\n <Text size={1} weight=\"medium\" muted>\n Recent icons\n </Text>\n <Button\n type=\"button\"\n mode=\"bleed\"\n fontSize={1}\n padding={2}\n text=\"Clear\"\n onClick={onForget}\n aria-label=\"Clear recent icons\"\n />\n </Flex>\n <Grid role=\"listbox\" aria-label=\"Recent icons\" gridTemplateColumns={gridColumns} style={gridLayoutStyle}>\n {icons.map((icon, index) => (\n <Cell\n key={icon.name}\n icon={icon}\n selected={icon.name === selected}\n focusable\n position={index + 1}\n total={icons.length}\n onSelect={onSelect}\n onHover={onHover}\n />\n ))}\n </Grid>\n </Stack>\n );\n}\n","import { iconRegistry } from \"@driftime/sanity-plugin-icon/sets\";\nimport { convertCase, isDefined } from \"@repo/lib/utils\";\n\nimport type { IconDrawing } from \"@/lib/nodes\";\nimport { getIconSetKey } from \"@/lib/registry\";\nimport { parseIconSet } from \"@/lib/sets\";\n\n/** Icon in the library, with the terms a search matches against. */\nexport interface LibraryIcon {\n /** Name of the icon in its library. */\n name: string;\n /** Readable form of the name. */\n label: string;\n /** Keywords describing the icon, as a comma-separated list. */\n tags: string;\n /** The icon's shapes and the SVG attributes they're drawn inside. */\n drawing: IconDrawing;\n /** Name and keywords, normalised for search. */\n terms: string;\n}\n\n/** Why a library's icons can't be shown, and what to do about it, with code marked by backticks. */\nexport interface LibraryProblem {\n /** What's wrong, in a few words. */\n title: string;\n /** What to do about it. */\n description: string;\n}\n\n/** Outcome of loading a library: its icons, or why they can't be shown. */\nexport type LibraryResult =\n | { icons: LibraryIcon[]; problem?: undefined }\n | { icons?: undefined; problem: LibraryProblem };\n\n/**\n * Normalises text for search, so hyphenated names and multi-word keywords match the same way.\n *\n * @param value - The text.\n * @returns The normalised text.\n */\nexport function normalizeTerms(value: string) {\n return value\n .toLowerCase()\n .replaceAll(/[\\s-]+/gu, \" \")\n .trim();\n}\n\n/**\n * Splits text into the parts a search matches and the parts it doesn't, matching the way search does: ignoring case,\n * and treating spaces and hyphens alike.\n *\n * @param text - The text to split.\n * @param query - The normalised search.\n * @returns The parts in order, each with where it starts in the text and whether it matches.\n */\nexport function splitMatches(text: string, query: string) {\n if (!isDefined(query)) return [{ text, start: 0, match: false }];\n\n const pattern = query\n .split(\" \")\n .map((word) => word.replaceAll(/[$()*+.?[\\\\\\]^{|}]/gu, String.raw`\\$&`))\n .join(String.raw`[\\s-]+`);\n\n const parts = text.split(new RegExp(`(${pattern})`, \"giu\"));\n\n return parts.map((part, index) => ({\n text: part,\n start: parts.slice(0, index).join(\"\").length,\n match: index % 2 === 1,\n }));\n}\n\n/**\n * Narrows the library to the named icons, in the order given. Unknown names are skipped, so a list keeps working\n * across library releases.\n *\n * @param library - Every icon in the library.\n * @param names - The icons to offer, or undefined for all of them.\n * @returns The icons to offer.\n */\nexport function selectIcons(library: LibraryIcon[], names: string[] | undefined) {\n if (!isDefined(names)) return library;\n\n const byName = new Map(library.map((icon) => [icon.name, icon]));\n\n return [...new Set(names)].flatMap((name) => {\n const icon = byName.get(name);\n\n return isDefined(icon) ? [icon] : [];\n });\n}\n\n/**\n * Lists identifiers as inline code, separated by commas.\n *\n * @param identifiers - The identifiers.\n * @returns The list.\n */\nfunction formatList(identifiers: string[]) {\n return identifiers.map((identifier) => `\\`${identifier}\\``).join(\", \");\n}\n\n/**\n * Describes why a library the project hasn't installed can't be shown, and what to add.\n *\n * @param label - Readable name of the library.\n * @param packageName - Package the library is read from, or an example of one for a family of packages.\n * @param family - Whether the library is a family of packages, one per style.\n * @param listed - Whether the project's `package.json` lists the package.\n * @param sitePackage - Another package of the library the project lists, or undefined when there's none.\n * @returns The problem.\n */\nfunction describeMissingLibrary(\n label: string,\n packageName: string,\n family: boolean,\n listed: boolean,\n sitePackage: string | undefined,\n): LibraryProblem {\n if (listed) {\n return {\n title: `${label} isn't installed yet`,\n description: `\\`${packageName}\\` is in \\`package.json\\` but not in \\`node_modules\\`. Reinstall the project's dependencies.`,\n };\n }\n\n if (isDefined(sitePackage)) {\n return {\n title: `${label} needs \\`${packageName}\\``,\n description: `The Studio reads ${label} from \\`${packageName}\\`, not \\`${sitePackage}\\`. Add it as a dev dependency.`,\n };\n }\n\n return {\n title: `${label} isn't installed`,\n description: family\n ? `Install a ${label} style package, such as \\`${packageName}\\`.`\n : `Install \\`${packageName}\\` in the project.`,\n };\n}\n\n/**\n * Loads one library style from the sets the build step converted.\n *\n * @param library - Identifier of the library, or undefined when none is set.\n * @param style - Identifier of the style, or undefined for the library's default.\n * @returns The icons, or why they can't be shown.\n */\nasync function readLibrary(library: string | undefined, style: string | undefined): Promise<LibraryResult> {\n if (!isDefined(library)) {\n return {\n problem: {\n title: \"No icon library set\",\n description: \"Set `library` in the icon plugin's configuration or in the field's options.\",\n },\n };\n }\n\n if (!iconRegistry.ready) {\n return {\n problem: {\n title: \"Icons aren't set up\",\n description: \"Add `withIcons()` to the Studio's build configuration, then restart the Studio.\",\n },\n };\n }\n\n const info = iconRegistry.libraries[library];\n if (!isDefined(info)) {\n return {\n problem: {\n title: \"Unknown icon library\",\n description: `There's no icon library called \\`${library}\\`. Use one of: ${formatList(Object.keys(iconRegistry.libraries))}.`,\n },\n };\n }\n\n const { label, packageName, packagePrefix, styles, listed, installed, sitePackage } = info;\n if (!installed) {\n return { problem: describeMissingLibrary(label, packageName, isDefined(packagePrefix), listed, sitePackage) };\n }\n\n const resolvedStyle = style ?? styles[0] ?? \"\";\n const loader = iconRegistry.sets[getIconSetKey(library, resolvedStyle)];\n if (!isDefined(loader)) {\n return {\n problem: isDefined(packagePrefix)\n ? {\n title: `${label} style \\`${resolvedStyle}\\` isn't installed`,\n description: `Install \\`${packagePrefix}${resolvedStyle}\\` in the project.`,\n }\n : {\n title: `Unknown ${label} style`,\n description: `${label} has no \\`${resolvedStyle}\\` style. Use one of: ${formatList(styles)}.`,\n },\n };\n }\n\n const module = await loader();\n const set = parseIconSet(module.default);\n if (!isDefined(set)) {\n return { problem: { title: `Couldn't load ${label}`, description: \"Restart the Studio and try again.\" } };\n }\n\n return {\n icons: set.icons.map(({ name, keywords, node, root }) => ({\n name,\n label: convertCase(name, \"title\"),\n tags: keywords.join(\", \"),\n drawing: { root: root ?? set.root, node },\n terms: normalizeTerms([name, ...keywords].join(\" \")),\n })),\n };\n}\n\n/** Library requests shared by every field in the session, keyed by library and style, since the data never changes. */\nconst libraryRequests = new Map<string, Promise<LibraryResult>>();\n\n/**\n * Loads a library style, reusing a request already in progress.\n *\n * @param library - Identifier of the library, or undefined when none is set.\n * @param style - Identifier of the style, or undefined for the library's default.\n * @returns The icons, or why they can't be shown.\n */\nexport async function requestLibrary(library: string | undefined, style: string | undefined) {\n const key = getIconSetKey(library ?? \"\", style ?? \"\");\n let request = libraryRequests.get(key);\n\n if (!isDefined(request)) {\n request = readLibrary(library, style);\n libraryRequests.set(key, request);\n }\n\n const result = await request;\n\n return result;\n}\n","import { isDefined } from \"@repo/lib/utils\";\nimport { Stack, Text } from \"@sanity/ui\";\nimport { Popover } from \"@sanity/ui/popover\";\nimport type { CSSProperties, ComponentProps } from \"react\";\n\nimport type { LibraryIcon } from \"@/lib/library\";\nimport { splitMatches } from \"@/lib/library\";\n\n/** Icon under the cursor and the cell showing it. */\nexport interface HoveredIcon {\n /** Icon in the cell. */\n icon: LibraryIcon;\n /** Cell the tooltip points at. */\n element: HTMLElement;\n}\n\n/**\n * Gap between the tooltip and its cell, set through margins because `@sanity/ui` offers no other way.\n * Only the top is set, since the tooltip always appears above the cell.\n */\nconst tooltipMargins: [number, number, number, number] = [-4, 0, 0, 0];\n\n/** Underlines a search match in place of the browser's highlighter-pen look, keeping the text's own colour. */\nconst matchStyle: CSSProperties = {\n background: \"none\",\n color: \"inherit\",\n textDecorationLine: \"underline\",\n textUnderlineOffset: \"0.2em\",\n};\n\nexport type HighlightProps = Omit<ComponentProps<\"span\">, \"children\"> & {\n text: string;\n query: string;\n};\n\nexport function Highlight({ text, query, ...props }: HighlightProps) {\n return (\n <span {...props}>\n {splitMatches(text, query).map((part) =>\n part.match ? (\n <mark key={part.start} style={matchStyle}>\n {part.text}\n </mark>\n ) : (\n part.text\n ),\n )}\n </span>\n );\n}\n\nexport type TooltipProps = Omit<ComponentProps<typeof Popover>, \"open\" | \"referenceElement\" | \"content\"> & {\n hovered: HoveredIcon | undefined;\n query: string;\n};\n\nexport function Tooltip({ hovered, query, ...props }: TooltipProps) {\n return (\n <Popover\n open={isDefined(hovered)}\n referenceElement={hovered?.element ?? null}\n placement=\"top\"\n portal\n padding={3}\n __unstable_margins={tooltipMargins}\n style={{ pointerEvents: \"none\" }}\n content={\n isDefined(hovered) && (\n <Stack gap={3} style={{ maxWidth: \"16rem\" }}>\n <Text size={1} weight=\"medium\">\n <Highlight text={hovered.icon.label} query={query} />\n </Text>\n {isDefined(hovered.icon.tags) && (\n <Text size={1} muted>\n <Highlight text={hovered.icon.tags} query={query} />\n </Text>\n )}\n </Stack>\n )\n }\n {...props}\n />\n );\n}\n","import { useEffect, useState } from \"react\";\n\nimport type { LibraryResult } from \"@/lib/library\";\nimport { requestLibrary } from \"@/lib/library\";\n\n/**\n * Loads an icon library style. Only an open picker calls this, so a Studio that never opens one never loads it.\n *\n * @param library - Identifier of the library, or undefined when none is set.\n * @param style - Identifier of the style, or undefined for the library's default.\n * @returns The icons or why they can't be shown, or undefined while loading.\n */\nexport function useIconLibrary(library: string | undefined, style: string | undefined) {\n const [result, setResult] = useState<LibraryResult>();\n\n useEffect(() => {\n let active = true;\n\n async function load() {\n const loaded = await requestLibrary(library, style);\n if (active) setResult(loaded);\n }\n\n void load();\n\n return () => {\n active = false;\n };\n }, [library, style]);\n\n return result;\n}\n","import { isDefined } from \"@repo/lib/utils\";\nimport { useEffect, useRef, useState } from \"react\";\n\nimport type { HoveredIcon } from \"@/components/picker/tooltip\";\nimport type { LibraryIcon } from \"@/lib/library\";\n\n/**\n * Tracks the icon under the cursor, showing its tooltip after a short delay. Tooltips are held back while the grid\n * scrolls, and the icon left under the cursor gets its tooltip once scrolling stops.\n *\n * @param scrolling - Whether the grid is scrolling.\n * @returns The hovered icon, and functions to update and clear it.\n */\nexport function useIconTooltip(scrolling: boolean) {\n const [hovered, setHovered] = useState<HoveredIcon>();\n const hoverStart = useRef<ReturnType<typeof setTimeout>>(undefined);\n const scrolledOnto = useRef<HoveredIcon>(undefined);\n\n useEffect(\n () => () => {\n if (isDefined(hoverStart.current)) clearTimeout(hoverStart.current);\n },\n [],\n );\n\n useEffect(() => {\n const landed = scrolledOnto.current;\n if (scrolling || !isDefined(landed)) return;\n\n scrolledOnto.current = undefined;\n if (!landed.element.isConnected || !landed.element.matches(\":hover\")) return;\n\n hoverStart.current = setTimeout(() => {\n setHovered(landed);\n }, 200);\n }, [scrolling]);\n\n function clearHover() {\n if (isDefined(hoverStart.current)) clearTimeout(hoverStart.current);\n if (isDefined(hovered)) setHovered(undefined);\n }\n\n function handleHover(icon: LibraryIcon, element: HTMLElement) {\n if (scrolling) {\n scrolledOnto.current = { icon, element };\n\n return;\n }\n\n if (element === hovered?.element) return;\n\n if (isDefined(hoverStart.current)) clearTimeout(hoverStart.current);\n\n if (isDefined(hovered)) {\n setHovered({ icon, element });\n\n return;\n }\n\n hoverStart.current = setTimeout(() => {\n setHovered({ icon, element });\n }, 200);\n }\n\n return { hovered, handleHover, clearHover };\n}\n","/** Local storage key for recent icons, which are kept in the browser rather than the dataset. */\nconst storageKey = \"driftime:sanity-plugin-icon:recent\";\n\n/** Number of recent icons to keep. */\nconst limit = 8;\n\n/**\n * Builds the storage key for one library style.\n *\n * @param scope - The library and style, such as `phosphor/bold`.\n * @returns The storage key.\n */\nfunction getStorageKey(scope: string) {\n return `${storageKey}:${scope}`;\n}\n\n/**\n * Reads the recently chosen icons.\n *\n * @param scope - The library and style, such as `phosphor/bold`.\n * @returns The icon names, most recent first.\n */\nexport function readRecent(scope: string) {\n try {\n const stored: unknown = JSON.parse(globalThis.localStorage.getItem(getStorageKey(scope)) ?? \"[]\");\n if (!Array.isArray(stored)) return [];\n\n return stored.filter((entry: unknown) => typeof entry === \"string\");\n } catch {\n return [];\n }\n}\n\n/**\n * Adds an icon to the front of the recent list.\n *\n * @param scope - The library and style, such as `phosphor/bold`.\n * @param name - The chosen icon's name.\n * @returns The updated icon names, most recent first.\n */\nexport function writeRecent(scope: string, name: string) {\n const updated = [name, ...readRecent(scope).filter((entry) => entry !== name)].slice(0, limit);\n\n try {\n globalThis.localStorage.setItem(getStorageKey(scope), JSON.stringify(updated));\n } catch {\n // If storage is blocked, the icon just isn't remembered.\n }\n\n return updated;\n}\n\n/**\n * Clears the recent icons.\n *\n * @param scope - The library and style, such as `phosphor/bold`.\n */\nexport function clearRecent(scope: string) {\n try {\n globalThis.localStorage.removeItem(getStorageKey(scope));\n } catch {\n // If storage is blocked, there's nothing to clear.\n }\n}\n","import { useState } from \"react\";\n\nimport { clearRecent, readRecent, writeRecent } from \"@/lib/recent\";\n\n/**\n * Tracks the icons an author chose most recently from one library style. The list is read when the picker opens, so\n * choices made in another tab are included.\n *\n * @param scope - The library and style, such as `phosphor/bold`.\n * @returns The recent icon names, most recent first, and functions to add to and clear them.\n */\nexport function useRecentIcons(scope: string) {\n const [recent, setRecent] = useState<string[]>(() => readRecent(scope));\n\n function remember(name: string) {\n setRecent(writeRecent(scope, name));\n }\n\n function forget() {\n clearRecent(scope);\n setRecent([]);\n }\n\n return { recent, remember, forget };\n}\n","import { gridColumns, gridHeight, gridOverscan, gridRowHeight, gridVisibleRows } from \"@/config/grid\";\n\n/**\n * Works out which icon a key press moves to.\n *\n * @param key - The key pressed.\n * @param current - Index of the current icon.\n * @param last - Index of the last icon.\n * @returns The new index, or undefined when the key doesn't move.\n */\nexport function getNextIndex(key: string, current: number, last: number) {\n if (key === \"ArrowRight\") return current + 1;\n if (key === \"ArrowLeft\") return current - 1;\n if (key === \"ArrowDown\") return current + gridColumns;\n if (key === \"ArrowUp\") return current - gridColumns;\n if (key === \"Home\") return 0;\n if (key === \"End\") return last;\n\n return undefined;\n}\n\n/**\n * Works out which rows to render at a scroll position, so only icons near the viewport are mounted.\n * Padding replaces the other rows, so the scrollbar stays the right size.\n *\n * @param scrollRow - The row scrolled to.\n * @param count - Number of icons in the results.\n * @returns The first and last rows to render, and the total number of rows.\n */\nexport function getVisibleRows(scrollRow: number, count: number) {\n const totalRows = Math.ceil(count / gridColumns);\n const firstRow = Math.max(0, scrollRow - gridOverscan);\n const lastRow = Math.min(totalRows, firstRow + gridVisibleRows + gridOverscan * 2);\n\n return { totalRows, firstRow, lastRow };\n}\n\n/**\n * Works out the scroll position that centres an icon, for opening on the selected icon.\n *\n * @param index - Index of the icon.\n * @returns The scroll position.\n */\nexport function getCenteredScrollTop(index: number) {\n return Math.max(0, Math.floor(index / gridColumns) * gridRowHeight - gridHeight / 2);\n}\n\n/**\n * Works out the scroll position that brings an icon into view, keeping the current one if it's\n * already visible. It uses the index because Home and End can move to rows that aren't mounted.\n *\n * @param index - Index of the icon.\n * @param scrollTop - The current scroll position.\n * @returns The scroll position.\n */\nexport function getRevealedScrollTop(index: number, scrollTop: number) {\n const top = Math.floor(index / gridColumns) * gridRowHeight;\n\n if (top < scrollTop) return top;\n if (top + gridRowHeight > scrollTop + gridHeight) return top + gridRowHeight - gridHeight;\n\n return scrollTop;\n}\n","import { isDefined } from \"@repo/lib/utils\";\nimport { SearchIcon } from \"@sanity/icons/Search\";\nimport { Box, Dialog, Flex, Spinner, Stack, Text, TextInput } from \"@sanity/ui\";\nimport type { ChangeEvent, ComponentProps, KeyboardEvent } from \"react\";\nimport { useEffect, useRef, useState } from \"react\";\n\nimport { Library } from \"@/components/picker/library\";\nimport { Problem } from \"@/components/picker/problem\";\nimport { Recent } from \"@/components/picker/recent\";\nimport { Tooltip } from \"@/components/picker/tooltip\";\nimport { gridHeight, gridRowHeight } from \"@/config/grid\";\nimport { useIconLibrary } from \"@/hooks/use-icon-library\";\nimport { useIconTooltip } from \"@/hooks/use-icon-tooltip\";\nimport { useRecentIcons } from \"@/hooks/use-recent-icons\";\nimport { getCenteredScrollTop, getNextIndex, getRevealedScrollTop, getVisibleRows } from \"@/lib/grid\";\nimport type { LibraryIcon } from \"@/lib/library\";\nimport { normalizeTerms, selectIcons } from \"@/lib/library\";\nimport { getIconSetKey } from \"@/lib/registry\";\n\nexport type PickerProps = Omit<\n ComponentProps<typeof Dialog>,\n \"children\" | \"header\" | \"width\" | \"selected\" | \"onSelect\"\n> & {\n library: string | undefined;\n iconStyle: string | undefined;\n allowed: string[] | undefined;\n selected: string | undefined;\n onSelect: (icon: LibraryIcon) => void;\n};\n\nexport function Picker({ library: libraryName, iconStyle, allowed, selected, onSelect, ...props }: PickerProps) {\n const result = useIconLibrary(libraryName, iconStyle);\n const library = result?.icons;\n const icons = selectIcons(library ?? [], allowed);\n const { recent, remember, forget } = useRecentIcons(getIconSetKey(libraryName ?? \"\", iconStyle ?? \"default\"));\n\n const [search, setSearch] = useState(\"\");\n const [scrollRow, setScrollRow] = useState(0);\n const [movedIndex, setMovedIndex] = useState<number>();\n const [scrolling, setScrolling] = useState(false);\n\n const scroller = useRef<HTMLDivElement>(null);\n const activeCell = useRef<HTMLButtonElement>(null);\n const focusIndex = useRef<number>(undefined);\n const scrollFrame = useRef<number>(undefined);\n const scrollStop = useRef<ReturnType<typeof setTimeout>>(undefined);\n\n const query = normalizeTerms(search);\n const searching = isDefined(query);\n const results = icons.filter((icon) => !searching || icon.terms.includes(query));\n\n const byName = new Map(icons.map((icon) => [icon.name, icon]));\n const recentIcons = searching\n ? []\n : recent.flatMap((entry) => {\n const icon = byName.get(entry);\n\n return isDefined(icon) ? [icon] : [];\n });\n\n const { hovered, handleHover, clearHover } = useIconTooltip(scrolling);\n\n const rows = getVisibleRows(scrollRow, results.length);\n\n const selectedIndex = searching || !isDefined(selected) ? -1 : icons.findIndex((icon) => icon.name === selected);\n const activeIndex = movedIndex ?? Math.max(0, selectedIndex);\n\n useEffect(() => {\n const element = scroller.current;\n if (!isDefined(element) || selectedIndex === -1) return;\n\n element.scrollTop = getCenteredScrollTop(selectedIndex);\n }, [scroller, selectedIndex]);\n\n useEffect(\n () => () => {\n if (isDefined(scrollFrame.current)) cancelAnimationFrame(scrollFrame.current);\n if (isDefined(scrollStop.current)) clearTimeout(scrollStop.current);\n },\n [],\n );\n\n useEffect(() => {\n if (focusIndex.current !== activeIndex) return;\n\n focusIndex.current = undefined;\n if (isDefined(activeCell.current)) activeCell.current.focus();\n }, [activeIndex]);\n\n function handleSelect(icon: LibraryIcon) {\n remember(icon.name);\n onSelect(icon);\n }\n\n function clearSearch() {\n setSearch(\"\");\n setMovedIndex(undefined);\n }\n\n function handleSearch(event: ChangeEvent<HTMLInputElement>) {\n setSearch(event.currentTarget.value);\n setMovedIndex(undefined);\n\n if (isDefined(scroller.current)) scroller.current.scrollTop = 0;\n }\n\n function selectActive() {\n const icon = results[activeIndex];\n\n if (isDefined(icon)) handleSelect(icon);\n }\n\n function handleSearchKeyDown(event: KeyboardEvent<HTMLInputElement>) {\n if (event.key === \"Enter\") {\n event.preventDefault();\n selectActive();\n\n return;\n }\n\n if (event.key !== \"ArrowDown\") return;\n\n event.preventDefault();\n\n if (isDefined(activeCell.current)) activeCell.current.focus();\n }\n\n function handleScroll() {\n clearHover();\n if (!scrolling) setScrolling(true);\n\n if (isDefined(scrollStop.current)) clearTimeout(scrollStop.current);\n scrollStop.current = setTimeout(() => {\n setScrolling(false);\n }, 150);\n\n if (isDefined(scrollFrame.current)) return;\n\n scrollFrame.current = requestAnimationFrame(() => {\n scrollFrame.current = undefined;\n\n const element = scroller.current;\n if (isDefined(element)) setScrollRow(Math.floor(element.scrollTop / gridRowHeight));\n });\n }\n\n function handleGridKeyDown(event: KeyboardEvent<HTMLDivElement>) {\n const last = results.length - 1;\n if (last < 0) return;\n\n if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n selectActive();\n\n return;\n }\n\n const next = getNextIndex(event.key, activeIndex, last);\n if (!isDefined(next)) return;\n\n event.preventDefault();\n\n const index = Math.min(Math.max(next, 0), last);\n focusIndex.current = index;\n setMovedIndex(index);\n\n const element = scroller.current;\n if (!isDefined(element)) return;\n\n element.scrollTop = getRevealedScrollTop(index, element.scrollTop);\n }\n\n return (\n <Dialog header=\"Select icon\" width={1} {...props}>\n <Stack gap={4} padding={4}>\n {!isDefined(result?.problem) && (\n <TextInput\n type=\"search\"\n icon={<SearchIcon />}\n placeholder=\"Search by name or keyword\"\n value={search}\n onChange={handleSearch}\n onKeyDown={handleSearchKeyDown}\n disabled={!isDefined(library) || !isDefined(icons)}\n aria-label=\"Search the icon library\"\n />\n )}\n {!isDefined(result) && (\n <Flex align=\"center\" justify=\"center\" style={{ height: gridHeight }}>\n <Spinner muted />\n </Flex>\n )}\n {isDefined(result?.problem) && <Problem problem={result.problem} />}\n {isDefined(recentIcons) && (\n <Recent\n icons={recentIcons}\n selected={selected}\n onSelect={handleSelect}\n onHover={handleHover}\n onForget={forget}\n onMouseLeave={clearHover}\n />\n )}\n {isDefined(library) && (\n <Stack gap={3}>\n <Box paddingY={2}>\n <Text size={1} weight=\"medium\" muted>\n All icons ({results.length.toLocaleString(\"en-US\")})\n </Text>\n </Box>\n {!isDefined(icons) && (\n <Flex align=\"center\" justify=\"center\" paddingTop={5} paddingBottom={6}>\n <Text size={1} muted>\n No icons available.\n </Text>\n </Flex>\n )}\n {isDefined(icons) && (\n <Library\n ref={scroller}\n icons={results}\n rows={rows}\n selected={selected}\n activeIndex={activeIndex}\n activeCell={activeCell}\n search={search}\n onSelect={handleSelect}\n onHover={handleHover}\n onClearSearch={clearSearch}\n onScroll={handleScroll}\n onMouseLeave={clearHover}\n onKeyDown={handleGridKeyDown}\n />\n )}\n </Stack>\n )}\n <Tooltip key={hovered?.icon.name} hovered={hovered} query={query} />\n </Stack>\n </Dialog>\n );\n}\n","import type { ComponentProps } from \"react\";\n\nexport type SquareDashedIconProps = ComponentProps<\"svg\">;\n\nexport function SquareDashedIcon(props: SquareDashedIconProps) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width={24}\n height={24}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n {...props}\n >\n <path d=\"M5 3a2 2 0 0 0-2 2\" />\n <path d=\"M19 3a2 2 0 0 1 2 2\" />\n <path d=\"M21 19a2 2 0 0 1-2 2\" />\n <path d=\"M5 21a2 2 0 0 1-2-2\" />\n <path d=\"M9 3h1\" />\n <path d=\"M9 21h1\" />\n <path d=\"M14 3h1\" />\n <path d=\"M14 21h1\" />\n <path d=\"M3 9v1\" />\n <path d=\"M21 9v1\" />\n <path d=\"M3 14v1\" />\n <path d=\"M21 14v1\" />\n </svg>\n );\n}\n","import { isDefined } from \"@repo/lib/utils\";\n\nimport type { SanityIconConfig, SanityIconOptions, SanityIconSelection } from \"@/plugin\";\n\n/**\n * Resolves the library, style, and icons a field offers. A field that names a library replaces all three of the\n * plugin's, and one that doesn't uses the plugin's.\n *\n * @param options - The field's options.\n * @param config - The plugin configuration.\n * @returns The field's settings, whose library is undefined when neither the field nor the plugin names one.\n */\nexport function resolveIconOptions(options: SanityIconOptions | undefined, config: SanityIconConfig | undefined) {\n const { library, style, icons }: Partial<SanityIconSelection> =\n (isDefined(options?.library) ? options : config) ?? {};\n\n return { library, style, icons };\n}\n","/** Schema type name of the icon object. */\nexport const iconTypeName = \"icon\";\n\n/**\n * Stored icon: which library it came from, its name, and the shapes it's drawn from.\n *\n * @public\n */\nexport interface SanityIcon {\n _type: typeof iconTypeName;\n /** Identifier of the library the icon came from. */\n library?: string;\n /** Identifier of the library style the icon came from. */\n style?: string;\n /** Name of the icon in its library. */\n name?: string;\n /** Shapes the icon is drawn from, saved when it's chosen. */\n node?: string;\n}\n","import { defaultIconProps } from \"@repo/lib/icons\";\nimport { convertCase, isDefined } from \"@repo/lib/utils\";\nimport { CloseIcon } from \"@sanity/icons/Close\";\nimport { Button, Flex } from \"@sanity/ui\";\nimport { useEffect, useState } from \"react\";\nimport type { ObjectInputProps, ObjectSchemaType } from \"sanity\";\nimport { set, setIfMissing, unset } from \"sanity\";\n\nimport { Drawing } from \"@/components/drawing\";\nimport { Picker } from \"@/components/picker/picker\";\nimport { logger } from \"@/config/defaults\";\nimport { SquareDashedIcon } from \"@/icons/square-dashed\";\nimport type { LibraryIcon } from \"@/lib/library\";\nimport { requestLibrary, selectIcons } from \"@/lib/library\";\nimport { resolveIconDrawing, serializeIconDrawing } from \"@/lib/nodes\";\nimport { resolveIconOptions } from \"@/lib/options\";\nimport type { SanityIconConfig, SanityIconOptions } from \"@/plugin\";\nimport type { SanityIcon } from \"@/types\";\nimport { iconTypeName } from \"@/types\";\n\n/** Compiled icon field type, with the field's own options. */\ninterface IconSchemaType extends ObjectSchemaType {\n options?: SanityIconOptions;\n}\n\nexport type InputProps = ObjectInputProps<Partial<SanityIcon>, IconSchemaType>;\n\n/**\n * Creates the patches that store an icon, with the library and style it was chosen from.\n *\n * @param icon - The icon.\n * @param library - Identifier of the library, or undefined when none is set.\n * @param style - Identifier of the style, or undefined for the library's default.\n * @returns The patches.\n */\nfunction createSelectionPatches(icon: LibraryIcon, library: string | undefined, style: string | undefined) {\n return [\n setIfMissing({ _type: iconTypeName satisfies SanityIcon[\"_type\"] }),\n isDefined(library)\n ? set(library, [\"library\" satisfies keyof SanityIcon])\n : unset([\"library\" satisfies keyof SanityIcon]),\n isDefined(style) ? set(style, [\"style\" satisfies keyof SanityIcon]) : unset([\"style\" satisfies keyof SanityIcon]),\n set(icon.name, [\"name\" satisfies keyof SanityIcon]),\n set(serializeIconDrawing(icon.drawing), [\"node\" satisfies keyof SanityIcon]),\n ];\n}\n\n/**\n * Creates the icon field input, bound to the plugin's configuration. A field's own icons replace the\n * plugin's rather than adding to them.\n *\n * @param config - The plugin configuration.\n * @returns The input component.\n */\nexport function createInput(config: SanityIconConfig) {\n function Input({ id, schemaType, value, onChange, readOnly }: InputProps) {\n const { library: storedLibrary, name, node } = value ?? {};\n\n const [open, setOpen] = useState(false);\n\n const { library, style, icons } = resolveIconOptions(schemaType.options, config);\n const selectedDrawing = resolveIconDrawing(node);\n const selectedName = storedLibrary === library ? name : undefined;\n const selectedLabel = isDefined(name) ? convertCase(name, \"title\") : undefined;\n const undrawnName = isDefined(node) ? undefined : name;\n\n // An initial value names an icon without its drawing, so the drawing is saved when the field is first shown.\n useEffect(() => {\n let active = true;\n\n async function saveDrawing() {\n if (!isDefined(undrawnName) || readOnly === true) return;\n\n const { icons: libraryIcons } = await requestLibrary(library, style);\n if (!active || !isDefined(libraryIcons)) return;\n\n const icon = selectIcons(libraryIcons, icons).find((candidate) => candidate.name === undrawnName);\n\n if (!isDefined(icon)) {\n logger.warn(\n `The icon field \"${id}\" starts with \"${undrawnName}\", which isn't one of its icons. Change its initialValue.`,\n );\n\n return;\n }\n\n onChange(createSelectionPatches(icon, library, style));\n }\n\n void saveDrawing();\n\n return () => {\n active = false;\n };\n }, [id, undrawnName, readOnly, library, style, icons, onChange]);\n\n function handleSelect(icon: LibraryIcon) {\n onChange(createSelectionPatches(icon, library, style));\n setOpen(false);\n }\n\n return (\n <Flex gap={2}>\n <Button\n id={id}\n type=\"button\"\n mode=\"ghost\"\n icon={\n isDefined(selectedDrawing) ? (\n <Drawing drawing={selectedDrawing} width=\"1em\" height=\"1em\" />\n ) : (\n <SquareDashedIcon {...defaultIconProps} />\n )\n }\n text={selectedLabel ?? \"Select icon\"}\n disabled={readOnly}\n onClick={() => {\n setOpen(true);\n }}\n aria-label={isDefined(selectedLabel) ? `${selectedLabel} currently selected` : \"Select icon\"}\n />\n {isDefined(value) && (\n <Button\n type=\"button\"\n mode=\"ghost\"\n tone=\"critical\"\n icon={<CloseIcon />}\n text=\"Clear\"\n disabled={readOnly}\n onClick={() => {\n onChange(unset());\n }}\n aria-label=\"Clear the selected icon\"\n />\n )}\n {open && (\n <Picker\n id={`${id}-library`}\n library={library}\n iconStyle={style}\n allowed={icons}\n selected={selectedName}\n onSelect={handleSelect}\n onClose={() => {\n setOpen(false);\n }}\n onClickOutside={() => {\n setOpen(false);\n }}\n />\n )}\n </Flex>\n );\n }\n\n return Input;\n}\n","import { isDefined } from \"@repo/lib/utils\";\nimport { createElement } from \"react\";\n\nimport { Drawing } from \"@/components/drawing\";\nimport { resolveIconDrawing } from \"@/lib/nodes\";\nimport type { SanityIcon } from \"@/types\";\n\n/**\n * Creates preview media for a stored icon, so each document shows its own icon instead of a placeholder.\n *\n * @param value - The stored icon.\n * @returns The media component, or undefined when nothing readable was stored.\n * @public\n */\nexport function createIconPreview(value: SanityIcon | undefined) {\n const drawing = resolveIconDrawing(value?.node);\n if (!isDefined(drawing)) return undefined;\n\n return function IconPreview() {\n return createElement(Drawing, { drawing, width: \"1em\", height: \"1em\" });\n };\n}\n","import { Field } from \"@repo/components/field\";\nimport { createSanityIcon } from \"@repo/lib/icons\";\nimport { convertCase, isDefined } from \"@repo/lib/utils\";\nimport { defineField, defineType } from \"sanity\";\n\nimport { createInput } from \"@/components/input\";\nimport { SquareDashedIcon } from \"@/icons/square-dashed\";\nimport { createIconPreview } from \"@/lib/preview\";\nimport type { SanityIconConfig } from \"@/plugin\";\nimport type { SanityIcon } from \"@/types\";\nimport { iconTypeName } from \"@/types\";\n\n/**\n * Creates the icon object type, offering the plugin's icons to fields that don't set their own.\n *\n * @param config - The plugin configuration.\n * @returns The icon type.\n */\nexport function createIconType(config: SanityIconConfig) {\n return defineType({\n name: iconTypeName satisfies SanityIcon[\"_type\"],\n type: \"object\",\n icon: createSanityIcon(SquareDashedIcon),\n description: \"Icon chosen from an icon library.\",\n // Uses a primitive field's flat frame on purpose, instead of Sanity's collapsible object fieldset.\n components: { field: Field, input: createInput(config) },\n validation: (rule) =>\n rule.custom((value: Partial<SanityIcon> | undefined) =>\n !isDefined(value?.name) || isDefined(value.node) ? true : \"Select the icon again to save its drawing.\",\n ),\n preview: {\n select: {\n name: \"name\",\n node: \"node\",\n },\n prepare(selection: { name?: string; node?: string }) {\n const { name, node } = selection;\n\n return {\n title: isDefined(name) ? convertCase(name, \"title\") : \"No icon\",\n media: createIconPreview({ _type: iconTypeName, name, node }),\n };\n },\n },\n fields: [\n defineField({\n name: \"library\" satisfies keyof SanityIcon,\n type: \"string\",\n description: \"Identifier of the library the icon came from.\",\n }),\n defineField({\n name: \"style\" satisfies keyof SanityIcon,\n type: \"string\",\n description: \"Identifier of the library style the icon came from.\",\n }),\n defineField({\n name: \"name\" satisfies keyof SanityIcon,\n type: \"string\",\n description: \"Name of the icon in its library.\",\n }),\n defineField({\n name: \"node\" satisfies keyof SanityIcon,\n type: \"text\",\n description: \"Shapes the icon is drawn from, saved when it's chosen.\",\n }),\n ],\n });\n}\n","import type { SanityIconNames } from \"@driftime/sanity-plugin-icon/names\";\nimport type { BaseSchemaTypeOptions, InitialValueProperty, TypeAliasDefinition } from \"sanity\";\nimport { definePlugin } from \"sanity\";\n\nimport { pluginName } from \"@/config/defaults\";\nimport type { iconLibraryStyles } from \"@/lib/libraries\";\nimport { createIconType } from \"@/schemas/types/icon\";\nimport type { iconTypeName } from \"@/types\";\n\ndeclare module \"@sanity/types\" {\n interface IntrinsicDefinitions {\n /** Definition of a field of type `icon`. */\n icon: SanityIconDefinition;\n }\n}\n\n/** Styles of each supported library, from the plugin's own list. */\ntype IconLibraryStyles = typeof iconLibraryStyles;\n\n/**\n * Identifier of a library the plugin supports.\n *\n * @public\n */\nexport type SanityIconLibrary = keyof IconLibraryStyles;\n\n/**\n * Styles a library offers. The project's own icon folders have one style, `default`.\n *\n * @public\n */\nexport type SanityIconStyle<Library extends string> = Library extends SanityIconLibrary\n ? IconLibraryStyles[Library][number]\n : \"default\";\n\n/**\n * Names of a library's icons, once the build step has listed the installed version's, or any name before then.\n *\n * @public\n */\nexport type SanityIconName<Library extends string> = Library extends keyof SanityIconNames\n ? SanityIconNames[Library]\n : string;\n\n/** Libraries the build step has listed, or any identifier before it has, so the project's own folders can be named. */\ntype ListedLibraryId = [keyof SanityIconNames] extends [never]\n ? string & NonNullable<unknown>\n : Extract<keyof SanityIconNames, string>;\n\n/** Libraries a field can name: the supported ones, plus the project's own folders. */\ntype IconLibraryId = SanityIconLibrary | ListedLibraryId;\n\n/**\n * A choice of library, style, and icons, where the style and icons are checked against the library.\n *\n * @public\n */\nexport type SanityIconSelection = {\n [Library in IconLibraryId]: {\n /** Identifier of the icon library, such as `phosphor`. */\n library: Library;\n /** Identifier of the library style, such as `bold`. Defaults to the library's first style. */\n style?: SanityIconStyle<Library>;\n /** Icons authors can choose from, in the order listed. Defaults to every icon. */\n icons?: SanityIconName<Library>[];\n };\n}[IconLibraryId];\n\n/**\n * Options for an icon field. A field that names a library replaces the plugin's library, style, and icons, and one\n * that doesn't uses the plugin's.\n *\n * @public\n */\nexport type SanityIconOptions = BaseSchemaTypeOptions &\n (SanityIconSelection | { library?: undefined; style?: undefined; icons?: undefined });\n\n/**\n * Icon a field starts with. The Studio saves its drawing from the field's library the first time the field is shown.\n *\n * @public\n */\nexport interface SanityIconInitialValue {\n /** Name of the icon, from any library the build step has listed. */\n name: SanityIconName<ListedLibraryId>;\n}\n\n/**\n * Definition of a field or array member holding an icon, so its options and initial value are type-checked like a\n * built-in type's.\n *\n * @public\n */\nexport interface SanityIconDefinition extends Omit<\n TypeAliasDefinition<typeof iconTypeName, undefined>,\n \"options\" | \"initialValue\"\n> {\n /** Options for the field. */\n options?: SanityIconOptions;\n /** Icon the field starts with, or a function that returns one. */\n initialValue?: InitialValueProperty<unknown, SanityIconInitialValue>;\n}\n\n/**\n * Plugin configuration, naming the library every icon field uses unless it names its own.\n *\n * @public\n */\nexport type SanityIconConfig = SanityIconSelection;\n\nconst plugin = definePlugin<SanityIconConfig>((config) => ({\n name: pluginName,\n schema: {\n types: [createIconType(config)],\n },\n}));\n\n/**\n * Adds an icon field type to Sanity Studio, with a searchable picker for the installed icon libraries that\n * stores the chosen icon's drawing.\n *\n * @param config - The plugin configuration.\n * @returns The plugin.\n * @public\n */\nexport function iconPlugin(config: SanityIconConfig) {\n return plugin(config);\n}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IACNE,aAAa;GACf,CAAC;GACDb,YAAY;IACVU,MAAM;IACNC,MAAM;IACNE,aAAa;GACf,CAAC;EAAC;CAEN,CAAC;AACH;AC2CA,MAAMkD,SAAS5B,cAAgC6B,YAAY;CACzDN,MAAMtB;CACN6B,QAAQ,EACNC,OAAO,CAAC5B,eAAe0B,MAAM,CAAC,EAChC;AACF,EAAE;;;;;;;;;AAUF,SAAgBG,WAAWH,QAA0B;CACnD,OAAOD,OAAOC,MAAM;AACtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-loader.d.ts","names":["LoaderContext","generateRegistryOnce","Promise","generateRegistry","ReturnType","LoaderContext","iconSetsLoader","Promise","default","generateRegistry"],"sources":["../src/build/loader.ts","../src/next-loader.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"next-loader.d.ts","names":["LoaderContext","generateRegistryOnce","Promise","generateRegistry","ReturnType","LoaderContext","iconSetsLoader","Promise","default","generateRegistry"],"sources":["../src/build/loader.ts","../src/next-loader.ts"],"mappings":"AAiBA;;;;;UAAiBA;;EAEf;;;;;;EAMA;;;;;;EAMA,iBAAiB;;;;;;EAMjB,wBAAwB;;;;;;;;;;iBAWXC,qBAAqB,sBAAsB,mBAAgBC;;;;;;;;;;;;;;;wBA+EpDC,iBACpB,sBACA,kBACA,oBACCC,kBAAkBH;;;;;;;;;;;iBCnGNK,eAAe,MAAMD,gBAAaE"}
|
package/dist/next-loader.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { n as logger } from "./sets-kepuObH8.js";
|
|
2
2
|
import { r as isRecord } from "./utils-COPacfAq.js";
|
|
3
|
-
import { t as createRegistryModule } from "./registry-
|
|
4
|
-
import { a as writeIconNames, i as loadIconSet, n as detectLibraries, r as listRegistryDependencies, t as describeReport } from "./sets-
|
|
3
|
+
import { n as getSetsFolder, t as createRegistryModule } from "./registry-B0Dxiwhh.js";
|
|
4
|
+
import { a as writeIconNames, i as loadIconSet, n as detectLibraries, r as listRegistryDependencies, t as describeReport } from "./sets-D5_YGFll.js";
|
|
5
5
|
import { i as listPluginFiles, s as readPluginBuild } from "./adapters-Bx_MyEX_.js";
|
|
6
6
|
import path from "node:path";
|
|
7
|
-
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
7
|
+
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
8
|
+
import { randomUUID } from "node:crypto";
|
|
8
9
|
/**
|
|
9
10
|
* Converts every installed library, writes each set to a file the bundler can split into its own chunk, and returns
|
|
10
11
|
* the registry that replaces the placeholder.
|
|
@@ -14,14 +15,14 @@ import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
|
14
15
|
* @returns The registry's code, and the files and folders it was generated from.
|
|
15
16
|
*/
|
|
16
17
|
async function generateRegistryOnce(resourcePath, options) {
|
|
17
|
-
let root = process.cwd(), custom = isRecord(options) && isRecord(options.custom) ? options.custom : {}, folders = Object.fromEntries(Object.entries(custom).flatMap(([name, folder]) => typeof folder == "string" ? [[name, folder]] : [])), cacheDir = path.join(root, "node_modules", ".cache"), setsDir =
|
|
18
|
+
let root = process.cwd(), custom = isRecord(options) && isRecord(options.custom) ? options.custom : {}, folders = Object.fromEntries(Object.entries(custom).flatMap(([name, folder]) => typeof folder == "string" ? [[name, folder]] : [])), cacheDir = path.join(root, "node_modules", ".cache"), setsDir = getSetsFolder(root);
|
|
18
19
|
await mkdir(setsDir, { recursive: !0 });
|
|
19
20
|
let libraries = await detectLibraries(root, folders), files = /* @__PURE__ */ new Map(), names = /* @__PURE__ */ new Map(), converted = await Promise.all(libraries.flatMap((library) => library.styles.map(async ({ style }) => {
|
|
20
21
|
let { adapter } = library, { set, report } = await loadIconSet(library, style, {
|
|
21
22
|
root,
|
|
22
23
|
cacheDir
|
|
23
|
-
}), file = path.join(setsDir, `${adapter.library}-${style}.json`)
|
|
24
|
-
return await writeFile(
|
|
24
|
+
}), file = path.join(setsDir, `${adapter.library}-${style}.json`), temporary = `${file}.${randomUUID()}.tmp`;
|
|
25
|
+
return await writeFile(temporary, JSON.stringify(set)), await rename(temporary, file), logger.info(describeReport(adapter.label, style, report)), {
|
|
25
26
|
library: adapter.library,
|
|
26
27
|
style,
|
|
27
28
|
set,
|
package/dist/next-loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-loader.js","names":["mkdir","readFile","writeFile","path","isRecord","writeIconNames","listPluginFiles","createRegistryModule","describeReport","detectLibraries","listRegistryDependencies","loadIconSet","logger","LoaderContext","resourcePath","getOptions","addDependency","file","addContextDependency","folder","generateRegistryOnce","options","root","process","cwd","custom","folders","Object","fromEntries","entries","flatMap","name","cacheDir","join","setsDir","recursive","libraries","files","Map","names","Set","converted","Promise","all","library","styles","map","style","adapter","set","report","JSON","stringify","info","label","libraryNames","get","icon","icons","add","filter","size","code","key","relative","dirname","replaceAll","startsWith","dependencies","readManifest","generateRegistry","attempts","ReturnType","before","result","after","isRecord","LoaderContext","generateRegistry","readPluginBuild","logger","LoaderModule","isLoaderModule","value","iconSetsLoader","this","fresh","import","meta","url","Error","format","code","files","folders","resourcePath","getOptions","file","addDependency","folder","addContextDependency","\"custom\"","\"generateRegistry\""],"sources":["../src/build/loader.ts","../src/next-loader.ts"],"sourcesContent":["import { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport { isRecord } from \"@repo/lib/utils\";\n\nimport { writeIconNames } from \"@/build/names\";\nimport { listPluginFiles } from \"@/build/packages\";\nimport { createRegistryModule } from \"@/build/registry\";\nimport { describeReport, detectLibraries, listRegistryDependencies, loadIconSet } from \"@/build/sets\";\nimport { logger } from \"@/config/defaults\";\n\n/**\n * The parts of a webpack or Turbopack loader's context the build step uses.\n *\n * @public\n */\nexport interface LoaderContext {\n /** Path of the module being loaded. */\n resourcePath: string;\n /**\n * Reads the loader's options.\n *\n * @returns The options.\n */\n getOptions: () => unknown;\n /**\n * Tells the bundler to run the loader again when a file changes.\n *\n * @param file - The file.\n */\n addDependency?: (file: string) => void;\n /**\n * Tells the bundler to run the loader again when anything in a folder changes.\n *\n * @param folder - The folder.\n */\n addContextDependency?: (folder: string) => void;\n}\n\n/**\n * Converts every installed library, writes each set to a file the bundler can split into its own chunk, and returns\n * the registry that replaces the placeholder.\n *\n * @param resourcePath - Path of the placeholder being replaced.\n * @param options - The loader's options.\n * @returns The registry's code, and the files and folders it was generated from.\n */\nasync function generateRegistryOnce(resourcePath: string, options: unknown) {\n const root = process.cwd();\n const custom = isRecord(options) && isRecord(options[\"custom\"]) ? options[\"custom\"] : {};\n const folders = Object.fromEntries(\n Object.entries(custom).flatMap(([name, folder]) => (typeof folder === \"string\" ? [[name, folder]] : [])),\n );\n\n const cacheDir = path.join(root, \"node_modules\", \".cache\");\n const setsDir = path.join(cacheDir, \"driftime-icon\", \"sets\");\n await mkdir(setsDir, { recursive: true });\n\n const libraries = await detectLibraries(root, folders);\n const files = new Map<string, string>();\n const names = new Map<string, Set<string>>();\n\n const converted = await Promise.all(\n libraries.flatMap((library) =>\n library.styles.map(async ({ style }) => {\n const { adapter } = library;\n const { set, report } = await loadIconSet(library, style, { root, cacheDir });\n const file = path.join(setsDir, `${adapter.library}-${style}.json`);\n\n await writeFile(file, JSON.stringify(set));\n logger.info(describeReport(adapter.label, style, report));\n\n return { library: adapter.library, style, set, file };\n }),\n ),\n );\n\n for (const { library, style, set, file } of converted) {\n const libraryNames = names.get(library) ?? new Set<string>();\n\n for (const icon of set.icons) libraryNames.add(icon.name);\n names.set(library, libraryNames);\n files.set(`${library}/${style}`, file);\n }\n\n await writeIconNames(new Map([...names].filter(([, libraryNames]) => libraryNames.size > 0)));\n\n const code = createRegistryModule(libraries, (key) => {\n const file = files.get(key) ?? \"\";\n const relative = path.relative(path.dirname(resourcePath), file).replaceAll(\"\\\\\", \"/\");\n\n return relative.startsWith(\".\") ? relative : `./${relative}`;\n });\n\n const dependencies = listRegistryDependencies(root, libraries);\n\n // The plugin's own files are included, so updating it runs the loader again even when `package.json` doesn't change.\n return { code, files: [...dependencies.files, ...(await listPluginFiles())], folders: dependencies.folders };\n}\n\n/**\n * Reads the project's `package.json` as text.\n *\n * @returns The contents, or an empty string when there's no file.\n */\nasync function readManifest() {\n try {\n return await readFile(path.join(process.cwd(), \"package.json\"), \"utf8\");\n } catch {\n return \"\";\n }\n}\n\n/**\n * Generates the registry, running again when the project's `package.json` changes while it runs, so a package\n * installed during a run isn't missed.\n *\n * @param resourcePath - Path of the placeholder being replaced.\n * @param options - The loader's options.\n * @param attempts - Runs allowed, including this one.\n * @returns The registry's code, and the files and folders it was generated from.\n * @public\n */\nexport async function generateRegistry(\n resourcePath: string,\n options: unknown,\n attempts = 3,\n): ReturnType<typeof generateRegistryOnce> {\n const before = await readManifest();\n const result = await generateRegistryOnce(resourcePath, options);\n const after = await readManifest();\n\n return before === after || attempts <= 1 ? result : generateRegistry(resourcePath, options, attempts - 1);\n}\n","import { isRecord } from \"@repo/lib/utils\";\n\nimport type { LoaderContext, generateRegistry } from \"@/build/loader\";\nimport { readPluginBuild } from \"@/build/packages\";\nimport { logger } from \"@/config/defaults\";\n\n/** This module as the loader imports it afresh on every run. */\ninterface LoaderModule {\n /** Generates the registry. */\n generateRegistry: typeof generateRegistry;\n}\n\n/**\n * Checks whether an imported module is a fresh copy of this one.\n *\n * @param value - The imported module.\n * @returns True if the module is this one.\n */\nfunction isLoaderModule(value: unknown): value is LoaderModule {\n return isRecord(value) && typeof value[\"generateRegistry\"] === \"function\";\n}\n\n/**\n * Webpack and Turbopack loader that replaces the placeholder registry with the project's converted icon sets. The\n * bundler keeps this module loaded, so it imports a fresh copy of itself, versioned by the plugin's code, and runs that\n * copy's build step, so updating the plugin takes effect without restarting the bundler.\n *\n * @param this - The loader context.\n * @returns The registry's code.\n * @throws When the plugin's build step can't be loaded.\n * @public\n */\nasync function iconSetsLoader(this: LoaderContext) {\n const fresh: unknown = await import(`${import.meta.url}?version=${await readPluginBuild()}`);\n if (!isLoaderModule(fresh)) throw new Error(logger.format(\"The build step couldn't be loaded.\"));\n\n const { code, files, folders } = await fresh.generateRegistry(this.resourcePath, this.getOptions());\n\n for (const file of files) this.addDependency?.(file);\n for (const folder of folders) this.addContextDependency?.(folder);\n\n return code;\n}\n\nexport default iconSetsLoader;\nexport { generateRegistry } from \"@/build/loader\";\n"],"mappings":";;;;;;;;;;;;;;;AA+CA,eAAeoB,qBAAqBN,cAAsBO,SAAkB;CAC1E,IAAMC,OAAOC,QAAQC,IAAI,GACnBC,SAASrB,SAASiB,OAAO,KAAKjB,SAASiB,QAAQgF,MAAS,IAAIhF,QAAQgF,SAAY,CAAC,GACjF3E,UAAUC,OAAOC,YACrBD,OAAOE,QAAQJ,MAAM,CAAC,CAACK,SAAS,CAACC,MAAMZ,YAAa,OAAOA,UAAW,WAAW,CAAC,CAACY,MAAMZ,MAAM,CAAC,IAAI,CAAA,CAAG,CACzG,GAEMa,WAAW7B,KAAK8B,KAAKX,MAAM,gBAAgB,QAAQ,GACnDY,UAAU/B,KAAK8B,KAAKD,UAAU,iBAAiB,MAAM;CAC3D,MAAMhC,MAAMkC,SAAS,EAAEC,WAAW,GAAK,CAAC;CAExC,IAAMC,YAAY,MAAM3B,gBAAgBa,MAAMI,OAAO,GAC/CW,wBAAQ,IAAIC,IAAoB,GAChCC,wBAAQ,IAAID,IAAyB,GAErCG,YAAY,MAAMC,QAAQC,IAC9BP,UAAUN,SAASc,YACjBA,QAAQC,OAAOC,IAAI,OAAO,EAAEC,YAAY;EACtC,IAAM,EAAEC,YAAYJ,SACd,EAAEK,KAAKC,WAAW,MAAMvC,YAAYiC,SAASG,OAAO;GAAEzB;GAAMU;EAAS,CAAC,GACtEf,OAAOd,KAAK8B,KAAKC,SAAS,GAAGc,QAAQJ,QAAO,GAAIG,MAAK,MAAO;EAKlE,OAHA,MAAM7C,UAAUe,MAAMkC,KAAKC,UAAUH,GAAG,CAAC,GACzCrC,OAAOyC,KAAK7C,eAAewC,QAAQM,OAAOP,OAAOG,MAAM,CAAC,GAEjD;GA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AAOoD,WAAWE,MAFEN,aAAa,KAENE,YAAY,IAAIG,SAASJ,iBAAiBxD,cAAcO,SAASkD,WAAW,CAAC;AAC1G;;;;;;;ACnHA,SAASW,eAAeC,OAAuC;CAC7D,OAAOP,SAASO,KAAK,KAAK,OAAOA,MAAMmB,oBAAwB;AACjE;;;;;;;;;;;AAYA,eAAelB,iBAAoC;CACjD,IAAME,QAAiB,MAAM,OAAO,GAAGC,YAAYE,IAAG,WAAY,MAAMV,gBAAgB;CACxF,IAAI,CAACG,eAAeI,KAAK,GAAG,MAAUI,MAAMV,OAAOW,OAAO,oCAAoC,CAAC;CAE/F,IAAM,EAAEC,MAAMC,OAAOC,YAAY,MAAMR,MAAMR,iBAAiB,KAAKiB,cAAc,KAAKC,WAAW,CAAC;CAElG,KAAK,IAAMC,QAAQJ,OAAO,KAAKK,gBAAgBD,IAAI;CACnD,KAAK,IAAME,UAAUL,SAAS,KAAKM,uBAAuBD,MAAM;CAEhE,OAAOP;AACT"}
|
|
1
|
+
{"version":3,"file":"next-loader.js","names":["randomUUID","mkdir","readFile","rename","writeFile","path","isRecord","writeIconNames","listPluginFiles","createRegistryModule","getSetsFolder","describeReport","detectLibraries","listRegistryDependencies","loadIconSet","logger","LoaderContext","resourcePath","getOptions","addDependency","file","addContextDependency","folder","generateRegistryOnce","options","root","process","cwd","custom","folders","Object","fromEntries","entries","flatMap","name","cacheDir","join","setsDir","recursive","libraries","files","Map","names","Set","converted","Promise","all","library","styles","map","style","adapter","set","report","temporary","JSON","stringify","info","label","libraryNames","get","icon","icons","add","filter","size","code","key","relative","dirname","replaceAll","startsWith","dependencies","readManifest","generateRegistry","attempts","ReturnType","before","result","after","isRecord","LoaderContext","generateRegistry","readPluginBuild","logger","LoaderModule","isLoaderModule","value","iconSetsLoader","this","fresh","import","meta","url","Error","format","code","files","folders","resourcePath","getOptions","file","addDependency","folder","addContextDependency","\"custom\"","\"generateRegistry\""],"sources":["../src/build/loader.ts","../src/next-loader.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { mkdir, readFile, rename, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport { isRecord } from \"@repo/lib/utils\";\n\nimport { writeIconNames } from \"@/build/names\";\nimport { listPluginFiles } from \"@/build/packages\";\nimport { createRegistryModule, getSetsFolder } from \"@/build/registry\";\nimport { describeReport, detectLibraries, listRegistryDependencies, loadIconSet } from \"@/build/sets\";\nimport { logger } from \"@/config/defaults\";\n\n/**\n * The parts of a webpack or Turbopack loader's context the build step uses.\n *\n * @public\n */\nexport interface LoaderContext {\n /** Path of the module being loaded. */\n resourcePath: string;\n /**\n * Reads the loader's options.\n *\n * @returns The options.\n */\n getOptions: () => unknown;\n /**\n * Tells the bundler to run the loader again when a file changes.\n *\n * @param file - The file.\n */\n addDependency?: (file: string) => void;\n /**\n * Tells the bundler to run the loader again when anything in a folder changes.\n *\n * @param folder - The folder.\n */\n addContextDependency?: (folder: string) => void;\n}\n\n/**\n * Converts every installed library, writes each set to a file the bundler can split into its own chunk, and returns\n * the registry that replaces the placeholder.\n *\n * @param resourcePath - Path of the placeholder being replaced.\n * @param options - The loader's options.\n * @returns The registry's code, and the files and folders it was generated from.\n */\nasync function generateRegistryOnce(resourcePath: string, options: unknown) {\n const root = process.cwd();\n const custom = isRecord(options) && isRecord(options[\"custom\"]) ? options[\"custom\"] : {};\n const folders = Object.fromEntries(\n Object.entries(custom).flatMap(([name, folder]) => (typeof folder === \"string\" ? [[name, folder]] : [])),\n );\n\n const cacheDir = path.join(root, \"node_modules\", \".cache\");\n const setsDir = getSetsFolder(root);\n await mkdir(setsDir, { recursive: true });\n\n const libraries = await detectLibraries(root, folders);\n const files = new Map<string, string>();\n const names = new Map<string, Set<string>>();\n\n const converted = await Promise.all(\n libraries.flatMap((library) =>\n library.styles.map(async ({ style }) => {\n const { adapter } = library;\n const { set, report } = await loadIconSet(library, style, { root, cacheDir });\n const file = path.join(setsDir, `${adapter.library}-${style}.json`);\n const temporary = `${file}.${randomUUID()}.tmp`;\n\n // The browser and server builds convert at once, even in one process, so each set is swapped in whole.\n await writeFile(temporary, JSON.stringify(set));\n await rename(temporary, file);\n logger.info(describeReport(adapter.label, style, report));\n\n return { library: adapter.library, style, set, file };\n }),\n ),\n );\n\n for (const { library, style, set, file } of converted) {\n const libraryNames = names.get(library) ?? new Set<string>();\n\n for (const icon of set.icons) libraryNames.add(icon.name);\n names.set(library, libraryNames);\n files.set(`${library}/${style}`, file);\n }\n\n await writeIconNames(new Map([...names].filter(([, libraryNames]) => libraryNames.size > 0)));\n\n const code = createRegistryModule(libraries, (key) => {\n const file = files.get(key) ?? \"\";\n const relative = path.relative(path.dirname(resourcePath), file).replaceAll(\"\\\\\", \"/\");\n\n return relative.startsWith(\".\") ? relative : `./${relative}`;\n });\n\n const dependencies = listRegistryDependencies(root, libraries);\n\n // The plugin's own files are included, so updating it runs the loader again even when `package.json` doesn't change.\n return { code, files: [...dependencies.files, ...(await listPluginFiles())], folders: dependencies.folders };\n}\n\n/**\n * Reads the project's `package.json` as text.\n *\n * @returns The contents, or an empty string when there's no file.\n */\nasync function readManifest() {\n try {\n return await readFile(path.join(process.cwd(), \"package.json\"), \"utf8\");\n } catch {\n return \"\";\n }\n}\n\n/**\n * Generates the registry, running again when the project's `package.json` changes while it runs, so a package\n * installed during a run isn't missed.\n *\n * @param resourcePath - Path of the placeholder being replaced.\n * @param options - The loader's options.\n * @param attempts - Runs allowed, including this one.\n * @returns The registry's code, and the files and folders it was generated from.\n * @public\n */\nexport async function generateRegistry(\n resourcePath: string,\n options: unknown,\n attempts = 3,\n): ReturnType<typeof generateRegistryOnce> {\n const before = await readManifest();\n const result = await generateRegistryOnce(resourcePath, options);\n const after = await readManifest();\n\n return before === after || attempts <= 1 ? result : generateRegistry(resourcePath, options, attempts - 1);\n}\n","import { isRecord } from \"@repo/lib/utils\";\n\nimport type { LoaderContext, generateRegistry } from \"@/build/loader\";\nimport { readPluginBuild } from \"@/build/packages\";\nimport { logger } from \"@/config/defaults\";\n\n/** This module as the loader imports it afresh on every run. */\ninterface LoaderModule {\n /** Generates the registry. */\n generateRegistry: typeof generateRegistry;\n}\n\n/**\n * Checks whether an imported module is a fresh copy of this one.\n *\n * @param value - The imported module.\n * @returns True if the module is this one.\n */\nfunction isLoaderModule(value: unknown): value is LoaderModule {\n return isRecord(value) && typeof value[\"generateRegistry\"] === \"function\";\n}\n\n/**\n * Webpack and Turbopack loader that replaces the placeholder registry with the project's converted icon sets. The\n * bundler keeps this module loaded, so it imports a fresh copy of itself, versioned by the plugin's code, and runs that\n * copy's build step, so updating the plugin takes effect without restarting the bundler.\n *\n * @param this - The loader context.\n * @returns The registry's code.\n * @throws When the plugin's build step can't be loaded.\n * @public\n */\nasync function iconSetsLoader(this: LoaderContext) {\n const fresh: unknown = await import(`${import.meta.url}?version=${await readPluginBuild()}`);\n if (!isLoaderModule(fresh)) throw new Error(logger.format(\"The build step couldn't be loaded.\"));\n\n const { code, files, folders } = await fresh.generateRegistry(this.resourcePath, this.getOptions());\n\n for (const file of files) this.addDependency?.(file);\n for (const folder of folders) this.addContextDependency?.(folder);\n\n return code;\n}\n\nexport default iconSetsLoader;\nexport { generateRegistry } from \"@/build/loader\";\n"],"mappings":";;;;;;;;;;;;;;;;AAgDA,eAAeuB,qBAAqBN,cAAsBO,SAAkB;CAC1E,IAAMC,OAAOC,QAAQC,IAAI,GACnBC,SAAStB,SAASkB,OAAO,KAAKlB,SAASkB,QAAQiF,MAAS,IAAIjF,QAAQiF,SAAY,CAAC,GACjF5E,UAAUC,OAAOC,YACrBD,OAAOE,QAAQJ,MAAM,CAAC,CAACK,SAAS,CAACC,MAAMZ,YAAa,OAAOA,UAAW,WAAW,CAAC,CAACY,MAAMZ,MAAM,CAAC,IAAI,CAAA,CAAG,CACzG,GAEMa,WAAW9B,KAAK+B,KAAKX,MAAM,gBAAgB,QAAQ,GACnDY,UAAU3B,cAAce,IAAI;CAClC,MAAMxB,MAAMoC,SAAS,EAAEC,WAAW,GAAK,CAA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|
package/dist/next.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.d.ts","names":["SanityIconBuildOptions","SanityIconWebpackConfig","SanityIconNextConfig","Record","SanityIconWebpackCustomizer","withIcons","Config"],"sources":["../src/build/next.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"next.d.ts","names":["SanityIconBuildOptions","SanityIconWebpackConfig","SanityIconNextConfig","Record","SanityIconWebpackCustomizer","withIcons","Config"],"sources":["../src/build/next.ts"],"mappings":";;;;;;UAoBiBC;;EAEf;IAAW;;;;;;;;UAQIC;;EAEf;IAAc,QAAQC;;;EAEtB,UAAUC;;;;;;;;KASAA,+BAA+B,QAAQH,yBAAyB,mBAAmBA;;;;;;;;;wBAa/EI,UAAU,UAASL,0BAOJ,eAAeE,sBAAoB,QAAUI,WAASA"}
|
package/dist/next.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { n as
|
|
1
|
+
import { i as registryModulePath, n as getSetsFolder, r as isRegistryModule } from "./registry-B0Dxiwhh.js";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { mkdirSync } from "node:fs";
|
|
3
4
|
import { fileURLToPath } from "node:url";
|
|
4
5
|
/** Path of the loader, published next to this file. */
|
|
5
6
|
const loaderPath = fileURLToPath(new URL("next-loader.js", import.meta.url));
|
|
@@ -16,7 +17,7 @@ function withIcons(options = {}) {
|
|
|
16
17
|
loader: loaderPath,
|
|
17
18
|
options: { custom: options.custom ?? {} }
|
|
18
19
|
}, placeholder = path.basename(path.dirname(path.dirname(registryModulePath)));
|
|
19
|
-
return function extendConfig(config) {
|
|
20
|
+
return mkdirSync(getSetsFolder(process.cwd()), { recursive: !0 }), function extendConfig(config) {
|
|
20
21
|
let { turbopack, webpack } = config;
|
|
21
22
|
return {
|
|
22
23
|
...config,
|
package/dist/next.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.js","names":["path","fileURLToPath","isRegistryModule","registryModulePath","SanityIconBuildOptions","WebpackRule","test","resource","use","loader","options","custom","Record","SanityIconWebpackConfig","module","rules","SanityIconNextConfig","turbopack","webpack","SanityIconWebpackCustomizer","config","context","loaderPath","URL","import","meta","url","withIcons","placeholder","basename","dirname","extendConfig","Config","loaders","as","webpackConfig","resolved","rule"],"sources":["../src/build/next.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { isRegistryModule, registryModulePath } from \"@/build/registry\";\nimport type { SanityIconBuildOptions } from \"@/build/vite\";\n\n/** A webpack rule, limited to what the build step adds. */\ninterface WebpackRule {\n /** Matches the placeholder registry. */\n test: (resource: string) => boolean;\n /** The loader that replaces it, with the build step's options. */\n use: { loader: string; options: { custom: Record<string, string> } }[];\n}\n\n/**\n * The parts of a webpack configuration the build step extends.\n *\n * @public\n */\nexport interface SanityIconWebpackConfig {\n /** Module settings, whose rules the build step adds to. */\n module?: { rules?: unknown[] };\n}\n\n/**\n * The parts of a Next.js configuration the build step extends, so the package doesn't depend on Next.js's own types.\n *\n * @public\n */\nexport interface SanityIconNextConfig {\n /** Turbopack settings, whose rules the build step adds to. */\n turbopack?: { rules?: Record<string, unknown> };\n /** Customises webpack, for projects that build with it instead of Turbopack. */\n webpack?: SanityIconWebpackCustomizer | null;\n}\n\n/**\n * Customises webpack, as Next.js's `webpack` option does. The context is typed `never` because the build step only\n * passes Next.js's own context through, so any context type a project's function declares is accepted.\n *\n * @public\n */\nexport type SanityIconWebpackCustomizer = (config: SanityIconWebpackConfig, context: never) => SanityIconWebpackConfig;\n\n/** Path of the loader, published next to this file. */\nconst loaderPath = fileURLToPath(new URL(\"next-loader.js\", import.meta.url));\n\n/**\n * Adds the icon build step to a Next.js configuration, for Studios embedded in a Next.js app. It works with both\n * Turbopack and webpack.\n *\n * @param options - Options for the build step.\n * @returns A function that extends the Next.js configuration.\n * @public\n */\nexport function withIcons(options: SanityIconBuildOptions = {}) {\n const loader = { loader: loaderPath, options: { custom: options.custom ?? {} } };\n const placeholder = path.basename(path.dirname(path.dirname(registryModulePath)));\n\n return function extendConfig<Config extends SanityIconNextConfig>(config: Config): Config {\n const { turbopack, webpack } = config;\n\n return {\n ...config,\n turbopack: {\n ...turbopack,\n rules: { ...turbopack?.rules, [`**/${placeholder}/dist/sets.js`]: { loaders: [loader], as: \"*.js\" } },\n },\n webpack(webpackConfig: SanityIconWebpackConfig, context: never) {\n const resolved = webpack?.(webpackConfig, context) ?? webpackConfig;\n const rule: WebpackRule = { test: isRegistryModule, use: [loader] };\n\n return { ...resolved, module: { ...resolved.module, rules: [...(resolved.module?.rules ?? []), rule] } };\n },\n };\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"next.js","names":["mkdirSync","path","fileURLToPath","getSetsFolder","isRegistryModule","registryModulePath","SanityIconBuildOptions","WebpackRule","test","resource","use","loader","options","custom","Record","SanityIconWebpackConfig","module","rules","SanityIconNextConfig","turbopack","webpack","SanityIconWebpackCustomizer","config","context","loaderPath","URL","import","meta","url","withIcons","placeholder","basename","dirname","process","cwd","recursive","extendConfig","Config","loaders","as","webpackConfig","resolved","rule"],"sources":["../src/build/next.ts"],"sourcesContent":["import { mkdirSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { getSetsFolder, isRegistryModule, registryModulePath } from \"@/build/registry\";\nimport type { SanityIconBuildOptions } from \"@/build/vite\";\n\n/** A webpack rule, limited to what the build step adds. */\ninterface WebpackRule {\n /** Matches the placeholder registry. */\n test: (resource: string) => boolean;\n /** The loader that replaces it, with the build step's options. */\n use: { loader: string; options: { custom: Record<string, string> } }[];\n}\n\n/**\n * The parts of a webpack configuration the build step extends.\n *\n * @public\n */\nexport interface SanityIconWebpackConfig {\n /** Module settings, whose rules the build step adds to. */\n module?: { rules?: unknown[] };\n}\n\n/**\n * The parts of a Next.js configuration the build step extends, so the package doesn't depend on Next.js's own types.\n *\n * @public\n */\nexport interface SanityIconNextConfig {\n /** Turbopack settings, whose rules the build step adds to. */\n turbopack?: { rules?: Record<string, unknown> };\n /** Customises webpack, for projects that build with it instead of Turbopack. */\n webpack?: SanityIconWebpackCustomizer | null;\n}\n\n/**\n * Customises webpack, as Next.js's `webpack` option does. The context is typed `never` because the build step only\n * passes Next.js's own context through, so any context type a project's function declares is accepted.\n *\n * @public\n */\nexport type SanityIconWebpackCustomizer = (config: SanityIconWebpackConfig, context: never) => SanityIconWebpackConfig;\n\n/** Path of the loader, published next to this file. */\nconst loaderPath = fileURLToPath(new URL(\"next-loader.js\", import.meta.url));\n\n/**\n * Adds the icon build step to a Next.js configuration, for Studios embedded in a Next.js app. It works with both\n * Turbopack and webpack.\n *\n * @param options - Options for the build step.\n * @returns A function that extends the Next.js configuration.\n * @public\n */\nexport function withIcons(options: SanityIconBuildOptions = {}) {\n const loader = { loader: loaderPath, options: { custom: options.custom ?? {} } };\n const placeholder = path.basename(path.dirname(path.dirname(registryModulePath)));\n\n // Turbopack never finds files in a folder that was missing when the build started, so it's made before then.\n mkdirSync(getSetsFolder(process.cwd()), { recursive: true });\n\n return function extendConfig<Config extends SanityIconNextConfig>(config: Config): Config {\n const { turbopack, webpack } = config;\n\n return {\n ...config,\n turbopack: {\n ...turbopack,\n rules: { ...turbopack?.rules, [`**/${placeholder}/dist/sets.js`]: { loaders: [loader], as: \"*.js\" } },\n },\n webpack(webpackConfig: SanityIconWebpackConfig, context: never) {\n const resolved = webpack?.(webpackConfig, context) ?? webpackConfig;\n const rule: WebpackRule = { test: isRegistryModule, use: [loader] };\n\n return { ...resolved, module: { ...resolved.module, rules: [...(resolved.module?.rules ?? []), rule] } };\n },\n };\n };\n}\n"],"mappings":";;;;;AA8CA,MAAMwB,aAAatB,cAAc,IAAIuB,IAAI,kBAAkBC,YAAYE,GAAG,CAAC;;;;;;;;;AAU3E,SAAgBC,UAAUjB,UAAkC,CAAC,GAAG;CAC9D,IAAMD,SAAS;EAAEA,QAAQa;EAAYZ,SAAS,EAAEC,QAAQD,QAAQC,UAAU,CAAC,EAAE;CAAE,GACzEiB,cAAc7B,KAAK8B,SAAS9B,KAAK+B,QAAQ/B,KAAK+B,QAAQ3B,kBAAkB,CAAC,CAAC;CAKhF,OAFAL,UAAUG,cAAc8B,QAAQC,IAAI,CAAC,GAAG,EAAEC,WAAW,GAAK,CAAC,GAEpD,SAASC,aAAkDd,QAAwB;EACxF,IAAM,EAAEH,WAAWC,YAAYE;EAE/B,OAAO;GACL,GAAGA;GACHH,WAAW;IACT,GAAGA;IACHF,OAAO;KAAE,GAAGE,WAAWF;MAAQ,MAAMa,YAAW,iBAAkB;MAAEQ,SAAS,CAAC3B,MAAM;MAAG4B,IAAI;KAAO;IAAE;GACtG;GACAnB,QAAQoB,eAAwCjB,SAAgB;IAC9D,IAAMkB,WAAWrB,UAAUoB,eAAejB,OAAO,KAAKiB,eAChDE,OAAoB;KAAElC,MAAMJ;KAAkBM,KAAK,CAACC,MAAM;IAAE;IAElE,OAAO;KAAE,GAAG8B;KAAUzB,QAAQ;MAAE,GAAGyB,SAASzB;MAAQC,OAAO,CAAC,GAAIwB,SAASzB,QAAQC,SAAS,CAAA,GAAKyB,IAAI;KAAE;IAAE;GACzG;EACF;CACF;AACF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { n as isDefined } from "./utils-COPacfAq.js";
|
|
2
2
|
import { t as getIconSetKey } from "./registry-BEEpqK3z.js";
|
|
3
|
+
import path from "node:path";
|
|
3
4
|
import { realpathSync } from "node:fs";
|
|
4
5
|
import { fileURLToPath } from "node:url";
|
|
5
6
|
/**
|
|
@@ -31,6 +32,15 @@ function isRegistryModule(id) {
|
|
|
31
32
|
return isDefined(file) && resolveRealPath(file) === registryModulePath;
|
|
32
33
|
}
|
|
33
34
|
/**
|
|
35
|
+
* Works out the folder the Next.js build step writes converted sets to, inside the project's `node_modules`.
|
|
36
|
+
*
|
|
37
|
+
* @param root - The project's folder.
|
|
38
|
+
* @returns The folder's path.
|
|
39
|
+
*/
|
|
40
|
+
function getSetsFolder(root) {
|
|
41
|
+
return path.join(root, "node_modules", ".cache", "driftime-icon", "sets");
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
34
44
|
* Writes the module that replaces the placeholder registry, with a loader for each installed library style, so each
|
|
35
45
|
* set is only downloaded when a picker for it opens.
|
|
36
46
|
*
|
|
@@ -53,6 +63,6 @@ function createRegistryModule(libraries, importFor) {
|
|
|
53
63
|
}]));
|
|
54
64
|
return [`const sets = {\n ${loaders.join(",\n ")}\n};`, `export const iconRegistry = { ready: true, sets, libraries: ${JSON.stringify(info)} };`].join("\n");
|
|
55
65
|
}
|
|
56
|
-
export {
|
|
66
|
+
export { registryModulePath as i, getSetsFolder as n, isRegistryModule as r, createRegistryModule as t };
|
|
57
67
|
|
|
58
|
-
//# sourceMappingURL=registry-
|
|
68
|
+
//# sourceMappingURL=registry-B0Dxiwhh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-B0Dxiwhh.js","names":["realpathSync","path","fileURLToPath","isDefined","DetectedLibrary","getIconSetKey","IconLibraryInfo","resolveRealPath","file","registryModulePath","URL","import","meta","url","isRegistryModule","id","split","getSetsFolder","root","join","createRegistryModule","libraries","importFor","key","loaders","flatMap","adapter","styles","map","style","library","JSON","stringify","info","Record","Object","fromEntries","listed","sitePackage","label","packageName","packageExample","packagePrefix","installed"],"sources":["../src/build/registry.ts"],"sourcesContent":["import { realpathSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { isDefined } from \"@repo/lib/utils\";\n\nimport type { DetectedLibrary } from \"@/build/sets\";\nimport { getIconSetKey } from \"@/lib/registry\";\nimport type { IconLibraryInfo } from \"@/lib/sets\";\n\n/**\n * Resolves symbolic links in a path, so a package linked into `node_modules` matches its real location.\n *\n * @param file - The path.\n * @returns The real path, or the path unchanged when it doesn't exist.\n */\nfunction resolveRealPath(file: string) {\n try {\n return realpathSync(file);\n } catch {\n return file;\n }\n}\n\n/**\n * Path of the placeholder registry module the Studio imports, which the build step replaces. The build step's own\n * code is published next to it, so the path is found from this file's location.\n */\nexport const registryModulePath = resolveRealPath(fileURLToPath(new URL(\"sets.js\", import.meta.url)));\n\n/**\n * Checks whether a module the bundler is loading is the placeholder registry.\n *\n * @param id - The module's path, possibly followed by a query.\n * @returns Whether it's the placeholder.\n */\nexport function isRegistryModule(id: string) {\n const [file] = id.split(\"?\");\n\n return isDefined(file) && resolveRealPath(file) === registryModulePath;\n}\n\n/**\n * Works out the folder the Next.js build step writes converted sets to, inside the project's `node_modules`.\n *\n * @param root - The project's folder.\n * @returns The folder's path.\n */\nexport function getSetsFolder(root: string) {\n return path.join(root, \"node_modules\", \".cache\", \"driftime-icon\", \"sets\");\n}\n\n/**\n * Writes the module that replaces the placeholder registry, with a loader for each installed library style, so each\n * set is only downloaded when a picker for it opens.\n *\n * @param libraries - Every library the build step knows.\n * @param importFor - The specifier the bundler imports a set from, given its key.\n * @returns The module's code.\n */\nexport function createRegistryModule(libraries: DetectedLibrary[], importFor: (key: string) => string) {\n const loaders = libraries.flatMap(({ adapter, styles }) =>\n styles.map(({ style }) => {\n const key = getIconSetKey(adapter.library, style);\n\n return `${JSON.stringify(key)}: () => import(${JSON.stringify(importFor(key))})`;\n }),\n );\n\n const info: Record<string, IconLibraryInfo> = Object.fromEntries(\n libraries.map(({ adapter, styles, listed, sitePackage }) => [\n adapter.library,\n {\n label: adapter.label,\n packageName: adapter.packageName ?? adapter.packageExample ?? adapter.library,\n ...(isDefined(adapter.packagePrefix) && { packagePrefix: adapter.packagePrefix }),\n styles: isDefined(styles) ? styles.map(({ style }) => style) : adapter.styles,\n listed,\n installed: isDefined(styles),\n ...(isDefined(sitePackage) && { sitePackage }),\n },\n ]),\n );\n\n return [\n `const sets = {\\n ${loaders.join(\",\\n \")}\\n};`,\n `export const iconRegistry = { ready: true, sets, libraries: ${JSON.stringify(info)} };`,\n ].join(\"\\n\");\n}\n"],"mappings":";;;;;;;;;;;AA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,OAC1C,+DAA+DY,KAAKC,UAAUC,IAAI,EAAC,IAAK,CACzF,CAACd,KAAK,IAAI;AACb"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as pluginName, t as parseIconSet } from "./sets-kepuObH8.js";
|
|
2
2
|
import { n as isDefined, r as isRecord } from "./utils-COPacfAq.js";
|
|
3
|
-
import {
|
|
3
|
+
import { i as registryModulePath } from "./registry-B0Dxiwhh.js";
|
|
4
4
|
import { a as readDeclaredPackages, c as convertIcon, n as createCustomAdapter, o as readJson, r as findPackage, s as readPluginBuild, t as iconAdapters } from "./adapters-Bx_MyEX_.js";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
@@ -255,4 +255,4 @@ function describeReport(label, style, report) {
|
|
|
255
255
|
}
|
|
256
256
|
export { writeIconNames as a, loadIconSet as i, detectLibraries as n, listRegistryDependencies as r, describeReport as t };
|
|
257
257
|
|
|
258
|
-
//# sourceMappingURL=sets-
|
|
258
|
+
//# sourceMappingURL=sets-D5_YGFll.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sets-DVh8eYeP.js","names":["readFile","rename","writeFile","path","isDefined","registryModulePath","pluginName","namesFile","join","dirname","writeIconNames","names","Map","Set","entries","toSorted","first","second","localeCompare","map","library","icons","union","name","JSON","stringify","content","current","catch","temporary","process","pid","once","mkdir","writeFile","path","Worker","isDefined","isRecord","createCustomAdapter","iconAdapters","IconAdapter","SourceIcon","convertIcon","InstalledPackage","findPackage","readDeclaredPackages","readJson","readPluginBuild","IconSet","IconSetIcon","parseIconSet","IconSetReport","total","skipped","name","reason","duration","DetectedStyle","style","installed","DetectedLibrary","adapter","styles","listed","sitePackage","folder","IconSetContext","root","cacheDir","detectLibraries","custom","Record","Promise","declared","known","all","map","packageName","packagePrefix","packagePattern","names","filter","startsWith","toSorted","found","slice","length","flat","has","undefined","find","test","folders","Object","entries","library","directory","resolve","version","findCommonRoot","icons","NonNullable","counts","Map","count","key","JSON","stringify","set","get","common","values","first","second","isSourceIcon","value","keywords","svg","Array","isArray","every","keyword","readSources","candidate","worker","URL","import","meta","url","workerData","env","process","NODE_ENV","received","sources","source","terminate","convertIconSet","started","performance","now","report","converted","icon","problem","push","iconRoot","Math","round","parseReport","flatMap","entry","loadIconSet","context","cacheable","cacheFile","join","replaceAll","cached","dirname","recursive","listRegistryDependencies","libraries","files","describeReport","label","kept","toLocaleString","timing","summary","shown","hidden","more","\"total\"","\"skipped\"","\"name\"","\"reason\"","\"set\"","\"report\""],"sources":["../src/build/names.ts","../src/build/sets.ts"],"sourcesContent":["import { readFile, rename, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport { isDefined } from \"@repo/lib/utils\";\n\nimport { registryModulePath } from \"@/build/registry\";\nimport { pluginName } from \"@/config/defaults\";\n\n/** Types file the plugin reads icon names from, published next to the placeholder registry. */\nconst namesFile = path.join(path.dirname(registryModulePath), \"names.d.ts\");\n\n/**\n * Writes the installed icon names into the plugin's own types, so options that list icons are checked against them.\n * The file is replaced rather than edited, because pnpm shares a package's files between projects.\n *\n * @param names - Icon names keyed by library.\n */\nexport async function writeIconNames(names: Map<string, Set<string>>) {\n const entries = [...names]\n .toSorted(([first], [second]) => first.localeCompare(second))\n .map(([library, icons]) => {\n const union = [...icons].toSorted().map((name) => JSON.stringify(name));\n\n return ` ${JSON.stringify(library)}: ${isDefined(union) ? union.join(\" | \") : \"never\"};`;\n });\n\n const content = [\n `// Written by ${pluginName}'s build step from the project's installed icon libraries.`,\n \"export type SanityIconNames = {\",\n ...entries,\n \"};\",\n \"\",\n ].join(\"\\n\");\n\n const current = await readFile(namesFile, \"utf8\").catch(() => \"\");\n if (current === content) return;\n\n const temporary = `${namesFile}.${process.pid}.tmp`;\n await writeFile(temporary, content);\n await rename(temporary, namesFile);\n}\n","import { once } from \"node:events\";\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { Worker } from \"node:worker_threads\";\n\nimport { isDefined, isRecord } from \"@repo/lib/utils\";\n\nimport { createCustomAdapter } from \"@/build/adapters/custom\";\nimport { iconAdapters } from \"@/build/adapters/index\";\nimport type { IconAdapter } from \"@/build/adapters/types\";\nimport type { SourceIcon } from \"@/build/convert\";\nimport { convertIcon } from \"@/build/convert\";\nimport type { InstalledPackage } from \"@/build/packages\";\nimport { findPackage, readDeclaredPackages, readJson, readPluginBuild } from \"@/build/packages\";\nimport type { IconSet, IconSetIcon } from \"@/lib/sets\";\nimport { parseIconSet } from \"@/lib/sets\";\n\n/** What happened converting a set, for the build's log. */\nexport interface IconSetReport {\n /** Icons the library ships in the style. */\n total: number;\n /** Icons skipped, with why. */\n skipped: { name: string; reason: string }[];\n /** Time the conversion took, in milliseconds, or 0 when it came from the cache. */\n duration: number;\n}\n\n/** One installed style of a library, and the package it's read from. */\nexport interface DetectedStyle {\n /** Identifier of the style. */\n style: string;\n /** The package the style is read from. */\n installed: InstalledPackage;\n}\n\n/** A library found in the project, and where each of its styles is installed. */\nexport interface DetectedLibrary {\n /** How to read the library. */\n adapter: IconAdapter;\n /** The styles the project has installed, empty when it has none. */\n styles: DetectedStyle[];\n /** Whether the project's `package.json` lists the package the library is read from, installed or not. */\n listed: boolean;\n /**\n * Another package of the library the project lists, such as its React version, or undefined when there's none or the\n * library's own package is listed.\n */\n sitePackage?: string;\n /** Folder of the project's own icons, relative to the project, or undefined for a known library. */\n folder?: string;\n}\n\n/** Where the build step reads libraries from and caches conversions. */\nexport interface IconSetContext {\n /** The project folder. */\n root: string;\n /** Folder for cached conversions, or undefined to convert every time. */\n cacheDir: string | undefined;\n}\n\n/**\n * Finds every library the project can use: known libraries whose package it lists and has installed, and its own icon\n * folders. Only listed packages count, so a package that's only there because another one depends on it is ignored.\n *\n * @param root - The project folder.\n * @param custom - The project's own icon folders, keyed by identifier.\n * @returns Every library the build step knows, with where it's installed.\n */\nexport async function detectLibraries(root: string, custom: Record<string, string> = {}): Promise<DetectedLibrary[]> {\n const declared = await readDeclaredPackages(root);\n\n const known = await Promise.all(\n iconAdapters.map(async (adapter) => {\n const { packageName, packagePrefix, packagePattern } = adapter;\n\n if (isDefined(packagePrefix)) {\n const names = [...declared].filter((name) => name.startsWith(packagePrefix)).toSorted();\n const found = await Promise.all(\n names.map(async (name) => {\n const installed = await findPackage(root, name);\n\n return isDefined(installed) ? [{ style: name.slice(packagePrefix.length), installed }] : [];\n }),\n );\n\n return { adapter, styles: found.flat(), listed: isDefined(names) };\n }\n\n const listed = isDefined(packageName) && declared.has(packageName);\n const installed = listed ? await findPackage(root, packageName) : undefined;\n const styles = isDefined(installed) ? adapter.styles.map((style) => ({ style, installed })) : [];\n const sitePackage =\n listed || !isDefined(packagePattern)\n ? undefined\n : [...declared].toSorted().find((name) => packagePattern.test(name));\n\n return { adapter, styles, listed, ...(isDefined(sitePackage) && { sitePackage }) };\n }),\n );\n\n const folders = Object.entries(custom).map(([library, folder]) => ({\n adapter: createCustomAdapter(library, folder),\n listed: true,\n folder,\n styles: [\n { style: \"default\", installed: { name: library, directory: path.resolve(root, folder), version: \"custom\" } },\n ],\n }));\n\n return [...known, ...folders];\n}\n\n/**\n * Picks the root most icons in a set share, so only the others need their own.\n *\n * @param icons - The converted icons.\n * @returns The most common root.\n */\nfunction findCommonRoot(icons: (IconSetIcon & { root: NonNullable<IconSetIcon[\"root\"]> })[]) {\n const counts = new Map<string, { root: IconSet[\"root\"]; count: number }>();\n\n for (const { root } of icons) {\n const key = JSON.stringify(root);\n counts.set(key, { root, count: (counts.get(key)?.count ?? 0) + 1 });\n }\n\n const [common] = [...counts.values()].toSorted((first, second) => second.count - first.count);\n\n return common?.root ?? {};\n}\n\n/**\n * Checks whether a value is an icon as a worker read it from its library.\n *\n * @param value - The value to check.\n * @returns True if the value is a source icon.\n */\nfunction isSourceIcon(value: unknown): value is SourceIcon {\n if (!isRecord(value)) return false;\n\n const { name, keywords, svg } = value;\n\n return (\n typeof name === \"string\" &&\n Array.isArray(keywords) &&\n keywords.every((keyword) => typeof keyword === \"string\") &&\n typeof svg === \"string\"\n );\n}\n\n/**\n * Reads a library's icons in a fresh worker thread. A long-running bundler keeps every module it has imported, so an\n * icon package updated in place would otherwise be read from the old copy.\n *\n * @param library - The library and where it's installed.\n * @param style - The style to read.\n * @param root - The project folder.\n * @returns The icons as the library ships them.\n */\nasync function readSources(library: DetectedLibrary, style: string, root: string) {\n const { adapter, folder } = library;\n const installed = library.styles.find((candidate) => candidate.style === style)?.installed;\n if (!isDefined(installed)) return [];\n\n const worker = new Worker(new URL(\"read-worker.js\", import.meta.url), {\n workerData: { library: adapter.library, folder, style, root, directory: installed.directory },\n // Libraries' components render with React's production build, which writes the same markup without warnings.\n env: { ...process.env, NODE_ENV: \"production\" },\n });\n\n try {\n const received: unknown[] = await once(worker, \"message\");\n const [sources] = received;\n\n return Array.isArray(sources) ? sources.filter((source) => isSourceIcon(source)) : [];\n } finally {\n void worker.terminate();\n }\n}\n\n/**\n * Converts one style of a library into a set, reporting anything skipped.\n *\n * @param library - The library and where it's installed.\n * @param style - The style to convert.\n * @param root - The project folder.\n * @returns The set and its report.\n */\nasync function convertIconSet(library: DetectedLibrary, style: string, root: string) {\n const { adapter } = library;\n const started = performance.now();\n const sources = await readSources(library, style, root);\n\n const report: IconSetReport = { total: sources.length, skipped: [], duration: 0 };\n const converted: (IconSetIcon & { root: NonNullable<IconSetIcon[\"root\"]> })[] = [];\n\n for (const source of sources) {\n const { icon, problem } = convertIcon(source);\n\n if (isDefined(icon)) converted.push(icon);\n else if (isDefined(problem)) report.skipped.push({ name: source.name, reason: problem });\n }\n\n const common = findCommonRoot(converted);\n const set: IconSet = {\n library: adapter.library,\n style,\n root: common,\n icons: converted.map(({ root: iconRoot, ...icon }) =>\n JSON.stringify(iconRoot) === JSON.stringify(common) ? icon : { ...icon, root: iconRoot },\n ),\n };\n\n report.duration = Math.round(performance.now() - started);\n\n return { set, report };\n}\n\n/**\n * Reads a cached conversion's report.\n *\n * @param value - The cached report.\n * @returns The report, or undefined when the value isn't one.\n */\nfunction parseReport(value: unknown): IconSetReport | undefined {\n if (!isRecord(value) || typeof value[\"total\"] !== \"number\" || !Array.isArray(value[\"skipped\"])) return undefined;\n\n const skipped = value[\"skipped\"].flatMap((entry: unknown) =>\n isRecord(entry) && typeof entry[\"name\"] === \"string\" && typeof entry[\"reason\"] === \"string\"\n ? [{ name: entry[\"name\"], reason: entry[\"reason\"] }]\n : [],\n );\n\n return { total: value[\"total\"], skipped, duration: 0 };\n}\n\n/**\n * Loads a converted set, from the cache when the same package version was converted before.\n *\n * @param library - The library and where it's installed.\n * @param style - The style to load.\n * @param context - The project folder and cache folder.\n * @returns The set and its report.\n */\nexport async function loadIconSet(library: DetectedLibrary, style: string, context: IconSetContext) {\n const { adapter, folder } = library;\n const installed = library.styles.find((candidate) => candidate.style === style)?.installed;\n const cacheable = isDefined(context.cacheDir) && isDefined(installed) && !isDefined(folder);\n const cacheFile =\n cacheable && isDefined(context.cacheDir)\n ? path.join(\n context.cacheDir,\n \"driftime-icon\",\n `${adapter.library}-${style}-${installed.name.replaceAll(/[@/]/gu, \"_\")}-${installed.version}-${await readPluginBuild()}.json`,\n )\n : undefined;\n\n if (isDefined(cacheFile)) {\n const cached = await readJson(cacheFile);\n const set = isRecord(cached) ? parseIconSet(cached[\"set\"]) : undefined;\n const report = isRecord(cached) ? parseReport(cached[\"report\"]) : undefined;\n\n if (isDefined(set) && isDefined(report)) return { set, report };\n }\n\n const { set, report } = await convertIconSet(library, style, context.root);\n\n if (isDefined(cacheFile)) {\n await mkdir(path.dirname(cacheFile), { recursive: true });\n await writeFile(cacheFile, JSON.stringify({ set, report }));\n }\n\n return { set, report };\n}\n\n/**\n * Lists the files the registry is generated from, so the bundler regenerates it when a library is installed, removed,\n * or updated, instead of keeping a cached copy.\n *\n * @param root - The project folder.\n * @param libraries - Every library the build step knows.\n * @returns The files, and the folders of the project's own icons.\n */\nexport function listRegistryDependencies(root: string, libraries: DetectedLibrary[]) {\n const files = [path.join(root, \"package.json\")];\n const folders: string[] = [];\n\n for (const { styles, folder } of libraries) {\n for (const { installed } of styles) {\n if (isDefined(folder)) folders.push(installed.directory);\n else files.push(path.join(installed.directory, \"package.json\"));\n }\n }\n\n return { files, folders };\n}\n\n/**\n * Summarises a set's conversion for the build's log, listing the first few icons it skipped and why.\n *\n * @param label - Readable name of the library.\n * @param style - The style converted.\n * @param report - What happened.\n * @returns The summary, one line per skipped icon after the first.\n */\nexport function describeReport(label: string, style: string, report: IconSetReport) {\n const { total, skipped, duration } = report;\n const kept = total - skipped.length;\n const count = `${kept.toLocaleString(\"en-US\")} ${kept === 1 ? \"icon\" : \"icons\"}`;\n const timing = duration > 0 ? `converted in ${duration.toLocaleString(\"en-US\")} ms` : \"loaded from the cache\";\n const summary = `${label} (\\`${style}\\`): ${count} ${timing}`;\n if (!isDefined(skipped)) return `${summary}.`;\n\n const shown = skipped.slice(0, 5).map(({ name, reason }) => ` \\`${name}\\` ${reason}.`);\n const hidden = skipped.length - shown.length;\n const more = hidden > 0 ? [` …and ${hidden.toLocaleString(\"en-US\")} more.`] : [];\n\n return [`${summary}, ${skipped.length.toLocaleString(\"en-US\")} skipped:`, ...shown, ...more].join(\"\\n\");\n}\n"],"mappings":";;;;;;;;;AASA,MAAMO,YAAYJ,KAAKK,KAAKL,KAAKM,QAAQJ,kBAAkB,GAAG,YAAY;;;;;;;AAQ1E,eAAsBK,eAAeC,OAAiC;CACpE,IAAMG,UAAU,CAAC,GAAGH,KAAK,CAAC,CACvBI,UAAU,CAACC,QAAQ,CAACC,YAAYD,MAAME,cAAcD,MAAM,CAAC,CAAC,CAC5DE,KAAK,CAACC,SAASC,WAAW;EACzB,IAAMC,QAAQ,CAAC,GAAGD,KAAK,CAAC,CAACN,SAAS,CAAC,CAACI,KAAKI,SAASC,KAAKC,UAAUF,IAAI,CAAC;EAEtE,OAAO,KAAKC,KAAKC,UAAUL,OAAO,EAAC,IAAKhB,UAAUkB,KAAK,IAAIA,MA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AeC,OAAe3G,OAAemF,QAAuB;CAClF,IAAM,EAAEzF,OAAOC,SAASG,aAAaqF,QAC/ByB,OAAOlH,QAAQC,QAAQiC,QAGvBmF,UAAU,GAAGJ,MAAK,MAAO3G,MAAK,OAAQ8C,GAF3B8D,KAAKC,eAAe,OAAO,EAAC,GAAID,SAAS,IAAI,SAAS,UAEtB,GADlC9G,WAAW,IAAI,gBAAgBA,SAAS+G,eAAe,OAAO,EAAC,OAAQ;CAEtF,IAAI,CAACnI,UAAUiB,OAAO,GAAG,OAAO,GAAGoH,QAAO;CAE1C,IAAMC,QAAQrH,QAAQgC,MAAM,GAAG,CAAC,CAAC,CAACT,KAAK,EAAEtB,MAAMC,aAAa,OAAOD,KAAI,KAAMC,OAAM,EAAG,GAChFoH,SAAStH,QAAQiC,SAASoF,MAAMpF,QAChCsF,OAAOD,SAAS,IAAI,CAAC,UAAUA,OAAOJ,eAAe,OAAO,EAAC,OAAQ,IAAI,CAAA;CAE/E,OAAO;EAAC,GAAGE,QAAO,IAAKpH,QAAQiC,OAAOiF,eAAe,OAAO,EAAC;EAAa,GAAGG;EAAO,GAAGE;CAAI,CAAC,CAAChB,KAAK,IAAI;AACxG"}
|
|
1
|
+
{"version":3,"file":"sets-D5_YGFll.js","names":["readFile","rename","writeFile","path","isDefined","registryModulePath","pluginName","namesFile","join","dirname","writeIconNames","names","Map","Set","entries","toSorted","first","second","localeCompare","map","library","icons","union","name","JSON","stringify","content","current","catch","temporary","process","pid","once","mkdir","writeFile","path","Worker","isDefined","isRecord","createCustomAdapter","iconAdapters","IconAdapter","SourceIcon","convertIcon","InstalledPackage","findPackage","readDeclaredPackages","readJson","readPluginBuild","IconSet","IconSetIcon","parseIconSet","IconSetReport","total","skipped","name","reason","duration","DetectedStyle","style","installed","DetectedLibrary","adapter","styles","listed","sitePackage","folder","IconSetContext","root","cacheDir","detectLibraries","custom","Record","Promise","declared","known","all","map","packageName","packagePrefix","packagePattern","names","filter","startsWith","toSorted","found","slice","length","flat","has","undefined","find","test","folders","Object","entries","library","directory","resolve","version","findCommonRoot","icons","NonNullable","counts","Map","count","key","JSON","stringify","set","get","common","values","first","second","isSourceIcon","value","keywords","svg","Array","isArray","every","keyword","readSources","candidate","worker","URL","import","meta","url","workerData","env","process","NODE_ENV","received","sources","source","terminate","convertIconSet","started","performance","now","report","converted","icon","problem","push","iconRoot","Math","round","parseReport","flatMap","entry","loadIconSet","context","cacheable","cacheFile","join","replaceAll","cached","dirname","recursive","listRegistryDependencies","libraries","files","describeReport","label","kept","toLocaleString","timing","summary","shown","hidden","more","\"total\"","\"skipped\"","\"name\"","\"reason\"","\"set\"","\"report\""],"sources":["../src/build/names.ts","../src/build/sets.ts"],"sourcesContent":["import { readFile, rename, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport { isDefined } from \"@repo/lib/utils\";\n\nimport { registryModulePath } from \"@/build/registry\";\nimport { pluginName } from \"@/config/defaults\";\n\n/** Types file the plugin reads icon names from, published next to the placeholder registry. */\nconst namesFile = path.join(path.dirname(registryModulePath), \"names.d.ts\");\n\n/**\n * Writes the installed icon names into the plugin's own types, so options that list icons are checked against them.\n * The file is replaced rather than edited, because pnpm shares a package's files between projects.\n *\n * @param names - Icon names keyed by library.\n */\nexport async function writeIconNames(names: Map<string, Set<string>>) {\n const entries = [...names]\n .toSorted(([first], [second]) => first.localeCompare(second))\n .map(([library, icons]) => {\n const union = [...icons].toSorted().map((name) => JSON.stringify(name));\n\n return ` ${JSON.stringify(library)}: ${isDefined(union) ? union.join(\" | \") : \"never\"};`;\n });\n\n const content = [\n `// Written by ${pluginName}'s build step from the project's installed icon libraries.`,\n \"export type SanityIconNames = {\",\n ...entries,\n \"};\",\n \"\",\n ].join(\"\\n\");\n\n const current = await readFile(namesFile, \"utf8\").catch(() => \"\");\n if (current === content) return;\n\n const temporary = `${namesFile}.${process.pid}.tmp`;\n await writeFile(temporary, content);\n await rename(temporary, namesFile);\n}\n","import { once } from \"node:events\";\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { Worker } from \"node:worker_threads\";\n\nimport { isDefined, isRecord } from \"@repo/lib/utils\";\n\nimport { createCustomAdapter } from \"@/build/adapters/custom\";\nimport { iconAdapters } from \"@/build/adapters/index\";\nimport type { IconAdapter } from \"@/build/adapters/types\";\nimport type { SourceIcon } from \"@/build/convert\";\nimport { convertIcon } from \"@/build/convert\";\nimport type { InstalledPackage } from \"@/build/packages\";\nimport { findPackage, readDeclaredPackages, readJson, readPluginBuild } from \"@/build/packages\";\nimport type { IconSet, IconSetIcon } from \"@/lib/sets\";\nimport { parseIconSet } from \"@/lib/sets\";\n\n/** What happened converting a set, for the build's log. */\nexport interface IconSetReport {\n /** Icons the library ships in the style. */\n total: number;\n /** Icons skipped, with why. */\n skipped: { name: string; reason: string }[];\n /** Time the conversion took, in milliseconds, or 0 when it came from the cache. */\n duration: number;\n}\n\n/** One installed style of a library, and the package it's read from. */\nexport interface DetectedStyle {\n /** Identifier of the style. */\n style: string;\n /** The package the style is read from. */\n installed: InstalledPackage;\n}\n\n/** A library found in the project, and where each of its styles is installed. */\nexport interface DetectedLibrary {\n /** How to read the library. */\n adapter: IconAdapter;\n /** The styles the project has installed, empty when it has none. */\n styles: DetectedStyle[];\n /** Whether the project's `package.json` lists the package the library is read from, installed or not. */\n listed: boolean;\n /**\n * Another package of the library the project lists, such as its React version, or undefined when there's none or the\n * library's own package is listed.\n */\n sitePackage?: string;\n /** Folder of the project's own icons, relative to the project, or undefined for a known library. */\n folder?: string;\n}\n\n/** Where the build step reads libraries from and caches conversions. */\nexport interface IconSetContext {\n /** The project folder. */\n root: string;\n /** Folder for cached conversions, or undefined to convert every time. */\n cacheDir: string | undefined;\n}\n\n/**\n * Finds every library the project can use: known libraries whose package it lists and has installed, and its own icon\n * folders. Only listed packages count, so a package that's only there because another one depends on it is ignored.\n *\n * @param root - The project folder.\n * @param custom - The project's own icon folders, keyed by identifier.\n * @returns Every library the build step knows, with where it's installed.\n */\nexport async function detectLibraries(root: string, custom: Record<string, string> = {}): Promise<DetectedLibrary[]> {\n const declared = await readDeclaredPackages(root);\n\n const known = await Promise.all(\n iconAdapters.map(async (adapter) => {\n const { packageName, packagePrefix, packagePattern } = adapter;\n\n if (isDefined(packagePrefix)) {\n const names = [...declared].filter((name) => name.startsWith(packagePrefix)).toSorted();\n const found = await Promise.all(\n names.map(async (name) => {\n const installed = await findPackage(root, name);\n\n return isDefined(installed) ? [{ style: name.slice(packagePrefix.length), installed }] : [];\n }),\n );\n\n return { adapter, styles: found.flat(), listed: isDefined(names) };\n }\n\n const listed = isDefined(packageName) && declared.has(packageName);\n const installed = listed ? await findPackage(root, packageName) : undefined;\n const styles = isDefined(installed) ? adapter.styles.map((style) => ({ style, installed })) : [];\n const sitePackage =\n listed || !isDefined(packagePattern)\n ? undefined\n : [...declared].toSorted().find((name) => packagePattern.test(name));\n\n return { adapter, styles, listed, ...(isDefined(sitePackage) && { sitePackage }) };\n }),\n );\n\n const folders = Object.entries(custom).map(([library, folder]) => ({\n adapter: createCustomAdapter(library, folder),\n listed: true,\n folder,\n styles: [\n { style: \"default\", installed: { name: library, directory: path.resolve(root, folder), version: \"custom\" } },\n ],\n }));\n\n return [...known, ...folders];\n}\n\n/**\n * Picks the root most icons in a set share, so only the others need their own.\n *\n * @param icons - The converted icons.\n * @returns The most common root.\n */\nfunction findCommonRoot(icons: (IconSetIcon & { root: NonNullable<IconSetIcon[\"root\"]> })[]) {\n const counts = new Map<string, { root: IconSet[\"root\"]; count: number }>();\n\n for (const { root } of icons) {\n const key = JSON.stringify(root);\n counts.set(key, { root, count: (counts.get(key)?.count ?? 0) + 1 });\n }\n\n const [common] = [...counts.values()].toSorted((first, second) => second.count - first.count);\n\n return common?.root ?? {};\n}\n\n/**\n * Checks whether a value is an icon as a worker read it from its library.\n *\n * @param value - The value to check.\n * @returns True if the value is a source icon.\n */\nfunction isSourceIcon(value: unknown): value is SourceIcon {\n if (!isRecord(value)) return false;\n\n const { name, keywords, svg } = value;\n\n return (\n typeof name === \"string\" &&\n Array.isArray(keywords) &&\n keywords.every((keyword) => typeof keyword === \"string\") &&\n typeof svg === \"string\"\n );\n}\n\n/**\n * Reads a library's icons in a fresh worker thread. A long-running bundler keeps every module it has imported, so an\n * icon package updated in place would otherwise be read from the old copy.\n *\n * @param library - The library and where it's installed.\n * @param style - The style to read.\n * @param root - The project folder.\n * @returns The icons as the library ships them.\n */\nasync function readSources(library: DetectedLibrary, style: string, root: string) {\n const { adapter, folder } = library;\n const installed = library.styles.find((candidate) => candidate.style === style)?.installed;\n if (!isDefined(installed)) return [];\n\n const worker = new Worker(new URL(\"read-worker.js\", import.meta.url), {\n workerData: { library: adapter.library, folder, style, root, directory: installed.directory },\n // Libraries' components render with React's production build, which writes the same markup without warnings.\n env: { ...process.env, NODE_ENV: \"production\" },\n });\n\n try {\n const received: unknown[] = await once(worker, \"message\");\n const [sources] = received;\n\n return Array.isArray(sources) ? sources.filter((source) => isSourceIcon(source)) : [];\n } finally {\n void worker.terminate();\n }\n}\n\n/**\n * Converts one style of a library into a set, reporting anything skipped.\n *\n * @param library - The library and where it's installed.\n * @param style - The style to convert.\n * @param root - The project folder.\n * @returns The set and its report.\n */\nasync function convertIconSet(library: DetectedLibrary, style: string, root: string) {\n const { adapter } = library;\n const started = performance.now();\n const sources = await readSources(library, style, root);\n\n const report: IconSetReport = { total: sources.length, skipped: [], duration: 0 };\n const converted: (IconSetIcon & { root: NonNullable<IconSetIcon[\"root\"]> })[] = [];\n\n for (const source of sources) {\n const { icon, problem } = convertIcon(source);\n\n if (isDefined(icon)) converted.push(icon);\n else if (isDefined(problem)) report.skipped.push({ name: source.name, reason: problem });\n }\n\n const common = findCommonRoot(converted);\n const set: IconSet = {\n library: adapter.library,\n style,\n root: common,\n icons: converted.map(({ root: iconRoot, ...icon }) =>\n JSON.stringify(iconRoot) === JSON.stringify(common) ? icon : { ...icon, root: iconRoot },\n ),\n };\n\n report.duration = Math.round(performance.now() - started);\n\n return { set, report };\n}\n\n/**\n * Reads a cached conversion's report.\n *\n * @param value - The cached report.\n * @returns The report, or undefined when the value isn't one.\n */\nfunction parseReport(value: unknown): IconSetReport | undefined {\n if (!isRecord(value) || typeof value[\"total\"] !== \"number\" || !Array.isArray(value[\"skipped\"])) return undefined;\n\n const skipped = value[\"skipped\"].flatMap((entry: unknown) =>\n isRecord(entry) && typeof entry[\"name\"] === \"string\" && typeof entry[\"reason\"] === \"string\"\n ? [{ name: entry[\"name\"], reason: entry[\"reason\"] }]\n : [],\n );\n\n return { total: value[\"total\"], skipped, duration: 0 };\n}\n\n/**\n * Loads a converted set, from the cache when the same package version was converted before.\n *\n * @param library - The library and where it's installed.\n * @param style - The style to load.\n * @param context - The project folder and cache folder.\n * @returns The set and its report.\n */\nexport async function loadIconSet(library: DetectedLibrary, style: string, context: IconSetContext) {\n const { adapter, folder } = library;\n const installed = library.styles.find((candidate) => candidate.style === style)?.installed;\n const cacheable = isDefined(context.cacheDir) && isDefined(installed) && !isDefined(folder);\n const cacheFile =\n cacheable && isDefined(context.cacheDir)\n ? path.join(\n context.cacheDir,\n \"driftime-icon\",\n `${adapter.library}-${style}-${installed.name.replaceAll(/[@/]/gu, \"_\")}-${installed.version}-${await readPluginBuild()}.json`,\n )\n : undefined;\n\n if (isDefined(cacheFile)) {\n const cached = await readJson(cacheFile);\n const set = isRecord(cached) ? parseIconSet(cached[\"set\"]) : undefined;\n const report = isRecord(cached) ? parseReport(cached[\"report\"]) : undefined;\n\n if (isDefined(set) && isDefined(report)) return { set, report };\n }\n\n const { set, report } = await convertIconSet(library, style, context.root);\n\n if (isDefined(cacheFile)) {\n await mkdir(path.dirname(cacheFile), { recursive: true });\n await writeFile(cacheFile, JSON.stringify({ set, report }));\n }\n\n return { set, report };\n}\n\n/**\n * Lists the files the registry is generated from, so the bundler regenerates it when a library is installed, removed,\n * or updated, instead of keeping a cached copy.\n *\n * @param root - The project folder.\n * @param libraries - Every library the build step knows.\n * @returns The files, and the folders of the project's own icons.\n */\nexport function listRegistryDependencies(root: string, libraries: DetectedLibrary[]) {\n const files = [path.join(root, \"package.json\")];\n const folders: string[] = [];\n\n for (const { styles, folder } of libraries) {\n for (const { installed } of styles) {\n if (isDefined(folder)) folders.push(installed.directory);\n else files.push(path.join(installed.directory, \"package.json\"));\n }\n }\n\n return { files, folders };\n}\n\n/**\n * Summarises a set's conversion for the build's log, listing the first few icons it skipped and why.\n *\n * @param label - Readable name of the library.\n * @param style - The style converted.\n * @param report - What happened.\n * @returns The summary, one line per skipped icon after the first.\n */\nexport function describeReport(label: string, style: string, report: IconSetReport) {\n const { total, skipped, duration } = report;\n const kept = total - skipped.length;\n const count = `${kept.toLocaleString(\"en-US\")} ${kept === 1 ? \"icon\" : \"icons\"}`;\n const timing = duration > 0 ? `converted in ${duration.toLocaleString(\"en-US\")} ms` : \"loaded from the cache\";\n const summary = `${label} (\\`${style}\\`): ${count} ${timing}`;\n if (!isDefined(skipped)) return `${summary}.`;\n\n const shown = skipped.slice(0, 5).map(({ name, reason }) => ` \\`${name}\\` ${reason}.`);\n const hidden = skipped.length - shown.length;\n const more = hidden > 0 ? [` …and ${hidden.toLocaleString(\"en-US\")} more.`] : [];\n\n return [`${summary}, ${skipped.length.toLocaleString(\"en-US\")} skipped:`, ...shown, ...more].join(\"\\n\");\n}\n"],"mappings":";;;;;;;;;AASA,MAAMO,YAAYJ,KAAKK,KAAKL,KAAKM,QAAQJ,kBAAkB,GAAG,YAAY;;;;;;;AAQ1E,eAAsBK,eAAeC,OAAiC;CACpE,IAAMG,UAAU,CAAC,GAAGH,KAAK,CAAC,CACvBI,UAAU,CAACC,QAAQ,CAACC,YAAYD,MAAME,cAAcD,MAAM,CAAC,CAAC,CAC5DE,KAAK,CAACC,SAASC,WAAW;EACzB,IAAMC,QAAQ,CAAC,GAAGD,KAAK,CAAC,CAACN,SAAS,CAAC,CAACI,KAAKI,SAASC,KAAKC,UAAUF,IAAI,CAAC;EAEtE,OAAO,KAAKC,KAAKC,UAAUL,OAA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AAQ;AAC1B;;;;;;;;;AAUA,SAAgBwE,eAAeC,OAAe3G,OAAemF,QAAuB;CAClF,IAAM,EAAEzF,OAAOC,SAASG,aAAaqF,QAC/ByB,OAAOlH,QAAQC,QAAQiC,QAGvBmF,UAAU,GAAGJ,MAAK,MAAO3G,MAAK,OAAQ8C,GAF3B8D,KAAKC,eAAe,OAAO,EAAC,GAAID,SAAS,IAAI,SAAS,UAEtB,GADlC9G,WAAW,IAAI,gBAAgBA,SAAS+G,eAAe,OAAO,EAAC,OAAQ;CAEtF,IAAI,CAACnI,UAAUiB,OAAO,GAAG,OAAO,GAAGoH,QAAO;CAE1C,IAAMC,QAAQrH,QAAQgC,MAAM,GAAG,CAAC,CAAC,CAACT,KAAK,EAAEtB,MAAMC,aAAa,OAAOD,KAAI,KAAMC,OAAM,EAAG,GAChFoH,SAAStH,QAAQiC,SAASoF,MAAMpF,QAChCsF,OAAOD,SAAS,IAAI,CAAC,UAAUA,OAAOJ,eAAe,OAAO,EAAC,OAAQ,IAAI,CAAA;CAE/E,OAAO;EAAC,GAAGE,QAAO,IAAKpH,QAAQiC,OAAOiF,eAAe,OAAO,EAAC;EAAa,GAAGG;EAAO,GAAGE;CAAI,CAAC,CAAChB,KAAK,IAAI;AACxG"}
|
package/dist/vite.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as logger, r as pluginName } from "./sets-kepuObH8.js";
|
|
2
2
|
import { n as isDefined } from "./utils-COPacfAq.js";
|
|
3
|
-
import {
|
|
4
|
-
import { a as writeIconNames, i as loadIconSet, n as detectLibraries, r as listRegistryDependencies, t as describeReport } from "./sets-
|
|
3
|
+
import { r as isRegistryModule, t as createRegistryModule } from "./registry-B0Dxiwhh.js";
|
|
4
|
+
import { a as writeIconNames, i as loadIconSet, n as detectLibraries, r as listRegistryDependencies, t as describeReport } from "./sets-D5_YGFll.js";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
/** Prefix of the module each set is loaded from, followed by its library and style. */
|
|
7
7
|
const setPrefix = `virtual:${pluginName}/set/`;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry-dxVzo7ZX.js","names":["realpathSync","fileURLToPath","isDefined","DetectedLibrary","getIconSetKey","IconLibraryInfo","resolveRealPath","file","registryModulePath","URL","import","meta","url","isRegistryModule","id","split","createRegistryModule","libraries","importFor","key","loaders","flatMap","adapter","styles","map","style","library","JSON","stringify","info","Record","Object","fromEntries","listed","sitePackage","label","packageName","packageExample","packagePrefix","installed","join"],"sources":["../src/build/registry.ts"],"sourcesContent":["import { realpathSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { isDefined } from \"@repo/lib/utils\";\n\nimport type { DetectedLibrary } from \"@/build/sets\";\nimport { getIconSetKey } from \"@/lib/registry\";\nimport type { IconLibraryInfo } from \"@/lib/sets\";\n\n/**\n * Resolves symbolic links in a path, so a package linked into `node_modules` matches its real location.\n *\n * @param file - The path.\n * @returns The real path, or the path unchanged when it doesn't exist.\n */\nfunction resolveRealPath(file: string) {\n try {\n return realpathSync(file);\n } catch {\n return file;\n }\n}\n\n/**\n * Path of the placeholder registry module the Studio imports, which the build step replaces. The build step's own\n * code is published next to it, so the path is found from this file's location.\n */\nexport const registryModulePath = resolveRealPath(fileURLToPath(new URL(\"sets.js\", import.meta.url)));\n\n/**\n * Checks whether a module the bundler is loading is the placeholder registry.\n *\n * @param id - The module's path, possibly followed by a query.\n * @returns Whether it's the placeholder.\n */\nexport function isRegistryModule(id: string) {\n const [file] = id.split(\"?\");\n\n return isDefined(file) && resolveRealPath(file) === registryModulePath;\n}\n\n/**\n * Writes the module that replaces the placeholder registry, with a loader for each installed library style, so each\n * set is only downloaded when a picker for it opens.\n *\n * @param libraries - Every library the build step knows.\n * @param importFor - The specifier the bundler imports a set from, given its key.\n * @returns The module's code.\n */\nexport function createRegistryModule(libraries: DetectedLibrary[], importFor: (key: string) => string) {\n const loaders = libraries.flatMap(({ adapter, styles }) =>\n styles.map(({ style }) => {\n const key = getIconSetKey(adapter.library, style);\n\n return `${JSON.stringify(key)}: () => import(${JSON.stringify(importFor(key))})`;\n }),\n );\n\n const info: Record<string, IconLibraryInfo> = Object.fromEntries(\n libraries.map(({ adapter, styles, listed, sitePackage }) => [\n adapter.library,\n {\n label: adapter.label,\n packageName: adapter.packageName ?? adapter.packageExample ?? adapter.library,\n ...(isDefined(adapter.packagePrefix) && { packagePrefix: adapter.packagePrefix }),\n styles: isDefined(styles) ? styles.map(({ style }) => style) : adapter.styles,\n listed,\n installed: isDefined(styles),\n ...(isDefined(sitePackage) && { sitePackage }),\n },\n ]),\n );\n\n return [\n `const sets = {\\n ${loaders.join(\",\\n \")}\\n};`,\n `export const iconRegistry = { ready: true, sets, libraries: ${JSON.stringify(info)} };`,\n ].join(\"\\n\");\n}\n"],"mappings":";;;;;;;;;;AAeA,SAASM,gBAAgBC,MAAc;CACrC,IAAI;EACF,OAAOP,aAAaO,IAAI;CAC1B,QAAQ;EACN,OAAOA;CACT;AACF;;;;;AAMA,MAAaC,qBAAqBF,gBAAgBL,cAAc,IAAIQ,IAAI,WAAWC,YAAYE,GAAG,CAAC,CAAC;;;;;;;AAQpG,SAAgBC,iBAAiBC,IAAY;CAC3C,IAAM,CAACP,QAAQO,GAAGC,MAAM,GAAG;CAE3B,OAAOb,UAAUK,IAAI,KAAKD,gBAAgBC,IAAI,MAAMC;AACtD;;;;;;;;;AAUA,SAAgBQ,qBAAqBC,WAA8BC,WAAoC;CACrG,IAAME,UAAUH,UAAUI,SAAS,EAAEC,SAASC,aAC5CA,OAAOC,KAAK,EAAEC,YAAY;EACxB,IAAMN,MAAMf,cAAckB,QAAQI,SAASD,KAAK;EAEhD,OAAO,GAAGE,KAAKC,UAAUT,GAAG,EAAC,iBAAkBQ,KAAKC,UAAUV,UAAUC,GAAG,CAAC,EAAC;CAC/E,CAAC,CACH,GAEMU,OAAwCE,OAAOC,YACnDf,UAAUO,KAAK,EAAEF,SAASC,QA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