@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 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
- import{cn as Z}from"@d1vij/shit-i-always-use";import{useMemo as R,useState as G}from"react";import{createContext as W,useContext as Y}from"react";var $o=["header","header_button","header_1","header_2","header_3","header_4","header_5","header_6","header_icon","anchor","button","bold","italic","span","striked","paragraph","code","preformatted","blockquote","horizontal_line","image","list","unordered_list","ordered_list","list_item","table","table_head","table_head_cell","table_body","table_row","table_data","table_container","table_action_buttons_details","table_action_buttons_summary","table_action_button","table_action_button_html","table_action_button_csv","table_action_button_json","table_action_button_markdown"],J=W(null);function e(){let o=Y(J);if(o===null)throw 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");return o}import{jsx as x}from"react/jsx-runtime";function A(o){let t=R(()=>new URL(window.location.href).origin.toString(),[]),r=e(),[n]=G(()=>{if(o.href?.match(/^#.*/))return"_self";return new URL(o.href??"").origin.toString()===t?"_self":"_blank"});return x("a",{className:Z(r.anchor),target:n,href:o.href,children:o.children})}import{cn as j}from"@d1vij/shit-i-always-use";import{jsx as oo}from"react/jsx-runtime";function E(o){let t=e();return oo("blockquote",{className:j(t.blockquote),children:o.children})}import{cn as to}from"@d1vij/shit-i-always-use";import{jsx as eo}from"react/jsx-runtime";function H(o){let t=e();return eo("span",{className:to(t.bold),children:o.children})}import{cn as ro}from"@d1vij/shit-i-always-use";import{jsx as no}from"react/jsx-runtime";function P(o){let t=e(),r=/language-(\w+)/.exec(o.className||"")?.[1];return no("code",{className:ro(t.code,r&&`language-${r}`),children:o.children})}import{cn as _,useClipboardText as lo}from"@d1vij/shit-i-always-use";import{useEffect as so,useRef as mo,useState as co}from"react";import{jsx as v}from"react/jsx-runtime";function h(o){let t=e(),r=mo(null),[n,s]=co(""),{copy:l}=lo();async function m(){let a=new URL(`/#${n}`,window.location.origin).toString();await l(a)}return so(()=>{if(!r.current)return;let c=(r.current.textContent??"").toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").slice(0,30);s(c)},[]),v("h1",{className:_(t.header,t[`header_${o.level}`]),children:v("button",{onClick:()=>void m(),ref:r,id:n,className:_(t.header_button),type:"button",children:o.children})})}import{cn as ao}from"@d1vij/shit-i-always-use";import{jsx as po}from"react/jsx-runtime";function S(o){let t=e();return po("hr",{className:ao(t.horizontal_line)})}import{cn as io}from"@d1vij/shit-i-always-use";import{jsx as uo}from"react/jsx-runtime";function X(o){let t=e();return uo("img",{className:io(t.image),alt:o.alt,title:o.title,src:o.src})}import{cn as fo}from"@d1vij/shit-i-always-use";import{jsx as ho}from"react/jsx-runtime";function B(o){let t=e();return ho("span",{className:fo(t.italic),children:o.children})}import{cn as O}from"@d1vij/shit-i-always-use";import{jsx as C}from"react/jsx-runtime";function b(o){let t=e(),r=o.type==="ordered"?"ol":"ul";return C(r,{className:O(t.list,o.type==="ordered"&&t.ordered_list,o.type==="unordered"&&t.unordered_list),children:o.children})}function q(o){let t=e();return C("li",{className:O(t.list_item),children:o.children})}import{cn as bo}from"@d1vij/shit-i-always-use";import{jsx as yo}from"react/jsx-runtime";function M(o){let t=e();return yo("p",{className:bo(t.paragraph),children:o.children})}import{cn as To}from"@d1vij/shit-i-always-use";import{jsx as Jo}from"react/jsx-runtime";function g(o){let t=e();return Jo("pre",{className:To(t.preformatted),children:o.children})}import{cn as Eo}from"@d1vij/shit-i-always-use";import{jsx as Po}from"react/jsx-runtime";function $(o){let t=e();return Po("span",{className:Eo(t.striked),children:o.children})}import{cn as u,useClipboardText as So}from"@d1vij/shit-i-always-use";import{useCallback as Xo,useEffect as go,useRef as k,useState as wo}from"react";import{jsx as p,jsxs as I}from"react/jsx-runtime";function y({label:o,onClick:t,setOpen:r}){let n=e();function s(l){r(!1),t(l)}return p("button",{onClick:s,className:u(n.table_action_button),type:"button",children:o})}function Lo(o){let t=[];o.querySelectorAll("thead > tr > th").forEach((l)=>{t.push(l.innerText.trim())});let n=[],s=o.querySelectorAll("tbody > tr");return s.forEach((l)=>{let m=[];l.querySelectorAll("td").forEach((a,c)=>{m.push({column:t[c]??c.toString(),content:a.innerText.trim()})}),n.push(m)}),{meta:{columns:t.length,rows:s.length},headings:t,rows:n}}function No(o){let t=o.headings.join(","),r=o.rows.map((n)=>n.map((s)=>s.content).join(",")).join(`
2
- `);return[t,r].join(`
3
- `)}function Ao(o){let t=o.headings.map((n)=>`<th>${n}</th>`).join(""),r=o.rows.map((n)=>{return`<tr>${n.map((l)=>`<td>${l.content}</td>`).join("")}</tr>`});return["<table>","<thead>",`<tr>${t}</tr>`,"</thead>","<tbody>",...r,"</tbody>","</table>"].join(`
4
- `)}function Ho(o){let t=`|${o.headings.join("|")}|`,r=`|${o.headings.map(()=>"-----").join("|")}|`,n=o.rows.map((s)=>`|${s.map((l)=>l.content).join("|")}|`);return[t,r,...n].join(`
5
- `)}function z(o){let t=e(),r=k(null),n=k(null),[s,l]=wo(!1),{copy:m}=So();go(()=>{let c=n.current;if(!c)return;function f(){l(!1)}function i(){l(!0)}return c.addEventListener("mouseenter",i),c.addEventListener("mouseleave",f),()=>{c.removeEventListener("mouseenter",i),c.removeEventListener("mouseleave",f)}},[]);let a=Xo((c)=>{return async()=>{let f=r.current;if(!f)return;let i=Lo(f),d;switch(c){case"html":d=Ao(i);break;case"csv":d=No(i);break;case"markdown":d=Ho(i);break;case"json":d=JSON.stringify(i,null,4);break;default:return}await m(d)}},[m]);return I("div",{className:u(t.table_container),children:[p("table",{ref:r,className:u(t.table),children:o.children}),I("details",{ref:n,className:u(t.table_action_buttons_details),open:s,children:[p("summary",{className:u(t.table_action_buttons_summary),children:"Copy"}),p(y,{setOpen:l,label:"HTML",onClick:a("html")}),p(y,{setOpen:l,label:"CSV",onClick:a("csv")}),p(y,{setOpen:l,label:"Json",onClick:a("json")}),p(y,{setOpen:l,label:"Markdown",onClick:a("markdown")})]})]})}function Q(o){let t=e();return p("thead",{className:u(t.table_head),children:o.children})}function D(o){let t=e();return p("tbody",{className:u(t.table_body),children:o.children})}function U(o){let t=e();return p("tr",{className:u(t.table_row),children:o.children})}function V(o){let t=e();return p("th",{className:u(t.table_head_cell),children:o.children})}function F(o){let t=e();return p("td",{className:u(t.table_data),children:o.children})}var jt=["h1","h2","h3","h4","h5","h6","a","em","del","strong","code","blockquote","pre","p","hr","ol","ul","li","img","table","thead","tbody","th","tr","td"],T={h1:(o)=>h({...o,level:1}),h2:(o)=>h({...o,level:2}),h3:(o)=>h({...o,level:3}),h4:(o)=>h({...o,level:4}),h5:(o)=>h({...o,level:5}),h6:(o)=>h({...o,level:6}),a:A,em:B,del:$,strong:H,code:P,blockquote:E,pre:g,p:M,hr:S,ol:(o)=>b({...o,type:"ordered"}),ul:(o)=>b({...o,type:"unordered"}),li:q,img:X,table:z,thead:Q,tbody:D,th:V,tr:U,td:F};import{Suspense as qo}from"react";function ne(o,t=!0){if(t)return{...T,...o};else return{...o}}import{lazy as _o}from"react";function vo({modulesGlob:o,metadataGlob:t,root:r,virtual:n}){let s=Object.keys(o),l=[],m=[],a=[],c=[],f=n==="/"||n===""?"":n;for(let i of s){let d=i.replace(`${r}/`,f).replace(".mdx",""),N=o[i];l.push(d),m.push([d,_o(()=>N())]),a.push([d,N]);let K=t[i.replace(".mdx",".meta.ts")];c.push([d,{__splat:d,...K}])}return{keys:l,components:Object.fromEntries(m),exports:Object.fromEntries(a),metadata:Object.fromEntries(c)}}class w{diffKeys(){let o=new Set(this.keys),t=new Set(Object.keys(this.exports)),r=new Set(Object.keys(this.metadata)),n=o.symmetricDifference(t),s=o.symmetricDifference(r),l=[],m={inComponentsButNotInExports:void 0,inComponentsButNotInMetadata:void 0,inExportsButNotInComponents:void 0,inMetadataButNotInComponents:void 0};if(n.size!==0)m.inComponentsButNotInExports=Array.from(o.difference(t)),m.inExportsButNotInComponents=Array.from(t.difference(o)),l.push(`Exports Registry and Component Registry have ${n.size} key mismatches.
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
- ${m.inComponentsButNotInExports.join(`
557
+ ${diffs.inComponentsButNotInExports.join(`
8
558
  `)}
9
559
  and the keys present in Exports but not in component map are
10
- ${m.inExportsButNotInComponents.join(`
560
+ ${diffs.inExportsButNotInComponents.join(`
11
561
  `)}
12
- `);if(s.size!==0)m.inComponentsButNotInMetadata=Array.from(o.difference(r)),m.inMetadataButNotInComponents=Array.from(s.difference(o)),l.push(`Metadata Registry and Component Registry have ${s.size} key mismatches.
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
- ${m.inComponentsButNotInMetadata.join(`
569
+ ${diffs.inComponentsButNotInMetadata.join(`
15
570
  `)}
16
571
  and the keys present in Metadata but not in Component map are
17
- ${m.inMetadataButNotInComponents.join(`
572
+ ${diffs.inMetadataButNotInComponents.join(`
18
573
  `)}
19
- `);if(l.length===0)return null;return{diffs:m,error:Error(l.join(`
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
- `))}}get(o,t){let r=o[t];if(!r)throw Error(`Invalid key passed ${t.toString()} to access whatever the fuck we were extractign`);return r}getComponent(o){return this.get(this.components,o)}getExport(o){return this.exports[o]()}getMetadata(o){return this.get(this.metadata,o)}}class Bo extends w{keys;components;exports;metadata;constructor(o){super();let t=vo(o);this.keys=t.keys,this.components=t.components,this.exports=t.exports,this.metadata=t.metadata}}class Oo extends w{keys=[];components={};exports={};metadata={};constructor(...o){super();for(let t of o)this.keys.push(...t.keys),Object.assign(this.components,t.components),Object.assign(this.exports,t.exports),Object.assign(this.metadata,t.metadata)}}import{jsx as L}from"react/jsx-runtime";function Co({source:o,styles:t,fallback:r,elements:n=T}){return L(J,{value:t,children:L(qo,{fallback:r,children:L(o,{components:n})})})}export{e as useStyles,vo as generateRegistry,ne as generateElementsFrom,J as StyleContext,$o as StyleClassesList,Bo as Registry,Co as MDXFromComponent,Oo as CoalescedRegistry,T as BaseElements,jt as BaseElementTags};
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
+ };
@@ -1 +1,14 @@
1
- import q from"@mdx-js/rollup";import z from"remark-gfm";function A(b){return q({...b,remarkPlugins:[z]})}var H=A;export{H as default,A as MDXLoaderPlugin};
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.23",
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.6",
47
- "@types/bun": "^1.3.9",
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": "^10.4.1",
52
- "bunup": "^0.16.29",
51
+ "bumpp": "^11.0.1",
52
+ "bunup": "^0.16.31",
53
53
  "simple-git-hooks": "^2.13.1",
54
- "typescript": "^5.9.3"
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.4",
59
- "react-dom": "^19.2.4",
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.9"
62
+ "@d1vij/shit-i-always-use": "^0.1.24"
62
63
  },
63
64
  "peerDependenciesMeta": {
64
65
  "typescript": {