@katajere/recap 2.1.8 → 2.1.10

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.
@@ -236,6 +236,9 @@
236
236
  flex-direction: column;
237
237
  }
238
238
 
239
+ .s26-milestone-copy { gap: 10px; align-items: flex-start; }
240
+ .s26-milestone-copy > .s26-text { margin: 0; }
241
+
239
242
  .s26-chip {
240
243
  display: inline-flex;
241
244
  align-items: center;
@@ -1 +1 @@
1
- {"version":3,"file":"slides.d.ts","sourceRoot":"","sources":["../../src/top10/slides.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAgB9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAQtE,OAAO,kBAAkB,CAAC;AAC1B,OAAO,mBAAmB,CAAC;AAE3B,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,eAAO,MAAM,MAAM,GAAI,MAAM,SAAS,WAAsB,CAAC;AAE7D,eAAO,MAAM,gBAAgB,GAAI,MAAM,SAAS,YACgE,CAAC;AAEjH,UAAU,eAAgB,SAAQ,UAAU;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAGD,wBAAgB,UAAU,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,aAAiC,EAAE,EAAE,eAAe,2CA4BtG;AAED,UAAU,OAAO;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6JAA6J;IAC7J,MAAM,CAAC,EAAE,K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C;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAGD,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,aAA0B,EAAE,EAAE,mBAAmB,2CAqBjG;AAeD,wBAAgB,YAAY,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAe,EAAE,EAAE,UAAU,GAAG;IAAE,QAAQ,EAAE,aAAa,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,2CA+D5H"}
@@ -1,7 +1,8 @@
1
1
  import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useEffect, useState } from 'react';
2
3
  import { motion } from 'framer-motion';
3
4
  import { RECAP_CATEGORIES } from '../categories';
4
- import { shareRecapVideo } from '../utils/shareRecapVideo';
5
+ import { canShareRecapMp4, loadRecapMp4, shareRecapMp4 } from '../utils/shareRecapVideo';
5
6
  import { BiggestDayIllustration, ClosingIllustration, CustomersIllustration, GrowthIllustration, HorizonIllustration, OrdersIllustration, PlugIllustration, SurpriseIllustration, } from './illustrations';
6
7
  import { countInWords, dayAndMonth, formatMoney, fullMonthName, shortDateUpper } from './format';
7
8
  import { useCanvasSqueeze, useContentShift } from './useCanvasScale';
@@ -91,7 +92,7 @@ const cardRock = loop(0.6, 4, [0, 1, 2, 3, 4], { rotate: [0, 1.5, 0, -1.5, 0] },
91
92
  export function MilestoneSlide({ data }) {
92
93
  const milestone = data.milestone;
93
94
  const milestoneValue = formatMoney(milestone.amount, data.currency, { spaced: true, preserveMinorUnits: true });
94
- return (_jsxs(_Fragment, { children: [_jsx(At, { top: 100, children: _jsx("p", { className: "s26-text s26-eyebrow", children: "Your order value" }) }), _jsx(Illustration, { top: 133.5, height: 330, entrance: popIn(0.1, { scale: 0.9, rotate: -6 }), children: _jsx(motion.img, { src: milestoneIllustration, alt: "", width: 343, height: 330, className: "s26-illustration-image", ...cardRock }) }), _jsx(At, { top: 487, anchor: "bottom", delay: 0.2, children: _jsx("p", { className: "s26-text s26-h2 s26-accent", children: milestoneValue }) }), _jsx(At, { top: 560, anchor: "bottom", delay: 0.5, children: _jsx("p", { className: "s26-text s26-h4", children: "You Hit a Milestone" }) }), _jsx(At, { top: 606, anchor: "bottom", delay: 0.6, children: _jsxs("p", { className: "s26-text s26-body", children: ["You reached ", milestoneValue, " in ", isPaidOrderRecap(data) ? 'paid order value' : 'order value', " on Huxxle."] }) }), _jsx(At, { top: 665, anchor: "bottom", delay: 0.8, children: _jsx("span", { className: "s26-chip", children: _jsx("span", { className: "s26-text s26-body", children: shortDateUpper(milestone.reachedOn) }) }) })] }));
95
+ return (_jsxs(_Fragment, { children: [_jsx(At, { top: 100, children: _jsx("p", { className: "s26-text s26-eyebrow", children: "Your order value" }) }), _jsx(Illustration, { top: 133.5, height: 330, entrance: popIn(0.1, { scale: 0.9, rotate: -6 }), children: _jsx(motion.img, { src: milestoneIllustration, alt: "", width: 343, height: 330, className: "s26-illustration-image", ...cardRock }) }), _jsxs(At, { top: 450, anchor: "bottom", className: "s26-stack s26-milestone-copy", children: [_jsx(motion.p, { className: "s26-text s26-h2 s26-accent", ...fadeIn(0.2), children: milestoneValue }), _jsx(motion.p, { className: "s26-text s26-h4", ...fadeIn(0.5), children: "You Hit a Milestone" }), _jsxs(motion.p, { className: "s26-text s26-body", ...fadeIn(0.6), children: ["You reached ", milestoneValue, " in ", isPaidOrderRecap(data) ? 'paid order value' : 'order value', " on Huxxle."] }), _jsx(motion.span, { className: "s26-chip", ...fadeIn(0.8), children: _jsx("span", { className: "s26-text s26-body", children: shortDateUpper(milestone.reachedOn) }) })] })] }));
95
96
  }
96
97
  // TF-09 Build-up (18679:60162)
97
98
  export function BuildUpSlide({ data }) {
@@ -131,7 +132,30 @@ function validVideoUrl(videoUrl) {
131
132
  export function ClosingSlide({ data, controls, welcome = false }) {
132
133
  const year = yearOf(data);
133
134
  const videoUrl = validVideoUrl(data.videoUrl);
135
+ const [download, setDownload] = useState();
136
+ const currentDownload = download?.url === videoUrl ? download : undefined;
137
+ const preparingVideo = currentDownload?.pending === true;
138
+ useEffect(() => {
139
+ if (!videoUrl || !canShareRecapMp4())
140
+ return;
141
+ const controller = new AbortController();
142
+ let mounted = true;
143
+ setDownload({ url: videoUrl, pending: true });
144
+ const timeout = window.setTimeout(() => controller.abort(), 10000);
145
+ void loadRecapMp4(videoUrl, year, controller.signal)
146
+ .catch(() => undefined)
147
+ .then(file => {
148
+ if (mounted)
149
+ setDownload({ url: videoUrl, pending: false, file });
150
+ })
151
+ .finally(() => window.clearTimeout(timeout));
152
+ return () => {
153
+ mounted = false;
154
+ window.clearTimeout(timeout);
155
+ controller.abort();
156
+ };
157
+ }, [videoUrl, year]);
134
158
  return (_jsxs(_Fragment, { children: [_jsx(Illustration, { top: 64, height: 310, children: _jsx(ClosingIllustration, {}) }), _jsxs(At, { top: 423, anchor: "bottom", className: "s26-stack s26-centered", style: { gap: 24 }, children: [_jsx(motion.p, { className: "s26-text s26-closing__title", ...fadeIn(1.0), initial: data.isVideo ? false : { opacity: 0 }, children: welcome ? "Make It Yours" : "Take Your Flowers" }), _jsx(motion.p, { className: "s26-text s26-body", ...fadeIn(1.2), initial: data.isVideo ? false : { opacity: 0 }, children: welcome
135
159
  ? 'Add your business details whenever you’re ready.'
136
- : _jsxs(_Fragment, { children: ["Sit back and be proud of the business you're building. ", year + 1, " isn't ready for you."] }) })] }), _jsxs(At, { top: 555, anchor: "bottom", className: "s26-stack", style: { gap: 12 }, children: [_jsxs(motion.button, { type: "button", className: "s26-button s26-button--primary", disabled: !videoUrl, title: videoUrl ? undefined : 'Sharing is available when your recap video is ready', onClick: videoUrl ? () => shareRecapVideo(videoUrl, year) : undefined, ...fadeIn(1.8), children: [_jsx("img", { src: shareIcon, alt: "", width: 24, height: 24 }), _jsx("span", { className: "s26-text s26-button__label", children: "Share My Recap" })] }), _jsxs(motion.button, { type: "button", className: "s26-button s26-button--secondary", onClick: controls.restart, ...fadeIn(2.0), children: [_jsx("img", { src: replayIcon, alt: "", width: 24, height: 24 }), _jsx("span", { className: "s26-text s26-button__label", children: "Replay Recap" })] })] }), _jsx(At, { top: 687, anchor: "bottom", delay: 2.2, className: "s26-centered", children: _jsxs("p", { className: "s26-text s26-body-sm s26-closing__footer", children: ["Your ", year, " business story, powered by Huxxle"] }) })] }));
160
+ : _jsxs(_Fragment, { children: ["Sit back and be proud of the business you're building. ", year + 1, " isn't ready for you."] }) })] }), _jsxs(At, { top: 555, anchor: "bottom", className: "s26-stack", style: { gap: 12 }, children: [_jsxs(motion.button, { type: "button", className: "s26-button s26-button--primary", disabled: !videoUrl || preparingVideo, "aria-busy": preparingVideo, title: videoUrl ? undefined : 'Sharing is available when your recap video is ready', onClick: videoUrl ? () => shareRecapMp4(videoUrl, currentDownload?.file) : undefined, ...fadeIn(1.8), children: [_jsx("img", { src: shareIcon, alt: "", width: 24, height: 24 }), _jsx("span", { className: "s26-text s26-button__label", children: preparingVideo ? 'Preparing video…' : 'Share My Recap' })] }), _jsxs(motion.button, { type: "button", className: "s26-button s26-button--secondary", onClick: controls.restart, ...fadeIn(2.0), children: [_jsx("img", { src: replayIcon, alt: "", width: 24, height: 24 }), _jsx("span", { className: "s26-text s26-button__label", children: "Replay Recap" })] })] }), _jsx(At, { top: 687, anchor: "bottom", delay: 2.2, className: "s26-centered", children: _jsxs("p", { className: "s26-text s26-body-sm s26-closing__footer", children: ["Your ", year, " business story, powered by Huxxle"] }) })] }));
137
161
  }
