@airalogy/aimd-recorder 1.17.0 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/README.md +11 -10
  2. package/README.zh-CN.md +11 -10
  3. package/dist/AimdCodeField-BQUuM-EF.js +182 -0
  4. package/dist/{AimdDnaSequenceField-D6ZgCDpp.js → AimdDnaSequenceField-KZU2Zj3E.js} +2 -2
  5. package/dist/{AimdEditor.vue_vue_type_style_index_0_lang-B5Tq4zPV.js → AimdEditor.vue_vue_type_style_index_0_lang-CzfYPp5r.js} +3922 -3829
  6. package/dist/AimdMarkdownField-t2d8uOeU.js +254 -0
  7. package/dist/AimdMarkdownNoteField-_h1oZSwH.js +259 -0
  8. package/dist/{_commonjsHelpers-CZXJ37nu.js → _commonjsHelpers-B5RozER-.js} +2 -2
  9. package/dist/aimd-recorder.css +1 -1
  10. package/dist/arc-DS_ocYoe.js +83 -0
  11. package/dist/architectureDiagram-3BPJPVTR-Dq2W8_tb.js +4692 -0
  12. package/dist/blockDiagram-GPEHLZMM-B4hnSAF_.js +2425 -0
  13. package/dist/c4Diagram-AAUBKEIU-CbffqNLY.js +1577 -0
  14. package/dist/channel-CtXnYrAk.js +5 -0
  15. package/dist/chunk-2J33WTMH-CROScrt5.js +19 -0
  16. package/dist/chunk-4BX2VUAB-DTmsQu5_.js +8 -0
  17. package/dist/chunk-55IACEB6-B5wDJzeX.js +8 -0
  18. package/dist/chunk-727SXJPM-CfyltY6o.js +1528 -0
  19. package/dist/chunk-AQP2D5EJ-B8274EYy.js +1387 -0
  20. package/dist/chunk-FMBD7UC4-CT_FK-SH.js +19 -0
  21. package/dist/chunk-ND2GUHAM-g9GulPi-.js +68 -0
  22. package/dist/chunk-QZHKN3VN-Di5HEktz.js +15 -0
  23. package/dist/classDiagram-4FO5ZUOK-BVUr246k.js +16 -0
  24. package/dist/classDiagram-v2-Q7XG4LA2-BVUr246k.js +16 -0
  25. package/dist/components.js +3279 -2216
  26. package/dist/composables.js +92 -68
  27. package/dist/cose-bilkent-S5V4N54A-GJ4IOO6v.js +2609 -0
  28. package/dist/cytoscape.esm-r59gEWFs.js +18710 -0
  29. package/dist/dagre-BM42HDAG-oL7Br44o.js +445 -0
  30. package/dist/defaultLocale-BgPVtth8.js +171 -0
  31. package/dist/diagram-2AECGRRQ-DtoCG_N4.js +217 -0
  32. package/dist/diagram-5GNKFQAL-f8QNdS7L.js +123 -0
  33. package/dist/diagram-KO2AKTUF-CsJOW_AX.js +461 -0
  34. package/dist/diagram-LMA3HP47-xmEKNZ7y.js +142 -0
  35. package/dist/diagram-OG6HWLK6-unpC7vo8.js +528 -0
  36. package/dist/erDiagram-TEJ5UH35-BGzFnCJD.js +899 -0
  37. package/dist/flowDiagram-I6XJVG4X-LBFhDnOs.js +1628 -0
  38. package/dist/ganttDiagram-6RSMTGT7-CFBc-jPD.js +2707 -0
  39. package/dist/gitGraphDiagram-PVQCEYII-BLduh-Rb.js +815 -0
  40. package/dist/graph-DdlKE625.js +1510 -0
  41. package/dist/index.js +104 -80
  42. package/dist/infoDiagram-5YYISTIA-CLQQI6zM.js +24 -0
  43. package/dist/init-DjUOC4st.js +16 -0
  44. package/dist/ishikawaDiagram-YF4QCWOH-CStdYBmW.js +621 -0
  45. package/dist/journeyDiagram-JHISSGLW-B6mRTzoE.js +834 -0
  46. package/dist/kanban-definition-UN3LZRKU-C-vnN5v4.js +724 -0
  47. package/dist/katex-DNob3HGn.js +11690 -0
  48. package/dist/layout-DDt0fz-M.js +1703 -0
  49. package/dist/linear-C-IAFdOt.js +259 -0
  50. package/dist/mermaid.core-CuZ3nINf.js +15940 -0
  51. package/dist/mindmap-definition-RKZ34NQL-TSZ1Vb3z.js +827 -0
  52. package/dist/ordinal-B6-f3MAq.js +61 -0
  53. package/dist/pieDiagram-4H26LBE5-DYok-1-k.js +163 -0
  54. package/dist/quadrantDiagram-W4KKPZXB-Cg856sbH.js +1024 -0
  55. package/dist/requirementDiagram-4Y6WPE33-BN9fGdlJ.js +882 -0
  56. package/dist/sankeyDiagram-5OEKKPKP-CDqTgonY.js +847 -0
  57. package/dist/sequenceDiagram-3UESZ5HK-Chjrc0-W.js +2891 -0
  58. package/dist/stateDiagram-AJRCARHV-DRyLHrdr.js +263 -0
  59. package/dist/stateDiagram-v2-BHNVJYJU-CZTIDHid.js +16 -0
  60. package/dist/timeline-definition-PNZ67QCA-Bc3D9AAG.js +1055 -0
  61. package/dist/{useFieldRendering-xLajJhyA.js → useCodeBlockRendering-qA6gj4vz.js} +3035 -2254
  62. package/dist/useMonacoAutoHeight-D4T-El3J.js +66 -0
  63. package/dist/vennDiagram-CIIHVFJN-CYAul48m.js +1557 -0
  64. package/dist/wardley-L42UT6IY-D7b2ujEZ.js +22512 -0
  65. package/dist/wardleyDiagram-YWT4CUSO-B7Tg0MG9.js +675 -0
  66. package/dist/xychartDiagram-2RQKCTM6-xWYVEqth.js +1342 -0
  67. package/package.json +9 -8
  68. package/src/__tests__/assigner-runner-dependent-data.test.ts +32 -0
  69. package/src/__tests__/markdown-field.test.ts +150 -1
  70. package/src/__tests__/markdown-note-field.test.ts +86 -3
  71. package/src/__tests__/recorder-assigner-control.test.ts +844 -0
  72. package/src/__tests__/recorder-editor.test.ts +17 -0
  73. package/src/__tests__/recorder-markdown-assigner-integration.test.ts +49 -0
  74. package/src/__tests__/step-field.test.ts +47 -1
  75. package/src/__tests__/type-plugins.test.ts +1 -0
  76. package/src/__tests__/var-field-render.test.ts +741 -1
  77. package/src/components/AimdCodeField.vue +24 -5
  78. package/src/components/AimdMarkdownField.vue +548 -11
  79. package/src/components/AimdMarkdownNoteField.vue +241 -30
  80. package/src/components/AimdRecorder.vue +1521 -95
  81. package/src/components/AimdRecorderEditor.vue +276 -8
  82. package/src/components/AimdRecorderWysiwygFieldHost.vue +6 -0
  83. package/src/components/AimdRecorderWysiwygSurface.vue +32 -0
  84. package/src/components/AimdStepCheckField.vue +82 -18
  85. package/src/components/AimdVarField.vue +694 -25
  86. package/src/components/AimdVarTableField.vue +283 -110
  87. package/src/components/icons/AimdAssignerCalculatorIcon.vue +18 -0
  88. package/src/components/icons/AimdAssignerCloudStatusIcon.vue +22 -0
  89. package/src/components/recorderMilkdownPlugin.ts +14 -0
  90. package/src/composables/__tests__/useRecordState.test.ts +86 -0
  91. package/src/composables/__tests__/useVarHelpers.test.ts +133 -0
  92. package/src/composables/index.ts +27 -1
  93. package/src/composables/useAssignerRunner.ts +376 -0
  94. package/src/composables/useCodeBlockRendering.ts +51 -0
  95. package/src/composables/useFieldRendering.ts +32 -4
  96. package/src/composables/useMonacoAutoHeight.ts +127 -0
  97. package/src/composables/useRecordState.ts +22 -3
  98. package/src/composables/useVarHelpers.ts +377 -9
  99. package/src/index.ts +13 -0
  100. package/src/locales.ts +45 -0
  101. package/src/styles/aimd.css +151 -1
  102. package/src/type-plugins.ts +7 -0
  103. package/src/types.ts +93 -2
  104. package/dist/AimdCodeField-DC3DPvgc.js +0 -172
  105. package/dist/AimdMarkdownField-BJ20QtO8.js +0 -67
  106. package/dist/AimdMarkdownNoteField-DwAQhoyk.js +0 -186
