Fix templates copying and export SafeExpression

This commit is contained in:
4eb0da
2022-09-29 18:10:41 +03:00
parent 5c20297e0f
commit 6734b89fdd
101 changed files with 282 additions and 113 deletions
@@ -1,4 +1,4 @@
{
"lang": "typescript",
"header": "// Generated code. Do not modify.\n\nimport { Exact, IntBoolean, NonEmptyArray } from '../helper';\nimport { TemplateBlock, Type } from '../template';\nimport { DivExpression } from '../expression';\n"
"header": "// Generated code. Do not modify.\n\nimport { Exact, IntBoolean, NonEmptyArray } from '../helper';\nimport { TemplateBlock, Type } from '../template';\nimport { DivExpression } from '../safe-expression';\n"
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@divkitframework/jsonbuilder",
"version": "1.3.0",
"version": "1.4.0",
"description": "DivKit TypeScript JSON Builder",
"main": "./dist/jsonbuilder.js",
"module": "./dist/es/jsonbuilder.js",
+2 -4
View File
@@ -1,7 +1,7 @@
import { DivExpression, UnsafeDivExpression } from './unsafe-expression';
import { DivExpression, SafeDivExpression } from './safe-expression';
export function expression(expression: string): DivExpression {
return new UnsafeDivExpression(expression);
return new SafeDivExpression(expression);
}
const replacer: Record<string, string> = {
@@ -14,5 +14,3 @@ export function escapeExpression(str: string): string {
return replacer[full];
});
}
export { DivExpression };
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
/**
* A Boolean variable in binary format.
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
/**
* Variable — HEX color as a string.
+1 -1
View File
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivContainer,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
/**
* Accessibility for disabled people.
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
IDivDownloadCallbacks,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
export type DivAlignmentHorizontal =
| 'left'
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
export type DivAlignmentVertical =
| 'top'
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivAnimationInterpolator,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
export type DivAnimationInterpolator =
| 'linear'
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivAppearanceTransition,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivAppearanceSetTransition,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
/**
* Size with a fixed aspect ratio. It counts height from width and ignores other specified height
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivImageBackground,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivAlignmentHorizontal,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
IDivCornersRadius,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivAnimationInterpolator,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivChangeTransition,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivChangeBoundsTransition,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
Div,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
/**
* Sets corner rounding.
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivFixedCount,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
Div,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
Div,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivSizeUnit,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
IDivAction,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivShapeDrawable,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivSizeUnit,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
/**
* Extension that affects an element.
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivAnimationInterpolator,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
/**
* Fixed number of repetitions.
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivSizeUnit,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivBackground,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
export type DivFontFamily =
| 'text'
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
export type DivFontWeight =
| 'light'
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
Div,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivAlignmentHorizontal,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
Div,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivAlignmentHorizontal,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivAlignmentHorizontal,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
export type DivImageScale =
| 'fill'
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivAlignmentHorizontal,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
/**
* Infinite number of repetitions.
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivAlignmentHorizontal,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
export type DivLineStyle =
| 'none'
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
/**
* Linear gradient.
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
/**
* Element size adjusts to a parent element.
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivFixedSize,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivPercentageSize,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
Div,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivNeighbourPageSize,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
Div,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
/**
* Percentage value of the element size.
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivPivotFixed,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivSizeUnit,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
/**
* Location of the coordinate of the axis of rotation as a percentage relative to the element.
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
IDivDimension,
@@ -2,7 +2,12 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivRadialGradientCenter,
DivRadialGradientRadius,
} from './';
/**
* Radial gradient.
@@ -12,23 +17,21 @@ export class DivRadialGradient<T extends DivRadialGradientProps = DivRadialGradi
readonly type = 'radial_gradient';
/**
* Shift of the central point of the gradient relative to the left edge along the X axis in the
* range `0..1`.
* Shift of the central point of the gradient relative to the left edge along the X axis.
*/
center_x?: Type<number | DivExpression>;
center_x?: Type<DivRadialGradientCenter>;
/**
* Shift of the central point of the gradient relative to the upper edge along the Y axis in the
* range `0..1`.
* Shift of the central point of the gradient relative to the upper edge along the Y axis.
*/
center_y?: Type<number | DivExpression>;
center_y?: Type<DivRadialGradientCenter>;
/**
* Colors. Gradient points will be located at an equal distance from each other.
*/
colors: Type<NonEmptyArray<string | DivExpression>>;
/**
* Radius of the gradient transition in `dp`.
* Radius of the gradient transition.
*/
radius: Type<number | DivExpression>;
radius?: Type<DivRadialGradientRadius>;
constructor(props: Exact<DivRadialGradientProps, T>) {
this.center_x = props.center_x;
@@ -40,21 +43,19 @@ export class DivRadialGradient<T extends DivRadialGradientProps = DivRadialGradi
export interface DivRadialGradientProps {
/**
* Shift of the central point of the gradient relative to the left edge along the X axis in the
* range `0..1`.
* Shift of the central point of the gradient relative to the left edge along the X axis.
*/
center_x?: Type<number | DivExpression>;
center_x?: Type<DivRadialGradientCenter>;
/**
* Shift of the central point of the gradient relative to the upper edge along the Y axis in the
* range `0..1`.
* Shift of the central point of the gradient relative to the upper edge along the Y axis.
*/
center_y?: Type<number | DivExpression>;
center_y?: Type<DivRadialGradientCenter>;
/**
* Colors. Gradient points will be located at an equal distance from each other.
*/
colors: Type<NonEmptyArray<string | DivExpression>>;
/**
* Radius of the gradient transition in `dp`.
* Radius of the gradient transition.
*/
radius: Type<number | DivExpression>;
radius?: Type<DivRadialGradientRadius>;
}
@@ -0,0 +1,14 @@
// Generated code. Do not modify.
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../safe-expression';
import {
DivRadialGradientFixedCenter,
DivRadialGradientRelativeCenter,
} from './';
export type DivRadialGradientCenter =
| DivRadialGradientFixedCenter
| DivRadialGradientRelativeCenter;
@@ -0,0 +1,44 @@
// Generated code. Do not modify.
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../safe-expression';
import {
DivSizeUnit,
} from './';
/**
* Fixed central point of the gradient.
*/
export class DivRadialGradientFixedCenter<T extends DivRadialGradientFixedCenterProps = DivRadialGradientFixedCenterProps> {
readonly _props?: Exact<DivRadialGradientFixedCenterProps, T>;
readonly type = 'fixed';
/**
* Unit of measurement. To learn more about units of size measurement, see [Layout inside the
* card](../../layout.dita).
*/
unit?: Type<DivSizeUnit | DivExpression>;
/**
* Shift value of the fixed central point of the gradient.
*/
value: Type<number | DivExpression>;
constructor(props: Exact<DivRadialGradientFixedCenterProps, T>) {
this.unit = props.unit;
this.value = props.value;
}
}
export interface DivRadialGradientFixedCenterProps {
/**
* Unit of measurement. To learn more about units of size measurement, see [Layout inside the
* card](../../layout.dita).
*/
unit?: Type<DivSizeUnit | DivExpression>;
/**
* Shift value of the fixed central point of the gradient.
*/
value: Type<number | DivExpression>;
}
@@ -0,0 +1,14 @@
// Generated code. Do not modify.
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../safe-expression';
import {
DivFixedSize,
DivRadialGradientRelativeRadius,
} from './';
export type DivRadialGradientRadius =
| DivFixedSize
| DivRadialGradientRelativeRadius;
@@ -0,0 +1,29 @@
// Generated code. Do not modify.
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../safe-expression';
/**
* Relative central point of the gradient.
*/
export class DivRadialGradientRelativeCenter<T extends DivRadialGradientRelativeCenterProps = DivRadialGradientRelativeCenterProps> {
readonly _props?: Exact<DivRadialGradientRelativeCenterProps, T>;
readonly type = 'relative';
/**
* Shift value of the central relative point of the gradient in the range `0..1`.
*/
value: Type<number | DivExpression>;
constructor(props: Exact<DivRadialGradientRelativeCenterProps, T>) {
this.value = props.value;
}
}
export interface DivRadialGradientRelativeCenterProps {
/**
* Shift value of the central relative point of the gradient in the range `0..1`.
*/
value: Type<number | DivExpression>;
}
@@ -0,0 +1,35 @@
// Generated code. Do not modify.
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../safe-expression';
/**
* Relative radius of the gradient transition.
*/
export class DivRadialGradientRelativeRadius<T extends DivRadialGradientRelativeRadiusProps = DivRadialGradientRelativeRadiusProps> {
readonly _props?: Exact<DivRadialGradientRelativeRadiusProps, T>;
readonly type = 'relative';
/**
* Type of relative radius of the gradient transition.
*/
value: Type<DivRadialGradientRelativeRadiusValue | DivExpression>;
constructor(props: Exact<DivRadialGradientRelativeRadiusProps, T>) {
this.value = props.value;
}
}
export interface DivRadialGradientRelativeRadiusProps {
/**
* Type of relative radius of the gradient transition.
*/
value: Type<DivRadialGradientRelativeRadiusValue | DivExpression>;
}
export type DivRadialGradientRelativeRadiusValue =
| 'nearest_corner'
| 'farthest_corner'
| 'nearest_side'
| 'farthest_side';
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivFixedSize,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivAnimationInterpolator,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivAlignmentHorizontal,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
IDivPoint,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivRoundedRectangleShape,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivShape,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivFixedSize,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
export type DivSizeUnit =
| 'dp'
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivAnimationInterpolator,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivAlignmentHorizontal,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
/**
* Solid background color.
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
Div,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivSizeUnit,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
Div,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivAlignmentHorizontal,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivLinearGradient,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
Div,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivPivot,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
DivAnimationInterpolator,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
export type DivTransitionSelector =
| 'none'
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
export type DivTransitionTrigger =
| 'data_change'
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
IDivAction,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
BooleanVariable,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
export type DivVisibility =
| 'visible'
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
import {
IDivDownloadCallbacks,
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
/**
* The size of an element adjusts to its contents.
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
/**
* An integer variable.
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
/**
* A floating-point variable.
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
/**
* A string variable.
@@ -2,7 +2,7 @@
import { Exact, IntBoolean, NonEmptyArray } from '../helper';
import { TemplateBlock, Type } from '../template';
import { DivExpression } from '../expression';
import { DivExpression } from '../safe-expression';
/**
* Variable — URL as a string.
@@ -57,6 +57,11 @@ export * from './DivPivotFixed';
export * from './DivPivotPercentage';
export * from './DivPoint';
export * from './DivRadialGradient';
export * from './DivRadialGradientCenter';
export * from './DivRadialGradientFixedCenter';
export * from './DivRadialGradientRadius';
export * from './DivRadialGradientRelativeCenter';
export * from './DivRadialGradientRelativeRadius';
export * from './DivRoundedRectangleShape';
export * from './DivScaleTransition';
export * from './DivSeparator';
+2 -1
View File
@@ -1,4 +1,5 @@
import { ITemplates } from './template';
import { SafeDivExpression } from './safe-expression';
export type NonEmptyArray<T> = T[];
@@ -37,7 +38,7 @@ export function copyTemplates<T extends ITemplates>(templates: T): T {
const copy: ITemplates = {};
const placeHolder = (node: unknown): unknown => {
if (!node || ['string', 'number'].includes(typeof node)) {
if (!node || ['string', 'number', 'boolean'].includes(typeof node) || node instanceof SafeDivExpression) {
return node;
}
+1
View File
@@ -3,6 +3,7 @@ export * from './div-utils';
export * from './expression';
export * from './generated';
export * from './helper';
export * from './safe-expression';
export * from './template';
export * from './template-helper';
export * from './template-helper-deps';
@@ -4,7 +4,7 @@ export interface DivExpression {
[expr]: string;
}
export class UnsafeDivExpression implements DivExpression {
export class SafeDivExpression implements DivExpression {
public [expr]: string;
public constructor(expression: string) {
+2 -2
View File
@@ -2,7 +2,7 @@
import { Div } from './generated/Div';
import { IDivData } from './generated/DivData';
import { UnsafeDivExpression } from './unsafe-expression';
import { SafeDivExpression } from './safe-expression';
import { escapeExpression } from './expression';
export interface ITemplates {
@@ -50,7 +50,7 @@ export function template<T extends string = any, U = object>(type: T, props?: U)
export function escapeCard(obj: unknown): unknown {
if (typeof obj === 'string') {
return escapeExpression(obj);
} else if (obj instanceof UnsafeDivExpression) {
} else if (obj instanceof SafeDivExpression) {
return obj.toJSON();
} else if (obj && typeof obj === 'object') {
if (Array.isArray(obj)) {

Some files were not shown because too many files have changed in this diff Show More