@mdsnai/sdk 0.2.2 → 0.3.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/README.md +39 -75
- package/dist/core/errors.d.ts +14 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +13 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/index.d.ts +16 -4
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +69 -13
- package/dist/core/index.js.map +1 -0
- package/dist/core/markdown-body.d.ts +3 -0
- package/dist/core/markdown-body.d.ts.map +1 -0
- package/dist/core/markdown-body.js +65 -0
- package/dist/core/markdown-body.js.map +1 -0
- package/dist/core/markdown-renderer.d.ts +5 -0
- package/dist/core/markdown-renderer.d.ts.map +1 -0
- package/dist/core/markdown-renderer.js +75 -0
- package/dist/core/markdown-renderer.js.map +1 -0
- package/dist/core/negotiate.d.ts +3 -0
- package/dist/core/negotiate.d.ts.map +1 -0
- package/dist/core/negotiate.js +63 -0
- package/dist/core/negotiate.js.map +1 -0
- package/dist/core/parse/anchors.d.ts +2 -0
- package/dist/core/parse/anchors.d.ts.map +1 -0
- package/dist/core/parse/anchors.js +26 -0
- package/dist/core/parse/anchors.js.map +1 -0
- package/dist/core/parse/block-parser.d.ts +3 -0
- package/dist/core/parse/block-parser.d.ts.map +1 -0
- package/dist/core/parse/block-parser.js +116 -0
- package/dist/core/parse/block-parser.js.map +1 -0
- package/dist/core/parse/executable-block.d.ts +6 -0
- package/dist/core/parse/executable-block.d.ts.map +1 -0
- package/dist/core/parse/executable-block.js +48 -0
- package/dist/core/parse/executable-block.js.map +1 -0
- package/dist/core/parse/frontmatter.d.ts +7 -0
- package/dist/core/parse/frontmatter.d.ts.map +1 -0
- package/dist/core/parse/frontmatter.js +45 -0
- package/dist/core/parse/frontmatter.js.map +1 -0
- package/dist/core/serialize.d.ts +4 -0
- package/dist/core/serialize.d.ts.map +1 -0
- package/dist/core/serialize.js +123 -0
- package/dist/core/serialize.js.map +1 -0
- package/dist/core/types.d.ts +66 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +2 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/validate.d.ts +3 -0
- package/dist/core/validate.d.ts.map +1 -0
- package/dist/core/validate.js +91 -0
- package/dist/core/validate.js.map +1 -0
- package/dist/elements/components/mdsn-action.d.ts +6 -0
- package/dist/elements/components/mdsn-action.d.ts.map +1 -0
- package/dist/elements/components/mdsn-action.js +34 -0
- package/dist/elements/components/mdsn-action.js.map +1 -0
- package/dist/elements/components/mdsn-block.d.ts +9 -0
- package/dist/elements/components/mdsn-block.d.ts.map +1 -0
- package/dist/elements/components/mdsn-block.js +36 -0
- package/dist/elements/components/mdsn-block.js.map +1 -0
- package/dist/elements/components/mdsn-error.d.ts +9 -0
- package/dist/elements/components/mdsn-error.d.ts.map +1 -0
- package/dist/elements/components/mdsn-error.js +36 -0
- package/dist/elements/components/mdsn-error.js.map +1 -0
- package/dist/elements/components/mdsn-field.d.ts +6 -0
- package/dist/elements/components/mdsn-field.d.ts.map +1 -0
- package/dist/elements/components/mdsn-field.js +35 -0
- package/dist/elements/components/mdsn-field.js.map +1 -0
- package/dist/elements/components/mdsn-form.d.ts +6 -0
- package/dist/elements/components/mdsn-form.d.ts.map +1 -0
- package/dist/elements/components/mdsn-form.js +22 -0
- package/dist/elements/components/mdsn-form.js.map +1 -0
- package/dist/elements/components/mdsn-page.d.ts +9 -0
- package/dist/elements/components/mdsn-page.d.ts.map +1 -0
- package/dist/elements/components/mdsn-page.js +46 -0
- package/dist/elements/components/mdsn-page.js.map +1 -0
- package/dist/elements/index.d.ts +3 -0
- package/dist/elements/index.d.ts.map +1 -0
- package/dist/elements/index.js +3 -0
- package/dist/elements/index.js.map +1 -0
- package/dist/elements/mount.d.ts +11 -0
- package/dist/elements/mount.d.ts.map +1 -0
- package/dist/elements/mount.js +245 -0
- package/dist/elements/mount.js.map +1 -0
- package/dist/elements/register.d.ts +2 -0
- package/dist/elements/register.d.ts.map +1 -0
- package/dist/elements/register.js +27 -0
- package/dist/elements/register.js.map +1 -0
- package/dist/elements/theme.d.ts +2 -0
- package/dist/elements/theme.d.ts.map +1 -0
- package/dist/elements/theme.js +13 -0
- package/dist/elements/theme.js.map +1 -0
- package/dist/index.d.ts +4 -8
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -35
- package/dist/index.js.map +1 -0
- package/dist/server/hosted-app.d.ts +35 -0
- package/dist/server/hosted-app.d.ts.map +1 -0
- package/dist/server/hosted-app.js +105 -0
- package/dist/server/hosted-app.js.map +1 -0
- package/dist/server/html-render.d.ts +13 -0
- package/dist/server/html-render.d.ts.map +1 -0
- package/dist/server/html-render.js +316 -0
- package/dist/server/html-render.js.map +1 -0
- package/dist/server/index.d.ts +8 -15
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +6 -32
- package/dist/server/index.js.map +1 -0
- package/dist/server/node.d.ts +23 -0
- package/dist/server/node.d.ts.map +1 -0
- package/dist/server/node.js +200 -0
- package/dist/server/node.js.map +1 -0
- package/dist/server/result.d.ts +15 -0
- package/dist/server/result.d.ts.map +1 -0
- package/dist/server/result.js +64 -0
- package/dist/server/result.js.map +1 -0
- package/dist/server/router.d.ts +12 -0
- package/dist/server/router.d.ts.map +1 -0
- package/dist/server/router.js +24 -0
- package/dist/server/router.js.map +1 -0
- package/dist/server/runtime.d.ts +15 -0
- package/dist/server/runtime.d.ts.map +1 -0
- package/dist/server/runtime.js +245 -0
- package/dist/server/runtime.js.map +1 -0
- package/dist/server/session.d.ts +5 -40
- package/dist/server/session.d.ts.map +1 -0
- package/dist/server/session.js +11 -213
- package/dist/server/session.js.map +1 -0
- package/dist/server/types.d.ts +62 -0
- package/dist/server/types.d.ts.map +1 -0
- package/dist/server/types.js +2 -0
- package/dist/server/types.js.map +1 -0
- package/dist/web/headless.d.ts +22 -92
- package/dist/web/headless.d.ts.map +1 -0
- package/dist/web/headless.js +311 -337
- package/dist/web/headless.js.map +1 -0
- package/dist/web/index.d.ts +2 -11
- package/dist/web/index.d.ts.map +1 -0
- package/dist/web/index.js +2 -23
- package/dist/web/index.js.map +1 -0
- package/package.json +19 -43
- package/LICENSE +0 -21
- package/dist/cli/args.d.ts +0 -8
- package/dist/cli/args.js +0 -63
- package/dist/cli/commands/build.d.ts +0 -5
- package/dist/cli/commands/build.js +0 -19
- package/dist/cli/commands/create.d.ts +0 -2
- package/dist/cli/commands/create.js +0 -39
- package/dist/cli/commands/dev.d.ts +0 -10
- package/dist/cli/commands/dev.js +0 -13
- package/dist/cli/commands/start.d.ts +0 -9
- package/dist/cli/commands/start.js +0 -13
- package/dist/cli/entry.d.ts +0 -2
- package/dist/cli/entry.js +0 -8
- package/dist/cli/index.d.ts +0 -9
- package/dist/cli/index.js +0 -58
- package/dist/core/document/frontmatter.d.ts +0 -5
- package/dist/core/document/frontmatter.js +0 -41
- package/dist/core/document/markdown.d.ts +0 -5
- package/dist/core/document/markdown.js +0 -81
- package/dist/core/document/page-definition.d.ts +0 -2
- package/dist/core/document/page-definition.js +0 -23
- package/dist/core/model/block.d.ts +0 -26
- package/dist/core/model/block.js +0 -8
- package/dist/core/model/document.d.ts +0 -11
- package/dist/core/model/document.js +0 -2
- package/dist/core/model/fragment.d.ts +0 -4
- package/dist/core/model/fragment.js +0 -2
- package/dist/core/model/index.d.ts +0 -4
- package/dist/core/model/index.js +0 -2
- package/dist/core/model/input.d.ts +0 -10
- package/dist/core/model/input.js +0 -2
- package/dist/core/protocol/mdsn.d.ts +0 -4
- package/dist/core/protocol/mdsn.js +0 -66
- package/dist/core/protocol/statements.d.ts +0 -7
- package/dist/core/protocol/statements.js +0 -115
- package/dist/core/protocol/validation.d.ts +0 -3
- package/dist/core/protocol/validation.js +0 -70
- package/dist/core/utils/html.d.ts +0 -6
- package/dist/core/utils/html.js +0 -28
- package/dist/core/utils/index.d.ts +0 -2
- package/dist/core/utils/index.js +0 -12
- package/dist/core/utils/logger.d.ts +0 -12
- package/dist/core/utils/logger.js +0 -45
- package/dist/framework/create-framework-app.d.ts +0 -13
- package/dist/framework/create-framework-app.js +0 -12
- package/dist/framework/hosted-app.d.ts +0 -34
- package/dist/framework/hosted-app.js +0 -223
- package/dist/framework/index.d.ts +0 -6
- package/dist/framework/index.js +0 -9
- package/dist/framework/site-app.d.ts +0 -13
- package/dist/framework/site-app.js +0 -147
- package/dist/server/action-context.d.ts +0 -11
- package/dist/server/action-context.js +0 -26
- package/dist/server/action-host.d.ts +0 -2
- package/dist/server/action-host.js +0 -10
- package/dist/server/action-inputs.d.ts +0 -3
- package/dist/server/action-inputs.js +0 -178
- package/dist/server/action-runtime.d.ts +0 -8
- package/dist/server/action-runtime.js +0 -62
- package/dist/server/action.d.ts +0 -33
- package/dist/server/action.js +0 -101
- package/dist/server/build.d.ts +0 -10
- package/dist/server/build.js +0 -170
- package/dist/server/config.d.ts +0 -56
- package/dist/server/config.js +0 -42
- package/dist/server/dev.d.ts +0 -48
- package/dist/server/dev.js +0 -90
- package/dist/server/error-fragments.d.ts +0 -46
- package/dist/server/error-fragments.js +0 -77
- package/dist/server/init.d.ts +0 -1
- package/dist/server/init.js +0 -176
- package/dist/server/layout.d.ts +0 -17
- package/dist/server/layout.js +0 -40
- package/dist/server/markdown.d.ts +0 -49
- package/dist/server/markdown.js +0 -77
- package/dist/server/module-loader.d.ts +0 -4
- package/dist/server/module-loader.js +0 -71
- package/dist/server/negotiate.d.ts +0 -3
- package/dist/server/negotiate.js +0 -61
- package/dist/server/page-host.d.ts +0 -21
- package/dist/server/page-host.js +0 -66
- package/dist/server/page-links.d.ts +0 -10
- package/dist/server/page-links.js +0 -80
- package/dist/server/route-matcher.d.ts +0 -6
- package/dist/server/route-matcher.js +0 -73
- package/dist/server/routes.d.ts +0 -6
- package/dist/server/routes.js +0 -73
- package/dist/server/server.d.ts +0 -28
- package/dist/server/server.js +0 -161
- package/dist/server/site.d.ts +0 -11
- package/dist/server/site.js +0 -59
- package/dist/server/targets.d.ts +0 -7
- package/dist/server/targets.js +0 -21
- package/dist/web/block-runtime.d.ts +0 -2
- package/dist/web/block-runtime.js +0 -25
- package/dist/web/fragment-render.d.ts +0 -8
- package/dist/web/fragment-render.js +0 -58
- package/dist/web/i18n.d.ts +0 -29
- package/dist/web/i18n.js +0 -65
- package/dist/web/navigation.d.ts +0 -3
- package/dist/web/navigation.js +0 -32
- package/dist/web/page-bootstrap.d.ts +0 -6
- package/dist/web/page-bootstrap.js +0 -28
- package/dist/web/page-client-runtime.d.ts +0 -4
- package/dist/web/page-client-runtime.js +0 -7
- package/dist/web/page-client-script.d.ts +0 -1
- package/dist/web/page-client-script.js +0 -579
- package/dist/web/page-html.d.ts +0 -8
- package/dist/web/page-html.js +0 -42
- package/dist/web/page-render.d.ts +0 -20
- package/dist/web/page-render.js +0 -84
- package/dist/web/public-client-runtime.d.ts +0 -1
- package/dist/web/public-client-runtime.js +0 -5
- package/dist/web/public-render.d.ts +0 -12
- package/dist/web/public-render.js +0 -18
- package/dist/web/target-path.d.ts +0 -1
- package/dist/web/target-path.js +0 -35
package/dist/index.js
CHANGED
|
@@ -1,35 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var web_1 = require("./web");
|
|
7
|
-
Object.defineProperty(exports, "createRenderModel", { enumerable: true, get: function () { return web_1.createRenderModel; } });
|
|
8
|
-
Object.defineProperty(exports, "getClientRuntimeScript", { enumerable: true, get: function () { return web_1.getClientRuntimeScript; } });
|
|
9
|
-
Object.defineProperty(exports, "parseFragment", { enumerable: true, get: function () { return web_1.parseFragment; } });
|
|
10
|
-
Object.defineProperty(exports, "parseMarkdown", { enumerable: true, get: function () { return web_1.parseMarkdown; } });
|
|
11
|
-
Object.defineProperty(exports, "parsePage", { enumerable: true, get: function () { return web_1.parsePage; } });
|
|
12
|
-
Object.defineProperty(exports, "renderDefaultHtmlDocument", { enumerable: true, get: function () { return web_1.renderDefaultHtmlDocument; } });
|
|
13
|
-
Object.defineProperty(exports, "renderPageHtml", { enumerable: true, get: function () { return web_1.renderPageHtml; } });
|
|
14
|
-
var framework_1 = require("./framework");
|
|
15
|
-
Object.defineProperty(exports, "createHostedApp", { enumerable: true, get: function () { return framework_1.createHostedApp; } });
|
|
16
|
-
Object.defineProperty(exports, "createFrameworkApp", { enumerable: true, get: function () { return framework_1.createFrameworkApp; } });
|
|
17
|
-
Object.defineProperty(exports, "defineConfig", { enumerable: true, get: function () { return framework_1.defineConfig; } });
|
|
18
|
-
var server_1 = require("./server");
|
|
19
|
-
Object.defineProperty(exports, "HttpCookieJar", { enumerable: true, get: function () { return server_1.HttpCookieJar; } });
|
|
20
|
-
Object.defineProperty(exports, "createActionContextFromRequest", { enumerable: true, get: function () { return server_1.createActionContextFromRequest; } });
|
|
21
|
-
Object.defineProperty(exports, "defineAction", { enumerable: true, get: function () { return server_1.defineAction; } });
|
|
22
|
-
Object.defineProperty(exports, "defineActions", { enumerable: true, get: function () { return server_1.defineActions; } });
|
|
23
|
-
Object.defineProperty(exports, "parseActionInputs", { enumerable: true, get: function () { return server_1.parseActionInputs; } });
|
|
24
|
-
Object.defineProperty(exports, "parseCookieHeader", { enumerable: true, get: function () { return server_1.parseCookieHeader; } });
|
|
25
|
-
Object.defineProperty(exports, "renderActionNotAvailableFragment", { enumerable: true, get: function () { return server_1.renderActionNotAvailableFragment; } });
|
|
26
|
-
Object.defineProperty(exports, "renderAuthRequiredFragment", { enumerable: true, get: function () { return server_1.renderAuthRequiredFragment; } });
|
|
27
|
-
Object.defineProperty(exports, "renderErrorFragment", { enumerable: true, get: function () { return server_1.renderErrorFragment; } });
|
|
28
|
-
Object.defineProperty(exports, "renderHostedPage", { enumerable: true, get: function () { return server_1.renderHostedPage; } });
|
|
29
|
-
Object.defineProperty(exports, "renderInternalErrorFragment", { enumerable: true, get: function () { return server_1.renderInternalErrorFragment; } });
|
|
30
|
-
Object.defineProperty(exports, "renderMarkdownFragment", { enumerable: true, get: function () { return server_1.renderMarkdownFragment; } });
|
|
31
|
-
Object.defineProperty(exports, "renderMarkdownValue", { enumerable: true, get: function () { return server_1.renderMarkdownValue; } });
|
|
32
|
-
Object.defineProperty(exports, "renderUnsupportedContentTypeFragment", { enumerable: true, get: function () { return server_1.renderUnsupportedContentTypeFragment; } });
|
|
33
|
-
Object.defineProperty(exports, "requireSessionFromCookie", { enumerable: true, get: function () { return server_1.requireSessionFromCookie; } });
|
|
34
|
-
Object.defineProperty(exports, "serializeActionInputsAsMarkdown", { enumerable: true, get: function () { return server_1.serializeActionInputsAsMarkdown; } });
|
|
35
|
-
Object.defineProperty(exports, "serializeBlock", { enumerable: true, get: function () { return server_1.serializeBlock; } });
|
|
1
|
+
export * from "./core/index.js";
|
|
2
|
+
export * from "./server/index.js";
|
|
3
|
+
export * from "./web/index.js";
|
|
4
|
+
export * from "./elements/index.js";
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { MdsnComposedPage } from "../core/index.js";
|
|
2
|
+
import { type CreateMdsnServerOptions } from "./runtime.js";
|
|
3
|
+
import type { MdsnActionResult, MdsnHandlerContext, MdsnHandlerResult, MdsnPageHandlerContext } from "./types.js";
|
|
4
|
+
export interface HostedPageContext extends MdsnPageHandlerContext {
|
|
5
|
+
routePath: string;
|
|
6
|
+
}
|
|
7
|
+
export interface HostedPageFactory {
|
|
8
|
+
(context: HostedPageContext): MdsnComposedPage;
|
|
9
|
+
}
|
|
10
|
+
export interface HostedActionContext extends MdsnHandlerContext, HostedPageContext {
|
|
11
|
+
routePath: string;
|
|
12
|
+
blockName: string;
|
|
13
|
+
page(routePath?: string): MdsnComposedPage;
|
|
14
|
+
pageResult(pageOrRoute?: string | MdsnComposedPage, result?: Omit<MdsnActionResult, "page" | "fragment">): MdsnActionResult;
|
|
15
|
+
block(result?: Omit<MdsnActionResult, "fragment">): MdsnActionResult;
|
|
16
|
+
}
|
|
17
|
+
export type HostedAction = (context: HostedActionContext) => Promise<MdsnHandlerResult> | MdsnHandlerResult;
|
|
18
|
+
export interface HostedActionDefinition {
|
|
19
|
+
target: string;
|
|
20
|
+
routePath: string;
|
|
21
|
+
blockName: string;
|
|
22
|
+
methods: Array<"GET" | "POST">;
|
|
23
|
+
handler: HostedAction;
|
|
24
|
+
}
|
|
25
|
+
export interface CreateHostedAppOptions extends CreateMdsnServerOptions {
|
|
26
|
+
pages: Record<string, HostedPageFactory>;
|
|
27
|
+
actions?: HostedActionDefinition[];
|
|
28
|
+
}
|
|
29
|
+
export declare function createHostedApp(options: CreateHostedAppOptions): {
|
|
30
|
+
get(path: string, handler: import("./types.js").MdsnHandler): void;
|
|
31
|
+
page(path: string, handler: import("./types.js").MdsnPageHandler): void;
|
|
32
|
+
post(path: string, handler: import("./types.js").MdsnHandler): void;
|
|
33
|
+
handle(request: import("./types.js").MdsnRequest): Promise<import("./types.js").MdsnResponse>;
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=hosted-app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-app.d.ts","sourceRoot":"","sources":["../../src/server/hosted-app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGzD,OAAO,EAAoB,KAAK,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAElH,MAAM,WAAW,iBAAkB,SAAQ,sBAAsB;IAC/D,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CAAC;CAChD;AAED,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB,EAAE,iBAAiB;IAChF,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAAC;IAC3C,UAAU,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,gBAAgB,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,UAAU,CAAC,GAAG,gBAAgB,CAAC;IAC5H,KAAK,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,GAAG,gBAAgB,CAAC;CACtE;AAED,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,mBAAmB,KAAK,OAAO,CAAC,iBAAiB,CAAC,GAAG,iBAAiB,CAAC;AAE5G,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC;IAC/B,OAAO,EAAE,YAAY,CAAC;CACvB;AAED,MAAM,WAAW,sBAAuB,SAAQ,uBAAuB;IACrE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACzC,OAAO,CAAC,EAAE,sBAAsB,EAAE,CAAC;CACpC;AA+DD,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB;;;;;EAoE9D"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { block as createBlockResult } from "./result.js";
|
|
2
|
+
import { createMdsnServer } from "./runtime.js";
|
|
3
|
+
function createBindingKey(method, target) {
|
|
4
|
+
return `${method}:${target}`;
|
|
5
|
+
}
|
|
6
|
+
function renderPage(factory, context) {
|
|
7
|
+
const page = factory(context);
|
|
8
|
+
if (typeof page.fragment !== "function") {
|
|
9
|
+
throw new Error(`Hosted page "${context.routePath}" must return a composed page created by composePage().`);
|
|
10
|
+
}
|
|
11
|
+
return page;
|
|
12
|
+
}
|
|
13
|
+
function buildBindings(pages, actions) {
|
|
14
|
+
const bindings = new Map();
|
|
15
|
+
for (const action of actions ?? []) {
|
|
16
|
+
if (!pages[action.routePath]) {
|
|
17
|
+
throw new Error(`Unknown hosted page route "${action.routePath}" for action "${action.target}".`);
|
|
18
|
+
}
|
|
19
|
+
if (action.methods.length === 0) {
|
|
20
|
+
throw new Error(`Hosted action "${action.target}" must declare at least one method.`);
|
|
21
|
+
}
|
|
22
|
+
if (!action.blockName.trim()) {
|
|
23
|
+
throw new Error(`Hosted action "${action.target}" must declare a non-empty blockName.`);
|
|
24
|
+
}
|
|
25
|
+
const uniqueMethods = new Set(action.methods);
|
|
26
|
+
if (uniqueMethods.size !== action.methods.length) {
|
|
27
|
+
throw new Error(`Hosted action "${action.target}" cannot declare duplicate methods.`);
|
|
28
|
+
}
|
|
29
|
+
for (const method of uniqueMethods) {
|
|
30
|
+
const key = createBindingKey(method, action.target);
|
|
31
|
+
if (bindings.has(key)) {
|
|
32
|
+
throw new Error(`${method} ${action.target} must bind to one stable block context.`);
|
|
33
|
+
}
|
|
34
|
+
bindings.set(key, {
|
|
35
|
+
routePath: action.routePath,
|
|
36
|
+
blockName: action.blockName,
|
|
37
|
+
method,
|
|
38
|
+
target: action.target,
|
|
39
|
+
handler: action.handler
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return bindings;
|
|
44
|
+
}
|
|
45
|
+
export function createHostedApp(options) {
|
|
46
|
+
const server = createMdsnServer(options);
|
|
47
|
+
const bindings = buildBindings(options.pages, options.actions);
|
|
48
|
+
for (const [routePath, factory] of Object.entries(options.pages)) {
|
|
49
|
+
server.page(routePath, async (context) => renderPage(factory, { ...context, routePath }));
|
|
50
|
+
}
|
|
51
|
+
for (const binding of bindings.values()) {
|
|
52
|
+
const register = binding.method === "GET" ? server.get.bind(server) : server.post.bind(server);
|
|
53
|
+
register(binding.target, async (context) => {
|
|
54
|
+
const routeFactory = options.pages[binding.routePath];
|
|
55
|
+
if (!routeFactory) {
|
|
56
|
+
throw new Error(`Missing hosted page renderer for "${binding.routePath}".`);
|
|
57
|
+
}
|
|
58
|
+
return binding.handler({
|
|
59
|
+
...context,
|
|
60
|
+
routePath: binding.routePath,
|
|
61
|
+
blockName: binding.blockName,
|
|
62
|
+
page(routePath = binding.routePath) {
|
|
63
|
+
const pageFactory = options.pages[routePath];
|
|
64
|
+
if (!pageFactory) {
|
|
65
|
+
throw new Error(`Unknown hosted page route "${routePath}".`);
|
|
66
|
+
}
|
|
67
|
+
return renderPage(pageFactory, {
|
|
68
|
+
request: context.request,
|
|
69
|
+
session: context.session,
|
|
70
|
+
routePath
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
pageResult(pageOrRoute = binding.routePath, result = {}) {
|
|
74
|
+
const page = typeof pageOrRoute === "string"
|
|
75
|
+
? (() => {
|
|
76
|
+
const pageFactory = options.pages[pageOrRoute];
|
|
77
|
+
if (!pageFactory) {
|
|
78
|
+
throw new Error(`Unknown hosted page route "${pageOrRoute}".`);
|
|
79
|
+
}
|
|
80
|
+
return renderPage(pageFactory, {
|
|
81
|
+
request: context.request,
|
|
82
|
+
session: context.session,
|
|
83
|
+
routePath: pageOrRoute
|
|
84
|
+
});
|
|
85
|
+
})()
|
|
86
|
+
: pageOrRoute;
|
|
87
|
+
return {
|
|
88
|
+
status: 200,
|
|
89
|
+
...result,
|
|
90
|
+
page
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
block(result = {}) {
|
|
94
|
+
return createBlockResult(renderPage(routeFactory, {
|
|
95
|
+
request: context.request,
|
|
96
|
+
session: context.session,
|
|
97
|
+
routePath: binding.routePath
|
|
98
|
+
}), binding.blockName, result);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return server;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=hosted-app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-app.js","sourceRoot":"","sources":["../../src/server/hosted-app.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,IAAI,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAgC,MAAM,cAAc,CAAC;AA0C9E,SAAS,gBAAgB,CAAC,MAAsB,EAAE,MAAc;IAC9D,OAAO,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC;AAC/B,CAAC;AAED,SAAS,UAAU,CAAC,OAA0B,EAAE,OAA0B;IACxE,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,UAAU,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,gBAAgB,OAAO,CAAC,SAAS,yDAAyD,CAAC,CAAC;IAC9G,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,aAAa,CACpB,KAAwC,EACxC,OAA6C;IAE7C,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAyB,CAAC;IAElD,KAAK,MAAM,MAAM,IAAI,OAAO,IAAI,EAAE,EAAE,CAAC;QACnC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,8BAA8B,MAAM,CAAC,SAAS,iBAAiB,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC;QACpG,CAAC;QACD,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,kBAAkB,MAAM,CAAC,MAAM,qCAAqC,CAAC,CAAC;QACxF,CA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S;qBACV,CAAC,CAAC;gBACL,CAAC;gBACD,UAAU,CAAC,WAAW,GAAG,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,EAAE;oBACrD,MAAM,IAAI,GACR,OAAO,WAAW,KAAK,QAAQ;wBAC7B,CAAC,CAAC,CAAC,GAAG,EAAE;4BACJ,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;4BAC/C,IAAI,CAAC,WAAW,EAAE,CAAC;gCACjB,MAAM,IAAI,KAAK,CAAC,8BAA8B,WAAW,IAAI,CAAC,CAAC;4BACjE,CAAC;4BACD,OAAO,UAAU,CAAC,WAAW,EAAE;gCAC7B,OAAO,EAAE,OAAO,CAAC,OAAO;gCACxB,OAAO,EAAE,OAAO,CAAC,OAAO;gCACxB,SAAS,EAAE,WAAW;6BACvB,CAAC,CAAC;wBACL,CAAC,CAAC,EAAE;wBACN,CAAC,CAAC,WAAW,CAAC;oBAClB,OAAO;wBACL,MAAM,EAAE,GAAG;wBACX,GAAG,MAAM;wBACT,IAAI;qBACL,CAAC;gBACJ,CAAC;gBACD,KAAK,CAAC,MAAM,GAAG,EAAE;oBACf,OAAO,iBAAiB,CACtB,UAAU,CAAC,YAAY,EAAE;wBACvB,OAAO,EAAE,OAAO,CAAC,OAAO;wBACxB,OAAO,EAAE,OAAO,CAAC,OAAO;wBACxB,SAAS,EAAE,OAAO,CAAC,SAAS;qBAC7B,CAAC,EACF,OAAO,CAAC,SAAS,EACjB,MAAM,CACP,CAAC;gBACJ,CAAC;aACF,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { MdsnMarkdownRenderer, MdsnFragment } from "../core/index.js";
|
|
2
|
+
interface MdsnRenderableDocument extends MdsnFragment {
|
|
3
|
+
blockContent?: Record<string, string>;
|
|
4
|
+
}
|
|
5
|
+
interface RenderHtmlDocumentOptions {
|
|
6
|
+
continueTarget?: string;
|
|
7
|
+
kind?: "page" | "fragment";
|
|
8
|
+
route?: string;
|
|
9
|
+
markdownRenderer?: MdsnMarkdownRenderer;
|
|
10
|
+
}
|
|
11
|
+
export declare function renderHtmlDocument(fragment: MdsnRenderableDocument, options?: RenderHtmlDocumentOptions): string;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=html-render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-render.d.ts","sourceRoot":"","sources":["../../src/server/html-render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAEpB,YAAY,EAKb,MAAM,kBAAkB,CAAC;AAG1B,UAAU,sBAAuB,SAAQ,YAAY;IACnD,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;AAID,UAAU,yBAAyB;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,oBAAoB,CAAC;CACzC;AAyLD,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,sBAAsB,EAAE,OAAO,GAAE,yBAA8B,GAAG,MAAM,CA8KpH"}
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { basicMarkdownRenderer } from "../core/index.js";
|
|
2
|
+
const blockAnchorPattern = /^<!--\s*mdsn:block\s+([a-zA-Z_][\w-]*)\s*-->$/;
|
|
3
|
+
function escapeHtml(value) {
|
|
4
|
+
return value
|
|
5
|
+
.replaceAll("&", "&")
|
|
6
|
+
.replaceAll("<", "<")
|
|
7
|
+
.replaceAll(">", ">")
|
|
8
|
+
.replaceAll('"', """);
|
|
9
|
+
}
|
|
10
|
+
function humanizeLabel(value) {
|
|
11
|
+
return value
|
|
12
|
+
.replace(/[_-]+/g, " ")
|
|
13
|
+
.replace(/\s+/g, " ")
|
|
14
|
+
.trim();
|
|
15
|
+
}
|
|
16
|
+
function resolveActionVariant(operation) {
|
|
17
|
+
const signature = `${operation.name ?? ""} ${operation.label ?? ""} ${operation.target}`.toLowerCase();
|
|
18
|
+
if (signature.includes("logout") || signature.includes("log out")) {
|
|
19
|
+
return "quiet";
|
|
20
|
+
}
|
|
21
|
+
if (operation.method === "GET") {
|
|
22
|
+
return "secondary";
|
|
23
|
+
}
|
|
24
|
+
return "primary";
|
|
25
|
+
}
|
|
26
|
+
function renderInput(input) {
|
|
27
|
+
const required = input.required ? ' required aria-required="true" data-required="true"' : "";
|
|
28
|
+
const placeholder = input.name === "message" ? ` placeholder="Write something worth keeping"` : "";
|
|
29
|
+
const name = escapeHtml(input.name);
|
|
30
|
+
const labelText = humanizeLabel(name);
|
|
31
|
+
const label = input.required
|
|
32
|
+
? `<span class="mdsn-label-text">${escapeHtml(labelText)} <span class="mdsn-required" aria-hidden="true">*</span></span>`
|
|
33
|
+
: `<span class="mdsn-label-text">${escapeHtml(labelText)}</span>`;
|
|
34
|
+
if (input.type === "choice") {
|
|
35
|
+
const options = (input.options ?? [])
|
|
36
|
+
.map((option) => `<option value="${escapeHtml(option)}">${escapeHtml(option)}</option>`)
|
|
37
|
+
.join("");
|
|
38
|
+
return `<mdsn-field><label>${label}<select name="${name}"${required}>${options}</select></label></mdsn-field>`;
|
|
39
|
+
}
|
|
40
|
+
if (input.type === "boolean") {
|
|
41
|
+
return `<mdsn-field><label>${label}<input name="${name}" type="checkbox"${required}></label></mdsn-field>`;
|
|
42
|
+
}
|
|
43
|
+
if (input.type === "asset") {
|
|
44
|
+
return `<mdsn-field><label>${label}<input name="${name}" type="file"${required}></label></mdsn-field>`;
|
|
45
|
+
}
|
|
46
|
+
const type = input.secret ? "password" : input.type === "number" ? "number" : "text";
|
|
47
|
+
return `<mdsn-field><label>${label}<input name="${name}" type="${type}"${required}${placeholder}></label></mdsn-field>`;
|
|
48
|
+
}
|
|
49
|
+
function renderOperation(operation, inputs) {
|
|
50
|
+
const variant = resolveActionVariant(operation);
|
|
51
|
+
const actionAttrs = `data-mdsn-action-variant="${variant}"`;
|
|
52
|
+
if (operation.method === "GET") {
|
|
53
|
+
if (operation.accept === "text/event-stream") {
|
|
54
|
+
return `<mdsn-stream data-mdsn-stream-target="${escapeHtml(operation.target)}"></mdsn-stream>`;
|
|
55
|
+
}
|
|
56
|
+
return `<mdsn-form><form method="GET" action="${escapeHtml(operation.target)}" data-mdsn-method="GET" data-mdsn-target="${escapeHtml(operation.target)}" ${actionAttrs}><mdsn-action><button type="submit" ${actionAttrs}>${escapeHtml(operation.label ?? operation.name ?? operation.target)}</button></mdsn-action></form></mdsn-form>`;
|
|
57
|
+
}
|
|
58
|
+
const fields = inputs
|
|
59
|
+
.filter((input) => operation.inputs.includes(input.name))
|
|
60
|
+
.map(renderInput)
|
|
61
|
+
.join("");
|
|
62
|
+
return `<mdsn-form><form method="POST" action="${escapeHtml(operation.target)}" data-mdsn-method="POST" data-mdsn-target="${escapeHtml(operation.target)}" ${actionAttrs}>${fields}<mdsn-action><button type="submit" ${actionAttrs}>${escapeHtml(operation.label ?? operation.name)}</button></mdsn-action></form></mdsn-form>`;
|
|
63
|
+
}
|
|
64
|
+
function renderBlock(block, innerHtml = "") {
|
|
65
|
+
const operations = block.operations.map((operation) => renderOperation(operation, block.inputs)).join("");
|
|
66
|
+
return `<mdsn-block data-mdsn-block="${escapeHtml(block.name)}">${innerHtml}${operations}</mdsn-block>`;
|
|
67
|
+
}
|
|
68
|
+
function escapeScriptJson(value) {
|
|
69
|
+
return value.replaceAll("</script>", "<\\/script>");
|
|
70
|
+
}
|
|
71
|
+
function resolveBlockMarkdown(fragment, blockName, hasAnchors, isSingleBlockResponse) {
|
|
72
|
+
if (hasAnchors) {
|
|
73
|
+
return fragment.blockContent?.[blockName]?.trim() ?? "";
|
|
74
|
+
}
|
|
75
|
+
if (isSingleBlockResponse && fragment.blocks[0]?.name === blockName) {
|
|
76
|
+
return fragment.markdown.trim();
|
|
77
|
+
}
|
|
78
|
+
return "";
|
|
79
|
+
}
|
|
80
|
+
function createHeadlessBlockSnapshot(block, markdown) {
|
|
81
|
+
return {
|
|
82
|
+
name: block.name,
|
|
83
|
+
markdown,
|
|
84
|
+
inputs: block.inputs,
|
|
85
|
+
operations: block.operations
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function createHeadlessBootstrap(fragment, options, hasAnchors, isSingleBlockResponse) {
|
|
89
|
+
if (options.kind === "page") {
|
|
90
|
+
return {
|
|
91
|
+
kind: "page",
|
|
92
|
+
...(options.route ? { route: options.route } : {}),
|
|
93
|
+
markdown: fragment.markdown,
|
|
94
|
+
blocks: fragment.blocks.map((block) => createHeadlessBlockSnapshot(block, resolveBlockMarkdown(fragment, block.name, hasAnchors, isSingleBlockResponse)))
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
if (fragment.blocks.length !== 1) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
const block = fragment.blocks[0];
|
|
101
|
+
if (!block) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
const bootstrap = {
|
|
105
|
+
kind: "fragment",
|
|
106
|
+
block: createHeadlessBlockSnapshot(block, resolveBlockMarkdown(fragment, block.name, hasAnchors, isSingleBlockResponse))
|
|
107
|
+
};
|
|
108
|
+
if (options.continueTarget) {
|
|
109
|
+
bootstrap.continueTarget = options.continueTarget;
|
|
110
|
+
}
|
|
111
|
+
return bootstrap;
|
|
112
|
+
}
|
|
113
|
+
function renderMarkdownWithAnchors(markdown, blocks, blockContent, markdownRenderer) {
|
|
114
|
+
const rendered = [];
|
|
115
|
+
const buffer = [];
|
|
116
|
+
const blockMap = new Map(blocks.map((block) => [block.name, block]));
|
|
117
|
+
function flushBuffer() {
|
|
118
|
+
const text = buffer.join("\n").trim();
|
|
119
|
+
if (text) {
|
|
120
|
+
rendered.push(markdownRenderer.render(text));
|
|
121
|
+
}
|
|
122
|
+
buffer.length = 0;
|
|
123
|
+
}
|
|
124
|
+
for (const line of markdown.split("\n")) {
|
|
125
|
+
const trimmed = line.trim();
|
|
126
|
+
const anchorMatch = trimmed.match(blockAnchorPattern);
|
|
127
|
+
if (anchorMatch) {
|
|
128
|
+
flushBuffer();
|
|
129
|
+
const block = blockMap.get(anchorMatch[1] ?? "");
|
|
130
|
+
if (block) {
|
|
131
|
+
const innerMarkdown = blockContent?.[anchorMatch[1] ?? ""]?.trim() ?? "";
|
|
132
|
+
rendered.push(renderBlock(block, markdownRenderer.render(innerMarkdown)));
|
|
133
|
+
}
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
buffer.push(line);
|
|
137
|
+
}
|
|
138
|
+
flushBuffer();
|
|
139
|
+
return rendered.join("\n");
|
|
140
|
+
}
|
|
141
|
+
export function renderHtmlDocument(fragment, options = {}) {
|
|
142
|
+
const markdownRenderer = options.markdownRenderer ?? basicMarkdownRenderer;
|
|
143
|
+
const hasAnchors = fragment.markdown.includes("<!-- mdsn:block");
|
|
144
|
+
const isSingleBlockResponse = !hasAnchors && fragment.blocks.length === 1 && fragment.markdown.trim().length > 0;
|
|
145
|
+
const markdown = hasAnchors
|
|
146
|
+
? renderMarkdownWithAnchors(fragment.markdown, fragment.blocks, fragment.blockContent, markdownRenderer)
|
|
147
|
+
: isSingleBlockResponse
|
|
148
|
+
? ""
|
|
149
|
+
: markdownRenderer.render(fragment.markdown);
|
|
150
|
+
const blocks = hasAnchors
|
|
151
|
+
? ""
|
|
152
|
+
: isSingleBlockResponse
|
|
153
|
+
? renderBlock(fragment.blocks[0], markdownRenderer.render(fragment.markdown))
|
|
154
|
+
: fragment.blocks.map((block) => renderBlock(block)).join("\n");
|
|
155
|
+
const continueTarget = options.continueTarget ? ` data-mdsn-continue-target="${escapeHtml(options.continueTarget)}"` : "";
|
|
156
|
+
const bootstrap = createHeadlessBootstrap(fragment, options, hasAnchors, isSingleBlockResponse);
|
|
157
|
+
const bootstrapScript = bootstrap
|
|
158
|
+
? `\n <script id="mdsn-bootstrap" type="application/json">${escapeScriptJson(JSON.stringify(bootstrap))}</script>`
|
|
159
|
+
: "";
|
|
160
|
+
return `<!doctype html>
|
|
161
|
+
<html lang="en">
|
|
162
|
+
<head>
|
|
163
|
+
<meta charset="utf-8">
|
|
164
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
165
|
+
<style>
|
|
166
|
+
:root {
|
|
167
|
+
font-family: ui-sans-serif, system-ui, sans-serif;
|
|
168
|
+
color: #1f2937;
|
|
169
|
+
background: #f4f7fb;
|
|
170
|
+
}
|
|
171
|
+
body {
|
|
172
|
+
margin: 0;
|
|
173
|
+
padding: 32px 16px;
|
|
174
|
+
}
|
|
175
|
+
main[data-mdsn-root] {
|
|
176
|
+
max-width: 760px;
|
|
177
|
+
margin: 0 auto;
|
|
178
|
+
background: rgba(255, 255, 255, 0.85);
|
|
179
|
+
border: 1px solid #dbe3ef;
|
|
180
|
+
border-radius: 24px;
|
|
181
|
+
box-shadow: 0 24px 64px rgba(15, 23, 42, 0.08);
|
|
182
|
+
padding: 28px;
|
|
183
|
+
}
|
|
184
|
+
h1 {
|
|
185
|
+
margin: 0 0 8px;
|
|
186
|
+
font-size: clamp(2.4rem, 5vw, 3.8rem);
|
|
187
|
+
line-height: 0.95;
|
|
188
|
+
letter-spacing: -0.05em;
|
|
189
|
+
}
|
|
190
|
+
h2 {
|
|
191
|
+
margin: 24px 0 10px;
|
|
192
|
+
font-size: 0.95rem;
|
|
193
|
+
letter-spacing: 0.12em;
|
|
194
|
+
text-transform: uppercase;
|
|
195
|
+
color: #0f766e;
|
|
196
|
+
}
|
|
197
|
+
mdsn-block, mdsn-form, mdsn-field, mdsn-action {
|
|
198
|
+
display: block;
|
|
199
|
+
}
|
|
200
|
+
mdsn-block {
|
|
201
|
+
margin-top: 20px;
|
|
202
|
+
padding: 20px;
|
|
203
|
+
border-radius: 22px;
|
|
204
|
+
background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
|
|
205
|
+
border: 1px solid rgba(148, 163, 184, 0.22);
|
|
206
|
+
box-shadow: 0 20px 44px rgba(15, 23, 42, 0.06);
|
|
207
|
+
}
|
|
208
|
+
form {
|
|
209
|
+
display: grid;
|
|
210
|
+
gap: 14px;
|
|
211
|
+
margin: 10px 0 0;
|
|
212
|
+
}
|
|
213
|
+
label {
|
|
214
|
+
display: grid;
|
|
215
|
+
gap: 8px;
|
|
216
|
+
font-size: 0.82rem;
|
|
217
|
+
letter-spacing: 0.08em;
|
|
218
|
+
text-transform: uppercase;
|
|
219
|
+
color: #475569;
|
|
220
|
+
font-weight: 700;
|
|
221
|
+
}
|
|
222
|
+
.mdsn-label-text {
|
|
223
|
+
display: inline-flex;
|
|
224
|
+
align-items: center;
|
|
225
|
+
gap: 6px;
|
|
226
|
+
}
|
|
227
|
+
.mdsn-required {
|
|
228
|
+
color: #dc2626;
|
|
229
|
+
font-size: 1rem;
|
|
230
|
+
line-height: 1;
|
|
231
|
+
}
|
|
232
|
+
input {
|
|
233
|
+
width: 100%;
|
|
234
|
+
box-sizing: border-box;
|
|
235
|
+
border: 1px solid rgba(148, 163, 184, 0.32);
|
|
236
|
+
border-radius: 14px;
|
|
237
|
+
padding: 12px 14px;
|
|
238
|
+
font: inherit;
|
|
239
|
+
background: rgba(255, 255, 255, 0.94);
|
|
240
|
+
}
|
|
241
|
+
input:invalid, select:invalid, textarea:invalid {
|
|
242
|
+
border-color: rgba(220, 38, 38, 0.58);
|
|
243
|
+
box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.08);
|
|
244
|
+
}
|
|
245
|
+
mdsn-action {
|
|
246
|
+
display: flex;
|
|
247
|
+
align-items: center;
|
|
248
|
+
gap: 10px;
|
|
249
|
+
}
|
|
250
|
+
button {
|
|
251
|
+
border: 0;
|
|
252
|
+
border-radius: 999px;
|
|
253
|
+
padding: 11px 18px;
|
|
254
|
+
font: inherit;
|
|
255
|
+
font-weight: 700;
|
|
256
|
+
color: white;
|
|
257
|
+
background: linear-gradient(180deg, #14b8a6 0%, #0f766e 100%);
|
|
258
|
+
box-shadow: 0 12px 24px rgba(15, 118, 110, 0.22);
|
|
259
|
+
cursor: pointer;
|
|
260
|
+
}
|
|
261
|
+
button[data-mdsn-action-variant="secondary"] {
|
|
262
|
+
color: #0f766e;
|
|
263
|
+
background: rgba(240, 253, 250, 0.92);
|
|
264
|
+
border: 1px solid rgba(15, 118, 110, 0.18);
|
|
265
|
+
box-shadow: none;
|
|
266
|
+
}
|
|
267
|
+
button[data-mdsn-action-variant="quiet"] {
|
|
268
|
+
color: #334155;
|
|
269
|
+
background: rgba(241, 245, 249, 0.92);
|
|
270
|
+
border: 1px solid rgba(148, 163, 184, 0.22);
|
|
271
|
+
box-shadow: none;
|
|
272
|
+
}
|
|
273
|
+
p {
|
|
274
|
+
line-height: 1.6;
|
|
275
|
+
color: #334155;
|
|
276
|
+
}
|
|
277
|
+
ul {
|
|
278
|
+
list-style: none;
|
|
279
|
+
padding: 0;
|
|
280
|
+
margin: 20px 0;
|
|
281
|
+
display: grid;
|
|
282
|
+
gap: 12px;
|
|
283
|
+
}
|
|
284
|
+
li {
|
|
285
|
+
position: relative;
|
|
286
|
+
padding: 16px 18px 16px 48px;
|
|
287
|
+
border-radius: 18px;
|
|
288
|
+
background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
|
|
289
|
+
border: 1px solid #dbe3ef;
|
|
290
|
+
box-shadow: 0 12px 30px rgba(15, 23, 42, 0.05);
|
|
291
|
+
}
|
|
292
|
+
li::before {
|
|
293
|
+
content: "";
|
|
294
|
+
position: absolute;
|
|
295
|
+
left: 18px;
|
|
296
|
+
top: 18px;
|
|
297
|
+
width: 14px;
|
|
298
|
+
height: 14px;
|
|
299
|
+
border-radius: 999px;
|
|
300
|
+
background: linear-gradient(180deg, #14b8a6 0%, #0f766e 100%);
|
|
301
|
+
box-shadow: 0 0 0 6px rgba(20, 184, 166, 0.12);
|
|
302
|
+
}
|
|
303
|
+
</style>
|
|
304
|
+
</head>
|
|
305
|
+
<body>
|
|
306
|
+
<mdsn-page>
|
|
307
|
+
<main data-mdsn-root${continueTarget}>
|
|
308
|
+
${markdown}
|
|
309
|
+
${blocks}
|
|
310
|
+
</main>
|
|
311
|
+
</mdsn-page>
|
|
312
|
+
${bootstrapScript}
|
|
313
|
+
</body>
|
|
314
|
+
</html>`;
|
|
315
|
+
}
|
|
316
|
+
//# sourceMappingURL=html-render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-render.js","sourceRoot":"","sources":["../../src/server/html-render.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAMzD,MAAM,kBAAkB,GAAG,+CAA+C,CAAC;AAS3E,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,KAAK;SACT,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC;SACxB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;SACvB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;SACvB,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,KAAK;SACT,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;SACtB,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,IAAI,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,oBAAoB,CAAC,SAAwB;IACpD,MAAM,SAAS,GAAG,GAAG,SAAS,CAAC,IAAI,IAAI,EAAE,IAAI,SAAS,CAAC,KAAK,IAAI,EAAE,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC;IACvG,IAAI,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAClE,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,IAAI,SAAS,CAAC,MAAM,K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E,UAAU,EAAE,qBAAqB,CAAC,CAAC;IAChG,MAAM,eAAe,GAAG,SAAS;QAC/B,CAAC,CAAC,6DAA6D,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,WAAW;QACrH,CAAC,CAAC,EAAE,CAAC;IACP,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAmJmB,cAAc;UAChC,QAAQ;UACR,MAAM;;;EAGd,eAAe;;QAET,CAAC;AACT,CAAC"}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
|
|
9
|
-
export { renderHostedPage } from "./page-host";
|
|
10
|
-
export type { ActionContext, ActionDefinition, ActionDefinitionMap, } from "./action";
|
|
11
|
-
export type { CreateActionContextFromRequestOptions, } from "./action-context";
|
|
12
|
-
export type { MarkdownImageValue, MarkdownTableValue, MarkdownValueType, RenderMarkdownFragmentOptions, SerializableBlock, SerializableInput, SerializableRead, SerializableWrite, } from "./markdown";
|
|
13
|
-
export type { HeaderCarrier, RequireSessionFromCookieOptions, SessionGuardFailure, SessionGuardResult, SessionGuardSuccess, } from "./session";
|
|
14
|
-
export type { RenderActionNotAvailableFragmentOptions, RenderAuthRequiredFragmentOptions, RenderErrorFragmentOptions, RenderInternalErrorFragmentOptions, RenderUnsupportedContentTypeFragmentOptions, } from "./error-fragments";
|
|
15
|
-
export type { HostedPageResponse } from "./page-host";
|
|
1
|
+
export { createHostedApp } from "./hosted-app.js";
|
|
2
|
+
export { createNodeHost } from "./node.js";
|
|
3
|
+
export { block, fail, navigate, ok, stream } from "./result.js";
|
|
4
|
+
export { createMdsnServer, type CreateMdsnServerOptions } from "./runtime.js";
|
|
5
|
+
export { refreshSession, signIn, signOut } from "./session.js";
|
|
6
|
+
export type { CreateHostedAppOptions, HostedAction, HostedActionDefinition, HostedActionContext, HostedPageFactory } from "./hosted-app.js";
|
|
7
|
+
export type { MdsnActionResult, MdsnHandler, MdsnHandlerContext, MdsnHandlerResult, MdsnPageHandler, MdsnPageHandlerContext, MdsnRequest, MdsnResponse, MdsnSessionMutation, MdsnSessionProvider, MdsnSessionSnapshot, MdsnStreamChunk, MdsnStreamResult } from "./types.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC/D,YAAY,EACV,sBAAsB,EACtB,YAAY,EACZ,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACtB,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EACjB,MAAM,YAAY,CAAC"}
|
package/dist/server/index.js
CHANGED
|
@@ -1,32 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var action_inputs_1 = require("./action-inputs");
|
|
8
|
-
Object.defineProperty(exports, "normalizeActionInputPayloadToMarkdown", { enumerable: true, get: function () { return action_inputs_1.normalizeActionInputPayloadToMarkdown; } });
|
|
9
|
-
Object.defineProperty(exports, "parseActionInputs", { enumerable: true, get: function () { return action_inputs_1.parseActionInputs; } });
|
|
10
|
-
Object.defineProperty(exports, "serializeActionInputsAsMarkdown", { enumerable: true, get: function () { return action_inputs_1.serializeActionInputsAsMarkdown; } });
|
|
11
|
-
var action_context_1 = require("./action-context");
|
|
12
|
-
Object.defineProperty(exports, "createActionContextFromRequest", { enumerable: true, get: function () { return action_context_1.createActionContextFromRequest; } });
|
|
13
|
-
var markdown_1 = require("./markdown");
|
|
14
|
-
Object.defineProperty(exports, "renderMarkdownFragment", { enumerable: true, get: function () { return markdown_1.renderMarkdownFragment; } });
|
|
15
|
-
Object.defineProperty(exports, "renderMarkdownValue", { enumerable: true, get: function () { return markdown_1.renderMarkdownValue; } });
|
|
16
|
-
Object.defineProperty(exports, "serializeBlock", { enumerable: true, get: function () { return markdown_1.serializeBlock; } });
|
|
17
|
-
var session_1 = require("./session");
|
|
18
|
-
Object.defineProperty(exports, "HttpCookieJar", { enumerable: true, get: function () { return session_1.HttpCookieJar; } });
|
|
19
|
-
Object.defineProperty(exports, "parseCookieHeader", { enumerable: true, get: function () { return session_1.parseCookieHeader; } });
|
|
20
|
-
Object.defineProperty(exports, "requireSessionFromCookie", { enumerable: true, get: function () { return session_1.requireSessionFromCookie; } });
|
|
21
|
-
var error_fragments_1 = require("./error-fragments");
|
|
22
|
-
Object.defineProperty(exports, "renderActionNotAvailableFragment", { enumerable: true, get: function () { return error_fragments_1.renderActionNotAvailableFragment; } });
|
|
23
|
-
Object.defineProperty(exports, "renderAuthRequiredFragment", { enumerable: true, get: function () { return error_fragments_1.renderAuthRequiredFragment; } });
|
|
24
|
-
Object.defineProperty(exports, "renderErrorFragment", { enumerable: true, get: function () { return error_fragments_1.renderErrorFragment; } });
|
|
25
|
-
Object.defineProperty(exports, "renderInternalErrorFragment", { enumerable: true, get: function () { return error_fragments_1.renderInternalErrorFragment; } });
|
|
26
|
-
Object.defineProperty(exports, "renderUnsupportedContentTypeFragment", { enumerable: true, get: function () { return error_fragments_1.renderUnsupportedContentTypeFragment; } });
|
|
27
|
-
var negotiate_1 = require("./negotiate");
|
|
28
|
-
Object.defineProperty(exports, "wantsHtml", { enumerable: true, get: function () { return negotiate_1.wantsHtml; } });
|
|
29
|
-
var action_host_1 = require("./action-host");
|
|
30
|
-
Object.defineProperty(exports, "executeActionHandler", { enumerable: true, get: function () { return action_host_1.executeActionHandler; } });
|
|
31
|
-
var page_host_1 = require("./page-host");
|
|
32
|
-
Object.defineProperty(exports, "renderHostedPage", { enumerable: true, get: function () { return page_host_1.renderHostedPage; } });
|
|
1
|
+
export { createHostedApp } from "./hosted-app.js";
|
|
2
|
+
export { createNodeHost } from "./node.js";
|
|
3
|
+
export { block, fail, navigate, ok, stream } from "./result.js";
|
|
4
|
+
export { createMdsnServer } from "./runtime.js";
|
|
5
|
+
export { refreshSession, signIn, signOut } from "./session.js";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAgC,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
|