@cratis/screenplay-language 5.3.0 → 5.3.2
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/dist/bundles/TypeReferenceSymbol.js.map +1 -1
- package/dist/bundles/action-subject-authoring.js.map +1 -1
- package/dist/bundles/bmp-word-characters.js.map +1 -1
- package/dist/bundles/case-authoring.js +1 -1
- package/dist/bundles/case-authoring.js.map +1 -1
- package/dist/bundles/code-actions.js.map +1 -1
- package/dist/bundles/command-read-completions.js.map +1 -1
- package/dist/bundles/compiler/Authoring/ActionSubjectQuickFixes.js +3 -3
- package/dist/bundles/compiler/Authoring/ActionSubjectQuickFixes.js.map +1 -1
- package/dist/bundles/compiler/Authoring/QuickFixes.js +4 -4
- package/dist/bundles/compiler/Authoring/QuickFixes.js.map +1 -1
- package/dist/bundles/compiler/Authoring/StructuredValueQuickFix.js +1 -1
- package/dist/bundles/compiler/Authoring/StructuredValueQuickFix.js.map +1 -1
- package/dist/bundles/compiler/Authoring/TimelineQuickFixContext.js +4 -4
- package/dist/bundles/compiler/Authoring/TimelineQuickFixContext.js.map +1 -1
- package/dist/bundles/compiler/Authoring/TimelineQuickFixImports.js +2 -2
- package/dist/bundles/compiler/Authoring/TimelineQuickFixImports.js.map +1 -1
- package/dist/bundles/compiler/Authoring/TimelineQuickFixes.js +1 -1
- package/dist/bundles/compiler/Authoring/TimelineQuickFixes.js.map +1 -1
- package/dist/bundles/compiler/Dependencies/DeclaredDependencies.js.map +1 -1
- package/dist/bundles/compiler/Dependencies/DeclaredDependencyTargets.js.map +1 -1
- package/dist/bundles/compiler/Dependencies/DependencyGraph.js +1 -1
- package/dist/bundles/compiler/Dependencies/DependencyGraph.js.map +1 -1
- package/dist/bundles/compiler/Dependencies/DependencyKind.js.map +1 -1
- package/dist/bundles/compiler/Dependencies/InvalidDependencyQuery.js.map +1 -1
- package/dist/bundles/compiler/Dependencies/SliceReferences.js.map +1 -1
- package/dist/bundles/compiler/Dependencies/StronglyConnectedGroups.js.map +1 -1
- package/dist/bundles/compiler/Diagnostics/DiagnosticArgument.js.map +1 -1
- package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js +1 -1
- package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js.map +1 -1
- package/dist/bundles/compiler/Diagnostics/ProductionDestinationDiagnostics.js +1 -1
- package/dist/bundles/compiler/Diagnostics/ProductionDestinationDiagnostics.js.map +1 -1
- package/dist/bundles/compiler/Diagnostics/SourceLocation.js.map +1 -1
- package/dist/bundles/compiler/Files/AuthoredOrder.js +1 -1
- package/dist/bundles/compiler/Files/AuthoredOrder.js.map +1 -1
- package/dist/bundles/compiler/Files/OrderingRoot.js +1 -1
- package/dist/bundles/compiler/Files/OrderingRoot.js.map +1 -1
- package/dist/bundles/compiler/Files/PlayApplicationAssembly.js +1 -1
- package/dist/bundles/compiler/Files/PlayApplicationAssembly.js.map +1 -1
- package/dist/bundles/compiler/Files/PlayDocumentSource.js.map +1 -1
- package/dist/bundles/compiler/Files/PlayFolderMerge.js +1 -1
- package/dist/bundles/compiler/Files/PlayFolderMerge.js.map +1 -1
- package/dist/bundles/compiler/Files/PlayGlob.js +2 -1
- package/dist/bundles/compiler/Files/PlayGlob.js.map +1 -1
- package/dist/bundles/compiler/Files/PlayImports.js +1 -1
- package/dist/bundles/compiler/Files/PlayImports.js.map +1 -1
- package/dist/bundles/compiler/Files/PlayPlacement.js.map +1 -1
- package/dist/bundles/compiler/Files/TimelineOrder.js +1 -1
- package/dist/bundles/compiler/Files/TimelineOrder.js.map +1 -1
- package/dist/bundles/compiler/Generation/FiniteGenerationRules.js +1 -1
- package/dist/bundles/compiler/Generation/GenerationAssessmentCache.js.map +1 -1
- package/dist/bundles/compiler/Generation/GenerationChecksum.js.map +1 -1
- package/dist/bundles/compiler/Generation/GenerationPattern.js +1 -1
- package/dist/bundles/compiler/Generation/GenerationPattern.js.map +1 -1
- package/dist/bundles/compiler/Generation/GenerationPatternAssessment.js.map +1 -1
- package/dist/bundles/compiler/Generation/GenerationPatternParser.js.map +1 -1
- package/dist/bundles/compiler/Generation/GenerationPatternToken.js.map +1 -1
- package/dist/bundles/compiler/Generation/GenerationRuleProof.js +1 -1
- package/dist/bundles/compiler/Generation/InvalidGenerationPattern.js.map +1 -1
- package/dist/bundles/compiler/Generation/RegexCharacters.js.map +1 -1
- package/dist/bundles/compiler/Generation/RegexExpression.js.map +1 -1
- package/dist/bundles/compiler/Generation/RuleConsistency.js +1 -1
- package/dist/bundles/compiler/Parsing/ActionSubjectClause.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ActionSubjectInputs.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ActionSubjectResolution.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ApplicationContextParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ApplicationContextParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/AuthorizeParser.js +1 -1
- package/dist/bundles/compiler/Parsing/AuthorizeParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/CanvasPlacement.js.map +1 -1
- package/dist/bundles/compiler/Parsing/CaptureEventFixturesValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/CaptureParser.js +1 -1
- package/dist/bundles/compiler/Parsing/CaptureParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ClockOperandParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/CodeBlockParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/CommandDestinationTypes.js.map +1 -1
- package/dist/bundles/compiler/Parsing/CommandHandlerValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/CommandParser.js +1 -1
- package/dist/bundles/compiler/Parsing/CommandParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/CommandReadSources.js.map +1 -1
- package/dist/bundles/compiler/Parsing/CommandResponseParser.js +1 -1
- package/dist/bundles/compiler/Parsing/CommandResponseParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/CommandStreamCandidates.js.map +1 -1
- package/dist/bundles/compiler/Parsing/CompositeStreamIdValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/CompositionParser.js +1 -1
- package/dist/bundles/compiler/Parsing/CompositionParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ConceptComplianceParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ConceptComplianceParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ConditionDepthBudget.js +2 -0
- package/dist/bundles/compiler/Parsing/ConditionDepthBudget.js.map +1 -0
- package/dist/bundles/compiler/Parsing/ConditionParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ConditionParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ConstraintParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ConstraintParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ConstraintPropertyValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/ConstraintPropertyValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ContinuationValues.js.map +1 -1
- package/dist/bundles/compiler/Parsing/DeclarationParsers.js +1 -1
- package/dist/bundles/compiler/Parsing/DeclarationParsers.js.map +1 -1
- package/dist/bundles/compiler/Parsing/DependencySourceParser.js +1 -1
- package/dist/bundles/compiler/Parsing/DependencySourceParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/DependsOnParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/DescriptionParser.js +1 -1
- package/dist/bundles/compiler/Parsing/DescriptionParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/DocumentationParser.js +1 -1
- package/dist/bundles/compiler/Parsing/DocumentationParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/EnumerationMembers.js +1 -1
- package/dist/bundles/compiler/Parsing/EnumerationMembers.js.map +1 -1
- package/dist/bundles/compiler/Parsing/EventMetadataParser.js +1 -1
- package/dist/bundles/compiler/Parsing/EventMetadataParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/EventSourceParser.js +1 -1
- package/dist/bundles/compiler/Parsing/EventSourceParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/EventSourceValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/EventSourceValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/EventSubjectValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/EventSubjectValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ExpressionParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ExpressionParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/FeatureBody.js +1 -1
- package/dist/bundles/compiler/Parsing/FeatureBody.js.map +1 -1
- package/dist/bundles/compiler/Parsing/FileImportParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/FileReferences.js.map +1 -1
- package/dist/bundles/compiler/Parsing/FoldedEventSources.js.map +1 -1
- package/dist/bundles/compiler/Parsing/GenerationBodyParser.js +1 -1
- package/dist/bundles/compiler/Parsing/GenerationBodyParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/GenerationParser.js +1 -1
- package/dist/bundles/compiler/Parsing/GenerationParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/GuardedActionInputs.js.map +1 -1
- package/dist/bundles/compiler/Parsing/GuardedActionParser.js +1 -1
- package/dist/bundles/compiler/Parsing/GuardedActionParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/GuardedActionShadowing.js.map +1 -1
- package/dist/bundles/compiler/Parsing/GuardedActionValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/GuardedActionValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/GuardedInteractions.js +1 -1
- package/dist/bundles/compiler/Parsing/GuardedInteractions.js.map +1 -1
- package/dist/bundles/compiler/Parsing/IdentifierComplianceValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/IdentifierComplianceValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/IdentityParser.js +1 -1
- package/dist/bundles/compiler/Parsing/IdentityParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/IdentityValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ImplementationParser.js +2 -2
- package/dist/bundles/compiler/Parsing/ImplementationParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ImportDiscovery.js +1 -1
- package/dist/bundles/compiler/Parsing/ImportDiscovery.js.map +1 -1
- package/dist/bundles/compiler/Parsing/InlineEventValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/InputUses.js +1 -1
- package/dist/bundles/compiler/Parsing/InputUses.js.map +1 -1
- package/dist/bundles/compiler/Parsing/InteractionAlternatives.js +1 -1
- package/dist/bundles/compiler/Parsing/InteractionAlternatives.js.map +1 -1
- package/dist/bundles/compiler/Parsing/InteractionExecutions.js +1 -1
- package/dist/bundles/compiler/Parsing/InteractionExecutions.js.map +1 -1
- package/dist/bundles/compiler/Parsing/LegacyTextRulePatterns.js.map +1 -1
- package/dist/bundles/compiler/Parsing/LineReader.js.map +1 -1
- package/dist/bundles/compiler/Parsing/LineText.js.map +1 -1
- package/dist/bundles/compiler/Parsing/MatchAmbiguity.js +1 -1
- package/dist/bundles/compiler/Parsing/MatchAmbiguity.js.map +1 -1
- package/dist/bundles/compiler/Parsing/MatchAmbiguityCharacters.js.map +1 -1
- package/dist/bundles/compiler/Parsing/MatchAmbiguityGraph.js.map +1 -1
- package/dist/bundles/compiler/Parsing/MatchAmbiguityParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/MatchOperandValidation.js +1 -1
- package/dist/bundles/compiler/Parsing/MatchOperandValidation.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ModuleBody.js +1 -1
- package/dist/bundles/compiler/Parsing/ModuleBody.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ObserverFilterParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ObserverFilterParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ObserverFilterValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/OperationParser.js +1 -1
- package/dist/bundles/compiler/Parsing/OperationParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/OperationValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/OperationValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ParserContext.js.map +1 -1
- package/dist/bundles/compiler/Parsing/PersonaCallerValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/PolicyParser.js +1 -1
- package/dist/bundles/compiler/Parsing/PolicyParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/PortableMatchGroupName.js.map +1 -1
- package/dist/bundles/compiler/Parsing/PortableMatchPattern.js.map +1 -1
- package/dist/bundles/compiler/Parsing/PortableMatchSuggestions.js.map +1 -1
- package/dist/bundles/compiler/Parsing/PossibleEventsParser.js +1 -1
- package/dist/bundles/compiler/Parsing/PossibleEventsParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ProducesParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ProducesParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ProjectionEventScopeValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ProjectionExpressionParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ProjectionExpressionParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ProjectionParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ProjectionParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ProjectionTargetValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/ProjectionTargetValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/PropertyLineParser.js +1 -1
- package/dist/bundles/compiler/Parsing/PropertyLineParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/PublicEventMetadataValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/PublicEventMetadataValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/PublicEventUsageCollector.js +1 -1
- package/dist/bundles/compiler/Parsing/PublicEventUsageCollector.js.map +1 -1
- package/dist/bundles/compiler/Parsing/PublicEventUsageValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/PublicEventUsageValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/PurposeParser.js +1 -1
- package/dist/bundles/compiler/Parsing/PurposeParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/PurposeValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/QueryParser.js +1 -1
- package/dist/bundles/compiler/Parsing/QueryParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ReactionIdentityParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ReactionIdentityParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ReactionParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ReactionParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ReactionRefusalValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/ReactionRefusalValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ReadModelKeyValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ReadModelMemberTypeValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ReadsParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ReadsParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/RedeliveryValues.js.map +1 -1
- package/dist/bundles/compiler/Parsing/RefusalDeclarations.js +1 -1
- package/dist/bundles/compiler/Parsing/RefusalDeclarations.js.map +1 -1
- package/dist/bundles/compiler/Parsing/RefusalValueWalker.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ResponseCommandResolver.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ResponseDateValues.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ResponseValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/ResponseValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ScreenParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ScreenParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/ScreenplayParser.js +1 -1
- package/dist/bundles/compiler/Parsing/ScreenplayParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SeedParser.js +1 -1
- package/dist/bundles/compiler/Parsing/SeedParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SliceParser.js +1 -1
- package/dist/bundles/compiler/Parsing/SliceParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SourceLine.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SourceLineSplitter.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SourceOptionsParser.js +1 -1
- package/dist/bundles/compiler/Parsing/SourceOptionsParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationCaseParser.js +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationCaseParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationCaseValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationCaseValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationCommandExamples.js +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationCommandExamples.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationExampleParser.js +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationExampleParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationParser.js +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationRedeliveryValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationRedeliveryValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationResponseParser.js +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationResponseParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationRouteComparison.js +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationRouteComparison.js.map +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationStreamValidator.js +1 -1
- package/dist/bundles/compiler/Parsing/SpecificationStreamValidator.js.map +1 -1
- package/dist/bundles/compiler/Parsing/StateMachineParser.js +1 -1
- package/dist/bundles/compiler/Parsing/StateMachineParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/StructuralInteractionSites.js.map +1 -1
- package/dist/bundles/compiler/Parsing/StructuredBlockParser.js +1 -1
- package/dist/bundles/compiler/Parsing/StructuredBlockParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/StructuredValueParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/TemplateReferenceText.js +1 -1
- package/dist/bundles/compiler/Parsing/TemplateReferenceText.js.map +1 -1
- package/dist/bundles/compiler/Parsing/TriggerDataParser.js +1 -1
- package/dist/bundles/compiler/Parsing/TriggerDataParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/UiBindingParser.js +1 -1
- package/dist/bundles/compiler/Parsing/UiBindingParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/UiProfileLegacyLayout.js +1 -1
- package/dist/bundles/compiler/Parsing/UiProfileLegacyLayout.js.map +1 -1
- package/dist/bundles/compiler/Parsing/WorkflowParser.js +1 -1
- package/dist/bundles/compiler/Parsing/WorkflowParser.js.map +1 -1
- package/dist/bundles/compiler/Parsing/checkPortableMatchPattern.js.map +1 -1
- package/dist/bundles/compiler/Parsing/hasExponentialMatchAmbiguity.js.map +1 -1
- package/dist/bundles/compiler/Parsing/trimMatchAmbiguityGraph.js.map +1 -1
- package/dist/bundles/compiler/ScreenActionSubjects.js.map +1 -1
- package/dist/bundles/compiler/ScreenplayCompiler.js +1 -1
- package/dist/bundles/compiler/ScreenplayCompiler.js.map +1 -1
- package/dist/bundles/compiler/Syntax/ActionSubjectInvariants.js.map +1 -1
- package/dist/bundles/compiler/Syntax/AuthoringProductionResolver.js.map +1 -1
- package/dist/bundles/compiler/Syntax/CaptureEventsSource.js.map +1 -1
- package/dist/bundles/compiler/Syntax/DependencySources.js.map +1 -1
- package/dist/bundles/compiler/Syntax/EventDeclarations.js.map +1 -1
- package/dist/bundles/compiler/Syntax/EventSourceCatalog.js.map +1 -1
- package/dist/bundles/compiler/Syntax/EventSourceReadConfidence.js.map +1 -1
- package/dist/bundles/compiler/Syntax/ExactMathFacts.js.map +1 -1
- package/dist/bundles/compiler/Syntax/ExactNumber.js.map +1 -1
- package/dist/bundles/compiler/Syntax/InvalidSyntaxJson.js.map +1 -1
- package/dist/bundles/compiler/Syntax/LegacyWireProjection.js.map +1 -1
- package/dist/bundles/compiler/Syntax/Operations.js.map +1 -1
- package/dist/bundles/compiler/Syntax/PersonaCallers.js.map +1 -1
- package/dist/bundles/compiler/Syntax/ProductionDestinations.js.map +1 -1
- package/dist/bundles/compiler/Syntax/PublicEventInvariants.js.map +1 -1
- package/dist/bundles/compiler/Syntax/ScreenplaySyntaxWalker.js.map +1 -1
- package/dist/bundles/compiler/Syntax/SourceOptions.js.map +1 -1
- package/dist/bundles/compiler/Syntax/SpecificationCaseOrigin.js.map +1 -1
- package/dist/bundles/compiler/Syntax/StreamIdFormatter.js.map +1 -1
- package/dist/bundles/compiler/Syntax/StrictSyntaxJson.js +1 -1
- package/dist/bundles/compiler/Syntax/Structure.js.map +1 -1
- package/dist/bundles/compiler/Syntax/SyntaxCollections.js.map +1 -1
- package/dist/bundles/compiler/Syntax/SyntaxInvariants.js +1 -1
- package/dist/bundles/compiler/Syntax/SyntaxInvariants.js.map +1 -1
- package/dist/bundles/compiler/Syntax/SyntaxJson.js +1 -1
- package/dist/bundles/compiler/Syntax/SyntaxJson.js.map +1 -1
- package/dist/bundles/compiler/Syntax/SyntaxMemberContracts.js.map +1 -1
- package/dist/bundles/compiler/Syntax/index.js +1 -1
- package/dist/bundles/compiler/Text/ImplementationHintText.js.map +1 -1
- package/dist/bundles/compiler/Text/ReservedWords.js.map +1 -1
- package/dist/bundles/compiler/Text/SourceStreamNames.js.map +1 -1
- package/dist/bundles/compiler/Text/StringLiteral.js.map +1 -1
- package/dist/bundles/compiler/Text/ordinalIgnoreCaseKey.js.map +1 -1
- package/dist/bundles/compiler/Text/patterns.js.map +1 -1
- package/dist/bundles/compiler/index.js +1 -1
- package/dist/bundles/completion-items.js +4 -4
- package/dist/bundles/completion-items.js.map +1 -1
- package/dist/bundles/completion-planner.js +2 -2
- package/dist/bundles/completion-planner.js.map +1 -1
- package/dist/bundles/completions.js +1 -1
- package/dist/bundles/completions.js.map +1 -1
- package/dist/bundles/continuation-responses.js +1 -1
- package/dist/bundles/continuation-responses.js.map +1 -1
- package/dist/bundles/declarations.js.map +1 -1
- package/dist/bundles/dependency-completions.js.map +1 -1
- package/dist/bundles/dependency-target-analysis.js.map +1 -1
- package/dist/bundles/diagnostic-codes.js +1 -1
- package/dist/bundles/diagnostic-codes.js.map +1 -1
- package/dist/bundles/diagnostics.js +1 -1
- package/dist/bundles/diagnostics.js.map +1 -1
- package/dist/bundles/document-context.js.map +1 -1
- package/dist/bundles/documentation-item.js.map +1 -1
- package/dist/bundles/event-analysis-source.js.map +1 -1
- package/dist/bundles/event-context-catalog.js.map +1 -1
- package/dist/bundles/event-context.js.map +1 -1
- package/dist/bundles/event-source-authoring.js +11 -11
- package/dist/bundles/event-source-authoring.js.map +1 -1
- package/dist/bundles/example-analysis.js +2 -2
- package/dist/bundles/example-analysis.js.map +1 -1
- package/dist/bundles/example-authoring.js +2 -2
- package/dist/bundles/example-authoring.js.map +1 -1
- package/dist/bundles/example-declaration-items.js.map +1 -1
- package/dist/bundles/example-values.js.map +1 -1
- package/dist/bundles/file-imports.js.map +1 -1
- package/dist/bundles/file-references.js.map +1 -1
- package/dist/bundles/generation-completions.js.map +1 -1
- package/dist/bundles/hover-content.js +5 -5
- package/dist/bundles/hover-content.js.map +1 -1
- package/dist/bundles/hover.js.map +1 -1
- package/dist/bundles/index.js +1 -1
- package/dist/bundles/index.js.map +1 -1
- package/dist/bundles/inlay-hints.js.map +1 -1
- package/dist/bundles/inline-completions.js +1 -1
- package/dist/bundles/inline-completions.js.map +1 -1
- package/dist/bundles/inline-event-validation.js +1 -1
- package/dist/bundles/inline-event-validation.js.map +1 -1
- package/dist/bundles/keyword-docs.js.map +1 -1
- package/dist/bundles/language.js.map +1 -1
- package/dist/bundles/named-rule-context.js.map +1 -1
- package/dist/bundles/operation-authoring.js +6 -6
- package/dist/bundles/operation-authoring.js.map +1 -1
- package/dist/bundles/persona-analysis.js +1 -1
- package/dist/bundles/persona-analysis.js.map +1 -1
- package/dist/bundles/production-destinations.js +1 -1
- package/dist/bundles/production-destinations.js.map +1 -1
- package/dist/bundles/purpose-items.js.map +1 -1
- package/dist/bundles/reaction-authoring.js +3 -3
- package/dist/bundles/reaction-authoring.js.map +1 -1
- package/dist/bundles/read-model-key-completions.js +1 -1
- package/dist/bundles/read-model-key-completions.js.map +1 -1
- package/dist/bundles/refusal-context.js.map +1 -1
- package/dist/bundles/response-analysis.js.map +1 -1
- package/dist/bundles/response-completions.js +1 -1
- package/dist/bundles/response-completions.js.map +1 -1
- package/dist/bundles/response-tokens.js +2 -2
- package/dist/bundles/response-tokens.js.map +1 -1
- package/dist/bundles/scope-items.js +3 -3
- package/dist/bundles/scope-items.js.map +1 -1
- package/dist/bundles/structure-completions.js.map +1 -1
- package/dist/bundles/sub-language-registry.js.map +1 -1
- package/dist/bundles/sub-languages/capture/CompletionProvider.js.map +1 -1
- package/dist/bundles/sub-languages/capture/HoverProvider.js.map +1 -1
- package/dist/bundles/sub-languages/capture/Validator.js.map +1 -1
- package/dist/bundles/sub-languages/capture/index.js.map +1 -1
- package/dist/bundles/sub-languages/capture/language.js.map +1 -1
- package/dist/bundles/sub-languages/cdl.js.map +1 -1
- package/dist/bundles/sub-languages/pdl.js.map +1 -1
- package/dist/bundles/sub-languages/projection/CodeActionProvider.js.map +1 -1
- package/dist/bundles/sub-languages/projection/CompletionProvider.js +1 -1
- package/dist/bundles/sub-languages/projection/CompletionProvider.js.map +1 -1
- package/dist/bundles/sub-languages/projection/HoverProvider.js.map +1 -1
- package/dist/bundles/sub-languages/projection/Validator.js.map +1 -1
- package/dist/bundles/sub-languages/projection/index.js.map +1 -1
- package/dist/bundles/sub-languages/projection/language.js.map +1 -1
- package/dist/bundles/symbols.js +2 -2
- package/dist/bundles/symbols.js.map +1 -1
- package/dist/bundles/themes/screenplay-dark.js.map +1 -1
- package/dist/bundles/themes/screenplay-light.js.map +1 -1
- package/dist/bundles/tokens.js.map +1 -1
- package/dist/bundles/validation.js +2 -2
- package/dist/bundles/validation.js.map +1 -1
- package/dist/diagnostic-codes.d.ts +1 -0
- package/dist/diagnostic-codes.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import"../../_virtual/_virtual/_rolldown/runtime.js";import{commentStart as e}from"../Parsing/SourceLineSplitter.js";const t=[(e,t)=>/\bthen\s+returns\s*$/.test(e)&&t===``?`${e.trimEnd()} value`:void 0,(e,t)=>/\bthen\s+no\s+readmodel\s+\S+\s+for\s*$/.test(e)&&t===``?e.trimEnd():void 0,(e,t)=>/\bfrom\s+literal\s*$/.test(e)?`${e.trimEnd()}${t===``?``:` ${t}`}`:void 0,(e,t)=>/=\s*literal\s*$/.test(e)&&t===``?e.replace(/\s*=\s*literal\s*$/,``):void 0,(e,t)=>/=\s*$/.test(e)&&t===``?e.replace(/\s*=\s*$/,``):void 0],n=/^\s*(?:given|when|then|case)\s+\S+.*\s\S+\s*=\s*$/;function rewriteInlineJson(r,i){let a=e(r),o=a<0?r:r.slice(0,a),s=a<0?``:` ${r.slice(a).trimStart()}`;for(let e of openings(o)){let a=new Reader(o,e),c=a.value();if(c===void 0||c.kind===`scalar`)continue;let l=o.slice(0,e),u=o.slice(a.position).trim();if(n.test(l))return;let d=t.map(e=>e(l,u)).find(e=>e!==void 0);if(d===void 0)continue;let f=/^\s*/.exec(r)[0],p=[];return block(d.slice(f.length),c,f,i,p),p[0]+=s,{start:f.length,text:p.join(`
|
|
2
|
-
`).slice(f.length)}}}function*openings(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];t&&r===`\\`?n++:r===`"`?t=!t
|
|
2
|
+
`).slice(f.length)}}}function*openings(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];t&&r===`\\`?n++:r===`"`?t=!t:t||r!==`{`&&r!==`[`||(yield n)}}function block(e,t,n,r,i){if(t.kind===`list`&&t.items.length===0){i.push(`${n}${e} none`);return}if(t.kind===`object`&&t.members.length===0){i.push(`${n}${e} empty`);return}i.push(`${n}${e}`);let a=n+r;if(t.kind===`list`)for(let e of t.items)e.kind===`scalar`?i.push(`${a}item ${e.text}`):block(`item`,e,a,r,i);else if(t.kind===`object`)for(let e of t.members){let t=memberName(e.name);e.value.kind===`scalar`?i.push(`${a}${t} = ${e.value.text}`):block(t,e.value,a,r,i)}}const memberName=e=>e===`item`?`@item`:/^[\p{L}_][\p{L}\p{N}_]*$/u.test(e)?e:quote(e),quote=e=>`"`+e.replace(/["\\\n\r\t]/g,e=>JSON.stringify(e).slice(1,-1))+`"`;var Reader=class{text;position;constructor(e,t){this.text=e,this.position=t}value(){this.space();let e=this.text[this.position];if(e===`{`)return this.object();if(e===`[`)return this.list();if(e===`"`){let e=this.string();return e===void 0?void 0:{kind:`scalar`,text:quote(e)}}let t=/^(?:-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null)/.exec(this.text.slice(this.position));if(t!==null)return this.position+=t[0].length,{kind:`scalar`,text:t[0]}}object(){this.position++;let e=[];if(this.space(),this.text[this.position]===`}`)return this.position++,{kind:`object`,members:e};for(;;){this.space();let t=this.string();if(this.space(),t===void 0||this.text[this.position]!==`:`)return;this.position++;let n=this.value();if(n===void 0)return;e.push({name:t,value:n}),this.space();let r=this.text[this.position++];if(r===`}`)return{kind:`object`,members:e};if(r!==`,`)return}}list(){this.position++;let e=[];if(this.space(),this.text[this.position]===`]`)return this.position++,{kind:`list`,items:e};for(;;){let t=this.value();if(t===void 0)return;e.push(t),this.space();let n=this.text[this.position++];if(n===`]`)return{kind:`list`,items:e};if(n!==`,`)return}}string(){if(this.text[this.position]!==`"`)return;let e=this.position+1;for(;e<this.text.length&&this.text[e]!==`"`;)e+=this.text[e]===`\\`?2:1;if(!(e>=this.text.length))try{let t=JSON.parse(this.text.slice(this.position,e+1));return this.position=e+1,t}catch{return}}space(){for(;this.position<this.text.length&&/\s/.test(this.text[this.position]);)this.position++}};export{rewriteInlineJson};
|
|
3
3
|
//# sourceMappingURL=StructuredValueQuickFix.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StructuredValueQuickFix.js","names":["headers","before","after","inlineStepHeader","comment","commentStart","line","code","trailing","start","reader","value","header","text","indent","lines","unit","inString","index","current","child","item","member","name","character","position","token","members","next","items","end"],"sources":["../../../../../../Compiler/Authoring/StructuredValueQuickFix.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { commentStart } from '../Parsing/SourceLineSplitter';\n\n// Rewrites one inline JSON value (PLAY0833) as the indented structured block Screenplay writes instead. The value is\n// read token by token so numbers keep their authored spelling; nothing is evaluated or normalized.\n\ntype Value =\n | { readonly kind: 'scalar'; readonly text: string }\n | { readonly kind: 'list'; readonly items: readonly Value[] }\n | { readonly kind: 'object'; readonly members: readonly { readonly name: string; readonly value: Value }[] };\n\nexport interface StructuredValueRewrite {\n /** Offset within the line where the replaced text starts. */\n readonly start: number;\n /** Replacement for the rest of the line from start; continuation lines carry their own indentation. */\n readonly text: string;\n}\n\n// The header shapes a JSON value can follow. Each returns the text that stays on the line before the block opens.\nconst headers: readonly ((before: string, after: string) => string | undefined)[] = [\n (before, after) => /\\bthen\\s+returns\\s*$/.test(before) && after === '' ? `${before.trimEnd()} value` : undefined,\n (before, after) => /\\bthen\\s+no\\s+readmodel\\s+\\S+\\s+for\\s*$/.test(before) && after === '' ? before.trimEnd() : undefined,\n (before, after) => /\\bfrom\\s+literal\\s*$/.test(before) ? `${before.trimEnd()}${after === '' ? '' : ` ${after}`}` : undefined,\n (before, after) => /=\\s*literal\\s*$/.test(before) && after === '' ? before.replace(/\\s*=\\s*literal\\s*$/, '') : undefined,\n (before, after) => /=\\s*$/.test(before) && after === '' ? before.replace(/\\s*=\\s*$/, '') : undefined,\n];\n\n// A step header that carries one inline assignment keeps scalars only; its structured value moves under the header,\n// which changes the parsed tree, so the editor leaves that rewrite to the author.\nconst inlineStepHeader = /^\\s*(?:given|when|then|case)\\s+\\S+.*\\s\\S+\\s*=\\s*$/;\n\n// The diagnostic may point at the line or at the value, so the value is found on the line: the first '{' or '[' outside a\n// string that follows one of the header shapes and runs to the end of the code.\nexport function rewriteInlineJson(line: string, unit: string): StructuredValueRewrite | undefined {\n const comment = commentStart(line);\n const code = comment < 0 ? line : line.slice(0, comment);\n const trailing = comment < 0 ? '' : ` ${line.slice(comment).trimStart()}`;\n for (const start of openings(code)) {\n const reader = new Reader(code, start);\n const value = reader.value();\n if (value === undefined || value.kind === 'scalar') continue;\n const before = code.slice(0, start);\n const after = code.slice(reader.position).trim();\n if (inlineStepHeader.test(before)) return undefined;\n const header = headers.map(header => header(before, after)).find(text => text !== undefined);\n if (header === undefined) continue;\n const indent = /^\\s*/.exec(line)![0];\n const lines: string[] = [];\n block(header.slice(indent.length), value, indent, unit, lines);\n lines[0] = lines[0] + trailing;\n return { start: indent.length, text: lines.join('\\n').slice(indent.length) };\n }\n return undefined;\n}\n\nfunction* openings(code: string): Generator<number> {\n let inString = false;\n for (let index = 0; index < code.length; index++) {\n const current = code[index];\n if (inString && current === '\\\\') index++;\n else if (current === '\"') inString = !inString;\n else if (!inString && (current === '{' || current === '[')) yield index;\n }\n}\n\nfunction block(header: string, value: Value, indent: string, unit: string, lines: string[]): void {\n if (value.kind === 'list' && value.items.length === 0) {\n lines.push(`${indent}${header} none`);\n return;\n }\n if (value.kind === 'object' && value.members.length === 0) {\n lines.push(`${indent}${header} empty`);\n return;\n }\n lines.push(`${indent}${header}`);\n const child = indent + unit;\n if (value.kind === 'list') {\n for (const item of value.items) {\n if (item.kind === 'scalar') lines.push(`${child}item ${item.text}`);\n else block('item', item, child, unit, lines);\n }\n } else if (value.kind === 'object') {\n for (const member of value.members) {\n const name = memberName(member.name);\n if (member.value.kind === 'scalar') lines.push(`${child}${name} = ${member.value.text}`);\n else block(name, member.value, child, unit, lines);\n }\n }\n}\n\nconst memberName = (name: string): string => name === 'item' ? '@item' : /^[\\p{L}_][\\p{L}\\p{N}_]*$/u.test(name) ? name : quote(name);\n\nconst quote = (text: string): string => '\"' + text.replace(/[\"\\\\\\n\\r\\t]/g, character => JSON.stringify(character).slice(1, -1)) + '\"';\n\nclass Reader {\n constructor(private readonly text: string, public position: number) { }\n\n value(): Value | undefined {\n this.space();\n const current = this.text[this.position];\n if (current === '{') return this.object();\n if (current === '[') return this.list();\n if (current === '\"') {\n const text = this.string();\n return text === undefined ? undefined : { kind: 'scalar', text: quote(text) };\n }\n const token = /^(?:-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?|true|false|null)/.exec(this.text.slice(this.position));\n if (token === null) return undefined;\n this.position += token[0].length;\n return { kind: 'scalar', text: token[0] };\n }\n\n private object(): Value | undefined {\n this.position++;\n const members: { name: string; value: Value }[] = [];\n this.space();\n if (this.text[this.position] === '}') {\n this.position++;\n return { kind: 'object', members };\n }\n for (;;) {\n this.space();\n const name = this.string();\n this.space();\n if (name === undefined || this.text[this.position] !== ':') return undefined;\n this.position++;\n const value = this.value();\n if (value === undefined) return undefined;\n members.push({ name, value });\n this.space();\n const next = this.text[this.position++];\n if (next === '}') return { kind: 'object', members };\n if (next !== ',') return undefined;\n }\n }\n\n private list(): Value | undefined {\n this.position++;\n const items: Value[] = [];\n this.space();\n if (this.text[this.position] === ']') {\n this.position++;\n return { kind: 'list', items };\n }\n for (;;) {\n const value = this.value();\n if (value === undefined) return undefined;\n items.push(value);\n this.space();\n const next = this.text[this.position++];\n if (next === ']') return { kind: 'list', items };\n if (next !== ',') return undefined;\n }\n }\n\n private string(): string | undefined {\n if (this.text[this.position] !== '\"') return undefined;\n let end = this.position + 1;\n while (end < this.text.length && this.text[end] !== '\"') end += this.text[end] === '\\\\' ? 2 : 1;\n if (end >= this.text.length) return undefined;\n try {\n const value = JSON.parse(this.text.slice(this.position, end + 1)) as string;\n this.position = end + 1;\n return value;\n } catch {\n return undefined;\n }\n }\n\n private space(): void {\n while (this.position < this.text.length && /\\s/.test(this.text[this.position])) this.position++;\n }\n}\n"],"mappings":"qHAqBA,MAAMA,EAA8E,EAC/E,EAAQ,IAAU,uBAAuB,KAAKC,CAAM,GAAKC,IAAU,GAAK,GAAGD,EAAO,QAAQ,EAAE,QAAU,IAAA,IACtG,EAAQ,IAAU,0CAA0C,KAAKA,CAAM,GAAKC,IAAU,GAAKD,EAAO,QAAQ,EAAI,IAAA,IAC9G,EAAQ,IAAU,uBAAuB,KAAKA,CAAM,EAAI,GAAGA,EAAO,QAAQ,IAAIC,IAAU,GAAK,GAAK,IAAIA,MAAY,IAAA,IAClH,EAAQ,IAAU,kBAAkB,KAAKD,CAAM,GAAKC,IAAU,GAAKD,EAAO,QAAQ,qBAAsB,EAAE,EAAI,IAAA,IAC9G,EAAQ,IAAU,QAAQ,KAAKA,CAAM,GAAKC,IAAU,GAAKD,EAAO,QAAQ,WAAY,EAAE,EAAI,IAAA,EAC/F,EAIME,EAAmB,oDAIzB,SAAgB,kBAAkB,EAAc,EAAkD,CAC9F,IAAMC,EAAUC,EAAaC,CAAI,EAC3BC,EAAOH,EAAU,EAAIE,EAAOA,EAAK,MAAM,EAAGF,CAAO,EACjDI,EAAWJ,EAAU,EAAI,GAAK,IAAIE,EAAK,MAAMF,CAAO,CAAC,CAAC,UAAU,IACtE,IAAK,IAAMK,KAAS,SAASF,CAAI,EAAG,CAChC,IAAMG,EAAS,IAAI,OAAOH,EAAME,CAAK,EAC/BE,EAAQD,EAAO,MAAM,EAC3B,GAAIC,IAAU,IAAA,IAAaA,EAAM,OAAS,SAAU,SACpD,IAAMV,EAASM,EAAK,MAAM,EAAGE,CAAK,EAC5BP,EAAQK,EAAK,MAAMG,EAAO,QAAQ,CAAC,CAAC,KAAK,EAC/C,GAAIP,EAAiB,KAAKF,CAAM,EAAG,OACnC,IAAMW,EAASZ,EAA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,GAAG,KAAK,UACzF,CACJ"}
|
|
1
|
+
{"version":3,"file":"StructuredValueQuickFix.js","names":["headers","before","after","inlineStepHeader","comment","commentStart","line","code","trailing","start","reader","value","header","text","indent","lines","unit","inString","index","current","child","item","member","name","character","position","token","members","next","items","end"],"sources":["../../../../../../Compiler/Authoring/StructuredValueQuickFix.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { commentStart } from '../Parsing/SourceLineSplitter';\n\n// Rewrites one inline JSON value (PLAY0833) as the indented structured block Screenplay writes instead. The value is\n// read token by token so numbers keep their authored spelling; nothing is evaluated or normalized.\n\ntype Value =\n | { readonly kind: 'scalar'; readonly text: string }\n | { readonly kind: 'list'; readonly items: readonly Value[] }\n | { readonly kind: 'object'; readonly members: readonly { readonly name: string; readonly value: Value }[] };\n\nexport interface StructuredValueRewrite {\n /** Offset within the line where the replaced text starts. */\n readonly start: number;\n /** Replacement for the rest of the line from start; continuation lines carry their own indentation. */\n readonly text: string;\n}\n\n// The header shapes a JSON value can follow. Each returns the text that stays on the line before the block opens.\nconst headers: readonly ((before: string, after: string) => string | undefined)[] = [\n (before, after) => /\\bthen\\s+returns\\s*$/.test(before) && after === '' ? `${before.trimEnd()} value` : undefined,\n (before, after) => /\\bthen\\s+no\\s+readmodel\\s+\\S+\\s+for\\s*$/.test(before) && after === '' ? before.trimEnd() : undefined,\n (before, after) => /\\bfrom\\s+literal\\s*$/.test(before) ? `${before.trimEnd()}${after === '' ? '' : ` ${after}`}` : undefined,\n (before, after) => /=\\s*literal\\s*$/.test(before) && after === '' ? before.replace(/\\s*=\\s*literal\\s*$/, '') : undefined,\n (before, after) => /=\\s*$/.test(before) && after === '' ? before.replace(/\\s*=\\s*$/, '') : undefined,\n];\n\n// A step header that carries one inline assignment keeps scalars only; its structured value moves under the header,\n// which changes the parsed tree, so the editor leaves that rewrite to the author.\nconst inlineStepHeader = /^\\s*(?:given|when|then|case)\\s+\\S+.*\\s\\S+\\s*=\\s*$/;\n\n// The diagnostic may point at the line or at the value, so the value is found on the line: the first '{' or '[' outside a\n// string that follows one of the header shapes and runs to the end of the code.\nexport function rewriteInlineJson(line: string, unit: string): StructuredValueRewrite | undefined {\n const comment = commentStart(line);\n const code = comment < 0 ? line : line.slice(0, comment);\n const trailing = comment < 0 ? '' : ` ${line.slice(comment).trimStart()}`;\n for (const start of openings(code)) {\n const reader = new Reader(code, start);\n const value = reader.value();\n if (value === undefined || value.kind === 'scalar') continue;\n const before = code.slice(0, start);\n const after = code.slice(reader.position).trim();\n if (inlineStepHeader.test(before)) return undefined;\n const header = headers.map(header => header(before, after)).find(text => text !== undefined);\n if (header === undefined) continue;\n const indent = /^\\s*/.exec(line)![0];\n const lines: string[] = [];\n block(header.slice(indent.length), value, indent, unit, lines);\n lines[0] = lines[0] + trailing;\n return { start: indent.length, text: lines.join('\\n').slice(indent.length) };\n }\n return undefined;\n}\n\nfunction* openings(code: string): Generator<number> {\n let inString = false;\n for (let index = 0; index < code.length; index++) {\n const current = code[index];\n if (inString && current === '\\\\') index++;\n else if (current === '\"') inString = !inString;\n else if (!inString && (current === '{' || current === '[')) yield index;\n }\n}\n\nfunction block(header: string, value: Value, indent: string, unit: string, lines: string[]): void {\n if (value.kind === 'list' && value.items.length === 0) {\n lines.push(`${indent}${header} none`);\n return;\n }\n if (value.kind === 'object' && value.members.length === 0) {\n lines.push(`${indent}${header} empty`);\n return;\n }\n lines.push(`${indent}${header}`);\n const child = indent + unit;\n if (value.kind === 'list') {\n for (const item of value.items) {\n if (item.kind === 'scalar') lines.push(`${child}item ${item.text}`);\n else block('item', item, child, unit, lines);\n }\n } else if (value.kind === 'object') {\n for (const member of value.members) {\n const name = memberName(member.name);\n if (member.value.kind === 'scalar') lines.push(`${child}${name} = ${member.value.text}`);\n else block(name, member.value, child, unit, lines);\n }\n }\n}\n\nconst memberName = (name: string): string => name === 'item' ? '@item' : /^[\\p{L}_][\\p{L}\\p{N}_]*$/u.test(name) ? name : quote(name);\n\nconst quote = (text: string): string => '\"' + text.replace(/[\"\\\\\\n\\r\\t]/g, character => JSON.stringify(character).slice(1, -1)) + '\"';\n\nclass Reader {\n constructor(private readonly text: string, public position: number) { }\n\n value(): Value | undefined {\n this.space();\n const current = this.text[this.position];\n if (current === '{') return this.object();\n if (current === '[') return this.list();\n if (current === '\"') {\n const text = this.string();\n return text === undefined ? undefined : { kind: 'scalar', text: quote(text) };\n }\n const token = /^(?:-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?|true|false|null)/.exec(this.text.slice(this.position));\n if (token === null) return undefined;\n this.position += token[0].length;\n return { kind: 'scalar', text: token[0] };\n }\n\n private object(): Value | undefined {\n this.position++;\n const members: { name: string; value: Value }[] = [];\n this.space();\n if (this.text[this.position] === '}') {\n this.position++;\n return { kind: 'object', members };\n }\n for (;;) {\n this.space();\n const name = this.string();\n this.space();\n if (name === undefined || this.text[this.position] !== ':') return undefined;\n this.position++;\n const value = this.value();\n if (value === undefined) return undefined;\n members.push({ name, value });\n this.space();\n const next = this.text[this.position++];\n if (next === '}') return { kind: 'object', members };\n if (next !== ',') return undefined;\n }\n }\n\n private list(): Value | undefined {\n this.position++;\n const items: Value[] = [];\n this.space();\n if (this.text[this.position] === ']') {\n this.position++;\n return { kind: 'list', items };\n }\n for (;;) {\n const value = this.value();\n if (value === undefined) return undefined;\n items.push(value);\n this.space();\n const next = this.text[this.position++];\n if (next === ']') return { kind: 'list', items };\n if (next !== ',') return undefined;\n }\n }\n\n private string(): string | undefined {\n if (this.text[this.position] !== '\"') return undefined;\n let end = this.position + 1;\n while (end < this.text.length && this.text[end] !== '\"') end += this.text[end] === '\\\\' ? 2 : 1;\n if (end >= this.text.length) return undefined;\n try {\n const value = JSON.parse(this.text.slice(this.position, end + 1)) as string;\n this.position = end + 1;\n return value;\n } catch {\n return undefined;\n }\n }\n\n private space(): void {\n while (this.position < this.text.length && /\\s/.test(this.text[this.position])) this.position++;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ual/_virtual/_rolldown/runtime.js";import{compileApplication as e}from"../Files/PlayApplicationAssembly.js";import{authoredOrderOf as t,authoredOriginsOf as n,sameAuthoredStep as r}from"../Files/AuthoredOrder.js";import{timelineOrderFindings as i}from"../Files/TimelineOrder.js";import{parseForAuthoring as a}from"../ScreenplayCompiler.js";import{splitLines as o}from"../Parsing/SourceLineSplitter.js";import{applyQuickFixEdits as s}from"./QuickFixes.js";var TimelineQuickFixContext=class{documents;compiled;ranks;origins;findings;#e=/* @__PURE__ */ new Map;constructor(e,r){this.documents=e,this.compiled=r,this.ranks=t(r.value),this.origins=n(r.value),this.findings=i(r.value)}block(e,t=!1){return[...this.ranks].sort((e,t)=>e[1]-t[1]).filter(([n])=>this.origins.get(n).some(n=>t?n.path===e.path&&n.node.kind===e.node.kind&&n.node.location.line===e.node.location.line&&n.node.location.column===e.node.location.column:r(n,e))).map(([e])=>e)}move(e,t,n){let r=[...this.ranks].sort((e,t)=>e[1]-t[1]).map(([e])=>e),contiguous=e=>e.length>0&&e.every((t,n)=>r[r.indexOf(e[0])+n]===t);if(!contiguous(e)||!contiguous(t)||e.some(e=>t.includes(e)))return;let i=r.filter(t=>!e.includes(t));return i.splice(i.indexOf(n?t.at(-1):t[0])+ +!!n,0,...e),new Map(i.map((e,t)=>[e,t]))}safe(e,t){let n=new Set(this.findings.filter(e=>e.key!==t.key).map(e=>e.key));return i(this.compiled.value,e).every(e=>n.has(e.key))}parsed(e){return this.#e.has(e)||this.#e.set(e,a(this.documents.get(e),e,this.compiled.documents.find(t=>t.path===e).placement,!1)),this.#e.get(e)}entries(e){let t=[],visit=e=>{for(let n of[`modules`,`features`,`slices`,`fileImports`])(e[n]??[]).forEach((r,i)=>{t.push({node:r,parent:e,member:n,index:i}),(r.kind===`ModuleSyntax`||r.kind===`FeatureSyntax`)&&visit(r)})};return visit(this.parsed(e).value),t}entry(e,t){let n=t.filter(t=>t.node.kind===e.node.kind&&t.node.location.line===e.node.location.line&&t.node.location.column===e.node.location.column);return n.length===1?n[0]:void 0}verify(n,r,o,c){let l=s(this.documents.get(r),n.fix.edits);if(l===void 0)return!1;let u=this.parsed(r),d=a(l,r,this.compiled.documents.find(e=>e.path===r).placement,!1),shape=(e,t=!1)=>JSON.stringify(e,(e,r)=>[`location`,`usesLocation`,`targetLocation`].includes(e)?void 0:t&&n.change!==void 0&&r===n.change.node?n.change.replacement:r);if(shape([u.value,u.triggerData],!0)!==shape([d.value,d.triggerData]))return!1;let f=new Map(this.documents).set(r,l),p=e(f);if(p.success!==this.compiled.success||p.documents.length!==this.compiled.documents.length||p.documents.some(e=>{let t=this.compiled.documents.find(t=>t.path===e.path);return t===void 0||t.isPlacementResolved!==e.isPlacementResolved||JSON.stringify(t.placement)!==JSON.stringify(e.placement)}))return!1;let m=t(p.value);if(m.size!==o.size||[...o].some(([e,t])=>m.get(e)!==t))return!1;let problems=e=>e.diagnostics.filter(e=>e.severity!==`information`).map(e=>JSON.stringify([e.code,e.severity,e.message,e.location.path])),h=problems(this.compiled),g=problems(p);if(g.some(e=>g.filter(t=>t===e).length>h.filter(t=>t===e).length))return!1;let _=new Set(this.findings.filter(e=>e.key!==c.key).map(e=>e.key));return i(p.value).every(e=>_.has(e.key))}};function moveTimelineText(e,t,n,r){let i=o(e),span=t=>{let n=i[t.location.line-1],r=/^\s*/.exec(n.raw)[0].length,a=i.slice(t.location.line).find(e=>e.raw.trim().length>0&&!e.raw.trimStart().startsWith(`//`)&&/^\s*/.exec(e.raw)[0].length<=r);return{start:n.startOffset,end:a?.startOffset??e.length}},a=span(t),s=span(n),c=r?s.end:s.start,l=e.includes(`\r
|
|
2
2
|
`)?`\r
|
|
3
3
|
`:`
|
|
4
|
-
`,u=
|
|
5
|
-
`)&&(u+=l),c===
|
|
6
|
-
`)&&(u=l+u.replace(/\r?\n$/,``)),c<
|
|
4
|
+
`,u=e.slice(a.start,a.end);return c<e.length&&!u.endsWith(`
|
|
5
|
+
`)&&(u+=l),c===e.length&&!e.endsWith(`
|
|
6
|
+
`)&&(u=l+u.replace(/\r?\n$/,``)),c<a.start?e.slice(0,c)+u+e.slice(c,a.start)+e.slice(a.end):e.slice(0,a.start)+e.slice(a.end,c)+u+e.slice(c)}export{TimelineQuickFixContext,moveTimelineText};
|
|
7
7
|
//# sourceMappingURL=TimelineQuickFixContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimelineQuickFixContext.js","names":["documents","compiled","authoredOrderOf","authoredOriginsOf","timelineOrderFindings","left","right","key","occurrence","origin","step","sameAuthoredStep","keys","block","index","moved","anchor","result","after","allowed","finding","target","ranks","#parsed","path","parseForAuthoring","document","member","parent","node","found","entries","entry","source","applyQuickFixEdits","candidate","original","parsed","value","replace","compileApplication","before","actual","rank","application","diagnostic","problem","lines","splitLines","line","indent","next","ending"],"sources":["../../../../../../Compiler/Authoring/TimelineQuickFixContext.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ApplicationCompilation, compileApplication } from '../Files/PlayApplicationAssembly';\nimport { AuthoredOrderStep, authoredOrderOf, authoredOriginsOf, sameAuthoredStep } from '../Files/AuthoredOrder';\nimport { TimelineFinding, timelineOrderFindings } from '../Files/TimelineOrder';\nimport { parseForAuthoring } from '../ScreenplayCompiler';\nimport { SyntaxNode } from '../Syntax/SyntaxNode';\nimport { ApplicationSyntax, FeatureSyntax, ModuleSyntax } from '../Syntax/Structure';\nimport { splitLines } from '../Parsing/SourceLineSplitter';\nimport { QuickFixCandidate } from './QuickFixCandidate';\nimport { applyQuickFixEdits } from './QuickFixes';\n\nexport interface TimelineEntry {\n readonly node: SyntaxNode;\n readonly parent: ApplicationSyntax | ModuleSyntax | FeatureSyntax;\n readonly member: 'modules' | 'features' | 'slices' | 'fileImports';\n readonly index: number;\n}\n\nexport class TimelineQuickFixContext {\n readonly ranks: ReadonlyMap<string, number>;\n readonly origins: ReadonlyMap<string, readonly AuthoredOrderStep[]>;\n readonly findings: readonly TimelineFinding[];\n readonly #parsed = new Map<string, ReturnType<typeof parseForAuthoring>>();\n constructor(readonly documents: ReadonlyMap<string, string>, readonly compiled: ApplicationCompilation) {\n this.ranks = authoredOrderOf(compiled.value);\n this.origins = authoredOriginsOf(compiled.value);\n this.findings = timelineOrderFindings(compiled.value);\n }\n block(step: AuthoredOrderStep, occurrence = false): string[] {\n return [...this.ranks].sort((left, right) => left[1] - right[1]).filter(([key]) => this.origins.get(key)!.some(origin => occurrence\n ? origin.path === step.path && origin.node.kind === step.node.kind && origin.node.location.line === step.node.location.line && origin.node.location.column === step.node.location.column\n : sameAuthoredStep(origin, step))).map(([key]) => key);\n }\n move(moved: readonly string[], anchor: readonly string[], after: boolean): ReadonlyMap<string, number> | undefined {\n const keys = [...this.ranks].sort((left, right) => left[1] - right[1]).map(([key]) => key);\n const contiguous = (block: readonly string[]) => block.length > 0 && block.every((key, index) => keys[keys.indexOf(block[0]) + index] === key);\n if (!contiguous(moved) || !contiguous(anchor) || moved.some(key => anchor.includes(key))) return undefined;\n const result = keys.filter(key => !moved.includes(key));\n result.splice(result.indexOf(after ? anchor.at(-1)! : anchor[0]) + (after ? 1 : 0), 0, ...moved);\n return new Map(result.map((key, index) => [key, index]));\n }\n safe(ranks: ReadonlyMap<string, number>, target: TimelineFinding): boolean {\n const allowed = new Set(this.findings.filter(finding => finding.key !== target.key).map(finding => finding.key));\n return timelineOrderFindings(this.compiled.value, ranks).every(finding => allowed.has(finding.key));\n }\n parsed(path: string): ReturnType<typeof parseForAuthoring> {\n if (!this.#parsed.has(path)) this.#parsed.set(path, parseForAuthoring(this.documents.get(path)!, path, this.compiled.documents.find(document => document.path === path)!.placement, false));\n return this.#parsed.get(path)!;\n }\n entries(path: string): TimelineEntry[] {\n const result: TimelineEntry[] = [];\n const visit = (parent: ApplicationSyntax | ModuleSyntax | FeatureSyntax) => {\n for (const member of ['modules', 'features', 'slices', 'fileImports'] as const) {\n const children = (parent as unknown as Record<string, readonly SyntaxNode[]>)[member] ?? [];\n children.forEach((node, index) => {\n result.push({ node, parent, member, index });\n if (node.kind === 'ModuleSyntax' || node.kind === 'FeatureSyntax') visit(node as ModuleSyntax | FeatureSyntax);\n });\n }\n };\n visit(this.parsed(path).value);\n return result;\n }\n entry(step: AuthoredOrderStep, entries: readonly TimelineEntry[]): TimelineEntry | undefined {\n const found = entries.filter(entry => entry.node.kind === step.node.kind && entry.node.location.line === step.node.location.line && entry.node.location.column === step.node.location.column);\n return found.length === 1 ? found[0] : undefined;\n }\n verify(candidate: QuickFixCandidate, path: string, ranks: ReadonlyMap<string, number>, finding: TimelineFinding): boolean {\n const source = applyQuickFixEdits(this.documents.get(path)!, candidate.fix.edits);\n if (source === undefined) return false;\n const original = this.parsed(path);\n const parsed = parseForAuthoring(source, path, this.compiled.documents.find(document => document.path === path)!.placement, false);\n const shape = (value: unknown, replace = false) => JSON.stringify(value, (key, node: unknown) => ['location', 'usesLocation', 'targetLocation'].includes(key) ? undefined : replace && candidate.change !== undefined && node === candidate.change.node ? candidate.change.replacement : node);\n if (shape([original.value, original.triggerData], true) !== shape([parsed.value, parsed.triggerData])) return false;\n const documents = new Map(this.documents).set(path, source);\n const compiled = compileApplication(documents);\n if (compiled.success !== this.compiled.success || compiled.documents.length !== this.compiled.documents.length || compiled.documents.some(document => {\n const before = this.compiled.documents.find(original => original.path === document.path);\n return before === undefined || before.isPlacementResolved !== document.isPlacementResolved || JSON.stringify(before.placement) !== JSON.stringify(document.placement);\n })) return false;\n const actual = authoredOrderOf(compiled.value);\n if (actual.size !== ranks.size || [...ranks].some(([key, rank]) => actual.get(key) !== rank)) return false;\n const problems = (application: ApplicationCompilation) => application.diagnostics.filter(diagnostic => diagnostic.severity !== 'information').map(diagnostic => JSON.stringify([diagnostic.code, diagnostic.severity, diagnostic.message, diagnostic.location.path]));\n const before = problems(this.compiled), after = problems(compiled);\n if (after.some(problem => after.filter(value => value === problem).length > before.filter(value => value === problem).length)) return false;\n const allowed = new Set(this.findings.filter(original => original.key !== finding.key).map(original => original.key));\n return timelineOrderFindings(compiled.value).every(candidate => allowed.has(candidate.key));\n }\n}\n\n/** Move intact physical text blocks; keep the enclosing source and its line-ending convention. */\nexport function moveTimelineText(source: string, moved: SyntaxNode, anchor: SyntaxNode, after: boolean): string {\n const lines = splitLines(source);\n const span = (node: SyntaxNode) => {\n const line = lines[node.location.line - 1];\n const indent = /^\\s*/.exec(line.raw)![0].length;\n const next = lines.slice(node.location.line).find(candidate => candidate.raw.trim().length > 0 && !candidate.raw.trimStart().startsWith('//') && /^\\s*/.exec(candidate.raw)![0].length <= indent);\n return { start: line.startOffset, end: next?.startOffset ?? source.length };\n };\n const left = span(moved), right = span(anchor);\n const target = after ? right.end : right.start;\n const ending = source.includes('\\r\\n') ? '\\r\\n' : '\\n';\n let block = source.slice(left.start, left.end);\n if (target < source.length && !block.endsWith('\\n')) block += ending;\n if (target === source.length && !source.endsWith('\\n')) block = ending + block.replace(/\\r?\\n$/, '');\n return target < left.start ? source.slice(0, target) + block + source.slice(target, left.start) + source.slice(left.end)\n : source.slice(0, left.start) + source.slice(left.end, target) + block + source.slice(target);\n}\n"],"mappings":"ydAoBA,IAAa,wBAAb,KAAqC,CAKZ,UAAiD,SAJtE,MACA,QACA,SACA,mBAAmB,IAAI,IACvB,YAAY,EAAiD,EAA2C,CAAnF,KAAA,UAAAA,EAAiD,KAAA,SAAAC,EAClE,KAAK,MAAQC,EAAgBD,EAAS,KAAK,EAC3C,KAAK,QAAUE,EAAkBF,EAAS,KAAK,EAC/C,KAAK,SAAWG,EAAsBH,EAAS,KAAK,CACxD,CACA,MAAM,EAAyB,EAAa,GAAiB,CACzD,MAAO,CAAC,GAAG,KAAK,KAAK,CAAC,CAAC,MAAM,EAAM,IAAUI,EAAK,GAAKC,EAAM,EAAE,CAAC,CAAC,QAAQ,CAACC,KAAS,KAAK,QAAQ,IAAIA,CAAG,CAAC,CAAE,KAAK,GAAUC,EACnHC,EAAO,OAASC,EAAK,MAAQD,EAAO,KAAK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AAIR,EAAQoB,EAAO,MAAMZ,EAAQhB,EAAK,KAAK,EAAI4B,EAAO,MAAM5B,EAAK,GAAG,EACjH4B,EAAO,MAAM,EAAG5B,EAAK,KAAK,EAAI4B,EAAO,MAAM5B,EAAK,IAAKgB,CAAM,EAAIR,EAAQoB,EAAO,MAAMZ,CAAM,CACpG"}
|
|
1
|
+
{"version":3,"file":"TimelineQuickFixContext.js","names":["documents","compiled","authoredOrderOf","authoredOriginsOf","timelineOrderFindings","left","right","key","occurrence","origin","step","sameAuthoredStep","keys","block","index","moved","anchor","result","after","allowed","finding","target","ranks","#parsed","path","parseForAuthoring","document","member","parent","node","found","entries","entry","source","applyQuickFixEdits","candidate","original","parsed","value","replace","compileApplication","before","actual","rank","application","diagnostic","problem","lines","splitLines","line","indent","next","ending"],"sources":["../../../../../../Compiler/Authoring/TimelineQuickFixContext.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ApplicationCompilation, compileApplication } from '../Files/PlayApplicationAssembly';\nimport { AuthoredOrderStep, authoredOrderOf, authoredOriginsOf, sameAuthoredStep } from '../Files/AuthoredOrder';\nimport { TimelineFinding, timelineOrderFindings } from '../Files/TimelineOrder';\nimport { parseForAuthoring } from '../ScreenplayCompiler';\nimport { SyntaxNode } from '../Syntax/SyntaxNode';\nimport { ApplicationSyntax, FeatureSyntax, ModuleSyntax } from '../Syntax/Structure';\nimport { splitLines } from '../Parsing/SourceLineSplitter';\nimport { QuickFixCandidate } from './QuickFixCandidate';\nimport { applyQuickFixEdits } from './QuickFixes';\n\nexport interface TimelineEntry {\n readonly node: SyntaxNode;\n readonly parent: ApplicationSyntax | ModuleSyntax | FeatureSyntax;\n readonly member: 'modules' | 'features' | 'slices' | 'fileImports';\n readonly index: number;\n}\n\nexport class TimelineQuickFixContext {\n readonly ranks: ReadonlyMap<string, number>;\n readonly origins: ReadonlyMap<string, readonly AuthoredOrderStep[]>;\n readonly findings: readonly TimelineFinding[];\n readonly #parsed = new Map<string, ReturnType<typeof parseForAuthoring>>();\n constructor(readonly documents: ReadonlyMap<string, string>, readonly compiled: ApplicationCompilation) {\n this.ranks = authoredOrderOf(compiled.value);\n this.origins = authoredOriginsOf(compiled.value);\n this.findings = timelineOrderFindings(compiled.value);\n }\n block(step: AuthoredOrderStep, occurrence = false): string[] {\n return [...this.ranks].sort((left, right) => left[1] - right[1]).filter(([key]) => this.origins.get(key)!.some(origin => occurrence\n ? origin.path === step.path && origin.node.kind === step.node.kind && origin.node.location.line === step.node.location.line && origin.node.location.column === step.node.location.column\n : sameAuthoredStep(origin, step))).map(([key]) => key);\n }\n move(moved: readonly string[], anchor: readonly string[], after: boolean): ReadonlyMap<string, number> | undefined {\n const keys = [...this.ranks].sort((left, right) => left[1] - right[1]).map(([key]) => key);\n const contiguous = (block: readonly string[]) => block.length > 0 && block.every((key, index) => keys[keys.indexOf(block[0]) + index] === key);\n if (!contiguous(moved) || !contiguous(anchor) || moved.some(key => anchor.includes(key))) return undefined;\n const result = keys.filter(key => !moved.includes(key));\n result.splice(result.indexOf(after ? anchor.at(-1)! : anchor[0]) + (after ? 1 : 0), 0, ...moved);\n return new Map(result.map((key, index) => [key, index]));\n }\n safe(ranks: ReadonlyMap<string, number>, target: TimelineFinding): boolean {\n const allowed = new Set(this.findings.filter(finding => finding.key !== target.key).map(finding => finding.key));\n return timelineOrderFindings(this.compiled.value, ranks).every(finding => allowed.has(finding.key));\n }\n parsed(path: string): ReturnType<typeof parseForAuthoring> {\n if (!this.#parsed.has(path)) this.#parsed.set(path, parseForAuthoring(this.documents.get(path)!, path, this.compiled.documents.find(document => document.path === path)!.placement, false));\n return this.#parsed.get(path)!;\n }\n entries(path: string): TimelineEntry[] {\n const result: TimelineEntry[] = [];\n const visit = (parent: ApplicationSyntax | ModuleSyntax | FeatureSyntax) => {\n for (const member of ['modules', 'features', 'slices', 'fileImports'] as const) {\n const children = (parent as unknown as Record<string, readonly SyntaxNode[]>)[member] ?? [];\n children.forEach((node, index) => {\n result.push({ node, parent, member, index });\n if (node.kind === 'ModuleSyntax' || node.kind === 'FeatureSyntax') visit(node as ModuleSyntax | FeatureSyntax);\n });\n }\n };\n visit(this.parsed(path).value);\n return result;\n }\n entry(step: AuthoredOrderStep, entries: readonly TimelineEntry[]): TimelineEntry | undefined {\n const found = entries.filter(entry => entry.node.kind === step.node.kind && entry.node.location.line === step.node.location.line && entry.node.location.column === step.node.location.column);\n return found.length === 1 ? found[0] : undefined;\n }\n verify(candidate: QuickFixCandidate, path: string, ranks: ReadonlyMap<string, number>, finding: TimelineFinding): boolean {\n const source = applyQuickFixEdits(this.documents.get(path)!, candidate.fix.edits);\n if (source === undefined) return false;\n const original = this.parsed(path);\n const parsed = parseForAuthoring(source, path, this.compiled.documents.find(document => document.path === path)!.placement, false);\n const shape = (value: unknown, replace = false) => JSON.stringify(value, (key, node: unknown) => ['location', 'usesLocation', 'targetLocation'].includes(key) ? undefined : replace && candidate.change !== undefined && node === candidate.change.node ? candidate.change.replacement : node);\n if (shape([original.value, original.triggerData], true) !== shape([parsed.value, parsed.triggerData])) return false;\n const documents = new Map(this.documents).set(path, source);\n const compiled = compileApplication(documents);\n if (compiled.success !== this.compiled.success || compiled.documents.length !== this.compiled.documents.length || compiled.documents.some(document => {\n const before = this.compiled.documents.find(original => original.path === document.path);\n return before === undefined || before.isPlacementResolved !== document.isPlacementResolved || JSON.stringify(before.placement) !== JSON.stringify(document.placement);\n })) return false;\n const actual = authoredOrderOf(compiled.value);\n if (actual.size !== ranks.size || [...ranks].some(([key, rank]) => actual.get(key) !== rank)) return false;\n const problems = (application: ApplicationCompilation) => application.diagnostics.filter(diagnostic => diagnostic.severity !== 'information').map(diagnostic => JSON.stringify([diagnostic.code, diagnostic.severity, diagnostic.message, diagnostic.location.path]));\n const before = problems(this.compiled), after = problems(compiled);\n if (after.some(problem => after.filter(value => value === problem).length > before.filter(value => value === problem).length)) return false;\n const allowed = new Set(this.findings.filter(original => original.key !== finding.key).map(original => original.key));\n return timelineOrderFindings(compiled.value).every(candidate => allowed.has(candidate.key));\n }\n}\n\n/** Move intact physical text blocks; keep the enclosing source and its line-ending convention. */\nexport function moveTimelineText(source: string, moved: SyntaxNode, anchor: SyntaxNode, after: boolean): string {\n const lines = splitLines(source);\n const span = (node: SyntaxNode) => {\n const line = lines[node.location.line - 1];\n const indent = /^\\s*/.exec(line.raw)![0].length;\n const next = lines.slice(node.location.line).find(candidate => candidate.raw.trim().length > 0 && !candidate.raw.trimStart().startsWith('//') && /^\\s*/.exec(candidate.raw)![0].length <= indent);\n return { start: line.startOffset, end: next?.startOffset ?? source.length };\n };\n const left = span(moved), right = span(anchor);\n const target = after ? right.end : right.start;\n const ending = source.includes('\\r\\n') ? '\\r\\n' : '\\n';\n let block = source.slice(left.start, left.end);\n if (target < source.length && !block.endsWith('\\n')) block += ending;\n if (target === source.length && !source.endsWith('\\n')) block = ending + block.replace(/\\r?\\n$/, '');\n return target < left.start ? source.slice(0, target) + block + source.slice(target, left.start) + source.slice(left.end)\n : source.slice(0, left.start) + source.slice(left.end, target) + block + source.slice(target);\n}\n"],"mappings":"A,ydAoBA,IAAa,wBAAb,KAAqC,CAKZ,UAAiD,SAJtE,MACA,QACA,SACA,mBAAmB,IAAI,IACvB,YAAY,EAAiD,EAA2C,CAAnF,KAAA,UAAAA,EAAiD,KAAA,SAAAC,EAClE,KAAK,MAAQC,EAAgBD,EAAS,KAAK,EAC3C,KAAK,QAAUE,EAAkBF,EAAS,KAAK,EAC/C,KAAK,SAAWG,EAAsBH,EAAS,KAAK,CACxD,CACA,MAAM,EAAyB,EAAa,GAAiB,CACzD,MAAO,CAAC,GAAG,KAAK,KAAK,CAAC,CAAC,MAAM,EAAM,IAAUI,EAAK,GAAKC,EAAM,EAAE,CAAC,CAAC,QAAQ,CAACC,KAAS,KAAK,QAAQ,IAAIA,CAAG,CAAC,CAAE,KAAK,GAAUC,EACnHC,EAAO,OAASC,EAAK,MAAQD,EAAO,KAA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EAAIR,EAAQoB,EAAO,MAAMZ,EAAQhB,EAAK,KAAK,EAAI4B,EAAO,MAAM5B,EAAK,GAAG,EACjH4B,EAAO,MAAM,EAAG5B,EAAK,KAAK,EAAI4B,EAAO,MAAM5B,EAAK,IAAKgB,CAAM,EAAIR,EAAQoB,EAAO,MAAMZ,CAAM,CACpG,C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import"../../_virtual/_virtual/_rolldown/runtime.js";import{
|
|
1
|
+
import"../../_virtual/_virtual/_rolldown/runtime.js";import{matchesPlayPattern as e,resolvePlayPattern as t}from"../Files/PlayGlob.js";import{commentStart as n,splitLines as r}from"../Parsing/SourceLineSplitter.js";const hasMetacharacters=e=>/[*?[\]{}]/.test(e),relativePath=(e,t)=>{let n=e.split(`/`).slice(0,-1),r=t.split(`/`);for(;n.length>0&&n[0]===r[0];)n.shift(),r.shift();return[...n.map(()=>`..`),...r].join(`/`)};function timelineImportFix(i,a,o,s,c,l){let u=i.documents.get(o.path),d=r(u),f=d[c.node.location.line-1],p=/^\s*/.exec(f.raw)[0],m=u.includes(`\r
|
|
2
2
|
`)?`\r
|
|
3
3
|
`:`
|
|
4
|
-
`,h=c.parent.fileImports,propose=(t,
|
|
4
|
+
`,h=c.parent.fileImports,propose=(e,t,r,s)=>{if(e.some(hasMetacharacters))return;let l=e.map(e=>({kind:`FileImportSyntax`,pattern:relativePath(o.path,e),location:c.node.location})),g={...c.parent,fileImports:[...h.slice(0,c.index),...l,...h.slice(c.index+r)]},_=r===0?f.startOffset:d[h[c.index+r-1].location.line]?.startOffset??u.length,v=new Set(h.slice(c.index,c.index+r).map(e=>e.location.line)),y=(r===0?[]:d.filter(e=>e.startOffset>=f.startOffset&&e.startOffset<_).flatMap(e=>{if(!v.has(e.number))return[u.slice(e.startOffset,d[e.number]?.startOffset??u.length)];let t=n(e.raw);return t<0?[]:[`${p}${e.raw.slice(t)}${m}`]})).join(``)+l.map(e=>`${p}import ${JSON.stringify(e.pattern)}${m}`).join(``),b={line:a.diagnostic.location.line,change:{node:c.parent,replacement:g},fix:{diagnosticCode:a.diagnostic.code,title:s,scope:`occurrence`,line:a.diagnostic.location.line,edits:[{path:o.path,start:f.startOffset,length:_-f.startOffset,text:y}]}};return i.verify(b,o.path,t,a)?b:void 0};if(c.index===l.index){let e=[...new Map([...i.origins.values()].flatMap(e=>e).filter(e=>e.path===o.path&&e.node.kind===`FileImportSyntax`&&e.node.location.line===o.node.location.line).map(e=>[e.targetPath,e])).values()].sort((e,t)=>e.matchIndex-t.matchIndex);if(e.length<2)return;let t=e.map(e=>e.targetPath),n=[...i.ranks].sort((e,t)=>e[1]-t[1]).map(([e])=>e),r=e.flatMap(e=>i.block(e)),c=n.indexOf(r[0]);if(!r.every((e,t)=>n[c+t]===e))return;let ranksFor=a=>{let o=[...a,...t.filter(e=>!a.includes(e))].flatMap(t=>i.block(e.find(e=>e.targetPath===t))),s=[...n];return s.splice(c,r.length,...o),new Map(s.map((e,t)=>[e,t]))},l=ranksFor([s.targetPath]);if(i.safe(l,a))return propose([s.targetPath],l,0,`Pin timeline order before the glob (new files remain imported)`);for(let e of[!1,!0]){let n=[...t],r=e?o.targetPath:s.targetPath,c=e?s.targetPath:o.targetPath;n.splice(n.indexOf(r),1),n.splice(n.indexOf(c)+ +!!e,0,r);let l=ranksFor(n);if(i.safe(l,a))for(let e=1;e<=n.length;e++){let t=n.slice(0,e),r=ranksFor(t);if(![...l].some(([e,t])=>r.get(e)!==t))return propose(t,r,0,`Pin timeline order before the glob (new files remain imported)`)}}return}if(c.index>l.index)return;let g=h.slice(c.index,l.index+1);if(!g.some(e=>hasMetacharacters(e.pattern)))return;let _=g.flatMap(n=>i.compiled.documents.filter(r=>r.path!==o.path&&e(t(o.path,n.pattern),r.path)).map(e=>e.path).sort());if(new Set(_).size===_.length)for(let e of[!1,!0]){let t=i.move(i.block(e?o:s),i.block(e?s:o),e);if(t===void 0||!i.safe(t,a))continue;let n=[..._],r=e?o.targetPath:s.targetPath,c=e?s.targetPath:o.targetPath;if(!n.includes(r)||!n.includes(c))continue;n.splice(n.indexOf(r),1),n.splice(n.indexOf(c)+ +!!e,0,r);let l=propose(n,t,g.length,`Replace timeline globs with ordered imports (new files need explicit imports)`);if(l!==void 0)return l}}export{timelineImportFix};
|
|
5
5
|
//# sourceMappingURL=TimelineQuickFixImports.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimelineQuickFixImports.js","names":["path","folder","document","parts","target","source","context","left","lines","splitLines","line","entry","indent","ending","imports","paths","nodes","replacement","remove","last","importLines","imported","text","candidate","comment","commentStart","node","finding","ranks","other","steps","chain","step","right","keys","key","all","position","index","ordered","prefix","result","single","after","desired","moved","anchor","count","rank","selected","matchesPlayPattern","resolvePlayPattern"],"sources":["../../../../../../Compiler/Authoring/TimelineQuickFixImports.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { AuthoredOrderStep } from '../Files/AuthoredOrder';\nimport { TimelineFinding } from '../Files/TimelineOrder';\nimport { matchesPlayPattern, resolvePlayPattern } from '../Files/PlayGlob';\nimport { FileImportSyntax } from '../Syntax/Structure';\nimport { commentStart, splitLines } from '../Parsing/SourceLineSplitter';\nimport { QuickFixCandidate } from './QuickFixCandidate';\nimport { TimelineEntry, TimelineQuickFixContext } from './TimelineQuickFixContext';\n\nconst hasMetacharacters = (path: string) => /[*?[\\]{}]/.test(path);\nconst relativePath = (document: string, target: string): string => {\n const folder = document.split('/').slice(0, -1), parts = target.split('/');\n while (folder.length > 0 && folder[0] === parts[0]) { folder.shift(); parts.shift(); }\n return [...folder.map(() => '..'), ...parts].join('/');\n};\n\nexport function timelineImportFix(context: TimelineQuickFixContext, finding: TimelineFinding, left: AuthoredOrderStep, right: AuthoredOrderStep, entry: TimelineEntry, other: TimelineEntry): QuickFixCandidate | undefined {\n const source = context.documents.get(left.path)!;\n const lines = splitLines(source);\n const line = lines[entry.node.location.line - 1];\n const indent = /^\\s*/.exec(line.raw)![0];\n const ending = source.includes('\\r\\n') ? '\\r\\n' : '\\n';\n const imports = (entry.parent as unknown as { fileImports: readonly FileImportSyntax[] }).fileImports;\n const propose = (paths: readonly string[], ranks: ReadonlyMap<string, number>, remove: number, title: string): QuickFixCandidate | undefined => {\n if (paths.some(hasMetacharacters)) return undefined;\n const nodes = paths.map(path => ({ kind: 'FileImportSyntax' as const, pattern: relativePath(left.path, path), location: entry.node.location }));\n const replacement = { ...entry.parent, fileImports: [...imports.slice(0, entry.index), ...nodes, ...imports.slice(entry.index + remove)] };\n const last = remove === 0 ? line.startOffset : lines[imports[entry.index + remove - 1].location.line]?.startOffset ?? source.length;\n // Keep comments attached to each replaced import exactly once. Pins leave the original line intact.\n const importLines = new Set(imports.slice(entry.index, entry.index + remove).map(imported => imported.location.line));\n const comments = remove === 0 ? [] : lines.filter(candidate => candidate.startOffset >= line.startOffset && candidate.startOffset < last).flatMap(candidate => {\n if (!importLines.has(candidate.number)) return [source.slice(candidate.startOffset, lines[candidate.number]?.startOffset ?? source.length)];\n const comment = commentStart(candidate.raw);\n return comment < 0 ? [] : [`${indent}${candidate.raw.slice(comment)}${ending}`];\n });\n const text = comments.join('') + nodes.map(node => `${indent}import ${JSON.stringify(node.pattern)}${ending}`).join('');\n const candidate: QuickFixCandidate = { line: finding.diagnostic.location.line, change: { node: entry.parent, replacement }, fix: {\n diagnosticCode: finding.diagnostic.code, title, scope: 'occurrence', line: finding.diagnostic.location.line,\n edits: [{ path: left.path, start: line.startOffset, length: last - line.startOffset, text }],\n } };\n return context.verify(candidate, left.path, ranks, finding) ? candidate : undefined;\n };\n if (entry.index === other.index) {\n const steps = [...new Map([...context.origins.values()].flatMap(chain => chain).filter(step => step.path === left.path && step.node.kind === 'FileImportSyntax' && step.node.location.line === left.node.location.line).map(step => [step.targetPath!, step])).values()].sort((left, right) => left.matchIndex! - right.matchIndex!);\n if (steps.length < 2) return undefined;\n const paths = steps.map(step => step.targetPath!);\n const keys = [...context.ranks].sort((left, right) => left[1] - right[1]).map(([key]) => key);\n const all = steps.flatMap(step => context.block(step));\n const position = keys.indexOf(all[0]);\n if (!all.every((key, index) => keys[position + index] === key)) return undefined;\n const ranksFor = (prefix: readonly string[]) => {\n const ordered = [...prefix, ...paths.filter(path => !prefix.includes(path))].flatMap(path => context.block(steps.find(step => step.targetPath === path)!));\n const result = [...keys];\n result.splice(position, all.length, ...ordered);\n return new Map(result.map((key, index) => [key, index]));\n };\n const single = ranksFor([right.targetPath!]);\n if (context.safe(single, finding)) return propose([right.targetPath!], single, 0, 'Pin timeline order before the glob (new files remain imported)');\n for (const after of [false, true]) {\n const desired = [...paths];\n const moved = after ? left.targetPath! : right.targetPath!, anchor = after ? right.targetPath! : left.targetPath!;\n desired.splice(desired.indexOf(moved), 1);\n desired.splice(desired.indexOf(anchor) + (after ? 1 : 0), 0, moved);\n const ranks = ranksFor(desired);\n if (!context.safe(ranks, finding)) continue;\n for (let count = 1; count <= desired.length; count++) {\n const prefix = desired.slice(0, count);\n const candidate = ranksFor(prefix);\n if ([...ranks].some(([key, rank]) => candidate.get(key) !== rank)) continue;\n return propose(prefix, candidate, 0, 'Pin timeline order before the glob (new files remain imported)');\n }\n }\n return undefined;\n }\n // Freeze only the affected adjacent import interval. Include files with no ranked declaration.\n if (entry.index > other.index) return undefined;\n const selected = imports.slice(entry.index, other.index + 1);\n if (!selected.some(imported => hasMetacharacters(imported.pattern))) return undefined;\n const paths = selected.flatMap(imported => context.compiled.documents.filter(document => document.path !== left.path && matchesPlayPattern(resolvePlayPattern(left.path, imported.pattern), document.path)).map(document => document.path).sort());\n if (new Set(paths).size !== paths.length) return undefined;\n for (const after of [false, true]) {\n const ranks = context.move(context.block(after ? left : right), context.block(after ? right : left), after);\n if (ranks === undefined || !context.safe(ranks, finding)) continue;\n const desired = [...paths];\n const moved = after ? left.targetPath! : right.targetPath!, anchor = after ? right.targetPath! : left.targetPath!;\n if (!desired.includes(moved) || !desired.includes(anchor)) continue;\n desired.splice(desired.indexOf(moved), 1);\n desired.splice(desired.indexOf(anchor) + (after ? 1 : 0), 0, moved);\n const candidate = propose(desired, ranks, selected.length, 'Replace timeline globs with ordered imports (new files need explicit imports)');\n if (candidate !== undefined) return candidate;\n }\n return undefined;\n}\n"],"mappings":"uNAWA,MAAM,kBAAqB,GAAiB,YAAY,KAAKA,CAAI,EAC3D,cAAgB,EAAkB,IAA2B,CAC/D,IAAMC,EAASC,EAAS,MAAM,GAAG,CAAC,CAAC,MAAM,EAAG,EAAE,EAAGC,EAAQC,EAAO,MAAM,GAAG,EACzE,KAAOH,EAAO,OAAS,GAAKA,EAAO,KAAOE,EAAM,IAAMF,EAAO,MAAM,EAAGE,EAAM,MAAM,EAClF,MAAO,CAAC,GAAGF,EAAO,QAAU,IAAI,EAAG,GAAGE,CAAK,CAAC,CAAC,KAAK,GAAG,CACzD,EAEA,SAAgB,kBAAkB,EAAkC,EAA0B,EAAyB,EAA0B,EAAsB,EAAqD,CACxN,IAAME,EAASC,EAAQ,UAAU,IAAIC,EAAK,IAAI,EACxCC,EAAQC,EAAWJ,CAAM,EACzBK,EAAOF,EAAMG,EAAM,KAAK,SAAS,KAAO,GACxCC,EAAS,OAAO,KAAKF,EAAK,GAAG,CAAC,CAAE,GAChCG,EAASR,EAAO,SAAS;CAAM,EAAI;EAAS;EAC5CS,EAAWH,EAAM,OAAmE,YACpF,SAAW,EAA0B,EAAoC,EAAgB,IAAiD,CAC5I,GAAII,EAAM,KAAK,iBAAiB,EAAG,OACnC,IAAMC,EAAQD,EAAM,IAAI,IAAS,CAAE,KAAM,mBAA6B,QAAS,aAAaR,EAAK,KAAMP,CAAI,EAAG,SAAUW,EAAM,KAAK,QAAS,EAAE,EACxIM,EAAc,CAAE,GAAGN,EAAM,OAAQ,YAAa,CAAC,GAAGG,EAAQ,MAAM,EAAGH,EAAM,KAAK,EAAG,GAAGK,EAAO,GAAGF,EAAQ,MAAMH,EAAM,MAAQO,CAAM,CAAC,CAAE,E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AAC,EACjP,GAAI,IAAI,IAAIa,CAAK,CAAC,CAAC,OAASA,EAAM,OAClC,IAAK,IAAM4B,IAAS,CAAC,GAAO,EAAI,EAAG,CAC/B,IAAMf,EAAQtB,EAAQ,KAAKA,EAAQ,MAAMqC,EAAQpC,EAAO0B,CAAK,EAAG3B,EAAQ,MAAMqC,EAAQV,EAAQ1B,CAAI,EAAGoC,CAAK,EAC1G,GAAIf,IAAU,IAAA,IAAa,CAACtB,EAAQ,KAAKsB,EAAOD,CAAO,EAAG,SAC1D,IAAMiB,EAAU,CAAC,GAAG7B,CAAK,EACnB8B,EAAQF,EAAQpC,EAAK,WAAc0B,EAAM,WAAaa,EAASH,EAAQV,EAAM,WAAc1B,EAAK,WACtG,GAAI,CAACqC,EAAQ,SAASC,CAAK,GAAK,CAACD,EAAQ,SAASE,CAAM,EAAG,SAC3DF,EAAQ,OAAOA,EAAQ,QAAQC,CAAK,EAAG,CAAC,EACxCD,EAAQ,OAAOA,EAAQ,QAAQE,CAAM,GAAK,KAAgB,EAAGD,CAAK,EAClE,IAAMtB,EAAY,QAAQqB,EAAShB,EAAOqB,EAAS,OAAQ,+EAA+E,EAC1I,GAAI1B,IAAc,IAAA,GAAW,OAAOA,CACxC,CAEJ"}
|
|
1
|
+
{"version":3,"file":"TimelineQuickFixImports.js","names":["path","folder","document","parts","target","source","context","left","lines","splitLines","line","entry","indent","ending","imports","paths","nodes","replacement","remove","last","importLines","imported","text","candidate","comment","commentStart","node","finding","ranks","other","steps","chain","step","right","keys","key","all","position","index","ordered","prefix","result","single","after","desired","moved","anchor","count","rank","selected","matchesPlayPattern","resolvePlayPattern"],"sources":["../../../../../../Compiler/Authoring/TimelineQuickFixImports.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { AuthoredOrderStep } from '../Files/AuthoredOrder';\nimport { TimelineFinding } from '../Files/TimelineOrder';\nimport { matchesPlayPattern, resolvePlayPattern } from '../Files/PlayGlob';\nimport { FileImportSyntax } from '../Syntax/Structure';\nimport { commentStart, splitLines } from '../Parsing/SourceLineSplitter';\nimport { QuickFixCandidate } from './QuickFixCandidate';\nimport { TimelineEntry, TimelineQuickFixContext } from './TimelineQuickFixContext';\n\nconst hasMetacharacters = (path: string) => /[*?[\\]{}]/.test(path);\nconst relativePath = (document: string, target: string): string => {\n const folder = document.split('/').slice(0, -1), parts = target.split('/');\n while (folder.length > 0 && folder[0] === parts[0]) { folder.shift(); parts.shift(); }\n return [...folder.map(() => '..'), ...parts].join('/');\n};\n\nexport function timelineImportFix(context: TimelineQuickFixContext, finding: TimelineFinding, left: AuthoredOrderStep, right: AuthoredOrderStep, entry: TimelineEntry, other: TimelineEntry): QuickFixCandidate | undefined {\n const source = context.documents.get(left.path)!;\n const lines = splitLines(source);\n const line = lines[entry.node.location.line - 1];\n const indent = /^\\s*/.exec(line.raw)![0];\n const ending = source.includes('\\r\\n') ? '\\r\\n' : '\\n';\n const imports = (entry.parent as unknown as { fileImports: readonly FileImportSyntax[] }).fileImports;\n const propose = (paths: readonly string[], ranks: ReadonlyMap<string, number>, remove: number, title: string): QuickFixCandidate | undefined => {\n if (paths.some(hasMetacharacters)) return undefined;\n const nodes = paths.map(path => ({ kind: 'FileImportSyntax' as const, pattern: relativePath(left.path, path), location: entry.node.location }));\n const replacement = { ...entry.parent, fileImports: [...imports.slice(0, entry.index), ...nodes, ...imports.slice(entry.index + remove)] };\n const last = remove === 0 ? line.startOffset : lines[imports[entry.index + remove - 1].location.line]?.startOffset ?? source.length;\n // Keep comments attached to each replaced import exactly once. Pins leave the original line intact.\n const importLines = new Set(imports.slice(entry.index, entry.index + remove).map(imported => imported.location.line));\n const comments = remove === 0 ? [] : lines.filter(candidate => candidate.startOffset >= line.startOffset && candidate.startOffset < last).flatMap(candidate => {\n if (!importLines.has(candidate.number)) return [source.slice(candidate.startOffset, lines[candidate.number]?.startOffset ?? source.length)];\n const comment = commentStart(candidate.raw);\n return comment < 0 ? [] : [`${indent}${candidate.raw.slice(comment)}${ending}`];\n });\n const text = comments.join('') + nodes.map(node => `${indent}import ${JSON.stringify(node.pattern)}${ending}`).join('');\n const candidate: QuickFixCandidate = { line: finding.diagnostic.location.line, change: { node: entry.parent, replacement }, fix: {\n diagnosticCode: finding.diagnostic.code, title, scope: 'occurrence', line: finding.diagnostic.location.line,\n edits: [{ path: left.path, start: line.startOffset, length: last - line.startOffset, text }],\n } };\n return context.verify(candidate, left.path, ranks, finding) ? candidate : undefined;\n };\n if (entry.index === other.index) {\n const steps = [...new Map([...context.origins.values()].flatMap(chain => chain).filter(step => step.path === left.path && step.node.kind === 'FileImportSyntax' && step.node.location.line === left.node.location.line).map(step => [step.targetPath!, step])).values()].sort((left, right) => left.matchIndex! - right.matchIndex!);\n if (steps.length < 2) return undefined;\n const paths = steps.map(step => step.targetPath!);\n const keys = [...context.ranks].sort((left, right) => left[1] - right[1]).map(([key]) => key);\n const all = steps.flatMap(step => context.block(step));\n const position = keys.indexOf(all[0]);\n if (!all.every((key, index) => keys[position + index] === key)) return undefined;\n const ranksFor = (prefix: readonly string[]) => {\n const ordered = [...prefix, ...paths.filter(path => !prefix.includes(path))].flatMap(path => context.block(steps.find(step => step.targetPath === path)!));\n const result = [...keys];\n result.splice(position, all.length, ...ordered);\n return new Map(result.map((key, index) => [key, index]));\n };\n const single = ranksFor([right.targetPath!]);\n if (context.safe(single, finding)) return propose([right.targetPath!], single, 0, 'Pin timeline order before the glob (new files remain imported)');\n for (const after of [false, true]) {\n const desired = [...paths];\n const moved = after ? left.targetPath! : right.targetPath!, anchor = after ? right.targetPath! : left.targetPath!;\n desired.splice(desired.indexOf(moved), 1);\n desired.splice(desired.indexOf(anchor) + (after ? 1 : 0), 0, moved);\n const ranks = ranksFor(desired);\n if (!context.safe(ranks, finding)) continue;\n for (let count = 1; count <= desired.length; count++) {\n const prefix = desired.slice(0, count);\n const candidate = ranksFor(prefix);\n if ([...ranks].some(([key, rank]) => candidate.get(key) !== rank)) continue;\n return propose(prefix, candidate, 0, 'Pin timeline order before the glob (new files remain imported)');\n }\n }\n return undefined;\n }\n // Freeze only the affected adjacent import interval. Include files with no ranked declaration.\n if (entry.index > other.index) return undefined;\n const selected = imports.slice(entry.index, other.index + 1);\n if (!selected.some(imported => hasMetacharacters(imported.pattern))) return undefined;\n const paths = selected.flatMap(imported => context.compiled.documents.filter(document => document.path !== left.path && matchesPlayPattern(resolvePlayPattern(left.path, imported.pattern), document.path)).map(document => document.path).sort());\n if (new Set(paths).size !== paths.length) return undefined;\n for (const after of [false, true]) {\n const ranks = context.move(context.block(after ? left : right), context.block(after ? right : left), after);\n if (ranks === undefined || !context.safe(ranks, finding)) continue;\n const desired = [...paths];\n const moved = after ? left.targetPath! : right.targetPath!, anchor = after ? right.targetPath! : left.targetPath!;\n if (!desired.includes(moved) || !desired.includes(anchor)) continue;\n desired.splice(desired.indexOf(moved), 1);\n desired.splice(desired.indexOf(anchor) + (after ? 1 : 0), 0, moved);\n const candidate = propose(desired, ranks, selected.length, 'Replace timeline globs with ordered imports (new files need explicit imports)');\n if (candidate !== undefined) return candidate;\n }\n return undefined;\n}\n"],"mappings":"A,uNAWA,MAAM,kBAAqB,GAAiB,YAAY,KAAKA,CAAI,EAC3D,cAAgB,EAAkB,IAA2B,CAC/D,IAAMC,EAASC,EAAS,MAAM,GAAG,CAAC,CAAC,MAAM,EAAG,EAAE,EAAGC,EAAQC,EAAO,MAAM,GAAG,EACzE,KAAOH,EAAO,OAAS,GAAKA,EAAO,KAAOE,EAAM,IAAMF,EAAO,MAAM,EAAGE,EAAM,MAAM,EAClF,MAAO,CAAC,GAAGF,EAAO,QAAU,IAAI,EAAG,GAAGE,CAAK,CAAC,CAAC,KAAK,GAAG,CACzD,EAEA,SAAgB,kBAAkB,EAAkC,EAA0B,EAAyB,EAA0B,EAAsB,EAAqD,CACxN,IAAME,EAASC,EAAQ,UAAU,IAAIC,EAAK,IAAI,EACxCC,EAAQC,EAAWJ,CAAM,EACzBK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AAS,OAAQ,+EAA+E,EAC1I,GAAI1B,IAAc,IAAA,GAAW,OAAOA,CACxC,CAEJ,C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../_virtual/_virtual/_rolldown/runtime.js";import{
|
|
1
|
+
import"../../_virtual/_virtual/_rolldown/runtime.js";import{authoredOrderKey as e,sameAuthoredStep as t}from"../Files/AuthoredOrder.js";import{compileApplication as n}from"../Files/PlayApplicationAssembly.js";import{DiagnosticCodes as r}from"../Diagnostics/DiagnosticCodes.js";import{TimelineQuickFixContext as i,moveTimelineText as a}from"./TimelineQuickFixContext.js";import{timelineImportFix as o}from"./TimelineQuickFixImports.js";function prepareTimelineQuickFixes(s,c){let l=c.path??`application.play`,u=new Map(c.documents??[[l,s]]);if(u.get(l)!==s||c.documents===void 0&&(c.placement?.length??0)>0)return()=>[];let d=n(u);if(!d.success||d.documents.some(e=>e.isPlacementResolved===!1))return()=>[];let f=new i(u,d),p=/* @__PURE__ */ new Map;return n=>{if(p.has(n))return p.get(n);let i=f.findings.filter(e=>e.diagnostic.code===r.EventFromLaterSlice&&e.diagnostic.location.path===l&&e.diagnostic.location.line===n),s=[];if(i.length===1&&!i[0].ownSubFeature){let r=i[0],l=f.origins.get(e(r.consumerScope)),d=f.origins.get(e(r.producerScope));if(l!==void 0&&d!==void 0){let e=0;for(;e<l.length&&e<d.length&&t(l[e],d[e]);)e++;let i=l[e],p=d[e];if(i!==void 0&&p!==void 0&&i.path===p.path){let e=f.entries(i.path),t=f.entry(i,e),l=f.entry(p,e);if(t!==void 0&&l!==void 0&&t.parent===l.parent&&t.member===l.member){let e;if(t.index!==l.index)for(let o of[!1,!0]){let s=o?t:l,c=o?l:t,d=o?i:p,m=o?p:i,h=f.move(f.block(d,d.node.kind===`FileImportSyntax`),f.block(m,m.node.kind===`FileImportSyntax`),o);if(h===void 0||!f.safe(h,r))continue;let g=[...t.parent[t.member]];g.splice(s.index,1),g.splice(g.indexOf(c.node)+ +!!o,0,s.node);let _={...t.parent,[t.member]:g},v=u.get(i.path);if(e={line:n,change:{node:t.parent,replacement:_},fix:{diagnosticCode:r.diagnostic.code,line:n,title:r.readModel?`Draw the read-model builder before its reader`:`Draw the event producer before its consumer`,scope:`occurrence`,edits:[{path:i.path,start:0,length:v.length,text:a(v,s.node,c.node,o)}]}},f.verify(e,i.path,h,r))break;e=void 0}e===void 0&&i.node.kind===`FileImportSyntax`&&p.node.kind===`FileImportSyntax`&&(e=o(f,r,i,p,t,l)),e!==void 0&&s.push(c.documents===void 0?{...e.fix,edits:e.fix.edits.map(({path:e,...t})=>t)}:e.fix)}}}}return p.size===32&&p.delete(p.keys().next().value),p.set(n,s),s}}export{prepareTimelineQuickFixes};
|
|
2
2
|
//# sourceMappingURL=TimelineQuickFixes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimelineQuickFixes.js","names":["path","options","documents","source","compiled","compileApplication","document","context","TimelineQuickFixContext","cache","line","findings","finding","DiagnosticCodes","candidates","consumer","authoredOrderKey","producer","common","sameAuthoredStep","left","right","entries","first","second","candidate","after","moved","anchor","movedStep","anchorStep","ranks","siblings","replacement","original","moveTimelineText","timelineImportFix","_path","edit"],"sources":["../../../../../../Compiler/Authoring/TimelineQuickFixes.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { authoredOrderKey, sameAuthoredStep } from '../Files/AuthoredOrder';\nimport { compileApplication } from '../Files/PlayApplicationAssembly';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { QuickFix, QuickFixOptions } from './QuickFixes';\nimport { QuickFixCandidate } from './QuickFixCandidate';\nimport { TimelineQuickFixContext, moveTimelineText } from './TimelineQuickFixContext';\nimport { timelineImportFix } from './TimelineQuickFixImports';\nimport { SyntaxNode } from '../Syntax/SyntaxNode';\n\n/** Owns one immutable application snapshot. No recipe is derived from diagnostic message text. */\nexport function prepareTimelineQuickFixes(source: string, options: QuickFixOptions): (line: number) => QuickFix[] {\n const path = options.path ?? 'application.play';\n const documents = new Map(options.documents ?? [[path, source]]);\n if (documents.get(path) !== source || (options.documents === undefined && (options.placement?.length ?? 0) > 0)) return () => [];\n const compiled = compileApplication(documents);\n if (!compiled.success || compiled.documents.some(document => document.isPlacementResolved === false)) return () => [];\n const context = new TimelineQuickFixContext(documents, compiled);\n const cache = new Map<number, QuickFix[]>();\n return line => {\n if (cache.has(line)) return cache.get(line)!;\n const findings = context.findings.filter(finding => finding.diagnostic.code === DiagnosticCodes.EventFromLaterSlice && finding.diagnostic.location.path === path && finding.diagnostic.location.line === line);\n const candidates: QuickFix[] = [];\n // Several event references on one line cannot be addressed unambiguously by this line-only API.\n if (findings.length === 1 && !findings[0].ownSubFeature) {\n const finding = findings[0];\n const consumer = context.origins.get(authoredOrderKey(finding.consumerScope));\n const producer = context.origins.get(authoredOrderKey(finding.producerScope));\n if (consumer !== undefined && producer !== undefined) {\n let common = 0;\n while (common < consumer.length && common < producer.length && sameAuthoredStep(consumer[common], producer[common])) common++;\n const left = consumer[common], right = producer[common];\n if (left !== undefined && right !== undefined && left.path === right.path) {\n const entries = context.entries(left.path);\n const first = context.entry(left, entries), second = context.entry(right, entries);\n if (first !== undefined && second !== undefined && first.parent === second.parent && first.member === second.member) {\n let candidate: QuickFixCandidate | undefined;\n if (first.index !== second.index) {\n for (const after of [false, true]) {\n const moved = after ? first : second, anchor = after ? second : first;\n const movedStep = after ? left : right, anchorStep = after ? right : left;\n const ranks = context.move(context.block(movedStep, movedStep.node.kind === 'FileImportSyntax'), context.block(anchorStep, anchorStep.node.kind === 'FileImportSyntax'), after);\n if (ranks === undefined || !context.safe(ranks, finding)) continue;\n const siblings = [...(first.parent as unknown as Record<string, readonly SyntaxNode[]>)[first.member]];\n siblings.splice(moved.index, 1);\n siblings.splice(siblings.indexOf(anchor.node) + (after ? 1 : 0), 0, moved.node);\n const replacement = { ...first.parent, [first.member]: siblings };\n const original = documents.get(left.path)!;\n candidate = { line, change: { node: first.parent, replacement }, fix: {\n diagnosticCode: finding.diagnostic.code, line, title: finding.readModel ? 'Draw the read-model builder before its reader' : 'Draw the event producer before its consumer', scope: 'occurrence',\n edits: [{ path: left.path, start: 0, length: original.length, text: moveTimelineText(original, moved.node, anchor.node, after) }],\n } };\n if (context.verify(candidate, left.path, ranks, finding)) break;\n candidate = undefined;\n }\n }\n if (candidate === undefined && left.node.kind === 'FileImportSyntax' && right.node.kind === 'FileImportSyntax') candidate = timelineImportFix(context, finding, left, right, first, second);\n if (candidate !== undefined) candidates.push(options.documents === undefined ? { ...candidate.fix, edits: candidate.fix.edits.map(({ path: _path, ...edit }) => edit) } : candidate.fix);\n }\n }\n }\n }\n if (cache.size === 32) cache.delete(cache.keys().next().value!);\n cache.set(line, candidates);\n return candidates;\n };\n}\n"],"mappings":"mbAaA,SAAgB,0BAA0B,EAAgB,EAAwD,CAC9G,IAAMA,EAAOC,EAAQ,MAAQ,mBACvBC,EAAY,IAAI,IAAID,EAAQ,WAAa,CAAC,CAACD,EAAMG,CAAM,CAAC,CAAC,EAC/D,GAAID,EAAU,IAAIF,CAAI,IAAMG,GAAWF,EAAQ,YAAc,IAAA,KAAcA,EAAQ,WAAW,QAAU,GAAK,EAAI,UAAa,CAAC,EAC/H,IAAMG,EAAWC,EAAmBH,CAAS,EAC7C,GAAI,CAACE,EAAS,SAAWA,EAAS,UAAU,KAAK,GAAYE,EAAS,sBAAwB,EAAK,EAAG,UAAa,CAAC,EACpH,IAAMC,EAAU,IAAIC,EAAwBN,EAAWE,CAAQ,EACzDK,kBAAQ,IAAI,IAClB,MAAO,IAAQ,CACX,GAAIA,EAAM,IAAIC,CAAI,EAAG,OAAOD,EAAM,IAAIC,CAAI,EAC1C,IAAMC,EAAWJ,EAAQ,SAAS,OAAO,GAAWK,EAAQ,WAAW,OAASC,EAAgB,qBAAuBD,EAAQ,WAAW,SAAS,OAASZ,GAAQY,EAAQ,WAAW,SAAS,OAASF,CAAI,EACvMI,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","context","TimelineQuickFixContext","cache","line","findings","finding","DiagnosticCodes","candidates","consumer","authoredOrderKey","producer","common","sameAuthoredStep","left","right","entries","first","second","candidate","after","moved","anchor","movedStep","anchorStep","ranks","siblings","replacement","original","moveTimelineText","timelineImportFix","_path","edit"],"sources":["../../../../../../Compiler/Authoring/TimelineQuickFixes.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { authoredOrderKey, sameAuthoredStep } from '../Files/AuthoredOrder';\nimport { compileApplication } from '../Files/PlayApplicationAssembly';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { QuickFix, QuickFixOptions } from './QuickFixes';\nimport { QuickFixCandidate } from './QuickFixCandidate';\nimport { TimelineQuickFixContext, moveTimelineText } from './TimelineQuickFixContext';\nimport { timelineImportFix } from './TimelineQuickFixImports';\nimport { SyntaxNode } from '../Syntax/SyntaxNode';\n\n/** Owns one immutable application snapshot. No recipe is derived from diagnostic message text. */\nexport function prepareTimelineQuickFixes(source: string, options: QuickFixOptions): (line: number) => QuickFix[] {\n const path = options.path ?? 'application.play';\n const documents = new Map(options.documents ?? [[path, source]]);\n if (documents.get(path) !== source || (options.documents === undefined && (options.placement?.length ?? 0) > 0)) return () => [];\n const compiled = compileApplication(documents);\n if (!compiled.success || compiled.documents.some(document => document.isPlacementResolved === false)) return () => [];\n const context = new TimelineQuickFixContext(documents, compiled);\n const cache = new Map<number, QuickFix[]>();\n return line => {\n if (cache.has(line)) return cache.get(line)!;\n const findings = context.findings.filter(finding => finding.diagnostic.code === DiagnosticCodes.EventFromLaterSlice && finding.diagnostic.location.path === path && finding.diagnostic.location.line === line);\n const candidates: QuickFix[] = [];\n // Several event references on one line cannot be addressed unambiguously by this line-only API.\n if (findings.length === 1 && !findings[0].ownSubFeature) {\n const finding = findings[0];\n const consumer = context.origins.get(authoredOrderKey(finding.consumerScope));\n const producer = context.origins.get(authoredOrderKey(finding.producerScope));\n if (consumer !== undefined && producer !== undefined) {\n let common = 0;\n while (common < consumer.length && common < producer.length && sameAuthoredStep(consumer[common], producer[common])) common++;\n const left = consumer[common], right = producer[common];\n if (left !== undefined && right !== undefined && left.path === right.path) {\n const entries = context.entries(left.path);\n const first = context.entry(left, entries), second = context.entry(right, entries);\n if (first !== undefined && second !== undefined && first.parent === second.parent && first.member === second.member) {\n let candidate: QuickFixCandidate | undefined;\n if (first.index !== second.index) {\n for (const after of [false, true]) {\n const moved = after ? first : second, anchor = after ? second : first;\n const movedStep = after ? left : right, anchorStep = after ? right : left;\n const ranks = context.move(context.block(movedStep, movedStep.node.kind === 'FileImportSyntax'), context.block(anchorStep, anchorStep.node.kind === 'FileImportSyntax'), after);\n if (ranks === undefined || !context.safe(ranks, finding)) continue;\n const siblings = [...(first.parent as unknown as Record<string, readonly SyntaxNode[]>)[first.member]];\n siblings.splice(moved.index, 1);\n siblings.splice(siblings.indexOf(anchor.node) + (after ? 1 : 0), 0, moved.node);\n const replacement = { ...first.parent, [first.member]: siblings };\n const original = documents.get(left.path)!;\n candidate = { line, change: { node: first.parent, replacement }, fix: {\n diagnosticCode: finding.diagnostic.code, line, title: finding.readModel ? 'Draw the read-model builder before its reader' : 'Draw the event producer before its consumer', scope: 'occurrence',\n edits: [{ path: left.path, start: 0, length: original.length, text: moveTimelineText(original, moved.node, anchor.node, after) }],\n } };\n if (context.verify(candidate, left.path, ranks, finding)) break;\n candidate = undefined;\n }\n }\n if (candidate === undefined && left.node.kind === 'FileImportSyntax' && right.node.kind === 'FileImportSyntax') candidate = timelineImportFix(context, finding, left, right, first, second);\n if (candidate !== undefined) candidates.push(options.documents === undefined ? { ...candidate.fix, edits: candidate.fix.edits.map(({ path: _path, ...edit }) => edit) } : candidate.fix);\n }\n }\n }\n }\n if (cache.size === 32) cache.delete(cache.keys().next().value!);\n cache.set(line, candidates);\n return candidates;\n };\n}\n"],"mappings":"A,mbAaA,SAAgB,0BAA0B,EAAgB,EAAwD,CAC9G,IA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CAAE,EACEnB,EAAQ,OAAOkB,EAAWL,EAAK,KAAMW,EAAOnB,CAAO,EAAG,MAC1D,EAAY,IAAA,EAChB,CAEAa,IAAc,IAAA,IAAaL,EAAK,KAAK,OAAS,oBAAsBC,EAAM,KAAK,OAAS,qBAAoB,EAAYe,EAAkB7B,EAASK,EAASQ,EAAMC,EAAOE,EAAOC,CAAM,GACtLC,IAAc,IAAA,IAAWX,EAAW,KAAKb,EAAQ,YAAc,IAAA,GAAY,CAAE,GAAGwB,EAAU,IAAK,MAAOA,EAAU,IAAI,MAAM,KAAK,CAAE,KAAMY,EAAO,GAAGC,KAAWA,CAAI,CAAE,EAAIb,EAAU,GAAG,CAC3L,CACJ,CACJ,CACJ,CAGA,OAFIhB,EAAM,OAAS,IAAIA,EAAM,OAAOA,EAAM,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,KAAM,EAC9DA,EAAM,IAAIC,EAAMI,CAAU,EACnBA,CACX,CACJ,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeclaredDependencies.js","names":["countedKinds","address","container","left","right","owners","scope","syntax","child","application","module","owner","graph","DependencyGraph","nodes","node","targets","DeclaredDependencyTargets","resolved","target","containers","diagnostics","declarations","edges","buckets","evidence","edge","item","candidates","producer","covering","declaration","candidate","status","prefix","mismatch","index","segment","suggestedTargets","details","DiagnosticCodes","dependency","diagnostic","context"],"sources":["../../../../../../Compiler/Dependencies/DeclaredDependencies.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Diagnostic } from '../Diagnostics/Diagnostic';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { ParserContext } from '../Parsing/ParserContext';\nimport { ApplicationSyntax, DependsOnSyntax, FeatureSyntax } from '../Syntax/Structure';\nimport { DeclaredDependencyTargets } from './DeclaredDependencyTargets';\nimport { DependencyGraph } from './DependencyGraph';\nimport { DependencyEvidence, DependencyNode } from './index';\n\nexport interface DependencyDeclaration {\n readonly syntax: DependsOnSyntax;\n readonly resolved?: string;\n readonly status: 'used' | 'provisional' | 'unused' | 'invalid';\n}\nexport interface DeclaredDependencyEdge {\n readonly evidence: DependencyEvidence;\n readonly status: 'declared' | 'provisional' | 'undeclared';\n readonly coveringDeclarations: readonly DependsOnSyntax[];\n}\nexport interface CheckedDependencyContainer {\n readonly container: DependencyNode;\n readonly location: SourceLocation;\n readonly declarations: readonly DependencyDeclaration[];\n readonly edges: readonly DeclaredDependencyEdge[];\n}\nexport interface DeclaredDependencyReport {\n readonly containers: readonly CheckedDependencyContainer[];\n readonly diagnostics: readonly Diagnostic[];\n}\nconst countedKinds = ['usesFactsFrom', 'reactsTo', 'decidesFrom', 'asks', 'shows'];\nconst contains = (container: string, address: string): boolean => address === container || address.startsWith(container + '.');\nconst ordinal = (left: string, right: string): number => left < right ? -1 : left > right ? 1 : 0;\nconst orderedEvidence = (left: DependencyEvidence, right: DependencyEvidence): number => ordinal(left.location.path ?? '', right.location.path ?? '') || left.location.line - right.location.line || left.location.column - right.location.column || ordinal(left.kind, right.kind) || ordinal(left.consumer.address, right.consumer.address) || ordinal(left.producer.address, right.producer.address) || ordinal(left.role, right.role) || ordinal(left.name, right.name);\n\n/** Independent opt-in inventories; checks explicit reference coupling, never executable identity. */\nexport class DeclaredDependencies {\n static for(application: ApplicationSyntax): DeclaredDependencyReport {\n const owners = new Map<string, { location: SourceLocation; dependencies: DependsOnSyntax[] }>();\n const inventory = (scope: string[], syntax: { location: SourceLocation; dependsOn?: readonly DependsOnSyntax[]; features: readonly FeatureSyntax[] }) => {\n const address = scope.join('.');\n if (!owners.has(address)) owners.set(address, { location: syntax.location, dependencies: [] });\n owners.get(address)!.dependencies.push(...syntax.dependsOn ?? []);\n syntax.features.forEach(child => inventory([...scope, child.name], child));\n };\n application.modules.forEach(module => inventory([module.name], module));\n if (![...owners.values()].some(owner => owner.dependencies.length)) return { containers: [], diagnostics: [] };\n // Both twins use syntax order, not authored import ranks.\n const graph = DependencyGraph.for(application, new Map());\n const nodes = graph.nodes.filter(node => node.kind === 'module' || node.kind === 'feature');\n const targets = DeclaredDependencyTargets.containersOf(application);\n const resolve = (target: string, scope: readonly string[]) => {\n const resolved = DeclaredDependencyTargets.resolve(target, scope, targets).resolved;\n return resolved && [...resolved.scope, resolved.name].join('.');\n };\n const containers: CheckedDependencyContainer[] = [];\n const diagnostics: Diagnostic[] = [];\n const finding = (code: string, severity: Diagnostic['severity'], message: string, location: SourceLocation) => diagnostics.push({ code, severity, message, location });\n for (const container of nodes.filter(node => owners.get(node.address)!.dependencies.length)) {\n const owner = owners.get(container.address)!;\n const declarations = owner.dependencies.map(syntax => {\n const resolved = resolve(syntax.target, container.scope);\n const valid = resolved !== undefined && !contains(container.address, resolved) && !contains(resolved, container.address);\n return { syntax, resolved, status: valid ? 'unused' : 'invalid' } as { syntax: DependsOnSyntax; resolved?: string; status: DependencyDeclaration['status'] };\n });\n const edges: DeclaredDependencyEdge[] = [];\n const buckets = new Map<string, DependencyEvidence[]>();\n for (const evidence of graph.edges.flatMap(edge => edge.evidence).filter(item => countedKinds.includes(item.kind) && contains(container.address, item.consumer.address)).sort(orderedEvidence)) {\n const candidates = [evidence.producer, ...evidence.alternatives].filter(producer => !contains(container.address, producer.address) && !contains(producer.scope.slice(0, -1).join('.'), container.address));\n if (!candidates.length) continue;\n const covering = declarations.filter(declaration => declaration.status !== 'invalid' && candidates.some(candidate => contains(declaration.resolved!, candidate.address)));\n for (const declaration of covering) declaration.status = evidence.ambiguous && declaration.status !== 'used' ? 'provisional' : 'used';\n const status = evidence.ambiguous ? 'provisional' : covering.length ? 'declared' : 'undeclared';\n edges.push({ evidence, status, coveringDeclarations: covering.map(declaration => declaration.syntax) });\n if (status === 'undeclared') {\n const module = evidence.producer.scope[0];\n if (!buckets.has(module)) buckets.set(module, []);\n buckets.get(module)!.push(evidence);\n }\n }\n for (const evidence of buckets.values()) {\n let prefix = evidence[0].producer.scope.slice(0, -1);\n const mismatch = prefix.findIndex((segment, index) => evidence.some(item => index >= item.producer.scope.length - 1 || item.producer.scope[index] !== segment));\n if (mismatch >= 0) prefix = prefix.slice(0, mismatch);\n const target = prefix.join('.');\n const suggestedTargets = contains(container.address, target) || contains(target, container.address)\n ? [...new Set(evidence.map(item => item.producer.scope.slice(0, -1).map((_, index) => item.producer.scope.slice(0, index + 1).join('.'))\n .find(candidate => !contains(container.address, candidate) && !contains(candidate, container.address))!))]\n : [target];\n const details = evidence.map(item => `${item.kind} ${item.role} '${item.name}' at ${item.location.path ?? ''}:${item.location.line}:${item.location.column}`).join('; ');\n finding(DiagnosticCodes.UndeclaredDependency, 'warning', `Container '${container.address}' depends on '${suggestedTargets.join(\"', '\")}' without declaring ${suggestedTargets.length === 1 ? 'it' : 'them'} - evidence: ${details}`, owner.location);\n }\n for (const declaration of declarations) {\n if (declaration.status === 'unused') finding(DiagnosticCodes.UnusedDependencyDeclaration, 'information', `Dependency '${declaration.syntax.target}' on '${container.address}' is not used by any counted explicit reference`, declaration.syntax.location);\n if (declaration.status !== 'invalid' && owners.get(declaration.resolved!)!.dependencies.some(dependency => resolve(dependency.target, declaration.resolved!.split('.')) === container.address)) {\n finding(DiagnosticCodes.MutualDependencyDeclarations, 'information', `Containers '${container.address}' and '${declaration.resolved}' declare each other`, declaration.syntax.location);\n }\n }\n containers.push({ container, location: owner.location, declarations, edges });\n }\n return { containers, diagnostics };\n }\n\n static validate(application: ApplicationSyntax, context: ParserContext): void {\n for (const diagnostic of this.for(application).diagnostics) context[diagnostic.severity === 'warning' ? 'warning' : 'information'](diagnostic.code, diagnostic.message, diagnostic.location);\n }\n}\n"],"mappings":"2PAgCA,MAAMA,EAAe,CAAC,gBAAiB,WAAY,cAAe,OAAQ,OAAO,EAC3E,UAAY,EAAmB,IAA6BC,IAAYC,GAAaD,EAAQ,WAAWC,EAAY,GAAG,EACvH,SAAW,EAAc,IAA0BC,EA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CAAE,CAAC,CAAC,EAC3G,CAACiB,CAAM,EACPoB,EAAUd,EAAS,IAAI,GAAQ,GAAGE,EAAK,KAAK,GAAGA,EAAK,KAAK,IAAIA,EAAK,KAAK,OAAOA,EAAK,SAAS,MAAQ,GAAG,GAAGA,EAAK,SAAS,KAAK,GAAGA,EAAK,SAAS,QAAQ,CAAC,CAAC,KAAK,IAAI,EACvK,QAAQa,EAAgB,qBAAsB,UAAW,cAActC,EAAU,QAAQ,gBAAgBoC,EAAiB,KAAK,MAAM,EAAE,sBAAsBA,EAAiB,SAAW,EAAI,KAAO,OAAO,eAAeC,IAAW5B,EAAM,QAAQ,CACvP,CACA,IAAK,IAAMoB,KAAeT,EAClBS,EAAY,SAAW,UAAU,QAAQS,EAAgB,4BAA6B,cAAe,eAAeT,EAAY,OAAO,OAAO,QAAQ7B,EAAU,QAAQ,iDAAkD6B,EAAY,OAAO,QAAQ,EACrPA,EAAY,SAAW,WAAa1B,EAAO,IAAI0B,EAAY,QAAS,CAAC,CAAE,aAAa,KAAK,GAAc,QAAQU,EAAW,OAAQV,EAAY,SAAU,MAAM,GAAG,CAAC,IAAM7B,EAAU,OAAO,GACzL,QAAQsC,EAAgB,6BAA8B,cAAe,eAAetC,EAAU,QAAQ,SAAS6B,EAAY,SAAS,sBAAuBA,EAAY,OAAO,QAAQ,EAG9LX,EAAW,KAAK,CAAE,YAAW,SAAUT,EAAM,SAAU,eAAc,OAAM,CAAC,CAChF,CACA,MAAO,CAAE,aAAY,aAAY,CACrC,CAEA,OAAO,SAAS,EAAgC,EAA8B,CAC1E,IAAK,IAAM+B,KAAc,KAAK,IAAIjC,CAAW,CAAC,CAAC,YAAakC,EAAQD,EAAW,WAAa,UAAY,UAAY,cAAc,CAACA,EAAW,KAAMA,EAAW,QAASA,EAAW,QAAQ,CAC/L,CACJ"}
|
|
1
|
+
{"version":3,"file":"DeclaredDependencies.js","names":["countedKinds","address","container","left","right","owners","scope","syntax","child","application","module","owner","graph","DependencyGraph","nodes","node","targets","DeclaredDependencyTargets","resolved","target","containers","diagnostics","declarations","edges","buckets","evidence","edge","item","candidates","producer","covering","declaration","candidate","status","prefix","mismatch","index","segment","suggestedTargets","details","DiagnosticCodes","dependency","diagnostic","context"],"sources":["../../../../../../Compiler/Dependencies/DeclaredDependencies.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Diagnostic } from '../Diagnostics/Diagnostic';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { ParserContext } from '../Parsing/ParserContext';\nimport { ApplicationSyntax, DependsOnSyntax, FeatureSyntax } from '../Syntax/Structure';\nimport { DeclaredDependencyTargets } from './DeclaredDependencyTargets';\nimport { DependencyGraph } from './DependencyGraph';\nimport { DependencyEvidence, DependencyNode } from './index';\n\nexport interface DependencyDeclaration {\n readonly syntax: DependsOnSyntax;\n readonly resolved?: string;\n readonly status: 'used' | 'provisional' | 'unused' | 'invalid';\n}\nexport interface DeclaredDependencyEdge {\n readonly evidence: DependencyEvidence;\n readonly status: 'declared' | 'provisional' | 'undeclared';\n readonly coveringDeclarations: readonly DependsOnSyntax[];\n}\nexport interface CheckedDependencyContainer {\n readonly container: DependencyNode;\n readonly location: SourceLocation;\n readonly declarations: readonly DependencyDeclaration[];\n readonly edges: readonly DeclaredDependencyEdge[];\n}\nexport interface DeclaredDependencyReport {\n readonly containers: readonly CheckedDependencyContainer[];\n readonly diagnostics: readonly Diagnostic[];\n}\nconst countedKinds = ['usesFactsFrom', 'reactsTo', 'decidesFrom', 'asks', 'shows'];\nconst contains = (container: string, address: string): boolean => address === container || address.startsWith(container + '.');\nconst ordinal = (left: string, right: string): number => left < right ? -1 : left > right ? 1 : 0;\nconst orderedEvidence = (left: DependencyEvidence, right: DependencyEvidence): number => ordinal(left.location.path ?? '', right.location.path ?? '') || left.location.line - right.location.line || left.location.column - right.location.column || ordinal(left.kind, right.kind) || ordinal(left.consumer.address, right.consumer.address) || ordinal(left.producer.address, right.producer.address) || ordinal(left.role, right.role) || ordinal(left.name, right.name);\n\n/** Independent opt-in inventories; checks explicit reference coupling, never executable identity. */\nexport class DeclaredDependencies {\n static for(application: ApplicationSyntax): DeclaredDependencyReport {\n const owners = new Map<string, { location: SourceLocation; dependencies: DependsOnSyntax[] }>();\n const inventory = (scope: string[], syntax: { location: SourceLocation; dependsOn?: readonly DependsOnSyntax[]; features: readonly FeatureSyntax[] }) => {\n const address = scope.join('.');\n if (!owners.has(address)) owners.set(address, { location: syntax.location, dependencies: [] });\n owners.get(address)!.dependencies.push(...syntax.dependsOn ?? []);\n syntax.features.forEach(child => inventory([...scope, child.name], child));\n };\n application.modules.forEach(module => inventory([module.name], module));\n if (![...owners.values()].some(owner => owner.dependencies.length)) return { containers: [], diagnostics: [] };\n // Both twins use syntax order, not authored import ranks.\n const graph = DependencyGraph.for(application, new Map());\n const nodes = graph.nodes.filter(node => node.kind === 'module' || node.kind === 'feature');\n const targets = DeclaredDependencyTargets.containersOf(application);\n const resolve = (target: string, scope: readonly string[]) => {\n const resolved = DeclaredDependencyTargets.resolve(target, scope, targets).resolved;\n return resolved && [...resolved.scope, resolved.name].join('.');\n };\n const containers: CheckedDependencyContainer[] = [];\n const diagnostics: Diagnostic[] = [];\n const finding = (code: string, severity: Diagnostic['severity'], message: string, location: SourceLocation) => diagnostics.push({ code, severity, message, location });\n for (const container of nodes.filter(node => owners.get(node.address)!.dependencies.length)) {\n const owner = owners.get(container.address)!;\n const declarations = owner.dependencies.map(syntax => {\n const resolved = resolve(syntax.target, container.scope);\n const valid = resolved !== undefined && !contains(container.address, resolved) && !contains(resolved, container.address);\n return { syntax, resolved, status: valid ? 'unused' : 'invalid' } as { syntax: DependsOnSyntax; resolved?: string; status: DependencyDeclaration['status'] };\n });\n const edges: DeclaredDependencyEdge[] = [];\n const buckets = new Map<string, DependencyEvidence[]>();\n for (const evidence of graph.edges.flatMap(edge => edge.evidence).filter(item => countedKinds.includes(item.kind) && contains(container.address, item.consumer.address)).sort(orderedEvidence)) {\n const candidates = [evidence.producer, ...evidence.alternatives].filter(producer => !contains(container.address, producer.address) && !contains(producer.scope.slice(0, -1).join('.'), container.address));\n if (!candidates.length) continue;\n const covering = declarations.filter(declaration => declaration.status !== 'invalid' && candidates.some(candidate => contains(declaration.resolved!, candidate.address)));\n for (const declaration of covering) declaration.status = evidence.ambiguous && declaration.status !== 'used' ? 'provisional' : 'used';\n const status = evidence.ambiguous ? 'provisional' : covering.length ? 'declared' : 'undeclared';\n edges.push({ evidence, status, coveringDeclarations: covering.map(declaration => declaration.syntax) });\n if (status === 'undeclared') {\n const module = evidence.producer.scope[0];\n if (!buckets.has(module)) buckets.set(module, []);\n buckets.get(module)!.push(evidence);\n }\n }\n for (const evidence of buckets.values()) {\n let prefix = evidence[0].producer.scope.slice(0, -1);\n const mismatch = prefix.findIndex((segment, index) => evidence.some(item => index >= item.producer.scope.length - 1 || item.producer.scope[index] !== segment));\n if (mismatch >= 0) prefix = prefix.slice(0, mismatch);\n const target = prefix.join('.');\n const suggestedTargets = contains(container.address, target) || contains(target, container.address)\n ? [...new Set(evidence.map(item => item.producer.scope.slice(0, -1).map((_, index) => item.producer.scope.slice(0, index + 1).join('.'))\n .find(candidate => !contains(container.address, candidate) && !contains(candidate, container.address))!))]\n : [target];\n const details = evidence.map(item => `${item.kind} ${item.role} '${item.name}' at ${item.location.path ?? ''}:${item.location.line}:${item.location.column}`).join('; ');\n finding(DiagnosticCodes.UndeclaredDependency, 'warning', `Container '${container.address}' depends on '${suggestedTargets.join(\"', '\")}' without declaring ${suggestedTargets.length === 1 ? 'it' : 'them'} - evidence: ${details}`, owner.location);\n }\n for (const declaration of declarations) {\n if (declaration.status === 'unused') finding(DiagnosticCodes.UnusedDependencyDeclaration, 'information', `Dependency '${declaration.syntax.target}' on '${container.address}' is not used by any counted explicit reference`, declaration.syntax.location);\n if (declaration.status !== 'invalid' && owners.get(declaration.resolved!)!.dependencies.some(dependency => resolve(dependency.target, declaration.resolved!.split('.')) === container.address)) {\n finding(DiagnosticCodes.MutualDependencyDeclarations, 'information', `Containers '${container.address}' and '${declaration.resolved}' declare each other`, declaration.syntax.location);\n }\n }\n containers.push({ container, location: owner.location, declarations, edges });\n }\n return { containers, diagnostics };\n }\n\n static validate(application: ApplicationSyntax, context: ParserContext): void {\n for (const diagnostic of this.for(application).diagnostics) context[diagnostic.severity === 'warning' ? 'warning' : 'information'](diagnostic.code, diagnostic.message, diagnostic.location);\n }\n}\n"],"mappings":"A,2PAgCA,MAAMA,EAAe,CAAC,gBAAiB,WAAY,cAAe,OAAQ,OAAO,EAC3E,UAAY,EAAmB,IAA6BC,IAAYC,GAAaD,EAAQ,WAAWC,EAAY,GAAG,EACvH,SAAW,EAAc,IAA0BC,EAAOC,EAAQ,GAAK,IAAOA,GAC9E,iBAAmB,EAA0B,IAAsC,QAAQD,EAAK,SAAS,MAAQ,GAAIC,EAAM,SAAS,MAAQ,EAAE,GAAKD,EAAK,SAAS,KAAOC,EAAM,SAAS,MAAQD,EAAK,SAAS,OAASC,EAAM,SAAS,QAAU,QAAQD,EAAK,KAAMC,EAAM,IAAI,GAAK,QAAQD,EAAK,SAAS,QAASC,EAAM,SAAS,OAAO,GAAK,QAAQD,EAAK,SAAS,QAASC,EAAM,SAAS,OAAO,GAAK,QAAQD,EAAK,KAAMC,EAAM,IAAI,GAAK,QAAQD,EAAK,KAAMC,EAAM,IAAI,EAG1c,IAAa,qBAAb,KAAkC,CAC9B,OAAO,IAAI,EAA0D,CACjE,IAAMC,kBAAS,IAAI,IACb,WAAa,EAAiB,IAAqH,CACrJ,IAAMJ,EAAUK,EAAM,KAAK,GAAG,EACzBD,EAAO,IAAIJ,CAAO,GAAGI,EAAO,IAAIJ,EAAS,CAAE,SAAUM,EAAO,SAAU,aAAc,CAAC,CAAE,CAAC,EAC7FF,EAAO,IAAIJ,CAAO,CAAC,CAAE,aAAa,KAAK,GAAGM,EA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GACzL,QAAQsC,EAAgB,6BAA8B,cAAe,eAAetC,EAAU,QAAQ,SAAS6B,EAAY,SAAS,sBAAuBA,EAAY,OAAO,QAAQ,EAG9LX,EAAW,KAAK,CAAE,YAAW,SAAUT,EAAM,SAAU,eAAc,OAAM,CAAC,CAChF,CACA,MAAO,CAAE,aAAY,aAAY,CACrC,CAEA,OAAO,SAAS,EAAgC,EAA8B,CAC1E,IAAK,IAAM+B,KAAc,KAAK,IAAIjC,CAAW,CAAC,CAAC,YAAakC,EAAQD,EAAW,WAAa,UAAY,UAAY,cAAc,CAACA,EAAW,KAAMA,EAAW,QAASA,EAAW,QAAQ,CAC/L,CACJ,E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeclaredDependencyTargets.js","names":["left","right","segment","index","container","containers","feature","parent","child","module","application","owner","from","address","parts","length","reference","segments","matches","depth","seenByOwner","kept","seen","dependency","dependencies","resolution","target","key","context","DiagnosticCodes"],"sources":["../../../../../../Compiler/Dependencies/DeclaredDependencyTargets.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { ParserContext } from '../Parsing/ParserContext';\nimport { ApplicationSyntax, DependsOnSyntax, FeatureSyntax } from '../Syntax/Structure';\n\nexport interface DependencyContainer {\n readonly name: string;\n readonly scope: readonly string[];\n}\n\nconst same = (left: readonly string[], right: readonly string[]) => left.length === right.length && left.every((segment, index) => segment === right[index]);\nconst addressOf = (container: DependencyContainer) => [...container.scope, container.name].join('.');\n\n// Children sets only: siblings, ancestors' siblings, then root modules. Dotted references match suffixes.\nexport class DeclaredDependencyTargets {\n static containersOf(application: ApplicationSyntax): DependencyContainer[] {\n const containers: DependencyContainer[] = [];\n const inventory = (feature: FeatureSyntax, parent: readonly string[]): void => {\n containers.push({ name: feature.name, scope: parent });\n feature.features.forEach(child => inventory(child, [...parent, feature.name]));\n };\n for (const module of application.modules) {\n containers.push({ name: module.name, scope: [] });\n module.features.forEach(feature => inventory(feature, [module.name]));\n }\n return [...new Map(containers.map(container => [addressOf(container), container])).values()];\n }\n\n static candidates(from: readonly string[], containers: readonly DependencyContainer[]): { container: DependencyContainer; reference: string; tier: number | 'qualified' }[] {\n const owner = from.join('.');\n return containers.flatMap(container => {\n const address = addressOf(container);\n if (address === owner || address.startsWith(owner + '.') || owner.startsWith(address + '.')) return [];\n const parts = [...container.scope, container.name];\n for (let length = 1; length <= parts.length; length++) {\n const reference = parts.slice(-length).join('.');\n if (this.resolve(reference, from, containers).resolved !== container) continue;\n const tier: number | 'qualified' = length === 1 ? from.length - 1 - container.scope.length : 'qualified';\n return [{ container, reference, tier }];\n }\n return [];\n }).sort((left, right) => (left.tier === 'qualified' ? from.length : left.tier) - (right.tier === 'qualified' ? from.length : right.tier));\n }\n\n static resolve(reference: string, from: readonly string[], containers: readonly DependencyContainer[]): { resolved?: DependencyContainer; ambiguous: readonly DependencyContainer[] } {\n const segments = reference.split('.');\n if (segments.length > 1) {\n const matches = containers.filter(container => same([...container.scope, container.name].slice(-segments.length), segments));\n return matches.length === 1 ? { resolved: matches[0], ambiguous: [] } : { ambiguous: matches };\n }\n for (let depth = from.length - 1; depth >= 0; depth--) {\n const matches = containers.filter(container => container.name === reference && same(container.scope, from.slice(0, depth)));\n if (matches.length > 0) return matches.length === 1 ? { resolved: matches[0], ambiguous: [] } : { ambiguous: matches };\n }\n return { ambiguous: [] };\n }\n}\n\nexport function validateDependencyDeclarations(application: ApplicationSyntax, context: ParserContext): ApplicationSyntax {\n const hasDependencies = (container: { dependsOn?: readonly DependsOnSyntax[]; features: readonly FeatureSyntax[] }): boolean =>\n (container.dependsOn?.length ?? 0) > 0 || container.features.some(hasDependencies);\n if (!application.modules.some(hasDependencies)) return application;\n const containers = DeclaredDependencyTargets.containersOf(application);\n\n const seenByOwner = new Map<string, Set<string>>();\n const keep = (dependencies: readonly DependsOnSyntax[], from: readonly string[]): DependsOnSyntax[] => {\n const kept: DependsOnSyntax[] = [];\n const owner = from.join('.');\n if (!seenByOwner.has(owner)) seenByOwner.set(owner, new Set());\n const seen = seenByOwner.get(owner)!;\n for (const dependency of dependencies) {\n const resolution = DeclaredDependencyTargets.resolve(dependency.target, from, containers);\n const target = resolution.resolved === undefined ? undefined : addressOf(resolution.resolved);\n const key = target === undefined ? `text:${dependency.target}` : `resolved:${target}`;\n if (seen.has(key)) {\n context.warning(DiagnosticCodes.RepeatedDependencyDeclaration, `Dependency '${dependency.target}' is already declared on this container - this repeated declaration is ignored`, dependency.location);\n continue;\n }\n seen.add(key);\n kept.push(dependency);\n if (resolution.ambiguous.length > 0) {\n context.warning(DiagnosticCodes.AmbiguousReference, `Ambiguous dependency target '${dependency.target}' - candidates: ${resolution.ambiguous.map(addressOf).join(', ')}`, dependency.location);\n } else if (target === undefined || target === owner || target.startsWith(owner + '.') || owner.startsWith(target + '.')) {\n context.warning(DiagnosticCodes.InvalidDependencyTarget, `Invalid dependency target '${dependency.target}' on '${owner}' - the target must resolve to another module or feature, not self, an ancestor, or a descendant`, dependency.location);\n }\n }\n return kept;\n };\n const normalize = (feature: FeatureSyntax, parent: readonly string[]): FeatureSyntax => {\n const address = [...parent, feature.name];\n return { ...feature, dependsOn: keep(feature.dependsOn ?? [], address), features: feature.features.map(child => normalize(child, address)) };\n };\n return { ...application, modules: application.modules.map(module => ({ ...module, dependsOn: keep(module.dependsOn ?? [], [module.name]), features: module.features.map(feature => normalize(feature, [module.name])) })) };\n}\n"],"mappings":"yHAYA,MAAM,MAAQ,EAAyB,IAA6BA,EAAK,SAAWC,EAAM,QAAUD,EAAK,OAAO,EAAS,IAAUE,IAAYD,EAAME,EAAM,EACrJ,UAAa,GAAmC,CAAC,GAAGC,EAAU,MAAOA,EAAU,IAAI,CAAC,CAAC,KAAK,GAAG,EAGnG,IAAa,0BAAb,KAAuC,CACnC,OAAO,aAAa,EAAuD,CACvE,IAAMC,EAAoC,CAAC,EACr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eclaredDependencyTargets.js","names":["left","right","segment","index","container","containers","feature","parent","child","module","application","owner","from","address","parts","length","reference","segments","matches","depth","seenByOwner","kept","seen","dependency","dependencies","resolution","target","key","context","DiagnosticCodes"],"sources":["../../../../../../Compiler/Dependencies/DeclaredDependencyTargets.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { ParserContext } from '../Parsing/ParserContext';\nimport { ApplicationSyntax, DependsOnSyntax, FeatureSyntax } from '../Syntax/Structure';\n\nexport interface DependencyContainer {\n readonly name: string;\n readonly scope: readonly string[];\n}\n\nconst same = (left: readonly string[], right: readonly string[]) => left.length === right.length && left.every((segment, index) => segment === right[index]);\nconst addressOf = (container: DependencyContainer) => [...container.scope, container.name].join('.');\n\n// Children sets only: siblings, ancestors' siblings, then root modules. Dotted references match suffixes.\nexport class DeclaredDependencyTargets {\n static containersOf(application: ApplicationSyntax): DependencyContainer[] {\n const containers: DependencyContainer[] = [];\n const inventory = (feature: FeatureSyntax, parent: readonly string[]): void => {\n containers.push({ name: feature.name, scope: parent });\n feature.features.forEach(child => inventory(child, [...parent, feature.name]));\n };\n for (const module of application.modules) {\n containers.push({ name: module.name, scope: [] });\n module.features.forEach(feature => inventory(feature, [module.name]));\n }\n return [...new Map(containers.map(container => [addressOf(container), container])).values()];\n }\n\n static candidates(from: readonly string[], containers: readonly DependencyContainer[]): { container: DependencyContainer; reference: string; tier: number | 'qualified' }[] {\n const owner = from.join('.');\n return containers.flatMap(container => {\n const address = addressOf(container);\n if (address === owner || address.startsWith(owner + '.') || owner.startsWith(address + '.')) return [];\n const parts = [...container.scope, container.name];\n for (let length = 1; length <= parts.length; length++) {\n const reference = parts.slice(-length).join('.');\n if (this.resolve(reference, from, containers).resolved !== container) continue;\n const tier: number | 'qualified' = length === 1 ? from.length - 1 - container.scope.length : 'qualified';\n return [{ container, reference, tier }];\n }\n return [];\n }).sort((left, right) => (left.tier === 'qualified' ? from.length : left.tier) - (right.tier === 'qualified' ? from.length : right.tier));\n }\n\n static resolve(reference: string, from: readonly string[], containers: readonly DependencyContainer[]): { resolved?: DependencyContainer; ambiguous: readonly DependencyContainer[] } {\n const segments = reference.split('.');\n if (segments.length > 1) {\n const matches = containers.filter(container => same([...container.scope, container.name].slice(-segments.length), segments));\n return matches.length === 1 ? { resolved: matches[0], ambiguous: [] } : { ambiguous: matches };\n }\n for (let depth = from.length - 1; depth >= 0; depth--) {\n const matches = containers.filter(container => container.name === reference && same(container.scope, from.slice(0, depth)));\n if (matches.length > 0) return matches.length === 1 ? { resolved: matches[0], ambiguous: [] } : { ambiguous: matches };\n }\n return { ambiguous: [] };\n }\n}\n\nexport function validateDependencyDeclarations(application: ApplicationSyntax, context: ParserContext): ApplicationSyntax {\n const hasDependencies = (container: { dependsOn?: readonly DependsOnSyntax[]; features: readonly FeatureSyntax[] }): boolean =>\n (container.dependsOn?.length ?? 0) > 0 || container.features.some(hasDependencies);\n if (!application.modules.some(hasDependencies)) return application;\n const containers = DeclaredDependencyTargets.containersOf(application);\n\n const seenByOwner = new Map<string, Set<string>>();\n const keep = (dependencies: readonly DependsOnSyntax[], from: readonly string[]): DependsOnSyntax[] => {\n const kept: DependsOnSyntax[] = [];\n const owner = from.join('.');\n if (!seenByOwner.has(owner)) seenByOwner.set(owner, new Set());\n const seen = seenByOwner.get(owner)!;\n for (const dependency of dependencies) {\n const resolution = DeclaredDependencyTargets.resolve(dependency.target, from, containers);\n const target = resolution.resolved === undefined ? undefined : addressOf(resolution.resolved);\n const key = target === undefined ? `text:${dependency.target}` : `resolved:${target}`;\n if (seen.has(key)) {\n context.warning(DiagnosticCodes.RepeatedDependencyDeclaration, `Dependency '${dependency.target}' is already declared on this container - this repeated declaration is ignored`, dependency.location);\n continue;\n }\n seen.add(key);\n kept.push(dependency);\n if (resolution.ambiguous.length > 0) {\n context.warning(DiagnosticCodes.AmbiguousReference, `Ambiguous dependency target '${dependency.target}' - candidates: ${resolution.ambiguous.map(addressOf).join(', ')}`, dependency.location);\n } else if (target === undefined || target === owner || target.startsWith(owner + '.') || owner.startsWith(target + '.')) {\n context.warning(DiagnosticCodes.InvalidDependencyTarget, `Invalid dependency target '${dependency.target}' on '${owner}' - the target must resolve to another module or feature, not self, an ancestor, or a descendant`, dependency.location);\n }\n }\n return kept;\n };\n const normalize = (feature: FeatureSyntax, parent: readonly string[]): FeatureSyntax => {\n const address = [...parent, feature.name];\n return { ...feature, dependsOn: keep(feature.dependsOn ?? [], address), features: feature.features.map(child => normalize(child, address)) };\n };\n return { ...application, modules: application.modules.map(module => ({ ...module, dependsOn: keep(module.dependsOn ?? [], [module.name]), features: module.features.map(feature => normalize(feature, [module.name])) })) };\n}\n"],"mappings":"A,yHAYA,MAAM,MAAQ,EAAyB,IAA6BA,EAAK,SAAWC,EAAM,QAAUD,EAAK,OAAO,EAAS,IAAUE,IAAYD,EAAME,EAAM,EACrJ,UAAa,GAAmC,CAAC,GAAGC,EAAU,MAAOA,EAAU,IAAI,CAAC,CAAC,KAAK,GAAG,EAGnG,IAAa,0BAAb,KAAuC,CACnC,OAAO,aAAa,EAAuD,CACvE,IAAMC,EAAoC,CAAC,EACrC,WAAa,EAAwB,IAAoC,CAC3EA,EAAW,KAAK,CAAE,KAAMC,EAAQ,KAAM,MAAOC,CAAO,CAAC,EACrDD,EAAQ,SAAS,QAAQ,GAAS,UAAUE,EAAO,CAAC,GAAGD,EAAQD,EAAQ,IAAI,CAAC,CAAC,CACjF,EACA,IAAK,IAAMG,KAAUC,EAAY,QAC7BL,EAAW,KAAK,CAAE,KAAMI,EAAO,KAAM,MAAO,CAAC,CAAE,CAAC,EAChDA,EAAO,SAAS,QAAQ,GAAW,UAAUH,EAAS,CAACG,EAAO,IAAI,CAAC,CAAC,EAExE,MAAO,CAAC,GAAG,IAAI,IAAIJ,EAAW,IAAI,GAAa,CAAC,UAAUD,CAAS,EAAGA,CAAS,CAAC,C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AAC,CAAC,KAAK,IAAI,IAAKF,EAAW,QAAQ,GACtLG,IAAW,IAAA,IAAaA,IAAWf,GAASe,EAAO,WAAWf,EAAQ,GAAG,GAAKA,EAAM,WAAWe,EAAS,GAAG,IAClHE,EAAQ,QAAQC,EAAgB,wBAAyB,8BAA8BN,EAAW,OAAO,QAAQZ,EAAM,kGAAmGY,EAAW,QAAQ,EAErP,CACA,OAAOF,CACX,EACM,WAAa,EAAwB,IAA6C,CACpF,IAAMR,EAAU,CAAC,GAAGN,EAAQD,EAAQ,IAAI,EACxC,MAAO,CAAE,GAAGA,EAAS,UAAW,KAAKA,EAAQ,WAAa,CAAC,EAAGO,CAAO,EAAG,SAAUP,EAAQ,SAAS,IAAI,GAAS,UAAUE,EAAOK,CAAO,CAAC,CAAE,CAC/I,EACA,MAAO,CAAE,GAAGH,EAAa,QAASA,EAAY,QAAQ,IAAI,IAAW,CAAE,GAAGD,EAAQ,UAAW,KAAKA,EAAO,WAAa,CAAC,EAAG,CAACA,EAAO,IAAI,CAAC,EAAG,SAAUA,EAAO,SAAS,IAAI,GAAW,UAAUH,EAAS,CAACG,EAAO,IAAI,CAAC,CAAC,CAAE,EAAE,CAAE,CAC9N,C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../_virtual/_virtual/_rolldown/runtime.js";import{eventDeclarations as e}from"../Syntax/EventDeclarations.js";import{dependencySourcesOf as t}from"../Syntax/DependencySources.js";import{expandSpecificationExamples as n}from"../Parsing/SpecificationCommandExamples.js";import{authoredOrderKey as r,authoredOrderOf as i}from"../Files/AuthoredOrder.js";import{dependencyKinds as a}from"./DependencyKind.js";import{InvalidDependencyQuery as o}from"./InvalidDependencyQuery.js";import{sliceReferences as s}from"./SliceReferences.js";import{stronglyConnectedGroups as c}from"./StronglyConnectedGroups.js";const l=[`usesFactsFrom`,`reactsTo`,`decidesFrom`],ordinal=(e,t)=>e<t?-1:+(e>t),declarationKey=(e,t)=>JSON.stringify([e,t.toLowerCase()]),nodeOf=(e,t,n,r)=>({kind:e,address:t,scope:n,rank:r,key:`${e}:${t}`}),compareNodes=(e,t)=>e.rank-t.rank||ordinal(e.key,t.key),distinctNodes=e=>[...new Map([...e].map(e=>[e.key,e])).values()].sort(compareNodes),compareEvidence=(e,t)=>e.consumer.rank-t.consumer.rank||e.location.line-t.location.line||e.location.column-t.location.column||a.indexOf(e.kind)-a.indexOf(t.kind)||e.producer.rank-t.producer.rank||ordinal(e.location.path??``,t.location.path??``)||ordinal(e.role,t.role)||ordinal(e.name,t.name);function variants(e){return e.flatMap(e=>e.kind===`ProjectionVariantSyntax`?[e,...variants(e.blocks)]:e.kind===`ChildrenSyntax`||e.kind===`NestedSyntax`?variants(e.blocks):[])}var u=class DependencyGraph{orderSource;edges;unresolved;excludedReferences;unusedImports;modelNodes=[];slices=[];children=/* @__PURE__ */ new Map;byKey=/* @__PURE__ */ new Map;parents=/* @__PURE__ */ new Map;root=nodeOf(`application`,``,[],-1);static for(e,t=i(e)){return new DependencyGraph(e,t)}get nodes(){return this.modelNodes}constructor(i,o){i=n(i),this.orderSource=o.size>0?`authored`:`syntax`,this.children.set(this.root.key,[]);let ordered=(e,t)=>e.map((e,n)=>({syntax:e,index:n,rank:o.get(r([...t.scope,e.name]))??2**53-1})).sort((e,t)=>e.rank-t.rank||e.index-t.index).map(e=>e.syntax),feature=(e,t)=>{let n=this.add(`feature`,e.name,t);for(let t of ordered(e.slices,n))this.slices.push({node:this.add(`slice`,t.name,n),syntax:t});for(let t of ordered(e.features,n))feature(t,n)};for(let e of ordered(i.modules,this.root)){let t=this.add(`module`,e.name,this.root);for(let n of ordered(e.features,t))feature(n,t)}let c=this.projectionEventTargets(),l=/* @__PURE__ */ new Map,u=/* @__PURE__ */ new Map,declare=(e,t,n,r)=>{let i=declarationKey(t,n);e.has(i)||e.set(i,[]);let a=e.get(i);a.includes(r)||a.push(r);let o=declarationKey(t,[...r.scope,n].join(`.`));e.has(o)||e.set(o,[]);let s=e.get(o);s.includes(r)||s.push(r)};for(let{node:n,syntax:r}of this.slices){for(let t of e(r))declare(l,`Event`,t.name,n);for(let e of r.commands)declare(l,`Command`,e.name,n);for(let e of r.reactions)declare(l,`Reaction`,e.name,n);for(let e of r.queries)declare(l,`Query`,e.name,n);for(let e of r.screens)declare(l,`Screen`,e.name,n);for(let e of r.readModels)declare(l,`ReadModel`,e.name,n);for(let e of this.projectionReadModels(r,n,c))declare(u,`ReadModel`,e,n);for(let e of t(r).reducers??[])declare(u,`ReadModel`,e.readModel,n)}let d=new Set((i.declaredTriggers??[]).map(e=>e.name.toLowerCase())),f=new Set([...i.concepts,...i.types].map(e=>e.name.toLowerCase())),p=new Set((i.policies??[]).map(e=>e.name.toLowerCase())),m=i.imports.filter(e=>e.qualifiedName.includes(`.`)).slice().sort((e,t)=>ordinal(e.location.path??``,t.location.path??``)||e.location.line-t.location.line||e.location.column-t.location.column||ordinal(e.qualifiedName,t.qualifiedName)),h=/* @__PURE__ */ new Map,g=[],_=[],v=/* @__PURE__ */ new Set,y=0;for(let{node:e,syntax:t}of this.slices){let n=s(t);y+=n.shared.filter(e=>(e.kind===`type`?f:p).has(e.name.toLowerCase())).length;for(let t of n.references){let n=declarationKey(t.targetKind,t.name),r=(t.targetKind===`ReadModel`&&u.has(n)?u:l).get(n);if(r!==void 0&&r.length>0){let n=r[0];n!==e&&g.push({consumer:e,producer:n,kind:t.kind,role:t.role,name:t.name,ambiguous:r.length>1,alternatives:r.slice(1),location:t.location,testOnly:t.kind===`verifiedWith`});continue}let i=t.targetKind===`Event`?m.filter(e=>e.qualifiedName.slice(e.qualifiedName.lastIndexOf(`.`)+1).toLowerCase()===t.name.toLowerCase()):[];if(i.length>0){let n=[];for(let e of i){v.add(e.qualifiedName);let t=e.qualifiedName.slice(0,e.qualifiedName.lastIndexOf(`.`)),r=`context:${t}`;if(!h.has(r)){let e=nodeOf(`context`,r,[t],this.modelNodes.length);this.modelNodes.push(e),h.set(r,e)}let i=h.get(r);n.includes(i)||n.push(i)}g.push({consumer:e,producer:n[0],kind:`outsideTheModel`,role:t.role,name:t.name,ambiguous:n.length>1,alternatives:n.slice(1),location:t.location,testOnly:t.kind===`verifiedWith`})}else t.role===`trigger`&&d.has(t.name.toLowerCase())?y++:_.push({consumer:e,kind:t.kind,role:t.role,name:t.name,location:t.location})}}let b=/* @__PURE__ */ new Map;for(let e of g.sort(compareEvidence)){let t=JSON.stringify([e.consumer.key,e.producer.key,e.kind]);b.has(t)||b.set(t,[]),b.get(t).push(e)}this.edges=[...b.values()].map(e=>({consumer:e[0].consumer,producer:e[0].producer,kind:e[0].kind,evidence:e})),this.unresolved=_.sort((e,t)=>e.consumer.rank-t.consumer.rank||e.location.line-t.location.line||e.location.column-t.location.column||a.indexOf(e.kind)-a.indexOf(t.kind)||ordinal(e.location.path??``,t.location.path??``)||ordinal(e.name,t.name)),this.excludedReferences=y,this.unusedImports=[...new Set(m.filter(e=>!v.has(e.qualifiedName)).map(e=>e.qualifiedName))]}implied(e,t,n,r=!1,i=3){if(![`slice`,`feature`,`module`].includes(e))throw new o(`Unsupported source level '${e}'.`);if(![`slice`,`feature`,`module`,`context`].includes(t))throw new o(`Unsupported target level '${t}'.`);if(i<0)throw new o(`Evidence limit must not be negative.`);let s=/* @__PURE__ */ new Map;for(let i of this.evidence(n,r))for(let n of this.at(i.consumer,e))for(let e of this.at(i.producer,t).filter(e=>this.disjoint(n,e))){let t=JSON.stringify([n.key,e.key]);s.has(t)||s.set(t,{source:n,target:e,evidence:[]}),s.get(t).evidence.push(i)}return[...s.values()].sort((e,t)=>e.source.rank-t.source.rank||e.target.rank-t.target.rank||ordinal(e.source.key,t.source.key)||ordinal(e.target.key,t.target.key)).map(e=>{let t=e.evidence.sort(compareEvidence),n={};for(let e of a){let r=t.filter(t=>t.kind===e).length;r>0&&(n[e]=r)}return{source:e.source,target:e.target,sliceEdges:new Set(t.map(e=>JSON.stringify([e.consumer.key,e.producer.key]))).size,references:t.length,byKind:n,consumers:distinctNodes(t.map(e=>e.consumer)),producers:distinctNodes(t.map(e=>e.producer)),evidence:t.slice(0,i),evidenceCount:t.length,evidenceTruncated:t.length>i}})}cycles(e,t){if(![`slice`,`feature`,`module`].includes(e))throw new o(`Unsupported cycle level '${e}'.`);let n=this.implied(e,e,selectedOrderingKinds(t)),r=distinctNodes(n.flatMap(e=>[e.source,e.target]));return groupsOf(adjacency(r,n),r,null)}siblingGroups(e){let t=this.siblingEdges(e);return this.containers().flatMap(e=>{let n=this.children.get(e.key);return groupsOf(adjacency(n,t.filter(t=>t.container===e)),n,e)})}suggestedOrder(e){let t=this.siblingEdges(e),n=[];for(let e of this.containers()){let r=this.children.get(e.key),i=t.filter(t=>t.container===e),a=new Map(r.map(e=>[e.key,e])),o=c(adjacency(r,i)).map(e=>e.map(e=>a.get(e)).sort(compareNodes)).sort((e,t)=>e[0].rank-t[0].rank),s=new Map(o.flatMap((e,t)=>e.map(e=>[e.key,t]))),l=new Map(r.map(e=>[e.key,/* @__PURE__ */ new Set]));for(let e of i)s.get(e.source.key)!==s.get(e.target.key)&&l.get(e.source.key).add(e.target.key);for(let e of o)for(let t=1;t<e.length;t++)l.get(e[t].key).add(e[t-1].key);let u=new Set(r.map(e=>e.key)),d=[];for(;u.size>0;){let e=[...u].filter(e=>l.get(e).size===0).sort((e,t)=>compareNodes(a.get(e),a.get(t)))[0];d.push(a.get(e)),u.delete(e);for(let t of u)l.get(t).delete(e)}n.push({container:e,children:d,changed:r.some((e,t)=>e!==d[t])})}let r=new Map(n.map(e=>[e.container.key,e.children])),i=[],walk=e=>{if(e.kind===`slice`)i.push(e);else for(let t of[...r.get(e.key)].sort((e,t)=>Number(e.kind!==`slice`)-Number(t.kind!==`slice`)))walk(t)};return walk(this.root),{containers:n,slices:i}}traverse(e,t,n,r=!1){if(t!==`incoming`&&t!==`outgoing`)throw new o(`Unsupported dependency direction '${t}'.`);let i=this.evidence(n,r).map(e=>t===`incoming`?{source:e.producer,target:e.consumer}:{source:e.consumer,target:e.producer}),a=/* @__PURE__ */ new Set([e]),s=[e],c=[];for(let e=0;e<s.length;e++)for(let t of i.filter(t=>t.source.address===s[e]).sort((e,t)=>e.target.rank-t.target.rank))a.has(t.target.address)||(a.add(t.target.address),c.push(t.target),s.push(t.target.address));return distinctNodes(c)}isBareProjectionTarget(e){return e.length!==0&&!e.includes(`.`)}*projectionReadModels(e,t,n){for(let r of e.projections){let e=variants(r.blocks);e.length>0?yield*e.map(e=>e.name):yield*this.projectionReadModel(r,t,n)}}projectionReadModel(e,t,n){return n.get(e.readModel??``)===t?[]:[e.readModel??e.name]}projectionEventTargets(){let t=/* @__PURE__ */ new Map,n=new Set(this.slices.flatMap(({syntax:e})=>e.readModels.map(e=>e.name.toLowerCase())));for(let{node:n,syntax:r}of this.slices)for(let i of e(r)){let e=i.name.toLowerCase();t.has(e)||t.set(e,[]),t.get(e).push({node:n,name:i.name})}let r=[...t.values()].filter(e=>e.length===1).map(([e])=>e).filter(e=>this.isBareProjectionTarget(e.name)).filter(e=>!n.has(e.name.toLowerCase()));return new Map(r.map(e=>[e.name,e.node]))}add(e,t,n){let r=[...n.scope,t],i=r.join(`.`),a=`${e}:${i}`,o=this.byKey.get(a);if(o!==void 0)return o;let s=nodeOf(e,i,r,this.modelNodes.length);return this.modelNodes.push(s),this.byKey.set(a,s),this.parents.set(a,n),this.children.get(n.key).push(s),e!==`slice`&&this.children.set(a,[]),s}ancestors(e){let t=[];for(let n=this.parents.get(e.key);n!==void 0;n=this.parents.get(n.key))t.push(n);return t}disjoint(e,t){return e.key!==t.key&&!this.ancestors(e).includes(t)&&!this.ancestors(t).includes(e)}at(e,t){return[e,...this.ancestors(e)].filter(e=>e.kind===t)}containers(){return[this.root,...this.modelNodes.filter(e=>e.kind===`module`||e.kind===`feature`)]}evidence(e,t){let n=selectedKinds(e);return this.edges.flatMap(e=>e.evidence).filter(e=>n.has(e.kind)&&(t||!e.testOnly))}path(e){return[...this.ancestors(e).reverse(),e].filter(e=>e!==this.root)}siblingEdges(e){let t=[];for(let n of this.evidence(selectedOrderingKinds(e),!1)){let e=this.path(n.consumer),r=this.path(n.producer),i=0;for(;i<e.length&&i<r.length&&e[i].key===r[i].key;)i++;i!==e.length&&i!==r.length&&t.push({container:i===0?this.root:e[i-1],source:e[i],target:r[i]})}return t}};function selectedKinds(e){let t=new Set(e??a);if([...t].some(e=>!a.includes(e)))throw new o(`Unsupported dependency kind.`);return t}function selectedOrderingKinds(e){return[...selectedKinds(e??l)].filter(e=>l.includes(e))}function adjacency(e,t){let n=new Map(e.map(e=>[e.key,/* @__PURE__ */ new Set]));for(let e of t)n.get(e.source.key).add(e.target.key);return n}function groupsOf(e,t,n){let r=new Map(t.map(e=>[e.key,e]));return c(e).filter(e=>e.length>1).map(e=>({container:n,members:distinctNodes(e.map(e=>r.get(e)))})).sort((e,t)=>e.members[0].rank-t.members[0].rank)}export{u as DependencyGraph};
|
|
1
|
+
import"../../_virtual/_virtual/_rolldown/runtime.js";import{authoredOrderKey as e,authoredOrderOf as t}from"../Files/AuthoredOrder.js";import{expandSpecificationExamples as n}from"../Parsing/SpecificationCommandExamples.js";import{dependencySourcesOf as r}from"../Syntax/DependencySources.js";import{eventDeclarations as i}from"../Syntax/EventDeclarations.js";import{dependencyKinds as a}from"./DependencyKind.js";import{InvalidDependencyQuery as o}from"./InvalidDependencyQuery.js";import{sliceReferences as s}from"./SliceReferences.js";import{stronglyConnectedGroups as c}from"./StronglyConnectedGroups.js";const l=[`usesFactsFrom`,`reactsTo`,`decidesFrom`],ordinal=(e,t)=>e<t?-1:+(e>t),declarationKey=(e,t)=>JSON.stringify([e,t.toLowerCase()]),nodeOf=(e,t,n,r)=>({kind:e,address:t,scope:n,rank:r,key:`${e}:${t}`}),compareNodes=(e,t)=>e.rank-t.rank||ordinal(e.key,t.key),distinctNodes=e=>[...new Map([...e].map(e=>[e.key,e])).values()].sort(compareNodes),compareEvidence=(e,t)=>e.consumer.rank-t.consumer.rank||e.location.line-t.location.line||e.location.column-t.location.column||a.indexOf(e.kind)-a.indexOf(t.kind)||e.producer.rank-t.producer.rank||ordinal(e.location.path??``,t.location.path??``)||ordinal(e.role,t.role)||ordinal(e.name,t.name);function variants(e){return e.flatMap(e=>e.kind===`ProjectionVariantSyntax`?[e,...variants(e.blocks)]:e.kind===`ChildrenSyntax`||e.kind===`NestedSyntax`?variants(e.blocks):[])}var u=class DependencyGraph{orderSource;edges;unresolved;excludedReferences;unusedImports;modelNodes=[];slices=[];children=/* @__PURE__ */ new Map;byKey=/* @__PURE__ */ new Map;parents=/* @__PURE__ */ new Map;root=nodeOf(`application`,``,[],-1);static for(e,n=t(e)){return new DependencyGraph(e,n)}get nodes(){return this.modelNodes}constructor(t,o){t=n(t),this.orderSource=o.size>0?`authored`:`syntax`,this.children.set(this.root.key,[]);let ordered=(t,n)=>t.map((t,r)=>({syntax:t,index:r,rank:o.get(e([...n.scope,t.name]))??2**53-1})).sort((e,t)=>e.rank-t.rank||e.index-t.index).map(e=>e.syntax),feature=(e,t)=>{let n=this.add(`feature`,e.name,t);for(let t of ordered(e.slices,n))this.slices.push({node:this.add(`slice`,t.name,n),syntax:t});for(let t of ordered(e.features,n))feature(t,n)};for(let e of ordered(t.modules,this.root)){let t=this.add(`module`,e.name,this.root);for(let n of ordered(e.features,t))feature(n,t)}let c=this.projectionEventTargets(),l=/* @__PURE__ */ new Map,u=/* @__PURE__ */ new Map,declare=(e,t,n,r)=>{let i=declarationKey(t,n);e.has(i)||e.set(i,[]);let a=e.get(i);a.includes(r)||a.push(r);let o=declarationKey(t,[...r.scope,n].join(`.`));e.has(o)||e.set(o,[]);let s=e.get(o);s.includes(r)||s.push(r)};for(let{node:e,syntax:t}of this.slices){for(let n of i(t))declare(l,`Event`,n.name,e);for(let n of t.commands)declare(l,`Command`,n.name,e);for(let n of t.reactions)declare(l,`Reaction`,n.name,e);for(let n of t.queries)declare(l,`Query`,n.name,e);for(let n of t.screens)declare(l,`Screen`,n.name,e);for(let n of t.readModels)declare(l,`ReadModel`,n.name,e);for(let n of this.projectionReadModels(t,e,c))declare(u,`ReadModel`,n,e);for(let n of r(t).reducers??[])declare(u,`ReadModel`,n.readModel,e)}let d=new Set((t.declaredTriggers??[]).map(e=>e.name.toLowerCase())),f=new Set([...t.concepts,...t.types].map(e=>e.name.toLowerCase())),p=new Set((t.policies??[]).map(e=>e.name.toLowerCase())),m=t.imports.filter(e=>e.qualifiedName.includes(`.`)).slice().sort((e,t)=>ordinal(e.location.path??``,t.location.path??``)||e.location.line-t.location.line||e.location.column-t.location.column||ordinal(e.qualifiedName,t.qualifiedName)),h=/* @__PURE__ */ new Map,g=[],_=[],v=/* @__PURE__ */ new Set,y=0;for(let{node:e,syntax:t}of this.slices){let n=s(t);y+=n.shared.filter(e=>(e.kind===`type`?f:p).has(e.name.toLowerCase())).length;for(let t of n.references){let n=declarationKey(t.targetKind,t.name),r=(t.targetKind===`ReadModel`&&u.has(n)?u:l).get(n);if(r!==void 0&&r.length>0){let n=r[0];n!==e&&g.push({consumer:e,producer:n,kind:t.kind,role:t.role,name:t.name,ambiguous:r.length>1,alternatives:r.slice(1),location:t.location,testOnly:t.kind===`verifiedWith`});continue}let i=t.targetKind===`Event`?m.filter(e=>e.qualifiedName.slice(e.qualifiedName.lastIndexOf(`.`)+1).toLowerCase()===t.name.toLowerCase()):[];if(i.length>0){let n=[];for(let e of i){v.add(e.qualifiedName);let t=e.qualifiedName.slice(0,e.qualifiedName.lastIndexOf(`.`)),r=`context:${t}`;if(!h.has(r)){let e=nodeOf(`context`,r,[t],this.modelNodes.length);this.modelNodes.push(e),h.set(r,e)}let i=h.get(r);n.includes(i)||n.push(i)}g.push({consumer:e,producer:n[0],kind:`outsideTheModel`,role:t.role,name:t.name,ambiguous:n.length>1,alternatives:n.slice(1),location:t.location,testOnly:t.kind===`verifiedWith`})}else t.role===`trigger`&&d.has(t.name.toLowerCase())?y++:_.push({consumer:e,kind:t.kind,role:t.role,name:t.name,location:t.location})}}let b=/* @__PURE__ */ new Map;for(let e of g.sort(compareEvidence)){let t=JSON.stringify([e.consumer.key,e.producer.key,e.kind]);b.has(t)||b.set(t,[]),b.get(t).push(e)}this.edges=[...b.values()].map(e=>({consumer:e[0].consumer,producer:e[0].producer,kind:e[0].kind,evidence:e})),this.unresolved=_.sort((e,t)=>e.consumer.rank-t.consumer.rank||e.location.line-t.location.line||e.location.column-t.location.column||a.indexOf(e.kind)-a.indexOf(t.kind)||ordinal(e.location.path??``,t.location.path??``)||ordinal(e.name,t.name)),this.excludedReferences=y,this.unusedImports=[...new Set(m.filter(e=>!v.has(e.qualifiedName)).map(e=>e.qualifiedName))]}implied(e,t,n,r=!1,i=3){if(![`slice`,`feature`,`module`].includes(e))throw new o(`Unsupported source level '${e}'.`);if(![`slice`,`feature`,`module`,`context`].includes(t))throw new o(`Unsupported target level '${t}'.`);if(i<0)throw new o(`Evidence limit must not be negative.`);let s=/* @__PURE__ */ new Map;for(let i of this.evidence(n,r))for(let n of this.at(i.consumer,e))for(let e of this.at(i.producer,t).filter(e=>this.disjoint(n,e))){let t=JSON.stringify([n.key,e.key]);s.has(t)||s.set(t,{source:n,target:e,evidence:[]}),s.get(t).evidence.push(i)}return[...s.values()].sort((e,t)=>e.source.rank-t.source.rank||e.target.rank-t.target.rank||ordinal(e.source.key,t.source.key)||ordinal(e.target.key,t.target.key)).map(e=>{let t=e.evidence.sort(compareEvidence),n={};for(let e of a){let r=t.filter(t=>t.kind===e).length;r>0&&(n[e]=r)}return{source:e.source,target:e.target,sliceEdges:new Set(t.map(e=>JSON.stringify([e.consumer.key,e.producer.key]))).size,references:t.length,byKind:n,consumers:distinctNodes(t.map(e=>e.consumer)),producers:distinctNodes(t.map(e=>e.producer)),evidence:t.slice(0,i),evidenceCount:t.length,evidenceTruncated:t.length>i}})}cycles(e,t){if(![`slice`,`feature`,`module`].includes(e))throw new o(`Unsupported cycle level '${e}'.`);let n=this.implied(e,e,selectedOrderingKinds(t)),r=distinctNodes(n.flatMap(e=>[e.source,e.target]));return groupsOf(adjacency(r,n),r,null)}siblingGroups(e){let t=this.siblingEdges(e);return this.containers().flatMap(e=>{let n=this.children.get(e.key);return groupsOf(adjacency(n,t.filter(t=>t.container===e)),n,e)})}suggestedOrder(e){let t=this.siblingEdges(e),n=[];for(let e of this.containers()){let r=this.children.get(e.key),i=t.filter(t=>t.container===e),a=new Map(r.map(e=>[e.key,e])),o=c(adjacency(r,i)).map(e=>e.map(e=>a.get(e)).sort(compareNodes)).sort((e,t)=>e[0].rank-t[0].rank),s=new Map(o.flatMap((e,t)=>e.map(e=>[e.key,t]))),l=new Map(r.map(e=>[e.key,/* @__PURE__ */ new Set]));for(let e of i)s.get(e.source.key)!==s.get(e.target.key)&&l.get(e.source.key).add(e.target.key);for(let e of o)for(let t=1;t<e.length;t++)l.get(e[t].key).add(e[t-1].key);let u=new Set(r.map(e=>e.key)),d=[];for(;u.size>0;){let e=[...u].filter(e=>l.get(e).size===0).sort((e,t)=>compareNodes(a.get(e),a.get(t)))[0];d.push(a.get(e)),u.delete(e);for(let t of u)l.get(t).delete(e)}n.push({container:e,children:d,changed:r.some((e,t)=>e!==d[t])})}let r=new Map(n.map(e=>[e.container.key,e.children])),i=[],walk=e=>{if(e.kind===`slice`)i.push(e);else for(let t of[...r.get(e.key)].sort((e,t)=>Number(e.kind!==`slice`)-Number(t.kind!==`slice`)))walk(t)};return walk(this.root),{containers:n,slices:i}}traverse(e,t,n,r=!1){if(t!==`incoming`&&t!==`outgoing`)throw new o(`Unsupported dependency direction '${t}'.`);let i=this.evidence(n,r).map(e=>t===`incoming`?{source:e.producer,target:e.consumer}:{source:e.consumer,target:e.producer}),a=/* @__PURE__ */ new Set([e]),s=[e],c=[];for(let e=0;e<s.length;e++)for(let t of i.filter(t=>t.source.address===s[e]).sort((e,t)=>e.target.rank-t.target.rank))a.has(t.target.address)||(a.add(t.target.address),c.push(t.target),s.push(t.target.address));return distinctNodes(c)}isBareProjectionTarget(e){return e.length!==0&&!e.includes(`.`)}*projectionReadModels(e,t,n){for(let r of e.projections){let e=variants(r.blocks);e.length>0?yield*e.map(e=>e.name):yield*this.projectionReadModel(r,t,n)}}projectionReadModel(e,t,n){return n.get(e.readModel??``)===t?[]:[e.readModel??e.name]}projectionEventTargets(){let e=/* @__PURE__ */ new Map,t=new Set(this.slices.flatMap(({syntax:e})=>e.readModels.map(e=>e.name.toLowerCase())));for(let{node:t,syntax:n}of this.slices)for(let r of i(n)){let n=r.name.toLowerCase();e.has(n)||e.set(n,[]),e.get(n).push({node:t,name:r.name})}let n=[...e.values()].filter(e=>e.length===1).map(([e])=>e).filter(e=>this.isBareProjectionTarget(e.name)).filter(e=>!t.has(e.name.toLowerCase()));return new Map(n.map(e=>[e.name,e.node]))}add(e,t,n){let r=[...n.scope,t],i=r.join(`.`),a=`${e}:${i}`,o=this.byKey.get(a);if(o!==void 0)return o;let s=nodeOf(e,i,r,this.modelNodes.length);return this.modelNodes.push(s),this.byKey.set(a,s),this.parents.set(a,n),this.children.get(n.key).push(s),e!==`slice`&&this.children.set(a,[]),s}ancestors(e){let t=[];for(let n=this.parents.get(e.key);n!==void 0;n=this.parents.get(n.key))t.push(n);return t}disjoint(e,t){return e.key!==t.key&&!this.ancestors(e).includes(t)&&!this.ancestors(t).includes(e)}at(e,t){return[e,...this.ancestors(e)].filter(e=>e.kind===t)}containers(){return[this.root,...this.modelNodes.filter(e=>e.kind===`module`||e.kind===`feature`)]}evidence(e,t){let n=selectedKinds(e);return this.edges.flatMap(e=>e.evidence).filter(e=>n.has(e.kind)&&(t||!e.testOnly))}path(e){return[...this.ancestors(e).reverse(),e].filter(e=>e!==this.root)}siblingEdges(e){let t=[];for(let n of this.evidence(selectedOrderingKinds(e),!1)){let e=this.path(n.consumer),r=this.path(n.producer),i=0;for(;i<e.length&&i<r.length&&e[i].key===r[i].key;)i++;i!==e.length&&i!==r.length&&t.push({container:i===0?this.root:e[i-1],source:e[i],target:r[i]})}return t}};function selectedKinds(e){let t=new Set(e??a);if([...t].some(e=>!a.includes(e)))throw new o(`Unsupported dependency kind.`);return t}function selectedOrderingKinds(e){return[...selectedKinds(e??l)].filter(e=>l.includes(e))}function adjacency(e,t){let n=new Map(e.map(e=>[e.key,/* @__PURE__ */ new Set]));for(let e of t)n.get(e.source.key).add(e.target.key);return n}function groupsOf(e,t,n){let r=new Map(t.map(e=>[e.key,e]));return c(e).filter(e=>e.length>1).map(e=>({container:n,members:distinctNodes(e.map(e=>r.get(e)))})).sort((e,t)=>e.members[0].rank-t.members[0].rank)}export{u as DependencyGraph};
|
|
2
2
|
//# sourceMappingURL=DependencyGraph.js.map
|