| 19449 | return new Particle.ParserPool(undefined, map, [{ regex: HandParsersProgram.parserFullRegex, parser: parserDefinitionParser }]) |
| 19450 | } |
| 19451 | toTypeScriptInterface(used = new Set()) { |
| 19452 | let subparticlesInterfaces = [] |
| 19453 | let properties = [] |
| 19454 | const inScope = this.cueMapWithDefinitions |
| 19455 | const thisId = this.id |
| 19456 | used.add(thisId) |
| 19457 | Object.keys(inScope).forEach(key => { |
| 19458 | const def = inScope[key] |
| 19459 | const map = def.cueMapWithDefinitions |
| 19460 | const id = def.id |
| 19461 | const optionalTag = def.isRequired() ? "" : "?" |
| 19462 | const escapedKey = key.match(/\?/) ? `"${key}"` : key |
| 19463 | const description = def.description |
| 19464 | if (Object.keys(map).length && !used.has(id)) { |
| 19465 | subparticlesInterfaces.push(def.toTypeScriptInterface(used)) |
| 19466 | properties.push(` ${escapedKey}${optionalTag}: ${id}`) |
| 19467 | } else properties.push(` ${escapedKey}${optionalTag}: any${description ? " // " + description : ""}`) |
| 19468 | }) |
| 19469 | properties.sort() |
| 19470 | const description = this.description |
| 19471 | const myInterface = "" |
| 19472 | return `${subparticlesInterfaces.join("\n")} |
| 19473 | ${description ? "// " + description : ""} |
| 19474 | interface ${thisId} { |
| 19475 | ${properties.join("\n")} |
| 19476 | }`.trim() |
| 19477 | } |
| 19478 | get id() { |
| 19479 | return this.getAtom(0) |
| 19480 | } |