@immediately-run/sdk 0.90.2 → 0.93.1
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.
- package/dist/bundleLinkPath.cjs +104 -0
- package/dist/bundleLinkPath.cjs.map +1 -0
- package/dist/bundleLinkPath.d.cts +28 -0
- package/dist/bundleLinkPath.d.ts +28 -0
- package/dist/bundleLinkPath.js +81 -0
- package/dist/bundleLinkPath.js.map +1 -0
- package/dist/followBundleLink.cjs +47 -0
- package/dist/followBundleLink.cjs.map +1 -0
- package/dist/followBundleLink.d.cts +20 -0
- package/dist/followBundleLink.d.ts +20 -0
- package/dist/followBundleLink.js +24 -0
- package/dist/followBundleLink.js.map +1 -0
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/llm.cjs +110 -4
- package/dist/llm.cjs.map +1 -1
- package/dist/llm.d.cts +101 -3
- package/dist/llm.d.ts +101 -3
- package/dist/llm.js +110 -5
- package/dist/llm.js.map +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.cts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var bundleLinkPath_exports = {};
|
|
20
|
+
__export(bundleLinkPath_exports, {
|
|
21
|
+
bundleRelativeTarget: () => bundleRelativeTarget
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(bundleLinkPath_exports);
|
|
24
|
+
var import_mdx_plugins = require("@immediately-run/mdx-plugins");
|
|
25
|
+
const SCHEME = /^[a-zA-Z][a-zA-Z0-9+.-]*:/;
|
|
26
|
+
const ENCODED_DOT_SEGMENT = /^(?:\.|%2e){1,2}$/i;
|
|
27
|
+
const hasControlChar = (s) => {
|
|
28
|
+
for (let i = 0; i < s.length; i++) {
|
|
29
|
+
const c = s.charCodeAt(i);
|
|
30
|
+
if (c < 32 || c === 127) return true;
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
};
|
|
34
|
+
const hasLoneSurrogate = (s) => {
|
|
35
|
+
for (let i = 0; i < s.length; i++) {
|
|
36
|
+
const c = s.charCodeAt(i);
|
|
37
|
+
if (c >= 55296 && c <= 56319) {
|
|
38
|
+
const next = s.charCodeAt(i + 1);
|
|
39
|
+
if (next >= 56320 && next <= 57343) i++;
|
|
40
|
+
else return true;
|
|
41
|
+
} else if (c >= 56320 && c <= 57343) return true;
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
};
|
|
45
|
+
const segmentRefusal = (raw) => {
|
|
46
|
+
let s;
|
|
47
|
+
try {
|
|
48
|
+
s = decodeURIComponent(raw);
|
|
49
|
+
} catch {
|
|
50
|
+
return "a segment has a malformed % escape";
|
|
51
|
+
}
|
|
52
|
+
if (s.includes("/") || s.includes("\\")) return "a segment holds a separator (/ or \\) once decoded";
|
|
53
|
+
if (hasControlChar(s)) return "a segment holds a control character";
|
|
54
|
+
if (hasLoneSurrogate(s)) return "a segment holds a lone surrogate";
|
|
55
|
+
return void 0;
|
|
56
|
+
};
|
|
57
|
+
function fold(start, parts) {
|
|
58
|
+
let ups = start.ups;
|
|
59
|
+
const segs = [...start.segs];
|
|
60
|
+
for (const part of parts) {
|
|
61
|
+
if (part === "" || part === ".") continue;
|
|
62
|
+
if (part === "..") {
|
|
63
|
+
if (segs.length > 0) segs.pop();
|
|
64
|
+
else ups += 1;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (ENCODED_DOT_SEGMENT.test(part)) return "encoded-dot";
|
|
68
|
+
segs.push(part);
|
|
69
|
+
}
|
|
70
|
+
return { ups, segs };
|
|
71
|
+
}
|
|
72
|
+
function bundleRelativeTarget(href, fromEntry, onRefused) {
|
|
73
|
+
if (href === "" || href.startsWith("#") || href.startsWith("//") || SCHEME.test(href)) return null;
|
|
74
|
+
if (href.startsWith(import_mdx_plugins.FS_PREFIX)) return null;
|
|
75
|
+
const refuse = (reason) => {
|
|
76
|
+
onRefused?.(reason);
|
|
77
|
+
return "refused";
|
|
78
|
+
};
|
|
79
|
+
const hash = href.indexOf("#");
|
|
80
|
+
const beforeHash = hash === -1 ? href : href.slice(0, hash);
|
|
81
|
+
const fragment = hash === -1 ? "" : href.slice(hash + 1);
|
|
82
|
+
const query = beforeHash.indexOf("?");
|
|
83
|
+
const pathPart = query === -1 ? beforeHash : beforeHash.slice(0, query);
|
|
84
|
+
if (pathPart.includes("\\")) return refuse("it has a backslash");
|
|
85
|
+
const entryDir = fold({ ups: 0, segs: [] }, fromEntry.split("/").slice(0, -1));
|
|
86
|
+
if (entryDir === "encoded-dot" || entryDir.ups > 0) return null;
|
|
87
|
+
const target = fold(pathPart.startsWith("/") ? { ups: 0, segs: [] } : entryDir, pathPart.split("/"));
|
|
88
|
+
if (target === "encoded-dot") return refuse("it has a percent-encoded dot segment");
|
|
89
|
+
if (pathPart.startsWith("/") || target.ups === 0) return "inside";
|
|
90
|
+
if (query !== -1) return refuse("it leaves the bundle with a query");
|
|
91
|
+
if (fragment.includes("#")) return refuse("it leaves the bundle with a second #");
|
|
92
|
+
if (target.segs.length === 0) return refuse("it lands on a directory and names no file");
|
|
93
|
+
for (const seg of target.segs) {
|
|
94
|
+
const reason = segmentRefusal(seg);
|
|
95
|
+
if (reason) return refuse(reason);
|
|
96
|
+
}
|
|
97
|
+
const path = [...Array(target.ups).fill(".."), ...target.segs].join("/");
|
|
98
|
+
return fragment ? { path, fragment } : { path };
|
|
99
|
+
}
|
|
100
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
101
|
+
0 && (module.exports = {
|
|
102
|
+
bundleRelativeTarget
|
|
103
|
+
});
|
|
104
|
+
//# sourceMappingURL=bundleLinkPath.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/bundleLinkPath.ts"],"sourcesContent":["// R3-1324 — the bundle-link normaliser (REPO_CONTENT_DISPATCH_SPEC §9, \"A relative link\n// that leaves its bundle is a cross-bundle link\").\n//\n// An author links between sibling bundles of one repository with the ordinary\n// repository-relative path (`../spec/BATON_SPEC/06-x.md#r-btn-120` from `tickets/B-10.mdx`).\n// The viewer never learns where its bundle lives, so it hands the host the target\n// relative to the BUNDLE ROOT with its leading `..` segments intact; the host resolves it\n// against the bundle's marker directory and confines it (R3-1321).\n//\n// Pure posix SEGMENT ARITHMETIC, deliberately — never `new URL` and never a URL library's\n// normalize: WHATWG URL parsing collapses `..` and `%2e%2e` against the base, which is\n// exactly the information this function exists to keep.\nimport { FS_PREFIX } from '@immediately-run/mdx-plugins';\nimport type { BundleLinkPayload } from './generated/protocol';\n\nconst SCHEME = /^[a-zA-Z][a-zA-Z0-9+.-]*:/;\n/** A percent-encoded dot segment (`%2e`, `.%2e`, `%2E%2e`, …). Refused rather than\n * decoded: a host that decodes later would read it as `.`/`..`, so its meaning would\n * depend on who looked last. */\nconst ENCODED_DOT_SEGMENT = /^(?:\\.|%2e){1,2}$/i;\n\nconst hasControlChar = (s: string): boolean => {\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x20 || c === 0x7f) return true;\n }\n return false;\n};\n\nconst hasLoneSurrogate = (s: string): boolean => {\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c >= 0xd800 && c <= 0xdbff) {\n const next = s.charCodeAt(i + 1);\n if (next >= 0xdc00 && next <= 0xdfff) i++;\n else return true;\n } else if (c >= 0xdc00 && c <= 0xdfff) return true;\n }\n return false;\n};\n\n/** Why the host would refuse this escaping segment, or `undefined` when it takes it. The\n * same tests as the host's `decodeSegment` (site-main `src/editor/bundleUrl.ts`, R3-1321),\n * so the SDK never posts a payload the host is certain to drop. */\nconst segmentRefusal = (raw: string): string | undefined => {\n let s: string;\n try {\n s = decodeURIComponent(raw);\n } catch {\n return 'a segment has a malformed % escape';\n }\n if (s.includes('/') || s.includes('\\\\')) return 'a segment holds a separator (/ or \\\\) once decoded';\n if (hasControlChar(s)) return 'a segment holds a control character';\n if (hasLoneSurrogate(s)) return 'a segment holds a lone surrogate';\n return undefined;\n};\n\ntype Segments = { ups: number; segs: string[] } | 'encoded-dot';\n\n/** Fold `parts` onto `start` (`segs` under `ups` leading `..`). `'encoded-dot'` on a\n * percent-encoded dot segment. */\nfunction fold(start: { ups: number; segs: string[] }, parts: string[]): Segments {\n let ups = start.ups;\n const segs = [...start.segs];\n for (const part of parts) {\n if (part === '' || part === '.') continue;\n if (part === '..') {\n if (segs.length > 0) segs.pop();\n else ups += 1;\n continue;\n }\n if (ENCODED_DOT_SEGMENT.test(part)) return 'encoded-dot';\n segs.push(part);\n }\n return { ups, segs };\n}\n\n/**\n * Resolve `href`, as written in the document at the bundle-relative path `fromEntry`,\n * into a bundle-relative target.\n *\n * - `null` — not ours to route: an external href (any scheme, or `//host`), a bare\n * anchor (`#x`), a `$fs:` href, an empty href, or a `fromEntry` that is not itself\n * bundle-relative.\n * - `'inside'` — the target stays inside the bundle; the caller routes it as today.\n * - `'refused'` — a relative href this function will not hand to the host, and which must\n * not be routed as today either, because URL parsing would collapse its `..` into a\n * wrong in-bundle path. That is any href with a backslash or a percent-encoded dot\n * segment in its path (whether it leaves depends on who reads it; the fragment is not\n * checked), and one that leaves the bundle\n * and carries a query or a second `#`, names only `..` segments, or has a segment the\n * host refuses once decoded: a malformed `%` escape, a `/` or `\\`, a control character\n * or a lone surrogate. `onRefused` receives the reason.\n * - `{ path, fragment? }` — the target leaves the bundle. `path` is in normal form:\n * one or more leading `..` segments, then clean segments (no `.`, no empty segment,\n * no other `..`). `fragment` carries no `#` and is absent when empty.\n *\n * A root-absolute href (`/x`) is bundle-root-relative and clamps at the root, so it is\n * `'inside'` unless its path carries a backslash or an encoded dot segment.\n */\nexport function bundleRelativeTarget(\n href: string,\n fromEntry: string,\n onRefused?: (reason: string) => void,\n): BundleLinkPayload | 'inside' | 'refused' | null {\n if (href === '' || href.startsWith('#') || href.startsWith('//') || SCHEME.test(href)) return null;\n if (href.startsWith(FS_PREFIX)) return null; // the explicit filesystem space is not bundle-relative\n const refuse = (reason: string): 'refused' => {\n onRefused?.(reason);\n return 'refused';\n };\n const hash = href.indexOf('#');\n const beforeHash = hash === -1 ? href : href.slice(0, hash);\n const fragment = hash === -1 ? '' : href.slice(hash + 1);\n const query = beforeHash.indexOf('?');\n const pathPart = query === -1 ? beforeHash : beforeHash.slice(0, query);\n // A URL parser reads `\\\\` as `/`, so a caller routing this href as today could collapse\n // a `..` behind it; and the host refuses it. Refused wherever it stands.\n if (pathPart.includes('\\\\')) return refuse('it has a backslash');\n\n // The document's own directory, inside the bundle. An entry that is not itself\n // bundle-relative has no directory to resolve against.\n const entryDir = fold({ ups: 0, segs: [] }, fromEntry.split('/').slice(0, -1));\n if (entryDir === 'encoded-dot' || entryDir.ups > 0) return null;\n\n const target = fold(pathPart.startsWith('/') ? { ups: 0, segs: [] } : entryDir, pathPart.split('/'));\n if (target === 'encoded-dot') return refuse('it has a percent-encoded dot segment');\n if (pathPart.startsWith('/') || target.ups === 0) return 'inside';\n if (query !== -1) return refuse('it leaves the bundle with a query');\n if (fragment.includes('#')) return refuse('it leaves the bundle with a second #');\n if (target.segs.length === 0) return refuse('it lands on a directory and names no file');\n for (const seg of target.segs) {\n const reason = segmentRefusal(seg);\n if (reason) return refuse(reason);\n }\n const path = [...Array<string>(target.ups).fill('..'), ...target.segs].join('/');\n return fragment ? { path, fragment } : { path };\n}\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BundleLinkPayload } from '@immediately-run/sandbox-protocol/sdk';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Resolve `href`, as written in the document at the bundle-relative path `fromEntry`,
|
|
5
|
+
* into a bundle-relative target.
|
|
6
|
+
*
|
|
7
|
+
* - `null` — not ours to route: an external href (any scheme, or `//host`), a bare
|
|
8
|
+
* anchor (`#x`), a `$fs:` href, an empty href, or a `fromEntry` that is not itself
|
|
9
|
+
* bundle-relative.
|
|
10
|
+
* - `'inside'` — the target stays inside the bundle; the caller routes it as today.
|
|
11
|
+
* - `'refused'` — a relative href this function will not hand to the host, and which must
|
|
12
|
+
* not be routed as today either, because URL parsing would collapse its `..` into a
|
|
13
|
+
* wrong in-bundle path. That is any href with a backslash or a percent-encoded dot
|
|
14
|
+
* segment in its path (whether it leaves depends on who reads it; the fragment is not
|
|
15
|
+
* checked), and one that leaves the bundle
|
|
16
|
+
* and carries a query or a second `#`, names only `..` segments, or has a segment the
|
|
17
|
+
* host refuses once decoded: a malformed `%` escape, a `/` or `\`, a control character
|
|
18
|
+
* or a lone surrogate. `onRefused` receives the reason.
|
|
19
|
+
* - `{ path, fragment? }` — the target leaves the bundle. `path` is in normal form:
|
|
20
|
+
* one or more leading `..` segments, then clean segments (no `.`, no empty segment,
|
|
21
|
+
* no other `..`). `fragment` carries no `#` and is absent when empty.
|
|
22
|
+
*
|
|
23
|
+
* A root-absolute href (`/x`) is bundle-root-relative and clamps at the root, so it is
|
|
24
|
+
* `'inside'` unless its path carries a backslash or an encoded dot segment.
|
|
25
|
+
*/
|
|
26
|
+
declare function bundleRelativeTarget(href: string, fromEntry: string, onRefused?: (reason: string) => void): BundleLinkPayload | 'inside' | 'refused' | null;
|
|
27
|
+
|
|
28
|
+
export { bundleRelativeTarget };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BundleLinkPayload } from '@immediately-run/sandbox-protocol/sdk';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Resolve `href`, as written in the document at the bundle-relative path `fromEntry`,
|
|
5
|
+
* into a bundle-relative target.
|
|
6
|
+
*
|
|
7
|
+
* - `null` — not ours to route: an external href (any scheme, or `//host`), a bare
|
|
8
|
+
* anchor (`#x`), a `$fs:` href, an empty href, or a `fromEntry` that is not itself
|
|
9
|
+
* bundle-relative.
|
|
10
|
+
* - `'inside'` — the target stays inside the bundle; the caller routes it as today.
|
|
11
|
+
* - `'refused'` — a relative href this function will not hand to the host, and which must
|
|
12
|
+
* not be routed as today either, because URL parsing would collapse its `..` into a
|
|
13
|
+
* wrong in-bundle path. That is any href with a backslash or a percent-encoded dot
|
|
14
|
+
* segment in its path (whether it leaves depends on who reads it; the fragment is not
|
|
15
|
+
* checked), and one that leaves the bundle
|
|
16
|
+
* and carries a query or a second `#`, names only `..` segments, or has a segment the
|
|
17
|
+
* host refuses once decoded: a malformed `%` escape, a `/` or `\`, a control character
|
|
18
|
+
* or a lone surrogate. `onRefused` receives the reason.
|
|
19
|
+
* - `{ path, fragment? }` — the target leaves the bundle. `path` is in normal form:
|
|
20
|
+
* one or more leading `..` segments, then clean segments (no `.`, no empty segment,
|
|
21
|
+
* no other `..`). `fragment` carries no `#` and is absent when empty.
|
|
22
|
+
*
|
|
23
|
+
* A root-absolute href (`/x`) is bundle-root-relative and clamps at the root, so it is
|
|
24
|
+
* `'inside'` unless its path carries a backslash or an encoded dot segment.
|
|
25
|
+
*/
|
|
26
|
+
declare function bundleRelativeTarget(href: string, fromEntry: string, onRefused?: (reason: string) => void): BundleLinkPayload | 'inside' | 'refused' | null;
|
|
27
|
+
|
|
28
|
+
export { bundleRelativeTarget };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import "./chunk-VHAA22YE.js";
|
|
2
|
+
import { FS_PREFIX } from "@immediately-run/mdx-plugins";
|
|
3
|
+
const SCHEME = /^[a-zA-Z][a-zA-Z0-9+.-]*:/;
|
|
4
|
+
const ENCODED_DOT_SEGMENT = /^(?:\.|%2e){1,2}$/i;
|
|
5
|
+
const hasControlChar = (s) => {
|
|
6
|
+
for (let i = 0; i < s.length; i++) {
|
|
7
|
+
const c = s.charCodeAt(i);
|
|
8
|
+
if (c < 32 || c === 127) return true;
|
|
9
|
+
}
|
|
10
|
+
return false;
|
|
11
|
+
};
|
|
12
|
+
const hasLoneSurrogate = (s) => {
|
|
13
|
+
for (let i = 0; i < s.length; i++) {
|
|
14
|
+
const c = s.charCodeAt(i);
|
|
15
|
+
if (c >= 55296 && c <= 56319) {
|
|
16
|
+
const next = s.charCodeAt(i + 1);
|
|
17
|
+
if (next >= 56320 && next <= 57343) i++;
|
|
18
|
+
else return true;
|
|
19
|
+
} else if (c >= 56320 && c <= 57343) return true;
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
};
|
|
23
|
+
const segmentRefusal = (raw) => {
|
|
24
|
+
let s;
|
|
25
|
+
try {
|
|
26
|
+
s = decodeURIComponent(raw);
|
|
27
|
+
} catch {
|
|
28
|
+
return "a segment has a malformed % escape";
|
|
29
|
+
}
|
|
30
|
+
if (s.includes("/") || s.includes("\\")) return "a segment holds a separator (/ or \\) once decoded";
|
|
31
|
+
if (hasControlChar(s)) return "a segment holds a control character";
|
|
32
|
+
if (hasLoneSurrogate(s)) return "a segment holds a lone surrogate";
|
|
33
|
+
return void 0;
|
|
34
|
+
};
|
|
35
|
+
function fold(start, parts) {
|
|
36
|
+
let ups = start.ups;
|
|
37
|
+
const segs = [...start.segs];
|
|
38
|
+
for (const part of parts) {
|
|
39
|
+
if (part === "" || part === ".") continue;
|
|
40
|
+
if (part === "..") {
|
|
41
|
+
if (segs.length > 0) segs.pop();
|
|
42
|
+
else ups += 1;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (ENCODED_DOT_SEGMENT.test(part)) return "encoded-dot";
|
|
46
|
+
segs.push(part);
|
|
47
|
+
}
|
|
48
|
+
return { ups, segs };
|
|
49
|
+
}
|
|
50
|
+
function bundleRelativeTarget(href, fromEntry, onRefused) {
|
|
51
|
+
if (href === "" || href.startsWith("#") || href.startsWith("//") || SCHEME.test(href)) return null;
|
|
52
|
+
if (href.startsWith(FS_PREFIX)) return null;
|
|
53
|
+
const refuse = (reason) => {
|
|
54
|
+
onRefused?.(reason);
|
|
55
|
+
return "refused";
|
|
56
|
+
};
|
|
57
|
+
const hash = href.indexOf("#");
|
|
58
|
+
const beforeHash = hash === -1 ? href : href.slice(0, hash);
|
|
59
|
+
const fragment = hash === -1 ? "" : href.slice(hash + 1);
|
|
60
|
+
const query = beforeHash.indexOf("?");
|
|
61
|
+
const pathPart = query === -1 ? beforeHash : beforeHash.slice(0, query);
|
|
62
|
+
if (pathPart.includes("\\")) return refuse("it has a backslash");
|
|
63
|
+
const entryDir = fold({ ups: 0, segs: [] }, fromEntry.split("/").slice(0, -1));
|
|
64
|
+
if (entryDir === "encoded-dot" || entryDir.ups > 0) return null;
|
|
65
|
+
const target = fold(pathPart.startsWith("/") ? { ups: 0, segs: [] } : entryDir, pathPart.split("/"));
|
|
66
|
+
if (target === "encoded-dot") return refuse("it has a percent-encoded dot segment");
|
|
67
|
+
if (pathPart.startsWith("/") || target.ups === 0) return "inside";
|
|
68
|
+
if (query !== -1) return refuse("it leaves the bundle with a query");
|
|
69
|
+
if (fragment.includes("#")) return refuse("it leaves the bundle with a second #");
|
|
70
|
+
if (target.segs.length === 0) return refuse("it lands on a directory and names no file");
|
|
71
|
+
for (const seg of target.segs) {
|
|
72
|
+
const reason = segmentRefusal(seg);
|
|
73
|
+
if (reason) return refuse(reason);
|
|
74
|
+
}
|
|
75
|
+
const path = [...Array(target.ups).fill(".."), ...target.segs].join("/");
|
|
76
|
+
return fragment ? { path, fragment } : { path };
|
|
77
|
+
}
|
|
78
|
+
export {
|
|
79
|
+
bundleRelativeTarget
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=bundleLinkPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/bundleLinkPath.ts"],"sourcesContent":["// R3-1324 — the bundle-link normaliser (REPO_CONTENT_DISPATCH_SPEC §9, \"A relative link\n// that leaves its bundle is a cross-bundle link\").\n//\n// An author links between sibling bundles of one repository with the ordinary\n// repository-relative path (`../spec/BATON_SPEC/06-x.md#r-btn-120` from `tickets/B-10.mdx`).\n// The viewer never learns where its bundle lives, so it hands the host the target\n// relative to the BUNDLE ROOT with its leading `..` segments intact; the host resolves it\n// against the bundle's marker directory and confines it (R3-1321).\n//\n// Pure posix SEGMENT ARITHMETIC, deliberately — never `new URL` and never a URL library's\n// normalize: WHATWG URL parsing collapses `..` and `%2e%2e` against the base, which is\n// exactly the information this function exists to keep.\nimport { FS_PREFIX } from '@immediately-run/mdx-plugins';\nimport type { BundleLinkPayload } from './generated/protocol';\n\nconst SCHEME = /^[a-zA-Z][a-zA-Z0-9+.-]*:/;\n/** A percent-encoded dot segment (`%2e`, `.%2e`, `%2E%2e`, …). Refused rather than\n * decoded: a host that decodes later would read it as `.`/`..`, so its meaning would\n * depend on who looked last. */\nconst ENCODED_DOT_SEGMENT = /^(?:\\.|%2e){1,2}$/i;\n\nconst hasControlChar = (s: string): boolean => {\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x20 || c === 0x7f) return true;\n }\n return false;\n};\n\nconst hasLoneSurrogate = (s: string): boolean => {\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c >= 0xd800 && c <= 0xdbff) {\n const next = s.charCodeAt(i + 1);\n if (next >= 0xdc00 && next <= 0xdfff) i++;\n else return true;\n } else if (c >= 0xdc00 && c <= 0xdfff) return true;\n }\n return false;\n};\n\n/** Why the host would refuse this escaping segment, or `undefined` when it takes it. The\n * same tests as the host's `decodeSegment` (site-main `src/editor/bundleUrl.ts`, R3-1321),\n * so the SDK never posts a payload the host is certain to drop. */\nconst segmentRefusal = (raw: string): string | undefined => {\n let s: string;\n try {\n s = decodeURIComponent(raw);\n } catch {\n return 'a segment has a malformed % escape';\n }\n if (s.includes('/') || s.includes('\\\\')) return 'a segment holds a separator (/ or \\\\) once decoded';\n if (hasControlChar(s)) return 'a segment holds a control character';\n if (hasLoneSurrogate(s)) return 'a segment holds a lone surrogate';\n return undefined;\n};\n\ntype Segments = { ups: number; segs: string[] } | 'encoded-dot';\n\n/** Fold `parts` onto `start` (`segs` under `ups` leading `..`). `'encoded-dot'` on a\n * percent-encoded dot segment. */\nfunction fold(start: { ups: number; segs: string[] }, parts: string[]): Segments {\n let ups = start.ups;\n const segs = [...start.segs];\n for (const part of parts) {\n if (part === '' || part === '.') continue;\n if (part === '..') {\n if (segs.length > 0) segs.pop();\n else ups += 1;\n continue;\n }\n if (ENCODED_DOT_SEGMENT.test(part)) return 'encoded-dot';\n segs.push(part);\n }\n return { ups, segs };\n}\n\n/**\n * Resolve `href`, as written in the document at the bundle-relative path `fromEntry`,\n * into a bundle-relative target.\n *\n * - `null` — not ours to route: an external href (any scheme, or `//host`), a bare\n * anchor (`#x`), a `$fs:` href, an empty href, or a `fromEntry` that is not itself\n * bundle-relative.\n * - `'inside'` — the target stays inside the bundle; the caller routes it as today.\n * - `'refused'` — a relative href this function will not hand to the host, and which must\n * not be routed as today either, because URL parsing would collapse its `..` into a\n * wrong in-bundle path. That is any href with a backslash or a percent-encoded dot\n * segment in its path (whether it leaves depends on who reads it; the fragment is not\n * checked), and one that leaves the bundle\n * and carries a query or a second `#`, names only `..` segments, or has a segment the\n * host refuses once decoded: a malformed `%` escape, a `/` or `\\`, a control character\n * or a lone surrogate. `onRefused` receives the reason.\n * - `{ path, fragment? }` — the target leaves the bundle. `path` is in normal form:\n * one or more leading `..` segments, then clean segments (no `.`, no empty segment,\n * no other `..`). `fragment` carries no `#` and is absent when empty.\n *\n * A root-absolute href (`/x`) is bundle-root-relative and clamps at the root, so it is\n * `'inside'` unless its path carries a backslash or an encoded dot segment.\n */\nexport function bundleRelativeTarget(\n href: string,\n fromEntry: string,\n onRefused?: (reason: string) => void,\n): BundleLinkPayload | 'inside' | 'refused' | null {\n if (href === '' || href.startsWith('#') || href.startsWith('//') || SCHEME.test(href)) return null;\n if (href.startsWith(FS_PREFIX)) return null; // the explicit filesystem space is not bundle-relative\n const refuse = (reason: string): 'refused' => {\n onRefused?.(reason);\n return 'refused';\n };\n const hash = href.indexOf('#');\n const beforeHash = hash === -1 ? href : href.slice(0, hash);\n const fragment = hash === -1 ? '' : href.slice(hash + 1);\n const query = beforeHash.indexOf('?');\n const pathPart = query === -1 ? beforeHash : beforeHash.slice(0, query);\n // A URL parser reads `\\\\` as `/`, so a caller routing this href as today could collapse\n // a `..` behind it; and the host refuses it. Refused wherever it stands.\n if (pathPart.includes('\\\\')) return refuse('it has a backslash');\n\n // The document's own directory, inside the bundle. An entry that is not itself\n // bundle-relative has no directory to resolve against.\n const entryDir = fold({ ups: 0, segs: [] }, fromEntry.split('/').slice(0, -1));\n if (entryDir === 'encoded-dot' || entryDir.ups > 0) return null;\n\n const target = fold(pathPart.startsWith('/') ? { ups: 0, segs: [] } : entryDir, pathPart.split('/'));\n if (target === 'encoded-dot') return refuse('it has a percent-encoded dot segment');\n if (pathPart.startsWith('/') || target.ups === 0) return 'inside';\n if (query !== -1) return refuse('it leaves the bundle with a query');\n if (fragment.includes('#')) return refuse('it leaves the bundle with a second #');\n if (target.segs.length === 0) return refuse('it lands on a directory and names no file');\n for (const seg of target.segs) {\n const reason = segmentRefusal(seg);\n if (reason) return refuse(reason);\n }\n const path = [...Array<string>(target.ups).fill('..'), ...target.segs].join('/');\n return fragment ? { path, fragment } : { path };\n}\n"],"mappings":";AAYA,SAAS,iBAAiB;AAG1B,MAAM,SAAS;AAIf,MAAM,sBAAsB;AAE5B,MAAM,iBAAiB,CAAC,MAAuB;AAC7C,WAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,KAAK;AACjC,UAAM,IAAI,EAAE,WAAW,CAAC;AACxB,QAAI,IAAI,MAAQ,MAAM,IAAM,QAAO;AAAA,EACrC;AACA,SAAO;AACT;AAEA,MAAM,mBAAmB,CAAC,MAAuB;AAC/C,WAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,KAAK;AACjC,UAAM,IAAI,EAAE,WAAW,CAAC;AACxB,QAAI,KAAK,SAAU,KAAK,OAAQ;AAC9B,YAAM,OAAO,EAAE,WAAW,IAAI,CAAC;AAC/B,UAAI,QAAQ,SAAU,QAAQ,MAAQ;AAAA,UACjC,QAAO;AAAA,IACd,WAAW,KAAK,SAAU,KAAK,MAAQ,QAAO;AAAA,EAChD;AACA,SAAO;AACT;AAKA,MAAM,iBAAiB,CAAC,QAAoC;AAC1D,MAAI;AACJ,MAAI;AACF,QAAI,mBAAmB,GAAG;AAAA,EAC5B,QAAQ;AACN,WAAO;AAAA,EACT;AACA,MAAI,EAAE,SAAS,GAAG,KAAK,EAAE,SAAS,IAAI,EAAG,QAAO;AAChD,MAAI,eAAe,CAAC,EAAG,QAAO;AAC9B,MAAI,iBAAiB,CAAC,EAAG,QAAO;AAChC,SAAO;AACT;AAMA,SAAS,KAAK,OAAwC,OAA2B;AAC/E,MAAI,MAAM,MAAM;AAChB,QAAM,OAAO,CAAC,GAAG,MAAM,IAAI;AAC3B,aAAW,QAAQ,OAAO;AACxB,QAAI,SAAS,MAAM,SAAS,IAAK;AACjC,QAAI,SAAS,MAAM;AACjB,UAAI,KAAK,SAAS,EAAG,MAAK,IAAI;AAAA,UACzB,QAAO;AACZ;AAAA,IACF;AACA,QAAI,oBAAoB,KAAK,IAAI,EAAG,QAAO;AAC3C,SAAK,KAAK,IAAI;AAAA,EAChB;AACA,SAAO,EAAE,KAAK,KAAK;AACrB;AAyBO,SAAS,qBACd,MACA,WACA,WACiD;AACjD,MAAI,SAAS,MAAM,KAAK,WAAW,GAAG,KAAK,KAAK,WAAW,IAAI,KAAK,OAAO,KAAK,IAAI,EAAG,QAAO;AAC9F,MAAI,KAAK,WAAW,SAAS,EAAG,QAAO;AACvC,QAAM,SAAS,CAAC,WAA8B;AAC5C,gBAAY,MAAM;AAClB,WAAO;AAAA,EACT;AACA,QAAM,OAAO,KAAK,QAAQ,GAAG;AAC7B,QAAM,aAAa,SAAS,KAAK,OAAO,KAAK,MAAM,GAAG,IAAI;AAC1D,QAAM,WAAW,SAAS,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AACvD,QAAM,QAAQ,WAAW,QAAQ,GAAG;AACpC,QAAM,WAAW,UAAU,KAAK,aAAa,WAAW,MAAM,GAAG,KAAK;AAGtE,MAAI,SAAS,SAAS,IAAI,EAAG,QAAO,OAAO,oBAAoB;AAI/D,QAAM,WAAW,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC,EAAE,GAAG,UAAU,MAAM,GAAG,EAAE,MAAM,GAAG,EAAE,CAAC;AAC7E,MAAI,aAAa,iBAAiB,SAAS,MAAM,EAAG,QAAO;AAE3D,QAAM,SAAS,KAAK,SAAS,WAAW,GAAG,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC,EAAE,IAAI,UAAU,SAAS,MAAM,GAAG,CAAC;AACnG,MAAI,WAAW,cAAe,QAAO,OAAO,sCAAsC;AAClF,MAAI,SAAS,WAAW,GAAG,KAAK,OAAO,QAAQ,EAAG,QAAO;AACzD,MAAI,UAAU,GAAI,QAAO,OAAO,mCAAmC;AACnE,MAAI,SAAS,SAAS,GAAG,EAAG,QAAO,OAAO,sCAAsC;AAChF,MAAI,OAAO,KAAK,WAAW,EAAG,QAAO,OAAO,2CAA2C;AACvF,aAAW,OAAO,OAAO,MAAM;AAC7B,UAAM,SAAS,eAAe,GAAG;AACjC,QAAI,OAAQ,QAAO,OAAO,MAAM;AAAA,EAClC;AACA,QAAM,OAAO,CAAC,GAAG,MAAc,OAAO,GAAG,EAAE,KAAK,IAAI,GAAG,GAAG,OAAO,IAAI,EAAE,KAAK,GAAG;AAC/E,SAAO,WAAW,EAAE,MAAM,SAAS,IAAI,EAAE,KAAK;AAChD;","names":[]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var followBundleLink_exports = {};
|
|
20
|
+
__export(followBundleLink_exports, {
|
|
21
|
+
followBundleLink: () => followBundleLink
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(followBundleLink_exports);
|
|
24
|
+
var import_sandboxUtils = require("./sandboxUtils");
|
|
25
|
+
var import_protocol = require("./generated/protocol");
|
|
26
|
+
var import_bundleLinkPath = require("./bundleLinkPath");
|
|
27
|
+
function followBundleLink(href, fromEntry) {
|
|
28
|
+
let reason = "";
|
|
29
|
+
const target = (0, import_bundleLinkPath.bundleRelativeTarget)(href, fromEntry, (r) => {
|
|
30
|
+
reason = r;
|
|
31
|
+
});
|
|
32
|
+
if (target === null || target === "inside") return false;
|
|
33
|
+
if (target === "refused") {
|
|
34
|
+
console.warn(
|
|
35
|
+
`followBundleLink: not following ${JSON.stringify(href)} from ${JSON.stringify(fromEntry)}: ${reason}`
|
|
36
|
+
);
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
const payload = target;
|
|
40
|
+
(0, import_sandboxUtils.sendMessage)(import_protocol.BUNDLE_LINK, payload);
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
followBundleLink
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=followBundleLink.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/followBundleLink.ts"],"sourcesContent":["// R3-1324 — hand the host a link that leaves the app's bundle (REPO_CONTENT_DISPATCH_SPEC\n// §9). The normalisation lives in `bundleLinkPath.ts`; this is the thin wrapper that posts.\n//\n// `bundle-link` is FIRE-AND-FORGET on purpose: a host that predates the message ignores\n// it (an unknown name gets no reply), and a request would hang its caller there. The\n// message carries a path and nothing else — the host decides, on its own gesture bit,\n// whether to navigate (R3-1321).\nimport { sendMessage } from './sandboxUtils';\nimport { BUNDLE_LINK } from './generated/protocol';\nimport type { BundleLinkPayload } from './generated/protocol';\nimport { bundleRelativeTarget } from './bundleLinkPath';\n\n/**\n * Follow a link that leaves the current bundle.\n *\n * `href` is the link as the author wrote it; `fromEntry` is the bundle-relative path of\n * the document it appears in (e.g. `tickets/B-10.mdx`).\n *\n * - Returns `true` when the href resolves OUTSIDE the bundle: one `bundle-link` message\n * is posted to the host.\n * - Also returns `true`, posting nothing, for a link `bundleRelativeTarget` refuses: one\n * with a backslash or a percent-encoded dot segment in its path, or one that leaves the bundle with\n * a query, a second `#`, only `..` segments, or a segment the host would refuse once\n * decoded. The click is consumed and one `console.warn` names the reason. Do not\n * route it as before, because URL parsing would collapse its `..` into a wrong path\n * inside the bundle. Render it as a broken link instead.\n * - Returns `false`, posting nothing, for an external href, a bare anchor, or a target\n * inside the bundle. Route those as before.\n */\nexport function followBundleLink(href: string, fromEntry: string): boolean {\n let reason = '';\n const target = bundleRelativeTarget(href, fromEntry, (r) => {\n reason = r;\n });\n if (target === null || target === 'inside') return false;\n if (target === 'refused') {\n console.warn(\n `followBundleLink: not following ${JSON.stringify(href)} from ${JSON.stringify(fromEntry)}: ${reason}`,\n );\n return true;\n }\n const payload: BundleLinkPayload = target;\n sendMessage(BUNDLE_LINK, payload);\n return true;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,0BAA4B;AAC5B,sBAA4B;AAE5B,4BAAqC;AAmB9B,SAAS,iBAAiB,MAAc,WAA4B;AACzE,MAAI,SAAS;AACb,QAAM,aAAS,4CAAqB,MAAM,WAAW,CAAC,MAAM;AAC1D,aAAS;AAAA,EACX,CAAC;AACD,MAAI,WAAW,QAAQ,WAAW,SAAU,QAAO;AACnD,MAAI,WAAW,WAAW;AACxB,YAAQ;AAAA,MACN,mCAAmC,KAAK,UAAU,IAAI,CAAC,SAAS,KAAK,UAAU,SAAS,CAAC,KAAK,MAAM;AAAA,IACtG;AACA,WAAO;AAAA,EACT;AACA,QAAM,UAA6B;AACnC,uCAAY,6BAAa,OAAO;AAChC,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Follow a link that leaves the current bundle.
|
|
3
|
+
*
|
|
4
|
+
* `href` is the link as the author wrote it; `fromEntry` is the bundle-relative path of
|
|
5
|
+
* the document it appears in (e.g. `tickets/B-10.mdx`).
|
|
6
|
+
*
|
|
7
|
+
* - Returns `true` when the href resolves OUTSIDE the bundle: one `bundle-link` message
|
|
8
|
+
* is posted to the host.
|
|
9
|
+
* - Also returns `true`, posting nothing, for a link `bundleRelativeTarget` refuses: one
|
|
10
|
+
* with a backslash or a percent-encoded dot segment in its path, or one that leaves the bundle with
|
|
11
|
+
* a query, a second `#`, only `..` segments, or a segment the host would refuse once
|
|
12
|
+
* decoded. The click is consumed and one `console.warn` names the reason. Do not
|
|
13
|
+
* route it as before, because URL parsing would collapse its `..` into a wrong path
|
|
14
|
+
* inside the bundle. Render it as a broken link instead.
|
|
15
|
+
* - Returns `false`, posting nothing, for an external href, a bare anchor, or a target
|
|
16
|
+
* inside the bundle. Route those as before.
|
|
17
|
+
*/
|
|
18
|
+
declare function followBundleLink(href: string, fromEntry: string): boolean;
|
|
19
|
+
|
|
20
|
+
export { followBundleLink };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Follow a link that leaves the current bundle.
|
|
3
|
+
*
|
|
4
|
+
* `href` is the link as the author wrote it; `fromEntry` is the bundle-relative path of
|
|
5
|
+
* the document it appears in (e.g. `tickets/B-10.mdx`).
|
|
6
|
+
*
|
|
7
|
+
* - Returns `true` when the href resolves OUTSIDE the bundle: one `bundle-link` message
|
|
8
|
+
* is posted to the host.
|
|
9
|
+
* - Also returns `true`, posting nothing, for a link `bundleRelativeTarget` refuses: one
|
|
10
|
+
* with a backslash or a percent-encoded dot segment in its path, or one that leaves the bundle with
|
|
11
|
+
* a query, a second `#`, only `..` segments, or a segment the host would refuse once
|
|
12
|
+
* decoded. The click is consumed and one `console.warn` names the reason. Do not
|
|
13
|
+
* route it as before, because URL parsing would collapse its `..` into a wrong path
|
|
14
|
+
* inside the bundle. Render it as a broken link instead.
|
|
15
|
+
* - Returns `false`, posting nothing, for an external href, a bare anchor, or a target
|
|
16
|
+
* inside the bundle. Route those as before.
|
|
17
|
+
*/
|
|
18
|
+
declare function followBundleLink(href: string, fromEntry: string): boolean;
|
|
19
|
+
|
|
20
|
+
export { followBundleLink };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import "./chunk-VHAA22YE.js";
|
|
2
|
+
import { sendMessage } from "./sandboxUtils.js";
|
|
3
|
+
import { BUNDLE_LINK } from "./generated/protocol.js";
|
|
4
|
+
import { bundleRelativeTarget } from "./bundleLinkPath.js";
|
|
5
|
+
function followBundleLink(href, fromEntry) {
|
|
6
|
+
let reason = "";
|
|
7
|
+
const target = bundleRelativeTarget(href, fromEntry, (r) => {
|
|
8
|
+
reason = r;
|
|
9
|
+
});
|
|
10
|
+
if (target === null || target === "inside") return false;
|
|
11
|
+
if (target === "refused") {
|
|
12
|
+
console.warn(
|
|
13
|
+
`followBundleLink: not following ${JSON.stringify(href)} from ${JSON.stringify(fromEntry)}: ${reason}`
|
|
14
|
+
);
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
const payload = target;
|
|
18
|
+
sendMessage(BUNDLE_LINK, payload);
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
followBundleLink
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=followBundleLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/followBundleLink.ts"],"sourcesContent":["// R3-1324 — hand the host a link that leaves the app's bundle (REPO_CONTENT_DISPATCH_SPEC\n// §9). The normalisation lives in `bundleLinkPath.ts`; this is the thin wrapper that posts.\n//\n// `bundle-link` is FIRE-AND-FORGET on purpose: a host that predates the message ignores\n// it (an unknown name gets no reply), and a request would hang its caller there. The\n// message carries a path and nothing else — the host decides, on its own gesture bit,\n// whether to navigate (R3-1321).\nimport { sendMessage } from './sandboxUtils';\nimport { BUNDLE_LINK } from './generated/protocol';\nimport type { BundleLinkPayload } from './generated/protocol';\nimport { bundleRelativeTarget } from './bundleLinkPath';\n\n/**\n * Follow a link that leaves the current bundle.\n *\n * `href` is the link as the author wrote it; `fromEntry` is the bundle-relative path of\n * the document it appears in (e.g. `tickets/B-10.mdx`).\n *\n * - Returns `true` when the href resolves OUTSIDE the bundle: one `bundle-link` message\n * is posted to the host.\n * - Also returns `true`, posting nothing, for a link `bundleRelativeTarget` refuses: one\n * with a backslash or a percent-encoded dot segment in its path, or one that leaves the bundle with\n * a query, a second `#`, only `..` segments, or a segment the host would refuse once\n * decoded. The click is consumed and one `console.warn` names the reason. Do not\n * route it as before, because URL parsing would collapse its `..` into a wrong path\n * inside the bundle. Render it as a broken link instead.\n * - Returns `false`, posting nothing, for an external href, a bare anchor, or a target\n * inside the bundle. Route those as before.\n */\nexport function followBundleLink(href: string, fromEntry: string): boolean {\n let reason = '';\n const target = bundleRelativeTarget(href, fromEntry, (r) => {\n reason = r;\n });\n if (target === null || target === 'inside') return false;\n if (target === 'refused') {\n console.warn(\n `followBundleLink: not following ${JSON.stringify(href)} from ${JSON.stringify(fromEntry)}: ${reason}`,\n );\n return true;\n }\n const payload: BundleLinkPayload = target;\n sendMessage(BUNDLE_LINK, payload);\n return true;\n}\n"],"mappings":";AAOA,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAE5B,SAAS,4BAA4B;AAmB9B,SAAS,iBAAiB,MAAc,WAA4B;AACzE,MAAI,SAAS;AACb,QAAM,SAAS,qBAAqB,MAAM,WAAW,CAAC,MAAM;AAC1D,aAAS;AAAA,EACX,CAAC;AACD,MAAI,WAAW,QAAQ,WAAW,SAAU,QAAO;AACnD,MAAI,WAAW,WAAW;AACxB,YAAQ;AAAA,MACN,mCAAmC,KAAK,UAAU,IAAI,CAAC,SAAS,KAAK,UAAU,SAAS,CAAC,KAAK,MAAM;AAAA,IACtG;AACA,WAAO;AAAA,EACT;AACA,QAAM,UAA6B;AACnC,cAAY,aAAa,OAAO;AAChC,SAAO;AACT;","names":[]}
|
package/dist/index.cjs
CHANGED
|
@@ -21,6 +21,7 @@ var index_exports = {};
|
|
|
21
21
|
__export(index_exports, {
|
|
22
22
|
SafeInclude: () => import_SafeInclude.SafeInclude,
|
|
23
23
|
ScrollRestoration: () => import_ScrollRestoration.ScrollRestoration,
|
|
24
|
+
followBundleLink: () => import_followBundleLink.followBundleLink,
|
|
24
25
|
getInjectedMetadataEmitter: () => import_injectedBundler.getInjectedMetadataEmitter,
|
|
25
26
|
getInjectedMetadataSnapshot: () => import_injectedBundler.getInjectedMetadataSnapshot
|
|
26
27
|
});
|
|
@@ -33,6 +34,7 @@ var import_SafeInclude = require("./components/SafeInclude");
|
|
|
33
34
|
__reExport(index_exports, require("./sourceCache"), module.exports);
|
|
34
35
|
__reExport(index_exports, require("./components/MDXComponents"), module.exports);
|
|
35
36
|
__reExport(index_exports, require("./linkSpace"), module.exports);
|
|
37
|
+
var import_followBundleLink = require("./followBundleLink");
|
|
36
38
|
__reExport(index_exports, require("./bundle"), module.exports);
|
|
37
39
|
__reExport(index_exports, require("./corpus"), module.exports);
|
|
38
40
|
__reExport(index_exports, require("./components/MountImage"), module.exports);
|
|
@@ -98,6 +100,7 @@ var import_ScrollRestoration = require("./components/ScrollRestoration");
|
|
|
98
100
|
0 && (module.exports = {
|
|
99
101
|
SafeInclude,
|
|
100
102
|
ScrollRestoration,
|
|
103
|
+
followBundleLink,
|
|
101
104
|
getInjectedMetadataEmitter,
|
|
102
105
|
getInjectedMetadataSnapshot,
|
|
103
106
|
...require("./MDXProvider"),
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './MDXProvider';\nexport * from './routing';\nexport * from './boot';\nexport * from './components/Include';\n// Only the component is public. `stripFrontmatter`/`appMountRelative` are module-level\n// exports so they can be unit-tested directly, NOT public API — the SDK's surface is\n// backwards-compatible forever, so an internal helper exported for a test's convenience is a\n// permanent commitment made for the wrong reason.\nexport { SafeInclude } from './components/SafeInclude';\nexport * from './sourceCache';\nexport * from './components/MDXComponents';\nexport * from './linkSpace';\nexport * from './bundle';\n// Deprecated `Corpus*` spellings of the above (R3-482); see `src/corpus.ts`.\nexport * from './corpus';\nexport * from './components/MountImage';\nexport * from './components/Routes';\nexport * from './hooks';\n// R3-276: the supported way for a viewer app to provide its own metadata store,\n// replacing a wholesale re-provision of `TinkerableContext` in app code.\nexport * from './metadataSource';\n// The deprecated injected-bundler adapters, re-exported so their deprecation notices\n// are visible in the published docs (R3-278; the window only narrows).\nexport { getInjectedMetadataEmitter, getInjectedMetadataSnapshot } from './injectedBundler';\nexport * from './auth';\nexport * from './theme';\nexport * from './editorContext';\nexport * from './editor';\nexport * from './formFactor';\nexport * from './chromeState';\nexport * from './workspace';\nexport * from './hostAttention';\nexport * from './region';\n// R3-708 — the spaces mode's route channel and its one navigation verb.\nexport * from './spacesMode';\nexport * from './mounts';\nexport * from './analytics';\nexport * from './contribute';\nexport * from './catalog';\nexport * from './ipc';\nexport * from './dnd';\nexport * from './netFetch';\nexport * from './feed';\nexport * from './secrets';\nexport * from './recents'; // R3-485: the gated recent-projects read (page.home)\nexport * from './openRepository'; // R3-476: host-mediated open-in-a-new-tab (route:read)\nexport * from './openExternal'; // R3-619: host-brokered outward-link open (link:open)\nexport * from './openBundle'; // host-mediated open of a bundle in its own tab\nexport * from './llm';\nexport * from './diagnostics';\nexport * from './vcs';\nexport * from './onFsChange';\nexport * from './fs';\nexport * from './debug';\nexport * from './tasks';\nexport * from './launch';\nexport * from './runtime';\nexport * from './irMarkers';\nexport * from './ready';\nexport * from './loading';\nexport * from './dialog';\nexport * from './status';\nexport * from './protocolStream';\nexport * from './protocolDeadline';\nexport * from './sandboxTypes';\nexport * from './safeContent';\n// R3-489 (GROVE_AGENT_SPEC): the embedded-agent seam every app shares — the tool-use\n// loop ported from agent-demo (`runAgent` over the host chat slot), the MDX metadata\n// query tool, the headings index collector, the deixis context block, and the fence\n// for corpus-derived bytes entering a loop.\nexport * from './agentLoop';\nexport * from './agentSteering';\nexport * from './agentPause';\nexport * from './agentChatClient';\nexport * from './metadataQueryTool';\nexport * from './collectHeadings';\nexport * from './agentContext';\nexport * from './fence';\nexport * from './platformLink';\n// R3-627: the per-history-entry scratch, and the scroll restoration built on it —\n// Back lands where the reader left, for however many entries deep they go.\nexport * from './entryState';\nexport * from './useEntryState';\nexport * from './scrollRestore';\nexport { ScrollRestoration, type ScrollRestorationProps } from './components/ScrollRestoration';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAc,0BAAd;AACA,0BAAc,sBADd;AAEA,0BAAc,mBAFd;AAGA,0BAAc,iCAHd;AAQA,yBAA4B;AAC5B,0BAAc,0BATd;AAUA,0BAAc,uCAVd;AAWA,0BAAc,wBAXd;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './MDXProvider';\nexport * from './routing';\nexport * from './boot';\nexport * from './components/Include';\n// Only the component is public. `stripFrontmatter`/`appMountRelative` are module-level\n// exports so they can be unit-tested directly, NOT public API — the SDK's surface is\n// backwards-compatible forever, so an internal helper exported for a test's convenience is a\n// permanent commitment made for the wrong reason.\nexport { SafeInclude } from './components/SafeInclude';\nexport * from './sourceCache';\nexport * from './components/MDXComponents';\nexport * from './linkSpace';\n// R3-1324: a link that leaves its bundle is handed to the host (`bundle-link`).\nexport { followBundleLink } from './followBundleLink';\nexport * from './bundle';\n// Deprecated `Corpus*` spellings of the above (R3-482); see `src/corpus.ts`.\nexport * from './corpus';\nexport * from './components/MountImage';\nexport * from './components/Routes';\nexport * from './hooks';\n// R3-276: the supported way for a viewer app to provide its own metadata store,\n// replacing a wholesale re-provision of `TinkerableContext` in app code.\nexport * from './metadataSource';\n// The deprecated injected-bundler adapters, re-exported so their deprecation notices\n// are visible in the published docs (R3-278; the window only narrows).\nexport { getInjectedMetadataEmitter, getInjectedMetadataSnapshot } from './injectedBundler';\nexport * from './auth';\nexport * from './theme';\nexport * from './editorContext';\nexport * from './editor';\nexport * from './formFactor';\nexport * from './chromeState';\nexport * from './workspace';\nexport * from './hostAttention';\nexport * from './region';\n// R3-708 — the spaces mode's route channel and its one navigation verb.\nexport * from './spacesMode';\nexport * from './mounts';\nexport * from './analytics';\nexport * from './contribute';\nexport * from './catalog';\nexport * from './ipc';\nexport * from './dnd';\nexport * from './netFetch';\nexport * from './feed';\nexport * from './secrets';\nexport * from './recents'; // R3-485: the gated recent-projects read (page.home)\nexport * from './openRepository'; // R3-476: host-mediated open-in-a-new-tab (route:read)\nexport * from './openExternal'; // R3-619: host-brokered outward-link open (link:open)\nexport * from './openBundle'; // host-mediated open of a bundle in its own tab\nexport * from './llm';\nexport * from './diagnostics';\nexport * from './vcs';\nexport * from './onFsChange';\nexport * from './fs';\nexport * from './debug';\nexport * from './tasks';\nexport * from './launch';\nexport * from './runtime';\nexport * from './irMarkers';\nexport * from './ready';\nexport * from './loading';\nexport * from './dialog';\nexport * from './status';\nexport * from './protocolStream';\nexport * from './protocolDeadline';\nexport * from './sandboxTypes';\nexport * from './safeContent';\n// R3-489 (GROVE_AGENT_SPEC): the embedded-agent seam every app shares — the tool-use\n// loop ported from agent-demo (`runAgent` over the host chat slot), the MDX metadata\n// query tool, the headings index collector, the deixis context block, and the fence\n// for corpus-derived bytes entering a loop.\nexport * from './agentLoop';\nexport * from './agentSteering';\nexport * from './agentPause';\nexport * from './agentChatClient';\nexport * from './metadataQueryTool';\nexport * from './collectHeadings';\nexport * from './agentContext';\nexport * from './fence';\nexport * from './platformLink';\n// R3-627: the per-history-entry scratch, and the scroll restoration built on it —\n// Back lands where the reader left, for however many entries deep they go.\nexport * from './entryState';\nexport * from './useEntryState';\nexport * from './scrollRestore';\nexport { ScrollRestoration, type ScrollRestorationProps } from './components/ScrollRestoration';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAc,0BAAd;AACA,0BAAc,sBADd;AAEA,0BAAc,mBAFd;AAGA,0BAAc,iCAHd;AAQA,yBAA4B;AAC5B,0BAAc,0BATd;AAUA,0BAAc,uCAVd;AAWA,0BAAc,wBAXd;AAaA,8BAAiC;AACjC,0BAAc,qBAdd;AAgBA,0BAAc,qBAhBd;AAiBA,0BAAc,oCAjBd;AAkBA,0BAAc,gCAlBd;AAmBA,0BAAc,oBAnBd;AAsBA,0BAAc,6BAtBd;AAyBA,6BAAwE;AACxE,0BAAc,mBA1Bd;AA2BA,0BAAc,oBA3Bd;AA4BA,0BAAc,4BA5Bd;AA6BA,0BAAc,qBA7Bd;AA8BA,0BAAc,yBA9Bd;AA+BA,0BAAc,0BA/Bd;AAgCA,0BAAc,wBAhCd;AAiCA,0BAAc,4BAjCd;AAkCA,0BAAc,qBAlCd;AAoCA,0BAAc,yBApCd;AAqCA,0BAAc,qBArCd;AAsCA,0BAAc,wBAtCd;AAuCA,0BAAc,yBAvCd;AAwCA,0BAAc,sBAxCd;AAyCA,0BAAc,kBAzCd;AA0CA,0BAAc,kBA1Cd;AA2CA,0BAAc,uBA3Cd;AA4CA,0BAAc,mBA5Cd;AA6CA,0BAAc,sBA7Cd;AA8CA,0BAAc,sBA9Cd;AA+CA,0BAAc,6BA/Cd;AAgDA,0BAAc,2BAhDd;AAiDA,0BAAc,yBAjDd;AAkDA,0BAAc,kBAlDd;AAmDA,0BAAc,0BAnDd;AAoDA,0BAAc,kBApDd;AAqDA,0BAAc,yBArDd;AAsDA,0BAAc,iBAtDd;AAuDA,0BAAc,oBAvDd;AAwDA,0BAAc,oBAxDd;AAyDA,0BAAc,qBAzDd;AA0DA,0BAAc,sBA1Dd;AA2DA,0BAAc,wBA3Dd;AA4DA,0BAAc,oBA5Dd;AA6DA,0BAAc,sBA7Dd;AA8DA,0BAAc,qBA9Dd;AA+DA,0BAAc,qBA/Dd;AAgEA,0BAAc,6BAhEd;AAiEA,0BAAc,+BAjEd;AAkEA,0BAAc,2BAlEd;AAmEA,0BAAc,0BAnEd;AAwEA,0BAAc,wBAxEd;AAyEA,0BAAc,4BAzEd;AA0EA,0BAAc,yBA1Ed;AA2EA,0BAAc,8BA3Ed;AA4EA,0BAAc,gCA5Ed;AA6EA,0BAAc,8BA7Ed;AA8EA,0BAAc,2BA9Ed;AA+EA,0BAAc,oBA/Ed;AAgFA,0BAAc,2BAhFd;AAmFA,0BAAc,yBAnFd;AAoFA,0BAAc,4BApFd;AAqFA,0BAAc,4BArFd;AAsFA,+BAA+D;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -6,6 +6,7 @@ export { SafeInclude } from './components/SafeInclude.cjs';
|
|
|
6
6
|
export { SourceCache, SourceReader, createSourceCache } from './sourceCache.cjs';
|
|
7
7
|
export { DEFAULT_MDX_COMPONENTS } from './components/MDXComponents.cjs';
|
|
8
8
|
export { LinkSpaceContext } from './linkSpace.cjs';
|
|
9
|
+
export { followBundleLink } from './followBundleLink.cjs';
|
|
9
10
|
export { BundleContext, BundleEntry, BundleScope, BundleContext as CorpusContext, BundleEntry as CorpusEntry, BundleScope as CorpusScope, fromBundlePath, fromBundlePath as fromCorpusPath, toBundlePath, toBundlePath as toCorpusPath, useBundle, useBundleEntries, useBundleEntry, useBundle as useCorpus, useBundleEntries as useCorpusEntries, useBundleEntry as useCorpusEntry, useCurrentEntry } from './bundle.cjs';
|
|
10
11
|
export { MountImage, MountImageProps } from './components/MountImage.cjs';
|
|
11
12
|
export { Route, RouteProps, Routes } from './components/Routes.cjs';
|
|
@@ -35,7 +36,7 @@ export { RecentProject, clearRecentProjects, listRecentProjects } from './recent
|
|
|
35
36
|
export { OpenRepositoryError, OpenRepositoryErrorCode, RepositoryCoordinates, RepositoryReveal, openRepository } from './openRepository.cjs';
|
|
36
37
|
export { OpenExternalError, OpenExternalErrorCode, openExternal } from './openExternal.cjs';
|
|
37
38
|
export { OPEN_BUNDLE_REPLY_TIMEOUT_MS, OpenBundleError, OpenBundleErrorCode, OpenBundleTarget, openBundle } from './openBundle.cjs';
|
|
38
|
-
export { ChatDelta, ChatExecutor, ChatFeatures, ChatMessage, ChatProviderChoice, ChatProviderInfo, ChatProviderState, ChatRequest, ChatResult, ChatRole, ChatStopReason, ChatTierModels, ContentPart, ToolDef, chat, deriveChatProviderState, describeChat, describeChatState, normalizeProviderInfo, onChatProviderChange, onChatProviderStateChange, useChatProvider, useChatProviderState } from './llm.cjs';
|
|
39
|
+
export { ChatDelta, ChatExecutor, ChatFeatures, ChatMessage, ChatModelInfo, ChatProviderChoice, ChatProviderInfo, ChatProviderState, ChatRequest, ChatResult, ChatRole, ChatStopReason, ChatTierModels, ContentPart, EmbedRequest, EmbedResult, KindModelInfo, ToolDef, chat, deriveChatProviderState, describeChat, describeChatState, embed, normalizeProviderInfo, onChatProviderChange, onChatProviderStateChange, useChatProvider, useChatProviderState } from './llm.cjs';
|
|
39
40
|
export { BuildError, ConsoleEntry, ConsoleLevel, Diagnostics, DiagnosticsProvenance, getDiagnostics, onDiagnosticsChange, useDiagnostics } from './diagnostics.cjs';
|
|
40
41
|
export { BundleCommit, BundleHistoryError, REF_KINDS, VcsActionError, VcsAgentSession, VcsBranch, VcsChange, VcsDiffWarning, VcsPR, VcsState, VcsTarget, bundleCanWrite, bundleDiffPaths, bundleHead, bundleIsAncestor, bundleLog, bundleRead, getVcsState, onVcsStateChange, refreshDiff, refreshPRs, resetWorkingTree, useVcsState } from './vcs.cjs';
|
|
41
42
|
export { FsChange, MountChange, getFsChange, onFsChange, useFsChange } from './onFsChange.cjs';
|
|
@@ -73,6 +74,7 @@ export { HeadingAnchor } from './components/HeadingAnchor.cjs';
|
|
|
73
74
|
export { ImmediatelyRunGlobal, getHostRuntime } from './hostRuntime.cjs';
|
|
74
75
|
export { IncludeMode, IncludeModeContext, RenderExportedComponentContext, RenderFileContextType } from './components/includeContexts.cjs';
|
|
75
76
|
export { InternalLink, Link } from './components/Link.cjs';
|
|
77
|
+
export { ModelKind } from '@immediately-run/sandbox-protocol';
|
|
76
78
|
export { SDK_VERSION } from './version.cjs';
|
|
77
79
|
export { WikiLink } from './components/WikiLink.cjs';
|
|
78
80
|
import 'react';
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { SafeInclude } from './components/SafeInclude.js';
|
|
|
6
6
|
export { SourceCache, SourceReader, createSourceCache } from './sourceCache.js';
|
|
7
7
|
export { DEFAULT_MDX_COMPONENTS } from './components/MDXComponents.js';
|
|
8
8
|
export { LinkSpaceContext } from './linkSpace.js';
|
|
9
|
+
export { followBundleLink } from './followBundleLink.js';
|
|
9
10
|
export { BundleContext, BundleEntry, BundleScope, BundleContext as CorpusContext, BundleEntry as CorpusEntry, BundleScope as CorpusScope, fromBundlePath, fromBundlePath as fromCorpusPath, toBundlePath, toBundlePath as toCorpusPath, useBundle, useBundleEntries, useBundleEntry, useBundle as useCorpus, useBundleEntries as useCorpusEntries, useBundleEntry as useCorpusEntry, useCurrentEntry } from './bundle.js';
|
|
10
11
|
export { MountImage, MountImageProps } from './components/MountImage.js';
|
|
11
12
|
export { Route, RouteProps, Routes } from './components/Routes.js';
|
|
@@ -35,7 +36,7 @@ export { RecentProject, clearRecentProjects, listRecentProjects } from './recent
|
|
|
35
36
|
export { OpenRepositoryError, OpenRepositoryErrorCode, RepositoryCoordinates, RepositoryReveal, openRepository } from './openRepository.js';
|
|
36
37
|
export { OpenExternalError, OpenExternalErrorCode, openExternal } from './openExternal.js';
|
|
37
38
|
export { OPEN_BUNDLE_REPLY_TIMEOUT_MS, OpenBundleError, OpenBundleErrorCode, OpenBundleTarget, openBundle } from './openBundle.js';
|
|
38
|
-
export { ChatDelta, ChatExecutor, ChatFeatures, ChatMessage, ChatProviderChoice, ChatProviderInfo, ChatProviderState, ChatRequest, ChatResult, ChatRole, ChatStopReason, ChatTierModels, ContentPart, ToolDef, chat, deriveChatProviderState, describeChat, describeChatState, normalizeProviderInfo, onChatProviderChange, onChatProviderStateChange, useChatProvider, useChatProviderState } from './llm.js';
|
|
39
|
+
export { ChatDelta, ChatExecutor, ChatFeatures, ChatMessage, ChatModelInfo, ChatProviderChoice, ChatProviderInfo, ChatProviderState, ChatRequest, ChatResult, ChatRole, ChatStopReason, ChatTierModels, ContentPart, EmbedRequest, EmbedResult, KindModelInfo, ToolDef, chat, deriveChatProviderState, describeChat, describeChatState, embed, normalizeProviderInfo, onChatProviderChange, onChatProviderStateChange, useChatProvider, useChatProviderState } from './llm.js';
|
|
39
40
|
export { BuildError, ConsoleEntry, ConsoleLevel, Diagnostics, DiagnosticsProvenance, getDiagnostics, onDiagnosticsChange, useDiagnostics } from './diagnostics.js';
|
|
40
41
|
export { BundleCommit, BundleHistoryError, REF_KINDS, VcsActionError, VcsAgentSession, VcsBranch, VcsChange, VcsDiffWarning, VcsPR, VcsState, VcsTarget, bundleCanWrite, bundleDiffPaths, bundleHead, bundleIsAncestor, bundleLog, bundleRead, getVcsState, onVcsStateChange, refreshDiff, refreshPRs, resetWorkingTree, useVcsState } from './vcs.js';
|
|
41
42
|
export { FsChange, MountChange, getFsChange, onFsChange, useFsChange } from './onFsChange.js';
|
|
@@ -73,6 +74,7 @@ export { HeadingAnchor } from './components/HeadingAnchor.js';
|
|
|
73
74
|
export { ImmediatelyRunGlobal, getHostRuntime } from './hostRuntime.js';
|
|
74
75
|
export { IncludeMode, IncludeModeContext, RenderExportedComponentContext, RenderFileContextType } from './components/includeContexts.js';
|
|
75
76
|
export { InternalLink, Link } from './components/Link.js';
|
|
77
|
+
export { ModelKind } from '@immediately-run/sandbox-protocol';
|
|
76
78
|
export { SDK_VERSION } from './version.js';
|
|
77
79
|
export { WikiLink } from './components/WikiLink.js';
|
|
78
80
|
import 'react';
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import { SafeInclude } from "./components/SafeInclude.js";
|
|
|
7
7
|
export * from "./sourceCache.js";
|
|
8
8
|
export * from "./components/MDXComponents.js";
|
|
9
9
|
export * from "./linkSpace.js";
|
|
10
|
+
import { followBundleLink } from "./followBundleLink.js";
|
|
10
11
|
export * from "./bundle.js";
|
|
11
12
|
export * from "./corpus.js";
|
|
12
13
|
export * from "./components/MountImage.js";
|
|
@@ -71,6 +72,7 @@ import { ScrollRestoration } from "./components/ScrollRestoration.js";
|
|
|
71
72
|
export {
|
|
72
73
|
SafeInclude,
|
|
73
74
|
ScrollRestoration,
|
|
75
|
+
followBundleLink,
|
|
74
76
|
getInjectedMetadataEmitter,
|
|
75
77
|
getInjectedMetadataSnapshot
|
|
76
78
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './MDXProvider';\nexport * from './routing';\nexport * from './boot';\nexport * from './components/Include';\n// Only the component is public. `stripFrontmatter`/`appMountRelative` are module-level\n// exports so they can be unit-tested directly, NOT public API — the SDK's surface is\n// backwards-compatible forever, so an internal helper exported for a test's convenience is a\n// permanent commitment made for the wrong reason.\nexport { SafeInclude } from './components/SafeInclude';\nexport * from './sourceCache';\nexport * from './components/MDXComponents';\nexport * from './linkSpace';\nexport * from './bundle';\n// Deprecated `Corpus*` spellings of the above (R3-482); see `src/corpus.ts`.\nexport * from './corpus';\nexport * from './components/MountImage';\nexport * from './components/Routes';\nexport * from './hooks';\n// R3-276: the supported way for a viewer app to provide its own metadata store,\n// replacing a wholesale re-provision of `TinkerableContext` in app code.\nexport * from './metadataSource';\n// The deprecated injected-bundler adapters, re-exported so their deprecation notices\n// are visible in the published docs (R3-278; the window only narrows).\nexport { getInjectedMetadataEmitter, getInjectedMetadataSnapshot } from './injectedBundler';\nexport * from './auth';\nexport * from './theme';\nexport * from './editorContext';\nexport * from './editor';\nexport * from './formFactor';\nexport * from './chromeState';\nexport * from './workspace';\nexport * from './hostAttention';\nexport * from './region';\n// R3-708 — the spaces mode's route channel and its one navigation verb.\nexport * from './spacesMode';\nexport * from './mounts';\nexport * from './analytics';\nexport * from './contribute';\nexport * from './catalog';\nexport * from './ipc';\nexport * from './dnd';\nexport * from './netFetch';\nexport * from './feed';\nexport * from './secrets';\nexport * from './recents'; // R3-485: the gated recent-projects read (page.home)\nexport * from './openRepository'; // R3-476: host-mediated open-in-a-new-tab (route:read)\nexport * from './openExternal'; // R3-619: host-brokered outward-link open (link:open)\nexport * from './openBundle'; // host-mediated open of a bundle in its own tab\nexport * from './llm';\nexport * from './diagnostics';\nexport * from './vcs';\nexport * from './onFsChange';\nexport * from './fs';\nexport * from './debug';\nexport * from './tasks';\nexport * from './launch';\nexport * from './runtime';\nexport * from './irMarkers';\nexport * from './ready';\nexport * from './loading';\nexport * from './dialog';\nexport * from './status';\nexport * from './protocolStream';\nexport * from './protocolDeadline';\nexport * from './sandboxTypes';\nexport * from './safeContent';\n// R3-489 (GROVE_AGENT_SPEC): the embedded-agent seam every app shares — the tool-use\n// loop ported from agent-demo (`runAgent` over the host chat slot), the MDX metadata\n// query tool, the headings index collector, the deixis context block, and the fence\n// for corpus-derived bytes entering a loop.\nexport * from './agentLoop';\nexport * from './agentSteering';\nexport * from './agentPause';\nexport * from './agentChatClient';\nexport * from './metadataQueryTool';\nexport * from './collectHeadings';\nexport * from './agentContext';\nexport * from './fence';\nexport * from './platformLink';\n// R3-627: the per-history-entry scratch, and the scroll restoration built on it —\n// Back lands where the reader left, for however many entries deep they go.\nexport * from './entryState';\nexport * from './useEntryState';\nexport * from './scrollRestore';\nexport { ScrollRestoration, type ScrollRestorationProps } from './components/ScrollRestoration';\n"],"mappings":";AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAKd,SAAS,mBAAmB;AAC5B,cAAc;AACd,cAAc;AACd,cAAc;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './MDXProvider';\nexport * from './routing';\nexport * from './boot';\nexport * from './components/Include';\n// Only the component is public. `stripFrontmatter`/`appMountRelative` are module-level\n// exports so they can be unit-tested directly, NOT public API — the SDK's surface is\n// backwards-compatible forever, so an internal helper exported for a test's convenience is a\n// permanent commitment made for the wrong reason.\nexport { SafeInclude } from './components/SafeInclude';\nexport * from './sourceCache';\nexport * from './components/MDXComponents';\nexport * from './linkSpace';\n// R3-1324: a link that leaves its bundle is handed to the host (`bundle-link`).\nexport { followBundleLink } from './followBundleLink';\nexport * from './bundle';\n// Deprecated `Corpus*` spellings of the above (R3-482); see `src/corpus.ts`.\nexport * from './corpus';\nexport * from './components/MountImage';\nexport * from './components/Routes';\nexport * from './hooks';\n// R3-276: the supported way for a viewer app to provide its own metadata store,\n// replacing a wholesale re-provision of `TinkerableContext` in app code.\nexport * from './metadataSource';\n// The deprecated injected-bundler adapters, re-exported so their deprecation notices\n// are visible in the published docs (R3-278; the window only narrows).\nexport { getInjectedMetadataEmitter, getInjectedMetadataSnapshot } from './injectedBundler';\nexport * from './auth';\nexport * from './theme';\nexport * from './editorContext';\nexport * from './editor';\nexport * from './formFactor';\nexport * from './chromeState';\nexport * from './workspace';\nexport * from './hostAttention';\nexport * from './region';\n// R3-708 — the spaces mode's route channel and its one navigation verb.\nexport * from './spacesMode';\nexport * from './mounts';\nexport * from './analytics';\nexport * from './contribute';\nexport * from './catalog';\nexport * from './ipc';\nexport * from './dnd';\nexport * from './netFetch';\nexport * from './feed';\nexport * from './secrets';\nexport * from './recents'; // R3-485: the gated recent-projects read (page.home)\nexport * from './openRepository'; // R3-476: host-mediated open-in-a-new-tab (route:read)\nexport * from './openExternal'; // R3-619: host-brokered outward-link open (link:open)\nexport * from './openBundle'; // host-mediated open of a bundle in its own tab\nexport * from './llm';\nexport * from './diagnostics';\nexport * from './vcs';\nexport * from './onFsChange';\nexport * from './fs';\nexport * from './debug';\nexport * from './tasks';\nexport * from './launch';\nexport * from './runtime';\nexport * from './irMarkers';\nexport * from './ready';\nexport * from './loading';\nexport * from './dialog';\nexport * from './status';\nexport * from './protocolStream';\nexport * from './protocolDeadline';\nexport * from './sandboxTypes';\nexport * from './safeContent';\n// R3-489 (GROVE_AGENT_SPEC): the embedded-agent seam every app shares — the tool-use\n// loop ported from agent-demo (`runAgent` over the host chat slot), the MDX metadata\n// query tool, the headings index collector, the deixis context block, and the fence\n// for corpus-derived bytes entering a loop.\nexport * from './agentLoop';\nexport * from './agentSteering';\nexport * from './agentPause';\nexport * from './agentChatClient';\nexport * from './metadataQueryTool';\nexport * from './collectHeadings';\nexport * from './agentContext';\nexport * from './fence';\nexport * from './platformLink';\n// R3-627: the per-history-entry scratch, and the scroll restoration built on it —\n// Back lands where the reader left, for however many entries deep they go.\nexport * from './entryState';\nexport * from './useEntryState';\nexport * from './scrollRestore';\nexport { ScrollRestoration, type ScrollRestorationProps } from './components/ScrollRestoration';\n"],"mappings":";AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAKd,SAAS,mBAAmB;AAC5B,cAAc;AACd,cAAc;AACd,cAAc;AAEd,SAAS,wBAAwB;AACjC,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AAGd,SAAS,4BAA4B,mCAAmC;AACxE,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAKd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,yBAAsD;","names":[]}
|