@fugood/bricks-ctor 2.24.0-beta.40

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.
Files changed (129) hide show
  1. package/compile/action-name-map.ts +988 -0
  2. package/compile/index.ts +1245 -0
  3. package/compile/util.ts +358 -0
  4. package/index.ts +6 -0
  5. package/package.json +28 -0
  6. package/skills/bricks-design/LICENSE.txt +180 -0
  7. package/skills/bricks-design/SKILL.md +66 -0
  8. package/skills/bricks-project/SKILL.md +32 -0
  9. package/skills/bricks-project/rules/animation.md +159 -0
  10. package/skills/bricks-project/rules/architecture-patterns.md +69 -0
  11. package/skills/bricks-project/rules/automations.md +221 -0
  12. package/skills/bricks-project/rules/buttress.md +156 -0
  13. package/skills/bricks-project/rules/data-calculation.md +208 -0
  14. package/skills/bricks-project/rules/local-sync.md +129 -0
  15. package/skills/bricks-project/rules/media-flow.md +158 -0
  16. package/skills/bricks-project/rules/remote-data-bank.md +196 -0
  17. package/skills/bricks-project/rules/standby-transition.md +124 -0
  18. package/skills/rive-marketplace/SKILL.md +99 -0
  19. package/tools/deploy.ts +151 -0
  20. package/tools/icons/.gitattributes +1 -0
  21. package/tools/icons/fa6pro-glyphmap.json +4686 -0
  22. package/tools/icons/fa6pro-meta.json +3671 -0
  23. package/tools/mcp-server.ts +28 -0
  24. package/tools/mcp-tools/compile.ts +91 -0
  25. package/tools/mcp-tools/huggingface.ts +762 -0
  26. package/tools/mcp-tools/icons.ts +70 -0
  27. package/tools/mcp-tools/lottie.ts +102 -0
  28. package/tools/mcp-tools/media.ts +110 -0
  29. package/tools/postinstall.ts +229 -0
  30. package/tools/preview-main.mjs +293 -0
  31. package/tools/preview.ts +143 -0
  32. package/tools/pull.ts +116 -0
  33. package/tsconfig.json +16 -0
  34. package/types/animation.ts +100 -0
  35. package/types/automation.ts +235 -0
  36. package/types/brick-base.ts +80 -0
  37. package/types/bricks/Camera.ts +246 -0
  38. package/types/bricks/Chart.ts +372 -0
  39. package/types/bricks/GenerativeMedia.ts +276 -0
  40. package/types/bricks/Icon.ts +98 -0
  41. package/types/bricks/Image.ts +114 -0
  42. package/types/bricks/Items.ts +476 -0
  43. package/types/bricks/Lottie.ts +168 -0
  44. package/types/bricks/Maps.ts +262 -0
  45. package/types/bricks/QrCode.ts +117 -0
  46. package/types/bricks/Rect.ts +150 -0
  47. package/types/bricks/RichText.ts +128 -0
  48. package/types/bricks/Rive.ts +220 -0
  49. package/types/bricks/Slideshow.ts +201 -0
  50. package/types/bricks/Svg.ts +99 -0
  51. package/types/bricks/Text.ts +148 -0
  52. package/types/bricks/TextInput.ts +242 -0
  53. package/types/bricks/Video.ts +175 -0
  54. package/types/bricks/VideoStreaming.ts +112 -0
  55. package/types/bricks/WebRtcStream.ts +65 -0
  56. package/types/bricks/WebView.ts +168 -0
  57. package/types/bricks/index.ts +21 -0
  58. package/types/canvas.ts +82 -0
  59. package/types/common.ts +144 -0
  60. package/types/data-calc-command.ts +7005 -0
  61. package/types/data-calc-script.ts +21 -0
  62. package/types/data-calc.ts +11 -0
  63. package/types/data.ts +95 -0
  64. package/types/generators/AlarmClock.ts +110 -0
  65. package/types/generators/Assistant.ts +621 -0
  66. package/types/generators/BleCentral.ts +247 -0
  67. package/types/generators/BlePeripheral.ts +208 -0
  68. package/types/generators/CanvasMap.ts +74 -0
  69. package/types/generators/CastlesPay.ts +87 -0
  70. package/types/generators/DataBank.ts +160 -0
  71. package/types/generators/File.ts +432 -0
  72. package/types/generators/GraphQl.ts +132 -0
  73. package/types/generators/Http.ts +222 -0
  74. package/types/generators/HttpServer.ts +176 -0
  75. package/types/generators/Information.ts +103 -0
  76. package/types/generators/Intent.ts +168 -0
  77. package/types/generators/Iterator.ts +108 -0
  78. package/types/generators/Keyboard.ts +105 -0
  79. package/types/generators/LlmAnthropicCompat.ts +212 -0
  80. package/types/generators/LlmAppleBuiltin.ts +159 -0
  81. package/types/generators/LlmGgml.ts +861 -0
  82. package/types/generators/LlmMediaTekNeuroPilot.ts +235 -0
  83. package/types/generators/LlmMlx.ts +227 -0
  84. package/types/generators/LlmOnnx.ts +213 -0
  85. package/types/generators/LlmOpenAiCompat.ts +244 -0
  86. package/types/generators/LlmQualcommAiEngine.ts +247 -0
  87. package/types/generators/Mcp.ts +637 -0
  88. package/types/generators/McpServer.ts +289 -0
  89. package/types/generators/MediaFlow.ts +170 -0
  90. package/types/generators/MqttBroker.ts +141 -0
  91. package/types/generators/MqttClient.ts +141 -0
  92. package/types/generators/Question.ts +408 -0
  93. package/types/generators/RealtimeTranscription.ts +279 -0
  94. package/types/generators/RerankerGgml.ts +191 -0
  95. package/types/generators/SerialPort.ts +151 -0
  96. package/types/generators/SoundPlayer.ts +94 -0
  97. package/types/generators/SoundRecorder.ts +130 -0
  98. package/types/generators/SpeechToTextGgml.ts +415 -0
  99. package/types/generators/SpeechToTextOnnx.ts +236 -0
  100. package/types/generators/SpeechToTextPlatform.ts +85 -0
  101. package/types/generators/SqLite.ts +159 -0
  102. package/types/generators/Step.ts +107 -0
  103. package/types/generators/SttAppleBuiltin.ts +130 -0
  104. package/types/generators/Tcp.ts +126 -0
  105. package/types/generators/TcpServer.ts +147 -0
  106. package/types/generators/TextToSpeechAppleBuiltin.ts +127 -0
  107. package/types/generators/TextToSpeechGgml.ts +221 -0
  108. package/types/generators/TextToSpeechOnnx.ts +178 -0
  109. package/types/generators/TextToSpeechOpenAiLike.ts +121 -0
  110. package/types/generators/ThermalPrinter.ts +191 -0
  111. package/types/generators/Tick.ts +83 -0
  112. package/types/generators/Udp.ts +120 -0
  113. package/types/generators/VadGgml.ts +250 -0
  114. package/types/generators/VadOnnx.ts +231 -0
  115. package/types/generators/VadTraditional.ts +138 -0
  116. package/types/generators/VectorStore.ts +257 -0
  117. package/types/generators/Watchdog.ts +107 -0
  118. package/types/generators/WebCrawler.ts +103 -0
  119. package/types/generators/WebRtc.ts +181 -0
  120. package/types/generators/WebSocket.ts +148 -0
  121. package/types/generators/index.ts +57 -0
  122. package/types/index.ts +13 -0
  123. package/types/subspace.ts +59 -0
  124. package/types/switch.ts +51 -0
  125. package/types/system.ts +707 -0
  126. package/utils/calc.ts +126 -0
  127. package/utils/data.ts +497 -0
  128. package/utils/event-props.ts +836 -0
  129. package/utils/id.ts +80 -0
