@cratis/screenplay-language 4.247.3 → 4.248.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/action-subject-authoring.d.ts +2 -0
  2. package/dist/action-subject-authoring.d.ts.map +1 -0
  3. package/dist/bundles/action-subject-authoring.js +2 -0
  4. package/dist/bundles/action-subject-authoring.js.map +1 -0
  5. package/dist/bundles/compiler/Authoring/ActionSubjectQuickFixes.js +6 -0
  6. package/dist/bundles/compiler/Authoring/ActionSubjectQuickFixes.js.map +1 -0
  7. package/dist/bundles/compiler/Authoring/QuickFixes.js +1 -1
  8. package/dist/bundles/compiler/Authoring/QuickFixes.js.map +1 -1
  9. package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js +1 -1
  10. package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js.map +1 -1
  11. package/dist/bundles/compiler/Parsing/ActionSubjectClause.js +2 -0
  12. package/dist/bundles/compiler/Parsing/ActionSubjectClause.js.map +1 -0
  13. package/dist/bundles/compiler/Parsing/ActionSubjectInputs.js +2 -0
  14. package/dist/bundles/compiler/Parsing/ActionSubjectInputs.js.map +1 -0
  15. package/dist/bundles/compiler/Parsing/ActionSubjectResolution.js +2 -0
  16. package/dist/bundles/compiler/Parsing/ActionSubjectResolution.js.map +1 -0
  17. package/dist/bundles/compiler/Parsing/GuardedActionValidator.js +1 -1
  18. package/dist/bundles/compiler/Parsing/GuardedActionValidator.js.map +1 -1
  19. package/dist/bundles/compiler/Parsing/ScreenParser.js +1 -1
  20. package/dist/bundles/compiler/Parsing/ScreenParser.js.map +1 -1
  21. package/dist/bundles/compiler/ScreenActionSubjects.js +2 -0
  22. package/dist/bundles/compiler/ScreenActionSubjects.js.map +1 -0
  23. package/dist/bundles/compiler/Syntax/ActionSubjectInvariants.js +2 -0
  24. package/dist/bundles/compiler/Syntax/ActionSubjectInvariants.js.map +1 -0
  25. package/dist/bundles/compiler/Syntax/ScreenplaySyntaxWalker.js +1 -1
  26. package/dist/bundles/compiler/Syntax/ScreenplaySyntaxWalker.js.map +1 -1
  27. package/dist/bundles/compiler/Syntax/SyntaxCollections.js +1 -1
  28. package/dist/bundles/compiler/Syntax/SyntaxCollections.js.map +1 -1
  29. package/dist/bundles/compiler/Syntax/SyntaxInvariants.js +1 -1
  30. package/dist/bundles/compiler/Syntax/SyntaxInvariants.js.map +1 -1
  31. package/dist/bundles/compiler/Syntax/SyntaxJson.js +1 -1
  32. package/dist/bundles/compiler/Syntax/SyntaxJson.js.map +1 -1
  33. package/dist/bundles/compiler/index.js +1 -1
  34. package/dist/bundles/completion-items.js +4 -4
  35. package/dist/bundles/completion-items.js.map +1 -1
  36. package/dist/bundles/completion-planner.js +2 -2
  37. package/dist/bundles/completion-planner.js.map +1 -1
  38. package/dist/bundles/diagnostic-codes.js +1 -1
  39. package/dist/bundles/diagnostic-codes.js.map +1 -1
  40. package/dist/bundles/hover-content.js +5 -5
  41. package/dist/bundles/hover-content.js.map +1 -1
  42. package/dist/bundles/tokens.js +1 -1
  43. package/dist/bundles/tokens.js.map +1 -1
  44. package/dist/bundles/validation.js +1 -1
  45. package/dist/bundles/validation.js.map +1 -1
  46. package/dist/completion-items.d.ts +2 -0
  47. package/dist/completion-items.d.ts.map +1 -1
  48. package/dist/completion-planner.d.ts.map +1 -1
  49. package/dist/diagnostic-codes.d.ts +5 -0
  50. package/dist/diagnostic-codes.d.ts.map +1 -1
  51. package/dist/hover-content.d.ts.map +1 -1
  52. package/dist/tokens.d.ts.map +1 -1
  53. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionSubjectInputs.js","names":["declarations","diagnostics","context","entry","name","key","input","concept","properties","property","named","keys","authored","identifiers","command","item","DiagnosticCodes","bound","inputs","legacy","current","result","argument","matches"],"sources":["../../../../../../Compiler/Parsing/ActionSubjectInputs.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Diagnostic } from '../Diagnostics/Diagnostic';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { PropertySyntax } from '../Syntax/Declarations';\nimport { InteractionArgumentSyntax, ScreenActionSubjectKind, ScreenDataSyntax } from '../Syntax/Screens';\nimport { SliceSyntax } from '../Syntax/Structure';\nimport { RefusalDeclarations } from './RefusalDeclarations';\n\nexport interface ActionSubjectContext {\n readonly data: readonly ScreenDataSyntax[];\n readonly slice: SliceSyntax;\n readonly location: SourceLocation;\n}\n\nexport class ActionSubjectInputs {\n constructor(readonly declarations: RefusalDeclarations, readonly diagnostics: Diagnostic[]) {}\n\n properties(context: ActionSubjectContext): readonly PropertySyntax[] {\n return context.data.length === 1 ? this.declarations.resolve(context.data[0].type.name, context.slice, entry => entry.readModels)?.node.properties ?? [] : [];\n }\n\n command(name: string, context: ActionSubjectContext): readonly PropertySyntax[] {\n return this.declarations.resolve(name, context.slice, entry => entry.commands)?.node.properties ?? [];\n }\n\n sameConcept(input: PropertySyntax, key: PropertySyntax): boolean {\n return !key.type.isCollection && !key.type.isOptional && input.type.name === key.type.name && this.declarations.application.concepts.filter(concept => concept.name === input.type.name).length === 1;\n }\n\n eligible(input: PropertySyntax): boolean {\n return input.isIdentifier && !input.isGenerated && !input.type.isOptional && !input.type.isCollection;\n }\n\n keys(input: PropertySyntax, properties: readonly PropertySyntax[]): readonly PropertySyntax[] {\n return this.eligible(input) ? properties.filter(property => property.isKey && this.sameConcept(input, property)) : [];\n }\n\n binding(input: PropertySyntax, properties: readonly PropertySyntax[]): PropertySyntax | null {\n const named = properties.filter(property => property.name === input.name && this.declarations.compatible(property.type, input.type) === true);\n if (named.length === 1) return named[0];\n const keys = this.keys(input, properties);\n return keys.length === 1 ? keys[0] : null;\n }\n\n subject(authored: ScreenActionSubjectKind | null | undefined, command: string, bound: readonly string[], context: ActionSubjectContext): ScreenActionSubjectKind | null {\n if (authored != null) return authored;\n const identifiers = this.command(command, context).filter(input => this.eligible(input));\n const keys = identifiers.length === 1 ? this.keys(identifiers[0], this.properties(context)) : [];\n const item = context.data.length === 1 && context.data[0].type.isCollection && keys.length === 1;\n this.diagnostics.push({ severity: 'information', code: DiagnosticCodes.InferredActionSubject, message: `Action '${command}' infers 'for ${item ? 'item' : 'screen'}' from its declared data and identifier types`, location: context.location });\n this.migration(command, bound, context, item);\n return item ? 'Item' : null;\n }\n\n migration(command: string, bound: readonly string[], context: ActionSubjectContext, item: boolean): void {\n if (context.data.length !== 1 || !context.data[0].type.isCollection) return;\n const properties = this.properties(context);\n const inputs = this.command(command, context).filter(input => !input.isGenerated && !bound.includes(input.name));\n const legacy = inputs.flatMap(input => properties.filter(property => input.name.toLowerCase() === property.name.toLowerCase()).map(property => `${input.name} from item.${property.name}`));\n const current = item ? inputs.flatMap(input => {\n const property = this.binding(input, properties);\n return property === null ? [] : [`${input.name} from item.${property.name}`];\n }) : [];\n if (JSON.stringify(legacy) !== JSON.stringify(current)) this.diagnostics.push({ severity: 'warning', code: DiagnosticCodes.ChangedActionSubject, message: `Action '${command}' now infers 'for ${item ? 'item' : 'screen'}'; legacy row-name matching would use ${legacy.length === 0 ? 'no row property' : legacy.join(', ')}`, location: context.location });\n }\n\n legacyInputs(command: string, authored: readonly InteractionArgumentSyntax[], context: ActionSubjectContext): readonly InteractionArgumentSyntax[] | null {\n if (context.data.length !== 1 || !context.data[0].type.isCollection) return null;\n const result = [...authored];\n const properties = this.properties(context);\n for (const input of this.command(command, context).filter(input => !input.isGenerated)) {\n if (result.some(argument => argument.name === input.name)) continue;\n const matches = properties.filter(property => property.name.toLowerCase() === input.name.toLowerCase());\n if (!this.legacyMatchIsSafe(input, properties, matches.length)) return null;\n if (matches.length === 1) result.push({ kind: 'InteractionArgumentSyntax', name: input.name, binding: `item.${matches[0].name}`, location: context.location });\n }\n return result;\n }\n\n private legacyMatchIsSafe(input: PropertySyntax, properties: readonly PropertySyntax[], matches: number): boolean {\n if (matches > 1) return false;\n return matches > 0 || this.keys(input, properties).length === 0;\n }\n\n inputs(command: string, authored: readonly InteractionArgumentSyntax[], context: ActionSubjectContext): readonly InteractionArgumentSyntax[] {\n const result = [...authored];\n if (context.data.length !== 1) return result;\n const properties = this.properties(context);\n for (const input of this.command(command, context).filter(input => !input.isGenerated)) {\n if (result.some(argument => argument.name === input.name)) continue;\n const property = this.binding(input, properties);\n if (property !== null) result.push({ kind: 'InteractionArgumentSyntax', name: input.name, binding: `item.${property.name}`, location: context.location });\n else if (this.keys(input, properties).length > 1) this.diagnostics.push({ severity: 'warning', code: DiagnosticCodes.AmbiguousActionInputBinding, message: `Input '${input.name}' of action '${command}' matches several declared key fields - write an explicit binding`, location: context.location });\n }\n return result;\n }\n}\n"],"mappings":"yHAiBA,IAAa,oBAAb,KAAiC,CACR,aAA4C,YAAjE,YAAY,EAA4C,EAAoC,CAAvE,KAAA,aAAAA,EAA4C,KAAA,YAAAC,CAA4B,CAE7F,WAAW,EAA0D,CACjE,OAAOC,EAAQ,KAAK,SAAW,EAAI,KAAK,aAAa,QAAQA,EAAQ,KAAK,EAAE,CAAC,KAAK,KAAMA,EAAQ,MAAO,GAASC,EAAM,UAAU,CAAC,EAAE,KAAK,YAAc,CAAC,EAAI,CAAC,CAChK,CAEA,QAAQ,EAAc,EAA0D,CAC5E,OAAO,KAAK,aAAa,QAAQC,EAAMF,EAAQ,MAAO,GAASC,EAAM,QAAQ,CAAC,EAAE,KAAK,YAAc,CAAC,CACxG,CAEA,YAAY,EAAuB,EAA8B,CAC7D,MAAO,CAACE,EAAI,KAAK,cAAgB,CAACA,EAAI,KAAK,YAAcC,EAAM,KAAK,OAASD,EAAI,KAAK,MAAQ,KAAK,aAAa,YAAY,SAAS,OAAO,GAAWE,EAAQ,OAASD,EAAM,KAAK,IAAI,CAAC,CAAC,SAAW,CACxM,CAEA,SAAS,EAAgC,CACrC,OAAOA,EAAM,cAAgB,CAACA,EAAM,aAAe,CAACA,EAAM,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AAYe,EAAQ,MAAM,EAAG,OAAO,KACnEA,EAAQ,SAAW,GAAGF,EAAO,KAAK,CAAE,KAAM,4BAA6B,KAAMf,EAAM,KAAM,QAAS,QAAQiB,EAAQ,EAAE,CAAC,OAAQ,SAAUrB,EAAQ,QAAS,CAAC,CACjK,CACA,OAAOmB,CACX,CAEA,kBAA0B,EAAuB,EAAuC,EAA0B,CAE9G,OADIE,EAAU,EAAU,GACjBA,EAAU,GAAK,KAAK,KAAKjB,EAAOE,CAAU,CAAC,CAAC,SAAW,CAClE,CAEA,OAAO,EAAiB,EAAgD,EAAqE,CACzI,IAAMa,EAAS,CAAC,GAAGT,CAAQ,EAC3B,GAAIV,EAAQ,KAAK,SAAW,EAAG,OAAOmB,EACtC,IAAMb,EAAa,KAAK,WAAWN,CAAO,EAC1C,IAAK,IAAMI,KAAS,KAAK,QAAQQ,EAASZ,CAAO,CAAC,CAAC,OAAO,GAAS,CAACI,EAAM,WAAW,EAAG,CACpF,GAAIe,EAAO,KAAK,GAAYC,EAAS,OAAShB,EAAM,IAAI,EAAG,SAC3D,IAAMG,EAAW,KAAK,QAAQH,EAAOE,CAAU,EAC3CC,IAAa,KACR,KAAK,KAAKH,EAAOE,CAAU,CAAC,CAAC,OAAS,GAAG,KAAK,YAAY,KAAK,CAAE,SAAU,UAAW,KAAMQ,EAAgB,4BAA6B,QAAS,UAAUV,EAAM,KAAK,eAAeQ,EAAQ,mEAAoE,SAAUZ,EAAQ,QAAS,CAAC,EADhRmB,EAAO,KAAK,CAAE,KAAM,4BAA6B,KAAMf,EAAM,KAAM,QAAS,QAAQG,EAAS,OAAQ,SAAUP,EAAQ,QAAS,CAAC,CAE5J,CACA,OAAOmB,CACX,CACJ"}
