@cratis/scene.react 4.12.0 → 4.14.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.
- package/dist/cjs/core/coreComponents.js +2 -1
- package/dist/cjs/core/coreComponents.js.map +1 -1
- package/dist/cjs/core/coreDescriptors.js +1 -0
- package/dist/cjs/core/coreDescriptors.js.map +1 -1
- package/dist/cjs/index.js +27 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/navigation/SceneNavigationContext.js.map +1 -1
- package/dist/cjs/navigation/SceneNavigationHost.js +19 -44
- package/dist/cjs/navigation/SceneNavigationHost.js.map +1 -1
- package/dist/cjs/navigation/createBrowserSceneHistory.js +39 -0
- package/dist/cjs/navigation/createBrowserSceneHistory.js.map +1 -0
- package/dist/cjs/navigation/createMemorySceneHistory.js +53 -0
- package/dist/cjs/navigation/createMemorySceneHistory.js.map +1 -0
- package/dist/cjs/navigation/diagnoseRenderedNavigation.js +17 -0
- package/dist/cjs/navigation/diagnoseRenderedNavigation.js.map +1 -0
- package/dist/cjs/navigation/identityRoute.js +19 -0
- package/dist/cjs/navigation/identityRoute.js.map +1 -0
- package/dist/cjs/navigation/matchSceneRoute.js +43 -0
- package/dist/cjs/navigation/matchSceneRoute.js.map +1 -0
- package/dist/cjs/navigation/navigationRouteKey.js +19 -0
- package/dist/cjs/navigation/navigationRouteKey.js.map +1 -0
- package/dist/cjs/navigation/resolveDestination.js +3 -10
- package/dist/cjs/navigation/resolveDestination.js.map +1 -1
- package/dist/cjs/navigation/sceneRoutesFrom.js +37 -0
- package/dist/cjs/navigation/sceneRoutesFrom.js.map +1 -0
- package/dist/cjs/navigation/useSceneHistoryNavigation.js +112 -0
- package/dist/cjs/navigation/useSceneHistoryNavigation.js.map +1 -0
- package/dist/cjs/packages/DesignTimeContractVersion.js +15 -0
- package/dist/cjs/packages/DesignTimeContractVersion.js.map +1 -0
- package/dist/cjs/packages/DesignTimeExtensionPoint.js +26 -0
- package/dist/cjs/packages/DesignTimeExtensionPoint.js.map +1 -0
- package/dist/cjs/packages/PackageHostConfiguration.js +1 -0
- package/dist/cjs/packages/PackageHostConfiguration.js.map +1 -1
- package/dist/cjs/packages/loadDesignTimeContributions.js +80 -0
- package/dist/cjs/packages/loadDesignTimeContributions.js.map +1 -0
- package/dist/cjs/packages/resolveDesignTimeHost.js +114 -0
- package/dist/cjs/packages/resolveDesignTimeHost.js.map +1 -0
- package/dist/cjs/packages/runDesignTimeAction.js +50 -0
- package/dist/cjs/packages/runDesignTimeAction.js.map +1 -0
- package/dist/esm/core/coreComponents.js +2 -1
- package/dist/esm/core/coreComponents.js.map +1 -1
- package/dist/esm/core/coreDescriptors.js +1 -0
- package/dist/esm/core/coreDescriptors.js.map +1 -1
- package/dist/esm/index.js +13 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/navigation/DestinationResolution.d.ts +1 -0
- package/dist/esm/navigation/DestinationResolution.d.ts.map +1 -1
- package/dist/esm/navigation/DialogResult.d.ts +5 -0
- package/dist/esm/navigation/DialogResult.d.ts.map +1 -0
- package/dist/esm/navigation/DialogResult.js +2 -0
- package/dist/esm/navigation/DialogResult.js.map +1 -0
- package/dist/esm/navigation/SceneHistory.d.ts +10 -0
- package/dist/esm/navigation/SceneHistory.d.ts.map +1 -0
- package/dist/esm/navigation/SceneHistory.js +2 -0
- package/dist/esm/navigation/SceneHistory.js.map +1 -0
- package/dist/esm/navigation/SceneNavigationContext.d.ts +6 -1
- package/dist/esm/navigation/SceneNavigationContext.d.ts.map +1 -1
- package/dist/esm/navigation/SceneNavigationContext.js.map +1 -1
- package/dist/esm/navigation/SceneNavigationHost.d.ts +7 -2
- package/dist/esm/navigation/SceneNavigationHost.d.ts.map +1 -1
- package/dist/esm/navigation/SceneNavigationHost.js +20 -45
- package/dist/esm/navigation/SceneNavigationHost.js.map +1 -1
- package/dist/esm/navigation/SceneNavigationState.d.ts +8 -0
- package/dist/esm/navigation/SceneNavigationState.d.ts.map +1 -0
- package/dist/esm/navigation/SceneNavigationState.js +2 -0
- package/dist/esm/navigation/SceneNavigationState.js.map +1 -0
- package/dist/esm/navigation/SceneRoute.d.ts +6 -0
- package/dist/esm/navigation/SceneRoute.d.ts.map +1 -0
- package/dist/esm/navigation/SceneRoute.js +2 -0
- package/dist/esm/navigation/SceneRoute.js.map +1 -0
- package/dist/esm/navigation/createBrowserSceneHistory.d.ts +4 -0
- package/dist/esm/navigation/createBrowserSceneHistory.d.ts.map +1 -0
- package/dist/esm/navigation/createBrowserSceneHistory.js +37 -0
- package/dist/esm/navigation/createBrowserSceneHistory.js.map +1 -0
- package/dist/esm/navigation/createMemorySceneHistory.d.ts +7 -0
- package/dist/esm/navigation/createMemorySceneHistory.d.ts.map +1 -0
- package/dist/esm/navigation/createMemorySceneHistory.js +51 -0
- package/dist/esm/navigation/createMemorySceneHistory.js.map +1 -0
- package/dist/esm/navigation/diagnoseRenderedNavigation.d.ts +3 -0
- package/dist/esm/navigation/diagnoseRenderedNavigation.d.ts.map +1 -0
- package/dist/esm/navigation/diagnoseRenderedNavigation.js +15 -0
- package/dist/esm/navigation/diagnoseRenderedNavigation.js.map +1 -0
- package/dist/esm/navigation/identityRoute.d.ts +3 -0
- package/dist/esm/navigation/identityRoute.d.ts.map +1 -0
- package/dist/esm/navigation/identityRoute.js +17 -0
- package/dist/esm/navigation/identityRoute.js.map +1 -0
- package/dist/esm/navigation/index.d.ts +12 -0
- package/dist/esm/navigation/index.d.ts.map +1 -1
- package/dist/esm/navigation/index.js +12 -0
- package/dist/esm/navigation/index.js.map +1 -1
- package/dist/esm/navigation/matchSceneRoute.d.ts +7 -0
- package/dist/esm/navigation/matchSceneRoute.d.ts.map +1 -0
- package/dist/esm/navigation/matchSceneRoute.js +41 -0
- package/dist/esm/navigation/matchSceneRoute.js.map +1 -0
- package/dist/esm/navigation/navigationRouteKey.d.ts +3 -0
- package/dist/esm/navigation/navigationRouteKey.d.ts.map +1 -0
- package/dist/esm/navigation/navigationRouteKey.js +17 -0
- package/dist/esm/navigation/navigationRouteKey.js.map +1 -0
- package/dist/esm/navigation/resolveDestination.d.ts.map +1 -1
- package/dist/esm/navigation/resolveDestination.js +2 -9
- package/dist/esm/navigation/resolveDestination.js.map +1 -1
- package/dist/esm/navigation/sceneRoutesFrom.d.ts +4 -0
- package/dist/esm/navigation/sceneRoutesFrom.d.ts.map +1 -0
- package/dist/esm/navigation/sceneRoutesFrom.js +35 -0
- package/dist/esm/navigation/sceneRoutesFrom.js.map +1 -0
- package/dist/esm/navigation/useSceneHistoryNavigation.d.ts +6 -0
- package/dist/esm/navigation/useSceneHistoryNavigation.d.ts.map +1 -0
- package/dist/esm/navigation/useSceneHistoryNavigation.js +110 -0
- package/dist/esm/navigation/useSceneHistoryNavigation.js.map +1 -0
- package/dist/esm/packages/DesignTimeActionOutcome.d.ts +7 -0
- package/dist/esm/packages/DesignTimeActionOutcome.d.ts.map +1 -0
- package/dist/esm/packages/DesignTimeActionOutcome.js +2 -0
- package/dist/esm/packages/DesignTimeActionOutcome.js.map +1 -0
- package/dist/esm/packages/DesignTimeActionState.d.ts +9 -0
- package/dist/esm/packages/DesignTimeActionState.d.ts.map +1 -0
- package/dist/esm/packages/DesignTimeActionState.js +2 -0
- package/dist/esm/packages/DesignTimeActionState.js.map +1 -0
- package/dist/esm/packages/DesignTimeContractVersion.d.ts +2 -0
- package/dist/esm/packages/DesignTimeContractVersion.d.ts.map +1 -0
- package/dist/esm/packages/DesignTimeContractVersion.js +13 -0
- package/dist/esm/packages/DesignTimeContractVersion.js.map +1 -0
- package/dist/esm/packages/DesignTimeExtensionPoint.d.ts +9 -0
- package/dist/esm/packages/DesignTimeExtensionPoint.d.ts.map +1 -0
- package/dist/esm/packages/DesignTimeExtensionPoint.js +23 -0
- package/dist/esm/packages/DesignTimeExtensionPoint.js.map +1 -0
- package/dist/esm/packages/DesignTimeResolution.d.ts +7 -0
- package/dist/esm/packages/DesignTimeResolution.d.ts.map +1 -0
- package/dist/esm/packages/DesignTimeResolution.js +2 -0
- package/dist/esm/packages/DesignTimeResolution.js.map +1 -0
- package/dist/esm/packages/PackageHostConfiguration.d.ts +3 -0
- package/dist/esm/packages/PackageHostConfiguration.d.ts.map +1 -1
- package/dist/esm/packages/PackageHostConfiguration.js +2 -1
- package/dist/esm/packages/PackageHostConfiguration.js.map +1 -1
- package/dist/esm/packages/index.d.ts +8 -0
- package/dist/esm/packages/index.d.ts.map +1 -1
- package/dist/esm/packages/index.js +8 -0
- package/dist/esm/packages/index.js.map +1 -1
- package/dist/esm/packages/loadDesignTimeContributions.d.ts +11 -0
- package/dist/esm/packages/loadDesignTimeContributions.d.ts.map +1 -0
- package/dist/esm/packages/loadDesignTimeContributions.js +78 -0
- package/dist/esm/packages/loadDesignTimeContributions.js.map +1 -0
- package/dist/esm/packages/resolveDesignTimeHost.d.ts +26 -0
- package/dist/esm/packages/resolveDesignTimeHost.d.ts.map +1 -0
- package/dist/esm/packages/resolveDesignTimeHost.js +112 -0
- package/dist/esm/packages/resolveDesignTimeHost.js.map +1 -0
- package/dist/esm/packages/runDesignTimeAction.d.ts +4 -0
- package/dist/esm/packages/runDesignTimeAction.d.ts.map +1 -0
- package/dist/esm/packages/runDesignTimeAction.js +48 -0
- package/dist/esm/packages/runDesignTimeAction.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/navigation/DestinationResolution.ts +3 -0
- package/navigation/DialogResult.ts +8 -0
- package/navigation/SceneHistory.ts +24 -0
- package/navigation/SceneNavigationContext.tsx +16 -1
- package/navigation/SceneNavigationHost.tsx +30 -40
- package/navigation/SceneNavigationState.ts +19 -0
- package/navigation/SceneRoute.ts +12 -0
- package/navigation/createBrowserSceneHistory.ts +40 -0
- package/navigation/createMemorySceneHistory.ts +44 -0
- package/navigation/diagnoseRenderedNavigation.ts +14 -0
- package/navigation/identityRoute.ts +14 -0
- package/navigation/index.ts +12 -0
- package/navigation/matchSceneRoute.ts +45 -0
- package/navigation/navigationRouteKey.ts +22 -0
- package/navigation/resolveDestination.ts +2 -6
- package/navigation/sceneRoutesFrom.ts +24 -0
- package/navigation/useSceneHistoryNavigation.ts +80 -0
- package/package.json +5 -5
- package/packages/DesignTimeActionOutcome.ts +18 -0
- package/packages/DesignTimeActionState.ts +21 -0
- package/packages/DesignTimeContractVersion.ts +12 -0
- package/packages/DesignTimeExtensionPoint.ts +23 -0
- package/packages/DesignTimeResolution.ts +23 -0
- package/packages/PackageHostConfiguration.ts +11 -1
- package/packages/index.ts +8 -0
- package/packages/loadDesignTimeContributions.ts +98 -0
- package/packages/resolveDesignTimeHost.ts +133 -0
- package/packages/runDesignTimeAction.ts +36 -0
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
* A history kept in memory with the same push, replace and back semantics as the browser's: pushing
|
|
5
|
+
* discards any forward entries, and going back notifies listeners. `forward` is exposed for hosts and specs
|
|
6
|
+
* that drive the stack themselves.
|
|
7
|
+
*/ function createMemorySceneHistory(initialUrl) {
|
|
8
|
+
const entries = [
|
|
9
|
+
{
|
|
10
|
+
url: initialUrl
|
|
11
|
+
}
|
|
12
|
+
];
|
|
13
|
+
let index = 0;
|
|
14
|
+
const listeners = new Set();
|
|
15
|
+
const notify = ()=>listeners.forEach((listener)=>listener(entries[index].url, entries[index].state));
|
|
16
|
+
return {
|
|
17
|
+
location: ()=>entries[index].url,
|
|
18
|
+
state: ()=>entries[index].state,
|
|
19
|
+
push: (state)=>{
|
|
20
|
+
entries.splice(index + 1, entries.length, {
|
|
21
|
+
url: state.url,
|
|
22
|
+
state
|
|
23
|
+
});
|
|
24
|
+
index = entries.length - 1;
|
|
25
|
+
},
|
|
26
|
+
replace: (state)=>{
|
|
27
|
+
entries[index] = {
|
|
28
|
+
url: state.url,
|
|
29
|
+
state
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
back: ()=>{
|
|
33
|
+
if (index === 0) return;
|
|
34
|
+
index--;
|
|
35
|
+
notify();
|
|
36
|
+
},
|
|
37
|
+
forward: ()=>{
|
|
38
|
+
if (index === entries.length - 1) return;
|
|
39
|
+
index++;
|
|
40
|
+
notify();
|
|
41
|
+
},
|
|
42
|
+
entries: ()=>entries.map((entry)=>entry.state).filter((state)=>state !== undefined),
|
|
43
|
+
listen: (listener)=>{
|
|
44
|
+
listeners.add(listener);
|
|
45
|
+
return ()=>listeners.delete(listener);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { createMemorySceneHistory };
|
|
51
|
+
//# sourceMappingURL=createMemorySceneHistory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createMemorySceneHistory.js","sources":["../../../navigation/createMemorySceneHistory.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 { SceneHistory } from './SceneHistory';\nimport { SceneNavigationState } from './SceneNavigationState';\n\n/**\n * A history kept in memory with the same push, replace and back semantics as the browser's: pushing\n * discards any forward entries, and going back notifies listeners. `forward` is exposed for hosts and specs\n * that drive the stack themselves.\n */\nexport function createMemorySceneHistory(initialUrl?: string): SceneHistory & { forward(): void; entries(): SceneNavigationState[] } {\n const entries: { url?: string; state?: SceneNavigationState }[] = [{ url: initialUrl }];\n let index = 0;\n const listeners = new Set<(url: string | undefined, state: SceneNavigationState | undefined) => void>();\n const notify = () => listeners.forEach(listener => listener(entries[index].url, entries[index].state));\n\n return {\n location: () => entries[index].url,\n state: () => entries[index].state,\n push: state => {\n entries.splice(index + 1, entries.length, { url: state.url, state });\n index = entries.length - 1;\n },\n replace: state => {\n entries[index] = { url: state.url, state };\n },\n back: () => {\n if (index === 0) return;\n index--;\n notify();\n },\n forward: () => {\n if (index === entries.length - 1) return;\n index++;\n notify();\n },\n entries: () => entries.map(entry => entry.state).filter((state): state is SceneNavigationState => state !== undefined),\n listen: listener => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n}\n"],"names":["createMemorySceneHistory","initialUrl","entries","url","index","listeners","Set","notify","forEach","listener","state","location","push","splice","length","replace","back","forward","map","entry","filter","undefined","listen","add","delete"],"mappings":"AAAA;AACA;AAKA;;;;IAKO,SAASA,wBAAAA,CAAyBC,UAAmB,EAAA;AACxD,IAAA,MAAMC,OAAAA,GAA4D;AAAC,QAAA;YAAEC,GAAAA,EAAKF;AAAW;AAAE,KAAA;AACvF,IAAA,IAAIG,KAAAA,GAAQ,CAAA;AACZ,IAAA,MAAMC,YAAY,IAAIC,GAAAA,EAAAA;AACtB,IAAA,MAAMC,SAAS,IAAMF,SAAAA,CAAUG,OAAO,CAACC,CAAAA,WAAYA,QAAAA,CAASP,OAAO,CAACE,KAAAA,CAAM,CAACD,GAAG,EAAED,OAAO,CAACE,KAAAA,CAAM,CAACM,KAAK,CAAA,CAAA;IAEpG,OAAO;AACHC,QAAAA,QAAAA,EAAU,IAAMT,OAAO,CAACE,KAAAA,CAAM,CAACD,GAAG;AAClCO,QAAAA,KAAAA,EAAO,IAAMR,OAAO,CAACE,KAAAA,CAAM,CAACM,KAAK;AACjCE,QAAAA,IAAAA,EAAMF,CAAAA,KAAAA,GAAAA;AACFR,YAAAA,OAAAA,CAAQW,MAAM,CAACT,KAAAA,GAAQ,CAAA,EAAGF,OAAAA,CAAQY,MAAM,EAAE;AAAEX,gBAAAA,GAAAA,EAAKO,MAAMP,GAAG;AAAEO,gBAAAA;AAAM,aAAA,CAAA;YAClEN,KAAAA,GAAQF,OAAAA,CAAQY,MAAM,GAAG,CAAA;AAC7B,QAAA,CAAA;AACAC,QAAAA,OAAAA,EAASL,CAAAA,KAAAA,GAAAA;YACLR,OAAO,CAACE,MAAM,GAAG;AAAED,gBAAAA,GAAAA,EAAKO,MAAMP,GAAG;AAAEO,gBAAAA;AAAM,aAAA;AAC7C,QAAA,CAAA;QACAM,IAAAA,EAAM,IAAA;AACF,YAAA,IAAIZ,UAAU,CAAA,EAAG;AACjBA,YAAAA,KAAAA,EAAAA;AACAG,YAAAA,MAAAA,EAAAA;AACJ,QAAA,CAAA;QACAU,OAAAA,EAAS,IAAA;AACL,YAAA,IAAIb,KAAAA,KAAUF,OAAAA,CAAQY,MAAM,GAAG,CAAA,EAAG;AAClCV,YAAAA,KAAAA,EAAAA;AACAG,YAAAA,MAAAA,EAAAA;AACJ,QAAA,CAAA;AACAL,QAAAA,OAAAA,EAAS,IAAMA,OAAAA,CAAQgB,GAAG,CAACC,CAAAA,KAAAA,GAASA,KAAAA,CAAMT,KAAK,CAAA,CAAEU,MAAM,CAAC,CAACV,QAAyCA,KAAAA,KAAUW,SAAAA,CAAAA;AAC5GC,QAAAA,MAAAA,EAAQb,CAAAA,QAAAA,GAAAA;AACJJ,YAAAA,SAAAA,CAAUkB,GAAG,CAACd,QAAAA,CAAAA;YACd,OAAO,IAAMJ,SAAAA,CAAUmB,MAAM,CAACf,QAAAA,CAAAA;AAClC,QAAA;AACJ,KAAA;AACJ;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnoseRenderedNavigation.d.ts","sourceRoot":"","sources":["../../../navigation/diagnoseRenderedNavigation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAsB,MAAM,sBAAsB,CAAC;AAQjG,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,eAAe,GAAG,oBAAoB,EAAE,CAEzF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { diagnoseNavigation } from '@cratis/scene.engine';
|
|
2
|
+
import { navigationRouteKey } from './navigationRouteKey.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
|
+
* Diagnoses navigation the way this renderer routes it: the engine's checks, with duplicate routes compared
|
|
8
|
+
* by the URLs `resolveDestination` actually builds - identity-derived routes included, parameter spellings
|
|
9
|
+
* treated as equal.
|
|
10
|
+
*/ function diagnoseRenderedNavigation(graph) {
|
|
11
|
+
return diagnoseNavigation(graph, navigationRouteKey);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { diagnoseRenderedNavigation };
|
|
15
|
+
//# sourceMappingURL=diagnoseRenderedNavigation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnoseRenderedNavigation.js","sources":["../../../navigation/diagnoseRenderedNavigation.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 { NavigationDiagnostic, NavigationGraph, diagnoseNavigation } from '@cratis/scene.engine';\nimport { navigationRouteKey } from './navigationRouteKey';\n\n/**\n * Diagnoses navigation the way this renderer routes it: the engine's checks, with duplicate routes compared\n * by the URLs `resolveDestination` actually builds - identity-derived routes included, parameter spellings\n * treated as equal.\n */\nexport function diagnoseRenderedNavigation(graph: NavigationGraph): NavigationDiagnostic[] {\n return diagnoseNavigation(graph, navigationRouteKey);\n}\n"],"names":["diagnoseRenderedNavigation","graph","diagnoseNavigation","navigationRouteKey"],"mappings":";;;AAAA;AACA;AAKA;;;;IAKO,SAASA,0BAAAA,CAA2BC,KAAsB,EAAA;AAC7D,IAAA,OAAOC,mBAAmBD,KAAAA,EAAOE,kBAAAA,CAAAA;AACrC;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identityRoute.d.ts","sourceRoot":"","sources":["../../../navigation/identityRoute.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAM3D,wBAAgB,aAAa,CAAC,WAAW,EAAE,oBAAoB,GAAG,MAAM,GAAG,SAAS,CAInF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
* The route a destination gets when no route override was authored: its screen name, or its stable
|
|
5
|
+
* module/feature/slice identity as a path.
|
|
6
|
+
*/ function identityRoute(destination) {
|
|
7
|
+
if (destination.screen) return destination.screen;
|
|
8
|
+
const parts = [
|
|
9
|
+
destination.module,
|
|
10
|
+
destination.feature,
|
|
11
|
+
destination.slice
|
|
12
|
+
].filter((part)=>typeof part === 'string' && part.length > 0);
|
|
13
|
+
return parts.length ? parts.join('/') : undefined;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { identityRoute };
|
|
17
|
+
//# sourceMappingURL=identityRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identityRoute.js","sources":["../../../navigation/identityRoute.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';\n\n/**\n * The route a destination gets when no route override was authored: its screen name, or its stable\n * module/feature/slice identity as a path.\n */\nexport function identityRoute(destination: DestinationReference): string | undefined {\n if (destination.screen) return destination.screen;\n const parts = [destination.module, destination.feature, destination.slice].filter((part): part is string => typeof part === 'string' && part.length > 0);\n return parts.length ? parts.join('/') : undefined;\n}\n"],"names":["identityRoute","destination","screen","parts","module","feature","slice","filter","part","length","join","undefined"],"mappings":"AAAA;AACA;AAIA;;;IAIO,SAASA,aAAAA,CAAcC,WAAiC,EAAA;AAC3D,IAAA,IAAIA,WAAAA,CAAYC,MAAM,EAAE,OAAOD,YAAYC,MAAM;AACjD,IAAA,MAAMC,KAAAA,GAAQ;AAACF,QAAAA,WAAAA,CAAYG,MAAM;AAAEH,QAAAA,WAAAA,CAAYI,OAAO;AAAEJ,QAAAA,WAAAA,CAAYK;KAAM,CAACC,MAAM,CAAC,CAACC,IAAAA,GAAyB,OAAOA,IAAAA,KAAS,QAAA,IAAYA,IAAAA,CAAKC,MAAM,GAAG,CAAA,CAAA;AACtJ,IAAA,OAAON,MAAMM,MAAM,GAAGN,KAAAA,CAAMO,IAAI,CAAC,GAAA,CAAA,GAAOC,SAAAA;AAC5C;;"}
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
export * from './DestinationResolution';
|
|
2
|
+
export * from './DialogResult';
|
|
3
|
+
export * from './SceneHistory';
|
|
2
4
|
export * from './SceneNavigationContext';
|
|
3
5
|
export * from './SceneNavigationHost';
|
|
6
|
+
export * from './SceneNavigationState';
|
|
7
|
+
export * from './SceneRoute';
|
|
8
|
+
export * from './createBrowserSceneHistory';
|
|
9
|
+
export * from './createMemorySceneHistory';
|
|
10
|
+
export * from './diagnoseRenderedNavigation';
|
|
11
|
+
export * from './identityRoute';
|
|
12
|
+
export * from './matchSceneRoute';
|
|
13
|
+
export * from './navigationRouteKey';
|
|
4
14
|
export * from './resolveDestination';
|
|
15
|
+
export * from './sceneRoutesFrom';
|
|
16
|
+
export * from './useSceneHistoryNavigation';
|
|
5
17
|
//# 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,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,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,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,5 +1,17 @@
|
|
|
1
1
|
export * from './DestinationResolution';
|
|
2
|
+
export * from './DialogResult';
|
|
3
|
+
export * from './SceneHistory';
|
|
2
4
|
export * from './SceneNavigationContext';
|
|
3
5
|
export * from './SceneNavigationHost';
|
|
6
|
+
export * from './SceneNavigationState';
|
|
7
|
+
export * from './SceneRoute';
|
|
8
|
+
export * from './createBrowserSceneHistory';
|
|
9
|
+
export * from './createMemorySceneHistory';
|
|
10
|
+
export * from './diagnoseRenderedNavigation';
|
|
11
|
+
export * from './identityRoute';
|
|
12
|
+
export * from './matchSceneRoute';
|
|
13
|
+
export * from './navigationRouteKey';
|
|
4
14
|
export * from './resolveDestination';
|
|
15
|
+
export * from './sceneRoutesFrom';
|
|
16
|
+
export * from './useSceneHistoryNavigation';
|
|
5
17
|
//# 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,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,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,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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SceneRoute } from './SceneRoute';
|
|
2
|
+
export interface SceneRouteMatch {
|
|
3
|
+
route: SceneRoute;
|
|
4
|
+
parameters: Record<string, string>;
|
|
5
|
+
}
|
|
6
|
+
export declare function matchSceneRoute(url: string, routes: SceneRoute[]): SceneRouteMatch | undefined;
|
|
7
|
+
//# sourceMappingURL=matchSceneRoute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matchSceneRoute.d.ts","sourceRoot":"","sources":["../../../navigation/matchSceneRoute.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,MAAM,WAAW,eAAe;IAC5B,KAAK,EAAE,UAAU,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC;AAOD,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,eAAe,GAAG,SAAS,CAwB9F"}
|
|
@@ -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
|
+
* Matches a URL - as a deep link, a refresh or a typed address delivers it - against route templates.
|
|
5
|
+
* `{name}` segments capture path parameters; the query string adds the rest. Literal segments win over
|
|
6
|
+
* parameters, so `orders/new` beats `orders/{orderId}`, and routes are otherwise tried in the given order.
|
|
7
|
+
*/ function matchSceneRoute(url, routes) {
|
|
8
|
+
const [path, query = ''] = url.split('?', 2);
|
|
9
|
+
const segments = path.split('/').filter((segment)=>segment.length > 0).map(decodeURIComponent);
|
|
10
|
+
const queryParameters = Object.fromEntries(new URLSearchParams(query));
|
|
11
|
+
const candidates = routes.map((route, order)=>({
|
|
12
|
+
route,
|
|
13
|
+
order,
|
|
14
|
+
template: route.route.split('/').filter((segment)=>segment.length > 0)
|
|
15
|
+
})).filter((candidate)=>candidate.template.length === segments.length).sort((left, right)=>literalCount(right.template) - literalCount(left.template) || left.order - right.order);
|
|
16
|
+
for (const { route, template } of candidates){
|
|
17
|
+
const parameters = {};
|
|
18
|
+
const matches = template.every((part, index)=>{
|
|
19
|
+
const name = /^\{([^}]+)\}$/.exec(part)?.[1];
|
|
20
|
+
if (name) {
|
|
21
|
+
parameters[name] = segments[index];
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
return part === segments[index];
|
|
25
|
+
});
|
|
26
|
+
if (matches) return {
|
|
27
|
+
route,
|
|
28
|
+
parameters: {
|
|
29
|
+
...queryParameters,
|
|
30
|
+
...parameters
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
function literalCount(template) {
|
|
37
|
+
return template.filter((part)=>!/^\{[^}]+\}$/.test(part)).length;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { matchSceneRoute };
|
|
41
|
+
//# sourceMappingURL=matchSceneRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matchSceneRoute.js","sources":["../../../navigation/matchSceneRoute.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 { SceneRoute } from './SceneRoute';\n\n/** A URL matched to the route that opens it. */\nexport interface SceneRouteMatch {\n route: SceneRoute;\n parameters: Record<string, string>;\n}\n\n/**\n * Matches a URL - as a deep link, a refresh or a typed address delivers it - against route templates.\n * `{name}` segments capture path parameters; the query string adds the rest. Literal segments win over\n * parameters, so `orders/new` beats `orders/{orderId}`, and routes are otherwise tried in the given order.\n */\nexport function matchSceneRoute(url: string, routes: SceneRoute[]): SceneRouteMatch | undefined {\n const [path, query = ''] = url.split('?', 2);\n const segments = path.split('/').filter(segment => segment.length > 0).map(decodeURIComponent);\n const queryParameters = Object.fromEntries(new URLSearchParams(query));\n\n const candidates = routes\n .map((route, order) => ({ route, order, template: route.route.split('/').filter(segment => segment.length > 0) }))\n .filter(candidate => candidate.template.length === segments.length)\n .sort((left, right) => literalCount(right.template) - literalCount(left.template) || left.order - right.order);\n\n for (const { route, template } of candidates) {\n const parameters: Record<string, string> = {};\n const matches = template.every((part, index) => {\n const name = /^\\{([^}]+)\\}$/.exec(part)?.[1];\n if (name) {\n parameters[name] = segments[index];\n return true;\n }\n return part === segments[index];\n });\n if (matches) return { route, parameters: { ...queryParameters, ...parameters } };\n }\n\n return undefined;\n}\n\nfunction literalCount(template: string[]): number {\n return template.filter(part => !/^\\{[^}]+\\}$/.test(part)).length;\n}\n"],"names":["matchSceneRoute","url","routes","path","query","split","segments","filter","segment","length","map","decodeURIComponent","queryParameters","Object","fromEntries","URLSearchParams","candidates","route","order","template","candidate","sort","left","right","literalCount","parameters","matches","every","part","index","name","exec","undefined","test"],"mappings":"AAAA;AACA;AAUA;;;;AAIC,IACM,SAASA,eAAAA,CAAgBC,GAAW,EAAEC,MAAoB,EAAA;IAC7D,MAAM,CAACC,MAAMC,KAAAA,GAAQ,EAAE,CAAC,GAAGH,GAAAA,CAAII,KAAK,CAAC,GAAA,EAAK,CAAA,CAAA;AAC1C,IAAA,MAAMC,QAAAA,GAAWH,IAAAA,CAAKE,KAAK,CAAC,KAAKE,MAAM,CAACC,CAAAA,OAAAA,GAAWA,OAAAA,CAAQC,MAAM,GAAG,CAAA,CAAA,CAAGC,GAAG,CAACC,kBAAAA,CAAAA;AAC3E,IAAA,MAAMC,eAAAA,GAAkBC,MAAAA,CAAOC,WAAW,CAAC,IAAIC,eAAAA,CAAgBX,KAAAA,CAAAA,CAAAA;AAE/D,IAAA,MAAMY,aAAad,MAAAA,CACdQ,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OO,SAAAA;AACX;AAEA,SAASR,aAAaL,QAAkB,EAAA;IACpC,OAAOA,QAAAA,CAASZ,MAAM,CAACqB,CAAAA,IAAAA,GAAQ,CAAC,aAAA,CAAcK,IAAI,CAACL,IAAAA,CAAAA,CAAAA,CAAOnB,MAAM;AACpE;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigationRouteKey.d.ts","sourceRoot":"","sources":["../../../navigation/navigationRouteKey.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAS1D,eAAO,MAAM,kBAAkB,EAAE,kBAShC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { identityRoute } from './identityRoute.js';
|
|
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
|
+
* The route a destination occupies in this renderer: the authored override or the identity-derived route -
|
|
7
|
+
* the same base `resolveDestination` builds a URL from - with surrounding slashes removed and every parameter
|
|
8
|
+
* placeholder (`{id}` or `:id`) reduced to one marker, so `/invoices/{id}` and `invoices/:invoiceId` are the
|
|
9
|
+
* same URL.
|
|
10
|
+
*/ const navigationRouteKey = (destination)=>{
|
|
11
|
+
const route = destination.route ?? identityRoute(destination);
|
|
12
|
+
if (!route?.trim()) return undefined;
|
|
13
|
+
return route.trim().split('/').filter((segment)=>segment.length > 0).map((segment)=>/^\{[^}]*\}$/.test(segment) || /^:.+$/.test(segment) ? '{}' : segment).join('/');
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { navigationRouteKey };
|
|
17
|
+
//# sourceMappingURL=navigationRouteKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigationRouteKey.js","sources":["../../../navigation/navigationRouteKey.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 { NavigationRouteKey } from '@cratis/scene.engine';\nimport { identityRoute } from './identityRoute';\n\n/**\n * The route a destination occupies in this renderer: the authored override or the identity-derived route -\n * the same base `resolveDestination` builds a URL from - with surrounding slashes removed and every parameter\n * placeholder (`{id}` or `:id`) reduced to one marker, so `/invoices/{id}` and `invoices/:invoiceId` are the\n * same URL.\n */\nexport const navigationRouteKey: NavigationRouteKey = destination => {\n const route = destination.route ?? identityRoute(destination);\n if (!route?.trim()) return undefined;\n return route\n .trim()\n .split('/')\n .filter(segment => segment.length > 0)\n .map(segment => (/^\\{[^}]*\\}$/.test(segment) || /^:.+$/.test(segment) ? '{}' : segment))\n .join('/');\n};\n"],"names":["navigationRouteKey","destination","route","identityRoute","trim","undefined","split","filter","segment","length","map","test","join"],"mappings":";;AAAA;AACA;AAKA;;;;;IAMO,MAAMA,kBAAAA,GAAyCC,CAAAA,WAAAA,GAAAA;AAClD,IAAA,MAAMC,KAAAA,GAAQD,WAAAA,CAAYC,KAAK,IAAIC,aAAAA,CAAcF,WAAAA,CAAAA;IACjD,IAAI,CAACC,KAAAA,EAAOE,IAAAA,EAAAA,EAAQ,OAAOC,SAAAA;AAC3B,IAAA,OAAOH,KAAAA,CACFE,IAAI,EAAA,CACJE,KAAK,CAAC,GAAA,CAAA,CACNC,MAAM,CAACC,CAAAA,OAAAA,GAAWA,OAAAA,CAAQC,MAAM,GAAG,CAAA,CAAA,CACnCC,GAAG,CAACF,CAAAA,OAAAA,GAAY,aAAA,CAAcG,IAAI,CAACH,OAAAA,CAAAA,IAAY,OAAA,CAAQG,IAAI,CAACH,OAAAA,CAAAA,GAAW,IAAA,GAAOA,OAAAA,CAAAA,CAC9EI,IAAI,CAAC,GAAA,CAAA;AACd;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveDestination.d.ts","sourceRoot":"","sources":["../../../navigation/resolveDestination.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAA4B,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAmB,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"resolveDestination.d.ts","sourceRoot":"","sources":["../../../navigation/resolveDestination.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAA4B,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAmB,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAMhE,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,oBAAoB,EAAE,KAAK,GAAE,YAAiB,GAAG,qBAAqB,CAkBrH"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resolveBindingExpression } from '@cratis/scene.engine';
|
|
2
2
|
import { DestinationKind } from '@cratis/scene.model';
|
|
3
|
+
import { identityRoute } from './identityRoute.js';
|
|
3
4
|
|
|
4
5
|
// Copyright (c) Cratis. All rights reserved.
|
|
5
6
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
@@ -20,19 +21,11 @@ import { DestinationKind } from '@cratis/scene.model';
|
|
|
20
21
|
url,
|
|
21
22
|
outlet: destination.outlet,
|
|
22
23
|
dialog: destination.dialog,
|
|
24
|
+
parameters: Object.fromEntries(parameters),
|
|
23
25
|
action: kind === DestinationKind.Dialog ? 'openDialog' : kind === DestinationKind.External ? 'openExternal' : 'navigate',
|
|
24
26
|
diagnostics
|
|
25
27
|
};
|
|
26
28
|
}
|
|
27
|
-
function identityRoute(destination) {
|
|
28
|
-
if (destination.screen) return destination.screen;
|
|
29
|
-
const parts = [
|
|
30
|
-
destination.module,
|
|
31
|
-
destination.feature,
|
|
32
|
-
destination.slice
|
|
33
|
-
].filter((part)=>typeof part === 'string' && part.length > 0);
|
|
34
|
-
return parts.length ? parts.join('/') : undefined;
|
|
35
|
-
}
|
|
36
29
|
function appendParameters(route, parameters) {
|
|
37
30
|
if (!parameters.length) return route;
|
|
38
31
|
let replaced = route;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveDestination.js","sources":["../../../navigation/resolveDestination.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 { BindingScope, resolveBindingExpression } from '@cratis/scene.engine';\nimport { DestinationKind, DestinationReference } from '@cratis/scene.model';\nimport { DestinationResolution } from './DestinationResolution';\n\n/**\n * Resolves a destination into a renderer-neutral navigation action, deep link and target outlet/dialog.\n */\nexport function resolveDestination(destination: DestinationReference, scope: BindingScope = {}): DestinationResolution {\n const diagnostics: string[] = [];\n const kind = destination.kind ?? (destination.dialog ? DestinationKind.Dialog : DestinationKind.Outlet);\n const parameters = Object.entries(destination.routeParameterBindings ?? {})\n .map(([name, binding]) => [name, String(resolveBindingExpression(binding, scope) ?? '')] as const);\n const base = destination.route ?? identityRoute(destination);\n if (!base && kind !== DestinationKind.Dialog) diagnostics.push('Destination has no routeable screen, stable identity or route.');\n\n const url = base ? appendParameters(base, parameters) : undefined;\n return {\n kind,\n url,\n outlet: destination.outlet,\n dialog: destination.dialog,\n action: kind === DestinationKind.Dialog ? 'openDialog' : kind === DestinationKind.External ? 'openExternal' : 'navigate',\n diagnostics,\n };\n}\n\nfunction
|
|
1
|
+
{"version":3,"file":"resolveDestination.js","sources":["../../../navigation/resolveDestination.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 { BindingScope, resolveBindingExpression } from '@cratis/scene.engine';\nimport { DestinationKind, DestinationReference } from '@cratis/scene.model';\nimport { DestinationResolution } from './DestinationResolution';\nimport { identityRoute } from './identityRoute';\n\n/**\n * Resolves a destination into a renderer-neutral navigation action, deep link and target outlet/dialog.\n */\nexport function resolveDestination(destination: DestinationReference, scope: BindingScope = {}): DestinationResolution {\n const diagnostics: string[] = [];\n const kind = destination.kind ?? (destination.dialog ? DestinationKind.Dialog : DestinationKind.Outlet);\n const parameters = Object.entries(destination.routeParameterBindings ?? {})\n .map(([name, binding]) => [name, String(resolveBindingExpression(binding, scope) ?? '')] as const);\n const base = destination.route ?? identityRoute(destination);\n if (!base && kind !== DestinationKind.Dialog) diagnostics.push('Destination has no routeable screen, stable identity or route.');\n\n const url = base ? appendParameters(base, parameters) : undefined;\n return {\n kind,\n url,\n outlet: destination.outlet,\n dialog: destination.dialog,\n parameters: Object.fromEntries(parameters),\n action: kind === DestinationKind.Dialog ? 'openDialog' : kind === DestinationKind.External ? 'openExternal' : 'navigate',\n diagnostics,\n };\n}\n\nfunction appendParameters(route: string, parameters: readonly (readonly [string, string])[]): string {\n if (!parameters.length) return route;\n let replaced = route;\n const unused: string[] = [];\n for (const [name, value] of parameters) {\n const marker = `{${name}}`;\n if (replaced.includes(marker)) {\n replaced = replaced.split(marker).join(encodeURIComponent(value));\n } else {\n unused.push(`${encodeURIComponent(name)}=${encodeURIComponent(value)}`);\n }\n }\n\n return unused.length ? `${replaced}?${unused.join('&')}` : replaced;\n}\n"],"names":["resolveDestination","destination","scope","diagnostics","kind","dialog","DestinationKind","Dialog","Outlet","parameters","Object","entries","routeParameterBindings","map","name","binding","String","resolveBindingExpression","base","route","identityRoute","push","url","appendParameters","undefined","outlet","fromEntries","action","External","length","replaced","unused","value","marker","includes","split","join","encodeURIComponent"],"mappings":";;;;AAAA;AACA;AAOA;;AAEC,IACM,SAASA,kBAAAA,CAAmBC,WAAiC,EAAEC,KAAAA,GAAsB,EAAE,EAAA;AAC1F,IAAA,MAAMC,cAAwB,EAAE;AAChC,IAAA,MAAMC,IAAAA,GAAOH,WAAAA,CAAYG,IAAI,KAAKH,WAAAA,CAAYI,MAAM,GAAGC,eAAAA,CAAgBC,MAAM,GAAGD,eAAAA,CAAgBE,MAAM,CAAD;AACrG,IAAA,MAAMC,UAAAA,GAAaC,MAAAA,CAA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nB,IAAAA,CAAK,CAAC,CAAC;QAC1B,IAAIgB,QAAAA,CAASI,QAAQ,CAACD,MAAAA,CAAAA,EAAS;AAC3BH,YAAAA,QAAAA,GAAWA,SAASK,KAAK,CAACF,MAAAA,CAAAA,CAAQG,IAAI,CAACC,kBAAAA,CAAmBL,KAAAA,CAAAA,CAAAA;QAC9D,CAAA,MAAO;YACHD,MAAAA,CAAOV,IAAI,CAAC,CAAA,EAAGgB,kBAAAA,CAAmBvB,MAAM,CAAC,EAAEuB,mBAAmBL,KAAAA,CAAAA,CAAAA,CAAQ,CAAA;AAC1E,QAAA;AACJ,IAAA;IAEA,OAAOD,MAAAA,CAAOF,MAAM,GAAG,CAAA,EAAGC,QAAAA,CAAS,CAAC,EAAEC,MAAAA,CAAOK,IAAI,CAAC,GAAA,CAAA,CAAA,CAAM,GAAGN,QAAAA;AAC/D;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sceneRoutesFrom.d.ts","sourceRoot":"","sources":["../../../navigation/sceneRoutesFrom.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE5E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAO1C,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,YAAY,GAAE,oBAAoB,EAAO,GAAG,UAAU,EAAE,CAW1G"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { DestinationKind } from '@cratis/scene.model';
|
|
2
|
+
import { identityRoute } from './identityRoute.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 routes a host can deep link to: every screen at its own name, and every outlet destination at its
|
|
8
|
+
* authored route override or identity route. A destination listed earlier wins a route it shares with a
|
|
9
|
+
* later one, and authored overrides come before the screen-name defaults.
|
|
10
|
+
*/ function sceneRoutesFrom(screens, destinations = []) {
|
|
11
|
+
const routes = [];
|
|
12
|
+
for (const destination of destinations){
|
|
13
|
+
const kind = destination.kind ?? (destination.dialog ? DestinationKind.Dialog : DestinationKind.Outlet);
|
|
14
|
+
const screen = destination.screen ?? destination.slice;
|
|
15
|
+
const route = destination.route ?? identityRoute(destination);
|
|
16
|
+
if (kind !== DestinationKind.Outlet || !screen || !route) continue;
|
|
17
|
+
routes.push({
|
|
18
|
+
route,
|
|
19
|
+
screen,
|
|
20
|
+
...destination.outlet ? {
|
|
21
|
+
outlet: destination.outlet
|
|
22
|
+
} : {}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return [
|
|
26
|
+
...routes,
|
|
27
|
+
...screens.map((screen)=>({
|
|
28
|
+
route: screen,
|
|
29
|
+
screen
|
|
30
|
+
}))
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { sceneRoutesFrom };
|
|
35
|
+
//# sourceMappingURL=sceneRoutesFrom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sceneRoutesFrom.js","sources":["../../../navigation/sceneRoutesFrom.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 { DestinationKind, DestinationReference } from '@cratis/scene.model';\nimport { identityRoute } from './identityRoute';\nimport { SceneRoute } from './SceneRoute';\n\n/**\n * The routes a host can deep link to: every screen at its own name, and every outlet destination at its\n * authored route override or identity route. A destination listed earlier wins a route it shares with a\n * later one, and authored overrides come before the screen-name defaults.\n */\nexport function sceneRoutesFrom(screens: string[], destinations: DestinationReference[] = []): SceneRoute[] {\n const routes: SceneRoute[] = [];\n for (const destination of destinations) {\n const kind = destination.kind ?? (destination.dialog ? DestinationKind.Dialog : DestinationKind.Outlet);\n const screen = destination.screen ?? destination.slice;\n const route = destination.route ?? identityRoute(destination);\n if (kind !== DestinationKind.Outlet || !screen || !route) continue;\n routes.push({ route, screen, ...(destination.outlet ? { outlet: destination.outlet } : {}) });\n }\n\n return [...routes, ...screens.map(screen => ({ route: screen, screen }))];\n}\n"],"names":["sceneRoutesFrom","screens","destinations","routes","destination","kind","dialog","DestinationKind","Dialog","Outlet","screen","slice","route","identityRoute","push","outlet","map"],"mappings":";;;AAAA;AACA;AAMA;;;;AAIC,IACM,SAASA,eAAAA,CAAgBC,OAAiB,EAAEC,eAAuC,EAAE,EAAA;AACxF,IAAA,MAAMC,SAAuB,EAAE;IAC/B,KAAK,MAAMC,eAAeF,YAAAA,CAAc;AACpC,QAAA,MAAMG,IAAAA,GAAOD,WAAAA,CAAYC,IAAI,KAAKD,WAAAA,CAAYE,MAAM,GAAGC,eAAAA,CAAgBC,MAAM,GAAGD,eAAAA,CAAgBE,MAAM,CAAD;AACrG,QAAA,MAAMC,MAAAA,GAASN,WAAAA,CAAYM,MAAM,IAAIN,YAAYO,KAAK;AACtD,QAAA,MAAMC,KAAAA,GAAQR,WAAAA,CAAYQ,KAAK,IAAIC,aAAAA,CAAcT,WAAAA,CAAAA;AACjD,QAAA,IAAIC,SAASE,eAAAA,CAAgBE,MAAM,IAAI,CAACC,MAAAA,IAAU,CAACE,KAAAA,EAAO;AAC1DT,QAAAA,MAAAA,CAAOW,IAAI,CAAC;AAAEF,YAAAA,KAAAA;AAAOF,YAAAA,MAAAA;YAAQ,GAAIN,WAAAA,CAAYW,MAAM,GAAG;AAAEA,gBAAAA,MAAAA,EAAQX,YAAYW;AAAO,aAAA,GAAI;AAAI,SAAA,CAAA;AAC/F,IAAA;IAEA,OAAO;AAAIZ,QAAAA,GAAAA,MAAAA;AAAWF,QAAAA,GAAAA,OAAAA,CAAQe,GAAG,CAACN,CAAAA,MAAAA,IAAW;gBAAEE,KAAAA,EAAOF,MAAAA;AAAQA,gBAAAA;aAAO,CAAA;AAAI,KAAA;AAC7E;;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BindingScope } from '@cratis/scene.engine';
|
|
2
|
+
import { SceneHistory } from './SceneHistory';
|
|
3
|
+
import { SceneNavigationContextValue } from './SceneNavigationContext';
|
|
4
|
+
import { SceneRoute } from './SceneRoute';
|
|
5
|
+
export declare function useSceneHistoryNavigation(history: SceneHistory, routes: SceneRoute[], initialScreen: string, bindingScope: BindingScope): SceneNavigationContextValue;
|
|
6
|
+
//# sourceMappingURL=useSceneHistoryNavigation.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { useCallback, useMemo, useState, useRef, useEffect } from 'react';
|
|
2
|
+
import { DestinationKind } from '@cratis/scene.model';
|
|
3
|
+
import { matchSceneRoute } from './matchSceneRoute.js';
|
|
4
|
+
import { resolveDestination } from './resolveDestination.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
|
+
/**
|
|
9
|
+
* Keeps a navigation host's state in a {@link SceneHistory}: every navigation and every dialog is an entry,
|
|
10
|
+
* so back and forward step through them, a refresh restores the stored entry, and a deep link is matched
|
|
11
|
+
* against the route table. Closing a dialog goes back to the entry that opened it.
|
|
12
|
+
*/ function useSceneHistoryNavigation(history, routes, initialScreen, bindingScope) {
|
|
13
|
+
const fromLocation = useCallback((url)=>{
|
|
14
|
+
const match = url ? matchSceneRoute(url, routes) : undefined;
|
|
15
|
+
return match ? {
|
|
16
|
+
screen: match.route.screen,
|
|
17
|
+
url,
|
|
18
|
+
outlet: match.route.outlet,
|
|
19
|
+
parameters: match.parameters
|
|
20
|
+
} : undefined;
|
|
21
|
+
}, [
|
|
22
|
+
routes
|
|
23
|
+
]);
|
|
24
|
+
const fallback = useMemo(()=>({
|
|
25
|
+
screen: initialScreen,
|
|
26
|
+
url: initialScreen,
|
|
27
|
+
parameters: {}
|
|
28
|
+
}), [
|
|
29
|
+
initialScreen
|
|
30
|
+
]);
|
|
31
|
+
const [unresolvedUrl] = useState(()=>{
|
|
32
|
+
const url = history.location();
|
|
33
|
+
return !history.state() && url && !fromLocation(url) ? url : undefined;
|
|
34
|
+
});
|
|
35
|
+
const [state, setState] = useState(()=>history.state() ?? fromLocation(history.location()) ?? fallback);
|
|
36
|
+
const [dialogResult, setDialogResult] = useState();
|
|
37
|
+
// Back and forward restore the stored entry, or match a URL the host never wrote against the current routes.
|
|
38
|
+
const restore = useRef((url, stored)=>stored ?? fromLocation(url) ?? fallback);
|
|
39
|
+
restore.current = (url, stored)=>stored ?? fromLocation(url) ?? fallback;
|
|
40
|
+
const initialState = useRef(state);
|
|
41
|
+
// The current entry is written once, when a history is attached; later entries are written by navigate.
|
|
42
|
+
useEffect(()=>{
|
|
43
|
+
history.replace(initialState.current);
|
|
44
|
+
return history.listen((url, stored)=>setState(restore.current(url, stored)));
|
|
45
|
+
}, [
|
|
46
|
+
history
|
|
47
|
+
]);
|
|
48
|
+
const go = useCallback((next)=>{
|
|
49
|
+
history.push(next);
|
|
50
|
+
setState(next);
|
|
51
|
+
}, [
|
|
52
|
+
history
|
|
53
|
+
]);
|
|
54
|
+
const navigate = useCallback((destination)=>{
|
|
55
|
+
const resolution = resolveDestination(destination, bindingScope);
|
|
56
|
+
if (resolution.kind === DestinationKind.Dialog) {
|
|
57
|
+
if (resolution.dialog) go({
|
|
58
|
+
...state,
|
|
59
|
+
dialog: resolution.dialog
|
|
60
|
+
});
|
|
61
|
+
} else if (resolution.kind !== DestinationKind.External) {
|
|
62
|
+
go({
|
|
63
|
+
screen: destination.screen ?? destination.slice ?? state.screen,
|
|
64
|
+
url: resolution.url,
|
|
65
|
+
outlet: resolution.outlet,
|
|
66
|
+
parameters: resolution.parameters
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return resolution;
|
|
70
|
+
}, [
|
|
71
|
+
bindingScope,
|
|
72
|
+
go,
|
|
73
|
+
state
|
|
74
|
+
]);
|
|
75
|
+
const closeDialog = useCallback((result)=>{
|
|
76
|
+
if (!state.dialog) return;
|
|
77
|
+
setDialogResult({
|
|
78
|
+
dialog: state.dialog,
|
|
79
|
+
result
|
|
80
|
+
});
|
|
81
|
+
history.back();
|
|
82
|
+
}, [
|
|
83
|
+
history,
|
|
84
|
+
state.dialog
|
|
85
|
+
]);
|
|
86
|
+
return useMemo(()=>({
|
|
87
|
+
currentScreen: state.screen,
|
|
88
|
+
currentUrl: state.url,
|
|
89
|
+
currentOutlet: state.outlet,
|
|
90
|
+
currentDialog: state.dialog,
|
|
91
|
+
currentParameters: state.parameters,
|
|
92
|
+
dialogResult,
|
|
93
|
+
unresolvedUrl,
|
|
94
|
+
bindingScope,
|
|
95
|
+
navigate,
|
|
96
|
+
closeDialog,
|
|
97
|
+
back: ()=>history.back()
|
|
98
|
+
}), [
|
|
99
|
+
bindingScope,
|
|
100
|
+
closeDialog,
|
|
101
|
+
dialogResult,
|
|
102
|
+
history,
|
|
103
|
+
navigate,
|
|
104
|
+
state,
|
|
105
|
+
unresolvedUrl
|
|
106
|
+
]);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export { useSceneHistoryNavigation };
|
|
110
|
+
//# sourceMappingURL=useSceneHistoryNavigation.js.map
|
|
@@ -0,0 +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,EAAK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come.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAKhD,MAAM,WAAW,uBAAuB;IAEpC,SAAS,EAAE,OAAO,CAAC;IAGnB,KAAK,EAAE,SAAS,EAAE,CAAC;IAGnB,WAAW,EAAE,MAAM,EAAE,CAAC;CACzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DesignTimeActionOutcome.js","sourceRoot":"","sources":["../../../packages/DesignTimeActionOutcome.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DesignTimeActionDescriptor } from '@cratis/scene.model';
|
|
2
|
+
export interface DesignTimeActionState {
|
|
3
|
+
descriptor: DesignTimeActionDescriptor;
|
|
4
|
+
package: string;
|
|
5
|
+
visible: boolean;
|
|
6
|
+
enabled: boolean;
|
|
7
|
+
diagnostic?: string;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=DesignTimeActionState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DesignTimeActionState.d.ts","sourceRoot":"","sources":["../../../packages/DesignTimeActionState.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAMjE,MAAM,WAAW,qBAAqB;IAClC,UAAU,EAAE,0BAA0B,CAAC;IAGvC,OAAO,EAAE,MAAM,CAAC;IAEhB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IAGjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DesignTimeActionState.js","sourceRoot":"","sources":["../../../packages/DesignTimeActionState.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DesignTimeContractVersion.d.ts","sourceRoot":"","sources":["../../../packages/DesignTimeContractVersion.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,yBAAyB,QAAQ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
* The design-time extension contract this host implements, as `major.minor`.
|
|
5
|
+
*
|
|
6
|
+
* The contract is the set of extension points a package's design-time bundle fills - previews, designers,
|
|
7
|
+
* property editors, property displays and actions - and the props and context each receives. A minor
|
|
8
|
+
* version adds optional members; a major version changes or removes them. A host loads a package's
|
|
9
|
+
* contributions only when the package's declared major version matches this one.
|
|
10
|
+
*/ const DesignTimeContractVersion = '1.0';
|
|
11
|
+
|
|
12
|
+
export { DesignTimeContractVersion };
|
|
13
|
+
//# sourceMappingURL=DesignTimeContractVersion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DesignTimeContractVersion.js","sources":["../../../packages/DesignTimeContractVersion.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\n/**\n * The design-time extension contract this host implements, as `major.minor`.\n *\n * The contract is the set of extension points a package's design-time bundle fills - previews, designers,\n * property editors, property displays and actions - and the props and context each receives. A minor\n * version adds optional members; a major version changes or removes them. A host loads a package's\n * contributions only when the package's declared major version matches this one.\n */\nexport const DesignTimeContractVersion = '1.0';\n"],"names":["DesignTimeContractVersion"],"mappings":"AAAA;AACA;AAEA;;;;;;;IAQO,MAAMA,yBAAAA,GAA4B;;"}
|