@@ -0,0 +1,51 @@
1
+ import { onBeforeUnmount, onMounted, shallowRef } from 'vue'
2
+ import {
3
+ createCodeBlockRenderer,
4
+ loadShikiHighlighter,
5
+ type ElementRenderer,
6
+ type ShikiHighlighter,
7
+ } from '@airalogy/aimd-renderer'
8
+
9
+ export function createChainedElementRenderer(...renderers: ElementRenderer[]): ElementRenderer {
10
+ return (node, children, ctx) => {
11
+ for (const renderer of renderers) {
12
+ const rendered = renderer(node, children, ctx)
13
+ if (rendered !== null && rendered !== undefined) {
14
+ return rendered
15
+ }
16
+ }
17
+ return null
18
+ }
19
+ }
20
+
21
+ export function useCodeBlockRendering(onHighlighterReady?: () => void) {
22
+ const highlighter = shallowRef<ShikiHighlighter | null>(null)
23
+ let cancelled = false
24
+ const preRenderer = createCodeBlockRenderer(() => highlighter.value, {
25
+ theme: 'github-light',
26
+ lineNumbers: true,
27
+ wrap: true,
28
+ })
29
+
30
+ onMounted(() => {
31
+ void loadShikiHighlighter()
32
+ .then((loadedHighlighter) => {
33
+ if (cancelled) {
34
+ return
35
+ }
36
+ highlighter.value = loadedHighlighter
37
+ onHighlighterReady?.()
38
+ })
39
+ .catch(() => {
40
+ // Keep the non-highlighted renderer. Line numbers and wrapping still work.
41
+ })
42
+ })
43
+
44
+ onBeforeUnmount(() => {
45
+ cancelled = true
46
+ })
47
+
48
+ return {
49
+ preRenderer,
50
+ }
51
+ }
@@ -1,5 +1,6 @@
1
1
  import { reactive, type VNode } from "vue"