@@ -0,0 +1,2 @@
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{RefusalDeclarations as t}from"./RefusalDeclarations.js";import{ActionSubjectInputs as n}from"./ActionSubjectInputs.js";function resolveActionSubjectApplication(r,i){let a=[],o=new n(new t(r),a),hasSubject=(t,n)=>{if(t.data.length===1)return!0;let r=n?`A guarded action requires exactly one nearest 'data' subject; no data or equally near data bindings leave 'item' unresolved`:`Action 'for item' requires one resolvable data subject - no item binding is inferred`;return a.push({severity:`warning`,code:e.UnresolvedActionSubject,message:r,location:t.location}),!1},toolbar=(e,t)=>{if(e.syntaxKind!==`Action`)return e;let n=o.subject(e.subject,e.target,e.parameters.map(e=>e.name),t),r=e.parameters.map(e=>({kind:`InteractionArgumentSyntax`,name:e.name,binding:e.binding.path,location:e.location})),a=n===`Item`&&hasSubject(t,!1)?o.inputs(e.target,r,t).slice(r.length):[],s=[...e.parameters,...a.map(e=>({kind:`ScreenNavigationParameterSyntax`,name:e.name,binding:{kind:`UiBindingSyntax`,bindingKind:`DataContext`,path:e.binding,query:null,componentId:null,componentPropertyPath:null,mode:null,nullBehavior:null,expectedValueType:null,literal:null,rawText:null,location:e.location},location:e.location}))],c=n==null&&a.length===0?e:{...e,subject:n,parameters:s};return i?.({authored:e,effective:c,command:e.target,context:t}),c},guarded=(t,n)=>{if(!hasSubject(n,!0))return t;if(t.subject===`Screen`&&n.data[0].type.isCollection)return a.push({severity:`warning`,code:e.UnsupportedActionSubjectContext,message:`A guarded action 'for screen' cannot use a collection as 'item' - use a single-record data context or 'for item'`,location:t.location}),t;let r=t.otherwise;return{...t,alternatives:t.alternatives.map(e=>({...e,arguments:o.inputs(e.command,e.arguments,{...n,location:e.location})})),otherwise:r!==null&&r.command!==null?{...r,arguments:o.inputs(r.command,r.arguments,{...n,location:r.location})}:r}},plain=(e,t)=>{let n=o.subject(e.subject,e.command,(e.inputs??[]).map(e=>e.name),t),r=n===`Item`&&hasSubject(t,!1)?o.inputs(e.command,e.inputs??[],t):e.inputs,a=n==null&&r===e.inputs?e:{...e,subject:n,...r===void 0?{}:{inputs:r}};return i?.({authored:e,effective:a,command:e.command,context:t}),a},body=(e,t)=>{let n=e.filter(e=>e.kind===`ScreenDataSyntax`),r={...t,data:n.length>0?n:t.data};return e.map(e=>{let t={...r,location:e.location};switch(e.kind){case`ScreenActionSyntax`:return plain(e,t);case`ScreenGuardedActionSyntax`:return guarded(e,t);case`ScreenToolbarSyntax`:return{...e,items:e.items.map(e=>toolbar(e,{...t,location:e.location}))};case`ScreenSectionSyntax`:return{...e,directives:body(e.directives,r)};case`ScreenTemplateReferenceSyntax`:return{...e,slots:e.slots.map(e=>({...e,directives:body(e.directives,r)}))};case`ScreenComponentSyntax`:return{...e,outlets:e.outlets.map(e=>({...e,directives:body(e.directives,r)}))};default:return e}})},screen=(e,t)=>{let n={data:[],slice:t,location:e.location};return{...e,directives:body(e.directives,n),...e.contributions===void 0?{}:{contributions:e.contributions.map(e=>({...e,directives:body(e.directives,n)}))}}},feature=e=>({...e,features:e.features.map(feature),slices:e.slices.map(e=>({...e,screens:e.screens.map(t=>screen(t,e))}))});return{value:{...r,modules:r.modules.map(e=>({...e,features:e.features.map(feature)}))},diagnostics:a,success:!a.some(e=>e.severity===`error`)}}export{resolveActionSubjectApplication};
2
+ //# sourceMappingURL=ActionSubjectResolution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionSubjectResolution.js","names":["diagnostics","resolver","ActionSubjectInputs","RefusalDeclarations","application","context","message","guarded","DiagnosticCodes","item","subject","parameter","authored","additions","parameters","input","effective","observe","action","fallback","alternative","node","inputs","local","directives","scope","inherited","slot","outlet","contribution","slice","module","diagnostic"],"sources":["../../../../../../Compiler/Parsing/ActionSubjectResolution.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Diagnostic } from '../Diagnostics/Diagnostic';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport type { CompilationResult } from '../ScreenplayCompiler';\nimport { ApplicationSyntax, FeatureSyntax, SliceSyntax } from '../Syntax/Structure';\nimport { ScreenActionSyntax, ScreenDirectiveSyntax, ScreenGuardedActionSyntax, ScreenSyntax, ToolbarItemSyntax } from '../Syntax/Screens';\nimport { RefusalDeclarations } from './RefusalDeclarations';\nimport { ActionSubjectContext, ActionSubjectInputs } from './ActionSubjectInputs';\n\nexport interface ActionSubjectEvidence {\n readonly authored: ScreenActionSyntax | ToolbarItemSyntax;\n readonly effective: ScreenActionSyntax | ToolbarItemSyntax;\n readonly command: string;\n readonly context: ActionSubjectContext;\n}\n\nexport function resolveActionSubjectApplication(application: ApplicationSyntax, observe?: (evidence: ActionSubjectEvidence) => void): CompilationResult<ApplicationSyntax> {\n const diagnostics: Diagnostic[] = [];\n const resolver = new ActionSubjectInputs(new RefusalDeclarations(application), diagnostics);\n const hasSubject = (context: ActionSubjectContext, guarded: boolean): boolean => {\n if (context.data.length === 1) return true;\n const message = guarded ? \"A guarded action requires exactly one nearest 'data' subject; no data or equally near data bindings leave 'item' unresolved\" : \"Action 'for item' requires one resolvable data subject - no item binding is inferred\";\n diagnostics.push({ severity: 'warning', code: DiagnosticCodes.UnresolvedActionSubject, message, location: context.location });\n return false;\n };\n const toolbar = (item: ToolbarItemSyntax, context: ActionSubjectContext): ToolbarItemSyntax => {\n if (item.syntaxKind !== 'Action') return item;\n const subject = resolver.subject(item.subject, item.target, item.parameters.map(parameter => parameter.name), context);\n const authored = item.parameters.map(parameter => ({ kind: 'InteractionArgumentSyntax' as const, name: parameter.name, binding: parameter.binding.path, location: parameter.location }));\n const additions = subject === 'Item' && hasSubject(context, false) ? resolver.inputs(item.target, authored, context).slice(authored.length) : [];\n const parameters = [...item.parameters, ...additions.map(input => ({ kind: 'ScreenNavigationParameterSyntax' as const, name: input.name, binding: { kind: 'UiBindingSyntax' as const, bindingKind: 'DataContext' as const, path: input.binding, query: null, componentId: null, componentPropertyPath: null, mode: null, nullBehavior: null, expectedValueType: null, literal: null, rawText: null, location: input.location }, location: input.location }))];\n const effective = subject == null && additions.length === 0 ? item : { ...item, subject, parameters };\n observe?.({ authored: item, effective, command: item.target, context });\n return effective;\n };\n const guarded = (action: ScreenGuardedActionSyntax, context: ActionSubjectContext): ScreenGuardedActionSyntax => {\n if (!hasSubject(context, true)) return action;\n if (action.subject === 'Screen' && context.data[0].type.isCollection) {\n diagnostics.push({ severity: 'warning', code: DiagnosticCodes.UnsupportedActionSubjectContext, message: \"A guarded action 'for screen' cannot use a collection as 'item' - use a single-record data context or 'for item'\", location: action.location });\n return action;\n }\n const fallback = action.otherwise;\n return { ...action,\n alternatives: action.alternatives.map(alternative => ({ ...alternative, arguments: resolver.inputs(alternative.command, alternative.arguments, { ...context, location: alternative.location }) })),\n otherwise: fallback !== null && fallback.command !== null ? { ...fallback, arguments: resolver.inputs(fallback.command, fallback.arguments, { ...context, location: fallback.location }) } : fallback,\n };\n };\n const plain = (node: ScreenActionSyntax, context: ActionSubjectContext): ScreenActionSyntax => {\n const subject = resolver.subject(node.subject, node.command, (node.inputs ?? []).map(input => input.name), context);\n const inputs = subject === 'Item' && hasSubject(context, false) ? resolver.inputs(node.command, node.inputs ?? [], context) : node.inputs;\n const effective = subject == null && inputs === node.inputs ? node : { ...node, subject, ...(inputs === undefined ? {} : { inputs }) };\n observe?.({ authored: node, effective, command: node.command, context });\n return effective;\n };\n const body = (directives: readonly ScreenDirectiveSyntax[], inherited: ActionSubjectContext): readonly ScreenDirectiveSyntax[] => {\n const local = directives.filter((node): node is Extract<ScreenDirectiveSyntax, { kind: 'ScreenDataSyntax' }> => node.kind === 'ScreenDataSyntax');\n const scope = { ...inherited, data: local.length > 0 ? local : inherited.data };\n return directives.map(node => {\n const context = { ...scope, location: node.location };\n switch (node.kind) {\n case 'ScreenActionSyntax': return plain(node, context);\n case 'ScreenGuardedActionSyntax': return guarded(node, context);\n case 'ScreenToolbarSyntax': return { ...node, items: node.items.map(item => toolbar(item, { ...context, location: item.location })) };\n case 'ScreenSectionSyntax': return { ...node, directives: body(node.directives, scope) };\n case 'ScreenTemplateReferenceSyntax': return { ...node, slots: node.slots.map(slot => ({ ...slot, directives: body(slot.directives, scope) })) };\n case 'ScreenComponentSyntax': return { ...node, outlets: node.outlets.map(outlet => ({ ...outlet, directives: body(outlet.directives, scope) })) };\n default: return node;\n }\n });\n };\n const screen = (node: ScreenSyntax, slice: SliceSyntax): ScreenSyntax => {\n const context = { data: [], slice, location: node.location };\n return { ...node, directives: body(node.directives, context), ...(node.contributions === undefined ? {} : { contributions: node.contributions.map(contribution => ({ ...contribution, directives: body(contribution.directives, context) })) }) };\n };\n const feature = (node: FeatureSyntax): FeatureSyntax => ({ ...node, features: node.features.map(feature), slices: node.slices.map(slice => ({ ...slice, screens: slice.screens.map(node => screen(node, slice)) })) });\n const value = { ...application, modules: application.modules.map(module => ({ ...module, features: module.features.map(feature) })) };\n return { value, diagnostics, success: !diagnostics.some(diagnostic => diagnostic.severity === 'error') };\n}\n"],"mappings":"uPAkBA,SAAgB,gCAAgC,EAAgC,EAA2F,CACvK,IAAMA,EAA4B,CAAC,EAC7BC,EAAW,IAAIC,EAAoB,IAAIC,EAAoBC,CAAW,EAAGJ,CAAW,EACpF,YAAc,EAA+B,IAA8B,CAC7E,GAAIK,EAAQ,KAAK,SAAW,EAAG,MAAO,GACtC,IAAMC,EAAUC,EAAU,8HAAgI,uFAE1J,OADAP,EAAY,KAAK,CAAE,SAAU,UAAW,KAAMQ,EAAgB,wBAAyB,UAAS,SAAUH,EAAQ,QAAS,CAAC,EACrH,EACX,EACM,SAAW,EAAyB,IAAqD,CAC3F,GAAII,EAAK,aAAe,SAAU,OAAOA,EACzC,IAAMC,EAAUT,EAAS,QAAQQ,EAAK,QAASA,EAAK,OAAQA,EAAK,WAAW,IAAI,GAAaE,EAAU,IAAI,EAAGN,CAAO,EAC/GO,EAAWH,EAAK,WAAW,IAAI,IAAc,CAAE,KAAM,4BAAsC,KAAME,EAAU,KAAM,QAASA,EAAU,QAAQ,KAAM,SAAUA,EAAU,QAAS,EAAE,EACjLE,EAAYH,IAAY,QAAU,WAAWL,EAAS,EAAK,EAAIJ,EAAS,OAAOQ,EAAK,O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,CAAE,EAAE,CAAE,EAC/I,IAAK,wBAAyB,MAAO,CAAE,GAAGJ,EAAM,QAASA,EAAK,QAAQ,IAAI,IAAW,CAAE,GAAGO,EAAQ,WAAY,KAAKA,EAAO,WAAYH,CAAK,CAAE,EAAE,CAAE,EACjJ,QAAS,OAAOJ,CACpB,CACJ,CAAC,CACL,EACM,QAAU,EAAoB,IAAqC,CACrE,IAAMhB,EAAU,CAAE,KAAM,CAAC,EAAG,QAAO,SAAUgB,EAAK,QAAS,EAC3D,MAAO,CAAE,GAAGA,EAAM,WAAY,KAAKA,EAAK,WAAYhB,CAAO,EAAG,GAAIgB,EAAK,gBAAkB,IAAA,GAAY,CAAC,EAAI,CAAE,cAAeA,EAAK,cAAc,IAAI,IAAiB,CAAE,GAAGQ,EAAc,WAAY,KAAKA,EAAa,WAAYxB,CAAO,CAAE,EAAE,CAAE,CAAG,CACpP,EACM,QAAW,IAAwC,CAAE,GAAGgB,EAAM,SAAUA,EAAK,SAAS,IAAI,OAAO,EAAG,OAAQA,EAAK,OAAO,IAAI,IAAU,CAAE,GAAGS,EAAO,QAASA,EAAM,QAAQ,IAAI,GAAQ,OAAOT,EAAMS,CAAK,CAAC,CAAE,EAAE,CAAE,GAEpN,MAAO,CAAE,MAAA,CADO,GAAG1B,EAAa,QAASA,EAAY,QAAQ,IAAI,IAAW,CAAE,GAAG2B,EAAQ,SAAUA,EAAO,SAAS,IAAI,OAAO,CAAE,EAAE,CACrH,EAAG,cAAa,QAAS,CAAC/B,EAAY,KAAK,GAAcgC,EAAW,WAAa,OAAO,CAAE,CAC3G"}
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{RefusalDeclarations as t}from"./RefusalDeclarations.js";import{comparisons as n,validateArguments as r,validateItemPath as i,viewProperties as a}from"./GuardedActionInputs.js";import{validateGuardedActionShadowing as o}from"./GuardedActionShadowing.js";import{GuardedInteractions as s}from"./GuardedInteractions.js";function validateGuardedActions(e,n){let r=new t(e),i=new s(r,n);i.structural(e);for(let{slice:e}of r.slices)for(let t of e.screens)validateContainer(t.directives,[],e,r,n,i)}function tableSubjects(e,t,n,r){let i=t.filter(t=>t.type.name===e.target);if(i.length>0||t.length!==1)return i;let o=t[0],s=a(o.type.name,n,r)?.filter(t=>t.name===e.target&&t.type.isCollection);return s?.length===1?[{...o,type:s[0].type,by:null,location:e.location}]:[]}function validateContainer(e,t,n,r,i,a){let o=e.filter(e=>e.kind===`ScreenDataSyntax`),s=o.length===0?t:o;for(let t of e)switch(t.kind){case`ScreenGuardedActionSyntax`:validateAction(t,s,n,r,i);break;case`ScreenBehaviorSyntax`:a.at(t.location,s,n);break;case`ScreenUsesBehaviorSyntax`:a.useAt(t.location,s,n);break;case`ScreenTableSyntax`:a.at(t.location,tableSubjects(t,s,n,r),n,!0);break;case`ScreenComponentSyntax`:a.at(t.location,s,n,!0);for(let e of t.outlets)validateContainer(e.directives,s,n,r,i,a);break;case`ScreenSectionSyntax`:validateContainer(t.directives,s,n,r,i,a);break;case`ScreenTemplateReferenceSyntax`:for(let e of t.slots)validateContainer(e.directives,s,n,r,i,a)}}function validateAction(t,s,c,l,u){let d=s.length===1?a(s[0].type.name,c,l):null;s.length!==1&&u.warning(e.UnresolvedActionSubject,`A guarded action requires exactly one nearest 'data' subject; no data or equally near data bindings leave 'item' unresolved`,t.location);for(let e of t.alternatives){for(let t of n(e.condition))i(t.left,t.location,d,c,l,u);r(e.command,e.arguments,d,c,l,u)}t.otherwise?.command!=null&&r(t.otherwise.command,t.otherwise.arguments,d,c,l,u),o(t,u)}export{validateGuardedActions};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{RefusalDeclarations as e}from"./RefusalDeclarations.js";import{resolveActionSubjects as t}from"../ScreenActionSubjects.js";import{comparisons as n,validateArguments as r,validateItemPath as i,viewProperties as a}from"./GuardedActionInputs.js";import{validateGuardedActionShadowing as o}from"./GuardedActionShadowing.js";import{GuardedInteractions as s}from"./GuardedInteractions.js";function validateGuardedActions(n,r){for(let e of t(n).diagnostics)r[e.severity](e.code,e.message,e.location,e.arguments);let i=new e(n),a=new s(i,r);a.structural(n);for(let{slice:e}of i.slices)for(let t of e.screens)validateContainer(t.directives,[],e,i,r,a)}function tableSubjects(e,t,n,r){let i=t.filter(t=>t.type.name===e.target);if(i.length>0||t.length!==1)return i;let o=t[0],s=a(o.type.name,n,r)?.filter(t=>t.name===e.target&&t.type.isCollection);return s?.length===1?[{...o,type:s[0].type,by:null,location:e.location}]:[]}function validateContainer(e,t,n,i,o,s){let c=e.filter(e=>e.kind===`ScreenDataSyntax`),l=c.length===0?t:c;for(let t of e)switch(t.kind){case`ScreenGuardedActionSyntax`:validateAction(t,l,n,i,o);break;case`ScreenActionSyntax`:r(t.command,t.inputs??[],l.length===1?a(l[0].type.name,n,i):null,n,i,o);break;case`ScreenBehaviorSyntax`:s.at(t.location,l,n);break;case`ScreenUsesBehaviorSyntax`:s.useAt(t.location,l,n);break;case`ScreenTableSyntax`:s.at(t.location,tableSubjects(t,l,n,i),n,!0);break;case`ScreenComponentSyntax`:s.at(t.location,l,n,!0);for(let e of t.outlets)validateContainer(e.directives,l,n,i,o,s);break;case`ScreenSectionSyntax`:validateContainer(t.directives,l,n,i,o,s);break;case`ScreenTemplateReferenceSyntax`:for(let e of t.slots)validateContainer(e.directives,l,n,i,o,s)}}function validateAction(e,t,s,c,l){let u=t.length===1?a(t[0].type.name,s,c):null;for(let t of e.alternatives){for(let e of n(t.condition))i(e.left,e.location,u,s,c,l);r(t.command,t.arguments,u,s,c,l)}e.otherwise?.command!=null&&r(e.otherwise.command,e.otherwise.arguments,u,s,c,l),o(e,l)}export{validateGuardedActions};
2
2
  //# sourceMappingURL=GuardedActionValidator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GuardedActionValidator.js","names":["declarations","RefusalDeclarations","application","interactions","GuardedInteractions","context","screen","slice","direct","subjects","subject","table","source","fields","viewProperties","property","local","directives","directive","inherited","outlet","slot","properties","DiagnosticCodes","action","alternative","comparison","comparisons","validateItemPath","validateArguments","validateGuardedActionShadowing"],"sources":["../../../../../../Compiler/Parsing/GuardedActionValidator.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 { ScreenDataSyntax, ScreenDirectiveSyntax, ScreenGuardedActionSyntax, ScreenTableSyntax } from '../Syntax/Screens';\nimport { ApplicationSyntax, SliceSyntax } from '../Syntax/Structure';\nimport { comparisons, validateArguments, validateItemPath, viewProperties } from './GuardedActionInputs';\nimport { validateGuardedActionShadowing } from './GuardedActionShadowing';\nimport { GuardedInteractions } from './GuardedInteractions';\nimport { ParserContext } from './ParserContext';\nimport { RefusalDeclarations } from './RefusalDeclarations';\n\n// Resolves known subject and input shapes without guessing imported or ambiguous declarations.\nexport function validateGuardedActions(application: ApplicationSyntax, context: ParserContext): void {\n const declarations = new RefusalDeclarations(application);\n const interactions = new GuardedInteractions(declarations, context);\n interactions.structural(application);\n for (const { slice } of declarations.slices) {\n for (const screen of slice.screens) validateContainer(screen.directives, [], slice, declarations, context, interactions);\n }\n}\n\nfunction tableSubjects(table: ScreenTableSyntax, subjects: readonly ScreenDataSyntax[], slice: SliceSyntax, declarations: RefusalDeclarations): readonly ScreenDataSyntax[] {\n const direct = subjects.filter(subject => subject.type.name === table.target);\n if (direct.length > 0 || subjects.length !== 1) return direct;\n const source = subjects[0];\n const fields = viewProperties(source.type.name, slice, declarations)?.filter(property => property.name === table.target && property.type.isCollection);\n return fields?.length === 1 ? [{ ...source, type: fields[0].type, by: null, location: table.location }] : [];\n}\n\nfunction validateContainer(directives: readonly ScreenDirectiveSyntax[], inherited: readonly ScreenDataSyntax[], slice: SliceSyntax, declarations: RefusalDeclarations, context: ParserContext, interactions: GuardedInteractions): void {\n const local = directives.filter(directive => directive.kind === 'ScreenDataSyntax');\n const subjects = local.length === 0 ? inherited : local;\n for (const directive of directives) {\n switch (directive.kind) {\n case 'ScreenGuardedActionSyntax':\n validateAction(directive, subjects, slice, declarations, context);\n break;\n case 'ScreenBehaviorSyntax':\n interactions.at(directive.location, subjects, slice);\n break;\n case 'ScreenUsesBehaviorSyntax':\n interactions.useAt(directive.location, subjects, slice);\n break;\n case 'ScreenTableSyntax':\n interactions.at(directive.location, tableSubjects(directive, subjects, slice, declarations), slice, true);\n break;\n case 'ScreenComponentSyntax':\n interactions.at(directive.location, subjects, slice, true);\n for (const outlet of directive.outlets) validateContainer(outlet.directives, subjects, slice, declarations, context, interactions);\n break;\n case 'ScreenSectionSyntax':\n validateContainer(directive.directives, subjects, slice, declarations, context, interactions);\n break;\n case 'ScreenTemplateReferenceSyntax':\n for (const slot of directive.slots) validateContainer(slot.directives, subjects, slice, declarations, context, interactions);\n break;\n }\n }\n}\n\nfunction validateAction(action: ScreenGuardedActionSyntax, subjects: readonly ScreenDataSyntax[], slice: SliceSyntax, declarations: RefusalDeclarations, context: ParserContext): void {\n const properties = subjects.length === 1 ? viewProperties(subjects[0].type.name, slice, declarations) : null;\n if (subjects.length !== 1) {\n context.warning(DiagnosticCodes.UnresolvedActionSubject, \"A guarded action requires exactly one nearest 'data' subject; no data or equally near data bindings leave 'item' unresolved\", action.location);\n }\n for (const alternative of action.alternatives) {\n for (const comparison of comparisons(alternative.condition)) validateItemPath(comparison.left, comparison.location, properties, slice, declarations, context);\n validateArguments(alternative.command, alternative.arguments, properties, slice, declarations, context);\n }\n if (action.otherwise?.command != null) validateArguments(action.otherwise.command, action.otherwise.arguments, properties, slice, declarations, context);\n validateGuardedActionShadowing(action, context);\n}\n"],"mappings":"4bAaA,SAAgB,uBAAuB,EAAgC,EAA8B,CACjG,IAAMA,EAAe,IAAIC,EAAoBC,CAAW,EAClDC,EAAe,IAAIC,EAAoBJ,EAAcK,CAAO,EAClEF,EAAa,WAAWD,CAAW,EACnC,IAAK,GAAM,CAAE,WAAWF,EA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UF,EAAOP,EAAcK,EAASF,CAAY,EACjI,MACJ,IAAK,sBACD,kBAAkBe,EAAU,WAAYT,EAAUF,EAAOP,EAAcK,EAASF,CAAY,EAC5F,MACJ,IAAK,gCACD,IAAK,IAAMkB,KAAQH,EAAU,MAAO,kBAAkBG,EAAK,WAAYZ,EAAUF,EAAOP,EAAcK,EAASF,CAAY,CAEnI,CAER,CAEA,SAAS,eAAe,EAAmC,EAAuC,EAAoB,EAAmC,EAA8B,CACnL,IAAMmB,EAAab,EAAS,SAAW,EAAIK,EAAeL,EAAS,EAAE,CAAC,KAAK,KAAMF,EAAOP,CAAY,EAAI,KACpGS,EAAS,SAAW,GACpBJ,EAAQ,QAAQkB,EAAgB,wBAAyB,8HAA+HC,EAAO,QAAQ,EAE3M,IAAK,IAAMC,KAAeD,EAAO,aAAc,CAC3C,IAAK,IAAME,KAAcC,EAAYF,EAAY,SAAS,EAAGG,EAAiBF,EAAW,KAAMA,EAAW,SAAUJ,EAAYf,EAAOP,EAAcK,CAAO,EAC5JwB,EAAkBJ,EAAY,QAASA,EAAY,UAAWH,EAAYf,EAAOP,EAAcK,CAAO,CAC1G,CACImB,EAAO,WAAW,SAAW,MAAMK,EAAkBL,EAAO,UAAU,QAASA,EAAO,UAAU,UAAWF,EAAYf,EAAOP,EAAcK,CAAO,EACvJyB,EAA+BN,EAAQnB,CAAO,CAClD"}
