@heartlandone/vega 2.75.0 → 2.76.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (752) hide show
  1. package/dist/cjs/{app-globals-bf183914.js → app-globals-12b7d808.js} +28 -32
  2. package/dist/cjs/breakpoints-751d433a.js +56 -0
  3. package/dist/cjs/{child-nodes-event-prevent-slimmer-aca87dac.js → child-nodes-event-prevent-slimmer-84435957.js} +2 -2
  4. package/dist/cjs/{child-nodes-notify-observer-slimmer-257fedb3.js → child-nodes-notify-observer-slimmer-ed39283b.js} +1 -1
  5. package/dist/cjs/{code-block-c1d2e6a8.js → code-block-f1480ec3.js} +17 -17
  6. package/dist/cjs/{component-global-style-slimmer-adfa2e59.js → component-global-style-slimmer-93c5fb50.js} +2 -1
  7. package/dist/cjs/{component-usage-runtime-metrics-d10ace87.js → component-usage-runtime-metrics-4572c5b7.js} +1 -1
  8. package/dist/cjs/{component-value-history-controller-slimmer.abstract-787c67dc.js → component-value-history-controller-slimmer.abstract-a9264cc8.js} +5 -5
  9. package/dist/cjs/{create-public-api-runtime-metrics-slimmer-e2e274e1.js → create-public-api-runtime-metrics-slimmer-9cb09fb2.js} +3 -41
  10. package/dist/cjs/{dark-mode-style-controller-c21172aa.js → dark-mode-style-controller-3a04af3d.js} +292 -1254
  11. package/dist/cjs/{date-required-rule-30ee62d0.js → date-required-rule-912469e0.js} +1 -1
  12. package/dist/cjs/{design-token-cbc01283.js → design-token-41baf118.js} +2 -2
  13. package/dist/cjs/dom-node-subject-observer-factory-c62823de.js +141 -0
  14. package/dist/cjs/{dto-renderer-manager-2fc24151.js → dto-renderer-manager-809c947b.js} +230 -55
  15. package/dist/cjs/{element-appender-slimmer-318d29c7.js → element-appender-slimmer-34e4eb56.js} +349 -166
  16. package/dist/cjs/{event-emit-slimmer-2dacabbd.js → event-emit-slimmer-062cdcb8.js} +2 -2
  17. package/dist/cjs/{feature-flag-controller-ce2162c8.js → feature-flag-controller-04cb1e69.js} +7 -1
  18. package/dist/cjs/{form-field-controller-slimmer-aef2fb1e.js → form-field-controller-slimmer-102f37c7.js} +13 -14
  19. package/dist/cjs/{internal-icon-manager-32f9ed63.js → icon-manager-c12c6ea9.js} +1 -52
  20. package/dist/cjs/{image-annotation-action-e4a35325.js → image-annotation-action-8d9fa20c.js} +10 -9
  21. package/dist/cjs/index-592b4052.js +220 -0
  22. package/dist/cjs/{index-4d7bce1a.js → index-f054eb5d.js} +15 -3
  23. package/dist/cjs/index.cjs.js +68 -65
  24. package/dist/cjs/{inject-keyboard-manager-d21b4387.js → inject-keyboard-manager-0f5bd568.js} +1 -1
  25. package/dist/cjs/internal-icon-manager-c989189a.js +55 -0
  26. package/dist/cjs/{translation-5f9f9c0c.js → internal-translation-controller-053eb0f1.js} +0 -93
  27. package/dist/cjs/{internal-vega-event-manager-6befeb34.js → internal-vega-event-manager-f7ecf3d4.js} +81 -81
  28. package/dist/cjs/internal-vega-z-index-manager-f03ddb37.js +180 -0
  29. package/dist/cjs/{keyboard-manager-3dea6b28.js → keyboard-manager-055e9f67.js} +2 -2
  30. package/dist/cjs/{keyboard-manager-slimmer-0d45f944.js → keyboard-manager-slimmer-0cc0c1c7.js} +1 -1
  31. package/dist/cjs/loader.cjs.js +26 -23
  32. package/dist/cjs/misc-3d30df91.js +41 -0
  33. package/dist/cjs/{month-view-generator-49cc5fc2.js → month-view-generator-6a6dd527.js} +1 -1
  34. package/dist/cjs/{page-resize-observer-slimmer-11937d6f.js → page-resize-observer-slimmer-7f065ee1.js} +2 -54
  35. package/dist/cjs/{public-rules-661823fa.js → public-rules-922849f3.js} +12 -13
  36. package/dist/cjs/{range-79b668e7.js → range-8aa49b08.js} +2 -2
  37. package/dist/cjs/{responsive-format-facade-f71d399c.js → responsive-format-facade-ea59bdcd.js} +13 -22
  38. package/dist/cjs/{rich-text-editor-required-rule-d5feeffd.js → rich-text-editor-required-rule-22225840.js} +1 -1
  39. package/dist/cjs/{string-format-strategy.abstract-63514c60.js → string-format-strategy.abstract-f2575647.js} +1 -1
  40. package/dist/cjs/{string-input-formatter-slimmer-f3e0bbc7.js → string-input-formatter-slimmer-0a334fc6.js} +5 -5
  41. package/dist/cjs/{string-mask-strategy-d23ac21a.js → string-mask-strategy-dda58395.js} +2 -2
  42. package/dist/cjs/{style-formatter-566df206.js → style-formatter-0c3ced39.js} +2 -2
  43. package/dist/cjs/{sub-state-notify-slimmer-468e19aa.js → sub-state-notify-slimmer-58121111.js} +1 -1
  44. package/dist/cjs/{sub-state-observer-slimmer-5d0b8ac3.js → sub-state-observer-slimmer-1dfbc4c3.js} +2 -2
  45. package/dist/cjs/{time-required-rule-c96ecdc9.js → time-required-rule-d6fa7aa8.js} +1 -1
  46. package/dist/cjs/{function-extension-ca9aa115.js → token-extension-07cac85d.js} +501 -387
  47. package/dist/cjs/{translation-slimmer-f0ebe710.js → translation-slimmer-4533bd67.js} +4 -4
  48. package/dist/cjs/{type-guard-a0f026d8.js → type-guard-407ba0b8.js} +3 -3
  49. package/dist/cjs/{ui-9e181079.js → ui-234ea151.js} +12 -0
  50. package/dist/cjs/{valid-credit-card-number-rule-c854bed9.js → valid-credit-card-number-rule-41a8b51b.js} +1 -1
  51. package/dist/cjs/vega-accordion.cjs.entry.js +21 -30
  52. package/dist/cjs/vega-app-footer.cjs.entry.js +3 -3
  53. package/dist/cjs/vega-app-header-button.cjs.entry.js +183 -49
  54. package/dist/cjs/vega-backdrop.cjs.entry.js +2 -2
  55. package/dist/cjs/vega-banner.cjs.entry.js +15 -13
  56. package/dist/cjs/vega-bar-chart.cjs.entry.js +1 -1
  57. package/dist/cjs/vega-box.cjs.entry.js +18 -33
  58. package/dist/cjs/vega-brand-logo.cjs.entry.js +7 -5
  59. package/dist/cjs/vega-breadcrumb.cjs.entry.js +14 -13
  60. package/dist/cjs/vega-button-circle.cjs.entry.js +20 -30
  61. package/dist/cjs/vega-button-group_2.cjs.entry.js +15 -15
  62. package/dist/cjs/vega-button-link.cjs.entry.js +15 -14
  63. package/dist/cjs/vega-button.cjs.entry.js +21 -30
  64. package/dist/cjs/vega-calendar_4.cjs.entry.js +48 -45
  65. package/dist/cjs/vega-card.cjs.entry.js +9 -28
  66. package/dist/cjs/vega-carousel.cjs.entry.js +15 -26
  67. package/dist/cjs/vega-checkbox_2.cjs.entry.js +22 -20
  68. package/dist/cjs/vega-chip.cjs.entry.js +22 -33
  69. package/dist/cjs/vega-code-block.cjs.entry.js +658 -2709
  70. package/dist/cjs/vega-color-picker.cjs.entry.js +15 -12
  71. package/dist/cjs/vega-combo-box.cjs.entry.js +29 -28
  72. package/dist/cjs/vega-counter-badge.cjs.entry.js +1 -1
  73. package/dist/cjs/vega-date-picker_2.cjs.entry.js +53 -56
  74. package/dist/cjs/vega-dialog-controller-03ef4d9a.js +84 -0
  75. package/dist/cjs/vega-dialog_2.cjs.entry.js +37 -44
  76. package/dist/cjs/vega-divider.cjs.entry.js +12 -30
  77. package/dist/cjs/vega-dropdown_5.cjs.entry.js +49 -55
  78. package/dist/cjs/vega-env-manager-23b8b23c.js +2 -2
  79. package/dist/cjs/{dom-node-subject-observer-factory-b5e71bf6.js → vega-event-id-ee01d8dd.js} +0 -139
  80. package/dist/cjs/vega-field-error.cjs.entry.js +1 -1
  81. package/dist/cjs/vega-field-label.cjs.entry.js +9 -8
  82. package/dist/cjs/vega-file-uploader.cjs.entry.js +28 -23
  83. package/dist/cjs/vega-flag-icon.cjs.entry.js +13 -27
  84. package/dist/cjs/vega-flex.cjs.entry.js +11 -28
  85. package/dist/cjs/vega-font.cjs.entry.js +12 -29
  86. package/dist/cjs/vega-form.cjs.entry.js +24 -22
  87. package/dist/cjs/vega-grid.cjs.entry.js +9 -28
  88. package/dist/cjs/vega-hint.cjs.entry.js +1 -1
  89. package/dist/cjs/vega-icon.cjs.entry.js +18 -31
  90. package/dist/cjs/vega-image-uploader.cjs.entry.js +34 -37
  91. package/dist/cjs/vega-input-credit-card.cjs.entry.js +31 -27
  92. package/dist/cjs/vega-input-numeric.cjs.entry.js +24 -22
  93. package/dist/cjs/vega-input-passcode.cjs.entry.js +26 -24
  94. package/dist/cjs/vega-input-phone-number.cjs.entry.js +31 -35
  95. package/dist/cjs/vega-input-range.cjs.entry.js +22 -20
  96. package/dist/cjs/vega-input-select.cjs.entry.js +41 -46
  97. package/dist/cjs/vega-input.cjs.entry.js +43 -31
  98. package/dist/cjs/vega-item-toggle.cjs.entry.js +8 -7
  99. package/dist/cjs/vega-left-nav_5.cjs.entry.js +38 -40
  100. package/dist/cjs/vega-line-chart.cjs.entry.js +1 -1
  101. package/dist/cjs/vega-loader-wrapper_2.cjs.entry.js +16 -32
  102. package/dist/cjs/vega-page-notification_2.cjs.entry.js +5 -4
  103. package/dist/cjs/vega-pagination-page-selector-mobile.cjs.entry.js +12 -12
  104. package/dist/cjs/vega-pagination-page-size-selector-mobile.cjs.entry.js +9 -10
  105. package/dist/cjs/vega-pagination.cjs.entry.js +28 -38
  106. package/dist/cjs/vega-pie-chart.cjs.entry.js +1 -1
  107. package/dist/cjs/vega-popover_2.cjs.entry.js +21 -31
  108. package/dist/cjs/vega-progress-tracker_2.cjs.entry.js +66 -39
  109. package/dist/cjs/vega-radio_2.cjs.entry.js +25 -23
  110. package/dist/cjs/vega-rich-text-content.cjs.entry.js +22 -20
  111. package/dist/cjs/vega-rich-text-editor_4.cjs.entry.js +115 -62
  112. package/dist/cjs/vega-section-title.cjs.entry.js +1 -1
  113. package/dist/cjs/vega-segment-control.cjs.entry.js +10 -8
  114. package/dist/cjs/vega-selection-chip_2.cjs.entry.js +25 -32
  115. package/dist/cjs/vega-selection-tile_2.cjs.entry.js +22 -20
  116. package/dist/cjs/vega-sidenav_3.cjs.entry.js +34 -40
  117. package/dist/cjs/vega-signature-capture.cjs.entry.js +27 -31
  118. package/dist/cjs/vega-skeleton.cjs.entry.js +1 -1
  119. package/dist/cjs/vega-slot-container.cjs.entry.js +1 -1
  120. package/dist/cjs/vega-stepper.cjs.entry.js +23 -21
  121. package/dist/cjs/vega-tab-group_2.cjs.entry.js +15 -14
  122. package/dist/cjs/vega-table_11.cjs.entry.js +67 -68
  123. package/dist/cjs/vega-text.cjs.entry.js +4 -3
  124. package/dist/cjs/vega-textarea.cjs.entry.js +22 -20
  125. package/dist/cjs/vega-time-picker_2.cjs.entry.js +35 -41
  126. package/dist/cjs/vega-toggle-switch.cjs.entry.js +15 -12
  127. package/dist/cjs/vega-tooltip_2.cjs.entry.js +17 -28
  128. package/dist/cjs/vega.cjs.js +26 -23
  129. package/dist/cjs/{index-95fca64f.js → wait-for-component-did-render-70a01bf9.js} +1 -12
  130. package/dist/collection/components/vega-app-header-button/vega-app-header-button.js +17 -2
  131. package/dist/collection/components/vega-box/slimmers/controllers/vega-box-responsive-style-controller.js +2 -1
  132. package/dist/collection/components/vega-box/slimmers/controllers/vega-box-state-styles-controller.js +2 -1
  133. package/dist/collection/components/vega-button/vega-button.js +2 -1
  134. package/dist/collection/components/vega-button-circle/vega-button-circle.js +2 -1
  135. package/dist/collection/components/vega-button-link/vega-button-link.css +1 -1
  136. package/dist/collection/components/vega-button-link/vega-button-link.js +2 -1
  137. package/dist/collection/components/vega-calendar/slimmers/common/helpers/repeat-pattern/base-repeat-pattern.js +1 -1
  138. package/dist/collection/components/vega-calendar/slimmers/common/helpers/repeat-pattern/calendar-event-daily-repeat-pattern.js +1 -1
  139. package/dist/collection/components/vega-calendar/slimmers/common/helpers/repeat-pattern/calendar-event-monthly-repeat-pattern.js +1 -1
  140. package/dist/collection/components/vega-calendar/slimmers/common/helpers/repeat-pattern/calendar-event-weekly-repeat-pattern.js +1 -1
  141. package/dist/collection/components/vega-calendar/slimmers/common/helpers/repeat-pattern/calendar-event-yearly-repeat-pattern.js +1 -1
  142. package/dist/collection/components/vega-code-block/slimmers/controllers/prism-code-highlight-parse-controller.js +5 -14
  143. package/dist/collection/components/vega-combo-box/slimmers/renderers/vega-combo-box-dropdown-renderer.js +2 -2
  144. package/dist/collection/components/vega-date-picker/slimmers/controllers/vega-date-picker-calendar-open-state-controller.js +1 -1
  145. package/dist/collection/components/vega-date-picker/slimmers/renderers/vega-date-picker-calendar-renderer.js +1 -1
  146. package/dist/collection/components/vega-dropdown/slimmers/controllers/vega-dropdown-search-controller.js +2 -2
  147. package/dist/collection/components/vega-dropdown/slimmers/renderers/vega-dropdown-list-renderer.js +2 -2
  148. package/dist/collection/components/vega-dropdown/vega-dropdown-group/slimmers/renderers/vega-dropdown-group-renderer.js +3 -3
  149. package/dist/collection/components/vega-dropdown/vega-dropdown-item/slimmers/renderers/vega-dropdown-item-renderer.js +6 -4
  150. package/dist/collection/components/vega-icon/vega-icon.js +2 -1
  151. package/dist/collection/components/vega-input/slimmers/renderers/vega-input-input-container-renderer.js +10 -2
  152. package/dist/collection/components/vega-input-phone-number/slimmers/renderers/country-select-renderer.js +1 -1
  153. package/dist/collection/components/vega-input-select/slimmers/renderers/vega-input-select-dropdown-renderer.js +2 -2
  154. package/dist/collection/components/vega-pagination/vega-pagination.js +1 -1
  155. package/dist/collection/components/vega-progress-tracker/slimmers/controllers/dto/internal-progress-tracker-step.js +30 -6
  156. package/dist/collection/components/vega-progress-tracker/slimmers/controllers/vega-progress-tracker-current-steps-controller.js +1 -1
  157. package/dist/collection/components/vega-progress-tracker/slimmers/renderers/vega-progress-tracker-renderer.js +8 -1
  158. package/dist/collection/components/vega-progress-tracker/vega-progress-tracker-step/vega-progress-tracker-step.js +27 -0
  159. package/dist/collection/components/vega-progress-tracker/vega-progress-tracker.css +12 -0
  160. package/dist/collection/components/vega-progress-tracker/vega-progress-tracker.js +8 -3
  161. package/dist/collection/components/vega-rich-text-content/vega-rich-text-content.js +1 -1
  162. package/dist/collection/components/vega-rich-text-editor/dto/blocks/html-block.js +16 -0
  163. package/dist/collection/components/vega-rich-text-editor/dto/content-state.js +3 -22
  164. package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/html-cleaner/html-content-cleaner.js +59 -0
  165. package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/html-cleaner/index.js +4 -0
  166. package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/html-cleaner/processors/remove-whitespace-after-opening-tag-processor.js +21 -0
  167. package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/html-cleaner/processors/remove-whitespace-before-closing-tag-processor.js +21 -0
  168. package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/html-cleaner/processors/remove-whitespace-between-tags-processor.js +77 -0
  169. package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/value-controller.js +1 -1
  170. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/link-toolbar-button-slimmer.js +1 -1
  171. package/dist/collection/components/vega-rich-text-editor/test/dto/blocks/html-block.test.js +39 -0
  172. package/dist/collection/components/vega-rich-text-editor/test/dto/content-state.test.js +166 -1
  173. package/dist/collection/components/vega-rich-text-editor/test/html-cleaner/html-content-cleaner.test.js +186 -0
  174. package/dist/collection/components/vega-rich-text-editor/test/html-cleaner/remove-whitespace-after-opening-tag-processor.test.js +22 -0
  175. package/dist/collection/components/vega-rich-text-editor/test/html-cleaner/remove-whitespace-before-closing-tag-processor.test.js +22 -0
  176. package/dist/collection/components/vega-rich-text-editor/test/html-cleaner/remove-whitespace-between-tags-processor.test.js +26 -0
  177. package/dist/collection/components/vega-signature-capture/slimmers/written-mode/controllers/written-mode-svg-controller.js +2 -1
  178. package/dist/collection/components/vega-table/interface.js +3 -0
  179. package/dist/collection/components/vega-table/vega-table-foot-cell/slimmers/renderers/vega-table-foot-cell-renderer.js +1 -1
  180. package/dist/collection/global/scripts/before-vega-load.js +4 -3
  181. package/dist/collection/helpers/calendar/calendar-date.js +1 -1
  182. package/dist/collection/helpers/calendar/calendar-event.js +1 -1
  183. package/dist/collection/helpers/calendar/calendar-time.js +1 -1
  184. package/dist/collection/helpers/code-format/code-formatter.js +57 -7
  185. package/dist/collection/helpers/code-format/test/code-formatter.test.js +49 -1
  186. package/dist/collection/helpers/common/index.js +2 -37
  187. package/dist/collection/helpers/common/test/wait-for-vega-handler.test.js +2 -2
  188. package/dist/collection/helpers/common/wait-for-component-did-render.js +27 -0
  189. package/dist/collection/helpers/common/wait-for-vega-handler.js +12 -1
  190. package/dist/collection/helpers/feature-control/feature-flags-map.js +6 -0
  191. package/dist/collection/helpers/formatter/responsive-map-formatter/responsive-border-radius-style-formatter.js +1 -1
  192. package/dist/collection/helpers/public-api.js +0 -2
  193. package/dist/collection/helpers/slimmers/component-global-style-slimmer.js +2 -1
  194. package/dist/collection/helpers/slimmers/field-error-ui-controller-slimmer.js +3 -4
  195. package/dist/collection/helpers/slimmers/form-field-message-translator.js +1 -1
  196. package/dist/collection/helpers/slimmers/global/vega-translate-observer-slimmer.js +1 -1
  197. package/dist/collection/helpers/slimmers/global/vega-watch-method-cancel-slimmer.js +1 -1
  198. package/dist/collection/helpers/slimmers/mutation-observer/aria-attributes-value-mapper.js +128 -0
  199. package/dist/collection/helpers/slimmers/mutation-observer/test/aria-attributes-value-mapper.test.js +196 -0
  200. package/dist/collection/helpers/slimmers/position-calculation/base-position-calculation-strategy.js +162 -151
  201. package/dist/collection/helpers/slimmers/position-calculation/position-calculation-controller.js +9 -0
  202. package/dist/collection/helpers/slimmers/position-calculation/screen-position-calculation-strategy.js +112 -1
  203. package/dist/collection/helpers/slimmers/position-calculation/screen-scroll-position-update.js +53 -0
  204. package/dist/collection/helpers/slimmers/position-calculation/test/screen-position-calculation-strategy.test.js +103 -6
  205. package/dist/collection/helpers/slimmers/string-input-formatter-slimmer.js +1 -1
  206. package/dist/collection/helpers/slimmers/translation/translation-slimmer.js +1 -1
  207. package/dist/collection/helpers/theme/controllers/brand-style-controller.js +3 -1
  208. package/dist/collection/helpers/theme/controllers/color-schema-overriding-controller.js +8 -6
  209. package/dist/collection/helpers/theme/controllers/dark-mode-style-controller.js +3 -1
  210. package/dist/collection/helpers/theme/internal-theme-manager.js +2 -1
  211. package/dist/collection/helpers/theme/tests/theme-manager-controller.test.js +1 -2
  212. package/dist/collection/helpers/ui/element-appender.js +4 -5
  213. package/dist/collection/helpers/ui/test/element-appender.test.js +66 -17
  214. package/dist/collection/index.js +2 -0
  215. package/dist/collection/polyfill/prism/index.js +2 -0
  216. package/dist/collection/polyfill/prism/languages/css.js +86 -0
  217. package/dist/collection/polyfill/prism/languages/javascript.js +96 -0
  218. package/dist/collection/polyfill/prism/languages/jsx.js +46 -0
  219. package/dist/collection/polyfill/prism/languages/language-registry.js +41 -0
  220. package/dist/collection/polyfill/prism/languages/markup.js +71 -0
  221. package/dist/collection/polyfill/prism/languages/tsx.js +10 -0
  222. package/dist/collection/polyfill/prism/languages/typescript.js +64 -0
  223. package/dist/collection/polyfill/prism/test/css.test.js +61 -0
  224. package/dist/collection/polyfill/prism/test/javascript.test.js +113 -0
  225. package/dist/collection/polyfill/prism/test/jsx.test.js +48 -0
  226. package/dist/collection/polyfill/prism/test/language-registry.test.js +77 -0
  227. package/dist/collection/polyfill/prism/test/markup.test.js +57 -0
  228. package/dist/collection/polyfill/prism/test/test-utils.js +22 -0
  229. package/dist/collection/polyfill/prism/test/tokenizer.test.js +180 -0
  230. package/dist/collection/polyfill/prism/test/tsx.test.js +87 -0
  231. package/dist/collection/polyfill/prism/test/typescript.test.js +86 -0
  232. package/dist/collection/polyfill/prism/tokenizer.js +242 -0
  233. package/dist/collection/polyfill/prism/types.js +1 -0
  234. package/dist/collection/polyfill/tinycolor/tinycolor-polyfill.js +320 -0
  235. package/dist/collection/polyfill/tinycolor/tinycolor-polyfill.test.js +361 -0
  236. package/dist/collection/types/ui.type.js +12 -0
  237. package/dist/collection/utils/e2e-utils.js +10 -3
  238. package/dist/collection/utils/sanitize/constants/tag-sets.js +5 -0
  239. package/dist/collection/utils/sanitize/core/html-sanitizer.js +39 -0
  240. package/dist/collection/utils/sanitize/core/sanitize-strategy.js +62 -0
  241. package/dist/collection/utils/sanitize/core/types.js +4 -0
  242. package/dist/collection/utils/sanitize/index.js +12 -0
  243. package/dist/collection/utils/sanitize/strategies/empty-sanitize-strategy.js +17 -0
  244. package/dist/collection/utils/sanitize/strategies/index.js +3 -0
  245. package/dist/collection/utils/sanitize/strategies/label-sanitize-strategy.js +13 -0
  246. package/dist/collection/utils/sanitize/strategies/style-sanitize-strategy.js +50 -0
  247. package/dist/collection/utils/sanitize/test/empty-strategy.test.js +12 -0
  248. package/dist/collection/utils/sanitize/test/html-sanitizer.test.js +57 -0
  249. package/dist/collection/utils/sanitize/test/label-strategy.test.js +56 -0
  250. package/dist/collection/utils/sanitize/test/sanitize-strategy.test.js +85 -0
  251. package/dist/collection/utils/sanitize/test/sanitize.test.js +22 -0
  252. package/dist/collection/utils/sanitize/test/serialize-fragment.test.js +25 -0
  253. package/dist/collection/utils/sanitize/test/style-strategy.test.js +45 -0
  254. package/dist/collection/utils/sanitize/utils/serialize-fragment.js +17 -0
  255. package/dist/esm/{app-globals-f3414aca.js → app-globals-c0676920.js} +12 -16
  256. package/dist/esm/breakpoints-56e5407b.js +53 -0
  257. package/dist/esm/{child-nodes-event-prevent-slimmer-e662bee2.js → child-nodes-event-prevent-slimmer-649b9d30.js} +2 -2
  258. package/dist/esm/{child-nodes-notify-observer-slimmer-b676cd2b.js → child-nodes-notify-observer-slimmer-541dd6a4.js} +1 -1
  259. package/dist/esm/{code-block-8ee34ab6.js → code-block-b6247a45.js} +7 -7
  260. package/dist/esm/{component-global-style-slimmer-08046b38.js → component-global-style-slimmer-ac703085.js} +2 -1
  261. package/dist/esm/{component-usage-runtime-metrics-a84cc93e.js → component-usage-runtime-metrics-46020a03.js} +1 -1
  262. package/dist/esm/{component-value-history-controller-slimmer.abstract-a61bf821.js → component-value-history-controller-slimmer.abstract-2bb8533d.js} +6 -6
  263. package/dist/esm/{create-public-api-runtime-metrics-slimmer-bedf3a1e.js → create-public-api-runtime-metrics-slimmer-aaadaa08.js} +3 -38
  264. package/dist/esm/{dark-mode-style-controller-de88a117.js → dark-mode-style-controller-82e5c1c6.js} +292 -1254
  265. package/dist/esm/{date-required-rule-47ecc28f.js → date-required-rule-e771e7d9.js} +1 -1
  266. package/dist/esm/{design-token-9b299589.js → design-token-4aee1c56.js} +2 -2
  267. package/dist/esm/dom-node-subject-observer-factory-82f346e3.js +138 -0
  268. package/dist/esm/{dto-renderer-manager-f07cf2d9.js → dto-renderer-manager-6fd22ab7.js} +204 -29
  269. package/dist/esm/{element-appender-slimmer-7cb08343.js → element-appender-slimmer-e4713a72.js} +348 -165
  270. package/dist/esm/{event-emit-slimmer-09827cec.js → event-emit-slimmer-ffaecb9a.js} +2 -2
  271. package/dist/esm/{feature-flag-controller-51659753.js → feature-flag-controller-09ea7e87.js} +7 -1
  272. package/dist/esm/{form-field-controller-slimmer-5d9dc384.js → form-field-controller-slimmer-5817d14d.js} +10 -11
  273. package/dist/esm/{internal-icon-manager-f0486245.js → icon-manager-539d7cf7.js} +2 -52
  274. package/dist/esm/{image-annotation-action-53529cd9.js → image-annotation-action-6701b4c9.js} +6 -5
  275. package/dist/esm/index-3b327f29.js +215 -0
  276. package/dist/esm/{index-e9da316f.js → index-bfc6dfa2.js} +13 -1
  277. package/dist/esm/index.js +32 -29
  278. package/dist/esm/{inject-keyboard-manager-83d76ff5.js → inject-keyboard-manager-78730062.js} +1 -1
  279. package/dist/esm/internal-icon-manager-bd80b3bb.js +53 -0
  280. package/dist/esm/{translation-96e5debd.js → internal-translation-controller-911515f9.js} +1 -93
  281. package/dist/esm/{internal-vega-event-manager-efb6786e.js → internal-vega-event-manager-32a3d848.js} +1 -1
  282. package/dist/esm/internal-vega-z-index-manager-7d2b54c3.js +178 -0
  283. package/dist/esm/{keyboard-manager-c92808d8.js → keyboard-manager-38934f94.js} +2 -2
  284. package/dist/esm/{keyboard-manager-slimmer-79c78ce8.js → keyboard-manager-slimmer-9984d922.js} +1 -1
  285. package/dist/esm/loader.js +27 -24
  286. package/dist/esm/misc-9fdbcfbb.js +37 -0
  287. package/dist/esm/{month-view-generator-16192182.js → month-view-generator-eaf9029c.js} +1 -1
  288. package/dist/esm/{page-resize-observer-slimmer-8744cb44.js → page-resize-observer-slimmer-d6af0d86.js} +2 -52
  289. package/dist/esm/{public-rules-6ebdfcf5.js → public-rules-25cc3a39.js} +13 -14
  290. package/dist/esm/{range-5257c062.js → range-663f44dc.js} +2 -2
  291. package/dist/esm/{responsive-format-facade-05e53016.js → responsive-format-facade-7a071174.js} +3 -12
  292. package/dist/esm/{rich-text-editor-required-rule-f63a37d1.js → rich-text-editor-required-rule-a238b862.js} +1 -1
  293. package/dist/esm/{string-format-strategy.abstract-fc60db79.js → string-format-strategy.abstract-713fba36.js} +1 -1
  294. package/dist/esm/{string-input-formatter-slimmer-ee32b1fd.js → string-input-formatter-slimmer-5b413ff9.js} +4 -4
  295. package/dist/esm/{string-mask-strategy-0b0accaa.js → string-mask-strategy-6beaf664.js} +2 -2
  296. package/dist/esm/{style-formatter-5f5bd714.js → style-formatter-3d06b72d.js} +2 -2
  297. package/dist/esm/{sub-state-notify-slimmer-4453047a.js → sub-state-notify-slimmer-5133f1a8.js} +2 -2
  298. package/dist/esm/{sub-state-observer-slimmer-202ec7dc.js → sub-state-observer-slimmer-478c9f41.js} +3 -3
  299. package/dist/esm/{time-required-rule-5fa43804.js → time-required-rule-e4138a76.js} +1 -1
  300. package/dist/esm/{function-extension-63028f20.js → token-extension-e33fd151.js} +488 -376
  301. package/dist/esm/{translation-slimmer-c936cb1b.js → translation-slimmer-2394b173.js} +1 -1
  302. package/dist/esm/{type-guard-c65a227d.js → type-guard-f50e34d6.js} +1 -1
  303. package/dist/esm/{ui-bb99c0c2.js → ui-ee31416b.js} +12 -0
  304. package/dist/esm/{valid-credit-card-number-rule-666c415d.js → valid-credit-card-number-rule-22ce81db.js} +1 -1
  305. package/dist/esm/vega-accordion.entry.js +19 -28
  306. package/dist/esm/vega-app-footer.entry.js +3 -3
  307. package/dist/esm/vega-app-header-button.entry.js +174 -40
  308. package/dist/esm/vega-backdrop.entry.js +2 -2
  309. package/dist/esm/vega-banner.entry.js +12 -10
  310. package/dist/esm/vega-bar-chart.entry.js +1 -1
  311. package/dist/esm/vega-box.entry.js +14 -29
  312. package/dist/esm/vega-brand-logo.entry.js +7 -5
  313. package/dist/esm/vega-breadcrumb.entry.js +11 -10
  314. package/dist/esm/vega-button-circle.entry.js +19 -29
  315. package/dist/esm/vega-button-group_2.entry.js +12 -12
  316. package/dist/esm/vega-button-link.entry.js +13 -12
  317. package/dist/esm/vega-button.entry.js +19 -28
  318. package/dist/esm/vega-calendar_4.entry.js +23 -20
  319. package/dist/esm/vega-card.entry.js +9 -28
  320. package/dist/esm/vega-carousel.entry.js +14 -25
  321. package/dist/esm/vega-checkbox_2.entry.js +19 -17
  322. package/dist/esm/vega-chip.entry.js +18 -29
  323. package/dist/esm/vega-code-block.entry.js +653 -2704
  324. package/dist/esm/vega-color-picker.entry.js +15 -12
  325. package/dist/esm/vega-combo-box.entry.js +22 -21
  326. package/dist/esm/vega-counter-badge.entry.js +1 -1
  327. package/dist/esm/vega-date-picker_2.entry.js +34 -37
  328. package/dist/esm/vega-dialog-controller-bbb2fc52.js +82 -0
  329. package/dist/esm/vega-dialog_2.entry.js +23 -30
  330. package/dist/esm/vega-divider.entry.js +11 -29
  331. package/dist/esm/vega-dropdown_5.entry.js +39 -45
  332. package/dist/esm/vega-env-manager-8f8dc473.js +2 -2
  333. package/dist/esm/vega-event-id-38aa77a0.js +113 -0
  334. package/dist/esm/vega-field-error.entry.js +1 -1
  335. package/dist/esm/vega-field-label.entry.js +7 -6
  336. package/dist/esm/vega-file-uploader.entry.js +19 -14
  337. package/dist/esm/vega-flag-icon.entry.js +12 -26
  338. package/dist/esm/vega-flex.entry.js +11 -28
  339. package/dist/esm/vega-font.entry.js +11 -28
  340. package/dist/esm/vega-form.entry.js +20 -18
  341. package/dist/esm/vega-grid.entry.js +9 -28
  342. package/dist/esm/vega-hint.entry.js +1 -1
  343. package/dist/esm/vega-icon.entry.js +15 -28
  344. package/dist/esm/vega-image-uploader.entry.js +28 -31
  345. package/dist/esm/vega-input-credit-card.entry.js +25 -21
  346. package/dist/esm/vega-input-numeric.entry.js +21 -19
  347. package/dist/esm/vega-input-passcode.entry.js +20 -18
  348. package/dist/esm/vega-input-phone-number.entry.js +27 -31
  349. package/dist/esm/vega-input-range.entry.js +19 -17
  350. package/dist/esm/vega-input-select.entry.js +27 -32
  351. package/dist/esm/vega-input.entry.js +33 -21
  352. package/dist/esm/{vega-internal-event-id-4a06d705.js → vega-internal-event-id-799d012e.js} +1 -1
  353. package/dist/esm/vega-item-toggle.entry.js +6 -5
  354. package/dist/esm/vega-left-nav_5.entry.js +29 -31
  355. package/dist/esm/vega-line-chart.entry.js +1 -1
  356. package/dist/esm/vega-loader-wrapper_2.entry.js +13 -29
  357. package/dist/esm/vega-page-notification_2.entry.js +4 -3
  358. package/dist/esm/vega-pagination-page-selector-mobile.entry.js +9 -9
  359. package/dist/esm/vega-pagination-page-size-selector-mobile.entry.js +7 -8
  360. package/dist/esm/vega-pagination.entry.js +20 -30
  361. package/dist/esm/vega-pie-chart.entry.js +1 -1
  362. package/dist/esm/vega-popover_2.entry.js +20 -30
  363. package/dist/esm/vega-progress-tracker_2.entry.js +64 -37
  364. package/dist/esm/vega-radio_2.entry.js +21 -19
  365. package/dist/esm/vega-rich-text-content.entry.js +18 -16
  366. package/dist/esm/vega-rich-text-editor_4.entry.js +90 -37
  367. package/dist/esm/vega-section-title.entry.js +1 -1
  368. package/dist/esm/vega-segment-control.entry.js +9 -7
  369. package/dist/esm/vega-selection-chip_2.entry.js +22 -29
  370. package/dist/esm/vega-selection-tile_2.entry.js +19 -17
  371. package/dist/esm/vega-sidenav_3.entry.js +24 -30
  372. package/dist/esm/vega-signature-capture.entry.js +24 -28
  373. package/dist/esm/vega-skeleton.entry.js +1 -1
  374. package/dist/esm/vega-slot-container.entry.js +1 -1
  375. package/dist/esm/vega-stepper.entry.js +18 -16
  376. package/dist/esm/vega-tab-group_2.entry.js +11 -10
  377. package/dist/esm/vega-table_11.entry.js +28 -29
  378. package/dist/esm/vega-text.entry.js +4 -3
  379. package/dist/esm/vega-textarea.entry.js +18 -16
  380. package/dist/esm/vega-time-picker_2.entry.js +26 -32
  381. package/dist/esm/vega-toggle-switch.entry.js +15 -12
  382. package/dist/esm/vega-tooltip_2.entry.js +18 -29
  383. package/dist/esm/vega.js +27 -24
  384. package/dist/esm/{index-51a7da7f.js → wait-for-component-did-render-b08ef07b.js} +3 -13
  385. package/dist/sri/vega-sri-manifest.json +415 -403
  386. package/dist/types/components/vega-app-footer/types.d.ts +18 -0
  387. package/dist/types/components/vega-app-header-button/types.d.ts +31 -0
  388. package/dist/types/components/vega-app-header-button/vega-app-header-button.d.ts +2 -0
  389. package/dist/types/components/vega-banner/types.d.ts +9 -0
  390. package/dist/types/components/vega-box/interface.d.ts +46 -0
  391. package/dist/types/components/vega-breadcrumb/types.d.ts +28 -0
  392. package/dist/types/components/vega-button/types.d.ts +12 -0
  393. package/dist/types/components/vega-button-circle/types.d.ts +9 -0
  394. package/dist/types/components/vega-button-group/types.d.ts +48 -0
  395. package/dist/types/components/vega-button-link/types.d.ts +3 -0
  396. package/dist/types/components/vega-calendar/types.d.ts +189 -0
  397. package/dist/types/components/vega-calendar/vega-calendar-event-preview/types.d.ts +6 -0
  398. package/dist/types/components/vega-chart/vega-bar-chart/types.d.ts +3 -0
  399. package/dist/types/components/vega-chip/types.d.ts +12 -0
  400. package/dist/types/components/vega-code-block/slimmers/controllers/prism-code-highlight-parse-controller.d.ts +2 -10
  401. package/dist/types/components/vega-combo-box/types.d.ts +6 -0
  402. package/dist/types/components/vega-date-picker/types.d.ts +39 -0
  403. package/dist/types/components/vega-dialog/types.d.ts +5 -0
  404. package/dist/types/components/vega-divider/interface.d.ts +18 -0
  405. package/dist/types/components/vega-dropdown/types.d.ts +30 -0
  406. package/dist/types/components/vega-dropdown/vega-dropdown-item/types.d.ts +9 -1
  407. package/dist/types/components/vega-field-error/types.d.ts +12 -0
  408. package/dist/types/components/vega-field-label/types.d.ts +16 -0
  409. package/dist/types/components/vega-file-uploader/types.d.ts +12 -0
  410. package/dist/types/components/vega-font/types.d.ts +3 -0
  411. package/dist/types/components/vega-form/types.d.ts +45 -0
  412. package/dist/types/components/vega-image-uploader/types.d.ts +33 -1
  413. package/dist/types/components/vega-input/types.d.ts +31 -0
  414. package/dist/types/components/vega-input-phone-number/types.d.ts +15 -0
  415. package/dist/types/components/vega-input-range/types.d.ts +9 -0
  416. package/dist/types/components/vega-input-select/types.d.ts +45 -0
  417. package/dist/types/components/vega-item-toggle/types.d.ts +21 -0
  418. package/dist/types/components/vega-loading-indicator/types.d.ts +3 -0
  419. package/dist/types/components/vega-modal/types.d.ts +9 -0
  420. package/dist/types/components/vega-nav/interface.d.ts +108 -0
  421. package/dist/types/components/vega-page-notification/types.d.ts +15 -0
  422. package/dist/types/components/vega-pagination/types.d.ts +11 -0
  423. package/dist/types/components/vega-progress-tracker/slimmers/controllers/dto/internal-progress-tracker-step.d.ts +16 -4
  424. package/dist/types/components/vega-progress-tracker/type.d.ts +8 -0
  425. package/dist/types/components/vega-progress-tracker/vega-progress-tracker-step/vega-progress-tracker-step.d.ts +6 -0
  426. package/dist/types/components/vega-progress-tracker/vega-progress-tracker.d.ts +2 -2
  427. package/dist/types/components/vega-rich-text-editor/dto/blocks/html-block.d.ts +10 -0
  428. package/dist/types/components/vega-rich-text-editor/interface.d.ts +473 -2
  429. package/dist/types/components/vega-rich-text-editor/slimmers/controllers/html-cleaner/html-content-cleaner-processor.interface.d.ts +13 -0
  430. package/dist/types/components/vega-rich-text-editor/slimmers/controllers/html-cleaner/html-content-cleaner.d.ts +35 -0
  431. package/dist/types/components/vega-rich-text-editor/slimmers/controllers/html-cleaner/index.d.ts +4 -0
  432. package/dist/types/components/vega-rich-text-editor/slimmers/controllers/html-cleaner/processors/remove-whitespace-after-opening-tag-processor.d.ts +19 -0
  433. package/dist/types/components/vega-rich-text-editor/slimmers/controllers/html-cleaner/processors/remove-whitespace-before-closing-tag-processor.d.ts +19 -0
  434. package/dist/types/components/vega-rich-text-editor/slimmers/controllers/html-cleaner/processors/remove-whitespace-between-tags-processor.d.ts +59 -0
  435. package/dist/types/components/vega-rich-text-editor/test/html-cleaner/html-content-cleaner.test.d.ts +1 -0
  436. package/dist/types/components/vega-rich-text-editor/test/html-cleaner/remove-whitespace-after-opening-tag-processor.test.d.ts +1 -0
  437. package/dist/types/components/vega-rich-text-editor/test/html-cleaner/remove-whitespace-before-closing-tag-processor.test.d.ts +1 -0
  438. package/dist/types/components/vega-rich-text-editor/test/html-cleaner/remove-whitespace-between-tags-processor.test.d.ts +1 -0
  439. package/dist/types/components/vega-rich-text-editor/vega-rich-text-image-editor/types.d.ts +24 -0
  440. package/dist/types/components/vega-rich-text-editor/vega-rich-text-link-editor/types.d.ts +24 -0
  441. package/dist/types/components/vega-segment-control/types.d.ts +18 -0
  442. package/dist/types/components/vega-selection-chip/interface.d.ts +12 -0
  443. package/dist/types/components/vega-selection-chip/vega-selection-chip-group/interface.d.ts +4 -0
  444. package/dist/types/components/vega-selection-tile/interface.d.ts +9 -0
  445. package/dist/types/components/vega-sidenav/types.d.ts +51 -0
  446. package/dist/types/components/vega-signature-capture/types.d.ts +29 -2
  447. package/dist/types/components/vega-skeleton/interface.d.ts +6 -0
  448. package/dist/types/components/vega-tab-group/types.d.ts +36 -0
  449. package/dist/types/components/vega-table/interface.d.ts +237 -20
  450. package/dist/types/components/vega-table/vega-table-expand-row/types.d.ts +6 -0
  451. package/dist/types/components/vega-table/vega-table-foot/types.d.ts +9 -0
  452. package/dist/types/components/vega-table/vega-table-foot-row/types.d.ts +9 -0
  453. package/dist/types/components/vega-table/vega-table-head/types.d.ts +9 -0
  454. package/dist/types/components/vega-table/vega-table-head-row/types.d.ts +12 -0
  455. package/dist/types/components/vega-table/vega-table-row/types.d.ts +18 -0
  456. package/dist/types/components/vega-text/types.d.ts +6 -0
  457. package/dist/types/components/vega-time-picker/types.d.ts +33 -0
  458. package/dist/types/components/vega-virtual-scroll/types.d.ts +30 -1
  459. package/dist/types/components.d.ts +13 -3
  460. package/dist/types/helpers/code-format/code-formatter.d.ts +14 -0
  461. package/dist/types/helpers/common/index.d.ts +2 -15
  462. package/dist/types/helpers/common/wait-for-component-did-render.d.ts +8 -0
  463. package/dist/types/helpers/common/wait-for-vega-handler.d.ts +6 -15
  464. package/dist/types/helpers/feature-control/feature-flag.d.ts +2 -1
  465. package/dist/types/helpers/public-api.d.ts +0 -2
  466. package/dist/types/helpers/slimmers/mutation-observer/aria-attributes-value-mapper.d.ts +44 -0
  467. package/dist/types/helpers/slimmers/mutation-observer/test/aria-attributes-value-mapper.test.d.ts +1 -0
  468. package/dist/types/helpers/slimmers/position-calculation/base-position-calculation-strategy.d.ts +57 -48
  469. package/dist/types/helpers/slimmers/position-calculation/position-calculation-controller.d.ts +5 -0
  470. package/dist/types/helpers/slimmers/position-calculation/screen-position-calculation-strategy.d.ts +41 -1
  471. package/dist/types/helpers/slimmers/position-calculation/screen-scroll-position-update.d.ts +39 -0
  472. package/dist/types/helpers/ui/element-appender.d.ts +0 -1
  473. package/dist/types/index.d.ts +2 -0
  474. package/dist/types/polyfill/prism/index.d.ts +3 -0
  475. package/dist/types/polyfill/prism/languages/css.d.ts +6 -0
  476. package/dist/types/polyfill/prism/languages/javascript.d.ts +7 -0
  477. package/dist/types/polyfill/prism/languages/jsx.d.ts +7 -0
  478. package/dist/types/polyfill/prism/languages/language-registry.d.ts +8 -0
  479. package/dist/types/polyfill/prism/languages/markup.d.ts +6 -0
  480. package/dist/types/polyfill/prism/languages/tsx.d.ts +7 -0
  481. package/dist/types/polyfill/prism/languages/typescript.d.ts +2 -0
  482. package/dist/types/polyfill/prism/test/css.test.d.ts +1 -0
  483. package/dist/types/polyfill/prism/test/javascript.test.d.ts +1 -0
  484. package/dist/types/polyfill/prism/test/jsx.test.d.ts +1 -0
  485. package/dist/types/polyfill/prism/test/language-registry.test.d.ts +1 -0
  486. package/dist/types/polyfill/prism/test/markup.test.d.ts +1 -0
  487. package/dist/types/polyfill/prism/test/test-utils.d.ts +10 -0
  488. package/dist/types/polyfill/prism/test/tokenizer.test.d.ts +1 -0
  489. package/dist/types/polyfill/prism/test/tsx.test.d.ts +1 -0
  490. package/dist/types/polyfill/prism/test/typescript.test.d.ts +1 -0
  491. package/dist/types/polyfill/prism/tokenizer.d.ts +17 -0
  492. package/dist/types/polyfill/prism/types.d.ts +25 -0
  493. package/dist/types/polyfill/tinycolor/tinycolor-polyfill.d.ts +149 -0
  494. package/dist/types/polyfill/tinycolor/tinycolor-polyfill.test.d.ts +1 -0
  495. package/dist/types/types/components.type.d.ts +4 -1
  496. package/dist/types/types/design-token.type.d.ts +36 -0
  497. package/dist/types/types/flag.type.d.ts +3 -0
  498. package/dist/types/types/general.d.ts +12 -0
  499. package/dist/types/types/ui.type.d.ts +372 -0
  500. package/dist/types/types/vega-chart.d.ts +281 -2
  501. package/dist/types/utils/e2e-utils.d.ts +2 -0
  502. package/dist/types/utils/sanitize/constants/tag-sets.d.ts +6 -0
  503. package/dist/types/utils/sanitize/core/html-sanitizer.d.ts +22 -0
  504. package/dist/types/utils/sanitize/core/sanitize-strategy.d.ts +27 -0
  505. package/dist/types/utils/sanitize/core/types.d.ts +13 -0
  506. package/dist/types/utils/sanitize/index.d.ts +12 -0
  507. package/dist/types/utils/sanitize/strategies/empty-sanitize-strategy.d.ts +14 -0
  508. package/dist/types/utils/sanitize/strategies/index.d.ts +3 -0
  509. package/dist/types/utils/sanitize/strategies/label-sanitize-strategy.d.ts +10 -0
  510. package/dist/types/utils/sanitize/strategies/style-sanitize-strategy.d.ts +24 -0
  511. package/dist/types/utils/sanitize/test/empty-strategy.test.d.ts +1 -0
  512. package/dist/types/utils/sanitize/test/html-sanitizer.test.d.ts +1 -0
  513. package/dist/types/utils/sanitize/test/label-strategy.test.d.ts +1 -0
  514. package/dist/types/utils/sanitize/test/sanitize-strategy.test.d.ts +1 -0
  515. package/dist/types/utils/sanitize/test/sanitize.test.d.ts +1 -0
  516. package/dist/types/utils/sanitize/test/serialize-fragment.test.d.ts +1 -0
  517. package/dist/types/utils/sanitize/test/style-strategy.test.d.ts +1 -0
  518. package/dist/types/utils/sanitize/utils/serialize-fragment.d.ts +12 -0
  519. package/dist/vega/index.esm.js +1 -1
  520. package/dist/vega/p-01d58eb8.entry.js +1 -0
  521. package/dist/vega/p-021d4ae4.js +1 -0
  522. package/dist/vega/p-02a7d60c.entry.js +1 -0
  523. package/dist/vega/{p-66fa700b.js → p-02c9796a.js} +1 -1
  524. package/dist/vega/p-033c31d8.entry.js +1 -0
  525. package/dist/vega/{p-e77a83e4.js → p-07cb0243.js} +1 -1
  526. package/dist/vega/p-087ea379.entry.js +1 -0
  527. package/dist/vega/{p-e5af5a4d.entry.js → p-0b4880bd.entry.js} +1 -1
  528. package/dist/vega/{p-920719ad.js → p-0e679d8c.js} +1 -1
  529. package/dist/vega/{p-c9b6b5a9.js → p-10734a00.js} +1 -1
  530. package/dist/vega/p-154f9cf7.entry.js +1 -0
  531. package/dist/vega/p-179aad4f.entry.js +1 -0
  532. package/dist/vega/p-1a3236e7.entry.js +1 -0
  533. package/dist/vega/p-1f3cd061.entry.js +1 -0
  534. package/dist/vega/p-1f5e35dc.entry.js +1 -0
  535. package/dist/vega/p-242fbcad.entry.js +1 -0
  536. package/dist/vega/p-249df6d2.entry.js +1 -0
  537. package/dist/vega/p-28ad1864.entry.js +1 -0
  538. package/dist/vega/p-2a10e2e5.js +1 -0
  539. package/dist/vega/p-2b49686d.entry.js +1 -0
  540. package/dist/vega/p-2ba78982.entry.js +1 -0
  541. package/dist/vega/p-2bb5a232.js +1 -0
  542. package/dist/vega/{p-e9b86dac.entry.js → p-2c1a85dd.entry.js} +1 -1
  543. package/dist/vega/p-2cc9d126.entry.js +1 -0
  544. package/dist/vega/p-2d69632d.js +1 -0
  545. package/dist/vega/p-2e91295d.entry.js +1 -0
  546. package/dist/vega/p-31ac7386.js +1 -0
  547. package/dist/vega/p-32033e7a.js +1 -0
  548. package/dist/vega/p-32183637.entry.js +1 -0
  549. package/dist/vega/p-3244c605.entry.js +1 -0
  550. package/dist/vega/p-32faa460.entry.js +1 -0
  551. package/dist/vega/p-33f9ad94.entry.js +1 -0
  552. package/dist/vega/{p-4897bedd.entry.js → p-358b4a06.entry.js} +1 -1
  553. package/dist/vega/p-3afc025e.entry.js +1 -0
  554. package/dist/vega/p-3d8122ab.entry.js +1 -0
  555. package/dist/vega/{p-ea04a387.entry.js → p-3f3c771a.entry.js} +1 -1
  556. package/dist/vega/{p-1f83cebf.js → p-415ffa35.js} +1 -1
  557. package/dist/vega/{p-d849e0f5.js → p-4415ad28.js} +1 -1
  558. package/dist/vega/{p-ce1a2982.js → p-464559e3.js} +1 -1
  559. package/dist/vega/p-49845a91.js +1 -0
  560. package/dist/vega/{p-e16b3adf.js → p-4bffdb28.js} +1 -1
  561. package/dist/vega/p-4e017458.entry.js +1 -0
  562. package/dist/vega/p-4e4a0228.entry.js +1 -0
  563. package/dist/vega/{p-a2aeb646.js → p-4ea30592.js} +1 -1
  564. package/dist/vega/{p-0b38a01f.entry.js → p-51fcb07f.entry.js} +1 -1
  565. package/dist/vega/p-57927b10.entry.js +1 -0
  566. package/dist/vega/p-5831d6d3.entry.js +1 -0
  567. package/dist/vega/p-593e0f80.js +1 -0
  568. package/dist/vega/p-5a25014f.js +1 -0
  569. package/dist/vega/p-5eb7f382.js +1 -0
  570. package/dist/vega/p-5f377954.js +1 -1
  571. package/dist/vega/p-644f701a.js +1 -0
  572. package/dist/vega/p-6a62e476.entry.js +1 -0
  573. package/dist/vega/{p-75f981ce.js → p-6b6f0fb4.js} +1 -1
  574. package/dist/vega/p-6d219c44.entry.js +1 -0
  575. package/dist/vega/p-6d60b66a.entry.js +1 -0
  576. package/dist/vega/{p-ad2055f4.entry.js → p-6dcdb580.entry.js} +1 -1
  577. package/dist/vega/{p-c8f1b9d5.js → p-7181861a.js} +1 -1
  578. package/dist/vega/p-76181a70.entry.js +1 -0
  579. package/dist/vega/p-781fd6e0.js +1 -0
  580. package/dist/vega/p-7958614a.entry.js +1 -0
  581. package/dist/vega/{p-5b71c85e.js → p-7c39ce96.js} +1 -1
  582. package/dist/vega/p-7d7aaff9.entry.js +1 -0
  583. package/dist/vega/{p-4dd6554e.entry.js → p-7f46cc1e.entry.js} +1 -1
  584. package/dist/vega/{p-badad9ed.js → p-81b044b9.js} +1 -1
  585. package/dist/vega/p-8950987b.entry.js +1 -0
  586. package/dist/vega/p-89f2e16d.entry.js +1 -0
  587. package/dist/vega/p-8ac2d165.js +1 -0
  588. package/dist/vega/p-8b153acd.entry.js +1 -0
  589. package/dist/vega/p-8b5d3a52.js +1 -0
  590. package/dist/vega/{p-fff13ed1.entry.js → p-8b891f36.entry.js} +1 -1
  591. package/dist/vega/p-8dbdd609.entry.js +1 -0
  592. package/dist/vega/{p-dd11f735.js → p-9339c6c4.js} +1 -1
  593. package/dist/vega/p-94a77fbe.entry.js +1 -0
  594. package/dist/vega/p-95528b47.js +1 -0
  595. package/dist/vega/p-9a137bab.entry.js +1 -0
  596. package/dist/vega/{p-6f8be8ea.js → p-a0b66c25.js} +1 -1
  597. package/dist/vega/{p-0bb3be0b.entry.js → p-a13a73fa.entry.js} +1 -1
  598. package/dist/vega/p-a560d8c5.entry.js +1 -0
  599. package/dist/vega/{p-d0e31633.js → p-a786259a.js} +1 -1
  600. package/dist/vega/p-a7a8a4eb.entry.js +1 -0
  601. package/dist/vega/p-a8792e3d.js +1 -0
  602. package/dist/vega/{p-60851f9d.js → p-aa1174dc.js} +1 -1
  603. package/dist/vega/p-ab834f06.js +1 -0
  604. package/dist/vega/p-b136ebba.entry.js +1 -0
  605. package/dist/vega/p-b201f379.js +1 -0
  606. package/dist/vega/p-b256b7a4.js +1 -0
  607. package/dist/vega/p-b366deff.entry.js +1 -0
  608. package/dist/vega/p-b597393b.entry.js +1 -0
  609. package/dist/vega/p-b7f3221f.js +1 -0
  610. package/dist/vega/p-bb5e0192.entry.js +1 -0
  611. package/dist/vega/p-be1a210b.js +1 -0
  612. package/dist/vega/p-bebfbe95.entry.js +1 -0
  613. package/dist/vega/p-bf6fc19f.entry.js +1 -0
  614. package/dist/vega/p-c1d13eec.entry.js +1 -0
  615. package/dist/vega/p-c29068fb.entry.js +1 -0
  616. package/dist/vega/p-c3d2f316.js +1 -0
  617. package/dist/vega/{p-671afda4.entry.js → p-c72e08c6.entry.js} +1 -1
  618. package/dist/vega/p-c801c85d.js +1 -0
  619. package/dist/vega/p-c8feb644.entry.js +1 -0
  620. package/dist/vega/p-ca5898dc.entry.js +1 -0
  621. package/dist/vega/p-d555f677.entry.js +1 -0
  622. package/dist/vega/p-d64fab3d.js +1 -0
  623. package/dist/vega/p-d6dbbe61.entry.js +1 -0
  624. package/dist/vega/p-d7a78c5e.entry.js +1 -0
  625. package/dist/vega/p-d8fadcdc.entry.js +1 -0
  626. package/dist/vega/p-dad3ba5f.js +1 -0
  627. package/dist/vega/p-dd3a94f4.entry.js +1 -0
  628. package/dist/vega/p-e1431c14.entry.js +1 -0
  629. package/dist/vega/p-e1fbfd20.js +1 -0
  630. package/dist/vega/p-e2af0e24.entry.js +1 -0
  631. package/dist/vega/{p-521d1d07.js → p-e52890db.js} +1 -1
  632. package/dist/vega/{p-1298b126.js → p-e632475e.js} +1 -1
  633. package/dist/vega/p-e6adf829.js +1 -0
  634. package/dist/vega/{p-77edf50c.js → p-e827d56d.js} +1 -1
  635. package/dist/vega/p-e8775a56.entry.js +1 -0
  636. package/dist/vega/p-e89e3ede.entry.js +1 -0
  637. package/dist/vega/p-eda988d5.entry.js +1 -0
  638. package/dist/vega/p-f05b8f76.entry.js +1 -0
  639. package/dist/vega/p-f0e828d8.js +1 -0
  640. package/dist/vega/p-f14a5eae.entry.js +1 -0
  641. package/dist/vega/p-f2b0b58a.js +1 -0
  642. package/dist/vega/p-f3d0f2dc.js +1 -0
  643. package/dist/vega/{p-5910be31.entry.js → p-f5bafc45.entry.js} +1 -1
  644. package/dist/vega/p-fc1fa345.js +1 -0
  645. package/dist/vega/p-fd7ddd64.entry.js +1 -0
  646. package/dist/vega/vega.esm.js +1 -1
  647. package/package.json +3 -5
  648. package/dist/cjs/_commonjsHelpers-537d719a.js +0 -20
  649. package/dist/cjs/language-extension-38e4905e.js +0 -210
  650. package/dist/cjs/sanitize-fb222510.js +0 -131
  651. package/dist/cjs/wait-for-vega-handler-5469ff80.js +0 -63
  652. package/dist/collection/utils/sanitize.js +0 -126
  653. package/dist/collection/utils/test/sanitize.test.js +0 -65
  654. package/dist/esm/_commonjsHelpers-9943807e.js +0 -17
  655. package/dist/esm/dom-node-subject-observer-factory-064ee2b2.js +0 -250
  656. package/dist/esm/language-extension-c4ff21dd.js +0 -207
  657. package/dist/esm/sanitize-fd0cb40d.js +0 -129
  658. package/dist/esm/wait-for-vega-handler-c2c07ac3.js +0 -61
  659. package/dist/types/utils/sanitize.d.ts +0 -71
  660. package/dist/vega/p-011b94b1.entry.js +0 -1
  661. package/dist/vega/p-06aaced4.js +0 -1
  662. package/dist/vega/p-07d3df01.entry.js +0 -1
  663. package/dist/vega/p-08f18b22.entry.js +0 -1
  664. package/dist/vega/p-10ac8b57.js +0 -1
  665. package/dist/vega/p-112455b1.js +0 -1
  666. package/dist/vega/p-17c55205.entry.js +0 -1
  667. package/dist/vega/p-1e0d8228.entry.js +0 -1
  668. package/dist/vega/p-20ad42be.js +0 -1
  669. package/dist/vega/p-22b2841f.entry.js +0 -1
  670. package/dist/vega/p-22c5d83b.js +0 -1
  671. package/dist/vega/p-34246870.entry.js +0 -1
  672. package/dist/vega/p-35bf5789.entry.js +0 -1
  673. package/dist/vega/p-3bbc0c7d.entry.js +0 -1
  674. package/dist/vega/p-3bf66be2.js +0 -1
  675. package/dist/vega/p-3c5a28e4.entry.js +0 -1
  676. package/dist/vega/p-3cfd8616.entry.js +0 -1
  677. package/dist/vega/p-3e5f362f.js +0 -1
  678. package/dist/vega/p-43f585f7.entry.js +0 -1
  679. package/dist/vega/p-476a173a.js +0 -1
  680. package/dist/vega/p-4a537391.entry.js +0 -1
  681. package/dist/vega/p-509eb52e.entry.js +0 -1
  682. package/dist/vega/p-50ab977c.entry.js +0 -1
  683. package/dist/vega/p-53a694d1.entry.js +0 -1
  684. package/dist/vega/p-56e97df8.js +0 -1
  685. package/dist/vega/p-5a27084e.entry.js +0 -1
  686. package/dist/vega/p-5d676a94.js +0 -1
  687. package/dist/vega/p-5df9a856.entry.js +0 -1
  688. package/dist/vega/p-5ea2e43c.entry.js +0 -1
  689. package/dist/vega/p-60274fb1.js +0 -1
  690. package/dist/vega/p-60da99c6.entry.js +0 -1
  691. package/dist/vega/p-67f18b9e.entry.js +0 -1
  692. package/dist/vega/p-67fcf6f2.entry.js +0 -9
  693. package/dist/vega/p-6a2205a1.entry.js +0 -1
  694. package/dist/vega/p-6a4277df.entry.js +0 -1
  695. package/dist/vega/p-6e136980.js +0 -1
  696. package/dist/vega/p-6f239144.entry.js +0 -1
  697. package/dist/vega/p-7045e84c.entry.js +0 -1
  698. package/dist/vega/p-7288f8c4.js +0 -1
  699. package/dist/vega/p-747d6afc.entry.js +0 -1
  700. package/dist/vega/p-75651f32.entry.js +0 -1
  701. package/dist/vega/p-7ae55fd5.js +0 -1
  702. package/dist/vega/p-81134e9e.entry.js +0 -1
  703. package/dist/vega/p-87238c4c.entry.js +0 -1
  704. package/dist/vega/p-8a887843.entry.js +0 -1
  705. package/dist/vega/p-8c0eb12f.entry.js +0 -1
  706. package/dist/vega/p-8c9ea6f4.js +0 -1
  707. package/dist/vega/p-8d0ca805.js +0 -1
  708. package/dist/vega/p-8e42a14c.entry.js +0 -1
  709. package/dist/vega/p-91ec2e30.js +0 -1
  710. package/dist/vega/p-94394df7.entry.js +0 -1
  711. package/dist/vega/p-991008a8.entry.js +0 -1
  712. package/dist/vega/p-9fd503e9.entry.js +0 -1
  713. package/dist/vega/p-a20854d6.entry.js +0 -1
  714. package/dist/vega/p-a4670e23.js +0 -1
  715. package/dist/vega/p-a530797f.entry.js +0 -1
  716. package/dist/vega/p-a5bd3c15.entry.js +0 -1
  717. package/dist/vega/p-a65941d0.entry.js +0 -1
  718. package/dist/vega/p-a85ad369.entry.js +0 -1
  719. package/dist/vega/p-a86010f7.entry.js +0 -1
  720. package/dist/vega/p-aa10eeb3.entry.js +0 -1
  721. package/dist/vega/p-ab2f35af.entry.js +0 -1
  722. package/dist/vega/p-ac4563d7.js +0 -1
  723. package/dist/vega/p-aedf7146.js +0 -1
  724. package/dist/vega/p-b4ea3fad.js +0 -1
  725. package/dist/vega/p-bb4a558d.entry.js +0 -1
  726. package/dist/vega/p-bb8339ed.entry.js +0 -1
  727. package/dist/vega/p-be930e85.entry.js +0 -1
  728. package/dist/vega/p-bf2bd6d0.entry.js +0 -1
  729. package/dist/vega/p-c379a5a5.entry.js +0 -1
  730. package/dist/vega/p-c616c592.js +0 -1
  731. package/dist/vega/p-ca3472c1.entry.js +0 -1
  732. package/dist/vega/p-cc43bffb.js +0 -1
  733. package/dist/vega/p-d6ed3d76.entry.js +0 -1
  734. package/dist/vega/p-db8cdba6.js +0 -1
  735. package/dist/vega/p-e1610196.entry.js +0 -1
  736. package/dist/vega/p-e87b0b4a.entry.js +0 -1
  737. package/dist/vega/p-e9c4fd24.entry.js +0 -1
  738. package/dist/vega/p-eb60cfe1.entry.js +0 -1
  739. package/dist/vega/p-ef001c70.entry.js +0 -1
  740. package/dist/vega/p-ef9cbad1.js +0 -1
  741. package/dist/vega/p-f383c856.js +0 -1
  742. package/dist/vega/p-f3c3ff26.entry.js +0 -1
  743. package/dist/vega/p-f52a0155.entry.js +0 -1
  744. package/dist/vega/p-f69f84a7.js +0 -1
  745. package/dist/vega/p-f8f7cf48.entry.js +0 -1
  746. package/dist/vega/p-fba14ad2.entry.js +0 -1
  747. package/dist/vega/p-fbd64f9c.entry.js +0 -1
  748. package/dist/vega/p-fdc270b8.entry.js +0 -1
  749. package/dist/vega/p-fe12eff6.js +0 -1
  750. package/dist/vega/p-ffbff9b5.entry.js +0 -1
  751. /package/dist/{types/utils/test/sanitize.test.d.ts → collection/components/vega-rich-text-editor/slimmers/controllers/html-cleaner/html-content-cleaner-processor.interface.js} +0 -0
  752. /package/dist/vega/{p-d9671d27.js → p-6c170474.js} +0 -0
