@johnmorrisdotca/fuda-cards 0.10.1 → 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.
Files changed (96) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE.md +16 -0
  3. package/README.md +106 -33
  4. package/dist/binder.d.ts +4 -6
  5. package/dist/binder.js +32 -23
  6. package/dist/card-markup.d.ts +2 -0
  7. package/dist/card-markup.js +59 -0
  8. package/dist/card-options.d.ts +131 -0
  9. package/dist/card-options.js +48 -0
  10. package/dist/card-styles.d.ts +2 -0
  11. package/dist/card-styles.js +314 -0
  12. package/dist/choice.d.ts +1 -1
  13. package/dist/choice.js +27 -23
  14. package/dist/collection-address.d.ts +8 -0
  15. package/dist/collection-address.js +52 -0
  16. package/dist/collection-binder-view.d.ts +9 -0
  17. package/dist/collection-binder-view.js +123 -0
  18. package/dist/collection-controls.d.ts +2 -0
  19. package/dist/collection-controls.js +143 -0
  20. package/dist/collection-deck.d.ts +11 -0
  21. package/dist/collection-deck.js +165 -0
  22. package/dist/collection-dialog.d.ts +2 -0
  23. package/dist/collection-dialog.js +28 -0
  24. package/dist/collection-element.d.ts +36 -67
  25. package/dist/collection-element.js +283 -484
  26. package/dist/collection-host.d.ts +5 -0
  27. package/dist/collection-host.js +1 -0
  28. package/dist/collection-icons.d.ts +3 -0
  29. package/dist/collection-icons.js +19 -0
  30. package/dist/collection-motion.d.ts +11 -0
  31. package/dist/collection-motion.js +72 -0
  32. package/dist/collection-styles.d.ts +4 -0
  33. package/dist/collection-styles.js +336 -0
  34. package/dist/collection-views.d.ts +8 -0
  35. package/dist/collection-views.js +8 -0
  36. package/dist/collection.d.ts +154 -11
  37. package/dist/collection.js +140 -34
  38. package/dist/element-define.d.ts +2 -0
  39. package/dist/element-define.js +3 -0
  40. package/dist/element.d.ts +20 -1
  41. package/dist/element.js +289 -98
  42. package/dist/index.d.ts +9 -52
  43. package/dist/index.js +5 -5
  44. package/dist/live-3d.d.ts +87 -4
  45. package/dist/live-3d.js +120 -52
  46. package/dist/materials.d.ts +117 -6
  47. package/dist/materials.js +246 -28
  48. package/dist/motion.d.ts +2 -0
  49. package/dist/motion.js +4 -0
  50. package/dist/pile-card.js +138 -91
  51. package/dist/pile.d.ts +61 -8
  52. package/dist/pile.js +89 -29
  53. package/dist/stack.d.ts +42 -6
  54. package/dist/stack.js +28 -3
  55. package/dist/version.d.ts +11 -0
  56. package/dist/version.js +11 -0
  57. package/dist/wear.d.ts +147 -9
  58. package/dist/wear.js +273 -89
  59. package/dist/zoom.d.ts +1 -1
  60. package/dist/zoom.js +73 -42
  61. package/docs/API.md +138 -134
  62. package/docs/collection-displays.md +4 -4
  63. package/docs/collection-input.md +5 -5
  64. package/docs/framework-integration.md +1 -1
  65. package/docs/guides/architecture.md +8 -8
  66. package/docs/guides/bundlers.md +60 -0
  67. package/docs/guides/card-element.md +26 -2
  68. package/docs/guides/collections.md +2 -2
  69. package/docs/guides/embed-in-an-iframe.md +39 -0
  70. package/docs/guides/frameworks.md +93 -66
  71. package/docs/guides/getting-started.md +4 -2
  72. package/docs/guides/html-and-cdn.md +86 -0
  73. package/docs/guides/ja/architecture.md +4 -4
  74. package/docs/guides/ja/bundlers.md +60 -0
  75. package/docs/guides/ja/card-element.md +26 -2
  76. package/docs/guides/ja/collections.md +2 -2
  77. package/docs/guides/ja/embed-in-an-iframe.md +39 -0
  78. package/docs/guides/ja/frameworks.md +93 -66
  79. package/docs/guides/ja/getting-started.md +4 -2
  80. package/docs/guides/ja/html-and-cdn.md +86 -0
  81. package/docs/guides/ja/live-3d.md +37 -24
  82. package/docs/guides/ja/materials-and-stacks.md +4 -4
  83. package/docs/guides/ja/troubleshooting.md +2 -2
  84. package/docs/guides/ja/typescript-and-node.md +45 -0
  85. package/docs/guides/ja/upgrading.md +7 -2
  86. package/docs/guides/ja/wear.md +1 -1
  87. package/docs/guides/live-3d.md +37 -24
  88. package/docs/guides/materials-and-stacks.md +4 -4
  89. package/docs/guides/troubleshooting.md +2 -2
  90. package/docs/guides/typescript-and-node.md +45 -0
  91. package/docs/guides/upgrading.md +7 -2
  92. package/docs/guides/wear.md +1 -1
  93. package/docs/live-3d.md +1 -18
  94. package/docs/materials.md +15 -11
  95. package/docs/wear.md +4 -12
  96. package/package.json +57 -10
