@airalogy/aimd-recorder 1.25.1 → 1.26.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.
- package/README.md +16 -0
- package/README.zh-CN.md +16 -0
- package/dist/{AimdDnaSequenceField-WZF4SAj2.js → AimdDnaSequenceField-CKfd3-_9.js} +1 -1
- package/dist/{AimdEditor.vue_vue_type_style_index_0_lang-COQDWC8R.js → AimdEditor.vue_vue_type_style_index_0_lang-C1XlvrNT.js} +8311 -7173
- package/dist/{AimdEntityRefField-CWVj0vPF.js → AimdEntityRefField-CX67car3.js} +1 -1
- package/dist/{AimdEntityRefField.vue_vue_type_script_setup_true_lang-CaKfY8iu.js → AimdEntityRefField.vue_vue_type_script_setup_true_lang-JISqbfKY.js} +1 -1
- package/dist/{AimdMarkdownField-BeDCefoQ.js → AimdMarkdownField-BuRsjOB5.js} +9 -9
- package/dist/{AimdMarkdownNoteField-BKrlgUYP.js → AimdMarkdownNoteField-NRA9ut3_.js} +6 -6
- package/dist/{AimdResourceRefField-DUlNcU3q.js → AimdResourceRefField-B71MVFFK.js} +2 -2
- package/dist/aimd-recorder.css +1 -1
- package/dist/{arc-DYnxKzGE.js → arc-2NNDEUZL.js} +1 -1
- package/dist/{architectureDiagram-3BPJPVTR-CjOI8IqA.js → architectureDiagram-3BPJPVTR-BGU_a_9z.js} +2 -2
- package/dist/{blockDiagram-GPEHLZMM-B8xNjZYk.js → blockDiagram-GPEHLZMM-ChLqLSJn.js} +4 -4
- package/dist/{c4Diagram-AAUBKEIU-TpIYY3Qn.js → c4Diagram-AAUBKEIU-BXt823OA.js} +2 -2
- package/dist/{channel-BYLaVK3q.js → channel-D1EuKFn5.js} +1 -1
- package/dist/{chunk-2J33WTMH-YwB0nZYk.js → chunk-2J33WTMH-XJPmqQtr.js} +1 -1
- package/dist/{chunk-4BX2VUAB-6QDBanOQ.js → chunk-4BX2VUAB-CbV5jCeG.js} +1 -1
- package/dist/{chunk-55IACEB6-7rwKJBSZ.js → chunk-55IACEB6-C8gv1Mc0.js} +1 -1
- package/dist/{chunk-727SXJPM-Ba_FZJwp.js → chunk-727SXJPM-Bs2EpCWN.js} +5 -5
- package/dist/{chunk-AQP2D5EJ-reuQpvqF.js → chunk-AQP2D5EJ-CngahRo6.js} +3 -3
- package/dist/{chunk-FMBD7UC4-D35dlx01.js → chunk-FMBD7UC4-DPBfEP1E.js} +1 -1
- package/dist/{chunk-ND2GUHAM-D7604ZCl.js → chunk-ND2GUHAM-BlEzeiST.js} +1 -1
- package/dist/{chunk-QZHKN3VN-CKYkktao.js → chunk-QZHKN3VN-DGOFj8Bc.js} +1 -1
- package/dist/{classDiagram-v2-Q7XG4LA2-BNKRYoAB.js → classDiagram-4FO5ZUOK-BUQqoFF9.js} +2 -2
- package/dist/{classDiagram-4FO5ZUOK-BNKRYoAB.js → classDiagram-v2-Q7XG4LA2-BUQqoFF9.js} +2 -2
- package/dist/components.js +3885 -3650
- package/dist/composables.js +3 -3
- package/dist/{cose-bilkent-S5V4N54A-Dq12egzW.js → cose-bilkent-S5V4N54A-Qxs9suxa.js} +1 -1
- package/dist/{dagre-BM42HDAG-CRwAbNsB.js → dagre-BM42HDAG-CqV8IXIy.js} +3 -3
- package/dist/{diagram-2AECGRRQ--WYmW1Cd.js → diagram-2AECGRRQ-D0mYOaE1.js} +2 -2
- package/dist/{diagram-5GNKFQAL-C7KgsBJW.js → diagram-5GNKFQAL-Dvjcs9SL.js} +3 -3
- package/dist/{diagram-KO2AKTUF-B_6YtDZt.js → diagram-KO2AKTUF-rSovr72L.js} +2 -2
- package/dist/{diagram-LMA3HP47-DARH_IPq.js → diagram-LMA3HP47-CirCeq88.js} +2 -2
- package/dist/{diagram-OG6HWLK6-CRdh6xnM.js → diagram-OG6HWLK6-rk46c1hT.js} +3 -3
- package/dist/{erDiagram-TEJ5UH35-CoC8CHnh.js → erDiagram-TEJ5UH35--_m5yDSV.js} +4 -4
- package/dist/{flowDiagram-I6XJVG4X-BvOa5j4A.js → flowDiagram-I6XJVG4X-DU-TlDfY.js} +6 -6
- package/dist/{ganttDiagram-6RSMTGT7-CVXhLTr6.js → ganttDiagram-6RSMTGT7-CrMwQSQi.js} +2 -2
- package/dist/{gitGraphDiagram-PVQCEYII-DFhjJRYR.js → gitGraphDiagram-PVQCEYII-Q-bwtX2H.js} +3 -3
- package/dist/{graph-DEn_dxZa.js → graph-CvyYQarK.js} +58 -58
- package/dist/index.js +124 -123
- package/dist/{infoDiagram-5YYISTIA-uEUHa5YE.js → infoDiagram-5YYISTIA-BejjAcMI.js} +1 -1
- package/dist/{ishikawaDiagram-YF4QCWOH-BqGYvdVJ.js → ishikawaDiagram-YF4QCWOH-CbRBA5Ak.js} +1 -1
- package/dist/{journeyDiagram-JHISSGLW-BkKJZduM.js → journeyDiagram-JHISSGLW-D_6-qOB8.js} +4 -4
- package/dist/{kanban-definition-UN3LZRKU-CEsZIhW3.js → kanban-definition-UN3LZRKU-DyGjEqu5.js} +2 -2
- package/dist/{layout-Dk4utAZD.js → layout-Z5g42JDg.js} +93 -93
- package/dist/{linear-pw3I09nb.js → linear-DSunMwcT.js} +1 -1
- package/dist/{mermaid.core-iJ2XgYy9.js → mermaid.core-B-O2uDZ3.js} +34 -34
- package/dist/{mindmap-definition-RKZ34NQL-ChQ5---t.js → mindmap-definition-RKZ34NQL-CC_NhwV9.js} +3 -3
- package/dist/{pieDiagram-4H26LBE5-DRIV2FNb.js → pieDiagram-4H26LBE5-CHlBAazu.js} +3 -3
- package/dist/{quadrantDiagram-W4KKPZXB-C57biOpe.js → quadrantDiagram-W4KKPZXB-BM6pMzVZ.js} +2 -2
- package/dist/record.js +2 -2
- package/dist/{requirementDiagram-4Y6WPE33-KjKJuN09.js → requirementDiagram-4Y6WPE33-CNkZDYpb.js} +3 -3
- package/dist/{sankeyDiagram-5OEKKPKP-BFubJDRS.js → sankeyDiagram-5OEKKPKP-Cq6DjItn.js} +1 -1
- package/dist/{sequenceDiagram-3UESZ5HK-B7vg6NfP.js → sequenceDiagram-3UESZ5HK-BIzn9dmF.js} +3 -3
- package/dist/{stateDiagram-AJRCARHV-BRs_mbra.js → stateDiagram-AJRCARHV-DbSpH-v9.js} +4 -4
- package/dist/{stateDiagram-v2-BHNVJYJU-4w8m6dxi.js → stateDiagram-v2-BHNVJYJU-Cnv8BTgy.js} +2 -2
- package/dist/{timeline-definition-PNZ67QCA-vrEAExRb.js → timeline-definition-PNZ67QCA-Bhs5_-8Z.js} +2 -2
- package/dist/useCodeBlockRendering-IjoDTQ64.js +35 -0
- package/dist/{useFieldRendering-B3Vm2XT8.js → useFieldRendering-r1bAnHjk.js} +239 -240
- package/dist/useVarHelpers-xrbf4f60.js +7008 -0
- package/dist/{validation-IAiGnEKX.js → validation-ZmPcMCY0.js} +991 -989
- package/dist/{vennDiagram-CIIHVFJN-CFtQv4Ta.js → vennDiagram-CIIHVFJN-DJSLUotN.js} +1 -1
- package/dist/{wardleyDiagram-YWT4CUSO-BxzaCMou.js → wardleyDiagram-YWT4CUSO-Bk66hVLg.js} +2 -2
- package/dist/{xychartDiagram-2RQKCTM6-DhTuG8MO.js → xychartDiagram-2RQKCTM6-Bss5MLVp.js} +2 -2
- package/package.json +4 -4
- package/src/__tests__/check-field-render.test.ts +65 -0
- package/src/__tests__/compact-field-types.test.ts +181 -0
- package/src/__tests__/compact-fields.test.ts +31 -0
- package/src/__tests__/multi-select-field.test.ts +54 -0
- package/src/__tests__/quoted-check-wysiwyg.test.ts +56 -0
- package/src/__tests__/recorder-field-authoring.test.ts +92 -0
- package/src/__tests__/recorder-wysiwyg-field-host.test.ts +115 -1
- package/src/__tests__/step-field.test.ts +54 -1
- package/src/components/AimdMultiSelectField.vue +56 -0
- package/src/components/AimdRecorder.vue +21 -4
- package/src/components/AimdRecorderEditor.vue +4 -0
- package/src/components/AimdRecorderWysiwygFieldHost.vue +8 -0
- package/src/components/AimdRecorderWysiwygSurface.vue +220 -8
- package/src/components/AimdStepCheckField.vue +36 -7
- package/src/components/AimdVarField.vue +48 -4
- package/src/components/AimdVarTableField.vue +3 -0
- package/src/components/index.ts +2 -0
- package/src/components/recorderMilkdownPlugin.ts +36 -6
- package/src/composables/__tests__/useVarHelpers.test.ts +15 -0
- package/src/composables/__tests__/workbenchFieldEditing.test.ts +10 -0
- package/src/composables/useFieldPresentation.ts +7 -0
- package/src/composables/useFieldRendering.ts +1 -0
- package/src/composables/useVarHelpers.ts +20 -101
- package/src/composables/workbenchFieldEditing.ts +5 -7
- package/src/index.ts +1 -0
- package/src/record/validation.ts +6 -0
- package/src/styles/recorder-compact.css +45 -0
- package/src/styles/recorder-surface.css +14 -5
- package/src/styles/recorder.css +4 -0
- package/src/type-utils.ts +5 -1
- package/src/types.ts +1 -1
- package/dist/useCodeBlockRendering-D2viVPtA.js +0 -3158
- package/dist/useVarHelpers-DzhBBFdk.js +0 -3525
|
@@ -8,6 +8,7 @@ import { NodeSelection } from '@milkdown/kit/prose/state'
|
|
|
8
8
|
import { hardbreakAttr, hardbreakSchema } from '@milkdown/kit/preset/commonmark'
|
|
9
9
|
import { $node, $prose, $remark, $view } from '@milkdown/kit/utils'
|
|
10
10
|
import type { AimdQuizGradeResult, ExtractedAimdFields } from '@airalogy/aimd-core/types'
|
|
11
|
+
import { parseVarDefinition } from '@airalogy/aimd-core/parser'
|
|
11
12
|
import {
|
|
12
13
|
aimdFieldInputRule,
|
|
13
14
|
aimdFieldNode,
|
|
@@ -53,6 +54,7 @@ export interface RecorderMilkdownFieldIdentity {
|
|
|
53
54
|
export interface RecorderMilkdownSurfaceState {
|
|
54
55
|
record: AimdProtocolRecordData
|
|
55
56
|
readonly: boolean
|
|
57
|
+
fieldDisplay?: 'compact' | 'detailed'
|
|
56
58
|
currentUserName?: string
|
|
57
59
|
now?: Date | string | number
|
|
58
60
|
locale?: string
|
|
@@ -102,8 +104,8 @@ export interface RecorderMilkdownSurfaceState {
|
|
|
102
104
|
interface RecorderMilkdownPluginOptions {
|
|
103
105
|
appContext?: AppContext | null
|
|
104
106
|
surfaceState: RecorderMilkdownSurfaceState
|
|
105
|
-
onEditField?: (field: RecorderMilkdownFieldIdentity) => void
|
|
106
|
-
onDeleteField?: (field: RecorderMilkdownFieldIdentity) => void
|
|
107
|
+
onEditField?: (field: RecorderMilkdownFieldIdentity, apply: (content: string) => boolean) => void
|
|
108
|
+
onDeleteField?: (field: RecorderMilkdownFieldIdentity, remove: () => void) => void
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
const RECORDER_QUIZ_MDAST_TYPE = 'aimdRecorderQuizBlock'
|
|
@@ -246,7 +248,7 @@ const recorderQuizNode = $node('aimd_recorder_quiz', () => ({
|
|
|
246
248
|
},
|
|
247
249
|
} as NodeSchema))
|
|
248
250
|
|
|
249
|
-
class RecorderWidgetNodeView implements NodeView {
|
|
251
|
+
export class RecorderWidgetNodeView implements NodeView {
|
|
250
252
|
dom: HTMLElement
|
|
251
253
|
private bodyEl: HTMLElement
|
|
252
254
|
private summaryEl: HTMLElement
|
|
@@ -299,7 +301,26 @@ class RecorderWidgetNodeView implements NodeView {
|
|
|
299
301
|
|
|
300
302
|
const identity = this.resolveIdentity()
|
|
301
303
|
if (identity) {
|
|
302
|
-
this.options.onEditField?.(identity
|
|
304
|
+
this.options.onEditField?.(identity, content => {
|
|
305
|
+
const pos = this.getPos()
|
|
306
|
+
if (typeof pos !== 'number' || this.options.surfaceState.readonly) return false
|
|
307
|
+
const current = this.view.state.doc.nodeAt(pos)
|
|
308
|
+
// Reparsing may replace a node with an equivalent instance while the dialog is open.
|
|
309
|
+
if (!current || !current.eq(this.node)) return false
|
|
310
|
+
const tr = this.view.state.tr.setNodeMarkup(pos, undefined, { ...current.attrs, fieldContent: content })
|
|
311
|
+
if (identity.fieldType === 'var') {
|
|
312
|
+
const nextId = parseVarDefinition(content).id
|
|
313
|
+
if (nextId !== identity.id) {
|
|
314
|
+
this.view.state.doc.descendants((child, childPos) => {
|
|
315
|
+
if (child.type.name === 'aimd_field' && child.attrs.fieldType === 'ref_var' && child.attrs.fieldContent.trim() === identity.id) {
|
|
316
|
+
tr.setNodeMarkup(childPos, undefined, { ...child.attrs, fieldContent: nextId })
|
|
317
|
+
}
|
|
318
|
+
})
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
this.view.dispatch(tr)
|
|
322
|
+
return true
|
|
323
|
+
})
|
|
303
324
|
}
|
|
304
325
|
})
|
|
305
326
|
actionsEl.appendChild(this.editButtonEl)
|
|
@@ -319,7 +340,13 @@ class RecorderWidgetNodeView implements NodeView {
|
|
|
319
340
|
|
|
320
341
|
const identity = this.resolveIdentity()
|
|
321
342
|
if (identity) {
|
|
322
|
-
this.options.onDeleteField?.(identity)
|
|
343
|
+
this.options.onDeleteField?.(identity, () => {
|
|
344
|
+
const pos = this.getPos()
|
|
345
|
+
if (typeof pos !== 'number' || this.options.surfaceState.readonly) return
|
|
346
|
+
const current = this.view.state.doc.nodeAt(pos)
|
|
347
|
+
if (!current || !current.eq(this.node)) return
|
|
348
|
+
this.view.dispatch(this.view.state.tr.delete(pos, pos + current.nodeSize))
|
|
349
|
+
})
|
|
323
350
|
}
|
|
324
351
|
})
|
|
325
352
|
actionsEl.appendChild(this.deleteButtonEl)
|
|
@@ -383,12 +410,15 @@ class RecorderWidgetNodeView implements NodeView {
|
|
|
383
410
|
|
|
384
411
|
private renderField() {
|
|
385
412
|
const identity = this.resolveIdentity()
|
|
413
|
+
const isStep = this.resolveFieldType() === 'step'
|
|
386
414
|
const label = identity?.id
|
|
387
415
|
? `${identity.fieldType} ${identity.id}`
|
|
388
416
|
: this.resolveFieldType()
|
|
389
417
|
this.summaryEl.textContent = label
|
|
390
418
|
this.summaryEl.title = label
|
|
391
419
|
this.dom.setAttribute('data-field-type', this.resolveFieldType())
|
|
420
|
+
// A step is a section header visually, but remains an inline AIMD token in the document.
|
|
421
|
+
this.dom.classList.toggle('aimd-recorder-wysiwyg-node--step', isStep)
|
|
392
422
|
this.dom.draggable = !this.options.surfaceState.readonly
|
|
393
423
|
|
|
394
424
|
if (this.dragHandleEl) {
|
|
@@ -406,7 +436,7 @@ class RecorderWidgetNodeView implements NodeView {
|
|
|
406
436
|
const vnode = h(AimdRecorderWysiwygFieldHost, {
|
|
407
437
|
surfaceState: this.options.surfaceState,
|
|
408
438
|
rawContent: this.resolveRaw(),
|
|
409
|
-
displayMode: this.block ? 'block' : 'inline',
|
|
439
|
+
displayMode: this.block || isStep ? 'block' : 'inline',
|
|
410
440
|
})
|
|
411
441
|
vnode.appContext = this.options.appContext ?? null
|
|
412
442
|
render(vnode, this.bodyEl)
|
|
@@ -805,6 +805,21 @@ describe('applyVarStackWidth', () => {
|
|
|
805
805
|
expect(wrapper.style.maxWidth).toBe('100%')
|
|
806
806
|
})
|
|
807
807
|
|
|
808
|
+
it.each([['checkbox', 64], ['boolean-select', 104]] as const)('keeps compact %s controls usable without a header', (kind, width) => {
|
|
809
|
+
const recorder = document.createElement('div')
|
|
810
|
+
recorder.className = 'aimd-protocol-recorder--compact'
|
|
811
|
+
const wrapper = document.createElement('span')
|
|
812
|
+
wrapper.className = 'aimd-rec-inline--var-stacked'
|
|
813
|
+
const control = document.createElement(kind === 'checkbox' ? 'input' : 'select')
|
|
814
|
+
wrapper.appendChild(control)
|
|
815
|
+
recorder.appendChild(wrapper)
|
|
816
|
+
document.body.appendChild(recorder)
|
|
817
|
+
|
|
818
|
+
applyVarStackWidth(control, kind)
|
|
819
|
+
|
|
820
|
+
expect(wrapper.style.width).toBe(`${width}px`)
|
|
821
|
+
})
|
|
822
|
+
|
|
808
823
|
it('lets stacked vars inside markdown tables size from content before wrapping', () => {
|
|
809
824
|
const table = document.createElement('table')
|
|
810
825
|
const row = document.createElement('tr')
|
|
@@ -11,6 +11,16 @@ import {
|
|
|
11
11
|
} from '../workbenchFieldEditing'
|
|
12
12
|
|
|
13
13
|
describe('workbenchFieldEditing', () => {
|
|
14
|
+
it('edits the complete checkpoint without treating quoted templates as nested fields', () => {
|
|
15
|
+
const raw = '{{check|reading, title="Review {{var|not_a_field}}", checked_message="Keep {{ref_var|wait_s}} literal."}}'
|
|
16
|
+
const content = `Before ${raw} After {{ref_var|wait_s}}.`
|
|
17
|
+
const fields = scanWorkbenchFields(content)
|
|
18
|
+
expect(fields).toHaveLength(1)
|
|
19
|
+
expect(fields[0]).toMatchObject({ id: 'reading', raw, start: 7, end: 7 + raw.length })
|
|
20
|
+
expect(updateWorkbenchFieldId(content, fields[0], 'review')).toBe(content.replace('check|reading', 'check|review'))
|
|
21
|
+
expect(deleteWorkbenchField(content, fields[0])).toBe('Before After {{ref_var|wait_s}}.')
|
|
22
|
+
})
|
|
23
|
+
|
|
14
24
|
it('scans recorder-editable field descriptors from inline AIMD tags and quiz blocks', () => {
|
|
15
25
|
const content = [
|
|
16
26
|
'Sample: {{var|sample_name: str = "abc", title = "Sample"}}',
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { inject, ref, type InjectionKey, type Ref } from 'vue'
|
|
2
|
+
|
|
3
|
+
export const fieldDisplayKey: InjectionKey<Readonly<Ref<'compact' | 'detailed'>>> = Symbol('aimd-field-display')
|
|
4
|
+
|
|
5
|
+
export function useFieldPresentation() {
|
|
6
|
+
return inject(fieldDisplayKey, ref<'compact' | 'detailed'>('detailed'))
|
|
7
|
+
}
|
|
@@ -223,6 +223,7 @@ export function useFieldRendering(options: FieldRenderingOptions) {
|
|
|
223
223
|
})
|
|
224
224
|
if (inputKind === "boolean-select") return null
|
|
225
225
|
if (isNullableVarType(type) && inputKind !== "scalar-list" && inputKind !== "checkbox") return null
|
|
226
|
+
if (inputKind === "multi-select") return []
|
|
226
227
|
if (inputKind === "checkbox") return false
|
|
227
228
|
if (inputKind === "scalar-list") return []
|
|
228
229
|
if (inputKind === "dna") return normalizeDnaSequenceValue(undefined)
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { resolveAimdTypePlugin } from '../type-plugins'
|
|
9
9
|
import { isAimdCodeEditorType } from '../code-types'
|
|
10
|
+
import { parseVarListEnumValues } from '@airalogy/aimd-core/parser'
|
|
10
11
|
import {
|
|
11
12
|
getAimdFileDisplayName,
|
|
12
13
|
getAimdFileInputConfig,
|
|
@@ -14,7 +15,9 @@ import {
|
|
|
14
15
|
isAimdAiralogyFileId,
|
|
15
16
|
isAimdFileLikeType,
|
|
16
17
|
isKnownAimdFileTypeName,
|
|
18
|
+
isAimdNullableType,
|
|
17
19
|
normalizeAimdTypeName,
|
|
20
|
+
unwrapAimdNullableType,
|
|
18
21
|
toAimdBooleanValue,
|
|
19
22
|
unwrapAimdStructuredValue,
|
|
20
23
|
type AimdAssetKind,
|
|
@@ -88,7 +91,10 @@ export function getFileInputConfig(
|
|
|
88
91
|
kwargs?: Record<string, unknown>,
|
|
89
92
|
fieldMeta?: AimdFieldMeta,
|
|
90
93
|
): FileInputConfig {
|
|
91
|
-
|
|
94
|
+
const baseType = unwrapAimdNullableType(type)
|
|
95
|
+
const config = getAimdFileInputConfig(baseType, kwargs, fieldMeta)
|
|
96
|
+
if (normalizeAimdTypeName(baseType) === 'fileiddna' && !config.accept) return { ...config, accept: '.dna' }
|
|
97
|
+
return config
|
|
92
98
|
}
|
|
93
99
|
|
|
94
100
|
export function isFileLikeVarType(
|
|
@@ -233,108 +239,12 @@ export function normalizeVarTypeName(type: string | undefined): string {
|
|
|
233
239
|
return normalizeAimdTypeName(type)
|
|
234
240
|
}
|
|
235
241
|
|
|
236
|
-
function splitTopLevelTypeUnion(annotation: string): string[] {
|
|
237
|
-
const parts: string[] = []
|
|
238
|
-
let depth = 0
|
|
239
|
-
let quote: string | null = null
|
|
240
|
-
let current = ""
|
|
241
|
-
|
|
242
|
-
for (let index = 0; index < annotation.length; index += 1) {
|
|
243
|
-
const char = annotation[index]
|
|
244
|
-
const previous = annotation[index - 1]
|
|
245
|
-
|
|
246
|
-
if (quote) {
|
|
247
|
-
current += char
|
|
248
|
-
if (char === quote && previous !== "\\") {
|
|
249
|
-
quote = null
|
|
250
|
-
}
|
|
251
|
-
continue
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
if (char === "\"" || char === "'") {
|
|
255
|
-
quote = char
|
|
256
|
-
current += char
|
|
257
|
-
continue
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
if (char === "[" || char === "(" || char === "{") {
|
|
261
|
-
depth += 1
|
|
262
|
-
current += char
|
|
263
|
-
continue
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
if (char === "]" || char === ")" || char === "}") {
|
|
267
|
-
depth = Math.max(0, depth - 1)
|
|
268
|
-
current += char
|
|
269
|
-
continue
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
if (char === "|" && depth === 0) {
|
|
273
|
-
parts.push(current.trim())
|
|
274
|
-
current = ""
|
|
275
|
-
continue
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
current += char
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
if (current.trim()) {
|
|
282
|
-
parts.push(current.trim())
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
return parts.length > 0 ? parts : [annotation.trim()]
|
|
286
|
-
}
|
|
287
|
-
|
|
288
242
|
function canonicalizeTypeExpression(type: string | undefined): string {
|
|
289
243
|
return typeof type === "string" ? type.trim().replace(/\s+/g, "").toLowerCase() : ""
|
|
290
244
|
}
|
|
291
245
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
for (let index = 0; index < 4; index += 1) {
|
|
296
|
-
const compact = canonicalizeTypeExpression(raw)
|
|
297
|
-
const optionalMatch = compact.match(/^(?:typing\.)?optional\[(.*)\]$/)
|
|
298
|
-
if (optionalMatch) {
|
|
299
|
-
raw = optionalMatch[1]
|
|
300
|
-
continue
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
const unionParts = splitTopLevelTypeUnion(raw)
|
|
304
|
-
if (unionParts.length > 1) {
|
|
305
|
-
const valueParts = unionParts.filter(part => {
|
|
306
|
-
const normalized = canonicalizeTypeExpression(part)
|
|
307
|
-
return normalized !== "none" && normalized !== "null" && normalized !== "undefined"
|
|
308
|
-
})
|
|
309
|
-
if (valueParts.length === 1) {
|
|
310
|
-
raw = valueParts[0]
|
|
311
|
-
continue
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
break
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
return raw
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
export function isNullableVarType(type: string | undefined): boolean {
|
|
322
|
-
const raw = typeof type === "string" ? type.trim() : ""
|
|
323
|
-
if (!raw) {
|
|
324
|
-
return false
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
const compact = canonicalizeTypeExpression(raw)
|
|
328
|
-
if (/^(?:typing\.)?optional\[.*\]$/.test(compact)) {
|
|
329
|
-
return true
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
const unionParts = splitTopLevelTypeUnion(raw)
|
|
333
|
-
return unionParts.length > 1 && unionParts.some(part => {
|
|
334
|
-
const normalized = canonicalizeTypeExpression(part)
|
|
335
|
-
return normalized === "none" || normalized === "null" || normalized === "undefined"
|
|
336
|
-
})
|
|
337
|
-
}
|
|
246
|
+
const unwrapOptionalTypeAnnotation = unwrapAimdNullableType
|
|
247
|
+
export const isNullableVarType = isAimdNullableType
|
|
338
248
|
|
|
339
249
|
export function isNumericVarType(type: string | undefined): boolean {
|
|
340
250
|
const normalized = normalizeVarTypeName(unwrapOptionalTypeAnnotation(type))
|
|
@@ -554,6 +464,8 @@ export function getVarInputKind(type: string | undefined, options: VarInputKindO
|
|
|
554
464
|
return "scalar-list"
|
|
555
465
|
}
|
|
556
466
|
|
|
467
|
+
if (parseVarListEnumValues(type).length) return "multi-select"
|
|
468
|
+
|
|
557
469
|
const unwrappedType = unwrapOptionalTypeAnnotation(type)
|
|
558
470
|
const normalized = normalizeVarTypeName(unwrappedType)
|
|
559
471
|
|
|
@@ -1093,6 +1005,10 @@ export function parseVarInputValue(
|
|
|
1093
1005
|
|
|
1094
1006
|
function getVarControlMinWidth(inputKind: VarInputKind): number {
|
|
1095
1007
|
switch (inputKind) {
|
|
1008
|
+
case "checkbox":
|
|
1009
|
+
return 64
|
|
1010
|
+
case "boolean-select":
|
|
1011
|
+
return 104
|
|
1096
1012
|
case "textarea":
|
|
1097
1013
|
case "dna":
|
|
1098
1014
|
case "code":
|
|
@@ -1237,6 +1153,7 @@ function measureFieldNameWidth(name: HTMLElement): number {
|
|
|
1237
1153
|
}
|
|
1238
1154
|
|
|
1239
1155
|
export function measureVarLabelWidth(wrapper: HTMLElement): number {
|
|
1156
|
+
if (wrapper.closest('.aimd-protocol-recorder--compact')) return 0
|
|
1240
1157
|
const scope = wrapper.querySelector(".aimd-field__scope--var") as HTMLElement | null
|
|
1241
1158
|
const name = wrapper.querySelector(".aimd-field__name") as HTMLElement | null
|
|
1242
1159
|
const id = wrapper.querySelector(".aimd-field__id") as HTMLElement | null
|
|
@@ -1269,12 +1186,14 @@ export function measureSingleLineControlWidth(input: HTMLElement): number {
|
|
|
1269
1186
|
const fontStyle = computed.fontStyle || "normal"
|
|
1270
1187
|
ctx.font = `${fontStyle} ${fontWeight} ${fontSize} ${fontFamily}`
|
|
1271
1188
|
|
|
1272
|
-
const text =
|
|
1189
|
+
const text = input instanceof HTMLSelectElement
|
|
1190
|
+
? Array.from(input.options).map(option => option.text).reduce((longest, option) => ctx.measureText(option).width > ctx.measureText(longest).width ? option : longest, '')
|
|
1191
|
+
: "value" in input
|
|
1273
1192
|
? ((input as HTMLInputElement | HTMLTextAreaElement).value || (input as HTMLInputElement | HTMLTextAreaElement).placeholder || "")
|
|
1274
1193
|
: ((input.textContent || "").trim())
|
|
1275
1194
|
const textWidth = ctx.measureText(text).width
|
|
1276
1195
|
const padding = parsePx(computed.paddingLeft) + parsePx(computed.paddingRight)
|
|
1277
|
-
return textWidth + padding + 2
|
|
1196
|
+
return textWidth + padding + (input instanceof HTMLSelectElement ? 26 : 2)
|
|
1278
1197
|
}
|
|
1279
1198
|
|
|
1280
1199
|
function measureOptionalControlSlotWidth(wrapper: HTMLElement, selector: string, fallbackWidth: number): number {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { findAimdInlineTemplates } from '@airalogy/aimd-core/parser'
|
|
2
|
+
|
|
1
3
|
export type AimdWorkbenchFieldType = 'var' | 'var_table' | 'step' | 'check' | 'quiz'
|
|
2
4
|
export type AimdWorkbenchFieldSourceKind = 'inline' | 'block'
|
|
3
5
|
|
|
@@ -16,7 +18,6 @@ export interface AimdWorkbenchFieldDescriptor {
|
|
|
16
18
|
quizType?: string
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
const INLINE_FIELD_PATTERN = /\{\{(var_table|var|step|check)\s*\|\s*([^}]+)\}\}/g
|
|
20
21
|
const QUIZ_BLOCK_PATTERN = /```quiz[^\n]*\n[\s\S]*?\n```/g
|
|
21
22
|
|
|
22
23
|
function trimYamlScalar(value: string): string {
|
|
@@ -427,12 +428,9 @@ function formatBlockInsertion(content: string, offset: number, syntax: string):
|
|
|
427
428
|
export function scanWorkbenchFields(content: string): AimdWorkbenchFieldDescriptor[] {
|
|
428
429
|
const fields: AimdWorkbenchFieldDescriptor[] = []
|
|
429
430
|
|
|
430
|
-
for (const match of content
|
|
431
|
-
const raw = match
|
|
432
|
-
|
|
433
|
-
const inner = match[2]
|
|
434
|
-
const start = match.index ?? 0
|
|
435
|
-
const end = start + raw.length
|
|
431
|
+
for (const match of findAimdInlineTemplates(content)) {
|
|
432
|
+
const { raw, type: outerType, content: inner, start, end } = match
|
|
433
|
+
if (!['var', 'var_table', 'step', 'check'].includes(outerType)) continue
|
|
436
434
|
const segment = maybeExpandToStandaloneSegment(content, start, end, 'inline')
|
|
437
435
|
|
|
438
436
|
if (outerType === 'var' && !looksLikeVarTable(inner)) {
|
package/src/index.ts
CHANGED
package/src/record/validation.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ExtractedAimdFields } from "@airalogy/aimd-core/types"
|
|
2
2
|
import { getAimdBuiltInTypeMetadata } from "@airalogy/aimd-core/utils"
|
|
3
|
+
import { parseVarListEnumValues } from '@airalogy/aimd-core/parser'
|
|
3
4
|
import type { ErrorObject } from "ajv"
|
|
4
5
|
import Ajv2020 from "ajv/dist/2020"
|
|
5
6
|
import addFormats from "ajv-formats"
|
|
@@ -698,6 +699,11 @@ function validateValue(
|
|
|
698
699
|
addIssue(issues, fieldKey, section, "enum", options.messages.enum(label), value, details)
|
|
699
700
|
}
|
|
700
701
|
|
|
702
|
+
const allowedItems = parseVarListEnumValues(type)
|
|
703
|
+
if (allowedItems.length && Array.isArray(value) && value.some(item => !allowedItems.some(option => Object.is(option, item)))) {
|
|
704
|
+
addIssue(issues, fieldKey, section, "enum", options.messages.enum(label), value, details)
|
|
705
|
+
}
|
|
706
|
+
|
|
701
707
|
if (!schemaCovered) {
|
|
702
708
|
const expectedType = getExpectedRuntimeType(type)
|
|
703
709
|
if (!valueMatchesType(value, expectedType)) {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
.aimd-protocol-recorder--compact .aimd-rec-inline--var-stacked {
|
|
2
|
+
border-color: #bbc7d5;
|
|
3
|
+
border-radius: 4px;
|
|
4
|
+
background: white;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.aimd-protocol-recorder--compact .aimd-rec-inline__compact-actions {
|
|
8
|
+
display: flex;
|
|
9
|
+
justify-content: flex-end;
|
|
10
|
+
padding: 4px;
|
|
11
|
+
border-bottom: 1px solid #e4e9ef;
|
|
12
|
+
background: #f8fafb;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.aimd-protocol-recorder--compact .aimd-rec-inline__checkbox-row {
|
|
16
|
+
gap: 6px;
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.aimd-protocol-recorder--compact .aimd-rec-inline__boolean-state {
|
|
21
|
+
min-width: 2em;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.aimd-protocol-recorder--compact .aimd-rec-inline-table > .aimd-field__header > :is(.aimd-field__scope, .aimd-field__name) {
|
|
25
|
+
display: none;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.aimd-protocol-recorder--compact .aimd-rec-inline-table > .aimd-field__header:not(:has(.aimd-rec-inline-table__header-actions)) {
|
|
29
|
+
display: none;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.aimd-protocol-recorder--compact .aimd-rec-inline-table .aimd-field__key {
|
|
33
|
+
display: none;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.aimd-protocol-recorder--compact :is(.aimd-markdown-field, .aimd-rec-inline--var-dna) > .aimd-field__label > :is(.aimd-field__scope, .aimd-field__id),
|
|
37
|
+
.aimd-protocol-recorder--compact .aimd-rec-inline--var-dna > .aimd-field__label,
|
|
38
|
+
.aimd-protocol-recorder--compact .aimd-rec-collector__header > :is(.aimd-field__scope, .aimd-rec-collector__identity) {
|
|
39
|
+
display: none;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.aimd-protocol-recorder--compact .aimd-markdown-field > .aimd-field__label {
|
|
43
|
+
background: #f8fafb;
|
|
44
|
+
border-bottom-color: #e4e9ef;
|
|
45
|
+
}
|
|
@@ -443,6 +443,10 @@
|
|
|
443
443
|
}
|
|
444
444
|
.aimd-protocol-recorder__content .aimd-rec-inline--var-stacked--textarea { min-width: 0; }
|
|
445
445
|
.aimd-protocol-recorder__content .aimd-rec-inline--var-stacked--checkbox { width: fit-content; min-width: 0; }
|
|
446
|
+
.aimd-protocol-recorder__content .aimd-rec-inline--multi-select {
|
|
447
|
+
max-width: calc(100% - 6px);
|
|
448
|
+
box-sizing: border-box;
|
|
449
|
+
}
|
|
446
450
|
.aimd-protocol-recorder__content .aimd-rec-inline--var-stacked--scalar-list {
|
|
447
451
|
display: flex;
|
|
448
452
|
width: 100%;
|
|
@@ -1853,13 +1857,18 @@
|
|
|
1853
1857
|
min-width: 0;
|
|
1854
1858
|
}
|
|
1855
1859
|
.aimd-protocol-recorder__content .aimd-rec-inline__step-num { font-weight: 600; color: #9a5800; }
|
|
1856
|
-
.aimd-protocol-recorder__content .aimd-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1860
|
+
.aimd-protocol-recorder__content .aimd-step-field__identity {
|
|
1861
|
+
display: inline-flex;
|
|
1862
|
+
flex: 1 1 auto;
|
|
1863
|
+
flex-direction: column;
|
|
1864
|
+
min-width: 0;
|
|
1865
|
+
gap: 2px;
|
|
1861
1866
|
overflow-wrap: anywhere;
|
|
1862
1867
|
}
|
|
1868
|
+
.aimd-protocol-recorder__content .aimd-step-field__title { font-size: 16px; font-weight: 600; line-height: 1.4; color: var(--rec-text); }
|
|
1869
|
+
.aimd-protocol-recorder__content .aimd-step-field__id { font: 12px/1.4 var(--rec-font-mono, monospace); color: #667085; }
|
|
1870
|
+
.aimd-protocol-recorder__content .aimd-rec-inline--step .aimd-rec-inline__check-wrap { flex-wrap: nowrap; align-items: center; max-width: 100%; }
|
|
1871
|
+
.aimd-protocol-recorder__content .aimd-rec-inline--step .aimd-rec-inline__check-wrap > :not(.aimd-step-field__identity) { flex-shrink: 0; }
|
|
1863
1872
|
.aimd-protocol-recorder__content .aimd-step-timer__pill {
|
|
1864
1873
|
display: inline-flex;
|
|
1865
1874
|
align-items: center;
|
package/src/styles/recorder.css
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
@import "@airalogy/aimd-renderer/styles";
|
|
8
8
|
@import "./recorder-surface.css";
|
|
9
9
|
@import "./collector-field.css";
|
|
10
|
+
@import "./recorder-compact.css";
|
|
10
11
|
|
|
11
12
|
/* Recorder-specific reference wrappers */
|
|
12
13
|
.aimd-ref--step .research-step__sequence {
|
|
@@ -664,3 +665,6 @@ td .field__wrapper--tagged {
|
|
|
664
665
|
.aimd-rec-table-cell-field .aimd-rec-validation-message {
|
|
665
666
|
white-space: normal;
|
|
666
667
|
}
|
|
668
|
+
.aimd-check-field__identity { display: inline-flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
|
|
669
|
+
.aimd-check-field__title { font-size: 14px; font-weight: 600; line-height: 1.5; }
|
|
670
|
+
.aimd-check-field__identity .aimd-check-field__key { font: 12px/1.4 monospace; color: #667085; }
|
package/src/type-utils.ts
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { normalizeAimdTypeName as normalizeType, unwrapAimdNullableType } from '@airalogy/aimd-core/utils'
|
|
2
|
+
|
|
3
|
+
export function normalizeAimdTypeName(value: unknown, fallback = 'str'): string {
|
|
4
|
+
return normalizeType(unwrapAimdNullableType(value), fallback)
|
|
5
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -258,7 +258,7 @@ export type AimdCollectorPermissionHandler = (
|
|
|
258
258
|
request: AimdCollectorPermissionRequest,
|
|
259
259
|
) => AimdCollectorPermissionDecision | Promise<AimdCollectorPermissionDecision>
|
|
260
260
|
|
|
261
|
-
export type AimdVarInputKind = "text" | "number" | "checkbox" | "boolean-select" | "textarea" | "scalar-list" | "entity-ref" | "resource-ref" | "date" | "datetime" | "time" | "dna" | "code" | "file"
|
|
261
|
+
export type AimdVarInputKind = "text" | "number" | "checkbox" | "boolean-select" | "multi-select" | "textarea" | "scalar-list" | "entity-ref" | "resource-ref" | "date" | "datetime" | "time" | "dna" | "code" | "file"
|
|
262
262
|
export type AimdStepDetailDisplay = "auto" | "always"
|
|
263
263
|
export type AimdChoiceOptionExplanationMode = "hidden" | "selected" | "submitted" | "graded"
|
|
264
264
|
export type AimdScaleGradeDisplayMode = "hidden" | "completed" | "submitted" | "graded"
|