@cratis/scene.react 4.14.0 → 4.16.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/core/ScreenplayCoreComponents.tsx +24 -3
- package/dist/cjs/SceneElementView.js +1 -0
- package/dist/cjs/SceneElementView.js.map +1 -1
- package/dist/cjs/core/ScreenplayCoreComponents.js +25 -5
- package/dist/cjs/core/ScreenplayCoreComponents.js.map +1 -1
- package/dist/cjs/index.js +11 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/navigation/createHashSceneHistory.js +43 -0
- package/dist/cjs/navigation/createHashSceneHistory.js.map +1 -0
- package/dist/cjs/packages/PackageHostConfiguration.js +18 -2
- package/dist/cjs/packages/PackageHostConfiguration.js.map +1 -1
- package/dist/cjs/packages/isNetworkAsset.js +18 -0
- package/dist/cjs/packages/isNetworkAsset.js.map +1 -0
- package/dist/cjs/renderer/RenderBindingScopeContext.js +15 -5
- package/dist/cjs/renderer/RenderBindingScopeContext.js.map +1 -1
- package/dist/cjs/renderer/useBoundQuery.js +50 -0
- package/dist/cjs/renderer/useBoundQuery.js.map +1 -0
- package/dist/cjs/renderer/useValueOutput.js +31 -0
- package/dist/cjs/renderer/useValueOutput.js.map +1 -0
- package/dist/cjs/renderer/valueOutputProperty.js +28 -0
- package/dist/cjs/renderer/valueOutputProperty.js.map +1 -0
- package/dist/esm/SceneElementView.js +1 -0
- package/dist/esm/SceneElementView.js.map +1 -1
- package/dist/esm/core/ScreenplayCoreComponents.d.ts.map +1 -1
- package/dist/esm/core/ScreenplayCoreComponents.js +25 -5
- package/dist/esm/core/ScreenplayCoreComponents.js.map +1 -1
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/navigation/createHashSceneHistory.d.ts +4 -0
- package/dist/esm/navigation/createHashSceneHistory.d.ts.map +1 -0
- package/dist/esm/navigation/createHashSceneHistory.js +41 -0
- package/dist/esm/navigation/createHashSceneHistory.js.map +1 -0
- package/dist/esm/navigation/index.d.ts +1 -0
- package/dist/esm/navigation/index.d.ts.map +1 -1
- package/dist/esm/navigation/index.js +1 -0
- package/dist/esm/navigation/index.js.map +1 -1
- package/dist/esm/packages/PackageHostConfiguration.d.ts +2 -0
- package/dist/esm/packages/PackageHostConfiguration.d.ts.map +1 -1
- package/dist/esm/packages/PackageHostConfiguration.js +19 -3
- package/dist/esm/packages/PackageHostConfiguration.js.map +1 -1
- package/dist/esm/packages/index.d.ts +1 -0
- package/dist/esm/packages/index.d.ts.map +1 -1
- package/dist/esm/packages/index.js +1 -0
- package/dist/esm/packages/index.js.map +1 -1
- package/dist/esm/packages/isNetworkAsset.d.ts +2 -0
- package/dist/esm/packages/isNetworkAsset.d.ts.map +1 -0
- package/dist/esm/packages/isNetworkAsset.js +16 -0
- package/dist/esm/packages/isNetworkAsset.js.map +1 -0
- package/dist/esm/renderer/RenderBindingScopeContext.d.ts.map +1 -1
- package/dist/esm/renderer/RenderBindingScopeContext.js +17 -7
- package/dist/esm/renderer/RenderBindingScopeContext.js.map +1 -1
- package/dist/esm/renderer/index.d.ts +3 -0
- package/dist/esm/renderer/index.d.ts.map +1 -1
- package/dist/esm/renderer/index.js +3 -0
- package/dist/esm/renderer/index.js.map +1 -1
- package/dist/esm/renderer/useBoundQuery.d.ts +3 -0
- package/dist/esm/renderer/useBoundQuery.d.ts.map +1 -0
- package/dist/esm/renderer/useBoundQuery.js +48 -0
- package/dist/esm/renderer/useBoundQuery.js.map +1 -0
- package/dist/esm/renderer/useValueOutput.d.ts +4 -0
- package/dist/esm/renderer/useValueOutput.d.ts.map +1 -0
- package/dist/esm/renderer/useValueOutput.js +28 -0
- package/dist/esm/renderer/useValueOutput.js.map +1 -0
- package/dist/esm/renderer/valueOutputProperty.d.ts +3 -0
- package/dist/esm/renderer/valueOutputProperty.d.ts.map +1 -0
- package/dist/esm/renderer/valueOutputProperty.js +26 -0
- package/dist/esm/renderer/valueOutputProperty.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/navigation/createHashSceneHistory.ts +42 -0
- package/navigation/index.ts +1 -0
- package/package.json +5 -5
- package/packages/PackageHostConfiguration.ts +26 -3
- package/packages/index.ts +1 -0
- package/packages/isNetworkAsset.ts +15 -0
- package/renderer/RenderBindingScopeContext.tsx +12 -8
- package/renderer/index.ts +3 -0
- package/renderer/useBoundQuery.ts +50 -0
- package/renderer/useValueOutput.ts +28 -0
- package/renderer/valueOutputProperty.ts +25 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
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
|
+
/** The output property an input widget publishes its current value under. */ const valueOutputName = 'value';
|
|
8
|
+
/**
|
|
9
|
+
* Publishes an input widget's current value as its `value` output: once when it mounts, with the initial
|
|
10
|
+
* value, and again on every change. Other elements bind to it with a `componentProperty` binding, and a
|
|
11
|
+
* command action maps it as `component.<id>.value`. The renderer clears the output when the widget unmounts.
|
|
12
|
+
*
|
|
13
|
+
* Values are published as JSON-compatible data so both engines read the same thing: a `Date` is published
|
|
14
|
+
* as its ISO 8601 string, and `undefined` as `null`.
|
|
15
|
+
*/ function useValueOutput(bindingOutputs, value) {
|
|
16
|
+
const published = value instanceof Date ? value.toISOString() : value ?? null;
|
|
17
|
+
const key = JSON.stringify(published);
|
|
18
|
+
const latest = react.useRef(published);
|
|
19
|
+
latest.current = published;
|
|
20
|
+
// Published by value through `key`: a new array or object with the same content is not a change.
|
|
21
|
+
react.useEffect(()=>{
|
|
22
|
+
bindingOutputs?.setOutput(valueOutputName, latest.current);
|
|
23
|
+
}, [
|
|
24
|
+
bindingOutputs,
|
|
25
|
+
key
|
|
26
|
+
]);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
exports.useValueOutput = useValueOutput;
|
|
30
|
+
exports.valueOutputName = valueOutputName;
|
|
31
|
+
//# sourceMappingURL=useValueOutput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useValueOutput.js","sources":["../../../renderer/useValueOutput.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useEffect, useRef } from 'react';\nimport { ComponentBindingOutputs } from './BindingOutputContext';\n\n/** The output property an input widget publishes its current value under. */\nexport const valueOutputName = 'value';\n\n/**\n * Publishes an input widget's current value as its `value` output: once when it mounts, with the initial\n * value, and again on every change. Other elements bind to it with a `componentProperty` binding, and a\n * command action maps it as `component.<id>.value`. The renderer clears the output when the widget unmounts.\n *\n * Values are published as JSON-compatible data so both engines read the same thing: a `Date` is published\n * as its ISO 8601 string, and `undefined` as `null`.\n */\nexport function useValueOutput(bindingOutputs: ComponentBindingOutputs | undefined, value: unknown): void {\n const published = value instanceof Date ? value.toISOString() : value ?? null;\n const key = JSON.stringify(published);\n const latest = useRef(published);\n latest.current = published;\n\n // Published by value through `key`: a new array or object with the same content is not a change.\n useEffect(() => {\n bindingOutputs?.setOutput(valueOutputName, latest.current);\n }, [bindingOutputs, key]);\n}\n"],"names":["valueOutputName","useValueOutput","bindingOutputs","value","published","Date","toISOString","key","JSON","stringify","latest","useRef","current","useEffect","setOutput"],"mappings":";;;;AAAA;AACA;AAKA,8EACO,MAAMA,eAAAA,GAAkB;AAE/B;;;;;;;AAOC,IACM,SAASC,cAAAA,CAAeC,cAAmD,EAAEC,KAAc,EAAA;AAC9F,IAAA,MAAMC,YAAYD,KAAAA,YAAiBE,IAAAA,GAAOF,KAAAA,CAAMG,WAAW,KAAKH,KAAAA,IAAS,IAAA;IACzE,MAAMI,GAAAA,GAAMC,IAAAA,CAAKC,SAAS,CAACL,SAAAA,CAAAA;AAC3B,IAAA,MAAMM,SAASC,YAAAA,CAAOP,SAAAA,CAAAA;AACtBM,IAAAA,MAAAA,CAAOE,OAAO,GAAGR,SAAAA;;IAGjBS,eAAAA,CAAU,IAAA;QACNX,cAAAA,EAAgBY,SAAAA,CAAUd,eAAAA,EAAiBU,MAAAA,CAAOE,OAAO,CAAA;IAC7D,CAAA,EAAG;AAACV,QAAAA,cAAAA;AAAgBK,QAAAA;AAAI,KAAA,CAAA;AAC5B;;;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var scene_model = require('@cratis/scene.model');
|
|
4
|
+
var useValueOutput = require('./useValueOutput.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
|
+
* The descriptor entry an input widget declares for the value it publishes with `useValueOutput`, so a
|
|
10
|
+
* designer can offer it as a binding source - for a detail component, a query argument or a command input.
|
|
11
|
+
*
|
|
12
|
+
* @param valueType The type of value the widget publishes.
|
|
13
|
+
* @param description What the value is, when the default sentence does not say enough.
|
|
14
|
+
*/ function valueOutputProperty(valueType, description = 'What the user has entered, published as the input changes.') {
|
|
15
|
+
return {
|
|
16
|
+
path: useValueOutput.valueOutputName,
|
|
17
|
+
label: 'Value',
|
|
18
|
+
group: 'Outputs',
|
|
19
|
+
valueType,
|
|
20
|
+
readOnly: true,
|
|
21
|
+
output: true,
|
|
22
|
+
bindingMode: scene_model.BindingMode.OneWay,
|
|
23
|
+
description
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports.valueOutputProperty = valueOutputProperty;
|
|
28
|
+
//# sourceMappingURL=valueOutputProperty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"valueOutputProperty.js","sources":["../../../renderer/valueOutputProperty.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { BindingMode, PropertyDescriptor, PropertyValueType } from '@cratis/scene.model';\nimport { valueOutputName } from './useValueOutput';\n\n/**\n * The descriptor entry an input widget declares for the value it publishes with `useValueOutput`, so a\n * designer can offer it as a binding source - for a detail component, a query argument or a command input.\n *\n * @param valueType The type of value the widget publishes.\n * @param description What the value is, when the default sentence does not say enough.\n */\nexport function valueOutputProperty(valueType: PropertyValueType, description = 'What the user has entered, published as the input changes.'): PropertyDescriptor {\n return {\n path: valueOutputName,\n label: 'Value',\n group: 'Outputs',\n valueType,\n readOnly: true,\n output: true,\n bindingMode: BindingMode.OneWay,\n description,\n };\n}\n"],"names":["valueOutputProperty","valueType","description","path","valueOutputName","label","group","readOnly","output","bindingMode","BindingMode","OneWay"],"mappings":";;;;;AAAA;AACA;AAKA;;;;;;AAMC,IACM,SAASA,mBAAAA,CAAoBC,SAA4B,EAAEC,cAAc,4DAA4D,EAAA;IACxI,OAAO;QACHC,IAAAA,EAAMC,8BAAAA;QACNC,KAAAA,EAAO,OAAA;QACPC,KAAAA,EAAO,SAAA;AACPL,QAAAA,SAAAA;QACAM,QAAAA,EAAU,IAAA;QACVC,MAAAA,EAAQ,IAAA;AACRC,QAAAA,WAAAA,EAAaC,wBAAYC,MAAM;AAC/BT,QAAAA;AACJ,KAAA;AACJ;;"}
|
|
@@ -2,6 +2,7 @@ import { jsx, Fragment } from 'react/jsx-runtime';
|
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { applyEffectiveConfiguration, renderElement } from '@cratis/scene.engine';
|
|
4
4
|
import { RenderBindingScopeProvider, useRenderBindingResolver } from './renderer/RenderBindingScopeContext.js';
|
|
5
|
+
import '@cratis/scene.model';
|
|
5
6
|
import { createReactRenderer } from './renderer/createReactRenderer.js';
|
|
6
7
|
import './interactions/useInteractions.js';
|
|
7
8
|
import './interactions/NotificationHost.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SceneElementView.js","sources":["../../SceneElementView.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 } from 'react';\nimport { applyEffectiveConfiguration, renderElement, BindingResolver } from '@cratis/scene.engine';\nimport { EffectiveConfiguration, SceneElement } from '@cratis/scene.model';\nimport { ComponentRegistry, RenderBindingScopeProvider, createReactRenderer, useRenderBindingResolver } from './renderer';\n\nexport interface SceneElementViewProps {\n element: SceneElement;\n registry: ComponentRegistry;\n resolveBinding?: BindingResolver;\n dataContext?: unknown;\n queryResults?: Record<string, unknown>;\n componentOutputs?: Record<string, Record<string, unknown>>;\n\n /**\n * The resolved configuration of the template chain the element sits in, from `resolveEffectiveConfiguration`.\n * When given, each configurable component renders with its resolved properties - what a screen's own values add\n * to an inherited template. It is the same data the editor shows, and the same code path whether the screen is\n * being edited or played: there is no design-time mode.\n */\n configuration?: EffectiveConfiguration;\n\n /** Called when rendered components publish or clear output properties for typed bindings. */\n onComponentOutputsChanged?: (outputs: Record<string, Record<string, unknown>>) => void;\n}\n\n/**\n * Renders a Scene element tree with the real `Scene.React` renderer - the WYSIWYG building block Studio's\n * preview surface and Stage's shipped web bundle both consume unmodified.\n */\nexport function SceneElementView({\n element,\n registry,\n resolveBinding,\n configuration,\n onComponentOutputsChanged,\n dataContext,\n queryResults,\n componentOutputs,\n}: SceneElementViewProps) {\n const configured = useMemo(() => configuration ? applyEffectiveConfiguration(element, configuration) : element, [element, configuration]);\n return (\n <RenderBindingScopeProvider\n dataContext={dataContext}\n queryResults={queryResults}\n componentOutputs={componentOutputs}\n resolveBinding={resolveBinding}\n onComponentOutputsChanged={onComponentOutputsChanged}>\n <RenderedElement element={configured} registry={registry} />\n </RenderBindingScopeProvider>\n );\n}\n\nfunction RenderedElement({ element, registry }: { element: SceneElement; registry: ComponentRegistry }) {\n const renderer = useMemo(() => createReactRenderer(registry), [registry]);\n const resolveBinding = useRenderBindingResolver();\n return <>{renderElement(element, renderer, resolveBinding)}</>;\n}\n"],"names":["SceneElementView","element","registry","resolveBinding","configuration","onComponentOutputsChanged","dataContext","queryResults","componentOutputs","configured","useMemo","applyEffectiveConfiguration","_jsx","RenderBindingScopeProvider","RenderedElement","renderer","createReactRenderer","useRenderBindingResolver","_Fragment","renderElement"],"mappings":"
|
|
1
|
+
{"version":3,"file":"SceneElementView.js","sources":["../../SceneElementView.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 } from 'react';\nimport { applyEffectiveConfiguration, renderElement, BindingResolver } from '@cratis/scene.engine';\nimport { EffectiveConfiguration, SceneElement } from '@cratis/scene.model';\nimport { ComponentRegistry, RenderBindingScopeProvider, createReactRenderer, useRenderBindingResolver } from './renderer';\n\nexport interface SceneElementViewProps {\n element: SceneElement;\n registry: ComponentRegistry;\n resolveBinding?: BindingResolver;\n dataContext?: unknown;\n queryResults?: Record<string, unknown>;\n componentOutputs?: Record<string, Record<string, unknown>>;\n\n /**\n * The resolved configuration of the template chain the element sits in, from `resolveEffectiveConfiguration`.\n * When given, each configurable component renders with its resolved properties - what a screen's own values add\n * to an inherited template. It is the same data the editor shows, and the same code path whether the screen is\n * being edited or played: there is no design-time mode.\n */\n configuration?: EffectiveConfiguration;\n\n /** Called when rendered components publish or clear output properties for typed bindings. */\n onComponentOutputsChanged?: (outputs: Record<string, Record<string, unknown>>) => void;\n}\n\n/**\n * Renders a Scene element tree with the real `Scene.React` renderer - the WYSIWYG building block Studio's\n * preview surface and Stage's shipped web bundle both consume unmodified.\n */\nexport function SceneElementView({\n element,\n registry,\n resolveBinding,\n configuration,\n onComponentOutputsChanged,\n dataContext,\n queryResults,\n componentOutputs,\n}: SceneElementViewProps) {\n const configured = useMemo(() => configuration ? applyEffectiveConfiguration(element, configuration) : element, [element, configuration]);\n return (\n <RenderBindingScopeProvider\n dataContext={dataContext}\n queryResults={queryResults}\n componentOutputs={componentOutputs}\n resolveBinding={resolveBinding}\n onComponentOutputsChanged={onComponentOutputsChanged}>\n <RenderedElement element={configured} registry={registry} />\n </RenderBindingScopeProvider>\n );\n}\n\nfunction RenderedElement({ element, registry }: { element: SceneElement; registry: ComponentRegistry }) {\n const renderer = useMemo(() => createReactRenderer(registry), [registry]);\n const resolveBinding = useRenderBindingResolver();\n return <>{renderElement(element, renderer, resolveBinding)}</>;\n}\n"],"names":["SceneElementView","element","registry","resolveBinding","configuration","onComponentOutputsChanged","dataContext","queryResults","componentOutputs","configured","useMemo","applyEffectiveConfiguration","_jsx","RenderBindingScopeProvider","RenderedElement","renderer","createReactRenderer","useRenderBindingResolver","_Fragment","renderElement"],"mappings":";;;;;;;;;AA4BA;;;AAGC,IACM,SAASA,gBAAAA,CAAiB,EAC7BC,OAAO,EACPC,QAAQ,EACRC,cAAc,EACdC,aAAa,EACbC,yBAAyB,EACzBC,WAAW,EACXC,YAAY,EACZC,gBAAgB,EACI,EAAA;AACpB,IAAA,MAAMC,aAAaC,OAAAA,CAAQ,IAAMN,gBAAgBO,2BAAAA,CAA4BV,OAAAA,EAASG,iBAAiBH,OAAAA,EAAS;AAACA,QAAAA,OAAAA;AAASG,QAAAA;AAAc,KAAA,CAAA;AACxI,IAAA,qBACIQ,GAAA,CAACC,0BAAAA,EAAAA;QACGP,WAAAA,EAAaA,WAAAA;QACbC,YAAAA,EAAcA,YAAAA;QACdC,gBAAAA,EAAkBA,gBAAAA;QAClBL,cAAAA,EAAgBA,cAAAA;QAChBE,yBAAAA,EAA2BA,yBAAAA;AAC3B,QAAA,QAAA,gBAAAO,GAAA,CAACE,eAAAA,EAAAA;YAAgBb,OAAAA,EAASQ,UAAAA;YAAYP,QAAAA,EAAUA;;;AAG5D;AAEA,SAASY,eAAAA,CAAgB,EAAEb,OAAO,EAAEC,QAAQ,EAA0D,EAAA;AAClG,IAAA,MAAMa,QAAAA,GAAWL,OAAAA,CAAQ,IAAMM,mBAAAA,CAAoBd,QAAAA,CAAAA,EAAW;AAACA,QAAAA;AAAS,KAAA,CAAA;AACxE,IAAA,MAAMC,cAAAA,GAAiBc,wBAAAA,EAAAA;IACvB,qBAAOL,GAAA,CAAAM,QAAA,EAAA;AAAGC,QAAAA,QAAAA,EAAAA,aAAAA,CAAclB,SAASc,QAAAA,EAAUZ,cAAAA;;AAC/C;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScreenplayCoreComponents.d.ts","sourceRoot":"","sources":["../../../core/ScreenplayCoreComponents.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScreenplayCoreComponents.d.ts","sourceRoot":"","sources":["../../../core/ScreenplayCoreComponents.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAyB,MAAM,aAAa,CAAC;AAO9E,wBAAgB,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,wBAAwB,+BAE7D;AAgBD,wBAAgB,UAAU,CAAC,EAAE,OAAO,EAAE,EAAE,wBAAwB,+BAY/D;AAGD,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,wBAAwB,+BAGvE;AAGD,wBAAgB,YAAY,CAAC,EAAE,OAAO,EAAE,EAAE,wBAAwB,+BAIjE;AAGD,wBAAgB,SAAS,CAAC,EAAE,OAAO,EAAE,EAAE,wBAAwB,+BAE9D;AAGD,wBAAgB,SAAS,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,wBAAwB,+BAErE;AAGD,wBAAgB,UAAU,CAAC,EAAE,OAAO,EAAE,EAAE,wBAAwB,+BAG/D;AAGD,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,wBAAwB,+BAEvE;AAGD,wBAAgB,SAAS,CAAC,EAAE,OAAO,EAAE,EAAE,wBAAwB,+BAG9D;AAGD,wBAAgB,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,wBAAwB,+BAG7D;AAGD,wBAAgB,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,wBAAwB,+BAE7D"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { resolveArgumentSource } from '@cratis/scene.engine';
|
|
3
|
+
import 'react';
|
|
4
|
+
import { useRenderBindingScope } from '../renderer/RenderBindingScopeContext.js';
|
|
5
|
+
import '@cratis/scene.model';
|
|
6
|
+
import '../interactions/useInteractions.js';
|
|
7
|
+
import '../interactions/NotificationHost.js';
|
|
2
8
|
|
|
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
9
|
function textProperty(properties, name, fallback = '') {
|
|
6
10
|
return typeof properties[name] === 'string' ? properties[name] : fallback;
|
|
7
11
|
}
|
|
@@ -12,15 +16,31 @@ function textProperty(properties, name, fallback = '') {
|
|
|
12
16
|
"data-scene-data": textProperty(element.properties, 'typeName')
|
|
13
17
|
});
|
|
14
18
|
}
|
|
15
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Renders a modeled command action and emits a host-neutral command event when invoked.
|
|
21
|
+
*
|
|
22
|
+
* The event carries the resolved `arguments`, by name, read when the action is invoked: a
|
|
23
|
+
* `component.<id>.<output>` source reads what another element publishes - such as what the user typed into
|
|
24
|
+
* an input - and any other source is a data-context path. Hosts that read the mapping from `element`
|
|
25
|
+
* themselves keep working.
|
|
26
|
+
*/ function CoreAction({ element }) {
|
|
16
27
|
const command = textProperty(element.properties, 'command');
|
|
17
28
|
const label = textProperty(element.properties, 'label', command);
|
|
18
|
-
const
|
|
29
|
+
const scope = useRenderBindingScope();
|
|
30
|
+
const invoke = ()=>{
|
|
31
|
+
const mapping = Array.isArray(element.properties.arguments) ? element.properties.arguments : [];
|
|
32
|
+
const args = Object.fromEntries(mapping.filter((argument)=>typeof argument.name === 'string' && typeof argument.source === 'string').map((argument)=>[
|
|
33
|
+
argument.name,
|
|
34
|
+
resolveArgumentSource(argument.source, scope)
|
|
35
|
+
]));
|
|
36
|
+
globalThis.dispatchEvent(new CustomEvent('cratis.scene.command', {
|
|
19
37
|
detail: {
|
|
20
38
|
command,
|
|
21
|
-
element
|
|
39
|
+
element,
|
|
40
|
+
arguments: args
|
|
22
41
|
}
|
|
23
42
|
}));
|
|
43
|
+
};
|
|
24
44
|
return /*#__PURE__*/ jsx("button", {
|
|
25
45
|
type: "button",
|
|
26
46
|
"data-scene-id": element.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScreenplayCoreComponents.js","sources":["../../../core/ScreenplayCoreComponents.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 { RegisteredComponentProps } from '../renderer';\n\nfunction textProperty(properties: Record<string, unknown>, name: string, fallback = ''): string {\n return typeof properties[name] === 'string' ? properties[name] : fallback;\n}\n\n/** Carries a Screenplay data declaration without adding visual chrome. */\nexport function CoreData({ element }: RegisteredComponentProps) {\n return <span hidden data-scene-id={element.id} data-scene-data={textProperty(element.properties, 'typeName')} />;\n}\n\n/** Renders a modeled command action and emits a host-neutral command event when invoked. */\nexport function CoreAction({ element }: RegisteredComponentProps) {\n const command = textProperty(element.properties, 'command');\n const label = textProperty(element.properties, 'label', command);\n const invoke = () => globalThis.dispatchEvent(new CustomEvent('cratis.scene.command', { detail: { command, element } }));\n return <button type='button' data-scene-id={element.id} onClick={invoke}>{label}</button>;\n}\n\n/** Groups the nested content of a Screenplay section. */\nexport function CoreSection({ element, slots }: RegisteredComponentProps) {\n const name = textProperty(element.properties, 'name');\n return <section data-scene-id={element.id}>{name && <h2>{name}</h2>}{slots.content}</section>;\n}\n\n/** Renders navigation intent and emits a host-neutral navigation event. */\nexport function CoreNavigate({ element }: RegisteredComponentProps) {\n const targetScreen = textProperty(element.properties, 'targetScreen');\n const navigate = () => globalThis.dispatchEvent(new CustomEvent('cratis.scene.navigate', { detail: { targetScreen, element } }));\n return <button type='button' data-scene-id={element.id} onClick={navigate}>{targetScreen}</button>;\n}\n\n/** Renders a Screenplay title directive. */\nexport function CoreTitle({ element }: RegisteredComponentProps) {\n return <h1 data-scene-id={element.id}>{textProperty(element.properties, 'text')}</h1>;\n}\n\n/** Renders the structural shell of a Screenplay table. Query data is supplied by the host. */\nexport function CoreTable({ element, slots }: RegisteredComponentProps) {\n return <section data-scene-id={element.id} role='table'><header role='row'>{slots.columns}</header></section>;\n}\n\n/** Renders a Screenplay table-column heading. */\nexport function CoreColumn({ element }: RegisteredComponentProps) {\n const property = textProperty(element.properties, 'property');\n return <span data-scene-id={element.id} role='columnheader'>{textProperty(element.properties, 'label', property)}</span>;\n}\n\n/** Renders the structural shell of a Screenplay summary. Query data is supplied by the host. */\nexport function CoreSummary({ element, slots }: RegisteredComponentProps) {\n return <dl data-scene-id={element.id}>{slots.fields}</dl>;\n}\n\n/** Renders a Screenplay summary field label. */\nexport function CoreField({ element }: RegisteredComponentProps) {\n const property = textProperty(element.properties, 'property');\n return <dt data-scene-id={element.id}>{textProperty(element.properties, 'label', property)}</dt>;\n}\n\n/** Renders a Screenplay code block. */\nexport function CoreCode({ element }: RegisteredComponentProps) {\n const language = textProperty(element.properties, 'language');\n return <pre data-scene-id={element.id}><code data-language={language}>{textProperty(element.properties, 'code')}</code></pre>;\n}\n\n/** Makes an external screen-file reference visible until a host supplies that file. */\nexport function CoreFile({ element }: RegisteredComponentProps) {\n return <p data-scene-id={element.id}>Screen source: {textProperty(element.properties, 'path')}</p>;\n}\n"],"names":["textProperty","properties","name","fallback","CoreData","element","_jsx","span","hidden","data-scene-id","id","data-scene-data","CoreAction","command","label","invoke","globalThis","dispatchEvent","CustomEvent","detail","button","type","onClick","CoreSection","slots","_jsxs","section","h2","content","CoreNavigate","targetScreen","navigate","CoreTitle","h1","CoreTable","role","header","columns","CoreColumn","property","CoreSummary","dl","fields","CoreField","dt","CoreCode","language","pre","code","data-language","CoreFile","p"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScreenplayCoreComponents.js","sources":["../../../core/ScreenplayCoreComponents.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 { resolveArgumentSource } from '@cratis/scene.engine';\nimport { RegisteredComponentProps, useRenderBindingScope } from '../renderer';\n\nfunction textProperty(properties: Record<string, unknown>, name: string, fallback = ''): string {\n return typeof properties[name] === 'string' ? properties[name] : fallback;\n}\n\n/** Carries a Screenplay data declaration without adding visual chrome. */\nexport function CoreData({ element }: RegisteredComponentProps) {\n return <span hidden data-scene-id={element.id} data-scene-data={textProperty(element.properties, 'typeName')} />;\n}\n\n/** One entry of a command action's argument mapping. */\ninterface ArgumentMapping {\n name?: unknown;\n source?: unknown;\n}\n\n/**\n * Renders a modeled command action and emits a host-neutral command event when invoked.\n *\n * The event carries the resolved `arguments`, by name, read when the action is invoked: a\n * `component.<id>.<output>` source reads what another element publishes - such as what the user typed into\n * an input - and any other source is a data-context path. Hosts that read the mapping from `element`\n * themselves keep working.\n */\nexport function CoreAction({ element }: RegisteredComponentProps) {\n const command = textProperty(element.properties, 'command');\n const label = textProperty(element.properties, 'label', command);\n const scope = useRenderBindingScope();\n const invoke = () => {\n const mapping = Array.isArray(element.properties.arguments) ? element.properties.arguments as ArgumentMapping[] : [];\n const args = Object.fromEntries(mapping\n .filter((argument): argument is { name: string; source: string } => typeof argument.name === 'string' && typeof argument.source === 'string')\n .map(argument => [argument.name, resolveArgumentSource(argument.source, scope)]));\n globalThis.dispatchEvent(new CustomEvent('cratis.scene.command', { detail: { command, element, arguments: args } }));\n };\n return <button type='button' data-scene-id={element.id} onClick={invoke}>{label}</button>;\n}\n\n/** Groups the nested content of a Screenplay section. */\nexport function CoreSection({ element, slots }: RegisteredComponentProps) {\n const name = textProperty(element.properties, 'name');\n return <section data-scene-id={element.id}>{name && <h2>{name}</h2>}{slots.content}</section>;\n}\n\n/** Renders navigation intent and emits a host-neutral navigation event. */\nexport function CoreNavigate({ element }: RegisteredComponentProps) {\n const targetScreen = textProperty(element.properties, 'targetScreen');\n const navigate = () => globalThis.dispatchEvent(new CustomEvent('cratis.scene.navigate', { detail: { targetScreen, element } }));\n return <button type='button' data-scene-id={element.id} onClick={navigate}>{targetScreen}</button>;\n}\n\n/** Renders a Screenplay title directive. */\nexport function CoreTitle({ element }: RegisteredComponentProps) {\n return <h1 data-scene-id={element.id}>{textProperty(element.properties, 'text')}</h1>;\n}\n\n/** Renders the structural shell of a Screenplay table. Query data is supplied by the host. */\nexport function CoreTable({ element, slots }: RegisteredComponentProps) {\n return <section data-scene-id={element.id} role='table'><header role='row'>{slots.columns}</header></section>;\n}\n\n/** Renders a Screenplay table-column heading. */\nexport function CoreColumn({ element }: RegisteredComponentProps) {\n const property = textProperty(element.properties, 'property');\n return <span data-scene-id={element.id} role='columnheader'>{textProperty(element.properties, 'label', property)}</span>;\n}\n\n/** Renders the structural shell of a Screenplay summary. Query data is supplied by the host. */\nexport function CoreSummary({ element, slots }: RegisteredComponentProps) {\n return <dl data-scene-id={element.id}>{slots.fields}</dl>;\n}\n\n/** Renders a Screenplay summary field label. */\nexport function CoreField({ element }: RegisteredComponentProps) {\n const property = textProperty(element.properties, 'property');\n return <dt data-scene-id={element.id}>{textProperty(element.properties, 'label', property)}</dt>;\n}\n\n/** Renders a Screenplay code block. */\nexport function CoreCode({ element }: RegisteredComponentProps) {\n const language = textProperty(element.properties, 'language');\n return <pre data-scene-id={element.id}><code data-language={language}>{textProperty(element.properties, 'code')}</code></pre>;\n}\n\n/** Makes an external screen-file reference visible until a host supplies that file. */\nexport function CoreFile({ element }: RegisteredComponentProps) {\n return <p data-scene-id={element.id}>Screen source: {textProperty(element.properties, 'path')}</p>;\n}\n"],"names":["textProperty","properties","name","fallback","CoreData","element","_jsx","span","hidden","data-scene-id","id","data-scene-data","CoreAction","command","label","scope","useRenderBindingScope","invoke","mapping","Array","isArray","arguments","args","Object","fromEntries","filter","argument","source","map","resolveArgumentSource","globalThis","dispatchEvent","CustomEvent","detail","button","type","onClick","CoreSection","slots","_jsxs","section","h2","content","CoreNavigate","targetScreen","navigate","CoreTitle","h1","CoreTable","role","header","columns","CoreColumn","property","CoreSummary","dl","fields","CoreField","dt","CoreCode","language","pre","code","data-language","CoreFile","p"],"mappings":";;;;;;;;AAMA,SAASA,aAAaC,UAAmC,EAAEC,IAAY,EAAEC,WAAW,EAAE,EAAA;IAClF,OAAO,OAAOF,UAAU,CAACC,IAAAA,CAAK,KAAK,QAAA,GAAWD,UAAU,CAACC,IAAAA,CAAK,GAAGC,QAAAA;AACrE;AAEA,2EACO,SAASC,QAAAA,CAAS,EAAEC,OAAO,EAA4B,EAAA;AAC1D,IAAA,qBAAOC,GAAA,CAACC,MAAAA,EAAAA;QAAKC,MAAM,EAAA,IAAA;AAACC,QAAAA,eAAAA,EAAeJ,QAAQK,EAAE;QAAEC,iBAAAA,EAAiBX,YAAAA,CAAaK,OAAAA,CAAQJ,UAAU,EAAE,UAAA;;AACrG;AAQA;;;;;;;AAOC,IACM,SAASW,UAAAA,CAAW,EAAEP,OAAO,EAA4B,EAAA;AAC5D,IAAA,MAAMQ,OAAAA,GAAUb,YAAAA,CAAaK,OAAAA,CAAQJ,UAAU,EAAE,SAAA,CAAA;AACjD,IAAA,MAAMa,KAAAA,GAAQd,YAAAA,CAAaK,OAAAA,CAAQJ,UAAU,EAAE,OAAA,EAASY,OAAAA,CAAAA;AACxD,IAAA,MAAME,KAAAA,GAAQC,qBAAAA,EAAAA;AACd,IAAA,MAAMC,MAAAA,GAAS,IAAA;AACX,QAAA,MAAMC,OAAAA,GAAUC,KAAAA,CAAMC,OAAO,CAACf,QAAQJ,UAAU,CAACoB,SAAS,CAAA,GAAIhB,OAAAA,CAAQJ,UAAU,CAACoB,SAAS,GAAwB,EAAE;QACpH,MAAMC,IAAAA,GAAOC,OAAOC,WAAW,CAACN,QAC3BO,MAAM,CAAC,CAACC,QAAAA,GAA2D,OAAOA,QAAAA,CAASxB,IAAI,KAAK,QAAA,IAAY,OAAOwB,QAAAA,CAASC,MAAM,KAAK,QAAA,CAAA,CACnIC,GAAG,CAACF,CAAA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AAA;AAAG9C,QAAAA,eAAAA,EAAeJ,QAAQK,EAAE;AAAG4B,QAAAA,QAAAA,EAAAA,KAAAA,CAAMkB;;AACjD;AAEA,iDACO,SAASC,SAAAA,CAAU,EAAEpD,OAAO,EAA4B,EAAA;AAC3D,IAAA,MAAMgD,QAAAA,GAAWrD,YAAAA,CAAaK,OAAAA,CAAQJ,UAAU,EAAE,UAAA,CAAA;AAClD,IAAA,qBAAOK,GAAA,CAACoD,IAAAA,EAAAA;AAAGjD,QAAAA,eAAAA,EAAeJ,QAAQK,EAAE;kBAAGV,YAAAA,CAAaK,OAAAA,CAAQJ,UAAU,EAAE,OAAA,EAASoD,QAAAA;;AACrF;AAEA,wCACO,SAASM,QAAAA,CAAS,EAAEtD,OAAO,EAA4B,EAAA;AAC1D,IAAA,MAAMuD,QAAAA,GAAW5D,YAAAA,CAAaK,OAAAA,CAAQJ,UAAU,EAAE,UAAA,CAAA;AAClD,IAAA,qBAAOK,GAAA,CAACuD,KAAAA,EAAAA;AAAIpD,QAAAA,eAAAA,EAAeJ,QAAQK,EAAE;AAAE,QAAA,QAAA,gBAAAJ,GAAA,CAACwD,MAAAA,EAAAA;YAAKC,eAAAA,EAAeH,QAAAA;sBAAW5D,YAAAA,CAAaK,OAAAA,CAAQJ,UAAU,EAAE,MAAA;;;AAC5G;AAEA,wFACO,SAAS+D,QAAAA,CAAS,EAAE3D,OAAO,EAA4B,EAAA;AAC1D,IAAA,qBAAOkC,IAAA,CAAC0B,GAAAA,EAAAA;AAAExD,QAAAA,eAAAA,EAAeJ,QAAQK,EAAE;;AAAE,YAAA,iBAAA;YAAgBV,YAAAA,CAAaK,OAAAA,CAAQJ,UAAU,EAAE,MAAA;;;AAC1F;;"}
|
package/dist/esm/index.js
CHANGED
|
@@ -3,6 +3,9 @@ export { AbortableQueryRunner } from './renderer/AbortableQueryRunner.js';
|
|
|
3
3
|
export { BindingOutputProvider, useBindingOutputScope, useBindingOutputs } from './renderer/BindingOutputContext.js';
|
|
4
4
|
export { RenderBindingScopeProvider, useRenderBindingResolver, useRenderBindingScope } from './renderer/RenderBindingScopeContext.js';
|
|
5
5
|
export { UnresolvedComponent } from './renderer/UnresolvedComponent.js';
|
|
6
|
+
export { useBoundQuery } from './renderer/useBoundQuery.js';
|
|
7
|
+
export { useValueOutput, valueOutputName } from './renderer/useValueOutput.js';
|
|
8
|
+
export { valueOutputProperty } from './renderer/valueOutputProperty.js';
|
|
6
9
|
export { createReactRenderer } from './renderer/createReactRenderer.js';
|
|
7
10
|
export { InteractiveComponent } from './renderer/InteractiveComponent.js';
|
|
8
11
|
export { CoreText } from './core/CoreText.js';
|
|
@@ -18,6 +21,7 @@ export { extractNavigationItem } from './NavBar/extractNavigationItem.js';
|
|
|
18
21
|
export { SceneNavigationProvider, useSceneNavigation } from './navigation/SceneNavigationContext.js';
|
|
19
22
|
export { SceneNavigationHost } from './navigation/SceneNavigationHost.js';
|
|
20
23
|
export { createBrowserSceneHistory } from './navigation/createBrowserSceneHistory.js';
|
|
24
|
+
export { createHashSceneHistory } from './navigation/createHashSceneHistory.js';
|
|
21
25
|
export { createMemorySceneHistory } from './navigation/createMemorySceneHistory.js';
|
|
22
26
|
export { diagnoseRenderedNavigation } from './navigation/diagnoseRenderedNavigation.js';
|
|
23
27
|
export { identityRoute } from './navigation/identityRoute.js';
|
|
@@ -36,6 +40,7 @@ export { DesignTimeExtensionPoint, designTimeExtensionPointLabels } from './pack
|
|
|
36
40
|
export { DesignTimeProvider, useDesignTimeContext } from './packages/DesignTimeProvider.js';
|
|
37
41
|
export { EmbeddedPackageHost } from './packages/EmbeddedPackageHost.js';
|
|
38
42
|
export { loadDesignTimeContributions } from './packages/loadDesignTimeContributions.js';
|
|
43
|
+
export { isNetworkAsset } from './packages/isNetworkAsset.js';
|
|
39
44
|
export { PackageHostAssets } from './packages/PackageHostAssets.js';
|
|
40
45
|
export { resolvePackageHost } from './packages/PackageHostConfiguration.js';
|
|
41
46
|
export { PackageHostRenderMode } from './packages/PackageHostRenderMode.js';
|
package/dist/esm/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 @@
|
|
|
1
|
+
{"version":3,"file":"createHashSceneHistory.d.ts","sourceRoot":"","sources":["../../../navigation/createHashSceneHistory.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAY9C,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,kBAA2B,GAAG,YAAY,CAyBzF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
const stateKey = 'sceneNavigation';
|
|
4
|
+
/**
|
|
5
|
+
* A history kept in the URL fragment - `index.html#/WorkItemDetails?workItemId=B` - for hosts that are served
|
|
6
|
+
* as a single file or from a path they do not control, such as a generated runtime or a webview. It behaves
|
|
7
|
+
* like `createBrowserSceneHistory`: entries are pushed with their navigation state, back and forward restore
|
|
8
|
+
* them, and a typed or bookmarked fragment is matched by URL alone. A fragment changed by hand, which fires
|
|
9
|
+
* `hashchange` rather than `popstate`, is reported the same way.
|
|
10
|
+
*/ function createHashSceneHistory(browser = window) {
|
|
11
|
+
const location = ()=>{
|
|
12
|
+
const fragment = browser.location.hash.replace(/^#\/?/, '');
|
|
13
|
+
return fragment.length ? fragment : undefined;
|
|
14
|
+
};
|
|
15
|
+
const href = (url)=>`${browser.location.pathname}${browser.location.search}#/${url ?? ''}`;
|
|
16
|
+
const stored = (value)=>value?.[stateKey];
|
|
17
|
+
return {
|
|
18
|
+
location,
|
|
19
|
+
state: ()=>stored(browser.history.state),
|
|
20
|
+
push: (state)=>browser.history.pushState({
|
|
21
|
+
[stateKey]: state
|
|
22
|
+
}, '', href(state.url)),
|
|
23
|
+
replace: (state)=>browser.history.replaceState({
|
|
24
|
+
[stateKey]: state
|
|
25
|
+
}, '', href(state.url)),
|
|
26
|
+
back: ()=>browser.history.back(),
|
|
27
|
+
listen: (listener)=>{
|
|
28
|
+
const onPopState = (event)=>listener(location(), stored(event.state));
|
|
29
|
+
const onHashChange = ()=>listener(location(), stored(browser.history.state));
|
|
30
|
+
browser.addEventListener('popstate', onPopState);
|
|
31
|
+
browser.addEventListener('hashchange', onHashChange);
|
|
32
|
+
return ()=>{
|
|
33
|
+
browser.removeEventListener('popstate', onPopState);
|
|
34
|
+
browser.removeEventListener('hashchange', onHashChange);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { createHashSceneHistory };
|
|
41
|
+
//# sourceMappingURL=createHashSceneHistory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createHashSceneHistory.js","sources":["../../../navigation/createHashSceneHistory.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 { SceneBrowserWindow } from './createBrowserSceneHistory';\nimport { SceneHistory } from './SceneHistory';\nimport { SceneNavigationState } from './SceneNavigationState';\n\nconst stateKey = 'sceneNavigation';\n\n/**\n * A history kept in the URL fragment - `index.html#/WorkItemDetails?workItemId=B` - for hosts that are served\n * as a single file or from a path they do not control, such as a generated runtime or a webview. It behaves\n * like `createBrowserSceneHistory`: entries are pushed with their navigation state, back and forward restore\n * them, and a typed or bookmarked fragment is matched by URL alone. A fragment changed by hand, which fires\n * `hashchange` rather than `popstate`, is reported the same way.\n */\nexport function createHashSceneHistory(browser: SceneBrowserWindow = window): SceneHistory {\n const location = () => {\n const fragment = browser.location.hash.replace(/^#\\/?/, '');\n return fragment.length ? fragment : undefined;\n };\n const href = (url: string | undefined) => `${browser.location.pathname}${browser.location.search}#/${url ?? ''}`;\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 const onHashChange = () => listener(location(), stored(browser.history.state));\n browser.addEventListener('popstate', onPopState);\n browser.addEventListener('hashchange', onHashChange);\n return () => {\n browser.removeEventListener('popstate', onPopState);\n browser.removeEventListener('hashchange', onHashChange);\n };\n },\n };\n}\n"],"names":["stateKey","createHashSceneHistory","browser","window","location","fragment","hash","replace","length","undefined","href","url","pathname","search","stored","value","state","history","push","pushState","replaceState","back","listen","listener","onPopState","event","onHashChange","addEventListener","removeEventListener"],"mappings":"AAAA;AACA;AAMA,MAAMA,QAAAA,GAAW,iBAAA;AAEjB;;;;;;AAMC,IACM,SAASC,sBAAAA,CAAuBC,OAAAA,GAA8BC,MAAM,EAAA;AACvE,IAAA,MAAMC,QAAAA,GAAW,IAAA;QACb,MAAMC,QAAAA,GAAWH,QAAQE,QAAQ,CAACE,IAAI,CAACC,OAAO,CAAC,OAAA,EAAS,EAAA,CAAA;QACxD,OAAOF,QAAAA,CAASG,MAAM,GAAGH,QAAAA,GAAWI,SAAAA;AACxC,IAAA,CAAA;AACA,IAAA,MAAMC,OAAO,CAACC,GAAAA,GAA4B,CAAA,EAAGT,OAAAA,CAAQE,QAAQ,CAACQ,QAAQ,CAAA,EAAGV,OAAAA,CAAQE,QAAQ,CAACS,MAAM,CAAC,EAAE,EAAEF,OAAO,EAAA,CAAA,CAAI;AAChH,IAAA,MAAMG,MAAAA,GAAS,CAACC,KAAAA,GAAoBA,KAA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@@ -6,6 +6,7 @@ export * from './SceneNavigationHost';
|
|
|
6
6
|
export * from './SceneNavigationState';
|
|
7
7
|
export * from './SceneRoute';
|
|
8
8
|
export * from './createBrowserSceneHistory';
|
|
9
|
+
export * from './createHashSceneHistory';
|
|
9
10
|
export * from './createMemorySceneHistory';
|
|
10
11
|
export * from './diagnoseRenderedNavigation';
|
|
11
12
|
export * from './identityRoute';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../navigation/index.ts"],"names":[],"mappings":"AAGA,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../navigation/index.ts"],"names":[],"mappings":"AAGA,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC"}
|
|
@@ -6,6 +6,7 @@ export * from './SceneNavigationHost';
|
|
|
6
6
|
export * from './SceneNavigationState';
|
|
7
7
|
export * from './SceneRoute';
|
|
8
8
|
export * from './createBrowserSceneHistory';
|
|
9
|
+
export * from './createHashSceneHistory';
|
|
9
10
|
export * from './createMemorySceneHistory';
|
|
10
11
|
export * from './diagnoseRenderedNavigation';
|
|
11
12
|
export * from './identityRoute';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../navigation/index.ts"],"names":[],"mappings":"AAGA,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../navigation/index.ts"],"names":[],"mappings":"AAGA,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC"}
|
|
@@ -20,6 +20,8 @@ export interface ResolvedPackageHost {
|
|
|
20
20
|
screenTemplates: ScreenTemplate[];
|
|
21
21
|
dialogTemplates: DialogTemplate[];
|
|
22
22
|
themes: Theme[];
|
|
23
|
+
layout?: Layout;
|
|
24
|
+
theme?: Theme;
|
|
23
25
|
templates: TemplateCatalogEntry[];
|
|
24
26
|
icons: IconAdapterRegistry;
|
|
25
27
|
assets: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackageHostConfiguration.d.ts","sourceRoot":"","sources":["../../../packages/PackageHostConfiguration.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"PackageHostConfiguration.d.ts","sourceRoot":"","sources":["../../../packages/PackageHostConfiguration.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EAAE,oBAAoB,EAA6E,MAAM,sBAAsB,CAAC;AACvI,OAAO,EAAE,mBAAmB,EAA6B,MAAM,8BAA8B,CAAC;AAC9F,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAyB,MAAM,sBAAsB,CAAC;AAGzG,MAAM,WAAW,iBAAiB;IAC9B,sBAAsB,EAAE,OAAO,CAAC;IAChC,kBAAkB,EAAE,OAAO,CAAC;IAG5B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,wBAAwB;IACrC,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAC9B,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,iBAAiB,CAAC;IAG1B,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,mBAAmB;IAChC,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAC9B,UAAU,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;IACtD,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,MAAM,EAAE,KAAK,EAAE,CAAC;IAGhB,MAAM,CAAC,EAAE,MAAM,CAAC;IAGhB,KAAK,CAAC,EAAE,KAAK,CAAC;IAMd,SAAS,EAAE,oBAAoB,EAAE,CAAC;IAClC,KAAK,EAAE,mBAAmB,CAAC;IAC3B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;CACzB;AAKD,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,wBAAwB,GAAG,mBAAmB,CAsF/F"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { resolvePackageDependencies, describeTemplateCatalog } from '@cratis/scene.engine';
|
|
1
|
+
import { resolvePackageDependencies, incompatiblePackages, describeTemplateCatalog } from '@cratis/scene.engine';
|
|
2
2
|
import { createIconAdapterRegistry } from '../icons/IconAdapterRegistry.js';
|
|
3
3
|
import { validatePackageBundle, mergePackageRegistries } from './ScenePackageBundle.js';
|
|
4
|
+
import { isNetworkAsset } from './isNetworkAsset.js';
|
|
4
5
|
|
|
5
6
|
// Copyright (c) Cratis. All rights reserved.
|
|
6
7
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
@@ -39,8 +40,9 @@ import { validatePackageBundle, mergePackageRegistries } from './ScenePackageBun
|
|
|
39
40
|
diagnostics.push(`Package '${packageName}' provides executable design-time contributions, but host policy forbids them`);
|
|
40
41
|
}
|
|
41
42
|
const packageAssets = bundle.manifest.assets ?? [];
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
const networkAssets = packageAssets.filter(isNetworkAsset);
|
|
44
|
+
if (!configuration.policy.allowNetworkAssets && networkAssets.length > 0) {
|
|
45
|
+
diagnostics.push(`Package '${packageName}' declares network assets (${networkAssets.join(', ')}), but host policy forbids them`);
|
|
44
46
|
}
|
|
45
47
|
assets.push(...packageAssets);
|
|
46
48
|
for (const dependency of bundle.manifest.runtimeSingletons ?? []){
|
|
@@ -52,6 +54,18 @@ import { validatePackageBundle, mergePackageRegistries } from './ScenePackageBun
|
|
|
52
54
|
}
|
|
53
55
|
bundles.push(bundle);
|
|
54
56
|
}
|
|
57
|
+
const layouts = bundles.flatMap((bundle)=>bundle.layouts ?? []);
|
|
58
|
+
const themes = bundles.flatMap((bundle)=>bundle.themes ?? []);
|
|
59
|
+
const layout = configuration.profile.layout ? layouts.find((candidate)=>candidate.name === configuration.profile.layout) : undefined;
|
|
60
|
+
const theme = configuration.profile.theme ? themes.find((candidate)=>candidate.name === configuration.profile.theme) : undefined;
|
|
61
|
+
if (configuration.profile.layout && !layout) {
|
|
62
|
+
diagnostics.push(`UI profile '${configuration.profile.name}' uses layout '${configuration.profile.layout}', which no approved package provides`);
|
|
63
|
+
}
|
|
64
|
+
if (configuration.profile.theme && !theme) {
|
|
65
|
+
diagnostics.push(`UI profile '${configuration.profile.name}' uses theme '${configuration.profile.theme}', which no approved package provides`);
|
|
66
|
+
} else if (theme && incompatiblePackages(theme, configuration.profile).length > 0) {
|
|
67
|
+
diagnostics.push(`Theme '${theme.name}' is not compatible with ${incompatiblePackages(theme, configuration.profile).join(', ')} in UI profile '${configuration.profile.name}'`);
|
|
68
|
+
}
|
|
55
69
|
const blocked = diagnostics.length > 0;
|
|
56
70
|
const approved = blocked ? [] : bundles;
|
|
57
71
|
const approvedAssets = blocked ? [] : assets;
|
|
@@ -62,6 +76,8 @@ import { validatePackageBundle, mergePackageRegistries } from './ScenePackageBun
|
|
|
62
76
|
screenTemplates: approved.flatMap((bundle)=>bundle.screenTemplates ?? []),
|
|
63
77
|
dialogTemplates: approved.flatMap((bundle)=>bundle.dialogTemplates ?? []),
|
|
64
78
|
themes: approved.flatMap((bundle)=>bundle.themes ?? []),
|
|
79
|
+
layout: blocked ? undefined : layout,
|
|
80
|
+
theme: blocked ? undefined : theme,
|
|
65
81
|
templates: describeTemplateCatalog(approved, configuration.sceneVersion),
|
|
66
82
|
icons: createIconAdapterRegistry(approved.map((bundle)=>bundle.iconLibrary?.adapter).filter((adapter)=>adapter !== undefined)),
|
|
67
83
|
assets: approvedAssets,
|
|
@@ -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 { 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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,CAAAA;QACnCI,OAAAA,EAASJ,QAAAA,CAASK,OAAO,CAAC/C,CAAAA,SAAUA,MAAAA,CAAO8C,OAAO,IAAI,EAAE,CAAA;QACxDE,eAAAA,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;QACtDC,SAAAA,EAAWC,uBAAAA,CAAwBV,QAAAA,EAAU9C,aAAAA,CAAcyD,YAAY,CAAA;AACvEC,QAAAA,KAAAA,EAAOC,yBAAAA,CAA0Bb,QAAAA,CAASjC,GAAG,CAACT,CAAAA,MAAAA,GAAUA,MAAAA,CAAOwD,WAAW,EAAEC,OAAAA,CAAAA,CAASC,MAAM,CAACD,CAAAA,UAAWA,OAAAA,KAAYE,SAAAA,CAAAA,CAAAA;QACnHlC,MAAAA,EAAQkB,cAAAA;QACRiB,KAAAA,EAAOjB,cAAAA,CAAee,MAAM,CAACG,WAAAA,CAAAA;AAC7BrB,QAAAA,OAAAA;AACA3C,QAAAA;AACJ,KAAA;AACJ;AAEA,SAASgE,YAAYzB,KAAa,EAAA;AAC9B,IAAA,OAAO,2BAA2BC,IAAI,CAACD,KAAAA,CAAAA,IAAUA,KAAAA,CAAM0B,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, incompatiblePackages, resolvePackageDependencies } from '@cratis/scene.engine';\nimport { IconAdapterRegistry, createIconAdapterRegistry } from '../icons/IconAdapterRegistry';\nimport { ScenePackageBundle, mergePackageRegistries, validatePackageBundle } from './ScenePackageBundle';\nimport { isNetworkAsset } from './isNetworkAsset';\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 /** The layout the UI profile names, from the approved packages. Absent when the profile names none. */\n layout?: Layout;\n\n /** The theme the UI profile names, from the approved packages. Absent when the profile names none. */\n theme?: 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 const networkAssets = packageAssets.filter(isNetworkAsset);\n if (!configuration.policy.allowNetworkAssets && networkAssets.length > 0) {\n diagnostics.push(`Package '${packageName}' declares network assets (${networkAssets.join(', ')}), 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 layouts = bundles.flatMap(bundle => bundle.layouts ?? []);\n const themes = bundles.flatMap(bundle => bundle.themes ?? []);\n const layout = configuration.profile.layout ? layouts.find(candidate => candidate.name === configuration.profile.layout) : undefined;\n const theme = configuration.profile.theme ? themes.find(candidate => candidate.name === configuration.profile.theme) : undefined;\n if (configuration.profile.layout && !layout) {\n diagnostics.push(`UI profile '${configuration.profile.name}' uses layout '${configuration.profile.layout}', which no approved package provides`);\n }\n if (configuration.profile.theme && !theme) {\n diagnostics.push(`UI profile '${configuration.profile.name}' uses theme '${configuration.profile.theme}', which no approved package provides`);\n } else if (theme && incompatiblePackages(theme, configuration.profile).length > 0) {\n diagnostics.push(`Theme '${theme.name}' is not compatible with ${incompatiblePackages(theme, configuration.profile).join(', ')} in UI profile '${configuration.profile.name}'`);\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 layout: blocked ? undefined : layout,\n theme: blocked ? undefined : theme,\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","networkAssets","filter","isNetworkAsset","allowNetworkAssets","length","dependency","owner","layouts","flatMap","themes","layout","find","candidate","undefined","theme","incompatiblePackages","blocked","approved","approvedAssets","components","mergePackageRegistries","screenTemplates","dialogTemplates","templates","describeTemplateCatalog","sceneVersion","icons","createIconAdapterRegistry","iconLibrary","adapter","fonts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QACnHtB,MAAAA,EAAQ2B,cAAAA;QACRY,KAAAA,EAAOZ,cAAAA,CAAejB,MAAM,CAAC8B,WAAAA,CAAAA;AAC7Bf,QAAAA,OAAAA;AACArD,QAAAA;AACJ,KAAA;AACJ;AAEA,SAASoE,YAAYC,KAAa,EAAA;AAC9B,IAAA,OAAO,2BAA2BC,IAAI,CAACD,KAAAA,CAAAA,IAAUA,KAAAA,CAAME,QAAQ,CAAC,SAAA,CAAA;AACpE;;"}
|
|
@@ -13,6 +13,7 @@ export * from './DesignTimeResolution';
|
|
|
13
13
|
export * from '../navigation';
|
|
14
14
|
export * from './EmbeddedPackageHost';
|
|
15
15
|
export * from './loadDesignTimeContributions';
|
|
16
|
+
export * from './isNetworkAsset';
|
|
16
17
|
export * from './PackageHostAssets';
|
|
17
18
|
export * from './PackageHostConfiguration';
|
|
18
19
|
export * from './PackageHostRenderMode';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/index.ts"],"names":[],"mappings":"AAGA,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC;AAChD,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/index.ts"],"names":[],"mappings":"AAGA,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC;AAChD,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC"}
|
|
@@ -13,6 +13,7 @@ export * from './DesignTimeResolution';
|
|
|
13
13
|
export * from '../navigation';
|
|
14
14
|
export * from './EmbeddedPackageHost';
|
|
15
15
|
export * from './loadDesignTimeContributions';
|
|
16
|
+
export * from './isNetworkAsset';
|
|
16
17
|
export * from './PackageHostAssets';
|
|
17
18
|
export * from './PackageHostConfiguration';
|
|
18
19
|
export * from './PackageHostRenderMode';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/index.ts"],"names":[],"mappings":"AAGA,cAAc,oBAAoB,CAAC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cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isNetworkAsset.d.ts","sourceRoot":"","sources":["../../../packages/isNetworkAsset.ts"],"names":[],"mappings":"AASA,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAKrD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
/**
|
|
4
|
+
* Whether loading an asset reaches beyond the host: an absolute URL with any scheme other than `data:`
|
|
5
|
+
* or `blob:` (`https://`, `http://`, `ws://`, `ftp://`), or a protocol-relative `//host/...` reference. A
|
|
6
|
+
* package-relative path or a bare module specifier such as `@cratis/components/styles` is resolved by the
|
|
7
|
+
* host from what it bundled, so it is not a network asset.
|
|
8
|
+
*/ function isNetworkAsset(asset) {
|
|
9
|
+
const trimmed = asset.trim();
|
|
10
|
+
if (trimmed.startsWith('//')) return true;
|
|
11
|
+
const scheme = /^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(trimmed)?.[1]?.toLowerCase();
|
|
12
|
+
return scheme !== undefined && scheme !== 'data' && scheme !== 'blob';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { isNetworkAsset };
|
|
16
|
+
//# sourceMappingURL=isNetworkAsset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isNetworkAsset.js","sources":["../../../packages/isNetworkAsset.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 * Whether loading an asset reaches beyond the host: an absolute URL with any scheme other than `data:`\n * or `blob:` (`https://`, `http://`, `ws://`, `ftp://`), or a protocol-relative `//host/...` reference. A\n * package-relative path or a bare module specifier such as `@cratis/components/styles` is resolved by the\n * host from what it bundled, so it is not a network asset.\n */\nexport function isNetworkAsset(asset: string): boolean {\n const trimmed = asset.trim();\n if (trimmed.startsWith('//')) return true;\n const scheme = /^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(trimmed)?.[1]?.toLowerCase();\n return scheme !== undefined && scheme !== 'data' && scheme !== 'blob';\n}\n"],"names":["isNetworkAsset","asset","trimmed","trim","startsWith","scheme","exec","toLowerCase","undefined"],"mappings":"AAAA;AACA;AAEA;;;;;IAMO,SAASA,cAAAA,CAAeC,KAAa,EAAA;IACxC,MAAMC,OAAAA,GAAUD,MAAME,IAAI,EAAA;AAC1B,IAAA,IAAID,OAAAA,CAAQE,UAAU,CAAC,IAAA,CAAA,EAAO,OAAO,IAAA;AACrC,IAAA,MAAMC,SAAS,6BAAA,CAA8BC,IAAI,CAACJ,OAAAA,CAAAA,GAAW,EAAE,EAAEK,WAAAA,EAAAA;AACjE,IAAA,OAAOF,MAAAA,KAAWG,SAAAA,IAAaH,MAAAA,KAAW,MAAA,IAAUA,MAAAA,KAAW,MAAA;AACnE;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderBindingScopeContext.d.ts","sourceRoot":"","sources":["../../../renderer/RenderBindingScopeContext.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAA2D,MAAM,OAAO,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"RenderBindingScopeContext.d.ts","sourceRoot":"","sources":["../../../renderer/RenderBindingScopeContext.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAA2D,MAAM,OAAO,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,YAAY,EAA8C,MAAM,sBAAsB,CAAC;AAWjH,MAAM,WAAW,+BAA+B;IAC5C,QAAQ,EAAE,SAAS,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3D,cAAc,CAAC,EAAE,eAAe,CAAC;IACjC,yBAAyB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK,IAAI,CAAC;CAC1F;AAUD,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,+BAA+B,+BAShF;AA2BD,wBAAgB,wBAAwB,IAAI,eAAe,CAI1D;AAED,wBAAgB,qBAAqB,IAAI,YAAY,CAEpD"}
|