@fugood/bricks-project 2.21.0-beta.14.test0

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/types/index.ts ADDED
@@ -0,0 +1,10 @@
1
+ export * from './data'
2
+ export * from './data-calc'
3
+ export * from './generators'
4
+ export * from './bricks'
5
+ export * from './animation'
6
+ export * from './canvas'
7
+ export * from './subspace'
8
+ export * from './common'
9
+ export * from './switch'
10
+ export * from './system'
@@ -0,0 +1,33 @@
1
+ import { Brick, Generator, LocalSyncStrategy, EventAction } from './common'
2
+ import { Animation } from './animation'
3
+ import { Canvas } from './canvas'
4
+ import { Data } from './data'
5
+ import { DataCalculation } from './data-calc'
6
+
7
+ export type Subspace = {
8
+ __typename: 'Subspace'
9
+ id: string
10
+ title: string
11
+ description?: string
12
+ localSyncChangeCanvas?: LocalSyncStrategy
13
+ layout: {
14
+ width: number
15
+ height: number
16
+ resizeMode?: 'cover' | 'stretch'
17
+ }
18
+ rootCanvas: Canvas
19
+ canvases: Array<Canvas>
20
+ animations: Array<Animation>
21
+ bricks: Array<Brick>
22
+ generators: Array<Generator>
23
+ data: Array<Data>
24
+ dataCalculation: Array<DataCalculation>
25
+ actions?: {
26
+ [key: string]: {
27
+ description: string
28
+ // TODO: add eventPropertyMap
29
+ }
30
+ }
31
+ events?: { [key: string]: Array<EventAction> }
32
+ }
33
+
@@ -0,0 +1,45 @@
1
+ import { Canvas } from './canvas'
2
+ import { Data } from './data'
3
+ export type SwitchCondInnerStateCurrentCanvas = {
4
+ __typename: 'SwitchCondInnerStateCurrentCanvas'
5
+ value: () => Canvas
6
+ }
7
+
8
+ export type SwitchCondData = {
9
+ __typename: 'SwitchCondData'
10
+ data: () => Data
11
+ value: any
12
+ }
13
+
14
+ export type SwitchCondPropertyBankByItemKey = {
15
+ __typename: 'SwitchCondPropertyBankByItemKey'
16
+ data: () => Data
17
+ value: any
18
+ }
19
+
20
+ export interface SwitchDef {
21
+ id: string
22
+ title?: string
23
+ description?: string
24
+ override?: {
25
+ animation?: boolean
26
+ event?: boolean
27
+ property?: boolean
28
+ outlet?: boolean
29
+ }
30
+ disabled?: boolean
31
+ break?: boolean
32
+ // Default property, events, outlets, animation, conds
33
+ property?: {}
34
+ events?: {}
35
+ outlets?: {}
36
+ animation?: {}
37
+ conds?: Array<{
38
+ method: '==' | '!=' | '>' | '<' | '>=' | '<='
39
+ cond: SwitchCondInnerStateCurrentCanvas | SwitchCondData | {
40
+ __typename: 'SwitchCondInnerStateOutlet'
41
+ outlet: string
42
+ value: any
43
+ }
44
+ }>
45
+ }
@@ -0,0 +1,397 @@
1
+ import { Action, ActionWithDataParams, ActionWithParams, Brick, Generator } from './common'
2
+ import { Canvas } from './canvas'
3
+ import { Data, DataLink } from './data'
4
+
5
+ /* Change Data value */
6
+ export type SystemActionPropertyBank = ActionWithDataParams & {
7
+ __actionName: 'PROPERTY_BANK'
8
+ }
9
+
10
+ /* Change Data value with expression */
11
+ export type SystemActionPropertyBankExpression = ActionWithParams & {
12
+ __actionName: 'PROPERTY_BANK_EXPRESSION'
13
+ params?: Array<
14
+ | {
15
+ input: 'expression'
16
+ value?: string | DataLink
17
+ mapping?: boolean
18
+ }
19
+ | {
20
+ input: 'variables'
21
+ value?: {} | DataLink
22
+ mapping?: boolean
23
+ }
24
+ | {
25
+ input: 'result'
26
+ value?: string | DataLink | (() => Data)
27
+ mapping?: boolean
28
+ }
29
+ | {
30
+ input: 'resultAssignPath'
31
+ value?: string | DataLink
32
+ mapping?: boolean
33
+ }
34
+ | {
35
+ input: 'errorResult'
36
+ value?: string | DataLink | (() => Data)
37
+ mapping?: boolean
38
+ }
39
+ >
40
+ }
41
+
42
+ /* Trigger Data calculation flow without value change */
43
+ export type SystemActionPropertyBankCommand = ActionWithDataParams & {
44
+ __actionName: 'PROPERTY_BANK_COMMAND'
45
+ }
46
+
47
+ /* [Unstable] Dynamically generate bricks */
48
+ export type SystemActionDynamicBrick = ActionWithParams & {
49
+ __actionName: 'DYNAMIC_BRICK'
50
+ params?: Array<
51
+ | {
52
+ input: 'addList'
53
+ value?: string | DataLink
54
+ mapping?: boolean
55
+ }
56
+ | {
57
+ input: 'preferAfterItemId'
58
+ value?: string | DataLink
59
+ mapping?: boolean
60
+ }
61
+ | {
62
+ input: 'reset'
63
+ value?: boolean | DataLink
64
+ mapping?: boolean
65
+ }
66
+ | {
67
+ input: 'removeItemId'
68
+ value?: string | DataLink
69
+ mapping?: boolean
70
+ }
71
+ | {
72
+ input: 'removeItems'
73
+ value?: string | DataLink
74
+ mapping?: boolean
75
+ }
76
+ >
77
+ }
78
+
79
+ /* [Unstable] Reset Dynamic Bricks */
80
+ export type SystemActionDynamicBrickReset = Action & {
81
+ __actionName: 'DYNAMIC_BRICK_RESET'
82
+ }
83
+
84
+ /* Run specific Animation on specific Brick */
85
+ export type SystemActionDynamicAnimation = ActionWithParams & {
86
+ __actionName: 'DYNAMIC_ANIMATION'
87
+ params?: Array<
88
+ | {
89
+ input: 'brickId'
90
+ value?: string | DataLink | (() => Brick)
91
+ mapping?: boolean
92
+ }
93
+ | {
94
+ input: 'animationId'
95
+ value?: string | DataLink | (() => Animation)
96
+ mapping?: boolean
97
+ }
98
+ | {
99
+ input: 'runType'
100
+ value?: 'once' | 'loop' | DataLink
101
+ mapping?: boolean
102
+ }
103
+ | {
104
+ input: 'resetInitialValue'
105
+ value?: boolean | DataLink
106
+ mapping?: boolean
107
+ }
108
+ >
109
+ }
110
+
111
+ /* Reset Dynamic Animation */
112
+ export type SystemActionDynamicAnimationReset = ActionWithParams & {
113
+ __actionName: 'DYNAMIC_ANIMATION_RESET'
114
+ params?: Array<{
115
+ input: 'dynamicAnimationBrickId'
116
+ value?: string | DataLink | (() => Brick)
117
+ mapping?: boolean
118
+ }>
119
+ }
120
+
121
+ /* Stop Dynamic Animation */
122
+ export type SystemActionDynamicAnimationStop = ActionWithParams & {
123
+ __actionName: 'DYNAMIC_ANIMATION_STOP'
124
+ params?: Array<{
125
+ input: 'dynamicAnimationBrickId'
126
+ value?: string | DataLink | (() => Brick)
127
+ mapping?: boolean
128
+ }>
129
+ }
130
+
131
+ /* Change canvas on the current Subspace */
132
+ export type SystemActionChangeCanvas = ActionWithParams & {
133
+ __actionName: 'CHANGE_CANVAS'
134
+ params?: Array<
135
+ | {
136
+ input: 'canvasId'
137
+ value?: string | DataLink | (() => Canvas)
138
+ mapping?: boolean
139
+ }
140
+ | {
141
+ input: 'canvasTitleLike'
142
+ value?: string | DataLink
143
+ mapping?: boolean
144
+ }
145
+ >
146
+ }
147
+
148
+ /* Log System message */
149
+ export type SystemActionMessage = ActionWithParams & {
150
+ __actionName: 'MESSAGE'
151
+ params?: Array<
152
+ | {
153
+ input: 'type'
154
+ value?:
155
+ | 'SYSTEM_MESSAGE_TYPE_INFO'
156
+ | 'SYSTEM_MESSAGE_TYPE_SUCCESS'
157
+ | 'SYSTEM_MESSAGE_TYPE_WARNING'
158
+ | 'SYSTEM_MESSAGE_TYPE_ERROR'
159
+ | DataLink
160
+ mapping?: boolean
161
+ }
162
+ | {
163
+ input: 'title'
164
+ value?: string | DataLink
165
+ mapping?: boolean
166
+ }
167
+ | {
168
+ input: 'message'
169
+ value?: string | DataLink
170
+ mapping?: boolean
171
+ }
172
+ >
173
+ }
174
+
175
+ /* Show system alert popup with custom message */
176
+ export type SystemActionAlert = ActionWithParams & {
177
+ __actionName: 'ALERT'
178
+ params?: Array<
179
+ | {
180
+ input: 'id'
181
+ value?: string | DataLink
182
+ mapping?: boolean
183
+ }
184
+ | {
185
+ input: 'type'
186
+ value?: 'info' | 'success' | 'warning' | 'error' | DataLink
187
+ mapping?: boolean
188
+ }
189
+ | {
190
+ input: 'title'
191
+ value?: string | DataLink
192
+ mapping?: boolean
193
+ }
194
+ | {
195
+ input: 'message'
196
+ value?: string | DataLink
197
+ mapping?: boolean
198
+ }
199
+ | {
200
+ input: 'selections'
201
+ value?: {} | DataLink
202
+ mapping?: boolean
203
+ }
204
+ | {
205
+ input: 'selectionResult'
206
+ value?: string | DataLink | (() => Data)
207
+ mapping?: boolean
208
+ }
209
+ | {
210
+ input: 'timeout'
211
+ value?: number | DataLink
212
+ mapping?: boolean
213
+ }
214
+ >
215
+ }
216
+
217
+ /* Close current showing popups with type or id. */
218
+ export type SystemActionPopupReset = ActionWithParams & {
219
+ __actionName: 'POPUP_RESET'
220
+ params?: Array<
221
+ | {
222
+ input: 'popupClearType'
223
+ value?: 'all' | 'alert' | 'generator' | DataLink
224
+ mapping?: boolean
225
+ }
226
+ | {
227
+ input: 'popupId'
228
+ value?: string | DataLink
229
+ mapping?: boolean
230
+ }
231
+ >
232
+ }
233
+
234
+ /* Take screenshot for current subspace */
235
+ export type SystemActionTakeScreenshot = ActionWithParams & {
236
+ __actionName: 'TAKE_SCREENSHOT'
237
+ params?: Array<
238
+ | {
239
+ input: 'currentSubspace'
240
+ value?: boolean | DataLink
241
+ mapping?: boolean
242
+ }
243
+ | {
244
+ input: 'format'
245
+ value?: 'jpg' | 'png' | DataLink
246
+ mapping?: boolean
247
+ }
248
+ | {
249
+ input: 'quality'
250
+ value?: number | DataLink
251
+ mapping?: boolean
252
+ }
253
+ | {
254
+ input: 'width'
255
+ value?: number | DataLink
256
+ mapping?: boolean
257
+ }
258
+ | {
259
+ input: 'height'
260
+ value?: number | DataLink
261
+ mapping?: boolean
262
+ }
263
+ | {
264
+ input: 'saveProperty'
265
+ value?: string | DataLink | (() => Data)
266
+ mapping?: boolean
267
+ }
268
+ >
269
+ }
270
+
271
+ /* [Internal] Use a shared application */
272
+ export type SystemActionUseShareApplication = ActionWithParams & {
273
+ __actionName: 'USE_SHARE_APPLICATION'
274
+ params?: Array<
275
+ | {
276
+ input: 'applicationId'
277
+ value?: string | DataLink
278
+ mapping?: boolean
279
+ }
280
+ | {
281
+ input: 'releaseVersion'
282
+ value?: string | DataLink
283
+ mapping?: boolean
284
+ }
285
+ | {
286
+ input: 'useType'
287
+ value?: 'run' | 'use-after-bind' | 'cancel-use' | DataLink
288
+ mapping?: boolean
289
+ }
290
+ | {
291
+ input: 'viewportPresetNameLike'
292
+ value?: string | DataLink
293
+ mapping?: boolean
294
+ }
295
+ | {
296
+ input: 'viewportPresetDeviceTarget'
297
+ value?: string | DataLink
298
+ mapping?: boolean
299
+ }
300
+ | {
301
+ input: 'enableLocalSync'
302
+ value?: boolean | DataLink
303
+ mapping?: boolean
304
+ }
305
+ >
306
+ }
307
+
308
+ /* [Internal] Auth in device */
309
+ export type SystemActionAuthInDevice = Action & {
310
+ __actionName: 'AUTH_IN_DEVICE'
311
+ }
312
+
313
+ /* [Internal] Refresh passcode for bind device */
314
+ export type SystemActionRefreshBindcode = Action & {
315
+ __actionName: 'REFRESH_BINDCODE'
316
+ }
317
+
318
+ /* Open URL */
319
+ export type SystemActionOpenUrl = ActionWithParams & {
320
+ __actionName: 'OPEN_URL'
321
+ params?: Array<
322
+ | {
323
+ input: 'url'
324
+ value?: string | DataLink
325
+ mapping?: boolean
326
+ }
327
+ | {
328
+ input: 'behavior'
329
+ value?: 'in-app' | 'new-window' | DataLink
330
+ mapping?: boolean
331
+ }
332
+ | {
333
+ input: 'inAppTintColor'
334
+ value?: string | DataLink
335
+ mapping?: boolean
336
+ }
337
+ >
338
+ }
339
+
340
+ /* Open File or Directory */
341
+ export type SystemActionOpenFile = ActionWithParams & {
342
+ __actionName: 'OPEN_FILE'
343
+ params?: Array<
344
+ | {
345
+ input: 'pickType'
346
+ value?: 'file' | 'multiple' | 'directory' | DataLink
347
+ mapping?: boolean
348
+ }
349
+ | {
350
+ input: 'fileType'
351
+ value?: any
352
+ mapping?: boolean
353
+ }
354
+ | {
355
+ input: 'copyTo'
356
+ value?: 'cache' | 'document' | DataLink
357
+ mapping?: boolean
358
+ }
359
+ | {
360
+ input: 'mode'
361
+ value?: 'import' | 'open' | DataLink
362
+ mapping?: boolean
363
+ }
364
+ | {
365
+ input: 'saveProperty'
366
+ value?: string | DataLink | (() => Data)
367
+ mapping?: boolean
368
+ }
369
+ | {
370
+ input: 'saveDetailProperty'
371
+ value?: string | DataLink | (() => Data)
372
+ mapping?: boolean
373
+ }
374
+ | {
375
+ input: 'errorSaveProperty'
376
+ value?: string | DataLink | (() => Data)
377
+ mapping?: boolean
378
+ }
379
+ >
380
+ }
381
+
382
+ /* Throw exception */
383
+ export type SystemActionThrowException = ActionWithParams & {
384
+ __actionName: 'THROW_EXCEPTION'
385
+ params?: Array<
386
+ | {
387
+ input: 'behavior'
388
+ value?: 'application' | 'application-render' | 'native' | DataLink
389
+ mapping?: boolean
390
+ }
391
+ | {
392
+ input: 'exceptionMessage'
393
+ value?: string | DataLink
394
+ mapping?: boolean
395
+ }
396
+ >
397
+ }
package/uuid.ts ADDED
@@ -0,0 +1,58 @@
1
+
2
+ import { v4 as uuid } from 'uuid'
3
+
4
+ let count = 0
5
+
6
+ // Used for snapshot mode
7
+ const countUUID = () => {
8
+ return `00000000-0000-0000-0000-${(count++).toString().padStart(12, '0')}`
9
+ }
10
+
11
+ export const makeId = (type, opts?: {
12
+ snapshotMode?: boolean,
13
+ }) => {
14
+ let prefix = ''
15
+ switch (type) {
16
+ case 'animation':
17
+ prefix = 'ANIMATION_'
18
+ break
19
+ case 'brick':
20
+ prefix = 'BRICK_'
21
+ break
22
+ case 'dynamic-brick':
23
+ prefix = 'DYNAMIC_BRICK_'
24
+ break
25
+ case 'subspace':
26
+ prefix = 'SUBSPACE_'
27
+ break
28
+ case 'canvas':
29
+ prefix = 'CANVAS_'
30
+ break
31
+ case 'generator':
32
+ prefix = 'GENERATOR_'
33
+ break
34
+ case 'data':
35
+ prefix = 'PROPERTY_BANK_DATA_NODE_'
36
+ break
37
+ case 'property_bank_command':
38
+ prefix = 'PROPERTY_BANK_COMMAND_NODE_'
39
+ break
40
+ case 'property_bank_calc':
41
+ prefix = 'PROPERTY_BANK_COMMAND_MAP_'
42
+ break
43
+ case 'test':
44
+ prefix = 'TEST_'
45
+ break
46
+ case 'test_case':
47
+ prefix = 'TEST_CASE_'
48
+ break
49
+ case 'test_var':
50
+ prefix = 'TEST_VAR_'
51
+ break
52
+ case 'state_group':
53
+ prefix = 'BRICK_STATE_GROUP_'
54
+ break
55
+ default:
56
+ }
57
+ return `${prefix}${opts?.snapshotMode ? countUUID() : uuid()}`
58
+ }