@cratis/scene.engine 4.2.1 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (311) hide show
  1. package/dist/cjs/editing/DescriptorCatalog.js +42 -0
  2. package/dist/cjs/editing/DescriptorCatalog.js.map +1 -0
  3. package/dist/cjs/editing/EditSession.js +44 -0
  4. package/dist/cjs/editing/EditSession.js.map +1 -0
  5. package/dist/cjs/editing/applyEdit.js +83 -0
  6. package/dist/cjs/editing/applyEdit.js.map +1 -0
  7. package/dist/cjs/editing/applyEffectiveConfiguration.js +62 -0
  8. package/dist/cjs/editing/applyEffectiveConfiguration.js.map +1 -0
  9. package/dist/cjs/editing/collectComponents.js +34 -0
  10. package/dist/cjs/editing/collectComponents.js.map +1 -0
  11. package/dist/cjs/editing/collectIconUsages.js +86 -0
  12. package/dist/cjs/editing/collectIconUsages.js.map +1 -0
  13. package/dist/cjs/editing/describeNode.js +63 -0
  14. package/dist/cjs/editing/describeNode.js.map +1 -0
  15. package/dist/cjs/editing/diagnoseIcons.js +67 -0
  16. package/dist/cjs/editing/diagnoseIcons.js.map +1 -0
  17. package/dist/cjs/editing/diagnostics.js +36 -0
  18. package/dist/cjs/editing/diagnostics.js.map +1 -0
  19. package/dist/cjs/editing/documentPaths.js +45 -0
  20. package/dist/cjs/editing/documentPaths.js.map +1 -0
  21. package/dist/cjs/editing/exposureEdits.js +106 -0
  22. package/dist/cjs/editing/exposureEdits.js.map +1 -0
  23. package/dist/cjs/editing/exposureGrants.js +115 -0
  24. package/dist/cjs/editing/exposureGrants.js.map +1 -0
  25. package/dist/cjs/editing/iconDiagnostics.js +103 -0
  26. package/dist/cjs/editing/iconDiagnostics.js.map +1 -0
  27. package/dist/cjs/editing/indexDocument.js +400 -0
  28. package/dist/cjs/editing/indexDocument.js.map +1 -0
  29. package/dist/cjs/editing/inspect.js +154 -0
  30. package/dist/cjs/editing/inspect.js.map +1 -0
  31. package/dist/cjs/editing/instanceEdits.js +267 -0
  32. package/dist/cjs/editing/instanceEdits.js.map +1 -0
  33. package/dist/cjs/editing/layoutTypeDescriptors.js +425 -0
  34. package/dist/cjs/editing/layoutTypeDescriptors.js.map +1 -0
  35. package/dist/cjs/editing/layoutTypeEdits.js +141 -0
  36. package/dist/cjs/editing/layoutTypeEdits.js.map +1 -0
  37. package/dist/cjs/editing/nodeIds.js +115 -0
  38. package/dist/cjs/editing/nodeIds.js.map +1 -0
  39. package/dist/cjs/editing/pathAccess.js +53 -0
  40. package/dist/cjs/editing/pathAccess.js.map +1 -0
  41. package/dist/cjs/editing/propertyEdits.js +125 -0
  42. package/dist/cjs/editing/propertyEdits.js.map +1 -0
  43. package/dist/cjs/editing/resolveEffectiveConfiguration.js +200 -0
  44. package/dist/cjs/editing/resolveEffectiveConfiguration.js.map +1 -0
  45. package/dist/cjs/editing/resolveTemplateChain.js +100 -0
  46. package/dist/cjs/editing/resolveTemplateChain.js.map +1 -0
  47. package/dist/cjs/editing/structureEdits.js +231 -0
  48. package/dist/cjs/editing/structureEdits.js.map +1 -0
  49. package/dist/cjs/editing/validateBinding.js +111 -0
  50. package/dist/cjs/editing/validateBinding.js.map +1 -0
  51. package/dist/cjs/editing/validateValue.js +114 -0
  52. package/dist/cjs/editing/validateValue.js.map +1 -0
  53. package/dist/cjs/icons/EffectiveIconCatalog.js +212 -0
  54. package/dist/cjs/icons/EffectiveIconCatalog.js.map +1 -0
  55. package/dist/cjs/icons/EffectiveIconEntry.js +22 -0
  56. package/dist/cjs/icons/EffectiveIconEntry.js.map +1 -0
  57. package/dist/cjs/icons/analyzeIconImpact.js +48 -0
  58. package/dist/cjs/icons/analyzeIconImpact.js.map +1 -0
  59. package/dist/cjs/icons/matchesIconQuery.js +22 -0
  60. package/dist/cjs/icons/matchesIconQuery.js.map +1 -0
  61. package/dist/cjs/icons/resolveIconLibraries.js +45 -0
  62. package/dist/cjs/icons/resolveIconLibraries.js.map +1 -0
  63. package/dist/cjs/index.js +67 -0
  64. package/dist/cjs/index.js.map +1 -1
  65. package/dist/esm/editing/DescriptorCatalog.d.ts +9 -0
  66. package/dist/esm/editing/DescriptorCatalog.d.ts.map +1 -0
  67. package/dist/esm/editing/DescriptorCatalog.js +38 -0
  68. package/dist/esm/editing/DescriptorCatalog.js.map +1 -0
  69. package/dist/esm/editing/DocumentIndex.d.ts +31 -0
  70. package/dist/esm/editing/DocumentIndex.d.ts.map +1 -0
  71. package/dist/esm/editing/DocumentIndex.js +2 -0
  72. package/dist/esm/editing/DocumentIndex.js.map +1 -0
  73. package/dist/esm/editing/EditOutcome.d.ts +7 -0
  74. package/dist/esm/editing/EditOutcome.d.ts.map +1 -0
  75. package/dist/esm/editing/EditOutcome.js +2 -0
  76. package/dist/esm/editing/EditOutcome.js.map +1 -0
  77. package/dist/esm/editing/EditSession.d.ts +20 -0
  78. package/dist/esm/editing/EditSession.d.ts.map +1 -0
  79. package/dist/esm/editing/EditSession.js +42 -0
  80. package/dist/esm/editing/EditSession.js.map +1 -0
  81. package/dist/esm/editing/EditingContext.d.ts +10 -0
  82. package/dist/esm/editing/EditingContext.d.ts.map +1 -0
  83. package/dist/esm/editing/EditingContext.js +2 -0
  84. package/dist/esm/editing/EditingContext.js.map +1 -0
  85. package/dist/esm/editing/TemplateChain.d.ts +13 -0
  86. package/dist/esm/editing/TemplateChain.d.ts.map +1 -0
  87. package/dist/esm/editing/TemplateChain.js +2 -0
  88. package/dist/esm/editing/TemplateChain.js.map +1 -0
  89. package/dist/esm/editing/applyEdit.d.ts +5 -0
  90. package/dist/esm/editing/applyEdit.d.ts.map +1 -0
  91. package/dist/esm/editing/applyEdit.js +81 -0
  92. package/dist/esm/editing/applyEdit.js.map +1 -0
  93. package/dist/esm/editing/applyEffectiveConfiguration.d.ts +3 -0
  94. package/dist/esm/editing/applyEffectiveConfiguration.d.ts.map +1 -0
  95. package/dist/esm/editing/applyEffectiveConfiguration.js +60 -0
  96. package/dist/esm/editing/applyEffectiveConfiguration.js.map +1 -0
  97. package/dist/esm/editing/collectComponents.d.ts +3 -0
  98. package/dist/esm/editing/collectComponents.d.ts.map +1 -0
  99. package/dist/esm/editing/collectComponents.js +32 -0
  100. package/dist/esm/editing/collectComponents.js.map +1 -0
  101. package/dist/esm/editing/collectIconUsages.d.ts +5 -0
  102. package/dist/esm/editing/collectIconUsages.d.ts.map +1 -0
  103. package/dist/esm/editing/collectIconUsages.js +84 -0
  104. package/dist/esm/editing/collectIconUsages.js.map +1 -0
  105. package/dist/esm/editing/describeNode.d.ts +11 -0
  106. package/dist/esm/editing/describeNode.d.ts.map +1 -0
  107. package/dist/esm/editing/describeNode.js +60 -0
  108. package/dist/esm/editing/describeNode.js.map +1 -0
  109. package/dist/esm/editing/diagnoseIcons.d.ts +4 -0
  110. package/dist/esm/editing/diagnoseIcons.d.ts.map +1 -0
  111. package/dist/esm/editing/diagnoseIcons.js +65 -0
  112. package/dist/esm/editing/diagnoseIcons.js.map +1 -0
  113. package/dist/esm/editing/diagnostics.d.ts +6 -0
  114. package/dist/esm/editing/diagnostics.d.ts.map +1 -0
  115. package/dist/esm/editing/diagnostics.js +32 -0
  116. package/dist/esm/editing/diagnostics.js.map +1 -0
  117. package/dist/esm/editing/documentPaths.d.ts +8 -0
  118. package/dist/esm/editing/documentPaths.d.ts.map +1 -0
  119. package/dist/esm/editing/documentPaths.js +41 -0
  120. package/dist/esm/editing/documentPaths.js.map +1 -0
  121. package/dist/esm/editing/exposureEdits.d.ts +5 -0
  122. package/dist/esm/editing/exposureEdits.d.ts.map +1 -0
  123. package/dist/esm/editing/exposureEdits.js +103 -0
  124. package/dist/esm/editing/exposureEdits.js.map +1 -0
  125. package/dist/esm/editing/exposureGrants.d.ts +21 -0
  126. package/dist/esm/editing/exposureGrants.d.ts.map +1 -0
  127. package/dist/esm/editing/exposureGrants.js +112 -0
  128. package/dist/esm/editing/exposureGrants.js.map +1 -0
  129. package/dist/esm/editing/given/a_layout_document.d.ts +14 -0
  130. package/dist/esm/editing/given/a_layout_document.d.ts.map +1 -0
  131. package/dist/esm/editing/given/a_layout_document.js +67 -0
  132. package/dist/esm/editing/given/a_layout_document.js.map +1 -0
  133. package/dist/esm/editing/given/a_scene_document.d.ts +20 -0
  134. package/dist/esm/editing/given/a_scene_document.d.ts.map +1 -0
  135. package/dist/esm/editing/given/a_scene_document.js +110 -0
  136. package/dist/esm/editing/given/a_scene_document.js.map +1 -0
  137. package/dist/esm/editing/iconDiagnostics.d.ts +11 -0
  138. package/dist/esm/editing/iconDiagnostics.d.ts.map +1 -0
  139. package/dist/esm/editing/iconDiagnostics.js +99 -0
  140. package/dist/esm/editing/iconDiagnostics.js.map +1 -0
  141. package/dist/esm/editing/index.d.ts +22 -0
  142. package/dist/esm/editing/index.d.ts.map +1 -0
  143. package/dist/esm/editing/index.js +22 -0
  144. package/dist/esm/editing/index.js.map +1 -0
  145. package/dist/esm/editing/indexDocument.d.ts +6 -0
  146. package/dist/esm/editing/indexDocument.d.ts.map +1 -0
  147. package/dist/esm/editing/indexDocument.js +396 -0
  148. package/dist/esm/editing/indexDocument.js.map +1 -0
  149. package/dist/esm/editing/inspect.d.ts +8 -0
  150. package/dist/esm/editing/inspect.d.ts.map +1 -0
  151. package/dist/esm/editing/inspect.js +151 -0
  152. package/dist/esm/editing/inspect.js.map +1 -0
  153. package/dist/esm/editing/instanceEdits.d.ts +9 -0
  154. package/dist/esm/editing/instanceEdits.d.ts.map +1 -0
  155. package/dist/esm/editing/instanceEdits.js +260 -0
  156. package/dist/esm/editing/instanceEdits.js.map +1 -0
  157. package/dist/esm/editing/layoutTypeDescriptors.d.ts +5 -0
  158. package/dist/esm/editing/layoutTypeDescriptors.d.ts.map +1 -0
  159. package/dist/esm/editing/layoutTypeDescriptors.js +421 -0
  160. package/dist/esm/editing/layoutTypeDescriptors.js.map +1 -0
  161. package/dist/esm/editing/layoutTypeEdits.d.ts +4 -0
  162. package/dist/esm/editing/layoutTypeEdits.d.ts.map +1 -0
  163. package/dist/esm/editing/layoutTypeEdits.js +139 -0
  164. package/dist/esm/editing/layoutTypeEdits.js.map +1 -0
  165. package/dist/esm/editing/nodeIds.d.ts +14 -0
  166. package/dist/esm/editing/nodeIds.d.ts.map +1 -0
  167. package/dist/esm/editing/nodeIds.js +102 -0
  168. package/dist/esm/editing/nodeIds.js.map +1 -0
  169. package/dist/esm/editing/pathAccess.d.ts +7 -0
  170. package/dist/esm/editing/pathAccess.d.ts.map +1 -0
  171. package/dist/esm/editing/pathAccess.js +48 -0
  172. package/dist/esm/editing/pathAccess.js.map +1 -0
  173. package/dist/esm/editing/propertyEdits.d.ts +15 -0
  174. package/dist/esm/editing/propertyEdits.d.ts.map +1 -0
  175. package/dist/esm/editing/propertyEdits.js +120 -0
  176. package/dist/esm/editing/propertyEdits.js.map +1 -0
  177. package/dist/esm/editing/resolveEffectiveConfiguration.d.ts +5 -0
  178. package/dist/esm/editing/resolveEffectiveConfiguration.d.ts.map +1 -0
  179. package/dist/esm/editing/resolveEffectiveConfiguration.js +198 -0
  180. package/dist/esm/editing/resolveEffectiveConfiguration.js.map +1 -0
  181. package/dist/esm/editing/resolveTemplateChain.d.ts +4 -0
  182. package/dist/esm/editing/resolveTemplateChain.d.ts.map +1 -0
  183. package/dist/esm/editing/resolveTemplateChain.js +98 -0
  184. package/dist/esm/editing/resolveTemplateChain.js.map +1 -0
  185. package/dist/esm/editing/structureEdits.d.ts +6 -0
  186. package/dist/esm/editing/structureEdits.d.ts.map +1 -0
  187. package/dist/esm/editing/structureEdits.js +227 -0
  188. package/dist/esm/editing/structureEdits.js.map +1 -0
  189. package/dist/esm/editing/validateBinding.d.ts +7 -0
  190. package/dist/esm/editing/validateBinding.d.ts.map +1 -0
  191. package/dist/esm/editing/validateBinding.js +108 -0
  192. package/dist/esm/editing/validateBinding.js.map +1 -0
  193. package/dist/esm/editing/validateValue.d.ts +8 -0
  194. package/dist/esm/editing/validateValue.d.ts.map +1 -0
  195. package/dist/esm/editing/validateValue.js +111 -0
  196. package/dist/esm/editing/validateValue.js.map +1 -0
  197. package/dist/esm/icons/EffectiveIconCatalog.d.ts +25 -0
  198. package/dist/esm/icons/EffectiveIconCatalog.d.ts.map +1 -0
  199. package/dist/esm/icons/EffectiveIconCatalog.js +210 -0
  200. package/dist/esm/icons/EffectiveIconCatalog.js.map +1 -0
  201. package/dist/esm/icons/EffectiveIconEntry.d.ts +9 -0
  202. package/dist/esm/icons/EffectiveIconEntry.d.ts.map +1 -0
  203. package/dist/esm/icons/EffectiveIconEntry.js +20 -0
  204. package/dist/esm/icons/EffectiveIconEntry.js.map +1 -0
  205. package/dist/esm/icons/IconCatalogSource.d.ts +6 -0
  206. package/dist/esm/icons/IconCatalogSource.d.ts.map +1 -0
  207. package/dist/esm/icons/IconCatalogSource.js +2 -0
  208. package/dist/esm/icons/IconCatalogSource.js.map +1 -0
  209. package/dist/esm/icons/IconDiagnostic.d.ts +9 -0
  210. package/dist/esm/icons/IconDiagnostic.d.ts.map +1 -0
  211. package/dist/esm/icons/IconDiagnostic.js +2 -0
  212. package/dist/esm/icons/IconDiagnostic.js.map +1 -0
  213. package/dist/esm/icons/IconImpactReport.d.ts +18 -0
  214. package/dist/esm/icons/IconImpactReport.d.ts.map +1 -0
  215. package/dist/esm/icons/IconImpactReport.js +2 -0
  216. package/dist/esm/icons/IconImpactReport.js.map +1 -0
  217. package/dist/esm/icons/IconLibraryResolution.d.ts +7 -0
  218. package/dist/esm/icons/IconLibraryResolution.d.ts.map +1 -0
  219. package/dist/esm/icons/IconLibraryResolution.js +2 -0
  220. package/dist/esm/icons/IconLibraryResolution.js.map +1 -0
  221. package/dist/esm/icons/IconQuery.d.ts +7 -0
  222. package/dist/esm/icons/IconQuery.d.ts.map +1 -0
  223. package/dist/esm/icons/IconQuery.js +2 -0
  224. package/dist/esm/icons/IconQuery.js.map +1 -0
  225. package/dist/esm/icons/IconResolution.d.ts +14 -0
  226. package/dist/esm/icons/IconResolution.d.ts.map +1 -0
  227. package/dist/esm/icons/IconResolution.js +2 -0
  228. package/dist/esm/icons/IconResolution.js.map +1 -0
  229. package/dist/esm/icons/IconSearchResult.d.ts +7 -0
  230. package/dist/esm/icons/IconSearchResult.d.ts.map +1 -0
  231. package/dist/esm/icons/IconSearchResult.js +2 -0
  232. package/dist/esm/icons/IconSearchResult.js.map +1 -0
  233. package/dist/esm/icons/IconUsage.d.ts +6 -0
  234. package/dist/esm/icons/IconUsage.d.ts.map +1 -0
  235. package/dist/esm/icons/IconUsage.js +2 -0
  236. package/dist/esm/icons/IconUsage.js.map +1 -0
  237. package/dist/esm/icons/ResolvedIconLibrary.d.ts +8 -0
  238. package/dist/esm/icons/ResolvedIconLibrary.d.ts.map +1 -0
  239. package/dist/esm/icons/ResolvedIconLibrary.js +2 -0
  240. package/dist/esm/icons/ResolvedIconLibrary.js.map +1 -0
  241. package/dist/esm/icons/analyzeIconImpact.d.ts +5 -0
  242. package/dist/esm/icons/analyzeIconImpact.d.ts.map +1 -0
  243. package/dist/esm/icons/analyzeIconImpact.js +46 -0
  244. package/dist/esm/icons/analyzeIconImpact.js.map +1 -0
  245. package/dist/esm/icons/index.d.ts +14 -0
  246. package/dist/esm/icons/index.d.ts.map +1 -0
  247. package/dist/esm/icons/index.js +14 -0
  248. package/dist/esm/icons/index.js.map +1 -0
  249. package/dist/esm/icons/matchesIconQuery.d.ts +4 -0
  250. package/dist/esm/icons/matchesIconQuery.d.ts.map +1 -0
  251. package/dist/esm/icons/matchesIconQuery.js +20 -0
  252. package/dist/esm/icons/matchesIconQuery.js.map +1 -0
  253. package/dist/esm/icons/resolveIconLibraries.d.ts +4 -0
  254. package/dist/esm/icons/resolveIconLibraries.d.ts.map +1 -0
  255. package/dist/esm/icons/resolveIconLibraries.js +43 -0
  256. package/dist/esm/icons/resolveIconLibraries.js.map +1 -0
  257. package/dist/esm/index.d.ts +2 -0
  258. package/dist/esm/index.d.ts.map +1 -1
  259. package/dist/esm/index.js +21 -0
  260. package/dist/esm/index.js.map +1 -1
  261. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  262. package/editing/DescriptorCatalog.ts +51 -0
  263. package/editing/DocumentIndex.ts +73 -0
  264. package/editing/EditOutcome.ts +21 -0
  265. package/editing/EditSession.ts +50 -0
  266. package/editing/EditingContext.ts +34 -0
  267. package/editing/TemplateChain.ts +36 -0
  268. package/editing/applyEdit.ts +69 -0
  269. package/editing/applyEffectiveConfiguration.ts +53 -0
  270. package/editing/collectComponents.ts +36 -0
  271. package/editing/collectIconUsages.ts +78 -0
  272. package/editing/describeNode.ts +61 -0
  273. package/editing/diagnoseIcons.ts +60 -0
  274. package/editing/diagnostics.ts +30 -0
  275. package/editing/documentPaths.ts +40 -0
  276. package/editing/exposureEdits.ts +119 -0
  277. package/editing/exposureGrants.ts +159 -0
  278. package/editing/given/a_layout_document.ts +88 -0
  279. package/editing/given/a_scene_document.ts +135 -0
  280. package/editing/iconDiagnostics.ts +90 -0
  281. package/editing/index.ts +24 -0
  282. package/editing/indexDocument.ts +237 -0
  283. package/editing/inspect.ts +165 -0
  284. package/editing/instanceEdits.ts +251 -0
  285. package/editing/layoutTypeDescriptors.ts +191 -0
  286. package/editing/layoutTypeEdits.ts +135 -0
  287. package/editing/nodeIds.ts +111 -0
  288. package/editing/pathAccess.ts +81 -0
  289. package/editing/propertyEdits.ts +127 -0
  290. package/editing/resolveEffectiveConfiguration.ts +202 -0
  291. package/editing/resolveTemplateChain.ts +109 -0
  292. package/editing/structureEdits.ts +234 -0
  293. package/editing/validateBinding.ts +103 -0
  294. package/editing/validateValue.ts +130 -0
  295. package/icons/EffectiveIconCatalog.ts +199 -0
  296. package/icons/EffectiveIconEntry.ts +36 -0
  297. package/icons/IconCatalogSource.ts +23 -0
  298. package/icons/IconDiagnostic.ts +45 -0
  299. package/icons/IconImpactReport.ts +63 -0
  300. package/icons/IconLibraryResolution.ts +22 -0
  301. package/icons/IconQuery.ts +27 -0
  302. package/icons/IconResolution.ts +25 -0
  303. package/icons/IconSearchResult.ts +21 -0
  304. package/icons/IconUsage.ts +21 -0
  305. package/icons/ResolvedIconLibrary.ts +32 -0
  306. package/icons/analyzeIconImpact.ts +41 -0
  307. package/icons/index.ts +16 -0
  308. package/icons/matchesIconQuery.ts +19 -0
  309. package/icons/resolveIconLibraries.ts +47 -0
  310. package/index.ts +2 -0
  311. package/package.json +3 -3
