duckfn-docs-kit 0.1.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/AGENTS.md +689 -0
- package/LICENSE +21 -0
- package/README.md +107 -0
- package/dist/dom.d.ts +69 -0
- package/dist/home/DfkFeatures.d.ts +20 -0
- package/dist/home/DfkHero.d.ts +25 -0
- package/dist/home/DfkNextSteps.d.ts +16 -0
- package/dist/home/styles.d.ts +8 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.js +2 -0
- package/dist/register-DKLiYs-F.js +2324 -0
- package/dist/register.d.ts +10 -0
- package/dist/remark.d.ts +21 -0
- package/dist/remark.js +15 -0
- package/dist/runtimeConfig-Bokbb8VH.js +106 -0
- package/dist/sql/DfkSql.d.ts +7 -0
- package/dist/sql/PreviewTabs.d.ts +37 -0
- package/dist/sql/client.d.ts +1 -0
- package/dist/sql/client.js +4 -0
- package/dist/sql/editor.d.ts +16 -0
- package/dist/sql/extensions.d.ts +108 -0
- package/dist/sql/extensions.js +198 -0
- package/dist/sql/remark.d.ts +88 -0
- package/dist/sql/remark.js +69 -0
- package/dist/sql/renderers.d.ts +44 -0
- package/dist/sql/runtime.d.ts +105 -0
- package/dist/sql/runtimeConfig.d.ts +80 -0
- package/dist/sql/styles.d.ts +6 -0
- package/dist/toc-toggle/TocToggle.d.ts +46 -0
- package/dist/toc-toggle/TocToggle.js +69 -0
- package/dist/toc-toggle/client.d.ts +1 -0
- package/dist/toc-toggle/client.js +9 -0
- package/dist/toc-toggle/plugin.d.ts +36 -0
- package/dist/toc-toggle/plugin.js +13 -0
- package/dist/types.d.ts +42 -0
- package/package.json +73 -0
- package/src/dom.ts +109 -0
- package/src/home/DfkFeatures.ts +78 -0
- package/src/home/DfkHero.ts +128 -0
- package/src/home/DfkNextSteps.ts +73 -0
- package/src/home/home.css +520 -0
- package/src/home/styles.ts +28 -0
- package/src/index.ts +59 -0
- package/src/kit.css +19 -0
- package/src/register.ts +39 -0
- package/src/remark.ts +60 -0
- package/src/sql/DfkSql.css +226 -0
- package/src/sql/DfkSql.ts +620 -0
- package/src/sql/PreviewTabs.ts +169 -0
- package/src/sql/client.ts +16 -0
- package/src/sql/editor.ts +75 -0
- package/src/sql/extensions.ts +470 -0
- package/src/sql/remark.ts +213 -0
- package/src/sql/renderers.ts +916 -0
- package/src/sql/runtime.ts +348 -0
- package/src/sql/runtimeConfig.ts +249 -0
- package/src/sql/sql.css +397 -0
- package/src/sql/styles.ts +24 -0
- package/src/theme/tokens.css +75 -0
- package/src/toc-toggle/TocToggle.css +69 -0
- package/src/toc-toggle/TocToggle.ts +172 -0
- package/src/toc-toggle/client.ts +20 -0
- package/src/toc-toggle/plugin.ts +54 -0
- package/src/types.ts +47 -0
- package/src/vite-env.d.ts +8 -0
package/src/remark.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type {Plugin} from 'unified';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Replaces a build-time version placeholder in the docs tree.
|
|
5
|
+
*
|
|
6
|
+
* Written as a plain text substitution so it can live in a shared package: the
|
|
7
|
+
* version value is passed in by the consuming site (it is the one thing that is
|
|
8
|
+
* *not* shared), and only "pure text" carriers are touched —
|
|
9
|
+
* `text` / `inlineCode` / `code` nodes. MDX expression nodes (`{expr}`) and ESM
|
|
10
|
+
* nodes are deliberately left alone, so this never interferes with MDX's own
|
|
11
|
+
* evaluation.
|
|
12
|
+
*
|
|
13
|
+
* This is Node-side build code: it must not touch `window` / `document`.
|
|
14
|
+
*/
|
|
15
|
+
export const DEFAULT_VERSION_PLACEHOLDER = '{{DUCKFN_VERSION}}';
|
|
16
|
+
|
|
17
|
+
export interface VersionPlaceholderOptions {
|
|
18
|
+
/** The real version string to substitute in, e.g. `0.0.13`. */
|
|
19
|
+
version: string;
|
|
20
|
+
/** Override the token if a site uses a different one. */
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const TEXT_NODE_TYPES = new Set(['text', 'inlineCode', 'code']);
|
|
25
|
+
|
|
26
|
+
interface TextLikeNode {
|
|
27
|
+
type: string;
|
|
28
|
+
value?: unknown;
|
|
29
|
+
children?: TextLikeNode[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const remarkVersionPlaceholder: Plugin<[VersionPlaceholderOptions]> =
|
|
33
|
+
({version, placeholder = DEFAULT_VERSION_PLACEHOLDER}) =>
|
|
34
|
+
(tree) => {
|
|
35
|
+
const walk = (node: unknown): void => {
|
|
36
|
+
if (typeof node !== 'object' || node === null) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const candidate = node as TextLikeNode;
|
|
41
|
+
const value = candidate.value;
|
|
42
|
+
|
|
43
|
+
if (
|
|
44
|
+
typeof candidate.type === 'string' &&
|
|
45
|
+
typeof value === 'string' &&
|
|
46
|
+
TEXT_NODE_TYPES.has(candidate.type) &&
|
|
47
|
+
value.includes(placeholder)
|
|
48
|
+
) {
|
|
49
|
+
// Exact-token replacement only — no general `{{…}}` parsing — so other
|
|
50
|
+
// content is left untouched.
|
|
51
|
+
candidate.value = value.split(placeholder).join(version);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (Array.isArray(candidate.children)) {
|
|
55
|
+
candidate.children.forEach(walk);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
walk(tree);
|
|
60
|
+
};
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/* Shadow-root styles for `<dfk-sql>`: the code box — the CodeMirror editor and
|
|
2
|
+
the action cluster floating in its top-right corner. The editor is in *this*
|
|
3
|
+
tree on purpose: style-mod mounts CodeMirror's base theme into the root it
|
|
4
|
+
resolves from the container (`editor.ts`), which is this shadow root, so the
|
|
5
|
+
`.cm-*` rules land where they are used. Only the result container is a slotted
|
|
6
|
+
light-DOM node, because VTable injects a *document-level* stylesheet that a
|
|
7
|
+
shadow boundary could not host (`sql.css` styles that one).
|
|
8
|
+
|
|
9
|
+
Theme colours arrive through the inherited `--ifm-*` custom properties;
|
|
10
|
+
box-sizing must be re-declared here because the host page's universal reset
|
|
11
|
+
does not cross the shadow boundary. */
|
|
12
|
+
|
|
13
|
+
*,
|
|
14
|
+
*::before,
|
|
15
|
+
*::after {
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
:host {
|
|
20
|
+
display: block;
|
|
21
|
+
margin: 1rem 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.dfk-sql-code {
|
|
25
|
+
position: relative;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/* The editor and the buttons are in this same tree, so CodeMirror's own base
|
|
29
|
+
theme (mounted by style-mod into this shadow root, see `editor.ts`) and these
|
|
30
|
+
rules land in one cascade. Our selectors carry `.dfk-sql-editor`, so they
|
|
31
|
+
outrank CodeMirror's bare `.cm-*` ones whatever the sheet order turns out to
|
|
32
|
+
be. */
|
|
33
|
+
.dfk-sql-editor {
|
|
34
|
+
border: 1px solid var(--ifm-global-border-color, #e0e0e0);
|
|
35
|
+
border-radius: var(--ifm-global-radius, 0.4rem);
|
|
36
|
+
overflow: hidden;
|
|
37
|
+
background: var(--ifm-background-surface-color, #fff);
|
|
38
|
+
font-size: var(--ifm-code-font-size, 95%);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.dfk-sql-editor .cm-editor {
|
|
42
|
+
outline: none;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* --- Loading placeholder -------------------------------------------------- */
|
|
46
|
+
|
|
47
|
+
/* The editor is a lazy `import()`; until the CodeMirror modules arrive (a few
|
|
48
|
+
hundred KB on a slow link) the box would be an empty outline. The ghost is one
|
|
49
|
+
bar per line of SQL, which is what the editor itself is — one
|
|
50
|
+
`line-height: 1.6` box per line — so the block does not resize when CodeMirror
|
|
51
|
+
takes over. `#setEditorPending` builds it and drops it again.
|
|
52
|
+
|
|
53
|
+
`sql/remark.ts` prerenders the very same bars for the longer window *before*
|
|
54
|
+
this component exists, and `sql.css` carries their copy of these two rules (a
|
|
55
|
+
shadow tree sees neither the document's rules nor its `@keyframes`): keep the
|
|
56
|
+
two in sync. */
|
|
57
|
+
.dfk-sql-editor-skeleton {
|
|
58
|
+
/* CodeMirror's own content inset — `.cm-content` carries `padding: 4px 0` and
|
|
59
|
+
this box has none — on the container so it is paid once, not per line. */
|
|
60
|
+
padding: 4px 0.75rem;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.dfk-sql-editor-skeleton-line {
|
|
64
|
+
display: flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
/* One code line box, exactly: `.cm-scroller`'s `line-height: 1.6`. The half
|
|
67
|
+
leading that centres a line's text is the flex centring here — margins would
|
|
68
|
+
collapse between neighbouring lines and stack the bars closer than the code
|
|
69
|
+
they stand in for. */
|
|
70
|
+
height: 1.6em;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.dfk-sql-editor-skeleton-line::before {
|
|
74
|
+
content: '';
|
|
75
|
+
flex: 1;
|
|
76
|
+
height: 0.75em;
|
|
77
|
+
border-radius: 0.25em;
|
|
78
|
+
background-color: var(--ifm-color-emphasis-200, #e6e6e6);
|
|
79
|
+
/* Base colour + a lighter band travelling through it; `background-size: 200%`
|
|
80
|
+
is what gives `background-position` room to move (at 100% it cannot). */
|
|
81
|
+
background-image: linear-gradient(
|
|
82
|
+
90deg,
|
|
83
|
+
transparent 0%,
|
|
84
|
+
var(--ifm-color-emphasis-100, #f5f5f5) 50%,
|
|
85
|
+
transparent 100%
|
|
86
|
+
);
|
|
87
|
+
background-size: 200% 100%;
|
|
88
|
+
animation: dfk-sql-shimmer 1.6s linear infinite;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@keyframes dfk-sql-shimmer {
|
|
92
|
+
from {
|
|
93
|
+
background-position: 0% 0;
|
|
94
|
+
}
|
|
95
|
+
to {
|
|
96
|
+
background-position: 100% 0;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/* A bar that sweeps forever is decoration; readers who asked for less motion get
|
|
101
|
+
the static grey. Mirrored in `sql.css`. */
|
|
102
|
+
@media (prefers-reduced-motion: reduce) {
|
|
103
|
+
.dfk-sql-editor-skeleton-line {
|
|
104
|
+
animation: none;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.dfk-sql-editor .cm-scroller {
|
|
109
|
+
font-family: var(--ifm-font-family-monospace, ui-monospace, SFMono-Regular,
|
|
110
|
+
Menlo, monospace);
|
|
111
|
+
line-height: 1.6;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/* The editor's vertical inset is CodeMirror's own (`padding: 4px 0` in its base
|
|
115
|
+
theme) and is deliberately left alone. ViewState reads the content's computed
|
|
116
|
+
`padding-top` with `parseInt` and re-applies it as the first gutter element's
|
|
117
|
+
`marginTop` (it arrives as the gutter's `above` offset), so an override that
|
|
118
|
+
is not a whole number of pixels — `0.4rem` is 6.4px, mirrored as 6px — leaves
|
|
119
|
+
the line numbers fractionally off, and padding `.cm-gutters` as well would
|
|
120
|
+
count the inset twice: the numbers then sit ~6px below the lines they
|
|
121
|
+
belong to. */
|
|
122
|
+
|
|
123
|
+
/* Hover/focus-revealed, like the buttons on Docusaurus' own code blocks. The
|
|
124
|
+
cluster is inert while hidden so an invisible button is never a click target
|
|
125
|
+
in the middle of the code. */
|
|
126
|
+
.dfk-sql-actions {
|
|
127
|
+
position: absolute;
|
|
128
|
+
top: 0.25rem;
|
|
129
|
+
right: 0.25rem;
|
|
130
|
+
z-index: 1;
|
|
131
|
+
display: flex;
|
|
132
|
+
align-items: center;
|
|
133
|
+
gap: 0.15rem;
|
|
134
|
+
padding: 0.1rem 0.2rem;
|
|
135
|
+
border-radius: var(--ifm-global-radius, 0.3rem);
|
|
136
|
+
background: var(--ifm-color-emphasis-100, #f5f5f5);
|
|
137
|
+
opacity: 0;
|
|
138
|
+
pointer-events: none;
|
|
139
|
+
transition: opacity 0.12s ease;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.dfk-sql-code:hover .dfk-sql-actions,
|
|
143
|
+
.dfk-sql-code:focus-within .dfk-sql-actions,
|
|
144
|
+
.dfk-sql-actions-busy {
|
|
145
|
+
opacity: 1;
|
|
146
|
+
pointer-events: auto;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.dfk-sql-status {
|
|
150
|
+
padding: 0 0.25rem;
|
|
151
|
+
font-size: 0.72rem;
|
|
152
|
+
color: var(--ifm-color-emphasis-700, #666);
|
|
153
|
+
white-space: nowrap;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.dfk-sql-status:empty {
|
|
157
|
+
display: none;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/* --- Icon buttons and their tooltips ------------------------------------- */
|
|
161
|
+
|
|
162
|
+
/* Duplicated in `sql.css`: these buttons live in this shadow tree, while the
|
|
163
|
+
fullscreen toggle a renderer parks in the result's tab strip lives in the
|
|
164
|
+
light DOM, where a shadow rule could not reach it. Keep both copies in sync. */
|
|
165
|
+
.dfk-sql-icon-button {
|
|
166
|
+
position: relative;
|
|
167
|
+
display: inline-flex;
|
|
168
|
+
align-items: center;
|
|
169
|
+
justify-content: center;
|
|
170
|
+
width: 1.6rem;
|
|
171
|
+
height: 1.6rem;
|
|
172
|
+
padding: 0;
|
|
173
|
+
border: none;
|
|
174
|
+
border-radius: var(--ifm-global-radius, 0.25rem);
|
|
175
|
+
background: transparent;
|
|
176
|
+
color: var(--ifm-color-emphasis-700, #666);
|
|
177
|
+
cursor: pointer;
|
|
178
|
+
transition: background 0.12s ease, color 0.12s ease;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.dfk-sql-icon-button:hover:not(:disabled),
|
|
182
|
+
.dfk-sql-icon-button:focus-visible {
|
|
183
|
+
background: var(--ifm-color-emphasis-200, #e6e6e6);
|
|
184
|
+
color: var(--ifm-color-primary, #14459b);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.dfk-sql-icon-button:disabled {
|
|
188
|
+
opacity: 0.45;
|
|
189
|
+
cursor: progress;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.dfk-sql-icon-button[hidden] {
|
|
193
|
+
display: none;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/* A sticky state, e.g. the wrap toggle while wrapping is on. */
|
|
197
|
+
.dfk-sql-icon-on {
|
|
198
|
+
color: var(--ifm-color-primary, #14459b);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.dfk-sql-icon {
|
|
202
|
+
font-size: 1rem;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
[data-tip]::after {
|
|
206
|
+
content: attr(data-tip);
|
|
207
|
+
position: absolute;
|
|
208
|
+
top: calc(100% + 0.3rem);
|
|
209
|
+
right: 0;
|
|
210
|
+
z-index: 2;
|
|
211
|
+
padding: 0.15rem 0.4rem;
|
|
212
|
+
border-radius: var(--ifm-global-radius, 0.25rem);
|
|
213
|
+
background: var(--ifm-color-emphasis-800, #333);
|
|
214
|
+
color: var(--ifm-color-emphasis-0, #fff);
|
|
215
|
+
font-size: 0.7rem;
|
|
216
|
+
line-height: 1.4;
|
|
217
|
+
white-space: nowrap;
|
|
218
|
+
opacity: 0;
|
|
219
|
+
pointer-events: none;
|
|
220
|
+
transition: opacity 0.12s ease;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
[data-tip]:hover::after,
|
|
224
|
+
[data-tip]:focus-visible::after {
|
|
225
|
+
opacity: 1;
|
|
226
|
+
}
|