@immediately-run/sdk 0.50.0 → 0.52.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 (77) hide show
  1. package/dist/analytics.cjs +47 -0
  2. package/dist/analytics.cjs.map +1 -0
  3. package/dist/analytics.d.cts +46 -0
  4. package/dist/analytics.d.ts +46 -0
  5. package/dist/analytics.js +21 -0
  6. package/dist/analytics.js.map +1 -0
  7. package/dist/corpus.cjs +91 -0
  8. package/dist/corpus.cjs.map +1 -0
  9. package/dist/corpus.d.cts +63 -0
  10. package/dist/corpus.d.ts +63 -0
  11. package/dist/corpus.js +62 -0
  12. package/dist/corpus.js.map +1 -0
  13. package/dist/generated/protocol.d.cts +1 -0
  14. package/dist/generated/protocol.d.ts +1 -0
  15. package/dist/index.cjs +4 -0
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +5 -6
  18. package/dist/index.d.ts +5 -6
  19. package/dist/index.js +2 -0
  20. package/dist/index.js.map +1 -1
  21. package/dist/linkSpace.cjs +4 -36
  22. package/dist/linkSpace.cjs.map +1 -1
  23. package/dist/linkSpace.d.cts +3 -60
  24. package/dist/linkSpace.d.ts +3 -60
  25. package/dist/linkSpace.js +1 -33
  26. package/dist/linkSpace.js.map +1 -1
  27. package/dist/protocolSchemes.cjs +1 -0
  28. package/dist/protocolSchemes.cjs.map +1 -1
  29. package/dist/protocolSchemes.d.cts +1 -0
  30. package/dist/protocolSchemes.d.ts +1 -0
  31. package/dist/protocolSchemes.js +2 -0
  32. package/dist/protocolSchemes.js.map +1 -1
  33. package/dist/safeContent/SafeContent.cjs +2 -27
  34. package/dist/safeContent/SafeContent.cjs.map +1 -1
  35. package/dist/safeContent/SafeContent.d.cts +1 -13
  36. package/dist/safeContent/SafeContent.d.ts +1 -13
  37. package/dist/safeContent/SafeContent.js +1 -26
  38. package/dist/safeContent/SafeContent.js.map +1 -1
  39. package/dist/safeContent/index.cjs +3 -23
  40. package/dist/safeContent/index.cjs.map +1 -1
  41. package/dist/safeContent/index.d.cts +1 -6
  42. package/dist/safeContent/index.d.ts +1 -6
  43. package/dist/safeContent/index.js +1 -14
  44. package/dist/safeContent/index.js.map +1 -1
  45. package/dist/safeContent/mdastDeps.cjs +7 -2
  46. package/dist/safeContent/mdastDeps.js +7 -2
  47. package/dist/safeContent/parseSafeMdast.cjs +2 -53
  48. package/dist/safeContent/parseSafeMdast.cjs.map +1 -1
  49. package/dist/safeContent/parseSafeMdast.d.cts +1 -45
  50. package/dist/safeContent/parseSafeMdast.d.ts +1 -45
  51. package/dist/safeContent/parseSafeMdast.js +1 -42
  52. package/dist/safeContent/parseSafeMdast.js.map +1 -1
  53. package/dist/safeContent/renderMdast.cjs +2 -133
  54. package/dist/safeContent/renderMdast.cjs.map +1 -1
  55. package/dist/safeContent/renderMdast.d.cts +1 -27
  56. package/dist/safeContent/renderMdast.d.ts +1 -27
  57. package/dist/safeContent/renderMdast.js +1 -132
  58. package/dist/safeContent/renderMdast.js.map +1 -1
  59. package/dist/safeContent/sanitizeUrl.cjs +2 -12
  60. package/dist/safeContent/sanitizeUrl.cjs.map +1 -1
  61. package/dist/safeContent/sanitizeUrl.d.cts +1 -9
  62. package/dist/safeContent/sanitizeUrl.d.ts +1 -9
  63. package/dist/safeContent/sanitizeUrl.js +1 -11
  64. package/dist/safeContent/sanitizeUrl.js.map +1 -1
  65. package/dist/safeContent/wikilink.cjs +3 -35
  66. package/dist/safeContent/wikilink.cjs.map +1 -1
  67. package/dist/safeContent/wikilink.d.cts +1 -21
  68. package/dist/safeContent/wikilink.d.ts +1 -21
  69. package/dist/safeContent/wikilink.js +1 -33
  70. package/dist/safeContent/wikilink.js.map +1 -1
  71. package/dist/version.cjs +1 -1
  72. package/dist/version.cjs.map +1 -1
  73. package/dist/version.d.cts +1 -1
  74. package/dist/version.d.ts +1 -1
  75. package/dist/version.js +1 -1
  76. package/dist/version.js.map +1 -1
  77. package/package.json +7 -5
@@ -1,27 +1 @@
1
- import { ReactNode } from 'react';
2
- import { SafeMdastNode } from './parseSafeMdast.cjs';
3
-
4
- interface SafeContentComponents {
5
- /** Safe components an app exposes to `<Component/>` syntax (host/app-provided).
6
- * Looked up by the JSX tag name; anything not here renders inert. */
7
- [tag: string]: React.ComponentType<Record<string, string>>;
8
- }
9
- interface RenderMdastOptions {
10
- /** The component registry for `<Component/>` syntax. Absent ⇒ all JSX tags inert. */
11
- components?: SafeContentComponents;
12
- /**
13
- * Resolve a wikilink target to an href, **within the granted mount only** — a pure,
14
- * synchronous, mount-scoped lookup that MUST NOT fetch or reach out of the mount.
15
- * Return `undefined` for an unresolvable/out-of-mount target (rendered as inert
16
- * text). Absent ⇒ every wikilink renders as inert text.
17
- */
18
- resolveWikiLink?: (target: string) => string | undefined;
19
- }
20
- /**
21
- * Render a safe-parsed mdast tree to React. Pure and synchronous; carries every §5.1
22
- * security property (registry-only JSX, dropped expressions, inert raw HTML, URL
23
- * sanitizing, in-mount wikilinks). Feed it a tree from {@link parseSafeMdast}.
24
- */
25
- declare function renderMdast(tree: SafeMdastNode, options?: RenderMdastOptions): ReactNode;
26
-
27
- export { type RenderMdastOptions, type SafeContentComponents, renderMdast };
1
+ export { RenderMdastOptions, SafeContentComponents, renderMdast } from '@immediately-run/safe-content';
@@ -1,27 +1 @@
1
- import { ReactNode } from 'react';
2
- import { SafeMdastNode } from './parseSafeMdast.js';
3
-
4
- interface SafeContentComponents {
5
- /** Safe components an app exposes to `<Component/>` syntax (host/app-provided).
6
- * Looked up by the JSX tag name; anything not here renders inert. */
7
- [tag: string]: React.ComponentType<Record<string, string>>;
8
- }
9
- interface RenderMdastOptions {
10
- /** The component registry for `<Component/>` syntax. Absent ⇒ all JSX tags inert. */
11
- components?: SafeContentComponents;
12
- /**
13
- * Resolve a wikilink target to an href, **within the granted mount only** — a pure,
14
- * synchronous, mount-scoped lookup that MUST NOT fetch or reach out of the mount.
15
- * Return `undefined` for an unresolvable/out-of-mount target (rendered as inert
16
- * text). Absent ⇒ every wikilink renders as inert text.
17
- */
18
- resolveWikiLink?: (target: string) => string | undefined;
19
- }
20
- /**
21
- * Render a safe-parsed mdast tree to React. Pure and synchronous; carries every §5.1
22
- * security property (registry-only JSX, dropped expressions, inert raw HTML, URL
23
- * sanitizing, in-mount wikilinks). Feed it a tree from {@link parseSafeMdast}.
24
- */
25
- declare function renderMdast(tree: SafeMdastNode, options?: RenderMdastOptions): ReactNode;
26
-
27
- export { type RenderMdastOptions, type SafeContentComponents, renderMdast };
1
+ export { RenderMdastOptions, SafeContentComponents, renderMdast } from '@immediately-run/safe-content';
@@ -1,136 +1,5 @@
1
1
  import "../chunk-VHAA22YE.js";
