@cratis/screenplay-language 5.2.0 → 5.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (408) hide show
  1. package/dist/bundles/TypeReferenceSymbol.js.map +1 -1
  2. package/dist/bundles/action-subject-authoring.js.map +1 -1
  3. package/dist/bundles/bmp-word-characters.js.map +1 -1
  4. package/dist/bundles/case-authoring.js +1 -1
  5. package/dist/bundles/case-authoring.js.map +1 -1
  6. package/dist/bundles/code-actions.js.map +1 -1
  7. package/dist/bundles/command-read-completions.js.map +1 -1
  8. package/dist/bundles/compiler/Authoring/ActionSubjectQuickFixes.js +3 -3
  9. package/dist/bundles/compiler/Authoring/ActionSubjectQuickFixes.js.map +1 -1
  10. package/dist/bundles/compiler/Authoring/QuickFixes.js +4 -4
  11. package/dist/bundles/compiler/Authoring/QuickFixes.js.map +1 -1
  12. package/dist/bundles/compiler/Authoring/StructuredValueQuickFix.js +1 -1
  13. package/dist/bundles/compiler/Authoring/StructuredValueQuickFix.js.map +1 -1
  14. package/dist/bundles/compiler/Authoring/TimelineQuickFixContext.js +4 -4
  15. package/dist/bundles/compiler/Authoring/TimelineQuickFixContext.js.map +1 -1
  16. package/dist/bundles/compiler/Authoring/TimelineQuickFixImports.js +2 -2
  17. package/dist/bundles/compiler/Authoring/TimelineQuickFixImports.js.map +1 -1
  18. package/dist/bundles/compiler/Authoring/TimelineQuickFixes.js +1 -1
  19. package/dist/bundles/compiler/Authoring/TimelineQuickFixes.js.map +1 -1
  20. package/dist/bundles/compiler/Dependencies/DeclaredDependencies.js.map +1 -1
  21. package/dist/bundles/compiler/Dependencies/DeclaredDependencyTargets.js.map +1 -1
  22. package/dist/bundles/compiler/Dependencies/DependencyGraph.js +1 -1
  23. package/dist/bundles/compiler/Dependencies/DependencyGraph.js.map +1 -1
  24. package/dist/bundles/compiler/Dependencies/DependencyKind.js.map +1 -1
  25. package/dist/bundles/compiler/Dependencies/InvalidDependencyQuery.js.map +1 -1
  26. package/dist/bundles/compiler/Dependencies/SliceReferences.js.map +1 -1
  27. package/dist/bundles/compiler/Dependencies/StronglyConnectedGroups.js.map +1 -1
  28. package/dist/bundles/compiler/Diagnostics/DiagnosticArgument.js.map +1 -1
  29. package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js +1 -1
  30. package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js.map +1 -1
  31. package/dist/bundles/compiler/Diagnostics/ProductionDestinationDiagnostics.js +1 -1
  32. package/dist/bundles/compiler/Diagnostics/ProductionDestinationDiagnostics.js.map +1 -1
  33. package/dist/bundles/compiler/Diagnostics/SourceLocation.js.map +1 -1
  34. package/dist/bundles/compiler/Files/AuthoredOrder.js +1 -1
  35. package/dist/bundles/compiler/Files/AuthoredOrder.js.map +1 -1
  36. package/dist/bundles/compiler/Files/OrderingRoot.js +1 -1
  37. package/dist/bundles/compiler/Files/OrderingRoot.js.map +1 -1
  38. package/dist/bundles/compiler/Files/PlayApplicationAssembly.js +1 -1
  39. package/dist/bundles/compiler/Files/PlayApplicationAssembly.js.map +1 -1
  40. package/dist/bundles/compiler/Files/PlayDocumentSource.js.map +1 -1
  41. package/dist/bundles/compiler/Files/PlayFolderMerge.js +1 -1
  42. package/dist/bundles/compiler/Files/PlayFolderMerge.js.map +1 -1
  43. package/dist/bundles/compiler/Files/PlayGlob.js +2 -1
  44. package/dist/bundles/compiler/Files/PlayGlob.js.map +1 -1
  45. package/dist/bundles/compiler/Files/PlayImports.js +1 -1
  46. package/dist/bundles/compiler/Files/PlayImports.js.map +1 -1
  47. package/dist/bundles/compiler/Files/PlayPlacement.js.map +1 -1
  48. package/dist/bundles/compiler/Files/TimelineOrder.js +1 -1
  49. package/dist/bundles/compiler/Files/TimelineOrder.js.map +1 -1
  50. package/dist/bundles/compiler/Generation/FiniteGenerationRules.js +1 -1
  51. package/dist/bundles/compiler/Generation/GenerationAssessmentCache.js.map +1 -1
  52. package/dist/bundles/compiler/Generation/GenerationChecksum.js.map +1 -1
  53. package/dist/bundles/compiler/Generation/GenerationPattern.js +1 -1
  54. package/dist/bundles/compiler/Generation/GenerationPattern.js.map +1 -1
  55. package/dist/bundles/compiler/Generation/GenerationPatternAssessment.js.map +1 -1
  56. package/dist/bundles/compiler/Generation/GenerationPatternParser.js.map +1 -1
  57. package/dist/bundles/compiler/Generation/GenerationPatternToken.js.map +1 -1
  58. package/dist/bundles/compiler/Generation/GenerationRuleProof.js +1 -1
  59. package/dist/bundles/compiler/Generation/InvalidGenerationPattern.js.map +1 -1
  60. package/dist/bundles/compiler/Generation/RegexCharacters.js.map +1 -1
  61. package/dist/bundles/compiler/Generation/RegexExpression.js.map +1 -1
  62. package/dist/bundles/compiler/Generation/RuleConsistency.js +1 -1
  63. package/dist/bundles/compiler/Parsing/ActionSubjectClause.js.map +1 -1
  64. package/dist/bundles/compiler/Parsing/ActionSubjectInputs.js.map +1 -1
  65. package/dist/bundles/compiler/Parsing/ActionSubjectResolution.js.map +1 -1
  66. package/dist/bundles/compiler/Parsing/ApplicationContextParser.js +2 -0
  67. package/dist/bundles/compiler/Parsing/ApplicationContextParser.js.map +1 -0
  68. package/dist/bundles/compiler/Parsing/AuthorizeParser.js +1 -1
  69. package/dist/bundles/compiler/Parsing/AuthorizeParser.js.map +1 -1
  70. package/dist/bundles/compiler/Parsing/CanvasPlacement.js.map +1 -1
  71. package/dist/bundles/compiler/Parsing/CaptureEventFixturesValidator.js.map +1 -1
  72. package/dist/bundles/compiler/Parsing/CaptureParser.js +1 -1
  73. package/dist/bundles/compiler/Parsing/CaptureParser.js.map +1 -1
  74. package/dist/bundles/compiler/Parsing/ClockOperandParser.js.map +1 -1
  75. package/dist/bundles/compiler/Parsing/CodeBlockParser.js.map +1 -1
  76. package/dist/bundles/compiler/Parsing/CommandDestinationTypes.js.map +1 -1
  77. package/dist/bundles/compiler/Parsing/CommandHandlerValidator.js.map +1 -1
  78. package/dist/bundles/compiler/Parsing/CommandParser.js +1 -1
  79. package/dist/bundles/compiler/Parsing/CommandParser.js.map +1 -1
  80. package/dist/bundles/compiler/Parsing/CommandReadSources.js.map +1 -1
  81. package/dist/bundles/compiler/Parsing/CommandResponseParser.js +1 -1
  82. package/dist/bundles/compiler/Parsing/CommandResponseParser.js.map +1 -1
  83. package/dist/bundles/compiler/Parsing/CommandStreamCandidates.js.map +1 -1
  84. package/dist/bundles/compiler/Parsing/CompositeStreamIdValidator.js.map +1 -1
  85. package/dist/bundles/compiler/Parsing/CompositionParser.js +1 -1
  86. package/dist/bundles/compiler/Parsing/CompositionParser.js.map +1 -1
  87. package/dist/bundles/compiler/Parsing/ConceptComplianceParser.js +1 -1
  88. package/dist/bundles/compiler/Parsing/ConceptComplianceParser.js.map +1 -1
  89. package/dist/bundles/compiler/Parsing/ConditionDepthBudget.js +2 -0
  90. package/dist/bundles/compiler/Parsing/ConditionDepthBudget.js.map +1 -0
  91. package/dist/bundles/compiler/Parsing/ConditionParser.js +1 -1
  92. package/dist/bundles/compiler/Parsing/ConditionParser.js.map +1 -1
  93. package/dist/bundles/compiler/Parsing/ConstraintParser.js +1 -1
  94. package/dist/bundles/compiler/Parsing/ConstraintParser.js.map +1 -1
  95. package/dist/bundles/compiler/Parsing/ConstraintPropertyValidator.js +1 -1
  96. package/dist/bundles/compiler/Parsing/ConstraintPropertyValidator.js.map +1 -1
  97. package/dist/bundles/compiler/Parsing/ContinuationValues.js.map +1 -1
  98. package/dist/bundles/compiler/Parsing/DeclarationParsers.js +1 -1
  99. package/dist/bundles/compiler/Parsing/DeclarationParsers.js.map +1 -1
  100. package/dist/bundles/compiler/Parsing/DependencySourceParser.js +1 -1
  101. package/dist/bundles/compiler/Parsing/DependencySourceParser.js.map +1 -1
  102. package/dist/bundles/compiler/Parsing/DependsOnParser.js.map +1 -1
  103. package/dist/bundles/compiler/Parsing/DescriptionParser.js +1 -1
  104. package/dist/bundles/compiler/Parsing/DescriptionParser.js.map +1 -1
  105. package/dist/bundles/compiler/Parsing/DocumentationParser.js +1 -1
  106. package/dist/bundles/compiler/Parsing/DocumentationParser.js.map +1 -1
  107. package/dist/bundles/compiler/Parsing/EnumerationMembers.js +1 -1
  108. package/dist/bundles/compiler/Parsing/EnumerationMembers.js.map +1 -1
  109. package/dist/bundles/compiler/Parsing/EventMetadataParser.js +1 -1
  110. package/dist/bundles/compiler/Parsing/EventMetadataParser.js.map +1 -1
  111. package/dist/bundles/compiler/Parsing/EventSourceParser.js +1 -1
  112. package/dist/bundles/compiler/Parsing/EventSourceParser.js.map +1 -1
  113. package/dist/bundles/compiler/Parsing/EventSourceValidator.js +1 -1
  114. package/dist/bundles/compiler/Parsing/EventSourceValidator.js.map +1 -1
  115. package/dist/bundles/compiler/Parsing/EventSubjectValidator.js +1 -1
  116. package/dist/bundles/compiler/Parsing/EventSubjectValidator.js.map +1 -1
  117. package/dist/bundles/compiler/Parsing/ExpressionParser.js +1 -1
  118. package/dist/bundles/compiler/Parsing/ExpressionParser.js.map +1 -1
  119. package/dist/bundles/compiler/Parsing/FeatureBody.js +1 -1
  120. package/dist/bundles/compiler/Parsing/FeatureBody.js.map +1 -1
  121. package/dist/bundles/compiler/Parsing/FileImportParser.js.map +1 -1
  122. package/dist/bundles/compiler/Parsing/FileReferences.js.map +1 -1
  123. package/dist/bundles/compiler/Parsing/FoldedEventSources.js.map +1 -1
  124. package/dist/bundles/compiler/Parsing/GenerationBodyParser.js +1 -1
  125. package/dist/bundles/compiler/Parsing/GenerationBodyParser.js.map +1 -1
  126. package/dist/bundles/compiler/Parsing/GenerationParser.js +1 -1
  127. package/dist/bundles/compiler/Parsing/GenerationParser.js.map +1 -1
  128. package/dist/bundles/compiler/Parsing/GuardedActionInputs.js.map +1 -1
  129. package/dist/bundles/compiler/Parsing/GuardedActionParser.js +1 -1
  130. package/dist/bundles/compiler/Parsing/GuardedActionParser.js.map +1 -1
  131. package/dist/bundles/compiler/Parsing/GuardedActionShadowing.js.map +1 -1
  132. package/dist/bundles/compiler/Parsing/GuardedActionValidator.js +1 -1
  133. package/dist/bundles/compiler/Parsing/GuardedActionValidator.js.map +1 -1
  134. package/dist/bundles/compiler/Parsing/GuardedInteractions.js +1 -1
  135. package/dist/bundles/compiler/Parsing/GuardedInteractions.js.map +1 -1
  136. package/dist/bundles/compiler/Parsing/IdentifierComplianceValidator.js +1 -1
  137. package/dist/bundles/compiler/Parsing/IdentifierComplianceValidator.js.map +1 -1
  138. package/dist/bundles/compiler/Parsing/IdentityParser.js +1 -1
  139. package/dist/bundles/compiler/Parsing/IdentityParser.js.map +1 -1
  140. package/dist/bundles/compiler/Parsing/IdentityValidator.js.map +1 -1
  141. package/dist/bundles/compiler/Parsing/ImplementationParser.js +2 -2
  142. package/dist/bundles/compiler/Parsing/ImplementationParser.js.map +1 -1
  143. package/dist/bundles/compiler/Parsing/ImportDiscovery.js +1 -1
  144. package/dist/bundles/compiler/Parsing/ImportDiscovery.js.map +1 -1
  145. package/dist/bundles/compiler/Parsing/InlineEventValidator.js.map +1 -1
  146. package/dist/bundles/compiler/Parsing/InputUses.js +1 -1
  147. package/dist/bundles/compiler/Parsing/InputUses.js.map +1 -1
  148. package/dist/bundles/compiler/Parsing/InteractionAlternatives.js +1 -1
  149. package/dist/bundles/compiler/Parsing/InteractionAlternatives.js.map +1 -1
  150. package/dist/bundles/compiler/Parsing/InteractionExecutions.js +1 -1
  151. package/dist/bundles/compiler/Parsing/InteractionExecutions.js.map +1 -1
  152. package/dist/bundles/compiler/Parsing/LegacyTextRulePatterns.js.map +1 -1
  153. package/dist/bundles/compiler/Parsing/LineReader.js.map +1 -1
  154. package/dist/bundles/compiler/Parsing/LineText.js.map +1 -1
  155. package/dist/bundles/compiler/Parsing/MatchAmbiguity.js +1 -1
  156. package/dist/bundles/compiler/Parsing/MatchAmbiguity.js.map +1 -1
  157. package/dist/bundles/compiler/Parsing/MatchAmbiguityCharacters.js.map +1 -1
  158. package/dist/bundles/compiler/Parsing/MatchAmbiguityGraph.js.map +1 -1
  159. package/dist/bundles/compiler/Parsing/MatchAmbiguityParser.js.map +1 -1
  160. package/dist/bundles/compiler/Parsing/MatchOperandValidation.js +1 -1
  161. package/dist/bundles/compiler/Parsing/MatchOperandValidation.js.map +1 -1
  162. package/dist/bundles/compiler/Parsing/ModuleBody.js +1 -1
  163. package/dist/bundles/compiler/Parsing/ModuleBody.js.map +1 -1
  164. package/dist/bundles/compiler/Parsing/ObserverFilterParser.js +1 -1
  165. package/dist/bundles/compiler/Parsing/ObserverFilterParser.js.map +1 -1
  166. package/dist/bundles/compiler/Parsing/ObserverFilterValidator.js.map +1 -1
  167. package/dist/bundles/compiler/Parsing/OperationParser.js +1 -1
  168. package/dist/bundles/compiler/Parsing/OperationParser.js.map +1 -1
  169. package/dist/bundles/compiler/Parsing/OperationValidator.js +1 -1
  170. package/dist/bundles/compiler/Parsing/OperationValidator.js.map +1 -1
  171. package/dist/bundles/compiler/Parsing/ParserContext.js.map +1 -1
  172. package/dist/bundles/compiler/Parsing/PersonaCallerValidator.js.map +1 -1
  173. package/dist/bundles/compiler/Parsing/PolicyParser.js +1 -1
  174. package/dist/bundles/compiler/Parsing/PolicyParser.js.map +1 -1
  175. package/dist/bundles/compiler/Parsing/PortableMatchGroupName.js.map +1 -1
  176. package/dist/bundles/compiler/Parsing/PortableMatchPattern.js.map +1 -1
  177. package/dist/bundles/compiler/Parsing/PortableMatchSuggestions.js.map +1 -1
  178. package/dist/bundles/compiler/Parsing/PossibleEventsParser.js +1 -1
  179. package/dist/bundles/compiler/Parsing/PossibleEventsParser.js.map +1 -1
  180. package/dist/bundles/compiler/Parsing/ProducesParser.js +1 -1
  181. package/dist/bundles/compiler/Parsing/ProducesParser.js.map +1 -1
  182. package/dist/bundles/compiler/Parsing/ProjectionEventScopeValidator.js.map +1 -1
  183. package/dist/bundles/compiler/Parsing/ProjectionExpressionParser.js +1 -1
  184. package/dist/bundles/compiler/Parsing/ProjectionExpressionParser.js.map +1 -1
  185. package/dist/bundles/compiler/Parsing/ProjectionParser.js +1 -1
  186. package/dist/bundles/compiler/Parsing/ProjectionParser.js.map +1 -1
  187. package/dist/bundles/compiler/Parsing/ProjectionTargetValidator.js +1 -1
  188. package/dist/bundles/compiler/Parsing/ProjectionTargetValidator.js.map +1 -1
  189. package/dist/bundles/compiler/Parsing/PropertyLineParser.js +1 -1
  190. package/dist/bundles/compiler/Parsing/PropertyLineParser.js.map +1 -1
  191. package/dist/bundles/compiler/Parsing/PublicEventMetadataValidator.js +1 -1
  192. package/dist/bundles/compiler/Parsing/PublicEventMetadataValidator.js.map +1 -1
  193. package/dist/bundles/compiler/Parsing/PublicEventUsageCollector.js +1 -1
  194. package/dist/bundles/compiler/Parsing/PublicEventUsageCollector.js.map +1 -1
  195. package/dist/bundles/compiler/Parsing/PublicEventUsageValidator.js +1 -1
  196. package/dist/bundles/compiler/Parsing/PublicEventUsageValidator.js.map +1 -1
  197. package/dist/bundles/compiler/Parsing/PurposeParser.js +1 -1
  198. package/dist/bundles/compiler/Parsing/PurposeParser.js.map +1 -1
  199. package/dist/bundles/compiler/Parsing/PurposeValidator.js.map +1 -1
  200. package/dist/bundles/compiler/Parsing/QueryParser.js +1 -1
  201. package/dist/bundles/compiler/Parsing/QueryParser.js.map +1 -1
  202. package/dist/bundles/compiler/Parsing/ReactionIdentityParser.js +1 -1
  203. package/dist/bundles/compiler/Parsing/ReactionIdentityParser.js.map +1 -1
  204. package/dist/bundles/compiler/Parsing/ReactionParser.js +1 -1
  205. package/dist/bundles/compiler/Parsing/ReactionParser.js.map +1 -1
  206. package/dist/bundles/compiler/Parsing/ReactionRefusalValidator.js +1 -1
  207. package/dist/bundles/compiler/Parsing/ReactionRefusalValidator.js.map +1 -1
  208. package/dist/bundles/compiler/Parsing/ReadModelKeyValidator.js.map +1 -1
  209. package/dist/bundles/compiler/Parsing/ReadModelMemberTypeValidator.js.map +1 -1
  210. package/dist/bundles/compiler/Parsing/ReadsParser.js +1 -1
  211. package/dist/bundles/compiler/Parsing/ReadsParser.js.map +1 -1
  212. package/dist/bundles/compiler/Parsing/RedeliveryValues.js.map +1 -1
  213. package/dist/bundles/compiler/Parsing/RefusalDeclarations.js +1 -1
  214. package/dist/bundles/compiler/Parsing/RefusalDeclarations.js.map +1 -1
  215. package/dist/bundles/compiler/Parsing/RefusalValueWalker.js.map +1 -1
  216. package/dist/bundles/compiler/Parsing/ResponseCommandResolver.js.map +1 -1
  217. package/dist/bundles/compiler/Parsing/ResponseDateValues.js.map +1 -1
  218. package/dist/bundles/compiler/Parsing/ResponseValidator.js +1 -1
  219. package/dist/bundles/compiler/Parsing/ResponseValidator.js.map +1 -1
  220. package/dist/bundles/compiler/Parsing/ScreenParser.js +1 -1
  221. package/dist/bundles/compiler/Parsing/ScreenParser.js.map +1 -1
  222. package/dist/bundles/compiler/Parsing/ScreenplayParser.js +1 -1
  223. package/dist/bundles/compiler/Parsing/ScreenplayParser.js.map +1 -1
  224. package/dist/bundles/compiler/Parsing/SeedParser.js +1 -1
  225. package/dist/bundles/compiler/Parsing/SeedParser.js.map +1 -1
  226. package/dist/bundles/compiler/Parsing/SliceParser.js +1 -1
  227. package/dist/bundles/compiler/Parsing/SliceParser.js.map +1 -1
  228. package/dist/bundles/compiler/Parsing/SourceLine.js.map +1 -1
  229. package/dist/bundles/compiler/Parsing/SourceLineSplitter.js.map +1 -1
  230. package/dist/bundles/compiler/Parsing/SourceOptionsParser.js +1 -1
  231. package/dist/bundles/compiler/Parsing/SourceOptionsParser.js.map +1 -1
  232. package/dist/bundles/compiler/Parsing/SpecificationCaseParser.js +1 -1
  233. package/dist/bundles/compiler/Parsing/SpecificationCaseParser.js.map +1 -1
  234. package/dist/bundles/compiler/Parsing/SpecificationCaseValidator.js +1 -1
  235. package/dist/bundles/compiler/Parsing/SpecificationCaseValidator.js.map +1 -1
  236. package/dist/bundles/compiler/Parsing/SpecificationCommandExamples.js +1 -1
  237. package/dist/bundles/compiler/Parsing/SpecificationCommandExamples.js.map +1 -1
  238. package/dist/bundles/compiler/Parsing/SpecificationExampleParser.js +1 -1
  239. package/dist/bundles/compiler/Parsing/SpecificationExampleParser.js.map +1 -1
  240. package/dist/bundles/compiler/Parsing/SpecificationParser.js +1 -1
  241. package/dist/bundles/compiler/Parsing/SpecificationParser.js.map +1 -1
  242. package/dist/bundles/compiler/Parsing/SpecificationRedeliveryValidator.js +1 -1
  243. package/dist/bundles/compiler/Parsing/SpecificationRedeliveryValidator.js.map +1 -1
  244. package/dist/bundles/compiler/Parsing/SpecificationResponseParser.js +1 -1
  245. package/dist/bundles/compiler/Parsing/SpecificationResponseParser.js.map +1 -1
  246. package/dist/bundles/compiler/Parsing/SpecificationRouteComparison.js +1 -1
  247. package/dist/bundles/compiler/Parsing/SpecificationRouteComparison.js.map +1 -1
  248. package/dist/bundles/compiler/Parsing/SpecificationStreamValidator.js +1 -1
  249. package/dist/bundles/compiler/Parsing/SpecificationStreamValidator.js.map +1 -1
  250. package/dist/bundles/compiler/Parsing/StateMachineParser.js +1 -1
  251. package/dist/bundles/compiler/Parsing/StateMachineParser.js.map +1 -1
  252. package/dist/bundles/compiler/Parsing/StructuralInteractionSites.js.map +1 -1
  253. package/dist/bundles/compiler/Parsing/StructuredBlockParser.js +1 -1
  254. package/dist/bundles/compiler/Parsing/StructuredBlockParser.js.map +1 -1
  255. package/dist/bundles/compiler/Parsing/StructuredValueParser.js.map +1 -1
  256. package/dist/bundles/compiler/Parsing/TemplateReferenceText.js +1 -1
  257. package/dist/bundles/compiler/Parsing/TemplateReferenceText.js.map +1 -1
  258. package/dist/bundles/compiler/Parsing/TriggerDataParser.js +1 -1
  259. package/dist/bundles/compiler/Parsing/TriggerDataParser.js.map +1 -1
  260. package/dist/bundles/compiler/Parsing/UiBindingParser.js +1 -1
  261. package/dist/bundles/compiler/Parsing/UiBindingParser.js.map +1 -1
  262. package/dist/bundles/compiler/Parsing/UiProfileLegacyLayout.js +1 -1
  263. package/dist/bundles/compiler/Parsing/UiProfileLegacyLayout.js.map +1 -1
  264. package/dist/bundles/compiler/Parsing/WorkflowParser.js +1 -1
  265. package/dist/bundles/compiler/Parsing/WorkflowParser.js.map +1 -1
  266. package/dist/bundles/compiler/Parsing/checkPortableMatchPattern.js.map +1 -1
  267. package/dist/bundles/compiler/Parsing/hasExponentialMatchAmbiguity.js.map +1 -1
  268. package/dist/bundles/compiler/Parsing/trimMatchAmbiguityGraph.js.map +1 -1
  269. package/dist/bundles/compiler/ScreenActionSubjects.js.map +1 -1
  270. package/dist/bundles/compiler/ScreenplayCompiler.js +1 -1
  271. package/dist/bundles/compiler/ScreenplayCompiler.js.map +1 -1
  272. package/dist/bundles/compiler/Syntax/ActionSubjectInvariants.js.map +1 -1
  273. package/dist/bundles/compiler/Syntax/AuthoringProductionResolver.js.map +1 -1
  274. package/dist/bundles/compiler/Syntax/CaptureEventsSource.js.map +1 -1
  275. package/dist/bundles/compiler/Syntax/DependencySources.js.map +1 -1
  276. package/dist/bundles/compiler/Syntax/EventDeclarations.js.map +1 -1
  277. package/dist/bundles/compiler/Syntax/EventSourceCatalog.js.map +1 -1
  278. package/dist/bundles/compiler/Syntax/EventSourceReadConfidence.js.map +1 -1
  279. package/dist/bundles/compiler/Syntax/ExactMathFacts.js.map +1 -1
  280. package/dist/bundles/compiler/Syntax/ExactNumber.js.map +1 -1
  281. package/dist/bundles/compiler/Syntax/InvalidSyntaxJson.js.map +1 -1
  282. package/dist/bundles/compiler/Syntax/LegacyWireProjection.js.map +1 -1
  283. package/dist/bundles/compiler/Syntax/Operations.js.map +1 -1
  284. package/dist/bundles/compiler/Syntax/PersonaCallers.js.map +1 -1
  285. package/dist/bundles/compiler/Syntax/ProductionDestinations.js.map +1 -1
  286. package/dist/bundles/compiler/Syntax/PublicEventInvariants.js.map +1 -1
  287. package/dist/bundles/compiler/Syntax/ScreenplaySyntaxWalker.js +1 -1
  288. package/dist/bundles/compiler/Syntax/ScreenplaySyntaxWalker.js.map +1 -1
  289. package/dist/bundles/compiler/Syntax/SourceOptions.js.map +1 -1
  290. package/dist/bundles/compiler/Syntax/SpecificationCaseOrigin.js.map +1 -1
  291. package/dist/bundles/compiler/Syntax/StreamIdFormatter.js.map +1 -1
  292. package/dist/bundles/compiler/Syntax/StrictSyntaxJson.js +1 -1
  293. package/dist/bundles/compiler/Syntax/Structure.js.map +1 -1
  294. package/dist/bundles/compiler/Syntax/SyntaxCollections.js +1 -1
  295. package/dist/bundles/compiler/Syntax/SyntaxCollections.js.map +1 -1
  296. package/dist/bundles/compiler/Syntax/SyntaxInvariants.js +1 -1
  297. package/dist/bundles/compiler/Syntax/SyntaxInvariants.js.map +1 -1
  298. package/dist/bundles/compiler/Syntax/SyntaxJson.js +1 -1
  299. package/dist/bundles/compiler/Syntax/SyntaxJson.js.map +1 -1
  300. package/dist/bundles/compiler/Syntax/SyntaxMemberContracts.js.map +1 -1
  301. package/dist/bundles/compiler/Syntax/index.js +1 -1
  302. package/dist/bundles/compiler/Text/ImplementationHintText.js.map +1 -1
  303. package/dist/bundles/compiler/Text/ReservedWords.js.map +1 -1
  304. package/dist/bundles/compiler/Text/SourceStreamNames.js.map +1 -1
  305. package/dist/bundles/compiler/Text/StringLiteral.js.map +1 -1
  306. package/dist/bundles/compiler/Text/ordinalIgnoreCaseKey.js.map +1 -1
  307. package/dist/bundles/compiler/Text/patterns.js.map +1 -1
  308. package/dist/bundles/compiler/index.js +1 -1
  309. package/dist/bundles/completion-items.js +18 -17
  310. package/dist/bundles/completion-items.js.map +1 -1
  311. package/dist/bundles/completion-planner.js +2 -2
  312. package/dist/bundles/completion-planner.js.map +1 -1
  313. package/dist/bundles/completions.js +1 -1
  314. package/dist/bundles/completions.js.map +1 -1
  315. package/dist/bundles/continuation-responses.js +1 -1
  316. package/dist/bundles/continuation-responses.js.map +1 -1
  317. package/dist/bundles/declarations.js.map +1 -1
  318. package/dist/bundles/dependency-completions.js.map +1 -1
  319. package/dist/bundles/dependency-target-analysis.js.map +1 -1
  320. package/dist/bundles/diagnostic-codes.js +1 -1
  321. package/dist/bundles/diagnostic-codes.js.map +1 -1
  322. package/dist/bundles/diagnostics.js +1 -1
  323. package/dist/bundles/diagnostics.js.map +1 -1
  324. package/dist/bundles/document-context.js.map +1 -1
  325. package/dist/bundles/documentation-item.js.map +1 -1
  326. package/dist/bundles/event-analysis-source.js.map +1 -1
  327. package/dist/bundles/event-context-catalog.js.map +1 -1
  328. package/dist/bundles/event-context.js.map +1 -1
  329. package/dist/bundles/event-source-authoring.js +11 -11
  330. package/dist/bundles/event-source-authoring.js.map +1 -1
  331. package/dist/bundles/example-analysis.js +2 -2
  332. package/dist/bundles/example-analysis.js.map +1 -1
  333. package/dist/bundles/example-authoring.js +2 -2
  334. package/dist/bundles/example-authoring.js.map +1 -1
  335. package/dist/bundles/example-declaration-items.js.map +1 -1
  336. package/dist/bundles/example-values.js.map +1 -1
  337. package/dist/bundles/file-imports.js.map +1 -1
  338. package/dist/bundles/file-references.js.map +1 -1
  339. package/dist/bundles/generation-completions.js.map +1 -1
  340. package/dist/bundles/hover-content.js +5 -5
  341. package/dist/bundles/hover-content.js.map +1 -1
  342. package/dist/bundles/hover.js.map +1 -1
  343. package/dist/bundles/index.js +1 -1
  344. package/dist/bundles/index.js.map +1 -1
  345. package/dist/bundles/inlay-hints.js.map +1 -1
  346. package/dist/bundles/inline-completions.js +1 -1
  347. package/dist/bundles/inline-completions.js.map +1 -1
  348. package/dist/bundles/inline-event-validation.js +1 -1
  349. package/dist/bundles/inline-event-validation.js.map +1 -1
  350. package/dist/bundles/keyword-docs.js +1 -1
  351. package/dist/bundles/keyword-docs.js.map +1 -1
  352. package/dist/bundles/language.js +1 -1
  353. package/dist/bundles/language.js.map +1 -1
  354. package/dist/bundles/named-rule-context.js.map +1 -1
  355. package/dist/bundles/operation-authoring.js +6 -6
  356. package/dist/bundles/operation-authoring.js.map +1 -1
  357. package/dist/bundles/persona-analysis.js +1 -1
  358. package/dist/bundles/persona-analysis.js.map +1 -1
  359. package/dist/bundles/production-destinations.js +1 -1
  360. package/dist/bundles/production-destinations.js.map +1 -1
  361. package/dist/bundles/purpose-items.js.map +1 -1
  362. package/dist/bundles/reaction-authoring.js +3 -3
  363. package/dist/bundles/reaction-authoring.js.map +1 -1
  364. package/dist/bundles/read-model-key-completions.js +1 -1
  365. package/dist/bundles/read-model-key-completions.js.map +1 -1
  366. package/dist/bundles/refusal-context.js.map +1 -1
  367. package/dist/bundles/response-analysis.js +1 -1
  368. package/dist/bundles/response-analysis.js.map +1 -1
  369. package/dist/bundles/response-completions.js +1 -1
  370. package/dist/bundles/response-completions.js.map +1 -1
  371. package/dist/bundles/response-tokens.js +2 -2
  372. package/dist/bundles/response-tokens.js.map +1 -1
  373. package/dist/bundles/scope-items.js +3 -3
  374. package/dist/bundles/scope-items.js.map +1 -1
  375. package/dist/bundles/structure-completions.js.map +1 -1
  376. package/dist/bundles/sub-language-registry.js.map +1 -1
  377. package/dist/bundles/sub-languages/capture/CompletionProvider.js.map +1 -1
  378. package/dist/bundles/sub-languages/capture/HoverProvider.js.map +1 -1
  379. package/dist/bundles/sub-languages/capture/Validator.js.map +1 -1
  380. package/dist/bundles/sub-languages/capture/index.js.map +1 -1
  381. package/dist/bundles/sub-languages/capture/language.js.map +1 -1
  382. package/dist/bundles/sub-languages/cdl.js.map +1 -1
  383. package/dist/bundles/sub-languages/pdl.js.map +1 -1
  384. package/dist/bundles/sub-languages/projection/CodeActionProvider.js.map +1 -1
  385. package/dist/bundles/sub-languages/projection/CompletionProvider.js +1 -1
  386. package/dist/bundles/sub-languages/projection/CompletionProvider.js.map +1 -1
  387. package/dist/bundles/sub-languages/projection/HoverProvider.js.map +1 -1
  388. package/dist/bundles/sub-languages/projection/Validator.js.map +1 -1
  389. package/dist/bundles/sub-languages/projection/index.js.map +1 -1
  390. package/dist/bundles/sub-languages/projection/language.js.map +1 -1
  391. package/dist/bundles/symbols.js +2 -2
  392. package/dist/bundles/symbols.js.map +1 -1
  393. package/dist/bundles/themes/screenplay-dark.js.map +1 -1
  394. package/dist/bundles/themes/screenplay-light.js.map +1 -1
  395. package/dist/bundles/tokens.js +1 -1
  396. package/dist/bundles/tokens.js.map +1 -1
  397. package/dist/bundles/validation.js +2 -2
  398. package/dist/bundles/validation.js.map +1 -1
  399. package/dist/completion-items.d.ts +1 -0
  400. package/dist/completion-items.d.ts.map +1 -1
  401. package/dist/completion-planner.d.ts.map +1 -1
  402. package/dist/diagnostic-codes.d.ts +6 -0
  403. package/dist/diagnostic-codes.d.ts.map +1 -1
  404. package/dist/keyword-docs.d.ts.map +1 -1
  405. package/dist/language.d.ts.map +1 -1
  406. package/dist/scope-items.d.ts.map +1 -1
  407. package/dist/tokens.d.ts.map +1 -1
  408. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"IdentityValidator.js","names":["details","application","names","detail","known","concept","type","imported","resolver","AuthoringProductionResolver","model","slice","projection","variants","block","name","variant","reducer","dependencySourcesOf","context","declared","DiagnosticCodes","identityProperties","source","parts","qualifiers","queries","entry","qualifier","index","query","authorizations","module","scope","policies","authorization","dependency","policy","expression","requirement","feature","features","segments","result","ScreenplaySyntaxWalker","syntax","property","diagnostic"],"sources":["../../../../../../Compiler/Parsing/IdentityValidator.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 { AuthorizeSyntax, PolicyRequirementSyntax } from '../Syntax/Authorization';\nimport { AuthoringProductionResolver } from '../Syntax/AuthoringProductionResolver';\nimport { dependencySourcesOf } from '../Syntax/DependencySources';\nimport { ExpressionSyntax, IdentityExpressionSyntax } from '../Syntax/Expressions';\nimport { ScreenplaySyntaxWalker } from '../Syntax/ScreenplaySyntaxWalker';\nimport { ApplicationSyntax, FeatureSyntax } from '../Syntax/Structure';\nimport { identityProperties } from './ExpressionParser';\nimport { ParserContext } from './ParserContext';\n\nexport function validateIdentity(application: ApplicationSyntax, context: ParserContext): void {\n const details = application.identity?.details ?? [];\n const names = new Set(details.map(detail => detail.name));\n const known = new Set(['Uuid', 'String', 'Int', 'Decimal', 'Bool', 'Date', 'DateTime', ...application.concepts.map(concept => concept.name), ...application.types.map(type => type.name), ...application.imports.map(imported => imported.qualifiedName.split('.').at(-1)!) ]);\n const resolver = new AuthoringProductionResolver(application);\n for (const { slice } of resolver.slices) {\n for (const model of slice.readModels) known.add(model.name);\n for (const projection of slice.projections) {\n // Match C# ProjectionBuiltReadModelNames: direct variants replace the builder's own output.\n const variants = projection.blocks.filter(block => block.kind === 'ProjectionVariantSyntax');\n for (const name of variants.length > 0 ? variants.map(variant => variant.name) : [projection.readModel ?? projection.name]) known.add(name);\n }\n for (const reducer of dependencySourcesOf(slice).reducers ?? []) known.add(reducer.readModel);\n }\n new IdentityPaths(names, context).visitApplication(application);\n const declared = new Set<string>();\n for (const detail of details) {\n if (declared.has(detail.name)) context.error(DiagnosticCodes.DuplicateIdentityDetail, `Duplicate identity detail '${detail.name}' - detail names must be unique`, detail.location);\n declared.add(detail.name);\n if (identityProperties.includes(detail.name)) context.error(DiagnosticCodes.BuiltInIdentityDetail, `Identity detail '${detail.name}' redeclares a built-in caller property`, detail.location);\n if (!known.has(detail.type.name)) context.warning(DiagnosticCodes.UnknownType, `Unknown type '${detail.type.name}' on identity detail '${detail.name}'`, detail.type.location);\n if (detail.source.kind !== 'QueryIdentitySourceSyntax') continue;\n const source = detail.source;\n if (!isTokenKey(source.by)) context.error(DiagnosticCodes.InvalidIdentityQueryKey, `Identity detail '${detail.name}' query key may reference only caller built-ins, claims or literals, never another detail`, source.by.location);\n const parts = source.query.split('.');\n const name = parts.at(-1)!;\n const qualifiers = parts.slice(0, -1);\n const queries = resolver.slices.flatMap(({ slice, scope }) => slice.queries.map(query => ({ query, scope }))).filter(entry => entry.query.name === name && qualifiers.length <= entry.scope.length && qualifiers.every((qualifier, index) => qualifier === entry.scope[entry.scope.length - qualifiers.length + index]));\n if (queries.length !== 1) {\n context.error(DiagnosticCodes.UnknownIdentityQuery, `Unknown or ambiguous identity query '${source.query}'`, source.location);\n continue;\n }\n const { query, scope } = queries[0];\n if (query.by === null || query.returnType.isCollection) context.error(DiagnosticCodes.InvalidIdentityQuery, `Identity query '${source.query}' must be keyed and return a single, possibly optional result`, source.location);\n if (query.returnType.name !== detail.type.name || detail.type.isCollection || query.returnType.isOptional && !detail.type.isOptional) context.error(DiagnosticCodes.IdentityQueryTypeMismatch, `Identity detail '${detail.name}' must match query '${source.query}' result type, including optionality`, detail.type.location);\n const authorizations: AuthorizeSyntax[] = query.authorize === null ? [] : [query.authorize];\n for (const module of application.modules.filter(module => module.name === scope[0])) {\n if (module.authorize !== null) authorizations.push(module.authorize);\n collectFeatureAuthorizations(module.features, scope.slice(1, -1), authorizations);\n }\n const policies = new Set(authorizations.flatMap(authorization => policyNames(authorization.requirement)));\n const dependency = new DetailReferences(names);\n for (const policy of (application.policies ?? []).filter(policy => policies.has(policy.name))) dependency.visitPolicy(policy);\n if (dependency.found.length > 0) context.error(DiagnosticCodes.IdentityQueryAuthorizationDependency, `Identity query '${source.query}' authorization depends on identity detail '${dependency.found[0].path.split('.')[0]}' - caller details cannot authorize their own resolution`, source.location);\n }\n}\n\nfunction isTokenKey(expression: ExpressionSyntax): boolean {\n if (expression.kind === 'LiteralExpressionSyntax') return true;\n if (expression.kind === 'IdentityExpressionSyntax') return identityProperties.includes(expression.path.split('.')[0]);\n return expression.kind === 'ContextExpressionSyntax' && expression.path.startsWith('identity.') && identityProperties.includes(expression.path.split('.')[1]);\n}\n\nfunction policyNames(requirement: PolicyRequirementSyntax): string[] {\n if (requirement.kind === 'PolicyReferenceSyntax') return [requirement.name];\n return [...policyNames(requirement.left), ...policyNames(requirement.right)];\n}\n\nfunction collectFeatureAuthorizations(features: readonly FeatureSyntax[], segments: readonly string[], result: AuthorizeSyntax[]): void {\n for (const feature of features.filter(feature => feature.name === segments[0])) {\n if (feature.authorize !== null) result.push(feature.authorize);\n collectFeatureAuthorizations(feature.features, segments.slice(1), result);\n }\n}\n\nclass IdentityPaths extends ScreenplaySyntaxWalker {\n constructor(private readonly details: ReadonlySet<string>, private readonly context: ParserContext) { super(); }\n override visitExpression(syntax: ExpressionSyntax): void {\n if (syntax.kind === 'ContextExpressionSyntax' && syntax.path.startsWith('identity.')) {\n const property = syntax.path.split('.')[1];\n if (!identityProperties.includes(property) && !this.context.diagnostics.some(diagnostic => diagnostic.code === DiagnosticCodes.UnknownContextIdentityProperty && diagnostic.location.line === syntax.location.line && diagnostic.location.column === syntax.location.column)) {\n this.context.warning(DiagnosticCodes.UnknownContextIdentityProperty, `Unknown $context.identity property '${property}' - expected ${identityProperties.join(', ')}`, syntax.location);\n }\n }\n super.visitExpression(syntax);\n }\n override visitIdentityExpression(syntax: IdentityExpressionSyntax): void {\n const property = syntax.path.split('.')[0];\n if (!this.details.has(property) && !identityProperties.includes(property)) this.context.warning(DiagnosticCodes.UnknownContextIdentityProperty, `Unknown $identity property '${property}' - expected ${[...identityProperties, ...this.details].join(', ')}`, syntax.location);\n }\n}\n\nclass DetailReferences extends ScreenplaySyntaxWalker {\n readonly found: IdentityExpressionSyntax[] = [];\n constructor(private readonly details: ReadonlySet<string>) { super(); }\n override visitIdentityExpression(syntax: IdentityExpressionSyntax): void {\n if (this.details.has(syntax.path.split('.')[0])) this.found.push(syntax);\n }\n}\n"],"mappings":"6ZAaA,SAAgB,iBAAiB,EAAgC,EAA8B,CAC3F,IAAMA,EAAUC,EAAY,UAAU,SAAW,CAAC,EAC5CC,EAAQ,IAAI,IAAIF,EAAQ,IAAI,GAAUG,EAAO,IAAI,CAAC,EAClDC,kBAAQ,IAAI,IAAI,CAAC,OAAQ,SAAU,MAAO,UAAW,OAAQ,OAAQ,WAAY,GAAGH,EAAY,SAAS,IAAI,GAAWI,EAAQ,IAAI,EAAG,GAAGJ,EAAY,MAAM,IAAI,GAAQK,EAAK,IAAI,EAAG,GAAGL,EAAY,QAAQ,IAAI,GAAYM,EAAS,cAAc,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,CAAE,CAAE,CAAC,EACvQC,EAAW,IAAIC,EAA4BR,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WAAW,EAAG,CAClF,IAAMC,EAAWD,EAAO,KAAK,MAAM,GAAG,CAAC,CAAC,GACpC,CAACvB,EAAmB,SAASwB,CAAQ,GAAK,CAAC,KAAK,QAAQ,YAAY,KAAK,GAAcC,EAAW,OAAS1B,EAAgB,gCAAkC0B,EAAW,SAAS,OAASF,EAAO,SAAS,MAAQE,EAAW,SAAS,SAAWF,EAAO,SAAS,MAAM,GACvQ,KAAK,QAAQ,QAAQxB,EAAgB,+BAAgC,uCAAuCyB,EAAS,eAAexB,EAAmB,KAAK,IAAI,IAAKuB,EAAO,QAAQ,CAE5L,CACA,MAAM,gBAAgBA,CAAM,CAChC,CACA,wBAAiC,EAAwC,CACrE,IAAMC,EAAWD,EAAO,KAAK,MAAM,GAAG,CAAC,CAAC,GACpC,CAAC,KAAK,QAAQ,IAAIC,CAAQ,GAAK,CAACxB,EAAmB,SAASwB,CAAQ,GAAG,KAAK,QAAQ,QAAQzB,EAAgB,+BAAgC,+BAA+ByB,EAAS,eAAe,CAAC,GAAGxB,EAAoB,GAAG,KAAK,OAAO,CAAC,CAAC,KAAK,IAAI,IAAKuB,EAAO,QAAQ,CACjR,CACJ,EAEM,iBAAN,cAA+BD,CAAuB,CAErB,QAD7B,MAA6C,CAAC,EAC9C,YAAY,EAA+C,CAAE,MAAM,EAAtC,KAAA,QAAA5C,CAAyC,CACtE,wBAAiC,EAAwC,CACjE,KAAK,QAAQ,IAAI6C,EAAO,KAAK,MAAM,GAAG,CAAC,CAAC,EAAE,GAAG,KAAK,MAAM,KAAKA,CAAM,CAC3E,CACJ"}
