@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
@@ -0,0 +1,206 @@
1
+ import { m as l } from "./editor.api-CgD9w0gG.js";
2
+ var i = Object.defineProperty, c = Object.getOwnPropertyDescriptor, u = Object.getOwnPropertyNames, s = Object.prototype.hasOwnProperty, d = (n, e, r, o) => {
3
+ if (e && typeof e == "object" || typeof e == "function")
4
+ for (let t of u(e))
5
+ !s.call(n, t) && t !== r && i(n, t, { get: () => e[t], enumerable: !(o = c(e, t)) || o.enumerable });
6
+ return n;
7
+ }, m = (n, e, r) => (d(n, e, "default"), r), a = {};
8
+ m(a, l);
9
+ var p = {
10
+ comments: {
11
+ lineComment: "#"
12
+ },
13
+ brackets: [
14
+ ["{", "}"],
15
+ ["[", "]"],
16
+ ["(", ")"]
17
+ ],
18
+ autoClosingPairs: [
19
+ { open: "{", close: "}" },
20
+ { open: "[", close: "]" },
21
+ { open: "(", close: ")" },
22
+ { open: '"', close: '"' },
23
+ { open: "'", close: "'" }
24
+ ],
25
+ surroundingPairs: [
26
+ { open: "{", close: "}" },
27
+ { open: "[", close: "]" },
28
+ { open: "(", close: ")" },
29
+ { open: '"', close: '"' },
30
+ { open: "'", close: "'" }
31
+ ],
32
+ folding: {
33
+ offSide: !0
34
+ },
35
+ onEnterRules: [
36
+ {
37
+ beforeText: /:\s*$/,
38
+ action: {
39
+ indentAction: a.languages.IndentAction.Indent
40
+ }
41
+ }
42
+ ]
43
+ }, f = {
44
+ tokenPostfix: ".yaml",
45
+ brackets: [
46
+ { token: "delimiter.bracket", open: "{", close: "}" },
47
+ { token: "delimiter.square", open: "[", close: "]" }
48
+ ],
49
+ keywords: ["true", "True", "TRUE", "false", "False", "FALSE", "null", "Null", "Null", "~"],
50
+ numberInteger: /(?:0|[+-]?[0-9]+)/,
51
+ numberFloat: /(?:0|[+-]?[0-9]+)(?:\.[0-9]+)?(?:e[-+][1-9][0-9]*)?/,
52
+ numberOctal: /0o[0-7]+/,
53
+ numberHex: /0x[0-9a-fA-F]+/,
54
+ numberInfinity: /[+-]?\.(?:inf|Inf|INF)/,
55
+ numberNaN: /\.(?:nan|Nan|NAN)/,
56
+ numberDate: /\d{4}-\d\d-\d\d([Tt ]\d\d:\d\d:\d\d(\.\d+)?(( ?[+-]\d\d?(:\d\d)?)|Z)?)?/,
57
+ escapes: /\\(?:[btnfr\\"']|[0-7][0-7]?|[0-3][0-7]{2})/,
58
+ tokenizer: {
59
+ root: [
60
+ { include: "@whitespace" },
61
+ { include: "@comment" },
62
+ // Directive
63
+ [/%[^ ]+.*$/, "meta.directive"],
64
+ // Document Markers
65
+ [/---/, "operators.directivesEnd"],
66
+ [/\.{3}/, "operators.documentEnd"],
67
+ // Block Structure Indicators
68
+ [/[-?:](?= )/, "operators"],
69
+ { include: "@anchor" },
70
+ { include: "@tagHandle" },
71
+ { include: "@flowCollections" },
72
+ { include: "@blockStyle" },
73
+ // Numbers
74
+ [/@numberInteger(?![ \t]*\S+)/, "number"],
75
+ [/@numberFloat(?![ \t]*\S+)/, "number.float"],
76
+ [/@numberOctal(?![ \t]*\S+)/, "number.octal"],
77
+ [/@numberHex(?![ \t]*\S+)/, "number.hex"],
78
+ [/@numberInfinity(?![ \t]*\S+)/, "number.infinity"],
79
+ [/@numberNaN(?![ \t]*\S+)/, "number.nan"],
80
+ [/@numberDate(?![ \t]*\S+)/, "number.date"],
81
+ // Key:Value pair
82
+ [/(".*?"|'.*?'|[^#'"]*?)([ \t]*)(:)( |$)/, ["type", "white", "operators", "white"]],
83
+ { include: "@flowScalars" },
84
+ // String nodes
85
+ [
86
+ /.+?(?=(\s+#|$))/,
87
+ {
88
+ cases: {
89
+ "@keywords": "keyword",
90
+ "@default": "string"
91
+ }
92
+ }
93
+ ]
94
+ ],
95
+ // Flow Collection: Flow Mapping
96
+ object: [
97
+ { include: "@whitespace" },
98
+ { include: "@comment" },
99
+ // Flow Mapping termination
100
+ [/\}/, "@brackets", "@pop"],
101
+ // Flow Mapping delimiter
102
+ [/,/, "delimiter.comma"],
103
+ // Flow Mapping Key:Value delimiter
104
+ [/:(?= )/, "operators"],
105
+ // Flow Mapping Key:Value key
106
+ [/(?:".*?"|'.*?'|[^,\{\[]+?)(?=: )/, "type"],
107
+ // Start Flow Style
108
+ { include: "@flowCollections" },
109
+ { include: "@flowScalars" },
110
+ // Scalar Data types
111
+ { include: "@tagHandle" },
112
+ { include: "@anchor" },
113
+ { include: "@flowNumber" },
114
+ // Other value (keyword or string)
115
+ [
116
+ /[^\},]+/,
117
+ {
118
+ cases: {
119
+ "@keywords": "keyword",
120
+ "@default": "string"
121
+ }
122
+ }
123
+ ]
124
+ ],
125
+ // Flow Collection: Flow Sequence
126
+ array: [
127
+ { include: "@whitespace" },
128
+ { include: "@comment" },
129
+ // Flow Sequence termination
130
+ [/\]/, "@brackets", "@pop"],
131
+ // Flow Sequence delimiter
132
+ [/,/, "delimiter.comma"],
133
+ // Start Flow Style
134
+ { include: "@flowCollections" },
135
+ { include: "@flowScalars" },
136
+ // Scalar Data types
137
+ { include: "@tagHandle" },
138
+ { include: "@anchor" },
139
+ { include: "@flowNumber" },
140
+ // Other value (keyword or string)
141
+ [
142
+ /[^\],]+/,
143
+ {
144
+ cases: {
145
+ "@keywords": "keyword",
146
+ "@default": "string"
147
+ }
148
+ }
149
+ ]
150
+ ],
151
+ // First line of a Block Style
152
+ multiString: [[/^( +).+$/, "string", "@multiStringContinued.$1"]],
153
+ // Further lines of a Block Style
154
+ // Workaround for indentation detection
155
+ multiStringContinued: [
156
+ [
157
+ /^( *).+$/,
158
+ {
159
+ cases: {
160
+ "$1==$S2": "string",
161
+ "@default": { token: "@rematch", next: "@popall" }
162
+ }
163
+ }
164
+ ]
165
+ ],
166
+ whitespace: [[/[ \t\r\n]+/, "white"]],
167
+ // Only line comments
168
+ comment: [[/#.*$/, "comment"]],
169
+ // Start Flow Collections
170
+ flowCollections: [
171
+ [/\[/, "@brackets", "@array"],
172
+ [/\{/, "@brackets", "@object"]
173
+ ],
174
+ // Start Flow Scalars (quoted strings)
175
+ flowScalars: [
176
+ [/"([^"\\]|\\.)*$/, "string.invalid"],
177
+ [/'([^'\\]|\\.)*$/, "string.invalid"],
178
+ [/'[^']*'/, "string"],
179
+ [/"/, "string", "@doubleQuotedString"]
180
+ ],
181
+ doubleQuotedString: [
182
+ [/[^\\"]+/, "string"],
183
+ [/@escapes/, "string.escape"],
184
+ [/\\./, "string.escape.invalid"],
185
+ [/"/, "string", "@pop"]
186
+ ],
187
+ // Start Block Scalar
188
+ blockStyle: [[/[>|][0-9]*[+-]?$/, "operators", "@multiString"]],
189
+ // Numbers in Flow Collections (terminate with ,]})
190
+ flowNumber: [
191
+ [/@numberInteger(?=[ \t]*[,\]\}])/, "number"],
192
+ [/@numberFloat(?=[ \t]*[,\]\}])/, "number.float"],
193
+ [/@numberOctal(?=[ \t]*[,\]\}])/, "number.octal"],
194
+ [/@numberHex(?=[ \t]*[,\]\}])/, "number.hex"],
195
+ [/@numberInfinity(?=[ \t]*[,\]\}])/, "number.infinity"],
196
+ [/@numberNaN(?=[ \t]*[,\]\}])/, "number.nan"],
197
+ [/@numberDate(?=[ \t]*[,\]\}])/, "number.date"]
198
+ ],
199
+ tagHandle: [[/\![^ ]*/, "tag"]],
200
+ anchor: [[/[&*][^ ]+/, "namespace"]]
201
+ }
202
+ };
203
+ export {
204
+ p as conf,
205
+ f as language
206
+ };
@@ -0,0 +1,8 @@
1
+ import { r as a } from "./_.contribution-IP0cDNhs.js";
2
+ a({
3
+ id: "yaml",
4
+ extensions: [".yaml", ".yml"],
5
+ aliases: ["YAML", "yaml", "YML", "yml"],
6
+ mimetypes: ["application/x-yaml", "text/x-yaml"],
7
+ loader: () => import("./yaml-C1p8rXG7.js")
8
+ });
package/package.json ADDED
@@ -0,0 +1,88 @@
1
+ {
2
+ "name": "@airalogy/aimd-recorder",
3
+ "type": "module",
4
+ "version": "1.14.1",
5
+ "description": "AIMD editor Vue components and UI",
6
+ "license": "Apache-2.0",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/airalogy/aimd.git",
10
+ "directory": "packages/aimd-recorder"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/airalogy/aimd/issues"
14
+ },
15
+ "homepage": "https://github.com/airalogy/aimd/tree/main/packages/aimd-recorder#readme",
16
+ "keywords": [
17
+ "aimd",
18
+ "markdown",
19
+ "editor",
20
+ "vue",
21
+ "components"
22
+ ],
23
+ "exports": {
24
+ ".": {
25
+ "types": "./src/index.ts",
26
+ "import": "./src/index.ts"
27
+ },
28
+ "./components": {
29
+ "types": "./src/components/index.ts",
30
+ "import": "./src/components/index.ts"
31
+ },
32
+ "./composables": {
33
+ "types": "./src/composables/index.ts",
34
+ "import": "./src/composables/index.ts"
35
+ },
36
+ "./styles": {
37
+ "import": "./src/styles/aimd.css",
38
+ "default": "./src/styles/aimd.css"
39
+ }
40
+ },
41
+ "main": "./src/index.ts",
42
+ "types": "./src/index.ts",
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "files": [
47
+ "dist",
48
+ "src"
49
+ ],
50
+ "scripts": {
51
+ "type-check": "vue-tsc --noEmit",
52
+ "build": "vite build",
53
+ "dev": "vite build --watch",
54
+ "test": "vitest run --config vitest.config.ts"
55
+ },
56
+ "peerDependencies": {
57
+ "@vueuse/core": "^13.5.0",
58
+ "naive-ui": "2.41.0",
59
+ "vue": "^3.5.17"
60
+ },
61
+ "dependencies": {
62
+ "@airalogy/aimd-editor": "workspace:^",
63
+ "@airalogy/aimd-core": "workspace:^",
64
+ "@airalogy/aimd-renderer": "workspace:^",
65
+ "@milkdown/kit": "^7.18.0",
66
+ "monaco-editor": "^0.52.2",
67
+ "react": "^19.2.4",
68
+ "react-dom": "^19.2.4",
69
+ "seqviz": "^3.10.18"
70
+ },
71
+ "devDependencies": {
72
+ "@types/node": "^24.3.0",
73
+ "@types/react": "^19.2.14",
74
+ "@types/react-dom": "^19.2.3",
75
+ "@vitejs/plugin-vue": "^6.0.1",
76
+ "@vueuse/core": "^13.5.0",
77
+ "naive-ui": "2.41.0",
78
+ "sass": "^1.90.0",
79
+ "typescript": "5.8.3",
80
+ "unocss": "^0.58.3",
81
+ "unplugin-auto-import": "^0.17.3",
82
+ "unplugin-vue-components": "^0.27.4",
83
+ "vite": "^7.1.3",
84
+ "vite-tsconfig-paths": "^5.1.4",
85
+ "vue": "^3.5.17",
86
+ "vue-tsc": "^3.0.6"
87
+ }
88
+ }
@@ -0,0 +1,341 @@
1
+ import { describe, expect, it } from 'vitest'
2
+
3
+ import { applyClientAssigners } from '../client-assigner'
4
+ import type { AimdClientAssignerField } from '@airalogy/aimd-core/types'
5
+
6
+ function makeAssigner(overrides: Partial<AimdClientAssignerField> & { id: string }): AimdClientAssignerField {
7
+ return {
8
+ runtime: 'client',
9
+ mode: 'auto',
10
+ function_source: 'function assign(fields) { return {}; }',
11
+ dependent_fields: [],
12
+ assigned_fields: [],
13
+ ...overrides,
14
+ } as AimdClientAssignerField
15
+ }
16
+
17
+ // ---------------------------------------------------------------------------
18
+ // Basic compilation & execution
19
+ // ---------------------------------------------------------------------------
20
+
21
+ describe('client-assigner: compilation', () => {
22
+ it('compiles and executes a simple assigner', () => {
23
+ const assigners = [makeAssigner({
24
+ id: 'sum',
25
+ function_source: 'function assign(fields) { return { total: fields.a + fields.b }; }',
26
+ dependent_fields: ['a', 'b'],
27
+ assigned_fields: ['total'],
28
+ })]
29
+
30
+ const values: Record<string, unknown> = { a: 10, b: 20, total: 0 }
31
+ const result = applyClientAssigners(assigners, values)
32
+
33
+ expect(result.changed).toBe(true)
34
+ expect(result.changedFields).toContain('total')
35
+ expect(values.total).toBe(30)
36
+ })
37
+
38
+ it('handles local variables in function body', () => {
39
+ const assigners = [makeAssigner({
40
+ id: 'calc',
41
+ function_source: 'function assign(fields) { var x = fields.a * 2; return { result: x }; }',
42
+ dependent_fields: ['a'],
43
+ assigned_fields: ['result'],
44
+ })]
45
+
46
+ const values: Record<string, unknown> = { a: 5, result: 0 }
47
+ applyClientAssigners(assigners, values)
48
+ expect(values.result).toBe(10)
49
+ })
50
+
51
+ it('reports no change when values are identical', () => {
52
+ const assigners = [makeAssigner({
53
+ id: 'noop',
54
+ function_source: 'function assign(fields) { return { x: fields.x }; }',
55
+ dependent_fields: ['x'],
56
+ assigned_fields: ['x'],
57
+ })]
58
+
59
+ const values: Record<string, unknown> = { x: 42 }
60
+ const result = applyClientAssigners(assigners, values)
61
+ expect(result.changed).toBe(false)
62
+ })
63
+
64
+ it('returns empty result for no assigners', () => {
65
+ const result = applyClientAssigners([], {})
66
+ expect(result.changed).toBe(false)
67
+ expect(result.changedFields).toEqual([])
68
+ })
69
+ })
70
+
71
+ // ---------------------------------------------------------------------------
72
+ // Execution modes
73
+ // ---------------------------------------------------------------------------
74
+
75
+ describe('client-assigner: modes', () => {
76
+ it('skips manual mode without explicit trigger', () => {
77
+ const assigners = [makeAssigner({
78
+ id: 'manual_calc',
79
+ mode: 'manual',
80
+ function_source: 'function assign(fields) { return { y: 999 }; }',
81
+ dependent_fields: ['x'],
82
+ assigned_fields: ['y'],
83
+ })]
84
+
85
+ const values: Record<string, unknown> = { x: 1, y: 0 }
86
+ applyClientAssigners(assigners, values)
87
+ expect(values.y).toBe(0)
88
+ })
89
+
90
+ it('runs manual mode with explicit trigger', () => {
91
+ const assigners = [makeAssigner({
92
+ id: 'manual_calc',
93
+ mode: 'manual',
94
+ function_source: 'function assign(fields) { return { y: 999 }; }',
95
+ dependent_fields: ['x'],
96
+ assigned_fields: ['y'],
97
+ })]
98
+
99
+ const values: Record<string, unknown> = { x: 1, y: 0 }
100
+ applyClientAssigners(assigners, values, { triggerIds: ['manual_calc'] })
101
+ expect(values.y).toBe(999)
102
+ })
103
+
104
+ it('auto_first runs only when assigned fields are empty', () => {
105
+ const assigners = [makeAssigner({
106
+ id: 'init',
107
+ mode: 'auto_first',
108
+ function_source: 'function assign(fields) { return { y: fields.x * 2 }; }',
109
+ dependent_fields: ['x'],
110
+ assigned_fields: ['y'],
111
+ })]
112
+
113
+ // y is empty → should run
114
+ const values1: Record<string, unknown> = { x: 5, y: '' }
115
+ applyClientAssigners(assigners, values1)
116
+ expect(values1.y).toBe(10)
117
+
118
+ // y is already set → should NOT run
119
+ const values2: Record<string, unknown> = { x: 5, y: 10 }
120
+ applyClientAssigners(assigners, values2)
121
+ expect(values2.y).toBe(10)
122
+ })
123
+
124
+ it('auto_force always runs', () => {
125
+ const assigners = [makeAssigner({
126
+ id: 'force',
127
+ mode: 'auto',
128
+ function_source: 'function assign(fields) { return { y: fields.x + 1 }; }',
129
+ dependent_fields: ['x'],
130
+ assigned_fields: ['y'],
131
+ })]
132
+
133
+ const values: Record<string, unknown> = { x: 5, y: 100 }
134
+ applyClientAssigners(assigners, values)
135
+ expect(values.y).toBe(6)
136
+ })
137
+ })
138
+
139
+ // ---------------------------------------------------------------------------
140
+ // Dependency ordering
141
+ // ---------------------------------------------------------------------------
142
+
143
+ describe('client-assigner: dependency ordering', () => {
144
+ it('executes assigners in dependency order', () => {
145
+ const assigners = [
146
+ makeAssigner({
147
+ id: 'second',
148
+ function_source: 'function assign(fields) { return { c: fields.b + 1 }; }',
149
+ dependent_fields: ['b'],
150
+ assigned_fields: ['c'],
151
+ }),
152
+ makeAssigner({
153
+ id: 'first',
154
+ function_source: 'function assign(fields) { return { b: fields.a + 1 }; }',
155
+ dependent_fields: ['a'],
156
+ assigned_fields: ['b'],
157
+ }),
158
+ ]
159
+
160
+ const values: Record<string, unknown> = { a: 1, b: 0, c: 0 }
161
+ applyClientAssigners(assigners, values)
162
+ expect(values.b).toBe(2)
163
+ expect(values.c).toBe(3)
164
+ })
165
+
166
+ it('skips assigners with unready dependencies', () => {
167
+ const assigners = [makeAssigner({
168
+ id: 'calc',
169
+ function_source: 'function assign(fields) { return { y: fields.x + 1 }; }',
170
+ dependent_fields: ['x'],
171
+ assigned_fields: ['y'],
172
+ })]
173
+
174
+ const values: Record<string, unknown> = { x: '', y: 0 }
175
+ const result = applyClientAssigners(assigners, values)
176
+ expect(result.changed).toBe(false)
177
+ expect(values.y).toBe(0)
178
+ })
179
+ })
180
+
181
+ // ---------------------------------------------------------------------------
182
+ // Error handling
183
+ // ---------------------------------------------------------------------------
184
+
185
+ describe('client-assigner: error handling', () => {
186
+ it('throws if assigner returns non-object', () => {
187
+ const assigners = [makeAssigner({
188
+ id: 'bad',
189
+ function_source: 'function assign(fields) { return 42; }',
190
+ dependent_fields: [],
191
+ assigned_fields: ['x'],
192
+ })]
193
+
194
+ const values: Record<string, unknown> = { x: 0 }
195
+ expect(() => applyClientAssigners(assigners, values)).toThrow('must return an object')
196
+ })
197
+
198
+ it('throws if missing assigned fields', () => {
199
+ const assigners = [makeAssigner({
200
+ id: 'bad',
201
+ function_source: 'function assign(fields) { return {}; }',
202
+ dependent_fields: [],
203
+ assigned_fields: ['x'],
204
+ })]
205
+
206
+ const values: Record<string, unknown> = { x: 0 }
207
+ expect(() => applyClientAssigners(assigners, values)).toThrow('missing assigned fields')
208
+ })
209
+
210
+ it('throws if extra fields returned', () => {
211
+ const assigners = [makeAssigner({
212
+ id: 'bad',
213
+ function_source: 'function assign(fields) { return { x: 1, extra: 2 }; }',
214
+ dependent_fields: [],
215
+ assigned_fields: ['x'],
216
+ })]
217
+
218
+ const values: Record<string, unknown> = { x: 0 }
219
+ expect(() => applyClientAssigners(assigners, values)).toThrow('not declared in assigned_fields')
220
+ })
221
+ })
222
+
223
+ // ---------------------------------------------------------------------------
224
+ // Sandbox & security
225
+ // ---------------------------------------------------------------------------
226
+
227
+ describe('client-assigner: sandbox escape prevention', () => {
228
+ it('rejects function source referencing window', () => {
229
+ const assigners = [makeAssigner({
230
+ id: 'escape_win',
231
+ function_source: 'function assign(fields) { return { x: typeof window }; }',
232
+ dependent_fields: [],
233
+ assigned_fields: ['x'],
234
+ })]
235
+
236
+ const values: Record<string, unknown> = { x: '' }
237
+ expect(() => applyClientAssigners(assigners, values)).toThrow()
238
+ })
239
+
240
+ it('rejects function source referencing document', () => {
241
+ const assigners = [makeAssigner({
242
+ id: 'escape_doc',
243
+ function_source: 'function assign(fields) { return { x: typeof document }; }',
244
+ dependent_fields: [],
245
+ assigned_fields: ['x'],
246
+ })]
247
+
248
+ const values: Record<string, unknown> = { x: '' }
249
+ expect(() => applyClientAssigners(assigners, values)).toThrow()
250
+ })
251
+
252
+ it('rejects function source referencing globalThis', () => {
253
+ const assigners = [makeAssigner({
254
+ id: 'escape_gt',
255
+ function_source: 'function assign(fields) { return { x: typeof globalThis }; }',
256
+ dependent_fields: [],
257
+ assigned_fields: ['x'],
258
+ })]
259
+
260
+ const values: Record<string, unknown> = { x: '' }
261
+ expect(() => applyClientAssigners(assigners, values)).toThrow()
262
+ })
263
+
264
+ it('rejects function source referencing fetch', () => {
265
+ const assigners = [makeAssigner({
266
+ id: 'escape_fetch',
267
+ function_source: 'function assign(fields) { return { x: typeof fetch }; }',
268
+ dependent_fields: [],
269
+ assigned_fields: ['x'],
270
+ })]
271
+
272
+ const values: Record<string, unknown> = { x: '' }
273
+ expect(() => applyClientAssigners(assigners, values)).toThrow()
274
+ })
275
+
276
+ it('has access to safe Math', () => {
277
+ const assigners = [makeAssigner({
278
+ id: 'math_test',
279
+ function_source: 'function assign(fields) { return { x: Math.round(3.7) }; }',
280
+ dependent_fields: [],
281
+ assigned_fields: ['x'],
282
+ })]
283
+
284
+ const values: Record<string, unknown> = { x: 0 }
285
+ applyClientAssigners(assigners, values)
286
+ expect(values.x).toBe(4)
287
+ })
288
+
289
+ it('has access to safe JSON', () => {
290
+ const assigners = [makeAssigner({
291
+ id: 'json_test',
292
+ function_source: 'function assign(fields) { return { x: JSON.parse(JSON.stringify({a:1})) }; }',
293
+ dependent_fields: [],
294
+ assigned_fields: ['x'],
295
+ })]
296
+
297
+ const values: Record<string, unknown> = { x: null }
298
+ applyClientAssigners(assigners, values)
299
+ expect(values.x).toEqual({ a: 1 })
300
+ })
301
+
302
+ it('has access to safe Object methods', () => {
303
+ const assigners = [makeAssigner({
304
+ id: 'obj_test',
305
+ function_source: 'function assign(fields) { return { x: Object.keys(fields).length }; }',
306
+ dependent_fields: ['a', 'b'],
307
+ assigned_fields: ['x'],
308
+ })]
309
+
310
+ const values: Record<string, unknown> = { a: 1, b: 2, x: 0 }
311
+ applyClientAssigners(assigners, values)
312
+ expect(values.x).toBe(2)
313
+ })
314
+
315
+ it('has access to safe Array.isArray', () => {
316
+ const assigners = [makeAssigner({
317
+ id: 'arr_test',
318
+ function_source: 'function assign(fields) { return { x: Array.isArray(fields.data) }; }',
319
+ dependent_fields: ['data'],
320
+ assigned_fields: ['x'],
321
+ })]
322
+
323
+ const values: Record<string, unknown> = { data: [1, 2], x: false }
324
+ applyClientAssigners(assigners, values)
325
+ expect(values.x).toBe(true)
326
+ })
327
+
328
+ it('clones dependent field values (no mutation leak)', () => {
329
+ const assigners = [makeAssigner({
330
+ id: 'mutate_test',
331
+ function_source: 'function assign(fields) { fields.data.push(99); return { x: fields.data.length }; }',
332
+ dependent_fields: ['data'],
333
+ assigned_fields: ['x'],
334
+ })]
335
+
336
+ const originalData = [1, 2, 3]
337
+ const values: Record<string, unknown> = { data: originalData, x: 0 }
338
+ applyClientAssigners(assigners, values)
339
+ expect(originalData).toEqual([1, 2, 3])
340
+ })
341
+ })
@@ -0,0 +1,30 @@
1
+ import { describe, expect, it } from 'vitest'
2
+
3
+ import { isAimdCodeEditorType, resolveAimdCodeEditorLanguage } from '../code-types'
4
+
5
+ describe('code-types', () => {
6
+ it('maps built-in Airalogy CodeStr types to Monaco languages', () => {
7
+ expect(resolveAimdCodeEditorLanguage('PyStr')).toBe('python')
8
+ expect(resolveAimdCodeEditorLanguage('JsStr')).toBe('javascript')
9
+ expect(resolveAimdCodeEditorLanguage('TsStr')).toBe('typescript')
10
+ expect(resolveAimdCodeEditorLanguage('JsonStr')).toBe('json')
11
+ expect(resolveAimdCodeEditorLanguage('YamlStr')).toBe('yaml')
12
+ expect(resolveAimdCodeEditorLanguage('TomlStr')).toBe('ini')
13
+ expect(resolveAimdCodeEditorLanguage('CodeStr')).toBe('plaintext')
14
+ })
15
+
16
+ it('accepts field-meta overrides for generic code editors', () => {
17
+ expect(resolveAimdCodeEditorLanguage('str', { codeLanguage: 'python' })).toBe('python')
18
+ expect(resolveAimdCodeEditorLanguage('str', { inputType: 'yaml' })).toBe('yaml')
19
+ expect(resolveAimdCodeEditorLanguage('str', { inputType: 'code', codeLanguage: 'sql' })).toBe('sql')
20
+ })
21
+
22
+ it('distinguishes code-like and non-code fields', () => {
23
+ expect(isAimdCodeEditorType('PyStr')).toBe(true)
24
+ expect(isAimdCodeEditorType('CodeStr')).toBe(true)
25
+ expect(isAimdCodeEditorType('str', { inputType: 'code' })).toBe(true)
26
+ expect(isAimdCodeEditorType('str', { codeLanguage: 'python' })).toBe(true)
27
+ expect(isAimdCodeEditorType('str')).toBe(false)
28
+ expect(isAimdCodeEditorType('markdown', { inputType: 'text' })).toBe(false)
29
+ })
30
+ })