Skip to content

StemJSON v1.1.0

Latest

Choose a tag to compare

@vkrychun vkrychun released this 02 Jul 08:35
· 6 commits to main since this release

Minor version: backwards-compatible language additions plus editorial clarifications. Modules targeting 1.0 are unaffected; a module that uses a 1.1 feature SHOULD declare "version": "1.1".

Added

  • switch() expression function (§8.6) — a flat multi-way conditional: switch(test1, value1, test2, value2, …, default). Returns the value paired with the first truthy test, or the trailing default. Eliminates the deeply nested ternaries that are the dominant source of unbalanced-paren errors in generated modules.
  • random() and range() functions (§8.6, §8.6.1) — random() → a double in [0, 1), random(min, max) → an inclusive integer; range(n) / range(start, end) build an integer sequence. range pairs with map to generate structured data declaratively. random is nondeterministic and must be used in an action/lifecycle value, never a render binding.
  • Collection functions (§8.6) — positional array edits setAt(arr, i, v), removeAt(arr, i), insertAt(arr, i, v) (negative indices count from the tail), and dictionary utilities keys(dict), values(dict), removeKey(dict, k). All return a new value. Positional array editing is the missing piece for piece-moving board games and index-addressed grids.
  • ai action (§10.11) — calls an AI provider and binds the result into the module, the foundation for AI-driven backends (a game opponent, summarization, on-the-fly data shaping). Provider-agnostic: the model, prompt, and response schema live in the request body; the API key is injected by the host repository's auth interceptor, never in JSON.

Clarified (editorial; runtime behavior unchanged)

  • Chained ternaries take no parentheses (§8.5) — the ternary is right-associative with lowest precedence, so a ? b : c ? d : e chains natively; the flat form is canonical.
  • style.shape.stroke (§7.9) — content accepts the same value forms as fill, including { "gradient": ... } directly as the discriminator.

Previous spec revisions remain available: spec/v1.0.md.

Full normative spec: spec/v1.1.md · LLM edition: spec/v1.1-ai.md