@aparte/plugin-cards 0.0.0-stage → 0.29.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 (105) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +151 -2
  3. package/dist/carousel-DwgHvriV.js +63 -0
  4. package/dist/carousel-DwgHvriV.js.map +1 -0
  5. package/dist/controls-BYUm4aRV.js +62 -0
  6. package/dist/controls-BYUm4aRV.js.map +1 -0
  7. package/dist/format-BFq79ydr.js +728 -0
  8. package/dist/format-BFq79ydr.js.map +1 -0
  9. package/dist/index.d.ts +30 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +120 -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 +201 -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/fence.d.ts +39 -0
  28. package/dist/kit/fence.d.ts.map +1 -0
  29. package/dist/kit/format.d.ts +49 -0
  30. package/dist/kit/format.d.ts.map +1 -0
  31. package/dist/kit/rating.d.ts +19 -0
  32. package/dist/kit/rating.d.ts.map +1 -0
  33. package/dist/kit/sparkline.d.ts +19 -0
  34. package/dist/kit/sparkline.d.ts.map +1 -0
  35. package/dist/kit/strings.d.ts +139 -0
  36. package/dist/kit/strings.d.ts.map +1 -0
  37. package/dist/link/icons.d.ts +16 -0
  38. package/dist/link/icons.d.ts.map +1 -0
  39. package/dist/link/index.d.ts +98 -0
  40. package/dist/link/index.d.ts.map +1 -0
  41. package/dist/link.js +387 -0
  42. package/dist/link.js.map +1 -0
  43. package/dist/media/icons.d.ts +28 -0
  44. package/dist/media/icons.d.ts.map +1 -0
  45. package/dist/media/index.d.ts +107 -0
  46. package/dist/media/index.d.ts.map +1 -0
  47. package/dist/media.js +610 -0
  48. package/dist/media.js.map +1 -0
  49. package/dist/order/icons.d.ts +49 -0
  50. package/dist/order/icons.d.ts.map +1 -0
  51. package/dist/order/index.d.ts +204 -0
  52. package/dist/order/index.d.ts.map +1 -0
  53. package/dist/order.js +1843 -0
  54. package/dist/order.js.map +1 -0
  55. package/dist/place/icons.d.ts +18 -0
  56. package/dist/place/icons.d.ts.map +1 -0
  57. package/dist/place/index.d.ts +207 -0
  58. package/dist/place/index.d.ts.map +1 -0
  59. package/dist/place.js +1456 -0
  60. package/dist/place.js.map +1 -0
  61. package/dist/plan/icons.d.ts +25 -0
  62. package/dist/plan/icons.d.ts.map +1 -0
  63. package/dist/plan/index.d.ts +153 -0
  64. package/dist/plan/index.d.ts.map +1 -0
  65. package/dist/plan.js +1191 -0
  66. package/dist/plan.js.map +1 -0
  67. package/dist/product/icons.d.ts +16 -0
  68. package/dist/product/icons.d.ts.map +1 -0
  69. package/dist/product/index.d.ts +133 -0
  70. package/dist/product/index.d.ts.map +1 -0
  71. package/dist/product.js +1245 -0
  72. package/dist/product.js.map +1 -0
  73. package/dist/rating-CHVajQ2b.js +35 -0
  74. package/dist/rating-CHVajQ2b.js.map +1 -0
  75. package/dist/score/icons.d.ts +35 -0
  76. package/dist/score/icons.d.ts.map +1 -0
  77. package/dist/score/index.d.ts +185 -0
  78. package/dist/score/index.d.ts.map +1 -0
  79. package/dist/score.js +1843 -0
  80. package/dist/score.js.map +1 -0
  81. package/dist/sparkline-C-cA9obz.js +56 -0
  82. package/dist/sparkline-C-cA9obz.js.map +1 -0
  83. package/dist/stats/icons.d.ts +19 -0
  84. package/dist/stats/icons.d.ts.map +1 -0
  85. package/dist/stats/index.d.ts +137 -0
  86. package/dist/stats/index.d.ts.map +1 -0
  87. package/dist/stats.js +1085 -0
  88. package/dist/stats.js.map +1 -0
  89. package/dist/stock/chart.d.ts +135 -0
  90. package/dist/stock/chart.d.ts.map +1 -0
  91. package/dist/stock/icons.d.ts +15 -0
  92. package/dist/stock/icons.d.ts.map +1 -0
  93. package/dist/stock/index.d.ts +195 -0
  94. package/dist/stock/index.d.ts.map +1 -0
  95. package/dist/stock.js +1013 -0
  96. package/dist/stock.js.map +1 -0
  97. package/dist/weather/conditions.d.ts +25 -0
  98. package/dist/weather/conditions.d.ts.map +1 -0
  99. package/dist/weather/icons.d.ts +12 -0
  100. package/dist/weather/icons.d.ts.map +1 -0
  101. package/dist/weather/index.d.ts +146 -0
  102. package/dist/weather/index.d.ts.map +1 -0
  103. package/dist/weather.js +1162 -0
  104. package/dist/weather.js.map +1 -0
  105. package/package.json +137 -3
