phation 0.0.0-stage → 0.1.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/LICENSE.md +15 -0
- package/README.md +142 -2
- package/animate/core/feels.js +11 -0
- package/animate/core/recipes/index.js +84 -0
- package/animate/core/recipes/resolve.js +96 -0
- package/animate/detect.mjs +201 -0
- package/animate/index.mjs +266 -0
- package/animate/testset/eval.mjs +24 -0
- package/animate/testset/expected.json +23 -0
- package/animate/testset/holdout/commerce-delete-item-button.tsx +38 -0
- package/animate/testset/holdout/commerce-gallery.tsx +96 -0
- package/animate/testset/holdout/commerce-tile.tsx +50 -0
- package/animate/testset/holdout/shadcn-button-group-demo.tsx +114 -0
- package/animate/testset/holdout/shadcn-card-demo.tsx +63 -0
- package/animate/testset/holdout/shadcn-command-dialog.tsx +87 -0
- package/animate/testset/holdout/shadcn-drawer-dialog.tsx +90 -0
- package/animate/testset/holdout/shadcn-field-switch.tsx +24 -0
- package/animate/testset/holdout/shadcn-hover-card-demo.tsx +40 -0
- package/animate/testset/holdout/shadcn-mode-toggle.tsx +40 -0
- package/animate/testset/holdout/shadcn-toggle-group-demo.tsx +22 -0
- package/animate/testset/holdout.json +14 -0
- package/animate/testset/holdout2/chatbot-artifact-close-button.tsx +30 -0
- package/animate/testset/holdout2/chatbot-message-actions.tsx +211 -0
- package/animate/testset/holdout2/chatbot-sidebar-history-item.tsx +132 -0
- package/animate/testset/holdout2/chatbot-sidebar-toggle.tsx +35 -0
- package/animate/testset/holdout2/chatbot-suggested-actions.tsx +82 -0
- package/animate/testset/holdout2/chatbot-weather.tsx +434 -0
- package/animate/testset/holdout2/site-code-tabs.tsx +26 -0
- package/animate/testset/holdout2/site-copy-button.tsx +121 -0
- package/animate/testset/holdout2/site-github-link.tsx +38 -0
- package/animate/testset/holdout2/site-mobile-nav.tsx +220 -0
- package/animate/testset/holdout2/site-mode-switcher.tsx +97 -0
- package/animate/testset/holdout2/site-page-nav.tsx +15 -0
- package/animate/testset/holdout2.json +15 -0
- package/animate/testset/screens/commerce-cart-add-to-cart.tsx +94 -0
- package/animate/testset/screens/commerce-cart-modal.tsx +256 -0
- package/animate/testset/screens/commerce-navbar-mobile-menu.tsx +104 -0
- package/animate/testset/screens/commerce-product-variant-selector.tsx +106 -0
- package/animate/testset/screens/shadcn-accordion-demo.tsx +61 -0
- package/animate/testset/screens/shadcn-alert-dialog-demo.tsx +35 -0
- package/animate/testset/screens/shadcn-card-with-form.tsx +59 -0
- package/animate/testset/screens/shadcn-collapsible-demo.tsx +46 -0
- package/animate/testset/screens/shadcn-dialog-demo.tsx +50 -0
- package/animate/testset/screens/shadcn-drawer-demo.tsx +136 -0
- package/animate/testset/screens/shadcn-login-form.tsx +71 -0
- package/animate/testset/screens/shadcn-nav-main.tsx +73 -0
- package/animate/testset/screens/shadcn-section-cards.tsx +102 -0
- package/animate/testset/screens/shadcn-sheet-demo.tsx +47 -0
- package/animate/testset/screens/shadcn-switch-demo.tsx +11 -0
- package/animate/testset/screens/shadcn-tabs-demo.tsx +80 -0
- package/animate/testset/screens/taxonomy-main-nav.tsx +61 -0
- package/animate/testset/screens/taxonomy-post-item.tsx +42 -0
- package/animate/testset/screens/taxonomy-pricing.tsx +69 -0
- package/animate/testset/screens/taxonomy-user-account-nav.tsx +65 -0
- package/audit.mjs +456 -0
- package/bin/cli.mjs +113 -0
- package/bin/server.mjs +147 -0
- package/data/entries.json +864 -0
- package/data/standard/CORE.md +21 -0
- package/data/standard/STANDARD.md +185 -0
- package/data/standard/claude/CLAUDE.block.md +5 -0
- package/data/standard/claude/SKILL.md +26 -0
- package/data/standard/codex/AGENTS.block.md +25 -0
- package/data/standard/cursor/phation.mdc +27 -0
- package/data/standard/meta.json +4 -0
- package/data/standard/vscode/phation.instructions.md +25 -0
- package/data/standard/windsurf/phation.md +26 -0
- package/lib.mjs +214 -0
- package/package.json +41 -4
- package/share.mjs +72 -0
package/share.mjs
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Studio share links: tuned motion values travel in the URL query of an entry page, only the keys that differ from
|
|
2
|
+
// the entry's defaults. Readable on purpose, so a link in Slack says what changed:
|
|
3
|
+
// /m/digit-roll?digit=s420_32_1&stagger=60 spring s<stiffness>_<damping>_<mass>
|
|
4
|
+
// /m/buy-morph?morph=b0.16_1_0.3_1&morphMs=450 curve b<x1>_<y1>_<x2>_<y2>
|
|
5
|
+
// number plain (ms, %, px…)
|
|
6
|
+
// Shared by the site (Studio) and the CLI (`phation add <slug> --from <link>`), so both read the same format.
|
|
7
|
+
|
|
8
|
+
const num = s => (s !== '' && Number.isFinite(+s) ? +s : null)
|
|
9
|
+
|
|
10
|
+
export function encodeValue(v) {
|
|
11
|
+
if (Array.isArray(v)) return 'b' + v.join('_')
|
|
12
|
+
if (v && typeof v === 'object') return `s${v.stiffness}_${v.damping}_${v.mass ?? 1}`
|
|
13
|
+
return String(v)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function decodeValue(s) {
|
|
17
|
+
s = String(s).trim()
|
|
18
|
+
if (s[0] === 's') {
|
|
19
|
+
const [k, c, m] = s.slice(1).split('_').map(num)
|
|
20
|
+
return k !== null && c !== null ? { stiffness: k, damping: c, mass: m ?? 1 } : null
|
|
21
|
+
}
|
|
22
|
+
if (s[0] === 'b') {
|
|
23
|
+
const b = s.slice(1).split('_').map(num)
|
|
24
|
+
return b.length === 4 && b.every(x => x !== null) ? b : null
|
|
25
|
+
}
|
|
26
|
+
return num(s)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b)
|
|
30
|
+
|
|
31
|
+
/** Query string ('' when nothing changed) for the values that differ from the defaults. */
|
|
32
|
+
export function encodeValues(values, defaults) {
|
|
33
|
+
const q = new URLSearchParams()
|
|
34
|
+
for (const [k, v] of Object.entries(values)) if (!same(v, defaults[k])) q.set(k, encodeValue(v))
|
|
35
|
+
return q.toString().replace(/%2C/g, ',')
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** { key: value } from a link, a query string or URLSearchParams; unknown or malformed values are dropped. */
|
|
39
|
+
export function decodeValues(input) {
|
|
40
|
+
let q
|
|
41
|
+
if (input instanceof URLSearchParams) q = input
|
|
42
|
+
else {
|
|
43
|
+
const s = String(input).trim()
|
|
44
|
+
try { q = new URL(s).searchParams } catch { q = new URLSearchParams(s.includes('?') ? s.slice(s.indexOf('?') + 1) : s) }
|
|
45
|
+
}
|
|
46
|
+
const out = {}
|
|
47
|
+
for (const [k, raw] of q) { const v = decodeValue(raw); if (v !== null && /^\w+$/.test(k)) out[k] = v }
|
|
48
|
+
return out
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Slug of an entry link (/m/<slug>), or null. */
|
|
52
|
+
export const slugOfLink = s => { try { return new URL(s).pathname.match(/^\/m\/([^/?#]+)/)?.[1] ?? null } catch { return null } }
|
|
53
|
+
|
|
54
|
+
const lit = v => (Array.isArray(v) ? `[${v.join(', ')}]` : v && typeof v === 'object' ? `{ type: 'spring', stiffness: ${v.stiffness}, damping: ${v.damping}, mass: ${v.mass} }` : String(v))
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Rewrites the `export const MOTION = { … }` block of an entry's source with tuned values. Each key sits on its own
|
|
58
|
+
* line (` key: value, // comment`); comments are kept. Returns { code, applied, skipped }.
|
|
59
|
+
*/
|
|
60
|
+
export function applyValues(code, values, note) {
|
|
61
|
+
const start = code.search(/^export const MOTION = \{/m)
|
|
62
|
+
if (start < 0) return { code, applied: [], skipped: Object.keys(values) }
|
|
63
|
+
const end = code.indexOf('\n}', start)
|
|
64
|
+
let block = code.slice(start, end)
|
|
65
|
+
const applied = [], skipped = []
|
|
66
|
+
for (const [k, v] of Object.entries(values)) {
|
|
67
|
+
const re = new RegExp(`^(\\s+${k}: )(.+?)(,[ \\t]*(//.*)?)$`, 'm')
|
|
68
|
+
if (re.test(block)) { block = block.replace(re, (_, a, _b, c) => a + lit(v) + c); applied.push(k) } else skipped.push(k)
|
|
69
|
+
}
|
|
70
|
+
const head = note && applied.length ? `// ${note}\n` : ''
|
|
71
|
+
return { code: code.slice(0, start) + head + block + code.slice(end), applied, skipped }
|
|
72
|
+
}
|