@airalogy/aimd-renderer 2.4.1

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/html.js ADDED
@@ -0,0 +1,11 @@
1
+ import { D as a, c as s, a as t, b as d, p as m, r as o, d as c, e as n } from "./processor-Cv8E7QsA.js";
2
+ export {
3
+ a as DEFAULT_AIMD_RENDERER_LOCALE,
4
+ s as createAimdRendererMessages,
5
+ t as createCustomElementAimdRenderer,
6
+ d as createHtmlProcessor,
7
+ m as parseAndExtract,
8
+ o as renderToHtml,
9
+ c as renderToHtmlSync,
10
+ n as resolveAimdRendererLocale
11
+ };
package/dist/index.js ADDED
@@ -0,0 +1,439 @@
1
+ import { e as V, c as C, p as I, q as K, s as j, t as x, u as D } from "./processor-Cv8E7QsA.js";
2
+ import { D as ie, f as re, g as ne, h as le, a as ce, i as de, b as oe, j as me, k as pe, l as ue, m as fe, n as _e, r as ye, d as ge, o as he } from "./processor-Cv8E7QsA.js";
3
+ import { h as e } from "vue";
4
+ const W = /* @__PURE__ */ Symbol("symbol-field-event-key"), J = /* @__PURE__ */ Symbol("symbol-protocol-key"), G = /* @__PURE__ */ Symbol("draft-event-key"), X = /* @__PURE__ */ Symbol("symbol-report-event-key"), Y = /* @__PURE__ */ Symbol("symbol-bubble-menu-event-key");
5
+ function B(t) {
6
+ return t === "var_table" ? "table" : t;
7
+ }
8
+ const H = /\[\[([^\[\]\s]+)\]\]/g;
9
+ function z(t, i) {
10
+ if (t !== "blank")
11
+ return [e("span", i)];
12
+ const n = [];
13
+ let l = 0;
14
+ for (const r of i.matchAll(H)) {
15
+ const o = r.index ?? 0, h = r[0], m = r[1];
16
+ o > l && n.push(e("span", i.slice(l, o))), n.push(
17
+ e("span", {
18
+ class: "aimd-quiz__blank-placeholder",
19
+ "data-blank-key": m
20
+ }, m)
21
+ ), l = o + h.length;
22
+ }
23
+ return l < i.length && n.push(e("span", i.slice(l))), n.length === 0 && n.push(e("span", i)), n;
24
+ }
25
+ function P(t) {
26
+ return typeof t.points == "number" && Number.isFinite(t.points) ? `${t.text} (${t.points})` : t.text;
27
+ }
28
+ function E(t) {
29
+ return !Array.isArray(t.items) || t.items.length === 0 || !Array.isArray(t.options) || t.options.length === 0 ? [e("div", { class: "aimd-scale__empty" }, "Scale definition is incomplete.")] : t.display === "list" ? [
30
+ e("div", { class: "aimd-scale__list" }, t.items.map(
31
+ (i) => e("div", { class: "aimd-scale__list-item" }, [
32
+ e("div", { class: "aimd-scale__item-stem" }, i.stem),
33
+ e("ul", { class: "aimd-scale__item-options" }, t.options.map(
34
+ (n) => e("li", P(n))
35
+ ))
36
+ ])
37
+ ))
38
+ ] : [
39
+ e("table", { class: "aimd-scale__table" }, [
40
+ e("thead", [
41
+ e("tr", [
42
+ e("th", { class: "aimd-scale__item-header" }, "Item"),
43
+ ...t.options.map((i) => e("th", P(i)))
44
+ ])
45
+ ]),
46
+ e("tbody", t.items.map(
47
+ (i) => e("tr", [
48
+ e("th", { class: "aimd-scale__item-stem", scope: "row" }, i.stem),
49
+ ...t.options.map(() => e("td", { class: "aimd-scale__cell" }, "○"))
50
+ ])
51
+ ))
52
+ ])
53
+ ];
54
+ }
55
+ function L(t) {
56
+ const i = Array.isArray(t.grading?.bands) ? t.grading.bands : [];
57
+ return i.length === 0 ? [] : [
58
+ e("ul", { class: "aimd-scale__bands" }, i.map(
59
+ (n) => e("li", `${n.min}-${n.max}: ${n.label}${n.interpretation ? ` · ${n.interpretation}` : ""}`)
60
+ ))
61
+ ];
62
+ }
63
+ function T(t, i, n, l) {
64
+ const r = B(t), o = x(t, n);
65
+ if (t === "var_table") {
66
+ const m = [
67
+ e("div", { class: "aimd-field__header" }, [
68
+ e("span", { class: "aimd-field__scope" }, n.scope.table),
69
+ e("span", { class: "aimd-field__name" }, i)
70
+ ])
71
+ ];
72
+ return l && l.length > 0 && m.push(
73
+ e("table", { class: "aimd-field__table-preview" }, [
74
+ e("thead", [
75
+ e("tr", l.map((u) => e("th", u)))
76
+ ]),
77
+ e("tbody", [
78
+ e("tr", l.map(() => e("td", "...")))
79
+ ])
80
+ ])
81
+ ), e("div", {
82
+ class: "aimd-field aimd-field--var-table",
83
+ "data-aimd-type": "var_table",
84
+ "data-aimd-id": i
85
+ }, m);
86
+ }
87
+ return e("span", {
88
+ class: `aimd-field aimd-field--${r === "table" ? "var-table" : r}`,
89
+ "data-aimd-type": r,
90
+ "data-aimd-id": i
91
+ }, [
92
+ e("span", { class: "aimd-field__scope" }, o),
93
+ e("span", { class: "aimd-field__name" }, i)
94
+ ]);
95
+ }
96
+ function O(t) {
97
+ const { getTokenProps: i, mode: n, components: l = {} } = t, r = C(t.locale, t.messages), {
98
+ AIMDItem: o,
99
+ AIMDTag: h,
100
+ AIMDStepRef: m,
101
+ StepRenderer: u,
102
+ CheckRenderer: q,
103
+ PreviewRenderer: _
104
+ } = l, b = () => typeof n == "function" ? n() : n, v = () => b() === "preview", w = () => D(b(), t.quizPreview);
105
+ return {
106
+ var: async (d, y, f) => {
107
+ const a = d, { id: s, scope: c } = a;
108
+ if (v())
109
+ return _ ? e(_, { type: "var" }, {
110
+ default: () => f,
111
+ name: () => s
112
+ }) : T(c, s, r);
113
+ if (i && o) {
114
+ const p = await i({ meta: { node: { id: s, scope: c } } });
115
+ if (p)
116
+ return e("span", {
117
+ class: "aimd-field-wrapper aimd-field-wrapper--inline",
118
+ id: `${c}-${s}`,
119
+ "data-has-variable": "true"
120
+ }, [e(o, p)]);
121
+ }
122
+ return T(c, s, r);
123
+ },
124
+ var_table: async (d, y, f) => {
125
+ const a = d, { id: s, scope: c, columns: p } = a;
126
+ if (v())
127
+ return _ ? e(_, { type: "var_table" }, {
128
+ default: () => f,
129
+ name: () => s
130
+ }) : T(c, s, r, p);
131
+ if (i && h) {
132
+ const A = await i({ meta: { node: { id: s, scope: c } } });
133
+ return e(h, { ...A, props: p });
134
+ }
135
+ return T(c, s, r, p);
136
+ },
137
+ quiz: async (d, y, f) => {
138
+ const a = d, { id: s, scope: c, quizType: p, stem: A, score: k } = a, S = j(p, a.mode, r);
139
+ if (v()) {
140
+ if (_)
141
+ return e(_, { type: "quiz" }, {
142
+ default: () => f,
143
+ name: () => s
144
+ });
145
+ const g = [
146
+ e("div", { class: "aimd-quiz__meta" }, [
147
+ e("span", { class: "aimd-field__scope" }, x(c, r)),
148
+ e("span", { class: "aimd-field__name" }, s),
149
+ e("span", { class: "aimd-field__type" }, `(${S})`),
150
+ k !== void 0 ? e("span", { class: "aimd-quiz__score" }, r.quiz.score(k)) : null
151
+ ]),
152
+ e("div", { class: "aimd-quiz__stem" }, z(p, A || s))
153
+ ];
154
+ typeof a.title == "string" && a.title.trim() && g.splice(1, 0, e("div", { class: "aimd-quiz__title" }, a.title)), typeof a.description == "string" && a.description.trim() && g.push(e("div", { class: "aimd-quiz__description" }, a.description)), p === "choice" && Array.isArray(a.options) && a.options.length > 0 && g.push(
155
+ e("ul", { class: "aimd-quiz__options" }, a.options.map(
156
+ (R) => e("li", `${R.key}. ${R.text}`)
157
+ ))
158
+ ), p === "scale" && (g.push(...E(a)), g.push(...L(a)));
159
+ const $ = w();
160
+ if ($.showAnswers && p === "choice" && a.answer !== void 0) {
161
+ const R = Array.isArray(a.answer) ? a.answer.join(", ") : String(a.answer);
162
+ R.trim() && g.push(
163
+ e("div", { class: "aimd-quiz__answer" }, r.quiz.answer(R))
164
+ );
165
+ }
166
+ return $.showAnswers && p === "blank" && Array.isArray(a.blanks) && a.blanks.length > 0 && g.push(
167
+ e("ul", { class: "aimd-quiz__blanks" }, a.blanks.map(
168
+ (R) => e("li", `${R.key}: ${R.answer}`)
169
+ ))
170
+ ), $.showRubric && p === "open" && typeof a.rubric == "string" && a.rubric.trim() && g.push(
171
+ e("div", { class: "aimd-quiz__rubric" }, r.quiz.rubric(a.rubric))
172
+ ), e("div", {
173
+ class: "aimd-field aimd-field--quiz",
174
+ "data-aimd-type": "quiz",
175
+ "data-aimd-id": s
176
+ }, g);
177
+ }
178
+ if (i && o) {
179
+ const g = await i({ meta: { node: { id: s, scope: c } } });
180
+ if (g)
181
+ return e("span", {
182
+ class: "aimd-field-wrapper aimd-field-wrapper--inline",
183
+ id: `${c}-${s}`,
184
+ "data-has-variable": "true"
185
+ }, [e(o, g)]);
186
+ }
187
+ return e("div", {
188
+ class: "aimd-field aimd-field--quiz",
189
+ "data-aimd-type": "quiz",
190
+ "data-aimd-id": s
191
+ }, [
192
+ e("div", { class: "aimd-quiz__meta" }, [
193
+ e("span", { class: "aimd-field__scope" }, x(c, r)),
194
+ e("span", { class: "aimd-field__name" }, s),
195
+ e("span", { class: "aimd-field__type" }, `(${S})`)
196
+ ]),
197
+ ...typeof a.title == "string" && a.title.trim() ? [e("div", { class: "aimd-quiz__title" }, a.title)] : [],
198
+ e("div", { class: "aimd-quiz__stem" }, z(p, A || s)),
199
+ ...typeof a.description == "string" && a.description.trim() ? [e("div", { class: "aimd-quiz__description" }, a.description)] : [],
200
+ ...p === "scale" ? [...E(a), ...L(a)] : []
201
+ ]);
202
+ },
203
+ step: async (d, y, f) => {
204
+ const a = d, { id: s, scope: c, step: p, check: A } = a;
205
+ if (v())
206
+ return _ ? e(_, { type: "step" }, {
207
+ default: () => f,
208
+ name: () => s
209
+ }) : e("span", { class: "research-step__sequence" }, r.step.sequence(p));
210
+ if (i && u) {
211
+ const k = await i({ meta: { node: { id: s, scope: c } } }), S = await i({ meta: { node: { id: s, scope: c, type: "step-annotation" } } });
212
+ return e(u, {
213
+ item: k,
214
+ annotationItem: S,
215
+ name: s,
216
+ step: String(p),
217
+ check: A
218
+ }, {
219
+ default: () => f
220
+ });
221
+ }
222
+ return e("span", { class: "research-step__sequence" }, r.step.sequence(p));
223
+ },
224
+ check: async (d, y, f) => {
225
+ const a = d, { id: s, scope: c, label: p } = a;
226
+ if (v())
227
+ return _ ? e(_, { type: "check" }, {
228
+ default: () => f,
229
+ name: () => s
230
+ }) : T(c, s, r);
231
+ if (i && q) {
232
+ const A = await i({ meta: { node: { id: s, scope: c } } }), k = await i({ meta: { node: { id: s, scope: c, type: "check-annotation" } } });
233
+ return e(q, {
234
+ item: A,
235
+ annotationItem: k,
236
+ name: s
237
+ }, {
238
+ default: () => f
239
+ });
240
+ }
241
+ return T(c, s, r);
242
+ },
243
+ ref_step: (d, y) => {
244
+ const { id: f } = d, a = "refTarget" in d ? d.refTarget : f, s = "stepSequence" in d && typeof d.stepSequence == "string" ? d.stepSequence : void 0, c = s ? r.step.reference(s) : a;
245
+ return m ? e(m, { name: a, type: "step", stepSequence: s }) : e("a", {
246
+ class: "aimd-ref aimd-ref--step",
247
+ href: `#step-${a}`,
248
+ "data-aimd-step-sequence": s,
249
+ title: a
250
+ }, [
251
+ e("span", { class: "aimd-ref__content" }, [
252
+ e("span", { class: "aimd-field aimd-field--step aimd-field--readonly" }, [
253
+ e("span", { class: "research-step__sequence" }, c)
254
+ ])
255
+ ])
256
+ ]);
257
+ },
258
+ ref_var: (d, y) => {
259
+ const { id: f } = d, a = "refTarget" in d ? d.refTarget : f, s = y.mode === "edit" ? F(y.value, a) : null;
260
+ return m ? e(m, {
261
+ name: a,
262
+ type: "var",
263
+ contextValue: y.value,
264
+ displayValue: s ?? void 0
265
+ }) : y.mode !== "edit" ? e("a", {
266
+ class: "aimd-ref aimd-ref--var",
267
+ href: `#var-${a}`,
268
+ title: a
269
+ }, [
270
+ e("span", { class: "aimd-ref__icon" }, "📌"),
271
+ e("span", { class: "aimd-ref__name" }, a)
272
+ ]) : e("span", {
273
+ class: "aimd-ref aimd-ref--var",
274
+ "data-aimd-ref": a,
275
+ title: a
276
+ }, [
277
+ e("span", { class: "aimd-ref__content" }, [
278
+ s !== null ? e("span", {
279
+ class: "aimd-field aimd-field--var aimd-field--readonly",
280
+ "data-aimd-id": a,
281
+ "data-aimd-scope": "var"
282
+ }, [
283
+ e("span", { class: "aimd-field__value" }, s)
284
+ ]) : e("span", { class: "aimd-field aimd-field--var" }, [
285
+ e("span", { class: "aimd-field__scope" }, r.scope.var),
286
+ e("span", { class: "aimd-field__name" }, a)
287
+ ])
288
+ ])
289
+ ]);
290
+ }
291
+ };
292
+ }
293
+ function M(t) {
294
+ return typeof t == "object" && t !== null && !Array.isArray(t);
295
+ }
296
+ function F(t, i) {
297
+ const n = t?.var?.[i], l = M(n) && "value" in n ? n.value : n;
298
+ if (l == null || l === "")
299
+ return null;
300
+ if (Array.isArray(l))
301
+ return l.map((r) => String(r)).join(", ");
302
+ if (M(l))
303
+ try {
304
+ return JSON.stringify(l);
305
+ } catch {
306
+ return null;
307
+ }
308
+ return String(l);
309
+ }
310
+ function N(t) {
311
+ const { getStaticResearchAssets: i, highlighter: n, components: l = {} } = t, { AssetRenderer: r, EmbeddedRenderer: o, MermaidBlock: h } = l, m = {};
312
+ return (r || i) && (m.img = (u, q, _) => {
313
+ const { src: b, alt: v } = u.properties || {};
314
+ return r ? e(r, {
315
+ src: b,
316
+ alt: v,
317
+ getStaticResearchAssets: i
318
+ }) : e("img", { src: b, alt: v, class: "aimd-image", loading: "lazy" });
319
+ }), m.pre = (u, q, _) => {
320
+ const b = u.children.find(
321
+ (s) => s.type === "element" && s.tagName === "code"
322
+ );
323
+ if (!b)
324
+ return e("pre", {}, q);
325
+ const v = b.properties?.className;
326
+ let w = "text";
327
+ if (Array.isArray(v)) {
328
+ const s = v.find((c) => typeof c == "string" && c.startsWith("language-"));
329
+ s && typeof s == "string" && (w = s.replace("language-", ""));
330
+ }
331
+ const d = b.children.map((s) => s.type === "text" ? s.value : "").join(""), y = d.split(/\n/)[0].trim();
332
+ if ((w === "mermaid" || y === "gantt" || y === "sequenceDiagram" || /^graph (?:TB|BT|RL|LR|TD);?$/.test(y)) && h)
333
+ return e(h, { code: d });
334
+ const a = typeof n == "function" ? n() : n;
335
+ if (a)
336
+ try {
337
+ const s = a.codeToHtml(d, {
338
+ lang: w,
339
+ theme: "github-dark"
340
+ });
341
+ return e("div", {
342
+ class: "shiki-code-block",
343
+ "data-lang": w,
344
+ innerHTML: s
345
+ });
346
+ } catch (s) {
347
+ console.error("Failed to highlight code:", s);
348
+ }
349
+ return e(
350
+ "pre",
351
+ { class: `language-${w}` },
352
+ e("code", { class: `language-${w}` }, d)
353
+ );
354
+ }, o && (m.iframe = (u, q, _) => e(o, {
355
+ contentProps: { ...u.properties, credentialless: !0 },
356
+ component: "iframe"
357
+ }), m.video = (u, q, _) => e(o, {
358
+ contentProps: u.properties,
359
+ component: "video"
360
+ })), m;
361
+ }
362
+ function Z(t) {
363
+ const i = () => typeof t.mode == "function" ? t.mode() : t.mode, n = () => D(i(), t.quizPreview), l = V(t.locale), r = C(l, t.messages), o = O(t), h = N(t), m = {
364
+ locale: l,
365
+ messages: r,
366
+ context: {
367
+ mode: i() === "timeline" ? "preview" : i(),
368
+ readonly: i() === "preview",
369
+ quizPreview: n(),
370
+ locale: l,
371
+ messages: r
372
+ },
373
+ aimdRenderers: o,
374
+ elementRenderers: h
375
+ };
376
+ return {
377
+ async render(u) {
378
+ return K(u, {
379
+ gfm: !0,
380
+ math: !0,
381
+ breaks: !0,
382
+ assignerVisibility: t.assignerVisibility,
383
+ ...m
384
+ });
385
+ },
386
+ extractFields(u) {
387
+ return I(u);
388
+ },
389
+ vueOptions: m
390
+ };
391
+ }
392
+ function ee(t) {
393
+ const { parent: i, sequence: n, level: l } = t;
394
+ let r = String(n + 1);
395
+ if (l === 1)
396
+ return r;
397
+ let o = i;
398
+ for (; o; )
399
+ r = `${o.sequence + 1}.${r}`, o = o.parent;
400
+ return r;
401
+ }
402
+ function te(t) {
403
+ if (t.startsWith("var_table")) {
404
+ const [o, h, m, ...u] = t.split(/(\\)?\|/g);
405
+ return [{ type: o, name: `${m}|${u.filter(Boolean).join(",")}` }];
406
+ }
407
+ const [n, l, r] = t.split(/(\\)?\|/);
408
+ return [{ type: n, name: r }];
409
+ }
410
+ export {
411
+ ie as DEFAULT_AIMD_RENDERER_LOCALE,
412
+ Y as bubbleMenuEventKey,
413
+ C as createAimdRendererMessages,
414
+ re as createAssetRenderer,
415
+ ne as createCodeBlockRenderer,
416
+ le as createComponentRenderer,
417
+ ce as createCustomElementAimdRenderer,
418
+ de as createEmbeddedRenderer,
419
+ oe as createHtmlProcessor,
420
+ me as createMermaidRenderer,
421
+ pe as createRenderer,
422
+ ue as createStepCardRenderer,
423
+ Z as createUnifiedTokenRenderer,
424
+ fe as defaultRenderer,
425
+ G as draftEventKey,
426
+ W as fieldEventKey,
427
+ j as getAimdRendererQuizTypeLabel,
428
+ ee as getFinalIndent,
429
+ _e as hastToVue,
430
+ I as parseAndExtract,
431
+ te as parseFieldTag,
432
+ J as protocolKey,
433
+ ye as renderToHtml,
434
+ ge as renderToHtmlSync,
435
+ he as renderToVNodes,
436
+ K as renderToVue,
437
+ X as reportEventKey,
438
+ V as resolveAimdRendererLocale
439
+ };