@markdy/astro 0.8.12 → 0.8.14
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 +1 -0
- package/package.json +2 -2
- package/src/Markdy.astro +20 -2
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
- **View Transition compatible** — re-observes elements on `astro:page-load`
|
|
10
10
|
- **Semantic node cards** — inherits renderer SVG glyphs for technical node kinds
|
|
11
11
|
- **Zero config** — pass your MarkdyScript code as a prop
|
|
12
|
+
- **Indent-safe transport** — encodes MarkdyScript as base64 on the DOM so HTML attribute normalization cannot destroy colon-body indentation before hydration
|
|
12
13
|
|
|
13
14
|
## Installation
|
|
14
15
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markdy/astro",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.14",
|
|
4
4
|
"description": "Astro island component for diagram-native animated MarkdyScript architecture diagrams.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@markdy/renderer-dom": "0.8.
|
|
41
|
+
"@markdy/renderer-dom": "0.8.14"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"astro": ">=4.0.0"
|
package/src/Markdy.astro
CHANGED
|
@@ -76,11 +76,18 @@ const {
|
|
|
76
76
|
title = "Markdy animation",
|
|
77
77
|
description,
|
|
78
78
|
} = Astro.props;
|
|
79
|
+
|
|
80
|
+
// Base64 avoids HTML attribute whitespace normalization, which strips the
|
|
81
|
+
// leading indentation MarkdyScript uses for colon bodies (groups/beats).
|
|
82
|
+
const codeB64 =
|
|
83
|
+
typeof Buffer !== "undefined"
|
|
84
|
+
? Buffer.from(code, "utf8").toString("base64")
|
|
85
|
+
: btoa(unescape(encodeURIComponent(code)));
|
|
79
86
|
---
|
|
80
87
|
|
|
81
88
|
<div
|
|
82
89
|
class:list={["markdy-root", className]}
|
|
83
|
-
data-markdy-code={
|
|
90
|
+
data-markdy-code-b64={codeB64}
|
|
84
91
|
data-markdy-assets={JSON.stringify(assets)}
|
|
85
92
|
data-markdy-autoplay={String(autoplay)}
|
|
86
93
|
data-markdy-loop={String(loop)}
|
|
@@ -233,8 +240,19 @@ const {
|
|
|
233
240
|
// host-page bundle. The browser only downloads it when an element is
|
|
234
241
|
// about to enter the viewport, keeping Time-to-Interactive low.
|
|
235
242
|
|
|
243
|
+
function readMarkdyCode(el: HTMLElement): string | undefined {
|
|
244
|
+
const b64 = el.dataset.markdyCodeB64;
|
|
245
|
+
if (b64) {
|
|
246
|
+
const binary = atob(b64);
|
|
247
|
+
const bytes = Uint8Array.from(binary, (c) => c.charCodeAt(0));
|
|
248
|
+
return new TextDecoder().decode(bytes);
|
|
249
|
+
}
|
|
250
|
+
// Legacy pages built before base64 encoding.
|
|
251
|
+
return el.dataset.markdyCode;
|
|
252
|
+
}
|
|
253
|
+
|
|
236
254
|
async function hydrate(el: HTMLElement, forcePlay = false): Promise<void> {
|
|
237
|
-
const code = el
|
|
255
|
+
const code = readMarkdyCode(el);
|
|
238
256
|
if (!code) return;
|
|
239
257
|
|
|
240
258
|
let assets: Record<string, string> = {};
|