@johnmorrisdotca/fuda-cards 0.9.1 → 0.10.1

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.
Files changed (35) hide show
  1. package/README.md +382 -58
  2. package/dist/collection-element.d.ts +13 -0
  3. package/dist/collection-element.js +20 -2
  4. package/dist/live-3d.d.ts +43 -0
  5. package/dist/live-3d.js +161 -0
  6. package/docs/API.md +793 -0
  7. package/docs/collection-displays.md +1 -1
  8. package/docs/guides/accessibility-and-theming.md +62 -0
  9. package/docs/guides/architecture.md +53 -0
  10. package/docs/guides/binder-and-piles.md +83 -0
  11. package/docs/guides/card-element.md +65 -0
  12. package/docs/guides/collections.md +86 -0
  13. package/docs/guides/frameworks.md +105 -0
  14. package/docs/guides/getting-started.md +94 -0
  15. package/docs/guides/ja/accessibility-and-theming.md +62 -0
  16. package/docs/guides/ja/architecture.md +53 -0
  17. package/docs/guides/ja/binder-and-piles.md +83 -0
  18. package/docs/guides/ja/card-element.md +65 -0
  19. package/docs/guides/ja/collections.md +86 -0
  20. package/docs/guides/ja/frameworks.md +105 -0
  21. package/docs/guides/ja/getting-started.md +94 -0
  22. package/docs/guides/ja/live-3d.md +75 -0
  23. package/docs/guides/ja/materials-and-stacks.md +73 -0
  24. package/docs/guides/ja/motion-and-spin.md +73 -0
  25. package/docs/guides/ja/troubleshooting.md +60 -0
  26. package/docs/guides/ja/upgrading.md +56 -0
  27. package/docs/guides/ja/wear.md +63 -0
  28. package/docs/guides/live-3d.md +75 -0
  29. package/docs/guides/materials-and-stacks.md +73 -0
  30. package/docs/guides/motion-and-spin.md +73 -0
  31. package/docs/guides/troubleshooting.md +60 -0
  32. package/docs/guides/upgrading.md +56 -0
  33. package/docs/guides/wear.md +63 -0
  34. package/docs/live-3d.md +59 -0
  35. package/package.json +29 -6
