@cratis/screenplay-language 4.237.0 → 4.238.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.
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{locationOf as n}from"./SourceLine.js";import{firstWord as r}from"./LineText.js";import{combineAuthorize as i,parseAuthorize as a}from"./AuthorizeParser.js";import{parseDescription as o}from"./DescriptionParser.js";import{parsePurposeReference as s}from"./PurposeParser.js";import{parseDocumentation as c}from"./DocumentationParser.js";import{parseDependsOn as l}from"./DependsOnParser.js";import{parseFileImport as u}from"./FileImportParser.js";import{collectInputUses as d}from"./InputUses.js";import{misplacedReactionIdentity as f}from"./ReactionIdentityParser.js";import{parseExample as p}from"./SpecificationExampleParser.js";import{parseSlice as m}from"./SliceParser.js";const h=t(`^feature\\s+([A-Za-z_]\\w*)$`),g=/* @__PURE__ */ new Set([`on`,`uses`,`contribute`,`template`]),_=`description, documentation, depends on <Name>, authorize, import, feature, slice, contribute, example, 'on <trigger>' or 'uses <Behavior>'`;var FeatureBody=class{name;#e=[];#t=[];#n=[];#r=[];#i=[];#a=[];#o=null;#s=null;#c=null;constructor(e){this.name=e}tryParse(t,n){let h=r(n.content);switch(h){case`runs`:return f(t,n),!0;case`description`:return this.#o=o(t,n,this.#o,`Feature '${this.name}'`),!0;case`documentation`:return this.#s=c(t,n,this.#s,`Feature '${this.name}'`),!0;case`depends`:return l(t,n,this.#i,e.UnknownFeatureDirective),!0;case`purpose`:return s(t,n,this.#a),!0;case`authorize`:return this.#c=i(this.#c,a(t,n)),!0;case`import`:return u(t,n,this.#r),!0;case`feature`:return this.#e.push(parseFeature(t,n)),!0;case`example`:return this.#n.push(p(t,n)),!0;case`slice`:return this.#t.push(m(t,n)),!0;default:return g.has(h)?(d(t,n),!0):!1}}build(e,t=!1){return{kind:`FeatureSyntax`,name:this.name,description:this.#o,documentation:this.#s,authorize:this.#c,dependsOn:this.#i,purposes:this.#a,features:this.#e,slices:this.#t,examples:this.#n,fileImports:this.#r,isPlacement:t,location:e}}};function parseFeature(t,i){let a=h.exec(i.content)?.[1]??``;a===``&&t.error(e.InvalidFeatureDeclaration,`Invalid feature declaration '${i.content}' - expected 'feature <Name>'`,n(i));let o=new FeatureBody(a),s=t.scope;t.scope=[...s,a];for(let a=t.peekChild(i.indent);a!==void 0;a=t.peekChild(i.indent))t.reader.takeSignificant(),o.tryParse(t,a)||(t.error(e.UnknownFeatureDirective,`Unexpected '${r(a.content)}' in feature body - expected ${_}`,n(a)),t.skipBlock(a.indent));return t.scope=s,o.build(n(i))}export{FeatureBody,_ as featureBodyExpected,parseFeature};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{locationOf as n}from"./SourceLine.js";import{firstWord as r}from"./LineText.js";import{combineAuthorize as i,parseAuthorize as a}from"./AuthorizeParser.js";import{parseDescription as o}from"./DescriptionParser.js";import{parsePurposeReference as s}from"./PurposeParser.js";import{parseDocumentation as c}from"./DocumentationParser.js";import{parseDependsOn as l}from"./DependsOnParser.js";import{parseFileImport as u}from"./FileImportParser.js";import{collectInputUses as d}from"./InputUses.js";import{misplacedReactionIdentity as f}from"./ReactionIdentityParser.js";import{parseExample as p}from"./SpecificationExampleParser.js";import{parseToolbar as m}from"./ScreenParser.js";import{parseSlice as h}from"./SliceParser.js";const g=t(`^feature\\s+([A-Za-z_]\\w*)$`),_=/* @__PURE__ */ new Set([`on`,`uses`,`contribute`,`template`]),v=`description, documentation, depends on <Name>, authorize, import, feature, slice, contribute, toolbar, example, 'on <trigger>' or 'uses <Behavior>'`;var FeatureBody=class{name;#e=[];#t=[];#n=[];#r=[];#i=[];#a=[];#o=[];#s=null;#c=null;#l=null;constructor(e){this.name=e}tryParse(t,n){let g=r(n.content);switch(g){case`runs`:return f(t,n),!0;case`description`:return this.#s=o(t,n,this.#s,`Feature '${this.name}'`),!0;case`documentation`:return this.#c=c(t,n,this.#c,`Feature '${this.name}'`),!0;case`depends`:return l(t,n,this.#i,e.UnknownFeatureDirective),!0;case`purpose`:return s(t,n,this.#a),!0;case`authorize`:return this.#l=i(this.#l,a(t,n)),!0;case`import`:return u(t,n,this.#r),!0;case`toolbar`:return this.#o.push(m(t,n)),!0;case`feature`:return this.#e.push(parseFeature(t,n)),!0;case`example`:return this.#n.push(p(t,n)),!0;case`slice`:return this.#t.push(h(t,n)),!0;default:return _.has(g)?(d(t,n),!0):!1}}build(e,t=!1){return{kind:`FeatureSyntax`,name:this.name,description:this.#s,documentation:this.#c,authorize:this.#l,dependsOn:this.#i,purposes:this.#a,...this.#o.length>0?{toolbars:this.#o}:{},features:this.#e,slices:this.#t,examples:this.#n,fileImports:this.#r,isPlacement:t,location:e}}};function parseFeature(t,i){let a=g.exec(i.content)?.[1]??``;a===``&&t.error(e.InvalidFeatureDeclaration,`Invalid feature declaration '${i.content}' - expected 'feature <Name>'`,n(i));let o=new FeatureBody(a),s=t.scope;t.scope=[...s,a];for(let a=t.peekChild(i.indent);a!==void 0;a=t.peekChild(i.indent))t.reader.takeSignificant(),o.tryParse(t,a)||(t.error(e.UnknownFeatureDirective,`Unexpected '${r(a.content)}' in feature body - expected ${v}`,n(a)),t.skipBlock(a.indent));return t.scope=s,o.build(n(i))}export{FeatureBody,v as featureBodyExpected,parseFeature};
2
2
  //# sourceMappingURL=FeatureBody.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FeatureBody.js","names":["featurePattern","pattern","opaqueFeatureMembers","featureBodyExpected","name","keyword","firstWord","line","misplacedReactionIdentity","context","#description","parseDescription","#documentation","parseDocumentation","parseDependsOn","#dependsOn","DiagnosticCodes","parsePurposeReference","#purposes","#authorize","combineAuthorize","parseAuthorize","parseFileImport","#fileImports","#features","#examples","parseExample","#slices","parseSlice","collectInputUses","locationOf","body","previous","child"],"sources":["../../../../../../Compiler/Parsing/FeatureBody.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { AuthorizeSyntax } from '../Syntax/Authorization';\nimport { SpecificationExampleSyntax } from '../Syntax/Specifications';\nimport { DependsOnSyntax, FeatureSyntax, FileImportSyntax, SliceSyntax } from '../Syntax/Structure';\nimport { pattern } from '../Text/patterns';\nimport { combineAuthorize, parseAuthorize } from './AuthorizeParser';\nimport { parseDescription } from './DescriptionParser';\nimport { PurposeReferenceSyntax } from '../Syntax/Purposes';\nimport { parsePurposeReference } from './PurposeParser';\nimport { parseDocumentation } from './DocumentationParser';\nimport { parseDependsOn } from './DependsOnParser';\nimport { parseFileImport } from './FileImportParser';\nimport { collectInputUses } from './InputUses';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { misplacedReactionIdentity } from './ReactionIdentityParser';\nimport { parseExample } from './SpecificationExampleParser';\nimport { parseSlice } from './SliceParser';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst featurePattern = pattern('^feature\\\\s+([A-Za-z_]\\\\w*)$');\n\n// Feature members the C# compiler knows that this compiler does not model. They are skipped whole, not reported.\nconst opaqueFeatureMembers = new Set(['on', 'uses', 'contribute', 'template']);\n\n// What a feature body may hold, as it reads in a diagnostic.\nexport const featureBodyExpected = 'description, documentation, depends on <Name>, authorize, import, feature, slice, contribute, example, \\'on <trigger>\\' or \\'uses <Behavior>\\'';\n\n// Collects the body of a feature - written beneath a 'feature' header, or at the top level of a file imported\n// into the feature. The port of the C# FeatureBody.\nexport class FeatureBody {\n readonly #features: FeatureSyntax[] = [];\n readonly #slices: SliceSyntax[] = [];\n readonly #examples: SpecificationExampleSyntax[] = [];\n readonly #fileImports: FileImportSyntax[] = [];\n readonly #dependsOn: DependsOnSyntax[] = [];\n readonly #purposes: PurposeReferenceSyntax[] = [];\n #description: string | null = null;\n #documentation: string | null = null;\n #authorize: AuthorizeSyntax | null = null;\n\n constructor(readonly name: string) {}\n\n // Parses one already consumed line of the body; false when the line does not belong to a feature body,\n // and nothing was reported.\n tryParse(context: ParserContext, line: SourceLine): boolean {\n const keyword = firstWord(line.content);\n switch (keyword) {\n case 'runs':\n misplacedReactionIdentity(context, line);\n return true;\n case 'description':\n this.#description = parseDescription(context, line, this.#description, `Feature '${this.name}'`);\n return true;\n case 'documentation':\n this.#documentation = parseDocumentation(context, line, this.#documentation, `Feature '${this.name}'`);\n return true;\n case 'depends':\n parseDependsOn(context, line, this.#dependsOn, DiagnosticCodes.UnknownFeatureDirective);\n return true;\n case 'purpose':\n parsePurposeReference(context, line, this.#purposes);\n return true;\n case 'authorize':\n this.#authorize = combineAuthorize(this.#authorize, parseAuthorize(context, line));\n return true;\n case 'import':\n parseFileImport(context, line, this.#fileImports);\n return true;\n case 'feature':\n this.#features.push(parseFeature(context, line));\n return true;\n case 'example':\n this.#examples.push(parseExample(context, line));\n return true;\n case 'slice':\n this.#slices.push(parseSlice(context, line));\n return true;\n default:\n if (opaqueFeatureMembers.has(keyword)) {\n collectInputUses(context, line);\n return true;\n }\n return false;\n }\n }\n\n // Builds the feature, located at its header or, when it only places an imported file, at that file.\n build(location: SourceLocation, isPlacement = false): FeatureSyntax {\n return {\n kind: 'FeatureSyntax',\n name: this.name,\n description: this.#description,\n documentation: this.#documentation,\n authorize: this.#authorize,\n dependsOn: this.#dependsOn,\n purposes: this.#purposes,\n features: this.#features,\n slices: this.#slices,\n examples: this.#examples,\n fileImports: this.#fileImports,\n isPlacement,\n location,\n };\n }\n}\n\n// Parses a feature from its already consumed header line.\nexport function parseFeature(context: ParserContext, line: SourceLine): FeatureSyntax {\n const name = featurePattern.exec(line.content)?.[1] ?? '';\n if (name === '') {\n context.error(DiagnosticCodes.InvalidFeatureDeclaration, `Invalid feature declaration '${line.content}' - expected 'feature <Name>'`, locationOf(line));\n }\n const body = new FeatureBody(name);\n const previous = context.scope;\n context.scope = [...previous, name];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (!body.tryParse(context, child)) {\n context.error(DiagnosticCodes.UnknownFeatureDirective, `Unexpected '${firstWord(child.content)}' in feature body - expected ${featureBodyExpected}`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n context.scope = previous;\n return body.build(locationOf(line));\n}\n"],"mappings":"k1BAwBA,MAAMA,EAAiBC,EAAQ,8BAA8B,EAGvDC,kBAAuB,IAAI,IAAI,CAAC,KAAM,OAAQ,aAAc,UAAU,CAAC,EAGhEC,EAAsB,6IAInC,IAAa,YAAb,KAAyB,CAWA,KAVrB,GAAsC,CAAC,EACvC,GAAkC,CAAC,EACnC,GAAmD,CAAC,EACpD,GAA4C,CAAC,EAC7C,GAAyC,CAAC,EAC1C,GAA+C,CAAC,EAChD,GAA8B,KAC9B,GAAgC,KAChC,GAAqC,KAErC,YAAY,EAAuB,CAAd,KAAA,KAAAC,CAAe,CAIpC,SAAS,EAAwB,EAA2B,CACxD,IAAMC,EAAUC,EAAUC,EAAK,OAAO,EACtC,OAAQF,EAAR,CACI,IAAK,OAED,OADAG,EAA0BC,EAASF,CAAI,EAChC,GACX,IAAK,cAED,MADA,MAAKG,GAAeC,EAAiBF,EAASF,EAAM,KAAKG,GAAc,YAAY,KAAK,KAAK,EAAE,EACxF,GACX,IAAK,gBAED,MADA,MAAKE,GAAiBC,EAAmBJ,EAASF,EAAM,KAAKK,GAAgB,YAAY,KAAK,KAAK,EAAE,EAC9F,GACX,IAAK,UAED,OADAE,EAAeL,EAASF,EAAM,KAAKQ,GAAYC,EAAgB,uBAAuB,EAC/E,GACX,IAAK,UAED,OADAC,EAAsBR,EAASF,EAAM,KAAKW,EAAS,EAC5C,GACX,IAAK,YAED,MADA,MAAKC,GAAaC,EAAiB,KAAKD,GAAYE,EAAeZ,EAAS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OAAO,EAAE,+BAA+B9B,IAAuB2B,EAAWG,CAAK,CAAC,EACtKxB,EAAQ,UAAUwB,EAAM,MAAM,GAItC,MADA,GAAQ,MAAQD,EACTD,EAAK,MAAMD,EAAWvB,CAAI,CAAC,CACtC"}
1
+ {"version":3,"file":"FeatureBody.js","names":["featurePattern","pattern","opaqueFeatureMembers","featureBodyExpected","name","keyword","firstWord","line","misplacedReactionIdentity","context","#description","parseDescription","#documentation","parseDocumentation","parseDependsOn","#dependsOn","DiagnosticCodes","parsePurposeReference","#purposes","#authorize","combineAuthorize","parseAuthorize","parseFileImport","#fileImports","#toolbars","parseToolbar","#features","#examples","parseExample","#slices","parseSlice","collectInputUses","locationOf","body","previous","child"],"sources":["../../../../../../Compiler/Parsing/FeatureBody.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { AuthorizeSyntax } from '../Syntax/Authorization';\nimport { SpecificationExampleSyntax } from '../Syntax/Specifications';\nimport { DependsOnSyntax, FeatureSyntax, FileImportSyntax, SliceSyntax } from '../Syntax/Structure';\nimport { ScreenToolbarSyntax } from '../Syntax/Screens';\nimport { pattern } from '../Text/patterns';\nimport { combineAuthorize, parseAuthorize } from './AuthorizeParser';\nimport { parseDescription } from './DescriptionParser';\nimport { PurposeReferenceSyntax } from '../Syntax/Purposes';\nimport { parsePurposeReference } from './PurposeParser';\nimport { parseDocumentation } from './DocumentationParser';\nimport { parseDependsOn } from './DependsOnParser';\nimport { parseFileImport } from './FileImportParser';\nimport { collectInputUses } from './InputUses';\nimport { firstWord } from './LineText';\nimport { ParserContext } from './ParserContext';\nimport { misplacedReactionIdentity } from './ReactionIdentityParser';\nimport { parseExample } from './SpecificationExampleParser';\nimport { parseToolbar } from './ScreenParser';\nimport { parseSlice } from './SliceParser';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst featurePattern = pattern('^feature\\\\s+([A-Za-z_]\\\\w*)$');\n\n// Feature members the C# compiler knows that this compiler does not model. They are skipped whole, not reported.\nconst opaqueFeatureMembers = new Set(['on', 'uses', 'contribute', 'template']);\n\n// What a feature body may hold, as it reads in a diagnostic.\nexport const featureBodyExpected = 'description, documentation, depends on <Name>, authorize, import, feature, slice, contribute, toolbar, example, \\'on <trigger>\\' or \\'uses <Behavior>\\'';\n\n// Collects the body of a feature - written beneath a 'feature' header, or at the top level of a file imported\n// into the feature. The port of the C# FeatureBody.\nexport class FeatureBody {\n readonly #features: FeatureSyntax[] = [];\n readonly #slices: SliceSyntax[] = [];\n readonly #examples: SpecificationExampleSyntax[] = [];\n readonly #fileImports: FileImportSyntax[] = [];\n readonly #dependsOn: DependsOnSyntax[] = [];\n readonly #purposes: PurposeReferenceSyntax[] = [];\n readonly #toolbars: ScreenToolbarSyntax[] = [];\n #description: string | null = null;\n #documentation: string | null = null;\n #authorize: AuthorizeSyntax | null = null;\n\n constructor(readonly name: string) {}\n\n // Parses one already consumed line of the body; false when the line does not belong to a feature body,\n // and nothing was reported.\n tryParse(context: ParserContext, line: SourceLine): boolean {\n const keyword = firstWord(line.content);\n switch (keyword) {\n case 'runs':\n misplacedReactionIdentity(context, line);\n return true;\n case 'description':\n this.#description = parseDescription(context, line, this.#description, `Feature '${this.name}'`);\n return true;\n case 'documentation':\n this.#documentation = parseDocumentation(context, line, this.#documentation, `Feature '${this.name}'`);\n return true;\n case 'depends':\n parseDependsOn(context, line, this.#dependsOn, DiagnosticCodes.UnknownFeatureDirective);\n return true;\n case 'purpose':\n parsePurposeReference(context, line, this.#purposes);\n return true;\n case 'authorize':\n this.#authorize = combineAuthorize(this.#authorize, parseAuthorize(context, line));\n return true;\n case 'import':\n parseFileImport(context, line, this.#fileImports);\n return true;\n case 'toolbar':\n this.#toolbars.push(parseToolbar(context, line));\n return true;\n case 'feature':\n this.#features.push(parseFeature(context, line));\n return true;\n case 'example':\n this.#examples.push(parseExample(context, line));\n return true;\n case 'slice':\n this.#slices.push(parseSlice(context, line));\n return true;\n default:\n if (opaqueFeatureMembers.has(keyword)) {\n collectInputUses(context, line);\n return true;\n }\n return false;\n }\n }\n\n // Builds the feature, located at its header or, when it only places an imported file, at that file.\n build(location: SourceLocation, isPlacement = false): FeatureSyntax {\n return {\n kind: 'FeatureSyntax',\n name: this.name,\n description: this.#description,\n documentation: this.#documentation,\n authorize: this.#authorize,\n dependsOn: this.#dependsOn,\n purposes: this.#purposes,\n ...(this.#toolbars.length > 0 ? { toolbars: this.#toolbars } : {}),\n features: this.#features,\n slices: this.#slices,\n examples: this.#examples,\n fileImports: this.#fileImports,\n isPlacement,\n location,\n };\n }\n}\n\n// Parses a feature from its already consumed header line.\nexport function parseFeature(context: ParserContext, line: SourceLine): FeatureSyntax {\n const name = featurePattern.exec(line.content)?.[1] ?? '';\n if (name === '') {\n context.error(DiagnosticCodes.InvalidFeatureDeclaration, `Invalid feature declaration '${line.content}' - expected 'feature <Name>'`, locationOf(line));\n }\n const body = new FeatureBody(name);\n const previous = context.scope;\n context.scope = [...previous, name];\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (!body.tryParse(context, child)) {\n context.error(DiagnosticCodes.UnknownFeatureDirective, `Unexpected '${firstWord(child.content)}' in feature body - expected ${featureBodyExpected}`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n context.scope = previous;\n return body.build(locationOf(line));\n}\n"],"mappings":"m4BA0BA,MAAMA,EAAiBC,EAAQ,8BAA8B,EAGvDC,kBAAuB,IAAI,IAAI,CAAC,KAAM,OAAQ,aAAc,UAAU,CAAC,EAGhEC,EAAsB,sJAInC,IAAa,YAAb,KAAyB,CAYA,KAXrB,GAAsC,CAAC,EACvC,GAAkC,CAAC,EACnC,GAAmD,CAAC,EACpD,GAA4C,CAAC,EAC7C,GAAyC,CAAC,EAC1C,GAA+C,CAAC,EAChD,GAA4C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AW,KAAKO,GAChB,UAAW,KAAKJ,GAChB,SAAU,KAAKG,GACf,GAAI,KAAKM,GAAU,OAAS,EAAI,CAAE,SAAU,KAAKA,EAAU,EAAI,CAAC,EAChE,SAAU,KAAKE,GACf,OAAQ,KAAKG,GACb,SAAU,KAAKF,GACf,YAAa,KAAKJ,GAClB,cACA,UACJ,CACJ,CACJ,EAGA,SAAgB,aAAa,EAAwB,EAAiC,CAClF,IAAMnB,EAAOJ,EAAe,KAAKO,EAAK,OAAO,CAAC,GAAG,IAAM,GACnDH,IAAS,IACTK,EAAQ,MAAMO,EAAgB,0BAA2B,gCAAgCT,EAAK,QAAQ,+BAAgCyB,EAAWzB,CAAI,CAAC,EAE1J,IAAM0B,EAAO,IAAI,YAAY7B,CAAI,EAC3B8B,EAAWzB,EAAQ,MACzB,EAAQ,MAAQ,CAAC,GAAGyB,EAAU9B,CAAI,EAClC,IAAK,IAAI+B,EAAQ1B,EAAQ,UAAUF,EAAK,MAAM,EAAG4B,IAAU,IAAA,GAAW,EAAQ1B,EAAQ,UAAUF,EAAK,MAAM,EACvGE,EAAQ,OAAO,gBAAgB,EAC1BwB,EAAK,SAASxB,EAAS0B,CAAK,IAC7B1B,EAAQ,MAAMO,EAAgB,wBAAyB,eAAeV,EAAU6B,EAAM,OAAO,EAAE,+BAA+BhC,IAAuB6B,EAAWG,CAAK,CAAC,EACtK1B,EAAQ,UAAU0B,EAAM,MAAM,GAItC,MADA,GAAQ,MAAQD,EACTD,EAAK,MAAMD,EAAWzB,CAAI,CAAC,CACtC"}
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{locationOf as n}from"./SourceLine.js";import{firstWord as r}from"./LineText.js";import{combineAuthorize as i,parseAuthorize as a}from"./AuthorizeParser.js";import{parseDescription as o}from"./DescriptionParser.js";import{parsePurposeReference as s}from"./PurposeParser.js";import{parseDocumentation as c}from"./DocumentationParser.js";import{parseDependsOn as l}from"./DependsOnParser.js";import{parseFileImport as u}from"./FileImportParser.js";import{collectInputUses as d}from"./InputUses.js";import{misplacedReactionIdentity as f}from"./ReactionIdentityParser.js";import{parseExample as p}from"./SpecificationExampleParser.js";import{parseFeature as m}from"./FeatureBody.js";const h=t(`^module\\s+([A-Za-z_]\\w*)$`),g=/* @__PURE__ */ new Set([`on`,`uses`,`screen`,`dialog`,`form`,`contribute`,`navigation`,`template`]),_=`description, documentation, depends on <Name>, authorize, import, screen template, dialog template, form, contribute, navigation, feature, example, 'on <trigger>' or 'uses <Behavior>'`;var ModuleBody=class{name;#e=[];#t=[];#n=[];#r=[];#i=[];#a=null;#o=null;#s=null;constructor(e){this.name=e}tryParse(t,n){let h=r(n.content);switch(h){case`runs`:return f(t,n),!0;case`description`:return this.#a=o(t,n,this.#a,`Module '${this.name}'`),!0;case`documentation`:return this.#o=c(t,n,this.#o,`Module '${this.name}'`),!0;case`depends`:return l(t,n,this.#r,e.UnknownModuleDirective),!0;case`purpose`:return s(t,n,this.#i),!0;case`authorize`:return this.#s=i(this.#s,a(t,n)),!0;case`import`:return u(t,n,this.#n),!0;case`example`:return this.#t.push(p(t,n)),!0;case`feature`:return this.#e.push(m(t,n)),!0;default:return g.has(h)?(d(t,n),!0):!1}}parseChildren(t,i){for(let a=t.peekChild(i.indent);a!==void 0;a=t.peekChild(i.indent))t.reader.takeSignificant(),this.tryParse(t,a)||(t.error(e.UnknownModuleDirective,`Unexpected '${r(a.content)}' in module body - expected ${_}`,n(a)),t.skipBlock(a.indent))}build(e,t=!1){return{kind:`ModuleSyntax`,name:this.name,description:this.#a,documentation:this.#o,authorize:this.#s,dependsOn:this.#r,purposes:this.#i,features:this.#e,examples:this.#t,fileImports:this.#n,isPlacement:t,location:e}}};function parseModule(t,r){let i=h.exec(r.content)?.[1]??``;i===``&&t.error(e.InvalidModuleDeclaration,`Invalid module declaration '${r.content}' - expected 'module <Name>'`,n(r));let a=new ModuleBody(i),o=t.scope;return t.scope=[i],a.parseChildren(t,r),t.scope=o,a.build(n(r))}export{ModuleBody,_ as moduleBodyExpected,h as modulePattern,parseModule};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{locationOf as n}from"./SourceLine.js";import{firstWord as r}from"./LineText.js";import{combineAuthorize as i,parseAuthorize as a}from"./AuthorizeParser.js";import{parseDescription as o}from"./DescriptionParser.js";import{parsePurposeReference as s}from"./PurposeParser.js";import{parseDocumentation as c}from"./DocumentationParser.js";import{parseDependsOn as l}from"./DependsOnParser.js";import{parseFileImport as u}from"./FileImportParser.js";import{collectInputUses as d}from"./InputUses.js";import{misplacedReactionIdentity as f}from"./ReactionIdentityParser.js";import{parseExample as p}from"./SpecificationExampleParser.js";import{parseToolbar as m}from"./ScreenParser.js";import{parseFeature as h}from"./FeatureBody.js";const g=t(`^module\\s+([A-Za-z_]\\w*)$`),_=/* @__PURE__ */ new Set([`on`,`uses`,`screen`,`dialog`,`form`,`contribute`,`navigation`,`template`]),v=`description, documentation, depends on <Name>, authorize, import, screen template, dialog template, form, contribute, toolbar, navigation, feature, example, 'on <trigger>' or 'uses <Behavior>'`;var ModuleBody=class{name;#e=[];#t=[];#n=[];#r=[];#i=[];#a=[];#o=null;#s=null;#c=null;constructor(e){this.name=e}tryParse(t,n){let g=r(n.content);switch(g){case`runs`:return f(t,n),!0;case`description`:return this.#o=o(t,n,this.#o,`Module '${this.name}'`),!0;case`documentation`:return this.#s=c(t,n,this.#s,`Module '${this.name}'`),!0;case`depends`:return l(t,n,this.#r,e.UnknownModuleDirective),!0;case`purpose`:return s(t,n,this.#i),!0;case`authorize`:return this.#c=i(this.#c,a(t,n)),!0;case`import`:return u(t,n,this.#n),!0;case`example`:return this.#t.push(p(t,n)),!0;case`toolbar`:return this.#a.push(m(t,n)),!0;case`feature`:return this.#e.push(h(t,n)),!0;default:return _.has(g)?(d(t,n),!0):!1}}parseChildren(t,i){for(let a=t.peekChild(i.indent);a!==void 0;a=t.peekChild(i.indent))t.reader.takeSignificant(),this.tryParse(t,a)||(t.error(e.UnknownModuleDirective,`Unexpected '${r(a.content)}' in module body - expected ${v}`,n(a)),t.skipBlock(a.indent))}build(e,t=!1){return{kind:`ModuleSyntax`,name:this.name,description:this.#o,documentation:this.#s,authorize:this.#c,dependsOn:this.#r,purposes:this.#i,...this.#a.length>0?{toolbars:this.#a}:{},features:this.#e,examples:this.#t,fileImports:this.#n,isPlacement:t,location:e}}};function parseModule(t,r){let i=g.exec(r.content)?.[1]??``;i===``&&t.error(e.InvalidModuleDeclaration,`Invalid module declaration '${r.content}' - expected 'module <Name>'`,n(r));let a=new ModuleBody(i),o=t.scope;return t.scope=[i],a.parseChildren(t,r),t.scope=o,a.build(n(r))}export{ModuleBody,v as moduleBodyExpected,g as modulePattern,parseModule};
2
2
  //# sourceMappingURL=ModuleBody.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ModuleBody.js","names":["modulePattern","pattern","opaqueModuleMembers","moduleBodyExpected","name","keyword","firstWord","line","misplacedReactionIdentity","context","#description","parseDescription","#documentation","parseDocumentation","parseDependsOn","#dependsOn","DiagnosticCodes","parsePurposeReference","#purposes","#authorize","combineAuthorize","parseAuthorize","parseFileImport","#fileImports","#examples","parseExample","#features","parseFeature","collectInputUses","child","locationOf","body","previous"],"sources":["../../../../../../Compiler/Parsing/ModuleBody.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { AuthorizeSyntax } from '../Syntax/Authorization';\nimport { SpecificationExampleSyntax } from '../Syntax/Specifications';\nimport { DependsOnSyntax, FeatureSyntax, FileImportSyntax, ModuleSyntax } from '../Syntax/Structure';\nimport { pattern } from '../Text/patterns';\nimport { combineAuthorize, parseAuthorize } from './AuthorizeParser';\nimport { parseDescription } from './DescriptionParser';\nimport { PurposeReferenceSyntax } from '../Syntax/Purposes';\nimport { parsePurposeReference } from './PurposeParser';\nimport { parseDocumentation } from './DocumentationParser';\nimport { parseDependsOn } from './DependsOnParser';\nimport { parseFeature } from './FeatureBody';\nimport { parseFileImport } from './FileImportParser';\nimport { collectInputUses } from './InputUses';\nimport { firstWord } from './LineText';\nimport { parseExample } from './SpecificationExampleParser';\nimport { ParserContext } from './ParserContext';\nimport { misplacedReactionIdentity } from './ReactionIdentityParser';\nimport { locationOf, SourceLine } from './SourceLine';\n\nexport const modulePattern = pattern('^module\\\\s+([A-Za-z_]\\\\w*)$');\n\n// Module members the C# compiler knows that this compiler does not model. They are skipped whole, not reported.\nconst opaqueModuleMembers = new Set(['on', 'uses', 'screen', 'dialog', 'form', 'contribute', 'navigation', 'template']);\n\n// What a module body may hold, as it reads in a diagnostic.\nexport const moduleBodyExpected = 'description, documentation, depends on <Name>, authorize, import, screen template, dialog template, form, contribute, navigation, feature, example, \\'on <trigger>\\' or \\'uses <Behavior>\\'';\n\n// Collects the body of a module - written beneath a 'module' header, or at the top level of a file imported\n// into the module. The port of the C# ModuleBody.\nexport class ModuleBody {\n readonly #features: FeatureSyntax[] = [];\n readonly #examples: SpecificationExampleSyntax[] = [];\n readonly #fileImports: FileImportSyntax[] = [];\n readonly #dependsOn: DependsOnSyntax[] = [];\n readonly #purposes: PurposeReferenceSyntax[] = [];\n #description: string | null = null;\n #documentation: string | null = null;\n #authorize: AuthorizeSyntax | null = null;\n\n constructor(readonly name: string) {}\n\n // Parses one already consumed line of the body; false when the line does not belong to a module body,\n // and nothing was reported.\n tryParse(context: ParserContext, line: SourceLine): boolean {\n const keyword = firstWord(line.content);\n switch (keyword) {\n case 'runs':\n misplacedReactionIdentity(context, line);\n return true;\n case 'description':\n this.#description = parseDescription(context, line, this.#description, `Module '${this.name}'`);\n return true;\n case 'documentation':\n this.#documentation = parseDocumentation(context, line, this.#documentation, `Module '${this.name}'`);\n return true;\n case 'depends':\n parseDependsOn(context, line, this.#dependsOn, DiagnosticCodes.UnknownModuleDirective);\n return true;\n case 'purpose':\n parsePurposeReference(context, line, this.#purposes);\n return true;\n case 'authorize':\n this.#authorize = combineAuthorize(this.#authorize, parseAuthorize(context, line));\n return true;\n case 'import':\n parseFileImport(context, line, this.#fileImports);\n return true;\n case 'example':\n this.#examples.push(parseExample(context, line));\n return true;\n case 'feature':\n this.#features.push(parseFeature(context, line));\n return true;\n default:\n if (opaqueModuleMembers.has(keyword)) {\n collectInputUses(context, line);\n return true;\n }\n return false;\n }\n }\n\n // Parses the children of a header line into this body, reporting what does not belong in a module.\n parseChildren(context: ParserContext, line: SourceLine): void {\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (!this.tryParse(context, child)) {\n context.error(DiagnosticCodes.UnknownModuleDirective, `Unexpected '${firstWord(child.content)}' in module body - expected ${moduleBodyExpected}`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n }\n\n // Builds the module, located at its header or, when it only places an imported file, at that file.\n build(location: SourceLocation, isPlacement = false): ModuleSyntax {\n return {\n kind: 'ModuleSyntax',\n name: this.name,\n description: this.#description,\n documentation: this.#documentation,\n authorize: this.#authorize,\n dependsOn: this.#dependsOn,\n purposes: this.#purposes,\n features: this.#features,\n examples: this.#examples,\n fileImports: this.#fileImports,\n isPlacement,\n location,\n };\n }\n}\n\n// Parses a module from its already consumed header line.\nexport function parseModule(context: ParserContext, line: SourceLine): ModuleSyntax {\n const name = modulePattern.exec(line.content)?.[1] ?? '';\n if (name === '') {\n context.error(DiagnosticCodes.InvalidModuleDeclaration, `Invalid module declaration '${line.content}' - expected 'module <Name>'`, locationOf(line));\n }\n const body = new ModuleBody(name);\n const previous = context.scope;\n context.scope = [name];\n body.parseChildren(context, line);\n context.scope = previous;\n return body.build(locationOf(line));\n}\n"],"mappings":"o1BAwBA,MAAaA,E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EAAwB,EAAwB,CAC1D,IAAK,IAAIsB,EAAQpB,EAAQ,UAAUF,EAAK,MAAM,EAAGsB,IAAU,IAAA,GAAW,EAAQpB,EAAQ,UAAUF,EAAK,MAAM,EACvGE,EAAQ,OAAO,gBAAgB,EAC1B,KAAK,SAASA,EAASoB,CAAK,IAC7BpB,EAAQ,MAAMO,EAAgB,uBAAwB,eAAeV,EAAUuB,EAAM,OAAO,EAAE,8BAA8B1B,IAAsB2B,EAAWD,CAAK,CAAC,EACnKpB,EAAQ,UAAUoB,EAAM,MAAM,EAG1C,CAGA,MAAM,EAA0B,EAAc,GAAqB,CAC/D,MAAO,CACH,KAAM,eACN,KAAM,KAAK,KACX,YAAa,KAAKnB,GAClB,cAAe,KAAKE,GACpB,UAAW,KAAKO,GAChB,UAAW,KAAKJ,GAChB,SAAU,KAAKG,GACf,SAAU,KAAKQ,GACf,SAAU,KAAKF,GACf,YAAa,KAAKD,GAClB,cACA,UACJ,CACJ,CACJ,EAGA,SAAgB,YAAY,EAAwB,EAAgC,CAChF,IAAMnB,EAAOJ,EAAc,KAAKO,EAAK,OAAO,CAAC,GAAG,IAAM,GAClDH,IAAS,IACTK,EAAQ,MAAMO,EAAgB,yBAA0B,+BAA+BT,EAAK,QAAQ,8BAA+BuB,EAAWvB,CAAI,CAAC,EAEvJ,IAAMwB,EAAO,IAAI,WAAW3B,CAAI,EAC1B4B,EAAWvB,EAAQ,MAIzB,MAHA,GAAQ,MAAQ,CAACL,CAAI,EACrB2B,EAAK,cAActB,EAASF,CAAI,EAChC,EAAQ,MAAQyB,EACTD,EAAK,MAAMD,EAAWvB,CAAI,CAAC,CACtC"}
1
+ {"version":3,"file":"ModuleBody.js","names":["modulePattern","pattern","opaqueModuleMembers","moduleBodyExpected","name","keyword","firstWord","line","misplacedReactionIdentity","context","#description","parseDescription","#documentation","parseDocumentation","parseDependsOn","#dependsOn","DiagnosticCodes","parsePurposeReference","#purposes","#authorize","combineAuthorize","parseAuthorize","parseFileImport","#fileImports","#examples","parseExample","#toolbars","parseToolbar","#features","parseFeature","collectInputUses","child","locationOf","body","previous"],"sources":["../../../../../../Compiler/Parsing/ModuleBody.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { AuthorizeSyntax } from '../Syntax/Authorization';\nimport { SpecificationExampleSyntax } from '../Syntax/Specifications';\nimport { DependsOnSyntax, FeatureSyntax, FileImportSyntax, ModuleSyntax } from '../Syntax/Structure';\nimport { ScreenToolbarSyntax } from '../Syntax/Screens';\nimport { pattern } from '../Text/patterns';\nimport { combineAuthorize, parseAuthorize } from './AuthorizeParser';\nimport { parseDescription } from './DescriptionParser';\nimport { PurposeReferenceSyntax } from '../Syntax/Purposes';\nimport { parsePurposeReference } from './PurposeParser';\nimport { parseDocumentation } from './DocumentationParser';\nimport { parseDependsOn } from './DependsOnParser';\nimport { parseFeature } from './FeatureBody';\nimport { parseFileImport } from './FileImportParser';\nimport { parseToolbar } from './ScreenParser';\nimport { collectInputUses } from './InputUses';\nimport { firstWord } from './LineText';\nimport { parseExample } from './SpecificationExampleParser';\nimport { ParserContext } from './ParserContext';\nimport { misplacedReactionIdentity } from './ReactionIdentityParser';\nimport { locationOf, SourceLine } from './SourceLine';\n\nexport const modulePattern = pattern('^module\\\\s+([A-Za-z_]\\\\w*)$');\n\n// Module members the C# compiler knows that this compiler does not model. They are skipped whole, not reported.\nconst opaqueModuleMembers = new Set(['on', 'uses', 'screen', 'dialog', 'form', 'contribute', 'navigation', 'template']);\n\n// What a module body may hold, as it reads in a diagnostic.\nexport const moduleBodyExpected = 'description, documentation, depends on <Name>, authorize, import, screen template, dialog template, form, contribute, toolbar, navigation, feature, example, \\'on <trigger>\\' or \\'uses <Behavior>\\'';\n\n// Collects the body of a module - written beneath a 'module' header, or at the top level of a file imported\n// into the module. The port of the C# ModuleBody.\nexport class ModuleBody {\n readonly #features: FeatureSyntax[] = [];\n readonly #examples: SpecificationExampleSyntax[] = [];\n readonly #fileImports: FileImportSyntax[] = [];\n readonly #dependsOn: DependsOnSyntax[] = [];\n readonly #purposes: PurposeReferenceSyntax[] = [];\n readonly #toolbars: ScreenToolbarSyntax[] = [];\n #description: string | null = null;\n #documentation: string | null = null;\n #authorize: AuthorizeSyntax | null = null;\n\n constructor(readonly name: string) {}\n\n // Parses one already consumed line of the body; false when the line does not belong to a module body,\n // and nothing was reported.\n tryParse(context: ParserContext, line: SourceLine): boolean {\n const keyword = firstWord(line.content);\n switch (keyword) {\n case 'runs':\n misplacedReactionIdentity(context, line);\n return true;\n case 'description':\n this.#description = parseDescription(context, line, this.#description, `Module '${this.name}'`);\n return true;\n case 'documentation':\n this.#documentation = parseDocumentation(context, line, this.#documentation, `Module '${this.name}'`);\n return true;\n case 'depends':\n parseDependsOn(context, line, this.#dependsOn, DiagnosticCodes.UnknownModuleDirective);\n return true;\n case 'purpose':\n parsePurposeReference(context, line, this.#purposes);\n return true;\n case 'authorize':\n this.#authorize = combineAuthorize(this.#authorize, parseAuthorize(context, line));\n return true;\n case 'import':\n parseFileImport(context, line, this.#fileImports);\n return true;\n case 'example':\n this.#examples.push(parseExample(context, line));\n return true;\n case 'toolbar':\n this.#toolbars.push(parseToolbar(context, line));\n return true;\n case 'feature':\n this.#features.push(parseFeature(context, line));\n return true;\n default:\n if (opaqueModuleMembers.has(keyword)) {\n collectInputUses(context, line);\n return true;\n }\n return false;\n }\n }\n\n // Parses the children of a header line into this body, reporting what does not belong in a module.\n parseChildren(context: ParserContext, line: SourceLine): void {\n for (let child = context.peekChild(line.indent); child !== undefined; child = context.peekChild(line.indent)) {\n context.reader.takeSignificant();\n if (!this.tryParse(context, child)) {\n context.error(DiagnosticCodes.UnknownModuleDirective, `Unexpected '${firstWord(child.content)}' in module body - expected ${moduleBodyExpected}`, locationOf(child));\n context.skipBlock(child.indent);\n }\n }\n }\n\n // Builds the module, located at its header or, when it only places an imported file, at that file.\n build(location: SourceLocation, isPlacement = false): ModuleSyntax {\n return {\n kind: 'ModuleSyntax',\n name: this.name,\n description: this.#description,\n documentation: this.#documentation,\n authorize: this.#authorize,\n dependsOn: this.#dependsOn,\n purposes: this.#purposes,\n ...(this.#toolbars.length > 0 ? { toolbars: this.#toolbars } : {}),\n features: this.#features,\n examples: this.#examples,\n fileImports: this.#fileImports,\n isPlacement,\n location,\n };\n }\n}\n\n// Parses a module from its already consumed header line.\nexport function parseModule(context: ParserContext, line: SourceLine): ModuleSyntax {\n const name = modulePattern.exec(line.content)?.[1] ?? '';\n if (name === '') {\n context.error(DiagnosticCodes.InvalidModuleDeclaration, `Invalid module declaration '${line.content}' - expected 'module <Name>'`, locationOf(line));\n }\n const body = new ModuleBody(name);\n const previous = context.scope;\n context.scope = [name];\n body.parseChildren(context, line);\n context.scope = previous;\n return body.build(locationOf(line));\n}\n"],"mappings":"q4BA0BA,MAAaA,EAAgBC,EAAQ,6BAA6B,EAG5DC,kBAAsB,IAAI,IAAI,CAAC,KAAM,OAAQ,SAAU,SAAU,OAAQ,aAAc,aAAc,UAAU,CAAC,EAGzGC,EAAqB,mMAIlC,IAAa,WAAb,KAAwB,CAWC,KAVrB,GAAsC,CAAC,EACvC,GAAmD,CAAC,EACpD,GAA4C,CAAC,EAC7C,GAAyC,CAAC,EAC1C,GAA+C,CAAC,EAChD,GAA4C,CAAC,EAC7C,GAA8B,KAC9B,GAAgC,KAChC,GAAqC,KAErC,YAAY,EAAuB,CAAd,KAAA,KAAAC,CAAe,CAIpC,SAAS,EAAwB,EAA2B,CACxD,IAAMC,EAAUC,EAAUC,EAAK,OAAO,EACtC,OAAQF,EAAR,CACI,IAAK,OAED,OADAG,EAA0BC,EAASF,CAAI,EAChC,GACX,IAAK,cAED,MADA,MAAKG,GAAeC,EAAiBF,EAASF,EAAM,KAAKG,GAAc,WAAW,KAAK,KAAK,EAAE,EACvF,GACX,IAAK,gBAED,M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GAAI,KAAKQ,GAAU,OAAS,EAAI,CAAE,SAAU,KAAKA,EAAU,EAAI,CAAC,EAChE,SAAU,KAAKE,GACf,SAAU,KAAKJ,GACf,YAAa,KAAKD,GAClB,cACA,UACJ,CACJ,CACJ,EAGA,SAAgB,YAAY,EAAwB,EAAgC,CAChF,IAAMnB,EAAOJ,EAAc,KAAKO,EAAK,OAAO,CAAC,GAAG,IAAM,GAClDH,IAAS,IACTK,EAAQ,MAAMO,EAAgB,yBAA0B,+BAA+BT,EAAK,QAAQ,8BAA+ByB,EAAWzB,CAAI,CAAC,EAEvJ,IAAM0B,EAAO,IAAI,WAAW7B,CAAI,EAC1B8B,EAAWzB,EAAQ,MAIzB,MAHA,GAAQ,MAAQ,CAACL,CAAI,EACrB6B,EAAK,cAAcxB,EAASF,CAAI,EAChC,EAAQ,MAAQ2B,EACTD,EAAK,MAAMD,EAAWzB,CAAI,CAAC,CACtC"}
@@ -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(`^item\\s+([A-Za-z_]\\w*)\\s+(action|navigate|dialog)(?:\\s+to)?\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),I=r(`^button\\s+(?:"(${t})"|([A-Za-z_][\\w-]*))(?:\\s+(.*))?$`),L=new RegExp(r(`\\s*(title|slice|emphasis|icon)\\s+(?:"(${t})"|(\\$strings\\.\\w+(?:\\.\\w+)*)|([A-Za-z_][\\w.-]*))(?=\\s|$)`).source,`uy`),R=r(`^[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*$`),z=r(`^[a-z_]\\w*$`),B=r(`^title\\s+${v}$`),V=r(`^column\\s+([\\w.]+)(?:\\s+label\\s+${v})?$`),H=r(`^on\\s+row-click\\s+(navigate\\s+to\\s+.+)$`),U=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(),z.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=B.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=V.exec(r.content),c=H.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=U.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 W=`button <id> title "<text>" [slice <Module>.<Feature>.<Slice>] [emphasis primary|secondary|quiet] [icon <name>]`;function parseToolbarButton(t,r){let a=I.exec(r.content);if(a===null){t.error(e.InvalidToolbarButton,`Invalid toolbar button '${r.content}' - expected ${W}`,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;){L.lastIndex=h;let a=L.exec(l);if(a===null){t.error(e.InvalidToolbarButton,`Invalid toolbar button '${r.content}' - unexpected '${l.substring(h).trim()}'; expected ${W}`,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&&R.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))t.reader.takeSignificant(),o(n.content)===`authorize`&&g===null?g=c(t,n):(t.error(e.InvalidToolbarButton,`Unexpected '${n.content}' under toolbar button '${s}' - a button takes one 'authorize' line and nothing else`,i(n)),t.skipBlock(n.indent));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},location:i(r)}}function parseToolbarItem(t,n){let r=F.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=[];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=O.exec(e.content);r===null?o(e.content)===`icon`?s=e.content.substring(4).trim():parsePresentationValue(t,e,l):c.push({kind:`ScreenNavigationParameterSyntax`,name:r[1],binding:_(t,r[2],i(e)),location:i(e)})}let u=r[2]===`navigate`?`Navigate`:r[2]===`dialog`?`Dialog`:`Action`;return{kind:`ToolbarItemSyntax`,name:r[1],syntaxKind:u,target:r[3],label:a,icon:s,parameters:c,presentation:l,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};
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};
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","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","parseAuthorize","itemLabel","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 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\nfunction 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 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 context.error(DiagnosticCodes.InvalidToolbarButton, `Unexpected '${child.content}' under toolbar button '${id}' - a button takes one 'authorize' 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 } : {}),\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 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 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, 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,6BAA6B,EACrDQ,EAAsBR,EAAQ,iEAAiE,EAC/FS,EAAYT,EAAQ,gDAAgD,EACpEU,EAAYV,EAAQ,wEAAwE,EAC5FW,EAAWX,EAAQ,eAAeF,EAAkB,YAAY,EAChEc,EAA2BZ,EAAQ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OC,EAAgB3E,EAASyE,EAAU1E,CAAI,EACpD,OAAO2E,IAAS,KAAO,IAAA,GAAY,CAC/B,KAAM,mBACN,KAAM,CAAE,KAAM,kBAAmB,WAAU,OAAM,SAAUxE,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","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,6BAA6B,EACrDQ,EAAsBR,EAAQ,iEAAiE,EAC/FS,EAAYT,EAAQ,gDAAgD,EACpEU,EAAYV,EAAQ,wEAAwE,EAC5FW,EAAWX,EAAQ,eAAeF,EAAkB,YAAY,EAChEc,EAA2BZ,EAAQ,yCAAyC,EAC5Ea,EAA2Bb,EAAQ,sCAAsC,EACzEc,EAAUd,EAAQ,8CAA8C,EAChEe,EAAef,EAAQ,uCAAuCH,EAAQ,EAAE,EACxEmB,EAAiBhB,EAAQ,eAAeH,EAAQ,EAAE,E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AAIA,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,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{locationOf as n}from"./SourceLine.js";import{dependencySources as r}from"../Syntax/DependencySources.js";import{firstWord as i}from"./LineText.js";import{parseDescription as a}from"./DescriptionParser.js";import{parsePurposeReference as o}from"./PurposeParser.js";import{parseDocumentation as s}from"./DocumentationParser.js";import{misplacedReactionIdentity as c}from"./ReactionIdentityParser.js";import{isFileDirective as l}from"./FileReferences.js";import{parseOperation as u}from"./OperationParser.js";import{parseSpecification as d}from"./SpecificationParser.js";import{parseExample as f}from"./SpecificationExampleParser.js";import{sliceTypes as p}from"../Syntax/Structure.js";import{parseEvent as m,parseReadModel as h}from"./DeclarationParsers.js";import{parseCapture as g}from"./CaptureParser.js";import{captureReducer as _}from"./DependencySourceParser.js";import{parseCommand as v}from"./CommandParser.js";import{parseConstraint as y}from"./ConstraintParser.js";import{parseProjection as b}from"./ProjectionParser.js";import{parseQuery as x}from"./QueryParser.js";import{parseReaction as S}from"./ReactionParser.js";import{parseScreen as C}from"./ScreenParser.js";const w=t(`^slice\\s+([A-Za-z]\\w*)\\s+([A-Za-z_]\\w*)$`),T=/* @__PURE__ */ new Set([`reducer`]);function parseSlice(t,E){let D=w.exec(E.content),O=`StateChange`,k=``;D===null?t.error(e.InvalidSliceDeclaration,`Invalid slice declaration '${E.content}' - expected 'slice <Type> <Name>'`,n(E)):(k=D[2],p.includes(D[1])?O=D[1]:t.error(e.UnknownSliceType,`Unknown slice type '${D[1]}' - expected StateChange, StateView, Automation or Translate`,n(E)));let A=t.scope;t.scope=[...A,k];let j=null,M=!1,N=null,P=null,F=[],I=[],L=[],R=[],z=[],B=[],V=[],H=[],U=[],W=[],G=[],K=[],q=[],J=[];for(let r=t.peekChild(E.indent);r!==void 0;r=t.peekChild(E.indent)){if(t.reader.takeSignificant(),l(r))continue;let p=r.content.split(/[ \t]/,1)[0],w=p===`public`||p===`direction`?p:i(r.content);if(w===`description`)N=a(t,r,N,`Slice '${k}'`);else if(w===`documentation`)P=s(t,r,P,`Slice '${k}'`);else if(w===`purpose`)o(t,r,G);else if(w===`operation`)I.push(u(t,r).operation);else if(w===`direction`){let i=/^direction\s+(inbound|outbound)$/.exec(r.content);M||O!==`Translate`||i===null?t.error(e.InvalidSliceDeclaration,`Declare direction inbound or direction outbound once, inside a Translate slice only`,n(r)):j=i[1]===`inbound`?`Inbound`:`Outbound`,M=!0}else w===`event`||w===`public`?F.push(m(t,r)):w===`command`?L.push(v(t,r)):w===`query`?R.push(x(t,r)):w===`projection`?z.push(b(t,r)):w===`capture`?V.push(g(t,r)):w===`runs`?c(t,r):w===`reaction`?B.push(S(t,r)):w===`constraint`?H.push(y(t,r)):w===`example`?W.push(f(t,r)):w===`specification`?U.push(d(t,r)):w===`readmodel`?K.push(h(t,r)):w===`screen`?q.push(C(t,r)):T.has(w)?(J.push(_(t,r)),t.skipOpaqueBlock(r.indent)):(t.warning(e.UnknownSliceDirective,`Unknown construct '${w}' in slice '${k}'`,n(r)),t.skipBlock(r.indent))}t.scope=A;let Y={kind:`SliceSyntax`,type:O,name:k,direction:j,description:N,documentation:P,examples:W,purposes:G,events:F,operations:I,commands:L,queries:R,projections:z,captures:V,reactions:B,constraints:H,specifications:U,readModels:K,screens:q,location:n(E)};return r.set(Y,{reducers:J}),Y}export{parseSlice};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{pattern as t}from"../Text/patterns.js";import{locationOf as n}from"./SourceLine.js";import{dependencySources as r}from"../Syntax/DependencySources.js";import{firstWord as i}from"./LineText.js";import{parseDescription as a}from"./DescriptionParser.js";import{parsePurposeReference as o}from"./PurposeParser.js";import{parseDocumentation as s}from"./DocumentationParser.js";import{misplacedReactionIdentity as c}from"./ReactionIdentityParser.js";import{isFileDirective as l}from"./FileReferences.js";import{parseOperation as u}from"./OperationParser.js";import{parseSpecification as d}from"./SpecificationParser.js";import{parseExample as f}from"./SpecificationExampleParser.js";import{parseScreen as p}from"./ScreenParser.js";import{sliceTypes as m}from"../Syntax/Structure.js";import{parseEvent as h,parseReadModel as g}from"./DeclarationParsers.js";import{parseCapture as _}from"./CaptureParser.js";import{captureReducer as v}from"./DependencySourceParser.js";import{parseCommand as y}from"./CommandParser.js";import{parseConstraint as b}from"./ConstraintParser.js";import{parseProjection as x}from"./ProjectionParser.js";import{parseQuery as S}from"./QueryParser.js";import{parseReaction as C}from"./ReactionParser.js";const w=t(`^slice\\s+([A-Za-z]\\w*)\\s+([A-Za-z_]\\w*)$`),T=/* @__PURE__ */ new Set([`reducer`]);function parseSlice(t,E){let D=w.exec(E.content),O=`StateChange`,k=``;D===null?t.error(e.InvalidSliceDeclaration,`Invalid slice declaration '${E.content}' - expected 'slice <Type> <Name>'`,n(E)):(k=D[2],m.includes(D[1])?O=D[1]:t.error(e.UnknownSliceType,`Unknown slice type '${D[1]}' - expected StateChange, StateView, Automation or Translate`,n(E)));let A=t.scope;t.scope=[...A,k];let j=null,M=!1,N=null,P=null,F=[],I=[],L=[],R=[],z=[],B=[],V=[],H=[],U=[],W=[],G=[],K=[],q=[],J=[];for(let r=t.peekChild(E.indent);r!==void 0;r=t.peekChild(E.indent)){if(t.reader.takeSignificant(),l(r))continue;let m=r.content.split(/[ \t]/,1)[0],w=m===`public`||m===`direction`?m:i(r.content);if(w===`description`)N=a(t,r,N,`Slice '${k}'`);else if(w===`documentation`)P=s(t,r,P,`Slice '${k}'`);else if(w===`purpose`)o(t,r,G);else if(w===`operation`)I.push(u(t,r).operation);else if(w===`direction`){let i=/^direction\s+(inbound|outbound)$/.exec(r.content);M||O!==`Translate`||i===null?t.error(e.InvalidSliceDeclaration,`Declare direction inbound or direction outbound once, inside a Translate slice only`,n(r)):j=i[1]===`inbound`?`Inbound`:`Outbound`,M=!0}else w===`event`||w===`public`?F.push(h(t,r)):w===`command`?L.push(y(t,r)):w===`query`?R.push(S(t,r)):w===`projection`?z.push(x(t,r)):w===`capture`?V.push(_(t,r)):w===`runs`?c(t,r):w===`reaction`?B.push(C(t,r)):w===`constraint`?H.push(b(t,r)):w===`example`?W.push(f(t,r)):w===`specification`?U.push(d(t,r)):w===`readmodel`?K.push(g(t,r)):w===`screen`?q.push(p(t,r)):T.has(w)?(J.push(v(t,r)),t.skipOpaqueBlock(r.indent)):(t.warning(e.UnknownSliceDirective,`Unknown construct '${w}' in slice '${k}'`,n(r)),t.skipBlock(r.indent))}t.scope=A;let Y={kind:`SliceSyntax`,type:O,name:k,direction:j,description:N,documentation:P,examples:W,purposes:G,events:F,operations:I,commands:L,queries:R,projections:z,captures:V,reactions:B,constraints:H,specifications:U,readModels:K,screens:q,location:n(E)};return r.set(Y,{reducers:J}),Y}export{parseSlice};
2
2
  //# sourceMappingURL=SliceParser.js.map