@@ -0,0 +1,139 @@
1
+ /**
2
+ * A card's words, in the chat's language.
3
+ *
4
+ * Core's locale is a closed list of what CORE draws, so a plugin reads its own keys off
5
+ * `getLocale()` and defaults them at the call site (the localization guide). A card does
6
+ * that, with one step in between: this package carries its words in the ten languages
7
+ * `@aparte/locales` ships, picked by the locale's `tag`. An app that sets a key wins;
8
+ * a language the table does not have reads English.
9
+ *
10
+ * aparteGlobalConfig.extendLocale({ cardsWeatherWind: 'Vent' });
11
+ */
12
+ import type { AparteConfig } from '@aparte/core';
13
+ /** The languages a card's words come in, beside English. */
14
+ export type CardLanguage = 'fr' | 'de' | 'es' | 'it' | 'ja' | 'ko' | 'pt' | 'ru' | 'zh';
15
+ /** One word or phrase, in English and in as many of the other languages as it has. */
16
+ export type CardWord = {
17
+ en: string;
18
+ } & Partial<Record<CardLanguage, string>>;
19
+ /** The language part of the locale's tag: `pt-BR` → `pt`, `zh-CN` → `zh`, none → `en`. */
20
+ export declare function languageOf(config: AparteConfig): string;
21
+ /** The locale's tag for `Intl`, or `undefined` to follow the browser (never `''`, which throws). */
22
+ export declare function intlTag(config: AparteConfig): string | undefined;
23
+ /**
24
+ * The word for `key`: the app's locale first, then this package's table for the chat's
25
+ * language, then English. `{name}` placeholders are filled from `vars`.
26
+ */
27
+ export declare function word(config: AparteConfig, key: string, table: CardWord, vars?: Record<string, string>): string;
28
+ /** The words every card shares. */
29
+ export declare const KIT_WORDS: {
30
+ cardsUnavailable: {
31
+ en: string;
32
+ fr: string;
33
+ de: string;
34
+ es: string;
35
+ it: string;
36
+ ja: string;
37
+ ko: string;
38
+ pt: string;
39
+ ru: string;
40
+ zh: string;
41
+ };
42
+ cardsWaiting: {
43
+ en: string;
44
+ fr: string;
45
+ de: string;
46
+ es: string;
47
+ it: string;
48
+ ja: string;
49
+ ko: string;
50
+ pt: string;
51
+ ru: string;
52
+ zh: string;
53
+ };
54
+ cardsRefused: {
55
+ en: string;
56
+ fr: string;
57
+ de: string;
58
+ es: string;
59
+ it: string;
60
+ ja: string;
61
+ ko: string;
62
+ pt: string;
63
+ ru: string;
64
+ zh: string;
65
+ };
66
+ cardsLoading: {
67
+ en: string;
68
+ fr: string;
69
+ de: string;
70
+ es: string;
71
+ it: string;
72
+ ja: string;
73
+ ko: string;
74
+ pt: string;
75
+ ru: string;
76
+ zh: string;
77
+ };
78
+ cardsPrevious: {
79
+ en: string;
80
+ fr: string;
81
+ de: string;
82
+ es: string;
83
+ it: string;
84
+ ja: string;
85
+ ko: string;
86
+ pt: string;
87
+ ru: string;
88
+ zh: string;
89
+ };
90
+ cardsNext: {
91
+ en: string;
92
+ fr: string;
93
+ de: string;
94
+ es: string;
95
+ it: string;
96
+ ja: string;
97
+ ko: string;
98
+ pt: string;
99
+ ru: string;
100
+ zh: string;
101
+ };
102
+ cardsSlide: {
103
+ en: string;
104
+ fr: string;
105
+ de: string;
106
+ es: string;
107
+ it: string;
108
+ ja: string;
109
+ ko: string;
110
+ pt: string;
111
+ ru: string;
112
+ zh: string;
113
+ };
114
+ cardsRating: {
115
+ en: string;
116
+ fr: string;
117
+ de: string;
118
+ es: string;
119
+ it: string;
120
+ ja: string;
121
+ ko: string;
122
+ pt: string;
123
+ ru: string;
124
+ zh: string;
125
+ };
126
+ cardsReviews: {
127
+ en: string;
128
+ fr: string;
129
+ de: string;
130
+ es: string;
131
+ it: string;
132
+ ja: string;
133
+ ko: string;
134
+ pt: string;
135
+ ru: string;
136
+ zh: string;
137
+ };
138
+ };
139
+ //# sourceMappingURL=strings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/kit/strings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,4DAA4D;AAC5D,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAExF,sFAAsF;AACtF,MAAM,MAAM,QAAQ,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;AAE9E,0FAA0F;AAC1F,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAGvD;AAED,oGAAoG;AACpG,wBAAgB,OAAO,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,CAchE;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAAG,MAAM,CAKlH;AAED,mCAAmC;AACnC,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCc,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The link card's glyphs: the chain that names the card, one small badge per kind of page
3
+ * (an article, a video, a code repository, a product), and the play disc a video's preview
4
+ * wears.
5
+ *
6
+ * Drawn on a 24 × 24 grid in `currentColor`, so the sheet colours them through `color` and
7
+ * a theme follows. Constants of this package — the only markup the card parses.
8
+ */
9
+ import type { LinkType } from './index.js';
10
+ /** Two links of a chain: a link, and the card's one-line state glyph. */
11
+ export declare const CHAIN: string;
12
+ /** The play triangle, filled: it sits on a disc over a video's preview. */
13
+ export declare const PLAY = "<svg viewBox=\"0 0 24 24\" fill=\"currentColor\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M8.5 5.6v12.8a1 1 0 0 0 1.5.86l10.2-6.4a1 1 0 0 0 0-1.72L10 4.74a1 1 0 0 0-1.5.86z\"/></svg>";
14
+ /** The badge glyph for a kind of page; a plain website has none. */
15
+ export declare function typeGlyph(type: Exclude<LinkType, 'website'>): string;
16
+ //# sourceMappingURL=icons.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../src/link/icons.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAK3C,yEAAyE;AACzE,eAAO,MAAM,KAAK,QAAwI,CAAC;AAE3J,2EAA2E;AAC3E,eAAO,MAAM,IAAI,iMAAyL,CAAC;AAa3M,oEAAoE;AACpE,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,MAAM,CAEpE"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * @aparte/plugin-cards/link — a web page, previewed: its picture, its site, its title and
3
+ * what it says it is about, the whole card one link to it.
4
+ *
5
+ * import { setupLinkCard } from '@aparte/plugin-cards/link';
6
+ *
7
+ * setupLinkCard({ tool: 'unfurl' }); // one page's Open Graph, as it is
8
+ * setupLinkCard({ tool: 'web_search', map: (r) => r.items }); // search results
9
+ *
10
+ * One link, several (`[...]`), or `{ title, links: [...] }`. Three variants of one card:
11
+ * `card` (the picture on top, the site, the title, the description), `compact` (one row: the
12
+ * site's icon, the title, a small picture at the end) and `quote` (the block chat apps draw
13
+ * under an unfurled link, with a coloured rule down its side). Your tool keeps its own
14
+ * fields: `readLinks` reads Open Graph and Twitter keys, unfurlers' nested shapes and search
15
+ * results (Google's Custom Search, SerpAPI, Brave, Tavily, Exa), and `map` says the rest.
16
+ *
17
+ * The card fetches nothing the tool's data does not name: no page, and no address of its
18
+ * own making — no favicon service is asked, no icon guessed at `/favicon.ico`. A picture or an
19
+ * icon the data names is loaded as given, wherever it is hosted (Brave's results name icons
20
+ * on Brave's own proxy). A site without an icon in the data gets its initial on a tinted
21
+ * square, and a page without a picture gets no picture.
22
+ *
23
+ * Every value is text. Search engines highlight the query in their snippets with markup
24
+ * (Brave's `<strong>`): those tags are dropped and the usual entities decoded, and what is
25
+ * left goes in as text — never parsed.
26
+ */
27
+ import type { AparteConfig } from '@aparte/core';
28
+ import { type CardSetupOptions } from '../kit/define.js';
29
+ export type LinkType = 'article' | 'video' | 'repo' | 'product' | 'website';
30
+ export type LinkVariant = 'card' | 'compact' | 'quote';
31
+ /**
32
+ * A link as `map` returns it. Only `url` is needed; every other field adds a line when it is
33
+ * there and nothing when it is not. `readLinks` also reads the usual aliases (listed on each
34
+ * field).
35
+ */
36
+ export interface LinkInput {
37
+ /** An `http(s)` page. Also `link`, `href`, `og:url`. */
38
+ url: string;
39
+ /** Falls back to the page's host. Also `og:title`, `twitter:title`, `meta.title`, `name`. */
40
+ title?: string;
41
+ /** Also `og:description`, `snippet`, `summary`, `content`. */
42
+ description?: string;
43
+ /** Also `og:image`, `twitter:image`, `thumbnail`, `open_graph.images[0].url`, `pagemap.cse_image[0].src`. */
44
+ image?: string;
45
+ /** Falls back to the host without `www.`. Also `og:site_name`, `site`, `publisher`, `source`. */
46
+ siteName?: string;
47
+ /** The site's icon, loaded as given. Without it, the site's initial on a tinted square — no icon address is made up. Also `icon`, `logo`, Brave's `meta_url.favicon`. */
48
+ favicon?: string;
49
+ /** Also `byline`, `article:author`, `authors[0]`. */
50
+ author?: string;
51
+ /** An ISO date or an epoch. Also `datePublished`, `published_date`, `date`, `article:published_time`. */
52
+ publishedAt?: string | number | Date;
53
+ /** The badge it wears. Read from `og:type` and the host (GitHub → repo, YouTube → video) when absent. */
54
+ type?: LinkType;
55
+ /** A colour for the quote's side rule: `#rgb` or `#rrggbb`. Also `theme-color`. */
56
+ themeColor?: string;
57
+ }
58
+ /** A link as the card draws it, once read. */
59
+ export interface Link {
60
+ url: string;
61
+ /** The page's host without `www.` — what stands in for a missing title or site name. */
62
+ host: string;
63
+ title?: string;
64
+ description?: string;
65
+ image?: string;
66
+ siteName?: string;
67
+ favicon?: string;
68
+ author?: string;
69
+ publishedAt?: Date;
70
+ type: LinkType;
71
+ themeColor?: string;
72
+ }
73
+ /** The card's data: one link or several, and the collection's title. */
74
+ export interface LinkData {
75
+ title?: string;
76
+ links: Link[];
77
+ }
78
+ export type LinkCardOptions = CardSetupOptions<LinkData, LinkVariant>;
79
+ /**
80
+ * The card's data from what `map` returns: one link (an object, or its address), an array,
81
+ * or a collection (`{ title?, links | results | items | organic_results | sources }`, and
82
+ * Brave's `web.results`). At most ten; `null` when not one has an `http(s)` address.
83
+ */
84
+ export declare function readLinks(raw: unknown): LinkData | null;
85
+ /** The link card — for `linkCard.segment(data)`. Plug it in with `setupLinkCard`. */
86
+ export declare const linkCard: {
87
+ name: string;
88
+ variants: readonly LinkVariant[];
89
+ setup: (options?: CardSetupOptions<LinkData, LinkVariant>) => () => void;
90
+ segment: (raw: unknown, options?: {
91
+ id?: string;
92
+ variant?: LinkVariant | undefined;
93
+ config?: AparteConfig;
94
+ }) => import("../index.js").AparteCardSegment;
95
+ };
96
+ /** Draw a tool's links as this card — returns the function that stops it. */
97
+ export declare function setupLinkCard(options?: LinkCardOptions): () => void;
98
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/link/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAgC,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAOvF,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;AAC5E,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;AAEvD;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACtB,wDAAwD;IACxD,GAAG,EAAE,MAAM,CAAC;IACZ,6FAA6F;IAC7F,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6GAA6G;IAC7G,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iGAAiG;IACjG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yKAAyK;IACzK,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yGAAyG;IACzG,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACrC,yGAAyG;IACzG,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,mFAAmF;IACnF,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,8CAA8C;AAC9C,MAAM,WAAW,IAAI;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,wFAAwF;IACxF,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,IAAI,CAAC;IACnB,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wEAAwE;AACxE,MAAM,WAAW,QAAQ;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,IAAI,EAAE,CAAC;CACjB;AAED,MAAM,MAAM,eAAe,GAAG,gBAAgB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AA0JtE;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,QAAQ,GAAG,IAAI,CAmBvD;AAwND,qFAAqF;AACrF,eAAO,MAAM,QAAQ;;;;;;;;;CAWnB,CAAC;AAEH,6EAA6E;AAC7E,wBAAgB,aAAa,CAAC,OAAO,GAAE,eAAoB,GAAG,MAAM,IAAI,CAEvE"}