@d1vij/jassm 0.1.23 → 0.1.26
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/dist/index.d.ts +2 -1
- package/dist/index.js +653 -12
- package/dist/vitePlugin.js +14 -1
- package/package.json +10 -9
package/dist/index.d.ts
CHANGED
|
@@ -102,6 +102,7 @@ type RegistryOptions<
|
|
|
102
102
|
* Virtual route mount point
|
|
103
103
|
*/
|
|
104
104
|
virtual: Virtual;
|
|
105
|
+
meta_extension?: string;
|
|
105
106
|
};
|
|
106
107
|
/**
|
|
107
108
|
* Internal function used by {@link Registry}.
|
|
@@ -117,7 +118,7 @@ declare function generateRegistry<
|
|
|
117
118
|
Modules extends Record<string, WrappedUnknownPromise>,
|
|
118
119
|
Root extends string,
|
|
119
120
|
Virtual extends string
|
|
120
|
-
>({ modulesGlob, metadataGlob, root, virtual }: RegistryOptions<MetaType, Modules, Root, Virtual>): {
|
|
121
|
+
>({ modulesGlob, metadataGlob, root, virtual, meta_extension }: RegistryOptions<MetaType, Modules, Root, Virtual>): {
|
|
121
122
|
/**
|
|
122
123
|
* List of route keys
|
|
123
124
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,662 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
// src/components/Elements/Anchor.tsx
|
|
2
|
+
import { cn } from "@d1vij/shit-i-always-use";
|
|
3
|
+
import { useMemo, useState } from "react";
|
|
4
|
+
|
|
5
|
+
// src/lib/StyleContext.ts
|
|
6
|
+
import { createContext, useContext } from "react";
|
|
7
|
+
var StyleClassesList = [
|
|
8
|
+
"header",
|
|
9
|
+
"header_button",
|
|
10
|
+
"header_1",
|
|
11
|
+
"header_2",
|
|
12
|
+
"header_3",
|
|
13
|
+
"header_4",
|
|
14
|
+
"header_5",
|
|
15
|
+
"header_6",
|
|
16
|
+
"header_icon",
|
|
17
|
+
"anchor",
|
|
18
|
+
"button",
|
|
19
|
+
"bold",
|
|
20
|
+
"italic",
|
|
21
|
+
"span",
|
|
22
|
+
"striked",
|
|
23
|
+
"paragraph",
|
|
24
|
+
"code",
|
|
25
|
+
"preformatted",
|
|
26
|
+
"blockquote",
|
|
27
|
+
"horizontal_line",
|
|
28
|
+
"image",
|
|
29
|
+
"list",
|
|
30
|
+
"unordered_list",
|
|
31
|
+
"ordered_list",
|
|
32
|
+
"list_item",
|
|
33
|
+
"table",
|
|
34
|
+
"table_head",
|
|
35
|
+
"table_head_cell",
|
|
36
|
+
"table_body",
|
|
37
|
+
"table_row",
|
|
38
|
+
"table_data",
|
|
39
|
+
"table_container",
|
|
40
|
+
"table_action_buttons_details",
|
|
41
|
+
"table_action_buttons_summary",
|
|
42
|
+
"table_action_button",
|
|
43
|
+
"table_action_button_html",
|
|
44
|
+
"table_action_button_csv",
|
|
45
|
+
"table_action_button_json",
|
|
46
|
+
"table_action_button_markdown"
|
|
47
|
+
];
|
|
48
|
+
var StyleContext = createContext(null);
|
|
49
|
+
function useStyles() {
|
|
50
|
+
const ctx = useContext(StyleContext);
|
|
51
|
+
if (ctx === null)
|
|
52
|
+
throw new Error("No stylesmap found at any parent level. Either you forgot to pass the stylesmap to component loader or didnt wrap your component in StyleContext");
|
|
53
|
+
return ctx;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// src/components/Elements/Anchor.tsx
|
|
57
|
+
import { jsx } from "react/jsx-runtime";
|
|
58
|
+
function Anchor(props) {
|
|
59
|
+
const selfOrigin = useMemo(() => new URL(window.location.href).origin.toString(), []);
|
|
60
|
+
const styles = useStyles();
|
|
61
|
+
const [target] = useState(() => {
|
|
62
|
+
const href = props.href;
|
|
63
|
+
if (href?.match(/^#.*/)) {
|
|
64
|
+
return "_self";
|
|
65
|
+
}
|
|
66
|
+
const targetOrigin = new URL(props.href ?? "").origin.toString();
|
|
67
|
+
return targetOrigin === selfOrigin ? "_self" : "_blank";
|
|
68
|
+
});
|
|
69
|
+
return /* @__PURE__ */ jsx("a", {
|
|
70
|
+
className: cn(styles.anchor),
|
|
71
|
+
target,
|
|
72
|
+
href: props.href,
|
|
73
|
+
children: props.children
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// src/components/Elements/BlockQuote.tsx
|
|
78
|
+
import { cn as cn2 } from "@d1vij/shit-i-always-use";
|
|
79
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
80
|
+
function BlockQuote(props) {
|
|
81
|
+
const styles = useStyles();
|
|
82
|
+
return /* @__PURE__ */ jsx2("blockquote", {
|
|
83
|
+
className: cn2(styles.blockquote),
|
|
84
|
+
children: props.children
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// src/components/Elements/Bold.tsx
|
|
89
|
+
import { cn as cn3 } from "@d1vij/shit-i-always-use";
|
|
90
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
91
|
+
function Bold(props) {
|
|
92
|
+
const styles = useStyles();
|
|
93
|
+
return /* @__PURE__ */ jsx3("span", {
|
|
94
|
+
className: cn3(styles.bold),
|
|
95
|
+
children: props.children
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// src/components/Elements/Code.tsx
|
|
100
|
+
import { cn as cn4 } from "@d1vij/shit-i-always-use";
|
|
101
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
102
|
+
function Code(props) {
|
|
103
|
+
const styles = useStyles();
|
|
104
|
+
const lang = /language-(\w+)/.exec(props.className || "")?.[1];
|
|
105
|
+
return /* @__PURE__ */ jsx4("code", {
|
|
106
|
+
className: cn4(styles.code, lang && `language-${lang}`),
|
|
107
|
+
children: props.children
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// src/components/Elements/Heading.tsx
|
|
112
|
+
import { cn as cn5 } from "@d1vij/shit-i-always-use";
|
|
113
|
+
import { useClipboardText } from "@d1vij/shit-i-always-use/react";
|
|
114
|
+
import { useEffect, useRef, useState as useState2 } from "react";
|
|
115
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
116
|
+
function Header(props) {
|
|
117
|
+
const styles = useStyles();
|
|
118
|
+
const headerRef = useRef(null);
|
|
119
|
+
const [id, setId] = useState2("");
|
|
120
|
+
const { copy } = useClipboardText();
|
|
121
|
+
async function handleClick() {
|
|
122
|
+
const url = new URL(`/#${id}`, window.location.origin).toString();
|
|
123
|
+
await copy(url);
|
|
124
|
+
}
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
if (!headerRef.current)
|
|
127
|
+
return;
|
|
128
|
+
const raw = headerRef.current.textContent ?? "";
|
|
129
|
+
const safe = raw.toLowerCase().replace(/[^a-z0-9\s-]/g, "").trim().replace(/\s+/g, "-").slice(0, 30);
|
|
130
|
+
setId(safe);
|
|
131
|
+
}, []);
|
|
132
|
+
return /* @__PURE__ */ jsx5("h1", {
|
|
133
|
+
className: cn5(styles.header, styles[`header_${props.level}`]),
|
|
134
|
+
children: /* @__PURE__ */ jsx5("button", {
|
|
135
|
+
onClick: () => void handleClick(),
|
|
136
|
+
ref: headerRef,
|
|
137
|
+
id,
|
|
138
|
+
className: cn5(styles.header_button),
|
|
139
|
+
type: "button",
|
|
140
|
+
children: props.children
|
|
141
|
+
})
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// src/components/Elements/HorizontalLine.tsx
|
|
146
|
+
import { cn as cn6 } from "@d1vij/shit-i-always-use";
|
|
147
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
148
|
+
function HorizontalLine(_) {
|
|
149
|
+
const styles = useStyles();
|
|
150
|
+
return /* @__PURE__ */ jsx6("hr", {
|
|
151
|
+
className: cn6(styles.horizontal_line)
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// src/components/Elements/Image.tsx
|
|
156
|
+
import { cn as cn7 } from "@d1vij/shit-i-always-use";
|
|
157
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
158
|
+
function Image(props) {
|
|
159
|
+
const styles = useStyles();
|
|
160
|
+
return /* @__PURE__ */ jsx7("img", {
|
|
161
|
+
className: cn7(styles.image),
|
|
162
|
+
alt: props.alt,
|
|
163
|
+
title: props.title,
|
|
164
|
+
src: props.src
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// src/components/Elements/Italics.tsx
|
|
169
|
+
import { cn as cn8 } from "@d1vij/shit-i-always-use";
|
|
170
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
171
|
+
function Italics(props) {
|
|
172
|
+
const styles = useStyles();
|
|
173
|
+
return /* @__PURE__ */ jsx8("span", {
|
|
174
|
+
className: cn8(styles.italic),
|
|
175
|
+
children: props.children
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// src/components/Elements/List.tsx
|
|
180
|
+
import { cn as cn9 } from "@d1vij/shit-i-always-use";
|
|
181
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
182
|
+
function List(props) {
|
|
183
|
+
const styles = useStyles();
|
|
184
|
+
const L = props.type === "ordered" ? "ol" : "ul";
|
|
185
|
+
return /* @__PURE__ */ jsx9(L, {
|
|
186
|
+
className: cn9(styles.list, props.type === "ordered" && styles.ordered_list, props.type === "unordered" && styles.unordered_list),
|
|
187
|
+
children: props.children
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
function ListItem(props) {
|
|
191
|
+
const styles = useStyles();
|
|
192
|
+
return /* @__PURE__ */ jsx9("li", {
|
|
193
|
+
className: cn9(styles.list_item),
|
|
194
|
+
children: props.children
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// src/components/Elements/Paragraph.tsx
|
|
199
|
+
import { cn as cn10 } from "@d1vij/shit-i-always-use";
|
|
200
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
201
|
+
function Paragraph(props) {
|
|
202
|
+
const styles = useStyles();
|
|
203
|
+
return /* @__PURE__ */ jsx10("p", {
|
|
204
|
+
className: cn10(styles.paragraph),
|
|
205
|
+
children: props.children
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// src/components/Elements/Preformatted.tsx
|
|
210
|
+
import { cn as cn11 } from "@d1vij/shit-i-always-use";
|
|
211
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
212
|
+
function Preformatted(props) {
|
|
213
|
+
const styles = useStyles();
|
|
214
|
+
return /* @__PURE__ */ jsx11("pre", {
|
|
215
|
+
className: cn11(styles.preformatted),
|
|
216
|
+
children: props.children
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// src/components/Elements/Striked.tsx
|
|
221
|
+
import { cn as cn12 } from "@d1vij/shit-i-always-use";
|
|
222
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
223
|
+
function Striked(props) {
|
|
224
|
+
const styles = useStyles();
|
|
225
|
+
return /* @__PURE__ */ jsx12("span", {
|
|
226
|
+
className: cn12(styles.striked),
|
|
227
|
+
children: props.children
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// src/components/Elements/Table.tsx
|
|
232
|
+
import { cn as cn13 } from "@d1vij/shit-i-always-use";
|
|
233
|
+
import {
|
|
234
|
+
useClipboardText as useClipboardText2
|
|
235
|
+
} from "@d1vij/shit-i-always-use/react";
|
|
236
|
+
import { useCallback, useEffect as useEffect2, useRef as useRef2, useState as useState3 } from "react";
|
|
237
|
+
import { jsx as jsx13, jsxs } from "react/jsx-runtime";
|
|
238
|
+
function TableActionButton({
|
|
239
|
+
label,
|
|
240
|
+
onClick,
|
|
241
|
+
setOpen
|
|
242
|
+
}) {
|
|
243
|
+
const styles = useStyles();
|
|
244
|
+
function handleClick(e) {
|
|
245
|
+
setOpen(false);
|
|
246
|
+
onClick(e);
|
|
247
|
+
}
|
|
248
|
+
return /* @__PURE__ */ jsx13("button", {
|
|
249
|
+
onClick: handleClick,
|
|
250
|
+
className: cn13(styles.table_action_button),
|
|
251
|
+
type: "button",
|
|
252
|
+
children: label
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
function getTableAsJson(elm) {
|
|
256
|
+
const headings = [];
|
|
257
|
+
const theadElms = elm.querySelectorAll("thead > tr > th");
|
|
258
|
+
theadElms.forEach((th) => {
|
|
259
|
+
headings.push(th.innerText.trim());
|
|
260
|
+
});
|
|
261
|
+
const rows = [];
|
|
262
|
+
const rowElms = elm.querySelectorAll("tbody > tr");
|
|
263
|
+
rowElms.forEach((tr) => {
|
|
264
|
+
const row = [];
|
|
265
|
+
tr.querySelectorAll("td").forEach((td, idx) => {
|
|
266
|
+
row.push({
|
|
267
|
+
column: headings[idx] ?? idx.toString(),
|
|
268
|
+
content: td.innerText.trim()
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
rows.push(row);
|
|
272
|
+
});
|
|
273
|
+
return {
|
|
274
|
+
meta: {
|
|
275
|
+
columns: headings.length,
|
|
276
|
+
rows: rowElms.length
|
|
277
|
+
},
|
|
278
|
+
headings,
|
|
279
|
+
rows
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function getTableJsonAsCsv(json) {
|
|
283
|
+
const heading = json.headings.join(",");
|
|
284
|
+
const rows = json.rows.map((row) => row.map((cell) => cell.content).join(",")).join(`
|
|
285
|
+
`);
|
|
286
|
+
return [heading, rows].join(`
|
|
287
|
+
`);
|
|
288
|
+
}
|
|
289
|
+
function getTableJsonAsHtml(json) {
|
|
290
|
+
const heading = json.headings.map((h) => `<th>${h}</th>`).join("");
|
|
291
|
+
const rows = json.rows.map((row) => {
|
|
292
|
+
const cells = row.map((c) => `<td>${c.content}</td>`).join("");
|
|
293
|
+
return `<tr>${cells}</tr>`;
|
|
294
|
+
});
|
|
295
|
+
return [
|
|
296
|
+
"<table>",
|
|
297
|
+
"<thead>",
|
|
298
|
+
`<tr>${heading}</tr>`,
|
|
299
|
+
"</thead>",
|
|
300
|
+
"<tbody>",
|
|
301
|
+
...rows,
|
|
302
|
+
"</tbody>",
|
|
303
|
+
"</table>"
|
|
304
|
+
].join(`
|
|
305
|
+
`);
|
|
306
|
+
}
|
|
307
|
+
function getTableJsonAsMarkdown(json) {
|
|
308
|
+
const heading = `|${json.headings.join("|")}|`;
|
|
309
|
+
const separator = `|${json.headings.map(() => "-----").join("|")}|`;
|
|
310
|
+
const rows = json.rows.map((row) => `|${row.map((cell) => cell.content).join("|")}|`);
|
|
311
|
+
return [heading, separator, ...rows].join(`
|
|
312
|
+
`);
|
|
313
|
+
}
|
|
314
|
+
function Table(props) {
|
|
315
|
+
const styles = useStyles();
|
|
316
|
+
const ref = useRef2(null);
|
|
317
|
+
const detailsRef = useRef2(null);
|
|
318
|
+
const [open, setOpen] = useState3(false);
|
|
319
|
+
const { copy } = useClipboardText2();
|
|
320
|
+
useEffect2(() => {
|
|
321
|
+
const elm = detailsRef.current;
|
|
322
|
+
if (!elm)
|
|
323
|
+
return;
|
|
324
|
+
function handleMouseLeave() {
|
|
325
|
+
setOpen(false);
|
|
326
|
+
}
|
|
327
|
+
function handleMouseEnter() {
|
|
328
|
+
setOpen(true);
|
|
329
|
+
}
|
|
330
|
+
elm.addEventListener("mouseenter", handleMouseEnter);
|
|
331
|
+
elm.addEventListener("mouseleave", handleMouseLeave);
|
|
332
|
+
return () => {
|
|
333
|
+
elm.removeEventListener("mouseenter", handleMouseEnter);
|
|
334
|
+
elm.removeEventListener("mouseleave", handleMouseLeave);
|
|
335
|
+
};
|
|
336
|
+
}, []);
|
|
337
|
+
const copyAs = useCallback((format) => {
|
|
338
|
+
return async () => {
|
|
339
|
+
const elm = ref.current;
|
|
340
|
+
if (!elm)
|
|
341
|
+
return;
|
|
342
|
+
const json = getTableAsJson(elm);
|
|
343
|
+
let extractedText;
|
|
344
|
+
switch (format) {
|
|
345
|
+
case "html":
|
|
346
|
+
extractedText = getTableJsonAsHtml(json);
|
|
347
|
+
break;
|
|
348
|
+
case "csv":
|
|
349
|
+
extractedText = getTableJsonAsCsv(json);
|
|
350
|
+
break;
|
|
351
|
+
case "markdown":
|
|
352
|
+
extractedText = getTableJsonAsMarkdown(json);
|
|
353
|
+
break;
|
|
354
|
+
case "json":
|
|
355
|
+
extractedText = JSON.stringify(json, null, 4);
|
|
356
|
+
break;
|
|
357
|
+
default:
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
await copy(extractedText);
|
|
361
|
+
};
|
|
362
|
+
}, [copy]);
|
|
363
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
364
|
+
className: cn13(styles.table_container),
|
|
365
|
+
children: [
|
|
366
|
+
/* @__PURE__ */ jsx13("table", {
|
|
367
|
+
ref,
|
|
368
|
+
className: cn13(styles.table),
|
|
369
|
+
children: props.children
|
|
370
|
+
}),
|
|
371
|
+
/* @__PURE__ */ jsxs("details", {
|
|
372
|
+
ref: detailsRef,
|
|
373
|
+
className: cn13(styles.table_action_buttons_details),
|
|
374
|
+
open,
|
|
375
|
+
children: [
|
|
376
|
+
/* @__PURE__ */ jsx13("summary", {
|
|
377
|
+
className: cn13(styles.table_action_buttons_summary),
|
|
378
|
+
children: "Copy"
|
|
379
|
+
}),
|
|
380
|
+
/* @__PURE__ */ jsx13(TableActionButton, {
|
|
381
|
+
setOpen,
|
|
382
|
+
label: "HTML",
|
|
383
|
+
onClick: copyAs("html")
|
|
384
|
+
}),
|
|
385
|
+
/* @__PURE__ */ jsx13(TableActionButton, {
|
|
386
|
+
setOpen,
|
|
387
|
+
label: "CSV",
|
|
388
|
+
onClick: copyAs("csv")
|
|
389
|
+
}),
|
|
390
|
+
/* @__PURE__ */ jsx13(TableActionButton, {
|
|
391
|
+
setOpen,
|
|
392
|
+
label: "Json",
|
|
393
|
+
onClick: copyAs("json")
|
|
394
|
+
}),
|
|
395
|
+
/* @__PURE__ */ jsx13(TableActionButton, {
|
|
396
|
+
setOpen,
|
|
397
|
+
label: "Markdown",
|
|
398
|
+
onClick: copyAs("markdown")
|
|
399
|
+
})
|
|
400
|
+
]
|
|
401
|
+
})
|
|
402
|
+
]
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
function TableHead(props) {
|
|
406
|
+
const styles = useStyles();
|
|
407
|
+
return /* @__PURE__ */ jsx13("thead", {
|
|
408
|
+
className: cn13(styles.table_head),
|
|
409
|
+
children: props.children
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
function TableBody(props) {
|
|
413
|
+
const styles = useStyles();
|
|
414
|
+
return /* @__PURE__ */ jsx13("tbody", {
|
|
415
|
+
className: cn13(styles.table_body),
|
|
416
|
+
children: props.children
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
function TableRow(props) {
|
|
420
|
+
const styles = useStyles();
|
|
421
|
+
return /* @__PURE__ */ jsx13("tr", {
|
|
422
|
+
className: cn13(styles.table_row),
|
|
423
|
+
children: props.children
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
function TableHeadCell(props) {
|
|
427
|
+
const styles = useStyles();
|
|
428
|
+
return /* @__PURE__ */ jsx13("th", {
|
|
429
|
+
className: cn13(styles.table_head_cell),
|
|
430
|
+
children: props.children
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
function TableData(props) {
|
|
434
|
+
const styles = useStyles();
|
|
435
|
+
return /* @__PURE__ */ jsx13("td", {
|
|
436
|
+
className: cn13(styles.table_data),
|
|
437
|
+
children: props.children
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// src/components/Elements/Elements.tsx
|
|
442
|
+
var BaseElementTags = [
|
|
443
|
+
"h1",
|
|
444
|
+
"h2",
|
|
445
|
+
"h3",
|
|
446
|
+
"h4",
|
|
447
|
+
"h5",
|
|
448
|
+
"h6",
|
|
449
|
+
"a",
|
|
450
|
+
"em",
|
|
451
|
+
"del",
|
|
452
|
+
"strong",
|
|
453
|
+
"code",
|
|
454
|
+
"blockquote",
|
|
455
|
+
"pre",
|
|
456
|
+
"p",
|
|
457
|
+
"hr",
|
|
458
|
+
"ol",
|
|
459
|
+
"ul",
|
|
460
|
+
"li",
|
|
461
|
+
"img",
|
|
462
|
+
"table",
|
|
463
|
+
"thead",
|
|
464
|
+
"tbody",
|
|
465
|
+
"th",
|
|
466
|
+
"tr",
|
|
467
|
+
"td"
|
|
468
|
+
];
|
|
469
|
+
var BaseElements = {
|
|
470
|
+
h1: (props) => Header({ ...props, level: 1 }),
|
|
471
|
+
h2: (props) => Header({ ...props, level: 2 }),
|
|
472
|
+
h3: (props) => Header({ ...props, level: 3 }),
|
|
473
|
+
h4: (props) => Header({ ...props, level: 4 }),
|
|
474
|
+
h5: (props) => Header({ ...props, level: 5 }),
|
|
475
|
+
h6: (props) => Header({ ...props, level: 6 }),
|
|
476
|
+
a: Anchor,
|
|
477
|
+
em: Italics,
|
|
478
|
+
del: Striked,
|
|
479
|
+
strong: Bold,
|
|
480
|
+
code: Code,
|
|
481
|
+
blockquote: BlockQuote,
|
|
482
|
+
pre: Preformatted,
|
|
483
|
+
p: Paragraph,
|
|
484
|
+
hr: HorizontalLine,
|
|
485
|
+
ol: (props) => List({ ...props, type: "ordered" }),
|
|
486
|
+
ul: (props) => List({ ...props, type: "unordered" }),
|
|
487
|
+
li: ListItem,
|
|
488
|
+
img: Image,
|
|
489
|
+
table: Table,
|
|
490
|
+
thead: TableHead,
|
|
491
|
+
tbody: TableBody,
|
|
492
|
+
th: TableHeadCell,
|
|
493
|
+
tr: TableRow,
|
|
494
|
+
td: TableData
|
|
495
|
+
};
|
|
496
|
+
// src/components/Loader.tsx
|
|
497
|
+
import { Suspense } from "react";
|
|
498
|
+
|
|
499
|
+
// src/lib/generateElements.ts
|
|
500
|
+
function generateElementsFrom(elements, baseElements = true) {
|
|
501
|
+
if (baseElements) {
|
|
502
|
+
return { ...BaseElements, ...elements };
|
|
503
|
+
} else
|
|
504
|
+
return { ...elements };
|
|
505
|
+
}
|
|
506
|
+
// src/lib/Registry.ts
|
|
507
|
+
import { lazy } from "react";
|
|
508
|
+
function generateRegistry({
|
|
509
|
+
modulesGlob,
|
|
510
|
+
metadataGlob,
|
|
511
|
+
root,
|
|
512
|
+
virtual,
|
|
513
|
+
meta_extension = ".meta.ts"
|
|
514
|
+
}) {
|
|
515
|
+
const paths = Object.keys(modulesGlob);
|
|
516
|
+
const keys = [];
|
|
517
|
+
const _components = [];
|
|
518
|
+
const _exports = [];
|
|
519
|
+
const _metadata = [];
|
|
520
|
+
const _virtual = virtual === "/" || virtual === "" ? "" : virtual;
|
|
521
|
+
for (const path of paths) {
|
|
522
|
+
const route = path.replace(`${root}/`, _virtual).replace(".mdx", "");
|
|
523
|
+
const loader = modulesGlob[path];
|
|
524
|
+
keys.push(route);
|
|
525
|
+
_components.push([route, lazy(() => loader())]);
|
|
526
|
+
_exports.push([route, loader]);
|
|
527
|
+
const metaLoader = metadataGlob[path.replace(".mdx", meta_extension)];
|
|
528
|
+
_metadata.push([route, { __splat: route, ...metaLoader }]);
|
|
529
|
+
}
|
|
530
|
+
return {
|
|
531
|
+
keys,
|
|
532
|
+
components: Object.fromEntries(_components),
|
|
533
|
+
exports: Object.fromEntries(_exports),
|
|
534
|
+
metadata: Object.fromEntries(_metadata)
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
class AbstractRegistry {
|
|
539
|
+
diffKeys() {
|
|
540
|
+
const keySet = new Set(this.keys);
|
|
541
|
+
const exportsSet = new Set(Object.keys(this.exports));
|
|
542
|
+
const metadataSet = new Set(Object.keys(this.metadata));
|
|
543
|
+
const exportsDiff = keySet.symmetricDifference(exportsSet);
|
|
544
|
+
const metadataDiff = keySet.symmetricDifference(metadataSet);
|
|
545
|
+
const errMsg = [];
|
|
546
|
+
const diffs = {
|
|
547
|
+
inComponentsButNotInExports: undefined,
|
|
548
|
+
inComponentsButNotInMetadata: undefined,
|
|
549
|
+
inExportsButNotInComponents: undefined,
|
|
550
|
+
inMetadataButNotInComponents: undefined
|
|
551
|
+
};
|
|
552
|
+
if (exportsDiff.size !== 0) {
|
|
553
|
+
diffs.inComponentsButNotInExports = Array.from(keySet.difference(exportsSet));
|
|
554
|
+
diffs.inExportsButNotInComponents = Array.from(exportsSet.difference(keySet));
|
|
555
|
+
errMsg.push(`Exports Registry and Component Registry have ${exportsDiff.size} key mismatches.
|
|
6
556
|
Keys which are present in Component map but not in Exports
|
|
7
|
-
${
|
|
557
|
+
${diffs.inComponentsButNotInExports.join(`
|
|
8
558
|
`)}
|
|
9
559
|
and the keys present in Exports but not in component map are
|
|
10
|
-
${
|
|
560
|
+
${diffs.inExportsButNotInComponents.join(`
|
|
11
561
|
`)}
|
|
12
|
-
`);
|
|
562
|
+
`);
|
|
563
|
+
}
|
|
564
|
+
if (metadataDiff.size !== 0) {
|
|
565
|
+
diffs.inComponentsButNotInMetadata = Array.from(keySet.difference(metadataSet));
|
|
566
|
+
diffs.inMetadataButNotInComponents = Array.from(metadataDiff.difference(keySet));
|
|
567
|
+
errMsg.push(`Metadata Registry and Component Registry have ${metadataDiff.size} key mismatches.
|
|
13
568
|
Keys which are present in Component map but not in Metadata
|
|
14
|
-
${
|
|
569
|
+
${diffs.inComponentsButNotInMetadata.join(`
|
|
15
570
|
`)}
|
|
16
571
|
and the keys present in Metadata but not in Component map are
|
|
17
|
-
${
|
|
572
|
+
${diffs.inMetadataButNotInComponents.join(`
|
|
18
573
|
`)}
|
|
19
|
-
`);
|
|
574
|
+
`);
|
|
575
|
+
}
|
|
576
|
+
if (errMsg.length === 0)
|
|
577
|
+
return null;
|
|
578
|
+
return {
|
|
579
|
+
diffs,
|
|
580
|
+
error: new Error(errMsg.join(`
|
|
581
|
+
|
|
582
|
+
`))
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
get(_from, key) {
|
|
586
|
+
const value = _from[key];
|
|
587
|
+
if (!value) {
|
|
588
|
+
throw new Error(`Invalid key passed ${key.toString()} to access whatever the fuck we were extractign`);
|
|
589
|
+
}
|
|
590
|
+
return value;
|
|
591
|
+
}
|
|
592
|
+
getComponent(key) {
|
|
593
|
+
return this.get(this.components, key);
|
|
594
|
+
}
|
|
595
|
+
getExport(key) {
|
|
596
|
+
return this.exports[key]();
|
|
597
|
+
}
|
|
598
|
+
getMetadata(key) {
|
|
599
|
+
return this.get(this.metadata, key);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
class Registry extends AbstractRegistry {
|
|
604
|
+
keys;
|
|
605
|
+
components;
|
|
606
|
+
exports;
|
|
607
|
+
metadata;
|
|
608
|
+
constructor(opts) {
|
|
609
|
+
super();
|
|
610
|
+
const result = generateRegistry(opts);
|
|
611
|
+
this.keys = result.keys;
|
|
612
|
+
this.components = result.components;
|
|
613
|
+
this.exports = result.exports;
|
|
614
|
+
this.metadata = result.metadata;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
20
617
|
|
|
21
|
-
|
|
618
|
+
class CoalescedRegistry extends AbstractRegistry {
|
|
619
|
+
keys = [];
|
|
620
|
+
components = {};
|
|
621
|
+
exports = {};
|
|
622
|
+
metadata = {};
|
|
623
|
+
constructor(...registries) {
|
|
624
|
+
super();
|
|
625
|
+
for (const registry of registries) {
|
|
626
|
+
this.keys.push(...registry.keys);
|
|
627
|
+
Object.assign(this.components, registry.components);
|
|
628
|
+
Object.assign(this.exports, registry.exports);
|
|
629
|
+
Object.assign(this.metadata, registry.metadata);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
// src/components/Loader.tsx
|
|
634
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
635
|
+
function MDXFromComponent({
|
|
636
|
+
source: SourceComponent,
|
|
637
|
+
styles,
|
|
638
|
+
fallback,
|
|
639
|
+
elements = BaseElements
|
|
640
|
+
}) {
|
|
641
|
+
return /* @__PURE__ */ jsx14(StyleContext, {
|
|
642
|
+
value: styles,
|
|
643
|
+
children: /* @__PURE__ */ jsx14(Suspense, {
|
|
644
|
+
fallback,
|
|
645
|
+
children: /* @__PURE__ */ jsx14(SourceComponent, {
|
|
646
|
+
components: elements
|
|
647
|
+
})
|
|
648
|
+
})
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
export {
|
|
652
|
+
useStyles,
|
|
653
|
+
generateRegistry,
|
|
654
|
+
generateElementsFrom,
|
|
655
|
+
StyleContext,
|
|
656
|
+
StyleClassesList,
|
|
657
|
+
Registry,
|
|
658
|
+
MDXFromComponent,
|
|
659
|
+
CoalescedRegistry,
|
|
660
|
+
BaseElements,
|
|
661
|
+
BaseElementTags
|
|
662
|
+
};
|
package/dist/vitePlugin.js
CHANGED
|
@@ -1 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
// src/vitePlugin.ts
|
|
2
|
+
import mdx from "@mdx-js/rollup";
|
|
3
|
+
import remarkGFM from "remark-gfm";
|
|
4
|
+
function MDXLoaderPlugin(opts) {
|
|
5
|
+
return mdx({
|
|
6
|
+
...opts,
|
|
7
|
+
remarkPlugins: [remarkGFM]
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
var vitePlugin_default = MDXLoaderPlugin;
|
|
11
|
+
export {
|
|
12
|
+
vitePlugin_default as default,
|
|
13
|
+
MDXLoaderPlugin
|
|
14
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d1vij/jassm",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.26",
|
|
4
4
|
"description": "Just another static site maker. Create simple content driven sites using MDX and React along with Typescript safety.",
|
|
5
5
|
"homepage": "https://github.com/d1vij/jassm",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,22 +43,23 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@biomejs/biome": "^2.4.
|
|
47
|
-
"@types/bun": "^1.3.
|
|
46
|
+
"@biomejs/biome": "^2.4.14",
|
|
47
|
+
"@types/bun": "^1.3.13",
|
|
48
48
|
"@types/mdx": "^2.0.13",
|
|
49
49
|
"@types/react": "^19.2.14",
|
|
50
50
|
"@types/react-dom": "^19.2.3",
|
|
51
|
-
"bumpp": "^
|
|
52
|
-
"bunup": "^0.16.
|
|
51
|
+
"bumpp": "^11.0.1",
|
|
52
|
+
"bunup": "^0.16.31",
|
|
53
53
|
"simple-git-hooks": "^2.13.1",
|
|
54
|
-
"typescript": "^
|
|
54
|
+
"typescript": "^6.0.3",
|
|
55
|
+
"vite": "^8.0.10"
|
|
55
56
|
},
|
|
56
57
|
"peerDependencies": {
|
|
57
58
|
"@mdx-js/rollup": "^3.1.1",
|
|
58
|
-
"react": "^19.2.
|
|
59
|
-
"react-dom": "^19.2.
|
|
59
|
+
"react": "^19.2.5",
|
|
60
|
+
"react-dom": "^19.2.5",
|
|
60
61
|
"remark-gfm": "^4.0.1",
|
|
61
|
-
"@d1vij/shit-i-always-use": "^0.1.
|
|
62
|
+
"@d1vij/shit-i-always-use": "^0.1.24"
|
|
62
63
|
},
|
|
63
64
|
"peerDependenciesMeta": {
|
|
64
65
|
"typescript": {
|