1
+ {"version":3,"file":"IdentityValidator.js","names":["details","application","names","detail","known","concept","type","imported","resolver","AuthoringProductionResolver","model","slice","projection","variants","block","name","variant","reducer","dependencySourcesOf","context","declared","DiagnosticCodes","identityProperties","source","parts","qualifiers","queries","entry","qualifier","index","query","authorizations","module","scope","policies","authorization","dependency","policy","expression","requirement","feature","features","segments","result","ScreenplaySyntaxWalker","syntax","property","diagnostic"],"sources":["../../../../../../Compiler/Parsing/IdentityValidator.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 { AuthorizeSyntax, PolicyRequirementSyntax } from '../Syntax/Authorization';\nimport { AuthoringProductionResolver } from '../Syntax/AuthoringProductionResolver';\nimport { dependencySourcesOf } from '../Syntax/DependencySources';\nimport { ExpressionSyntax, IdentityExpressionSyntax } from '../Syntax/Expressions';\nimport { ScreenplaySyntaxWalker } from '../Syntax/ScreenplaySyntaxWalker';\nimport { ApplicationSyntax, FeatureSyntax } from '../Syntax/Structure';\nimport { identityProperties } from './ExpressionParser';\nimport { ParserContext } from './ParserContext';\n\nexport function validateIdentity(application: ApplicationSyntax, context: ParserContext): void {\n const details = application.identity?.details ?? [];\n const names = new Set(details.map(detail => detail.name));\n const known = new Set(['Uuid', 'String', 'Int', 'Decimal', 'Bool', 'Date', 'DateTime', ...application.concepts.map(concept => concept.name), ...application.types.map(type => type.name), ...application.imports.map(imported => imported.qualifiedName.split('.').at(-1)!) ]);\n const resolver = new AuthoringProductionResolver(application);\n for (const { slice } of resolver.slices) {\n for (const model of slice.readModels) known.add(model.name);\n for (const projection of slice.projections) {\n // Match C# ProjectionBuiltReadModelNames: direct variants replace the builder's own output.\n const variants = projection.blocks.filter(block => block.kind === 'ProjectionVariantSyntax');\n for (const name of variants.length > 0 ? variants.map(variant => variant.name) : [projection.readModel ?? projection.name]) known.add(name);\n }\n for (const reducer of dependencySourcesOf(slice).reducers ?? []) known.add(reducer.readModel);\n }\n new IdentityPaths(names, context).visitApplication(application);\n const declared = new Set<string>();\n for (const detail of details) {\n if (declared.has(detail.name)) context.error(DiagnosticCodes.DuplicateIdentityDetail, `Duplicate identity detail '${detail.name}' - detail names must be unique`, detail.location);\n declared.add(detail.name);\n if (identityProperties.includes(detail.name)) context.error(DiagnosticCodes.BuiltInIdentityDetail, `Identity detail '${detail.name}' redeclares a built-in caller property`, detail.location);\n if (!known.has(detail.type.name)) context.warning(DiagnosticCodes.UnknownType, `Unknown type '${detail.type.name}' on identity detail '${detail.name}'`, detail.type.location);\n if (detail.source.kind !== 'QueryIdentitySourceSyntax') continue;\n const source = detail.source;\n if (!isTokenKey(source.by)) context.error(DiagnosticCodes.InvalidIdentityQueryKey, `Identity detail '${detail.name}' query key may reference only caller built-ins, claims or literals, never another detail`, source.by.location);\n const parts = source.query.split('.');\n const name = parts.at(-1)!;\n const qualifiers = parts.slice(0, -1);\n const queries = resolver.slices.flatMap(({ slice, scope }) => slice.queries.map(query => ({ query, scope }))).filter(entry => entry.query.name === name && qualifiers.length <= entry.scope.length && qualifiers.every((qualifier, index) => qualifier === entry.scope[entry.scope.length - qualifiers.length + index]));\n if (queries.length !== 1) {\n context.error(DiagnosticCodes.UnknownIdentityQuery, `Unknown or ambiguous identity query '${source.query}'`, source.location);\n continue;\n }\n const { query, scope } = queries[0];\n if (query.by === null || query.returnType.isCollection) context.error(DiagnosticCodes.InvalidIdentityQuery, `Identity query '${source.query}' must be keyed and return a single, possibly optional result`, source.location);\n if (query.returnType.name !== detail.type.name || detail.type.isCollection || query.returnType.isOptional && !detail.type.isOptional) context.error(DiagnosticCodes.IdentityQueryTypeMismatch, `Identity detail '${detail.name}' must match query '${source.query}' result type, including optionality`, detail.type.location);\n const authorizations: AuthorizeSyntax[] = query.authorize === null ? [] : [query.authorize];\n for (const module of application.modules.filter(module => module.name === scope[0])) {\n if (module.authorize !== null) authorizations.push(module.authorize);\n collectFeatureAuthorizations(module.features, scope.slice(1, -1), authorizations);\n }\n const policies = new Set(authorizations.flatMap(authorization => policyNames(authorization.requirement)));\n const dependency = new DetailReferences(names);\n for (const policy of (application.policies ?? []).filter(policy => policies.has(policy.name))) dependency.visitPolicy(policy);\n if (dependency.found.length > 0) context.error(DiagnosticCodes.IdentityQueryAuthorizationDependency, `Identity query '${source.query}' authorization depends on identity detail '${dependency.found[0].path.split('.')[0]}' - caller details cannot authorize their own resolution`, source.location);\n }\n}\n\nfunction isTokenKey(expression: ExpressionSyntax): boolean {\n if (expression.kind === 'LiteralExpressionSyntax') return true;\n if (expression.kind === 'IdentityExpressionSyntax') return identityProperties.includes(expression.path.split('.')[0]);\n return expression.kind === 'ContextExpressionSyntax' && expression.path.startsWith('identity.') && identityProperties.includes(expression.path.split('.')[1]);\n}\n\nfunction policyNames(requirement: PolicyRequirementSyntax): string[] {\n if (requirement.kind === 'PolicyReferenceSyntax') return [requirement.name];\n return [...policyNames(requirement.left), ...policyNames(requirement.right)];\n}\n\nfunction collectFeatureAuthorizations(features: readonly FeatureSyntax[], segments: readonly string[], result: AuthorizeSyntax[]): void {\n for (const feature of features.filter(feature => feature.name === segments[0])) {\n if (feature.authorize !== null) result.push(feature.authorize);\n collectFeatureAuthorizations(feature.features, segments.slice(1), result);\n }\n}\n\nclass IdentityPaths extends ScreenplaySyntaxWalker {\n constructor(private readonly details: ReadonlySet<string>, private readonly context: ParserContext) { super(); }\n override visitExpression(syntax: ExpressionSyntax): void {\n if (syntax.kind === 'ContextExpressionSyntax' && syntax.path.startsWith('identity.')) {\n const property = syntax.path.split('.')[1];\n if (!identityProperties.includes(property) && !this.context.diagnostics.some(diagnostic => diagnostic.code === DiagnosticCodes.UnknownContextIdentityProperty && diagnostic.location.line === syntax.location.line && diagnostic.location.column === syntax.location.column)) {\n this.context.warning(DiagnosticCodes.UnknownContextIdentityProperty, `Unknown $context.identity property '${property}' - expected ${identityProperties.join(', ')}`, syntax.location);\n }\n }\n super.visitExpression(syntax);\n }\n override visitIdentityExpression(syntax: IdentityExpressionSyntax): void {\n const property = syntax.path.split('.')[0];\n if (!this.details.has(property) && !identityProperties.includes(property)) this.context.warning(DiagnosticCodes.UnknownContextIdentityProperty, `Unknown $identity property '${property}' - expected ${[...identityProperties, ...this.details].join(', ')}`, syntax.location);\n }\n}\n\nclass DetailReferences extends ScreenplaySyntaxWalker {\n readonly found: IdentityExpressionSyntax[] = [];\n constructor(private readonly details: ReadonlySet<string>) { super(); }\n override visitIdentityExpression(syntax: IdentityExpressionSyntax): void {\n if (this.details.has(syntax.path.split('.')[0])) this.found.push(syntax);\n }\n}\n"],"mappings":"A,6ZAaA,SAAgB,iBAAiB,EAAgC,EAA8B,CAC3F,IAAMA,EAAUC,EAAY,UAAU,SAAW,CAAC,EAC5CC,EAAQ,IAAI,IAAIF,EAAQ,IAAI,GAAUG,EAAO,IAAI,CAAC,EAClDC,kBAAQ,IAAI,IAAI,CAAC,OAAQ,SAAU,MAAO,UAAW,OAAQ,OAAQ,WAAY,GAAGH,EAAY,SAAS,IAAI,GAAWI,EAAQ,IAAI,EAAG,GAAGJ,EAAY,MAAM,IAAI,GAAQK,EAAK,IAAI,EAAG,GAAGL,EAAY,QAAQ,IAAI,GAAYM,EAAS,cAAc,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,CAAE,CAAE,CAAC,EACvQC,EAAW,IAAIC,EAA4BR,CAAW,EAC5D,IAAK,GAAM,CAAE,WAAWO,EAAS,OAAQ,CACrC,IAAK,IAAME,KAASC,EAAM,WAAYP,EAAM,IAAIM,EAAM,IAAI,EAC1D,IAAK,IAAME,KAAcD,EAAM,YAAa,CAExC,IAAME,EAAWD,EAAW,OAAO,OAAO,GAASE,EAAM,OAAS,yBAAyB,EAC3F,IAAK,IAAMC,KAAQF,EAAS,OAAS,EAAIA,EAAS,IAAI,GAAWG,EAAQ,IAAI,EAAI,CAACJ,EAAW,WAAaA,EAAW,IAAI,EAAGR,EAAM,IAAIW,CAAI,CAC9I,CACA,IAAK,IAAME,KAAWC,EAAoBP,CAAK,CAAC,CAAC,UAAY,CAAC,EAAGP,EAAM,IAAIa,EAAQ,SAAS,CAChG,CACA,IAAI,cAAcf,EAAOiB,CAAO,CAAC,CAAC,iBAAiBlB,CAAW,EAC9D,IAAMmB,kBAAW,IAAI,IACrB,IAAK,IAAMjB,KAAUH,EAAS,CAK1B,GAJIoB,EAAS,IAAIjB,EAAO,IAA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B,EAAoB,GAAG,KAAK,OAAO,CAAC,CAAC,KAAK,IAAI,IAAKuB,EAAO,QAAQ,CACjR,CACJ,EAEM,iBAAN,cAA+BD,CAAuB,CAErB,QAD7B,MAA6C,CAAC,EAC9C,YAAY,EAA+C,CAAE,MAAM,EAAtC,KAAA,QAAA5C,CAAyC,CACtE,wBAAiC,EAAwC,CACjE,KAAK,QAAQ,IAAI6C,EAAO,KAAK,MAAM,GAAG,CAAC,CAAC,EAAE,GAAG,KAAK,MAAM,KAAKA,CAAM,CAC3E,CACJ,E"}
@@ -1,3 +1,3 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{unescapeString as t}from"../Text/StringLiteral.js";import{locationOf as n}from"./SourceLine.js";import{firstWord as r}from"./LineText.js";import{isBlankImplementationHint as i}from"../Text/ImplementationHintText.js";import{parsePossibleEvents as a}from"./PossibleEventsParser.js";const o=/* @__PURE__ */ RegExp(`^hint[\\u0009-\\u000d\\u0020\\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]+"((?:[^"\\\\\\r\\n]|\\\\[^\\r\\n])*)"$`),isFile=e=>r(e.content)===`file`&&e.content.substring(4).trim().length>0,isCode=(e,t)=>t.content.startsWith("```")||e.languages.has(t.content);function parseFile(t,r){let i=r.content.substring(4).trim();return/^(?:[/\\]|[A-Za-z]:[/\\]|~[/\\])/.test(i)&&t.warning(e.AbsoluteFileReference,`'${i}' is an absolute path - a file reference is relative to the repository root, so it means the same thing on every machine`,n(r)),{kind:`FileReferenceSyntax`,path:i,location:n(r)}}const isClosingCodeFence=e=>e.raw.trim()==="```";function parseCode(t,r){let i=r.content.startsWith("```")?r.content.substring(3):r.content;if(!t.languages.has(i))return t.error(e.ExpectedCodeFence,`Expected a registered language on the opening fence, not '${r.content}'`,n(r)),null;let a=r;if(!r.content.startsWith("```")){t.warning(e.LegacyInlineCodeFence,`'${i}' on its own line is deprecated - use '\`\`\`${i}' instead`,n(r));let o=t.reader.peekSignificant();if(o===void 0||o.indent<=r.indent||o.content!=="```"&&o.content!==`\`\`\`${i}`)return t.error(e.ExpectedCodeFence,`Expected an opening \`\`\`${i} fence after '${i}'`,n(r)),null;a=t.reader.takeSignificant()}let o=[];for(;;){let r=t.reader.takeRaw();if(r===void 0){t.error(e.UnclosedCodeBlock,"Unclosed inline code block - expected a closing ``` line",n(a));break}if(isClosingCodeFence(r))break;let i=0;for(;i<a.indent&&r.raw[i]===` `;)i++;o.push(r.raw.substring(i))}return{kind:`CodeBlockSyntax`,language:i,code:o.join(`
2
- `),location:n(r)}}function parseHandler(e,t){let n=e.peekChild(t.indent)?.content===`may produce`?a(e,e.reader.takeSignificant()):null,r=parseHandlerBody(e,t);return r===null||n===null?r:{...r,possibleEvents:n}}function parseHandlerBody(t,i){let a=t.peekChild(i.indent);if(a===void 0)return t.error(e.HandlerWithoutImplementation,`Expected a 'file' directive or an inline code block in the handler`,n(i)),null;if(t.reader.takeSignificant(),r(a.content)===`implementation`)return parseImplementation(t,i,a);let o=isFile(a)?parseFile(t,a):null,s=o===null&&isCode(t,a)?parseCode(t,a):null;if(o!==null||s!==null){let a=t.peekChild(i.indent);return a!==void 0&&r(a.content)===`implementation`&&(t.error(e.ConflictingImplementationSources,`A handler cannot mix wrapped and direct sources.`,n(a)),t.skipBlock(i.indent)),{kind:`HandlerSyntax`,file:o,code:s,implementation:null,location:n(i)}}return t.error(e.UnknownHandlerDirective,`Unexpected '${a.content}' in handler - expected 'file <path>' or an inline code block`,n(a)),t.skipBlock(i.indent),null}function parseImplementation(t,i,a){let o=parseImplementationWrapper(t,a);for(let a=t.peekChild(i.indent);a!==void 0;a=t.peekChild(i.indent))t.reader.takeSignificant(),t.error(r(a.content)===`implementation`?e.InvalidImplementationBlock:e.ConflictingImplementationSources,`A handler has one implementation wrapper and cannot mix wrapped and direct sources.`,n(a)),isCode(t,a)?parseCode(t,a):t.skipBlock(a.indent);return{kind:`HandlerSyntax`,...o,location:n(i)}}function parseImplementationWrapper(a,s){let c=[],l=null,u=null,d=!1;s.content!==`implementation`&&a.error(e.InvalidImplementationBlock,`Expected 'implementation' with no operand.`,n(s));for(let f=a.peekChild(s.indent);f!==void 0;f=a.peekChild(s.indent))if(a.reader.takeSignificant(),r(f.content)===`hint`||o.test(f.content)){let r=o.exec(f.content),s=r===null?null:t(r[1]);i(s)?a.error(e.InvalidImplementationHint,`Expected 'hint' followed by one nonblank quoted string.`,n(f)):c.push({kind:`ImplementationHintSyntax`,text:s,location:n(f)});let l=a.peekChild(f.indent);l!==void 0&&(a.error(e.InvalidImplementationHint,`A hint cannot have children.`,n(l)),a.skipBlock(f.indent))}else if(isFile(f)||f.content.startsWith("```")){d&&a.error(e.ConflictingImplementationSources,`An implementation has at most one file or inline payload.`,n(f));let t=isFile(f)?parseFile(a,f):null,r=t===null?parseCode(a,f):null;d||(l=t,u=r),d=!0;let i=a.peekChild(f.indent);t!==null&&i!==void 0&&(a.error(e.InvalidImplementationBlock,`A file directive cannot have children.`,n(i)),a.skipBlock(f.indent))}else a.error(e.InvalidImplementationBlock,`Unexpected '${f.content}' in implementation - expected hint, file or a tagged fence.`,n(f)),a.skipBlock(f.indent);return{file:l,code:u,implementation:{kind:`ImplementationSyntax`,hints:c,location:n(s)}}}export{isClosingCodeFence,isCode,isFile,parseCode,parseFile,parseHandler,parseImplementationWrapper};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{isBlankImplementationHint as t}from"../Text/ImplementationHintText.js";import{unescapeString as n}from"../Text/StringLiteral.js";import{firstWord as r}from"./LineText.js";import{parsePossibleEvents as i}from"./PossibleEventsParser.js";import{locationOf as a}from"./SourceLine.js";const o=/* @__PURE__ */ RegExp(`^hint[\\u0009-\\u000d\\u0020\\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]+"((?:[^"\\\\\\r\\n]|\\\\[^\\r\\n])*)"$`),isFile=e=>r(e.content)===`file`&&e.content.substring(4).trim().length>0,isCode=(e,t)=>t.content.startsWith("```")||e.languages.has(t.content);function parseFile(t,n){let r=n.content.substring(4).trim();return/^(?:[/\\]|[A-Za-z]:[/\\]|~[/\\])/.test(r)&&t.warning(e.AbsoluteFileReference,`'${r}' is an absolute path - a file reference is relative to the repository root, so it means the same thing on every machine`,a(n)),{kind:`FileReferenceSyntax`,path:r,location:a(n)}}const isClosingCodeFence=e=>e.raw.trim()==="```";function parseCode(t,n){let r=n.content.startsWith("```")?n.content.substring(3):n.content;if(!t.languages.has(r))return t.error(e.ExpectedCodeFence,`Expected a registered language on the opening fence, not '${n.content}'`,a(n)),null;let i=n;if(!n.content.startsWith("```")){t.warning(e.LegacyInlineCodeFence,`'${r}' on its own line is deprecated - use '\`\`\`${r}' instead`,a(n));let o=t.reader.peekSignificant();if(o===void 0||o.indent<=n.indent||o.content!=="```"&&o.content!==`\`\`\`${r}`)return t.error(e.ExpectedCodeFence,`Expected an opening \`\`\`${r} fence after '${r}'`,a(n)),null;i=t.reader.takeSignificant()}let o=[];for(;;){let n=t.reader.takeRaw();if(n===void 0){t.error(e.UnclosedCodeBlock,"Unclosed inline code block - expected a closing ``` line",a(i));break}if(isClosingCodeFence(n))break;let r=0;for(;r<i.indent&&n.raw[r]===` `;)r++;o.push(n.raw.substring(r))}return{kind:`CodeBlockSyntax`,language:r,code:o.join(`
2
+ `),location:a(n)}}function parseHandler(e,t){let n=e.peekChild(t.indent)?.content===`may produce`?i(e,e.reader.takeSignificant()):null,r=parseHandlerBody(e,t);return r===null||n===null?r:{...r,possibleEvents:n}}function parseHandlerBody(t,n){let i=t.peekChild(n.indent);if(i===void 0)return t.error(e.HandlerWithoutImplementation,`Expected a 'file' directive or an inline code block in the handler`,a(n)),null;if(t.reader.takeSignificant(),r(i.content)===`implementation`)return parseImplementation(t,n,i);let o=isFile(i)?parseFile(t,i):null,s=o===null&&isCode(t,i)?parseCode(t,i):null;if(o!==null||s!==null){let i=t.peekChild(n.indent);return i!==void 0&&r(i.content)===`implementation`&&(t.error(e.ConflictingImplementationSources,`A handler cannot mix wrapped and direct sources.`,a(i)),t.skipBlock(n.indent)),{kind:`HandlerSyntax`,file:o,code:s,implementation:null,location:a(n)}}return t.error(e.UnknownHandlerDirective,`Unexpected '${i.content}' in handler - expected 'file <path>' or an inline code block`,a(i)),t.skipBlock(n.indent),null}function parseImplementation(t,n,i){let o=parseImplementationWrapper(t,i);for(let i=t.peekChild(n.indent);i!==void 0;i=t.peekChild(n.indent))t.reader.takeSignificant(),t.error(r(i.content)===`implementation`?e.InvalidImplementationBlock:e.ConflictingImplementationSources,`A handler has one implementation wrapper and cannot mix wrapped and direct sources.`,a(i)),isCode(t,i)?parseCode(t,i):t.skipBlock(i.indent);return{kind:`HandlerSyntax`,...o,location:a(n)}}function parseImplementationWrapper(i,s){let c=[],l=null,u=null,d=!1;s.content!==`implementation`&&i.error(e.InvalidImplementationBlock,`Expected 'implementation' with no operand.`,a(s));for(let f=i.peekChild(s.indent);f!==void 0;f=i.peekChild(s.indent))if(i.reader.takeSignificant(),r(f.content)===`hint`||o.test(f.content)){let r=o.exec(f.content),s=r===null?null:n(r[1]);t(s)?i.error(e.InvalidImplementationHint,`Expected 'hint' followed by one nonblank quoted string.`,a(f)):c.push({kind:`ImplementationHintSyntax`,text:s,location:a(f)});let l=i.peekChild(f.indent);l!==void 0&&(i.error(e.InvalidImplementationHint,`A hint cannot have children.`,a(l)),i.skipBlock(f.indent))}else if(isFile(f)||f.content.startsWith("```")){d&&i.error(e.ConflictingImplementationSources,`An implementation has at most one file or inline payload.`,a(f));let t=isFile(f)?parseFile(i,f):null,n=t===null?parseCode(i,f):null;d||(l=t,u=n),d=!0;let r=i.peekChild(f.indent);t!==null&&r!==void 0&&(i.error(e.InvalidImplementationBlock,`A file directive cannot have children.`,a(r)),i.skipBlock(f.indent))}else i.error(e.InvalidImplementationBlock,`Unexpected '${f.content}' in implementation - expected hint, file or a tagged fence.`,a(f)),i.skipBlock(f.indent);return{file:l,code:u,implementation:{kind:`ImplementationSyntax`,hints:c,location:a(s)}}}export{isClosingCodeFence,isCode,isFile,parseCode,parseFile,parseHandler,parseImplementationWrapper};
3
3
  //# sourceMappingURL=ImplementationParser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ImplementationParser.js","names":["hintPattern","firstWord","line","context","path","DiagnosticCodes","locationOf","language","tag","open","next","lines","strip","possibleEvents","handler","parsePossibleEvents","parsed","body","file","code","extra","source","wrapper","hints","hasPayload","child","match","text","unescapeString","isBlankImplementationHint","nested","parsedFile","parsedCode"],"sources":["../../../../../../Compiler/Parsing/ImplementationParser.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 { CodeBlockSyntax, FileReferenceSyntax, HandlerSyntax, ImplementationHintSyntax, ImplementationSyntax } from '../Syntax/Implementations';\nimport { isBlankImplementationHint } from '../Text/ImplementationHintText';\nimport { unescapeString } from '../Text/StringLiteral';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { parsePossibleEvents } from './PossibleEventsParser';\nimport { locationOf, SourceLine } from './SourceLine';\n\n// Match ImplementationHintText's White_Space set, not ECMAScript \\s. A hint stays on one CR/LF-delimited source line.\n// eslint-disable-next-line no-control-regex -- The shared whitespace set deliberately includes U+0009 through U+000D.\nconst hintPattern = new RegExp('^hint[\\\\u0009-\\\\u000d\\\\u0020\\\\u0085\\\\u00a0\\\\u1680\\\\u2000-\\\\u200a\\\\u2028\\\\u2029\\\\u202f\\\\u205f\\\\u3000]+\"((?:[^\"\\\\\\\\\\\\r\\\\n]|\\\\\\\\[^\\\\r\\\\n])*)\"$');\nexport const isFile = (line: SourceLine): boolean => firstWord(line.content) === 'file' && line.content.substring(4).trim().length > 0;\nexport const isCode = (context: ParserContext, line: SourceLine): boolean => line.content.startsWith('```') || context.languages.has(line.content);\n\nexport function parseFile(context: ParserContext, line: SourceLine): FileReferenceSyntax {\n const path = line.content.substring(4).trim();\n if (/^(?:[/\\\\]|[A-Za-z]:[/\\\\]|~[/\\\\])/.test(path)) {\n context.warning(DiagnosticCodes.AbsoluteFileReference, `'${path}' is an absolute path - a file reference is relative to the repository root, so it means the same thing on every machine`, locationOf(line));\n }\n return { kind: 'FileReferenceSyntax', path, location: locationOf(line) };\n}\n\nexport const isClosingCodeFence = (line: SourceLine): boolean => line.raw.trim() === '```';\n\nexport function parseCode(context: ParserContext, tag: SourceLine): CodeBlockSyntax | null {\n const language = tag.content.startsWith('```') ? tag.content.substring(3) : tag.content;\n if (!context.languages.has(language)) {\n context.error(DiagnosticCodes.ExpectedCodeFence, `Expected a registered language on the opening fence, not '${tag.content}'`, locationOf(tag));\n return null;\n }\n let open = tag;\n if (!tag.content.startsWith('```')) {\n context.warning(DiagnosticCodes.LegacyInlineCodeFence, `'${language}' on its own line is deprecated - use '\\`\\`\\`${language}' instead`, locationOf(tag));\n const next = context.reader.peekSignificant();\n if (next === undefined || next.indent <= tag.indent || (next.content !== '```' && next.content !== `\\`\\`\\`${language}`)) {\n context.error(DiagnosticCodes.ExpectedCodeFence, `Expected an opening \\`\\`\\`${language} fence after '${language}'`, locationOf(tag));\n return null;\n }\n open = context.reader.takeSignificant();\n }\n const lines: string[] = [];\n for (;;) {\n const line = context.reader.takeRaw();\n if (line === undefined) {\n context.error(DiagnosticCodes.UnclosedCodeBlock, 'Unclosed inline code block - expected a closing ``` line', locationOf(open));\n break;\n }\n if (isClosingCodeFence(line)) break;\n let strip = 0;\n while (strip < open.indent && line.raw[strip] === ' ') strip++;\n lines.push(line.raw.substring(strip));\n }\n return { kind: 'CodeBlockSyntax', language, code: lines.join('\\n'), location: locationOf(tag) };\n}\n\nexport function parseHandler(context: ParserContext, handler: SourceLine): HandlerSyntax | null {\n const first = context.peekChild(handler.indent);\n const possibleEvents = first?.content === 'may produce' ? parsePossibleEvents(context, context.reader.takeSignificant()!) : null;\n const parsed = parseHandlerBody(context, handler);\n return parsed === null || possibleEvents === null ? parsed : { ...parsed, possibleEvents };\n}\n\nfunction parseHandlerBody(context: ParserContext, handler: SourceLine): HandlerSyntax | null {\n const body = context.peekChild(handler.indent);\n if (body === undefined) {\n context.error(DiagnosticCodes.HandlerWithoutImplementation, \"Expected a 'file' directive or an inline code block in the handler\", locationOf(handler));\n return null;\n }\n context.reader.takeSignificant();\n if (firstWord(body.content) === 'implementation') return parseImplementation(context, handler, body);\n const file = isFile(body) ? parseFile(context, body) : null;\n const code = file === null && isCode(context, body) ? parseCode(context, body) : null;\n if (file !== null || code !== null) {\n const extra = context.peekChild(handler.indent);\n if (extra !== undefined && firstWord(extra.content) === 'implementation') {\n context.error(DiagnosticCodes.ConflictingImplementationSources, 'A handler cannot mix wrapped and direct sources.', locationOf(extra));\n context.skipBlock(handler.indent);\n }\n return { kind: 'HandlerSyntax', file, code, implementation: null, location: locationOf(handler) };\n }\n context.error(DiagnosticCodes.UnknownHandlerDirective, `Unexpected '${body.content}' in handler - expected 'file <path>' or an inline code block`, locationOf(body));\n context.skipBlock(handler.indent);\n return null;\n}\n\nfunction parseImplementation(context: ParserContext, handler: SourceLine, wrapper: SourceLine): HandlerSyntax {\n const source = parseImplementationWrapper(context, wrapper);\n for (let extra = context.peekChild(handler.indent); extra !== undefined; extra = context.peekChild(handler.indent)) {\n context.reader.takeSignificant();\n context.error(firstWord(extra.content) === 'implementation' ? DiagnosticCodes.InvalidImplementationBlock : DiagnosticCodes.ConflictingImplementationSources,\n 'A handler has one implementation wrapper and cannot mix wrapped and direct sources.', locationOf(extra));\n if (isCode(context, extra)) parseCode(context, extra);\n else context.skipBlock(extra.indent);\n }\n return { kind: 'HandlerSyntax', ...source, location: locationOf(handler) };\n}\n\nexport function parseImplementationWrapper(context: ParserContext, wrapper: SourceLine): { file: FileReferenceSyntax | null; code: CodeBlockSyntax | null; implementation: ImplementationSyntax } {\n const hints: ImplementationHintSyntax[] = [];\n let file: FileReferenceSyntax | null = null;\n let code: CodeBlockSyntax | null = null;\n let hasPayload = false;\n if (wrapper.content !== 'implementation') context.error(DiagnosticCodes.InvalidImplementationBlock, \"Expected 'implementation' with no operand.\", locationOf(wrapper));\n for (let child = context.peekChild(wrapper.indent); child !== undefined; child = context.peekChild(wrapper.indent)) {\n context.reader.takeSignificant();\n if (firstWord(child.content) === 'hint' || hintPattern.test(child.content)) {\n const match = hintPattern.exec(child.content);\n const text = match === null ? null : unescapeString(match[1]);\n if (isBlankImplementationHint(text)) context.error(DiagnosticCodes.InvalidImplementationHint, \"Expected 'hint' followed by one nonblank quoted string.\", locationOf(child));\n else hints.push({ kind: 'ImplementationHintSyntax', text: text!, location: locationOf(child) });\n const nested = context.peekChild(child.indent);\n if (nested !== undefined) {\n context.error(DiagnosticCodes.InvalidImplementationHint, 'A hint cannot have children.', locationOf(nested));\n context.skipBlock(child.indent);\n }\n } else if (isFile(child) || child.content.startsWith('```')) {\n if (hasPayload) context.error(DiagnosticCodes.ConflictingImplementationSources, 'An implementation has at most one file or inline payload.', locationOf(child));\n const parsedFile = isFile(child) ? parseFile(context, child) : null;\n const parsedCode = parsedFile === null ? parseCode(context, child) : null;\n if (!hasPayload) { file = parsedFile; code = parsedCode; }\n hasPayload = true;\n const nested = context.peekChild(child.indent);\n if (parsedFile !== null && nested !== undefined) {\n context.error(DiagnosticCodes.InvalidImplementationBlock, 'A file directive cannot have children.', locationOf(nested));\n context.skipBlock(child.indent);\n }\n } else {\n context.error(DiagnosticCodes.InvalidImplementationBlock, `Unexpected '${child.content}' in implementation - expected hint, file or a tagged fence.`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n return { file, code, implementation: { kind: 'ImplementationSyntax', hints, location: locationOf(wrapper) } };\n}\n"],"mappings":"wZAcA,MAAMA,EAAc,gBAAI,OAAO,6IAA6I,EAC/J,OAAU,GAA8BC,EAAUC,EAAK,OAAO,IAAM,QAAUA,EAAK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wB,QAAO,SAAUnB,EAAWgB,CAAO,CAAE,CAAE,CAChH"}
