@fugood/bricks-project 2.24.0-beta.4 → 2.24.0-beta.41

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 (126) hide show
  1. package/compile/action-name-map.ts +38 -0
  2. package/compile/index.ts +429 -160
  3. package/compile/util.ts +2 -0
  4. package/package.json +7 -3
  5. package/package.json.bak +27 -0
  6. package/skills/{bricks-project → bricks-ctor}/SKILL.md +2 -2
  7. package/skills/{bricks-project → bricks-ctor}/rules/animation.md +1 -1
  8. package/skills/{bricks-project → bricks-ctor}/rules/architecture-patterns.md +7 -0
  9. package/skills/bricks-ctor/rules/automations.md +221 -0
  10. package/skills/{bricks-project → bricks-ctor}/rules/buttress.md +10 -7
  11. package/skills/{bricks-project → bricks-ctor}/rules/data-calculation.md +1 -1
  12. package/skills/{bricks-project → bricks-ctor}/rules/local-sync.md +2 -2
  13. package/skills/{bricks-project → bricks-ctor}/rules/media-flow.md +3 -3
  14. package/skills/{bricks-project → bricks-ctor}/rules/remote-data-bank.md +6 -6
  15. package/skills/{bricks-project → bricks-ctor}/rules/standby-transition.md +1 -1
  16. package/skills/bricks-design/LICENSE.txt +180 -0
  17. package/skills/bricks-design/SKILL.md +66 -0
  18. package/tools/deploy.ts +66 -12
  19. package/tools/icons/fa6pro-meta.json +3669 -26125
  20. package/tools/mcp-server.ts +11 -878
  21. package/tools/mcp-tools/compile.ts +91 -0
  22. package/tools/mcp-tools/huggingface.ts +762 -0
  23. package/tools/mcp-tools/icons.ts +70 -0
  24. package/tools/mcp-tools/lottie.ts +102 -0
  25. package/tools/mcp-tools/media.ts +110 -0
  26. package/tools/postinstall.ts +137 -40
  27. package/tools/preview-main.mjs +146 -9
  28. package/tools/preview.ts +30 -2
  29. package/tools/pull.ts +37 -19
  30. package/tsconfig.json +16 -0
  31. package/types/animation.ts +4 -0
  32. package/types/automation.ts +4 -1
  33. package/types/brick-base.ts +1 -1
  34. package/types/bricks/Camera.ts +48 -13
  35. package/types/bricks/Chart.ts +10 -4
  36. package/types/bricks/GenerativeMedia.ts +30 -14
  37. package/types/bricks/Icon.ts +9 -5
  38. package/types/bricks/Image.ts +10 -6
  39. package/types/bricks/Items.ts +29 -15
  40. package/types/bricks/Lottie.ts +15 -7
  41. package/types/bricks/Maps.ts +16 -8
  42. package/types/bricks/QrCode.ts +9 -5
  43. package/types/bricks/Rect.ts +45 -6
  44. package/types/bricks/RichText.ts +9 -5
  45. package/types/bricks/Rive.ts +21 -11
  46. package/types/bricks/Slideshow.ts +20 -10
  47. package/types/bricks/Svg.ts +8 -4
  48. package/types/bricks/Text.ts +9 -5
  49. package/types/bricks/TextInput.ts +23 -13
  50. package/types/bricks/Video.ts +11 -7
  51. package/types/bricks/VideoStreaming.ts +8 -4
  52. package/types/bricks/WebRtcStream.ts +7 -3
  53. package/types/bricks/WebView.ts +12 -8
  54. package/types/canvas.ts +4 -2
  55. package/types/common.ts +19 -12
  56. package/types/data-calc-command.ts +2 -0
  57. package/types/data-calc.ts +1 -0
  58. package/types/data.ts +2 -0
  59. package/types/generators/AlarmClock.ts +17 -11
  60. package/types/generators/Assistant.ts +69 -18
  61. package/types/generators/BleCentral.ts +31 -11
  62. package/types/generators/BlePeripheral.ts +11 -7
  63. package/types/generators/CanvasMap.ts +10 -6
  64. package/types/generators/CastlesPay.ts +15 -7
  65. package/types/generators/DataBank.ts +44 -9
  66. package/types/generators/File.ts +109 -30
  67. package/types/generators/GraphQl.ts +12 -6
  68. package/types/generators/Http.ts +33 -10
  69. package/types/generators/HttpServer.ts +23 -15
  70. package/types/generators/Information.ts +9 -5
  71. package/types/generators/Intent.ts +15 -5
  72. package/types/generators/Iterator.ts +15 -11
  73. package/types/generators/Keyboard.ts +27 -13
  74. package/types/generators/LlmAnthropicCompat.ts +33 -11
  75. package/types/generators/LlmAppleBuiltin.ts +25 -10
  76. package/types/generators/LlmGgml.ts +140 -31
  77. package/types/generators/LlmMediaTekNeuroPilot.ts +235 -0
  78. package/types/generators/LlmMlx.ts +227 -0
  79. package/types/generators/LlmOnnx.ts +34 -14
  80. package/types/generators/LlmOpenAiCompat.ts +47 -11
  81. package/types/generators/LlmQualcommAiEngine.ts +45 -13
  82. package/types/generators/Mcp.ts +375 -34
  83. package/types/generators/McpServer.ts +58 -19
  84. package/types/generators/MediaFlow.ts +38 -12
  85. package/types/generators/MqttBroker.ts +29 -11
  86. package/types/generators/MqttClient.ts +19 -9
  87. package/types/generators/Question.ts +13 -9
  88. package/types/generators/RealtimeTranscription.ts +108 -19
  89. package/types/generators/RerankerGgml.ts +43 -12
  90. package/types/generators/SerialPort.ts +18 -10
  91. package/types/generators/SoundPlayer.ts +10 -4
  92. package/types/generators/SoundRecorder.ts +24 -9
  93. package/types/generators/SpeechToTextGgml.ts +52 -18
  94. package/types/generators/SpeechToTextOnnx.ts +18 -11
  95. package/types/generators/SpeechToTextPlatform.ts +15 -7
  96. package/types/generators/SqLite.ts +20 -10
  97. package/types/generators/Step.ts +9 -5
  98. package/types/generators/SttAppleBuiltin.ts +22 -9
  99. package/types/generators/Tcp.ts +13 -9
  100. package/types/generators/TcpServer.ts +20 -14
  101. package/types/generators/TextToSpeechAppleBuiltin.ts +21 -8
  102. package/types/generators/TextToSpeechGgml.ts +29 -11
  103. package/types/generators/TextToSpeechOnnx.ts +19 -12
  104. package/types/generators/TextToSpeechOpenAiLike.ts +14 -8
  105. package/types/generators/ThermalPrinter.ts +13 -9
  106. package/types/generators/Tick.ts +11 -7
  107. package/types/generators/Udp.ts +17 -8
  108. package/types/generators/VadGgml.ts +51 -14
  109. package/types/generators/VadOnnx.ts +42 -12
  110. package/types/generators/VadTraditional.ts +28 -13
  111. package/types/generators/VectorStore.ts +33 -12
  112. package/types/generators/Watchdog.ts +19 -10
  113. package/types/generators/WebCrawler.ts +11 -7
  114. package/types/generators/WebRtc.ts +30 -16
  115. package/types/generators/WebSocket.ts +11 -7
  116. package/types/generators/index.ts +2 -0
  117. package/types/subspace.ts +3 -0
  118. package/types/system.ts +1 -1
  119. package/utils/calc.ts +12 -8
  120. package/utils/event-props.ts +833 -1022
  121. package/utils/id.ts +4 -0
  122. package/api/index.ts +0 -1
  123. package/api/instance.ts +0 -213
  124. package/skills/bricks-project/rules/automations.md +0 -175
  125. package/types/generators/TextToSpeechApple.ts +0 -113
  126. package/types/generators/TtsAppleBuiltin.ts +0 -105
