@immediately-run/sdk 0.39.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.
Files changed (37) hide show
  1. package/dist/components/Include.cjs +22 -4
  2. package/dist/components/Include.cjs.map +1 -1
  3. package/dist/components/Include.d.cts +21 -10
  4. package/dist/components/Include.d.ts +21 -10
  5. package/dist/components/Include.js +21 -4
  6. package/dist/components/Include.js.map +1 -1
  7. package/dist/components/SafeInclude.cjs +89 -0
  8. package/dist/components/SafeInclude.cjs.map +1 -0
  9. package/dist/components/SafeInclude.d.cts +26 -0
  10. package/dist/components/SafeInclude.d.ts +26 -0
  11. package/dist/components/SafeInclude.js +64 -0
  12. package/dist/components/SafeInclude.js.map +1 -0
  13. package/dist/components/includeContexts.cjs +33 -0
  14. package/dist/components/includeContexts.cjs.map +1 -0
  15. package/dist/components/includeContexts.d.cts +22 -0
  16. package/dist/components/includeContexts.d.ts +22 -0
  17. package/dist/components/includeContexts.js +9 -0
  18. package/dist/components/includeContexts.js.map +1 -0
  19. package/dist/index.cjs +11 -0
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +4 -1
  22. package/dist/index.d.ts +4 -1
  23. package/dist/index.js +6 -0
  24. package/dist/index.js.map +1 -1
  25. package/dist/sourceCache.cjs +48 -0
  26. package/dist/sourceCache.cjs.map +1 -0
  27. package/dist/sourceCache.d.cts +12 -0
  28. package/dist/sourceCache.d.ts +12 -0
  29. package/dist/sourceCache.js +25 -0
  30. package/dist/sourceCache.js.map +1 -0
  31. package/dist/version.cjs +1 -1
  32. package/dist/version.cjs.map +1 -1
  33. package/dist/version.d.cts +1 -1
  34. package/dist/version.d.ts +1 -1
  35. package/dist/version.js +1 -1
  36. package/dist/version.js.map +1 -1
  37. package/package.json +1 -1