package/docs/API.md ADDED
@@ -0,0 +1,793 @@
1
+ # @johnmorrisdotca/fuda-cards API reference
2
+
3
+ Every export of @johnmorrisdotca/fuda-cards 0.10.0, one section for each entry point, written by `pnpm docs:api` from the built declarations. Do not edit it by hand: `pnpm docs:check` fails when it is out of date. The guides are in [docs/guides](guides/getting-started.md).
4
+
5
+ ## `@johnmorrisdotca/fuda-cards`
6
+
7
+ 14 values and 15 types.
8
+
9
+ ```js
10
+ import { cardFinishes, cardMaterial, cardMaterials, cardVariants, mmPerPoint, stackHeightMm, stackLayout, stackPresets, wearLayout, wearLevels, wearOutline, wearOverlaySvg, wearPreset, wearPresets } from '@johnmorrisdotca/fuda-cards';
11
+ ```
12
+
13
+ ### cardFinishes
14
+
15
+ *constant*
16
+
17
+ ```ts
18
+ const cardFinishes: readonly CardFinish[];
19
+ ```
20
+
21
+ ### cardMaterial
22
+
23
+ *function*. The material with this id, or undefined.
24
+
25
+ ```ts
26
+ function cardMaterial(id: string | null | undefined): CardMaterial | undefined;
27
+ ```
28
+
29
+ ### cardMaterials
30
+
31
+ *constant*
32
+
33
+ ```ts
34
+ const cardMaterials: readonly CardMaterial[];
35
+ ```
36
+
37
+ ### cardVariants
38
+
39
+ *constant*
40
+
41
+ ```ts
42
+ const cardVariants: readonly CardVariant[];
43
+ ```
44
+
45
+ ### mmPerPoint
46
+
47
+ *constant*. One thousandth of an inch ("pt" in card and paper trade talk) in millimetres.
48
+
49
+ ```ts
50
+ const mmPerPoint = 0.0254;
51
+ ```
52
+
53
+ ### stackHeightMm
54
+
55
+ *function*. Height of a stack of `count` cards `thicknessMm` thick, in millimetres.
56
+
57
+ ```ts
58
+ function stackHeightMm(count: number, thicknessMm: number): number;
59
+ ```
60
+
61
+ ### stackLayout
62
+
63
+ *function*. The cards under the top one of a stack of `count`, bottom first: the top `depth` of them, as the top card is the live one
64
+
65
+ ```ts
66
+ function stackLayout(count: number, options?: StackLayoutOptions): StackPlace[];
67
+ ```
68
+
69
+ ### stackPresets
70
+
71
+ *constant*
72
+
73
+ ```ts
74
+ const stackPresets: readonly StackPreset[];
75
+ ```
76
+
77
+ ### wearLayout
78
+
79
+ *function*. Where every mark of a card lies. A pure function of the levels and the seed: no DOM, nothing at random.
80
+
81
+ ```ts
82
+ function wearLayout(levels: WearLevels, seed?: number): WearFeatures;
83
+ ```
84
+
85
+ ### wearLevels
86
+
87
+ *function*. The levels a card's wear asks for, or null when it asks for none (no wear, "perfect", an unknown name or all zero).
88
+
89
+ ```ts
90
+ function wearLevels(options: WearOptions): WearLevels | null;
91
+ ```
92
+
93
+ ### wearOutline
94
+
95
+ *function*. The outline of a face as an SVG path in the 250 by 350 box, corners as worn.
96
+
97
+ ```ts
98
+ function wearOutline(features: WearFeatures, face?: 'front' | 'back'): string;
99
+ ```
100
+
101
+ ### wearOverlaySvg
102
+
103
+ *function*. The SVG laid over one face: whitening, folds, creases, scratches, specks, stain and toning. Markup only, no script.
104
+
105
+ ```ts
106
+ function wearOverlaySvg(features: WearFeatures, face?: 'front' | 'back'): string;
107
+ ```
108
+
109
+ ### wearPreset
110
+
111
+ *function*
112
+
113
+ ```ts
114
+ function wearPreset(id: string | null | undefined): WearPreset | undefined;
115
+ ```
116
+
117
+ ### wearPresets
118
+
119
+ *constant*. From perfect to damaged. The names are the plain grading terms; the numbers are this package's reading of them (docs/wear.md).
120
+
121
+ ```ts
122
+ const wearPresets: readonly WearPreset[];
123
+ ```
124
+
125
+ ### CardFinish
126
+
127
+ *type*. A card's finish and visual family.
128
+
129
+ ```ts
130
+ type CardFinish = 'foil' | 'matte';
131
+ ```
132
+
133
+ ### CardMaterial
134
+
135
+ *interface*
136
+
137
+ ```ts
138
+ interface CardMaterial {
139
+ id: string;
140
+ name: string;
141
+ group: CardMaterialGroup;
142
+ /** Thickness of one card in millimetres. */
143
+ thicknessMm: number;
144
+ /** The colour of the card's edge (a look, not a measurement). */
145
+ edge: string;
146
+ source: CardMaterialSource;
147
+ }
148
+ ```
149
+
150
+ ### CardMaterialGroup
151
+
152
+ *type*
153
+
154
+ ```ts
155
+ type CardMaterialGroup = 'paper' | 'plastic' | 'thick-card' | 'metal';
156
+ ```
157
+
158
+ ### CardMaterialSource
159
+
160
+ *interface*. A card material with a thickness taken from a maker or a standard, and where it was read.
161
+
162
+ ```ts
163
+ interface CardMaterialSource {
164
+ label: string;
165
+ url: string;
166
+ /** What the source says, in short. */
167
+ says: string;
168
+ }
169
+ ```
170
+
171
+ ### CardOptions
172
+
173
+ *interface*
174
+
175
+ ```ts
176
+ interface CardOptions {
177
+ title?: string;
178
+ category?: string;
179
+ subtitle?: string;
180
+ description?: string;
181
+ number?: string;
182
+ rarity?: string;
183
+ variant?: CardVariant;
184
+ finish?: CardFinish;
185
+ /** Card thickness in millimetres at the 63 mm wide card size; overrides the material's. Default 0.3, 0 for a flat card. */
186
+ thickness?: number;
187
+ /** A material's id (see `cardMaterials`): its sourced thickness and edge colour. */
188
+ material?: string;
189
+ /** How many cards the stack holds (1 to 1000); the stack is that many times the card's thickness high. Default 1, one card. */
190
+ stack?: number;
191
+ /** From 0 (squared up) to 1 (very messy) for the cards under the top one. Default 0.3. */
192
+ stackMessiness?: number;
193
+ /** The stack's seed: the same seed lays the same stack the same way. Default 1. */
194
+ stackSeed?: number;
195
+ /** How many cards under the top one are laid out nudged and turned, at most 52. Default 10. */
196
+ stackDepth?: number;
197
+ /** A card that is not perfect: a preset's id (`mint`, `near-mint`, `lightly-played`, `moderately-played`, `heavily-played`, `damaged`) or a number from 0 to 1. Default: perfect, nothing drawn. */
198
+ wear?: string | number;
199
+ /** The wear's seed: the same seed draws the same marks the same way. Default 1. */
200
+ wearSeed?: number;
201
+ /** One level of the wear on its own, from 0 to 1, over the preset's. */
202
+ wearCorners?: number;
203
+ wearEdges?: number;
204
+ wearSurface?: number;
205
+ wearCreases?: number;
206
+ flipped?: boolean;
207
+ motion?: 'still' | 'pan';
208
+ playing?: boolean;
209
+ /** `focus`: the card in focus animates its art (needs `motion: 'pan'`); never with reduced motion. */
210
+ autoplay?: 'focus';
211
+ panDirection?: 'down' | 'up';
212
+ panLoop?: 'alternate' | 'restart';
213
+ cardSpin?: 'center' | 'corner';
214
+ cardSpinDirection?: 'normal' | 'reverse';
215
+ cardSpinPaused?: boolean;
216
+ }
217
+ ```
218
+
219
+ ### CardVariant
220
+
221
+ *type*
222
+
223
+ ```ts
224
+ type CardVariant = 'classic' | 'sport' | 'cosmic';
225
+ ```
226
+
227
+ ### CornerKind
228
+
229
+ *type*
230
+
231
+ ```ts
232
+ type CornerKind = 'sharp' | 'soft' | 'rounded' | 'chipped' | 'dog-eared';
233
+ ```
234
+
235
+ ### StackLayoutOptions
236
+
237
+ *interface*
238
+
239
+ ```ts
240
+ interface StackLayoutOptions {
241
+ /** From 0 (squared up) to 1 (very messy). Unless said, 0.3. */
242
+ messiness?: number;
243
+ /** The stack's own seed: the same seed lays the same stack the same way. Unless said, 1. */
244
+ seed?: number;
245
+ /** How many cards under the top one are laid out at most, so a stack of 52 costs no more than one of 11. Unless said, 10. */
246
+ depth?: number;
247
+ }
248
+ ```
249
+
250
+ ### StackPlace
251
+
252
+ *interface*. Where the cards of a stack lie, from neat to messy, the same every time for the same seed.
253
+
254
+ ```ts
255
+ interface StackPlace {
256
+ /** Across, in card widths from where a square card lies. */
257
+ x: number;
258
+ /** Down, in card widths. */
259
+ y: number;
260
+ /** Turn in degrees. */
261
+ rotate: number;
262
+ }
263
+ ```
264
+
265
+ ### StackPreset
266
+
267
+ *interface*. A count of cards for a stack, with where the number comes from.
268
+
269
+ ```ts
270
+ interface StackPreset {
271
+ id: string;
272
+ name: string;
273
+ count: number;
274
+ source: CardMaterialSource;
275
+ }
276
+ ```
277
+
278
+ ### WearCorner
279
+
280
+ *interface*
281
+
282
+ ```ts
283
+ interface WearCorner {
284
+ kind: CornerKind;
285
+ /** How far the damage reaches along each edge, in units of a 250 by 350 card. */
286
+ size: number;
287
+ /** Jagged points of a chip, in the corner's own frame. */
288
+ jag: number[];
289
+ }
290
+ ```
291
+
292
+ ### WearFeatures
293
+
294
+ *interface*
295
+
296
+ ```ts
297
+ interface WearFeatures {
298
+ levels: WearLevels;
299
+ /** Top left, top right, bottom right, bottom left of the front. */
300
+ corners: WearCorner[];
301
+ /** The print's shift off centre in pixels at 300 wide: x and y. */
302
+ centering: {
303
+ x: number;
304
+ y: number;
305
+ };
306
+ front: WearFace;
307
+ back: WearFace;
308
+ }
309
+ ```
310
+
311
+ ### WearLevels
312
+
313
+ *interface*. How much of each kind of wear, from 0 (none) to 1 (the worst the preset names).
314
+
315
+ ```ts
316
+ interface WearLevels {
317
+ corners: number;
318
+ edges: number;
319
+ surface: number;
320
+ creases: number;
321
+ /** Yellowing and darkened borders with age. */
322
+ toning: number;
323
+ /** How far the print sits off centre. */
324
+ centering: number;
325
+ }
326
+ ```
327
+
328
+ ### WearOptions
329
+
330
+ *interface*
331
+
332
+ ```ts
333
+ interface WearOptions {
334
+ /** A preset's id, or a number from 0 to 1 for all the levels at once. */
335
+ wear?: string | number | null;
336
+ /** The seed: the same seed lays the same marks the same way. Unless said, 1. */
337
+ seed?: number;
338
+ /** Overrides of one level each, from 0 to 1. */
339
+ corners?: number;
340
+ edges?: number;
341
+ surface?: number;
342
+ creases?: number;
343
+ }
344
+ ```
345
+
346
+ ### WearPreset
347
+
348
+ *interface*
349
+
350
+ ```ts
351
+ interface WearPreset {
352
+ id: string;
353
+ name: string;
354
+ levels: WearLevels;
355
+ /** What the condition term means in grading language, in a few words. */
356
+ says: string;
357
+ }
358
+ ```
359
+
360
+ ## `@johnmorrisdotca/fuda-cards/element`
361
+
362
+ 1 value and 0 types.
363
+
364
+ ```js
365
+ import { FudaCard } from '@johnmorrisdotca/fuda-cards/element';
366
+ ```
367
+
368
+ ### FudaCard
369
+
370
+ *class*
371
+
372
+ ```ts
373
+ class FudaCard extends HTMLElement {
374
+ static observedAttributes: string[];
375
+ private focused;
376
+ private hushed;
377
+ private focusedAtPress?;
378
+ constructor();
379
+ /** With `autoplay="focus"` the card in focus animates its art; leaving it (pointer, keyboard or a tap elsewhere) stops it. */
380
+ private watchFocus;
381
+ /** Put this card in focus (or out of it); the card that had focus is put out, so only one is ever in focus. */
382
+ setFocused(on: boolean): void;
383
+ /** True while the art moves: `playing` is set, or the card is in focus with `autoplay="focus"` and the person has not paused it. Never autoplays with reduced motion. */
384
+ get isMoving(): boolean;
385
+ private toggleMotion;
386
+ /** The art stays invisible until the card has a size on screen and every slotted image has loaded, so it never shows outside the frame. */
387
+ private watchArt;
388
+ connectedCallback(): void;
389
+ disconnectedCallback(): void;
390
+ attributeChangedCallback(name: string): void;
391
+ /** Millimetres thick: the `thickness` attribute, else the `material`'s, else 0.3. */
392
+ get cardThicknessMm(): number;
393
+ /** How many cards the stack holds: the `stack` attribute as a whole number from 1 (one card) to 1000. */
394
+ get stackCount(): number;
395
+ /** Height of the stack in millimetres: the count times a card's thickness. */
396
+ get stackHeight(): number;
397
+ /** How many cards are still in the stack: `stack` less the `taken-off` ones (at least one stays). */
398
+ get heldCount(): number;
399
+ /** True while the stack is fanned open (`fan="open"`, with more than one card). */
400
+ get fanOpen(): boolean;
401
+ /** How far the pile reaches beyond the card's own box, in card widths: an open fan and the pile of cards taken off. It is zero until a pile feature is used. Pages use it to fit the view; `fuda-pile` is sent when it changes. */
402
+ pileBounds: {
403
+ left: number;
404
+ right: number;
405
+ top: number;
406
+ bottom: number;
407
+ };
408
+ /** Take the top card (or `count` cards) off the stack: it flies to a pile at the stack's side and lands as `deck-land` says. At least one card stays. */
409
+ takeOff(count?: number): void;
410
+ /** Bring the card (or `count` cards) back from the pile onto the stack. */
411
+ putBack(count?: number): void;
412
+ pileUsed: boolean;
413
+ private pileModule?;
414
+ /** Fanning, the pile of cards taken off and the controls are drawn by a module that is loaded only when a stack asks for them; a card without them never loads it. */
415
+ private applyPile;
416
+ private wearKey;
417
+ private wearToken;
418
+ private wearModule?;
419
+ /** Wear (an imperfect card) is drawn by a module that is loaded only when a card asks for it; a perfect card never loads it. */
420
+ private applyWear;
421
+ /** The wear the card is drawn with: a preset's id, a number, or an empty string when it is perfect. */
422
+ get wear(): string;
423
+ set wear(value: string);
424
+ private stillsKey;
425
+ /** The cards under the top one that are laid out nudged and turned; the rest of the stack is one block with a line for each card on its edge. */
426
+ private drawStills;
427
+ render(): void;
428
+ }
429
+ ```
430
+
431
+ ## `@johnmorrisdotca/fuda-cards/live-3d`
432
+
433
+ 1 value and 5 types.
434
+
435
+ ```js
436
+ import { createLiveCards } from '@johnmorrisdotca/fuda-cards/live-3d';
437
+ ```
438
+
439
+ ### createLiveCards
440
+
441
+ *function*
442
+
443
+ ```ts
444
+ function createLiveCards<T extends ThreeLike = ThreeLike>(options: LiveCardsOptions<T>): LiveCards<T>;
445
+ ```
446
+
447
+ ### AddOptions
448
+
449
+ *interface*
450
+
451
+ ```ts
452
+ interface AddOptions {
453
+ /** A picture the card already has (an `<img>` of its own), kept until the card is in focus. With one, the card costs no 3D code until then. */
454
+ still?: HTMLImageElement;
455
+ }
456
+ ```
457
+
458
+ ### LiveCards
459
+
460
+ *interface*
461
+
462
+ ```ts
463
+ interface LiveCards<T extends ThreeLike = ThreeLike> {
464
+ /** Make a card live on focus: a `<fuda-card>` or any element with a size. Gives back the function that takes it off again. */
465
+ add(card: HTMLElement, item: LiveItem<T>, options?: AddOptions): () => void;
466
+ /** Put this card in focus: it takes the context, and the card that had it freezes to a picture at its last angle. False if it did not go live (another took it, reduced motion, no WebGL). */
467
+ focus(card: HTMLElement): Promise<boolean>;
468
+ /** No card in focus: the live one freezes to a picture and nothing draws. */
469
+ blur(): void;
470
+ /** The card in focus, if any. */
471
+ readonly focused: HTMLElement | undefined;
472
+ /** The shared renderer's own figures; undefined until it has been needed. */
473
+ readonly stats: RendererStats | undefined;
474
+ /** The shared renderer; undefined until it has been needed. */
475
+ readonly renderer: SharedRenderer<T> | undefined;
476
+ /** Take every card off and let go of the renderer. */
477
+ dispose(): void;
478
+ }
479
+ ```
480
+
481
+ ### LiveCardsOptions
482
+
483
+ *interface*
484
+
485
+ ```ts
486
+ interface LiveCardsOptions<T extends ThreeLike = ThreeLike> extends Omit<SharedRendererOptions<T>, 'scheduler' | 'assets' | 'clock' | 'document'> {
487
+ /** Seconds for one turn of the card in focus (12). 0 does not turn it. */
488
+ turnSeconds?: number;
489
+ /** How long the pointer has to rest on a card before it goes live, in milliseconds (150), so moving the pointer across a page of cards starts nothing. A press or the keyboard does not wait. */
490
+ dwellMs?: number;
491
+ /** How far outside the view a card with no picture of its own gets its still made, in pixels (300). */
492
+ lookAheadPx?: number;
493
+ }
494
+ ```
495
+
496
+ ### LiveItem
497
+
498
+ *interface*. What a card shows in 3D: a key (items with the same key share their pictures) and a scene made from shared assets (`assets.acquire`).
499
+
500
+ ```ts
501
+ interface LiveItem<T extends ThreeLike = ThreeLike> {
502
+ key: string;
503
+ build(context: BuildContext<T>): LiveScene | Promise<LiveScene>;
504
+ }
505
+ ```
506
+
507
+ ### LiveScene
508
+
509
+ *interface*. A scene for a card. `object` is what turns about its upright axis while the card is in focus.
510
+
511
+ ```ts
512
+ interface LiveScene extends Scene3D {
513
+ object?: {
514
+ rotation: {
515
+ y: number;
516
+ };
517
+ };
518
+ }
519
+ ```
520
+
521
+ ## `@johnmorrisdotca/fuda-cards/collection`
522
+
523
+ 10 values and 6 types.
524
+
525
+ ```js
526
+ import { collectionKinds, collectionViewAliases, collectionViews, deckLandings, fanLayout, isCard, movePage, normalizeLanding, parseCollection, randomDrawIndex } from '@johnmorrisdotca/fuda-cards/collection';
527
+ ```
528
+
529
+ ### collectionKinds
530
+
531
+ *constant*
532
+
533
+ ```ts
534
+ const collectionKinds: ReadonlyArray<CollectionKind>;
535
+ ```
536
+
537
+ ### collectionViewAliases
538
+
539
+ *constant*. Display names that earlier versions accepted and that now open another display, so a page that sets them keeps working.
540
+
541
+ ```ts
542
+ const collectionViewAliases: Readonly<Record<string, CollectionView>>;
543
+ ```
544
+
545
+ ### collectionViews
546
+
547
+ *constant*. The displays, in the order the buttons show them. `jukebox` and `tower` were two more names for the deck's pile of cards (no real counterpart for cards, and the same drawing), so they are no longer offered; see `collectionViewAliases`.
548
+
549
+ ```ts
550
+ const collectionViews: ReadonlyArray<{
551
+ id: CollectionView;
552
+ label: string;
553
+ }>;
554
+ ```
555
+
556
+ ### deckLandings
557
+
558
+ *constant*
559
+
560
+ ```ts
561
+ const deckLandings: ReadonlyArray<{
562
+ id: 'face-up' | 'face-down';
563
+ label: string;
564
+ }>;
565
+ ```
566
+
567
+ ### fanLayout
568
+
569
+ *function*. `step` is how far apart neighbouring cards lie across, in card widths; the angle does the rest of the spreading. A phone uses a smaller one.
570
+
571
+ ```ts
572
+ function fanLayout(count: number, seed?: number, step?: number): FanPlace[];
573
+ ```
574
+
575
+ ### isCard
576
+
577
+ *constant*. True for an item that is a card: anything that does not say it is an object. Only a card turns, has a back and lands turned over.
578
+
579
+ ```ts
580
+ const isCard: (card: Pick<CollectionCard, "kind">) => boolean;
581
+ ```
582
+
583
+ ### movePage
584
+
585
+ *function*. Return the first card index of a wrapped page.
586
+
587
+ ```ts
588
+ function movePage(index: number, length: number, pageSize: number, delta: number): number;
589
+ ```
590
+
591
+ ### normalizeLanding
592
+
593
+ *function*. The landing a value means: `face-down` (also `upside-down` and `turned-over`) is turned over; anything else is still facing up.
594
+
595
+ ```ts
596
+ function normalizeLanding(value: string | null | undefined): 'face-up' | 'face-down';
597
+ ```
598
+
599
+ ### parseCollection
600
+
601
+ *function*
602
+
603
+ ```ts
604
+ function parseCollection(value: unknown): CollectionCard[];
605
+ ```
606
+
607
+ ### randomDrawIndex
608
+
609
+ *function*. Choose a matching card, avoiding the current card when another match exists.
610
+
611
+ ```ts
612
+ function randomDrawIndex(cards: CollectionCard[], current: number, filter: string, random?: () => number): number | null;
613
+ ```
614
+
615
+ ### CollectionCard
616
+
617
+ *interface*
618
+
619
+ ```ts
620
+ interface CollectionCard {
621
+ id: string;
622
+ name: string;
623
+ image: string;
624
+ backImage?: string;
625
+ kind?: CollectionKind;
626
+ metadata?: CollectionMetadata;
627
+ }
628
+ ```
629
+
630
+ ### CollectionKind
631
+
632
+ *type*. What an item is. A `card` (the default, so every collection written before this field existed is still cards) is a flat, thin card with a back: it
633
+
634
+ ```ts
635
+ type CollectionKind = 'card' | 'object';
636
+ ```
637
+
638
+ ### CollectionMetadata
639
+
640
+ *interface*
641
+
642
+ ```ts
643
+ interface CollectionMetadata {
644
+ set?: string;
645
+ year?: number;
646
+ number?: string;
647
+ edition?: string;
648
+ condition?: string;
649
+ grade?: string;
650
+ quantity?: number;
651
+ notes?: string;
652
+ }
653
+ ```
654
+
655
+ ### CollectionView
656
+
657
+ *type*. Browser-native collection viewer. Import this module to register <fuda-collection>.
658
+
659
+ ```ts
660
+ type CollectionView = 'deck' | 'rolodex' | 'binder' | 'case' | 'jukebox' | 'random' | 'story' | 'wall' | 'tower' | 'spotlight' | 'atlas' | 'fan';
661
+ ```
662
+
663
+ ### DeckLanding
664
+
665
+ *type*. How a card taken off a pile lands on the pile at its side: still facing up, or turned over sideways (as a person turns a card, like a
666
+
667
+ ```ts
668
+ type DeckLanding = 'face-up' | 'face-down' | 'upside-down';
669
+ ```
670
+
671
+ ### FanPlace
672
+
673
+ *interface*. Where the cards of a fan lie, first card on the left when open and on top when closed. `open` is the fan spread like a hand of playing cards; `closed` is the squared-up deck it starts from and closes back to.
674
+
675
+ ```ts
676
+ interface FanPlace {
677
+ angle: number;
678
+ x: number;
679
+ y: number;
680
+ closedAngle: number;
681
+ closedX: number;
682
+ closedY: number;
683
+ }
684
+ ```
685
+
686
+ ## `@johnmorrisdotca/fuda-cards/collection-element`
687
+
688
+ 1 value and 1 type.
689
+
690
+ ```js
691
+ import { FudaCollection } from '@johnmorrisdotca/fuda-cards/collection-element';
692
+ ```
693
+
694
+ ### FudaCollection
695
+
696
+ *class*
697
+
698
+ ```ts
699
+ class FudaCollection extends HTMLElement {
700
+ private root;
701
+ private data;
702
+ private index;
703
+ private pageSize;
704
+ private selected;
705
+ private back;
706
+ private drawFilter;
707
+ private zoom;
708
+ private tiles?;
709
+ private landing?;
710
+ private fanChoice?;
711
+ private animateChoice?;
712
+ private speedChoice?;
713
+ private binderChoices;
714
+ private turn;
715
+ private flip;
716
+ private addressTimer;
717
+ private fanPlaces;
718
+ private liveSetup;
719
+ private liveOff;
720
+ static get observedAttributes(): string[];
721
+ set cards(value: CollectionCard[]);
722
+ get cards(): CollectionCard[];
723
+ /** Live 3D: the card in focus turns in 3D on the page's one WebGL context, and every other card stays its picture. Nothing 3D loads until a card is focused. */
724
+ set live(value: CollectionLive | null);
725
+ get live(): CollectionLive | null;
726
+ /** The cards are drawn again on every move, so their live views are made again too: the pictures stay in the shared cache. */
727
+ private attachLive;
728
+ /** The card on top of the deck, or the first card of the page or fan (counting from 0). */
729
+ get position(): number;
730
+ connectedCallback(): void;
731
+ disconnectedCallback(): void;
732
+ attributeChangedCallback(name: string): void;
733
+ private get currentView();
734
+ /** How a card taken off lands: still facing up, or turned over sideways. The 0.6.0 value `upside-down` is still accepted and means turned over. */
735
+ private get land();
736
+ private get fanOpen();
737
+ private get stacked();
738
+ private get piled();
739
+ /** Only a card turns: a collection of objects (no card in it) never turns, and in a mixed one the objects stay square to the reader while the cards turn. */
740
+ private get hasCards();
741
+ private get turnable();
742
+ private q;
743
+ /** With `address`, the display, the fan, the landing, the animation and its speed are kept in the page's address (`?view=fan&fan=open&land=face-down&animate=off`), and a link to it opens the same. */
744
+ private readAddress;
745
+ private writeAddress;
746
+ private move;
747
+ private binderLay;
748
+ /** The first card of an opening of the binder: the right-hand page's first card, or the left-hand page's when the right-hand page is past the end. */
749
+ private spreadFirst;
750
+ private image;
751
+ private open;
752
+ private renderDialog;
753
+ private canDraw;
754
+ /** The one length every move takes, in a custom property the stylesheet reads: `animate="off"` and reduced motion make it 0, `speed` stretches it. */
755
+ private timeVars;
756
+ private syncChoices;
757
+ private build;
758
+ /** One pile of the deck. `positions` are data indexes from the bottom of the pile to its top; the cards under the top one lie nudged and turned from the seed and the top one lies square. A deck's cards also carry where they lie when the fan is open. */
759
+ private pile;
760
+ /** Where the fan's cards lie for a pile of this many cards. A phone's fan lies closer across and leans on its angle. */
761
+ private fanFor;
762
+ /** Open the fan (or close it) on the pile that is on screen, without drawing it again, so every card glides: the open fan's reach is put in custom properties that move the piles apart and the Fit box. */
763
+ private fanVars;
764
+ /** `fan` changed: when a pile is on screen, move its cards to or from the fan in place (animated) and fit the view to it. Returns false when there is no pile to move. */
765
+ private setFan;
766
+ private renderDeck;
767
+ /** The card that just moved flies between the two piles, turning over sideways on the way if it lands face down. The same element, so the card is never drawn twice. An open fan sends the card from where the fan holds it. */
768
+ private playFlip;
769
+ private renderFan;
770
+ /** Where every card is on screen now, by data index. */
771
+ private snapshot;
772
+ /** Cards that arrive grow and fade in, a little to the side the reader is heading. Only an opening keyframe: they end on the card's own style. */
773
+ private enter;
774
+ /** After a card or page change or a switch of display: glide what stays, let what goes leave, bring in what comes. Nothing runs afterwards: each is one animation that ends by itself. */
775
+ private play;
776
+ private syncBinder;
777
+ private binderCount;
778
+ /** The binder: a ring or zip binder open on two facing sheets of pockets. A page turn swings the leaf about the spine, bending as it goes, and shows the pockets on its back. */
779
+ private renderBinder;
780
+ private render;
781
+ }
782
+ ```
783
+
784
+ ### CollectionLive
785
+
786
+ *interface*. Live 3D in a collection's cards: the shared cards from `createLiveCards` and the 3D item of a card, if it has one. See docs/live-3d.md.
787
+
788
+ ```ts
789
+ interface CollectionLive {
790
+ cards: LiveCards<never>;
791
+ item(card: CollectionCard): LiveItem<never> | undefined;
792
+ }
793
+ ```