discord2html 1.0.2 → 1.0.3

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 CHANGED
@@ -13,6 +13,8 @@ Generate styled HTML transcripts from Discord channel message history. Processes
13
13
 
14
14
  - **Bug fix**: v3.3.0 introduced a stray `;` after the `<style>` JSX tag that prevented all custom CSS from loading, breaking the visual rendering of every Components V2 message. Fixed.
15
15
  - **Components V2**: Select menu option emojis now render as images (not raw URL strings). Premium button style handled. All unknown component types degrade gracefully to `null` instead of throwing.
16
+ - **Modern markdown**: Headings (`#`, `##`, `###`) and subtext (`-#`) are now rendered as styled HTML instead of falling through to plain text — important for Components V2 messages that rely on them.
17
+ - **CJS interop fix**: `discord-markdown-parser`'s `parse` is now imported as a named export. The previous default import resolved to the whole `module.exports` object under ESM, causing a runtime `parse is not a function` error.
16
18
  - **Dual CJS/ESM output**: Package now ships both `dist/index.js` (CJS) and `dist/index.mjs` (ESM) with matching `.d.ts` / `.d.mts` type declarations. The `exports` field is set correctly.
17
19
  - **Dependency fix**: `debug` was in `devDependencies` but is used in production code — moved to `dependencies`.
18
20
  - **Bundled React (self-contained)**: React, ReactDOM and `@derockdev/discord-components-*` are bundled into the dist at build time. The package renders with React 19 (`react-dom/static`), but `@derockdev/discord-components-react` peer-requires React ≤18 — so a naïve install left two React copies in the tree, and elements created under React 18 failed to render under React 19 with *"Objects are not valid as a React child"*. Bundling resolves every `import React` to a single React 19 instance baked into the package, so **consumers never need to install React or add `overrides`** — only `discord.js`. The ESM build injects a `createRequire` shim so the bundled CJS `react-dom` server can load Node built-ins (`util`, `stream`, …) without the *"Dynamic require of X is not supported"* error.
package/dist/index.js CHANGED
@@ -135367,7 +135367,7 @@ var import_discord10 = require("discord.js");
135367
135367
  var import_react17 = __toESM(require_react());
135368
135368
 
135369
135369
  // src/generator/renderers/content.tsx
135370
- var import_discord_markdown_parser = __toESM(require("discord-markdown-parser"));
135370
+ var import_discord_markdown_parser = require("discord-markdown-parser");
135371
135371
  var import_discord2 = require("discord.js");
135372
135372
  var import_react = __toESM(require_react());
135373
135373
 
@@ -135402,7 +135402,7 @@ function streamToString(stream) {
135402
135402
  // src/generator/renderers/content.tsx
135403
135403
  async function MessageContent({ content, context }) {
135404
135404
  if (context.type === 1 /* REPLY */ && content.length > 180) content = content.slice(0, 180) + "...";
135405
- const parsed = (0, import_discord_markdown_parser.default)(
135405
+ const parsed = (0, import_discord_markdown_parser.parse)(
135406
135406
  content,
135407
135407
  context.type === 0 /* EMBED */ || context.type === 3 /* WEBHOOK */ ? "extended" : "normal"
135408
135408
  );
@@ -135499,6 +135499,18 @@ async function MessageSingleASTNode({ node, context }) {
135499
135499
  );
135500
135500
  case "timestamp":
135501
135501
  return /* @__PURE__ */ import_react.default.createElement(DiscordTime, { timestamp: parseInt(node.timestamp) * 1e3, format: node.format });
135502
+ // Discord Components V2 / modern markdown: headings (#, ##, ###) and subtext (-#).
135503
+ case "heading": {
135504
+ if (context.type === 1 /* REPLY */) {
135505
+ return /* @__PURE__ */ import_react.default.createElement(MessageASTNodes, { nodes: node.content, context });
135506
+ }
135507
+ const level = Math.min(Math.max(Number(node.level) || 1, 1), 3);
135508
+ const fontSize = level === 1 ? "1.5em" : level === 2 ? "1.25em" : "1.1em";
135509
+ const Tag = `h${level}`;
135510
+ return /* @__PURE__ */ import_react.default.createElement(Tag, { style: { margin: "8px 0 4px", fontWeight: 700, lineHeight: 1.25, fontSize } }, /* @__PURE__ */ import_react.default.createElement(MessageASTNodes, { nodes: node.content, context }));
135511
+ }
135512
+ case "subtext":
135513
+ return /* @__PURE__ */ import_react.default.createElement("span", { style: { fontSize: "0.8em", color: "var(--text-muted, #949ba4)" } }, /* @__PURE__ */ import_react.default.createElement(MessageASTNodes, { nodes: node.content, context }));
135502
135514
  default: {
135503
135515
  console.log(`Unknown node type: ${type}`, node);
135504
135516
  return typeof node.content === "string" ? node.content : /* @__PURE__ */ import_react.default.createElement(MessageASTNodes, { nodes: node.content, context });