2
- import { createElement, Fragment } from "react";
3
- import { sanitizeUrl } from "./sanitizeUrl";
4
- import { splitWikiLinks } from "./wikilink";
5
- import { resolveLinkTarget } from "../linkSpace";
6
- function literalProps(attributes) {
7
- const props = {};
8
- for (const attr of attributes ?? []) {
9
- if (attr.type !== "mdxJsxAttribute") continue;
10
- if (typeof attr.name !== "string") continue;
11
- if (typeof attr.value === "string") props[attr.name] = attr.value;
12
- else if (attr.value === null || attr.value === void 0) props[attr.name] = "";
13
- }
14
- return props;
15
- }
16
- let keyCounter = 0;
17
- const nextKey = () => `sc-${keyCounter++}`;
18
- function elementFor(tag, components) {
19
- return components?.[tag] ?? tag;
20
- }
21
- function renderWiki(token, opts) {
22
- const label = token.label ?? token.target;
23
- if (resolveLinkTarget(token.target).state === "invalid") return label;
24
- const href = opts.resolveWikiLink?.(token.target);
25
- const safe = href !== void 0 ? sanitizeUrl(href) : void 0;
26
- if (safe === void 0) return label;
27
- return createElement(
28
- elementFor("a", opts.components),
29
- { href: safe, "data-wikilink": token.target, key: nextKey() },
30
- label
31
- );
32
- }
33
- function renderText(value, opts) {
34
- const parts = splitWikiLinks(value);
35
- if (!parts) return value;
36
- return parts.map(
37
- (p, i) => "text" in p ? createElement(Fragment, { key: `t${i}` }, p.text) : createElement(Fragment, { key: `w${i}` }, renderWiki(p.wiki, opts))
38
- );
39
- }
40
- function renderChildren(node, opts) {
41
- return (node.children ?? []).map((c, i) => renderNode(c, opts, i));
42
- }
43
- const HEADING_TAGS = ["h1", "h2", "h3", "h4", "h5", "h6"];
44
- function renderNode(node, opts, index = 0) {
45
- const key = `n${index}`;
46
- switch (node.type) {
47
- case "root":
48
- return createElement(Fragment, { key }, ...renderChildren(node, opts));
49
- case "text":
50
- return renderText(node.value ?? "", opts);
51
- case "paragraph":
52
- return createElement("p", { key }, ...renderChildren(node, opts));
53
- case "heading": {
54
- const tag = HEADING_TAGS[Math.min(Math.max((node.depth ?? 1) - 1, 0), 5)];
55
- const hp = node.data?.hProperties;
56
- const headingProps = {};
57
- if (typeof hp?.id === "string") headingProps.id = hp.id;
58
- if (typeof hp?.["data-slug"] === "string") headingProps["data-slug"] = hp["data-slug"];
59
- return createElement(tag, { key, ...headingProps }, ...renderChildren(node, opts));
60
- }
61
- case "strong":
62
- return createElement("strong", { key }, ...renderChildren(node, opts));
63
- case "emphasis":
64
- return createElement("em", { key }, ...renderChildren(node, opts));
65
- case "delete":
66
- return createElement("del", { key }, ...renderChildren(node, opts));
67
- case "inlineCode":
68
- return createElement("code", { key }, node.value ?? "");
69
- case "code":
70
- return createElement("pre", { key }, createElement("code", null, node.value ?? ""));
71
- case "blockquote":
72
- return createElement("blockquote", { key }, ...renderChildren(node, opts));
73
- case "list":
74
- return createElement(node.ordered ? "ol" : "ul", { key }, ...renderChildren(node, opts));
75
- case "listItem":
76
- return createElement("li", { key }, ...renderChildren(node, opts));
77
- case "thematicBreak":
78
- return createElement("hr", { key });
79
- case "break":
80
- return createElement("br", { key });
81
- case "link": {
82
- const href = sanitizeUrl(node.url);
83
- if (href === void 0) return createElement(Fragment, { key }, ...renderChildren(node, opts));
84
- return createElement(
85
- elementFor("a", opts.components),
86
- { key, href, title: node.title ?? void 0 },
87
- ...renderChildren(node, opts)
88
- );
89
- }
90
- case "image": {
91
- const src = sanitizeUrl(node.url);
92
- if (src === void 0) return node.alt ? createElement(Fragment, { key }, node.alt) : null;
93
- return createElement(elementFor("img", opts.components), {
94
- key,
95
- src,
96
- alt: node.alt ?? "",
97
- title: node.title ?? void 0
98
- });
99
- }
100
- // GFM tables.
101
- case "table":
102
- return createElement("table", { key }, createElement("tbody", null, ...renderChildren(node, opts)));
103
- case "tableRow":
104
- return createElement("tr", { key }, ...renderChildren(node, opts));
105
- case "tableCell":
106
- return createElement("td", { key }, ...renderChildren(node, opts));
107
- // Raw HTML (`<script>`, `<div onclick>` at block level) → INERT TEXT. No
108
- // `rehype-raw`, never `dangerouslySetInnerHTML`. The literal markup is shown, not run.
109
- case "html":
110
- return createElement(Fragment, { key }, node.value ?? "");
111
- // JSX `<Component/>` syntax → registry lookup by NAME, literal props only.
112
- case "mdxJsxFlowElement":
113
- case "mdxJsxTextElement": {
114
- const name = typeof node.name === "string" ? node.name : "";
115
- const Component = name ? opts.components?.[name] : void 0;
116
- const children = renderChildren(node, opts);
117
- if (!Component) return createElement(Fragment, { key }, ...children);
118
- return createElement(Component, { key, ...literalProps(node.attributes) }, ...children);
119
- }
120
- // Inert expression nodes (should not occur — expression extension is off — but be
121
- // defensive if a tree from elsewhere carries them): render nothing.
122
- case "mdxFlowExpression":
123
- case "mdxTextExpression":
124
- case "mdxjsEsm":
125
- return null;
126
- default:
127
- return node.children ? createElement(Fragment, { key }, ...renderChildren(node, opts)) : null;
128
- }
129
- }
130
- function renderMdast(tree, options = {}) {
131
- keyCounter = 0;
132
- return renderNode(tree, options);
133
- }
2
+ import { renderMdast } from "@immediately-run/safe-content";
134
3
  export {
135
4
  renderMdast
136
5
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/safeContent/renderMdast.tsx"],"sourcesContent":["import { createElement, Fragment, type ReactNode } from 'react';\nimport { sanitizeUrl } from './sanitizeUrl';\nimport { splitWikiLinks, type WikiLinkToken } from './wikilink';\nimport { resolveLinkTarget } from '../linkSpace';\nimport type { SafeMdastNode, SafeMdxAttribute } from './parseSafeMdast';\n\n// The mdast→React renderer for the safe content path (TRUST_MODES_SPEC §5.1). PURE\n// and synchronous — it only reads `node.type` off an already-parsed tree, so it\n// carries no ESM dep and is exhaustively unit-testable. Every security property lives\n// here:\n//\n// - **JSX tags resolve ONLY to a component registry, by name.** A `<Component/>`\n// node becomes `registry[name]` with **literal string props only**; an unknown tag\n// renders its children inert (a Fragment, no element) — so author-written `<div\n// onclick=…>`, `<img onerror=…>`, `<script>` never become an intrinsic element with\n// attacker attributes. (Block-level raw HTML arrives as an `html` node, below.)\n// - **Expression attributes are dropped.** `f={fetch(\"/x\")}` / `{...spread}` are\n// `mdxJsxExpressionAttribute` or object-valued `mdxJsxAttribute`s — never passed to\n// a component, never evaluated. (There is also no evaluator to reach — parse used\n// no acorn.)\n// - **Raw HTML is inert text.** `html` nodes render as their literal string via a\n// text node — never `dangerouslySetInnerHTML` (no `rehype-raw`).\n// - **URL-scheme sanitizer** on every `link`/`image` URL (`sanitizeUrl`).\n// - **Wikilinks resolve in-mount only** via an injected resolver; the renderer never\n// fetches.\n\nexport interface SafeContentComponents {\n /** Safe components an app exposes to `<Component/>` syntax (host/app-provided).\n * Looked up by the JSX tag name; anything not here renders inert. */\n [tag: string]: React.ComponentType<Record<string, string>>;\n}\n\nexport interface RenderMdastOptions {\n /** The component registry for `<Component/>` syntax. Absent ⇒ all JSX tags inert. */\n components?: SafeContentComponents;\n /**\n * Resolve a wikilink target to an href, **within the granted mount only** — a pure,\n * synchronous, mount-scoped lookup that MUST NOT fetch or reach out of the mount.\n * Return `undefined` for an unresolvable/out-of-mount target (rendered as inert\n * text). Absent ⇒ every wikilink renders as inert text.\n */\n resolveWikiLink?: (target: string) => string | undefined;\n}\n\n/** Extract the literal string props of a JSX element — `mdxJsxAttribute`s whose value\n * is a plain string. Expression attributes (object value) and spreads are DROPPED. */\nfunction literalProps(attributes: SafeMdxAttribute[] | undefined): Record<string, string> {\n const props: Record<string, string> = {};\n for (const attr of attributes ?? []) {\n if (attr.type !== 'mdxJsxAttribute') continue; // drop `{...spread}`\n if (typeof attr.name !== 'string') continue;\n // A literal attribute's value is a string (or null → boolean-ish `true`). An\n // expression value is an object (`mdxJsxAttributeValueExpression`) — DROP it: it\n // is an inert raw string, never a real value, and must never reach a component.\n if (typeof attr.value === 'string') props[attr.name] = attr.value;\n else if (attr.value === null || attr.value === undefined) props[attr.name] = '';\n // object-valued (expression) → skipped\n }\n return props;\n}\n\nlet keyCounter = 0;\nconst nextKey = () => `sc-${keyCounter++}`;\n\n/**\n * The element to build for a link/image: the host's registered override when it has one,\n * else the intrinsic tag.\n *\n * **Why this is safe.** `components` is the HOST's registry — the same one `<Component/>`\n * syntax resolves against — never author input. An author cannot add to it or choose one\n * here, because the lookup is by a FIXED key (`'a'`/`'img'`), not by anything read out of\n * the document. The URL is still `sanitizeUrl`'d before it is handed over, and only props\n * this renderer controls are passed. The trust boundary is unchanged: author text still\n * reaches nothing but children and a sanitized URL.\n *\n * **Why it is needed.** Without it, a safe-rendered document's links are raw `<a href>`,\n * so a click performs a REAL navigation. Inside an app's sandboxed iframe that is fatal —\n * the frame navigates away from the app, and in a routed host app it dies with\n * `Failed to construct 'URL': Invalid URL`. Hosts route links through a component for\n * exactly this reason, and the compiled-MDX path has always honoured that component; the\n * safe path silently ignored it, so one document behaved differently on the two renderers.\n */\nfunction elementFor(tag: 'a' | 'img', components: RenderMdastOptions['components']): React.ElementType {\n return (components?.[tag] as React.ElementType) ?? tag;\n}\n\n/** Render a wikilink token via the in-mount resolver, or inert text when it can't\n * resolve (never a network call — resolution is the injected mount-scoped callback). */\nfunction renderWiki(token: WikiLinkToken, opts: RenderMdastOptions): ReactNode {\n const label = token.label ?? token.target;\n // R3-273: a malformed `$fs:` target (not mount-absolute — catches scheme\n // smuggling) is inert BEFORE the injected resolver ever sees it, so every\n // consumer fails closed identically. Consumers implement their resolver on the\n // same shared `resolveLinkTarget` for well-formed targets.\n if (resolveLinkTarget(token.target).state === 'invalid') return label;\n const href = opts.resolveWikiLink?.(token.target);\n const safe = href !== undefined ? sanitizeUrl(href) : undefined;\n if (safe === undefined) return label; // inert text — unresolved or out-of-mount\n return createElement(\n elementFor('a', opts.components),\n { href: safe, 'data-wikilink': token.target, key: nextKey() },\n label,\n );\n}\n\n/** Render a `text` node, splitting any `[[…]]` wikilinks out of it. */\nfunction renderText(value: string, opts: RenderMdastOptions): ReactNode {\n const parts = splitWikiLinks(value);\n if (!parts) return value;\n return parts.map((p, i) =>\n 'text' in p\n ? createElement(Fragment, { key: `t${i}` }, p.text)\n : createElement(Fragment, { key: `w${i}` }, renderWiki(p.wiki, opts)),\n );\n}\n\nfunction renderChildren(node: SafeMdastNode, opts: RenderMdastOptions): ReactNode[] {\n return (node.children ?? []).map((c, i) => renderNode(c, opts, i));\n}\n\n// Standard mdast block/inline nodes → a FIXED, safe React element. We control every\n// attribute; author input only reaches text content and (sanitized) URLs.\nconst HEADING_TAGS = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] as const;\n\nfunction renderNode(node: SafeMdastNode, opts: RenderMdastOptions, index = 0): ReactNode {\n const key = `n${index}`;\n switch (node.type) {\n case 'root':\n return createElement(Fragment, { key }, ...renderChildren(node, opts));\n case 'text':\n return renderText(node.value ?? '', opts);\n case 'paragraph':\n return createElement('p', { key }, ...renderChildren(node, opts));\n case 'heading': {\n const tag = HEADING_TAGS[Math.min(Math.max((node.depth ?? 1) - 1, 0), 5)];\n // R3-213: the no-acorn path has no hast stage, so the heading id the shared\n // `remarkHeadingAnchors` plugin sets via `data.hProperties.id` (+ the `data-slug`\n // fallback, R3-211) must be translated to React props HERE, or headings render\n // id-less and deep-linking (`#sec-8-9`) breaks in the safe path. These are\n // plugin-computed literal strings, not author input — safe to pass through.\n const hp = (node.data as { hProperties?: Record<string, unknown> } | undefined)?.hProperties;\n const headingProps: Record<string, string> = {};\n if (typeof hp?.id === 'string') headingProps.id = hp.id;\n if (typeof hp?.['data-slug'] === 'string') headingProps['data-slug'] = hp['data-slug'];\n return createElement(tag, { key, ...headingProps }, ...renderChildren(node, opts));\n }\n case 'strong':\n return createElement('strong', { key }, ...renderChildren(node, opts));\n case 'emphasis':\n return createElement('em', { key }, ...renderChildren(node, opts));\n case 'delete':\n return createElement('del', { key }, ...renderChildren(node, opts));\n case 'inlineCode':\n return createElement('code', { key }, node.value ?? '');\n case 'code':\n return createElement('pre', { key }, createElement('code', null, node.value ?? ''));\n case 'blockquote':\n return createElement('blockquote', { key }, ...renderChildren(node, opts));\n case 'list':\n return createElement(node.ordered ? 'ol' : 'ul', { key }, ...renderChildren(node, opts));\n case 'listItem':\n return createElement('li', { key }, ...renderChildren(node, opts));\n case 'thematicBreak':\n return createElement('hr', { key });\n case 'break':\n return createElement('br', { key });\n case 'link': {\n const href = sanitizeUrl(node.url);\n // A rejected scheme → render the link TEXT only (inert), never an <a href>.\n if (href === undefined) return createElement(Fragment, { key }, ...renderChildren(node, opts));\n return createElement(\n elementFor('a', opts.components),\n { key, href, title: node.title ?? undefined },\n ...renderChildren(node, opts),\n );\n }\n case 'image': {\n const src = sanitizeUrl(node.url);\n if (src === undefined) return node.alt ? createElement(Fragment, { key }, node.alt) : null;\n return createElement(elementFor('img', opts.components), {\n key,\n src,\n alt: node.alt ?? '',\n title: node.title ?? undefined,\n });\n }\n // GFM tables.\n case 'table':\n return createElement('table', { key }, createElement('tbody', null, ...renderChildren(node, opts)));\n case 'tableRow':\n return createElement('tr', { key }, ...renderChildren(node, opts));\n case 'tableCell':\n return createElement('td', { key }, ...renderChildren(node, opts));\n // Raw HTML (`<script>`, `<div onclick>` at block level) → INERT TEXT. No\n // `rehype-raw`, never `dangerouslySetInnerHTML`. The literal markup is shown, not run.\n case 'html':\n return createElement(Fragment, { key }, node.value ?? '');\n // JSX `<Component/>` syntax → registry lookup by NAME, literal props only.\n case 'mdxJsxFlowElement':\n case 'mdxJsxTextElement': {\n const name = typeof node.name === 'string' ? node.name : '';\n const Component = name ? opts.components?.[name] : undefined;\n const children = renderChildren(node, opts);\n // Unknown tag (not in the registry) OR a fragment `<>` → render children inert,\n // NO element, NO author attributes. This is what neutralizes `<script>`/`<div\n // onclick>`/`<img onerror>` written as JSX.\n if (!Component) return createElement(Fragment, { key }, ...children);\n return createElement(Component, { key, ...literalProps(node.attributes) }, ...children);\n }\n // Inert expression nodes (should not occur — expression extension is off — but be\n // defensive if a tree from elsewhere carries them): render nothing.\n case 'mdxFlowExpression':\n case 'mdxTextExpression':\n case 'mdxjsEsm':\n return null;\n default:\n // Unknown node → render its children (never its raw value as markup).\n return node.children ? createElement(Fragment, { key }, ...renderChildren(node, opts)) : null;\n }\n}\n\n/**\n * Render a safe-parsed mdast tree to React. Pure and synchronous; carries every §5.1\n * security property (registry-only JSX, dropped expressions, inert raw HTML, URL\n * sanitizing, in-mount wikilinks). Feed it a tree from {@link parseSafeMdast}.\n */\nexport function renderMdast(tree: SafeMdastNode, options: RenderMdastOptions = {}): ReactNode {\n keyCounter = 0;\n return renderNode(tree, options);\n}\n"],"mappings":";AAAA,SAAS,eAAe,gBAAgC;AACxD,SAAS,mBAAmB;AAC5B,SAAS,sBAA0C;AACnD,SAAS,yBAAyB;AA2ClC,SAAS,aAAa,YAAoE;AACxF,QAAM,QAAgC,CAAC;AACvC,aAAW,QAAQ,cAAc,CAAC,GAAG;AACnC,QAAI,KAAK,SAAS,kBAAmB;AACrC,QAAI,OAAO,KAAK,SAAS,SAAU;AAInC,QAAI,OAAO,KAAK,UAAU,SAAU,OAAM,KAAK,IAAI,IAAI,KAAK;AAAA,aACnD,KAAK,UAAU,QAAQ,KAAK,UAAU,OAAW,OAAM,KAAK,IAAI,IAAI;AAAA,EAE/E;AACA,SAAO;AACT;AAEA,IAAI,aAAa;AACjB,MAAM,UAAU,MAAM,MAAM,YAAY;AAoBxC,SAAS,WAAW,KAAkB,YAAiE;AACrG,SAAQ,aAAa,GAAG,KAA2B;AACrD;AAIA,SAAS,WAAW,OAAsB,MAAqC;AAC7E,QAAM,QAAQ,MAAM,SAAS,MAAM;AAKnC,MAAI,kBAAkB,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WAAW,EAAE,KAAK,GAAG,aAAa,KAAK,UAAU,EAAE,GAAG,GAAG,QAAQ;AAAA,IACxF;AAAA;AAAA;AAAA,IAGA,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT;AAEE,aAAO,KAAK,WAAW,cAAc,UAAU,EAAE,IAAI,GAAG,GAAG,eAAe,MAAM,IAAI,CAAC,IAAI;AAAA,EAC7F;AACF;AAOO,SAAS,YAAY,MAAqB,UAA8B,CAAC,GAAc;AAC5F,eAAa;AACb,SAAO,WAAW,MAAM,OAAO;AACjC;","names":[]}
1
+ {"version":3,"sources":["../../src/safeContent/renderMdast.tsx"],"sourcesContent":["// R3-279 (phase 3): re-export shim — the implementation lives in\n// `@immediately-run/safe-content`; this subpath keeps working byte-compatibly.\nexport { renderMdast } from '@immediately-run/safe-content';\nexport type { RenderMdastOptions, SafeContentComponents } from '@immediately-run/safe-content';\n"],"mappings":";AAEA,SAAS,mBAAmB;","names":[]}
@@ -18,20 +18,10 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var sanitizeUrl_exports = {};
20
20
  __export(sanitizeUrl_exports, {
21
- sanitizeUrl: () => sanitizeUrl
21
+ sanitizeUrl: () => import_safe_content.sanitizeUrl
22
22
  });
23
23
  module.exports = __toCommonJS(sanitizeUrl_exports);
24
- const SCHEME = /^([a-zA-Z][a-zA-Z0-9+.-]*):/;
25
- const ALLOWED_SCHEMES = /* @__PURE__ */ new Set(["http", "https", "mailto"]);
26
- const CONTROL_CHARS = /[\u0000-\u001F\u007F]/g;
27
- function sanitizeUrl(url) {
28
- if (typeof url !== "string") return void 0;
29
- const cleaned = url.replace(CONTROL_CHARS, "").trim();
30
- if (cleaned === "") return void 0;
31
- const m = SCHEME.exec(cleaned);
32
- if (!m) return cleaned;
33
- return ALLOWED_SCHEMES.has(m[1].toLowerCase()) ? cleaned : void 0;
34
- }
24
+ var import_safe_content = require("@immediately-run/safe-content");
35
25
  // Annotate the CommonJS export names for ESM import in node:
36
26
  0 && (module.exports = {
37
27
  sanitizeUrl
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/safeContent/sanitizeUrl.ts"],"sourcesContent":["// URL-scheme sanitizer for the safe content renderer (TRUST_MODES_SPEC §5.1,\n// AGENT_AUTHORING §10). A §5.1 residual requirement: link/image URLs in untrusted\n// content are allowlisted to `http`/`https`/`mailto` and relative URLs; every other\n// scheme — `javascript:`, `data:`, `vbscript:`, `file:`, … — is rejected. We do NOT\n// rely on React to neutralize `javascript:` (it does not, on an `<a href>`), so this\n// is the single chokepoint every rendered `href`/`src` passes through.\n\n// A leading `scheme:` per RFC 3986 (`ALPHA *( ALPHA / DIGIT / \"+\" / \"-\" / \".\" )`).\n// Anything before the first `:` that matches this is an absolute-URI scheme; if the\n// URL has no such prefix it is relative (path/query/fragment) and allowed.\nconst SCHEME = /^([a-zA-Z][a-zA-Z0-9+.-]*):/;\nconst ALLOWED_SCHEMES = new Set(['http', 'https', 'mailto']);\n\n// ASCII control chars (0x00–0x1F, 0x7F) that browsers ignore INSIDE a scheme — the\n// `java\\tscript:` / `java\\nscript:` obfuscation — stripped anywhere before testing.\n// eslint-disable-next-line no-control-regex\nconst CONTROL_CHARS = /[\\u0000-\\u001F\\u007F]/g;\n\n/**\n * Return the URL if its scheme is allowed (or it is relative/anchor), else\n * `undefined`. Control chars are stripped first so an obfuscated scheme cannot slip\n * past. A protocol-relative `//host` URL is treated as relative-with-authority and\n * allowed (it inherits the page's https scheme).\n */\nexport function sanitizeUrl(url: unknown): string | undefined {\n if (typeof url !== 'string') return undefined;\n const cleaned = url.replace(CONTROL_CHARS, '').trim();\n if (cleaned === '') return undefined;\n const m = SCHEME.exec(cleaned);\n if (!m) return cleaned; // no scheme → relative / anchor / query — allowed\n return ALLOWED_SCHEMES.has(m[1].toLowerCase()) ? cleaned : undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,MAAM,SAAS;AACf,MAAM,kBAAkB,oBAAI,IAAI,CAAC,QAAQ,SAAS,QAAQ,CAAC;AAK3D,MAAM,gBAAgB;AAQf,SAAS,YAAY,KAAkC;AAC5D,MAAI,OAAO,QAAQ,SAAU,QAAO;AACpC,QAAM,UAAU,IAAI,QAAQ,eAAe,EAAE,EAAE,KAAK;AACpD,MAAI,YAAY,GAAI,QAAO;AAC3B,QAAM,IAAI,OAAO,KAAK,OAAO;AAC7B,MAAI,CAAC,EAAG,QAAO;AACf,SAAO,gBAAgB,IAAI,EAAE,CAAC,EAAE,YAAY,CAAC,IAAI,UAAU;AAC7D;","names":[]}
1
+ {"version":3,"sources":["../../src/safeContent/sanitizeUrl.ts"],"sourcesContent":["// R3-279 (phase 3): re-export shim — the implementation lives in\n// `@immediately-run/safe-content`; this subpath keeps working byte-compatibly.\nexport { sanitizeUrl } from '@immediately-run/safe-content';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,0BAA4B;","names":[]}
@@ -1,9 +1 @@
1
- /**
2
- * Return the URL if its scheme is allowed (or it is relative/anchor), else
3
- * `undefined`. Control chars are stripped first so an obfuscated scheme cannot slip
4
- * past. A protocol-relative `//host` URL is treated as relative-with-authority and
5
- * allowed (it inherits the page's https scheme).
6
- */
7
- declare function sanitizeUrl(url: unknown): string | undefined;
8
-
9
- export { sanitizeUrl };
1
+ export { sanitizeUrl } from '@immediately-run/safe-content';
@@ -1,9 +1 @@
1
- /**
2
- * Return the URL if its scheme is allowed (or it is relative/anchor), else
3
- * `undefined`. Control chars are stripped first so an obfuscated scheme cannot slip
4
- * past. A protocol-relative `//host` URL is treated as relative-with-authority and
5
- * allowed (it inherits the page's https scheme).
6
- */
7
- declare function sanitizeUrl(url: unknown): string | undefined;
8
-
9
- export { sanitizeUrl };
1
+ export { sanitizeUrl } from '@immediately-run/safe-content';
@@ -1,15 +1,5 @@
1
1
  import "../chunk-VHAA22YE.js";
2
- const SCHEME = /^([a-zA-Z][a-zA-Z0-9+.-]*):/;
3
- const ALLOWED_SCHEMES = /* @__PURE__ */ new Set(["http", "https", "mailto"]);
4
- const CONTROL_CHARS = /[\u0000-\u001F\u007F]/g;
5
- function sanitizeUrl(url) {
6
- if (typeof url !== "string") return void 0;
7
- const cleaned = url.replace(CONTROL_CHARS, "").trim();
8
- if (cleaned === "") return void 0;
9
- const m = SCHEME.exec(cleaned);
10
- if (!m) return cleaned;
11
- return ALLOWED_SCHEMES.has(m[1].toLowerCase()) ? cleaned : void 0;
12
- }
2
+ import { sanitizeUrl } from "@immediately-run/safe-content";
13
3
  export {
14
4
  sanitizeUrl
15
5
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/safeContent/sanitizeUrl.ts"],"sourcesContent":["// URL-scheme sanitizer for the safe content renderer (TRUST_MODES_SPEC §5.1,\n// AGENT_AUTHORING §10). A §5.1 residual requirement: link/image URLs in untrusted\n// content are allowlisted to `http`/`https`/`mailto` and relative URLs; every other\n// scheme — `javascript:`, `data:`, `vbscript:`, `file:`, … — is rejected. We do NOT\n// rely on React to neutralize `javascript:` (it does not, on an `<a href>`), so this\n// is the single chokepoint every rendered `href`/`src` passes through.\n\n// A leading `scheme:` per RFC 3986 (`ALPHA *( ALPHA / DIGIT / \"+\" / \"-\" / \".\" )`).\n// Anything before the first `:` that matches this is an absolute-URI scheme; if the\n// URL has no such prefix it is relative (path/query/fragment) and allowed.\nconst SCHEME = /^([a-zA-Z][a-zA-Z0-9+.-]*):/;\nconst ALLOWED_SCHEMES = new Set(['http', 'https', 'mailto']);\n\n// ASCII control chars (0x00–0x1F, 0x7F) that browsers ignore INSIDE a scheme — the\n// `java\\tscript:` / `java\\nscript:` obfuscation — stripped anywhere before testing.\n// eslint-disable-next-line no-control-regex\nconst CONTROL_CHARS = /[\\u0000-\\u001F\\u007F]/g;\n\n/**\n * Return the URL if its scheme is allowed (or it is relative/anchor), else\n * `undefined`. Control chars are stripped first so an obfuscated scheme cannot slip\n * past. A protocol-relative `//host` URL is treated as relative-with-authority and\n * allowed (it inherits the page's https scheme).\n */\nexport function sanitizeUrl(url: unknown): string | undefined {\n if (typeof url !== 'string') return undefined;\n const cleaned = url.replace(CONTROL_CHARS, '').trim();\n if (cleaned === '') return undefined;\n const m = SCHEME.exec(cleaned);\n if (!m) return cleaned; // no scheme → relative / anchor / query — allowed\n return ALLOWED_SCHEMES.has(m[1].toLowerCase()) ? cleaned : undefined;\n}\n"],"mappings":";AAUA,MAAM,SAAS;AACf,MAAM,kBAAkB,oBAAI,IAAI,CAAC,QAAQ,SAAS,QAAQ,CAAC;AAK3D,MAAM,gBAAgB;AAQf,SAAS,YAAY,KAAkC;AAC5D,MAAI,OAAO,QAAQ,SAAU,QAAO;AACpC,QAAM,UAAU,IAAI,QAAQ,eAAe,EAAE,EAAE,KAAK;AACpD,MAAI,YAAY,GAAI,QAAO;AAC3B,QAAM,IAAI,OAAO,KAAK,OAAO;AAC7B,MAAI,CAAC,EAAG,QAAO;AACf,SAAO,gBAAgB,IAAI,EAAE,CAAC,EAAE,YAAY,CAAC,IAAI,UAAU;AAC7D;","names":[]}
1
+ {"version":3,"sources":["../../src/safeContent/sanitizeUrl.ts"],"sourcesContent":["// R3-279 (phase 3): re-export shim — the implementation lives in\n// `@immediately-run/safe-content`; this subpath keeps working byte-compatibly.\nexport { sanitizeUrl } from '@immediately-run/safe-content';\n"],"mappings":";AAEA,SAAS,mBAAmB;","names":[]}
@@ -18,43 +18,11 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var wikilink_exports = {};
20
20
  __export(wikilink_exports, {
21
- parseWikiInner: () => parseWikiInner,
22
- splitWikiLinks: () => splitWikiLinks
21
+ parseWikiInner: () => import_safe_content.parseWikiInner,
22
+ splitWikiLinks: () => import_safe_content.splitWikiLinks
23
23
  });
24
24
  module.exports = __toCommonJS(wikilink_exports);
25
- const WIKILINK = /\[\[([^[\]]+)\]\]/g;
26
- function parseWikiInner(inner) {
27
- const pipe = inner.indexOf("|");
28
- let target;
29
- let label;
30
- if (pipe === -1) {
31
- target = inner.trim();
32
- } else {
33
- label = inner.slice(0, pipe).trim();
34
- target = inner.slice(pipe + 1).trim();
35
- }
36
- if (target === "") return null;
37
- return label ? { target, label } : { target };
38
- }
39
- function splitWikiLinks(value) {
40
- if (value.indexOf("[[") === -1) return null;
41
- const out = [];
42
- let lastIndex = 0;
43
- let produced = false;
44
- WIKILINK.lastIndex = 0;
45
- let match;
46
- while ((match = WIKILINK.exec(value)) !== null) {
47
- const token = parseWikiInner(match[1]);
48
- if (!token) continue;
49
- if (match.index > lastIndex) out.push({ text: value.slice(lastIndex, match.index) });
50
- out.push({ wiki: token });
51
- lastIndex = match.index + match[0].length;
52
- produced = true;
53
- }
54
- if (!produced) return null;
55
- if (lastIndex < value.length) out.push({ text: value.slice(lastIndex) });
56
- return out;
57
- }
25
+ var import_safe_content = require("@immediately-run/safe-content");
58
26
  // Annotate the CommonJS export names for ESM import in node:
59
27
  0 && (module.exports = {
60
28
  parseWikiInner,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/safeContent/wikilink.ts"],"sourcesContent":["// Wikilink parsing for the safe content renderer (TRUST_MODES_SPEC §5.1). A §5.1\n// residual: wikilinks resolve **only within the granted mount, never a fetch**. The\n// kernel's executable pipeline compiles `[[target]]`/`[[label|target]]` to a\n// `<WikiLink>` component (transpiler `remarkWikiLinks`, MARKDOWN_SYNTAX_SPEC §13); the\n// SAFE renderer parses raw source, so it splits `[[…]]` out of text itself with the\n// same byte-local rule and hands the raw target/label to an injected, **in-mount**\n// resolver. The renderer never fetches; resolution is the consumer's mount-scoped\n// callback (or, absent one, the link renders as inert text).\n\n// Inner content up to the closing `]]`, forbidding `[`/`]` so nested brackets can't\n// be swallowed. Global — a text run may hold several.\nconst WIKILINK = /\\[\\[([^[\\]]+)\\]\\]/g;\n\nexport interface WikiLinkToken {\n /** The raw target path, verbatim (relative or absolute; resolved in-mount only). */\n target: string;\n /** The explicit label, or undefined (the component derives one). */\n label?: string;\n}\n\nexport type WikiPart = { text: string } | { wiki: WikiLinkToken };\n\n/** Parse the `[[label|target]]` / `[[target]]` inner text (label first, then target\n * — the §13.1 order), or `null` for an empty target (leave the literal `[[…]]`). */\nexport function parseWikiInner(inner: string): WikiLinkToken | null {\n const pipe = inner.indexOf('|');\n let target: string;\n let label: string | undefined;\n if (pipe === -1) {\n target = inner.trim();\n } else {\n label = inner.slice(0, pipe).trim();\n target = inner.slice(pipe + 1).trim();\n }\n if (target === '') return null;\n return label ? { target, label } : { target };\n}\n\n/**\n * Split a text string on its `[[…]]` runs into ordered text / wiki parts, or `null`\n * when there is no usable wiki-link (so the caller keeps the text node untouched).\n */\nexport function splitWikiLinks(value: string): WikiPart[] | null {\n if (value.indexOf('[[') === -1) return null;\n const out: WikiPart[] = [];\n let lastIndex = 0;\n let produced = false;\n WIKILINK.lastIndex = 0;\n let match: RegExpExecArray | null;\n while ((match = WIKILINK.exec(value)) !== null) {\n const token = parseWikiInner(match[1]);\n if (!token) continue; // empty target → keep the literal `[[…]]`\n if (match.index > lastIndex) out.push({ text: value.slice(lastIndex, match.index) });\n out.push({ wiki: token });\n lastIndex = match.index + match[0].length;\n produced = true;\n }\n if (!produced) return null;\n if (lastIndex < value.length) out.push({ text: value.slice(lastIndex) });\n return out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,MAAM,WAAW;AAaV,SAAS,eAAe,OAAqC;AAClE,QAAM,OAAO,MAAM,QAAQ,GAAG;AAC9B,MAAI;AACJ,MAAI;AACJ,MAAI,SAAS,IAAI;AACf,aAAS,MAAM,KAAK;AAAA,EACtB,OAAO;AACL,YAAQ,MAAM,MAAM,GAAG,IAAI,EAAE,KAAK;AAClC,aAAS,MAAM,MAAM,OAAO,CAAC,EAAE,KAAK;AAAA,EACtC;AACA,MAAI,WAAW,GAAI,QAAO;AAC1B,SAAO,QAAQ,EAAE,QAAQ,MAAM,IAAI,EAAE,OAAO;AAC9C;AAMO,SAAS,eAAe,OAAkC;AAC/D,MAAI,MAAM,QAAQ,IAAI,MAAM,GAAI,QAAO;AACvC,QAAM,MAAkB,CAAC;AACzB,MAAI,YAAY;AAChB,MAAI,WAAW;AACf,WAAS,YAAY;AACrB,MAAI;AACJ,UAAQ,QAAQ,SAAS,KAAK,KAAK,OAAO,MAAM;AAC9C,UAAM,QAAQ,eAAe,MAAM,CAAC,CAAC;AACrC,QAAI,CAAC,MAAO;AACZ,QAAI,MAAM,QAAQ,UAAW,KAAI,KAAK,EAAE,MAAM,MAAM,MAAM,WAAW,MAAM,KAAK,EAAE,CAAC;AACnF,QAAI,KAAK,EAAE,MAAM,MAAM,CAAC;AACxB,gBAAY,MAAM,QAAQ,MAAM,CAAC,EAAE;AACnC,eAAW;AAAA,EACb;AACA,MAAI,CAAC,SAAU,QAAO;AACtB,MAAI,YAAY,MAAM,OAAQ,KAAI,KAAK,EAAE,MAAM,MAAM,MAAM,SAAS,EAAE,CAAC;AACvE,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/safeContent/wikilink.ts"],"sourcesContent":["// R3-279 (phase 3): re-export shim — the implementation lives in\n// `@immediately-run/safe-content`; this subpath keeps working byte-compatibly.\nexport { splitWikiLinks, parseWikiInner } from '@immediately-run/safe-content';\nexport type { WikiLinkToken, WikiPart } from '@immediately-run/safe-content';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,0BAA+C;","names":[]}
@@ -1,21 +1 @@
1
- interface WikiLinkToken {
2
- /** The raw target path, verbatim (relative or absolute; resolved in-mount only). */
3
- target: string;
4
- /** The explicit label, or undefined (the component derives one). */
5
- label?: string;
6
- }
7
- type WikiPart = {
8
- text: string;
9
- } | {
10
- wiki: WikiLinkToken;
11
- };
12
- /** Parse the `[[label|target]]` / `[[target]]` inner text (label first, then target
13
- * — the §13.1 order), or `null` for an empty target (leave the literal `[[…]]`). */
14
- declare function parseWikiInner(inner: string): WikiLinkToken | null;
15
- /**
16
- * Split a text string on its `[[…]]` runs into ordered text / wiki parts, or `null`
17
- * when there is no usable wiki-link (so the caller keeps the text node untouched).
18
- */
19
- declare function splitWikiLinks(value: string): WikiPart[] | null;
20
-
21
- export { type WikiLinkToken, type WikiPart, parseWikiInner, splitWikiLinks };
1
+ export { WikiLinkToken, WikiPart, parseWikiInner, splitWikiLinks } from '@immediately-run/safe-content';
@@ -1,21 +1 @@
1
- interface WikiLinkToken {
2
- /** The raw target path, verbatim (relative or absolute; resolved in-mount only). */
3
- target: string;
4
- /** The explicit label, or undefined (the component derives one). */
5
- label?: string;
6
- }
7
- type WikiPart = {
8
- text: string;
9
- } | {
10
- wiki: WikiLinkToken;
11
- };
12
- /** Parse the `[[label|target]]` / `[[target]]` inner text (label first, then target
13
- * — the §13.1 order), or `null` for an empty target (leave the literal `[[…]]`). */
14
- declare function parseWikiInner(inner: string): WikiLinkToken | null;
15
- /**
16
- * Split a text string on its `[[…]]` runs into ordered text / wiki parts, or `null`
17
- * when there is no usable wiki-link (so the caller keeps the text node untouched).
18
- */
19
- declare function splitWikiLinks(value: string): WikiPart[] | null;
20
-
21
- export { type WikiLinkToken, type WikiPart, parseWikiInner, splitWikiLinks };
1
+ export { WikiLinkToken, WikiPart, parseWikiInner, splitWikiLinks } from '@immediately-run/safe-content';
@@ -1,37 +1,5 @@
1
1
  import "../chunk-VHAA22YE.js";
2
- const WIKILINK = /\[\[([^[\]]+)\]\]/g;
3
- function parseWikiInner(inner) {
4
- const pipe = inner.indexOf("|");
5
- let target;
6
- let label;
7
- if (pipe === -1) {
8
- target = inner.trim();
9
- } else {
10
- label = inner.slice(0, pipe).trim();
11
- target = inner.slice(pipe + 1).trim();
12
- }
13
- if (target === "") return null;
14
- return label ? { target, label } : { target };
15
- }
16
- function splitWikiLinks(value) {
17
- if (value.indexOf("[[") === -1) return null;
18
- const out = [];
19
- let lastIndex = 0;
20
- let produced = false;
21
- WIKILINK.lastIndex = 0;
22
- let match;
23
- while ((match = WIKILINK.exec(value)) !== null) {
24
- const token = parseWikiInner(match[1]);
25
- if (!token) continue;
26
- if (match.index > lastIndex) out.push({ text: value.slice(lastIndex, match.index) });
27
- out.push({ wiki: token });
28
- lastIndex = match.index + match[0].length;
29
- produced = true;
30
- }
31
- if (!produced) return null;
32
- if (lastIndex < value.length) out.push({ text: value.slice(lastIndex) });
33
- return out;
34
- }
2
+ import { splitWikiLinks, parseWikiInner } from "@immediately-run/safe-content";
35
3
  export {
36
4
  parseWikiInner,
37
5
  splitWikiLinks
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/safeContent/wikilink.ts"],"sourcesContent":["// Wikilink parsing for the safe content renderer (TRUST_MODES_SPEC §5.1). A §5.1\n// residual: wikilinks resolve **only within the granted mount, never a fetch**. The\n// kernel's executable pipeline compiles `[[target]]`/`[[label|target]]` to a\n// `<WikiLink>` component (transpiler `remarkWikiLinks`, MARKDOWN_SYNTAX_SPEC §13); the\n// SAFE renderer parses raw source, so it splits `[[…]]` out of text itself with the\n// same byte-local rule and hands the raw target/label to an injected, **in-mount**\n// resolver. The renderer never fetches; resolution is the consumer's mount-scoped\n// callback (or, absent one, the link renders as inert text).\n\n// Inner content up to the closing `]]`, forbidding `[`/`]` so nested brackets can't\n// be swallowed. Global — a text run may hold several.\nconst WIKILINK = /\\[\\[([^[\\]]+)\\]\\]/g;\n\nexport interface WikiLinkToken {\n /** The raw target path, verbatim (relative or absolute; resolved in-mount only). */\n target: string;\n /** The explicit label, or undefined (the component derives one). */\n label?: string;\n}\n\nexport type WikiPart = { text: string } | { wiki: WikiLinkToken };\n\n/** Parse the `[[label|target]]` / `[[target]]` inner text (label first, then target\n * — the §13.1 order), or `null` for an empty target (leave the literal `[[…]]`). */\nexport function parseWikiInner(inner: string): WikiLinkToken | null {\n const pipe = inner.indexOf('|');\n let target: string;\n let label: string | undefined;\n if (pipe === -1) {\n target = inner.trim();\n } else {\n label = inner.slice(0, pipe).trim();\n target = inner.slice(pipe + 1).trim();\n }\n if (target === '') return null;\n return label ? { target, label } : { target };\n}\n\n/**\n * Split a text string on its `[[…]]` runs into ordered text / wiki parts, or `null`\n * when there is no usable wiki-link (so the caller keeps the text node untouched).\n */\nexport function splitWikiLinks(value: string): WikiPart[] | null {\n if (value.indexOf('[[') === -1) return null;\n const out: WikiPart[] = [];\n let lastIndex = 0;\n let produced = false;\n WIKILINK.lastIndex = 0;\n let match: RegExpExecArray | null;\n while ((match = WIKILINK.exec(value)) !== null) {\n const token = parseWikiInner(match[1]);\n if (!token) continue; // empty target → keep the literal `[[…]]`\n if (match.index > lastIndex) out.push({ text: value.slice(lastIndex, match.index) });\n out.push({ wiki: token });\n lastIndex = match.index + match[0].length;\n produced = true;\n }\n if (!produced) return null;\n if (lastIndex < value.length) out.push({ text: value.slice(lastIndex) });\n return out;\n}\n"],"mappings":";AAWA,MAAM,WAAW;AAaV,SAAS,eAAe,OAAqC;AAClE,QAAM,OAAO,MAAM,QAAQ,GAAG;AAC9B,MAAI;AACJ,MAAI;AACJ,MAAI,SAAS,IAAI;AACf,aAAS,MAAM,KAAK;AAAA,EACtB,OAAO;AACL,YAAQ,MAAM,MAAM,GAAG,IAAI,EAAE,KAAK;AAClC,aAAS,MAAM,MAAM,OAAO,CAAC,EAAE,KAAK;AAAA,EACtC;AACA,MAAI,WAAW,GAAI,QAAO;AAC1B,SAAO,QAAQ,EAAE,QAAQ,MAAM,IAAI,EAAE,OAAO;AAC9C;AAMO,SAAS,eAAe,OAAkC;AAC/D,MAAI,MAAM,QAAQ,IAAI,MAAM,GAAI,QAAO;AACvC,QAAM,MAAkB,CAAC;AACzB,MAAI,YAAY;AAChB,MAAI,WAAW;AACf,WAAS,YAAY;AACrB,MAAI;AACJ,UAAQ,QAAQ,SAAS,KAAK,KAAK,OAAO,MAAM;AAC9C,UAAM,QAAQ,eAAe,MAAM,CAAC,CAAC;AACrC,QAAI,CAAC,MAAO;AACZ,QAAI,MAAM,QAAQ,UAAW,KAAI,KAAK,EAAE,MAAM,MAAM,MAAM,WAAW,MAAM,KAAK,EAAE,CAAC;AACnF,QAAI,KAAK,EAAE,MAAM,MAAM,CAAC;AACxB,gBAAY,MAAM,QAAQ,MAAM,CAAC,EAAE;AACnC,eAAW;AAAA,EACb;AACA,MAAI,CAAC,SAAU,QAAO;AACtB,MAAI,YAAY,MAAM,OAAQ,KAAI,KAAK,EAAE,MAAM,MAAM,MAAM,SAAS,EAAE,CAAC;AACvE,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/safeContent/wikilink.ts"],"sourcesContent":["// R3-279 (phase 3): re-export shim — the implementation lives in\n// `@immediately-run/safe-content`; this subpath keeps working byte-compatibly.\nexport { splitWikiLinks, parseWikiInner } from '@immediately-run/safe-content';\nexport type { WikiLinkToken, WikiPart } from '@immediately-run/safe-content';\n"],"mappings":";AAEA,SAAS,gBAAgB,sBAAsB;","names":[]}
package/dist/version.cjs CHANGED
@@ -21,7 +21,7 @@ __export(version_exports, {
21
21
  SDK_VERSION: () => SDK_VERSION
22
22
  });
23
23
  module.exports = __toCommonJS(version_exports);
24
- const SDK_VERSION = "0.50.0";
24
+ const SDK_VERSION = "0.52.0";
25
25
  // Annotate the CommonJS export names for ESM import in node:
26
26
  0 && (module.exports = {
27
27
  SDK_VERSION
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/version.ts"],"sourcesContent":["// GENERATED by scripts/gen-version.mjs from package.json — do not edit by hand.\n// Regenerated on every build (prebuild); kept honest by version.test.ts.\n\n/** This SDK's package version, baked from package.json at build (SP2-6). */\nexport const SDK_VERSION = '0.50.0';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO,MAAM,cAAc;","names":[]}
1
+ {"version":3,"sources":["../src/version.ts"],"sourcesContent":["// GENERATED by scripts/gen-version.mjs from package.json — do not edit by hand.\n// Regenerated on every build (prebuild); kept honest by version.test.ts.\n\n/** This SDK's package version, baked from package.json at build (SP2-6). */\nexport const SDK_VERSION = '0.52.0';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO,MAAM,cAAc;","names":[]}
@@ -1,4 +1,4 @@
1
1
  /** This SDK's package version, baked from package.json at build (SP2-6). */
2
- declare const SDK_VERSION = "0.50.0";
2
+ declare const SDK_VERSION = "0.52.0";
3
3
 
4
4
  export { SDK_VERSION };
package/dist/version.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  /** This SDK's package version, baked from package.json at build (SP2-6). */
2
- declare const SDK_VERSION = "0.50.0";
2
+ declare const SDK_VERSION = "0.52.0";
3
3
 
4
4
  export { SDK_VERSION };
package/dist/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./chunk-VHAA22YE.js";
2
- const SDK_VERSION = "0.50.0";
2
+ const SDK_VERSION = "0.52.0";
3
3
  export {
4
4
  SDK_VERSION
5
5
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/version.ts"],"sourcesContent":["// GENERATED by scripts/gen-version.mjs from package.json — do not edit by hand.\n// Regenerated on every build (prebuild); kept honest by version.test.ts.\n\n/** This SDK's package version, baked from package.json at build (SP2-6). */\nexport const SDK_VERSION = '0.50.0';\n"],"mappings":";AAIO,MAAM,cAAc;","names":[]}
1
+ {"version":3,"sources":["../src/version.ts"],"sourcesContent":["// GENERATED by scripts/gen-version.mjs from package.json — do not edit by hand.\n// Regenerated on every build (prebuild); kept honest by version.test.ts.\n\n/** This SDK's package version, baked from package.json at build (SP2-6). */\nexport const SDK_VERSION = '0.52.0';\n"],"mappings":";AAIO,MAAM,cAAc;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@immediately-run/sdk",
3
- "version": "0.50.0",
3
+ "version": "0.52.0",
4
4
  "description": "Runtime SDK for code executing inside an immediately.run sandbox.",
5
5
  "license": "MIT",
6
6
  "repository": "github:immediately-run/immediately-run-sdk",
@@ -58,11 +58,12 @@
58
58
  },
59
59
  "dependencies": {
60
60
  "@immediately-run/platform-constants": "0.2.0",
61
- "@immediately-run/sandbox-protocol": "0.4.0",
62
- "react-error-boundary": "^6.0.0"
61
+ "@immediately-run/sandbox-protocol": "0.5.0",
62
+ "react-error-boundary": "^6.0.0",
63
+ "@immediately-run/safe-content": "0.1.0",
64
+ "@immediately-run/mdx-plugins": "0.5.0"
63
65
  },
64
66
  "devDependencies": {
65
- "@immediately-run/mdx-plugins": "^0.1.0",
66
67
  "@immediately-run/prettier-config": "0.1.0",
67
68
  "@testing-library/dom": "^10.4.1",
68
69
  "@testing-library/react": "^16.3.2",
@@ -85,7 +86,8 @@
85
86
  "ts-node": "^10.9.2",
86
87
  "tsup": "^8.0.0",
87
88
  "typedoc": "^0.27.0",
88
- "typescript": "^5.6.0"
89
+ "typescript": "^5.6.0",
90
+ "unified": "^11.0.5"
89
91
  },
90
92
  "prettier": "@immediately-run/prettier-config"
91
93
  }