@cratis/scene.react 4.15.0 → 4.17.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 (116) hide show
  1. package/core/ScreenplayCoreComponents.tsx +24 -3
  2. package/core/coreComponents.ts +2 -0
  3. package/core/coreDescriptors.ts +6 -0
  4. package/core/corePackage.ts +1 -0
  5. package/dist/cjs/SceneElementView.js +1 -0
  6. package/dist/cjs/SceneElementView.js.map +1 -1
  7. package/dist/cjs/core/ScreenplayCoreComponents.js +25 -5
  8. package/dist/cjs/core/ScreenplayCoreComponents.js.map +1 -1
  9. package/dist/cjs/core/coreComponents.js +3 -1
  10. package/dist/cjs/core/coreComponents.js.map +1 -1
  11. package/dist/cjs/core/coreDescriptors.js +16 -0
  12. package/dist/cjs/core/coreDescriptors.js.map +1 -1
  13. package/dist/cjs/core/corePackage.js +2 -1
  14. package/dist/cjs/core/corePackage.js.map +1 -1
  15. package/dist/cjs/index.js +18 -0
  16. package/dist/cjs/index.js.map +1 -1
  17. package/dist/cjs/navigation/CoreOutlet.js +32 -0
  18. package/dist/cjs/navigation/CoreOutlet.js.map +1 -0
  19. package/dist/cjs/navigation/SceneNavigationContext.js +2 -0
  20. package/dist/cjs/navigation/SceneNavigationContext.js.map +1 -1
  21. package/dist/cjs/navigation/SceneNavigationHost.js +46 -29
  22. package/dist/cjs/navigation/SceneNavigationHost.js.map +1 -1
  23. package/dist/cjs/navigation/SceneOutletContext.js +14 -0
  24. package/dist/cjs/navigation/SceneOutletContext.js.map +1 -0
  25. package/dist/cjs/navigation/collectOutletOwners.js +36 -0
  26. package/dist/cjs/navigation/collectOutletOwners.js.map +1 -0
  27. package/dist/cjs/navigation/createHashSceneHistory.js +43 -0
  28. package/dist/cjs/navigation/createHashSceneHistory.js.map +1 -0
  29. package/dist/cjs/navigation/placeInOutlet.js +65 -0
  30. package/dist/cjs/navigation/placeInOutlet.js.map +1 -0
  31. package/dist/cjs/navigation/useSceneHistoryNavigation.js +22 -6
  32. package/dist/cjs/navigation/useSceneHistoryNavigation.js.map +1 -1
  33. package/dist/cjs/renderer/useValueOutput.js +31 -0
  34. package/dist/cjs/renderer/useValueOutput.js.map +1 -0
  35. package/dist/cjs/renderer/valueOutputProperty.js +28 -0
  36. package/dist/cjs/renderer/valueOutputProperty.js.map +1 -0
  37. package/dist/esm/SceneElementView.js +1 -0
  38. package/dist/esm/SceneElementView.js.map +1 -1
  39. package/dist/esm/core/ScreenplayCoreComponents.d.ts.map +1 -1
  40. package/dist/esm/core/ScreenplayCoreComponents.js +25 -5
  41. package/dist/esm/core/ScreenplayCoreComponents.js.map +1 -1
  42. package/dist/esm/core/coreComponents.d.ts.map +1 -1
  43. package/dist/esm/core/coreComponents.js +3 -1
  44. package/dist/esm/core/coreComponents.js.map +1 -1
  45. package/dist/esm/core/coreDescriptors.d.ts.map +1 -1
  46. package/dist/esm/core/coreDescriptors.js +16 -0
  47. package/dist/esm/core/coreDescriptors.js.map +1 -1
  48. package/dist/esm/core/corePackage.d.ts.map +1 -1
  49. package/dist/esm/core/corePackage.js +2 -1
  50. package/dist/esm/core/corePackage.js.map +1 -1
  51. package/dist/esm/index.js +8 -1
  52. package/dist/esm/index.js.map +1 -1
  53. package/dist/esm/navigation/CoreOutlet.d.ts +3 -0
  54. package/dist/esm/navigation/CoreOutlet.d.ts.map +1 -0
  55. package/dist/esm/navigation/CoreOutlet.js +30 -0
  56. package/dist/esm/navigation/CoreOutlet.js.map +1 -0
  57. package/dist/esm/navigation/SceneNavigationContext.d.ts +3 -0
  58. package/dist/esm/navigation/SceneNavigationContext.d.ts.map +1 -1
  59. package/dist/esm/navigation/SceneNavigationContext.js +3 -2
  60. package/dist/esm/navigation/SceneNavigationContext.js.map +1 -1
  61. package/dist/esm/navigation/SceneNavigationHost.d.ts.map +1 -1
  62. package/dist/esm/navigation/SceneNavigationHost.js +47 -30
  63. package/dist/esm/navigation/SceneNavigationHost.js.map +1 -1
  64. package/dist/esm/navigation/SceneNavigationState.d.ts +2 -0
  65. package/dist/esm/navigation/SceneNavigationState.d.ts.map +1 -1
  66. package/dist/esm/navigation/SceneOutletContext.d.ts +9 -0
  67. package/dist/esm/navigation/SceneOutletContext.d.ts.map +1 -0
  68. package/dist/esm/navigation/SceneOutletContext.js +11 -0
  69. package/dist/esm/navigation/SceneOutletContext.js.map +1 -0
  70. package/dist/esm/navigation/collectOutletOwners.d.ts +4 -0
  71. package/dist/esm/navigation/collectOutletOwners.d.ts.map +1 -0
  72. package/dist/esm/navigation/collectOutletOwners.js +33 -0
  73. package/dist/esm/navigation/collectOutletOwners.js.map +1 -0
  74. package/dist/esm/navigation/createHashSceneHistory.d.ts +4 -0
  75. package/dist/esm/navigation/createHashSceneHistory.d.ts.map +1 -0
  76. package/dist/esm/navigation/createHashSceneHistory.js +41 -0
  77. package/dist/esm/navigation/createHashSceneHistory.js.map +1 -0
  78. package/dist/esm/navigation/index.d.ts +5 -0
  79. package/dist/esm/navigation/index.d.ts.map +1 -1
  80. package/dist/esm/navigation/index.js +5 -0
  81. package/dist/esm/navigation/index.js.map +1 -1
  82. package/dist/esm/navigation/placeInOutlet.d.ts +4 -0
  83. package/dist/esm/navigation/placeInOutlet.d.ts.map +1 -0
  84. package/dist/esm/navigation/placeInOutlet.js +63 -0
  85. package/dist/esm/navigation/placeInOutlet.js.map +1 -0
  86. package/dist/esm/navigation/useSceneHistoryNavigation.d.ts +2 -1
  87. package/dist/esm/navigation/useSceneHistoryNavigation.d.ts.map +1 -1
  88. package/dist/esm/navigation/useSceneHistoryNavigation.js +22 -6
  89. package/dist/esm/navigation/useSceneHistoryNavigation.js.map +1 -1
  90. package/dist/esm/renderer/index.d.ts +2 -0
  91. package/dist/esm/renderer/index.d.ts.map +1 -1
  92. package/dist/esm/renderer/index.js +2 -0
  93. package/dist/esm/renderer/index.js.map +1 -1
  94. package/dist/esm/renderer/useValueOutput.d.ts +4 -0
  95. package/dist/esm/renderer/useValueOutput.d.ts.map +1 -0
  96. package/dist/esm/renderer/useValueOutput.js +28 -0
  97. package/dist/esm/renderer/useValueOutput.js.map +1 -0
  98. package/dist/esm/renderer/valueOutputProperty.d.ts +3 -0
  99. package/dist/esm/renderer/valueOutputProperty.d.ts.map +1 -0
  100. package/dist/esm/renderer/valueOutputProperty.js +26 -0
  101. package/dist/esm/renderer/valueOutputProperty.js.map +1 -0
  102. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  103. package/navigation/CoreOutlet.tsx +26 -0
  104. package/navigation/SceneNavigationContext.tsx +10 -0
  105. package/navigation/SceneNavigationHost.tsx +12 -6
  106. package/navigation/SceneNavigationState.ts +13 -0
  107. package/navigation/SceneOutletContext.tsx +19 -0
  108. package/navigation/collectOutletOwners.ts +30 -0
  109. package/navigation/createHashSceneHistory.ts +42 -0
  110. package/navigation/index.ts +5 -0
  111. package/navigation/placeInOutlet.ts +68 -0
  112. package/navigation/useSceneHistoryNavigation.ts +20 -5
  113. package/package.json +5 -5
  114. package/renderer/index.ts +2 -0
  115. package/renderer/useValueOutput.ts +28 -0
  116. package/renderer/valueOutputProperty.ts +25 -0
@@ -6,6 +6,7 @@ export * from './SceneNavigationHost';
6
6
  export * from './SceneNavigationState';
7
7
  export * from './SceneRoute';
8
8
  export * from './createBrowserSceneHistory';
9
+ export * from './createHashSceneHistory';
9
10
  export * from './createMemorySceneHistory';
10
11
  export * from './diagnoseRenderedNavigation';
11
12
  export * from './identityRoute';
@@ -14,4 +15,8 @@ export * from './navigationRouteKey';
14
15
  export * from './resolveDestination';
15
16
  export * from './sceneRoutesFrom';
16
17
  export * from './useSceneHistoryNavigation';
18
+ export * from './CoreOutlet';
19
+ export * from './SceneOutletContext';
20
+ export * from './collectOutletOwners';
21
+ export * from './placeInOutlet';
17
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../navigation/index.ts"],"names":[],"mappings":"AAGA,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../navigation/index.ts"],"names":[],"mappings":"AAGA,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC"}
@@ -6,6 +6,7 @@ export * from './SceneNavigationHost';
6
6
  export * from './SceneNavigationState';
7
7
  export * from './SceneRoute';
8
8
  export * from './createBrowserSceneHistory';
9
+ export * from './createHashSceneHistory';
9
10
  export * from './createMemorySceneHistory';
10
11
  export * from './diagnoseRenderedNavigation';
11
12
  export * from './identityRoute';
@@ -14,4 +15,8 @@ export * from './navigationRouteKey';
14
15
  export * from './resolveDestination';
15
16
  export * from './sceneRoutesFrom';
16
17
  export * from './useSceneHistoryNavigation';