@@ -1,4 +1,19 @@
1
- /* Auto generated by build script */
1
+ /* Auto generated by build script
2
+ *
3
+ * Local Text-to-Speech (TTS) inference based on GGML and [llama.cpp](https://github.com/ggerganov/llama.cpp)
4
+ * You can use any converted model on HuggingFace.
5
+ *
6
+ * ## Notice
7
+ * - The device RAM must be larger than 8GB
8
+ * - iOS: Recommended use M1+ / A17+ chip device. Supported GPU acceleration by Metal.
9
+ * - macOS: Recommended use M1+ chip device. Supported GPU acceleration by Metal.
10
+ * - Android: Recommended use Android 13+ system.
11
+ * - Supported GPU acceleration by OpenCL, currently only for Qualcomm Adreno 700+ GPUs, other GPUs are not supported.
12
+ * - Supported Hexagon NPU for Qualcomm Snapdragon 8 Gen 2+ GPUs.
13
+ * - Linux / Windows
14
+ * - Supported GPU acceleration, you can choose `vulkan` or `cuda` backend in Accel Variant property
15
+ * - Supported Hexagon NPU for Qualcomm Dragonwing IQ9 series+ (Linux)
16
+ */
2
17
  import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
3
18
  import type { Data, DataLink } from '../data'
