@oneuptime/common 14.0.106 → 14.0.108
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.
- package/Models/AnalyticsModels/AuditLog.js +1 -1
- package/Models/AnalyticsModels/Index.js +3 -0
- package/Models/AnalyticsModels/RumProductAnalyticsEvent.d.mts +5 -0
- package/Models/AnalyticsModels/RumProductAnalyticsEvent.d.ts +5 -0
- package/Models/AnalyticsModels/RumProductAnalyticsEvent.js +300 -0
- package/Models/AnalyticsModels/RumProductAnalyticsEvent.mjs +3 -0
- package/Models/DatabaseModels/CallLog.d.mts +4 -0
- package/Models/DatabaseModels/CallLog.d.ts +4 -0
- package/Models/DatabaseModels/CallLog.js +85 -0
- package/Models/DatabaseModels/DataBiConnection.d.mts +7 -0
- package/Models/DatabaseModels/DataBiConnection.d.ts +7 -0
- package/Models/DatabaseModels/DataBiConnection.js +105 -2
- package/Models/DatabaseModels/DataDashboard.d.mts +10 -0
- package/Models/DatabaseModels/DataDashboard.d.ts +10 -0
- package/Models/DatabaseModels/DataDashboard.js +129 -2
- package/Models/DatabaseModels/Index.js +8 -0
- package/Models/DatabaseModels/NetworkDevice.d.mts +1 -0
- package/Models/DatabaseModels/NetworkDevice.d.ts +1 -0
- package/Models/DatabaseModels/NetworkDevice.js +55 -0
- package/Models/DatabaseModels/NetworkDeviceNamingRule.d.mts +26 -0
- package/Models/DatabaseModels/NetworkDeviceNamingRule.d.ts +26 -0
- package/Models/DatabaseModels/NetworkDeviceNamingRule.js +536 -0
- package/Models/DatabaseModels/NetworkDeviceNamingRule.mjs +2 -0
- package/Models/DatabaseModels/NetworkSite.d.mts +1 -0
- package/Models/DatabaseModels/NetworkSite.d.ts +1 -0
- package/Models/DatabaseModels/NetworkSite.js +51 -0
- package/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.d.mts +2 -0
- package/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.d.ts +2 -0
- package/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.js +41 -0
- package/Models/DatabaseModels/ProjectCallSMSConfig.d.mts +2 -0
- package/Models/DatabaseModels/ProjectCallSMSConfig.d.ts +2 -0
- package/Models/DatabaseModels/ProjectCallSMSConfig.js +80 -1
- package/Models/DatabaseModels/RumApplication.d.mts +2 -0
- package/Models/DatabaseModels/RumApplication.d.ts +2 -0
- package/Models/DatabaseModels/RumApplication.js +108 -0
- package/Models/DatabaseModels/RumProductAnalyticsSavedView.d.mts +20 -0
- package/Models/DatabaseModels/RumProductAnalyticsSavedView.d.ts +20 -0
- package/Models/DatabaseModels/RumProductAnalyticsSavedView.js +353 -0
- package/Models/DatabaseModels/RumProductAnalyticsSavedView.mjs +2 -0
- package/Models/DatabaseModels/Team.js +10 -2
- package/Models/DatabaseModels/TeamComplianceSetting.js +8 -1
- package/Models/DatabaseModels/TeamCustomRole.js +9 -1
- package/Models/DatabaseModels/TeamMember.js +15 -1
- package/Models/DatabaseModels/TeamOwnerTeam.d.mts +17 -0
- package/Models/DatabaseModels/TeamOwnerTeam.d.ts +17 -0
- package/Models/DatabaseModels/TeamOwnerTeam.js +325 -0
- package/Models/DatabaseModels/TeamOwnerTeam.mjs +2 -0
- package/Models/DatabaseModels/TeamOwnerUser.d.mts +17 -0
- package/Models/DatabaseModels/TeamOwnerUser.d.ts +17 -0
- package/Models/DatabaseModels/TeamOwnerUser.js +331 -0
- package/Models/DatabaseModels/TeamOwnerUser.mjs +2 -0
- package/Models/DatabaseModels/TeamPermission.js +12 -1
- package/Models/DatabaseModels/TelemetryUsageBilling.d.mts +1 -0
- package/Models/DatabaseModels/TelemetryUsageBilling.d.ts +1 -0
- package/Models/DatabaseModels/TelemetryUsageBilling.js +34 -0
- package/Models/DatabaseModels/WhatsAppLog.d.mts +3 -0
- package/Models/DatabaseModels/WhatsAppLog.d.ts +3 -0
- package/Models/DatabaseModels/WhatsAppLog.js +62 -0
- package/Models/DatabaseModels/WorkspaceProjectAuthToken.d.mts +11 -0
- package/Models/DatabaseModels/WorkspaceProjectAuthToken.d.ts +11 -0
- package/Models/DatabaseModels/WorkspaceUserGroup.js +1 -1
- package/Server/Utils/Telemetry/NotificationDeliveryMetrics.d.mts +212 -0
- package/Server/Utils/Telemetry/NotificationDeliveryMetrics.d.ts +212 -0
- package/Server/Utils/Workspace/WorkspaceBase.d.mts +3 -0
- package/Server/Utils/Workspace/WorkspaceBase.d.ts +3 -0
- package/Types/AI/AIActionWords.d.mts +1 -0
- package/Types/AI/AIActionWords.d.ts +1 -0
- package/Types/AI/AIActionWords.js +15 -4
- package/Types/AI/AIChatRecordSeen.d.mts +3 -0
- package/Types/AI/AIChatRecordSeen.d.ts +3 -0
- package/Types/AI/AIChatRecordSeen.js +28 -3
- package/Types/AI/AIChatRecordSeen.mjs +1 -0
- package/Types/AI/AIChatTypes.d.mts +2 -1
- package/Types/AI/AIChatTypes.d.ts +2 -1
- package/Types/AI/AIChatTypes.js +2 -0
- package/Types/AI/InvestigationNotStartedReason.d.mts +7 -0
- package/Types/AI/InvestigationNotStartedReason.d.ts +7 -0
- package/Types/AnalyticsDatabase/AnalyticsTableName.d.mts +2 -1
- package/Types/AnalyticsDatabase/AnalyticsTableName.d.ts +2 -1
- package/Types/AnalyticsDatabase/AnalyticsTableName.js +7 -0
- package/Types/AuditLog/AuditLogRetention.d.mts +10 -0
- package/Types/AuditLog/AuditLogRetention.d.ts +10 -0
- package/Types/AuditLog/AuditLogRetention.js +91 -0
- package/Types/AuditLog/AuditLogRetention.mjs +8 -0
- package/Types/CallAndSMS/TwilioConfigDefaults.d.mts +37 -0
- package/Types/CallAndSMS/TwilioConfigDefaults.d.ts +37 -0
- package/Types/CallAndSMS/TwilioConfigDefaults.js +224 -0
- package/Types/CallAndSMS/TwilioConfigDefaults.mjs +3 -0
- package/Types/CodeInSentence.d.mts +8 -0
- package/Types/CodeInSentence.d.ts +8 -0
- package/Types/CodeInSentence.js +875 -0
- package/Types/CodeInSentence.mjs +4 -0
- package/Types/CodeRepository/CodeFileSeen.d.mts +3 -0
- package/Types/CodeRepository/CodeFileSeen.d.ts +3 -0
- package/Types/CodeRepository/CodeFileSeen.js +61 -3
- package/Types/Dashboard/DashboardComponentType.d.mts +2 -0
- package/Types/Dashboard/DashboardComponentType.d.ts +2 -0
- package/Types/Dashboard/DashboardComponentType.js +7 -0
- package/Types/Dashboard/DashboardComponents/ComponentArgument.d.mts +3 -1
- package/Types/Dashboard/DashboardComponents/ComponentArgument.d.ts +3 -1
- package/Types/Dashboard/DashboardComponents/ComponentArgument.js +3 -0
- package/Types/Dashboard/DashboardComponents/DashboardProductAnalyticsFunnelComponent.d.mts +11 -0
- package/Types/Dashboard/DashboardComponents/DashboardProductAnalyticsFunnelComponent.d.ts +11 -0
- package/Types/Dashboard/DashboardComponents/DashboardProductAnalyticsFunnelComponent.js +2 -0
- package/Types/Dashboard/DashboardComponents/DashboardProductAnalyticsFunnelComponent.mjs +1 -0
- package/Types/Dashboard/DashboardComponents/DashboardProductAnalyticsRetentionComponent.d.mts +11 -0
- package/Types/Dashboard/DashboardComponents/DashboardProductAnalyticsRetentionComponent.d.ts +11 -0
- package/Types/Dashboard/DashboardComponents/DashboardProductAnalyticsRetentionComponent.js +2 -0
- package/Types/Dashboard/DashboardComponents/DashboardProductAnalyticsRetentionComponent.mjs +1 -0
- package/Types/Dashboard/PublicDashboardServedSettings.js +15 -7
- package/Types/DataObservability/DataBiRefreshAlert.d.mts +44 -0
- package/Types/DataObservability/DataBiRefreshAlert.d.ts +44 -0
- package/Types/DataObservability/DataBiRefreshAlert.js +206 -0
- package/Types/DataObservability/DataBiRefreshAlert.mjs +12 -0
- package/Types/DataObservability/DataDashboardActivity.d.mts +40 -0
- package/Types/DataObservability/DataDashboardActivity.d.ts +40 -0
- package/Types/DataObservability/DataDashboardActivity.js +119 -0
- package/Types/DataObservability/DataDashboardActivity.mjs +12 -0
- package/Types/DataObservability/DataObservabilityApiTypes.d.mts +14 -0
- package/Types/DataObservability/DataObservabilityApiTypes.d.ts +14 -0
- package/Types/DataObservability/DataObservabilityApiTypes.js +14 -0
- package/Types/DataObservability/DataTableLineage.d.mts +108 -0
- package/Types/DataObservability/DataTableLineage.d.ts +108 -0
- package/Types/DataObservability/DataTableLineage.js +119 -0
- package/Types/DataObservability/DataTableLineage.mjs +21 -0
- package/Types/DataSecurity/DataStoreKind.d.mts +1 -0
- package/Types/DataSecurity/DataStoreKind.d.ts +1 -0
- package/Types/DataSecurity/DataStoreKind.js +3 -0
- package/Types/Database/AccessControl/PermissionScopeNarrowing.js +6 -0
- package/Types/DatabaseServer/DatabaseServerMetricCatalog.js +71 -82
- package/Types/Date.d.mts +4 -0
- package/Types/Date.d.ts +4 -0
- package/Types/Date.js +47 -2
- package/Types/Date.mjs +2 -0
- package/Types/DateLanguage.d.mts +9 -0
- package/Types/DateLanguage.d.ts +9 -0
- package/Types/DateLanguage.js +79 -1
- package/Types/DateLanguage.mjs +4 -0
- package/Types/HashedString.js +9 -2
- package/Types/MessageQueue/MessageQueueMetricCatalog.js +61 -61
- package/Types/Monitor/CriteriaFilterTerms.d.mts +4 -0
- package/Types/Monitor/CriteriaFilterTerms.d.ts +4 -0
- package/Types/Monitor/CriteriaFilterTerms.js +166 -0
- package/Types/Monitor/CriteriaFilterTerms.mjs +4 -0
- package/Types/Monitor/CriteriaFilterValues.d.mts +16 -0
- package/Types/Monitor/CriteriaFilterValues.d.ts +16 -0
- package/Types/Monitor/CriteriaFilterValues.js +324 -0
- package/Types/Monitor/CriteriaFilterValues.mjs +2 -0
- package/Types/Monitor/DataBiRefreshMonitorStep.d.mts +13 -0
- package/Types/Monitor/DataBiRefreshMonitorStep.d.ts +13 -0
- package/Types/Monitor/DataBiRefreshMonitorStep.js +108 -0
- package/Types/Monitor/DataBiRefreshMonitorStep.mjs +3 -0
- package/Types/Monitor/EvaluationSentence.d.mts +37 -0
- package/Types/Monitor/EvaluationSentence.d.ts +37 -0
- package/Types/Monitor/EvaluationSentence.js +298 -0
- package/Types/Monitor/EvaluationSentence.mjs +12 -0
- package/Types/Monitor/IncomingEmailMonitor/IncomingEmailMonitorRequest.d.mts +1 -0
- package/Types/Monitor/IncomingEmailMonitor/IncomingEmailMonitorRequest.d.ts +1 -0
- package/Types/Monitor/MonitorCriteria.d.mts +2 -0
- package/Types/Monitor/MonitorCriteria.d.ts +2 -0
- package/Types/Monitor/MonitorCriteria.js +8 -0
- package/Types/Monitor/MonitorCriteriaInstance.d.mts +5 -0
- package/Types/Monitor/MonitorCriteriaInstance.d.ts +5 -0
- package/Types/Monitor/MonitorCriteriaInstance.js +265 -196
- package/Types/Monitor/MonitorEvaluationDetails.d.mts +2 -0
- package/Types/Monitor/MonitorEvaluationDetails.d.ts +2 -0
- package/Types/Monitor/MonitorEvaluationSummary.d.mts +4 -0
- package/Types/Monitor/MonitorEvaluationSummary.d.ts +4 -0
- package/Types/Monitor/MonitorStep.d.mts +2 -0
- package/Types/Monitor/MonitorStep.d.ts +2 -0
- package/Types/Monitor/MonitorStep.js +28 -11
- package/Types/Monitor/MonitorStepMetricMonitor.js +6 -1
- package/Types/Monitor/MonitorStepRollingTime.d.mts +12 -0
- package/Types/Monitor/MonitorStepRollingTime.d.ts +12 -0
- package/Types/Monitor/MonitorStepRollingTime.js +117 -0
- package/Types/Monitor/MonitorStepRollingTime.mjs +2 -0
- package/Types/Monitor/MonitorSteps.d.mts +2 -0
- package/Types/Monitor/MonitorSteps.d.ts +2 -0
- package/Types/Monitor/MonitorType.d.mts +1 -0
- package/Types/Monitor/MonitorType.d.ts +1 -0
- package/Types/Monitor/MonitorType.js +12 -0
- package/Types/Monitor/SeriesContext/SeriesLabelDisplay.js +11 -0
- package/Types/Monitor/ServerMonitor/ServerMonitorResponse.d.mts +1 -0
- package/Types/Monitor/ServerMonitor/ServerMonitorResponse.d.ts +1 -0
- package/Types/Monitor/TelemetryAlertRule.js +7 -2
- package/Types/Monitor/TelemetryObservation.d.mts +15 -0
- package/Types/Monitor/TelemetryObservation.d.ts +15 -0
- package/Types/Monitor/TelemetryObservation.js +28 -0
- package/Types/Monitor/TelemetryObservation.mjs +2 -0
- package/Types/NetworkDevice/DeviceNaming.d.mts +87 -0
- package/Types/NetworkDevice/DeviceNaming.d.ts +87 -0
- package/Types/NetworkDevice/DeviceNaming.js +279 -0
- package/Types/NetworkDevice/DeviceNaming.mjs +24 -0
- package/Types/NetworkDevice/DiscoveredDevice.d.mts +1 -0
- package/Types/NetworkDevice/DiscoveredDevice.d.ts +1 -0
- package/Types/NetworkDevice/DiscoveredDevice.js +4 -0
- package/Types/NotificationRule/NotificationRepeat.d.mts +10 -0
- package/Types/NotificationRule/NotificationRepeat.d.ts +10 -0
- package/Types/NotificationRule/NotificationRepeat.js +51 -0
- package/Types/NotificationRule/NotificationRepeat.mjs +2 -0
- package/Types/OnCallDutyPolicy/OnCallAcknowledgePage.d.mts +70 -0
- package/Types/OnCallDutyPolicy/OnCallAcknowledgePage.d.ts +70 -0
- package/Types/OnCallDutyPolicy/OnCallAcknowledgePage.js +276 -0
- package/Types/OnCallDutyPolicy/OnCallAcknowledgePage.mjs +12 -0
- package/Types/OnCallDutyPolicy/OnCallEscalationWait.d.mts +9 -0
- package/Types/OnCallDutyPolicy/OnCallEscalationWait.d.ts +9 -0
- package/Types/OnCallDutyPolicy/OnCallEscalationWait.js +44 -0
- package/Types/OnCallDutyPolicy/OnCallEscalationWait.mjs +5 -0
- package/Types/OnCallDutyPolicy/OnCallPageChannel.d.mts +68 -0
- package/Types/OnCallDutyPolicy/OnCallPageChannel.d.ts +68 -0
- package/Types/OnCallDutyPolicy/OnCallPageChannel.js +351 -0
- package/Types/OnCallDutyPolicy/OnCallPageChannel.mjs +15 -0
- package/Types/Permission.d.mts +5 -0
- package/Types/Permission.d.ts +5 -0
- package/Types/Permission.js +61 -5
- package/Types/Probe/ProbeMonitorResponse.d.mts +1 -0
- package/Types/Probe/ProbeMonitorResponse.d.ts +1 -0
- package/Types/ReadingDirection.d.mts +2 -0
- package/Types/ReadingDirection.d.ts +2 -0
- package/Types/ReadingDirection.js +221 -25
- package/Types/ReadingDirection.mjs +2 -0
- package/Types/RollingTime/RollingTimeUtil.d.mts +7 -0
- package/Types/RollingTime/RollingTimeUtil.d.ts +7 -0
- package/Types/RollingTime/RollingTimeUtil.js +240 -71
- package/Types/Rules/RuleCriteriaFieldRegistry.js +12 -0
- package/Types/Rules/RuleCriteriaSubject.js +1 -0
- package/Types/Rum/ProductAnalyticsEventReads.d.mts +115 -0
- package/Types/Rum/ProductAnalyticsEventReads.d.ts +115 -0
- package/Types/Rum/ProductAnalyticsEventReads.js +166 -0
- package/Types/Rum/ProductAnalyticsEventReads.mjs +27 -0
- package/Types/Rum/ProductAnalyticsEvents.d.mts +121 -0
- package/Types/Rum/ProductAnalyticsEvents.d.ts +121 -0
- package/Types/Rum/ProductAnalyticsEvents.js +477 -0
- package/Types/Rum/ProductAnalyticsEvents.mjs +40 -0
- package/Types/Rum/ProductAnalyticsSavedViews.d.mts +56 -0
- package/Types/Rum/ProductAnalyticsSavedViews.d.ts +56 -0
- package/Types/Rum/ProductAnalyticsSavedViews.js +219 -0
- package/Types/Rum/ProductAnalyticsSavedViews.mjs +14 -0
- package/Types/Rum/SessionReplay.d.mts +4 -0
- package/Types/Rum/SessionReplay.d.ts +4 -0
- package/Types/Rum/SessionReplayHealth.js +1 -1
- package/Types/SecurityEvent/Connectors/SecurityEventConnectorCatalog.js +8 -7
- package/Types/ServiceLevelObjective/SloErrorBudgetPolicyChange.d.mts +10 -0
- package/Types/ServiceLevelObjective/SloErrorBudgetPolicyChange.d.ts +10 -0
- package/Types/ServiceLevelObjective/SloErrorBudgetPolicyChange.js +51 -0
- package/Types/ServiceLevelObjective/SloErrorBudgetPolicyChange.mjs +4 -0
- package/Types/Team/BuiltInTeam.d.mts +1 -0
- package/Types/Team/BuiltInTeam.d.ts +1 -0
- package/Types/Team/BuiltInTeam.js +14 -1
- package/Types/Team/BuiltInTeam.mjs +1 -0
- package/Types/Telemetry/ServiceType.d.mts +1 -0
- package/Types/Telemetry/ServiceType.d.ts +1 -0
- package/Types/Telemetry/ServiceType.js +6 -0
- package/Types/Telemetry/TelemetryUsage.d.mts +7 -2
- package/Types/Telemetry/TelemetryUsage.d.ts +7 -2
- package/Types/Telemetry/TelemetryUsage.js +24 -5
- package/Types/Telemetry/TelemetryUsage.mjs +3 -0
- package/Types/UserNotification/UserNotificationStatus.d.mts +2 -1
- package/Types/UserNotification/UserNotificationStatus.d.ts +2 -1
- package/Types/UserNotification/UserNotificationStatus.js +8 -0
- package/Types/Workspace/NotificationRules/EventType.d.mts +2 -1
- package/Types/Workspace/NotificationRules/EventType.d.ts +2 -1
- package/Types/Workspace/NotificationRules/EventType.js +8 -0
- package/Types/Workspace/NotificationRules/NotificationRuleCondition.d.mts +7 -1
- package/Types/Workspace/NotificationRules/NotificationRuleCondition.d.ts +7 -1
- package/Types/Workspace/NotificationRules/NotificationRuleInvites.js +5 -1
- package/Types/Workspace/NotificationRules/NotificationRuleTypes/ServiceLevelObjectiveNotificationRule.d.mts +4 -0
- package/Types/Workspace/NotificationRules/NotificationRuleTypes/ServiceLevelObjectiveNotificationRule.d.ts +4 -0
- package/Types/Workspace/NotificationRules/NotificationRuleTypes/ServiceLevelObjectiveNotificationRule.js +2 -0
- package/Types/Workspace/NotificationRules/NotificationRuleTypes/ServiceLevelObjectiveNotificationRule.mjs +1 -0
- package/Utils/AI/InvestigationReport.js +93 -21
- package/Utils/AI/InvestigationReportLanguages.d.mts +25 -0
- package/Utils/AI/InvestigationReportLanguages.d.ts +25 -0
- package/Utils/AI/InvestigationReportLanguages.js +603 -0
- package/Utils/AI/InvestigationReportLanguages.mjs +11 -0
- package/Utils/Crypto.js +10 -3
- package/Utils/Dashboard/Components/DashboardProductAnalyticsFunnelComponent.d.mts +7 -0
- package/Utils/Dashboard/Components/DashboardProductAnalyticsFunnelComponent.d.ts +7 -0
- package/Utils/Dashboard/Components/DashboardProductAnalyticsFunnelComponent.js +67 -0
- package/Utils/Dashboard/Components/DashboardProductAnalyticsFunnelComponent.mjs +2 -0
- package/Utils/Dashboard/Components/DashboardProductAnalyticsRetentionComponent.d.mts +7 -0
- package/Utils/Dashboard/Components/DashboardProductAnalyticsRetentionComponent.d.ts +7 -0
- package/Utils/Dashboard/Components/DashboardProductAnalyticsRetentionComponent.js +68 -0
- package/Utils/Dashboard/Components/DashboardProductAnalyticsRetentionComponent.mjs +2 -0
- package/Utils/Dashboard/DashboardWidgetIds.js +6 -1
- package/Utils/Dashboard/TableThresholds.js +5 -2
- package/Utils/Metrics/MetricQueryCloudAggregation.js +2 -4
- package/Utils/Monitor/MonitorLogSummaryUtil.d.mts +8 -0
- package/Utils/Monitor/MonitorLogSummaryUtil.d.ts +8 -0
- package/Utils/Monitor/MonitorLogSummaryUtil.js +170 -0
- package/Utils/Monitor/MonitorRootCauseWording.d.mts +17 -0
- package/Utils/Monitor/MonitorRootCauseWording.d.ts +17 -0
- package/Utils/Monitor/MonitorRootCauseWording.js +246 -0
- package/Utils/Monitor/MonitorRootCauseWording.mjs +2 -0
- package/Utils/Monitor/MonitorStepMetricQueries.js +2 -1
- package/Utils/Monitor/MonitorStepsValuesUtil.d.mts +13 -0
- package/Utils/Monitor/MonitorStepsValuesUtil.d.ts +13 -0
- package/Utils/Monitor/MonitorStepsValuesUtil.js +80 -0
- package/Utils/Monitor/MonitorStepsValuesUtil.mjs +2 -0
- package/Utils/Monitor/MonitorSummarySnapshotUtil.d.mts +3 -0
- package/Utils/Monitor/MonitorSummarySnapshotUtil.d.ts +3 -0
- package/Utils/Monitor/MonitorSummarySnapshotUtil.js +5 -2
- package/Utils/NetworkDevice/Naming/DeviceNamingPlanner.d.mts +75 -0
- package/Utils/NetworkDevice/Naming/DeviceNamingPlanner.d.ts +75 -0
- package/Utils/NetworkDevice/Naming/DeviceNamingPlanner.js +303 -0
- package/Utils/NetworkDevice/Naming/DeviceNamingPlanner.mjs +8 -0
- package/Utils/NetworkDevice/Naming/NamePattern.d.mts +122 -0
- package/Utils/NetworkDevice/Naming/NamePattern.d.ts +122 -0
- package/Utils/NetworkDevice/Naming/NamePattern.js +649 -0
- package/Utils/NetworkDevice/Naming/NamePattern.mjs +22 -0
- package/Utils/NetworkDevice/Naming/NamingLookup.d.mts +77 -0
- package/Utils/NetworkDevice/Naming/NamingLookup.d.ts +77 -0
- package/Utils/NetworkDevice/Naming/NamingLookup.js +467 -0
- package/Utils/NetworkDevice/Naming/NamingLookup.mjs +14 -0
- package/Utils/NetworkDevice/Naming/NamingRuleMatcher.d.mts +26 -0
- package/Utils/NetworkDevice/Naming/NamingRuleMatcher.d.ts +26 -0
- package/Utils/NetworkDevice/Naming/NamingRuleMatcher.js +327 -0
- package/Utils/NetworkDevice/Naming/NamingRuleMatcher.mjs +7 -0
- package/Utils/NetworkDiscovery/DiscoveredNameUpgrade.d.mts +1 -0
- package/Utils/NetworkDiscovery/DiscoveredNameUpgrade.d.ts +1 -0
- package/Utils/NetworkDiscovery/DiscoveredNameUpgrade.js +8 -0
- package/Utils/NetworkDiscovery/PingMonitorBuilder.d.mts +2 -0
- package/Utils/NetworkDiscovery/PingMonitorBuilder.d.ts +2 -0
- package/Utils/NetworkDiscovery/PingMonitorBuilder.js +1 -0
- package/Utils/{Rum → SessionReplay}/SessionReplayHealth.d.mts +7 -6
- package/Utils/{Rum → SessionReplay}/SessionReplayHealth.d.ts +7 -6
- package/Utils/SessionReplay/SessionReplayHealth.js +703 -0
- package/Utils/Slo/SloErrorBudgetPolicy.d.mts +7 -0
- package/Utils/Slo/SloErrorBudgetPolicy.d.ts +7 -0
- package/Utils/Slo/SloErrorBudgetPolicy.js +39 -0
- package/Utils/Slo/SloErrorBudgetPolicy.mjs +1 -0
- package/Utils/Slo/SloFeedMarkdown.d.mts +19 -4
- package/Utils/Slo/SloFeedMarkdown.d.ts +19 -4
- package/Utils/Slo/SloFeedMarkdown.js +64 -17
- package/Utils/Slo/SloFeedMarkdown.mjs +4 -0
- package/Utils/Slo/SloProjection.d.mts +18 -0
- package/Utils/Slo/SloProjection.d.ts +18 -0
- package/Utils/Slo/SloProjection.js +53 -12
- package/Utils/Slo/SloProjection.mjs +2 -0
- package/Utils/StatusPage/ResourceExplorer.d.mts +0 -10
- package/Utils/StatusPage/ResourceExplorer.d.ts +0 -10
- package/Utils/StatusPage/ResourceExplorer.js +5 -32
- package/Utils/TotpSetupKey.d.mts +3 -0
- package/Utils/TotpSetupKey.d.ts +3 -0
- package/Utils/TotpSetupKey.js +72 -0
- package/Utils/TotpSetupKey.mjs +4 -0
- package/Utils/Workspace/WorkspaceChannelName.js +5 -1
- package/package.json +1 -1
- package/Utils/Rum/SessionReplayHealth.js +0 -558
- /package/Utils/{Rum → SessionReplay}/SessionReplayHealth.mjs +0 -0
|
@@ -0,0 +1,875 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setCodeApartInSentence = exports.getCodeInSentence = exports.LEFT_TO_RIGHT_ISOLATE = void 0;
|
|
4
|
+
const ReadingDirection_1 = require("./ReadingDirection");
|
|
5
|
+
/*
|
|
6
|
+
* CODE IN A SENTENCE READ FROM THE RIGHT, DRAWN AS IT IS WRITTEN.
|
|
7
|
+
*
|
|
8
|
+
* An Arabic or Persian sentence that names a function, a path or a flag -
|
|
9
|
+
* "تُلتقط المقاييس المخصصة ... باستخدام oneuptime.captureMetric()." - is
|
|
10
|
+
* laid out by the Unicode bidi algorithm as one paragraph read from the
|
|
11
|
+
* right. The letters of the code are a run read from the left, but the
|
|
12
|
+
* signs at its ends are not letters: they take the sentence's direction,
|
|
13
|
+
* and the browser draws them at the code's other end. The brackets of
|
|
14
|
+
* oneuptime.captureMetric() came out before its name, the slash of
|
|
15
|
+
* /api/v1/users after it, and --help read help--. The words in the locale
|
|
16
|
+
* files were right; only the drawing was wrong.
|
|
17
|
+
*
|
|
18
|
+
* So in a sentence of a language read from the right, each stretch of
|
|
19
|
+
* text in letters read from the left that holds code is set apart in a
|
|
20
|
+
* Unicode LEFT-TO-RIGHT ISOLATE (LRI ... PDI): inside it, it reads from
|
|
21
|
+
* the left with every sign where it was written, and the sentence around
|
|
22
|
+
* it still reads from the right, the isolate one piece of it. It is done
|
|
23
|
+
* as the words are handed to the page, not in the locale files: every
|
|
24
|
+
* frontend's i18next runs each translated sentence through it
|
|
25
|
+
* (Common/UI/Utils/CodeReadsAsWritten), so a sentence added tomorrow, or
|
|
26
|
+
* a language read from the right added next year, is drawn right without
|
|
27
|
+
* anyone remembering to.
|
|
28
|
+
*
|
|
29
|
+
* Only what the browser would draw wrongly is set apart. A stretch whose
|
|
30
|
+
* first and last signs are letters or digits is drawn right as it is
|
|
31
|
+
* ("Node.js", "helm upgrade --reuse-values", "Pub/Sub"), and so is a
|
|
32
|
+
* bracket round words ("track('signup')"), which the bidi algorithm pairs
|
|
33
|
+
* with the letters before it. What is set apart starts or ends with a sign
|
|
34
|
+
* that belongs to the code: a function's brackets, a path's slash, a
|
|
35
|
+
* file's or a flag's leading dot or dash, a glob's star, a sign beside a
|
|
36
|
+
* number ("+1", "-2", "{{count}}+"). So is an expression that starts
|
|
37
|
+
* with a number - a cron line, "2^64", "2001:db8::1" - whose digits the
|
|
38
|
+
* bidi algorithm reads as a number of the sentence's. What belongs to the
|
|
39
|
+
* sentence stays outside: the full stop after the code, the brackets and
|
|
40
|
+
* quotation marks the sentence puts round it, a slash or an arrow set off
|
|
41
|
+
* by spaces between two words ("CPU / الذاكرة", "APM > الخدمات"), or a
|
|
42
|
+
* slash joining a word to the sentence's own ("CPU/الذاكرة").
|
|
43
|
+
*
|
|
44
|
+
* A {{placeholder}} is one piece that is never cut. Inside code it is set
|
|
45
|
+
* apart once more, in a first-strong isolate (FSI ... PDI), so a value in
|
|
46
|
+
* Arabic letters still reads the way its own letters do; and one written
|
|
47
|
+
* onto a word of the code ("v{{version}}", "{{url}}/otlp") sets the code
|
|
48
|
+
* apart, as its value may come in an isolate of its own. Stretches of
|
|
49
|
+
* nothing but values and signs - "~{{time}} {{count}}" - are read value by
|
|
50
|
+
* value: a sign stays with the value it is written beside, and two values
|
|
51
|
+
* keep the sentence's order. An HTML tag ("<p>"), a value's isolate or an
|
|
52
|
+
* isolate already in the sentence is never entered, and a sentence with no
|
|
53
|
+
* letter of a script read from the right - English left on the page, a
|
|
54
|
+
* name, an example - is left as it is: it reads from the left already.
|
|
55
|
+
*/
|
|
56
|
+
// LEFT-TO-RIGHT ISOLATE: what follows it, up to its PDI, reads from the left.
|
|
57
|
+
exports.LEFT_TO_RIGHT_ISOLATE = String.fromCharCode(0x2066);
|
|
58
|
+
const RIGHT_TO_LEFT_ISOLATE = String.fromCharCode(0x2067);
|
|
59
|
+
// A mark that reads from the left, placed by hand: it steadies a sign itself.
|
|
60
|
+
const LEFT_TO_RIGHT_MARK = String.fromCharCode(0x200e);
|
|
61
|
+
/*
|
|
62
|
+
* A letter, a sign or a mark of a script read from the right: Arabic
|
|
63
|
+
* (with its comma, semicolon and question mark, and its digits), Hebrew,
|
|
64
|
+
* Syriac, Thaana, N'Ko and the others ReadingDirection names, and the
|
|
65
|
+
* RIGHT-TO-LEFT MARK. Each ends a stretch of left-to-right text.
|
|
66
|
+
*/
|
|
67
|
+
const RIGHT_TO_LEFT_CHARACTER_REGEX = /[\p{Script_Extensions=Arabic}\p{Script_Extensions=Hebrew}\p{Script_Extensions=Syriac}\p{Script_Extensions=Thaana}\p{Script_Extensions=Nko}\p{Script_Extensions=Adlam}\p{Script_Extensions=Hanifi_Rohingya}\p{Script_Extensions=Mandaic}\p{Script_Extensions=Samaritan}\u{200F}]/u;
|
|
68
|
+
// A run of them: one piece of the sentence's own, however long.
|
|
69
|
+
const RIGHT_TO_LEFT_RUN_REGEX = new RegExp(`${RIGHT_TO_LEFT_CHARACTER_REGEX.source}+`, "uy");
|
|
70
|
+
// A letter of any script, with its accents.
|
|
71
|
+
const LETTER_REGEX = /^[\p{L}\p{M}]$/u;
|
|
72
|
+
/*
|
|
73
|
+
* Two letters, each with its accents or vowel signs, at the end of a text:
|
|
74
|
+
* a word, not a letter written onto what follows it. Read on the last
|
|
75
|
+
* WORD_END_LENGTH characters only.
|
|
76
|
+
*/
|
|
77
|
+
const WORD_AT_END_REGEX = /\p{L}\p{M}{0,4}\p{L}\p{M}{0,4}$/u;
|
|
78
|
+
const WORD_END_LENGTH = 16;
|
|
79
|
+
// One decimal digit, of any script.
|
|
80
|
+
const DIGIT_REGEX = /^\p{Nd}$/u;
|
|
81
|
+
// A space of any width.
|
|
82
|
+
const SPACE_REGEX = /^\s$/u;
|
|
83
|
+
/*
|
|
84
|
+
* A line's end, an embedding, an override or the end of an isolate: no
|
|
85
|
+
* stretch of text runs across one.
|
|
86
|
+
*/
|
|
87
|
+
const STRETCH_BREAK_REGEX = /^[\r\n\u{2028}\u{2029}\u{85}\u{202A}-\u{202E}\u{2069}]$/u;
|
|
88
|
+
// A {{placeholder}}, which a value fills: one piece, never cut.
|
|
89
|
+
const PLACEHOLDER_REGEX = /\{\{[^{}]*\}\}/y;
|
|
90
|
+
// Every {{placeholder}} in a piece of code.
|
|
91
|
+
const PLACEHOLDERS_REGEX = /\{\{[^{}]*\}\}/g;
|
|
92
|
+
/*
|
|
93
|
+
* An HTML tag a sentence holds - "<p>", "</p>", "<br/>", "<a href=...>" -
|
|
94
|
+
* or a numbered one a translation fills with an element ("<0>", "</0>"):
|
|
95
|
+
* never entered, and no code runs across one. A placeholder of code's own
|
|
96
|
+
* in angle brackets ("<token>", "<file>", "<link>") is not a tag: it is
|
|
97
|
+
* part of the code.
|
|
98
|
+
*/
|
|
99
|
+
const MARKUP_TAG_REGEX = /<\/?(?:\d{1,3}|a|abbr|b|bdi|bdo|blockquote|br|code|dd|del|div|dl|dt|em|h[1-6]|hr|i|img|ins|kbd|li|mark|ol|p|pre|q|s|samp|small|span|strong|sub|sup|table|tbody|td|th|thead|tr|u|ul)(?:\s[^<>]{0,256})?\/?>/y;
|
|
100
|
+
// An HTML entity - "›", "›": one sign, never cut.
|
|
101
|
+
const ENTITY_REGEX = /&(?:[A-Za-z][A-Za-z0-9]{1,31}|#\d{1,7}|#[xX][\dA-Fa-f]{1,6});/y;
|
|
102
|
+
/*
|
|
103
|
+
* A Markdown link's target - the "(/docs/...)" of "[words](/docs/...)":
|
|
104
|
+
* never drawn, so never entered. A mark inside it would be part of the
|
|
105
|
+
* address the link opens.
|
|
106
|
+
*/
|
|
107
|
+
const LINK_TARGET_REGEX = /\([^()\s]{0,2048}\)/y;
|
|
108
|
+
/*
|
|
109
|
+
* The signs a sentence ends a clause with. One right after the code is
|
|
110
|
+
* the sentence's, not the code's: "grantConsent().", "webcal://.",
|
|
111
|
+
* "{{itemsName}}…" - but not after a backslash ("^orders\.").
|
|
112
|
+
*/
|
|
113
|
+
const SENTENCE_STOPS = [
|
|
114
|
+
".",
|
|
115
|
+
",",
|
|
116
|
+
";",
|
|
117
|
+
":",
|
|
118
|
+
"!",
|
|
119
|
+
"?",
|
|
120
|
+
"\u{2026}",
|
|
121
|
+
];
|
|
122
|
+
// Brackets and quotation marks that open, and the sign that closes each.
|
|
123
|
+
const CLOSING_SIGN_OF = {
|
|
124
|
+
"(": ")",
|
|
125
|
+
"[": "]",
|
|
126
|
+
"{": "}",
|
|
127
|
+
"\u{00AB}": "\u{00BB}",
|
|
128
|
+
"\u{201C}": "\u{201D}",
|
|
129
|
+
"\u{2018}": "\u{2019}",
|
|
130
|
+
"\u{2039}": "\u{203A}",
|
|
131
|
+
};
|
|
132
|
+
const CLOSING_SIGNS = Object.values(CLOSING_SIGN_OF);
|
|
133
|
+
/*
|
|
134
|
+
* The brackets the bidi algorithm pairs (its paired brackets): one round
|
|
135
|
+
* letters takes their direction. A quotation mark is never paired - the
|
|
136
|
+
* closing quote of crossorigin="anonymous" went to the far end of the code.
|
|
137
|
+
*/
|
|
138
|
+
const BIDI_BRACKETS = ["(", ")", "[", "]", "{", "}"];
|
|
139
|
+
// Quotation marks that open and close with the same sign.
|
|
140
|
+
const SAME_SIGN_QUOTES = ['"', "'", "`"];
|
|
141
|
+
// Between two letters these are apostrophes ("it's"), not quotation marks.
|
|
142
|
+
const APOSTROPHES = ["'", "\u{2019}"];
|
|
143
|
+
/*
|
|
144
|
+
* Signs that join the number beside them (the bidi algorithm's European
|
|
145
|
+
* terminators): "#12", "$5", "90%", "21°" are drawn right as they are.
|
|
146
|
+
* A plus or a minus is not one: "-2" and "+1" lost their sign to the
|
|
147
|
+
* number's other end.
|
|
148
|
+
*/
|
|
149
|
+
const NUMBER_SIGNS = [
|
|
150
|
+
"#",
|
|
151
|
+
"$",
|
|
152
|
+
"%",
|
|
153
|
+
"\u{00B1}",
|
|
154
|
+
"\u{00B0}",
|
|
155
|
+
"\u{2030}",
|
|
156
|
+
"\u{00A2}",
|
|
157
|
+
"\u{00A3}",
|
|
158
|
+
"\u{00A5}",
|
|
159
|
+
"\u{20AC}",
|
|
160
|
+
"\u{20B9}",
|
|
161
|
+
];
|
|
162
|
+
/*
|
|
163
|
+
* Signs the bidi algorithm keeps inside a number when they stand between
|
|
164
|
+
* two digits (its common and European separators): "10.0.0.1", "1,000",
|
|
165
|
+
* "24/7", "09:00", "1-5".
|
|
166
|
+
*/
|
|
167
|
+
const NUMBER_JOINERS = [
|
|
168
|
+
".",
|
|
169
|
+
",",
|
|
170
|
+
"/",
|
|
171
|
+
":",
|
|
172
|
+
"+",
|
|
173
|
+
"-",
|
|
174
|
+
"\u{00A0}",
|
|
175
|
+
"\u{2212}",
|
|
176
|
+
];
|
|
177
|
+
/*
|
|
178
|
+
* Signs that set a number off from what follows it - a dash between two
|
|
179
|
+
* numbers, a dot between two items: "70–85%", "عاملون: 2 · Docker". The
|
|
180
|
+
* sentence's own, drawn in its direction.
|
|
181
|
+
*/
|
|
182
|
+
const NUMBER_SEPARATORS = [
|
|
183
|
+
"\u{2013}",
|
|
184
|
+
"\u{2014}",
|
|
185
|
+
"\u{00B7}",
|
|
186
|
+
"\u{2022}",
|
|
187
|
+
];
|
|
188
|
+
// Markdown's emphasis: "**bold**", "__bold__" - drawn as style, not as signs.
|
|
189
|
+
const EMPHASIS_SIGNS = ["*", "_"];
|
|
190
|
+
/*
|
|
191
|
+
* How deep brackets pair: as deep as the bidi algorithm pairs them (its
|
|
192
|
+
* stack holds 63). Brackets opened deeper are left unpaired, so a text
|
|
193
|
+
* of nothing but brackets is read in time that grows with its length.
|
|
194
|
+
*/
|
|
195
|
+
const MOST_OPEN_BRACKETS = 63;
|
|
196
|
+
// How far an expression from a number is read for the sign that makes it one.
|
|
197
|
+
const MOST_EXPRESSION_PIECES = 128;
|
|
198
|
+
/*
|
|
199
|
+
* How many times a stretch is trimmed of what belongs to the sentence -
|
|
200
|
+
* a space, a full stop, a quotation mark - before what is left is read:
|
|
201
|
+
* a sentence needs a handful, and a text of thousands of signs is not
|
|
202
|
+
* trimmed one sign at a time.
|
|
203
|
+
*/
|
|
204
|
+
const MOST_PEELS = 64;
|
|
205
|
+
// The whole match of a sticky `regex` at `index` in `text`, or null.
|
|
206
|
+
const matchAt = (regex, text, index) => {
|
|
207
|
+
regex.lastIndex = index;
|
|
208
|
+
const match = regex.exec(text);
|
|
209
|
+
return match ? match[0] : null;
|
|
210
|
+
};
|
|
211
|
+
/*
|
|
212
|
+
* The sentence cut into pieces: a character, a {{placeholder}} or an HTML
|
|
213
|
+
* entity whole, or a break - a line's end, an HTML tag, or a whole isolate
|
|
214
|
+
* (LRI, RLI or FSI up to its PDI), which is never entered.
|
|
215
|
+
*/
|
|
216
|
+
const getPieces = (sentence) => {
|
|
217
|
+
const pieces = [];
|
|
218
|
+
let index = 0;
|
|
219
|
+
while (index < sentence.length) {
|
|
220
|
+
const words = matchAt(RIGHT_TO_LEFT_RUN_REGEX, sentence, index);
|
|
221
|
+
if (words) {
|
|
222
|
+
pieces.push({
|
|
223
|
+
kind: "sentence",
|
|
224
|
+
text: words,
|
|
225
|
+
start: index,
|
|
226
|
+
end: index + words.length,
|
|
227
|
+
});
|
|
228
|
+
index += words.length;
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
const codePoint = sentence.codePointAt(index);
|
|
232
|
+
const character = String.fromCodePoint(codePoint);
|
|
233
|
+
const next = index + character.length;
|
|
234
|
+
if (character === exports.LEFT_TO_RIGHT_ISOLATE ||
|
|
235
|
+
character === RIGHT_TO_LEFT_ISOLATE ||
|
|
236
|
+
character === ReadingDirection_1.FIRST_STRONG_ISOLATE) {
|
|
237
|
+
// To its PDI, counting the isolates inside it.
|
|
238
|
+
let depth = 1;
|
|
239
|
+
let end = next;
|
|
240
|
+
while (end < sentence.length && depth > 0) {
|
|
241
|
+
const inner = sentence.charAt(end);
|
|
242
|
+
if (inner === exports.LEFT_TO_RIGHT_ISOLATE ||
|
|
243
|
+
inner === RIGHT_TO_LEFT_ISOLATE ||
|
|
244
|
+
inner === ReadingDirection_1.FIRST_STRONG_ISOLATE) {
|
|
245
|
+
depth++;
|
|
246
|
+
}
|
|
247
|
+
else if (inner === ReadingDirection_1.POP_DIRECTIONAL_ISOLATE) {
|
|
248
|
+
depth--;
|
|
249
|
+
}
|
|
250
|
+
end++;
|
|
251
|
+
}
|
|
252
|
+
pieces.push({
|
|
253
|
+
kind: "break",
|
|
254
|
+
text: sentence.slice(index, end),
|
|
255
|
+
start: index,
|
|
256
|
+
end: end,
|
|
257
|
+
});
|
|
258
|
+
index = end;
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
let whole = null;
|
|
262
|
+
let wholeKind = "sign";
|
|
263
|
+
if (character === "{") {
|
|
264
|
+
whole = matchAt(PLACEHOLDER_REGEX, sentence, index);
|
|
265
|
+
wholeKind = "placeholder";
|
|
266
|
+
}
|
|
267
|
+
else if (character === "<") {
|
|
268
|
+
whole = matchAt(MARKUP_TAG_REGEX, sentence, index);
|
|
269
|
+
wholeKind = "break";
|
|
270
|
+
}
|
|
271
|
+
else if (character === "&") {
|
|
272
|
+
whole = matchAt(ENTITY_REGEX, sentence, index);
|
|
273
|
+
wholeKind = "sign";
|
|
274
|
+
}
|
|
275
|
+
else if (character === "(" && sentence.charAt(index - 1) === "]") {
|
|
276
|
+
whole = matchAt(LINK_TARGET_REGEX, sentence, index);
|
|
277
|
+
wholeKind = "break";
|
|
278
|
+
}
|
|
279
|
+
if (whole) {
|
|
280
|
+
pieces.push({
|
|
281
|
+
kind: wholeKind,
|
|
282
|
+
text: whole,
|
|
283
|
+
start: index,
|
|
284
|
+
end: index + whole.length,
|
|
285
|
+
});
|
|
286
|
+
index += whole.length;
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
let kind = "sign";
|
|
290
|
+
if (STRETCH_BREAK_REGEX.test(character)) {
|
|
291
|
+
kind = "break";
|
|
292
|
+
}
|
|
293
|
+
else if (character === LEFT_TO_RIGHT_MARK) {
|
|
294
|
+
kind = "mark";
|
|
295
|
+
}
|
|
296
|
+
else if (LETTER_REGEX.test(character)) {
|
|
297
|
+
kind = "letter";
|
|
298
|
+
}
|
|
299
|
+
else if (DIGIT_REGEX.test(character)) {
|
|
300
|
+
kind = "digit";
|
|
301
|
+
}
|
|
302
|
+
else if (SPACE_REGEX.test(character)) {
|
|
303
|
+
kind = "space";
|
|
304
|
+
}
|
|
305
|
+
pieces.push({ kind, text: character, start: index, end: next });
|
|
306
|
+
index = next;
|
|
307
|
+
}
|
|
308
|
+
return pieces;
|
|
309
|
+
};
|
|
310
|
+
// A piece the bidi algorithm reads in its own direction: a word, a number, a value.
|
|
311
|
+
const isStrong = (piece) => {
|
|
312
|
+
return (piece !== undefined &&
|
|
313
|
+
(piece.kind === "letter" ||
|
|
314
|
+
piece.kind === "digit" ||
|
|
315
|
+
piece.kind === "placeholder" ||
|
|
316
|
+
piece.kind === "mark"));
|
|
317
|
+
};
|
|
318
|
+
// What code is made of, beside its signs: a letter, a digit or a value.
|
|
319
|
+
const isContent = (piece) => {
|
|
320
|
+
return (piece !== undefined &&
|
|
321
|
+
(piece.kind === "letter" ||
|
|
322
|
+
piece.kind === "digit" ||
|
|
323
|
+
piece.kind === "placeholder"));
|
|
324
|
+
};
|
|
325
|
+
const isNumberLike = (piece) => {
|
|
326
|
+
return (piece !== undefined &&
|
|
327
|
+
(piece.kind === "digit" || piece.kind === "placeholder"));
|
|
328
|
+
};
|
|
329
|
+
const isSign = (piece, signs) => {
|
|
330
|
+
return (piece !== undefined && piece.kind === "sign" && signs.includes(piece.text));
|
|
331
|
+
};
|
|
332
|
+
// A bracket or a quotation mark, opening or closing.
|
|
333
|
+
const isBracket = (piece) => {
|
|
334
|
+
return (piece !== undefined &&
|
|
335
|
+
piece.kind === "sign" &&
|
|
336
|
+
(CLOSING_SIGN_OF[piece.text] !== undefined ||
|
|
337
|
+
CLOSING_SIGNS.includes(piece.text) ||
|
|
338
|
+
SAME_SIGN_QUOTES.includes(piece.text)));
|
|
339
|
+
};
|
|
340
|
+
// A bracket or a quotation mark that closes.
|
|
341
|
+
const isClosingSign = (piece) => {
|
|
342
|
+
return (piece !== undefined &&
|
|
343
|
+
piece.kind === "sign" &&
|
|
344
|
+
(CLOSING_SIGNS.includes(piece.text) ||
|
|
345
|
+
SAME_SIGN_QUOTES.includes(piece.text)));
|
|
346
|
+
};
|
|
347
|
+
// An apostrophe between two letters ("it's", "it’s"): part of the word.
|
|
348
|
+
const isApostrophe = (pieces, index) => {
|
|
349
|
+
var _a, _b;
|
|
350
|
+
return (isSign(pieces[index], APOSTROPHES) &&
|
|
351
|
+
((_a = pieces[index - 1]) === null || _a === void 0 ? void 0 : _a.kind) === "letter" &&
|
|
352
|
+
((_b = pieces[index + 1]) === null || _b === void 0 ? void 0 : _b.kind) === "letter");
|
|
353
|
+
};
|
|
354
|
+
/*
|
|
355
|
+
* Which bracket or quotation mark closes which, in one stretch of text:
|
|
356
|
+
* partner[i] is the piece that opens or closes with piece i, or -1. A
|
|
357
|
+
* quotation mark written with the same sign at both ends pairs with the
|
|
358
|
+
* next one; an apostrophe between two letters ("it's") is not one.
|
|
359
|
+
*/
|
|
360
|
+
const getPartners = (pieces) => {
|
|
361
|
+
const partner = pieces.map(() => {
|
|
362
|
+
return -1;
|
|
363
|
+
});
|
|
364
|
+
const opened = [];
|
|
365
|
+
const openQuote = {};
|
|
366
|
+
pieces.forEach((piece, index) => {
|
|
367
|
+
if (!isBracket(piece) || isApostrophe(pieces, index)) {
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
if (SAME_SIGN_QUOTES.includes(piece.text)) {
|
|
371
|
+
const before = openQuote[piece.text];
|
|
372
|
+
if (before === undefined) {
|
|
373
|
+
openQuote[piece.text] = index;
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
partner[before] = index;
|
|
377
|
+
partner[index] = before;
|
|
378
|
+
delete openQuote[piece.text];
|
|
379
|
+
}
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
if (CLOSING_SIGN_OF[piece.text] !== undefined) {
|
|
383
|
+
// As deep as the bidi algorithm pairs brackets, and no deeper.
|
|
384
|
+
if (opened.length < MOST_OPEN_BRACKETS) {
|
|
385
|
+
opened.push(index);
|
|
386
|
+
}
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
// A closing sign pairs with the nearest bracket still open that it closes.
|
|
390
|
+
for (let depth = opened.length - 1; depth >= 0; depth--) {
|
|
391
|
+
const openerIndex = opened[depth];
|
|
392
|
+
const opener = pieces[openerIndex];
|
|
393
|
+
if (CLOSING_SIGN_OF[opener.text] === piece.text) {
|
|
394
|
+
partner[openerIndex] = index;
|
|
395
|
+
partner[index] = openerIndex;
|
|
396
|
+
opened.length = depth;
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
return partner;
|
|
402
|
+
};
|
|
403
|
+
/*
|
|
404
|
+
* Whether pieces (from, to) - both ends left out - hold a letter: a
|
|
405
|
+
* bracket round letters takes their direction ("track('signup')"), one
|
|
406
|
+
* round a number or a value only does not ("getItem(2)").
|
|
407
|
+
*/
|
|
408
|
+
const holdsLetters = (pieces, from, to) => {
|
|
409
|
+
var _a;
|
|
410
|
+
for (let index = from + 1; index < to; index++) {
|
|
411
|
+
if (((_a = pieces[index]) === null || _a === void 0 ? void 0 : _a.kind) === "letter") {
|
|
412
|
+
return true;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
return false;
|
|
416
|
+
};
|
|
417
|
+
/*
|
|
418
|
+
* Whether the sentence's words right after a stretch start with a letter:
|
|
419
|
+
* a sign between the two ("CPU/الذاكرة") joins two words. Before the
|
|
420
|
+
* sentence's comma ("<key>،") or a mark, a sign is the code's own.
|
|
421
|
+
*/
|
|
422
|
+
const isBeforeWord = (piece) => {
|
|
423
|
+
if ((piece === null || piece === void 0 ? void 0 : piece.kind) !== "sentence") {
|
|
424
|
+
return false;
|
|
425
|
+
}
|
|
426
|
+
const character = String.fromCodePoint(piece.text.codePointAt(0));
|
|
427
|
+
return LETTER_REGEX.test(character);
|
|
428
|
+
};
|
|
429
|
+
/*
|
|
430
|
+
* Whether the sentence's words right before a stretch end in a word of
|
|
431
|
+
* two letters or more ("الذاكرة/CPU"). A letter on its own is a prefix
|
|
432
|
+
* written onto the code - "و/orders/2" is "and /orders/2" - and the sign
|
|
433
|
+
* after it is the code's.
|
|
434
|
+
*/
|
|
435
|
+
const isAfterWord = (piece) => {
|
|
436
|
+
if ((piece === null || piece === void 0 ? void 0 : piece.kind) !== "sentence") {
|
|
437
|
+
return false;
|
|
438
|
+
}
|
|
439
|
+
// Its last letters, with their vowel signs: never more than a few.
|
|
440
|
+
return WORD_AT_END_REGEX.test(piece.text.slice(-WORD_END_LENGTH));
|
|
441
|
+
};
|
|
442
|
+
/*
|
|
443
|
+
* Whether a stretch is an expression that starts with a number - the cron
|
|
444
|
+
* line "0 9 * * 1-5", "2^64", "0=inactive", "2001:db8::1". In a
|
|
445
|
+
* sentence read from the right the bidi algorithm reads its digits as a
|
|
446
|
+
* number of the sentence's, and a sign after them that does not join two
|
|
447
|
+
* digits takes the sentence's direction: the expression was drawn back to
|
|
448
|
+
* front. A star, or a sign written between two pieces of it, makes one.
|
|
449
|
+
* A number on its own, with the signs it is written with ("10.0.0.1",
|
|
450
|
+
* "99.9%", "1,000 USD"), and one the sentence sets off - by a space, a
|
|
451
|
+
* bracket, a dash or a dot ("10 = ...", "1433 (SQL Server)", "70–85%") -
|
|
452
|
+
* is the sentence's, drawn in its order.
|
|
453
|
+
*/
|
|
454
|
+
const isNumberExpression = (pieces, from, to) => {
|
|
455
|
+
var _a;
|
|
456
|
+
// Read no further than an expression runs: a text of thousands of signs is no cron line.
|
|
457
|
+
const end = Math.min(to, from + MOST_EXPRESSION_PIECES);
|
|
458
|
+
let index = from;
|
|
459
|
+
while (index < end && !isContent(pieces[index])) {
|
|
460
|
+
index++;
|
|
461
|
+
}
|
|
462
|
+
if (index >= end || ((_a = pieces[index]) === null || _a === void 0 ? void 0 : _a.kind) !== "digit") {
|
|
463
|
+
return false;
|
|
464
|
+
}
|
|
465
|
+
for (; index < end; index++) {
|
|
466
|
+
const piece = pieces[index];
|
|
467
|
+
if (piece.kind === "letter") {
|
|
468
|
+
return false;
|
|
469
|
+
}
|
|
470
|
+
if (piece.kind !== "sign") {
|
|
471
|
+
continue;
|
|
472
|
+
}
|
|
473
|
+
if (piece.text === "*") {
|
|
474
|
+
return true;
|
|
475
|
+
}
|
|
476
|
+
const before = index > from ? pieces[index - 1] : undefined;
|
|
477
|
+
const after = index < to - 1 ? pieces[index + 1] : undefined;
|
|
478
|
+
const isBetweenPieces = before !== undefined &&
|
|
479
|
+
after !== undefined &&
|
|
480
|
+
before.kind !== "space" &&
|
|
481
|
+
after.kind !== "space";
|
|
482
|
+
const isNumbers = (isSign(piece, NUMBER_JOINERS) &&
|
|
483
|
+
(before === null || before === void 0 ? void 0 : before.kind) === "digit" &&
|
|
484
|
+
(after === null || after === void 0 ? void 0 : after.kind) === "digit") ||
|
|
485
|
+
isSign(piece, NUMBER_SIGNS);
|
|
486
|
+
if (isBetweenPieces &&
|
|
487
|
+
!isNumbers &&
|
|
488
|
+
!isBracket(piece) &&
|
|
489
|
+
!isSign(piece, NUMBER_SEPARATORS)) {
|
|
490
|
+
return true;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
return false;
|
|
494
|
+
};
|
|
495
|
+
/*
|
|
496
|
+
* The code in one stretch of left-to-right text, if it needs setting
|
|
497
|
+
* apart: the stretch without what belongs to the sentence around it, or
|
|
498
|
+
* null when it reads right as it is.
|
|
499
|
+
*/
|
|
500
|
+
const getCodeInStretch = (pieces, touchesSentenceAtStart, touchesSentenceAtEnd) => {
|
|
501
|
+
var _a, _b, _c, _d, _e, _f;
|
|
502
|
+
const partner = getPartners(pieces);
|
|
503
|
+
let from = 0;
|
|
504
|
+
let to = pieces.length;
|
|
505
|
+
let gluedAtStart = touchesSentenceAtStart;
|
|
506
|
+
let gluedAtEnd = touchesSentenceAtEnd;
|
|
507
|
+
// Whether the sentence quotes the code: its last full stop is then the code's.
|
|
508
|
+
let isQuoted = false;
|
|
509
|
+
// A sign whose partner is inside the code: the code's own.
|
|
510
|
+
const isPairedWithin = (index) => {
|
|
511
|
+
const other = partner[index];
|
|
512
|
+
return other >= from && other < to;
|
|
513
|
+
};
|
|
514
|
+
// Markdown's strong emphasis, "**" or "__", starting at `index`.
|
|
515
|
+
const isEmphasisRun = (index) => {
|
|
516
|
+
var _a, _b, _c;
|
|
517
|
+
return (isSign(pieces[index], EMPHASIS_SIGNS) &&
|
|
518
|
+
((_a = pieces[index + 1]) === null || _a === void 0 ? void 0 : _a.kind) === "sign" &&
|
|
519
|
+
((_b = pieces[index + 1]) === null || _b === void 0 ? void 0 : _b.text) === ((_c = pieces[index]) === null || _c === void 0 ? void 0 : _c.text));
|
|
520
|
+
};
|
|
521
|
+
// Whether a run of `sign` twice starts in [start, end - 1).
|
|
522
|
+
const hasEmphasisRun = (sign, start, end) => {
|
|
523
|
+
var _a;
|
|
524
|
+
for (let index = start; index < end - 1; index++) {
|
|
525
|
+
if (((_a = pieces[index]) === null || _a === void 0 ? void 0 : _a.text) === sign && isEmphasisRun(index)) {
|
|
526
|
+
return true;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
return false;
|
|
530
|
+
};
|
|
531
|
+
let isChanged = true;
|
|
532
|
+
let peeled = 0;
|
|
533
|
+
while (isChanged && from < to && peeled < MOST_PEELS) {
|
|
534
|
+
isChanged = false;
|
|
535
|
+
peeled++;
|
|
536
|
+
while (from < to && ((_a = pieces[from]) === null || _a === void 0 ? void 0 : _a.kind) === "space") {
|
|
537
|
+
from++;
|
|
538
|
+
gluedAtStart = false;
|
|
539
|
+
isChanged = true;
|
|
540
|
+
}
|
|
541
|
+
while (to > from && ((_b = pieces[to - 1]) === null || _b === void 0 ? void 0 : _b.kind) === "space") {
|
|
542
|
+
to--;
|
|
543
|
+
gluedAtEnd = false;
|
|
544
|
+
isChanged = true;
|
|
545
|
+
}
|
|
546
|
+
if (from >= to) {
|
|
547
|
+
break;
|
|
548
|
+
}
|
|
549
|
+
const first = pieces[from];
|
|
550
|
+
const last = pieces[to - 1];
|
|
551
|
+
/*
|
|
552
|
+
* A bracket or a quotation mark the sentence puts round the whole
|
|
553
|
+
* code. What a quotation holds is quoted whole: its last full stop
|
|
554
|
+
* is the code's own ("without «client.»").
|
|
555
|
+
*/
|
|
556
|
+
if (isBracket(first) && partner[from] === to - 1 && from < to - 1) {
|
|
557
|
+
isQuoted = isQuoted || !BIDI_BRACKETS.includes(first.text);
|
|
558
|
+
from++;
|
|
559
|
+
to--;
|
|
560
|
+
gluedAtStart = false;
|
|
561
|
+
gluedAtEnd = false;
|
|
562
|
+
isChanged = true;
|
|
563
|
+
continue;
|
|
564
|
+
}
|
|
565
|
+
// A bracket or a quotation mark whose partner is not here: the sentence's.
|
|
566
|
+
if (isBracket(last) && !isPairedWithin(to - 1)) {
|
|
567
|
+
to--;
|
|
568
|
+
gluedAtEnd = false;
|
|
569
|
+
isChanged = true;
|
|
570
|
+
continue;
|
|
571
|
+
}
|
|
572
|
+
if (isBracket(first) && !isPairedWithin(from)) {
|
|
573
|
+
from++;
|
|
574
|
+
gluedAtStart = false;
|
|
575
|
+
isChanged = true;
|
|
576
|
+
continue;
|
|
577
|
+
}
|
|
578
|
+
/*
|
|
579
|
+
* The sentence's full stop, comma or colon after the code: one sign
|
|
580
|
+
* on its own ("grantConsent().", "webcal://."), or several after a
|
|
581
|
+
* word, a number or a bracket ("Docker...", "{{count}}):"). Several
|
|
582
|
+
* after a sign are the code's own: "x-oneuptime-token=...". A stop
|
|
583
|
+
* after a backslash is the code's too: "^orders\.".
|
|
584
|
+
*/
|
|
585
|
+
if (!isQuoted && isSign(last, SENTENCE_STOPS) && to - from >= 2) {
|
|
586
|
+
let stops = to - 1;
|
|
587
|
+
while (stops > from && isSign(pieces[stops - 1], SENTENCE_STOPS)) {
|
|
588
|
+
stops--;
|
|
589
|
+
}
|
|
590
|
+
const before = pieces[stops - 1];
|
|
591
|
+
const isOneStop = stops === to - 1;
|
|
592
|
+
if (stops > from &&
|
|
593
|
+
(before === null || before === void 0 ? void 0 : before.text) !== "\\" &&
|
|
594
|
+
(isOneStop ||
|
|
595
|
+
isStrong(before) ||
|
|
596
|
+
isClosingSign(before) ||
|
|
597
|
+
(isSign(before, NUMBER_SIGNS) && isNumberLike(pieces[stops - 2])))) {
|
|
598
|
+
to = stops;
|
|
599
|
+
gluedAtEnd = false;
|
|
600
|
+
isChanged = true;
|
|
601
|
+
continue;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
/*
|
|
605
|
+
* Markdown's emphasis at either end: "**CPU" is drawn as CPU in bold,
|
|
606
|
+
* and "**Settings**" round the whole code is the sentence's. One that
|
|
607
|
+
* closes inside the code is the code's: "**Settings → Command**
|
|
608
|
+
* `--help`" is set apart from its first sign.
|
|
609
|
+
*/
|
|
610
|
+
const isBoldAtStart = isEmphasisRun(from);
|
|
611
|
+
const isBoldAtEnd = to - from >= 4 && isEmphasisRun(to - 2);
|
|
612
|
+
if (isBoldAtStart &&
|
|
613
|
+
isBoldAtEnd &&
|
|
614
|
+
first.text === last.text &&
|
|
615
|
+
to - from >= 5 &&
|
|
616
|
+
!hasEmphasisRun(first.text, from + 2, to - 2)) {
|
|
617
|
+
from += 2;
|
|
618
|
+
to -= 2;
|
|
619
|
+
gluedAtStart = false;
|
|
620
|
+
gluedAtEnd = false;
|
|
621
|
+
isChanged = true;
|
|
622
|
+
continue;
|
|
623
|
+
}
|
|
624
|
+
if (isBoldAtStart && !hasEmphasisRun(first.text, from + 2, to)) {
|
|
625
|
+
from += 2;
|
|
626
|
+
gluedAtStart = false;
|
|
627
|
+
isChanged = true;
|
|
628
|
+
continue;
|
|
629
|
+
}
|
|
630
|
+
if (isBoldAtEnd && !hasEmphasisRun(last.text, from, to - 2)) {
|
|
631
|
+
to -= 2;
|
|
632
|
+
gluedAtEnd = false;
|
|
633
|
+
isChanged = true;
|
|
634
|
+
continue;
|
|
635
|
+
}
|
|
636
|
+
// Emphasis round the whole code, "_{{name}}_", or a glob's "*api*": as written.
|
|
637
|
+
if (isSign(first, EMPHASIS_SIGNS) &&
|
|
638
|
+
last.text === first.text &&
|
|
639
|
+
to - from >= 3) {
|
|
640
|
+
from++;
|
|
641
|
+
to--;
|
|
642
|
+
gluedAtStart = false;
|
|
643
|
+
gluedAtEnd = false;
|
|
644
|
+
isChanged = true;
|
|
645
|
+
continue;
|
|
646
|
+
}
|
|
647
|
+
/*
|
|
648
|
+
* Signs on their own between the code and the sentence - "/ LLM",
|
|
649
|
+
* "CPU /", "APM >": a separator of the sentence's, set off by a space.
|
|
650
|
+
*/
|
|
651
|
+
let firstSpace = -1;
|
|
652
|
+
for (let index = from; index < to; index++) {
|
|
653
|
+
if (((_c = pieces[index]) === null || _c === void 0 ? void 0 : _c.kind) === "space") {
|
|
654
|
+
firstSpace = index;
|
|
655
|
+
break;
|
|
656
|
+
}
|
|
657
|
+
if (isStrong(pieces[index])) {
|
|
658
|
+
break;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
if (firstSpace > from) {
|
|
662
|
+
from = firstSpace;
|
|
663
|
+
gluedAtStart = false;
|
|
664
|
+
isChanged = true;
|
|
665
|
+
continue;
|
|
666
|
+
}
|
|
667
|
+
let lastSpace = -1;
|
|
668
|
+
// An expression from a number keeps its stars and signs: "0 9 * * 1-5".
|
|
669
|
+
const isExpression = isNumberExpression(pieces, from, to);
|
|
670
|
+
for (let index = to - 1; !isExpression && index >= from; index--) {
|
|
671
|
+
if (((_d = pieces[index]) === null || _d === void 0 ? void 0 : _d.kind) === "space") {
|
|
672
|
+
lastSpace = index;
|
|
673
|
+
break;
|
|
674
|
+
}
|
|
675
|
+
if (isStrong(pieces[index])) {
|
|
676
|
+
break;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
if (lastSpace !== -1 && lastSpace < to - 1) {
|
|
680
|
+
to = lastSpace;
|
|
681
|
+
gluedAtEnd = false;
|
|
682
|
+
isChanged = true;
|
|
683
|
+
continue;
|
|
684
|
+
}
|
|
685
|
+
/*
|
|
686
|
+
* Signs that join a word to the sentence's own with no space -
|
|
687
|
+
* "CPU/الذاكرة": the sentence's, drawn between the two as it is. A
|
|
688
|
+
* bracket closed or opened inside the code is the code's own.
|
|
689
|
+
*/
|
|
690
|
+
if (gluedAtEnd && first !== last && last.kind === "sign") {
|
|
691
|
+
let index = to - 1;
|
|
692
|
+
while (index > from &&
|
|
693
|
+
((_e = pieces[index]) === null || _e === void 0 ? void 0 : _e.kind) === "sign" &&
|
|
694
|
+
!isPairedWithin(index)) {
|
|
695
|
+
index--;
|
|
696
|
+
}
|
|
697
|
+
if (index < to - 1 &&
|
|
698
|
+
(isStrong(pieces[index]) || isPairedWithin(index))) {
|
|
699
|
+
to = index + 1;
|
|
700
|
+
gluedAtEnd = false;
|
|
701
|
+
isChanged = true;
|
|
702
|
+
continue;
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
if (gluedAtStart && first !== last && first.kind === "sign") {
|
|
706
|
+
let index = from;
|
|
707
|
+
while (index < to - 1 &&
|
|
708
|
+
((_f = pieces[index]) === null || _f === void 0 ? void 0 : _f.kind) === "sign" &&
|
|
709
|
+
!isPairedWithin(index)) {
|
|
710
|
+
index++;
|
|
711
|
+
}
|
|
712
|
+
if (index > from && (isStrong(pieces[index]) || isPairedWithin(index))) {
|
|
713
|
+
from = index;
|
|
714
|
+
gluedAtStart = false;
|
|
715
|
+
isChanged = true;
|
|
716
|
+
continue;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
let hasContent = false;
|
|
721
|
+
for (let index = from; index < to; index++) {
|
|
722
|
+
if (isContent(pieces[index])) {
|
|
723
|
+
hasContent = true;
|
|
724
|
+
break;
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
if (!hasContent) {
|
|
728
|
+
return null;
|
|
729
|
+
}
|
|
730
|
+
// The first and last signs drawn: Markdown's "**" is drawn as bold, not as signs.
|
|
731
|
+
let drawnFrom = from;
|
|
732
|
+
let drawnTo = to;
|
|
733
|
+
while (drawnTo - drawnFrom > 2 && isEmphasisRun(drawnFrom)) {
|
|
734
|
+
drawnFrom += 2;
|
|
735
|
+
}
|
|
736
|
+
while (drawnTo - drawnFrom > 2 && isEmphasisRun(drawnTo - 2)) {
|
|
737
|
+
drawnTo -= 2;
|
|
738
|
+
}
|
|
739
|
+
const first = pieces[drawnFrom];
|
|
740
|
+
const last = pieces[drawnTo - 1];
|
|
741
|
+
/*
|
|
742
|
+
* Whether the piece at an edge of the code is drawn where it is written.
|
|
743
|
+
* A {{placeholder}} written onto a word of the code is not -
|
|
744
|
+
* "v{{version}}", "{{url}}/otlp", "{{allowWrites}}=true": the value it is
|
|
745
|
+
* filled with may come in an isolate of its own (Translator's
|
|
746
|
+
* setsValuesApart), which the bidi algorithm reads as a sign, and it was
|
|
747
|
+
* drawn at the word's other end. Between values and signs only it is a
|
|
748
|
+
* number's - "{{online}}/{{count}}", "{{min}}–{{max}} ms" - and drawn as
|
|
749
|
+
* the sentence draws numbers.
|
|
750
|
+
*/
|
|
751
|
+
const isDrawnRightAtEdge = (index, inward) => {
|
|
752
|
+
var _a;
|
|
753
|
+
const piece = pieces[index];
|
|
754
|
+
if ((piece === null || piece === void 0 ? void 0 : piece.kind) !== "placeholder") {
|
|
755
|
+
return isStrong(piece);
|
|
756
|
+
}
|
|
757
|
+
for (let next = index + inward; next >= drawnFrom && next < drawnTo; next += inward) {
|
|
758
|
+
const kind = (_a = pieces[next]) === null || _a === void 0 ? void 0 : _a.kind;
|
|
759
|
+
if (kind === "letter" || kind === "digit") {
|
|
760
|
+
return false;
|
|
761
|
+
}
|
|
762
|
+
if (kind === "space") {
|
|
763
|
+
return true;
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
return true;
|
|
767
|
+
};
|
|
768
|
+
const startsRight = isDrawnRightAtEdge(drawnFrom, 1) ||
|
|
769
|
+
(isSign(first, BIDI_BRACKETS) &&
|
|
770
|
+
isPairedWithin(drawnFrom) &&
|
|
771
|
+
holdsLetters(pieces, drawnFrom, partner[drawnFrom])) ||
|
|
772
|
+
(isSign(first, NUMBER_SIGNS) && isNumberLike(pieces[drawnFrom + 1]));
|
|
773
|
+
const endsRight = isDrawnRightAtEdge(drawnTo - 1, -1) ||
|
|
774
|
+
(isSign(last, BIDI_BRACKETS) &&
|
|
775
|
+
isPairedWithin(drawnTo - 1) &&
|
|
776
|
+
holdsLetters(pieces, partner[drawnTo - 1], drawnTo - 1)) ||
|
|
777
|
+
(isSign(last, NUMBER_SIGNS) && isNumberLike(pieces[drawnTo - 2]));
|
|
778
|
+
if (startsRight && endsRight && !isNumberExpression(pieces, from, to)) {
|
|
779
|
+
return null;
|
|
780
|
+
}
|
|
781
|
+
return { from, to };
|
|
782
|
+
};
|
|
783
|
+
/*
|
|
784
|
+
* Where the code that needs setting apart sits in `sentence`, read as a
|
|
785
|
+
* sentence of a language read from the right. Empty when the sentence has
|
|
786
|
+
* no letter of such a script.
|
|
787
|
+
*/
|
|
788
|
+
const getCodeInSentence = (sentence) => {
|
|
789
|
+
if (!sentence || !RIGHT_TO_LEFT_CHARACTER_REGEX.test(sentence)) {
|
|
790
|
+
return [];
|
|
791
|
+
}
|
|
792
|
+
const pieces = getPieces(sentence);
|
|
793
|
+
const found = [];
|
|
794
|
+
const readPart = (part, touchesSentenceAtStart, touchesSentenceAtEnd) => {
|
|
795
|
+
if (part.length === 0) {
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
const code = getCodeInStretch(part, touchesSentenceAtStart, touchesSentenceAtEnd);
|
|
799
|
+
if (code) {
|
|
800
|
+
const start = part[code.from].start;
|
|
801
|
+
const end = part[code.to - 1].end;
|
|
802
|
+
found.push({ start, end, text: sentence.slice(start, end) });
|
|
803
|
+
}
|
|
804
|
+
};
|
|
805
|
+
/*
|
|
806
|
+
* One stretch of left-to-right text, read part by part: a bracket or a
|
|
807
|
+
* quotation mark whose partner is beyond the stretch belongs to the
|
|
808
|
+
* sentence and ends a part ("--reset-then-reuse-values (Helm 3.14 أو
|
|
809
|
+
* أحدث)"), and so does a space in a stretch of nothing but values and
|
|
810
|
+
* signs ("~{{time}} {{count}}").
|
|
811
|
+
*/
|
|
812
|
+
const readStretch = (start, end) => {
|
|
813
|
+
const stretch = pieces.slice(start, end);
|
|
814
|
+
// A space or a sign between the sentence's words holds no code.
|
|
815
|
+
if (!stretch.some(isContent)) {
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
818
|
+
const touchesSentenceAtStart = isAfterWord(pieces[start - 1]);
|
|
819
|
+
const touchesSentenceAtEnd = isBeforeWord(pieces[end]);
|
|
820
|
+
const partner = getPartners(stretch);
|
|
821
|
+
const isValuesOnly = !stretch.some((piece) => {
|
|
822
|
+
return piece.kind === "letter" || piece.kind === "digit";
|
|
823
|
+
});
|
|
824
|
+
let partStart = 0;
|
|
825
|
+
stretch.forEach((piece, index) => {
|
|
826
|
+
const endsPart = (isBracket(piece) &&
|
|
827
|
+
!SAME_SIGN_QUOTES.includes(piece.text) &&
|
|
828
|
+
partner[index] === -1 &&
|
|
829
|
+
!isApostrophe(stretch, index)) ||
|
|
830
|
+
(isValuesOnly && piece.kind === "space");
|
|
831
|
+
if (!endsPart) {
|
|
832
|
+
return;
|
|
833
|
+
}
|
|
834
|
+
readPart(stretch.slice(partStart, index), partStart === 0 && touchesSentenceAtStart, false);
|
|
835
|
+
partStart = index + 1;
|
|
836
|
+
});
|
|
837
|
+
readPart(stretch.slice(partStart), partStart === 0 && touchesSentenceAtStart, touchesSentenceAtEnd);
|
|
838
|
+
};
|
|
839
|
+
let stretchStart = 0;
|
|
840
|
+
pieces.forEach((piece, index) => {
|
|
841
|
+
if (piece.kind === "sentence" || piece.kind === "break") {
|
|
842
|
+
readStretch(stretchStart, index);
|
|
843
|
+
stretchStart = index + 1;
|
|
844
|
+
}
|
|
845
|
+
});
|
|
846
|
+
readStretch(stretchStart, pieces.length);
|
|
847
|
+
return found;
|
|
848
|
+
};
|
|
849
|
+
exports.getCodeInSentence = getCodeInSentence;
|
|
850
|
+
/*
|
|
851
|
+
* `sentence` as a page shows it to a reader of `language`: in a language
|
|
852
|
+
* read from the right, each piece of code set apart in a left-to-right
|
|
853
|
+
* isolate, and each {{placeholder}} inside it in a first-strong one (see
|
|
854
|
+
* above); in any other language, as it is.
|
|
855
|
+
*/
|
|
856
|
+
const setCodeApartInSentence = (sentence, language) => {
|
|
857
|
+
if (!sentence || !(0, ReadingDirection_1.isRightToLeftLanguage)(language)) {
|
|
858
|
+
return sentence;
|
|
859
|
+
}
|
|
860
|
+
const code = (0, exports.getCodeInSentence)(sentence);
|
|
861
|
+
if (code.length === 0) {
|
|
862
|
+
return sentence;
|
|
863
|
+
}
|
|
864
|
+
let result = "";
|
|
865
|
+
let at = 0;
|
|
866
|
+
for (const piece of code) {
|
|
867
|
+
const text = piece.text.replace(PLACEHOLDERS_REGEX, (placeholder) => {
|
|
868
|
+
return `${ReadingDirection_1.FIRST_STRONG_ISOLATE}${placeholder}${ReadingDirection_1.POP_DIRECTIONAL_ISOLATE}`;
|
|
869
|
+
});
|
|
870
|
+
result += `${sentence.slice(at, piece.start)}${exports.LEFT_TO_RIGHT_ISOLATE}${text}${ReadingDirection_1.POP_DIRECTIONAL_ISOLATE}`;
|
|
871
|
+
at = piece.end;
|
|
872
|
+
}
|
|
873
|
+
return `${result}${sentence.slice(at)}`;
|
|
874
|
+
};
|
|
875
|
+
exports.setCodeApartInSentence = setCodeApartInSentence;
|