@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.
- package/README.md +11 -10
- package/README.zh-CN.md +11 -10
- package/dist/AimdCodeField-BQUuM-EF.js +182 -0
- package/dist/{AimdDnaSequenceField-D6ZgCDpp.js → AimdDnaSequenceField-KZU2Zj3E.js} +2 -2
- package/dist/{AimdEditor.vue_vue_type_style_index_0_lang-B5Tq4zPV.js → AimdEditor.vue_vue_type_style_index_0_lang-CzfYPp5r.js} +3922 -3829
- package/dist/AimdMarkdownField-t2d8uOeU.js +254 -0
- package/dist/AimdMarkdownNoteField-_h1oZSwH.js +259 -0
- package/dist/{_commonjsHelpers-CZXJ37nu.js → _commonjsHelpers-B5RozER-.js} +2 -2
- package/dist/aimd-recorder.css +1 -1
- package/dist/arc-DS_ocYoe.js +83 -0
- package/dist/architectureDiagram-3BPJPVTR-Dq2W8_tb.js +4692 -0
- package/dist/blockDiagram-GPEHLZMM-B4hnSAF_.js +2425 -0
- package/dist/c4Diagram-AAUBKEIU-CbffqNLY.js +1577 -0
- package/dist/channel-CtXnYrAk.js +5 -0
- package/dist/chunk-2J33WTMH-CROScrt5.js +19 -0
- package/dist/chunk-4BX2VUAB-DTmsQu5_.js +8 -0
- package/dist/chunk-55IACEB6-B5wDJzeX.js +8 -0
- package/dist/chunk-727SXJPM-CfyltY6o.js +1528 -0
- package/dist/chunk-AQP2D5EJ-B8274EYy.js +1387 -0
- package/dist/chunk-FMBD7UC4-CT_FK-SH.js +19 -0
- package/dist/chunk-ND2GUHAM-g9GulPi-.js +68 -0
- package/dist/chunk-QZHKN3VN-Di5HEktz.js +15 -0
- package/dist/classDiagram-4FO5ZUOK-BVUr246k.js +16 -0
- package/dist/classDiagram-v2-Q7XG4LA2-BVUr246k.js +16 -0
- package/dist/components.js +3279 -2216
- package/dist/composables.js +92 -68
- package/dist/cose-bilkent-S5V4N54A-GJ4IOO6v.js +2609 -0
- package/dist/cytoscape.esm-r59gEWFs.js +18710 -0
- package/dist/dagre-BM42HDAG-oL7Br44o.js +445 -0
- package/dist/defaultLocale-BgPVtth8.js +171 -0
- package/dist/diagram-2AECGRRQ-DtoCG_N4.js +217 -0
- package/dist/diagram-5GNKFQAL-f8QNdS7L.js +123 -0
- package/dist/diagram-KO2AKTUF-CsJOW_AX.js +461 -0
- package/dist/diagram-LMA3HP47-xmEKNZ7y.js +142 -0
- package/dist/diagram-OG6HWLK6-unpC7vo8.js +528 -0
- package/dist/erDiagram-TEJ5UH35-BGzFnCJD.js +899 -0
- package/dist/flowDiagram-I6XJVG4X-LBFhDnOs.js +1628 -0
- package/dist/ganttDiagram-6RSMTGT7-CFBc-jPD.js +2707 -0
- package/dist/gitGraphDiagram-PVQCEYII-BLduh-Rb.js +815 -0
- package/dist/graph-DdlKE625.js +1510 -0
- package/dist/index.js +104 -80
- package/dist/infoDiagram-5YYISTIA-CLQQI6zM.js +24 -0
- package/dist/init-DjUOC4st.js +16 -0
- package/dist/ishikawaDiagram-YF4QCWOH-CStdYBmW.js +621 -0
- package/dist/journeyDiagram-JHISSGLW-B6mRTzoE.js +834 -0
- package/dist/kanban-definition-UN3LZRKU-C-vnN5v4.js +724 -0
- package/dist/katex-DNob3HGn.js +11690 -0
- package/dist/layout-DDt0fz-M.js +1703 -0
- package/dist/linear-C-IAFdOt.js +259 -0
- package/dist/mermaid.core-CuZ3nINf.js +15940 -0
- package/dist/mindmap-definition-RKZ34NQL-TSZ1Vb3z.js +827 -0
- package/dist/ordinal-B6-f3MAq.js +61 -0
- package/dist/pieDiagram-4H26LBE5-DYok-1-k.js +163 -0
- package/dist/quadrantDiagram-W4KKPZXB-Cg856sbH.js +1024 -0
- package/dist/requirementDiagram-4Y6WPE33-BN9fGdlJ.js +882 -0
- package/dist/sankeyDiagram-5OEKKPKP-CDqTgonY.js +847 -0
- package/dist/sequenceDiagram-3UESZ5HK-Chjrc0-W.js +2891 -0
- package/dist/stateDiagram-AJRCARHV-DRyLHrdr.js +263 -0
- package/dist/stateDiagram-v2-BHNVJYJU-CZTIDHid.js +16 -0
- package/dist/timeline-definition-PNZ67QCA-Bc3D9AAG.js +1055 -0
- package/dist/{useFieldRendering-xLajJhyA.js → useCodeBlockRendering-qA6gj4vz.js} +3035 -2254
- package/dist/useMonacoAutoHeight-D4T-El3J.js +66 -0
- package/dist/vennDiagram-CIIHVFJN-CYAul48m.js +1557 -0
- package/dist/wardley-L42UT6IY-D7b2ujEZ.js +22512 -0
- package/dist/wardleyDiagram-YWT4CUSO-B7Tg0MG9.js +675 -0
- package/dist/xychartDiagram-2RQKCTM6-xWYVEqth.js +1342 -0
- package/package.json +9 -8
- package/src/__tests__/assigner-runner-dependent-data.test.ts +32 -0
- package/src/__tests__/markdown-field.test.ts +150 -1
- package/src/__tests__/markdown-note-field.test.ts +86 -3
- package/src/__tests__/recorder-assigner-control.test.ts +844 -0
- package/src/__tests__/recorder-editor.test.ts +17 -0
- package/src/__tests__/recorder-markdown-assigner-integration.test.ts +49 -0
- package/src/__tests__/step-field.test.ts +47 -1
- package/src/__tests__/type-plugins.test.ts +1 -0
- package/src/__tests__/var-field-render.test.ts +741 -1
- package/src/components/AimdCodeField.vue +24 -5
- package/src/components/AimdMarkdownField.vue +548 -11
- package/src/components/AimdMarkdownNoteField.vue +241 -30
- package/src/components/AimdRecorder.vue +1521 -95
- package/src/components/AimdRecorderEditor.vue +276 -8
- package/src/components/AimdRecorderWysiwygFieldHost.vue +6 -0
- package/src/components/AimdRecorderWysiwygSurface.vue +32 -0
- package/src/components/AimdStepCheckField.vue +82 -18
- package/src/components/AimdVarField.vue +694 -25
- package/src/components/AimdVarTableField.vue +283 -110
- package/src/components/icons/AimdAssignerCalculatorIcon.vue +18 -0
- package/src/components/icons/AimdAssignerCloudStatusIcon.vue +22 -0
- package/src/components/recorderMilkdownPlugin.ts +14 -0
- package/src/composables/__tests__/useRecordState.test.ts +86 -0
- package/src/composables/__tests__/useVarHelpers.test.ts +133 -0
- package/src/composables/index.ts +27 -1
- package/src/composables/useAssignerRunner.ts +376 -0
- package/src/composables/useCodeBlockRendering.ts +51 -0
- package/src/composables/useFieldRendering.ts +32 -4
- package/src/composables/useMonacoAutoHeight.ts +127 -0
- package/src/composables/useRecordState.ts +22 -3
- package/src/composables/useVarHelpers.ts +377 -9
- package/src/index.ts +13 -0
- package/src/locales.ts +45 -0
- package/src/styles/aimd.css +151 -1
- package/src/type-plugins.ts +7 -0
- package/src/types.ts +93 -2
- package/dist/AimdCodeField-DC3DPvgc.js +0 -172
- package/dist/AimdMarkdownField-BJ20QtO8.js +0 -67
- package/dist/AimdMarkdownNoteField-DwAQhoyk.js +0 -186
|
@@ -8,7 +8,14 @@
|
|
|
8
8
|
import { resolveAimdTypePlugin } from '../type-plugins'
|
|
9
9
|
import { isAimdCodeEditorType } from '../code-types'
|
|
10
10
|
import { normalizeAimdTypeName } from '../type-utils'
|
|
11
|
-
import type {
|
|
11
|
+
import type {
|
|
12
|
+
AimdFieldMeta,
|
|
13
|
+
AimdSelectedFileValue,
|
|
14
|
+
AimdTypePlugin,
|
|
15
|
+
AimdTypePluginParseContext,
|
|
16
|
+
AimdTypePluginValueContext,
|
|
17
|
+
AimdVarInputKind,
|
|
18
|
+
} from '../types'
|
|
12
19
|
|
|
13
20
|
// ---------------------------------------------------------------------------
|
|
14
21
|
// Types
|
|
@@ -19,6 +26,8 @@ export type VarInputKind = AimdVarInputKind
|
|
|
19
26
|
export interface VarInputKindOptions {
|
|
20
27
|
inputType?: string
|
|
21
28
|
codeLanguage?: string
|
|
29
|
+
kwargs?: Record<string, unknown>
|
|
30
|
+
fieldMeta?: AimdFieldMeta
|
|
22
31
|
typePlugin?: AimdTypePlugin
|
|
23
32
|
typePlugins?: AimdTypePlugin[]
|
|
24
33
|
}
|
|
@@ -26,9 +35,10 @@ export interface VarInputKindOptions {
|
|
|
26
35
|
export interface VarInputValueOptions extends VarInputKindOptions {
|
|
27
36
|
type?: string
|
|
28
37
|
nodeFieldKey?: string
|
|
29
|
-
fieldMeta?: Record<string, unknown>
|
|
30
38
|
}
|
|
31
39
|
|
|
40
|
+
export type AimdVarEnumOption = NonNullable<AimdFieldMeta["enumOptions"]>[number]
|
|
41
|
+
|
|
32
42
|
export interface AimdNumericFieldConstraints {
|
|
33
43
|
gt?: number
|
|
34
44
|
ge?: number
|
|
@@ -43,6 +53,290 @@ export interface NumericInputAttributes {
|
|
|
43
53
|
step?: number
|
|
44
54
|
}
|
|
45
55
|
|
|
56
|
+
export type FileInputDisplayKind = "file" | "csv" | "image" | "audio" | "video" | "document" | "text"
|
|
57
|
+
|
|
58
|
+
export interface FileInputConfig {
|
|
59
|
+
kind: FileInputDisplayKind
|
|
60
|
+
accept?: string
|
|
61
|
+
badge: string
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const FILE_CONFIG_BY_NORMALIZED_TYPE: Record<string, FileInputConfig> = {
|
|
65
|
+
file: { kind: "file", badge: "FILE" },
|
|
66
|
+
upload: { kind: "file", badge: "FILE" },
|
|
67
|
+
csv: { kind: "csv", accept: ".csv,text/csv", badge: "CSV" },
|
|
68
|
+
fileidcsv: { kind: "csv", accept: ".csv,text/csv", badge: "CSV" },
|
|
69
|
+
image: { kind: "image", accept: "image/*", badge: "IMG" },
|
|
70
|
+
fileidpng: { kind: "image", accept: ".png,image/png", badge: "IMG" },
|
|
71
|
+
fileidjpg: { kind: "image", accept: ".jpg,.jpeg,image/jpeg", badge: "IMG" },
|
|
72
|
+
fileidjpeg: { kind: "image", accept: ".jpg,.jpeg,image/jpeg", badge: "IMG" },
|
|
73
|
+
fileidsvg: { kind: "image", accept: ".svg,image/svg+xml", badge: "IMG" },
|
|
74
|
+
fileidwebp: { kind: "image", accept: ".webp,image/webp", badge: "IMG" },
|
|
75
|
+
fileidtiff: { kind: "image", accept: ".tif,.tiff,image/tiff", badge: "IMG" },
|
|
76
|
+
audio: { kind: "audio", accept: "audio/*", badge: "AUD" },
|
|
77
|
+
fileidmp3: { kind: "audio", accept: ".mp3,audio/mpeg", badge: "AUD" },
|
|
78
|
+
video: { kind: "video", accept: "video/*", badge: "VID" },
|
|
79
|
+
fileidmp4: { kind: "video", accept: ".mp4,video/mp4", badge: "VID" },
|
|
80
|
+
fileidaimd: { kind: "text", accept: ".aimd,text/plain", badge: "AIMD" },
|
|
81
|
+
fileidmd: { kind: "text", accept: ".md,text/markdown,text/plain", badge: "MD" },
|
|
82
|
+
fileidtxt: { kind: "text", accept: ".txt,text/plain", badge: "TXT" },
|
|
83
|
+
fileidjson: { kind: "text", accept: ".json,application/json", badge: "JSON" },
|
|
84
|
+
fileiddocx: { kind: "document", accept: ".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document", badge: "DOC" },
|
|
85
|
+
fileidxlsx: { kind: "document", accept: ".xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", badge: "XLS" },
|
|
86
|
+
fileidpptx: { kind: "document", accept: ".pptx,application/vnd.openxmlformats-officedocument.presentationml.presentation", badge: "PPT" },
|
|
87
|
+
fileidpdf: { kind: "document", accept: ".pdf,application/pdf", badge: "PDF" },
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const FILE_KIND_BY_EXTENSION: Record<string, FileInputDisplayKind> = {
|
|
91
|
+
csv: "csv",
|
|
92
|
+
png: "image",
|
|
93
|
+
jpg: "image",
|
|
94
|
+
jpeg: "image",
|
|
95
|
+
svg: "image",
|
|
96
|
+
webp: "image",
|
|
97
|
+
tif: "image",
|
|
98
|
+
tiff: "image",
|
|
99
|
+
mp3: "audio",
|
|
100
|
+
wav: "audio",
|
|
101
|
+
m4a: "audio",
|
|
102
|
+
mp4: "video",
|
|
103
|
+
mov: "video",
|
|
104
|
+
webm: "video",
|
|
105
|
+
aimd: "text",
|
|
106
|
+
md: "text",
|
|
107
|
+
txt: "text",
|
|
108
|
+
json: "text",
|
|
109
|
+
pdf: "document",
|
|
110
|
+
docx: "document",
|
|
111
|
+
xlsx: "document",
|
|
112
|
+
pptx: "document",
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const FILE_BADGE_BY_KIND: Record<FileInputDisplayKind, string> = {
|
|
116
|
+
file: "FILE",
|
|
117
|
+
csv: "CSV",
|
|
118
|
+
image: "IMG",
|
|
119
|
+
audio: "AUD",
|
|
120
|
+
video: "VID",
|
|
121
|
+
document: "DOC",
|
|
122
|
+
text: "TXT",
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const MIME_BY_EXTENSION: Record<string, string> = {
|
|
126
|
+
csv: "text/csv",
|
|
127
|
+
png: "image/png",
|
|
128
|
+
jpg: "image/jpeg",
|
|
129
|
+
jpeg: "image/jpeg",
|
|
130
|
+
svg: "image/svg+xml",
|
|
131
|
+
webp: "image/webp",
|
|
132
|
+
tif: "image/tiff",
|
|
133
|
+
tiff: "image/tiff",
|
|
134
|
+
mp3: "audio/mpeg",
|
|
135
|
+
wav: "audio/wav",
|
|
136
|
+
m4a: "audio/mp4",
|
|
137
|
+
mp4: "video/mp4",
|
|
138
|
+
webm: "video/webm",
|
|
139
|
+
md: "text/markdown",
|
|
140
|
+
txt: "text/plain",
|
|
141
|
+
aimd: "text/plain",
|
|
142
|
+
json: "application/json",
|
|
143
|
+
pdf: "application/pdf",
|
|
144
|
+
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
145
|
+
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
146
|
+
pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const AIRALOGY_FILE_ID_RE = /^airalogy\.id\.file\.[A-Za-z0-9_-]+$/i
|
|
150
|
+
|
|
151
|
+
function getStringFromRecord(record: Record<string, unknown> | undefined, keys: string[]): string | undefined {
|
|
152
|
+
if (!record) {
|
|
153
|
+
return undefined
|
|
154
|
+
}
|
|
155
|
+
for (const key of keys) {
|
|
156
|
+
const value = record[key]
|
|
157
|
+
if (typeof value === "string" && value.trim()) {
|
|
158
|
+
return value.trim()
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return undefined
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function normalizeFileExtension(value: unknown): string | undefined {
|
|
165
|
+
if (typeof value !== "string") {
|
|
166
|
+
return undefined
|
|
167
|
+
}
|
|
168
|
+
const trimmed = value.trim().toLowerCase()
|
|
169
|
+
if (!trimmed || trimmed === "*") {
|
|
170
|
+
return undefined
|
|
171
|
+
}
|
|
172
|
+
return trimmed.replace(/^\./, "")
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function getConfiguredFileExtension(kwargs?: Record<string, unknown>, fieldMeta?: AimdFieldMeta): string | undefined {
|
|
176
|
+
const metaExtension = normalizeFileExtension((fieldMeta as { fileExtension?: unknown } | undefined)?.fileExtension)
|
|
177
|
+
if (metaExtension) {
|
|
178
|
+
return metaExtension
|
|
179
|
+
}
|
|
180
|
+
return normalizeFileExtension(kwargs?.file_extension)
|
|
181
|
+
?? normalizeFileExtension(kwargs?.fileExtension)
|
|
182
|
+
?? normalizeFileExtension(kwargs?.extension)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function acceptFromExtension(extension: string): string {
|
|
186
|
+
const ext = extension.replace(/^\./, "").toLowerCase()
|
|
187
|
+
const mime = MIME_BY_EXTENSION[ext]
|
|
188
|
+
return mime ? `.${ext},${mime}` : `.${ext}`
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function fileKindFromExtension(extension: string | undefined): FileInputDisplayKind {
|
|
192
|
+
if (!extension) {
|
|
193
|
+
return "file"
|
|
194
|
+
}
|
|
195
|
+
return FILE_KIND_BY_EXTENSION[extension] ?? "file"
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function isKnownFileTypeName(normalized: string | undefined): boolean {
|
|
199
|
+
if (!normalized) {
|
|
200
|
+
return false
|
|
201
|
+
}
|
|
202
|
+
return Boolean(FILE_CONFIG_BY_NORMALIZED_TYPE[normalized])
|
|
203
|
+
|| normalized.startsWith("fileid")
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export function getFileInputConfig(
|
|
207
|
+
type: string | undefined,
|
|
208
|
+
kwargs?: Record<string, unknown>,
|
|
209
|
+
fieldMeta?: AimdFieldMeta,
|
|
210
|
+
): FileInputConfig {
|
|
211
|
+
const normalizedInputType = normalizeAimdTypeName(fieldMeta?.inputType)
|
|
212
|
+
const normalized = isKnownFileTypeName(normalizedInputType)
|
|
213
|
+
? normalizedInputType
|
|
214
|
+
: normalizeVarTypeName(type)
|
|
215
|
+
const configuredExtension = getConfiguredFileExtension(kwargs, fieldMeta)
|
|
216
|
+
const configuredAccept = normalizeMetaString(fieldMeta?.accept)
|
|
217
|
+
?? getStringFromRecord(kwargs, ["accept", "file_accept", "fileAccept"])
|
|
218
|
+
const base = FILE_CONFIG_BY_NORMALIZED_TYPE[normalized]
|
|
219
|
+
|
|
220
|
+
if (configuredExtension) {
|
|
221
|
+
const kind = fileKindFromExtension(configuredExtension)
|
|
222
|
+
return {
|
|
223
|
+
kind,
|
|
224
|
+
accept: configuredAccept ?? acceptFromExtension(configuredExtension),
|
|
225
|
+
badge: base?.badge ?? FILE_BADGE_BY_KIND[kind],
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (base) {
|
|
230
|
+
return {
|
|
231
|
+
...base,
|
|
232
|
+
accept: configuredAccept ?? base.accept,
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return {
|
|
237
|
+
kind: "file",
|
|
238
|
+
accept: configuredAccept,
|
|
239
|
+
badge: FILE_BADGE_BY_KIND.file,
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export function isFileLikeVarType(
|
|
244
|
+
type: string | undefined,
|
|
245
|
+
kwargs?: Record<string, unknown>,
|
|
246
|
+
fieldMeta?: AimdFieldMeta,
|
|
247
|
+
): boolean {
|
|
248
|
+
const normalized = normalizeVarTypeName(type)
|
|
249
|
+
const normalizedInputType = normalizeAimdTypeName(fieldMeta?.inputType)
|
|
250
|
+
return isKnownFileTypeName(normalized)
|
|
251
|
+
|| isKnownFileTypeName(normalizedInputType)
|
|
252
|
+
|| Boolean(getConfiguredFileExtension(kwargs, fieldMeta))
|
|
253
|
+
|| Boolean(normalizeMetaString(fieldMeta?.accept))
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export function createSelectedFileValue(file: File): AimdSelectedFileValue {
|
|
257
|
+
return {
|
|
258
|
+
format: "airalogy_selected_file_v1",
|
|
259
|
+
name: file.name,
|
|
260
|
+
type: file.type,
|
|
261
|
+
size: file.size,
|
|
262
|
+
lastModified: file.lastModified,
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export function isAiralogyFileId(value: unknown): value is string {
|
|
267
|
+
return typeof value === "string" && AIRALOGY_FILE_ID_RE.test(value)
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export function getFileValueId(value: unknown): string | undefined {
|
|
271
|
+
const normalized = unwrapStructuredValue(value)
|
|
272
|
+
if (typeof normalized === "string") {
|
|
273
|
+
return normalized.trim() || undefined
|
|
274
|
+
}
|
|
275
|
+
if (!normalized || typeof normalized !== "object" || Array.isArray(normalized)) {
|
|
276
|
+
return undefined
|
|
277
|
+
}
|
|
278
|
+
return getStringFromRecord(normalized as Record<string, unknown>, [
|
|
279
|
+
"id",
|
|
280
|
+
"file_id",
|
|
281
|
+
"fileId",
|
|
282
|
+
"src",
|
|
283
|
+
])
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export function getFileDisplayName(value: unknown): string {
|
|
287
|
+
const normalized = unwrapStructuredValue(value)
|
|
288
|
+
if (typeof normalized === "string") {
|
|
289
|
+
if (isAiralogyFileId(normalized)) {
|
|
290
|
+
return ""
|
|
291
|
+
}
|
|
292
|
+
return normalized
|
|
293
|
+
}
|
|
294
|
+
if (!normalized || typeof normalized !== "object" || Array.isArray(normalized)) {
|
|
295
|
+
return ""
|
|
296
|
+
}
|
|
297
|
+
const record = normalized as Record<string, unknown>
|
|
298
|
+
return getStringFromRecord(record, [
|
|
299
|
+
"name",
|
|
300
|
+
"fileName",
|
|
301
|
+
"file_name",
|
|
302
|
+
"filename",
|
|
303
|
+
"originalName",
|
|
304
|
+
"original_name",
|
|
305
|
+
"id",
|
|
306
|
+
"file_id",
|
|
307
|
+
"src",
|
|
308
|
+
"url",
|
|
309
|
+
]) ?? ""
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function normalizeMetaString(value: unknown): string | undefined {
|
|
313
|
+
return typeof value === "string" && value.trim() ? value.trim() : undefined
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export function getVarEnumSelectValue(options: AimdVarEnumOption[], value: unknown): string {
|
|
317
|
+
const normalized = unwrapStructuredValue(value)
|
|
318
|
+
const exactIndex = options.findIndex(option => Object.is(option.value, normalized))
|
|
319
|
+
if (exactIndex >= 0) {
|
|
320
|
+
return String(exactIndex)
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (normalized !== undefined && normalized !== null) {
|
|
324
|
+
const stringIndex = options.findIndex(option => String(option.value) === String(normalized))
|
|
325
|
+
if (stringIndex >= 0) {
|
|
326
|
+
return String(stringIndex)
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
return ""
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export function getVarEnumValueFromSelectValue(options: AimdVarEnumOption[], selectValue: string): unknown {
|
|
334
|
+
const index = Number.parseInt(selectValue, 10)
|
|
335
|
+
return Number.isInteger(index) && index >= 0 && index < options.length
|
|
336
|
+
? options[index].value
|
|
337
|
+
: ""
|
|
338
|
+
}
|
|
339
|
+
|
|
46
340
|
function resolveOverrideInputKind(inputType: string | undefined, codeLanguage: string | undefined): VarInputKind | undefined {
|
|
47
341
|
if (isAimdCodeEditorType(undefined, { inputType, codeLanguage })) {
|
|
48
342
|
return 'code'
|
|
@@ -82,8 +376,8 @@ function resolveOverrideInputKind(inputType: string | undefined, codeLanguage: s
|
|
|
82
376
|
return 'dna'
|
|
83
377
|
}
|
|
84
378
|
|
|
85
|
-
if (normalized
|
|
86
|
-
return '
|
|
379
|
+
if (isKnownFileTypeName(normalized)) {
|
|
380
|
+
return 'file'
|
|
87
381
|
}
|
|
88
382
|
|
|
89
383
|
if (normalized === 'text' || normalized === 'string') {
|
|
@@ -147,6 +441,10 @@ export function getVarInputKind(type: string | undefined, options: VarInputKindO
|
|
|
147
441
|
return "textarea"
|
|
148
442
|
}
|
|
149
443
|
|
|
444
|
+
if (isFileLikeVarType(type, options.kwargs, options.fieldMeta)) {
|
|
445
|
+
return "file"
|
|
446
|
+
}
|
|
447
|
+
|
|
150
448
|
if (isAimdCodeEditorType(type, { codeLanguage: options.codeLanguage })) {
|
|
151
449
|
return 'code'
|
|
152
450
|
}
|
|
@@ -433,6 +731,10 @@ export function getVarInputDisplayValue(
|
|
|
433
731
|
return typeof normalized === "string" ? normalized : JSON.stringify(normalized)
|
|
434
732
|
}
|
|
435
733
|
|
|
734
|
+
if (kind === "file") {
|
|
735
|
+
return getFileDisplayName(normalized)
|
|
736
|
+
}
|
|
737
|
+
|
|
436
738
|
if (typeof normalized === "string") {
|
|
437
739
|
return normalized
|
|
438
740
|
}
|
|
@@ -493,6 +795,7 @@ function getVarControlMinWidth(inputKind: VarInputKind): number {
|
|
|
493
795
|
case "textarea":
|
|
494
796
|
case "dna":
|
|
495
797
|
case "code":
|
|
798
|
+
case "file":
|
|
496
799
|
return 160
|
|
497
800
|
default:
|
|
498
801
|
return 0
|
|
@@ -507,11 +810,28 @@ function getVarControlExtraWidth(inputKind: VarInputKind): number {
|
|
|
507
810
|
return 32
|
|
508
811
|
case "time":
|
|
509
812
|
return 28
|
|
813
|
+
case "file":
|
|
814
|
+
return 24
|
|
510
815
|
default:
|
|
511
816
|
return 4
|
|
512
817
|
}
|
|
513
818
|
}
|
|
514
819
|
|
|
820
|
+
function getFileControlMinWidth(input: HTMLElement | null): number {
|
|
821
|
+
if (!input?.classList.contains("aimd-rec-inline__file-control")) {
|
|
822
|
+
return 0
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
switch (input.dataset.fileKind) {
|
|
826
|
+
case "image":
|
|
827
|
+
return 360
|
|
828
|
+
case "csv":
|
|
829
|
+
return 280
|
|
830
|
+
default:
|
|
831
|
+
return 220
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
|
|
515
835
|
export function calculateVarStackWidth(name: string, inputKind: VarInputKind): string {
|
|
516
836
|
const labelChars = Math.max(name.length + 7, 10)
|
|
517
837
|
const approximateCharWidth = 8
|
|
@@ -576,9 +896,43 @@ function measureLabelTokenWidth(token: HTMLElement): number {
|
|
|
576
896
|
return textWidth + horizontal
|
|
577
897
|
}
|
|
578
898
|
|
|
899
|
+
function getElementHorizontalSpace(element: HTMLElement): number {
|
|
900
|
+
if (typeof window === "undefined") {
|
|
901
|
+
return 0
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
const computed = window.getComputedStyle(element)
|
|
905
|
+
return parsePx(computed.paddingLeft)
|
|
906
|
+
+ parsePx(computed.paddingRight)
|
|
907
|
+
+ parsePx(computed.borderLeftWidth)
|
|
908
|
+
+ parsePx(computed.borderRightWidth)
|
|
909
|
+
+ parsePx(computed.marginLeft)
|
|
910
|
+
+ parsePx(computed.marginRight)
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
function measureFieldNameWidth(name: HTMLElement): number {
|
|
914
|
+
const title = name.querySelector(".aimd-field__title") as HTMLElement | null
|
|
915
|
+
const key = name.querySelector(".aimd-field__key") as HTMLElement | null
|
|
916
|
+
const visibleTokenWidth = Math.max(
|
|
917
|
+
title ? measureLabelTokenWidth(title) : 0,
|
|
918
|
+
key ? measureLabelTokenWidth(key) : 0,
|
|
919
|
+
)
|
|
920
|
+
|
|
921
|
+
if (visibleTokenWidth > 0) {
|
|
922
|
+
return visibleTokenWidth + getElementHorizontalSpace(name)
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
return measureLabelTokenWidth(name)
|
|
926
|
+
}
|
|
927
|
+
|
|
579
928
|
export function measureVarLabelWidth(wrapper: HTMLElement): number {
|
|
580
929
|
const scope = wrapper.querySelector(".aimd-field__scope--var") as HTMLElement | null
|
|
930
|
+
const name = wrapper.querySelector(".aimd-field__name") as HTMLElement | null
|
|
581
931
|
const id = wrapper.querySelector(".aimd-field__id") as HTMLElement | null
|
|
932
|
+
if (scope && name) {
|
|
933
|
+
return measureLabelTokenWidth(scope) + measureFieldNameWidth(name) + 4
|
|
934
|
+
}
|
|
935
|
+
|
|
582
936
|
if (scope && id) {
|
|
583
937
|
return measureLabelTokenWidth(scope) + measureLabelTokenWidth(id) + 4
|
|
584
938
|
}
|
|
@@ -587,7 +941,7 @@ export function measureVarLabelWidth(wrapper: HTMLElement): number {
|
|
|
587
941
|
return fallbackLabel ? fallbackLabel.scrollWidth + 2 : 0
|
|
588
942
|
}
|
|
589
943
|
|
|
590
|
-
export function measureSingleLineControlWidth(input:
|
|
944
|
+
export function measureSingleLineControlWidth(input: HTMLElement): number {
|
|
591
945
|
if (typeof window === "undefined") {
|
|
592
946
|
return input.scrollWidth
|
|
593
947
|
}
|
|
@@ -604,12 +958,22 @@ export function measureSingleLineControlWidth(input: HTMLInputElement | HTMLText
|
|
|
604
958
|
const fontStyle = computed.fontStyle || "normal"
|
|
605
959
|
ctx.font = `${fontStyle} ${fontWeight} ${fontSize} ${fontFamily}`
|
|
606
960
|
|
|
607
|
-
const text =
|
|
961
|
+
const text = "value" in input
|
|
962
|
+
? ((input as HTMLInputElement | HTMLTextAreaElement).value || (input as HTMLInputElement | HTMLTextAreaElement).placeholder || "")
|
|
963
|
+
: ((input.textContent || "").trim())
|
|
608
964
|
const textWidth = ctx.measureText(text).width
|
|
609
965
|
const padding = parsePx(computed.paddingLeft) + parsePx(computed.paddingRight)
|
|
610
966
|
return textWidth + padding + 2
|
|
611
967
|
}
|
|
612
968
|
|
|
969
|
+
function measureOptionalControlSlotWidth(wrapper: HTMLElement, selector: string, fallbackWidth: number): number {
|
|
970
|
+
const element = wrapper.querySelector(selector) as HTMLElement | null
|
|
971
|
+
if (!element) {
|
|
972
|
+
return 0
|
|
973
|
+
}
|
|
974
|
+
return element.offsetWidth || fallbackWidth
|
|
975
|
+
}
|
|
976
|
+
|
|
613
977
|
// ---------------------------------------------------------------------------
|
|
614
978
|
// Textarea auto-height
|
|
615
979
|
// ---------------------------------------------------------------------------
|
|
@@ -644,14 +1008,18 @@ export function applyVarStackWidth(target: HTMLElement, inputKind: VarInputKind)
|
|
|
644
1008
|
|
|
645
1009
|
const labelWidth = measureVarLabelWidth(wrapper)
|
|
646
1010
|
|
|
647
|
-
const minWidthPx = getVarControlMinWidth(inputKind)
|
|
648
1011
|
let controlWidth = 0
|
|
649
|
-
const input = wrapper.querySelector(".aimd-rec-inline__input--stacked, .aimd-rec-inline__textarea--stacked-text") as
|
|
650
|
-
|
|
1012
|
+
const input = wrapper.querySelector(".aimd-rec-inline__input--stacked, .aimd-rec-inline__textarea--stacked-text, .aimd-rec-inline__file-control") as HTMLElement | null
|
|
1013
|
+
const minWidthPx = Math.max(getVarControlMinWidth(inputKind), getFileControlMinWidth(input))
|
|
651
1014
|
if (input) {
|
|
652
1015
|
controlWidth = measureSingleLineControlWidth(input) + getVarControlExtraWidth(inputKind)
|
|
653
1016
|
}
|
|
654
1017
|
|
|
1018
|
+
if (wrapper.querySelector(".aimd-rec-inline__control-row")) {
|
|
1019
|
+
controlWidth += measureOptionalControlSlotWidth(wrapper, ".aimd-rec-inline__assigner-prefix", 36)
|
|
1020
|
+
+ measureOptionalControlSlotWidth(wrapper, ".aimd-rec-inline__assigner-status", 30)
|
|
1021
|
+
}
|
|
1022
|
+
|
|
655
1023
|
const measuredWidth = Math.max(minWidthPx, labelWidth, controlWidth)
|
|
656
1024
|
wrapper.style.width = `${Math.ceil(measuredWidth)}px`
|
|
657
1025
|
wrapper.style.maxWidth = "100%"
|
package/src/index.ts
CHANGED
|
@@ -23,6 +23,19 @@ export {
|
|
|
23
23
|
} from './locales'
|
|
24
24
|
export type {
|
|
25
25
|
AimdProtocolRecordData,
|
|
26
|
+
AimdAssignerDefinition,
|
|
27
|
+
AimdAssignerMap,
|
|
28
|
+
AimdAssignerRunner,
|
|
29
|
+
AimdAssignerRunnerRequest,
|
|
30
|
+
AimdServerAssignerMap,
|
|
31
|
+
AimdServerAssignerRunner,
|
|
32
|
+
AimdServerAssignerRunnerRequest,
|
|
33
|
+
AimdFileUploadContext,
|
|
34
|
+
AimdFileUploadHandler,
|
|
35
|
+
AimdFileResolveContext,
|
|
36
|
+
AimdFileInfoResolver,
|
|
37
|
+
AimdResolvedFileInfo,
|
|
38
|
+
AimdSelectedFileValue,
|
|
26
39
|
AimdTypePlugin,
|
|
27
40
|
AimdTypePluginInitContext,
|
|
28
41
|
AimdTypePluginParseContext,
|
package/src/locales.ts
CHANGED
|
@@ -80,6 +80,21 @@ export interface AimdRecorderMessages {
|
|
|
80
80
|
deleteRow: string
|
|
81
81
|
addRow: string
|
|
82
82
|
}
|
|
83
|
+
assigner: {
|
|
84
|
+
run: string
|
|
85
|
+
running: string
|
|
86
|
+
cancel: string
|
|
87
|
+
}
|
|
88
|
+
file: {
|
|
89
|
+
choose: string
|
|
90
|
+
selected: string
|
|
91
|
+
clear: string
|
|
92
|
+
open: string
|
|
93
|
+
download: string
|
|
94
|
+
preview: string
|
|
95
|
+
replace: string
|
|
96
|
+
uploadFailed: string
|
|
97
|
+
}
|
|
83
98
|
dna: {
|
|
84
99
|
editMode: string
|
|
85
100
|
interactiveMode: string
|
|
@@ -249,6 +264,21 @@ const EN_US_MESSAGES: AimdRecorderMessages = {
|
|
|
249
264
|
deleteRow: "Delete",
|
|
250
265
|
addRow: "Add row",
|
|
251
266
|
},
|
|
267
|
+
assigner: {
|
|
268
|
+
run: "Run Assigner",
|
|
269
|
+
running: "Running",
|
|
270
|
+
cancel: "Cancel",
|
|
271
|
+
},
|
|
272
|
+
file: {
|
|
273
|
+
choose: "Choose file",
|
|
274
|
+
selected: "Selected file",
|
|
275
|
+
clear: "Clear file",
|
|
276
|
+
open: "Open file",
|
|
277
|
+
download: "Download",
|
|
278
|
+
preview: "Preview",
|
|
279
|
+
replace: "Replace file",
|
|
280
|
+
uploadFailed: "File upload failed.",
|
|
281
|
+
},
|
|
252
282
|
dna: {
|
|
253
283
|
editMode: "Edit mode",
|
|
254
284
|
interactiveMode: "Interactive",
|
|
@@ -391,6 +421,21 @@ const ZH_CN_MESSAGES: AimdRecorderMessages = {
|
|
|
391
421
|
deleteRow: "删除",
|
|
392
422
|
addRow: "添加行",
|
|
393
423
|
},
|
|
424
|
+
assigner: {
|
|
425
|
+
run: "运行赋值器",
|
|
426
|
+
running: "运行中",
|
|
427
|
+
cancel: "取消",
|
|
428
|
+
},
|
|
429
|
+
file: {
|
|
430
|
+
choose: "选择文件",
|
|
431
|
+
selected: "已选择文件",
|
|
432
|
+
clear: "清除文件",
|
|
433
|
+
open: "打开文件",
|
|
434
|
+
download: "下载",
|
|
435
|
+
preview: "预览",
|
|
436
|
+
replace: "替换文件",
|
|
437
|
+
uploadFailed: "文件上传失败。",
|
|
438
|
+
},
|
|
394
439
|
dna: {
|
|
395
440
|
editMode: "编辑模式",
|
|
396
441
|
interactiveMode: "交互式",
|