@@ -1,43 +1,46 @@
1
1
  import { h, F as Fragment, r as registerInstance, c as createEvent, H as Host, g as getElement } from './index-090d31ca.js';
2
2
  import { c as MapToComponentField, V as VegaSlimmer, M as MapToComponentMethod, I as InjectVegaSlimmer } from './global-slimmer-registry-17c4efd4.js';
3
- import { V as VegaComponentUsageRuntimeMetricsSlimmer, I as InjectVegaGlobalSlimmer } from './component-usage-runtime-metrics-a84cc93e.js';
3
+ import { V as VegaComponentUsageRuntimeMetricsSlimmer, I as InjectVegaGlobalSlimmer } from './component-usage-runtime-metrics-46020a03.js';
4
4
  import { s as sanitizeVegaComponent } from './component-7d906393.js';
5
- import { a as VegaInternalIconManager } from './internal-icon-manager-f0486245.js';
5
+ import { V as VegaInternalIconManager } from './internal-icon-manager-bd80b3bb.js';
6
6
  import { t as trashCan } from './trash-can-8819a939.js';
7
- import { D as DomNodeSubjectObserverFactory, g as VegaChange, a as VegaClick, d as domNodeSubjectFactory, m as VegaRemove } from './dom-node-subject-observer-factory-064ee2b2.js';
8
- import { Q as CodeLanguage } from './code-block-8ee34ab6.js';
9
- import { a as arrayToClassString } from './ui-bb99c0c2.js';
10
- import { c as createEventEmitSlimmer } from './event-emit-slimmer-09827cec.js';
7
+ import { D as DomNodeSubjectObserverFactory, d as domNodeSubjectFactory } from './dom-node-subject-observer-factory-82f346e3.js';
8
+ import { f as VegaChange, a as VegaClick, l as VegaRemove } from './vega-event-id-38aa77a0.js';
9
+ import { Q as CodeLanguage } from './code-block-b6247a45.js';
10
+ import { a as arrayToClassString } from './ui-ee31416b.js';
11
+ import { c as createEventEmitSlimmer } from './event-emit-slimmer-ffaecb9a.js';
11
12
  import { d as deepEqual } from './object-66c37948.js';