2
2
  import type { AimdVarNode } from "@airalogy/aimd-core/types"
3
+ import { formatAimdExampleValue, getAimdFieldExamples } from "@airalogy/aimd-core/utils"
3
4
  import type { AimdFieldMeta, AimdFieldState, AimdTypePlugin, AimdTypePluginInitContext, AimdTypePluginValueContext } from "../types"
4
5
  import {
5
6
  normalizeVarTypeName,
@@ -31,6 +32,19 @@ export interface FieldRenderingOptions {
31
32
  wrapField: () => ((fieldKey: string, fieldType: string, defaultVNode: VNode) => VNode) | undefined
32
33
  }
33
34
 
35
+ function getFieldMetaExamples(meta?: AimdFieldMeta): unknown[] {
36
+ if (!meta) return []
37
+ if (Array.isArray(meta.examples)) {
38
+ return meta.examples.filter(value => value !== undefined && value !== null)
39
+ }
40
+ const singleExample = (meta as { example?: unknown }).example
41
+ return singleExample === undefined || singleExample === null ? [] : [singleExample]
42
+ }
43
+
44
+ function isReadonlyAssignerMode(mode?: NonNullable<AimdFieldMeta["assigner"]>["mode"]): boolean {
45
+ return mode === "auto_force" || mode === "auto_readonly" || mode === "manual_readonly"
46
+ }
47
+
34
48
  // ---------------------------------------------------------------------------
35
49
  // Composable
36
50
  // ---------------------------------------------------------------------------
@@ -57,7 +71,7 @@ export function useFieldRendering(options: FieldRenderingOptions) {
57
71
  if (options.readonly()) return true
58
72
  const meta = options.fieldMeta()?.[fieldKey]
59
73
  const state = options.fieldState()?.[fieldKey]
60
- return !!(meta?.disabled || state?.disabled || meta?.assigner?.mode === "auto_force")
74
+ return !!(meta?.disabled || state?.disabled || isReadonlyAssignerMode(meta?.assigner?.mode))
61
75
  }
62
76
 
63
77
  // ── resolveNowDate ─────────────────────────────────────────────────────
@@ -123,6 +137,8 @@ export function useFieldRendering(options: FieldRenderingOptions) {
123
137
  getVarInputKind(type, {
124
138
  inputType: options.fieldMeta()?.[fieldKey]?.inputType,
125
139
  codeLanguage: options.fieldMeta()?.[fieldKey]?.codeLanguage,
140
+ kwargs: node.definition?.kwargs,
141
+ fieldMeta: options.fieldMeta()?.[fieldKey],
126
142
  typePlugin: getTypePlugin(fieldKey, type),
127
143
  }) !== "number"
128
144
  || typeof node.definition?.default !== "number"
@@ -196,6 +212,8 @@ export function useFieldRendering(options: FieldRenderingOptions) {
196
212
  const inputKind = getVarInputKind(type, {
197
213
  inputType: options.fieldMeta()?.[fieldKey]?.inputType,
198
214
  codeLanguage: options.fieldMeta()?.[fieldKey]?.codeLanguage,
215
+ kwargs: node.definition?.kwargs,
216
+ fieldMeta: options.fieldMeta()?.[fieldKey],
199
217
  typePlugin,
200
218
  })
201
219
  if (inputKind === "checkbox") return false
@@ -227,9 +245,19 @@ export function useFieldRendering(options: FieldRenderingOptions) {
227
245
  return value
228
246
  }
229
247
 
230
- function getVarPlaceholder(node: AimdVarNode): string | undefined {
231
- const title = node.definition?.kwargs?.title
232
- return typeof title === "string" && title.trim() ? title.trim() : undefined
248
+ function getVarPlaceholder(node: AimdVarNode, meta?: AimdFieldMeta): string | undefined {
249
+ const placeholder = node.definition?.kwargs?.placeholder
250
+ if (typeof placeholder === "string" && placeholder.trim()) {
251
+ return placeholder.trim()
252
+ }
253
+
254
+ const metaExamples = getFieldMetaExamples(meta)
255
+ const [example] = metaExamples.length > 0 ? metaExamples : getAimdFieldExamples(node.definition)
256
+ if (example !== undefined && example !== null && typeof example !== "object") {
257
+ return formatAimdExampleValue(example)
258
+ }
259
+
260
+ return undefined
233
261
  }
234
262
 
235
263
  // ── ID helpers ─────────────────────────────────────────────────────────
@@ -0,0 +1,127 @@
1
+ import { nextTick, ref, type Ref } from 'vue'
2
+
3
+ export type MonacoAutoHeightEditor = {
4
+ getContentHeight?: () => number
5
+ layout?: (dimension?: { width: number; height: number }) => void
6
+ onDidContentSizeChange?: (listener: (event: { contentHeight: number }) => void) => { dispose: () => void }
7
+ }
8
+
9
+ export type MonacoAutoHeightOptions = {
10
+ getInitialValue: () => string
11
+ getLayoutElement: () => HTMLElement | null
12
+ lineHeight?: number
13
+ verticalPadding?: number
14
+ minHeight?: number
15
+ maxHeight?: number
16
+ estimatedCharsPerLine?: number
17
+ }
18
+
19
+ export type MonacoAutoHeightController = {
20
+ editorHeight: Ref<number>
21
+ lineHeight: number
22
+ minHeight: number
23
+ maxHeight: number
24
+ attachEditor: (editor: MonacoAutoHeightEditor) => void
25
+ dispose: () => void
26
+ estimateEditorHeight: (value: string) => number
27
+ layoutEditor: () => void
28
+ setEditorHeight: (height: number) => void
29
+ syncEstimatedEditorHeight: (value?: string) => void
30
+ syncMeasuredEditorHeight: () => void
31
+ }
32
+
33
+ const DEFAULT_LINE_HEIGHT = 21
34
+ const DEFAULT_VERTICAL_PADDING = 24
35
+ const DEFAULT_ESTIMATED_CHARS_PER_LINE = 96
36
+
37
+ export function estimateMonacoVisualLineCount(value: string, estimatedCharsPerLine = DEFAULT_ESTIMATED_CHARS_PER_LINE): number {
38
+ const lines = value.replace(/\r\n?/g, '\n').split('\n')
39
+ return lines.reduce((total, line) => {
40
+ const length = Array.from(line).length
41
+ return total + Math.max(1, Math.ceil(length / estimatedCharsPerLine))
42
+ }, 0)
43
+ }
44
+
45
+ export function createMonacoAutoHeight(options: MonacoAutoHeightOptions): MonacoAutoHeightController {
46
+ const lineHeight = options.lineHeight ?? DEFAULT_LINE_HEIGHT
47
+ const verticalPadding = options.verticalPadding ?? DEFAULT_VERTICAL_PADDING
48
+ const minHeight = options.minHeight ?? lineHeight + verticalPadding
49
+ const maxHeight = options.maxHeight ?? 560
50
+ const estimatedCharsPerLine = options.estimatedCharsPerLine ?? DEFAULT_ESTIMATED_CHARS_PER_LINE
51
+ const editorHeight = ref(estimateEditorHeight(options.getInitialValue()))
52
+
53
+ let editor: MonacoAutoHeightEditor | null = null
54
+ let contentSizeDisposable: { dispose: () => void } | null = null
55
+
56
+ function clampEditorHeight(height: number): number {
57
+ return Math.max(minHeight, Math.min(maxHeight, Math.ceil(height)))
58
+ }
59
+
60
+ function estimateEditorHeight(value: string): number {
61
+ return clampEditorHeight((estimateMonacoVisualLineCount(value, estimatedCharsPerLine) * lineHeight) + verticalPadding)
62
+ }
63
+
64
+ function layoutEditor() {
65
+ if (!editor?.layout) {
66
+ return
67
+ }
68
+
69
+ const width = options.getLayoutElement()?.clientWidth ?? 0
70
+ if (width > 0) {
71
+ editor.layout({ width, height: editorHeight.value })
72
+ return
73
+ }
74
+
75
+ editor.layout()
76
+ }
77
+
78
+ function setEditorHeight(height: number) {
79
+ const nextHeight = clampEditorHeight(height)
80
+ if (nextHeight === editorHeight.value) {
81
+ return
82
+ }
83
+
84
+ editorHeight.value = nextHeight
85
+ void nextTick(layoutEditor)
86
+ }
87
+
88
+ function syncEstimatedEditorHeight(value = options.getInitialValue()) {
89
+ setEditorHeight(estimateEditorHeight(value))
90
+ }
91
+
92
+ function syncMeasuredEditorHeight() {
93
+ const contentHeight = editor?.getContentHeight?.()
94
+ if (typeof contentHeight === 'number' && Number.isFinite(contentHeight)) {
95
+ setEditorHeight(contentHeight)
96
+ }
97
+ }
98
+
99
+ function attachEditor(nextEditor: MonacoAutoHeightEditor) {
100
+ contentSizeDisposable?.dispose()
101
+ editor = nextEditor
102
+ contentSizeDisposable = editor.onDidContentSizeChange?.((event) => {
103
+ setEditorHeight(event.contentHeight)
104
+ }) ?? null
105
+ syncMeasuredEditorHeight()
106
+ }
107
+
108
+ function dispose() {
109
+ contentSizeDisposable?.dispose()
110
+ contentSizeDisposable = null
111
+ editor = null
112
+ }
113
+
114
+ return {
115
+ editorHeight,
116
+ lineHeight,
117
+ minHeight,
118
+ maxHeight,
119
+ attachEditor,
120
+ dispose,
121
+ estimateEditorHeight,
122
+ layoutEditor,
123
+ setEditorHeight,
124
+ syncEstimatedEditorHeight,
125
+ syncMeasuredEditorHeight,
126
+ }
127
+ }
@@ -363,6 +363,14 @@ export function normalizeVarTableRows(raw: unknown, columns: string[]): Record<s
363
363
  return rows
364
364
  }
365
365
 
366
+ function isPlaceholderVarTableRows(rows: Record<string, string>[], columns: string[]): boolean {
367
+ if (rows.length !== 1) {
368
+ return false
369
+ }
370
+
371
+ return columns.every(column => rows[0]?.[column] === "")
372
+ }
373
+
366
374
  export interface VarTablePastedCell {
367
375
  rowIndex: number
368
376
  column: string
@@ -456,9 +464,20 @@ export function ensureDefaultsFromFields(localRecord: AimdProtocolRecordData, fi
456
464
 
457
465
  for (const vt of normalizeVarTableFields(fields.var_table)) {
458
466
  const columns = vt.subvars.map(subvar => subvar.id)
459
- const rows = localRecord.var[vt.id]
460
- const normalizedRows = normalizeVarTableRows(rows, columns)
461
- if (JSON.stringify(normalizedRows) !== JSON.stringify(rows)) {
467
+ const hasExistingRows = vt.id in localRecord.var
468
+ const defaultRows = Array.isArray(vt.default) && vt.default.length > 0
469
+ ? normalizeVarTableRows(vt.default, columns)
470
+ : undefined
471
+ const rows = hasExistingRows ? localRecord.var[vt.id] : (defaultRows ?? vt.default)
472
+ const existingRows = normalizeVarTableRows(rows, columns)
473
+ const shouldApplyDefaults = Boolean(
474
+ hasExistingRows
475
+ && defaultRows
476
+ && isPlaceholderVarTableRows(existingRows, columns)
477
+ && !isPlaceholderVarTableRows(defaultRows, columns),
478
+ )
479
+ const normalizedRows = shouldApplyDefaults && defaultRows ? defaultRows : existingRows
480
+ if (!hasExistingRows || JSON.stringify(normalizedRows) !== JSON.stringify(rows)) {
462
481
  localRecord.var[vt.id] = normalizedRows
463
482
  changed = true
464
483
  }