@immediately-run/sdk 0.38.0 → 0.40.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.
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.d.cts +2 -2
- package/dist/catalog.d.ts +2 -2
- package/dist/catalog.js.map +1 -1
- package/dist/components/Include.cjs +22 -4
- package/dist/components/Include.cjs.map +1 -1
- package/dist/components/Include.d.cts +21 -10
- package/dist/components/Include.d.ts +21 -10
- package/dist/components/Include.js +21 -4
- package/dist/components/Include.js.map +1 -1
- package/dist/components/MountImage.d.cts +1 -0
- package/dist/components/MountImage.d.ts +1 -0
- package/dist/components/SafeInclude.cjs +89 -0
- package/dist/components/SafeInclude.cjs.map +1 -0
- package/dist/components/SafeInclude.d.cts +26 -0
- package/dist/components/SafeInclude.d.ts +26 -0
- package/dist/components/SafeInclude.js +64 -0
- package/dist/components/SafeInclude.js.map +1 -0
- package/dist/components/includeContexts.cjs +33 -0
- package/dist/components/includeContexts.cjs.map +1 -0
- package/dist/components/includeContexts.d.cts +22 -0
- package/dist/components/includeContexts.d.ts +22 -0
- package/dist/components/includeContexts.js +9 -0
- package/dist/components/includeContexts.js.map +1 -0
- package/dist/fs.d.cts +1 -0
- package/dist/fs.d.ts +1 -0
- package/dist/generated/spaces.cjs +62 -0
- package/dist/generated/spaces.cjs.map +1 -0
- package/dist/generated/spaces.d.cts +121 -0
- package/dist/generated/spaces.d.ts +121 -0
- package/dist/generated/spaces.js +31 -0
- package/dist/generated/spaces.js.map +1 -0
- package/dist/hooks.d.cts +1 -0
- package/dist/hooks.d.ts +1 -0
- package/dist/index.cjs +11 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/mounts.cjs +10 -26
- package/dist/mounts.cjs.map +1 -1
- package/dist/mounts.d.cts +3 -78
- package/dist/mounts.d.ts +3 -78
- package/dist/mounts.js +11 -17
- package/dist/mounts.js.map +1 -1
- package/dist/sourceCache.cjs +48 -0
- package/dist/sourceCache.cjs.map +1 -0
- package/dist/sourceCache.d.cts +12 -0
- package/dist/sourceCache.d.ts +12 -0
- package/dist/sourceCache.js +25 -0
- package/dist/sourceCache.js.map +1 -0
- 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 -2
package/dist/catalog.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/catalog.ts"],"sourcesContent":["// The method catalog (UI_AS_APPS_SPEC §5.5) — the app's own grant-filtered RPC\n// surface, and a generic way to call it. The host advertises exactly the methods\n// this app may invoke (MCP-tool-shaped); `invoke()` calls one by its catalog name.\n// Handing the catalog to an embedded agent as its tool list confines the agent to\n// the app's authority (agent sandboxing falls out of the capability model, §5.9).\nimport { protocolRequest, sendMessage, addListener } from './sandboxUtils';\nimport type { StreamFrame, StreamTransport } from './protocolStream';\nimport { consumeStream } from './protocolStream';\nimport { createPushChannel } from './pushChannel';\n\n/** One advertised method, as the host generated it from its gate table. */\nexport interface ApiMethod {\n /** Catalog name, `protocol-` stripped — e.g. `spaces:
|
|
1
|
+
{"version":3,"sources":["../src/catalog.ts"],"sourcesContent":["// The method catalog (UI_AS_APPS_SPEC §5.5) — the app's own grant-filtered RPC\n// surface, and a generic way to call it. The host advertises exactly the methods\n// this app may invoke (MCP-tool-shaped); `invoke()` calls one by its catalog name.\n// Handing the catalog to an embedded agent as its tool list confines the agent to\n// the app's authority (agent sandboxing falls out of the capability model, §5.9).\nimport { protocolRequest, sendMessage, addListener } from './sandboxUtils';\nimport type { StreamFrame, StreamTransport } from './protocolStream';\nimport { consumeStream } from './protocolStream';\nimport { createPushChannel } from './pushChannel';\n\n/** One advertised method, as the host generated it from its gate table. */\nexport interface ApiMethod {\n /** Catalog name, `protocol-` stripped — e.g. `spaces:invite`, `contribute:run`. */\n name: string;\n /** The capability this method requires (already held — it's in your catalog). */\n capability: string;\n /** True when the method STREAMS (use {@link invokeStream}) vs. single-reply. */\n stream?: boolean;\n /**\n * JSON Schema for the method's single object argument, when the host declares one.\n * Self-describes the call so a catalog-as-tools bridge (an embedded agent) can\n * advertise the real param shape — e.g. that `authoring:typecheck` takes a nested\n * `{ files: [{ path, content }] }` array — instead of a permissive \"any object\".\n * Absent for methods the host advertises without a schema.\n */\n paramsSchema?: Record<string, unknown>;\n}\n\n// `scheme:method` → ['scheme', 'method'] (the wire protocol is `protocol-scheme`).\nconst split = (name: string): [string, string] => {\n const i = name.indexOf(':');\n if (i <= 0) throw new Error(`invalid catalog method name: ${name}`);\n return [name.slice(0, i), name.slice(i + 1)];\n};\n\n/**\n * Call a catalog method by name — `invoke('spaces:invite', { spaceId, login, role })`.\n * A thin generic over the host protocol: the host validates params and gates the\n * call (an un-granted method → `forbidden`, even if you name it directly). For a\n * STREAMING method (`ApiMethod.stream`), use {@link invokeStream}.\n */\nexport const invoke = async <T = unknown>(\n name: string,\n params: Record<string, unknown> = {},\n): Promise<T> => {\n const [scheme, method] = split(name);\n // The host replies with an `{ ok, data } | { ok:false, code }` envelope; unwrap\n // it and THROW on refusal (a `.code` like `forbidden` for an off-catalog call)\n // so callers — and any agent driving `invoke` — see the gate's verdict.\n const res = (await protocolRequest(scheme, method, [params])) as\n | { ok: true; data: unknown }\n | { ok: false; code?: string; message?: string }\n | undefined;\n if (!res || res.ok !== true) {\n const err = new Error(res?.message ?? `${name} failed`) as Error & { code?: string };\n err.code = res?.code ?? 'unknown';\n throw err;\n }\n return res.data as T;\n};\n\n// Stream transport over the resolver (SDK_PACKAGING_SPEC §4) — sendMessage /\n// addListener route through `transport()` (injected bundler messageBus or the §4\n// global), never `bundler.messageBus` directly.\nconst streamTransport: StreamTransport = {\n send: (msg) => sendMessage(msg.type, msg as unknown as Record<string, unknown>),\n subscribe: (type, handler) =>\n addListener(type, (msg) => handler(msg as { msgId?: number; stream?: StreamFrame })),\n // Early-cancel: route a `{type, msgId, cancel:true}` frame back to the host so it\n // aborts the in-flight generation (and, for `llm:chat`, stops billing) — §3.3.\n cancel: (msg) => sendMessage(msg.type, msg as unknown as Record<string, unknown>),\n};\n\n/** Call a STREAMING catalog method by name, yielding its events. Pass `signal` to\n * abort mid-stream: the host stops generating and (for `llm:chat`) stops billing. */\nexport function invokeStream<T = unknown, R = unknown>(\n name: string,\n params: Record<string, unknown> = {},\n signal?: AbortSignal,\n): AsyncGenerator<T, R, void> {\n const [scheme, method] = split(name);\n return consumeStream<T, R>(streamTransport, `protocol-${scheme}`, method, [params], undefined, signal);\n}\n\n// The catalog list is read over the transport (§4): the host pushes `api-catalog`\n// and answers `request-api-catalog` with this app's grant-filtered methods (wire\n// format: site-main channelBridge.ts).\nconst channel = createPushChannel<ApiMethod[]>({\n pushType: 'api-catalog',\n requestType: 'request-api-catalog',\n initial: [],\n parse: (msg) => (Array.isArray(msg.methods) ? (msg.methods as ApiMethod[]) : undefined),\n});\n\n/** The methods this app may call (grant-filtered, §5.5). Poll for a one-off read;\n * use {@link onCatalogChange} / {@link useCatalog} to react. */\nexport const getCatalog = (): ApiMethod[] => channel.get();\n\n/** Subscribe to catalog changes (e.g. a grant added/revoked). Invoked immediately\n * with the current catalog, then on every change. Returns an unsubscribe fn. */\nexport const onCatalogChange = (listener: (catalog: ApiMethod[]) => void): (() => void) =>\n channel.onChange(listener);\n\n/** React hook returning this app's method catalog, re-rendering on change. Hand\n * it to an embedded agent as its tool list to confine the agent to the app's\n * authority (§5.9). */\nexport const useCatalog = (): ApiMethod[] => channel.use();\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,0BAA0D;AAE1D,4BAA8B;AAC9B,yBAAkC;AAqBlC,MAAM,QAAQ,CAAC,SAAmC;AAChD,QAAM,IAAI,KAAK,QAAQ,GAAG;AAC1B,MAAI,KAAK,EAAG,OAAM,IAAI,MAAM,gCAAgC,IAAI,EAAE;AAClE,SAAO,CAAC,KAAK,MAAM,GAAG,CAAC,GAAG,KAAK,MAAM,IAAI,CAAC,CAAC;AAC7C;AAQO,MAAM,SAAS,OACpB,MACA,SAAkC,CAAC,MACpB;AACf,QAAM,CAAC,QAAQ,MAAM,IAAI,MAAM,IAAI;AAInC,QAAM,MAAO,UAAM,qCAAgB,QAAQ,QAAQ,CAAC,MAAM,CAAC;AAI3D,MAAI,CAAC,OAAO,IAAI,OAAO,MAAM;AAC3B,UAAM,MAAM,IAAI,MAAM,KAAK,WAAW,GAAG,IAAI,SAAS;AACtD,QAAI,OAAO,KAAK,QAAQ;AACxB,UAAM;AAAA,EACR;AACA,SAAO,IAAI;AACb;AAKA,MAAM,kBAAmC;AAAA,EACvC,MAAM,CAAC,YAAQ,iCAAY,IAAI,MAAM,GAAyC;AAAA,EAC9E,WAAW,CAAC,MAAM,gBAChB,iCAAY,MAAM,CAAC,QAAQ,QAAQ,GAA+C,CAAC;AAAA;AAAA;AAAA,EAGrF,QAAQ,CAAC,YAAQ,iCAAY,IAAI,MAAM,GAAyC;AAClF;AAIO,SAAS,aACd,MACA,SAAkC,CAAC,GACnC,QAC4B;AAC5B,QAAM,CAAC,QAAQ,MAAM,IAAI,MAAM,IAAI;AACnC,aAAO,qCAAoB,iBAAiB,YAAY,MAAM,IAAI,QAAQ,CAAC,MAAM,GAAG,QAAW,MAAM;AACvG;AAKA,MAAM,cAAU,sCAA+B;AAAA,EAC7C,UAAU;AAAA,EACV,aAAa;AAAA,EACb,SAAS,CAAC;AAAA,EACV,OAAO,CAAC,QAAS,MAAM,QAAQ,IAAI,OAAO,IAAK,IAAI,UAA0B;AAC/E,CAAC;AAIM,MAAM,aAAa,MAAmB,QAAQ,IAAI;AAIlD,MAAM,kBAAkB,CAAC,aAC9B,QAAQ,SAAS,QAAQ;AAKpB,MAAM,aAAa,MAAmB,QAAQ,IAAI;","names":[]}
|
package/dist/catalog.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** One advertised method, as the host generated it from its gate table. */
|
|
2
2
|
interface ApiMethod {
|
|
3
|
-
/** Catalog name, `protocol-` stripped — e.g. `spaces:
|
|
3
|
+
/** Catalog name, `protocol-` stripped — e.g. `spaces:invite`, `contribute:run`. */
|
|
4
4
|
name: string;
|
|
5
5
|
/** The capability this method requires (already held — it's in your catalog). */
|
|
6
6
|
capability: string;
|
|
@@ -16,7 +16,7 @@ interface ApiMethod {
|
|
|
16
16
|
paramsSchema?: Record<string, unknown>;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* Call a catalog method by name — `invoke('spaces:
|
|
19
|
+
* Call a catalog method by name — `invoke('spaces:invite', { spaceId, login, role })`.
|
|
20
20
|
* A thin generic over the host protocol: the host validates params and gates the
|
|
21
21
|
* call (an un-granted method → `forbidden`, even if you name it directly). For a
|
|
22
22
|
* STREAMING method (`ApiMethod.stream`), use {@link invokeStream}.
|
package/dist/catalog.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** One advertised method, as the host generated it from its gate table. */
|
|
2
2
|
interface ApiMethod {
|
|
3
|
-
/** Catalog name, `protocol-` stripped — e.g. `spaces:
|
|
3
|
+
/** Catalog name, `protocol-` stripped — e.g. `spaces:invite`, `contribute:run`. */
|
|
4
4
|
name: string;
|
|
5
5
|
/** The capability this method requires (already held — it's in your catalog). */
|
|
6
6
|
capability: string;
|
|
@@ -16,7 +16,7 @@ interface ApiMethod {
|
|
|
16
16
|
paramsSchema?: Record<string, unknown>;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* Call a catalog method by name — `invoke('spaces:
|
|
19
|
+
* Call a catalog method by name — `invoke('spaces:invite', { spaceId, login, role })`.
|
|
20
20
|
* A thin generic over the host protocol: the host validates params and gates the
|
|
21
21
|
* call (an un-granted method → `forbidden`, even if you name it directly). For a
|
|
22
22
|
* STREAMING method (`ApiMethod.stream`), use {@link invokeStream}.
|
package/dist/catalog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/catalog.ts"],"sourcesContent":["// The method catalog (UI_AS_APPS_SPEC §5.5) — the app's own grant-filtered RPC\n// surface, and a generic way to call it. The host advertises exactly the methods\n// this app may invoke (MCP-tool-shaped); `invoke()` calls one by its catalog name.\n// Handing the catalog to an embedded agent as its tool list confines the agent to\n// the app's authority (agent sandboxing falls out of the capability model, §5.9).\nimport { protocolRequest, sendMessage, addListener } from './sandboxUtils';\nimport type { StreamFrame, StreamTransport } from './protocolStream';\nimport { consumeStream } from './protocolStream';\nimport { createPushChannel } from './pushChannel';\n\n/** One advertised method, as the host generated it from its gate table. */\nexport interface ApiMethod {\n /** Catalog name, `protocol-` stripped — e.g. `spaces:
|
|
1
|
+
{"version":3,"sources":["../src/catalog.ts"],"sourcesContent":["// The method catalog (UI_AS_APPS_SPEC §5.5) — the app's own grant-filtered RPC\n// surface, and a generic way to call it. The host advertises exactly the methods\n// this app may invoke (MCP-tool-shaped); `invoke()` calls one by its catalog name.\n// Handing the catalog to an embedded agent as its tool list confines the agent to\n// the app's authority (agent sandboxing falls out of the capability model, §5.9).\nimport { protocolRequest, sendMessage, addListener } from './sandboxUtils';\nimport type { StreamFrame, StreamTransport } from './protocolStream';\nimport { consumeStream } from './protocolStream';\nimport { createPushChannel } from './pushChannel';\n\n/** One advertised method, as the host generated it from its gate table. */\nexport interface ApiMethod {\n /** Catalog name, `protocol-` stripped — e.g. `spaces:invite`, `contribute:run`. */\n name: string;\n /** The capability this method requires (already held — it's in your catalog). */\n capability: string;\n /** True when the method STREAMS (use {@link invokeStream}) vs. single-reply. */\n stream?: boolean;\n /**\n * JSON Schema for the method's single object argument, when the host declares one.\n * Self-describes the call so a catalog-as-tools bridge (an embedded agent) can\n * advertise the real param shape — e.g. that `authoring:typecheck` takes a nested\n * `{ files: [{ path, content }] }` array — instead of a permissive \"any object\".\n * Absent for methods the host advertises without a schema.\n */\n paramsSchema?: Record<string, unknown>;\n}\n\n// `scheme:method` → ['scheme', 'method'] (the wire protocol is `protocol-scheme`).\nconst split = (name: string): [string, string] => {\n const i = name.indexOf(':');\n if (i <= 0) throw new Error(`invalid catalog method name: ${name}`);\n return [name.slice(0, i), name.slice(i + 1)];\n};\n\n/**\n * Call a catalog method by name — `invoke('spaces:invite', { spaceId, login, role })`.\n * A thin generic over the host protocol: the host validates params and gates the\n * call (an un-granted method → `forbidden`, even if you name it directly). For a\n * STREAMING method (`ApiMethod.stream`), use {@link invokeStream}.\n */\nexport const invoke = async <T = unknown>(\n name: string,\n params: Record<string, unknown> = {},\n): Promise<T> => {\n const [scheme, method] = split(name);\n // The host replies with an `{ ok, data } | { ok:false, code }` envelope; unwrap\n // it and THROW on refusal (a `.code` like `forbidden` for an off-catalog call)\n // so callers — and any agent driving `invoke` — see the gate's verdict.\n const res = (await protocolRequest(scheme, method, [params])) as\n | { ok: true; data: unknown }\n | { ok: false; code?: string; message?: string }\n | undefined;\n if (!res || res.ok !== true) {\n const err = new Error(res?.message ?? `${name} failed`) as Error & { code?: string };\n err.code = res?.code ?? 'unknown';\n throw err;\n }\n return res.data as T;\n};\n\n// Stream transport over the resolver (SDK_PACKAGING_SPEC §4) — sendMessage /\n// addListener route through `transport()` (injected bundler messageBus or the §4\n// global), never `bundler.messageBus` directly.\nconst streamTransport: StreamTransport = {\n send: (msg) => sendMessage(msg.type, msg as unknown as Record<string, unknown>),\n subscribe: (type, handler) =>\n addListener(type, (msg) => handler(msg as { msgId?: number; stream?: StreamFrame })),\n // Early-cancel: route a `{type, msgId, cancel:true}` frame back to the host so it\n // aborts the in-flight generation (and, for `llm:chat`, stops billing) — §3.3.\n cancel: (msg) => sendMessage(msg.type, msg as unknown as Record<string, unknown>),\n};\n\n/** Call a STREAMING catalog method by name, yielding its events. Pass `signal` to\n * abort mid-stream: the host stops generating and (for `llm:chat`) stops billing. */\nexport function invokeStream<T = unknown, R = unknown>(\n name: string,\n params: Record<string, unknown> = {},\n signal?: AbortSignal,\n): AsyncGenerator<T, R, void> {\n const [scheme, method] = split(name);\n return consumeStream<T, R>(streamTransport, `protocol-${scheme}`, method, [params], undefined, signal);\n}\n\n// The catalog list is read over the transport (§4): the host pushes `api-catalog`\n// and answers `request-api-catalog` with this app's grant-filtered methods (wire\n// format: site-main channelBridge.ts).\nconst channel = createPushChannel<ApiMethod[]>({\n pushType: 'api-catalog',\n requestType: 'request-api-catalog',\n initial: [],\n parse: (msg) => (Array.isArray(msg.methods) ? (msg.methods as ApiMethod[]) : undefined),\n});\n\n/** The methods this app may call (grant-filtered, §5.5). Poll for a one-off read;\n * use {@link onCatalogChange} / {@link useCatalog} to react. */\nexport const getCatalog = (): ApiMethod[] => channel.get();\n\n/** Subscribe to catalog changes (e.g. a grant added/revoked). Invoked immediately\n * with the current catalog, then on every change. Returns an unsubscribe fn. */\nexport const onCatalogChange = (listener: (catalog: ApiMethod[]) => void): (() => void) =>\n channel.onChange(listener);\n\n/** React hook returning this app's method catalog, re-rendering on change. Hand\n * it to an embedded agent as its tool list to confine the agent to the app's\n * authority (§5.9). */\nexport const useCatalog = (): ApiMethod[] => channel.use();\n"],"mappings":";AAKA,SAAS,iBAAiB,aAAa,mBAAmB;AAE1D,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB;AAqBlC,MAAM,QAAQ,CAAC,SAAmC;AAChD,QAAM,IAAI,KAAK,QAAQ,GAAG;AAC1B,MAAI,KAAK,EAAG,OAAM,IAAI,MAAM,gCAAgC,IAAI,EAAE;AAClE,SAAO,CAAC,KAAK,MAAM,GAAG,CAAC,GAAG,KAAK,MAAM,IAAI,CAAC,CAAC;AAC7C;AAQO,MAAM,SAAS,OACpB,MACA,SAAkC,CAAC,MACpB;AACf,QAAM,CAAC,QAAQ,MAAM,IAAI,MAAM,IAAI;AAInC,QAAM,MAAO,MAAM,gBAAgB,QAAQ,QAAQ,CAAC,MAAM,CAAC;AAI3D,MAAI,CAAC,OAAO,IAAI,OAAO,MAAM;AAC3B,UAAM,MAAM,IAAI,MAAM,KAAK,WAAW,GAAG,IAAI,SAAS;AACtD,QAAI,OAAO,KAAK,QAAQ;AACxB,UAAM;AAAA,EACR;AACA,SAAO,IAAI;AACb;AAKA,MAAM,kBAAmC;AAAA,EACvC,MAAM,CAAC,QAAQ,YAAY,IAAI,MAAM,GAAyC;AAAA,EAC9E,WAAW,CAAC,MAAM,YAChB,YAAY,MAAM,CAAC,QAAQ,QAAQ,GAA+C,CAAC;AAAA;AAAA;AAAA,EAGrF,QAAQ,CAAC,QAAQ,YAAY,IAAI,MAAM,GAAyC;AAClF;AAIO,SAAS,aACd,MACA,SAAkC,CAAC,GACnC,QAC4B;AAC5B,QAAM,CAAC,QAAQ,MAAM,IAAI,MAAM,IAAI;AACnC,SAAO,cAAoB,iBAAiB,YAAY,MAAM,IAAI,QAAQ,CAAC,MAAM,GAAG,QAAW,MAAM;AACvG;AAKA,MAAM,UAAU,kBAA+B;AAAA,EAC7C,UAAU;AAAA,EACV,aAAa;AAAA,EACb,SAAS,CAAC;AAAA,EACV,OAAO,CAAC,QAAS,MAAM,QAAQ,IAAI,OAAO,IAAK,IAAI,UAA0B;AAC/E,CAAC;AAIM,MAAM,aAAa,MAAmB,QAAQ,IAAI;AAIlD,MAAM,kBAAkB,CAAC,aAC9B,QAAQ,SAAS,QAAQ;AAKpB,MAAM,aAAa,MAAmB,QAAQ,IAAI;","names":[]}
|
|
@@ -19,8 +19,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var Include_exports = {};
|
|
20
20
|
__export(Include_exports, {
|
|
21
21
|
Include: () => Include,
|
|
22
|
+
IncludeModeContext: () => import_includeContexts2.IncludeModeContext,
|
|
22
23
|
RenderExportedComponent: () => RenderExportedComponent,
|
|
23
|
-
RenderExportedComponentContext: () => RenderExportedComponentContext
|
|
24
|
+
RenderExportedComponentContext: () => import_includeContexts2.RenderExportedComponentContext
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(Include_exports);
|
|
26
27
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -28,29 +29,46 @@ var import_react = require("react");
|
|
|
28
29
|
var import_react_error_boundary = require("react-error-boundary");
|
|
29
30
|
var import_moduleCache = require("../moduleCache");
|
|
30
31
|
var import_defaults = require("./defaults");
|
|
31
|
-
|
|
32
|
+
var import_includeContexts = require("./includeContexts");
|
|
33
|
+
var import_SafeInclude = require("./SafeInclude");
|
|
34
|
+
var import_includeContexts2 = require("./includeContexts");
|
|
32
35
|
const RenderExportedComponent = ({
|
|
33
36
|
evaluationContextPromise,
|
|
34
37
|
exportedSymbol = "default"
|
|
35
38
|
}) => {
|
|
36
39
|
const evaluationContext = (0, import_react.use)(evaluationContextPromise);
|
|
37
40
|
const Component = exportedSymbol === "*" ? evaluationContext.exports : evaluationContext.exports[exportedSymbol];
|
|
38
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RenderExportedComponentContext, { value: { evaluationContext }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}) });
|
|
41
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_includeContexts.RenderExportedComponentContext, { value: { evaluationContext }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}) });
|
|
39
42
|
};
|
|
40
43
|
const Include = ({
|
|
41
44
|
filename,
|
|
42
45
|
exportedSymbol = "default",
|
|
43
46
|
LoadingComponent = import_defaults.defaultLoadingComponent,
|
|
44
47
|
ErrorComponent = import_defaults.defaultErrorComponent,
|
|
45
|
-
baseModule
|
|
48
|
+
baseModule,
|
|
49
|
+
mode,
|
|
50
|
+
components
|
|
46
51
|
}) => {
|
|
52
|
+
const contextMode = (0, import_react.use)(import_includeContexts.IncludeModeContext);
|
|
47
53
|
const moduleCache = (0, import_react.use)(import_moduleCache.ModuleCacheContext);
|
|
54
|
+
if ((mode ?? contextMode) === "interpreted") {
|
|
55
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
56
|
+
import_SafeInclude.SafeInclude,
|
|
57
|
+
{
|
|
58
|
+
filename,
|
|
59
|
+
components,
|
|
60
|
+
LoadingComponent,
|
|
61
|
+
ErrorComponent
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
}
|
|
48
65
|
const evaluationContextPromise = moduleCache.getEvaluationContext(filename, baseModule ?? module);
|
|
49
66
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_error_boundary.ErrorBoundary, { fallbackRender: ErrorComponent, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingComponent, {}), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RenderExportedComponent, { evaluationContextPromise, exportedSymbol }) }) });
|
|
50
67
|
};
|
|
51
68
|
// Annotate the CommonJS export names for ESM import in node:
|
|
52
69
|
0 && (module.exports = {
|
|
53
70
|
Include,
|
|
71
|
+
IncludeModeContext,
|
|
54
72
|
RenderExportedComponent,
|
|
55
73
|
RenderExportedComponentContext
|
|
56
74
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Include.tsx"],"sourcesContent":["import { Suspense,
|
|
1
|
+
{"version":3,"sources":["../../src/components/Include.tsx"],"sourcesContent":["import { Suspense, use } from 'react';\nimport { ErrorBoundary } from 'react-error-boundary';\n\nimport { ModuleCacheContext } from '../moduleCache';\nimport { EvaluationContext } from '../sandboxTypes';\nimport { defaultErrorComponent, defaultLoadingComponent } from './defaults';\nimport { IncludeModeContext, RenderExportedComponentContext, type IncludeMode } from './includeContexts';\nimport { SafeInclude } from './SafeInclude';\n\n// The contexts live in `./includeContexts` so `Include` and `SafeInclude` do not import each\n// other (`check:circular`); re-exported here because this is the public entry point and the\n// import path must not change.\nexport { IncludeModeContext, RenderExportedComponentContext } from './includeContexts';\nexport type { IncludeMode, RenderFileContextType } from './includeContexts';\n\n/** Low-level: render one export of an already-resolving module evaluation. Most\n * code should use {@link Include}, which resolves the module and adds Suspense. */\nexport const RenderExportedComponent = ({\n evaluationContextPromise,\n exportedSymbol = 'default',\n}: {\n evaluationContextPromise: Promise<EvaluationContext>;\n exportedSymbol: string;\n}) => {\n const evaluationContext = use(evaluationContextPromise);\n // TODO: handle case where exported symbol not found.\n const Component = exportedSymbol === '*' ? evaluationContext.exports : evaluationContext.exports[exportedSymbol];\n return (\n <RenderExportedComponentContext value={{ evaluationContext }}>\n <Component />\n </RenderExportedComponentContext>\n );\n};\n\n/** Render another repo file's exported component inline, resolving + evaluating it\n * through the module cache (with Suspense + an error boundary).\n *\n * Under `mode=\"interpreted\"` (or inside an {@link IncludeModeContext} set to it) the file is\n * instead rendered **as data** through the safe renderer — no author JavaScript executes,\n * and the file need not be an evaluable module at all. */\nexport const Include = ({\n filename,\n exportedSymbol = 'default',\n LoadingComponent = defaultLoadingComponent,\n ErrorComponent = defaultErrorComponent,\n baseModule,\n mode,\n components,\n}: {\n filename: string;\n exportedSymbol?: string;\n LoadingComponent?: typeof defaultLoadingComponent;\n ErrorComponent?: typeof defaultErrorComponent;\n baseModule?: EvaluationContext;\n /** Override {@link IncludeModeContext} for this one include. */\n mode?: IncludeMode;\n /** Interpreted mode only: components merged OVER the surrounding MDXProvider map.\n *\n * An app's SAFE component set is not always the same as the one it hands\n * `boot({ mdxComponents })`. Grove is the worked example: under the safe renderer it also\n * needs sanitizing wrappers for structural tags (`main`, `section`, …), and it must NOT\n * register those globally, because MDX consults the provider for intrinsics on the\n * COMPILED path too — so a global registration would silently strip `style` and other\n * non-allow-listed props from compiled authors who legitimately pass them. Ignored in\n * compiled mode, where components come from the provider as they always have. */\n components?: Record<string, unknown>;\n}) => {\n // Both contexts are read unconditionally, before the branch, so hook order is stable\n // whichever renderer this include resolves to.\n const contextMode = use(IncludeModeContext);\n const moduleCache = use(ModuleCacheContext);\n // The prop wins over the context so a single file can opt out either way: an interpreter\n // app including one trusted, executable component of its own, or a compiled app rendering\n // one file it does not trust (the shape Grove's non-executable proof page needs).\n if ((mode ?? contextMode) === 'interpreted') {\n return (\n <SafeInclude\n filename={filename}\n components={components}\n LoadingComponent={LoadingComponent}\n ErrorComponent={ErrorComponent}\n />\n );\n }\n // @ts-ignore\n const evaluationContextPromise = moduleCache!.getEvaluationContext(filename, baseModule ?? module);\n return (\n <ErrorBoundary fallbackRender={ErrorComponent}>\n <Suspense fallback={<LoadingComponent />}>\n <RenderExportedComponent evaluationContextPromise={evaluationContextPromise} exportedSymbol={exportedSymbol} />\n </Suspense>\n </ErrorBoundary>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BM;AA7BN,mBAA8B;AAC9B,kCAA8B;AAE9B,yBAAmC;AAEnC,sBAA+D;AAC/D,6BAAqF;AACrF,yBAA4B;AAK5B,IAAAA,0BAAmE;AAK5D,MAAM,0BAA0B,CAAC;AAAA,EACtC;AAAA,EACA,iBAAiB;AACnB,MAGM;AACJ,QAAM,wBAAoB,kBAAI,wBAAwB;AAEtD,QAAM,YAAY,mBAAmB,MAAM,kBAAkB,UAAU,kBAAkB,QAAQ,cAAc;AAC/G,SACE,4CAAC,yDAA+B,OAAO,EAAE,kBAAkB,GACzD,sDAAC,aAAU,GACb;AAEJ;AAQO,MAAM,UAAU,CAAC;AAAA,EACtB;AAAA,EACA,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AACF,MAkBM;AAGJ,QAAM,kBAAc,kBAAI,yCAAkB;AAC1C,QAAM,kBAAc,kBAAI,qCAAkB;AAI1C,OAAK,QAAQ,iBAAiB,eAAe;AAC3C,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACF;AAAA,EAEJ;AAEA,QAAM,2BAA2B,YAAa,qBAAqB,UAAU,cAAc,MAAM;AACjG,SACE,4CAAC,6CAAc,gBAAgB,gBAC7B,sDAAC,yBAAS,UAAU,4CAAC,oBAAiB,GACpC,sDAAC,2BAAwB,0BAAoD,gBAAgC,GAC/G,GACF;AAEJ;","names":["import_includeContexts"]}
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { EvaluationContext } from '../sandboxTypes.cjs';
|
|
3
3
|
import { defaultLoadingComponent, defaultErrorComponent } from './defaults.cjs';
|
|
4
|
+
import { IncludeMode } from './includeContexts.cjs';
|
|
5
|
+
export { IncludeModeContext, RenderExportedComponentContext, RenderFileContextType } from './includeContexts.cjs';
|
|
4
6
|
import 'react-error-boundary';
|
|
5
7
|
|
|
6
|
-
/** The value exposed on {@link RenderExportedComponentContext}: the evaluation
|
|
7
|
-
* context of the module {@link Include} resolved. */
|
|
8
|
-
type RenderFileContextType = {
|
|
9
|
-
evaluationContext: EvaluationContext;
|
|
10
|
-
};
|
|
11
|
-
/** Context carrying the included module's {@link EvaluationContext} to its subtree. */
|
|
12
|
-
declare const RenderExportedComponentContext: react.Context<RenderFileContextType | null>;
|
|
13
8
|
/** Low-level: render one export of an already-resolving module evaluation. Most
|
|
14
9
|
* code should use {@link Include}, which resolves the module and adds Suspense. */
|
|
15
10
|
declare const RenderExportedComponent: ({ evaluationContextPromise, exportedSymbol, }: {
|
|
@@ -17,13 +12,29 @@ declare const RenderExportedComponent: ({ evaluationContextPromise, exportedSymb
|
|
|
17
12
|
exportedSymbol: string;
|
|
18
13
|
}) => react.JSX.Element;
|
|
19
14
|
/** Render another repo file's exported component inline, resolving + evaluating it
|
|
20
|
-
* through the module cache (with Suspense + an error boundary).
|
|
21
|
-
|
|
15
|
+
* through the module cache (with Suspense + an error boundary).
|
|
16
|
+
*
|
|
17
|
+
* Under `mode="interpreted"` (or inside an {@link IncludeModeContext} set to it) the file is
|
|
18
|
+
* instead rendered **as data** through the safe renderer — no author JavaScript executes,
|
|
19
|
+
* and the file need not be an evaluable module at all. */
|
|
20
|
+
declare const Include: ({ filename, exportedSymbol, LoadingComponent, ErrorComponent, baseModule, mode, components, }: {
|
|
22
21
|
filename: string;
|
|
23
22
|
exportedSymbol?: string;
|
|
24
23
|
LoadingComponent?: typeof defaultLoadingComponent;
|
|
25
24
|
ErrorComponent?: typeof defaultErrorComponent;
|
|
26
25
|
baseModule?: EvaluationContext;
|
|
26
|
+
/** Override {@link IncludeModeContext} for this one include. */
|
|
27
|
+
mode?: IncludeMode;
|
|
28
|
+
/** Interpreted mode only: components merged OVER the surrounding MDXProvider map.
|
|
29
|
+
*
|
|
30
|
+
* An app's SAFE component set is not always the same as the one it hands
|
|
31
|
+
* `boot({ mdxComponents })`. Grove is the worked example: under the safe renderer it also
|
|
32
|
+
* needs sanitizing wrappers for structural tags (`main`, `section`, …), and it must NOT
|
|
33
|
+
* register those globally, because MDX consults the provider for intrinsics on the
|
|
34
|
+
* COMPILED path too — so a global registration would silently strip `style` and other
|
|
35
|
+
* non-allow-listed props from compiled authors who legitimately pass them. Ignored in
|
|
36
|
+
* compiled mode, where components come from the provider as they always have. */
|
|
37
|
+
components?: Record<string, unknown>;
|
|
27
38
|
}) => react.JSX.Element;
|
|
28
39
|
|
|
29
|
-
export { Include,
|
|
40
|
+
export { Include, IncludeMode, RenderExportedComponent };
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { EvaluationContext } from '../sandboxTypes.js';
|
|
3
3
|
import { defaultLoadingComponent, defaultErrorComponent } from './defaults.js';
|
|
4
|
+
import { IncludeMode } from './includeContexts.js';
|
|
5
|
+
export { IncludeModeContext, RenderExportedComponentContext, RenderFileContextType } from './includeContexts.js';
|
|
4
6
|
import 'react-error-boundary';
|
|
5
7
|
|
|
6
|
-
/** The value exposed on {@link RenderExportedComponentContext}: the evaluation
|
|
7
|
-
* context of the module {@link Include} resolved. */
|
|
8
|
-
type RenderFileContextType = {
|
|
9
|
-
evaluationContext: EvaluationContext;
|
|
10
|
-
};
|
|
11
|
-
/** Context carrying the included module's {@link EvaluationContext} to its subtree. */
|
|
12
|
-
declare const RenderExportedComponentContext: react.Context<RenderFileContextType | null>;
|
|
13
8
|
/** Low-level: render one export of an already-resolving module evaluation. Most
|
|
14
9
|
* code should use {@link Include}, which resolves the module and adds Suspense. */
|
|
15
10
|
declare const RenderExportedComponent: ({ evaluationContextPromise, exportedSymbol, }: {
|
|
@@ -17,13 +12,29 @@ declare const RenderExportedComponent: ({ evaluationContextPromise, exportedSymb
|
|
|
17
12
|
exportedSymbol: string;
|
|
18
13
|
}) => react.JSX.Element;
|
|
19
14
|
/** Render another repo file's exported component inline, resolving + evaluating it
|
|
20
|
-
* through the module cache (with Suspense + an error boundary).
|
|
21
|
-
|
|
15
|
+
* through the module cache (with Suspense + an error boundary).
|
|
16
|
+
*
|
|
17
|
+
* Under `mode="interpreted"` (or inside an {@link IncludeModeContext} set to it) the file is
|
|
18
|
+
* instead rendered **as data** through the safe renderer — no author JavaScript executes,
|
|
19
|
+
* and the file need not be an evaluable module at all. */
|
|
20
|
+
declare const Include: ({ filename, exportedSymbol, LoadingComponent, ErrorComponent, baseModule, mode, components, }: {
|
|
22
21
|
filename: string;
|
|
23
22
|
exportedSymbol?: string;
|
|
24
23
|
LoadingComponent?: typeof defaultLoadingComponent;
|
|
25
24
|
ErrorComponent?: typeof defaultErrorComponent;
|
|
26
25
|
baseModule?: EvaluationContext;
|
|
26
|
+
/** Override {@link IncludeModeContext} for this one include. */
|
|
27
|
+
mode?: IncludeMode;
|
|
28
|
+
/** Interpreted mode only: components merged OVER the surrounding MDXProvider map.
|
|
29
|
+
*
|
|
30
|
+
* An app's SAFE component set is not always the same as the one it hands
|
|
31
|
+
* `boot({ mdxComponents })`. Grove is the worked example: under the safe renderer it also
|
|
32
|
+
* needs sanitizing wrappers for structural tags (`main`, `section`, …), and it must NOT
|
|
33
|
+
* register those globally, because MDX consults the provider for intrinsics on the
|
|
34
|
+
* COMPILED path too — so a global registration would silently strip `style` and other
|
|
35
|
+
* non-allow-listed props from compiled authors who legitimately pass them. Ignored in
|
|
36
|
+
* compiled mode, where components come from the provider as they always have. */
|
|
37
|
+
components?: Record<string, unknown>;
|
|
27
38
|
}) => react.JSX.Element;
|
|
28
39
|
|
|
29
|
-
export { Include,
|
|
40
|
+
export { Include, IncludeMode, RenderExportedComponent };
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import "../chunk-VHAA22YE.js";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { Suspense,
|
|
3
|
+
import { Suspense, use } from "react";
|
|
4
4
|
import { ErrorBoundary } from "react-error-boundary";
|
|
5
5
|
import { ModuleCacheContext } from "../moduleCache";
|
|
6
6
|
import { defaultErrorComponent, defaultLoadingComponent } from "./defaults";
|
|
7
|
-
|
|
7
|
+
import { IncludeModeContext, RenderExportedComponentContext } from "./includeContexts";
|
|
8
|
+
import { SafeInclude } from "./SafeInclude";
|
|
9
|
+
import { IncludeModeContext as IncludeModeContext2, RenderExportedComponentContext as RenderExportedComponentContext2 } from "./includeContexts";
|
|
8
10
|
const RenderExportedComponent = ({
|
|
9
11
|
evaluationContextPromise,
|
|
10
12
|
exportedSymbol = "default"
|
|
@@ -18,15 +20,30 @@ const Include = ({
|
|
|
18
20
|
exportedSymbol = "default",
|
|
19
21
|
LoadingComponent = defaultLoadingComponent,
|
|
20
22
|
ErrorComponent = defaultErrorComponent,
|
|
21
|
-
baseModule
|
|
23
|
+
baseModule,
|
|
24
|
+
mode,
|
|
25
|
+
components
|
|
22
26
|
}) => {
|
|
27
|
+
const contextMode = use(IncludeModeContext);
|
|
23
28
|
const moduleCache = use(ModuleCacheContext);
|
|
29
|
+
if ((mode ?? contextMode) === "interpreted") {
|
|
30
|
+
return /* @__PURE__ */ jsx(
|
|
31
|
+
SafeInclude,
|
|
32
|
+
{
|
|
33
|
+
filename,
|
|
34
|
+
components,
|
|
35
|
+
LoadingComponent,
|
|
36
|
+
ErrorComponent
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
}
|
|
24
40
|
const evaluationContextPromise = moduleCache.getEvaluationContext(filename, baseModule ?? module);
|
|
25
41
|
return /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorComponent, children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingComponent, {}), children: /* @__PURE__ */ jsx(RenderExportedComponent, { evaluationContextPromise, exportedSymbol }) }) });
|
|
26
42
|
};
|
|
27
43
|
export {
|
|
28
44
|
Include,
|
|
45
|
+
IncludeModeContext2 as IncludeModeContext,
|
|
29
46
|
RenderExportedComponent,
|
|
30
|
-
RenderExportedComponentContext
|
|
47
|
+
RenderExportedComponentContext2 as RenderExportedComponentContext
|
|
31
48
|
};
|
|
32
49
|
//# sourceMappingURL=Include.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Include.tsx"],"sourcesContent":["import { Suspense,
|
|
1
|
+
{"version":3,"sources":["../../src/components/Include.tsx"],"sourcesContent":["import { Suspense, use } from 'react';\nimport { ErrorBoundary } from 'react-error-boundary';\n\nimport { ModuleCacheContext } from '../moduleCache';\nimport { EvaluationContext } from '../sandboxTypes';\nimport { defaultErrorComponent, defaultLoadingComponent } from './defaults';\nimport { IncludeModeContext, RenderExportedComponentContext, type IncludeMode } from './includeContexts';\nimport { SafeInclude } from './SafeInclude';\n\n// The contexts live in `./includeContexts` so `Include` and `SafeInclude` do not import each\n// other (`check:circular`); re-exported here because this is the public entry point and the\n// import path must not change.\nexport { IncludeModeContext, RenderExportedComponentContext } from './includeContexts';\nexport type { IncludeMode, RenderFileContextType } from './includeContexts';\n\n/** Low-level: render one export of an already-resolving module evaluation. Most\n * code should use {@link Include}, which resolves the module and adds Suspense. */\nexport const RenderExportedComponent = ({\n evaluationContextPromise,\n exportedSymbol = 'default',\n}: {\n evaluationContextPromise: Promise<EvaluationContext>;\n exportedSymbol: string;\n}) => {\n const evaluationContext = use(evaluationContextPromise);\n // TODO: handle case where exported symbol not found.\n const Component = exportedSymbol === '*' ? evaluationContext.exports : evaluationContext.exports[exportedSymbol];\n return (\n <RenderExportedComponentContext value={{ evaluationContext }}>\n <Component />\n </RenderExportedComponentContext>\n );\n};\n\n/** Render another repo file's exported component inline, resolving + evaluating it\n * through the module cache (with Suspense + an error boundary).\n *\n * Under `mode=\"interpreted\"` (or inside an {@link IncludeModeContext} set to it) the file is\n * instead rendered **as data** through the safe renderer — no author JavaScript executes,\n * and the file need not be an evaluable module at all. */\nexport const Include = ({\n filename,\n exportedSymbol = 'default',\n LoadingComponent = defaultLoadingComponent,\n ErrorComponent = defaultErrorComponent,\n baseModule,\n mode,\n components,\n}: {\n filename: string;\n exportedSymbol?: string;\n LoadingComponent?: typeof defaultLoadingComponent;\n ErrorComponent?: typeof defaultErrorComponent;\n baseModule?: EvaluationContext;\n /** Override {@link IncludeModeContext} for this one include. */\n mode?: IncludeMode;\n /** Interpreted mode only: components merged OVER the surrounding MDXProvider map.\n *\n * An app's SAFE component set is not always the same as the one it hands\n * `boot({ mdxComponents })`. Grove is the worked example: under the safe renderer it also\n * needs sanitizing wrappers for structural tags (`main`, `section`, …), and it must NOT\n * register those globally, because MDX consults the provider for intrinsics on the\n * COMPILED path too — so a global registration would silently strip `style` and other\n * non-allow-listed props from compiled authors who legitimately pass them. Ignored in\n * compiled mode, where components come from the provider as they always have. */\n components?: Record<string, unknown>;\n}) => {\n // Both contexts are read unconditionally, before the branch, so hook order is stable\n // whichever renderer this include resolves to.\n const contextMode = use(IncludeModeContext);\n const moduleCache = use(ModuleCacheContext);\n // The prop wins over the context so a single file can opt out either way: an interpreter\n // app including one trusted, executable component of its own, or a compiled app rendering\n // one file it does not trust (the shape Grove's non-executable proof page needs).\n if ((mode ?? contextMode) === 'interpreted') {\n return (\n <SafeInclude\n filename={filename}\n components={components}\n LoadingComponent={LoadingComponent}\n ErrorComponent={ErrorComponent}\n />\n );\n }\n // @ts-ignore\n const evaluationContextPromise = moduleCache!.getEvaluationContext(filename, baseModule ?? module);\n return (\n <ErrorBoundary fallbackRender={ErrorComponent}>\n <Suspense fallback={<LoadingComponent />}>\n <RenderExportedComponent evaluationContextPromise={evaluationContextPromise} exportedSymbol={exportedSymbol} />\n </Suspense>\n </ErrorBoundary>\n );\n};\n"],"mappings":";AA6BM;AA7BN,SAAS,UAAU,WAAW;AAC9B,SAAS,qBAAqB;AAE9B,SAAS,0BAA0B;AAEnC,SAAS,uBAAuB,+BAA+B;AAC/D,SAAS,oBAAoB,sCAAwD;AACrF,SAAS,mBAAmB;AAK5B,SAAS,sBAAAA,qBAAoB,kCAAAC,uCAAsC;AAK5D,MAAM,0BAA0B,CAAC;AAAA,EACtC;AAAA,EACA,iBAAiB;AACnB,MAGM;AACJ,QAAM,oBAAoB,IAAI,wBAAwB;AAEtD,QAAM,YAAY,mBAAmB,MAAM,kBAAkB,UAAU,kBAAkB,QAAQ,cAAc;AAC/G,SACE,oBAAC,kCAA+B,OAAO,EAAE,kBAAkB,GACzD,8BAAC,aAAU,GACb;AAEJ;AAQO,MAAM,UAAU,CAAC;AAAA,EACtB;AAAA,EACA,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AACF,MAkBM;AAGJ,QAAM,cAAc,IAAI,kBAAkB;AAC1C,QAAM,cAAc,IAAI,kBAAkB;AAI1C,OAAK,QAAQ,iBAAiB,eAAe;AAC3C,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACF;AAAA,EAEJ;AAEA,QAAM,2BAA2B,YAAa,qBAAqB,UAAU,cAAc,MAAM;AACjG,SACE,oBAAC,iBAAc,gBAAgB,gBAC7B,8BAAC,YAAS,UAAU,oBAAC,oBAAiB,GACpC,8BAAC,2BAAwB,0BAAoD,gBAAgC,GAC/G,GACF;AAEJ;","names":["IncludeModeContext","RenderExportedComponentContext"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ImgHTMLAttributes, ReactNode } from 'react';
|
|
3
3
|
import { SandboxMount } from '../mounts.cjs';
|
|
4
|
+
import '../generated/spaces.cjs';
|
|
4
5
|
import '../tasks.cjs';
|
|
5
6
|
|
|
6
7
|
/** Props for {@link MountImage}. Extends the native `<img>` attributes (minus `src`,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ImgHTMLAttributes, ReactNode } from 'react';
|
|
3
3
|
import { SandboxMount } from '../mounts.js';
|
|
4
|
+
import '../generated/spaces.js';
|
|
4
5
|
import '../tasks.js';
|
|
5
6
|
|
|
6
7
|
/** Props for {@link MountImage}. Extends the native `<img>` attributes (minus `src`,
|
|
@@ -0,0 +1,89 @@
|
|
|
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 SafeInclude_exports = {};
|
|
20
|
+
__export(SafeInclude_exports, {
|
|
21
|
+
SafeInclude: () => SafeInclude,
|
|
22
|
+
appMountRelative: () => appMountRelative,
|
|
23
|
+
stripFrontmatter: () => stripFrontmatter
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(SafeInclude_exports);
|
|
26
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
var import_react_error_boundary = require("react-error-boundary");
|
|
29
|
+
var import_fs = require("../fs");
|
|
30
|
+
var import_mounts = require("../mounts");
|
|
31
|
+
var import_MDXProvider = require("../MDXProvider");
|
|
32
|
+
var import_SafeContent = require("../safeContent/SafeContent");
|
|
33
|
+
var import_sourceCache = require("../sourceCache");
|
|
34
|
+
var import_includeContexts = require("./includeContexts");
|
|
35
|
+
var import_defaults = require("./defaults");
|
|
36
|
+
function stripFrontmatter(source) {
|
|
37
|
+
return source.replace(/^\uFEFF?---\r?\n[\s\S]*?\r?\n---[ \t]*\r?\n?/, "");
|
|
38
|
+
}
|
|
39
|
+
function appMountRelative(filename) {
|
|
40
|
+
const root = (0, import_mounts.getAppMountPath)().replace(/\/+$/, "");
|
|
41
|
+
const abs = filename.startsWith(root + "/") ? filename.slice(root.length) : filename;
|
|
42
|
+
return abs.replace(/^\/+/, "");
|
|
43
|
+
}
|
|
44
|
+
const defaultSources = (0, import_sourceCache.createSourceCache)(
|
|
45
|
+
(path) => (0, import_fs.openAppFs)().readFile(path, "utf8")
|
|
46
|
+
);
|
|
47
|
+
function InterpretedBody({
|
|
48
|
+
filename,
|
|
49
|
+
components,
|
|
50
|
+
readSource
|
|
51
|
+
}) {
|
|
52
|
+
const sources = (0, import_react.useMemo)(
|
|
53
|
+
() => readSource ? (0, import_sourceCache.createSourceCache)(readSource) : defaultSources,
|
|
54
|
+
[readSource]
|
|
55
|
+
);
|
|
56
|
+
const raw = (0, import_react.use)(sources.read(appMountRelative(filename)));
|
|
57
|
+
const provided = (0, import_MDXProvider.useMDXComponents)(components);
|
|
58
|
+
const body = stripFrontmatter(raw);
|
|
59
|
+
return (
|
|
60
|
+
// Publishing the included file's path is what lets the WikiLink resolver know which file
|
|
61
|
+
// a relative `[[target]]` (and its `#sec-…` fragment) is relative TO — the same context
|
|
62
|
+
// the compiled path publishes from the module's evaluation.
|
|
63
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
64
|
+
import_includeContexts.RenderExportedComponentContext,
|
|
65
|
+
{
|
|
66
|
+
value: { evaluationContext: { evaluation: { module: { filepath: filename } } } },
|
|
67
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_SafeContent.SafeContent, { source: body, components: provided })
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
const SafeInclude = ({
|
|
73
|
+
filename,
|
|
74
|
+
components,
|
|
75
|
+
readSource,
|
|
76
|
+
LoadingComponent = import_defaults.defaultLoadingComponent,
|
|
77
|
+
ErrorComponent = import_defaults.defaultErrorComponent
|
|
78
|
+
}) => (
|
|
79
|
+
// Same boundary shape as the compiled path: a file that fails to read renders the error
|
|
80
|
+
// component rather than taking down the tree that included it.
|
|
81
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_error_boundary.ErrorBoundary, { fallbackRender: ErrorComponent, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingComponent, {}), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InterpretedBody, { filename, components, readSource }) }) })
|
|
82
|
+
);
|
|
83
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
84
|
+
0 && (module.exports = {
|
|
85
|
+
SafeInclude,
|
|
86
|
+
appMountRelative,
|
|
87
|
+
stripFrontmatter
|
|
88
|
+
});
|
|
89
|
+
//# sourceMappingURL=SafeInclude.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/SafeInclude.tsx"],"sourcesContent":["import { Suspense, use, useMemo } from 'react';\nimport { ErrorBoundary } from 'react-error-boundary';\n\nimport { openAppFs } from '../fs';\nimport { getAppMountPath } from '../mounts';\nimport { useMDXComponents } from '../MDXProvider';\nimport { SafeContent } from '../safeContent/SafeContent';\nimport { createSourceCache, type SourceReader } from '../sourceCache';\nimport { RenderExportedComponentContext } from './includeContexts';\nimport { defaultErrorComponent, defaultLoadingComponent } from './defaults';\n\n// `<Include mode=\"interpreted\">` — the same tag, the NON-EXECUTABLE renderer. (R3-263)\n//\n// WHY THIS EXISTS. `<Include>` resolves a file through the module cache and *evaluates* it,\n// which is right for an app's own source and wrong for content. An interpreter app\n// (TRUST_MODES_SPEC §5) had no way to say \"include this file, but as data\": it could render\n// its own bodies through `<SafeContent>` while any file it pulled in with `<Include>` still\n// executed. Grove hit exactly that — a wiki declaring `render: safe` still ran author\n// JavaScript out of its `_layout.mdx`, because the layout chain went through `<Include>`.\n//\n// It is also what makes such a file renderable AT ALL when it does not live in the app: the\n// compiled path evaluates an app-source module, which a file resident in a content mount is\n// not. That is the `AGENT_AUTHORING §10` MDX-from-mount gate, which `TRUST_MODES §5.1` says\n// MUST terminate in the safe renderer and never in compiled MDX.\n//\n// The component map comes from `useMDXComponents` — the SAME provider map `boot({\n// mdxComponents })` establishes for the compiled path — so a document resolves the identical\n// vocabulary under either renderer and an app wires nothing extra to get it.\n\n/** Strip a leading YAML frontmatter block (and an optional BOM). The compiled path never\n * renders frontmatter — the MDX loader consumes it — so the safe path must not either, or\n * the same file gains a wall of raw YAML when the renderer changes. */\nexport function stripFrontmatter(source: string): string {\n return source.replace(/^\\uFEFF?---\\r?\\n[\\s\\S]*?\\r?\\n---[ \\t]*\\r?\\n?/, '');\n}\n\n/** `/app/content/x.mdx` → `content/x.mdx`. {@link openAppFs} is anchored at the app mount,\n * so an absolute module path has to be made mount-relative before it is read. A path that\n * is already relative is passed through untouched. */\nexport function appMountRelative(filename: string): string {\n const root = getAppMountPath().replace(/\\/+$/, '');\n const abs = filename.startsWith(root + '/') ? filename.slice(root.length) : filename;\n return abs.replace(/^\\/+/, '');\n}\n\n// One cache for every interpreted include in the app: a layout file is included on every\n// page, so a per-component cache would re-read it per navigation. See `../sourceCache` for\n// why a REJECTED read must not be memoised.\nconst defaultSources = createSourceCache(\n (path) => openAppFs().readFile(path, 'utf8') as Promise<string>,\n);\n\nfunction InterpretedBody({\n filename,\n components,\n readSource,\n}: {\n filename: string;\n components?: Record<string, unknown>;\n readSource?: SourceReader;\n}) {\n // A caller-supplied reader gets its own cache; the shared one is used otherwise. Memoised\n // on the reader identity so `use()` still sees a stable promise across renders.\n const sources = useMemo(\n () => (readSource ? createSourceCache(readSource) : defaultSources),\n [readSource],\n );\n const raw = use(sources.read(appMountRelative(filename)));\n const provided = useMDXComponents(components) as Record<string, unknown>;\n const body = stripFrontmatter(raw);\n return (\n // Publishing the included file's path is what lets the WikiLink resolver know which file\n // a relative `[[target]]` (and its `#sec-…` fragment) is relative TO — the same context\n // the compiled path publishes from the module's evaluation.\n <RenderExportedComponentContext\n value={{ evaluationContext: { evaluation: { module: { filepath: filename } } } } as never}\n >\n <SafeContent source={body} components={provided as never} />\n </RenderExportedComponentContext>\n );\n}\n\n/** Render another file's Markdown/MDX **as data** — no author JavaScript executes. Reached\n * via `<Include mode=\"interpreted\">` or `<IncludeModeContext value=\"interpreted\">`. */\nexport const SafeInclude = ({\n filename,\n components,\n readSource,\n LoadingComponent = defaultLoadingComponent,\n ErrorComponent = defaultErrorComponent,\n}: {\n filename: string;\n /** Extra/override components, merged OVER the surrounding MDXProvider map. */\n components?: Record<string, unknown>;\n /** Read the raw bytes yourself — e.g. from a content mount rather than the app repo. */\n readSource?: SourceReader;\n LoadingComponent?: typeof defaultLoadingComponent;\n ErrorComponent?: typeof defaultErrorComponent;\n}) => (\n // Same boundary shape as the compiled path: a file that fails to read renders the error\n // component rather than taking down the tree that included it.\n <ErrorBoundary fallbackRender={ErrorComponent}>\n <Suspense fallback={<LoadingComponent />}>\n <InterpretedBody filename={filename} components={components} readSource={readSource} />\n </Suspense>\n </ErrorBoundary>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6EM;AA7EN,mBAAuC;AACvC,kCAA8B;AAE9B,gBAA0B;AAC1B,oBAAgC;AAChC,yBAAiC;AACjC,yBAA4B;AAC5B,yBAAqD;AACrD,6BAA+C;AAC/C,sBAA+D;AAuBxD,SAAS,iBAAiB,QAAwB;AACvD,SAAO,OAAO,QAAQ,gDAAgD,EAAE;AAC1E;AAKO,SAAS,iBAAiB,UAA0B;AACzD,QAAM,WAAO,+BAAgB,EAAE,QAAQ,QAAQ,EAAE;AACjD,QAAM,MAAM,SAAS,WAAW,OAAO,GAAG,IAAI,SAAS,MAAM,KAAK,MAAM,IAAI;AAC5E,SAAO,IAAI,QAAQ,QAAQ,EAAE;AAC/B;AAKA,MAAM,qBAAiB;AAAA,EACrB,CAAC,aAAS,qBAAU,EAAE,SAAS,MAAM,MAAM;AAC7C;AAEA,SAAS,gBAAgB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AACF,GAIG;AAGD,QAAM,cAAU;AAAA,IACd,MAAO,iBAAa,sCAAkB,UAAU,IAAI;AAAA,IACpD,CAAC,UAAU;AAAA,EACb;AACA,QAAM,UAAM,kBAAI,QAAQ,KAAK,iBAAiB,QAAQ,CAAC,CAAC;AACxD,QAAM,eAAW,qCAAiB,UAAU;AAC5C,QAAM,OAAO,iBAAiB,GAAG;AACjC;AAAA;AAAA;AAAA;AAAA,IAIE;AAAA,MAAC;AAAA;AAAA,QACC,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,SAAS,EAAE,EAAE,EAAE;AAAA,QAE/E,sDAAC,kCAAY,QAAQ,MAAM,YAAY,UAAmB;AAAA;AAAA,IAC5D;AAAA;AAEJ;AAIO,MAAM,cAAc,CAAC;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA,mBAAmB;AAAA,EACnB,iBAAiB;AACnB;AAAA;AAAA;AAAA,EAWE,4CAAC,6CAAc,gBAAgB,gBAC7B,sDAAC,yBAAS,UAAU,4CAAC,oBAAiB,GACpC,sDAAC,mBAAgB,UAAoB,YAAwB,YAAwB,GACvF,GACF;AAAA;","names":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { SourceReader } from '../sourceCache.cjs';
|
|
3
|
+
import { defaultLoadingComponent, defaultErrorComponent } from './defaults.cjs';
|
|
4
|
+
import 'react-error-boundary';
|
|
5
|
+
|
|
6
|
+
/** Strip a leading YAML frontmatter block (and an optional BOM). The compiled path never
|
|
7
|
+
* renders frontmatter — the MDX loader consumes it — so the safe path must not either, or
|
|
8
|
+
* the same file gains a wall of raw YAML when the renderer changes. */
|
|
9
|
+
declare function stripFrontmatter(source: string): string;
|
|
10
|
+
/** `/app/content/x.mdx` → `content/x.mdx`. {@link openAppFs} is anchored at the app mount,
|
|
11
|
+
* so an absolute module path has to be made mount-relative before it is read. A path that
|
|
12
|
+
* is already relative is passed through untouched. */
|
|
13
|
+
declare function appMountRelative(filename: string): string;
|
|
14
|
+
/** Render another file's Markdown/MDX **as data** — no author JavaScript executes. Reached
|
|
15
|
+
* via `<Include mode="interpreted">` or `<IncludeModeContext value="interpreted">`. */
|
|
16
|
+
declare const SafeInclude: ({ filename, components, readSource, LoadingComponent, ErrorComponent, }: {
|
|
17
|
+
filename: string;
|
|
18
|
+
/** Extra/override components, merged OVER the surrounding MDXProvider map. */
|
|
19
|
+
components?: Record<string, unknown>;
|
|
20
|
+
/** Read the raw bytes yourself — e.g. from a content mount rather than the app repo. */
|
|
21
|
+
readSource?: SourceReader;
|
|
22
|
+
LoadingComponent?: typeof defaultLoadingComponent;
|
|
23
|
+
ErrorComponent?: typeof defaultErrorComponent;
|
|
24
|
+
}) => react.JSX.Element;
|
|
25
|
+
|
|
26
|
+
export { SafeInclude, appMountRelative, stripFrontmatter };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { SourceReader } from '../sourceCache.js';
|
|
3
|
+
import { defaultLoadingComponent, defaultErrorComponent } from './defaults.js';
|
|
4
|
+
import 'react-error-boundary';
|
|
5
|
+
|
|
6
|
+
/** Strip a leading YAML frontmatter block (and an optional BOM). The compiled path never
|
|
7
|
+
* renders frontmatter — the MDX loader consumes it — so the safe path must not either, or
|
|
8
|
+
* the same file gains a wall of raw YAML when the renderer changes. */
|
|
9
|
+
declare function stripFrontmatter(source: string): string;
|
|
10
|
+
/** `/app/content/x.mdx` → `content/x.mdx`. {@link openAppFs} is anchored at the app mount,
|
|
11
|
+
* so an absolute module path has to be made mount-relative before it is read. A path that
|
|
12
|
+
* is already relative is passed through untouched. */
|
|
13
|
+
declare function appMountRelative(filename: string): string;
|
|
14
|
+
/** Render another file's Markdown/MDX **as data** — no author JavaScript executes. Reached
|
|
15
|
+
* via `<Include mode="interpreted">` or `<IncludeModeContext value="interpreted">`. */
|
|
16
|
+
declare const SafeInclude: ({ filename, components, readSource, LoadingComponent, ErrorComponent, }: {
|
|
17
|
+
filename: string;
|
|
18
|
+
/** Extra/override components, merged OVER the surrounding MDXProvider map. */
|
|
19
|
+
components?: Record<string, unknown>;
|
|
20
|
+
/** Read the raw bytes yourself — e.g. from a content mount rather than the app repo. */
|
|
21
|
+
readSource?: SourceReader;
|
|
22
|
+
LoadingComponent?: typeof defaultLoadingComponent;
|
|
23
|
+
ErrorComponent?: typeof defaultErrorComponent;
|
|
24
|
+
}) => react.JSX.Element;
|
|
25
|
+
|
|
26
|
+
export { SafeInclude, appMountRelative, stripFrontmatter };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import "../chunk-VHAA22YE.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Suspense, use, useMemo } from "react";
|
|
4
|
+
import { ErrorBoundary } from "react-error-boundary";
|
|
5
|
+
import { openAppFs } from "../fs";
|
|
6
|
+
import { getAppMountPath } from "../mounts";
|
|
7
|
+
import { useMDXComponents } from "../MDXProvider";
|
|
8
|
+
import { SafeContent } from "../safeContent/SafeContent";
|
|
9
|
+
import { createSourceCache } from "../sourceCache";
|
|
10
|
+
import { RenderExportedComponentContext } from "./includeContexts";
|
|
11
|
+
import { defaultErrorComponent, defaultLoadingComponent } from "./defaults";
|
|
12
|
+
function stripFrontmatter(source) {
|
|
13
|
+
return source.replace(/^\uFEFF?---\r?\n[\s\S]*?\r?\n---[ \t]*\r?\n?/, "");
|
|
14
|
+
}
|
|
15
|
+
function appMountRelative(filename) {
|
|
16
|
+
const root = getAppMountPath().replace(/\/+$/, "");
|
|
17
|
+
const abs = filename.startsWith(root + "/") ? filename.slice(root.length) : filename;
|
|
18
|
+
return abs.replace(/^\/+/, "");
|
|
19
|
+
}
|
|
20
|
+
const defaultSources = createSourceCache(
|
|
21
|
+
(path) => openAppFs().readFile(path, "utf8")
|
|
22
|
+
);
|
|
23
|
+
function InterpretedBody({
|
|
24
|
+
filename,
|
|
25
|
+
components,
|
|
26
|
+
readSource
|
|
27
|
+
}) {
|
|
28
|
+
const sources = useMemo(
|
|
29
|
+
() => readSource ? createSourceCache(readSource) : defaultSources,
|
|
30
|
+
[readSource]
|
|
31
|
+
);
|
|
32
|
+
const raw = use(sources.read(appMountRelative(filename)));
|
|
33
|
+
const provided = useMDXComponents(components);
|
|
34
|
+
const body = stripFrontmatter(raw);
|
|
35
|
+
return (
|
|
36
|
+
// Publishing the included file's path is what lets the WikiLink resolver know which file
|
|
37
|
+
// a relative `[[target]]` (and its `#sec-…` fragment) is relative TO — the same context
|
|
38
|
+
// the compiled path publishes from the module's evaluation.
|
|
39
|
+
/* @__PURE__ */ jsx(
|
|
40
|
+
RenderExportedComponentContext,
|
|
41
|
+
{
|
|
42
|
+
value: { evaluationContext: { evaluation: { module: { filepath: filename } } } },
|
|
43
|
+
children: /* @__PURE__ */ jsx(SafeContent, { source: body, components: provided })
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
const SafeInclude = ({
|
|
49
|
+
filename,
|
|
50
|
+
components,
|
|
51
|
+
readSource,
|
|
52
|
+
LoadingComponent = defaultLoadingComponent,
|
|
53
|
+
ErrorComponent = defaultErrorComponent
|
|
54
|
+
}) => (
|
|
55
|
+
// Same boundary shape as the compiled path: a file that fails to read renders the error
|
|
56
|
+
// component rather than taking down the tree that included it.
|
|
57
|
+
/* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorComponent, children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingComponent, {}), children: /* @__PURE__ */ jsx(InterpretedBody, { filename, components, readSource }) }) })
|
|
58
|
+
);
|
|
59
|
+
export {
|
|
60
|
+
SafeInclude,
|
|
61
|
+
appMountRelative,
|
|
62
|
+
stripFrontmatter
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=SafeInclude.js.map
|