Skip to content

feat(sdk): variable declaration read APIs + browser-safe variables entry#2046

Open
jrusso1020 wants to merge 1 commit into
mainfrom
07-07-feat_sdk_variable_declaration_read_apis_browser-safe_variables_entry
Open

feat(sdk): variable declaration read APIs + browser-safe variables entry#2046
jrusso1020 wants to merge 1 commit into
mainfrom
07-07-feat_sdk_variable_declaration_read_apis_browser-safe_variables_entry

Conversation

@jrusso1020

@jrusso1020 jrusso1020 commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

What

First PR of the template-variables Studio stack (#2046#2052): the SDK read surface for composition variables, plus a new browser-safe @hyperframes/core/variables entry point.

  • comp.getVariableDeclarations() — the typed schema from data-composition-variables (same strict filter the render pipeline uses)
  • comp.getVariableValues(overrides?) — resolves values exactly like the runtime's getVariables() (loose defaults merged under overrides, undeclared keys pass through), so callers can predict what a composition script will read for a given --variables payload
  • comp.validateVariableValues(values) — same checks as --strict-variables (undeclared / type-mismatch / enum-out-of-range)
  • @hyperframes/core/variables: one browser-safe import for the whole variables surface (schema types, parseCompositionVariables, getVariables/readDeclaredDefaults, validateVariables)
  • parsers: parseCompositionVariables moved out of the linkedom-heavy htmlParser.ts into a browser-safe module (re-exported from the root and ./composition entries)

Why

The variables backend (runtime merge, CLI/Lambda injection, validation) is complete, but Studio and embedders had no API to inspect a composition's variable contract. This PR is the foundation the rest of the stack (edit ops → studio-server plumbing → Variables panel) builds on, SDK-first so agents and embedded hosts get the same contract as Studio.

How

The subpath exists because the core/parsers root barrels pull Node-only modules and break browser bundles — verified by building the studio against a root import (it fails on node:path in assetPaths.ts). getVariableValues deliberately uses the runtime's loose defaults extraction, not the strict declaration parser, so its output matches render behavior byte-for-byte even for malformed entries the strict parser drops (covered by a dedicated test).

Test plan

  • Unit tests added: session.variables.test.ts (declarations parsing, runtime-parity merge including the loose-vs-strict divergence case, validation issues)
  • Full suites green: sdk 435, parsers 1118, core 1118; studio browser build passes (the regression that motivated the subpath)
  • Manual testing performed (see fix(studio): code-review and live-test fixes for the variables stack #2052 — the whole stack was driven end-to-end in a live studio session)

🤖 Generated with Claude Code

First PR of the template-variables Studio stack — the SDK read surface.

- @hyperframes/core/variables: new browser-safe subpath bundling the full
  composition-variables surface in one import: schema types,
  parseCompositionVariables, getVariables/readDeclaredDefaults,
  validateVariables. The core/parsers root barrels pull Node-only modules
  and break browser bundles (verified against the studio build).
- parsers: move parseCompositionVariables out of htmlParser.ts into a
  browser-safe module; re-export from the root and ./composition entries.
- sdk: new read-only Composition methods:
  - getVariableDeclarations() — strict canonical schema parse
  - getVariableValues(overrides?) — mirrors the runtime getVariables()
    merge exactly (loose defaults + overrides, undeclared keys pass through)
  - validateVariableValues(values) — same checks as --strict-variables
- re-export CompositionVariable/CompositionVariableType/
  VariableValidationIssue types from the SDK for consumers.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jrusso1020 jrusso1020 force-pushed the 07-07-feat_sdk_variable_declaration_read_apis_browser-safe_variables_entry branch from df8c269 to 9e24243 Compare July 8, 2026 08:00
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Fallow audit report

Found 1 finding.

Details
Severity Rule Location Description
major fallow/unused-export packages/parsers/src/compositionVariables.ts:31 Export 'isScalarVariableValue' is never imported by other modules

Generated by fallow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant