@kaskad/schema 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/fesm2022/kaskad-schema.mjs +1368 -0
  2. package/fesm2022/kaskad-schema.mjs.map +1 -0
  3. package/package.json +9 -9
  4. package/types/kaskad-schema.d.ts +125 -0
  5. package/esm2022/index.js +0 -17
  6. package/esm2022/index.js.map +0 -1
  7. package/esm2022/kaskad-schema.js +0 -5
  8. package/esm2022/kaskad-schema.js.map +0 -1
  9. package/esm2022/lib/load/load-schema.js +0 -16
  10. package/esm2022/lib/load/load-schema.js.map +0 -1
  11. package/esm2022/lib/load/load-templates.js +0 -136
  12. package/esm2022/lib/load/load-templates.js.map +0 -1
  13. package/esm2022/lib/load/register-declared-type.js +0 -28
  14. package/esm2022/lib/load/register-declared-type.js.map +0 -1
  15. package/esm2022/lib/load/schema-component-extractor.js +0 -101
  16. package/esm2022/lib/load/schema-component-extractor.js.map +0 -1
  17. package/esm2022/lib/load/template-registry.js +0 -51
  18. package/esm2022/lib/load/template-registry.js.map +0 -1
  19. package/esm2022/lib/types/component-definition.js +0 -1
  20. package/esm2022/lib/types/component-definition.js.map +0 -1
  21. package/esm2022/lib/types/component-schema.js +0 -1
  22. package/esm2022/lib/types/component-schema.js.map +0 -1
  23. package/esm2022/lib/types/raw-schemas.js +0 -3
  24. package/esm2022/lib/types/raw-schemas.js.map +0 -1
  25. package/esm2022/lib/types/template-raw-definition.js +0 -1
  26. package/esm2022/lib/types/template-raw-definition.js.map +0 -1
  27. package/esm2022/lib/unfolding/computation/unfold-computation-schema.js +0 -70
  28. package/esm2022/lib/unfolding/computation/unfold-computation-schema.js.map +0 -1
  29. package/esm2022/lib/unfolding/computation/unfold-for-new-syntax.js +0 -147
  30. package/esm2022/lib/unfolding/computation/unfold-for-new-syntax.js.map +0 -1
  31. package/esm2022/lib/unfolding/computation/unfold-for.js +0 -45
  32. package/esm2022/lib/unfolding/computation/unfold-for.js.map +0 -1
  33. package/esm2022/lib/unfolding/computation/unfold-if.js +0 -18
  34. package/esm2022/lib/unfolding/computation/unfold-if.js.map +0 -1
  35. package/esm2022/lib/unfolding/computation/unfold-import.js +0 -26
  36. package/esm2022/lib/unfolding/computation/unfold-import.js.map +0 -1
  37. package/esm2022/lib/unfolding/computation/unfold-interpolation.js +0 -44
  38. package/esm2022/lib/unfolding/computation/unfold-interpolation.js.map +0 -1
  39. package/esm2022/lib/unfolding/parse-binding-shorthand.js +0 -40
  40. package/esm2022/lib/unfolding/parse-binding-shorthand.js.map +0 -1
  41. package/esm2022/lib/unfolding/parse-property-key-shorthand.js +0 -9
  42. package/esm2022/lib/unfolding/parse-property-key-shorthand.js.map +0 -1
  43. package/esm2022/lib/unfolding/parse-value-type.js +0 -115
  44. package/esm2022/lib/unfolding/parse-value-type.js.map +0 -1
  45. package/esm2022/lib/unfolding/to-full-notation.js +0 -124
  46. package/esm2022/lib/unfolding/to-full-notation.js.map +0 -1
  47. package/esm2022/lib/unfolding/unfold-flat-wrapper-notation.js +0 -72
  48. package/esm2022/lib/unfolding/unfold-flat-wrapper-notation.js.map +0 -1
  49. package/esm2022/lib/unfolding/unfold-node-schema.js +0 -35
  50. package/esm2022/lib/unfolding/unfold-node-schema.js.map +0 -1
  51. package/esm2022/lib/unfolding/unfold-property.js +0 -21
  52. package/esm2022/lib/unfolding/unfold-property.js.map +0 -1
  53. package/esm2022/lib/unfolding/value/handlers/index.js +0 -11
  54. package/esm2022/lib/unfolding/value/handlers/index.js.map +0 -1
  55. package/esm2022/lib/unfolding/value/handlers/unfold-array.js +0 -9
  56. package/esm2022/lib/unfolding/value/handlers/unfold-array.js.map +0 -1
  57. package/esm2022/lib/unfolding/value/handlers/unfold-boolean.js +0 -8
  58. package/esm2022/lib/unfolding/value/handlers/unfold-boolean.js.map +0 -1
  59. package/esm2022/lib/unfolding/value/handlers/unfold-command.js +0 -22
  60. package/esm2022/lib/unfolding/value/handlers/unfold-command.js.map +0 -1
  61. package/esm2022/lib/unfolding/value/handlers/unfold-component-schema.js +0 -14
  62. package/esm2022/lib/unfolding/value/handlers/unfold-component-schema.js.map +0 -1
  63. package/esm2022/lib/unfolding/value/handlers/unfold-component.js +0 -66
  64. package/esm2022/lib/unfolding/value/handlers/unfold-component.js.map +0 -1
  65. package/esm2022/lib/unfolding/value/handlers/unfold-map.js +0 -13
  66. package/esm2022/lib/unfolding/value/handlers/unfold-map.js.map +0 -1
  67. package/esm2022/lib/unfolding/value/handlers/unfold-number.js +0 -11
  68. package/esm2022/lib/unfolding/value/handlers/unfold-number.js.map +0 -1
  69. package/esm2022/lib/unfolding/value/handlers/unfold-object.js +0 -15
  70. package/esm2022/lib/unfolding/value/handlers/unfold-object.js.map +0 -1
  71. package/esm2022/lib/unfolding/value/handlers/unfold-set.js +0 -6
  72. package/esm2022/lib/unfolding/value/handlers/unfold-set.js.map +0 -1
  73. package/esm2022/lib/unfolding/value/handlers/unfold-shape.js +0 -13
  74. package/esm2022/lib/unfolding/value/handlers/unfold-shape.js.map +0 -1
  75. package/esm2022/lib/unfolding/value/handlers/unfold-string.js +0 -8
  76. package/esm2022/lib/unfolding/value/handlers/unfold-string.js.map +0 -1
  77. package/esm2022/lib/unfolding/value/handlers/unfold-unknown.js +0 -4
  78. package/esm2022/lib/unfolding/value/handlers/unfold-unknown.js.map +0 -1
  79. package/esm2022/lib/unfolding/value/handlers/unfold-variant-shape.js +0 -61
  80. package/esm2022/lib/unfolding/value/handlers/unfold-variant-shape.js.map +0 -1
  81. package/esm2022/lib/unfolding/value/handlers/validate-props.js +0 -20
  82. package/esm2022/lib/unfolding/value/handlers/validate-props.js.map +0 -1
  83. package/esm2022/lib/unfolding/value/throw-unfold-value-error.js +0 -11
  84. package/esm2022/lib/unfolding/value/throw-unfold-value-error.js.map +0 -1
  85. package/esm2022/lib/unfolding/value/unfold-node-value.js +0 -30
  86. package/esm2022/lib/unfolding/value/unfold-node-value.js.map +0 -1
  87. package/esm2022/lib/util/is-object.js +0 -4
  88. package/esm2022/lib/util/is-object.js.map +0 -1
  89. package/esm2022/lib/util/stringify-object.js +0 -4
  90. package/esm2022/lib/util/stringify-object.js.map +0 -1
  91. package/esm2022/lib/util/unfold-component-definitions.js +0 -21
  92. package/esm2022/lib/util/unfold-component-definitions.js.map +0 -1
  93. package/index.d.ts +0 -16
  94. package/kaskad-schema.d.ts +0 -5
  95. package/lib/load/load-schema.d.ts +0 -3
  96. package/lib/load/load-templates.d.ts +0 -2
  97. package/lib/load/register-declared-type.d.ts +0 -1
  98. package/lib/load/schema-component-extractor.d.ts +0 -2
  99. package/lib/load/template-registry.d.ts +0 -16
  100. package/lib/types/component-definition.d.ts +0 -5
  101. package/lib/types/component-schema.d.ts +0 -26
  102. package/lib/types/raw-schemas.d.ts +0 -25
  103. package/lib/types/template-raw-definition.d.ts +0 -7
  104. package/lib/unfolding/computation/unfold-computation-schema.d.ts +0 -2
  105. package/lib/unfolding/computation/unfold-for-new-syntax.d.ts +0 -6
  106. package/lib/unfolding/computation/unfold-for.d.ts +0 -2
  107. package/lib/unfolding/computation/unfold-if.d.ts +0 -3
  108. package/lib/unfolding/computation/unfold-import.d.ts +0 -2
  109. package/lib/unfolding/computation/unfold-interpolation.d.ts +0 -3
  110. package/lib/unfolding/parse-binding-shorthand.d.ts +0 -3
  111. package/lib/unfolding/parse-property-key-shorthand.d.ts +0 -2
  112. package/lib/unfolding/parse-value-type.d.ts +0 -2
  113. package/lib/unfolding/to-full-notation.d.ts +0 -8
  114. package/lib/unfolding/unfold-flat-wrapper-notation.d.ts +0 -13
  115. package/lib/unfolding/unfold-node-schema.d.ts +0 -3
  116. package/lib/unfolding/unfold-property.d.ts +0 -2
  117. package/lib/unfolding/value/handlers/index.d.ts +0 -10
  118. package/lib/unfolding/value/handlers/unfold-array.d.ts +0 -3
  119. package/lib/unfolding/value/handlers/unfold-boolean.d.ts +0 -2
  120. package/lib/unfolding/value/handlers/unfold-command.d.ts +0 -3
  121. package/lib/unfolding/value/handlers/unfold-component-schema.d.ts +0 -4
  122. package/lib/unfolding/value/handlers/unfold-component.d.ts +0 -3
  123. package/lib/unfolding/value/handlers/unfold-map.d.ts +0 -3
  124. package/lib/unfolding/value/handlers/unfold-number.d.ts +0 -2
  125. package/lib/unfolding/value/handlers/unfold-object.d.ts +0 -3
  126. package/lib/unfolding/value/handlers/unfold-set.d.ts +0 -3
  127. package/lib/unfolding/value/handlers/unfold-shape.d.ts +0 -3
  128. package/lib/unfolding/value/handlers/unfold-string.d.ts +0 -2
  129. package/lib/unfolding/value/handlers/unfold-unknown.d.ts +0 -2
  130. package/lib/unfolding/value/handlers/unfold-variant-shape.d.ts +0 -3
  131. package/lib/unfolding/value/handlers/validate-props.d.ts +0 -2
  132. package/lib/unfolding/value/throw-unfold-value-error.d.ts +0 -2
  133. package/lib/unfolding/value/unfold-node-value.d.ts +0 -8
  134. package/lib/util/is-object.d.ts +0 -1
  135. package/lib/util/stringify-object.d.ts +0 -1
  136. package/lib/util/unfold-component-definitions.d.ts +0 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kaskad-schema.mjs","sources":["../../../../libs/schema/src/lib/types/raw-schemas.ts","../../../../libs/schema/src/lib/util/is-object.ts","../../../../libs/schema/src/lib/util/stringify-object.ts","../../../../libs/schema/src/lib/unfolding/parse-value-type.ts","../../../../libs/schema/src/lib/unfolding/parse-property-key-shorthand.ts","../../../../libs/schema/src/lib/unfolding/computation/unfold-for.ts","../../../../libs/schema/src/lib/unfolding/computation/unfold-for-new-syntax.ts","../../../../libs/schema/src/lib/unfolding/computation/unfold-if.ts","../../../../libs/schema/src/lib/unfolding/computation/unfold-import.ts","../../../../libs/schema/src/lib/unfolding/computation/unfold-interpolation.ts","../../../../libs/schema/src/lib/unfolding/computation/unfold-computation-schema.ts","../../../../libs/schema/src/lib/unfolding/parse-binding-shorthand.ts","../../../../libs/schema/src/lib/unfolding/unfold-flat-wrapper-notation.ts","../../../../libs/schema/src/lib/unfolding/to-full-notation.ts","../../../../libs/schema/src/lib/unfolding/value/throw-unfold-value-error.ts","../../../../libs/schema/src/lib/unfolding/value/handlers/unfold-boolean.ts","../../../../libs/schema/src/lib/unfolding/value/handlers/unfold-number.ts","../../../../libs/schema/src/lib/unfolding/value/handlers/unfold-string.ts","../../../../libs/schema/src/lib/unfolding/value/handlers/unfold-unknown.ts","../../../../libs/schema/src/lib/unfolding/value/handlers/unfold-array.ts","../../../../libs/schema/src/lib/unfolding/value/handlers/unfold-map.ts","../../../../libs/schema/src/lib/unfolding/value/handlers/unfold-object.ts","../../../../libs/schema/src/lib/unfolding/value/handlers/unfold-command.ts","../../../../libs/schema/src/lib/unfolding/value/handlers/validate-props.ts","../../../../libs/schema/src/lib/unfolding/value/handlers/unfold-component-schema.ts","../../../../libs/schema/src/lib/unfolding/unfold-property.ts","../../../../libs/schema/src/lib/unfolding/value/handlers/unfold-component.ts","../../../../libs/schema/src/lib/unfolding/value/handlers/unfold-set.ts","../../../../libs/schema/src/lib/unfolding/value/handlers/unfold-shape.ts","../../../../libs/schema/src/lib/unfolding/value/handlers/unfold-variant-shape.ts","../../../../libs/schema/src/lib/unfolding/value/unfold-node-value.ts","../../../../libs/schema/src/lib/unfolding/unfold-node-schema.ts","../../../../libs/schema/src/lib/load/schema-component-extractor.ts","../../../../libs/schema/src/lib/load/template-registry.ts","../../../../libs/schema/src/lib/load/load-schema.ts","../../../../libs/schema/src/lib/load/register-declared-type.ts","../../../../libs/schema/src/lib/load/load-templates.ts","../../../../libs/schema/src/lib/util/unfold-component-definitions.ts","../../../../libs/schema/src/kaskad-schema.ts"],"sourcesContent":["// Recipe types used for unfolding\n// These types represent the raw input format before normalization\n\nexport type FormulaComputationRecipe = {\n formula: string;\n};\n\nexport type ForComputationRecipe = {\n items: unknown[];\n as?: {\n item: unknown;\n index: unknown;\n first?: unknown;\n last?: unknown;\n };\n yield: unknown;\n};\n\nexport type IfComputationRecipe = Record<'if' | 'then' | 'else', unknown> | ({ if: unknown } & Record<string, unknown>);\n\nexport type SwitchComputationRecipe = {\n computationType: 'switch';\n source: unknown;\n cases: { equals: unknown; then: unknown }[];\n default: unknown;\n};\n","export function isObject(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value) && !(value instanceof Set);\n}\n","export function stringifyObject(label: string, data: unknown): string {\n return `\\n${label}:\\n${JSON.stringify(data, null, 2)}`;\n}\n","import { DefinitionStore } from '@kaskad/definition';\nimport {\n CommandValueType,\n NodeType,\n NodeTypes,\n ObjectValueType,\n ShapeValueType,\n ValueType,\n VariantShapeValueType,\n} from '@kaskad/types';\n\nexport function parseValueType(type: string): ValueType {\n type = type.replaceAll(' ', '');\n\n if (type.startsWith('(') && type.endsWith(')')) {\n return createCommandType(type.slice(1, -1));\n }\n\n // Check for map type first (but not just '{}')\n if (type.endsWith('{}') && type !== '{}') {\n const rest = type.slice(0, -2);\n return {\n type: 'map',\n item: parseValueType(rest),\n };\n }\n\n // Check for set type\n if (type.endsWith('#')) {\n const rest = type.slice(0, -1);\n return {\n type: 'set',\n item: parseValueType(rest),\n };\n }\n\n if (type.endsWith('[]')) {\n const rest = type.slice(0, -2);\n return {\n type: 'array',\n item: parseValueType(rest),\n };\n }\n\n // Check for object type after map/array to handle {} and complex object types\n if (type.startsWith('{') && type.endsWith('}')) {\n return createObjectType(type.slice(1, -1));\n }\n\n return createSimpleType(type as NodeType);\n}\n\nfunction createObjectType(type: string): ObjectValueType {\n const fieldsPairs = splitTypesByComma(type);\n\n const fields = fieldsPairs.reduce<Record<string, ValueType>>((acc, str) => {\n if (!str) return acc; // Handle empty object case\n\n const colonIndex = str.indexOf(':');\n const errorPrefix = `Invalid object field definition: \"${str}\"`;\n\n if (colonIndex === -1) {\n throw new Error(`${errorPrefix} - expected format \"fieldName:type\"`);\n }\n\n const fieldKey = str.substring(0, colonIndex);\n const fieldType = str.substring(colonIndex + 1);\n\n if (!fieldKey) {\n throw new Error(`${errorPrefix} - field name cannot be empty`);\n }\n\n if (!fieldType) {\n throw new Error(`${errorPrefix} - field type cannot be empty`);\n }\n\n acc[fieldKey] = parseValueType(fieldType);\n return acc;\n }, {});\n\n return {\n type: 'object',\n fields,\n } satisfies ObjectValueType;\n}\n\nfunction createCommandType(type: string): CommandValueType {\n const args = splitTypesByComma(type).filter(Boolean);\n\n return {\n type: 'command',\n args: args.map(parseValueType),\n } satisfies CommandValueType;\n}\n\nfunction createSimpleType(type: NodeType): ValueType {\n if (NodeTypes.includes(type)) {\n return { type } as ValueType;\n }\n\n if (type in DefinitionStore.getInstance().shapes) {\n return {\n type: 'shape',\n shapeType: type,\n } as ShapeValueType;\n }\n\n if (type in DefinitionStore.getInstance().variantShapes) {\n return {\n type: 'variantShape',\n shapeType: type,\n } as VariantShapeValueType;\n }\n\n throw new Error(`Unknown type '${type}'`);\n}\n\nfunction splitTypesByComma(str: string): string[] {\n const pairs: string[] = [];\n\n let braceCount = 0;\n let part = '';\n\n for (let i = 0; i < str.length; i++) {\n const char = str[i];\n\n if (char === '{') {\n braceCount++;\n part += char;\n continue;\n }\n\n if (char === '}') {\n braceCount--;\n part += char;\n continue;\n }\n\n if (char === ',' && braceCount === 0) {\n pairs.push(part);\n part = '';\n } else {\n part += char;\n }\n }\n\n pairs.push(part);\n\n return pairs;\n}\n","import { NodeType, ValueType } from '@kaskad/types';\n\nimport { parseValueType } from './parse-value-type';\n\nexport function parsePropertyKeyShorthand(shorthand: string): [string, ValueType] {\n const [key, type] = shorthand.split('@') as [string, NodeType];\n if (!type) {\n throw new Error(`Invalid node key expression \"${key}\". Expected type for key \"${key}\"`);\n }\n return [key, parseValueType(type)];\n}\n","import { ComputationSchema, ForComputationSchema } from '@kaskad/types';\n\nimport { ForComputationRecipe } from '../../types/raw-schemas';\nimport { isObject } from '../../util/is-object';\nimport { parsePropertyKeyShorthand } from '../parse-property-key-shorthand';\nimport { unfoldNodeSchema } from '../unfold-node-schema';\n\nexport function unfoldForComputationSchema(schema: unknown): ComputationSchema | null {\n if (!isObject(schema) || !('computationType' in schema)) {\n return null;\n }\n let rawDimensions = schema['dimensions'] as ForComputationRecipe[];\n if (rawDimensions) {\n if (!Array.isArray(rawDimensions)) {\n throw new Error(`Invalid dimensions schema \"${JSON.stringify(rawDimensions)}\". It must be an array.`);\n }\n } else {\n // schema can be a flat object if only one dimension is defined\n rawDimensions = [schema as ForComputationRecipe];\n }\n\n const dimensions = rawDimensions.map((dimension) => {\n const { item = 'item', index = 'index', first = null, last = null } = dimension.as || {};\n\n const itemsKey = Object.keys(dimension).find((key) => key.startsWith('items')) as keyof typeof dimension;\n\n const [items, itemsType] = parsePropertyKeyShorthand(itemsKey ?? '');\n if (items !== 'items') {\n throw new Error(`Computation \"for\" requires \"items\" field: ${JSON.stringify(schema)}`);\n }\n\n const itemsArr = dimension[itemsKey];\n\n return {\n items: unfoldNodeSchema(itemsArr, itemsType, []),\n itemsType,\n item: unfoldNodeSchema(item, { type: 'string' }, []),\n index: unfoldNodeSchema(index, { type: 'string' }, []),\n first: unfoldNodeSchema(first, { type: 'string' }, []),\n last: unfoldNodeSchema(last, { type: 'string' }, []),\n trackBy: unfoldNodeSchema(null, { type: 'unknown' }, []),\n };\n });\n\n const normalizedYield = unfoldNodeSchema(schema['yield'], { type: 'unknown' }, []);\n\n const result: ForComputationSchema = {\n computationType: 'for',\n dimensions,\n yield: normalizedYield,\n [Symbol.for('type')]: 'ComputationSchema',\n };\n return result;\n}\n","import { ComputationSchema, ForComputationSchema } from '@kaskad/types';\n\nimport { isObject } from '../../util/is-object';\nimport { parseValueType } from '../parse-value-type';\nimport { unfoldNodeSchema } from '../unfold-node-schema';\n\ninterface ParsedForSpec {\n itemName: string;\n itemType: string;\n itemsExpr: unknown;\n metadata: {\n index?: string;\n first?: string;\n last?: string;\n };\n trackBy: string | null;\n}\n\n/**\n * Parses metadata object from the `with` clause\n * Example: \"index: $i, first: $isFirst, last: $isLast\"\n */\nfunction parseMetadata(str: string): { index?: string; first?: string; last?: string } {\n const result: { index?: string; first?: string; last?: string } = {};\n const trimmed = str.trim();\n\n if (!trimmed) {\n throw new Error('Empty metadata block. Omit \"with\" clause if no metadata is needed.');\n }\n\n const pairs = trimmed.split(',').map((s) => s.trim());\n\n for (const pair of pairs) {\n const colonIndex = pair.indexOf(':');\n if (colonIndex === -1) {\n throw new Error(`Invalid metadata pair: \"${pair}\". Expected format: \"key: $value\"`);\n }\n\n const key = pair.slice(0, colonIndex).trim();\n const value = pair.slice(colonIndex + 1).trim();\n\n if (!['index', 'first', 'last'].includes(key)) {\n throw new Error(`Invalid metadata key: \"${key}\". Only \"index\", \"first\", and \"last\" are allowed.`);\n }\n\n if (!value || !value.startsWith('$')) {\n throw new Error(`Invalid metadata value: \"${value}\". Must be a variable starting with $.`);\n }\n\n result[key as 'index' | 'first' | 'last'] = value.slice(1); // Remove $\n }\n\n return result;\n}\n\n/**\n * Parses a single for-loop specification\n * Example: \"$row@Row of $rows with { index: $i, first: $isFirst } trackBy $row.id\"\n */\nfunction parseForSpec(spec: string): ParsedForSpec {\n const trimmed = spec.trim();\n\n // First, extract trackBy if present at the end\n // trackBy uses $variable or $variable.property syntax (e.g., \"$item\" or \"$item.id\")\n let trackBy: string | null = null;\n let specWithoutTrackBy = trimmed;\n\n const trackByMatch = trimmed.match(/\\s+trackBy\\s+(\\$\\w+(?:\\.\\w+)*)$/);\n if (trackByMatch) {\n const trackByValue = trackByMatch[1].trim();\n specWithoutTrackBy = trimmed.slice(0, trackByMatch.index).trim();\n\n // Parse the $variable.property syntax\n const pathMatch = trackByValue.match(/^\\$(\\w+)((?:\\.\\w+)*)$/);\n if (!pathMatch) {\n throw new Error(`Invalid trackBy syntax: ${trackByValue}. Expected format: $variable or $variable.property`);\n }\n\n const variableName = pathMatch[1]; // e.g., \"item\"\n const propertyPath = pathMatch[2]; // e.g., \".id\" or \"\"\n\n // We'll validate against itemName after parsing the main pattern\n // Store both parts temporarily - validation happens after we know itemName\n trackBy = `${variableName}${propertyPath}`;\n }\n\n // Pattern: $item@Type of $items with { metadata }\n // ^^^^^ ^^^^ ^^^^^^ ^^^^^^^^^^^^^^^\n // name type expr metadata (optional)\n // Note: Type can include dots for namespaced types like \"app.table.Row\"\n const pattern = /^\\$(\\w+)@([\\w.[\\]{}:,\\s]+)\\s+of\\s+(.+?)(?:\\s+with\\s*\\{([^}]+)})?$/;\n const match = specWithoutTrackBy.match(pattern);\n\n if (!match) {\n throw new Error(\n `Invalid for-loop syntax: \"${spec}\". Expected format: \"$item@Type of $items\" or \"$item@Type of $items with { index: $i }\"`,\n );\n }\n\n const [, itemName, typeStr, itemsExpr, metadataStr] = match;\n\n // Validate and process trackBy\n // null = no trackBy specified (use index)\n // \"\" = trackBy $var (use item value directly for primitives)\n // \"id\" or \"user.id\" = trackBy $var.property (use property path)\n let processedTrackBy: string | null = null;\n if (trackBy !== null) {\n // trackBy is in format \"variableName\" or \"variableName.property.path\"\n const parts = trackBy.split('.');\n const variableName = parts[0];\n\n // Validate that trackBy references the loop variable\n if (variableName !== itemName) {\n throw new Error(`trackBy must reference loop variable $${itemName}, got $${variableName}`);\n }\n\n // Extract the property path (everything after the variable name)\n // If parts.length === 1, it's just the variable (primitive array) -> \"\" (use item value)\n // If parts.length > 1, it's a property path -> \"id\" or \"user.id\"\n processedTrackBy = parts.length > 1 ? parts.slice(1).join('.') : '';\n }\n\n return {\n itemName,\n itemType: typeStr.trim(),\n itemsExpr,\n metadata: metadataStr ? parseMetadata(metadataStr) : {},\n trackBy: processedTrackBy,\n };\n}\n\n/**\n * Unfolds the new for-loop syntax into a ForComputationSchema\n * Supports: for: \"$item@Type of $items\" or for: [\"$item1@Type1 of $items1\", \"$item2@Type2 of $items2\"]\n */\nexport function unfoldForWithNewSyntax(schema: unknown): ComputationSchema | null {\n if (!isObject(schema) || !('for' in schema)) {\n return null;\n }\n\n const forSpec = schema['for'];\n const specs = Array.isArray(forSpec) ? forSpec : [forSpec];\n\n if (specs.length === 0) {\n throw new Error('For-loop requires at least one dimension');\n }\n\n const dimensions = specs.map((spec) => {\n if (typeof spec !== 'string') {\n throw new Error(`Invalid for-loop spec: ${JSON.stringify(spec)}. Must be a string.`);\n }\n\n const parsed = parseForSpec(spec);\n\n // Parse the type annotation\n // The type can be either:\n // 1. An item type (e.g., \"string\") - we need to wrap in array\n // 2. Already an array type (e.g., \"string[]\") - use as-is\n const parsedType = parseValueType(parsed.itemType);\n const itemsType = parsedType.type === 'array' ? parsedType : { type: 'array' as const, item: parsedType };\n\n return {\n items: unfoldNodeSchema(parsed.itemsExpr, itemsType, []),\n itemsType,\n item: unfoldNodeSchema(parsed.itemName, { type: 'string' }, []),\n index: unfoldNodeSchema(parsed.metadata.index || 'index', { type: 'string' }, []),\n first: unfoldNodeSchema(parsed.metadata.first || null, { type: 'string' }, []),\n last: unfoldNodeSchema(parsed.metadata.last || null, { type: 'string' }, []),\n // trackBy: null = use index, property path (e.g., \"id\") = extract from item\n trackBy: unfoldNodeSchema(parsed.trackBy, { type: 'string' }, []),\n };\n });\n\n // Extract yield: either explicit 'yield' property or all other properties (inline yield)\n let yieldSchema: unknown;\n if ('yield' in schema) {\n yieldSchema = schema['yield'];\n } else {\n // Inline yield: all properties except 'for'\n const { for: _, ...rest } = schema as Record<string, unknown>;\n yieldSchema = rest;\n }\n\n const normalizedYield = unfoldNodeSchema(yieldSchema, { type: 'componentSchema' }, []);\n\n const result: ForComputationSchema = {\n computationType: 'for',\n dimensions,\n yield: normalizedYield,\n [Symbol.for('type')]: 'ComputationSchema',\n };\n\n return result;\n}\n","import { ComputationSchema, IfComputationSchema } from '@kaskad/types';\n\nimport { IfComputationRecipe } from '../../types/raw-schemas';\nimport { unfoldNodeSchema } from '../unfold-node-schema';\n\nexport function unfoldIfComputationSchema(schema: IfComputationRecipe): ComputationSchema {\n if (schema.if === undefined) {\n throw new Error('If computation requires the \"if\" field.');\n }\n\n const result: IfComputationSchema = {\n computationType: 'if',\n if: unfoldNodeSchema(schema.if, { type: 'boolean' }, []),\n then: createBranch(schema.then),\n else: createBranch(schema.else),\n [Symbol.for('type')]: 'ComputationSchema',\n };\n return result;\n}\n\nfunction createBranch(schema: unknown = null) {\n return unfoldNodeSchema(schema, { type: 'componentSchema' }, []);\n}\n","import { ComponentRef, TemplateComputationSchema } from '@kaskad/types';\n\nimport { Defer } from '../../types/component-schema';\nimport { isObject } from '../../util/is-object';\nimport { unfoldNodeSchema } from '../unfold-node-schema';\n\ntype TemplateFullRawSchema = {\n readonly computationType: 'template';\n readonly path: string;\n readonly ref?: ComponentRef;\n readonly _defer?: Defer;\n} & Record<string, unknown>;\n\nexport function unfoldImportComputationSchema(schema: unknown): TemplateComputationSchema | null {\n if (!isObject(schema) || !('computationType' in schema)) {\n return null;\n }\n\n const { path, ref, computationType, _defer, ...contractVariables } = schema as TemplateFullRawSchema;\n if (!path) {\n throw new Error(`Import resolver requires a path field.`);\n }\n\n const defer = _defer\n ? {\n placeholder: unfoldNodeSchema(_defer.placeholder || null, { type: 'component' }, []),\n error: unfoldNodeSchema(_defer.error || null, { type: 'component' }, []),\n }\n : null;\n\n return {\n computationType,\n path,\n defer,\n ref,\n contractVariables,\n [Symbol.for('type')]: 'ComputationSchema',\n };\n}\n","import { ComputationSchema, FormulaComputationSchema } from '@kaskad/types';\n\nexport function unfoldInterpolationComputationSchema(schema: string): ComputationSchema | null {\n const args = stringToFuncArgs(schema);\n return { computationType: 'formula', formula: `concat(${args})` } as FormulaComputationSchema;\n}\n\nexport function replaceInterpolationsInFormula(formula: string): string {\n // Replace {{}} inside single-quoted string literals\n let result = formula.replace(/'([^']*\\{\\{.*?\\}\\}[^']*)'/g, (_, content) => {\n return `concat(${stringToFuncArgs(content)})`;\n });\n // Replace {{}} inside double-quoted string literals\n result = result.replace(/\"([^\"]*\\{\\{.*?\\}\\}[^\"]*)\"/g, (_, content) => {\n return `concat(${stringToFuncArgs(content)})`;\n });\n // Strip bare {{}} delimiters (expression is already valid formula syntax)\n result = result.replace(/\\{\\{(.*?)\\}\\}/g, (_, expr) => expr.trim());\n return result;\n}\n\nfunction stringToFuncArgs(str: string): string {\n const result: string[] = [];\n let currentIndex = 0;\n\n while (currentIndex < str.length) {\n const startBrace = str.indexOf('{{', currentIndex);\n\n if (startBrace === -1) {\n const remaining = str.slice(currentIndex);\n if (remaining) result.push(`'${remaining}'`);\n break;\n }\n\n const before = str.slice(currentIndex, startBrace);\n if (before) result.push(`'${before}'`);\n\n const endBrace = str.indexOf('}}', startBrace);\n if (!endBrace) {\n result.push(str);\n break;\n }\n\n const template = str.slice(startBrace + 2, endBrace).trim();\n if (template) result.push(template);\n\n currentIndex = endBrace + 2;\n }\n return '[' + result.join(', ') + ']';\n}\n","import {\n ComponentSchemaNodeSchema,\n ComputationSchema,\n FormulaComputationSchema,\n SwitchComputationSchema,\n} from '@kaskad/types';\n\nimport { FormulaComputationRecipe, IfComputationRecipe, SwitchComputationRecipe } from '../../types/raw-schemas';\nimport { isObject } from '../../util/is-object';\nimport { stringifyObject } from '../../util/stringify-object';\nimport { unfoldNodeSchema } from '../unfold-node-schema';\nimport { unfoldForComputationSchema as unfoldFor } from './unfold-for';\nimport { unfoldForWithNewSyntax } from './unfold-for-new-syntax';\nimport { unfoldIfComputationSchema as unfoldIf } from './unfold-if';\nimport { unfoldImportComputationSchema as unfoldTemplate } from './unfold-import';\nimport { replaceInterpolationsInFormula, unfoldInterpolationComputationSchema } from './unfold-interpolation';\n\nconst unfoldFormula = (schema: FormulaComputationRecipe): ComputationSchema => {\n const result: FormulaComputationSchema = {\n computationType: 'formula',\n formula: schema.formula,\n [Symbol.for('type')]: 'ComputationSchema',\n };\n return result;\n};\n\nconst unfoldSwitch = (schema: SwitchComputationRecipe): SwitchComputationSchema => {\n return {\n computationType: 'switch',\n source: unfoldNodeSchema(schema.source, { type: 'unknown' }, []),\n cases: schema.cases.map((c) => {\n return {\n equals: c.equals,\n then: unfoldNodeSchema(c.then, { type: 'componentSchema' }) as ComponentSchemaNodeSchema,\n };\n }),\n default: unfoldNodeSchema(schema.default, { type: 'componentSchema' }) as ComponentSchemaNodeSchema,\n [Symbol.for('type')]: 'ComputationSchema',\n };\n};\n\nexport function unfoldComputationSchema(schema: unknown): ComputationSchema | null {\n if (typeof schema === 'string') {\n if (schema.startsWith('=> ')) {\n let formula = schema.slice(3);\n if (formula.includes('{{')) {\n formula = replaceInterpolationsInFormula(formula);\n }\n return { computationType: 'formula', formula } as FormulaComputationSchema;\n }\n\n if (schema.includes('{{') && schema.includes('}}')) {\n return unfoldInterpolationComputationSchema(schema);\n }\n }\n\n // Check for new for-loop syntax (before computationType check)\n if (isObject(schema) && 'for' in schema && !('computationType' in schema)) {\n return unfoldForWithNewSyntax(schema);\n }\n\n if (!isObject(schema) || !('computationType' in schema)) {\n return null;\n }\n\n if (isUnfoldedComputationSchema(schema)) {\n return schema;\n }\n\n const computationUnfolders: Record<string, (schema: unknown) => ComputationSchema | null> = {\n formula: (schema) => unfoldFormula(schema as FormulaComputationRecipe),\n for: (schema) => unfoldFor(schema),\n template: (schema) => unfoldTemplate(schema),\n if: (schema) => unfoldIf(schema as IfComputationRecipe),\n switch: (schema) => unfoldSwitch(schema as SwitchComputationRecipe),\n };\n\n const unfolder = computationUnfolders[schema['computationType'] as string];\n if (unfolder) {\n return unfolder(schema);\n }\n\n throw new Error(`Unable to unfold computation schema.\\n${stringifyObject('Schema', schema)}`);\n}\n\nfunction isUnfoldedComputationSchema(schema: unknown): schema is ComputationSchema {\n return isObject(schema) && Symbol.for('type') in schema;\n}\n","import { BindingSchema } from '@kaskad/types';\n\nconst MIRROR_PATTERN = /^<=>\\s*(\\S+)$/;\nconst SELECTION_PATTERN = /^<#>\\s*(\\S+)->\\((\\$\\w+),\\s*(\\$\\w+)\\)$/;\nconst OBJECT_PATTERN = /^<\\{\\}>\\s*(\\S+)->\\((\\$\\w+),\\s*(\\$\\w+)\\)$/;\nconst ARRAY_PATTERN = /^<\\[\\]>\\s*(\\S+)->\\((\\$\\w+)\\)$/;\n\nexport function parseBindingShorthand(value: string): BindingSchema | null {\n let match: RegExpMatchArray | null;\n\n match = value.match(MIRROR_PATTERN);\n if (match) {\n return { bindingType: 'mirror', selector: match[1] };\n }\n\n match = value.match(SELECTION_PATTERN);\n if (match) {\n return {\n bindingType: 'selection',\n componentSelector: match[1],\n mapping: { key: match[2], selected: match[3] },\n };\n }\n\n match = value.match(OBJECT_PATTERN);\n if (match) {\n return {\n bindingType: 'object',\n componentSelector: match[1],\n mapping: { key: match[2], value: match[3] },\n };\n }\n\n match = value.match(ARRAY_PATTERN);\n if (match) {\n return {\n bindingType: 'array',\n componentSelector: match[1],\n mapping: { value: match[2] },\n };\n }\n\n return null;\n}\n\nexport function isBindingShorthand(value: string): boolean {\n return value.startsWith('<=>') || value.startsWith('<#>') || value.startsWith('<{}>') || value.startsWith('<[]>');\n}\n","import { DefinitionStore } from '@kaskad/definition';\n\nimport { ComponentRecipe, TemplateRecipe } from '../types/component-schema';\nimport { isObject } from '../util/is-object';\nimport { RawNode } from './to-full-notation';\n\ntype WrapperEntity = [string, Record<string, unknown>];\n\ntype ComposedSchema =\n | ComponentRecipe\n | RawNode\n | {\n computationType: string;\n [x: string]: unknown;\n };\n\nexport const WrapperPrefix = '+';\nexport const PathSymbol = '/';\n\nexport function unfoldFlatWrappers(wrappers: WrapperEntity[], schema: ComposedSchema, resultingNode: RawNode): RawNode {\n const composed = wrappers\n .reverse()\n .reduce<ComposedSchema>((composed, wrapper) => unfoldWrapper(wrapper, composed), schema);\n\n if ('computationType' in composed) {\n resultingNode._computation = composed;\n } else {\n resultingNode._value = composed;\n }\n\n return resultingNode;\n}\n\nfunction unfoldWrapper(wrapper: WrapperEntity, schema: ComposedSchema): ComposedSchema {\n const [componentType, props] = wrapper;\n\n if (componentType.includes(PathSymbol)) {\n return {\n computationType: 'template',\n path: componentType,\n ...props,\n slot: schema,\n };\n }\n\n const slot = getComponentSlot(componentType);\n\n return {\n componentType,\n ...props,\n [slot]: {\n ...schema,\n },\n };\n}\n\nfunction getComponentSlot(wrapperType: string): string {\n const props = DefinitionStore.getInstance().getComputedComponentContract(wrapperType);\n\n const componentSlots = Object.entries(props)\n .filter(([, prop]) => prop.valueType.type === 'component')\n .map(([key]) => key);\n\n if (!componentSlots.length) {\n throw new Error(`No component slot found for wrapper: \"${wrapperType}\"`);\n }\n\n if (componentSlots.length > 1) {\n const defaultSlot = DefinitionStore.getInstance().getComponent(wrapperType)?.defaultSlot;\n if (!defaultSlot) {\n throw new Error(`Multiple component slots found for wrapper: \"${wrapperType}\". Please specify a default slot.`);\n }\n return defaultSlot;\n }\n\n return componentSlots[0];\n}\n\nexport function extractWrappers(\n schema: ComponentRecipe | TemplateRecipe,\n): [WrapperEntity[], ComponentRecipe | TemplateRecipe] {\n const wrappers: WrapperEntity[] = [];\n\n const shallow = { ...schema };\n\n for (const key in shallow) {\n if (key.startsWith(WrapperPrefix)) {\n const wrapperType = key.slice(1);\n const wrapperProps = shallow[key] || {};\n\n if (!isObject(wrapperProps)) {\n throw new Error(`Properties for wrapper \"${wrapperType}\" must be an object`);\n }\n\n wrappers.push([wrapperType, wrapperProps]);\n delete shallow[key];\n }\n }\n\n return [wrappers, shallow];\n}\n\nexport function hasWrappers(schema: ComponentRecipe | TemplateRecipe): boolean {\n return Object.keys(schema).some((key) => key.startsWith(WrapperPrefix));\n}\n","import { BindingSchema, ValueType } from '@kaskad/types';\n\nimport { ComponentRecipe, TemplateRecipe } from '../types/component-schema';\nimport { isBindingShorthand, parseBindingShorthand } from './parse-binding-shorthand';\nimport { extractWrappers, hasWrappers, unfoldFlatWrappers } from './unfold-flat-wrapper-notation';\n\nexport type RawNode = {\n _valueType: ValueType;\n _value: unknown;\n _computation: unknown;\n _binding: unknown;\n};\n\nexport function toFullNotation(nodeSchema: unknown, valueType: ValueType): RawNode {\n const rawNode: RawNode = {\n _valueType: valueType,\n _value: null,\n _computation: null,\n _binding: null,\n };\n\n if (nodeSchema === null) {\n rawNode._value = null;\n return rawNode;\n }\n\n if (typeof nodeSchema === 'string') {\n if (nodeSchema.includes('{{') && nodeSchema.includes('}}')) {\n rawNode._computation = nodeSchema;\n return rawNode;\n }\n\n if (nodeSchema === '=>') {\n rawNode._value = '=>';\n return rawNode;\n }\n\n if (nodeSchema.startsWith('=> ')) {\n rawNode._computation = nodeSchema;\n return rawNode;\n }\n\n if (isBindingShorthand(nodeSchema)) {\n const binding = parseBindingShorthand(nodeSchema);\n if (binding) {\n rawNode._binding = binding;\n return rawNode;\n }\n }\n }\n\n if (Array.isArray(nodeSchema) && valueType.type === 'string') {\n const desugared = desugarStringArray(nodeSchema);\n return toFullNotation(desugared, valueType);\n }\n\n if (typeof nodeSchema !== 'object') {\n rawNode._value = nodeSchema;\n return rawNode;\n }\n\n if ('computationType' in nodeSchema) {\n rawNode._computation = nodeSchema;\n return rawNode;\n }\n\n if ('bindingType' in nodeSchema) {\n rawNode._binding = nodeSchema as BindingSchema;\n return rawNode;\n }\n\n const isFullNotation = ['_valueType', '_value', '_computation', '_binding'].some((key) => key in nodeSchema);\n if (isFullNotation) {\n if ('_value' in nodeSchema) rawNode._value = nodeSchema._value;\n if ('_computation' in nodeSchema) rawNode._computation = nodeSchema._computation;\n if ('_binding' in nodeSchema) rawNode._binding = nodeSchema._binding as BindingSchema;\n return rawNode;\n }\n\n // detect 'if' short notation\n // TODO: change to _if to isolate keyword)\n if ('if' in nodeSchema) {\n const computation: Record<string, unknown> = {\n computationType: 'if',\n if: nodeSchema.if,\n then: null,\n else: null,\n };\n\n if (!('then' in nodeSchema) && !('else' in nodeSchema)) {\n const { if: _, ...thenSchema } = nodeSchema;\n computation['then'] = thenSchema;\n } else {\n if ('then' in nodeSchema) {\n computation['then'] = nodeSchema['then'];\n }\n if ('else' in nodeSchema) {\n computation['else'] = nodeSchema['else'];\n }\n }\n\n rawNode._computation = computation;\n return rawNode;\n }\n\n // detect new 'for' syntax\n if ('for' in nodeSchema) {\n rawNode._computation = nodeSchema;\n return rawNode;\n }\n\n if ('templateUrl' in nodeSchema) {\n const schema = nodeSchema as TemplateRecipe;\n if (hasWrappers(schema)) {\n const [wrappers, cleanedSchema] = extractWrappers(schema);\n return unfoldFlatWrappers(wrappers, toFullNotation(cleanedSchema, valueType), rawNode);\n }\n\n const { templateUrl: path, ...rest } = nodeSchema;\n rawNode._computation = { computationType: 'template', path, ...rest };\n\n return rawNode;\n }\n\n if (hasWrappers(nodeSchema as ComponentRecipe)) {\n const [wrappers, cleanedSchema] = extractWrappers(nodeSchema as ComponentRecipe);\n return unfoldFlatWrappers(wrappers, toFullNotation(cleanedSchema, valueType), rawNode);\n }\n\n rawNode._value = nodeSchema;\n return rawNode;\n}\n\nfunction desugarStringArray(items: unknown[]): string {\n if (items.length === 0) return '';\n if (items.length === 1) return items[0] as string;\n\n for (const item of items) {\n if (typeof item !== 'string') {\n throw new Error(`styleClass array items must be strings, got ${typeof item}: ${JSON.stringify(item)}`);\n }\n }\n\n const strings = items as string[];\n const hasFormula = strings.some((s) => s.startsWith('=> '));\n\n if (!hasFormula) return strings.join(' ');\n\n const parts = strings.map((s) => (s.startsWith('=> ') ? s.slice(3) : `'${s}'`));\n return `=> concat([${parts.join(', ')}], ' ')`;\n}\n","import { stringifyObject } from '../../util/stringify-object';\nimport { UnfoldCtx } from './unfold-node-value';\n\nexport function throwUnfoldError(ctx: UnfoldCtx): never {\n let message = 'Error happened while unfolding node';\n if (ctx.nodePath) {\n message += `\\nPath: ${JSON.stringify(ctx.nodePath)}.`;\n }\n message += stringifyObject('ValueType', ctx.valueType);\n message += stringifyObject('Provided value', ctx.rawValue);\n\n throw new Error(message);\n}\n","import { throwUnfoldError } from '../throw-unfold-value-error';\nimport { UnfoldCtx } from '../unfold-node-value';\n\nexport const unfoldBoolean = (ctx: UnfoldCtx) => {\n if (typeof ctx.rawValue !== 'boolean') {\n throwUnfoldError(ctx);\n }\n return ctx.rawValue;\n};\n","import { throwUnfoldError } from '../throw-unfold-value-error';\nimport { UnfoldCtx } from '../unfold-node-value';\n\nexport function unfoldNumber(ctx: UnfoldCtx) {\n if (!isValidNumber(ctx.rawValue)) {\n throwUnfoldError(ctx);\n }\n return ctx.rawValue;\n}\n\nfunction isValidNumber(value: unknown) {\n return typeof value === 'number' && !isNaN(value);\n}\n","import { throwUnfoldError } from '../throw-unfold-value-error';\nimport { UnfoldCtx } from '../unfold-node-value';\n\nexport function unfoldString(ctx: UnfoldCtx) {\n if (typeof ctx.rawValue !== 'string') {\n throwUnfoldError(ctx);\n }\n return ctx.rawValue;\n}\n","import { UnfoldCtx } from '../unfold-node-value';\n\nexport function unfoldUnknown(ctx: UnfoldCtx) {\n return ctx.rawValue;\n}\n","import { ArrayValueType } from '@kaskad/types';\n\nimport { unfoldNodeSchema } from '../../unfold-node-schema';\nimport { throwUnfoldError } from '../throw-unfold-value-error';\nimport { UnfoldCtx } from '../unfold-node-value';\n\nexport function unfoldArray(ctx: UnfoldCtx<ArrayValueType>) {\n if (!Array.isArray(ctx.rawValue)) {\n throwUnfoldError(ctx);\n }\n\n return ctx.rawValue.map((item, index) => unfoldNodeSchema(item, ctx.valueType.item, [...ctx.nodePath, index]));\n}\n","import { MapValueType, NodeSchema } from '@kaskad/types';\n\nimport { isObject } from '../../../util/is-object';\nimport { unfoldNodeSchema } from '../../unfold-node-schema';\nimport { throwUnfoldError } from '../throw-unfold-value-error';\nimport { UnfoldCtx } from '../unfold-node-value';\n\nexport function unfoldMap(ctx: UnfoldCtx<MapValueType>) {\n if (!isObject(ctx.rawValue)) {\n throwUnfoldError(ctx);\n }\n return Object.entries(ctx.rawValue).reduce<Record<string, NodeSchema>>((structure, [key, child]) => {\n structure[key] = unfoldNodeSchema(child, ctx.valueType.item, [...ctx.nodePath, key]);\n return structure;\n }, {});\n}\n","import { NodeSchema, ObjectValueType } from '@kaskad/types';\n\nimport { isObject } from '../../../util/is-object';\nimport { unfoldNodeSchema } from '../../unfold-node-schema';\nimport { throwUnfoldError } from '../throw-unfold-value-error';\nimport { UnfoldCtx } from '../unfold-node-value';\n\nexport function unfoldObject(ctx: UnfoldCtx<ObjectValueType>) {\n if (!isObject(ctx.rawValue)) {\n throwUnfoldError(ctx);\n }\n\n const rawObject = ctx.rawValue as Record<string, unknown>;\n\n return Object.entries(ctx.valueType.fields).reduce<Record<string, NodeSchema>>(\n (structure, [fieldKey, fieldValueType]) => {\n const fieldValue = fieldKey in rawObject ? rawObject[fieldKey] : null;\n structure[fieldKey] = unfoldNodeSchema(fieldValue, fieldValueType, [...ctx.nodePath, fieldKey]);\n return structure;\n },\n {},\n );\n}\n","import { AnyFn, CommandValue, CommandValueType } from '@kaskad/types';\n\nimport { isObject } from '../../../util/is-object';\nimport { throwUnfoldError } from '../throw-unfold-value-error';\nimport { UnfoldCtx } from '../unfold-node-value';\n\nexport function unfoldCommand(ctx: UnfoldCtx<CommandValueType>): CommandValue {\n const rawValue = ctx.rawValue;\n\n if (typeof rawValue === 'string') {\n return { runnerType: 'js', target: rawValue, owner: null };\n }\n\n if (isObject(rawValue) && 'runnerType' in rawValue && 'target' in rawValue) {\n if (typeof rawValue['runnerType'] !== 'string') {\n throw new Error(`Command schema is invalid. Field \"runnerType\" must be string.`);\n }\n if (!rawValue['target']) {\n throw new Error(`Command schema is invalid. Field \"target\" must be defined.`);\n }\n return rawValue as CommandValue;\n }\n\n if (typeof rawValue === 'function') {\n return { runnerType: 'inline', target: rawValue as AnyFn, owner: null };\n }\n\n throwUnfoldError(ctx);\n}\n","import { Delimiters } from '@kaskad/config';\nimport { DefinitionStore } from '@kaskad/definition';\n\nimport { ComponentRecipe } from '../../../types/component-schema';\n\nexport function validateProps(rawSchema: ComponentRecipe) {\n const componentDefinitionProps = DefinitionStore.getInstance().getComputedComponentContract(rawSchema.componentType);\n const ignoredSchemaProps = new Set([\n 'componentType',\n 'onNodeChange',\n 'ref',\n 'contract',\n 'defaultSlot',\n 'context',\n 'types',\n 'importTypes',\n ]);\n\n const invalidProps = Object.keys(rawSchema).filter(\n (prop) => !componentDefinitionProps[prop] && !ignoredSchemaProps.has(prop) && !prop.startsWith(Delimiters.Variable),\n );\n\n if (invalidProps.length) {\n throw new Error(\n `Component schema \"${rawSchema.componentType}\" contains unknown properties: ${invalidProps.join(', ')}`,\n );\n }\n}\n","import { ComponentSchemaValueType } from '@kaskad/types';\n\nimport { ComponentRecipe } from '../../../types/component-schema';\nimport { isObject } from '../../../util/is-object';\nimport { UnfoldCtx } from '../unfold-node-value';\nimport { validateProps } from './validate-props';\n\nexport function unfoldComponentSchema(ctx: UnfoldCtx<ComponentSchemaValueType>) {\n if (!isObject(ctx.rawValue)) {\n throw new Error('Unfolded component schema type');\n }\n const componentRawSchema = ctx.rawValue as ComponentRecipe;\n\n if (!componentRawSchema.componentType) {\n componentRawSchema.componentType = 'browser.Element';\n }\n\n validateProps(componentRawSchema);\n\n return componentRawSchema;\n}\n","import { NodeSchema, ValueType } from '@kaskad/types';\n\nimport { isObject } from '../util/is-object';\nimport { parsePropertyKeyShorthand } from './parse-property-key-shorthand';\nimport { toFullNotation } from './to-full-notation';\nimport { isUnfoldedNodeSchema, unfoldNodeSchema } from './unfold-node-schema';\n\nexport function unfoldProperty(keyEx: string, rawSchema: unknown): [string, NodeSchema] {\n if (isUnfoldedNodeSchema(rawSchema)) {\n return [keyEx, rawSchema];\n }\n if (keyEx.includes('@')) {\n const [key, valueType] = parsePropertyKeyShorthand(keyEx);\n const nodeSchema = unfoldNodeSchema(toFullNotation(rawSchema, valueType), valueType, [key]);\n return [key, nodeSchema];\n }\n\n if (isObject(rawSchema) && '_valueType' in rawSchema) {\n const valueType = rawSchema['_valueType'] as ValueType; // TODO: check if valueType is valid\n const nodeSchema = unfoldNodeSchema(rawSchema, valueType, [keyEx]);\n return [keyEx, nodeSchema];\n }\n\n throw new Error(`Cannot unfold node schema. Invalid schema notation ${JSON.stringify(rawSchema)} for key \"${keyEx}\"`);\n}\n","import { Delimiters } from '@kaskad/config';\nimport { DefinitionStore } from '@kaskad/definition';\nimport { ComponentNodeValue, NodeChangeHandlerSchema, NodeSchema } from '@kaskad/types';\n\nimport { ComponentRecipe } from '../../../types/component-schema';\nimport { isObject } from '../../../util/is-object';\nimport { unfoldNodeSchema } from '../../unfold-node-schema';\nimport { unfoldProperty } from '../../unfold-property';\nimport { throwUnfoldError } from '../throw-unfold-value-error';\nimport { UnfoldCtx } from '../unfold-node-value';\nimport { validateProps } from './validate-props';\n\nexport function unfoldComponent(ctx: UnfoldCtx): ComponentNodeValue {\n if (typeof ctx.rawValue === 'string' && ctx.rawValue.startsWith('csid-')) {\n return ctx.rawValue;\n }\n if (!isObject(ctx.rawValue)) {\n throwUnfoldError(ctx);\n }\n\n const componentRawSchema = ctx.rawValue as ComponentRecipe;\n\n if (!componentRawSchema.componentType) {\n componentRawSchema.componentType = 'browser.Element';\n }\n\n validateProps(componentRawSchema);\n\n const properties = DefinitionStore.getInstance().getComputedComponentContract(componentRawSchema.componentType);\n\n const props = new Map<string, NodeSchema>();\n for (const [key, baseSchema] of Object.entries(properties)) {\n if (!(key in componentRawSchema)) {\n props.set(key, baseSchema);\n continue;\n }\n\n const unfoldedRawSchema = unfoldNodeSchema(componentRawSchema[key], baseSchema.valueType, [...ctx.nodePath, key]);\n\n const node = {\n valueType: baseSchema.valueType,\n value: unfoldedRawSchema.value ?? baseSchema.value,\n computation: unfoldedRawSchema.computation || baseSchema.computation,\n binding: unfoldedRawSchema.binding || baseSchema.binding,\n } as NodeSchema;\n\n props.set(key, node);\n }\n\n const variables = new Map<string, NodeSchema>();\n for (const [keyEx, schema] of Object.entries(componentRawSchema)) {\n if (!keyEx.startsWith(Delimiters.Variable)) {\n continue;\n }\n\n const variableKeyEx = keyEx.slice(Delimiters.Variable.length);\n const [key, unfolded] = unfoldProperty(variableKeyEx, schema);\n variables.set(key, unfolded);\n }\n\n const rawHandlers = componentRawSchema.onNodeChange || [];\n const onNodeChange: NodeChangeHandlerSchema[] = rawHandlers.map((handler) => {\n if (!handler.selector) {\n throw new Error(`onNodeChange handler \"${JSON.stringify(handler)}\" is missing required selector.`);\n }\n if (!handler.command) {\n throw new Error(`onNodeChange handler \"${JSON.stringify(handler)}\" is missing required command.`);\n }\n\n return {\n selector: handler.selector,\n command: unfoldNodeSchema(handler.command, { type: 'command' }, ctx.nodePath),\n };\n });\n\n return {\n componentType: componentRawSchema.componentType,\n ref: componentRawSchema.ref || '',\n props,\n variables,\n onNodeChange,\n };\n}\n","import { SetValueType } from '@kaskad/types';\n\nimport { unfoldNodeSchema } from '../../unfold-node-schema';\nimport { UnfoldCtx } from '../unfold-node-value';\n\nexport function unfoldSet(ctx: UnfoldCtx<SetValueType>) {\n const items =\n ctx.rawValue instanceof Set ? Array.from(ctx.rawValue) : Array.isArray(ctx.rawValue) ? ctx.rawValue : [];\n\n return items.map((item, index) => unfoldNodeSchema(item, ctx.valueType.item, [...ctx.nodePath, index]));\n}\n","import { DefinitionStore } from '@kaskad/definition';\nimport { ShapeValue, ShapeValueType } from '@kaskad/types';\n\nimport { isObject } from '../../../util/is-object';\nimport { throwUnfoldError } from '../throw-unfold-value-error';\nimport { UnfoldCtx } from '../unfold-node-value';\nimport { unfoldObject } from './unfold-object';\n\nexport function unfoldShape(ctx: UnfoldCtx<ShapeValueType>): ShapeValue {\n if (!isObject(ctx.rawValue)) {\n throwUnfoldError(ctx);\n }\n\n const rawValue = ctx.rawValue as Record<string, unknown>;\n const objectValueType = DefinitionStore.getInstance().getShape(ctx.valueType.shapeType);\n return unfoldObject({ rawValue, valueType: objectValueType, nodePath: ctx.nodePath });\n}\n","import { DefinitionStore } from '@kaskad/definition';\nimport { NodeSchema, VariantShapeValue, VariantShapeValueType } from '@kaskad/types';\n\nimport { isObject } from '../../../util/is-object';\nimport { unfoldNodeSchema } from '../../unfold-node-schema';\nimport { throwUnfoldError } from '../throw-unfold-value-error';\nimport { UnfoldCtx } from '../unfold-node-value';\n\nfunction unfoldShortValidatorSyntax(rawValue: Record<string, unknown>) {\n if ('validatorType' in rawValue) {\n return rawValue;\n }\n\n const entries = Object.entries(rawValue);\n const validatorEntries = entries.filter(([key]) => key !== 'message' && key !== 'disabled');\n\n if (validatorEntries.length === 0) {\n throw new Error(\n `Validator must have at least one validator type specified. Raw value: ${JSON.stringify(rawValue)}`,\n );\n }\n if (validatorEntries.length > 1) {\n throw new Error(`Validator can only have one validator type specified. Raw value: ${JSON.stringify(rawValue)}`);\n }\n\n const [validatorType, param] = validatorEntries[0];\n\n const validator = {\n validatorType,\n params: {},\n message: rawValue['message'] || '',\n disabled: !!rawValue['disabled'],\n };\n\n if (isObject(param)) {\n validator.params = param;\n } else {\n validator.params = { [validatorType]: param };\n }\n\n return validator;\n}\n\nexport function unfoldVariantShape(ctx: UnfoldCtx<VariantShapeValueType>): VariantShapeValue {\n if (!isObject(ctx.rawValue)) {\n throwUnfoldError(ctx);\n }\n\n let rawValue = ctx.rawValue as Record<string, unknown>;\n\n if ('kind' in rawValue && 'fields' in rawValue) {\n const kindKey = `${ctx.valueType.shapeType}Type`;\n const kind = rawValue['kind'] as string;\n const fields = rawValue['fields'] as Record<string, unknown>;\n\n return {\n ...fields,\n [kindKey]: kind,\n } as VariantShapeValue;\n }\n\n const kindKey = `${ctx.valueType.shapeType}Type`;\n\n if (kindKey === 'validatorType') {\n rawValue = unfoldShortValidatorSyntax(rawValue);\n }\n\n const kind = rawValue[kindKey] as string;\n\n if (!kind) {\n throw new Error(`Missing the kind field \"${kindKey}\"`);\n }\n\n const objectValueType = DefinitionStore.getInstance().getVariantShape(ctx.valueType.shapeType, kind);\n\n const objectNode = unfoldNodeSchema(rawValue, objectValueType, ctx.nodePath);\n return {\n ...(objectNode.value as Record<string, NodeSchema>),\n [kindKey]: kind,\n };\n}\n","import { NodePath, NodeSchema, ValueType } from '@kaskad/types';\n\nimport {\n unfoldArray,\n unfoldBoolean,\n unfoldCommand,\n unfoldComponent,\n unfoldComponentSchema,\n unfoldMap,\n unfoldNumber,\n unfoldObject,\n unfoldString,\n unfoldUnknown,\n} from './handlers';\nimport { unfoldSet } from './handlers/unfold-set';\nimport { unfoldShape } from './handlers/unfold-shape';\nimport { unfoldVariantShape } from './handlers/unfold-variant-shape';\n\nexport type UnfoldCtx<T extends ValueType = ValueType> = {\n rawValue: unknown;\n valueType: T;\n nodePath: NodePath;\n};\n\nexport type Handler = (ctx: UnfoldCtx) => NodeSchema['value'];\n\nconst handlers: Record<ValueType['type'], unknown> = {\n unknown: unfoldUnknown,\n number: unfoldNumber,\n string: unfoldString,\n boolean: unfoldBoolean,\n array: unfoldArray,\n map: unfoldMap,\n set: unfoldSet,\n object: unfoldObject,\n shape: unfoldShape,\n variantShape: unfoldVariantShape,\n command: unfoldCommand,\n componentSchema: unfoldComponentSchema,\n component: unfoldComponent,\n};\n\nexport function unfoldValue(ctx: UnfoldCtx) {\n const handler = handlers[ctx.valueType.type] as Handler;\n if (!handler) {\n throw new Error(`Cannot unfold value \"${ctx.rawValue}\". Unknown value type '${ctx.valueType.type}'`);\n }\n if (ctx.rawValue === undefined || ctx.rawValue === null) {\n return null;\n }\n return handler(ctx);\n}\n","import { BindingSchema, NodePath, NodeSchema, NodeSchemaBase, ValueType } from '@kaskad/types';\n\nimport { isObject } from '../util/is-object';\nimport { unfoldComputationSchema } from './computation/unfold-computation-schema';\nimport { toFullNotation } from './to-full-notation';\nimport { unfoldValue } from './value/unfold-node-value';\n\nexport function unfoldNodeSchema(rawSchema: unknown, valueType: ValueType, nodePath: NodePath = []): NodeSchema {\n if (isUnfoldedNodeSchema(rawSchema)) {\n return rawSchema;\n }\n\n const node: NodeSchemaBase = {\n valueType,\n value: null,\n computation: null,\n binding: null,\n [Symbol.for('type')]: 'NodeSchema',\n };\n\n const nodeSchema = toFullNotation(rawSchema, valueType);\n\n if ('_binding' in nodeSchema) {\n node.binding = nodeSchema['_binding'] as BindingSchema;\n }\n if ('_computation' in nodeSchema) {\n node.computation = unfoldComputationSchema(nodeSchema._computation);\n }\n if ('_value' in nodeSchema) {\n node.value = unfoldValue({\n rawValue: nodeSchema._value,\n valueType,\n nodePath,\n });\n }\n\n return node as NodeSchema;\n}\n\nexport function isUnfoldedNodeSchema(nodeSchema: unknown): nodeSchema is NodeSchema {\n return isObject(nodeSchema) && ['valueType', 'value', 'computation', 'binding'].every((key) => key in nodeSchema);\n}\n","import {\n ArrayNodeSchema,\n ComponentNodeSchema,\n ComponentSchemaNodeSchema,\n isForComputation,\n isIfComputation,\n isSwitchComputation,\n isTemplateComputation,\n NodeSchema,\n ObjectNodeSchema,\n} from '@kaskad/types';\n\nimport { isObject } from '../util/is-object';\n\nexport function extractComponentTypes(schema: NodeSchema, types: Set<string> = new Set()): Set<string> {\n extractFromValue(schema, types);\n extractFromComputations(schema, types);\n\n return types;\n}\n\nfunction extractFromValue(schema: NodeSchema, types: Set<string>) {\n if (!schema.value) {\n return types;\n }\n\n const type = schema.valueType.type;\n\n if (type === 'component') {\n const componentSchema = schema as ComponentNodeSchema;\n if (!isObject(componentSchema.value)) {\n return types;\n }\n\n types.add(componentSchema.value.componentType);\n\n for (const prop of componentSchema.value.props.values()) {\n extractComponentTypes(prop, types);\n }\n for (const variable of componentSchema.value.variables.values()) {\n extractComponentTypes(variable, types);\n }\n }\n\n if (type === 'componentSchema' || type === 'unknown') {\n const componentSchema = schema as ComponentSchemaNodeSchema;\n\n if (isObject(componentSchema.value) && 'componentType' in componentSchema.value) {\n extractFromRawComponentSchema(componentSchema.value, types);\n }\n }\n\n if (type === 'array') {\n const arraySchema = schema as ArrayNodeSchema;\n for (const item of arraySchema.value || []) {\n extractComponentTypes(item, types);\n }\n }\n\n if (type === 'object' || type === 'map') {\n const objectSchema = schema as ObjectNodeSchema;\n for (const prop of Object.values(objectSchema.value || {})) {\n extractComponentTypes(prop, types);\n }\n }\n\n return types;\n}\n\nfunction extractFromComputations(schema: NodeSchema, types: Set<string>) {\n if (!schema.computation) {\n return types;\n }\n\n if (isSwitchComputation(schema.computation)) {\n for (const caseItem of schema.computation.cases) {\n extractComponentTypes(caseItem.then, types);\n }\n extractComponentTypes(schema.computation.default, types);\n }\n\n if (isIfComputation(schema.computation)) {\n extractComponentTypes(schema.computation.then, types);\n extractComponentTypes(schema.computation.else, types);\n }\n\n if (isForComputation(schema.computation)) {\n extractComponentTypes(schema.computation.yield as NodeSchema, types);\n }\n\n if (isTemplateComputation(schema.computation)) {\n if (schema.computation.defer) {\n if (schema.computation.defer.placeholder) {\n extractComponentTypes(schema.computation.defer.placeholder, types);\n }\n if (schema.computation.defer.error) {\n extractComponentTypes(schema.computation.defer.error, types);\n }\n }\n\n for (const variable of Object.values(schema.computation.contractVariables)) {\n if (isObject(variable) || Array.isArray(variable)) {\n extractFromRawComponentSchema(variable, types);\n }\n }\n }\n\n return types;\n}\n\nfunction extractFromRawComponentSchema(schema: Record<string, unknown> | unknown[], types: Set<string>): Set<string> {\n if (Array.isArray(schema)) {\n for (const item of schema) {\n if (isObject(item) || Array.isArray(item)) {\n extractFromRawComponentSchema(item, types);\n }\n }\n return types;\n }\n\n if (isObject(schema)) {\n for (const [key, value] of Object.entries(schema)) {\n if (key === 'componentType' && typeof value === 'string') {\n types.add(value);\n }\n if (isObject(value) || Array.isArray(value)) {\n extractFromRawComponentSchema(value, types);\n }\n }\n }\n\n return types;\n}\n","import { TemplateRecipeDefinition } from '../types/template-raw-definition';\n\ninterface TemplateEntry {\n recipe: TemplateRecipeDefinition;\n ownComponentTypes: Set<string>;\n dependencies: Set<string>;\n}\n\nexport const templateRegistry = {\n entries: new Map<string, TemplateEntry>(),\n\n get(url: string): TemplateEntry | undefined {\n return this.entries.get(url);\n },\n\n getAggregatedComponentTypes(url: string): Set<string> {\n const aggregated = new Set<string>();\n const visited = new Set<string>();\n\n const collect = (currentUrl: string) => {\n if (visited.has(currentUrl)) return;\n visited.add(currentUrl);\n\n const entry = this.entries.get(currentUrl);\n if (!entry) return;\n\n // Add own component types\n for (const type of entry.ownComponentTypes) {\n aggregated.add(type);\n }\n\n // Recursively collect from dependencies\n for (const depUrl of entry.dependencies) {\n collect(depUrl);\n }\n };\n\n collect(url);\n return aggregated;\n },\n\n getAllComponentTypes(): Set<string> {\n const allTypes = new Set<string>();\n\n for (const entry of this.entries.values()) {\n for (const type of entry.ownComponentTypes) {\n allTypes.add(type);\n }\n }\n\n return allTypes;\n },\n\n set(url: string, recipe: TemplateRecipeDefinition, ownComponentTypes: Set<string>, dependencies?: Set<string>) {\n this.entries.set(url, {\n recipe,\n ownComponentTypes,\n dependencies: dependencies || new Set(),\n });\n },\n\n has(url: string): boolean {\n return this.entries.has(url);\n },\n\n reset() {\n this.entries.clear();\n },\n};\n","import { parse } from 'yaml';\n\nimport { TemplateRecipeDefinition } from '../types/template-raw-definition';\n\nexport const withBaseTemplateUrl = (url: string) => `/recipes/${url}.yml`;\n\nexport async function loadRecipe(url: string): Promise<TemplateRecipeDefinition> {\n const response = await fetch(withBaseTemplateUrl(url));\n\n if (response.status === 404) {\n throw new Error(`Schema not found: ${url}`);\n }\n\n const text = await response.text();\n try {\n return parse(text);\n } catch (e) {\n throw new Error(`Failed to parse YAML: ${e}`);\n }\n}\n","import { DefinitionStore } from '@kaskad/definition';\nimport { ObjectValueType, ValueType } from '@kaskad/types';\n\nimport { parseValueType } from '../unfolding/parse-value-type';\n\nexport function registerDeclaredType(name: string, definition: string | Record<string, string>): void {\n let properties: Record<string, ValueType>;\n\n if (typeof definition === 'string') {\n const parsed = parseValueType(definition);\n if (parsed.type !== 'object') {\n throw new Error(`Type \"${name}\" must be an object type, got \"${parsed.type}\"`);\n }\n properties = (parsed as ObjectValueType).fields;\n } else {\n properties = {};\n for (const [propName, propType] of Object.entries(definition)) {\n properties[propName] = parseValueType(propType);\n }\n }\n\n const store = DefinitionStore.getInstance();\n const existing = store.shapes[name];\n\n if (existing && !isEqualType(existing.properties, properties)) {\n throw new Error(`Type \"${name}\" is already defined with a different shape`);\n }\n\n store.setShape(name, properties);\n}\n\nfunction isEqualType(a: Record<string, ValueType>, b: Record<string, ValueType>): boolean {\n return JSON.stringify(a) === JSON.stringify(b);\n}\n","import { log } from '@kaskad/config';\n\nimport { ComponentRecipe, TemplateRecipe } from '../types/component-schema';\nimport { TemplateRecipeDefinition } from '../types/template-raw-definition';\nimport { PathSymbol, WrapperPrefix } from '../unfolding/unfold-flat-wrapper-notation';\nimport { unfoldNodeSchema } from '../unfolding/unfold-node-schema';\nimport { isObject } from '../util/is-object';\nimport { loadRecipe } from './load-schema';\nimport { registerDeclaredType } from './register-declared-type';\nimport { extractComponentTypes } from './schema-component-extractor';\nimport { templateRegistry } from './template-registry';\n\nconst reservedKeys = new Set(['importTypes', 'types', 'contract', 'defaultSlot']);\n\nfunction isTypeOnlyTemplate(template: Record<string, unknown>): boolean {\n const contentKeys = Object.keys(template).filter((k) => !reservedKeys.has(k));\n return contentKeys.length > 0 && contentKeys.every((k) => k.includes('.'));\n}\n\nexport async function loadTemplates(recipe: TemplateRecipe | ComponentRecipe) {\n // Pass 1: Recursively load all templates and register types immediately\n const allTemplates = new Map<string, TemplateRecipeDefinition>();\n await collectAllTemplates(recipe, allTemplates);\n\n // Register types from the root recipe (after all dependencies are loaded)\n const rootTypes = (recipe as TemplateRecipeDefinition).types;\n if (rootTypes) {\n for (const [key, value] of Object.entries(rootTypes)) {\n if (typeof value === 'string' || isObject(value)) {\n registerDeclaredType(key, value as string | Record<string, string>);\n }\n }\n }\n\n // Pass 2: Unfold and register all templates (types are already registered)\n for (const [url, template] of allTemplates) {\n try {\n const {\n types: _types,\n importTypes: _importTypes,\n contract: _contract,\n defaultSlot: _defaultSlot,\n ...rootRawSchema\n } = template;\n\n // Skip unfolding for type-only templates (all keys are namespaced)\n if (isTypeOnlyTemplate(template)) {\n templateRegistry.set(url, template, new Set(), extractUrls(template));\n continue;\n }\n\n const schema = unfoldNodeSchema(rootRawSchema, { type: 'component' });\n const componentTypes = extractComponentTypes(schema);\n const dependencies = extractUrls(template);\n templateRegistry.set(url, template, componentTypes, dependencies);\n } catch (e) {\n log.error(`Failed to resolve template: ${url}`, e);\n throw new Error(`Failed to resolve template: ${url}`, { cause: e });\n }\n }\n}\n\nasync function collectAllTemplates(\n recipe: TemplateRecipe | ComponentRecipe,\n collected: Map<string, TemplateRecipeDefinition>,\n): Promise<void> {\n const urls = extractUrls(recipe);\n const newUrls = Array.from(urls).filter((url) => !templateRegistry.has(url) && !collected.has(url));\n\n if (newUrls.length === 0) return;\n\n const templates = await Promise.all(newUrls.map((url) => loadRecipe(url)));\n\n // Register types immediately after loading (before recursive collection)\n const pending = new Map<string, string | Record<string, string>>();\n\n for (const template of templates) {\n const isTypeOnlyFile = isTypeOnlyTemplate(template);\n const typesToRegister = isTypeOnlyFile ? template : (template.types ?? {});\n\n for (const [key, value] of Object.entries(typesToRegister)) {\n if (key === 'importTypes') continue;\n\n if (isTypeOnlyFile && !key.includes('.')) {\n throw new Error(`Invalid key \"${key}\" in type-only file. Type names must be namespaced (e.g., \"app.MyType\")`);\n }\n\n if (typeof value !== 'string' && !isObject(value)) {\n throw new Error(`Invalid type definition for \"${key}\". Expected string or object, got ${typeof value}`);\n }\n\n pending.set(key, value as string | Record<string, string>);\n }\n }\n\n // Register with retries to handle forward references between types\n let lastSize = -1;\n while (pending.size > 0 && pending.size !== lastSize) {\n lastSize = pending.size;\n for (const [key, value] of pending) {\n try {\n registerDeclaredType(key, value);\n pending.delete(key);\n } catch {\n // Will retry after other types are registered\n }\n }\n }\n\n for (const [key, value] of pending) {\n try {\n registerDeclaredType(key, value);\n } catch (e) {\n throw new Error(`Failed to register type \"${key}\"`, { cause: e });\n }\n }\n\n for (let i = 0; i < newUrls.length; i++) {\n collected.set(newUrls[i], templates[i]);\n }\n\n // Recursively collect from loaded templates\n await Promise.all(templates.map((t) => collectAllTemplates(t, collected)));\n}\n\nfunction extractUrls(value: unknown, urls: Set<string> = new Set()): Set<string> {\n if (value == null) return urls;\n\n if (Array.isArray(value)) {\n value.forEach((item) => extractUrls(item, urls));\n return urls;\n }\n\n if (!isObject(value)) return urls;\n\n if ('_defer' in value) return urls;\n\n for (const [key, val] of Object.entries(value)) {\n if (key.startsWith(WrapperPrefix) && key.includes(PathSymbol)) {\n urls.add(key.slice(1));\n }\n\n if (key === 'importTypes') {\n if (!Array.isArray(val)) {\n throw new Error(`\"importTypes\" must be an array, got ${typeof val}`);\n }\n for (const url of val) {\n if (typeof url !== 'string') {\n throw new Error(`\"importTypes\" entries must be strings, got ${typeof url}`);\n }\n urls.add(url);\n }\n continue;\n }\n\n if (typeof val !== 'string') {\n extractUrls(val, urls);\n continue;\n }\n\n if (key === 'templateUrl') {\n urls.add(val);\n }\n\n extractUrls(val, urls);\n }\n\n return urls;\n}\n","import { ComponentDefinition } from '@kaskad/definition';\nimport { NodeSchema } from '@kaskad/types';\n\nimport { ComponentRawDefinition } from '../types/component-definition';\nimport { unfoldProperty } from '../unfolding/unfold-property';\n\nexport function unfoldComponentDefinition(rawDefinition: ComponentRawDefinition): ComponentDefinition {\n const properties: Record<string, NodeSchema> = {};\n\n for (const entry of Object.entries(rawDefinition.properties)) {\n const [key, prop] = unfoldProperty(...entry);\n properties[key] = prop;\n }\n\n return {\n traits: rawDefinition.traits,\n properties,\n defaultSlot: rawDefinition.defaultSlot,\n };\n}\n\nexport function unfoldComponentDefinitions(\n rawDefinitions: Record<string, ComponentRawDefinition>,\n): Record<string, ComponentDefinition> {\n const result: Record<string, ComponentDefinition> = {};\n\n for (const [componentType, rawDefinition] of Object.entries(rawDefinitions)) {\n result[componentType] = unfoldComponentDefinition(rawDefinition);\n }\n\n return result;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["unfoldFor","unfoldTemplate","unfoldIf"],"mappings":";;;;;AAAA;AACA;;ACDM,SAAU,QAAQ,CAAC,KAAc,EAAA;IACrC,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,YAAY,GAAG,CAAC;AACxG;;ACFM,SAAU,eAAe,CAAC,KAAa,EAAE,IAAa,EAAA;AAC1D,IAAA,OAAO,CAAA,EAAA,EAAK,KAAK,CAAA,GAAA,EAAM,IAAI,CAAC,SAAS,CAAC,IAAI,EA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AAM,UAAU,GAA+B,EAAE;AAEjD,IAAA,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE;QAC5D,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,cAAc,CAAC,GAAG,KAAK,CAAC;AAC5C,QAAA,UAAU,CAAC,GAAG,CAAC,GAAG,IAAI;;IAGxB,OAAO;QACL,MAAM,EAAE,aAAa,CAAC,MAAM;QAC5B,UAAU;QACV,WAAW,EAAE,aAAa,CAAC,WAAW;KACvC;AACH;AAEM,SAAU,0BAA0B,CACxC,cAAsD,EAAA;IAEtD,MAAM,MAAM,GAAwC,EAAE;AAEtD,IAAA,KAAK,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE;QAC3E,MAAM,CAAC,aAAa,CAAC,GAAG,yBAAyB,CAAC,aAAa,CAAC;;AAGlE,IAAA,OAAO,MAAM;AACf;;AC/BA;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,28 +1,28 @@
1
1
  {
2
2
  "name": "@kaskad/schema",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "peerDependencies": {
5
- "@kaskad/types": "0.0.1",
6
- "@kaskad/definition": "0.0.1",
7
- "@kaskad/config": "0.0.1",
5
+ "@kaskad/types": "0.0.2",
6
+ "@kaskad/definition": "0.0.2",
7
+ "@kaskad/config": "0.0.2",
8
8
  "yaml": "2.8.1",
9
9
  "@angular/core": "21.1.3",
10
10
  "vite": "7.3.1",
11
11
  "@nx/vite": "22.4.5"
12
12
  },
13
13
  "sideEffects": false,
14
- "module": "esm2022/kaskad-schema.js",
15
- "typings": "kaskad-schema.d.ts",
14
+ "module": "fesm2022/kaskad-schema.mjs",
15
+ "typings": "types/kaskad-schema.d.ts",
16
16
  "exports": {
17
17
  "./package.json": {
18
18
  "default": "./package.json"
19
19
  },
20
20
  ".": {
21
- "types": "./kaskad-schema.d.ts",
22
- "default": "./esm2022/kaskad-schema.js"
21
+ "types": "./types/kaskad-schema.d.ts",
22
+ "default": "./fesm2022/kaskad-schema.mjs"
23
23
  }
24
24
  },
25
25
  "dependencies": {
26
26
  "tslib": "^2.3.0"
27
27
  }
28
- }
28
+ }
@@ -0,0 +1,125 @@
1
+ import { ComponentRef, ValueType, NodePath, NodeSchema } from '@kaskad/types';
2
+ import { ComponentDefinition } from '@kaskad/definition';
3
+
4
+ type Defer = {
5
+ placeholder?: {
6
+ componentType: string;
7
+ } & {
8
+ [key: string]: unknown;
9
+ };
10
+ error?: {
11
+ componentType: string;
12
+ } & {
13
+ [key: string]: unknown;
14
+ };
15
+ };
16
+ interface NodeChangeHandlerRecipe {
17
+ selector: string;
18
+ command: unknown;
19
+ }
20
+ interface ComponentRecipe {
21
+ ref?: ComponentRef;
22
+ componentType: string;
23
+ onNodeChange?: NodeChangeHandlerRecipe[];
24
+ [propOrVariable: string]: unknown;
25
+ }
26
+ type TemplateRecipe = Omit<ComponentRecipe, 'componentType'> & {
27
+ templateUrl: string;
28
+ };
29
+
30
+ type FormulaComputationRecipe = {
31
+ formula: string;
32
+ };
33
+ type ForComputationRecipe = {
34
+ items: unknown[];
35
+ as?: {
36
+ item: unknown;
37
+ index: unknown;
38
+ first?: unknown;
39
+ last?: unknown;
40
+ };
41
+ yield: unknown;
42
+ };
43
+ type IfComputationRecipe = Record<'if' | 'then' | 'else', unknown> | ({
44
+ if: unknown;
45
+ } & Record<string, unknown>);
46
+ type SwitchComputationRecipe = {
47
+ computationType: 'switch';
48
+ source: unknown;
49
+ cases: {
50
+ equals: unknown;
51
+ then: unknown;
52
+ }[];
53
+ default: unknown;
54
+ };
55
+
56
+ type ComponentRawDefinition = {
57
+ readonly traits?: string[];
58
+ readonly properties: Record<string, unknown>;
59
+ readonly defaultSlot?: string;
60
+ };
61
+
62
+ interface TemplateRecipeDefinition extends ComponentRecipe {
63
+ types?: Record<string, string | Record<string, string>>;
64
+ importTypes?: string[];
65
+ contract?: Record<string, string>;
66
+ defaultSlot?: string;
67
+ }
68
+
69
+ declare function unfoldNodeSchema(rawSchema: unknown, valueType: ValueType, nodePath?: NodePath): NodeSchema;
70
+ declare function isUnfoldedNodeSchema(nodeSchema: unknown): nodeSchema is NodeSchema;
71
+
72
+ declare function unfoldProperty(keyEx: string, rawSchema: unknown): [string, NodeSchema];
73
+
74
+ type RawNode = {
75
+ _valueType: ValueType;
76
+ _value: unknown;
77
+ _computation: unknown;
78
+ _binding: unknown;
79
+ };
80
+ declare function toFullNotation(nodeSchema: unknown, valueType: ValueType): RawNode;
81
+
82
+ type WrapperEntity = [string, Record<string, unknown>];
83
+ type ComposedSchema = ComponentRecipe | RawNode | {
84
+ computationType: string;
85
+ [x: string]: unknown;
86
+ };
87
+ declare const WrapperPrefix = "+";
88
+ declare const PathSymbol = "/";
89
+ declare function unfoldFlatWrappers(wrappers: WrapperEntity[], schema: ComposedSchema, resultingNode: RawNode): RawNode;
90
+ declare function extractWrappers(schema: ComponentRecipe | TemplateRecipe): [WrapperEntity[], ComponentRecipe | TemplateRecipe];
91
+ declare function hasWrappers(schema: ComponentRecipe | TemplateRecipe): boolean;
92
+
93
+ declare function parseValueType(type: string): ValueType;
94
+
95
+ declare function extractComponentTypes(schema: NodeSchema, types?: Set<string>): Set<string>;
96
+
97
+ interface TemplateEntry {
98
+ recipe: TemplateRecipeDefinition;
99
+ ownComponentTypes: Set<string>;
100
+ dependencies: Set<string>;
101
+ }
102
+ declare const templateRegistry: {
103
+ entries: Map<string, TemplateEntry>;
104
+ get(url: string): TemplateEntry | undefined;
105
+ getAggregatedComponentTypes(url: string): Set<string>;
106
+ getAllComponentTypes(): Set<string>;
107
+ set(url: string, recipe: TemplateRecipeDefinition, ownComponentTypes: Set<string>, dependencies?: Set<string>): void;
108
+ has(url: string): boolean;
109
+ reset(): void;
110
+ };
111
+
112
+ declare function loadTemplates(recipe: TemplateRecipe | ComponentRecipe): Promise<void>;
113
+
114
+ declare const withBaseTemplateUrl: (url: string) => string;
115
+ declare function loadRecipe(url: string): Promise<TemplateRecipeDefinition>;
116
+
117
+ declare function registerDeclaredType(name: string, definition: string | Record<string, string>): void;
118
+
119
+ declare function unfoldComponentDefinition(rawDefinition: ComponentRawDefinition): ComponentDefinition;
120
+ declare function unfoldComponentDefinitions(rawDefinitions: Record<string, ComponentRawDefinition>): Record<string, ComponentDefinition>;
121
+
122
+ declare function isObject(value: unknown): value is Record<string, unknown>;
123
+
124
+ export { PathSymbol, WrapperPrefix, extractComponentTypes, extractWrappers, hasWrappers, isObject, isUnfoldedNodeSchema, loadRecipe, loadTemplates, parseValueType, registerDeclaredType, templateRegistry, toFullNotation, unfoldComponentDefinition, unfoldComponentDefinitions, unfoldFlatWrappers, unfoldNodeSchema, unfoldProperty, withBaseTemplateUrl };
125
+ export type { ComponentRawDefinition, ComponentRecipe, Defer, ForComputationRecipe, FormulaComputationRecipe, IfComputationRecipe, NodeChangeHandlerRecipe, RawNode, SwitchComputationRecipe, TemplateRecipe, TemplateRecipeDefinition };
package/esm2022/index.js DELETED
@@ -1,17 +0,0 @@
1
- export * from './lib/types/component-schema';
2
- export * from './lib/types/raw-schemas';
3
- export * from './lib/types/component-definition';
4
- export * from './lib/types/template-raw-definition';
5
- export * from './lib/unfolding/unfold-node-schema';
6
- export * from './lib/unfolding/unfold-property';
7
- export * from './lib/unfolding/unfold-flat-wrapper-notation';
8
- export * from './lib/unfolding/parse-value-type';
9
- export * from './lib/unfolding/to-full-notation';
10
- export * from './lib/load/schema-component-extractor';
11
- export * from './lib/load/template-registry';
12
- export * from './lib/load/load-templates';
13
- export * from './lib/load/load-schema';
14
- export * from './lib/load/register-declared-type';
15
- export * from './lib/util/unfold-component-definitions';
16
- export * from './lib/util/is-object';
17
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/schema/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,kCAAkC,CAAC;AACjD,cAAc,qCAAqC,CAAC;AACpD,cAAc,oCAAoC,CAAC;AACnD,cAAc,iCAAiC,CAAC;AAChD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,uCAAuC,CAAC;AACtD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,mCAAmC,CAAC;AAClD,cAAc,yCAAyC,CAAC;AACxD,cAAc,sBAAsB,CAAC","sourcesContent":["export * from './lib/types/component-schema';\nexport * from './lib/types/raw-schemas';\nexport * from './lib/types/component-definition';\nexport * from './lib/types/template-raw-definition';\nexport * from './lib/unfolding/unfold-node-schema';\nexport * from './lib/unfolding/unfold-property';\nexport * from './lib/unfolding/unfold-flat-wrapper-notation';\nexport * from './lib/unfolding/parse-value-type';\nexport * from './lib/unfolding/to-full-notation';\nexport * from './lib/load/schema-component-extractor';\nexport * from './lib/load/template-registry';\nexport * from './lib/load/load-templates';\nexport * from './lib/load/load-schema';\nexport * from './lib/load/register-declared-type';\nexport * from './lib/util/unfold-component-definitions';\nexport * from './lib/util/is-object';\n"]}
@@ -1,5 +0,0 @@
1
- /**
2
- * Generated bundle index. Do not edit.
3
- */
4
- export * from './index';
5
- //# sourceMappingURL=kaskad-schema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"kaskad-schema.js","sourceRoot":"","sources":["../../../../libs/schema/src/kaskad-schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAC","sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"]}
@@ -1,16 +0,0 @@
1
- import { parse } from 'yaml';
2
- export const withBaseTemplateUrl = (url) => `/recipes/${url}.yml`;
3
- export async function loadRecipe(url) {
4
- const response = await fetch(withBaseTemplateUrl(url));
5
- if (response.status === 404) {
6
- throw new Error(`Schema not found: ${url}`);
7
- }
8
- const text = await response.text();
9
- try {
10
- return parse(text);
11
- }
12
- catch (e) {
13
- throw new Error(`Failed to parse YAML: ${e}`);
14
- }
15
- }
16
- //# sourceMappingURL=load-schema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"load-schema.js","sourceRoot":"","sources":["../../../../../../libs/schema/src/lib/load/load-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAI7B,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,YAAY,GAAG,MAAM,CAAC;AAE1E,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAW;IAC1C,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC;IAEvD,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACnC,IAAI,CAAC;QACH,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,EAAE,CAAC,CAAC;IAChD,CAAC;AACH,CAAC","sourcesContent":["import { parse } from 'yaml';\n\nimport { TemplateRecipeDefinition } from '../types/template-raw-definition';\n\nexport const withBaseTemplateUrl = (url: string) => `/recipes/${url}.yml`;\n\nexport async function loadRecipe(url: string): Promise<TemplateRecipeDefinition> {\n const response = await fetch(withBaseTemplateUrl(url));\n\n if (response.status === 404) {\n throw new Error(`Schema not found: ${url}`);\n }\n\n const text = await response.text();\n try {\n return parse(text);\n } catch (e) {\n throw new Error(`Failed to parse YAML: ${e}`);\n }\n}\n"]}
@@ -1,136 +0,0 @@
1
- import { log } from '@kaskad/config';
2
- import { PathSymbol, WrapperPrefix } from '../unfolding/unfold-flat-wrapper-notation';
3
- import { unfoldNodeSchema } from '../unfolding/unfold-node-schema';
4
- import { isObject } from '../util/is-object';
5
- import { loadRecipe } from './load-schema';
6
- import { registerDeclaredType } from './register-declared-type';
7
- import { extractComponentTypes } from './schema-component-extractor';
8
- import { templateRegistry } from './template-registry';
9
- const reservedKeys = new Set(['importTypes', 'types', 'contract', 'defaultSlot']);
10
- function isTypeOnlyTemplate(template) {
11
- const contentKeys = Object.keys(template).filter((k) => !reservedKeys.has(k));
12
- return contentKeys.length > 0 && contentKeys.every((k) => k.includes('.'));
13
- }
14
- export async function loadTemplates(recipe) {
15
- // Pass 1: Recursively load all templates and register types immediately
16
- const allTemplates = new Map();
17
- await collectAllTemplates(recipe, allTemplates);
18
- // Register types from the root recipe (after all dependencies are loaded)
19
- const rootTypes = recipe.types;
20
- if (rootTypes) {
21
- for (const [key, value] of Object.entries(rootTypes)) {
22
- if (typeof value === 'string' || isObject(value)) {
23
- registerDeclaredType(key, value);
24
- }
25
- }
26
- }
27
- // Pass 2: Unfold and register all templates (types are already registered)
28
- for (const [url, template] of allTemplates) {
29
- try {
30
- const { types: _types, importTypes: _importTypes, contract: _contract, defaultSlot: _defaultSlot, ...rootRawSchema } = template;
31
- // Skip unfolding for type-only templates (all keys are namespaced)
32
- if (isTypeOnlyTemplate(template)) {
33
- templateRegistry.set(url, template, new Set(), extractUrls(template));
34
- continue;
35
- }
36
- const schema = unfoldNodeSchema(rootRawSchema, { type: 'component' });
37
- const componentTypes = extractComponentTypes(schema);
38
- const dependencies = extractUrls(template);
39
- templateRegistry.set(url, template, componentTypes, dependencies);
40
- }
41
- catch (e) {
42
- log.error(`Failed to resolve template: ${url}`, e);
43
- throw new Error(`Failed to resolve template: ${url}`, { cause: e });
44
- }
45
- }
46
- }
47
- async function collectAllTemplates(recipe, collected) {
48
- const urls = extractUrls(recipe);
49
- const newUrls = Array.from(urls).filter((url) => !templateRegistry.has(url) && !collected.has(url));
50
- if (newUrls.length === 0)
51
- return;
52
- const templates = await Promise.all(newUrls.map((url) => loadRecipe(url)));
53
- // Register types immediately after loading (before recursive collection)
54
- const pending = new Map();
55
- for (const template of templates) {
56
- const isTypeOnlyFile = isTypeOnlyTemplate(template);
57
- const typesToRegister = isTypeOnlyFile ? template : (template.types ?? {});
58
- for (const [key, value] of Object.entries(typesToRegister)) {
59
- if (key === 'importTypes')
60
- continue;
61
- if (isTypeOnlyFile && !key.includes('.')) {
62
- throw new Error(`Invalid key "${key}" in type-only file. Type names must be namespaced (e.g., "app.MyType")`);
63
- }
64
- if (typeof value !== 'string' && !isObject(value)) {
65
- throw new Error(`Invalid type definition for "${key}". Expected string or object, got ${typeof value}`);
66
- }
67
- pending.set(key, value);
68
- }
69
- }
70
- // Register with retries to handle forward references between types
71
- let lastSize = -1;
72
- while (pending.size > 0 && pending.size !== lastSize) {
73
- lastSize = pending.size;
74
- for (const [key, value] of pending) {
75
- try {
76
- registerDeclaredType(key, value);
77
- pending.delete(key);
78
- }
79
- catch {
80
- // Will retry after other types are registered
81
- }
82
- }
83
- }
84
- for (const [key, value] of pending) {
85
- try {
86
- registerDeclaredType(key, value);
87
- }
88
- catch (e) {
89
- throw new Error(`Failed to register type "${key}"`, { cause: e });
90
- }
91
- }
92
- for (let i = 0; i < newUrls.length; i++) {
93
- collected.set(newUrls[i], templates[i]);
94
- }
95
- // Recursively collect from loaded templates
96
- await Promise.all(templates.map((t) => collectAllTemplates(t, collected)));
97
- }
98
- function extractUrls(value, urls = new Set()) {
99
- if (value == null)
100
- return urls;
101
- if (Array.isArray(value)) {
102
- value.forEach((item) => extractUrls(item, urls));
103
- return urls;
104
- }
105
- if (!isObject(value))
106
- return urls;
107
- if ('_defer' in value)
108
- return urls;
109
- for (const [key, val] of Object.entries(value)) {
110
- if (key.startsWith(WrapperPrefix) && key.includes(PathSymbol)) {
111
- urls.add(key.slice(1));
112
- }
113
- if (key === 'importTypes') {
114
- if (!Array.isArray(val)) {
115
- throw new Error(`"importTypes" must be an array, got ${typeof val}`);
116
- }
117
- for (const url of val) {
118
- if (typeof url !== 'string') {
119
- throw new Error(`"importTypes" entries must be strings, got ${typeof url}`);
120
- }
121
- urls.add(url);
122
- }
123
- continue;
124
- }
125
- if (typeof val !== 'string') {
126
- extractUrls(val, urls);
127
- continue;
128
- }
129
- if (key === 'templateUrl') {
130
- urls.add(val);
131
- }
132
- extractUrls(val, urls);
133
- }
134
- return urls;
135
- }
136
- //# sourceMappingURL=load-templates.js.map