@fugood/bricks-project 2.22.0-beta.9 → 2.22.1
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/compile/action-name-map.ts +108 -17
- package/compile/index.ts +10 -1
- package/package.json +3 -4
- package/tools/postinstall.ts +16 -9
- package/types/animation.ts +2 -1
- package/types/brick-base.ts +79 -0
- package/types/bricks/3DViewer.ts +200 -0
- package/types/bricks/Camera.ts +195 -0
- package/types/bricks/Chart.ts +362 -0
- package/types/bricks/GenerativeMedia.ts +240 -0
- package/types/bricks/Icon.ts +93 -0
- package/types/bricks/Image.ts +104 -0
- package/types/bricks/Items.ts +461 -0
- package/types/bricks/Lottie.ts +159 -0
- package/types/bricks/QrCode.ts +112 -0
- package/types/bricks/Rect.ts +110 -0
- package/types/bricks/RichText.ts +123 -0
- package/types/bricks/Rive.ts +209 -0
- package/types/bricks/Slideshow.ts +155 -0
- package/types/bricks/Svg.ts +94 -0
- package/types/bricks/Text.ts +143 -0
- package/types/bricks/TextInput.ts +231 -0
- package/types/bricks/Video.ts +170 -0
- package/types/bricks/VideoStreaming.ts +107 -0
- package/types/bricks/WebRtcStream.ts +60 -0
- package/types/bricks/WebView.ts +157 -0
- package/types/bricks/index.ts +19 -0
- package/types/common.ts +8 -3
- package/types/data.ts +6 -0
- package/types/generators/AlarmClock.ts +102 -0
- package/types/generators/Assistant.ts +546 -0
- package/types/generators/BleCentral.ts +225 -0
- package/types/generators/BlePeripheral.ts +202 -0
- package/types/generators/CanvasMap.ts +57 -0
- package/types/generators/CastlesPay.ts +77 -0
- package/types/generators/DataBank.ts +123 -0
- package/types/generators/File.ts +351 -0
- package/types/generators/GraphQl.ts +124 -0
- package/types/generators/Http.ts +117 -0
- package/types/generators/HttpServer.ts +164 -0
- package/types/generators/Information.ts +97 -0
- package/types/generators/Intent.ts +107 -0
- package/types/generators/Iterator.ts +95 -0
- package/types/generators/Keyboard.ts +85 -0
- package/types/generators/LlmAnthropicCompat.ts +188 -0
- package/types/generators/LlmGgml.ts +719 -0
- package/types/generators/LlmOnnx.ts +184 -0
- package/types/generators/LlmOpenAiCompat.ts +206 -0
- package/types/generators/LlmQualcommAiEngine.ts +213 -0
- package/types/generators/Mcp.ts +294 -0
- package/types/generators/McpServer.ts +248 -0
- package/types/generators/MediaFlow.ts +142 -0
- package/types/generators/MqttBroker.ts +121 -0
- package/types/generators/MqttClient.ts +129 -0
- package/types/generators/Question.ts +395 -0
- package/types/generators/RealtimeTranscription.ts +180 -0
- package/types/generators/RerankerGgml.ts +153 -0
- package/types/generators/SerialPort.ts +141 -0
- package/types/generators/SoundPlayer.ts +86 -0
- package/types/generators/SoundRecorder.ts +113 -0
- package/types/generators/SpeechToTextGgml.ts +462 -0
- package/types/generators/SpeechToTextOnnx.ts +227 -0
- package/types/generators/SpeechToTextPlatform.ts +75 -0
- package/types/generators/SqLite.ts +118 -0
- package/types/generators/Step.ts +101 -0
- package/types/generators/Tcp.ts +120 -0
- package/types/generators/TcpServer.ts +137 -0
- package/types/generators/TextToSpeechGgml.ts +182 -0
- package/types/generators/TextToSpeechOnnx.ts +169 -0
- package/types/generators/TextToSpeechOpenAiLike.ts +113 -0
- package/types/generators/ThermalPrinter.ts +185 -0
- package/types/generators/Tick.ts +75 -0
- package/types/generators/Udp.ts +109 -0
- package/types/generators/VadGgml.ts +211 -0
- package/types/generators/VectorStore.ts +223 -0
- package/types/generators/Watchdog.ts +96 -0
- package/types/generators/WebCrawler.ts +97 -0
- package/types/generators/WebRtc.ts +165 -0
- package/types/generators/WebSocket.ts +142 -0
- package/types/generators/index.ts +50 -0
- package/types/system.ts +64 -0
- package/utils/data.ts +45 -0
- package/utils/event-props.ts +89 -13
- package/types/bricks.ts +0 -3168
- package/types/generators.ts +0 -7633
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
|
|
2
|
+
import type { Data, DataLink } from '../data'
|
|
3
|
+
import type {
|
|
4
|
+
Generator,
|
|
5
|
+
EventAction,
|
|
6
|
+
ActionWithDataParams,
|
|
7
|
+
ActionWithParams,
|
|
8
|
+
Action,
|
|
9
|
+
EventProperty,
|
|
10
|
+
} from '../common'
|
|
11
|
+
|
|
12
|
+
/* Start HTTP server */
|
|
13
|
+
export type GeneratorHTTPServerActionStart = Action & {
|
|
14
|
+
__actionName: 'GENERATOR_HTTP_SERVER_START'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* Stop HTTP server */
|
|
18
|
+
export type GeneratorHTTPServerActionStop = Action & {
|
|
19
|
+
__actionName: 'GENERATOR_HTTP_SERVER_STOP'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* Clear upload temp files */
|
|
23
|
+
export type GeneratorHTTPServerActionClearTempFiles = Action & {
|
|
24
|
+
__actionName: 'GENERATOR_HTTP_SERVER_CLEAR_TEMP_FILES'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* End stream */
|
|
28
|
+
export type GeneratorHTTPServerActionEndStream = Action & {
|
|
29
|
+
__actionName: 'GENERATOR_HTTP_SERVER_END_STREAM'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface GeneratorHTTPServerDef {
|
|
33
|
+
/*
|
|
34
|
+
Default property:
|
|
35
|
+
{
|
|
36
|
+
"init": false,
|
|
37
|
+
"method": "GET",
|
|
38
|
+
"path": "/",
|
|
39
|
+
"idleTimeout": 10000,
|
|
40
|
+
"authType": "none",
|
|
41
|
+
"asyncMode": false,
|
|
42
|
+
"resStatusCode": 200,
|
|
43
|
+
"resContentType": "text/plain",
|
|
44
|
+
"tls": false,
|
|
45
|
+
"tlsKeyPairPassword": ""
|
|
46
|
+
}
|
|
47
|
+
*/
|
|
48
|
+
property?: {
|
|
49
|
+
/* Start HTTP server on generator initialized */
|
|
50
|
+
init?: boolean | DataLink
|
|
51
|
+
/* Bind port of HTTP server */
|
|
52
|
+
port?: number | DataLink
|
|
53
|
+
/* Method of HTTP request */
|
|
54
|
+
method?:
|
|
55
|
+
| 'GET'
|
|
56
|
+
| 'POST'
|
|
57
|
+
| 'PUT'
|
|
58
|
+
| 'DELETE'
|
|
59
|
+
| 'HEAD'
|
|
60
|
+
| 'PATCH'
|
|
61
|
+
| 'OPTIONS'
|
|
62
|
+
| 'CONNECT'
|
|
63
|
+
| 'TRACE'
|
|
64
|
+
| DataLink
|
|
65
|
+
/* Path of HTTP request */
|
|
66
|
+
path?: string | DataLink
|
|
67
|
+
/* Max connection idle time, 0 is disable */
|
|
68
|
+
idleTimeout?: number | DataLink
|
|
69
|
+
/* HTTP request body limit, 0 is unlimited */
|
|
70
|
+
bodyLimit?: number | DataLink
|
|
71
|
+
/* CORS allowed origins
|
|
72
|
+
You can use wildcard like `*`, `*.example.com`, `http://*.example.com` */
|
|
73
|
+
corsOrigins?: Array<string | DataLink> | DataLink
|
|
74
|
+
/* Authorization type of HTTP request */
|
|
75
|
+
authType?: 'none' | 'basic' | 'bearer' | DataLink
|
|
76
|
+
/* Username of basic auth */
|
|
77
|
+
basicAuthUser?: string | DataLink
|
|
78
|
+
/* Password of basic auth */
|
|
79
|
+
basicAuthPassword?: string | DataLink
|
|
80
|
+
/* Token of bearer auth */
|
|
81
|
+
bearerToken?: string | DataLink
|
|
82
|
+
/* Asynchronous response mode
|
|
83
|
+
Will block connection until Response Body update. */
|
|
84
|
+
asyncMode?: boolean | DataLink
|
|
85
|
+
/* Save request body as file
|
|
86
|
+
Only work on `application/octet-stream` or `multipart/form-data`. */
|
|
87
|
+
saveBodyAsFile?: boolean | DataLink
|
|
88
|
+
/* Response status code */
|
|
89
|
+
resStatusCode?: number | DataLink
|
|
90
|
+
/* Response Content-Type
|
|
91
|
+
`text/*` will not convert body.
|
|
92
|
+
`application/xml` convert object to XML, [example object struct](https://github.com/davidcalhoun/jstoxml#example-10-podcast-rss-feed)
|
|
93
|
+
`application/octet-stream` body should be Base64 string or file path. */
|
|
94
|
+
resContentType?:
|
|
95
|
+
| 'text/plain'
|
|
96
|
+
| 'text/html'
|
|
97
|
+
| 'text/javascript'
|
|
98
|
+
| 'text/css'
|
|
99
|
+
| 'text/xml'
|
|
100
|
+
| 'application/xml'
|
|
101
|
+
| 'application/json'
|
|
102
|
+
| 'application/octet-stream'
|
|
103
|
+
| 'text/event-stream'
|
|
104
|
+
| DataLink
|
|
105
|
+
/* Response Body */
|
|
106
|
+
resBody?: any
|
|
107
|
+
/* Custom response headers */
|
|
108
|
+
resHeader?: {} | DataLink
|
|
109
|
+
/* Event name of SSE */
|
|
110
|
+
sseEvent?: string | DataLink
|
|
111
|
+
/* SSE single request mode, block new request until the previous request is processed */
|
|
112
|
+
sseSingleRequest?: boolean | DataLink
|
|
113
|
+
/* Enable TLS (HTTPS) */
|
|
114
|
+
tls?: boolean | DataLink
|
|
115
|
+
/* Server side key pair (Base64 encoded PKCS #12) */
|
|
116
|
+
tlsKeyPair?: string | DataLink
|
|
117
|
+
/* Password of key pair, leave empty if no password */
|
|
118
|
+
tlsKeyPairPassword?: string | DataLink
|
|
119
|
+
}
|
|
120
|
+
events?: {
|
|
121
|
+
/* Event of HTTP server is ready */
|
|
122
|
+
onReady?: Array<EventAction>
|
|
123
|
+
/* Event of HTTP server accept the request */
|
|
124
|
+
onRequest?: Array<EventAction>
|
|
125
|
+
/* Event of client close connection */
|
|
126
|
+
onClientClose?: Array<EventAction>
|
|
127
|
+
/* Event of client error */
|
|
128
|
+
onClientError?: Array<EventAction>
|
|
129
|
+
/* Event of server close */
|
|
130
|
+
onClose?: Array<EventAction>
|
|
131
|
+
/* Event of server error */
|
|
132
|
+
onError?: Array<EventAction>
|
|
133
|
+
}
|
|
134
|
+
outlets?: {
|
|
135
|
+
/* Query of request */
|
|
136
|
+
requestQuery?: () => Data
|
|
137
|
+
/* Body of request */
|
|
138
|
+
requestBody?: () => Data
|
|
139
|
+
/* Remote address of request */
|
|
140
|
+
clientAddress?: () => Data
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/* HTTP Server */
|
|
145
|
+
export type GeneratorHTTPServer = Generator &
|
|
146
|
+
GeneratorHTTPServerDef & {
|
|
147
|
+
templateKey: 'GENERATOR_HTTP_SERVER'
|
|
148
|
+
switches: Array<
|
|
149
|
+
SwitchDef &
|
|
150
|
+
GeneratorHTTPServerDef & {
|
|
151
|
+
conds?: Array<{
|
|
152
|
+
method: '==' | '!=' | '>' | '<' | '>=' | '<='
|
|
153
|
+
cond:
|
|
154
|
+
| SwitchCondInnerStateCurrentCanvas
|
|
155
|
+
| SwitchCondData
|
|
156
|
+
| {
|
|
157
|
+
__typename: 'SwitchCondInnerStateOutlet'
|
|
158
|
+
outlet: 'requestQuery' | 'requestBody' | 'clientAddress'
|
|
159
|
+
value: any
|
|
160
|
+
}
|
|
161
|
+
}>
|
|
162
|
+
}
|
|
163
|
+
>
|
|
164
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
|
|
2
|
+
import type { Data, DataLink } from '../data'
|
|
3
|
+
import type {
|
|
4
|
+
Generator,
|
|
5
|
+
EventAction,
|
|
6
|
+
ActionWithDataParams,
|
|
7
|
+
ActionWithParams,
|
|
8
|
+
Action,
|
|
9
|
+
EventProperty,
|
|
10
|
+
} from '../common'
|
|
11
|
+
|
|
12
|
+
/* Show information */
|
|
13
|
+
export type GeneratorInformationActionShow = ActionWithParams & {
|
|
14
|
+
__actionName: 'GENERATOR_INFORMATION_SHOW'
|
|
15
|
+
params?: Array<
|
|
16
|
+
| {
|
|
17
|
+
input: 'displayLanguage'
|
|
18
|
+
value?: string | DataLink | EventProperty
|
|
19
|
+
mapping?: string
|
|
20
|
+
}
|
|
21
|
+
| {
|
|
22
|
+
input: 'content'
|
|
23
|
+
value?: {} | DataLink | EventProperty
|
|
24
|
+
mapping?: string
|
|
25
|
+
}
|
|
26
|
+
>
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Close information */
|
|
30
|
+
export type GeneratorInformationActionClose = Action & {
|
|
31
|
+
__actionName: 'GENERATOR_INFORMATION_CLOSE'
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface GeneratorInformationDef {
|
|
35
|
+
/*
|
|
36
|
+
Default property:
|
|
37
|
+
{
|
|
38
|
+
"modalMode": "root",
|
|
39
|
+
"backgroundColor": "#161616"
|
|
40
|
+
}
|
|
41
|
+
*/
|
|
42
|
+
property?: {
|
|
43
|
+
/* Modal mode */
|
|
44
|
+
modalMode?: 'root' | 'in-subspace' | DataLink
|
|
45
|
+
/* Information contents */
|
|
46
|
+
content?:
|
|
47
|
+
| DataLink
|
|
48
|
+
| {
|
|
49
|
+
type?: 'loading' | 'info' | 'warning' | 'success' | 'queue-number' | DataLink
|
|
50
|
+
title?: string | DataLink
|
|
51
|
+
description?: string | DataLink
|
|
52
|
+
queueNumberLabel?:
|
|
53
|
+
| DataLink
|
|
54
|
+
| {
|
|
55
|
+
number?: string | DataLink
|
|
56
|
+
labelTitle?: string | DataLink
|
|
57
|
+
note?: string | DataLink
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/* Display language */
|
|
61
|
+
displayLanguage?: string | DataLink
|
|
62
|
+
/* Background color */
|
|
63
|
+
backgroundColor?: string | DataLink
|
|
64
|
+
}
|
|
65
|
+
events?: {
|
|
66
|
+
/* Trigger when user confirms the information */
|
|
67
|
+
onConfirm?: Array<EventAction>
|
|
68
|
+
/* Trigger when error occurs */
|
|
69
|
+
onError?: Array<EventAction>
|
|
70
|
+
}
|
|
71
|
+
outlets?: {
|
|
72
|
+
/* Error message */
|
|
73
|
+
errorMessage?: () => Data
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/* Show information */
|
|
78
|
+
export type GeneratorInformation = Generator &
|
|
79
|
+
GeneratorInformationDef & {
|
|
80
|
+
templateKey: 'GENERATOR_INFORMATION'
|
|
81
|
+
switches: Array<
|
|
82
|
+
SwitchDef &
|
|
83
|
+
GeneratorInformationDef & {
|
|
84
|
+
conds?: Array<{
|
|
85
|
+
method: '==' | '!=' | '>' | '<' | '>=' | '<='
|
|
86
|
+
cond:
|
|
87
|
+
| SwitchCondInnerStateCurrentCanvas
|
|
88
|
+
| SwitchCondData
|
|
89
|
+
| {
|
|
90
|
+
__typename: 'SwitchCondInnerStateOutlet'
|
|
91
|
+
outlet: 'errorMessage'
|
|
92
|
+
value: any
|
|
93
|
+
}
|
|
94
|
+
}>
|
|
95
|
+
}
|
|
96
|
+
>
|
|
97
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
|
|
2
|
+
import type { Data, DataLink } from '../data'
|
|
3
|
+
import type {
|
|
4
|
+
Generator,
|
|
5
|
+
EventAction,
|
|
6
|
+
ActionWithDataParams,
|
|
7
|
+
ActionWithParams,
|
|
8
|
+
Action,
|
|
9
|
+
EventProperty,
|
|
10
|
+
} from '../common'
|
|
11
|
+
|
|
12
|
+
/* Read stats */
|
|
13
|
+
export type GeneratorIntentActionSendIntent = ActionWithParams & {
|
|
14
|
+
__actionName: 'GENERATOR_INTENT_SEND_INTENT'
|
|
15
|
+
params?: Array<
|
|
16
|
+
| {
|
|
17
|
+
input: 'action'
|
|
18
|
+
value?: string | DataLink | EventProperty
|
|
19
|
+
mapping?: string
|
|
20
|
+
}
|
|
21
|
+
| {
|
|
22
|
+
input: 'data'
|
|
23
|
+
value?: string | DataLink | EventProperty
|
|
24
|
+
mapping?: string
|
|
25
|
+
}
|
|
26
|
+
| {
|
|
27
|
+
input: 'type'
|
|
28
|
+
value?: string | DataLink | EventProperty
|
|
29
|
+
mapping?: string
|
|
30
|
+
}
|
|
31
|
+
| {
|
|
32
|
+
input: 'extra'
|
|
33
|
+
value?: {} | DataLink | EventProperty
|
|
34
|
+
mapping?: string
|
|
35
|
+
}
|
|
36
|
+
| {
|
|
37
|
+
input: 'className'
|
|
38
|
+
value?: string | DataLink | EventProperty
|
|
39
|
+
mapping?: string
|
|
40
|
+
}
|
|
41
|
+
| {
|
|
42
|
+
input: 'packageName'
|
|
43
|
+
value?: string | DataLink | EventProperty
|
|
44
|
+
mapping?: string
|
|
45
|
+
}
|
|
46
|
+
| {
|
|
47
|
+
input: 'category'
|
|
48
|
+
value?: string | DataLink | EventProperty
|
|
49
|
+
mapping?: string
|
|
50
|
+
}
|
|
51
|
+
>
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface GeneratorIntentDef {
|
|
55
|
+
/*
|
|
56
|
+
Default property:
|
|
57
|
+
{}
|
|
58
|
+
*/
|
|
59
|
+
property?: {
|
|
60
|
+
/* Intent action */
|
|
61
|
+
action?: string | DataLink
|
|
62
|
+
/* Intent data */
|
|
63
|
+
data?: string | DataLink
|
|
64
|
+
/* Intent type */
|
|
65
|
+
type?: string | DataLink
|
|
66
|
+
/* Extra data */
|
|
67
|
+
extra?: {} | DataLink
|
|
68
|
+
/* Intent target class name in package */
|
|
69
|
+
className?: string | DataLink
|
|
70
|
+
/* Intent target package name */
|
|
71
|
+
packageName?: string | DataLink
|
|
72
|
+
/* Intent category */
|
|
73
|
+
category?: string | DataLink
|
|
74
|
+
}
|
|
75
|
+
events?: {
|
|
76
|
+
/* On intent return a result trigger */
|
|
77
|
+
onResult?: Array<EventAction>
|
|
78
|
+
/* On intent error trigger */
|
|
79
|
+
onError?: Array<EventAction>
|
|
80
|
+
}
|
|
81
|
+
outlets?: {
|
|
82
|
+
/* Last intent result */
|
|
83
|
+
result?: () => Data
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/* Send intent to app and get result (Android only) */
|
|
88
|
+
export type GeneratorIntent = Generator &
|
|
89
|
+
GeneratorIntentDef & {
|
|
90
|
+
templateKey: 'GENERATOR_INTENT'
|
|
91
|
+
switches: Array<
|
|
92
|
+
SwitchDef &
|
|
93
|
+
GeneratorIntentDef & {
|
|
94
|
+
conds?: Array<{
|
|
95
|
+
method: '==' | '!=' | '>' | '<' | '>=' | '<='
|
|
96
|
+
cond:
|
|
97
|
+
| SwitchCondInnerStateCurrentCanvas
|
|
98
|
+
| SwitchCondData
|
|
99
|
+
| {
|
|
100
|
+
__typename: 'SwitchCondInnerStateOutlet'
|
|
101
|
+
outlet: 'result'
|
|
102
|
+
value: any
|
|
103
|
+
}
|
|
104
|
+
}>
|
|
105
|
+
}
|
|
106
|
+
>
|
|
107
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
|
|
2
|
+
import type { Data, DataLink } from '../data'
|
|
3
|
+
import type {
|
|
4
|
+
Generator,
|
|
5
|
+
EventAction,
|
|
6
|
+
ActionWithDataParams,
|
|
7
|
+
ActionWithParams,
|
|
8
|
+
Action,
|
|
9
|
+
EventProperty,
|
|
10
|
+
} from '../common'
|
|
11
|
+
|
|
12
|
+
/* Proceed to next iteration */
|
|
13
|
+
export type GeneratorIteratorActionNext = Action & {
|
|
14
|
+
__actionName: 'GENERATOR_ITERATOR_NEXT'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* Go back to previous iteration */
|
|
18
|
+
export type GeneratorIteratorActionPrevious = Action & {
|
|
19
|
+
__actionName: 'GENERATOR_ITERATOR_PREVIOUS'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* Jump to the last iteration element (ignoring the loop setting) */
|
|
23
|
+
export type GeneratorIteratorActionLast = Action & {
|
|
24
|
+
__actionName: 'GENERATOR_ITERATOR_LAST'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* Reset iteration state */
|
|
28
|
+
export type GeneratorIteratorActionReset = Action & {
|
|
29
|
+
__actionName: 'GENERATOR_ITERATOR_RESET'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface GeneratorIteratorDef {
|
|
33
|
+
/*
|
|
34
|
+
Default property:
|
|
35
|
+
{
|
|
36
|
+
"data": [],
|
|
37
|
+
"start": 0,
|
|
38
|
+
"step": 1
|
|
39
|
+
}
|
|
40
|
+
*/
|
|
41
|
+
property?: {
|
|
42
|
+
/* Data source for iteration. If it's an Array, it will iterate through elements. If it's an Object, it will use Object.values() as data source. If it's a String, it will iterate through characters. If it's a Number, it represents count from 1 to N. */
|
|
43
|
+
data?: any
|
|
44
|
+
/* Starting element position */
|
|
45
|
+
start?: number | DataLink
|
|
46
|
+
/* Step size for each iteration */
|
|
47
|
+
step?: number | DataLink
|
|
48
|
+
/* Maximum number of iterations (can be set to -1 for unlimited) */
|
|
49
|
+
maxQuantity?: number | DataLink
|
|
50
|
+
/* Whether to loop the iteration */
|
|
51
|
+
loop?: boolean | DataLink
|
|
52
|
+
}
|
|
53
|
+
events?: {
|
|
54
|
+
/* Event triggered on each iteration */
|
|
55
|
+
iterate?: Array<EventAction>
|
|
56
|
+
/* Event triggered on the first iteration of a round */
|
|
57
|
+
first?: Array<EventAction>
|
|
58
|
+
/* Event triggered on the last iteration of a round */
|
|
59
|
+
end?: Array<EventAction>
|
|
60
|
+
}
|
|
61
|
+
outlets?: {
|
|
62
|
+
/* Elements that have been iterated (including current one) */
|
|
63
|
+
iteratedArray?: () => Data
|
|
64
|
+
/* Elements that will be iterated but have not been iterated yet */
|
|
65
|
+
upcomingArray?: () => Data
|
|
66
|
+
/* Current iteration element */
|
|
67
|
+
value?: () => Data
|
|
68
|
+
/* Key of the current iteration element (for number: same as value, for array/string: index, for object: string key) */
|
|
69
|
+
key?: () => Data
|
|
70
|
+
/* Current iteration count (if data is 6 and step is 2, this will return: 1,2,3 in sequence) */
|
|
71
|
+
index?: () => Data
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* Iterate through values (Array, Object, Number, String) */
|
|
76
|
+
export type GeneratorIterator = Generator &
|
|
77
|
+
GeneratorIteratorDef & {
|
|
78
|
+
templateKey: 'GENERATOR_ITERATOR'
|
|
79
|
+
switches: Array<
|
|
80
|
+
SwitchDef &
|
|
81
|
+
GeneratorIteratorDef & {
|
|
82
|
+
conds?: Array<{
|
|
83
|
+
method: '==' | '!=' | '>' | '<' | '>=' | '<='
|
|
84
|
+
cond:
|
|
85
|
+
| SwitchCondInnerStateCurrentCanvas
|
|
86
|
+
| SwitchCondData
|
|
87
|
+
| {
|
|
88
|
+
__typename: 'SwitchCondInnerStateOutlet'
|
|
89
|
+
outlet: 'iteratedArray' | 'upcomingArray' | 'value' | 'key' | 'index'
|
|
90
|
+
value: any
|
|
91
|
+
}
|
|
92
|
+
}>
|
|
93
|
+
}
|
|
94
|
+
>
|
|
95
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
|
|
2
|
+
import type { Data, DataLink } from '../data'
|
|
3
|
+
import type {
|
|
4
|
+
Generator,
|
|
5
|
+
EventAction,
|
|
6
|
+
ActionWithDataParams,
|
|
7
|
+
ActionWithParams,
|
|
8
|
+
Action,
|
|
9
|
+
EventProperty,
|
|
10
|
+
} from '../common'
|
|
11
|
+
|
|
12
|
+
interface GeneratorKeyboardDef {
|
|
13
|
+
/*
|
|
14
|
+
Default property:
|
|
15
|
+
{
|
|
16
|
+
"enabled": true,
|
|
17
|
+
"keyMap": {},
|
|
18
|
+
"batchStopKeys": [
|
|
19
|
+
13
|
|
20
|
+
],
|
|
21
|
+
"batchDebounce": 500
|
|
22
|
+
}
|
|
23
|
+
*/
|
|
24
|
+
property?: {
|
|
25
|
+
/* Enable listening for input */
|
|
26
|
+
enabled?: boolean | DataLink
|
|
27
|
+
/* Key map to transform key or key code to the designated content (e.g. { 37: 'left' }) */
|
|
28
|
+
keyMap?: {} | DataLink
|
|
29
|
+
/* Key outlet preference use key code or key. */
|
|
30
|
+
keyOutletPrefer?: 'auto' | 'key-code' | 'key' | DataLink
|
|
31
|
+
/* Key or code to finish continuous input */
|
|
32
|
+
batchStopKeys?: Array<string | DataLink | number | DataLink | DataLink> | DataLink
|
|
33
|
+
/* Debounce time (ms) to finish continuous input */
|
|
34
|
+
batchDebounce?: number | DataLink
|
|
35
|
+
/* Maximum wait time (ms) to finish continuous input (default: unlimited) */
|
|
36
|
+
batchDebounceMaxWait?: number | DataLink
|
|
37
|
+
}
|
|
38
|
+
events?: {
|
|
39
|
+
/* Event on key press */
|
|
40
|
+
onDown?: Array<EventAction>
|
|
41
|
+
/* Event on key up */
|
|
42
|
+
onUp?: Array<EventAction>
|
|
43
|
+
/* Event on continuous input complete */
|
|
44
|
+
onBatch?: Array<EventAction>
|
|
45
|
+
}
|
|
46
|
+
outlets?: {
|
|
47
|
+
/* Last key code pressed */
|
|
48
|
+
lastKeyDown?: () => Data
|
|
49
|
+
/* Modifier key information on last key press */
|
|
50
|
+
lastKeyDownFlags?: () => Data
|
|
51
|
+
/* Last key code released */
|
|
52
|
+
lastKeyUp?: () => Data
|
|
53
|
+
/* Modifier key information on last key release */
|
|
54
|
+
lastKeyUpFlags?: () => Data
|
|
55
|
+
/* Last continuous event */
|
|
56
|
+
lastBatchEvents?: () => Data
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* Access keyboard (remote control) events */
|
|
61
|
+
export type GeneratorKeyboard = Generator &
|
|
62
|
+
GeneratorKeyboardDef & {
|
|
63
|
+
templateKey: 'GENERATOR_KEYBOARD'
|
|
64
|
+
switches: Array<
|
|
65
|
+
SwitchDef &
|
|
66
|
+
GeneratorKeyboardDef & {
|
|
67
|
+
conds?: Array<{
|
|
68
|
+
method: '==' | '!=' | '>' | '<' | '>=' | '<='
|
|
69
|
+
cond:
|
|
70
|
+
| SwitchCondInnerStateCurrentCanvas
|
|
71
|
+
| SwitchCondData
|
|
72
|
+
| {
|
|
73
|
+
__typename: 'SwitchCondInnerStateOutlet'
|
|
74
|
+
outlet:
|
|
75
|
+
| 'lastKeyDown'
|
|
76
|
+
| 'lastKeyDownFlags'
|
|
77
|
+
| 'lastKeyUp'
|
|
78
|
+
| 'lastKeyUpFlags'
|
|
79
|
+
| 'lastBatchEvents'
|
|
80
|
+
value: any
|
|
81
|
+
}
|
|
82
|
+
}>
|
|
83
|
+
}
|
|
84
|
+
>
|
|
85
|
+
}
|