claude-flow-novice 2.0.3 → 2.0.5

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 (228) hide show
  1. package/dist/src/cli/commands/swarm.js +1 -1
  2. package/dist/src/cli/main.js +1 -1
  3. package/dist/src/coordination/byzantine-memory-channels.js +25 -1
  4. package/dist/src/index.js +384 -35
  5. package/dist/src/utils/error-handler.js +2 -36
  6. package/dist/src/web/api/apm-routes.js +353 -0
  7. package/dist/src/web/api/config/api-config.js +184 -0
  8. package/dist/src/web/api/middleware/auth.js +203 -0
  9. package/dist/src/web/api/middleware/cache.js +273 -0
  10. package/dist/src/web/api/middleware/error-handler.js +257 -0
  11. package/dist/src/web/api/middleware/request-logger.js +215 -0
  12. package/dist/src/web/api/middleware/validation.js +323 -0
  13. package/dist/src/web/api/routes/events.js +463 -0
  14. package/dist/src/web/api/routes/hierarchy.js +300 -0
  15. package/dist/src/web/api/routes/index.js +12 -0
  16. package/dist/src/web/api/routes/metrics.js +559 -0
  17. package/dist/src/web/api/routes/parallel-status.js +359 -0
  18. package/dist/src/web/api/routes/status.js +448 -0
  19. package/dist/src/web/api/server.js +462 -0
  20. package/dist/src/web/dashboard/hooks/useWebSocket.js +383 -0
  21. package/dist/src/web/dashboard/index.js +85 -0
  22. package/dist/src/web/dashboard/realtime/CustomSyncManager.js +439 -0
  23. package/dist/src/web/dashboard/realtime/NativeWebSocketManager.js +323 -0
  24. package/dist/src/web/dashboard/realtime/PerformanceBenchmark.js +527 -0
  25. package/dist/src/web/dashboard/realtime/RealtimeCommunicationManager.js +474 -0
  26. package/dist/src/web/dashboard/realtime/RealtimeServer.js +666 -0
  27. package/dist/src/web/dashboard/realtime/SSEManager.js +426 -0
  28. package/dist/src/web/dashboard/types.js +4 -0
  29. package/dist/src/web/messaging/agent-status-tracker.js +453 -0
  30. package/dist/src/web/messaging/human-intervention-system.js +305 -0
  31. package/dist/src/web/messaging/message-filter.js +302 -0
  32. package/dist/src/web/messaging/swarm-message-router.js +324 -0
  33. package/dist/src/web/messaging/transparency-logger.js +421 -0
  34. package/dist/src/web/portal-server.js +460 -0
  35. package/dist/src/web/server.js +322 -0
  36. package/dist/src/web/websocket/apm-websocket-handler.js +453 -0
  37. package/dist/src/web/websocket/websocket-manager.js +780 -0
  38. package/package.json +6 -4
  39. package/dist/src/cli/minimal-main.js +0 -22
  40. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/documentSymbols/browser/documentSymbols.js +0 -23
  41. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/copyPasteContribution.js +0 -57
  42. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/copyPasteController.js +0 -401
  43. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/defaultProviders.js +0 -181
  44. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/dropIntoEditorContribution.js +0 -44
  45. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/dropIntoEditorController.js +0 -157
  46. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/edit.js +0 -71
  47. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/editorState/browser/editorState.js +0 -112
  48. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findController.js +0 -990
  49. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findDecorations.js +0 -296
  50. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findModel.js +0 -488
  51. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findOptionsWidget.js +0 -138
  52. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findState.js +0 -243
  53. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findWidget.js +0 -1177
  54. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/folding/browser/folding.js +0 -1093
  55. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/folding/browser/foldingDecorations.js +0 -133
  56. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/folding/browser/foldingModel.js +0 -538
  57. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/folding/browser/foldingRanges.js +0 -351
  58. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/fontZoom/browser/fontZoom.js +0 -49
  59. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/format/browser/format.js +0 -360
  60. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/format/browser/formatActions.js +0 -263
  61. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/format/browser/formattingEdit.js +0 -54
  62. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/gotoSymbol/browser/link/clickLinkGesture.js +0 -149
  63. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/hover/browser/contentHover.js +0 -874
  64. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/inlineCompletions/browser/commandIds.js +0 -7
  65. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/inlineCompletions/browser/commands.js +0 -199
  66. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/linesOperations/browser/copyLinesCommand.js +0 -70
  67. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/quickAccess/browser/commandsQuickAccess.js +0 -26
  68. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/quickAccess/browser/editorNavigationQuickAccess.js +0 -153
  69. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/readOnlyMessage/browser/contribution.js +0 -33
  70. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/semanticTokens/browser/documentSemanticTokens.js +0 -354
  71. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/smartSelect/browser/bracketSelections.js +0 -146
  72. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/suggest/browser/completionModel.js +0 -224
  73. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/unicodeHighlighter/browser/bannerController.js +0 -119
  74. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/edcore.main.js +0 -14
  75. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/editor.all.js +0 -63
  76. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/editor.api.js +0 -55
  77. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/editor.main.js +0 -7
  78. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/editor.worker.js +0 -25
  79. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/standalone/browser/colorizer.js +0 -118
  80. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/language/css/css.worker.js +0 -36869
  81. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/language/css/cssMode.js +0 -2035
  82. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/accessibility/browser/accessibilityService.js +0 -88
  83. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/accessibility/common/accessibility.js +0 -9
  84. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/action/common/action.js +0 -7
  85. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/action/common/actionCommonCategories.js +0 -13
  86. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/actionWidget/browser/actionList.js +0 -276
  87. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/actionWidget/browser/actionWidget.js +0 -248
  88. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/actionWidget/common/actionWidget.js +0 -5
  89. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/actions/common/actions.js +0 -409
  90. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/audioCues/browser/audioCueService.js +0 -176
  91. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/clipboard/browser/clipboardService.js +0 -141
  92. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/clipboard/common/clipboardService.js +0 -6
  93. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/commands/common/commands.js +0 -80
  94. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/configuration/common/configuration.js +0 -86
  95. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/configuration/common/configurationModels.js +0 -554
  96. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/configuration/common/configurationRegistry.js +0 -317
  97. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/configuration/common/configurations.js +0 -41
  98. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextkey/browser/contextKeyService.js +0 -432
  99. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextkey/common/contextkey.js +0 -1547
  100. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextkey/common/contextkeys.js +0 -18
  101. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextview/browser/contextMenuHandler.js +0 -124
  102. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextview/browser/contextMenuService.js +0 -101
  103. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextview/browser/contextView.js +0 -7
  104. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextview/browser/contextViewService.js +0 -72
  105. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/dialogs/common/dialogs.js +0 -2
  106. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/dnd/browser/dnd.js +0 -36
  107. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/editor/common/editor.js +0 -17
  108. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/environment/common/environment.js +0 -2
  109. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/extensions/common/extensions.js +0 -47
  110. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/files/common/files.js +0 -9
  111. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/history/browser/contextScopedHistoryWidget.js +0 -105
  112. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/instantiation/common/descriptors.js +0 -11
  113. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/instantiation/common/extensions.js +0 -15
  114. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/keybinding/common/abstractKeybindingService.js +0 -277
  115. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/keybinding/common/baseResolvedKeybinding.js +0 -53
  116. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/quickinput/browser/commandsQuickAccess.js +0 -354
  117. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/theme/browser/defaultStyles.js +0 -162
  118. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/theme/common/colorRegistry.js +0 -482
  119. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/abap/abap.js +0 -10
  120. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/apex/apex.js +0 -10
  121. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/azcli/azcli.js +0 -10
  122. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/bat/bat.js +0 -10
  123. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/bicep/bicep.js +0 -11
  124. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/cameligo/cameligo.js +0 -10
  125. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/clojure/clojure.js +0 -10
  126. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/coffee/coffee.js +0 -10
  127. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/cpp/cpp.js +0 -10
  128. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/csharp/csharp.js +0 -10
  129. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/csp/csp.js +0 -10
  130. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/css/css.js +0 -12
  131. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/cypher/cypher.js +0 -10
  132. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/dart/dart.js +0 -10
  133. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/dockerfile/dockerfile.js +0 -10
  134. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/ecl/ecl.js +0 -10
  135. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/elixir/elixir.js +0 -10
  136. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/flow9/flow9.js +0 -10
  137. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.js +0 -745
  138. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.de.js +0 -31
  139. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.es.js +0 -31
  140. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.fr.js +0 -29
  141. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.it.js +0 -29
  142. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.ja.js +0 -31
  143. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.js +0 -29
  144. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.ko.js +0 -29
  145. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.ru.js +0 -31
  146. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.zh-cn.js +0 -31
  147. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.zh-tw.js +0 -29
  148. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/language/css/cssMode.js +0 -13
  149. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/language/css/cssWorker.js +0 -81
  150. package/dist/src/web/frontend/node_modules/.multicast-dns-iKseM9bB/cli.js +0 -64
  151. package/dist/src/web/frontend/node_modules/.multicast-dns-iKseM9bB/example.js +0 -36
  152. package/dist/src/web/frontend/node_modules/.multicast-dns-iKseM9bB/index.js +0 -205
  153. package/dist/src/web/frontend/node_modules/.multicast-dns-iKseM9bB/test.js +0 -260
  154. package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/async/index.browser.js +0 -34
  155. package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/async/index.js +0 -35
  156. package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/async/index.native.js +0 -26
  157. package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/index.browser.js +0 -34
  158. package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/index.js +0 -45
  159. package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/nanoid.js +0 -1
  160. package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/non-secure/index.js +0 -21
  161. package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/url-alphabet/index.js +0 -3
  162. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/bin/nodemon.js +0 -16
  163. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/cli/index.js +0 -49
  164. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/cli/parse.js +0 -230
  165. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/command.js +0 -43
  166. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/defaults.js +0 -34
  167. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/exec.js +0 -234
  168. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/index.js +0 -93
  169. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/load.js +0 -225
  170. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/help/index.js +0 -27
  171. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/index.js +0 -1
  172. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/index.js +0 -4
  173. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/match.js +0 -287
  174. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/run.js +0 -562
  175. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/signals.js +0 -34
  176. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/watch.js +0 -244
  177. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/nodemon.js +0 -317
  178. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/rules/add.js +0 -89
  179. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/rules/index.js +0 -53
  180. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/rules/parse.js +0 -43
  181. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/spawn.js +0 -74
  182. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/bus.js +0 -44
  183. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/clone.js +0 -40
  184. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/colour.js +0 -26
  185. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/index.js +0 -103
  186. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/log.js +0 -82
  187. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/merge.js +0 -47
  188. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/version.js +0 -100
  189. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/brace-expansion/index.js +0 -201
  190. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/has-flag/index.js +0 -8
  191. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/minimatch/minimatch.js +0 -947
  192. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/supports-color/browser.js +0 -5
  193. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/supports-color/index.js +0 -131
  194. package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/bin/pidtree.js +0 -128
  195. package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/index.js +0 -49
  196. package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/bin.js +0 -61
  197. package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/get.js +0 -45
  198. package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/pidtree.js +0 -104
  199. package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/ps.js +0 -47
  200. package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/wmic.js +0 -49
  201. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/doc.js +0 -1270
  202. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/acorn.js +0 -15
  203. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/angular.js +0 -2
  204. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/babel.js +0 -15
  205. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/estree.js +0 -36
  206. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/flow.js +0 -19
  207. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/glimmer.js +0 -29
  208. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/graphql.js +0 -29
  209. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/html.js +0 -22
  210. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/markdown.js +0 -63
  211. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/meriyah.js +0 -4
  212. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/postcss.js +0 -54
  213. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/typescript.js +0 -20
  214. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/yaml.js +0 -160
  215. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/standalone.js +0 -34
  216. package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/bin/react-scripts.js +0 -58
  217. package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/env.js +0 -112
  218. package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/getHttpsConfig.js +0 -74
  219. package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/jest/babelTransform.js +0 -37
  220. package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/jest/cssTransform.js +0 -22
  221. package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/jest/fileTransform.js +0 -40
  222. package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/modules.js +0 -142
  223. package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/paths.js +0 -153
  224. package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/webpack/persistentCache/createEnvironmentHash.js +0 -9
  225. package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/webpack.config.js +0 -796
  226. package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/webpackDevServer.config.js +0 -135
  227. package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/scripts/build.js +0 -225
  228. package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/scripts/eject.js +0 -340
