@jag-k/scriptable-jsx 1.0.1 → 1.1.2
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/dist/alert.d.ts +1 -1
- package/dist/index.d.ts +9 -10
- package/dist/index.js +7 -7
- package/dist/widget.d.ts +8 -8
- package/package.json +3 -3
- package/types/index.d.ts +113 -6
- package/types/alert.d.ts +0 -24
- package/types/widget.d.ts +0 -95
package/dist/alert.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare function alertCreateElement(element: unknown, props: Record<string, any>, ...children: any[]): Alert | {
|
|
3
3
|
type: "text-field";
|
|
4
4
|
props: Record<string, any>;
|
|
5
|
-
children?:
|
|
5
|
+
children?: undefined;
|
|
6
6
|
} | {
|
|
7
7
|
type: "action";
|
|
8
8
|
props: Record<string, any>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
/// <reference path="../types/index.d.ts" />
|
|
2
1
|
/// <reference types="@types/scriptable-ios" />
|
|
3
2
|
export declare class ScriptableJSX {
|
|
4
3
|
static createElement(element: unknown, props: Record<string, any>, ...children: any[]): Alert | {
|
|
5
4
|
type: "text-field";
|
|
6
5
|
props: Record<string, any>;
|
|
7
|
-
children?:
|
|
6
|
+
children?: undefined;
|
|
8
7
|
} | {
|
|
9
8
|
type: "action";
|
|
10
9
|
props: Record<string, any>;
|
|
@@ -13,26 +12,26 @@ export declare class ScriptableJSX {
|
|
|
13
12
|
type: "text";
|
|
14
13
|
props: Record<string, any>;
|
|
15
14
|
text: string;
|
|
16
|
-
children?:
|
|
15
|
+
children?: undefined;
|
|
17
16
|
} | {
|
|
18
17
|
type: "stack";
|
|
19
18
|
props: Record<string, any>;
|
|
20
19
|
children: any[];
|
|
21
|
-
text?:
|
|
20
|
+
text?: undefined;
|
|
22
21
|
} | {
|
|
23
22
|
type: "spacer";
|
|
24
23
|
props: Record<string, any>;
|
|
25
|
-
text?:
|
|
26
|
-
children?:
|
|
24
|
+
text?: undefined;
|
|
25
|
+
children?: undefined;
|
|
27
26
|
} | {
|
|
28
27
|
type: "image";
|
|
29
28
|
props: Record<string, any>;
|
|
30
|
-
text?:
|
|
31
|
-
children?:
|
|
29
|
+
text?: undefined;
|
|
30
|
+
children?: undefined;
|
|
32
31
|
} | {
|
|
33
32
|
type: "date";
|
|
34
33
|
props: Record<string, any>;
|
|
35
|
-
text?:
|
|
36
|
-
children?:
|
|
34
|
+
text?: undefined;
|
|
35
|
+
children?: undefined;
|
|
37
36
|
} | undefined;
|
|
38
37
|
}
|
package/dist/index.js
CHANGED
|
@@ -262,14 +262,15 @@ function processContainerChildren(widget, children) {
|
|
|
262
262
|
}
|
|
263
263
|
case "image": {
|
|
264
264
|
let init;
|
|
265
|
-
|
|
266
|
-
|
|
265
|
+
const { data } = child.props || {};
|
|
266
|
+
if (typeof data === "string") {
|
|
267
|
+
init = Image.fromFile(child.props.fileURL);
|
|
267
268
|
}
|
|
268
|
-
else if (
|
|
269
|
-
init =
|
|
269
|
+
else if (data.size) {
|
|
270
|
+
init = data;
|
|
270
271
|
}
|
|
271
|
-
else
|
|
272
|
-
init = Image.
|
|
272
|
+
else {
|
|
273
|
+
init = Image.fromData(data);
|
|
273
274
|
}
|
|
274
275
|
const image = widget.addImage(init);
|
|
275
276
|
processImageProps(image, child.props || {});
|
|
@@ -383,7 +384,6 @@ function alertCreateElement(element, props, ...children) {
|
|
|
383
384
|
}
|
|
384
385
|
}
|
|
385
386
|
|
|
386
|
-
/// <reference path="../types/index.d.ts" />
|
|
387
387
|
const createElements = [widgetCreateElement, alertCreateElement];
|
|
388
388
|
class ScriptableJSX {
|
|
389
389
|
static createElement(element, props, ...children) {
|
package/dist/widget.d.ts
CHANGED
|
@@ -3,25 +3,25 @@ export declare function widgetCreateElement(element: unknown, props: Record<stri
|
|
|
3
3
|
type: "text";
|
|
4
4
|
props: Record<string, any>;
|
|
5
5
|
text: string;
|
|
6
|
-
children?:
|
|
6
|
+
children?: undefined;
|
|
7
7
|
} | {
|
|
8
8
|
type: "stack";
|
|
9
9
|
props: Record<string, any>;
|
|
10
10
|
children: any[];
|
|
11
|
-
text?:
|
|
11
|
+
text?: undefined;
|
|
12
12
|
} | {
|
|
13
13
|
type: "spacer";
|
|
14
14
|
props: Record<string, any>;
|
|
15
|
-
text?:
|
|
16
|
-
children?:
|
|
15
|
+
text?: undefined;
|
|
16
|
+
children?: undefined;
|
|
17
17
|
} | {
|
|
18
18
|
type: "image";
|
|
19
19
|
props: Record<string, any>;
|
|
20
|
-
text?:
|
|
21
|
-
children?:
|
|
20
|
+
text?: undefined;
|
|
21
|
+
children?: undefined;
|
|
22
22
|
} | {
|
|
23
23
|
type: "date";
|
|
24
24
|
props: Record<string, any>;
|
|
25
|
-
text?:
|
|
26
|
-
children?:
|
|
25
|
+
text?: undefined;
|
|
26
|
+
children?: undefined;
|
|
27
27
|
} | undefined;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@jag-k/scriptable-jsx",
|
|
3
3
|
"description": "Create a Scriptable bundle from JSX",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.1.2",
|
|
6
6
|
"author": {
|
|
7
7
|
"email": "jag.konon@gmail.com",
|
|
8
8
|
"name": "Jag_k",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build": "rollup -c",
|
|
28
|
-
"watch": "rollup -cw",
|
|
28
|
+
"watch": "npm run prebuild && rollup -cw",
|
|
29
29
|
"prebuild": "rm -rf dist"
|
|
30
30
|
},
|
|
31
31
|
"files": [
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
],
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@rollup/plugin-typescript": "^8.3.4",
|
|
45
|
-
"rollup": "^2.
|
|
45
|
+
"rollup": "^2.78.0",
|
|
46
46
|
"tslib": "^2.4.0"
|
|
47
47
|
},
|
|
48
48
|
"types": "./dist/index.d.ts",
|
package/types/index.d.ts
CHANGED
|
@@ -1,10 +1,117 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare namespace JSX {
|
|
2
|
+
// Widgets types
|
|
3
|
+
type JSXColor = Color | string | number;
|
|
4
|
+
type Align = "left" | "right" | "center";
|
|
5
|
+
type ContentAlign = "top" | "bottom" | "center";
|
|
6
|
+
type DateStyle = "time" | "date" | "relative" | "offset" | "timer";
|
|
3
7
|
|
|
4
|
-
|
|
5
|
-
|
|
8
|
+
interface Alienable {
|
|
9
|
+
align?: Align;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface ContentAlienable {
|
|
13
|
+
align?: ContentAlign;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface PaddingProps {
|
|
17
|
+
'p-all'?: number;
|
|
18
|
+
|
|
19
|
+
'p-x'?: number;
|
|
20
|
+
'p-y'?: number;
|
|
21
|
+
|
|
22
|
+
'p-top'?: number;
|
|
23
|
+
'p-bottom'?: number;
|
|
24
|
+
'p-right'?: number;
|
|
25
|
+
'p-left'?: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface WidgetAndStackBase extends PaddingProps {
|
|
29
|
+
spacing?: number;
|
|
30
|
+
backgroundColor?: JSXColor;
|
|
31
|
+
backgroundImage?: Image;
|
|
32
|
+
backgroundGradient?: LinearGradient;
|
|
33
|
+
url?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface StackProps extends WidgetAndStackBase, ContentAlienable {
|
|
37
|
+
layout?: "vertical" | "horizontal";
|
|
38
|
+
size?: Size;
|
|
39
|
+
cornerRadius?: number;
|
|
40
|
+
borderWidth?: number;
|
|
41
|
+
borderColor?: JSXColor;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface WidgetProps extends WidgetAndStackBase {
|
|
45
|
+
refreshAfterDate?: Date;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface SpacerProps {
|
|
49
|
+
length?: number;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
interface TextProps extends Alienable {
|
|
53
|
+
font?: Font;
|
|
54
|
+
color?: JSXColor;
|
|
55
|
+
opacity?: number;
|
|
56
|
+
lineLimit?: number;
|
|
57
|
+
minimumScaleFactor?: number;
|
|
58
|
+
shadowColor?: JSXColor;
|
|
59
|
+
shadowOffset?: Point;
|
|
60
|
+
shadowRadius?: number;
|
|
61
|
+
url?: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
type ImageContentMode = "fitting" | "filling";
|
|
65
|
+
|
|
66
|
+
interface ImageProps extends Alienable {
|
|
67
|
+
data: string /* file url */ | Image | Data;
|
|
68
|
+
size?: Size;
|
|
69
|
+
cornerRadius?: number;
|
|
70
|
+
resizable?: boolean;
|
|
71
|
+
opacity?: number;
|
|
72
|
+
borderColor?: JSXColor;
|
|
73
|
+
borderWidth?: number;
|
|
74
|
+
containerRelativeShape?: boolean;
|
|
75
|
+
tintColor?: JSXColor;
|
|
76
|
+
url?: string;
|
|
77
|
+
contentMode?: ImageContentMode;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
interface DateProps extends TextProps {
|
|
81
|
+
date: Date | string | number;
|
|
82
|
+
style?: DateStyle;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Alert types
|
|
86
|
+
export interface AlertProps {
|
|
87
|
+
title?: string;
|
|
88
|
+
message?: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface ActionProps {
|
|
92
|
+
type?: "action" | "cancel" | "destructive";
|
|
93
|
+
text?: string;
|
|
94
|
+
children?: string | string[];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface TextFieldProps {
|
|
98
|
+
placeholder?: string;
|
|
99
|
+
text?: string;
|
|
100
|
+
secure?: boolean;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
interface IntrinsicElements {
|
|
104
|
+
// Widget Elements
|
|
105
|
+
widget: WidgetProps;
|
|
106
|
+
stack: StackProps;
|
|
107
|
+
image: ImageProps;
|
|
108
|
+
spacer: SpacerProps;
|
|
109
|
+
text: TextProps;
|
|
110
|
+
date: DateProps;
|
|
6
111
|
|
|
7
|
-
|
|
8
|
-
|
|
112
|
+
// Alert Elements
|
|
113
|
+
alert: AlertProps;
|
|
114
|
+
action: ActionProps;
|
|
115
|
+
'text-field': TextFieldProps;
|
|
9
116
|
}
|
|
10
117
|
}
|
package/types/alert.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export declare namespace JSX {
|
|
2
|
-
interface AlertProps {
|
|
3
|
-
title?: string;
|
|
4
|
-
message?: string;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
interface ActionProps {
|
|
8
|
-
type?: "action" | "cancel" | "destructive";
|
|
9
|
-
text?: string;
|
|
10
|
-
children?: string | string[];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface TextFieldProps {
|
|
14
|
-
placeholder?: string;
|
|
15
|
-
text?: string;
|
|
16
|
-
secure?: boolean;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
interface IntrinsicElements {
|
|
20
|
-
alert: AlertProps;
|
|
21
|
-
action: ActionProps;
|
|
22
|
-
'text-field': TextFieldProps;
|
|
23
|
-
}
|
|
24
|
-
}
|
package/types/widget.d.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
export declare namespace JSX {
|
|
2
|
-
type JSXColor = Color | string | number;
|
|
3
|
-
type Align = "left" | "right" | "center";
|
|
4
|
-
type ContentAlign = "top" | "bottom" | "center";
|
|
5
|
-
type DateStyle = "time" | "date" | "relative" | "offset" | "timer";
|
|
6
|
-
|
|
7
|
-
interface Alienable {
|
|
8
|
-
align?: Align;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface ContentAlienable {
|
|
12
|
-
align?: ContentAlign;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
interface PaddingProps {
|
|
16
|
-
'p-all'?: number;
|
|
17
|
-
|
|
18
|
-
'p-x'?: number;
|
|
19
|
-
'p-y'?: number;
|
|
20
|
-
|
|
21
|
-
'p-top'?: number;
|
|
22
|
-
'p-bottom'?: number;
|
|
23
|
-
'p-right'?: number;
|
|
24
|
-
'p-left'?: number;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
interface WidgetAndStackBase extends PaddingProps {
|
|
28
|
-
spacing?: number;
|
|
29
|
-
backgroundColor?: JSXColor;
|
|
30
|
-
backgroundImage?: Image;
|
|
31
|
-
backgroundGradient?: LinearGradient;
|
|
32
|
-
url?: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
interface StackProps extends WidgetAndStackBase, ContentAlienable {
|
|
36
|
-
layout?: "vertical" | "horizontal";
|
|
37
|
-
size?: Size;
|
|
38
|
-
cornerRadius?: number;
|
|
39
|
-
borderWidth?: number;
|
|
40
|
-
borderColor?: JSXColor;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
interface WidgetProps extends WidgetAndStackBase {
|
|
44
|
-
refreshAfterDate?: Date;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
interface SpacerProps {
|
|
48
|
-
length?: number;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
interface TextProps extends Alienable {
|
|
52
|
-
font?: Font;
|
|
53
|
-
color?: JSXColor;
|
|
54
|
-
opacity?: number;
|
|
55
|
-
lineLimit?: number;
|
|
56
|
-
minimumScaleFactor?: number;
|
|
57
|
-
shadowColor?: JSXColor;
|
|
58
|
-
shadowOffset?: Point;
|
|
59
|
-
shadowRadius?: number;
|
|
60
|
-
url?: string;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
type ImageContentMode = "fitting" | "filling";
|
|
64
|
-
|
|
65
|
-
interface ImageCommonProps extends Alienable {
|
|
66
|
-
size?: Size;
|
|
67
|
-
cornerRadius?: number;
|
|
68
|
-
resizable?: boolean;
|
|
69
|
-
opacity?: number;
|
|
70
|
-
borderColor?: JSXColor;
|
|
71
|
-
borderWidth?: number;
|
|
72
|
-
containerRelativeShape?: boolean;
|
|
73
|
-
tintColor?: JSXColor;
|
|
74
|
-
url?: string;
|
|
75
|
-
contentMode?: ImageContentMode;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
type ImageProps =
|
|
79
|
-
& ImageCommonProps
|
|
80
|
-
& ({ data: Data } | { fileURL: string } | { image: Image });
|
|
81
|
-
|
|
82
|
-
interface DateProps extends TextProps {
|
|
83
|
-
date: Date | string | number;
|
|
84
|
-
style?: DateStyle;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
interface IntrinsicElements {
|
|
88
|
-
widget: WidgetProps;
|
|
89
|
-
stack: StackProps;
|
|
90
|
-
image: ImageProps;
|
|
91
|
-
spacer: SpacerProps;
|
|
92
|
-
text: TextProps;
|
|
93
|
-
date: DateProps;
|
|
94
|
-
}
|
|
95
|
-
}
|