@steamfield/decks 0.0.0-stage → 1.0.0-rc.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 +201 -0
- package/README.md +28 -2
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +5 -0
- package/dist/index-B2n69xrC.d.ts +75 -0
- package/dist/index-BURtH7IB.d.ts +182 -0
- package/dist/index-BV_-6L5L.d.ts +136 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +6 -0
- package/dist/kit/chrome/od-byline.css +7 -0
- package/dist/kit/chrome/od-cover-head.css +10 -0
- package/dist/kit/chrome/od-eyebrow.css +13 -0
- package/dist/kit/chrome/od-logo.css +167 -0
- package/dist/kit/chrome/od-qr-card.css +30 -0
- package/dist/kit/ink/code-ink.css +83 -0
- package/dist/kit/ink/graph-3d.css +29 -0
- package/dist/kit/ink/ink-bars.css +7 -0
- package/dist/kit/ink/ink-card-rect.css +6 -0
- package/dist/kit/ink/ink-chip.css +62 -0
- package/dist/kit/ink/ink-line.css +7 -0
- package/dist/kit/ink/ink-number.css +22 -0
- package/dist/kit/ink/ink-ping.css +4 -0
- package/dist/kit/ink/ink-rule.css +4 -0
- package/dist/kit/ink/ink-timeline-cursor.css +3 -0
- package/dist/kit/ink/ink-timeline.css +9 -0
- package/dist/kit/ink/underline.css +12 -0
- package/dist/kit/ink/unit-grid.css +3 -0
- package/dist/kit/story/story-card.css +19 -0
- package/dist/kit/story/story-link.css +13 -0
- package/dist/kit/story/story-stage.css +59 -0
- package/dist/kit/styles/base.css +82 -0
- package/dist/kit/styles/compat.css +78 -0
- package/dist/kit/styles/components.css +224 -0
- package/dist/kit/styles/fonts/inter-cyrillic-ext-wght-normal.woff2 +0 -0
- package/dist/kit/styles/fonts/inter-cyrillic-wght-normal.woff2 +0 -0
- package/dist/kit/styles/fonts/inter-greek-ext-wght-normal.woff2 +0 -0
- package/dist/kit/styles/fonts/inter-greek-wght-normal.woff2 +0 -0
- package/dist/kit/styles/fonts/inter-latin-ext-wght-normal.woff2 +0 -0
- package/dist/kit/styles/fonts/inter-latin-wght-normal.woff2 +0 -0
- package/dist/kit/styles/fonts/inter-vietnamese-wght-normal.woff2 +0 -0
- package/dist/kit/styles/fonts.css +73 -0
- package/dist/kit/styles/index.css +36 -0
- package/dist/kit/styles/layout.css +181 -0
- package/dist/kit/styles/stats.css +92 -0
- package/dist/kit/styles/story-frame.css +179 -0
- package/dist/kit/styles/story-marks.css +115 -0
- package/dist/kit/styles/story-transition.css +182 -0
- package/dist/kit/styles.css +1 -0
- package/dist/kit.d.ts +880 -0
- package/dist/kit.js +3475 -0
- package/dist/layers.css +60 -0
- package/dist/layouts.css +58 -0
- package/dist/lint/ai-rhetoric-patterns.tsv +110 -0
- package/dist/lint/deck-writing-reminder.md +9 -0
- package/dist/motion.css +215 -0
- package/dist/motion.d.ts +2 -0
- package/dist/motion.js +1 -0
- package/dist/node.d.ts +63 -0
- package/dist/node.js +1 -0
- package/dist/overview-view.css +58 -0
- package/dist/play-view.css +29 -0
- package/dist/plugin/skills/building-a-deck/SKILL.md +22 -0
- package/dist/plugin/skills/building-a-deck/references/workflow.md +86 -0
- package/dist/plugin/skills/deck-data/SKILL.md +27 -0
- package/dist/plugin/skills/deck-data/references/fact-check.md +59 -0
- package/dist/plugin/skills/deck-data/references/provenance.md +61 -0
- package/dist/plugin/skills/deck-design/SKILL.md +31 -0
- package/dist/plugin/skills/deck-design/references/layout.md +55 -0
- package/dist/plugin/skills/deck-motion/SKILL.md +34 -0
- package/dist/plugin/skills/deck-motion/references/motion.md +66 -0
- package/dist/plugin/skills/visualization/SKILL.md +34 -0
- package/dist/plugin/skills/visualization/references/VENDORED.md +25 -0
- package/dist/plugin/skills/visualization/references/annotations.md +27 -0
- package/dist/plugin/skills/visualization/references/chart-selection.md +29 -0
- package/dist/plugin/skills/visualization/references/color-strategy.md +22 -0
- package/dist/plugin/skills/visualization/references/encoding-channels.md +44 -0
- package/dist/plugin/skills/visualization/references/ink.md +38 -0
- package/dist/plugin/skills/visualization/references/marks.md +33 -0
- package/dist/plugin/skills/visualization/references/presentation.md +43 -0
- package/dist/plugin/skills/working-with-decks/SKILL.md +34 -0
- package/dist/plugin/skills/working-with-decks/references/project.md +59 -0
- package/dist/plugin/skills/writing-slides/SKILL.md +45 -0
- package/dist/plugin/skills/writing-slides/references/lint.md +11 -0
- package/dist/plugin/skills/writing-slides/references/prose-patterns.md +48 -0
- package/dist/presenter-view.css +113 -0
- package/dist/print-view.module.css +32 -0
- package/dist/prose-patterns-DPqjGBFu.js +76 -0
- package/dist/prose-scan-BrWZ7gxZ.js +233 -0
- package/dist/src-C-OfT72W.js +396 -0
- package/dist/src-CmQgaG1b.js +2469 -0
- package/dist/src-DizFoqYt.js +1508 -0
- package/dist/templates/conventional/deck.config.ts +7 -0
- package/dist/templates/conventional/setup.ts +3 -0
- package/dist/templates/conventional/slides/01-cover.mdx +9 -0
- package/dist/templates/conventional/slides/02-first-point.mdx +12 -0
- package/dist/templates/conventional/styles/index.css +1 -0
- package/dist/templates/story/components/FirstStage.tsx +34 -0
- package/dist/templates/story/data/01-first.ts +8 -0
- package/dist/templates/story/data-sources.md +7 -0
- package/dist/templates/story/deck.config.ts +8 -0
- package/dist/templates/story/setup.ts +3 -0
- package/dist/templates/story/slides/01-cover.mdx +9 -0
- package/dist/templates/story/slides/02-first-point.mdx +6 -0
- package/dist/templates/story/styles/index.css +1 -0
- package/dist/transition.css +87 -0
- package/docs/README.md +28 -0
- package/docs/canvas.md +134 -0
- package/docs/cli.md +49 -0
- package/docs/code-blocks.md +132 -0
- package/docs/config.md +183 -0
- package/docs/getting-started.md +204 -0
- package/docs/kit.md +371 -0
- package/docs/migrating-from-slidev.md +45 -0
- package/docs/motion.md +396 -0
- package/docs/presenting.md +99 -0
- package/docs/slides.md +246 -0
- package/package.json +108 -4
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { i as DeckError, o as compileError, t as allowOf } from "./prose-patterns-DPqjGBFu.js";
|
|
2
|
+
import remarkFrontmatter from "remark-frontmatter";
|
|
3
|
+
import { unified } from "unified";
|
|
4
|
+
import remarkMdx from "remark-mdx";
|
|
5
|
+
import remarkParse from "remark-parse";
|
|
6
|
+
import { Visitor, parseSync } from "oxc-parser";
|
|
7
|
+
// ../node/src/prose/prose-offsets.ts
|
|
8
|
+
const markdown = unified().use(remarkParse);
|
|
9
|
+
/** Keep source positions while the parsers decode escapes and character references. */
|
|
10
|
+
function proseOffsets(raw, start, quote) {
|
|
11
|
+
const offsets = [];
|
|
12
|
+
const units = quote ? /\r\n|\\(?:u\{[\da-f]+\}|u[\da-f]{4}|x[\da-f]{2}|\r\n|[\s\S])|[\s\S]/gi : /\r\n|&(?:#\d+|#x[\da-f]+|[a-z][\da-z]*);|\\[!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~\\]|[\s\S]/gi;
|
|
13
|
+
for (const unit of raw.matchAll(units)) {
|
|
14
|
+
const text = unit[0];
|
|
15
|
+
let decoded = quote && text === "\r\n" ? "\n" : text;
|
|
16
|
+
if (quote && text.startsWith("\\")) {
|
|
17
|
+
const statement = parseSync("literal.ts", `${quote}${text}${quote}`).program.body[0];
|
|
18
|
+
if (statement?.type === "ExpressionStatement") {
|
|
19
|
+
const value = statement.expression;
|
|
20
|
+
if (value.type === "Literal" && typeof value.value === "string") decoded = value.value;
|
|
21
|
+
else if (value.type === "TemplateLiteral") decoded = value.quasis[0]?.value.cooked ?? text;
|
|
22
|
+
}
|
|
23
|
+
} else if (!quote && (text.startsWith("&") || text.startsWith("\\"))) {
|
|
24
|
+
const paragraph = markdown.parse(text).children[0];
|
|
25
|
+
const value = paragraph?.type === "paragraph" ? paragraph.children[0] : void 0;
|
|
26
|
+
if (value?.type === "text") decoded = value.value;
|
|
27
|
+
}
|
|
28
|
+
for (let index = 0; index < decoded.length; index++) offsets.push(start + unit.index);
|
|
29
|
+
}
|
|
30
|
+
return offsets;
|
|
31
|
+
}
|
|
32
|
+
// ../node/src/prose/prose-entries.ts
|
|
33
|
+
const inlineTags = /* @__PURE__ */ new Set([
|
|
34
|
+
"a",
|
|
35
|
+
"b",
|
|
36
|
+
"em",
|
|
37
|
+
"i",
|
|
38
|
+
"mark",
|
|
39
|
+
"s",
|
|
40
|
+
"small",
|
|
41
|
+
"span",
|
|
42
|
+
"strong",
|
|
43
|
+
"sub",
|
|
44
|
+
"sup",
|
|
45
|
+
"u"
|
|
46
|
+
]);
|
|
47
|
+
function proseEntries(source) {
|
|
48
|
+
const entries = [];
|
|
49
|
+
const prose = /* @__PURE__ */ new Map();
|
|
50
|
+
const add = (text, start, notes, inline = false, raw = text, quote) => {
|
|
51
|
+
const positions = proseOffsets(raw, start, quote);
|
|
52
|
+
let index = 0;
|
|
53
|
+
for (const line of text.split("\n")) {
|
|
54
|
+
const offsets = positions.slice(index, index + line.length);
|
|
55
|
+
const key = `${notes}:${source.slice(0, offsets[0] ?? start).split("\n").length}`;
|
|
56
|
+
const previous = inline ? prose.get(key) : void 0;
|
|
57
|
+
if (previous) {
|
|
58
|
+
previous.text += line;
|
|
59
|
+
previous.offsets.push(...offsets);
|
|
60
|
+
} else {
|
|
61
|
+
const entry = {
|
|
62
|
+
text: line,
|
|
63
|
+
offsets,
|
|
64
|
+
notes
|
|
65
|
+
};
|
|
66
|
+
entries.push(entry);
|
|
67
|
+
if (inline) prose.set(key, entry);
|
|
68
|
+
}
|
|
69
|
+
index += line.length + 1;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
return {
|
|
73
|
+
entries,
|
|
74
|
+
add,
|
|
75
|
+
clear: () => prose.clear()
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
// ../node/src/prose/mdx-prose.ts
|
|
79
|
+
const parser = unified().use(remarkParse).use(remarkFrontmatter).use(remarkMdx);
|
|
80
|
+
function collectMdxProse(file, source, entries, remarkPlugins) {
|
|
81
|
+
const { add, clear } = entries;
|
|
82
|
+
let tree;
|
|
83
|
+
try {
|
|
84
|
+
tree = parser().use(remarkPlugins ?? []).parse(source);
|
|
85
|
+
} catch (cause) {
|
|
86
|
+
throw compileError(cause, file);
|
|
87
|
+
}
|
|
88
|
+
const walkExpression = (node, notes) => {
|
|
89
|
+
if (!node || typeof node !== "object") return;
|
|
90
|
+
const boundary = "type" in node && (node.type === "ConditionalExpression" || node.type === "JSXElement");
|
|
91
|
+
if (boundary) clear();
|
|
92
|
+
if ("type" in node && node.type === "JSXText" && "value" in node && typeof node.value === "string" && "start" in node && typeof node.start === "number") {
|
|
93
|
+
const end = "end" in node && typeof node.end === "number" ? node.end : node.start + node.value.length;
|
|
94
|
+
add(node.value, node.start, notes, true, source.slice(node.start, end));
|
|
95
|
+
}
|
|
96
|
+
if ("type" in node && node.type === "JSXAttribute" && "value" in node && node.value && typeof node.value === "object") {
|
|
97
|
+
let value = node.value;
|
|
98
|
+
let expression = false;
|
|
99
|
+
if ("type" in value && value.type === "JSXExpressionContainer" && "expression" in value && value.expression && typeof value.expression === "object") {
|
|
100
|
+
expression = true;
|
|
101
|
+
value = value.expression;
|
|
102
|
+
}
|
|
103
|
+
if ("type" in value && value.type === "Literal" && "value" in value && typeof value.value === "string" && "start" in value && typeof value.start === "number" && "end" in value && typeof value.end === "number") add(value.value, value.start + 1, notes, false, source.slice(value.start + 1, value.end - 1), expression ? source[value.start] : void 0);
|
|
104
|
+
}
|
|
105
|
+
for (const child of Object.values(node)) walkExpression(child, notes);
|
|
106
|
+
if (boundary) clear();
|
|
107
|
+
};
|
|
108
|
+
const walk = (node, notes = false) => {
|
|
109
|
+
if (node.name === "Disclosure") return;
|
|
110
|
+
const boundary = node.type === "paragraph" || node.type === "heading" || node.type === "code" || node.type === "inlineCode" || node.name !== void 0 && node.name !== null && !inlineTags.has(node.name);
|
|
111
|
+
if (boundary) clear();
|
|
112
|
+
const inNotes = notes || node.name === "Notes";
|
|
113
|
+
if (node.type === "text" && typeof node.value === "string") add(node.value, node.position?.start.offset ?? 0, inNotes, true, source.slice(node.position?.start.offset, node.position?.end.offset));
|
|
114
|
+
walkExpression(node.data, inNotes);
|
|
115
|
+
for (const attr of node.attributes ?? []) {
|
|
116
|
+
if (attr.type !== "mdxJsxAttribute") continue;
|
|
117
|
+
if (typeof attr.value === "string") {
|
|
118
|
+
const start = attr.position?.start.offset ?? 0;
|
|
119
|
+
const raw = source.slice(start, attr.position?.end.offset);
|
|
120
|
+
const quote = raw.search(/["']/);
|
|
121
|
+
add(attr.value, start + quote + 1, inNotes, false, raw.slice(quote + 1, -1));
|
|
122
|
+
} else if (attr.value?.type === "mdxJsxAttributeValueExpression") {
|
|
123
|
+
walkExpression(attr.value.data, inNotes);
|
|
124
|
+
const expression = attr.value.data?.estree?.body[0];
|
|
125
|
+
if (expression?.type === "ExpressionStatement" && expression.expression.type === "Literal" && typeof expression.expression.value === "string") {
|
|
126
|
+
const literal = expression.expression;
|
|
127
|
+
if (!("start" in literal) || typeof literal.start !== "number") throw new DeckError("Cannot locate a string-literal prop. Check the slide syntax.", file);
|
|
128
|
+
if (typeof literal.value === "string") {
|
|
129
|
+
const end = "end" in literal && typeof literal.end === "number" ? literal.end : literal.start + literal.value.length + 2;
|
|
130
|
+
add(literal.value, literal.start + 1, inNotes, false, source.slice(literal.start + 1, end - 1), source[literal.start]);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
for (const child of node.children ?? []) walk(child, inNotes);
|
|
136
|
+
if (boundary) clear();
|
|
137
|
+
};
|
|
138
|
+
walk(tree);
|
|
139
|
+
}
|
|
140
|
+
// ../node/src/prose/tsx-prose.ts
|
|
141
|
+
function collectTsxProse(file, source, entries) {
|
|
142
|
+
const { add, clear } = entries;
|
|
143
|
+
const parsed = parseSync(file, source);
|
|
144
|
+
const error = parsed.errors[0];
|
|
145
|
+
if (error) {
|
|
146
|
+
const before = source.slice(0, error.labels[0]?.start ?? 0).split("\n");
|
|
147
|
+
throw new DeckError(`${error.message}. Check the component syntax.`, file, {
|
|
148
|
+
line: before.length,
|
|
149
|
+
column: (before.at(-1)?.length ?? 0) + 1
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
let notes = 0;
|
|
153
|
+
let jsxDepth = 0;
|
|
154
|
+
const branches = /* @__PURE__ */ new Set();
|
|
155
|
+
const copyRanges = [];
|
|
156
|
+
new Visitor({
|
|
157
|
+
VariableDeclarator(node) {
|
|
158
|
+
if (node.id.type !== "Identifier" || node.id.name !== "COPY") return;
|
|
159
|
+
let value = node.init;
|
|
160
|
+
while (value?.type === "TSAsExpression" || value?.type === "TSSatisfiesExpression" || value?.type === "ParenthesizedExpression") value = value.expression;
|
|
161
|
+
if (value?.type === "ArrayExpression") copyRanges.push(value);
|
|
162
|
+
},
|
|
163
|
+
JSXElement(node) {
|
|
164
|
+
if (jsxDepth === 0 || branches.has(node.start) || node.openingElement.name.type !== "JSXIdentifier" || !inlineTags.has(node.openingElement.name.name)) clear();
|
|
165
|
+
jsxDepth++;
|
|
166
|
+
if (node.openingElement.name.type === "JSXIdentifier" && node.openingElement.name.name === "Notes") notes++;
|
|
167
|
+
},
|
|
168
|
+
"JSXElement:exit"(node) {
|
|
169
|
+
jsxDepth--;
|
|
170
|
+
if (jsxDepth === 0 || branches.has(node.start) || node.openingElement.name.type !== "JSXIdentifier" || !inlineTags.has(node.openingElement.name.name)) clear();
|
|
171
|
+
if (node.openingElement.name.type === "JSXIdentifier" && node.openingElement.name.name === "Notes") notes--;
|
|
172
|
+
},
|
|
173
|
+
JSXText(node) {
|
|
174
|
+
add(node.value, node.start, notes > 0, true, source.slice(node.start, node.end));
|
|
175
|
+
},
|
|
176
|
+
ConditionalExpression(node) {
|
|
177
|
+
clear();
|
|
178
|
+
for (let branch of [node.consequent, node.alternate]) {
|
|
179
|
+
while (branch.type === "ParenthesizedExpression") branch = branch.expression;
|
|
180
|
+
branches.add(branch.start);
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
"ConditionalExpression:exit"() {
|
|
184
|
+
clear();
|
|
185
|
+
},
|
|
186
|
+
JSXExpressionContainer(node) {
|
|
187
|
+
if (node.expression.type !== "JSXEmptyExpression") clear();
|
|
188
|
+
},
|
|
189
|
+
"JSXExpressionContainer:exit"(node) {
|
|
190
|
+
if (node.expression.type !== "JSXEmptyExpression") clear();
|
|
191
|
+
},
|
|
192
|
+
Property(node) {
|
|
193
|
+
if (!copyRanges.some((range) => node.start >= range.start && node.end <= range.end)) return;
|
|
194
|
+
const key = node.key.type === "Identifier" ? node.key.name : node.key.type === "Literal" ? node.key.value : void 0;
|
|
195
|
+
if (key !== "lead" && key !== "body") return;
|
|
196
|
+
if (node.value.type === "Literal" && typeof node.value.value === "string") add(node.value.value, node.value.start + 1, false, false, source.slice(node.value.start + 1, node.value.end - 1), source[node.value.start]);
|
|
197
|
+
else if (node.value.type === "TemplateLiteral") for (const quasi of node.value.quasis) add(quasi.value.cooked ?? quasi.value.raw, quasi.start + 1, false, false, quasi.value.raw, "`");
|
|
198
|
+
}
|
|
199
|
+
}).visit(parsed.program);
|
|
200
|
+
}
|
|
201
|
+
// ../node/src/prose/prose-scan.ts
|
|
202
|
+
function scanSource(file, source, patterns, options) {
|
|
203
|
+
const prose = proseEntries(source);
|
|
204
|
+
if (file.endsWith(".mdx")) collectMdxProse(file, source, prose, options.remarkPlugins);
|
|
205
|
+
else collectTsxProse(file, source, prose);
|
|
206
|
+
const lines = source.split("\n");
|
|
207
|
+
const hits = [];
|
|
208
|
+
for (const pattern of patterns) for (const entry of prose.entries) {
|
|
209
|
+
const severity = entry.notes ? "warn" : pattern.severity;
|
|
210
|
+
if (options.errorsOnly && severity === "warn") continue;
|
|
211
|
+
const match = pattern.re.exec(entry.text);
|
|
212
|
+
if (!match) continue;
|
|
213
|
+
const offset = entry.offsets[match.index] ?? 0;
|
|
214
|
+
const before = source.slice(0, offset).split("\n");
|
|
215
|
+
const line = before.length;
|
|
216
|
+
const allow = allowOf(lines[line - 1] ?? "");
|
|
217
|
+
if (allow.includes("*") || allow.includes(pattern.id)) continue;
|
|
218
|
+
hits.push({
|
|
219
|
+
file,
|
|
220
|
+
line,
|
|
221
|
+
col: (before.at(-1)?.length ?? 0) + 1,
|
|
222
|
+
id: pattern.id,
|
|
223
|
+
severity,
|
|
224
|
+
text: entry.text,
|
|
225
|
+
match: match[0]
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
return hits;
|
|
229
|
+
}
|
|
230
|
+
function formatHit(hit) {
|
|
231
|
+
return `${hit.file}:${hit.line}:${hit.col} ${hit.severity} ${hit.id} ${hit.match}`;
|
|
232
|
+
}
|
|
233
|
+
export { formatHit, scanSource };
|
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
import { b as useSlideScale, g as registerSettleProbe, x as stepState, y as useSlide } from "./src-DizFoqYt.js";
|
|
2
|
+
import { Children, cloneElement, isValidElement, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore } from "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { flushSync } from "react-dom";
|
|
5
|
+
import "./motion.css";
|
|
6
|
+
import { gsap, gsap as gsap$1 } from "gsap";
|
|
7
|
+
import { CustomEase } from "gsap/CustomEase";
|
|
8
|
+
// ../motion/src/settle.ts
|
|
9
|
+
let pending = 0;
|
|
10
|
+
function pendingTweenNotification(change) {
|
|
11
|
+
pending += change;
|
|
12
|
+
}
|
|
13
|
+
registerSettleProbe(() => {
|
|
14
|
+
if (pending) return true;
|
|
15
|
+
return gsap$1.globalTimeline.getChildren(true, true, false).some((tween) => {
|
|
16
|
+
let unfinished = false;
|
|
17
|
+
for (let animation = tween; animation; animation = animation.parent) {
|
|
18
|
+
if (animation.paused() || animation.repeat() === -1) return false;
|
|
19
|
+
if (animation !== gsap$1.globalTimeline) unfinished ||= animation.totalProgress() < 1;
|
|
20
|
+
}
|
|
21
|
+
return unfinished;
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
// ../motion/src/code-block.tsx
|
|
25
|
+
function CodeBlock(props) {
|
|
26
|
+
const { clicks, isActive, renderContext } = useSlide();
|
|
27
|
+
const scale = useSlideScale();
|
|
28
|
+
const pre = useRef(null);
|
|
29
|
+
const rawSteps = "data-steps" in props ? props["data-steps"] : void 0;
|
|
30
|
+
const steps = useMemo(() => typeof rawSteps === "string" ? JSON.parse(rawSteps) : [], [rawSteps]);
|
|
31
|
+
const at = "data-at" in props ? Number(props["data-at"]) : 0;
|
|
32
|
+
const step = steps[clicks < at ? -1 : Math.min(clicks - at, steps.length - 1)];
|
|
33
|
+
const title = "data-title" in props ? String(props["data-title"]) : void 0;
|
|
34
|
+
const maxHeight = "data-max-height" in props ? Number(props["data-max-height"]) : void 0;
|
|
35
|
+
"data-lines" in props && Number(props["data-lines"]);
|
|
36
|
+
const height = { "--deck-code-max-height": maxHeight === void 0 ? "none" : `${maxHeight}px` };
|
|
37
|
+
const mark = (children) => Children.map(children, (child) => {
|
|
38
|
+
if (!isValidElement(child)) return child;
|
|
39
|
+
const line = child.props["data-line"];
|
|
40
|
+
return cloneElement(child, {
|
|
41
|
+
...line === void 0 ? {} : { "data-line-state": step === void 0 ? void 0 : step === "all" || Array.isArray(step) && step.includes(Number(line)) ? "active" : "dim" },
|
|
42
|
+
children: mark(child.props.children)
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
useLayoutEffect(() => {
|
|
46
|
+
const block = pre.current;
|
|
47
|
+
if (!block) return;
|
|
48
|
+
const measure = () => {
|
|
49
|
+
if (block.scrollHeight > block.clientHeight || block.scrollWidth > block.clientWidth) block.tabIndex = 0;
|
|
50
|
+
else block.removeAttribute("tabindex");
|
|
51
|
+
};
|
|
52
|
+
measure();
|
|
53
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
54
|
+
const observer = new ResizeObserver(measure);
|
|
55
|
+
observer.observe(block);
|
|
56
|
+
if (block.firstElementChild) observer.observe(block.firstElementChild);
|
|
57
|
+
return () => observer.disconnect();
|
|
58
|
+
}, []);
|
|
59
|
+
useLayoutEffect(() => {
|
|
60
|
+
const block = pre.current;
|
|
61
|
+
if (!block || maxHeight === void 0 || step === void 0) return;
|
|
62
|
+
if (renderContext === "print" || renderContext === "slide" && !isActive) return;
|
|
63
|
+
const active = block.querySelector("[data-line-state=\"active\"]");
|
|
64
|
+
if (!active) return;
|
|
65
|
+
const bounds = block.getBoundingClientRect();
|
|
66
|
+
const line = active.getBoundingClientRect();
|
|
67
|
+
const margin = 12;
|
|
68
|
+
if (line.top < bounds.top + margin * scale) block.scrollTop += (line.top - bounds.top) / scale - margin;
|
|
69
|
+
else if (line.bottom > bounds.bottom - margin * scale) block.scrollTop += (line.bottom - bounds.bottom) / scale + margin;
|
|
70
|
+
}, [
|
|
71
|
+
step,
|
|
72
|
+
maxHeight,
|
|
73
|
+
scale,
|
|
74
|
+
isActive,
|
|
75
|
+
renderContext
|
|
76
|
+
]);
|
|
77
|
+
return /* @__PURE__ */ jsxs("figure", {
|
|
78
|
+
className: "rd-code",
|
|
79
|
+
style: height,
|
|
80
|
+
children: [title !== void 0 && /* @__PURE__ */ jsx("figcaption", { children: title }), /* @__PURE__ */ jsx("pre", {
|
|
81
|
+
...props,
|
|
82
|
+
ref: pre,
|
|
83
|
+
children: mark(props.children)
|
|
84
|
+
})]
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
// ../motion/src/steps.tsx
|
|
88
|
+
function useStepState(at, until) {
|
|
89
|
+
return stepState(useSlide().clicks, at, until);
|
|
90
|
+
}
|
|
91
|
+
function stepAttributes(state, enter = "fade", exit = "fade") {
|
|
92
|
+
const hidden = state === "before" || state === "gone";
|
|
93
|
+
return {
|
|
94
|
+
"data-step-state": state,
|
|
95
|
+
"data-step-enter": enter,
|
|
96
|
+
"data-step-exit": exit,
|
|
97
|
+
"aria-hidden": hidden ? true : void 0,
|
|
98
|
+
inert: hidden ? true : void 0
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function Step({ at, until, enter, exit, as: Element = "div", className, children }) {
|
|
102
|
+
return /* @__PURE__ */ jsx(Element, {
|
|
103
|
+
...stepAttributes(useStepState(at, until), enter, exit),
|
|
104
|
+
className,
|
|
105
|
+
style: Element === "span" ? { display: "inline-block" } : void 0,
|
|
106
|
+
children
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
function Steps({ from, enter, as: Element = "div", className, children }) {
|
|
110
|
+
const { clicks } = useSlide();
|
|
111
|
+
const contents = Children.toArray(children).filter((child) => typeof child !== "string" || child.trim() !== "");
|
|
112
|
+
const list = contents[0];
|
|
113
|
+
if (contents.length === 1 && isValidElement(list) && (list.type === "ul" || list.type === "ol")) {
|
|
114
|
+
let index = 0;
|
|
115
|
+
return cloneElement(list, { className: [list.props.className, className].filter(Boolean).join(" ") || void 0 }, Children.map(list.props.children, (child) => isValidElement(child) && child.type === "li" ? cloneElement(child, stepAttributes(stepState(clicks, from + index++), enter)) : child));
|
|
116
|
+
}
|
|
117
|
+
return /* @__PURE__ */ jsx(Element, {
|
|
118
|
+
className,
|
|
119
|
+
children: Children.map(contents, (child, index) => /* @__PURE__ */ jsx(Step, {
|
|
120
|
+
at: from + index,
|
|
121
|
+
enter,
|
|
122
|
+
as: Element === "div" ? "div" : "li",
|
|
123
|
+
children: child
|
|
124
|
+
}))
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
function pieceStyle(index) {
|
|
128
|
+
return { "--step-index": index };
|
|
129
|
+
}
|
|
130
|
+
const groupStyle = {
|
|
131
|
+
opacity: 1,
|
|
132
|
+
transform: "none",
|
|
133
|
+
filter: "none",
|
|
134
|
+
clipPath: "none"
|
|
135
|
+
};
|
|
136
|
+
function Stagger({ at, until, enter, as: Element = "div", className, children }) {
|
|
137
|
+
const attrs = stepAttributes(useStepState(at, until), enter);
|
|
138
|
+
const Item = Element === "div" ? "div" : "li";
|
|
139
|
+
return /* @__PURE__ */ jsx(Element, {
|
|
140
|
+
...attrs,
|
|
141
|
+
style: groupStyle,
|
|
142
|
+
className,
|
|
143
|
+
children: Children.map(children, (child, index) => /* @__PURE__ */ jsx(Item, {
|
|
144
|
+
...attrs,
|
|
145
|
+
style: pieceStyle(index),
|
|
146
|
+
children: child
|
|
147
|
+
}))
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
const graphemes = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
151
|
+
function TextReveal({ at, by = "word", enter, children }) {
|
|
152
|
+
const attrs = stepAttributes(useStepState(at), enter);
|
|
153
|
+
if (typeof children !== "string") throw new Error(`TextReveal takes plain text; received ${children === null ? "null" : Array.isArray(children) ? "array" : typeof children}. Pass a string as its child.`);
|
|
154
|
+
const pieces = by === "char" ? Array.from(graphemes.segment(children), ({ segment }) => segment) : children.split(/(\s+)/);
|
|
155
|
+
let index = 0;
|
|
156
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
157
|
+
...attrs,
|
|
158
|
+
style: {
|
|
159
|
+
...groupStyle,
|
|
160
|
+
whiteSpace: "pre-wrap"
|
|
161
|
+
},
|
|
162
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
163
|
+
className: "rd-visually-hidden",
|
|
164
|
+
children
|
|
165
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
166
|
+
"aria-hidden": "true",
|
|
167
|
+
children: Children.map(pieces, (piece) => {
|
|
168
|
+
if (by === "word" && /^\s+$/.test(piece)) return piece;
|
|
169
|
+
if (!piece) return null;
|
|
170
|
+
return /* @__PURE__ */ jsx("span", {
|
|
171
|
+
...attrs,
|
|
172
|
+
"aria-hidden": "true",
|
|
173
|
+
style: {
|
|
174
|
+
...pieceStyle(index++),
|
|
175
|
+
display: /[\r\n]/.test(piece) ? "contents" : "inline-block",
|
|
176
|
+
whiteSpace: "pre"
|
|
177
|
+
},
|
|
178
|
+
children: piece
|
|
179
|
+
});
|
|
180
|
+
})
|
|
181
|
+
})]
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
function Highlight({ at, until, children }) {
|
|
185
|
+
return /* @__PURE__ */ jsx("mark", {
|
|
186
|
+
"data-step-state": useStepState(at, until),
|
|
187
|
+
"data-step-enter": "fade",
|
|
188
|
+
"data-step-exit": "fade",
|
|
189
|
+
children
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
function Draw({ at, until, children }) {
|
|
193
|
+
const shapes = /* @__PURE__ */ new Set([
|
|
194
|
+
"path",
|
|
195
|
+
"line",
|
|
196
|
+
"polyline",
|
|
197
|
+
"polygon",
|
|
198
|
+
"circle",
|
|
199
|
+
"ellipse",
|
|
200
|
+
"rect"
|
|
201
|
+
]);
|
|
202
|
+
return /* @__PURE__ */ jsx("g", {
|
|
203
|
+
...stepAttributes(useStepState(at, until)),
|
|
204
|
+
className: "rd-draw",
|
|
205
|
+
children: Children.map(children, (child) => isValidElement(child) && typeof child.type === "string" && shapes.has(child.type) ? cloneElement(child, { pathLength: 1 }) : child)
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
// ../motion/src/tokens.ts
|
|
209
|
+
const duration = {
|
|
210
|
+
quick: .14,
|
|
211
|
+
base: .3,
|
|
212
|
+
slow: .6
|
|
213
|
+
};
|
|
214
|
+
const ease = {
|
|
215
|
+
enter: "deckEnter",
|
|
216
|
+
exit: "deckExit",
|
|
217
|
+
settle: "deckSettle",
|
|
218
|
+
draw: "deckDraw"
|
|
219
|
+
};
|
|
220
|
+
const stagger = .06;
|
|
221
|
+
gsap.registerPlugin(CustomEase);
|
|
222
|
+
CustomEase.create(ease.enter, "0.16,1,0.3,1");
|
|
223
|
+
CustomEase.create(ease.exit, "0.7,0,0.84,0");
|
|
224
|
+
CustomEase.create(ease.settle, "0.32,0.72,0,1");
|
|
225
|
+
CustomEase.create(ease.draw, "0.65,0,0.35,1");
|
|
226
|
+
gsap.defaults({ ease: ease.settle });
|
|
227
|
+
gsap.ticker.lagSmoothing(0);
|
|
228
|
+
function motionMode() {
|
|
229
|
+
return document.documentElement.getAttribute("data-deck-motion") === "live" ? "live" : "instant";
|
|
230
|
+
}
|
|
231
|
+
// ../motion/src/use-tween.ts
|
|
232
|
+
function useTween(initial) {
|
|
233
|
+
const [, refresh] = useReducer((revision) => revision + 1, 0);
|
|
234
|
+
const [store] = useState(() => {
|
|
235
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
236
|
+
const fields = new Set(Object.keys(initial));
|
|
237
|
+
let revision = 0;
|
|
238
|
+
let pending = null;
|
|
239
|
+
return {
|
|
240
|
+
value: new Proxy({ ...initial }, { set(target, key, next) {
|
|
241
|
+
const changed = Reflect.get(target, key) !== next;
|
|
242
|
+
Reflect.set(target, key, next);
|
|
243
|
+
if (changed && typeof key === "string" && fields.has(key)) {
|
|
244
|
+
revision++;
|
|
245
|
+
if (pending) return true;
|
|
246
|
+
const publish = () => {
|
|
247
|
+
if (pending !== publish) return;
|
|
248
|
+
pending = null;
|
|
249
|
+
pendingTweenNotification(-1);
|
|
250
|
+
for (const notify of [...listeners]) notify();
|
|
251
|
+
};
|
|
252
|
+
pending = publish;
|
|
253
|
+
pendingTweenNotification(1);
|
|
254
|
+
queueMicrotask(publish);
|
|
255
|
+
}
|
|
256
|
+
return true;
|
|
257
|
+
} }),
|
|
258
|
+
snapshot: () => revision,
|
|
259
|
+
subscribe(notify) {
|
|
260
|
+
listeners.add(notify);
|
|
261
|
+
return () => {
|
|
262
|
+
listeners.delete(notify);
|
|
263
|
+
if (!listeners.size && pending) {
|
|
264
|
+
pending = null;
|
|
265
|
+
pendingTweenNotification(-1);
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
});
|
|
271
|
+
const revision = useSyncExternalStore(store.subscribe, store.snapshot, store.snapshot);
|
|
272
|
+
useLayoutEffect(() => store.subscribe(() => {
|
|
273
|
+
if (store.snapshot() !== revision) flushSync(refresh);
|
|
274
|
+
}), [store, revision]);
|
|
275
|
+
return store.value;
|
|
276
|
+
}
|
|
277
|
+
// ../motion/src/count-up.tsx
|
|
278
|
+
const numberFormat = new Intl.NumberFormat();
|
|
279
|
+
const defaultFormat = (value) => numberFormat.format(Math.round(value));
|
|
280
|
+
function CountUp({ at, from = 0, to, format = defaultFormat }) {
|
|
281
|
+
const state = useStepState(at);
|
|
282
|
+
const { isActive, renderContext } = useSlide();
|
|
283
|
+
const value = useTween({ number: state === "before" ? from : to });
|
|
284
|
+
const previous = useRef(state);
|
|
285
|
+
useLayoutEffect(() => {
|
|
286
|
+
const animate = previous.current === "before" && state === "current" && isActive && renderContext === "slide" && motionMode() === "live";
|
|
287
|
+
previous.current = state;
|
|
288
|
+
if (!animate) {
|
|
289
|
+
value.number = state === "before" ? from : to;
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
const tween = gsap.to(value, {
|
|
293
|
+
number: to,
|
|
294
|
+
duration: duration.slow,
|
|
295
|
+
ease: ease.settle
|
|
296
|
+
});
|
|
297
|
+
return () => {
|
|
298
|
+
tween.kill();
|
|
299
|
+
};
|
|
300
|
+
}, [
|
|
301
|
+
state,
|
|
302
|
+
from,
|
|
303
|
+
to,
|
|
304
|
+
isActive,
|
|
305
|
+
renderContext,
|
|
306
|
+
value
|
|
307
|
+
]);
|
|
308
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
309
|
+
"data-step-state": state,
|
|
310
|
+
"data-step-enter": "fade",
|
|
311
|
+
"data-step-exit": "fade",
|
|
312
|
+
style: {
|
|
313
|
+
opacity: 1,
|
|
314
|
+
visibility: "visible"
|
|
315
|
+
},
|
|
316
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
317
|
+
className: "rd-visually-hidden",
|
|
318
|
+
children: format(state === "before" ? from : to)
|
|
319
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
320
|
+
"aria-hidden": "true",
|
|
321
|
+
children: format(state === "before" ? from : value.number)
|
|
322
|
+
})]
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
// ../motion/src/morph.tsx
|
|
326
|
+
function Morph({ name, as: Element = "div", className, children }) {
|
|
327
|
+
const { isActive, renderContext } = useSlide();
|
|
328
|
+
if (!/^[A-Za-z_][A-Za-z0-9_-]*$/.test(name) || /^(none|auto|match-element|root|initial|inherit|unset|revert|revert-layer|default|deck-layer-above)$/i.test(name)) throw new Error(`Invalid Morph name ${JSON.stringify(name)}. Use a CSS identifier starting with a letter or underscore; CSS keywords and deck-layer-above are reserved.`);
|
|
329
|
+
return /* @__PURE__ */ jsx(Element, {
|
|
330
|
+
className,
|
|
331
|
+
style: isActive && renderContext === "slide" ? { viewTransitionName: name } : void 0,
|
|
332
|
+
children
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
// ../motion/src/use-timeline.ts
|
|
336
|
+
function useTimeline(build, deps = []) {
|
|
337
|
+
const { clicks, isActive, renderContext } = useSlide();
|
|
338
|
+
const state = useRef(null);
|
|
339
|
+
const builder = useRef(build);
|
|
340
|
+
useLayoutEffect(() => {
|
|
341
|
+
builder.current = build;
|
|
342
|
+
});
|
|
343
|
+
useLayoutEffect(() => {
|
|
344
|
+
const tl = gsap.timeline({ paused: true });
|
|
345
|
+
let last = -1;
|
|
346
|
+
try {
|
|
347
|
+
builder.current(tl, (n) => {
|
|
348
|
+
if (n !== last + 1 || n === 0 && tl.getChildren().length > 0) throw new Error(`Invalid label beat${n}; expected beat${last + 1} first`);
|
|
349
|
+
tl.addLabel(`beat${n}`);
|
|
350
|
+
last = n;
|
|
351
|
+
});
|
|
352
|
+
if (last < 0) throw new Error("Missing label beat0");
|
|
353
|
+
} catch (error) {
|
|
354
|
+
tl.kill();
|
|
355
|
+
throw error;
|
|
356
|
+
}
|
|
357
|
+
const built = {
|
|
358
|
+
tl,
|
|
359
|
+
current: -1,
|
|
360
|
+
last,
|
|
361
|
+
tween: null
|
|
362
|
+
};
|
|
363
|
+
state.current = built;
|
|
364
|
+
return () => {
|
|
365
|
+
built.tween?.kill();
|
|
366
|
+
tl.kill();
|
|
367
|
+
state.current = null;
|
|
368
|
+
};
|
|
369
|
+
}, [...deps]);
|
|
370
|
+
useLayoutEffect(() => {
|
|
371
|
+
const s = state.current;
|
|
372
|
+
if (!s) return;
|
|
373
|
+
const label = `beat${Math.min(clicks, s.last)}`;
|
|
374
|
+
const interrupted = s.tween !== null && s.tween.progress() < 1;
|
|
375
|
+
const rate = Math.abs(s.tl.timeScale()) || 1;
|
|
376
|
+
const previousTime = s.tl.labels[`beat${Math.min(s.current, s.last)}`] ?? 0;
|
|
377
|
+
const targetTime = s.tl.labels[label] ?? 0;
|
|
378
|
+
const stepDuration = Math.abs(targetTime - previousTime) / rate;
|
|
379
|
+
const remaining = Math.abs(targetTime - s.tl.time()) / rate;
|
|
380
|
+
s.tween?.kill();
|
|
381
|
+
s.tween = null;
|
|
382
|
+
if (s.current >= 0 && isActive && renderContext === "slide" && motionMode() === "live" && Math.abs(clicks - s.current) === 1) s.tween = s.tl.tweenTo(label, {
|
|
383
|
+
ease: "none",
|
|
384
|
+
overwrite: true,
|
|
385
|
+
...interrupted && stepDuration > 0 ? { duration: Math.min(remaining, stepDuration) } : {}
|
|
386
|
+
});
|
|
387
|
+
else s.tl.seek(label, false);
|
|
388
|
+
s.current = clicks;
|
|
389
|
+
}, [
|
|
390
|
+
clicks,
|
|
391
|
+
isActive,
|
|
392
|
+
renderContext,
|
|
393
|
+
...deps
|
|
394
|
+
]);
|
|
395
|
+
}
|
|
396
|
+
export { CodeBlock as _, duration as a, motionMode as c, Highlight as d, Stagger as f, useStepState as g, TextReveal as h, useTween as i, stagger as l, Steps as m, Morph as n, ease as o, Step as p, CountUp as r, gsap as s, useTimeline as t, Draw as u };
|