create-disposabl-app 0.15.0 → 0.17.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 (101) hide show
  1. package/README.md +26 -9
  2. package/dist/disposabl.js +357 -50
  3. package/dist/index.js +9026 -160
  4. package/dist/templates/default/.github/scripts/mobile.sh +3 -2
  5. package/dist/templates/default/.github/scripts/release.sh +1 -0
  6. package/dist/templates/default/.github/scripts/verify-android-abis.mjs +22 -0
  7. package/dist/templates/default/apps/desktop/forge.config.mts +2 -1
  8. package/dist/templates/default/apps/docs/content/getting-started.mdx +1 -1
  9. package/dist/templates/default/apps/mobile/app.config.js +18 -9
  10. package/dist/templates/default/apps/mobile/package.json +1 -0
  11. package/dist/templates/default/apps/mobile/plugins/with-e2e-network.js +41 -0
  12. package/dist/templates/default/apps/web/eslint.config.ts +5 -1
  13. package/dist/templates/default/apps/web/public/disposabl-logo-light.svg +8 -0
  14. package/dist/templates/default/apps/web/public/landing/coast.jpg +0 -0
  15. package/dist/templates/default/apps/web/public/landing/community.jpg +0 -0
  16. package/dist/templates/default/apps/web/public/landing/stores/app-store.svg +46 -0
  17. package/dist/templates/default/apps/web/public/landing/stores/google-play.png +0 -0
  18. package/dist/templates/default/apps/web/public/landing/taste/LICENSE +21 -0
  19. package/dist/templates/default/apps/web/public/landing/taste/init.js +3 -0
  20. package/dist/templates/default/apps/web/public/landing/taste/moments/lib.js +189 -0
  21. package/dist/templates/default/apps/web/public/landing/taste/moments/moments.js +109 -0
  22. package/dist/templates/default/apps/web/public/landing/taste/moments/word-highlight/moment.css +8 -0
  23. package/dist/templates/default/apps/web/public/landing/taste/moments/word-highlight/moment.js +35 -0
  24. package/dist/templates/default/apps/web/public/landing/taste/motion/motion.css +321 -0
  25. package/dist/templates/default/apps/web/public/landing/taste/motion/motion.js +406 -0
  26. package/dist/templates/default/apps/web/routes.config.ts +14 -0
  27. package/dist/templates/default/apps/web/src/router/__root.tsx +8 -2
  28. package/dist/templates/default/apps/web/tsr.config.json +1 -1
  29. package/dist/templates/default/apps/web/vite.config.ts +10 -2
  30. package/dist/templates/default/bun.lock +6 -0
  31. package/dist/templates/default/bunfig.toml +1 -0
  32. package/dist/templates/default/disposabl.json +2 -1
  33. package/dist/templates/default/packages/backend/convex/authSetup.ts +2 -5
  34. package/dist/templates/default/packages/backend/convex/billing.ts +5 -0
  35. package/dist/templates/default/packages/backend/convex/billingHandoff.ts +6 -0
  36. package/dist/templates/default/packages/backend/convex/convex.config.ts +8 -0
  37. package/dist/templates/default/packages/backend/convex/http.ts +6 -0
  38. package/dist/templates/default/packages/backend/convex/revenuecat.ts +13 -0
  39. package/dist/templates/default/packages/backend/convex/schema.ts +44 -0
  40. package/dist/templates/default/packages/backend/convex/telemetry.ts +41 -5
  41. package/dist/templates/default/packages/backend/generate.ts +6 -0
  42. package/dist/templates/default/packages/cli/auth.ts +36 -3
  43. package/dist/templates/default/packages/cli/build.ts +6 -0
  44. package/dist/templates/default/packages/cli/client.ts +189 -19
  45. package/dist/templates/default/packages/cli/errors.ts +18 -0
  46. package/dist/templates/default/packages/cli/telemetry-build.ts +27 -0
  47. package/dist/templates/default/packages/cli/telemetry.ts +266 -0
  48. package/dist/templates/default/packages/disposabl-kit/PAYMENTS.md +23 -5
  49. package/dist/templates/default/packages/disposabl-kit/android-architectures.ts +35 -0
  50. package/dist/templates/default/packages/disposabl-kit/client/lib/telemetry.ts +24 -2
  51. package/dist/templates/default/packages/disposabl-kit/client/lib/theme.ts +1 -0
  52. package/dist/templates/default/packages/disposabl-kit/client/routes/billing-login.tsx +92 -0
  53. package/dist/templates/default/packages/disposabl-kit/client/routes/pricing.tsx +113 -43
  54. package/dist/templates/default/packages/disposabl-kit/client/routes/route.tsx +13 -5
  55. package/dist/templates/default/packages/disposabl-kit/client/vite.config.ts +3 -2
  56. package/dist/templates/default/packages/disposabl-kit/lib/telemetry.ts +148 -12
  57. package/dist/templates/default/packages/disposabl-kit/mobile/billing/account-billing.tsx +143 -40
  58. package/dist/templates/default/packages/disposabl-kit/mobile/billing/paywall.ts +83 -0
  59. package/dist/templates/default/packages/disposabl-kit/mobile/billing/policy.ts +125 -0
  60. package/dist/templates/default/packages/disposabl-kit/mobile/billing/session.ts +31 -3
  61. package/dist/templates/default/packages/disposabl-kit/mobile/billing/topup.ts +99 -0
  62. package/dist/templates/default/packages/disposabl-kit/mobile/billing/use-topup.ts +116 -0
  63. package/dist/templates/default/packages/disposabl-kit/mobile/billing/web-checkout.ts +190 -0
  64. package/dist/templates/default/packages/disposabl-kit/mobile/expo-plugin.cjs +23 -1
  65. package/dist/templates/default/packages/disposabl-kit/mobile/layout.tsx +9 -2
  66. package/dist/templates/default/packages/disposabl-kit/package.json +10 -1
  67. package/dist/templates/default/packages/disposabl-kit/payments/checkout-attempt.ts +64 -0
  68. package/dist/templates/default/packages/disposabl-kit/payments/config.ts +16 -3
  69. package/dist/templates/default/packages/disposabl-kit/server/billing-functions.ts +218 -9
  70. package/dist/templates/default/packages/disposabl-kit/server/billing-handoff.ts +126 -0
  71. package/dist/templates/default/packages/disposabl-kit/server/billing-native-capability.ts +12 -0
  72. package/dist/templates/default/packages/disposabl-kit/server/billing-setup.ts +2 -0
  73. package/dist/templates/default/packages/disposabl-kit/server/billing.ts +31 -0
  74. package/dist/templates/default/packages/disposabl-kit/server/browser-session.ts +27 -0
  75. package/dist/templates/default/packages/disposabl-kit/server/lib/telemetry.ts +173 -59
  76. package/dist/templates/default/packages/disposabl-kit/server/revenuecat-contract.ts +233 -0
  77. package/dist/templates/default/packages/disposabl-kit/server/revenuecat-functions.ts +554 -0
  78. package/dist/templates/default/packages/disposabl-kit/server/revenuecat-validator.ts +76 -0
  79. package/dist/templates/default/packages/reconfigure-skill/SKILL.md +38 -0
  80. package/dist/templates/default/packages/sdk/README.md +21 -0
  81. package/dist/templates/default/packages/sdk/src/analytics.ts +102 -0
  82. package/dist/templates/default/packages/sdk/src/index.ts +2 -0
  83. package/dist/templates/default/packages/skill/SKILL.md +2 -0
  84. package/dist/templates/default/packages/skill/references/agent.md +2 -0
  85. package/dist/templates/default/packages/tests/android-architectures.test.ts +43 -0
  86. package/dist/templates/default/packages/tests/android-ota-artifacts.test.ts +5 -1
  87. package/dist/templates/default/packages/tests/android-ota-selection.test.ts +7 -2
  88. package/dist/templates/default/packages/tests/billing-attempts.test.ts +156 -0
  89. package/dist/templates/default/packages/tests/billing-handoff.test.ts +116 -0
  90. package/dist/templates/default/packages/tests/billing-setup.test.ts +4 -3
  91. package/dist/templates/default/packages/tests/billing.test.ts +48 -4
  92. package/dist/templates/default/packages/tests/desktop-packaging.test.ts +12 -0
  93. package/dist/templates/default/packages/tests/flows/seo.e2e.ts +3 -1
  94. package/dist/templates/default/packages/tests/mobile-android-e2e-network.test.ts +112 -0
  95. package/dist/templates/default/packages/tests/native-billing.test.ts +417 -0
  96. package/dist/templates/default/packages/tests/page-telemetry.test.ts +218 -0
  97. package/dist/templates/default/packages/tests/revenuecat-inbox.test.ts +476 -0
  98. package/dist/templates/default/packages/tests/sdk-analytics.test.ts +158 -0
  99. package/dist/templates/default/packages/tests/telemetry.test.ts +272 -55
  100. package/package.json +1 -1
  101. package/dist/templates/default/apps/web/src/routeTree.gen.ts +0 -578
