@oneuptime/common 14.0.109 → 14.0.110

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 (285) hide show
  1. package/Models/AnalyticsModels/SecurityEvent.js +1 -1
  2. package/Models/DatabaseModels/AIInsight.js +2 -2
  3. package/Models/DatabaseModels/Alert.js +2 -2
  4. package/Models/DatabaseModels/AlertEpisode.js +2 -2
  5. package/Models/DatabaseModels/AlertEpisodeOnCallRule.js +3 -3
  6. package/Models/DatabaseModels/AlertGroupingRule.d.mts +1 -0
  7. package/Models/DatabaseModels/AlertGroupingRule.d.ts +1 -0
  8. package/Models/DatabaseModels/AlertGroupingRule.js +48 -2
  9. package/Models/DatabaseModels/AlertOnCallRule.js +3 -3
  10. package/Models/DatabaseModels/AlertSeverity.js +13 -4
  11. package/Models/DatabaseModels/AlertState.js +1 -1
  12. package/Models/DatabaseModels/CallLog.js +12 -12
  13. package/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel.d.mts +2 -0
  14. package/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel.d.ts +2 -0
  15. package/Models/DatabaseModels/EmailLog.js +12 -12
  16. package/Models/DatabaseModels/FormSubmission.js +2 -2
  17. package/Models/DatabaseModels/GlobalConfig.d.mts +1 -0
  18. package/Models/DatabaseModels/GlobalConfig.d.ts +1 -0
  19. package/Models/DatabaseModels/GlobalConfig.js +28 -0
  20. package/Models/DatabaseModels/Incident.js +2 -2
  21. package/Models/DatabaseModels/IncidentEpisode.js +2 -2
  22. package/Models/DatabaseModels/IncidentEpisodeOnCallRule.js +3 -3
  23. package/Models/DatabaseModels/IncidentGroupingRule.d.mts +1 -0
  24. package/Models/DatabaseModels/IncidentGroupingRule.d.ts +1 -0
  25. package/Models/DatabaseModels/IncidentGroupingRule.js +48 -2
  26. package/Models/DatabaseModels/IncidentOnCallRule.js +3 -3
  27. package/Models/DatabaseModels/IncidentSeverity.js +13 -4
  28. package/Models/DatabaseModels/IncidentState.js +1 -1
  29. package/Models/DatabaseModels/IncidentTemplate.js +2 -2
  30. package/Models/DatabaseModels/Monitor.js +3 -3
  31. package/Models/DatabaseModels/NetworkDevice.d.mts +1 -0
  32. package/Models/DatabaseModels/NetworkDevice.d.ts +1 -0
  33. package/Models/DatabaseModels/NetworkDevice.js +41 -0
  34. package/Models/DatabaseModels/OnCallDutyPolicy.js +4 -2
  35. package/Models/DatabaseModels/OnCallDutyPolicyEscalationRule.js +1 -1
  36. package/Models/DatabaseModels/OnCallDutyPolicyEscalationRuleSchedule.js +8 -5
  37. package/Models/DatabaseModels/OnCallDutyPolicyEscalationRuleTeam.js +5 -2
  38. package/Models/DatabaseModels/OnCallDutyPolicyEscalationRuleUser.js +5 -2
  39. package/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.js +9 -6
  40. package/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.js +10 -7
  41. package/Models/DatabaseModels/OnCallDutyPolicyFeed.js +14 -11
  42. package/Models/DatabaseModels/OnCallDutyPolicyOwnerTeam.js +7 -4
  43. package/Models/DatabaseModels/OnCallDutyPolicyOwnerUser.js +7 -4
  44. package/Models/DatabaseModels/OnCallDutyPolicySchedule.js +6 -3
  45. package/Models/DatabaseModels/OnCallDutyPolicyScheduleCalendarFeed.js +4 -4
  46. package/Models/DatabaseModels/OnCallDutyPolicyScheduleLayer.js +3 -3
  47. package/Models/DatabaseModels/OnCallDutyPolicyScheduleLayerUser.js +6 -6
  48. package/Models/DatabaseModels/OnCallDutyPolicyTimeLog.js +9 -6
  49. package/Models/DatabaseModels/Project.d.mts +2 -0
  50. package/Models/DatabaseModels/Project.d.ts +2 -0
  51. package/Models/DatabaseModels/Project.js +96 -2
  52. package/Models/DatabaseModels/ProxmoxCluster.d.mts +1 -0
  53. package/Models/DatabaseModels/ProxmoxCluster.d.ts +1 -0
  54. package/Models/DatabaseModels/ProxmoxCluster.js +52 -3
  55. package/Models/DatabaseModels/PushNotificationLog.js +12 -12
  56. package/Models/DatabaseModels/Reseller.js +8 -2
  57. package/Models/DatabaseModels/ResellerPlan.js +8 -2
  58. package/Models/DatabaseModels/ScheduledMaintenance.js +6 -3
  59. package/Models/DatabaseModels/ScheduledMaintenanceInternalNote.js +7 -4
  60. package/Models/DatabaseModels/ScheduledMaintenanceMeasurementValue.js +2 -2
  61. package/Models/DatabaseModels/ScheduledMaintenancePublicNote.js +7 -4
  62. package/Models/DatabaseModels/ScheduledMaintenanceStateTimeline.js +1 -1
  63. package/Models/DatabaseModels/Service.js +1 -1
  64. package/Models/DatabaseModels/ServiceLevelObjectiveBurnRateRule.js +4 -4
  65. package/Models/DatabaseModels/ServiceLevelObjectiveErrorBudgetPolicyTier.js +4 -4
  66. package/Models/DatabaseModels/SmsLog.js +12 -12
  67. package/Models/DatabaseModels/StatusPage.js +5 -5
  68. package/Models/DatabaseModels/StatusPageSubscriber.js +2 -2
  69. package/Models/DatabaseModels/TelegramLog.js +12 -12
  70. package/Models/DatabaseModels/TelemetryIngestionKey.js +8 -5
  71. package/Models/DatabaseModels/TelemetryIngestionKeyRefusal.js +7 -4
  72. package/Models/DatabaseModels/User.d.mts +4 -0
  73. package/Models/DatabaseModels/User.d.ts +4 -0
  74. package/Models/DatabaseModels/User.js +100 -0
  75. package/Models/DatabaseModels/UserOnCallLog.js +6 -6
  76. package/Models/DatabaseModels/UserOnCallLogTimeline.js +3 -3
  77. package/Models/DatabaseModels/UserOnCallShiftReminderLog.js +2 -2
  78. package/Models/DatabaseModels/WebhookLog.js +12 -12
  79. package/Models/DatabaseModels/WhatsAppLog.js +12 -12
  80. package/Models/DatabaseModels/WorkspaceNotificationLog.js +12 -12
  81. package/Types/AI/AIChatTypes.d.mts +2 -1
  82. package/Types/AI/AIChatTypes.d.ts +2 -1
  83. package/Types/AI/AIChatTypes.js +5 -0
  84. package/Types/Analytics/ProductEvent.d.mts +6 -1
  85. package/Types/Analytics/ProductEvent.d.ts +6 -1
  86. package/Types/Analytics/ProductEvent.js +41 -0
  87. package/Types/AuditLog/AuditLogCoverage.d.mts +1 -0
  88. package/Types/AuditLog/AuditLogCoverage.d.ts +1 -0
  89. package/Types/AuditLog/AuditLogCoverage.js +4 -2
  90. package/Types/Cloud/CloudResourceCatalog.d.mts +2 -0
  91. package/Types/Cloud/CloudResourceCatalog.d.ts +2 -0
  92. package/Types/Cloud/CloudResourceCatalog.js +33 -3
  93. package/Types/Cloud/CloudResourceCatalog.mjs +1 -0
  94. package/Types/DataObservability/DataCheckSuggestions.d.mts +25 -0
  95. package/Types/DataObservability/DataCheckSuggestions.d.ts +25 -0
  96. package/Types/DataObservability/DataCheckSuggestions.js +102 -65
  97. package/Types/DataObservability/DataCheckSuggestions.mjs +1 -0
  98. package/Types/Database/TableMetadata.d.mts +2 -0
  99. package/Types/Database/TableMetadata.d.ts +2 -0
  100. package/Types/Database/TableMetadata.js +6 -0
  101. package/Types/Date.d.mts +20 -1
  102. package/Types/Date.d.ts +20 -1
  103. package/Types/Date.js +42 -2
  104. package/Types/DateLanguage.d.mts +2 -0
  105. package/Types/DateLanguage.d.ts +2 -0
  106. package/Types/DateLanguage.js +44 -2
  107. package/Types/DateLanguage.mjs +2 -0
  108. package/Types/DirectionArrow.d.mts +7 -0
  109. package/Types/DirectionArrow.d.ts +7 -0
  110. package/Types/DirectionArrow.js +88 -0
  111. package/Types/DirectionArrow.mjs +7 -0
  112. package/Types/Docs/GlossaryTerm.d.mts +1 -0
  113. package/Types/Docs/GlossaryTerm.d.ts +1 -0
  114. package/Types/Docs/GlossaryTerm.js +2 -0
  115. package/Types/Docs/RetiredNames.d.mts +11 -0
  116. package/Types/Docs/RetiredNames.d.ts +11 -0
  117. package/Types/Docs/RetiredNames.js +139 -0
  118. package/Types/Docs/RetiredNames.mjs +3 -0
  119. package/Types/Exception/RefusalWithValues.d.mts +7 -0
  120. package/Types/Exception/RefusalWithValues.d.ts +7 -0
  121. package/Types/Exception/RefusalWithValues.js +76 -0
  122. package/Types/Exception/RefusalWithValues.mjs +3 -0
  123. package/Types/Exception/UnexplainedError.d.mts +13 -0
  124. package/Types/Exception/UnexplainedError.d.ts +13 -0
  125. package/Types/Exception/UnexplainedError.js +53 -1
  126. package/Types/Exception/UnexplainedError.mjs +1 -0
  127. package/Types/File/FileSize.d.mts +4 -1
  128. package/Types/File/FileSize.d.ts +4 -1
  129. package/Types/File/FileSize.js +18 -17
  130. package/Types/HostCollector/HostCollector.d.mts +1 -0
  131. package/Types/HostCollector/HostCollector.d.ts +1 -0
  132. package/Types/HostCollector/HostCollector.js +26 -10
  133. package/Types/HostCollector/HostCollector.mjs +1 -0
  134. package/Types/Monitor/MonitorCriteria.js +2 -2
  135. package/Types/Monitor/MonitorStep.js +1 -1
  136. package/Types/Monitor/MonitorTemplateSyncField.d.mts +6 -0
  137. package/Types/Monitor/MonitorTemplateSyncField.d.ts +6 -0
  138. package/Types/Monitor/MonitorTemplateSyncField.js +106 -64
  139. package/Types/Monitor/NtpMonitor/NtpMonitorUtil.d.mts +1 -0
  140. package/Types/Monitor/NtpMonitor/NtpMonitorUtil.d.ts +1 -0
  141. package/Types/Monitor/NtpMonitor/NtpMonitorUtil.js +11 -3
  142. package/Types/Monitor/WhoIsTold.d.mts +3 -1
  143. package/Types/Monitor/WhoIsTold.d.ts +3 -1
  144. package/Types/Monitor/WhoIsTold.js +2 -1
  145. package/Types/NotificationRule/PagingLadder.d.mts +137 -0
  146. package/Types/NotificationRule/PagingLadder.d.ts +137 -0
  147. package/Types/NotificationRule/PagingLadder.js +682 -0
  148. package/Types/NotificationRule/PagingLadder.mjs +28 -0
  149. package/Types/NotificationSetting/NotificationEmailRollupCategory.js +1 -1
  150. package/Types/OnCallDutyPolicy/OnCallPageLine.d.mts +26 -0
  151. package/Types/OnCallDutyPolicy/OnCallPageLine.d.ts +26 -0
  152. package/Types/OnCallDutyPolicy/OnCallPageLine.js +136 -0
  153. package/Types/OnCallDutyPolicy/OnCallPageLine.mjs +18 -0
  154. package/Types/OnCallDutyPolicy/OnCallTestPage.d.mts +44 -0
  155. package/Types/OnCallDutyPolicy/OnCallTestPage.d.ts +44 -0
  156. package/Types/OnCallDutyPolicy/OnCallTestPage.js +96 -5
  157. package/Types/OnCallDutyPolicy/OnCallTestPage.mjs +1 -0
  158. package/Types/OnCallDutyPolicy/OnCallTestPageLine.d.mts +19 -0
  159. package/Types/OnCallDutyPolicy/OnCallTestPageLine.d.ts +19 -0
  160. package/Types/OnCallDutyPolicy/OnCallTestPageLine.js +222 -0
  161. package/Types/OnCallDutyPolicy/OnCallTestPageLine.mjs +6 -0
  162. package/Types/OnCallDutyPolicy/ScheduleLayerDefaults.js +5 -2
  163. package/Types/OnCallDutyPolicy/UserOverrideCoverRequest.js +9 -1
  164. package/Types/Permission.d.mts +2 -2
  165. package/Types/Permission.d.ts +2 -2
  166. package/Types/Permission.js +194 -193
  167. package/Types/Product/ProductCatalog.d.mts +10 -0
  168. package/Types/Product/ProductCatalog.d.ts +10 -0
  169. package/Types/Product/ProductCatalog.js +208 -0
  170. package/Types/Product/ProductCatalog.mjs +6 -0
  171. package/Types/Product/ProductOfTable.d.mts +3 -0
  172. package/Types/Product/ProductOfTable.d.ts +3 -0
  173. package/Types/Product/ProductOfTable.js +68 -0
  174. package/Types/Product/ProductOfTable.mjs +3 -0
  175. package/Types/Product/ProjectProductsAnswer.d.mts +3 -0
  176. package/Types/Product/ProjectProductsAnswer.d.ts +3 -0
  177. package/Types/Product/ProjectProductsAnswer.js +35 -2
  178. package/Types/Product/ProjectProductsAnswer.mjs +1 -0
  179. package/Types/Product/ServerProducts.d.mts +65 -0
  180. package/Types/Product/ServerProducts.d.ts +65 -0
  181. package/Types/Product/ServerProducts.js +383 -0
  182. package/Types/Product/ServerProducts.mjs +26 -0
  183. package/Types/Product/ServerProductsAnswer.d.mts +21 -0
  184. package/Types/Product/ServerProductsAnswer.d.ts +21 -0
  185. package/Types/Product/ServerProductsAnswer.js +78 -0
  186. package/Types/Product/ServerProductsAnswer.mjs +5 -0
  187. package/Types/ProductFeedback/ProductFeedback.d.mts +3 -1
  188. package/Types/ProductFeedback/ProductFeedback.d.ts +3 -1
  189. package/Types/ProductFeedback/ProductFeedback.js +8 -0
  190. package/Types/Rum/SessionReplayCustomEvents.d.mts +1 -0
  191. package/Types/Rum/SessionReplayCustomEvents.d.ts +1 -0
  192. package/Types/SampleProject/SampleProject.d.mts +54 -0
  193. package/Types/SampleProject/SampleProject.d.ts +54 -0
  194. package/Types/SampleProject/SampleProject.js +177 -0
  195. package/Types/SampleProject/SampleProject.mjs +22 -0
  196. package/Types/SampleProject/SampleProjectContent.d.mts +127 -0
  197. package/Types/SampleProject/SampleProjectContent.d.ts +127 -0
  198. package/Types/SampleProject/SampleProjectContent.js +397 -0
  199. package/Types/SampleProject/SampleProjectContent.mjs +18 -0
  200. package/Types/Telemetry/TelemetryIngestSurface.js +6 -5
  201. package/Types/Translator.d.mts +1 -0
  202. package/Types/Translator.d.ts +1 -0
  203. package/Types/Translator.js +40 -2
  204. package/Types/Translator.mjs +1 -0
  205. package/Types/UsedBy/UsedBy.d.mts +103 -0
  206. package/Types/UsedBy/UsedBy.d.ts +103 -0
  207. package/Types/UsedBy/UsedBy.js +389 -0
  208. package/Types/UsedBy/UsedBy.mjs +20 -0
  209. package/Types/UsedBy/UsedByServerProducts.d.mts +4 -0
  210. package/Types/UsedBy/UsedByServerProducts.d.ts +4 -0
  211. package/Types/UsedBy/UsedByServerProducts.js +48 -0
  212. package/Types/UsedBy/UsedByServerProducts.mjs +3 -0
  213. package/Types/WelcomeChecklist/WelcomeChecklist.d.mts +6 -0
  214. package/Types/WelcomeChecklist/WelcomeChecklist.d.ts +6 -0
  215. package/Types/WelcomeChecklist/WelcomeChecklist.js +54 -2
  216. package/Types/WelcomeChecklist/WelcomeChecklist.mjs +4 -0
  217. package/Types/WelcomeChecklist/WelcomeChecklistAnswer.d.mts +1 -0
  218. package/Types/WelcomeChecklist/WelcomeChecklistAnswer.d.ts +1 -0
  219. package/Types/WelcomeChecklist/WelcomeChecklistAnswer.js +3 -0
  220. package/Types/Workflow/PassedOnFields.js +2 -1
  221. package/Types/Workflow/Templates.js +1 -1
  222. package/Types/Workspace/NotificationRules/NotificationRuleCondition.d.mts +2 -0
  223. package/Types/Workspace/NotificationRules/NotificationRuleCondition.d.ts +2 -0
  224. package/Utils/AI/MeaningMatch.d.mts +36 -0
  225. package/Utils/AI/MeaningMatch.d.ts +36 -0
  226. package/Utils/AI/MeaningMatch.js +535 -0
  227. package/Utils/AI/MeaningMatch.mjs +7 -0
  228. package/Utils/ArchivableValues.js +1 -1
  229. package/Utils/AuditLog/AuditLogValues.js +2 -2
  230. package/Utils/Dashboard/ClockWidgetFormat.d.mts +14 -2
  231. package/Utils/Dashboard/ClockWidgetFormat.d.ts +14 -2
  232. package/Utils/Dashboard/ClockWidgetFormat.js +105 -2
  233. package/Utils/Dashboard/DashboardViewConfigSignature.d.mts +3 -0
  234. package/Utils/Dashboard/DashboardViewConfigSignature.d.ts +3 -0
  235. package/Utils/Dashboard/DashboardViewConfigSignature.js +45 -0
  236. package/Utils/Dashboard/DashboardViewConfigSignature.mjs +3 -0
  237. package/Utils/DataSecurity/TextScanner.js +2 -2
  238. package/Utils/DeveloperDocs/AiAssistantExamples.js +4 -4
  239. package/Utils/DeveloperDocs/CliCommands.d.mts +1 -0
  240. package/Utils/DeveloperDocs/CliCommands.d.ts +1 -0
  241. package/Utils/DeveloperDocs/CliCommands.js +2 -1
  242. package/Utils/DeveloperDocs/CliResources.js +2 -1
  243. package/Utils/DeveloperDocs/TerraformSchema.js +3 -1
  244. package/Utils/Markdown/LinkReferenceDefinitions.d.mts +8 -0
  245. package/Utils/Markdown/LinkReferenceDefinitions.d.ts +8 -0
  246. package/Utils/Markdown/LinkReferenceDefinitions.js +1493 -131
  247. package/Utils/Markdown/LinkReferenceDefinitions.mjs +1 -0
  248. package/Utils/Markdown/MarkdownTableCell.js +2 -1
  249. package/Utils/Markdown/OverLongText.js +523 -5
  250. package/Utils/Markdown/SlowMarkdown.d.mts +14 -0
  251. package/Utils/Markdown/SlowMarkdown.d.ts +14 -0
  252. package/Utils/Markdown/SlowMarkdown.js +595 -11
  253. package/Utils/Markdown/SlowMarkdown.mjs +6 -0
  254. package/Utils/ModelApiName.d.mts +11 -0
  255. package/Utils/ModelApiName.d.ts +11 -0
  256. package/Utils/ModelApiName.js +72 -0
  257. package/Utils/ModelApiName.mjs +5 -0
  258. package/Utils/Monitor/DeviceMacLearningUtil.d.mts +2 -1
  259. package/Utils/Monitor/DeviceMacLearningUtil.d.ts +2 -1
  260. package/Utils/Monitor/DeviceMacLearningUtil.js +26 -0
  261. package/Utils/Monitor/EndpointAttachmentUtil.js +8 -3
  262. package/Utils/Monitor/ExternalStatusPageReading.d.mts +3 -0
  263. package/Utils/Monitor/ExternalStatusPageReading.d.ts +3 -0
  264. package/Utils/Monitor/ExternalStatusPageReading.js +35 -1
  265. package/Utils/Monitor/ExternalStatusPageReading.mjs +2 -0
  266. package/Utils/Monitor/MonitorTemplateLinkRefusal.d.mts +9 -0
  267. package/Utils/Monitor/MonitorTemplateLinkRefusal.d.ts +9 -0
  268. package/Utils/Monitor/MonitorTemplateLinkRefusal.js +45 -0
  269. package/Utils/Monitor/MonitorTemplateLinkRefusal.mjs +6 -0
  270. package/Utils/OpenStack/OpenStackCheckName.js +2 -1
  271. package/Utils/OpenStack/OpenStackLogScrub.js +1 -1
  272. package/Utils/OpenStack/OpenStackLogs.js +3 -2
  273. package/Utils/OpenStack/OpenStackTraces.js +2 -1
  274. package/Utils/Project/NotificationChannels.js +5 -5
  275. package/Utils/Project/ProjectBalance.js +2 -2
  276. package/Utils/Project/TwilioAccount.js +2 -2
  277. package/Utils/ScheduledMaintenanceStart.d.mts +3 -0
  278. package/Utils/ScheduledMaintenanceStart.d.ts +3 -0
  279. package/Utils/ScheduledMaintenanceStart.js +9 -0
  280. package/Utils/Schema/ModelSchema.js +10 -1
  281. package/Utils/Uptime/UptimeMaintenanceUtil.js +2 -1
  282. package/Utils/ValueFormatter.d.mts +8 -6
  283. package/Utils/ValueFormatter.d.ts +8 -6
  284. package/Utils/ValueFormatter.js +145 -0
  285. package/package.json +1 -1
