@superwall/studio 2.1.1 → 2.2.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/dist/assets/index-DQ--wQrM.js +11 -0
- package/dist/assets/index-FbZPTKMZ.css +1 -0
- package/dist/index.html +2 -2
- package/dist/lib/components/NotificationPreview.d.ts +18 -0
- package/dist/lib/components/PaywallToasts.d.ts +8 -2
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +1653 -1359
- package/dist/lib/lib/actions.d.ts +2 -2
- package/dist/lib/lib/contract.d.ts +4 -0
- package/dist/lib/lib/devices.d.ts +4 -0
- package/dist/lib/lib/project.d.ts +2 -1
- package/dist/lib/lib/surfaces.d.ts +8 -3
- package/dist/lib/lib/time.d.ts +1 -0
- package/dist/lib/studio.css +1 -1
- package/package.json +2 -2
- package/src/components/DownloadScreenshot.tsx +93 -31
- package/src/components/NotificationPreview.tsx +228 -0
- package/src/components/PaywallToasts.tsx +92 -5
- package/src/components/preview/Canvas.tsx +67 -10
- package/src/index.ts +2 -0
- package/src/lib/actions.ts +6 -3
- package/src/lib/contract.ts +5 -0
- package/src/lib/devices.ts +12 -0
- package/src/lib/notices.ts +0 -1
- package/src/lib/project.ts +11 -0
- package/src/lib/surfaces.ts +9 -1
- package/src/lib/time.ts +13 -6
- package/src/screens/SurfaceEditor.tsx +7 -1
- package/dist/assets/index-0QL9585B.js +0 -11
- package/dist/assets/index-DVQfR2L6.css +0 -1
package/src/lib/time.ts
CHANGED
|
@@ -7,14 +7,21 @@ const UNITS: [number, Intl.RelativeTimeFormatUnit][] = [
|
|
|
7
7
|
[12, "month"],
|
|
8
8
|
];
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
const then = Date.parse(iso);
|
|
12
|
-
if (Number.isNaN(then)) return undefined;
|
|
13
|
-
let value = Math.max(0, (now - then) / 1000);
|
|
10
|
+
const relative = (seconds: number): string => {
|
|
14
11
|
const formatter = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
|
|
12
|
+
const sign = Math.sign(seconds) || 1;
|
|
13
|
+
let value = Math.abs(seconds);
|
|
15
14
|
for (const [factor, unit] of UNITS) {
|
|
16
|
-
if (value < factor) return formatter.format(
|
|
15
|
+
if (value < factor) return formatter.format(sign * Math.round(value), unit);
|
|
17
16
|
value /= factor;
|
|
18
17
|
}
|
|
19
|
-
return formatter.format(
|
|
18
|
+
return formatter.format(sign * Math.round(value), "year");
|
|
20
19
|
};
|
|
20
|
+
|
|
21
|
+
export const timeAgo = (iso: string, now = Date.now()): string | undefined => {
|
|
22
|
+
const then = Date.parse(iso);
|
|
23
|
+
if (Number.isNaN(then)) return undefined;
|
|
24
|
+
return relative(-Math.max(0, (now - then) / 1000));
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const timeUntil = (ms: number): string => relative(Math.max(0, ms) / 1000);
|
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
deviceById,
|
|
42
42
|
deviceVariablesFor,
|
|
43
43
|
isWebOnly,
|
|
44
|
+
notificationScreenFor,
|
|
44
45
|
webViewportFor,
|
|
45
46
|
RESPONSIVE_DEFAULT,
|
|
46
47
|
RESPONSIVE_ID,
|
|
@@ -254,7 +255,6 @@ export const SurfaceEditor = ({
|
|
|
254
255
|
React.useEffect(() => () => window.clearTimeout(dismissTimer.current), []);
|
|
255
256
|
|
|
256
257
|
const shipping = source.actions;
|
|
257
|
-
const delegate = useStudioDelegate();
|
|
258
258
|
const defaults = React.useMemo(studioDefaults, [surface]);
|
|
259
259
|
|
|
260
260
|
const locales = surface.locales;
|
|
@@ -321,6 +321,12 @@ export const SurfaceEditor = ({
|
|
|
321
321
|
? webViewportFor(device)
|
|
322
322
|
: { width: device.width, height: device.height };
|
|
323
323
|
const presentation = web ? undefined : surface.presentation;
|
|
324
|
+
const reminderScreen = notificationScreenFor(device, web || responsive);
|
|
325
|
+
const delegate = useStudioDelegate({
|
|
326
|
+
platform: reminderScreen.platform,
|
|
327
|
+
screenWidth: reminderScreen.width,
|
|
328
|
+
app: source.app ?? { name: surface.project ?? source.title },
|
|
329
|
+
});
|
|
324
330
|
const frame = landscape ? { width: upright.height, height: upright.width } : upright;
|
|
325
331
|
|
|
326
332
|
const openPreview = () => {
|