12
- import { T as TranslationSlimmer } from './translation-slimmer-c936cb1b.js';
13
- import { A as AutoRunWhenReRenderTaskQueueSlimmer, S as ShadowSelectionPolyfill, a as SelectionController, C as ComponentValueHistoryControllerSlimmer } from './component-value-history-controller-slimmer.abstract-a61bf821.js';
13
+ import { T as TranslationSlimmer } from './translation-slimmer-2394b173.js';
14
+ import { A as AutoRunWhenReRenderTaskQueueSlimmer, S as ShadowSelectionPolyfill, a as SelectionController, C as ComponentValueHistoryControllerSlimmer } from './component-value-history-controller-slimmer.abstract-2bb8533d.js';
14
15
  import { C as ChangeManager } from './change-manager-6a7eb88c.js';
15
- import { u as VegaInternalCodeBlockSelectionChange } from './vega-internal-event-id-4a06d705.js';
16
+ import { u as VegaInternalCodeBlockSelectionChange } from './vega-internal-event-id-799d012e.js';
16
17
  import { d as debounce } from './timer-9321173b.js';
17
- import { C as ChildNodesEventPreventSlimmer } from './child-nodes-event-prevent-slimmer-e662bee2.js';
18
- import { c as createCommonjsModule, a as commonjsGlobal } from './_commonjsHelpers-9943807e.js';
19
- import { C as ComponentGlobalStyleSlimmer } from './component-global-style-slimmer-08046b38.js';
20
- import './create-public-api-runtime-metrics-slimmer-bedf3a1e.js';
18
+ import { C as ChildNodesEventPreventSlimmer } from './child-nodes-event-prevent-slimmer-649b9d30.js';
19
+ import { C as ComponentGlobalStyleSlimmer } from './component-global-style-slimmer-ac703085.js';
20
+ import './icon-manager-539d7cf7.js';
21
+ import './create-public-api-runtime-metrics-slimmer-aaadaa08.js';
21
22
  import './dynamic-slimmer-90b8af32.js';
23
+ import './misc-9fdbcfbb.js';
22
24
  import './observer-3959f9dd.js';
23
25
  import './string-a953eafc.js';
24
- import './type-guard-c65a227d.js';
26
+ import './type-guard-f50e34d6.js';
25
27
  import './breakpoints-d9faf11c.js';
26
28
  import './ui-28fd4193.js';
27
29
  import './typography-396de03f.js';
