@mdsnai/sdk 0.2.0 → 0.2.2

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.
@@ -23,7 +23,7 @@ function parseMdsnBlocks(blocks) {
23
23
  continue;
24
24
  }
25
25
  if (!currentBlock) {
26
- if (line.startsWith("block ")) {
26
+ if (line.startsWith("BLOCK ")) {
27
27
  currentBlock = createBlock((0, statements_1.parseBlockHeaderLine)(line));
28
28
  documentBlocks.push(currentBlock);
29
29
  index += 1;
@@ -28,7 +28,7 @@ function parseStringArrayLiteral(raw) {
28
28
  return parsed;
29
29
  }
30
30
  function parseBlockHeaderLine(line) {
31
- const match = line.trim().match(/^block\s+([a-zA-Z_][\w-]*)\s*\{$/);
31
+ const match = line.trim().match(/^BLOCK\s+([a-zA-Z_][\w-]*)\s*\{$/);
32
32
  if (!match) {
33
33
  throw new Error(`Invalid block declaration: ${line}`);
34
34
  }
@@ -109,7 +109,7 @@ function blockToSerializableBlock(block) {
109
109
  };
110
110
  }
111
111
  function sendActionFragment(reqAccept, status, markdown, binding, res, options) {
112
- if ((0, negotiate_1.wantsMarkdown)(reqAccept) || !(0, negotiate_1.wantsHtml)(reqAccept)) {
112
+ if ((0, negotiate_1.wantsMarkdown)(reqAccept) && !(0, negotiate_1.wantsHtml)(reqAccept)) {
113
113
  res.status(status).type("text/markdown; charset=utf-8").send(markdown);
114
114
  return;
115
115
  }
@@ -29,7 +29,7 @@ function createStarterSite(targetDir) {
29
29
  start: "mdsn start",
30
30
  },
31
31
  dependencies: {
32
- "@mdsnai/sdk": "^0.2.0",
32
+ "@mdsnai/sdk": "^0.2.2",
33
33
  },
34
34
  }, null, 2) + "\n", "utf8");
35
35
  (0, node_fs_1.writeFileSync)(node_path_1.default.join(targetDir, "pages", "index.md"), `---
@@ -49,7 +49,7 @@ Start with a working guestbook and reshape it into your own app.
49
49
  <!-- mdsn:block guestbook -->
50
50
 
51
51
  \`\`\`mdsn
52
- block guestbook {
52
+ BLOCK guestbook {
53
53
  INPUT text -> nickname
54
54
  INPUT text required -> message
55
55
  GET "/list" -> refresh
@@ -46,7 +46,7 @@ function renderMarkdownValue(type, value, options) {
46
46
  }
47
47
  }
48
48
  function serializeBlock(block) {
49
- const lines = ["```mdsn", `block ${block.name} {`];
49
+ const lines = ["```mdsn", `BLOCK ${block.name} {`];
50
50
  for (const input of block.inputs ?? []) {
51
51
  const requiredMarker = input.required ? " required" : "";
52
52
  const secretMarker = input.secret ? " secret" : "";
@@ -28,7 +28,13 @@ function hasAcceptableMediaType(acceptHeader, matcher) {
28
28
  return parseAcceptHeader(acceptHeader).some((entry) => entry.quality > 0 && matcher(entry.mediaType));
29
29
  }
30
30
  function wantsHtml(acceptHeader) {
31
- return hasAcceptableMediaType(acceptHeader, (mediaType) => mediaType === "text/html" || mediaType === "application/xhtml+xml");
31
+ return hasAcceptableMediaType(acceptHeader, (mediaType) => {
32
+ if (mediaType === "*/*")
33
+ return true;
34
+ if (mediaType === "text/*")
35
+ return true;
36
+ return mediaType === "text/html" || mediaType === "application/xhtml+xml";
37
+ });
32
38
  }
33
39
  function wantsMarkdown(acceptHeader) {
34
40
  return hasAcceptableMediaType(acceptHeader, (mediaType) => mediaType === "text/markdown");
@@ -15,7 +15,7 @@ function renderHostedPage(rawPage, options) {
15
15
  body: "Not Acceptable",
16
16
  };
17
17
  }
18
- if (!(0, negotiate_1.wantsHtml)(options.accept)) {
18
+ if ((0, negotiate_1.wantsMarkdown)(options.accept) && !(0, negotiate_1.wantsHtml)(options.accept)) {
19
19
  return {
20
20
  status: 200,
21
21
  contentType: "text/markdown; charset=utf-8",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mdsnai/sdk",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "private": false,
5
5
  "description": "SDK, framework host, parser, renderer, and CLI for building MDSN sites.",
6
6
  "license": "MIT",