@cratis/scene.react 4.8.0 → 4.10.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/SceneElementView.tsx +34 -5
- package/dist/cjs/SceneElementView.js +20 -5
- package/dist/cjs/SceneElementView.js.map +1 -1
- package/dist/cjs/core/coreComponents.js +4 -0
- package/dist/cjs/core/coreComponents.js.map +1 -1
- package/dist/cjs/core/coreDescriptors.js +3 -0
- package/dist/cjs/core/coreDescriptors.js.map +1 -1
- package/dist/cjs/index.js +19 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/navigation/resolveDestination.js +54 -0
- package/dist/cjs/navigation/resolveDestination.js.map +1 -0
- package/dist/cjs/packages/DesignTimeBundle.js +17 -0
- package/dist/cjs/packages/DesignTimeBundle.js.map +1 -0
- package/dist/cjs/packages/DesignTimeProvider.js +23 -0
- package/dist/cjs/packages/DesignTimeProvider.js.map +1 -0
- package/dist/cjs/packages/PackageHostConfiguration.js +71 -0
- package/dist/cjs/packages/PackageHostConfiguration.js.map +1 -0
- package/dist/cjs/packages/ScenePackageBundle.js +2 -0
- package/dist/cjs/packages/ScenePackageBundle.js.map +1 -1
- package/dist/cjs/renderer/AbortableQueryRunner.js +26 -0
- package/dist/cjs/renderer/AbortableQueryRunner.js.map +1 -0
- package/dist/cjs/renderer/BindingOutputContext.js +74 -0
- package/dist/cjs/renderer/BindingOutputContext.js.map +1 -0
- package/dist/cjs/renderer/InteractiveComponent.js +37 -2
- package/dist/cjs/renderer/InteractiveComponent.js.map +1 -1
- package/dist/cjs/renderer/RenderBindingScopeContext.js +77 -0
- package/dist/cjs/renderer/RenderBindingScopeContext.js.map +1 -0
- package/dist/esm/SceneElementView.d.ts +6 -2
- package/dist/esm/SceneElementView.d.ts.map +1 -1
- package/dist/esm/SceneElementView.js +20 -5
- package/dist/esm/SceneElementView.js.map +1 -1
- package/dist/esm/core/coreComponents.js +4 -0
- package/dist/esm/core/coreComponents.js.map +1 -1
- package/dist/esm/core/coreDescriptors.js +3 -0
- package/dist/esm/core/coreDescriptors.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/navigation/DestinationResolution.d.ts +10 -0
- package/dist/esm/navigation/DestinationResolution.d.ts.map +1 -0
- package/dist/esm/navigation/DestinationResolution.js +2 -0
- package/dist/esm/navigation/DestinationResolution.js.map +1 -0
- package/dist/esm/navigation/index.d.ts +3 -0
- package/dist/esm/navigation/index.d.ts.map +1 -0
- package/dist/esm/navigation/index.js +3 -0
- package/dist/esm/navigation/index.js.map +1 -0
- package/dist/esm/navigation/resolveDestination.d.ts +5 -0
- package/dist/esm/navigation/resolveDestination.d.ts.map +1 -0
- package/dist/esm/navigation/resolveDestination.js +52 -0
- package/dist/esm/navigation/resolveDestination.js.map +1 -0
- package/dist/esm/packages/DesignTimeAction.d.ts +22 -0
- package/dist/esm/packages/DesignTimeAction.d.ts.map +1 -0
- package/dist/esm/packages/DesignTimeAction.js +2 -0
- package/dist/esm/packages/DesignTimeAction.js.map +1 -0
- package/dist/esm/packages/DesignTimeBundle.d.ts +14 -0
- package/dist/esm/packages/DesignTimeBundle.d.ts.map +1 -0
- package/dist/esm/packages/DesignTimeBundle.js +15 -0
- package/dist/esm/packages/DesignTimeBundle.js.map +1 -0
- package/dist/esm/packages/DesignTimeComponentProps.d.ts +5 -0
- package/dist/esm/packages/DesignTimeComponentProps.d.ts.map +1 -0
- package/dist/esm/packages/DesignTimeComponentProps.js +2 -0
- package/dist/esm/packages/DesignTimeComponentProps.js.map +1 -0
- package/dist/esm/packages/DesignTimeContext.d.ts +18 -0
- package/dist/esm/packages/DesignTimeContext.d.ts.map +1 -0
- package/dist/esm/packages/DesignTimeContext.js +2 -0
- package/dist/esm/packages/DesignTimeContext.js.map +1 -0
- package/dist/esm/packages/DesignTimePropertyDisplayProps.d.ts +8 -0
- package/dist/esm/packages/DesignTimePropertyDisplayProps.d.ts.map +1 -0
- package/dist/esm/packages/DesignTimePropertyDisplayProps.js +2 -0
- package/dist/esm/packages/DesignTimePropertyDisplayProps.js.map +1 -0
- package/dist/esm/packages/DesignTimePropertyEditorProps.d.ts +9 -0
- package/dist/esm/packages/DesignTimePropertyEditorProps.d.ts.map +1 -0
- package/dist/esm/packages/DesignTimePropertyEditorProps.js +2 -0
- package/dist/esm/packages/DesignTimePropertyEditorProps.js.map +1 -0
- package/dist/esm/packages/DesignTimeProvider.d.ts +9 -0
- package/dist/esm/packages/DesignTimeProvider.d.ts.map +1 -0
- package/dist/esm/packages/DesignTimeProvider.js +20 -0
- package/dist/esm/packages/DesignTimeProvider.js.map +1 -0
- package/dist/esm/packages/PackageHostConfiguration.d.ts +25 -0
- package/dist/esm/packages/PackageHostConfiguration.d.ts.map +1 -0
- package/dist/esm/packages/PackageHostConfiguration.js +69 -0
- package/dist/esm/packages/PackageHostConfiguration.js.map +1 -0
- package/dist/esm/packages/ScenePackageBundle.d.ts +2 -0
- package/dist/esm/packages/ScenePackageBundle.d.ts.map +1 -1
- package/dist/esm/packages/ScenePackageBundle.js +2 -0
- package/dist/esm/packages/ScenePackageBundle.js.map +1 -1
- package/dist/esm/packages/index.d.ts +9 -0
- package/dist/esm/packages/index.d.ts.map +1 -1
- package/dist/esm/packages/index.js +9 -0
- package/dist/esm/packages/index.js.map +1 -1
- package/dist/esm/renderer/AbortableQueryRunner.d.ts +7 -0
- package/dist/esm/renderer/AbortableQueryRunner.d.ts.map +1 -0
- package/dist/esm/renderer/AbortableQueryRunner.js +24 -0
- package/dist/esm/renderer/AbortableQueryRunner.js.map +1 -0
- package/dist/esm/renderer/BindingOutputContext.d.ts +18 -0
- package/dist/esm/renderer/BindingOutputContext.d.ts.map +1 -0
- package/dist/esm/renderer/BindingOutputContext.js +70 -0
- package/dist/esm/renderer/BindingOutputContext.js.map +1 -0
- package/dist/esm/renderer/ComponentRegistry.d.ts +2 -0
- package/dist/esm/renderer/ComponentRegistry.d.ts.map +1 -1
- package/dist/esm/renderer/InteractiveComponent.d.ts.map +1 -1
- package/dist/esm/renderer/InteractiveComponent.js +38 -3
- package/dist/esm/renderer/InteractiveComponent.js.map +1 -1
- package/dist/esm/renderer/RenderBindingScopeContext.d.ts +14 -0
- package/dist/esm/renderer/RenderBindingScopeContext.d.ts.map +1 -0
- package/dist/esm/renderer/RenderBindingScopeContext.js +73 -0
- package/dist/esm/renderer/RenderBindingScopeContext.js.map +1 -0
- 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/tsconfig.tsbuildinfo +1 -1
- package/index.ts +1 -0
- package/navigation/DestinationResolution.ts +13 -0
- package/navigation/index.ts +5 -0
- package/navigation/resolveDestination.ts +50 -0
- package/package.json +5 -5
- package/packages/DesignTimeAction.ts +24 -0
- package/packages/DesignTimeBundle.ts +30 -0
- package/packages/DesignTimeComponentProps.ts +11 -0
- package/packages/DesignTimeContext.ts +32 -0
- package/packages/DesignTimePropertyDisplayProps.ts +14 -0
- package/packages/DesignTimePropertyEditorProps.ts +15 -0
- package/packages/DesignTimeProvider.tsx +25 -0
- package/packages/PackageHostConfiguration.ts +98 -0
- package/packages/ScenePackageBundle.ts +5 -0
- package/packages/index.ts +9 -0
- package/renderer/AbortableQueryRunner.ts +27 -0
- package/renderer/BindingOutputContext.tsx +69 -0
- package/renderer/ComponentRegistry.ts +4 -0
- package/renderer/InteractiveComponent.tsx +30 -3
- package/renderer/RenderBindingScopeContext.tsx +73 -0
- package/renderer/index.ts +3 -0
|
@@ -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
|
+
* Runs query bindings so a newer argument set aborts and ignores older work.
|
|
7
|
+
*/ class AbortableQueryRunner {
|
|
8
|
+
#controller;
|
|
9
|
+
#generation = 0;
|
|
10
|
+
async run(query, argumentsValue, performer) {
|
|
11
|
+
this.#controller?.abort();
|
|
12
|
+
const controller = new AbortController();
|
|
13
|
+
const generation = ++this.#generation;
|
|
14
|
+
this.#controller = controller;
|
|
15
|
+
const result = await performer(query, argumentsValue, controller.signal);
|
|
16
|
+
return generation === this.#generation && !controller.signal.aborted ? result : undefined;
|
|
17
|
+
}
|
|
18
|
+
clear() {
|
|
19
|
+
this.#controller?.abort();
|
|
20
|
+
this.#generation++;
|
|
21
|
+
this.#controller = undefined;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
exports.AbortableQueryRunner = AbortableQueryRunner;
|
|
26
|
+
//# sourceMappingURL=AbortableQueryRunner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbortableQueryRunner.js","sources":["../../../renderer/AbortableQueryRunner.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\nexport type QueryPerformer = (query: string, argumentsValue: unknown, signal: AbortSignal) => Promise<unknown>;\n\n/**\n * Runs query bindings so a newer argument set aborts and ignores older work.\n */\nexport class AbortableQueryRunner {\n #controller?: AbortController;\n #generation = 0;\n\n async run(query: string, argumentsValue: unknown, performer: QueryPerformer): Promise<unknown | undefined> {\n this.#controller?.abort();\n const controller = new AbortController();\n const generation = ++this.#generation;\n this.#controller = controller;\n const result = await performer(query, argumentsValue, controller.signal);\n return generation === this.#generation && !controller.signal.aborted ? result : undefined;\n }\n\n clear(): void {\n this.#controller?.abort();\n this.#generation++;\n this.#controller = undefined;\n }\n}\n"],"names":["AbortableQueryRunner","run","query","argumentsValue","performer","abort","controller","AbortController","generation","result","signal","aborted","undefined","clear"],"mappings":";;AAAA;AACA;AAIA;;AAEC,IACM,MAAMA,oBAAAA,CAAAA;AACT,IAAA,WAAW;IACX,WAAW,GAAG,CAAA;AAEd,IAAA,MAAMC,IAAIC,KAAa,EAAEC,cAAuB,EAAEC,SAAyB,EAAgC;QACvG,IAAI,CAAC,WAAW,EAAEC,KAAAA,EAAAA;AAClB,QAAA,MAAMC,aAAa,IAAIC,eAAAA,EAAAA;AACvB,QAAA,MAAMC,UAAAA,GAAa,EAAE,IAAI,CAAC,WAAW;QACrC,IAAI,CAAC,WAAW,GAAGF,UAAAA;AACnB,QAAA,MAAMG,SAAS,MAAML,SAAAA,CAAUF,KAAAA,EAAOC,cAAAA,EAAgBG,WAAWI,MAAM,CAAA;AACvE,QAAA,OAAOF,UAAAA,KAAe,IAAI,CAAC,WAAW,IAAI,CAACF,UAAAA,CAAWI,MAAM,CAACC,OAAO,GAAGF,MAAAA,GAASG,SAAAA;AACpF,IAAA;IAEAC,KAAAA,GAAc;QACV,IAAI,CAAC,WAAW,EAAER,KAAAA,EAAAA;QAClB,IAAI,CAAC,WAAW,EAAA;QAChB,IAAI,CAAC,WAAW,GAAGO,SAAAA;AACvB,IAAA;AACJ;;"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
|
|
6
|
+
const emptyOutputs = {
|
|
7
|
+
setOutput: ()=>undefined,
|
|
8
|
+
clearOutput: ()=>undefined,
|
|
9
|
+
clearAll: ()=>undefined
|
|
10
|
+
};
|
|
11
|
+
const Context = /*#__PURE__*/ react.createContext(undefined);
|
|
12
|
+
/**
|
|
13
|
+
* Tracks component output properties for typed component-property bindings and clears them with component lifecycle.
|
|
14
|
+
*/ function BindingOutputProvider({ children, onOutputsChanged }) {
|
|
15
|
+
const [outputs, setOutputs] = react.useState({});
|
|
16
|
+
react.useEffect(()=>{
|
|
17
|
+
onOutputsChanged?.(outputs);
|
|
18
|
+
}, [
|
|
19
|
+
onOutputsChanged,
|
|
20
|
+
outputs
|
|
21
|
+
]);
|
|
22
|
+
const outputFor = react.useCallback((elementId)=>({
|
|
23
|
+
setOutput: (property, propertyValue)=>setOutputs((current)=>({
|
|
24
|
+
...current,
|
|
25
|
+
[elementId]: {
|
|
26
|
+
...current[elementId] ?? {},
|
|
27
|
+
[property]: propertyValue
|
|
28
|
+
}
|
|
29
|
+
})),
|
|
30
|
+
clearOutput: (property)=>setOutputs((current)=>{
|
|
31
|
+
const elementOutputs = {
|
|
32
|
+
...current[elementId] ?? {}
|
|
33
|
+
};
|
|
34
|
+
delete elementOutputs[property];
|
|
35
|
+
return {
|
|
36
|
+
...current,
|
|
37
|
+
[elementId]: elementOutputs
|
|
38
|
+
};
|
|
39
|
+
}),
|
|
40
|
+
clearAll: ()=>setOutputs((current)=>{
|
|
41
|
+
const next = {
|
|
42
|
+
...current
|
|
43
|
+
};
|
|
44
|
+
delete next[elementId];
|
|
45
|
+
return next;
|
|
46
|
+
})
|
|
47
|
+
}), []);
|
|
48
|
+
const value = react.useMemo(()=>({
|
|
49
|
+
outputs,
|
|
50
|
+
outputFor
|
|
51
|
+
}), [
|
|
52
|
+
outputs,
|
|
53
|
+
outputFor
|
|
54
|
+
]);
|
|
55
|
+
return /*#__PURE__*/ jsxRuntime.jsx(Context.Provider, {
|
|
56
|
+
value: value,
|
|
57
|
+
children: children
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function useBindingOutputs(elementId) {
|
|
61
|
+
const outputFor = react.useContext(Context)?.outputFor;
|
|
62
|
+
return react.useMemo(()=>outputFor?.(elementId) ?? emptyOutputs, [
|
|
63
|
+
outputFor,
|
|
64
|
+
elementId
|
|
65
|
+
]);
|
|
66
|
+
}
|
|
67
|
+
function useBindingOutputScope() {
|
|
68
|
+
return react.useContext(Context)?.outputs ?? {};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
exports.BindingOutputProvider = BindingOutputProvider;
|
|
72
|
+
exports.useBindingOutputScope = useBindingOutputScope;
|
|
73
|
+
exports.useBindingOutputs = useBindingOutputs;
|
|
74
|
+
//# sourceMappingURL=BindingOutputContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BindingOutputContext.js","sources":["../../../renderer/BindingOutputContext.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ReactNode, createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';\n\nexport interface ComponentBindingOutputs {\n setOutput(property: string, value: unknown): void;\n clearOutput(property: string): void;\n clearAll(): void;\n}\n\nexport interface BindingOutputProviderValue {\n outputs: Record<string, Record<string, unknown>>;\n outputFor(elementId: string): ComponentBindingOutputs;\n}\n\nconst emptyOutputs: ComponentBindingOutputs = {\n setOutput: () => undefined,\n clearOutput: () => undefined,\n clearAll: () => undefined,\n};\n\nconst Context = createContext<BindingOutputProviderValue | undefined>(undefined);\n\nexport interface BindingOutputProviderProps {\n children: ReactNode;\n onOutputsChanged?: (outputs: Record<string, Record<string, unknown>>) => void;\n}\n\n/**\n * Tracks component output properties for typed component-property bindings and clears them with component lifecycle.\n */\nexport function BindingOutputProvider({ children, onOutputsChanged }: BindingOutputProviderProps) {\n const [outputs, setOutputs] = useState<Record<string, Record<string, unknown>>>({});\n\n useEffect(() => {\n onOutputsChanged?.(outputs);\n }, [onOutputsChanged, outputs]);\n\n const outputFor = useCallback((elementId: string): ComponentBindingOutputs => ({\n setOutput: (property: string, propertyValue: unknown) => setOutputs(current => ({\n ...current,\n [elementId]: { ...(current[elementId] ?? {}), [property]: propertyValue },\n })),\n clearOutput: (property: string) => setOutputs(current => {\n const elementOutputs = { ...(current[elementId] ?? {}) };\n delete elementOutputs[property];\n return { ...current, [elementId]: elementOutputs };\n }),\n clearAll: () => setOutputs(current => {\n const next = { ...current };\n delete next[elementId];\n return next;\n }),\n }), []);\n\n const value = useMemo<BindingOutputProviderValue>(() => ({ outputs, outputFor }), [outputs, outputFor]);\n\n return <Context.Provider value={value}>{children}</Context.Provider>;\n}\n\nexport function useBindingOutputs(elementId: string): ComponentBindingOutputs {\n const outputFor = useContext(Context)?.outputFor;\n return useMemo(() => outputFor?.(elementId) ?? emptyOutputs, [outputFor, elementId]);\n}\n\nexport function useBindingOutputScope(): Record<string, Record<string, unknown>> {\n return useContext(Context)?.outputs ?? {};\n}\n"],"names":["emptyOutputs","setOutput","undefined","clearOutput","clearAll","Context","createContext","BindingOutputProvider","children","onOutputsChanged","outputs","setOutputs","useState","useEffect","outputFor","useCallback","elementId","property","propertyValue","current","elementOutputs","next","value","useMemo","_jsx","Provider","useBindingOutputs","useContext","useBindingOutputScope"],"mappings":";;;;;AAgBA,MAAMA,YAAAA,GAAwC;AAC1CC,IAAAA,SAAAA,EAAW,IAAMC,SAAAA;AACjBC,IAAAA,WAAAA,EAAa,IAAMD,SAAAA;AACnBE,IAAAA,QAAAA,EAAU,IAAMF;AACpB,CAAA;AAEA,MAAMG,wBAAUC,mBAAAA,CAAsDJ,SAAAA,CAAAA;AAOtE;;AAEC,IACM,SAASK,qBAAAA,CAAsB,EAAEC,QAAQ,EAAEC,gBAAgB,EAA8B,EAAA;AAC5F,IAAA,MAAM,CAACC,OAAAA,EAASC,UAAAA,CAAW,GAAGC,eAAkD,EAAC,CAAA;IAEjFC,eAAAA,CAAU,IAAA;QACNJ,gBAAAA,GAAmBC,OAAAA,CAAAA;IACvB,CAAA,EAAG;AAACD,QAAAA,gBAAAA;AAAkBC,QAAAA;AAAQ,KAAA,CAAA;AAE9B,IAAA,MAAMI,SAAAA,GAAYC,iBAAAA,CAAY,CAACC,SAAAA,IAAgD;AAC3Ef,YAAAA,SAAAA,EAAW,CAACgB,QAAAA,EAAkBC,aAAAA,GAA2BP,UAAAA,CAAWQ,CAAAA,WAAY;AAC5E,wBAAA,GAAGA,OAAO;AACV,wBAAA,CAACH,YAAY;AAAE,4BAAA,GAAIG,OAAO,CAACH,SAAAA,CAAU,IAAI,EAAE;AAAG,4BAAA,CAAC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;"}
|
|
@@ -4,6 +4,8 @@ var react = require('react');
|
|
|
4
4
|
require('react/jsx-runtime');
|
|
5
5
|
var useInteractions = require('../interactions/useInteractions.js');
|
|
6
6
|
require('../interactions/NotificationHost.js');
|
|
7
|
+
var BindingOutputContext = require('./BindingOutputContext.js');
|
|
8
|
+
var RenderBindingScopeContext = require('./RenderBindingScopeContext.js');
|
|
7
9
|
|
|
8
10
|
// Copyright (c) Cratis. All rights reserved.
|
|
9
11
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
@@ -15,12 +17,45 @@ require('../interactions/NotificationHost.js');
|
|
|
15
17
|
* same element tree be rendered by something that is not React at all.
|
|
16
18
|
*/ function InteractiveComponent({ component, element, slots }) {
|
|
17
19
|
const interactions = useInteractions.useInteractions(element.id, element.behaviors);
|
|
18
|
-
|
|
20
|
+
const bindingOutputs = BindingOutputContext.useBindingOutputs(element.id);
|
|
21
|
+
const resolveBinding = RenderBindingScopeContext.useRenderBindingResolver();
|
|
22
|
+
const resolvedElement = react.useMemo(()=>({
|
|
23
|
+
...element,
|
|
24
|
+
properties: resolveProperties(element.properties, resolveBinding)
|
|
25
|
+
}), [
|
|
19
26
|
element,
|
|
27
|
+
resolveBinding
|
|
28
|
+
]);
|
|
29
|
+
react.useEffect(()=>()=>bindingOutputs.clearAll(), [
|
|
30
|
+
element.id
|
|
31
|
+
]);
|
|
32
|
+
return /*#__PURE__*/ react.createElement(component, {
|
|
33
|
+
element: resolvedElement,
|
|
20
34
|
slots,
|
|
21
|
-
interactions
|
|
35
|
+
interactions,
|
|
36
|
+
bindingOutputs
|
|
22
37
|
});
|
|
23
38
|
}
|
|
39
|
+
function resolveProperties(properties, resolveBinding) {
|
|
40
|
+
return Object.fromEntries(Object.entries(properties).map(([name, value])=>[
|
|
41
|
+
name,
|
|
42
|
+
resolveValue(value, resolveBinding)
|
|
43
|
+
]));
|
|
44
|
+
}
|
|
45
|
+
function resolveValue(value, resolveBinding) {
|
|
46
|
+
if (isBindingExpression(value)) return resolveBinding(value);
|
|
47
|
+
if (Array.isArray(value)) return value.map((entry)=>resolveValue(entry, resolveBinding));
|
|
48
|
+
if (value !== null && typeof value === 'object') {
|
|
49
|
+
return Object.fromEntries(Object.entries(value).map(([name, entry])=>[
|
|
50
|
+
name,
|
|
51
|
+
resolveValue(entry, resolveBinding)
|
|
52
|
+
]));
|
|
53
|
+
}
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
function isBindingExpression(value) {
|
|
57
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value) && typeof value.path === 'string';
|
|
58
|
+
}
|
|
24
59
|
|
|
25
60
|
exports.InteractiveComponent = InteractiveComponent;
|
|
26
61
|
//# sourceMappingURL=InteractiveComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InteractiveComponent.js","sources":["../../../renderer/InteractiveComponent.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 { ComponentType, ReactNode, createElement } from 'react';\nimport { ExternalComponent } from '@cratis/scene.model';\nimport { useInteractions } from '../interactions';\nimport { RegisteredComponentProps } from './ComponentRegistry';\n\nexport interface InteractiveComponentProps {\n component: ComponentType<RegisteredComponentProps>;\n element: ExternalComponent;\n slots: Record<string, ReactNode[]>;\n}\n\n/**\n * Resolves an element's interactions and hands them to the component that renders it.\n *\n * This exists as a component rather than as a call inside the renderer because resolving them is a hook, and a\n * hook cannot run inside the plain function a {@link Renderer} is. Keeping the renderer plain is what lets the\n * same element tree be rendered by something that is not React at all.\n */\nexport function InteractiveComponent({ component, element, slots }: InteractiveComponentProps) {\n const interactions = useInteractions(element.id, element.behaviors);\n return createElement(component, { element, slots, interactions });\n}\n"],"names":["InteractiveComponent","component","element","slots","interactions","useInteractions","id","behaviors","createElement"],"mappings":"
|
|
1
|
+
{"version":3,"file":"InteractiveComponent.js","sources":["../../../renderer/InteractiveComponent.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 { ComponentType, ReactNode, createElement, useEffect, useMemo } from 'react';\nimport { BindingExpression, ExternalComponent } from '@cratis/scene.model';\nimport { useInteractions } from '../interactions';\nimport { useBindingOutputs } from './BindingOutputContext';\nimport { RegisteredComponentProps } from './ComponentRegistry';\nimport { useRenderBindingResolver } from './RenderBindingScopeContext';\n\nexport interface InteractiveComponentProps {\n component: ComponentType<RegisteredComponentProps>;\n element: ExternalComponent;\n slots: Record<string, ReactNode[]>;\n}\n\n/**\n * Resolves an element's interactions and hands them to the component that renders it.\n *\n * This exists as a component rather than as a call inside the renderer because resolving them is a hook, and a\n * hook cannot run inside the plain function a {@link Renderer} is. Keeping the renderer plain is what lets the\n * same element tree be rendered by something that is not React at all.\n */\nexport function InteractiveComponent({ component, element, slots }: InteractiveComponentProps) {\n const interactions = useInteractions(element.id, element.behaviors);\n const bindingOutputs = useBindingOutputs(element.id);\n const resolveBinding = useRenderBindingResolver();\n const resolvedElement = useMemo(() => ({\n ...element,\n properties: resolveProperties(element.properties, resolveBinding),\n }), [element, resolveBinding]);\n useEffect(() => () => bindingOutputs.clearAll(), [element.id]);\n return createElement(component, { element: resolvedElement, slots, interactions, bindingOutputs });\n}\n\nfunction resolveProperties(properties: Record<string, unknown>, resolveBinding: (binding: BindingExpression) => unknown): Record<string, unknown> {\n return Object.fromEntries(Object.entries(properties).map(([name, value]) => [name, resolveValue(value, resolveBinding)]));\n}\n\nfunction resolveValue(value: unknown, resolveBinding: (binding: BindingExpression) => unknown): unknown {\n if (isBindingExpression(value)) return resolveBinding(value);\n if (Array.isArray(value)) return value.map(entry => resolveValue(entry, resolveBinding));\n if (value !== null && typeof value === 'object') {\n return Object.fromEntries(Object.entries(value as Record<string, unknown>).map(([name, entry]) => [name, resolveValue(entry, resolveBinding)]));\n }\n\n return value;\n}\n\nfunction isBindingExpression(value: unknown): value is BindingExpression {\n return value !== null && typeof value === 'object' && !Array.isArray(value) && typeof (value as Record<string, unknown>).path === 'string';\n}\n"],"names":["InteractiveComponent","component","element","slots","interactions","useInteractions","id","behaviors","bindingOutputs","useBindingOutputs","resolveBinding","useRenderBindingResolver","resolvedElement","useMemo","properties","resolveProperties","useEffect","clearAll","createElement","Object","fromEntries","entries","map","name","value","resolveValue","isBindingExpression","Array","isArray","entry","path"],"mappings":";;;;;;;;;AAAA;AACA;AAeA;;;;;;IAOO,SAASA,oBAAAA,CAAqB,EAAEC,SAAS,EAAEC,OAAO,EAAEC,KAAK,EAA6B,EAAA;AACzF,IAAA,MAAMC,eAAeC,+BAAAA,CAAgBH,OAAAA,CAAQI,EAAE,EAAEJ,QAAQK,SAAS,CAAA;IAClE,MAAMC,cAAAA,GAAiBC,sCAAAA,CAAkBP,OAAAA,CAAQI,EAAE,CAAA;AACnD,IAAA,MAAMI,cAAAA,GAAiBC,kDAAAA,EAAAA;IACvB,MAAMC,eAAAA,GAAkBC,aAAAA,CAAQ,KAAO;AACnC,YAAA,GAAGX,OAAO;YACVY,UAAAA,EAAYC,iBAAAA,CAAkBb,OAAAA,CAAQY,UAAU,EAAEJ,cAAAA;AACtD,SAAA,CAAA,EAAI;AAACR,QAAAA,OAAAA;AAASQ,QAAAA;AAAe,KAAA,CAAA;AAC7BM,IAAAA,eAAAA,CAAU,IAAM,IAAMR,cAAAA,CAAeS,QAAQ,EAAA,EAAI;AAACf,QAAAA,OAAAA,CAAQI;AAAG,KAAA,CAAA;AAC7D,IAAA,qBAAOY,oBAAcjB,SAAAA,EAAW;QAAEC,OAAAA,EAASU,eAAAA;AAAiBT,QAAAA,KAAAA;AAAOC,QAAAA,YAAAA;AAAcI,QAAAA;AAAe,KAAA,CAAA;AACpG;AAEA,SAASO,iBAAAA,CAAkBD,UAAmC,EAAEJ,cAAuD,EAAA;AACnH,IAAA,OAAOS,MAAAA,CAAOC,WAAW,CAACD,MAAAA,CAAOE,OAAO,CAACP,UAAAA,CAAAA,CAAYQ,GAAG,CAAC,CAAC,CAACC,IAAAA,EAAMC,MAAM,GAAK;AAACD,YAAAA,IAAAA;AAAME,YAAAA,YAAAA,CAAaD,KAAAA,EAAOd,cAAAA;AAAgB,SAAA,CAAA,CAAA;AAC3H;AAEA,SAASe,YAAAA,CAAaD,KAAc,EAAEd,cAAuD,EAAA;IACzF,IAAIgB,mBAAAA,CAAoBF,KAAAA,CAAAA,EAAQ,OAAOd,cAAAA,CAAec,KAAAA,CAAAA;IACtD,IAAIG,KAAAA,CAAMC,OAAO,CAACJ,KAAAA,CAAAA,EAAQ,OAAOA,KAAAA,CAAMF,GAAG,CAACO,CAAAA,KAAAA,GAASJ,YAAAA,CAAaI,KAAAA,EAAOnB,cAAAA,CAAAA,CAAAA;AACxE,IAAA,IAAIc,KAAAA,KAAU,IAAA,IAAQ,OAAOA,KAAAA,KAAU,QAAA,EAAU;AAC7C,QAAA,OAAOL,MAAAA,CAAOC,WAAW,CAACD,MAAAA,CAAOE,OAAO,CAACG,KAAAA,CAAAA,CAAkCF,GAAG,CAAC,CAAC,CAACC,IAAAA,EAAMM,MAAM,GAAK;AAACN,gBAAAA,IAAAA;AAAME,gBAAAA,YAAAA,CAAaI,KAAAA,EAAOnB,cAAAA;AAAgB,aAAA,CAAA,CAAA;AACjJ,IAAA;IAEA,OAAOc,KAAAA;AACX;AAEA,SAASE,oBAAoBF,KAAc,EAAA;AACvC,IAAA,OAAOA,KAAAA,KAAU,IAAA,IAAQ,OAAOA,KAAAA,KAAU,YAAY,CAACG,KAAAA,CAAMC,OAAO,CAACJ,KAAAA,CAAAA,IAAU,OAAO,KAACA,CAAkCM,IAAI,KAAK,QAAA;AACtI;;"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var scene_engine = require('@cratis/scene.engine');
|
|
6
|
+
var scene_model = require('@cratis/scene.model');
|
|
7
|
+
var BindingOutputContext = require('./BindingOutputContext.js');
|
|
8
|
+
|
|
9
|
+
const Context = /*#__PURE__*/ react.createContext(undefined);
|
|
10
|
+
/**
|
|
11
|
+
* Provides the inherited reactive binding scope for a rendered Scene tree.
|
|
12
|
+
*/ function RenderBindingScopeProvider(props) {
|
|
13
|
+
const current = react.useContext(Context);
|
|
14
|
+
if (current) return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
15
|
+
children: props.children
|
|
16
|
+
});
|
|
17
|
+
return /*#__PURE__*/ jsxRuntime.jsx(BindingOutputContext.BindingOutputProvider, {
|
|
18
|
+
onOutputsChanged: props.onComponentOutputsChanged,
|
|
19
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(RenderBindingScopeInner, {
|
|
20
|
+
...props
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function RenderBindingScopeInner({ children, dataContext, queryResults, componentOutputs, resolveBinding }) {
|
|
25
|
+
const outputs = BindingOutputContext.useBindingOutputScope();
|
|
26
|
+
const previousValues = react.useRef(new Map());
|
|
27
|
+
const scope = react.useMemo(()=>({
|
|
28
|
+
dataContext,
|
|
29
|
+
queryResults,
|
|
30
|
+
componentOutputs: {
|
|
31
|
+
...componentOutputs ?? {},
|
|
32
|
+
...outputs
|
|
33
|
+
}
|
|
34
|
+
}), [
|
|
35
|
+
componentOutputs,
|
|
36
|
+
dataContext,
|
|
37
|
+
outputs,
|
|
38
|
+
queryResults
|
|
39
|
+
]);
|
|
40
|
+
const resolver = react.useCallback((binding)=>{
|
|
41
|
+
if (!binding.kind && resolveBinding) return resolveBinding(binding);
|
|
42
|
+
const key = JSON.stringify(binding);
|
|
43
|
+
const value = scene_engine.resolveBindingExpression(binding, scope);
|
|
44
|
+
if (binding.nullBehavior === scene_model.BindingNullBehavior.Preserve && value === undefined) {
|
|
45
|
+
return previousValues.current.get(key);
|
|
46
|
+
}
|
|
47
|
+
if (value !== undefined) previousValues.current.set(key, value);
|
|
48
|
+
return value;
|
|
49
|
+
}, [
|
|
50
|
+
resolveBinding,
|
|
51
|
+
scope
|
|
52
|
+
]);
|
|
53
|
+
const value = react.useMemo(()=>({
|
|
54
|
+
resolveBinding: resolver,
|
|
55
|
+
scope
|
|
56
|
+
}), [
|
|
57
|
+
resolver,
|
|
58
|
+
scope
|
|
59
|
+
]);
|
|
60
|
+
return /*#__PURE__*/ jsxRuntime.jsx(Context.Provider, {
|
|
61
|
+
value: value,
|
|
62
|
+
children: children
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function useRenderBindingResolver() {
|
|
66
|
+
const context = react.useContext(Context);
|
|
67
|
+
if (!context) throw new Error('No Scene render binding scope is available.');
|
|
68
|
+
return context.resolveBinding;
|
|
69
|
+
}
|
|
70
|
+
function useRenderBindingScope() {
|
|
71
|
+
return react.useContext(Context)?.scope ?? {};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
exports.RenderBindingScopeProvider = RenderBindingScopeProvider;
|
|
75
|
+
exports.useRenderBindingResolver = useRenderBindingResolver;
|
|
76
|
+
exports.useRenderBindingScope = useRenderBindingScope;
|
|
77
|
+
//# sourceMappingURL=RenderBindingScopeContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RenderBindingScopeContext.js","sources":["../../../renderer/RenderBindingScopeContext.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ReactNode, createContext, useCallback, useContext, useMemo, useRef } from 'react';\nimport { BindingResolver, BindingScope, resolveBindingExpression } from '@cratis/scene.engine';\nimport { BindingExpression, BindingNullBehavior } from '@cratis/scene.model';\nimport { BindingOutputProvider, useBindingOutputScope } from './BindingOutputContext';\n\ninterface RenderBindingScopeValue {\n resolveBinding: BindingResolver;\n scope: BindingScope;\n}\n\nconst Context = createContext<RenderBindingScopeValue | undefined>(undefined);\n\nexport interface RenderBindingScopeProviderProps {\n children: ReactNode;\n dataContext?: unknown;\n queryResults?: Record<string, unknown>;\n componentOutputs?: Record<string, Record<string, unknown>>;\n resolveBinding?: BindingResolver;\n onComponentOutputsChanged?: (outputs: Record<string, Record<string, unknown>>) => void;\n}\n\n/**\n * Provides the inherited reactive binding scope for a rendered Scene tree.\n */\nexport function RenderBindingScopeProvider(props: RenderBindingScopeProviderProps) {\n const current = useContext(Context);\n if (current) return <>{props.children}</>;\n\n return (\n <BindingOutputProvider onOutputsChanged={props.onComponentOutputsChanged}>\n <RenderBindingScopeInner {...props} />\n </BindingOutputProvider>\n );\n}\n\nfunction RenderBindingScopeInner({ children, dataContext, queryResults, componentOutputs, resolveBinding }: RenderBindingScopeProviderProps) {\n const outputs = useBindingOutputScope();\n const previousValues = useRef(new Map<string, unknown>());\n const scope = useMemo<BindingScope>(() => ({\n dataContext,\n queryResults,\n componentOutputs: { ...(componentOutputs ?? {}), ...outputs },\n }), [componentOutputs, dataContext, outputs, queryResults]);\n\n const resolver = useCallback<BindingResolver>((binding: BindingExpression) => {\n if (!binding.kind && resolveBinding) return resolveBinding(binding);\n\n const key = JSON.stringify(binding);\n const value = resolveBindingExpression(binding, scope);\n if (binding.nullBehavior === BindingNullBehavior.Preserve && value === undefined) {\n return previousValues.current.get(key);\n }\n\n if (value !== undefined) previousValues.current.set(key, value);\n return value;\n }, [resolveBinding, scope]);\n\n const value = useMemo<RenderBindingScopeValue>(() => ({ resolveBinding: resolver, scope }), [resolver, scope]);\n return <Context.Provider value={value}>{children}</Context.Provider>;\n}\n\nexport function useRenderBindingResolver(): BindingResolver {\n const context = useContext(Context);\n if (!context) throw new Error('No Scene render binding scope is available.');\n return context.resolveBinding;\n}\n\nexport function useRenderBindingScope(): BindingScope {\n return useContext(Context)?.scope ?? {};\n}\n"],"names":["Context","createContext","undefined","RenderBindingScopeProvider","props","current","useContext","_jsx","_Fragment","children","BindingOutputProvider","onOutputsChanged","onComponentOutputsChanged","RenderBindingScopeInner","dataContext","queryResults","componentOutputs","resolveBinding","outputs","useBindingOutputScope","previousValues","useRef","Map","scope","useMemo","resolver","useCallback","binding","kind","key","JSON","stringify","value","resolveBindingExpression","nullBehavior","BindingNullBehavior","Preserve","get","set","Provider","useRenderBindingResolver","context","Error","useRenderBindingScope"],"mappings":";;;;;;;;AAaA,MAAMA,wBAAUC,mBAAAA,CAAmDC,SAAAA,CAAAA;AAWnE;;IAGO,SAASC,0BAAAA,CAA2BC,KAAsC,EAAA;AAC7E,IAAA,MAAMC,UAAUC,gBAAAA,CAAWN,OAAAA,CAAAA;AAC3B,IAAA,IAAIK,SAAS,qBAAOE,cAAA,CAAAC,mBAAA,EAAA;AAAGJ,QAAAA,QAAAA,EAAAA,KAAAA,CAAMK;;AAE7B,IAAA,qBACIF,cAAA,CAACG,0CAAAA,EAAAA;AAAsBC,QAAAA,gBAAAA,EAAkBP,MAAMQ,yBAAyB;AACpE,QAAA,QAAA,gBAAAL,cAAA,CAACM,uBAAAA,EAAAA;AAAyB,YAAA,GAAGT;;;AAGzC;AAEA,SAASS,uBAAAA,CAAwB,EAAEJ,QAAQ,EAAEK,WAAW,EAAEC,YAAY,EAAEC,gBAAgB,EAAEC,cAAc,EAAmC,EAAA;AACvI,IAAA,MAAMC,OAAAA,GAAUC,0CAAAA,EAAAA;IAChB,MAAMC,cAAAA,GAAiBC,aAAO,IAAIC,GAAAA,EAAAA,CAAAA;IAClC,MAAMC,KAAAA,GAAQC,aAAAA,CAAsB,KAAO;AACvCV,YAAAA,WAAAA;AACAC,YAAAA,YAAAA;YACAC,gBAAAA,EAAkB;gBAAE,GAAIA,gBAAAA,IAAoB,EAAE;AAAG,gBAAA,GAAGE;AAAQ;AAChE,SAAA,CAAA,EAAI;AAACF,QAAAA,gBAAAA;AAAkBF,QAAAA,WAAAA;AAAaI,QAAAA,OAAAA;AAASH,QAAAA;AAAa,KAAA,CAAA;IAE1D,MAAMU,QAAAA,GAAWC,kBAA6B,CAACC,OAAAA,GAAAA;AAC3C,QAAA,IAAI,CAACA,OAAAA,CAAQ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derer';
|
|
|
4
4
|
export interface SceneElementViewProps {
|
|
5
5
|
element: SceneElement;
|
|
6
6
|
registry: ComponentRegistry;
|
|
7
|
-
resolveBinding
|
|
7
|
+
resolveBinding?: BindingResolver;
|
|
8
|
+
dataContext?: unknown;
|
|
9
|
+
queryResults?: Record<string, unknown>;
|
|
10
|
+
componentOutputs?: Record<string, Record<string, unknown>>;
|
|
8
11
|
configuration?: EffectiveConfiguration;
|
|
12
|
+
onComponentOutputsChanged?: (outputs: Record<string, Record<string, unknown>>) => void;
|
|
9
13
|
}
|
|
10
|
-
export declare function SceneElementView({ element, registry, resolveBinding, configuration }: SceneElementViewProps): import("react").JSX.Element;
|
|
14
|
+
export declare function SceneElementView({ element, registry, resolveBinding, configuration, onComponentOutputsChanged, dataContext, queryResults, componentOutputs, }: SceneElementViewProps): import("react").JSX.Element;
|
|
11
15
|
//# sourceMappingURL=SceneElementView.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SceneElementView.d.ts","sourceRoot":"","sources":["../../SceneElementView.tsx"],"names":[],"mappings":"AAIA,OAAO,EAA8C,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACnG,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"SceneElementView.d.ts","sourceRoot":"","sources":["../../SceneElementView.tsx"],"names":[],"mappings":"AAIA,OAAO,EAA8C,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACnG,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAA6E,MAAM,YAAY,CAAC;AAE1H,MAAM,WAAW,qBAAqB;IAClC,OAAO,EAAE,YAAY,CAAC;IACtB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,cAAc,CAAC,EAAE,eAAe,CAAC;IACjC,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;IAQ3D,aAAa,CAAC,EAAE,sBAAsB,CAAC;IAGvC,yBAAyB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK,IAAI,CAAC;CAC1F;AAMD,wBAAgB,gBAAgB,CAAC,EAC7B,OAAO,EACP,QAAQ,EACR,cAAc,EACd,aAAa,EACb,yBAAyB,EACzB,WAAW,EACX,YAAY,EACZ,gBAAgB,GACnB,EAAE,qBAAqB,+BAYvB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { applyEffectiveConfiguration, renderElement } from '@cratis/scene.engine';
|
|
4
|
+
import { RenderBindingScopeProvider, useRenderBindingResolver } from './renderer/RenderBindingScopeContext.js';
|
|
4
5
|
import { createReactRenderer } from './renderer/createReactRenderer.js';
|
|
5
6
|
import './interactions/useInteractions.js';
|
|
6
7
|
import './interactions/NotificationHost.js';
|
|
@@ -8,16 +9,30 @@ import './interactions/NotificationHost.js';
|
|
|
8
9
|
/**
|
|
9
10
|
* Renders a Scene element tree with the real `Scene.React` renderer - the WYSIWYG building block Studio's
|
|
10
11
|
* preview surface and Stage's shipped web bundle both consume unmodified.
|
|
11
|
-
*/ function SceneElementView({ element, registry, resolveBinding, configuration }) {
|
|
12
|
-
const renderer = useMemo(()=>createReactRenderer(registry), [
|
|
13
|
-
registry
|
|
14
|
-
]);
|
|
12
|
+
*/ function SceneElementView({ element, registry, resolveBinding, configuration, onComponentOutputsChanged, dataContext, queryResults, componentOutputs }) {
|
|
15
13
|
const configured = useMemo(()=>configuration ? applyEffectiveConfiguration(element, configuration) : element, [
|
|
16
14
|
element,
|
|
17
15
|
configuration
|
|
18
16
|
]);
|
|
17
|
+
return /*#__PURE__*/ jsx(RenderBindingScopeProvider, {
|
|
18
|
+
dataContext: dataContext,
|
|
19
|
+
queryResults: queryResults,
|
|
20
|
+
componentOutputs: componentOutputs,
|
|
21
|
+
resolveBinding: resolveBinding,
|
|
22
|
+
onComponentOutputsChanged: onComponentOutputsChanged,
|
|
23
|
+
children: /*#__PURE__*/ jsx(RenderedElement, {
|
|
24
|
+
element: configured,
|
|
25
|
+
registry: registry
|
|
26
|
+
})
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function RenderedElement({ element, registry }) {
|
|
30
|
+
const renderer = useMemo(()=>createReactRenderer(registry), [
|
|
31
|
+
registry
|
|
32
|
+
]);
|
|
33
|
+
const resolveBinding = useRenderBindingResolver();
|
|
19
34
|
return /*#__PURE__*/ jsx(Fragment, {
|
|
20
|
-
children: renderElement(
|
|
35
|
+
children: renderElement(element, renderer, resolveBinding)
|
|
21
36
|
});
|
|
22
37
|
}
|
|
23
38
|
|
|
@@ -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, createReactRenderer } from './renderer';\n\nexport interface SceneElementViewProps {\n element: SceneElement;\n registry: ComponentRegistry;\n resolveBinding
|
|
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,3 +1,7 @@
|
|
|
1
|
+
import 'react/jsx-runtime';
|
|
2
|
+
import 'react';
|
|
3
|
+
import '@cratis/scene.engine';
|
|
4
|
+
import '@cratis/scene.model';
|
|
1
5
|
import { componentRegistryKey } from '../packages/ScenePackageBundle.js';
|
|
2
6
|
import { CoreText } from './CoreText.js';
|
|
3
7
|
import { CoreButton } from './CoreButton.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,oBAAAA,CAAqB,MAAA,EAAQ,MAAA,CAAA,GAAUC,QAAAA;IACxC,CAACD,oBAAAA,CAAqB,MAAA,EAAQ,QAAA,CAAA,GAAYE,UAAAA;IAC1C,CAACF,oBAAAA,CAAqB,MAAA,EAAQ,MAAA,CAAA,GAAUG,QAAAA;IACxC,CAACH,oBAAAA,CAAqB,MAAA,EAAQ,MAAA,CAAA,GAAUI,QAAAA;IACxC,CAACJ,oBAAAA,CAAqB,MAAA,EAAQ,QAAA,CAAA,GAAYK,UAAAA;IAC1C,CAACL,oBAAAA,CAAqB,MAAA,EAAQ,SAAA,CAAA,GAAaM,WAAAA;IAC3C,CAACN,oBAAAA,CAAqB,MAAA,EAAQ,UAAA,CAAA,GAAcO,YAAAA;IAC5C,CAACP,oBAAAA,CAAqB,MAAA,EAAQ,OAAA,CAAA,GAAWQ,SAAAA;IACzC,CAACR,oBAAAA,CAAqB,MAAA,EAAQ,OAAA,CAAA,GAAWS,SAAAA;IACzC,CAACT,oBAAAA,CAAqB,MAAA,EAAQ,QAAA,CAAA,GAAYU,UAAAA;IAC1C,CAACV,oBAAAA,CAAqB,MAAA,EAAQ,SAAA,CAAA,GAAaW,WAAAA;IAC3C,CAACX,oBAAAA,CAAqB,MAAA,EAAQ,OAAA,CAAA,GAAWY,SAAAA;IACzC,CAACZ,oBAAAA,CAAqB,MAAA,EAAQ,MAAA,CAAA,GAAUa,QAAAA;IACxC,CAACb,oBAAAA,CAAqB,MAAA,EAAQ,MAAA,CAAA,GAAUc,QAAAA;IACxC,CAACd,oBAAAA,CAAqB,MAAA,EAAQ,eAAA,CAAA,GAAmBe;AACrD;;"}
|
|
@@ -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,oBAAAA,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,kBAAkBC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,kBAAkBC,MAAM;4BAAEI,WAAAA,EAAa;gCAAEC,QAAAA,EAAU,IAAA;gCAAMG,aAAAA,EAAe;AAAE;AAAE,yBAAA;AAC1I,wBAAA;4BAAEb,IAAAA,EAAM,MAAA;4BAAQC,KAAAA,EAAO,MAAA;4BAAQC,KAAAA,EAAO,SAAA;AAAWC,4BAAAA,SAAAA,EAAWC,kBAAkBU,IAAI;4BAAEN,UAAAA,EAAY;AAAa,yBAAA;AAC7G,wBAAA;4BAAER,IAAAA,EAAM,aAAA;4BAAeC,KAAAA,EAAO,aAAA;4BAAeC,KAAAA,EAAO,SAAA;AAAWC,4BAAAA,SAAAA,EAAWC,kBAAkBW,WAAW;4BAAEP,UAAAA,EAAY,cAAA;4BAAgBC,WAAAA,EAAa;gCAAEC,QAAAA,EAAU;AAAK;AAAE;AACxK;AACL;AACJ;AACH;AACL;;;"}
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAGA,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAGA,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export { SceneElementView } from './SceneElementView.js';
|
|
2
|
+
export { AbortableQueryRunner } from './renderer/AbortableQueryRunner.js';
|
|
3
|
+
export { BindingOutputProvider, useBindingOutputScope, useBindingOutputs } from './renderer/BindingOutputContext.js';
|
|
4
|
+
export { RenderBindingScopeProvider, useRenderBindingResolver, useRenderBindingScope } from './renderer/RenderBindingScopeContext.js';
|
|
2
5
|
export { UnresolvedComponent } from './renderer/UnresolvedComponent.js';
|
|
3
6
|
export { createReactRenderer } from './renderer/createReactRenderer.js';
|
|
4
7
|
export { InteractiveComponent } from './renderer/InteractiveComponent.js';
|
|
@@ -12,10 +15,14 @@ export { coreComponents } from './core/coreComponents.js';
|
|
|
12
15
|
export { corePackage, corePackageManifest } from './core/corePackage.js';
|
|
13
16
|
export { NavBar } from './NavBar/NavBar.js';
|
|
14
17
|
export { extractNavigationItem } from './NavBar/extractNavigationItem.js';
|
|
18
|
+
export { resolveDestination } from './navigation/resolveDestination.js';
|
|
15
19
|
export { IconAdapterRegistry, createIconAdapterRegistry } from './icons/IconAdapterRegistry.js';
|
|
16
20
|
export { IconAdapterProvider, useIconAdapters } from './icons/IconAdapterContext.js';
|
|
17
21
|
export { useIconGlyph } from './icons/useIconGlyph.js';
|
|
18
22
|
export { SceneIcon } from './icons/SceneIcon.js';
|
|
23
|
+
export { validateDesignTimeBundle } from './packages/DesignTimeBundle.js';
|
|
24
|
+
export { DesignTimeProvider, useDesignTimeContext } from './packages/DesignTimeProvider.js';
|
|
25
|
+
export { resolvePackageHost } from './packages/PackageHostConfiguration.js';
|
|
19
26
|
export { componentRegistryKey, mergeIconAdapters, mergePackageRegistries, validatePackageBundle } from './packages/ScenePackageBundle.js';
|
|
20
27
|
export { validateComponentsUiLibraryContract, validateComponentsUiLibraryMapping } from './packages/ComponentsUiLibraryContract.js';
|
|
21
28
|
export { applyThemeTokens, themeTokenPrefix, themeTokenProperty } from './theme/themeTokens.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,10 @@
|
|
|
1
|
+
import { DestinationKind } from '@cratis/scene.model';
|
|
2
|
+
export interface DestinationResolution {
|
|
3
|
+
kind: DestinationKind;
|
|
4
|
+
url?: string;
|
|
5
|
+
outlet?: string;
|
|
6
|
+
dialog?: string;
|
|
7
|
+
action: 'navigate' | 'openDialog' | 'openExternal';
|
|
8
|
+
diagnostics: string[];
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=DestinationResolution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DestinationResolution.d.ts","sourceRoot":"","sources":["../../../navigation/DestinationResolution.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,WAAW,qBAAqB;IAClC,IAAI,EAAE,eAAe,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,UAAU,GAAG,YAAY,GAAG,cAAc,CAAC;IACnD,WAAW,EAAE,MAAM,EAAE,CAAC;CACzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DestinationResolution.js","sourceRoot":"","sources":["../../../navigation/DestinationResolution.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../navigation/index.ts"],"names":[],"mappings":"AAGA,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../navigation/index.ts"],"names":[],"mappings":"AAGA,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BindingScope } from '@cratis/scene.engine';
|
|
2
|
+
import { DestinationReference } from '@cratis/scene.model';
|
|
3
|
+
import { DestinationResolution } from './DestinationResolution';
|
|
4
|
+
export declare function resolveDestination(destination: DestinationReference, scope?: BindingScope): DestinationResolution;
|
|
5
|
+
//# sourceMappingURL=resolveDestination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveDestination.d.ts","sourceRoot":"","sources":["../../../navigation/resolveDestination.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAA4B,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAmB,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,oBAAoB,EAAE,KAAK,GAAE,YAAiB,GAAG,qBAAqB,CAiBrH"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { resolveBindingExpression } from '@cratis/scene.engine';
|
|
2
|
+
import { DestinationKind } from '@cratis/scene.model';
|
|
3
|
+
|
|
4
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
5
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
6
|
+
/**
|
|
7
|
+
* Resolves a destination into a renderer-neutral navigation action, deep link and target outlet/dialog.
|
|
8
|
+
*/ function resolveDestination(destination, scope = {}) {
|
|
9
|
+
const diagnostics = [];
|
|
10
|
+
const kind = destination.kind ?? (destination.dialog ? DestinationKind.Dialog : DestinationKind.Outlet);
|
|
11
|
+
const parameters = Object.entries(destination.routeParameterBindings ?? {}).map(([name, binding])=>[
|
|
12
|
+
name,
|
|
13
|
+
String(resolveBindingExpression(binding, scope) ?? '')
|
|
14
|
+
]);
|
|
15
|
+
const base = destination.route ?? identityRoute(destination);
|
|
16
|
+
if (!base && kind !== DestinationKind.Dialog) diagnostics.push('Destination has no routeable screen, stable identity or route.');
|
|
17
|
+
const url = base ? appendParameters(base, parameters) : undefined;
|
|
18
|
+
return {
|
|
19
|
+
kind,
|
|
20
|
+
url,
|
|
21
|
+
outlet: destination.outlet,
|
|
22
|
+
dialog: destination.dialog,
|
|
23
|
+
action: kind === DestinationKind.Dialog ? 'openDialog' : kind === DestinationKind.External ? 'openExternal' : 'navigate',
|
|
24
|
+
diagnostics
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function identityRoute(destination) {
|
|
28
|
+
if (destination.screen) return destination.screen;
|
|
29
|
+
const parts = [
|
|
30
|
+
destination.module,
|
|
31
|
+
destination.feature,
|
|
32
|
+
destination.slice
|
|
33
|
+
].filter((part)=>typeof part === 'string' && part.length > 0);
|
|
34
|
+
return parts.length ? parts.join('/') : undefined;
|
|
35
|
+
}
|
|
36
|
+
function appendParameters(route, parameters) {
|
|
37
|
+
if (!parameters.length) return route;
|
|
38
|
+
let replaced = route;
|
|
39
|
+
const unused = [];
|
|
40
|
+
for (const [name, value] of parameters){
|
|
41
|
+
const marker = `{${name}}`;
|
|
42
|
+
if (replaced.includes(marker)) {
|
|
43
|
+
replaced = replaced.split(marker).join(encodeURIComponent(value));
|
|
44
|
+
} else {
|
|
45
|
+
unused.push(`${encodeURIComponent(name)}=${encodeURIComponent(value)}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return unused.length ? `${replaced}?${unused.join('&')}` : replaced;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { resolveDestination };
|
|
52
|
+
//# sourceMappingURL=resolveDestination.js.map
|