1
+ {"version":3,"file":"GuardedActionValidator.js","names":["diagnostic","resolveActionSubjects","application","context","declarations","RefusalDeclarations","interactions","GuardedInteractions","screen","slice","direct","subjects","subject","table","source","fields","viewProperties","property","local","directives","directive","inherited","validateArguments","outlet","slot","properties","alternative","action","comparison","comparisons","validateItemPath","validateGuardedActionShadowing"],"sources":["../../../../../../Compiler/Parsing/GuardedActionValidator.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 { resolveActionSubjects } from '../ScreenActionSubjects';\nimport { ScreenDataSyntax, ScreenDirectiveSyntax, ScreenGuardedActionSyntax, ScreenTableSyntax } from '../Syntax/Screens';\nimport { ApplicationSyntax, SliceSyntax } from '../Syntax/Structure';\nimport { comparisons, validateArguments, validateItemPath, viewProperties } from './GuardedActionInputs';\nimport { validateGuardedActionShadowing } from './GuardedActionShadowing';\nimport { GuardedInteractions } from './GuardedInteractions';\nimport { ParserContext } from './ParserContext';\nimport { RefusalDeclarations } from './RefusalDeclarations';\n\n// Resolves known subject and input shapes without guessing imported or ambiguous declarations.\nexport function validateGuardedActions(application: ApplicationSyntax, context: ParserContext): void {\n for (const diagnostic of resolveActionSubjects(application).diagnostics) context[diagnostic.severity](diagnostic.code, diagnostic.message, diagnostic.location, diagnostic.arguments);\n const declarations = new RefusalDeclarations(application);\n const interactions = new GuardedInteractions(declarations, context);\n interactions.structural(application);\n for (const { slice } of declarations.slices) {\n for (const screen of slice.screens) validateContainer(screen.directives, [], slice, declarations, context, interactions);\n }\n}\n\nfunction tableSubjects(table: ScreenTableSyntax, subjects: readonly ScreenDataSyntax[], slice: SliceSyntax, declarations: RefusalDeclarations): readonly ScreenDataSyntax[] {\n const direct = subjects.filter(subject => subject.type.name === table.target);\n if (direct.length > 0 || subjects.length !== 1) return direct;\n const source = subjects[0];\n const fields = viewProperties(source.type.name, slice, declarations)?.filter(property => property.name === table.target && property.type.isCollection);\n return fields?.length === 1 ? [{ ...source, type: fields[0].type, by: null, location: table.location }] : [];\n}\n\nfunction validateContainer(directives: readonly ScreenDirectiveSyntax[], inherited: readonly ScreenDataSyntax[], slice: SliceSyntax, declarations: RefusalDeclarations, context: ParserContext, interactions: GuardedInteractions): void {\n const local = directives.filter(directive => directive.kind === 'ScreenDataSyntax');\n const subjects = local.length === 0 ? inherited : local;\n for (const directive of directives) {\n switch (directive.kind) {\n case 'ScreenGuardedActionSyntax':\n validateAction(directive, subjects, slice, declarations, context);\n break;\n case 'ScreenActionSyntax':\n validateArguments(directive.command, directive.inputs ?? [], subjects.length === 1 ? viewProperties(subjects[0].type.name, slice, declarations) : null, slice, declarations, context);\n break;\n case 'ScreenBehaviorSyntax':\n interactions.at(directive.location, subjects, slice);\n break;\n case 'ScreenUsesBehaviorSyntax':\n interactions.useAt(directive.location, subjects, slice);\n break;\n case 'ScreenTableSyntax':\n interactions.at(directive.location, tableSubjects(directive, subjects, slice, declarations), slice, true);\n break;\n case 'ScreenComponentSyntax':\n interactions.at(directive.location, subjects, slice, true);\n for (const outlet of directive.outlets) validateContainer(outlet.directives, subjects, slice, declarations, context, interactions);\n break;\n case 'ScreenSectionSyntax':\n validateContainer(directive.directives, subjects, slice, declarations, context, interactions);\n break;\n case 'ScreenTemplateReferenceSyntax':\n for (const slot of directive.slots) validateContainer(slot.directives, subjects, slice, declarations, context, interactions);\n break;\n }\n }\n}\n\nfunction validateAction(action: ScreenGuardedActionSyntax, subjects: readonly ScreenDataSyntax[], slice: SliceSyntax, declarations: RefusalDeclarations, context: ParserContext): void {\n const properties = subjects.length === 1 ? viewProperties(subjects[0].type.name, slice, declarations) : null;\n for (const alternative of action.alternatives) {\n for (const comparison of comparisons(alternative.condition)) validateItemPath(comparison.left, comparison.location, properties, slice, declarations, context);\n validateArguments(alternative.command, alternative.arguments, properties, slice, declarations, context);\n }\n if (action.otherwise?.command != null) validateArguments(action.otherwise.command, action.otherwise.arguments, properties, slice, declarations, context);\n validateGuardedActionShadowing(action, context);\n}\n"],"mappings":"2bAaA,SAAgB,uBAAuB,EAAgC,EAA8B,CACjG,IAAK,IAAMA,KAAcC,EAAsBC,CAAW,CAAC,CAAC,YAAaC,EAAQH,EAAW,SAAS,CAACA,EAAW,KAAMA,EAAW,QAASA,EAAW,SAAUA,EAAW,SAAS,EACpL,IAAMI,EAAe,IAAIC,EAAoBH,CAAW,EAClDI,EAAe,IAAIC,EAAoBH,EAAcD,CAAO,EAClEG,EAAa,WAAWJ,CAAW,EACnC,IAAK,GAAM,CAAE,WAAWE,EAAa,OACjC,IAAK,IAAMI,KAAUC,EAAM,QAAS,kBAAkBD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AAK,wBACDH,EAAa,GAAGc,EAAU,SAAUT,EAAUF,EAAO,EAAI,EACzD,IAAK,IAAMc,KAAUH,EAAU,QAAS,kBAAkBG,EAAO,WAAYZ,EAAUF,EAAOL,EAAcD,EAASG,CAAY,EACjI,MACJ,IAAK,sBACD,kBAAkBc,EAAU,WAAYT,EAAUF,EAAOL,EAAcD,EAASG,CAAY,EAC5F,MACJ,IAAK,gCACD,IAAK,IAAMkB,KAAQJ,EAAU,MAAO,kBAAkBI,EAAK,WAAYb,EAAUF,EAAOL,EAAcD,EAASG,CAAY,CAEnI,CAER,CAEA,SAAS,eAAe,EAAmC,EAAuC,EAAoB,EAAmC,EAA8B,CACnL,IAAMmB,EAAad,EAAS,SAAW,EAAIK,EAAeL,EAAS,EAAE,CAAC,KAAK,KAAMF,EAAOL,CAAY,EAAI,KACxG,IAAK,IAAMsB,KAAeC,EAAO,aAAc,CAC3C,IAAK,IAAMC,KAAcC,EAAYH,EAAY,SAAS,EAAGI,EAAiBF,EAAW,KAAMA,EAAW,SAAUH,EAAYhB,EAAOL,EAAcD,CAAO,EAC5JmB,EAAkBI,EAAY,QAASA,EAAY,UAAWD,EAAYhB,EAAOL,EAAcD,CAAO,CAC1G,CACIwB,EAAO,WAAW,SAAW,MAAML,EAAkBK,EAAO,UAAU,QAASA,EAAO,UAAU,UAAWF,EAAYhB,EAAOL,EAAcD,CAAO,EACvJ4B,EAA+BJ,EAAQxB,CAAO,CAClD"}
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{stringBodyPattern as t,unescapeString as n}from"../Text/StringLiteral.js";import{pattern as r}from"../Text/patterns.js";import{locationOf as i}from"./SourceLine.js";import{parseMappingSource as a}from"./ExpressionParser.js";import{firstWord as o}from"./LineText.js";import{parseTypeRef as s}from"./PropertyLineParser.js";import{parseAuthorize as c}from"./AuthorizeParser.js";import{parseFencedText as l}from"./CodeBlockParser.js";import{parseDescription as u}from"./DescriptionParser.js";import{parseGuardedAction as d}from"./GuardedActionParser.js";import{collectInputUses as f}from"./InputUses.js";import{isFileDirective as p}from"./FileReferences.js";import{isValidTemplateVersionRange as m,parseBlueprintReference as h,startsBlueprintReference as g}from"./TemplateReferenceText.js";import{parseFromClause as _}from"./UiBindingParser.js";const v=`(?:"(${t})"|(\\$strings\\.\\w+(?:\\.\\w+)*))`,y=r(`^screen\\s+([A-Za-z_]\\w*)$`),b=r(`^data\\s+([\\w.]+(?:\\[\\])?)\\s+via\\s+query\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$`),x=r(`^action\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),S=r(`^label\\s+${v}$`),C=r(`^action\\s+${v}$`),w=r(`^navigate\\s+to\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$`),T=r(`^route\\s+${v}$`),E=r(`^outlet\\s+([A-Za-z_]\\w*)$`),D=r(`^contribute\\s+to\\s+([A-Za-z_]\\w*)(?:\\s+order\\s+(-?\\d+))?$`),O=r(`^parameter\\s+([A-Za-z_]\\w*)\\s+from\\s+(.+)$`),k=r(`^component\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)\\s+([A-Za-z_]\\w*)$`),A=r(`^id\\s+(?:"(${t})"|(\\S+))$`),j=r(`^property\\s+([\\w.]+)\\s+from\\s+(.+)$`),M=r(`^property\\s+([\\w.]+)\\s*=\\s+(.+)$`),N=r(`^exposes\\s+([A-Za-z_]\\w*)\\s+from\\s+(.+)$`),P=r(`^presentation\\s+([A-Za-z_]\\w*)\\s+${v}$`),F=r(`^confirm\\s+${v}$`),I=r(`^item\\s+([A-Za-z_]\\w*)\\s+(action|navigate|dialog)(?:\\s+to)?\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),L=r(`^button\\s+(?:"(${t})"|([A-Za-z_][\\w-]*))(?:\\s+(.*))?$`),R=new RegExp(r(`\\s*(title|slice|emphasis|icon)\\s+(?:"(${t})"|(\\$strings\\.\\w+(?:\\.\\w+)*)|([A-Za-z_][\\w.-]*))(?=\\s|$)`).source,`uy`),z=r(`^[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*$`),B=r(`^[a-z_]\\w*$`),V=r(`^title\\s+${v}$`),H=r(`^column\\s+([\\w.]+)(?:\\s+label\\s+${v})?$`),U=r(`^on\\s+row-click\\s+(navigate\\s+to\\s+.+)$`),W=r(`^field\\s+([\\w.]+)\\s+label\\s+${v}$`),operandText=(e,t)=>e[t]===void 0?e[t+1]:n(e[t]),isInteraction=e=>[`on`,`uses`].includes(o(e.content)),isCodeLine=(e,t)=>t.content.startsWith("```")||e.languages.has(t.content);function parseScreen(t,n){let r=y.exec(n.content);r===null&&t.error(e.InvalidScreenDeclaration,`Invalid screen declaration '${n.content}' - expected 'screen <Name>'`,i(n));let a=[],s=[],c=null;for(let e=t.peekChild(n.indent);e!==void 0;e=t.peekChild(n.indent))if(t.reader.takeSignificant(),o(e.content)===`contribute`){let n=parseScreenContribution(t,e);n!==void 0&&s.push(n)}else o(e.content)===`description`?c=u(t,e,c,`Screen '${r?.[1]??``}'`):p(e)||pushDirective(t,e,a);return{kind:`ScreenSyntax`,name:r?.[1]??``,directives:a,description:c,...s.length>0?{contributions:s}:{},location:i(n)}}function parseScreenContribution(t,n){let r=D.exec(n.content);if(r===null)t.error(e.UnknownScreenDirective,`Invalid screen contribution '${n.content}' - expected 'contribute to <Point> [order <n>]'`,i(n)),t.skipBlock(n.indent);else return{kind:`ScreenContributionSyntax`,contributionPoint:r[1],order:r[2]===void 0?null:Number(r[2]),directives:parseDirectives(t,n),location:i(n)}}function pushDirective(e,t,n){let r=parseDirective(e,t);r!==void 0&&n.push(r)}function parseDirectives(e,t){let n=[];for(let r=e.peekChild(t.indent);r!==void 0;r=e.peekChild(t.indent))e.reader.takeSignificant(),pushDirective(e,r,n);return n}function parseDirective(t,n){switch(o(n.content)){case`data`:return parseData(t,n);case`action`:return parseAction(t,n);case`template`:return parseTemplateReference(t,n);case`section`:return parseSection(t,n);case`title`:return parseTitle(t,n);case`table`:return parseTable(t,n);case`summary`:return parseSummary(t,n);case`component`:return parseComponent(t,n);case`toolbar`:return parseToolbar(t,n);case`navigate`:return parseNavigate(t,n.content,n);case`on`:return f(t,n),{kind:`ScreenBehaviorSyntax`,location:i(n)};case`uses`:return f(t,n),{kind:`ScreenUsesBehaviorSyntax`,location:i(n)};default:if(isCodeLine(t,n))return parseCode(t,n);t.error(e.UnknownScreenDirective,`Unexpected '${n.content}' in screen body`,i(n)),t.skipBlock(n.indent);return}}function parseData(t,n){let r=b.exec(n.content);if(r===null)t.error(e.InvalidDataDirective,`Invalid data directive '${n.content}' - expected 'data <ReadModel> via query <Query> [by <param>]'`,i(n));else return{kind:`ScreenDataSyntax`,type:s(r[1],i(n)),query:r[2],by:r[3]??null,location:i(n)}}function parseAction(t,n){let r=C.exec(n.content);if(r!==null)return d(t,n,operandText(r,1),parseNavigate);let a=x.exec(n.content);if(a===null){t.error(e.InvalidActionDirective,`Invalid action directive '${n.content}' - expected 'action <Command>'`,i(n)),t.skipBlock(n.indent);return}let s=null,c=null;for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=S.exec(r.content);n===null?o(r.content)===`navigate`?c=parseNavigate(t,r.content,r)??null:t.error(e.UnknownActionDirective,`Unexpected '${r.content}' in action - expected 'label "..."' or 'navigate to ...'`,i(r)):s=operandText(n,1)}return{kind:`ScreenActionSyntax`,command:a[1],label:s,navigate:c,location:i(n)}}function parseNavigate(t,n,r){let a=w.exec(n);if(a===null){t.error(e.InvalidNavigation,`Invalid navigation '${n}' - expected 'navigate to <Screen> [by <param>]'`,i(r));return}let o=[],s=null,c=null;for(let n=t.peekChild(r.indent);n!==void 0;n=t.peekChild(r.indent)){t.reader.takeSignificant();let r=O.exec(n.content);if(r!==null){o.push({kind:`ScreenNavigationParameterSyntax`,name:r[1],binding:_(t,r[2],i(n)),location:i(n)});continue}let a=T.exec(n.content);if(a!==null){s=operandText(a,1);continue}let l=E.exec(n.content);l===null?t.error(e.InvalidNavigation,`Unexpected '${n.content}' in navigation - expected 'route "..."', 'outlet <name>' or 'parameter <name> from <binding>'`,i(n)):c=l[1]}return{kind:`ScreenNavigateSyntax`,screen:a[1],by:a[2]??null,route:s,...c===null?{}:{outlet:c},parameters:o,location:i(r)}}function parseTemplateReference(t,n){let r=n.content.substring(8).trim(),a=null,o=null;if(g(r)){let s=h(r);s===void 0?t.error(e.UnknownLayoutDirective,`Invalid template reference '${n.content}' - expected 'template <Name>' or 'template blueprint <Blueprint> <Name> [version "<range>"]'`,i(n)):({blueprint:a,name:r,version:o}=s,o!==null&&!m(o)&&t.error(e.InvalidTemplateVersionRange,`The template version range '${o}' is not one Scene understands - use '*', an exact version or a ^, ~, >=, >, <= or < range such as "^1.2"`,i(n)))}let s=[];for(let a=t.peekChild(n.indent);a!==void 0;a=t.peekChild(n.indent))t.reader.takeSignificant(),B.test(a.content)?s.push({kind:`ScreenSlotSyntax`,name:a.content,directives:parseDirectives(t,a),location:i(a)}):(t.error(e.InvalidScreenLayoutSlot,`Expected a slot name in template '${r}', got '${a.content}'`,i(a)),t.skipBlock(a.indent));return{kind:`ScreenTemplateReferenceSyntax`,name:r,slots:s,...a===null?{}:{blueprint:a},...o===null?{}:{version:o},location:i(n)}}function parseSection(e,t){return{kind:`ScreenSectionSyntax`,name:t.content.substring(7).trim(),directives:parseDirectives(e,t),location:i(t)}}function parseTitle(t,n){let r=V.exec(n.content);return r===null?(t.error(e.InvalidTitleDirective,`Invalid title directive '${n.content}' - expected 'title "..."'`,i(n)),{kind:`ScreenTitleSyntax`,text:``,location:i(n)}):{kind:`ScreenTitleSyntax`,text:operandText(r,1),location:i(n)}}function parseTable(t,n){let r=n.content.substring(5).trim(),a=[],s=null;for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=H.exec(r.content),c=U.exec(r.content);if(n!==null){let e=n[2]!==void 0||n[3]!==void 0;a.push({kind:`ScreenColumnSyntax`,property:n[1],label:e?operandText(n,2):null,location:i(r)})}else c===null?o(r.content)===`on`||isInteraction(r)?f(t,r):t.error(e.UnknownTableDirective,`Unexpected '${r.content}' in table - expected 'column ...', 'on row-click navigate to ...', 'on <trigger>' or 'uses <Behavior>'`,i(r)):s=parseNavigate(t,c[1],r)??null}return{kind:`ScreenTableSyntax`,target:r,columns:a,rowClick:s,location:i(n)}}function parseSummary(t,n){let r=n.content.substring(7).trim(),a=[];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=W.exec(r.content);n===null?t.error(e.UnknownSummaryDirective,`Unexpected '${r.content}' in summary - expected 'field <property> label "..."'`,i(r)):a.push({kind:`ScreenFieldSyntax`,property:n[1],label:operandText(n,2),location:i(r)})}return{kind:`ScreenSummarySyntax`,target:r,fields:a,location:i(n)}}function parseComponent(t,n){let r=k.exec(n.content);if(r===null){t.error(e.UnknownScreenDirective,`Invalid component directive '${n.content}' - expected 'component <Package.Component> <name>'`,i(n)),t.skipBlock(n.indent);return}let a=null,s=null,c=null,l=[],u=[],d=[],p=[];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent))switch(t.reader.takeSignificant(),o(r.content)){case`context`:a=parseUiContext(t,r);break;case`id`:s=parseStableId(t,r);break;case`property`:parseComponentProperty(t,r,l);break;case`icon`:c=r.content.substring(4).trim();break;case`presentation`:parsePresentationValue(t,r,d);break;case`exposes`:parseExposedValue(t,r,u);break;case`outlet`:p.push({kind:`ComponentOutletSyntax`,name:r.content.substring(6).trim(),directives:parseDirectives(t,r),location:i(r)});break;case`on`:f(t,r);break;case`uses`:f(t,r);break;default:t.error(e.UnknownScreenDirective,`Unexpected '${r.content}' in component - expected context, id, property, icon, presentation, exposes, outlet, on or uses`,i(r)),t.skipBlock(r.indent)}return{kind:`ScreenComponentSyntax`,component:r[1],name:r[2],stableId:s,context:a,properties:l,exposes:u,presentation:d,icon:c,outlets:p,location:i(n)}}function parseUiContext(e,t){return parseUiBindingValue(e,t.content.substring(7).trim(),t)}function parseComponentProperty(t,n,r){let o=j.exec(n.content);if(o!==null){r.push({kind:`ComponentPropertySyntax`,property:o[1],binding:_(t,o[2],i(n)),value:null,location:i(n)});return}let s=M.exec(n.content);s===null?t.error(e.UnknownScreenDirective,`Invalid component property '${n.content}' - expected 'property <path> from <binding>' or 'property <path> = <literal|object|array|null>'`,i(n)):r.push({kind:`ComponentPropertySyntax`,property:s[1],binding:null,value:a(s[2],i(n),t),location:i(n)})}function parseStableId(t,n){let r=A.exec(n.content);return r===null?(t.error(e.UnknownScreenDirective,`Invalid component id '${n.content}' - expected 'id "stable-id"'`,i(n)),null):operandText(r,1)}function parseExposedValue(t,n,r){let a=N.exec(n.content);a===null?t.error(e.UnknownScreenDirective,`Invalid exposed value '${n.content}' - expected 'exposes <name> from <binding>'`,i(n)):r.push({kind:`ComponentExposedValueSyntax`,name:a[1],binding:_(t,a[2],i(n)),location:i(n)})}function parsePresentationValue(t,n,r){let a=P.exec(n.content);a===null?t.error(e.UnknownScreenDirective,`Invalid presentation value '${n.content}' - expected 'presentation <key> "value"'`,i(n)):r.push({kind:`PresentationValueSyntax`,name:a[1],value:operandText(a,2),location:i(n)})}function parseToolbar(e,t){let n=t.content.substring(7).trim(),r=[],a=[];for(let n=e.peekChild(t.indent);n!==void 0;n=e.peekChild(t.indent)){if(e.reader.takeSignificant(),o(n.content)===`button`){let t=parseToolbarButton(e,n);t!==void 0&&a.push(t);continue}let t=parseToolbarItem(e,n);t!==void 0&&r.push(t)}return{kind:`ScreenToolbarSyntax`,name:n,items:r,...a.length>0?{buttons:a}:{},location:i(t)}}const G=`button <id> title "<text>" [slice <Module>.<Feature>.<Slice>] [emphasis primary|secondary|quiet] [icon <name>]`;function parseToolbarButton(t,r){let a=L.exec(r.content);if(a===null){t.error(e.InvalidToolbarButton,`Invalid toolbar button '${r.content}' - expected ${G}`,i(r)),t.skipBlock(r.indent);return}let s=a[1]===void 0?a[2]:n(a[1]),l=a[3]??``,u,d,f,p,m=!0,h=0;for(;h<l.length;){R.lastIndex=h;let a=R.exec(l);if(a===null){t.error(e.InvalidToolbarButton,`Invalid toolbar button '${r.content}' - unexpected '${l.substring(h).trim()}'; expected ${G}`,i(r)),m=!1;break}h=a.index+a[0].length;let o=a[1],c=a[2]!==void 0,g=a[3]!==void 0,_=c?n(a[2]):g?a[3]:a[4];(o===`title`?u!==void 0:o===`slice`?d!==void 0:o===`icon`?f!==void 0:p!==void 0)?t.error(e.InvalidToolbarButton,`Toolbar button '${s}' states '${o}' more than once`,i(r)):o===`title`?c||g?u=_:(t.error(e.InvalidToolbarButton,`Invalid title '${_}' on toolbar button '${s}' - expected a quoted string or a $strings.<key> token`,i(r)),m=!1):o===`slice`?!c&&!g&&z.test(_)?d=_:(t.error(e.InvalidToolbarButton,`Invalid slice '${_}' on toolbar button '${s}' - expected <Module>.<Feature>.<Slice>`,i(r)),m=!1):o===`emphasis`?!c&&!g&&[`primary`,`secondary`,`quiet`].includes(_)?p=_===`primary`?`Primary`:_===`secondary`?`Secondary`:`Quiet`:(t.error(e.InvalidToolbarButton,`Invalid emphasis '${_}' on toolbar button '${s}' - expected primary, secondary or quiet`,i(r)),m=!1):f=_}u===void 0&&m&&t.error(e.InvalidToolbarButton,`Toolbar button '${s}' has no title - expected 'button ${s} title "<text>"'`,i(r));let g=null,_;for(let n=t.peekChild(r.indent);n!==void 0;n=t.peekChild(r.indent)){if(t.reader.takeSignificant(),o(n.content)===`authorize`&&g===null){g=c(t,n);continue}let r=_===void 0?F.exec(n.content):null;r===null?(t.error(e.InvalidToolbarButton,`Unexpected '${n.content}' under toolbar button '${s}' - a button takes one 'authorize' line, one 'confirm' line and nothing else`,i(n)),t.skipBlock(n.indent)):_=operandText(r,1)}return{kind:`ToolbarButtonSyntax`,id:s,title:u??``,...d===void 0?{}:{slice:d},...p===void 0?{}:{emphasis:p},...f===void 0?{}:{icon:f},...g===null?{}:{authorize:g},..._===void 0?{}:{confirm:_},location:i(r)}}function parseToolbarItem(t,n){let r=I.exec(n.content);if(r===null){t.error(e.UnknownScreenDirective,`Invalid toolbar item '${n.content}' - expected 'item <name> action <Command>', 'item <name> navigate to <Screen>', 'item <name> dialog <DialogTemplate>' or 'button <id> title "<text>" slice <Slice>'`,i(n)),t.skipBlock(n.indent);return}let a=null,s=null,c,l=[],u=[];for(let e=t.peekChild(n.indent);e!==void 0;e=t.peekChild(n.indent)){t.reader.takeSignificant();let n=S.exec(e.content);if(n!==null){a=operandText(n,1);continue}let r=F.exec(e.content);if(r!==null){c=operandText(r,1);continue}let d=O.exec(e.content);d===null?o(e.content)===`icon`?s=e.content.substring(4).trim():parsePresentationValue(t,e,u):l.push({kind:`ScreenNavigationParameterSyntax`,name:d[1],binding:_(t,d[2],i(e)),location:i(e)})}let d=r[2]===`navigate`?`Navigate`:r[2]===`dialog`?`Dialog`:`Action`;return{kind:`ToolbarItemSyntax`,name:r[1],syntaxKind:d,target:r[3],label:a,icon:s,...c===void 0?{}:{confirm:c},parameters:l,presentation:u,location:i(n)}}function parseUiBindingValue(e,t,n){return _(e,t,i(n))}function parseCode(t,n){let r=n.content.startsWith("```")?n.content.substring(3):n.content;if(!t.languages.has(r)){t.error(e.ExpectedCodeFence,`Expected a registered language on the opening fence, not '${n.content}'`,i(n));return}n.content.startsWith("```")||t.warning(e.LegacyInlineCodeFence,`'${r}' on its own line is deprecated - use '\`\`\`${r}' instead`,i(n));let a=l(t,r,n);return a===null?void 0:{kind:`ScreenCodeSyntax`,code:{kind:`CodeBlockSyntax`,language:r,code:a,location:i(n)},location:i(n)}}export{parseScreen,parseToolbar};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{stringBodyPattern as t,unescapeString as n}from"../Text/StringLiteral.js";import{pattern as r}from"../Text/patterns.js";import{locationOf as i}from"./SourceLine.js";import{parseMappingSource as a}from"./ExpressionParser.js";import{firstWord as o}from"./LineText.js";import{parseTypeRef as s}from"./PropertyLineParser.js";import{parseAuthorize as c}from"./AuthorizeParser.js";import{parseFencedText as l}from"./CodeBlockParser.js";import{parseDescription as u}from"./DescriptionParser.js";import{parseGuardedAction as d}from"./GuardedActionParser.js";import{collectInputUses as f}from"./InputUses.js";import{isFileDirective as p}from"./FileReferences.js";import{parsePlainActionInput as m,parseSubjectClause as h}from"./ActionSubjectClause.js";import{isValidTemplateVersionRange as g,parseBlueprintReference as _,startsBlueprintReference as v}from"./TemplateReferenceText.js";import{parseFromClause as y}from"./UiBindingParser.js";const b=`(?:"(${t})"|(\\$strings\\.\\w+(?:\\.\\w+)*))`,x=r(`^screen\\s+([A-Za-z_]\\w*)$`),S=r(`^data\\s+([\\w.]+(?:\\[\\])?)\\s+via\\s+query\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$`),C=r(`^action\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),w=r(`^label\\s+${b}$`),T=r(`^action\\s+${b}$`),E=r(`^navigate\\s+to\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$`),D=r(`^route\\s+${b}$`),O=r(`^outlet\\s+([A-Za-z_]\\w*)$`),k=r(`^contribute\\s+to\\s+([A-Za-z_]\\w*)(?:\\s+order\\s+(-?\\d+))?$`),A=r(`^parameter\\s+([A-Za-z_]\\w*)\\s+from\\s+(.+)$`),j=r(`^component\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)\\s+([A-Za-z_]\\w*)$`),M=r(`^id\\s+(?:"(${t})"|(\\S+))$`),N=r(`^property\\s+([\\w.]+)\\s+from\\s+(.+)$`),P=r(`^property\\s+([\\w.]+)\\s*=\\s+(.+)$`),F=r(`^exposes\\s+([A-Za-z_]\\w*)\\s+from\\s+(.+)$`),I=r(`^presentation\\s+([A-Za-z_]\\w*)\\s+${b}$`),L=r(`^confirm\\s+${b}$`),R=r(`^item\\s+([A-Za-z_]\\w*)\\s+(action|navigate|dialog)(?:\\s+to)?\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),z=r(`^button\\s+(?:"(${t})"|([A-Za-z_][\\w-]*))(?:\\s+(.*))?$`),B=new RegExp(r(`\\s*(title|slice|emphasis|icon)\\s+(?:"(${t})"|(\\$strings\\.\\w+(?:\\.\\w+)*)|([A-Za-z_][\\w.-]*))(?=\\s|$)`).source,`uy`),V=r(`^[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*$`),H=r(`^[a-z_]\\w*$`),U=r(`^title\\s+${b}$`),W=r(`^column\\s+([\\w.]+)(?:\\s+label\\s+${b})?$`),G=r(`^on\\s+row-click\\s+(navigate\\s+to\\s+.+)$`),K=r(`^field\\s+([\\w.]+)\\s+label\\s+${b}$`),operandText=(e,t)=>e[t]===void 0?e[t+1]:n(e[t]),isInteraction=e=>[`on`,`uses`].includes(o(e.content)),isCodeLine=(e,t)=>t.content.startsWith("```")||e.languages.has(t.content);function parseScreen(t,n){let r=x.exec(n.content);r===null&&t.error(e.InvalidScreenDeclaration,`Invalid screen declaration '${n.content}' - expected 'screen <Name>'`,i(n));let a=[],s=[],c=null;for(let e=t.peekChild(n.indent);e!==void 0;e=t.peekChild(n.indent))if(t.reader.takeSignificant(),o(e.content)===`contribute`){let n=parseScreenContribution(t,e);n!==void 0&&s.push(n)}else o(e.content)===`description`?c=u(t,e,c,`Screen '${r?.[1]??``}'`):p(e)||pushDirective(t,e,a);return{kind:`ScreenSyntax`,name:r?.[1]??``,directives:a,description:c,...s.length>0?{contributions:s}:{},location:i(n)}}function parseScreenContribution(t,n){let r=k.exec(n.content);if(r===null)t.error(e.UnknownScreenDirective,`Invalid screen contribution '${n.content}' - expected 'contribute to <Point> [order <n>]'`,i(n)),t.skipBlock(n.indent);else return{kind:`ScreenContributionSyntax`,contributionPoint:r[1],order:r[2]===void 0?null:Number(r[2]),directives:parseDirectives(t,n),location:i(n)}}function pushDirective(e,t,n){let r=parseDirective(e,t);r!==void 0&&n.push(r)}function parseDirectives(e,t){let n=[];for(let r=e.peekChild(t.indent);r!==void 0;r=e.peekChild(t.indent))e.reader.takeSignificant(),pushDirective(e,r,n);return n}function parseDirective(t,n){switch(validateNonActionSubjectClause(t,n),o(n.content)){case`data`:return parseData(t,n);case`action`:return parseAction(t,n);case`template`:return parseTemplateReference(t,n);case`section`:return parseSection(t,n);case`title`:return parseTitle(t,n);case`table`:return parseTable(t,n);case`summary`:return parseSummary(t,n);case`component`:return parseComponent(t,n);case`toolbar`:return parseToolbar(t,n);case`navigate`:return parseNavigate(t,n.content,n);case`on`:return f(t,n),{kind:`ScreenBehaviorSyntax`,location:i(n)};case`uses`:return f(t,n),{kind:`ScreenUsesBehaviorSyntax`,location:i(n)};default:if(isCodeLine(t,n))return parseCode(t,n);t.error(e.UnknownScreenDirective,`Unexpected '${n.content}' in screen body`,i(n)),t.skipBlock(n.indent);return}}function parseData(t,n){let r=S.exec(n.content);if(r===null)t.error(e.InvalidDataDirective,`Invalid data directive '${n.content}' - expected 'data <ReadModel> via query <Query> [by <param>]'`,i(n));else return{kind:`ScreenDataSyntax`,type:s(r[1],i(n)),query:r[2],by:r[3]??null,location:i(n)}}function validateNonActionSubjectClause(e,t){let n=(/* @__PURE__ */ new Map([[`data`,S],[`navigate`,E],[`component`,j],[`title`,U]])).get(o(t.content));n!==void 0&&h(e,t,!1,e=>n.test(e))}function parseAction(e,t){let n=h(e,t,!0,e=>C.test(e)||T.test(e)),r=parseActionHeader(e,t,n);return r===void 0||n.subject===void 0?r:{...r,subject:n.subject}}function parseActionHeader(t,n,r){let a=T.exec(r.header);if(a!==null)return d(t,n,operandText(a,1),parseNavigate);let s=C.exec(r.header);if(s===null){t.error(e.InvalidActionDirective,`Invalid action directive '${n.content}' - expected 'action <Command>'`,i(n)),t.skipBlock(n.indent);return}let c=r.label??null,l=null,u=[];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=w.exec(r.content);n===null?o(r.content)===`navigate`?l=parseNavigate(t,r.content,r)??null:o(r.content)===`with`?addPlainActionInput(t,r,u):t.error(e.UnknownActionDirective,`Unexpected '${r.content}' in action - expected 'label "..."' or 'navigate to ...'`,i(r)):c=operandText(n,1)}return{kind:`ScreenActionSyntax`,command:s[1],label:c,navigate:l,...u.length===0?{}:{inputs:u},location:i(n)}}function addPlainActionInput(e,t,n){let r=m(e,t,n);r!==void 0&&n.push(r)}function parseNavigate(t,n,r){let a=E.exec(n);if(a===null){t.error(e.InvalidNavigation,`Invalid navigation '${n}' - expected 'navigate to <Screen> [by <param>]'`,i(r));return}let o=[],s=null,c=null;for(let n=t.peekChild(r.indent);n!==void 0;n=t.peekChild(r.indent)){t.reader.takeSignificant();let r=A.exec(n.content);if(r!==null){o.push({kind:`ScreenNavigationParameterSyntax`,name:r[1],binding:y(t,r[2],i(n)),location:i(n)});continue}let a=D.exec(n.content);if(a!==null){s=operandText(a,1);continue}let l=O.exec(n.content);l===null?t.error(e.InvalidNavigation,`Unexpected '${n.content}' in navigation - expected 'route "..."', 'outlet <name>' or 'parameter <name> from <binding>'`,i(n)):c=l[1]}return{kind:`ScreenNavigateSyntax`,screen:a[1],by:a[2]??null,route:s,...c===null?{}:{outlet:c},parameters:o,location:i(r)}}function parseTemplateReference(t,n){let r=n.content.substring(8).trim(),a=null,o=null;if(v(r)){let s=_(r);s===void 0?t.error(e.UnknownLayoutDirective,`Invalid template reference '${n.content}' - expected 'template <Name>' or 'template blueprint <Blueprint> <Name> [version "<range>"]'`,i(n)):({blueprint:a,name:r,version:o}=s,o!==null&&!g(o)&&t.error(e.InvalidTemplateVersionRange,`The template version range '${o}' is not one Scene understands - use '*', an exact version or a ^, ~, >=, >, <= or < range such as "^1.2"`,i(n)))}let s=[];for(let a=t.peekChild(n.indent);a!==void 0;a=t.peekChild(n.indent))t.reader.takeSignificant(),H.test(a.content)?s.push({kind:`ScreenSlotSyntax`,name:a.content,directives:parseDirectives(t,a),location:i(a)}):(t.error(e.InvalidScreenLayoutSlot,`Expected a slot name in template '${r}', got '${a.content}'`,i(a)),t.skipBlock(a.indent));return{kind:`ScreenTemplateReferenceSyntax`,name:r,slots:s,...a===null?{}:{blueprint:a},...o===null?{}:{version:o},location:i(n)}}function parseSection(e,t){return{kind:`ScreenSectionSyntax`,name:t.content.substring(7).trim(),directives:parseDirectives(e,t),location:i(t)}}function parseTitle(t,n){let r=U.exec(n.content);return r===null?(t.error(e.InvalidTitleDirective,`Invalid title directive '${n.content}' - expected 'title "..."'`,i(n)),{kind:`ScreenTitleSyntax`,text:``,location:i(n)}):{kind:`ScreenTitleSyntax`,text:operandText(r,1),location:i(n)}}function parseTable(t,n){let r=n.content.substring(5).trim(),a=[],s=null;for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=W.exec(r.content),c=G.exec(r.content);if(n!==null){let e=n[2]!==void 0||n[3]!==void 0;a.push({kind:`ScreenColumnSyntax`,property:n[1],label:e?operandText(n,2):null,location:i(r)})}else c===null?o(r.content)===`on`||isInteraction(r)?f(t,r):t.error(e.UnknownTableDirective,`Unexpected '${r.content}' in table - expected 'column ...', 'on row-click navigate to ...', 'on <trigger>' or 'uses <Behavior>'`,i(r)):s=parseNavigate(t,c[1],r)??null}return{kind:`ScreenTableSyntax`,target:r,columns:a,rowClick:s,location:i(n)}}function parseSummary(t,n){let r=n.content.substring(7).trim(),a=[];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent)){t.reader.takeSignificant();let n=K.exec(r.content);n===null?t.error(e.UnknownSummaryDirective,`Unexpected '${r.content}' in summary - expected 'field <property> label "..."'`,i(r)):a.push({kind:`ScreenFieldSyntax`,property:n[1],label:operandText(n,2),location:i(r)})}return{kind:`ScreenSummarySyntax`,target:r,fields:a,location:i(n)}}function parseComponent(t,n){let r=j.exec(n.content);if(r===null){t.error(e.UnknownScreenDirective,`Invalid component directive '${n.content}' - expected 'component <Package.Component> <name>'`,i(n)),t.skipBlock(n.indent);return}let a=null,s=null,c=null,l=[],u=[],d=[],p=[];for(let r=t.peekChild(n.indent);r!==void 0;r=t.peekChild(n.indent))switch(t.reader.takeSignificant(),o(r.content)){case`context`:a=parseUiContext(t,r);break;case`id`:s=parseStableId(t,r);break;case`property`:parseComponentProperty(t,r,l);break;case`icon`:c=r.content.substring(4).trim();break;case`presentation`:parsePresentationValue(t,r,d);break;case`exposes`:parseExposedValue(t,r,u);break;case`outlet`:p.push({kind:`ComponentOutletSyntax`,name:r.content.substring(6).trim(),directives:parseDirectives(t,r),location:i(r)});break;case`on`:f(t,r);break;case`uses`:f(t,r);break;default:t.error(e.UnknownScreenDirective,`Unexpected '${r.content}' in component - expected context, id, property, icon, presentation, exposes, outlet, on or uses`,i(r)),t.skipBlock(r.indent)}return{kind:`ScreenComponentSyntax`,component:r[1],name:r[2],stableId:s,context:a,properties:l,exposes:u,presentation:d,icon:c,outlets:p,location:i(n)}}function parseUiContext(e,t){return parseUiBindingValue(e,t.content.substring(7).trim(),t)}function parseComponentProperty(t,n,r){let o=N.exec(n.content);if(o!==null){r.push({kind:`ComponentPropertySyntax`,property:o[1],binding:y(t,o[2],i(n)),value:null,location:i(n)});return}let s=P.exec(n.content);s===null?t.error(e.UnknownScreenDirective,`Invalid component property '${n.content}' - expected 'property <path> from <binding>' or 'property <path> = <literal|object|array|null>'`,i(n)):r.push({kind:`ComponentPropertySyntax`,property:s[1],binding:null,value:a(s[2],i(n),t),location:i(n)})}function parseStableId(t,n){let r=M.exec(n.content);return r===null?(t.error(e.UnknownScreenDirective,`Invalid component id '${n.content}' - expected 'id "stable-id"'`,i(n)),null):operandText(r,1)}function parseExposedValue(t,n,r){let a=F.exec(n.content);a===null?t.error(e.UnknownScreenDirective,`Invalid exposed value '${n.content}' - expected 'exposes <name> from <binding>'`,i(n)):r.push({kind:`ComponentExposedValueSyntax`,name:a[1],binding:y(t,a[2],i(n)),location:i(n)})}function parsePresentationValue(t,n,r){let a=I.exec(n.content);a===null?t.error(e.UnknownScreenDirective,`Invalid presentation value '${n.content}' - expected 'presentation <key> "value"'`,i(n)):r.push({kind:`PresentationValueSyntax`,name:a[1],value:operandText(a,2),location:i(n)})}function parseToolbar(e,t){let n=t.content.substring(7).trim(),r=[],a=[];for(let n=e.peekChild(t.indent);n!==void 0;n=e.peekChild(t.indent)){if(e.reader.takeSignificant(),o(n.content)===`button`){let t=parseToolbarButton(e,n);t!==void 0&&a.push(t);continue}let t=parseToolbarItem(e,n);t!==void 0&&r.push(t)}return{kind:`ScreenToolbarSyntax`,name:n,items:r,...a.length>0?{buttons:a}:{},location:i(t)}}const q=`button <id> title "<text>" [slice <Module>.<Feature>.<Slice>] [emphasis primary|secondary|quiet] [icon <name>]`;function parseToolbarButton(t,r){let a=z.exec(r.content);if(a===null){t.error(e.InvalidToolbarButton,`Invalid toolbar button '${r.content}' - expected ${q}`,i(r)),t.skipBlock(r.indent);return}let s=a[1]===void 0?a[2]:n(a[1]),l=a[3]??``,u,d,f,p,m=!0,h=0;for(;h<l.length;){B.lastIndex=h;let a=B.exec(l);if(a===null){t.error(e.InvalidToolbarButton,`Invalid toolbar button '${r.content}' - unexpected '${l.substring(h).trim()}'; expected ${q}`,i(r)),m=!1;break}h=a.index+a[0].length;let o=a[1],c=a[2]!==void 0,g=a[3]!==void 0,_=c?n(a[2]):g?a[3]:a[4];(o===`title`?u!==void 0:o===`slice`?d!==void 0:o===`icon`?f!==void 0:p!==void 0)?t.error(e.InvalidToolbarButton,`Toolbar button '${s}' states '${o}' more than once`,i(r)):o===`title`?c||g?u=_:(t.error(e.InvalidToolbarButton,`Invalid title '${_}' on toolbar button '${s}' - expected a quoted string or a $strings.<key> token`,i(r)),m=!1):o===`slice`?!c&&!g&&V.test(_)?d=_:(t.error(e.InvalidToolbarButton,`Invalid slice '${_}' on toolbar button '${s}' - expected <Module>.<Feature>.<Slice>`,i(r)),m=!1):o===`emphasis`?!c&&!g&&[`primary`,`secondary`,`quiet`].includes(_)?p=_===`primary`?`Primary`:_===`secondary`?`Secondary`:`Quiet`:(t.error(e.InvalidToolbarButton,`Invalid emphasis '${_}' on toolbar button '${s}' - expected primary, secondary or quiet`,i(r)),m=!1):f=_}u===void 0&&m&&t.error(e.InvalidToolbarButton,`Toolbar button '${s}' has no title - expected 'button ${s} title "<text>"'`,i(r));let g=null,_;for(let n=t.peekChild(r.indent);n!==void 0;n=t.peekChild(r.indent)){if(t.reader.takeSignificant(),o(n.content)===`authorize`&&g===null){g=c(t,n);continue}let r=_===void 0?L.exec(n.content):null;r===null?(t.error(e.InvalidToolbarButton,`Unexpected '${n.content}' under toolbar button '${s}' - a button takes one 'authorize' line, one 'confirm' line and nothing else`,i(n)),t.skipBlock(n.indent)):_=operandText(r,1)}return{kind:`ToolbarButtonSyntax`,id:s,title:u??``,...d===void 0?{}:{slice:d},...p===void 0?{}:{emphasis:p},...f===void 0?{}:{icon:f},...g===null?{}:{authorize:g},..._===void 0?{}:{confirm:_},location:i(r)}}function parseToolbarItem(t,n){let r=h(t,n,/^item\s+\S+\s+action\s/u.test(n.content),e=>R.test(e)),a=R.exec(r.header);if(a===null){t.error(e.UnknownScreenDirective,`Invalid toolbar item '${n.content}' - expected 'item <name> action <Command>', 'item <name> navigate to <Screen>', 'item <name> dialog <DialogTemplate>' or 'button <id> title "<text>" slice <Slice>'`,i(n)),t.skipBlock(n.indent);return}let s=r.label??null,c=null,l,u=[],d=[];for(let e=t.peekChild(n.indent);e!==void 0;e=t.peekChild(n.indent)){t.reader.takeSignificant();let n=w.exec(e.content);if(n!==null){s=operandText(n,1);continue}let r=L.exec(e.content);if(r!==null){l=operandText(r,1);continue}let a=A.exec(e.content);a===null?o(e.content)===`icon`?c=e.content.substring(4).trim():parsePresentationValue(t,e,d):u.push({kind:`ScreenNavigationParameterSyntax`,name:a[1],binding:y(t,a[2],i(e)),location:i(e)})}let f=a[2]===`navigate`?`Navigate`:a[2]===`dialog`?`Dialog`:`Action`;return{kind:`ToolbarItemSyntax`,name:a[1],syntaxKind:f,target:a[3],label:s,icon:c,...r.subject===void 0?{}:{subject:r.subject},...l===void 0?{}:{confirm:l},parameters:u,presentation:d,location:i(n)}}function parseUiBindingValue(e,t,n){return y(e,t,i(n))}function parseCode(t,n){let r=n.content.startsWith("```")?n.content.substring(3):n.content;if(!t.languages.has(r)){t.error(e.ExpectedCodeFence,`Expected a registered language on the opening fence, not '${n.content}'`,i(n));return}n.content.startsWith("```")||t.warning(e.LegacyInlineCodeFence,`'${r}' on its own line is deprecated - use '\`\`\`${r}' instead`,i(n));let a=l(t,r,n);return a===null?void 0:{kind:`ScreenCodeSyntax`,code:{kind:`CodeBlockSyntax`,language:r,code:a,location:i(n)},location:i(n)}}export{parseScreen,parseToolbar};
2
2
  //# sourceMappingURL=ScreenParser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ScreenParser.js","names":["operand","stringBodyPattern","header","pattern","data","action","label","guardedAction","navigate","route","outletPattern","contributionPattern","parameter","component","stableId","componentPropertyBinding","componentPropertyLiteral","exposes","presentation","confirmPattern","toolbarItem","toolbarButton","toolbarButtonPart","toolbarSlicePath","slot","title","column","rowClick","field","match","quotedGroup","unescapeString","firstWord","line","context","DiagnosticCodes","locationOf","directives","contributions","description","child","parsed","parseDescription","isFileDirective","directive","parent","collectInputUses","parseTypeRef","guarded","parseGuardedAction","text","target","labelMatch","parameters","routeValue","outletValue","parameterMatch","parseFromClause","routeMatch","outletMatch","name","blueprint","version","startsBlueprintReference","reference","parseBlueprintReference","isValidTemplateVersionRange","slots","columns","click","columnMatch","clickMatch","labelled","fields","dataContext","componentStableId","icon","properties","exposedValues","presentationValues","outlets","bound","literal","parseMappingSource","values","items","buttons","button","item","toolbarButtonExpected","head","id","rest","buttonTitle","slice","emphasis","valid","position","part","key","quoted","localized","value","authorize","buttonConfirm","parseAuthorize","confirmMatch","itemLabel","itemConfirm","syntaxKind","language","code","parseFencedText"],"sources":["../../../../../../Compiler/Parsing/ScreenParser.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 {\n ComponentExposedValueSyntax, ComponentOutletSyntax, ComponentPropertySyntax, PresentationValueSyntax,\n ScreenActionSyntax, ScreenGuardedActionSyntax, ScreenCodeSyntax, ScreenColumnSyntax, ScreenComponentSyntax, ScreenDataSyntax, ScreenDirectiveSyntax, ScreenFieldSyntax,\n ScreenNavigateSyntax, ScreenNavigationParameterSyntax, ScreenSectionSyntax, ScreenSlotSyntax, ScreenSummarySyntax, ScreenSyntax, ScreenTableSyntax,\n ScreenTemplateReferenceSyntax, ScreenTitleSyntax, ScreenToolbarSyntax, ToolbarButtonSyntax, ToolbarEmphasis, ToolbarItemKind, ToolbarItemSyntax,\n} from '../Syntax/Screens';\nimport { AuthorizeSyntax } from '../Syntax/Authorization';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { pattern } from '../Text/patterns';\nimport { parseAuthorize } from './AuthorizeParser';\nimport { parseFencedText } from './CodeBlockParser';\nimport { parseMappingSource } from './ExpressionParser';\nimport { parseDescription } from './DescriptionParser';\nimport { isFileDirective } from './FileReferences';\nimport { parseGuardedAction } from './GuardedActionParser';\nimport { collectInputUses } from './InputUses';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { isValidTemplateVersionRange, parseBlueprintReference, startsBlueprintReference } from './TemplateReferenceText';\nimport { parseTypeRef } from './PropertyLineParser';\nimport { parseFromClause } from './UiBindingParser';\nimport { ScreenContributionSyntax } from '../Syntax/CompositionSyntax';\nimport { locationOf, SourceLine } from './SourceLine';\n\n// Parses 'screen' declarations the way the C# ScreenParser does - intent level directives, the template\n// whose slots they fill, and inline code. Interaction bodies remain opaque in the AST, but 'on' alternatives\n// are checked for structure, condition operands and shadowing; 'uses' attachments are recognized.\n\nconst operand = `(?:\"(${stringBodyPattern})\"|(\\\\$strings\\\\.\\\\w+(?:\\\\.\\\\w+)*))`;\nconst header = pattern('^screen\\\\s+([A-Za-z_]\\\\w*)$');\nconst data = pattern('^data\\\\s+([\\\\w.]+(?:\\\\[\\\\])?)\\\\s+via\\\\s+query\\\\s+(\\\\w+(?:\\\\.\\\\w+)*)(?:\\\\s+by\\\\s+(\\\\w+))?$');\nconst action = pattern('^action\\\\s+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)$');\nconst label = pattern(`^label\\\\s+${operand}$`);\nconst guardedAction = pattern(`^action\\\\s+${operand}$`);\nconst navigate = pattern('^navigate\\\\s+to\\\\s+(\\\\w+(?:\\\\.\\\\w+)*)(?:\\\\s+by\\\\s+(\\\\w+))?$');\nconst route = pattern(`^route\\\\s+${operand}$`);\nconst outletPattern = pattern('^outlet\\\\s+([A-Za-z_]\\\\w*)$');\nconst contributionPattern = pattern('^contribute\\\\s+to\\\\s+([A-Za-z_]\\\\w*)(?:\\\\s+order\\\\s+(-?\\\\d+))?$');\nconst parameter = pattern('^parameter\\\\s+([A-Za-z_]\\\\w*)\\\\s+from\\\\s+(.+)$');\nconst component = pattern('^component\\\\s+([A-Za-z_]\\\\w*(?:\\\\.[A-Za-z_]\\\\w*)*)\\\\s+([A-Za-z_]\\\\w*)$');\nconst stableId = pattern(`^id\\\\s+(?:\"(${stringBodyPattern})\"|(\\\\S+))$`);\nconst componentPropertyBinding = pattern('^property\\\\s+([\\\\w.]+)\\\\s+from\\\\s+(.+)$');\nconst componentPropertyLiteral = pattern('^property\\\\s+([\\\\w.]+)\\\\s*=\\\\s+(.+)$');\nconst exposes = pattern('^exposes\\\\s+([A-Za-z_]\\\\w*)\\\\s+from\\\\s+(.+)$');\nconst presentation = pattern(`^presentation\\\\s+([A-Za-z_]\\\\w*)\\\\s+${operand}$`);\nconst confirmPattern = pattern(`^confirm\\\\s+${operand}$`);\nconst toolbarItem = pattern('^item\\\\s+([A-Za-z_]\\\\w*)\\\\s+(action|navigate|dialog)(?:\\\\s+to)?\\\\s+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)$');\nconst toolbarButton = pattern(`^button\\\\s+(?:\"(${stringBodyPattern})\"|([A-Za-z_][\\\\w-]*))(?:\\\\s+(.*))?$`);\nconst toolbarButtonPart = new RegExp(pattern(`\\\\s*(title|slice|emphasis|icon)\\\\s+(?:\"(${stringBodyPattern})\"|(\\\\$strings\\\\.\\\\w+(?:\\\\.\\\\w+)*)|([A-Za-z_][\\\\w.-]*))(?=\\\\s|$)`).source, 'uy');\nconst toolbarSlicePath = pattern('^[A-Za-z_]\\\\w*(?:\\\\.[A-Za-z_]\\\\w*)*$');\nconst slot = pattern('^[a-z_]\\\\w*$');\nconst title = pattern(`^title\\\\s+${operand}$`);\nconst column = pattern(`^column\\\\s+([\\\\w.]+)(?:\\\\s+label\\\\s+${operand})?$`);\nconst rowClick = pattern('^on\\\\s+row-click\\\\s+(navigate\\\\s+to\\\\s+.+)$');\nconst field = pattern(`^field\\\\s+([\\\\w.]+)\\\\s+label\\\\s+${operand}$`);\n\nconst operandText = (match: RegExpExecArray, quotedGroup: number): string =>\n match[quotedGroup] !== undefined ? unescapeString(match[quotedGroup]) : match[quotedGroup + 1];\n\nconst isInteraction = (line: SourceLine): boolean => ['on', 'uses'].includes(firstWord(line.content));\n\nconst isCodeLine = (context: ParserContext, line: SourceLine): boolean => line.content.startsWith('```') || context.languages.has(line.content);\n\nexport function parseScreen(context: ParserContext, line: SourceLine): ScreenSyntax {\n const match = header.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidScreenDeclaration, `Invalid screen declaration '${line.content}' - expected 'screen <Name>'`, locationOf(line));\n }\n const directives: ScreenDirectiveSyntax[] = [];\n const contributions: ScreenContributionSyntax[] = [];\n let description: string | null = null;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (firstWord(child.content) === 'contribute') {\n const parsed = parseScreenContribution(context, child);\n if (parsed !== undefined) contributions.push(parsed);\n } else if (firstWord(child.content) === 'description') {\n description = parseDescription(context, child, description, `Screen '${match?.[1] ?? ''}'`);\n } else if (!isFileDirective(child)) {\n pushDirective(context, child, directives);\n }\n }\n return { kind: 'ScreenSyntax', name: match?.[1] ?? '', directives, description, ...(contributions.length > 0 ? { contributions } : {}), location: locationOf(line) };\n}\n\nfunction parseScreenContribution(context: ParserContext, line: SourceLine): ScreenContributionSyntax | undefined {\n const match = contributionPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.UnknownScreenDirective, `Invalid screen contribution '${line.content}' - expected 'contribute to <Point> [order <n>]'`, locationOf(line));\n context.skipBlock(line.indent);\n return undefined;\n }\n return { kind: 'ScreenContributionSyntax', contributionPoint: match[1], order: match[2] === undefined ? null : Number(match[2]), directives: parseDirectives(context, line), location: locationOf(line) };\n}\n\nfunction pushDirective(context: ParserContext, line: SourceLine, directives: ScreenDirectiveSyntax[]): void {\n const directive = parseDirective(context, line);\n if (directive !== undefined) {\n directives.push(directive);\n }\n}\n\nfunction parseDirectives(context: ParserContext, parent: SourceLine): ScreenDirectiveSyntax[] {\n const directives: ScreenDirectiveSyntax[] = [];\n for (let child = context.peekChild(parent.indent); child !== undefined; child = context.peekChild(parent.indent)) {\n context.reader.takeSignificant();\n pushDirective(context, child, directives);\n }\n return directives;\n}\n\nfunction parseDirective(context: ParserContext, line: SourceLine): ScreenDirectiveSyntax | undefined {\n switch (firstWord(line.content)) {\n case 'data':\n return parseData(context, line);\n case 'action':\n return parseAction(context, line);\n case 'template':\n return parseTemplateReference(context, line);\n case 'section':\n return parseSection(context, line);\n case 'title':\n return parseTitle(context, line);\n case 'table':\n return parseTable(context, line);\n case 'summary':\n return parseSummary(context, line);\n case 'component':\n return parseComponent(context, line);\n case 'toolbar':\n return parseToolbar(context, line);\n case 'navigate':\n return parseNavigate(context, line.content, line);\n case 'on':\n collectInputUses(context, line);\n return { kind: 'ScreenBehaviorSyntax', location: locationOf(line) };\n case 'uses':\n collectInputUses(context, line);\n return { kind: 'ScreenUsesBehaviorSyntax', location: locationOf(line) };\n default:\n if (isCodeLine(context, line)) {\n return parseCode(context, line);\n }\n context.error(DiagnosticCodes.UnknownScreenDirective, `Unexpected '${line.content}' in screen body`, locationOf(line));\n context.skipBlock(line.indent);\n return undefined;\n }\n}\n\nfunction parseData(context: ParserContext, line: SourceLine): ScreenDataSyntax | undefined {\n const match = data.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidDataDirective, `Invalid data directive '${line.content}' - expected 'data <ReadModel> via query <Query> [by <param>]'`, locationOf(line));\n return undefined;\n }\n return { kind: 'ScreenDataSyntax', type: parseTypeRef(match[1], locationOf(line)), query: match[2], by: match[3] ?? null, location: locationOf(line) };\n}\n\nfunction parseAction(context: ParserContext, line: SourceLine): ScreenActionSyntax | ScreenGuardedActionSyntax | undefined {\n const guarded = guardedAction.exec(line.content);\n if (guarded !== null) return parseGuardedAction(context, line, operandText(guarded, 1), parseNavigate);\n const match = action.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidActionDirective, `Invalid action directive '${line.content}' - expected 'action <Command>'`, locationOf(line));\n context.skipBlock(line.indent);\n return undefined;\n }\n let text: string | null = null;\n let target: ScreenNavigateSyntax | null = null;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const labelMatch = label.exec(child.content);\n if (labelMatch !== null) {\n text = operandText(labelMatch, 1);\n } else if (firstWord(child.content) === 'navigate') {\n target = parseNavigate(context, child.content, child) ?? null;\n } else {\n context.error(DiagnosticCodes.UnknownActionDirective, `Unexpected '${child.content}' in action - expected 'label \"...\"' or 'navigate to ...'`, locationOf(child));\n }\n }\n return { kind: 'ScreenActionSyntax', command: match[1], label: text, navigate: target, location: locationOf(line) };\n}\n\nfunction parseNavigate(context: ParserContext, text: string, line: SourceLine): ScreenNavigateSyntax | undefined {\n const match = navigate.exec(text);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidNavigation, `Invalid navigation '${text}' - expected 'navigate to <Screen> [by <param>]'`, locationOf(line));\n return undefined;\n }\n const parameters: ScreenNavigationParameterSyntax[] = [];\n let routeValue: string | null = null;\n let outletValue: string | null = null;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const parameterMatch = parameter.exec(child.content);\n if (parameterMatch !== null) {\n parameters.push({ kind: 'ScreenNavigationParameterSyntax', name: parameterMatch[1], binding: parseFromClause(context, parameterMatch[2], locationOf(child)), location: locationOf(child) });\n continue;\n }\n const routeMatch = route.exec(child.content);\n if (routeMatch !== null) {\n routeValue = operandText(routeMatch, 1);\n continue;\n }\n const outletMatch = outletPattern.exec(child.content);\n if (outletMatch !== null) {\n outletValue = outletMatch[1];\n continue;\n }\n context.error(DiagnosticCodes.InvalidNavigation, `Unexpected '${child.content}' in navigation - expected 'route \"...\"', 'outlet <name>' or 'parameter <name> from <binding>'`, locationOf(child));\n }\n return { kind: 'ScreenNavigateSyntax', screen: match[1], by: match[2] ?? null, route: routeValue, ...(outletValue === null ? {} : { outlet: outletValue }), parameters, location: locationOf(line) };\n}\n\nfunction parseTemplateReference(context: ParserContext, line: SourceLine): ScreenTemplateReferenceSyntax {\n let name = line.content.substring('template'.length).trim();\n let blueprint: string | null = null;\n let version: string | null = null;\n if (startsBlueprintReference(name)) {\n const reference = parseBlueprintReference(name);\n if (reference === undefined) {\n context.error(DiagnosticCodes.UnknownLayoutDirective, `Invalid template reference '${line.content}' - expected 'template <Name>' or 'template blueprint <Blueprint> <Name> [version \"<range>\"]'`, locationOf(line));\n } else {\n ({ blueprint, name, version } = reference);\n if (version !== null && !isValidTemplateVersionRange(version)) {\n context.error(DiagnosticCodes.InvalidTemplateVersionRange, `The template version range '${version}' is not one Scene understands - use '*', an exact version or a ^, ~, >=, >, <= or < range such as \"^1.2\"`, locationOf(line));\n }\n }\n }\n const slots: ScreenSlotSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (!slot.test(child.content)) {\n context.error(DiagnosticCodes.InvalidScreenLayoutSlot, `Expected a slot name in template '${name}', got '${child.content}'`, locationOf(child));\n context.skipBlock(child.indent);\n continue;\n }\n slots.push({ kind: 'ScreenSlotSyntax', name: child.content, directives: parseDirectives(context, child), location: locationOf(child) });\n }\n return { kind: 'ScreenTemplateReferenceSyntax', name, slots, ...(blueprint === null ? {} : { blueprint }), ...(version === null ? {} : { version }), location: locationOf(line) };\n}\n\nfunction parseSection(context: ParserContext, line: SourceLine): ScreenSectionSyntax {\n const name = line.content.substring('section'.length).trim();\n return { kind: 'ScreenSectionSyntax', name, directives: parseDirectives(context, line), location: locationOf(line) };\n}\n\nfunction parseTitle(context: ParserContext, line: SourceLine): ScreenTitleSyntax {\n const match = title.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidTitleDirective, `Invalid title directive '${line.content}' - expected 'title \"...\"'`, locationOf(line));\n return { kind: 'ScreenTitleSyntax', text: '', location: locationOf(line) };\n }\n return { kind: 'ScreenTitleSyntax', text: operandText(match, 1), location: locationOf(line) };\n}\n\nfunction parseTable(context: ParserContext, line: SourceLine): ScreenTableSyntax {\n const target = line.content.substring('table'.length).trim();\n const columns: ScreenColumnSyntax[] = [];\n let click: ScreenNavigateSyntax | null = null;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const columnMatch = column.exec(child.content);\n const clickMatch = rowClick.exec(child.content);\n if (columnMatch !== null) {\n const labelled = columnMatch[2] !== undefined || columnMatch[3] !== undefined;\n columns.push({ kind: 'ScreenColumnSyntax', property: columnMatch[1], label: labelled ? operandText(columnMatch, 2) : null, location: locationOf(child) });\n } else if (clickMatch !== null) {\n click = parseNavigate(context, clickMatch[1], child) ?? null;\n } else if (firstWord(child.content) === 'on') {\n collectInputUses(context, child);\n } else if (isInteraction(child)) {\n collectInputUses(context, child);\n } else {\n context.error(DiagnosticCodes.UnknownTableDirective, `Unexpected '${child.content}' in table - expected 'column ...', 'on row-click navigate to ...', 'on <trigger>' or 'uses <Behavior>'`, locationOf(child));\n }\n }\n return { kind: 'ScreenTableSyntax', target, columns, rowClick: click, location: locationOf(line) };\n}\n\nfunction parseSummary(context: ParserContext, line: SourceLine): ScreenSummarySyntax {\n const target = line.content.substring('summary'.length).trim();\n const fields: ScreenFieldSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const match = field.exec(child.content);\n if (match === null) {\n context.error(DiagnosticCodes.UnknownSummaryDirective, `Unexpected '${child.content}' in summary - expected 'field <property> label \"...\"'`, locationOf(child));\n continue;\n }\n fields.push({ kind: 'ScreenFieldSyntax', property: match[1], label: operandText(match, 2), location: locationOf(child) });\n }\n return { kind: 'ScreenSummarySyntax', target, fields, location: locationOf(line) };\n}\n\n\nfunction parseComponent(context: ParserContext, line: SourceLine): ScreenComponentSyntax | undefined {\n const match = component.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.UnknownScreenDirective, `Invalid component directive '${line.content}' - expected 'component <Package.Component> <name>'`, locationOf(line));\n context.skipBlock(line.indent);\n return undefined;\n }\n\n let dataContext = null;\n let componentStableId = null;\n let icon = null;\n const properties: ComponentPropertySyntax[] = [];\n const exposedValues: ComponentExposedValueSyntax[] = [];\n const presentationValues: PresentationValueSyntax[] = [];\n const outlets: ComponentOutletSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n switch (firstWord(child.content)) {\n case 'context':\n dataContext = parseUiContext(context, child);\n break;\n case 'id':\n componentStableId = parseStableId(context, child);\n break;\n case 'property':\n parseComponentProperty(context, child, properties);\n break;\n case 'icon':\n icon = child.content.substring('icon'.length).trim();\n break;\n case 'presentation':\n parsePresentationValue(context, child, presentationValues);\n break;\n case 'exposes':\n parseExposedValue(context, child, exposedValues);\n break;\n case 'outlet':\n outlets.push({ kind: 'ComponentOutletSyntax', name: child.content.substring('outlet'.length).trim(), directives: parseDirectives(context, child), location: locationOf(child) });\n break;\n case 'on':\n collectInputUses(context, child);\n break;\n case 'uses':\n collectInputUses(context, child);\n break;\n default:\n context.error(DiagnosticCodes.UnknownScreenDirective, `Unexpected '${child.content}' in component - expected context, id, property, icon, presentation, exposes, outlet, on or uses`, locationOf(child));\n context.skipBlock(child.indent);\n break;\n }\n }\n\n return { kind: 'ScreenComponentSyntax', component: match[1], name: match[2], stableId: componentStableId, context: dataContext, properties, exposes: exposedValues, presentation: presentationValues, icon, outlets, location: locationOf(line) };\n}\n\nfunction parseUiContext(context: ParserContext, line: SourceLine) {\n return parseUiBindingValue(context, line.content.substring('context'.length).trim(), line);\n}\n\nfunction parseComponentProperty(context: ParserContext, line: SourceLine, properties: ComponentPropertySyntax[]): void {\n const bound = componentPropertyBinding.exec(line.content);\n if (bound !== null) {\n properties.push({ kind: 'ComponentPropertySyntax', property: bound[1], binding: parseFromClause(context, bound[2], locationOf(line)), value: null, location: locationOf(line) });\n return;\n }\n const literal = componentPropertyLiteral.exec(line.content);\n if (literal !== null) {\n properties.push({ kind: 'ComponentPropertySyntax', property: literal[1], binding: null, value: parseMappingSource(literal[2], locationOf(line), context), location: locationOf(line) });\n return;\n }\n context.error(DiagnosticCodes.UnknownScreenDirective, `Invalid component property '${line.content}' - expected 'property <path> from <binding>' or 'property <path> = <literal|object|array|null>'`, locationOf(line));\n}\n\nfunction parseStableId(context: ParserContext, line: SourceLine): string | null {\n const match = stableId.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.UnknownScreenDirective, `Invalid component id '${line.content}' - expected 'id \"stable-id\"'`, locationOf(line));\n return null;\n }\n return operandText(match, 1);\n}\n\nfunction parseExposedValue(context: ParserContext, line: SourceLine, values: ComponentExposedValueSyntax[]): void {\n const match = exposes.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.UnknownScreenDirective, `Invalid exposed value '${line.content}' - expected 'exposes <name> from <binding>'`, locationOf(line));\n return;\n }\n values.push({ kind: 'ComponentExposedValueSyntax', name: match[1], binding: parseFromClause(context, match[2], locationOf(line)), location: locationOf(line) });\n}\n\nfunction parsePresentationValue(context: ParserContext, line: SourceLine, values: PresentationValueSyntax[]): void {\n const match = presentation.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.UnknownScreenDirective, `Invalid presentation value '${line.content}' - expected 'presentation <key> \"value\"'`, locationOf(line));\n return;\n }\n values.push({ kind: 'PresentationValueSyntax', name: match[1], value: operandText(match, 2), location: locationOf(line) });\n}\n\nexport function parseToolbar(context: ParserContext, line: SourceLine): ScreenToolbarSyntax {\n const name = line.content.substring('toolbar'.length).trim();\n const items: ToolbarItemSyntax[] = [];\n const buttons: ToolbarButtonSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (firstWord(child.content) === 'button') {\n const button = parseToolbarButton(context, child);\n if (button !== undefined) buttons.push(button);\n continue;\n }\n const item = parseToolbarItem(context, child);\n if (item !== undefined) items.push(item);\n }\n return { kind: 'ScreenToolbarSyntax', name, items, ...(buttons.length > 0 ? { buttons } : {}), location: locationOf(line) };\n}\n\nconst toolbarButtonExpected = 'button <id> title \"<text>\" [slice <Module>.<Feature>.<Slice>] [emphasis primary|secondary|quiet] [icon <name>]';\n\n// A button is one line; the C# compiler checks what it names (PLAY0761-PLAY0765), this one reads its grammar.\nfunction parseToolbarButton(context: ParserContext, line: SourceLine): ToolbarButtonSyntax | undefined {\n const head = toolbarButton.exec(line.content);\n if (head === null) {\n context.error(DiagnosticCodes.InvalidToolbarButton, `Invalid toolbar button '${line.content}' - expected ${toolbarButtonExpected}`, locationOf(line));\n context.skipBlock(line.indent);\n return undefined;\n }\n const id = head[1] !== undefined ? unescapeString(head[1]) : head[2];\n const rest = head[3] ?? '';\n let buttonTitle: string | undefined;\n let slice: string | undefined;\n let icon: string | undefined;\n let emphasis: ToolbarEmphasis | undefined;\n let valid = true;\n let position = 0;\n while (position < rest.length) {\n toolbarButtonPart.lastIndex = position;\n const part = toolbarButtonPart.exec(rest);\n if (part === null) {\n context.error(DiagnosticCodes.InvalidToolbarButton, `Invalid toolbar button '${line.content}' - unexpected '${rest.substring(position).trim()}'; expected ${toolbarButtonExpected}`, locationOf(line));\n valid = false;\n break;\n }\n position = part.index + part[0].length;\n const key = part[1];\n const quoted = part[2] !== undefined;\n const localized = part[3] !== undefined;\n const value = quoted ? unescapeString(part[2]) : localized ? part[3] : part[4];\n const repeated = key === 'title' ? buttonTitle !== undefined : key === 'slice' ? slice !== undefined : key === 'icon' ? icon !== undefined : emphasis !== undefined;\n if (repeated) {\n context.error(DiagnosticCodes.InvalidToolbarButton, `Toolbar button '${id}' states '${key}' more than once`, locationOf(line));\n continue;\n }\n if (key === 'title') {\n if (quoted || localized) buttonTitle = value;\n else {\n context.error(DiagnosticCodes.InvalidToolbarButton, `Invalid title '${value}' on toolbar button '${id}' - expected a quoted string or a $strings.<key> token`, locationOf(line));\n valid = false;\n }\n } else if (key === 'slice') {\n if (!quoted && !localized && toolbarSlicePath.test(value)) slice = value;\n else {\n context.error(DiagnosticCodes.InvalidToolbarButton, `Invalid slice '${value}' on toolbar button '${id}' - expected <Module>.<Feature>.<Slice>`, locationOf(line));\n valid = false;\n }\n } else if (key === 'emphasis') {\n if (!quoted && !localized && ['primary', 'secondary', 'quiet'].includes(value)) emphasis = value === 'primary' ? 'Primary' : value === 'secondary' ? 'Secondary' : 'Quiet';\n else {\n context.error(DiagnosticCodes.InvalidToolbarButton, `Invalid emphasis '${value}' on toolbar button '${id}' - expected primary, secondary or quiet`, locationOf(line));\n valid = false;\n }\n } else {\n icon = value;\n }\n }\n if (buttonTitle === undefined && valid) {\n context.error(DiagnosticCodes.InvalidToolbarButton, `Toolbar button '${id}' has no title - expected 'button ${id} title \"<text>\"'`, locationOf(line));\n }\n let authorize: AuthorizeSyntax | null = null;\n let buttonConfirm: string | undefined;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (firstWord(child.content) === 'authorize' && authorize === null) {\n authorize = parseAuthorize(context, child);\n continue;\n }\n const confirmMatch = buttonConfirm === undefined ? confirmPattern.exec(child.content) : null;\n if (confirmMatch !== null) {\n buttonConfirm = operandText(confirmMatch, 1);\n continue;\n }\n context.error(DiagnosticCodes.InvalidToolbarButton, `Unexpected '${child.content}' under toolbar button '${id}' - a button takes one 'authorize' line, one 'confirm' line and nothing else`, locationOf(child));\n context.skipBlock(child.indent);\n }\n return {\n kind: 'ToolbarButtonSyntax', id, title: buttonTitle ?? '',\n ...(slice !== undefined ? { slice } : {}), ...(emphasis !== undefined ? { emphasis } : {}), ...(icon !== undefined ? { icon } : {}), ...(authorize !== null ? { authorize } : {}), ...(buttonConfirm !== undefined ? { confirm: buttonConfirm } : {}),\n location: locationOf(line),\n };\n}\n\nfunction parseToolbarItem(context: ParserContext, line: SourceLine): ToolbarItemSyntax | undefined {\n const match = toolbarItem.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.UnknownScreenDirective, `Invalid toolbar item '${line.content}' - expected 'item <name> action <Command>', 'item <name> navigate to <Screen>', 'item <name> dialog <DialogTemplate>' or 'button <id> title \"<text>\" slice <Slice>'`, locationOf(line));\n context.skipBlock(line.indent);\n return undefined;\n }\n let itemLabel = null;\n let icon = null;\n let itemConfirm: string | undefined;\n const parameters: ScreenNavigationParameterSyntax[] = [];\n const presentationValues: PresentationValueSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const labelMatch = label.exec(child.content);\n if (labelMatch !== null) {\n itemLabel = operandText(labelMatch, 1);\n continue;\n }\n const confirmMatch = confirmPattern.exec(child.content);\n if (confirmMatch !== null) {\n itemConfirm = operandText(confirmMatch, 1);\n continue;\n }\n const parameterMatch = parameter.exec(child.content);\n if (parameterMatch !== null) {\n parameters.push({ kind: 'ScreenNavigationParameterSyntax', name: parameterMatch[1], binding: parseFromClause(context, parameterMatch[2], locationOf(child)), location: locationOf(child) });\n continue;\n }\n if (firstWord(child.content) === 'icon') {\n icon = child.content.substring('icon'.length).trim();\n continue;\n }\n parsePresentationValue(context, child, presentationValues);\n }\n const syntaxKind: ToolbarItemKind = match[2] === 'navigate' ? 'Navigate' : match[2] === 'dialog' ? 'Dialog' : 'Action';\n return { kind: 'ToolbarItemSyntax', name: match[1], syntaxKind, target: match[3], label: itemLabel, icon, ...(itemConfirm !== undefined ? { confirm: itemConfirm } : {}), parameters, presentation: presentationValues, location: locationOf(line) };\n}\n\nfunction parseUiBindingValue(context: ParserContext, text: string, line: SourceLine) {\n return parseFromClause(context, text, locationOf(line));\n}\n\nfunction parseCode(context: ParserContext, line: SourceLine): ScreenCodeSyntax | undefined {\n const language = line.content.startsWith('```') ? line.content.substring(3) : line.content;\n if (!context.languages.has(language)) {\n context.error(DiagnosticCodes.ExpectedCodeFence, `Expected a registered language on the opening fence, not '${line.content}'`, locationOf(line));\n return undefined;\n }\n if (!line.content.startsWith('```')) {\n context.warning(DiagnosticCodes.LegacyInlineCodeFence, `'${language}' on its own line is deprecated - use '\\`\\`\\`${language}' instead`, locationOf(line));\n }\n const code = parseFencedText(context, language, line);\n return code === null ? undefined : {\n kind: 'ScreenCodeSyntax',\n code: { kind: 'CodeBlockSyntax', language, code, location: locationOf(line) },\n location: locationOf(line),\n };\n}\n"],"mappings":"y8BAgCA,MAAMA,EAAU,QAAQC,EAAkB,qCACpCC,EAASC,EAAQ,6BAA6B,EAC9CC,EAAOD,EAAQ,2FAA2F,EAC1GE,EAASF,EAAQ,yCAAyC,EAC1DG,EAAQH,EAAQ,aAAaH,EAAQ,EAAE,EACvCO,EAAgBJ,EAAQ,cAAcH,EAAQ,EAAE,EAChDQ,EAAWL,EAAQ,6DAA6D,EAChFM,EAAQN,EAAQ,aAAaH,EAAQ,EAAE,EACvCU,EAAgBP,EAAQ,6BAA6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,IAAA,GAAuC,CAAC,EAA5B,CAAE,QAASA,CAAY,EAAS,aAAY,aAAc7B,EAAoB,SAAU3C,EAAWH,CAAI,CAAE,CACvP,CAEA,SAAS,oBAAoB,EAAwB,EAAc,EAAkB,CACjF,OAAOwB,EAAgBvB,EAASgB,EAAMd,EAAWH,CAAI,CAAC,CAC1D,CAEA,SAAS,UAAU,EAAwB,EAAgD,CACvF,IAAM6E,EAAW7E,EAAK,QAAQ,WAAW,KAAK,EAAIA,EAAK,QAAQ,UAAU,CAAC,EAAIA,EAAK,QACnF,GAAI,CAACC,EAAQ,UAAU,IAAI4E,CAAQ,EAAG,CAClC5E,EAAQ,MAAMC,EAAgB,kBAAmB,6DAA6DF,EAAK,QAAQ,GAAIG,EAAWH,CAAI,CAAC,EAC/I,MACJ,CACKA,EAAK,QAAQ,WAAW,KAAK,GAC9BC,EAAQ,QAAQC,EAAgB,sBAAuB,IAAI2E,EAAS,+CAA+CA,EAAS,WAAY1E,EAAWH,CAAI,CAAC,EAE5J,IAAM8E,EAAOC,EAAgB9E,EAAS4E,EAAU7E,CAAI,EACpD,OAAO8E,IAAS,KAAO,IAAA,GAAY,CAC/B,KAAM,mBACN,KAAM,CAAE,KAAM,kBAAmB,WAAU,OAAM,SAAU3E,EAAWH,CAAI,CAAE,EAC5E,SAAUG,EAAWH,CAAI,CAC7B,CACJ"}
