@fugood/bricks-project 2.21.0-beta.14.test6 → 2.21.0-beta.14.test8
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/api/instance.ts +16 -4
- package/compile/action-name-map.ts +502 -0
- package/compile/index.ts +52 -33
- package/package.json +1 -1
- package/tools/deploy.ts +3 -3
- package/tools/pull.ts +23 -9
- package/types/bricks.ts +4 -4
- package/types/common.ts +3 -3
- package/types/subspace.ts +5 -5
- package/types/switch.ts +2 -2
package/api/instance.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const apiUrlMap = {
|
|
2
2
|
production: 'https://display.bricks.tools/api/graphql-workspace',
|
|
3
3
|
beta: 'https://display-beta.bricks.tools/api/graphql-workspace',
|
|
4
|
-
|
|
4
|
+
development: 'http://localhost:3001/api/graphql-workspace',
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
const workspaceToken = process.env.BRICKS_WORKSPACE_TOKEN
|
|
@@ -22,6 +22,8 @@ const doGQL = async (stage: Stage, query: string, variables: Record<string, any>
|
|
|
22
22
|
},
|
|
23
23
|
body: JSON.stringify({ query, variables }),
|
|
24
24
|
}).then((res) => res.json())
|
|
25
|
+
|
|
26
|
+
if (data.error && data.error.message) throw new Error(data.error.message)
|
|
25
27
|
return data
|
|
26
28
|
}
|
|
27
29
|
|
|
@@ -58,7 +60,12 @@ export const pullApp = async (stage: Stage, appId: string) => {
|
|
|
58
60
|
|
|
59
61
|
type Config = { title?: string }
|
|
60
62
|
|
|
61
|
-
export const deployApp = async (
|
|
63
|
+
export const deployApp = async (
|
|
64
|
+
stage: Stage,
|
|
65
|
+
appId: string,
|
|
66
|
+
config: Config,
|
|
67
|
+
lastCommitId: string,
|
|
68
|
+
) => {
|
|
62
69
|
const app = await pullApp(stage, appId)
|
|
63
70
|
if (app.config?.bricks_project_last_commit_id === lastCommitId)
|
|
64
71
|
throw new Error('No changes to deploy')
|
|
@@ -124,7 +131,12 @@ export const pullModule = async (stage: Stage, modId: string) => {
|
|
|
124
131
|
return mod
|
|
125
132
|
}
|
|
126
133
|
|
|
127
|
-
export const deployModule = async (
|
|
134
|
+
export const deployModule = async (
|
|
135
|
+
stage: Stage,
|
|
136
|
+
modId: string,
|
|
137
|
+
config: Config,
|
|
138
|
+
lastCommitId: string,
|
|
139
|
+
) => {
|
|
128
140
|
const mod = await pullModule(stage, modId)
|
|
129
141
|
if (mod.config?.bricks_project_last_commit_id === lastCommitId)
|
|
130
142
|
throw new Error('No changes to deploy')
|
|
@@ -145,7 +157,7 @@ export const deployModule = async (stage: Stage, modId: string, config: Config,
|
|
|
145
157
|
id: modId,
|
|
146
158
|
config: JSON.stringify({
|
|
147
159
|
...config,
|
|
148
|
-
title: `${
|
|
160
|
+
title: `${config.title || mod.name || 'Untitled'} (${Date.now()})`,
|
|
149
161
|
bricks_project_last_commit_id: lastCommitId,
|
|
150
162
|
}),
|
|
151
163
|
},
|
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
// NOTE: The action parameter name convertion is not 1:1 mapping case conversion, so we need to define the mapping here
|
|
2
|
+
// This may be improved in the future
|
|
3
|
+
export const templateActionNameMap = {
|
|
4
|
+
SYSTEM: {
|
|
5
|
+
PROPERTY_BANK_EXPRESSION: {
|
|
6
|
+
expression: 'EXPRESSION',
|
|
7
|
+
variables: 'VARIABLES',
|
|
8
|
+
result: 'RESULT',
|
|
9
|
+
resultAssignPath: 'RESULT_ASSIGN_PATH',
|
|
10
|
+
errorResult: 'ERROR_RESULT',
|
|
11
|
+
},
|
|
12
|
+
DYNAMIC_BRICK: {
|
|
13
|
+
addList: 'DYNAMIC_BRICK_ADD_LIST',
|
|
14
|
+
preferAfterItemId: 'DYNAMIC_BRICK_PREFER_AFTER_ITEM_ID',
|
|
15
|
+
reset: 'DYNAMIC_BRICK_RESET',
|
|
16
|
+
removeItemId: 'DYNAMIC_BRICK_REMOVE_ITEM_ID',
|
|
17
|
+
removeItems: 'DYNAMIC_BRICK_REMOVE_ITEMS',
|
|
18
|
+
},
|
|
19
|
+
DYNAMIC_ANIMATION: {
|
|
20
|
+
brickId: 'DYNAMIC_ANIMATION_BRICK_ID',
|
|
21
|
+
animationId: 'DYNAMIC_ANIMATION_ANIMATION_ID',
|
|
22
|
+
runType: 'DYNAMIC_ANIMATION_RUN_TYPE',
|
|
23
|
+
resetInitialValue: 'DYNAMIC_ANIMATION_RESET_INITIAL_VALUE',
|
|
24
|
+
},
|
|
25
|
+
DYNAMIC_ANIMATION_RESET: {
|
|
26
|
+
dynamicAnimationBrickId: 'DYNAMIC_ANIMATION_BRICK_ID',
|
|
27
|
+
},
|
|
28
|
+
DYNAMIC_ANIMATION_STOP: {
|
|
29
|
+
dynamicAnimationBrickId: 'DYNAMIC_ANIMATION_BRICK_ID',
|
|
30
|
+
},
|
|
31
|
+
CHANGE_CANVAS: {
|
|
32
|
+
canvasId: 'CANVAS_ID',
|
|
33
|
+
canvasTitleLike: 'CANVAS_TITLE_LIKE',
|
|
34
|
+
},
|
|
35
|
+
MESSAGE: {
|
|
36
|
+
type: 'SYSTEM_MESSAGE_TYPE',
|
|
37
|
+
title: 'SYSTEM_MESSAGE_TITLE',
|
|
38
|
+
message: 'SYSTEM_MESSAGE_MESSAGE',
|
|
39
|
+
},
|
|
40
|
+
ALERT: {
|
|
41
|
+
id: 'ALERT_ID',
|
|
42
|
+
type: 'ALERT_TYPE',
|
|
43
|
+
title: 'ALERT_TITLE',
|
|
44
|
+
message: 'ALERT_MESSAGE',
|
|
45
|
+
selections: 'ALERT_SELECTIONS',
|
|
46
|
+
selectionResult: 'ALERT_SELECTION_RESULT',
|
|
47
|
+
timeout: 'ALERT_TIMEOUT',
|
|
48
|
+
},
|
|
49
|
+
POPUP_RESET: {
|
|
50
|
+
popupClearType: 'POPUP_CLEAR_TYPE',
|
|
51
|
+
popupId: 'POPUP_ID',
|
|
52
|
+
},
|
|
53
|
+
TAKE_SCREENSHOT: {
|
|
54
|
+
currentSubspace: 'TAKE_SCREENSHOT_CURRENT_SUBSPACE',
|
|
55
|
+
format: 'TAKE_SCREENSHOT_FORMAT',
|
|
56
|
+
quality: 'TAKE_SCREENSHOT_QUALITY',
|
|
57
|
+
width: 'TAKE_SCREENSHOT_WIDTH',
|
|
58
|
+
height: 'TAKE_SCREENSHOT_HEIGHT',
|
|
59
|
+
saveProperty: 'TAKE_SCREENSHOT_SAVE_PROPERTY',
|
|
60
|
+
},
|
|
61
|
+
USE_SHARE_APPLICATION: {
|
|
62
|
+
applicationId: 'APPLICATION_ID',
|
|
63
|
+
releaseVersion: 'RELEASE_VERSION',
|
|
64
|
+
useType: 'USE_TYPE',
|
|
65
|
+
viewportPresetNameLike: 'VIEWPORT_PRESET_NAME_LIKE',
|
|
66
|
+
viewportPresetDeviceTarget: 'VIEWPORT_PRESET_DEVICE_TARGET',
|
|
67
|
+
enableLocalSync: 'ENABLE_LOCAL_SYNC',
|
|
68
|
+
},
|
|
69
|
+
OPEN_URL: {
|
|
70
|
+
url: 'URL',
|
|
71
|
+
behavior: 'BEHAVIOR',
|
|
72
|
+
inAppTintColor: 'IN_APP_TINT_COLOR',
|
|
73
|
+
},
|
|
74
|
+
OPEN_FILE: {
|
|
75
|
+
pickType: 'PICK_TYPE',
|
|
76
|
+
fileType: 'FILE_TYPE',
|
|
77
|
+
copyTo: 'COPY_TO',
|
|
78
|
+
mode: 'MODE',
|
|
79
|
+
saveProperty: 'SAVE_PROPERTY',
|
|
80
|
+
saveDetailProperty: 'SAVE_DETAIL_PROPERTY',
|
|
81
|
+
errorSaveProperty: 'ERROR_SAVE_PROPERTY',
|
|
82
|
+
},
|
|
83
|
+
THROW_EXCEPTION: {
|
|
84
|
+
behavior: 'BEHAVIOR',
|
|
85
|
+
exceptionMessage: 'EXCEPTION_MESSAGE',
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
BRICK_TEXT_INPUT: {
|
|
90
|
+
BRICK_TEXT_INPUT_SELECT_TEXT: {
|
|
91
|
+
regex: 'BRICK_TEXT_INPUT_REGEX',
|
|
92
|
+
start: 'BRICK_TEXT_INPUT_START',
|
|
93
|
+
end: 'BRICK_TEXT_INPUT_END',
|
|
94
|
+
},
|
|
95
|
+
BRICK_TEXT_INPUT_SET_TEXT: {
|
|
96
|
+
text: 'BRICK_TEXT_INPUT_TEXT',
|
|
97
|
+
},
|
|
98
|
+
BRICK_TEXT_INPUT_APPEND_TEXT: {
|
|
99
|
+
text: 'BRICK_TEXT_INPUT_TEXT',
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
BRICK_SLIDESHOW: {
|
|
104
|
+
BRICK_SLIDESHOW_JUMP_TO_INDEX: {
|
|
105
|
+
index: 'BRICK_SLIDESHOW_INDEX',
|
|
106
|
+
reset: 'BRICK_SLIDESHOW_RESET',
|
|
107
|
+
shuffle: 'BRICK_SLIDESHOW_SHUFFLE',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
BRICK_CHART: {
|
|
111
|
+
BRICK_CHART_DATA_HIGHLIGHT: {
|
|
112
|
+
seriesName: 'BRICK_CHART_SERIES_NAME',
|
|
113
|
+
seriesId: 'BRICK_CHART_SERIES_ID',
|
|
114
|
+
seriesIndex: 'BRICK_CHART_SERIES_INDEX',
|
|
115
|
+
dataIndex: 'BRICK_CHART_DATA_INDEX',
|
|
116
|
+
name: 'BRICK_CHART_NAME',
|
|
117
|
+
},
|
|
118
|
+
BRICK_CHART_DATA_DOWNPLAY: {
|
|
119
|
+
seriesName: 'BRICK_CHART_SERIES_NAME',
|
|
120
|
+
seriesId: 'BRICK_CHART_SERIES_ID',
|
|
121
|
+
seriesIndex: 'BRICK_CHART_SERIES_INDEX',
|
|
122
|
+
dataIndex: 'BRICK_CHART_DATA_INDEX',
|
|
123
|
+
name: 'BRICK_CHART_NAME',
|
|
124
|
+
},
|
|
125
|
+
BRICK_CHART_DATA_SELECT: {
|
|
126
|
+
seriesName: 'BRICK_CHART_SERIES_NAME',
|
|
127
|
+
seriesId: 'BRICK_CHART_SERIES_ID',
|
|
128
|
+
seriesIndex: 'BRICK_CHART_SERIES_INDEX',
|
|
129
|
+
dataIndex: 'BRICK_CHART_DATA_INDEX',
|
|
130
|
+
name: 'BRICK_CHART_NAME',
|
|
131
|
+
},
|
|
132
|
+
BRICK_CHART_DATA_UNSELECT: {
|
|
133
|
+
seriesName: 'BRICK_CHART_SERIES_NAME',
|
|
134
|
+
seriesId: 'BRICK_CHART_SERIES_ID',
|
|
135
|
+
seriesIndex: 'BRICK_CHART_SERIES_INDEX',
|
|
136
|
+
dataIndex: 'BRICK_CHART_DATA_INDEX',
|
|
137
|
+
name: 'BRICK_CHART_NAME',
|
|
138
|
+
},
|
|
139
|
+
BRICK_CHART_DATA_TOGGLE_SELECT: {
|
|
140
|
+
seriesName: 'BRICK_CHART_SERIES_NAME',
|
|
141
|
+
seriesId: 'BRICK_CHART_SERIES_ID',
|
|
142
|
+
seriesIndex: 'BRICK_CHART_SERIES_INDEX',
|
|
143
|
+
dataIndex: 'BRICK_CHART_DATA_INDEX',
|
|
144
|
+
name: 'BRICK_CHART_NAME',
|
|
145
|
+
},
|
|
146
|
+
BRICK_CHART_LEGEND_SELECT: {
|
|
147
|
+
name: 'BRICK_CHART_NAME',
|
|
148
|
+
},
|
|
149
|
+
BRICK_CHART_LEGEND_UNSELECT: {
|
|
150
|
+
name: 'BRICK_CHART_NAME',
|
|
151
|
+
},
|
|
152
|
+
BRICK_CHART_TOOLTIP_SHOW: {
|
|
153
|
+
seriesIndex: 'BRICK_CHART_SERIES_INDEX',
|
|
154
|
+
dataIndex: 'BRICK_CHART_DATA_INDEX',
|
|
155
|
+
name: 'BRICK_CHART_NAME',
|
|
156
|
+
},
|
|
157
|
+
BRICK_CHART_TOOLTIP_HIDE: {
|
|
158
|
+
seriesIndex: 'BRICK_CHART_SERIES_INDEX',
|
|
159
|
+
dataIndex: 'BRICK_CHART_DATA_INDEX',
|
|
160
|
+
name: 'BRICK_CHART_NAME',
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
BRICK_ITEMS: {
|
|
164
|
+
BRICK_ITEMS_JUMP_PAGE: {
|
|
165
|
+
pageIndex: 'BRICK_ITEMS_PAGE_INDEX',
|
|
166
|
+
},
|
|
167
|
+
BRICK_ITEMS_OPEN_DETAIL: {
|
|
168
|
+
detailIndex: 'BRICK_ITEMS_DETAIL_INDEX',
|
|
169
|
+
},
|
|
170
|
+
BRICK_ITEMS_DYNAMIC_ANIMATION: {
|
|
171
|
+
mode: 'BRICK_ITEMS_MODE',
|
|
172
|
+
brickId: 'BRICK_ITEMS_BRICK_ID',
|
|
173
|
+
dataId: 'BRICK_ITEMS_DATA_ID',
|
|
174
|
+
index: 'BRICK_ITEMS_INDEX',
|
|
175
|
+
animationId: 'BRICK_ITEMS_ANIMATION_ID',
|
|
176
|
+
animationType: 'BRICK_ITEMS_ANIMATION_TYPE',
|
|
177
|
+
animationResetInitialValue: 'BRICK_ITEMS_ANIMATION_RESET_INITIAL_VALUE',
|
|
178
|
+
},
|
|
179
|
+
BRICK_ITEMS_DYNAMIC_ANIMATION_RESET: {
|
|
180
|
+
mode: 'BRICK_ITEMS_MODE',
|
|
181
|
+
brickId: 'BRICK_ITEMS_BRICK_ID',
|
|
182
|
+
dataId: 'BRICK_ITEMS_DATA_ID',
|
|
183
|
+
index: 'BRICK_ITEMS_INDEX',
|
|
184
|
+
},
|
|
185
|
+
BRICK_ITEMS_DYNAMIC_ANIMATION_STOP: {
|
|
186
|
+
mode: 'BRICK_ITEMS_MODE',
|
|
187
|
+
brickId: 'BRICK_ITEMS_BRICK_ID',
|
|
188
|
+
dataId: 'BRICK_ITEMS_DATA_ID',
|
|
189
|
+
index: 'BRICK_ITEMS_INDEX',
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
BRICK_WEBVIEW: {
|
|
194
|
+
BRICK_WEBVIEW_INJECT_JAVASCRIPT: {
|
|
195
|
+
javascriptCode: 'BRICK_WEBVIEW_JAVASCRIPT_CODE',
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
BRICK_CAMERA: {
|
|
199
|
+
BRICK_CAMERA_TAKE_PICTURE: {
|
|
200
|
+
width: 'BRICK_CAMERA_WIDTH',
|
|
201
|
+
quality: 'BRICK_CAMERA_QUALITY',
|
|
202
|
+
base64: 'BRICK_CAMERA_BASE64',
|
|
203
|
+
mirrorImage: 'BRICK_CAMERA_MIRROR_IMAGE',
|
|
204
|
+
},
|
|
205
|
+
BRICK_CAMERA_RECORD: {
|
|
206
|
+
quality: 'BRICK_CAMERA_QUALITY',
|
|
207
|
+
mirrorVideo: 'BRICK_CAMERA_MIRROR_VIDEO',
|
|
208
|
+
videoBitrate: 'BRICK_CAMERA_VIDEO_BITRATE',
|
|
209
|
+
maxDuration: 'BRICK_CAMERA_MAX_DURATION',
|
|
210
|
+
maxFileSize: 'BRICK_CAMERA_MAX_FILE_SIZE',
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
|
|
214
|
+
BRICK_3D_VIEWER: {
|
|
215
|
+
BRICK_3D_VIEWER_ANIMATION_PLAY: {
|
|
216
|
+
objectIndex: 'BRICK_3D_VIEWER_OBJECT_INDEX',
|
|
217
|
+
},
|
|
218
|
+
BRICK_3D_VIEWER_ANIMATION_PAUSE: {
|
|
219
|
+
objectIndex: 'BRICK_3D_VIEWER_OBJECT_INDEX',
|
|
220
|
+
},
|
|
221
|
+
BRICK_3D_VIEWER_ANIMATION_GOTO: {
|
|
222
|
+
objectIndex: 'BRICK_3D_VIEWER_OBJECT_INDEX',
|
|
223
|
+
animationProgress: 'BRICK_3D_VIEWER_ANIMATION_PROGRESS',
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
|
|
227
|
+
GENERATOR_FILE: {
|
|
228
|
+
GENERATOR_FILE_READ_CONTENT: {
|
|
229
|
+
encoding: 'ENCODING',
|
|
230
|
+
},
|
|
231
|
+
GENERATOR_FILE_APPEND_CONTENT: {
|
|
232
|
+
content: 'CONTENT',
|
|
233
|
+
encoding: 'ENCODING',
|
|
234
|
+
contentList: 'CONTENT_LIST',
|
|
235
|
+
},
|
|
236
|
+
GENERATOR_FILE_WRITE_CONTENT: {
|
|
237
|
+
content: 'CONTENT',
|
|
238
|
+
encoding: 'ENCODING',
|
|
239
|
+
position: 'POSITION',
|
|
240
|
+
contentList: 'CONTENT_LIST',
|
|
241
|
+
},
|
|
242
|
+
GENERATOR_FILE_START_UPLOAD: {
|
|
243
|
+
withAll: 'WITH_ALL',
|
|
244
|
+
withId: 'WITH_ID',
|
|
245
|
+
withIndex: 'WITH_INDEX',
|
|
246
|
+
},
|
|
247
|
+
GENERATOR_FILE_STOP_UPLOAD: {
|
|
248
|
+
withAll: 'WITH_ALL',
|
|
249
|
+
withId: 'WITH_ID',
|
|
250
|
+
withIndex: 'WITH_INDEX',
|
|
251
|
+
},
|
|
252
|
+
GENERATOR_FILE_START_DOWNLOAD: {
|
|
253
|
+
withAll: 'WITH_ALL',
|
|
254
|
+
withId: 'WITH_ID',
|
|
255
|
+
withIndex: 'WITH_INDEX',
|
|
256
|
+
},
|
|
257
|
+
GENERATOR_FILE_STOP_DOWNLOAD: {
|
|
258
|
+
withAll: 'WITH_ALL',
|
|
259
|
+
withId: 'WITH_ID',
|
|
260
|
+
withIndex: 'WITH_INDEX',
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
|
|
264
|
+
GENERATOR_DATA_BANK: {
|
|
265
|
+
GENERATOR_DATA_BANK_UPDATE_PROPERTY: {
|
|
266
|
+
propertyId: 'GENERATOR_DATA_BANK_PROPERTY_ID',
|
|
267
|
+
propertyValue: 'GENERATOR_DATA_BANK_PROPERTY_VALUE',
|
|
268
|
+
},
|
|
269
|
+
GENERATOR_DATA_BANK_REMOVE_PROPERTY: {
|
|
270
|
+
propertyId: 'GENERATOR_DATA_BANK_PROPERTY_ID',
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
GENERATOR_GRAPHQL: {
|
|
274
|
+
GENERATOR_GRAPHQL_RUN_QUERY: {
|
|
275
|
+
type: 'GENERATOR_GRAPHQL_TYPE',
|
|
276
|
+
query: 'GENERATOR_GRAPHQL_QUERY',
|
|
277
|
+
variables: 'GENERATOR_GRAPHQL_VARIABLES',
|
|
278
|
+
},
|
|
279
|
+
},
|
|
280
|
+
|
|
281
|
+
GENERATOR_WEB_SOCKET: {
|
|
282
|
+
GENERATOR_WEB_SOCKET_EMIT: {
|
|
283
|
+
eventName: 'GENERATOR_WEB_SOCKET_EVENT_NAME',
|
|
284
|
+
arguments: 'GENERATOR_WEB_SOCKET_ARGUMENTS',
|
|
285
|
+
acknowledgementType: 'GENERATOR_WEB_SOCKET_ACKNOWLEDGEMENT_TYPE',
|
|
286
|
+
withAcknowledgement: 'GENERATOR_WEB_SOCKET_WITH_ACKNOWLEDGEMENT',
|
|
287
|
+
},
|
|
288
|
+
GENERATOR_WEB_SOCKET_SEND: {
|
|
289
|
+
value: 'GENERATOR_WEB_SOCKET_VALUE',
|
|
290
|
+
},
|
|
291
|
+
},
|
|
292
|
+
|
|
293
|
+
GENERATOR_MQTT: {
|
|
294
|
+
GENERATOR_MQTT_PUBLISH: {
|
|
295
|
+
topic: 'GENERATOR_MQTT_TOPIC',
|
|
296
|
+
payload: 'GENERATOR_MQTT_PAYLOAD',
|
|
297
|
+
qos: 'GENERATOR_MQTT_QOS',
|
|
298
|
+
retain: 'GENERATOR_MQTT_RETAIN',
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
GENERATOR_MQTT_BROKER: {
|
|
302
|
+
GENERATOR_MQTT_BROKER_PUBLISH: {
|
|
303
|
+
topic: 'GENERATOR_MQTT_BROKER_TOPIC',
|
|
304
|
+
payload: 'GENERATOR_MQTT_BROKER_PAYLOAD',
|
|
305
|
+
messageId: 'GENERATOR_MQTT_BROKER_MESSAGE_ID',
|
|
306
|
+
},
|
|
307
|
+
},
|
|
308
|
+
GENERATOR_BLE_CENTRAL: {
|
|
309
|
+
GENERATOR_BLE_CENTRAL_CONNECT: {
|
|
310
|
+
deviceId: 'GENERATOR_BLE_CENTRAL_DEVICE_ID',
|
|
311
|
+
},
|
|
312
|
+
GENERATOR_BLE_CENTRAL_READ_CHARACTERISTIC: {
|
|
313
|
+
deviceId: 'GENERATOR_BLE_CENTRAL_DEVICE_ID',
|
|
314
|
+
serviceId: 'GENERATOR_BLE_CENTRAL_SERVICE_ID',
|
|
315
|
+
characteristicId: 'GENERATOR_BLE_CENTRAL_CHARACTERISTIC_ID',
|
|
316
|
+
},
|
|
317
|
+
GENERATOR_BLE_CENTRAL_MONITOR_CHARACTERISTIC: {
|
|
318
|
+
deviceId: 'GENERATOR_BLE_CENTRAL_DEVICE_ID',
|
|
319
|
+
serviceId: 'GENERATOR_BLE_CENTRAL_SERVICE_ID',
|
|
320
|
+
characteristicId: 'GENERATOR_BLE_CENTRAL_CHARACTERISTIC_ID',
|
|
321
|
+
},
|
|
322
|
+
GENERATOR_BLE_CENTRAL_CANCEL_MONITOR_CHARACTERISTIC: {
|
|
323
|
+
deviceId: 'GENERATOR_BLE_CENTRAL_DEVICE_ID',
|
|
324
|
+
serviceId: 'GENERATOR_BLE_CENTRAL_SERVICE_ID',
|
|
325
|
+
characteristicId: 'GENERATOR_BLE_CENTRAL_CHARACTERISTIC_ID',
|
|
326
|
+
},
|
|
327
|
+
GENERATOR_BLE_CENTRAL_WRITE_CHARACTERISTIC: {
|
|
328
|
+
deviceId: 'GENERATOR_BLE_CENTRAL_DEVICE_ID',
|
|
329
|
+
serviceId: 'GENERATOR_BLE_CENTRAL_SERVICE_ID',
|
|
330
|
+
characteristicId: 'GENERATOR_BLE_CENTRAL_CHARACTERISTIC_ID',
|
|
331
|
+
dataHex: 'GENERATOR_BLE_CENTRAL_DATA_HEX',
|
|
332
|
+
writeWithoutResponse: 'GENERATOR_BLE_CENTRAL_WRITE_WITHOUT_RESPONSE',
|
|
333
|
+
},
|
|
334
|
+
GENERATOR_BLE_CENTRAL_DISCONNECT: {
|
|
335
|
+
deviceId: 'GENERATOR_BLE_CENTRAL_DEVICE_ID',
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
GENERATOR_SERIAL_PORT: {
|
|
339
|
+
GENERATOR_SERIAL_SEND_STRING: {
|
|
340
|
+
generatorSerialStringValue: 'GENERATOR_SERIAL_STRING_VALUE',
|
|
341
|
+
generatorSerialStringEncoding: 'GENERATOR_SERIAL_STRING_ENCODING',
|
|
342
|
+
},
|
|
343
|
+
GENERATOR_SERIAL_SEND_HEX: {
|
|
344
|
+
generatorSerialHexValue: 'GENERATOR_SERIAL_HEX_VALUE',
|
|
345
|
+
},
|
|
346
|
+
},
|
|
347
|
+
GENERATOR_TCP: {
|
|
348
|
+
GENERATOR_TCP_SEND: {
|
|
349
|
+
sendData: 'GENERATOR_TCP_SEND_DATA',
|
|
350
|
+
},
|
|
351
|
+
GENERATOR_TCP_END: {
|
|
352
|
+
endWithData: 'GENERATOR_TCP_END_WITH_DATA',
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
GENERATOR_TCP_SERVER: {
|
|
356
|
+
GENERATOR_TCP_SERVER_SEND: {
|
|
357
|
+
remote: 'GENERATOR_TCP_SERVER_REMOTE',
|
|
358
|
+
sendData: 'GENERATOR_TCP_SERVER_SEND_DATA',
|
|
359
|
+
},
|
|
360
|
+
GENERATOR_TCP_SERVER_END: {
|
|
361
|
+
remote: 'GENERATOR_TCP_SERVER_REMOTE',
|
|
362
|
+
generatorTcpClientEndWithData: 'GENERATOR_TCP_CLIENT_END_WITH_DATA',
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
GENERATOR_UDP: {
|
|
366
|
+
GENERATOR_UDP_SEND: {
|
|
367
|
+
targetHost: 'GENERATOR_UDP_TARGET_HOST',
|
|
368
|
+
targetPort: 'GENERATOR_UDP_TARGET_PORT',
|
|
369
|
+
sendData: 'GENERATOR_UDP_SEND_DATA',
|
|
370
|
+
},
|
|
371
|
+
},
|
|
372
|
+
|
|
373
|
+
GENERATOR_WEBRTC: {
|
|
374
|
+
GENERATOR_WEBRTC_PROCESS_INPUT_SIGNAL: {
|
|
375
|
+
inputSignal: 'GENERATOR_WEBRTC_INPUT_SIGNAL',
|
|
376
|
+
},
|
|
377
|
+
GENERATOR_WEBRTC_CHANNEL_SEND: {
|
|
378
|
+
textMessage: 'GENERATOR_WEBRTC_TEXT_MESSAGE',
|
|
379
|
+
},
|
|
380
|
+
},
|
|
381
|
+
|
|
382
|
+
GENERATOR_BLE_PERIPHERAL: {
|
|
383
|
+
GENERATOR_BLE_PERIPHERAL_NOTIFY: {
|
|
384
|
+
serviceId: 'GENERATOR_BLE_PERIPHERAL_SERVICE_ID',
|
|
385
|
+
charId: 'GENERATOR_BLE_PERIPHERAL_CHAR_ID',
|
|
386
|
+
value: 'GENERATOR_BLE_PERIPHERAL_VALUE',
|
|
387
|
+
encoding: 'GENERATOR_BLE_PERIPHERAL_ENCODING',
|
|
388
|
+
},
|
|
389
|
+
},
|
|
390
|
+
|
|
391
|
+
GENERATOR_INTENT: {
|
|
392
|
+
GENERATOR_INTENT_SEND_INTENT: {
|
|
393
|
+
action: 'GENERATOR_INTENT_ACTION',
|
|
394
|
+
data: 'GENERATOR_INTENT_DATA',
|
|
395
|
+
type: 'GENERATOR_INTENT_TYPE',
|
|
396
|
+
extra: 'GENERATOR_INTENT_EXTRA',
|
|
397
|
+
className: 'GENERATOR_INTENT_CLASS_NAME',
|
|
398
|
+
packageName: 'GENERATOR_INTENT_PACKAGE_NAME',
|
|
399
|
+
category: 'GENERATOR_INTENT_CATEGORY',
|
|
400
|
+
},
|
|
401
|
+
},
|
|
402
|
+
GENERATOR_TAPPAY_T2P_IOS: {
|
|
403
|
+
GENERATOR_TAPPAY_T2P_IOS_BIND: {
|
|
404
|
+
bindId: 'GENERATOR_TAPPAY_T2P_IOS_BIND_ID',
|
|
405
|
+
bindDescription: 'GENERATOR_TAPPAY_T2P_IOS_BIND_DESCRIPTION',
|
|
406
|
+
},
|
|
407
|
+
GENERATOR_TAPPAY_T2P_IOS_READ_CARD_AND_AUTHORIZATION: {
|
|
408
|
+
amount: 'GENERATOR_TAPPAY_T2P_IOS_AMOUNT',
|
|
409
|
+
orderNumber: 'GENERATOR_TAPPAY_T2P_IOS_ORDER_NUMBER',
|
|
410
|
+
bankTransactionId: 'GENERATOR_TAPPAY_T2P_IOS_BANK_TRANSACTION_ID',
|
|
411
|
+
},
|
|
412
|
+
GENERATOR_TAPPAY_T2P_IOS_GET_RECEIPT: {
|
|
413
|
+
receiptIdentifier: 'GENERATOR_TAPPAY_T2P_IOS_RECEIPT_IDENTIFIER',
|
|
414
|
+
type: 'GENERATOR_TAPPAY_T2P_IOS_TYPE',
|
|
415
|
+
email: 'GENERATOR_TAPPAY_T2P_IOS_EMAIL',
|
|
416
|
+
},
|
|
417
|
+
},
|
|
418
|
+
|
|
419
|
+
GENERATOR_THERMAL_PRINTER: {
|
|
420
|
+
GENERATOR_THERMAL_PRINTER_PRINT: {
|
|
421
|
+
options: 'GENERATOR_THERMAL_PRINTER_OPTIONS',
|
|
422
|
+
payload: 'GENERATOR_THERMAL_PRINTER_PAYLOAD',
|
|
423
|
+
rawCommands: 'GENERATOR_THERMAL_PRINTER_RAW_COMMANDS',
|
|
424
|
+
},
|
|
425
|
+
},
|
|
426
|
+
GENERATOR_TTS: {
|
|
427
|
+
GENERATOR_TTS_GENERATE: {
|
|
428
|
+
text: 'GENERATOR_TTS_TEXT',
|
|
429
|
+
},
|
|
430
|
+
},
|
|
431
|
+
GENERATOR_ONNX_LLM: {
|
|
432
|
+
GENERATOR_ONNX_LLM_INFER: {
|
|
433
|
+
prompt: 'GENERATOR_ONNX_LLM_PROMPT',
|
|
434
|
+
chat: 'GENERATOR_ONNX_LLM_CHAT',
|
|
435
|
+
},
|
|
436
|
+
},
|
|
437
|
+
GENERATOR_ONNX_STT: {
|
|
438
|
+
GENERATOR_ONNX_STT_INFER: {
|
|
439
|
+
audioUri: 'GENERATOR_ONNX_STT_AUDIO_URI',
|
|
440
|
+
},
|
|
441
|
+
},
|
|
442
|
+
GENERATOR_SPEECH_INFERENCE: {
|
|
443
|
+
GENERATOR_SPEECH_INFERENCE_TRANSCRIBE_FILE: {
|
|
444
|
+
prompt: 'GENERATOR_SPEECH_INFERENCE_PROMPT',
|
|
445
|
+
beamSize: 'GENERATOR_SPEECH_INFERENCE_BEAM_SIZE',
|
|
446
|
+
language: 'GENERATOR_SPEECH_INFERENCE_LANGUAGE',
|
|
447
|
+
translate: 'GENERATOR_SPEECH_INFERENCE_TRANSLATE',
|
|
448
|
+
fileUrl: 'GENERATOR_SPEECH_INFERENCE_FILE_URL',
|
|
449
|
+
},
|
|
450
|
+
GENERATOR_SPEECH_INFERENCE_TRANSCRIBE_REALTIME: {
|
|
451
|
+
prompt: 'GENERATOR_SPEECH_INFERENCE_PROMPT',
|
|
452
|
+
beamSize: 'GENERATOR_SPEECH_INFERENCE_BEAM_SIZE',
|
|
453
|
+
language: 'GENERATOR_SPEECH_INFERENCE_LANGUAGE',
|
|
454
|
+
translate: 'GENERATOR_SPEECH_INFERENCE_TRANSLATE',
|
|
455
|
+
realtimeAudioSeconds: 'GENERATOR_SPEECH_INFERENCE_REALTIME_AUDIO_SECONDS',
|
|
456
|
+
realtimeAudioSliceSeconds: 'GENERATOR_SPEECH_INFERENCE_REALTIME_AUDIO_SLICE_SECONDS',
|
|
457
|
+
realtimeAudioMinSeconds: 'GENERATOR_SPEECH_INFERENCE_REALTIME_AUDIO_MIN_SECONDS',
|
|
458
|
+
realtimeSaveAudio: 'GENERATOR_SPEECH_INFERENCE_REALTIME_SAVE_AUDIO',
|
|
459
|
+
realtimeVadEnabled: 'GENERATOR_SPEECH_INFERENCE_REALTIME_VAD_ENABLED',
|
|
460
|
+
realtimeVadMs: 'GENERATOR_SPEECH_INFERENCE_REALTIME_VAD_MS',
|
|
461
|
+
realtimeVadThold: 'GENERATOR_SPEECH_INFERENCE_REALTIME_VAD_THOLD',
|
|
462
|
+
realtimeVadFreqThold: 'GENERATOR_SPEECH_INFERENCE_REALTIME_VAD_FREQ_THOLD',
|
|
463
|
+
},
|
|
464
|
+
},
|
|
465
|
+
GENERATOR_LLM: {
|
|
466
|
+
GENERATOR_LLM_PROCESS_PROMPT: {
|
|
467
|
+
mode: 'GENERATOR_LLM_MODE',
|
|
468
|
+
messages: 'GENERATOR_LLM_MESSAGES',
|
|
469
|
+
prompt: 'GENERATOR_LLM_PROMPT',
|
|
470
|
+
promptTemplateData: 'GENERATOR_LLM_PROMPT_TEMPLATE_DATA',
|
|
471
|
+
promptTemplateType: 'GENERATOR_LLM_PROMPT_TEMPLATE_TYPE',
|
|
472
|
+
},
|
|
473
|
+
GENERATOR_LLM_COMPLETION: {
|
|
474
|
+
mode: 'GENERATOR_LLM_MODE',
|
|
475
|
+
messages: 'GENERATOR_LLM_MESSAGES',
|
|
476
|
+
prompt: 'GENERATOR_LLM_PROMPT',
|
|
477
|
+
promptTemplateData: 'GENERATOR_LLM_PROMPT_TEMPLATE_DATA',
|
|
478
|
+
promptTemplateType: 'GENERATOR_LLM_PROMPT_TEMPLATE_TYPE',
|
|
479
|
+
grammar: 'GENERATOR_LLM_GRAMMAR',
|
|
480
|
+
stopWords: 'GENERATOR_LLM_STOP_WORDS',
|
|
481
|
+
predict: 'GENERATOR_LLM_PREDICT',
|
|
482
|
+
temperature: 'GENERATOR_LLM_TEMPERATURE',
|
|
483
|
+
probs: 'GENERATOR_LLM_PROBS',
|
|
484
|
+
topK: 'GENERATOR_LLM_TOP_K',
|
|
485
|
+
topP: 'GENERATOR_LLM_TOP_P',
|
|
486
|
+
tfsZ: 'GENERATOR_LLM_TFS_Z',
|
|
487
|
+
mirostat: 'GENERATOR_LLM_MIROSTAT',
|
|
488
|
+
mirostatTau: 'GENERATOR_LLM_MIROSTAT_TAU',
|
|
489
|
+
mirostatEta: 'GENERATOR_LLM_MIROSTAT_ETA',
|
|
490
|
+
penaltyLastN: 'GENERATOR_LLM_PENALTY_LAST_N',
|
|
491
|
+
penaltyRepeat: 'GENERATOR_LLM_PENALTY_REPEAT',
|
|
492
|
+
penaltyFrequency: 'GENERATOR_LLM_PENALTY_FREQUENCY',
|
|
493
|
+
penaltyPresent: 'GENERATOR_LLM_PENALTY_PRESENT',
|
|
494
|
+
penalizeNewline: 'GENERATOR_LLM_PENALIZE_NEWLINE',
|
|
495
|
+
seed: 'GENERATOR_LLM_SEED',
|
|
496
|
+
typicalP: 'GENERATOR_LLM_TYPICAL_P',
|
|
497
|
+
ignoreEos: 'GENERATOR_LLM_IGNORE_EOS',
|
|
498
|
+
functionCallEnabled: 'GENERATOR_LLM_FUNCTION_CALL_ENABLED',
|
|
499
|
+
functionCallSchema: 'GENERATOR_LLM_FUNCTION_CALL_SCHEMA',
|
|
500
|
+
},
|
|
501
|
+
},
|
|
502
|
+
}
|
package/compile/index.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import _ from 'lodash'
|
|
2
|
-
import { parse as parseAST
|
|
2
|
+
import { parse as parseAST } from 'acorn'
|
|
3
|
+
import type { ExportNamedDeclaration, FunctionDeclaration } from 'acorn'
|
|
3
4
|
import escodegen from 'escodegen'
|
|
4
|
-
import {
|
|
5
|
+
import { generateCalulationMap } from './util'
|
|
6
|
+
import { templateActionNameMap } from './action-name-map'
|
|
7
|
+
import type {
|
|
5
8
|
Application,
|
|
6
9
|
Data,
|
|
7
10
|
Animation,
|
|
@@ -23,7 +26,6 @@ import {
|
|
|
23
26
|
Canvas,
|
|
24
27
|
Subspace,
|
|
25
28
|
} from '../types'
|
|
26
|
-
import { generateCalulationMap } from './util'
|
|
27
29
|
|
|
28
30
|
const compileProperty = (property, result = {}) => {
|
|
29
31
|
if (Array.isArray(property)) {
|
|
@@ -66,6 +68,9 @@ const compileAnimations = (templateKey: string, animations: { [key: string]: Ani
|
|
|
66
68
|
}, {})
|
|
67
69
|
}
|
|
68
70
|
|
|
71
|
+
const compileActionParam = (templateKey: string, actionName: string, paramName: string) =>
|
|
72
|
+
templateActionNameMap[templateKey]?.[actionName]?.[paramName] || paramName
|
|
73
|
+
|
|
69
74
|
const compileEvents = (
|
|
70
75
|
templateKey: string,
|
|
71
76
|
eventMap: { [key: string]: Array<EventAction> },
|
|
@@ -76,12 +81,27 @@ const compileEvents = (
|
|
|
76
81
|
acc[convertEventKey(templateKey, key)] = events.map((event) => {
|
|
77
82
|
const { handler, action } = event
|
|
78
83
|
|
|
84
|
+
let handlerKey
|
|
85
|
+
let handlerTemplateKey
|
|
86
|
+
if (handler === 'system' || typeof handler === 'string') {
|
|
87
|
+
if (handler.startsWith('SUBSPACE_')) handlerKey = handler
|
|
88
|
+
else handlerKey = handler.toUpperCase()
|
|
89
|
+
if (handlerKey === 'SYSTEM') handlerTemplateKey = 'SYSTEM'
|
|
90
|
+
} else if (typeof handler === 'function') {
|
|
91
|
+
const instance = handler() as Brick | Generator
|
|
92
|
+
handlerKey = instance?.id
|
|
93
|
+
handlerTemplateKey = instance?.templateKey
|
|
94
|
+
}
|
|
95
|
+
if (!handlerKey) throw new Error(`Invalid handler: ${handler}`)
|
|
96
|
+
|
|
79
97
|
const parameterList: Array<object> = []
|
|
80
98
|
if (Object.hasOwn(action, 'params')) {
|
|
81
99
|
const actionDef = action as ActionWithParams
|
|
82
100
|
;(actionDef.params || []).forEach(({ input, value, mapping }) => {
|
|
83
101
|
parameterList.push({
|
|
84
|
-
[camelCase ? 'inputToReceiver' : 'input_to_receiver']:
|
|
102
|
+
[camelCase ? 'inputToReceiver' : 'input_to_receiver']: handlerTemplateKey
|
|
103
|
+
? compileActionParam(handlerTemplateKey, action.__actionName, input)
|
|
104
|
+
: input,
|
|
85
105
|
[camelCase ? 'resultFromSender' : 'result_from_sender']: compileProperty(value),
|
|
86
106
|
[camelCase ? 'resultDataMapping' : 'result_data_mapping']: mapping,
|
|
87
107
|
})
|
|
@@ -97,14 +117,6 @@ const compileEvents = (
|
|
|
97
117
|
})
|
|
98
118
|
})
|
|
99
119
|
}
|
|
100
|
-
let handlerKey
|
|
101
|
-
if (handler === 'system' || typeof handler === 'string') {
|
|
102
|
-
if (handler.startsWith('SUBSPACE_')) handlerKey = handler
|
|
103
|
-
else handlerKey = handler.toUpperCase()
|
|
104
|
-
} else if (typeof handler === 'function') {
|
|
105
|
-
handlerKey = (handler() as Brick | Generator)?.id
|
|
106
|
-
}
|
|
107
|
-
if (!handlerKey) throw new Error(`Invalid handler: ${handler}`)
|
|
108
120
|
return {
|
|
109
121
|
handler: handlerKey,
|
|
110
122
|
action: action.__actionName,
|
|
@@ -119,22 +131,23 @@ const compileEvents = (
|
|
|
119
131
|
const compileSwitchConds = (templateKey, conds) =>
|
|
120
132
|
(conds || []).map((item: any) => {
|
|
121
133
|
const result: any = { method: item.method }
|
|
122
|
-
if (item.__typename === 'SwitchCondData') {
|
|
123
|
-
const cond = item as SwitchCondData
|
|
134
|
+
if (item.cond.__typename === 'SwitchCondData') {
|
|
135
|
+
const cond = item.cond as SwitchCondData
|
|
124
136
|
result.type = 'property_bank'
|
|
125
137
|
result.key = cond.data().id
|
|
126
138
|
result.value = cond.value
|
|
127
|
-
} else if (item.__typename === 'SwitchCondPropertyBankByItemKey') {
|
|
128
|
-
const cond = item as SwitchCondPropertyBankByItemKey
|
|
139
|
+
} else if (item.cond.__typename === 'SwitchCondPropertyBankByItemKey') {
|
|
140
|
+
const cond = item.cond as SwitchCondPropertyBankByItemKey
|
|
129
141
|
result.type = 'property_bank_by_item_key'
|
|
130
142
|
result.key = cond.data().id
|
|
131
143
|
result.value = cond.value
|
|
132
|
-
} else if (item.__typename === 'SwitchCondInnerStateOutlet') {
|
|
144
|
+
} else if (item.cond.__typename === 'SwitchCondInnerStateOutlet') {
|
|
145
|
+
const cond = item.cond
|
|
133
146
|
result.type = 'inner_state'
|
|
134
|
-
result.key = convertOutletKey(templateKey,
|
|
135
|
-
result.value =
|
|
136
|
-
} else if (item.__typename === 'SwitchCondInnerStateCurrentCanvas') {
|
|
137
|
-
const cond = item as SwitchCondInnerStateCurrentCanvas
|
|
147
|
+
result.key = convertOutletKey(templateKey, cond.outlet)
|
|
148
|
+
result.value = cond.value
|
|
149
|
+
} else if (item.cond.__typename === 'SwitchCondInnerStateCurrentCanvas') {
|
|
150
|
+
const cond = item.cond as SwitchCondInnerStateCurrentCanvas
|
|
138
151
|
result.type = 'inner_state'
|
|
139
152
|
result.key = 'current_canvas'
|
|
140
153
|
result.value = cond.value().id
|
|
@@ -283,17 +296,23 @@ export const compile = (app: Application) => {
|
|
|
283
296
|
eventMap: compileEvents(itemBrick.templateKey, itemBrick.eventMap || {}, {
|
|
284
297
|
camelCase: true,
|
|
285
298
|
}),
|
|
286
|
-
stateGroup: itemBrick.stateGroup.
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
299
|
+
stateGroup: itemBrick.stateGroup.reduce((acc, stateGroup) => {
|
|
300
|
+
acc[stateGroup.id] = {
|
|
301
|
+
title: stateGroup.title,
|
|
302
|
+
description: stateGroup.description,
|
|
303
|
+
override: stateGroup.override,
|
|
304
|
+
break: stateGroup.break,
|
|
305
|
+
commented: stateGroup.disabled,
|
|
306
|
+
conds: compileSwitchConds(itemBrick.templateKey, stateGroup.conds || []),
|
|
307
|
+
property: compileProperty(stateGroup.property),
|
|
308
|
+
animation: compileAnimations(itemBrick.templateKey, stateGroup.animation || {}),
|
|
309
|
+
outlet: compileOutlets(itemBrick.templateKey, stateGroup.outlets || {}),
|
|
310
|
+
eventMap: compileEvents(itemBrick.templateKey, stateGroup.eventMap || {}, {
|
|
311
|
+
camelCase: true,
|
|
312
|
+
}),
|
|
313
|
+
}
|
|
314
|
+
return acc
|
|
315
|
+
}, {}),
|
|
297
316
|
})
|
|
298
317
|
if (Array.isArray(brickItems.brickList)) {
|
|
299
318
|
const brickList = (brickItems.brickList || []).map(buildList)
|
|
@@ -580,7 +599,7 @@ export const compile = (app: Application) => {
|
|
|
580
599
|
map[dataCalc.id] = calc
|
|
581
600
|
return map
|
|
582
601
|
}, {}),
|
|
583
|
-
action_map: subspace.actions ||
|
|
602
|
+
action_map: subspace.actions || undefined,
|
|
584
603
|
event_map: compileEvents('', subspace.events || {}),
|
|
585
604
|
routing: subspace.dataRouting.reduce((acc, data) => {
|
|
586
605
|
acc[data.id] = { enabled_routing: true }
|
package/package.json
CHANGED
package/tools/deploy.ts
CHANGED
|
@@ -6,7 +6,7 @@ const cwd = process.cwd()
|
|
|
6
6
|
const unstagedChanges = await $`cd ${cwd} && git diff --name-only --diff-filter=ACMR`.text()
|
|
7
7
|
if (unstagedChanges) throw new Error('Unstaged changes found, please commit or stash your changes before deploying')
|
|
8
8
|
|
|
9
|
-
const commitId = await $`cd ${cwd} && git rev-parse HEAD`.text()
|
|
9
|
+
const commitId = (await $`cd ${cwd} && git rev-parse HEAD`.text()).trim()
|
|
10
10
|
const app = await Bun.file(`${cwd}/application.json`).json()
|
|
11
11
|
const stage = app.stage || 'production'
|
|
12
12
|
const config = await Bun.file(`${cwd}/.bricks/build/application-config.json`).json()
|
|
@@ -16,9 +16,9 @@ const confirm = prompt('Are you sure you want to deploy? (y/n)')
|
|
|
16
16
|
if (confirm !== 'y') throw new Error('Deployment cancelled')
|
|
17
17
|
|
|
18
18
|
if (!app.type || app.type === 'application') {
|
|
19
|
-
await deployApp(stage, app.
|
|
19
|
+
await deployApp(stage, app.id, config, commitId)
|
|
20
20
|
console.log('App deployed')
|
|
21
21
|
} else if (app.type === 'module') {
|
|
22
|
-
await deployModule(stage, app.
|
|
22
|
+
await deployModule(stage, app.id, config, commitId)
|
|
23
23
|
console.log('Module deployed')
|
|
24
24
|
}
|
package/tools/pull.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { $ } from 'bun'
|
|
2
|
+
import { format } from 'prettier'
|
|
2
3
|
import { pullApplicationProject, pullModuleProject } from '../api'
|
|
3
4
|
|
|
4
5
|
const cwd = process.cwd()
|
|
@@ -11,24 +12,37 @@ const app = await Bun.file(`${cwd}/application.json`).json()
|
|
|
11
12
|
const stage = app.stage || 'production'
|
|
12
13
|
const { files, lastCommitId } =
|
|
13
14
|
app.type === 'module'
|
|
14
|
-
? await pullModuleProject(stage, app.
|
|
15
|
-
: await pullApplicationProject(stage, app.
|
|
15
|
+
? await pullModuleProject(stage, app.id)
|
|
16
|
+
: await pullApplicationProject(stage, app.id)
|
|
16
17
|
|
|
17
|
-
const
|
|
18
|
+
const found = (await $`cd ${cwd} && git rev-list -1 ${lastCommitId}`.nothrow().text())
|
|
19
|
+
.trim()
|
|
20
|
+
.match(/^[a-f0-9]{40}$/)
|
|
21
|
+
|
|
22
|
+
const commitId = (await $`cd ${cwd} && git rev-parse HEAD`.text()).trim()
|
|
18
23
|
|
|
19
|
-
|
|
24
|
+
if (commitId === lastCommitId) throw new Error('Commit not changed')
|
|
25
|
+
|
|
26
|
+
const branchName = 'BRICKS_PROJECT_try-pull-application'
|
|
20
27
|
|
|
21
|
-
|
|
28
|
+
await $`cd ${cwd} && git branch -D ${branchName}`.nothrow()
|
|
22
29
|
|
|
23
30
|
let useMain = false
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
if (found) {
|
|
32
|
+
await $`cd ${cwd} && git checkout -b ${branchName} ${lastCommitId}`.nothrow()
|
|
33
|
+
} else {
|
|
27
34
|
await $`cd ${cwd} && git checkout -b ${branchName}`
|
|
28
35
|
useMain = true
|
|
29
36
|
}
|
|
30
37
|
|
|
31
|
-
await Promise.all(
|
|
38
|
+
await Promise.all(
|
|
39
|
+
files.map(async (file) =>
|
|
40
|
+
Bun.write(
|
|
41
|
+
`${cwd}/${file.name}`,
|
|
42
|
+
file.formatable ? await format(file.input, { parser: 'typescript' }) : file.input,
|
|
43
|
+
),
|
|
44
|
+
),
|
|
45
|
+
)
|
|
32
46
|
|
|
33
47
|
await $`cd ${cwd} && git add .`
|
|
34
48
|
await $`cd ${cwd} && git commit -m 'Apply ${app.name} file changes'`
|
package/types/bricks.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from './switch'
|
|
2
|
-
import { Data, DataLink } from './data'
|
|
3
|
-
import { Animation, AnimationBasicEvents } from './animation'
|
|
4
|
-
import { Brick, EventAction, ActionWithDataParams, ActionWithParams, Action } from './common'
|
|
1
|
+
import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from './switch'
|
|
2
|
+
import type { Data, DataLink } from './data'
|
|
3
|
+
import type { Animation, AnimationBasicEvents } from './animation'
|
|
4
|
+
import type { Brick, EventAction, ActionWithDataParams, ActionWithParams, Action } from './common'
|
|
5
5
|
|
|
6
6
|
interface BrickBasicProperty {
|
|
7
7
|
/* The brick opacity (0 ~ 1) */
|
package/types/common.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SwitchDef } from './switch'
|
|
2
|
-
import { Data } from './data'
|
|
3
|
-
import { Subspace } from './subspace'
|
|
1
|
+
import type { SwitchDef } from './switch'
|
|
2
|
+
import type { Data } from './data'
|
|
3
|
+
import type { Subspace } from './subspace'
|
|
4
4
|
|
|
5
5
|
export interface Brick {
|
|
6
6
|
__typename: 'Brick'
|
package/types/subspace.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Brick, Generator, LocalSyncStrategy, EventAction, SubspaceID } from './common'
|
|
2
|
-
import { Animation } from './animation'
|
|
3
|
-
import { Canvas } from './canvas'
|
|
4
|
-
import { Data } from './data'
|
|
5
|
-
import { DataCalculation } from './data-calc'
|
|
1
|
+
import type { Brick, Generator, LocalSyncStrategy, EventAction, SubspaceID } from './common'
|
|
2
|
+
import type { Animation } from './animation'
|
|
3
|
+
import type { Canvas } from './canvas'
|
|
4
|
+
import type { Data } from './data'
|
|
5
|
+
import type { DataCalculation } from './data-calc'
|
|
6
6
|
|
|
7
7
|
export type Subspace = {
|
|
8
8
|
__typename: 'Subspace'
|
package/types/switch.ts
CHANGED