@aparte/plugin-cards 0.0.0-stage → 0.29.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 (103) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +148 -2
  3. package/dist/carousel-CPy-0JGN.js +63 -0
  4. package/dist/carousel-CPy-0JGN.js.map +1 -0
  5. package/dist/controls-BVX2u7sK.js +62 -0
  6. package/dist/controls-BVX2u7sK.js.map +1 -0
  7. package/dist/format-CchcJRum.js +720 -0
  8. package/dist/format-CchcJRum.js.map +1 -0
  9. package/dist/index.d.ts +28 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +35 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/items/icons.d.ts +12 -0
  14. package/dist/items/icons.d.ts.map +1 -0
  15. package/dist/items/index.d.ts +100 -0
  16. package/dist/items/index.d.ts.map +1 -0
  17. package/dist/items.js +698 -0
  18. package/dist/items.js.map +1 -0
  19. package/dist/kit/carousel.d.ts +17 -0
  20. package/dist/kit/carousel.d.ts.map +1 -0
  21. package/dist/kit/controls.d.ts +51 -0
  22. package/dist/kit/controls.d.ts.map +1 -0
  23. package/dist/kit/define.d.ts +194 -0
  24. package/dist/kit/define.d.ts.map +1 -0
  25. package/dist/kit/dom.d.ts +40 -0
  26. package/dist/kit/dom.d.ts.map +1 -0
  27. package/dist/kit/format.d.ts +49 -0
  28. package/dist/kit/format.d.ts.map +1 -0
  29. package/dist/kit/rating.d.ts +19 -0
  30. package/dist/kit/rating.d.ts.map +1 -0
  31. package/dist/kit/sparkline.d.ts +19 -0
  32. package/dist/kit/sparkline.d.ts.map +1 -0
  33. package/dist/kit/strings.d.ts +139 -0
  34. package/dist/kit/strings.d.ts.map +1 -0
  35. package/dist/link/icons.d.ts +16 -0
  36. package/dist/link/icons.d.ts.map +1 -0
  37. package/dist/link/index.d.ts +98 -0
  38. package/dist/link/index.d.ts.map +1 -0
  39. package/dist/link.js +387 -0
  40. package/dist/link.js.map +1 -0
  41. package/dist/media/icons.d.ts +28 -0
  42. package/dist/media/icons.d.ts.map +1 -0
  43. package/dist/media/index.d.ts +107 -0
  44. package/dist/media/index.d.ts.map +1 -0
  45. package/dist/media.js +610 -0
  46. package/dist/media.js.map +1 -0
  47. package/dist/order/icons.d.ts +49 -0
  48. package/dist/order/icons.d.ts.map +1 -0
  49. package/dist/order/index.d.ts +204 -0
  50. package/dist/order/index.d.ts.map +1 -0
  51. package/dist/order.js +1843 -0
  52. package/dist/order.js.map +1 -0
  53. package/dist/place/icons.d.ts +18 -0
  54. package/dist/place/icons.d.ts.map +1 -0
  55. package/dist/place/index.d.ts +207 -0
  56. package/dist/place/index.d.ts.map +1 -0
  57. package/dist/place.js +1456 -0
  58. package/dist/place.js.map +1 -0
  59. package/dist/plan/icons.d.ts +25 -0
  60. package/dist/plan/icons.d.ts.map +1 -0
  61. package/dist/plan/index.d.ts +153 -0
  62. package/dist/plan/index.d.ts.map +1 -0
  63. package/dist/plan.js +1191 -0
  64. package/dist/plan.js.map +1 -0
  65. package/dist/product/icons.d.ts +16 -0
  66. package/dist/product/icons.d.ts.map +1 -0
  67. package/dist/product/index.d.ts +133 -0
  68. package/dist/product/index.d.ts.map +1 -0
  69. package/dist/product.js +1245 -0
  70. package/dist/product.js.map +1 -0
  71. package/dist/rating-B8Mdx_b_.js +35 -0
  72. package/dist/rating-B8Mdx_b_.js.map +1 -0
  73. package/dist/score/icons.d.ts +35 -0
  74. package/dist/score/icons.d.ts.map +1 -0
  75. package/dist/score/index.d.ts +185 -0
  76. package/dist/score/index.d.ts.map +1 -0
  77. package/dist/score.js +1843 -0
  78. package/dist/score.js.map +1 -0
  79. package/dist/sparkline-C-cA9obz.js +56 -0
  80. package/dist/sparkline-C-cA9obz.js.map +1 -0
  81. package/dist/stats/icons.d.ts +19 -0
  82. package/dist/stats/icons.d.ts.map +1 -0
  83. package/dist/stats/index.d.ts +137 -0
  84. package/dist/stats/index.d.ts.map +1 -0
  85. package/dist/stats.js +1085 -0
  86. package/dist/stats.js.map +1 -0
  87. package/dist/stock/chart.d.ts +135 -0
  88. package/dist/stock/chart.d.ts.map +1 -0
  89. package/dist/stock/icons.d.ts +15 -0
  90. package/dist/stock/icons.d.ts.map +1 -0
  91. package/dist/stock/index.d.ts +195 -0
  92. package/dist/stock/index.d.ts.map +1 -0
  93. package/dist/stock.js +1013 -0
  94. package/dist/stock.js.map +1 -0
  95. package/dist/weather/conditions.d.ts +25 -0
  96. package/dist/weather/conditions.d.ts.map +1 -0
  97. package/dist/weather/icons.d.ts +12 -0
  98. package/dist/weather/icons.d.ts.map +1 -0
  99. package/dist/weather/index.d.ts +146 -0
  100. package/dist/weather/index.d.ts.map +1 -0
  101. package/dist/weather.js +1162 -0
  102. package/dist/weather.js.map +1 -0
  103. package/package.json +137 -3