package/dist/materials.js CHANGED
@@ -1,48 +1,266 @@
1
- /** One thousandth of an inch ("pt" in card and paper trade talk) in millimetres. */
1
+ /**
2
+ * One thousandth of an inch ("pt" in card and paper trade talk) in millimetres, 0.0254: a 13 pt card is 13 × 0.0254 mm.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import { mmPerPoint } from "@johnmorrisdotca/fuda-cards";
7
+ *
8
+ * console.log(Math.round(13 * mmPerPoint * 1000) / 1000); // 0.33
9
+ * ```
10
+ */
2
11
  export const mmPerPoint = 0.0254;
12
+ /**
13
+ * The thickness of a card that names no material or thickness: a playing card's black-core stock, 13 pt, 0.325 mm
14
+ * (Qin Printing, Black Core Paper 310 gsm, 0.325 mm).
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * import { DEFAULT_CARD_THICKNESS_MM, stackHeightMm } from "@johnmorrisdotca/fuda-cards";
19
+ *
20
+ * console.log(stackHeightMm(52, DEFAULT_CARD_THICKNESS_MM)); // 16.9
21
+ * ```
22
+ */
23
+ export const DEFAULT_CARD_THICKNESS_MM = 0.325;
3
24
  const pt = (points) => Math.round(points * mmPerPoint * 1000) / 1000;
4
- const qin = { label: 'Qin Printing, Custom Playing Card Printing', url: 'https://www.qinprinting.com/poker-card-printing/' };
25
+ const qin = {
26
+ label: "Qin Printing, Custom Playing Card Printing",
27
+ url: "https://www.qinprinting.com/poker-card-printing/",
28
+ };
5
29
  const holder = (points, slug) => ({
6
30
  label: `Ultra PRO, ${points}PT ONE-TOUCH Magnetic Holder`,
7
31
  url: `https://ultrapro.com/products/${slug}`,
8
- says: `holds standard cards (2-1/2" x 3-1/2") up to ${points}pt in thickness`
32
+ says: `holds standard cards (2-1/2" x 3-1/2") up to ${points}pt in thickness`,
9
33
  });
10
34
  const thick = (points, slug) => ({
11
35
  id: `card-${points}pt`,
12
36
  name: `Thick trading card, ${points} pt`,
13
- group: 'thick-card',
37
+ group: "thick-card",
14
38
  thicknessMm: pt(points),
15
- edge: '#e8dfca',
16
- source: holder(points, slug)
39
+ edge: "#e8dfca",
40
+ source: holder(points, slug),
17
41
  });
