@airalogy/aimd-recorder 1.14.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.
Files changed (178) hide show
  1. package/README.md +240 -0
  2. package/README.zh-CN.md +224 -0
  3. package/dist/AimdCodeField-DC3DPvgc.js +172 -0
  4. package/dist/AimdDnaSequenceField-__jdnFS9.js +59466 -0
  5. package/dist/AimdEditor.vue_vue_type_style_index_0_lang-Bq79rKNw.js +28370 -0
  6. package/dist/AimdMarkdownField-98ImHGbc.js +66 -0
  7. package/dist/AimdMarkdownNoteField-CuUJZkgT.js +185 -0
  8. package/dist/_.contribution-IP0cDNhs.js +38 -0
  9. package/dist/_commonjsHelpers-CZXJ37nu.js +40 -0
  10. package/dist/abap-Bs8kvjsq.js +1398 -0
  11. package/dist/aimd-recorder.css +1 -0
  12. package/dist/apex-Dspwrl5m.js +326 -0
  13. package/dist/assets/css.worker-Dmf38jDD.js +79 -0
  14. package/dist/assets/editor.worker-CpuX8TSY.js +12 -0
  15. package/dist/assets/html.worker-DotaEs7v.js +456 -0
  16. package/dist/assets/json.worker-B4VHhH6h.js +44 -0
  17. package/dist/assets/ts.worker-sl17zBDo.js +51316 -0
  18. package/dist/azcli-k1BiOau1.js +68 -0
  19. package/dist/bat-BIP72KWc.js +100 -0
  20. package/dist/bicep-VhQeYhS3.js +102 -0
  21. package/dist/cameligo-DnuAXtHg.js +174 -0
  22. package/dist/clojure-BAuDPsal.js +761 -0
  23. package/dist/coffee-BV06qSnj.js +232 -0
  24. package/dist/components.js +3595 -0
  25. package/dist/composables.js +72 -0
  26. package/dist/cpp-Cz8Jeyrf.js +389 -0
  27. package/dist/csharp-F6hhlXFb.js +326 -0
  28. package/dist/csp-KzlEHCyI.js +53 -0
  29. package/dist/css-e4FKntZ3.js +187 -0
  30. package/dist/cssMode-uz9U6SUU.js +1571 -0
  31. package/dist/cypher-CpvDGKRr.js +263 -0
  32. package/dist/dart-DdHeFWR0.js +281 -0
  33. package/dist/dockerfile-aoNXDcio.js +130 -0
  34. package/dist/ecl-C4Q0DYuA.js +456 -0
  35. package/dist/editor.api-CgD9w0gG.js +77091 -0
  36. package/dist/editor.main-Du02abDl.js +33783 -0
  37. package/dist/elixir-C9X42b0T.js +569 -0
  38. package/dist/flow9-Bff42pfB.js +142 -0
  39. package/dist/freemarker2-DFLX4iQ-.js +989 -0
  40. package/dist/fsharp-C6vPAsHG.js +217 -0
  41. package/dist/go-DEr8zx9f.js +218 -0
  42. package/dist/graphql-BiNBBRFh.js +151 -0
  43. package/dist/handlebars-aiZbIuWY.js +419 -0
  44. package/dist/hcl-2T9lKuFg.js +183 -0
  45. package/dist/html-phzTMObN.js +308 -0
  46. package/dist/htmlMode-BF7wMi3N.js +1581 -0
  47. package/dist/index.js +89 -0
  48. package/dist/ini-CZGtssYM.js +71 -0
  49. package/dist/ini.contribution-DyWtiacL.js +8 -0
  50. package/dist/java-B260NeH3.js +232 -0
  51. package/dist/javascript-BKKOItMi.js +70 -0
  52. package/dist/jsonMode-CDYK4B5l.js +1996 -0
  53. package/dist/julia-kuNLM9c5.js +511 -0
  54. package/dist/kotlin-Bz6kAefA.js +253 -0
  55. package/dist/less-AZUtS89I.js +162 -0
  56. package/dist/lexon-BcmgnyRb.js +157 -0
  57. package/dist/liquid-B2eRz5SA.js +240 -0
  58. package/dist/lua-Dz1RbATg.js +162 -0
  59. package/dist/m3-CIMooLFn.js +210 -0
  60. package/dist/markdown-C1BsCK9P.js +229 -0
  61. package/dist/markdown.contribution-DYYk6zUU.js +7 -0
  62. package/dist/mdx-BfV1HDRG.js +165 -0
  63. package/dist/mips-BovsnfLQ.js +198 -0
  64. package/dist/monaco.contribution-C-bQhUTI.js +114 -0
  65. package/dist/monaco.contribution-CCVvl3Jx.js +72 -0
  66. package/dist/monaco.contribution-Col-f0XR.js +164 -0
  67. package/dist/monaco.contribution-b5xkgQ-s.js +112 -0
  68. package/dist/msdax-CiRB2ZB-.js +375 -0
  69. package/dist/mysql-BwdpPE19.js +878 -0
  70. package/dist/objective-c-D4nfHfso.js +183 -0
  71. package/dist/pascal--j5-PYtz.js +251 -0
  72. package/dist/pascaligo-C7TcJxNL.js +164 -0
  73. package/dist/perl-BzEWqUb5.js +626 -0
  74. package/dist/pgsql-B_KZ0mGX.js +851 -0
  75. package/dist/php-A19QHzQV.js +500 -0
  76. package/dist/pla-COeKY1hA.js +137 -0
  77. package/dist/postiats-BfMp7zJL.js +907 -0
  78. package/dist/powerquery-B0TS_5Gb.js +890 -0
  79. package/dist/powershell-5jSbKdYB.js +239 -0
  80. package/dist/protobuf-YgnOutn3.js +420 -0
  81. package/dist/pug-DLej6kn5.js +402 -0
  82. package/dist/python-CQrZx9mR.js +301 -0
  83. package/dist/python.contribution-CcKs2Ktm.js +8 -0
  84. package/dist/qsharp-AhjqtSHB.js +301 -0
  85. package/dist/r-D-F4P80w.js +243 -0
  86. package/dist/razor-DWmpHMcx.js +550 -0
  87. package/dist/redis-hwwIlMnV.js +302 -0
  88. package/dist/redshift-Bcm_kjEG.js +809 -0
  89. package/dist/restructuredtext-CrdzfPP-.js +174 -0
  90. package/dist/ruby-QC2UNm1s.js +511 -0
  91. package/dist/rust-5aqiQ3L5.js +343 -0
  92. package/dist/sb-B1g1ZfLJ.js +115 -0
  93. package/dist/scala-C2U4R5Gb.js +370 -0
  94. package/dist/scheme-DeFRbslr.js +108 -0
  95. package/dist/scss-RSTCiCmI.js +262 -0
  96. package/dist/shell-BpF-iNu8.js +221 -0
  97. package/dist/shell.contribution-B80NZ3iO.js +7 -0
  98. package/dist/solidity-C00r2mbQ.js +1367 -0
  99. package/dist/sophia-DVW5ZKDB.js +199 -0
  100. package/dist/sparql-B0nmpxeX.js +201 -0
  101. package/dist/sql-CJwKPERn.js +853 -0
  102. package/dist/sql.contribution-DQy36aE5.js +7 -0
  103. package/dist/st-DPlKG5DT.js +416 -0
  104. package/dist/swift-YZBAbVHV.js +309 -0
  105. package/dist/systemverilog-CDQSaH63.js +576 -0
  106. package/dist/tcl-Dlu8sp6Q.js +232 -0
  107. package/dist/tsMode-Bh-v12OL.js +887 -0
  108. package/dist/twig-C5TO7-kw.js +392 -0
  109. package/dist/typescript-c7y6IZVP.js +343 -0
  110. package/dist/typespec-BsmjDEu7.js +117 -0
  111. package/dist/useFieldRendering-BIqeE3qo.js +6083 -0
  112. package/dist/vb-ChHvIDrk.js +372 -0
  113. package/dist/wgsl-XEp1ju8c.js +439 -0
  114. package/dist/xml-MAEprTnF.js +95 -0
  115. package/dist/xml.contribution-XMOaon8i.js +27 -0
  116. package/dist/yaml-C1p8rXG7.js +206 -0
  117. package/dist/yaml.contribution-DRRVhJmJ.js +8 -0
  118. package/package.json +88 -0
  119. package/src/__tests__/client-assigner.test.ts +341 -0
  120. package/src/__tests__/code-types.test.ts +30 -0
  121. package/src/__tests__/markdown-field.test.ts +34 -0
  122. package/src/__tests__/markdown-note-field.test.ts +135 -0
  123. package/src/__tests__/quiz-recorder.test.ts +195 -0
  124. package/src/__tests__/recorder-editor-content-sync.test.ts +172 -0
  125. package/src/__tests__/recorder-editor.test.ts +143 -0
  126. package/src/__tests__/recorder-render.test.ts +57 -0
  127. package/src/__tests__/recorder-wysiwyg-field-host.test.ts +33 -0
  128. package/src/__tests__/step-field.test.ts +270 -0
  129. package/src/__tests__/type-plugins.test.ts +59 -0
  130. package/src/__tests__/var-field-render.test.ts +26 -0
  131. package/src/client-assigner.ts +269 -0
  132. package/src/code-types.ts +94 -0
  133. package/src/components/AimdCodeField.vue +228 -0
  134. package/src/components/AimdDnaSequenceField.vue +983 -0
  135. package/src/components/AimdMarkdownField.vue +168 -0
  136. package/src/components/AimdMarkdownNoteField.vue +457 -0
  137. package/src/components/AimdQuizRecorder.vue +792 -0
  138. package/src/components/AimdRecorder.vue +1959 -0
  139. package/src/components/AimdRecorderEditor.vue +2281 -0
  140. package/src/components/AimdRecorderWysiwygFieldHost.vue +93 -0
  141. package/src/components/AimdRecorderWysiwygSurface.vue +487 -0
  142. package/src/components/AimdSeqVizViewer.vue +122 -0
  143. package/src/components/AimdStepCheckField.vue +453 -0
  144. package/src/components/AimdVarField.vue +213 -0
  145. package/src/components/AimdVarTableField.vue +516 -0
  146. package/src/components/DnaAnnotationEditor.vue +477 -0
  147. package/src/components/DnaSequenceEditor.vue +44 -0
  148. package/src/components/DnaSequenceToolbar.vue +98 -0
  149. package/src/components/DnaSequenceViewer.vue +162 -0
  150. package/src/components/index.ts +21 -0
  151. package/src/components/recorderMilkdownPlugin.ts +632 -0
  152. package/src/composables/__tests__/useDnaSequence.test.ts +467 -0
  153. package/src/composables/__tests__/useFieldAdapters.test.ts +115 -0
  154. package/src/composables/__tests__/useFocusManagement.test.ts +66 -0
  155. package/src/composables/__tests__/useRecordState.test.ts +586 -0
  156. package/src/composables/__tests__/useStepTimers.test.ts +64 -0
  157. package/src/composables/__tests__/useVarHelpers.test.ts +424 -0
  158. package/src/composables/__tests__/workbenchFieldEditing.test.ts +97 -0
  159. package/src/composables/index.ts +94 -0
  160. package/src/composables/useClientAssignerRunner.ts +74 -0
  161. package/src/composables/useDnaSequence.ts +400 -0
  162. package/src/composables/useDnaSequenceField.ts +316 -0
  163. package/src/composables/useFieldAdapters.ts +61 -0
  164. package/src/composables/useFieldRendering.ts +269 -0
  165. package/src/composables/useFocusManagement.ts +144 -0
  166. package/src/composables/useRecordState.ts +429 -0
  167. package/src/composables/useStepTimers.ts +243 -0
  168. package/src/composables/useVarHelpers.ts +545 -0
  169. package/src/composables/useVarTableDragDrop.ts +236 -0
  170. package/src/composables/workbenchFieldEditing.ts +705 -0
  171. package/src/css.d.ts +9 -0
  172. package/src/index.ts +65 -0
  173. package/src/locales.ts +559 -0
  174. package/src/monaco-code.ts +75 -0
  175. package/src/styles/aimd.css +994 -0
  176. package/src/type-plugins.ts +132 -0
  177. package/src/type-utils.ts +3 -0
  178. package/src/types.ts +191 -0