@@ -0,0 +1,107 @@
1
+ /**
2
+ * @aparte/plugin-cards/media — a tool's pictures, videos and sounds, drawn as a card: one
3
+ * photo large, a gallery as a mosaic, a row of thumbnails, a lightbox to see each one big.
4
+ *
5
+ * import { setupMediaCard } from '@aparte/plugin-cards/media';
6
+ *
7
+ * setupMediaCard({ tool: 'generate_image' }); // DALL·E's `{ data: [{ url }] }` as it is
8
+ * setupMediaCard({ tool: 'search_photos', map: (r) => r.results }); // Unsplash, Pexels…
9
+ *
10
+ * One medium, several (`[...]`), or `{ title, items: [...] }`. Three variants of one card:
11
+ * `single` (the first medium large, its caption under it), `gallery` (a mosaic, the first
12
+ * larger, "+3" on the last tile) and `strip` (square thumbnails that scroll sideways). Every
13
+ * picture opens in a lightbox: the browser's own `<dialog>`, wearing core's `.aparte-dialog`.
14
+ *
15
+ * Nothing here plays a third party: a video is the native `<video>`, a sound the native
16
+ * `<audio>`, and a YouTube or Vimeo page is a poster that LINKS to it — no iframe, no
17
+ * player script. What the browser fetches is what the tool's data names — the medium, its
18
+ * poster — and nothing else: no thumbnail is derived from a video's address, no service
19
+ * is asked about a link. An HLS or DASH stream (`.m3u8`, `.mpd`) plays in the native
20
+ * `<video>` only where the browser says it can (Safari, for HLS); elsewhere it would need a
21
+ * player script, so it is a poster that links out, like a YouTube page.
22
+ */
23
+ import type { AparteConfig } from '@aparte/core';
24
+ import { type CardSetupOptions } from '../kit/define.js';
25
+ export type MediaKind = 'image' | 'video' | 'audio';
26
+ export type MediaVariant = 'single' | 'gallery' | 'strip';
27
+ /**
28
+ * A medium as `map` returns it. Only `src` is needed; every other field adds something when
29
+ * it is there and nothing when it is not. `readMedia` also reads the usual aliases (listed
30
+ * on each field).
31
+ */
32
+ export interface MediumInput {
33
+ /** Read from the address's extension or `mimeType` when absent. Also `type`, `mediaType`. */
34
+ kind?: MediaKind;
35
+ /** An `http(s)` address. Also `url`, `link`, `href`, `image`, `imageUrl`, `thumbnail`, Unsplash's `urls.regular`. */
36
+ src: string;
37
+ /** The still shown before a video plays, the cover of a sound, a smaller copy of an image for its tile. Also `thumb`, `preview`. */
38
+ poster?: string;
39
+ title?: string;
40
+ /** Also `description`, and an image model's `revised_prompt`. */
41
+ caption?: string;
42
+ /** Who made it, or where it comes from. Also `author`, `source`, `photographer`, Unsplash's `user.name`. */
43
+ credit?: string;
44
+ /** What the picture shows, for a reader who cannot see it. Also `alt_description`. */
45
+ alt?: string;
46
+ /** With `height`, reserves the picture's shape before it loads — nothing jumps when it does. */
47
+ width?: number;
48
+ height?: number;
49
+ /** In seconds; `"3:42"` and ISO 8601 (`"PT3M42S"`) are read too. */
50
+ duration?: number | string;
51
+ mimeType?: string;
52
+ /** The page the medium comes from. */
53
+ url?: string;
54
+ }
55
+ /** A medium as the card draws it, once read. */
56
+ export interface Medium {
57
+ kind: MediaKind;
58
+ src: string;
59
+ /**
60
+ * Set when `src` is a video's page on a site that plays it itself ("YouTube", "Vimeo"):
61
+ * drawn as a poster that links out, never embedded.
62
+ */
63
+ site?: string;
64
+ poster?: string;
65
+ title?: string;
66
+ caption?: string;
67
+ credit?: string;
68
+ alt?: string;
69
+ width?: number;
70
+ height?: number;
71
+ duration?: number;
72
+ mimeType?: string;
73
+ url?: string;
74
+ }
75
+ /** The card's data: one medium or several, and the collection's title. */
76
+ export interface MediaData {
77
+ title?: string;
78
+ items: Medium[];
79
+ }
80
+ export type MediaCardOptions = CardSetupOptions<MediaData, MediaVariant>;
81
+ /**
82
+ * A length in seconds from what tools write: a number, `"3:42"`, `"1:02:03"`, ISO 8601's
83
+ * `"PT3M42S"` (YouTube's API). `undefined` for anything else.
84
+ */
85
+ export declare function readDuration(value: unknown): number | undefined;
86
+ /**
87
+ * The card's data from what `map` returns: one medium (an object, or its address), an array,
88
+ * or a collection (`{ title?, items | media | images | photos | videos | results | data }` —
89
+ * the last is an image model's answer). At most 24; `null` when not one has an `http(s)` source.
90
+ */
91
+ export declare function readMedia(raw: unknown): MediaData | null;
92
+ /** A length as a player writes it, in the chat's digits: `3:42`, `1:02:03`. */
93
+ export declare function formatDuration(config: AparteConfig, seconds: number): string;
94
+ /** The media card — for `mediaCard.segment(data)`. Plug it in with `setupMediaCard`. */
95
+ export declare const mediaCard: {
96
+ name: string;
97
+ variants: readonly MediaVariant[];
98
+ setup: (options?: CardSetupOptions<MediaData, MediaVariant>) => () => void;
99
+ segment: (raw: unknown, options?: {
100
+ id?: string;
101
+ variant?: MediaVariant | undefined;
102
+ config?: AparteConfig;
103
+ }) => import("../index.js").AparteCardSegment;
104
+ };
105
+ /** Draw a tool's media as this card — returns the function that stops it. */
106
+ export declare function setupMediaCard(options?: MediaCardOptions): () => void;
107
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/media/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAgC,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAOvF,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,OAAO,GA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