@glissade/cli 0.44.0-pre.0 → 0.44.0-pre.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/dist/typedSdk.js +27 -19
- package/package.json +10 -10
package/dist/typedSdk.js
CHANGED
|
@@ -18,26 +18,29 @@ const CORE_TYPE_IMPORTS = {
|
|
|
18
18
|
path: "PathValue"
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
21
|
-
* Collect every animatable prop path across the manifest's node taxonomy (
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
21
|
+
* Collect every animatable prop path across the manifest's node taxonomy (component
|
|
22
|
+
* props are construction-only → excluded). Value types are UNIONED per path — the
|
|
23
|
+
* manifest encodes a polymorphic prop as a pipe-joined id (`'color|paint'`), and a
|
|
24
|
+
* path can carry different types on different node types; both cases become the union
|
|
25
|
+
* of members, so passing ANY valid member type-checks (a wrong-type-for-a-specific-node
|
|
26
|
+
* still fails loud at bind — the honest best an instance-free SDK can do). `polymorphic`
|
|
27
|
+
* lists the >1-member paths for the header note.
|
|
25
28
|
*/
|
|
26
29
|
function collectTargets(manifest) {
|
|
27
30
|
const byPath = /* @__PURE__ */ new Map();
|
|
28
|
-
const conflicts = [];
|
|
29
31
|
for (const node of Object.values(manifest.nodes)) for (const [path, prop] of Object.entries(node.props)) {
|
|
30
32
|
if (!prop.animatable || prop.target === void 0) continue;
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
const set = byPath.get(path) ?? /* @__PURE__ */ new Set();
|
|
34
|
+
for (const member of prop.type.split("|")) set.add(member.trim());
|
|
35
|
+
byPath.set(path, set);
|
|
34
36
|
}
|
|
37
|
+
const targets = [...byPath.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([path, set]) => ({
|
|
38
|
+
path,
|
|
39
|
+
valueTypes: [...set].sort()
|
|
40
|
+
}));
|
|
35
41
|
return {
|
|
36
|
-
targets
|
|
37
|
-
|
|
38
|
-
valueType
|
|
39
|
-
})),
|
|
40
|
-
conflicts
|
|
42
|
+
targets,
|
|
43
|
+
polymorphic: targets.filter((t) => t.valueTypes.length > 1).map((t) => `${t.path}: ${t.valueTypes.join(" | ")}`)
|
|
41
44
|
};
|
|
42
45
|
}
|
|
43
46
|
const tsValueOf = (valueType) => TS_VALUE_TYPE[valueType] ?? "unknown";
|
|
@@ -49,14 +52,18 @@ const tsValueOf = (valueType) => TS_VALUE_TYPE[valueType] ?? "unknown";
|
|
|
49
52
|
* sorted, so the same manifest → byte-identical output (drift-guardable with `--check`).
|
|
50
53
|
*/
|
|
51
54
|
function generateTypedSdk(manifest) {
|
|
52
|
-
const { targets,
|
|
53
|
-
const usedCoreTypes = [...new Set(targets.
|
|
55
|
+
const { targets, polymorphic } = collectTargets(manifest);
|
|
56
|
+
const usedCoreTypes = [...new Set(targets.flatMap((t) => t.valueTypes.map((v) => CORE_TYPE_IMPORTS[v])).filter((n) => n !== void 0))].sort();
|
|
57
|
+
/** union of value-type id literals for a target, e.g. `'color' | 'paint'`. */
|
|
58
|
+
const typeIdUnion = (t) => t.valueTypes.map((v) => `'${v}'`).join(" | ");
|
|
59
|
+
/** union of TS value types for a target, e.g. `string | Paint`. */
|
|
60
|
+
const valueUnion = (t) => [...new Set(t.valueTypes.map(tsValueOf))].join(" | ");
|
|
54
61
|
const L = [];
|
|
55
62
|
L.push(`// GENERATED by \`gs types\` from the describe() API manifest v${manifest.version} — DO NOT EDIT.`);
|
|
56
63
|
L.push("// Regenerate after a glissade upgrade (or when you add a defineComponent target):");
|
|
57
64
|
L.push("// gs types --out glissade-targets.ts");
|
|
58
65
|
L.push("// Then import `track` from here instead of @glissade/core to type-check your targets.");
|
|
59
|
-
if (
|
|
66
|
+
if (polymorphic.length) L.push(`// Polymorphic paths (accept a value-type UNION): ${polymorphic.join(", ")}`);
|
|
60
67
|
L.push("");
|
|
61
68
|
L.push(`import { track as _track, type Track, type Key } from '@glissade/core';`);
|
|
62
69
|
if (usedCoreTypes.length) L.push(`import type { ${usedCoreTypes.join(", ")} } from '@glissade/core';`);
|
|
@@ -69,14 +76,15 @@ function generateTypedSdk(manifest) {
|
|
|
69
76
|
L.push("/** A track target: any node id + a KNOWN animatable path. */");
|
|
70
77
|
L.push("export type TrackTarget = `${string}/${KnownTrackPath}`;");
|
|
71
78
|
L.push("");
|
|
72
|
-
L.push("/** The value-type id each path expects (a wrong `type` arg is a type error
|
|
79
|
+
L.push("/** The value-type id each path expects (a wrong `type` arg is a type error;");
|
|
80
|
+
L.push(" * a polymorphic prop like `fill: color|paint` accepts either member). */");
|
|
73
81
|
L.push("type TypeIdOf<P extends TrackTarget> =");
|
|
74
|
-
for (const t of targets) L.push(` P extends \`\${string}/${t.path}\` ?
|
|
82
|
+
for (const t of targets) L.push(` P extends \`\${string}/${t.path}\` ? ${typeIdUnion(t)} :`);
|
|
75
83
|
L.push(" never;");
|
|
76
84
|
L.push("");
|
|
77
85
|
L.push("/** The value each path animates (the keyframe value type). */");
|
|
78
86
|
L.push("type ValueOf<P extends TrackTarget> =");
|
|
79
|
-
for (const t of targets) L.push(` P extends \`\${string}/${t.path}\` ? ${
|
|
87
|
+
for (const t of targets) L.push(` P extends \`\${string}/${t.path}\` ? ${valueUnion(t)} :`);
|
|
80
88
|
L.push(" never;");
|
|
81
89
|
L.push("");
|
|
82
90
|
L.push("/**");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glissade/cli",
|
|
3
|
-
"version": "0.44.0-pre.
|
|
3
|
+
"version": "0.44.0-pre.1",
|
|
4
4
|
"description": "glissade CLI: headless rendering via backend-skia (+ FFmpeg mux).",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"engines": {
|
|
@@ -28,15 +28,15 @@
|
|
|
28
28
|
"@napi-rs/canvas": "^0.1.65",
|
|
29
29
|
"esbuild": "0.28.0",
|
|
30
30
|
"jiti": "^2.4.2",
|
|
31
|
-
"@glissade/backend-skia": "0.44.0-pre.
|
|
32
|
-
"@glissade/core": "0.44.0-pre.
|
|
33
|
-
"@glissade/interact": "0.44.0-pre.
|
|
34
|
-
"@glissade/lottie": "0.44.0-pre.
|
|
35
|
-
"@glissade/narrate": "0.44.0-pre.
|
|
36
|
-
"@glissade/player": "0.44.0-pre.
|
|
37
|
-
"@glissade/scene": "0.44.0-pre.
|
|
38
|
-
"@glissade/sfx": "0.44.0-pre.
|
|
39
|
-
"@glissade/svg": "0.44.0-pre.
|
|
31
|
+
"@glissade/backend-skia": "0.44.0-pre.1",
|
|
32
|
+
"@glissade/core": "0.44.0-pre.1",
|
|
33
|
+
"@glissade/interact": "0.44.0-pre.1",
|
|
34
|
+
"@glissade/lottie": "0.44.0-pre.1",
|
|
35
|
+
"@glissade/narrate": "0.44.0-pre.1",
|
|
36
|
+
"@glissade/player": "0.44.0-pre.1",
|
|
37
|
+
"@glissade/scene": "0.44.0-pre.1",
|
|
38
|
+
"@glissade/sfx": "0.44.0-pre.1",
|
|
39
|
+
"@glissade/svg": "0.44.0-pre.1"
|
|
40
40
|
},
|
|
41
41
|
"repository": {
|
|
42
42
|
"type": "git",
|