@slexkit/streamdown 0.2.0 → 0.3.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/index.js +19 -2
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { createElement, Fragment, useEffect, useMemo, useRef, useState, } from "
2
2
  import { CodeBlockContainer, CodeBlockHeader, } from "streamdown";
3
3
  import { ingest, getSlexKitMarkdownRuntimeHost, mount, mountSecureArtifact, parseSlexSource, } from "slexkit";
4
4
  const DEFAULT_LANGUAGES = ["slex"];
5
- const STREAMDOWN_RENDERER_VERSION = "0.2.0";
5
+ const STREAMDOWN_RENDERER_VERSION = "0.3.0";
6
6
  const DEFAULT_SECURE_POLICY = {};
7
7
  function languageList(languages) {
8
8
  return languages ?? [...DEFAULT_LANGUAGES];
@@ -177,7 +177,7 @@ export function SlexKitRenderer({ code, language, isIncomplete, meta, domain, re
177
177
  return parsedSource?.ok && isStateOnlySource(parsedSource.value) ? "state-only" : "renderable";
178
178
  }, [delegatesToSecureHost, isIncomplete, isSecureRuntime, parsedSource]);
179
179
  const isStateOnly = sourceKind === "state-only";
180
- const runtimeInput = useMemo(() => isSecureRuntime || delegatesToSecureHost ? String(code) : scopedSlexKitInput(code, parsedSource?.ok ? parsedSource.value : undefined, domain), [code, delegatesToSecureHost, domain, isSecureRuntime, parsedSource]);
180
+ const runtimeInput = useMemo(() => isSecureRuntime || activeRuntimeHost ? String(code) : scopedSlexKitInput(code, parsedSource?.ok ? parsedSource.value : undefined, domain), [code, activeRuntimeHost, domain, isSecureRuntime, parsedSource]);
181
181
  const effectiveRenderMode = useMemo(() => resolveRenderMode(meta, renderMode), [meta, renderMode]);
182
182
  const parseError = parsedSource && !parsedSource.ok ? parsedSource.error : null;
183
183
  const displayError = parseError ?? error;
@@ -190,6 +190,22 @@ export function SlexKitRenderer({ code, language, isIncomplete, meta, domain, re
190
190
  return;
191
191
  }
192
192
  if (isStateOnly) {
193
+ if (activeRuntimeHost) {
194
+ const container = document.createElement("span");
195
+ try {
196
+ const cleanup = activeRuntimeHost.mountBlock({
197
+ artifactId: domain,
198
+ source: runtimeInput,
199
+ container,
200
+ });
201
+ return cleanup;
202
+ }
203
+ catch (err) {
204
+ setError(err);
205
+ onError?.(err, String(code));
206
+ return;
207
+ }
208
+ }
193
209
  if (!ingest(runtimeInput)) {
194
210
  const err = new Error("Failed to parse Slex state block.");
195
211
  setError(err);
@@ -245,6 +261,7 @@ export function SlexKitRenderer({ code, language, isIncomplete, meta, domain, re
245
261
  code,
246
262
  activeRuntimeHost,
247
263
  delegatesToSecureHost,
264
+ domain,
248
265
  effectiveRenderMode,
249
266
  hostAdapter,
250
267
  isIncomplete,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slexkit/streamdown",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Streamdown custom renderer for SlexKit fenced UI blocks.",
5
5
  "author": "SlexKit contributors",
6
6
  "type": "module",
@@ -47,7 +47,7 @@
47
47
  "access": "public"
48
48
  },
49
49
  "peerDependencies": {
50
- "slexkit": "^0.2.0",
50
+ "slexkit": "^0.3.0",
51
51
  "react": "^18.0.0 || ^19.0.0",
52
52
  "react-dom": "^18.0.0 || ^19.0.0",
53
53
  "streamdown": "^2.5.0"