42
+ /**
43
+ * Every material the package knows, each with a thickness and the page it was read from. `docs/materials.md` lists them with their sources.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * import { cardMaterials } from "@johnmorrisdotca/fuda-cards";
48
+ *
49
+ * for (const material of cardMaterials.slice(0, 3)) console.log(material.id, material.thicknessMm);
50
+ * // paper-250 0.28
51
+ * // paper-310-black-core 0.325
52
+ * // paper-350 0.405
53
+ * ```
54
+ */
18
55
  export const cardMaterials = [
19
- { id: 'paper-250', name: 'Card stock, 250 gsm (11 pt)', group: 'paper', thicknessMm: 0.28, edge: '#efe9da', source: { ...qin, says: 'Premium Cardstock, 250gsm, 0.28mm, 11pt' } },
20
- { id: 'paper-310-black-core', name: 'Playing-card stock, black core, 310 gsm (13 pt)', group: 'paper', thicknessMm: 0.325, edge: '#2a2a2e', source: { ...qin, says: 'Black Core Paper, 310gsm, 0.325mm, 13pt' } },
21
- { id: 'paper-350', name: 'Heavy card stock, 350 gsm (16 pt)', group: 'paper', thicknessMm: 0.405, edge: '#e9e1cd', source: { ...qin, says: 'Premium Cardstock, 350gsm, 0.405mm, 16pt' } },
22
- { id: 'plastic-id1', name: 'Plastic bank-size card (ID-1, PVC)', group: 'plastic', thicknessMm: 0.76, edge: '#f2f2ef', source: { label: 'ISO/IEC 7810 ID-1, as summarised on Wikipedia', url: 'https://en.wikipedia.org/wiki/ISO/IEC_7810', says: '"All card sizes have a thickness of 760±80 μm." Payment cards are generally PVC (Wikipedia, Payment card).' } },
23
- thick(35, '35pt-uv-one-touch-magnetic-holders-5ct'),
24
- thick(55, '55pt-uv-one-touch-magnetic-holder'),
25
- thick(75, '75pt-uv-one-touch-magnetic-holder'),
26
- thick(100, '100pt-uv-one-touch-magnetic-holder'),
27
- thick(130, '130pt-uv-one-touch-magnetic-holder'),
28
- thick(180, '180pt-uv-one-touch-magnetic-holder'),
29
- { id: 'booklet-175pt', name: 'Booklet card, 175 pt', group: 'thick-card', thicknessMm: pt(175), edge: '#e8dfca', source: { label: 'Ultra PRO, 175PT Vertical Booklet Card ONE-TOUCH Magnetic Holder', url: 'https://ultrapro.com/products/175pt-vertical-booklet-card-uv-one-touch-magnetic-holder', says: '"Sized to fit Vertical Booklets up to 175pt thickness"' } },
30
- { id: 'aluminium-0.8', name: 'Anodised aluminium card, 0.8 mm', group: 'metal', thicknessMm: 0.8, edge: '#c9ced4', source: { label: 'ebamaz anodised aluminium business card blank, 86 x 54 x 0.8 mm (Wood Art Supply listing)', url: 'https://woodartsupply.com/products/ebamaz-metal-business-cards-anodized-aluminum-plaque-plate-86x54x0-8mm-silver-blank-10pcs', says: '"Material: Anodized Aluminum", "Size: 86X54X0.8mm"' } },
31
- { id: 'steel-0.5', name: 'Stainless steel card, 0.5 mm', group: 'metal', thicknessMm: 0.5, edge: '#aab0b6', source: { label: 'My Metal Business Card, Metal Business Card Thickness Guide', url: 'https://mymetalbusinesscard.com/blog/metal-business-card-thickness-guide/', says: '"our standard metal business card thickness is 0.5mm"; "A 0.5mm stainless steel business card"' } }
56
+ {
57
+ id: "paper-250",
58
+ name: "Card stock, 250 gsm (11 pt)",
59
+ group: "paper",
60
+ thicknessMm: 0.28,
61
+ edge: "#efe9da",
62
+ source: { ...qin, says: "Premium Cardstock, 250gsm, 0.28mm, 11pt" },
63
+ },
64
+ {
65
+ id: "paper-310-black-core",
66
+ name: "Playing-card stock, black core, 310 gsm (13 pt)",
67
+ group: "paper",
68
+ thicknessMm: 0.325,
69
+ edge: "#2a2a2e",
70
+ source: { ...qin, says: "Black Core Paper, 310gsm, 0.325mm, 13pt" },
71
+ },
72
+ {
73
+ id: "paper-350",
74
+ name: "Heavy card stock, 350 gsm (16 pt)",
75
+ group: "paper",
76
+ thicknessMm: 0.405,
77
+ edge: "#e9e1cd",
78
+ source: { ...qin, says: "Premium Cardstock, 350gsm, 0.405mm, 16pt" },
79
+ },
80
+ {
81
+ id: "plastic-id1",
82
+ name: "Plastic bank-size card (ID-1, PVC)",
83
+ group: "plastic",
84
+ thicknessMm: 0.76,
85
+ edge: "#f2f2ef",
86
+ source: {
87
+ label: "ISO/IEC 7810 ID-1, as summarised on Wikipedia",
88
+ url: "https://en.wikipedia.org/wiki/ISO/IEC_7810",
89
+ says: '"All card sizes have a thickness of 760±80 μm." Payment cards are generally PVC (Wikipedia, Payment card).',
90
+ },
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
+ },
104
+ thick(35, "35pt-uv-one-touch-magnetic-holders-5ct"),
105
+ thick(55, "55pt-uv-one-touch-magnetic-holder"),
106
+ thick(75, "75pt-uv-one-touch-magnetic-holder"),
107
+ thick(100, "100pt-uv-one-touch-magnetic-holder"),
108
+ thick(130, "130pt-uv-one-touch-magnetic-holder"),
109
+ thick(180, "180pt-uv-one-touch-magnetic-holder"),
110
+ {
111
+ id: "booklet-175pt",
112
+ name: "Booklet card, 175 pt",
113
+ group: "thick-card",
114
+ thicknessMm: pt(175),
115
+ edge: "#e8dfca",
116
+ source: {
117
+ label: "Ultra PRO, 175PT Vertical Booklet Card ONE-TOUCH Magnetic Holder",
118
+ url: "https://ultrapro.com/products/175pt-vertical-booklet-card-uv-one-touch-magnetic-holder",
119
+ says: '"Sized to fit Vertical Booklets up to 175pt thickness"',
120
+ },
121
+ },
122
+ {
123
+ id: "aluminium-0.8",
124
+ name: "Anodised aluminium card, 0.8 mm",
125
+ group: "metal",
126
+ thicknessMm: 0.8,
127
+ edge: "#c9ced4",
128
+ source: {
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.",
132
+ },
133
+ },
134
+ {
135
+ id: "steel-0.5",
136
+ name: "Stainless steel card, 0.5 mm",
137
+ group: "metal",
138
+ thicknessMm: 0.5,
139
+ edge: "#aab0b6",
140
+ source: {
141
+ label: "My Metal Business Card, Metal Business Card Thickness Guide",
142
+ url: "https://mymetalbusinesscard.com/blog/metal-business-card-thickness-guide/",
143
+ says: '"our standard metal business card thickness is 0.5mm"; "A 0.5mm stainless steel business card"',
144
+ },
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
+ },
32
182
  ];
