@gryt/ui 0.24.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Choosing what your owl looks like, instead of only what your name hashes to.
3
+ *
4
+ * Everybody already has an owl — `@gryt/owl` draws one from the nickname, and
5
+ * that is what a member list shows for anyone who has not uploaded a picture.
6
+ * This lets somebody take that owl and choose its colours, its expression and
7
+ * what it is wearing.
8
+ *
9
+ * Three columns: the slots on a rail, every option for the chosen slot as a
10
+ * grid of owls, and the owl itself pinned on the right where it does not scroll
11
+ * away. That last part is the whole reason for this shape — comparing two hats
12
+ * should be looking rather than remembering.
13
+ *
14
+ * Options are drawn, never named. The expression slot holds fourteen things and
15
+ * `eyes-eyelashes-surprised` in a dropdown tells nobody anything.
16
+ */
17
+ export declare function AvatarChoiceDialog({ open, nickname, onOpenChange, onUpload, onDesign, }: {
18
+ open: boolean;
19
+ nickname: string;
20
+ onOpenChange: (open: boolean) => void;
21
+ onUpload: () => void;
22
+ onDesign: () => void;
23
+ }): import("react").JSX.Element;
24
+ /**
25
+ * The designer itself, with no dialog around it.
26
+ *
27
+ * Split out so it can sit in a page as well as in a modal. The client opens it
28
+ * from settings and wants the dialog; gryt.chat puts it straight on the front
29
+ * page, where a modal would mean asking somebody to open a window to look at a
30
+ * toy. `OwlDesignerDialog` below is now a thin wrapper around this.
31
+ *
32
+ * `onCancel` is optional. Inline there is nothing to cancel back to, so the
33
+ * button is simply absent rather than present and inert.
34
+ */
35
+ export declare function OwlDesigner({ nickname, saving, onSave, onCancel, active, followSeed, }: {
36
+ nickname: string;
37
+ saving: boolean;
38
+ onSave: (png: Blob, worn: string) => void;
39
+ onCancel?: () => void;
40
+ /** Reset when this goes true. The dialog uses it for "was just opened". */
41
+ active?: boolean;
42
+ /**
43
+ * Open on the owl the nickname already draws, and keep following it while
44
+ * the nickname changes, until somebody changes something here.
45
+ *
46
+ * gryt.chat sets this. The client does not: there you open the designer to
47
+ * design, and your last look is the right place to start.
48
+ */
49
+ followSeed?: boolean;
50
+ }): import("react").JSX.Element;
51
+ /**
52
+ * The designer in a modal, which is how the client opens it from settings.
53
+ *
54
+ * Kept as a wrapper rather than as the only shape, because gryt.chat renders
55
+ * `OwlDesigner` straight into the page. The title is here rather than inside
56
+ * the designer: a dialog needs an accessible name, a section on a page already
57
+ * has a heading above it.
58
+ */
59
+ export declare function OwlDesignerDialog({ open, nickname, saving, onOpenChange, onSave, }: {
60
+ open: boolean;
61
+ nickname: string;
62
+ saving: boolean;
63
+ onOpenChange: (open: boolean) => void;
64
+ onSave: (png: Blob, worn: string) => void;
65
+ }): import("react").JSX.Element;
66
+ //# sourceMappingURL=owlDesigner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"owlDesigner.d.ts","sourceRoot":"","sources":["../../../src/components/OwlDesigner/owlDesigner.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AA6WH,wBAAgB,kBAAkB,CAAC,EACjC,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB,+BAiEA;AAID;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,MAAM,EACN,MAAM,EACN,QAAQ,EACR,MAAa,EACb,UAAkB,GACnB,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,2EAA2E;IAC3E,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,+BA2YA;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,MAAM,GACP,EAAE;IACD,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,MAAM,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C,+BAkBA"}
@@ -0,0 +1,31 @@
1
+ import { WornLook } from '@gryt/owl';
2
+ /** The size a raster export is written at. See the note above. */
3
+ export declare const EXPORT_SIZE = 1024;
4
+ export interface ExportFormat {
5
+ id: "svg" | "png" | "webp" | "jpeg";
6
+ label: string;
7
+ /** What it is good for, in the few words a menu row has. */
8
+ hint: string;
9
+ extension: string;
10
+ mime: string;
11
+ }
12
+ export declare const EXPORT_FORMATS: readonly ExportFormat[];
13
+ /**
14
+ * The owl as a blob in one of the formats above.
15
+ *
16
+ * The rasters go through an `<img>` and a canvas so the browser draws the same
17
+ * SVG it would have drawn on screen, rather than this reimplementing the
18
+ * geometry and getting a slightly different owl.
19
+ */
20
+ export declare function renderOwl(seed: string, look: WornLook, format: ExportFormat, size?: number): Promise<Blob>;
21
+ /** `sivert-owl.png`, and nothing a filesystem will refuse. */
22
+ export declare function exportFilename(nickname: string, format: ExportFormat): string;
23
+ /**
24
+ * Hand the blob to the browser as a download.
25
+ *
26
+ * The object URL is revoked on a timer rather than immediately. Revoking in the
27
+ * same tick can beat the download starting, and the failure is a save that
28
+ * silently does nothing.
29
+ */
30
+ export declare function saveBlob(blob: Blob, filename: string): void;
31
+ //# sourceMappingURL=owlExport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"owlExport.d.ts","sourceRoot":"","sources":["../../../src/components/OwlDesigner/owlExport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAkC,KAAK,QAAQ,EAAgB,MAAM,WAAW,CAAC;AAExF,kEAAkE;AAClE,eAAO,MAAM,WAAW,OAAO,CAAC;AAEhC,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,cAAc,EAAE,SAAS,YAAY,EAKjD,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,SAAS,CAC7B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,QAAQ,EACd,MAAM,EAAE,YAAY,EACpB,IAAI,SAAc,GACjB,OAAO,CAAC,IAAI,CAAC,CAwCf;AAED,8DAA8D;AAC9D,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,MAAM,CAQ7E;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAS3D"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Which cosmetics somebody has already had a look at.
3
+ *
4
+ * Cosmetics get added and nothing says so, so the editor puts a dot on the ones
5
+ * that are new — on the drawing itself, and on its slot in the rail so you know
6
+ * which category to open.
7
+ *
8
+ * The whole feature turns on one decision, and it is the first-run case rather
9
+ * than anything about drawing dots.
10
+ *
11
+ * A fresh install has no record. Treating "not in the record" as "new" would
12
+ * light up all thirty-seven on the first open, which is worse than no badge at
13
+ * all: a badge on everything is a badge on nothing, and it trains somebody to
14
+ * ignore the dot before they have ever seen it mean something. So the first
15
+ * read writes the whole registry into the record and reports nothing as new.
16
+ *
17
+ * The badge therefore means exactly one thing — added since you last looked —
18
+ * which is the only thing it is any use for.
19
+ *
20
+ * localStorage, beside the wardrobe. It is a list of names; losing it costs a
21
+ * dot rather than an avatar, and IndexedDB would be a lot of machinery for
22
+ * something with that consequence.
23
+ */
24
+ /**
25
+ * The cosmetics that have appeared since this person last opened the editor.
26
+ *
27
+ * `all` is every accessory name the running build knows. Pass the registry —
28
+ * this deliberately does not import it, so the caller decides what "everything"
29
+ * means and this stays a store rather than a second source of truth.
30
+ *
31
+ * Empty on a first run, by design. See the note at the top.
32
+ */
33
+ export declare function readNewCosmetics(all: readonly string[]): Set<string>;
34
+ /**
35
+ * Record that somebody has tried one on, and return what is still new.
36
+ *
37
+ * Tried on, not hovered or scrolled past. Wearing a thing is the moment you
38
+ * have actually seen it, and it is also the moment the dot has done its job.
39
+ */
40
+ export declare function markCosmeticSeen(name: string, all: readonly string[]): Set<string>;
41
+ /**
42
+ * Record every one of them, for "I have looked, stop telling me".
43
+ *
44
+ * Returns an empty set so a caller can use it as the new state directly.
45
+ */
46
+ export declare function markAllCosmeticsSeen(all: readonly string[]): Set<string>;
47
+ //# sourceMappingURL=owlSeen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"owlSeen.d.ts","sourceRoot":"","sources":["../../../src/components/OwlDesigner/owlSeen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAyBH;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAUpE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAQlF;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAGxE"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Every look somebody has worn, kept so going back to one is a click.
3
+ *
4
+ * A look is a sixteen-character string from `@gryt/owl`, which is what makes a
5
+ * wardrobe cheap enough to be worth having: a wardrobe of pictures would be an
6
+ * upload and a stored file per entry, and nobody would keep more than a couple.
7
+ * A wardrobe of strings is a list in settings.
8
+ *
9
+ * Newest first, deduplicated, and capped — see LIMIT for why there is one.
10
+ */
11
+ export interface WardrobeEntry {
12
+ /** The encoded look. */
13
+ worn: string;
14
+ /** When it was last used, so the newest reads as "what I have on". */
15
+ at: number;
16
+ }
17
+ export declare function readWardrobe(): WardrobeEntry[];
18
+ /**
19
+ * Records a look as worn, and returns the wardrobe as it now stands.
20
+ *
21
+ * Wearing something again moves it to the front rather than adding a second
22
+ * copy, so the list stays a set of looks rather than a history of clicks.
23
+ */
24
+ export declare function rememberLook(worn: string): WardrobeEntry[];
25
+ export declare function forgetLook(worn: string): WardrobeEntry[];
26
+ //# sourceMappingURL=owlWardrobe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"owlWardrobe.d.ts","sourceRoot":"","sources":["../../../src/components/OwlDesigner/owlWardrobe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAWH,MAAM,WAAW,aAAa;IAC5B,wBAAwB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,sEAAsE;IACtE,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,wBAAgB,YAAY,IAAI,aAAa,EAAE,CAiB9C;AAUD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE,CAK1D;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE,CAIxD"}