discord-html-transcripts-fix 1.7.1 → 1.8.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.
@@ -150,7 +150,13 @@ async function render(_a) {
150
150
  // Non-blocking inline JSON: type="application/json" so the parser doesn't pause
151
151
  (0, jsx_runtime_1.jsx)("script", { id: "dht-data", type: "application/json", dangerouslySetInnerHTML: { __html: (0, utils_1.safeJsonForScript)(globalData) } }),
152
152
  (0, jsx_runtime_1.jsx)("script", { dangerouslySetInnerHTML: { __html: 'try{globalThis.$discordMessage=JSON.parse(document.getElementById("dht-data").textContent);}catch(e){globalThis.$discordMessage={};}' } }),
153
- !options.hydrate && (0, jsx_runtime_1.jsx)("script", { type: "module", src: `https://cdn.jsdelivr.net/npm/@skyra/discord-components-core@${discordComponentsVersion}/+esm`, crossOrigin: "anonymous" }),
153
+ // Always load the @skyra/discord-components-core ES module, even
154
+ // when `hydrate: true` is requested. Lit SSR does not reliably
155
+ // expand every <discord-*> custom element to plain HTML, and the
156
+ // browser-side definitions are also needed to hydrate the SSR'd
157
+ // markup (re-render with state, click handlers, etc.). Without
158
+ // this tag the page is just static unstyled custom elements.
159
+ (0, jsx_runtime_1.jsx)("script", { type: "module", src: `https://cdn.jsdelivr.net/npm/@skyra/discord-components-core@${discordComponentsVersion}/+esm`, crossOrigin: "anonymous" }),
154
160
  ] }),
155
161
  (0, jsx_runtime_1.jsxs)("body", { style: { margin: 0, minHeight: '100vh' }, children: [
156
162
  (0, jsx_runtime_1.jsx)(transcript_1.default, Object.assign({ messages, channel, callbacks }, options, renderContext)),
@@ -52,21 +52,24 @@ async function DiscordMessages(_a) {
52
52
  ] }));
53
53
  }
54
54
 
55
- // Legacy "Exported X message(s). Powered by …" line. The new stats footer
56
- // (see renderStatsFooter in generator/index.js) already shows the message
57
- // count, so this line is suppressed by default and only renders when:
58
- // - options.statsFooter === false (caller opted out of the new footer), or
59
- // - options.footerText is explicitly set to a string, or
60
- // - options.poweredBy === true (caller wants the credit link).
55
+ // Legacy "Exported X message(s). Powered by …" footer line.
56
+ //
57
+ // The new stats footer (see renderStatsFooter in generator/index.js) already
58
+ // shows the message count and more. To prevent two footers stacking on the
59
+ // same transcript, the legacy footer is now mutually exclusive with the
60
+ // stats footer: it ONLY renders when the caller has explicitly disabled the
61
+ // stats footer via `statsFooter: false` (or `{ enabled: false }`). Setting
62
+ // `footerText` or `poweredBy` alone is no longer enough — that used to
63
+ // produce a duplicate footer because the stats footer kept rendering.
61
64
  function renderLegacyFooter(messages, options) {
62
65
  const statsDisabled = options.statsFooter === false ||
63
66
  (options.statsFooter && options.statsFooter.enabled === false);
67
+ if (!statsDisabled) return null;
64
68
  const customText = (typeof options.footerText === 'string' && options.footerText.length > 0)
65
69
  ? options.footerText.replaceAll('{number}', messages.length.toString()).replaceAll('{s}', messages.length > 1 ? 's' : '')
66
70
  : null;
67
71
  const wantsPowered = !!options.poweredBy;
68
- // Default render only if stats footer is off AND no custom text was set.
69
- const defaultText = statsDisabled && !customText
72
+ const defaultText = !customText
70
73
  ? `Exported ${messages.length} message${messages.length > 1 ? 's' : ''}.`
71
74
  : null;
72
75
  const shown = customText || defaultText;
@@ -97,9 +97,15 @@ async function buildAllContext(messages, channel) {
97
97
  : (displayHex && displayHex !== '#000000' ? displayHex : null);
98
98
 
99
99
  // legacy profile (used by <discord-mention>)
100
+ //
101
+ // forceStatic: Discord CDN returns HTTP 415 for `.gif` on some animated
102
+ // avatar hashes (commonly bot avatars whose animation was removed but
103
+ // whose hash still carries the `a_` prefix). The static variant (.webp
104
+ // or .png) always works, so render avatars as static in transcripts.
105
+ // Avatars in a historical archive don't gain much from being animated.
100
106
  profiles[id] = {
101
107
  author: member?.nickname ?? author.displayName ?? author.username,
102
- avatar: member?.displayAvatarURL?.({ size: 64 }) ?? author.displayAvatarURL?.({ size: 64 }),
108
+ avatar: member?.displayAvatarURL?.({ size: 64, forceStatic: true }) ?? author.displayAvatarURL?.({ size: 64, forceStatic: true }),
103
109
  roleColor: effectiveColor,
104
110
  roleIcon: member?.roles?.icon?.iconURL?.() ?? undefined,
105
111
  roleName: member?.roles?.hoist?.name ?? undefined,
@@ -124,7 +130,7 @@ async function buildAllContext(messages, channel) {
124
130
  username: author.username,
125
131
  displayName: member?.nickname || author.displayName || author.username,
126
132
  globalName: author.globalName || null,
127
- avatar: member?.displayAvatarURL?.({ size: 128 }) || author.displayAvatarURL?.({ size: 128 }) || null,
133
+ avatar: member?.displayAvatarURL?.({ size: 128, forceStatic: true }) || author.displayAvatarURL?.({ size: 128, forceStatic: true }) || null,
128
134
  bannerColor: effectiveColor,
129
135
  bot: !!author.bot,
130
136
  system: !!author.system,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "discord-html-transcripts-fix",
3
- "version": "1.7.1",
3
+ "version": "1.8.0",
4
4
  "description": "A nicely formatted html transcript generator for discord.js. Bugfix fork with support for the latest discord.js and Components v2.",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/index.d.ts",