@fugood/bricks-project 2.24.1-beta.3 → 2.24.2

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.
@@ -17,7 +17,18 @@ const STYLE_BITS: Record<IconStyle, number> = {
17
17
  duotone: 256,
18
18
  }
19
19
  const ALL_STYLES = Object.keys(STYLE_BITS) as IconStyle[]
20
- const iconMeta = glyphmapMeta as Record<string, number>
20
+
21
+ // Metadata is shipped as { bitmaskValue: [iconName, ...] } with the dominant
22
+ // 510 (all non-brand families) omitted. Expand to a flat lookup once.
23
+ const DEFAULT_BITMASK = 510
24
+ const compactMeta = glyphmapMeta as Record<string, string[]>
25
+ const iconMeta: Record<string, number> = {}
26
+ for (const name of Object.keys(glyphmap)) iconMeta[name] = DEFAULT_BITMASK
27
+ for (const bitmaskKey of Object.keys(compactMeta)) {
28
+ const value = Number(bitmaskKey)
29
+ const names = compactMeta[bitmaskKey]
30
+ for (const name of names) iconMeta[name] = value
31
+ }
21
32
 
22
33
  const iconList = Object.entries(glyphmap as Record<string, number>).map(([name, code]) => {
23
34
  const bits = iconMeta[name] || 0
@@ -0,0 +1,254 @@
1
+ /* Auto generated by build script
2
+ *
3
+ * Drawing canvas with undo/redo, import/export state, and image export
4
+ */
5
+ import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
6
+ import type { Data, DataLink } from '../data'
7
+ import type { Animation, AnimationBasicEvents } from '../animation'
8
+ import type {
9
+ Brick,
10
+ EventAction,
11
+ EventActionForItem,
12
+ ActionWithDataParams,
13
+ ActionWithParams,
14
+ Action,
15
+ EventProperty,
16
+ } from '../common'
17
+ import type { BrickBasicProperty, BrickBasicEvents, BrickBasicEventsForItem } from '../brick-base'
18
+ import type { TemplateEventPropsMap } from '../../utils/event-props'
19
+
20
+ /* Undo the last stroke */
21
+ export type BrickSketchActionUndo = Action & {
22
+ __actionName: 'BRICK_SKETCH_UNDO'
23
+ }
24
+
25
+ /* Redo the last undone stroke */
26
+ export type BrickSketchActionRedo = Action & {
27
+ __actionName: 'BRICK_SKETCH_REDO'
28
+ }
29
+
30
+ /* Clear all strokes from the canvas */
31
+ export type BrickSketchActionClear = Action & {
32
+ __actionName: 'BRICK_SKETCH_CLEAR'
33
+ }
34
+
35
+ /* Set the active tool */
36
+ export type BrickSketchActionSetTool = ActionWithParams & {
37
+ __actionName: 'BRICK_SKETCH_SET_TOOL'
38
+ params?: Array<{
39
+ input: 'tool'
40
+ value?: 'pen' | 'eraser' | DataLink | EventProperty
41
+ mapping?: string
42
+ }>
43
+ }
44
+
45
+ /* Set the stroke color */
46
+ export type BrickSketchActionSetColor = ActionWithParams & {
47
+ __actionName: 'BRICK_SKETCH_SET_COLOR'
48
+ params?: Array<{
49
+ input: 'color'
50
+ value?: string | DataLink | EventProperty
51
+ mapping?: string
52
+ }>
53
+ }
54
+
55
+ /* Set the stroke width (px) */
56
+ export type BrickSketchActionSetStrokeWidth = ActionWithParams & {
57
+ __actionName: 'BRICK_SKETCH_SET_STROKE_WIDTH'
58
+ params?: Array<{
59
+ input: 'strokeWidth'
60
+ value?: number | DataLink | EventProperty
61
+ mapping?: string
62
+ }>
63
+ }
64
+
65
+ /* Import sketch state (JSON string from a previous export) */
66
+ export type BrickSketchActionImportState = ActionWithParams & {
67
+ __actionName: 'BRICK_SKETCH_IMPORT_STATE'
68
+ params?: Array<{
69
+ input: 'stateJson'
70
+ value?: string | DataLink | EventProperty
71
+ mapping?: string
72
+ }>
73
+ }
74
+
75
+ /* Export the current sketch state to the BRICK_SKETCH_STATE outlet */
76
+ export type BrickSketchActionExportState = Action & {
77
+ __actionName: 'BRICK_SKETCH_EXPORT_STATE'
78
+ }
79
+
80
+ /* Export the canvas as an image (file URI emitted to BRICK_SKETCH_IMAGE_URI) */
81
+ export type BrickSketchActionExportImage = ActionWithParams & {
82
+ __actionName: 'BRICK_SKETCH_EXPORT_IMAGE'
83
+ params?: Array<
84
+ | {
85
+ input: 'imageFormat'
86
+ value?: 'png' | 'jpeg' | DataLink | EventProperty
87
+ mapping?: string
88
+ }
89
+ | {
90
+ input: 'imageQuality'
91
+ value?: number | DataLink | EventProperty
92
+ mapping?: string
93
+ }
94
+ >
95
+ }
96
+
97
+ /* Add a stroke programmatically */
98
+ export type BrickSketchActionAddStroke = ActionWithParams & {
99
+ __actionName: 'BRICK_SKETCH_ADD_STROKE'
100
+ params?: Array<
101
+ | {
102
+ input: 'strokePoints'
103
+ value?: any | EventProperty
104
+ mapping?: string
105
+ }
106
+ | {
107
+ input: 'strokeColor'
108
+ value?: string | DataLink | EventProperty
109
+ mapping?: string
110
+ }
111
+ | {
112
+ input: 'strokeWidth'
113
+ value?: number | DataLink | EventProperty
114
+ mapping?: string
115
+ }
116
+ >
117
+ }
118
+
119
+ interface BrickSketchDef {
120
+ /*
121
+ Default property:
122
+ {
123
+ "tool": "pen",
124
+ "strokeColor": "#000000",
125
+ "strokeWidth": 3,
126
+ "pressureSensitive": true,
127
+ "layoutType": "cover",
128
+ "scale": 1,
129
+ "mode": "pen",
130
+ "theme": "auto",
131
+ "backgroundPattern": "dot",
132
+ "hideToolbar": false,
133
+ "hideUndo": false,
134
+ "hideRedo": false,
135
+ "hidePencilTool": false,
136
+ "hideColorPicker": false,
137
+ "hideThickness": false,
138
+ "availableColors": [
139
+ "#000000",
140
+ "#ffffff",
141
+ "#e53935",
142
+ "#fb8c00",
143
+ "#fdd835",
144
+ "#43a047",
145
+ "#1e88e5",
146
+ "#8e24aa"
147
+ ]
148
+ }
149
+ */
150
+ property?: BrickBasicProperty & {
151
+ /* Initial sketch state to load on mount (object or JSON string from a previous export). When `BRICK_SKETCH_STATE` outlet feeds the same value back via binding, the echo is detected and ignored to avoid an update loop. */
152
+ initialState?: string | DataLink | DataLink | {} | DataLink
153
+ /* Drawing tool */
154
+ tool?: 'pen' | 'eraser' | DataLink
155
+ /* Stroke color */
156
+ strokeColor?: string | DataLink
157
+ /* Stroke width (px) */
158
+ strokeWidth?: number | DataLink
159
+ /* Vary stroke width by pen pressure */
160
+ pressureSensitive?: boolean | DataLink
161
+ /* Canvas layout. `cover` fits the brick frame; `extend` lets the canvas grow with content */
162
+ layoutType?: 'cover' | 'extend' | DataLink
163
+ /* Canvas resolution scale (device-pixel multiplier) */
164
+ scale?: number | DataLink
165
+ /* Interaction mode. `pen` = drawing (scroll disabled), `scroll` = scroll/pan (drawing disabled) */
166
+ mode?: 'pen' | 'scroll' | DataLink
167
+ /* Toolbar/UI theme. `auto` follows the system color scheme; `light`/`dark` force the palette. */
168
+ theme?: 'auto' | 'light' | 'dark' | DataLink
169
+ /* Background color of the canvas */
170
+ backgroundColor?: string | DataLink
171
+ /* Background image URL (covers the canvas; rendered behind strokes) */
172
+ backgroundImage?: string | DataLink
173
+ /* Decorative background pattern when no background image is provided */
174
+ backgroundPattern?: 'dot' | 'grid' | 'none' | DataLink
175
+ /* Hide the entire built-in toolbar */
176
+ hideToolbar?: boolean | DataLink
177
+ /* Hide the undo button in the toolbar */
178
+ hideUndo?: boolean | DataLink
179
+ /* Hide the redo button in the toolbar */
180
+ hideRedo?: boolean | DataLink
181
+ /* Hide the pen/eraser tool toggle */
182
+ hidePencilTool?: boolean | DataLink
183
+ /* Hide the color picker */
184
+ hideColorPicker?: boolean | DataLink
185
+ /* Hide the stroke thickness slider */
186
+ hideThickness?: boolean | DataLink
187
+ /* Colors shown in the built-in color picker */
188
+ availableColors?: Array<string | DataLink> | DataLink
189
+ }
190
+ events?: BrickBasicEvents & {
191
+ /* A stroke was just committed (drawn or added programmatically) */
192
+ onStrokeEnd?: Array<EventAction<string & keyof TemplateEventPropsMap['Sketch']['onStrokeEnd']>>
193
+ /* The canvas was cleared */
194
+ onClear?: Array<EventAction>
195
+ /* Sketch state changed (any commit, undo, redo, clear, or import) */
196
+ onStateChange?: Array<EventAction>
197
+ /* Active tool changed */
198
+ onToolChange?: Array<
199
+ EventAction<string & keyof TemplateEventPropsMap['Sketch']['onToolChange']>
200
+ >
201
+ /* Image export finished */
202
+ onExportImage?: Array<
203
+ EventAction<string & keyof TemplateEventPropsMap['Sketch']['onExportImage']>
204
+ >
205
+ }
206
+ outlets?: {
207
+ /* Current sketch state (strokes, settings, undo/redo stacks) */
208
+ state?: () => Data<{
209
+ strokes?: any[]
210
+ undone?: any[]
211
+ settings?: { [key: string]: any }
212
+ [key: string]: any
213
+ }>
214
+ /* URI of the most recently exported image */
215
+ imageUri?: () => Data<string>
216
+ /* Most recently committed stroke (points, color, width) */
217
+ lastStroke?: () => Data<{
218
+ color?: string
219
+ width?: number
220
+ tool?: string
221
+ points?: any[]
222
+ [key: string]: any
223
+ }>
224
+ }
225
+ animation?: AnimationBasicEvents & {
226
+ onStrokeEnd?: Animation
227
+ onClear?: Animation
228
+ onStateChange?: Animation
229
+ onToolChange?: Animation
230
+ onExportImage?: Animation
231
+ }
232
+ }
233
+
234
+ /* Drawing canvas with undo/redo, import/export state, and image export */
235
+ export type BrickSketch = Brick &
236
+ BrickSketchDef & {
237
+ templateKey: 'BRICK_SKETCH'
238
+ switches?: Array<
239
+ SwitchDef &
240
+ BrickSketchDef & {
241
+ conds?: Array<{
242
+ method: '==' | '!=' | '>' | '<' | '>=' | '<='
243
+ cond:
244
+ | SwitchCondInnerStateCurrentCanvas
245
+ | SwitchCondData
246
+ | {
247
+ __typename: 'SwitchCondInnerStateOutlet'
248
+ outlet: 'state' | 'imageUri' | 'lastStroke'
249
+ value: any
250
+ }
251
+ }>
252
+ }
253
+ >
254
+ }
@@ -19,3 +19,4 @@ export * from './Camera'
19
19
  export * from './WebRtcStream'
20
20
  export * from './GenerativeMedia'
21
21
  export * from './Maps'
22
+ export * from './Sketch'
@@ -174,6 +174,7 @@ Default property:
174
174
  isCapturing?: boolean
175
175
  data?: {
176
176
  result?: string
177
+ language?: string
177
178
  [key: string]: any
178
179
  }
179
180
  vadEvent?: {
@@ -215,6 +216,7 @@ Default property:
215
216
  isCapturing?: boolean
216
217
  data?: {
217
218
  result?: string
219
+ language?: string
218
220
  [key: string]: any
219
221
  }
220
222
  vadEvent?: {
@@ -238,6 +240,10 @@ Default property:
238
240
  }>
239
241
  /* Stabilized transcription text from completed slices */
240
242
  stabilizedText?: () => Data<string>
243
+ /* Latest detected language code (e.g. `en`, `zh`, `ja`) from any transcribe slice (best-effort, may flicker on short slices) */
244
+ detectedLanguage?: () => Data<string>
245
+ /* Detected language code of the most recently stabilized (finalized) slice */
246
+ stabilizedLanguage?: () => Data<string>
241
247
  /* Audio output file path (auto-generated when saving audio) */
242
248
  audioOutputPath?: () => Data<string>
243
249
  /* Available microphone devices (Web / Desktop only) */
@@ -269,6 +275,8 @@ export type GeneratorRealtimeTranscription = Generator &
269
275
  | 'lastTranscribeEvent'
270
276
  | 'lastVadEvent'
271
277
  | 'stabilizedText'
278
+ | 'detectedLanguage'
279
+ | 'stabilizedLanguage'
272
280
  | 'audioOutputPath'
273
281
  | 'devices'
274
282
  value: any
@@ -358,9 +358,12 @@ Default property:
358
358
  transcribeProgress?: () => Data<number>
359
359
  /* Inference result */
360
360
  transcribeResult?: () => Data<string>
361
+ /* Detected language code of the latest transcription (e.g. `en`, `zh`, `ja`) */
362
+ detectedLanguage?: () => Data<string>
361
363
  /* Inference result details */
362
364
  transcribeDetails?: () => Data<{
363
365
  result?: string
366
+ language?: string
364
367
  segments?: Array<{
365
368
  start?: number
366
369
  end?: number
@@ -405,6 +408,7 @@ export type GeneratorSpeechInference = Generator &
405
408
  | 'isTranscribing'
406
409
  | 'transcribeProgress'
407
410
  | 'transcribeResult'
411
+ | 'detectedLanguage'
408
412
  | 'transcribeDetails'
409
413
  | 'recordedPath'
410
414
  value: any
@@ -141,6 +141,11 @@ export const templateEventPropsMap = {
141
141
  BRICK_MAPS_REGION_LONGITUDE_DELTA: 'number',
142
142
  },
143
143
  },
144
+ Sketch: {
145
+ onStrokeEnd: { BRICK_SKETCH_STROKE_COUNT: 'number' },
146
+ onToolChange: { BRICK_SKETCH_TOOL: 'string' },
147
+ onExportImage: { BRICK_SKETCH_IMAGE_URI: 'string' },
148
+ },
144
149
  Tick: {
145
150
  ticking: { GENERATOR_TICK_COUNTDOWN: 'number', GENERATOR_TICK_VALUE: 'any' },
146
151
  completed: { GENERATOR_TICK_COUNTDOWN: 'number', GENERATOR_TICK_VALUE: 'any' },
@@ -598,6 +603,7 @@ export const templateEventPropsMap = {
598
603
  onError: { GENERATOR_SPEECH_INFERENCE_ERROR: 'string' },
599
604
  onTranscribed: {
600
605
  GENERATOR_SPEECH_INFERENCE_TRANSCRIBE_RESULT: 'string',
606
+ GENERATOR_SPEECH_INFERENCE_TRANSCRIBE_LANGUAGE: 'string',
601
607
  GENERATOR_SPEECH_INFERENCE_TRANSCRIBE_START_TIME: 'number',
602
608
  GENERATOR_SPEECH_INFERENCE_TRANSCRIBE_END_TIME: 'number',
603
609
  GENERATOR_SPEECH_INFERENCE_TRANSCRIBE_TIME: 'number',
@@ -619,10 +625,11 @@ export const templateEventPropsMap = {
619
625
  RealtimeTranscription: {
620
626
  onTranscribe: {
621
627
  GENERATOR_REALTIME_TRANSCRIPTION_TRANSCRIBE_EVENT:
622
- '{ type?: string sliceIndex?: number isCapturing?: boolean data?: { result?: string [key: string]: any } vadEvent?: { type?: string confidence?: number duration?: number sliceIndex?: number timestamp?: number [key: string]: any } [key: string]: any }',
628
+ '{ type?: string sliceIndex?: number isCapturing?: boolean data?: { result?: string language?: string [key: string]: any } vadEvent?: { type?: string confidence?: number duration?: number sliceIndex?: number timestamp?: number [key: string]: any } [key: string]: any }',
623
629
  GENERATOR_REALTIME_TRANSCRIPTION_TRANSCRIBE_TYPE: 'string',
624
630
  GENERATOR_REALTIME_TRANSCRIPTION_TRANSCRIBE_SLICE_INDEX: 'number',
625
631
  GENERATOR_REALTIME_TRANSCRIPTION_TRANSCRIBE_RESULT_TEXT: 'string',
632
+ GENERATOR_REALTIME_TRANSCRIPTION_TRANSCRIBE_LANGUAGE: 'string',
626
633
  GENERATOR_REALTIME_TRANSCRIPTION_TRANSCRIBE_IS_CAPTURING: 'boolean',
627
634
  GENERATOR_REALTIME_TRANSCRIPTION_VAD_EVENT:
628
635
  '{ type?: string confidence?: number duration?: number sliceIndex?: number timestamp?: number [key: string]: any }',
@@ -644,10 +651,13 @@ export const templateEventPropsMap = {
644
651
  GENERATOR_REALTIME_TRANSCRIPTION_STATS:
645
652
  '{ type?: string timestamp?: number data?: { [key: string]: any } [key: string]: any }',
646
653
  },
647
- onStabilized: { GENERATOR_REALTIME_TRANSCRIPTION_STABILIZED_TEXT: 'string' },
654
+ onStabilized: {
655
+ GENERATOR_REALTIME_TRANSCRIPTION_STABILIZED_TEXT: 'string',
656
+ GENERATOR_REALTIME_TRANSCRIPTION_STABILIZED_LANGUAGE: 'string',
657
+ },
648
658
  onEnd: {
649
659
  GENERATOR_REALTIME_TRANSCRIPTION_END_RESULTS:
650
- 'Array<{ transcribeEvent?: { type?: string sliceIndex?: number isCapturing?: boolean data?: { result?: string [key: string]: any } vadEvent?: { type?: string confidence?: number duration?: number sliceIndex?: number timestamp?: number [key: string]: any } [key: string]: any } vadEvent?: { type?: string confidence?: number duration?: number sliceIndex?: number timestamp?: number [key: string]: any } [key: string]: any }>',
660
+ 'Array<{ transcribeEvent?: { type?: string sliceIndex?: number isCapturing?: boolean data?: { result?: string language?: string [key: string]: any } vadEvent?: { type?: string confidence?: number duration?: number sliceIndex?: number timestamp?: number [key: string]: any } [key: string]: any } vadEvent?: { type?: string confidence?: number duration?: number sliceIndex?: number timestamp?: number [key: string]: any } [key: string]: any }>',
651
661
  GENERATOR_REALTIME_TRANSCRIPTION_END_AUDIO_OUTPUT_PATH: 'string',
652
662
  },
653
663
  },