@glissade/cli 0.44.0-pre.0 → 0.44.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 (2) hide show
  1. package/dist/typedSdk.js +27 -19
  2. 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 (+ the
22
- * component surface is construction-only, so excluded). Deduped by path; the FIRST
23
- * value type wins and a differing later one is reported in `conflicts` (base targets
24
- * are uniform a conflict is a taxonomy smell worth surfacing, not silently picking).
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 existing = byPath.get(path);
32
- if (existing === void 0) byPath.set(path, prop.type);
33
- else if (existing !== prop.type) conflicts.push(`${path}: ${existing} vs ${prop.type}`);
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: [...byPath.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([path, valueType]) => ({
37
- path,
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, conflicts } = collectTargets(manifest);
53
- const usedCoreTypes = [...new Set(targets.map((t) => CORE_TYPE_IMPORTS[t.valueType]).filter((n) => n !== void 0))].sort();
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 (conflicts.length) L.push(`// NOTE: ${conflicts.length} path(s) carry >1 value type across nodes: ${conflicts.join(", ")}`);
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}\` ? '${t.valueType}' :`);
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}\` ? ${tsValueOf(t.valueType)} :`);
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.0",
3
+ "version": "0.44.0",
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.0",
32
- "@glissade/core": "0.44.0-pre.0",
33
- "@glissade/interact": "0.44.0-pre.0",
34
- "@glissade/lottie": "0.44.0-pre.0",
35
- "@glissade/narrate": "0.44.0-pre.0",
36
- "@glissade/player": "0.44.0-pre.0",
37
- "@glissade/scene": "0.44.0-pre.0",
38
- "@glissade/sfx": "0.44.0-pre.0",
39
- "@glissade/svg": "0.44.0-pre.0"
31
+ "@glissade/backend-skia": "0.44.0",
32
+ "@glissade/core": "0.44.0",
33
+ "@glissade/interact": "0.44.0",
34
+ "@glissade/lottie": "0.44.0",
35
+ "@glissade/narrate": "0.44.0",
36
+ "@glissade/player": "0.44.0",
37
+ "@glissade/scene": "0.44.0",
38
+ "@glissade/sfx": "0.44.0",
39
+ "@glissade/svg": "0.44.0"
40
40
  },
41
41
  "repository": {
42
42
  "type": "git",