1
+ {"version":3,"file":"ScreenParser.js","names":["operand","stringBodyPattern","header","pattern","data","action","label","guardedAction","navigate","route","outletPattern","contributionPattern","parameter","component","stableId","componentPropertyBinding","componentPropertyLiteral","exposes","presentation","confirmPattern","toolbarItem","toolbarButton","toolbarButtonPart","toolbarSlicePath","slot","title","column","rowClick","field","match","quotedGroup","unescapeString","firstWord","line","context","DiagnosticCodes","locationOf","directives","contributions","description","child","parsed","parseDescription","isFileDirective","directive","parent","collectInputUses","parseTypeRef","grammar","parseSubjectClause","content","result","guarded","parseGuardedAction","text","target","inputs","labelMatch","input","parsePlainActionInput","parameters","routeValue","outletValue","parameterMatch","parseFromClause","routeMatch","outletMatch","name","blueprint","version","startsBlueprintReference","reference","parseBlueprintReference","isValidTemplateVersionRange","slots","columns","click","columnMatch","clickMatch","labelled","fields","dataContext","componentStableId","icon","properties","exposedValues","presentationValues","outlets","bound","literal","parseMappingSource","values","items","buttons","button","item","toolbarButtonExpected","head","id","rest","buttonTitle","slice","emphasis","valid","position","part","key","quoted","localized","value","authorize","buttonConfirm","parseAuthorize","confirmMatch","itemLabel","itemConfirm","syntaxKind","language","code","parseFencedText"],"sources":["../../../../../../Compiler/Parsing/ScreenParser.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 {\n ComponentExposedValueSyntax, ComponentOutletSyntax, ComponentPropertySyntax, PresentationValueSyntax,\n ScreenActionSyntax, ScreenGuardedActionSyntax, ScreenCodeSyntax, ScreenColumnSyntax, ScreenComponentSyntax, ScreenDataSyntax, ScreenDirectiveSyntax, ScreenFieldSyntax,\n ScreenNavigateSyntax, ScreenNavigationParameterSyntax, ScreenSectionSyntax, ScreenSlotSyntax, ScreenSummarySyntax, ScreenSyntax, ScreenTableSyntax,\n ScreenTemplateReferenceSyntax, ScreenTitleSyntax, ScreenToolbarSyntax, ToolbarButtonSyntax, ToolbarEmphasis, ToolbarItemKind, ToolbarItemSyntax,\n} from '../Syntax/Screens';\nimport { AuthorizeSyntax } from '../Syntax/Authorization';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { pattern } from '../Text/patterns';\nimport { parseAuthorize } from './AuthorizeParser';\nimport { parsePlainActionInput, parseSubjectClause } from './ActionSubjectClause';\nimport { InteractionArgumentSyntax } from '../Syntax/Screens';\nimport { parseFencedText } from './CodeBlockParser';\nimport { parseMappingSource } from './ExpressionParser';\nimport { parseDescription } from './DescriptionParser';\nimport { isFileDirective } from './FileReferences';\nimport { parseGuardedAction } from './GuardedActionParser';\nimport { collectInputUses } from './InputUses';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { isValidTemplateVersionRange, parseBlueprintReference, startsBlueprintReference } from './TemplateReferenceText';\nimport { parseTypeRef } from './PropertyLineParser';\nimport { parseFromClause } from './UiBindingParser';\nimport { ScreenContributionSyntax } from '../Syntax/CompositionSyntax';\nimport { locationOf, SourceLine } from './SourceLine';\n\n// Parses 'screen' declarations the way the C# ScreenParser does - intent level directives, the template\n// whose slots they fill, and inline code. Interaction bodies remain opaque in the AST, but 'on' alternatives\n// are checked for structure, condition operands and shadowing; 'uses' attachments are recognized.\n\nconst operand = `(?:\"(${stringBodyPattern})\"|(\\\\$strings\\\\.\\\\w+(?:\\\\.\\\\w+)*))`;\nconst header = pattern('^screen\\\\s+([A-Za-z_]\\\\w*)$');\nconst data = pattern('^data\\\\s+([\\\\w.]+(?:\\\\[\\\\])?)\\\\s+via\\\\s+query\\\\s+(\\\\w+(?:\\\\.\\\\w+)*)(?:\\\\s+by\\\\s+(\\\\w+))?$');\nconst action = pattern('^action\\\\s+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)$');\nconst label = pattern(`^label\\\\s+${operand}$`);\nconst guardedAction = pattern(`^action\\\\s+${operand}$`);\nconst navigate = pattern('^navigate\\\\s+to\\\\s+(\\\\w+(?:\\\\.\\\\w+)*)(?:\\\\s+by\\\\s+(\\\\w+))?$');\nconst route = pattern(`^route\\\\s+${operand}$`);\nconst outletPattern = pattern('^outlet\\\\s+([A-Za-z_]\\\\w*)$');\nconst contributionPattern = pattern('^contribute\\\\s+to\\\\s+([A-Za-z_]\\\\w*)(?:\\\\s+order\\\\s+(-?\\\\d+))?$');\nconst parameter = pattern('^parameter\\\\s+([A-Za-z_]\\\\w*)\\\\s+from\\\\s+(.+)$');\nconst component = pattern('^component\\\\s+([A-Za-z_]\\\\w*(?:\\\\.[A-Za-z_]\\\\w*)*)\\\\s+([A-Za-z_]\\\\w*)$');\nconst stableId = pattern(`^id\\\\s+(?:\"(${stringBodyPattern})\"|(\\\\S+))$`);\nconst componentPropertyBinding = pattern('^property\\\\s+([\\\\w.]+)\\\\s+from\\\\s+(.+)$');\nconst componentPropertyLiteral = pattern('^property\\\\s+([\\\\w.]+)\\\\s*=\\\\s+(.+)$');\nconst exposes = pattern('^exposes\\\\s+([A-Za-z_]\\\\w*)\\\\s+from\\\\s+(.+)$');\nconst presentation = pattern(`^presentation\\\\s+([A-Za-z_]\\\\w*)\\\\s+${operand}$`);\nconst confirmPattern = pattern(`^confirm\\\\s+${operand}$`);\nconst toolbarItem = pattern('^item\\\\s+([A-Za-z_]\\\\w*)\\\\s+(action|navigate|dialog)(?:\\\\s+to)?\\\\s+([A-Za-z_]\\\\w*(?:\\\\.\\\\w+)*)$');\nconst toolbarButton = pattern(`^button\\\\s+(?:\"(${stringBodyPattern})\"|([A-Za-z_][\\\\w-]*))(?:\\\\s+(.*))?$`);\nconst toolbarButtonPart = new RegExp(pattern(`\\\\s*(title|slice|emphasis|icon)\\\\s+(?:\"(${stringBodyPattern})\"|(\\\\$strings\\\\.\\\\w+(?:\\\\.\\\\w+)*)|([A-Za-z_][\\\\w.-]*))(?=\\\\s|$)`).source, 'uy');\nconst toolbarSlicePath = pattern('^[A-Za-z_]\\\\w*(?:\\\\.[A-Za-z_]\\\\w*)*$');\nconst slot = pattern('^[a-z_]\\\\w*$');\nconst title = pattern(`^title\\\\s+${operand}$`);\nconst column = pattern(`^column\\\\s+([\\\\w.]+)(?:\\\\s+label\\\\s+${operand})?$`);\nconst rowClick = pattern('^on\\\\s+row-click\\\\s+(navigate\\\\s+to\\\\s+.+)$');\nconst field = pattern(`^field\\\\s+([\\\\w.]+)\\\\s+label\\\\s+${operand}$`);\n\nconst operandText = (match: RegExpExecArray, quotedGroup: number): string =>\n match[quotedGroup] !== undefined ? unescapeString(match[quotedGroup]) : match[quotedGroup + 1];\n\nconst isInteraction = (line: SourceLine): boolean => ['on', 'uses'].includes(firstWord(line.content));\n\nconst isCodeLine = (context: ParserContext, line: SourceLine): boolean => line.content.startsWith('```') || context.languages.has(line.content);\n\nexport function parseScreen(context: ParserContext, line: SourceLine): ScreenSyntax {\n const match = header.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidScreenDeclaration, `Invalid screen declaration '${line.content}' - expected 'screen <Name>'`, locationOf(line));\n }\n const directives: ScreenDirectiveSyntax[] = [];\n const contributions: ScreenContributionSyntax[] = [];\n let description: string | null = null;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (firstWord(child.content) === 'contribute') {\n const parsed = parseScreenContribution(context, child);\n if (parsed !== undefined) contributions.push(parsed);\n } else if (firstWord(child.content) === 'description') {\n description = parseDescription(context, child, description, `Screen '${match?.[1] ?? ''}'`);\n } else if (!isFileDirective(child)) {\n pushDirective(context, child, directives);\n }\n }\n return { kind: 'ScreenSyntax', name: match?.[1] ?? '', directives, description, ...(contributions.length > 0 ? { contributions } : {}), location: locationOf(line) };\n}\n\nfunction parseScreenContribution(context: ParserContext, line: SourceLine): ScreenContributionSyntax | undefined {\n const match = contributionPattern.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.UnknownScreenDirective, `Invalid screen contribution '${line.content}' - expected 'contribute to <Point> [order <n>]'`, locationOf(line));\n context.skipBlock(line.indent);\n return undefined;\n }\n return { kind: 'ScreenContributionSyntax', contributionPoint: match[1], order: match[2] === undefined ? null : Number(match[2]), directives: parseDirectives(context, line), location: locationOf(line) };\n}\n\nfunction pushDirective(context: ParserContext, line: SourceLine, directives: ScreenDirectiveSyntax[]): void {\n const directive = parseDirective(context, line);\n if (directive !== undefined) {\n directives.push(directive);\n }\n}\n\nfunction parseDirectives(context: ParserContext, parent: SourceLine): ScreenDirectiveSyntax[] {\n const directives: ScreenDirectiveSyntax[] = [];\n for (let child = context.peekChild(parent.indent); child !== undefined; child = context.peekChild(parent.indent)) {\n context.reader.takeSignificant();\n pushDirective(context, child, directives);\n }\n return directives;\n}\n\nfunction parseDirective(context: ParserContext, line: SourceLine): ScreenDirectiveSyntax | undefined {\n validateNonActionSubjectClause(context, line);\n switch (firstWord(line.content)) {\n case 'data':\n return parseData(context, line);\n case 'action':\n return parseAction(context, line);\n case 'template':\n return parseTemplateReference(context, line);\n case 'section':\n return parseSection(context, line);\n case 'title':\n return parseTitle(context, line);\n case 'table':\n return parseTable(context, line);\n case 'summary':\n return parseSummary(context, line);\n case 'component':\n return parseComponent(context, line);\n case 'toolbar':\n return parseToolbar(context, line);\n case 'navigate':\n return parseNavigate(context, line.content, line);\n case 'on':\n collectInputUses(context, line);\n return { kind: 'ScreenBehaviorSyntax', location: locationOf(line) };\n case 'uses':\n collectInputUses(context, line);\n return { kind: 'ScreenUsesBehaviorSyntax', location: locationOf(line) };\n default:\n if (isCodeLine(context, line)) {\n return parseCode(context, line);\n }\n context.error(DiagnosticCodes.UnknownScreenDirective, `Unexpected '${line.content}' in screen body`, locationOf(line));\n context.skipBlock(line.indent);\n return undefined;\n }\n}\n\nfunction parseData(context: ParserContext, line: SourceLine): ScreenDataSyntax | undefined {\n const match = data.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidDataDirective, `Invalid data directive '${line.content}' - expected 'data <ReadModel> via query <Query> [by <param>]'`, locationOf(line));\n return undefined;\n }\n return { kind: 'ScreenDataSyntax', type: parseTypeRef(match[1], locationOf(line)), query: match[2], by: match[3] ?? null, location: locationOf(line) };\n}\n\nfunction validateNonActionSubjectClause(context: ParserContext, line: SourceLine): void {\n const grammar = new Map([['data', data], ['navigate', navigate], ['component', component], ['title', title]]).get(firstWord(line.content));\n // Expressions, code and open-ended template references belong to their own parsers.\n if (grammar !== undefined) parseSubjectClause(context, line, false, content => grammar.test(content));\n}\n\nfunction parseAction(context: ParserContext, line: SourceLine): ScreenActionSyntax | ScreenGuardedActionSyntax | undefined {\n const parsed = parseSubjectClause(context, line, true, content => action.test(content) || guardedAction.test(content));\n const result = parseActionHeader(context, line, parsed);\n if (result === undefined || parsed.subject === undefined) return result;\n return { ...result, subject: parsed.subject };\n}\n\nfunction parseActionHeader(context: ParserContext, line: SourceLine, parsed: ReturnType<typeof parseSubjectClause>): ScreenActionSyntax | ScreenGuardedActionSyntax | undefined {\n const guarded = guardedAction.exec(parsed.header);\n if (guarded !== null) return parseGuardedAction(context, line, operandText(guarded, 1), parseNavigate);\n const match = action.exec(parsed.header);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidActionDirective, `Invalid action directive '${line.content}' - expected 'action <Command>'`, locationOf(line));\n context.skipBlock(line.indent);\n return undefined;\n }\n let text: string | null = parsed.label ?? null;\n let target: ScreenNavigateSyntax | null = null;\n const inputs: InteractionArgumentSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const labelMatch = label.exec(child.content);\n if (labelMatch !== null) {\n text = operandText(labelMatch, 1);\n } else if (firstWord(child.content) === 'navigate') {\n target = parseNavigate(context, child.content, child) ?? null;\n } else if (firstWord(child.content) === 'with') {\n addPlainActionInput(context, child, inputs);\n } else {\n context.error(DiagnosticCodes.UnknownActionDirective, `Unexpected '${child.content}' in action - expected 'label \"...\"' or 'navigate to ...'`, locationOf(child));\n }\n }\n return { kind: 'ScreenActionSyntax', command: match[1], label: text, navigate: target, ...(inputs.length === 0 ? {} : { inputs }), location: locationOf(line) };\n}\n\nfunction addPlainActionInput(context: ParserContext, line: SourceLine, inputs: InteractionArgumentSyntax[]): void {\n const input = parsePlainActionInput(context, line, inputs);\n if (input !== undefined) inputs.push(input);\n}\n\nfunction parseNavigate(context: ParserContext, text: string, line: SourceLine): ScreenNavigateSyntax | undefined {\n const match = navigate.exec(text);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidNavigation, `Invalid navigation '${text}' - expected 'navigate to <Screen> [by <param>]'`, locationOf(line));\n return undefined;\n }\n const parameters: ScreenNavigationParameterSyntax[] = [];\n let routeValue: string | null = null;\n let outletValue: string | null = null;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const parameterMatch = parameter.exec(child.content);\n if (parameterMatch !== null) {\n parameters.push({ kind: 'ScreenNavigationParameterSyntax', name: parameterMatch[1], binding: parseFromClause(context, parameterMatch[2], locationOf(child)), location: locationOf(child) });\n continue;\n }\n const routeMatch = route.exec(child.content);\n if (routeMatch !== null) {\n routeValue = operandText(routeMatch, 1);\n continue;\n }\n const outletMatch = outletPattern.exec(child.content);\n if (outletMatch !== null) {\n outletValue = outletMatch[1];\n continue;\n }\n context.error(DiagnosticCodes.InvalidNavigation, `Unexpected '${child.content}' in navigation - expected 'route \"...\"', 'outlet <name>' or 'parameter <name> from <binding>'`, locationOf(child));\n }\n return { kind: 'ScreenNavigateSyntax', screen: match[1], by: match[2] ?? null, route: routeValue, ...(outletValue === null ? {} : { outlet: outletValue }), parameters, location: locationOf(line) };\n}\n\nfunction parseTemplateReference(context: ParserContext, line: SourceLine): ScreenTemplateReferenceSyntax {\n let name = line.content.substring('template'.length).trim();\n let blueprint: string | null = null;\n let version: string | null = null;\n if (startsBlueprintReference(name)) {\n const reference = parseBlueprintReference(name);\n if (reference === undefined) {\n context.error(DiagnosticCodes.UnknownLayoutDirective, `Invalid template reference '${line.content}' - expected 'template <Name>' or 'template blueprint <Blueprint> <Name> [version \"<range>\"]'`, locationOf(line));\n } else {\n ({ blueprint, name, version } = reference);\n if (version !== null && !isValidTemplateVersionRange(version)) {\n context.error(DiagnosticCodes.InvalidTemplateVersionRange, `The template version range '${version}' is not one Scene understands - use '*', an exact version or a ^, ~, >=, >, <= or < range such as \"^1.2\"`, locationOf(line));\n }\n }\n }\n const slots: ScreenSlotSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (!slot.test(child.content)) {\n context.error(DiagnosticCodes.InvalidScreenLayoutSlot, `Expected a slot name in template '${name}', got '${child.content}'`, locationOf(child));\n context.skipBlock(child.indent);\n continue;\n }\n slots.push({ kind: 'ScreenSlotSyntax', name: child.content, directives: parseDirectives(context, child), location: locationOf(child) });\n }\n return { kind: 'ScreenTemplateReferenceSyntax', name, slots, ...(blueprint === null ? {} : { blueprint }), ...(version === null ? {} : { version }), location: locationOf(line) };\n}\n\nfunction parseSection(context: ParserContext, line: SourceLine): ScreenSectionSyntax {\n const name = line.content.substring('section'.length).trim();\n return { kind: 'ScreenSectionSyntax', name, directives: parseDirectives(context, line), location: locationOf(line) };\n}\n\nfunction parseTitle(context: ParserContext, line: SourceLine): ScreenTitleSyntax {\n const match = title.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.InvalidTitleDirective, `Invalid title directive '${line.content}' - expected 'title \"...\"'`, locationOf(line));\n return { kind: 'ScreenTitleSyntax', text: '', location: locationOf(line) };\n }\n return { kind: 'ScreenTitleSyntax', text: operandText(match, 1), location: locationOf(line) };\n}\n\nfunction parseTable(context: ParserContext, line: SourceLine): ScreenTableSyntax {\n const target = line.content.substring('table'.length).trim();\n const columns: ScreenColumnSyntax[] = [];\n let click: ScreenNavigateSyntax | null = null;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const columnMatch = column.exec(child.content);\n const clickMatch = rowClick.exec(child.content);\n if (columnMatch !== null) {\n const labelled = columnMatch[2] !== undefined || columnMatch[3] !== undefined;\n columns.push({ kind: 'ScreenColumnSyntax', property: columnMatch[1], label: labelled ? operandText(columnMatch, 2) : null, location: locationOf(child) });\n } else if (clickMatch !== null) {\n click = parseNavigate(context, clickMatch[1], child) ?? null;\n } else if (firstWord(child.content) === 'on') {\n collectInputUses(context, child);\n } else if (isInteraction(child)) {\n collectInputUses(context, child);\n } else {\n context.error(DiagnosticCodes.UnknownTableDirective, `Unexpected '${child.content}' in table - expected 'column ...', 'on row-click navigate to ...', 'on <trigger>' or 'uses <Behavior>'`, locationOf(child));\n }\n }\n return { kind: 'ScreenTableSyntax', target, columns, rowClick: click, location: locationOf(line) };\n}\n\nfunction parseSummary(context: ParserContext, line: SourceLine): ScreenSummarySyntax {\n const target = line.content.substring('summary'.length).trim();\n const fields: ScreenFieldSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const match = field.exec(child.content);\n if (match === null) {\n context.error(DiagnosticCodes.UnknownSummaryDirective, `Unexpected '${child.content}' in summary - expected 'field <property> label \"...\"'`, locationOf(child));\n continue;\n }\n fields.push({ kind: 'ScreenFieldSyntax', property: match[1], label: operandText(match, 2), location: locationOf(child) });\n }\n return { kind: 'ScreenSummarySyntax', target, fields, location: locationOf(line) };\n}\n\n\nfunction parseComponent(context: ParserContext, line: SourceLine): ScreenComponentSyntax | undefined {\n const match = component.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.UnknownScreenDirective, `Invalid component directive '${line.content}' - expected 'component <Package.Component> <name>'`, locationOf(line));\n context.skipBlock(line.indent);\n return undefined;\n }\n\n let dataContext = null;\n let componentStableId = null;\n let icon = null;\n const properties: ComponentPropertySyntax[] = [];\n const exposedValues: ComponentExposedValueSyntax[] = [];\n const presentationValues: PresentationValueSyntax[] = [];\n const outlets: ComponentOutletSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n switch (firstWord(child.content)) {\n case 'context':\n dataContext = parseUiContext(context, child);\n break;\n case 'id':\n componentStableId = parseStableId(context, child);\n break;\n case 'property':\n parseComponentProperty(context, child, properties);\n break;\n case 'icon':\n icon = child.content.substring('icon'.length).trim();\n break;\n case 'presentation':\n parsePresentationValue(context, child, presentationValues);\n break;\n case 'exposes':\n parseExposedValue(context, child, exposedValues);\n break;\n case 'outlet':\n outlets.push({ kind: 'ComponentOutletSyntax', name: child.content.substring('outlet'.length).trim(), directives: parseDirectives(context, child), location: locationOf(child) });\n break;\n case 'on':\n collectInputUses(context, child);\n break;\n case 'uses':\n collectInputUses(context, child);\n break;\n default:\n context.error(DiagnosticCodes.UnknownScreenDirective, `Unexpected '${child.content}' in component - expected context, id, property, icon, presentation, exposes, outlet, on or uses`, locationOf(child));\n context.skipBlock(child.indent);\n break;\n }\n }\n\n return { kind: 'ScreenComponentSyntax', component: match[1], name: match[2], stableId: componentStableId, context: dataContext, properties, exposes: exposedValues, presentation: presentationValues, icon, outlets, location: locationOf(line) };\n}\n\nfunction parseUiContext(context: ParserContext, line: SourceLine) {\n return parseUiBindingValue(context, line.content.substring('context'.length).trim(), line);\n}\n\nfunction parseComponentProperty(context: ParserContext, line: SourceLine, properties: ComponentPropertySyntax[]): void {\n const bound = componentPropertyBinding.exec(line.content);\n if (bound !== null) {\n properties.push({ kind: 'ComponentPropertySyntax', property: bound[1], binding: parseFromClause(context, bound[2], locationOf(line)), value: null, location: locationOf(line) });\n return;\n }\n const literal = componentPropertyLiteral.exec(line.content);\n if (literal !== null) {\n properties.push({ kind: 'ComponentPropertySyntax', property: literal[1], binding: null, value: parseMappingSource(literal[2], locationOf(line), context), location: locationOf(line) });\n return;\n }\n context.error(DiagnosticCodes.UnknownScreenDirective, `Invalid component property '${line.content}' - expected 'property <path> from <binding>' or 'property <path> = <literal|object|array|null>'`, locationOf(line));\n}\n\nfunction parseStableId(context: ParserContext, line: SourceLine): string | null {\n const match = stableId.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.UnknownScreenDirective, `Invalid component id '${line.content}' - expected 'id \"stable-id\"'`, locationOf(line));\n return null;\n }\n return operandText(match, 1);\n}\n\nfunction parseExposedValue(context: ParserContext, line: SourceLine, values: ComponentExposedValueSyntax[]): void {\n const match = exposes.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.UnknownScreenDirective, `Invalid exposed value '${line.content}' - expected 'exposes <name> from <binding>'`, locationOf(line));\n return;\n }\n values.push({ kind: 'ComponentExposedValueSyntax', name: match[1], binding: parseFromClause(context, match[2], locationOf(line)), location: locationOf(line) });\n}\n\nfunction parsePresentationValue(context: ParserContext, line: SourceLine, values: PresentationValueSyntax[]): void {\n const match = presentation.exec(line.content);\n if (match === null) {\n context.error(DiagnosticCodes.UnknownScreenDirective, `Invalid presentation value '${line.content}' - expected 'presentation <key> \"value\"'`, locationOf(line));\n return;\n }\n values.push({ kind: 'PresentationValueSyntax', name: match[1], value: operandText(match, 2), location: locationOf(line) });\n}\n\nexport function parseToolbar(context: ParserContext, line: SourceLine): ScreenToolbarSyntax {\n const name = line.content.substring('toolbar'.length).trim();\n const items: ToolbarItemSyntax[] = [];\n const buttons: ToolbarButtonSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (firstWord(child.content) === 'button') {\n const button = parseToolbarButton(context, child);\n if (button !== undefined) buttons.push(button);\n continue;\n }\n const item = parseToolbarItem(context, child);\n if (item !== undefined) items.push(item);\n }\n return { kind: 'ScreenToolbarSyntax', name, items, ...(buttons.length > 0 ? { buttons } : {}), location: locationOf(line) };\n}\n\nconst toolbarButtonExpected = 'button <id> title \"<text>\" [slice <Module>.<Feature>.<Slice>] [emphasis primary|secondary|quiet] [icon <name>]';\n\n// A button is one line; the C# compiler checks what it names (PLAY0761-PLAY0765), this one reads its grammar.\nfunction parseToolbarButton(context: ParserContext, line: SourceLine): ToolbarButtonSyntax | undefined {\n const head = toolbarButton.exec(line.content);\n if (head === null) {\n context.error(DiagnosticCodes.InvalidToolbarButton, `Invalid toolbar button '${line.content}' - expected ${toolbarButtonExpected}`, locationOf(line));\n context.skipBlock(line.indent);\n return undefined;\n }\n const id = head[1] !== undefined ? unescapeString(head[1]) : head[2];\n const rest = head[3] ?? '';\n let buttonTitle: string | undefined;\n let slice: string | undefined;\n let icon: string | undefined;\n let emphasis: ToolbarEmphasis | undefined;\n let valid = true;\n let position = 0;\n while (position < rest.length) {\n toolbarButtonPart.lastIndex = position;\n const part = toolbarButtonPart.exec(rest);\n if (part === null) {\n context.error(DiagnosticCodes.InvalidToolbarButton, `Invalid toolbar button '${line.content}' - unexpected '${rest.substring(position).trim()}'; expected ${toolbarButtonExpected}`, locationOf(line));\n valid = false;\n break;\n }\n position = part.index + part[0].length;\n const key = part[1];\n const quoted = part[2] !== undefined;\n const localized = part[3] !== undefined;\n const value = quoted ? unescapeString(part[2]) : localized ? part[3] : part[4];\n const repeated = key === 'title' ? buttonTitle !== undefined : key === 'slice' ? slice !== undefined : key === 'icon' ? icon !== undefined : emphasis !== undefined;\n if (repeated) {\n context.error(DiagnosticCodes.InvalidToolbarButton, `Toolbar button '${id}' states '${key}' more than once`, locationOf(line));\n continue;\n }\n if (key === 'title') {\n if (quoted || localized) buttonTitle = value;\n else {\n context.error(DiagnosticCodes.InvalidToolbarButton, `Invalid title '${value}' on toolbar button '${id}' - expected a quoted string or a $strings.<key> token`, locationOf(line));\n valid = false;\n }\n } else if (key === 'slice') {\n if (!quoted && !localized && toolbarSlicePath.test(value)) slice = value;\n else {\n context.error(DiagnosticCodes.InvalidToolbarButton, `Invalid slice '${value}' on toolbar button '${id}' - expected <Module>.<Feature>.<Slice>`, locationOf(line));\n valid = false;\n }\n } else if (key === 'emphasis') {\n if (!quoted && !localized && ['primary', 'secondary', 'quiet'].includes(value)) emphasis = value === 'primary' ? 'Primary' : value === 'secondary' ? 'Secondary' : 'Quiet';\n else {\n context.error(DiagnosticCodes.InvalidToolbarButton, `Invalid emphasis '${value}' on toolbar button '${id}' - expected primary, secondary or quiet`, locationOf(line));\n valid = false;\n }\n } else {\n icon = value;\n }\n }\n if (buttonTitle === undefined && valid) {\n context.error(DiagnosticCodes.InvalidToolbarButton, `Toolbar button '${id}' has no title - expected 'button ${id} title \"<text>\"'`, locationOf(line));\n }\n let authorize: AuthorizeSyntax | null = null;\n let buttonConfirm: string | undefined;\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (firstWord(child.content) === 'authorize' && authorize === null) {\n authorize = parseAuthorize(context, child);\n continue;\n }\n const confirmMatch = buttonConfirm === undefined ? confirmPattern.exec(child.content) : null;\n if (confirmMatch !== null) {\n buttonConfirm = operandText(confirmMatch, 1);\n continue;\n }\n context.error(DiagnosticCodes.InvalidToolbarButton, `Unexpected '${child.content}' under toolbar button '${id}' - a button takes one 'authorize' line, one 'confirm' line and nothing else`, locationOf(child));\n context.skipBlock(child.indent);\n }\n return {\n kind: 'ToolbarButtonSyntax', id, title: buttonTitle ?? '',\n ...(slice !== undefined ? { slice } : {}), ...(emphasis !== undefined ? { emphasis } : {}), ...(icon !== undefined ? { icon } : {}), ...(authorize !== null ? { authorize } : {}), ...(buttonConfirm !== undefined ? { confirm: buttonConfirm } : {}),\n location: locationOf(line),\n };\n}\n\nfunction parseToolbarItem(context: ParserContext, line: SourceLine): ToolbarItemSyntax | undefined {\n const parsed = parseSubjectClause(context, line, /^item\\s+\\S+\\s+action\\s/u.test(line.content), content => toolbarItem.test(content));\n const match = toolbarItem.exec(parsed.header);\n if (match === null) {\n context.error(DiagnosticCodes.UnknownScreenDirective, `Invalid toolbar item '${line.content}' - expected 'item <name> action <Command>', 'item <name> navigate to <Screen>', 'item <name> dialog <DialogTemplate>' or 'button <id> title \"<text>\" slice <Slice>'`, locationOf(line));\n context.skipBlock(line.indent);\n return undefined;\n }\n let itemLabel: string | null = parsed.label ?? null;\n let icon = null;\n let itemConfirm: string | undefined;\n const parameters: ScreenNavigationParameterSyntax[] = [];\n const presentationValues: PresentationValueSyntax[] = [];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n const labelMatch = label.exec(child.content);\n if (labelMatch !== null) {\n itemLabel = operandText(labelMatch, 1);\n continue;\n }\n const confirmMatch = confirmPattern.exec(child.content);\n if (confirmMatch !== null) {\n itemConfirm = operandText(confirmMatch, 1);\n continue;\n }\n const parameterMatch = parameter.exec(child.content);\n if (parameterMatch !== null) {\n parameters.push({ kind: 'ScreenNavigationParameterSyntax', name: parameterMatch[1], binding: parseFromClause(context, parameterMatch[2], locationOf(child)), location: locationOf(child) });\n continue;\n }\n if (firstWord(child.content) === 'icon') {\n icon = child.content.substring('icon'.length).trim();\n continue;\n }\n parsePresentationValue(context, child, presentationValues);\n }\n const syntaxKind: ToolbarItemKind = match[2] === 'navigate' ? 'Navigate' : match[2] === 'dialog' ? 'Dialog' : 'Action';\n return { kind: 'ToolbarItemSyntax', name: match[1], syntaxKind, target: match[3], label: itemLabel, icon, ...(parsed.subject === undefined ? {} : { subject: parsed.subject }), ...(itemConfirm !== undefined ? { confirm: itemConfirm } : {}), parameters, presentation: presentationValues, location: locationOf(line) };\n}\n\nfunction parseUiBindingValue(context: ParserContext, text: string, line: SourceLine) {\n return parseFromClause(context, text, locationOf(line));\n}\n\nfunction parseCode(context: ParserContext, line: SourceLine): ScreenCodeSyntax | undefined {\n const language = line.content.startsWith('```') ? line.content.substring(3) : line.content;\n if (!context.languages.has(language)) {\n context.error(DiagnosticCodes.ExpectedCodeFence, `Expected a registered language on the opening fence, not '${line.content}'`, locationOf(line));\n return undefined;\n }\n if (!line.content.startsWith('```')) {\n context.warning(DiagnosticCodes.LegacyInlineCodeFence, `'${language}' on its own line is deprecated - use '\\`\\`\\`${language}' instead`, locationOf(line));\n }\n const code = parseFencedText(context, language, line);\n return code === null ? undefined : {\n kind: 'ScreenCodeSyntax',\n code: { kind: 'CodeBlockSyntax', language, code, location: locationOf(line) },\n location: locationOf(line),\n };\n}\n"],"mappings":"kiCAkCA,MAAMA,EAAU,QAAQC,EAAkB,qCACpCC,EAASC,EAAQ,6BAA6B,EAC9CC,EAAOD,EAAQ,2FAA2F,EAC1GE,EAASF,EAAQ,yCAAyC,EAC1DG,EAAQH,EAAQ,aAAaH,EAAQ,EAAE,EACvCO,EAAgBJ,EAAQ,cAAcH,EAAQ,EAAE,EAChDQ,EAAWL,EAAQ,6DAA6D,EAChFM,EAAQN,EAAQ,aAAaH,EAAQ,EAAE,EACvCU,EAAgBP,EAAQ,6B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AY,aAAc7B,EAAoB,SAAUlD,EAAWH,CAAI,CAAE,CAC7T,CAEA,SAAS,oBAAoB,EAAwB,EAAc,EAAkB,CACjF,OAAO+B,EAAgB9B,EAASoB,EAAMlB,EAAWH,CAAI,CAAC,CAC1D,CAEA,SAAS,UAAU,EAAwB,EAAgD,CACvF,IAAMoF,EAAWpF,EAAK,QAAQ,WAAW,KAAK,EAAIA,EAAK,QAAQ,UAAU,CAAC,EAAIA,EAAK,QACnF,GAAI,CAACC,EAAQ,UAAU,IAAImF,CAAQ,EAAG,CAClCnF,EAAQ,MAAMC,EAAgB,kBAAmB,6DAA6DF,EAAK,QAAQ,GAAIG,EAAWH,CAAI,CAAC,EAC/I,MACJ,CACKA,EAAK,QAAQ,WAAW,KAAK,GAC9BC,EAAQ,QAAQC,EAAgB,sBAAuB,IAAIkF,EAAS,+CAA+CA,EAAS,WAAYjF,EAAWH,CAAI,CAAC,EAE5J,IAAMqF,EAAOC,EAAgBrF,EAASmF,EAAUpF,CAAI,EACpD,OAAOqF,IAAS,KAAO,IAAA,GAAY,CAC/B,KAAM,mBACN,KAAM,CAAE,KAAM,kBAAmB,WAAU,OAAM,SAAUlF,EAAWH,CAAI,CAAE,EAC5E,SAAUG,EAAWH,CAAI,CAC7B,CACJ"}
@@ -0,0 +1,2 @@
1
+ import"../_virtual/_virtual/_rolldown/runtime.js";import{resolveActionSubjectApplication as e}from"./Parsing/ActionSubjectResolution.js";function resolveActionSubjects(t){return e(t)}export{resolveActionSubjects};
2
+ //# sourceMappingURL=ScreenActionSubjects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScreenActionSubjects.js","names":["resolveActionSubjectApplication","application"],"sources":["../../../../../Compiler/ScreenActionSubjects.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 type { CompilationResult } from './ScreenplayCompiler';\nimport { resolveActionSubjectApplication } from './Parsing/ActionSubjectResolution';\nimport { ApplicationSyntax } from './Syntax/Structure';\n\n/** Resolves an immutable authored tree into its effective action-subject semantics without changing the authored syntax. */\nexport function resolveActionSubjects(application: ApplicationSyntax): CompilationResult<ApplicationSyntax> {\n return resolveActionSubjectApplication(application);\n}\n"],"mappings":"yIAQA,SAAgB,sBAAsB,EAAsE,CACxG,OAAOA,EAAgCC,CAAW,CACtD"}
@@ -0,0 +1,2 @@
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{InvalidSyntaxJson as e}from"./InvalidSyntaxJson.js";function validateActionSubject(t,n){if(![`ScreenActionSyntax`,`ScreenGuardedActionSyntax`,`ToolbarItemSyntax`].includes(t.kind))return;let r=t;if(!isValidActionSubject(r.subject))throw new e(`An action subject must be Item or Screen.`);if(hasInapplicableToolbarSubject(r))throw new e(`Only an action toolbar item can have a subject.`);r.kind===`ScreenActionSyntax`&&r.inputs!==void 0&&n(r.inputs,`InteractionArgumentSyntax`,`Action inputs must be a collection of arguments.`)}function isValidActionSubject(e){return e==null||e===`Item`||e===`Screen`}function hasInapplicableToolbarSubject(e){return e.kind===`ToolbarItemSyntax`&&e.subject!=null&&e.syntaxKind!==`Action`}export{validateActionSubject};
2
+ //# sourceMappingURL=ActionSubjectInvariants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionSubjectInvariants.js","names":["node","action","InvalidSyntaxJson","validateCollection","subject"],"sources":["../../../../../../Compiler/Syntax/ActionSubjectInvariants.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 { InvalidSyntaxJson } from './InvalidSyntaxJson';\nimport { ScreenActionSyntax, ScreenGuardedActionSyntax, ToolbarItemSyntax } from './Screens';\nimport { SyntaxNode } from './SyntaxNode';\n\nexport function validateActionSubject(node: SyntaxNode, validateCollection: (value: unknown, kind: string, message: string) => void): void {\n if (!['ScreenActionSyntax', 'ScreenGuardedActionSyntax', 'ToolbarItemSyntax'].includes(node.kind)) return;\n const action = node as ScreenActionSyntax | ScreenGuardedActionSyntax | ToolbarItemSyntax;\n if (!isValidActionSubject(action.subject)) throw new InvalidSyntaxJson('An action subject must be Item or Screen.');\n if (hasInapplicableToolbarSubject(action)) throw new InvalidSyntaxJson('Only an action toolbar item can have a subject.');\n if (action.kind === 'ScreenActionSyntax' && action.inputs !== undefined) validateCollection(action.inputs, 'InteractionArgumentSyntax', 'Action inputs must be a collection of arguments.');\n}\n\nfunction isValidActionSubject(subject: unknown): boolean {\n return subject == null || subject === 'Item' || subject === 'Screen';\n}\n\nfunction hasInapplicableToolbarSubject(action: ScreenActionSyntax | ScreenGuardedActionSyntax | ToolbarItemSyntax): boolean {\n return action.kind === 'ToolbarItemSyntax' && action.subject != null && action.syntaxKind !== 'Action';\n}\n"],"mappings":"gHAOA,SAAgB,sBAAsB,EAAkB,EAAmF,CACvI,GAAI,CAAC,CAAC,qBAAsB,4BAA6B,mBAAmB,CAAC,CAAC,SAASA,EAAK,IAAI,EAAG,OACnG,IAAMC,EAASD,EACf,GAAI,CAAC,qBAAqBC,EAAO,OAAO,EAAG,MAAM,IAAIC,EAAkB,2CAA2C,EAClH,GAAI,8BAA8BD,CAAM,EAAG,MAAM,IAAIC,EAAkB,iDAAiD,EACpHD,EAAO,OAAS,sBAAwBA,EAAO,SAAW,IAAA,IAAWE,EAAmBF,EAAO,OAAQ,4BAA6B,kDAAkD,CAC9L,CAEA,SAAS,qBAAqB,EAA2B,CACrD,OAAOG,GAAW,MAAQA,IAAY,QAAUA,IAAY,QAChE,CAEA,SAAS,8BAA8B,EAAqF,CACxH,OAAOH,EAAO,OAAS,qBAAuBA,EAAO,SAAW,MAAQA,EAAO,aAAe,QAClG"}