@@ -3,4 +3,8 @@
3
3
  * WhatsApp Status), else as a link, else by opening it in a new tab.
4
4
  */
5
5
  export declare function shareRecapVideo(videoUrl: string, year: number): Promise<void>;
6
+ export declare function canShareRecapMp4(): boolean;
7
+ /** Load the file before the click so the native share sheet keeps user activation. */
8
+ export declare function loadRecapMp4(videoUrl: string, year: number, signal: AbortSignal): Promise<File | undefined>;
9
+ export declare function shareRecapMp4(videoUrl: string, file?: File): Promise<void>;
6
10
  //# sourceMappingURL=shareRecapVideo.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shareRecapVideo.d.ts","sourceRoot":"","sources":["../../src/utils/shareRecapVideo.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAuCnF"}
1
+ {"version":3,"file":"shareRecapVideo.d.ts","sourceRoot":"","sources":["../../src/utils/shareRecapVideo.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAuCnF;AAID,wBAAgB,gBAAgB,IAAI,OAAO,CAI1C;AAED,sFAAsF;AACtF,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CAUjH;AAED,wBAAsB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBhF"}
@@ -38,3 +38,44 @@ export async function shareRecapVideo(videoUrl, year) {
38
38
  window.open(videoUrl, '_blank', 'noopener');
39
39
  }
40
40
  }