@@ -0,0 +1,208 @@
1
+ # Data Calculation (JS Sandbox)
2
+
3
+ Transform and compute Data Bank values using JavaScript scripts.
4
+
5
+ ## DataCalculationScript
6
+
7
+ JavaScript code executed in a sandbox with access to inputs and outputs.
8
+
9
+ ```typescript
10
+ import { makeId } from 'bricks-ctor'
11
+
12
+ const calculation: DataCalculationScript = {
13
+ __typename: 'DataCalculationScript',
14
+ id: makeId('property_bank_calc'),
15
+ title: 'Format Price',
16
+ description: 'Formats price with currency symbol',
17
+ note: '',
18
+ triggerMode: 'auto', // 'auto' | 'manual'
19
+ enableAsync: false,
20
+ // Inline code
21
+ code: `
22
+ const price = inputs.price || 0
23
+ const currency = inputs.currency || 'USD'
24
+ return new Intl.NumberFormat('en-US', {
25
+ style: 'currency',
26
+ currency,
27
+ }).format(price)
28
+ `,
29
+ // Or load from file (preferred for longer scripts)
30
+ // code: await Bun.file(`${import.meta.dir}/format-price.sandbox.js`).text(),
31
+ inputs: [
32
+ { key: 'price', data: () => priceData, trigger: true },
33
+ { key: 'currency', data: () => currencyData, trigger: false },
34
+ ],
35
+ output: () => formattedPriceData,
36
+ outputs: [], // Additional named outputs
37
+ error: null, // or () => errorData for error handling
38
+ }
39
+ ```
40
+
41
+ ## Trigger Modes
42
+
43
+ | Mode | Description |
44
+ |------|-------------|
45
+ | `auto` | Run when input values change (with trigger: true) |
46
+ | `manual` | Only run via `PROPERTY_BANK_COMMAND` action |
47
+
48
+ Use `manual` to prevent circular dependencies or for explicit control.
49
+
50
+ ## Script Sandbox Features
51
+
52
+ Scripts run in `use strict` mode with a sandboxed set of globals and libraries.
53
+
54
+ ### Built-in Globals
55
+
56
+ | Global | Description |
57
+ |--------|-------------|
58
+ | `inputs` | Object with input values |
59
+ | `console` | `{ log, error, warn, info }` for debugging |
60
+ | `Platform` | `{ OS, isTV, isPad, isVision, isElectron }` |
61
+ | `TextEncoder`, `TextDecoder` | Text encoding/decoding |
62
+ | `Buffer` | Node.js Buffer (without `allocUnsafe`) |
63
+ | `btoa`, `atob` | Base64 encoding/decoding |
64
+
65
+ ### Available Libraries
66
+
67
+ **Utility**
68
+ | Library | Global | Description |
69
+ |---------|--------|-------------|
70
+ | [lodash](https://lodash.com) | `_`, `lodash` | Utility (sync: no debounce/delay/defer) |
71
+ | [voca](https://vocajs.com) | `voca` | String manipulation |
72
+ | [invariant](https://github.com/zertosh/invariant) | `invariant` | Assertions |
73
+
74
+ **Data & Encoding**
75
+ | Library | Global | Description |
76
+ |---------|--------|-------------|
77
+ | [json5](https://github.com/json5/json5) | `json5` | JSON5 parsing |
78
+ | [qs](https://github.com/ljharb/qs) | `qs` | Query string parsing |
79
+ | [url](https://github.com/defunctzombie/node-url) | `url` | URL parsing |
80
+ | [bytes](https://github.com/visionmedia/bytes.js) | `bytes` | Byte parsing/formatting |
81
+ | [ms](https://github.com/vercel/ms) | `ms` | Millisecond conversion |
82
+ | [base45](https://github.com/irony/base45) | `base45` | Base45 encoding |
83
+ | [iconv-lite](https://github.com/ashtuchkin/iconv-lite) | `iconv` | Character encoding |
84
+
85
+ **Math & Color**
86
+ | Library | Global | Description |
87
+ |---------|--------|-------------|
88
+ | [mathjs](https://mathjs.org) | `math`, `mathjs` | Math library |
89
+ | [chroma-js](https://gka.github.io/chroma.js) | `chroma` | Color manipulation |
90
+
91
+ **Date/Time**
92
+ | Library | Global | Description |
93
+ |---------|--------|-------------|
94
+ | [moment](https://momentjs.com) | `moment` | Date/time (auto parseFormat) |
95
+
96
+ **ID & Hash**
97
+ | Library | Global | Description |
98
+ |---------|--------|-------------|
99
+ | [nanoid](https://github.com/ai/nanoid) | `nanoid` | Unique ID generation |
100
+ | [md5](https://github.com/pvorb/node-md5) | `md5` | MD5 hashing |
101
+
102
+ **Crypto**
103
+ | Library | Global | Description |
104
+ |---------|--------|-------------|
105
+ | [crypto-browserify](https://github.com/crypto-browserify/crypto-browserify) | `crypto` | Crypto functions |
106
+ | [jsrsasign](https://github.com/kjur/jsrsasign) | `kjurJWS` | JWT/JWS signing |
107
+ | [cose-js](https://github.com/erdtman/COSE-JS) | `coseVerify` | COSE verification (sync) |
108
+
109
+ **Compression**
110
+ | Library | Global | Description |
111
+ |---------|--------|-------------|
112
+ | [fflate](https://github.com/101arrowz/fflate) | `fflate` | `{ zlibSync, unzlibSync, gzipSync, gunzipSync, compressSync, decompressSync, strFromU8 }` |
113
+ | [cbor](https://github.com/hildjj/node-cbor) | `cbor` | `{ encode, decode, decodeFirstSync, decodeAllSync }` |
114
+
115
+ **File & Document**
116
+ | Library | Global | Description |
117
+ |---------|--------|-------------|
118
+ | fs | `fs` | File system (limited, no download/upload) |
119
+ | [officeparser](https://github.com/nicktang) | `parseDocument` | Office document parsing (async) |
120
+ | [turndown](https://github.com/mixmark-io/turndown) | `TurndownService` | HTML to Markdown |
121
+ | [opencc-js](https://github.com/nk2028/opencc-js) | `OpenCC` | Chinese conversion `{ Converter, ConverterFactory, CustomConverter, Locale }` |
122
+ | [toon-format](https://github.com/nicktang) | `TOON` | TOON format parsing |
123
+
124
+ ### Runtime Environment
125
+
126
+ | Platform | Engine |
127
+ |----------|--------|
128
+ | Android | Hermes engine sandbox |
129
+ | iOS | JavaScriptCore sandbox |
130
+
131
+ ### Async Mode
132
+
133
+ Enable `enableAsync: true` to unlock additional capabilities:
134
+
135
+ **Additional async globals:**
136
+ - `Promise`, `setTimeout`, `setInterval`, `setImmediate`
137
+ - `clearTimeout`, `clearInterval`, `clearImmediate`
138
+ - `requestAnimationFrame`
139
+ - Full lodash (including `debounce`, `delay`, `defer`)
140
+
141
+ ```typescript
142
+ code: `
143
+ const result = await new Promise((resolve) => {
144
+ setTimeout(() => resolve(inputs.value * 2), 100)
145
+ })
146
+ return result
147
+ `,
148
+ enableAsync: true,
149
+ ```
150
+
151
+ ### Multiple Outputs
152
+
153
+ ```typescript
154
+ outputs: [
155
+ { key: 'total', data: () => totalData },
156
+ { key: 'tax', data: () => taxData },
157
+ { key: 'subtotal', data: () => subtotalData },
158
+ ],
159
+ code: `
160
+ const subtotal = inputs.price * inputs.quantity
161
+ const tax = subtotal * 0.1
162
+ const total = subtotal + tax
163
+ return { total, tax, subtotal }
164
+ `,
165
+ ```
166
+
167
+ ## Triggering Manually
168
+
169
+ Use `PROPERTY_BANK_COMMAND` system action to trigger a manual calculation:
170
+
171
+ ```typescript
172
+ const triggerCalc: EventAction = {
173
+ handler: 'system',
174
+ action: {
175
+ __actionName: 'PROPERTY_BANK_COMMAND',
176
+ parent: 'System',
177
+ dataParams: [
178
+ { input: () => computeTotalCalc }, // Reference to DataCalculation
179
+ ],
180
+ },
181
+ }
182
+ ```
183
+
184
+ ## Best Practices
185
+
186
+ 1. **Avoid circular deps**: Set non-triggering inputs (`trigger: false`) or use `manual` mode
187
+ 2. **Error handling**: Always set `error` output for scripts that might fail
188
+ 3. **Keep scripts pure**: Avoid side effects, return computed values
189
+ 4. **Debounce rapid updates**: Use `manual` mode + timer for high-frequency inputs
190
+
191
+ ## Anti-Patterns (AVOID)
192
+
193
+ See [Architecture Patterns](architecture-patterns.md) for the full pattern selection guide.
194
+
195
+ ### Using Data Calc as an orchestrator
196
+ Scripts that manage state machines, control UI flow, or coordinate multi-step processes belong in Event Action Chains, not here.
197
+
198
+ **Symptom**: Script has if/else branches deciding "what happens next" or tracks "current step".
199
+
200
+ ### Quick reference
201
+
202
+ | If you need to... | Use instead |
203
+ |---|---|
204
+ | Call an LLM / AI model | Generator (Assistant, LLM, HTTP) |
205
+ | Sequence multiple actions | Event Action Chain |
206
+ | Set a data value directly | PROPERTY_BANK system action |
207
+ | Compute a simple expression | PROPERTY_BANK_EXPRESSION |
208
+ | Transform/format/parse data | Data Calculation (correct use) |
@@ -0,0 +1,129 @@
1
+ # Local Sync
2
+
3
+ Synchronize data between devices on a Local Area Network (LAN) without remote server storage. High synchronization rate for real-time multi-device experiences.
4
+
5
+ ## Features
6
+
7
+ - **Update Data**: Sync Data Bank values across local devices
8
+ - **Execute Data Calculation**: Trigger calculations on other devices
9
+ - **No Remote Storage**: Direct device-to-device communication
10
+
11
+ ## Main / Minor Device Model
12
+
13
+ | Role | Description |
14
+ |------|-------------|
15
+ | Main | Manages Data Bank if enabled, first device to start |
16
+ | Minor | Follows main device, subsequent devices |
17
+
18
+ ### Role Determination
19
+
20
+ 1. First device to start becomes Main
21
+ 2. If simultaneous start: `Priority as Main Device` (0-9, set in Device Page) + random number determines Main
22
+
23
+ ## Configuration
24
+
25
+ ### Run Mode Options
26
+
27
+ | Mode | Description |
28
+ |------|-------------|
29
+ | `all` | Run on all devices |
30
+ | `main-only` | Only run on Main device |
31
+ | `minor-only` | Only run on Minor devices |
32
+
33
+ Apply run mode to:
34
+ - Data properties
35
+ - Generators
36
+ - Data Calculations
37
+
38
+ ### Subspace Local Sync Settings
39
+
40
+ ```typescript
41
+ const subspace: Subspace = {
42
+ __typename: 'Subspace',
43
+ id: 'main',
44
+ localSyncChangeCanvas: 'all', // 'all' | 'main-only' | 'minor-only' | 'none'
45
+ // ...
46
+ }
47
+ ```
48
+
49
+ ### Data Local Sync
50
+
51
+ ```typescript
52
+ import { makeId } from 'bricks-ctor'
53
+
54
+ const data: Data = {
55
+ __typename: 'Data',
56
+ id: makeId('data'),
57
+ title: 'Shared Counter',
58
+ type: 'number',
59
+ value: 0,
60
+ localSyncUpdateMode: 'main-only', // 'main-only' | 'minor-only' | undefined (all)
61
+ events: {},
62
+ }
63
+ ```
64
+
65
+ ### Generator Local Sync
66
+
67
+ ```typescript
68
+ import { makeId } from 'bricks-ctor'
69
+
70
+ const generator: GeneratorTimer = {
71
+ __typename: 'Generator',
72
+ templateKey: 'Timer',
73
+ id: makeId('generator'),
74
+ title: 'Sync Timer',
75
+ description: '',
76
+ localSyncRunMode: 'main-only', // Timer only runs on main device
77
+ property: {},
78
+ events: {},
79
+ switches: [],
80
+ }
81
+ ```
82
+
83
+ ## Use Cases
84
+
85
+ ### Synchronized Displays
86
+ Multiple screens showing coordinated content:
87
+ - Main device controls timing/state
88
+ - Minor devices follow state changes
89
+
90
+ ### Interactive Kiosks
91
+ Touch on one device, update all:
92
+ - User interacts with input device (Minor)
93
+ - Main device processes and broadcasts result
94
+ - All devices update simultaneously
95
+
96
+ ### Video Walls
97
+ Coordinated multi-screen layouts:
98
+ - Main device manages playback state
99
+ - Minor devices sync position/frame
100
+
101
+ ## System Data
102
+
103
+ Access local sync status via System Data:
104
+
105
+ ```typescript
106
+ // Is current device the main device?
107
+ systemData.isLocalSyncMainDevice // boolean
108
+ ```
109
+
110
+ ## Important Notes
111
+
112
+ 1. **Version Matching**: All devices must use same BRICKS Foundation minor version
113
+ - ✅ v2.11.0 matches v2.11.1
114
+ - ❌ v2.11.0 does NOT match v2.10.8
115
+
116
+ 2. **Network Requirements**:
117
+ - All devices on same LAN
118
+ - mDNS/Bonjour enabled
119
+ - Firewall allows local discovery
120
+
121
+ 3. **Startup Order**: Consider device startup sequence when Main role matters
122
+
123
+ ## Best Practices
124
+
125
+ 1. **Designate Main explicitly**: Set high `Priority as Main Device` on intended main
126
+ 2. **Idempotent logic**: Design for eventual consistency, not strict ordering
127
+ 3. **Minimal sync scope**: Only enable local sync for data that truly needs it
128
+ 4. **Test multi-device**: Validate behavior with actual device count
129
+ 5. **Handle disconnection**: Design for graceful degradation if devices disconnect
@@ -0,0 +1,158 @@
1
+ # Media Flow
2
+
3
+ Centralized media asset management for BRICKS applications. Store, organize, and reference images, videos, and audio files.
4
+
5
+ ## Enable Media Workspace
6
+
7
+ 1. Visit `Media` tab in workspace page
8
+ 2. Enable media workspace for your workspace
9
+
10
+ ## Media Box
11
+
12
+ Organize assets into boxes (folders). Each box can contain files of various types.
13
+
14
+ ### Generator Media Flow
15
+
16
+ Use `Generator Media Flow` to:
17
+ - Get file list from a box
18
+ - Download files
19
+ - Subscribe to box changes
20
+
21
+ Quick setup: Create new Property with `As Media Resource file list?` option.
22
+
23
+ ```typescript
24
+ import { makeId } from 'bricks-ctor'
25
+
26
+ const mediaListGenerator: GeneratorMediaFlow = {
27
+ __typename: 'Generator',
28
+ templateKey: 'MediaFlow',
29
+ id: makeId('generator'),
30
+ title: 'Promo Images',
31
+ description: '',
32
+ property: {
33
+ boxId: 'promo-box-id',
34
+ },
35
+ outlets: {
36
+ files: () => promoFilesData, // Array of file objects
37
+ },
38
+ events: {},
39
+ switches: [],
40
+ }
41
+ ```
42
+
43
+ ## Property Kinds for Media
44
+
45
+ Link Data properties to Media Flow for asset selection:
46
+
47
+ | Kind | Description |
48
+ |------|-------------|
49
+ | `media-resource-image` | Image asset selector |
50
+ | `media-resource-video` | Video asset selector |
51
+ | `media-resource-audio` | Audio asset selector |
52
+ | `lottie-file-uri` | Lottie animation selector |
53
+
54
+ ```typescript
55
+ import { makeId } from 'bricks-ctor'
56
+
57
+ const backgroundImage: Data = {
58
+ __typename: 'Data',
59
+ id: makeId('data'),
60
+ title: 'Background Image',
61
+ type: 'string',
62
+ kind: { type: 'media-resource-image' },
63
+ value: '',
64
+ events: {},
65
+ }
66
+ ```
67
+
68
+ Assets with these kinds are **preloaded** during application launch.
69
+
70
+ ## Compatible Bricks & Generators
71
+
72
+ ### Bricks
73
+ - **Brick Image**: Display images from Media Flow
74
+ - **Brick Video**: Play videos from Media Flow
75
+ - **Brick Lottie**: Render Lottie animations
76
+ - **Brick Slideshow**: Cycle through Media Flow file list
77
+
78
+ ### Generators
79
+ - **Generator Sound Player**: Play audio files
80
+ - **Generator File Reader**: Read file contents
81
+
82
+ ## Slideshow with Media Flow
83
+
84
+ Connect Generator Media Flow output to Brick Slideshow:
85
+
86
+ ```typescript
87
+ import { makeId, linkData } from 'bricks-ctor'
88
+
89
+ const slideshow: BrickSlideshow = {
90
+ __typename: 'Brick',
91
+ templateKey: 'Slideshow',
92
+ id: makeId('brick'),
93
+ title: 'Promo Slideshow',
94
+ description: '',
95
+ property: {
96
+ images: linkData(() => promoFilesData),
97
+ interval: 5000, // ms between slides
98
+ transition: 'fade',
99
+ },
100
+ events: {},
101
+ switches: [],
102
+ }
103
+ ```
104
+
105
+ ## File Object Structure
106
+
107
+ Files from Media Flow include:
108
+
109
+ ```typescript
110
+ interface MediaFile {
111
+ id: string
112
+ name: string
113
+ url: string
114
+ thumbnailUrl?: string
115
+ mimeType: string
116
+ size: number
117
+ width?: number // For images/videos
118
+ height?: number
119
+ duration?: number // For videos/audio
120
+ createdAt: string
121
+ updatedAt: string
122
+ }
123
+ ```
124
+
125
+ ## Upload & Management
126
+
127
+ ### Via Editor
128
+ 1. Open Media tab in BRICKS Editor
129
+ 2. Select or create a box
130
+ 3. Drag & drop files or use upload button
131
+
132
+ ### Via CLI
133
+ ```bash
134
+ bricks media boxes # List media boxes
135
+ bricks media box <box-id> # Box details
136
+ bricks media files <box-id> # List files in box
137
+ bricks media file <file-id> # File details
138
+ ```
139
+
140
+ > Note: CLI currently supports read-only operations. Upload is not yet supported.
141
+
142
+ ### Via API
143
+ Use BRICKS API for programmatic upload and management.
144
+
145
+ ## Screenshot Storage
146
+
147
+ Automation `Match Screenshot` can save screenshots to Media Flow workspace:
148
+ - Baseline images stored in specified box
149
+ - Easy visual comparison and management
150
+
151
+ ## Best Practices
152
+
153
+ 1. **Organize by purpose**: Create boxes for different content types (backgrounds, icons, videos)
154
+ 2. **Optimize assets**: Compress images/videos before upload
155
+ 3. **Preload critical assets**: Use `media-resource-*` kinds for important visuals
156
+ 4. **Slideshow performance**: Limit file count and resolution for smooth playback
157
+ 5. **Version control**: Use box naming conventions for content versions
158
+ 6. **CDN benefit**: Media Flow URLs are CDN-backed for fast delivery
@@ -0,0 +1,196 @@
1
+ # Remote Data Bank
2
+
3
+ Cloud-synchronized Data Bank for real-time data sharing across devices and external API access.
4
+
5
+ ## Remote Update Types
6
+
7
+ The `remoteUpdate` field configures cloud synchronization:
8
+
9
+ ```typescript
10
+ remoteUpdate?:
11
+ | { type: 'auto' } // Sync across all devices
12
+ | { type: 'device-specific' } // Isolated per device
13
+ | { type: 'global-data', id: string } // Cross-application global data
14
+ ```
15
+
16
+ ### Auto Sync
17
+
18
+ Sync across all devices using the same application.
19
+
20
+ ```typescript
21
+ import { makeId } from 'bricks-ctor'
22
+
23
+ const data: Data = {
24
+ __typename: 'Data',
25
+ id: makeId('data'),
26
+ title: 'Announcement',
27
+ type: 'string',
28
+ value: '',
29
+ remoteUpdate: { type: 'auto' },
30
+ events: {},
31
+ }
32
+ ```
33
+
34
+ ### Global Data
35
+
36
+ Share data across different applications. Must create Global Data first on BANK page.
37
+
38
+ ```typescript
39
+ import { makeId } from 'bricks-ctor'
40
+
41
+ const data: Data = {
42
+ __typename: 'Data',
43
+ id: makeId('data'),
44
+ title: 'Global Config',
45
+ type: 'object',
46
+ value: {},
47
+ remoteUpdate: { type: 'global-data', id: 'workspace-global-config-id' },
48
+ events: {},
49
+ }
50
+ ```
51
+
52
+ ### Device Specific
53
+
54
+ Isolate data per device while still allowing web page control.
55
+
56
+ ```typescript
57
+ import { makeId } from 'bricks-ctor'
58
+
59
+ const data: Data = {
60
+ __typename: 'Data',
61
+ id: makeId('data'),
62
+ title: 'Device Message',
63
+ type: 'string',
64
+ value: '',
65
+ remoteUpdate: { type: 'device-specific' },
66
+ events: {},
67
+ }
68
+ ```
69
+
70
+ Use case: Control individual displays from a shared web interface without affecting other devices.
71
+
72
+ ## External Access
73
+
74
+ ### Web Update Page
75
+
76
+ Generate a web page for non-technical users to update data:
77
+
78
+ 1. Visit BANK page
79
+ 2. Click `Manage Keys`
80
+ 3. Select `Generate Key used by Update Page`
81
+ 4. Share the generated link
82
+
83
+ The page has independent permissions and can be shared with content managers.
84
+
85
+ ### API Access
86
+
87
+ Programmatic data updates via REST API.
88
+
89
+ **Setup:**
90
+ 1. Visit BANK page → Manage Keys
91
+ 2. Create API key with appropriate permissions
92
+ 3. Use key in API requests
93
+
94
+ **Example API Usage:**
95
+
96
+ ```bash
97
+ # Update a property
98
+ curl -X POST https://api.bricks.tools/v1/bank/update \
99
+ -H "Authorization: Bearer YOUR_API_KEY" \
100
+ -H "Content-Type: application/json" \
101
+ -d '{
102
+ "applicationId": "app-id",
103
+ "propertyId": "announcement",
104
+ "value": "New announcement text"
105
+ }'
106
+
107
+ # Get property value
108
+ curl https://api.bricks.tools/v1/bank/get \
109
+ -H "Authorization: Bearer YOUR_API_KEY" \
110
+ -G \
111
+ -d "applicationId=app-id" \
112
+ -d "propertyId=announcement"
113
+ ```
114
+
115
+ ## Data Routing
116
+
117
+ Cross-subspace data sharing with access control.
118
+
119
+ ```typescript
120
+ const routedData: Data = {
121
+ __typename: 'Data',
122
+ id: 'shared-state',
123
+ type: 'object',
124
+ routing: 'read-only', // 'read-only' | default (read-write)
125
+ // When read-only: only accepts changes from same subspace
126
+ // Default: accepts changes from any subspace
127
+ }
128
+ ```
129
+
130
+ ## Use Cases
131
+
132
+ ### Digital Signage Content Management
133
+
134
+ ```typescript
135
+ import { makeId } from 'bricks-ctor'
136
+
137
+ // Remote-updated announcement
138
+ const announcement: Data = {
139
+ __typename: 'Data',
140
+ id: makeId('data'),
141
+ title: 'Announcement',
142
+ type: 'object',
143
+ value: { title: '', body: '', enabled: false },
144
+ remoteUpdate: { type: 'auto' },
145
+ events: {},
146
+ }
147
+ ```
148
+
149
+ Operator updates content via web page → All displays update in real-time.
150
+
151
+ ### Multi-Location Coordination
152
+
153
+ ```typescript
154
+ import { makeId } from 'bricks-ctor'
155
+
156
+ // Global data shared across locations
157
+ const globalConfig: Data = {
158
+ __typename: 'Data',
159
+ id: makeId('data'),
160
+ title: 'Brand Config',
161
+ type: 'object',
162
+ value: {},
163
+ remoteUpdate: { type: 'global-data', id: 'brand-config-global' },
164
+ events: {},
165
+ }
166
+ ```
167
+
168
+ Update once → All locations receive update.
169
+
170
+ ### Per-Device Customization
171
+
172
+ ```typescript
173
+ import { makeId } from 'bricks-ctor'
174
+
175
+ // Device-specific greeting
176
+ const deviceGreeting: Data = {
177
+ __typename: 'Data',
178
+ id: makeId('data'),
179
+ title: 'Greeting',
180
+ type: 'string',
181
+ value: '',
182
+ remoteUpdate: { type: 'device-specific' },
183
+ events: {},
184
+ }
185
+ ```
186
+
187
+ Each display shows different greeting, controlled from single dashboard.
188
+
189
+ ## Best Practices
190
+
191
+ 1. **Minimize remote data**: Only enable for data that truly needs cloud sync
192
+ 2. **Use device-specific wisely**: Good for personalization, not for shared state
193
+ 3. **API key security**: Use scoped keys with minimal permissions
194
+ 4. **Offline resilience**: Design for temporary disconnection
195
+ 5. **Batch updates**: Group related changes to reduce API calls
196
+ 6. **Global data governance**: Establish clear ownership for global data keys