@mdsnai/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 +67 -0
- package/dist/cli/args.d.ts +8 -0
- package/dist/cli/args.js +63 -0
- package/dist/cli/commands/build.d.ts +5 -0
- package/dist/cli/commands/build.js +19 -0
- package/dist/cli/commands/create.d.ts +2 -0
- package/dist/cli/commands/create.js +39 -0
- package/dist/cli/commands/dev.d.ts +10 -0
- package/dist/cli/commands/dev.js +13 -0
- package/dist/cli/commands/start.d.ts +9 -0
- package/dist/cli/commands/start.js +13 -0
- package/dist/cli/entry.d.ts +2 -0
- package/dist/cli/entry.js +8 -0
- package/dist/cli/index.d.ts +9 -0
- package/dist/cli/index.js +58 -0
- package/dist/core/action/execution.d.ts +4 -0
- package/dist/core/action/execution.js +57 -0
- package/dist/core/action/index.d.ts +2 -0
- package/dist/core/action/index.js +7 -0
- package/dist/core/action/types.d.ts +19 -0
- package/dist/core/action/types.js +2 -0
- package/dist/core/document/frontmatter.d.ts +5 -0
- package/dist/core/document/frontmatter.js +41 -0
- package/dist/core/document/markdown.d.ts +5 -0
- package/dist/core/document/markdown.js +83 -0
- package/dist/core/document/page-definition.d.ts +2 -0
- package/dist/core/document/page-definition.js +24 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.js +5 -0
- package/dist/core/model/block.d.ts +30 -0
- package/dist/core/model/block.js +2 -0
- package/dist/core/model/document.d.ts +13 -0
- package/dist/core/model/document.js +2 -0
- package/dist/core/model/fragment.d.ts +4 -0
- package/dist/core/model/fragment.js +2 -0
- package/dist/core/model/index.d.ts +5 -0
- package/dist/core/model/index.js +2 -0
- package/dist/core/model/input.d.ts +11 -0
- package/dist/core/model/input.js +2 -0
- package/dist/core/model/schema.d.ts +4 -0
- package/dist/core/model/schema.js +2 -0
- package/dist/core/protocol/mdsn.d.ts +6 -0
- package/dist/core/protocol/mdsn.js +80 -0
- package/dist/core/protocol/statements.d.ts +12 -0
- package/dist/core/protocol/statements.js +140 -0
- package/dist/core/protocol/validation.d.ts +4 -0
- package/dist/core/protocol/validation.js +60 -0
- package/dist/framework/create-framework-app.d.ts +12 -0
- package/dist/framework/create-framework-app.js +11 -0
- package/dist/framework/hosted-app.d.ts +13 -0
- package/dist/framework/hosted-app.js +133 -0
- package/dist/framework/index.d.ts +4 -0
- package/dist/framework/index.js +7 -0
- package/dist/framework/site-app.d.ts +12 -0
- package/dist/framework/site-app.js +146 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +18 -0
- package/dist/server/action-host.d.ts +3 -0
- package/dist/server/action-host.js +8 -0
- package/dist/server/action-runtime.d.ts +8 -0
- package/dist/server/action-runtime.js +81 -0
- package/dist/server/action.d.ts +41 -0
- package/dist/server/action.js +97 -0
- package/dist/server/build.d.ts +10 -0
- package/dist/server/build.js +166 -0
- package/dist/server/config.d.ts +56 -0
- package/dist/server/config.js +42 -0
- package/dist/server/dev.d.ts +48 -0
- package/dist/server/dev.js +90 -0
- package/dist/server/index.d.ts +8 -0
- package/dist/server/index.js +16 -0
- package/dist/server/init.d.ts +1 -0
- package/dist/server/init.js +176 -0
- package/dist/server/layout.d.ts +17 -0
- package/dist/server/layout.js +40 -0
- package/dist/server/markdown.d.ts +53 -0
- package/dist/server/markdown.js +76 -0
- package/dist/server/module-loader.d.ts +4 -0
- package/dist/server/module-loader.js +71 -0
- package/dist/server/negotiate.d.ts +3 -0
- package/dist/server/negotiate.js +55 -0
- package/dist/server/page-host.d.ts +21 -0
- package/dist/server/page-host.js +66 -0
- package/dist/server/page-links.d.ts +10 -0
- package/dist/server/page-links.js +80 -0
- package/dist/server/route-matcher.d.ts +6 -0
- package/dist/server/route-matcher.js +73 -0
- package/dist/server/routes.d.ts +6 -0
- package/dist/server/routes.js +73 -0
- package/dist/server/server.d.ts +27 -0
- package/dist/server/server.js +152 -0
- package/dist/server/site.d.ts +11 -0
- package/dist/server/site.js +59 -0
- package/dist/server/targets.d.ts +7 -0
- package/dist/server/targets.js +21 -0
- package/dist/web/block-runtime.d.ts +2 -0
- package/dist/web/block-runtime.js +27 -0
- package/dist/web/fragment-render.d.ts +10 -0
- package/dist/web/fragment-render.js +59 -0
- package/dist/web/headless.d.ts +95 -0
- package/dist/web/headless.js +370 -0
- package/dist/web/i18n.d.ts +31 -0
- package/dist/web/i18n.js +69 -0
- package/dist/web/index.d.ts +11 -0
- package/dist/web/index.js +22 -0
- package/dist/web/navigation.d.ts +3 -0
- package/dist/web/navigation.js +32 -0
- package/dist/web/page-bootstrap.d.ts +6 -0
- package/dist/web/page-bootstrap.js +29 -0
- package/dist/web/page-client-runtime.d.ts +15 -0
- package/dist/web/page-client-runtime.js +22 -0
- package/dist/web/page-client-script.d.ts +2 -0
- package/dist/web/page-client-script.js +567 -0
- package/dist/web/page-html.d.ts +8 -0
- package/dist/web/page-html.js +49 -0
- package/dist/web/page-render.d.ts +20 -0
- package/dist/web/page-render.js +92 -0
- package/dist/web/public-client-runtime.d.ts +1 -0
- package/dist/web/public-client-runtime.js +5 -0
- package/dist/web/public-render.d.ts +12 -0
- package/dist/web/public-render.js +18 -0
- package/dist/web/target-path.d.ts +1 -0
- package/dist/web/target-path.js +35 -0
- package/package.json +91 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { createRenderModel, renderDefaultHtmlDocument, renderPageHtml, } from "./public-render";
|
|
2
|
+
export { getClientRuntimeScript } from "./public-client-runtime";
|
|
3
|
+
export { createPageBootstrap } from "./page-bootstrap";
|
|
4
|
+
export { parseBlockFragment } from "./fragment-render";
|
|
5
|
+
export { createPageRenderModel } from "./page-render";
|
|
6
|
+
export { parseFragment, parseMarkdown, parsePage, } from "./headless";
|
|
7
|
+
export { createBlockRegionMarkup, replaceBlockRegionMarkup, } from "./block-runtime";
|
|
8
|
+
export type { CreateRenderModelOptions, RenderModel, } from "./public-render";
|
|
9
|
+
export type { PageBootstrap } from "./page-bootstrap";
|
|
10
|
+
export type { CreatePageRenderOptions, PageRenderModel } from "./page-render";
|
|
11
|
+
export type { FragmentStructureSegment, MarkdownBlockNode, MarkdownContainer, MarkdownInlineNode, PageStructureSegment, ParsedFragment, ParsedPage, } from "./headless";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.replaceBlockRegionMarkup = exports.createBlockRegionMarkup = exports.parsePage = exports.parseMarkdown = exports.parseFragment = exports.createPageRenderModel = exports.parseBlockFragment = exports.createPageBootstrap = exports.getClientRuntimeScript = exports.renderPageHtml = exports.renderDefaultHtmlDocument = exports.createRenderModel = void 0;
|
|
4
|
+
var public_render_1 = require("./public-render");
|
|
5
|
+
Object.defineProperty(exports, "createRenderModel", { enumerable: true, get: function () { return public_render_1.createRenderModel; } });
|
|
6
|
+
Object.defineProperty(exports, "renderDefaultHtmlDocument", { enumerable: true, get: function () { return public_render_1.renderDefaultHtmlDocument; } });
|
|
7
|
+
Object.defineProperty(exports, "renderPageHtml", { enumerable: true, get: function () { return public_render_1.renderPageHtml; } });
|
|
8
|
+
var public_client_runtime_1 = require("./public-client-runtime");
|
|
9
|
+
Object.defineProperty(exports, "getClientRuntimeScript", { enumerable: true, get: function () { return public_client_runtime_1.getClientRuntimeScript; } });
|
|
10
|
+
var page_bootstrap_1 = require("./page-bootstrap");
|
|
11
|
+
Object.defineProperty(exports, "createPageBootstrap", { enumerable: true, get: function () { return page_bootstrap_1.createPageBootstrap; } });
|
|
12
|
+
var fragment_render_1 = require("./fragment-render");
|
|
13
|
+
Object.defineProperty(exports, "parseBlockFragment", { enumerable: true, get: function () { return fragment_render_1.parseBlockFragment; } });
|
|
14
|
+
var page_render_1 = require("./page-render");
|
|
15
|
+
Object.defineProperty(exports, "createPageRenderModel", { enumerable: true, get: function () { return page_render_1.createPageRenderModel; } });
|
|
16
|
+
var headless_1 = require("./headless");
|
|
17
|
+
Object.defineProperty(exports, "parseFragment", { enumerable: true, get: function () { return headless_1.parseFragment; } });
|
|
18
|
+
Object.defineProperty(exports, "parseMarkdown", { enumerable: true, get: function () { return headless_1.parseMarkdown; } });
|
|
19
|
+
Object.defineProperty(exports, "parsePage", { enumerable: true, get: function () { return headless_1.parsePage; } });
|
|
20
|
+
var block_runtime_1 = require("./block-runtime");
|
|
21
|
+
Object.defineProperty(exports, "createBlockRegionMarkup", { enumerable: true, get: function () { return block_runtime_1.createBlockRegionMarkup; } });
|
|
22
|
+
Object.defineProperty(exports, "replaceBlockRegionMarkup", { enumerable: true, get: function () { return block_runtime_1.replaceBlockRegionMarkup; } });
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeMarkdownRouteTarget = normalizeMarkdownRouteTarget;
|
|
4
|
+
exports.resolveTargetValue = resolveTargetValue;
|
|
5
|
+
exports.getNavigationRuntimeSource = getNavigationRuntimeSource;
|
|
6
|
+
function normalizeMarkdownRouteTarget(target, baseOrigin) {
|
|
7
|
+
if (typeof target !== "string" || target.length === 0) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
if (/^https?:\/\//i.test(target)) {
|
|
11
|
+
return target;
|
|
12
|
+
}
|
|
13
|
+
const url = new URL(target, baseOrigin);
|
|
14
|
+
if (!/\.md$/i.test(url.pathname)) {
|
|
15
|
+
return url.pathname + url.search + url.hash;
|
|
16
|
+
}
|
|
17
|
+
if (url.pathname === "/index.md") {
|
|
18
|
+
return "/" + url.search + url.hash;
|
|
19
|
+
}
|
|
20
|
+
const stripped = url.pathname.slice(0, -3);
|
|
21
|
+
const routePath = stripped.endsWith("/index") ? stripped.slice(0, -6) || "/" : stripped;
|
|
22
|
+
return routePath + url.search + url.hash;
|
|
23
|
+
}
|
|
24
|
+
function resolveTargetValue(value) {
|
|
25
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
26
|
+
}
|
|
27
|
+
function getNavigationRuntimeSource() {
|
|
28
|
+
return [
|
|
29
|
+
normalizeMarkdownRouteTarget.toString(),
|
|
30
|
+
resolveTargetValue.toString(),
|
|
31
|
+
].join("\n\n");
|
|
32
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DocumentDefinition } from "../core/model/document";
|
|
2
|
+
export interface PageBootstrap extends DocumentDefinition {
|
|
3
|
+
version: "vNext";
|
|
4
|
+
inputState: Record<string, unknown>;
|
|
5
|
+
}
|
|
6
|
+
export declare function createPageBootstrap(document: DocumentDefinition): PageBootstrap;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPageBootstrap = createPageBootstrap;
|
|
4
|
+
function getInitialInputValue(type) {
|
|
5
|
+
if (type === "boolean") {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
if (type === "number") {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
return "";
|
|
12
|
+
}
|
|
13
|
+
function createPageBootstrap(document) {
|
|
14
|
+
const inputState = {};
|
|
15
|
+
for (const block of document.blocks) {
|
|
16
|
+
for (const input of block.inputs) {
|
|
17
|
+
inputState[input.id] = getInitialInputValue(input.type);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
version: "vNext",
|
|
22
|
+
frontmatter: document.frontmatter,
|
|
23
|
+
markdown: document.markdown,
|
|
24
|
+
schemas: document.schemas,
|
|
25
|
+
blocks: document.blocks,
|
|
26
|
+
blockAnchors: document.blockAnchors,
|
|
27
|
+
inputState,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ActionFailure, FragmentActionSuccess, RedirectActionSuccess } from "../core/action";
|
|
2
|
+
type AppliedFragmentResult = {
|
|
3
|
+
kind: "fragment";
|
|
4
|
+
html: string;
|
|
5
|
+
};
|
|
6
|
+
type AppliedRedirectResult = {
|
|
7
|
+
kind: "redirect";
|
|
8
|
+
location: string;
|
|
9
|
+
};
|
|
10
|
+
export type AppliedPageActionResult = AppliedFragmentResult | AppliedRedirectResult;
|
|
11
|
+
export type PageActionTransportResult = ActionFailure | RedirectActionSuccess | (FragmentActionSuccess & {
|
|
12
|
+
html: string;
|
|
13
|
+
});
|
|
14
|
+
export declare function applyActionResultToPageHtml(currentHtml: string, blockName: string, result: PageActionTransportResult): AppliedPageActionResult;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyActionResultToPageHtml = applyActionResultToPageHtml;
|
|
4
|
+
const block_runtime_1 = require("./block-runtime");
|
|
5
|
+
function applyActionResultToPageHtml(currentHtml, blockName, result) {
|
|
6
|
+
if (!result.ok) {
|
|
7
|
+
return {
|
|
8
|
+
kind: "fragment",
|
|
9
|
+
html: currentHtml,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
if (result.kind === "redirect") {
|
|
13
|
+
return {
|
|
14
|
+
kind: "redirect",
|
|
15
|
+
location: result.location,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
kind: "fragment",
|
|
20
|
+
html: (0, block_runtime_1.replaceBlockRegionMarkup)(currentHtml, blockName, result.html),
|
|
21
|
+
};
|
|
22
|
+
}
|