@@ -41,6 +41,13 @@
41
41
  * every punctuation character of a word to its end. The runs of the
42
42
  * text together may cost limits.maxInlineWork; the costliest are held
43
43
  * back until they do.
44
+ * - for marked (limits.countAsMarked: the emails), each line as marked
45
+ * reads it (readMarkedLine, #7228): a link, an image or a reference
46
+ * whose label closes costs it a copy of its block, not a look through
47
+ * the rest of it; what a complete link's parentheses or a definition
48
+ * hold is read once; a "&" or a "]" costs nothing; and a run of an
49
+ * email address's characters before an "@" costs the run times itself
50
+ * and the domain after it.
44
51
  * - its lines: a run may have limits.maxRunLines, and all the runs and
45
52
  * fenced code read as Markdown limits.maxLines together (the dashboard
46
53
  * and Slack only: marked reads lines in linear time).
@@ -78,7 +85,8 @@
78
85
  * the text: the dashboard and the server both use it.
79
86
  */
80
87
  Object.defineProperty(exports, "__esModule", { value: true });
81
- exports.measureSlowMarkdownCodeBlocks = exports.measureSlowMarkdownRuns = exports.holdBackSlowMarkdown = exports.getWordPunctuationWork = exports.getInlineCharacterCount = exports.SLOW_MARKDOWN_MAX_NESTING_DEPTH = exports.SLOW_MARKDOWN_MAX_INLINE_WORK = exports.SLOW_MARKDOWN_MIN_LENGTH = void 0;
88
+ exports.measureSlowMarkdownCodeBlocks = exports.measureSlowMarkdownRuns = exports.holdBackSlowMarkdown = exports.getMarkedLineWork = exports.getMarkedDefinitionAddressStart = exports.getMarkedLinkEnd = exports.MARKED_TAIL_READING_SHARE = exports.MAX_MARKED_LABEL_LENGTH = exports.MARKED_MASKED_ITEM_SHARE = exports.getWordPunctuationWork = exports.getInlineCharacterCount = exports.SLOW_MARKDOWN_MAX_NESTING_DEPTH = exports.SLOW_MARKDOWN_MAX_INLINE_WORK = exports.SLOW_MARKDOWN_MIN_LENGTH = void 0;
89
+ const RegExpCharacterClasses_1 = require("../RegExpCharacterClasses");
82
90
  /*
83
91
  * Markdown of at most this many characters is given to a parser as it is:
84
92
  * its slowest shapes take a few hundredths of a second.
@@ -105,7 +113,20 @@ const PIPE = 0x7c;
105
113
  const BACKSLASH = 0x5c;
106
114
  const ASTERISK = 0x2a;
107
115
  const UNDERSCORE = 0x5f;
116
+ const OPEN_BRACKET = 0x5b;
117
+ const CLOSE_BRACKET = 0x5d;
118
+ const OPEN_PARENTHESIS = 0x28;
119
+ const CLOSE_PARENTHESIS = 0x29;
120
+ const COLON = 0x3a;
121
+ const QUOTATION_MARK = 0x22;
122
+ const APOSTROPHE = 0x27;
123
+ const AT_SIGN = 0x40;
124
+ const SLASH = 0x2f;
125
+ const EXCLAMATION_MARK = 0x21;
126
+ const QUESTION_MARK = 0x3f;
108
127
  const WORD_CHARACTER = /[\p{L}\p{N}]/u;
128
+ // What a backslash escapes for marked: punctuation or a symbol, any script.
129
+ const PUNCTUATION_OR_SYMBOL = /[\p{P}\p{S}]/u;
109
130
  const isSpaceOrTab = (code) => {
110
131
  return code === SPACE || code === TAB;
111
132
  };
@@ -254,6 +275,555 @@ const getWordPunctuationWork = (text, start, end) => {
254
275
  return work;
255
276
  };
256
277
  exports.getWordPunctuationWork = getWordPunctuationWork;
278
+ /*
279
+ * HOW MARKED READS A LINE (counting.countAsMarked: the emails, #7228).
280
+ *
281
+ * Measured on marked 12 where V8 compiles regular expressions unoptimized,
282
+ * some shapes that the other parsers look ahead through cost marked far
283
+ * less, and one costs it more:
284
+ *
285
+ * - A link, an image or a reference whose label closes - "[text](address)",
286
+ * "![alt][label]", "[label][]", "[label]" - marked reads up to its
287
+ * closing bracket. But before it reads a block it masks each of them,
288
+ * each "<...>" and each escape, with a copy of the block: so each costs
289
+ * a copy of its unit, which is a sixteenth of a look through it or less
290
+ * (MARKED_MASKED_ITEM_SHARE). A paragraph of 1,000 references, one on
291
+ * each line, took marked 9 ms; one of 18,724 (256 KB) took 5.5 s.
292
+ * - What a complete link's parentheses hold - its address and its title -
293
+ * and a definition marked takes, label and all, marked takes as one
294
+ * piece and never reads as inline Markdown: it is counted once, not as
295
+ * the punctuation of a word times the word's length. A link to a
296
+ * megabyte of a query took marked 65 ms.
297
+ * - A "&" and a "]" cost it no more than a letter: a megabyte of "&amp;"
298
+ * took 140 ms, of "]" 103 ms.
299
+ * - A run of the characters an email address can hold, right before an
300
+ * "@", marked reads from each of its characters to the "@" and through
301
+ * the domain after it: the run times itself and the domain. 64 KB of
302
+ * letters before an "@" took it 26 s.
303
+ *
304
+ * A bracket that does not close, or a link whose address or title does not
305
+ * close on its line, costs as it does for the other parsers - a look
306
+ * through the rest of its unit - as do emphasis, code spans, tags and the
307
+ * punctuation of words, and a link past what the tails of its line may
308
+ * read (MARKED_TAIL_READING_SHARE).
309
+ */
310
+ /*
311
+ * What a link, a reference, a "<...>" or an escape that marked masks costs
312
+ * it, as a share of a character it looks ahead from: a copy of the unit,
313
+ * where that character is a look through it. Measured, a copy cost from a
314
+ * fiftieth (references, in text of Latin letters) to a sixteenth (escapes
315
+ * of symbols, in text of other scripts) of a look.
316
+ */
317
+ exports.MARKED_MASKED_ITEM_SHARE = 16;
318
+ /*
319
+ * The longest label read as one that closes; past it a "[" counts as one
320
+ * that never does. A link label of CommonMark is at most 999 characters.
321
+ */
322
+ exports.MAX_MARKED_LABEL_LENGTH = 999;
323
+ const newUnitWork = () => {
324
+ return {
325
+ characters: 0,
326
+ maskedItems: 0,
327
+ work: 0,
328
+ isLessThanOpen: false,
329
+ mayDefine: true,
330
+ };
331
+ };
332
+ /*
333
+ * What marked reads as a character of an email address before its "@":
334
+ * ASCII letters, digits and .!#$%&'*+/=?_`{|}~-
335
+ */
336
+ const isMarkedEmailCode = (code) => {
337
+ return (isAsciiLetter(code) ||
338
+ isDigit(code) ||
339
+ (code >= 0x23 && code <= 0x27) ||
340
+ code === EXCLAMATION_MARK ||
341
+ code === ASTERISK ||
342
+ code === 0x2b ||
343
+ code === 0x2d ||
344
+ code === 0x2e ||
345
+ code === SLASH ||
346
+ code === 0x3d ||
347
+ code === QUESTION_MARK ||
348
+ code === UNDERSCORE ||
349
+ code === BACKTICK ||
350
+ (code >= 0x7b && code <= TILDE));
351
+ };
352
+ // What marked reads as a character of an email address's domain.
353
+ const isMarkedDomainCode = (code) => {
354
+ return (isAsciiLetter(code) ||
355
+ isDigit(code) ||
356
+ code === 0x2e ||
357
+ code === UNDERSCORE ||
358
+ code === 0x2d);
359
+ };
360
+ /*
361
+ * The code units of the character at `index` - after a "\" - when marked
362
+ * masks the escape (punctuation or a symbol, of any script), or 0.
363
+ */
364
+ const getEscapedLength = (text, index, end) => {
365
+ var _a;
366
+ if (index >= end) {
367
+ return 0;
368
+ }
369
+ const code = text.charCodeAt(index);
370
+ if (code < 0x80) {
371
+ return isAsciiPunctuation(code) ? 1 : 0;
372
+ }
373
+ const codePoint = (_a = text.codePointAt(index)) !== null && _a !== void 0 ? _a : code;
374
+ if (!PUNCTUATION_OR_SYMBOL.test(String.fromCodePoint(codePoint))) {
375
+ return 0;
376
+ }
377
+ return codePoint > 0xffff ? 2 : 1;
378
+ };
379
+ /*
380
+ * Where the label whose "[" is at `open` closes: the index of its "]" - or
381
+ * -1 when a "[", a backtick or the line's end comes first, or the label is
382
+ * longer than MAX_MARKED_LABEL_LENGTH. A "\" escapes the character after
383
+ * it. A code span inside a label can hold a "]" for marked, so a label
384
+ * with a backtick counts as one that never closes.
385
+ */
386
+ const readClosedLabel = (text, open, end) => {
387
+ const limit = Math.min(end, open + 2 + exports.MAX_MARKED_LABEL_LENGTH);
388
+ let index = open + 1;
389
+ while (index < limit) {
390
+ const code = text.charCodeAt(index);
391
+ if (code === CLOSE_BRACKET) {
392
+ return index;
393
+ }
394
+ if (code === OPEN_BRACKET || code === BACKTICK) {
395
+ return -1;
396
+ }
397
+ index += code === BACKSLASH ? 2 : 1;
398
+ }
399
+ return -1;
400
+ };
401
+ /*
402
+ * Where the title whose quote or "(" is at `open` ends - past its closing
403
+ * character - or -1 where it does not close on the line. A "\" escapes in
404
+ * every title of a link (`isInLink`); in a definition's, only in one in
405
+ * '"', and one in "()" holds no "(".
406
+ */
407
+ const readTitleEnd = (text, open, end, isInLink) => {
408
+ const opener = text.charCodeAt(open);
409
+ const closer = opener === OPEN_PARENTHESIS ? CLOSE_PARENTHESIS : opener;
410
+ const escapes = isInLink || opener === QUOTATION_MARK;
411
+ if (opener !== QUOTATION_MARK &&
412
+ opener !== APOSTROPHE &&
413
+ opener !== OPEN_PARENTHESIS) {
414
+ return -1;
415
+ }
416
+ let index = open + 1;
417
+ while (index < end) {
418
+ const code = text.charCodeAt(index);
419
+ if (code === BACKSLASH && escapes) {
420
+ index += 2;
421
+ continue;
422
+ }
423
+ if (code === closer) {
424
+ return index + 1;
425
+ }
426
+ if (code === OPEN_PARENTHESIS && opener === OPEN_PARENTHESIS && !isInLink) {
427
+ return -1;
428
+ }
429
+ index++;
430
+ }
431
+ return -1;
432
+ };
433
+ /*
434
+ * How much the link tails of a line may read (readLinkTail), as a multiple
435
+ * of the line. A tail that closes is read once - the line is read on from
436
+ * its end - but one whose address or title does not close is read again by
437
+ * each tail inside it: a line of 64 KB of "[a](" would cost the measure the
438
+ * square of the line - 2.9 s, and a megabyte of such lines 40 s. Past this
439
+ * a tail reads as one that does not close: a look through the rest of its
440
+ * unit, which only makes the line look costlier. Tails read more than
441
+ * their line only inside tails that do not close, which marked reads again
442
+ * for each of them too.
443
+ */
444
+ exports.MARKED_TAIL_READING_SHARE = 8;
445
+ /*
446
+ * Where the link whose "(" is at `open` - right after its label's "]" -
447
+ * ends as marked ends it: past the ")" after its address and title, or -1
448
+ * where they do not close on the line (marked can close them on a later
449
+ * line: counted as not closing, which only makes the line look costlier).
450
+ *
451
+ * The address is in "<>" - no "<" inside, a "\" escaping - or runs to
452
+ * white space or a control character, with its parentheses balanced: a ")"
453
+ * with none open ends the link. After white space, a title in '"', "'" or
454
+ * "()" may follow, then white space and the ")".
455
+ *
456
+ * Where white space comes before an address that a ")" with none open
457
+ * ends, marked ends the link that many characters before its ")", and
458
+ * reads the end of the address as inline Markdown: such a link counts as
459
+ * not closing.
460
+ *
461
+ * It reads no more than `reading` has left, and takes what it read from
462
+ * it: a tail that would read past that counts as not closing.
463
+ */
464
+ const readLinkTail = (text, open, end, reading) => {
465
+ const limit = Math.min(end, open + 1 + Math.max(reading.left, 0));
466
+ // Takes what was read, up to `readTo`, and returns where the tail ends.
467
+ const read = (tailEnd, readTo) => {
468
+ reading.left -= readTo - open;
469
+ return tailEnd;
470
+ };
471
+ let index = open + 1;
472
+ while (index < limit && (0, RegExpCharacterClasses_1.isWhiteSpaceCode)(text.charCodeAt(index))) {
473
+ index++;
474
+ }
475
+ const hasSpaceBefore = index > open + 1;
476
+ if (index < limit && text.charCodeAt(index) === LESS_THAN) {
477
+ index++;
478
+ for (;;) {
479
+ if (index >= limit) {
480
+ return read(-1, limit);
481
+ }
482
+ const code = text.charCodeAt(index);
483
+ if (code === BACKSLASH) {
484
+ index += 2;
485
+ continue;
486
+ }
487
+ if (code === LESS_THAN) {
488
+ return read(-1, index + 1);
489
+ }
490
+ index++;
491
+ if (code === GREATER_THAN) {
492
+ break;
493
+ }
494
+ }
495
+ }
496
+ else {
497
+ let depth = 0;
498
+ while (index < limit) {
499
+ const code = text.charCodeAt(index);
500
+ if ((0, RegExpCharacterClasses_1.isWhiteSpaceCode)(code) || code < SPACE) {
501
+ break;
502
+ }
503
+ if (code === BACKSLASH && index + 1 < limit) {
504
+ const escaped = text.charCodeAt(index + 1);
505
+ index += (0, RegExpCharacterClasses_1.isWhiteSpaceCode)(escaped) || escaped < SPACE ? 1 : 2;
506
+ continue;
507
+ }
508
+ if (code === OPEN_PARENTHESIS) {
509
+ depth++;
510
+ }
511
+ else if (code === CLOSE_PARENTHESIS) {
512
+ if (depth === 0) {
513
+ return read(hasSpaceBefore ? -1 : index + 1, index + 1);
514
+ }
515
+ depth--;
516
+ }
517
+ index++;
518
+ }
519
+ if (depth !== 0) {
520
+ return read(-1, index);
521
+ }
522
+ }
523
+ // White space, a title after it if any, white space, and the ")".
524
+ let afterSpace = index;
525
+ while (afterSpace < limit && (0, RegExpCharacterClasses_1.isWhiteSpaceCode)(text.charCodeAt(afterSpace))) {
526
+ afterSpace++;
527
+ }
528
+ if (afterSpace < limit && text.charCodeAt(afterSpace) === CLOSE_PARENTHESIS) {
529
+ return read(afterSpace + 1, afterSpace + 1);
530
+ }
531
+ const opener = afterSpace < limit ? text.charCodeAt(afterSpace) : NaN;
532
+ if (afterSpace === index ||
533
+ (opener !== QUOTATION_MARK &&
534
+ opener !== APOSTROPHE &&
535
+ opener !== OPEN_PARENTHESIS)) {
536
+ return read(-1, afterSpace);
537
+ }
538
+ let titleEnd = readTitleEnd(text, afterSpace, limit, true);
539
+ if (titleEnd === -1) {
540
+ // A title that does not close is read to the limit.
541
+ return read(-1, limit);
542
+ }
543
+ while (titleEnd < limit && (0, RegExpCharacterClasses_1.isWhiteSpaceCode)(text.charCodeAt(titleEnd))) {
544
+ titleEnd++;
545
+ }
546
+ return read(titleEnd < limit && text.charCodeAt(titleEnd) === CLOSE_PARENTHESIS
547
+ ? titleEnd + 1
548
+ : -1, titleEnd + 1);
549
+ };
550
+ /*
551
+ * Where the link or image whose label's "[" is at `open` ends for marked -
552
+ * past the ")" after its address and title - or -1 where its label or its
553
+ * address does not close on the line (getMarkedLineWork reads it as a look
554
+ * through the rest of its unit there). Exported for tests.
555
+ */
556
+ const getMarkedLinkEnd = (text, open, end) => {
557
+ const close = readClosedLabel(text, open, end);
558
+ if (close === -1 ||
559
+ close + 1 >= end ||
560
+ text.charCodeAt(close + 1) !== OPEN_PARENTHESIS) {
561
+ return -1;
562
+ }
563
+ return readLinkTail(text, close + 1, end, {
564
+ left: Number.POSITIVE_INFINITY,
565
+ });
566
+ };
567
+ exports.getMarkedLinkEnd = getMarkedLinkEnd;
568
+ /*
569
+ * Where the address of the link reference definition text[start, end) is
570
+ * starts - or -1 when the line is not one marked takes whole: "[label]:",
571
+ * spaces, an address in "<>" or up to white space, and, after spaces, an
572
+ * optional title, then spaces to the line's end. Exported for tests.
573
+ */
574
+ const getMarkedDefinitionAddressStart = (text, start, end) => {
575
+ if (start >= end || text.charCodeAt(start) !== OPEN_BRACKET) {
576
+ return -1;
577
+ }
578
+ const close = readClosedLabel(text, start, end);
579
+ if (close === -1 ||
580
+ close + 1 >= end ||
581
+ text.charCodeAt(close + 1) !== COLON) {
582
+ return -1;
583
+ }
584
+ // A label of white space alone is no label.
585
+ let hasText = false;
586
+ for (let index = start + 1; index < close && !hasText; index++) {
587
+ hasText = !(0, RegExpCharacterClasses_1.isWhiteSpaceCode)(text.charCodeAt(index));
588
+ }
589
+ if (!hasText) {
590
+ return -1;
591
+ }
592
+ let index = close + 2;
593
+ while (index < end && text.charCodeAt(index) === SPACE) {
594
+ index++;
595
+ }
596
+ const addressStart = index;
597
+ if (index >= end) {
598
+ return -1;
599
+ }
600
+ if (text.charCodeAt(index) === LESS_THAN) {
601
+ index++;
602
+ while (index < end && text.charCodeAt(index) !== GREATER_THAN) {
603
+ if ((0, RegExpCharacterClasses_1.isLineTerminatorCode)(text.charCodeAt(index))) {
604
+ return -1;
605
+ }
606
+ index++;
607
+ }
608
+ if (index >= end) {
609
+ return -1;
610
+ }
611
+ index++;
612
+ }
613
+ else {
614
+ while (index < end && !(0, RegExpCharacterClasses_1.isWhiteSpaceCode)(text.charCodeAt(index))) {
615
+ index++;
616
+ }
617
+ }
618
+ let afterSpaces = index;
619
+ while (afterSpaces < end && text.charCodeAt(afterSpaces) === SPACE) {
620
+ afterSpaces++;
621
+ }
622
+ if (afterSpaces >= end) {
623
+ return addressStart;
624
+ }
625
+ if (afterSpaces === index) {
626
+ return -1;
627
+ }
628
+ let titleEnd = readTitleEnd(text, afterSpaces, end, false);
629
+ if (titleEnd === -1) {
630
+ return -1;
631
+ }
632
+ while (titleEnd < end && text.charCodeAt(titleEnd) === SPACE) {
633
+ titleEnd++;
634
+ }
635
+ return titleEnd >= end ? addressStart : -1;
636
+ };
637
+ exports.getMarkedDefinitionAddressStart = getMarkedDefinitionAddressStart;
638
+ /*
639
+ * What the line text[start, end) costs marked, added to its unit (see
640
+ * HOW MARKED READS A LINE): characters it looks ahead from through the
641
+ * unit, what it masks with a copy of the unit, and the line's work that
642
+ * does not grow with the unit - the punctuation of its words as
643
+ * getWordPunctuationWork counts it, what a complete link's parentheses
644
+ * hold, once, and the runs before an "@". A definition marked takes costs
645
+ * its length, once. A definition is one marked takes only as the first
646
+ * line of its unit or after others: after a paragraph's line, marked reads
647
+ * it as the paragraph's text.
648
+ */
649
+ const readMarkedLine = (text, start, end, counting, unit) => {
650
+ unit.mayDefine =
651
+ unit.mayDefine && (0, exports.getMarkedDefinitionAddressStart)(text, start, end) !== -1;
652
+ if (unit.mayDefine) {
653
+ /*
654
+ * marked's block rule takes the definition whole, its label too: no
655
+ * part of it is inline Markdown, so it costs its length, once - and a
656
+ * block of many definitions costs no more than their length.
657
+ */
658
+ unit.work += end - start;
659
+ return;
660
+ }
661
+ // What marked reads once and is not counted otherwise: [skipFrom, skipTo).
662
+ let skipFrom = -1;
663
+ let skipTo = end;
664
+ let wordStart = start;
665
+ let wordPunctuation = 0;
666
+ // Where the run of an email address's characters being read starts.
667
+ let emailRunStart = start;
668
+ /*
669
+ * Characters from here on are read for inline Markdown: an escape or a
670
+ * delimiter run took the ones before.
671
+ */
672
+ let inlineFrom = start;
673
+ /*
674
+ * Where the last reference's label closed, and whether it was the label
675
+ * of a "[text][label]": the label after the text is one masked item.
676
+ */
677
+ let referenceEnd = -1;
678
+ let wasLabelOfText = false;
679
+ // What the line's link tails may still read (readLinkTail).
680
+ const tailReading = {
681
+ left: exports.MARKED_TAIL_READING_SHARE * (end - start),
682
+ };
683
+ let index = start;
684
+ while (index < end) {
685
+ if (index === skipFrom) {
686
+ unit.work += skipTo - skipFrom;
687
+ index = skipTo;
688
+ emailRunStart = index;
689
+ inlineFrom = index;
690
+ skipFrom = -1;
691
+ continue;
692
+ }
693
+ const code = text.charCodeAt(index);
694
+ // The punctuation of words, as getWordPunctuationWork counts it.
695
+ if (isSpaceOrTab(code)) {
696
+ unit.work += wordPunctuation * (index - wordStart);
697
+ wordStart = index + 1;
698
+ wordPunctuation = 0;
699
+ }
700
+ else if (isAsciiPunctuation(code)) {
701
+ wordPunctuation++;
702
+ }
703
+ if (code === AT_SIGN && index > emailRunStart) {
704
+ let domainEnd = index + 1;
705
+ while (domainEnd < end &&
706
+ isMarkedDomainCode(text.charCodeAt(domainEnd))) {
707
+ domainEnd++;
708
+ }
709
+ const run = index - emailRunStart;
710
+ unit.work += run * (run + domainEnd - index - 1);
711
+ }
712
+ if (!isMarkedEmailCode(code)) {
713
+ emailRunStart = index + 1;
714
+ }
715
+ if (index < inlineFrom) {
716
+ index++;
717
+ continue;
718
+ }
719
+ const next = index + 1 < end ? text.charCodeAt(index + 1) : NaN;
720
+ if (code === ASTERISK || code === UNDERSCORE || code === TILDE) {
721
+ let runEnd = index + 1;
722
+ while (runEnd < end && text.charCodeAt(runEnd) === code) {
723
+ runEnd++;
724
+ }
725
+ const before = index > start ? text.charCodeAt(index - 1) : NaN;
726
+ const after = runEnd < end ? text.charCodeAt(runEnd) : NaN;
727
+ const canNeitherOpenNorClose = isWhitespaceOrNothing(before) && isWhitespaceOrNothing(after);
728
+ const isInsideWord = code === UNDERSCORE &&
729
+ !counting.countWordUnderscores &&
730
+ index > start &&
731
+ runEnd < end &&
732
+ isWordCharacterAt(text, index - 1) &&
733
+ isWordCharacterAt(text, runEnd);
734
+ if (!canNeitherOpenNorClose && !isInsideWord) {
735
+ unit.characters += runEnd - index;
736
+ }
737
+ inlineFrom = runEnd;
738
+ }
739
+ else if (code === BACKTICK) {
740
+ unit.characters++;
741
+ }
742
+ else if (code === OPEN_BRACKET) {
743
+ const close = readClosedLabel(text, index, end);
744
+ const tailEnd = close !== -1 &&
745
+ close + 1 < end &&
746
+ text.charCodeAt(close + 1) === OPEN_PARENTHESIS
747
+ ? readLinkTail(text, close + 1, end, tailReading)
748
+ : -2;
749
+ if (close === -1 || tailEnd === -1) {
750
+ // A label or an address that does not close: a look through.
751
+ unit.characters++;
752
+ }
753
+ else if (tailEnd >= 0) {
754
+ unit.maskedItems++;
755
+ skipFrom = close + 1;
756
+ skipTo = tailEnd;
757
+ referenceEnd = -1;
758
+ }
759
+ else {
760
+ if (index === referenceEnd && !wasLabelOfText) {
761
+ wasLabelOfText = true;
762
+ }
763
+ else {
764
+ unit.maskedItems++;
765
+ wasLabelOfText = false;
766
+ }
767
+ referenceEnd = close + 1;
768
+ }
769
+ }
770
+ else if (code === LESS_THAN) {
771
+ if (isAsciiLetter(next) ||
772
+ next === SLASH ||
773
+ next === EXCLAMATION_MARK ||
774
+ next === QUESTION_MARK) {
775
+ unit.characters++;
776
+ unit.isLessThanOpen = false;
777
+ }
778
+ else {
779
+ unit.isLessThanOpen = true;
780
+ }
781
+ }
782
+ else if (code === GREATER_THAN) {
783
+ if (unit.isLessThanOpen) {
784
+ unit.maskedItems++;
785
+ unit.isLessThanOpen = false;
786
+ }
787
+ }
788
+ else if (code === BACKSLASH) {
789
+ const escaped = getEscapedLength(text, index + 1, end);
790
+ if (escaped > 0) {
791
+ unit.maskedItems++;
792
+ inlineFrom = index + 1 + escaped;
793
+ }
794
+ }
795
+ else if (counting.countUrlLiterals &&
796
+ (code === AT_SIGN ||
797
+ (code === COLON &&
798
+ next === SLASH &&
799
+ index + 2 < end &&
800
+ text.charCodeAt(index + 2) === SLASH) ||
801
+ ((code | 0x20) === 0x77 && startsWithWww(text, index, end)))) {
802
+ unit.characters++;
803
+ }
804
+ index++;
805
+ }
806
+ unit.work += wordPunctuation * (end - wordStart);
807
+ };
808
+ /*
809
+ * What the line text[start, end) costs marked as the first line of its
810
+ * unit (readMarkedLine). Exported for tests.
811
+ */
812
+ const getMarkedLineWork = (text, start, end, counting = {}) => {
813
+ const unit = newUnitWork();
814
+ readMarkedLine(text, start, end, {
815
+ countUrlLiterals: Boolean(counting.countUrlLiterals),
816
+ countWordUnderscores: Boolean(counting.countWordUnderscores),
817
+ countAsMarked: true,
818
+ }, unit);
819
+ return {
820
+ characters: unit.characters,
821
+ maskedItems: unit.maskedItems,
822
+ work: unit.work,
823
+ isDefinition: unit.mayDefine,
824
+ };
825
+ };
826
+ exports.getMarkedLineWork = getMarkedLineWork;
257
827
  // Where the line that starts at `start` ends: its "\n", or the text's end.
258
828
  const getLineEnd = (text, start) => {
259
829
  const lineEnd = text.indexOf("\n", start);
@@ -635,9 +1205,18 @@ const measureRun = (text, lineStarts, counting) => {
635
1205
  let cellsPerLine = 0;
636
1206
  let unitLength = 0;
637
1207
  let unitLines = 0;
638
- let unitCharacters = 0;
1208
+ let unit = newUnitWork();
639
1209
  // What started the unit being read, if a marker did.
640
1210
  let unitKind = null;
1211
+ // Adds what the unit read costs: marked's copies of it in their share.
1212
+ const addUnit = () => {
1213
+ inlineWork +=
1214
+ unit.characters * unitLength +
1215
+ Math.ceil((unit.maskedItems * unitLength) / exports.MARKED_MASKED_ITEM_SHARE) +
1216
+ unit.work;
1217
+ longestUnit = Math.max(longestUnit, unitLength);
1218
+ longestUnitLines = Math.max(longestUnitLines, unitLines);
1219
+ };
641
1220
  for (const lineStart of lineStarts) {
642
1221
  const lineEnd = withoutCarriageReturn(text, lineStart, getLineEnd(text, lineStart));
643
1222
  const start = readLineStart(text, lineStart, lineEnd);
@@ -646,24 +1225,25 @@ const measureRun = (text, lineStarts, counting) => {
646
1225
  (start.unitStart !== null &&
647
1226
  (start.isFirstOrdered || start.unitStart === unitKind));
648
1227
  if (startsUnit) {
649
- inlineWork += unitCharacters * unitLength;
650
- longestUnit = Math.max(longestUnit, unitLength);
651
- longestUnitLines = Math.max(longestUnitLines, unitLines);
1228
+ addUnit();
652
1229
  unitLength = 0;
653
1230
  unitLines = 0;
654
- unitCharacters = 0;
1231
+ unit = newUnitWork();
655
1232
  unitKind = start.unitStart;
656
1233
  }
657
1234
  unitLength += lineEnd - lineStart + 1;
658
1235
  unitLines++;
659
- unitCharacters += (0, exports.getInlineCharacterCount)(text, start.contentStart, lineEnd, counting);
660
- inlineWork += (0, exports.getWordPunctuationWork)(text, start.contentStart, lineEnd);
1236
+ if (counting.countAsMarked) {
1237
+ readMarkedLine(text, start.contentStart, lineEnd, counting, unit);
1238
+ }
1239
+ else {
1240
+ unit.characters += (0, exports.getInlineCharacterCount)(text, start.contentStart, lineEnd, counting);
1241
+ unit.work += (0, exports.getWordPunctuationWork)(text, start.contentStart, lineEnd);
1242
+ }
661
1243
  nestingDepth = Math.max(nestingDepth, start.nestingDepth);
662
1244
  cellsPerLine = Math.max(cellsPerLine, getPipeCount(text, start.contentStart, lineEnd));
663
1245
  }
664
- inlineWork += unitCharacters * unitLength;
665
- longestUnit = Math.max(longestUnit, unitLength);
666
- longestUnitLines = Math.max(longestUnitLines, unitLines);
1246
+ addUnit();
667
1247
  const lastLineStart = lineStarts[lineStarts.length - 1];
668
1248
  return {
669
1249
  start: lineStarts[0],
@@ -921,11 +1501,13 @@ const holdBackSlowMarkdown = (text, holder, limits) => {
921
1501
  holdBackCodeBlockContent: false,
922
1502
  countUrlLiterals: false,
923
1503
  countWordUnderscores: false,
1504
+ countAsMarked: false,
924
1505
  };
925
1506
  }
926
1507
  const segments = readSegments(text, {
927
1508
  countUrlLiterals: appliedLimits.countUrlLiterals,
928
1509
  countWordUnderscores: appliedLimits.countWordUnderscores,
1510
+ countAsMarked: appliedLimits.countAsMarked,
929
1511
  });
930
1512
  let heldBack = chooseSegmentsToHoldBack(segments, appliedLimits);
931
1513
  /*
@@ -1006,6 +1588,7 @@ const measureSlowMarkdownRuns = (text, counting = {}) => {
1006
1588
  for (const segment of readSegments(typeof text === "string" ? text : "", {
1007
1589
  countUrlLiterals: Boolean(counting.countUrlLiterals),
1008
1590
  countWordUnderscores: Boolean(counting.countWordUnderscores),
1591
+ countAsMarked: Boolean(counting.countAsMarked),
1009
1592
  })) {
1010
1593
  if (segment.kind === "run") {
1011
1594
  runs.push(segment.run);
@@ -1023,6 +1606,7 @@ const measureSlowMarkdownCodeBlocks = (text) => {
1023
1606
  for (const segment of readSegments(typeof text === "string" ? text : "", {
1024
1607
  countUrlLiterals: false,
1025
1608
  countWordUnderscores: false,
1609
+ countAsMarked: false,
1026
1610
  })) {
1027
1611
  if (segment.kind === "code") {
1028
1612
  blocks.push({
@@ -1,8 +1,14 @@
1
1
  import commonJsModule from "./SlowMarkdown.js";
2
+ export const MARKED_MASKED_ITEM_SHARE = commonJsModule.MARKED_MASKED_ITEM_SHARE;
3
+ export const MARKED_TAIL_READING_SHARE = commonJsModule.MARKED_TAIL_READING_SHARE;
4
+ export const MAX_MARKED_LABEL_LENGTH = commonJsModule.MAX_MARKED_LABEL_LENGTH;
2
5
  export const SLOW_MARKDOWN_MAX_INLINE_WORK = commonJsModule.SLOW_MARKDOWN_MAX_INLINE_WORK;
3
6
  export const SLOW_MARKDOWN_MAX_NESTING_DEPTH = commonJsModule.SLOW_MARKDOWN_MAX_NESTING_DEPTH;
4
7
  export const SLOW_MARKDOWN_MIN_LENGTH = commonJsModule.SLOW_MARKDOWN_MIN_LENGTH;
5
8
  export const getInlineCharacterCount = commonJsModule.getInlineCharacterCount;
9
+ export const getMarkedDefinitionAddressStart = commonJsModule.getMarkedDefinitionAddressStart;
10
+ export const getMarkedLineWork = commonJsModule.getMarkedLineWork;
11
+ export const getMarkedLinkEnd = commonJsModule.getMarkedLinkEnd;
6
12
  export const getWordPunctuationWork = commonJsModule.getWordPunctuationWork;
7
13
  export const holdBackSlowMarkdown = commonJsModule.holdBackSlowMarkdown;
8
14
  export const measureSlowMarkdownCodeBlocks = commonJsModule.measureSlowMarkdownCodeBlocks;