18
+ export * from './CoreOutlet';
19
+ export * from './SceneOutletContext';
20
+ export * from './collectOutletOwners';
21
+ export * from './placeInOutlet';
17
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../navigation/index.ts"],"names":[],"mappings":"AAGA,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../navigation/index.ts"],"names":[],"mappings":"AAGA,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { DestinationReference } from '@cratis/scene.model';
2
+ import { SceneNavigationState } from './SceneNavigationState';
3
+ export declare function placeInOutlet(current: SceneNavigationState, screen: string, outlet: string | undefined, owners: Record<string, string>, destinations?: DestinationReference[]): Pick<SceneNavigationState, 'primary' | 'outlets'>;
4
+ //# sourceMappingURL=placeInOutlet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"placeInOutlet.d.ts","sourceRoot":"","sources":["../../../navigation/placeInOutlet.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAa9D,wBAAgB,aAAa,CACzB,OAAO,EAAE,oBAAoB,EAC7B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,YAAY,GAAE,oBAAoB,EAAO,GAC1C,IAAI,CAAC,oBAAoB,EAAE,SAAS,GAAG,SAAS,CAAC,CAmBnD"}
@@ -0,0 +1,63 @@
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
+ /** The most levels of nesting a placement follows before it stops, so a cyclic model cannot loop forever. */ const maximumDepth = 32;
4
+ /**
5
+ * Places a screen, recursively composing nested outlets.
6
+ *
7
+ * When `outlet` is a nested outlet - one a screen declares with `core:outlet` - the screen goes into it, and
8
+ * the screen that declares it is placed first: where it already is, or, when it is not on the page, where a
9
+ * known destination puts it, up to the primary region. Outlets declared by screens that are no longer on the
10
+ * page are dropped. Any other outlet replaces the primary region and clears every nested placement.
11
+ */ function placeInOutlet(current, screen, outlet, owners, destinations = []) {
12
+ const primary = current.primary ?? current.screen;
13
+ const placements = {
14
+ ...current.outlets ?? {}
15
+ };
16
+ let root = primary;
17
+ let target = {
18
+ screen,
19
+ outlet
20
+ };
21
+ for(let depth = 0; target && depth < maximumDepth; depth++){
22
+ const owner = target.outlet === undefined ? undefined : owners[target.outlet];
23
+ if (owner === undefined) {
24
+ root = target.screen;
25
+ break;
26
+ }
27
+ placements[target.outlet] = target.screen;
28
+ if (isOnPage(owner, root, placements, owners)) break;
29
+ target = {
30
+ screen: owner,
31
+ outlet: destinations.find((destination)=>destination.screen === owner && destination.outlet)?.outlet
32
+ };
33
+ }
34
+ return {
35
+ primary: root,
36
+ outlets: reachable(root, placements, owners)
37
+ };
38
+ }
39
+ /** Whether a screen is the root or shown in an outlet reachable from it. */ function isOnPage(screen, root, placements, owners) {
40
+ return screen === root || Object.values(reachable(root, placements, owners)).includes(screen);
41
+ }
42
+ /** Only the placements reachable from the root through the outlets each placed screen declares. */ function reachable(root, placements, owners) {
43
+ const kept = {};
44
+ const pending = [
45
+ root
46
+ ];
47
+ const seen = new Set();
48
+ while(pending.length > 0){
49
+ const screen = pending.shift();
50
+ if (seen.has(screen)) continue;
51
+ seen.add(screen);
52
+ for (const [outlet, placed] of Object.entries(placements)){
53
+ if (owners[outlet] === screen) {
54
+ kept[outlet] = placed;
55
+ pending.push(placed);
56
+ }
57
+ }
58
+ }
59
+ return kept;
60
+ }
61
+
62
+ export { placeInOutlet };
63
+ //# sourceMappingURL=placeInOutlet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"placeInOutlet.js","sources":["../../../navigation/placeInOutlet.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 { DestinationReference } from '@cratis/scene.model';\nimport { SceneNavigationState } from './SceneNavigationState';\n\n/** The most levels of nesting a placement follows before it stops, so a cyclic model cannot loop forever. */\nconst maximumDepth = 32;\n\n/**\n * Places a screen, recursively composing nested outlets.\n *\n * When `outlet` is a nested outlet - one a screen declares with `core:outlet` - the screen goes into it, and\n * the screen that declares it is placed first: where it already is, or, when it is not on the page, where a\n * known destination puts it, up to the primary region. Outlets declared by screens that are no longer on the\n * page are dropped. Any other outlet replaces the primary region and clears every nested placement.\n */\nexport function placeInOutlet(\n current: SceneNavigationState,\n screen: string,\n outlet: string | undefined,\n owners: Record<string, string>,\n destinations: DestinationReference[] = [],\n): Pick<SceneNavigationState, 'primary' | 'outlets'> {\n const primary = current.primary ?? current.screen;\n const placements: Record<string, string> = { ...(current.outlets ?? {}) };\n let root = primary;\n\n let target: { screen: string; outlet: string | undefined } | undefined = { screen, outlet };\n for (let depth = 0; target && depth < maximumDepth; depth++) {\n const owner = target.outlet === undefined ? undefined : owners[target.outlet];\n if (owner === undefined) {\n root = target.screen;\n break;\n }\n\n placements[target.outlet!] = target.screen;\n if (isOnPage(owner, root, placements, owners)) break;\n target = { screen: owner, outlet: destinations.find(destination => destination.screen === owner && destination.outlet)?.outlet };\n }\n\n return { primary: root, outlets: reachable(root, placements, owners) };\n}\n\n/** Whether a screen is the root or shown in an outlet reachable from it. */\nfunction isOnPage(screen: string, root: string, placements: Record<string, string>, owners: Record<string, string>): boolean {\n return screen === root || Object.values(reachable(root, placements, owners)).includes(screen);\n}\n\n/** Only the placements reachable from the root through the outlets each placed screen declares. */\nfunction reachable(root: string, placements: Record<string, string>, owners: Record<string, string>): Record<string, string> {\n const kept: Record<string, string> = {};\n const pending = [root];\n const seen = new Set<string>();\n while (pending.length > 0) {\n const screen = pending.shift()!;\n if (seen.has(screen)) continue;\n seen.add(screen);\n for (const [outlet, placed] of Object.entries(placements)) {\n if (owners[outlet] === screen) {\n kept[outlet] = placed;\n pending.push(placed);\n }\n }\n }\n\n return kept;\n}\n"],"names":["maximumDepth","placeInOutlet","current","screen","outlet","owners","destinations","primary","placements","outlets","root","target","depth","owner","undefined","isOnPage","find","destination","reachable","Object","values","includes","kept","pending","seen","Set","length","shift","has","add","placed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,EAASG,IAAAA;QAAMD,OAAAA,EAASS,SAAAA,CAAUR,MAAMF,UAAAA,EAAYH,MAAAA;AAAQ,KAAA;AACzE;AAEA,6EACA,SAASU,QAAAA,CAASZ,MAAc,EAAEO,IAAY,EAAEF,UAAkC,EAAEH,MAA8B,EAAA;IAC9G,OAAOF,MAAAA,KAAWO,IAAAA,IAAQS,MAAAA,CAAOC,MAAM,CAACF,UAAUR,IAAAA,EAAMF,UAAAA,EAAYH,MAAAA,CAAAA,CAAAA,CAASgB,QAAQ,CAAClB,MAAAA,CAAAA;AAC1F;AAEA,oGACA,SAASe,SAAAA,CAAUR,IAAY,EAAEF,UAAkC,EAAEH,MAA8B,EAAA;AAC/F,IAAA,MAAMiB,OAA+B,EAAC;AACtC,IAAA,MAAMC,OAAAA,GAAU;AAACb,QAAAA;AAAK,KAAA;AACtB,IAAA,MAAMc,OAAO,IAAIC,GAAAA,EAAAA;IACjB,MAAOF,OAAAA,CAAQG,MAAM,GAAG,CAAA,CAAG;QACvB,MAAMvB,MAAAA,GAASoB,QAAQI,KAAK,EAAA;QAC5B,IAAIH,IAAAA,CAAKI,GAAG,CAACzB,MAAAA,CAAAA,EAAS;AACtBqB,QAAAA,IAAAA,CAAKK,GAAG,CAAC1B,MAAAA,CAAAA;QACT,KAAK,MAAM,CAACC,MAAAA,EAAQ0B,MAAAA,CAAO,IAAIX,MAAAA,CAAOY,OAAO,CAACvB,UAAAA,CAAAA,CAAa;AACvD,YAAA,IAAIH,MAAM,CAACD,MAAAA,CAAO,KAAKD,MAAAA,EAAQ;gBAC3BmB,IAAI,CAAClB,OAAO,GAAG0B,MAAAA;AACfP,gBAAAA,OAAAA,CAAQS,IAAI,CAACF,MAAAA,CAAAA;AACjB,YAAA;AACJ,QAAA;AACJ,IAAA;IAEA,OAAOR,IAAAA;AACX;;"}
@@ -1,6 +1,7 @@
1
1
  import { BindingScope } from '@cratis/scene.engine';