@@ -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
- const RenderExportedComponentContext = (0, import_react.createContext)(null);
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, createContext, use } from 'react';\nimport { ErrorBoundary } from 'react-error-boundary';\n\nimport { ModuleCacheContext } from '../moduleCache';\nimport { EvaluationContext } from '../sandboxTypes';\nimport { defaultErrorComponent, defaultLoadingComponent } from './defaults';\n\n/** The value exposed on {@link RenderExportedComponentContext}: the evaluation\n * context of the module {@link Include} resolved. */\nexport type RenderFileContextType = {\n evaluationContext: EvaluationContext;\n};\n\n/** Context carrying the included module's {@link EvaluationContext} to its subtree. */\nexport const RenderExportedComponentContext = createContext<RenderFileContextType | null>(null);\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). */\nexport const Include = ({\n filename,\n exportedSymbol = 'default',\n LoadingComponent = defaultLoadingComponent,\n ErrorComponent = defaultErrorComponent,\n baseModule,\n}: {\n filename: string;\n exportedSymbol?: string;\n LoadingComponent?: typeof defaultLoadingComponent;\n ErrorComponent?: typeof defaultErrorComponent;\n baseModule?: EvaluationContext;\n}) => {\n const moduleCache = use(ModuleCacheContext);\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;AA8BM;AA9BN,mBAA6C;AAC7C,kCAA8B;AAE9B,yBAAmC;AAEnC,sBAA+D;AASxD,MAAM,qCAAiC,4BAA4C,IAAI;AAIvF,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,kCAA+B,OAAO,EAAE,kBAAkB,GACzD,sDAAC,aAAU,GACb;AAEJ;AAIO,MAAM,UAAU,CAAC;AAAA,EACtB;AAAA,EACA,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB;AACF,MAMM;AACJ,QAAM,kBAAc,kBAAI,qCAAkB;AAE1C,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":[]}
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
- declare const Include: ({ filename, exportedSymbol, LoadingComponent, ErrorComponent, baseModule, }: {
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, RenderExportedComponent, RenderExportedComponentContext, type RenderFileContextType };
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
- declare const Include: ({ filename, exportedSymbol, LoadingComponent, ErrorComponent, baseModule, }: {
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, RenderExportedComponent, RenderExportedComponentContext, type RenderFileContextType };
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, createContext, use } from "react";
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
- const RenderExportedComponentContext = createContext(null);
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, createContext, use } from 'react';\nimport { ErrorBoundary } from 'react-error-boundary';\n\nimport { ModuleCacheContext } from '../moduleCache';\nimport { EvaluationContext } from '../sandboxTypes';\nimport { defaultErrorComponent, defaultLoadingComponent } from './defaults';\n\n/** The value exposed on {@link RenderExportedComponentContext}: the evaluation\n * context of the module {@link Include} resolved. */\nexport type RenderFileContextType = {\n evaluationContext: EvaluationContext;\n};\n\n/** Context carrying the included module's {@link EvaluationContext} to its subtree. */\nexport const RenderExportedComponentContext = createContext<RenderFileContextType | null>(null);\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). */\nexport const Include = ({\n filename,\n exportedSymbol = 'default',\n LoadingComponent = defaultLoadingComponent,\n ErrorComponent = defaultErrorComponent,\n baseModule,\n}: {\n filename: string;\n exportedSymbol?: string;\n LoadingComponent?: typeof defaultLoadingComponent;\n ErrorComponent?: typeof defaultErrorComponent;\n baseModule?: EvaluationContext;\n}) => {\n const moduleCache = use(ModuleCacheContext);\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":";AA8BM;AA9BN,SAAS,UAAU,eAAe,WAAW;AAC7C,SAAS,qBAAqB;AAE9B,SAAS,0BAA0B;AAEnC,SAAS,uBAAuB,+BAA+B;AASxD,MAAM,iCAAiC,cAA4C,IAAI;AAIvF,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;AAIO,MAAM,UAAU,CAAC;AAAA,EACtB;AAAA,EACA,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB;AACF,MAMM;AACJ,QAAM,cAAc,IAAI,kBAAkB;AAE1C,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":[]}
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"]}
@@ -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
@@ -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":";AA6EM;AA7EN,SAAS,UAAU,KAAK,eAAe;AACvC,SAAS,qBAAqB;AAE9B,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAChC,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,yBAA4C;AACrD,SAAS,sCAAsC;AAC/C,SAAS,uBAAuB,+BAA+B;AAuBxD,SAAS,iBAAiB,QAAwB;AACvD,SAAO,OAAO,QAAQ,gDAAgD,EAAE;AAC1E;AAKO,SAAS,iBAAiB,UAA0B;AACzD,QAAM,OAAO,gBAAgB,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,iBAAiB;AAAA,EACrB,CAAC,SAAS,UAAU,EAAE,SAAS,MAAM,MAAM;AAC7C;AAEA,SAAS,gBAAgB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AACF,GAIG;AAGD,QAAM,UAAU;AAAA,IACd,MAAO,aAAa,kBAAkB,UAAU,IAAI;AAAA,IACpD,CAAC,UAAU;AAAA,EACb;AACA,QAAM,MAAM,IAAI,QAAQ,KAAK,iBAAiB,QAAQ,CAAC,CAAC;AACxD,QAAM,WAAW,iBAAiB,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,8BAAC,eAAY,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,oBAAC,iBAAc,gBAAgB,gBAC7B,8BAAC,YAAS,UAAU,oBAAC,oBAAiB,GACpC,8BAAC,mBAAgB,UAAoB,YAAwB,YAAwB,GACvF,GACF;AAAA;","names":[]}
@@ -0,0 +1,33 @@
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 includeContexts_exports = {};
20
+ __export(includeContexts_exports, {
21
+ IncludeModeContext: () => IncludeModeContext,
22
+ RenderExportedComponentContext: () => RenderExportedComponentContext
23
+ });
24
+ module.exports = __toCommonJS(includeContexts_exports);
25
+ var import_react = require("react");
26
+ const RenderExportedComponentContext = (0, import_react.createContext)(null);
27
+ const IncludeModeContext = (0, import_react.createContext)("compiled");
28
+ // Annotate the CommonJS export names for ESM import in node:
29
+ 0 && (module.exports = {
30
+ IncludeModeContext,
31
+ RenderExportedComponentContext
32
+ });
33
+ //# sourceMappingURL=includeContexts.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/includeContexts.ts"],"sourcesContent":["import { createContext } from 'react';\n\nimport { EvaluationContext } from '../sandboxTypes';\n\n// The contexts `<Include>` publishes and reads, in their own module so that `Include` and\n// `SafeInclude` can each import them without importing each other. `Include` branches to\n// `SafeInclude` and `SafeInclude` publishes `RenderExportedComponentContext`, which would be\n// a cycle if either owned the contexts — and `check:circular` is a CI gate, because a\n// circular SDK import once made the bundler infinite-loop.\n//\n// Both are re-exported from `./Include`, which is the public entry point; nothing outside\n// needs to know this module exists.\n\n/** The value exposed on {@link RenderExportedComponentContext}: the evaluation\n * context of the module `Include` resolved. */\nexport type RenderFileContextType = {\n evaluationContext: EvaluationContext;\n};\n\n/** Context carrying the included module's {@link EvaluationContext} to its subtree. */\nexport const RenderExportedComponentContext = createContext<RenderFileContextType | null>(null);\n\n/** Which renderer `Include` uses: `compiled` evaluates the module (the default, unchanged\n * behaviour); `interpreted` renders the file's Markdown/MDX **as data** through the safe\n * renderer, so no author JavaScript executes. */\nexport type IncludeMode = 'compiled' | 'interpreted';\n\n/** Declare the renderer for every `Include` in a subtree. An **interpreter** app\n * (TRUST_MODES_SPEC §5) sets this once at its root instead of remembering to pass `mode` at\n * each call site — the failure mode being silent (one forgotten `<Include>` executes author\n * code while the app believes it renders nothing but data). Defaults to `compiled`, so every\n * existing consumer is unaffected. */\nexport const IncludeModeContext = createContext<IncludeMode>('compiled');\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA8B;AAoBvB,MAAM,qCAAiC,4BAA4C,IAAI;AAYvF,MAAM,yBAAqB,4BAA2B,UAAU;","names":[]}
@@ -0,0 +1,22 @@
1
+ import * as react from 'react';
2
+ import { EvaluationContext } from '../sandboxTypes.cjs';
3
+
4
+ /** The value exposed on {@link RenderExportedComponentContext}: the evaluation
5
+ * context of the module `Include` resolved. */
6
+ type RenderFileContextType = {
7
+ evaluationContext: EvaluationContext;
8
+ };
9
+ /** Context carrying the included module's {@link EvaluationContext} to its subtree. */
10
+ declare const RenderExportedComponentContext: react.Context<RenderFileContextType | null>;
11
+ /** Which renderer `Include` uses: `compiled` evaluates the module (the default, unchanged
12
+ * behaviour); `interpreted` renders the file's Markdown/MDX **as data** through the safe
13
+ * renderer, so no author JavaScript executes. */
14
+ type IncludeMode = 'compiled' | 'interpreted';
15
+ /** Declare the renderer for every `Include` in a subtree. An **interpreter** app
16
+ * (TRUST_MODES_SPEC §5) sets this once at its root instead of remembering to pass `mode` at
17
+ * each call site — the failure mode being silent (one forgotten `<Include>` executes author
18
+ * code while the app believes it renders nothing but data). Defaults to `compiled`, so every
19
+ * existing consumer is unaffected. */
20
+ declare const IncludeModeContext: react.Context<IncludeMode>;
21
+
22
+ export { type IncludeMode, IncludeModeContext, RenderExportedComponentContext, type RenderFileContextType };
@@ -0,0 +1,22 @@
1
+ import * as react from 'react';
2
+ import { EvaluationContext } from '../sandboxTypes.js';
3
+
4
+ /** The value exposed on {@link RenderExportedComponentContext}: the evaluation
5
+ * context of the module `Include` resolved. */
6
+ type RenderFileContextType = {
7
+ evaluationContext: EvaluationContext;
8
+ };
9
+ /** Context carrying the included module's {@link EvaluationContext} to its subtree. */
10
+ declare const RenderExportedComponentContext: react.Context<RenderFileContextType | null>;
11
+ /** Which renderer `Include` uses: `compiled` evaluates the module (the default, unchanged
12
+ * behaviour); `interpreted` renders the file's Markdown/MDX **as data** through the safe
13
+ * renderer, so no author JavaScript executes. */
14
+ type IncludeMode = 'compiled' | 'interpreted';
15
+ /** Declare the renderer for every `Include` in a subtree. An **interpreter** app
16
+ * (TRUST_MODES_SPEC §5) sets this once at its root instead of remembering to pass `mode` at
17
+ * each call site — the failure mode being silent (one forgotten `<Include>` executes author
18
+ * code while the app believes it renders nothing but data). Defaults to `compiled`, so every
19
+ * existing consumer is unaffected. */
20
+ declare const IncludeModeContext: react.Context<IncludeMode>;
21
+
22
+ export { type IncludeMode, IncludeModeContext, RenderExportedComponentContext, type RenderFileContextType };
@@ -0,0 +1,9 @@
1
+ import "../chunk-VHAA22YE.js";
2
+ import { createContext } from "react";
3
+ const RenderExportedComponentContext = createContext(null);
4
+ const IncludeModeContext = createContext("compiled");
5
+ export {
6
+ IncludeModeContext,
7
+ RenderExportedComponentContext
8
+ };
9
+ //# sourceMappingURL=includeContexts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/includeContexts.ts"],"sourcesContent":["import { createContext } from 'react';\n\nimport { EvaluationContext } from '../sandboxTypes';\n\n// The contexts `<Include>` publishes and reads, in their own module so that `Include` and\n// `SafeInclude` can each import them without importing each other. `Include` branches to\n// `SafeInclude` and `SafeInclude` publishes `RenderExportedComponentContext`, which would be\n// a cycle if either owned the contexts — and `check:circular` is a CI gate, because a\n// circular SDK import once made the bundler infinite-loop.\n//\n// Both are re-exported from `./Include`, which is the public entry point; nothing outside\n// needs to know this module exists.\n\n/** The value exposed on {@link RenderExportedComponentContext}: the evaluation\n * context of the module `Include` resolved. */\nexport type RenderFileContextType = {\n evaluationContext: EvaluationContext;\n};\n\n/** Context carrying the included module's {@link EvaluationContext} to its subtree. */\nexport const RenderExportedComponentContext = createContext<RenderFileContextType | null>(null);\n\n/** Which renderer `Include` uses: `compiled` evaluates the module (the default, unchanged\n * behaviour); `interpreted` renders the file's Markdown/MDX **as data** through the safe\n * renderer, so no author JavaScript executes. */\nexport type IncludeMode = 'compiled' | 'interpreted';\n\n/** Declare the renderer for every `Include` in a subtree. An **interpreter** app\n * (TRUST_MODES_SPEC §5) sets this once at its root instead of remembering to pass `mode` at\n * each call site — the failure mode being silent (one forgotten `<Include>` executes author\n * code while the app believes it renders nothing but data). Defaults to `compiled`, so every\n * existing consumer is unaffected. */\nexport const IncludeModeContext = createContext<IncludeMode>('compiled');\n"],"mappings":";AAAA,SAAS,qBAAqB;AAoBvB,MAAM,iCAAiC,cAA4C,IAAI;AAYvF,MAAM,qBAAqB,cAA2B,UAAU;","names":[]}
package/dist/index.cjs CHANGED
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
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
+ };
6
10
  var __copyProps = (to, from, except, desc) => {
7
11
  if (from && typeof from === "object" || typeof from === "function") {
8
12
  for (let key of __getOwnPropNames(from))
@@ -14,11 +18,16 @@ var __copyProps = (to, from, except, desc) => {
14
18
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
20
  var index_exports = {};
21
+ __export(index_exports, {
22
+ SafeInclude: () => import_SafeInclude.SafeInclude
23
+ });
17
24
  module.exports = __toCommonJS(index_exports);
18
25
  __reExport(index_exports, require("./MDXProvider"), module.exports);
19
26
  __reExport(index_exports, require("./routing"), module.exports);
20
27
  __reExport(index_exports, require("./boot"), module.exports);
21
28
  __reExport(index_exports, require("./components/Include"), module.exports);
29
+ var import_SafeInclude = require("./components/SafeInclude");
30
+ __reExport(index_exports, require("./sourceCache"), module.exports);
22
31
  __reExport(index_exports, require("./components/MDXComponents"), module.exports);
23
32
  __reExport(index_exports, require("./components/MountImage"), module.exports);
24
33
  __reExport(index_exports, require("./components/Routes"), module.exports);
@@ -53,10 +62,12 @@ __reExport(index_exports, require("./sandboxTypes"), module.exports);
53
62
  __reExport(index_exports, require("./safeContent"), module.exports);
54
63
  // Annotate the CommonJS export names for ESM import in node:
55
64
  0 && (module.exports = {
65
+ SafeInclude,
56
66
  ...require("./MDXProvider"),
57
67
  ...require("./routing"),
58
68
  ...require("./boot"),
59
69
  ...require("./components/Include"),
70
+ ...require("./sourceCache"),
60
71
  ...require("./components/MDXComponents"),
61
72
  ...require("./components/MountImage"),
62
73
  ...require("./components/Routes"),
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from \"./MDXProvider\";\nexport * from \"./routing\";\nexport * from \"./boot\";\nexport * from './components/Include';\nexport * from './components/MDXComponents';\nexport * from './components/MountImage';\nexport * from './components/Routes';\nexport * from './hooks'\nexport * from './auth';\nexport * from './theme';\nexport * from './editorContext';\nexport * from './editor';\nexport * from './formFactor';\nexport * from './region';\nexport * from './mounts';\nexport * from './contribute';\nexport * from './catalog';\nexport * from './ipc';\nexport * from './dnd';\nexport * from './netFetch';\nexport * from './secrets';\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 './protocolStream';\nexport * from './sandboxTypes';\nexport * from './safeContent';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,0BAAd;AACA,0BAAc,sBADd;AAEA,0BAAc,mBAFd;AAGA,0BAAc,iCAHd;AAIA,0BAAc,uCAJd;AAKA,0BAAc,oCALd;AAMA,0BAAc,gCANd;AAOA,0BAAc,oBAPd;AAQA,0BAAc,mBARd;AASA,0BAAc,oBATd;AAUA,0BAAc,4BAVd;AAWA,0BAAc,qBAXd;AAYA,0BAAc,yBAZd;AAaA,0BAAc,qBAbd;AAcA,0BAAc,qBAdd;AAeA,0BAAc,yBAfd;AAgBA,0BAAc,sBAhBd;AAiBA,0BAAc,kBAjBd;AAkBA,0BAAc,kBAlBd;AAmBA,0BAAc,uBAnBd;AAoBA,0BAAc,sBApBd;AAqBA,0BAAc,kBArBd;AAsBA,0BAAc,0BAtBd;AAuBA,0BAAc,kBAvBd;AAwBA,0BAAc,yBAxBd;AAyBA,0BAAc,iBAzBd;AA0BA,0BAAc,oBA1Bd;AA2BA,0BAAc,oBA3Bd;AA4BA,0BAAc,qBA5Bd;AA6BA,0BAAc,sBA7Bd;AA8BA,0BAAc,wBA9Bd;AA+BA,0BAAc,oBA/Bd;AAgCA,0BAAc,sBAhCd;AAiCA,0BAAc,6BAjCd;AAkCA,0BAAc,2BAlCd;AAmCA,0BAAc,0BAnCd;","names":[]}
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 './components/MountImage';\nexport * from './components/Routes';\nexport * from './hooks'\nexport * from './auth';\nexport * from './theme';\nexport * from './editorContext';\nexport * from './editor';\nexport * from './formFactor';\nexport * from './region';\nexport * from './mounts';\nexport * from './contribute';\nexport * from './catalog';\nexport * from './ipc';\nexport * from './dnd';\nexport * from './netFetch';\nexport * from './secrets';\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 './protocolStream';\nexport * from './sandboxTypes';\nexport * from './safeContent';\n"],"mappings":";;;;;;;;;;;;;;;;;;;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,oCAXd;AAYA,0BAAc,gCAZd;AAaA,0BAAc,oBAbd;AAcA,0BAAc,mBAdd;AAeA,0BAAc,oBAfd;AAgBA,0BAAc,4BAhBd;AAiBA,0BAAc,qBAjBd;AAkBA,0BAAc,yBAlBd;AAmBA,0BAAc,qBAnBd;AAoBA,0BAAc,qBApBd;AAqBA,0BAAc,yBArBd;AAsBA,0BAAc,sBAtBd;AAuBA,0BAAc,kBAvBd;AAwBA,0BAAc,kBAxBd;AAyBA,0BAAc,uBAzBd;AA0BA,0BAAc,sBA1Bd;AA2BA,0BAAc,kBA3Bd;AA4BA,0BAAc,0BA5Bd;AA6BA,0BAAc,kBA7Bd;AA8BA,0BAAc,yBA9Bd;AA+BA,0BAAc,iBA/Bd;AAgCA,0BAAc,oBAhCd;AAiCA,0BAAc,oBAjCd;AAkCA,0BAAc,qBAlCd;AAmCA,0BAAc,sBAnCd;AAoCA,0BAAc,wBApCd;AAqCA,0BAAc,oBArCd;AAsCA,0BAAc,sBAtCd;AAuCA,0BAAc,6BAvCd;AAwCA,0BAAc,2BAxCd;AAyCA,0BAAc,0BAzCd;","names":[]}
package/dist/index.d.cts CHANGED
@@ -1,7 +1,9 @@
1
1
  export { MDXProvider, useMDXComponents } from './MDXProvider.cjs';
2
2
  export { AppliedRoutingRule, Router, applyRoutingRule, navigate, renderRoute, useRoute, useRouteParams, useTinkerableLink } from './routing.cjs';
3
3
  export { BootProps, CATCH_ALL_ROUTING_SPEC, DEFAULT_ROUTING_SPEC, MdxComponents, TinkerableApp, boot, resolveMdxComponents } from './boot.cjs';
4
- export { Include, RenderExportedComponent, RenderExportedComponentContext, RenderFileContextType } from './components/Include.cjs';
4
+ export { Include, RenderExportedComponent } from './components/Include.cjs';
5
+ export { SafeInclude } from './components/SafeInclude.cjs';
6
+ export { SourceCache, SourceReader, createSourceCache } from './sourceCache.cjs';
5
7
  export { DEFAULT_MDX_COMPONENTS } from './components/MDXComponents.cjs';
6
8
  export { MountImage, MountImageProps } from './components/MountImage.cjs';
7
9
  export { Route, RouteProps, Routes } from './components/Routes.cjs';
@@ -42,6 +44,7 @@ export { Admonition, AdmonitionType } from './components/Admonition.cjs';
42
44
  export { GrantRecord, Member, ResolvedUser, Role, SpaceInfo, getSpaceMembers, inviteToSpace, listAllSpaces, listGrants, listSpaces, lookupUser, revokeGrant, setSpaceRole, unshareSpace } from './generated/spaces.cjs';
43
45
  export { HeadingAnchor } from './components/HeadingAnchor.cjs';
44
46
  export { ImmediatelyRunGlobal, getHostRuntime } from './hostRuntime.cjs';
47
+ export { IncludeMode, IncludeModeContext, RenderExportedComponentContext, RenderFileContextType } from './components/includeContexts.cjs';
45
48
  export { InternalLink, Link } from './components/Link.cjs';
46
49
  export { SDK_VERSION } from './version.cjs';
47
50
  export { WikiLink } from './components/WikiLink.cjs';
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  export { MDXProvider, useMDXComponents } from './MDXProvider.js';
2
2
  export { AppliedRoutingRule, Router, applyRoutingRule, navigate, renderRoute, useRoute, useRouteParams, useTinkerableLink } from './routing.js';
3
3
  export { BootProps, CATCH_ALL_ROUTING_SPEC, DEFAULT_ROUTING_SPEC, MdxComponents, TinkerableApp, boot, resolveMdxComponents } from './boot.js';
4
- export { Include, RenderExportedComponent, RenderExportedComponentContext, RenderFileContextType } from './components/Include.js';
4
+ export { Include, RenderExportedComponent } from './components/Include.js';
5
+ export { SafeInclude } from './components/SafeInclude.js';
6
+ export { SourceCache, SourceReader, createSourceCache } from './sourceCache.js';
5
7
  export { DEFAULT_MDX_COMPONENTS } from './components/MDXComponents.js';
6
8
  export { MountImage, MountImageProps } from './components/MountImage.js';
7
9
  export { Route, RouteProps, Routes } from './components/Routes.js';
@@ -42,6 +44,7 @@ export { Admonition, AdmonitionType } from './components/Admonition.js';
42
44
  export { GrantRecord, Member, ResolvedUser, Role, SpaceInfo, getSpaceMembers, inviteToSpace, listAllSpaces, listGrants, listSpaces, lookupUser, revokeGrant, setSpaceRole, unshareSpace } from './generated/spaces.js';
43
45
  export { HeadingAnchor } from './components/HeadingAnchor.js';
44
46
  export { ImmediatelyRunGlobal, getHostRuntime } from './hostRuntime.js';
47
+ export { IncludeMode, IncludeModeContext, RenderExportedComponentContext, RenderFileContextType } from './components/includeContexts.js';
45
48
  export { InternalLink, Link } from './components/Link.js';
46
49
  export { SDK_VERSION } from './version.js';
47
50
  export { WikiLink } from './components/WikiLink.js';
package/dist/index.js CHANGED
@@ -1,7 +1,10 @@
1
+ import "./chunk-VHAA22YE.js";
1
2
  export * from "./MDXProvider";
2
3
  export * from "./routing";
3
4
  export * from "./boot";
4
5
  export * from "./components/Include";
6
+ import { SafeInclude } from "./components/SafeInclude";
7
+ export * from "./sourceCache";
5
8
  export * from "./components/MDXComponents";
6
9
  export * from "./components/MountImage";
7
10
  export * from "./components/Routes";
@@ -34,4 +37,7 @@ export * from "./loading";
34
37
  export * from "./protocolStream";
35
38
  export * from "./sandboxTypes";
36
39
  export * from "./safeContent";
40
+ export {
41
+ SafeInclude
42
+ };
37
43
  //# sourceMappingURL=index.js.map
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';\nexport * from './components/MDXComponents';\nexport * from './components/MountImage';\nexport * from './components/Routes';\nexport * from './hooks'\nexport * from './auth';\nexport * from './theme';\nexport * from './editorContext';\nexport * from './editor';\nexport * from './formFactor';\nexport * from './region';\nexport * from './mounts';\nexport * from './contribute';\nexport * from './catalog';\nexport * from './ipc';\nexport * from './dnd';\nexport * from './netFetch';\nexport * from './secrets';\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 './protocolStream';\nexport * from './sandboxTypes';\nexport * from './safeContent';\n"],"mappings":"AAAA,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;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
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 './components/MountImage';\nexport * from './components/Routes';\nexport * from './hooks'\nexport * from './auth';\nexport * from './theme';\nexport * from './editorContext';\nexport * from './editor';\nexport * from './formFactor';\nexport * from './region';\nexport * from './mounts';\nexport * from './contribute';\nexport * from './catalog';\nexport * from './ipc';\nexport * from './dnd';\nexport * from './netFetch';\nexport * from './secrets';\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 './protocolStream';\nexport * from './sandboxTypes';\nexport * from './safeContent';\n"],"mappings":";AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAKd,SAAS,mBAAmB;AAC5B,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;AACd,cAAc;","names":[]}
@@ -0,0 +1,48 @@
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 sourceCache_exports = {};
20
+ __export(sourceCache_exports, {
21
+ createSourceCache: () => createSourceCache
22
+ });
23
+ module.exports = __toCommonJS(sourceCache_exports);
24
+ function createSourceCache(reader) {
25
+ const cache = /* @__PURE__ */ new Map();
26
+ return {
27
+ read(path) {
28
+ const hit = cache.get(path);
29
+ if (hit) return hit;
30
+ const p = reader(path).catch((error) => {
31
+ if (cache.get(path) === p) cache.delete(path);
32
+ throw error;
33
+ });
34
+ cache.set(path, p);
35
+ return p;
36
+ },
37
+ invalidate(path) {
38
+ if (path === void 0) cache.clear();
39
+ else cache.delete(path);
40
+ },
41
+ size: () => cache.size
42
+ };
43
+ }
44
+ // Annotate the CommonJS export names for ESM import in node:
45
+ 0 && (module.exports = {
46
+ createSourceCache
47
+ });
48
+ //# sourceMappingURL=sourceCache.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/sourceCache.ts"],"sourcesContent":["// A memoised raw-source reader for React `use()`. (R3-263)\n//\n// `use()` needs a STABLE promise across renders, so a component that reads a file must not\n// start a new read every time it renders. That much is obvious. The part that is not, and\n// the reason this lives in the SDK rather than being re-derived per app, is what happens\n// when a read FAILS:\n//\n// a rejected promise left in the cache is returned to EVERY later render, so the file can\n// never recover.\n//\n// That is not theoretical. The host↔sandbox RPC drops requests during a navigation\n// (\"Invalid RPC id\"), and a wiki entry whose read lost that race stayed **permanently blank\n// for the rest of the session** — no error, no retry, nothing short of a reload. Evicting on\n// rejection makes the next attempt a fresh read, so a transient failure costs a retry\n// instead of the page.\n//\n// Injectable reader, no `fs` import: the cache is pure and testable without a host, and the\n// same instance serves whatever mount the caller reads from.\n\nexport type SourceReader = (path: string) => Promise<string>;\n\nexport interface SourceCache {\n /** The memoised read for `path` — the same promise identity until it settles-and-fails. */\n read: (path: string) => Promise<string>;\n /** Drop a memoised read (a live edit, or an explicit refresh); no argument clears all. */\n invalidate: (path?: string) => void;\n /** Testing/diagnostics: how many paths are memoised right now. */\n size: () => number;\n}\n\nexport function createSourceCache(reader: SourceReader): SourceCache {\n const cache = new Map<string, Promise<string>>();\n return {\n read(path) {\n const hit = cache.get(path);\n if (hit) return hit;\n const p = reader(path).catch((error: unknown) => {\n // Never let a failure become the permanent answer for this path. Guarded on\n // identity so a newer read started after an invalidate is not evicted by an older\n // one settling late.\n if (cache.get(path) === p) cache.delete(path);\n throw error;\n });\n cache.set(path, p);\n return p;\n },\n invalidate(path) {\n if (path === undefined) cache.clear();\n else cache.delete(path);\n },\n size: () => cache.size,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA8BO,SAAS,kBAAkB,QAAmC;AACnE,QAAM,QAAQ,oBAAI,IAA6B;AAC/C,SAAO;AAAA,IACL,KAAK,MAAM;AACT,YAAM,MAAM,MAAM,IAAI,IAAI;AAC1B,UAAI,IAAK,QAAO;AAChB,YAAM,IAAI,OAAO,IAAI,EAAE,MAAM,CAAC,UAAmB;AAI/C,YAAI,MAAM,IAAI,IAAI,MAAM,EAAG,OAAM,OAAO,IAAI;AAC5C,cAAM;AAAA,MACR,CAAC;AACD,YAAM,IAAI,MAAM,CAAC;AACjB,aAAO;AAAA,IACT;AAAA,IACA,WAAW,MAAM;AACf,UAAI,SAAS,OAAW,OAAM,MAAM;AAAA,UAC/B,OAAM,OAAO,IAAI;AAAA,IACxB;AAAA,IACA,MAAM,MAAM,MAAM;AAAA,EACpB;AACF;","names":[]}
@@ -0,0 +1,12 @@
1
+ type SourceReader = (path: string) => Promise<string>;
2
+ interface SourceCache {
3
+ /** The memoised read for `path` — the same promise identity until it settles-and-fails. */
4
+ read: (path: string) => Promise<string>;
5
+ /** Drop a memoised read (a live edit, or an explicit refresh); no argument clears all. */
6
+ invalidate: (path?: string) => void;
7
+ /** Testing/diagnostics: how many paths are memoised right now. */
8
+ size: () => number;
9
+ }
10
+ declare function createSourceCache(reader: SourceReader): SourceCache;
11
+
12
+ export { type SourceCache, type SourceReader, createSourceCache };
@@ -0,0 +1,12 @@
1
+ type SourceReader = (path: string) => Promise<string>;
2
+ interface SourceCache {
3
+ /** The memoised read for `path` — the same promise identity until it settles-and-fails. */
4
+ read: (path: string) => Promise<string>;
5
+ /** Drop a memoised read (a live edit, or an explicit refresh); no argument clears all. */
6
+ invalidate: (path?: string) => void;
7
+ /** Testing/diagnostics: how many paths are memoised right now. */
8
+ size: () => number;
9
+ }
10
+ declare function createSourceCache(reader: SourceReader): SourceCache;
11
+
12
+ export { type SourceCache, type SourceReader, createSourceCache };
@@ -0,0 +1,25 @@
1
+ import "./chunk-VHAA22YE.js";
2
+ function createSourceCache(reader) {
3
+ const cache = /* @__PURE__ */ new Map();
4
+ return {
5
+ read(path) {
6
+ const hit = cache.get(path);
7
+ if (hit) return hit;
8
+ const p = reader(path).catch((error) => {
9
+ if (cache.get(path) === p) cache.delete(path);
10
+ throw error;
11
+ });
12
+ cache.set(path, p);
13
+ return p;
14
+ },
15
+ invalidate(path) {
16
+ if (path === void 0) cache.clear();
17
+ else cache.delete(path);
18
+ },
19
+ size: () => cache.size
20
+ };
21
+ }
22
+ export {
23
+ createSourceCache
24
+ };
25
+ //# sourceMappingURL=sourceCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/sourceCache.ts"],"sourcesContent":["// A memoised raw-source reader for React `use()`. (R3-263)\n//\n// `use()` needs a STABLE promise across renders, so a component that reads a file must not\n// start a new read every time it renders. That much is obvious. The part that is not, and\n// the reason this lives in the SDK rather than being re-derived per app, is what happens\n// when a read FAILS:\n//\n// a rejected promise left in the cache is returned to EVERY later render, so the file can\n// never recover.\n//\n// That is not theoretical. The host↔sandbox RPC drops requests during a navigation\n// (\"Invalid RPC id\"), and a wiki entry whose read lost that race stayed **permanently blank\n// for the rest of the session** — no error, no retry, nothing short of a reload. Evicting on\n// rejection makes the next attempt a fresh read, so a transient failure costs a retry\n// instead of the page.\n//\n// Injectable reader, no `fs` import: the cache is pure and testable without a host, and the\n// same instance serves whatever mount the caller reads from.\n\nexport type SourceReader = (path: string) => Promise<string>;\n\nexport interface SourceCache {\n /** The memoised read for `path` — the same promise identity until it settles-and-fails. */\n read: (path: string) => Promise<string>;\n /** Drop a memoised read (a live edit, or an explicit refresh); no argument clears all. */\n invalidate: (path?: string) => void;\n /** Testing/diagnostics: how many paths are memoised right now. */\n size: () => number;\n}\n\nexport function createSourceCache(reader: SourceReader): SourceCache {\n const cache = new Map<string, Promise<string>>();\n return {\n read(path) {\n const hit = cache.get(path);\n if (hit) return hit;\n const p = reader(path).catch((error: unknown) => {\n // Never let a failure become the permanent answer for this path. Guarded on\n // identity so a newer read started after an invalidate is not evicted by an older\n // one settling late.\n if (cache.get(path) === p) cache.delete(path);\n throw error;\n });\n cache.set(path, p);\n return p;\n },\n invalidate(path) {\n if (path === undefined) cache.clear();\n else cache.delete(path);\n },\n size: () => cache.size,\n };\n}\n"],"mappings":";AA8BO,SAAS,kBAAkB,QAAmC;AACnE,QAAM,QAAQ,oBAAI,IAA6B;AAC/C,SAAO;AAAA,IACL,KAAK,MAAM;AACT,YAAM,MAAM,MAAM,IAAI,IAAI;AAC1B,UAAI,IAAK,QAAO;AAChB,YAAM,IAAI,OAAO,IAAI,EAAE,MAAM,CAAC,UAAmB;AAI/C,YAAI,MAAM,IAAI,IAAI,MAAM,EAAG,OAAM,OAAO,IAAI;AAC5C,cAAM;AAAA,MACR,CAAC;AACD,YAAM,IAAI,MAAM,CAAC;AACjB,aAAO;AAAA,IACT;AAAA,IACA,WAAW,MAAM;AACf,UAAI,SAAS,OAAW,OAAM,MAAM;AAAA,UAC/B,OAAM,OAAO,IAAI;AAAA,IACxB;AAAA,IACA,MAAM,MAAM,MAAM;AAAA,EACpB;AACF;","names":[]}
package/dist/version.cjs CHANGED
@@ -21,7 +21,7 @@ __export(version_exports, {
21
21
  SDK_VERSION: () => SDK_VERSION
22
22
  });
23
23
  module.exports = __toCommonJS(version_exports);
24
- const SDK_VERSION = "0.39.0";
24
+ const SDK_VERSION = "0.40.0";
25
25
  // Annotate the CommonJS export names for ESM import in node:
26
26
  0 && (module.exports = {
27
27
  SDK_VERSION
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/version.ts"],"sourcesContent":["// GENERATED by scripts/gen-version.mjs from package.json — do not edit by hand.\n// Regenerated on every build (prebuild); kept honest by version.test.ts.\n\n/** This SDK's package version, baked from package.json at build (SP2-6). */\nexport const SDK_VERSION = '0.39.0';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO,MAAM,cAAc;","names":[]}
1
+ {"version":3,"sources":["../src/version.ts"],"sourcesContent":["// GENERATED by scripts/gen-version.mjs from package.json — do not edit by hand.\n// Regenerated on every build (prebuild); kept honest by version.test.ts.\n\n/** This SDK's package version, baked from package.json at build (SP2-6). */\nexport const SDK_VERSION = '0.40.0';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO,MAAM,cAAc;","names":[]}
@@ -1,4 +1,4 @@
1
1
  /** This SDK's package version, baked from package.json at build (SP2-6). */
2
- declare const SDK_VERSION = "0.39.0";
2
+ declare const SDK_VERSION = "0.40.0";
3
3
 
4
4
  export { SDK_VERSION };
package/dist/version.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  /** This SDK's package version, baked from package.json at build (SP2-6). */
2
- declare const SDK_VERSION = "0.39.0";
2
+ declare const SDK_VERSION = "0.40.0";
3
3
 
4
4
  export { SDK_VERSION };
package/dist/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./chunk-VHAA22YE.js";
2
- const SDK_VERSION = "0.39.0";
2
+ const SDK_VERSION = "0.40.0";
3
3
  export {
4
4
  SDK_VERSION
5
5
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/version.ts"],"sourcesContent":["// GENERATED by scripts/gen-version.mjs from package.json — do not edit by hand.\n// Regenerated on every build (prebuild); kept honest by version.test.ts.\n\n/** This SDK's package version, baked from package.json at build (SP2-6). */\nexport const SDK_VERSION = '0.39.0';\n"],"mappings":";AAIO,MAAM,cAAc;","names":[]}
1
+ {"version":3,"sources":["../src/version.ts"],"sourcesContent":["// GENERATED by scripts/gen-version.mjs from package.json — do not edit by hand.\n// Regenerated on every build (prebuild); kept honest by version.test.ts.\n\n/** This SDK's package version, baked from package.json at build (SP2-6). */\nexport const SDK_VERSION = '0.40.0';\n"],"mappings":";AAIO,MAAM,cAAc;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@immediately-run/sdk",
3
- "version": "0.39.0",
3
+ "version": "0.40.0",
4
4
  "description": "Runtime SDK for code executing inside an immediately.run sandbox.",
5
5
  "license": "MIT",
6
6
  "repository": "github:immediately-run/immediately-run-sdk",