@@ -3,7 +3,7 @@ set -euo pipefail
3
3
  manifest() {
4
4
  bun x --no-install expo config --json | jq -ce --arg channel "${CHANNEL:-}" --arg runtime "${RUNTIME:-}" '
5
5
  def required($name): if type == "string" and (test("[^[:space:]]")) then . else error("Missing or invalid " + $name) end;
6
- {channel: ($channel | required("channel")), projectId: (.extra.eas.projectId | required("projectId")), applicationId: (.android.package | required("applicationId")), runtimeVersion: ($runtime | required("runtimeVersion") | if test("^[a-f0-9]{40,64}$") then . else error("Invalid runtimeVersion") end)}
6
+ {channel: ($channel | required("channel")), projectId: (.extra.eas.projectId | required("projectId")), applicationId: (.android.package | required("applicationId")), runtimeVersion: ($runtime | required("runtimeVersion") | if test("^[a-f0-9]{40,64}$") then . else error("Invalid runtimeVersion") end), androidArchitectures: (.extra.disposablAndroidArchitectures | if type == "array" and length > 0 then . else error("Missing Android architectures") end)}
7
7
  '
8
8
  }
9
9
  case "${1:?operation required}" in
@@ -78,7 +78,7 @@ bun -e '
78
78
  const wanted = JSON.parse(process.env.MANIFEST);
79
79
  const release = await Bun.file(`${process.env.RUNNER_TEMP}/release.json`).json();
80
80
  const prior = JSON.parse(/<!-- android (\{[^\n]+\}) -->/.exec(release.body || "")?.[1] || "null");
81
- const reusable = prior && Object.keys(wanted).every(k => prior[k] === wanted[k]) && /^[a-f0-9]{64}$/.test(prior.sha256 || "") && release.assets.some(a => a.name === process.env.artifact && a.state === "uploaded" && a.size > 0 && a.digest === `sha256:${prior.sha256}`);
81
+ const reusable = prior && Object.keys(wanted).every(k => JSON.stringify(prior[k]) === JSON.stringify(wanted[k])) && /^[a-f0-9]{64}$/.test(prior.sha256 || "") && release.assets.some(a => a.name === process.env.artifact && a.state === "uploaded" && a.size > 0 && a.digest === `sha256:${prior.sha256}`);
82
82
  const blocked = !reusable && process.env.CHANNEL === "production" && process.env.ANDROID_SIGNING_READY !== "true";