2
+ import { DestinationReference } from '@cratis/scene.model';
2
3
  import { SceneHistory } from './SceneHistory';
3
4
  import { SceneNavigationContextValue } from './SceneNavigationContext';
4
5
  import { SceneRoute } from './SceneRoute';
5
- export declare function useSceneHistoryNavigation(history: SceneHistory, routes: SceneRoute[], initialScreen: string, bindingScope: BindingScope): SceneNavigationContextValue;
6
+ export declare function useSceneHistoryNavigation(history: SceneHistory, routes: SceneRoute[], initialScreen: string, bindingScope: BindingScope, outletOwners?: Record<string, string>, destinations?: DestinationReference[]): SceneNavigationContextValue;
6
7
  //# sourceMappingURL=useSceneHistoryNavigation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSceneHistoryNavigation.d.ts","sourceRoot":"","sources":["../../../navigation/useSceneHistoryNavigation.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAKpD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAEvE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAO1C,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,GAAG,2BAA2B,CA4DrK"}
1
+ {"version":3,"file":"useSceneHistoryNavigation.d.ts","sourceRoot":"","sources":["../../../navigation/useSceneHistoryNavigation.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAmB,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAK5E,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAEvE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAO1C,wBAAgB,yBAAyB,CACrC,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,UAAU,EAAE,EACpB,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,YAAY,EAC1B,YAAY,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,EACzC,YAAY,GAAE,oBAAoB,EAAO,GAC1C,2BAA2B,CAmE7B"}
@@ -1,6 +1,7 @@
1
1
  import { useCallback, useMemo, useState, useRef, useEffect } from 'react';
2
2
  import { DestinationKind } from '@cratis/scene.model';
3
3
  import { matchSceneRoute } from './matchSceneRoute.js';
4
+ import { placeInOutlet } from './placeInOutlet.js';
4
5
  import { resolveDestination } from './resolveDestination.js';
5
6
 
6
7
  // Copyright (c) Cratis. All rights reserved.
@@ -9,16 +10,24 @@ import { resolveDestination } from './resolveDestination.js';
9
10
  * Keeps a navigation host's state in a {@link SceneHistory}: every navigation and every dialog is an entry,
10
11
  * so back and forward step through them, a refresh restores the stored entry, and a deep link is matched
11
12
  * against the route table. Closing a dialog goes back to the entry that opened it.
12
- */ function useSceneHistoryNavigation(history, routes, initialScreen, bindingScope) {
13
+ */ function useSceneHistoryNavigation(history, routes, initialScreen, bindingScope, outletOwners = {}, destinations = []) {
13
14
  const fromLocation = useCallback((url)=>{
14
15
  const match = url ? matchSceneRoute(url, routes) : undefined;
15
- return match ? {
16
+ if (!match) return undefined;
17
+ const start = {
18
+ screen: initialScreen};
19
+ const placement = placeInOutlet(start, match.route.screen, match.route.outlet, outletOwners, destinations);
20
+ return {
16
21
  screen: match.route.screen,
17
22
  url,
18
23
  outlet: match.route.outlet,
19
- parameters: match.parameters
20
- } : undefined;
24
+ parameters: match.parameters,
25
+ ...placement
26
+ };
21
27
  }, [
28
+ destinations,
29
+ initialScreen,
30
+ outletOwners,
22
31
  routes
23
32
  ]);
24
33
  const fallback = useMemo(()=>({
@@ -59,17 +68,22 @@ import { resolveDestination } from './resolveDestination.js';
59
68
  dialog: resolution.dialog
60
69
  });
61
70
  } else if (resolution.kind !== DestinationKind.External) {
71
+ const screen = destination.screen ?? destination.slice ?? state.screen;
72
+ const placement = placeInOutlet(state, screen, resolution.outlet, outletOwners, destinations);
62
73
  go({
63
- screen: destination.screen ?? destination.slice ?? state.screen,
74
+ screen,
64
75
  url: resolution.url,
65
76
  outlet: resolution.outlet,
66
- parameters: resolution.parameters
77
+ parameters: resolution.parameters,
78
+ ...placement
67
79
  });
68
80
  }
69
81
  return resolution;
70
82
  }, [
71
83
  bindingScope,
84
+ destinations,
72
85
  go,
86
+ outletOwners,
73
87
  state
74
88
  ]);
75
89
  const closeDialog = useCallback((result)=>{
@@ -85,6 +99,8 @@ import { resolveDestination } from './resolveDestination.js';
85
99
  ]);
86
100
  return useMemo(()=>({
87
101
  currentScreen: state.screen,
102
+ primaryScreen: state.primary ?? state.screen,
103
+ outlets: state.outlets ?? {},
88
104
  currentUrl: state.url,
89
105
  currentOutlet: state.outlet,
90
106
  currentDialog: state.dialog,
@@ -1 +1 @@
1
- {"version":3,"file":"useSceneHistoryNavigation.js","sources":["../../../navigation/useSceneHistoryNavigation.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 { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { BindingScope } from '@cratis/scene.engine';\nimport { DestinationKind, DestinationReference } from '@cratis/scene.model';\nimport { DialogResult } from './DialogResult';\nimport { matchSceneRoute } from './matchSceneRoute';\nimport { resolveDestination } from './resolveDestination';\nimport { SceneHistory } from './SceneHistory';\nimport { SceneNavigationContextValue } from './SceneNavigationContext';\nimport { SceneNavigationState } from './SceneNavigationState';\nimport { SceneRoute } from './SceneRoute';\n\n/**\n * Keeps a navigation host's state in a {@link SceneHistory}: every navigation and every dialog is an entry,\n * so back and forward step through them, a refresh restores the stored entry, and a deep link is matched\n * against the route table. Closing a dialog goes back to the entry that opened it.\n */\nexport function useSceneHistoryNavigation(history: SceneHistory, routes: SceneRoute[], initialScreen: string, bindingScope: BindingScope): SceneNavigationContextValue {\n const fromLocation = useCallback((url: string | undefined): SceneNavigationState | undefined => {\n const match = url ? matchSceneRoute(url, routes) : undefined;\n return match ? { screen: match.route.screen, url, outlet: match.route.outlet, parameters: match.parameters } : undefined;\n }, [routes]);\n const fallback = useMemo<SceneNavigationState>(() => ({ screen: initialScreen, url: initialScreen, parameters: {} }), [initialScreen]);\n\n const [unresolvedUrl] = useState(() => {\n const url = history.location();\n return !history.state() && url && !fromLocation(url) ? url : undefined;\n });\n const [state, setState] = useState<SceneNavigationState>(() => history.state() ?? fromLocation(history.location()) ?? fallback);\n const [dialogResult, setDialogResult] = useState<DialogResult>();\n\n // Back and forward restore the stored entry, or match a URL the host never wrote against the current routes.\n const restore = useRef((url: string | undefined, stored: SceneNavigationState | undefined) => stored ?? fromLocation(url) ?? fallback);\n restore.current = (url, stored) => stored ?? fromLocation(url) ?? fallback;\n const initialState = useRef(state);\n\n // The current entry is written once, when a history is attached; later entries are written by navigate.\n useEffect(() => {\n history.replace(initialState.current);\n return history.listen((url, stored) => setState(restore.current(url, stored)));\n }, [history]);\n\n const go = useCallback((next: SceneNavigationState) => {\n history.push(next);\n setState(next);\n }, [history]);\n\n const navigate = useCallback((destination: DestinationReference) => {\n const resolution = resolveDestination(destination, bindingScope);\n if (resolution.kind === DestinationKind.Dialog) {\n if (resolution.dialog) go({ ...state, dialog: resolution.dialog });\n } else if (resolution.kind !== DestinationKind.External) {\n go({ screen: destination.screen ?? destination.slice ?? state.screen, url: resolution.url, outlet: resolution.outlet, parameters: resolution.parameters });\n }\n\n return resolution;\n }, [bindingScope, go, state]);\n\n const closeDialog = useCallback((result?: unknown) => {\n if (!state.dialog) return;\n setDialogResult({ dialog: state.dialog, result });\n history.back();\n }, [history, state.dialog]);\n\n return useMemo(() => ({\n currentScreen: state.screen,\n currentUrl: state.url,\n currentOutlet: state.outlet,\n currentDialog: state.dialog,\n currentParameters: state.parameters,\n dialogResult,\n unresolvedUrl,\n bindingScope,\n navigate,\n closeDialog,\n back: () => history.back(),\n }), [bindingScope, closeDialog, dialogResult, history, navigate, state, unresolvedUrl]);\n}\n"],"names":["useSceneHistoryNavigation","history","routes","initialScreen","bindingScope","fromLocation","useCallback","url","match","matchSceneRoute","undefined","screen","route","outlet","parameters","fallback","useMemo","unresolvedUrl","useState","location","state","setState","dialogResult","setDialogResult","restore","useRef","stored","current","initialState","useEffect","replace","listen","go","next","push","navigate","destination","resolution","resolveDestination","kind","DestinationKind","Dialog","dialog","External","slice","closeDialog","result","back","currentScreen","currentUrl","currentOutlet","currentDialog","currentParameters"],"mappings":";;;;;AAAA;AACA;AAaA;;;;IAKO,SAASA,yBAAAA,CAA0BC,OAAqB,EAAEC,MAAoB,EAAEC,aAAqB,EAAEC,YAA0B,EAAA;IACpI,MAAMC,YAAAA,GAAeC,YAAY,CAACC,GAAAA,GAAAA;AAC9B,QAAA,MAAMC,KAAAA,GAAQD,GAAAA,GAAME,eAAAA,CAAgBF,GAAAA,EAAKL,MAAAA,CAAAA,GAAUQ,SAAAA;AACnD,QAAA,OAAOF,KAAAA,GAAQ;YAAEG,MAAAA,EAAQH,KAAAA,CAAMI,KAAK,CAACD,MAAM;AAAEJ,YAAAA,GAAAA;YAAKM,MAAAA,EAAQL,KAAAA,CAAMI,KAAK,CAACC,MAAM;AAAEC,YAAAA,UAAAA,EAAYN,MAAMM;SAAW,GAAIJ,SAAAA;IACnH,CAAA,EAAG;AAACR,QAAAA;AAAO,KAAA,CAAA;IACX,MAAMa,QAAAA,GAAWC,OAAAA,CAA8B,KAAO;YAAEL,MAAAA,EAAQR,aAAAA;YAAeI,GAAAA,EAAKJ,aAAAA;AAAeW,YAAAA,UAAAA,EAAY;AAAG,SAAA,CAAA,EAAI;AAACX,QAAAA;AAAc,KAAA,CAAA;IAErI,MAAM,CAACc,aAAAA,CAAc,GAAGC,QAAAA,CAAS,IAAA;QAC7B,MAAMX,GAAAA,GAAMN,QAAQkB,QAAQ,EAAA;QAC5B,OAAO,CAAClB,QAAQmB,KAAK,EAAA,IAAMb,OAAO,CAACF,YAAAA,CAAaE,OAAOA,GAA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sC,YAAAA,aAAAA,EAAe/B,MAAMsB,MAAM;AAC3BU,YAAAA,iBAAAA,EAAmBhC,MAAMN,UAAU;AACnCQ,YAAAA,YAAAA;AACAL,YAAAA,aAAAA;AACAb,YAAAA,YAAAA;AACA+B,YAAAA,QAAAA;AACAU,YAAAA,WAAAA;YACAE,IAAAA,EAAM,IAAM9C,QAAQ8C,IAAI;AAC5B,SAAA,CAAA,EAAI;AAAC3C,QAAAA,YAAAA;AAAcyC,QAAAA,WAAAA;AAAavB,QAAAA,YAAAA;AAAcrB,QAAAA,OAAAA;AAASkC,QAAAA,QAAAA;AAAUf,QAAAA,KAAAA;AAAOH,QAAAA;AAAc,KAAA,CAAA;AAC1F;;"}
1
+ {"version":3,"file":"useSceneHistoryNavigation.js","sources":["../../../navigation/useSceneHistoryNavigation.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 { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { BindingScope } from '@cratis/scene.engine';\nimport { DestinationKind, DestinationReference } from '@cratis/scene.model';\nimport { DialogResult } from './DialogResult';\nimport { matchSceneRoute } from './matchSceneRoute';\nimport { placeInOutlet } from './placeInOutlet';\nimport { resolveDestination } from './resolveDestination';\nimport { SceneHistory } from './SceneHistory';\nimport { SceneNavigationContextValue } from './SceneNavigationContext';\nimport { SceneNavigationState } from './SceneNavigationState';\nimport { SceneRoute } from './SceneRoute';\n\n/**\n * Keeps a navigation host's state in a {@link SceneHistory}: every navigation and every dialog is an entry,\n * so back and forward step through them, a refresh restores the stored entry, and a deep link is matched\n * against the route table. Closing a dialog goes back to the entry that opened it.\n */\nexport function useSceneHistoryNavigation(\n history: SceneHistory,\n routes: SceneRoute[],\n initialScreen: string,\n bindingScope: BindingScope,\n outletOwners: Record<string, string> = {},\n destinations: DestinationReference[] = [],\n): SceneNavigationContextValue {\n const fromLocation = useCallback((url: string | undefined): SceneNavigationState | undefined => {\n const match = url ? matchSceneRoute(url, routes) : undefined;\n if (!match) return undefined;\n const start: SceneNavigationState = { screen: initialScreen, parameters: {} };\n const placement = placeInOutlet(start, match.route.screen, match.route.outlet, outletOwners, destinations);\n return { screen: match.route.screen, url, outlet: match.route.outlet, parameters: match.parameters, ...placement };\n }, [destinations, initialScreen, outletOwners, routes]);\n const fallback = useMemo<SceneNavigationState>(() => ({ screen: initialScreen, url: initialScreen, parameters: {} }), [initialScreen]);\n\n const [unresolvedUrl] = useState(() => {\n const url = history.location();\n return !history.state() && url && !fromLocation(url) ? url : undefined;\n });\n const [state, setState] = useState<SceneNavigationState>(() => history.state() ?? fromLocation(history.location()) ?? fallback);\n const [dialogResult, setDialogResult] = useState<DialogResult>();\n\n // Back and forward restore the stored entry, or match a URL the host never wrote against the current routes.\n const restore = useRef((url: string | undefined, stored: SceneNavigationState | undefined) => stored ?? fromLocation(url) ?? fallback);\n restore.current = (url, stored) => stored ?? fromLocation(url) ?? fallback;\n const initialState = useRef(state);\n\n // The current entry is written once, when a history is attached; later entries are written by navigate.\n useEffect(() => {\n history.replace(initialState.current);\n return history.listen((url, stored) => setState(restore.current(url, stored)));\n }, [history]);\n\n const go = useCallback((next: SceneNavigationState) => {\n history.push(next);\n setState(next);\n }, [history]);\n\n const navigate = useCallback((destination: DestinationReference) => {\n const resolution = resolveDestination(destination, bindingScope);\n if (resolution.kind === DestinationKind.Dialog) {\n if (resolution.dialog) go({ ...state, dialog: resolution.dialog });\n } else if (resolution.kind !== DestinationKind.External) {\n const screen = destination.screen ?? destination.slice ?? state.screen;\n const placement = placeInOutlet(state, screen, resolution.outlet, outletOwners, destinations);\n go({ screen, url: resolution.url, outlet: resolution.outlet, parameters: resolution.parameters, ...placement });\n }\n\n return resolution;\n }, [bindingScope, destinations, go, outletOwners, state]);\n\n const closeDialog = useCallback((result?: unknown) => {\n if (!state.dialog) return;\n setDialogResult({ dialog: state.dialog, result });\n history.back();\n }, [history, state.dialog]);\n\n return useMemo(() => ({\n currentScreen: state.screen,\n primaryScreen: state.primary ?? state.screen,\n outlets: state.outlets ?? {},\n currentUrl: state.url,\n currentOutlet: state.outlet,\n currentDialog: state.dialog,\n currentParameters: state.parameters,\n dialogResult,\n unresolvedUrl,\n bindingScope,\n navigate,\n closeDialog,\n back: () => history.back(),\n }), [bindingScope, closeDialog, dialogResult, history, navigate, state, unresolvedUrl]);\n}\n"],"names":["useSceneHistoryNavigation","history","routes","initialScreen","bindingScope","outletOwners","destinations","fromLocation","useCallback","url","match","matchSceneRoute","undefined","start","screen","placement","placeInOutlet","route","outlet","parameters","fallback","useMemo","unresolvedUrl","useState","location","state","setState","dialogResult","setDialogResult","restore","useRef","stored","current","initialState","useEffect","replace","listen","go","next","push","navigate","destination","resolution","resolveDestination","kind","DestinationKind","Dialog","dialog","External","slice","closeDialog","result","back","currentScreen","primaryScreen","primary","outlets","currentUrl","currentOutlet","currentDialog","currentParameters"],"mappings":";;;;;;AAAA;AACA;AAcA;;;;AAIC,IACM,SAASA,yBAAAA,CACZC,OAAqB,EACrBC,MAAoB,EACpBC,aAAqB,EACrBC,YAA0B,EAC1BC,YAAAA,GAAuC,EAAE,EACzCC,eAAuC,EAAE,EAAA;IAEzC,MAAMC,YAAAA,GAAeC,YAAY,CAACC,GAAAA,GAAAA;AAC9B,QAAA,MAAMC,KAAAA,GAAQD,GAAAA,GAAME,eAAAA,CAAgBF,GAAAA,EAAKP,MAAAA,CAAAA,GAAUU,SAAAA;QACnD,IAAI,CAACF,OAAO,OAAOE,SAAAA;AACnB,QAAA,MAAMC,KAAAA,GAA8B;YAAEC,MAAAA,EAAQX,aAA8B,CAAA;AAC5E,QAAA,MAAMY,SAAAA,GAAYC,aAAAA,CAAcH,KAAAA,EAAOH,KAAAA,CAAMO,KAAK,CAACH,MAAM,EAAEJ,KAAAA,CAAMO,KAAK,CAACC,MAAM,EAAEb,YAAAA,EAAcC,YAAAA,CAAAA;QAC7F,OAAO;YAAEQ,MAAAA,EAAQJ,KAAAA,CAAMO,KAAK,C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nD,QAAQmD,IAAI;AAC5B,SAAA,CAAA,EAAI;AAAChD,QAAAA,YAAAA;AAAc8C,QAAAA,WAAAA;AAAavB,QAAAA,YAAAA;AAAc1B,QAAAA,OAAAA;AAASuC,QAAAA,QAAAA;AAAUf,QAAAA,KAAAA;AAAOH,QAAAA;AAAc,KAAA,CAAA;AAC1F;;"}
@@ -4,6 +4,8 @@ export * from './ComponentRegistry';
4
4
  export * from './RenderBindingScopeContext';
5
5
  export * from './UnresolvedComponent';
6
6
  export * from './useBoundQuery';
7
+ export * from './useValueOutput';
8
+ export * from './valueOutputProperty';
7
9
  export * from './createReactRenderer';
8
10
  export * from './InteractiveComponent';
9
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../renderer/index.ts"],"names":[],"mappings":"AAGA,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../renderer/index.ts"],"names":[],"mappings":"AAGA,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC"}
@@ -4,6 +4,8 @@ export * from './ComponentRegistry';
4
4
  export * from './RenderBindingScopeContext';
5
5
  export * from './UnresolvedComponent';
6
6
  export * from './useBoundQuery';
7
+ export * from './useValueOutput';
8
+ export * from './valueOutputProperty';
7
9
  export * from './createReactRenderer';
8
10
  export * from './InteractiveComponent';
9
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../renderer/index.ts"],"names":[],"mappings":"AAGA,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../renderer/index.ts"],"names":[],"mappings":"AAGA,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { ComponentBindingOutputs } from './BindingOutputContext';
2
+ export declare const valueOutputName = "value";
3
+ export declare function useValueOutput(bindingOutputs: ComponentBindingOutputs | undefined, value: unknown): void;
4
+ //# sourceMappingURL=useValueOutput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useValueOutput.d.ts","sourceRoot":"","sources":["../../../renderer/useValueOutput.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,eAAO,MAAM,eAAe,UAAU,CAAC;AAUvC,wBAAgB,cAAc,CAAC,cAAc,EAAE,uBAAuB,GAAG,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAUxG"}
@@ -0,0 +1,28 @@
1
+ import { useRef, useEffect } from 'react';
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
+ /** The output property an input widget publishes its current value under. */ const valueOutputName = 'value';
6
+ /**
7
+ * Publishes an input widget's current value as its `value` output: once when it mounts, with the initial
8
+ * value, and again on every change. Other elements bind to it with a `componentProperty` binding, and a
9
+ * command action maps it as `component.<id>.value`. The renderer clears the output when the widget unmounts.
10
+ *
11
+ * Values are published as JSON-compatible data so both engines read the same thing: a `Date` is published
12
+ * as its ISO 8601 string, and `undefined` as `null`.
13
+ */ function useValueOutput(bindingOutputs, value) {
14
+ const published = value instanceof Date ? value.toISOString() : value ?? null;
15
+ const key = JSON.stringify(published);
16
+ const latest = useRef(published);
17
+ latest.current = published;
18
+ // Published by value through `key`: a new array or object with the same content is not a change.
19
+ useEffect(()=>{
20
+ bindingOutputs?.setOutput(valueOutputName, latest.current);
21
+ }, [
22
+ bindingOutputs,
23
+ key
24
+ ]);
25
+ }
26
+
27
+ export { useValueOutput, valueOutputName };
28
+ //# sourceMappingURL=useValueOutput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useValueOutput.js","sources":["../../../renderer/useValueOutput.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 { useEffect, useRef } from 'react';\nimport { ComponentBindingOutputs } from './BindingOutputContext';\n\n/** The output property an input widget publishes its current value under. */\nexport const valueOutputName = 'value';\n\n/**\n * Publishes an input widget's current value as its `value` output: once when it mounts, with the initial\n * value, and again on every change. Other elements bind to it with a `componentProperty` binding, and a\n * command action maps it as `component.<id>.value`. The renderer clears the output when the widget unmounts.\n *\n * Values are published as JSON-compatible data so both engines read the same thing: a `Date` is published\n * as its ISO 8601 string, and `undefined` as `null`.\n */\nexport function useValueOutput(bindingOutputs: ComponentBindingOutputs | undefined, value: unknown): void {\n const published = value instanceof Date ? value.toISOString() : value ?? null;\n const key = JSON.stringify(published);\n const latest = useRef(published);\n latest.current = published;\n\n // Published by value through `key`: a new array or object with the same content is not a change.\n useEffect(() => {\n bindingOutputs?.setOutput(valueOutputName, latest.current);\n }, [bindingOutputs, key]);\n}\n"],"names":["valueOutputName","useValueOutput","bindingOutputs","value","published","Date","toISOString","key","JSON","stringify","latest","useRef","current","useEffect","setOutput"],"mappings":";;AAAA;AACA;AAKA,8EACO,MAAMA,eAAAA,GAAkB;AAE/B;;;;;;;AAOC,IACM,SAASC,cAAAA,CAAeC,cAAmD,EAAEC,KAAc,EAAA;AAC9F,IAAA,MAAMC,YAAYD,KAAAA,YAAiBE,IAAAA,GAAOF,KAAAA,CAAMG,WAAW,KAAKH,KAAAA,IAAS,IAAA;IACzE,MAAMI,GAAAA,GAAMC,IAAAA,CAAKC,SAAS,CAACL,SAAAA,CAAAA;AAC3B,IAAA,MAAMM,SAASC,MAAAA,CAAOP,SAAAA,CAAAA;AACtBM,IAAAA,MAAAA,CAAOE,OAAO,GAAGR,SAAAA;;IAGjBS,SAAAA,CAAU,IAAA;QACNX,cAAAA,EAAgBY,SAAAA,CAAUd,eAAAA,EAAiBU,MAAAA,CAAOE,OAAO,CAAA;IAC7D,CAAA,EAAG;AAACV,QAAAA,cAAAA;AAAgBK,QAAAA;AAAI,KAAA,CAAA;AAC5B;;"}
@@ -0,0 +1,3 @@
1
+ import { PropertyDescriptor, PropertyValueType } from '@cratis/scene.model';
2
+ export declare function valueOutputProperty(valueType: PropertyValueType, description?: string): PropertyDescriptor;
3
+ //# sourceMappingURL=valueOutputProperty.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"valueOutputProperty.d.ts","sourceRoot":"","sources":["../../../renderer/valueOutputProperty.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAUzF,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,iBAAiB,EAAE,WAAW,SAA+D,GAAG,kBAAkB,CAWhK"}
@@ -0,0 +1,26 @@
1
+ import { BindingMode } from '@cratis/scene.model';
2
+ import { valueOutputName } from './useValueOutput.js';
3
+
4
+ // Copyright (c) Cratis. All rights reserved.
5
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
6
+ /**
7
+ * The descriptor entry an input widget declares for the value it publishes with `useValueOutput`, so a
8
+ * designer can offer it as a binding source - for a detail component, a query argument or a command input.
9
+ *
10
+ * @param valueType The type of value the widget publishes.
11
+ * @param description What the value is, when the default sentence does not say enough.
12
+ */ function valueOutputProperty(valueType, description = 'What the user has entered, published as the input changes.') {
13
+ return {
14
+ path: valueOutputName,
15
+ label: 'Value',
16
+ group: 'Outputs',
17
+ valueType,
18
+ readOnly: true,
19
+ output: true,
20
+ bindingMode: BindingMode.OneWay,
21
+ description
22
+ };
23
+ }
24
+
25
+ export { valueOutputProperty };
26
+ //# sourceMappingURL=valueOutputProperty.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"valueOutputProperty.js","sources":["../../../renderer/valueOutputProperty.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 { BindingMode, PropertyDescriptor, PropertyValueType } from '@cratis/scene.model';\nimport { valueOutputName } from './useValueOutput';\n\n/**\n * The descriptor entry an input widget declares for the value it publishes with `useValueOutput`, so a\n * designer can offer it as a binding source - for a detail component, a query argument or a command input.\n *\n * @param valueType The type of value the widget publishes.\n * @param description What the value is, when the default sentence does not say enough.\n */\nexport function valueOutputProperty(valueType: PropertyValueType, description = 'What the user has entered, published as the input changes.'): PropertyDescriptor {\n return {\n path: valueOutputName,\n label: 'Value',\n group: 'Outputs',\n valueType,\n readOnly: true,\n output: true,\n bindingMode: BindingMode.OneWay,\n description,\n };\n}\n"],"names":["valueOutputProperty","valueType","description","path","valueOutputName","label","group","readOnly","output","bindingMode","BindingMode","OneWay"],"mappings":";;;AAAA;AACA;AAKA;;;;;;AAMC,IACM,SAASA,mBAAAA,CAAoBC,SAA4B,EAAEC,cAAc,4DAA4D,EAAA;IACxI,OAAO;QACHC,IAAAA,EAAMC,eAAAA;QACNC,KAAAA,EAAO,OAAA;QACPC,KAAAA,EAAO,SAAA;AACPL,QAAAA,SAAAA;QACAM,QAAAA,EAAU,IAAA;QACVC,MAAAA,EAAQ,IAAA;AACRC,QAAAA,WAAAA,EAAaC,YAAYC,MAAM;AAC/BT,QAAAA;AACJ,KAAA;AACJ;;"}