@fugood/bricks-project 2.23.0-beta.45 → 2.23.0-beta.49

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.
@@ -310,6 +310,24 @@ export const templateActionNameMap = {
310
310
  },
311
311
  },
312
312
 
313
+ BRICK_MAPS: {
314
+ BRICK_MAPS_PAN: {
315
+ panDirection: 'BRICK_MAPS_PAN_DIRECTION',
316
+ },
317
+ BRICK_MAPS_NAVIGATE_TO: {
318
+ targetLatitude: 'BRICK_MAPS_TARGET_LATITUDE',
319
+ targetLongitude: 'BRICK_MAPS_TARGET_LONGITUDE',
320
+ targetZoom: 'BRICK_MAPS_TARGET_ZOOM',
321
+ },
322
+ BRICK_MAPS_FOCUS_MARKER: {
323
+ markerId: 'BRICK_MAPS_MARKER_ID',
324
+ },
325
+ BRICK_MAPS_FIT_TO_MARKERS: {
326
+ edgePadding: 'BRICK_MAPS_EDGE_PADDING',
327
+ animated: 'BRICK_MAPS_ANIMATED',
328
+ },
329
+ },
330
+
313
331
  GENERATOR_FILE: {
314
332
  GENERATOR_FILE_READ_CONTENT: {
315
333
  encoding: 'ENCODING',
package/compile/util.ts CHANGED
@@ -3,6 +3,7 @@ import { makeId } from '../utils/id'
3
3
  type ScriptConfig = {
4
4
  inputs: Record<string, string>
5
5
  enable_async: boolean
6
+ trigger_mode?: 'auto' | 'manual'
6
7
  disabled_triggers: Record<string, boolean>
7
8
  output: string | null
8
9
  outputs: Record<string, string[]>
@@ -13,6 +14,8 @@ type ScriptConfig = {
13
14
  const errorMsg = 'Not allow duplicate set property id between inputs / outputs / output / error.'
14
15
 
15
16
  export const validateConfig = (config: ScriptConfig) => {
17
+ // Skip input/output overlap validation in manual mode (allows same data node in both)
18
+ if (config.trigger_mode === 'manual') return
16
19
  if (config.error && config.inputs[config.error]) {
17
20
  throw new Error(`${errorMsg}. key: error`)
18
21
  }
@@ -87,7 +90,8 @@ export const generateCalulationMap = (config: ScriptConfig, opts?: { snapshotMod
87
90
  {
88
91
  id: key,
89
92
  port: 'value',
90
- disable_trigger_command: config.disabled_triggers?.[key] ? true : undefined,
93
+ disable_trigger_command:
94
+ config.trigger_mode === 'manual' || config.disabled_triggers?.[key] || undefined,
91
95
  },
92
96
  ],
93
97
  },
@@ -152,6 +156,8 @@ export const generateCalulationMap = (config: ScriptConfig, opts?: { snapshotMod
152
156
  points: {},
153
157
  }
154
158
  pbList.forEach((pb, pbIndex) => {
159
+ // Check if this data node already exists (it might be used as both input and output)
160
+ const existingNode = acc.map[pb] || inputs.map[pb]
155
161
  acc.map[pb] = {
156
162
  type: 'data-node',
157
163
  properties: {},
@@ -164,7 +170,8 @@ export const generateCalulationMap = (config: ScriptConfig, opts?: { snapshotMod
164
170
  ],
165
171
  },
166
172
  out: {
167
- value: null,
173
+ // Preserve existing out.value if node is also used as input
174
+ value: existingNode?.out?.value ?? null,
168
175
  },
169
176
  }
170
177
  acc.editorInfo[pb] = {
@@ -292,7 +299,8 @@ export const generateCalulationMap = (config: ScriptConfig, opts?: { snapshotMod
292
299
  ],
293
300
  },
294
301
  out: {
295
- value: null,
302
+ // Preserve existing out.value if node is also used as input
303
+ value: inputs.map[config.error]?.out?.value ?? null,
296
304
  },
297
305
  },
298
306
  }),
@@ -309,7 +317,8 @@ export const generateCalulationMap = (config: ScriptConfig, opts?: { snapshotMod
309
317
  ],
310
318
  },
311
319
  out: {
312
- value: null,
320
+ // Preserve existing out.value if node is also used as input
321
+ value: inputs.map[config.output]?.out?.value ?? null,
313
322
  },
314
323
  },
315
324
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fugood/bricks-project",
3
- "version": "2.23.0-beta.45",
3
+ "version": "2.23.0-beta.49",
4
4
  "main": "index.ts",
5
5
  "scripts": {
6
6
  "build": "bun scripts/build.js"
@@ -14,5 +14,5 @@
14
14
  "lodash": "^4.17.4",
15
15
  "uuid": "^8.3.1"
16
16
  },
17
- "gitHead": "fa67a0c333ca6e372e7b7b01035d8e871b216b9f"
17
+ "gitHead": "d879268aee7397545296e9c1ca1f369af32dfee5"
18
18
  }
@@ -107,8 +107,8 @@ Default property:
107
107
  }
108
108
  */
109
109
  property?: BrickBasicProperty & {
110
- /* Camera type (Ignore it if you are using external camera) */
111
- type?: 'back' | 'front' | DataLink
110
+ /* Camera type */
111
+ type?: 'back' | 'front' | 'external' | DataLink
112
112
  /* Enable or disable camera */
113
113
  isActive?: boolean | DataLink
114
114
  /* Camera zoom */
@@ -0,0 +1,254 @@
1
+ /* Auto generated by build script */
2
+ import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
3
+ import type { Data, DataLink } from '../data'
4
+ import type { Animation, AnimationBasicEvents } from '../animation'
5
+ import type {
6
+ Brick,
7
+ EventAction,
8
+ EventActionForItem,
9
+ ActionWithDataParams,
10
+ ActionWithParams,
11
+ Action,
12
+ EventProperty,
13
+ } from '../common'
14
+ import type { BrickBasicProperty, BrickBasicEvents, BrickBasicEventsForItem } from '../brick-base'
15
+
16
+ /* Zoom in the map */
17
+ export type BrickMapsActionZoomIn = Action & {
18
+ __actionName: 'BRICK_MAPS_ZOOM_IN'
19
+ }
20
+
21
+ /* Zoom out the map */
22
+ export type BrickMapsActionZoomOut = Action & {
23
+ __actionName: 'BRICK_MAPS_ZOOM_OUT'
24
+ }
25
+
26
+ /* Pan the map in a direction */
27
+ export type BrickMapsActionPan = ActionWithParams & {
28
+ __actionName: 'BRICK_MAPS_PAN'
29
+ params?: Array<{
30
+ input: 'panDirection'
31
+ value?: 'up' | 'down' | 'left' | 'right' | DataLink | EventProperty
32
+ mapping?: string
33
+ }>
34
+ }
35
+
36
+ /* Navigate to a specific location */
37
+ export type BrickMapsActionNavigateTo = ActionWithParams & {
38
+ __actionName: 'BRICK_MAPS_NAVIGATE_TO'
39
+ params?: Array<
40
+ | {
41
+ input: 'targetLatitude'
42
+ value?: number | DataLink | EventProperty
43
+ mapping?: string
44
+ }
45
+ | {
46
+ input: 'targetLongitude'
47
+ value?: number | DataLink | EventProperty
48
+ mapping?: string
49
+ }
50
+ | {
51
+ input: 'targetZoom'
52
+ value?: number | DataLink | EventProperty
53
+ mapping?: string
54
+ }
55
+ >
56
+ }
57
+
58
+ /* Focus on a marker by ID */
59
+ export type BrickMapsActionFocusMarker = ActionWithParams & {
60
+ __actionName: 'BRICK_MAPS_FOCUS_MARKER'
61
+ params?: Array<{
62
+ input: 'markerId'
63
+ value?: string | DataLink | EventProperty
64
+ mapping?: string
65
+ }>
66
+ }
67
+
68
+ /* Reset map to initial position */
69
+ export type BrickMapsActionReset = Action & {
70
+ __actionName: 'BRICK_MAPS_RESET'
71
+ }
72
+
73
+ /* Fit map to show all markers */
74
+ export type BrickMapsActionFitToMarkers = ActionWithParams & {
75
+ __actionName: 'BRICK_MAPS_FIT_TO_MARKERS'
76
+ params?: Array<
77
+ | {
78
+ input: 'edgePadding'
79
+ value?: number | DataLink | EventProperty
80
+ mapping?: string
81
+ }
82
+ | {
83
+ input: 'animated'
84
+ value?: boolean | DataLink | EventProperty
85
+ mapping?: string
86
+ }
87
+ >
88
+ }
89
+
90
+ interface BrickMapsDef {
91
+ /*
92
+ Default property:
93
+ {
94
+ "provider": "google",
95
+ "apiKey": "",
96
+ "initialLatitude": 25.033,
97
+ "initialLongitude": 121.5654,
98
+ "initialZoom": 10,
99
+ "mapType": "standard",
100
+ "mapTheme": "standard",
101
+ "showUserLocation": false,
102
+ "showCompass": true,
103
+ "showZoomControls": true,
104
+ "scrollEnabled": true,
105
+ "zoomEnabled": true,
106
+ "rotateEnabled": true,
107
+ "markers": [],
108
+ "customMapStyle": [],
109
+ "showTraffic": false,
110
+ "showBuildings": false,
111
+ "showIndoors": true,
112
+ "minZoomLevel": 1,
113
+ "maxZoomLevel": 20,
114
+ "followUserLocation": false,
115
+ "showPath": false,
116
+ "pathStrokeColor": "#4285F4",
117
+ "pathStrokeWidth": 3
118
+ }
119
+ */
120
+ property?: BrickBasicProperty & {
121
+ /* Map provider (iOS/tvOS only - Android and Web always use Google Maps) */
122
+ provider?: 'google' | 'apple' | DataLink
123
+ /* Google Maps API Key (Web only) */
124
+ apiKey?: string | DataLink
125
+ /* Initial latitude */
126
+ initialLatitude?: number | DataLink
127
+ /* Initial longitude */
128
+ initialLongitude?: number | DataLink
129
+ /* Initial zoom level (1-20) */
130
+ initialZoom?: number | DataLink
131
+ /* Map type */
132
+ mapType?: 'standard' | 'satellite' | 'hybrid' | 'terrain' | DataLink
133
+ /* Map theme preset */
134
+ mapTheme?: 'standard' | 'dark' | 'night' | 'retro' | 'silver' | 'aubergine' | DataLink
135
+ /* Show user location button */
136
+ showUserLocation?: boolean | DataLink
137
+ /* Show compass */
138
+ showCompass?: boolean | DataLink
139
+ /* Show zoom controls */
140
+ showZoomControls?: boolean | DataLink
141
+ /* Enable scrolling */
142
+ scrollEnabled?: boolean | DataLink
143
+ /* Enable zooming */
144
+ zoomEnabled?: boolean | DataLink
145
+ /* Enable rotating */
146
+ rotateEnabled?: boolean | DataLink
147
+ /* Map markers data */
148
+ markers?:
149
+ | Array<
150
+ | DataLink
151
+ | {
152
+ id?: string | DataLink
153
+ latitude?: number | DataLink
154
+ longitude?: number | DataLink
155
+ title?: string | DataLink
156
+ description?: string | DataLink
157
+ color?: string | DataLink
158
+ icon?: string | DataLink
159
+ }
160
+ >
161
+ | DataLink
162
+ /* Custom map style (array of Google Maps style objects) */
163
+ customMapStyle?:
164
+ | Array<
165
+ | DataLink
166
+ | {
167
+ featureType?: string | DataLink
168
+ elementType?: string | DataLink
169
+ stylers?: Array<{} | DataLink> | DataLink
170
+ }
171
+ >
172
+ | DataLink
173
+ /* Show traffic layer */
174
+ showTraffic?: boolean | DataLink
175
+ /* Show buildings in 3D */
176
+ showBuildings?: boolean | DataLink
177
+ /* Show indoor maps */
178
+ showIndoors?: boolean | DataLink
179
+ /* Minimum zoom level */
180
+ minZoomLevel?: number | DataLink
181
+ /* Maximum zoom level */
182
+ maxZoomLevel?: number | DataLink
183
+ /* Follow user location */
184
+ followUserLocation?: boolean | DataLink
185
+ /* Show path between markers */
186
+ showPath?: boolean | DataLink
187
+ /* Path stroke color */
188
+ pathStrokeColor?: string | DataLink
189
+ /* Path stroke width */
190
+ pathStrokeWidth?: number | DataLink
191
+ }
192
+ events?: BrickBasicEvents & {
193
+ /* Event of the brick press */
194
+ onPress?: Array<EventAction>
195
+ /* Event of the brick press in */
196
+ onPressIn?: Array<EventAction>
197
+ /* Event of the brick press out */
198
+ onPressOut?: Array<EventAction>
199
+ /* Event of the brick long press */
200
+ onLongPress?: Array<EventAction>
201
+ /* Event of the brick focus (Use TV Device with controller) */
202
+ onFocus?: Array<EventAction>
203
+ /* Event of the brick blur (Use TV Device with controller) */
204
+ onBlur?: Array<EventAction>
205
+ /* Event when a marker is pressed */
206
+ onMarkerPress?: Array<EventAction>
207
+ /* Event when the map is pressed */
208
+ onMapPress?: Array<EventAction>
209
+ /* Event when the map region changes */
210
+ onRegionChange?: Array<EventAction>
211
+ /* Event when the map is ready */
212
+ onReady?: Array<EventAction>
213
+ }
214
+ outlets?: {
215
+ /* Brick is pressing */
216
+ brickPressing?: () => Data
217
+ /* Brick is focusing (Use TV Device with controller) */
218
+ brickFocusing?: () => Data
219
+ }
220
+ animation?: AnimationBasicEvents & {
221
+ onPress?: Animation
222
+ onPressIn?: Animation
223
+ onPressOut?: Animation
224
+ onLongPress?: Animation
225
+ onFocus?: Animation
226
+ onBlur?: Animation
227
+ onMarkerPress?: Animation
228
+ onMapPress?: Animation
229
+ onRegionChange?: Animation
230
+ onReady?: Animation
231
+ }
232
+ }
233
+
234
+ /* Maps brick ([Tutorial](https://intercom.help/bricks-dag-inc/articles/maps)) */
235
+ export type BrickMaps = Brick &
236
+ BrickMapsDef & {
237
+ templateKey: 'BRICK_MAPS'
238
+ switches: Array<
239
+ SwitchDef &
240
+ BrickMapsDef & {
241
+ conds?: Array<{
242
+ method: '==' | '!=' | '>' | '<' | '>=' | '<='
243
+ cond:
244
+ | SwitchCondInnerStateCurrentCanvas
245
+ | SwitchCondData
246
+ | {
247
+ __typename: 'SwitchCondInnerStateOutlet'
248
+ outlet: 'brickPressing' | 'brickFocusing'
249
+ value: any
250
+ }
251
+ }>
252
+ }
253
+ >
254
+ }
@@ -18,3 +18,4 @@ export * from './WebView'
18
18
  export * from './Camera'
19
19
  export * from './WebRtcStream'
20
20
  export * from './GenerativeMedia'
21
+ export * from './Maps'