transitions-refine 0.3.4 → 0.3.5
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/demo.html +748 -257
- package/package.json +1 -1
- package/server/inject.mjs +7 -3
- package/server/motion-tokens.mjs +4 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "transitions-refine",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "Live, agent-driven Refine panel for CSS/Motion transitions — injects a timeline + Refine UI and runs transitions.dev suggestions via your coding agent.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/server/inject.mjs
CHANGED
|
@@ -14,6 +14,7 @@ import { readFile } from "node:fs/promises";
|
|
|
14
14
|
import { fileURLToPath } from "node:url";
|
|
15
15
|
|
|
16
16
|
const DEMO_PATH = fileURLToPath(new URL("../demo.html", import.meta.url));
|
|
17
|
+
const PKG_PATH = fileURLToPath(new URL("../package.json", import.meta.url));
|
|
17
18
|
|
|
18
19
|
// Absolute module URLs so the injected script works without an import map.
|
|
19
20
|
const REACT_URL = "https://esm.sh/react@19";
|
|
@@ -40,7 +41,7 @@ function stripSkipRegions(css) {
|
|
|
40
41
|
return css.replace(/\/\*\s*@inject-skip-start[\s\S]*?@inject-skip-end\s*\*\//g, "").trim();
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
function buildJs(scriptSrc) {
|
|
44
|
+
function buildJs(scriptSrc, version) {
|
|
44
45
|
let js = scriptSrc;
|
|
45
46
|
// Drop everything from the demo-only boxes onward (App + createRoot render).
|
|
46
47
|
const cut = js.indexOf(CUT_MARKER);
|
|
@@ -57,7 +58,7 @@ function buildJs(scriptSrc) {
|
|
|
57
58
|
// works on any port the CLI chose (the script is served BY the relay).
|
|
58
59
|
js = js.replace(
|
|
59
60
|
/(import\s+\{\s*createPortal\s*\}\s+from\s+"[^"]+";)/,
|
|
60
|
-
`$1\n try { if (typeof window !== "undefined"
|
|
61
|
+
`$1\n try { if (typeof window !== "undefined") { if (!window.REFINE_RELAY_URL) window.REFINE_RELAY_URL = new URL(import.meta.url).origin; window.__TX_REFINE_VERSION = ${JSON.stringify(version || "")}; } } catch (e) {}`
|
|
61
62
|
);
|
|
62
63
|
|
|
63
64
|
return js.trim();
|
|
@@ -112,8 +113,11 @@ export async function buildInjectModule({ noCache = false } = {}) {
|
|
|
112
113
|
throw new Error("inject: could not locate <style> or module <script> in demo.html");
|
|
113
114
|
}
|
|
114
115
|
|
|
116
|
+
let version = "";
|
|
117
|
+
try { version = JSON.parse(await readFile(PKG_PATH, "utf8")).version || ""; } catch (e) {}
|
|
118
|
+
|
|
115
119
|
const css = stripSkipRegions(styleSrc);
|
|
116
|
-
const js = buildJs(scriptSrc);
|
|
120
|
+
const js = buildJs(scriptSrc, version);
|
|
117
121
|
_cache = `${js}\n${buildEpilogue(css)}`;
|
|
118
122
|
return _cache;
|
|
119
123
|
}
|
package/server/motion-tokens.mjs
CHANGED
|
@@ -78,10 +78,11 @@ export function refineTimings(timings) {
|
|
|
78
78
|
id: `${prop}-duration`,
|
|
79
79
|
kind: "duration",
|
|
80
80
|
property: prop,
|
|
81
|
+
member: t.member || null,
|
|
81
82
|
title: `Duration → ${token.name}`,
|
|
82
83
|
from: `${t.durationMs}ms`,
|
|
83
84
|
to: `${token.ms}ms`,
|
|
84
|
-
patch: { property: prop, durationMs: token.ms },
|
|
85
|
+
patch: { property: prop, durationMs: token.ms, ...(t.member ? { member: t.member } : {}) },
|
|
85
86
|
reason: `${token.name} (${token.ms}ms) is the closest motion token — used for ${token.usage}. ${t.durationMs}ms is off-grid.`,
|
|
86
87
|
});
|
|
87
88
|
}
|
|
@@ -93,10 +94,11 @@ export function refineTimings(timings) {
|
|
|
93
94
|
id: `${prop}-easing`,
|
|
94
95
|
kind: "easing",
|
|
95
96
|
property: prop,
|
|
97
|
+
member: t.member || null,
|
|
96
98
|
title: `Easing → Smooth ease out`,
|
|
97
99
|
from: t.easing,
|
|
98
100
|
to: SMOOTH_OUT,
|
|
99
|
-
patch: { property: prop, easing: SMOOTH_OUT },
|
|
101
|
+
patch: { property: prop, easing: SMOOTH_OUT, ...(t.member ? { member: t.member } : {}) },
|
|
100
102
|
reason: `"${t.easing}" is a generic curve. The transitions.dev standard ease-out reads more intentional on opens, closes, slides, and resizes.`,
|
|
101
103
|
});
|
|
102
104
|
}
|