@@ -0,0 +1,84 @@
1
+ import { PropertyValueType } from '@cratis/scene.model';
2
+ import { collectComponents } from './collectComponents.js';
3
+ import { findComponentDescriptor } from './DescriptorCatalog.js';
4
+ import { getValueAtPath } from './pathAccess.js';
5
+
6
+ // Copyright (c) Cratis. All rights reserved.
7
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
8
+ function iconFields(property) {
9
+ return (property.item?.properties ?? []).filter((field)=>field.valueType === PropertyValueType.Icon).map((field)=>field.path);
10
+ }
11
+ function usagesOf(property, value, items, location) {
12
+ if (property.valueType === PropertyValueType.Icon) {
13
+ return value === undefined ? [] : [
14
+ {
15
+ value: value,
16
+ location: `${location}:${property.path}`
17
+ }
18
+ ];
19
+ }
20
+ return property.valueType === PropertyValueType.Collection ? (items ?? []).flatMap((item)=>iconFields(property).filter((field)=>item.values[field] !== undefined).map((field)=>({
21
+ value: item.values[field],
22
+ location: `${location}:${property.path}:${item.id}:${field}`
23
+ }))) : [];
24
+ }
25
+ function ownerItems(value) {
26
+ return (Array.isArray(value) ? value : []).filter((item)=>item !== null && typeof item === 'object').map(({ id, ...values })=>({
27
+ id: String(id),
28
+ values
29
+ }));
30
+ }
31
+ /**
32
+ * Finds every icon value stored anywhere in a document - the values components carry themselves, and the values
33
+ * and collection-item icon fields that template instances contributed - as the `IconUsage`s that
34
+ * `analyzeIconImpact` takes, so "what would removing this library break" can be asked of a whole document.
35
+ *
36
+ * Each usage's `location` reads `<owner or instance>:<component>:<path>[:<itemId>:<field>]`, where the first part is
37
+ * the contributing instance id (`screen:Orders`) for a contributed value and the name of the owning layout or
38
+ * template for a value the component carries. Values are read as stored; none are changed.
39
+ *
40
+ * @param document The document to read.
41
+ * @param catalog The descriptors saying which properties are icons.
42
+ */ function collectIconUsages(document, catalog) {
43
+ const usages = [];
44
+ const componentNames = new Map();
45
+ const owners = [
46
+ ...document.layouts.map((layout)=>({
47
+ name: layout.name,
48
+ value: layout
49
+ })),
50
+ ...document.screenTemplates.map((template)=>({
51
+ name: template.name,
52
+ value: template
53
+ })),
54
+ ...document.dialogTemplates.map((template)=>({
55
+ name: template.name,
56
+ value: template
57
+ })),
58
+ ...document.screens.map((screen)=>({
59
+ name: screen.name,
60
+ value: screen
61
+ }))
62
+ ];
63
+ for (const owner of owners){
64
+ for (const component of collectComponents(owner.value)){
65
+ if (!componentNames.has(component.id)) componentNames.set(component.id, component.componentName);
66
+ for (const property of findComponentDescriptor(catalog, component.componentName)?.properties ?? []){
67
+ const value = getValueAtPath(component.properties, property.path);
68
+ usages.push(...usagesOf(property, value, ownerItems(value), `${owner.name}:${component.id}`));
69
+ }
70
+ }
71
+ }
72
+ for (const contribution of document.instanceContributions){
73
+ const componentName = componentNames.get(contribution.component);
74
+ const property = componentName === undefined ? undefined : findComponentDescriptor(catalog, componentName)?.properties.find((candidate)=>candidate.path === contribution.path);
75
+ if (property) usages.push(...contributedUsages(property, contribution));
76
+ }
77
+ return usages;
78
+ }
79
+ function contributedUsages(property, contribution) {
80
+ return usagesOf(property, contribution.value, contribution.items, `${contribution.instance}:${contribution.component}`);
81
+ }
82
+
83
+ export { collectIconUsages };
84
+ //# sourceMappingURL=collectIconUsages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collectIconUsages.js","sources":["../../../editing/collectIconUsages.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 { InstanceContribution, PropertyDescriptor, PropertyValueType, SceneDocument } from '@cratis/scene.model';\nimport { IconUsage } from '../icons/IconUsage';\nimport { collectComponents } from './collectComponents';\nimport { DescriptorCatalog, findComponentDescriptor } from './DescriptorCatalog';\nimport { getValueAtPath } from './pathAccess';\n\nfunction iconFields(property: PropertyDescriptor): string[] {\n return (property.item?.properties ?? []).filter((field) => field.valueType === PropertyValueType.Icon).map((field) => field.path);\n}\n\nfunction usagesOf(property: PropertyDescriptor, value: unknown, items: { id: string; values: Record<string, unknown> }[] | undefined, location: string): IconUsage[] {\n if (property.valueType === PropertyValueType.Icon) {\n return value === undefined ? [] : [{ value: value as IconUsage['value'], location: `${location}:${property.path}` }];\n }\n\n return property.valueType === PropertyValueType.Collection\n ? (items ?? []).flatMap((item) =>\n iconFields(property)\n .filter((field) => item.values[field] !== undefined)\n .map((field) => ({ value: item.values[field] as IconUsage['value'], location: `${location}:${property.path}:${item.id}:${field}` })))\n : [];\n}\n\nfunction ownerItems(value: unknown): { id: string; values: Record<string, unknown> }[] {\n return (Array.isArray(value) ? value : [])\n .filter((item): item is Record<string, unknown> => item !== null && typeof item === 'object')\n .map(({ id, ...values }) => ({ id: String(id), values }));\n}\n\n/**\n * Finds every icon value stored anywhere in a document - the values components carry themselves, and the values\n * and collection-item icon fields that template instances contributed - as the `IconUsage`s that\n * `analyzeIconImpact` takes, so \"what would removing this library break\" can be asked of a whole document.\n *\n * Each usage's `location` reads `<owner or instance>:<component>:<path>[:<itemId>:<field>]`, where the first part is\n * the contributing instance id (`screen:Orders`) for a contributed value and the name of the owning layout or\n * template for a value the component carries. Values are read as stored; none are changed.\n *\n * @param document The document to read.\n * @param catalog The descriptors saying which properties are icons.\n */\nexport function collectIconUsages(document: SceneDocument, catalog: DescriptorCatalog): IconUsage[] {\n const usages: IconUsage[] = [];\n const componentNames = new Map<string, string>();\n\n const owners: { name: string; value: unknown }[] = [\n ...document.layouts.map((layout) => ({ name: layout.name, value: layout })),\n ...document.screenTemplates.map((template) => ({ name: template.name, value: template })),\n ...document.dialogTemplates.map((template) => ({ name: template.name, value: template })),\n ...document.screens.map((screen) => ({ name: screen.name, value: screen })),\n ];\n\n for (const owner of owners) {\n for (const component of collectComponents(owner.value)) {\n if (!componentNames.has(component.id)) componentNames.set(component.id, component.componentName);\n\n for (const property of findComponentDescriptor(catalog, component.componentName)?.properties ?? []) {\n const value = getValueAtPath(component.properties, property.path);\n usages.push(...usagesOf(property, value, ownerItems(value), `${owner.name}:${component.id}`));\n }\n }\n }\n\n for (const contribution of document.instanceContributions) {\n const componentName = componentNames.get(contribution.component);\n const property = componentName === undefined ? undefined : findComponentDescriptor(catalog, componentName)?.properties.find((candidate) => candidate.path === contribution.path);\n if (property) usages.push(...contributedUsages(property, contribution));\n }\n\n return usages;\n}\n\nfunction contributedUsages(property: PropertyDescriptor, contribution: InstanceContribution): IconUsage[] {\n return usagesOf(property, contribution.value, contribution.items, `${contribution.instance}:${contribution.component}`);\n}\n"],"names":["iconFields","property","item","properties","filter","field","valueType","PropertyValueType","Icon","map","path","usagesOf","value","items","location","undefined","Collection","flatMap","values","id","ownerItems","Array","isArray","String","collectIconUsages","document","catalog","usages","componentNames","Map","owners","layouts","layout","name","screenTemplates","template","dialogTemplates","screens","screen","owner","component","collectComponents","has","set","componentName","findComponentDescriptor","getValueAtPath","push","contribution","instanceContributions","get","find","candidate","contributedUsages","instance"],"mappings":";;;;;AAAA;AACA;AAQA,SAASA,WAAWC,QAA4B,EAAA;IAC5C,OAAQA,CAAAA,QAAAA,CAASC,IAAI,EAAEC,cAAc,EAAC,EAAGC,MAAM,CAAC,CAACC,QAAUA,KAAAA,CAAMC,SAAS,KAAKC,iBAAAA,CAAkBC,IAAI,CAAA,CAAEC,GAAG,CAAC,CAACJ,KAAAA,GAAUA,KAAAA,CAAMK,IAAI,CAAA;AACpI;AAEA,SAASC,SAASV,QAA4B,EAAEW,KAAc,EAAEC,KAAoE,EAAEC,QAAgB,EAAA;AAClJ,IAAA,IAAIb,QAAAA,CAASK,SAAS,KAAKC,iBAAAA,CAAkBC,IAAI,EAAE;QAC/C,OAAOI,KAAAA,KAAUG,SAAAA,GAAY,EAAE,GAAG;AAAC,YAAA;gBAAEH,KAAAA,EAAOA,KAAAA;AAA6BE,gBAAAA,QAAAA,EAAU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AAAA,CAAAA,EAAQ,CAAA,EAAG2B,KAAAA,CAAMN,IAAI,CAAC,CAAC,EAAEO,SAAAA,CAAUrB,EAAE,CAAA,CAAE,CAAA,CAAA;AAC/F,YAAA;AACJ,QAAA;AACJ,IAAA;AAEA,IAAA,KAAK,MAAM6B,YAAAA,IAAgBvB,QAAAA,CAASwB,qBAAqB,CAAE;AACvD,QAAA,MAAML,aAAAA,GAAgBhB,cAAAA,CAAesB,GAAG,CAACF,aAAaR,SAAS,CAAA;AAC/D,QAAA,MAAMvC,QAAAA,GAAW2C,aAAAA,KAAkB7B,SAAAA,GAAYA,SAAAA,GAAY8B,wBAAwBnB,OAAAA,EAASkB,aAAAA,CAAAA,EAAgBzC,UAAAA,CAAWgD,IAAAA,CAAK,CAACC,SAAAA,GAAcA,SAAAA,CAAU1C,IAAI,KAAKsC,aAAatC,IAAI,CAAA;AAC/K,QAAA,IAAIT,QAAAA,EAAU0B,MAAAA,CAAOoB,IAAI,CAAA,GAAIM,kBAAkBpD,QAAAA,EAAU+C,YAAAA,CAAAA,CAAAA;AAC7D,IAAA;IAEA,OAAOrB,MAAAA;AACX;AAEA,SAAS0B,iBAAAA,CAAkBpD,QAA4B,EAAE+C,YAAkC,EAAA;AACvF,IAAA,OAAOrC,SAASV,QAAAA,EAAU+C,YAAAA,CAAapC,KAAK,EAAEoC,aAAanC,KAAK,EAAE,CAAA,EAAGmC,YAAAA,CAAaM,QAAQ,CAAC,CAAC,EAAEN,YAAAA,CAAaR,SAAS,CAAA,CAAE,CAAA;AAC1H;;"}
@@ -0,0 +1,11 @@
1
+ import { LayoutCapabilities, PropertyDescriptor, SceneDiagnostic } from '@cratis/scene.model';
2
+ import { DescriptorCatalog } from './DescriptorCatalog';
3
+ import { NodeRecord } from './DocumentIndex';
4
+ export interface NodeDescription {
5
+ properties: PropertyDescriptor[];
6
+ capabilities?: LayoutCapabilities;
7
+ diagnostics: SceneDiagnostic[];
8
+ }
9
+ export declare function describeNode(record: NodeRecord, catalog: DescriptorCatalog): NodeDescription;
10
+ export declare function readNodeValue(record: NodeRecord, path: string): unknown;
11
+ //# sourceMappingURL=describeNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"describeNode.d.ts","sourceRoot":"","sources":["../../../editing/describeNode.ts"],"names":[],"mappings":"AAGA,OAAO,EACa,kBAAkB,EAAc,kBAAkB,EAAE,eAAe,EACtF,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAqD,MAAM,qBAAqB,CAAC;AAC3G,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAQ7C,MAAM,WAAW,eAAe;IAC5B,UAAU,EAAE,kBAAkB,EAAE,CAAC;IACjC,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,WAAW,EAAE,eAAe,EAAE,CAAC;CAClC;AAWD,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,iBAAiB,GAAG,eAAe,CAqB5F;AAKD,wBAAgB,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAIvE"}
@@ -0,0 +1,60 @@
1
+ import { LayoutType, SceneNodeKind, DiagnosticCode } from '@cratis/scene.model';
2
+ import { findLayoutTypeDescriptor, findComponentDescriptor } from './DescriptorCatalog.js';
3
+ import { warningDiagnostic } from './diagnostics.js';
4
+ import { getValueAtPath } from './pathAccess.js';
5
+ import { placementProperties, templateProperties } from './layoutTypeDescriptors.js';
6
+
7
+ // Copyright (c) Cratis. All rights reserved.
8
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
9
+ const layoutTypes = new Set(Object.values(LayoutType));
10
+ /**
11
+ * Works out which descriptors apply to a node.
12
+ *
13
+ * A component takes its descriptor from the catalog by the name it carries; a layout node takes its layout type's;
14
+ * a placement and a template have their own fixed sets. A component nothing describes has no editable
15
+ * properties, and says so rather than failing.
16
+ */ function describeNode(record, catalog) {
17
+ const diagnostics = [];
18
+ if (record.kind === SceneNodeKind.Placement) return {
19
+ properties: placementProperties,
20
+ diagnostics
21
+ };
22
+ if (record.kind === SceneNodeKind.ScreenTemplate || record.kind === SceneNodeKind.DialogTemplate) return {
23
+ properties: templateProperties,
24
+ diagnostics
25
+ };
26
+ if (layoutTypes.has(record.typeId)) {
27
+ const descriptor = findLayoutTypeDescriptor(catalog, record.typeId);
28
+ return {
29
+ properties: descriptor?.properties ?? [],
30
+ capabilities: descriptor?.capabilities,
31
+ diagnostics
32
+ };
33
+ }
34
+ if (record.kind === SceneNodeKind.Element && record.value.componentName !== undefined) {
35
+ const descriptor = findComponentDescriptor(catalog, record.typeId);
36
+ if (!descriptor) {
37
+ diagnostics.push(warningDiagnostic(DiagnosticCode.MissingComponentDescriptor, `Nothing describes the component '${record.typeId}', so none of its properties can be edited.`, {
38
+ nodeId: record.id
39
+ }));
40
+ }
41
+ return {
42
+ properties: descriptor?.properties ?? [],
43
+ diagnostics
44
+ };
45
+ }
46
+ return {
47
+ properties: [],
48
+ diagnostics
49
+ };
50
+ }
51
+ /**
52
+ * Reads a descriptor's value from a node: from the property bag of a component, from the node itself otherwise.
53
+ */ function readNodeValue(record, path) {
54
+ const value = record.value;
55
+ const isComponent = record.kind === SceneNodeKind.Element && value.componentName !== undefined;
56
+ return getValueAtPath(isComponent ? value.properties : value, path);
57
+ }
58
+
59
+ export { describeNode, readNodeValue };
60
+ //# sourceMappingURL=describeNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"describeNode.js","sources":["../../../editing/describeNode.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 {\n DiagnosticCode, LayoutCapabilities, LayoutType, PropertyDescriptor, SceneDiagnostic, SceneNodeKind,\n} from '@cratis/scene.model';\nimport { DescriptorCatalog, findComponentDescriptor, findLayoutTypeDescriptor } from './DescriptorCatalog';\nimport { NodeRecord } from './DocumentIndex';\nimport { warningDiagnostic } from './diagnostics';\nimport { getValueAtPath } from './pathAccess';\nimport { placementProperties, templateProperties } from './layoutTypeDescriptors';\n\n/**\n * What describes a node: its editable properties, and for a layout node what the type can do.\n */\nexport interface NodeDescription {\n properties: PropertyDescriptor[];\n capabilities?: LayoutCapabilities;\n diagnostics: SceneDiagnostic[];\n}\n\nconst layoutTypes = new Set<string>(Object.values(LayoutType));\n\n/**\n * Works out which descriptors apply to a node.\n *\n * A component takes its descriptor from the catalog by the name it carries; a layout node takes its layout type's;\n * a placement and a template have their own fixed sets. A component nothing describes has no editable\n * properties, and says so rather than failing.\n */\nexport function describeNode(record: NodeRecord, catalog: DescriptorCatalog): NodeDescription {\n const diagnostics: SceneDiagnostic[] = [];\n\n if (record.kind === SceneNodeKind.Placement) return { properties: placementProperties, diagnostics };\n if (record.kind === SceneNodeKind.ScreenTemplate || record.kind === SceneNodeKind.DialogTemplate) return { properties: templateProperties, diagnostics };\n\n if (layoutTypes.has(record.typeId)) {\n const descriptor = findLayoutTypeDescriptor(catalog, record.typeId);\n return { properties: descriptor?.properties ?? [], capabilities: descriptor?.capabilities, diagnostics };\n }\n\n if (record.kind === SceneNodeKind.Element && (record.value as { componentName?: unknown }).componentName !== undefined) {\n const descriptor = findComponentDescriptor(catalog, record.typeId);\n if (!descriptor) {\n diagnostics.push(warningDiagnostic(DiagnosticCode.MissingComponentDescriptor, `Nothing describes the component '${record.typeId}', so none of its properties can be edited.`, { nodeId: record.id }));\n }\n\n return { properties: descriptor?.properties ?? [], diagnostics };\n }\n\n return { properties: [], diagnostics };\n}\n\n/**\n * Reads a descriptor's value from a node: from the property bag of a component, from the node itself otherwise.\n */\nexport function readNodeValue(record: NodeRecord, path: string): unknown {\n const value = record.value as Record<string, unknown>;\n const isComponent = record.kind === SceneNodeKind.Element && value.componentName !== undefined;\n return getValueAtPath(isComponent ? (value.properties as Record<string, unknown>) : value, path);\n}\n"],"names":["layoutTypes","Set","Object","values","LayoutType","describeNode","record","catalog","diagnostics","kind","SceneNodeKind","Placement","properties","placementProperties","ScreenTemplate","DialogTemplate","templateProperties","has","typeId","descriptor","findLayoutTypeDescriptor","capabilities","Element","value","componentName","undefined","findComponentDescriptor","push","warningDiagnostic","DiagnosticCode","MissingComponentDescriptor","nodeId","id","readNodeValue","path","isComponent","getValueAtPath"],"mappings":";;;;;;AAAA;AACA;AAoBA,MAAMA,WAAAA,GAAc,IAAIC,GAAAA,CAAYC,MAAAA,CAAOC,MAAM,CAACC,UAAAA,CAAAA,CAAAA;AAElD;;;;;;AAMC,IACM,SAASC,YAAAA,CAAaC,MAAkB,EAAEC,OAA0B,EAAA;AACvE,IAAA,MAAMC,cAAiC,EAAE;AAEzC,IAAA,IAAIF,OAAOG,IAAI,KAAKC,aAAAA,CAAcC,SAAS,EAAE,OAAO;QAAEC,UAAAA,EAAYC,mBAAAA;AAAqBL,QAAAA;AAAY,KAAA;AACnG,IAAA,IAAIF,MAAAA,CAAOG,IAAI,KAAKC,aAAAA,CAAcI,cAAc,IAAIR,MAAAA,CAAOG,IAAI,KAAKC,aAAAA,CAAcK,cAAc,EAAE,OAAO;QAAEH,UAAAA,EAAYI,kBAAAA;AAAoBR,QAAAA;AAAY,KAAA;AAEvJ,IAAA,IAAIR,WAAAA,CAAYiB,GAAG,CAACX,MAAAA,CAAOY,MAAM,CAAA,EAAG;AAChC,QAAA,MAAMC,UAAAA,GAAaC,wBAAAA,CAAyBb,OAAAA,EAASD,MAAAA,CAAOY,MAAM,CAAA;QAClE,OAAO;YAAEN,UAAAA,EAAYO,UAAAA,EAAYP,cAAc,EAAE;AAAES,YAAAA,YAAAA,EAAcF,UAAAA,EAAYE,YAAAA;AAAcb,YAAAA;AAAY,SAAA;AAC3G,IAAA;AAEA,IAAA,IAAIF,MAAAA,CAAOG,IAAI,KAAKC,aAAAA,CAAcY,OAAO,IAAI,MAAChB,CAAOiB,KAAK,CAAiCC,aAAa,KAAKC,SAAAA,EAAW;AACpH,QAAA,MAAMN,UAAAA,GAAaO,uBAAAA,CAAwBnB,OAAAA,EAASD,MAAAA,CAAOY,MAAM,CAAA;AACjE,QAAA,IAAI,CAACC,UAAAA,EAAY;AACbX,YAAAA,WAAAA,CAAYmB,IAAI,CAACC,iBAAAA,CAAkBC,cAAAA,CAAeC,0BAA0B,EAAE,CAAC,iCAAiC,EAAExB,MAAAA,CAAOY,MAAM,CAAC,2CAA2C,CAAC,EAAE;AAAEa,gBAAAA,MAAAA,EAAQzB,OAAO0B;AAAG,aAAA,CAAA,CAAA;AACtM,QAAA;QAEA,OAAO;YAAEpB,UAAAA,EAAYO,UAAAA,EAAYP,cAAc,EAAE;AAAEJ,YAAAA;AAAY,SAAA;AACnE,IAAA;IAEA,OAAO;AAAEI,QAAAA,UAAAA,EAAY,EAAE;AAAEJ,QAAAA;AAAY,KAAA;AACzC;AAEA;;AAEC,IACM,SAASyB,aAAAA,CAAc3B,MAAkB,EAAE4B,IAAY,EAAA;IAC1D,MAAMX,KAAAA,GAAQjB,OAAOiB,KAAK;IAC1B,MAAMY,WAAAA,GAAc7B,OAAOG,IAAI,KAAKC,cAAcY,OAAO,IAAIC,KAAAA,CAAMC,aAAa,KAAKC,SAAAA;AACrF,IAAA,OAAOW,cAAAA,CAAeD,WAAAA,GAAeZ,KAAAA,CAAMX,UAAU,GAA+BW,KAAAA,EAAOW,IAAAA,CAAAA;AAC/F;;"}
@@ -0,0 +1,4 @@
1
+ import { SceneDiagnostic, SceneDocument } from '@cratis/scene.model';
2
+ import { EditingContext } from './EditingContext';
3
+ export declare function diagnoseIcons(document: SceneDocument, context: EditingContext): SceneDiagnostic[];
4
+ //# sourceMappingURL=diagnoseIcons.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnoseIcons.d.ts","sourceRoot":"","sources":["../../../editing/diagnoseIcons.ts"],"names":[],"mappings":"AAGA,OAAO,EAA6D,eAAe,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEhI,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAuBlD,wBAAgB,aAAa,CAAC,QAAQ,EAAE,aAAa,EAAE,OAAO,EAAE,cAAc,GAAG,eAAe,EAAE,CA+BjG"}
@@ -0,0 +1,65 @@
1
+ import { PropertyValueType, DiagnosticSeverity } from '@cratis/scene.model';
2
+ import { findComponentDescriptor } from './DescriptorCatalog.js';
3
+ import { iconProblemsOfProperty, iconProblemsOfItems } from './iconDiagnostics.js';
4
+ import { getValueAtPath } from './pathAccess.js';
5
+ import { resolveEffectiveConfiguration } from './resolveEffectiveConfiguration.js';
6
+ import { resolveTemplateChain } from './resolveTemplateChain.js';
7
+
8
+ // Copyright (c) Cratis. All rights reserved.
9
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
10
+ function isIconBearing(property) {
11
+ return property.valueType === PropertyValueType.Icon || property.valueType === PropertyValueType.Collection && (property.item?.properties ?? []).some((field)=>field.valueType === PropertyValueType.Icon);
12
+ }
13
+ /**
14
+ * Reports every icon in what the editing scope renders - the template chain's own values and what each instance
15
+ * contributed - that the profile's icon catalog cannot supply: a library the profile lacks, an icon or variant a
16
+ * library no longer has, a library at an incompatible version.
17
+ *
18
+ * It reports; it never changes anything. The offending values stay in the document, still applied (a renderer
19
+ * shows its fallback), and apply again as soon as the icon is available, so removing a library is reversible.
20
+ * Each diagnostic names the component, property, collection item and - for a contributed value - the instance.
21
+ *
22
+ * Returns nothing when the context carries no `iconCatalog`. Load the catalogs first (`iconCatalog.load()`) for
23
+ * definite answers; an icon from an unloaded library is reported as not verified.
24
+ */ function diagnoseIcons(document, context) {
25
+ const iconCatalog = context.iconCatalog;
26
+ if (!iconCatalog) return [];
27
+ const chain = resolveTemplateChain(document, context.scope);
28
+ const configuration = resolveEffectiveConfiguration(chain, document.instanceContributions, context.catalog);
29
+ const diagnostics = [];
30
+ for (const level of chain.levels){
31
+ for (const element of level.elements){
32
+ const descriptor = findComponentDescriptor(context.catalog, element.componentName);
33
+ const configured = configuration.components.find((candidate)=>candidate.component === element.id);
34
+ for (const property of (descriptor?.properties ?? []).filter(isIconBearing)){
35
+ const effective = configured?.values.find((candidate)=>candidate.path === property.path);
36
+ const where = {
37
+ component: element.id,
38
+ ...effective?.contributedBy === undefined ? {} : {
39
+ instance: effective.contributedBy
40
+ }
41
+ };
42
+ if (property.valueType === PropertyValueType.Icon) {
43
+ const value = effective ? effective.value : getValueAtPath(element.properties, property.path);
44
+ diagnostics.push(...iconProblemsOfProperty(iconCatalog, property, value, DiagnosticSeverity.Warning, where));
45
+ } else if (effective?.items) {
46
+ const items = effective.items.map((item)=>({
47
+ id: item.id,
48
+ values: item.values,
49
+ instance: item.origin === 'owner' ? undefined : item.origin
50
+ }));
51
+ diagnostics.push(...iconProblemsOfItems(iconCatalog, property.item, items, DiagnosticSeverity.Warning, {
52
+ component: element.id,
53
+ path: property.path
54
+ }));
55
+ } else {
56
+ diagnostics.push(...iconProblemsOfProperty(iconCatalog, property, getValueAtPath(element.properties, property.path), DiagnosticSeverity.Warning, where));
57
+ }
58
+ }
59
+ }
60
+ }
61
+ return diagnostics;
62
+ }
63
+
64
+ export { diagnoseIcons };
65
+ //# sourceMappingURL=diagnoseIcons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnoseIcons.js","sources":["../../../editing/diagnoseIcons.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 { DiagnosticSeverity, PropertyDescriptor, PropertyValueType, SceneDiagnostic, SceneDocument } from '@cratis/scene.model';\nimport { findComponentDescriptor } from './DescriptorCatalog';\nimport { EditingContext } from './EditingContext';\nimport { iconProblemsOfItems, iconProblemsOfProperty } from './iconDiagnostics';\nimport { getValueAtPath } from './pathAccess';\nimport { resolveEffectiveConfiguration } from './resolveEffectiveConfiguration';\nimport { resolveTemplateChain } from './resolveTemplateChain';\n\nfunction isIconBearing(property: PropertyDescriptor): boolean {\n return property.valueType === PropertyValueType.Icon\n || (property.valueType === PropertyValueType.Collection && (property.item?.properties ?? []).some((field) => field.valueType === PropertyValueType.Icon));\n}\n\n/**\n * Reports every icon in what the editing scope renders - the template chain's own values and what each instance\n * contributed - that the profile's icon catalog cannot supply: a library the profile lacks, an icon or variant a\n * library no longer has, a library at an incompatible version.\n *\n * It reports; it never changes anything. The offending values stay in the document, still applied (a renderer\n * shows its fallback), and apply again as soon as the icon is available, so removing a library is reversible.\n * Each diagnostic names the component, property, collection item and - for a contributed value - the instance.\n *\n * Returns nothing when the context carries no `iconCatalog`. Load the catalogs first (`iconCatalog.load()`) for\n * definite answers; an icon from an unloaded library is reported as not verified.\n */\nexport function diagnoseIcons(document: SceneDocument, context: EditingContext): SceneDiagnostic[] {\n const iconCatalog = context.iconCatalog;\n if (!iconCatalog) return [];\n\n const chain = resolveTemplateChain(document, context.scope);\n const configuration = resolveEffectiveConfiguration(chain, document.instanceContributions, context.catalog);\n const diagnostics: SceneDiagnostic[] = [];\n\n for (const level of chain.levels) {\n for (const element of level.elements) {\n const descriptor = findComponentDescriptor(context.catalog, element.componentName);\n const configured = configuration.components.find((candidate) => candidate.component === element.id);\n\n for (const property of (descriptor?.properties ?? []).filter(isIconBearing)) {\n const effective = configured?.values.find((candidate) => candidate.path === property.path);\n const where = { component: element.id, ...(effective?.contributedBy === undefined ? {} : { instance: effective.contributedBy }) };\n\n if (property.valueType === PropertyValueType.Icon) {\n const value = effective ? effective.value : getValueAtPath(element.properties, property.path);\n diagnostics.push(...iconProblemsOfProperty(iconCatalog, property, value, DiagnosticSeverity.Warning, where));\n } else if (effective?.items) {\n const items = effective.items.map((item) => ({ id: item.id, values: item.values, instance: item.origin === 'owner' ? undefined : item.origin }));\n diagnostics.push(...iconProblemsOfItems(iconCatalog, property.item, items, DiagnosticSeverity.Warning, { component: element.id, path: property.path }));\n } else {\n diagnostics.push(...iconProblemsOfProperty(iconCatalog, property, getValueAtPath(element.properties, property.path), DiagnosticSeverity.Warning, where));\n }\n }\n }\n }\n\n return diagnostics;\n}\n"],"names":["isIconBearing","property","valueType","PropertyValueType","Icon","Collection","item","properties","some","field","diagnoseIcons","document","context","iconCatalog","chain","resolveTemplateChain","scope","configuration","resolveEffectiveConfiguration","instanceContributions","catalog","diagnostics","level","levels","element","elements","descriptor","findComponentDescriptor","componentName","configured","components","find","candidate","component","id","filter","effective","values","path","where","contributedBy","undefined","instance","value","getValueAtPath","push","iconProblemsOfProperty","DiagnosticSeverity","Warning","items","map","origin","iconProblemsOfItems"],"mappings":";;;;;;;AAAA;AACA;AAUA,SAASA,cAAcC,QAA4B,EAAA;AAC/C,IAAA,OAAOA,QAAAA,CAASC,SAAS,KAAKC,iBAAAA,CAAkBC,IAAI,IAC5CH,QAAAA,CAASC,SAAS,KAAKC,iBAAAA,CAAkBE,UAAU,IAAI,CAACJ,QAAAA,CAASK,IAAI,EAAEC,UAAAA,IAAc,EAAC,EAAGC,IAAI,CAAC,CAACC,KAAAA,GAAUA,KAAAA,CAAMP,SAAS,KAAKC,kBAAkBC,IAAI,CAAA;AAC/J;AAEA;;;;;;;;;;;AAWC,IACM,SAASM,aAAAA,CAAcC,QAAuB,EAAEC,OAAuB,EAAA;IAC1E,MAAMC,WAAAA,GAAcD,QAAQC,WAAW;IACvC,IAAI,CAACA,WAAAA,EAAa,OAAO,EAAE;AAE3B,IAAA,MAAMC,KAAAA,GAAQC,oBAAAA,CAAqBJ,QAAAA,EAAUC,OAAAA,CAAQI,KAAK,CAAA;AAC1D,IAAA,MAAMC,gBAAgBC,6BAAAA,CAA8BJ,KAAAA,EAAOH,SAASQ,qBAAqB,EAAEP,QAAQQ,OAAO,CAAA;AAC1G,IAAA,MAAMC,cAAiC,EAAE;AAEzC,IAAA,KAAK,MAAMC,KAAAA,IAASR,KAAAA,CAAMS,MAAM,CAAE;AAC9B,QAAA,KAAK,MAAMC,OAAAA,IAAWF,KAAAA,CAAMG,QAAQ,CAAE;AAClC,YAAA,MAAMC,aAAaC,uBAAAA,CAAwBf,OAAAA,CAAQQ,OAAO,EAAEI,QAAQI,aAAa,CAAA;AACjF,YAAA,MAA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,GAAUV,SAAAA,GAAYnC,KAAK6C;yBAAO,CAAA,CAAA;oBAC7I9B,WAAAA,CAAYwB,IAAI,CAAA,GAAIO,mBAAAA,CAAoBvC,WAAAA,EAAaZ,QAAAA,CAASK,IAAI,EAAE2C,KAAAA,EAAOF,kBAAAA,CAAmBC,OAAO,EAAE;AAAEf,wBAAAA,SAAAA,EAAWT,QAAQU,EAAE;AAAEI,wBAAAA,IAAAA,EAAMrC,SAASqC;AAAK,qBAAA,CAAA,CAAA;gBACxJ,CAAA,MAAO;AACHjB,oBAAAA,WAAAA,CAAYwB,IAAI,CAAA,GAAIC,sBAAAA,CAAuBjC,WAAAA,EAAaZ,UAAU2C,cAAAA,CAAepB,OAAAA,CAAQjB,UAAU,EAAEN,QAAAA,CAASqC,IAAI,CAAA,EAAGS,kBAAAA,CAAmBC,OAAO,EAAET,KAAAA,CAAAA,CAAAA;AACrJ,gBAAA;AACJ,YAAA;AACJ,QAAA;AACJ,IAAA;IAEA,OAAOlB,WAAAA;AACX;;"}
@@ -0,0 +1,6 @@
1
+ import { DiagnosticCode, SceneDiagnostic } from '@cratis/scene.model';
2
+ export type DiagnosticContext = Partial<Omit<SceneDiagnostic, 'code' | 'severity' | 'message'>>;
3
+ export declare function errorDiagnostic(code: DiagnosticCode, message: string, context?: DiagnosticContext): SceneDiagnostic;
4
+ export declare function warningDiagnostic(code: DiagnosticCode, message: string, context?: DiagnosticContext): SceneDiagnostic;
5
+ export declare function hasErrors(diagnostics: SceneDiagnostic[]): boolean;
6
+ //# sourceMappingURL=diagnostics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../../editing/diagnostics.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAsB,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAK1F,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC;AAKhG,wBAAgB,eAAe,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,eAAe,CAEvH;AAKD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,eAAe,CAEzH;AAKD,wBAAgB,SAAS,CAAC,WAAW,EAAE,eAAe,EAAE,GAAG,OAAO,CAEjE"}
@@ -0,0 +1,32 @@
1
+ import { DiagnosticSeverity } from '@cratis/scene.model';
2
+
3
+ // Copyright (c) Cratis. All rights reserved.
4
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
5
+ /**
6
+ * Builds an error diagnostic: the edit or resolution step that produced it did not happen.
7
+ */ function errorDiagnostic(code, message, context = {}) {
8
+ return {
9
+ code,
10
+ severity: DiagnosticSeverity.Error,
11
+ message,
12
+ ...context
13
+ };
14
+ }
15
+ /**
16
+ * Builds a warning diagnostic: the work went ahead, and the author should know something about it.
17
+ */ function warningDiagnostic(code, message, context = {}) {
18
+ return {
19
+ code,
20
+ severity: DiagnosticSeverity.Warning,
21
+ message,
22
+ ...context
23
+ };
24
+ }
25
+ /**
26
+ * Whether any diagnostic is an error.
27
+ */ function hasErrors(diagnostics) {
28
+ return diagnostics.some((diagnostic)=>diagnostic.severity === DiagnosticSeverity.Error);
29
+ }
30
+
31
+ export { errorDiagnostic, hasErrors, warningDiagnostic };
32
+ //# sourceMappingURL=diagnostics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostics.js","sources":["../../../editing/diagnostics.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 { DiagnosticCode, DiagnosticSeverity, SceneDiagnostic } from '@cratis/scene.model';\n\n/**\n * The context a diagnostic can carry besides its code and message.\n */\nexport type DiagnosticContext = Partial<Omit<SceneDiagnostic, 'code' | 'severity' | 'message'>>;\n\n/**\n * Builds an error diagnostic: the edit or resolution step that produced it did not happen.\n */\nexport function errorDiagnostic(code: DiagnosticCode, message: string, context: DiagnosticContext = {}): SceneDiagnostic {\n return { code, severity: DiagnosticSeverity.Error, message, ...context };\n}\n\n/**\n * Builds a warning diagnostic: the work went ahead, and the author should know something about it.\n */\nexport function warningDiagnostic(code: DiagnosticCode, message: string, context: DiagnosticContext = {}): SceneDiagnostic {\n return { code, severity: DiagnosticSeverity.Warning, message, ...context };\n}\n\n/**\n * Whether any diagnostic is an error.\n */\nexport function hasErrors(diagnostics: SceneDiagnostic[]): boolean {\n return diagnostics.some(diagnostic => diagnostic.severity === DiagnosticSeverity.Error);\n}\n"],"names":["errorDiagnostic","code","message","context","severity","DiagnosticSeverity","Error","warningDiagnostic","Warning","hasErrors","diagnostics","some","diagnostic"],"mappings":";;AAAA;AACA;AASA;;IAGO,SAASA,eAAAA,CAAgBC,IAAoB,EAAEC,OAAe,EAAEC,OAAAA,GAA6B,EAAE,EAAA;IAClG,OAAO;AAAEF,QAAAA,IAAAA;AAAMG,QAAAA,QAAAA,EAAUC,mBAAmBC,KAAK;AAAEJ,QAAAA,OAAAA;AAAS,QAAA,GAAGC;AAAQ,KAAA;AAC3E;AAEA;;IAGO,SAASI,iBAAAA,CAAkBN,IAAoB,EAAEC,OAAe,EAAEC,OAAAA,GAA6B,EAAE,EAAA;IACpG,OAAO;AAAEF,QAAAA,IAAAA;AAAMG,QAAAA,QAAAA,EAAUC,mBAAmBG,OAAO;AAAEN,QAAAA,OAAAA;AAAS,QAAA,GAAGC;AAAQ,KAAA;AAC7E;AAEA;;IAGO,SAASM,SAAAA,CAAUC,WAA8B,EAAA;IACpD,OAAOA,WAAAA,CAAYC,IAAI,CAACC,CAAAA,aAAcA,UAAAA,CAAWR,QAAQ,KAAKC,kBAAAA,CAAmBC,KAAK,CAAA;AAC1F;;"}
@@ -0,0 +1,8 @@
1
+ import { DocumentPath } from './DocumentIndex';
2
+ export declare function getAtPath(root: unknown, path: DocumentPath): unknown;
3
+ export declare function ensureArrayAt(root: unknown, path: DocumentPath): unknown[];
4
+ export declare function mirroredPaths(mirror: {
5
+ prefix: DocumentPath;
6
+ others: DocumentPath[];
7
+ } | undefined, path: DocumentPath): DocumentPath[];
8
+ //# sourceMappingURL=documentPaths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentPaths.d.ts","sourceRoot":"","sources":["../../../editing/documentPaths.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAK/C,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAQpE;AAMD,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,EAAE,CAQ1E;AAMD,wBAAgB,aAAa,CAAC,MAAM,EAAE;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,YAAY,EAAE,CAAA;CAAE,GAAG,SAAS,EAAE,IAAI,EAAE,YAAY,GAAG,YAAY,EAAE,CAGtI"}
@@ -0,0 +1,41 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+ /**
4
+ * Reads the value at a document path.
5
+ */ function getAtPath(root, path) {
6
+ let current = root;
7
+ for (const key of path){
8
+ if (current === null || typeof current !== 'object') return undefined;
9
+ current = current[key];
10
+ }
11
+ return current;
12
+ }
13
+ /**
14
+ * Reads the array at a path, creating it - and any objects on the way - when it is not there yet. Mutates `root`,
15
+ * which callers hold a copy of.
16
+ */ function ensureArrayAt(root, path) {
17
+ let current = root;
18
+ path.forEach((key, position)=>{
19
+ if (current[key] === undefined) current[key] = position === path.length - 1 ? [] : {};
20
+ current = current[key];
21
+ });
22
+ return current;
23
+ }
24
+ /**
25
+ * The paths a change to `path` must be made at: the path itself and, for a node inside a freeform element, the same
26
+ * place in every other size-class variant's copy.
27
+ */ function mirroredPaths(mirror, path) {
28
+ if (!mirror || mirror.prefix.some((key, position)=>path[position] !== key)) return [
29
+ path
30
+ ];
31
+ return [
32
+ path,
33
+ ...mirror.others.map((other)=>[
34
+ ...other,
35
+ ...path.slice(mirror.prefix.length)
36
+ ])
37
+ ];
38
+ }
39
+
40
+ export { ensureArrayAt, getAtPath, mirroredPaths };
41
+ //# sourceMappingURL=documentPaths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentPaths.js","sources":["../../../editing/documentPaths.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 { DocumentPath } from './DocumentIndex';\n\n/**\n * Reads the value at a document path.\n */\nexport function getAtPath(root: unknown, path: DocumentPath): unknown {\n let current = root;\n for (const key of path) {\n if (current === null || typeof current !== 'object') return undefined;\n current = (current as Record<string | number, unknown>)[key];\n }\n\n return current;\n}\n\n/**\n * Reads the array at a path, creating it - and any objects on the way - when it is not there yet. Mutates `root`,\n * which callers hold a copy of.\n */\nexport function ensureArrayAt(root: unknown, path: DocumentPath): unknown[] {\n let current = root as Record<string | number, unknown>;\n path.forEach((key, position) => {\n if (current[key] === undefined) current[key] = position === path.length - 1 ? [] : {};\n current = current[key] as Record<string | number, unknown>;\n });\n\n return current as unknown as unknown[];\n}\n\n/**\n * The paths a change to `path` must be made at: the path itself and, for a node inside a freeform element, the same\n * place in every other size-class variant's copy.\n */\nexport function mirroredPaths(mirror: { prefix: DocumentPath; others: DocumentPath[] } | undefined, path: DocumentPath): DocumentPath[] {\n if (!mirror || mirror.prefix.some((key, position) => path[position] !== key)) return [path];\n return [path, ...mirror.others.map(other => [...other, ...path.slice(mirror.prefix.length)])];\n}\n"],"names":["getAtPath","root","path","current","key","undefined","ensureArrayAt","forEach","position","length","mirroredPaths","mirror","prefix","some","others","map","other","slice"],"mappings":"AAAA;AACA;AAIA;;AAEC,IACM,SAASA,SAAAA,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+1,5 @@
1
+ import { ExposePropertyEdit, SceneDiagnostic, SceneDocument, UnexposePropertyEdit } from '@cratis/scene.model';
2
+ import { EditSession } from './EditSession';
3
+ export declare function applyExposeProperty(session: EditSession, edit: ExposePropertyEdit, clone: SceneDocument, diagnostics: SceneDiagnostic[]): void;
4
+ export declare function applyUnexposeProperty(session: EditSession, edit: UnexposePropertyEdit, clone: SceneDocument, diagnostics: SceneDiagnostic[]): void;
5
+ //# sourceMappingURL=exposureEdits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exposureEdits.d.ts","sourceRoot":"","sources":["../../../editing/exposureEdits.ts"],"names":[],"mappings":"AAGA,OAAO,EACmD,kBAAkB,EAAqB,eAAe,EAC5G,aAAa,EAAE,oBAAoB,EACtC,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AA8E5C,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,eAAe,EAAE,GAAG,IAAI,CAc9I;AAKD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,oBAAoB,EAAE,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,eAAe,EAAE,GAAG,IAAI,CAYlJ"}
@@ -0,0 +1,103 @@
1
+ import { DiagnosticCode, PropertyValueType, CollectionOperation } from '@cratis/scene.model';
2
+ import { findComponentDescriptor } from './DescriptorCatalog.js';
3
+ import { errorDiagnostic } from './diagnostics.js';
4
+ import { grantKey } from './exposureGrants.js';
5
+ import { cloneData } from './pathAccess.js';
6
+
7
+ // Copyright (c) Cratis. All rights reserved.
8
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
9
+ function ownsDeclaration(session, owner, diagnostics) {
10
+ const level = session.chain.levels.at(-1);
11
+ if (!level || level.owner !== owner) {
12
+ diagnostics.push(errorDiagnostic(DiagnosticCode.NodeNotEditable, `Exposure is declared by the layout or template that owns the component. '${owner}' is not what is being edited.`));
13
+ return false;
14
+ }
15
+ return true;
16
+ }
17
+ function validateExposure(session, property, diagnostics) {
18
+ const context = {
19
+ component: property.component,
20
+ path: property.path
21
+ };
22
+ const level = session.chain.levels.at(-1);
23
+ const reExposed = property.reExposes !== undefined;
24
+ if (!reExposed && !level.elements.some((candidate)=>candidate.id === property.component)) {
25
+ diagnostics.push(errorDiagnostic(DiagnosticCode.ExposureTargetMissing, `'${level.owner}' has no component '${property.component}'.`, context));
26
+ return false;
27
+ }
28
+ const grant = reExposed ? session.scopeGrants.get(grantKey(property.component, property.path)) : undefined;
29
+ if (reExposed && (!grant || grant.owner !== property.reExposes)) {
30
+ diagnostics.push(errorDiagnostic(DiagnosticCode.ReExposureBroken, `'${property.reExposes}' does not expose '${property.path}' on '${property.component}' to '${level.owner}', so it cannot be passed on.`, context));
31
+ return false;
32
+ }
33
+ const element = level.elements.find((candidate)=>candidate.id === property.component);
34
+ const descriptor = grant ? grant.descriptor : findComponentDescriptor(session.context.catalog, element.componentName)?.properties.find((candidate)=>candidate.path === property.path);
35
+ if (!descriptor) {
36
+ diagnostics.push(errorDiagnostic(DiagnosticCode.ExposureTargetMissing, `There is no editable property '${property.path}' on '${property.component}'.`, context));
37
+ return false;
38
+ }
39
+ const operations = property.operations ?? [];
40
+ if (descriptor.valueType !== PropertyValueType.Collection) {
41
+ if (operations.length > 0 || property.editableFields !== undefined) {
42
+ diagnostics.push(errorDiagnostic(DiagnosticCode.InvalidEdit, `'${descriptor.label}' is not a collection, so operations and editable fields do not apply.`, context));
43
+ return false;
44
+ }
45
+ return true;
46
+ }
47
+ const known = Object.values(CollectionOperation);
48
+ const unknown = operations.find((operation)=>!known.includes(operation));
49
+ if (unknown !== undefined) {
50
+ diagnostics.push(errorDiagnostic(DiagnosticCode.InvalidEdit, `'${unknown}' is not a collection operation.`, context));
51
+ return false;
52
+ }
53
+ const fields = descriptor.item?.properties.map((candidate)=>candidate.path) ?? [];
54
+ const unknownField = property.editableFields?.find((field)=>!fields.includes(field));
55
+ if (unknownField !== undefined) {
56
+ diagnostics.push(errorDiagnostic(DiagnosticCode.UnknownCollectionField, `Items of '${descriptor.label}' have no field '${unknownField}'.`, context));
57
+ return false;
58
+ }
59
+ if (grant && (operations.some((operation)=>!grant.operations.includes(operation)) || grant.editableFields !== undefined && (property.editableFields ?? fields).some((field)=>!grant.editableFields.includes(field)))) {
60
+ diagnostics.push(errorDiagnostic(DiagnosticCode.ExposureWidensOwner, `'${property.reExposes}' exposed less of '${descriptor.label}' than this re-exposes.`, context));
61
+ return false;
62
+ }
63
+ return true;
64
+ }
65
+ /**
66
+ * Applies an exposure declaration to a copy of the document.
67
+ *
68
+ * Exposure only narrows: the property has to be one the component's descriptor supports, a collection's
69
+ * operations and fields have to exist, and a re-exposure cannot grant more than the owner it passes on.
70
+ */ function applyExposeProperty(session, edit, clone, diagnostics) {
71
+ if (!ownsDeclaration(session, edit.owner, diagnostics) || !validateExposure(session, edit.property, diagnostics)) return;
72
+ let declaration = clone.exposures.find((candidate)=>candidate.owner === edit.owner);
73
+ if (!declaration) {
74
+ declaration = {
75
+ owner: edit.owner,
76
+ properties: []
77
+ };
78
+ clone.exposures.push(declaration);
79
+ }
80
+ const same = (candidate)=>candidate.component === edit.property.component && candidate.path === edit.property.path && candidate.reExposes === edit.property.reExposes;
81
+ const position = declaration.properties.findIndex(same);
82
+ if (position >= 0) declaration.properties[position] = cloneData(edit.property);
83
+ else declaration.properties.push(cloneData(edit.property));
84
+ }
85
+ /**
86
+ * Applies an exposure withdrawal to a copy of the document. Values already saved against it are not touched.
87
+ */ function applyUnexposeProperty(session, edit, clone, diagnostics) {
88
+ if (!ownsDeclaration(session, edit.owner, diagnostics)) return;
89
+ const declaration = clone.exposures.find((candidate)=>candidate.owner === edit.owner);
90
+ const remaining = declaration?.properties.filter((candidate)=>!(candidate.component === edit.component && candidate.path === edit.path));
91
+ if (!declaration || remaining.length === declaration.properties.length) {
92
+ diagnostics.push(errorDiagnostic(DiagnosticCode.ExposureTargetMissing, `'${edit.owner}' does not expose '${edit.path}' on '${edit.component}'.`, {
93
+ component: edit.component,
94
+ path: edit.path
95
+ }));
96
+ return;
97
+ }
98
+ if (remaining.length === 0) clone.exposures.splice(clone.exposures.indexOf(declaration), 1);
99
+ else declaration.properties = remaining;
100
+ }
101
+
102
+ export { applyExposeProperty, applyUnexposeProperty };
103
+ //# sourceMappingURL=exposureEdits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exposureEdits.js","sources":["../../../editing/exposureEdits.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 {\n CollectionOperation, DiagnosticCode, ExposedProperty, ExposePropertyEdit, PropertyValueType, SceneDiagnostic,\n SceneDocument, UnexposePropertyEdit,\n} from '@cratis/scene.model';\nimport { findComponentDescriptor } from './DescriptorCatalog';\nimport { errorDiagnostic } from './diagnostics';\nimport { EditSession } from './EditSession';\nimport { grantKey } from './exposureGrants';\nimport { cloneData } from './pathAccess';\n\nfunction ownsDeclaration(session: EditSession, owner: string, diagnostics: SceneDiagnostic[]): boolean {\n const level = session.chain.levels.at(-1);\n if (!level || level.owner !== owner) {\n diagnostics.push(errorDiagnostic(DiagnosticCode.NodeNotEditable, `Exposure is declared by the layout or template that owns the component. '${owner}' is not what is being edited.`));\n return false;\n }\n\n return true;\n}\n\nfunction validateExposure(session: EditSession, property: ExposedProperty, diagnostics: SceneDiagnostic[]): boolean {\n const context = { component: property.component, path: property.path };\n const level = session.chain.levels.at(-1)!;\n const reExposed = property.reExposes !== undefined;\n\n if (!reExposed && !level.elements.some(candidate => candidate.id === property.component)) {\n diagnostics.push(errorDiagnostic(DiagnosticCode.ExposureTargetMissing, `'${level.owner}' has no component '${property.component}'.`, context));\n return false;\n }\n\n const grant = reExposed ? session.scopeGrants.get(grantKey(property.component, property.path)) : undefined;\n if (reExposed && (!grant || grant.owner !== property.reExposes)) {\n diagnostics.push(errorDiagnostic(DiagnosticCode.ReExposureBroken, `'${property.reExposes}' does not expose '${property.path}' on '${property.component}' to '${level.owner}', so it cannot be passed on.`, context));\n return false;\n }\n\n const element = level.elements.find(candidate => candidate.id === property.component);\n const descriptor = grant\n ? grant.descriptor\n : findComponentDescriptor(session.context.catalog, element!.componentName)?.properties.find(candidate => candidate.path === property.path);\n if (!descriptor) {\n diagnostics.push(errorDiagnostic(DiagnosticCode.ExposureTargetMissing, `There is no editable property '${property.path}' on '${property.component}'.`, context));\n return false;\n }\n\n const operations = property.operations ?? [];\n if (descriptor.valueType !== PropertyValueType.Collection) {\n if (operations.length > 0 || property.editableFields !== undefined) {\n diagnostics.push(errorDiagnostic(DiagnosticCode.InvalidEdit, `'${descriptor.label}' is not a collection, so operations and editable fields do not apply.`, context));\n return false;\n }\n\n return true;\n }\n\n const known = Object.values(CollectionOperation) as string[];\n const unknown = operations.find(operation => !known.includes(operation));\n if (unknown !== undefined) {\n diagnostics.push(errorDiagnostic(DiagnosticCode.InvalidEdit, `'${unknown}' is not a collection operation.`, context));\n return false;\n }\n\n const fields = descriptor.item?.properties.map(candidate => candidate.path) ?? [];\n const unknownField = property.editableFields?.find(field => !fields.includes(field));\n if (unknownField !== undefined) {\n diagnostics.push(errorDiagnostic(DiagnosticCode.UnknownCollectionField, `Items of '${descriptor.label}' have no field '${unknownField}'.`, context));\n return false;\n }\n\n if (grant && (operations.some(operation => !grant.operations.includes(operation))\n || (grant.editableFields !== undefined && (property.editableFields ?? fields).some(field => !grant.editableFields!.includes(field))))) {\n diagnostics.push(errorDiagnostic(DiagnosticCode.ExposureWidensOwner, `'${property.reExposes}' exposed less of '${descriptor.label}' than this re-exposes.`, context));\n return false;\n }\n\n return true;\n}\n\n/**\n * Applies an exposure declaration to a copy of the document.\n *\n * Exposure only narrows: the property has to be one the component's descriptor supports, a collection's\n * operations and fields have to exist, and a re-exposure cannot grant more than the owner it passes on.\n */\nexport function applyExposeProperty(session: EditSession, edit: ExposePropertyEdit, clone: SceneDocument, diagnostics: SceneDiagnostic[]): void {\n if (!ownsDeclaration(session, edit.owner, diagnostics) || !validateExposure(session, edit.property, diagnostics)) return;\n\n let declaration = clone.exposures.find(candidate => candidate.owner === edit.owner);\n if (!declaration) {\n declaration = { owner: edit.owner, properties: [] };\n clone.exposures.push(declaration);\n }\n\n const same = (candidate: ExposedProperty) => candidate.component === edit.property.component\n && candidate.path === edit.property.path && candidate.reExposes === edit.property.reExposes;\n const position = declaration.properties.findIndex(same);\n if (position >= 0) declaration.properties[position] = cloneData(edit.property);\n else declaration.properties.push(cloneData(edit.property));\n}\n\n/**\n * Applies an exposure withdrawal to a copy of the document. Values already saved against it are not touched.\n */\nexport function applyUnexposeProperty(session: EditSession, edit: UnexposePropertyEdit, clone: SceneDocument, diagnostics: SceneDiagnostic[]): void {\n if (!ownsDeclaration(session, edit.owner, diagnostics)) return;\n\n const declaration = clone.exposures.find(candidate => candidate.owner === edit.owner);\n const remaining = declaration?.properties.filter(candidate => !(candidate.component === edit.component && candidate.path === edit.path));\n if (!declaration || remaining!.length === declaration.properties.length) {\n diagnostics.push(errorDiagnostic(DiagnosticCode.ExposureTargetMissing, `'${edit.owner}' does not expose '${edit.path}' on '${edit.component}'.`, { component: edit.component, path: edit.path }));\n return;\n }\n\n if (remaining!.length === 0) clone.exposures.splice(clone.exposures.indexOf(declaration), 1);\n else declaration.properties = remaining!;\n}\n"],"names":["ownsDeclaration","session","owner","diagnostics","level","chain","levels","at","push","errorDiagnostic","DiagnosticCode","NodeNotEditable","validateExposure","property","context","component","path","reExposed","reExposes","undefined","elements","some","candidate","id","ExposureTargetMissing","grant","scopeGrants","get","grantKey","ReExposureBroken","element","find","descriptor","findComponentDescriptor","catalog","componentName","properties","operations","valueType","PropertyValueType","Collection","length","editableFields","InvalidEdit","label","known","Object","values","CollectionOperation","unknown","operation","includes","fields","item","map","unknownField","field","UnknownCollectionField","ExposureWidensOwner","applyExposeProperty","edit","clone","declaration","exposures","same","position","findIndex","cloneData","applyUnexposeProperty","remaining","filter","splice","indexOf"],"mappings":";;;;;;AAAA;AACA;AAYA,SAASA,eAAAA,CAAgBC,OAAoB,EAAEC,KAAa,EAAEC,WAA8B,EAAA;IACxF,MAAMC,KAAAA,GAAQH,QAAQI,KAAK,CAACC,MAAM,CAACC,EAAE,CAAC,EAAC,CAAA;AACvC,IAAA,IAAI,CAACH,KAAAA,IAASA,KAAAA,CAAMF,KAAK,KAAKA,KAAAA,EAAO;QACjCC,WAAAA,CAAYK,IAAI,CAACC,eAAAA,CAAgBC,cAAAA,CAAeC,eAAe,EAAE,CAAC,yEAAyE,EAAET,KAAAA,CAAM,8BAA8B,CAAC,CAAA,CAAA;QAClL,OAAO,KAAA;AACX,IAAA;IAEA,OAAO,IAAA;AACX;AAEA,SAASU,gBAAAA,CAAiBX,OAAoB,EAAEY,QAAyB,EAAEV,WAA8B,EAAA;AACrG,IAAA,MAAMW,OAAAA,GAAU;AAAEC,QAAAA,SAAAA,EAAWF,SAASE,SAAS;AAAEC,QAAAA,IAAAA,EAAMH,SAASG;AAAK,KAAA;IACrE,MAAMZ,KAAAA,GAAQH,QAAQI,KAAK,CAACC,MAAM,CAACC,EAAE,CAAC,EAAC,CAAA;IACvC,MAAMU,SAAAA,GAAYJ,QAAAA,CAASK,SAAS,KAAKC,SAAAA;AAEzC,IAAA,IAAI,CAACF,SAAAA,IAAa,CAACb,KAAAA,CAAMgB,QAAQ,CAACC,IAAI,CAACC,CAAAA,YAAaA,SAAAA,CAAUC,EAAE,KAAKV,QAAAA,CAASE,SAAS,CAAA,EAAG;AACtFZ,QAAAA,WAAAA,CAAYK,IAAI,CAACC,eAAAA,CAAgBC,eAAec,qBAAqB,EAAE,CAAC,CAAC,EAAEpB,MAAMF,KAAK,CAAC,oBAAoB,EAAEW,QAAAA,CAASE,SAAS,CAAC,EAAE,CAAC,EAAED,OAAAA,CAAAA,CAAAA;QACrI,OAAO,KAAA;AACX,IAAA;AAE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K1D,KAAK,CAAA;AACpF,IAAA,MAAMmE,YAAYP,WAAAA,EAAa1B,UAAAA,CAAWkC,OAAOhD,CAAAA,SAAAA,GAAa,EAAEA,SAAAA,CAAUP,SAAS,KAAK6C,IAAAA,CAAK7C,SAAS,IAAIO,SAAAA,CAAUN,IAAI,KAAK4C,IAAAA,CAAK5C,IAAI,CAAD,CAAA;IACrI,IAAI,CAAC8C,eAAeO,SAAAA,CAAW5B,MAAM,KAAKqB,WAAAA,CAAY1B,UAAU,CAACK,MAAM,EAAE;QACrEtC,WAAAA,CAAYK,IAAI,CAACC,eAAAA,CAAgBC,cAAAA,CAAec,qBAAqB,EAAE,CAAC,CAAC,EAAEoC,IAAAA,CAAK1D,KAAK,CAAC,mBAAmB,EAAE0D,IAAAA,CAAK5C,IAAI,CAAC,MAAM,EAAE4C,KAAK7C,SAAS,CAAC,EAAE,CAAC,EAAE;AAAEA,YAAAA,SAAAA,EAAW6C,KAAK7C,SAAS;AAAEC,YAAAA,IAAAA,EAAM4C,KAAK5C;AAAK,SAAA,CAAA,CAAA;AAC9L,QAAA;AACJ,IAAA;AAEA,IAAA,IAAIqD,SAAAA,CAAW5B,MAAM,KAAK,CAAA,EAAGoB,MAAME,SAAS,CAACQ,MAAM,CAACV,KAAAA,CAAME,SAAS,CAACS,OAAO,CAACV,WAAAA,CAAAA,EAAc,CAAA,CAAA;AACrFA,SAAAA,WAAAA,CAAY1B,UAAU,GAAGiC,SAAAA;AAClC;;"}
@@ -0,0 +1,21 @@
1
+ import { CollectionOperation, PropertyDescriptor, SceneDiagnostic } from '@cratis/scene.model';
2
+ import { DescriptorCatalog } from './DescriptorCatalog';
3
+ import { TemplateChain } from './TemplateChain';
4
+ export interface ExposureGrant {
5
+ component: string;
6
+ path: string;
7
+ descriptor: PropertyDescriptor;
8
+ owner: string;
9
+ ownerLevel: number;
10
+ operations: CollectionOperation[];
11
+ editableFields?: string[];
12
+ label?: string;
13
+ }
14
+ export interface ExposureGrants {
15
+ exposed: ExposureGrant[];
16
+ byInstance: Map<string, Map<string, ExposureGrant>>;
17
+ diagnostics: SceneDiagnostic[];
18
+ }
19
+ export declare function grantKey(component: string, path: string): string;
20
+ export declare function computeExposureGrants(chain: TemplateChain, catalog: DescriptorCatalog): ExposureGrants;
21
+ //# sourceMappingURL=exposureGrants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exposureGrants.d.ts","sourceRoot":"","sources":["../../../editing/exposureGrants.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,mBAAmB,EAAmC,kBAAkB,EAAqB,eAAe,EAC/G,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAA2B,MAAM,qBAAqB,CAAC;AAEjF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAMhD,MAAM,WAAW,aAAa;IAE1B,SAAS,EAAE,MAAM,CAAC;IAElB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,kBAAkB,CAAC;IAG/B,KAAK,EAAE,MAAM,CAAC;IAGd,UAAU,EAAE,MAAM,CAAC;IAGnB,UAAU,EAAE,mBAAmB,EAAE,CAAC;IAGlC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAE1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAKD,MAAM,WAAW,cAAc;IAE3B,OAAO,EAAE,aAAa,EAAE,CAAC;IAGzB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC;IAEpD,WAAW,EAAE,eAAe,EAAE,CAAC;CAClC;AAKD,wBAAgB,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhE;AAyBD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,iBAAiB,GAAG,cAAc,CA+EtG"}