1
+ {"version":3,"file":"ImplementationParser.js","names":["hintPattern","firstWord","line","context","path","DiagnosticCodes","locationOf","language","tag","open","next","lines","strip","possibleEvents","handler","parsePossibleEvents","parsed","body","file","code","extra","source","wrapper","hints","hasPayload","child","match","text","unescapeString","isBlankImplementationHint","nested","parsedFile","parsedCode"],"sources":["../../../../../../Compiler/Parsing/ImplementationParser.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 { CodeBlockSyntax, FileReferenceSyntax, HandlerSyntax, ImplementationHintSyntax, ImplementationSyntax } from '../Syntax/Implementations';\nimport { isBlankImplementationHint } from '../Text/ImplementationHintText';\nimport { unescapeString } from '../Text/StringLiteral';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { parsePossibleEvents } from './PossibleEventsParser';\nimport { locationOf, SourceLine } from './SourceLine';\n\n// Match ImplementationHintText's White_Space set, not ECMAScript \\s. A hint stays on one CR/LF-delimited source line.\n// eslint-disable-next-line no-control-regex -- The shared whitespace set deliberately includes U+0009 through U+000D.\nconst hintPattern = new RegExp('^hint[\\\\u0009-\\\\u000d\\\\u0020\\\\u0085\\\\u00a0\\\\u1680\\\\u2000-\\\\u200a\\\\u2028\\\\u2029\\\\u202f\\\\u205f\\\\u3000]+\"((?:[^\"\\\\\\\\\\\\r\\\\n]|\\\\\\\\[^\\\\r\\\\n])*)\"$');\nexport const isFile = (line: SourceLine): boolean => firstWord(line.content) === 'file' && line.content.substring(4).trim().length > 0;\nexport const isCode = (context: ParserContext, line: SourceLine): boolean => line.content.startsWith('```') || context.languages.has(line.content);\n\nexport function parseFile(context: ParserContext, line: SourceLine): FileReferenceSyntax {\n const path = line.content.substring(4).trim();\n if (/^(?:[/\\\\]|[A-Za-z]:[/\\\\]|~[/\\\\])/.test(path)) {\n context.warning(DiagnosticCodes.AbsoluteFileReference, `'${path}' is an absolute path - a file reference is relative to the repository root, so it means the same thing on every machine`, locationOf(line));\n }\n return { kind: 'FileReferenceSyntax', path, location: locationOf(line) };\n}\n\nexport const isClosingCodeFence = (line: SourceLine): boolean => line.raw.trim() === '```';\n\nexport function parseCode(context: ParserContext, tag: SourceLine): CodeBlockSyntax | null {\n const language = tag.content.startsWith('```') ? tag.content.substring(3) : tag.content;\n if (!context.languages.has(language)) {\n context.error(DiagnosticCodes.ExpectedCodeFence, `Expected a registered language on the opening fence, not '${tag.content}'`, locationOf(tag));\n return null;\n }\n let open = tag;\n if (!tag.content.startsWith('```')) {\n context.warning(DiagnosticCodes.LegacyInlineCodeFence, `'${language}' on its own line is deprecated - use '\\`\\`\\`${language}' instead`, locationOf(tag));\n const next = context.reader.peekSignificant();\n if (next === undefined || next.indent <= tag.indent || (next.content !== '```' && next.content !== `\\`\\`\\`${language}`)) {\n context.error(DiagnosticCodes.ExpectedCodeFence, `Expected an opening \\`\\`\\`${language} fence after '${language}'`, locationOf(tag));\n return null;\n }\n open = context.reader.takeSignificant();\n }\n const lines: string[] = [];\n for (;;) {\n const line = context.reader.takeRaw();\n if (line === undefined) {\n context.error(DiagnosticCodes.UnclosedCodeBlock, 'Unclosed inline code block - expected a closing ``` line', locationOf(open));\n break;\n }\n if (isClosingCodeFence(line)) break;\n let strip = 0;\n while (strip < open.indent && line.raw[strip] === ' ') strip++;\n lines.push(line.raw.substring(strip));\n }\n return { kind: 'CodeBlockSyntax', language, code: lines.join('\\n'), location: locationOf(tag) };\n}\n\nexport function parseHandler(context: ParserContext, handler: SourceLine): HandlerSyntax | null {\n const first = context.peekChild(handler.indent);\n const possibleEvents = first?.content === 'may produce' ? parsePossibleEvents(context, context.reader.takeSignificant()!) : null;\n const parsed = parseHandlerBody(context, handler);\n return parsed === null || possibleEvents === null ? parsed : { ...parsed, possibleEvents };\n}\n\nfunction parseHandlerBody(context: ParserContext, handler: SourceLine): HandlerSyntax | null {\n const body = context.peekChild(handler.indent);\n if (body === undefined) {\n context.error(DiagnosticCodes.HandlerWithoutImplementation, \"Expected a 'file' directive or an inline code block in the handler\", locationOf(handler));\n return null;\n }\n context.reader.takeSignificant();\n if (firstWord(body.content) === 'implementation') return parseImplementation(context, handler, body);\n const file = isFile(body) ? parseFile(context, body) : null;\n const code = file === null && isCode(context, body) ? parseCode(context, body) : null;\n if (file !== null || code !== null) {\n const extra = context.peekChild(handler.indent);\n if (extra !== undefined && firstWord(extra.content) === 'implementation') {\n context.error(DiagnosticCodes.ConflictingImplementationSources, 'A handler cannot mix wrapped and direct sources.', locationOf(extra));\n context.skipBlock(handler.indent);\n }\n return { kind: 'HandlerSyntax', file, code, implementation: null, location: locationOf(handler) };\n }\n context.error(DiagnosticCodes.UnknownHandlerDirective, `Unexpected '${body.content}' in handler - expected 'file <path>' or an inline code block`, locationOf(body));\n context.skipBlock(handler.indent);\n return null;\n}\n\nfunction parseImplementation(context: ParserContext, handler: SourceLine, wrapper: SourceLine): HandlerSyntax {\n const source = parseImplementationWrapper(context, wrapper);\n for (let extra = context.peekChild(handler.indent); extra !== undefined; extra = context.peekChild(handler.indent)) {\n context.reader.takeSignificant();\n context.error(firstWord(extra.content) === 'implementation' ? DiagnosticCodes.InvalidImplementationBlock : DiagnosticCodes.ConflictingImplementationSources,\n 'A handler has one implementation wrapper and cannot mix wrapped and direct sources.', locationOf(extra));\n if (isCode(context, extra)) parseCode(context, extra);\n else context.skipBlock(extra.indent);\n }\n return { kind: 'HandlerSyntax', ...source, location: locationOf(handler) };\n}\n\nexport function parseImplementationWrapper(context: ParserContext, wrapper: SourceLine): { file: FileReferenceSyntax | null; code: CodeBlockSyntax | null; implementation: ImplementationSyntax } {\n const hints: ImplementationHintSyntax[] = [];\n let file: FileReferenceSyntax | null = null;\n let code: CodeBlockSyntax | null = null;\n let hasPayload = false;\n if (wrapper.content !== 'implementation') context.error(DiagnosticCodes.InvalidImplementationBlock, \"Expected 'implementation' with no operand.\", locationOf(wrapper));\n for (let child = context.peekChild(wrapper.indent); child !== undefined; child = context.peekChild(wrapper.indent)) {\n context.reader.takeSignificant();\n if (firstWord(child.content) === 'hint' || hintPattern.test(child.content)) {\n const match = hintPattern.exec(child.content);\n const text = match === null ? null : unescapeString(match[1]);\n if (isBlankImplementationHint(text)) context.error(DiagnosticCodes.InvalidImplementationHint, \"Expected 'hint' followed by one nonblank quoted string.\", locationOf(child));\n else hints.push({ kind: 'ImplementationHintSyntax', text: text!, location: locationOf(child) });\n const nested = context.peekChild(child.indent);\n if (nested !== undefined) {\n context.error(DiagnosticCodes.InvalidImplementationHint, 'A hint cannot have children.', locationOf(nested));\n context.skipBlock(child.indent);\n }\n } else if (isFile(child) || child.content.startsWith('```')) {\n if (hasPayload) context.error(DiagnosticCodes.ConflictingImplementationSources, 'An implementation has at most one file or inline payload.', locationOf(child));\n const parsedFile = isFile(child) ? parseFile(context, child) : null;\n const parsedCode = parsedFile === null ? parseCode(context, child) : null;\n if (!hasPayload) { file = parsedFile; code = parsedCode; }\n hasPayload = true;\n const nested = context.peekChild(child.indent);\n if (parsedFile !== null && nested !== undefined) {\n context.error(DiagnosticCodes.InvalidImplementationBlock, 'A file directive cannot have children.', locationOf(nested));\n context.skipBlock(child.indent);\n }\n } else {\n context.error(DiagnosticCodes.InvalidImplementationBlock, `Unexpected '${child.content}' in implementation - expected hint, file or a tagged fence.`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n return { file, code, implementation: { kind: 'ImplementationSyntax', hints, location: locationOf(wrapper) } };\n}\n"],"mappings":"A,wZAcA,MAAMA,EAAc,gBAAI,OAAO,6IAA6I,EAC/J,OAAU,GAA8BC,EAAUC,EAAK,OAAO,IAAM,QAAUA,EAAK,QAAQ,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,OAAS,EACxH,QAAU,EAAwB,IAA8BA,EAAK,QAAQ,WAAW,KAAK,GAAKC,EAAQ,UAAU,IAAID,EAAK,OAAO,E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"../Files/PlayPlacement.js";import{tryParseFileImport as n}from"./FileImportParser.js";import{parseFeature as r}from"./FeatureBody.js";import{parseModule as i}from"./ModuleBody.js";function placementFrom(e,n){let{scope:r}=e;return r.length===0?n:e.startsAtModule?t(n)?r:n.length===1&&n[0]===r[0]?[...n,...r.slice(1)]:void 0:t(n)?void 0:[...n,...r]}function discoverImports(t){let a=[];for(let o=t.reader.peekSignificant();o!==void 0;o=t.reader.peekSignificant()){t.reader.takeSignificant();let s=e(o.content),c=s===`import`?n(o):void 0;if(c!==void 0)a.push({scope:[],startsAtModule:!1,fileImport:c});else if(s===`module`){let e=i(t,o);a.push(...e.fileImports.map(t=>({scope:[e.name],startsAtModule:!0,fileImport:t}))),a.push(...e.features.flatMap(t=>importsIn(t,[e.name],!0)))}else s===`feature`?a.push(...importsIn(r(t,o),[],!1)):t.skipOpaqueBlock(o.indent)}return a}function importsIn(e,t,n){let r=[...t,e.name];return[...e.fileImports.map(e=>({scope:r,startsAtModule:n,fileImport:e})),...e.features.flatMap(e=>importsIn(e,r,n))]}export{discoverImports,placementFrom};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{isDocumentPlacement as e}from"../Files/PlayPlacement.js";import{parseFeature as t}from"./FeatureBody.js";import{tryParseFileImport as n}from"./FileImportParser.js";import{firstWord as r}from"./LineText.js";import{parseModule as i}from"./ModuleBody.js";function placementFrom(t,n){let{scope:r}=t;return r.length===0?n:t.startsAtModule?e(n)?r:n.length===1&&n[0]===r[0]?[...n,...r.slice(1)]:void 0:e(n)?void 0:[...n,...r]}function discoverImports(e){let a=[];for(let o=e.reader.peekSignificant();o!==void 0;o=e.reader.peekSignificant()){e.reader.takeSignificant();let s=r(o.content),c=s===`import`?n(o):void 0;if(c!==void 0)a.push({scope:[],startsAtModule:!1,fileImport:c});else if(s===`module`){let t=i(e,o);a.push(...t.fileImports.map(e=>({scope:[t.name],startsAtModule:!0,fileImport:e}))),a.push(...t.features.flatMap(e=>importsIn(e,[t.name],!0)))}else s===`feature`?a.push(...importsIn(t(e,o),[],!1)):e.skipOpaqueBlock(o.indent)}return a}function importsIn(e,t,n){let r=[...t,e.name];return[...e.fileImports.map(e=>({scope:r,startsAtModule:n,fileImport:e})),...e.features.flatMap(e=>importsIn(e,r,n))]}export{discoverImports,placementFrom};
2
2
  //# sourceMappingURL=ImportDiscovery.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ImportDiscovery.js","names":["discovered","scope","document","isDocumentPlacement","found","line","context","keyword","firstWord","fileImport","tryParseFileImport","module","parseModule","each","feature","parseFeature","outer","nested","startsAtModule"],"sources":["../../../../../../Compiler/Parsing/ImportDiscovery.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 { isDocumentPlacement, PlayPlacement } from '../Files/PlayPlacement';\nimport { FeatureSyntax, FileImportSyntax } from '../Syntax/Structure';\nimport { parseFeature } from './FeatureBody';\nimport { tryParseFileImport } from './FileImportParser';\nimport { firstWord } from './LineText';\nimport { parseModule } from './ModuleBody';\nimport { ParserContext } from './ParserContext';\n\n// A file import, together with the module and feature names around it in the document, outermost first, and\n// whether the outermost name is a 'module' written at the document's top level rather than a 'feature'. The\n// port of the C# DiscoveredFileImport.\nexport interface DiscoveredImport {\n readonly scope: readonly string[];\n readonly startsAtModule: boolean;\n readonly fileImport: FileImportSyntax;\n}\n\n// Where an import places what it imports, given where the document holding it is placed - undefined when the\n// import cannot place anything from there. A top level 'feature' only means something once the document is\n// placed in a module, so until then its imports place nothing - the document reports the misplaced feature\n// itself if it never is. A top level 'module' is the module's own declaration in a whole document, a\n// restatement that joins the placement in a document placed in that module, and nothing anywhere else.\nexport function placementFrom(discovered: DiscoveredImport, document: PlayPlacement): PlayPlacement | undefined {\n const { scope } = discovered;\n if (scope.length === 0) return document;\n if (!discovered.startsAtModule) return isDocumentPlacement(document) ? undefined : [...document, ...scope];\n if (isDocumentPlacement(document)) return scope;\n return document.length === 1 && document[0] === scope[0] ? [...document, ...scope.slice(1)] : undefined;\n}\n\n// Finds the files a document imports and where in it each import is written, without settling where the\n// document itself belongs - the port of the C# ScreenplayParser.DiscoverImports. Where a file belongs depends\n// on what imports it, and what it imports depends on where the imports are written in it, so this reads the\n// module and feature structure of any file, whether its top level is the application's or the body of a\n// module or feature it will later be placed in. The context's diagnostics are not the document's.\nexport function discoverImports(context: ParserContext): DiscoveredImport[] {\n const found: DiscoveredImport[] = [];\n for (let line = context.reader.peekSignificant(); line !== undefined; line = context.reader.peekSignificant()) {\n context.reader.takeSignificant();\n const keyword = firstWord(line.content);\n const fileImport = keyword === 'import' ? tryParseFileImport(line) : undefined;\n if (fileImport !== undefined) {\n found.push({ scope: [], startsAtModule: false, fileImport });\n } else if (keyword === 'module') {\n const module = parseModule(context, line);\n found.push(...module.fileImports.map(each => ({ scope: [module.name], startsAtModule: true, fileImport: each })));\n found.push(...module.features.flatMap(feature => importsIn(feature, [module.name], true)));\n } else if (keyword === 'feature') {\n found.push(...importsIn(parseFeature(context, line), [], false));\n } else {\n context.skipOpaqueBlock(line.indent);\n }\n }\n return found;\n}\n\nfunction importsIn(feature: FeatureSyntax, outer: readonly string[], startsAtModule: boolean): DiscoveredImport[] {\n const scope = [...outer, feature.name];\n return [\n ...feature.fileImports.map(fileImport => ({ scope, startsAtModule, fileImport })),\n ...feature.features.flatMap(nested => importsIn(nested, scope, startsAtModule)),\n ];\n}\n"],"mappings":"wTAyBA,SAAgB,cAAc,EAA8B,EAAoD,CAC5G,GAAM,CAAE,SAAUA,EAIlB,OAHIC,EAAM,SAAW,EAAUC,EAC1BF,EAAW,eACZG,EAAoBD,CAAQ,EAAUD,EACnCC,EAAS,SAAW,GAAKA,EAAS,KAAOD,EAAM,GAAK,CAAC,GAAGC,EAAU,GAAGD,EAAM,MAAM,CAAC,CAAC,EAAI,IAAA,GAFvDE,EAAoBD,CAAQ,EAAI,IAAA,GAAY,CAAC,GAAGA,EAAU,GAAGD,CAAK,CAG7G,CAOA,SAAgB,gBAAgB,EAA4C,CACxE,IAAMG,EAA4B,CAAC,EACnC,IAAK,IAAIC,EAAOC,EAAQ,OAAO,gBAAgB,EAAGD,IAAS,IAAA,GAAW,EAAOC,EAAQ,OAAO,gBAAgB,EAAG,CAC3GA,EAAQ,OAAO,gBAAgB,EAC/B,IAAMC,EAAUC,EAAUH,EAAK,OAAO,EAChCI,EAAaF,IAAY,SAAWG,EAAmBL,CAAI,EAAI,IAAA,GACrE,GAAII,IAAe,IAAA,GACfL,EAAM,KAAK,CAAE,MAAO,CAAC,EAAG,eAAgB,GAAO,YAAW,CAAC,OACxD,GAAIG,IAAY,SAAU,CAC7B,IAAMI,EAASC,EAAYN,EAASD,CAAI,EACxCD,EAAM,KAAK,GAAGO,EAAO,YAAY,IAAI,IAAS,CAAE,MAAO,CAACA,EAAO,IAAI,EAAG,eAAgB,GAAM,WAAYE,CAAK,EAAE,CAAC,EAChHT,EAAM,KAAK,GAAGO,EAAO,SAAS,QAAQ,GAAW,UAAUG,EAAS,CAACH,EAAO,IAAI,EAAG,EAAI,CAAC,CAAC,CAC7F,MAAWJ,IAAY,UACnBH,EAAM,KAAK,GAAG,UAAUW,EAAaT,EAASD,CAAI,EAAG,CAAC,EAAG,EAAK,CAAC,EAE/DC,EAAQ,gBAAgBD,EAAK,MAAM,CAE3C,CACA,OAAOD,CACX,CAEA,SAAS,UAAU,EAAwB,EAA0B,EAA6C,CAC9G,IAAMH,EAAQ,CAAC,GAAGe,EAAOF,EAAQ,IAAI,EACrC,MAAO,CACH,GAAGA,EAAQ,YAAY,IAAI,IAAe,CAAE,QAAO,iBAAgB,YAAW,EAAE,EAChF,GAAGA,EAAQ,SAAS,QAAQ,GAAU,UAAUG,EAAQhB,EAAOiB,CAAc,CAAC,CAClF,CACJ"}
1
+ {"version":3,"file":"ImportDiscovery.js","names":["discovered","scope","document","isDocumentPlacement","found","line","context","keyword","firstWord","fileImport","tryParseFileImport","module","parseModule","each","feature","parseFeature","outer","nested","startsAtModule"],"sources":["../../../../../../Compiler/Parsing/ImportDiscovery.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 { isDocumentPlacement, PlayPlacement } from '../Files/PlayPlacement';\nimport { FeatureSyntax, FileImportSyntax } from '../Syntax/Structure';\nimport { parseFeature } from './FeatureBody';\nimport { tryParseFileImport } from './FileImportParser';\nimport { firstWord } from './LineText';\nimport { parseModule } from './ModuleBody';\nimport { ParserContext } from './ParserContext';\n\n// A file import, together with the module and feature names around it in the document, outermost first, and\n// whether the outermost name is a 'module' written at the document's top level rather than a 'feature'. The\n// port of the C# DiscoveredFileImport.\nexport interface DiscoveredImport {\n readonly scope: readonly string[];\n readonly startsAtModule: boolean;\n readonly fileImport: FileImportSyntax;\n}\n\n// Where an import places what it imports, given where the document holding it is placed - undefined when the\n// import cannot place anything from there. A top level 'feature' only means something once the document is\n// placed in a module, so until then its imports place nothing - the document reports the misplaced feature\n// itself if it never is. A top level 'module' is the module's own declaration in a whole document, a\n// restatement that joins the placement in a document placed in that module, and nothing anywhere else.\nexport function placementFrom(discovered: DiscoveredImport, document: PlayPlacement): PlayPlacement | undefined {\n const { scope } = discovered;\n if (scope.length === 0) return document;\n if (!discovered.startsAtModule) return isDocumentPlacement(document) ? undefined : [...document, ...scope];\n if (isDocumentPlacement(document)) return scope;\n return document.length === 1 && document[0] === scope[0] ? [...document, ...scope.slice(1)] : undefined;\n}\n\n// Finds the files a document imports and where in it each import is written, without settling where the\n// document itself belongs - the port of the C# ScreenplayParser.DiscoverImports. Where a file belongs depends\n// on what imports it, and what it imports depends on where the imports are written in it, so this reads the\n// module and feature structure of any file, whether its top level is the application's or the body of a\n// module or feature it will later be placed in. The context's diagnostics are not the document's.\nexport function discoverImports(context: ParserContext): DiscoveredImport[] {\n const found: DiscoveredImport[] = [];\n for (let line = context.reader.peekSignificant(); line !== undefined; line = context.reader.peekSignificant()) {\n context.reader.takeSignificant();\n const keyword = firstWord(line.content);\n const fileImport = keyword === 'import' ? tryParseFileImport(line) : undefined;\n if (fileImport !== undefined) {\n found.push({ scope: [], startsAtModule: false, fileImport });\n } else if (keyword === 'module') {\n const module = parseModule(context, line);\n found.push(...module.fileImports.map(each => ({ scope: [module.name], startsAtModule: true, fileImport: each })));\n found.push(...module.features.flatMap(feature => importsIn(feature, [module.name], true)));\n } else if (keyword === 'feature') {\n found.push(...importsIn(parseFeature(context, line), [], false));\n } else {\n context.skipOpaqueBlock(line.indent);\n }\n }\n return found;\n}\n\nfunction importsIn(feature: FeatureSyntax, outer: readonly string[], startsAtModule: boolean): DiscoveredImport[] {\n const scope = [...outer, feature.name];\n return [\n ...feature.fileImports.map(fileImport => ({ scope, startsAtModule, fileImport })),\n ...feature.features.flatMap(nested => importsIn(nested, scope, startsAtModule)),\n ];\n}\n"],"mappings":"A,wTAyBA,SAAgB,cAAc,EAA8B,EAAoD,CAC5G,GAAM,CAAE,SAAUA,EAIlB,OAHIC,EAAM,SAAW,EAAUC,EAC1BF,EAAW,eACZG,EAAoBD,CAAQ,EAAUD,EACnCC,EAAS,SAAW,GAAKA,EAAS,KAAOD,EAAM,GAAK,CAAC,GAAGC,EAAU,GAAGD,EAAM,MAAM,CAAC,CAAC,EAAI,IAAA,GAFvDE,EAAoBD,CAAQ,EAAI,IAAA,GAAY,CAAC,GAAGA,EAAU,GAAGD,CAAK,CAG7G,CAOA,SAAgB,gBAAgB,EAA4C,CACxE,IAAMG,EAA4B,CAAC,EACnC,IAAK,IAAIC,EAAOC,EAAQ,OAAO,gBAAgB,EAAGD,IAAS,IAAA,GAAW,EAAOC,EAAQ,OAAO,gBAAgB,EAAG,CAC3GA,EAAQ,OAAO,gBAAgB,EAC/B,IAAMC,EAAUC,EAAUH,EAAK,OAAO,EAChCI,EAAaF,IAAY,SAAWG,EAAmBL,CAAI,EAAI,IAAA,GACrE,GAAII,IAAe,IAAA,GACfL,EAAM,KAAK,CAAE,MAAO,CAAC,EAAG,eAAgB,GAAO,YAAW,CAAC,OACxD,GAAIG,IAAY,SAAU,CAC7B,IAAMI,EAASC,EAAYN,EAASD,CAAI,EACxCD,EAAM,KAAK,GAAGO,EAAO,YAAY,IAAI,IAAS,CAAE,MAAO,CAACA,EAAO,IAAI,EAAG,eAAgB,GAAM,WAAYE,CAAK,EAAE,CAAC,EAChHT,EAAM,KAAK,GAAGO,EAAO,SAAS,QAAQ,GAAW,UAAUG,EAAS,CAACH,EAAO,IAAI,EAAG,EAAI,CAAC,CAAC,CAC7F,MAAWJ,IAAY,UACnBH,EAAM,KAAK,GAAG,UAAUW,EAAaT,EAASD,CAAI,EAAG,CAAC,EAAG,EAAK,CAAC,EAE/DC,EAAQ,gBAAgBD,EAAK,MAAM,CAE3C,CACA,OAAOD,CACX,CAEA,SAAS,UAAU,EAAwB,EAA0B,EAA6C,CAC9G,IAAMH,EAAQ,CAAC,GAAGe,EAAOF,EAAQ,IAAI,EACrC,MAAO,CACH,GAAGA,EAAQ,YAAY,IAAI,IAAe,CAAE,QAAO,iBAAgB,YAAW,EAAE,EAChF,GAAGA,EAAQ,SAAS,QAAQ,GAAU,UAAUG,EAAQhB,EAAOiB,CAAc,CAAC,CAClF,CACJ,C"}
@@ -1 +1 @@
1
- {"version":3,"file":"InlineEventValidator.js","names":["slices","feature","application","module","eventCounts","event","eventDeclarations","importedNames","value","resolver","AuthoringProductionResolver","slice","events","command","production","identifier","property","mixed","requiresExplicitDestinations","inline","context","DiagnosticCodes","destination","mapping","message"],"sources":["../../../../../../Compiler/Parsing/InlineEventValidator.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 { eventDeclarations } from '../Syntax/EventDeclarations';\nimport { AuthoringProductionResolver } from '../Syntax/AuthoringProductionResolver';\nimport { requiresExplicitDestinations } from '../Syntax/ProductionDestinations';\nimport { ApplicationSyntax, FeatureSyntax, SliceSyntax } from '../Syntax/Structure';\nimport { ParserContext } from './ParserContext';\n\nexport function validateInlineEvents(application: ApplicationSyntax, context: ParserContext): void {\n const slices: SliceSyntax[] = [];\n const inFeature = (feature: FeatureSyntax): void => {\n slices.push(...feature.slices);\n feature.features.forEach(inFeature);\n };\n application.modules.forEach(module => module.features.forEach(inFeature));\n const eventCounts = new Map<string, number>();\n for (const event of slices.flatMap(eventDeclarations)) eventCounts.set(event.name, (eventCounts.get(event.name) ?? 0) + 1);\n const importedNames = new Set(application.imports.map(value => value.qualifiedName.split('.').at(-1)));\n const resolver = new AuthoringProductionResolver(application);\n for (const { slice, command } of slices.flatMap(slice => slice.commands.map(command => ({ slice, command })))) {\n const events = command.produces.filter(production => resolver.isEventProduction(production, slice));\n const identifier = command.properties.find(property => property.isIdentifier)?.name;\n const mixed = requiresExplicitDestinations(command, { resolver, slice });\n for (const production of events) {\n const inline = production.inlineEvent;\n if (inline !== null && ((eventCounts.get(inline.name) ?? 0) > 1 || importedNames.has(inline.name))) {\n context.error(DiagnosticCodes.InlineEventCollision, `Inline event '${inline.name}' collides with another event declaration or import`, production.location);\n }\n if (mixed && production.for === null) {\n context.error(DiagnosticCodes.ExplicitProducesTargetsRequired, `Production '${production.event}' in command '${command.name}' must state 'for' explicitly - every production must state 'for' when destinations differ`, production.location);\n }\n const destination = production.for?.kind === 'PathExpressionSyntax' ? production.for.path : production.for === null && inline !== null ? identifier : undefined;\n if (identifier === undefined || destination !== identifier) continue;\n for (const mapping of production.mappings.filter(mapping => mapping.source.kind === 'PathExpressionSyntax' && mapping.source.path === identifier)) {\n const message = `Event '${production.event}' copies command identifier '${identifier}' into payload property '${mapping.property}' although it already identifies the event source`;\n if (inline === null) context.information(DiagnosticCodes.EventSourceIdInPayload, message, mapping.location);\n else context.warning(DiagnosticCodes.EventSourceIdInPayload, message, mapping.location);\n }\n }\n }\n}\n"],"mappings":"sWAUA,SAAgB,qBAAqB,EAAgC,EAA8B,CAC/F,IAAMA,EAAwB,CAAC,EACzB,U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AAQK,IAAW,KAAOJ,EAAa,IAAA,GACtJ,GAAIA,IAAe,IAAA,IAAaO,IAAgBP,EAChD,IAAK,IAAMQ,KAAWT,EAAW,SAAS,OAAO,GAAWS,EAAQ,OAAO,OAAS,wBAA0BA,EAAQ,OAAO,OAASR,CAAU,EAAG,CAC/I,IAAMS,EAAU,UAAUV,EAAW,MAAM,+BAA+BC,EAAW,2BAA2BQ,EAAQ,SAAS,mDAC7HJ,IAAW,KAAMC,EAAQ,YAAYC,EAAgB,uBAAwBG,EAASD,EAAQ,QAAQ,EACrGH,EAAQ,QAAQC,EAAgB,uBAAwBG,EAASD,EAAQ,QAAQ,CAC1F,CACJ,CACJ,CACJ"}
1
+ {"version":3,"file":"InlineEventValidator.js","names":["slices","feature","application","module","eventCounts","event","eventDeclarations","importedNames","value","resolver","AuthoringProductionResolver","slice","events","command","production","identifier","property","mixed","requiresExplicitDestinations","inline","context","DiagnosticCodes","destination","mapping","message"],"sources":["../../../../../../Compiler/Parsing/InlineEventValidator.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 { eventDeclarations } from '../Syntax/EventDeclarations';\nimport { AuthoringProductionResolver } from '../Syntax/AuthoringProductionResolver';\nimport { requiresExplicitDestinations } from '../Syntax/ProductionDestinations';\nimport { ApplicationSyntax, FeatureSyntax, SliceSyntax } from '../Syntax/Structure';\nimport { ParserContext } from './ParserContext';\n\nexport function validateInlineEvents(application: ApplicationSyntax, context: ParserContext): void {\n const slices: SliceSyntax[] = [];\n const inFeature = (feature: FeatureSyntax): void => {\n slices.push(...feature.slices);\n feature.features.forEach(inFeature);\n };\n application.modules.forEach(module => module.features.forEach(inFeature));\n const eventCounts = new Map<string, number>();\n for (const event of slices.flatMap(eventDeclarations)) eventCounts.set(event.name, (eventCounts.get(event.name) ?? 0) + 1);\n const importedNames = new Set(application.imports.map(value => value.qualifiedName.split('.').at(-1)));\n const resolver = new AuthoringProductionResolver(application);\n for (const { slice, command } of slices.flatMap(slice => slice.commands.map(command => ({ slice, command })))) {\n const events = command.produces.filter(production => resolver.isEventProduction(production, slice));\n const identifier = command.properties.find(property => property.isIdentifier)?.name;\n const mixed = requiresExplicitDestinations(command, { resolver, slice });\n for (const production of events) {\n const inline = production.inlineEvent;\n if (inline !== null && ((eventCounts.get(inline.name) ?? 0) > 1 || importedNames.has(inline.name))) {\n context.error(DiagnosticCodes.InlineEventCollision, `Inline event '${inline.name}' collides with another event declaration or import`, production.location);\n }\n if (mixed && production.for === null) {\n context.error(DiagnosticCodes.ExplicitProducesTargetsRequired, `Production '${production.event}' in command '${command.name}' must state 'for' explicitly - every production must state 'for' when destinations differ`, production.location);\n }\n const destination = production.for?.kind === 'PathExpressionSyntax' ? production.for.path : production.for === null && inline !== null ? identifier : undefined;\n if (identifier === undefined || destination !== identifier) continue;\n for (const mapping of production.mappings.filter(mapping => mapping.source.kind === 'PathExpressionSyntax' && mapping.source.path === identifier)) {\n const message = `Event '${production.event}' copies command identifier '${identifier}' into payload property '${mapping.property}' although it already identifies the event source`;\n if (inline === null) context.information(DiagnosticCodes.EventSourceIdInPayload, message, mapping.location);\n else context.warning(DiagnosticCodes.EventSourceIdInPayload, message, mapping.location);\n }\n }\n }\n}\n"],"mappings":"A,sWAUA,SAAgB,qBAAqB,EAAgC,EAA8B,CAC/F,IAAMA,EAAwB,CAAC,EACzB,UAAa,GAAiC,CAChDA,EAAO,KAAK,GAAGC,EAAQ,MAAM,EAC7BA,EAAQ,SAAS,QAAQ,SAAS,CACtC,EACAC,EAAY,QAAQ,QAAQ,GAAUC,EAAO,SAAS,QAAQ,SAAS,CAAC,EACxE,IAAMC,kBAAc,IAAI,IACxB,IAAK,IAAMC,KAASL,EAAO,QAAQM,CAAiB,EAAGF,EAAY,IAAIC,EAAM,MAAOD,EAAY,IAAIC,EAAM,IAAI,GAAK,GAAK,CAAC,EACzH,IAAME,EA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,EAASD,EAAQ,QAAQ,EACrGH,EAAQ,QAAQC,EAAgB,uBAAwBG,EAASD,EAAQ,QAAQ,CAC1F,CACJ,CACJ,CACJ,C"}
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{pattern as e}from"../Text/patterns.js";import{locationOf as t}from"./SourceLine.js";import{firstWord as n,unescapeIdentifier as r}from"./LineText.js";import{parseDescription as i}from"./DescriptionParser.js";import{collectContinuationValues as a}from"./ContinuationValues.js";import{validateInteractionBodies as o}from"./InteractionAlternatives.js";const s=e(`^form\\s+[A-Za-z_]\\w*\\s+for\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),c=e(`^(execute|invokes)\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),l=e(`^field\\s+([\\w.]+)(?:\\s|$)`),u=e(`^with\\s+([A-Za-z_]\\w*)\\s+from\\s+.+$`),d=e(`^(@?[\\w.]+)\\s*=(?!=|>)\\s*.+$`),f=e(`^parameter\\s+([A-Za-z_]\\w*)(?:\\s+([\\w.]+(?:\\[\\])?))?$`),p=/* @__PURE__ */ new Set([`refresh`,`navigate`,`open`,`close`,`set`,`notify`,`confirm`,`raise`,`on`,`when`,`otherwise`]);function collectInputUses(m,h){let g=[],_=/* @__PURE__ */ new Set,v=[],y=n(h.content)===`behavior`,b=null,recognize=e=>{for(;g.length>0&&g[g.length-1].indent>=e.indent;)g.pop();let i=y&&g.length===0?f.exec(e.content):null;i!==null&&_.add(i[1]);let a=s.exec(e.content),o=c.exec(e.content);if(a!==null)g.push({command:a[1],kind:`form`,indent:e.indent});else if(o!==null)g.push({command:o[2],kind:o[1],indent:e.indent});else if(p.has(n(e.content)))g.push({command:``,kind:`other`,indent:e.indent});else{let n=g.at(-1);if(n===void 0||n.kind===`other`)return;let i=(n.kind===`form`?l:n.kind===`execute`?u:d).exec(e.content);i!==null&&v.push({command:n.command,property:r(i[1]),scope:m.scope,location:t(e)})}};recognize(h);let x=[h];for(let t=m.peekChild(h.indent);t!==void 0;t=m.peekChild(h.indent)){for(m.reader.takeSignificant();g.length>0&&g[g.length-1].indent>=t.indent;)g.pop();s.test(h.content)&&n(t.content)===`description`&&g.at(-1)?.kind===`form`?b=i(m,t,b,`Form '${h.content.split(e(`\\s+`))[1]}'`):t.content.startsWith("```")?m.skipFencedBody():(x.push(t),recognize(t))}o(m,x),m.continuationValues.push(...a(x,m.scope));for(let e of v)m.inputUses.push(_.has(e.command)?{...e,isParameter:!0}:e)}export{collectInputUses};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{collectContinuationValues as e}from"./ContinuationValues.js";import{pattern as t}from"../Text/patterns.js";import{firstWord as n,unescapeIdentifier as r}from"./LineText.js";import{validateInteractionBodies as i}from"./InteractionAlternatives.js";import{parseDescription as a}from"./DescriptionParser.js";import{locationOf as o}from"./SourceLine.js";const s=t(`^form\\s+[A-Za-z_]\\w*\\s+for\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),c=t(`^(execute|invokes)\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),l=t(`^field\\s+([\\w.]+)(?:\\s|$)`),u=t(`^with\\s+([A-Za-z_]\\w*)\\s+from\\s+.+$`),d=t(`^(@?[\\w.]+)\\s*=(?!=|>)\\s*.+$`),f=t(`^parameter\\s+([A-Za-z_]\\w*)(?:\\s+([\\w.]+(?:\\[\\])?))?$`),p=/* @__PURE__ */ new Set([`refresh`,`navigate`,`open`,`close`,`set`,`notify`,`confirm`,`raise`,`on`,`when`,`otherwise`]);function collectInputUses(m,h){let g=[],_=/* @__PURE__ */ new Set,v=[],y=n(h.content)===`behavior`,b=null,recognize=e=>{for(;g.length>0&&g[g.length-1].indent>=e.indent;)g.pop();let t=y&&g.length===0?f.exec(e.content):null;t!==null&&_.add(t[1]);let i=s.exec(e.content),a=c.exec(e.content);if(i!==null)g.push({command:i[1],kind:`form`,indent:e.indent});else if(a!==null)g.push({command:a[2],kind:a[1],indent:e.indent});else if(p.has(n(e.content)))g.push({command:``,kind:`other`,indent:e.indent});else{let t=g.at(-1);if(t===void 0||t.kind===`other`)return;let n=(t.kind===`form`?l:t.kind===`execute`?u:d).exec(e.content);n!==null&&v.push({command:t.command,property:r(n[1]),scope:m.scope,location:o(e)})}};recognize(h);let x=[h];for(let e=m.peekChild(h.indent);e!==void 0;e=m.peekChild(h.indent)){for(m.reader.takeSignificant();g.length>0&&g[g.length-1].indent>=e.indent;)g.pop();s.test(h.content)&&n(e.content)===`description`&&g.at(-1)?.kind===`form`?b=a(m,e,b,`Form '${h.content.split(t(`\\s+`))[1]}'`):e.content.startsWith("```")?m.skipFencedBody():(x.push(e),recognize(e))}i(m,x),m.continuationValues.push(...e(x,m.scope));for(let e of v)m.inputUses.push(_.has(e.command)?{...e,isParameter:!0}:e)}export{collectInputUses};
2
2
  //# sourceMappingURL=InputUses.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"InputUses.js","names":["form","pattern","execution","field","argument","mapping","parameter","actionBoundaries","owners","parameters","inputs","isBehavior","firstWord","header","formDescription","line","declared","formMatch","execute","owner","supplied","unescapeIdentifier","context","locationOf","lines","child","parseDescription","validateInteractionBodies","collectContinuationValues","input"],"sources":["../../../../../../Compiler/Parsing/InputUses.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 { collectContinuationValues } from './ContinuationValues';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { pattern } from '../Text/patterns';\nimport { firstWord, unescapeIdentifier } from './LineText';\nimport { validateInteractionBodies } from './InteractionAlternatives';\nimport { ParserContext } from './ParserContext';\nimport { parseDescription } from './DescriptionParser';\nimport { locationOf, SourceLine } from './SourceLine';\n\n// Typed authoring facts from bodies the TS syntax tree does not yet model. Never serialized as ESM.\nexport interface InputUse {\n readonly command: string;\n readonly property: string;\n readonly scope: readonly string[];\n readonly location: SourceLocation;\n readonly isParameter?: boolean;\n}\n\ninterface InputOwner { command: string; kind: 'form' | 'execute' | 'invokes' | 'other'; indent: number }\nconst form = pattern('^form\\\\s+[A-Za-z_]\\\\w*\\\\s+for\\\\s+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)$');\nconst execution = pattern('^(execute|invokes)\\\\s+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)$');\nconst field = pattern('^field\\\\s+([\\\\w.]+)(?:\\\\s|$)');\nconst argument = pattern('^with\\\\s+([A-Za-z_]\\\\w*)\\\\s+from\\\\s+.+$');\nconst mapping = pattern('^(@?[\\\\w.]+)\\\\s*=(?!=|>)\\\\s*.+$');\nconst parameter = pattern('^parameter\\\\s+([A-Za-z_]\\\\w*)(?:\\\\s+([\\\\w.]+(?:\\\\[\\\\])?))?$');\nconst actionBoundaries = new Set(['refresh', 'navigate', 'open', 'close', 'set', 'notify', 'confirm', 'raise', 'on', 'when', 'otherwise']);\n\n// A single forward walk, tracking owners by indentation and skipping fences as opaque text.\nexport function collectInputUses(context: ParserContext, header: SourceLine): void {\n const owners: InputOwner[] = [];\n const parameters = new Set<string>();\n const inputs: InputUse[] = [];\n const isBehavior = firstWord(header.content) === 'behavior';\n let formDescription: string | null = null;\n const recognize = (line: SourceLine): void => {\n while (owners.length > 0 && owners[owners.length - 1].indent >= line.indent) owners.pop();\n const declared = isBehavior && owners.length === 0 ? parameter.exec(line.content) : null;\n if (declared !== null) parameters.add(declared[1]);\n const formMatch = form.exec(line.content);\n const execute = execution.exec(line.content);\n if (formMatch !== null) owners.push({ command: formMatch[1], kind: 'form', indent: line.indent });\n else if (execute !== null) owners.push({ command: execute[2], kind: execute[1] as 'execute' | 'invokes', indent: line.indent });\n else if (actionBoundaries.has(firstWord(line.content))) owners.push({ command: '', kind: 'other', indent: line.indent });\n else {\n const owner = owners.at(-1);\n if (owner === undefined || owner.kind === 'other') return;\n const supplied = (owner.kind === 'form' ? field : owner.kind === 'execute' ? argument : mapping).exec(line.content);\n if (supplied !== null) inputs.push({ command: owner.command, property: unescapeIdentifier(supplied[1]), scope: context.scope, location: locationOf(line) });\n }\n };\n recognize(header);\n const lines = [header];\n for (let child = context.peekChild(header.indent); child !== undefined; child = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n while (owners.length > 0 && owners[owners.length - 1].indent >= child.indent) owners.pop();\n if (form.test(header.content) && firstWord(child.content) === 'description' && owners.at(-1)?.kind === 'form') {\n formDescription = parseDescription(context, child, formDescription, `Form '${header.content.split(pattern('\\\\s+'))[1]}'`);\n } else if (child.content.startsWith('```')) context.skipFencedBody();\n else {\n lines.push(child);\n recognize(child);\n }\n }\n validateInteractionBodies(context, lines);\n context.continuationValues.push(...collectContinuationValues(lines, context.scope));\n // Parameters may be declared after their bindings; commit facts once their scope is complete.\n for (const input of inputs) context.inputUses.push(parameters.has(input.command) ? { ...input, isParameter: true } : input);\n}\n"],"mappings":"yZAsBA,MAAMA,EAAOC,EAAQ,+DAA+D,EAC9EC,EAAYD,EAAQ,oDAAoD,EACxEE,EAAQF,EAAQ,8BAA8B,EAC9CG,EAAWH,EAAQ,yCAAyC,EAC5DI,EAAUJ,EAAQ,iCAAiC,EACnDK,EAAYL,EAAQ,6DAA6D,EACjFM,kBAAmB,IAAI,IAAI,CAAC,UAAW,WAAY,OAAQ,QAAS,MAAO,SAAU,UAAW,QAAS,KAAM,OAAQ,WAAW,CAAC,EAGzI,SAAgB,iBAAiB,EAAwB,EAA0B,CAC/E,IAAMC,EAAuB,CAAC,EACxBC,kBAAa,IAAI,IACjBC,EAAqB,CAAC,EACtBC,EAAaC,EAAUC,EAAO,OAAO,IAAM,WAC7CC,EAAiC,KAC/B,UAAa,GAA2B,CAC1C,KAAON,EAAO,OAAS,GAAKA,EAAOA,EAAO,OAAS,EAAE,CAAC,QAAUO,EAAK,QAAQP,EAAO,IAAI,EACxF,IAAMQ,EAAWL,GAAcH,EAAO,SAAW,EAAIF,EAAU,KAAKS,EAAK,OAAO,EAAI,KAChFC,IAAa,MAAMP,EAAW,IAAIO,EAAS,EAAE,EACjD,IAAMC,E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EAAO,QAAQ,MAAMZ,EAAQ,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,EACjHwB,EAAM,QAAQ,WAAW,KAAK,EAAGH,EAAQ,eAAe,GAE/DE,EAAM,KAAKC,CAAK,EAChB,UAAUA,CAAK,EAEvB,CACAE,EAA0BL,EAASE,CAAK,EACxCF,EAAQ,mBAAmB,KAAK,GAAGM,EAA0BJ,EAAOF,EAAQ,KAAK,CAAC,EAElF,IAAK,IAAMO,KAASnB,EAAQY,EAAQ,UAAU,KAAKb,EAAW,IAAIoB,EAAM,OAAO,EAAI,CAAE,GAAGA,EAAO,YAAa,EAAK,EAAIA,CAAK,CAC9H"}
1
+ {"version":3,"file":"InputUses.js","names":["form","pattern","execution","field","argument","mapping","parameter","actionBoundaries","owners","parameters","inputs","isBehavior","firstWord","header","formDescription","line","declared","formMatch","execute","owner","supplied","unescapeIdentifier","context","locationOf","lines","child","parseDescription","validateInteractionBodies","collectContinuationValues","input"],"sources":["../../../../../../Compiler/Parsing/InputUses.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 { collectContinuationValues } from './ContinuationValues';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { pattern } from '../Text/patterns';\nimport { firstWord, unescapeIdentifier } from './LineText';\nimport { validateInteractionBodies } from './InteractionAlternatives';\nimport { ParserContext } from './ParserContext';\nimport { parseDescription } from './DescriptionParser';\nimport { locationOf, SourceLine } from './SourceLine';\n\n// Typed authoring facts from bodies the TS syntax tree does not yet model. Never serialized as ESM.\nexport interface InputUse {\n readonly command: string;\n readonly property: string;\n readonly scope: readonly string[];\n readonly location: SourceLocation;\n readonly isParameter?: boolean;\n}\n\ninterface InputOwner { command: string; kind: 'form' | 'execute' | 'invokes' | 'other'; indent: number }\nconst form = pattern('^form\\\\s+[A-Za-z_]\\\\w*\\\\s+for\\\\s+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)$');\nconst execution = pattern('^(execute|invokes)\\\\s+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)$');\nconst field = pattern('^field\\\\s+([\\\\w.]+)(?:\\\\s|$)');\nconst argument = pattern('^with\\\\s+([A-Za-z_]\\\\w*)\\\\s+from\\\\s+.+$');\nconst mapping = pattern('^(@?[\\\\w.]+)\\\\s*=(?!=|>)\\\\s*.+$');\nconst parameter = pattern('^parameter\\\\s+([A-Za-z_]\\\\w*)(?:\\\\s+([\\\\w.]+(?:\\\\[\\\\])?))?$');\nconst actionBoundaries = new Set(['refresh', 'navigate', 'open', 'close', 'set', 'notify', 'confirm', 'raise', 'on', 'when', 'otherwise']);\n\n// A single forward walk, tracking owners by indentation and skipping fences as opaque text.\nexport function collectInputUses(context: ParserContext, header: SourceLine): void {\n const owners: InputOwner[] = [];\n const parameters = new Set<string>();\n const inputs: InputUse[] = [];\n const isBehavior = firstWord(header.content) === 'behavior';\n let formDescription: string | null = null;\n const recognize = (line: SourceLine): void => {\n while (owners.length > 0 && owners[owners.length - 1].indent >= line.indent) owners.pop();\n const declared = isBehavior && owners.length === 0 ? parameter.exec(line.content) : null;\n if (declared !== null) parameters.add(declared[1]);\n const formMatch = form.exec(line.content);\n const execute = execution.exec(line.content);\n if (formMatch !== null) owners.push({ command: formMatch[1], kind: 'form', indent: line.indent });\n else if (execute !== null) owners.push({ command: execute[2], kind: execute[1] as 'execute' | 'invokes', indent: line.indent });\n else if (actionBoundaries.has(firstWord(line.content))) owners.push({ command: '', kind: 'other', indent: line.indent });\n else {\n const owner = owners.at(-1);\n if (owner === undefined || owner.kind === 'other') return;\n const supplied = (owner.kind === 'form' ? field : owner.kind === 'execute' ? argument : mapping).exec(line.content);\n if (supplied !== null) inputs.push({ command: owner.command, property: unescapeIdentifier(supplied[1]), scope: context.scope, location: locationOf(line) });\n }\n };\n recognize(header);\n const lines = [header];\n for (let child = context.peekChild(header.indent); child !== undefined; child = context.peekChild(header.indent)) {\n context.reader.takeSignificant();\n while (owners.length > 0 && owners[owners.length - 1].indent >= child.indent) owners.pop();\n if (form.test(header.content) && firstWord(child.content) === 'description' && owners.at(-1)?.kind === 'form') {\n formDescription = parseDescription(context, child, formDescription, `Form '${header.content.split(pattern('\\\\s+'))[1]}'`);\n } else if (child.content.startsWith('```')) context.skipFencedBody();\n else {\n lines.push(child);\n recognize(child);\n }\n }\n validateInteractionBodies(context, lines);\n context.continuationValues.push(...collectContinuationValues(lines, context.scope));\n // Parameters may be declared after their bindings; commit facts once their scope is complete.\n for (const input of inputs) context.inputUses.push(parameters.has(input.command) ? { ...input, isParameter: true } : input);\n}\n"],"mappings":"A,yZAsBA,MAAMA,EAAOC,EAAQ,+DAA+D,EAC9EC,EAAYD,EAAQ,oDAAoD,EACxEE,EAAQF,EAAQ,8BAA8B,EAC9CG,EAAWH,EAAQ,yCAAyC,EAC5DI,EAAUJ,EAAQ,iCAAiC,EACnDK,EAAYL,EAAQ,6DAA6D,EACjFM,kBAAmB,IAAI,IAAI,CAAC,UAAW,WAAY,OAAQ,QAAS,MAAO,SAAU,UAAW,QAAS,KAAM,OAAQ,WAAW,CAAC,EAGzI,SAAgB,iBAAiB,EAAwB,EAA0B,CAC/E,IAAMC,EAAuB,CAAC,EACxBC,kBAAa,IAAI,IACjBC,EAAqB,CAAC,EACtBC,EAAaC,EAAUC,EAAO,OAAO,IAAM,WAC7CC,EAAiC,KAC/B,UAAa,GAA2B,CAC1C,KAAON,EAAO,OAAS,GAAKA,EAAOA,EAAO,OAAS,EAAE,CAAC,QAAUO,EAAK,QAAQP,EAAO,IAAI,EACxF,IAAMQ,EAAWL,GAAcH,EAAO,SAAW,EAAIF,EAAU,KAAKS,EAAK,OAAO,EAAI,KAChFC,IAAa,MAAMP,EAAW,IAAIO,EAAS,EAAE,EACjD,IAAMC,EAAYjB,EAAK,KAAKe,EAAK,OAAO,EAClCG,EAAUhB,EAAU,KAAKa,EAAK,OAAO,EAC3C,GAAIE,IAAc,KAAMT,EAAO,KAAK,CAAE,QAASS,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E,EAAM,KAAKC,CAAK,EAChB,UAAUA,CAAK,EAEvB,CACAE,EAA0BL,EAASE,CAAK,EACxCF,EAAQ,mBAAmB,KAAK,GAAGM,EAA0BJ,EAAOF,EAAQ,KAAK,CAAC,EAElF,IAAK,IAAMO,KAASnB,EAAQY,EAAQ,UAAU,KAAKb,EAAW,IAAIoB,EAAM,OAAO,EAAI,CAAE,GAAGA,EAAO,YAAa,EAAK,EAAIA,CAAK,CAC9H,C"}
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{dotNetWhitespace as t,pattern as n}from"../Text/patterns.js";import{locationOf as r}from"./SourceLine.js";import{firstWord as i}from"./LineText.js";import{interactionBody as a,interactionExecutions as o}from"./InteractionExecutions.js";import{parseCondition as s}from"./ConditionParser.js";import{validateCondition as c}from"./GuardedActionParser.js";import{LineReader as l}from"./LineReader.js";import{ParserContext as u}from"./ParserContext.js";const d=n(`^screen${t}+template(?:${t}|$)`);function interactionAncestry(e){let t=/* @__PURE__ */ new Map,n=[],a=!1;for(let o of e)if(o.content.startsWith("```"))a=!a;else if(!(a||o.content.length===0||o.content.startsWith(`//`))){for(;n.length>0&&n[n.length-1].indent>=o.indent;)n.pop();[`on`,`uses`].includes(i(o.content))&&t.set(o.number,n.map(e=>({keyword:d.test(e.content)?`screen template`:i(e.content),location:r(e)}))),n.push(o)}return t}const f=n(`^when${t}+([^\\n]+)${t}+execute${t}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),p=n(`^on${t}+([^\\n]+)$`),m=n(`^where${t}+([^\\n]+)$`),h=/* @__PURE__ */ new Set([`execute`,`navigate`,`open`,`close`,`refresh`,`set`,`notify`,`confirm`,`raise`]),g=n(`^behavior${t}+([A-Za-z_]\\w*)$`),_=n(`^uses${t}+([A-Za-z_]\\w*)$`),v=n(`^([A-Za-z_]\\w*)${t}+([^\\n]+)$`);function validateInteractionBodies(t,n){let l=g.exec(n[0]?.content??``);l!==null&&t.interactionBehaviors.push({name:l[1],location:r(n[0])});for(let l=0;l<n.length;l++){let u=n[l],d=_.exec(u.content);d!==null&&t.interactionUses.push({behavior:d[1],location:r(u),ancestors:t.interactionAncestors.get(u.number)??[],arguments:a(n,u).flatMap(e=>{let t=v.exec(e.content);return t===null?[]:[{name:t[1],value:t[2].trim()}]})});let g=p.exec(u.content);if(g===null||g[1].startsWith(`row-click `))continue;let y=[];for(let e=l+1;e<n.length&&n[e].indent>u.indent;e++)y.push(n[e]);let b=y.filter(e=>e.indent===y[0]?.indent),x=b.filter(e=>[`when`,`otherwise`].includes(i(e.content))),S=[`click`,`double click`,`select`,`change`].includes(g[1].trim()),C=[`click`,`double click`,`select`].includes(g[1].trim()),w=b.filter(e=>m.test(e.content)),T=[],E=[],D=!1;for(let n of x){let l=i(n.content)===`when`,u=l?f.exec(n.content):null;if(l){D&&t.error(e.MisplacedActionOtherwise,`A 'when' alternative must precede 'otherwise'`,r(n));let i=s(t,u?.[1]??n.content.slice(4).trim(),r(n),!0);if(i!==null){c(t,i);let e=o(u===null?a(y,n):[{...n,content:`execute ${u[2]}`},...a(y,n)]);T.push({condition:i,executions:e,location:r(n),message:`This 'when' alternative is shadowed by earlier alternatives in this interaction`})}u!==null&&t.error(e.InlineInteractionAlternative,`Interaction alternatives require an indented action list, not 'when <condition> execute <Command>'`,r(n))}else(D||n.content!==`otherwise`)&&t.error(e.MisplacedActionOtherwise,`An interaction permits one final block-form 'otherwise'`,r(n)),D=!0,E=o(a(y,n));let d=y[y.indexOf(n)+1];u===null&&(d===void 0||d.indent<=n.indent||!h.has(i(d.content)))&&t.error(e.InteractionAlternativeWithoutActions,`An interaction alternative requires a non-empty action list`,r(n))}if(x.length>0&&(S||t.error(e.UnsupportedInteractionAlternatives,`Interaction alternatives are only supported on click, double click, select and change`,r(u)),(w.length>0||b.some(e=>h.has(i(e.content))))&&t.error(e.MixedInteractionAlternatives,`Interaction alternatives cannot mix with plain actions or 'where'`,r(u)),x.some(e=>i(e.content)===`when`)||t.error(e.GuardedActionWithoutAlternatives,`A guarded interaction requires at least one 'when' alternative`,r(u))),C)for(let e of w)deprecateWhere(t,e);T.length>0&&t.guardedInteractions.push({location:r(u),ancestors:t.interactionAncestors.get(u.number)??[],alternatives:T,otherwise:E})}}function deprecateWhere(t,n){let i=new u(new l([]));i.sourceOptions=t.sourceOptions;let a=s(i,m.exec(n.content)[1].trim(),r(n),!0);a!==null&&c(i,a);let o=`Opaque 'where' on click, double click and select is deprecated; use block-form 'when' item conditions`;a!==null&&i.diagnostics.length===0?t.warning(e.LegacyInteractionWhere,o,r(n)):t.information(e.LegacyInteractionWhere,o,r(n))}export{interactionAncestry,validateInteractionBodies};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{interactionBody as t,interactionExecutions as n}from"./InteractionExecutions.js";import{dotNetWhitespace as r,pattern as i}from"../Text/patterns.js";import{parseCondition as a}from"./ConditionParser.js";import{validateCondition as o}from"./GuardedActionParser.js";import{firstWord as s}from"./LineText.js";import{LineReader as c}from"./LineReader.js";import{ParserContext as l}from"./ParserContext.js";import{locationOf as u}from"./SourceLine.js";const d=i(`^screen${r}+template(?:${r}|$)`);function interactionAncestry(e){let t=/* @__PURE__ */ new Map,n=[],r=!1;for(let i of e)if(i.content.startsWith("```"))r=!r;else if(!(r||i.content.length===0||i.content.startsWith(`//`))){for(;n.length>0&&n[n.length-1].indent>=i.indent;)n.pop();[`on`,`uses`].includes(s(i.content))&&t.set(i.number,n.map(e=>({keyword:d.test(e.content)?`screen template`:s(e.content),location:u(e)}))),n.push(i)}return t}const f=i(`^when${r}+([^\\n]+)${r}+execute${r}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),p=i(`^on${r}+([^\\n]+)$`),m=i(`^where${r}+([^\\n]+)$`),h=/* @__PURE__ */ new Set([`execute`,`navigate`,`open`,`close`,`refresh`,`set`,`notify`,`confirm`,`raise`]),g=i(`^behavior${r}+([A-Za-z_]\\w*)$`),_=i(`^uses${r}+([A-Za-z_]\\w*)$`),v=i(`^([A-Za-z_]\\w*)${r}+([^\\n]+)$`);function validateInteractionBodies(r,i){let c=g.exec(i[0]?.content??``);c!==null&&r.interactionBehaviors.push({name:c[1],location:u(i[0])});for(let c=0;c<i.length;c++){let l=i[c],d=_.exec(l.content);d!==null&&r.interactionUses.push({behavior:d[1],location:u(l),ancestors:r.interactionAncestors.get(l.number)??[],arguments:t(i,l).flatMap(e=>{let t=v.exec(e.content);return t===null?[]:[{name:t[1],value:t[2].trim()}]})});let g=p.exec(l.content);if(g===null||g[1].startsWith(`row-click `))continue;let y=[];for(let e=c+1;e<i.length&&i[e].indent>l.indent;e++)y.push(i[e]);let b=y.filter(e=>e.indent===y[0]?.indent),x=b.filter(e=>[`when`,`otherwise`].includes(s(e.content))),S=[`click`,`double click`,`select`,`change`].includes(g[1].trim()),C=[`click`,`double click`,`select`].includes(g[1].trim()),w=b.filter(e=>m.test(e.content)),T=[],E=[],D=!1;for(let i of x){let c=s(i.content)===`when`,l=c?f.exec(i.content):null;if(c){D&&r.error(e.MisplacedActionOtherwise,`A 'when' alternative must precede 'otherwise'`,u(i));let s=a(r,l?.[1]??i.content.slice(4).trim(),u(i),!0);if(s!==null){o(r,s);let e=n(l===null?t(y,i):[{...i,content:`execute ${l[2]}`},...t(y,i)]);T.push({condition:s,executions:e,location:u(i),message:`This 'when' alternative is shadowed by earlier alternatives in this interaction`})}l!==null&&r.error(e.InlineInteractionAlternative,`Interaction alternatives require an indented action list, not 'when <condition> execute <Command>'`,u(i))}else(D||i.content!==`otherwise`)&&r.error(e.MisplacedActionOtherwise,`An interaction permits one final block-form 'otherwise'`,u(i)),D=!0,E=n(t(y,i));let d=y[y.indexOf(i)+1];l===null&&(d===void 0||d.indent<=i.indent||!h.has(s(d.content)))&&r.error(e.InteractionAlternativeWithoutActions,`An interaction alternative requires a non-empty action list`,u(i))}if(x.length>0&&(S||r.error(e.UnsupportedInteractionAlternatives,`Interaction alternatives are only supported on click, double click, select and change`,u(l)),(w.length>0||b.some(e=>h.has(s(e.content))))&&r.error(e.MixedInteractionAlternatives,`Interaction alternatives cannot mix with plain actions or 'where'`,u(l)),x.some(e=>s(e.content)===`when`)||r.error(e.GuardedActionWithoutAlternatives,`A guarded interaction requires at least one 'when' alternative`,u(l))),C)for(let e of w)deprecateWhere(r,e);T.length>0&&r.guardedInteractions.push({location:u(l),ancestors:r.interactionAncestors.get(l.number)??[],alternatives:T,otherwise:E})}}function deprecateWhere(t,n){let r=new l(new c([]));r.sourceOptions=t.sourceOptions;let i=a(r,m.exec(n.content)[1].trim(),u(n),!0);i!==null&&o(r,i);let s=`Opaque 'where' on click, double click and select is deprecated; use block-form 'when' item conditions`;i!==null&&r.diagnostics.length===0?t.warning(e.LegacyInteractionWhere,s,u(n)):t.information(e.LegacyInteractionWhere,s,u(n))}export{interactionAncestry,validateInteractionBodies};
2
2
  //# sourceMappingURL=InteractionAlternatives.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"InteractionAlternatives.js","names":["screenTemplate","pattern","dotNetWhitespace","result","ancestors","fenced","line","lines","firstWord","ancestor","locationOf","inline","trigger","where","actions","behavior","uses","behaviorArgument","declaration","context","index","header","attachment","interactionBody","match","on","body","child","children","branches","supported","deprecatesWhere","guards","alternatives","otherwise","sawOtherwise","branch","isWhen","DiagnosticCodes","condition","parseCondition","validateCondition","executions","interactionExecutions","nested","guard","probe","ParserContext","LineReader","message"],"sources":["../../../../../../Compiler/Parsing/InteractionAlternatives.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 { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { GuardedInteractionAlternative } from './GuardedInteractionAlternative';\nimport { InteractionExecution } from './InteractionExecution';\nimport { interactionBody, interactionExecutions } from './InteractionExecutions';\nimport { dotNetWhitespace, pattern } from '../Text/patterns';\nimport { parseCondition } from './ConditionParser';\nimport { validateCondition } from './GuardedActionParser';\nimport { firstWord } from './LineText';\nimport { LineReader } from './LineReader';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\n// Authoring facts only: interaction bodies are still opaque in the serialized TS AST.\nexport interface InteractionAncestor {\n readonly keyword: string;\n readonly location: SourceLocation;\n}\n\nexport interface GuardedInteractionBinding {\n readonly location: SourceLocation;\n readonly ancestors: readonly InteractionAncestor[];\n readonly alternatives: readonly GuardedInteractionAlternative[];\n readonly otherwise: readonly InteractionExecution[];\n}\n\nconst screenTemplate = pattern(`^screen${dotNetWhitespace}+template(?:${dotNetWhitespace}|$)`);\n\n// Capture attachment ancestry before parsing consumes opaque bodies. Fenced code is not Screenplay.\nexport function interactionAncestry(lines: readonly SourceLine[]): ReadonlyMap<number, readonly InteractionAncestor[]> {\n const result = new Map<number, readonly InteractionAncestor[]>();\n const ancestors: SourceLine[] = [];\n let fenced = false;\n for (const line of lines) {\n if (line.content.startsWith('```')) {\n fenced = !fenced;\n continue;\n }\n if (fenced || line.content.length === 0 || line.content.startsWith('//')) continue;\n while (ancestors.length > 0 && ancestors[ancestors.length - 1].indent >= line.indent) ancestors.pop();\n if (['on', 'uses'].includes(firstWord(line.content))) result.set(line.number, ancestors.map(ancestor => ({ keyword: screenTemplate.test(ancestor.content) ? 'screen template' : firstWord(ancestor.content), location: locationOf(ancestor) })));\n ancestors.push(line);\n }\n return result;\n}\n\nconst inline = pattern(`^when${dotNetWhitespace}+([^\\\\n]+)${dotNetWhitespace}+execute${dotNetWhitespace}+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)$`);\nconst trigger = pattern(`^on${dotNetWhitespace}+([^\\\\n]+)$`);\nconst where = pattern(`^where${dotNetWhitespace}+([^\\\\n]+)$`);\nconst actions = new Set(['execute', 'navigate', 'open', 'close', 'refresh', 'set', 'notify', 'confirm', 'raise']);\nconst behavior = pattern(`^behavior${dotNetWhitespace}+([A-Za-z_]\\\\w*)$`);\nconst uses = pattern(`^uses${dotNetWhitespace}+([A-Za-z_]\\\\w*)$`);\nconst behaviorArgument = pattern(`^([A-Za-z_]\\\\w*)${dotNetWhitespace}+([^\\\\n]+)$`);\n\n// Interaction bodies remain opaque in the TS AST. Check their structure instead of silently accepting\n// alternatives the C# compiler refuses. Input collection supplies only significant, non-fenced lines.\nexport function validateInteractionBodies(context: ParserContext, lines: readonly SourceLine[]): void {\n const declaration = behavior.exec(lines[0]?.content ?? '');\n if (declaration !== null) context.interactionBehaviors.push({ name: declaration[1], location: locationOf(lines[0]) });\n for (let index = 0; index < lines.length; index++) {\n const header = lines[index];\n const attachment = uses.exec(header.content);\n if (attachment !== null) context.interactionUses.push({\n behavior: attachment[1], location: locationOf(header), ancestors: context.interactionAncestors.get(header.number) ?? [],\n arguments: interactionBody(lines, header).flatMap(line => {\n const match = behaviorArgument.exec(line.content);\n return match === null ? [] : [{ name: match[1], value: match[2].trim() }];\n }),\n });\n const on = trigger.exec(header.content);\n if (on === null || on[1].startsWith('row-click ')) continue;\n const body: SourceLine[] = [];\n for (let child = index + 1; child < lines.length && lines[child].indent > header.indent; child++) body.push(lines[child]);\n const children = body.filter(line => line.indent === body[0]?.indent);\n const branches = children.filter(line => ['when', 'otherwise'].includes(firstWord(line.content)));\n const supported = ['click', 'double click', 'select', 'change'].includes(on[1].trim());\n const deprecatesWhere = ['click', 'double click', 'select'].includes(on[1].trim());\n const guards = children.filter(line => where.test(line.content));\n const alternatives: GuardedInteractionAlternative[] = [];\n let otherwise: readonly InteractionExecution[] = [];\n let sawOtherwise = false;\n for (const branch of branches) {\n const isWhen = firstWord(branch.content) === 'when';\n const match = isWhen ? inline.exec(branch.content) : null;\n if (isWhen) {\n if (sawOtherwise) context.error(DiagnosticCodes.MisplacedActionOtherwise, \"A 'when' alternative must precede 'otherwise'\", locationOf(branch));\n const condition = parseCondition(context, match?.[1] ?? branch.content.slice(4).trim(), locationOf(branch), true);\n if (condition !== null) {\n validateCondition(context, condition);\n const executions = match === null ? interactionExecutions(interactionBody(body, branch))\n : interactionExecutions([{ ...branch, content: `execute ${match[2]}` }, ...interactionBody(body, branch)]);\n alternatives.push({ condition, executions, location: locationOf(branch), message: \"This 'when' alternative is shadowed by earlier alternatives in this interaction\" });\n }\n if (match !== null) context.error(DiagnosticCodes.InlineInteractionAlternative, \"Interaction alternatives require an indented action list, not 'when <condition> execute <Command>'\", locationOf(branch));\n } else {\n if (sawOtherwise || branch.content !== 'otherwise') context.error(DiagnosticCodes.MisplacedActionOtherwise, \"An interaction permits one final block-form 'otherwise'\", locationOf(branch));\n sawOtherwise = true;\n otherwise = interactionExecutions(interactionBody(body, branch));\n }\n const position = body.indexOf(branch);\n const nested = body[position + 1];\n if (match === null && (nested === undefined || nested.indent <= branch.indent || !actions.has(firstWord(nested.content)))) {\n context.error(DiagnosticCodes.InteractionAlternativeWithoutActions, 'An interaction alternative requires a non-empty action list', locationOf(branch));\n }\n }\n if (branches.length > 0) {\n if (!supported) context.error(DiagnosticCodes.UnsupportedInteractionAlternatives, 'Interaction alternatives are only supported on click, double click, select and change', locationOf(header));\n if (guards.length > 0 || children.some(line => actions.has(firstWord(line.content)))) {\n context.error(DiagnosticCodes.MixedInteractionAlternatives, \"Interaction alternatives cannot mix with plain actions or 'where'\", locationOf(header));\n }\n if (!branches.some(line => firstWord(line.content) === 'when')) context.error(DiagnosticCodes.GuardedActionWithoutAlternatives, \"A guarded interaction requires at least one 'when' alternative\", locationOf(header));\n }\n if (deprecatesWhere) for (const guard of guards) deprecateWhere(context, guard);\n if (alternatives.length > 0) context.guardedInteractions.push({ location: locationOf(header), ancestors: context.interactionAncestors.get(header.number) ?? [], alternatives, otherwise });\n }\n}\n\nfunction deprecateWhere(context: ParserContext, line: SourceLine): void {\n const probe = new ParserContext(new LineReader([]));\n probe.sourceOptions = context.sourceOptions;\n const condition = parseCondition(probe, where.exec(line.content)![1].trim(), locationOf(line), true);\n if (condition !== null) validateCondition(probe, condition);\n const message = \"Opaque 'where' on click, double click and select is deprecated; use block-form 'when' item conditions\";\n if (condition !== null && probe.diagnostics.length === 0) context.warning(DiagnosticCodes.LegacyInteractionWhere, message, locationOf(line));\n else context.information(DiagnosticCodes.LegacyInteractionWhere, message, locationOf(line));\n}\n"],"mappings":"+jBA6BA,MAAMA,EAAiBC,EAAQ,UAAUC,EAAiB,cAAcA,EAAiB,IAAI,EAG7F,SAAgB,oBAAoB,EAAmF,CACnH,IAAMC,kBAAS,IAAI,IACbC,EAA0B,CAAC,EAC7BC,EAAS,GACb,IAAK,IAAMC,KAAQC,EACf,GAAID,EAAK,QAAQ,WAAW,KAAK,EAC7B,EAAS,CAACD,OAGd,GAAI,KAAUC,EAAK,QAAQ,SAAW,GAAKA,EAAK,QAAQ,WAAW,IAAI,GACvE,MAAOF,EAAU,OAAS,GAAKA,EAAUA,EAAU,OAAS,EAAE,CAAC,QAAUE,EAAK,QAAQF,EAAU,IAAI,EAChG,CAAC,KAAM,MAAM,CAAC,CAAC,SAASI,EAAUF,EAAK,OAAO,CAAC,GAAGH,EAAO,IAAIG,EAAK,OAAQF,EAAU,IAAI,IAAa,CAAE,QAASJ,EAAe,KAAKS,EAAS,OAAO,EAAI,kBAAoBD,EAAUC,EAAS,OAAO,EAAG,SAAUC,EAAWD,CAAQ,CAAE,EAAE,CAAC,EAC/OL,EAAU,KAAKE,CAAI,CAFiF,CAIxG,OAAOH,CACX,CAEA,MAAMQ,EAASV,EAAQ,QAAQC,EAAiB,YAAYA,EAAiB,UAAUA,EAAiB,8BAA8B,EAChIU,EAAUX,EAAQ,MAAMC,EAAiB,YAAY,EACrDW,EAAQZ,EAAQ,SAASC,EAAiB,YAAY,EACtDY,kBAAU,IAAI,IAAI,CAAC,UAAW,WAAY,OAAQ,QAAS,UAAW,MAAO,SAAU,UAAW,OAAO,CAAC,EAC1GC,EAAWd,EAAQ,YAAYC,EAAiB,kBAAkB,EAClEc,EAAOf,EAAQ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,wGACZV,IAAc,MAAQO,EAAM,YAAY,SAAW,EAAG3B,EAAQ,QAAQmB,EAAgB,uBAAwBW,EAASvC,EAAWJ,CAAI,CAAC,EACtIa,EAAQ,YAAYmB,EAAgB,uBAAwBW,EAASvC,EAAWJ,CAAI,CAAC,CAC9F"}
1
+ {"version":3,"file":"InteractionAlternatives.js","names":["screenTemplate","pattern","dotNetWhitespace","result","ancestors","fenced","line","lines","firstWord","ancestor","locationOf","inline","trigger","where","actions","behavior","uses","behaviorArgument","declaration","context","index","header","attachment","interactionBody","match","on","body","child","children","branches","supported","deprecatesWhere","guards","alternatives","otherwise","sawOtherwise","branch","isWhen","DiagnosticCodes","condition","parseCondition","validateCondition","executions","interactionExecutions","nested","guard","probe","ParserContext","LineReader","message"],"sources":["../../../../../../Compiler/Parsing/InteractionAlternatives.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 { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { GuardedInteractionAlternative } from './GuardedInteractionAlternative';\nimport { InteractionExecution } from './InteractionExecution';\nimport { interactionBody, interactionExecutions } from './InteractionExecutions';\nimport { dotNetWhitespace, pattern } from '../Text/patterns';\nimport { parseCondition } from './ConditionParser';\nimport { validateCondition } from './GuardedActionParser';\nimport { firstWord } from './LineText';\nimport { LineReader } from './LineReader';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\n// Authoring facts only: interaction bodies are still opaque in the serialized TS AST.\nexport interface InteractionAncestor {\n readonly keyword: string;\n readonly location: SourceLocation;\n}\n\nexport interface GuardedInteractionBinding {\n readonly location: SourceLocation;\n readonly ancestors: readonly InteractionAncestor[];\n readonly alternatives: readonly GuardedInteractionAlternative[];\n readonly otherwise: readonly InteractionExecution[];\n}\n\nconst screenTemplate = pattern(`^screen${dotNetWhitespace}+template(?:${dotNetWhitespace}|$)`);\n\n// Capture attachment ancestry before parsing consumes opaque bodies. Fenced code is not Screenplay.\nexport function interactionAncestry(lines: readonly SourceLine[]): ReadonlyMap<number, readonly InteractionAncestor[]> {\n const result = new Map<number, readonly InteractionAncestor[]>();\n const ancestors: SourceLine[] = [];\n let fenced = false;\n for (const line of lines) {\n if (line.content.startsWith('```')) {\n fenced = !fenced;\n continue;\n }\n if (fenced || line.content.length === 0 || line.content.startsWith('//')) continue;\n while (ancestors.length > 0 && ancestors[ancestors.length - 1].indent >= line.indent) ancestors.pop();\n if (['on', 'uses'].includes(firstWord(line.content))) result.set(line.number, ancestors.map(ancestor => ({ keyword: screenTemplate.test(ancestor.content) ? 'screen template' : firstWord(ancestor.content), location: locationOf(ancestor) })));\n ancestors.push(line);\n }\n return result;\n}\n\nconst inline = pattern(`^when${dotNetWhitespace}+([^\\\\n]+)${dotNetWhitespace}+execute${dotNetWhitespace}+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)$`);\nconst trigger = pattern(`^on${dotNetWhitespace}+([^\\\\n]+)$`);\nconst where = pattern(`^where${dotNetWhitespace}+([^\\\\n]+)$`);\nconst actions = new Set(['execute', 'navigate', 'open', 'close', 'refresh', 'set', 'notify', 'confirm', 'raise']);\nconst behavior = pattern(`^behavior${dotNetWhitespace}+([A-Za-z_]\\\\w*)$`);\nconst uses = pattern(`^uses${dotNetWhitespace}+([A-Za-z_]\\\\w*)$`);\nconst behaviorArgument = pattern(`^([A-Za-z_]\\\\w*)${dotNetWhitespace}+([^\\\\n]+)$`);\n\n// Interaction bodies remain opaque in the TS AST. Check their structure instead of silently accepting\n// alternatives the C# compiler refuses. Input collection supplies only significant, non-fenced lines.\nexport function validateInteractionBodies(context: ParserContext, lines: readonly SourceLine[]): void {\n const declaration = behavior.exec(lines[0]?.content ?? '');\n if (declaration !== null) context.interactionBehaviors.push({ name: declaration[1], location: locationOf(lines[0]) });\n for (let index = 0; index < lines.length; index++) {\n const header = lines[index];\n const attachment = uses.exec(header.content);\n if (attachment !== null) context.interactionUses.push({\n behavior: attachment[1], location: locationOf(header), ancestors: context.interactionAncestors.get(header.number) ?? [],\n arguments: interactionBody(lines, header).flatMap(line => {\n const match = behaviorArgument.exec(line.content);\n return match === null ? [] : [{ name: match[1], value: match[2].trim() }];\n }),\n });\n const on = trigger.exec(header.content);\n if (on === null || on[1].startsWith('row-click ')) continue;\n const body: SourceLine[] = [];\n for (let child = index + 1; child < lines.length && lines[child].indent > header.indent; child++) body.push(lines[child]);\n const children = body.filter(line => line.indent === body[0]?.indent);\n const branches = children.filter(line => ['when', 'otherwise'].includes(firstWord(line.content)));\n const supported = ['click', 'double click', 'select', 'change'].includes(on[1].trim());\n const deprecatesWhere = ['click', 'double click', 'select'].includes(on[1].trim());\n const guards = children.filter(line => where.test(line.content));\n const alternatives: GuardedInteractionAlternative[] = [];\n let otherwise: readonly InteractionExecution[] = [];\n let sawOtherwise = false;\n for (const branch of branches) {\n const isWhen = firstWord(branch.content) === 'when';\n const match = isWhen ? inline.exec(branch.content) : null;\n if (isWhen) {\n if (sawOtherwise) context.error(DiagnosticCodes.MisplacedActionOtherwise, \"A 'when' alternative must precede 'otherwise'\", locationOf(branch));\n const condition = parseCondition(context, match?.[1] ?? branch.content.slice(4).trim(), locationOf(branch), true);\n if (condition !== null) {\n validateCondition(context, condition);\n const executions = match === null ? interactionExecutions(interactionBody(body, branch))\n : interactionExecutions([{ ...branch, content: `execute ${match[2]}` }, ...interactionBody(body, branch)]);\n alternatives.push({ condition, executions, location: locationOf(branch), message: \"This 'when' alternative is shadowed by earlier alternatives in this interaction\" });\n }\n if (match !== null) context.error(DiagnosticCodes.InlineInteractionAlternative, \"Interaction alternatives require an indented action list, not 'when <condition> execute <Command>'\", locationOf(branch));\n } else {\n if (sawOtherwise || branch.content !== 'otherwise') context.error(DiagnosticCodes.MisplacedActionOtherwise, \"An interaction permits one final block-form 'otherwise'\", locationOf(branch));\n sawOtherwise = true;\n otherwise = interactionExecutions(interactionBody(body, branch));\n }\n const position = body.indexOf(branch);\n const nested = body[position + 1];\n if (match === null && (nested === undefined || nested.indent <= branch.indent || !actions.has(firstWord(nested.content)))) {\n context.error(DiagnosticCodes.InteractionAlternativeWithoutActions, 'An interaction alternative requires a non-empty action list', locationOf(branch));\n }\n }\n if (branches.length > 0) {\n if (!supported) context.error(DiagnosticCodes.UnsupportedInteractionAlternatives, 'Interaction alternatives are only supported on click, double click, select and change', locationOf(header));\n if (guards.length > 0 || children.some(line => actions.has(firstWord(line.content)))) {\n context.error(DiagnosticCodes.MixedInteractionAlternatives, \"Interaction alternatives cannot mix with plain actions or 'where'\", locationOf(header));\n }\n if (!branches.some(line => firstWord(line.content) === 'when')) context.error(DiagnosticCodes.GuardedActionWithoutAlternatives, \"A guarded interaction requires at least one 'when' alternative\", locationOf(header));\n }\n if (deprecatesWhere) for (const guard of guards) deprecateWhere(context, guard);\n if (alternatives.length > 0) context.guardedInteractions.push({ location: locationOf(header), ancestors: context.interactionAncestors.get(header.number) ?? [], alternatives, otherwise });\n }\n}\n\nfunction deprecateWhere(context: ParserContext, line: SourceLine): void {\n const probe = new ParserContext(new LineReader([]));\n probe.sourceOptions = context.sourceOptions;\n const condition = parseCondition(probe, where.exec(line.content)![1].trim(), locationOf(line), true);\n if (condition !== null) validateCondition(probe, condition);\n const message = \"Opaque 'where' on click, double click and select is deprecated; use block-form 'when' item conditions\";\n if (condition !== null && probe.diagnostics.length === 0) context.warning(DiagnosticCodes.LegacyInteractionWhere, message, locationOf(line));\n else context.information(DiagnosticCodes.LegacyInteractionWhere, message, locationOf(line));\n}\n"],"mappings":"A,+jBA6BA,MAAMA,EAAiBC,EAAQ,UAAUC,EAAiB,cAAcA,EAAiB,IAAI,EAG7F,SAAgB,oBAAoB,EAAmF,CACnH,IAAMC,kBAAS,IAAI,IACbC,EAA0B,CAAC,EAC7BC,EAAS,GACb,IAAK,IAAMC,KAAQC,EACf,GAAID,EAAK,QAAQ,WAAW,KAAK,EAC7B,EAAS,CAACD,OAGd,G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K,OAAO,CAAC,CAAC,IAC/Ea,EAAQ,MAAMmB,EAAgB,6BAA8B,oEAAqE5B,EAAWW,CAAM,CAAC,EAElJQ,EAAS,KAAK,GAAQrB,EAAUF,EAAK,OAAO,IAAM,MAAM,GAAGa,EAAQ,MAAMmB,EAAgB,iCAAkC,iEAAkE5B,EAAWW,CAAM,CAAC,GAEpNU,EAAiB,IAAK,IAAMc,KAASb,EAAQ,eAAeb,EAAS0B,CAAK,EAC1EZ,EAAa,OAAS,GAAGd,EAAQ,oBAAoB,KAAK,CAAE,SAAUT,EAAWW,CAAM,EAAG,UAAWF,EAAQ,qBAAqB,IAAIE,EAAO,MAAM,GAAK,CAAC,EAAG,eAAc,WAAU,CAAC,CAC7L,CACJ,CAEA,SAAS,eAAe,EAAwB,EAAwB,CACpE,IAAMyB,EAAQ,IAAIC,EAAc,IAAIC,EAAW,CAAC,CAAC,CAAC,EAClD,EAAM,cAAgB7B,EAAQ,cAC9B,IAAMoB,EAAYC,EAAeM,EAAOjC,EAAM,KAAKP,EAAK,OAAO,CAAC,CAAE,EAAE,CAAC,KAAK,EAAGI,EAAWJ,CAAI,EAAG,EAAI,EAC/FiC,IAAc,MAAME,EAAkBK,EAAOP,CAAS,EAC1D,IAAMU,EAAU,wGACZV,IAAc,MAAQO,EAAM,YAAY,SAAW,EAAG3B,EAAQ,QAAQmB,EAAgB,uBAAwBW,EAASvC,EAAWJ,CAAI,CAAC,EACtIa,EAAQ,YAAYmB,EAAgB,uBAAwBW,EAASvC,EAAWJ,CAAI,CAAC,CAC9F,C"}
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{dotNetWhitespace as e,pattern as t}from"../Text/patterns.js";import{locationOf as n}from"./SourceLine.js";import{firstWord as r}from"./LineText.js";const i=t(`^execute${e}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),a=t(`^with${e}+([A-Za-z_]\\w*)${e}+from${e}+([^\\n]+)$`),o=RegExp(`^${e}+|${e}+$`,`gu`),s=t(`^on${e}+(success|failure|result)$`),c=/* @__PURE__ */ new Set([`execute`,`refresh`,`confirm`,`open`,`raise`]);function interactionBody(e,t){let n=e.indexOf(t)+1,r=n;for(;r<e.length&&e[r].indent>t.indent;)r++;return e.slice(n,r)}function interactionExecutions(e,l=1){if(l>16||e.length===0)return[];let u=[];for(let d of e.filter(t=>t.indent===e[0].indent)){let f=i.exec(d.content),p=r(d.content);if(f===null&&!c.has(p))continue;let m=interactionBody(e,d),h=m.filter(e=>e.indent===m[0]?.indent);if(f!==null){let e=h.flatMap(e=>{let t=a.exec(e.content);return t===null?[]:[{kind:`InteractionArgumentSyntax`,name:t[1],binding:t[2].replace(o,``),location:n(e)}]});u.push({command:f[1],arguments:e})}for(let e of[`success`,`failure`,`result`])if(e!==`result`||t(`^open[\\u0009-\\u000d\\u0020\\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]+dialog[\\u0009-\\u000d\\u0020\\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]+`).test(d.content))for(let t of h.filter(t=>s.exec(t.content)?.[1]===e))u.push(...interactionExecutions(interactionBody(m,t),l+1))}return u}export{interactionBody,interactionExecutions};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{dotNetWhitespace as e,pattern as t}from"../Text/patterns.js";import{firstWord as n}from"./LineText.js";import{locationOf as r}from"./SourceLine.js";const i=t(`^execute${e}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),a=t(`^with${e}+([A-Za-z_]\\w*)${e}+from${e}+([^\\n]+)$`),o=RegExp(`^${e}+|${e}+$`,`gu`),s=t(`^on${e}+(success|failure|result)$`),c=/* @__PURE__ */ new Set([`execute`,`refresh`,`confirm`,`open`,`raise`]);function interactionBody(e,t){let n=e.indexOf(t)+1,r=n;for(;r<e.length&&e[r].indent>t.indent;)r++;return e.slice(n,r)}function interactionExecutions(e,l=1){if(l>16||e.length===0)return[];let u=[];for(let d of e.filter(t=>t.indent===e[0].indent)){let f=i.exec(d.content),p=n(d.content);if(f===null&&!c.has(p))continue;let m=interactionBody(e,d),h=m.filter(e=>e.indent===m[0]?.indent);if(f!==null){let e=h.flatMap(e=>{let t=a.exec(e.content);return t===null?[]:[{kind:`InteractionArgumentSyntax`,name:t[1],binding:t[2].replace(o,``),location:r(e)}]});u.push({command:f[1],arguments:e})}for(let e of[`success`,`failure`,`result`])if(e!==`result`||t(`^open[\\u0009-\\u000d\\u0020\\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]+dialog[\\u0009-\\u000d\\u0020\\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]+`).test(d.content))for(let t of h.filter(t=>s.exec(t.content)?.[1]===e))u.push(...interactionExecutions(interactionBody(m,t),l+1))}return u}export{interactionBody,interactionExecutions};
2
2
  //# sourceMappingURL=InteractionExecutions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"InteractionExecutions.js","names":["execute","pattern","dotNetWhitespace","argument","trim","continuation","failable","start","lines","header","end","depth","result","line","command","keyword","firstWord","body","children","arguments_","match","locationOf","outcome","child"],"sources":["../../../../../../Compiler/Parsing/InteractionExecutions.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 { InteractionArgumentSyntax } from '../Syntax/Screens';\nimport { dotNetWhitespace, pattern } from '../Text/patterns';\nimport { InteractionExecution } from './InteractionExecution';\nimport { firstWord } from './LineText';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst execute = pattern(`^execute${dotNetWhitespace}+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)$`);\nconst argument = pattern(`^with${dotNetWhitespace}+([A-Za-z_]\\\\w*)${dotNetWhitespace}+from${dotNetWhitespace}+([^\\\\n]+)$`);\nconst trim = new RegExp(`^${dotNetWhitespace}+|${dotNetWhitespace}+$`, 'gu');\nconst continuation = pattern(`^on${dotNetWhitespace}+(success|failure|result)$`);\nconst failable = new Set(['execute', 'refresh', 'confirm', 'open', 'raise']);\n\nexport function interactionBody(lines: readonly SourceLine[], header: SourceLine): readonly SourceLine[] {\n const start = lines.indexOf(header) + 1;\n let end = start;\n while (end < lines.length && lines[end].indent > header.indent) end++;\n return lines.slice(start, end);\n}\n\n// Preserve action, success, failure, result order even when continuations are authored out of order.\nexport function interactionExecutions(lines: readonly SourceLine[], depth = 1): readonly InteractionExecution[] {\n if (depth > 16 || lines.length === 0) return [];\n const result: InteractionExecution[] = [];\n for (const header of lines.filter(line => line.indent === lines[0].indent)) {\n const command = execute.exec(header.content);\n const keyword = firstWord(header.content);\n if (command === null && !failable.has(keyword)) continue;\n const body = interactionBody(lines, header);\n const children = body.filter(line => line.indent === body[0]?.indent);\n if (command !== null) {\n const arguments_: InteractionArgumentSyntax[] = children.flatMap(line => {\n const match = argument.exec(line.content);\n return match === null ? [] : [{ kind: 'InteractionArgumentSyntax', name: match[1], binding: match[2].replace(trim, ''), location: locationOf(line) }];\n });\n result.push({ command: command[1], arguments: arguments_ });\n }\n for (const outcome of ['success', 'failure', 'result']) {\n if (outcome === 'result' && !pattern(`^open${dotNetWhitespace}+dialog${dotNetWhitespace}+`).test(header.content)) continue;\n for (const child of children.filter(line => continuation.exec(line.content)?.[1] === outcome)) {\n result.push(...interactionExecutions(interactionBody(body, child), depth + 1));\n }\n }\n }\n return result;\n}\n"],"mappings":"gNASA,MAAMA,EAAUC,EAAQ,WAAWC,EAAiB,8BAA8B,EAC5EC,EAAWF,EAAQ,QAAQC,EAAiB,kBAAkBA,EAAiB,OAAOA,EAAiB,YAAY,EACnHE,EAAW,OAAO,IAAIF,EAAiB,IAAIA,EAAiB,IAAK,IAAI,EACrEG,EAAeJ,EAAQ,MAAMC,EAAiB,2BAA2B,EACzEI,kBAAW,IAAI,IAAI,CAAC,UAAW,UAAW,UAAW,OAAQ,OAAO,CAAC,EAE3E,SAAg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AAC,GAAG,KAAOS,CAAO,EACxFV,EAAO,KAAK,GAAG,sBAAsB,gBAAgBK,EAAMM,CAAK,EAAGZ,EAAQ,CAAC,CAAC,CAGzF,CACA,OAAOC,CACX"}
1
+ {"version":3,"file":"InteractionExecutions.js","names":["execute","pattern","dotNetWhitespace","argument","trim","continuation","failable","start","lines","header","end","depth","result","line","command","keyword","firstWord","body","children","arguments_","match","locationOf","outcome","child"],"sources":["../../../../../../Compiler/Parsing/InteractionExecutions.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 { InteractionArgumentSyntax } from '../Syntax/Screens';\nimport { dotNetWhitespace, pattern } from '../Text/patterns';\nimport { InteractionExecution } from './InteractionExecution';\nimport { firstWord } from './LineText';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst execute = pattern(`^execute${dotNetWhitespace}+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)$`);\nconst argument = pattern(`^with${dotNetWhitespace}+([A-Za-z_]\\\\w*)${dotNetWhitespace}+from${dotNetWhitespace}+([^\\\\n]+)$`);\nconst trim = new RegExp(`^${dotNetWhitespace}+|${dotNetWhitespace}+$`, 'gu');\nconst continuation = pattern(`^on${dotNetWhitespace}+(success|failure|result)$`);\nconst failable = new Set(['execute', 'refresh', 'confirm', 'open', 'raise']);\n\nexport function interactionBody(lines: readonly SourceLine[], header: SourceLine): readonly SourceLine[] {\n const start = lines.indexOf(header) + 1;\n let end = start;\n while (end < lines.length && lines[end].indent > header.indent) end++;\n return lines.slice(start, end);\n}\n\n// Preserve action, success, failure, result order even when continuations are authored out of order.\nexport function interactionExecutions(lines: readonly SourceLine[], depth = 1): readonly InteractionExecution[] {\n if (depth > 16 || lines.length === 0) return [];\n const result: InteractionExecution[] = [];\n for (const header of lines.filter(line => line.indent === lines[0].indent)) {\n const command = execute.exec(header.content);\n const keyword = firstWord(header.content);\n if (command === null && !failable.has(keyword)) continue;\n const body = interactionBody(lines, header);\n const children = body.filter(line => line.indent === body[0]?.indent);\n if (command !== null) {\n const arguments_: InteractionArgumentSyntax[] = children.flatMap(line => {\n const match = argument.exec(line.content);\n return match === null ? [] : [{ kind: 'InteractionArgumentSyntax', name: match[1], binding: match[2].replace(trim, ''), location: locationOf(line) }];\n });\n result.push({ command: command[1], arguments: arguments_ });\n }\n for (const outcome of ['success', 'failure', 'result']) {\n if (outcome === 'result' && !pattern(`^open${dotNetWhitespace}+dialog${dotNetWhitespace}+`).test(header.content)) continue;\n for (const child of children.filter(line => continuation.exec(line.content)?.[1] === outcome)) {\n result.push(...interactionExecutions(interactionBody(body, child), depth + 1));\n }\n }\n }\n return result;\n}\n"],"mappings":"A,gNASA,MAAMA,EAAUC,EAAQ,WAAWC,EAAiB,8BAA8B,EAC5EC,EAAWF,EAAQ,QAAQC,EAAiB,kBAAkBA,EAAiB,OAAOA,EAAiB,YAAY,EACnHE,EAAW,OAAO,IAAIF,EAAiB,IAAIA,EAAiB,IAAK,IAAI,EACrEG,EAAeJ,EAAQ,MAAMC,EAAiB,2BAA2B,EACzEI,kBAAW,IAAI,IAAI,CAAC,UAAW,UAAW,UAAW,OAAQ,OAAO,CAAC,EAE3E,SAAgB,gBAAgB,EAA8B,EAA2C,CACrG,IAAMC,EAAQC,EAAM,QAAQC,CAAM,EAAI,EAClCC,EAAMH,EACV,KAAOG,EAAMF,EAAM,QAAUA,EAAME,EAAI,CAAC,OAASD,EAAO,QAAQ,IAChE,OAAOD,EAAM,MAAMD,EAAOG,CAAG,CACjC,CAGA,SAAgB,sBAAsB,EAA8B,EAAQ,EAAoC,CAC5G,GAAIC,EAAQ,IAAMH,EAAM,SAAW,EAAG,MAAO,CAAC,EAC9C,IAAMI,EAAiC,CAAC,EACxC,IAAK,IAAMH,KAAUD,EAAM,OAAO,GAAQK,EAAK,SAAWL,EAAM,EAAE,CAAC,MAAM,EAAG,CACxE,IAAMM,EAAUd,EAAQ,KAAKS,EAAO,OAAO,EACrCM,EAAUC,EAAUP,EAAO,OAAO,EACxC,GAAIK,IAAY,MAAQ,CAACR,EAAS,IAAIS,CAAO,EAAG,SAChD,IAAME,EAAO,gBAAgBT,EAAOC,CAAM,EACpCS,EAAWD,EAAK,OAAO,GAAQJ,EAAK,SAAWI,EAAK,EAAE,EAAE,MAAM,EACpE,GAAIH,IAAY,KAAM,CAClB,IAAMK,EAA0CD,EAAS,QAAQ,GAAQ,CACrE,IAAME,EAAQjB,EAAS,KAAKU,EAAK,OAAO,EACxC,OAAOO,IAAU,KAAO,CAAC,EAAI,CAAC,CAAE,KAAM,4BAA6B,KAAMA,EAAM,GAAI,QAASA,EAAM,EAAE,CAAC,QAAQhB,EAAM,EAAE,EAAG,SAAUiB,EAAWR,CAAI,CAAE,CAAC,CACxJ,CAAC,EACDD,EAAO,KAAK,CAAE,QAASE,EAAQ,GAAI,UAAWK,CAAW,CAAC,CAC9D,CACA,IAAK,IAAMG,IAAW,CAAC,UAAW,UAAW,QAAQ,EACjD,GAAIA,IAAY,UAAarB,EAAQ,6MAAqD,CAAC,CAAC,KAAKQ,EAAO,OAAO,EAC/G,IAAK,IAAMc,KAASL,EAAS,OAAO,GAAQb,EAAa,KAAKQ,EAAK,OAAO,CAAC,GAAG,KAAOS,CAAO,EACxFV,EAAO,KAAK,GAAG,sBAAsB,gBAAgBK,EAAMM,CAAK,EAAGZ,EAAQ,CAAC,CAAC,CAGzF,CACA,OAAOC,CACX,C"}
@@ -1 +1 @@
1
- {"version":3,"file":"LegacyTextRulePatterns.js","names":["pattern","literal","value","escaped","index","character","control","v1"],"sources":["../../../../../../Compiler/Parsing/LegacyTextRulePatterns.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 { PortableMatchReplacement } from './PortableMatchReplacement';\n\nconst strictEnd = '(?![\\\\s\\\\S])';\nconst v2Escaped = '\\\\^$.|?*+()[]{}/';\nconst v1Escaped = '\\\\*+?|{[()^$.# ';\n\n/** Recognizes only losslessly re-escaped Studio shapes, never arbitrary lookaround. */\nexport function recognizeLegacyTextRule(pattern: string): PortableMatchReplacement | undefined {\n if (pattern.length >= 11 + 1 && pattern.startsWith('^(?![\\\\s\\\\S]*') && pattern.endsWith(')')) {\n const literal = pattern.slice(11, -1);\n const value = decode(literal, false) ?? decode(literal, true);\n return value === undefined ? undefined : { kind: 'NotContains', value };\n }\n if (pattern.startsWith('^(?!')) {\n if (pattern.length >= 4 + strictEnd.length + 1 && pattern.endsWith(strictEnd + ')')) return replacement('NotEqual', pattern.slice(4, -(strictEnd.length + 1)), false);\n if (pattern.length >= 4 + 2 && pattern.endsWith('$)')) return replacement('NotEqual', pattern.slice(4, -2), true);\n }\n if (pattern.length < strictEnd.length || !pattern.endsWith(strictEnd)) return undefined;\n if (pattern.length >= 1 + strictEnd.length && pattern.startsWith('^')) return replacement('Equal', pattern.slice(1, -strictEnd.length), false);\n return replacement('EndsWith', pattern.slice(0, -strictEnd.length), false);\n}\n\nexport function escapeLegacyTextRule(value: string, v1: boolean): string {\n let escaped = '';\n for (let index = 0; index < value.length; index++) {\n const character = value[index];\n const control = v1 ? ({ '\\t': 't', '\\n': 'n', '\\f': 'f', '\\r': 'r' } as Record<string, string>)[character] : undefined;\n if (control !== undefined) escaped += '\\\\' + control;\n else escaped += ((v1 ? v1Escaped : v2Escaped).includes(character) ? '\\\\' : '') + character;\n }\n return escaped;\n}\n\nfunction replacement(kind: PortableMatchReplacement['kind'], literal: string, v1: boolean): PortableMatchReplacement | undefined {\n const value = decode(literal, v1);\n return value === undefined ? undefined : { kind, value };\n}\nfunction decode(literal: string, v1: boolean): string | undefined {\n let value = '';\n for (let index = 0; index < literal.length; index++) {\n let character = literal[index];\n if (character === '\\\\') {\n if (++index === literal.length) return undefined;\n character = literal[index];\n if (v1) character = ({ t: '\\t', n: '\\n', f: '\\f', r: '\\r' } as Record<string, string>)[character] ?? character;\n }\n value += character;\n }\n return escapeLegacyTextRule(value, v1) === literal ? value : undef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,EAAmD,CAC7H,IAAMD,EAAQ,OAAOD,EAASM,CAAE,EAChC,OAAOL,IAAU,IAAA,GAAY,IAAA,GAAY,CAAE,OAAM,OAAM,CAC3D,CACA,SAAS,OAAO,EAAiB,EAAiC,CAC9D,IAAIA,EAAQ,GACZ,IAAK,IAAIE,EAAQ,EAAGA,EAAQH,EAAQ,OAAQ,IAAS,CACjD,IAAII,EAAYJ,EAAQG,GACxB,GAAIC,IAAc,KAAM,CACpB,GAAI,EAAED,IAAUH,EAAQ,OAAQ,OAChC,EAAYA,EAAQG,GAChBG,IAAI,EAAa,CAAE,EAAG,IAAM,EAAG;EAAM,EAAG,KAAM,EAAG,IAAK,EAA6BF,IAAcA,EACzG,CACA,GAASA,CACb,CACA,OAAO,qBAAqBH,EAAOK,CAAE,IAAMN,EAAUC,EAAQ,IAAA,EACjE"}
1
+ {"version":3,"file":"LegacyTextRulePatterns.js","names":["pattern","literal","value","escaped","index","character","control","v1"],"sources":["../../../../../../Compiler/Parsing/LegacyTextRulePatterns.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 { PortableMatchReplacement } from './PortableMatchReplacement';\n\nconst strictEnd = '(?![\\\\s\\\\S])';\nconst v2Escaped = '\\\\^$.|?*+()[]{}/';\nconst v1Escaped = '\\\\*+?|{[()^$.# ';\n\n/** Recognizes only losslessly re-escaped Studio shapes, never arbitrary lookaround. */\nexport function recognizeLegacyTextRule(pattern: string): PortableMatchReplacement | undefined {\n if (pattern.length >= 11 + 1 && pattern.startsWith('^(?![\\\\s\\\\S]*') && pattern.endsWith(')')) {\n const literal = pattern.slice(11, -1);\n const value = decode(literal, false) ?? decode(literal, true);\n return value === undefined ? undefined : { kind: 'NotContains', value };\n }\n if (pattern.startsWith('^(?!')) {\n if (pattern.length >= 4 + strictEnd.length + 1 && pattern.endsWith(strictEnd + ')')) return replacement('NotEqual', pattern.slice(4, -(strictEnd.length + 1)), false);\n if (pattern.length >= 4 + 2 && pattern.endsWith('$)')) return replacement('NotEqual', pattern.slice(4, -2), true);\n }\n if (pattern.length < strictEnd.length || !pattern.endsWith(strictEnd)) return undefined;\n if (pattern.length >= 1 + strictEnd.length && pattern.startsWith('^')) return replacement('Equal', pattern.slice(1, -strictEnd.length), false);\n return replacement('EndsWith', pattern.slice(0, -strictEnd.length), false);\n}\n\nexport function escapeLegacyTextRule(value: string, v1: boolean): string {\n let escaped = '';\n for (let index = 0; index < value.length; index++) {\n const character = value[index];\n const control = v1 ? ({ '\\t': 't', '\\n': 'n', '\\f': 'f', '\\r': 'r' } as Record<string, string>)[character] : undefined;\n if (control !== undefined) escaped += '\\\\' + control;\n else escaped += ((v1 ? v1Escaped : v2Escaped).includes(character) ? '\\\\' : '') + character;\n }\n return escaped;\n}\n\nfunction replacement(kind: PortableMatchReplacement['kind'], literal: string, v1: boolean): PortableMatchReplacement | undefined {\n const value = decode(literal, v1);\n return value === undefined ? undefined : { kind, value };\n}\nfunction decode(literal: string, v1: boolean): string | undefined {\n let value = '';\n for (let index = 0; index < literal.length; index++) {\n let character = literal[index];\n if (character === '\\\\') {\n if (++index === literal.length) return undefined;\n character = literal[index];\n if (v1) character = ({ t: '\\t', n: '\\n', f: '\\f', r: '\\r' } as Record<string, string>)[character] ?? character;\n }\n value += character;\n }\n return escapeLegacyTextRule(value, v1) === literal ? value : undefined;\n}\n"],"mappings":"A,qDAUA,SAAgB,wBAAwB,EAAuD,CAC3F,GAAIA,EAAQ,QAAU,IAAUA,EAAQ,WAAW,eAAe,GAAKA,EAAQ,SAAS,GAAG,EAAG,CAC1F,IAAMC,EAAUD,EAAQ,MAAM,GAAI,EAAE,EAC9BE,EAAQ,OAAOD,EAAS,EAAK,GAAK,OAAOA,EAAS,EAAI,EAC5D,OAAOC,IAAU,IAAA,GAAY,IAAA,GAAY,CAAE,KAAM,cAAe,OAAM,CAC1E,CACA,GAAIF,EAAQ,WAAW,MAAM,EAAG,CAC5B,GAAIA,EAAQ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,IAAM,EAAG;EAAM,EAAG,KAAM,EAAG,IAAK,EAA6BF,IAAcA,EACzG,CACA,GAASA,CACb,CACA,OAAO,qBAAqBH,EAAOK,CAAE,IAAMN,EAAUC,EAAQ,IAAA,EACjE,C"}
@@ -1 +1 @@
1
- {"version":3,"file":"LineReader.js","names":["LineReader","lines","#index","isBlank","reader","line"],"sources":["../../../../../../Compiler/Parsing/LineReader.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 { isBlank, SourceLine } from './SourceLine';\n\n// Walks the lines of a document forward. Significant reads skip blank lines; a raw read takes the next line\n// as it is, which is how a fenced code block keeps its blank lines.\nexport class LineReader {\n #index = 0;\n\n constructor(private readonly lines: readonly SourceLine[]) {}\n\n get atEnd(): boolean {\n return this.lines.slice(this.#index).every(isBlank);\n }\n\n // Independent lookahead must not consume the committed parser's source.\n fork(): LineReader {\n const reader = new LineReader(this.lines);\n reader.#index = this.#index;\n return reader;\n }\n\n peekSignificant(): SourceLine | undefined {\n while (this.#index < this.lines.length && isBlank(this.lines[this.#index])) {\n this.#index++;\n }\n return this.#index < this.lines.length ? this.lines[this.#index] : undefined;\n }\n\n takeSignificant(): SourceLine {\n const line = this.peekSignificant();\n if (line === undefined) {\n throw new Error('There is no significant line left to take');\n }\n this.#index++;\n return line;\n }\n\n takeRaw(): SourceLine | undefined {\n return this.#index < this.lines.length ? this.lines[this.#index++] : undefined;\n }\n}\n"],"mappings":"+FAOA,IAAaA,EAAb,MAAa,UAAW,CAGS,MAF7B,GAAS,EAET,YAAY,EAA+C,CAA9B,KAAA,MAAAC,CAA+B,CAE5D,IAAI,OAAiB,CACjB,OAAO,KAAK,MAAM,MAAM,KAAKC,EAAM,CAAC,CAAC,MAAMC,CAAO,CACtD,CAGA,MAAmB,CACf,IAAMC,EAAS,IAAI,WAAW,KAAK,KAAK,EAExC,MADA,GAAOF,GAAS,KAAKA,GACdE,CACX,CAEA,iBAA0C,CACtC,KAAO,KAAKF,GAAS,KAAK,MAAM,QAAUC,EAAQ,KAAK,MAAM,KAAKD,GAAO,GACrE,KAAKA,KAET,OAAO,KAAKA,GAAS,KAAK,MAAM,OAAS,KAAK,MAAM,KAAKA,IAAU,IAAA,EACvE,CAEA,iBAA8B,CAC1B,IAAMG,EAAO,KAAK,gBAAgB,EAClC,GAAIA,IAAS,IAAA,GACT,MAAU,MAAM,2CAA2C,EAG/D,MADA,MAAKH,KACEG,CACX,CAEA,SAAkC,CAC9B,OAAO,KAAKH,GAAS,KAAK,MAAM,OAAS,KAAK,MAAM,KAAKA,MAAY,IAAA,EACzE,CACJ"}
1
+ {"version":3,"file":"LineReader.js","names":["LineReader","lines","#index","isBlank","reader","line"],"sources":["../../../../../../Compiler/Parsing/LineReader.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 { isBlank, SourceLine } from './SourceLine';\n\n// Walks the lines of a document forward. Significant reads skip blank lines; a raw read takes the next line\n// as it is, which is how a fenced code block keeps its blank lines.\nexport class LineReader {\n #index = 0;\n\n constructor(private readonly lines: readonly SourceLine[]) {}\n\n get atEnd(): boolean {\n return this.lines.slice(this.#index).every(isBlank);\n }\n\n // Independent lookahead must not consume the committed parser's source.\n fork(): LineReader {\n const reader = new LineReader(this.lines);\n reader.#index = this.#index;\n return reader;\n }\n\n peekSignificant(): SourceLine | undefined {\n while (this.#index < this.lines.length && isBlank(this.lines[this.#index])) {\n this.#index++;\n }\n return this.#index < this.lines.length ? this.lines[this.#index] : undefined;\n }\n\n takeSignificant(): SourceLine {\n const line = this.peekSignificant();\n if (line === undefined) {\n throw new Error('There is no significant line left to take');\n }\n this.#index++;\n return line;\n }\n\n takeRaw(): SourceLine | undefined {\n return this.#index < this.lines.length ? this.lines[this.#index++] : undefined;\n }\n}\n"],"mappings":"A,+FAOA,IAAaA,EAAb,MAAa,UAAW,CAGS,MAF7B,GAAS,EAET,YAAY,EAA+C,CAA9B,KAAA,MAAAC,CAA+B,CAE5D,IAAI,OAAiB,CACjB,OAAO,KAAK,MAAM,MAAM,KAAKC,EAAM,CAAC,CAAC,MAAMC,CAAO,CACtD,CAGA,MAAmB,CACf,IAAMC,EAAS,IAAI,WAAW,KAAK,KAAK,EAExC,MADA,GAAOF,GAAS,KAAKA,GACdE,CACX,CAEA,iBAA0C,CACtC,KAAO,KAAKF,GAAS,KAAK,MAAM,QAAUC,EAAQ,KAAK,MAAM,KAAKD,GAAO,GACrE,KAAKA,KAET,OAAO,KAAKA,GAAS,KAAK,MAAM,OAAS,KAAK,MAAM,KAAKA,IAAU,IAAA,EACvE,CAEA,iBAA8B,CAC1B,IAAMG,EAAO,KAAK,gBAAgB,EAClC,GAAIA,IAAS,IAAA,GACT,MAAU,MAAM,2CAA2C,EAG/D,MADA,MAAKH,KACEG,CACX,CAEA,SAAkC,CAC9B,OAAO,KAAKH,GAAS,KAAK,MAAM,OAAS,KAAK,MAAM,KAAKA,MAAY,IAAA,EACzE,CACJ,E"}
@@ -1 +1 @@
1
- {"version":3,"file":"LineText.js","names":["space","content","identifier","parts","start","inString","inTemplate","index","text","current","separator"],"sources":["../../../../../../Compiler/Parsing/LineText.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\n// The first space-separated word of a line's content - the keyword every construct is recognized by.\nexport const firstWord = (content: string): string => {\n const space = content.indexOf(' ');\n return space === -1 ? content : content.substring(0, space);\n};\n\n// Removes the '@' that lets an identifier read as a keyword ('@validate' names a property called validate).\nexport const unescapeIdentifier = (identifier: string): string => identifier.replaceAll('@', '');\n\n// Splits text on a separator that is not inside a string or a template literal.\nexport function splitTopLevel(text: string, separator: string): string[] {\n const parts: string[] = [];\n let start = 0;\n let inString = false;\n let inTemplate = false;\n for (let index = 0; index < text.length; index++) {\n const current = text[index];\n if (current === '\\\\' && inString && index + 1 < text.length) {\n index++;\n } else if (current === '\"' && !inTemplate) {\n inString = !inString;\n } else if (current === '`' && !inString) {\n inTemplate = !inTemplate;\n } else if (current === separator && !inString && !inTemplate) {\n parts.push(text.substring(start, index));\n start = index + 1;\n }\n }\n parts.push(text.substring(start));\n return parts;\n}\n"],"mappings":"qDAIA,MAAa,UAAa,GAA4B,CAClD,IAAMA,EAAQC,EAAQ,QAAQ,GAAG,EACjC,OAAOD,IAAU,GAAKC,EAAUA,EAAQ,UAAU,EAAGD,CAAK,CAC9D,EAGa,mBAAsB,GAA+BE,EAAW,WAAW,IAAK,EAAE,EAG/F,SAAgB,cAAc,EAAc,EAA6B,CACrE,IAAMC,EAAkB,CAAC,EACrBC,EAAQ,EACRC,EAAW,GACXC,EAAa,GACjB,IAAK,IAAIC,EAAQ,EAAGA,EAAQC,EAAK,OAAQ,IAAS,CAC9C,IAAMC,EAAUD,EAAKD,GACjBE,IAAY,MAAQJ,GAAYE,EAAQ,EAAIC,EAAK,OACjD,IACOC,IAAY,KAAO,CAACH,EAC3B,EAAW,CAACD,EACLI,IAAY,KAAO,CAACJ,EAC3B,EAAa,CAACC,EACPG,IAAYC,GAAa,CAACL,GAAY,CAACC,IAC9CH,EAAM,KAAKK,EAAK,UAAUJ,EAAOG,CAAK,CAAC,EACvC,EAAQA,EAAQ,EAExB,CAEA,OADAJ,EAAM,KAAKK,EAAK,UAAUJ,CAAK,CAAC,EACzBD,CACX"}
1
+ {"version":3,"file":"LineText.js","names":["space","content","identifier","parts","start","inString","inTemplate","index","text","current","separator"],"sources":["../../../../../../Compiler/Parsing/LineText.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\n// The first space-separated word of a line's content - the keyword every construct is recognized by.\nexport const firstWord = (content: string): string => {\n const space = content.indexOf(' ');\n return space === -1 ? content : content.substring(0, space);\n};\n\n// Removes the '@' that lets an identifier read as a keyword ('@validate' names a property called validate).\nexport const unescapeIdentifier = (identifier: string): string => identifier.replaceAll('@', '');\n\n// Splits text on a separator that is not inside a string or a template literal.\nexport function splitTopLevel(text: string, separator: string): string[] {\n const parts: string[] = [];\n let start = 0;\n let inString = false;\n let inTemplate = false;\n for (let index = 0; index < text.length; index++) {\n const current = text[index];\n if (current === '\\\\' && inString && index + 1 < text.length) {\n index++;\n } else if (current === '\"' && !inTemplate) {\n inString = !inString;\n } else if (current === '`' && !inString) {\n inTemplate = !inTemplate;\n } else if (current === separator && !inString && !inTemplate) {\n parts.push(text.substring(start, index));\n start = index + 1;\n }\n }\n parts.push(text.substring(start));\n return parts;\n}\n"],"mappings":"A,qDAIA,MAAa,UAAa,GAA4B,CAClD,IAAMA,EAAQC,EAAQ,QAAQ,GAAG,EACjC,OAAOD,IAAU,GAAKC,EAAUA,EAAQ,UAAU,EAAGD,CAAK,CAC9D,EAGa,mBAAsB,GAA+BE,EAAW,WAAW,IAAK,EAAE,EAG/F,SAAgB,cAAc,EAAc,EAA6B,CACrE,IAAMC,EAAkB,CAAC,EACrBC,EAAQ,EACRC,EAAW,GACXC,EAAa,GACjB,IAAK,IAAIC,EAAQ,EAAGA,EAAQC,EAAK,OAAQ,IAAS,CAC9C,IAAMC,EAAUD,EAAKD,GACjBE,IAAY,MAAQJ,GAAYE,EAAQ,EAAIC,EAAK,OACjD,IACOC,IAAY,KAAO,CAACH,EAC3B,EAAW,CAACD,EACLI,IAAY,KAAO,CAACJ,EAC3B,EAAa,CAACC,EACPG,IAAYC,GAAa,CAACL,GAAY,CAACC,IAC9CH,EAAM,KAAKK,EAAK,UAAUJ,EAAOG,CAAK,CAAC,EACvC,EAAQA,EAAQ,EAExB,CAEA,OADAJ,EAAM,KAAKK,EAAK,UAAUJ,CAAK,CAAC,EACzBD,CACX,C"}
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{MatchAmbiguityGraph as e}from"./MatchAmbiguityGraph.js";import{hasExponentialMatchAmbiguity as t}from"./hasExponentialMatchAmbiguity.js";import{MatchAmbiguityParser as n}from"./MatchAmbiguityParser.js";import{trimMatchAmbiguityGraph as r}from"./trimMatchAmbiguityGraph.js";function descendants(e){return[e,...e.children.flatMap(descendants)]}function unwrap(e){for(;[`group`,`concat`,`alternate`].includes(e.kind)&&e.children.length===1;)e=e.children[0];return e}function rewrite(e,t){if(e.minimum>1)return;let n=unwrap(e.children[0]),r=e.minimum;if(n.kind===`repeat`&&n.maximum===null&&n.minimum<=1)r*=n.minimum,n=unwrap(n.children[0]);else if(n.kind===`alternate`&&n.children.length===2){let e=unwrap(n.children[0]),r=unwrap(n.children[1]);if(e.kind!==`characters`||t.slice(e.offset,e.offset+e.length)!==t.slice(r.offset,r.offset+r.length))return;n=e}else return;let i=t.slice(n.offset,n.offset+n.length);return(n.kind===`characters`?i:`(?:${i})`)+(r===0?`*`:`+`)}var i=class MatchAmbiguity{offset;length;subexpression;suggestion;constructor(e,t,n,r){this.offset=e,this.length=t,this.subexpression=n,this.suggestion=r}get description(){return`Match subexpression '${this.subexpression}' at offset ${this.offset} is exponentially ambiguous and can cause excessive browser backtracking.${this.suggestion===void 0?``:` Use '${this.suggestion}' instead.`}`}static find(i){let a=new n(i).parse(),o=new e(a);if(o.exhausted)return;let s=r(o),c=descendants(a).filter(e=>e.kind===`repeat`&&e.maximum===null).sort((e,t)=>e.length-t.length||e.offset-t.offset);for(let e of c){if(t(o,e,s))return new MatchAmbiguity(e.offset,e.length,i.slice(e.offset,e.offset+e.length),rewrite(e,i));if(o.exhausted)return}}};export{i as MatchAmbiguity};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{hasExponentialMatchAmbiguity as e}from"./hasExponentialMatchAmbiguity.js";import{MatchAmbiguityGraph as t}from"./MatchAmbiguityGraph.js";import{MatchAmbiguityParser as n}from"./MatchAmbiguityParser.js";import{trimMatchAmbiguityGraph as r}from"./trimMatchAmbiguityGraph.js";function descendants(e){return[e,...e.children.flatMap(descendants)]}function unwrap(e){for(;[`group`,`concat`,`alternate`].includes(e.kind)&&e.children.length===1;)e=e.children[0];return e}function rewrite(e,t){if(e.minimum>1)return;let n=unwrap(e.children[0]),r=e.minimum;if(n.kind===`repeat`&&n.maximum===null&&n.minimum<=1)r*=n.minimum,n=unwrap(n.children[0]);else if(n.kind===`alternate`&&n.children.length===2){let e=unwrap(n.children[0]),r=unwrap(n.children[1]);if(e.kind!==`characters`||t.slice(e.offset,e.offset+e.length)!==t.slice(r.offset,r.offset+r.length))return;n=e}else return;let i=t.slice(n.offset,n.offset+n.length);return(n.kind===`characters`?i:`(?:${i})`)+(r===0?`*`:`+`)}var i=class MatchAmbiguity{offset;length;subexpression;suggestion;constructor(e,t,n,r){this.offset=e,this.length=t,this.subexpression=n,this.suggestion=r}get description(){return`Match subexpression '${this.subexpression}' at offset ${this.offset} is exponentially ambiguous and can cause excessive browser backtracking.${this.suggestion===void 0?``:` Use '${this.suggestion}' instead.`}`}static find(i){let a=new n(i).parse(),o=new t(a);if(o.exhausted)return;let s=r(o),c=descendants(a).filter(e=>e.kind===`repeat`&&e.maximum===null).sort((e,t)=>e.length-t.length||e.offset-t.offset);for(let t of c){if(e(o,t,s))return new MatchAmbiguity(t.offset,t.length,i.slice(t.offset,t.offset+t.length),rewrite(t,i));if(o.exhausted)return}}};export{i as MatchAmbiguity};
2
2
  //# sourceMappingURL=MatchAmbiguity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MatchAmbiguity.js","names":["node","body","minimum","left","right","pattern","text","MatchAmbiguity","offset","length","subexpression","suggestion","expression","MatchAmbiguityParser","graph","MatchAmbiguityGraph","live","trimMatchAmbiguityGraph","candidates","candidate","hasExponentialMatchAmbiguity"],"sources":["../../../../../../Compiler/Parsing/MatchAmbiguity.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 { hasExponentialMatchAmbiguity } from './hasExponentialMatchAmbiguity';\nimport { MatchAmbiguityGraph } from './MatchAmbiguityGraph';\nimport { MatchAmbiguityNode } from './MatchAmbiguityNode';\nimport { MatchAmbiguityParser } from './MatchAmbiguityParser';\nimport { trimMatchAmbiguityGraph } from './trimMatchAmbiguityGraph';\n\nfunction descendants(node: MatchAmbiguityNode): MatchAmbiguityNode[] { return [node, ...node.children.flatMap(descendants)]; }\nfunction unwrap(node: MatchAmbiguityNode): MatchAmbiguityNode {\n while (['group', 'concat', 'alternate'].includes(node.kind) && node.children.length === 1) node = node.children[0];\n return node;\n}\nfunction rewrite(node: MatchAmbiguityNode, pattern: string): string | undefined {\n if (node.minimum > 1) return undefined;\n let body = unwrap(node.children[0]);\n let minimum = node.minimum;\n if (body.kind === 'repeat' && body.maximum === null && body.minimum <= 1) {\n minimum *= body.minimum;\n body = unwrap(body.children[0]);\n } else if (body.kind === 'alternate' && body.children.length === 2) {\n const left = unwrap(body.children[0]);\n const right = unwrap(body.children[1]);\n // Restrict this shortcut to one character token; a compound body may stay ambiguous.\n if (left.kind !== 'characters' || pattern.slice(left.offset, left.offset + left.length) !== pattern.slice(right.offset, right.offset + right.length)) return undefined;\n body = left;\n } else return undefined;\n const text = pattern.slice(body.offset, body.offset + body.length);\n return (body.kind === 'characters' ? text : `(?:${text})`) + (minimum === 0 ? '*' : '+');\n}\n\n/** Finding for an admitted pattern; analysis budget exhaustion produces no finding. */\nexport class MatchAmbiguity {\n constructor(readonly offset: number, readonly length: number, readonly subexpression: string, readonly suggestion: string | undefined) { }\n get description(): string {\n return `Match subexpression '${this.subexpression}' at offset ${this.offset} is exponentially ambiguous and can cause excessive browser backtracking.${this.suggestion === undefined ? '' : ` Use '${this.suggestion}' instead.`}`;\n }\n static find(pattern: string): MatchAmbiguity | undefined {\n const expression = new MatchAmbiguityParser(pattern).parse();\n const graph = new MatchAmbiguityGraph(expression);\n if (graph.exhausted) return undefined;\n const live = trimMatchAmbiguityGraph(graph);\n const candidates = descendants(expression).filter(node => node.kind === 'repeat' && node.maximum === null).sort((left, right) => left.length - right.length || left.offset - right.offset);\n for (const candidate of candidates) {\n if (hasExponentialMatchAmbiguity(graph, candidate, live)) return new MatchAmbiguity(candidate.offset, candidate.length, pattern.slice(candidate.offset, candidate.offset + candidate.length), rewrite(candidate, pattern));\n if (graph.exhausted) return undefined;\n }\n return undefined;\n }\n}\n"],"mappings":"6UASA,SAAS,YAAY,EAAgD,CAAE,MAAO,CAACA,EAAM,GAAGA,EAAK,SAAS,QAAQ,WAAW,CAAC,CAAG,CAC7H,SAAS,OAAO,EAA8C,CAC1D,KAAO,CAAC,QAAS,SAAU,WAAW,CAAC,CAAC,SAASA,EAAK,IAAI,GAAKA,EAAK,SAAS,SAAW,GAAG,EAAOA,EAAK,SAAS,GAChH,OAAOA,CACX,CACA,SAAS,QAAQ,EAA0B,EAAqC,CAC5E,GAAIA,EAAK,QAAU,EAAG,OACtB,IAAIC,EAAO,OAAOD,EAAK,SAAS,EAAE,EAC9BE,EAAUF,EAAK,QACnB,GAAIC,EAAK,OAAS,UAAYA,EAAK,UAAY,MAAQA,EAAK,SAAW,EACnE,GAAWA,EAAK,QAChB,EAAO,OAAOA,EAAK,SAAS,EAAE,OAC3B,GAAIA,EAAK,OAAS,aAAeA,EAAK,SAAS,SAAW,EAAG,CAChE,IAAME,EAAO,OAAOF,EAAK,SAAS,EAAE,EAC9BG,EAAQ,OAAOH,EAAK,SAAS,EAAE,EAErC,GAAIE,EAAK,OAAS,cAAgBE,EAAQ,MAAMF,EAAK,OAAQA,EAAK,OAASA,EAAK,MAAM,IAAME,EAAQ,MAAMD,EAAM,OAAQA,EAAM,OAASA,EAAM,MAAM,EAAG,OACtJ,EAAOD,CACX,MAAO,OACP,IAAMG,EAAOD,EAAQ,MAAMJ,EAAK,OAAQA,EAAK,OAASA,EAAK,MAAM,EACjE,OAAQA,EAAK,OAAS,aAAeK,EAAO,MAAMA,EAAK,KAAOJ,IAAY,EAAI,IAAM,IACxF,CAGA,IAAaK,EAAb,MAAa,cAAe,CACH,OAAyB,OAAyB,cAAgC,WAAvG,YAAY,EAAyB,EAAyB,EAAgC,EAAyC,CAAlH,KAAA,OAAAC,EAAyB,KAAA,OAAAC,EAAyB,KAAA,cAAAC,EAAgC,KAAA,WAAAC,CAAkC,CACzI,IAAI,aAAsB,CACtB,MAAO,wBAAwB,KAAK,cAAc,cAAc,KAAK,OAAO,2EAA2E,KAAK,aAAe,IAAA,GAAY,GAAK,SAAS,KAAK,WAAW,aACzN,CACA,OAAO,KAAK,EAA6C,CACrD,IAAMC,EAAa,IAAIC,EAAqBR,CAAO,CAAC,CAAC,MAAM,EACrDS,EAAQ,IAAIC,EAAoBH,CAAU,EAChD,GAAIE,EAAM,UAAW,OACrB,IAAME,EAAOC,EAAwBH,CAAK,EACpCI,EAAa,YAAYN,CAAU,CAAC,CAAC,OAAO,GAAQZ,EAAK,OAAS,UAAYA,EAAK,UAAY,IAAI,CAAC,CAAC,MAAM,EAAM,IAAUG,EAAK,OAASC,EAAM,QAAUD,EAAK,OAASC,EAAM,MAAM,EACzL,IAAK,IAAMe,KAAaD,EAAY,CAChC,GAAIE,EAA6BN,EAAOK,EAAWH,CAAI,EAAG,OAAO,IAAI,eAAeG,EAAU,OAAQA,EAAU,OAAQd,EAAQ,MAAMc,EAAU,OAAQA,EAAU,OAASA,EAAU,MAAM,EAAG,QAAQA,EAAWd,CAAO,CAAC,EACzN,GAAIS,EAAM,UAAW,MACzB,CAEJ,CACJ"}
1
+ {"version":3,"file":"MatchAmbiguity.js","names":["node","body","minimum","left","right","pattern","text","MatchAmbiguity","offset","length","subexpression","suggestion","expression","MatchAmbiguityParser","graph","MatchAmbiguityGraph","live","trimMatchAmbiguityGraph","candidates","candidate","hasExponentialMatchAmbiguity"],"sources":["../../../../../../Compiler/Parsing/MatchAmbiguity.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 { hasExponentialMatchAmbiguity } from './hasExponentialMatchAmbiguity';\nimport { MatchAmbiguityGraph } from './MatchAmbiguityGraph';\nimport { MatchAmbiguityNode } from './MatchAmbiguityNode';\nimport { MatchAmbiguityParser } from './MatchAmbiguityParser';\nimport { trimMatchAmbiguityGraph } from './trimMatchAmbiguityGraph';\n\nfunction descendants(node: MatchAmbiguityNode): MatchAmbiguityNode[] { return [node, ...node.children.flatMap(descendants)]; }\nfunction unwrap(node: MatchAmbiguityNode): MatchAmbiguityNode {\n while (['group', 'concat', 'alternate'].includes(node.kind) && node.children.length === 1) node = node.children[0];\n return node;\n}\nfunction rewrite(node: MatchAmbiguityNode, pattern: string): string | undefined {\n if (node.minimum > 1) return undefined;\n let body = unwrap(node.children[0]);\n let minimum = node.minimum;\n if (body.kind === 'repeat' && body.maximum === null && body.minimum <= 1) {\n minimum *= body.minimum;\n body = unwrap(body.children[0]);\n } else if (body.kind === 'alternate' && body.children.length === 2) {\n const left = unwrap(body.children[0]);\n const right = unwrap(body.children[1]);\n // Restrict this shortcut to one character token; a compound body may stay ambiguous.\n if (left.kind !== 'characters' || pattern.slice(left.offset, left.offset + left.length) !== pattern.slice(right.offset, right.offset + right.length)) return undefined;\n body = left;\n } else return undefined;\n const text = pattern.slice(body.offset, body.offset + body.length);\n return (body.kind === 'characters' ? text : `(?:${text})`) + (minimum === 0 ? '*' : '+');\n}\n\n/** Finding for an admitted pattern; analysis budget exhaustion produces no finding. */\nexport class MatchAmbiguity {\n constructor(readonly offset: number, readonly length: number, readonly subexpression: string, readonly suggestion: string | undefined) { }\n get description(): string {\n return `Match subexpression '${this.subexpression}' at offset ${this.offset} is exponentially ambiguous and can cause excessive browser backtracking.${this.suggestion === undefined ? '' : ` Use '${this.suggestion}' instead.`}`;\n }\n static find(pattern: string): MatchAmbiguity | undefined {\n const expression = new MatchAmbiguityParser(pattern).parse();\n const graph = new MatchAmbiguityGraph(expression);\n if (graph.exhausted) return undefined;\n const live = trimMatchAmbiguityGraph(graph);\n const candidates = descendants(expression).filter(node => node.kind === 'repeat' && node.maximum === null).sort((left, right) => left.length - right.length || left.offset - right.offset);\n for (const candidate of candidates) {\n if (hasExponentialMatchAmbiguity(graph, candidate, live)) return new MatchAmbiguity(candidate.offset, candidate.length, pattern.slice(candidate.offset, candidate.offset + candidate.length), rewrite(candidate, pattern));\n if (graph.exhausted) return undefined;\n }\n return undefined;\n }\n}\n"],"mappings":"A,6UASA,SAAS,YAAY,EAAgD,CAAE,MAAO,CAACA,EAAM,GAAGA,EAAK,SAAS,QAAQ,WAAW,CAAC,CAAG,CAC7H,SAAS,OAAO,EAA8C,CAC1D,KAAO,CAAC,QAAS,SAAU,WAAW,CAAC,CAAC,SAASA,EAAK,IAAI,GAAKA,EAAK,SAAS,SAAW,GAAG,EAAOA,EAAK,SAAS,GAChH,OAAOA,CACX,CACA,SAAS,QAAQ,EAA0B,EAAqC,CAC5E,GAAIA,EAAK,QAAU,EAAG,OACtB,IAAIC,EAAO,OAAOD,EAAK,SAAS,EAAE,EAC9BE,EAAUF,EAAK,QACnB,GAAIC,EAAK,OAAS,UAAYA,EAAK,UAAY,MAAQA,EAAK,SAAW,EACnE,GAAWA,EAAK,QAChB,EAAO,OAAOA,EAAK,SAAS,EAAE,OAC3B,GAAIA,EAAK,OAAS,aAAeA,EAAK,SAAS,SAAW,EAAG,CAChE,IAAME,EAAO,OAAOF,EAAK,SAAS,EAAE,EAC9BG,EAAQ,OAAOH,EAAK,SAAS,EAAE,EAErC,GAAIE,EAAK,OAAS,cAAgBE,EAAQ,MAAMF,EAAK,OAAQA,EAAK,OAASA,EAAK,MAAM,IAAME,EAAQ,MAAMD,EAAM,OAAQA,EAAM,OAASA,EAAM,MAAM,EAAG,OACtJ,EAAOD,CACX,MAAO,OACP,IAAMG,EAAOD,EAAQ,MAAMJ,EAAK,OAAQA,EAAK,OAASA,EAAK,MAAM,EACjE,OAAQA,EAAK,OAAS,aAAeK,EAAO,MAAMA,EAAK,KAAOJ,IAAY,EAAI,IAAM,IACxF,CAGA,IAAaK,EAAb,MAAa,cAAe,CACH,OAAyB,OAAyB,cAAgC,WAAvG,YAAY,EAAyB,EAAyB,EAAgC,EAAyC,CAA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