@cratis/scene.react 4.11.0 → 4.13.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 +1 -0
- 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 +17 -0
- package/dist/cjs/index.js.map +1 -1
- 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/navigationRouteKey.js +19 -0
- package/dist/cjs/navigation/navigationRouteKey.js.map +1 -0
- package/dist/cjs/navigation/resolveDestination.js +2 -10
- package/dist/cjs/navigation/resolveDestination.js.map +1 -1
- 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 +1 -0
- 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 +8 -0
- package/dist/esm/index.js.map +1 -1
- 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 +3 -0
- package/dist/esm/navigation/index.d.ts.map +1 -1
- package/dist/esm/navigation/index.js +3 -0
- package/dist/esm/navigation/index.js.map +1 -1
- 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 +1 -9
- package/dist/esm/navigation/resolveDestination.js.map +1 -1
- 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/diagnoseRenderedNavigation.ts +14 -0
- package/navigation/identityRoute.ts +14 -0
- package/navigation/index.ts +3 -0
- package/navigation/navigationRouteKey.ts +22 -0
- package/navigation/resolveDestination.ts +1 -6
- 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
|
@@ -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
|
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;QACbR,UAAAA,EAAY;AACR,YAAA;gBAAEC,IAAAA,EAAM,OAAA;gBAASC,KAAAA,EAAO,OAAA;gBAASC,KAAAA,EAAO,SAAA;AAAWC,gBAAAA,SAAAA,EAAWC,8BAAkBC;AAAO,aAAA;AACvF,YAAA;gBACIL,IAAAA,EAAM,SAAA;gBAAWC,KAAAA,EAAO,SAAA;gBAAWC,KAAAA,EAAO,UAAA;AAAYC,gBAAAA,S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EAAY,cAAA;4BAAgBC,WAAAA,EAAa;gCAAEC,QAAAA,EAAU;AAAK;AAAE;AACxK;AACL;AACJ;AACH;AACL;;;"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -20,17 +20,25 @@ var extractNavigationItem = require('./NavBar/extractNavigationItem.js');
|
|
|
20
20
|
var SceneNavigationContext = require('./navigation/SceneNavigationContext.js');
|
|
21
21
|
var SceneNavigationHost = require('./navigation/SceneNavigationHost.js');
|
|
22
22
|
var resolveDestination = require('./navigation/resolveDestination.js');
|
|
23
|
+
var diagnoseRenderedNavigation = require('./navigation/diagnoseRenderedNavigation.js');
|
|
24
|
+
var identityRoute = require('./navigation/identityRoute.js');
|
|
25
|
+
var navigationRouteKey = require('./navigation/navigationRouteKey.js');
|
|
23
26
|
var IconAdapterRegistry = require('./icons/IconAdapterRegistry.js');
|
|
24
27
|
var IconAdapterContext = require('./icons/IconAdapterContext.js');
|
|
25
28
|
var useIconGlyph = require('./icons/useIconGlyph.js');
|
|
26
29
|
var SceneIcon = require('./icons/SceneIcon.js');
|
|
27
30
|
var DesignTimeBundle = require('./packages/DesignTimeBundle.js');
|
|
31
|
+
var DesignTimeContractVersion = require('./packages/DesignTimeContractVersion.js');
|
|
32
|
+
var DesignTimeExtensionPoint = require('./packages/DesignTimeExtensionPoint.js');
|
|
28
33
|
var DesignTimeProvider = require('./packages/DesignTimeProvider.js');
|
|
29
34
|
var EmbeddedPackageHost = require('./packages/EmbeddedPackageHost.js');
|
|
35
|
+
var loadDesignTimeContributions = require('./packages/loadDesignTimeContributions.js');
|
|
30
36
|
var PackageHostAssets = require('./packages/PackageHostAssets.js');
|
|
31
37
|
var PackageHostConfiguration = require('./packages/PackageHostConfiguration.js');
|
|
32
38
|
var PackageHostRenderMode = require('./packages/PackageHostRenderMode.js');
|
|
33
39
|
var PackageHostView = require('./packages/PackageHostView.js');
|
|
40
|
+
var resolveDesignTimeHost = require('./packages/resolveDesignTimeHost.js');
|
|
41
|
+
var runDesignTimeAction = require('./packages/runDesignTimeAction.js');
|
|
34
42
|
var ScenePackageBundle = require('./packages/ScenePackageBundle.js');
|
|
35
43
|
var StandalonePackageHost = require('./packages/StandalonePackageHost.js');
|
|
36
44
|
var WebViewPackageHost = require('./packages/WebViewPackageHost.js');
|
|
@@ -83,6 +91,9 @@ exports.SceneNavigationProvider = SceneNavigationContext.SceneNavigationProvider
|
|
|
83
91
|
exports.useSceneNavigation = SceneNavigationContext.useSceneNavigation;
|
|
84
92
|
exports.SceneNavigationHost = SceneNavigationHost.SceneNavigationHost;
|
|
85
93
|
exports.resolveDestination = resolveDestination.resolveDestination;
|
|
94
|
+
exports.diagnoseRenderedNavigation = diagnoseRenderedNavigation.diagnoseRenderedNavigation;
|
|
95
|
+
exports.identityRoute = identityRoute.identityRoute;
|
|
96
|
+
exports.navigationRouteKey = navigationRouteKey.navigationRouteKey;
|
|
86
97
|
exports.IconAdapterRegistry = IconAdapterRegistry.IconAdapterRegistry;
|
|
87
98
|
exports.createIconAdapterRegistry = IconAdapterRegistry.createIconAdapterRegistry;
|
|
88
99
|
exports.IconAdapterProvider = IconAdapterContext.IconAdapterProvider;
|
|
@@ -90,13 +101,19 @@ exports.useIconAdapters = IconAdapterContext.useIconAdapters;
|
|
|
90
101
|
exports.useIconGlyph = useIconGlyph.useIconGlyph;
|
|
91
102
|
exports.SceneIcon = SceneIcon.SceneIcon;
|
|
92
103
|
exports.validateDesignTimeBundle = DesignTimeBundle.validateDesignTimeBundle;
|
|
104
|
+
exports.DesignTimeContractVersion = DesignTimeContractVersion.DesignTimeContractVersion;
|
|
105
|
+
exports.DesignTimeExtensionPoint = DesignTimeExtensionPoint.DesignTimeExtensionPoint;
|
|
106
|
+
exports.designTimeExtensionPointLabels = DesignTimeExtensionPoint.designTimeExtensionPointLabels;
|
|
93
107
|
exports.DesignTimeProvider = DesignTimeProvider.DesignTimeProvider;
|
|
94
108
|
exports.useDesignTimeContext = DesignTimeProvider.useDesignTimeContext;
|
|
95
109
|
exports.EmbeddedPackageHost = EmbeddedPackageHost.EmbeddedPackageHost;
|
|
110
|
+
exports.loadDesignTimeContributions = loadDesignTimeContributions.loadDesignTimeContributions;
|
|
96
111
|
exports.PackageHostAssets = PackageHostAssets.PackageHostAssets;
|
|
97
112
|
exports.resolvePackageHost = PackageHostConfiguration.resolvePackageHost;
|
|
98
113
|
exports.PackageHostRenderMode = PackageHostRenderMode.PackageHostRenderMode;
|
|
99
114
|
exports.PackageHostView = PackageHostView.PackageHostView;
|
|
115
|
+
exports.resolveDesignTimeHost = resolveDesignTimeHost.resolveDesignTimeHost;
|
|
116
|
+
exports.runDesignTimeAction = runDesignTimeAction.runDesignTimeAction;
|
|
100
117
|
exports.componentRegistryKey = ScenePackageBundle.componentRegistryKey;
|
|
101
118
|
exports.mergeIconAdapters = ScenePackageBundle.mergeIconAdapters;
|
|
102
119
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -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,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var identityRoute = require('./identityRoute.js');
|
|
4
|
+
|
|
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 {
|
|
@@ -26,15 +27,6 @@ var scene_model = require('@cratis/scene.model');
|
|
|
26
27
|
diagnostics
|
|
27
28
|
};
|
|
28
29
|
}
|
|
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
30
|
function appendParameters(route, parameters) {
|
|
39
31
|
if (!parameters.length) return route;
|
|
40
32
|
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 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","action","External","length","replaced","unused","value","marker","includes","split","join","encodeURICom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D,EAAA;AACvF,IAAA,IAAI,CAACA,UAAAA,CAAWmB,MAAM,EAAE,OAAOT,KAAAA;AAC/B,IAAA,IAAIU,QAAAA,GAAWV,KAAAA;AACf,IAAA,MAAMW,SAAmB,EAAE;AAC3B,IAAA,KAAK,MAAM,CAAChB,IAAAA,EAAMiB,KAAAA,CAAM,IAAItB,UAAAA,CAAY;AACpC,QAAA,MAAMuB,SAAS,CAAC,CAAC,EAAElB,IAAAA,CAAK,CAAC,CAAC;QAC1B,IAAIe,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,CAAOT,IAAI,CAAC,CAAA,EAAGe,kBAAAA,CAAmBtB,MAAM,CAAC,EAAEsB,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,15 @@
|
|
|
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 design-time extension contract this host implements, as `major.minor`.
|
|
7
|
+
*
|
|
8
|
+
* The contract is the set of extension points a package's design-time bundle fills - previews, designers,
|
|
9
|
+
* property editors, property displays and actions - and the props and context each receives. A minor
|
|
10
|
+
* version adds optional members; a major version changes or removes them. A host loads a package's
|
|
11
|
+
* contributions only when the package's declared major version matches this one.
|
|
12
|
+
*/ const DesignTimeContractVersion = '1.0';
|
|
13
|
+
|
|
14
|
+
exports.DesignTimeContractVersion = DesignTimeContractVersion;
|
|
15
|
+
//# 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;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
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 versioned design-time extension points a package can fill. The values are the keys shared by
|
|
7
|
+
* `PackageDesignTimeMetadata` (what a manifest declares) and `DesignTimeBundle` (what a bundle provides).
|
|
8
|
+
*/ var DesignTimeExtensionPoint = /*#__PURE__*/ function(DesignTimeExtensionPoint) {
|
|
9
|
+
DesignTimeExtensionPoint["Preview"] = "previews";
|
|
10
|
+
DesignTimeExtensionPoint["Designer"] = "designers";
|
|
11
|
+
DesignTimeExtensionPoint["PropertyEditor"] = "propertyEditors";
|
|
12
|
+
DesignTimeExtensionPoint["PropertyDisplay"] = "propertyDisplays";
|
|
13
|
+
DesignTimeExtensionPoint["Action"] = "actions";
|
|
14
|
+
return DesignTimeExtensionPoint;
|
|
15
|
+
}({});
|
|
16
|
+
/** How a diagnostic names an extension point. */ const designTimeExtensionPointLabels = {
|
|
17
|
+
["previews"]: 'preview',
|
|
18
|
+
["designers"]: 'designer',
|
|
19
|
+
["propertyEditors"]: 'property editor',
|
|
20
|
+
["propertyDisplays"]: 'property display',
|
|
21
|
+
["actions"]: 'action'
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
exports.DesignTimeExtensionPoint = DesignTimeExtensionPoint;
|
|
25
|
+
exports.designTimeExtensionPointLabels = designTimeExtensionPointLabels;
|
|
26
|
+
//# sourceMappingURL=DesignTimeExtensionPoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DesignTimeExtensionPoint.js","sources":["../../../packages/DesignTimeExtensionPoint.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 versioned design-time extension points a package can fill. The values are the keys shared by\n * `PackageDesignTimeMetadata` (what a manifest declares) and `DesignTimeBundle` (what a bundle provides).\n */\nexport enum DesignTimeExtensionPoint {\n Preview = 'previews',\n Designer = 'designers',\n PropertyEditor = 'propertyEditors',\n PropertyDisplay = 'propertyDisplays',\n Action = 'actions',\n}\n\n/** How a diagnostic names an extension point. */\nexport const designTimeExtensionPointLabels: Record<DesignTimeExtensionPoint, string> = {\n [DesignTimeExtensionPoint.Preview]: 'preview',\n [DesignTimeExtensionPoint.Designer]: 'designer',\n [DesignTimeExtensionPoint.PropertyEditor]: 'property editor',\n [DesignTimeExtensionPoint.PropertyDisplay]: 'property display',\n [DesignTimeExtensionPoint.Action]: 'action',\n};\n"],"names":["DesignTimeExtensionPoint","designTimeExtensionPointLabels"],"mappings":";;AAAA;AACA;AAEA;;;IAIO,IAAKA,wBAAAA,iBAAAA,SAAAA,wBAAAA,EAAAA;;;;;;AAAAA,IAAAA,OAAAA,wBAAAA;AAMX,CAAA,CAAA,EAAA;AAED,kDACO,MAAMC,8BAAAA,GAA2E;AACpF,IAAA,CAAA,UAAA,GAAoC,SAAA;AACpC,IAAA,CAAA,WAAA,GAAqC,UAAA;AACrC,IAAA,CAAA,iBAAA,GAA2C,iBAAA;AAC3C,IAAA,CAAA,kBAAA,GAA4C,kBAAA;AAC5C,IAAA,CAAA,SAAA,GAAmC;AACvC;;;"}
|
|
@@ -64,6 +64,7 @@ var ScenePackageBundle = require('./ScenePackageBundle.js');
|
|
|
64
64
|
screenTemplates: approved.flatMap((bundle)=>bundle.screenTemplates ?? []),
|
|
65
65
|
dialogTemplates: approved.flatMap((bundle)=>bundle.dialogTemplates ?? []),
|
|
66
66
|
themes: approved.flatMap((bundle)=>bundle.themes ?? []),
|
|
67
|
+
templates: scene_engine.describeTemplateCatalog(approved, configuration.sceneVersion),
|
|
67
68
|
icons: IconAdapterRegistry.createIconAdapterRegistry(approved.map((bundle)=>bundle.iconLibrary?.adapter).filter((adapter)=>adapter !== undefined)),
|
|
68
69
|
assets: approvedAssets,
|
|
69
70
|
fonts: approvedAssets.filter(isFontAsset),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackageHostConfiguration.js","sources":["../../../packages/PackageHostConfiguration.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 { DialogTemplate, Layout, ScreenTemplate, Theme, UiProfile } from '@cratis/scene.model';\nimport { resolvePackageDependencies } from '@cratis/scene.engine';\nimport { IconAdapterRegistry, createIconAdapterRegistry } from '../icons/IconAdapterRegistry';\nimport { ScenePackageBundle, mergePackageRegistries, validatePackageBundle } from './ScenePackageBundle';\n\nexport interface PackageHostPolicy {\n allowExecutableImports: boolean;\n allowNetworkAssets: boolean;\n\n /** Whether this host is resolving optional design-time bundles in addition to runtime contributions. */\n loadDesignTime?: boolean;\n}\n\nexport interface PackageHostConfiguration {\n bundles: ScenePackageBundle[];\n profile: UiProfile;\n policy: PackageHostPolicy;\n}\n\nexport interface ResolvedPackageHost {\n bundles: ScenePackageBundle[];\n components: ReturnType<typeof mergePackageRegistries>;\n layouts: Layout[];\n screenTemplates: ScreenTemplate[];\n dialogTemplates: DialogTemplate[];\n themes: Theme[];\n icons: IconAdapterRegistry;\n assets: string[];\n fonts: string[];\n blocked: boolean;\n diagnostics: string[];\n}\n\n/**\n * Resolves the approved package set a standalone or embedded React host uses.\n */\nexport function resolvePackageHost(configuration: PackageHostConfiguration): ResolvedPackageHost {\n const diagnostics: string[] = [];\n const names = new Map<string, number>();\n for (const bundle of configuration.bundles) {\n names.set(bundle.manifest.name, (names.get(bundle.manifest.name) ?? 0) + 1);\n }\n\n for (const [name, count] of names) {\n if (count > 1) diagnostics.push(`Package '${name}' is approved more than once; duplicate bundles are ambiguous`);\n }\n\n const byName = new Map(configuration.bundles.map(bundle => [bundle.manifest.name, bundle]));\n const selection = resolvePackageDependencies(configuration.profile.packages, configuration.bundles.map(bundle => bundle.manifest));\n for (const missing of selection.missing) diagnostics.push(`Package '${missing.package}' depends on missing package '${missing.dependsOn}'`);\n for (const conflict of selection.versionConflicts) {\n diagnostics.push(`Package '${conflict.package}' requires '${conflict.dependsOn}' ${conflict.requiredRange} but approved version is ${conflict.actualVersion}`);\n }\n for (const cycle of selection.cycles) diagnostics.push(`Package dependency cycle: ${cycle.join(' -> ')}`);\n\n const bundles: ScenePackageBundle[] = [];\n const runtimeSingletons = new Map<string, string>();\n const assets: string[] = [];\n\n for (const packageName of selection.packages) {\n const bundle = byName.get(packageName);\n if (!bundle) {\n diagnostics.push(`UI profile asks for '${packageName}' but the host did not approve a bundle for it`);\n continue;\n }\n\n diagnostics.push(...validatePackageBundle(bundle).map(problem => `${packageName}: ${problem}`));\n if (configuration.policy.loadDesignTime === true && !configuration.policy.allowExecutableImports && bundle.designTime) {\n diagnostics.push(`Package '${packageName}' provides executable design-time contributions, but host policy forbids them`);\n }\n\n const packageAssets = bundle.manifest.assets ?? [];\n if (!configuration.policy.allowNetworkAssets && packageAssets.some(asset => /^https?:\\/\\//.test(asset))) {\n diagnostics.push(`Package '${packageName}' declares network assets, but host policy forbids them`);\n }\n assets.push(...packageAssets);\n\n for (const dependency of bundle.manifest.runtimeSingletons ?? []) {\n const owner = runtimeSingletons.get(dependency);\n if (owner && owner !== packageName) {\n diagnostics.push(`Runtime singleton '${dependency}' is provided by both '${owner}' and '${packageName}'`);\n }\n runtimeSingletons.set(dependency, packageName);\n }\n\n bundles.push(bundle);\n }\n\n const blocked = diagnostics.length > 0;\n const approved = blocked ? [] : bundles;\n const approvedAssets = blocked ? [] : assets;\n\n return {\n bundles: approved,\n components: mergePackageRegistries(approved),\n layouts: approved.flatMap(bundle => bundle.layouts ?? []),\n screenTemplates: approved.flatMap(bundle => bundle.screenTemplates ?? []),\n dialogTemplates: approved.flatMap(bundle => bundle.dialogTemplates ?? []),\n themes: approved.flatMap(bundle => bundle.themes ?? []),\n icons: createIconAdapterRegistry(approved.map(bundle => bundle.iconLibrary?.adapter).filter(adapter => adapter !== undefined)),\n assets: approvedAssets,\n fonts: approvedAssets.filter(isFontAsset),\n blocked,\n diagnostics,\n };\n}\n\nfunction isFontAsset(asset: string): boolean {\n return /\\.(woff2?|otf|ttf)(\\?|$)/.test(asset) || asset.includes('/fonts/');\n}\n"],"names":["resolvePackageHost","configuration","diagnostics","names","Map","bundle","bundles","set","manifest","name","get","count","push","byName","map","selection","resolvePackageDependencies","profile","packages","missing","package","dependsOn","conflict","versionConflicts","requiredRange","actualVersion","cycle","cycles","join","runtimeSingletons","assets","packageName","validatePackageBundle","problem","policy","loadDesignTime","allowExecutableImports","designTime","packageAssets","allowNetworkAssets","some","asset","test","dependency","owner","blocked","length","approved","approvedAssets","components","mergePackageRegistries","layouts","flatMap","screenTemplates","dialogTemplates","themes","icons","createIconAdapterRegistry","iconLibrary","adapter","filter","undefined","fonts","isFontAsset","includes"],"mappings":";;;;;;AAAA;AACA;AAmCA;;IAGO,SAASA,kBAAAA,CAAmBC,aAAuC,EAAA;AACtE,IAAA,MAAMC,cAAwB,EAAE;AAChC,IAAA,MAAMC,QAAQ,IAAIC,GAAAA,EAAAA;AAClB,IAAA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AA,EAAiBN,QAAAA,CAASK,OAAO,CAAC/C,CAAAA,SAAUA,MAAAA,CAAOgD,eAAe,IAAI,EAAE,CAAA;QACxEC,eAAAA,EAAiBP,QAAAA,CAASK,OAAO,CAAC/C,CAAAA,SAAUA,MAAAA,CAAOiD,eAAe,IAAI,EAAE,CAAA;QACxEC,MAAAA,EAAQR,QAAAA,CAASK,OAAO,CAAC/C,CAAAA,SAAUA,MAAAA,CAAOkD,MAAM,IAAI,EAAE,CAAA;AACtDC,QAAAA,KAAAA,EAAOC,6CAAAA,CAA0BV,QAAAA,CAASjC,GAAG,CAACT,CAAAA,MAAAA,GAAUA,MAAAA,CAAOqD,WAAW,EAAEC,OAAAA,CAAAA,CAASC,MAAM,CAACD,CAAAA,UAAWA,OAAAA,KAAYE,SAAAA,CAAAA,CAAAA;QACnH/B,MAAAA,EAAQkB,cAAAA;QACRc,KAAAA,EAAOd,cAAAA,CAAeY,MAAM,CAACG,WAAAA,CAAAA;AAC7BlB,QAAAA,OAAAA;AACA3C,QAAAA;AACJ,KAAA;AACJ;AAEA,SAAS6D,YAAYtB,KAAa,EAAA;AAC9B,IAAA,OAAO,2BAA2BC,IAAI,CAACD,KAAAA,CAAAA,IAAUA,KAAAA,CAAMuB,QAAQ,CAAC,SAAA,CAAA;AACpE;;"}
|
|
1
|
+
{"version":3,"file":"PackageHostConfiguration.js","sources":["../../../packages/PackageHostConfiguration.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 { DialogTemplate, Layout, ScreenTemplate, Theme, UiProfile } from '@cratis/scene.model';\nimport { TemplateCatalogEntry, describeTemplateCatalog, resolvePackageDependencies } from '@cratis/scene.engine';\nimport { IconAdapterRegistry, createIconAdapterRegistry } from '../icons/IconAdapterRegistry';\nimport { ScenePackageBundle, mergePackageRegistries, validatePackageBundle } from './ScenePackageBundle';\n\nexport interface PackageHostPolicy {\n allowExecutableImports: boolean;\n allowNetworkAssets: boolean;\n\n /** Whether this host is resolving optional design-time bundles in addition to runtime contributions. */\n loadDesignTime?: boolean;\n}\n\nexport interface PackageHostConfiguration {\n bundles: ScenePackageBundle[];\n profile: UiProfile;\n policy: PackageHostPolicy;\n\n /** The Scene version the host runs, checked against each template's compatibility range when given. */\n sceneVersion?: string;\n}\n\nexport interface ResolvedPackageHost {\n bundles: ScenePackageBundle[];\n components: ReturnType<typeof mergePackageRegistries>;\n layouts: Layout[];\n screenTemplates: ScreenTemplate[];\n dialogTemplates: DialogTemplate[];\n themes: Theme[];\n\n /**\n * Every template the approved packages provide, with compatibility, attribution and license metadata and\n * whether it can be used with this package set. Template browsers read this rather than the raw lists.\n */\n templates: TemplateCatalogEntry[];\n icons: IconAdapterRegistry;\n assets: string[];\n fonts: string[];\n blocked: boolean;\n diagnostics: string[];\n}\n\n/**\n * Resolves the approved package set a standalone or embedded React host uses.\n */\nexport function resolvePackageHost(configuration: PackageHostConfiguration): ResolvedPackageHost {\n const diagnostics: string[] = [];\n const names = new Map<string, number>();\n for (const bundle of configuration.bundles) {\n names.set(bundle.manifest.name, (names.get(bundle.manifest.name) ?? 0) + 1);\n }\n\n for (const [name, count] of names) {\n if (count > 1) diagnostics.push(`Package '${name}' is approved more than once; duplicate bundles are ambiguous`);\n }\n\n const byName = new Map(configuration.bundles.map(bundle => [bundle.manifest.name, bundle]));\n const selection = resolvePackageDependencies(configuration.profile.packages, configuration.bundles.map(bundle => bundle.manifest));\n for (const missing of selection.missing) diagnostics.push(`Package '${missing.package}' depends on missing package '${missing.dependsOn}'`);\n for (const conflict of selection.versionConflicts) {\n diagnostics.push(`Package '${conflict.package}' requires '${conflict.dependsOn}' ${conflict.requiredRange} but approved version is ${conflict.actualVersion}`);\n }\n for (const cycle of selection.cycles) diagnostics.push(`Package dependency cycle: ${cycle.join(' -> ')}`);\n\n const bundles: ScenePackageBundle[] = [];\n const runtimeSingletons = new Map<string, string>();\n const assets: string[] = [];\n\n for (const packageName of selection.packages) {\n const bundle = byName.get(packageName);\n if (!bundle) {\n diagnostics.push(`UI profile asks for '${packageName}' but the host did not approve a bundle for it`);\n continue;\n }\n\n diagnostics.push(...validatePackageBundle(bundle).map(problem => `${packageName}: ${problem}`));\n if (configuration.policy.loadDesignTime === true && !configuration.policy.allowExecutableImports && bundle.designTime) {\n diagnostics.push(`Package '${packageName}' provides executable design-time contributions, but host policy forbids them`);\n }\n\n const packageAssets = bundle.manifest.assets ?? [];\n if (!configuration.policy.allowNetworkAssets && packageAssets.some(asset => /^https?:\\/\\//.test(asset))) {\n diagnostics.push(`Package '${packageName}' declares network assets, but host policy forbids them`);\n }\n assets.push(...packageAssets);\n\n for (const dependency of bundle.manifest.runtimeSingletons ?? []) {\n const owner = runtimeSingletons.get(dependency);\n if (owner && owner !== packageName) {\n diagnostics.push(`Runtime singleton '${dependency}' is provided by both '${owner}' and '${packageName}'`);\n }\n runtimeSingletons.set(dependency, packageName);\n }\n\n bundles.push(bundle);\n }\n\n const blocked = diagnostics.length > 0;\n const approved = blocked ? [] : bundles;\n const approvedAssets = blocked ? [] : assets;\n\n return {\n bundles: approved,\n components: mergePackageRegistries(approved),\n layouts: approved.flatMap(bundle => bundle.layouts ?? []),\n screenTemplates: approved.flatMap(bundle => bundle.screenTemplates ?? []),\n dialogTemplates: approved.flatMap(bundle => bundle.dialogTemplates ?? []),\n themes: approved.flatMap(bundle => bundle.themes ?? []),\n templates: describeTemplateCatalog(approved, configuration.sceneVersion),\n icons: createIconAdapterRegistry(approved.map(bundle => bundle.iconLibrary?.adapter).filter(adapter => adapter !== undefined)),\n assets: approvedAssets,\n fonts: approvedAssets.filter(isFontAsset),\n blocked,\n diagnostics,\n };\n}\n\nfunction isFontAsset(asset: string): boolean {\n return /\\.(woff2?|otf|ttf)(\\?|$)/.test(asset) || asset.includes('/fonts/');\n}\n"],"names":["resolvePackageHost","configuration","diagnostics","names","Map","bundle","bundles","set","manifest","name","get","count","push","byName","map","selection","resolvePackageDependencies","profile","packages","missing","package","dependsOn","conflict","versionConflicts","requiredRange","actualVersion","cycle","cycles","join","runtimeSingletons","assets","packageName","validatePackageBundle","problem","policy","loadDesignTime","allowExecutableImports","designTime","packageAssets","allowNetworkAssets","some","asset","test","dependency","owner","blocked","length","approved","approvedAssets","components","mergePackageRegistries","layouts","flatMap","screenTemplates","dialogTemplates","themes","templates","describeTemplateCatalog","sceneVersion","icons","createIconAdapterRegistry","iconLibrary","adapter","filter","undefined","fonts","isFontAsset","includes"],"mappings":";;;;;;AAAA;AACA;AA4CA;;IAGO,SAASA,kBAAAA,CAAmBC,aAAuC,EAAA;AACtE,IAAA,MAAMC,cAAwB,EAAE;AAChC,IAAA,MAAMC,QAAQ,IAAIC,GAAAA,EAAAA;AAClB,IAAA,KAAK,MAAMC,MAAAA,IAAUJ,aAAAA,CAAcK,OAAO,CAAE;AACxCH,QAAAA,KAAAA,CAAMI,GAAG,CAACF,MAAAA,CAAOG,QAAQ,CAACC,IAAI,EAAE,CAACN,KAAAA,CAAMO,GAAG,CAACL,MAAAA,CAAOG,QAAQ,CAACC,IAAI,CAAA,IAAK,CAAA,IAAK,CAAA,CAAA;AAC7E,IAAA;AAEA,IAAA,KAAK,MAAM,CAACA,IAAAA,EAAME,KAAAA,CAAM,IAAIR,KAAAA,CAAO;QAC/B,IAAIQ,KAAAA,GAAQ,CAAA,EAAGT,WAAAA,CAAYU,IAAI,CAAC,CAAC,SAAS,EAAEH,IAAAA,CAAK,6DAA6D,CAAC,CAAA;AACnH,IAAA;IAEA,MAAMI,MAAAA,GAAS,IAAIT,GAAAA,CAAIH,aAAAA,CAAcK,OAAO,CAACQ,GAAG,CAACT,CAAAA,MAAAA,GAAU;YAACA,MAAAA,CAAOG,QAAQ,CAACC,IAAI;AAAEJ,YAAAA;AAAO,SAAA,CAAA,CAAA;AACzF,IAAA,MAAMU,SAAAA,GAAYC,uCAAAA,CAA2Bf,aAAAA,CAAcgB,OAAO,CAACC,QAAQ,EAAEjB,aAAAA,CAAcK,OAAO,CAACQ,GA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C9B,IAAA,OAAO,2BAA2BC,IAAI,CAACD,KAAAA,CAAAA,IAAUA,KAAAA,CAAM0B,QAAQ,CAAC,SAAA,CAAA;AACpE;;"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var DesignTimeContractVersion = require('./DesignTimeContractVersion.js');
|
|
4
|
+
var DesignTimeExtensionPoint = require('./DesignTimeExtensionPoint.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
|
+
* Loads the design-time contributions of approved bundles, checking each against the contract version this
|
|
10
|
+
* host implements and against what its manifest declares. Nothing is partially trusted: a package with an
|
|
11
|
+
* incompatible or unreadable contract version, or contributions its manifest does not declare at all,
|
|
12
|
+
* contributes nothing; a single undeclared contribution is left out; a declared one the bundle lacks is
|
|
13
|
+
* reported and falls back.
|
|
14
|
+
*/ function loadDesignTimeContributions(bundles, loadDesignTime) {
|
|
15
|
+
const packages = new Map();
|
|
16
|
+
const diagnostics = [];
|
|
17
|
+
const hostMajor = DesignTimeContractVersion.DesignTimeContractVersion.split('.')[0];
|
|
18
|
+
for (const { manifest, designTime } of bundles){
|
|
19
|
+
const declared = manifest.designTime;
|
|
20
|
+
const unavailable = (reason)=>{
|
|
21
|
+
diagnostics.push(reason);
|
|
22
|
+
packages.set(manifest.name, {
|
|
23
|
+
contributions: {},
|
|
24
|
+
unavailableReason: reason
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
if (!declared && !designTime) continue;
|
|
28
|
+
if (!loadDesignTime) {
|
|
29
|
+
packages.set(manifest.name, {
|
|
30
|
+
contributions: {},
|
|
31
|
+
unavailableReason: `This host does not load design-time contributions, so package '${manifest.name}' uses generic editors`
|
|
32
|
+
});
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (!declared) {
|
|
36
|
+
unavailable(`Package '${manifest.name}' provides design-time contributions its manifest does not declare; none are loaded`);
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const version = declared.contractVersion ?? '1.0';
|
|
40
|
+
if (!/^\d+\.\d+$/.test(version)) {
|
|
41
|
+
unavailable(`Package '${manifest.name}' declares design-time contract version '${version}', which is not a major.minor version; none of its contributions are loaded`);
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (version.split('.')[0] !== hostMajor) {
|
|
45
|
+
unavailable(`Package '${manifest.name}' targets design-time contract ${version}, but this host implements ${DesignTimeContractVersion.DesignTimeContractVersion}; none of its contributions are loaded`);
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
packages.set(manifest.name, {
|
|
49
|
+
contributions: declaredContributions(manifest.name, declared, designTime, diagnostics)
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
packages,
|
|
54
|
+
diagnostics
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function declaredContributions(packageName, declared, provided, diagnostics) {
|
|
58
|
+
const contributions = {};
|
|
59
|
+
for (const point of Object.values(DesignTimeExtensionPoint.DesignTimeExtensionPoint)){
|
|
60
|
+
const label = DesignTimeExtensionPoint.designTimeExtensionPointLabels[point];
|
|
61
|
+
const names = new Set(declared[point] ?? []);
|
|
62
|
+
const available = provided?.[point] ?? {};
|
|
63
|
+
const loaded = {};
|
|
64
|
+
for (const name of names){
|
|
65
|
+
if (name in available) {
|
|
66
|
+
loaded[name] = available[name];
|
|
67
|
+
} else {
|
|
68
|
+
diagnostics.push(`Package '${packageName}' declares the ${label} '${name}', but its design-time bundle does not provide it`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
for (const name of Object.keys(available).filter((name)=>!names.has(name))){
|
|
72
|
+
diagnostics.push(`Package '${packageName}' provides the ${label} '${name}', which its manifest does not declare; it is not loaded`);
|
|
73
|
+
}
|
|
74
|
+
contributions[point] = loaded;
|
|
75
|
+
}
|
|
76
|
+
return contributions;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
exports.loadDesignTimeContributions = loadDesignTimeContributions;
|
|
80
|
+
//# sourceMappingURL=loadDesignTimeContributions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadDesignTimeContributions.js","sources":["../../../packages/loadDesignTimeContributions.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 { DesignTimeBundle } from './DesignTimeBundle';\nimport { DesignTimeContractVersion } from './DesignTimeContractVersion';\nimport { DesignTimeExtensionPoint, designTimeExtensionPointLabels } from './DesignTimeExtensionPoint';\nimport { ScenePackageBundle } from './ScenePackageBundle';\n\n/**\n * A package's design-time contributions as a host loaded them: only what the manifest declares, or nothing\n * with the reason when the package cannot be loaded at all.\n */\nexport interface LoadedDesignTimeContributions {\n contributions: Partial<Record<DesignTimeExtensionPoint, Record<string, unknown>>>;\n unavailableReason?: string;\n}\n\n/**\n * Loads the design-time contributions of approved bundles, checking each against the contract version this\n * host implements and against what its manifest declares. Nothing is partially trusted: a package with an\n * incompatible or unreadable contract version, or contributions its manifest does not declare at all,\n * contributes nothing; a single undeclared contribution is left out; a declared one the bundle lacks is\n * reported and falls back.\n */\nexport function loadDesignTimeContributions(\n bundles: ScenePackageBundle[],\n loadDesignTime: boolean,\n): { packages: Map<string, LoadedDesignTimeContributions>; diagnostics: string[] } {\n const packages = new Map<string, LoadedDesignTimeContributions>();\n const diagnostics: string[] = [];\n const hostMajor = DesignTimeContractVersion.split('.')[0];\n\n for (const { manifest, designTime } of bundles) {\n const declared = manifest.designTime;\n const unavailable = (reason: string) => {\n diagnostics.push(reason);\n packages.set(manifest.name, { contributions: {}, unavailableReason: reason });\n };\n\n if (!declared && !designTime) continue;\n if (!loadDesignTime) {\n packages.set(manifest.name, { contributions: {}, unavailableReason: `This host does not load design-time contributions, so package '${manifest.name}' uses generic editors` });\n continue;\n }\n\n if (!declared) {\n unavailable(`Package '${manifest.name}' provides design-time contributions its manifest does not declare; none are loaded`);\n continue;\n }\n\n const version = declared.contractVersion ?? '1.0';\n if (!/^\\d+\\.\\d+$/.test(version)) {\n unavailable(`Package '${manifest.name}' declares design-time contract version '${version}', which is not a major.minor version; none of its contributions are loaded`);\n continue;\n }\n\n if (version.split('.')[0] !== hostMajor) {\n unavailable(`Package '${manifest.name}' targets design-time contract ${version}, but this host implements ${DesignTimeContractVersion}; none of its contributions are loaded`);\n continue;\n }\n\n packages.set(manifest.name, { contributions: declaredContributions(manifest.name, declared, designTime, diagnostics) });\n }\n\n return { packages, diagnostics };\n}\n\nfunction declaredContributions(\n packageName: string,\n declared: Record<DesignTimeExtensionPoint, string[]>,\n provided: DesignTimeBundle | undefined,\n diagnostics: string[],\n): LoadedDesignTimeContributions['contributions'] {\n const contributions: LoadedDesignTimeContributions['contributions'] = {};\n\n for (const point of Object.values(DesignTimeExtensionPoint)) {\n const label = designTimeExtensionPointLabels[point];\n const names = new Set(declared[point] ?? []);\n const available = (provided?.[point] ?? {}) as Record<string, unknown>;\n const loaded: Record<string, unknown> = {};\n\n for (const name of names) {\n if (name in available) {\n loaded[name] = available[name];\n } else {\n diagnostics.push(`Package '${packageName}' declares the ${label} '${name}', but its design-time bundle does not provide it`);\n }\n }\n\n for (const name of Object.keys(available).filter(name => !names.has(name))) {\n diagnostics.push(`Package '${packageName}' provides the ${label} '${name}', which its manifest does not declare; it is not loaded`);\n }\n\n contributions[point] = loaded;\n }\n\n return contributions;\n}\n"],"names":["loadDesignTimeContributions","bundles","loadDesignTime","packages","Map","diagnostics","hostMajor","DesignTimeContractVersion","split","manifest","designTime","declared","unavailable","reason","push","set","name","contributions","unavailableReason","version","contractVersion","test","declaredContributions","packageName","provided","point","Object","values","DesignTimeExtensionPoint","label","designTimeExtensionPointLabels","names","Set","available","loaded","keys","filter","has"],"mappings":";;;;;AAAA;AACA;AAgBA;;;;;;AAMC,IACM,SAASA,2BAAAA,CAC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