33
- const wikiDeck = { label: 'Wikipedia, Playing card', url: 'https://en.wikipedia.org/wiki/Playing_card' };
34
- const wikiPokemon = { label: 'Wikipedia, Pokémon Trading Card Game', url: 'https://en.wikipedia.org/wiki/Pok%C3%A9mon_Trading_Card_Game' };
183
+ const playingCards = {
184
+ label: "Bicycle Cards, Basics of Poker",
185
+ url: "https://bicyclecards.com/how-to-play/basics-of-poker",
186
+ };
187
+ const wikiPokemon = {
188
+ label: "Wikipedia, Pokémon Trading Card Game",
189
+ url: "https://en.wikipedia.org/wiki/Pok%C3%A9mon_Trading_Card_Game",
190
+ };
191
+ /**
192
+ * The usual sizes of a stack of cards, each with where the number comes from.
193
+ *
194
+ * @example
195
+ * ```ts
196
+ * import { stackPresets } from "@johnmorrisdotca/fuda-cards";
197
+ *
198
+ * console.log(stackPresets.map((preset) => preset.count)); // [ 52, 54, 60, 10 ]
199
+ * ```
200
+ */
35
201
  export const stackPresets = [
36
- { id: 'deck-52', name: 'Playing cards, 52', count: 52, source: { ...wikiDeck, says: '"The 52-card deck is the most popular deck"' } },
37
- { id: 'deck-54', name: 'Playing cards with two jokers, 54', count: 54, source: { ...wikiDeck, says: 'commercial packs "often include between one and six jokers, most often two", so 52 + 2' } },
38
- { id: 'pokemon-deck', name: 'Pokémon TCG deck, 60', count: 60, source: { ...wikiPokemon, says: 'players "play with 60-card decks"' } },
39
- { id: 'pokemon-booster', name: 'Booster pack, about 10', count: 10, source: { ...wikiPokemon, says: '"a collector can pull 10 cards in total" from a booster pack' } }
202
+ {
203
+ id: "deck-52",
204
+ name: "Playing cards, 52",
205
+ count: 52,
206
+ source: { ...playingCards, says: "The standard poker pack has 52 cards." },
207
+ },
208
+ {
209
+ id: "deck-54",
210
+ name: "Playing cards with two jokers, 54",
211
+ count: 54,
212
+ source: {
213
+ ...playingCards,
214
+ says: "A 52-card pack with two added jokers has 54 cards.",
215
+ },
216
+ },
217
+ {
218
+ id: "pokemon-deck",
219
+ name: "Pokémon TCG deck, 60",
220
+ count: 60,
221
+ source: { ...wikiPokemon, says: 'players "play with 60-card decks"' },
222
+ },
223
+ {
224
+ id: "pokemon-booster",
225
+ name: "Booster pack, about 10",
226
+ count: 10,
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
+ },
232
+ },
40
233
  ];
