@johnmorrisdotca/fuda-cards 0.11.0 → 0.12.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.
package/NOTICE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Third-party material
2
2
 
3
- The code of Fuda Cards is MIT licensed (see [LICENSE](LICENSE)). Nothing below is part of the published npm package except where it says so; it is the pictures and data the repository and its demo pages use, each with its source and licence as read on 2026-11-03.
3
+ The code of Fuda Cards is MIT licensed (see [LICENSE](LICENSE)). Nothing below is part of the published npm package except where it says so; it is the pictures and data the repository and its demo pages use, with sources and licences at the dates recorded in the notes.
4
4
 
5
5
  | What | Where | Source and licence |
6
6
  |---|---|---|
@@ -10,5 +10,7 @@ The code of Fuda Cards is MIT licensed (see [LICENSE](LICENSE)). Nothing below i
10
10
  | Vintage hockey cards | `demo/vintage-hockey.js` keeps only addresses and credits; the pictures load from Wikimedia Commons | 1910-11 Imperial Tobacco Canada cards, each file marked public domain on its Commons page (checked 2026-11-02). |
11
11
  | Pokémon Base Set card pictures and data | `demo/tcgdex.html` loads them from TCGdex when the demo opens; none is stored here | Supplied by [TCGdex](https://tcgdex.dev/). The card artwork and the Pokémon names are the property of their owners (Nintendo, Creatures, GAME FREAK, The Pokémon Company) and are shown in the demo only as an example of a collection; they are not licensed by this project and are not in the package. |
12
12
  | Card thicknesses and deck sizes | `src/materials.ts`, `docs/materials.md` | Facts read from the makers' and standards' own pages, each cited with its address. No text or table was copied. |
13
+ | Historical card sizes | `docs/card-images.md` and the card element guides | Sheet sizes of two public-domain objects in the Met's Jefferson R. Burdick Collection, read from the Met's object API (checked 2026-12-06). The guide examples use original drawings. |
14
+ | Wear terminology and visual references | `docs/wear.md` | TCGplayer's Card Conditioning Overview and PSA's Grading Standards and Grader Notes, checked 2026-12-06. Fuda defines its own drawing presets. |
13
15
 
14
16
  The card designs, the wear marks, the binder and every other picture drawn by the package are drawn in code from public facts and are MIT licensed with the rest.
package/README.md CHANGED
@@ -55,11 +55,11 @@ npm install @johnmorrisdotca/fuda-cards
55
55
  And the tables behind it, in script, with no page at all:
56
56
 
57
57
  ```ts
58
- import { cardMaterial, stackHeightMm, wearPresets } from '@johnmorrisdotca/fuda-cards';
58
+ import { cardMaterial, DEFAULT_CARD_THICKNESS_MM, stackHeightMm, wearPresets } from '@johnmorrisdotca/fuda-cards';
59
59
 
60
60
  const stock = cardMaterial('paper-310-black-core');
61
61
  console.log(stock?.name, stock?.thicknessMm);
62
- console.log(stackHeightMm(52, stock?.thicknessMm ?? 0.3));
62
+ console.log(stackHeightMm(52, stock?.thicknessMm ?? DEFAULT_CARD_THICKNESS_MM));
63
63
  console.log(wearPresets.map((preset) => preset.id).join(' '));
64
64
  // Playing-card stock, black core, 310 gsm (13 pt) 0.325
65
65
  // 16.9
@@ -76,7 +76,7 @@ console.log(wearPresets.map((preset) => preset.id).join(' '));
76
76
  ## Features
77
77
 
78
78
  - **A true-scale card.** Thickness in millimetres at the 63 mm card size, a drawn edge, a back, a foil or matte finish, three frame variants.
79
- - **Sourced materials.** Thirteen materials, each thickness read from a maker or a standard and cited.
79
+ - **Sourced materials.** Seventeen materials with cited thicknesses, including paper stocks, plastics and metals.
80
80
  - **Stacks.** One card to a thousand, as high as the count times the thickness, a seeded messiness.
81
81
  - **Wear.** Six grading presets, a seed, and one dial for corners, edges, surface and creases.
82
82
  - **Motion.** A pan over a tall picture, autoplay on the card in focus, a spin about the centre or a corner.
@@ -103,7 +103,7 @@ import '@johnmorrisdotca/fuda-cards/element';
103
103
  import '@johnmorrisdotca/fuda-cards/collection-element';
104
104
  import type { CardOptions } from '@johnmorrisdotca/fuda-cards';
105
105
 
106
- const options: CardOptions = { title: 'Relic', thickness: 1.5, wear: 'near-mint' };
106
+ const options: CardOptions = { title: 'Thick card', thickness: 1.5, wear: 'near-mint' };
107
107
  const card = document.createElement('fuda-card');
108
108
  card.setAttribute('title', options.title ?? '');
109
109
  card.setAttribute('thickness', String(options.thickness));
@@ -132,7 +132,7 @@ A card with a back and a thick edge, a deck, a worn card, a collection. Each of
132
132
 
133
133
  ```html
134
134
  <script type="module">import '@johnmorrisdotca/fuda-cards/element';</script>
135
- <fuda-card title="Relic" thickness="1.5"></fuda-card>
135
+ <fuda-card title="Thick card" thickness="1.5"></fuda-card>
136
136
  <fuda-card title="Deck" material="paper-310-black-core" stack="52" stack-messiness="0.3" stack-seed="7"></fuda-card>
137
137
  <fuda-card title="Rookie" wear="moderately-played" wear-seed="7"></fuda-card>
138
138
  ```
@@ -149,7 +149,7 @@ A card with a back and a thick edge, a deck, a worn card, a collection. Each of
149
149
 
150
150
  ## The card
151
151
 
152
- `<fuda-card>` has the attributes `title`, `category`, `subtitle`, `description`, `number`, `rarity`, `variant` (`classic`, `sport`, `cosmic`), `finish` (`foil`, `matte`), `thickness` (millimetres, default `0.3`), `material`, `stack`, `wear` and `flipped` (boolean). Set the element's width to scale it; it keeps the 2.5 by 3.5 proportion of a real card. The default slot accepts HTML, including an existing interactive 3D viewer: its owner handles rotation, zoom and model loading, and the card has no drag-to-flip handler. Control the reverse by adding or removing `flipped`.
152
+ `<fuda-card>` has the attributes `title`, `category`, `subtitle`, `description`, `number`, `rarity`, `variant` (`classic`, `sport`, `cosmic`), `finish` (`foil`, `matte`), `thickness` (millimetres, default `0.325`), `material`, `stack`, `wear` and `flipped` (boolean). Set the element's width to scale it; it keeps the 2.5 by 3.5 proportion of a real card. The default slot accepts HTML, including an existing interactive 3D viewer: its owner handles rotation, zoom and model loading, and the card has no drag-to-flip handler. Control the reverse by adding or removing `flipped`.
153
153
 
154
154
  ```ts
155
155
  import { cardFinishes, cardVariants } from '@johnmorrisdotca/fuda-cards';
@@ -174,18 +174,18 @@ It keeps `<fuda-card>` (300 px wide, 2.5:3.5, or whatever width your own rule gi
174
174
 
175
175
  A card turned past 90° shows its back (the navy FUDA face), never the mirrored front, and the front's Animate button cannot be seen or clicked from behind. The back is the card's own face and is shown for `flipped` too.
176
176
 
177
- The card has thickness, drawn to scale at the 63 mm wide card size: set `thickness` in millimetres (default `0.325`, a playing card's black-core stock, 13 pt, `DEFAULT_CARD_THICKNESS_MM`; `0` for a flat card; or pick a `material`, below). The edge is drawn from thin planes between the two faces, so it shows edge-on and at any angle, and it scales with the element's width (a 300px card is about 1.4px thick at the default). It is gold foil for the classic gold frame and card-stock cream for the sport and cosmic variants; override it with the `--fuda-edge` CSS custom property (any CSS background). The drop shadow is on the element itself, so a `filter` must not be added to anything between the card and its faces.
177
+ Set `thickness` in millimetres or pick a `material`. The default, `DEFAULT_CARD_THICKNESS_MM`, is 0.325 mm, based on 13 pt black-core playing-card stock. Use `thickness="0"` for a flat card. Thin planes between the two faces form the edge, which scales with the element’s width. At the default thickness, the edge of a 300 px card is about 1.5 px thick. Override the edge with the `--fuda-edge` CSS custom property, which accepts any CSS background. Apply any `filter` outside the card’s 3D scene to preserve the two faces.
178
178
 
179
179
  ```html
180
180
  <script type="module">import '@johnmorrisdotca/fuda-cards/element';</script>
181
- <fuda-card title="Relic" thickness="1.5" flipped></fuda-card>
181
+ <fuda-card title="Thick card" thickness="1.5" flipped></fuda-card>
182
182
  ```
183
183
 
184
184
  ![A card 4.5 mm thick turned to show its edge, on a phone](https://raw.githubusercontent.com/johnmorrisdotca/fuda-cards/main/docs/images/thick-phone-light.webp)
185
185
 
186
186
  ## Materials and stacks
187
187
 
188
- `material="<id>"` gives a card the thickness and edge colour of a material, each thickness read from a maker or a standard and cited: card stock at 11, 13 and 16 pt, a plastic bank-size card (0.76 mm), thick trading cards from 35 to 180 pt, a 175 pt booklet card, anodised aluminium (0.8 mm) and stainless steel (0.5 mm). `thickness` still overrides it. [docs/materials.md](docs/materials.md) lists every material, its thickness, its source and what the source says, and what was left out because it could not be sourced (a patch or relic card, for one).
188
+ `material="<id>"` gives a card the thickness and edge colour of a material, each thickness read from a maker or a standard and cited: card stock at 11, 13 and 16 pt, plastic bank-size and PVC playing cards, thick trading cards from 35 to 180 pt, a 175 pt booklet card, and aluminium, stainless steel, brass, copper and titanium. `thickness` still overrides it. [docs/materials.md](docs/materials.md) lists every material, its thickness, its source and what the source says, and what was left out because it could not be sourced (a patch or relic card, for one).
189
189
 
190
190
  `stack="52"` draws that many cards as a stack whose height is the count times a card's thickness (52 cards of the black-core playing-card stock are 16.9 mm). The count is free, 1 to 1000; the Card Studio has presets with a source (52 playing cards, 52 and two jokers, a 60-card Pokémon deck, a booster pack of 10). Turn the card to see the stack's edge, with a line for each card in the material's colour.
191
191
 
@@ -275,20 +275,11 @@ All of it is in [Motion and rotation](https://github.com/johnmorrisdotca/fuda-ca
275
275
 
276
276
  ## Live 3D in a card
277
277
 
278
- A card can hold a live 3D item (a rocket, a device) that turns while the card is in focus. **Only one card is ever live, on one WebGL context for the whole page; every other card is a picture, and a page of pictures loads no 3D code at all.** `three` is yours (an optional peer dependency) and loads at the first focus:
279
-
280
- ```ts no-check
281
- import { createLiveCards } from '@johnmorrisdotca/fuda-cards/live-3d';
282
-
283
- const live = createLiveCards({ load: () => import('three') });
284
- live.add(card, { key: 'cube', build({ three, assets, width, height }) { /* scene, camera, object */ } }, { still: card.querySelector('img') });
285
- ```
286
-
287
- On a `<fuda-collection>`: `collection.live = { cards: live, item: (card) => itemFor(card) }`. Budgets, the focus rules and what cannot be proved in a test are in [docs/live-3d.md](docs/live-3d.md) and the [live 3D guide](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/live-3d.md); try it in the [live demo](https://johnmorrisdotca.github.io/fuda-cards/demo/live-3d.html).
278
+ A card can hold a live 3D item that turns while it has focus. One `createLiveCards({ load: () => import('three') })` instance gives the page a shared WebGL context. With a still image supplied for each card, the 3D code waits for the first focus. Use `live.add(card, item, { still })` for a single card or assign `collection.live` for a collection. The guide has a complete scene and both integrations. [Live 3D guide](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/live-3d.md) · [Rocket demo](https://johnmorrisdotca.github.io/fuda-cards/demo/live-3d.html)
288
279
 
289
280
  ## The collection viewer
290
281
 
291
- Import `@johnmorrisdotca/fuda-cards/collection-element` to register the element, then set its `cards` property to an array of `{ id, name, image, backImage?, kind? }` (`kind` is `"card"`, the default, or `"object"`: a picture of a thing that is not a card, such as a games console, which has no back and no thickness and so never turns over). Image URLs are loaded by the viewer's browser. `id` is optional on input (the position is used if omitted); IDs must be unique.
282
+ Import `@johnmorrisdotca/fuda-cards/collection-element` to register the element. Set its `cards` property to an array or an object with a `cards` array. Each record needs a `name` and `image`. Optional fields include `backImage`, `metadata` and `kind`. Use `kind: 'object'` for a picture of a console or trophy that should stay face up. Ids must be unique, and the element uses the zero-based position when an id is omitted.
292
283
 
293
284
  ```html
294
285
  <fuda-collection view="deck"></fuda-collection>
@@ -372,19 +363,19 @@ export function Cards({ cards }) {
372
363
  }
373
364
  ```
374
365
 
375
- Vue 3 (`:cards.prop`), Svelte and Angular (`CUSTOM_ELEMENTS_SCHEMA`) are in [Frameworks](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/frameworks.md), and server rendering in [TypeScript and Node](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/typescript-and-node.md). The integrations were bundled and exercised in Chromium with React 19, Angular 19, Vue 3 and Svelte 4; there are no framework wrappers yet.
366
+ The framework guide covers Vue's `:cards.prop`, Svelte and Angular's `CUSTOM_ELEMENTS_SCHEMA`. The TypeScript guide covers server rendering. [Frameworks](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/frameworks.md) · [TypeScript and Node](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/typescript-and-node.md)
376
367
 
377
368
  ## Demos
378
369
 
379
370
  [Open the Fuda Cards demos](https://johnmorrisdotca.github.io/fuda-cards/). The Card Studio, the collection views, the Pokémon binder, the vintage cards and the live 3D page are built together for GitHub Pages. Run `pnpm site` to build the static site in `site/`; serve that directory to review it. The Pages workflow runs the checks and deploys the site on pushes to `main`.
380
371
 
381
- **Builder.** [`demo/builder.html`](https://johnmorrisdotca.github.io/fuda-cards/demo/builder.html) is a page to choose a card or a collection, see it live and copy the HTML, React or Vue code for it. Every choice is a row of buttons, and the setup is kept in the link.
372
+ **Builder.** Choose a card or collection, preview it and copy HTML, iframe, ES module, React, Vue, Angular or Svelte code. The link preserves the settings. [Open the Builder](https://johnmorrisdotca.github.io/fuda-cards/builder.html)
382
373
 
383
374
  **Pokémon binder.** `demo/tcgdex.html` browses the Pokémon Base Set as full-card images supplied by [TCGdex](https://tcgdex.dev/). Search by name or number, change pages and select a card to enlarge it. This standalone demo fetches public set data and remote images in the browser, so it needs an internet connection. No API key, personal collection storage, or image hosting by Fuda is involved. Card images and metadata are provided by TCGdex; consult provider terms before deploying a public demo.
384
375
 
385
376
  **Vintage cards.** `demo/vintage.html` shows real 1909 to 1911 hockey and baseball cards whose pictures are in the public domain (Wikimedia Commons and The Met's Open Access, each card's rights checked one by one), loaded from their sources and never shipped; [docs/card-images.md](docs/card-images.md) says what card-picture sources exist, their terms and what was not used.
386
377
 
387
- **Demo collectors.** The collection demo has three fictional users, Alex, Sam and Riley, with different collections: Alex has 25 Base Set cards (a 5 by 5 page), Sam a pack of 10 and Riley 5 consoles. They are local demo profiles, not accounts. The demo can save, load and export named collections in the current browser's localStorage, scoped to the selected profile; this is not account-based sync or a backup.
378
+ **Demo collectors.** Alex has 25 Base Set cards, Sam has 10 and Riley has 5 consoles. The demo can import and export JSON and save or load named collections in the current browser's localStorage for each fictional profile. [Open the collection demo](https://johnmorrisdotca.github.io/fuda-cards/demo/collections-component.html)
388
379
 
389
380
  <picture>
390
381
  <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/fuda-cards/main/docs/images/vintage-desk-dark.webp">
@@ -414,7 +405,7 @@ The display choices are a radio group with arrow keys; a card in a display is a
414
405
  - **Tested in headless Chromium only,** drawing in software, at a desk and a phone size. A real phone, Safari and Firefox are not tested, and nothing measures a real GPU.
415
406
  - **Wear** is not drawn on the images of a collection or on the cards under a stack's top card.
416
407
  - **Images are yours.** Fuda hosts none; a missing image or failed request is reported in the demo's page.
417
- - **Not built yet:** framework wrappers, scanned-card and JSON importers, search and filters, editing, large-collection virtualisation and accessibility validation by assistive-technology testing. [docs/feature-roadmap.md](docs/feature-roadmap.md) says what is partial and what is not started.
408
+ - Scanned-card import, collection-wide filters, editing, large-collection virtualisation and assistive-technology testing are on the roadmap. [Feature roadmap](docs/feature-roadmap.md)
418
409
 
419
410
  ## Browser and runtime support
420
411
 
@@ -437,19 +428,19 @@ The elements' own words (button names, labels) are English today. The documentat
437
428
 
438
429
  ## Roadmap
439
430
 
440
- Open work, in order of what a user would notice: framework wrappers; JSON, API and scanned-card importers and filters; the Hako Devices and Uchusen Rockets viewers inside card artwork; researched card designs for the recognisable families of the past century; configurable case geometry; large-collection virtualisation; and testing on a real phone, Safari and Firefox. The detail, with each item's status, is [docs/feature-roadmap.md](docs/feature-roadmap.md).
431
+ Open work includes API and scanned-card importers, collection filters, live Hako devices, researched period designs, configurable case geometry, large-collection virtualisation and testing in more browsers and on real phones. The live 3D demo already shows Uchusen Rockets in framed cards and in a binder. [Feature roadmap](docs/feature-roadmap.md)
441
432
 
442
433
  ## Architecture
443
434
 
444
- `element.js` is the card and loads the wear, pile and stack code only when a card asks for them; `collection-element.js` draws the ten displays; `live-3d.js` is the focus policy for one WebGL context. A page pays only for what it uses. The files and their sizes are in the [architecture guide](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/architecture.md).
435
+ `element.js` is the card and loads the wear and pile code when a card asks for them; `collection-element.js` draws the ten displays; `live-3d.js` is the focus policy for one WebGL context. A page pays only for what it uses. The files and their sizes are in the [architecture guide](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/architecture.md).
445
436
 
446
437
  ## Documentation
447
438
 
448
439
  | Guide | What it covers |
449
440
  |---|---|
450
441
  | [Getting started](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/getting-started.md) | A first card, a stack, a worn card and a collection |
451
- | [The card element](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/card-element.md) | Every attribute, property and CSS variable |
452
- | [Materials and stacks](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/materials-and-stacks.md) | Thickness, thirteen sourced materials, stacks |
442
+ | [The card element](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/card-element.md) | Attributes, properties, CSS variables and narrow vintage formats |
443
+ | [Materials and stacks](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/materials-and-stacks.md) | Thickness, seventeen sourced materials, stacks |
453
444
  | [Wear](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/wear.md) | Presets, the seed, wear as data |
454
445
  | [Motion and rotation](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/motion-and-spin.md) | Pan, autoplay, spin, driving the turn |
455
446
  | [Collections](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/collections.md) | The element, the input, kinds, ten displays |
@@ -1,4 +1,4 @@
1
- import { type CollectionCard } from "./collection.js";
1
+ import { type CollectionCard, type CollectionCardInput } from "./collection.js";
2
2
  import type { LiveCards, LiveItem } from "./live-3d.js";
3
3
  /**
4
4
  * 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.
@@ -8,7 +8,7 @@ import type { LiveCards, LiveItem } from "./live-3d.js";
8
8
  * import type { CollectionLive } from "@johnmorrisdotca/fuda-cards/collection-element";
9
9
  * import { createLiveCards } from "@johnmorrisdotca/fuda-cards/live-3d";
10
10
  *
11
- * const live: CollectionLive = { cards: createLiveCards({ load: () => import("three") }) as never, item: () => undefined };
11
+ * const live: CollectionLive = { cards: createLiveCards({ load: () => import("three") }), item: () => undefined };
12
12
  * console.log(typeof live.item);
13
13
  * ```
14
14
  */
@@ -28,7 +28,7 @@ export interface CollectionLive {
28
28
  *
29
29
  * const collection = document.createElement("fuda-collection") as FudaCollection;
30
30
  * collection.setAttribute("view", "binder");
31
- * collection.cards = [{ id: "1", name: "Explorer One", image: "one.jpg" }];
31
+ * collection.cards = { cards: [{ name: "Explorer One", image: "one.jpg" }] };
32
32
  * document.body.append(collection);
33
33
  * ```
34
34
  */
@@ -36,8 +36,12 @@ export declare class FudaCollection extends HTMLElement {
36
36
  private liveSetup;
37
37
  private liveOff;
38
38
  static get observedAttributes(): string[];
39
- set cards(value: CollectionCard[]);
40
- get cards(): CollectionCard[];
39
+ set cards(value: readonly CollectionCardInput[] | {
40
+ readonly cards: readonly CollectionCardInput[];
41
+ });
42
+ get cards(): readonly CollectionCardInput[] | {
43
+ readonly cards: readonly CollectionCardInput[];
44
+ };
41
45
  /** 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. */
42
46
  set live(value: CollectionLive | null);
43
47
  get live(): CollectionLive | null;
@@ -20,7 +20,7 @@ import { normalizeLanding, timing } from "./pile.js";
20
20
  *
21
21
  * const collection = document.createElement("fuda-collection") as FudaCollection;
22
22
  * collection.setAttribute("view", "binder");
23
- * collection.cards = [{ id: "1", name: "Explorer One", image: "one.jpg" }];
23
+ * collection.cards = { cards: [{ name: "Explorer One", image: "one.jpg" }] };
24
24
  * document.body.append(collection);
25
25
  * ```
26
26
  */
@@ -80,6 +80,20 @@ export interface CollectionCard {
80
80
  kind?: CollectionKind;
81
81
  metadata?: CollectionMetadata;
82
82
  }
83
+ /**
84
+ * A card supplied by a caller. The parser uses the item's position when its id is omitted.
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * import { parseCollection, type CollectionCardInput } from "@johnmorrisdotca/fuda-cards/collection";
89
+ *
90
+ * const card: CollectionCardInput = { name: "Explorer One", image: "front.jpg" };
91
+ * console.log(parseCollection([card])[0].id); // 0
92
+ * ```
93
+ */
94
+ export type CollectionCardInput = Omit<CollectionCard, "id"> & {
95
+ id?: string;
96
+ };
83
97
  /**
84
98
  * Whether an item is a card: anything that does not say it is an object. Only a card turns, has a back and lands turned over.
85
99
  *
@@ -81,7 +81,7 @@ export function parseCollection(input) {
81
81
  if (!Array.isArray(value))
82
82
  throw new Error("Collection must be an array or an object containing a cards array.");
83
83
  const ids = new Set();
84
- return value.map((item, i) => {
84
+ return Array.from(value, (item, i) => {
85
85
  if (!item || typeof item !== "object")
86
86
  throw new Error(`Card ${i + 1} must be an object.`);
87
87
  const c = item;
@@ -23,7 +23,7 @@ export interface CardMaterialSource {
23
23
  * import { cardMaterials, type CardMaterialGroup } from "@johnmorrisdotca/fuda-cards";
24
24
  *
25
25
  * const group: CardMaterialGroup = "metal";
26
- * console.log(cardMaterials.filter((material) => material.group === group).map((material) => material.id)); // [ 'aluminium-0.8', 'steel-0.5' ]
26
+ * console.log(cardMaterials.filter((material) => material.group === group).map((material) => material.id)); // [ 'aluminium-0.8', 'steel-0.5', 'brass-0.5', 'copper-0.5', 'titanium-0.8' ]
27
27
  * ```
28
28
  */
29
29
  export type CardMaterialGroup = "paper" | "plastic" | "thick-card" | "metal";
package/dist/materials.js CHANGED
@@ -89,6 +89,18 @@ export const cardMaterials = [
89
89
  says: '"All card sizes have a thickness of 760±80 μm." Payment cards are generally PVC (Wikipedia, Payment card).',
90
90
  },
91
91
  },
92
+ {
93
+ id: "plastic-pvc-0.31",
94
+ name: "Matte PVC playing-card stock",
95
+ group: "plastic",
96
+ thicknessMm: 0.31,
97
+ edge: "#f2f2ef",
98
+ source: {
99
+ label: "Kuo Kau Paper Products, Custom Plastic Poker Cards",
100
+ url: "https://www.kkplayingcard.com/en/product-713063/Custom-Plastic-Playing-Cards-with-P107-Poker-Size-Plastic-Box-Chocolate-Brand-Promotional-Tool-CPA027P107-A-CPA031P107-A.html",
101
+ says: "The maker lists 0.31 mm white PVC with a matte finish.",
102
+ },
103
+ },
92
104
  thick(35, "35pt-uv-one-touch-magnetic-holders-5ct"),
93
105
  thick(55, "55pt-uv-one-touch-magnetic-holder"),
94
106
  thick(75, "75pt-uv-one-touch-magnetic-holder"),
@@ -114,9 +126,9 @@ export const cardMaterials = [
114
126
  thicknessMm: 0.8,
115
127
  edge: "#c9ced4",
116
128
  source: {
117
- label: "ebamaz anodised aluminium business card blank, 86 x 54 x 0.8 mm (Wood Art Supply listing)",
118
- url: "https://woodartsupply.com/products/ebamaz-metal-business-cards-anodized-aluminum-plaque-plate-86x54x0-8mm-silver-blank-10pcs",
119
- says: '"Material: Anodized Aluminum", "Size: 86X54X0.8mm"',
129
+ label: "Foison Metal, Blank Metal Business Cards",
130
+ url: "https://www.foismetal.com/product/blank-metal-business-cards-wholesale/",
131
+ says: "The maker lists anodised aluminium among the options for its 85 × 54 × 0.8 mm blanks.",
120
132
  },
121
133
  },
122
134
  {
@@ -131,8 +143,47 @@ export const cardMaterials = [
131
143
  says: '"our standard metal business card thickness is 0.5mm"; "A 0.5mm stainless steel business card"',
132
144
  },
133
145
  },
146
+ {
147
+ id: "brass-0.5",
148
+ name: "Brass card, 0.5 mm",
149
+ group: "metal",
150
+ thicknessMm: 0.5,
151
+ edge: "#b59a52",
152
+ source: {
153
+ label: "Pure Metal Cards, Standard Brass Cards",
154
+ url: "https://www.puremetalcards.com/order-cards/brass-gold-cards/standard-brass-gold-cards/",
155
+ says: "The maker lists brass as the metal and offers a 0.5 mm thickness.",
156
+ },
157
+ },
158
+ {
159
+ id: "copper-0.5",
160
+ name: "Copper card, 0.5 mm",
161
+ group: "metal",
162
+ thicknessMm: 0.5,
163
+ edge: "#bd7757",
164
+ source: {
165
+ label: "Pure Metal Cards, Copper Brushed Cards",
166
+ url: "https://www.puremetalcards.com/order-cards/copper-cards/copper-brushed-cards/",
167
+ says: "The maker offers brushed copper cards in 0.5 mm.",
168
+ },
169
+ },
170
+ {
171
+ id: "titanium-0.8",
172
+ name: "Titanium card, 0.8 mm",
173
+ group: "metal",
174
+ thicknessMm: 0.8,
175
+ edge: "#9b9fa6",
176
+ source: {
177
+ label: "Pure Metal Cards, Brushed Titanium Cards",
178
+ url: "https://www.puremetalcards.com/order-cards/titanium-cards/brushed-titanium-cards/",
179
+ says: "The maker specifies 0.8 mm for brushed titanium cards.",
180
+ },
181
+ },
134
182
  ];
135
- const wikiDeck = { label: "Wikipedia, Playing card", url: "https://en.wikipedia.org/wiki/Playing_card" };
183
+ const playingCards = {
184
+ label: "Bicycle Cards, Basics of Poker",
185
+ url: "https://bicyclecards.com/how-to-play/basics-of-poker",
186
+ };
136
187
  const wikiPokemon = {
137
188
  label: "Wikipedia, Pokémon Trading Card Game",
138
189
  url: "https://en.wikipedia.org/wiki/Pok%C3%A9mon_Trading_Card_Game",
@@ -152,15 +203,15 @@ export const stackPresets = [
152
203
  id: "deck-52",
153
204
  name: "Playing cards, 52",
154
205
  count: 52,
155
- source: { ...wikiDeck, says: '"The 52-card deck is the most popular deck"' },
206
+ source: { ...playingCards, says: "The standard poker pack has 52 cards." },
156
207
  },
157
208
  {
158
209
  id: "deck-54",
159
210
  name: "Playing cards with two jokers, 54",
160
211
  count: 54,
161
212
  source: {
162
- ...wikiDeck,
163
- says: 'commercial packs "often include between one and six jokers, most often two", so 52 + 2',
213
+ ...playingCards,
214
+ says: "A 52-card pack with two added jokers has 54 cards.",
164
215
  },
165
216
  },
166
217
  {
@@ -173,7 +224,11 @@ export const stackPresets = [
173
224
  id: "pokemon-booster",
174
225
  name: "Booster pack, about 10",
175
226
  count: 10,
176
- source: { ...wikiPokemon, says: '"a collector can pull 10 cards in total" from a booster pack' },
227
+ source: {
228
+ label: "The Pokémon Company, Sun & Moon—Forbidden Light release",
229
+ url: "https://press.pokemon.com/en/releases/LATEST-EXPANSION-OF-THE-POKEMON-TRADING-CARD-GAME-SUN-MOONFORBIDDEN-LI",
230
+ says: "A booster from this expansion has 10 expansion cards plus a Basic Energy card. The preset counts the expansion cards.",
231
+ },
177
232
  },
178
233
  ];
179
234
  /**
package/dist/version.d.ts CHANGED
@@ -8,4 +8,4 @@
8
8
  * console.log(/^\d+\.\d+\.\d+$/.test(VERSION)); // true
9
9
  * ```
10
10
  */
11
- export declare const VERSION = "0.11.0";
11
+ export declare const VERSION = "0.12.0";
package/dist/version.js CHANGED
@@ -8,4 +8,4 @@
8
8
  * console.log(/^\d+\.\d+\.\d+$/.test(VERSION)); // true
9
9
  * ```
10
10
  */
11
- export const VERSION = "0.11.0";
11
+ export const VERSION = "0.12.0";
package/docs/API.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @johnmorrisdotca/fuda-cards API reference
2
2
 
3
- Every export of @johnmorrisdotca/fuda-cards 0.11.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).
3
+ Every export of @johnmorrisdotca/fuda-cards 0.12.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
4
 
5
5
  ## `@johnmorrisdotca/fuda-cards`
6
6
 
@@ -95,7 +95,7 @@ const stackPresets: readonly StackPreset[];
95
95
  *constant*. The version of this package, the same as `package.json`'s (a test holds the two together).
96
96
 
97
97
  ```ts
98
- const VERSION = "0.11.0";
98
+ const VERSION = "0.12.0";
99
99
  ```
100
100
 
101
101
  ### wearLayout
@@ -572,7 +572,7 @@ interface LiveScene extends Scene3D {
572
572
 
573
573
  ## `@johnmorrisdotca/fuda-cards/collection`
574
574
 
575
- 10 values and 6 types.
575
+ 10 values and 7 types.
576
576
 
577
577
  ```js
578
578
  import { collectionKinds, collectionViewAliases, collectionViews, deckLandings, fanLayout, isCard, movePage, normalizeLanding, parseCollection, randomDrawIndex } from '@johnmorrisdotca/fuda-cards/collection';
@@ -679,6 +679,16 @@ interface CollectionCard {
679
679
  }
680
680
  ```
681
681
 
682
+ ### CollectionCardInput
683
+
684
+ *type*. A card supplied by a caller. The parser uses the item's position when its id is omitted.
685
+
686
+ ```ts
687
+ type CollectionCardInput = Omit<CollectionCard, "id"> & {
688
+ id?: string;
689
+ };
690
+ ```
691
+
682
692
  ### CollectionKind
683
693
 
684
694
  *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
@@ -752,8 +762,12 @@ class FudaCollection extends HTMLElement {
752
762
  private liveSetup;
753
763
  private liveOff;
754
764
  static get observedAttributes(): string[];
755
- set cards(value: CollectionCard[]);
756
- get cards(): CollectionCard[];
765
+ set cards(value: readonly CollectionCardInput[] | {
766
+ readonly cards: readonly CollectionCardInput[];
767
+ });
768
+ get cards(): readonly CollectionCardInput[] | {
769
+ readonly cards: readonly CollectionCardInput[];
770
+ };
757
771
  /** 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. */
758
772
  set live(value: CollectionLive | null);
759
773
  get live(): CollectionLive | null;
@@ -1,11 +1,11 @@
1
1
  # Collection displays
2
2
 
3
- Fuda supplies reusable frames for a caller's cards and reusable ways to display collections on websites. The hosting site supplies the card data and artwork or interactive content. Initial versions of twelve layouts now exist in `<fuda-collection>`. They are prototypes; the detailed capabilities below remain design goals unless described as implemented in the README.
3
+ Fuda supplies reusable card frames and collection displays for websites. The host supplies the data and artwork. `<fuda-collection>` offers ten displays. The later sections describe both implemented features and design goals. [Current feature roadmap](feature-roadmap.md)
4
4
 
5
5
  ## Choosing a display, piles, the fan and animation (0.6.0, 0.7.0)
6
6
 
7
- - **Display buttons.** All twelve displays are buttons on screen at once, in a row that spans the width, each with a small picture of its layout. No drop-down. At least 48 px high; 4 to a row on a phone, 6 on a desk; arrow keys move the choice; light and dark follow the reader.
8
- - **Piles (0.7.0).** The Overlapping Deck, Random Draw, the Jukebox Carousel and the Flip Tower (the last three drew a pile of three cards) are the same pile with their own look. Every pile turns in 3D (angle, tilt, Auto-turn), fans open and closed, and has a card taken off it. `<fuda-card stack>` is a pile too. Rolodex and Spotlight spread their cards and are carousels, not piles.
7
+ - **Display buttons.** The ten displays have tiles with layout illustrations. Arrow keys move the choice, and the colours follow the reader's light or dark setting.
8
+ - **Piles.** Overlapping Deck, Random Draw and `<fuda-card stack>` can turn, fan open and send a card to a side pile. Rolodex and Spotlight show staggered cards as carousels.
9
9
  - **Deck.** A deck and a pile. Next flips the top card off to the pile on the deck's other side, Previous brings it back. The landing is a choice: still facing up, or turned over (a sideways turn about the card's vertical axis, like turning a page, showing the back image or the package's own back). A card never lands with its picture on its head; the 0.6.0 value `upside-down` still works and means turned over. One element flies, so a card is never drawn twice.
10
10
  - **Fan.** Every pile fans open and closed with a control right under the view: up to ten cards in an arc, most of each card showing, closing back exactly. `view="fan"` is the same pile with only the fan. In the address (`?fan=open`).
11
11
  - **Animate (0.7.0).** `animate="off"` and `speed` for every move: the fan, a card taken off, Next in the carousels, a binder page turn, a switch of display, a pan to the card in the wall, story and atlas. On when the attribute is missing; reduced motion always wins. One shared timing, CSS transforms and one-shot animations, nothing running when idle. Moves with it on and off end in exactly the same place.
@@ -22,7 +22,7 @@ An item says what it is with `kind` (`"card"`, the default, or `"object"`; see `
22
22
 
23
23
  ## Zoom, Fit and move (every view)
24
24
 
25
- Every view has the shared view controls (`@johnmorrisdotca/kazoku-ui`) on the view: zoom out, the zoom as a number, zoom in, **Fit**, and, under **More**, an arrow pad. A double press on the view goes to 2 times. Ctrl or Command with the wheel, a trackpad pinch and a two-finger pinch zoom about the pointer; zoomed in, a drag or the wheel moves the view. The views are flat, so none turns in 3D and the angle, tilt and auto-turn controls are hidden.
25
+ The shared `@johnmorrisdotca/kazoku-ui` controls zoom and pan every collection display. The bar offers zoom out, the current zoom, zoom in and Fit. More shows the arrow pad. A double press goes to 2 times, and Ctrl or Command with the wheel or a pinch zooms about the pointer. Pile displays with cards also offer angle, tilt and Auto-turn.
26
26
 
27
27
  - The controls take every press on the view, including one that starts on a card, so a drag or a pinch works over the cards. A tap that did not move is passed to the card as a click, and the keyboard still opens a focused card with Enter.
28
28
  - **Fit** shows every card the view draws, at most at natural size. The wall, story and atlas open at half size or larger and start at their first card; the other views open at Fit. Zoom out goes to 0.4 of Fit.
@@ -1,12 +1,12 @@
1
1
  # Collection input
2
2
 
3
- Fuda should display real collections as well as cards generated from other projects. The collection viewer accepts a JSON array or an object containing a cards array. The broader integration features below remain planned.
3
+ The collection viewer accepts a JavaScript array or an object containing a `cards` array. To use a JSON file, parse it and pass its result to `parseCollection` or assign it to the element's `cards` property.
4
4
 
5
5
  ## Sources
6
6
 
7
7
  - A JSON file, a JavaScript array or object supplied by the host, and data fetched from an API by the host.
8
8
  - Adapters can map different external APIs and collection exports into Fuda's common card format. The host controls authentication, fetch, refresh and error handling; Fuda does not require a server or assume an external service.
9
- - Treat image and asset URLs as supplied by the host, and give useful feedback when a file, URL, or field is missing. Support partial data and optional front and back images.
9
+ - Supply a `name` and front `image` URL for each record. The browser requests the images, and the displays can show a fallback when a request fails. The reverse image, `backImage`, is optional.
10
10
 
11
11
  ## Card data
12
12
 
@@ -32,9 +32,9 @@ An example supported collection format:
32
32
  - **What an item is.** `kind` is `"card"` (the default: a collection written without it is all cards, as before) or `"object"`. A card is flat and thin with a back, so it turns in 3D, can be seen from behind and lands turned over when taken off a pile. An object is a picture of a thing that is not a card (a games console, a trophy): it has no back and no thickness, so it never turns over, is never seen edge-on or from behind, and always lands facing up. No angle, tilt, Auto-turn or "turned over" landing is offered for a collection with no card in it, and an angle in the address is dropped. In a mixed collection the controls are there for the cards, and the objects stay square to the reader. Objects can still be fanned open (a flat layout) and taken off a pile (they fly across and land facing up). A real 3D object would be a third kind, once an item can carry one.
33
33
  - Represent photographed or scanned cards as full-card front and back images, so collectors can display what they already own. Alternatively, use a Fuda frame with a separate image or host-provided interactive artwork in its window.
34
34
  - Keep collector details optional: set, year, card number, edition, condition, grade, quantity, notes, and other metadata. Do not assume every item has a market price or grade.
35
- - Provide stable IDs for selection and navigation; validate malformed input and report errors without discarding valid cards.
35
+ - Use unique ids to identify cards. Without an id, the parser uses the item's zero-based position. `parseCollection` validates the whole input before returning a normalised array, and a failed assignment keeps the previous collection.
36
36
  - Allow host-supplied visual content, including interactive 3D elements, in addition to serializable image references; JSON alone cannot contain a live 3D viewer.
37
- - Each collection presentation (binder, case, jukebox, rotating index, random viewer) consumes the same normalized collection and can expose filtering and selection to the host.
37
+ - All ten displays consume the same normalised collection. The Random Draw view filters by name.
38
38
 
39
- No accounts, collection storage, third-party integrations, importers, or synchronization are implemented yet. Avoid requiring accounts or uploading a collection to Fuda merely to display it.
39
+ The collection demo imports and exports JSON and saves named collections in browser-local storage. Hosts provide their own accounts, storage and sync when needed.
40
40
 
@@ -1,6 +1,6 @@
1
1
  # Framework integration
2
2
 
3
- Build with `pnpm build`, then install or link the package in the host application. The package is not published yet. Import each element's registration entry once in browser code. `cards` is a JavaScript **property**, not an HTML attribute: assign an array of `{ id, name, image, backImage? }` objects. Image URLs are supplied by the host. Equivalent integrations were bundled and exercised in Chromium using React 19, Angular 19, Vue 3 and Svelte 4; check your framework version and server-rendering setup.
3
+ Install `@johnmorrisdotca/fuda-cards` in the host application. Import the element's registration entry once in browser code. Assign the collection to its JavaScript `cards` property. The [frameworks guide](guides/frameworks.md) covers the current built examples and server rendering.
4
4
 
5
5
  ## Plain HTML
6
6
 
@@ -12,16 +12,16 @@ Fuda is plain TypeScript compiled to ES modules, with no framework and no 3D eng
12
12
  | Entry | File | What it is | Size (raw, gzip -9) |
13
13
  |---|---|---|---|
14
14
  | `@johnmorrisdotca/fuda-cards` | `dist/index.js` | Types and tables: variants, finishes, materials, stack presets, the stack and wear maths. No DOM. | 0.4 KB, plus its modules |
15
- | `.../element` | `dist/element.js` | Registers `<fuda-card>`. | 21.4 KB, 6.5 KB |
16
- | `.../collection` | `dist/collection.js` | The collection's data rules: `parseCollection`, views, kinds, the fan's layout. No DOM. | 4.7 KB, 1.6 KB |
17
- | `.../collection-element` | `dist/collection-element.js` | Registers `<fuda-collection>`. | 45.1 KB, 13.4 KB |
18
- | `.../live-3d` | `dist/live-3d.js` | The focus policy for live 3D cards. | 7.5 KB, 2.3 KB |
15
+ | `.../element` | `dist/element.js` | Registers `<fuda-card>`. | 16.5 KB, 4.9 KB |
16
+ | `.../collection` | `dist/collection.js` | The collection's data rules: `parseCollection`, views, kinds, the fan's layout. No DOM. | 8.1 KB, 2.6 KB |
17
+ | `.../collection-element` | `dist/collection-element.js` | Registers `<fuda-collection>`. | 15.0 KB, 4.4 KB |
18
+ | `.../live-3d` | `dist/live-3d.js` | The focus policy for live 3D cards. | 9.0 KB, 2.7 KB |
19
19
 
20
20
  ## The modules behind them
21
21
 
22
22
  - **`element.ts`** draws the card: two faces, an edge made of thin planes, the art slot, the Animate button and the pan, the spin. It imports `materials.ts` and `stack.ts`, and loads the rest on demand. The class it registers, `FudaCard`, is exported too, for a subclass or a type.
23
- - **`wear.ts`** (17 KB) is a module of its own, loaded with `import()` only when a card has a `wear` attribute. A perfect card is drawn exactly as before.
24
- - **`pile-card.ts`** (13.7 KB) holds the fan, the take-off and the side pile for `<fuda-card stack>`, loaded only when a card asks for `fan`, `taken-off` or `pile-controls`.
23
+ - **`wear.ts`** (20.6 KB) is a module of its own, loaded with `import()` only when a card has a `wear` attribute. A perfect card is drawn exactly as before.
24
+ - **`pile-card.ts`** (14.3 KB) holds the fan, the take-off and the side pile for `<fuda-card stack>`, loaded only when a card asks for `fan`, `taken-off` or `pile-controls`.
25
25
  - **`pile.ts`** is what every pile shares: the landing, the fan layout and the timing (`animate`, `speed`, reduced motion). Both the card and the collection use it, so a pile behaves the same everywhere.
26
26
  - **`stack.ts`** lays the cards under the top one from a seed (a small seeded generator, mulberry32), the same way each time.
27
27
  - **`materials.ts`** is the table of sourced thicknesses and the stack presets.
@@ -35,7 +35,7 @@ import { cardMaterials, stackLayout, wearLayout, wearLevels } from '@johnmorrisd
35
35
 
36
36
  const levels = wearLevels({ wear: 'damaged' });
37
37
  console.log(cardMaterials.length, stackLayout(11).length, Boolean(levels && wearLayout(levels, 1)));
38
- // 13 10 true
38
+ // 17 10 true
39
39
  ```
40
40
 
41
41
  ## Drawing
@@ -50,4 +50,4 @@ The art is kept hidden until the card has a size on screen and every slotted ima
50
50
 
51
51
  ## Tests
52
52
 
53
- `pnpm test` runs unit tests on the tables and the rules. `pnpm test:e2e` drives headless Chromium, in software, at a desk and a phone size, one file at a time. Both are part of `pnpm check` and the release. See [Development](../../README.md#development).
53
+ `pnpm test` runs unit tests on the tables and the rules. `pnpm test:e2e` drives headless Chromium, in software, at a desk and a phone size, one file at a time. `pnpm check` includes the unit tests. CI runs the browser suite separately. See [Development](../../README.md#development).
@@ -2,7 +2,7 @@
2
2
  title: Bundlers
3
3
  section: how-to
4
4
  order: 10
5
- description: Use the card with Vite or webpack: import the element once, in code that runs in the browser, and build with nothing more to configure.
5
+ description: "Use the card with Vite or webpack: import the element once, in code that runs in the browser, and build with nothing more to configure."
6
6
  ---
7
7
 
8
8
  A bundler resolves everything from `node_modules`. Import `@johnmorrisdotca/fuda-cards/element` (and `/collection-element` for the collection) once, anywhere that runs in the browser. The package marks its element files as having side effects, so a bundler keeps the import even though nothing is used from it. Both examples are built by `pnpm test:usage` from the package as npm packs it, and the page they make is opened.
@@ -57,4 +57,4 @@ export default {
57
57
 
58
58
  ## What you get
59
59
 
60
- The element's modules for stacks, wear and piles are loaded only when a card asks for one, so a plain card costs little. The sizes of every entry point are in [Architecture](architecture.md).
60
+ The element loads wear and pile rendering when a card uses them. The standard card module imports the stack layout helpers. The sizes of every entry point are in [Architecture](architecture.md).