@sit-onyx/mdc 0.3.0 → 0.3.2-dev-20261123100908

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,4 +12,4 @@ Wrapper for the [@nuxtjs/mdc](https://github.com/nuxt-content/mdc) package using
12
12
 
13
13
  ## Documentation
14
14
 
15
- You can find our documentation [here](https://storybook.onyx.schwarz/?path=/docs/documentation-markdownrenderer--docs).
15
+ You can find our documentation [here](https://onyx.schwarz/components/docs/markdown).
@@ -1,15 +1,12 @@
1
- import { c as e, d as t, l as n, m as r, n as i, o as a, p as o } from "./node-Oi5de8aj.js";
2
- import { Comment as s, Text as c, computed as l, defineAsyncComponent as u, defineComponent as d, getCurrentInstance as f, h as p, reactive as m, resolveComponent as h, toRaw as g, watch as _ } from "vue";
3
- //#region ../../node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs
4
- var v = /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/, y = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/, b = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
5
- function x(e, t) {
6
- if (e === "__proto__" || e === "constructor" && t && typeof t == "object" && "prototype" in t) {
7
- S(e);
8
- return;
9
- }
10
- return t;
1
+ import { c as e, d as t, g as n, h as r, i, n as a, p as o, t as s, u as c } from "./props-D9WqZr0-.js";
2
+ import { Comment as l, Text as u, computed as d, defineAsyncComponent as f, defineComponent as p, getCurrentInstance as m, h, reactive as g, resolveComponent as _, toRaw as v, watch as y } from "vue";
3
+ // ../../node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs
4
+ var b = /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/, x = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/, ee = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
5
+ function S(e, t) {
6
+ if (e === "__proto__" || e === "constructor" && t && typeof t == "object" && "prototype" in t) te(e);
7
+ else return t;
11
8
  }
12
- function S(e) {
9
+ function te(e) {
13
10
  console.warn(`[destr] Dropping "${e}" key to prevent prototype pollution.`);
14
11
  }
15
12
  function C(e, t = {}) {
@@ -25,14 +22,14 @@ function C(e, t = {}) {
25
22
  case "infinity": return Infinity;
26
23
  case "-infinity": return -Infinity;
27
24
  }
28
- if (!b.test(e)) {
25
+ if (!ee.test(e)) {
29
26
  if (t.strict) throw SyntaxError("[destr] Invalid JSON");
30
27
  return e;
31
28
  }
32
29
  try {
33
- if (v.test(e) || y.test(e)) {
30
+ if (b.test(e) || x.test(e)) {
34
31
  if (t.strict) throw Error("[destr] Possible prototype pollution");
35
- return JSON.parse(e, x);
32
+ return JSON.parse(e, S);
36
33
  }
37
34
  return JSON.parse(e);
38
35
  } catch (n) {
@@ -40,8 +37,7 @@ function C(e, t = {}) {
40
37
  return e;
41
38
  }
42
39
  }
43
- //#endregion
44
- //#region ../../node_modules/.pnpm/@nuxtjs+mdc@0.22.1_magicast@0.5.3/node_modules/@nuxtjs/mdc/dist/runtime/utils/index.js
40
+ // ../../node_modules/.pnpm/@nuxtjs+mdc@0.23.4_@nuxt+schema@4.6.4_confbox@0.3.2_dotenv@17.4.2_giget@3.3.1_jiti@2.7._8aa46dd70d56c1a2fed2f05572323d85/node_modules/@nuxtjs/mdc/dist/runtime/utils/index.js
45
41
  function w(e, t) {
46
42
  return t.reduce((t, n) => {
47
43
  let r = T(e, n);
@@ -51,13 +47,22 @@ function w(e, t) {
51
47
  function T(e, t) {
52
48
  return t.split(".").reduce((e, t) => e && e[t], e);
53
49
  }
54
- //#endregion
55
- //#region ../../node_modules/.pnpm/@nuxtjs+mdc@0.22.1_magicast@0.5.3/node_modules/@nuxtjs/mdc/dist/runtime/components/MDCRenderer.vue
50
+ // ../../node_modules/.pnpm/@nuxtjs+mdc@0.23.4_@nuxt+schema@4.6.4_confbox@0.3.2_dotenv@17.4.2_giget@3.3.1_jiti@2.7._8aa46dd70d56c1a2fed2f05572323d85/node_modules/@nuxtjs/mdc/dist/runtime/components/MDCRenderer.vue
56
51
  var E = "default", D = /^@|^v-on:/, O = /^:|^v-bind:/, k = /^v-model/, A = [
57
52
  "select",
58
53
  "textarea",
59
54
  "input"
60
- ], j = /* @__PURE__ */ new Set(["math", "svg"]), M = /* @__PURE__ */ new Set(), N = Object.fromEntries((/* @__PURE__ */ "p.a.blockquote.code.pre.code.em.h1.h2.h3.h4.h5.h6.hr.img.ul.ol.li.strong.table.thead.tbody.td.th.tr.script".split(".")).map((e) => [e, `prose-${e}`])), P = ["script", "base"], F = d({
55
+ ], j = /* @__PURE__ */ new Set(["math", "svg"]), M = /* @__PURE__ */ new Set(), N = Object.fromEntries((/* @__PURE__ */ "p.a.blockquote.code.pre.code.em.h1.h2.h3.h4.h5.h6.hr.img.ul.ol.li.strong.table.thead.tbody.td.th.tr.script".split(".")).map((e) => [e, `prose-${e}`])), P = ["script", "base"], F = /* @__PURE__ */ new Set([
56
+ ...P,
57
+ "iframe",
58
+ "frame",
59
+ "frameset",
60
+ "embed",
61
+ "object",
62
+ "style",
63
+ "link",
64
+ "meta"
65
+ ]), I = /^[a-z][\w-]*$/i, L = p({
61
66
  name: "MDCRenderer",
62
67
  props: {
63
68
  body: {
@@ -90,30 +95,37 @@ var E = "default", D = /^@|^v-on:/, O = /^:|^v-bind:/, k = /^v-model/, A = [
90
95
  }
91
96
  },
92
97
  async setup(e) {
93
- let t = f()?.appContext?.app?.$nuxt, n = t?.$route || t?._route, { mdc: r } = t?.$config?.public || {}, i = r?.components?.customElements || r?.components?.custom;
98
+ let t = m()?.appContext?.app?.$nuxt, n = t?.$route || t?._route, { mdc: r } = t?.$config?.public || {}, i = r?.components?.customElements || r?.components?.custom;
94
99
  i && i.forEach((e) => M.add(e));
95
- let a = l(() => ({
100
+ let o = d(() => ({
96
101
  ...r?.components?.prose && e.prose !== !1 ? N : {},
97
102
  ...r?.components?.map || {},
98
- ...g(e.data?.mdc?.components || {}),
103
+ ...Object.fromEntries(Object.entries(v(e.data?.mdc?.components || {})).filter(([, e]) => typeof e == "string")),
99
104
  ...e.components
100
- })), o = l(() => {
101
- let t = (e.body?.children || []).map((e) => e.tag || e.type).filter((e) => !Q(e));
105
+ })), s = d(() => {
106
+ let t = (e.body?.children || []).map((e) => e.tag || e.type).filter((e) => !$(e));
102
107
  return Array.from(new Set(t)).sort().join(".");
103
- }), s = m({ ...e.data });
104
- _(() => e.data, (e) => {
105
- Object.assign(s, e);
106
- }), await X(e.body, { tags: a.value });
107
- function c(e, t) {
108
+ }), c = g({ ...e.data });
109
+ y(() => e.data, (e) => {
110
+ Object.assign(c, e);
111
+ }), await ne(e.body, { tags: o.value });
112
+ function l(e, t) {
108
113
  let n = e.split(".").length - 1;
109
- return e.split(".").reduce((e, r, i) => i == n && e ? (e[r] = t, e[r]) : typeof e == "object" ? e[r] : void 0, s);
114
+ return e.split(".").reduce((e, r, i) => i == n && e ? (e[r] = t, e[r]) : typeof e == "object" ? e[r] : void 0, c);
110
115
  }
111
116
  return {
112
- tags: a,
113
- contentKey: o,
117
+ tags: o,
118
+ contentKey: s,
114
119
  route: n,
115
- runtimeData: s,
116
- updateRuntimeData: c
120
+ runtimeData: c,
121
+ updateRuntimeData: l,
122
+ root: d(() => {
123
+ let t = e.data?.component, n = e.tag || t?.name || t || "div", r = t?.props;
124
+ return !e.tag && t && ((typeof n != "string" || !I.test(n) || F.has(n.toLowerCase())) && (n = "div"), r &&= a(n, r)), {
125
+ tag: n,
126
+ props: r
127
+ };
128
+ })
117
129
  };
118
130
  },
119
131
  render(e) {
@@ -125,47 +137,49 @@ var E = "default", D = /^@|^v-on:/, O = /^:|^v-bind:/, k = /^v-model/, A = [
125
137
  $route: s,
126
138
  runtimeData: l,
127
139
  updateRuntimeData: u
128
- }, f = n === !1 ? void 0 : W(n || d.component?.name || d.component || "div");
129
- return f ? p(f, {
130
- ...d.component?.props,
140
+ }, { tag: f, props: p } = e.root, m = n === !1 ? void 0 : K(f);
141
+ return m ? h(m, {
142
+ ...p,
131
143
  class: e.class,
132
144
  ...this.$attrs,
133
145
  key: o
134
- }, { default: m }) : m?.();
135
- function m() {
136
- let e = L(r, p, {
146
+ }, { default: g }) : g?.();
147
+ function g() {
148
+ let e = z(r, h, {
137
149
  documentMeta: d,
138
150
  parentScope: d,
139
- resolveComponent: W
151
+ resolveComponent: K
140
152
  });
141
153
  return e?.default ? c ? i(e.default(), typeof c == "string" ? c.split(" ") : ["*"]) : e.default() : null;
142
154
  }
143
155
  }
144
156
  });
145
- function I(e, t, n, i) {
146
- let { documentMeta: o, parentScope: l, resolveComponent: u } = n;
147
- if (e.type === "text") return t(c, e.value);
148
- if (e.type === "comment") return t(s, null, e.value);
149
- let d = e.tag, f = Z(e, o.tags);
150
- if (e.tag === "binding") return R(e, t, o, l);
151
- let p = J(f) ? (e) => e : u;
152
- if (P.includes(r(f).toLowerCase())) return t("pre", { class: "mdc-renderer-dangerous-tag" }, "<" + f + ">" + a(e) + "</" + f + ">");
157
+ function R(t, r, i, a) {
158
+ let { documentMeta: o, parentScope: s, resolveComponent: c } = i;
159
+ if (t.type === "text") return r(u, t.value);
160
+ if (t.type === "comment") return r(l, null, t.value);
161
+ let d = t.tag;
162
+ if (typeof d != "string") return r(l, null, "invalid tag");
163
+ let f = Q(t, o.tags);
164
+ if (t.tag === "binding") return B(t, r, o, s);
165
+ let p = X(f) ? (e) => e : c;
166
+ if (P.includes(n(f).toLowerCase())) return r("pre", { class: "mdc-renderer-dangerous-tag" }, "<" + f + ">" + e(t) + "</" + f + ">");
153
167
  let m = p(f);
154
168
  typeof m == "object" && (m.tag = d);
155
- let h = z(e, o);
156
- return i && (h.key = i), t(m, h, L(e, t, {
169
+ let h = V(t, o);
170
+ return a && (h.key = a), r(m, h, z(t, r, {
157
171
  documentMeta: o,
158
172
  parentScope: {
159
- ...l,
173
+ ...s,
160
174
  ...h
161
175
  },
162
176
  resolveComponent: p
163
177
  }));
164
178
  }
165
- function L(e, t, n) {
179
+ function z(e, t, n) {
166
180
  let { documentMeta: r, parentScope: a, resolveComponent: o } = n, s = (e.children || []).reduce((e, t) => {
167
- if (!q(t)) return e[E].children.push(t), e;
168
- let n = K(t);
181
+ if (!Y(t)) return e[E].children.push(t), e;
182
+ let n = J(t);
169
183
  return e[n] = e[n] || {
170
184
  props: {},
171
185
  children: []
@@ -175,7 +189,7 @@ function L(e, t, n) {
175
189
  children: []
176
190
  } });
177
191
  return Object.entries(s).reduce((e, [n, { props: s, children: c }]) => (c.length && (e[n] = (e = {}) => {
178
- let n = w(e, Object.keys(s || {})), l = c.map((e, i) => I(e, t, {
192
+ let n = w(e, Object.keys(s || {})), l = c.map((e, i) => R(e, t, {
179
193
  documentMeta: r,
180
194
  parentScope: {
181
195
  ...a,
@@ -183,10 +197,10 @@ function L(e, t, n) {
183
197
  },
184
198
  resolveComponent: o
185
199
  }, String(e.props?.key || i)));
186
- return s?.unwrap && (l = i(l, s.unwrap)), Y(l);
200
+ return s?.unwrap && (l = i(l, s.unwrap)), Z(l);
187
201
  }), e), {});
188
202
  }
189
- function R(e, t, n, r = {}) {
203
+ function B(e, t, n, r = {}) {
190
204
  let i = {
191
205
  ...n.runtimeData,
192
206
  ...r,
@@ -195,96 +209,95 @@ function R(e, t, n, r = {}) {
195
209
  }, a = (e.props?.value.trim().split(/\.|\[(\d+)\]/).filter(Boolean)).reduce((e, t) => {
196
210
  if (e && t in e) return typeof e[t] == "function" ? e[t]() : e[t];
197
211
  }, i), o = e.props?.defaultValue;
198
- return t(c, a ?? o ?? "");
212
+ return t(u, a ?? o ?? "");
199
213
  }
200
- function z(e, r) {
201
- let { tag: i = "", props: a = {} } = e;
202
- return Object.keys(a).reduce(function(e, o) {
203
- if (o === "__ignoreMap") return e;
204
- let s = a[o];
205
- if (k.test(o)) return B(o, s, e, r, { native: A.includes(i) });
206
- if (o === "v-bind") return V(o, s, e, r);
207
- if (D.test(o)) return H(o, s, e, r);
208
- if (O.test(o)) return U(o, s, e, r);
209
- let { attribute: c } = t(n, o);
214
+ function V(e, n) {
215
+ let { tag: r = "", props: i = {} } = e, a = Object.keys(i).reduce(function(e, a) {
216
+ if (a === "__ignoreMap") return e;
217
+ let s = i[a];
218
+ if (k.test(a)) return H(a, s, e, n, { native: A.includes(r) });
219
+ if (a === "v-bind") return U(a, s, e, n);
220
+ if (D.test(a)) return W(a, s, e, n);
221
+ if (O.test(a)) return G(a, s, e, n);
222
+ let { attribute: c } = o(t, a);
210
223
  return Array.isArray(s) && s.every((e) => typeof e == "string") ? (e[c] = s.join(" "), e) : (e[c] = s, e);
211
224
  }, {});
225
+ return Object.fromEntries(Object.entries(a).filter(([e, t]) => !s(e, t)));
212
226
  }
213
- function B(e, t, n, r, { native: i }) {
227
+ function H(e, t, n, r, { native: i }) {
214
228
  let a = e.match(/^v-model:([^=]+)/)?.[1] || "modelValue", o = i ? "value" : a, s = i ? "onInput" : `onUpdate:${a}`;
215
- return n[o] = G(t, r.runtimeData), n[s] = (e) => {
229
+ return n[o] = q(t, r.runtimeData), n[s] = (e) => {
216
230
  r.updateRuntimeData(t, i ? e.target?.value : e);
217
231
  }, n;
218
232
  }
219
- function V(e, t, n, r) {
220
- let i = G(t, r);
233
+ function U(e, t, n, r) {
234
+ let i = q(t, r);
221
235
  return n = Object.assign(n, i), n;
222
236
  }
223
- function H(e, t, n, r) {
224
- return e = e.replace(D, ""), n.on = n.on || {}, n.on[e] = () => G(t, r), n;
237
+ function W(e, t, n, r) {
238
+ return e = e.replace(D, ""), n.on = n.on || {}, n.on[e] = () => q(t, r), n;
225
239
  }
226
- function U(e, t, n, r) {
227
- return e = e.replace(O, ""), n[e] = G(t, r), n;
240
+ function G(e, t, n, r) {
241
+ return e = e.replace(O, ""), n[e] = q(t, r), n;
228
242
  }
229
- var W = (e) => {
243
+ var K = (e) => {
230
244
  if (typeof e == "string") {
231
- if (Q(e)) return e;
232
- let t = h(r(e), !1);
233
- return !e || t?.name === "AsyncComponentWrapper" || typeof t == "string" ? t : "setup" in t ? u(() => new Promise((e) => e(t))) : t;
245
+ if ($(e)) return e;
246
+ let t = _(n(e), !1);
247
+ return !e || t?.name === "AsyncComponentWrapper" || typeof t == "string" ? t : "setup" in t ? f(() => new Promise((e) => e(t))) : t;
234
248
  }
235
249
  return e;
236
250
  };
237
- function G(e, t) {
251
+ function q(e, t) {
238
252
  let n = e.split(".").reduce((e, t) => typeof e == "object" ? e[t] : void 0, t);
239
253
  return n === void 0 ? C(e) : n;
240
254
  }
241
- function K(e) {
255
+ function J(e) {
242
256
  let t = "";
243
- for (let n of Object.keys(e.props || {})) if (!(!n.startsWith("#") && !n.startsWith("v-slot:"))) {
257
+ for (let n of Object.keys(e.props || {})) if (n.startsWith("#") || n.startsWith("v-slot:")) {
244
258
  t = n.split(/[:#]/, 2)[1];
245
259
  break;
246
260
  }
247
261
  return t || E;
248
262
  }
249
- function q(e) {
263
+ function Y(e) {
250
264
  return e.tag === "template";
251
265
  }
252
- function J(e) {
266
+ function X(e) {
253
267
  return j.has(e);
254
268
  }
255
- function Y(e) {
269
+ function Z(e) {
256
270
  let t = [];
257
271
  for (let n of e) {
258
272
  let e = t[t.length - 1];
259
- n.type === c && e?.type === c ? e.children += n.children : t.push(n);
273
+ n.type === u && e?.type === u ? e.children += n.children : t.push(n);
260
274
  }
261
275
  return t;
262
276
  }
263
- async function X(e, t) {
277
+ async function ne(e, t) {
264
278
  if (!e) return;
265
279
  let n = Array.from(new Set(r(e, t)));
266
280
  await Promise.all(n.map(async (e) => {
267
281
  if (e?.render || e?.ssrRender || e?.__ssrInlineRender) return;
268
- let t = W(e);
282
+ let t = K(e);
269
283
  t?.__asyncLoader && !t.__asyncResolved && await t.__asyncLoader();
270
284
  }));
271
285
  function r(e, t) {
272
286
  let n = e.tag;
273
- if (e.type === "text" || n === "binding" || e.type === "comment") return [];
274
- let i = Z(e, t.tags);
275
- if (J(i)) return [];
287
+ if (e.type === "text" || n === "binding" || e.type === "comment" || e.type !== "root" && typeof n != "string") return [];
288
+ let i = Q(e, t.tags);
289
+ if (X(i)) return [];
276
290
  let a = [];
277
- e.type !== "root" && !Q(i) && a.push(i);
291
+ e.type !== "root" && !$(i) && a.push(i);
278
292
  for (let n of e.children || []) a.push(...r(n, t));
279
293
  return a;
280
294
  }
281
295
  }
282
- function Z(e, t) {
283
- let n = e.tag;
284
- return !n || e.props?.__ignoreMap !== void 0 ? n : t[n] || t[r(n)] || t[o(e.tag)] || n;
296
+ function Q(e, t) {
297
+ let i = e.tag;
298
+ return !i || e.props?.__ignoreMap !== void 0 ? i : t[i] || t[n(i)] || t[r(e.tag)] || i;
285
299
  }
286
- function Q(t) {
287
- return (typeof t == "string" ? M.has(t) : !1) || e.has(t);
300
+ function $(e) {
301
+ return typeof e == "string" && M.has(e) || c.has(e);
288
302
  }
289
- //#endregion
290
- export { F as default };
303
+ export { L as default };
@@ -6,7 +6,8 @@ type __VLS_Props = {
6
6
  /**
7
7
  * Code language
8
8
  *
9
- * @example js, ts, html, css, etc.
9
+ * @example
10
+ * js, ts, html, css, etc.
10
11
  */
11
12
  language?: string;
12
13
  /**