package/src/index.ts ADDED
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @airalogy/aimd-recorder
3
+ *
4
+ * AIMD editor Vue components and UI
5
+ *
6
+ * This package provides Vue components for editing and displaying AIMD content
7
+ */
8
+
9
+ // Re-export styles
10
+ import './styles/aimd.css'
11
+ import { AimdProtocolRecorder as DeprecatedAimdProtocolRecorder } from './components'
12
+
13
+ export { AimdRecorder, AimdRecorderEditor, AimdQuizRecorder } from './components'
14
+ export { AimdDnaSequenceField, AimdMarkdownField } from './components'
15
+ /**
16
+ * @deprecated Use `AimdRecorder` instead.
17
+ */
18
+ export const AimdProtocolRecorder = DeprecatedAimdProtocolRecorder
19
+ export {
20
+ createAimdRecorderMessages,
21
+ DEFAULT_AIMD_RECORDER_LOCALE,
22
+ resolveAimdRecorderLocale,
23
+ } from './locales'
24
+ export type {
25
+ AimdProtocolRecordData,
26
+ AimdTypePlugin,
27
+ AimdTypePluginInitContext,
28
+ AimdTypePluginParseContext,
29
+ AimdTypePluginRenderContext,
30
+ AimdTypePluginValueContext,
31
+ AimdVarInputKind,
32
+ AimdStepDetailDisplay,
33
+ AimdChoiceOptionExplanationMode,
34
+ AimdScaleGradeDisplayMode,
35
+ AimdRecorderFieldAdapter,
36
+ AimdRecorderFieldAdapterContext,
37
+ AimdRecorderFieldAdapters,
38
+ AimdRecorderFieldNode,
39
+ AimdRecorderFieldNodeMap,
40
+ AimdRecorderFieldType,
41
+ AimdCheckRecordItem,
42
+ AimdStepRecordItem,
43
+ AimdStepOrCheckRecordItem,
44
+ AimdFieldMeta,
45
+ AimdFieldState,
46
+ AimdDnaSequenceAnnotation,
47
+ AimdDnaSequenceQualifier,
48
+ AimdDnaSequenceSegment,
49
+ AimdDnaSequenceValue,
50
+ FieldEventPayload,
51
+ TableEventPayload,
52
+ } from './types'
53
+ export { createEmptyProtocolRecordData } from './types'
54
+ export {
55
+ BUILT_IN_AIMD_TYPE_PLUGINS,
56
+ createAimdTypePlugins,
57
+ resolveAimdTypePlugin,
58
+ } from './type-plugins'
59
+ export type {
60
+ AimdRecorderI18nOptions,
61
+ AimdRecorderLocale,
62
+ AimdRecorderMessages,
63
+ AimdRecorderMessagesInput,
64
+ } from './locales'
65
+ export * from './composables'
package/src/locales.ts ADDED
@@ -0,0 +1,559 @@
1
+ import { getAimdRendererQuizTypeLabel as getSharedRendererQuizTypeLabel } from "@airalogy/aimd-renderer"
2
+
3
+ export type AimdRecorderLocale = "en-US" | "zh-CN"
4
+
5
+ export const DEFAULT_AIMD_RECORDER_LOCALE: AimdRecorderLocale = "en-US"
6
+
7
+ type DeepPartial<T> = {
8
+ [K in keyof T]?: T[K] extends (...args: any[]) => any
9
+ ? T[K]
10
+ : T[K] extends Array<infer U>
11
+ ? Array<DeepPartial<U>>
12
+ : T[K] extends object
13
+ ? DeepPartial<T[K]>
14
+ : T[K]
15
+ }
16
+
17
+ export interface AimdRecorderMessages {
18
+ scope: {
19
+ var: string
20
+ quiz: string
21
+ step: string
22
+ check: string
23
+ table: string
24
+ }
25
+ quiz: {
26
+ types: {
27
+ choice: string
28
+ singleChoice: string
29
+ multipleChoice: string
30
+ blank: string
31
+ open: string
32
+ scale: string
33
+ }
34
+ score: (score: string | number) => string
35
+ answer: (value: string) => string
36
+ rubric: (value: string) => string
37
+ gradedScore: (earned: string | number, max: string | number) => string
38
+ feedback: string
39
+ classification: string
40
+ interpretation: string
41
+ reviewRequired: string
42
+ status: {
43
+ correct: string
44
+ incorrect: string
45
+ partial: string
46
+ scored: string
47
+ needsReview: string
48
+ error: string
49
+ ungraded: string
50
+ }
51
+ openPlaceholder: string
52
+ }
53
+ step: {
54
+ annotationPlaceholder: string
55
+ annotationToggle: string
56
+ estimatedDuration: (value: string) => string
57
+ estimatedBadge: (value: string) => string
58
+ remainingDuration: (value: string) => string
59
+ remainingBadge: (value: string) => string
60
+ overtimeDuration: (value: string) => string
61
+ overtimeBadge: (value: string) => string
62
+ recordedDuration: (value: string) => string
63
+ recordedBadge: (value: string) => string
64
+ protocolEstimatedTotal: (value: string) => string
65
+ protocolRecordedTotal: (value: string) => string
66
+ timerToggle: string
67
+ startTimer: string
68
+ pauseTimer: string
69
+ resumeTimer: string
70
+ resetTimer: string
71
+ }
72
+ check: {
73
+ annotationPlaceholder: string
74
+ }
75
+ table: {
76
+ actionColumn: string
77
+ dragDisabled: string
78
+ dragReorder: string
79
+ deleteRow: string
80
+ addRow: string
81
+ }
82
+ dna: {
83
+ editMode: string
84
+ interactiveMode: string
85
+ rawMode: string
86
+ topology: string
87
+ linear: string
88
+ circular: string
89
+ sequence: string
90
+ sequenceName: string
91
+ sequenceNamePlaceholder: string
92
+ sequencePlaceholder: string
93
+ viewer: string
94
+ viewerHint: string
95
+ viewerRequiresSequence: string
96
+ onboardingPasteLabel: string
97
+ onboardingApplySequence: string
98
+ onboardingImportFile: string
99
+ onboardingImportHint: string
100
+ onboardingNoSequenceDetected: string
101
+ onboardingImportReadError: string
102
+ importReplaceConfirm: string
103
+ selection: string
104
+ selectionEmpty: string
105
+ selectionClear: string
106
+ selectionRange: (value: string) => string
107
+ selectionTarget: (value: string) => string
108
+ selectionModeSequence: string
109
+ createFromSelection: string
110
+ applySelectionToSegment: string
111
+ annotations: string
112
+ addAnnotation: string
113
+ exportGenBank: string
114
+ removeAnnotation: string
115
+ editAnnotation: string
116
+ focusAnnotation: string
117
+ noAnnotations: string
118
+ interactiveDetails: string
119
+ interactiveDetailsHint: string
120
+ interactiveDetailsEmpty: string
121
+ advancedEditor: string
122
+ advancedEditorHint: string
123
+ advancedEditorEmpty: string
124
+ selectedAnnotation: (value: string) => string
125
+ annotationName: string
126
+ annotationType: string
127
+ segments: string
128
+ addSegment: string
129
+ removeSegment: string
130
+ start: string
131
+ end: string
132
+ partialStart: string
133
+ partialEnd: string
134
+ strand: string
135
+ forward: string
136
+ reverse: string
137
+ qualifiers: string
138
+ addQualifier: string
139
+ removeQualifier: string
140
+ noQualifiers: string
141
+ qualifierKey: string
142
+ qualifierValue: string
143
+ color: string
144
+ iupacHint: string
145
+ invalidCharacters: (chars: string) => string
146
+ length: (count: number) => string
147
+ gc: (value: string) => string
148
+ gcUnavailable: string
149
+ segmentRequiresSequence: string
150
+ segmentRangeError: string
151
+ segmentOutOfBounds: (end: number, length: number) => string
152
+ }
153
+ common: {
154
+ emptyContent: string
155
+ }
156
+ }
157
+
158
+ export type AimdRecorderMessagesInput = DeepPartial<AimdRecorderMessages>
159
+
160
+ export interface AimdRecorderI18nOptions {
161
+ locale?: AimdRecorderLocale | string
162
+ messages?: AimdRecorderMessagesInput
163
+ }
164
+
165
+ function detectRuntimeLocale(): string | undefined {
166
+ if (typeof document !== "undefined") {
167
+ const htmlLang = document.documentElement?.lang?.trim()
168
+ if (htmlLang) {
169
+ return htmlLang
170
+ }
171
+ }
172
+
173
+ if (typeof navigator !== "undefined") {
174
+ if (navigator.language) {
175
+ return navigator.language
176
+ }
177
+ if (Array.isArray(navigator.languages) && navigator.languages.length > 0) {
178
+ return navigator.languages[0]
179
+ }
180
+ }
181
+
182
+ return undefined
183
+ }
184
+
185
+ const EN_US_MESSAGES: AimdRecorderMessages = {
186
+ scope: {
187
+ var: "var",
188
+ quiz: "quiz",
189
+ step: "step",
190
+ check: "check",
191
+ table: "table",
192
+ },
193
+ quiz: {
194
+ types: {
195
+ choice: "choice",
196
+ singleChoice: "Single choice",
197
+ multipleChoice: "Multiple choice",
198
+ blank: "blank",
199
+ open: "open",
200
+ scale: "scale",
201
+ },
202
+ score: score => `${score} pt`,
203
+ answer: value => `Answer: ${value}`,
204
+ rubric: value => `Rubric: ${value}`,
205
+ gradedScore: (earned, max) => `Score: ${earned} / ${max}`,
206
+ feedback: "Feedback",
207
+ classification: "Classification",
208
+ interpretation: "Interpretation",
209
+ reviewRequired: "Review required",
210
+ status: {
211
+ correct: "Correct",
212
+ incorrect: "Incorrect",
213
+ partial: "Partial",
214
+ scored: "Scored",
215
+ needsReview: "Needs review",
216
+ error: "Error",
217
+ ungraded: "Ungraded",
218
+ },
219
+ openPlaceholder: "Input your answer...",
220
+ },
221
+ step: {
222
+ annotationPlaceholder: "Notes",
223
+ annotationToggle: "Notes",
224
+ estimatedDuration: value => `Estimated: ${value}`,
225
+ estimatedBadge: value => `ETA ${value}`,
226
+ remainingDuration: value => `Remaining: ${value}`,
227
+ remainingBadge: value => `Remain ${value}`,
228
+ overtimeDuration: value => `Overtime: ${value}`,
229
+ overtimeBadge: value => `Overtime ${value}`,
230
+ recordedDuration: value => `Recorded: ${value}`,
231
+ recordedBadge: value => `Timer ${value}`,
232
+ protocolEstimatedTotal: value => `Estimated total ${value}`,
233
+ protocolRecordedTotal: value => `Recorded total ${value}`,
234
+ timerToggle: "Timer",
235
+ startTimer: "Start",
236
+ pauseTimer: "Pause",
237
+ resumeTimer: "Resume",
238
+ resetTimer: "Reset",
239
+ },
240
+ check: {
241
+ annotationPlaceholder: "Check notes",
242
+ },
243
+ table: {
244
+ actionColumn: "Actions",
245
+ dragDisabled: "Drag is disabled in read-only mode",
246
+ dragReorder: "Drag to reorder rows",
247
+ deleteRow: "Delete",
248
+ addRow: "Add row",
249
+ },
250
+ dna: {
251
+ editMode: "Edit mode",
252
+ interactiveMode: "Interactive",
253
+ rawMode: "Raw structure",
254
+ topology: "Topology",
255
+ linear: "Linear",
256
+ circular: "Circular",
257
+ sequence: "Sequence",
258
+ sequenceName: "Sequence name",
259
+ sequenceNamePlaceholder: "Optional plasmid or sequence name",
260
+ sequencePlaceholder: "Paste or type DNA sequence using IUPAC DNA letters",
261
+ viewer: "Sequence viewer",
262
+ viewerHint: "Drag across the sequence to select a range. Click a feature to edit it in the selected annotation panel.",
263
+ viewerRequiresSequence: "Start by pasting a DNA sequence, or use Import file in the toolbar.",
264
+ onboardingPasteLabel: "Paste sequence",
265
+ onboardingApplySequence: "Use sequence",
266
+ onboardingImportFile: "Import file",
267
+ onboardingImportHint: "Supports plain DNA text, FASTA, and GenBank sequence imports. Use the toolbar Import file action for files; raw structure mode remains available for advanced cleanup.",
268
+ onboardingNoSequenceDetected: "No DNA sequence was detected in the pasted content or imported file.",
269
+ onboardingImportReadError: "The selected file could not be read.",
270
+ importReplaceConfirm: "Importing a file or pasted sequence will replace the current DNA sequence and clear existing annotations. Continue?",
271
+ selection: "Current selection",
272
+ selectionEmpty: "Drag across the sequence to create or update an annotation.",
273
+ selectionClear: "Clear selection",
274
+ selectionRange: value => `Range: ${value}`,
275
+ selectionTarget: value => `Target: ${value}`,
276
+ selectionModeSequence: "Sequence range",
277
+ createFromSelection: "Create annotation",
278
+ applySelectionToSegment: "Apply to active segment",
279
+ annotations: "Annotations",
280
+ addAnnotation: "Add annotation",
281
+ exportGenBank: "Export GenBank",
282
+ removeAnnotation: "Remove annotation",
283
+ editAnnotation: "Edit",
284
+ focusAnnotation: "Focus in viewer",
285
+ noAnnotations: "No annotations yet.",
286
+ interactiveDetails: "Selected annotation",
287
+ interactiveDetailsHint: "Use interactive mode for selection and quick annotation edits. Switch to raw structure mode for segments, qualifiers, and bulk annotation management.",
288
+ interactiveDetailsEmpty: "Click a feature in the viewer to edit it, or drag a range above to create one.",
289
+ advancedEditor: "Raw structure editor",
290
+ advancedEditorHint: "Use raw structure mode for sequence text, multi-segment locations, qualifiers, and precise coordinate cleanup.",
291
+ advancedEditorEmpty: "Select or create an annotation to edit its structured fields.",
292
+ selectedAnnotation: value => `Selected: ${value}`,
293
+ annotationName: "Name",
294
+ annotationType: "Type",
295
+ segments: "Segments",
296
+ addSegment: "Add segment",
297
+ removeSegment: "Remove segment",
298
+ start: "Start",
299
+ end: "End",
300
+ partialStart: "Partial start",
301
+ partialEnd: "Partial end",
302
+ strand: "Strand",
303
+ forward: "Forward",
304
+ reverse: "Reverse",
305
+ qualifiers: "Qualifiers",
306
+ addQualifier: "Add qualifier",
307
+ removeQualifier: "Remove qualifier",
308
+ noQualifiers: "No qualifiers yet.",
309
+ qualifierKey: "Key",
310
+ qualifierValue: "Value",
311
+ color: "Color",
312
+ iupacHint: "Supports IUPAC DNA letters: A, C, G, T, R, Y, S, W, K, M, B, D, H, V, N.",
313
+ invalidCharacters: chars => `Unsupported sequence characters: ${chars}`,
314
+ length: count => `Length: ${count} bp`,
315
+ gc: value => `GC: ${value}`,
316
+ gcUnavailable: "GC: -",
317
+ segmentRequiresSequence: "Enter a sequence before positioning feature segments.",
318
+ segmentRangeError: "Segment end must be greater than or equal to start.",
319
+ segmentOutOfBounds: (end, length) => `Segment end ${end} exceeds sequence length ${length}.`,
320
+ },
321
+ common: {
322
+ emptyContent: "No renderable protocol content.",
323
+ },
324
+ }
325
+
326
+ const ZH_CN_MESSAGES: AimdRecorderMessages = {
327
+ scope: {
328
+ var: "变量",
329
+ quiz: "题目",
330
+ step: "步骤",
331
+ check: "检查点",
332
+ table: "表格",
333
+ },
334
+ quiz: {
335
+ types: {
336
+ choice: "选择",
337
+ singleChoice: "单选",
338
+ multipleChoice: "多选",
339
+ blank: "填空",
340
+ open: "开放",
341
+ scale: "量表",
342
+ },
343
+ score: score => `${score} 分`,
344
+ answer: value => `答案:${value}`,
345
+ rubric: value => `评分标准:${value}`,
346
+ gradedScore: (earned, max) => `得分:${earned} / ${max}`,
347
+ feedback: "反馈",
348
+ classification: "分组",
349
+ interpretation: "解读",
350
+ reviewRequired: "需要复核",
351
+ status: {
352
+ correct: "正确",
353
+ incorrect: "错误",
354
+ partial: "部分得分",
355
+ scored: "已评分",
356
+ needsReview: "待复核",
357
+ error: "异常",
358
+ ungraded: "未评分",
359
+ },
360
+ openPlaceholder: "请输入答案...",
361
+ },
362
+ step: {
363
+ annotationPlaceholder: "备注",
364
+ annotationToggle: "备注",
365
+ estimatedDuration: value => `预计:${value}`,
366
+ estimatedBadge: value => `预计 ${value}`,
367
+ remainingDuration: value => `剩余:${value}`,
368
+ remainingBadge: value => `剩余 ${value}`,
369
+ overtimeDuration: value => `超时:${value}`,
370
+ overtimeBadge: value => `超时 ${value}`,
371
+ recordedDuration: value => `已记录:${value}`,
372
+ recordedBadge: value => `计时 ${value}`,
373
+ protocolEstimatedTotal: value => `协议预计总时长 ${value}`,
374
+ protocolRecordedTotal: value => `协议已记录时长 ${value}`,
375
+ timerToggle: "计时",
376
+ startTimer: "开始",
377
+ pauseTimer: "暂停",
378
+ resumeTimer: "继续",
379
+ resetTimer: "重置",
380
+ },
381
+ check: {
382
+ annotationPlaceholder: "检查备注",
383
+ },
384
+ table: {
385
+ actionColumn: "操作",
386
+ dragDisabled: "只读模式下无法拖拽",
387
+ dragReorder: "拖拽调整行顺序",
388
+ deleteRow: "删除",
389
+ addRow: "添加行",
390
+ },
391
+ dna: {
392
+ editMode: "编辑模式",
393
+ interactiveMode: "交互式",
394
+ rawMode: "原始结构",
395
+ topology: "拓扑",
396
+ linear: "线性",
397
+ circular: "环状",
398
+ sequence: "序列",
399
+ sequenceName: "序列名称",
400
+ sequenceNamePlaceholder: "可选的质粒或序列名称",
401
+ sequencePlaceholder: "粘贴或输入 DNA 序列,支持 IUPAC DNA 字母",
402
+ viewer: "序列视图",
403
+ viewerHint: "直接在序列上拖拽选择范围,点击已有特征可在当前注释面板中编辑。",
404
+ viewerRequiresSequence: "先粘贴一段 DNA 序列,或使用工具栏中的“导入文件”。",
405
+ onboardingPasteLabel: "粘贴序列",
406
+ onboardingApplySequence: "使用这段序列",
407
+ onboardingImportFile: "导入文件",
408
+ onboardingImportHint: "目前支持纯 DNA 文本、FASTA 和 GenBank 序列导入;文件请使用工具栏中的“导入文件”,原始结构模式仍可用于高级修整。",
409
+ onboardingNoSequenceDetected: "在粘贴内容或导入文件中没有识别到 DNA 序列。",
410
+ onboardingImportReadError: "无法读取所选文件。",
411
+ importReplaceConfirm: "导入文件或粘贴新序列会替换当前 DNA 序列,并清空现有注释。是否继续?",
412
+ selection: "当前选择",
413
+ selectionEmpty: "请先在序列上拖拽选择范围,再创建或更新注释。",
414
+ selectionClear: "清除选择",
415
+ selectionRange: value => `范围:${value}`,
416
+ selectionTarget: value => `目标:${value}`,
417
+ selectionModeSequence: "序列范围",
418
+ createFromSelection: "创建注释",
419
+ applySelectionToSegment: "应用到当前片段",
420
+ annotations: "注释",
421
+ addAnnotation: "添加注释",
422
+ exportGenBank: "导出 GenBank",
423
+ removeAnnotation: "删除注释",
424
+ editAnnotation: "编辑",
425
+ focusAnnotation: "在视图中定位",
426
+ noAnnotations: "还没有注释。",
427
+ interactiveDetails: "当前注释",
428
+ interactiveDetailsHint: "交互式模式适合拖拽选区和快速修改基础属性;多段位置、限定词和批量管理请切到原始结构模式。",
429
+ interactiveDetailsEmpty: "请先在视图中点击一个特征,或先拖拽选择范围创建注释。",
430
+ advancedEditor: "原始结构编辑",
431
+ advancedEditorHint: "原始结构模式用于序列原文、多段位置、限定词和精确坐标修正。",
432
+ advancedEditorEmpty: "请选择或创建一个注释后再编辑结构化字段。",
433
+ selectedAnnotation: value => `当前注释:${value}`,
434
+ annotationName: "名称",
435
+ annotationType: "类型",
436
+ segments: "位置片段",
437
+ addSegment: "添加片段",
438
+ removeSegment: "删除片段",
439
+ start: "起点",
440
+ end: "终点",
441
+ partialStart: "起点不完整",
442
+ partialEnd: "终点不完整",
443
+ strand: "链方向",
444
+ forward: "正链",
445
+ reverse: "反链",
446
+ qualifiers: "限定词",
447
+ addQualifier: "添加限定词",
448
+ removeQualifier: "删除限定词",
449
+ noQualifiers: "还没有限定词。",
450
+ qualifierKey: "键",
451
+ qualifierValue: "值",
452
+ color: "颜色",
453
+ iupacHint: "支持 IUPAC DNA 字母:A、C、G、T、R、Y、S、W、K、M、B、D、H、V、N。",
454
+ invalidCharacters: chars => `存在不支持的序列字符:${chars}`,
455
+ length: count => `长度:${count} bp`,
456
+ gc: value => `GC:${value}`,
457
+ gcUnavailable: "GC:-",
458
+ segmentRequiresSequence: "请先输入序列,再设置特征位置片段。",
459
+ segmentRangeError: "片段终点必须大于或等于起点。",
460
+ segmentOutOfBounds: (end, length) => `片段终点 ${end} 超出了序列长度 ${length}。`,
461
+ },
462
+ common: {
463
+ emptyContent: "没有可渲染的协议内容。",
464
+ },
465
+ }
466
+
467
+ const BASE_MESSAGES: Record<AimdRecorderLocale, AimdRecorderMessages> = {
468
+ "en-US": EN_US_MESSAGES,
469
+ "zh-CN": ZH_CN_MESSAGES,
470
+ }
471
+
472
+ function isPlainObject(value: unknown): value is Record<string, unknown> {
473
+ return typeof value === "object" && value !== null && !Array.isArray(value)
474
+ }
475
+
476
+ function deepMerge<T>(base: T, override?: DeepPartial<T>): T {
477
+ if (!override) {
478
+ return base
479
+ }
480
+
481
+ const result: Record<string, unknown> = { ...(base as Record<string, unknown>) }
482
+
483
+ for (const key of Object.keys(override) as Array<keyof T>) {
484
+ const overrideValue = override[key]
485
+ if (overrideValue === undefined) {
486
+ continue
487
+ }
488
+
489
+ const baseValue = base[key]
490
+ if (isPlainObject(baseValue) && isPlainObject(overrideValue)) {
491
+ result[key as string] = deepMerge(baseValue, overrideValue as any)
492
+ continue
493
+ }
494
+
495
+ result[key as string] = overrideValue as T[keyof T]
496
+ }
497
+
498
+ return result as T
499
+ }
500
+
501
+ export function resolveAimdRecorderLocale(locale?: string): AimdRecorderLocale {
502
+ const runtimeLocale = locale || detectRuntimeLocale()
503
+
504
+ if (runtimeLocale?.toLowerCase().startsWith("zh")) {
505
+ return "zh-CN"
506
+ }
507
+
508
+ return DEFAULT_AIMD_RECORDER_LOCALE
509
+ }
510
+
511
+ export function createAimdRecorderMessages(
512
+ locale: string | undefined,
513
+ overrides?: AimdRecorderMessagesInput,
514
+ ): AimdRecorderMessages {
515
+ const resolvedLocale = resolveAimdRecorderLocale(locale)
516
+ const merged = deepMerge(BASE_MESSAGES[resolvedLocale], overrides)
517
+ const choiceOverride = overrides?.quiz?.types?.choice
518
+ const hasSingleChoiceOverride = overrides?.quiz?.types?.singleChoice !== undefined
519
+ const hasMultipleChoiceOverride = overrides?.quiz?.types?.multipleChoice !== undefined
520
+
521
+ if (typeof choiceOverride === "string") {
522
+ if (!hasSingleChoiceOverride) {
523
+ merged.quiz.types.singleChoice = choiceOverride
524
+ }
525
+ if (!hasMultipleChoiceOverride) {
526
+ merged.quiz.types.multipleChoice = choiceOverride
527
+ }
528
+ }
529
+
530
+ return merged
531
+ }
532
+
533
+ export function getAimdRecorderScopeLabel(
534
+ scope: string,
535
+ messages: Pick<AimdRecorderMessages, "scope">,
536
+ ): string {
537
+ switch (scope) {
538
+ case "var":
539
+ return messages.scope.var
540
+ case "quiz":
541
+ return messages.scope.quiz
542
+ case "step":
543
+ return messages.scope.step
544
+ case "check":
545
+ return messages.scope.check
546
+ case "var_table":
547
+ return messages.scope.table
548
+ default:
549
+ return scope
550
+ }
551
+ }
552
+
553
+ export function getAimdRecorderQuizTypeLabel(
554
+ quizType: string | undefined,
555
+ messages: Pick<AimdRecorderMessages, "quiz">,
556
+ quizMode?: string,
557
+ ): string {
558
+ return getSharedRendererQuizTypeLabel(quizType, quizMode, messages)
559
+ }
@@ -0,0 +1,75 @@
1
+ import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker'
2
+ import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker'
3
+ import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker'
4
+ import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker'
5
+ import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker'
6
+
7
+ const contributionLoaders: Record<string, () => Promise<unknown>> = {
8
+ css: () => import('monaco-editor/esm/vs/language/css/monaco.contribution.js'),
9
+ scss: () => import('monaco-editor/esm/vs/language/css/monaco.contribution.js'),
10
+ less: () => import('monaco-editor/esm/vs/language/css/monaco.contribution.js'),
11
+ html: () => import('monaco-editor/esm/vs/language/html/monaco.contribution.js'),
12
+ javascript: () => import('monaco-editor/esm/vs/language/typescript/monaco.contribution.js'),
13
+ typescript: () => import('monaco-editor/esm/vs/language/typescript/monaco.contribution.js'),
14
+ json: () => import('monaco-editor/esm/vs/language/json/monaco.contribution.js'),
15
+ ini: () => import('monaco-editor/esm/vs/basic-languages/ini/ini.contribution.js'),
16
+ markdown: () => import('monaco-editor/esm/vs/basic-languages/markdown/markdown.contribution.js'),
17
+ python: () => import('monaco-editor/esm/vs/basic-languages/python/python.contribution.js'),
18
+ shell: () => import('monaco-editor/esm/vs/basic-languages/shell/shell.contribution.js'),
19
+ sql: () => import('monaco-editor/esm/vs/basic-languages/sql/sql.contribution.js'),
20
+ xml: () => import('monaco-editor/esm/vs/basic-languages/xml/xml.contribution.js'),
21
+ yaml: () => import('monaco-editor/esm/vs/basic-languages/yaml/yaml.contribution.js'),
22
+ }
23
+
24
+ const loadedContributionPromises = new Map<string, Promise<void>>()
25
+
26
+ export function ensureMonacoEnvironment() {
27
+ if (typeof globalThis === 'undefined') {
28
+ return
29
+ }
30
+
31
+ const existing = (globalThis as { MonacoEnvironment?: { getWorker?: (moduleId: string, label: string) => Worker } }).MonacoEnvironment
32
+ if (typeof existing?.getWorker === 'function') {
33
+ return
34
+ }
35
+
36
+ ;(globalThis as {
37
+ MonacoEnvironment?: { getWorker: (moduleId: string, label: string) => Worker }
38
+ }).MonacoEnvironment = {
39
+ getWorker(_: string, label: string) {
40
+ if (label === 'json') {
41
+ return new jsonWorker()
42
+ }
43
+
44
+ if (label === 'css' || label === 'scss' || label === 'less') {
45
+ return new cssWorker()
46
+ }
47
+
48
+ if (label === 'html' || label === 'handlebars' || label === 'razor') {
49
+ return new htmlWorker()
50
+ }
51
+
52
+ if (label === 'typescript' || label === 'javascript') {
53
+ return new tsWorker()
54
+ }
55
+
56
+ return new editorWorker()
57
+ },
58
+ }
59
+ }
60
+
61
+ export async function ensureMonacoLanguageContribution(language: string): Promise<void> {
62
+ const loader = contributionLoaders[language]
63
+ if (!loader) {
64
+ return
65
+ }
66
+
67
+ const existingPromise = loadedContributionPromises.get(language)
68
+ if (existingPromise) {
69
+ return existingPromise
70
+ }
71
+
72
+ const loadingPromise = Promise.resolve(loader()).then(() => undefined)
73
+ loadedContributionPromises.set(language, loadingPromise)
74
+ return loadingPromise
75
+ }