phation 0.0.0-stage → 0.1.1
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 +110 -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/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 +51 -4
- package/server.json +36 -0
- package/share.mjs +72 -0
package/package.json
CHANGED
|
@@ -1,6 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phation",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"mcpName": "io.github.pnhathuy09/phation",
|
|
4
|
+
"version": "0.1.1",
|
|
5
|
+
"description": "Phation: production-ready interactions for React + Motion, as an MCP server and a CLI.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
8
|
+
"homepage": "https://phation.app",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/pnhathuy09/phation.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/pnhathuy09/phation/issues"
|
|
15
|
+
},
|
|
16
|
+
"bin": {
|
|
17
|
+
"phation-mcp": "bin/server.mjs",
|
|
18
|
+
"phation": "bin/cli.mjs"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"bin",
|
|
22
|
+
"lib.mjs",
|
|
23
|
+
"share.mjs",
|
|
24
|
+
"audit.mjs",
|
|
25
|
+
"data/entries.json",
|
|
26
|
+
"data/standard",
|
|
27
|
+
"LICENSE.md",
|
|
28
|
+
"README.md",
|
|
29
|
+
"animate/*.mjs",
|
|
30
|
+
"animate/core",
|
|
31
|
+
"server.json"
|
|
32
|
+
],
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=18"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@babel/parser": "7.29.13",
|
|
38
|
+
"@modelcontextprotocol/sdk": "1.32.1",
|
|
39
|
+
"puppeteer-core": "23.11.1",
|
|
40
|
+
"zod": "4.6.7"
|
|
41
|
+
},
|
|
42
|
+
"keywords": [
|
|
43
|
+
"motion",
|
|
44
|
+
"animation",
|
|
45
|
+
"react",
|
|
46
|
+
"framer-motion",
|
|
47
|
+
"mcp",
|
|
48
|
+
"claude",
|
|
49
|
+
"cursor",
|
|
50
|
+
"ui",
|
|
51
|
+
"spring"
|
|
52
|
+
]
|
|
53
|
+
}
|
package/server.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "io.github.pnhathuy09/phation",
|
|
4
|
+
"title": "Phation",
|
|
5
|
+
"description": "Motion rules and ready-made React + Motion interactions so your agent's animations feel right.",
|
|
6
|
+
"repository": {
|
|
7
|
+
"url": "https://github.com/pnhathuy09/phation",
|
|
8
|
+
"source": "github"
|
|
9
|
+
},
|
|
10
|
+
"websiteUrl": "https://phation.app",
|
|
11
|
+
"version": "0.1.1",
|
|
12
|
+
"packages": [
|
|
13
|
+
{
|
|
14
|
+
"registryType": "npm",
|
|
15
|
+
"identifier": "phation",
|
|
16
|
+
"version": "0.1.1",
|
|
17
|
+
"transport": {
|
|
18
|
+
"type": "stdio"
|
|
19
|
+
},
|
|
20
|
+
"packageArguments": [
|
|
21
|
+
{
|
|
22
|
+
"type": "positional",
|
|
23
|
+
"value": "mcp"
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"environmentVariables": [
|
|
27
|
+
{
|
|
28
|
+
"name": "PHATION_KEY",
|
|
29
|
+
"description": "Phation Pro license key (optional; enables add_motion, audit_motion and animate_ui)",
|
|
30
|
+
"isRequired": false,
|
|
31
|
+
"isSecret": true
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}
|
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
|
+
}
|