@@ -1,1547 +0,0 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License. See License.txt in the project root for license information.
4
- *--------------------------------------------------------------------------------------------*/
5
- import { isChrome, isEdge, isFirefox, isLinux, isMacintosh, isSafari, isWeb, isWindows } from '../../../base/common/platform.js';
6
- import { isFalsyOrWhitespace } from '../../../base/common/strings.js';
7
- import { Scanner } from './scanner.js';
8
- import { createDecorator } from '../../instantiation/common/instantiation.js';
9
- import { localize } from '../../../nls.js';
10
- const CONSTANT_VALUES = new Map();
11
- CONSTANT_VALUES.set('false', false);
12
- CONSTANT_VALUES.set('true', true);
13
- CONSTANT_VALUES.set('isMac', isMacintosh);
14
- CONSTANT_VALUES.set('isLinux', isLinux);
15
- CONSTANT_VALUES.set('isWindows', isWindows);
16
- CONSTANT_VALUES.set('isWeb', isWeb);
17
- CONSTANT_VALUES.set('isMacNative', isMacintosh && !isWeb);
18
- CONSTANT_VALUES.set('isEdge', isEdge);
19
- CONSTANT_VALUES.set('isFirefox', isFirefox);
20
- CONSTANT_VALUES.set('isChrome', isChrome);
21
- CONSTANT_VALUES.set('isSafari', isSafari);
22
- const hasOwnProperty = Object.prototype.hasOwnProperty;
23
- const defaultConfig = {
24
- regexParsingWithErrorRecovery: true
25
- };
26
- const errorEmptyString = localize('contextkey.parser.error.emptyString', "Empty context key expression");
27
- const hintEmptyString = localize('contextkey.parser.error.emptyString.hint', "Did you forget to write an expression? You can also put 'false' or 'true' to always evaluate to false or true, respectively.");
28
- const errorNoInAfterNot = localize('contextkey.parser.error.noInAfterNot', "'in' after 'not'.");
29
- const errorClosingParenthesis = localize('contextkey.parser.error.closingParenthesis', "closing parenthesis ')'");
30
- const errorUnexpectedToken = localize('contextkey.parser.error.unexpectedToken', "Unexpected token");
31
- const hintUnexpectedToken = localize('contextkey.parser.error.unexpectedToken.hint', "Did you forget to put && or || before the token?");
32
- const errorUnexpectedEOF = localize('contextkey.parser.error.unexpectedEOF', "Unexpected end of expression");
33
- const hintUnexpectedEOF = localize('contextkey.parser.error.unexpectedEOF.hint', "Did you forget to put a context key?");
34
- /**
35
- * A parser for context key expressions.
36
- *
37
- * Example:
38
- * ```ts
39
- * const parser = new Parser();
40
- * const expr = parser.parse('foo == "bar" && baz == true');
41
- *
42
- * if (expr === undefined) {
43
- * // there were lexing or parsing errors
44
- * // process lexing errors with `parser.lexingErrors`
45
- * // process parsing errors with `parser.parsingErrors`
46
- * } else {
47
- * // expr is a valid expression
48
- * }
49
- * ```
50
- */
51
- export class Parser {
52
- constructor(_config = defaultConfig) {
53
- this._config = _config;
54
- // lifetime note: `_scanner` lives as long as the parser does, i.e., is not reset between calls to `parse`
55
- this._scanner = new Scanner();
56
- // lifetime note: `_tokens`, `_current`, and `_parsingErrors` must be reset between calls to `parse`
57
- this._tokens = [];
58
- this._current = 0; // invariant: 0 <= this._current < this._tokens.length ; any incrementation of this value must first call `_isAtEnd`
59
- this._parsingErrors = [];
60
- this._flagsGYRe = /g|y/g;
61
- }
62
- /**
63
- * Parse a context key expression.
64
- *
65
- * @param input the expression to parse
66
- * @returns the parsed expression or `undefined` if there's an error - call `lexingErrors` and `parsingErrors` to see the errors
67
- */
68
- parse(input) {
69
- if (input === '') {
70
- this._parsingErrors.push({ message: errorEmptyString, offset: 0, lexeme: '', additionalInfo: hintEmptyString });
71
- return undefined;
72
- }
73
- this._tokens = this._scanner.reset(input).scan();
74
- // @ulugbekna: we do not stop parsing if there are lexing errors to be able to reconstruct regexes with unescaped slashes; TODO@ulugbekna: make this respect config option for recovery
75
- this._current = 0;
76
- this._parsingErrors = [];
77
- try {
78
- const expr = this._expr();
79
- if (!this._isAtEnd()) {
80
- const peek = this._peek();
81
- const additionalInfo = peek.type === 17 /* TokenType.Str */ ? hintUnexpectedToken : undefined;
82
- this._parsingErrors.push({ message: errorUnexpectedToken, offset: peek.offset, lexeme: Scanner.getLexeme(peek), additionalInfo });
83
- throw Parser._parseError;
84
- }
85
- return expr;
86
- }
87
- catch (e) {
88
- if (!(e === Parser._parseError)) {
89
- throw e;
90
- }
91
- return undefined;
92
- }
93
- }
94
- _expr() {
95
- return this._or();
96
- }
97
- _or() {
98
- const expr = [this._and()];
99
- while (this._matchOne(16 /* TokenType.Or */)) {
100
- const right = this._and();
101
- expr.push(right);
102
- }
103
- return expr.length === 1 ? expr[0] : ContextKeyExpr.or(...expr);
104
- }
105
- _and() {
106
- const expr = [this._term()];
107
- while (this._matchOne(15 /* TokenType.And */)) {
108
- const right = this._term();
109
- expr.push(right);
110
- }
111
- return expr.length === 1 ? expr[0] : ContextKeyExpr.and(...expr);
112
- }
113
- _term() {
114
- if (this._matchOne(2 /* TokenType.Neg */)) {
115
- const peek = this._peek();
116
- switch (peek.type) {
117
- case 11 /* TokenType.True */:
118
- this._advance();
119
- return ContextKeyFalseExpr.INSTANCE;
120
- case 12 /* TokenType.False */:
121
- this._advance();
122
- return ContextKeyTrueExpr.INSTANCE;
123
- case 0 /* TokenType.LParen */: {
124
- this._advance();
125
- const expr = this._expr();
126
- this._consume(1 /* TokenType.RParen */, errorClosingParenthesis);
127
- return expr === null || expr === void 0 ? void 0 : expr.negate();
128
- }
129
- case 17 /* TokenType.Str */:
130
- this._advance();
131
- return ContextKeyNotExpr.create(peek.lexeme);
132
- default:
133
- throw this._errExpectedButGot(`KEY | true | false | '(' expression ')'`, peek);
134
- }
135
- }
136
- return this._primary();
137
- }
138
- _primary() {
139
- const peek = this._peek();
140
- switch (peek.type) {
141
- case 11 /* TokenType.True */:
142
- this._advance();
143
- return ContextKeyExpr.true();
144
- case 12 /* TokenType.False */:
145
- this._advance();
146
- return ContextKeyExpr.false();
147
- case 0 /* TokenType.LParen */: {
148
- this._advance();
149
- const expr = this._expr();
150
- this._consume(1 /* TokenType.RParen */, errorClosingParenthesis);
151
- return expr;
152
- }
153
- case 17 /* TokenType.Str */: {
154
- // KEY
155
- const key = peek.lexeme;
156
- this._advance();
157
- // =~ regex
158
- if (this._matchOne(9 /* TokenType.RegexOp */)) {
159
- // @ulugbekna: we need to reconstruct the regex from the tokens because some extensions use unescaped slashes in regexes
160
- const expr = this._peek();
161
- if (!this._config.regexParsingWithErrorRecovery) {
162
- this._advance();
163
- if (expr.type !== 10 /* TokenType.RegexStr */) {
164
- throw this._errExpectedButGot(`REGEX`, expr);
165
- }
166
- const regexLexeme = expr.lexeme;
167
- const closingSlashIndex = regexLexeme.lastIndexOf('/');
168
- const flags = closingSlashIndex === regexLexeme.length - 1 ? undefined : this._removeFlagsGY(regexLexeme.substring(closingSlashIndex + 1));
169
- let regexp;
170
- try {
171
- regexp = new RegExp(regexLexeme.substring(1, closingSlashIndex), flags);
172
- }
173
- catch (e) {
174
- throw this._errExpectedButGot(`REGEX`, expr);
175
- }
176
- return ContextKeyRegexExpr.create(key, regexp);
177
- }
178
- switch (expr.type) {
179
- case 10 /* TokenType.RegexStr */:
180
- case 19 /* TokenType.Error */: { // also handle an ErrorToken in case of smth such as /(/file)/
181
- const lexemeReconstruction = [expr.lexeme]; // /REGEX/ or /REGEX/FLAGS
182
- this._advance();
183
- let followingToken = this._peek();
184
- let parenBalance = 0;
185
- for (let i = 0; i < expr.lexeme.length; i++) {
186
- if (expr.lexeme.charCodeAt(i) === 40 /* CharCode.OpenParen */) {
187
- parenBalance++;
188
- }
189
- else if (expr.lexeme.charCodeAt(i) === 41 /* CharCode.CloseParen */) {
190
- parenBalance--;
191
- }
192
- }
193
- while (!this._isAtEnd() && followingToken.type !== 15 /* TokenType.And */ && followingToken.type !== 16 /* TokenType.Or */) {
194
- switch (followingToken.type) {
195
- case 0 /* TokenType.LParen */:
196
- parenBalance++;
197
- break;
198
- case 1 /* TokenType.RParen */:
199
- parenBalance--;
200
- break;
201
- case 10 /* TokenType.RegexStr */:
202
- case 18 /* TokenType.QuotedStr */:
203
- for (let i = 0; i < followingToken.lexeme.length; i++) {
204
- if (followingToken.lexeme.charCodeAt(i) === 40 /* CharCode.OpenParen */) {
205
- parenBalance++;
206
- }
207
- else if (expr.lexeme.charCodeAt(i) === 41 /* CharCode.CloseParen */) {
208
- parenBalance--;
209
- }
210
- }
211
- }
212
- if (parenBalance < 0) {
213
- break;
214
- }
215
- lexemeReconstruction.push(Scanner.getLexeme(followingToken));
216
- this._advance();
217
- followingToken = this._peek();
218
- }
219
- const regexLexeme = lexemeReconstruction.join('');
220
- const closingSlashIndex = regexLexeme.lastIndexOf('/');
221
- const flags = closingSlashIndex === regexLexeme.length - 1 ? undefined : this._removeFlagsGY(regexLexeme.substring(closingSlashIndex + 1));
222
- let regexp;
223
- try {
224
- regexp = new RegExp(regexLexeme.substring(1, closingSlashIndex), flags);
225
- }
226
- catch (e) {
227
- throw this._errExpectedButGot(`REGEX`, expr);
228
- }
229
- return ContextKeyExpr.regex(key, regexp);
230
- }
231
- case 18 /* TokenType.QuotedStr */: {
232
- const serializedValue = expr.lexeme;
233
- this._advance();
234
- // replicate old regex parsing behavior
235
- let regex = null;
236
- if (!isFalsyOrWhitespace(serializedValue)) {
237
- const start = serializedValue.indexOf('/');
238
- const end = serializedValue.lastIndexOf('/');
239
- if (start !== end && start >= 0) {
240
- const value = serializedValue.slice(start + 1, end);
241
- const caseIgnoreFlag = serializedValue[end + 1] === 'i' ? 'i' : '';
242
- try {
243
- regex = new RegExp(value, caseIgnoreFlag);
244
- }
245
- catch (_e) {
246
- throw this._errExpectedButGot(`REGEX`, expr);
247
- }
248
- }
249
- }
250
- if (regex === null) {
251
- throw this._errExpectedButGot('REGEX', expr);
252
- }
253
- return ContextKeyRegexExpr.create(key, regex);
254
- }
255
- default:
256
- throw this._errExpectedButGot('REGEX', this._peek());
257
- }
258
- }
259
- // [ 'not' 'in' value ]
260
- if (this._matchOne(14 /* TokenType.Not */)) {
261
- this._consume(13 /* TokenType.In */, errorNoInAfterNot);
262
- const right = this._value();
263
- return ContextKeyExpr.notIn(key, right);
264
- }
265
- // [ ('==' | '!=' | '<' | '<=' | '>' | '>=' | 'in') value ]
266
- const maybeOp = this._peek().type;
267
- switch (maybeOp) {
268
- case 3 /* TokenType.Eq */: {
269
- this._advance();
270
- const right = this._value();
271
- if (this._previous().type === 18 /* TokenType.QuotedStr */) { // to preserve old parser behavior: "foo == 'true'" is preserved as "foo == 'true'", but "foo == true" is optimized as "foo"
272
- return ContextKeyExpr.equals(key, right);
273
- }
274
- switch (right) {
275
- case 'true':
276
- return ContextKeyExpr.has(key);
277
- case 'false':
278
- return ContextKeyExpr.not(key);
279
- default:
280
- return ContextKeyExpr.equals(key, right);
281
- }
282
- }
283
- case 4 /* TokenType.NotEq */: {
284
- this._advance();
285
- const right = this._value();
286
- if (this._previous().type === 18 /* TokenType.QuotedStr */) { // same as above with "foo != 'true'"
287
- return ContextKeyExpr.notEquals(key, right);
288
- }
289
- switch (right) {
290
- case 'true':
291
- return ContextKeyExpr.not(key);
292
- case 'false':
293
- return ContextKeyExpr.has(key);
294
- default:
295
- return ContextKeyExpr.notEquals(key, right);
296
- }
297
- }
298
- // TODO: ContextKeyExpr.smaller(key, right) accepts only `number` as `right` AND during eval of this node, we just eval to `false` if `right` is not a number
299
- // consequently, package.json linter should _warn_ the user if they're passing undesired things to ops
300
- case 5 /* TokenType.Lt */:
301
- this._advance();
302
- return ContextKeySmallerExpr.create(key, this._value());
303
- case 6 /* TokenType.LtEq */:
304
- this._advance();
305
- return ContextKeySmallerEqualsExpr.create(key, this._value());
306
- case 7 /* TokenType.Gt */:
307
- this._advance();
308
- return ContextKeyGreaterExpr.create(key, this._value());
309
- case 8 /* TokenType.GtEq */:
310
- this._advance();
311
- return ContextKeyGreaterEqualsExpr.create(key, this._value());
312
- case 13 /* TokenType.In */:
313
- this._advance();
314
- return ContextKeyExpr.in(key, this._value());
315
- default:
316
- return ContextKeyExpr.has(key);
317
- }
318
- }
319
- case 20 /* TokenType.EOF */:
320
- this._parsingErrors.push({ message: errorUnexpectedEOF, offset: peek.offset, lexeme: '', additionalInfo: hintUnexpectedEOF });
321
- throw Parser._parseError;
322
- default:
323
- throw this._errExpectedButGot(`true | false | KEY \n\t| KEY '=~' REGEX \n\t| KEY ('==' | '!=' | '<' | '<=' | '>' | '>=' | 'in' | 'not' 'in') value`, this._peek());
324
- }
325
- }
326
- _value() {
327
- const token = this._peek();
328
- switch (token.type) {
329
- case 17 /* TokenType.Str */:
330
- case 18 /* TokenType.QuotedStr */:
331
- this._advance();
332
- return token.lexeme;
333
- case 11 /* TokenType.True */:
334
- this._advance();
335
- return 'true';
336
- case 12 /* TokenType.False */:
337
- this._advance();
338
- return 'false';
339
- case 13 /* TokenType.In */: // we support `in` as a value, e.g., "when": "languageId == in" - exists in existing extensions
340
- this._advance();
341
- return 'in';
342
- default:
343
- // this allows "when": "foo == " which's used by existing extensions
344
- // we do not call `_advance` on purpose - we don't want to eat unintended tokens
345
- return '';
346
- }
347
- }
348
- _removeFlagsGY(flags) {
349
- return flags.replaceAll(this._flagsGYRe, '');
350
- }
351
- // careful: this can throw if current token is the initial one (ie index = 0)
352
- _previous() {
353
- return this._tokens[this._current - 1];
354
- }
355
- _matchOne(token) {
356
- if (this._check(token)) {
357
- this._advance();
358
- return true;
359
- }
360
- return false;
361
- }
362
- _advance() {
363
- if (!this._isAtEnd()) {
364
- this._current++;
365
- }
366
- return this._previous();
367
- }
368
- _consume(type, message) {
369
- if (this._check(type)) {
370
- return this._advance();
371
- }
372
- throw this._errExpectedButGot(message, this._peek());
373
- }
374
- _errExpectedButGot(expected, got, additionalInfo) {
375
- const message = localize('contextkey.parser.error.expectedButGot', "Expected: {0}\nReceived: '{1}'.", expected, Scanner.getLexeme(got));
376
- const offset = got.offset;
377
- const lexeme = Scanner.getLexeme(got);
378
- this._parsingErrors.push({ message, offset, lexeme, additionalInfo });
379
- return Parser._parseError;
380
- }
381
- _check(type) {
382
- return this._peek().type === type;
383
- }
384
- _peek() {
385
- return this._tokens[this._current];
386
- }
387
- _isAtEnd() {
388
- return this._peek().type === 20 /* TokenType.EOF */;
389
- }
390
- }
391
- // Note: this doesn't produce an exact syntax tree but a normalized one
392
- // ContextKeyExpression's that we use as AST nodes do not expose constructors that do not normalize
393
- Parser._parseError = new Error();
394
- export class ContextKeyExpr {
395
- static false() {
396
- return ContextKeyFalseExpr.INSTANCE;
397
- }
398
- static true() {
399
- return ContextKeyTrueExpr.INSTANCE;
400
- }
401
- static has(key) {
402
- return ContextKeyDefinedExpr.create(key);
403
- }
404
- static equals(key, value) {
405
- return ContextKeyEqualsExpr.create(key, value);
406
- }
407
- static notEquals(key, value) {
408
- return ContextKeyNotEqualsExpr.create(key, value);
409
- }
410
- static regex(key, value) {
411
- return ContextKeyRegexExpr.create(key, value);
412
- }
413
- static in(key, value) {
414
- return ContextKeyInExpr.create(key, value);
415
- }
416
- static notIn(key, value) {
417
- return ContextKeyNotInExpr.create(key, value);
418
- }
419
- static not(key) {
420
- return ContextKeyNotExpr.create(key);
421
- }
422
- static and(...expr) {
423
- return ContextKeyAndExpr.create(expr, null, true);
424
- }
425
- static or(...expr) {
426
- return ContextKeyOrExpr.create(expr, null, true);
427
- }
428
- static deserialize(serialized) {
429
- if (serialized === undefined || serialized === null) { // an empty string needs to be handled by the parser to get a corresponding parsing error reported
430
- return undefined;
431
- }
432
- const expr = this._parser.parse(serialized);
433
- return expr;
434
- }
435
- }
436
- ContextKeyExpr._parser = new Parser({ regexParsingWithErrorRecovery: false });
437
- export function expressionsAreEqualWithConstantSubstitution(a, b) {
438
- const aExpr = a ? a.substituteConstants() : undefined;
439
- const bExpr = b ? b.substituteConstants() : undefined;
440
- if (!aExpr && !bExpr) {
441
- return true;
442
- }
443
- if (!aExpr || !bExpr) {
444
- return false;
445
- }
446
- return aExpr.equals(bExpr);
447
- }
448
- function cmp(a, b) {
449
- return a.cmp(b);
450
- }
451
- export class ContextKeyFalseExpr {
452
- constructor() {
453
- this.type = 0 /* ContextKeyExprType.False */;
454
- }
455
- cmp(other) {
456
- return this.type - other.type;
457
- }
458
- equals(other) {
459
- return (other.type === this.type);
460
- }
461
- substituteConstants() {
462
- return this;
463
- }
464
- evaluate(context) {
465
- return false;
466
- }
467
- serialize() {
468
- return 'false';
469
- }
470
- keys() {
471
- return [];
472
- }
473
- negate() {
474
- return ContextKeyTrueExpr.INSTANCE;
475
- }
476
- }
477
- ContextKeyFalseExpr.INSTANCE = new ContextKeyFalseExpr();
478
- export class ContextKeyTrueExpr {
479
- constructor() {
480
- this.type = 1 /* ContextKeyExprType.True */;
481
- }
482
- cmp(other) {
483
- return this.type - other.type;
484
- }
485
- equals(other) {
486
- return (other.type === this.type);
487
- }
488
- substituteConstants() {
489
- return this;
490
- }
491
- evaluate(context) {
492
- return true;
493
- }
494
- serialize() {
495
- return 'true';
496
- }
497
- keys() {
498
- return [];
499
- }
500
- negate() {
501
- return ContextKeyFalseExpr.INSTANCE;
502
- }
503
- }
504
- ContextKeyTrueExpr.INSTANCE = new ContextKeyTrueExpr();
505
- export class ContextKeyDefinedExpr {
506
- static create(key, negated = null) {
507
- const constantValue = CONSTANT_VALUES.get(key);
508
- if (typeof constantValue === 'boolean') {
509
- return constantValue ? ContextKeyTrueExpr.INSTANCE : ContextKeyFalseExpr.INSTANCE;
510
- }
511
- return new ContextKeyDefinedExpr(key, negated);
512
- }
513
- constructor(key, negated) {
514
- this.key = key;
515
- this.negated = negated;
516
- this.type = 2 /* ContextKeyExprType.Defined */;
517
- }
518
- cmp(other) {
519
- if (other.type !== this.type) {
520
- return this.type - other.type;
521
- }
522
- return cmp1(this.key, other.key);
523
- }
524
- equals(other) {
525
- if (other.type === this.type) {
526
- return (this.key === other.key);
527
- }
528
- return false;
529
- }
530
- substituteConstants() {
531
- const constantValue = CONSTANT_VALUES.get(this.key);
532
- if (typeof constantValue === 'boolean') {
533
- return constantValue ? ContextKeyTrueExpr.INSTANCE : ContextKeyFalseExpr.INSTANCE;
534
- }
535
- return this;
536
- }
537
- evaluate(context) {
538
- return (!!context.getValue(this.key));
539
- }
540
- serialize() {
541
- return this.key;
542
- }
543
- keys() {
544
- return [this.key];
545
- }
546
- negate() {
547
- if (!this.negated) {
548
- this.negated = ContextKeyNotExpr.create(this.key, this);
549
- }
550
- return this.negated;
551
- }
552
- }
553
- export class ContextKeyEqualsExpr {
554
- static create(key, value, negated = null) {
555
- if (typeof value === 'boolean') {
556
- return (value ? ContextKeyDefinedExpr.create(key, negated) : ContextKeyNotExpr.create(key, negated));
557
- }
558
- const constantValue = CONSTANT_VALUES.get(key);
559
- if (typeof constantValue === 'boolean') {
560
- const trueValue = constantValue ? 'true' : 'false';
561
- return (value === trueValue ? ContextKeyTrueExpr.INSTANCE : ContextKeyFalseExpr.INSTANCE);
562
- }
563
- return new ContextKeyEqualsExpr(key, value, negated);
564
- }
565
- constructor(key, value, negated) {
566
- this.key = key;
567
- this.value = value;
568
- this.negated = negated;
569
- this.type = 4 /* ContextKeyExprType.Equals */;
570
- }
571
- cmp(other) {
572
- if (other.type !== this.type) {
573
- return this.type - other.type;
574
- }
575
- return cmp2(this.key, this.value, other.key, other.value);
576
- }
577
- equals(other) {
578
- if (other.type === this.type) {
579
- return (this.key === other.key && this.value === other.value);
580
- }
581
- return false;
582
- }
583
- substituteConstants() {
584
- const constantValue = CONSTANT_VALUES.get(this.key);
585
- if (typeof constantValue === 'boolean') {
586
- const trueValue = constantValue ? 'true' : 'false';
587
- return (this.value === trueValue ? ContextKeyTrueExpr.INSTANCE : ContextKeyFalseExpr.INSTANCE);
588
- }
589
- return this;
590
- }
591
- evaluate(context) {
592
- // Intentional ==
593
- // eslint-disable-next-line eqeqeq
594
- return (context.getValue(this.key) == this.value);
595
- }
596
- serialize() {
597
- return `${this.key} == '${this.value}'`;
598
- }
599
- keys() {
600
- return [this.key];
601
- }
602
- negate() {
603
- if (!this.negated) {
604
- this.negated = ContextKeyNotEqualsExpr.create(this.key, this.value, this);
605
- }
606
- return this.negated;
607
- }
608
- }
609
- export class ContextKeyInExpr {
610
- static create(key, valueKey) {
611
- return new ContextKeyInExpr(key, valueKey);
612
- }
613
- constructor(key, valueKey) {
614
- this.key = key;
615
- this.valueKey = valueKey;
616
- this.type = 10 /* ContextKeyExprType.In */;
617
- this.negated = null;
618
- }
619
- cmp(other) {
620
- if (other.type !== this.type) {
621
- return this.type - other.type;
622
- }
623
- return cmp2(this.key, this.valueKey, other.key, other.valueKey);
624
- }
625
- equals(other) {
626
- if (other.type === this.type) {
627
- return (this.key === other.key && this.valueKey === other.valueKey);
628
- }
629
- return false;
630
- }
631
- substituteConstants() {
632
- return this;
633
- }
634
- evaluate(context) {
635
- const source = context.getValue(this.valueKey);
636
- const item = context.getValue(this.key);
637
- if (Array.isArray(source)) {
638
- return source.includes(item);
639
- }
640
- if (typeof item === 'string' && typeof source === 'object' && source !== null) {
641
- return hasOwnProperty.call(source, item);
642
- }
643
- return false;
644
- }
645
- serialize() {
646
- return `${this.key} in '${this.valueKey}'`;
647
- }
648
- keys() {
649
- return [this.key, this.valueKey];
650
- }
651
- negate() {
652
- if (!this.negated) {
653
- this.negated = ContextKeyNotInExpr.create(this.key, this.valueKey);
654
- }
655
- return this.negated;
656
- }
657
- }
658
- export class ContextKeyNotInExpr {
659
- static create(key, valueKey) {
660
- return new ContextKeyNotInExpr(key, valueKey);
661
- }
662
- constructor(key, valueKey) {
663
- this.key = key;
664
- this.valueKey = valueKey;
665
- this.type = 11 /* ContextKeyExprType.NotIn */;
666
- this._negated = ContextKeyInExpr.create(key, valueKey);
667
- }
668
- cmp(other) {
669
- if (other.type !== this.type) {
670
- return this.type - other.type;
671
- }
672
- return this._negated.cmp(other._negated);
673
- }
674
- equals(other) {
675
- if (other.type === this.type) {
676
- return this._negated.equals(other._negated);
677
- }
678
- return false;
679
- }
680
- substituteConstants() {
681
- return this;
682
- }
683
- evaluate(context) {
684
- return !this._negated.evaluate(context);
685
- }
686
- serialize() {
687
- return `${this.key} not in '${this.valueKey}'`;
688
- }
689
- keys() {
690
- return this._negated.keys();
691
- }
692
- negate() {
693
- return this._negated;
694
- }
695
- }
696
- export class ContextKeyNotEqualsExpr {
697
- static create(key, value, negated = null) {
698
- if (typeof value === 'boolean') {
699
- if (value) {
700
- return ContextKeyNotExpr.create(key, negated);
701
- }
702
- return ContextKeyDefinedExpr.create(key, negated);
703
- }
704
- const constantValue = CONSTANT_VALUES.get(key);
705
- if (typeof constantValue === 'boolean') {
706
- const falseValue = constantValue ? 'true' : 'false';
707
- return (value === falseValue ? ContextKeyFalseExpr.INSTANCE : ContextKeyTrueExpr.INSTANCE);
708
- }
709
- return new ContextKeyNotEqualsExpr(key, value, negated);
710
- }
711
- constructor(key, value, negated) {
712
- this.key = key;
713
- this.value = value;
714
- this.negated = negated;
715
- this.type = 5 /* ContextKeyExprType.NotEquals */;
716
- }
717
- cmp(other) {
718
- if (other.type !== this.type) {
719
- return this.type - other.type;
720
- }
721
- return cmp2(this.key, this.value, other.key, other.value);
722
- }
723
- equals(other) {
724
- if (other.type === this.type) {
725
- return (this.key === other.key && this.value === other.value);
726
- }
727
- return false;
728
- }
729
- substituteConstants() {
730
- const constantValue = CONSTANT_VALUES.get(this.key);
731
- if (typeof constantValue === 'boolean') {
732
- const falseValue = constantValue ? 'true' : 'false';
733
- return (this.value === falseValue ? ContextKeyFalseExpr.INSTANCE : ContextKeyTrueExpr.INSTANCE);
734
- }
735
- return this;
736
- }
737
- evaluate(context) {
738
- // Intentional !=
739
- // eslint-disable-next-line eqeqeq
740
- return (context.getValue(this.key) != this.value);
741
- }
742
- serialize() {
743
- return `${this.key} != '${this.value}'`;
744
- }
745
- keys() {
746
- return [this.key];
747
- }
748
- negate() {
749
- if (!this.negated) {
750
- this.negated = ContextKeyEqualsExpr.create(this.key, this.value, this);
751
- }
752
- return this.negated;
753
- }
754
- }
755
- export class ContextKeyNotExpr {
756
- static create(key, negated = null) {
757
- const constantValue = CONSTANT_VALUES.get(key);
758
- if (typeof constantValue === 'boolean') {
759
- return (constantValue ? ContextKeyFalseExpr.INSTANCE : ContextKeyTrueExpr.INSTANCE);
760
- }
761
- return new ContextKeyNotExpr(key, negated);
762
- }
763
- constructor(key, negated) {
764
- this.key = key;
765
- this.negated = negated;
766
- this.type = 3 /* ContextKeyExprType.Not */;
767
- }
768
- cmp(other) {
769
- if (other.type !== this.type) {
770
- return this.type - other.type;
771
- }
772
- return cmp1(this.key, other.key);
773
- }
774
- equals(other) {
775
- if (other.type === this.type) {
776
- return (this.key === other.key);
777
- }
778
- return false;
779
- }
780
- substituteConstants() {
781
- const constantValue = CONSTANT_VALUES.get(this.key);
782
- if (typeof constantValue === 'boolean') {
783
- return (constantValue ? ContextKeyFalseExpr.INSTANCE : ContextKeyTrueExpr.INSTANCE);
784
- }
785
- return this;
786
- }
787
- evaluate(context) {
788
- return (!context.getValue(this.key));
789
- }
790
- serialize() {
791
- return `!${this.key}`;
792
- }
793
- keys() {
794
- return [this.key];
795
- }
796
- negate() {
797
- if (!this.negated) {
798
- this.negated = ContextKeyDefinedExpr.create(this.key, this);
799
- }
800
- return this.negated;
801
- }
802
- }
803
- function withFloatOrStr(value, callback) {
804
- if (typeof value === 'string') {
805
- const n = parseFloat(value);
806
- if (!isNaN(n)) {
807
- value = n;
808
- }
809
- }
810
- if (typeof value === 'string' || typeof value === 'number') {
811
- return callback(value);
812
- }
813
- return ContextKeyFalseExpr.INSTANCE;
814
- }
815
- export class ContextKeyGreaterExpr {
816
- static create(key, _value, negated = null) {
817
- return withFloatOrStr(_value, (value) => new ContextKeyGreaterExpr(key, value, negated));
818
- }
819
- constructor(key, value, negated) {
820
- this.key = key;
821
- this.value = value;
822
- this.negated = negated;
823
- this.type = 12 /* ContextKeyExprType.Greater */;
824
- }
825
- cmp(other) {
826
- if (other.type !== this.type) {
827
- return this.type - other.type;
828
- }
829
- return cmp2(this.key, this.value, other.key, other.value);
830
- }
831
- equals(other) {
832
- if (other.type === this.type) {
833
- return (this.key === other.key && this.value === other.value);
834
- }
835
- return false;
836
- }
837
- substituteConstants() {
838
- return this;
839
- }
840
- evaluate(context) {
841
- if (typeof this.value === 'string') {
842
- return false;
843
- }
844
- return (parseFloat(context.getValue(this.key)) > this.value);
845
- }
846
- serialize() {
847
- return `${this.key} > ${this.value}`;
848
- }
849
- keys() {
850
- return [this.key];
851
- }
852
- negate() {
853
- if (!this.negated) {
854
- this.negated = ContextKeySmallerEqualsExpr.create(this.key, this.value, this);
855
- }
856
- return this.negated;
857
- }
858
- }
859
- export class ContextKeyGreaterEqualsExpr {
860
- static create(key, _value, negated = null) {
861
- return withFloatOrStr(_value, (value) => new ContextKeyGreaterEqualsExpr(key, value, negated));
862
- }
863
- constructor(key, value, negated) {
864
- this.key = key;
865
- this.value = value;
866
- this.negated = negated;
867
- this.type = 13 /* ContextKeyExprType.GreaterEquals */;
868
- }
869
- cmp(other) {
870
- if (other.type !== this.type) {
871
- return this.type - other.type;
872
- }
873
- return cmp2(this.key, this.value, other.key, other.value);
874
- }
875
- equals(other) {
876
- if (other.type === this.type) {
877
- return (this.key === other.key && this.value === other.value);
878
- }
879
- return false;
880
- }
881
- substituteConstants() {
882
- return this;
883
- }
884
- evaluate(context) {
885
- if (typeof this.value === 'string') {
886
- return false;
887
- }
888
- return (parseFloat(context.getValue(this.key)) >= this.value);
889
- }
890
- serialize() {
891
- return `${this.key} >= ${this.value}`;
892
- }
893
- keys() {
894
- return [this.key];
895
- }
896
- negate() {
897
- if (!this.negated) {
898
- this.negated = ContextKeySmallerExpr.create(this.key, this.value, this);
899
- }
900
- return this.negated;
901
- }
902
- }
903
- export class ContextKeySmallerExpr {
904
- static create(key, _value, negated = null) {
905
- return withFloatOrStr(_value, (value) => new ContextKeySmallerExpr(key, value, negated));
906
- }
907
- constructor(key, value, negated) {
908
- this.key = key;
909
- this.value = value;
910
- this.negated = negated;
911
- this.type = 14 /* ContextKeyExprType.Smaller */;
912
- }
913
- cmp(other) {
914
- if (other.type !== this.type) {
915
- return this.type - other.type;
916
- }
917
- return cmp2(this.key, this.value, other.key, other.value);
918
- }
919
- equals(other) {
920
- if (other.type === this.type) {
921
- return (this.key === other.key && this.value === other.value);
922
- }
923
- return false;
924
- }
925
- substituteConstants() {
926
- return this;
927
- }
928
- evaluate(context) {
929
- if (typeof this.value === 'string') {
930
- return false;
931
- }
932
- return (parseFloat(context.getValue(this.key)) < this.value);
933
- }
934
- serialize() {
935
- return `${this.key} < ${this.value}`;
936
- }
937
- keys() {
938
- return [this.key];
939
- }
940
- negate() {
941
- if (!this.negated) {
942
- this.negated = ContextKeyGreaterEqualsExpr.create(this.key, this.value, this);
943
- }
944
- return this.negated;
945
- }
946
- }
947
- export class ContextKeySmallerEqualsExpr {
948
- static create(key, _value, negated = null) {
949
- return withFloatOrStr(_value, (value) => new ContextKeySmallerEqualsExpr(key, value, negated));
950
- }
951
- constructor(key, value, negated) {
952
- this.key = key;
953
- this.value = value;
954
- this.negated = negated;
955
- this.type = 15 /* ContextKeyExprType.SmallerEquals */;
956
- }
957
- cmp(other) {
958
- if (other.type !== this.type) {
959
- return this.type - other.type;
960
- }
961
- return cmp2(this.key, this.value, other.key, other.value);
962
- }
963
- equals(other) {
964
- if (other.type === this.type) {
965
- return (this.key === other.key && this.value === other.value);
966
- }
967
- return false;
968
- }
969
- substituteConstants() {
970
- return this;
971
- }
972
- evaluate(context) {
973
- if (typeof this.value === 'string') {
974
- return false;
975
- }
976
- return (parseFloat(context.getValue(this.key)) <= this.value);
977
- }
978
- serialize() {
979
- return `${this.key} <= ${this.value}`;
980
- }
981
- keys() {
982
- return [this.key];
983
- }
984
- negate() {
985
- if (!this.negated) {
986
- this.negated = ContextKeyGreaterExpr.create(this.key, this.value, this);
987
- }
988
- return this.negated;
989
- }
990
- }
991
- export class ContextKeyRegexExpr {
992
- static create(key, regexp) {
993
- return new ContextKeyRegexExpr(key, regexp);
994
- }
995
- constructor(key, regexp) {
996
- this.key = key;
997
- this.regexp = regexp;
998
- this.type = 7 /* ContextKeyExprType.Regex */;
999
- this.negated = null;
1000
- //
1001
- }
1002
- cmp(other) {
1003
- if (other.type !== this.type) {
1004
- return this.type - other.type;
1005
- }
1006
- if (this.key < other.key) {
1007
- return -1;
1008
- }
1009
- if (this.key > other.key) {
1010
- return 1;
1011
- }
1012
- const thisSource = this.regexp ? this.regexp.source : '';
1013
- const otherSource = other.regexp ? other.regexp.source : '';
1014
- if (thisSource < otherSource) {
1015
- return -1;
1016
- }
1017
- if (thisSource > otherSource) {
1018
- return 1;
1019
- }
1020
- return 0;
1021
- }
1022
- equals(other) {
1023
- if (other.type === this.type) {
1024
- const thisSource = this.regexp ? this.regexp.source : '';
1025
- const otherSource = other.regexp ? other.regexp.source : '';
1026
- return (this.key === other.key && thisSource === otherSource);
1027
- }
1028
- return false;
1029
- }
1030
- substituteConstants() {
1031
- return this;
1032
- }
1033
- evaluate(context) {
1034
- const value = context.getValue(this.key);
1035
- return this.regexp ? this.regexp.test(value) : false;
1036
- }
1037
- serialize() {
1038
- const value = this.regexp
1039
- ? `/${this.regexp.source}/${this.regexp.flags}`
1040
- : '/invalid/';
1041
- return `${this.key} =~ ${value}`;
1042
- }
1043
- keys() {
1044
- return [this.key];
1045
- }
1046
- negate() {
1047
- if (!this.negated) {
1048
- this.negated = ContextKeyNotRegexExpr.create(this);
1049
- }
1050
- return this.negated;
1051
- }
1052
- }
1053
- export class ContextKeyNotRegexExpr {
1054
- static create(actual) {
1055
- return new ContextKeyNotRegexExpr(actual);
1056
- }
1057
- constructor(_actual) {
1058
- this._actual = _actual;
1059
- this.type = 8 /* ContextKeyExprType.NotRegex */;
1060
- //
1061
- }
1062
- cmp(other) {
1063
- if (other.type !== this.type) {
1064
- return this.type - other.type;
1065
- }
1066
- return this._actual.cmp(other._actual);
1067
- }
1068
- equals(other) {
1069
- if (other.type === this.type) {
1070
- return this._actual.equals(other._actual);
1071
- }
1072
- return false;
1073
- }
1074
- substituteConstants() {
1075
- return this;
1076
- }
1077
- evaluate(context) {
1078
- return !this._actual.evaluate(context);
1079
- }
1080
- serialize() {
1081
- return `!(${this._actual.serialize()})`;
1082
- }
1083
- keys() {
1084
- return this._actual.keys();
1085
- }
1086
- negate() {
1087
- return this._actual;
1088
- }
1089
- }
1090
- /**
1091
- * @returns the same instance if nothing changed.
1092
- */
1093
- function eliminateConstantsInArray(arr) {
1094
- // Allocate array only if there is a difference
1095
- let newArr = null;
1096
- for (let i = 0, len = arr.length; i < len; i++) {
1097
- const newExpr = arr[i].substituteConstants();
1098
- if (arr[i] !== newExpr) {
1099
- // something has changed!
1100
- // allocate array on first difference
1101
- if (newArr === null) {
1102
- newArr = [];
1103
- for (let j = 0; j < i; j++) {
1104
- newArr[j] = arr[j];
1105
- }
1106
- }
1107
- }
1108
- if (newArr !== null) {
1109
- newArr[i] = newExpr;
1110
- }
1111
- }
1112
- if (newArr === null) {
1113
- return arr;
1114
- }
1115
- return newArr;
1116
- }
1117
- export class ContextKeyAndExpr {
1118
- static create(_expr, negated, extraRedundantCheck) {
1119
- return ContextKeyAndExpr._normalizeArr(_expr, negated, extraRedundantCheck);
1120
- }
1121
- constructor(expr, negated) {
1122
- this.expr = expr;
1123
- this.negated = negated;
1124
- this.type = 6 /* ContextKeyExprType.And */;
1125
- }
1126
- cmp(other) {
1127
- if (other.type !== this.type) {
1128
- return this.type - other.type;
1129
- }
1130
- if (this.expr.length < other.expr.length) {
1131
- return -1;
1132
- }
1133
- if (this.expr.length > other.expr.length) {
1134
- return 1;
1135
- }
1136
- for (let i = 0, len = this.expr.length; i < len; i++) {
1137
- const r = cmp(this.expr[i], other.expr[i]);
1138
- if (r !== 0) {
1139
- return r;
1140
- }
1141
- }
1142
- return 0;
1143
- }
1144
- equals(other) {
1145
- if (other.type === this.type) {
1146
- if (this.expr.length !== other.expr.length) {
1147
- return false;
1148
- }
1149
- for (let i = 0, len = this.expr.length; i < len; i++) {
1150
- if (!this.expr[i].equals(other.expr[i])) {
1151
- return false;
1152
- }
1153
- }
1154
- return true;
1155
- }
1156
- return false;
1157
- }
1158
- substituteConstants() {
1159
- const exprArr = eliminateConstantsInArray(this.expr);
1160
- if (exprArr === this.expr) {
1161
- // no change
1162
- return this;
1163
- }
1164
- return ContextKeyAndExpr.create(exprArr, this.negated, false);
1165
- }
1166
- evaluate(context) {
1167
- for (let i = 0, len = this.expr.length; i < len; i++) {
1168
- if (!this.expr[i].evaluate(context)) {
1169
- return false;
1170
- }
1171
- }
1172
- return true;
1173
- }
1174
- static _normalizeArr(arr, negated, extraRedundantCheck) {
1175
- const expr = [];
1176
- let hasTrue = false;
1177
- for (const e of arr) {
1178
- if (!e) {
1179
- continue;
1180
- }
1181
- if (e.type === 1 /* ContextKeyExprType.True */) {
1182
- // anything && true ==> anything
1183
- hasTrue = true;
1184
- continue;
1185
- }
1186
- if (e.type === 0 /* ContextKeyExprType.False */) {
1187
- // anything && false ==> false
1188
- return ContextKeyFalseExpr.INSTANCE;
1189
- }
1190
- if (e.type === 6 /* ContextKeyExprType.And */) {
1191
- expr.push(...e.expr);
1192
- continue;
1193
- }
1194
- expr.push(e);
1195
- }
1196
- if (expr.length === 0 && hasTrue) {
1197
- return ContextKeyTrueExpr.INSTANCE;
1198
- }
1199
- if (expr.length === 0) {
1200
- return undefined;
1201
- }
1202
- if (expr.length === 1) {
1203
- return expr[0];
1204
- }
1205
- expr.sort(cmp);
1206
- // eliminate duplicate terms
1207
- for (let i = 1; i < expr.length; i++) {
1208
- if (expr[i - 1].equals(expr[i])) {
1209
- expr.splice(i, 1);
1210
- i--;
1211
- }
1212
- }
1213
- if (expr.length === 1) {
1214
- return expr[0];
1215
- }
1216
- // We must distribute any OR expression because we don't support parens
1217
- // OR extensions will be at the end (due to sorting rules)
1218
- while (expr.length > 1) {
1219
- const lastElement = expr[expr.length - 1];
1220
- if (lastElement.type !== 9 /* ContextKeyExprType.Or */) {
1221
- break;
1222
- }
1223
- // pop the last element
1224
- expr.pop();
1225
- // pop the second to last element
1226
- const secondToLastElement = expr.pop();
1227
- const isFinished = (expr.length === 0);
1228
- // distribute `lastElement` over `secondToLastElement`
1229
- const resultElement = ContextKeyOrExpr.create(lastElement.expr.map(el => ContextKeyAndExpr.create([el, secondToLastElement], null, extraRedundantCheck)), null, isFinished);
1230
- if (resultElement) {
1231
- expr.push(resultElement);
1232
- expr.sort(cmp);
1233
- }
1234
- }
1235
- if (expr.length === 1) {
1236
- return expr[0];
1237
- }
1238
- // resolve false AND expressions
1239
- if (extraRedundantCheck) {
1240
- for (let i = 0; i < expr.length; i++) {
1241
- for (let j = i + 1; j < expr.length; j++) {
1242
- if (expr[i].negate().equals(expr[j])) {
1243
- // A && !A case
1244
- return ContextKeyFalseExpr.INSTANCE;
1245
- }
1246
- }
1247
- }
1248
- if (expr.length === 1) {
1249
- return expr[0];
1250
- }
1251
- }
1252
- return new ContextKeyAndExpr(expr, negated);
1253
- }
1254
- serialize() {
1255
- return this.expr.map(e => e.serialize()).join(' && ');
1256
- }
1257
- keys() {
1258
- const result = [];
1259
- for (const expr of this.expr) {
1260
- result.push(...expr.keys());
1261
- }
1262
- return result;
1263
- }
1264
- negate() {
1265
- if (!this.negated) {
1266
- const result = [];
1267
- for (const expr of this.expr) {
1268
- result.push(expr.negate());
1269
- }
1270
- this.negated = ContextKeyOrExpr.create(result, this, true);
1271
- }
1272
- return this.negated;
1273
- }
1274
- }
1275
- export class ContextKeyOrExpr {
1276
- static create(_expr, negated, extraRedundantCheck) {
1277
- return ContextKeyOrExpr._normalizeArr(_expr, negated, extraRedundantCheck);
1278
- }
1279
- constructor(expr, negated) {
1280
- this.expr = expr;
1281
- this.negated = negated;
1282
- this.type = 9 /* ContextKeyExprType.Or */;
1283
- }
1284
- cmp(other) {
1285
- if (other.type !== this.type) {
1286
- return this.type - other.type;
1287
- }
1288
- if (this.expr.length < other.expr.length) {
1289
- return -1;
1290
- }
1291
- if (this.expr.length > other.expr.length) {
1292
- return 1;
1293
- }
1294
- for (let i = 0, len = this.expr.length; i < len; i++) {
1295
- const r = cmp(this.expr[i], other.expr[i]);
1296
- if (r !== 0) {
1297
- return r;
1298
- }
1299
- }
1300
- return 0;
1301
- }
1302
- equals(other) {
1303
- if (other.type === this.type) {
1304
- if (this.expr.length !== other.expr.length) {
1305
- return false;
1306
- }
1307
- for (let i = 0, len = this.expr.length; i < len; i++) {
1308
- if (!this.expr[i].equals(other.expr[i])) {
1309
- return false;
1310
- }
1311
- }
1312
- return true;
1313
- }
1314
- return false;
1315
- }
1316
- substituteConstants() {
1317
- const exprArr = eliminateConstantsInArray(this.expr);
1318
- if (exprArr === this.expr) {
1319
- // no change
1320
- return this;
1321
- }
1322
- return ContextKeyOrExpr.create(exprArr, this.negated, false);
1323
- }
1324
- evaluate(context) {
1325
- for (let i = 0, len = this.expr.length; i < len; i++) {
1326
- if (this.expr[i].evaluate(context)) {
1327
- return true;
1328
- }
1329
- }
1330
- return false;
1331
- }
1332
- static _normalizeArr(arr, negated, extraRedundantCheck) {
1333
- let expr = [];
1334
- let hasFalse = false;
1335
- if (arr) {
1336
- for (let i = 0, len = arr.length; i < len; i++) {
1337
- const e = arr[i];
1338
- if (!e) {
1339
- continue;
1340
- }
1341
- if (e.type === 0 /* ContextKeyExprType.False */) {
1342
- // anything || false ==> anything
1343
- hasFalse = true;
1344
- continue;
1345
- }
1346
- if (e.type === 1 /* ContextKeyExprType.True */) {
1347
- // anything || true ==> true
1348
- return ContextKeyTrueExpr.INSTANCE;
1349
- }
1350
- if (e.type === 9 /* ContextKeyExprType.Or */) {
1351
- expr = expr.concat(e.expr);
1352
- continue;
1353
- }
1354
- expr.push(e);
1355
- }
1356
- if (expr.length === 0 && hasFalse) {
1357
- return ContextKeyFalseExpr.INSTANCE;
1358
- }
1359
- expr.sort(cmp);
1360
- }
1361
- if (expr.length === 0) {
1362
- return undefined;
1363
- }
1364
- if (expr.length === 1) {
1365
- return expr[0];
1366
- }
1367
- // eliminate duplicate terms
1368
- for (let i = 1; i < expr.length; i++) {
1369
- if (expr[i - 1].equals(expr[i])) {
1370
- expr.splice(i, 1);
1371
- i--;
1372
- }
1373
- }
1374
- if (expr.length === 1) {
1375
- return expr[0];
1376
- }
1377
- // resolve true OR expressions
1378
- if (extraRedundantCheck) {
1379
- for (let i = 0; i < expr.length; i++) {
1380
- for (let j = i + 1; j < expr.length; j++) {
1381
- if (expr[i].negate().equals(expr[j])) {
1382
- // A || !A case
1383
- return ContextKeyTrueExpr.INSTANCE;
1384
- }
1385
- }
1386
- }
1387
- if (expr.length === 1) {
1388
- return expr[0];
1389
- }
1390
- }
1391
- return new ContextKeyOrExpr(expr, negated);
1392
- }
1393
- serialize() {
1394
- return this.expr.map(e => e.serialize()).join(' || ');
1395
- }
1396
- keys() {
1397
- const result = [];
1398
- for (const expr of this.expr) {
1399
- result.push(...expr.keys());
1400
- }
1401
- return result;
1402
- }
1403
- negate() {
1404
- if (!this.negated) {
1405
- const result = [];
1406
- for (const expr of this.expr) {
1407
- result.push(expr.negate());
1408
- }
1409
- // We don't support parens, so here we distribute the AND over the OR terminals
1410
- // We always take the first 2 AND pairs and distribute them
1411
- while (result.length > 1) {
1412
- const LEFT = result.shift();
1413
- const RIGHT = result.shift();
1414
- const all = [];
1415
- for (const left of getTerminals(LEFT)) {
1416
- for (const right of getTerminals(RIGHT)) {
1417
- all.push(ContextKeyAndExpr.create([left, right], null, false));
1418
- }
1419
- }
1420
- result.unshift(ContextKeyOrExpr.create(all, null, false));
1421
- }
1422
- this.negated = ContextKeyOrExpr.create(result, this, true);
1423
- }
1424
- return this.negated;
1425
- }
1426
- }
1427
- export class RawContextKey extends ContextKeyDefinedExpr {
1428
- static all() {
1429
- return RawContextKey._info.values();
1430
- }
1431
- constructor(key, defaultValue, metaOrHide) {
1432
- super(key, null);
1433
- this._defaultValue = defaultValue;
1434
- // collect all context keys into a central place
1435
- if (typeof metaOrHide === 'object') {
1436
- RawContextKey._info.push({ ...metaOrHide, key });
1437
- }
1438
- else if (metaOrHide !== true) {
1439
- RawContextKey._info.push({ key, description: metaOrHide, type: defaultValue !== null && defaultValue !== undefined ? typeof defaultValue : undefined });
1440
- }
1441
- }
1442
- bindTo(target) {
1443
- return target.createKey(this.key, this._defaultValue);
1444
- }
1445
- getValue(target) {
1446
- return target.getContextKeyValue(this.key);
1447
- }
1448
- toNegated() {
1449
- return this.negate();
1450
- }
1451
- isEqualTo(value) {
1452
- return ContextKeyEqualsExpr.create(this.key, value);
1453
- }
1454
- }
1455
- RawContextKey._info = [];
1456
- export const IContextKeyService = createDecorator('contextKeyService');
1457
- function cmp1(key1, key2) {
1458
- if (key1 < key2) {
1459
- return -1;
1460
- }
1461
- if (key1 > key2) {
1462
- return 1;
1463
- }
1464
- return 0;
1465
- }
1466
- function cmp2(key1, value1, key2, value2) {
1467
- if (key1 < key2) {
1468
- return -1;
1469
- }
1470
- if (key1 > key2) {
1471
- return 1;
1472
- }
1473
- if (value1 < value2) {
1474
- return -1;
1475
- }
1476
- if (value1 > value2) {
1477
- return 1;
1478
- }
1479
- return 0;
1480
- }
1481
- /**
1482
- * Returns true if it is provable `p` implies `q`.
1483
- */
1484
- export function implies(p, q) {
1485
- if (p.type === 0 /* ContextKeyExprType.False */ || q.type === 1 /* ContextKeyExprType.True */) {
1486
- // false implies anything
1487
- // anything implies true
1488
- return true;
1489
- }
1490
- if (p.type === 9 /* ContextKeyExprType.Or */) {
1491
- if (q.type === 9 /* ContextKeyExprType.Or */) {
1492
- // `a || b || c` can only imply something like `a || b || c || d`
1493
- return allElementsIncluded(p.expr, q.expr);
1494
- }
1495
- return false;
1496
- }
1497
- if (q.type === 9 /* ContextKeyExprType.Or */) {
1498
- for (const element of q.expr) {
1499
- if (implies(p, element)) {
1500
- return true;
1501
- }
1502
- }
1503
- return false;
1504
- }
1505
- if (p.type === 6 /* ContextKeyExprType.And */) {
1506
- if (q.type === 6 /* ContextKeyExprType.And */) {
1507
- // `a && b && c` implies `a && c`
1508
- return allElementsIncluded(q.expr, p.expr);
1509
- }
1510
- for (const element of p.expr) {
1511
- if (implies(element, q)) {
1512
- return true;
1513
- }
1514
- }
1515
- return false;
1516
- }
1517
- return p.equals(q);
1518
- }
1519
- /**
1520
- * Returns true if all elements in `p` are also present in `q`.
1521
- * The two arrays are assumed to be sorted
1522
- */
1523
- function allElementsIncluded(p, q) {
1524
- let pIndex = 0;
1525
- let qIndex = 0;
1526
- while (pIndex < p.length && qIndex < q.length) {
1527
- const cmp = p[pIndex].cmp(q[qIndex]);
1528
- if (cmp < 0) {
1529
- // an element from `p` is missing from `q`
1530
- return false;
1531
- }
1532
- else if (cmp === 0) {
1533
- pIndex++;
1534
- qIndex++;
1535
- }
1536
- else {
1537
- qIndex++;
1538
- }
1539
- }
1540
- return (pIndex === p.length);
1541
- }
1542
- function getTerminals(node) {
1543
- if (node.type === 9 /* ContextKeyExprType.Or */) {
1544
- return node.expr;
1545
- }
1546
- return [node];
1547
- }