28
- import './translation-96e5debd.js';
30
+ import './internal-translation-controller-911515f9.js';
29
31
  import './static-subject-title-52f93124.js';
30
- import './dark-mode-style-controller-de88a117.js';
32
+ import './dark-mode-style-controller-82e5c1c6.js';
31
33
  import './vega-nonce-manager-497e5eb5.js';
32
34
  import './try-get-document-bef0f526.js';
33
- import './internal-vega-event-manager-efb6786e.js';
34
- import './range-5257c062.js';
35
+ import './index-3b327f29.js';
36
+ import './internal-vega-event-manager-32a3d848.js';
37
+ import './range-663f44dc.js';
35
38
  import './synchronize-task-queue-ac8acc3b.js';
36
- import './keyboard-manager-slimmer-79c78ce8.js';
37
- import './keyboard-manager-c92808d8.js';
39
+ import './keyboard-manager-slimmer-9984d922.js';
40
+ import './keyboard-manager-38934f94.js';
38
41
  import './vega-env-manager-8f8dc473.js';
39
- import './feature-flag-controller-51659753.js';
40
- import './index-e9da316f.js';
42
+ import './feature-flag-controller-09ea7e87.js';
43
+ import './index-bfc6dfa2.js';
41
44
 
42
45
  var __decorate$c = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
43
46
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -998,2712 +1001,658 @@ __decorate$5([
998
1001
  MapToComponentField()
999
1002
  ], VegaCodeBlockCopyButtonRenderer.prototype, "translationSlimmer", void 0);
1000
1003
 
