@fugood/bricks-project 2.21.0-beta.14.test2 → 2.21.0-beta.14.test4

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/index.ts CHANGED
@@ -1 +1 @@
1
- export * from './application'
1
+ export * from './instance'
@@ -48,6 +48,30 @@ export const deployApp = async (appId: string, config: {}, lastCommitId: string)
48
48
  return true
49
49
  }
50
50
 
51
+ export const deployModule = async (modId: string, config: {}, lastCommitId: string) => {
52
+ const { errors } = await doGQL(
53
+ `mutation BRICKS_PROJECT_updateModule($id: ID!, $config: JSON) {
54
+ updateModule(
55
+ id: $id
56
+ config: $config
57
+ validateConfig: true
58
+ ) {
59
+ _id
60
+ name
61
+ }
62
+ }`,
63
+ {
64
+ id: modId,
65
+ config: {
66
+ ...config,
67
+ bricks_project_last_commit_id: lastCommitId,
68
+ },
69
+ },
70
+ )
71
+ if (errors) throw new Error(errors[0].message)
72
+ return true
73
+ }
74
+
51
75
  export const pullApp = async (appId: string) => {
52
76
  const { data, errors } = await doGQL(
53
77
  `query BRICKS_PROJECT_application($id: ID!) {
@@ -63,3 +87,19 @@ export const pullApp = async (appId: string) => {
63
87
  if (errors) throw new Error(errors[0].message)
64
88
  return data.application
65
89
  }
90
+
91
+ export const pullModule = async (modId: string) => {
92
+ const { data, errors } = await doGQL(
93
+ `query BRICKS_PROJECT_module($id: ID!) {
94
+ module(id: $id) {
95
+ _id
96
+ name
97
+ description
98
+ config
99
+ }
100
+ }`,
101
+ { id: modId },
102
+ )
103
+ if (errors) throw new Error(errors[0].message)
104
+ return data.module
105
+ }
package/compile/index.ts CHANGED
@@ -4,6 +4,7 @@ import escodegen from 'escodegen'
4
4
  import {
5
5
  Application,
6
6
  Data,
7
+ Animation,
7
8
  AnimationDef,
8
9
  AnimationComposeDef,
9
10
  EventAction,
@@ -20,6 +21,7 @@ import {
20
21
  Brick,
21
22
  Generator,
22
23
  Canvas,
24
+ Subspace,
23
25
  } from '../types'
24
26
  import { generateCalulationMap } from './util'
25
27
 
@@ -184,6 +186,47 @@ const compileFrame = (frame: Canvas['items'][number]['frame']) => ({
184
186
  render_out_of_viewport: frame.renderOutOfViewport,
185
187
  })
186
188
 
189
+ const compileKind = (kind: Data['kind']) => {
190
+ const { type, ...rest } = kind || {}
191
+ if (!type) return {}
192
+ return { kind: type, ...rest }
193
+ }
194
+
195
+ const compileRemoteUpdate = (remoteUpdate: Data['remoteUpdate']) => {
196
+ if (!remoteUpdate) return {}
197
+ if (remoteUpdate.type === 'auto') return { enable_remote_update: true }
198
+ return {
199
+ enable_remote_update: true,
200
+ ...(remoteUpdate.type === 'device-specific' ? { use_remote_id_prefix: true } : {}),
201
+ ...(remoteUpdate.type === 'global-data' ? { global_remote_update_prop: remoteUpdate.id } : {}),
202
+ }
203
+ }
204
+
205
+ const compileModule = (subspace: Subspace) => {
206
+ if (!subspace.module) return {}
207
+ return {
208
+ module: {
209
+ link: true,
210
+ id: subspace.module.id,
211
+ version: subspace.module.version,
212
+ },
213
+ selected_requirements: subspace.module.selectedRequirements?.reduce((acc, requirement) => {
214
+ acc[requirement.subspace] = {
215
+ id: requirement.id,
216
+ version: requirement.version,
217
+ }
218
+ return acc
219
+ }, {}),
220
+ requirements: subspace.module.requirements?.reduce((acc, requirement) => {
221
+ acc[requirement.subspace] = {
222
+ id: requirement.id,
223
+ version: requirement.version,
224
+ }
225
+ return acc
226
+ }, {}),
227
+ }
228
+ }
229
+
187
230
  export const compile = (app: Application) => {
188
231
  const config = {
189
232
  title: app.name,
@@ -196,6 +239,11 @@ export const compile = (app: Application) => {
196
239
  height: subspace.layout?.height,
197
240
  resize_mode: subspace.layout?.resizeMode,
198
241
  },
242
+ local_sync: subspace.localSyncChangeCanvas
243
+ ? {
244
+ change_canvas: subspace.localSyncChangeCanvas,
245
+ }
246
+ : undefined,
199
247
  animation_map: subspace.animations.reduce((map, animation) => {
200
248
  if (animation.__typename === 'Animation') {
201
249
  const animationDef = animation as AnimationDef
@@ -324,6 +372,11 @@ export const compile = (app: Application) => {
324
372
  template_key: generator.templateKey,
325
373
  title: generator.title,
326
374
  description: generator.description,
375
+ local_sync: generator.localSyncRunMode
376
+ ? {
377
+ run_mode: generator.localSyncRunMode,
378
+ }
379
+ : undefined,
327
380
  property: compileProperty(generator.property || {}),
328
381
  event_map: compileEvents(generator.templateKey, generator.events || {}),
329
382
  outlet: compileOutlets(generator.templateKey, generator.outlets || {}),
@@ -349,10 +402,19 @@ export const compile = (app: Application) => {
349
402
  map[data.id] = {
350
403
  title: data.title,
351
404
  description: data.description,
405
+ linked: data.metadata?.linked,
406
+ linkedFrom: data.metadata?.linkedFrom,
407
+ local_sync: data.localSyncUpdateMode
408
+ ? {
409
+ update_mode: data.localSyncUpdateMode,
410
+ }
411
+ : undefined,
352
412
  persist_data: data.persistData,
413
+ ...compileRemoteUpdate(data.remoteUpdate),
353
414
  routing: data.routing,
354
415
  schema: data.schema,
355
416
  type: data.type,
417
+ ...compileKind(data.kind),
356
418
  value: data.value,
357
419
  event_map: compileEvents('PROPERTY_BANK', data.events || {}),
358
420
  }
@@ -369,14 +431,27 @@ export const compile = (app: Application) => {
369
431
 
370
432
  const generateInputPorts = (inputs, outputs) =>
371
433
  inputs.reduce((acc, port) => {
372
- if (!port.source().id) return acc
434
+ if (!acc[port.key]) acc[port.key] = null
373
435
 
374
- const firstOutput = outputs[0]
375
- let disableTriggerCommandIn = firstOutput?.target().id
436
+ let sourceId
437
+ let sourceNode = port.source()
438
+ if (sourceNode?.__typename === 'DataCalculationData')
439
+ sourceId = (sourceNode as DataCalculationData).data().id
440
+ if (sourceNode?.__typename === 'DataCommand') sourceId = sourceNode.id
376
441
 
442
+ if (!sourceId) return acc
377
443
  if (!acc[port.key]) acc[port.key] = []
444
+
445
+ const firstOutput = outputs[0]
446
+ let disableTriggerCommandIn
447
+ let firstOutputTargetNode = firstOutput?.target()
448
+ if (!port.trigger && firstOutputTargetNode?.__typename === 'DataCalculationData')
449
+ disableTriggerCommandIn = (firstOutputTargetNode as DataCalculationData).data().id
450
+ if (!port.trigger && firstOutputTargetNode?.__typename === 'DataCommand')
451
+ disableTriggerCommandIn = firstOutputTargetNode.id
452
+
378
453
  acc[port.key].push({
379
- id: port.source().id,
454
+ id: sourceId,
380
455
  port: port.sourceKey,
381
456
  disable_trigger_command_in: disableTriggerCommandIn,
382
457
  })
@@ -385,18 +460,26 @@ export const compile = (app: Application) => {
385
460
 
386
461
  const generateOutputPorts = (outputs) =>
387
462
  outputs.reduce((acc, port) => {
388
- if (!port.target().id) return acc
463
+ if (!acc[port.key]) acc[port.key] = null
389
464
 
465
+ let targetId
466
+ let targetNode = port.target()
467
+ if (targetNode?.__typename === 'DataCalculationData')
468
+ targetId = (targetNode as DataCalculationData).data().id
469
+ if (targetNode?.__typename === 'DataCommand') targetId = targetNode.id
470
+
471
+ if (!targetId) return acc
390
472
  if (!acc[port.key]) acc[port.key] = []
473
+
391
474
  acc[port.key].push({
392
- id: port.target().id,
475
+ id: targetId,
393
476
  port: port.targetKey,
394
477
  })
395
478
  return acc
396
479
  }, {})
397
480
 
398
481
  const getNodeId = (node) => {
399
- if (node.__typename === 'DataCalculationData') return node.data.id
482
+ if (node.__typename === 'DataCalculationData') return node.data().id
400
483
  if (node.__typename === 'DataCommand') return node.id
401
484
  throw new Error(`Invalid node: ${JSON.stringify(node)}`)
402
485
  }
@@ -463,15 +546,20 @@ export const compile = (app: Application) => {
463
546
  const scriptCalc = dataCalc as DataCalculationScript
464
547
  calc.type = 'script'
465
548
 
466
- const program = parseAST(scriptCalc.code, { sourceType: 'module', ecmaVersion: 2020 })
467
- // export function main() { ... }
468
- const declarationBody = (
469
- (program.body[0] as ExportNamedDeclaration).declaration as FunctionDeclaration
470
- )?.body
471
-
549
+ let code: string
550
+ try {
551
+ const program = parseAST(scriptCalc.code, { sourceType: 'module', ecmaVersion: 2020 })
552
+ // export function main() { ... }
553
+ const declarationBody = (
554
+ (program.body[0] as ExportNamedDeclaration).declaration as FunctionDeclaration
555
+ )?.body
556
+ code = escodegen.generate(declarationBody)
557
+ } catch (e) {
558
+ code = scriptCalc.code || ''
559
+ }
472
560
  calc.script_config = {
473
561
  note: scriptCalc.note,
474
- code: escodegen.generate(declarationBody),
562
+ code,
475
563
  enable_async: scriptCalc.enableAsync,
476
564
  inputs: scriptCalc.inputs.reduce((acc, input) => {
477
565
  acc[input.data().id] = input.key
@@ -502,12 +590,18 @@ export const compile = (app: Application) => {
502
590
  }, {}),
503
591
  action_map: subspace.actions || {},
504
592
  event_map: compileEvents('', subspace.events || {}),
593
+ routing: subspace.dataRouting.reduce((acc, data) => {
594
+ acc[data.id] = { enabled_routing: true }
595
+ return acc
596
+ }, {}),
597
+ ...compileModule(subspace),
505
598
  }
506
599
  return subspaceMap
507
600
  }, {}),
508
601
  root_subspace_id: app.rootSubspace.id,
509
602
  fonts: app.fonts,
510
603
  ...compileApplicationSettings(app.settings),
604
+ test_map: app.metadata?.TEMP_test_map || {},
511
605
  }
512
606
  return config
513
607
  }
package/index.ts CHANGED
@@ -1,6 +1,6 @@
1
- export * from './types'
1
+ export type * from './types'
2
2
 
3
- import { DataLink, Data } from './types'
3
+ import type { DataLink, Data } from './types'
4
4
 
5
5
  export { makeId } from './uuid'
6
6
 
package/package.json CHANGED
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "name": "@fugood/bricks-project",
3
- "version": "2.21.0-beta.14.test2",
3
+ "version": "2.21.0-beta.14.test4",
4
4
  "main": "index.ts",
5
5
  "scripts": {
6
6
  "build": "node scripts/build.js"
7
7
  },
8
8
  "dependencies": {
9
+ "@types/escodegen": "^0.0.10",
10
+ "@types/lodash": "^4.17.12",
9
11
  "acorn": "^8.13.0",
10
12
  "escodegen": "^2.1.0",
11
13
  "lodash": "^4.17.4",
package/types/canvas.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { Easing } from './animation'
2
- import { Data, DataLink } from './data'
3
- import { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from './switch'
4
- import { Brick, SubspaceID, EventAction } from './common'
1
+ import type { Easing } from './animation'
2
+ import type { Data, DataLink } from './data'
3
+ import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from './switch'
4
+ import type { Brick, SubspaceID, EventAction } from './common'
5
5
 
6
6
  type StandbyEasing = {
7
7
  method: Easing
package/types/common.ts CHANGED
@@ -113,4 +113,7 @@ export type Application = {
113
113
  rootSubspace: Subspace
114
114
  fonts?: ApplicationFont[]
115
115
  settings?: ApplicationSettings
116
- }
116
+ metadata?: {
117
+ [key: string]: any
118
+ }
119
+ }
@@ -1,4 +1,4 @@
1
- import { Data } from './data'
1
+ import type { Data } from './data'
2
2
 
3
3
  export interface DataCalculation {
4
4
  __typename: string
@@ -950,6 +950,7 @@ export type DataCommandObjectMapKeys = DataCommand & {
950
950
  }
951
951
  | {
952
952
  // Default value: undefined
953
+ // Iteratee Callback Input: true
953
954
  key: 'iteratee_result_key'
954
955
  source: (() => DataCalculationData | DataCommand) | any
955
956
  sourceKey: string
@@ -958,6 +959,7 @@ export type DataCommandObjectMapKeys = DataCommand & {
958
959
  >
959
960
  outputs?: Array<
960
961
  | {
962
+ // Iteratee Callback: true
961
963
  key: 'iteratee_input'
962
964
  // target type: object
963
965
  target: () => DataCalculationData | DataCommand
@@ -997,6 +999,7 @@ export type DataCommandObjectMapValues = DataCommand & {
997
999
  }
998
1000
  | {
999
1001
  // Default value: undefined
1002
+ // Iteratee Callback Input: true
1000
1003
  key: 'iteratee_result_key'
1001
1004
  source: (() => DataCalculationData | DataCommand) | any
1002
1005
  sourceKey: string
@@ -1005,6 +1008,7 @@ export type DataCommandObjectMapValues = DataCommand & {
1005
1008
  >
1006
1009
  outputs?: Array<
1007
1010
  | {
1011
+ // Iteratee Callback: true
1008
1012
  key: 'iteratee_input'
1009
1013
  // target type: object
1010
1014
  target: () => DataCalculationData | DataCommand
@@ -1220,6 +1224,7 @@ export type DataCommandCollectionCount = DataCommand & {
1220
1224
  }
1221
1225
  | {
1222
1226
  // Default value: undefined
1227
+ // Iteratee Callback Input: true
1223
1228
  key: 'iteratee_result_group'
1224
1229
  source: (() => DataCalculationData | DataCommand) | string
1225
1230
  sourceKey: string
@@ -1228,6 +1233,7 @@ export type DataCommandCollectionCount = DataCommand & {
1228
1233
  >
1229
1234
  outputs?: Array<
1230
1235
  | {
1236
+ // Iteratee Callback: true
1231
1237
  key: 'iteratee_input'
1232
1238
  // target type: object
1233
1239
  target: () => DataCalculationData | DataCommand
@@ -1334,6 +1340,7 @@ export type DataCommandCollectionEvery = DataCommand & {
1334
1340
  }
1335
1341
  | {
1336
1342
  // Default value: undefined
1343
+ // Iteratee Callback Input: true
1337
1344
  key: 'iteratee_result_valid'
1338
1345
  source: (() => DataCalculationData | DataCommand) | boolean
1339
1346
  sourceKey: string
@@ -1342,6 +1349,7 @@ export type DataCommandCollectionEvery = DataCommand & {
1342
1349
  >
1343
1350
  outputs?: Array<
1344
1351
  | {
1352
+ // Iteratee Callback: true
1345
1353
  key: 'iteratee_input'
1346
1354
  // target type: object
1347
1355
  target: () => DataCalculationData | DataCommand
@@ -1425,6 +1433,7 @@ export type DataCommandCollectionFilter = DataCommand & {
1425
1433
  }
1426
1434
  | {
1427
1435
  // Default value: undefined
1436
+ // Iteratee Callback Input: true
1428
1437
  key: 'iteratee_result_valid'
1429
1438
  source: (() => DataCalculationData | DataCommand) | boolean
1430
1439
  sourceKey: string
@@ -1433,6 +1442,7 @@ export type DataCommandCollectionFilter = DataCommand & {
1433
1442
  >
1434
1443
  outputs?: Array<
1435
1444
  | {
1445
+ // Iteratee Callback: true
1436
1446
  key: 'iteratee_input'
1437
1447
  // target type: object
1438
1448
  target: () => DataCalculationData | DataCommand
@@ -1472,6 +1482,7 @@ export type DataCommandCollectionFind = DataCommand & {
1472
1482
  }
1473
1483
  | {
1474
1484
  // Default value: undefined
1485
+ // Iteratee Callback Input: true
1475
1486
  key: 'iteratee_result_valid'
1476
1487
  source: (() => DataCalculationData | DataCommand) | boolean
1477
1488
  sourceKey: string
@@ -1487,6 +1498,7 @@ export type DataCommandCollectionFind = DataCommand & {
1487
1498
  >
1488
1499
  outputs?: Array<
1489
1500
  | {
1501
+ // Iteratee Callback: true
1490
1502
  key: 'iteratee_input'
1491
1503
  // target type: object
1492
1504
  target: () => DataCalculationData | DataCommand
@@ -1526,6 +1538,7 @@ export type DataCommandCollectionFindKey = DataCommand & {
1526
1538
  }
1527
1539
  | {
1528
1540
  // Default value: undefined
1541
+ // Iteratee Callback Input: true
1529
1542
  key: 'iteratee_result_valid'
1530
1543
  source: (() => DataCalculationData | DataCommand) | boolean
1531
1544
  sourceKey: string
@@ -1541,6 +1554,7 @@ export type DataCommandCollectionFindKey = DataCommand & {
1541
1554
  >
1542
1555
  outputs?: Array<
1543
1556
  | {
1557
+ // Iteratee Callback: true
1544
1558
  key: 'iteratee_input'
1545
1559
  // target type: object
1546
1560
  target: () => DataCalculationData | DataCommand
@@ -1631,6 +1645,7 @@ export type DataCommandCollectionGroupBy = DataCommand & {
1631
1645
  }
1632
1646
  | {
1633
1647
  // Default value: undefined
1648
+ // Iteratee Callback Input: true
1634
1649
  key: 'iteratee_result_group'
1635
1650
  source: (() => DataCalculationData | DataCommand) | string
1636
1651
  sourceKey: string
@@ -1639,6 +1654,7 @@ export type DataCommandCollectionGroupBy = DataCommand & {
1639
1654
  >
1640
1655
  outputs?: Array<
1641
1656
  | {
1657
+ // Iteratee Callback: true
1642
1658
  key: 'iteratee_input'
1643
1659
  // target type: object
1644
1660
  target: () => DataCalculationData | DataCommand
@@ -1715,6 +1731,7 @@ export type DataCommandCollectionIntersection = DataCommand & {
1715
1731
  }
1716
1732
  | {
1717
1733
  // Default value: undefined
1734
+ // Iteratee Callback Input: true
1718
1735
  key: 'iteratee_result_value'
1719
1736
  source: (() => DataCalculationData | DataCommand) | any
1720
1737
  sourceKey: string
@@ -1723,6 +1740,7 @@ export type DataCommandCollectionIntersection = DataCommand & {
1723
1740
  >
1724
1741
  outputs?: Array<
1725
1742
  | {
1743
+ // Iteratee Callback: true
1726
1744
  key: 'iteratee_input'
1727
1745
  // target type: object
1728
1746
  target: () => DataCalculationData | DataCommand
@@ -1762,6 +1780,7 @@ export type DataCommandCollectionKeyBy = DataCommand & {
1762
1780
  }
1763
1781
  | {
1764
1782
  // Default value: undefined
1783
+ // Iteratee Callback Input: true
1765
1784
  key: 'iteratee_result_key'
1766
1785
  source: (() => DataCalculationData | DataCommand) | string
1767
1786
  sourceKey: string
@@ -1770,6 +1789,7 @@ export type DataCommandCollectionKeyBy = DataCommand & {
1770
1789
  >
1771
1790
  outputs?: Array<
1772
1791
  | {
1792
+ // Iteratee Callback: true
1773
1793
  key: 'iteratee_input'
1774
1794
  // target type: object
1775
1795
  target: () => DataCalculationData | DataCommand
@@ -1830,6 +1850,7 @@ export type DataCommandCollectionMap = DataCommand & {
1830
1850
  }
1831
1851
  | {
1832
1852
  // Default value: undefined
1853
+ // Iteratee Callback Input: true
1833
1854
  key: 'iteratee_result_value'
1834
1855
  source: (() => DataCalculationData | DataCommand) | any
1835
1856
  sourceKey: string
@@ -1838,6 +1859,7 @@ export type DataCommandCollectionMap = DataCommand & {
1838
1859
  >
1839
1860
  outputs?: Array<
1840
1861
  | {
1862
+ // Iteratee Callback: true
1841
1863
  key: 'iteratee_input'
1842
1864
  // target type: object
1843
1865
  target: () => DataCalculationData | DataCommand
@@ -1957,6 +1979,7 @@ export type DataCommandCollectionReduce = DataCommand & {
1957
1979
  }
1958
1980
  | {
1959
1981
  // Default value: undefined
1982
+ // Iteratee Callback Input: true
1960
1983
  key: 'iteratee_result'
1961
1984
  source: (() => DataCalculationData | DataCommand) | any
1962
1985
  sourceKey: string
@@ -1965,6 +1988,7 @@ export type DataCommandCollectionReduce = DataCommand & {
1965
1988
  >
1966
1989
  outputs?: Array<
1967
1990
  | {
1991
+ // Iteratee Callback: true
1968
1992
  key: 'iteratee_input'
1969
1993
  // target type: object
1970
1994
  target: () => DataCalculationData | DataCommand
@@ -2134,6 +2158,7 @@ export type DataCommandCollectionSome = DataCommand & {
2134
2158
  }
2135
2159
  | {
2136
2160
  // Default value: undefined
2161
+ // Iteratee Callback Input: true
2137
2162
  key: 'iteratee_result_valid'
2138
2163
  source: (() => DataCalculationData | DataCommand) | boolean
2139
2164
  sourceKey: string
@@ -2142,6 +2167,7 @@ export type DataCommandCollectionSome = DataCommand & {
2142
2167
  >
2143
2168
  outputs?: Array<
2144
2169
  | {
2170
+ // Iteratee Callback: true
2145
2171
  key: 'iteratee_input'
2146
2172
  // target type: object
2147
2173
  target: () => DataCalculationData | DataCommand
@@ -2181,6 +2207,7 @@ export type DataCommandCollectionSort = DataCommand & {
2181
2207
  }
2182
2208
  | {
2183
2209
  // Default value: undefined
2210
+ // Iteratee Callback Input: true
2184
2211
  key: 'iteratee_result_value'
2185
2212
  source: (() => DataCalculationData | DataCommand) | any
2186
2213
  sourceKey: string
@@ -2189,6 +2216,7 @@ export type DataCommandCollectionSort = DataCommand & {
2189
2216
  >
2190
2217
  outputs?: Array<
2191
2218
  | {
2219
+ // Iteratee Callback: true
2192
2220
  key: 'iteratee_input'
2193
2221
  // target type: object
2194
2222
  target: () => DataCalculationData | DataCommand
@@ -2265,6 +2293,7 @@ export type DataCommandCollectionUnion = DataCommand & {
2265
2293
  }
2266
2294
  | {
2267
2295
  // Default value: undefined
2296
+ // Iteratee Callback Input: true
2268
2297
  key: 'iteratee_result_value'
2269
2298
  source: (() => DataCalculationData | DataCommand) | any
2270
2299
  sourceKey: string
@@ -2273,6 +2302,7 @@ export type DataCommandCollectionUnion = DataCommand & {
2273
2302
  >
2274
2303
  outputs?: Array<
2275
2304
  | {
2305
+ // Iteratee Callback: true
2276
2306
  key: 'iteratee_input'
2277
2307
  // target type: object
2278
2308
  target: () => DataCalculationData | DataCommand
@@ -3467,6 +3497,7 @@ export type DataCommandStringReplace = DataCommand & {
3467
3497
  }
3468
3498
  | {
3469
3499
  // Default value: undefined
3500
+ // Invocation Callback Input: true
3470
3501
  key: 'invocation_result'
3471
3502
  source: (() => DataCalculationData | DataCommand) | string
3472
3503
  sourceKey: string
@@ -3489,6 +3520,7 @@ export type DataCommandStringReplace = DataCommand & {
3489
3520
  >
3490
3521
  outputs?: Array<
3491
3522
  | {
3523
+ // Invocation Callback: true
3492
3524
  key: 'invocation_input'
3493
3525
  // target type: object
3494
3526
  target: () => DataCalculationData | DataCommand
package/types/data.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { EventAction } from './common'
1
+ import type { SubspaceID, EventAction, LocalSyncStrategy } from './common'
2
2
 
3
3
  interface DataDef {
4
4
  events?: {
@@ -15,15 +15,55 @@ interface DataDef {
15
15
 
16
16
  export type Data<T = any> = DataDef & {
17
17
  __typename: 'Data'
18
- type: 'string' | 'number' | 'bool' | 'array' | 'object' | 'any'
19
18
  id: string
20
19
  title: string
21
20
  description?: string
21
+ metadata?: {
22
+ linked?: Array<SubspaceID>
23
+ linkedFrom?: SubspaceID
24
+ [key: string]: any
25
+ }
26
+ remoteUpdate?: { type: 'auto' | 'device-specific' } | { type: 'global-data'; id: string }
22
27
  // Determine how the property is changed via another subspaces.
23
28
  routing?: 'default' | 'read-only'
24
29
  // Persist data, so that the data will be keep after refresh.
25
30
  persistData?: boolean
26
- schema: object
31
+ localSyncUpdateMode?: LocalSyncStrategy
32
+ type: 'string' | 'number' | 'bool' | 'array' | 'object' | 'any'
33
+ schema?: object
34
+ kind?:
35
+ | {
36
+ type: 'id'
37
+ idType?: 'brick' | 'generator' | 'canvas' | 'animation'
38
+ }
39
+ | {
40
+ type: 'auto-generated-item-id'
41
+ idType?: 'canvas'
42
+ }
43
+ | {
44
+ type: 'unit'
45
+ unit?: 'ms' | 'grid' | 'px'
46
+ max?: number
47
+ min?: number
48
+ step?: number
49
+ }
50
+ | {
51
+ type:
52
+ | 'color'
53
+ | 'datetime'
54
+ | 'graphql'
55
+ | 'rich-text-content'
56
+ | 'sandbox-script'
57
+ | 'llm-prompt'
58
+ | 'media-resource-image'
59
+ | 'media-resource-video'
60
+ | 'media-resource-audio'
61
+ | 'media-resource-file'
62
+ | 'lottie-file-uri'
63
+ | 'ggml-model-asset'
64
+ | 'gguf-model-asset'
65
+ | 'binary-asset'
66
+ }
27
67
  value: T
28
68
  }
29
69
 
@@ -1,6 +1,12 @@
1
- import { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from './switch'
2
- import { Data, DataLink } from './data'
3
- import { Generator, EventAction, ActionWithDataParams, ActionWithParams, Action } from './common'
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
+ } from './common'
4
10
 
5
11
  /* Start the tick */
6
12
  export type GeneratorTickAction_ = Action & {
package/types/subspace.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Brick, Generator, LocalSyncStrategy, EventAction } from './common'
1
+ import { Brick, Generator, LocalSyncStrategy, EventAction, SubspaceID } from './common'
2
2
  import { Animation } from './animation'
3
3
  import { Canvas } from './canvas'
4
4
  import { Data } from './data'
@@ -10,6 +10,21 @@ export type Subspace = {
10
10
  title: string
11
11
  description?: string
12
12
  localSyncChangeCanvas?: LocalSyncStrategy
13
+ module?: {
14
+ id: string
15
+ version: string
16
+ selectedRequirements?: Array<{
17
+ subspace: SubspaceID
18
+ id: string
19
+ version: string
20
+ }>
21
+ // Module only
22
+ requirements?: Array<{
23
+ subspace: SubspaceID
24
+ id: string
25
+ version: string
26
+ }>
27
+ }
13
28
  layout: {
14
29
  width: number
15
30
  height: number
@@ -21,6 +36,7 @@ export type Subspace = {
21
36
  bricks: Array<Brick>
22
37
  generators: Array<Generator>
23
38
  data: Array<Data>
39
+ dataRouting: Array<Data>
24
40
  dataCalculation: Array<DataCalculation>
25
41
  actions?: {
26
42
  [key: string]: {
@@ -30,4 +46,3 @@ export type Subspace = {
30
46
  }
31
47
  events?: { [key: string]: Array<EventAction> }
32
48
  }
33
-
package/types/system.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { Action, ActionWithDataParams, ActionWithParams, Brick, Generator } from './common'
2
- import { Canvas } from './canvas'
3
- import { Data, DataLink } from './data'
1
+ import type { Action, ActionWithDataParams, ActionWithParams, Brick, Generator } from './common'
2
+ import type { Animation } from './animation'
3
+ import type { Canvas } from './canvas'
4
+ import type { Data, DataLink } from './data'
4
5
 
5
6
  /* Change Data value */
6
7
  export type SystemActionPropertyBank = ActionWithDataParams & {