41
- /** The material with this id, or undefined. */
234
+ /**
235
+ * The material with this id.
236
+ *
237
+ * @param id - A material's id, such as `paper-310-black-core` (the `material` attribute's value).
238
+ * @returns The material, or `undefined` when there is none with that id (and for `null` and `undefined`).
239
+ * @example
240
+ * ```ts
241
+ * import { cardMaterial } from "@johnmorrisdotca/fuda-cards";
242
+ *
243
+ * console.log(cardMaterial("aluminium-0.8")?.thicknessMm); // 0.8
244
+ * console.log(cardMaterial("nothing")); // undefined
245
+ * ```
246
+ */
42
247
  export function cardMaterial(id) {
43
- return cardMaterials.find(material => material.id === id);
248
+ return cardMaterials.find((material) => material.id === id);
44
249
  }
45
- /** Height of a stack of `count` cards `thicknessMm` thick, in millimetres. */
250
+ /**
251
+ * The height of a stack of cards, in millimetres: the count times the thickness of one, to a thousandth of a millimetre.
252
+ *
253
+ * @param count - How many cards; a count under one is one card.
254
+ * @param thicknessMm - The thickness of one card in millimetres.
255
+ * @returns The height of the stack in millimetres.
256
+ * @example
257
+ * ```ts
258
+ * import { cardMaterial, stackHeightMm } from "@johnmorrisdotca/fuda-cards";
259
+ *
260
+ * const stock = cardMaterial("paper-310-black-core");
261
+ * console.log(stackHeightMm(52, stock?.thicknessMm ?? 0.325)); // 16.9
262
+ * ```
263
+ */
46
264
  export function stackHeightMm(count, thicknessMm) {
47
265
  return Math.round(Math.max(1, Math.floor(count)) * thicknessMm * 1000) / 1000;
48
266
  }
@@ -0,0 +1,2 @@
1
+ /** True when the reader asked their device for less motion: nothing here moves by itself, and a move ends at once. */
2
+ export declare function reducedMotion(): boolean;
package/dist/motion.js ADDED
@@ -0,0 +1,4 @@
1
+ /** True when the reader asked their device for less motion: nothing here moves by itself, and a move ends at once. */
2
+ export function reducedMotion() {
3
+ return typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
4
+ }