@immediately-run/sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +36 -0
- package/dist/MDXProvider.cjs +58 -0
- package/dist/MDXProvider.cjs.map +1 -0
- package/dist/MDXProvider.d.cts +6 -0
- package/dist/MDXProvider.d.ts +6 -0
- package/dist/MDXProvider.js +33 -0
- package/dist/MDXProvider.js.map +1 -0
- package/dist/RoutingSpec.cjs +17 -0
- package/dist/RoutingSpec.cjs.map +1 -0
- package/dist/RoutingSpec.d.cts +12 -0
- package/dist/RoutingSpec.d.ts +12 -0
- package/dist/RoutingSpec.js +1 -0
- package/dist/RoutingSpec.js.map +1 -0
- package/dist/TinkerableContext.cjs +30 -0
- package/dist/TinkerableContext.cjs.map +1 -0
- package/dist/TinkerableContext.d.cts +27 -0
- package/dist/TinkerableContext.d.ts +27 -0
- package/dist/TinkerableContext.js +6 -0
- package/dist/TinkerableContext.js.map +1 -0
- package/dist/boot.cjs +119 -0
- package/dist/boot.cjs.map +1 -0
- package/dist/boot.d.cts +15 -0
- package/dist/boot.d.ts +15 -0
- package/dist/boot.js +93 -0
- package/dist/boot.js.map +1 -0
- package/dist/components/FileRouter.cjs +53 -0
- package/dist/components/FileRouter.cjs.map +1 -0
- package/dist/components/FileRouter.d.cts +5 -0
- package/dist/components/FileRouter.d.ts +5 -0
- package/dist/components/FileRouter.js +29 -0
- package/dist/components/FileRouter.js.map +1 -0
- package/dist/components/Include.cjs +57 -0
- package/dist/components/Include.cjs.map +1 -0
- package/dist/components/Include.d.cts +23 -0
- package/dist/components/Include.d.ts +23 -0
- package/dist/components/Include.js +31 -0
- package/dist/components/Include.js.map +1 -0
- package/dist/components/MDXComponents.cjs +75 -0
- package/dist/components/MDXComponents.cjs.map +1 -0
- package/dist/components/MDXComponents.d.cts +10 -0
- package/dist/components/MDXComponents.d.ts +10 -0
- package/dist/components/MDXComponents.js +49 -0
- package/dist/components/MDXComponents.js.map +1 -0
- package/dist/components/MainContent.cjs +74 -0
- package/dist/components/MainContent.cjs.map +1 -0
- package/dist/components/MainContent.d.cts +16 -0
- package/dist/components/MainContent.d.ts +16 -0
- package/dist/components/MainContent.js +48 -0
- package/dist/components/MainContent.js.map +1 -0
- package/dist/components/defaults.cjs +36 -0
- package/dist/components/defaults.cjs.map +1 -0
- package/dist/components/defaults.d.cts +7 -0
- package/dist/components/defaults.d.ts +7 -0
- package/dist/components/defaults.js +11 -0
- package/dist/components/defaults.js.map +1 -0
- package/dist/components/errors.cjs +38 -0
- package/dist/components/errors.cjs.map +1 -0
- package/dist/components/errors.d.cts +5 -0
- package/dist/components/errors.d.ts +5 -0
- package/dist/components/errors.js +14 -0
- package/dist/components/errors.js.map +1 -0
- package/dist/contextUtils.cjs +60 -0
- package/dist/contextUtils.cjs.map +1 -0
- package/dist/contextUtils.d.cts +10 -0
- package/dist/contextUtils.d.ts +10 -0
- package/dist/contextUtils.js +34 -0
- package/dist/contextUtils.js.map +1 -0
- package/dist/hooks.cjs +75 -0
- package/dist/hooks.cjs.map +1 -0
- package/dist/hooks.d.cts +6 -0
- package/dist/hooks.d.ts +6 -0
- package/dist/hooks.js +50 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.cjs +35 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/moduleCache.cjs +66 -0
- package/dist/moduleCache.cjs.map +1 -0
- package/dist/moduleCache.d.cts +20 -0
- package/dist/moduleCache.d.ts +20 -0
- package/dist/moduleCache.js +40 -0
- package/dist/moduleCache.js.map +1 -0
- package/dist/pathUtils.cjs +63 -0
- package/dist/pathUtils.cjs.map +1 -0
- package/dist/pathUtils.d.cts +4 -0
- package/dist/pathUtils.d.ts +4 -0
- package/dist/pathUtils.js +38 -0
- package/dist/pathUtils.js.map +1 -0
- package/dist/routing.cjs +84 -0
- package/dist/routing.cjs.map +1 -0
- package/dist/routing.d.cts +15 -0
- package/dist/routing.d.ts +15 -0
- package/dist/routing.js +57 -0
- package/dist/routing.js.map +1 -0
- package/dist/sandboxTypes.cjs +17 -0
- package/dist/sandboxTypes.cjs.map +1 -0
- package/dist/sandboxTypes.d.cts +24 -0
- package/dist/sandboxTypes.d.ts +24 -0
- package/dist/sandboxTypes.js +1 -0
- package/dist/sandboxTypes.js.map +1 -0
- package/dist/sandboxUtils.cjs +46 -0
- package/dist/sandboxUtils.cjs.map +1 -0
- package/dist/sandboxUtils.d.cts +5 -0
- package/dist/sandboxUtils.d.ts +5 -0
- package/dist/sandboxUtils.js +20 -0
- package/dist/sandboxUtils.js.map +1 -0
- package/dist/urlUtils.cjs +159 -0
- package/dist/urlUtils.cjs.map +1 -0
- package/dist/urlUtils.d.cts +24 -0
- package/dist/urlUtils.d.ts +24 -0
- package/dist/urlUtils.js +124 -0
- package/dist/urlUtils.js.map +1 -0
- package/package.json +53 -0
|
@@ -0,0 +1,53 @@
|
|
|
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 FileRouter_exports = {};
|
|
20
|
+
__export(FileRouter_exports, {
|
|
21
|
+
FileRouter: () => FileRouter
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(FileRouter_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
var import_TinkerableContext = require("../TinkerableContext");
|
|
27
|
+
var import_defaults = require("./defaults");
|
|
28
|
+
var import_Include = require("./Include");
|
|
29
|
+
const FileRouter = ({
|
|
30
|
+
LoadingComponent = import_defaults.defaultLoadingComponent,
|
|
31
|
+
ErrorComponent = import_defaults.defaultErrorComponent
|
|
32
|
+
} = {}) => {
|
|
33
|
+
const { navigationState: { pathParameters, sandboxPath } } = (0, import_react.useContext)(import_TinkerableContext.TinkerableContext);
|
|
34
|
+
const filename = pathParameters?.filename;
|
|
35
|
+
if (!filename) {
|
|
36
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorComponent, { error: new Error(`No filename could be extracted from ${sandboxPath}`), resetErrorBoundary: () => {
|
|
37
|
+
} });
|
|
38
|
+
}
|
|
39
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
40
|
+
import_Include.Include,
|
|
41
|
+
{
|
|
42
|
+
filename,
|
|
43
|
+
LoadingComponent,
|
|
44
|
+
ErrorComponent,
|
|
45
|
+
baseModule: module
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
FileRouter
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=FileRouter.cjs.map
|
|
@@ -0,0 +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 { 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 return <Include\n filename={filename}\n LoadingComponent={LoadingComponent}\n ErrorComponent={ErrorComponent}\n // @ts-ignore\n baseModule={module}\n />\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBW;AAhBX,mBAA2B;AAE3B,+BAAkC;AAClC,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;AACA,SAAO;AAAA,IAAC;AAAA;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MAEA,YAAY;AAAA;AAAA,EACd;AACF;","names":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
import { TinkerableContext } from "../TinkerableContext";
|
|
4
|
+
import { defaultErrorComponent, defaultLoadingComponent } from "./defaults";
|
|
5
|
+
import { Include } from "./Include";
|
|
6
|
+
const FileRouter = ({
|
|
7
|
+
LoadingComponent = defaultLoadingComponent,
|
|
8
|
+
ErrorComponent = defaultErrorComponent
|
|
9
|
+
} = {}) => {
|
|
10
|
+
const { navigationState: { pathParameters, sandboxPath } } = useContext(TinkerableContext);
|
|
11
|
+
const filename = pathParameters?.filename;
|
|
12
|
+
if (!filename) {
|
|
13
|
+
return /* @__PURE__ */ jsx(ErrorComponent, { error: new Error(`No filename could be extracted from ${sandboxPath}`), resetErrorBoundary: () => {
|
|
14
|
+
} });
|
|
15
|
+
}
|
|
16
|
+
return /* @__PURE__ */ jsx(
|
|
17
|
+
Include,
|
|
18
|
+
{
|
|
19
|
+
filename,
|
|
20
|
+
LoadingComponent,
|
|
21
|
+
ErrorComponent,
|
|
22
|
+
baseModule: module
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
FileRouter
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=FileRouter.js.map
|
|
@@ -0,0 +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 { 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 return <Include\n filename={filename}\n LoadingComponent={LoadingComponent}\n ErrorComponent={ErrorComponent}\n // @ts-ignore\n baseModule={module}\n />\n};\n"],"mappings":"AAiBW;AAhBX,SAAS,kBAAkB;AAE3B,SAAS,yBAAyB;AAClC,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;AACA,SAAO;AAAA,IAAC;AAAA;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MAEA,YAAY;AAAA;AAAA,EACd;AACF;","names":[]}
|
|
@@ -0,0 +1,57 @@
|
|
|
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 Include_exports = {};
|
|
20
|
+
__export(Include_exports, {
|
|
21
|
+
Include: () => Include,
|
|
22
|
+
RenderExportedComponent: () => RenderExportedComponent,
|
|
23
|
+
RenderExportedComponentContext: () => RenderExportedComponentContext
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(Include_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_moduleCache = require("../moduleCache");
|
|
30
|
+
var import_defaults = require("./defaults");
|
|
31
|
+
const RenderExportedComponentContext = (0, import_react.createContext)(null);
|
|
32
|
+
const RenderExportedComponent = ({
|
|
33
|
+
evaluationContextPromise,
|
|
34
|
+
exportedSymbol = "default"
|
|
35
|
+
}) => {
|
|
36
|
+
const evaluationContext = (0, import_react.use)(evaluationContextPromise);
|
|
37
|
+
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, {}) });
|
|
39
|
+
};
|
|
40
|
+
const Include = ({
|
|
41
|
+
filename,
|
|
42
|
+
exportedSymbol = "default",
|
|
43
|
+
LoadingComponent = import_defaults.defaultLoadingComponent,
|
|
44
|
+
ErrorComponent = import_defaults.defaultErrorComponent,
|
|
45
|
+
baseModule
|
|
46
|
+
}) => {
|
|
47
|
+
const moduleCache = (0, import_react.use)(import_moduleCache.ModuleCacheContext);
|
|
48
|
+
const evaluationContextPromise = moduleCache.getEvaluationContext(filename, baseModule ?? module);
|
|
49
|
+
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
|
+
};
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
Include,
|
|
54
|
+
RenderExportedComponent,
|
|
55
|
+
RenderExportedComponentContext
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=Include.cjs.map
|
|
@@ -0,0 +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\nexport type RenderFileContextType = {\n evaluationContext: EvaluationContext;\n};\n\nexport const RenderExportedComponentContext = createContext<RenderFileContextType | null>(null);\n\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\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;AAyBM;AAzBN,mBAA6C;AAC7C,kCAA8B;AAE9B,yBAAmC;AAEnC,sBAA+D;AAMxD,MAAM,qCAAiC,4BAA4C,IAAI;AAEvF,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;AAEO,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":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import { EvaluationContext } from '../sandboxTypes.cjs';
|
|
4
|
+
import { defaultLoadingComponent, defaultErrorComponent } from './defaults.cjs';
|
|
5
|
+
import 'react-error-boundary';
|
|
6
|
+
|
|
7
|
+
type RenderFileContextType = {
|
|
8
|
+
evaluationContext: EvaluationContext;
|
|
9
|
+
};
|
|
10
|
+
declare const RenderExportedComponentContext: react.Context<RenderFileContextType | null>;
|
|
11
|
+
declare const RenderExportedComponent: ({ evaluationContextPromise, exportedSymbol, }: {
|
|
12
|
+
evaluationContextPromise: Promise<EvaluationContext>;
|
|
13
|
+
exportedSymbol: string;
|
|
14
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
15
|
+
declare const Include: ({ filename, exportedSymbol, LoadingComponent, ErrorComponent, baseModule, }: {
|
|
16
|
+
filename: string;
|
|
17
|
+
exportedSymbol?: string;
|
|
18
|
+
LoadingComponent?: typeof defaultLoadingComponent;
|
|
19
|
+
ErrorComponent?: typeof defaultErrorComponent;
|
|
20
|
+
baseModule?: EvaluationContext;
|
|
21
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
22
|
+
|
|
23
|
+
export { Include, RenderExportedComponent, RenderExportedComponentContext, type RenderFileContextType };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import { EvaluationContext } from '../sandboxTypes.js';
|
|
4
|
+
import { defaultLoadingComponent, defaultErrorComponent } from './defaults.js';
|
|
5
|
+
import 'react-error-boundary';
|
|
6
|
+
|
|
7
|
+
type RenderFileContextType = {
|
|
8
|
+
evaluationContext: EvaluationContext;
|
|
9
|
+
};
|
|
10
|
+
declare const RenderExportedComponentContext: react.Context<RenderFileContextType | null>;
|
|
11
|
+
declare const RenderExportedComponent: ({ evaluationContextPromise, exportedSymbol, }: {
|
|
12
|
+
evaluationContextPromise: Promise<EvaluationContext>;
|
|
13
|
+
exportedSymbol: string;
|
|
14
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
15
|
+
declare const Include: ({ filename, exportedSymbol, LoadingComponent, ErrorComponent, baseModule, }: {
|
|
16
|
+
filename: string;
|
|
17
|
+
exportedSymbol?: string;
|
|
18
|
+
LoadingComponent?: typeof defaultLoadingComponent;
|
|
19
|
+
ErrorComponent?: typeof defaultErrorComponent;
|
|
20
|
+
baseModule?: EvaluationContext;
|
|
21
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
22
|
+
|
|
23
|
+
export { Include, RenderExportedComponent, RenderExportedComponentContext, type RenderFileContextType };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Suspense, createContext, use } from "react";
|
|
3
|
+
import { ErrorBoundary } from "react-error-boundary";
|
|
4
|
+
import { ModuleCacheContext } from "../moduleCache";
|
|
5
|
+
import { defaultErrorComponent, defaultLoadingComponent } from "./defaults";
|
|
6
|
+
const RenderExportedComponentContext = createContext(null);
|
|
7
|
+
const RenderExportedComponent = ({
|
|
8
|
+
evaluationContextPromise,
|
|
9
|
+
exportedSymbol = "default"
|
|
10
|
+
}) => {
|
|
11
|
+
const evaluationContext = use(evaluationContextPromise);
|
|
12
|
+
const Component = exportedSymbol === "*" ? evaluationContext.exports : evaluationContext.exports[exportedSymbol];
|
|
13
|
+
return /* @__PURE__ */ jsx(RenderExportedComponentContext, { value: { evaluationContext }, children: /* @__PURE__ */ jsx(Component, {}) });
|
|
14
|
+
};
|
|
15
|
+
const Include = ({
|
|
16
|
+
filename,
|
|
17
|
+
exportedSymbol = "default",
|
|
18
|
+
LoadingComponent = defaultLoadingComponent,
|
|
19
|
+
ErrorComponent = defaultErrorComponent,
|
|
20
|
+
baseModule
|
|
21
|
+
}) => {
|
|
22
|
+
const moduleCache = use(ModuleCacheContext);
|
|
23
|
+
const evaluationContextPromise = moduleCache.getEvaluationContext(filename, baseModule ?? module);
|
|
24
|
+
return /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorComponent, children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingComponent, {}), children: /* @__PURE__ */ jsx(RenderExportedComponent, { evaluationContextPromise, exportedSymbol }) }) });
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
Include,
|
|
28
|
+
RenderExportedComponent,
|
|
29
|
+
RenderExportedComponentContext
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=Include.js.map
|
|
@@ -0,0 +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\nexport type RenderFileContextType = {\n evaluationContext: EvaluationContext;\n};\n\nexport const RenderExportedComponentContext = createContext<RenderFileContextType | null>(null);\n\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\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":"AAyBM;AAzBN,SAAS,UAAU,eAAe,WAAW;AAC7C,SAAS,qBAAqB;AAE9B,SAAS,0BAA0B;AAEnC,SAAS,uBAAuB,+BAA+B;AAMxD,MAAM,iCAAiC,cAA4C,IAAI;AAEvF,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;AAEO,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":[]}
|
|
@@ -0,0 +1,75 @@
|
|
|
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 MDXComponents_exports = {};
|
|
20
|
+
__export(MDXComponents_exports, {
|
|
21
|
+
DEFAULT_MDX_COMPONENTS: () => DEFAULT_MDX_COMPONENTS,
|
|
22
|
+
InternalLink: () => InternalLink,
|
|
23
|
+
Link: () => Link
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(MDXComponents_exports);
|
|
26
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
var import_routing = require("../routing");
|
|
29
|
+
var import_TinkerableContext = require("../TinkerableContext");
|
|
30
|
+
var import_urlUtils = require("../urlUtils");
|
|
31
|
+
const InternalLink = ({
|
|
32
|
+
href,
|
|
33
|
+
children,
|
|
34
|
+
...props
|
|
35
|
+
}) => {
|
|
36
|
+
const clickHandler = (0, import_react.useCallback)(
|
|
37
|
+
(e) => {
|
|
38
|
+
if (href) {
|
|
39
|
+
e.preventDefault();
|
|
40
|
+
(0, import_routing.navigate)(href);
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
[href]
|
|
44
|
+
);
|
|
45
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href, onClick: clickHandler, ...props, children });
|
|
46
|
+
};
|
|
47
|
+
const Link = ({
|
|
48
|
+
href,
|
|
49
|
+
children,
|
|
50
|
+
...properties
|
|
51
|
+
}) => {
|
|
52
|
+
const { outerHref, navigationState } = (0, import_react.use)(import_TinkerableContext.TinkerableContext);
|
|
53
|
+
if (href && (0, import_urlUtils.isInternalHref)(outerHref, href, navigationState)) {
|
|
54
|
+
const targetHref = (0, import_urlUtils.constructOuterUrl)(outerHref, href, navigationState);
|
|
55
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InternalLink, { href: targetHref, ...properties, children });
|
|
56
|
+
} else {
|
|
57
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { ...{ href, ...properties }, children });
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const DEFAULT_MDX_COMPONENTS = {
|
|
61
|
+
a({
|
|
62
|
+
href,
|
|
63
|
+
children,
|
|
64
|
+
...properties
|
|
65
|
+
}) {
|
|
66
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Link, { href, ...properties, children });
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
70
|
+
0 && (module.exports = {
|
|
71
|
+
DEFAULT_MDX_COMPONENTS,
|
|
72
|
+
InternalLink,
|
|
73
|
+
Link
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=MDXComponents.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/MDXComponents.tsx"],"sourcesContent":["import { ReactNode, use, useCallback } from 'react';\nimport { navigate } from '../routing';\nimport { TinkerableContext } from '../TinkerableContext';\nimport { constructOuterUrl, constructUrl, isInternalHref, repositoryPrefixURL } from '../urlUtils';\n\nexport const InternalLink = ({\n href,\n children,\n ...props\n}: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>): ReactNode => {\n const clickHandler = useCallback(\n (e: any) => {\n if (href) {\n e.preventDefault();\n navigate(href);\n }\n },\n [href]\n );\n return (\n <a href={href} onClick={clickHandler} {...props}>\n {children}\n </a>\n );\n};\n\nexport const Link = ({\n href,\n children,\n ...properties\n}: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>): ReactNode => {\n const { outerHref, navigationState } = use(TinkerableContext);\n if (href && isInternalHref(outerHref, href, navigationState)) {\n const targetHref = constructOuterUrl(outerHref, href, navigationState);\n return (\n <InternalLink href={targetHref} {...properties}>\n {children}\n </InternalLink>\n );\n } else {\n // create a regular link to external resource\n return <a {...{ href, ...properties }}>{children}</a>;\n }\n};\n\nexport const DEFAULT_MDX_COMPONENTS = {\n a({\n href,\n children,\n ...properties\n }: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>) {\n return (\n <Link href={href} {...properties}>\n {children}\n </Link>\n );\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBI;AApBJ,mBAA4C;AAC5C,qBAAyB;AACzB,+BAAkC;AAClC,sBAAqF;AAE9E,MAAM,eAAe,CAAC;AAAA,EAC3B;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAA4G;AAC1G,QAAM,mBAAe;AAAA,IACnB,CAAC,MAAW;AACV,UAAI,MAAM;AACR,UAAE,eAAe;AACjB,qCAAS,IAAI;AAAA,MACf;AAAA,IACF;AAAA,IACA,CAAC,IAAI;AAAA,EACP;AACA,SACE,4CAAC,OAAE,MAAY,SAAS,cAAe,GAAG,OACvC,UACH;AAEJ;AAEO,MAAM,OAAO,CAAC;AAAA,EACnB;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAA4G;AAC1G,QAAM,EAAE,WAAW,gBAAgB,QAAI,kBAAI,0CAAiB;AAC5D,MAAI,YAAQ,gCAAe,WAAW,MAAM,eAAe,GAAG;AAC5D,UAAM,iBAAa,mCAAkB,WAAW,MAAM,eAAe;AACrE,WACE,4CAAC,gBAAa,MAAM,YAAa,GAAG,YACjC,UACH;AAAA,EAEJ,OAAO;AAEL,WAAO,4CAAC,OAAG,GAAG,EAAE,MAAM,GAAG,WAAW,GAAI,UAAS;AAAA,EACnD;AACF;AAEO,MAAM,yBAAyB;AAAA,EACpC,EAAE;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GAA8F;AAC5F,WACE,4CAAC,QAAK,MAAa,GAAG,YACnB,UACH;AAAA,EAEJ;AACF;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
declare const InternalLink: ({ href, children, ...props }: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>) => ReactNode;
|
|
5
|
+
declare const Link: ({ href, children, ...properties }: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>) => ReactNode;
|
|
6
|
+
declare const DEFAULT_MDX_COMPONENTS: {
|
|
7
|
+
a({ href, children, ...properties }: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>): react_jsx_runtime.JSX.Element;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { DEFAULT_MDX_COMPONENTS, InternalLink, Link };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
declare const InternalLink: ({ href, children, ...props }: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>) => ReactNode;
|
|
5
|
+
declare const Link: ({ href, children, ...properties }: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>) => ReactNode;
|
|
6
|
+
declare const DEFAULT_MDX_COMPONENTS: {
|
|
7
|
+
a({ href, children, ...properties }: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>): react_jsx_runtime.JSX.Element;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { DEFAULT_MDX_COMPONENTS, InternalLink, Link };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { use, useCallback } from "react";
|
|
3
|
+
import { navigate } from "../routing";
|
|
4
|
+
import { TinkerableContext } from "../TinkerableContext";
|
|
5
|
+
import { constructOuterUrl, isInternalHref } from "../urlUtils";
|
|
6
|
+
const InternalLink = ({
|
|
7
|
+
href,
|
|
8
|
+
children,
|
|
9
|
+
...props
|
|
10
|
+
}) => {
|
|
11
|
+
const clickHandler = useCallback(
|
|
12
|
+
(e) => {
|
|
13
|
+
if (href) {
|
|
14
|
+
e.preventDefault();
|
|
15
|
+
navigate(href);
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
[href]
|
|
19
|
+
);
|
|
20
|
+
return /* @__PURE__ */ jsx("a", { href, onClick: clickHandler, ...props, children });
|
|
21
|
+
};
|
|
22
|
+
const Link = ({
|
|
23
|
+
href,
|
|
24
|
+
children,
|
|
25
|
+
...properties
|
|
26
|
+
}) => {
|
|
27
|
+
const { outerHref, navigationState } = use(TinkerableContext);
|
|
28
|
+
if (href && isInternalHref(outerHref, href, navigationState)) {
|
|
29
|
+
const targetHref = constructOuterUrl(outerHref, href, navigationState);
|
|
30
|
+
return /* @__PURE__ */ jsx(InternalLink, { href: targetHref, ...properties, children });
|
|
31
|
+
} else {
|
|
32
|
+
return /* @__PURE__ */ jsx("a", { ...{ href, ...properties }, children });
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const DEFAULT_MDX_COMPONENTS = {
|
|
36
|
+
a({
|
|
37
|
+
href,
|
|
38
|
+
children,
|
|
39
|
+
...properties
|
|
40
|
+
}) {
|
|
41
|
+
return /* @__PURE__ */ jsx(Link, { href, ...properties, children });
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
export {
|
|
45
|
+
DEFAULT_MDX_COMPONENTS,
|
|
46
|
+
InternalLink,
|
|
47
|
+
Link
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=MDXComponents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/MDXComponents.tsx"],"sourcesContent":["import { ReactNode, use, useCallback } from 'react';\nimport { navigate } from '../routing';\nimport { TinkerableContext } from '../TinkerableContext';\nimport { constructOuterUrl, constructUrl, isInternalHref, repositoryPrefixURL } from '../urlUtils';\n\nexport const InternalLink = ({\n href,\n children,\n ...props\n}: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>): ReactNode => {\n const clickHandler = useCallback(\n (e: any) => {\n if (href) {\n e.preventDefault();\n navigate(href);\n }\n },\n [href]\n );\n return (\n <a href={href} onClick={clickHandler} {...props}>\n {children}\n </a>\n );\n};\n\nexport const Link = ({\n href,\n children,\n ...properties\n}: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>): ReactNode => {\n const { outerHref, navigationState } = use(TinkerableContext);\n if (href && isInternalHref(outerHref, href, navigationState)) {\n const targetHref = constructOuterUrl(outerHref, href, navigationState);\n return (\n <InternalLink href={targetHref} {...properties}>\n {children}\n </InternalLink>\n );\n } else {\n // create a regular link to external resource\n return <a {...{ href, ...properties }}>{children}</a>;\n }\n};\n\nexport const DEFAULT_MDX_COMPONENTS = {\n a({\n href,\n children,\n ...properties\n }: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>) {\n return (\n <Link href={href} {...properties}>\n {children}\n </Link>\n );\n },\n};\n"],"mappings":"AAoBI;AApBJ,SAAoB,KAAK,mBAAmB;AAC5C,SAAS,gBAAgB;AACzB,SAAS,yBAAyB;AAClC,SAAS,mBAAiC,sBAA2C;AAE9E,MAAM,eAAe,CAAC;AAAA,EAC3B;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAA4G;AAC1G,QAAM,eAAe;AAAA,IACnB,CAAC,MAAW;AACV,UAAI,MAAM;AACR,UAAE,eAAe;AACjB,iBAAS,IAAI;AAAA,MACf;AAAA,IACF;AAAA,IACA,CAAC,IAAI;AAAA,EACP;AACA,SACE,oBAAC,OAAE,MAAY,SAAS,cAAe,GAAG,OACvC,UACH;AAEJ;AAEO,MAAM,OAAO,CAAC;AAAA,EACnB;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAA4G;AAC1G,QAAM,EAAE,WAAW,gBAAgB,IAAI,IAAI,iBAAiB;AAC5D,MAAI,QAAQ,eAAe,WAAW,MAAM,eAAe,GAAG;AAC5D,UAAM,aAAa,kBAAkB,WAAW,MAAM,eAAe;AACrE,WACE,oBAAC,gBAAa,MAAM,YAAa,GAAG,YACjC,UACH;AAAA,EAEJ,OAAO;AAEL,WAAO,oBAAC,OAAG,GAAG,EAAE,MAAM,GAAG,WAAW,GAAI,UAAS;AAAA,EACnD;AACF;AAEO,MAAM,yBAAyB;AAAA,EACpC,EAAE;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GAA8F;AAC5F,WACE,oBAAC,QAAK,MAAa,GAAG,YACnB,UACH;AAAA,EAEJ;AACF;","names":[]}
|
|
@@ -0,0 +1,74 @@
|
|
|
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 MainContent_exports = {};
|
|
20
|
+
__export(MainContent_exports, {
|
|
21
|
+
MainContent: () => MainContent,
|
|
22
|
+
MainContentInner: () => MainContentInner,
|
|
23
|
+
MainContentRedirect: () => MainContentRedirect
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(MainContent_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_routing = require("../routing");
|
|
30
|
+
var import_urlUtils = require("../urlUtils");
|
|
31
|
+
var import_defaults = require("./defaults");
|
|
32
|
+
const directories = ["/", "/src/"];
|
|
33
|
+
const basenames = ["App", "landing", "main", "README"];
|
|
34
|
+
const extensions = [".js", ".jsx", ".mjs", ".cjs", ".ts", ".tsx", ".mdx", ".md"];
|
|
35
|
+
const candidates = directories.flatMap(
|
|
36
|
+
(dir) => basenames.flatMap((basename) => extensions.map((ext) => `${dir}${basename}${ext}`))
|
|
37
|
+
);
|
|
38
|
+
const fileExists = async (path) => {
|
|
39
|
+
const bundler = module.evaluation.module.bundler;
|
|
40
|
+
const exists = await bundler.fs.isFile.async(path);
|
|
41
|
+
return [path, exists];
|
|
42
|
+
};
|
|
43
|
+
const MainContentRedirect = ({ filename }) => {
|
|
44
|
+
const url = (0, import_routing.useTinkerableLink)(filename);
|
|
45
|
+
(0, import_routing.navigate)(url);
|
|
46
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
47
|
+
"Redirecting to ",
|
|
48
|
+
filename
|
|
49
|
+
] });
|
|
50
|
+
};
|
|
51
|
+
const MainContentInner = ({
|
|
52
|
+
candidatesExistPromise
|
|
53
|
+
}) => {
|
|
54
|
+
const candidatesExist = (0, import_react.use)(candidatesExistPromise);
|
|
55
|
+
const filename = candidatesExist.find(([_, exists]) => exists)?.[0];
|
|
56
|
+
if (!filename) {
|
|
57
|
+
throw new Error(`No main content file present`);
|
|
58
|
+
}
|
|
59
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MainContentRedirect, { filename: import_urlUtils.FILES_PREFIX + filename });
|
|
60
|
+
};
|
|
61
|
+
const MainContent = ({
|
|
62
|
+
LoadingComponent = import_defaults.defaultLoadingComponent,
|
|
63
|
+
ErrorComponent = import_defaults.defaultErrorComponent
|
|
64
|
+
} = {}) => {
|
|
65
|
+
const candidatesExistPromise = (0, import_react.useMemo)(() => Promise.all(candidates.map(fileExists)), []);
|
|
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)(MainContentInner, { candidatesExistPromise }) }) });
|
|
67
|
+
};
|
|
68
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
+
0 && (module.exports = {
|
|
70
|
+
MainContent,
|
|
71
|
+
MainContentInner,
|
|
72
|
+
MainContentRedirect
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=MainContent.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/MainContent.tsx"],"sourcesContent":["import { Suspense, use, useMemo } from 'react';\nimport { ErrorBoundary } from 'react-error-boundary';\nimport { navigate, useTinkerableLink } from '../routing';\nimport { FILES_PREFIX } from '../urlUtils';\n\nimport { defaultErrorComponent, defaultLoadingComponent } from './defaults';\n\nconst directories = ['/', '/src/'];\nconst basenames = ['App', 'landing', 'main', 'README'];\nconst extensions = ['.js', '.jsx', '.mjs', '.cjs', '.ts', '.tsx', '.mdx', '.md'];\nconst candidates = directories.flatMap((dir) =>\n basenames.flatMap((basename) => extensions.map((ext) => `${dir}${basename}${ext}`))\n);\n\nconst fileExists = async (path: string): Promise<[string, boolean]> => {\n // @ts-ignore\n const bundler = module.evaluation.module.bundler;\n const exists = await bundler.fs.isFile.async(path);\n return [path, exists];\n};\n\nexport const MainContentRedirect = ({filename}:{filename:string}) => {\n const url = useTinkerableLink(filename);\n navigate(url);\n return <>Redirecting to {filename}</>;\n}\n\nexport const MainContentInner = ({\n candidatesExistPromise,\n}: {\n candidatesExistPromise: Promise<[string, boolean][]>;\n}) => {\n const candidatesExist = use(candidatesExistPromise);\n const filename = candidatesExist.find(([_, exists]) => exists)?.[0];\n if (!filename) {\n // todo: show file list\n throw new Error(`No main content file present`);\n }\n return <MainContentRedirect filename={FILES_PREFIX + filename}/>;\n};\n\nexport const MainContent = ({\n LoadingComponent = defaultLoadingComponent,\n ErrorComponent = defaultErrorComponent,\n}: {\n LoadingComponent?: typeof defaultLoadingComponent;\n ErrorComponent?: typeof defaultErrorComponent;\n} = {}) => {\n // TODO: when to invalidate?\n const candidatesExistPromise = useMemo(() => Promise.all(candidates.map(fileExists)), []);\n return (\n <ErrorBoundary fallbackRender={ErrorComponent}>\n <Suspense fallback={<LoadingComponent />}>\n <MainContentInner candidatesExistPromise={candidatesExistPromise} />\n </Suspense>\n </ErrorBoundary>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwBS;AAxBT,mBAAuC;AACvC,kCAA8B;AAC9B,qBAA4C;AAC5C,sBAA6B;AAE7B,sBAA+D;AAE/D,MAAM,cAAc,CAAC,KAAK,OAAO;AACjC,MAAM,YAAY,CAAC,OAAO,WAAW,QAAQ,QAAQ;AACrD,MAAM,aAAa,CAAC,OAAO,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,QAAQ,KAAK;AAC/E,MAAM,aAAa,YAAY;AAAA,EAAQ,CAAC,QACtC,UAAU,QAAQ,CAAC,aAAa,WAAW,IAAI,CAAC,QAAQ,GAAG,GAAG,GAAG,QAAQ,GAAG,GAAG,EAAE,CAAC;AACpF;AAEA,MAAM,aAAa,OAAO,SAA6C;AAErE,QAAM,UAAU,OAAO,WAAW,OAAO;AACzC,QAAM,SAAS,MAAM,QAAQ,GAAG,OAAO,MAAM,IAAI;AACjD,SAAO,CAAC,MAAM,MAAM;AACtB;AAEO,MAAM,sBAAsB,CAAC,EAAC,SAAQ,MAAwB;AACnE,QAAM,UAAM,kCAAkB,QAAQ;AACtC,+BAAS,GAAG;AACZ,SAAO,4EAAE;AAAA;AAAA,IAAgB;AAAA,KAAS;AACpC;AAEO,MAAM,mBAAmB,CAAC;AAAA,EAC/B;AACF,MAEM;AACJ,QAAM,sBAAkB,kBAAI,sBAAsB;AAClD,QAAM,WAAW,gBAAgB,KAAK,CAAC,CAAC,GAAG,MAAM,MAAM,MAAM,IAAI,CAAC;AAClE,MAAI,CAAC,UAAU;AAEb,UAAM,IAAI,MAAM,8BAA8B;AAAA,EAChD;AACA,SAAO,4CAAC,uBAAoB,UAAU,+BAAe,UAAS;AAChE;AAEO,MAAM,cAAc,CAAC;AAAA,EAC1B,mBAAmB;AAAA,EACnB,iBAAiB;AACnB,IAGI,CAAC,MAAM;AAET,QAAM,6BAAyB,sBAAQ,MAAM,QAAQ,IAAI,WAAW,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC;AACxF,SACE,4CAAC,6CAAc,gBAAgB,gBAC7B,sDAAC,yBAAS,UAAU,4CAAC,oBAAiB,GACpC,sDAAC,oBAAiB,wBAAgD,GACpE,GACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { defaultLoadingComponent, defaultErrorComponent } from './defaults.cjs';
|
|
3
|
+
import 'react-error-boundary';
|
|
4
|
+
|
|
5
|
+
declare const MainContentRedirect: ({ filename }: {
|
|
6
|
+
filename: string;
|
|
7
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
8
|
+
declare const MainContentInner: ({ candidatesExistPromise, }: {
|
|
9
|
+
candidatesExistPromise: Promise<[string, boolean][]>;
|
|
10
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
11
|
+
declare const MainContent: ({ LoadingComponent, ErrorComponent, }?: {
|
|
12
|
+
LoadingComponent?: typeof defaultLoadingComponent;
|
|
13
|
+
ErrorComponent?: typeof defaultErrorComponent;
|
|
14
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
15
|
+
|
|
16
|
+
export { MainContent, MainContentInner, MainContentRedirect };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { defaultLoadingComponent, defaultErrorComponent } from './defaults.js';
|
|
3
|
+
import 'react-error-boundary';
|
|
4
|
+
|
|
5
|
+
declare const MainContentRedirect: ({ filename }: {
|
|
6
|
+
filename: string;
|
|
7
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
8
|
+
declare const MainContentInner: ({ candidatesExistPromise, }: {
|
|
9
|
+
candidatesExistPromise: Promise<[string, boolean][]>;
|
|
10
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
11
|
+
declare const MainContent: ({ LoadingComponent, ErrorComponent, }?: {
|
|
12
|
+
LoadingComponent?: typeof defaultLoadingComponent;
|
|
13
|
+
ErrorComponent?: typeof defaultErrorComponent;
|
|
14
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
15
|
+
|
|
16
|
+
export { MainContent, MainContentInner, MainContentRedirect };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Suspense, use, useMemo } from "react";
|
|
3
|
+
import { ErrorBoundary } from "react-error-boundary";
|
|
4
|
+
import { navigate, useTinkerableLink } from "../routing";
|
|
5
|
+
import { FILES_PREFIX } from "../urlUtils";
|
|
6
|
+
import { defaultErrorComponent, defaultLoadingComponent } from "./defaults";
|
|
7
|
+
const directories = ["/", "/src/"];
|
|
8
|
+
const basenames = ["App", "landing", "main", "README"];
|
|
9
|
+
const extensions = [".js", ".jsx", ".mjs", ".cjs", ".ts", ".tsx", ".mdx", ".md"];
|
|
10
|
+
const candidates = directories.flatMap(
|
|
11
|
+
(dir) => basenames.flatMap((basename) => extensions.map((ext) => `${dir}${basename}${ext}`))
|
|
12
|
+
);
|
|
13
|
+
const fileExists = async (path) => {
|
|
14
|
+
const bundler = module.evaluation.module.bundler;
|
|
15
|
+
const exists = await bundler.fs.isFile.async(path);
|
|
16
|
+
return [path, exists];
|
|
17
|
+
};
|
|
18
|
+
const MainContentRedirect = ({ filename }) => {
|
|
19
|
+
const url = useTinkerableLink(filename);
|
|
20
|
+
navigate(url);
|
|
21
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
22
|
+
"Redirecting to ",
|
|
23
|
+
filename
|
|
24
|
+
] });
|
|
25
|
+
};
|
|
26
|
+
const MainContentInner = ({
|
|
27
|
+
candidatesExistPromise
|
|
28
|
+
}) => {
|
|
29
|
+
const candidatesExist = use(candidatesExistPromise);
|
|
30
|
+
const filename = candidatesExist.find(([_, exists]) => exists)?.[0];
|
|
31
|
+
if (!filename) {
|
|
32
|
+
throw new Error(`No main content file present`);
|
|
33
|
+
}
|
|
34
|
+
return /* @__PURE__ */ jsx(MainContentRedirect, { filename: FILES_PREFIX + filename });
|
|
35
|
+
};
|
|
36
|
+
const MainContent = ({
|
|
37
|
+
LoadingComponent = defaultLoadingComponent,
|
|
38
|
+
ErrorComponent = defaultErrorComponent
|
|
39
|
+
} = {}) => {
|
|
40
|
+
const candidatesExistPromise = useMemo(() => Promise.all(candidates.map(fileExists)), []);
|
|
41
|
+
return /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorComponent, children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingComponent, {}), children: /* @__PURE__ */ jsx(MainContentInner, { candidatesExistPromise }) }) });
|
|
42
|
+
};
|
|
43
|
+
export {
|
|
44
|
+
MainContent,
|
|
45
|
+
MainContentInner,
|
|
46
|
+
MainContentRedirect
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=MainContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/MainContent.tsx"],"sourcesContent":["import { Suspense, use, useMemo } from 'react';\nimport { ErrorBoundary } from 'react-error-boundary';\nimport { navigate, useTinkerableLink } from '../routing';\nimport { FILES_PREFIX } from '../urlUtils';\n\nimport { defaultErrorComponent, defaultLoadingComponent } from './defaults';\n\nconst directories = ['/', '/src/'];\nconst basenames = ['App', 'landing', 'main', 'README'];\nconst extensions = ['.js', '.jsx', '.mjs', '.cjs', '.ts', '.tsx', '.mdx', '.md'];\nconst candidates = directories.flatMap((dir) =>\n basenames.flatMap((basename) => extensions.map((ext) => `${dir}${basename}${ext}`))\n);\n\nconst fileExists = async (path: string): Promise<[string, boolean]> => {\n // @ts-ignore\n const bundler = module.evaluation.module.bundler;\n const exists = await bundler.fs.isFile.async(path);\n return [path, exists];\n};\n\nexport const MainContentRedirect = ({filename}:{filename:string}) => {\n const url = useTinkerableLink(filename);\n navigate(url);\n return <>Redirecting to {filename}</>;\n}\n\nexport const MainContentInner = ({\n candidatesExistPromise,\n}: {\n candidatesExistPromise: Promise<[string, boolean][]>;\n}) => {\n const candidatesExist = use(candidatesExistPromise);\n const filename = candidatesExist.find(([_, exists]) => exists)?.[0];\n if (!filename) {\n // todo: show file list\n throw new Error(`No main content file present`);\n }\n return <MainContentRedirect filename={FILES_PREFIX + filename}/>;\n};\n\nexport const MainContent = ({\n LoadingComponent = defaultLoadingComponent,\n ErrorComponent = defaultErrorComponent,\n}: {\n LoadingComponent?: typeof defaultLoadingComponent;\n ErrorComponent?: typeof defaultErrorComponent;\n} = {}) => {\n // TODO: when to invalidate?\n const candidatesExistPromise = useMemo(() => Promise.all(candidates.map(fileExists)), []);\n return (\n <ErrorBoundary fallbackRender={ErrorComponent}>\n <Suspense fallback={<LoadingComponent />}>\n <MainContentInner candidatesExistPromise={candidatesExistPromise} />\n </Suspense>\n </ErrorBoundary>\n );\n};\n"],"mappings":"AAwBS,mBAcA,KAdA;AAxBT,SAAS,UAAU,KAAK,eAAe;AACvC,SAAS,qBAAqB;AAC9B,SAAS,UAAU,yBAAyB;AAC5C,SAAS,oBAAoB;AAE7B,SAAS,uBAAuB,+BAA+B;AAE/D,MAAM,cAAc,CAAC,KAAK,OAAO;AACjC,MAAM,YAAY,CAAC,OAAO,WAAW,QAAQ,QAAQ;AACrD,MAAM,aAAa,CAAC,OAAO,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,QAAQ,KAAK;AAC/E,MAAM,aAAa,YAAY;AAAA,EAAQ,CAAC,QACtC,UAAU,QAAQ,CAAC,aAAa,WAAW,IAAI,CAAC,QAAQ,GAAG,GAAG,GAAG,QAAQ,GAAG,GAAG,EAAE,CAAC;AACpF;AAEA,MAAM,aAAa,OAAO,SAA6C;AAErE,QAAM,UAAU,OAAO,WAAW,OAAO;AACzC,QAAM,SAAS,MAAM,QAAQ,GAAG,OAAO,MAAM,IAAI;AACjD,SAAO,CAAC,MAAM,MAAM;AACtB;AAEO,MAAM,sBAAsB,CAAC,EAAC,SAAQ,MAAwB;AACnE,QAAM,MAAM,kBAAkB,QAAQ;AACtC,WAAS,GAAG;AACZ,SAAO,iCAAE;AAAA;AAAA,IAAgB;AAAA,KAAS;AACpC;AAEO,MAAM,mBAAmB,CAAC;AAAA,EAC/B;AACF,MAEM;AACJ,QAAM,kBAAkB,IAAI,sBAAsB;AAClD,QAAM,WAAW,gBAAgB,KAAK,CAAC,CAAC,GAAG,MAAM,MAAM,MAAM,IAAI,CAAC;AAClE,MAAI,CAAC,UAAU;AAEb,UAAM,IAAI,MAAM,8BAA8B;AAAA,EAChD;AACA,SAAO,oBAAC,uBAAoB,UAAU,eAAe,UAAS;AAChE;AAEO,MAAM,cAAc,CAAC;AAAA,EAC1B,mBAAmB;AAAA,EACnB,iBAAiB;AACnB,IAGI,CAAC,MAAM;AAET,QAAM,yBAAyB,QAAQ,MAAM,QAAQ,IAAI,WAAW,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC;AACxF,SACE,oBAAC,iBAAc,gBAAgB,gBAC7B,8BAAC,YAAS,UAAU,oBAAC,oBAAiB,GACpC,8BAAC,oBAAiB,wBAAgD,GACpE,GACF;AAEJ;","names":[]}
|