41
+ const MAX_RECAP_SHARE_BYTES = 16 * 1024 * 1024;
42
+ export function canShareRecapMp4() {
43
+ return Boolean(typeof navigator.share === 'function' && navigator.canShare?.({
44
+ files: [new File([new Uint8Array(1)], 'recap.mp4', { type: 'video/mp4' })],
45
+ }));
46
+ }
47
+ /** Load the file before the click so the native share sheet keeps user activation. */
48
+ export async function loadRecapMp4(videoUrl, year, signal) {
49
+ const response = await fetch(videoUrl, { signal });
50
+ if (!response.ok || response.headers.get('Content-Type')?.split(';')[0] !== 'video/mp4')
51
+ return;
52
+ if (Number(response.headers.get('Content-Length')) > MAX_RECAP_SHARE_BYTES) {
53
+ await response.body?.cancel();
54
+ return;
55
+ }
56
+ const blob = await response.blob();
57
+ if (blob.size === 0 || blob.size > MAX_RECAP_SHARE_BYTES)
58
+ return;
59
+ return new File([blob], `huxxle-wrapped-${year}.mp4`, { type: 'video/mp4' });
60
+ }
61
+ export async function shareRecapMp4(videoUrl, file) {
62
+ try {
63
+ if (navigator.share) {
64
+ const title = 'My Huxxle Recap';
65
+ if (file && navigator.canShare?.({ files: [file] })) {
66
+ await navigator.share({ title, files: [file] });
67
+ }
68
+ else {
69
+ await navigator.share({ title, url: videoUrl });
70
+ }
71
+ return;
72
+ }
73
+ window.open(videoUrl, '_blank', 'noopener');
74
+ }
75
+ catch (error) {
76
+ if (error instanceof Error && error.name === 'AbortError')
77
+ return;
78
+ // Opening the signed link also gives unsupported share targets a download.
79
+ window.open(videoUrl, '_blank', 'noopener');
80
+ }
81
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@katajere/recap",
3
- "version": "2.1.8",
3
+ "version": "2.1.10",
4
4
  "description": "Vendor Year in Review Experience - Recap your business metrics for 2025",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -236,6 +236,9 @@
236
236
  flex-direction: column;
237
237
  }
