@superwall/cli 1.6.2 → 2.0.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/README.md +281 -34
- package/dist/apple-CkKlHBZ9.js +195 -0
- package/dist/auth.d.ts +4 -19
- package/dist/auth.js +4 -2
- package/dist/{actions-H7f6knyY.js → billing-XCZU_T46.js} +98 -28
- package/dist/{bind-BIzaGq8K.js → bind-drne__Ys.js} +38 -33
- package/dist/{build-B7BS1rF2.js → build-Gpdq5QXP.js} +20 -26
- package/dist/client-BZ1UbpXz.js +66 -0
- package/dist/client-DP6Rc0t_.js +176 -0
- package/dist/config-BO1Y87kV.js +105 -0
- package/dist/create-BBrtgUgS.js +969 -0
- package/dist/{create-CwnnNqv4.js → create-Cwc3SRWJ.js} +194 -168
- package/dist/create-Yvf2gStM.js +19 -0
- package/dist/doctor-C9ldpPFC.js +83 -0
- package/dist/{drivers-6RMOPIdn.js → drivers-DNrx4LWA.js} +185 -172
- package/dist/entry.d.ts +0 -5
- package/dist/entry.js +28083 -801
- package/dist/environment-DF1qKlny.js +58 -0
- package/dist/{existing-DHpPn1y6.js → existing-78LWSsqS.js} +12 -6
- package/dist/held-Cy8Wl4D1.js +1112 -0
- package/dist/held-Ddw1XSsr.js +16 -0
- package/dist/input-vi0bou04.js +42 -0
- package/dist/{integrate-BR2LR-EK.js → integrate-DcJhpXy8.js} +277 -253
- package/dist/kinds-GFXB3sYu.js +11 -0
- package/dist/log-NVhVe_oe.js +62 -0
- package/dist/login-B2TsCE2H.js +53 -0
- package/dist/login-BoBe8Psl.js +16 -0
- package/dist/{login-Bhxgqwtm.js → login-D0lh3_JI.js} +144 -66
- package/dist/lookup-D-nmmAbw.js +71 -0
- package/dist/migrate-Cfec564E.js +274 -0
- package/dist/notification-url-YDbq6FMA.js +100 -0
- package/dist/{open-studio-BnVD6tJ9.js → open-Ba2vBl1_.js} +34 -43
- package/dist/org-D0g_q3mv.js +35 -0
- package/dist/output-Ggzq5_-t.js +122 -0
- package/dist/paths-DxSLdpOI.js +29 -0
- package/dist/playbook-DIeb7hne.js +53 -0
- package/dist/{asc-products-Dvcyef3_.js → products-DH_fK9tY.js} +6 -39
- package/dist/promote-COD4fYdz.js +91 -0
- package/dist/push-CncywhkQ.js +482 -0
- package/dist/push-CtD4FZQV.js +22 -0
- package/dist/registry-DSrosOYs.js +10228 -0
- package/dist/{reports-DqMs9xNR.js → reports-DdPq4blM.js} +7 -6
- package/dist/{resources-Bf9O1JNM.js → resources-Dqr01Dep.js} +150 -55
- package/dist/{run-D-NbZLpj.js → run-C9qg_QlC.js} +16 -22
- package/dist/scan-Cv5uOwVY.js +4 -0
- package/dist/{scan-BmAW413l.js → scan-DLrsrFS9.js} +48 -37
- package/dist/scope-V336uz8j.js +198 -0
- package/dist/screenshot-file-0UETadF8.js +16 -0
- package/dist/{selection-BGi6GyxC.js → selection-Rdw-ZUoG.js} +94 -51
- package/dist/send-BxD9yf6F.js +150 -0
- package/dist/{dev-CgGAb5Al.js → server-D0tGG8C4.js} +82 -87
- package/dist/server-z1LH94R_.js +22 -0
- package/dist/session-1AV_Bs_d.js +6 -0
- package/dist/session-CFAmMhem.js +40 -0
- package/dist/session-D_nEWKXT.js +768 -0
- package/dist/skills/animate-onboarding/SKILL.md +467 -0
- package/dist/skills/animate-onboarding/references/engine.md +494 -0
- package/dist/skills/animate-onboarding/references/framework/Question.tsx +71 -0
- package/dist/skills/animate-onboarding/references/framework/README.md +40 -0
- package/dist/skills/animate-onboarding/references/framework/answers.ts +19 -0
- package/dist/skills/animate-onboarding/references/framework/flow.ts +80 -0
- package/dist/skills/animate-onboarding/references/framework/handoffs.ts +869 -0
- package/dist/skills/animate-onboarding/references/framework/layout.tsx +113 -0
- package/dist/skills/animate-onboarding/references/framework/motion.css +559 -0
- package/dist/skills/animate-onboarding/references/framework/useStoryRouter.ts +48 -0
- package/dist/skills/animate-onboarding/references/handoffs.md +375 -0
- package/dist/skills/animate-onboarding/references/imageReady.ts +92 -0
- package/dist/skills/animate-onboarding/references/morphFrame.ts +356 -0
- package/dist/skills/animate-onboarding/references/performance.md +41 -0
- package/dist/skills/animate-onboarding/references/web-runtime/README.md +17 -0
- package/dist/skills/animate-onboarding/references/web-runtime/handoffs.ts +858 -0
- package/dist/skills/animate-onboarding/references/web-runtime/story-motion.css +301 -0
- package/dist/skills/index.json +37 -0
- package/dist/skills/mobile-design/SKILL.md +447 -0
- package/dist/skills/mobile-design/references/responsive.md +162 -0
- package/dist/skills/onboarding-questions/SKILL.md +231 -0
- package/dist/skills/onboarding-questions/references/arpu-questions.md +139 -0
- package/dist/skills/onboarding-questions/references/craft.md +142 -0
- package/dist/skills/onboarding-questions/references/example-reflective.md +117 -0
- package/dist/skills/superwall/SKILL.md +82 -9
- package/dist/skills/superwall/references/api.md +153 -37
- package/dist/skills/superwall/references/apple-setup.md +316 -0
- package/dist/skills/superwall/references/asc.md +74 -38
- package/dist/skills/superwall/references/data-analytics.md +55 -21
- package/dist/skills/superwall/workflows/dashboard/playbook.md +3 -3
- package/dist/skills/superwall/workflows/dashboard/setup.md +8 -8
- package/dist/skills/superwall/workflows/migrate/adapty.md +6 -6
- package/dist/skills/superwall/workflows/migrate/playbook.md +4 -4
- package/dist/skills/superwall/workflows/migrate/qonversion.md +5 -5
- package/dist/skills/superwall/workflows/migrate/revenuecat.md +6 -6
- package/dist/skills/superwall/workflows/placements/android.md +2 -2
- package/dist/skills/superwall/workflows/placements/expo.md +2 -2
- package/dist/skills/superwall/workflows/placements/flutter.md +2 -2
- package/dist/skills/superwall/workflows/placements/ios.md +2 -2
- package/dist/skills/superwall/workflows/placements/playbook.md +2 -2
- package/dist/skills/superwall/workflows/placements/react-native.md +2 -2
- package/dist/skills/superwall/workflows/placements/strategy.md +2 -2
- package/dist/skills/superwall/workflows/review/playbook.md +1 -1
- package/dist/skills/superwall-editor/SKILL.md +61 -0
- package/dist/skills/superwall-editor/references/cli.md +135 -0
- package/dist/skills/superwall-editor/references/design.md +51 -0
- package/dist/skills/superwall-editor/references/native-elements.md +171 -0
- package/dist/skills/superwall-editor/references/workflow.md +65 -0
- package/dist/skills/superwall-editor/scripts/sw-editor.sh +662 -0
- package/dist/skills/superwall-framework/SKILL.md +78 -28
- package/dist/skills/superwall-framework/references/cli.md +58 -28
- package/dist/skills/superwall-framework/references/examples.md +4 -3
- package/dist/skills/superwall-framework/references/layout.md +30 -8
- package/dist/skills/superwall-framework/references/migrate-from-editor.md +1 -1
- package/dist/skills/superwall-framework/references/onboarding-state.md +245 -0
- package/dist/skills/wwdc/SKILL.md +22 -0
- package/dist/skills/wwdc/references/docs.md +52 -0
- package/dist/skills/wwdc/scripts/wwdc.sh +266 -0
- package/dist/{skills-AxAf7bDB.js → skills-BvFOa4y6.js} +99 -122
- package/dist/skills-DMG4bpKk.js +14 -0
- package/dist/{spawn-DSoTXy_j.js → spawn-DmmmHIP-.js} +14 -12
- package/dist/spinner-CneRK5rk.js +294 -0
- package/dist/storage-DYvmIOHa.d.ts +16 -0
- package/dist/storage-s2Dnz-yl.js +31 -0
- package/dist/storekit-DafAnGkM.js +16 -0
- package/dist/storekit-yY_kS2iR.js +47 -0
- package/dist/telemetry-DtG92m5O.js +56 -0
- package/dist/theme-DUsCh-Vd.js +25 -0
- package/dist/timing-BVxPrYq3.js +5 -0
- package/dist/{token-BGAVPSQc.js → token-DzRh7dI1.js} +6 -38
- package/dist/tools.d.ts +96 -0
- package/dist/tools.js +11178 -0
- package/dist/ui-D_qf3Gvw.js +53 -0
- package/dist/upgrade-Bt4Ouw1y.js +117 -0
- package/dist/upgrade-Cqy5orjb.js +7 -0
- package/package.json +10 -5
- package/dist/api-Dv3LyZ5m.js +0 -151
- package/dist/api-output-aJNw7Syy.js +0 -20
- package/dist/app-mJC5NDtW.js +0 -189
- package/dist/asa-D6H7Pjae.js +0 -1194
- package/dist/asc-xCin0akG.js +0 -539
- package/dist/auth-ZlLL-Gko.js +0 -139
- package/dist/billing-C8kBge_S.js +0 -80
- package/dist/command-3fGYyC8r.js +0 -301
- package/dist/dev-Dx99K183.js +0 -22
- package/dist/doctor-CyUvut31.js +0 -88
- package/dist/feedback-RKyGuQ8_.js +0 -152
- package/dist/hosted-BeGVAntr.js +0 -32
- package/dist/migrate-C-4ISELN.js +0 -284
- package/dist/org-CQduIOic.js +0 -40
- package/dist/output-C-4UKMot.js +0 -136
- package/dist/params-l3CrvRtR.js +0 -51
- package/dist/pipeline-CHX0Syre.js +0 -977
- package/dist/print-skill-BiZLdCKv.js +0 -74
- package/dist/promote-Pgpz-3xl.js +0 -88
- package/dist/publish-BPeuc3lq.js +0 -35
- package/dist/push-DcSQ4odB.js +0 -35
- package/dist/query-CWLaZkdm.js +0 -53
- package/dist/resource-jwASPCrw.js +0 -483
- package/dist/skills-FK5aDuNV.js +0 -64
- package/dist/spinner-DFctF_Jw.js +0 -18
- package/dist/storekit-CC4gnTI6.js +0 -29
- package/dist/telemetry-Ch9cCTI-.js +0 -169
- package/dist/ui-4gLyfrgl.js +0 -27737
- package/dist/update-DIXbL-H9.js +0 -59
- package/dist/upgrade-De7JMI1g.js +0 -72
- /package/dist/{devtools-8EgLo86w.js → devtools-ByZ6XYnn.js} +0 -0
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
// THE way to morph Frame A into Frame B (one frame, two faces, one geometry), as shipped on
|
|
2
|
+
// Reflective's web2app, with one addition for the superwall framework: the frame is mounted into
|
|
3
|
+
// the layout's motion layer (`mount`), never `document.body`, because a surface never positions
|
|
4
|
+
// anything fixed and its pages are absolute layers inside the framework's content box.
|
|
5
|
+
|
|
6
|
+
import { decodedCopy } from "./imageReady";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Frame A → Frame B morphs. The one rule: **A and B share the same geometry at
|
|
10
|
+
* every moment of the transition.** Not "two copies driven by the same numbers" —
|
|
11
|
+
* those drift apart the moment one has its own rounded corners, border, margin,
|
|
12
|
+
* blur or rounding error, and the eye catches it instantly.
|
|
13
|
+
*
|
|
14
|
+
* So there is exactly one frame, and it alone owns the geometry:
|
|
15
|
+
*
|
|
16
|
+
* outer (fixed at `home`, no transform) — the blur, in screen pixels
|
|
17
|
+
* middle — the transform: translate to the box's centre, scale only *up*
|
|
18
|
+
* clipper — the clip-path: the box's size and corner radius
|
|
19
|
+
* face A — fills the clipper; opacity only
|
|
20
|
+
* face B — fills the clipper; opacity only, on top
|
|
21
|
+
*
|
|
22
|
+
* The faces never have a shape of their own (no radius, border, margin or
|
|
23
|
+
* transform of their own): they fill the frame, and the frame's clip is the
|
|
24
|
+
* only outline anyone sees. A and B cannot differ in geometry because there is
|
|
25
|
+
* only one geometry.
|
|
26
|
+
*
|
|
27
|
+
* Usage, answer → photo:
|
|
28
|
+
*
|
|
29
|
+
* const answer = fillFace(answerEl, answerRect); // capture before the page swaps
|
|
30
|
+
* // …swap the page…
|
|
31
|
+
* const { frame, animations, faces } = morph({
|
|
32
|
+
* from: { rect: answerRect, radius: answerRect.height / 2 },
|
|
33
|
+
* to: { rect: photoRect, radius: 20 },
|
|
34
|
+
* faces: { from: answer, to: photoFace(photoEl) },
|
|
35
|
+
* duration: 504,
|
|
36
|
+
* });
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* One switch for every blur in the hand-offs (the morph frame's motion blur and the answers gathering
|
|
41
|
+
* into a photo). Off gives the same motion with no blur.
|
|
42
|
+
*/
|
|
43
|
+
export const MOTION_BLUR_ENABLED = true;
|
|
44
|
+
/** A blur amount, or 0 while motion blur is switched off. */
|
|
45
|
+
export const motionBlur = (px: number) => (MOTION_BLUR_ENABLED ? px : 0);
|
|
46
|
+
|
|
47
|
+
export type MorphEnd = { rect: DOMRect; radius: number };
|
|
48
|
+
/** Builds a face that fills the frame; given the frame's home rect (its size when unscaled). */
|
|
49
|
+
export type Face = (home: DOMRect) => HTMLElement;
|
|
50
|
+
|
|
51
|
+
/** The frame's shape at one moment, in screen pixels: centre, size, corner radius. */
|
|
52
|
+
export type Box = { cx: number; cy: number; w: number; h: number; r: number };
|
|
53
|
+
|
|
54
|
+
/** A corner radius as a fraction of the shape's shorter side (0.5 = fully round ends). */
|
|
55
|
+
export const roundness = (radius: number, w: number, h: number) =>
|
|
56
|
+
Math.min(0.5, radius / Math.max(1e-6, Math.min(w, h)));
|
|
57
|
+
|
|
58
|
+
export const lerp = (a: number, b: number, k: number) => a + (b - a) * k;
|
|
59
|
+
/** 0 before `a`, 1 after `b`, linear in between. */
|
|
60
|
+
export const span = (t: number, a: number, b: number) =>
|
|
61
|
+
t <= a ? 0 : t >= b ? 1 : (t - a) / (b - a);
|
|
62
|
+
/** 0 → 1 across [a, b] with zero speed at both ends. */
|
|
63
|
+
export const ease01 = (t: number, a: number, b: number) => {
|
|
64
|
+
const k = span(t, a, b);
|
|
65
|
+
return k * k * (3 - 2 * k);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The A → B clock: a critically damped spring (ζ = 1, Apple's default for UI: no overshoot) chasing
|
|
70
|
+
* a target that eases in from rest after a barely-there pull-back (~1%). It speeds up to its top
|
|
71
|
+
* speed early (~27% of the time) and then slows continuously over a long, gentle tail, so there's
|
|
72
|
+
* no constant-speed middle and no snap at the end; a final taper lands it exactly at rest on the
|
|
73
|
+
* last frame. Speed is continuous everywhere and zero at both ends.
|
|
74
|
+
*
|
|
75
|
+
* Tried and dropped: a quintic ease to a 1.5% overshoot at 82% with a ~90ms settle (linear-feeling
|
|
76
|
+
* middle, snappy bounce at the end); a stiff spring (~6% overshoot, back in ~75ms); stock
|
|
77
|
+
* ease-in-out-back (10% both ways, rushed middle).
|
|
78
|
+
*/
|
|
79
|
+
const CLOCK_RAMP = 0.25; // the target eases in over the first quarter
|
|
80
|
+
const CLOCK_OMEGA = 9; // spring stiffness, per transition length
|
|
81
|
+
const CLOCK_PULL = 0.6; // → ~1% pull-back
|
|
82
|
+
const CLOCK_TAPER = 0.12; // the last 12% eases the spring's tail exactly onto the target
|
|
83
|
+
const CLOCK_SAMPLES = 1200;
|
|
84
|
+
let clockTable: Float64Array | null = null;
|
|
85
|
+
|
|
86
|
+
function buildClock(): Float64Array {
|
|
87
|
+
const smoother = (u: number) => {
|
|
88
|
+
const k = Math.min(1, Math.max(0, u));
|
|
89
|
+
return k * k * k * (k * (k * 6 - 15) + 10);
|
|
90
|
+
};
|
|
91
|
+
const table = new Float64Array(CLOCK_SAMPLES + 1);
|
|
92
|
+
const dt = 1 / CLOCK_SAMPLES;
|
|
93
|
+
let x = 0;
|
|
94
|
+
let v = 0;
|
|
95
|
+
for (let i = 0; i <= CLOCK_SAMPLES; i++) {
|
|
96
|
+
const s = smoother((i * dt) / CLOCK_RAMP);
|
|
97
|
+
const target = s - CLOCK_PULL * Math.sin(Math.PI * s) * (1 - s);
|
|
98
|
+
table[i] = x;
|
|
99
|
+
v += (CLOCK_OMEGA * CLOCK_OMEGA * (target - x) - 2 * CLOCK_OMEGA * v) * dt; // ζ = 1
|
|
100
|
+
x += v * dt;
|
|
101
|
+
}
|
|
102
|
+
const end = table[CLOCK_SAMPLES];
|
|
103
|
+
for (let i = 0; i <= CLOCK_SAMPLES; i++) {
|
|
104
|
+
const y = table[i] / end;
|
|
105
|
+
table[i] = y + (1 - y) * ease01(i / CLOCK_SAMPLES, 1 - CLOCK_TAPER, 1);
|
|
106
|
+
}
|
|
107
|
+
return table;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function glideAt(t: number): number {
|
|
111
|
+
clockTable ??= buildClock();
|
|
112
|
+
const f = Math.min(1, Math.max(0, t)) * CLOCK_SAMPLES;
|
|
113
|
+
const i = Math.floor(f);
|
|
114
|
+
return i >= CLOCK_SAMPLES
|
|
115
|
+
? clockTable[CLOCK_SAMPLES]
|
|
116
|
+
: clockTable[i] + (clockTable[i + 1] - clockTable[i]) * (f - i);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Samples per morph; every channel is sampled from the same clock at the same instants. */
|
|
120
|
+
export const MORPH_STEPS = 30;
|
|
121
|
+
|
|
122
|
+
/** Up to a 20% dip for a dimension about equal at both ends (a bubble squeezing through); none once they differ by half. */
|
|
123
|
+
const dipFor = (x: number, y: number) =>
|
|
124
|
+
0.2 * Math.max(0, 1 - (Math.max(x, y) / Math.min(x, y) - 1) / 0.5);
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* The frame's box at clock value p (0 = a, 1 = b; a hair below 0 at the start). It travels
|
|
128
|
+
* on p and opens on p^1.5, so the move leads and the opening follows without either restarting;
|
|
129
|
+
* size only interpolates between the ends (never below 80% of the smaller); a dimension equal at
|
|
130
|
+
* both ends dips and swells back.
|
|
131
|
+
*
|
|
132
|
+
* Corners are proportional: the radius is interpolated as a fraction of the shorter side (its
|
|
133
|
+
* "roundness"), not in pixels. A fully round answer (0.5) opening into a square background (0)
|
|
134
|
+
* stays visibly rounded while it's big and only goes square at the end; pixel interpolation would
|
|
135
|
+
* leave a big frame with tiny, sharp-looking corners almost at once.
|
|
136
|
+
*/
|
|
137
|
+
function boxAt(a: Box, b: Box, p: number): Box {
|
|
138
|
+
const open = Math.sign(p) * Math.pow(Math.abs(p), 1.5);
|
|
139
|
+
const bulge = Math.sin(Math.PI * p);
|
|
140
|
+
const w = lerp(a.w, b.w, open) * (1 - dipFor(a.w, b.w) * bulge);
|
|
141
|
+
const h = lerp(a.h, b.h, open) * (1 - dipFor(a.h, b.h) * bulge);
|
|
142
|
+
const round = lerp(
|
|
143
|
+
roundness(a.r, a.w, a.h),
|
|
144
|
+
roundness(b.r, b.w, b.h),
|
|
145
|
+
Math.min(1, Math.max(0, open)),
|
|
146
|
+
);
|
|
147
|
+
return { cx: lerp(a.cx, b.cx, p), cy: lerp(a.cy, b.cy, p), w, h, r: round * Math.min(w, h) };
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const boxOf = ({ rect, radius }: MorphEnd): Box => ({
|
|
151
|
+
cx: rect.left + rect.width / 2,
|
|
152
|
+
cy: rect.top + rect.height / 2,
|
|
153
|
+
w: rect.width,
|
|
154
|
+
h: rect.height,
|
|
155
|
+
r: radius,
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
/** Makes `el` fill its parent exactly, with no shape of its own. */
|
|
159
|
+
function fill(el: HTMLElement) {
|
|
160
|
+
el.removeAttribute("style");
|
|
161
|
+
Object.assign(el.style, {
|
|
162
|
+
position: "absolute",
|
|
163
|
+
left: "0",
|
|
164
|
+
top: "0",
|
|
165
|
+
width: "100%",
|
|
166
|
+
height: "100%",
|
|
167
|
+
margin: "0",
|
|
168
|
+
border: "0",
|
|
169
|
+
borderRadius: "0",
|
|
170
|
+
boxShadow: "none",
|
|
171
|
+
transform: "none",
|
|
172
|
+
animation: "none",
|
|
173
|
+
transition: "none",
|
|
174
|
+
});
|
|
175
|
+
return el;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** A photo face: the decoded image covering the frame exactly as it covers its own box at rest. */
|
|
179
|
+
export function photoFace(img: HTMLImageElement): Face {
|
|
180
|
+
const copy = fill(decodedCopy(img));
|
|
181
|
+
copy.style.objectFit = "cover";
|
|
182
|
+
return () => copy;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* A face for a filled element (an answer capsule, a button): its colour fills the whole frame, so
|
|
187
|
+
* the frame's shape is the only shape, and a copy of its content sits where the element rests.
|
|
188
|
+
* Captures the element now (call it before the page swaps, while the element still exists).
|
|
189
|
+
*/
|
|
190
|
+
export function fillFace(el: HTMLElement, rest: DOMRect): Face {
|
|
191
|
+
const background = getComputedStyle(el).backgroundColor;
|
|
192
|
+
const content = el.cloneNode(true) as HTMLElement;
|
|
193
|
+
return (home) => {
|
|
194
|
+
const face = fill(document.createElement("div"));
|
|
195
|
+
face.style.background = background;
|
|
196
|
+
// Where the frame shows the element's own box, its content must sit: centred, at rest size
|
|
197
|
+
// (scaled by 1/k when that box is larger than the frame's home, as the frame scales it by k).
|
|
198
|
+
const k = Math.max(1, rest.width / home.width, rest.height / home.height);
|
|
199
|
+
content.removeAttribute("style");
|
|
200
|
+
Object.assign(content.style, {
|
|
201
|
+
position: "absolute",
|
|
202
|
+
left: `${(home.width - rest.width) / 2}px`,
|
|
203
|
+
top: `${(home.height - rest.height) / 2}px`,
|
|
204
|
+
width: `${rest.width}px`,
|
|
205
|
+
height: `${rest.height}px`,
|
|
206
|
+
margin: "0",
|
|
207
|
+
background: "transparent",
|
|
208
|
+
border: "0",
|
|
209
|
+
boxShadow: "none",
|
|
210
|
+
transform: k === 1 ? "none" : `scale(${1 / k})`,
|
|
211
|
+
animation: "none",
|
|
212
|
+
transition: "none",
|
|
213
|
+
});
|
|
214
|
+
face.appendChild(content);
|
|
215
|
+
return face;
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* A face that's just a colour: for a destination (or source) whose look is its fill, like a
|
|
221
|
+
* page background that ties to the chosen answer's colour.
|
|
222
|
+
*/
|
|
223
|
+
export function colorFace(color: string): Face {
|
|
224
|
+
return () => {
|
|
225
|
+
const face = fill(document.createElement("div"));
|
|
226
|
+
face.style.background = color;
|
|
227
|
+
return face;
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Morph Frame A into Frame B. `handover` is the clock window over which B fades in on top of A
|
|
233
|
+
* (A stays opaque underneath until B is fully in, so the frame never goes see-through); keep it
|
|
234
|
+
* inside the blur window so the swap happens under the blur. The blur is motion blur: crisp at both
|
|
235
|
+
* ends, blurred only while it's moving fastest — from 25% to 75% of the duration (easing in over
|
|
236
|
+
* 25–35%, full 35–65%, easing out over 65–75%). Returns the frame (remove it when done) and its
|
|
237
|
+
* animations (await them).
|
|
238
|
+
*/
|
|
239
|
+
export function morph({
|
|
240
|
+
from,
|
|
241
|
+
to,
|
|
242
|
+
faces,
|
|
243
|
+
duration,
|
|
244
|
+
handover = [0.45, 0.75],
|
|
245
|
+
blur = 5,
|
|
246
|
+
blurWindow = [0.25, 0.75],
|
|
247
|
+
zIndex = 31,
|
|
248
|
+
path,
|
|
249
|
+
steps = MORPH_STEPS,
|
|
250
|
+
mount,
|
|
251
|
+
}: {
|
|
252
|
+
from: MorphEnd;
|
|
253
|
+
to: MorphEnd;
|
|
254
|
+
faces: { from: Face; to: Face };
|
|
255
|
+
duration: number;
|
|
256
|
+
/** Clock window (p) over which B takes over. */
|
|
257
|
+
handover?: [number, number];
|
|
258
|
+
/** Peak blur, on-screen px. */
|
|
259
|
+
blur?: number;
|
|
260
|
+
/** Time window (fraction of the duration) the blur spans; crisp outside it. */
|
|
261
|
+
blurWindow?: [number, number];
|
|
262
|
+
zIndex?: number;
|
|
263
|
+
/**
|
|
264
|
+
* The frame's shape at each moment t (0–1), for a move with its own geometry (e.g. into the
|
|
265
|
+
* progress bar, right edge first). Must start exactly on `from` and end exactly on `to`.
|
|
266
|
+
*/
|
|
267
|
+
path?: (t: number) => Box;
|
|
268
|
+
/** Keyframe samples (make steps × any key moment a whole number so a sample lands on it). */
|
|
269
|
+
steps?: number;
|
|
270
|
+
/**
|
|
271
|
+
* Where the frame lives: a positioned layer and that layer's screen rect, so the frame is placed
|
|
272
|
+
* at `rect - origin` inside it. Defaults to document.body at page coordinates.
|
|
273
|
+
*/
|
|
274
|
+
mount?: { into: HTMLElement; origin: { left: number; top: number } };
|
|
275
|
+
}) {
|
|
276
|
+
// Home: the larger end, so the frame is only ever scaled up (never squashed).
|
|
277
|
+
const home =
|
|
278
|
+
from.rect.width * from.rect.height >= to.rect.width * to.rect.height ? from.rect : to.rect;
|
|
279
|
+
const outer = document.createElement("div");
|
|
280
|
+
outer.setAttribute("aria-hidden", "true");
|
|
281
|
+
outer.setAttribute("data-handoff-clone", "");
|
|
282
|
+
const origin = mount?.origin ?? { left: -window.scrollX, top: -window.scrollY };
|
|
283
|
+
Object.assign(outer.style, {
|
|
284
|
+
position: "absolute",
|
|
285
|
+
left: `${home.left - origin.left}px`,
|
|
286
|
+
top: `${home.top - origin.top}px`,
|
|
287
|
+
width: `${home.width}px`,
|
|
288
|
+
height: `${home.height}px`,
|
|
289
|
+
zIndex: String(zIndex),
|
|
290
|
+
pointerEvents: "none",
|
|
291
|
+
});
|
|
292
|
+
const middle = fill(document.createElement("div"));
|
|
293
|
+
middle.style.transformOrigin = "50% 50%";
|
|
294
|
+
const clipper = fill(document.createElement("div"));
|
|
295
|
+
clipper.style.overflow = "hidden";
|
|
296
|
+
const faceA = faces.from(home);
|
|
297
|
+
const faceB = faces.to(home);
|
|
298
|
+
clipper.append(faceA, faceB);
|
|
299
|
+
middle.appendChild(clipper);
|
|
300
|
+
outer.appendChild(middle);
|
|
301
|
+
(mount?.into ?? document.body).appendChild(outer);
|
|
302
|
+
|
|
303
|
+
const a = boxOf(from);
|
|
304
|
+
const b = boxOf(to);
|
|
305
|
+
const homeCx = home.left + home.width / 2;
|
|
306
|
+
const homeCy = home.top + home.height / 2;
|
|
307
|
+
const [h0, h1] = handover;
|
|
308
|
+
const [b0, b1] = blurWindow;
|
|
309
|
+
const ramp = (b1 - b0) * 0.2;
|
|
310
|
+
const samples = Array.from({ length: steps + 1 }, (_, i) => ({
|
|
311
|
+
t: i / steps,
|
|
312
|
+
p: glideAt(i / steps),
|
|
313
|
+
}));
|
|
314
|
+
|
|
315
|
+
const middleFrames: Keyframe[] = [];
|
|
316
|
+
const clipFrames: Keyframe[] = [];
|
|
317
|
+
const outerFrames: Keyframe[] = [];
|
|
318
|
+
const aFrames: Keyframe[] = [];
|
|
319
|
+
const bFrames: Keyframe[] = [];
|
|
320
|
+
for (const { t, p } of samples) {
|
|
321
|
+
const box = path ? path(t) : boxAt(a, b, p);
|
|
322
|
+
// Scale only up, when the box is bigger than home; the clip shows the box, in local pixels.
|
|
323
|
+
const k = Math.max(1, box.w / home.width, box.h / home.height);
|
|
324
|
+
const w = box.w / k;
|
|
325
|
+
const h = box.h / k;
|
|
326
|
+
middleFrames.push({
|
|
327
|
+
offset: t,
|
|
328
|
+
transform: `translate3d(${box.cx - homeCx}px, ${box.cy - homeCy}px, 0) scale(${k})`,
|
|
329
|
+
});
|
|
330
|
+
clipFrames.push({
|
|
331
|
+
offset: t,
|
|
332
|
+
clipPath: `inset(${(home.height - h) / 2}px ${(home.width - w) / 2}px round ${box.r / k}px)`,
|
|
333
|
+
});
|
|
334
|
+
// Motion blur: only while it's moving fastest, crisp at both ends.
|
|
335
|
+
const amount = ease01(t, b0, b0 + ramp) * (1 - ease01(t, b1 - ramp, b1));
|
|
336
|
+
outerFrames.push({ offset: t, filter: `blur(${(motionBlur(blur) * amount).toFixed(3)}px)` });
|
|
337
|
+
bFrames.push({ offset: t, opacity: ease01(p, h0, h1) });
|
|
338
|
+
// A fades out gradually, from halfway through B's fade-in to a little after it. Never in one
|
|
339
|
+
// step: when B is translucent (a selected answer is 90%), whatever is under it shows through, and
|
|
340
|
+
// switching A off at once changes that instantly — a mid-morph brightness jump.
|
|
341
|
+
aFrames.push({
|
|
342
|
+
offset: t,
|
|
343
|
+
opacity: 1 - ease01(p, (h0 + h1) / 2, Math.min(1, h1 + (h1 - h0) / 2)),
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
const options: KeyframeAnimationOptions = { duration, easing: "linear", fill: "both" };
|
|
348
|
+
const animations = [
|
|
349
|
+
middle.animate(middleFrames, options),
|
|
350
|
+
clipper.animate(clipFrames, options),
|
|
351
|
+
outer.animate(outerFrames, options),
|
|
352
|
+
faceA.animate(aFrames, options),
|
|
353
|
+
faceB.animate(bFrames, options),
|
|
354
|
+
];
|
|
355
|
+
return { frame: outer, animations, faces: { from: faceA, to: faceB } };
|
|
356
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Performance
|
|
2
|
+
|
|
3
|
+
"It's choppy, weird artefacts everywhere, not premium" was the first reaction
|
|
4
|
+
to a version that used View Transitions and blur everywhere. It ran at 15fps.
|
|
5
|
+
Premium motion is smooth motion first.
|
|
6
|
+
|
|
7
|
+
## What may animate
|
|
8
|
+
|
|
9
|
+
| Property | Verdict |
|
|
10
|
+
|---|---|
|
|
11
|
+
| `transform`, `opacity` | Yes. Composited; nothing re-rasterises. |
|
|
12
|
+
| `filter: blur()` | Only on one element at a time: the A → B morph frame's outer wrapper (5px peak), never on text blocks, whole pages or lists. |
|
|
13
|
+
| `backdrop-filter` | Never on something that moves. Drop frosted-glass backgrounds on answers in the animated flow (over a soft gradient the difference is barely visible). |
|
|
14
|
+
| `clip-path` | Sanctioned for one element at a time: the A → B morph frame's clipper, its only outline (reshapes it without squashing corners). Not for page-wide wipes or reveals. |
|
|
15
|
+
| `width`, `height`, `top`, `left` | No. Progress fills slide with `translateX` inside an `overflow: hidden` track. |
|
|
16
|
+
| View Transitions (`document.startViewTransition`) | No, for page hand-offs: snapshot artefacts, stretched morphs, full-page re-compositing. |
|
|
17
|
+
|
|
18
|
+
Also:
|
|
19
|
+
- Keep simultaneous animated layers modest (tens, not hundreds).
|
|
20
|
+
- Clones are cheap; blur on a big clone is not.
|
|
21
|
+
- Don't animate CSS custom properties on a parent to drive children; write the
|
|
22
|
+
transform on the element.
|
|
23
|
+
|
|
24
|
+
## Diagnosing "it's slow"
|
|
25
|
+
|
|
26
|
+
1. **Judge a production build**, not the dev server (unminified React,
|
|
27
|
+
StrictMode double effects). Serve the build on an unused port
|
|
28
|
+
(`vite preview --port <free> --strictPort --host 0.0.0.0`).
|
|
29
|
+
2. **Compare against the old motion** on the same build (`?motion=classic`).
|
|
30
|
+
If both are slow, it isn't your motion.
|
|
31
|
+
3. **Check the browser's GPU.** In Chrome/Dia/Arc, open `chrome://gpu`. If it
|
|
32
|
+
says *Compositing: Software only* or *GPU process was unable to boot: GPU
|
|
33
|
+
access is disabled due to frequent crashes*, every page is being drawn on
|
|
34
|
+
the CPU (at 5K on a 2× display that caps any animation near 20–25fps).
|
|
35
|
+
A full browser restart clears the crash block; a disabled flag such as
|
|
36
|
+
Skia Graphite may be the cause (reset it in `chrome://flags`). Recheck
|
|
37
|
+
that Compositing and Rasterization say *Hardware accelerated*.
|
|
38
|
+
4. Only then optimise the page, starting with anything on the "no" list above.
|
|
39
|
+
|
|
40
|
+
Real users (mostly phones from ads) have working GPUs; don't strip the design
|
|
41
|
+
for one broken browser, but do make it transform/opacity-only regardless.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# The web-runtime engine (not for surfaces)
|
|
2
|
+
|
|
3
|
+
`handoffs.ts` and `story-motion.css` are the hand-off engine as it first
|
|
4
|
+
shipped, in a hand-rolled web2app runtime that swaps pages itself: it clones
|
|
5
|
+
the outgoing page, pins the clone, keys entrances on its own
|
|
6
|
+
`data-motion` / `data-flow-transition` / `data-handoff` attributes, and
|
|
7
|
+
positions some copies with `position: fixed`.
|
|
8
|
+
|
|
9
|
+
On a Superwall surface none of that applies. The framework's router swaps
|
|
10
|
+
the pages, keeps the leaving one mounted and stamps `data-sw-transition` and
|
|
11
|
+
`data-sw-phase` on every layer, so the engine is `../framework/` instead:
|
|
12
|
+
no clone, exits and entrances as CSS on those attributes, flights in a
|
|
13
|
+
layout-level motion layer. Building a page swapper, a custom router or a
|
|
14
|
+
fixed copy on a surface is the wrong build, whatever this code made easy.
|
|
15
|
+
|
|
16
|
+
Read these files only when the user keeps a flow in their own web runtime
|
|
17
|
+
and has declined to move it to a surface.
|