4
19
  import type {
@@ -10,6 +25,7 @@ import type {
10
25
  Action,
11
26
  EventProperty,
12
27
  } from '../common'
28
+ import type { TemplateEventPropsMap } from '../../utils/event-props'
13
29
 
14
30
  /* Load the model */
15
31
  export type GeneratorGGMLTTSActionLoadModel = Action & {
@@ -75,7 +91,7 @@ Default property:
75
91
  property?: {
76
92
  /* Initialize the TTS context on generator initialization */
77
93
  init?: boolean | DataLink
78
- /* The URL or path of model
94
+ /* The URL or path of model
79
95
  We used GGUF format model, please refer to https://github.com/ggerganov/llama.cpp/tree/master#description */
80
96
  modelUrl?: string | DataLink
81
97
  /* Hash type of model */
@@ -128,13 +144,13 @@ Default property:
128
144
  microBatchSize?: number | DataLink
129
145
  /* Number of threads */
130
146
  maxThreads?: number | DataLink
131
- /* Accelerator variant (Only for desktop)
147
+ /* Accelerator variant (Only for desktop)
132
148
  `default` - CPU / Metal (macOS)
133
149
  `vulkan` - Use Vulkan
134
150
  `cuda` - Use CUDA
135
151
  `snapdragon` - Use OpenCL/Hexagon of Qualcomm Snapdragon */
136
152
  accelVariant?: 'default' | 'vulkan' | 'cuda' | 'snapdragon' | DataLink
137
- /* Devices. For example:
153
+ /* Devices. For example:
138
154
 
139
155
  Metal or CPU for iOS/tvOS/MacOS
140
156
  OpenCL or CPU for Android
@@ -154,21 +170,23 @@ Default property:
154
170
  }
155
171
  events?: {
156
172
  /* Event triggered when state change */
157
- onContextStateChange?: Array<EventAction>
173
+ onContextStateChange?: Array<
174
+ EventAction<string & keyof TemplateEventPropsMap['GgmlTts']['onContextStateChange']>
175
+ >
158
176
  /* Event triggered when error occurs */
159
- onError?: Array<EventAction>
177
+ onError?: Array<EventAction<string & keyof TemplateEventPropsMap['GgmlTts']['onError']>>
160
178
  }
161
179
  outlets?: {
162
180
  /* Context state */
163
- contextState?: () => Data
181
+ contextState?: () => Data<string>
164
182
  /* Generated audio file */
165
- generatedAudio?: () => Data
183
+ generatedAudio?: () => Data<string>
166
184
  /* Generated audio file is playing */
167
- generatedAudioPlaying?: () => Data
185
+ generatedAudioPlaying?: () => Data<boolean>
168
186
  }
169
187
  }
170
188
 
171
- /* Local Text-to-Speech (TTS) inference based on GGML and [llama.cpp](https://github.com/ggerganov/llama.cpp)
189
+ /* Local Text-to-Speech (TTS) inference based on GGML and [llama.cpp](https://github.com/ggerganov/llama.cpp)
172
190
  You can use any converted model on HuggingFace.
173
191
 
174
192
  ## Notice
@@ -184,7 +202,7 @@ Default property:
184
202
  export type GeneratorGGMLTTS = Generator &
185
203
  GeneratorGGMLTTSDef & {
186
204
  templateKey: 'GENERATOR_GGML_TTS'
187
- switches: Array<
205
+ switches?: Array<
188
206
  SwitchDef &
189
207
  GeneratorGGMLTTSDef & {
190
208
  conds?: Array<{
@@ -1,4 +1,8 @@
1
- /* Auto generated by build script */
1
+ /* Auto generated by build script
2
+ *
3
+ * Local Text-to-Speech (TTS) inference based on ONNX Runtime and [transformers.js](https://huggingface.co/docs/transformers.js)
4
+ * You can use any converted model on HuggingFace.
5
+ */
2
6
  import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
3
7
  import type { Data, DataLink } from '../data'
4
8
  import type {
@@ -10,6 +14,7 @@ import type {
10
14
  Action,
11
15
  EventProperty,
12
16
  } from '../common'
17
+ import type { TemplateEventPropsMap } from '../../utils/event-props'
13
18
 
14
19
  /* Load the model */
15
20
  export type GeneratorTTSActionLoadModel = Action & {
@@ -64,7 +69,7 @@ Default property:
64
69
  property?: {
65
70
  /* Initialize the TTS context on generator initialization */
66
71
  init?: boolean | DataLink
67
- /* TTS model
72
+ /* TTS model
68
73
  The mms-tts models are licensed under CC-BY-NC-4.0 */
69
74
  model?: string | DataLink
70
75
  /* Model type */
@@ -83,7 +88,7 @@ Default property:
83
88
  | DataLink
84
89
  /* Vocoder model for SpeechT5 */
85
90
  vocoderModel?: 'Custom' | 'speecht5_hifigan' | DataLink
86
- /* Custom vocoder model
91
+ /* Custom vocoder model
87
92
  Choose model from https://huggingface.co/models?library=transformers.js&other=hifigan */
88
93
  customVocoderModel?: string | DataLink
89
94
  /* Speaker embedding, for SpeechT5 or StyleTTS (Kokoro) */
@@ -116,12 +121,12 @@ Default property:
116
121
  softBreakRegex?: string | DataLink
117
122
  /* Time to force inference when softBreakRegex is not satisfied */
118
123
  hardBreakTime?: number | DataLink
119
- /* Executor candidates, descending order of priority
124
+ /* Executor candidates, descending order of priority
120
125
  Default will be xnnpack, wasm, cpu */
121
126
  executors?:
122
127
  | Array<'qnn' | 'dml' | 'nnapi' | 'xnnpack' | 'coreml' | 'cpu' | 'wasm' | 'webgpu' | DataLink>
123
128
  | DataLink
124
- /* Execution mode
129
+ /* Execution mode
125
130
  Usually when the model has many branches, setting this option to `parallel` will give you better performance. */
126
131
  executionMode?: 'sequential' | 'parallel' | DataLink
127
132
  /* QNN backend */
@@ -133,26 +138,28 @@ Default property:
133
138
  }
134
139
  events?: {
135
140
  /* Event triggered when state change */
136
- onContextStateChange?: Array<EventAction>
141
+ onContextStateChange?: Array<
142
+ EventAction<string & keyof TemplateEventPropsMap['Tts']['onContextStateChange']>
143
+ >
137
144
  /* Event triggered when error occurs */
138
- onError?: Array<EventAction>
145
+ onError?: Array<EventAction<string & keyof TemplateEventPropsMap['Tts']['onError']>>
139
146
  }
140
147
  outlets?: {
141
148
  /* Context state */
142
- contextState?: () => Data
149
+ contextState?: () => Data<string>
143
150
  /* Generated audio file */
144
- generatedAudio?: () => Data
151
+ generatedAudio?: () => Data<string>
145
152
  /* Generated audio file is playing */
146
- generatedAudioPlaying?: () => Data
153
+ generatedAudioPlaying?: () => Data<boolean>
147
154
  }
148
155
  }
149
156
 
150
- /* Local Text-to-Speech (TTS) inference based on ONNX Runtime and [transformers.js](https://huggingface.co/docs/transformers.js)
157
+ /* Local Text-to-Speech (TTS) inference based on ONNX Runtime and [transformers.js](https://huggingface.co/docs/transformers.js)
151
158
  You can use any converted model on HuggingFace. */
152
159
  export type GeneratorTTS = Generator &
153
160
  GeneratorTTSDef & {
154
161
  templateKey: 'GENERATOR_TTS'
155
- switches: Array<
162
+ switches?: Array<
156
163
  SwitchDef &
157
164
  GeneratorTTSDef & {
158
165
  conds?: Array<{
@@ -1,4 +1,7 @@
1
- /* Auto generated by build script */
1
+ /* Auto generated by build script
2
+ *
3
+ * Generate speech from text using OpenAI's Text-to-Speech API
4
+ */
2
5
  import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
3
6
  import type { Data, DataLink } from '../data'
4
7
  import type {
@@ -10,6 +13,7 @@ import type {
10
13
  Action,
11
14
  EventProperty,
12
15
  } from '../common'
16
+ import type { TemplateEventPropsMap } from '../../utils/event-props'
13
17
 
14
18
  /* Generate audio */
15
19
  export type GeneratorOpenAiTTSActionGenerate = ActionWithParams & {
@@ -54,7 +58,7 @@ Default property:
54
58
  apiKey?: string | DataLink
55
59
  /* OpenAI TTS model */
56
60
  model?: string | DataLink
57
- /* Voice to use
61
+ /* Voice to use
58
62
  Select voice from https://openai.fm , default alloy */
59
63
  voice?: string | DataLink
60
64
  /* Additional instructions for the speech generation */
@@ -78,17 +82,19 @@ Default property:
78
82
  }
79
83
  events?: {
80
84
  /* Event triggered when state change */
81
- onContextStateChange?: Array<EventAction>
85
+ onContextStateChange?: Array<
86
+ EventAction<string & keyof TemplateEventPropsMap['OpenaiTts']['onContextStateChange']>
87
+ >
82
88
  /* Event triggered when error occurs */
83
- onError?: Array<EventAction>
89
+ onError?: Array<EventAction<string & keyof TemplateEventPropsMap['OpenaiTts']['onError']>>
84
90
  }
85
91
  outlets?: {
86
92
  /* Context state */
87
- contextState?: () => Data
93
+ contextState?: () => Data<string>
88
94
  /* Generated audio file */
89
- generatedAudio?: () => Data
95
+ generatedAudio?: () => Data<string>
90
96
  /* Generated audio file is playing */
91
- generatedAudioPlaying?: () => Data
97
+ generatedAudioPlaying?: () => Data<boolean>
92
98
  }
93
99
  }
94
100
 
@@ -96,7 +102,7 @@ Default property:
96
102
  export type GeneratorOpenAiTTS = Generator &
97
103
  GeneratorOpenAiTTSDef & {
98
104
  templateKey: 'GENERATOR_OPENAI_TTS'
99
- switches: Array<
105
+ switches?: Array<
100
106
  SwitchDef &
101
107
  GeneratorOpenAiTTSDef & {
102
108
  conds?: Array<{
@@ -1,4 +1,7 @@
1
- /* Auto generated by build script */
1
+ /* Auto generated by build script
2
+ *
3
+ * ESC/POS thermal receipt printer control via Bluetooth or USB
4
+ */
2
5
  import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
3
6
  import type { Data, DataLink } from '../data'
4
7
  import type {
@@ -10,6 +13,7 @@ import type {
10
13
  Action,
11
14
  EventProperty,
12
15
  } from '../common'
16
+ import type { TemplateEventPropsMap } from '../../utils/event-props'
13
17
 
14
18
  /* Init thermal printer connection */
15
19
  export type GeneratorThermalPrinterActionInit = Action & {
@@ -85,7 +89,7 @@ Default property:
85
89
  pageHeight?: number | DataLink
86
90
  /* Cut mode at the end of printing */
87
91
  cutMode?: 'NONE' | 'FULL' | 'PARTIAL' | DataLink
88
- /* Print payload
92
+ /* Print payload
89
93
  example:
90
94
  { type: 'text', content: 'Hello, World!' }
91
95
  { type: 'feed', feedLines: 1 }
@@ -150,25 +154,25 @@ Default property:
150
154
  }
151
155
  events?: {
152
156
  /* Event of connection error */
153
- onError?: Array<EventAction>
157
+ onError?: Array<EventAction<string & keyof TemplateEventPropsMap['ThermalPrinter']['onError']>>
154
158
  }
155
159
  outlets?: {
156
160
  /* Is thermal printer initialized */
157
- initialized?: () => Data
161
+ initialized?: () => Data<boolean>
158
162
  /* Thermal printer status */
159
- status?: () => Data
163
+ status?: () => Data<{ [key: string]: any }>
160
164
  /* Discovered devices */
161
- discoveredDevices?: () => Data
165
+ discoveredDevices?: () => Data<Array<{ [key: string]: any }>>
162
166
  /* Last error message */
163
- lastError?: () => Data
167
+ lastError?: () => Data<string>
164
168
  }
165
169
  }
166
170
 
167
- /* Thermal Printer */
171
+ /* ESC/POS thermal receipt printer control via Bluetooth or USB */
168
172
  export type GeneratorThermalPrinter = Generator &
169
173
  GeneratorThermalPrinterDef & {
170
174
  templateKey: 'GENERATOR_THERMAL_PRINTER'
171
- switches: Array<
175
+ switches?: Array<
172
176
  SwitchDef &
173
177
  GeneratorThermalPrinterDef & {
174
178
  conds?: Array<{
@@ -1,4 +1,7 @@
1
- /* Auto generated by build script */
1
+ /* Auto generated by build script
2
+ *
3
+ * Periodic timer that triggers events at a configurable interval
4
+ */
2
5
  import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
3
6
  import type { Data, DataLink } from '../data'
4
7
  import type {
@@ -10,6 +13,7 @@ import type {
10
13
  Action,
11
14
  EventProperty,
12
15
  } from '../common'
16
+ import type { TemplateEventPropsMap } from '../../utils/event-props'
13
17
 
14
18
  /* Start the tick */
15
19
  export type GeneratorTickAction_ = Action & {
@@ -44,23 +48,23 @@ Default property:
44
48
  }
45
49
  events?: {
46
50
  /* Event for each tick start */
47
- ticking?: Array<EventAction>
51
+ ticking?: Array<EventAction<string & keyof TemplateEventPropsMap['Tick']['ticking']>>
48
52
  /* Event for tick completed */
49
- completed?: Array<EventAction>
53
+ completed?: Array<EventAction<string & keyof TemplateEventPropsMap['Tick']['completed']>>
50
54
  }
51
55
  outlets?: {
52
56
  /* Countdown step value */
53
- countdown?: () => Data
57
+ countdown?: () => Data<string | number>
54
58
  /* Is tick running? */
55
- running?: () => Data
59
+ running?: () => Data<boolean | string | number>
56
60
  }
57
61
  }
58
62
 
59
- /* Execute event in countdown manner */
63
+ /* Periodic timer that triggers events at a configurable interval */
60
64
  export type GeneratorTick = Generator &
61
65
  GeneratorTickDef & {
62
66
  templateKey: 'GENERATOR_TICK'
63
- switches: Array<
67
+ switches?: Array<
64
68
  SwitchDef &
65
69
  GeneratorTickDef & {
66
70
  conds?: Array<{
@@ -1,4 +1,7 @@
1
- /* Auto generated by build script */
1
+ /* Auto generated by build script
2
+ *
3
+ * UDP socket communication
4
+ */
2
5
  import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
3
6
  import type { Data, DataLink } from '../data'
4
7
  import type {
@@ -10,6 +13,7 @@ import type {
10
13
  Action,
11
14
  EventProperty,
12
15
  } from '../common'
16
+ import type { TemplateEventPropsMap } from '../../utils/event-props'
13
17
 
14
18
  /* Bind UDP port */
15
19
  export type GeneratorUDPActionBind = Action & {
@@ -72,27 +76,32 @@ Default property:
72
76
  /* Event of UDP port is binded */
73
77
  onReady?: Array<EventAction>
74
78
  /* Event of receive data */
75
- onData?: Array<EventAction>
79
+ onData?: Array<EventAction<string & keyof TemplateEventPropsMap['Udp']['onData']>>
76
80
  /* Event of socket closeed */
77
81
  onClose?: Array<EventAction>
78
82
  /* Event of socket error */
79
- onError?: Array<EventAction>
83
+ onError?: Array<EventAction<string & keyof TemplateEventPropsMap['Udp']['onError']>>
80
84
  }
81
85
  outlets?: {
82
86
  /* Local UDP binded port */
83
- port?: () => Data
87
+ port?: () => Data<number>
84
88
  /* Last received packet */
85
- lastReceive?: () => Data
89
+ lastReceive?: () => Data<{
90
+ address?: string
91
+ port?: number
92
+ data?: any
93
+ [key: string]: any
94
+ }>
86
95
  /* Error message */
87
- errorMessage?: () => Data
96
+ errorMessage?: () => Data<string>
88
97
  }
89
98
  }
90
99
 
91
- /* TCP Server */
100
+ /* UDP socket communication */
92
101
  export type GeneratorUDP = Generator &
93
102
  GeneratorUDPDef & {
94
103
  templateKey: 'GENERATOR_UDP'
95
- switches: Array<
104
+ switches?: Array<
96
105
  SwitchDef &
97
106
  GeneratorUDPDef & {
98
107
  conds?: Array<{
@@ -1,4 +1,7 @@
1
- /* Auto generated by build script */
1
+ /* Auto generated by build script
2
+ *
3
+ * Local Voice Activity Detection (VAD) inference based on GGML and [whisper.rn](https://github.com/mybigday/whisper.rn)
4
+ */
2
5
  import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
3
6
  import type { Data, DataLink } from '../data'
4
7
  import type {
@@ -10,6 +13,7 @@ import type {
10
13
  Action,
11
14
  EventProperty,
12
15
  } from '../common'
16
+ import type { TemplateEventPropsMap } from '../../utils/event-props'
13
17
 
14
18
  /* Load the model */
15
19
  export type GeneratorVadInferenceActionLoadModel = Action & {
@@ -127,14 +131,14 @@ Default property:
127
131
  }
128
132
  */
129
133
  property?: {
130
- /* Initialize the VAD context on generator initialization
134
+ /* Initialize the VAD context on generator initialization
131
135
  Please note that it will take some RAM depending on the model size */
132
136
  init?: boolean | DataLink
133
- /* Use model name, currently only supports the Silero VAD model.
137
+ /* Use model name, currently only supports the Silero VAD model.
134
138
  The model download progress will be done in preload stage or the generator initialization stage.
135
139
  You can also choose `custom` option and set `Model URL` and `Model SHA1` to use your own model */
136
140
  modelName?: 'custom' | 'silero-v6.2.0' | 'silero-v5.1.2' | DataLink
137
- /* The URL or path of model
141
+ /* The URL or path of model
138
142
  We used `ggml` format model, please refer to https://huggingface.co/ggml-org/whisper-vad */
139
143
  modelUrl?: string | DataLink
140
144
  /* Hash type of model */
@@ -157,7 +161,7 @@ Default property:
157
161
  detectSpeechPadMs?: number | DataLink
158
162
  /* Overlap between analysis windows (0.0-1.0) */
159
163
  detectSamplesOverlap?: number | DataLink
160
- /* The file URL or path to be analyzed.
164
+ /* The file URL or path to be analyzed.
161
165
  It only supported `wav` format with 16kHz sample rate & single (mono) channel */
162
166
  detectFileUrl?: string | DataLink
163
167
  /* MD5 of file to be analyzed */
@@ -165,23 +169,56 @@ Default property:
165
169
  }
166
170
  events?: {
167
171
  /* Event triggered when context state changes */
168
- onContextStateChange?: Array<EventAction>
172
+ onContextStateChange?: Array<
173
+ EventAction<string & keyof TemplateEventPropsMap['VadInference']['onContextStateChange']>
174
+ >
169
175
  /* Event triggered when error occurs */
170
- onError?: Array<EventAction>
176
+ onError?: Array<EventAction<string & keyof TemplateEventPropsMap['VadInference']['onError']>>
171
177
  /* Event triggered when got detection result */
172
- onDetected?: Array<EventAction>
178
+ onDetected?: Array<
179
+ EventAction<string & keyof TemplateEventPropsMap['VadInference']['onDetected']>
180
+ >
173
181
  }
174
182
  outlets?: {
175
183
  /* Context state */
176
- contextState?: () => Data
184
+ contextState?: () => Data<string>
177
185
  /* Context details */
178
- contextDetails?: () => Data
186
+ contextDetails?: () => Data<{
187
+ state?: string
188
+ contextId?: string
189
+ gpu?: string
190
+ reasonNoGPU?: string
191
+ [key: string]: any
192
+ }>
179
193
  /* Is detecting */
180
- isDetecting?: () => Data
194
+ isDetecting?: () => Data<boolean>
181
195
  /* Detection segments result */
182
- detectionSegments?: () => Data
196
+ detectionSegments?: () => Data<
197
+ Array<{
198
+ start?: number
199
+ end?: number
200
+ confidence?: number
201
+ t0?: number
202
+ t1?: number
203
+ [key: string]: any
204
+ }>
205
+ >
183
206
  /* Detection details */
184
- detectionDetails?: () => Data
207
+ detectionDetails?: () => Data<{
208
+ result?: string
209
+ segments?: Array<{
210
+ start?: number
211
+ end?: number
212
+ confidence?: number
213
+ t0?: number
214
+ t1?: number
215
+ [key: string]: any
216
+ }>
217
+ time?: number
218
+ startTime?: number
219
+ endTime?: number
220
+ [key: string]: any
221
+ }>
185
222
  }
186
223
  }
187
224
 
@@ -189,7 +226,7 @@ Default property:
189
226
  export type GeneratorVadInference = Generator &
190
227
  GeneratorVadInferenceDef & {
191
228
  templateKey: 'GENERATOR_VAD_INFERENCE'
192
- switches: Array<
229
+ switches?: Array<
193
230
  SwitchDef &
194
231
  GeneratorVadInferenceDef & {
195
232
  conds?: Array<{
@@ -1,4 +1,8 @@
1
- /* Auto generated by build script */
1
+ /* Auto generated by build script
2
+ *
3
+ * Local Voice Activity Detection (VAD) inference based on [transformers.js](https://huggingface.co/docs/transformers.js)
4
+ * You can use any compatible VAD model from HuggingFace (Silero VAD, smart-turn, etc.)
5
+ */
2
6
  import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
3
7
  import type { Data, DataLink } from '../data'
4
8
  import type {
@@ -10,6 +14,7 @@ import type {
10
14
  Action,
11
15
  EventProperty,
12
16
  } from '../common'
17
+ import type { TemplateEventPropsMap } from '../../utils/event-props'
13
18
 
14
19
  /* Load the model */
15
20
  export type GeneratorVadInferenceOnnxActionLoadModel = Action & {
@@ -142,12 +147,12 @@ Default property:
142
147
  detectMaxSpeechDurationS?: number | DataLink
143
148
  /* Padding around speech segments in milliseconds */
144
149
  detectSpeechPadMs?: number | DataLink
145
- /* Executor candidates, descending order of priority
150
+ /* Executor candidates, descending order of priority
146
151
  Default will be xnnpack, wasm, cpu */
147
152
  executors?:
148
153
  | Array<'qnn' | 'dml' | 'nnapi' | 'xnnpack' | 'coreml' | 'cpu' | 'wasm' | 'webgpu' | DataLink>
149
154
  | DataLink
150
- /* Execution mode
155
+ /* Execution mode
151
156
  Usually when the model has many branches, setting this option to `parallel` will give you better performance. */
152
157
  executionMode?: 'sequential' | 'parallel' | DataLink
153
158
  /* QNN backend */
@@ -159,30 +164,55 @@ Default property:
159
164
  }
160
165
  events?: {
161
166
  /* Event triggered when context state changes */
162
- onContextStateChange?: Array<EventAction>
167
+ onContextStateChange?: Array<
168
+ EventAction<string & keyof TemplateEventPropsMap['OnnxVad']['onContextStateChange']>
169
+ >
163
170
  /* Event triggered when error occurs */
164
- onError?: Array<EventAction>
171
+ onError?: Array<EventAction<string & keyof TemplateEventPropsMap['OnnxVad']['onError']>>
165
172
  /* Event triggered when got detection result */
166
- onDetected?: Array<EventAction>
173
+ onDetected?: Array<EventAction<string & keyof TemplateEventPropsMap['OnnxVad']['onDetected']>>
167
174
  }
168
175
  outlets?: {
169
176
  /* Context state */
170
- contextState?: () => Data
177
+ contextState?: () => Data<string>
171
178
  /* Is detecting */
172
- isDetecting?: () => Data
179
+ isDetecting?: () => Data<boolean>
173
180
  /* Detection segments result */
174
- detectionSegments?: () => Data
181
+ detectionSegments?: () => Data<
182
+ Array<{
183
+ start?: number
184
+ end?: number
185
+ confidence?: number
186
+ t0?: number
187
+ t1?: number
188
+ [key: string]: any
189
+ }>
190
+ >
175
191
  /* Detection details */
176
- detectionDetails?: () => Data
192
+ detectionDetails?: () => Data<{
193
+ result?: string
194
+ segments?: Array<{
195
+ start?: number
196
+ end?: number
197
+ confidence?: number
198
+ t0?: number
199
+ t1?: number
200
+ [key: string]: any
201
+ }>
202
+ time?: number
203
+ startTime?: number
204
+ endTime?: number
205
+ [key: string]: any
206
+ }>
177
207
  }
178
208
  }
179
209
 
180
- /* Local Voice Activity Detection (VAD) inference based on [transformers.js](https://huggingface.co/docs/transformers.js)
210
+ /* Local Voice Activity Detection (VAD) inference based on [transformers.js](https://huggingface.co/docs/transformers.js)
181
211
  You can use any compatible VAD model from HuggingFace (Silero VAD, smart-turn, etc.) */
182
212
  export type GeneratorVadInferenceOnnx = Generator &
183
213
  GeneratorVadInferenceOnnxDef & {
184
214
  templateKey: 'GENERATOR_ONNX_VAD'
185
- switches: Array<
215
+ switches?: Array<
186
216
  SwitchDef &
187
217
  GeneratorVadInferenceOnnxDef & {
188
218
  conds?: Array<{