238
238
 
239
+ .s26-milestone-copy { gap: 10px; align-items: flex-start; }
240
+ .s26-milestone-copy > .s26-text { margin: 0; }
241
+
239
242
  .s26-chip {
240
243
  display: inline-flex;
241
244
  align-items: center;
@@ -1,10 +1,10 @@
1
- import React from 'react';
1
+ import React, { useEffect, useState } from 'react';
2
2
  import type { CSSProperties, ReactNode } from 'react';
3
3
  import { motion } from 'framer-motion';
4
4
  import type { RecapData } from '../types';
5
5
  import type { StoryControls } from '../story';
6
6
  import { RECAP_CATEGORIES } from '../categories';
7
- import { shareRecapVideo } from '../utils/shareRecapVideo';
7
+ import { canShareRecapMp4, loadRecapMp4, shareRecapMp4 } from '../utils/shareRecapVideo';
8
8
  import {
9
9
  BiggestDayIllustration,
10
10
  ClosingIllustration,
@@ -363,21 +363,15 @@ export function MilestoneSlide({ data }: SlideProps) {
363
363
  {...cardRock}
364
364
  />
365
365
  </Illustration>
366
- <At top={487} anchor="bottom" delay={0.2}>
367
- <p className="s26-text s26-h2 s26-accent">{milestoneValue}</p>
368
- </At>
369
- <At top={560} anchor="bottom" delay={0.5}>
370
- <p className="s26-text s26-h4">You Hit a Milestone</p>
371
- </At>
372
- <At top={606} anchor="bottom" delay={0.6}>
373
- <p className="s26-text s26-body">
366
+ <At top={450} anchor="bottom" className="s26-stack s26-milestone-copy">
367
+ <motion.p className="s26-text s26-h2 s26-accent" {...fadeIn(0.2)}>{milestoneValue}</motion.p>
368
+ <motion.p className="s26-text s26-h4" {...fadeIn(0.5)}>You Hit a Milestone</motion.p>
369
+ <motion.p className="s26-text s26-body" {...fadeIn(0.6)}>
374
370
  You reached {milestoneValue} in {isPaidOrderRecap(data) ? 'paid order value' : 'order value'} on Huxxle.
375
- </p>
376
- </At>
377
- <At top={665} anchor="bottom" delay={0.8}>
378
- <span className="s26-chip">
371
+ </motion.p>
372
+ <motion.span className="s26-chip" {...fadeIn(0.8)}>
379
373
  <span className="s26-text s26-body">{shortDateUpper(milestone.reachedOn)}</span>
380
- </span>
374
+ </motion.span>
381
375
  </At>
382
376
  </>
383
377
  );
@@ -525,6 +519,27 @@ function validVideoUrl(videoUrl?: string): string | undefined {
525
519
  export function ClosingSlide({ data, controls, welcome = false }: SlideProps & { controls: StoryControls; welcome?: boolean }) {
526
520
  const year = yearOf(data);
527
521
  const videoUrl = validVideoUrl(data.videoUrl);
522
+ const [download, setDownload] = useState<{ url: string; pending: boolean; file?: File }>();
523
+ const currentDownload = download?.url === videoUrl ? download : undefined;
524
+ const preparingVideo = currentDownload?.pending === true;
525
+ useEffect(() => {
526
+ if (!videoUrl || !canShareRecapMp4()) return;
527
+ const controller = new AbortController();
528
+ let mounted = true;
529
+ setDownload({ url: videoUrl, pending: true });
530
+ const timeout = window.setTimeout(() => controller.abort(), 10000);
531
+ void loadRecapMp4(videoUrl, year, controller.signal)
532
+ .catch(() => undefined)
533
+ .then(file => {
534
+ if (mounted) setDownload({ url: videoUrl, pending: false, file });
535
+ })
536
+ .finally(() => window.clearTimeout(timeout));
537
+ return () => {
538
+ mounted = false;
539
+ window.clearTimeout(timeout);
540
+ controller.abort();
541
+ };
542
+ }, [videoUrl, year]);
528
543
 
529
544
  return (
530
545
  <>
@@ -545,13 +560,14 @@ export function ClosingSlide({ data, controls, welcome = false }: SlideProps & {
545
560
  <motion.button
546
561
  type="button"
547
562
  className="s26-button s26-button--primary"
548
- disabled={!videoUrl}
563
+ disabled={!videoUrl || preparingVideo}
564
+ aria-busy={preparingVideo}
549
565
  title={videoUrl ? undefined : 'Sharing is available when your recap video is ready'}
550
- onClick={videoUrl ? () => shareRecapVideo(videoUrl, year) : undefined}
566
+ onClick={videoUrl ? () => shareRecapMp4(videoUrl, currentDownload?.file) : undefined}
551
567
  {...fadeIn(1.8)}
552
568
  >
553
569
  <img src={shareIcon} alt="" width={24} height={24} />
554
- <span className="s26-text s26-button__label">Share My Recap</span>
570
+ <span className="s26-text s26-button__label">{preparingVideo ? 'Preparing video…' : 'Share My Recap'}</span>
555
571
  </motion.button>
556
572
  <motion.button type="button" className="s26-button s26-button--secondary" onClick={controls.restart} {...fadeIn(2.0)}>
557
573
  <img src={replayIcon} alt="" width={24} height={24} />
@@ -42,3 +42,43 @@ export async function shareRecapVideo(videoUrl: string, year: number): Promise<v
42
42
  window.open(videoUrl, '_blank', 'noopener');
43
43
  }
44
44
  }
45
+
46
+ const MAX_RECAP_SHARE_BYTES = 16 * 1024 * 1024;
47
+
48
+ export function canShareRecapMp4(): boolean {
49
+ return Boolean(typeof navigator.share === 'function' && navigator.canShare?.({
50
+ files: [new File([new Uint8Array(1)], 'recap.mp4', { type: 'video/mp4' })],
51
+ }));
52
+ }
53
+
54
+ /** Load the file before the click so the native share sheet keeps user activation. */
55
+ export async function loadRecapMp4(videoUrl: string, year: number, signal: AbortSignal): Promise<File | undefined> {
56
+ const response = await fetch(videoUrl, { signal });
57
+ if (!response.ok || response.headers.get('Content-Type')?.split(';')[0] !== 'video/mp4') return;
58
+ if (Number(response.headers.get('Content-Length')) > MAX_RECAP_SHARE_BYTES) {
59
+ await response.body?.cancel();
60
+ return;
61
+ }
62
+ const blob = await response.blob();
63
+ if (blob.size === 0 || blob.size > MAX_RECAP_SHARE_BYTES) return;
64
+ return new File([blob], `huxxle-wrapped-${year}.mp4`, { type: 'video/mp4' });
65
+ }
66
+
67
+ export async function shareRecapMp4(videoUrl: string, file?: File): Promise<void> {
68
+ try {
69
+ if (navigator.share) {
70
+ const title = 'My Huxxle Recap';
71
+ if (file && navigator.canShare?.({ files: [file] })) {
72
+ await navigator.share({ title, files: [file] });
73
+ } else {
74
+ await navigator.share({ title, url: videoUrl });
75
+ }
76
+ return;
77
+ }
78
+ window.open(videoUrl, '_blank', 'noopener');
79
+ } catch (error) {
80
+ if (error instanceof Error && error.name === 'AbortError') return;
81
+ // Opening the signed link also gives unsupported share targets a download.
82
+ window.open(videoUrl, '_blank', 'noopener');
83
+ }
84
+ }