1001
- var prism = createCommonjsModule(function (module) {
1002
- /* **********************************************
1003
- Begin prism-core.js
1004
- ********************************************** */
1005
-
1006
- /// <reference lib="WebWorker"/>
1007
-
1008
- var _self = (typeof window !== 'undefined')
1009
- ? window // if in browser
1010
- : (
1011
- (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
1012
- ? self // if in worker
1013
- : {} // if in node js
1014
- );
1015
-
1016
1004
  /**
1017
- * Prism: Lightweight, robust, elegant syntax highlighting
1005
+ * Unique placeholder used to mark greedy-matched regions so they are not
1006
+ * re-tokenized by later grammar rules. The surrounding curly-brace pairs
1007
+ * make an accidental collision with real source code extremely unlikely.
1008
+ */
1009
+ const GREEDY_PLACEHOLDER = '\x00GREEDY_PLACEHOLDER\x00';
1010
+ /**
1011
+ * Core tokenizer that converts source code into syntax tokens based on a grammar definition.
1012
+ * This is a local replacement for Prism tokenize.
1013
+ *
1014
+ * The tokenizer works by:
1015
+ * 1. Pre-processing greedy patterns to claim their matched regions first
1016
+ * 2. Iterating through all grammar rules in order
1017
+ * 3. Finding regex matches in the source text
1018
+ * 4. Splitting the text into matched (typed) and unmatched (plain) segments
1019
+ * 5. Recursively tokenizing nested content when an `inside` grammar is specified
1018
1020
  *
1019
- * @license MIT <https://opensource.org/licenses/MIT>
1020
- * @author Lea Verou <https://lea.verou.me>
1021
- * @namespace
1022
- * @public
1021
+ * @param {string} code - The source code string to tokenize.
1022
+ * @param {Grammar} grammar - The grammar rules to apply for tokenization.
1023
+ * @returns {(string | SyntaxToken)[]} An array of plain strings and syntax tokens.
1023
1024
  */
1024
- var Prism = (function (_self) {
1025
-
1026
- // Private helper vars
1027
- var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i;
1028
- var uniqueId = 0;
1029
-
1030
- // The grammar object for plaintext
1031
- var plainTextGrammar = {};
1032
-
1033
-
1034
- var _ = {
1035
- /**
1036
- * By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
1037
- * current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
1038
- * additional languages or plugins yourself.
1039
- *
1040
- * By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
1041
- *
1042
- * You obviously have to change this value before the automatic highlighting started. To do this, you can add an
1043
- * empty Prism object into the global scope before loading the Prism script like this:
1044
- *
1045
- * ```js
1046
- * window.Prism = window.Prism || {};
1047
- * Prism.manual = true;
1048
- * // add a new <script> to load Prism's script
1049
- * ```
1050
- *
1051
- * @default false
1052
- * @type {boolean}
1053
- * @memberof Prism
1054
- * @public
1055
- */
1056
- manual: _self.Prism && _self.Prism.manual,
1057
- /**
1058
- * By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
1059
- * `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your
1060
- * own worker, you don't want it to do this.
1061
- *
1062
- * By setting this value to `true`, Prism will not add its own listeners to the worker.
1063
- *
1064
- * You obviously have to change this value before Prism executes. To do this, you can add an
1065
- * empty Prism object into the global scope before loading the Prism script like this:
1066
- *
1067
- * ```js
1068
- * window.Prism = window.Prism || {};
1069
- * Prism.disableWorkerMessageHandler = true;
1070
- * // Load Prism's script
1071
- * ```
1072
- *
1073
- * @default false
1074
- * @type {boolean}
1075
- * @memberof Prism
1076
- * @public
1077
- */
1078
- disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
1079
-
1080
- /**
1081
- * A namespace for utility methods.
1082
- *
1083
- * All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
1084
- * change or disappear at any time.
1085
- *
1086
- * @namespace
1087
- * @memberof Prism
1088
- */
1089
- util: {
1090
- encode: function encode(tokens) {
1091
- if (tokens instanceof Token) {
1092
- return new Token(tokens.type, encode(tokens.content), tokens.alias);
1093
- } else if (Array.isArray(tokens)) {
1094
- return tokens.map(encode);
1095
- } else {
1096
- return tokens.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\u00a0/g, ' ');
1097
- }
1098
- },
1099
-
1100
- /**
1101
- * Returns the name of the type of the given value.
1102
- *
1103
- * @param {any} o
1104
- * @returns {string}
1105
- * @example
1106
- * type(null) === 'Null'
1107
- * type(undefined) === 'Undefined'
1108
- * type(123) === 'Number'
1109
- * type('foo') === 'String'
1110
- * type(true) === 'Boolean'
1111
- * type([1, 2]) === 'Array'
1112
- * type({}) === 'Object'
1113
- * type(String) === 'Function'
1114
- * type(/abc+/) === 'RegExp'
1115
- */
1116
- type: function (o) {
1117
- return Object.prototype.toString.call(o).slice(8, -1);
1118
- },
1119
-
1120
- /**
1121
- * Returns a unique number for the given object. Later calls will still return the same number.
1122
- *
1123
- * @param {Object} obj
1124
- * @returns {number}
1125
- */
1126
- objId: function (obj) {
1127
- if (!obj['__id']) {
1128
- Object.defineProperty(obj, '__id', { value: ++uniqueId });
1129
- }
1130
- return obj['__id'];
1131
- },
1132
-
1133
- /**
1134
- * Creates a deep clone of the given object.
1135
- *
1136
- * The main intended use of this function is to clone language definitions.
1137
- *
1138
- * @param {T} o
1139
- * @param {Record<number, any>} [visited]
1140
- * @returns {T}
1141
- * @template T
1142
- */
1143
- clone: function deepClone(o, visited) {
1144
- visited = visited || {};
1145
-
1146
- var clone; var id;
1147
- switch (_.util.type(o)) {
1148
- case 'Object':
1149
- id = _.util.objId(o);
1150
- if (visited[id]) {
1151
- return visited[id];
1152
- }
1153
- clone = /** @type {Record<string, any>} */ ({});
1154
- visited[id] = clone;
1155
-
1156
- for (var key in o) {
1157
- if (o.hasOwnProperty(key)) {
1158
- clone[key] = deepClone(o[key], visited);
1159
- }
1160
- }
1161
-
1162
- return /** @type {any} */ (clone);
1163
-
1164
- case 'Array':
1165
- id = _.util.objId(o);
1166
- if (visited[id]) {
1167
- return visited[id];
1168
- }
1169
- clone = [];
1170
- visited[id] = clone;
1171
-
1172
- (/** @type {Array} */(/** @type {any} */(o))).forEach(function (v, i) {
1173
- clone[i] = deepClone(v, visited);
1174
- });
1175
-
1176
- return /** @type {any} */ (clone);
1177
-
1178
- default:
1179
- return o;
1180
- }
1181
- },
1182
-
1183
- /**
1184
- * Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
1185
- *
1186
- * If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
1187
- *
1188
- * @param {Element} element
1189
- * @returns {string}
1190
- */
1191
- getLanguage: function (element) {
1192
- while (element) {
1193
- var m = lang.exec(element.className);
1194
- if (m) {
1195
- return m[1].toLowerCase();
1196
- }
1197
- element = element.parentElement;
1198
- }
1199
- return 'none';
1200
- },
1201
-
1202
- /**
1203
- * Sets the Prism `language-xxxx` class of the given element.
1204
- *
1205
- * @param {Element} element
1206
- * @param {string} language
1207
- * @returns {void}
1208
- */
1209
- setLanguage: function (element, language) {
1210
- // remove all `language-xxxx` classes
1211
- // (this might leave behind a leading space)
1212
- element.className = element.className.replace(RegExp(lang, 'gi'), '');
1213
-
1214
- // add the new `language-xxxx` class
1215
- // (using `classList` will automatically clean up spaces for us)
1216
- element.classList.add('language-' + language);
1217
- },
1218
-
1219
- /**
1220
- * Returns the script element that is currently executing.
1221
- *
1222
- * This does __not__ work for line script element.
1223
- *
1224
- * @returns {HTMLScriptElement | null}
1225
- */
1226
- currentScript: function () {
1227
- if (typeof document === 'undefined') {
1228
- return null;
1229
- }
1230
- if (document.currentScript && document.currentScript.tagName === 'SCRIPT' && 1 < 2 /* hack to trip TS' flow analysis */) {
1231
- return /** @type {any} */ (document.currentScript);
1232
- }
1233
-
1234
- // IE11 workaround
1235
- // we'll get the src of the current script by parsing IE11's error stack trace
1236
- // this will not work for inline scripts
1237
-
1238
- try {
1239
- throw new Error();
1240
- } catch (err) {
1241
- // Get file src url from stack. Specifically works with the format of stack traces in IE.
1242
- // A stack will look like this:
1243
- //
1244
- // Error
1245
- // at _.util.currentScript (http://localhost/components/prism-core.js:119:5)
1246
- // at Global code (http://localhost/components/prism-core.js:606:1)
1247
-
1248
- var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) || [])[1];
1249
- if (src) {
1250
- var scripts = document.getElementsByTagName('script');
1251
- for (var i in scripts) {
1252
- if (scripts[i].src == src) {
1253
- return scripts[i];
1254
- }
1255
- }
1256
- }
1257
- return null;
1258
- }
1259
- },
1260
-
1261
- /**
1262
- * Returns whether a given class is active for `element`.
1263
- *
1264
- * The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated
1265
- * if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the
1266
- * given class is just the given class with a `no-` prefix.
1267
- *
1268
- * Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is
1269
- * closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its
1270
- * ancestors have the given class or the negated version of it, then the default activation will be returned.
1271
- *
1272
- * In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated
1273
- * version of it, the class is considered active.
1274
- *
1275
- * @param {Element} element
1276
- * @param {string} className
1277
- * @param {boolean} [defaultActivation=false]
1278
- * @returns {boolean}
1279
- */
1280
- isActive: function (element, className, defaultActivation) {
1281
- var no = 'no-' + className;
1282
-
1283
- while (element) {
1284
- var classList = element.classList;
1285
- if (classList.contains(className)) {
1286
- return true;
1287
- }
1288
- if (classList.contains(no)) {
1289
- return false;
1290
- }
1291
- element = element.parentElement;
1292
- }
1293
- return !!defaultActivation;
1294
- }
1295
- },
1296
-
1297
- /**
1298
- * This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
1299
- *
1300
- * @namespace
1301
- * @memberof Prism
1302
- * @public
1303
- */
1304
- languages: {
1305
- /**
1306
- * The grammar for plain, unformatted text.
1307
- */
1308
- plain: plainTextGrammar,
1309
- plaintext: plainTextGrammar,
1310
- text: plainTextGrammar,
1311
- txt: plainTextGrammar,
1312
-
1313
- /**
1314
- * Creates a deep copy of the language with the given id and appends the given tokens.
1315
- *
1316
- * If a token in `redef` also appears in the copied language, then the existing token in the copied language
1317
- * will be overwritten at its original position.
1318
- *
1319
- * ## Best practices
1320
- *
1321
- * Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
1322
- * doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
1323
- * understand the language definition because, normally, the order of tokens matters in Prism grammars.
1324
- *
1325
- * Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
1326
- * Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
1327
- *
1328
- * @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
1329
- * @param {Grammar} redef The new tokens to append.
1330
- * @returns {Grammar} The new language created.
1331
- * @public
1332
- * @example
1333
- * Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
1334
- * // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
1335
- * // at its original position
1336
- * 'comment': { ... },
1337
- * // CSS doesn't have a 'color' token, so this token will be appended
1338
- * 'color': /\b(?:red|green|blue)\b/
1339
- * });
1340
- */
1341
- extend: function (id, redef) {
1342
- var lang = _.util.clone(_.languages[id]);
1343
-
1344
- for (var key in redef) {
1345
- lang[key] = redef[key];
1346
- }
1347
-
1348
- return lang;
1349
- },
1350
-
1351
- /**
1352
- * Inserts tokens _before_ another token in a language definition or any other grammar.
1353
- *
1354
- * ## Usage
1355
- *
1356
- * This helper method makes it easy to modify existing languages. For example, the CSS language definition
1357
- * not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
1358
- * in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
1359
- * appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
1360
- * this:
1361
- *
1362
- * ```js
1363
- * Prism.languages.markup.style = {
1364
- * // token
1365
- * };
1366
- * ```
1367
- *
1368
- * then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
1369
- * before existing tokens. For the CSS example above, you would use it like this:
1370
- *
1371
- * ```js
1372
- * Prism.languages.insertBefore('markup', 'cdata', {
1373
- * 'style': {
1374
- * // token
1375
- * }
1376
- * });
1377
- * ```
1378
- *
1379
- * ## Special cases
1380
- *
1381
- * If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
1382
- * will be ignored.
1383
- *
1384
- * This behavior can be used to insert tokens after `before`:
1385
- *
1386
- * ```js
1387
- * Prism.languages.insertBefore('markup', 'comment', {
1388
- * 'comment': Prism.languages.markup.comment,
1389
- * // tokens after 'comment'
1390
- * });
1391
- * ```
1392
- *
1393
- * ## Limitations
1394
- *
1395
- * The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
1396
- * properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
1397
- * differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
1398
- * deleting properties which is necessary to insert at arbitrary positions.
1399
- *
1400
- * To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
1401
- * Instead, it will create a new object and replace all references to the target object with the new one. This
1402
- * can be done without temporarily deleting properties, so the iteration order is well-defined.
1403
- *
1404
- * However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
1405
- * you hold the target object in a variable, then the value of the variable will not change.
1406
- *
1407
- * ```js
1408
- * var oldMarkup = Prism.languages.markup;
1409
- * var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
1410
- *
1411
- * assert(oldMarkup !== Prism.languages.markup);
1412
- * assert(newMarkup === Prism.languages.markup);
1413
- * ```
1414
- *
1415
- * @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
1416
- * object to be modified.
1417
- * @param {string} before The key to insert before.
1418
- * @param {Grammar} insert An object containing the key-value pairs to be inserted.
1419
- * @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
1420
- * object to be modified.
1421
- *
1422
- * Defaults to `Prism.languages`.
1423
- * @returns {Grammar} The new grammar object.
1424
- * @public
1425
- */
1426
- insertBefore: function (inside, before, insert, root) {
1427
- root = root || /** @type {any} */ (_.languages);
1428
- var grammar = root[inside];
1429
- /** @type {Grammar} */
1430
- var ret = {};
1431
-
1432
- for (var token in grammar) {
1433
- if (grammar.hasOwnProperty(token)) {
1434
-
1435
- if (token == before) {
1436
- for (var newToken in insert) {
1437
- if (insert.hasOwnProperty(newToken)) {
1438
- ret[newToken] = insert[newToken];
1439
- }
1440
- }
1441
- }
1442
-
1443
- // Do not insert token which also occur in insert. See #1525
1444
- if (!insert.hasOwnProperty(token)) {
1445
- ret[token] = grammar[token];
1446
- }
1447
- }
1448
- }
1449
-
1450
- var old = root[inside];
1451
- root[inside] = ret;
1452
-
1453
- // Update references in other language definitions
1454
- _.languages.DFS(_.languages, function (key, value) {
1455
- if (value === old && key != inside) {
1456
- this[key] = ret;
1457
- }
1458
- });
1459
-
1460
- return ret;
1461
- },
1462
-
1463
- // Traverse a language definition with Depth First Search
1464
- DFS: function DFS(o, callback, type, visited) {
1465
- visited = visited || {};
1466
-
1467
- var objId = _.util.objId;
1468
-
1469
- for (var i in o) {
1470
- if (o.hasOwnProperty(i)) {
1471
- callback.call(o, i, o[i], type || i);
1472
-
1473
- var property = o[i];
1474
- var propertyType = _.util.type(property);
1475
-
1476
- if (propertyType === 'Object' && !visited[objId(property)]) {
1477
- visited[objId(property)] = true;
1478
- DFS(property, callback, null, visited);
1479
- } else if (propertyType === 'Array' && !visited[objId(property)]) {
1480
- visited[objId(property)] = true;
1481
- DFS(property, callback, i, visited);
1482
- }
1483
- }
1484
- }
1485
- }
1486
- },
1487
-
1488
- plugins: {},
1489
-
1490
- /**
1491
- * This is the most high-level function in Prism’s API.
1492
- * It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
1493
- * each one of them.
1494
- *
1495
- * This is equivalent to `Prism.highlightAllUnder(document, async, callback)`.
1496
- *
1497
- * @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}.
1498
- * @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}.
1499
- * @memberof Prism
1500
- * @public
1501
- */
1502
- highlightAll: function (async, callback) {
1503
- _.highlightAllUnder(document, async, callback);
1504
- },
1505
-
1506
- /**
1507
- * Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
1508
- * {@link Prism.highlightElement} on each one of them.
1509
- *
1510
- * The following hooks will be run:
1511
- * 1. `before-highlightall`
1512
- * 2. `before-all-elements-highlight`
1513
- * 3. All hooks of {@link Prism.highlightElement} for each element.
1514
- *
1515
- * @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
1516
- * @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers.
1517
- * @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done.
1518
- * @memberof Prism
1519
- * @public
1520
- */
1521
- highlightAllUnder: function (container, async, callback) {
1522
- var env = {
1523
- callback: callback,
1524
- container: container,
1525
- selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
1526
- };
1527
-
1528
- _.hooks.run('before-highlightall', env);
1529
-
1530
- env.elements = Array.prototype.slice.apply(env.container.querySelectorAll(env.selector));
1531
-
1532
- _.hooks.run('before-all-elements-highlight', env);
1533
-
1534
- for (var i = 0, element; (element = env.elements[i++]);) {
1535
- _.highlightElement(element, async === true, env.callback);
1536
- }
1537
- },
1538
-
1539
- /**
1540
- * Highlights the code inside a single element.
1541
- *
1542
- * The following hooks will be run:
1543
- * 1. `before-sanity-check`
1544
- * 2. `before-highlight`
1545
- * 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`.
1546
- * 4. `before-insert`
1547
- * 5. `after-highlight`
1548
- * 6. `complete`
1549
- *
1550
- * Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for
1551
- * the element's language.
1552
- *
1553
- * @param {Element} element The element containing the code.
1554
- * It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.
1555
- * @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers
1556
- * to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is
1557
- * [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).
1558
- *
1559
- * Note: All language definitions required to highlight the code must be included in the main `prism.js` file for
1560
- * asynchronous highlighting to work. You can build your own bundle on the
1561
- * [Download page](https://prismjs.com/download.html).
1562
- * @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done.
1563
- * Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
1564
- * @memberof Prism
1565
- * @public
1566
- */
1567
- highlightElement: function (element, async, callback) {
1568
- // Find language
1569
- var language = _.util.getLanguage(element);
1570
- var grammar = _.languages[language];
1571
-
1572
- // Set language on the element, if not present
1573
- _.util.setLanguage(element, language);
1574
-
1575
- // Set language on the parent, for styling
1576
- var parent = element.parentElement;
1577
- if (parent && parent.nodeName.toLowerCase() === 'pre') {
1578
- _.util.setLanguage(parent, language);
1579
- }
1580
-
1581
- var code = element.textContent;
1582
-
1583
- var env = {
1584
- element: element,
1585
- language: language,
1586
- grammar: grammar,
1587
- code: code
1588
- };
1589
-
1590
- function insertHighlightedCode(highlightedCode) {
1591
- env.highlightedCode = highlightedCode;
1592
-
1593
- _.hooks.run('before-insert', env);
1594
-
1595
- env.element.innerHTML = env.highlightedCode;
1596
-
1597
- _.hooks.run('after-highlight', env);
1598
- _.hooks.run('complete', env);
1599
- callback && callback.call(env.element);
1600
- }
1601
-
1602
- _.hooks.run('before-sanity-check', env);
1603
-
1604
- // plugins may change/add the parent/element
1605
- parent = env.element.parentElement;
1606
- if (parent && parent.nodeName.toLowerCase() === 'pre' && !parent.hasAttribute('tabindex')) {
1607
- parent.setAttribute('tabindex', '0');
1608
- }
1609
-
1610
- if (!env.code) {
1611
- _.hooks.run('complete', env);
1612
- callback && callback.call(env.element);
1613
- return;
1614
- }
1615
-
1616
- _.hooks.run('before-highlight', env);
1617
-
1618
- if (!env.grammar) {
1619
- insertHighlightedCode(_.util.encode(env.code));
1620
- return;
1621
- }
1622
-
1623
- if (async && _self.Worker) {
1624
- var worker = new Worker(_.filename);
1625
-
1626
- worker.onmessage = function (evt) {
1627
- insertHighlightedCode(evt.data);
1628
- };
1629
-
1630
- worker.postMessage(JSON.stringify({
1631
- language: env.language,
1632
- code: env.code,
1633
- immediateClose: true
1634
- }));
1635
- } else {
1636
- insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
1637
- }
1638
- },
1639
-
1640
- /**
1641
- * Low-level function, only use if you know what you’re doing. It accepts a string of text as input
1642
- * and the language definitions to use, and returns a string with the HTML produced.
1643
- *
1644
- * The following hooks will be run:
1645
- * 1. `before-tokenize`
1646
- * 2. `after-tokenize`
1647
- * 3. `wrap`: On each {@link Token}.
1648
- *
1649
- * @param {string} text A string with the code to be highlighted.
1650
- * @param {Grammar} grammar An object containing the tokens to use.
1651
- *
1652
- * Usually a language definition like `Prism.languages.markup`.
1653
- * @param {string} language The name of the language definition passed to `grammar`.
1654
- * @returns {string} The highlighted HTML.
1655
- * @memberof Prism
1656
- * @public
1657
- * @example
1658
- * Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
1659
- */
1660
- highlight: function (text, grammar, language) {
1661
- var env = {
1662
- code: text,
1663
- grammar: grammar,
1664
- language: language
1665
- };
1666
- _.hooks.run('before-tokenize', env);
1667
- if (!env.grammar) {
1668
- throw new Error('The language "' + env.language + '" has no grammar.');
1669
- }
1670
- env.tokens = _.tokenize(env.code, env.grammar);
1671
- _.hooks.run('after-tokenize', env);
1672
- return Token.stringify(_.util.encode(env.tokens), env.language);
1673
- },
1674
-
1675
- /**
1676
- * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
1677
- * and the language definitions to use, and returns an array with the tokenized code.
1678
- *
1679
- * When the language definition includes nested tokens, the function is called recursively on each of these tokens.
1680
- *
1681
- * This method could be useful in other contexts as well, as a very crude parser.
1682
- *
1683
- * @param {string} text A string with the code to be highlighted.
1684
- * @param {Grammar} grammar An object containing the tokens to use.
1685
- *
1686
- * Usually a language definition like `Prism.languages.markup`.
1687
- * @returns {TokenStream} An array of strings and tokens, a token stream.
1688
- * @memberof Prism
1689
- * @public
1690
- * @example
1691
- * let code = `var foo = 0;`;
1692
- * let tokens = Prism.tokenize(code, Prism.languages.javascript);
1693
- * tokens.forEach(token => {
1694
- * if (token instanceof Prism.Token && token.type === 'number') {
1695
- * console.log(`Found numeric literal: ${token.content}`);
1696
- * }
1697
- * });
1698
- */
1699
- tokenize: function (text, grammar) {
1700
- var rest = grammar.rest;
1701
- if (rest) {
1702
- for (var token in rest) {
1703
- grammar[token] = rest[token];
1704
- }
1705
-
1706
- delete grammar.rest;
1707
- }
1708
-
1709
- var tokenList = new LinkedList();
1710
- addAfter(tokenList, tokenList.head, text);
1711
-
1712
- matchGrammar(text, tokenList, grammar, tokenList.head, 0);
1713
-
1714
- return toArray(tokenList);
1715
- },
1716
-
1717
- /**
1718
- * @namespace
1719
- * @memberof Prism
1720
- * @public
1721
- */
1722
- hooks: {
1723
- all: {},
1724
-
1725
- /**
1726
- * Adds the given callback to the list of callbacks for the given hook.
1727
- *
1728
- * The callback will be invoked when the hook it is registered for is run.
1729
- * Hooks are usually directly run by a highlight function but you can also run hooks yourself.
1730
- *
1731
- * One callback function can be registered to multiple hooks and the same hook multiple times.
1732
- *
1733
- * @param {string} name The name of the hook.
1734
- * @param {HookCallback} callback The callback function which is given environment variables.
1735
- * @public
1736
- */
1737
- add: function (name, callback) {
1738
- var hooks = _.hooks.all;
1739
-
1740
- hooks[name] = hooks[name] || [];
1741
-
1742
- hooks[name].push(callback);
1743
- },
1744
-
1745
- /**
1746
- * Runs a hook invoking all registered callbacks with the given environment variables.
1747
- *
1748
- * Callbacks will be invoked synchronously and in the order in which they were registered.
1749
- *
1750
- * @param {string} name The name of the hook.
1751
- * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
1752
- * @public
1753
- */
1754
- run: function (name, env) {
1755
- var callbacks = _.hooks.all[name];
1756
-
1757
- if (!callbacks || !callbacks.length) {
1758
- return;
1759
- }
1760
-
1761
- for (var i = 0, callback; (callback = callbacks[i++]);) {
1762
- callback(env);
1763
- }
1764
- }
1765
- },
1766
-
1767
- Token: Token
1768
- };
1769
- _self.Prism = _;
1770
-
1771
-
1772
- // Typescript note:
1773
- // The following can be used to import the Token type in JSDoc:
1774
- //
1775
- // @typedef {InstanceType<import("./prism-core")["Token"]>} Token
1776
-
1777
- /**
1778
- * Creates a new token.
1779
- *
1780
- * @param {string} type See {@link Token#type type}
1781
- * @param {string | TokenStream} content See {@link Token#content content}
1782
- * @param {string|string[]} [alias] The alias(es) of the token.
1783
- * @param {string} [matchedStr=""] A copy of the full string this token was created from.
1784
- * @class
1785
- * @global
1786
- * @public
1787
- */
1788
- function Token(type, content, alias, matchedStr) {
1789
- /**
1790
- * The type of the token.
1791
- *
1792
- * This is usually the key of a pattern in a {@link Grammar}.
1793
- *
1794
- * @type {string}
1795
- * @see GrammarToken
1796
- * @public
1797
- */
1798
- this.type = type;
1799
- /**
1800
- * The strings or tokens contained by this token.
1801
- *
1802
- * This will be a token stream if the pattern matched also defined an `inside` grammar.
1803
- *
1804
- * @type {string | TokenStream}
1805
- * @public
1806
- */
1807
- this.content = content;
1808
- /**
1809
- * The alias(es) of the token.
1810
- *
1811
- * @type {string|string[]}
1812
- * @see GrammarToken
1813
- * @public
1814
- */
1815
- this.alias = alias;
1816
- // Copy of the full string this token was created from
1817
- this.length = (matchedStr || '').length | 0;
1818
- }
1819
-
1820
- /**
1821
- * A token stream is an array of strings and {@link Token Token} objects.
1822
- *
1823
- * Token streams have to fulfill a few properties that are assumed by most functions (mostly internal ones) that process
1824
- * them.
1825
- *
1826
- * 1. No adjacent strings.
1827
- * 2. No empty strings.
1828
- *
1829
- * The only exception here is the token stream that only contains the empty string and nothing else.
1830
- *
1831
- * @typedef {Array<string | Token>} TokenStream
1832
- * @global
1833
- * @public
1834
- */
1835
-
1836
- /**
1837
- * Converts the given token or token stream to an HTML representation.
1838
- *
1839
- * The following hooks will be run:
1840
- * 1. `wrap`: On each {@link Token}.
1841
- *
1842
- * @param {string | Token | TokenStream} o The token or token stream to be converted.
1843
- * @param {string} language The name of current language.
1844
- * @returns {string} The HTML representation of the token or token stream.
1845
- * @memberof Token
1846
- * @static
1847
- */
1848
- Token.stringify = function stringify(o, language) {
1849
- if (typeof o == 'string') {
1850
- return o;
1851
- }
1852
- if (Array.isArray(o)) {
1853
- var s = '';
1854
- o.forEach(function (e) {
1855
- s += stringify(e, language);
1856
- });
1857
- return s;
1858
- }
1859
-
1860
- var env = {
1861
- type: o.type,
1862
- content: stringify(o.content, language),
1863
- tag: 'span',
1864
- classes: ['token', o.type],
1865
- attributes: {},
1866
- language: language
1867
- };
1868
-
1869
- var aliases = o.alias;
1870
- if (aliases) {
1871
- if (Array.isArray(aliases)) {
1872
- Array.prototype.push.apply(env.classes, aliases);
1873
- } else {
1874
- env.classes.push(aliases);
1875
- }
1876
- }
1877
-
1878
- _.hooks.run('wrap', env);
1879
-
1880
- var attributes = '';
1881
- for (var name in env.attributes) {
1882
- attributes += ' ' + name + '="' + (env.attributes[name] || '').replace(/"/g, '&quot;') + '"';
1883
- }
1884
-
1885
- return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + attributes + '>' + env.content + '</' + env.tag + '>';
1886
- };
1887
-
1888
- /**
1889
- * @param {RegExp} pattern
1890
- * @param {number} pos
1891
- * @param {string} text
1892
- * @param {boolean} lookbehind
1893
- * @returns {RegExpExecArray | null}
1894
- */
1895
- function matchPattern(pattern, pos, text, lookbehind) {
1896
- pattern.lastIndex = pos;
1897
- var match = pattern.exec(text);
1898
- if (match && lookbehind && match[1]) {
1899
- // change the match to remove the text matched by the Prism lookbehind group
1900
- var lookbehindLength = match[1].length;
1901
- match.index += lookbehindLength;
1902
- match[0] = match[0].slice(lookbehindLength);
1903
- }
1904
- return match;
1905
- }
1906
-
1907
- /**
1908
- * @param {string} text
1909
- * @param {LinkedList<string | Token>} tokenList
1910
- * @param {any} grammar
1911
- * @param {LinkedListNode<string | Token>} startNode
1912
- * @param {number} startPos
1913
- * @param {RematchOptions} [rematch]
1914
- * @returns {void}
1915
- * @private
1916
- *
1917
- * @typedef RematchOptions
1918
- * @property {string} cause
1919
- * @property {number} reach
1920
- */
1921
- function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
1922
- for (var token in grammar) {
1923
- if (!grammar.hasOwnProperty(token) || !grammar[token]) {
1924
- continue;
1925
- }
1926
-
1927
- var patterns = grammar[token];
1928
- patterns = Array.isArray(patterns) ? patterns : [patterns];
1929
-
1930
- for (var j = 0; j < patterns.length; ++j) {
1931
- if (rematch && rematch.cause == token + ',' + j) {
1932
- return;
1933
- }
1934
-
1935
- var patternObj = patterns[j];
1936
- var inside = patternObj.inside;
1937
- var lookbehind = !!patternObj.lookbehind;
1938
- var greedy = !!patternObj.greedy;
1939
- var alias = patternObj.alias;
1940
-
1941
- if (greedy && !patternObj.pattern.global) {
1942
- // Without the global flag, lastIndex won't work
1943
- var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
1944
- patternObj.pattern = RegExp(patternObj.pattern.source, flags + 'g');
1945
- }
1946
-
1947
- /** @type {RegExp} */
1948
- var pattern = patternObj.pattern || patternObj;
1949
-
1950
- for ( // iterate the token list and keep track of the current token/string position
1951
- var currentNode = startNode.next, pos = startPos;
1952
- currentNode !== tokenList.tail;
1953
- pos += currentNode.value.length, currentNode = currentNode.next
1954
- ) {
1955
-
1956
- if (rematch && pos >= rematch.reach) {
1957
- break;
1958
- }
1959
-
1960
- var str = currentNode.value;
1961
-
1962
- if (tokenList.length > text.length) {
1963
- // Something went terribly wrong, ABORT, ABORT!
1964
- return;
1965
- }
1966
-
1967
- if (str instanceof Token) {
1968
- continue;
1969
- }
1970
-
1971
- var removeCount = 1; // this is the to parameter of removeBetween
1972
- var match;
1973
-
1974
- if (greedy) {
1975
- match = matchPattern(pattern, pos, text, lookbehind);
1976
- if (!match || match.index >= text.length) {
1977
- break;
1978
- }
1979
-
1980
- var from = match.index;
1981
- var to = match.index + match[0].length;
1982
- var p = pos;
1983
-
1984
- // find the node that contains the match
1985
- p += currentNode.value.length;
1986
- while (from >= p) {
1987
- currentNode = currentNode.next;
1988
- p += currentNode.value.length;
1989
- }
1990
- // adjust pos (and p)
1991
- p -= currentNode.value.length;
1992
- pos = p;
1993
-
1994
- // the current node is a Token, then the match starts inside another Token, which is invalid
1995
- if (currentNode.value instanceof Token) {
1996
- continue;
1997
- }
1998
-
1999
- // find the last node which is affected by this match
2000
- for (
2001
- var k = currentNode;
2002
- k !== tokenList.tail && (p < to || typeof k.value === 'string');
2003
- k = k.next
2004
- ) {
2005
- removeCount++;
2006
- p += k.value.length;
2007
- }
2008
- removeCount--;
2009
-
2010
- // replace with the new match
2011
- str = text.slice(pos, p);
2012
- match.index -= pos;
2013
- } else {
2014
- match = matchPattern(pattern, 0, str, lookbehind);
2015
- if (!match) {
2016
- continue;
2017
- }
2018
- }
2019
-
2020
- // eslint-disable-next-line no-redeclare
2021
- var from = match.index;
2022
- var matchStr = match[0];
2023
- var before = str.slice(0, from);
2024
- var after = str.slice(from + matchStr.length);
2025
-
2026
- var reach = pos + str.length;
2027
- if (rematch && reach > rematch.reach) {
2028
- rematch.reach = reach;
2029
- }
2030
-
2031
- var removeFrom = currentNode.prev;
2032
-
2033
- if (before) {
2034
- removeFrom = addAfter(tokenList, removeFrom, before);
2035
- pos += before.length;
2036
- }
2037
-
2038
- removeRange(tokenList, removeFrom, removeCount);
2039
-
2040
- var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr);
2041
- currentNode = addAfter(tokenList, removeFrom, wrapped);
2042
-
2043
- if (after) {
2044
- addAfter(tokenList, currentNode, after);
2045
- }
2046
-
2047
- if (removeCount > 1) {
2048
- // at least one Token object was removed, so we have to do some rematching
2049
- // this can only happen if the current pattern is greedy
2050
-
2051
- /** @type {RematchOptions} */
2052
- var nestedRematch = {
2053
- cause: token + ',' + j,
2054
- reach: reach
2055
- };
2056
- matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch);
2057
-
2058
- // the reach might have been extended because of the rematching
2059
- if (rematch && nestedRematch.reach > rematch.reach) {
2060
- rematch.reach = nestedRematch.reach;
2061
- }
2062
- }
2063
- }
2064
- }
2065
- }
2066
- }
2067
-
2068
- /**
2069
- * @typedef LinkedListNode
2070
- * @property {T} value
2071
- * @property {LinkedListNode<T> | null} prev The previous node.
2072
- * @property {LinkedListNode<T> | null} next The next node.
2073
- * @template T
2074
- * @private
2075
- */
2076
-
2077
- /**
2078
- * @template T
2079
- * @private
2080
- */
2081
- function LinkedList() {
2082
- /** @type {LinkedListNode<T>} */
2083
- var head = { value: null, prev: null, next: null };
2084
- /** @type {LinkedListNode<T>} */
2085
- var tail = { value: null, prev: head, next: null };
2086
- head.next = tail;
2087
-
2088
- /** @type {LinkedListNode<T>} */
2089
- this.head = head;
2090
- /** @type {LinkedListNode<T>} */
2091
- this.tail = tail;
2092
- this.length = 0;
2093
- }
2094
-
2095
- /**
2096
- * Adds a new node with the given value to the list.
2097
- *
2098
- * @param {LinkedList<T>} list
2099
- * @param {LinkedListNode<T>} node
2100
- * @param {T} value
2101
- * @returns {LinkedListNode<T>} The added node.
2102
- * @template T
2103
- */
2104
- function addAfter(list, node, value) {
2105
- // assumes that node != list.tail && values.length >= 0
2106
- var next = node.next;
2107
-
2108
- var newNode = { value: value, prev: node, next: next };
2109
- node.next = newNode;
2110
- next.prev = newNode;
2111
- list.length++;
2112
-
2113
- return newNode;
2114
- }
2115
- /**
2116
- * Removes `count` nodes after the given node. The given node will not be removed.
2117
- *
2118
- * @param {LinkedList<T>} list
2119
- * @param {LinkedListNode<T>} node
2120
- * @param {number} count
2121
- * @template T
2122
- */
2123
- function removeRange(list, node, count) {
2124
- var next = node.next;
2125
- for (var i = 0; i < count && next !== list.tail; i++) {
2126
- next = next.next;
2127
- }
2128
- node.next = next;
2129
- next.prev = node;
2130
- list.length -= i;
2131
- }
2132
- /**
2133
- * @param {LinkedList<T>} list
2134
- * @returns {T[]}
2135
- * @template T
2136
- */
2137
- function toArray(list) {
2138
- var array = [];
2139
- var node = list.head.next;
2140
- while (node !== list.tail) {
2141
- array.push(node.value);
2142
- node = node.next;
2143
- }
2144
- return array;
2145
- }
2146
-
2147
-
2148
- if (!_self.document) {
2149
- if (!_self.addEventListener) {
2150
- // in Node.js
2151
- return _;
2152
- }
2153
-
2154
- if (!_.disableWorkerMessageHandler) {
2155
- // In worker
2156
- _self.addEventListener('message', function (evt) {
2157
- var message = JSON.parse(evt.data);
2158
- var lang = message.language;
2159
- var code = message.code;
2160
- var immediateClose = message.immediateClose;
2161
-
2162
- _self.postMessage(_.highlight(code, _.languages[lang], lang));
2163
- if (immediateClose) {
2164
- _self.close();
2165
- }
2166
- }, false);
2167
- }
2168
-
2169
- return _;
2170
- }
2171
-
2172
- // Get current script and highlight
2173
- var script = _.util.currentScript();
2174
-
2175
- if (script) {
2176
- _.filename = script.src;
2177
-
2178
- if (script.hasAttribute('data-manual')) {
2179
- _.manual = true;
2180
- }
2181
- }
2182
-
2183
- function highlightAutomaticallyCallback() {
2184
- if (!_.manual) {
2185
- _.highlightAll();
2186
- }
2187
- }
2188
-
2189
- if (!_.manual) {
2190
- // If the document state is "loading", then we'll use DOMContentLoaded.
2191
- // If the document state is "interactive" and the prism.js script is deferred, then we'll also use the
2192
- // DOMContentLoaded event because there might be some plugins or languages which have also been deferred and they
2193
- // might take longer one animation frame to execute which can create a race condition where only some plugins have
2194
- // been loaded when Prism.highlightAll() is executed, depending on how fast resources are loaded.
2195
- // See https://github.com/PrismJS/prism/issues/2102
2196
- var readyState = document.readyState;
2197
- if (readyState === 'loading' || readyState === 'interactive' && script && script.defer) {
2198
- document.addEventListener('DOMContentLoaded', highlightAutomaticallyCallback);
2199
- } else {
2200
- if (window.requestAnimationFrame) {
2201
- window.requestAnimationFrame(highlightAutomaticallyCallback);
2202
- } else {
2203
- window.setTimeout(highlightAutomaticallyCallback, 16);
2204
- }
2205
- }
2206
- }
2207
-
2208
- return _;
2209
-
2210
- }(_self));
2211
-
2212
- if (module.exports) {
2213
- module.exports = Prism;
2214
- }
2215
-
2216
- // hack for components to work correctly in node.js
2217
- if (typeof commonjsGlobal !== 'undefined') {
2218
- commonjsGlobal.Prism = Prism;
1025
+ function tokenize(code, grammar) {
1026
+ if (!code || !grammar) {
1027
+ return [code];
1028
+ }
1029
+ const tokens = [code];
1030
+ matchGrammar(tokens, grammar);
1031
+ return tokens;
2219
1032
  }
2220
-
2221
- // some additional documentation/types
2222
-
2223
1033
  /**
2224
- * The expansion of a simple `RegExp` literal to support additional properties.
1034
+ * Apply grammar rules to tokenize string entries in the token list.
1035
+ * Greedy patterns are applied first: their matched regions are replaced with
1036
+ * opaque placeholder tokens so that subsequent (non-greedy) rules cannot
1037
+ * match inside those regions. After all rules have run the placeholders are
1038
+ * restored to the original matched text.
2225
1039
  *
2226
- * @typedef GrammarToken
2227
- * @property {RegExp} pattern The regular expression of the token.
2228
- * @property {boolean} [lookbehind=false] If `true`, then the first capturing group of `pattern` will (effectively)
2229
- * behave as a lookbehind group meaning that the captured text will not be part of the matched text of the new token.
2230
- * @property {boolean} [greedy=false] Whether the token is greedy.
2231
- * @property {string|string[]} [alias] An optional alias or list of aliases.
2232
- * @property {Grammar} [inside] The nested grammar of this token.
1040
+ * @param {(string | SyntaxToken)[]} tokens - The current token list to process in-place.
1041
+ * @param {Grammar} grammar - The grammar rules to apply.
1042
+ */
1043
+ function matchGrammar(tokens, grammar) {
1044
+ const greedyEntries = [];
1045
+ const nonGreedyEntries = [];
1046
+ for (const tokenType of Object.keys(grammar)) {
1047
+ const grammarEntry = grammar[tokenType];
1048
+ const patterns = Array.isArray(grammarEntry) ? grammarEntry : [grammarEntry];
1049
+ for (const patternDef of patterns) {
1050
+ if (patternDef.greedy) {
1051
+ greedyEntries.push({ tokenType, patternDef });
1052
+ }
1053
+ else {
1054
+ nonGreedyEntries.push({ tokenType, patternDef });
1055
+ }
1056
+ }
1057
+ }
1058
+ // --- Phase 1: Apply greedy patterns first --------------------------------
1059
+ // Greedy patterns claim regions of the source text exclusively.
1060
+ // We replace matched regions with a placeholder string of equal length so
1061
+ // that character offsets remain stable. Each greedy match is recorded so
1062
+ // we can later restore the original text inside the token.
1063
+ if (greedyEntries.length > 0) {
1064
+ applyGreedyPatterns(tokens, greedyEntries);
1065
+ }
1066
+ // --- Phase 2: Apply remaining non-greedy patterns ------------------------
1067
+ for (const { tokenType, patternDef } of nonGreedyEntries) {
1068
+ applyPattern(tokens, tokenType, patternDef);
1069
+ }
1070
+ }
1071
+ /**
1072
+ * Process all greedy patterns against the current token list.
2233
1073
  *
2234
- * The `inside` grammar will be used to tokenize the text value of each token of this kind.
1074
+ * For every plain-string entry in the list the function builds a *mask* string
1075
+ * of the same length. Greedy matches are recorded and their corresponding
1076
+ * character ranges in the mask are overwritten with a placeholder character so
1077
+ * that later greedy patterns (and all non-greedy patterns) will never match
1078
+ * inside an already-claimed region.
2235
1079
  *
2236
- * This can be used to make nested and even recursive language definitions.
1080
+ * After all greedy patterns have been collected the affected string entries are
1081
+ * rebuilt by splicing in SyntaxToken objects for each greedy match.
2237
1082
  *
2238
- * Note: This can cause infinite recursion. Be careful when you embed different languages or even the same language into
2239
- * each another.
2240
- * @global
2241
- * @public
1083
+ * @param {(string | SyntaxToken)[]} tokens - The token list to process in-place.
1084
+ * @param {{ tokenType: string; patternDef: GrammarPattern }[]} greedyEntries - Greedy patterns to apply.
2242
1085
  */
2243
-
1086
+ function applyGreedyPatterns(tokens, greedyEntries) {
1087
+ for (let i = 0; i < tokens.length; i++) {
1088
+ const token = tokens[i];
1089
+ /* istanbul ignore next -- defensive: greedy phase only sees strings from initial tokenize() call */
1090
+ if (typeof token !== 'string') {
1091
+ continue;
1092
+ }
1093
+ // Build the full text by concatenating all consecutive string segments
1094
+ // so greedy regex can match across them — but for simplicity we operate
1095
+ // per-segment, which matches prismjs behavior for the patterns we use.
1096
+ const originalText = token;
1097
+ // Mask tracks which characters have been claimed. A GREEDY_PLACEHOLDER
1098
+ // character at position j means that character is already part of a greedy match.
1099
+ let mask = originalText;
1100
+ const matches = [];
1101
+ for (const { tokenType, patternDef } of greedyEntries) {
1102
+ const { pattern, lookbehind, inside } = patternDef;
1103
+ const regex = new RegExp(pattern.source, pattern.flags.replace(/g/g, '') + 'g');
1104
+ let execResult;
1105
+ while ((execResult = regex.exec(mask)) !== null) {
1106
+ let matchIndex = execResult.index;
1107
+ let match = execResult[0];
1108
+ /* istanbul ignore next -- defensive: prevents infinite loop on zero-length regex matches */
1109
+ if (match.length === 0) {
1110
+ regex.lastIndex++;
1111
+ continue;
1112
+ }
1113
+ // If matched text contains a placeholder char it overlaps a
1114
+ // previously claimed region — skip it.
1115
+ /* istanbul ignore next -- defensive: prevents re-tokenizing already-claimed greedy regions */
1116
+ if (match.indexOf(GREEDY_PLACEHOLDER) !== -1) {
1117
+ continue;
1118
+ }
1119
+ if (lookbehind && execResult[1]) {
1120
+ const lookbehindLength = execResult[1].length;
1121
+ matchIndex += lookbehindLength;
1122
+ match = match.slice(lookbehindLength);
1123
+ }
1124
+ // Record the match and blank out the region in the mask.
1125
+ const matchEnd = matchIndex + match.length;
1126
+ matches.push({
1127
+ tokenType,
1128
+ matchStart: matchIndex,
1129
+ matchEnd,
1130
+ matchText: originalText.slice(matchIndex, matchEnd),
1131
+ inside,
1132
+ });
1133
+ // Replace matched region in the mask with placeholder so later
1134
+ // patterns cannot match inside it.
1135
+ mask =
1136
+ mask.slice(0, matchIndex) +
1137
+ GREEDY_PLACEHOLDER.repeat(match.length).slice(0, match.length) +
1138
+ mask.slice(matchEnd);
1139
+ }
1140
+ }
1141
+ if (matches.length === 0) {
1142
+ continue;
1143
+ }
1144
+ // Sort matches by start position for deterministic splicing.
1145
+ matches.sort((a, b) => a.matchStart - b.matchStart);
1146
+ // Build replacement array.
1147
+ const replacement = [];
1148
+ let lastIndex = 0;
1149
+ for (const m of matches) {
1150
+ if (m.matchStart > lastIndex) {
1151
+ replacement.push(originalText.slice(lastIndex, m.matchStart));
1152
+ }
1153
+ let content = m.matchText;
1154
+ if (m.inside) {
1155
+ const nested = tokenize(m.matchText, m.inside);
1156
+ content = nested.length === 1 ? nested[0] : nested;
1157
+ }
1158
+ replacement.push({ type: m.tokenType, content });
1159
+ lastIndex = m.matchEnd;
1160
+ }
1161
+ if (lastIndex < originalText.length) {
1162
+ replacement.push(originalText.slice(lastIndex));
1163
+ }
1164
+ tokens.splice(i, 1, ...replacement);
1165
+ i += replacement.length - 1;
1166
+ }
1167
+ }
2244
1168
  /**
2245
- * @typedef Grammar
2246
- * @type {Object<string, RegExp | GrammarToken | Array<RegExp | GrammarToken>>}
2247
- * @property {Grammar} [rest] An optional grammar object that will be appended to this grammar.
2248
- * @global
2249
- * @public
1169
+ * Apply a single pattern definition across all string entries in the token list.
1170
+ * For each string entry, finds ALL matches of the pattern and splits the string
1171
+ * into alternating unmatched/matched segments in one pass.
1172
+ *
1173
+ * @param {(string | SyntaxToken)[]} tokens - The token list to process.
1174
+ * @param {string} tokenType - The token type name for matched content.
1175
+ * @param {GrammarPattern} patternDef - The pattern definition to apply.
2250
1176
  */
2251
-
1177
+ function applyPattern(tokens, tokenType, patternDef) {
1178
+ for (let i = 0; i < tokens.length; i++) {
1179
+ const token = tokens[i];
1180
+ // Only process string tokens, skip already-tokenized entries
1181
+ if (typeof token !== 'string') {
1182
+ continue;
1183
+ }
1184
+ const replacement = tokenizeStringByPattern(token, tokenType, patternDef);
1185
+ // Only splice if matches were found (replacement differs from original)
1186
+ if (replacement.length === 1 && typeof replacement[0] === 'string') {
1187
+ continue;
1188
+ }
1189
+ tokens.splice(i, 1, ...replacement);
1190
+ // Skip past the entire replacement — all matches in this string are handled
1191
+ i += replacement.length - 1;
1192
+ }
1193
+ }
2252
1194
  /**
2253
- * A function which will invoked after an element was successfully highlighted.
1195
+ * Find all matches of a pattern within a string and return the split result
1196
+ * as an array of alternating plain strings and syntax tokens.
2254
1197
  *
2255
- * @callback HighlightCallback
2256
- * @param {Element} element The element successfully highlighted.
2257
- * @returns {void}
2258
- * @global
2259
- * @public
1198
+ * @param {string} text - The string to tokenize.
1199
+ * @param {string} tokenType - The token type name for matched content.
1200
+ * @param {GrammarPattern} patternDef - The pattern definition to apply.
1201
+ * @returns {(string | SyntaxToken)[]} The tokenized result.
2260
1202
  */
1203
+ function tokenizeStringByPattern(text, tokenType, patternDef) {
1204
+ const { pattern, lookbehind, inside } = patternDef;
1205
+ const regex = new RegExp(pattern.source, pattern.flags.replace(/g/g, '') + 'g');
1206
+ const result = [];
1207
+ let lastIndex = 0;
1208
+ let execResult;
1209
+ while ((execResult = regex.exec(text)) !== null) {
1210
+ let matchIndex = execResult.index;
1211
+ let match = execResult[0];
1212
+ // Prevent zero-length match infinite loops
1213
+ if (match.length === 0) {
1214
+ regex.lastIndex++;
1215
+ continue;
1216
+ }
1217
+ // Handle lookbehind: adjust match position and content
1218
+ if (lookbehind && execResult[1]) {
1219
+ const lookbehindLength = execResult[1].length;
1220
+ matchIndex += lookbehindLength;
1221
+ match = match.slice(lookbehindLength);
1222
+ }
1223
+ // Add unmatched text before this match
1224
+ if (matchIndex > lastIndex) {
1225
+ result.push(text.slice(lastIndex, matchIndex));
1226
+ }
1227
+ // Process nested grammar if specified
1228
+ let content = match;
1229
+ if (inside) {
1230
+ const nestedTokens = tokenize(match, inside);
1231
+ content = nestedTokens.length === 1 ? nestedTokens[0] : nestedTokens;
1232
+ }
1233
+ result.push({ type: tokenType, content });
1234
+ lastIndex = matchIndex + match.length;
1235
+ }
1236
+ // Add remaining unmatched text
1237
+ if (lastIndex < text.length) {
1238
+ result.push(text.slice(lastIndex));
1239
+ }
1240
+ /* istanbul ignore next -- defensive: tokenizeStringByPattern always has remainder text */
1241
+ if (result.length === 0) {
1242
+ return [text];
1243
+ }
1244
+ return result;
1245
+ }
2261
1246
 
2262
1247
  /**
2263
- * @callback HookCallback
2264
- * @param {Object<string, any>} env The environment variables of the hook.
2265
- * @returns {void}
2266
- * @global
2267
- * @public
1248
+ * Grammar definition for CSS syntax highlighting.
1249
+ * Handles selectors, properties, values, at-rules, comments, strings, and other CSS constructs.
2268
1250
  */
2269
-
2270
-
2271
- /* **********************************************
2272
- Begin prism-markup.js
2273
- ********************************************** */
2274
-
2275
- Prism.languages.markup = {
2276
- 'comment': {
2277
- pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
2278
- greedy: true
2279
- },
2280
- 'prolog': {
2281
- pattern: /<\?[\s\S]+?\?>/,
2282
- greedy: true
2283
- },
2284
- 'doctype': {
2285
- // https://www.w3.org/TR/xml/#NT-doctypedecl
2286
- pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
2287
- greedy: true,
2288
- inside: {
2289
- 'internal-subset': {
2290
- pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
2291
- lookbehind: true,
2292
- greedy: true,
2293
- inside: null // see below
2294
- },
2295
- 'string': {
2296
- pattern: /"[^"]*"|'[^']*'/,
2297
- greedy: true
2298
- },
2299
- 'punctuation': /^<!|>$|[[\]]/,
2300
- 'doctype-tag': /^DOCTYPE/i,
2301
- 'name': /[^\s<>'"]+/
2302
- }
2303
- },
2304
- 'cdata': {
2305
- pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
2306
- greedy: true
2307
- },
2308
- 'tag': {
2309
- pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
2310
- greedy: true,
2311
- inside: {
2312
- 'tag': {
2313
- pattern: /^<\/?[^\s>\/]+/,
2314
- inside: {
2315
- 'punctuation': /^<\/?/,
2316
- 'namespace': /^[^\s>\/:]+:/
2317
- }
2318
- },
2319
- 'special-attr': [],
2320
- 'attr-value': {
2321
- pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
2322
- inside: {
2323
- 'punctuation': [
2324
- {
2325
- pattern: /^=/,
2326
- alias: 'attr-equals'
2327
- },
2328
- {
2329
- pattern: /^(\s*)["']|["']$/,
2330
- lookbehind: true
2331
- }
2332
- ]
2333
- }
2334
- },
2335
- 'punctuation': /\/?>/,
2336
- 'attr-name': {
2337
- pattern: /[^\s>\/]+/,
2338
- inside: {
2339
- 'namespace': /^[^\s>\/:]+:/
2340
- }
2341
- }
2342
-
2343
- }
2344
- },
2345
- 'entity': [
2346
- {
2347
- pattern: /&[\da-z]{1,8};/i,
2348
- alias: 'named-entity'
2349
- },
2350
- /&#x?[\da-f]{1,8};/i
2351
- ]
1251
+ const cssGrammar = {
1252
+ comment: {
1253
+ pattern: /\/\*[\s\S]*?\*\//,
1254
+ greedy: true,
1255
+ },
1256
+ string: {
1257
+ pattern: /("|')(?:\\[\s\S]|(?!\1)[^\\\n\r])*\1/,
1258
+ greedy: true,
1259
+ },
1260
+ atrule: [
1261
+ {
1262
+ pattern: /@[\w-](?:[^;{\s]|\s+(?![\s{]))*(?:;|(?=\s*\{))/,
1263
+ inside: {
1264
+ 'rule': { pattern: /^@[\w-]+/ },
1265
+ 'selector-function-argument': {
1266
+ pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
1267
+ lookbehind: true,
1268
+ },
1269
+ 'keyword': {
1270
+ pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
1271
+ lookbehind: true,
1272
+ },
1273
+ 'punctuation': { pattern: /[;:(){}]/ },
1274
+ },
1275
+ },
1276
+ ],
1277
+ url: {
1278
+ pattern: /\burl\((?:("|')(?:\\[\s\S]|(?!\1)[^\\\n\r])*\1|(?:[^\\\r\n()"']|\\[\s\S])*)\)/i,
1279
+ greedy: true,
1280
+ inside: {
1281
+ function: { pattern: /^url/i },
1282
+ punctuation: { pattern: /^\(|\)$/ },
1283
+ string: {
1284
+ pattern: /^("|')[\s\S]+(?=\1$)/,
1285
+ lookbehind: true,
1286
+ },
1287
+ },
1288
+ },
1289
+ selector: {
1290
+ pattern: /(?=\S)[^@;{}()]?(?:[^@;{}()\s]|\s+(?![\s{])|\((?:[^()]|\([^()]*\))*\))*(?=\s*\{)/,
1291
+ inside: {
1292
+ 'pseudo-element': { pattern: /(?:::)[\w-]+/ },
1293
+ 'pseudo-class': { pattern: /(?::)[\w-]+/ },
1294
+ 'class': { pattern: /\.[\w-]+/ },
1295
+ 'id': { pattern: /#[\w-]+/ },
1296
+ 'attribute': {
1297
+ pattern: /\[(?:[^[\]"']|("|')(?:\\[\s\S]|(?!\1)[^\\\n\r])*\1)*\]/,
1298
+ greedy: true,
1299
+ inside: {
1300
+ 'punctuation': { pattern: /^\[|\]$/ },
1301
+ 'attr-name': { pattern: /^(\s*)(?:(?!\s)[-\w\u00B7\u00C0-\u024F])+/i, lookbehind: true },
1302
+ 'attr-value': [{ pattern: /(=\s*)(?:"[^"]*"|'[^']*'|[^\s'"=]+)/, lookbehind: true }],
1303
+ 'operator': { pattern: /[|~*^$]?=/ },
1304
+ },
1305
+ },
1306
+ },
1307
+ },
1308
+ property: {
1309
+ pattern: /(?!\s)[-_a-z\u00B7\u00C0-\u024F][-\w\u00B7\u00C0-\u024F]*(?=\s*:)/i,
1310
+ },
1311
+ important: {
1312
+ pattern: /!important\b/i,
1313
+ },
1314
+ function: {
1315
+ pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
1316
+ lookbehind: true,
1317
+ },
1318
+ number: {
1319
+ pattern: /(^|[^\w.-])-?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?/i,
1320
+ lookbehind: true,
1321
+ },
1322
+ unit: {
1323
+ pattern: /(\b\d+)(?:%|[a-z]+)/,
1324
+ lookbehind: true,
1325
+ },
1326
+ punctuation: {
1327
+ pattern: /[(){};:,]/,
1328
+ },
1329
+ operator: {
1330
+ pattern: /[+\-*/=><~^|]+/,
1331
+ },
2352
1332
  };
2353
1333
 
2354
- Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] =
2355
- Prism.languages.markup['entity'];
2356
- Prism.languages.markup['doctype'].inside['internal-subset'].inside = Prism.languages.markup;
2357
-
2358
- // Plugin to make entity title show the real entity, idea by Roman Komarov
2359
- Prism.hooks.add('wrap', function (env) {
2360
-
2361
- if (env.type === 'entity') {
2362
- env.attributes['title'] = env.content.replace(/&amp;/, '&');
2363
- }
2364
- });
2365
-
2366
- Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
2367
- /**
2368
- * Adds an inlined language to markup.
2369
- *
2370
- * An example of an inlined language is CSS with `<style>` tags.
2371
- *
2372
- * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
2373
- * case insensitive.
2374
- * @param {string} lang The language key.
2375
- * @example
2376
- * addInlined('style', 'css');
2377
- */
2378
- value: function addInlined(tagName, lang) {
2379
- var includedCdataInside = {};
2380
- includedCdataInside['language-' + lang] = {
2381
- pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
2382
- lookbehind: true,
2383
- inside: Prism.languages[lang]
2384
- };
2385
- includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i;
2386
-
2387
- var inside = {
2388
- 'included-cdata': {
2389
- pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
2390
- inside: includedCdataInside
2391
- }
2392
- };
2393
- inside['language-' + lang] = {
2394
- pattern: /[\s\S]+/,
2395
- inside: Prism.languages[lang]
2396
- };
2397
-
2398
- var def = {};
2399
- def[tagName] = {
2400
- pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () { return tagName; }), 'i'),
2401
- lookbehind: true,
2402
- greedy: true,
2403
- inside: inside
2404
- };
2405
-
2406
- Prism.languages.insertBefore('markup', 'cdata', def);
2407
- }
2408
- });
2409
- Object.defineProperty(Prism.languages.markup.tag, 'addAttribute', {
2410
- /**
2411
- * Adds an pattern to highlight languages embedded in HTML attributes.
2412
- *
2413
- * An example of an inlined language is CSS with `style` attributes.
2414
- *
2415
- * @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as
2416
- * case insensitive.
2417
- * @param {string} lang The language key.
2418
- * @example
2419
- * addAttribute('style', 'css');
2420
- */
2421
- value: function (attrName, lang) {
2422
- Prism.languages.markup.tag.inside['special-attr'].push({
2423
- pattern: RegExp(
2424
- /(^|["'\s])/.source + '(?:' + attrName + ')' + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
2425
- 'i'
2426
- ),
2427
- lookbehind: true,
2428
- inside: {
2429
- 'attr-name': /^[^\s=]+/,
2430
- 'attr-value': {
2431
- pattern: /=[\s\S]+/,
2432
- inside: {
2433
- 'value': {
2434
- pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
2435
- lookbehind: true,
2436
- alias: [lang, 'language-' + lang],
2437
- inside: Prism.languages[lang]
2438
- },
2439
- 'punctuation': [
2440
- {
2441
- pattern: /^=/,
2442
- alias: 'attr-equals'
2443
- },
2444
- /"|'/
2445
- ]
2446
- }
2447
- }
2448
- }
2449
- });
2450
- }
2451
- });
2452
-
2453
- Prism.languages.html = Prism.languages.markup;
2454
- Prism.languages.mathml = Prism.languages.markup;
2455
- Prism.languages.svg = Prism.languages.markup;
2456
-
2457
- Prism.languages.xml = Prism.languages.extend('markup', {});
2458
- Prism.languages.ssml = Prism.languages.xml;
2459
- Prism.languages.atom = Prism.languages.xml;
2460
- Prism.languages.rss = Prism.languages.xml;
2461
-
2462
-
2463
- /* **********************************************
2464
- Begin prism-css.js
2465
- ********************************************** */
2466
-
2467
- (function (Prism) {
2468
-
2469
- var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
2470
-
2471
- Prism.languages.css = {
2472
- 'comment': /\/\*[\s\S]*?\*\//,
2473
- 'atrule': {
2474
- pattern: RegExp('@[\\w-](?:' + /[^;{\s"']|\s+(?!\s)/.source + '|' + string.source + ')*?' + /(?:;|(?=\s*\{))/.source),
2475
- inside: {
2476
- 'rule': /^@[\w-]+/,
2477
- 'selector-function-argument': {
2478
- pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
2479
- lookbehind: true,
2480
- alias: 'selector'
2481
- },
2482
- 'keyword': {
2483
- pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
2484
- lookbehind: true
2485
- }
2486
- // See rest below
2487
- }
2488
- },
2489
- 'url': {
2490
- // https://drafts.csswg.org/css-values-3/#urls
2491
- pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'),
2492
- greedy: true,
2493
- inside: {
2494
- 'function': /^url/i,
2495
- 'punctuation': /^\(|\)$/,
2496
- 'string': {
2497
- pattern: RegExp('^' + string.source + '$'),
2498
- alias: 'url'
2499
- }
2500
- }
2501
- },
2502
- 'selector': {
2503
- pattern: RegExp('(^|[{}\\s])[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + string.source + ')*(?=\\s*\\{)'),
2504
- lookbehind: true
2505
- },
2506
- 'string': {
2507
- pattern: string,
2508
- greedy: true
2509
- },
2510
- 'property': {
2511
- pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
2512
- lookbehind: true
2513
- },
2514
- 'important': /!important\b/i,
2515
- 'function': {
2516
- pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
2517
- lookbehind: true
2518
- },
2519
- 'punctuation': /[(){};:,]/
2520
- };
2521
-
2522
- Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
2523
-
2524
- var markup = Prism.languages.markup;
2525
- if (markup) {
2526
- markup.tag.addInlined('style', 'css');
2527
- markup.tag.addAttribute('style', 'css');
2528
- }
2529
-
2530
- }(Prism));
2531
-
2532
-
2533
- /* **********************************************
2534
- Begin prism-clike.js
2535
- ********************************************** */
2536
-
2537
- Prism.languages.clike = {
2538
- 'comment': [
2539
- {
2540
- pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
2541
- lookbehind: true,
2542
- greedy: true
2543
- },
2544
- {
2545
- pattern: /(^|[^\\:])\/\/.*/,
2546
- lookbehind: true,
2547
- greedy: true
2548
- }
2549
- ],
2550
- 'string': {
2551
- pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
2552
- greedy: true
2553
- },
2554
- 'class-name': {
2555
- pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
2556
- lookbehind: true,
2557
- inside: {
2558
- 'punctuation': /[.\\]/
2559
- }
2560
- },
2561
- 'keyword': /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
2562
- 'boolean': /\b(?:false|true)\b/,
2563
- 'function': /\b\w+(?=\()/,
2564
- 'number': /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
2565
- 'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
2566
- 'punctuation': /[{}[\];(),.:]/
1334
+ /**
1335
+ * Grammar definition for HTML/Markup syntax highlighting.
1336
+ * Handles tags, attributes, comments, doctypes, CDATA, entities, and embedded content.
1337
+ */
1338
+ const markupGrammar = {
1339
+ comment: {
1340
+ pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
1341
+ greedy: true,
1342
+ },
1343
+ prolog: {
1344
+ pattern: /<\?[\s\S]+?\?>/,
1345
+ greedy: true,
1346
+ },
1347
+ doctype: {
1348
+ pattern: /<!DOCTYPE(?:[^>"']|"[^"]*"|'[^']*')+(?:>|$)/i,
1349
+ greedy: true,
1350
+ inside: {
1351
+ 'internal-subset': {
1352
+ pattern: /(^[^[]*\[)[\s\S]+(?=\]>$)/,
1353
+ lookbehind: true,
1354
+ greedy: true,
1355
+ },
1356
+ 'punctuation': { pattern: /^<!|>$|[[\]]/ },
1357
+ 'doctype-tag': { pattern: /^DOCTYPE/i },
1358
+ 'name': { pattern: /[^\s<>'"/]+/ },
1359
+ 'string': {
1360
+ pattern: /("|')[\s\S]*?\1/,
1361
+ greedy: true,
1362
+ },
1363
+ },
1364
+ },
1365
+ cdata: {
1366
+ pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
1367
+ greedy: true,
1368
+ },
1369
+ tag: {
1370
+ pattern: /<\/?(?!\d)[^\s>/=$<%]+(?:\s(?:\s*[^\s>/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
1371
+ greedy: true,
1372
+ inside: {
1373
+ 'tag': {
1374
+ pattern: /^<\/?[^\s>/]+/,
1375
+ inside: {
1376
+ punctuation: { pattern: /^<\/?/ },
1377
+ namespace: { pattern: /^[^\s>/:]+:/ },
1378
+ },
1379
+ },
1380
+ 'special-attr': [],
1381
+ 'attr-value': {
1382
+ pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
1383
+ inside: {
1384
+ punctuation: [{ pattern: /^=/ }, { pattern: /^(\s*)["']|["']$/, lookbehind: true }],
1385
+ },
1386
+ },
1387
+ 'punctuation': { pattern: /\/?>/ },
1388
+ 'attr-name': {
1389
+ pattern: /[^\s>/]+/,
1390
+ inside: {
1391
+ namespace: { pattern: /^[^\s>/:]+:/ },
1392
+ },
1393
+ },
1394
+ },
1395
+ },
1396
+ entity: [
1397
+ {
1398
+ pattern: /&[\da-z]{1,8};/i,
1399
+ },
1400
+ {
1401
+ pattern: /&#x?[\da-f]{1,8};/i,
1402
+ },
1403
+ ],
2567
1404
  };
2568
1405
 
2569
-
2570
- /* **********************************************
2571
- Begin prism-javascript.js
2572
- ********************************************** */
2573
-
2574
- Prism.languages.javascript = Prism.languages.extend('clike', {
2575
- 'class-name': [
2576
- Prism.languages.clike['class-name'],
2577
- {
2578
- pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
2579
- lookbehind: true
2580
- }
2581
- ],
2582
- 'keyword': [
2583
- {
2584
- pattern: /((?:^|\})\s*)catch\b/,
2585
- lookbehind: true
2586
- },
2587
- {
2588
- pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
2589
- lookbehind: true
2590
- },
2591
- ],
2592
- // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
2593
- 'function': /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
2594
- 'number': {
2595
- pattern: RegExp(
2596
- /(^|[^\w$])/.source +
2597
- '(?:' +
2598
- (
2599
- // constant
2600
- /NaN|Infinity/.source +
2601
- '|' +
2602
- // binary integer
2603
- /0[bB][01]+(?:_[01]+)*n?/.source +
2604
- '|' +
2605
- // octal integer
2606
- /0[oO][0-7]+(?:_[0-7]+)*n?/.source +
2607
- '|' +
2608
- // hexadecimal integer
2609
- /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source +
2610
- '|' +
2611
- // decimal bigint
2612
- /\d+(?:_\d+)*n/.source +
2613
- '|' +
2614
- // decimal number (integer or float) but no bigint
2615
- /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source
2616
- ) +
2617
- ')' +
2618
- /(?![\w$])/.source
2619
- ),
2620
- lookbehind: true
2621
- },
2622
- 'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
2623
- });
2624
-
2625
- Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
2626
-
2627
- Prism.languages.insertBefore('javascript', 'keyword', {
2628
- 'regex': {
2629
- pattern: RegExp(
2630
- // lookbehind
2631
- // eslint-disable-next-line regexp/no-dupe-characters-character-class
2632
- /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source +
2633
- // Regex pattern:
2634
- // There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
2635
- // classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
2636
- // with the only syntax, so we have to define 2 different regex patterns.
2637
- /\//.source +
2638
- '(?:' +
2639
- /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source +
2640
- '|' +
2641
- // `v` flag syntax. This supports 3 levels of nested character classes.
2642
- /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source +
2643
- ')' +
2644
- // lookahead
2645
- /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
2646
- ),
2647
- lookbehind: true,
2648
- greedy: true,
2649
- inside: {
2650
- 'regex-source': {
2651
- pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
2652
- lookbehind: true,
2653
- alias: 'language-regex',
2654
- inside: Prism.languages.regex
2655
- },
2656
- 'regex-delimiter': /^\/|\/$/,
2657
- 'regex-flags': /^[a-z]+$/,
2658
- }
2659
- },
2660
- // This must be declared before keyword because we use "function" inside the look-forward
2661
- 'function-variable': {
2662
- pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
2663
- alias: 'function'
2664
- },
2665
- 'parameter': [
2666
- {
2667
- pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
2668
- lookbehind: true,
2669
- inside: Prism.languages.javascript
2670
- },
2671
- {
2672
- pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
2673
- lookbehind: true,
2674
- inside: Prism.languages.javascript
2675
- },
2676
- {
2677
- pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
2678
- lookbehind: true,
2679
- inside: Prism.languages.javascript
2680
- },
2681
- {
2682
- pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,
2683
- lookbehind: true,
2684
- inside: Prism.languages.javascript
2685
- }
2686
- ],
2687
- 'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
2688
- });
2689
-
2690
- Prism.languages.insertBefore('javascript', 'string', {
2691
- 'hashbang': {
2692
- pattern: /^#!.*/,
2693
- greedy: true,
2694
- alias: 'comment'
2695
- },
2696
- 'template-string': {
2697
- pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
2698
- greedy: true,
2699
- inside: {
2700
- 'template-punctuation': {
2701
- pattern: /^`|`$/,
2702
- alias: 'string'
2703
- },
2704
- 'interpolation': {
2705
- pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
2706
- lookbehind: true,
2707
- inside: {
2708
- 'interpolation-punctuation': {
2709
- pattern: /^\$\{|\}$/,
2710
- alias: 'punctuation'
2711
- },
2712
- rest: Prism.languages.javascript
2713
- }
2714
- },
2715
- 'string': /[\s\S]+/
2716
- }
2717
- },
2718
- 'string-property': {
2719
- pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
2720
- lookbehind: true,
2721
- greedy: true,
2722
- alias: 'property'
2723
- }
2724
- });
2725
-
2726
- Prism.languages.insertBefore('javascript', 'operator', {
2727
- 'literal-property': {
2728
- pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
2729
- lookbehind: true,
2730
- alias: 'property'
2731
- },
2732
- });
2733
-
2734
- if (Prism.languages.markup) {
2735
- Prism.languages.markup.tag.addInlined('script', 'javascript');
2736
-
2737
- // add attribute support for all DOM events.
2738
- // https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events
2739
- Prism.languages.markup.tag.addAttribute(
2740
- /on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,
2741
- 'javascript'
2742
- );
2743
- }
2744
-
2745
- Prism.languages.js = Prism.languages.javascript;
2746
-
2747
-
2748
- /* **********************************************
2749
- Begin prism-file-highlight.js
2750
- ********************************************** */
2751
-
2752
- (function () {
2753
-
2754
- if (typeof Prism === 'undefined' || typeof document === 'undefined') {
2755
- return;
2756
- }
2757
-
2758
- // https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill
2759
- if (!Element.prototype.matches) {
2760
- Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
2761
- }
2762
-
2763
- var LOADING_MESSAGE = 'Loading…';
2764
- var FAILURE_MESSAGE = function (status, message) {
2765
- return '✖ Error ' + status + ' while fetching file: ' + message;
2766
- };
2767
- var FAILURE_EMPTY_MESSAGE = '✖ Error: File does not exist or is empty';
2768
-
2769
- var EXTENSIONS = {
2770
- 'js': 'javascript',
2771
- 'py': 'python',
2772
- 'rb': 'ruby',
2773
- 'ps1': 'powershell',
2774
- 'psm1': 'powershell',
2775
- 'sh': 'bash',
2776
- 'bat': 'batch',
2777
- 'h': 'c',
2778
- 'tex': 'latex'
2779
- };
2780
-
2781
- var STATUS_ATTR = 'data-src-status';
2782
- var STATUS_LOADING = 'loading';
2783
- var STATUS_LOADED = 'loaded';
2784
- var STATUS_FAILED = 'failed';
2785
-
2786
- var SELECTOR = 'pre[data-src]:not([' + STATUS_ATTR + '="' + STATUS_LOADED + '"])'
2787
- + ':not([' + STATUS_ATTR + '="' + STATUS_LOADING + '"])';
2788
-
2789
- /**
2790
- * Loads the given file.
2791
- *
2792
- * @param {string} src The URL or path of the source file to load.
2793
- * @param {(result: string) => void} success
2794
- * @param {(reason: string) => void} error
2795
- */
2796
- function loadFile(src, success, error) {
2797
- var xhr = new XMLHttpRequest();
2798
- xhr.open('GET', src, true);
2799
- xhr.onreadystatechange = function () {
2800
- if (xhr.readyState == 4) {
2801
- if (xhr.status < 400 && xhr.responseText) {
2802
- success(xhr.responseText);
2803
- } else {
2804
- if (xhr.status >= 400) {
2805
- error(FAILURE_MESSAGE(xhr.status, xhr.statusText));
2806
- } else {
2807
- error(FAILURE_EMPTY_MESSAGE);
2808
- }
2809
- }
2810
- }
2811
- };
2812
- xhr.send(null);
2813
- }
2814
-
2815
- /**
2816
- * Parses the given range.
2817
- *
2818
- * This returns a range with inclusive ends.
2819
- *
2820
- * @param {string | null | undefined} range
2821
- * @returns {[number, number | undefined] | undefined}
2822
- */
2823
- function parseRange(range) {
2824
- var m = /^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(range || '');
2825
- if (m) {
2826
- var start = Number(m[1]);
2827
- var comma = m[2];
2828
- var end = m[3];
2829
-
2830
- if (!comma) {
2831
- return [start, start];
2832
- }
2833
- if (!end) {
2834
- return [start, undefined];
2835
- }
2836
- return [start, Number(end)];
2837
- }
2838
- return undefined;
2839
- }
2840
-
2841
- Prism.hooks.add('before-highlightall', function (env) {
2842
- env.selector += ', ' + SELECTOR;
2843
- });
2844
-
2845
- Prism.hooks.add('before-sanity-check', function (env) {
2846
- var pre = /** @type {HTMLPreElement} */ (env.element);
2847
- if (pre.matches(SELECTOR)) {
2848
- env.code = ''; // fast-path the whole thing and go to complete
2849
-
2850
- pre.setAttribute(STATUS_ATTR, STATUS_LOADING); // mark as loading
2851
-
2852
- // add code element with loading message
2853
- var code = pre.appendChild(document.createElement('CODE'));
2854
- code.textContent = LOADING_MESSAGE;
2855
-
2856
- var src = pre.getAttribute('data-src');
2857
-
2858
- var language = env.language;
2859
- if (language === 'none') {
2860
- // the language might be 'none' because there is no language set;
2861
- // in this case, we want to use the extension as the language
2862
- var extension = (/\.(\w+)$/.exec(src) || [, 'none'])[1];
2863
- language = EXTENSIONS[extension] || extension;
2864
- }
2865
-
2866
- // set language classes
2867
- Prism.util.setLanguage(code, language);
2868
- Prism.util.setLanguage(pre, language);
2869
-
2870
- // preload the language
2871
- var autoloader = Prism.plugins.autoloader;
2872
- if (autoloader) {
2873
- autoloader.loadLanguages(language);
2874
- }
2875
-
2876
- // load file
2877
- loadFile(
2878
- src,
2879
- function (text) {
2880
- // mark as loaded
2881
- pre.setAttribute(STATUS_ATTR, STATUS_LOADED);
2882
-
2883
- // handle data-range
2884
- var range = parseRange(pre.getAttribute('data-range'));
2885
- if (range) {
2886
- var lines = text.split(/\r\n?|\n/g);
2887
-
2888
- // the range is one-based and inclusive on both ends
2889
- var start = range[0];
2890
- var end = range[1] == null ? lines.length : range[1];
2891
-
2892
- if (start < 0) { start += lines.length; }
2893
- start = Math.max(0, Math.min(start - 1, lines.length));
2894
- if (end < 0) { end += lines.length; }
2895
- end = Math.max(0, Math.min(end, lines.length));
2896
-
2897
- text = lines.slice(start, end).join('\n');
2898
-
2899
- // add data-start for line numbers
2900
- if (!pre.hasAttribute('data-start')) {
2901
- pre.setAttribute('data-start', String(start + 1));
2902
- }
2903
- }
2904
-
2905
- // highlight code
2906
- code.textContent = text;
2907
- Prism.highlightElement(code);
2908
- },
2909
- function (error) {
2910
- // mark as failed
2911
- pre.setAttribute(STATUS_ATTR, STATUS_FAILED);
2912
-
2913
- code.textContent = error;
2914
- }
2915
- );
2916
- }
2917
- });
2918
-
2919
- Prism.plugins.fileHighlight = {
2920
- /**
2921
- * Executes the File Highlight plugin for all matching `pre` elements under the given container.
2922
- *
2923
- * Note: Elements which are already loaded or currently loading will not be touched by this method.
2924
- *
2925
- * @param {ParentNode} [container=document]
2926
- */
2927
- highlight: function highlight(container) {
2928
- var elements = (container || document).querySelectorAll(SELECTOR);
2929
-
2930
- for (var i = 0, element; (element = elements[i++]);) {
2931
- Prism.highlightElement(element);
2932
- }
2933
- }
2934
- };
2935
-
2936
- var logged = false;
2937
- /** @deprecated Use `Prism.plugins.fileHighlight.highlight` instead. */
2938
- Prism.fileHighlight = function () {
2939
- if (!logged) {
2940
- console.warn('Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead.');
2941
- logged = true;
2942
- }
2943
- Prism.plugins.fileHighlight.highlight.apply(this, arguments);
2944
- };
2945
-
2946
- }());
2947
- });
2948
-
2949
- Prism.languages.clike = {
2950
- 'comment': [
2951
- {
2952
- pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
2953
- lookbehind: true,
2954
- greedy: true
2955
- },
2956
- {
2957
- pattern: /(^|[^\\:])\/\/.*/,
2958
- lookbehind: true,
2959
- greedy: true
2960
- }
2961
- ],
2962
- 'string': {
2963
- pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
2964
- greedy: true
2965
- },
2966
- 'class-name': {
2967
- pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
2968
- lookbehind: true,
2969
- inside: {
2970
- 'punctuation': /[.\\]/
2971
- }
2972
- },
2973
- 'keyword': /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
2974
- 'boolean': /\b(?:false|true)\b/,
2975
- 'function': /\b\w+(?=\()/,
2976
- 'number': /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
2977
- 'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
2978
- 'punctuation': /[{}[\];(),.:]/
1406
+ /**
1407
+ * Grammar definition for JavaScript syntax highlighting.
1408
+ * Handles keywords, operators, strings, template literals, numbers,
1409
+ * regex literals, comments, functions, classes, and other JS constructs.
1410
+ */
1411
+ const javascriptGrammar = {
1412
+ 'comment': [
1413
+ {
1414
+ pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
1415
+ lookbehind: true,
1416
+ greedy: true,
1417
+ },
1418
+ {
1419
+ pattern: /(^|[^\\:])\/\/.*/,
1420
+ lookbehind: true,
1421
+ greedy: true,
1422
+ },
1423
+ ],
1424
+ 'string': [
1425
+ {
1426
+ pattern: /(["'])(?:\\[\s\S]|(?!\1)[^\\\r\n])*\1/,
1427
+ greedy: true,
1428
+ },
1429
+ ],
1430
+ 'template-string': {
1431
+ pattern: /`(?:\\[\s\S]|[^\\`])*`/,
1432
+ greedy: true,
1433
+ inside: {
1434
+ 'template-punctuation': {
1435
+ pattern: /^`|`$/,
1436
+ },
1437
+ 'interpolation': {
1438
+ pattern: /\$\{(?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*\}/,
1439
+ inside: {
1440
+ 'interpolation-punctuation': {
1441
+ pattern: /^\$\{|\}$/,
1442
+ },
1443
+ },
1444
+ },
1445
+ 'string': {
1446
+ pattern: /[\s\S]+/,
1447
+ },
1448
+ },
1449
+ },
1450
+ 'regex': {
1451
+ pattern:
1452
+ // eslint-disable-next-line no-useless-escape
1453
+ /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[.\r\n,;:})\]]|\/\/))/,
1454
+ lookbehind: true,
1455
+ greedy: true,
1456
+ inside: {
1457
+ 'regex-source': {
1458
+ pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
1459
+ lookbehind: true,
1460
+ },
1461
+ 'regex-delimiter': {
1462
+ pattern: /^\/|\/$/,
1463
+ },
1464
+ 'regex-flags': {
1465
+ pattern: /^[a-z]+$/,
1466
+ },
1467
+ },
1468
+ },
1469
+ 'class-name': [
1470
+ {
1471
+ pattern: /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,
1472
+ lookbehind: true,
1473
+ inside: {
1474
+ punctuation: { pattern: /[.\\]/ },
1475
+ },
1476
+ },
1477
+ ],
1478
+ 'keyword': [
1479
+ {
1480
+ pattern: /\b(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
1481
+ },
1482
+ ],
1483
+ 'boolean': {
1484
+ pattern: /\b(?:false|true)\b/,
1485
+ },
1486
+ 'number': {
1487
+ pattern: /\b(?:(?:0[xX][\dA-Fa-f](?:_[\dA-Fa-f])*|0[bB][01](?:_[01])*|0[oO][0-7](?:_[0-7])*)n?|(?:\d(?:_\d)*\.?\d*|\.\d+)(?:[Ee][+-]?\d(?:_\d)*)?n?|NaN|Infinity)\b/,
1488
+ },
1489
+ 'function': {
1490
+ pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
1491
+ },
1492
+ 'operator': {
1493
+ pattern: /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%|&^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/,
1494
+ },
1495
+ 'punctuation': {
1496
+ pattern: /[{}[\];(),.:]/,
1497
+ },
1498
+ 'constant': {
1499
+ pattern: /\b[A-Z](?:[A-Z_]|\dx)*\b/,
1500
+ },
2979
1501
  };
2980
1502
 
2981
- Prism.languages.javascript = Prism.languages.extend('clike', {
2982
- 'class-name': [
2983
- Prism.languages.clike['class-name'],
2984
- {
2985
- pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
2986
- lookbehind: true
2987
- }
2988
- ],
2989
- 'keyword': [
2990
- {
2991
- pattern: /((?:^|\})\s*)catch\b/,
2992
- lookbehind: true
2993
- },
2994
- {
2995
- pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
2996
- lookbehind: true
2997
- },
2998
- ],
2999
- // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
3000
- 'function': /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
3001
- 'number': {
3002
- pattern: RegExp(
3003
- /(^|[^\w$])/.source +
3004
- '(?:' +
3005
- (
3006
- // constant
3007
- /NaN|Infinity/.source +
3008
- '|' +
3009
- // binary integer
3010
- /0[bB][01]+(?:_[01]+)*n?/.source +
3011
- '|' +
3012
- // octal integer
3013
- /0[oO][0-7]+(?:_[0-7]+)*n?/.source +
3014
- '|' +
3015
- // hexadecimal integer
3016
- /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source +
3017
- '|' +
3018
- // decimal bigint
3019
- /\d+(?:_\d+)*n/.source +
3020
- '|' +
3021
- // decimal number (integer or float) but no bigint
3022
- /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source
3023
- ) +
3024
- ')' +
3025
- /(?![\w$])/.source
3026
- ),
3027
- lookbehind: true
3028
- },
3029
- 'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
3030
- });
3031
-
3032
- Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
3033
-
3034
- Prism.languages.insertBefore('javascript', 'keyword', {
3035
- 'regex': {
3036
- pattern: RegExp(
3037
- // lookbehind
3038
- // eslint-disable-next-line regexp/no-dupe-characters-character-class
3039
- /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source +
3040
- // Regex pattern:
3041
- // There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
3042
- // classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
3043
- // with the only syntax, so we have to define 2 different regex patterns.
3044
- /\//.source +
3045
- '(?:' +
3046
- /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source +
3047
- '|' +
3048
- // `v` flag syntax. This supports 3 levels of nested character classes.
3049
- /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source +
3050
- ')' +
3051
- // lookahead
3052
- /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
3053
- ),
3054
- lookbehind: true,
3055
- greedy: true,
3056
- inside: {
3057
- 'regex-source': {
3058
- pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
3059
- lookbehind: true,
3060
- alias: 'language-regex',
3061
- inside: Prism.languages.regex
3062
- },
3063
- 'regex-delimiter': /^\/|\/$/,
3064
- 'regex-flags': /^[a-z]+$/,
3065
- }
3066
- },
3067
- // This must be declared before keyword because we use "function" inside the look-forward
3068
- 'function-variable': {
3069
- pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
3070
- alias: 'function'
3071
- },
3072
- 'parameter': [
3073
- {
3074
- pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
3075
- lookbehind: true,
3076
- inside: Prism.languages.javascript
3077
- },
3078
- {
3079
- pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
3080
- lookbehind: true,
3081
- inside: Prism.languages.javascript
3082
- },
3083
- {
3084
- pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
3085
- lookbehind: true,
3086
- inside: Prism.languages.javascript
3087
- },
3088
- {
3089
- pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,
3090
- lookbehind: true,
3091
- inside: Prism.languages.javascript
3092
- }
3093
- ],
3094
- 'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
3095
- });
3096
-
3097
- Prism.languages.insertBefore('javascript', 'string', {
3098
- 'hashbang': {
3099
- pattern: /^#!.*/,
3100
- greedy: true,
3101
- alias: 'comment'
3102
- },
3103
- 'template-string': {
3104
- pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
3105
- greedy: true,
3106
- inside: {
3107
- 'template-punctuation': {
3108
- pattern: /^`|`$/,
3109
- alias: 'string'
3110
- },
3111
- 'interpolation': {
3112
- pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
3113
- lookbehind: true,
3114
- inside: {
3115
- 'interpolation-punctuation': {
3116
- pattern: /^\$\{|\}$/,
3117
- alias: 'punctuation'
3118
- },
3119
- rest: Prism.languages.javascript
3120
- }
3121
- },
3122
- 'string': /[\s\S]+/
3123
- }
3124
- },
3125
- 'string-property': {
3126
- pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
3127
- lookbehind: true,
3128
- greedy: true,
3129
- alias: 'property'
3130
- }
3131
- });
3132
-
3133
- Prism.languages.insertBefore('javascript', 'operator', {
3134
- 'literal-property': {
3135
- pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
3136
- lookbehind: true,
3137
- alias: 'property'
3138
- },
3139
- });
3140
-
3141
- if (Prism.languages.markup) {
3142
- Prism.languages.markup.tag.addInlined('script', 'javascript');
3143
-
3144
- // add attribute support for all DOM events.
3145
- // https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events
3146
- Prism.languages.markup.tag.addAttribute(
3147
- /on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,
3148
- 'javascript'
3149
- );
3150
- }
3151
-
3152
- Prism.languages.js = Prism.languages.javascript;
3153
-
3154
- Prism.languages.markup = {
3155
- 'comment': {
3156
- pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
3157
- greedy: true
3158
- },
3159
- 'prolog': {
3160
- pattern: /<\?[\s\S]+?\?>/,
3161
- greedy: true
3162
- },
3163
- 'doctype': {
3164
- // https://www.w3.org/TR/xml/#NT-doctypedecl
3165
- pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
3166
- greedy: true,
3167
- inside: {
3168
- 'internal-subset': {
3169
- pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
3170
- lookbehind: true,
3171
- greedy: true,
3172
- inside: null // see below
3173
- },
3174
- 'string': {
3175
- pattern: /"[^"]*"|'[^']*'/,
3176
- greedy: true
3177
- },
3178
- 'punctuation': /^<!|>$|[[\]]/,
3179
- 'doctype-tag': /^DOCTYPE/i,
3180
- 'name': /[^\s<>'"]+/
3181
- }
3182
- },
3183
- 'cdata': {
3184
- pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
3185
- greedy: true
3186
- },
3187
- 'tag': {
3188
- pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
3189
- greedy: true,
3190
- inside: {
3191
- 'tag': {
3192
- pattern: /^<\/?[^\s>\/]+/,
3193
- inside: {
3194
- 'punctuation': /^<\/?/,
3195
- 'namespace': /^[^\s>\/:]+:/
3196
- }
3197
- },
3198
- 'special-attr': [],
3199
- 'attr-value': {
3200
- pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
3201
- inside: {
3202
- 'punctuation': [
3203
- {
3204
- pattern: /^=/,
3205
- alias: 'attr-equals'
3206
- },
3207
- {
3208
- pattern: /^(\s*)["']|["']$/,
3209
- lookbehind: true
3210
- }
3211
- ]
3212
- }
3213
- },
3214
- 'punctuation': /\/?>/,
3215
- 'attr-name': {
3216
- pattern: /[^\s>\/]+/,
3217
- inside: {
3218
- 'namespace': /^[^\s>\/:]+:/
3219
- }
3220
- }
3221
-
3222
- }
3223
- },
3224
- 'entity': [
3225
- {
3226
- pattern: /&[\da-z]{1,8};/i,
3227
- alias: 'named-entity'
3228
- },
3229
- /&#x?[\da-f]{1,8};/i
3230
- ]
1503
+ var __rest = (undefined && undefined.__rest) || function (s, e) {
1504
+ var t = {};
1505
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1506
+ t[p] = s[p];
1507
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
1508
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1509
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1510
+ t[p[i]] = s[p[i]];
1511
+ }
1512
+ return t;
3231
1513
  };
1514
+ /**
1515
+ * Grammar definition for TypeScript syntax highlighting.
1516
+ * Extends JavaScript grammar with TypeScript-specific constructs such as
1517
+ * type annotations, generics, interfaces, enums, decorators, and access modifiers.
1518
+ *
1519
+ * Note: We destructure `keyword`, `function`, `operator`, and `punctuation` out
1520
+ * of the JS grammar and re-add them in the correct order. This ensures:
1521
+ * - `builtin` is matched before `keyword` (both contain words like void, null, etc.)
1522
+ * - `function` is matched before `operator` and `punctuation` (the function
1523
+ * pattern uses a lookahead for `(` which must still be an unmatched string)
1524
+ */
1525
+ const {
1526
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1527
+ keyword: _jsKeyword, function: jsFunction,
1528
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1529
+ operator: _jsOperator, punctuation: jsPunctuation } = javascriptGrammar, jsGrammarBase = __rest(javascriptGrammar, ["keyword", "function", "operator", "punctuation"]);
1530
+ const typescriptGrammar = Object.assign(Object.assign({}, jsGrammarBase), { 'class-name': [
1531
+ {
1532
+ pattern: /(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,
1533
+ lookbehind: true,
1534
+ greedy: true,
1535
+ inside: {
1536
+ punctuation: { pattern: /[<>.,]/ },
1537
+ },
1538
+ },
1539
+ ], 'builtin': {
1540
+ pattern: /\b(?:Array|Boolean|Date|Function|Map|Number|Object|Promise|RegExp|Set|String|WeakMap|WeakSet|bigint|boolean|never|null|number|string|symbol|undefined|unknown|void)\b/,
1541
+ }, 'keyword': [
1542
+ {
1543
+ pattern: /\b(?:abstract|as|asserts|async|await|break|case|catch|class|const|constructor|continue|debugger|declare|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|infer|instanceof|interface|is|keyof|let|module|namespace|new|null|of|package|private|protected|public|readonly|return|require|set|static|super|switch|this|throw|try|type|typeof|undefined|var|void|while|with|yield)\b/,
1544
+ },
1545
+ ], 'function': jsFunction, 'generic-function': {
1546
+ pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,
1547
+ greedy: true,
1548
+ inside: {
1549
+ function: {
1550
+ pattern: /^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,
1551
+ },
1552
+ generic: {
1553
+ pattern: /<[\s\S]+/,
1554
+ inside: {
1555
+ punctuation: { pattern: /[<>(),.]/ },
1556
+ keyword: { pattern: /\b(?:extends|infer|keyof)\b/ },
1557
+ builtin: {
1558
+ pattern: /\b(?:boolean|never|null|number|string|symbol|undefined|unknown|void)\b/,
1559
+ },
1560
+ },
1561
+ },
1562
+ },
1563
+ }, 'operator': {
1564
+ pattern: /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%|&^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]|!(?=\s*[^=])/,
1565
+ }, 'punctuation': jsPunctuation });
3232
1566
 
3233
- Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] =
3234
- Prism.languages.markup['entity'];
3235
- Prism.languages.markup['doctype'].inside['internal-subset'].inside = Prism.languages.markup;
3236
-
3237
- // Plugin to make entity title show the real entity, idea by Roman Komarov
3238
- Prism.hooks.add('wrap', function (env) {
3239
-
3240
- if (env.type === 'entity') {
3241
- env.attributes['title'] = env.content.replace(/&amp;/, '&');
3242
- }
3243
- });
3244
-
3245
- Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
3246
- /**
3247
- * Adds an inlined language to markup.
3248
- *
3249
- * An example of an inlined language is CSS with `<style>` tags.
3250
- *
3251
- * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
3252
- * case insensitive.
3253
- * @param {string} lang The language key.
3254
- * @example
3255
- * addInlined('style', 'css');
3256
- */
3257
- value: function addInlined(tagName, lang) {
3258
- var includedCdataInside = {};
3259
- includedCdataInside['language-' + lang] = {
3260
- pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
3261
- lookbehind: true,
3262
- inside: Prism.languages[lang]
3263
- };
3264
- includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i;
3265
-
3266
- var inside = {
3267
- 'included-cdata': {
3268
- pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
3269
- inside: includedCdataInside
3270
- }
3271
- };
3272
- inside['language-' + lang] = {
3273
- pattern: /[\s\S]+/,
3274
- inside: Prism.languages[lang]
3275
- };
3276
-
3277
- var def = {};
3278
- def[tagName] = {
3279
- pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () { return tagName; }), 'i'),
3280
- lookbehind: true,
3281
- greedy: true,
3282
- inside: inside
3283
- };
3284
-
3285
- Prism.languages.insertBefore('markup', 'cdata', def);
3286
- }
3287
- });
3288
- Object.defineProperty(Prism.languages.markup.tag, 'addAttribute', {
3289
- /**
3290
- * Adds an pattern to highlight languages embedded in HTML attributes.
3291
- *
3292
- * An example of an inlined language is CSS with `style` attributes.
3293
- *
3294
- * @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as
3295
- * case insensitive.
3296
- * @param {string} lang The language key.
3297
- * @example
3298
- * addAttribute('style', 'css');
3299
- */
3300
- value: function (attrName, lang) {
3301
- Prism.languages.markup.tag.inside['special-attr'].push({
3302
- pattern: RegExp(
3303
- /(^|["'\s])/.source + '(?:' + attrName + ')' + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
3304
- 'i'
3305
- ),
3306
- lookbehind: true,
3307
- inside: {
3308
- 'attr-name': /^[^\s=]+/,
3309
- 'attr-value': {
3310
- pattern: /=[\s\S]+/,
3311
- inside: {
3312
- 'value': {
3313
- pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
3314
- lookbehind: true,
3315
- alias: [lang, 'language-' + lang],
3316
- inside: Prism.languages[lang]
3317
- },
3318
- 'punctuation': [
3319
- {
3320
- pattern: /^=/,
3321
- alias: 'attr-equals'
3322
- },
3323
- /"|'/
3324
- ]
3325
- }
3326
- }
3327
- }
3328
- });
3329
- }
3330
- });
3331
-
3332
- Prism.languages.html = Prism.languages.markup;
3333
- Prism.languages.mathml = Prism.languages.markup;
3334
- Prism.languages.svg = Prism.languages.markup;
3335
-
3336
- Prism.languages.xml = Prism.languages.extend('markup', {});
3337
- Prism.languages.ssml = Prism.languages.xml;
3338
- Prism.languages.atom = Prism.languages.xml;
3339
- Prism.languages.rss = Prism.languages.xml;
3340
-
3341
- Prism.languages.c = Prism.languages.extend('clike', {
3342
- 'comment': {
3343
- pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,
3344
- greedy: true
3345
- },
3346
- 'string': {
3347
- // https://en.cppreference.com/w/c/language/string_literal
3348
- pattern: /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,
3349
- greedy: true
3350
- },
3351
- 'class-name': {
3352
- pattern: /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,
3353
- lookbehind: true
3354
- },
3355
- 'keyword': /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,
3356
- 'function': /\b[a-z_]\w*(?=\s*\()/i,
3357
- 'number': /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,
3358
- 'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/
3359
- });
3360
-
3361
- Prism.languages.insertBefore('c', 'string', {
3362
- 'char': {
3363
- // https://en.cppreference.com/w/c/language/character_constant
3364
- pattern: /'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,
3365
- greedy: true
3366
- }
3367
- });
3368
-
3369
- Prism.languages.insertBefore('c', 'string', {
3370
- 'macro': {
3371
- // allow for multiline macro definitions
3372
- // spaces after the # character compile fine with gcc
3373
- pattern: /(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,
3374
- lookbehind: true,
3375
- greedy: true,
3376
- alias: 'property',
3377
- inside: {
3378
- 'string': [
3379
- {
3380
- // highlight the path of the include statement as a string
3381
- pattern: /^(#\s*include\s*)<[^>]+>/,
3382
- lookbehind: true
3383
- },
3384
- Prism.languages.c['string']
3385
- ],
3386
- 'char': Prism.languages.c['char'],
3387
- 'comment': Prism.languages.c['comment'],
3388
- 'macro-name': [
3389
- {
3390
- pattern: /(^#\s*define\s+)\w+\b(?!\()/i,
3391
- lookbehind: true
3392
- },
3393
- {
3394
- pattern: /(^#\s*define\s+)\w+\b(?=\()/i,
3395
- lookbehind: true,
3396
- alias: 'function'
3397
- }
3398
- ],
3399
- // highlight macro directives as keywords
3400
- 'directive': {
3401
- pattern: /^(#\s*)[a-z]+/,
3402
- lookbehind: true,
3403
- alias: 'keyword'
3404
- },
3405
- 'directive-hash': /^#/,
3406
- 'punctuation': /##|\\(?=[\r\n])/,
3407
- 'expression': {
3408
- pattern: /\S[\s\S]*/,
3409
- inside: Prism.languages.c
3410
- }
3411
- }
3412
- }
3413
- });
3414
-
3415
- Prism.languages.insertBefore('c', 'function', {
3416
- // highlight predefined macros as constants
3417
- 'constant': /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/
3418
- });
3419
-
3420
- delete Prism.languages.c['boolean'];
3421
-
3422
- (function (Prism) {
3423
-
3424
- var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
3425
-
3426
- Prism.languages.css = {
3427
- 'comment': /\/\*[\s\S]*?\*\//,
3428
- 'atrule': {
3429
- pattern: RegExp('@[\\w-](?:' + /[^;{\s"']|\s+(?!\s)/.source + '|' + string.source + ')*?' + /(?:;|(?=\s*\{))/.source),
3430
- inside: {
3431
- 'rule': /^@[\w-]+/,
3432
- 'selector-function-argument': {
3433
- pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
3434
- lookbehind: true,
3435
- alias: 'selector'
3436
- },
3437
- 'keyword': {
3438
- pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
3439
- lookbehind: true
3440
- }
3441
- // See rest below
3442
- }
3443
- },
3444
- 'url': {
3445
- // https://drafts.csswg.org/css-values-3/#urls
3446
- pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'),
3447
- greedy: true,
3448
- inside: {
3449
- 'function': /^url/i,
3450
- 'punctuation': /^\(|\)$/,
3451
- 'string': {
3452
- pattern: RegExp('^' + string.source + '$'),
3453
- alias: 'url'
3454
- }
3455
- }
3456
- },
3457
- 'selector': {
3458
- pattern: RegExp('(^|[{}\\s])[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + string.source + ')*(?=\\s*\\{)'),
3459
- lookbehind: true
3460
- },
3461
- 'string': {
3462
- pattern: string,
3463
- greedy: true
3464
- },
3465
- 'property': {
3466
- pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
3467
- lookbehind: true
3468
- },
3469
- 'important': /!important\b/i,
3470
- 'function': {
3471
- pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
3472
- lookbehind: true
3473
- },
3474
- 'punctuation': /[(){};:,]/
3475
- };
3476
-
3477
- Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
3478
-
3479
- var markup = Prism.languages.markup;
3480
- if (markup) {
3481
- markup.tag.addInlined('style', 'css');
3482
- markup.tag.addAttribute('style', 'css');
3483
- }
3484
-
3485
- }(Prism));
3486
-
3487
- (function (Prism) {
3488
-
3489
- Prism.languages.typescript = Prism.languages.extend('javascript', {
3490
- 'class-name': {
3491
- pattern: /(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,
3492
- lookbehind: true,
3493
- greedy: true,
3494
- inside: null // see below
3495
- },
3496
- 'builtin': /\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/,
3497
- });
3498
-
3499
- // The keywords TypeScript adds to JavaScript
3500
- Prism.languages.typescript.keyword.push(
3501
- /\b(?:abstract|declare|is|keyof|readonly|require)\b/,
3502
- // keywords that have to be followed by an identifier
3503
- /\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,
3504
- // This is for `import type *, {}`
3505
- /\btype\b(?=\s*(?:[\{*]|$))/
3506
- );
3507
-
3508
- // doesn't work with TS because TS is too complex
3509
- delete Prism.languages.typescript['parameter'];
3510
- delete Prism.languages.typescript['literal-property'];
3511
-
3512
- // a version of typescript specifically for highlighting types
3513
- var typeInside = Prism.languages.extend('typescript', {});
3514
- delete typeInside['class-name'];
3515
-
3516
- Prism.languages.typescript['class-name'].inside = typeInside;
3517
-
3518
- Prism.languages.insertBefore('typescript', 'function', {
3519
- 'decorator': {
3520
- pattern: /@[$\w\xA0-\uFFFF]+/,
3521
- inside: {
3522
- 'at': {
3523
- pattern: /^@/,
3524
- alias: 'operator'
3525
- },
3526
- 'function': /^[\s\S]+/
3527
- }
3528
- },
3529
- 'generic-function': {
3530
- // e.g. foo<T extends "bar" | "baz">( ...
3531
- pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,
3532
- greedy: true,
3533
- inside: {
3534
- 'function': /^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,
3535
- 'generic': {
3536
- pattern: /<[\s\S]+/, // everything after the first <
3537
- alias: 'class-name',
3538
- inside: typeInside
3539
- }
3540
- }
3541
- }
3542
- });
3543
-
3544
- Prism.languages.ts = Prism.languages.typescript;
3545
-
3546
- }(Prism));
3547
-
3548
- (function (Prism) {
3549
-
3550
- var javascript = Prism.util.clone(Prism.languages.javascript);
3551
-
3552
- var space = /(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))\*\/)/.source;
3553
- var braces = /(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])*\})/.source;
3554
- var spread = /(?:\{<S>*\.{3}(?:[^{}]|<BRACES>)*\})/.source;
3555
-
3556
- /**
3557
- * @param {string} source
3558
- * @param {string} [flags]
3559
- */
3560
- function re(source, flags) {
3561
- source = source
3562
- .replace(/<S>/g, function () { return space; })
3563
- .replace(/<BRACES>/g, function () { return braces; })
3564
- .replace(/<SPREAD>/g, function () { return spread; });
3565
- return RegExp(source, flags);
3566
- }
3567
-
3568
- spread = re(spread).source;
3569
-
3570
-
3571
- Prism.languages.jsx = Prism.languages.extend('markup', javascript);
3572
- Prism.languages.jsx.tag.pattern = re(
3573
- /<\/?(?:[\w.:-]+(?:<S>+(?:[\w.:$-]+(?:=(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\/?)?>/.source
3574
- );
3575
-
3576
- Prism.languages.jsx.tag.inside['tag'].pattern = /^<\/?[^\s>\/]*/;
3577
- Prism.languages.jsx.tag.inside['attr-value'].pattern = /=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/;
3578
- Prism.languages.jsx.tag.inside['tag'].inside['class-name'] = /^[A-Z]\w*(?:\.[A-Z]\w*)*$/;
3579
- Prism.languages.jsx.tag.inside['comment'] = javascript['comment'];
3580
-
3581
- Prism.languages.insertBefore('inside', 'attr-name', {
3582
- 'spread': {
3583
- pattern: re(/<SPREAD>/.source),
3584
- inside: Prism.languages.jsx
3585
- }
3586
- }, Prism.languages.jsx.tag);
3587
-
3588
- Prism.languages.insertBefore('inside', 'special-attr', {
3589
- 'script': {
3590
- // Allow for two levels of nesting
3591
- pattern: re(/=<BRACES>/.source),
3592
- alias: 'language-javascript',
3593
- inside: {
3594
- 'script-punctuation': {
3595
- pattern: /^=(?=\{)/,
3596
- alias: 'punctuation'
3597
- },
3598
- rest: Prism.languages.jsx
3599
- },
3600
- }
3601
- }, Prism.languages.jsx.tag);
3602
-
3603
- // The following will handle plain text inside tags
3604
- var stringifyToken = function (token) {
3605
- if (!token) {
3606
- return '';
3607
- }
3608
- if (typeof token === 'string') {
3609
- return token;
3610
- }
3611
- if (typeof token.content === 'string') {
3612
- return token.content;
3613
- }
3614
- return token.content.map(stringifyToken).join('');
3615
- };
3616
-
3617
- var walkTokens = function (tokens) {
3618
- var openedTags = [];
3619
- for (var i = 0; i < tokens.length; i++) {
3620
- var token = tokens[i];
3621
- var notTagNorBrace = false;
3622
-
3623
- if (typeof token !== 'string') {
3624
- if (token.type === 'tag' && token.content[0] && token.content[0].type === 'tag') {
3625
- // We found a tag, now find its kind
3626
-
3627
- if (token.content[0].content[0].content === '</') {
3628
- // Closing tag
3629
- if (openedTags.length > 0 && openedTags[openedTags.length - 1].tagName === stringifyToken(token.content[0].content[1])) {
3630
- // Pop matching opening tag
3631
- openedTags.pop();
3632
- }
3633
- } else {
3634
- if (token.content[token.content.length - 1].content === '/>') ; else {
3635
- // Opening tag
3636
- openedTags.push({
3637
- tagName: stringifyToken(token.content[0].content[1]),
3638
- openedBraces: 0
3639
- });
3640
- }
3641
- }
3642
- } else if (openedTags.length > 0 && token.type === 'punctuation' && token.content === '{') {
3643
-
3644
- // Here we might have entered a JSX context inside a tag
3645
- openedTags[openedTags.length - 1].openedBraces++;
3646
-
3647
- } else if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces > 0 && token.type === 'punctuation' && token.content === '}') {
3648
-
3649
- // Here we might have left a JSX context inside a tag
3650
- openedTags[openedTags.length - 1].openedBraces--;
3651
-
3652
- } else {
3653
- notTagNorBrace = true;
3654
- }
3655
- }
3656
- if (notTagNorBrace || typeof token === 'string') {
3657
- if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces === 0) {
3658
- // Here we are inside a tag, and not inside a JSX context.
3659
- // That's plain text: drop any tokens matched.
3660
- var plainText = stringifyToken(token);
3661
-
3662
- // And merge text with adjacent text
3663
- if (i < tokens.length - 1 && (typeof tokens[i + 1] === 'string' || tokens[i + 1].type === 'plain-text')) {
3664
- plainText += stringifyToken(tokens[i + 1]);
3665
- tokens.splice(i + 1, 1);
3666
- }
3667
- if (i > 0 && (typeof tokens[i - 1] === 'string' || tokens[i - 1].type === 'plain-text')) {
3668
- plainText = stringifyToken(tokens[i - 1]) + plainText;
3669
- tokens.splice(i - 1, 1);
3670
- i--;
3671
- }
3672
-
3673
- tokens[i] = new Prism.Token('plain-text', plainText, null, plainText);
3674
- }
3675
- }
3676
-
3677
- if (token.content && typeof token.content !== 'string') {
3678
- walkTokens(token.content);
3679
- }
3680
- }
3681
- };
3682
-
3683
- Prism.hooks.add('after-tokenize', function (env) {
3684
- if (env.language !== 'jsx' && env.language !== 'tsx') {
3685
- return;
3686
- }
3687
- walkTokens(env.tokens);
3688
- });
3689
-
3690
- }(Prism));
3691
-
3692
- (function (Prism) {
3693
- var typescript = Prism.util.clone(Prism.languages.typescript);
3694
- Prism.languages.tsx = Prism.languages.extend('jsx', typescript);
1567
+ /**
1568
+ * Grammar definition for JSX syntax highlighting.
1569
+ * Extends JavaScript grammar with JSX tag syntax for React components,
1570
+ * including self-closing tags, expressions in braces, and embedded markup attributes.
1571
+ */
1572
+ const jsxGrammar = Object.assign(Object.assign({
1573
+ // Tag must come before JS spread so operator pattern doesn't consume < and >
1574
+ tag: {
1575
+ pattern: /<\/?(?:[\w.:-]+(?:\s+(?:[\w.:$-]+(?:=(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])+\}))?|\{\.{3}[a-z_$][\w$]*(?:\.[\w$]+)*\}))*\s*\/?)?>/i,
1576
+ greedy: true,
1577
+ inside: {
1578
+ 'tag': {
1579
+ pattern: /^<\/?[^\s>/]*/,
1580
+ inside: {
1581
+ punctuation: { pattern: /^<\/?/ },
1582
+ namespace: { pattern: /^[^\s>/:]+:/ },
1583
+ },
1584
+ },
1585
+ 'attr-value': {
1586
+ pattern: /=\s*(?:"[^"]*"|'[^']*'|\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])+\})/,
1587
+ inside: {
1588
+ punctuation: [{ pattern: /^=/ }, { pattern: /^(\s*)["'{]|[}"']$/, lookbehind: true }],
1589
+ script: {
1590
+ pattern: /[\s\S]+/,
1591
+ inside: javascriptGrammar,
1592
+ },
1593
+ },
1594
+ },
1595
+ 'spread': {
1596
+ pattern: /\{\.{3}[a-z_$][\w$]*(?:\.[\w$]+)*\}/,
1597
+ inside: {
1598
+ 'punctuation': { pattern: /^\{\.{3}|\}$/ },
1599
+ 'attr-name': { pattern: /[\s\S]+/ },
1600
+ },
1601
+ },
1602
+ 'attr-name': {
1603
+ pattern: /[^\s>/]+/,
1604
+ inside: {
1605
+ namespace: { pattern: /^[^\s>/:]+:/ },
1606
+ },
1607
+ },
1608
+ 'punctuation': { pattern: /\/?>/ },
1609
+ },
1610
+ } }, javascriptGrammar), { entity: markupGrammar.entity });
3695
1611
 
3696
- // doesn't work with TS because TS is too complex
3697
- delete Prism.languages.tsx['parameter'];
3698
- delete Prism.languages.tsx['literal-property'];
1612
+ /**
1613
+ * Grammar definition for TSX (TypeScript + JSX) syntax highlighting.
1614
+ * Merges TypeScript and JSX grammars, supporting both type annotations
1615
+ * and JSX tag syntax in the same file.
1616
+ */
1617
+ const tsxGrammar = Object.assign(Object.assign({
1618
+ // Tag must come before TS spread so operator pattern doesn't consume < and >
1619
+ tag: jsxGrammar['tag'] }, typescriptGrammar), { entity: jsxGrammar['entity'] });
3699
1620
 
3700
- // This will prevent collisions between TSX tags and TS generic types.
3701
- // Idea by https://github.com/karlhorky
3702
- // Discussion: https://github.com/PrismJS/prism/issues/2594#issuecomment-710666928
3703
- var tag = Prism.languages.tsx.tag;
3704
- tag.pattern = RegExp(/(^|[^\w$]|(?=<\/))/.source + '(?:' + tag.pattern.source + ')', tag.pattern.flags);
3705
- tag.lookbehind = true;
3706
- }(Prism));
1621
+ /**
1622
+ * A registry that maps language identifiers to their grammar definitions.
1623
+ * Supports common aliases (e.g., 'html' -> markup, 'js' -> javascript).
1624
+ *
1625
+ * The registry provides grammars for:
1626
+ * - CSS
1627
+ * - HTML / Markup
1628
+ * - JavaScript (JS)
1629
+ * - TypeScript (TS)
1630
+ * - JSX
1631
+ * - TSX
1632
+ * - C / C-like (falls back to JavaScript grammar for basic C-family highlighting)
1633
+ */
1634
+ const languageRegistry = {
1635
+ css: cssGrammar,
1636
+ html: markupGrammar,
1637
+ markup: markupGrammar,
1638
+ javascript: javascriptGrammar,
1639
+ js: javascriptGrammar,
1640
+ typescript: typescriptGrammar,
1641
+ ts: typescriptGrammar,
1642
+ jsx: jsxGrammar,
1643
+ tsx: tsxGrammar,
1644
+ c: javascriptGrammar,
1645
+ clike: javascriptGrammar,
1646
+ };
1647
+ /**
1648
+ * Retrieve the grammar for a given language identifier.
1649
+ *
1650
+ * @param {string} language - The language identifier (e.g., 'js', 'css', 'html', 'ts', 'jsx', 'tsx').
1651
+ * @returns {Grammar | undefined} The grammar definition, or undefined if the language is not registered.
1652
+ */
1653
+ function getLanguageGrammar(language) {
1654
+ return languageRegistry[language];
1655
+ }
3707
1656
 
3708
1657
  var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
3709
1658
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -3792,7 +1741,7 @@ __decorate$4([
3792
1741
  ], CodeHighlightParser.prototype, "value", void 0);
3793
1742
 
3794
1743
  /**
3795
- * Use the plugin Prism to highlight the code content.
1744
+ * Use the local syntax highlight tokenizer to highlight the code content.
3796
1745
  */
3797
1746
  class PrismCodeHighlightParseController extends CodeHighlightParser {
3798
1747
  /**
@@ -3805,15 +1754,15 @@ class PrismCodeHighlightParseController extends CodeHighlightParser {
3805
1754
  return code && language && this.isHighlightLanguage(language);
3806
1755
  }
3807
1756
  /**
3808
- * Use plugin to parse the string code into an array of nodes with different keywords.
1757
+ * Use tokenizer to parse the string code into an array of nodes with different keywords.
3809
1758
  *
3810
1759
  * @returns {CodeNodeType[]} - The object contains content and highlight type.
3811
1760
  */
3812
1761
  parse() {
3813
1762
  const { code, language } = this.value;
3814
1763
  let result = [];
3815
- const parseLanguage = prism.languages[language];
3816
- const tokens = prism.tokenize(code, parseLanguage);
1764
+ const parseLanguage = getLanguageGrammar(language);
1765
+ const tokens = tokenize(code, parseLanguage);
3817
1766
  result = this.getHighlightNodes(tokens);
3818
1767
  return this.markLineNumberNodes(result);
3819
1768
  }