@immediately-run/sdk 0.17.0 → 0.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/boot.cjs CHANGED
@@ -97,15 +97,10 @@ const BootMarkers = () => {
97
97
  }, []);
98
98
  return null;
99
99
  };
100
- const escapeForRegexp = (str) => str.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&");
101
100
  const DEFAULT_ROUTING_SPEC = {
102
101
  routes: [
103
- { name: "MainContent", pattern: /^\/$/, element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_MainContent.MainContent, {}) },
104
- {
105
- name: "FileRouter",
106
- pattern: new RegExp(`^${escapeForRegexp(import_urlUtils.FILES_PREFIX)}(?<filename>/.+)$`),
107
- element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_FileRouter.FileRouter, {})
108
- },
102
+ { name: "MainContent", pattern: "/", element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_MainContent.MainContent, {}) },
103
+ { name: "FileRouter", pattern: `${import_urlUtils.FILES_PREFIX}/*`, element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_FileRouter.FileRouter, {}) },
109
104
  { name: "ErrorNotFound", pattern: /^(?<path>.+)$/, element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_errors.ErrorNotFound, {}) }
110
105
  ]
111
106
  };
package/dist/boot.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/boot.tsx"],"sourcesContent":["import { FC, ReactNode, StrictMode, useEffect, useLayoutEffect, useState } from 'react';\nimport { createRoot } from 'react-dom/client';\n\nimport { emitMarkerOnce } from './markers';\n\nimport { ErrorNotFound } from './components/errors';\nimport { FileRouter } from './components/FileRouter';\nimport { MainContent } from './components/MainContent';\nimport { DEFAULT_MDX_COMPONENTS } from './components/MDXComponents';\nimport { getInitialContext, updateContext } from './contextUtils';\nimport { getInjectedMetadataEmitter, resolveMetadataSource } from './injectedBundler';\nimport { MDXProvider } from './MDXProvider';\nimport { ModuleCache, ModuleCacheContextProvider } from './moduleCache';\nimport { Router } from './routing';\nimport type { RoutingSpec } from './RoutingSpec';\nimport { FilesMetadata } from './sandboxTypes';\nimport { addListener } from './sandboxUtils';\nimport { TinkerableContext, TinkerableState } from './TinkerableContext';\nimport { FILES_PREFIX } from './urlUtils';\n\n/** Options for {@link boot}: MDX overrides, a route table, or an app root. */\nexport type BootProps = {\n mdxComponents?: Record<string, FC>;\n routingSpec?: RoutingSpec;\n /**\n * App root rendered directly inside the providers (with full navigation\n * context), instead of dispatching through a `routingSpec`. Render\n * `<Routes>`/`<Route>` here for fully dynamic routing — no catch-all rule\n * boilerplate. Takes precedence over `routingSpec` for what is rendered.\n */\n children?: ReactNode;\n};\n\nconst updateAlreadyApplied = (filesMetadata: FilesMetadata, update: FilesMetadata) => {\n for (let [key, value] of Object.entries(update)) {\n if (filesMetadata[key] !== value) {\n return false;\n }\n }\n return true;\n};\n\n/** The app shell {@link boot} renders: holds navigation state, subscribes to host\n * URL + metadata pushes, and renders `children` or the route `<Router />`. */\nexport const TinkerableApp = ({\n routingSpec,\n children,\n}: {\n routingSpec: RoutingSpec;\n children?: ReactNode;\n}) => {\n const [context, setContext] = useState<TinkerableState>(getInitialContext(routingSpec));\n useEffect(() => {\n const removeListener = addListener('urlchange', ({ url }) => {\n setContext((context) => {\n const updatedContext = updateContext(context, url);\n if (updatedContext !== context) {\n console.log(\n `[Sandbox] Updating path from ${context.navigationState.sandboxPath} to ${updatedContext.navigationState.sandboxPath}`\n );\n }\n return updatedContext;\n });\n });\n return removeListener;\n }, [setContext]);\n useEffect(() => {\n // Phase 5 dual-mode (SDK_PACKAGING_SPEC §4/§8): prefer the injected bundler's\n // metadata emitter (the live path, byte-identical); when the SDK is npm-fetched\n // with no injection, `event` is undefined so `addListener` receives\n // 'metadata-update' over the §4 transport instead, and `enable` is a no-op.\n const source = resolveMetadataSource(getInjectedMetadataEmitter());\n const dispose = addListener(\n 'metadata-update',\n ({ update }: Record<string, any>) => {\n setContext((prevContext) =>\n updateAlreadyApplied(prevContext.filesMetadata, update)\n ? prevContext\n : {\n ...prevContext,\n filesMetadata: {\n // TODO: file deletion!\n ...prevContext.filesMetadata,\n ...update,\n },\n }\n );\n },\n source.event\n );\n source.enable();\n return dispose;\n }, [setContext]);\n\n return (\n <TinkerableContext value={context}>\n {children ?? <Router />}\n </TinkerableContext>\n );\n};\n\n// Boot marker emitter (LOAD_PROFILING_SPEC §3, R3-46). Rendered at the top of the\n// app tree so its layout effect fires on the FIRST root-render commit: that instant\n// is `ir.fmp` (the content is in the DOM, about to paint) and the baseline for\n// `ir.interactive` (the host treats a forwarded `ir.interactive` as the root-commit\n// signal and resolves `max(commit, reportReady)` — LP2-3 — so this can only ever be\n// delayed by an app's `reportReady()`, never advanced). Emitted in canonical stream\n// order (fmp then interactive); idempotent per name (StrictMode-safe). Renders null.\nconst BootMarkers = (): null => {\n useLayoutEffect(() => {\n emitMarkerOnce('ir.fmp');\n emitMarkerOnce('ir.interactive');\n }, []);\n return null;\n};\n\n// from: https://stackoverflow.com/a/63838890\nconst escapeForRegexp = (str: string) => str.replace(/[.*+\\-?^${}()|[\\]\\\\]/g, '\\\\$&');\n\n/** The default route table when `boot` is called with no `routingSpec`/`children`:\n * `/` → main content, `/files/<path>` → the file router, else not-found. */\nexport const DEFAULT_ROUTING_SPEC: RoutingSpec = {\n routes: [\n { name: 'MainContent', pattern: /^\\/$/, element: <MainContent /> },\n {\n name: 'FileRouter',\n pattern: new RegExp(`^${escapeForRegexp(FILES_PREFIX)}(?<filename>\\/.+)$`),\n element: <FileRouter />,\n },\n { name: 'ErrorNotFound', pattern: /^(?<path>.+)$/, element: <ErrorNotFound /> },\n ],\n};\n\n/**\n * Matches any `sandboxPath` so navigation context can be built without a route\n * table. Used when {@link boot} is given `children` (the app owns dispatch via\n * `<Routes>`); the catch-all's `element` is never rendered (children are).\n */\nexport const CATCH_ALL_ROUTING_SPEC: RoutingSpec = {\n routes: [{ name: 'AppRoot', pattern: /^.*$/, element: null }],\n};\n\n/**\n * Mount an immediately.run app into the sandbox `#root`. The entry point every\n * app calls from `index.tsx`: wires the MDX, module-cache, and navigation\n * providers, then renders the route table (`routingSpec`) or your `children`.\n */\nexport const boot = ({\n mdxComponents = DEFAULT_MDX_COMPONENTS,\n routingSpec,\n children,\n}: BootProps = {}) => {\n const rootElement = document.getElementById('root');\n if (!rootElement) {\n throw new Error('boot requires root HTML element to exist');\n }\n // `children` own dispatch, so a catch-all keeps navigation working without a\n // table; otherwise fall back to the default file/main-content routes.\n const spec = routingSpec ?? (children ? CATCH_ALL_ROUTING_SPEC : DEFAULT_ROUTING_SPEC);\n const moduleCache = new ModuleCache();\n const root = createRoot(rootElement);\n root.render(\n <StrictMode>\n <ModuleCacheContextProvider moduleCache={moduleCache}>\n <MDXProvider components={mdxComponents}>\n <BootMarkers />\n <TinkerableApp routingSpec={spec}>{children}</TinkerableApp>\n </MDXProvider>\n </ModuleCacheContextProvider>\n </StrictMode>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgGmB;AAhGnB,mBAAgF;AAChF,oBAA2B;AAE3B,qBAA+B;AAE/B,oBAA8B;AAC9B,wBAA2B;AAC3B,yBAA4B;AAC5B,2BAAuC;AACvC,0BAAiD;AACjD,6BAAkE;AAClE,yBAA4B;AAC5B,yBAAwD;AACxD,qBAAuB;AAGvB,0BAA4B;AAC5B,+BAAmD;AACnD,sBAA6B;AAe7B,MAAM,uBAAuB,CAAC,eAA8B,WAA0B;AACpF,WAAS,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AAC/C,QAAI,cAAc,GAAG,MAAM,OAAO;AAChC,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAIO,MAAM,gBAAgB,CAAC;AAAA,EAC5B;AAAA,EACA;AACF,MAGM;AACJ,QAAM,CAAC,SAAS,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SAAS,IAAI,OAAO,IAAI,gBAAgB,4BAAY,CAAC,mBAAoB;AAAA,MACzE,SAAS,4CAAC,gCAAW;AAAA,IACvB;AAAA,IACA,EAAE,MAAM,iBAAiB,SAAS,iBAAiB,SAAS,4CAAC,+BAAc,EAAG;AAAA,EAChF;AACF;AAOO,MAAM,yBAAsC;AAAA,EACjD,QAAQ,CAAC,EAAE,MAAM,WAAW,SAAS,QAAQ,SAAS,KAAK,CAAC;AAC9D;AAOO,MAAM,OAAO,CAAC;AAAA,EACnB,gBAAgB;AAAA,EAChB;AAAA,EACA;AACF,IAAe,CAAC,MAAM;AACpB,QAAM,cAAc,SAAS,eAAe,MAAM;AAClD,MAAI,CAAC,aAAa;AAChB,UAAM,IAAI,MAAM,0CAA0C;AAAA,EAC5D;AAGA,QAAM,OAAO,gBAAgB,WAAW,yBAAyB;AACjE,QAAM,cAAc,IAAI,+BAAY;AACpC,QAAM,WAAO,0BAAW,WAAW;AACnC,OAAK;AAAA,IACH,4CAAC,2BACC,sDAAC,iDAA2B,aAC1B,uDAAC,kCAAY,YAAY,eACvB;AAAA,kDAAC,eAAY;AAAA,MACb,4CAAC,iBAAc,aAAa,MAAO,UAAS;AAAA,OAC9C,GACF,GACF;AAAA,EACF;AACF;","names":["context"]}
1
+ {"version":3,"sources":["../src/boot.tsx"],"sourcesContent":["import { FC, ReactNode, StrictMode, useEffect, useLayoutEffect, useState } from 'react';\nimport { createRoot } from 'react-dom/client';\n\nimport { emitMarkerOnce } from './markers';\n\nimport { ErrorNotFound } from './components/errors';\nimport { FileRouter } from './components/FileRouter';\nimport { MainContent } from './components/MainContent';\nimport { DEFAULT_MDX_COMPONENTS } from './components/MDXComponents';\nimport { getInitialContext, updateContext } from './contextUtils';\nimport { getInjectedMetadataEmitter, resolveMetadataSource } from './injectedBundler';\nimport { MDXProvider } from './MDXProvider';\nimport { ModuleCache, ModuleCacheContextProvider } from './moduleCache';\nimport { Router } from './routing';\nimport type { RoutingSpec } from './RoutingSpec';\nimport { FilesMetadata } from './sandboxTypes';\nimport { addListener } from './sandboxUtils';\nimport { TinkerableContext, TinkerableState } from './TinkerableContext';\nimport { FILES_PREFIX } from './urlUtils';\n\n/** Options for {@link boot}: MDX overrides, a route table, or an app root. */\nexport type BootProps = {\n mdxComponents?: Record<string, FC>;\n routingSpec?: RoutingSpec;\n /**\n * App root rendered directly inside the providers (with full navigation\n * context), instead of dispatching through a `routingSpec`. Render\n * `<Routes>`/`<Route>` here for fully dynamic routing — no catch-all rule\n * boilerplate. Takes precedence over `routingSpec` for what is rendered.\n */\n children?: ReactNode;\n};\n\nconst updateAlreadyApplied = (filesMetadata: FilesMetadata, update: FilesMetadata) => {\n for (let [key, value] of Object.entries(update)) {\n if (filesMetadata[key] !== value) {\n return false;\n }\n }\n return true;\n};\n\n/** The app shell {@link boot} renders: holds navigation state, subscribes to host\n * URL + metadata pushes, and renders `children` or the route `<Router />`. */\nexport const TinkerableApp = ({\n routingSpec,\n children,\n}: {\n routingSpec: RoutingSpec;\n children?: ReactNode;\n}) => {\n const [context, setContext] = useState<TinkerableState>(getInitialContext(routingSpec));\n useEffect(() => {\n const removeListener = addListener('urlchange', ({ url }) => {\n setContext((context) => {\n const updatedContext = updateContext(context, url);\n if (updatedContext !== context) {\n console.log(\n `[Sandbox] Updating path from ${context.navigationState.sandboxPath} to ${updatedContext.navigationState.sandboxPath}`\n );\n }\n return updatedContext;\n });\n });\n return removeListener;\n }, [setContext]);\n useEffect(() => {\n // Phase 5 dual-mode (SDK_PACKAGING_SPEC §4/§8): prefer the injected bundler's\n // metadata emitter (the live path, byte-identical); when the SDK is npm-fetched\n // with no injection, `event` is undefined so `addListener` receives\n // 'metadata-update' over the §4 transport instead, and `enable` is a no-op.\n const source = resolveMetadataSource(getInjectedMetadataEmitter());\n const dispose = addListener(\n 'metadata-update',\n ({ update }: Record<string, any>) => {\n setContext((prevContext) =>\n updateAlreadyApplied(prevContext.filesMetadata, update)\n ? prevContext\n : {\n ...prevContext,\n filesMetadata: {\n // TODO: file deletion!\n ...prevContext.filesMetadata,\n ...update,\n },\n }\n );\n },\n source.event\n );\n source.enable();\n return dispose;\n }, [setContext]);\n\n return (\n <TinkerableContext value={context}>\n {children ?? <Router />}\n </TinkerableContext>\n );\n};\n\n// Boot marker emitter (LOAD_PROFILING_SPEC §3, R3-46). Rendered at the top of the\n// app tree so its layout effect fires on the FIRST root-render commit: that instant\n// is `ir.fmp` (the content is in the DOM, about to paint) and the baseline for\n// `ir.interactive` (the host treats a forwarded `ir.interactive` as the root-commit\n// signal and resolves `max(commit, reportReady)` — LP2-3 — so this can only ever be\n// delayed by an app's `reportReady()`, never advanced). Emitted in canonical stream\n// order (fmp then interactive); idempotent per name (StrictMode-safe). Renders null.\nconst BootMarkers = (): null => {\n useLayoutEffect(() => {\n emitMarkerOnce('ir.fmp');\n emitMarkerOnce('ir.interactive');\n }, []);\n return null;\n};\n\n/** The default route table when `boot` is called with no `routingSpec`/`children`:\n * `/` → main content, `/files/<path>` → the file router, else not-found.\n * Re-expressed with path templates (SANDBOX_ROUTING_SPEC §7); the file path\n * surfaces under the `*` wildcard. The catch-all stays a raw RegExp — the\n * escape hatch — so it anchors `.+` (a non-empty path) exactly as before. */\nexport const DEFAULT_ROUTING_SPEC: RoutingSpec = {\n routes: [\n { name: 'MainContent', pattern: '/', element: <MainContent /> },\n { name: 'FileRouter', pattern: `${FILES_PREFIX}/*`, element: <FileRouter /> },\n { name: 'ErrorNotFound', pattern: /^(?<path>.+)$/, element: <ErrorNotFound /> },\n ],\n};\n\n/**\n * Matches any `sandboxPath` so navigation context can be built without a route\n * table. Used when {@link boot} is given `children` (the app owns dispatch via\n * `<Routes>`); the catch-all's `element` is never rendered (children are).\n */\nexport const CATCH_ALL_ROUTING_SPEC: RoutingSpec = {\n routes: [{ name: 'AppRoot', pattern: /^.*$/, element: null }],\n};\n\n/**\n * Mount an immediately.run app into the sandbox `#root`. The entry point every\n * app calls from `index.tsx`: wires the MDX, module-cache, and navigation\n * providers, then renders the route table (`routingSpec`) or your `children`.\n */\nexport const boot = ({\n mdxComponents = DEFAULT_MDX_COMPONENTS,\n routingSpec,\n children,\n}: BootProps = {}) => {\n const rootElement = document.getElementById('root');\n if (!rootElement) {\n throw new Error('boot requires root HTML element to exist');\n }\n // `children` own dispatch, so a catch-all keeps navigation working without a\n // table; otherwise fall back to the default file/main-content routes.\n const spec = routingSpec ?? (children ? CATCH_ALL_ROUTING_SPEC : DEFAULT_ROUTING_SPEC);\n const moduleCache = new ModuleCache();\n const root = createRoot(rootElement);\n root.render(\n <StrictMode>\n <ModuleCacheContextProvider moduleCache={moduleCache}>\n <MDXProvider components={mdxComponents}>\n <BootMarkers />\n <TinkerableApp routingSpec={spec}>{children}</TinkerableApp>\n </MDXProvider>\n </ModuleCacheContextProvider>\n </StrictMode>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgGmB;AAhGnB,mBAAgF;AAChF,oBAA2B;AAE3B,qBAA+B;AAE/B,oBAA8B;AAC9B,wBAA2B;AAC3B,yBAA4B;AAC5B,2BAAuC;AACvC,0BAAiD;AACjD,6BAAkE;AAClE,yBAA4B;AAC5B,yBAAwD;AACxD,qBAAuB;AAGvB,0BAA4B;AAC5B,+BAAmD;AACnD,sBAA6B;AAe7B,MAAM,uBAAuB,CAAC,eAA8B,WAA0B;AACpF,WAAS,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AAC/C,QAAI,cAAc,GAAG,MAAM,OAAO;AAChC,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAIO,MAAM,gBAAgB,CAAC;AAAA,EAC5B;AAAA,EACA;AACF,MAGM;AACJ,QAAM,CAAC,SAAS,UAAU,QAAI,2BAA0B,uCAAkB,WAAW,CAAC;AACtF,8BAAU,MAAM;AACd,UAAM,qBAAiB,iCAAY,aAAa,CAAC,EAAE,IAAI,MAAM;AAC3D,iBAAW,CA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,SAAS,QAAQ,SAAS,KAAK,CAAC;AAC9D;AAOO,MAAM,OAAO,CAAC;AAAA,EACnB,gBAAgB;AAAA,EAChB;AAAA,EACA;AACF,IAAe,CAAC,MAAM;AACpB,QAAM,cAAc,SAAS,eAAe,MAAM;AAClD,MAAI,CAAC,aAAa;AAChB,UAAM,IAAI,MAAM,0CAA0C;AAAA,EAC5D;AAGA,QAAM,OAAO,gBAAgB,WAAW,yBAAyB;AACjE,QAAM,cAAc,IAAI,+BAAY;AACpC,QAAM,WAAO,0BAAW,WAAW;AACnC,OAAK;AAAA,IACH,4CAAC,2BACC,sDAAC,iDAA2B,aAC1B,uDAAC,kCAAY,YAAY,eACvB;AAAA,kDAAC,eAAY;AAAA,MACb,4CAAC,iBAAc,aAAa,MAAO,UAAS;AAAA,OAC9C,GACF,GACF;AAAA,EACF;AACF;","names":["context"]}
package/dist/boot.d.cts CHANGED
@@ -21,7 +21,10 @@ declare const TinkerableApp: ({ routingSpec, children, }: {
21
21
  children?: ReactNode;
22
22
  }) => react_jsx_runtime.JSX.Element;
23
23
  /** The default route table when `boot` is called with no `routingSpec`/`children`:
24
- * `/` → main content, `/files/<path>` → the file router, else not-found. */
24
+ * `/` → main content, `/files/<path>` → the file router, else not-found.
25
+ * Re-expressed with path templates (SANDBOX_ROUTING_SPEC §7); the file path
26
+ * surfaces under the `*` wildcard. The catch-all stays a raw RegExp — the
27
+ * escape hatch — so it anchors `.+` (a non-empty path) exactly as before. */
25
28
  declare const DEFAULT_ROUTING_SPEC: RoutingSpec;
26
29
  /**
27
30
  * Matches any `sandboxPath` so navigation context can be built without a route
package/dist/boot.d.ts CHANGED
@@ -21,7 +21,10 @@ declare const TinkerableApp: ({ routingSpec, children, }: {
21
21
  children?: ReactNode;
22
22
  }) => react_jsx_runtime.JSX.Element;
23
23
  /** The default route table when `boot` is called with no `routingSpec`/`children`:
24
- * `/` → main content, `/files/<path>` → the file router, else not-found. */
24
+ * `/` → main content, `/files/<path>` → the file router, else not-found.
25
+ * Re-expressed with path templates (SANDBOX_ROUTING_SPEC §7); the file path
26
+ * surfaces under the `*` wildcard. The catch-all stays a raw RegExp — the
27
+ * escape hatch — so it anchors `.+` (a non-empty path) exactly as before. */
25
28
  declare const DEFAULT_ROUTING_SPEC: RoutingSpec;
26
29
  /**
27
30
  * Matches any `sandboxPath` so navigation context can be built without a route
package/dist/boot.js CHANGED
@@ -71,15 +71,10 @@ const BootMarkers = () => {
71
71
  }, []);
72
72
  return null;
73
73
  };
74
- const escapeForRegexp = (str) => str.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&");
75
74
  const DEFAULT_ROUTING_SPEC = {
76
75
  routes: [
77
- { name: "MainContent", pattern: /^\/$/, element: /* @__PURE__ */ jsx(MainContent, {}) },
78
- {
79
- name: "FileRouter",
80
- pattern: new RegExp(`^${escapeForRegexp(FILES_PREFIX)}(?<filename>/.+)$`),
81
- element: /* @__PURE__ */ jsx(FileRouter, {})
82
- },
76
+ { name: "MainContent", pattern: "/", element: /* @__PURE__ */ jsx(MainContent, {}) },
77
+ { name: "FileRouter", pattern: `${FILES_PREFIX}/*`, element: /* @__PURE__ */ jsx(FileRouter, {}) },
83
78
  { name: "ErrorNotFound", pattern: /^(?<path>.+)$/, element: /* @__PURE__ */ jsx(ErrorNotFound, {}) }
84
79
  ]
85
80
  };
package/dist/boot.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/boot.tsx"],"sourcesContent":["import { FC, ReactNode, StrictMode, useEffect, useLayoutEffect, useState } from 'react';\nimport { createRoot } from 'react-dom/client';\n\nimport { emitMarkerOnce } from './markers';\n\nimport { ErrorNotFound } from './components/errors';\nimport { FileRouter } from './components/FileRouter';\nimport { MainContent } from './components/MainContent';\nimport { DEFAULT_MDX_COMPONENTS } from './components/MDXComponents';\nimport { getInitialContext, updateContext } from './contextUtils';\nimport { getInjectedMetadataEmitter, resolveMetadataSource } from './injectedBundler';\nimport { MDXProvider } from './MDXProvider';\nimport { ModuleCache, ModuleCacheContextProvider } from './moduleCache';\nimport { Router } from './routing';\nimport type { RoutingSpec } from './RoutingSpec';\nimport { FilesMetadata } from './sandboxTypes';\nimport { addListener } from './sandboxUtils';\nimport { TinkerableContext, TinkerableState } from './TinkerableContext';\nimport { FILES_PREFIX } from './urlUtils';\n\n/** Options for {@link boot}: MDX overrides, a route table, or an app root. */\nexport type BootProps = {\n mdxComponents?: Record<string, FC>;\n routingSpec?: RoutingSpec;\n /**\n * App root rendered directly inside the providers (with full navigation\n * context), instead of dispatching through a `routingSpec`. Render\n * `<Routes>`/`<Route>` here for fully dynamic routing — no catch-all rule\n * boilerplate. Takes precedence over `routingSpec` for what is rendered.\n */\n children?: ReactNode;\n};\n\nconst updateAlreadyApplied = (filesMetadata: FilesMetadata, update: FilesMetadata) => {\n for (let [key, value] of Object.entries(update)) {\n if (filesMetadata[key] !== value) {\n return false;\n }\n }\n return true;\n};\n\n/** The app shell {@link boot} renders: holds navigation state, subscribes to host\n * URL + metadata pushes, and renders `children` or the route `<Router />`. */\nexport const TinkerableApp = ({\n routingSpec,\n children,\n}: {\n routingSpec: RoutingSpec;\n children?: ReactNode;\n}) => {\n const [context, setContext] = useState<TinkerableState>(getInitialContext(routingSpec));\n useEffect(() => {\n const removeListener = addListener('urlchange', ({ url }) => {\n setContext((context) => {\n const updatedContext = updateContext(context, url);\n if (updatedContext !== context) {\n console.log(\n `[Sandbox] Updating path from ${context.navigationState.sandboxPath} to ${updatedContext.navigationState.sandboxPath}`\n );\n }\n return updatedContext;\n });\n });\n return removeListener;\n }, [setContext]);\n useEffect(() => {\n // Phase 5 dual-mode (SDK_PACKAGING_SPEC §4/§8): prefer the injected bundler's\n // metadata emitter (the live path, byte-identical); when the SDK is npm-fetched\n // with no injection, `event` is undefined so `addListener` receives\n // 'metadata-update' over the §4 transport instead, and `enable` is a no-op.\n const source = resolveMetadataSource(getInjectedMetadataEmitter());\n const dispose = addListener(\n 'metadata-update',\n ({ update }: Record<string, any>) => {\n setContext((prevContext) =>\n updateAlreadyApplied(prevContext.filesMetadata, update)\n ? prevContext\n : {\n ...prevContext,\n filesMetadata: {\n // TODO: file deletion!\n ...prevContext.filesMetadata,\n ...update,\n },\n }\n );\n },\n source.event\n );\n source.enable();\n return dispose;\n }, [setContext]);\n\n return (\n <TinkerableContext value={context}>\n {children ?? <Router />}\n </TinkerableContext>\n );\n};\n\n// Boot marker emitter (LOAD_PROFILING_SPEC §3, R3-46). Rendered at the top of the\n// app tree so its layout effect fires on the FIRST root-render commit: that instant\n// is `ir.fmp` (the content is in the DOM, about to paint) and the baseline for\n// `ir.interactive` (the host treats a forwarded `ir.interactive` as the root-commit\n// signal and resolves `max(commit, reportReady)` — LP2-3 — so this can only ever be\n// delayed by an app's `reportReady()`, never advanced). Emitted in canonical stream\n// order (fmp then interactive); idempotent per name (StrictMode-safe). Renders null.\nconst BootMarkers = (): null => {\n useLayoutEffect(() => {\n emitMarkerOnce('ir.fmp');\n emitMarkerOnce('ir.interactive');\n }, []);\n return null;\n};\n\n// from: https://stackoverflow.com/a/63838890\nconst escapeForRegexp = (str: string) => str.replace(/[.*+\\-?^${}()|[\\]\\\\]/g, '\\\\$&');\n\n/** The default route table when `boot` is called with no `routingSpec`/`children`:\n * `/` → main content, `/files/<path>` → the file router, else not-found. */\nexport const DEFAULT_ROUTING_SPEC: RoutingSpec = {\n routes: [\n { name: 'MainContent', pattern: /^\\/$/, element: <MainContent /> },\n {\n name: 'FileRouter',\n pattern: new RegExp(`^${escapeForRegexp(FILES_PREFIX)}(?<filename>\\/.+)$`),\n element: <FileRouter />,\n },\n { name: 'ErrorNotFound', pattern: /^(?<path>.+)$/, element: <ErrorNotFound /> },\n ],\n};\n\n/**\n * Matches any `sandboxPath` so navigation context can be built without a route\n * table. Used when {@link boot} is given `children` (the app owns dispatch via\n * `<Routes>`); the catch-all's `element` is never rendered (children are).\n */\nexport const CATCH_ALL_ROUTING_SPEC: RoutingSpec = {\n routes: [{ name: 'AppRoot', pattern: /^.*$/, element: null }],\n};\n\n/**\n * Mount an immediately.run app into the sandbox `#root`. The entry point every\n * app calls from `index.tsx`: wires the MDX, module-cache, and navigation\n * providers, then renders the route table (`routingSpec`) or your `children`.\n */\nexport const boot = ({\n mdxComponents = DEFAULT_MDX_COMPONENTS,\n routingSpec,\n children,\n}: BootProps = {}) => {\n const rootElement = document.getElementById('root');\n if (!rootElement) {\n throw new Error('boot requires root HTML element to exist');\n }\n // `children` own dispatch, so a catch-all keeps navigation working without a\n // table; otherwise fall back to the default file/main-content routes.\n const spec = routingSpec ?? (children ? CATCH_ALL_ROUTING_SPEC : DEFAULT_ROUTING_SPEC);\n const moduleCache = new ModuleCache();\n const root = createRoot(rootElement);\n root.render(\n <StrictMode>\n <ModuleCacheContextProvider moduleCache={moduleCache}>\n <MDXProvider components={mdxComponents}>\n <BootMarkers />\n <TinkerableApp routingSpec={spec}>{children}</TinkerableApp>\n </MDXProvider>\n </ModuleCacheContextProvider>\n </StrictMode>\n );\n};\n"],"mappings":"AAgGmB,cAoEX,YApEW;AAhGnB,SAAwB,YAAY,WAAW,iBAAiB,gBAAgB;AAChF,SAAS,kBAAkB;AAE3B,SAAS,sBAAsB;AAE/B,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,8BAA8B;AACvC,SAAS,mBAAmB,qBAAqB;AACjD,SAAS,4BAA4B,6BAA6B;AAClE,SAAS,mBAAmB;AAC5B,SAAS,aAAa,kCAAkC;AACxD,SAAS,cAAc;AAGvB,SAAS,mBAAmB;AAC5B,SAAS,yBAA0C;AACnD,SAAS,oBAAoB;AAe7B,MAAM,uBAAuB,CAAC,eAA8B,WAA0B;AACpF,WAAS,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AAC/C,QAAI,cAAc,GAAG,MAAM,OAAO;AAChC,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAIO,MAAM,gBAAgB,CAAC;AAAA,EAC5B;AAAA,EACA;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AAA,MACE,MAAM;AAAA,MACN,SAAS,IAAI,OAAO,IAAI,gBAAgB,YAAY,CAAC,mBAAoB;AAAA,MACzE,SAAS,oBAAC,cAAW;AAAA,IACvB;AAAA,IACA,EAAE,MAAM,iBAAiB,SAAS,iBAAiB,SAAS,oBAAC,iBAAc,EAAG;AAAA,EAChF;AACF;AAOO,MAAM,yBAAsC;AAAA,EACjD,QAAQ,CAAC,EAAE,MAAM,WAAW,SAAS,QAAQ,SAAS,KAAK,CAAC;AAC9D;AAOO,MAAM,OAAO,CAAC;AAAA,EACnB,gBAAgB;AAAA,EAChB;AAAA,EACA;AACF,IAAe,CAAC,MAAM;AACpB,QAAM,cAAc,SAAS,eAAe,MAAM;AAClD,MAAI,CAAC,aAAa;AAChB,UAAM,IAAI,MAAM,0CAA0C;AAAA,EAC5D;AAGA,QAAM,OAAO,gBAAgB,WAAW,yBAAyB;AACjE,QAAM,cAAc,IAAI,YAAY;AACpC,QAAM,OAAO,WAAW,WAAW;AACnC,OAAK;AAAA,IACH,oBAAC,cACC,8BAAC,8BAA2B,aAC1B,+BAAC,eAAY,YAAY,eACvB;AAAA,0BAAC,eAAY;AAAA,MACb,oBAAC,iBAAc,aAAa,MAAO,UAAS;AAAA,OAC9C,GACF,GACF;AAAA,EACF;AACF;","names":["context"]}
1
+ {"version":3,"sources":["../src/boot.tsx"],"sourcesContent":["import { FC, ReactNode, StrictMode, useEffect, useLayoutEffect, useState } from 'react';\nimport { createRoot } from 'react-dom/client';\n\nimport { emitMarkerOnce } from './markers';\n\nimport { ErrorNotFound } from './components/errors';\nimport { FileRouter } from './components/FileRouter';\nimport { MainContent } from './components/MainContent';\nimport { DEFAULT_MDX_COMPONENTS } from './components/MDXComponents';\nimport { getInitialContext, updateContext } from './contextUtils';\nimport { getInjectedMetadataEmitter, resolveMetadataSource } from './injectedBundler';\nimport { MDXProvider } from './MDXProvider';\nimport { ModuleCache, ModuleCacheContextProvider } from './moduleCache';\nimport { Router } from './routing';\nimport type { RoutingSpec } from './RoutingSpec';\nimport { FilesMetadata } from './sandboxTypes';\nimport { addListener } from './sandboxUtils';\nimport { TinkerableContext, TinkerableState } from './TinkerableContext';\nimport { FILES_PREFIX } from './urlUtils';\n\n/** Options for {@link boot}: MDX overrides, a route table, or an app root. */\nexport type BootProps = {\n mdxComponents?: Record<string, FC>;\n routingSpec?: RoutingSpec;\n /**\n * App root rendered directly inside the providers (with full navigation\n * context), instead of dispatching through a `routingSpec`. Render\n * `<Routes>`/`<Route>` here for fully dynamic routing — no catch-all rule\n * boilerplate. Takes precedence over `routingSpec` for what is rendered.\n */\n children?: ReactNode;\n};\n\nconst updateAlreadyApplied = (filesMetadata: FilesMetadata, update: FilesMetadata) => {\n for (let [key, value] of Object.entries(update)) {\n if (filesMetadata[key] !== value) {\n return false;\n }\n }\n return true;\n};\n\n/** The app shell {@link boot} renders: holds navigation state, subscribes to host\n * URL + metadata pushes, and renders `children` or the route `<Router />`. */\nexport const TinkerableApp = ({\n routingSpec,\n children,\n}: {\n routingSpec: RoutingSpec;\n children?: ReactNode;\n}) => {\n const [context, setContext] = useState<TinkerableState>(getInitialContext(routingSpec));\n useEffect(() => {\n const removeListener = addListener('urlchange', ({ url }) => {\n setContext((context) => {\n const updatedContext = updateContext(context, url);\n if (updatedContext !== context) {\n console.log(\n `[Sandbox] Updating path from ${context.navigationState.sandboxPath} to ${updatedContext.navigationState.sandboxPath}`\n );\n }\n return updatedContext;\n });\n });\n return removeListener;\n }, [setContext]);\n useEffect(() => {\n // Phase 5 dual-mode (SDK_PACKAGING_SPEC §4/§8): prefer the injected bundler's\n // metadata emitter (the live path, byte-identical); when the SDK is npm-fetched\n // with no injection, `event` is undefined so `addListener` receives\n // 'metadata-update' over the §4 transport instead, and `enable` is a no-op.\n const source = resolveMetadataSource(getInjectedMetadataEmitter());\n const dispose = addListener(\n 'metadata-update',\n ({ update }: Record<string, any>) => {\n setContext((prevContext) =>\n updateAlreadyApplied(prevContext.filesMetadata, update)\n ? prevContext\n : {\n ...prevContext,\n filesMetadata: {\n // TODO: file deletion!\n ...prevContext.filesMetadata,\n ...update,\n },\n }\n );\n },\n source.event\n );\n source.enable();\n return dispose;\n }, [setContext]);\n\n return (\n <TinkerableContext value={context}>\n {children ?? <Router />}\n </TinkerableContext>\n );\n};\n\n// Boot marker emitter (LOAD_PROFILING_SPEC §3, R3-46). Rendered at the top of the\n// app tree so its layout effect fires on the FIRST root-render commit: that instant\n// is `ir.fmp` (the content is in the DOM, about to paint) and the baseline for\n// `ir.interactive` (the host treats a forwarded `ir.interactive` as the root-commit\n// signal and resolves `max(commit, reportReady)` — LP2-3 — so this can only ever be\n// delayed by an app's `reportReady()`, never advanced). Emitted in canonical stream\n// order (fmp then interactive); idempotent per name (StrictMode-safe). Renders null.\nconst BootMarkers = (): null => {\n useLayoutEffect(() => {\n emitMarkerOnce('ir.fmp');\n emitMarkerOnce('ir.interactive');\n }, []);\n return null;\n};\n\n/** The default route table when `boot` is called with no `routingSpec`/`children`:\n * `/` → main content, `/files/<path>` → the file router, else not-found.\n * Re-expressed with path templates (SANDBOX_ROUTING_SPEC §7); the file path\n * surfaces under the `*` wildcard. The catch-all stays a raw RegExp — the\n * escape hatch — so it anchors `.+` (a non-empty path) exactly as before. */\nexport const DEFAULT_ROUTING_SPEC: RoutingSpec = {\n routes: [\n { name: 'MainContent', pattern: '/', element: <MainContent /> },\n { name: 'FileRouter', pattern: `${FILES_PREFIX}/*`, element: <FileRouter /> },\n { name: 'ErrorNotFound', pattern: /^(?<path>.+)$/, element: <ErrorNotFound /> },\n ],\n};\n\n/**\n * Matches any `sandboxPath` so navigation context can be built without a route\n * table. Used when {@link boot} is given `children` (the app owns dispatch via\n * `<Routes>`); the catch-all's `element` is never rendered (children are).\n */\nexport const CATCH_ALL_ROUTING_SPEC: RoutingSpec = {\n routes: [{ name: 'AppRoot', pattern: /^.*$/, element: null }],\n};\n\n/**\n * Mount an immediately.run app into the sandbox `#root`. The entry point every\n * app calls from `index.tsx`: wires the MDX, module-cache, and navigation\n * providers, then renders the route table (`routingSpec`) or your `children`.\n */\nexport const boot = ({\n mdxComponents = DEFAULT_MDX_COMPONENTS,\n routingSpec,\n children,\n}: BootProps = {}) => {\n const rootElement = document.getElementById('root');\n if (!rootElement) {\n throw new Error('boot requires root HTML element to exist');\n }\n // `children` own dispatch, so a catch-all keeps navigation working without a\n // table; otherwise fall back to the default file/main-content routes.\n const spec = routingSpec ?? (children ? CATCH_ALL_ROUTING_SPEC : DEFAULT_ROUTING_SPEC);\n const moduleCache = new ModuleCache();\n const root = createRoot(rootElement);\n root.render(\n <StrictMode>\n <ModuleCacheContextProvider moduleCache={moduleCache}>\n <MDXProvider components={mdxComponents}>\n <BootMarkers />\n <TinkerableApp routingSpec={spec}>{children}</TinkerableApp>\n </MDXProvider>\n </ModuleCacheContextProvider>\n </StrictMode>\n );\n};\n"],"mappings":"AAgGmB,cAgEX,YAhEW;AAhGnB,SAAwB,YAAY,WAAW,iBAAiB,gBAAgB;AAChF,SAAS,kBAAkB;AAE3B,SAAS,sBAAsB;AAE/B,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,8BAA8B;AACvC,SAAS,mBAAmB,qBAAqB;AACjD,SAAS,4BAA4B,6BAA6B;AAClE,SAAS,mBAAmB;AAC5B,SAAS,aAAa,kCAAkC;AACxD,SAAS,cAAc;AAGvB,SAAS,mBAAmB;AAC5B,SAAS,yBAA0C;AACnD,SAAS,oBAAoB;AAe7B,MAAM,uBAAuB,CAAC,eAA8B,WAA0B;AACpF,WAAS,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AAC/C,QAAI,cAAc,GAAG,MAAM,OAAO;AAChC,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAIO,MAAM,gBAAgB,CAAC;AAAA,EAC5B;AAAA,EACA;AACF,MAGM;AACJ,QAAM,CAAC,SAAS,UAAU,IAAI,SAA0B,kBAAkB,WAAW,CA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,EAAG;AAAA,EAChF;AACF;AAOO,MAAM,yBAAsC;AAAA,EACjD,QAAQ,CAAC,EAAE,MAAM,WAAW,SAAS,QAAQ,SAAS,KAAK,CAAC;AAC9D;AAOO,MAAM,OAAO,CAAC;AAAA,EACnB,gBAAgB;AAAA,EAChB;AAAA,EACA;AACF,IAAe,CAAC,MAAM;AACpB,QAAM,cAAc,SAAS,eAAe,MAAM;AAClD,MAAI,CAAC,aAAa;AAChB,UAAM,IAAI,MAAM,0CAA0C;AAAA,EAC5D;AAGA,QAAM,OAAO,gBAAgB,WAAW,yBAAyB;AACjE,QAAM,cAAc,IAAI,YAAY;AACpC,QAAM,OAAO,WAAW,WAAW;AACnC,OAAK;AAAA,IACH,oBAAC,cACC,8BAAC,8BAA2B,aAC1B,+BAAC,eAAY,YAAY,eACvB;AAAA,0BAAC,eAAY;AAAA,MACb,oBAAC,iBAAc,aAAa,MAAO,UAAS;AAAA,OAC9C,GACF,GACF;AAAA,EACF;AACF;","names":["context"]}
@@ -32,7 +32,7 @@ const FileRouter = ({
32
32
  ErrorComponent = import_defaults.defaultErrorComponent
33
33
  } = {}) => {
34
34
  const { navigationState: { pathParameters, sandboxPath } } = (0, import_react.useContext)(import_TinkerableContext.TinkerableContext);
35
- const filename = pathParameters?.filename;
35
+ const filename = pathParameters?.["*"];
36
36
  if (!filename) {
37
37
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorComponent, { error: new Error(`No filename could be extracted from ${sandboxPath}`), resetErrorBoundary: () => {
38
38
  } });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/FileRouter.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { useContext } from 'react';\n\nimport { TinkerableContext } from '../TinkerableContext';\nimport { underAppRoot } from '../urlUtils';\nimport { defaultErrorComponent, defaultLoadingComponent } from './defaults';\nimport { Include } from './Include';\n\nexport const FileRouter: FC = ({\n LoadingComponent = defaultLoadingComponent,\n ErrorComponent = defaultErrorComponent,\n}: {\n LoadingComponent?: typeof defaultLoadingComponent;\n ErrorComponent?: typeof defaultErrorComponent;\n} = {}) => {\n const { navigationState: { pathParameters, sandboxPath } } = useContext(TinkerableContext);\n const filename = pathParameters?.filename;\n if (!filename) {\n return <ErrorComponent error={new Error(`No filename could be extracted from ${sandboxPath}`)} resetErrorBoundary={() => {}}/>;\n }\n // URL subpaths are repo-relative; the sandbox fs is rooted at `/` with the\n // repo mounted at `APP_ROOT`, so anchor the file path there before resolving.\n return <Include\n filename={underAppRoot(filename)}\n LoadingComponent={LoadingComponent}\n ErrorComponent={ErrorComponent}\n // @ts-ignore\n baseModule={module}\n />\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBW;AAjBX,mBAA2B;AAE3B,+BAAkC;AAClC,sBAA6B;AAC7B,sBAA+D;AAC/D,qBAAwB;AAEjB,MAAM,aAAiB,CAAC;AAAA,EAC7B,mBAAmB;AAAA,EACnB,iBAAiB;AACnB,IAGI,CAAC,MAAM;AACT,QAAM,EAAE,iBAAiB,EAAE,gBAAgB,YAAY,EAAE,QAAI,yBAAW,0CAAiB;AACzF,QAAM,WAAW,gBAAgB;AACjC,MAAI,CAAC,UAAU;AACb,WAAO,4CAAC,kBAAe,OAAO,IAAI,MAAM,uCAAuC,WAAW,EAAE,GAAG,oBAAoB,MAAM;AAAA,IAAC,GAAE;AAAA,EAC9H;AAGA,SAAO;AAAA,IAAC;AAAA;AAAA,MACN,cAAU,8BAAa,QAAQ;AAAA,MAC/B;AAAA,MACA;AAAA,MAEA,YAAY;AAAA;AAAA,EACd;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/components/FileRouter.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { useContext } from 'react';\n\nimport { TinkerableContext } from '../TinkerableContext';\nimport { underAppRoot } from '../urlUtils';\nimport { defaultErrorComponent, defaultLoadingComponent } from './defaults';\nimport { Include } from './Include';\n\nexport const FileRouter: FC = ({\n LoadingComponent = defaultLoadingComponent,\n ErrorComponent = defaultErrorComponent,\n}: {\n LoadingComponent?: typeof defaultLoadingComponent;\n ErrorComponent?: typeof defaultErrorComponent;\n} = {}) => {\n const { navigationState: { pathParameters, sandboxPath } } = useContext(TinkerableContext);\n // The default table matches `/files/*`, surfacing the file path under the `*`\n // wildcard (SANDBOX_ROUTING_SPEC §4.1/§7).\n const filename = pathParameters?.['*'];\n if (!filename) {\n return <ErrorComponent error={new Error(`No filename could be extracted from ${sandboxPath}`)} resetErrorBoundary={() => {}}/>;\n }\n // URL subpaths are repo-relative; the sandbox fs is rooted at `/` with the\n // repo mounted at `APP_ROOT`, so anchor the file path there before resolving.\n return <Include\n filename={underAppRoot(filename)}\n LoadingComponent={LoadingComponent}\n ErrorComponent={ErrorComponent}\n // @ts-ignore\n baseModule={module}\n />\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBW;AAnBX,mBAA2B;AAE3B,+BAAkC;AAClC,sBAA6B;AAC7B,sBAA+D;AAC/D,qBAAwB;AAEjB,MAAM,aAAiB,CAAC;AAAA,EAC7B,mBAAmB;AAAA,EACnB,iBAAiB;AACnB,IAGI,CAAC,MAAM;AACT,QAAM,EAAE,iBAAiB,EAAE,gBAAgB,YAAY,EAAE,QAAI,yBAAW,0CAAiB;AAGzF,QAAM,WAAW,iBAAiB,GAAG;AACrC,MAAI,CAAC,UAAU;AACb,WAAO,4CAAC,kBAAe,OAAO,IAAI,MAAM,uCAAuC,WAAW,EAAE,GAAG,oBAAoB,MAAM;AAAA,IAAC,GAAE;AAAA,EAC9H;AAGA,SAAO;AAAA,IAAC;AAAA;AAAA,MACN,cAAU,8BAAa,QAAQ;AAAA,MAC/B;AAAA,MACA;AAAA,MAEA,YAAY;AAAA;AAAA,EACd;AACF;","names":[]}
@@ -9,7 +9,7 @@ const FileRouter = ({
9
9
  ErrorComponent = defaultErrorComponent
10
10
  } = {}) => {
11
11
  const { navigationState: { pathParameters, sandboxPath } } = useContext(TinkerableContext);
12
- const filename = pathParameters?.filename;
12
+ const filename = pathParameters?.["*"];
13
13
  if (!filename) {
14
14
  return /* @__PURE__ */ jsx(ErrorComponent, { error: new Error(`No filename could be extracted from ${sandboxPath}`), resetErrorBoundary: () => {
15
15
  } });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/FileRouter.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { useContext } from 'react';\n\nimport { TinkerableContext } from '../TinkerableContext';\nimport { underAppRoot } from '../urlUtils';\nimport { defaultErrorComponent, defaultLoadingComponent } from './defaults';\nimport { Include } from './Include';\n\nexport const FileRouter: FC = ({\n LoadingComponent = defaultLoadingComponent,\n ErrorComponent = defaultErrorComponent,\n}: {\n LoadingComponent?: typeof defaultLoadingComponent;\n ErrorComponent?: typeof defaultErrorComponent;\n} = {}) => {\n const { navigationState: { pathParameters, sandboxPath } } = useContext(TinkerableContext);\n const filename = pathParameters?.filename;\n if (!filename) {\n return <ErrorComponent error={new Error(`No filename could be extracted from ${sandboxPath}`)} resetErrorBoundary={() => {}}/>;\n }\n // URL subpaths are repo-relative; the sandbox fs is rooted at `/` with the\n // repo mounted at `APP_ROOT`, so anchor the file path there before resolving.\n return <Include\n filename={underAppRoot(filename)}\n LoadingComponent={LoadingComponent}\n ErrorComponent={ErrorComponent}\n // @ts-ignore\n baseModule={module}\n />\n};\n"],"mappings":"AAkBW;AAjBX,SAAS,kBAAkB;AAE3B,SAAS,yBAAyB;AAClC,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB,+BAA+B;AAC/D,SAAS,eAAe;AAEjB,MAAM,aAAiB,CAAC;AAAA,EAC7B,mBAAmB;AAAA,EACnB,iBAAiB;AACnB,IAGI,CAAC,MAAM;AACT,QAAM,EAAE,iBAAiB,EAAE,gBAAgB,YAAY,EAAE,IAAI,WAAW,iBAAiB;AACzF,QAAM,WAAW,gBAAgB;AACjC,MAAI,CAAC,UAAU;AACb,WAAO,oBAAC,kBAAe,OAAO,IAAI,MAAM,uCAAuC,WAAW,EAAE,GAAG,oBAAoB,MAAM;AAAA,IAAC,GAAE;AAAA,EAC9H;AAGA,SAAO;AAAA,IAAC;AAAA;AAAA,MACN,UAAU,aAAa,QAAQ;AAAA,MAC/B;AAAA,MACA;AAAA,MAEA,YAAY;AAAA;AAAA,EACd;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/components/FileRouter.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { useContext } from 'react';\n\nimport { TinkerableContext } from '../TinkerableContext';\nimport { underAppRoot } from '../urlUtils';\nimport { defaultErrorComponent, defaultLoadingComponent } from './defaults';\nimport { Include } from './Include';\n\nexport const FileRouter: FC = ({\n LoadingComponent = defaultLoadingComponent,\n ErrorComponent = defaultErrorComponent,\n}: {\n LoadingComponent?: typeof defaultLoadingComponent;\n ErrorComponent?: typeof defaultErrorComponent;\n} = {}) => {\n const { navigationState: { pathParameters, sandboxPath } } = useContext(TinkerableContext);\n // The default table matches `/files/*`, surfacing the file path under the `*`\n // wildcard (SANDBOX_ROUTING_SPEC §4.1/§7).\n const filename = pathParameters?.['*'];\n if (!filename) {\n return <ErrorComponent error={new Error(`No filename could be extracted from ${sandboxPath}`)} resetErrorBoundary={() => {}}/>;\n }\n // URL subpaths are repo-relative; the sandbox fs is rooted at `/` with the\n // repo mounted at `APP_ROOT`, so anchor the file path there before resolving.\n return <Include\n filename={underAppRoot(filename)}\n LoadingComponent={LoadingComponent}\n ErrorComponent={ErrorComponent}\n // @ts-ignore\n baseModule={module}\n />\n};\n"],"mappings":"AAoBW;AAnBX,SAAS,kBAAkB;AAE3B,SAAS,yBAAyB;AAClC,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB,+BAA+B;AAC/D,SAAS,eAAe;AAEjB,MAAM,aAAiB,CAAC;AAAA,EAC7B,mBAAmB;AAAA,EACnB,iBAAiB;AACnB,IAGI,CAAC,MAAM;AACT,QAAM,EAAE,iBAAiB,EAAE,gBAAgB,YAAY,EAAE,IAAI,WAAW,iBAAiB;AAGzF,QAAM,WAAW,iBAAiB,GAAG;AACrC,MAAI,CAAC,UAAU;AACb,WAAO,oBAAC,kBAAe,OAAO,IAAI,MAAM,uCAAuC,WAAW,EAAE,GAAG,oBAAoB,MAAM;AAAA,IAAC,GAAE;AAAA,EAC9H;AAGA,SAAO;AAAA,IAAC;AAAA;AAAA,MACN,UAAU,aAAa,QAAQ;AAAA,MAC/B;AAAA,MACA;AAAA,MAEA,YAAY;AAAA;AAAA,EACd;AACF;","names":[]}
@@ -23,7 +23,21 @@ __export(defaults_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(defaults_exports);
25
25
  var import_jsx_runtime = require("react/jsx-runtime");
26
- const defaultLoadingComponent = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: "loading..." });
26
+ var import_loading = require("../loading");
27
+ const defaultLoadingComponent = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
28
+ "div",
29
+ {
30
+ style: {
31
+ display: "flex",
32
+ alignItems: "center",
33
+ justifyContent: "center",
34
+ width: "100%",
35
+ height: "100%",
36
+ minHeight: 48
37
+ },
38
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_loading.Spinner, {})
39
+ }
40
+ );
27
41
  const defaultErrorComponent = ({ error }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
28
42
  "ERROR ",
29
43
  String(error)
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/defaults.tsx"],"sourcesContent":["import { ErrorBoundaryPropsWithRender } from 'react-error-boundary';\n\nexport const defaultLoadingComponent = () => <>loading...</>;\n\nexport const defaultErrorComponent:ErrorBoundaryPropsWithRender[\"fallbackRender\"] = ({error}) => <>ERROR {String(error)}</>;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAE6C;AAAtC,MAAM,0BAA0B,MAAM,2EAAE,wBAAU;AAElD,MAAM,wBAAuE,CAAC,EAAC,MAAK,MAAM,4EAAE;AAAA;AAAA,EAAO,OAAO,KAAK;AAAA,GAAE;","names":[]}
1
+ {"version":3,"sources":["../../src/components/defaults.tsx"],"sourcesContent":["import { ErrorBoundaryPropsWithRender } from 'react-error-boundary';\nimport { Spinner } from '../loading';\n\n/**\n * Default Suspense fallback for the SDK content loaders (Include / FileRouter /\n * MainContent).\n *\n * It used to be bare `<>loading...</>` text, which React paints unstyled in the\n * top-left on the iframe's white canvas — reading as a \"white flash with loading…\"\n * between the host's skeleton and the app (LOADING_UX_SPEC §9 / I3). Instead, a\n * calm, centred indicator: `Spinner` renders **nothing** for the first ~150ms (the\n * §6.2 spinner floor), so a fast wait shows no flash at all; a longer wait gets a\n * subtle centred spinner that inherits the app's own text colour. The host themes\n * the iframe canvas behind it (sandbox `themeCanvas.ts`), so there is no white.\n */\nexport const defaultLoadingComponent = () => (\n <div\n style={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n width: '100%',\n height: '100%',\n minHeight: 48,\n }}\n >\n <Spinner />\n </div>\n);\n\nexport const defaultErrorComponent:ErrorBoundaryPropsWithRender[\"fallbackRender\"] = ({error}) => <>ERROR {String(error)}</>;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0BI;AAzBJ,qBAAwB;AAcjB,MAAM,0BAA0B,MACrC;AAAA,EAAC;AAAA;AAAA,IACC,OAAO;AAAA,MACL,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,gBAAgB;AAAA,MAChB,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,WAAW;AAAA,IACb;AAAA,IAEA,sDAAC,0BAAQ;AAAA;AACX;AAGK,MAAM,wBAAuE,CAAC,EAAC,MAAK,MAAM,4EAAE;AAAA;AAAA,EAAO,OAAO,KAAK;AAAA,GAAE;","names":[]}
@@ -1,6 +1,18 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ErrorBoundaryPropsWithRender } from 'react-error-boundary';
3
3
 
4
+ /**
5
+ * Default Suspense fallback for the SDK content loaders (Include / FileRouter /
6
+ * MainContent).
7
+ *
8
+ * It used to be bare `<>loading...</>` text, which React paints unstyled in the
9
+ * top-left on the iframe's white canvas — reading as a "white flash with loading…"
10
+ * between the host's skeleton and the app (LOADING_UX_SPEC §9 / I3). Instead, a
11
+ * calm, centred indicator: `Spinner` renders **nothing** for the first ~150ms (the
12
+ * §6.2 spinner floor), so a fast wait shows no flash at all; a longer wait gets a
13
+ * subtle centred spinner that inherits the app's own text colour. The host themes
14
+ * the iframe canvas behind it (sandbox `themeCanvas.ts`), so there is no white.
15
+ */
4
16
  declare const defaultLoadingComponent: () => react_jsx_runtime.JSX.Element;
5
17
  declare const defaultErrorComponent: ErrorBoundaryPropsWithRender["fallbackRender"];
6
18
 
@@ -1,6 +1,18 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ErrorBoundaryPropsWithRender } from 'react-error-boundary';
3
3
 
4
+ /**
5
+ * Default Suspense fallback for the SDK content loaders (Include / FileRouter /
6
+ * MainContent).
7
+ *
8
+ * It used to be bare `<>loading...</>` text, which React paints unstyled in the
9
+ * top-left on the iframe's white canvas — reading as a "white flash with loading…"
10
+ * between the host's skeleton and the app (LOADING_UX_SPEC §9 / I3). Instead, a
11
+ * calm, centred indicator: `Spinner` renders **nothing** for the first ~150ms (the
12
+ * §6.2 spinner floor), so a fast wait shows no flash at all; a longer wait gets a
13
+ * subtle centred spinner that inherits the app's own text colour. The host themes
14
+ * the iframe canvas behind it (sandbox `themeCanvas.ts`), so there is no white.
15
+ */
4
16
  declare const defaultLoadingComponent: () => react_jsx_runtime.JSX.Element;
5
17
  declare const defaultErrorComponent: ErrorBoundaryPropsWithRender["fallbackRender"];
6
18
 
@@ -1,5 +1,19 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- const defaultLoadingComponent = () => /* @__PURE__ */ jsx(Fragment, { children: "loading..." });
2
+ import { Spinner } from "../loading";
3
+ const defaultLoadingComponent = () => /* @__PURE__ */ jsx(
4
+ "div",
5
+ {
6
+ style: {
7
+ display: "flex",
8
+ alignItems: "center",
9
+ justifyContent: "center",
10
+ width: "100%",
11
+ height: "100%",
12
+ minHeight: 48
13
+ },
14
+ children: /* @__PURE__ */ jsx(Spinner, {})
15
+ }
16
+ );
3
17
  const defaultErrorComponent = ({ error }) => /* @__PURE__ */ jsxs(Fragment, { children: [
4
18
  "ERROR ",
5
19
  String(error)
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/defaults.tsx"],"sourcesContent":["import { ErrorBoundaryPropsWithRender } from 'react-error-boundary';\n\nexport const defaultLoadingComponent = () => <>loading...</>;\n\nexport const defaultErrorComponent:ErrorBoundaryPropsWithRender[\"fallbackRender\"] = ({error}) => <>ERROR {String(error)}</>;\n"],"mappings":"AAE6C,wBAEoD,YAFpD;AAAtC,MAAM,0BAA0B,MAAM,gCAAE,wBAAU;AAElD,MAAM,wBAAuE,CAAC,EAAC,MAAK,MAAM,iCAAE;AAAA;AAAA,EAAO,OAAO,KAAK;AAAA,GAAE;","names":[]}
1
+ {"version":3,"sources":["../../src/components/defaults.tsx"],"sourcesContent":["import { ErrorBoundaryPropsWithRender } from 'react-error-boundary';\nimport { Spinner } from '../loading';\n\n/**\n * Default Suspense fallback for the SDK content loaders (Include / FileRouter /\n * MainContent).\n *\n * It used to be bare `<>loading...</>` text, which React paints unstyled in the\n * top-left on the iframe's white canvas — reading as a \"white flash with loading…\"\n * between the host's skeleton and the app (LOADING_UX_SPEC §9 / I3). Instead, a\n * calm, centred indicator: `Spinner` renders **nothing** for the first ~150ms (the\n * §6.2 spinner floor), so a fast wait shows no flash at all; a longer wait gets a\n * subtle centred spinner that inherits the app's own text colour. The host themes\n * the iframe canvas behind it (sandbox `themeCanvas.ts`), so there is no white.\n */\nexport const defaultLoadingComponent = () => (\n <div\n style={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n width: '100%',\n height: '100%',\n minHeight: 48,\n }}\n >\n <Spinner />\n </div>\n);\n\nexport const defaultErrorComponent:ErrorBoundaryPropsWithRender[\"fallbackRender\"] = ({error}) => <>ERROR {String(error)}</>;\n"],"mappings":"AA0BI,SAI6F,UAJ7F,KAI6F,YAJ7F;AAzBJ,SAAS,eAAe;AAcjB,MAAM,0BAA0B,MACrC;AAAA,EAAC;AAAA;AAAA,IACC,OAAO;AAAA,MACL,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,gBAAgB;AAAA,MAChB,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,WAAW;AAAA,IACb;AAAA,IAEA,8BAAC,WAAQ;AAAA;AACX;AAGK,MAAM,wBAAuE,CAAC,EAAC,MAAK,MAAM,iCAAE;AAAA;AAAA,EAAO,OAAO,KAAK;AAAA,GAAE;","names":[]}
package/dist/fs.cjs ADDED
@@ -0,0 +1,214 @@
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 fs_exports = {};
20
+ __export(fs_exports, {
21
+ fsAvailable: () => fsAvailable,
22
+ openAppFs: () => openAppFs,
23
+ openFs: () => openFs,
24
+ sandboxFs: () => sandboxFs
25
+ });
26
+ module.exports = __toCommonJS(fs_exports);
27
+ var import_mounts = require("./mounts");
28
+ const hasFs = (fs) => typeof fs?.promises?.readFile === "function" || typeof fs?.readFile === "function";
29
+ function sandboxFs() {
30
+ try {
31
+ const shared = globalThis.__sandpackSharedFs;
32
+ if (hasFs(shared)) return shared;
33
+ } catch {
34
+ }
35
+ try {
36
+ const layers = module?.evaluation?.module?.bundler?.fs?.layers;
37
+ if (Array.isArray(layers)) {
38
+ for (const layer of layers) {
39
+ const fs = layer?.boundContext?.fs;
40
+ if (hasFs(fs)) return fs;
41
+ }
42
+ }
43
+ } catch {
44
+ }
45
+ return null;
46
+ }
47
+ function fsAvailable() {
48
+ return sandboxFs() != null;
49
+ }
50
+ const ERRNO = {
51
+ ENOENT: "not-found",
52
+ EROFS: "read-only",
53
+ EACCES: "not-permitted",
54
+ EPERM: "not-permitted",
55
+ EEXIST: "exists",
56
+ ENOTEMPTY: "not-empty"
57
+ };
58
+ const fsError = (code, message) => {
59
+ const err = new Error(message);
60
+ err.code = code;
61
+ return err;
62
+ };
63
+ const mapError = (e) => {
64
+ const errno = e?.code;
65
+ const code = (errno ? ERRNO[errno] : void 0) ?? "unknown";
66
+ const err = new Error(e?.message ?? "fs operation failed");
67
+ err.code = code;
68
+ return err;
69
+ };
70
+ const decoder = new TextDecoder();
71
+ const encoder = new TextEncoder();
72
+ const resolveUnder = (root, relPath) => {
73
+ if (relPath.startsWith("/")) {
74
+ throw fsError("invalid-path", `expected a mount-relative path, got absolute "${relPath}"`);
75
+ }
76
+ const parts = [];
77
+ for (const seg of relPath.split("/")) {
78
+ if (seg === "" || seg === ".") continue;
79
+ if (seg === "..") {
80
+ throw fsError("invalid-path", `"${relPath}" escapes the mount root`);
81
+ }
82
+ parts.push(seg);
83
+ }
84
+ const base = root.endsWith("/") ? root.slice(0, -1) : root;
85
+ return parts.length ? `${base}/${parts.join("/")}` : base;
86
+ };
87
+ const writableAt = (mount, relPath) => {
88
+ const path = "/" + relPath.split("/").filter((s) => s && s !== ".").join("/");
89
+ const rules = mount.rules;
90
+ if (rules && rules.length) {
91
+ let best;
92
+ for (const r of rules) {
93
+ const sub = r.subtree.endsWith("/") ? r.subtree : r.subtree + "/";
94
+ if (path === r.subtree || path.startsWith(sub) || r.subtree === "/") {
95
+ if (!best || r.subtree.length > best.subtree.length) best = r;
96
+ }
97
+ }
98
+ if (best) return best.mode === "rw";
99
+ }
100
+ return (mount.mode ?? "rw") === "rw";
101
+ };
102
+ const promisesOf = (port) => port.promises ?? port;
103
+ function openFs(mount) {
104
+ const root = mount.path;
105
+ const port = () => {
106
+ const p = sandboxFs();
107
+ if (!p) throw fsError("unavailable", "immediately.run: sandbox filesystem unavailable");
108
+ return promisesOf(p);
109
+ };
110
+ const api = {
111
+ mount,
112
+ async readFile(relPath, encoding) {
113
+ const p = port();
114
+ const abs = resolveUnder(root, relPath);
115
+ try {
116
+ const data = await p.readFile(abs);
117
+ const bytes = typeof data === "string" ? encoder.encode(data) : data;
118
+ return encoding === "utf8" ? decoder.decode(bytes) : bytes;
119
+ } catch (e) {
120
+ throw mapError(e);
121
+ }
122
+ },
123
+ async writeFile(relPath, data) {
124
+ const p = port();
125
+ const abs = resolveUnder(root, relPath);
126
+ try {
127
+ await p.writeFile(abs, typeof data === "string" ? encoder.encode(data) : data);
128
+ } catch (e) {
129
+ throw mapError(e);
130
+ }
131
+ },
132
+ async readdir(relPath = "") {
133
+ const p = port();
134
+ const abs = resolveUnder(root, relPath);
135
+ try {
136
+ const entries = await p.readdir(abs, { withFileTypes: true });
137
+ return entries.map(
138
+ (d) => typeof d === "string" ? { name: d, kind: "file" } : { name: d.name, kind: d.isDirectory?.() ? "dir" : "file" }
139
+ );
140
+ } catch (e) {
141
+ throw mapError(e);
142
+ }
143
+ },
144
+ async stat(relPath) {
145
+ const p = port();
146
+ const abs = resolveUnder(root, relPath);
147
+ try {
148
+ const s = await p.stat(abs);
149
+ return {
150
+ kind: s.isDirectory?.() ? "dir" : "file",
151
+ size: typeof s.size === "number" ? s.size : 0,
152
+ mtimeMs: typeof s.mtimeMs === "number" ? s.mtimeMs : void 0
153
+ };
154
+ } catch (e) {
155
+ throw mapError(e);
156
+ }
157
+ },
158
+ async exists(relPath) {
159
+ try {
160
+ await api.stat(relPath);
161
+ return true;
162
+ } catch (e) {
163
+ if (e.code === "not-found") return false;
164
+ if (e.code === "unavailable" || e.code === "invalid-path") {
165
+ throw e;
166
+ }
167
+ return false;
168
+ }
169
+ },
170
+ async mkdir(relPath, opts) {
171
+ const p = port();
172
+ const abs = resolveUnder(root, relPath);
173
+ try {
174
+ await p.mkdir(abs, { recursive: opts?.recursive ?? false });
175
+ } catch (e) {
176
+ throw mapError(e);
177
+ }
178
+ },
179
+ async rm(relPath, opts) {
180
+ const p = port();
181
+ const abs = resolveUnder(root, relPath);
182
+ try {
183
+ await p.rm(abs, { recursive: opts?.recursive ?? false });
184
+ } catch (e) {
185
+ throw mapError(e);
186
+ }
187
+ },
188
+ async rename(fromRel, toRel) {
189
+ const p = port();
190
+ const from = resolveUnder(root, fromRel);
191
+ const to = resolveUnder(root, toRel);
192
+ try {
193
+ await p.rename(from, to);
194
+ } catch (e) {
195
+ throw mapError(e);
196
+ }
197
+ },
198
+ canWrite(relPath = "") {
199
+ return writableAt(mount, relPath);
200
+ }
201
+ };
202
+ return api;
203
+ }
204
+ function openAppFs() {
205
+ return openFs({ path: (0, import_mounts.getAppMountPath)(), type: "repo" });
206
+ }
207
+ // Annotate the CommonJS export names for ESM import in node:
208
+ 0 && (module.exports = {
209
+ fsAvailable,
210
+ openAppFs,
211
+ openFs,
212
+ sandboxFs
213
+ });
214
+ //# sourceMappingURL=fs.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/fs.ts"],"sourcesContent":["// Typed, discoverable filesystem access — the app-facing surface for the ZenFS\n// mount ports (SDK_FS_SURFACE_SPEC; FILESYSTEM_SPEC §2 the ZenFS-shaped contract).\n//\n// The single most important thing an app does — read/write files in its mounts —\n// previously had NO SDK surface: apps reached an ambient `globalThis.__sandpackSharedFs`\n// by hand-rolling the same accessor (editor/file-explorer `src/fs/mountFs.ts`, \"keep the\n// two in sync\"), with a documented footgun (`module.evaluation.module.bundler.fs` is the\n// WRONG object — it has no `promises`/`stat`). This module is that accessor's ONE home,\n// typed and documented.\n//\n// It adds NO authority: the ZenFS port is already minted and chroot/`ro`-enforced\n// host-side (FILESYSTEM_SPEC §2, UI_AS_APPS §8.7). This is typing + discoverability +\n// de-duplication only. `fs` is a Resource PORT (a byte channel), not a host-brokered RPC,\n// so — unlike the `invoke()` catalog surface — it is hand-written, not gate-table-derived.\nimport type { SandboxMount, MountRule } from './mounts';\nimport { getAppMountPath } from './mounts';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/** The node-compatible promises surface the sandbox ZenFS exposes (the subset we use). */\ninterface NodeFsPromises {\n readFile(path: string, encoding?: any): Promise<string | Uint8Array>;\n writeFile(path: string, data: string | Uint8Array): Promise<void>;\n readdir(path: string, opts?: any): Promise<any[]>;\n stat(path: string): Promise<any>;\n mkdir(path: string, opts?: any): Promise<unknown>;\n rm(path: string, opts?: any): Promise<void>;\n rename(from: string, to: string): Promise<void>;\n}\n\n/** The resolved sandbox ZenFS handle (node-compatible, `/`-rooted). Opaque to apps —\n * reach it through {@link openFs}; the raw handle is the {@link sandboxFs} escape hatch. */\nexport interface SandboxFsPort {\n promises?: NodeFsPromises;\n readFile?: NodeFsPromises['readFile'];\n}\n\nconst hasFs = (fs: any): boolean =>\n typeof fs?.promises?.readFile === 'function' || typeof fs?.readFile === 'function';\n\n/**\n * The resolved sandbox ZenFS, or `null` when unavailable. The ONE home for the\n * resolution order previously duplicated in every app's `mountFs.ts`:\n *\n * 1. `globalThis.__sandpackSharedFs` — the `/`-rooted bound ZenFS the sandbox publishes.\n * 2. fallback: the first `module.evaluation.module.bundler.fs.layers[].boundContext.fs`\n * whose surface has `readFile` (the bundler ZenFS-layer bound context).\n * 3. else `null` (local `vite dev` / before boot).\n *\n * Prefer {@link openFs}; reach for this only when a system app spans mounts in absolute\n * `/mnt/{hash}` paths (the file explorer / editor).\n */\nexport function sandboxFs(): SandboxFsPort | null {\n try {\n const shared = (globalThis as any).__sandpackSharedFs;\n if (hasFs(shared)) return shared as SandboxFsPort;\n } catch {\n /* not in the sandbox */\n }\n try {\n // @ts-ignore - `module` is injected by the sandbox runtime (see sandboxUtils transport).\n const layers = module?.evaluation?.module?.bundler?.fs?.layers;\n if (Array.isArray(layers)) {\n for (const layer of layers) {\n const fs = layer?.boundContext?.fs;\n if (hasFs(fs)) return fs as SandboxFsPort;\n }\n }\n } catch {\n /* not in the sandbox */\n }\n return null;\n}\n\n/** Is the sandbox filesystem reachable at all? `false` in local `vite dev` and before\n * boot — gate file affordances on it so an app degrades instead of throwing. */\nexport function fsAvailable(): boolean {\n return sandboxFs() != null;\n}\n\n/** A directory entry from {@link MountFs.readdir}. */\nexport interface DirEntry {\n name: string;\n kind: 'file' | 'dir';\n}\n\n/** A stat result from {@link MountFs.stat}. */\nexport interface FileStat {\n kind: 'file' | 'dir';\n size: number;\n mtimeMs?: number;\n}\n\n/** An error from a {@link MountFs} operation, carrying a machine-readable `.code`\n * (mapped from the ZenFS errno) so an app branches on `.code`, never on a message. */\nexport interface FsError extends Error {\n code:\n | 'not-found' // ENOENT\n | 'read-only' // EROFS — a `ro` mount / downgraded role; NEVER surface as UX (gate with canWrite)\n | 'not-permitted' // EACCES\n | 'exists' // EEXIST\n | 'not-empty' // ENOTEMPTY\n | 'invalid-path' // a `..` segment / absolute escape was passed as a relPath\n | 'unavailable' // no sandbox fs (local dev / pre-boot)\n | 'unknown';\n}\n\nconst ERRNO: Record<string, FsError['code']> = {\n ENOENT: 'not-found',\n EROFS: 'read-only',\n EACCES: 'not-permitted',\n EPERM: 'not-permitted',\n EEXIST: 'exists',\n ENOTEMPTY: 'not-empty',\n};\n\nconst fsError = (code: FsError['code'], message: string): FsError => {\n const err = new Error(message) as FsError;\n err.code = code;\n return err;\n};\n\nconst mapError = (e: unknown): FsError => {\n const errno = (e as { code?: string } | null)?.code;\n const code: FsError['code'] = (errno ? ERRNO[errno] : undefined) ?? 'unknown';\n const err = new Error((e as Error)?.message ?? 'fs operation failed') as FsError;\n err.code = code;\n return err;\n};\n\nconst decoder = new TextDecoder();\nconst encoder = new TextEncoder();\n\n// Join a mount-RELATIVE path under the mount root, rejecting `..` escapes and absolute\n// paths (CLAUDE.md security rule 3 — don't probe for escapes). The host chroot is the\n// real enforcer; this keeps an honest app from accidentally naming outside its grant.\nconst resolveUnder = (root: string, relPath: string): string => {\n if (relPath.startsWith('/')) {\n throw fsError('invalid-path', `expected a mount-relative path, got absolute \"${relPath}\"`);\n }\n const parts: string[] = [];\n for (const seg of relPath.split('/')) {\n if (seg === '' || seg === '.') continue;\n if (seg === '..') {\n throw fsError('invalid-path', `\"${relPath}\" escapes the mount root`);\n }\n parts.push(seg);\n }\n const base = root.endsWith('/') ? root.slice(0, -1) : root;\n return parts.length ? `${base}/${parts.join('/')}` : base;\n};\n\n// The longest matching `rules` subtree governs a path (mounts.ts MountRule); fall back to\n// the whole-mount `mode`. A CLIENT-SIDE hint mirroring the host rule — EROFS stays\n// authoritative (the host re-checks live policy on every write).\nconst writableAt = (mount: SandboxMount, relPath: string): boolean => {\n const path = '/' + relPath.split('/').filter((s) => s && s !== '.').join('/');\n const rules: MountRule[] | undefined = mount.rules;\n if (rules && rules.length) {\n let best: MountRule | undefined;\n for (const r of rules) {\n const sub = r.subtree.endsWith('/') ? r.subtree : r.subtree + '/';\n if (path === r.subtree || path.startsWith(sub) || r.subtree === '/') {\n if (!best || r.subtree.length > best.subtree.length) best = r;\n }\n }\n if (best) return best.mode === 'rw';\n }\n return (mount.mode ?? 'rw') === 'rw';\n};\n\n/** A mount-anchored, typed filesystem view. All paths are RELATIVE to the mount root;\n * the accessor resolves them under `mount.path`. Async-only (ZenFS rides a MessagePort).\n * Obtain one with {@link openFs}. */\nexport interface MountFs {\n /** The mount this view is anchored to (read `mode`/`rules` for writability). */\n readonly mount: SandboxMount;\n /** Read a file as UTF-8 text (`encoding: 'utf8'`) or raw bytes (omit encoding). */\n readFile(relPath: string, encoding: 'utf8'): Promise<string>;\n readFile(relPath: string): Promise<Uint8Array>;\n /** Write text or bytes, creating or truncating the file. Throws `read-only` on a `ro` mount. */\n writeFile(relPath: string, data: string | Uint8Array): Promise<void>;\n /** List a directory (the mount root when `relPath` is omitted). */\n readdir(relPath?: string): Promise<DirEntry[]>;\n /** Stat a path. Throws `not-found` if absent. */\n stat(relPath: string): Promise<FileStat>;\n /** Does `relPath` exist? Never throws on absence. */\n exists(relPath: string): Promise<boolean>;\n /** Create a directory (pass `{ recursive: true }` to make parents). */\n mkdir(relPath: string, opts?: { recursive?: boolean }): Promise<void>;\n /** Remove a file, or a directory with `{ recursive: true }`. */\n rm(relPath: string, opts?: { recursive?: boolean }): Promise<void>;\n /** Rename/move within the mount. */\n rename(fromRel: string, toRel: string): Promise<void>;\n /** Client-side writability hint for `relPath` (mount `mode` ∩ longest-matching `rule`),\n * so an app can hide an \"edit\" affordance instead of catching `read-only`\n * (EDITOR_FIRST_EDITING_SPEC §3). Re-evaluate on `onMountsChange` — a role downgrade\n * flips it. EROFS from the host stays authoritative. */\n canWrite(relPath?: string): boolean;\n}\n\nconst promisesOf = (port: SandboxFsPort): NodeFsPromises =>\n (port.promises ?? (port as unknown as NodeFsPromises));\n\n/**\n * Open a typed, mount-anchored filesystem view (SDK_FS_SURFACE_SPEC §2.1). Pure-client:\n * resolves the ambient ZenFS once ({@link sandboxFs}) and binds it to `mount.path`, so you\n * read/write with paths RELATIVE to the mount root — you cannot accidentally name a path\n * outside your grant (a `..`/absolute path throws `invalid-path`; the host chroot is the\n * real enforcer).\n *\n * ```ts\n * import { mountSpace } from '@immediately-run/sdk';\n * import { openFs } from '@immediately-run/sdk/fs';\n * const fs = openFs(await mountSpace({ spaceId }));\n * const text = await fs.readFile('notes/idea.mdx', 'utf8');\n * if (fs.canWrite('notes/idea.mdx')) await fs.writeFile('notes/idea.mdx', text);\n * ```\n *\n * Throws {@link FsError} `unavailable` if the sandbox fs is not present (local `vite dev`\n * / before boot — gate with {@link fsAvailable}). Per-op failures throw {@link FsError}\n * with a mapped `.code` (`not-found`, `read-only`, …).\n */\nexport function openFs(mount: SandboxMount): MountFs {\n const root = mount.path;\n\n const port = (): NodeFsPromises => {\n const p = sandboxFs();\n if (!p) throw fsError('unavailable', 'immediately.run: sandbox filesystem unavailable');\n return promisesOf(p);\n };\n\n const api: MountFs = {\n mount,\n async readFile(relPath: string, encoding?: 'utf8'): Promise<any> {\n const p = port();\n const abs = resolveUnder(root, relPath);\n try {\n const data = await p.readFile(abs);\n const bytes =\n typeof data === 'string' ? encoder.encode(data) : (data as Uint8Array);\n return encoding === 'utf8' ? decoder.decode(bytes) : bytes;\n } catch (e) {\n throw mapError(e);\n }\n },\n async writeFile(relPath, data) {\n const p = port();\n const abs = resolveUnder(root, relPath);\n try {\n await p.writeFile(abs, typeof data === 'string' ? encoder.encode(data) : data);\n } catch (e) {\n throw mapError(e);\n }\n },\n async readdir(relPath = '') {\n const p = port();\n const abs = resolveUnder(root, relPath);\n try {\n const entries = await p.readdir(abs, { withFileTypes: true });\n return entries.map((d: any) =>\n typeof d === 'string'\n ? ({ name: d, kind: 'file' } as DirEntry)\n : ({ name: d.name, kind: d.isDirectory?.() ? 'dir' : 'file' } as DirEntry),\n );\n } catch (e) {\n throw mapError(e);\n }\n },\n async stat(relPath) {\n const p = port();\n const abs = resolveUnder(root, relPath);\n try {\n const s: any = await p.stat(abs);\n return {\n kind: s.isDirectory?.() ? 'dir' : 'file',\n size: typeof s.size === 'number' ? s.size : 0,\n mtimeMs: typeof s.mtimeMs === 'number' ? s.mtimeMs : undefined,\n };\n } catch (e) {\n throw mapError(e);\n }\n },\n async exists(relPath) {\n try {\n await api.stat(relPath);\n return true;\n } catch (e) {\n if ((e as FsError).code === 'not-found') return false;\n if ((e as FsError).code === 'unavailable' || (e as FsError).code === 'invalid-path') {\n throw e;\n }\n return false;\n }\n },\n async mkdir(relPath, opts) {\n const p = port();\n const abs = resolveUnder(root, relPath);\n try {\n await p.mkdir(abs, { recursive: opts?.recursive ?? false });\n } catch (e) {\n throw mapError(e);\n }\n },\n async rm(relPath, opts) {\n const p = port();\n const abs = resolveUnder(root, relPath);\n try {\n await p.rm(abs, { recursive: opts?.recursive ?? false });\n } catch (e) {\n throw mapError(e);\n }\n },\n async rename(fromRel, toRel) {\n const p = port();\n const from = resolveUnder(root, fromRel);\n const to = resolveUnder(root, toRel);\n try {\n await p.rename(from, to);\n } catch (e) {\n throw mapError(e);\n }\n },\n canWrite(relPath = '') {\n return writableAt(mount, relPath);\n },\n };\n return api;\n}\n\n/** Open a mount-anchored view of this app's OWN repository working tree — a convenience\n * over {@link openFs} using `getAppMountPath()` (FILE_SHARING_SPEC §11.2). */\nexport function openAppFs(): MountFs {\n return openFs({ path: getAppMountPath(), type: 'repo' } as SandboxMount);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,oBAAgC;AAsBhC,MAAM,QAAQ,CAAC,OACb,OAAO,IAAI,UAAU,aAAa,cAAc,OAAO,IAAI,aAAa;AAcnE,SAAS,YAAkC;AAChD,MAAI;AACF,UAAM,SAAU,WAAmB;AACnC,QAAI,MAAM,MAAM,EAAG,QAAO;AAAA,EAC5B,QAAQ;AAAA,EAER;AACA,MAAI;AAEF,UAAM,SAAS,QAAQ,YAAY,QAAQ,SAAS,IAAI;AACxD,QAAI,MAAM,QAAQ,MAAM,GAAG;AACzB,iBAAW,SAAS,QAAQ;AAC1B,cAAM,KAAK,OAAO,cAAc;AAChC,YAAI,MAAM,EAAE,EAAG,QAAO;AAAA,MACxB;AAAA,IACF;AAAA,EACF,QAAQ;AAAA,EAER;AACA,SAAO;AACT;AAIO,SAAS,cAAuB;AACrC,SAAO,UAAU,KAAK;AACxB;AA6BA,MAAM,QAAyC;AAAA,EAC7C,QAAQ;AAAA,EACR,OAAO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