@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
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
require('react/jsx-runtime');
|
|
4
4
|
require('react');
|
|
5
|
-
require('@cratis/scene.model');
|
|
6
5
|
require('@cratis/scene.engine');
|
|
6
|
+
require('@cratis/scene.model');
|
|
7
7
|
require('../interactions/useInteractions.js');
|
|
8
8
|
require('../interactions/NotificationHost.js');
|
|
9
9
|
var ScenePackageBundle = require('../packages/ScenePackageBundle.js');
|
|
10
|
+
require('../packages/runDesignTimeAction.js');
|
|
10
11
|
var CoreText = require('./CoreText.js');
|
|
11
12
|
var CoreButton = require('./CoreButton.js');
|
|
12
13
|
var CoreCard = require('./CoreCard.js');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreComponents.js","sources":["../../../core/coreComponents.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 { ComponentRegistry } from '../renderer';\nimport { componentRegistryKey } from '../packages';\nimport { CoreText } from './CoreText';\nimport { CoreButton } from './CoreButton';\nimport { CoreCard } from './CoreCard';\nimport { CoreNavigationBar } from './CoreNavigationBar';\nimport {\n CoreAction,\n CoreCode,\n CoreColumn,\n CoreData,\n CoreField,\n CoreFile,\n CoreNavigate,\n CoreSection,\n CoreSummary,\n CoreTable,\n CoreTitle,\n} from './ScreenplayCoreComponents';\n\n/**\n * The `core` package's component registry - the final fallback every `ui profile` resolves against\n * regardless of which other packages it lists (Scene#3).\n */\nexport const coreComponents: ComponentRegistry = {\n [componentRegistryKey('core', 'text')]: CoreText,\n [componentRegistryKey('core', 'button')]: CoreButton,\n [componentRegistryKey('core', 'card')]: CoreCard,\n [componentRegistryKey('core', 'data')]: CoreData,\n [componentRegistryKey('core', 'action')]: CoreAction,\n [componentRegistryKey('core', 'section')]: CoreSection,\n [componentRegistryKey('core', 'navigate')]: CoreNavigate,\n [componentRegistryKey('core', 'title')]: CoreTitle,\n [componentRegistryKey('core', 'table')]: CoreTable,\n [componentRegistryKey('core', 'column')]: CoreColumn,\n [componentRegistryKey('core', 'summary')]: CoreSummary,\n [componentRegistryKey('core', 'field')]: CoreField,\n [componentRegistryKey('core', 'code')]: CoreCode,\n [componentRegistryKey('core', 'file')]: CoreFile,\n [componentRegistryKey('core', 'navigationBar')]: CoreNavigationBar,\n};\n"],"names":["coreComponents","componentRegistryKey","CoreText","CoreButton","CoreCard","CoreData","CoreAction","CoreSection","CoreNavigate","CoreTitle","CoreTable","CoreColumn","CoreSummary","CoreField","CoreCode","CoreFile","CoreNavigationBar"],"mappings":"
|
|
1
|
+
{"version":3,"file":"coreComponents.js","sources":["../../../core/coreComponents.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 { ComponentRegistry } from '../renderer';\nimport { componentRegistryKey } from '../packages';\nimport { CoreText } from './CoreText';\nimport { CoreButton } from './CoreButton';\nimport { CoreCard } from './CoreCard';\nimport { CoreNavigationBar } from './CoreNavigationBar';\nimport {\n CoreAction,\n CoreCode,\n CoreColumn,\n CoreData,\n CoreField,\n CoreFile,\n CoreNavigate,\n CoreSection,\n CoreSummary,\n CoreTable,\n CoreTitle,\n} from './ScreenplayCoreComponents';\n\n/**\n * The `core` package's component registry - the final fallback every `ui profile` resolves against\n * regardless of which other packages it lists (Scene#3).\n */\nexport const coreComponents: ComponentRegistry = {\n [componentRegistryKey('core', 'text')]: CoreText,\n [componentRegistryKey('core', 'button')]: CoreButton,\n [componentRegistryKey('core', 'card')]: CoreCard,\n [componentRegistryKey('core', 'data')]: CoreData,\n [componentRegistryKey('core', 'action')]: CoreAction,\n [componentRegistryKey('core', 'section')]: CoreSection,\n [componentRegistryKey('core', 'navigate')]: CoreNavigate,\n [componentRegistryKey('core', 'title')]: CoreTitle,\n [componentRegistryKey('core', 'table')]: CoreTable,\n [componentRegistryKey('core', 'column')]: CoreColumn,\n [componentRegistryKey('core', 'summary')]: CoreSummary,\n [componentRegistryKey('core', 'field')]: CoreField,\n [componentRegistryKey('core', 'code')]: CoreCode,\n [componentRegistryKey('core', 'file')]: CoreFile,\n [componentRegistryKey('core', 'navigationBar')]: CoreNavigationBar,\n};\n"],"names":["coreComponents","componentRegistryKey","CoreText","CoreButton","CoreCard","CoreData","CoreAction","CoreSection","CoreNavigate","CoreTitle","CoreTable","CoreColumn","CoreSummary","CoreField","CoreCode","CoreFile","CoreNavigationBar"],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA;AAsBA;;;UAIaA,cAAAA,GAAoC;IAC7C,CAACC,uCAAAA,CAAqB,MAAA,EAAQ,MAAA,CAAA,GAAUC,iBAAAA;IACxC,CAACD,uCAAAA,CAAqB,MAAA,EAAQ,QAAA,CAAA,GAAYE,qBAAAA;IAC1C,CAACF,uCAAAA,CAAqB,MAAA,EAAQ,MAAA,CAAA,GAAUG,iBAAAA;IACxC,CAACH,uCAAAA,CAAqB,MAAA,EAAQ,MAAA,CAAA,GAAUI,iCAAAA;IACxC,CAACJ,uCAAAA,CAAqB,MAAA,EAAQ,QAAA,CAAA,GAAYK,mCAAAA;IAC1C,CAACL,uCAAAA,CAAqB,MAAA,EAAQ,SAAA,CAAA,GAAaM,oCAAAA;IAC3C,CAACN,uCAAAA,CAAqB,MAAA,EAAQ,UAAA,CAAA,GAAcO,qCAAAA;IAC5C,CAACP,uCAAAA,CAAqB,MAAA,EAAQ,OAAA,CAAA,GAAWQ,kCAAAA;IACzC,CAACR,uCAAAA,CAAqB,MAAA,EAAQ,OAAA,CAAA,GAAWS,kCAAAA;IACzC,CAACT,uCAAAA,CAAqB,MAAA,EAAQ,QAAA,CAAA,GAAYU,mCAAAA;IAC1C,CAACV,uCAAAA,CAAqB,MAAA,EAAQ,SAAA,CAAA,GAAaW,oCAAAA;IAC3C,CAACX,uCAAAA,CAAqB,MAAA,EAAQ,OAAA,CAAA,GAAWY,kCAAAA;IACzC,CAACZ,uCAAAA,CAAqB,MAAA,EAAQ,MAAA,CAAA,GAAUa,iCAAAA;IACxC,CAACb,uCAAAA,CAAqB,MAAA,EAAQ,MAAA,CAAA,GAAUc,iCAAAA;IACxC,CAACd,uCAAAA,CAAqB,MAAA,EAAQ,eAAA,CAAA,GAAmBe;AACrD;;"}
|
|
@@ -7,6 +7,7 @@ require('@cratis/scene.engine');
|
|
|
7
7
|
require('../interactions/useInteractions.js');
|
|
8
8
|
require('../interactions/NotificationHost.js');
|
|
9
9
|
var ScenePackageBundle = require('../packages/ScenePackageBundle.js');
|
|
10
|
+
require('../packages/runDesignTimeAction.js');
|
|
10
11
|
|
|
11
12
|
// Copyright (c) Cratis. All rights reserved.
|
|
12
13
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreDescriptors.js","sources":["../../../core/coreDescriptors.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 { ComponentDescriptor, PropertyValueType } from '@cratis/scene.model';\nimport { componentRegistryKey } from '../packages';\n\nconst key = (name: string) => componentRegistryKey('core', name);\n\n/**\n * What can be edited on the `core` package's components.\n *\n * Only the components an author configures by hand are described: a button's label, an action's command and its\n * argument mapping, a column's heading, and the navigation bar. The Screenplay structural components - `data`,\n * `section`, `summary` - have nothing to edit that is not already a node in the tree.\n */\nexport const coreDescriptors: ComponentDescriptor[] = [\n {\n component: key('button'),\n displayName: 'Button',\n properties: [\n { path: 'label', label: 'Label', group: 'Content', valueType: PropertyValueType.String, default: '' },\n ],\n },\n {\n component: key('action'),\n displayName: 'Command action',\n description: 'Invokes a modeled command. The command and its argument mapping are stored on the element; the host that handles the command event reads them.',\n properties: [\n { path: 'label', label: 'Label', group: 'Content', valueType: PropertyValueType.String },\n {\n path: 'command', label: 'Command', group: 'Behavior', valueType: PropertyValueType.String,\n editorKind: 'stateChangeReference', constraints: { required: true },\n description: 'The state change this action submits.',\n },\n {\n path: 'arguments', label: 'Argument mapping', group: 'Behavior', valueType: PropertyValueType.Collection,\n description: 'Where each command argument comes from.',\n item: {\n label: 'Argument',\n properties: [\n { path: 'name', label: 'Argument', group: 'Behavior', valueType: PropertyValueType.String, constraints: { required: true } },\n { path: 'source', label: 'Source', group: 'Behavior', valueType: PropertyValueType.String, editorKind: 'bindingPath', constraints: { required: true } },\n ],\n },\n },\n ],\n },\n {\n component: key('column'),\n displayName: 'Table column',\n properties: [\n { path: 'property', label: 'Result field', group: 'Data', valueType: PropertyValueType.String, editorKind: 'resultField', constraints: { required: true } },\n { path: 'label', label: 'Heading', group: 'Content', valueType: PropertyValueType.String },\n ],\n },\n {\n component: key('navigationBar'),\n displayName: 'Navigation bar',\n description: 'A list of navigation items. A template author fixes the first item (Home) and can expose the list so that screens add their own.',\n properties: [\n { path: 'title', label: 'Title', group: 'Content', valueType: PropertyValueType.String, default: 'Navigation' },\n {\n path: 'items', label: 'Items', group: 'Content', valueType: PropertyValueType.Collection, default: [],\n item: {\n label: 'Navigation item',\n properties: [\n { path: 'label', label: 'Label', group: 'Content', valueType: PropertyValueType.String, constraints: { required: true, minimumLength: 1 } },\n { path: 'icon', label: 'Icon', group: 'Content', valueType: PropertyValueType.Icon, editorKind: 'iconPicker' },\n { path: 'destination', label: 'Destination', group: 'Content', valueType: PropertyValueType.Destination, editorKind: 'screenPicker', constraints: { required: true } },\n ],\n },\n },\n ],\n },\n];\n"],"names":["key","name","componentRegistryKey","coreDescriptors","component","displayName","properties","path","label","group","valueType","PropertyValueType","String","default","description","editorKind","constraints","required","Collection","item","minimumLength","Icon","Destination"],"mappings":"
|
|
1
|
+
{"version":3,"file":"coreDescriptors.js","sources":["../../../core/coreDescriptors.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 { ComponentDescriptor, PropertyValueType } from '@cratis/scene.model';\nimport { componentRegistryKey } from '../packages';\n\nconst key = (name: string) => componentRegistryKey('core', name);\n\n/**\n * What can be edited on the `core` package's components.\n *\n * Only the components an author configures by hand are described: a button's label, an action's command and its\n * argument mapping, a column's heading, and the navigation bar. The Screenplay structural components - `data`,\n * `section`, `summary` - have nothing to edit that is not already a node in the tree.\n */\nexport const coreDescriptors: ComponentDescriptor[] = [\n {\n component: key('button'),\n displayName: 'Button',\n properties: [\n { path: 'label', label: 'Label', group: 'Content', valueType: PropertyValueType.String, default: '' },\n ],\n },\n {\n component: key('action'),\n displayName: 'Command action',\n description: 'Invokes a modeled command. The command and its argument mapping are stored on the element; the host that handles the command event reads them.',\n properties: [\n { path: 'label', label: 'Label', group: 'Content', valueType: PropertyValueType.String },\n {\n path: 'command', label: 'Command', group: 'Behavior', valueType: PropertyValueType.String,\n editorKind: 'stateChangeReference', constraints: { required: true },\n description: 'The state change this action submits.',\n },\n {\n path: 'arguments', label: 'Argument mapping', group: 'Behavior', valueType: PropertyValueType.Collection,\n description: 'Where each command argument comes from.',\n item: {\n label: 'Argument',\n properties: [\n { path: 'name', label: 'Argument', group: 'Behavior', valueType: PropertyValueType.String, constraints: { required: true } },\n { path: 'source', label: 'Source', group: 'Behavior', valueType: PropertyValueType.String, editorKind: 'bindingPath', constraints: { required: true } },\n ],\n },\n },\n ],\n },\n {\n component: key('column'),\n displayName: 'Table column',\n properties: [\n { path: 'property', label: 'Result field', group: 'Data', valueType: PropertyValueType.String, editorKind: 'resultField', constraints: { required: true } },\n { path: 'label', label: 'Heading', group: 'Content', valueType: PropertyValueType.String },\n ],\n },\n {\n component: key('navigationBar'),\n displayName: 'Navigation bar',\n description: 'A list of navigation items. A template author fixes the first item (Home) and can expose the list so that screens add their own.',\n properties: [\n { path: 'title', label: 'Title', group: 'Content', valueType: PropertyValueType.String, default: 'Navigation' },\n {\n path: 'items', label: 'Items', group: 'Content', valueType: PropertyValueType.Collection, default: [],\n item: {\n label: 'Navigation item',\n properties: [\n { path: 'label', label: 'Label', group: 'Content', valueType: PropertyValueType.String, constraints: { required: true, minimumLength: 1 } },\n { path: 'icon', label: 'Icon', group: 'Content', valueType: PropertyValueType.Icon, editorKind: 'iconPicker' },\n { path: 'destination', label: 'Destination', group: 'Content', valueType: PropertyValueType.Destination, editorKind: 'screenPicker', constraints: { required: true } },\n ],\n },\n },\n ],\n },\n];\n"],"names":["key","name","componentRegistryKey","coreDescriptors","component","displayName","properties","path","label","group","valueType","PropertyValueType","String","default","description","editorKind","constraints","required","Collection","item","minimumLength","Icon","Destination"],"mappings":";;;;;;;;;;;AAAA;AACA;AAKA,MAAMA,GAAAA,GAAM,CAACC,IAAAA,GAAiBC,uCAAAA,CAAqB,MAAA,EAAQD,IAAAA,CAAAA;AAE3D;;;;;;UAOaE,eAAAA,GAAyC;AAClD,IAAA;AACIC,QAAAA,SAAAA,EAAWJ,GAAAA,CAAI,QAAA,CAAA;QACfK,WAAAA,EAAa,QAAA;QACbC,UAAAA,EAAY;AACR,YAAA;gBAAEC,IAAAA,EAAM,OAAA;gBAASC,KAAAA,EAAO,OAAA;gBAASC,KAAAA,EAAO,SAAA;AAAWC,gBAAAA,SAAAA,EAAWC,8BAAkBC,MAAM;gBAAEC,OAAAA,EAAS;AAAG;AACvG;AACL,KAAA;AACA,IAAA;AACIT,QAAAA,SAAAA,EAAWJ,GAAAA,CAAI,QAAA,CAAA;QACfK,WAAAA,EAAa,gBAAA;QACbS,WAAAA,EAAa,gJAAA;QACb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AA;4BAAQC,KAAAA,EAAO,SAAA;AAAWC,4BAAAA,SAAAA,EAAWC,8BAAkBU,IAAI;4BAAEN,UAAAA,EAAY;AAAa,yBAAA;AAC7G,wBAAA;4BAAER,IAAAA,EAAM,aAAA;4BAAeC,KAAAA,EAAO,aAAA;4BAAeC,KAAAA,EAAO,SAAA;AAAWC,4BAAAA,SAAAA,EAAWC,8BAAkBW,WAAW;4BAAEP,UAAAA,EAAY,cAAA;4BAAgBC,WAAAA,EAAa;gCAAEC,QAAAA,EAAU;AAAK;AAAE;AACxK;AACL;AACJ;AACH;AACL;;;"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -19,18 +19,31 @@ var NavBar = require('./NavBar/NavBar.js');
|
|
|
19
19
|
var extractNavigationItem = require('./NavBar/extractNavigationItem.js');
|
|
20
20
|
var SceneNavigationContext = require('./navigation/SceneNavigationContext.js');
|
|
21
21
|
var SceneNavigationHost = require('./navigation/SceneNavigationHost.js');
|
|
22
|
+
var createBrowserSceneHistory = require('./navigation/createBrowserSceneHistory.js');
|
|
23
|
+
var createMemorySceneHistory = require('./navigation/createMemorySceneHistory.js');
|
|
24
|
+
var diagnoseRenderedNavigation = require('./navigation/diagnoseRenderedNavigation.js');
|
|
25
|
+
var identityRoute = require('./navigation/identityRoute.js');
|
|
26
|
+
var matchSceneRoute = require('./navigation/matchSceneRoute.js');
|
|
27
|
+
var navigationRouteKey = require('./navigation/navigationRouteKey.js');
|
|
22
28
|
var resolveDestination = require('./navigation/resolveDestination.js');
|
|
29
|
+
var sceneRoutesFrom = require('./navigation/sceneRoutesFrom.js');
|
|
30
|
+
var useSceneHistoryNavigation = require('./navigation/useSceneHistoryNavigation.js');
|
|
23
31
|
var IconAdapterRegistry = require('./icons/IconAdapterRegistry.js');
|
|
24
32
|
var IconAdapterContext = require('./icons/IconAdapterContext.js');
|
|
25
33
|
var useIconGlyph = require('./icons/useIconGlyph.js');
|
|
26
34
|
var SceneIcon = require('./icons/SceneIcon.js');
|
|
27
35
|
var DesignTimeBundle = require('./packages/DesignTimeBundle.js');
|
|
36
|
+
var DesignTimeContractVersion = require('./packages/DesignTimeContractVersion.js');
|
|
37
|
+
var DesignTimeExtensionPoint = require('./packages/DesignTimeExtensionPoint.js');
|
|
28
38
|
var DesignTimeProvider = require('./packages/DesignTimeProvider.js');
|
|
29
39
|
var EmbeddedPackageHost = require('./packages/EmbeddedPackageHost.js');
|
|
40
|
+
var loadDesignTimeContributions = require('./packages/loadDesignTimeContributions.js');
|
|
30
41
|
var PackageHostAssets = require('./packages/PackageHostAssets.js');
|
|
31
42
|
var PackageHostConfiguration = require('./packages/PackageHostConfiguration.js');
|
|
32
43
|
var PackageHostRenderMode = require('./packages/PackageHostRenderMode.js');
|
|
33
44
|
var PackageHostView = require('./packages/PackageHostView.js');
|
|
45
|
+
var resolveDesignTimeHost = require('./packages/resolveDesignTimeHost.js');
|
|
46
|
+
var runDesignTimeAction = require('./packages/runDesignTimeAction.js');
|
|
34
47
|
var ScenePackageBundle = require('./packages/ScenePackageBundle.js');
|
|
35
48
|
var StandalonePackageHost = require('./packages/StandalonePackageHost.js');
|
|
36
49
|
var WebViewPackageHost = require('./packages/WebViewPackageHost.js');
|
|
@@ -82,7 +95,15 @@ exports.extractNavigationItem = extractNavigationItem.extractNavigationItem;
|
|
|
82
95
|
exports.SceneNavigationProvider = SceneNavigationContext.SceneNavigationProvider;
|
|
83
96
|
exports.useSceneNavigation = SceneNavigationContext.useSceneNavigation;
|
|
84
97
|
exports.SceneNavigationHost = SceneNavigationHost.SceneNavigationHost;
|
|
98
|
+
exports.createBrowserSceneHistory = createBrowserSceneHistory.createBrowserSceneHistory;
|
|
99
|
+
exports.createMemorySceneHistory = createMemorySceneHistory.createMemorySceneHistory;
|
|
100
|
+
exports.diagnoseRenderedNavigation = diagnoseRenderedNavigation.diagnoseRenderedNavigation;
|
|
101
|
+
exports.identityRoute = identityRoute.identityRoute;
|
|
102
|
+
exports.matchSceneRoute = matchSceneRoute.matchSceneRoute;
|
|
103
|
+
exports.navigationRouteKey = navigationRouteKey.navigationRouteKey;
|
|
85
104
|
exports.resolveDestination = resolveDestination.resolveDestination;
|
|
105
|
+
exports.sceneRoutesFrom = sceneRoutesFrom.sceneRoutesFrom;
|
|
106
|
+
exports.useSceneHistoryNavigation = useSceneHistoryNavigation.useSceneHistoryNavigation;
|
|
86
107
|
exports.IconAdapterRegistry = IconAdapterRegistry.IconAdapterRegistry;
|
|
87
108
|
exports.createIconAdapterRegistry = IconAdapterRegistry.createIconAdapterRegistry;
|
|
88
109
|
exports.IconAdapterProvider = IconAdapterContext.IconAdapterProvider;
|
|
@@ -90,13 +111,19 @@ exports.useIconAdapters = IconAdapterContext.useIconAdapters;
|
|
|
90
111
|
exports.useIconGlyph = useIconGlyph.useIconGlyph;
|
|
91
112
|
exports.SceneIcon = SceneIcon.SceneIcon;
|
|
92
113
|
exports.validateDesignTimeBundle = DesignTimeBundle.validateDesignTimeBundle;
|
|
114
|
+
exports.DesignTimeContractVersion = DesignTimeContractVersion.DesignTimeContractVersion;
|
|
115
|
+
exports.DesignTimeExtensionPoint = DesignTimeExtensionPoint.DesignTimeExtensionPoint;
|
|
116
|
+
exports.designTimeExtensionPointLabels = DesignTimeExtensionPoint.designTimeExtensionPointLabels;
|
|
93
117
|
exports.DesignTimeProvider = DesignTimeProvider.DesignTimeProvider;
|
|
94
118
|
exports.useDesignTimeContext = DesignTimeProvider.useDesignTimeContext;
|
|
95
119
|
exports.EmbeddedPackageHost = EmbeddedPackageHost.EmbeddedPackageHost;
|
|
120
|
+
exports.loadDesignTimeContributions = loadDesignTimeContributions.loadDesignTimeContributions;
|
|
96
121
|
exports.PackageHostAssets = PackageHostAssets.PackageHostAssets;
|
|
97
122
|
exports.resolvePackageHost = PackageHostConfiguration.resolvePackageHost;
|
|
98
123
|
exports.PackageHostRenderMode = PackageHostRenderMode.PackageHostRenderMode;
|
|
99
124
|
exports.PackageHostView = PackageHostView.PackageHostView;
|
|
125
|
+
exports.resolveDesignTimeHost = resolveDesignTimeHost.resolveDesignTimeHost;
|
|
126
|
+
exports.runDesignTimeAction = runDesignTimeAction.runDesignTimeAction;
|
|
100
127
|
exports.componentRegistryKey = ScenePackageBundle.componentRegistryKey;
|
|
101
128
|
exports.mergeIconAdapters = ScenePackageBundle.mergeIconAdapters;
|
|
102
129
|
exports.mergePackageRegistries = ScenePackageBundle.mergePackageRegistries;
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SceneNavigationContext.js","sources":["../../../navigation/SceneNavigationContext.tsx"],"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 { ReactNode, createContext, useContext } from 'react';\nimport { BindingScope } from '@cratis/scene.engine';\nimport { DestinationReference } from '@cratis/scene.model';\nimport { DestinationResolution } from './DestinationResolution';\n\nexport interface SceneNavigationContextValue {\n currentScreen: string;\n currentUrl?: string;\n currentOutlet?: string;\n currentDialog?: string;\n bindingScope: BindingScope;\n navigate(destination: DestinationReference): DestinationResolution;\n closeDialog(): void;\n}\n\nconst Context = createContext<SceneNavigationContextValue | undefined>(undefined);\n\nexport interface SceneNavigationProviderProps {\n value: SceneNavigationContextValue;\n children: ReactNode;\n}\n\nexport function SceneNavigationProvider({ value, children }: SceneNavigationProviderProps) {\n return <Context.Provider value={value}>{children}</Context.Provider>;\n}\n\nexport function useSceneNavigation(): SceneNavigationContextValue {\n const context = useContext(Context);\n if (!context) throw new Error('No Scene navigation context is available.');\n return context;\n}\n"],"names":["Context","createContext","undefined","SceneNavigationProvider","value","children","_jsx","Provider","useSceneNavigation","context","useContext","Error"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"SceneNavigationContext.js","sources":["../../../navigation/SceneNavigationContext.tsx"],"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 { ReactNode, createContext, useContext } from 'react';\nimport { BindingScope } from '@cratis/scene.engine';\nimport { DestinationReference } from '@cratis/scene.model';\nimport { DestinationResolution } from './DestinationResolution';\nimport { DialogResult } from './DialogResult';\n\nexport interface SceneNavigationContextValue {\n currentScreen: string;\n currentUrl?: string;\n currentOutlet?: string;\n currentDialog?: string;\n\n /** The route parameters of the current entry - from the destination that opened it, or the deep link. */\n currentParameters: Record<string, string>;\n\n /** What the last dialog returned when it closed. */\n dialogResult?: DialogResult;\n\n /** A deep link that matched no route; the host fell back to its initial screen. */\n unresolvedUrl?: string;\n bindingScope: BindingScope;\n navigate(destination: DestinationReference): DestinationResolution;\n\n /** Closes the open dialog, returning to the entry that opened it, and records its result. */\n closeDialog(result?: unknown): void;\n\n /** Goes back one history entry. */\n back(): void;\n}\n\nconst Context = createContext<SceneNavigationContextValue | undefined>(undefined);\n\nexport interface SceneNavigationProviderProps {\n value: SceneNavigationContextValue;\n children: ReactNode;\n}\n\nexport function SceneNavigationProvider({ value, children }: SceneNavigationProviderProps) {\n return <Context.Provider value={value}>{children}</Context.Provider>;\n}\n\nexport function useSceneNavigation(): SceneNavigationContextValue {\n const context = useContext(Context);\n if (!context) throw new Error('No Scene navigation context is available.');\n return context;\n}\n"],"names":["Context","createContext","undefined","SceneNavigationProvider","value","children","_jsx","Provider","useSceneNavigation","context","useContext","Error"],"mappings":";;;;;AAiCA,MAAMA,wBAAUC,mBAAAA,CAAuDC,SAAAA,CAAAA;AAOhE,SAASC,uBAAAA,CAAwB,EAAEC,KAAK,EAAEC,QAAQ,EAAgC,EAAA;IACrF,qBAAOC,cAAA,CAACN,QAAQO,QAAQ,EAAA;QAACH,KAAAA,EAAOA,KAAAA;AAAQC,QAAAA,QAAAA,EAAAA;;AAC5C;AAEO,SAASG,kBAAAA,GAAAA;AACZ,IAAA,MAAMC,UAAUC,gBAAAA,CAAWV,OAAAA,CAAAA;AAC3B,IAAA,IAAI,CAACS,OAAAA,EAAS,MAAM,IAAIE,KAAAA,CAAM,2CAAA,CAAA;IAC9B,OAAOF,OAAAA;AACX;;;"}
|
|
@@ -2,59 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var react = require('react');
|
|
5
|
-
var scene_model = require('@cratis/scene.model');
|
|
6
5
|
var SceneElementView = require('../SceneElementView.js');
|
|
6
|
+
var createMemorySceneHistory = require('./createMemorySceneHistory.js');
|
|
7
7
|
var SceneNavigationContext = require('./SceneNavigationContext.js');
|
|
8
|
-
var
|
|
8
|
+
var sceneRoutesFrom = require('./sceneRoutesFrom.js');
|
|
9
|
+
var useSceneHistoryNavigation = require('./useSceneHistoryNavigation.js');
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Executes Scene destinations against an in-memory rendered hierarchy: screen routes replace outlets,
|
|
12
|
-
* dialog destinations render dialog content
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const [
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (resolution.kind === scene_model.DestinationKind.Dialog) {
|
|
21
|
-
setCurrentDialog(resolution.dialog);
|
|
22
|
-
return resolution;
|
|
23
|
-
}
|
|
24
|
-
if (resolution.kind !== scene_model.DestinationKind.External) {
|
|
25
|
-
setCurrentScreen(destination.screen ?? destination.slice ?? currentScreen);
|
|
26
|
-
setCurrentOutlet(resolution.outlet);
|
|
27
|
-
}
|
|
28
|
-
setCurrentUrl(resolution.url);
|
|
29
|
-
return resolution;
|
|
30
|
-
}, [
|
|
31
|
-
bindingScope,
|
|
32
|
-
currentScreen
|
|
13
|
+
* dialog destinations render dialog content over the screen that opened them, and external destinations
|
|
14
|
+
* only report their resolved action. Every navigation is a history entry.
|
|
15
|
+
*/ function SceneNavigationHost({ screens, dialogs = {}, initialScreen, registry, bindingScope = {}, history, destinations, routes }) {
|
|
16
|
+
const [memoryHistory] = react.useState(()=>createMemorySceneHistory.createMemorySceneHistory());
|
|
17
|
+
const routeTable = react.useMemo(()=>routes ?? sceneRoutesFrom.sceneRoutesFrom(Object.keys(screens), destinations), [
|
|
18
|
+
destinations,
|
|
19
|
+
routes,
|
|
20
|
+
screens
|
|
33
21
|
]);
|
|
34
|
-
const value =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
currentOutlet,
|
|
38
|
-
currentDialog,
|
|
39
|
-
bindingScope,
|
|
40
|
-
navigate,
|
|
41
|
-
closeDialog: ()=>setCurrentDialog(undefined)
|
|
42
|
-
}), [
|
|
43
|
-
bindingScope,
|
|
44
|
-
currentDialog,
|
|
45
|
-
currentOutlet,
|
|
46
|
-
currentScreen,
|
|
47
|
-
currentUrl,
|
|
48
|
-
navigate
|
|
49
|
-
]);
|
|
50
|
-
const screen = screens[currentScreen];
|
|
51
|
-
const dialog = currentDialog ? dialogs[currentDialog] : undefined;
|
|
22
|
+
const value = useSceneHistoryNavigation.useSceneHistoryNavigation(history ?? memoryHistory, routeTable, initialScreen, bindingScope);
|
|
23
|
+
const screen = screens[value.currentScreen];
|
|
24
|
+
const dialog = value.currentDialog ? dialogs[value.currentDialog] : undefined;
|
|
52
25
|
return /*#__PURE__*/ jsxRuntime.jsxs(SceneNavigationContext.SceneNavigationProvider, {
|
|
53
26
|
value: value,
|
|
54
27
|
children: [
|
|
55
28
|
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
56
|
-
"data-scene-outlet": currentOutlet ?? 'primary',
|
|
57
|
-
"data-scene-url": currentUrl,
|
|
29
|
+
"data-scene-outlet": value.currentOutlet ?? 'primary',
|
|
30
|
+
"data-scene-url": value.currentUrl,
|
|
58
31
|
children: screen && /*#__PURE__*/ jsxRuntime.jsx(SceneElementView.SceneElementView, {
|
|
59
32
|
element: screen,
|
|
60
33
|
registry: registry,
|
|
@@ -65,7 +38,9 @@ var resolveDestination = require('./resolveDestination.js');
|
|
|
65
38
|
}),
|
|
66
39
|
dialog && /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
67
40
|
role: "dialog",
|
|
68
|
-
"
|
|
41
|
+
"aria-modal": "true",
|
|
42
|
+
"aria-label": value.currentDialog,
|
|
43
|
+
"data-scene-dialog": value.currentDialog,
|
|
69
44
|
children: /*#__PURE__*/ jsxRuntime.jsx(SceneElementView.SceneElementView, {
|
|
70
45
|
element: dialog,
|
|
71
46
|
registry: registry,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SceneNavigationHost.js","sources":["../../../navigation/SceneNavigationHost.tsx"],"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 {
|
|
1
|
+
{"version":3,"file":"SceneNavigationHost.js","sources":["../../../navigation/SceneNavigationHost.tsx"],"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 { useMemo, useState } from 'react';\nimport { BindingScope } from '@cratis/scene.engine';\nimport { DestinationReference, SceneElement } from '@cratis/scene.model';\nimport { SceneElementView } from '../SceneElementView';\nimport { ComponentRegistry } from '../renderer';\nimport { createMemorySceneHistory } from './createMemorySceneHistory';\nimport { SceneHistory } from './SceneHistory';\nimport { SceneNavigationProvider } from './SceneNavigationContext';\nimport { SceneRoute } from './SceneRoute';\nimport { sceneRoutesFrom } from './sceneRoutesFrom';\nimport { useSceneHistoryNavigation } from './useSceneHistoryNavigation';\n\nexport interface SceneNavigationHostProps {\n screens: Record<string, SceneElement>;\n dialogs?: Record<string, SceneElement>;\n initialScreen: string;\n registry: ComponentRegistry;\n bindingScope?: BindingScope;\n\n /**\n * Where entries are recorded. `createBrowserSceneHistory()` drives the address bar, so deep links,\n * refresh and back/forward work; the default is an in-memory history for embedded hosts.\n */\n history?: SceneHistory;\n\n /** The destinations the application navigates to, so their route overrides can be deep linked. */\n destinations?: DestinationReference[];\n\n /** An explicit route table, used instead of the one derived from `screens` and `destinations`. */\n routes?: SceneRoute[];\n}\n\n/**\n * Executes Scene destinations against an in-memory rendered hierarchy: screen routes replace outlets,\n * dialog destinations render dialog content over the screen that opened them, and external destinations\n * only report their resolved action. Every navigation is a history entry.\n */\nexport function SceneNavigationHost({ screens, dialogs = {}, initialScreen, registry, bindingScope = {}, history, destinations, routes }: SceneNavigationHostProps) {\n const [memoryHistory] = useState(() => createMemorySceneHistory());\n const routeTable = useMemo(() => routes ?? sceneRoutesFrom(Object.keys(screens), destinations), [destinations, routes, screens]);\n const value = useSceneHistoryNavigation(history ?? memoryHistory, routeTable, initialScreen, bindingScope);\n\n const screen = screens[value.currentScreen];\n const dialog = value.currentDialog ? dialogs[value.currentDialog] : undefined;\n\n return <SceneNavigationProvider value={value}>\n <div data-scene-outlet={value.currentOutlet ?? 'primary'} data-scene-url={value.currentUrl}>\n {screen && <SceneElementView element={screen} registry={registry} dataContext={bindingScope.dataContext} queryResults={bindingScope.queryResults} componentOutputs={bindingScope.componentOutputs} />}\n </div>\n {dialog && <div role='dialog' aria-modal='true' aria-label={value.currentDialog} data-scene-dialog={value.currentDialog}>\n <SceneElementView element={dialog} registry={registry} dataContext={bindingScope.dataContext} queryResults={bindingScope.queryResults} componentOutputs={bindingScope.componentOutputs} />\n </div>}\n </SceneNavigationProvider>;\n}\n"],"names":["SceneNavigationHost","screens","dialogs","initialScreen","registry","bindingScope","history","destinations","routes","memoryHistory","useState","createMemorySceneHistory","routeTable","useMemo","sceneRoutesFrom","Object","keys","value","useSceneHistoryNavigation","screen","currentScreen","dialog","currentDialog","undefined","_jsxs","SceneNavigationProvider","_jsx","div","data-scene-outlet","currentOutlet","data-scene-url","currentUrl","SceneElementView","element","dataContext","queryResults","componentOutputs","role","aria-modal","aria-label","data-scene-dialog"],"mappings":";;;;;;;;;;AAmCA;;;;IAKO,SAASA,mBAAAA,CAAoB,EAAEC,OAAO,EAAEC,OAAAA,GAAU,EAAE,EAAEC,aAAa,EAAEC,QAAQ,EAAEC,YAAAA,GAAe,EAAE,EAAEC,OAAO,EAAEC,YAAY,EAAEC,MAAM,EAA4B,EAAA;AAC9J,IAAA,MAAM,CAACC,aAAAA,CAAc,GAAGC,cAAAA,CAAS,IAAMC,iDAAAA,EAAAA,CAAAA;IACvC,MAAMC,UAAAA,GAAaC,cAAQ,IAAML,MAAAA,IAAUM,gCAAgBC,MAAAA,CAAOC,IAAI,CAACf,OAAAA,CAAAA,EAAUM,YAAAA,CAAAA,EAAe;AAACA,QAAAA,YAAAA;AAAcC,QAAAA,MAAAA;AAAQP,QAAAA;AAAQ,KAAA,CAAA;AAC/H,IAAA,MAAMgB,KAAAA,GAAQC,mDAAAA,CAA0BZ,OAAAA,IAAWG,aAAAA,EAAeG,YAAYT,aAAAA,EAAeE,YAAAA,CAAAA;AAE7F,IAAA,MAAMc,MAAAA,GAASlB,OAAO,CAACgB,KAAAA,CAAMG,aAAa,CAAC;IAC3C,MAAMC,MAAAA,GAASJ,MAAMK,aAAa,GAAGpB,OAAO,CAACe,KAAAA,CAAMK,aAAa,CAAC,GAAGC,SAAAA;AAEpE,IAAA,qBAAOC,eAAA,CAACC,8CAAAA,EAAAA;QAAwBR,KAAAA,EAAOA,KAAAA;;0BACnCS,cAAA,CAACC,KAAAA,EAAAA;gBAAIC,mBAAAA,EAAmBX,KAAAA,CAAMY,aAAa,IAAI,SAAA;AAAWC,gBAAAA,gBAAAA,EAAgBb,MAAMc,UAAU;AACrFZ,gBAAAA,QAAAA,EAAAA,MAAAA,kBAAUO,cAAA,CAACM,iCAAAA,EAAAA;oBAAiBC,OAAAA,EAASd,MAAAA;oBAAQf,QAAAA,EAAUA,QAAAA;AAAU8B,oBAAAA,WAAAA,EAAa7B,aAAa6B,WAAW;AAAEC,oBAAAA,YAAAA,EAAc9B,aAAa8B,YAAY;AAAEC,oBAAAA,gBAAAA,EAAkB/B,aAAa+B;;;AAEpLf,YAAAA,MAAAA,kBAAUK,cAAA,CAACC,KAAAA,EAAAA;gBAAIU,IAAAA,EAAK,QAAA;gBAASC,YAAAA,EAAW,MAAA;AAAOC,gBAAAA,YAAAA,EAAYtB,MAAMK,aAAa;AAAEkB,gBAAAA,mBAAAA,EAAmBvB,MAAMK,aAAa;AACnH,gBAAA,QAAA,gBAAAI,cAAA,CAACM,iCAAAA,EAAAA;oBAAiBC,OAAAA,EAASZ,MAAAA;oBAAQjB,QAAAA,EAAUA,QAAAA;AAAU8B,oBAAAA,WAAAA,EAAa7B,aAAa6B,WAAW;AAAEC,oBAAAA,YAAAA,EAAc9B,aAAa8B,YAAY;AAAEC,oBAAAA,gBAAAA,EAAkB/B,aAAa+B;;;;;AAGlL;;"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
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
|
+
const stateKey = 'sceneNavigation';
|
|
6
|
+
/**
|
|
7
|
+
* A history backed by the browser's `history` API under a base path such as `/app/`. Entries carry their
|
|
8
|
+
* navigation state, so back and forward restore the screen, outlet, parameters and dialog without
|
|
9
|
+
* re-resolving; an entry without state - a typed or bookmarked URL - is reported by URL alone.
|
|
10
|
+
*/ function createBrowserSceneHistory(browser = window, basePath = '/') {
|
|
11
|
+
const base = basePath.endsWith('/') ? basePath : `${basePath}/`;
|
|
12
|
+
const href = (url)=>`${base}${url ?? ''}`;
|
|
13
|
+
const location = ()=>{
|
|
14
|
+
const current = `${browser.location.pathname}${browser.location.search}`;
|
|
15
|
+
if (!current.startsWith(base)) return undefined;
|
|
16
|
+
const relative = current.substring(base.length);
|
|
17
|
+
return relative.length ? relative : undefined;
|
|
18
|
+
};
|
|
19
|
+
const stored = (value)=>value?.[stateKey];
|
|
20
|
+
return {
|
|
21
|
+
location,
|
|
22
|
+
state: ()=>stored(browser.history.state),
|
|
23
|
+
push: (state)=>browser.history.pushState({
|
|
24
|
+
[stateKey]: state
|
|
25
|
+
}, '', href(state.url)),
|
|
26
|
+
replace: (state)=>browser.history.replaceState({
|
|
27
|
+
[stateKey]: state
|
|
28
|
+
}, '', href(state.url)),
|
|
29
|
+
back: ()=>browser.history.back(),
|
|
30
|
+
listen: (listener)=>{
|
|
31
|
+
const onPopState = (event)=>listener(location(), stored(event.state));
|
|
32
|
+
browser.addEventListener('popstate', onPopState);
|
|
33
|
+
return ()=>browser.removeEventListener('popstate', onPopState);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
exports.createBrowserSceneHistory = createBrowserSceneHistory;
|
|
39
|
+
//# sourceMappingURL=createBrowserSceneHistory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createBrowserSceneHistory.js","sources":["../../../navigation/createBrowserSceneHistory.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/** The part of `window` the browser history needs, so a host can pass its own frame's window. */\nexport type SceneBrowserWindow = Pick<Window, 'history' | 'location' | 'addEventListener' | 'removeEventListener'>;\n\nconst stateKey = 'sceneNavigation';\n\n/**\n * A history backed by the browser's `history` API under a base path such as `/app/`. Entries carry their\n * navigation state, so back and forward restore the screen, outlet, parameters and dialog without\n * re-resolving; an entry without state - a typed or bookmarked URL - is reported by URL alone.\n */\nexport function createBrowserSceneHistory(browser: SceneBrowserWindow = window, basePath = '/'): SceneHistory {\n const base = basePath.endsWith('/') ? basePath : `${basePath}/`;\n const href = (url: string | undefined) => `${base}${url ?? ''}`;\n const location = () => {\n const current = `${browser.location.pathname}${browser.location.search}`;\n if (!current.startsWith(base)) return undefined;\n const relative = current.substring(base.length);\n return relative.length ? relative : undefined;\n };\n const stored = (value: unknown) => (value as Record<string, SceneNavigationState> | null)?.[stateKey];\n\n return {\n location,\n state: () => stored(browser.history.state),\n push: state => browser.history.pushState({ [stateKey]: state }, '', href(state.url)),\n replace: state => browser.history.replaceState({ [stateKey]: state }, '', href(state.url)),\n back: () => browser.history.back(),\n listen: listener => {\n const onPopState = (event: PopStateEvent) => listener(location(), stored(event.state));\n browser.addEventListener('popstate', onPopState);\n return () => browser.removeEventListener('popstate', onPopState);\n },\n };\n}\n"],"names":["stateKey","createBrowserSceneHistory","browser","window","basePath","base","endsWith","href","url","location","current","pathname","search","startsWith","undefined","relative","substring","length","stored","value","state","history","push","pushState","replace","replaceState","back","listen","listener","onPopState","event","addEventListener","removeEventListener"],"mappings":";;AAAA;AACA;AAQA,MAAMA,QAAAA,GAAW,iBAAA;AAEjB;;;;AAIC,IACM,SAASC,yBAAAA,CAA0BC,UAA8BC,MAAM,EAAEC,WAAW,GAAG,EAAA;IAC1F,MAAMC,IAAAA,GAAOD,SAASE,QAAQ,CAAC,OAAOF,QAAAA,GAAW,CAAA,EAAGA,QAAAA,CAAS,CAAC,CAAC;AAC/D,IAAA,MAAMG,OAAO,CAACC,GAAAA,GAA4B,CAAA,EAAGH,IAAAA,CAAAA,EAAOG,OAAO,EAAA,CAAA,CAAI;AAC/D,IAAA,MAAMC,QAAAA,GAAW,IAAA;QACb,MAAMC,OAAAA,GAAU,CAAA,EAAGR,OAAAA,CAAQO,QAAQ,CAACE,QAAQ,CAAA,EAAGT,OAAAA,CAAQO,QAAQ,CAACG,MAAM,CAAA,CAAE;AACxE,QAAA,IAAI,CAACF,OAAAA,CAAQG,UAAU,CAACR,OAAO,OAAOS,SAAAA;AACtC,QAAA,MAAMC,QAAAA,GAAWL,OAAAA,CAAQM,SAAS,CAACX,KAAKY,MAAM,CAAA;Q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the project root for full license information.
|
|
5
|
+
/**
|
|
6
|
+
* A history kept in memory with the same push, replace and back semantics as the browser's: pushing
|
|
7
|
+
* discards any forward entries, and going back notifies listeners. `forward` is exposed for hosts and specs
|
|
8
|
+
* that drive the stack themselves.
|
|
9
|
+
*/ function createMemorySceneHistory(initialUrl) {
|
|
10
|
+
const entries = [
|
|
11
|
+
{
|
|
12
|
+
url: initialUrl
|
|
13
|
+
}
|
|
14
|
+
];
|
|
15
|
+
let index = 0;
|
|
16
|
+
const listeners = new Set();
|
|
17
|
+
const notify = ()=>listeners.forEach((listener)=>listener(entries[index].url, entries[index].state));
|
|
18
|
+
return {
|
|
19
|
+
location: ()=>entries[index].url,
|
|
20
|
+
state: ()=>entries[index].state,
|
|
21
|
+
push: (state)=>{
|
|
22
|
+
entries.splice(index + 1, entries.length, {
|
|
23
|
+
url: state.url,
|
|
24
|
+
state
|
|
25
|
+
});
|
|
26
|
+
index = entries.length - 1;
|
|
27
|
+
},
|
|
28
|
+
replace: (state)=>{
|
|
29
|
+
entries[index] = {
|
|
30
|
+
url: state.url,
|
|
31
|
+
state
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
back: ()=>{
|
|
35
|
+
if (index === 0) return;
|
|
36
|
+
index--;
|
|
37
|
+
notify();
|
|
38
|
+
},
|
|
39
|
+
forward: ()=>{
|
|
40
|
+
if (index === entries.length - 1) return;
|
|
41
|
+
index++;
|
|
42
|
+
notify();
|
|
43
|
+
},
|
|
44
|
+
entries: ()=>entries.map((entry)=>entry.state).filter((state)=>state !== undefined),
|
|
45
|
+
listen: (listener)=>{
|
|
46
|
+
listeners.add(listener);
|
|
47
|
+
return ()=>listeners.delete(listener);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
exports.createMemorySceneHistory = createMemorySceneHistory;
|
|
53
|
+
//# 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,W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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,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var scene_engine = require('@cratis/scene.engine');
|
|
4
|
+
var navigationRouteKey = require('./navigationRouteKey.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
|
+
* Diagnoses navigation the way this renderer routes it: the engine's checks, with duplicate routes compared
|
|
10
|
+
* by the URLs `resolveDestination` actually builds - identity-derived routes included, parameter spellings
|
|
11
|
+
* treated as equal.
|
|
12
|
+
*/ function diagnoseRenderedNavigation(graph) {
|
|
13
|
+
return scene_engine.diagnoseNavigation(graph, navigationRouteKey.navigationRouteKey);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
exports.diagnoseRenderedNavigation = diagnoseRenderedNavigation;
|
|
17
|
+
//# 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,gCAAmBD,KAAAA,EAAOE,qCAAAA,CAAAA;AACrC;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
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 gets when no route override was authored: its screen name, or its stable
|
|
7
|
+
* module/feature/slice identity as a path.
|
|
8
|
+
*/ function identityRoute(destination) {
|
|
9
|
+
if (destination.screen) return destination.screen;
|
|
10
|
+
const parts = [
|
|
11
|
+
destination.module,
|
|
12
|
+
destination.feature,
|
|
13
|
+
destination.slice
|
|
14
|
+
].filter((part)=>typeof part === 'string' && part.length > 0);
|
|
15
|
+
return parts.length ? parts.join('/') : undefined;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
exports.identityRoute = identityRoute;
|
|
19
|
+
//# 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;;"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
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
|
+
* Matches a URL - as a deep link, a refresh or a typed address delivers it - against route templates.
|
|
7
|
+
* `{name}` segments capture path parameters; the query string adds the rest. Literal segments win over
|
|
8
|
+
* parameters, so `orders/new` beats `orders/{orderId}`, and routes are otherwise tried in the given order.
|
|
9
|
+
*/ function matchSceneRoute(url, routes) {
|
|
10
|
+
const [path, query = ''] = url.split('?', 2);
|
|
11
|
+
const segments = path.split('/').filter((segment)=>segment.length > 0).map(decodeURIComponent);
|
|
12
|
+
const queryParameters = Object.fromEntries(new URLSearchParams(query));
|
|
13
|
+
const candidates = routes.map((route, order)=>({
|
|
14
|
+
route,
|
|
15
|
+
order,
|
|
16
|
+
template: route.route.split('/').filter((segment)=>segment.length > 0)
|
|
17
|
+
})).filter((candidate)=>candidate.template.length === segments.length).sort((left, right)=>literalCount(right.template) - literalCount(left.template) || left.order - right.order);
|
|
18
|
+
for (const { route, template } of candidates){
|
|
19
|
+
const parameters = {};
|
|
20
|
+
const matches = template.every((part, index)=>{
|
|
21
|
+
const name = /^\{([^}]+)\}$/.exec(part)?.[1];
|
|
22
|
+
if (name) {
|
|
23
|
+
parameters[name] = segments[index];
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
return part === segments[index];
|
|
27
|
+
});
|
|
28
|
+
if (matches) return {
|
|
29
|
+
route,
|
|
30
|
+
parameters: {
|
|
31
|
+
...queryParameters,
|
|
32
|
+
...parameters
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
function literalCount(template) {
|
|
39
|
+
return template.filter((part)=>!/^\{[^}]+\}$/.test(part)).length;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
exports.matchSceneRoute = matchSceneRoute;
|
|
43
|
+
//# 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,GAAG,CAAC,CAACO,KAAAA,EAAOC,SAAW;AAAED,YAAAA,KAAAA;AAAOC,YAAAA,KAAAA;AAAOC,YAAAA,QAAAA,EAAUF,KAAAA,CAAMA,KAAK,CAACZ,KAAK,CAAC,GAAA,CAAA,CAAKE,MAAM,CAACC,CAAAA,OAAAA,GAAWA,OAAAA,CAAQC,MAAM,GAAG,CAAA;AAAG,SAAA,CAAA,CAAA,CAC9GF,MAAM,CAACa,CAAAA,SAAAA,G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
|
5
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
6
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
7
|
+
/**
|
|
8
|
+
* The route a destination occupies in this renderer: the authored override or the identity-derived route -
|
|
9
|
+
* the same base `resolveDestination` builds a URL from - with surrounding slashes removed and every parameter
|
|
10
|
+
* placeholder (`{id}` or `:id`) reduced to one marker, so `/invoices/{id}` and `invoices/:invoiceId` are the
|
|
11
|
+
* same URL.
|
|
12
|
+
*/ const navigationRouteKey = (destination)=>{
|
|
13
|
+
const route = destination.route ?? identityRoute.identityRoute(destination);
|
|
14
|
+
if (!route?.trim()) return undefined;
|
|
15
|
+
return route.trim().split('/').filter((segment)=>segment.length > 0).map((segment)=>/^\{[^}]*\}$/.test(segment) || /^:.+$/.test(segment) ? '{}' : segment).join('/');
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.navigationRouteKey = navigationRouteKey;
|
|
19
|
+
//# 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,2BAAAA,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;;"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var scene_engine = require('@cratis/scene.engine');
|
|
4
4
|
var scene_model = require('@cratis/scene.model');
|
|
5
|
+
var identityRoute = require('./identityRoute.js');
|
|
5
6
|
|
|
6
7
|
// Copyright (c) Cratis. All rights reserved.
|
|
7
8
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
@@ -14,7 +15,7 @@ var scene_model = require('@cratis/scene.model');
|
|
|
14
15
|
name,
|
|
15
16
|
String(scene_engine.resolveBindingExpression(binding, scope) ?? '')
|
|
16
17
|
]);
|
|
17
|
-
const base = destination.route ?? identityRoute(destination);
|
|
18
|
+
const base = destination.route ?? identityRoute.identityRoute(destination);
|
|
18
19
|
if (!base && kind !== scene_model.DestinationKind.Dialog) diagnostics.push('Destination has no routeable screen, stable identity or route.');
|
|
19
20
|
const url = base ? appendParameters(base, parameters) : undefined;
|
|
20
21
|
return {
|
|
@@ -22,19 +23,11 @@ var scene_model = require('@cratis/scene.model');
|
|
|
22
23
|
url,
|
|
23
24
|
outlet: destination.outlet,
|
|
24
25
|
dialog: destination.dialog,
|
|
26
|
+
parameters: Object.fromEntries(parameters),
|
|
25
27
|
action: kind === scene_model.DestinationKind.Dialog ? 'openDialog' : kind === scene_model.DestinationKind.External ? 'openExternal' : 'navigate',
|
|
26
28
|
diagnostics
|
|
27
29
|
};
|
|
28
30
|
}
|
|
29
|
-
function identityRoute(destination) {
|
|
30
|
-
if (destination.screen) return destination.screen;
|
|
31
|
-
const parts = [
|
|
32
|
-
destination.module,
|
|
33
|
-
destination.feature,
|
|
34
|
-
destination.slice
|
|
35
|
-
].filter((part)=>typeof part === 'string' && part.length > 0);
|
|
36
|
-
return parts.length ? parts.join('/') : undefined;
|
|
37
|
-
}
|
|
38
31
|
function appendParameters(route, parameters) {
|
|
39
32
|
if (!parameters.length) return route;
|
|
40
33
|
let replaced = route;
|