@mapples/render 1.0.3 → 1.0.4

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.
@@ -44,6 +44,6 @@ import { RenderProps } from '../types';
44
44
  * />
45
45
  * ```
46
46
  */
47
- declare const Render: ({ root, CustomRenderComponent }: RenderProps) => import("react").JSX.Element;
47
+ declare const Render: ({ root, state, CustomRenderComponent }: RenderProps) => import("react").JSX.Element;
48
48
  export default Render;
49
49
  //# sourceMappingURL=Render.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Render.d.ts","sourceRoot":"","sources":["../../src/components/Render.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAIvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,QAAA,MAAM,MAAM,GAAI,iCAAiC,WAAW,gCAM3D,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"Render.d.ts","sourceRoot":"","sources":["../../src/components/Render.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAIvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,QAAA,MAAM,MAAM,GAAI,wCAAwC,WAAW,gCAQlE,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { RenderStateContextProvider } from '../context/RenderStateContext';
1
2
  import RenderComponent from './RenderComponent';
2
3
  /**
3
4
  * Main render component that renders a component tree from a root component definition.
@@ -44,8 +45,10 @@ import RenderComponent from './RenderComponent';
44
45
  * />
45
46
  * ```
46
47
  */
47
- const Render = ({ root, CustomRenderComponent }) => {
48
- return CustomRenderComponent ? (<CustomRenderComponent {...root}/>) : (<RenderComponent {...root}/>);
48
+ const Render = ({ root, state, CustomRenderComponent }) => {
49
+ return CustomRenderComponent ? (<CustomRenderComponent {...root}/>) : (<RenderStateContextProvider value={state}>
50
+ <RenderComponent {...root}/>
51
+ </RenderStateContextProvider>);
49
52
  };
50
53
  export default Render;
51
54
  //# sourceMappingURL=Render.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Render.js","sourceRoot":"","sources":["../../src/components/Render.tsx"],"names":[],"mappings":"AAEA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,MAAM,GAAG,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAe,EAAE,EAAE;IAC9D,OAAO,qBAAqB,CAAC,CAAC,CAAC,CAC7B,CAAC,qBAAqB,CAAC,IAAI,IAAI,CAAC,EAAG,CACpC,CAAC,CAAC,CAAC,CACF,CAAC,eAAe,CAAC,IAAI,IAAI,CAAC,EAAG,CAC9B,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"Render.js","sourceRoot":"","sources":["../../src/components/Render.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAG3E,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,MAAM,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,qBAAqB,EAAe,EAAE,EAAE;IACrE,OAAO,qBAAqB,CAAC,CAAC,CAAC,CAC7B,CAAC,qBAAqB,CAAC,IAAI,IAAI,CAAC,EAAG,CACpC,CAAC,CAAC,CAAC,CACF,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CACvC;MAAA,CAAC,eAAe,CAAC,IAAI,IAAI,CAAC,EAC5B;IAAA,EAAE,0BAA0B,CAAC,CAC9B,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"RenderComponent.d.ts","sourceRoot":"","sources":["../../src/components/RenderComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAQ,MAAM,OAAO,CAAC;AAOjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,QAAA,MAAM,eAAe,EAAE,EAAE,CAAC,mBAAmB,CAiC5C,CAAC;AAQF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"RenderComponent.d.ts","sourceRoot":"","sources":["../../src/components/RenderComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAQ,MAAM,OAAO,CAAC;AAQjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,QAAA,MAAM,eAAe,EAAE,EAAE,CAAC,mBAAmB,CAsC5C,CAAC;AAQF,eAAe,eAAe,CAAC"}
@@ -2,6 +2,7 @@ import { memo } from 'react';
2
2
  import { useDataProps } from '@mapples/state';
3
3
  import { map } from 'lodash';
4
4
  import { useRender } from '../hooks';
5
+ import useConditionalStyled from '../hooks/useConditionalStyled';
5
6
  import useRefProps from '../hooks/useRefProps';
6
7
  /**
7
8
  * Default implementation of a renderable component.
@@ -42,6 +43,7 @@ const RenderComponent = ({ type, props, dataProps, children, refProps, childComp
42
43
  const { components } = useRender();
43
44
  const propsWithData = useDataProps(dataProps);
44
45
  const resolvedRefProps = useRefProps(refProps);
46
+ const propsWithConditional = useConditionalStyled(props);
45
47
  const Component = components[type].Component;
46
48
  if (!Component) {
47
49
  return null;
@@ -50,7 +52,7 @@ const RenderComponent = ({ type, props, dataProps, children, refProps, childComp
50
52
  const renderComponentProps = childComponents[child];
51
53
  return (<RenderComponentMemorized {...renderComponentProps} key={renderComponentProps.id}/>);
52
54
  };
53
- return (<Component {...props} {...propsWithData} {...resolvedRefProps}>
55
+ return (<Component {...propsWithConditional} {...propsWithData} {...resolvedRefProps}>
54
56
  {map(children, renderChildren)}
55
57
  </Component>);
56
58
  };
@@ -1 +1 @@
1
- {"version":3,"file":"RenderComponent.js","sourceRoot":"","sources":["../../src/components/RenderComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAM,IAAI,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,WAAW,MAAM,sBAAsB,CAAC;AAG/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,eAAe,GAA4B,CAAC,EAChD,IAAI,EACJ,KAAK,EACL,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,eAAe,GAChB,EAAE,EAAE;IACH,MAAM,EAAE,UAAU,EAAE,GAAG,SAAS,EAAE,CAAC;IACnC,MAAM,aAAa,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IAC9C,MAAM,gBAAgB,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IAE/C,MAAM,SAAS,GAAG,UAAU,CAAC,IAA+B,CAAC,CAAC,SAAS,CAAC;IAExE,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,cAAc,GAAG,CAAC,KAAa,EAAE,EAAE;QACvC,MAAM,oBAAoB,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;QACpD,OAAO,CACL,CAAC,wBAAwB,CACvB,IAAI,oBAAoB,CAAC,CACzB,GAAG,CAAC,CAAC,oBAAoB,CAAC,EAAE,CAAC,EAC7B,CACH,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,CACL,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,CAAC,IAA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,KAAK,CAAC,CAAC;QACpD,OAAO,CACL,CAAC,wBAAwB,CACvB,IAAI,oBAAoB,CAAC,CACzB,GAAG,CAAC,CAAC,oBAAoB,CAAC,EAAE,CAAC,EAC7B,CACH,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,CACL,CAAC,SAAS,CACR,IAAI,oBAAoB,CAAC,CACzB,IAAI,aAAa,CAAC,CAClB,IAAI,gBAAgB,CAAC,CAErB;MAAA,CAAC,GAAG,CAAC,QAAQ,EAAE,cAAc,CAAC,CAChC;IAAA,EAAE,SAAS,CAAC,CACb,CAAC;AACJ,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,wBAAwB,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC;AAEvD,eAAe,eAAe,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { StateCondition } from '../types';
2
+ declare const RenderStateContext: import("react").Context<Record<string, StateCondition> | undefined>;
3
+ export declare const RenderStateContextProvider: import("react").Provider<Record<string, StateCondition> | undefined>;
4
+ export default RenderStateContext;
5
+ //# sourceMappingURL=RenderStateContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RenderStateContext.d.ts","sourceRoot":"","sources":["../../src/context/RenderStateContext.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,QAAA,MAAM,kBAAkB,qEAEZ,CAAC;AAEb,eAAO,MAAM,0BAA0B,sEAA8B,CAAC;AAEtE,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { createContext } from 'react';
2
+ const RenderStateContext = createContext(undefined);
3
+ export const RenderStateContextProvider = RenderStateContext.Provider;
4
+ export default RenderStateContext;
5
+ //# sourceMappingURL=RenderStateContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RenderStateContext.js","sourceRoot":"","sources":["../../src/context/RenderStateContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAItC,MAAM,kBAAkB,GAAG,aAAa,CAEtC,SAAS,CAAC,CAAC;AAEb,MAAM,CAAC,MAAM,0BAA0B,GAAG,kBAAkB,CAAC,QAAQ,CAAC;AAEtE,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { AnyObject } from '../types';
2
+ /**
3
+ * Hook that processes component props to apply conditional styling based on state conditions.
4
+ *
5
+ * This hook evaluates conditions defined in the `styled` prop and applies conditional styles
6
+ * based on the current render state. Style keys can include condition suffixes (e.g., "backgroundColor::conditionName")
7
+ * that are evaluated against the render state.
8
+ *
9
+ * @param props - Component props that may contain a `styled` object with conditional styles
10
+ * @returns Props with processed conditional styles applied
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * const props = {
15
+ * styled: {
16
+ * backgroundColor: '#fff',
17
+ * 'backgroundColor::isActive': '#000',
18
+ * }
19
+ * };
20
+ *
21
+ * const processedProps = useConditionalStyled(props);
22
+ * // If isActive condition is true, backgroundColor will be '#000', otherwise '#fff'
23
+ * ```
24
+ *
25
+ * @internal
26
+ */
27
+ declare const useConditionalStyled: (props: AnyObject) => AnyObject;
28
+ export default useConditionalStyled;
29
+ //# sourceMappingURL=useConditionalStyled.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useConditionalStyled.d.ts","sourceRoot":"","sources":["../../src/hooks/useConditionalStyled.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,QAAA,MAAM,oBAAoB,GAAI,OAAO,SAAS,cAoC7C,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { useContext, useMemo } from 'react';
2
+ import { useDataState } from '@mapples/state';
3
+ import { keys, reduce } from 'lodash';
4
+ import RenderStateContext from '../context/RenderStateContext';
5
+ /**
6
+ * Hook that processes component props to apply conditional styling based on state conditions.
7
+ *
8
+ * This hook evaluates conditions defined in the `styled` prop and applies conditional styles
9
+ * based on the current render state. Style keys can include condition suffixes (e.g., "backgroundColor::conditionName")
10
+ * that are evaluated against the render state.
11
+ *
12
+ * @param props - Component props that may contain a `styled` object with conditional styles
13
+ * @returns Props with processed conditional styles applied
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * const props = {
18
+ * styled: {
19
+ * backgroundColor: '#fff',
20
+ * 'backgroundColor::isActive': '#000',
21
+ * }
22
+ * };
23
+ *
24
+ * const processedProps = useConditionalStyled(props);
25
+ * // If isActive condition is true, backgroundColor will be '#000', otherwise '#fff'
26
+ * ```
27
+ *
28
+ * @internal
29
+ */
30
+ const useConditionalStyled = (props) => {
31
+ const { getConditionResult } = useDataState();
32
+ const state = useContext(RenderStateContext);
33
+ const propsWithConditional = useMemo(() => {
34
+ const styled = props?.styled;
35
+ if (!styled)
36
+ return props;
37
+ const activeKeys = reduce(keys(styled), (acc, next) => {
38
+ const [styleKey, styleCondition] = next.split('::');
39
+ let conditionActive = false;
40
+ const condition = state?.[styleCondition];
41
+ if (condition) {
42
+ conditionActive = getConditionResult(condition?.condition);
43
+ }
44
+ return {
45
+ ...acc,
46
+ [styleKey]: [styled[styleKey], conditionActive && styled[next]],
47
+ };
48
+ }, {});
49
+ return {
50
+ ...props,
51
+ styled: activeKeys,
52
+ };
53
+ }, [props, state, getConditionResult]);
54
+ return propsWithConditional;
55
+ };
56
+ export default useConditionalStyled;
57
+ //# sourceMappingURL=useConditionalStyled.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useConditionalStyled.js","sourceRoot":"","sources":["../../src/hooks/useConditionalStyled.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,kBAAkB,MAAM,+BAA+B,CA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looking up assets from the render context.
4
+ *
5
+ * Ref properties are strings that reference assets in the format `ref(assetType:uuid:name)`.
6
+ * This hook resolves these references to their actual asset values from the render context.
7
+ *
8
+ * @param refProps - Optional map of ref property names to ref strings
9
+ * @returns Map of resolved asset values, with undefined values filtered out
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * const refProps = {
14
+ * image: 'ref(image:123:logo)',
15
+ * icon: 'ref(icon:456:home)',
16
+ * };
17
+ *
18
+ * const resolved = useRefProps(refProps);
19
+ * // Returns: { image: <ImageAsset>, icon: <IconAsset> }
20
+ * ```
21
+ *
22
+ * @internal
23
+ */
2
24
  declare const useRefProps: (refProps?: RefPropsMap) => {
3
25
  [x: string]: any;
4
26
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useRefProps.d.ts","sourceRoot":"","sources":["../../src/hooks/useRefProps.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAIvC,QAAA,MAAM,WAAW,GAAI,WAAW,WAAW;;CAQ1C,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"useRefProps.d.ts","sourceRoot":"","sources":["../../src/hooks/useRefProps.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAIvC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,QAAA,MAAM,WAAW,GAAI,WAAW,WAAW;;CAQ1C,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1,5 +1,27 @@
1
1
  import { mapValues } from 'lodash';
2
2
  import useRender from './useRender';
3
+ /**
4
+ * Hook that resolves ref properties by looking up assets from the render context.
5
+ *
6
+ * Ref properties are strings that reference assets in the format `ref(assetType:uuid:name)`.
7
+ * This hook resolves these references to their actual asset values from the render context.
8
+ *
9
+ * @param refProps - Optional map of ref property names to ref strings
10
+ * @returns Map of resolved asset values, with undefined values filtered out
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * const refProps = {
15
+ * image: 'ref(image:123:logo)',
16
+ * icon: 'ref(icon:456:home)',
17
+ * };
18
+ *
19
+ * const resolved = useRefProps(refProps);
20
+ * // Returns: { image: <ImageAsset>, icon: <IconAsset> }
21
+ * ```
22
+ *
23
+ * @internal
24
+ */
3
25
  const useRefProps = (refProps) => {
4
26
  const { assets } = useRender();
5
27
  return mapValues(refProps, (value) => {
@@ -1 +1 @@
1
- {"version":3,"file":"useRefProps.js","sourceRoot":"","sources":["../../src/hooks/useRefProps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAInC,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,MAAM,WAAW,GAAG,CAAC,QAAsB,EAAE,EAAE;IAC7C,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,CAAC;IAE/B,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;QACnC,IAAI,CAAC,KAAK;YAAE,OAAO;QAEnB,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"useRefProps.js","sourceRoot":"","sources":["../../src/hooks/useRefProps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAInC,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,GAAG,CAAC,QAAsB,EAAE,EAAE;IAC7C,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,CAAC;IAE/B,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;QACnC,IAAI,CAAC,KAAK;YAAE,OAAO;QAEnB,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -58,6 +58,24 @@ export interface RenderComponentType {
58
58
  actionProps?: ActionPropsMap;
59
59
  refProps?: RefPropsMap;
60
60
  }
61
+ /**
62
+ * Represents a state condition used for conditional styling and rendering.
63
+ *
64
+ * State conditions allow components to apply different styles or behaviors
65
+ * based on dynamic state values. The condition string follows the format
66
+ * used by the state package's condition system.
67
+ *
68
+ * @interface StateCondition
69
+ * @property {string} name - The name identifier for this condition
70
+ * @property {string} condition - The condition string (e.g., "user.age::eq::18")
71
+ * @property {string} id - Unique identifier for this condition instance
72
+ * @public
73
+ */
74
+ export interface StateCondition {
75
+ name: string;
76
+ condition: string;
77
+ id: string;
78
+ }
61
79
  /**
62
80
  * Represents the complete render DOM structure.
63
81
  * Extends ChildComponents with a special 'root' component.
@@ -65,8 +83,9 @@ export interface RenderComponentType {
65
83
  * @interface RenderDom
66
84
  * @property {RenderComponentType} root - The root component of the render tree
67
85
  */
68
- export interface RenderDom extends ChildComponents {
86
+ export interface RenderDom {
69
87
  root: RenderComponentType;
88
+ state?: Record<string, StateCondition>;
70
89
  }
71
90
  /**
72
91
  * Props for the main Render component.
@@ -75,7 +94,7 @@ export interface RenderDom extends ChildComponents {
75
94
  * @property {RenderComponentType} root - The root component to render
76
95
  * @property {FC<RenderComponentType>} [CustomRenderComponent] - Optional custom render component to override default rendering
77
96
  */
78
- export type RenderProps = Pick<RenderDom, 'root'> & {
97
+ export type RenderProps = Pick<RenderDom, 'root' | 'state'> & {
79
98
  CustomRenderComponent?: FC<RenderComponentType>;
80
99
  };
81
100
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAE3B,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEjE;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CA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WAAW,SAAS;IACxB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CACxC;AAED;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG;IAC5D,qBAAqB,CAAC,EAAE,EAAE,CAAC,mBAAmB,CAAC,CAAC;CACjD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,oBAAoB,CAAC;IACjC,MAAM,EAAE,SAAS,CAAC;CACnB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapples/render",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {