@cratis/scene.react 3.2.0 → 3.3.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 +72 -0
- package/core/coreComponents.ts +24 -0
- package/core/corePackage.ts +16 -1
- package/core/index.ts +1 -0
- package/dist/cjs/NavBar/NavBar.js.map +1 -1
- package/dist/cjs/NavBar/extractNavigationItem.js.map +1 -1
- package/dist/cjs/SceneElementView.js.map +1 -1
- package/dist/cjs/core/CoreButton.js.map +1 -1
- package/dist/cjs/core/CoreCard.js.map +1 -1
- package/dist/cjs/core/CoreText.js.map +1 -1
- package/dist/cjs/core/ScreenplayCoreComponents.js +128 -0
- package/dist/cjs/core/ScreenplayCoreComponents.js.map +1 -0
- package/dist/cjs/core/coreComponents.js +13 -1
- package/dist/cjs/core/coreComponents.js.map +1 -1
- package/dist/cjs/core/corePackage.js +12 -1
- package/dist/cjs/core/corePackage.js.map +1 -1
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/packages/ScenePackageBundle.js.map +1 -1
- package/dist/cjs/renderer/UnresolvedComponent.js.map +1 -1
- package/dist/cjs/renderer/createReactRenderer.js.map +1 -1
- package/dist/cjs/renderer/panelLayout.js.map +1 -1
- package/dist/cjs/theme/SceneThemeProvider.js.map +1 -1
- package/dist/cjs/theme/themeTokens.js.map +1 -1
- package/dist/esm/NavBar/NavBar.js.map +1 -1
- package/dist/esm/NavBar/extractNavigationItem.js.map +1 -1
- package/dist/esm/SceneElementView.js.map +1 -1
- package/dist/esm/core/CoreButton.js.map +1 -1
- package/dist/esm/core/CoreCard.js.map +1 -1
- package/dist/esm/core/CoreText.js.map +1 -1
- package/dist/esm/core/ScreenplayCoreComponents.d.ts +13 -0
- package/dist/esm/core/ScreenplayCoreComponents.d.ts.map +1 -0
- package/dist/esm/core/ScreenplayCoreComponents.js +116 -0
- package/dist/esm/core/ScreenplayCoreComponents.js.map +1 -0
- package/dist/esm/core/coreComponents.d.ts.map +1 -1
- package/dist/esm/core/coreComponents.js +13 -1
- package/dist/esm/core/coreComponents.js.map +1 -1
- package/dist/esm/core/corePackage.d.ts.map +1 -1
- package/dist/esm/core/corePackage.js +12 -1
- package/dist/esm/core/corePackage.js.map +1 -1
- package/dist/esm/core/index.d.ts +1 -0
- package/dist/esm/core/index.d.ts.map +1 -1
- package/dist/esm/core/index.js +1 -0
- package/dist/esm/core/index.js.map +1 -1
- package/dist/esm/for_ScreenplayCoreComponents/when_rendering_a_translated_screen.d.ts +2 -0
- package/dist/esm/for_ScreenplayCoreComponents/when_rendering_a_translated_screen.d.ts.map +1 -0
- package/dist/esm/for_ScreenplayCoreComponents/when_rendering_a_translated_screen.js +46 -0
- package/dist/esm/for_ScreenplayCoreComponents/when_rendering_a_translated_screen.js.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/packages/ScenePackageBundle.js.map +1 -1
- package/dist/esm/renderer/UnresolvedComponent.js.map +1 -1
- package/dist/esm/renderer/createReactRenderer.js.map +1 -1
- package/dist/esm/renderer/panelLayout.js.map +1 -1
- package/dist/esm/theme/SceneThemeProvider.js.map +1 -1
- package/dist/esm/theme/themeTokens.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/for_ScreenplayCoreComponents/when_rendering_a_translated_screen.tsx +60 -0
- package/package.json +11 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panelLayout.js","sources":["../../../renderer/panelLayout.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 type { CSSProperties } from 'react';\nimport { isCanvas, isDockPanel, isGrid, isStackPanel, isWrapPanel } from '@cratis/scene.engine';\nimport { Dock, GridUnitType, Orientation } from '@cratis/scene.model';\nimport type { ColumnDefinition, GridLength, Panel, RowDefinition, SceneElement } from '@cratis/scene.model';\n\n/**\n * Turns a panel into the CSS that arranges it, and a child into the CSS that places it inside one.\n *\n * The panels say what an arrangement *is*; this says what it looks like on the web. A second renderer -\n * native, desktop - answers the same question with its own platform's layout primitives, which is why\n * this lives in `Scene.React` rather than in the model or the engine.\n *\n * Where a panel needs to say something about an individual child - which grid cell, which edge - it does\n * so through that child's own `properties` bag, because the model has no attached properties of its own.\n * The keys are the ones the model's documentation names: `Grid.Row`, `Grid.Column`, `Grid.RowSpan`,\n * `Grid.ColumnSpan` and `Dock`.\n */\n\nconst track = (length: GridLength): string => {\n switch (length.unitType) {\n case GridUnitType.Auto: return 'auto';\n case GridUnitType.Absolute: return `${length.value}px`;\n case GridUnitType.Star: return `${length.value}fr`;\n }\n};\n\nconst bound = (minimum: number, maximum: number, size: string): string =>\n minimum === 0 && !Number.isFinite(maximum)\n ? size\n : `minmax(${minimum}px, ${Number.isFinite(maximum) ? `${maximum}px` : size})`;\n\nconst rowTrack = (row: RowDefinition): string => bound(row.minimumHeight, row.maximumHeight, track(row.height));\nconst columnTrack = (column: ColumnDefinition): string => bound(column.minimumWidth, column.maximumWidth, track(column.width));\n\nconst number = (value: unknown): number | undefined => (typeof value === 'number' ? value : undefined);\n\n/** The CSS that arranges a panel's own children. */\nexport function panelStyle(panel: Panel): CSSProperties | undefined {\n if (isCanvas(panel)) {\n // Absolutely placed children need a positioned ancestor to be placed against, and the canvas is\n // that ancestor rather than whatever happens to be above it.\n return {\n position: 'relative',\n width: panel.extent?.width ?? undefined,\n height: panel.extent?.height ?? undefined,\n };\n }\n\n if (isGrid(panel)) {\n return {\n display: 'grid',\n gridTemplateRows: panel.rows.map(rowTrack).join(' ') || undefined,\n gridTemplateColumns: panel.columns.map(columnTrack).join(' ') || undefined,\n };\n }\n\n if (isDockPanel(panel)) {\n // Docking has no single CSS primitive. A column of rows with a middle that grows is the shape a\n // dock panel actually produces, and `lastChildFill` decides whether the final child is that\n // middle or just another docked edge.\n return { display: 'flex', flexDirection: 'column' };\n }\n\n if (isStackPanel(panel)) {\n return {\n display: 'flex',\n flexDirection: panel.orientation === Orientation.Horizontal ? 'row' : 'column',\n gap: panel.spacing ? `${panel.spacing}px` : undefined,\n };\n }\n\n if (isWrapPanel(panel)) {\n return {\n display: 'flex',\n flexWrap: 'wrap',\n flexDirection: panel.orientation === Orientation.Horizontal ? 'row' : 'column',\n };\n }\n\n return undefined;\n}\n\n/** The CSS that places one child within its panel, or `undefined` when the panel places children implicitly. */\nexport function childStyle(panel: Panel, child: SceneElement, index: number): CSSProperties | undefined {\n const properties = child.properties ?? {};\n\n if (isCanvas(panel)) {\n const left = number(properties['Canvas.Left']);\n const top = number(properties['Canvas.Top']);\n const right = number(properties['Canvas.Right']);\n const bottom = number(properties['Canvas.Bottom']);\n // A child that names no edge is not placed by the canvas at all, so it keeps whatever flow the\n // renderer would otherwise have given it rather than being pinned to the origin.\n if (left === undefined && top === undefined && right === undefined && bottom === undefined) return undefined;\n return { position: 'absolute', left, top, right, bottom };\n }\n\n if (isGrid(panel)) {\n const row = number(properties['Grid.Row']);\n const column = number(properties['Grid.Column']);\n const rowSpan = number(properties['Grid.RowSpan']) ?? 1;\n const columnSpan = number(properties['Grid.ColumnSpan']) ?? 1;\n if (row === undefined && column === undefined) return undefined;\n return {\n gridRow: row === undefined ? undefined : `${row + 1} / span ${rowSpan}`,\n gridColumn: column === undefined ? undefined : `${column + 1} / span ${columnSpan}`,\n };\n }\n\n if (isDockPanel(panel)) {\n const dock = properties['Dock'] as Dock | undefined;\n const isFill = panel.lastChildFill && index === (panel.children?.length ?? 0) - 1;\n if (isFill) return { flex: '1 1 auto', minHeight: 0 };\n // Left and right dock along the cross axis of the column the panel lays out, so they become a row\n // of their own rather than a sibling in the column.\n return dock === Dock.Left || dock === Dock.Right\n ? { alignSelf: dock === Dock.Left ? 'flex-start' : 'flex-end', flex: '0 0 auto' }\n : { flex: '0 0 auto' };\n }\n\n if (isWrapPanel(panel)) {\n if (panel.itemWidth === undefined && panel.itemHeight === undefined) return undefined;\n return { width: panel.itemWidth, height: panel.itemHeight, flex: '0 0 auto' };\n }\n\n return undefined;\n}\n"],"names":["track","length","unitType","GridUnitType","Auto","Absolute","value","Star","bound","minimum","maximum","size","Number","isFinite","rowTrack","row","minimumHeight","maximumHeight","height","columnTrack","column","minimumWidth","maximumWidth","width","number","undefined","panelStyle","panel","isCanvas","position","extent","isGrid","display","gridTemplateRows","rows","map","join","gridTemplateColumns","columns","isDockPanel","flexDirection","isStackPanel","orientation","Orientation","Horizontal","gap","spacing","isWrapPanel","flexWrap","childStyle","child","index","properties","left","top","right","bottom","rowSpan","columnSpan","gridRow","gridColumn","dock","isFill","lastChildFill","children","flex","minHeight","Dock","Left","Right","alignSelf","itemWidth","itemHeight"],"mappings":";;;;;AAAA;AACA;AAOA;;;;;;;;;;;IAaA,MAAMA,QAAQ,CAACC,MAAAA,GAAAA;AACX,IAAA,OAAQA,OAAOC,QAAQ;AACnB,QAAA,KAAKC,yBAAaC,IAAI;YAAE,OAAO,MAAA;AAC/B,QAAA,KAAKD,yBAAaE,QAAQ;AAAE,YAAA,OAAO,CAAA,EAAGJ,MAAAA,CAAOK,KAAK,CAAC,EAAE,CAAC;AACtD,QAAA,KAAKH,yBAAaI,IAAI;AAAE,YAAA,OAAO,CAAA,EAAGN,MAAAA,CAAOK,KAAK,CAAC,EAAE,CAAC;AACtD;AACJ,CAAA;AAEA,MAAME,KAAAA,GAAQ,CAACC,OAAAA,EAAiBC,OAAAA,EAAiBC,IAAAA,GAC7CF,OAAAA,KAAY,CAAA,IAAK,CAACG,MAAAA,CAAOC,QAAQ,CAACH,OAAAA,CAAAA,GAC5BC,OACA,CAAC,OAAO,EAAEF,OAAAA,CAAQ,IAAI,EAAEG,MAAAA,CAAOC,QAAQ,CAACH,OAAAA,CAAAA,GAAW,CAAA,EAAGA,OAAAA,CAAQ,EAAE,CAAC,GAAGC,IAAAA,CAAK,CAAC,CAAC;AAErF,MAAMG,QAAAA,GAAW,CAACC,GAAAA,GAA+BP,KAAAA,CAAMO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AA,CAAKE,KAAK,GAC1C;AAAEC,YAAAA,SAAAA,EAAWT,IAAAA,KAASM,gBAAAA,CAAKC,IAAI,GAAG,YAAA,GAAe,UAAA;YAAYH,IAAAA,EAAM;SAAW,GAC9E;YAAEA,IAAAA,EAAM;AAAW,SAAA;AAC7B,IAAA;AAEA,IAAA,IAAIlB,yBAAYpB,KAAAA,CAAAA,EAAQ;QACpB,IAAIA,KAAAA,CAAM4C,SAAS,KAAK9C,SAAAA,IAAaE,MAAM6C,UAAU,KAAK/C,WAAW,OAAOA,SAAAA;QAC5E,OAAO;AAAEF,YAAAA,KAAAA,EAAOI,MAAM4C,SAAS;AAAErD,YAAAA,MAAAA,EAAQS,MAAM6C,UAAU;YAAEP,IAAAA,EAAM;AAAW,SAAA;AAChF,IAAA;IAEA,OAAOxC,SAAAA;AACX;;;;;"}
|
|
1
|
+
{"version":3,"file":"panelLayout.js","sources":["../../../renderer/panelLayout.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 type { CSSProperties } from 'react';\nimport { isCanvas, isDockPanel, isGrid, isStackPanel, isWrapPanel } from '@cratis/scene.engine';\nimport { Dock, GridUnitType, Orientation } from '@cratis/scene.model';\nimport type { ColumnDefinition, GridLength, Panel, RowDefinition, SceneElement } from '@cratis/scene.model';\n\n/**\n * Turns a panel into the CSS that arranges it, and a child into the CSS that places it inside one.\n *\n * The panels say what an arrangement *is*; this says what it looks like on the web. A second renderer -\n * native, desktop - answers the same question with its own platform's layout primitives, which is why\n * this lives in `Scene.React` rather than in the model or the engine.\n *\n * Where a panel needs to say something about an individual child - which grid cell, which edge - it does\n * so through that child's own `properties` bag, because the model has no attached properties of its own.\n * The keys are the ones the model's documentation names: `Grid.Row`, `Grid.Column`, `Grid.RowSpan`,\n * `Grid.ColumnSpan` and `Dock`.\n */\n\nconst track = (length: GridLength): string => {\n switch (length.unitType) {\n case GridUnitType.Auto: return 'auto';\n case GridUnitType.Absolute: return `${length.value}px`;\n case GridUnitType.Star: return `${length.value}fr`;\n }\n};\n\nconst bound = (minimum: number, maximum: number, size: string): string =>\n minimum === 0 && !Number.isFinite(maximum)\n ? size\n : `minmax(${minimum}px, ${Number.isFinite(maximum) ? `${maximum}px` : size})`;\n\nconst rowTrack = (row: RowDefinition): string => bound(row.minimumHeight, row.maximumHeight, track(row.height));\nconst columnTrack = (column: ColumnDefinition): string => bound(column.minimumWidth, column.maximumWidth, track(column.width));\n\nconst number = (value: unknown): number | undefined => (typeof value === 'number' ? value : undefined);\n\n/** The CSS that arranges a panel's own children. */\nexport function panelStyle(panel: Panel): CSSProperties | undefined {\n if (isCanvas(panel)) {\n // Absolutely placed children need a positioned ancestor to be placed against, and the canvas is\n // that ancestor rather than whatever happens to be above it.\n return {\n position: 'relative',\n width: panel.extent?.width ?? undefined,\n height: panel.extent?.height ?? undefined,\n };\n }\n\n if (isGrid(panel)) {\n return {\n display: 'grid',\n gridTemplateRows: panel.rows.map(rowTrack).join(' ') || undefined,\n gridTemplateColumns: panel.columns.map(columnTrack).join(' ') || undefined,\n };\n }\n\n if (isDockPanel(panel)) {\n // Docking has no single CSS primitive. A column of rows with a middle that grows is the shape a\n // dock panel actually produces, and `lastChildFill` decides whether the final child is that\n // middle or just another docked edge.\n return { display: 'flex', flexDirection: 'column' };\n }\n\n if (isStackPanel(panel)) {\n return {\n display: 'flex',\n flexDirection: panel.orientation === Orientation.Horizontal ? 'row' : 'column',\n gap: panel.spacing ? `${panel.spacing}px` : undefined,\n };\n }\n\n if (isWrapPanel(panel)) {\n return {\n display: 'flex',\n flexWrap: 'wrap',\n flexDirection: panel.orientation === Orientation.Horizontal ? 'row' : 'column',\n };\n }\n\n return undefined;\n}\n\n/** The CSS that places one child within its panel, or `undefined` when the panel places children implicitly. */\nexport function childStyle(panel: Panel, child: SceneElement, index: number): CSSProperties | undefined {\n const properties = child.properties ?? {};\n\n if (isCanvas(panel)) {\n const left = number(properties['Canvas.Left']);\n const top = number(properties['Canvas.Top']);\n const right = number(properties['Canvas.Right']);\n const bottom = number(properties['Canvas.Bottom']);\n // A child that names no edge is not placed by the canvas at all, so it keeps whatever flow the\n // renderer would otherwise have given it rather than being pinned to the origin.\n if (left === undefined && top === undefined && right === undefined && bottom === undefined) return undefined;\n return { position: 'absolute', left, top, right, bottom };\n }\n\n if (isGrid(panel)) {\n const row = number(properties['Grid.Row']);\n const column = number(properties['Grid.Column']);\n const rowSpan = number(properties['Grid.RowSpan']) ?? 1;\n const columnSpan = number(properties['Grid.ColumnSpan']) ?? 1;\n if (row === undefined && column === undefined) return undefined;\n return {\n gridRow: row === undefined ? undefined : `${row + 1} / span ${rowSpan}`,\n gridColumn: column === undefined ? undefined : `${column + 1} / span ${columnSpan}`,\n };\n }\n\n if (isDockPanel(panel)) {\n const dock = properties['Dock'] as Dock | undefined;\n const isFill = panel.lastChildFill && index === (panel.children?.length ?? 0) - 1;\n if (isFill) return { flex: '1 1 auto', minHeight: 0 };\n // Left and right dock along the cross axis of the column the panel lays out, so they become a row\n // of their own rather than a sibling in the column.\n return dock === Dock.Left || dock === Dock.Right\n ? { alignSelf: dock === Dock.Left ? 'flex-start' : 'flex-end', flex: '0 0 auto' }\n : { flex: '0 0 auto' };\n }\n\n if (isWrapPanel(panel)) {\n if (panel.itemWidth === undefined && panel.itemHeight === undefined) return undefined;\n return { width: panel.itemWidth, height: panel.itemHeight, flex: '0 0 auto' };\n }\n\n return undefined;\n}\n"],"names":["track","length","unitType","GridUnitType","Auto","Absolute","value","Star","bound","minimum","maximum","size","Number","isFinite","rowTrack","row","minimumHeight","maximumHeight","height","columnTrack","column","minimumWidth","maximumWidth","width","number","undefined","panelStyle","panel","isCanvas","position","extent","isGrid","display","gridTemplateRows","rows","map","join","gridTemplateColumns","columns","isDockPanel","flexDirection","isStackPanel","orientation","Orientation","Horizontal","gap","spacing","isWrapPanel","flexWrap","childStyle","child","index","properties","left","top","right","bottom","rowSpan","columnSpan","gridRow","gridColumn","dock","isF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,MAAM4C,SAAS;AAAErD,YAAAA,MAAAA,EAAQS,MAAM6C,UAAU;YAAEP,IAAAA,EAAM;AAAW,SAAA;AAChF,IAAA;IAEA,OAAOxC,SAAAA;AACX;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SceneThemeProvider.js","sources":["../../../theme/SceneThemeProvider.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ReactNode, createContext, useContext, useLayoutEffect, useRef } from 'react';\nimport { Theme } from '@cratis/scene.model';\nimport { applyThemeTokens } from './themeTokens';\n\nconst SceneThemeContext = createContext<Theme | undefined>(undefined);\n\n/**\n * The theme currently applied by the nearest {@link SceneThemeProvider}, for a package component that has\n * to make a decision a token cannot express - picking a light or dark logo asset, say.\n */\nexport function useSceneTheme(): Theme | undefined {\n return useContext(SceneThemeContext);\n}\n\nexport interface SceneThemePropsBase {\n /**\n * The theme to apply. Changing it re-resolves in place - no reload, no remount of the subtree.\n */\n theme?: Theme;\n\n /**\n * The content the theme applies to.\n */\n children?: ReactNode;\n\n /**\n * A class name for the element the tokens land on.\n */\n className?: string;\n}\n\n/**\n * Applies a {@link Theme}'s tokens to a wrapping element and makes the theme available to everything\n * inside it.\n *\n * Theme switching is live re-resolution: the tokens are written onto the same element rather than\n * swapping a stylesheet, so a preview changes theme without a flash and without losing any state below\n * it. That is what lets Studio's gallery switch themes as fast as you can click.\n */\nexport function SceneThemeProvider({ theme, children, className }: SceneThemePropsBase) {\n const elementRef = useRef<HTMLDivElement>(null);\n const previousRef = useRef<Theme | undefined>(undefined);\n\n useLayoutEffect(() => {\n if (!elementRef.current) return;\n applyThemeTokens(elementRef.current, theme, previousRef.current);\n previousRef.current = theme;\n }, [theme]);\n\n return (\n <div ref={elementRef} className={className} data-scene-theme-root=''>\n <SceneThemeContext.Provider value={theme}>{children}</SceneThemeContext.Provider>\n </div>\n );\n}\n"],"names":["SceneThemeContext","createContext","undefined","useSceneTheme","useContext","SceneThemeProvider","theme","children","className","elementRef","useRef","previousRef","useLayoutEffect","current","applyThemeTokens","_jsx","div","ref","data-scene-theme-root","Provider","value"],"mappings":";;;;;;AAOA,MAAMA,kCAAoBC,mBAAAA,CAAiCC,SAAAA,CAAAA;AAE3D;;;AAGC,IACM,SAASC,aAAAA,GAAAA;AACZ,IAAA,OAAOC,gBAAAA,CAAWJ,iBAAAA,CAAAA;AACtB;AAmBA;;;;;;;IAQO,SAASK,kBAAAA,CAAmB,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,SAAS,EAAuB,EAAA;AAClF,IAAA,MAAMC,aAAaC,YAAAA,CAAuB,IAAA,CAAA;AAC1C,IAAA,MAAMC,cAAcD,YAAAA,CAA0BR,SAAAA,CAAAA;IAE9CU,qBAAAA,CAAgB,IAAA;QACZ,IAAI,CAACH,UAAAA,CAAWI,OAAO,EAAE;AACzBC,QAAAA,4BAAAA,CAAiBL,UAAAA,CAAWI,OAAO,EAAEP,KAAAA,EAAOK,YAAYE,OAAO,CAAA;AAC/DF,QAAAA,WAAAA,CAAYE,OAAO,GAAGP,KAAAA;IAC1B,CAAA,EAAG;AAACA,QAAAA;AAAM,KAAA,CAAA;AAEV,IAAA,qBACIS,cAAA,CAACC,KAAAA,EAAAA;QAAIC,GAAAA,EAAKR,UAAAA;QAAYD,SAAAA,EAAWA,SAAAA;QAAWU,uBAAAA,EAAsB,EAAA;gCAC9DH,cAAA,CAACf,kBAAkBmB,QAAQ,EAAA;YAACC,KAAAA,EAAOd,KAAAA;AAAQC,YAAAA,QAAAA,EAAAA;;;AAGvD
|
|
1
|
+
{"version":3,"file":"SceneThemeProvider.js","sources":["../../../theme/SceneThemeProvider.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ReactNode, createContext, useContext, useLayoutEffect, useRef } from 'react';\nimport { Theme } from '@cratis/scene.model';\nimport { applyThemeTokens } from './themeTokens';\n\nconst SceneThemeContext = createContext<Theme | undefined>(undefined);\n\n/**\n * The theme currently applied by the nearest {@link SceneThemeProvider}, for a package component that has\n * to make a decision a token cannot express - picking a light or dark logo asset, say.\n */\nexport function useSceneTheme(): Theme | undefined {\n return useContext(SceneThemeContext);\n}\n\nexport interface SceneThemePropsBase {\n /**\n * The theme to apply. Changing it re-resolves in place - no reload, no remount of the subtree.\n */\n theme?: Theme;\n\n /**\n * The content the theme applies to.\n */\n children?: ReactNode;\n\n /**\n * A class name for the element the tokens land on.\n */\n className?: string;\n}\n\n/**\n * Applies a {@link Theme}'s tokens to a wrapping element and makes the theme available to everything\n * inside it.\n *\n * Theme switching is live re-resolution: the tokens are written onto the same element rather than\n * swapping a stylesheet, so a preview changes theme without a flash and without losing any state below\n * it. That is what lets Studio's gallery switch themes as fast as you can click.\n */\nexport function SceneThemeProvider({ theme, children, className }: SceneThemePropsBase) {\n const elementRef = useRef<HTMLDivElement>(null);\n const previousRef = useRef<Theme | undefined>(undefined);\n\n useLayoutEffect(() => {\n if (!elementRef.current) return;\n applyThemeTokens(elementRef.current, theme, previousRef.current);\n previousRef.current = theme;\n }, [theme]);\n\n return (\n <div ref={elementRef} className={className} data-scene-theme-root=''>\n <SceneThemeContext.Provider value={theme}>{children}</SceneThemeContext.Provider>\n </div>\n );\n}\n"],"names":["SceneThemeContext","createContext","undefined","useSceneTheme","useContext","SceneThemeProvider","theme","children","className","elementRef","useRef","previousRef","useLayoutEffect","current","applyThemeTokens","_jsx","div","ref","data-scene-theme-root","Provider","value"],"mappings":";;;;;;AAOA,MAAMA,kCAAoBC,mBAAAA,CAAiCC,SAAAA,CAAAA;AAE3D;;;AAGC,IACM,SAASC,aAAAA,GAAAA;AACZ,IAAA,OAAOC,gBAAAA,CAAWJ,iBAAAA,CAAAA;AACtB;AAmBA;;;;;;;IAQO,SAASK,kBAAAA,CAAmB,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,SAAS,EAAuB,EAAA;AAClF,IAAA,MAAMC,aAAaC,YAAAA,CAAuB,IAAA,CAAA;AAC1C,IAAA,MAAMC,cAAcD,YAAAA,CAA0BR,SAAAA,CAAAA;IAE9CU,qBAAAA,CAAgB,IAAA;QACZ,IAAI,CAACH,UAAAA,CAAWI,OAAO,EAAE;AACzBC,QAAAA,4BAAAA,CAAiBL,UAAAA,CAAWI,OAAO,EAAEP,KAAAA,EAAOK,YAAYE,OAAO,CAAA;AAC/DF,QAAAA,WAAAA,CAAYE,OAAO,GAAGP,KAAAA;IAC1B,CAAA,EAAG;AAACA,QAAAA;AAAM,KAAA,CAAA;AAEV,IAAA,qBACIS,cAAA,CAACC,KAAAA,EAAAA;QAAIC,GAAAA,EAAKR,UAAAA;QAAYD,SAAAA,EAAWA,SAAAA;QAAWU,uBAAAA,EAAsB,EAAA;gCAC9DH,cAAA,CAACf,kBAAkBmB,QAAQ,EAAA;YAACC,KAAAA,EAAOd,KAAAA;AAAQC,YAAAA,QAAAA,EAAAA;;;AAGvD;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"themeTokens.js","sources":["../../../theme/themeTokens.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 { Theme } from '@cratis/scene.model';\n\n/**\n * The prefix every Scene design token gets as a CSS custom property. A package adapts these to whatever\n * its own component library expects — the PrimeReact package maps them onto PrimeReact's variables, the\n * same indirection `@cratis/components` uses for its `--cratis-*` layer — so layout and component CSS\n * never hardcodes one library's variable names.\n */\nexport const themeTokenPrefix = '--scene';\n\n/**\n * Turns a semantic token name into its CSS custom property name: `primary.color` becomes\n * `--scene-primary-color`, `surface.borderColor` becomes `--scene-surface-border-color`.\n *\n * Token names are semantic and platform-neutral in `Scene.Model` on purpose; this is the one place that\n * decides what they look like in CSS, so a non-DOM renderer can make an entirely different choice.\n */\nexport function themeTokenProperty(token: string): string {\n const kebab = token\n .split('.')\n .map((part) => part.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase())\n .join('-');\n return `${themeTokenPrefix}-${kebab}`;\n}\n\n/**\n * Applies a theme to an element, in place.\n *\n * Every token becomes a custom property on the element, and the element is marked with the theme's name\n * and colour scheme so CSS can key off either. Tokens the previous theme set and this one does not are\n * removed, so switching themes cannot leave a stale value behind.\n *\n * This is deliberately a mutation of an existing element rather than a re-render: switching theme has to\n * be live re-resolution against the running profile, with no reload and no remount, or a gallery preview\n * flickers every time someone tries a different theme.\n */\nexport function applyThemeTokens(element: HTMLElement, theme: Theme | undefined, previous?: Theme): void {\n for (const token of Object.keys(previous?.tokens ?? {})) {\n if (!theme?.tokens || !(token in theme.tokens)) {\n element.style.removeProperty(themeTokenProperty(token));\n }\n }\n\n if (!theme) {\n element.removeAttribute('data-scene-theme');\n element.removeAttribute('data-scene-color-scheme');\n return;\n }\n\n for (const [token, value] of Object.entries(theme.tokens ?? {})) {\n element.style.setProperty(themeTokenProperty(token), value);\n }\n\n element.setAttribute('data-scene-theme', theme.name);\n element.setAttribute('data-scene-color-scheme', theme.isDark ? 'dark' : 'light');\n}\n"],"names":["themeTokenPrefix","themeTokenProperty","token","kebab","split","map","part","replace","toLowerCase","join","applyThemeTokens","element","theme","previous","Object","keys","tokens","style","removeProperty","removeAttribute","value","entries","setProperty","setAttribute","name","isDark"],"mappings":";;AAAA;AACA;AAIA;;;;;IAMO,MAAMA,gBAAAA,GAAmB;AAEhC;;;;;;IAOO,SAASC,kBAAAA,CAAmBC,KAAa,EAAA;AAC5C,IAAA,MAAMC,QAAQD,KAAAA,CACTE,KAAK,CAAC,GAAA,CAAA,CACNC,GAAG,CAAC,CAACC,IAAAA,GAASA,IAAAA,CAAKC,OAAO,CAAC,oBAAA,EAAsB,SAASC,WAAW,EAAA,CAAA,CACrEC,IAAI,CAAC,GAAA,CAAA;AACV,IAAA,OAAO,CAAA,EAAGT,gBAAAA,CAAiB,CAAC,EAAEG,KAAAA,CAAAA,CAAO;AACzC;AAEA;;;;;;;;;;AAUC,IACM,SAASO,gBAAAA,CAAiBC,OAAoB,EAAEC,KAAwB,EAAEC,QAAgB,EAAA;IAC7F,KAAK,MAAMX,SAASY,MAAAA,CAAOC,IAAI,CAACF,QAAAA,EAAUG,MAAAA,IAAU,EAAC,CAAA,CAAI;QACrD,IAAI,CAACJ,OAAOI,MAAAA,IAAU,EAAEd,KAAAA,IAASU,KAAAA,CAAMI,MAAK,CAAA,EAAI;AAC5CL,YAAAA,OAAAA,CAAQM,KAAK,CAACC,cAAc,CAACjB,kBAAAA,CAAmBC,KAAAA,CAAAA,CAAAA;AACpD,QAAA;AACJ,IAAA;AAEA,IAAA,IAAI,CAACU,KAAAA,EAAO;AACRD,QAAAA,OAAAA,CAAQQ,eAAe,CAAC,kBAAA,CAAA;AACxBR,QAAAA,OAAAA,CAAQQ,eAAe,CAAC,yBAAA,CAAA;AACxB,QAAA;AACJ,IAAA;AAEA,IAAA,KAAK,MAAM,CAACjB,KAAAA,EAAOkB,KAAAA,CAAM,IAAIN,MAAAA,CAAOO,OAAO,CAACT,KAAAA,CAAMI,MAAM,IAAI,EAAC,CAAA,CAAI;AAC7DL,QAAAA,OAAAA,CAAQM,KAAK,CAACK,WAAW,CAACrB,mBAAmBC,KAAAA,CAAAA,EAAQkB,KAAAA,CAAAA;AACzD,IAAA;AAEAT,IAAAA,OAAAA,CAAQY,YAAY,CAAC,kBAAA,EAAoBX,KAAAA,CAAMY,IAAI,CAAA;AACnDb,IAAAA,OAAAA,CAAQY,YAAY,CAAC,yBAAA,EAA2BX,KAAAA,CAAMa,MAAM,GAAG,MAAA,GAAS,OAAA,CAAA;AAC5E
|
|
1
|
+
{"version":3,"file":"themeTokens.js","sources":["../../../theme/themeTokens.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 { Theme } from '@cratis/scene.model';\n\n/**\n * The prefix every Scene design token gets as a CSS custom property. A package adapts these to whatever\n * its own component library expects — the PrimeReact package maps them onto PrimeReact's variables, the\n * same indirection `@cratis/components` uses for its `--cratis-*` layer — so layout and component CSS\n * never hardcodes one library's variable names.\n */\nexport const themeTokenPrefix = '--scene';\n\n/**\n * Turns a semantic token name into its CSS custom property name: `primary.color` becomes\n * `--scene-primary-color`, `surface.borderColor` becomes `--scene-surface-border-color`.\n *\n * Token names are semantic and platform-neutral in `Scene.Model` on purpose; this is the one place that\n * decides what they look like in CSS, so a non-DOM renderer can make an entirely different choice.\n */\nexport function themeTokenProperty(token: string): string {\n const kebab = token\n .split('.')\n .map((part) => part.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase())\n .join('-');\n return `${themeTokenPrefix}-${kebab}`;\n}\n\n/**\n * Applies a theme to an element, in place.\n *\n * Every token becomes a custom property on the element, and the element is marked with the theme's name\n * and colour scheme so CSS can key off either. Tokens the previous theme set and this one does not are\n * removed, so switching themes cannot leave a stale value behind.\n *\n * This is deliberately a mutation of an existing element rather than a re-render: switching theme has to\n * be live re-resolution against the running profile, with no reload and no remount, or a gallery preview\n * flickers every time someone tries a different theme.\n */\nexport function applyThemeTokens(element: HTMLElement, theme: Theme | undefined, previous?: Theme): void {\n for (const token of Object.keys(previous?.tokens ?? {})) {\n if (!theme?.tokens || !(token in theme.tokens)) {\n element.style.removeProperty(themeTokenProperty(token));\n }\n }\n\n if (!theme) {\n element.removeAttribute('data-scene-theme');\n element.removeAttribute('data-scene-color-scheme');\n return;\n }\n\n for (const [token, value] of Object.entries(theme.tokens ?? {})) {\n element.style.setProperty(themeTokenProperty(token), value);\n }\n\n element.setAttribute('data-scene-theme', theme.name);\n element.setAttribute('data-scene-color-scheme', theme.isDark ? 'dark' : 'light');\n}\n"],"names":["themeTokenPrefix","themeTokenProperty","token","kebab","split","map","part","replace","toLowerCase","join","applyThemeTokens","element","theme","previous","Object","keys","tokens","style","removeProperty","removeAttribute","value","entries","setProperty","setAttribute","name","isDark"],"mappings":";;AAAA;AACA;AAIA;;;;;IAMO,MAAMA,gB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,KAAAA,CAAMY,IAAI,CAAA;AACnDb,IAAAA,OAAAA,CAAQY,YAAY,CAAC,yBAAA,EAA2BX,KAAAA,CAAMa,MAAM,GAAG,MAAA,GAAS,OAAA,CAAA;AAC5E;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavBar.js","sources":["../../../NavBar/NavBar.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 { Contribution, NavigationItem } from '@cratis/scene.model';\nimport { aggregateContributions } from '@cratis/scene.engine';\nimport { extractNavigationItem } from './extractNavigationItem';\n\nexport interface NavBarProps {\n /** Every contribution in scope - `NavBar` aggregates the ones targeting `Navigation` itself. */\n contributions: Contribution[];\n\n /**\n * Turns a {@link NavigationItem}'s target screen and route parameters into a concrete route - a URL\n * path, a query string, or a native deep link. Owning this as a caller-supplied function, rather than\n * a fixed URL scheme, is what makes `NavBar` usable unmodified across renderers (Cratis/Scene#2).\n */\n renderRoute: (item: NavigationItem) => string;\n}\n\n/**\n * Renders the aggregated `Navigation` contributions from across the current element tree - part of\n * Cratis/Scene#2. `NavBar` is not wired to a fixed source: pass it whatever contributions are currently\n * in scope and it recomputes, the same way any contribution-point consumer does.\n */\nexport function NavBar({ contributions, renderRoute }: NavBarProps) {\n const items = aggregateContributions(contributions, 'Navigation')\n .map(extractNavigationItem)\n .filter((item): item is NavigationItem => item !== undefined);\n\n const hasGroups = items.some(item => item.group !== undefined);\n if (!hasGroups) {\n return (\n <nav data-scene-navbar=\"\">\n {items.map(item => <NavBarItem key={item.targetScreen} item={item} href={renderRoute(item)} />)}\n </nav>\n );\n }\n\n const groupNames = [...new Set(items.map(item => item.group ?? ''))];\n return (\n <nav data-scene-navbar=\"\">\n {groupNames.map(groupName => (\n <section key={groupName} data-scene-navbar-group={groupName}>\n {items.filter(item => (item.group ?? '') === groupName).map(item => <NavBarItem key={item.targetScreen} item={item} href={renderRoute(item)} />)}\n </section>\n ))}\n </nav>\n );\n}\n\nfunction NavBarItem({ item, href }: { item: NavigationItem; href: string }) {\n return <a href={href}>{item.label}</a>;\n}\n"],"names":["NavBar","contributions","renderRoute","items","aggregateContributions","map","extractNavigationItem","filter","item","undefined","hasGroups","some","group","_jsx","nav","data-scene-navbar","NavBarItem","href","targetScreen","groupNames","Set","groupName","section","data-scene-navbar-group","a","label"],"mappings":";;;;AAAA;AACA;AAkBA;;;;AAIC,IACM,SAASA,MAAAA,CAAO,EAAEC,aAAa,EAAEC,WAAW,EAAe,EAAA;IAC9D,MAAMC,KAAAA,GAAQC,sBAAAA,CAAuBH,aAAAA,EAAe,YAAA,CAAA,CAC/CI,GAAG,CAACC,qBAAAA,CAAAA,CACJC,MAAM,CAAC,CAACC,IAAAA,GAAiCA,IAAAA,KAASC,SAAAA,CAAAA;IAEvD,MAAMC,SAAAA,GAAYP,MAAMQ,IAAI,CAACH,CAAAA,IAAAA,GAAQA,IAAAA,CAAKI,KAAK,KAAKH,SAAAA,CAAAA;AACpD,IAAA,IAAI,CAACC,SAAAA,EAAW;AACZ,QAAA,qBACIG,GAAA,CAACC,KAAAA,EAAAA;YAAIC,mBAAAA,EAAkB,EAAA;AAClBZ,YAAAA,QAAAA,EAAAA,KAAAA,CAAME,GAAG,CAACG,CAAAA,IAAAA,iBAAQK,GAAA,CAACG,UAAAA,EAAAA;oBAAmCR,IAAAA,EAAMA,IAAAA;AAAMS,oBAAAA,IAAAA,EAAMf,WAAAA,CAAYM,IAAAA;AAAjDA,iBAAAA,EAAAA,IAAAA,CAAKU,YAAY,CAAA;;AAGjE,IAAA;AAEA,IAAA,MAAMC,UAAAA,GAAa;WAAI,IAAIC,GAAAA,CAAIjB,MAAME,GAAG,CAACG,CAAAA,IAAAA,GAAQA,IAAAA,CAAKI,KAAK,IAAI,EAAA,CAAA;AAAK,KAAA;AACpE,IAAA,qBACIC,GAAA,CAACC,KAAAA,EAAAA;QAAIC,mBAAAA,EAAkB,EAAA;AAClBI,QAAAA,QAAAA,EAAAA,UAAAA,CAAWd,GAAG,CAACgB,CAAAA,SAAAA,iBACZR,GAAA,CAACS,SAAAA,EAAAA;gBAAwBC,yBAAAA,EAAyBF,SAAAA;AAC7ClB,gBAAAA,QAAAA,EAAAA,KAAAA,CAAMI,MAAM,CAACC,CAAAA,IAAAA,GAASA,CAAAA,IAAAA,CAAKI,KAAK,IAAI,EAAC,MAAOS,SAAAA,CAAAA,CAAWhB,GAAG,CAACG,CAAAA,qBAAQK,GAAA,CAACG,UAAAA,EAAAA;wBAAmCR,IAAAA,EAAMA,IAAAA;AAAMS,wBAAAA,IAAAA,EAAMf,WAAAA,CAAYM,IAAAA;AAAjDA,qBAAAA,EAAAA,IAAAA,CAAKU,YAAY,CAAA;AAD5FG,aAAAA,EAAAA,SAAAA,CAAAA;;AAM9B;AAEA,SAASL,UAAAA,CAAW,EAAER,IAAI,EAAES,IAAI,EAA0C,EAAA;AACtE,IAAA,qBAAOJ,GAAA,CAACW,GAAAA,EAAAA;QAAEP,IAAAA,EAAMA,IAAAA;AAAOT,QAAAA,QAAAA,EAAAA,IAAAA,CAAKiB;;AAChC
|
|
1
|
+
{"version":3,"file":"NavBar.js","sources":["../../../NavBar/NavBar.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 { Contribution, NavigationItem } from '@cratis/scene.model';\nimport { aggregateContributions } from '@cratis/scene.engine';\nimport { extractNavigationItem } from './extractNavigationItem';\n\nexport interface NavBarProps {\n /** Every contribution in scope - `NavBar` aggregates the ones targeting `Navigation` itself. */\n contributions: Contribution[];\n\n /**\n * Turns a {@link NavigationItem}'s target screen and route parameters into a concrete route - a URL\n * path, a query string, or a native deep link. Owning this as a caller-supplied function, rather than\n * a fixed URL scheme, is what makes `NavBar` usable unmodified across renderers (Cratis/Scene#2).\n */\n renderRoute: (item: NavigationItem) => string;\n}\n\n/**\n * Renders the aggregated `Navigation` contributions from across the current element tree - part of\n * Cratis/Scene#2. `NavBar` is not wired to a fixed source: pass it whatever contributions are currently\n * in scope and it recomputes, the same way any contribution-point consumer does.\n */\nexport function NavBar({ contributions, renderRoute }: NavBarProps) {\n const items = aggregateContributions(contributions, 'Navigation')\n .map(extractNavigationItem)\n .filter((item): item is NavigationItem => item !== undefined);\n\n const hasGroups = items.some(item => item.group !== undefined);\n if (!hasGroups) {\n return (\n <nav data-scene-navbar=\"\">\n {items.map(item => <NavBarItem key={item.targetScreen} item={item} href={renderRoute(item)} />)}\n </nav>\n );\n }\n\n const groupNames = [...new Set(items.map(item => item.group ?? ''))];\n return (\n <nav data-scene-navbar=\"\">\n {groupNames.map(groupName => (\n <section key={groupName} data-scene-navbar-group={groupName}>\n {items.filter(item => (item.group ?? '') === groupName).map(item => <NavBarItem key={item.targetScreen} item={item} href={renderRoute(item)} />)}\n </section>\n ))}\n </nav>\n );\n}\n\nfunction NavBarItem({ item, href }: { item: NavigationItem; href: string }) {\n return <a href={href}>{item.label}</a>;\n}\n"],"names":["NavBar","contributions","renderRoute","items","aggregateContributions","map","extractNavigationItem","filter","item","undefined","hasGroups","some","group","_jsx","nav","data-scene-navbar","NavBarItem","href","targetScreen","groupNames","Set","groupName","section","data-scene-navbar-group","a","label"],"mappings":";;;;AAAA;AACA;AAkBA;;;;AAIC,IACM,SAASA,MAAAA,CAAO,EAAEC,aAAa,EAAEC,WAAW,EAAe,EAAA;IAC9D,MAAMC,KAAAA,GAAQC,sBAAAA,CAAuBH,aAAAA,EAAe,YAAA,CAAA,CAC/CI,GAAG,CAACC,qBAAAA,CAAAA,CACJC,MAAM,CAAC,CAACC,IAAAA,GAAiCA,IAAAA,KAASC,SAAAA,CAAAA;IAEvD,MAAMC,SAAAA,GAAYP,MAAMQ,IAAI,CAACH,CAAAA,IAAAA,GAAQA,IAAAA,CAAKI,KAAK,KAAKH,SAAAA,CAAAA;AACpD,IAAA,IAAI,CAACC,SAAAA,EAAW;AACZ,QAAA,qBACIG,GAAA,CAACC,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C;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractNavigationItem.js","sources":["../../../NavBar/extractNavigationItem.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 { BindingExpression, Contribution, ExternalComponent, NavigationItem } from '@cratis/scene.model';\n\n/**\n * Reads a {@link NavigationItem} out of a {@link Contribution} to the built-in `Navigation` contribution\n * point. `Contribution.content` carries an {@link ExternalComponent} whose open `properties` bag holds the\n * navigation-specific values (`label`, `targetScreen`, `routeParameterBindings`, `order`, `group`) - the\n * same names as {@link NavigationItem}'s own fields. This property-bag contract is Scene#2's own choice,\n * made without a real Screenplay-to-Scene translation to confirm it against (Stage#37 hasn't been built\n * yet) - whoever builds that seam should either produce contributions matching this contract or this\n * function should move to match whatever Stage#37 actually emits.\n *\n * @param contribution The contribution to read.\n * @returns The extracted {@link NavigationItem}, or `undefined` when `contribution.content` isn't an {@link ExternalComponent} or is missing a required property.\n */\nexport function extractNavigationItem(contribution: Contribution): NavigationItem | undefined {\n const content = contribution.content as Partial<ExternalComponent>;\n if (!content.properties) {\n return undefined;\n }\n\n const { label, targetScreen, routeParameterBindings, order, group } = content.properties as Record<string, unknown>;\n if (typeof label !== 'string' || typeof targetScreen !== 'string') {\n return undefined;\n }\n\n return {\n label,\n targetScreen,\n routeParameterBindings: isBindingExpressionRecord(routeParameterBindings) ? routeParameterBindings : {},\n order: typeof order === 'number' ? order : contribution.order,\n group: typeof group === 'string' ? group : undefined,\n };\n}\n\nfunction isBindingExpressionRecord(value: unknown): value is Record<string, BindingExpression> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n"],"names":["extractNavigationItem","contribution","content","properties","undefined","label","targetScreen","routeParameterBindings","order","group","isBindingExpressionRecord","value","Array","isArray"],"mappings":"AAAA;AACA;AAIA;;;;;;;;;;;IAYO,SAASA,qBAAAA,CAAsBC,YAA0B,EAAA;IAC5D,MAAMC,OAAAA,GAAUD,aAAaC,OAAO;IACpC,IAAI,CAACA,OAAAA,CAAQC,UAAU,EAAE;QACrB,OAAOC,SAAAA;AACX,IAAA;AAEA,IAAA,MAAM,EAAEC,KAAK,EAAEC,YAAY,EAAEC,sBAAsB,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGP,QAAQC,UAAU;AACxF,IAAA,IAAI,OAAOE,KAAAA,KAAU,QAAA,IAAY,OAAOC,iBAAiB,QAAA,EAAU;QAC/D,OAAOF,SAAAA;AACX,IAAA;IAEA,OAAO;AACHC,QAAAA,KAAAA;AACAC,QAAAA,YAAAA;QACAC,sBAAAA,EAAwBG,yBAAAA,CAA0BH,sBAAAA,CAAAA,GAA0BA,sBAAAA,GAAyB,EAAC;AACtGC,QAAAA,KAAAA,EAAO,OAAOA,KAAAA,KAAU,QAAA,GAAWA,KAAAA,GAAQP,aAAaO,KAAK;QAC7DC,KAAAA,EAAO,OAAOA,KAAAA,KAAU,QAAA,GAAWA,KAAAA,GAAQL;AAC/C,KAAA;AACJ;AAEA,SAASM,0BAA0BC,KAAc,EAAA;IAC7C,OAAO,OAAOA,UAAU,QAAA,IAAYA,KAAAA,KAAU,QAAQ,CAACC,KAAAA,CAAMC,OAAO,CAACF,KAAAA,CAAAA;AACzE
|
|
1
|
+
{"version":3,"file":"extractNavigationItem.js","sources":["../../../NavBar/extractNavigationItem.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 { BindingExpression, Contribution, ExternalComponent, NavigationItem } from '@cratis/scene.model';\n\n/**\n * Reads a {@link NavigationItem} out of a {@link Contribution} to the built-in `Navigation` contribution\n * point. `Contribution.content` carries an {@link ExternalComponent} whose open `properties` bag holds the\n * navigation-specific values (`label`, `targetScreen`, `routeParameterBindings`, `order`, `group`) - the\n * same names as {@link NavigationItem}'s own fields. This property-bag contract is Scene#2's own choice,\n * made without a real Screenplay-to-Scene translation to confirm it against (Stage#37 hasn't been built\n * yet) - whoever builds that seam should either produce contributions matching this contract or this\n * function should move to match whatever Stage#37 actually emits.\n *\n * @param contribution The contribution to read.\n * @returns The extracted {@link NavigationItem}, or `undefined` when `contribution.content` isn't an {@link ExternalComponent} or is missing a required property.\n */\nexport function extractNavigationItem(contribution: Contribution): NavigationItem | undefined {\n const content = contribution.content as Partial<ExternalComponent>;\n if (!content.properties) {\n return undefined;\n }\n\n const { label, targetScreen, routeParameterBindings, order, group } = content.properties as Record<string, unknown>;\n if (typeof label !== 'string' || typeof targetScreen !== 'string') {\n return undefined;\n }\n\n return {\n label,\n targetScreen,\n routeParameterBindings: isBindingExpressionRecord(routeParameterBindings) ? routeParameterBindings : {},\n order: typeof order === 'number' ? order : contribution.order,\n group: typeof group === 'string' ? group : undefined,\n };\n}\n\nfunction isBindingExpressionRecord(value: unknown): value is Record<string, BindingExpression> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n"],"names":["extractNavigationItem","contribution","content","properties","undefined","label","targetScreen","routeParameterBindings","order","group","isBindingExpressionRecord","value","Array","isArray"],"mappings":"AAAA;AACA;AAIA;;;;;;;;;;;IAYO,SAASA,qBAAAA,CAAsBC,YAA0B,EAAA;IAC5D,MAAMC,OAAAA,GAAUD,aAAaC,OAAO;IACpC,IAAI,CAACA,OAAAA,CAAQC,UAAU,EAAE;QACrB,OAAOC,SAAAA;AACX,IAAA;AAEA,IAAA,MAAM,EAAEC,KAAK,EAAEC,YAAY,EAAEC,sBAAsB,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGP,QAAQC,UAAU;AACxF,IAAA,IAAI,OAAOE,KAAAA,KAAU,QAAA,IAAY,OAAOC,iBAAiB,QAAA,EAAU;QAC/D,OAAOF,SAAAA;AACX,IAAA;IAEA,OAAO;AACHC,QAAAA,KAAAA;AACAC,QAAAA,YAAAA;QACAC,sBAAAA,EAAwBG,yBAAAA,CAA0BH,sBAAAA,CAAAA,GAA0BA,sBAAAA,GAAyB,EAAC;AACtGC,QAAAA,KAAAA,EAAO,OAAOA,KAAAA,KAAU,QAAA,GAAWA,KAAAA,GAAQP,aAAaO,KAAK;QAC7DC,KAAAA,EAAO,OAAOA,KAAAA,KAAU,QAAA,GAAWA,KAAAA,GAAQL;AAC/C,KAAA;AACJ;AAEA,SAASM,0BAA0BC,KAAc,EAAA;IAC7C,OAAO,OAAOA,UAAU,QAAA,IAAYA,KAAAA,KAAU,QAAQ,CAACC,KAAAA,CAAMC,OAAO,CAACF,KAAAA,CAAAA;AACzE;;"}
|
|
@@ -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 { renderElement, BindingResolver } from '@cratis/scene.engine';\nimport { SceneElement } from '@cratis/scene.model';\nimport { ComponentRegistry, createReactRenderer } from './renderer';\n\nexport interface SceneElementViewProps {\n element: SceneElement;\n registry: ComponentRegistry;\n resolveBinding: BindingResolver;\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({ element, registry, resolveBinding }: SceneElementViewProps) {\n const renderer = useMemo(() => createReactRenderer(registry), [registry]);\n return <>{renderElement(element, renderer, resolveBinding)}</>;\n}\n"],"names":["SceneElementView","element","registry","resolveBinding","renderer","useMemo","createReactRenderer","_jsx","_Fragment","renderElement"],"mappings":";;;;;AAcA;;;IAIO,SAASA,gBAAAA,CAAiB,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,cAAc,EAAyB,EAAA;AACzF,IAAA,MAAMC,QAAAA,GAAWC,OAAAA,CAAQ,IAAMC,mBAAAA,CAAoBJ,QAAAA,CAAAA,EAAW;AAACA,QAAAA;AAAS,KAAA,CAAA;IACxE,qBAAOK,GAAA,CAAAC,QAAA,EAAA;AAAGC,QAAAA,QAAAA,EAAAA,aAAAA,CAAcR,SAASG,QAAAA,EAAUD,cAAAA;;AAC/C
|
|
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 { renderElement, BindingResolver } from '@cratis/scene.engine';\nimport { SceneElement } from '@cratis/scene.model';\nimport { ComponentRegistry, createReactRenderer } from './renderer';\n\nexport interface SceneElementViewProps {\n element: SceneElement;\n registry: ComponentRegistry;\n resolveBinding: BindingResolver;\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({ element, registry, resolveBinding }: SceneElementViewProps) {\n const renderer = useMemo(() => createReactRenderer(registry), [registry]);\n return <>{renderElement(element, renderer, resolveBinding)}</>;\n}\n"],"names":["SceneElementView","element","registry","resolveBinding","renderer","useMemo","createReactRenderer","_jsx","_Fragment","renderElement"],"mappings":";;;;;AAcA;;;IAIO,SAASA,gBAAAA,CAAiB,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,cAAc,EAAyB,EAAA;AACzF,IAAA,MAAMC,QAAAA,GAAWC,OAAAA,CAAQ,IAAMC,mBAAAA,CAAoBJ,QAAAA,CAAAA,EAAW;AAACA,QAAAA;AAAS,KAAA,CAAA;IACxE,qBAAOK,GAAA,CAAAC,QAAA,EAAA;AAAGC,QAAAA,QAAAA,EAAAA,aAAAA,CAAcR,SAASG,QAAAA,EAAUD,cAAAA;;AAC/C;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoreButton.js","sources":["../../../core/CoreButton.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\n/**\n * The `core:button` component - part of the minimum vocabulary a `ui profile` can always fall back to.\n */\nexport function CoreButton({ element, slots }: RegisteredComponentProps) {\n const label = typeof element.properties.label === 'string' ? element.properties.label : '';\n return (\n <button type=\"button\" data-scene-id={element.id}>\n {label}\n {slots.content}\n </button>\n );\n}\n"],"names":["CoreButton","element","slots","label","properties","_jsxs","button","type","data-scene-id","id","content"],"mappings":";;AAAA;AACA;AAIA;;AAEC,IACM,SAASA,UAAAA,CAAW,EAAEC,OAAO,EAAEC,KAAK,EAA4B,EAAA;AACnE,IAAA,MAAMC,KAAAA,GAAQ,OAAOF,OAAAA,CAAQG,UAAU,CAACD,KAAK,KAAK,QAAA,GAAWF,OAAAA,CAAQG,UAAU,CAACD,KAAK,GAAG,EAAA;AACxF,IAAA,qBACIE,IAAA,CAACC,QAAAA,EAAAA;QAAOC,IAAAA,EAAK,QAAA;AAASC,QAAAA,eAAAA,EAAeP,QAAQQ,EAAE;;AAC1CN,YAAAA,KAAAA;AACAD,YAAAA,KAAAA,CAAMQ;;;AAGnB
|
|
1
|
+
{"version":3,"file":"CoreButton.js","sources":["../../../core/CoreButton.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\n/**\n * The `core:button` component - part of the minimum vocabulary a `ui profile` can always fall back to.\n */\nexport function CoreButton({ element, slots }: RegisteredComponentProps) {\n const label = typeof element.properties.label === 'string' ? element.properties.label : '';\n return (\n <button type=\"button\" data-scene-id={element.id}>\n {label}\n {slots.content}\n </button>\n );\n}\n"],"names":["CoreButton","element","slots","label","properties","_jsxs","button","type","data-scene-id","id","content"],"mappings":";;AAAA;AACA;AAIA;;AAEC,IACM,SAASA,UAAAA,CAAW,EAAEC,OAAO,EAAEC,KAAK,EAA4B,EAAA;AACnE,IAAA,MAAMC,KAAAA,GAAQ,OAAOF,OAAAA,CAAQG,UAAU,CAACD,KAAK,KAAK,QAAA,GAAWF,OAAAA,CAAQG,UAAU,CAACD,KAAK,GAAG,EAAA;AACxF,IAAA,qBACIE,IAAA,CAACC,QAAAA,EAAAA;QAAOC,IAAAA,EAAK,QAAA;AAASC,QAAAA,eAAAA,EAAeP,QAAQQ,EAAE;;AAC1CN,YAAAA,KAAAA;AACAD,YAAAA,KAAAA,CAAMQ;;;AAGnB;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoreCard.js","sources":["../../../core/CoreCard.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\n/**\n * The `core:card` component - part of the minimum vocabulary a `ui profile` can always fall back to.\n */\nexport function CoreCard({ element, slots }: RegisteredComponentProps) {\n return (\n <section data-scene-id={element.id} style={{ border: '1px solid #ccc', borderRadius: 4, padding: '0.75rem' }}>\n {slots.content}\n </section>\n );\n}\n"],"names":["CoreCard","element","slots","_jsx","section","data-scene-id","id","style","border","borderRadius","padding","content"],"mappings":";;AAAA;AACA;AAIA;;AAEC,IACM,SAASA,QAAAA,CAAS,EAAEC,OAAO,EAAEC,KAAK,EAA4B,EAAA;AACjE,IAAA,qBACIC,GAAA,CAACC,SAAAA,EAAAA;AAAQC,QAAAA,eAAAA,EAAeJ,QAAQK,EAAE;QAAEC,KAAAA,EAAO;YAAEC,MAAAA,EAAQ,gBAAA;YAAkBC,YAAAA,EAAc,CAAA;YAAGC,OAAAA,EAAS;AAAU,SAAA;AACtGR,QAAAA,QAAAA,EAAAA,KAAAA,CAAMS;;AAGnB
|
|
1
|
+
{"version":3,"file":"CoreCard.js","sources":["../../../core/CoreCard.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\n/**\n * The `core:card` component - part of the minimum vocabulary a `ui profile` can always fall back to.\n */\nexport function CoreCard({ element, slots }: RegisteredComponentProps) {\n return (\n <section data-scene-id={element.id} style={{ border: '1px solid #ccc', borderRadius: 4, padding: '0.75rem' }}>\n {slots.content}\n </section>\n );\n}\n"],"names":["CoreCard","element","slots","_jsx","section","data-scene-id","id","style","border","borderRadius","padding","content"],"mappings":";;AAAA;AACA;AAIA;;AAEC,IACM,SAASA,QAAAA,CAAS,EAAEC,OAAO,EAAEC,KAAK,EAA4B,EAAA;AACjE,IAAA,qBACIC,GAAA,CAACC,SAAAA,EAAAA;AAAQC,QAAAA,eAAAA,EAAeJ,QAAQK,EAAE;QAAEC,KAAAA,EAAO;YAAEC,MAAAA,EAAQ,gBAAA;YAAkBC,YAAAA,EAAc,CAAA;YAAGC,OAAAA,EAAS;AAAU,SAAA;AACtGR,QAAAA,QAAAA,EAAAA,KAAAA,CAAMS;;AAGnB;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoreText.js","sources":["../../../core/CoreText.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\n/**\n * The `core:text` component - the minimum vocabulary a `ui profile` can always fall back to, regardless\n * of which packages it lists, per Scene#3's `core` fallback guarantee.\n */\nexport function CoreText({ element }: RegisteredComponentProps) {\n const text = typeof element.properties.text === 'string' ? element.properties.text : '';\n return <span data-scene-id={element.id}>{text}</span>;\n}\n"],"names":["CoreText","element","text","properties","_jsx","span","data-scene-id","id"],"mappings":";;AAAA;AACA;AAIA;;;AAGC,IACM,SAASA,QAAAA,CAAS,EAAEC,OAAO,EAA4B,EAAA;AAC1D,IAAA,MAAMC,IAAAA,GAAO,OAAOD,OAAAA,CAAQE,UAAU,CAACD,IAAI,KAAK,QAAA,GAAWD,OAAAA,CAAQE,UAAU,CAACD,IAAI,GAAG,EAAA;AACrF,IAAA,qBAAOE,GAAA,CAACC,MAAAA,EAAAA;AAAKC,QAAAA,eAAAA,EAAeL,QAAQM,EAAE;AAAGL,QAAAA,QAAAA,EAAAA;;AAC7C
|
|
1
|
+
{"version":3,"file":"CoreText.js","sources":["../../../core/CoreText.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\n/**\n * The `core:text` component - the minimum vocabulary a `ui profile` can always fall back to, regardless\n * of which packages it lists, per Scene#3's `core` fallback guarantee.\n */\nexport function CoreText({ element }: RegisteredComponentProps) {\n const text = typeof element.properties.text === 'string' ? element.properties.text : '';\n return <span data-scene-id={element.id}>{text}</span>;\n}\n"],"names":["CoreText","element","text","properties","_jsx","span","data-scene-id","id"],"mappings":";;AAAA;AACA;AAIA;;;AAGC,IACM,SAASA,QAAAA,CAAS,EAAEC,OAAO,EAA4B,EAAA;AAC1D,IAAA,MAAMC,IAAAA,GAAO,OAAOD,OAAAA,CAAQE,UAAU,CAACD,IAAI,KAAK,QAAA,GAAWD,OAAAA,CAAQE,UAAU,CAACD,IAAI,GAAG,EAAA;AACrF,IAAA,qBAAOE,GAAA,CAACC,MAAAA,EAAAA;AAAKC,QAAAA,eAAAA,EAAeL,QAAQM,EAAE;AAAGL,QAAAA,QAAAA,EAAAA;;AAC7C;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RegisteredComponentProps } from '../renderer';
|
|
2
|
+
export declare function CoreData({ element }: RegisteredComponentProps): import("react").JSX.Element;
|
|
3
|
+
export declare function CoreAction({ element }: RegisteredComponentProps): import("react").JSX.Element;
|
|
4
|
+
export declare function CoreSection({ element, slots }: RegisteredComponentProps): import("react").JSX.Element;
|
|
5
|
+
export declare function CoreNavigate({ element }: RegisteredComponentProps): import("react").JSX.Element;
|
|
6
|
+
export declare function CoreTitle({ element }: RegisteredComponentProps): import("react").JSX.Element;
|
|
7
|
+
export declare function CoreTable({ element, slots }: RegisteredComponentProps): import("react").JSX.Element;
|
|
8
|
+
export declare function CoreColumn({ element }: RegisteredComponentProps): import("react").JSX.Element;
|
|
9
|
+
export declare function CoreSummary({ element, slots }: RegisteredComponentProps): import("react").JSX.Element;
|
|
10
|
+
export declare function CoreField({ element }: RegisteredComponentProps): import("react").JSX.Element;
|
|
11
|
+
export declare function CoreCode({ element }: RegisteredComponentProps): import("react").JSX.Element;
|
|
12
|
+
export declare function CoreFile({ element }: RegisteredComponentProps): import("react").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=ScreenplayCoreComponents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScreenplayCoreComponents.d.ts","sourceRoot":"","sources":["../../../core/ScreenplayCoreComponents.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAOvD,wBAAgB,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,wBAAwB,+BAE7D;AAGD,wBAAgB,UAAU,CAAC,EAAE,OAAO,EAAE,EAAE,wBAAwB,+BAK/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"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
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
|
+
function textProperty(properties, name, fallback = '') {
|
|
6
|
+
return typeof properties[name] === 'string' ? properties[name] : fallback;
|
|
7
|
+
}
|
|
8
|
+
/** Carries a Screenplay data declaration without adding visual chrome. */ function CoreData({ element }) {
|
|
9
|
+
return /*#__PURE__*/ jsx("span", {
|
|
10
|
+
hidden: true,
|
|
11
|
+
"data-scene-id": element.id,
|
|
12
|
+
"data-scene-data": textProperty(element.properties, 'typeName')
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
/** Renders a modeled command action and emits a host-neutral command event when invoked. */ function CoreAction({ element }) {
|
|
16
|
+
const command = textProperty(element.properties, 'command');
|
|
17
|
+
const label = textProperty(element.properties, 'label', command);
|
|
18
|
+
const invoke = ()=>globalThis.dispatchEvent(new CustomEvent('cratis.scene.command', {
|
|
19
|
+
detail: {
|
|
20
|
+
command,
|
|
21
|
+
element
|
|
22
|
+
}
|
|
23
|
+
}));
|
|
24
|
+
return /*#__PURE__*/ jsx("button", {
|
|
25
|
+
type: "button",
|
|
26
|
+
"data-scene-id": element.id,
|
|
27
|
+
onClick: invoke,
|
|
28
|
+
children: label
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/** Groups the nested content of a Screenplay section. */ function CoreSection({ element, slots }) {
|
|
32
|
+
const name = textProperty(element.properties, 'name');
|
|
33
|
+
return /*#__PURE__*/ jsxs("section", {
|
|
34
|
+
"data-scene-id": element.id,
|
|
35
|
+
children: [
|
|
36
|
+
name && /*#__PURE__*/ jsx("h2", {
|
|
37
|
+
children: name
|
|
38
|
+
}),
|
|
39
|
+
slots.content
|
|
40
|
+
]
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/** Renders navigation intent and emits a host-neutral navigation event. */ function CoreNavigate({ element }) {
|
|
44
|
+
const targetScreen = textProperty(element.properties, 'targetScreen');
|
|
45
|
+
const navigate = ()=>globalThis.dispatchEvent(new CustomEvent('cratis.scene.navigate', {
|
|
46
|
+
detail: {
|
|
47
|
+
targetScreen,
|
|
48
|
+
element
|
|
49
|
+
}
|
|
50
|
+
}));
|
|
51
|
+
return /*#__PURE__*/ jsx("button", {
|
|
52
|
+
type: "button",
|
|
53
|
+
"data-scene-id": element.id,
|
|
54
|
+
onClick: navigate,
|
|
55
|
+
children: targetScreen
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/** Renders a Screenplay title directive. */ function CoreTitle({ element }) {
|
|
59
|
+
return /*#__PURE__*/ jsx("h1", {
|
|
60
|
+
"data-scene-id": element.id,
|
|
61
|
+
children: textProperty(element.properties, 'text')
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/** Renders the structural shell of a Screenplay table. Query data is supplied by the host. */ function CoreTable({ element, slots }) {
|
|
65
|
+
return /*#__PURE__*/ jsx("section", {
|
|
66
|
+
"data-scene-id": element.id,
|
|
67
|
+
role: "table",
|
|
68
|
+
children: /*#__PURE__*/ jsx("header", {
|
|
69
|
+
role: "row",
|
|
70
|
+
children: slots.columns
|
|
71
|
+
})
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/** Renders a Screenplay table-column heading. */ function CoreColumn({ element }) {
|
|
75
|
+
const property = textProperty(element.properties, 'property');
|
|
76
|
+
return /*#__PURE__*/ jsx("span", {
|
|
77
|
+
"data-scene-id": element.id,
|
|
78
|
+
role: "columnheader",
|
|
79
|
+
children: textProperty(element.properties, 'label', property)
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/** Renders the structural shell of a Screenplay summary. Query data is supplied by the host. */ function CoreSummary({ element, slots }) {
|
|
83
|
+
return /*#__PURE__*/ jsx("dl", {
|
|
84
|
+
"data-scene-id": element.id,
|
|
85
|
+
children: slots.fields
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/** Renders a Screenplay summary field label. */ function CoreField({ element }) {
|
|
89
|
+
const property = textProperty(element.properties, 'property');
|
|
90
|
+
return /*#__PURE__*/ jsx("dt", {
|
|
91
|
+
"data-scene-id": element.id,
|
|
92
|
+
children: textProperty(element.properties, 'label', property)
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/** Renders a Screenplay code block. */ function CoreCode({ element }) {
|
|
96
|
+
const language = textProperty(element.properties, 'language');
|
|
97
|
+
return /*#__PURE__*/ jsx("pre", {
|
|
98
|
+
"data-scene-id": element.id,
|
|
99
|
+
children: /*#__PURE__*/ jsx("code", {
|
|
100
|
+
"data-language": language,
|
|
101
|
+
children: textProperty(element.properties, 'code')
|
|
102
|
+
})
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/** Makes an external screen-file reference visible until a host supplies that file. */ function CoreFile({ element }) {
|
|
106
|
+
return /*#__PURE__*/ jsxs("p", {
|
|
107
|
+
"data-scene-id": element.id,
|
|
108
|
+
children: [
|
|
109
|
+
"Screen source: ",
|
|
110
|
+
textProperty(element.properties, 'path')
|
|
111
|
+
]
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export { CoreAction, CoreCode, CoreColumn, CoreData, CoreField, CoreFile, CoreNavigate, CoreSection, CoreSummary, CoreTable, CoreTitle };
|
|
116
|
+
//# sourceMappingURL=ScreenplayCoreComponents.js.map
|
|
@@ -0,0 +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":";;AAAA;AACA;AAIA,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;AAEA,6FACO,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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U,EAAEtC,OAAO,EAA4B,EAAA;AAC3D,IAAA,MAAMkC,QAAAA,GAAWvC,YAAAA,CAAaK,OAAAA,CAAQJ,UAAU,EAAE,UAAA,CAAA;AAClD,IAAA,qBAAOK,GAAA,CAACsC,IAAAA,EAAAA;AAAGnC,QAAAA,eAAAA,EAAeJ,QAAQK,EAAE;kBAAGV,YAAAA,CAAaK,OAAAA,CAAQJ,UAAU,EAAE,OAAA,EAASsC,QAAAA;;AACrF;AAEA,wCACO,SAASM,QAAAA,CAAS,EAAExC,OAAO,EAA4B,EAAA;AAC1D,IAAA,MAAMyC,QAAAA,GAAW9C,YAAAA,CAAaK,OAAAA,CAAQJ,UAAU,EAAE,UAAA,CAAA;AAClD,IAAA,qBAAOK,GAAA,CAACyC,KAAAA,EAAAA;AAAItC,QAAAA,eAAAA,EAAeJ,QAAQK,EAAE;AAAE,QAAA,QAAA,gBAAAJ,GAAA,CAAC0C,MAAAA,EAAAA;YAAKC,eAAAA,EAAeH,QAAAA;sBAAW9C,YAAAA,CAAaK,OAAAA,CAAQJ,UAAU,EAAE,MAAA;;;AAC5G;AAEA,wFACO,SAASiD,QAAAA,CAAS,EAAE7C,OAAO,EAA4B,EAAA;AAC1D,IAAA,qBAAOoB,IAAA,CAAC0B,GAAAA,EAAAA;AAAE1C,QAAAA,eAAAA,EAAeJ,QAAQK,EAAE;;AAAE,YAAA,iBAAA;YAAgBV,YAAAA,CAAaK,OAAAA,CAAQJ,UAAU,EAAE,MAAA;;;AAC1F;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreComponents.d.ts","sourceRoot":"","sources":["../../../core/coreComponents.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"coreComponents.d.ts","sourceRoot":"","sources":["../../../core/coreComponents.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAuBhD,eAAO,MAAM,cAAc,EAAE,iBAe5B,CAAC"}
|
|
@@ -2,6 +2,7 @@ import { componentRegistryKey } from '../packages/ScenePackageBundle.js';
|
|
|
2
2
|
import { CoreText } from './CoreText.js';
|
|
3
3
|
import { CoreButton } from './CoreButton.js';
|
|
4
4
|
import { CoreCard } from './CoreCard.js';
|
|
5
|
+
import { CoreFile, CoreCode, CoreField, CoreSummary, CoreColumn, CoreTable, CoreTitle, CoreNavigate, CoreSection, CoreAction, CoreData } from './ScreenplayCoreComponents.js';
|
|
5
6
|
|
|
6
7
|
// Copyright (c) Cratis. All rights reserved.
|
|
7
8
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
@@ -11,7 +12,18 @@ import { CoreCard } from './CoreCard.js';
|
|
|
11
12
|
*/ const coreComponents = {
|
|
12
13
|
[componentRegistryKey('core', 'text')]: CoreText,
|
|
13
14
|
[componentRegistryKey('core', 'button')]: CoreButton,
|
|
14
|
-
[componentRegistryKey('core', 'card')]: CoreCard
|
|
15
|
+
[componentRegistryKey('core', 'card')]: CoreCard,
|
|
16
|
+
[componentRegistryKey('core', 'data')]: CoreData,
|
|
17
|
+
[componentRegistryKey('core', 'action')]: CoreAction,
|
|
18
|
+
[componentRegistryKey('core', 'section')]: CoreSection,
|
|
19
|
+
[componentRegistryKey('core', 'navigate')]: CoreNavigate,
|
|
20
|
+
[componentRegistryKey('core', 'title')]: CoreTitle,
|
|
21
|
+
[componentRegistryKey('core', 'table')]: CoreTable,
|
|
22
|
+
[componentRegistryKey('core', 'column')]: CoreColumn,
|
|
23
|
+
[componentRegistryKey('core', 'summary')]: CoreSummary,
|
|
24
|
+
[componentRegistryKey('core', 'field')]: CoreField,
|
|
25
|
+
[componentRegistryKey('core', 'code')]: CoreCode,
|
|
26
|
+
[componentRegistryKey('core', 'file')]: CoreFile
|
|
15
27
|
};
|
|
16
28
|
|
|
17
29
|
export { coreComponents };
|
|
@@ -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';\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};\n"],"names":["coreComponents","componentRegistryKey","CoreText","CoreButton","CoreCard"],"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 {\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};\n"],"names":["coreComponents","componentRegistryKey","CoreText","CoreButton","CoreCard","CoreData","CoreAction","CoreSection","CoreNavigate","CoreTitle","CoreTable","CoreColumn","CoreSummary","CoreField","CoreCode","CoreFile"],"mappings":";;;;;;AAAA;AACA;AAqBA;;;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;AAC5C;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"corePackage.d.ts","sourceRoot":"","sources":["../../../core/corePackage.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAUjD,eAAO,MAAM,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"corePackage.d.ts","sourceRoot":"","sources":["../../../core/corePackage.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAUjD,eAAO,MAAM,mBAAmB,EAAE,YA8BjC,CAAC;AAKF,eAAO,MAAM,WAAW,EAAE,kBAGzB,CAAC"}
|
|
@@ -17,7 +17,18 @@ import { coreComponents } from './coreComponents.js';
|
|
|
17
17
|
components: [
|
|
18
18
|
'text',
|
|
19
19
|
'button',
|
|
20
|
-
'card'
|
|
20
|
+
'card',
|
|
21
|
+
'data',
|
|
22
|
+
'action',
|
|
23
|
+
'section',
|
|
24
|
+
'navigate',
|
|
25
|
+
'title',
|
|
26
|
+
'table',
|
|
27
|
+
'column',
|
|
28
|
+
'summary',
|
|
29
|
+
'field',
|
|
30
|
+
'code',
|
|
31
|
+
'file'
|
|
21
32
|
],
|
|
22
33
|
layouts: [],
|
|
23
34
|
screenTemplates: [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"corePackage.js","sources":["../../../core/corePackage.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 { PackageKind, ScenePackage } from '@cratis/scene.model';\nimport { ScenePackageBundle } from '../packages';\nimport { coreComponents } from './coreComponents';\n\n/**\n * The `core` package's declaration. Every other package is loaded by a host that reads its manifest;\n * `core` ships inside the renderer itself, because Scene#3 guarantees a bare name always has somewhere to\n * resolve regardless of which packages a profile lists. It is still declared the same way as any other -\n * a package picker should be able to show it, and the dependency resolver should be able to reason about\n * it, without a special case.\n */\nexport const corePackageManifest: ScenePackage = {\n name: 'core',\n version: '1.0.0',\n kind: PackageKind.ComponentLibrary,\n dependencies: [],\n components: ['text'
|
|
1
|
+
{"version":3,"file":"corePackage.js","sources":["../../../core/corePackage.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 { PackageKind, ScenePackage } from '@cratis/scene.model';\nimport { ScenePackageBundle } from '../packages';\nimport { coreComponents } from './coreComponents';\n\n/**\n * The `core` package's declaration. Every other package is loaded by a host that reads its manifest;\n * `core` ships inside the renderer itself, because Scene#3 guarantees a bare name always has somewhere to\n * resolve regardless of which packages a profile lists. It is still declared the same way as any other -\n * a package picker should be able to show it, and the dependency resolver should be able to reason about\n * it, without a special case.\n */\nexport const corePackageManifest: ScenePackage = {\n name: 'core',\n version: '1.0.0',\n kind: PackageKind.ComponentLibrary,\n dependencies: [],\n components: [\n 'text',\n 'button',\n 'card',\n 'data',\n 'action',\n 'section',\n 'navigate',\n 'title',\n 'table',\n 'column',\n 'summary',\n 'field',\n 'code',\n 'file',\n ],\n layouts: [],\n screenTemplates: [],\n dialogTemplates: [],\n themes: [],\n displayName: 'Core',\n description: 'The built-in fallback vocabulary every ui profile resolves against.',\n module: '@cratis/scene.react',\n license: 'MIT',\n licenseUrl: 'https://github.com/Cratis/Scene/blob/main/LICENSE',\n};\n\n/**\n * The `core` package as a loadable bundle.\n */\nexport const corePackage: ScenePackageBundle = {\n manifest: corePackageManifest,\n components: coreComponents,\n};\n"],"names":["corePackageManifest","name","version","kind","PackageKind","ComponentLibrary","dependencies","components","layouts","screenTemplates","dialogTemplates","themes","displayName","description","module","license","licenseUrl","corePackage","manifest","coreComponents"],"mappings":";;;AAAA;AACA;AAMA;;;;;;UAOaA,mBAAAA,GAAoC;IAC7CC,IAAAA,EAAM,MAAA;IACNC,OAAAA,EAAS,OAAA;AACTC,IAAAA,IAAAA,EAAMC,YAAYC,gBAAgB;AAClCC,IAAAA,YAAAA,EAAc,EAAE;IAChBC,UAAAA,EAAY;AACR,QAAA,MAAA;AACA,QAAA,QAAA;AACA,QAAA,MAAA;AACA,QAAA,MAAA;AACA,QAAA,QAAA;AACA,QAAA,SAAA;AACA,QAAA,UAAA;AACA,QAAA,OAAA;AACA,QAAA,OAAA;AACA,QAAA,QAAA;AACA,QAAA,SAAA;AACA,QAAA,OAAA;AACA,QAAA,MAAA;AACA,QAAA;AACH,KAAA;AACDC,IAAAA,OAAAA,EAAS,EAAE;AACXC,IAAAA,eAAAA,EAAiB,EAAE;AACnBC,IAAAA,eAAAA,EAAiB,EAAE;AACnBC,IAAAA,MAAAA,EAAQ,EAAE;IACVC,WAAAA,EAAa,MAAA;IACbC,WAAAA,EAAa,qEAAA;IACbC,MAAAA,EAAQ,qBAAA;IACRC,OAAAA,EAAS,KAAA;IACTC,UAAAA,EAAY;AAChB;AAEA;;UAGaC,WAAAA,GAAkC;IAC3CC,QAAAA,EAAUlB,mBAAAA;IACVO,UAAAA,EAAYY;AAChB;;"}
|
package/dist/esm/core/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../core/index.ts"],"names":[],"mappings":"AAGA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../core/index.ts"],"names":[],"mappings":"AAGA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC"}
|
package/dist/esm/core/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../core/index.ts"],"names":[],"mappings":"AAGA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../core/index.ts"],"names":[],"mappings":"AAGA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_rendering_a_translated_screen.d.ts","sourceRoot":"","sources":["../../../for_ScreenplayCoreComponents/when_rendering_a_translated_screen.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { expect } from 'chai';
|
|
3
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
4
|
+
import { HorizontalAlignment, VerticalAlignment, Visibility } from '@cratis/scene.model';
|
|
5
|
+
import { SceneElementView } from '../SceneElementView';
|
|
6
|
+
import { coreComponents } from '../core';
|
|
7
|
+
function control(id) {
|
|
8
|
+
return {
|
|
9
|
+
id,
|
|
10
|
+
name: id,
|
|
11
|
+
properties: {},
|
|
12
|
+
visibility: Visibility.Visible,
|
|
13
|
+
isEnabled: true,
|
|
14
|
+
opacity: 1,
|
|
15
|
+
size: {},
|
|
16
|
+
zIndex: 0,
|
|
17
|
+
minimumSize: {},
|
|
18
|
+
maximumSize: {},
|
|
19
|
+
margin: { left: 0, top: 0, right: 0, bottom: 0 },
|
|
20
|
+
horizontalAlignment: HorizontalAlignment.Stretch,
|
|
21
|
+
verticalAlignment: VerticalAlignment.Stretch,
|
|
22
|
+
borderThickness: { left: 0, top: 0, right: 0, bottom: 0 },
|
|
23
|
+
padding: { left: 0, top: 0, right: 0, bottom: 0 },
|
|
24
|
+
tabIndex: 0,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const component = (id, componentName, properties = {}, slots = {}) => ({ ...control(id), componentName, properties, slots });
|
|
28
|
+
describe('when rendering a translated Screenplay screen', () => {
|
|
29
|
+
const title = component('title', 'core:title', { text: 'Invoices' });
|
|
30
|
+
const action = component('create', 'core:action', { command: 'CreateInvoice', label: 'Create invoice' });
|
|
31
|
+
const section = component('section', 'core:section', { name: 'Open invoices' }, { content: [title, action] });
|
|
32
|
+
beforeEach(() => {
|
|
33
|
+
render(_jsx(SceneElementView, { element: section, registry: coreComponents, resolveBinding: () => undefined }));
|
|
34
|
+
});
|
|
35
|
+
it('should render the section heading', () => expect(screen.getByRole('heading', { name: 'Open invoices' })).to.exist);
|
|
36
|
+
it('should render the translated title', () => expect(screen.getByRole('heading', { name: 'Invoices' })).to.exist);
|
|
37
|
+
it('should render the modeled action', () => expect(screen.getByRole('button', { name: 'Create invoice' })).to.exist);
|
|
38
|
+
it('should announce the modeled command to the host', () => {
|
|
39
|
+
let command = '';
|
|
40
|
+
const listener = (event) => { command = event.detail.command; };
|
|
41
|
+
globalThis.addEventListener('cratis.scene.command', listener, { once: true });
|
|
42
|
+
fireEvent.click(screen.getByRole('button', { name: 'Create invoice' }));
|
|
43
|
+
command.should.equal('CreateInvoice');
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=when_rendering_a_translated_screen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_rendering_a_translated_screen.js","sourceRoot":"","sources":["../../../for_ScreenplayCoreComponents/when_rendering_a_translated_screen.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,MAAM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AE,GAAG,EAAE;QACvD,IAAI,OAAO,GAAG,EAAE,CAAC;QACjB,MAAM,QAAQ,GAAG,CAAC,KAAY,EAAE,EAAE,GAAG,OAAO,GAAI,KAAqB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACxF,UAAU,CAAC,gBAAgB,CAAC,sBAAsB,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAE9E,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC;QAExE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export { createReactRenderer } from './renderer/createReactRenderer.js';
|
|
|
4
4
|
export { CoreText } from './core/CoreText.js';
|
|
5
5
|
export { CoreButton } from './core/CoreButton.js';
|
|
6
6
|
export { CoreCard } from './core/CoreCard.js';
|
|
7
|
+
export { CoreAction, CoreCode, CoreColumn, CoreData, CoreField, CoreFile, CoreNavigate, CoreSection, CoreSummary, CoreTable, CoreTitle } from './core/ScreenplayCoreComponents.js';
|
|
7
8
|
export { coreComponents } from './core/coreComponents.js';
|
|
8
9
|
export { corePackage, corePackageManifest } from './core/corePackage.js';
|
|
9
10
|
export { NavBar } from './NavBar/NavBar.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":";;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScenePackageBundle.js","sources":["../../../packages/ScenePackageBundle.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, ScenePackage, Screen, ScreenTemplate, Theme } from '@cratis/scene.model';\nimport { ComponentRegistry } from '../renderer';\n\n/**\n * What a package actually ships to a React renderer, as opposed to what it *declares*.\n *\n * `ScenePackage` is the declaration — a name, a kind, dependencies, and the names of what it\n * contributes. It is deliberately platform-agnostic and lives in `Scene.Model`, because Stage's build and\n * Studio's design-time queries both read it without ever loading a component. A bundle is the other half:\n * the real React components, layouts, screens and themes behind those names, which only a renderer needs.\n *\n * A package publishes exactly one bundle, as a named export following its own name —\n * `primeReactPackage`, `cratisComponentsPackage`, `corePackage`. A host loads it from the module the\n * declaration's `ScenePackage.module` names.\n */\nexport interface ScenePackageBundle {\n /**\n * The package's own declaration. Its `components`, `layouts` and `themes` name lists must agree with\n * what this bundle actually provides — {@link validatePackageBundle} is what proves they do.\n */\n manifest: ScenePackage;\n\n /**\n * The components this package provides, keyed by {@link componentRegistryKey}.\n */\n components: ComponentRegistry;\n\n /**\n * The application shells this package provides, if any. Only a blueprint has these.\n */\n layouts?: Layout[];\n\n /**\n * The screen templates this package provides — the shapes that go inside a layout, each declaring\n * which of its parent's slots it fills.\n */\n screenTemplates?: ScreenTemplate[];\n\n /**\n * The dialog templates this package provides.\n */\n dialogTemplates?: DialogTemplate[];\n\n /**\n * Sample screens this package ships — a layout package's gallery, so a preview has real content to\n * put through the real engine rather than a mockup.\n */\n screens?: Screen[];\n\n /**\n * The themes this package ships, if any.\n */\n themes?: Theme[];\n}\n\n/**\n * The key a component is registered and looked up under: the package that provides it, then the bare name\n * a screen refers to it by.\n *\n * A screen writes a bare name (`button`) or a package-qualified one (`PrimeReact.button`);\n * `resolveComponentName` turns either into a `{ name, package }` pair, and this turns that pair into the\n * registry key. Nothing should build this string by hand — the separator is an implementation detail of\n * the registry, deliberately not the `.` used for qualification in a screen, so a package name containing\n * dots stays unambiguous.\n */\nexport function componentRegistryKey(packageName: string, componentName: string): string {\n return `${packageName}:${componentName}`;\n}\n\n/**\n * Checks that a bundle provides everything its manifest declares, and declares everything it provides.\n *\n * A manifest that promises a component the bundle does not register renders as `UnresolvedComponent` at\n * runtime — a blank box, far from where the mistake was made. A component registered but not declared is\n * invisible to `resolveComponentName`, so a screen can never name it. Both are silent failures, which is\n * why every package's specs run this.\n */\nexport function validatePackageBundle(bundle: ScenePackageBundle): string[] {\n const problems: string[] = [];\n const { manifest } = bundle;\n\n for (const name of manifest.components) {\n if (!(componentRegistryKey(manifest.name, name) in bundle.components)) {\n problems.push(`declares the component '${name}' but registers no implementation for it`);\n }\n }\n\n const declared = new Set(manifest.components.map((name) => componentRegistryKey(manifest.name, name)));\n for (const key of Object.keys(bundle.components)) {\n if (!declared.has(key)) {\n problems.push(`registers '${key}', which the manifest does not declare`);\n }\n }\n\n const providedLayouts = new Set((bundle.layouts ?? []).map((layout) => layout.name));\n for (const name of manifest.layouts) {\n if (!providedLayouts.has(name)) {\n problems.push(`declares the layout '${name}' but provides no definition for it`);\n }\n }\n\n const providedScreenTemplates = new Set((bundle.screenTemplates ?? []).map((template) => template.name));\n for (const name of manifest.screenTemplates) {\n if (!providedScreenTemplates.has(name)) {\n problems.push(`declares the screen template '${name}' but provides no definition for it`);\n }\n }\n\n const providedDialogTemplates = new Set((bundle.dialogTemplates ?? []).map((template) => template.name));\n for (const name of manifest.dialogTemplates) {\n if (!providedDialogTemplates.has(name)) {\n problems.push(`declares the dialog template '${name}' but provides no definition for it`);\n }\n }\n\n const providedThemes = new Set((bundle.themes ?? []).map((theme) => theme.name));\n for (const name of manifest.themes) {\n if (!providedThemes.has(name)) {\n problems.push(`declares the theme '${name}' but provides no definition for it`);\n }\n }\n\n return problems;\n}\n\n/**\n * Merges the component registries of several bundles into the single registry a renderer consumes.\n *\n * Keys carry their package name, so nothing collides and merge order does not matter — which package wins\n * a *bare* name is decided earlier, by `resolveComponentName` walking the profile's priority order.\n */\nexport function mergePackageRegistries(bundles: ScenePackageBundle[]): ComponentRegistry {\n return Object.assign({}, ...bundles.map((bundle) => bundle.components)) as ComponentRegistry;\n}\n"],"names":["componentRegistryKey","packageName","componentName","validatePackageBundle","bundle","problems","manifest","name","components","push","declared","Set","map","key","Object","keys","has","providedLayouts","layouts","layout","providedScreenTemplates","screenTemplates","template","providedDialogTemplates","dialogTemplates","providedThemes","themes","theme","mergePackageRegistries","bundles","assign"],"mappings":"AAAA;AACA;AAyDA;;;;;;;;;AASC,IACM,SAASA,oBAAAA,CAAqBC,WAAmB,EAAEC,aAAqB,EAAA;AAC3E,IAAA,OAAO,CAAA,EAAGD,WAAAA,CAAY,CAAC,EAAEC,aAAAA,CAAAA,CAAe;AAC5C;AAEA;;;;;;;IAQO,SAASC,qBAAAA,CAAsBC,MAA0B,EAAA;AAC5D,IAAA,MAAMC,WAAqB,EAAE;IAC7B,MAAM,EAAEC,QAAQ,EAAE,GAAGF,MAAAA;AAErB,IAAA,KAAK,MAAMG,IAAAA,IAAQD,QAAAA,CAASE,UAAU,CAAE;QACpC,IAAI,EAAER,oBAAAA,CAAqBM,QAAAA,CAASC,IAAI,EAAEA,IAAAA,CAAAA,IAASH,MAAAA,CAAOI,UAAS,CAAA,EAAI;AACnEH,YAAAA,QAAAA,CAASI,IAAI,CAAC,CAAC,wBAAwB,EAAEF,IAAAA,CAAK,wCAAwC,CAAC,CAAA;AAC3F,QAAA;AACJ,IAAA;AAEA,IAAA,MAAMG,QAAAA,GAAW,IAAIC,GAAAA,CAAIL,QAAAA,CAASE,UAAU,CAACI,GAAG,CAAC,CAACL,IAAAA,GAASP,oBAAAA,CAAqBM,QAAAA,CAASC,IAAI,EAAEA,IAAAA,CAAAA,CAAAA,CAAAA;AAC/F,IAAA,KAAK,MAAMM,GAAAA,IAAOC,MAAAA,CAAOC,IAAI,CAACX,MAAAA,CAAOI,UAAU,CAAA,CAAG;AAC9C,QAAA,IAAI,CAACE,QAAAA,CAASM,GAAG,CAACH,GAAAA,CAAAA,EAAM;AACpBR,Y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IAAI,CAAC,CAAC,8BAA8B,EAAEF,IAAAA,CAAK,mCAAmC,CAAC,CAAA;AAC5F,QAAA;AACJ,IAAA;AAEA,IAAA,MAAMkB,iBAAiB,IAAId,GAAAA,CAAI,CAACP,OAAOsB,MAAM,IAAI,EAAC,EAAGd,GAAG,CAAC,CAACe,KAAAA,GAAUA,MAAMpB,IAAI,CAAA,CAAA;AAC9E,IAAA,KAAK,MAAMA,IAAAA,IAAQD,QAAAA,CAASoB,MAAM,CAAE;AAChC,QAAA,IAAI,CAACD,cAAAA,CAAeT,GAAG,CAACT,IAAAA,CAAAA,EAAO;AAC3BF,YAAAA,QAAAA,CAASI,IAAI,CAAC,CAAC,oBAAoB,EAAEF,IAAAA,CAAK,mCAAmC,CAAC,CAAA;AAClF,QAAA;AACJ,IAAA;IAEA,OAAOF,QAAAA;AACX;AAEA;;;;;IAMO,SAASuB,sBAAAA,CAAuBC,OAA6B,EAAA;IAChE,OAAOf,MAAAA,CAAOgB,MAAM,CAAC,EAAC,EAAA,GAAMD,OAAAA,CAAQjB,GAAG,CAAC,CAACR,MAAAA,GAAWA,MAAAA,CAAOI,UAAU,CAAA,CAAA;AACzE
|
|
1
|
+
{"version":3,"file":"ScenePackageBundle.js","sources":["../../../packages/ScenePackageBundle.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, ScenePackage, Screen, ScreenTemplate, Theme } from '@cratis/scene.model';\nimport { ComponentRegistry } from '../renderer';\n\n/**\n * What a package actually ships to a React renderer, as opposed to what it *declares*.\n *\n * `ScenePackage` is the declaration — a name, a kind, dependencies, and the names of what it\n * contributes. It is deliberately platform-agnostic and lives in `Scene.Model`, because Stage's build and\n * Studio's design-time queries both read it without ever loading a component. A bundle is the other half:\n * the real React components, layouts, screens and themes behind those names, which only a renderer needs.\n *\n * A package publishes exactly one bundle, as a named export following its own name —\n * `primeReactPackage`, `cratisComponentsPackage`, `corePackage`. A host loads it from the module the\n * declaration's `ScenePackage.module` names.\n */\nexport interface ScenePackageBundle {\n /**\n * The package's own declaration. Its `components`, `layouts` and `themes` name lists must agree with\n * what this bundle actually provides — {@link validatePackageBundle} is what proves they do.\n */\n manifest: ScenePackage;\n\n /**\n * The components this package provides, keyed by {@link componentRegistryKey}.\n */\n components: ComponentRegistry;\n\n /**\n * The application shells this package provides, if any. Only a blueprint has these.\n */\n layouts?: Layout[];\n\n /**\n * The screen templates this package provides — the shapes that go inside a layout, each declaring\n * which of its parent's slots it fills.\n */\n screenTemplates?: ScreenTemplate[];\n\n /**\n * The dialog templates this package provides.\n */\n dialogTemplates?: DialogTemplate[];\n\n /**\n * Sample screens this package ships — a layout package's gallery, so a preview has real content to\n * put through the real engine rather than a mockup.\n */\n screens?: Screen[];\n\n /**\n * The themes this package ships, if any.\n */\n themes?: Theme[];\n}\n\n/**\n * The key a component is registered and looked up under: the package that provides it, then the bare name\n * a screen refers to it by.\n *\n * A screen writes a bare name (`button`) or a package-qualified one (`PrimeReact.button`);\n * `resolveComponentName` turns either into a `{ name, package }` pair, and this turns that pair into the\n * registry key. Nothing should build this string by hand — the separator is an implementation detail of\n * the registry, deliberately not the `.` used for qualification in a screen, so a package name containing\n * dots stays unambiguous.\n */\nexport function componentRegistryKey(packageName: string, componentName: string): string {\n return `${packageName}:${componentName}`;\n}\n\n/**\n * Checks that a bundle provides everything its manifest declares, and declares everything it provides.\n *\n * A manifest that promises a component the bundle does not register renders as `UnresolvedComponent` at\n * runtime — a blank box, far from where the mistake was made. A component registered but not declared is\n * invisible to `resolveComponentName`, so a screen can never name it. Both are silent failures, which is\n * why every package's specs run this.\n */\nexport function validatePackageBundle(bundle: ScenePackageBundle): string[] {\n const problems: string[] = [];\n const { manifest } = bundle;\n\n for (const name of manifest.components) {\n if (!(componentRegistryKey(manifest.name, name) in bundle.components)) {\n problems.push(`declares the component '${name}' but registers no implementation for it`);\n }\n }\n\n const declared = new Set(manifest.components.map((name) => componentRegistryKey(manifest.name, name)));\n for (const key of Object.keys(bundle.components)) {\n if (!declared.has(key)) {\n problems.push(`registers '${key}', which the manifest does not declare`);\n }\n }\n\n const providedLayouts = new Set((bundle.layouts ?? []).map((layout) => layout.name));\n for (const name of manifest.layouts) {\n if (!providedLayouts.has(name)) {\n problems.push(`declares the layout '${name}' but provides no definition for it`);\n }\n }\n\n const providedScreenTemplates = new Set((bundle.screenTemplates ?? []).map((template) => template.name));\n for (const name of manifest.screenTemplates) {\n if (!providedScreenTemplates.has(name)) {\n problems.push(`declares the screen template '${name}' but provides no definition for it`);\n }\n }\n\n const providedDialogTemplates = new Set((bundle.dialogTemplates ?? []).map((template) => template.name));\n for (const name of manifest.dialogTemplates) {\n if (!providedDialogTemplates.has(name)) {\n problems.push(`declares the dialog template '${name}' but provides no definition for it`);\n }\n }\n\n const providedThemes = new Set((bundle.themes ?? []).map((theme) => theme.name));\n for (const name of manifest.themes) {\n if (!providedThemes.has(name)) {\n problems.push(`declares the theme '${name}' but provides no definition for it`);\n }\n }\n\n return problems;\n}\n\n/**\n * Merges the component registries of several bundles into the single registry a renderer consumes.\n *\n * Keys carry their package name, so nothing collides and merge order does not matter — which package wins\n * a *bare* name is decided earlier, by `resolveComponentName` walking the profile's priority order.\n */\nexport function mergePackageRegistries(bundles: ScenePackageBundle[]): ComponentRegistry {\n return Object.assign({}, ...bundles.map((bundle) => bundle.components)) as ComponentRegistry;\n}\n"],"names":["componentRegistryKey","packageName","componentName","validatePackageBundle","bundle","problems","manifest","name","components","push","declared","Set","map","key","Object","keys","has","providedLayouts","layouts","layout","providedScreenTemplates","screenTemplates","template","providedDialogTemplates","dialogTemplates","providedThemes","themes","theme","mergePackageRegistries","bundles","assign"],"mappings":"AAAA;AACA;AAyDA;;;;;;;;;AASC,IACM,SAASA,oBAAAA,CAAqBC,WAAmB,EAAEC,aAAqB,EAAA;AAC3E,IAAA,OAAO,CAAA,EAAGD,WAAAA,CAAY,CAAC,EAAEC,aAAAA,CAAAA,C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