83
83
  if (blocked) {
84
84
  const reason = "Configure Android production signing credentials before building a production APK.";
@@ -131,6 +131,7 @@ binary=android/app/build/outputs/apk/release/app-release.apk
131
131
  fingerprint=assets/fingerprint
132
132
 
133
133
  (cd android && bash ../../../.github/scripts/android-runner.sh build)
134
+ node ../../.github/scripts/verify-android-abis.mjs "$binary" "$MANIFEST"
134
135
  test "$(unzip -p "$binary" "$fingerprint")" = "$RUNTIME"
135
136
  test "$(bun x --no-install expo-updates runtimeversion:resolve --platform android --workflow managed | jq -er .runtimeVersion)" = "$RUNTIME"
136
137
  mkdir -p ../../dist/release
@@ -68,6 +68,7 @@ for platform in android linux windows macos; do
68
68
  if (release.draft !== false || !prior || wanted.channel !== process.env.CHANNEL
69
69
  || !/^[a-f0-9]{40,64}$/.test(wanted.runtimeVersion || "") || !/^[a-f0-9]{64}$/.test(wanted.sha256 || "")
70
70
  || !fields.every(k => typeof wanted[k] === "string" && wanted[k].trim() && prior[k] === wanted[k])
71
+ || !Array.isArray(wanted.androidArchitectures) || !wanted.androidArchitectures.length || JSON.stringify(prior.androidArchitectures) !== JSON.stringify(wanted.androidArchitectures)
71
72
  || !release.assets?.some(a => a.name === "android.apk" && a.state === "uploaded" && a.size > 0 && a.digest === `sha256:${wanted.sha256}`)) {
72
73
  throw new Error("Android source release does not match the OTA manifest.");
73
74
  }
@@ -0,0 +1,22 @@
1
+ import { execFileSync } from "node:child_process";
2
+
3
+ const [apk, manifest] = process.argv.slice(2);
4
+ const expected = JSON.parse(manifest).androidArchitectures;
5
+ const entries = execFileSync("unzip", ["-Z1", apk], { encoding: "utf8" }).split(
6
+ "\n",
7
+ );
8
+ const actual = [
9
+ ...new Set(
10
+ entries
11
+ .map((path) => /^lib\/([^/]+)\/.+\.so$/.exec(path)?.[1])
12
+ .filter(Boolean),
13
+ ),
14
+ ].sort();
15
+ if (
16
+ !Array.isArray(expected) ||
17
+ !expected.length ||
18
+ JSON.stringify(actual) !== JSON.stringify([...expected].sort())
19
+ )
20
+ throw new Error(
21
+ `APK architectures mismatch: expected ${expected?.join(",")}; found ${actual.join(",")}`,
22
+ );
@@ -97,7 +97,8 @@ const config: ForgeConfig = {
97
97
  makers: [
98
98
  new MakerSquirrel({ setupIcon: 'src/assets/icon.ico' }),
99
99
  new MakerZIP({}, ['darwin']),
100
- new MakerDMG({ format: 'ULFO' }),
100
+ // The HFS+ volume title is limited; keep app and artifact names unchanged.
101
+ new MakerDMG({ format: 'ULFO', title: 'Install' }),
101
102
  new MakerRpm({ options: rpmOptions }),
102
103
  new MakerDeb({
103
104
  options: { name: executableName, bin: executableName, mimeType },
@@ -23,4 +23,4 @@ Authentication, analytics, payments, and documentation are optional. Use the gen
23
23
 
24
24
  Run `bun run test` for your selected platforms. Native tests require a locally installed build and an available simulator or emulator. Check the visible login, empty state, and first useful action on each target.
25
25
 
26
- If you selected payments, the starter includes editable examples: a $5 monthly plan with 500 credits and a $5 top-up with 500 non-expiring credits. Configure the provider and verify sandbox purchases before enabling live payments. See `packages/disposabl-kit/PAYMENTS.md`.
26
+ If you selected payments, the starter includes editable examples: a $5 monthly plan with 750 credits that expire each cycle and a $5 top-up with 500 non-expiring credits. Configure the provider and verify sandbox purchases before enabling live payments. See `packages/disposabl-kit/PAYMENTS.md`.
@@ -42,12 +42,15 @@ module.exports = ({ config }) => {
42
42
  }
43
43
  return {
44
44
  ...config,
45
- scheme: [
46
- ...new Set([
47
- ...[config.scheme || []].flat(),
48
- `disposabl-${project.name.replace(/[^a-z0-9.-]/g, "-")}`,
49
- ]),
50
- ],
45
+ scheme:
46
+ process.env.EXPO_PUBLIC_E2E === "true" && process.env.E2E_ANDROID_SCHEME
47
+ ? [process.env.E2E_ANDROID_SCHEME]
48
+ : [
49
+ ...new Set([
50
+ ...[config.scheme || []].flat(),
51
+ `disposabl-${project.name.replace(/[^a-z0-9.-]/g, "-")}`,
52
+ ]),
53
+ ],
51
54
  owner: process.env.EXPO_OWNER || config.owner,
52
55
  slug: process.env.EXPO_SLUG || config.slug,
53
56
  ios: {
@@ -63,9 +66,11 @@ module.exports = ({ config }) => {
63
66
  ...config.android,
64
67
  ...(projectId ? { runtimeVersion: { policy: "fingerprint" } } : {}),
65
68
  package:
66
- channel === "production"
67
- ? basePackage
68
- : `${basePackage}.${channel.replaceAll("-", "")}`,
69
+ process.env.EXPO_PUBLIC_E2E === "true" && process.env.E2E_ANDROID_APP_ID
70
+ ? process.env.E2E_ANDROID_APP_ID
71
+ : channel === "production"
72
+ ? basePackage
73
+ : `${basePackage}.${channel.replaceAll("-", "")}`,
69
74
  versionCode,
70
75
  },
71
76
  plugins: [
@@ -73,9 +78,13 @@ module.exports = ({ config }) => {
73
78
  "./plugins/with-android-signing.js",
74
79
  ...(process.env.EXPO_PUBLIC_E2E === "true"
75
80
  ? [
81
+ ...(process.env.E2E_ANDROID_LOOPBACK === "true"
82
+ ? ["./plugins/with-e2e-network.js"]
83
+ : []),
76
84
  [
77
85
  "expo-dev-client",
78
86
  {
87
+ addGeneratedScheme: false,
79
88
  toolsButton: false,
80
89
  skipOnboarding: true,
81
90
  showMenuAtLaunch: false,
@@ -33,6 +33,7 @@
33
33
  "react-native-css": "3.1.0-rc.1",
34
34
  "react-native-gesture-handler": "~3.3.0",
35
35
  "react-native-purchases": "10.16.0",
36
+ "react-native-purchases-ui": "10.16.0",
36
37
  "react-native-reanimated": "4.7.1",
37
38
  "react-native-safe-area-context": "~5.11.1",
38
39
  "react-native-screens": "~4.30.1",
@@ -0,0 +1,41 @@
1
+ const {
2
+ withAndroidManifest,
3
+ withDangerousMod,
4
+ } = require("@expo/config-plugins");
5
+ const fs = require("node:fs");
6
+ const path = require("node:path");
7
+
8
+ module.exports = function withE2ENetwork(config) {
9
+ const backend = new URL(process.env.EXPO_PUBLIC_CONVEX_URL || "");
10
+ if (
11
+ process.env.EXPO_PUBLIC_E2E !== "true" ||
12
+ process.env.E2E_ANDROID_LOOPBACK !== "true" ||
13
+ backend.protocol !== "http:" ||
14
+ backend.hostname !== "10.0.2.2"
15
+ ) {
16
+ throw new Error(
17
+ "E2E network configuration requires the Android emulator loopback backend",
18
+ );
19
+ }
20
+ config = withAndroidManifest(config, (result) => {
21
+ result.modResults.manifest.application[0].$[
22
+ "android:networkSecurityConfig"
23
+ ] = "@xml/e2e_network_security_config";
24
+ return result;
25
+ });
26
+ return withDangerousMod(config, [
27
+ "android",
28
+ async (result) => {
29
+ const dir = path.join(
30
+ result.modRequest.platformProjectRoot,
31
+ "app/src/main/res/xml",
32
+ );
33
+ fs.mkdirSync(dir, { recursive: true });
34
+ fs.writeFileSync(
35
+ path.join(dir, "e2e_network_security_config.xml"),
36
+ '<?xml version="1.0" encoding="utf-8"?>\n<network-security-config><domain-config cleartextTrafficPermitted="true"><domain includeSubdomains="false">10.0.2.2</domain></domain-config></network-security-config>\n',
37
+ );
38
+ return result;
39
+ },
40
+ ]);
41
+ };
@@ -16,6 +16,10 @@ export default [
16
16
  },
17
17
  },
18
18
  {
19
- ignores: ["eslint.config.js", ".prettierrc"],
19
+ ignores: [
20
+ "eslint.config.js",
21
+ ".prettierrc",
22
+ "public/landing/taste/**/*.js",
23
+ ],
20
24
  },
21
25
  ];
@@ -0,0 +1,8 @@
1
+ <svg width="1024" height="1024" viewBox="0 0 1024 1024" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill="#F8F5EF" d="M616 142h166v740H616v-76c-52 53-119 80-201 80-151 0-274-123-274-274s123-274 274-274c74 0 141 28 201 80V142Zm-183 362c-61 0-110 49-110 109s49 109 110 109 110-49 110-109-49-109-110-109Z"/>
3
+ <rect x="285" y="413" width="331" height="315" rx="36" fill="#101A32"/>
4
+ <path d="M285 489h331" stroke="#F8F5EF" stroke-width="24"/>
5
+ <circle cx="336" cy="451" r="12" fill="#F8F5EF"/>
6
+ <circle cx="375" cy="451" r="12" fill="#F8F5EF" opacity=".42"/>
7
+ <path d="m378 574 154-64v205l-154-75V574Z" fill="#FF6B57"/>
8
+ </svg>
@@ -0,0 +1,46 @@
1
+ <svg id="livetype" xmlns="http://www.w3.org/2000/svg" width="119.66407" height="40" viewBox="0 0 119.66407 40">
2
+ <title>Download_on_the_App_Store_Badge_US-UK_RGB_blk_4SVG_092917</title>
3
+ <g>
4
+ <g>
5
+ <g>
6
+ <path d="M110.13477,0H9.53468c-.3667,0-.729,0-1.09473.002-.30615.002-.60986.00781-.91895.0127A13.21476,13.21476,0,0,0,5.5171.19141a6.66509,6.66509,0,0,0-1.90088.627A6.43779,6.43779,0,0,0,1.99757,1.99707,6.25844,6.25844,0,0,0,.81935,3.61816a6.60119,6.60119,0,0,0-.625,1.90332,12.993,12.993,0,0,0-.1792,2.002C.00587,7.83008.00489,8.1377,0,8.44434V31.5586c.00489.3105.00587.6113.01515.9219a12.99232,12.99232,0,0,0,.1792,2.0019,6.58756,6.58756,0,0,0,.625,1.9043A6.20778,6.20778,0,0,0,1.99757,38.001a6.27445,6.27445,0,0,0,1.61865,1.1787,6.70082,6.70082,0,0,0,1.90088.6308,13.45514,13.45514,0,0,0,2.0039.1768c.30909.0068.6128.0107.91895.0107C8.80567,40,9.168,40,9.53468,40H110.13477c.3594,0,.7246,0,1.084-.002.3047,0,.6172-.0039.9219-.0107a13.279,13.279,0,0,0,2-.1768,6.80432,6.80432,0,0,0,1.9082-.6308,6.27742,6.27742,0,0,0,1.6172-1.1787,6.39482,6.39482,0,0,0,1.1816-1.6143,6.60413,6.60413,0,0,0,.6191-1.9043,13.50643,13.50643,0,0,0,.1856-2.0019c.0039-.3106.0039-.6114.0039-.9219.0078-.3633.0078-.7246.0078-1.0938V9.53613c0-.36621,0-.72949-.0078-1.09179,0-.30664,0-.61426-.0039-.9209a13.5071,13.5071,0,0,0-.1856-2.002,6.6177,6.6177,0,0,0-.6191-1.90332,6.46619,6.46619,0,0,0-2.7988-2.7998,6.76754,6.76754,0,0,0-1.9082-.627,13.04394,13.04394,0,0,0-2-.17676c-.3047-.00488-.6172-.01074-.9219-.01269-.3594-.002-.7246-.002-1.084-.002Z" style="fill: #a6a6a6"/>
7
+ <path d="M8.44483,39.125c-.30468,0-.602-.0039-.90429-.0107a12.68714,12.68714,0,0,1-1.86914-.1631,5.88381,5.88381,0,0,1-1.65674-.5479,5.40573,5.40573,0,0,1-1.397-1.0166,5.32082,5.32082,0,0,1-1.02051-1.3965,5.72186,5.72186,0,0,1-.543-1.6572,12.41351,12.41351,0,0,1-.1665-1.875c-.00634-.2109-.01464-.9131-.01464-.9131V8.44434S.88185,7.75293.8877,7.5498a12.37039,12.37039,0,0,1,.16553-1.87207,5.7555,5.7555,0,0,1,.54346-1.6621A5.37349,5.37349,0,0,1,2.61183,2.61768,5.56543,5.56543,0,0,1,4.01417,1.59521a5.82309,5.82309,0,0,1,1.65332-.54394A12.58589,12.58589,0,0,1,7.543.88721L8.44532.875H111.21387l.9131.0127a12.38493,12.38493,0,0,1,1.8584.16259,5.93833,5.93833,0,0,1,1.6709.54785,5.59374,5.59374,0,0,1,2.415,2.41993,5.76267,5.76267,0,0,1,.5352,1.64892,12.995,12.995,0,0,1,.1738,1.88721c.0029.2832.0029.5874.0029.89014.0079.375.0079.73193.0079,1.09179V30.4648c0,.3633,0,.7178-.0079,1.0752,0,.3252,0,.6231-.0039.9297a12.73126,12.73126,0,0,1-.1709,1.8535,5.739,5.739,0,0,1-.54,1.67,5.48029,5.48029,0,0,1-1.0156,1.3857,5.4129,5.4129,0,0,1-1.3994,1.0225,5.86168,5.86168,0,0,1-1.668.5498,12.54218,12.54218,0,0,1-1.8692.1631c-.2929.0068-.5996.0107-.8974.0107l-1.084.002Z"/>
8
+ </g>
9
+ <g id="_Group_" data-name="&lt;Group&gt;">
10
+ <g id="_Group_2" data-name="&lt;Group&gt;">
11
+ <g id="_Group_3" data-name="&lt;Group&gt;">
12
+ <path id="_Path_" data-name="&lt;Path&gt;" d="M24.76888,20.30068a4.94881,4.94881,0,0,1,2.35656-4.15206,5.06566,5.06566,0,0,0-3.99116-2.15768c-1.67924-.17626-3.30719,1.00483-4.1629,1.00483-.87227,0-2.18977-.98733-3.6085-.95814a5.31529,5.31529,0,0,0-4.47292,2.72787c-1.934,3.34842-.49141,8.26947,1.3612,10.97608.9269,1.32535,2.01018,2.8058,3.42763,2.7533,1.38706-.05753,1.9051-.88448,3.5794-.88448,1.65876,0,2.14479.88448,3.591.8511,1.48838-.02416,2.42613-1.33124,3.32051-2.66914a10.962,10.962,0,0,0,1.51842-3.09251A4.78205,4.78205,0,0,1,24.76888,20.30068Z" style="fill: #fff"/>
13
+ <path id="_Path_2" data-name="&lt;Path&gt;" d="M22.03725,12.21089a4.87248,4.87248,0,0,0,1.11452-3.49062,4.95746,4.95746,0,0,0-3.20758,1.65961,4.63634,4.63634,0,0,0-1.14371,3.36139A4.09905,4.09905,0,0,0,22.03725,12.21089Z" style="fill: #fff"/>
14
+ </g>
15
+ </g>
16
+ <g>
17
+ <path d="M42.30227,27.13965h-4.7334l-1.13672,3.35645H34.42727l4.4834-12.418h2.083l4.4834,12.418H43.438ZM38.0591,25.59082h3.752l-1.84961-5.44727h-.05176Z" style="fill: #fff"/>
18
+ <path d="M55.15969,25.96973c0,2.81348-1.50586,4.62109-3.77832,4.62109a3.0693,3.0693,0,0,1-2.84863-1.584h-.043v4.48438h-1.8584V21.44238H48.4302v1.50586h.03418a3.21162,3.21162,0,0,1,2.88281-1.60059C53.645,21.34766,55.15969,23.16406,55.15969,25.96973Zm-1.91016,0c0-1.833-.94727-3.03809-2.39258-3.03809-1.41992,0-2.375,1.23047-2.375,3.03809,0,1.82422.95508,3.0459,2.375,3.0459C52.30227,29.01563,53.24953,27.81934,53.24953,25.96973Z" style="fill: #fff"/>
19
+ <path d="M65.12453,25.96973c0,2.81348-1.50586,4.62109-3.77832,4.62109a3.0693,3.0693,0,0,1-2.84863-1.584h-.043v4.48438h-1.8584V21.44238H58.395v1.50586h.03418A3.21162,3.21162,0,0,1,61.312,21.34766C63.60988,21.34766,65.12453,23.16406,65.12453,25.96973Zm-1.91016,0c0-1.833-.94727-3.03809-2.39258-3.03809-1.41992,0-2.375,1.23047-2.375,3.03809,0,1.82422.95508,3.0459,2.375,3.0459C62.26711,29.01563,63.21438,27.81934,63.21438,25.96973Z" style="fill: #fff"/>
20
+ <path d="M71.71047,27.03613c.1377,1.23145,1.334,2.04,2.96875,2.04,1.56641,0,2.69336-.80859,2.69336-1.91895,0-.96387-.67969-1.541-2.28906-1.93652l-1.60937-.3877c-2.28027-.55078-3.33887-1.61719-3.33887-3.34766,0-2.14258,1.86719-3.61426,4.51855-3.61426,2.624,0,4.42285,1.47168,4.4834,3.61426h-1.876c-.1123-1.23926-1.13672-1.9873-2.63379-1.9873s-2.52148.75684-2.52148,1.8584c0,.87793.6543,1.39453,2.25488,1.79l1.36816.33594c2.54785.60254,3.60645,1.626,3.60645,3.44238,0,2.32324-1.85059,3.77832-4.79395,3.77832-2.75391,0-4.61328-1.4209-4.7334-3.667Z" style="fill: #fff"/>
21
+ <path d="M83.34621,19.2998v2.14258h1.72168v1.47168H83.34621v4.99121c0,.77539.34473,1.13672,1.10156,1.13672a5.80752,5.80752,0,0,0,.61133-.043v1.46289a5.10351,5.10351,0,0,1-1.03223.08594c-1.833,0-2.54785-.68848-2.54785-2.44434V22.91406H80.16262V21.44238H81.479V19.2998Z" style="fill: #fff"/>
22
+ <path d="M86.065,25.96973c0-2.84863,1.67773-4.63867,4.29395-4.63867,2.625,0,4.29492,1.79,4.29492,4.63867,0,2.85645-1.66113,4.63867-4.29492,4.63867C87.72609,30.6084,86.065,28.82617,86.065,25.96973Zm6.69531,0c0-1.9541-.89551-3.10742-2.40137-3.10742s-2.40039,1.16211-2.40039,3.10742c0,1.96191.89453,3.10645,2.40039,3.10645S92.76027,27.93164,92.76027,25.96973Z" style="fill: #fff"/>
23
+ <path d="M96.18606,21.44238h1.77246v1.541h.043a2.1594,2.1594,0,0,1,2.17773-1.63574,2.86616,2.86616,0,0,1,.63672.06934v1.73828a2.59794,2.59794,0,0,0-.835-.1123,1.87264,1.87264,0,0,0-1.93652,2.083v5.37012h-1.8584Z" style="fill: #fff"/>
24
+ <path d="M109.3843,27.83691c-.25,1.64355-1.85059,2.77148-3.89844,2.77148-2.63379,0-4.26855-1.76465-4.26855-4.5957,0-2.83984,1.64355-4.68164,4.19043-4.68164,2.50488,0,4.08008,1.7207,4.08008,4.46582v.63672h-6.39453v.1123a2.358,2.358,0,0,0,2.43555,2.56445,2.04834,2.04834,0,0,0,2.09082-1.27344Zm-6.28223-2.70215h4.52637a2.1773,2.1773,0,0,0-2.2207-2.29785A2.292,2.292,0,0,0,103.10207,25.13477Z" style="fill: #fff"/>
25
+ </g>
26
+ </g>
27
+ </g>
28
+ <g id="_Group_4" data-name="&lt;Group&gt;">
29
+ <g>
30
+ <path d="M37.82619,8.731a2.63964,2.63964,0,0,1,2.80762,2.96484c0,1.90625-1.03027,3.002-2.80762,3.002H35.67092V8.731Zm-1.22852,5.123h1.125a1.87588,1.87588,0,0,0,1.96777-2.146,1.881,1.881,0,0,0-1.96777-2.13379h-1.125Z" style="fill: #fff"/>
31
+ <path d="M41.68068,12.44434a2.13323,2.13323,0,1,1,4.24707,0,2.13358,2.13358,0,1,1-4.24707,0Zm3.333,0c0-.97607-.43848-1.54687-1.208-1.54687-.77246,0-1.207.5708-1.207,1.54688,0,.98389.43457,1.55029,1.207,1.55029C44.57522,13.99463,45.01369,13.42432,45.01369,12.44434Z" style="fill: #fff"/>
32
+ <path d="M51.57326,14.69775h-.92187l-.93066-3.31641h-.07031l-.92676,3.31641h-.91309l-1.24121-4.50293h.90137l.80664,3.436h.06641l.92578-3.436h.85254l.92578,3.436h.07031l.80273-3.436h.88867Z" style="fill: #fff"/>
33
+ <path d="M53.85354,10.19482H54.709v.71533h.06641a1.348,1.348,0,0,1,1.34375-.80225,1.46456,1.46456,0,0,1,1.55859,1.6748v2.915h-.88867V12.00586c0-.72363-.31445-1.0835-.97168-1.0835a1.03294,1.03294,0,0,0-1.0752,1.14111v2.63428h-.88867Z" style="fill: #fff"/>
34
+ <path d="M59.09377,8.437h.88867v6.26074h-.88867Z" style="fill: #fff"/>
35
+ <path d="M61.21779,12.44434a2.13346,2.13346,0,1,1,4.24756,0,2.1338,2.1338,0,1,1-4.24756,0Zm3.333,0c0-.97607-.43848-1.54687-1.208-1.54687-.77246,0-1.207.5708-1.207,1.54688,0,.98389.43457,1.55029,1.207,1.55029C64.11232,13.99463,64.5508,13.42432,64.5508,12.44434Z" style="fill: #fff"/>
36
+ <path d="M66.4009,13.42432c0-.81055.60352-1.27783,1.6748-1.34424l1.21973-.07031v-.38867c0-.47559-.31445-.74414-.92187-.74414-.49609,0-.83984.18213-.93848.50049h-.86035c.09082-.77344.81836-1.26953,1.83984-1.26953,1.12891,0,1.76563.562,1.76563,1.51318v3.07666h-.85547v-.63281h-.07031a1.515,1.515,0,0,1-1.35254.707A1.36026,1.36026,0,0,1,66.4009,13.42432Zm2.89453-.38477v-.37646l-1.09961.07031c-.62012.0415-.90137.25244-.90137.64941,0,.40527.35156.64111.835.64111A1.0615,1.0615,0,0,0,69.29543,13.03955Z" style="fill: #fff"/>
37
+ <path d="M71.34816,12.44434c0-1.42285.73145-2.32422,1.86914-2.32422a1.484,1.484,0,0,1,1.38086.79h.06641V8.437h.88867v6.26074h-.85156v-.71143h-.07031a1.56284,1.56284,0,0,1-1.41406.78564C72.0718,14.772,71.34816,13.87061,71.34816,12.44434Zm.918,0c0,.95508.4502,1.52979,1.20313,1.52979.749,0,1.21191-.583,1.21191-1.52588,0-.93848-.46777-1.52979-1.21191-1.52979C72.72121,10.91846,72.26613,11.49707,72.26613,12.44434Z" style="fill: #fff"/>
38
+ <path d="M79.23,12.44434a2.13323,2.13323,0,1,1,4.24707,0,2.13358,2.13358,0,1,1-4.24707,0Zm3.333,0c0-.97607-.43848-1.54687-1.208-1.54687-.77246,0-1.207.5708-1.207,1.54688,0,.98389.43457,1.55029,1.207,1.55029C82.12453,13.99463,82.563,13.42432,82.563,12.44434Z" style="fill: #fff"/>
39
+ <path d="M84.66945,10.19482h.85547v.71533h.06641a1.348,1.348,0,0,1,1.34375-.80225,1.46456,1.46456,0,0,1,1.55859,1.6748v2.915H87.605V12.00586c0-.72363-.31445-1.0835-.97168-1.0835a1.03294,1.03294,0,0,0-1.0752,1.14111v2.63428h-.88867Z" style="fill: #fff"/>
40
+ <path d="M93.51516,9.07373v1.1416h.97559v.74854h-.97559V13.2793c0,.47168.19434.67822.63672.67822a2.96657,2.96657,0,0,0,.33887-.02051v.74023a2.9155,2.9155,0,0,1-.4834.04541c-.98828,0-1.38184-.34766-1.38184-1.21582v-2.543h-.71484v-.74854h.71484V9.07373Z" style="fill: #fff"/>
41
+ <path d="M95.70461,8.437h.88086v2.48145h.07031a1.3856,1.3856,0,0,1,1.373-.80664,1.48339,1.48339,0,0,1,1.55078,1.67871v2.90723H98.69v-2.688c0-.71924-.335-1.0835-.96289-1.0835a1.05194,1.05194,0,0,0-1.13379,1.1416v2.62988h-.88867Z" style="fill: #fff"/>
42
+ <path d="M104.76125,13.48193a1.828,1.828,0,0,1-1.95117,1.30273A2.04531,2.04531,0,0,1,100.73,12.46045a2.07685,2.07685,0,0,1,2.07617-2.35254c1.25293,0,2.00879.856,2.00879,2.27V12.688h-3.17969v.0498a1.1902,1.1902,0,0,0,1.19922,1.29,1.07934,1.07934,0,0,0,1.07129-.5459Zm-3.126-1.45117h2.27441a1.08647,1.08647,0,0,0-1.1084-1.1665A1.15162,1.15162,0,0,0,101.63527,12.03076Z" style="fill: #fff"/>
43
+ </g>
44
+ </g>
45
+ </g>
46
+ </svg>
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Leonxlnx
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,3 @@
1
+ import { refresh } from './motion/motion.js';
2
+ import { mountAll, unmountAll } from './moments/moments.js';
3
+ window.disposablLandingMotion = { refresh, mountAll, unmountAll };
@@ -0,0 +1,189 @@
1
+ /*
2
+ moments/lib.js - the few helpers every moment shares (taste-skill). One ES module, no dependencies.
3
+
4
+ reduced() true under prefers-reduced-motion: a moment then shows its finished state only
5
+ phone() true on a phone: under 640px wide, or a touch screen in landscape under 500px tall
6
+ (a phone turned sideways). A moment shows its finished state there too, unless
7
+ its module says `export const phone = true` (word-highlight, picture-develops,
8
+ photo-chapters: light enough to run there).
9
+ still() reduced() || phone(): the one question every moment asks. The loader (moments.js)
10
+ hands each moment a lib whose reduced() answers still() (only reduced() for a
11
+ moment that runs on a phone), so a moment written against reduced() is static
12
+ where it must be, and sets data-moment-still on its host ("reduced" or "phone").
13
+ The answer is taken once, when the page loads.
14
+ coarse() true on a touch screen (no hover moments there)
15
+ inCard(el) true when el is, or sits in, a card, a plan, a result or a bento cell: nothing
16
+ on a card ever moves on scroll, so the loader leaves such a moment still
17
+ scrub(el, fn, opts) calls fn(progress, rect) from a requestAnimationFrame while el is near the
18
+ screen. mode 'hold' (default): 0 when el's top reaches the viewport top, 1 when
19
+ its bottom reaches the viewport bottom (a pinned stage's run). mode 'view': 0 when
20
+ el's top enters at the bottom edge, 1 when its bottom leaves at the top.
21
+ Returns { destroy, update }. Nothing is captured: the page scrolls natively.
22
+ once(el, fn, opts) fn once: when `threshold` of el is on screen, or el covers that share of the screen (a
23
+ target taller than the screen can never show it), or part of it has stayed on screen
24
+ for opts.rescue ms (3000), or the observer has not reported at all after 1.5 s of a
25
+ visible page. Nothing waits for ever. Returns { destroy }.
26
+ split(el, unit) wraps the words ('words') or letters ('chars') of el in spans
27
+ (.mo-w, .mo-c, each with an inner .mo-i that moves) and keeps the text readable:
28
+ the host gets aria-label, the spans aria-hidden. Returns the inner spans.
29
+ lines(words) groups word spans into lines by their offsetTop; returns an array of arrays.
30
+ fontsReady(ms) resolves when the fonts are loaded, or after ms.
31
+ clamp, lerp, ease the maths.
32
+ */
33
+ const rq = typeof matchMedia === 'function' ? matchMedia('(prefers-reduced-motion: reduce)') : null;
34
+ export const reduced = () => !!(rq && rq.matches);
35
+ const pq = typeof matchMedia === 'function' ? [matchMedia('(max-width: 639px)'), matchMedia('(pointer: coarse) and (max-height: 499px) and (max-width: 959px)')] : [];
36
+ export const phone = () => pq.some(q => q.matches);
37
+ export const still = () => reduced() || phone();
38
+ export const stillWhy = () => (reduced() ? 'reduced' : phone() ? 'phone' : '');
39
+ export const inCard = el => !!(el && el.closest && el.closest('.card, .plan, .result, .knock, [data-card], .bento > *'));
40
+ export const coarse = () => typeof matchMedia === 'function' && matchMedia('(pointer: coarse)').matches;
41
+ export const clamp = (v, a = 0, b = 1) => Math.min(b, Math.max(a, v));
42
+ export const lerp = (a, b, t) => a + (b - a) * t;
43
+ export const ease = {
44
+ out: t => 1 - Math.pow(1 - t, 3),
45
+ quint: t => 1 - Math.pow(1 - t, 5),
46
+ expo: t => (t >= 1 ? 1 : 1 - Math.pow(2, -10 * t)),
47
+ inOut: t => (t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2),
48
+ smooth: (a, b, x) => { const t = clamp((x - a) / (b - a)); return t * t * (3 - 2 * t); },
49
+ };
50
+
51
+ export function scrub(el, fn, { mode = 'hold', margin = '25% 0px' } = {}) {
52
+ // on from the start, with the scroll listener: an observer that never reports (a dead stub, a page it cannot reach) leaves the
53
+ // moment following the scroll instead of frozen at its first state; the observer turns it off when the target is far away
54
+ let on = true, raf = 0, last = -1;
55
+ const tick = () => {
56
+ raf = 0;
57
+ if (!on) return;
58
+ const r = el.getBoundingClientRect(), vh = innerHeight;
59
+ let p = mode === 'view' ? (vh - r.top) / (vh + r.height) : -r.top / Math.max(1, r.height - vh);
60
+ p = clamp(p);
61
+ if (p !== last) { last = p; fn(p, r); }
62
+ };
63
+ const req = () => { if (!raf) raf = requestAnimationFrame(tick); };
64
+ const io = new IntersectionObserver(es => {
65
+ on = es[es.length - 1].isIntersecting;
66
+ removeEventListener('scroll', req); removeEventListener('resize', req);
67
+ if (on) { addEventListener('scroll', req, { passive: true }); addEventListener('resize', req); req(); }
68
+ }, { rootMargin: margin });
69
+ io.observe(el);
70
+ addEventListener('scroll', req, { passive: true }); addEventListener('resize', req); req();
71
+ return {
72
+ update: () => { last = -1; req(); },
73
+ destroy() { io.disconnect(); removeEventListener('scroll', req); removeEventListener('resize', req); if (raf) cancelAnimationFrame(raf); },
74
+ };
75
+ }
76
+
77
+ export function once(el, fn, { threshold = 0.35, margin = '0px', rescue = 3000 } = {}) {
78
+ // fn runs once when `threshold` of el is on screen, or el covers that share of the screen (a target taller
79
+ // than the screen can never show `threshold` of itself), or any part of it has stayed on screen for `rescue`
80
+ // ms. An observer that has not reported at all after 1.5 s of a visible page runs fn too: nothing waits for ever
81
+ let timer = 0, starve = 0, done = false;
82
+ const go = () => { if (done) return; done = true; clearTimeout(timer); clearTimeout(starve); io.disconnect(); fn(); };
83
+ const steps = [0];
84
+ for (let t = 0.1; t < threshold - 1e-6; t += 0.1) steps.push(+t.toFixed(2));
85
+ steps.push(threshold);
86
+ const io = new IntersectionObserver(es => {
87
+ clearTimeout(starve);
88
+ const e = es[es.length - 1];
89
+ if (!e.isIntersecting) { clearTimeout(timer); timer = 0; return; }
90
+ const vh = e.rootBounds ? e.rootBounds.height : innerHeight;
91
+ if (e.intersectionRatio >= threshold || e.intersectionRect.height >= vh * threshold) return go();
92
+ if (!timer) timer = setTimeout(go, rescue);
93
+ }, { threshold: steps, rootMargin: margin });
94
+ const wait = () => { starve = setTimeout(() => (document.hidden ? wait() : go()), 1500); };
95
+ wait();
96
+ io.observe(el);
97
+ return { destroy() { done = true; clearTimeout(timer); clearTimeout(starve); io.disconnect(); } };
98
+ }
99
+
100
+ export function split(el, unit = 'words') {
101
+ if (!el.getAttribute('aria-label')) el.setAttribute('aria-label', el.textContent.replace(/\s+/g, ' ').trim());
102
+ const inners = [];
103
+ const wrap = (text, cls) => {
104
+ const s = document.createElement('span');
105
+ s.className = cls;
106
+ const i = document.createElement('span');
107
+ i.className = 'mo-i';
108
+ i.textContent = text;
109
+ s.append(i);
110
+ inners.push(i);
111
+ return s;
112
+ };
113
+ const walk = node => {
114
+ [...node.childNodes].forEach(n => {
115
+ if (n.nodeType === 3) {
116
+ const frag = document.createDocumentFragment();
117
+ n.textContent.split(/(\s+)/).forEach(part => {
118
+ if (!part) return;
119
+ if (/^\s+$/.test(part)) { frag.append(' '); return; }
120
+ if (unit === 'chars') {
121
+ const w = document.createElement('span');
122
+ w.className = 'mo-w';
123
+ for (const ch of part) w.append(wrap(ch, 'mo-c'));
124
+ frag.append(w);
125
+ } else frag.append(wrap(part, 'mo-w'));
126
+ });
127
+ n.replaceWith(frag);
128
+ } else if (n.nodeType === 1 && !n.classList.contains('mo-w')) {
129
+ // a link or button inside keeps its name: its words are hidden with the rest, so it is named first
130
+ if (n.matches('a[href], button') && !n.getAttribute('aria-label') && n.textContent.trim()) n.setAttribute('aria-label', n.textContent.replace(/\s+/g, ' ').trim());
131
+ walk(n);
132
+ }
133
+ });
134
+ };
135
+ walk(el);
136
+ el.querySelectorAll('.mo-w').forEach(w => w.setAttribute('aria-hidden', 'true'));
137
+ return inners;
138
+ }
139
+
140
+ export function lines(words) {
141
+ const out = [];
142
+ let top = null;
143
+ for (const w of words) {
144
+ const t = w.offsetTop;
145
+ if (top === null || Math.abs(t - top) > 2) { out.push([]); top = t; }
146
+ out[out.length - 1].push(w);
147
+ }
148
+ return out;
149
+ }
150
+
151
+ export const fontsReady = (ms = 900) => Promise.race([document.fonts ? document.fonts.ready : Promise.resolve(), new Promise(r => setTimeout(r, ms))]);
152
+
153
+ /*
154
+ blocks(root, skip) the section's words and pictures as whole blocks, for a moment that uncovers a section with a
155
+ clip (a disc, a line): a block is a heading, paragraph, list item, button, link, picture, UI
156
+ window or any element that carries text of its own, outermost first (a frame with its own
157
+ text is one block). A clip that slices through a block cuts its words mid-move, so such a
158
+ moment keeps each block invisible until the clip has passed the whole of it, then fades it
159
+ in whole. Returns { list, measure, set, release }:
160
+ list [{ el, l, t, r, b }] with the box of each block in root's own coordinates (set by measure)
161
+ measure() reads the boxes again (call when the root's size changes or the fonts arrive)
162
+ set(fn) fn(block) -> opacity 0-1 for every block; 1 puts the element's own inline opacity back
163
+ release() every block as it was
164
+ skip: elements (the moment's own layers) that are never a block.
165
+ */
166
+ const BLOCK = 'h1,h2,h3,h4,h5,h6,p,li,dt,dd,blockquote,figcaption,label,a,button,img,picture,video,canvas,svg,table,figure,.frame,.dw,[data-moment-block]';
167
+ export function blocks(root, skip = []) {
168
+ const list = [];
169
+ const walk = el => {
170
+ for (const c of el.children) {
171
+ if (skip.includes(c) || /^(SCRIPT|STYLE|NOSCRIPT|TEMPLATE)$/.test(c.tagName)) continue;
172
+ const own = [...c.childNodes].some(n => n.nodeType === 3 && n.textContent.trim());
173
+ if (c.matches(BLOCK) || own) list.push({ el: c, was: c.style.opacity, l: 0, t: 0, r: 0, b: 0 });
174
+ else walk(c);
175
+ }
176
+ };
177
+ walk(root);
178
+ const measure = () => {
179
+ const rr = root.getBoundingClientRect();
180
+ for (const b of list) {
181
+ const r = b.el.getBoundingClientRect();
182
+ b.l = r.left - rr.left; b.t = r.top - rr.top; b.r = r.right - rr.left; b.b = r.bottom - rr.top;
183
+ }
184
+ };
185
+ measure();
186
+ const set = fn => { for (const b of list) { const o = fn(b); b.el.style.opacity = o >= 0.999 ? b.was : (o <= 0 ? '0' : o.toFixed(3)); } };
187
+ const release = () => { for (const b of list) b.el.style.opacity = b.was; };
188
+ return { list, measure, set, release };
189
+ }
@@ -0,0 +1,109 @@
1
+ /*
2
+ moments.js - the loader for the page's one or two creative moments (taste-skill, references/moments.md).
3
+
4
+ <section data-moment="pinned-chapters" data-moment-opts='{"hold": 2.4}'>…</section>
5
+
6
+ in system.js: const m = await import(new URL('moments/moments.js', HERE).href); await m.ready;
7
+ on its own: <script type="module" src="assets/moments/moments.js"></script>
8
+
9
+ It finds every [data-moment], links <id>/moment.css, imports <id>/moment.js and calls its default
10
+ export mount(root, opts, lib) -> { destroy }. The page keeps scrolling natively; every moment shows
11
+ its finished state under prefers-reduced-motion, without script, and when its module fails.
12
+
13
+ Mounting is idempotent: an element mounts once however many times mount() or mountAll() is called
14
+ (the mount promise is kept on the element as __momentP, before any await), mountAll(document) is
15
+ one cached promise, and `ready` is that promise: it resolves with the mounted elements. Importing
16
+ this module starts mountAll(document) on its own unless window.__momentsManual is set first.
17
+
18
+ Marks on <html>: .mo-js as soon as this runs (a moment's CSS may hide what it will reveal only under
19
+ .mo-js, and .mo-safe arrives 2.5 s later as a fallback that shows everything); data-moments-ready="n"
20
+ when every moment is mounted (shoot scripts wait for it); data-moments-over="n" when a page holds
21
+ more than two, and data-moments-repeat when an id is used twice (both are faults: one or two a page,
22
+ an id once). A moment whose module fails gets data-moment-failed and the class mo-safe on its own
23
+ element (its CSS shows the finished state at once). The 2.5 s timer and .mo-js can also be set
24
+ earlier by one line in <head>, with modulepreload links for this file, lib.js and the dealt moment:
25
+ <script>document.documentElement.classList.add('mo-js');setTimeout(()=>document.documentElement.classList.add('mo-safe'),2500)</script>
26
+ <link rel="modulepreload" href="assets/moments/moments.js"><link rel="modulepreload" href="assets/moments/lib.js">
27
+ */
28
+ import * as lib from './lib.js';
29
+
30
+ const BASE = new URL('./', import.meta.url);
31
+ const html = document.documentElement;
32
+ const linked = new Map();
33
+ function css(href) {
34
+ if (!linked.has(href)) {
35
+ const done = [...document.querySelectorAll('link[rel="stylesheet"]')].some(l => l.href === href);
36
+ linked.set(href, done ? Promise.resolve() : new Promise(res => {
37
+ const l = document.createElement('link');
38
+ l.rel = 'stylesheet';
39
+ l.href = href;
40
+ l.onload = l.onerror = () => res();
41
+ document.head.appendChild(l);
42
+ }));
43
+ }
44
+ return linked.get(href);
45
+ }
46
+
47
+ export function mount(el) {
48
+ if (el.__momentP) return el.__momentP;
49
+ const id = el.dataset.moment;
50
+ if (!id) return Promise.resolve(null);
51
+ el.__momentP = (async () => {
52
+ let opts = {};
53
+ try { opts = JSON.parse(el.dataset.momentOpts || '{}'); } catch { console.warn(`moments: bad data-moment-opts on ${id}`); }
54
+ const card = lib.inCard(el);
55
+ const [, mod] = await Promise.all([css(new URL(`${id}/moment.css`, BASE).href), import(new URL(`${id}/moment.js`, BASE).href)]);
56
+ // a moment light enough for a phone says so in its module (export const phone = true: one picture
57
+ // or one line of words, transform, filter or colour, nothing pinned that a phone cannot hold): it runs
58
+ // there too, and only reduced motion and a card keep it still. Every other moment is still on a phone
59
+ const onPhone = mod.phone === true;
60
+ const why = onPhone ? (lib.reduced() ? 'reduced' : '') : lib.stillWhy();
61
+ if (card) { el.dataset.momentStill = 'card'; html.dataset.momentsCard = [html.dataset.momentsCard, id].filter(Boolean).join(' '); console.warn(`moments: ${id} sits in a card; it stays still`); }
62
+ else if (why) el.dataset.momentStill = why;
63
+ const mlib = { ...lib, reduced: () => card || (onPhone ? lib.reduced() : lib.still()) };
64
+ const api = mod.default(el, opts, mlib) || {};
65
+ el.__moment = api;
66
+ el.dataset.momentMounted = '1';
67
+ return api;
68
+ })();
69
+ return el.__momentP;
70
+ }
71
+
72
+ let docP = null, resolveReady;
73
+ export const ready = new Promise(r => { resolveReady = r; });
74
+
75
+ export function mountAll(root = document) {
76
+ if (root === document && docP) return docP;
77
+ const p = (async () => {
78
+ html.classList.add('mo-js');
79
+ const els = [...root.querySelectorAll('[data-moment]')].filter(el => !el.parentElement?.closest('[data-moment]'));
80
+ const ids = els.map(el => el.dataset.moment);
81
+ const repeat = ids.filter((id, i) => ids.indexOf(id) !== i);
82
+ if (repeat.length) { html.dataset.momentsRepeat = [...new Set(repeat)].join(' '); console.warn(`moments: an id twice on one page: ${repeat.join(', ')}`); }
83
+ if (ids.length > 2) { html.dataset.momentsOver = String(ids.length); console.warn(`moments: ${ids.length} moments on one page (one or two)`); }
84
+ await Promise.all(els.map(el => mount(el).catch(e => {
85
+ if (!el.dataset.momentFailed) console.warn(`moments: ${el.dataset.moment} failed: ${e.message}`);
86
+ el.dataset.momentFailed = e.message;
87
+ el.classList.add('mo-safe');
88
+ el.classList.remove('is-live'); // the hide rules are written under .is-live and ignore .mo-safe: a failed moment shows as written
89
+ el.classList.add('is-done');
90
+ })));
91
+ if (root === document) html.dataset.momentsReady = String(els.length);
92
+ return els;
93
+ })();
94
+ if (root === document) { docP = p; p.then(resolveReady, () => resolveReady([])); }
95
+ return p;
96
+ }
97
+
98
+ export function unmountAll(root = document) {
99
+ root.querySelectorAll('[data-moment-mounted]').forEach(el => { try { el.__moment?.destroy?.(); } catch { /* gone */ } delete el.__moment; delete el.__momentP; el.removeAttribute('data-moment-mounted'); });
100
+ if (root === document) docP = null;
101
+ }
102
+
103
+ html.classList.add('mo-js');
104
+ setTimeout(() => html.classList.add('mo-safe'), 2500);
105
+ const start = () => { if (!window.__momentsManual) mountAll(document); };
106
+ if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', start, { once: true });
107
+ else start();
108
+
109
+ export default { mount, mountAll, unmountAll, ready, lib };
@@ -0,0 +1,8 @@
1
+ /* word-highlight: the statement in the display face; each word rests at half ink on the ground and turns to ink when
2
+ the scroll reaches it, a <strong> word to the accent. Without script every word is ink. */
3
+ .mo-wh__text, [data-moment="word-highlight"] > .container > p { font-family: var(--font-display); font-weight: var(--display-weight); font-size: var(--t-h2); line-height: 1.16; letter-spacing: var(--display-tracking); max-width: 960px; text-wrap: pretty; }
4
+ .mo-wh .mo-w { color: color-mix(in oklab, var(--ink) 50%, var(--bg)); transition: color 160ms ease; }
5
+ .mo-wh .mo-w.is-on { color: var(--ink); }
6
+ .mo-wh strong { font-weight: inherit; }
7
+ .mo-wh strong .mo-w.is-on { color: var(--accent); }
8
+ @media (prefers-reduced-motion: reduce) { .mo-wh .mo-w { color: var(--ink); transition: none; } .mo-wh strong .mo-w { color: var(--accent); } }