@fugood/bricks-project 2.22.0-beta.8 → 2.22.0

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 (86) hide show
  1. package/compile/action-name-map.ts +112 -1
  2. package/compile/index.ts +10 -1
  3. package/package.json +3 -3
  4. package/tools/postinstall.ts +16 -9
  5. package/types/animation.ts +2 -1
  6. package/types/brick-base.ts +79 -0
  7. package/types/bricks/3DViewer.ts +200 -0
  8. package/types/bricks/Camera.ts +195 -0
  9. package/types/bricks/Chart.ts +362 -0
  10. package/types/bricks/GenerativeMedia.ts +240 -0
  11. package/types/bricks/Icon.ts +93 -0
  12. package/types/bricks/Image.ts +104 -0
  13. package/types/bricks/Items.ts +461 -0
  14. package/types/bricks/Lottie.ts +159 -0
  15. package/types/bricks/QrCode.ts +112 -0
  16. package/types/bricks/Rect.ts +110 -0
  17. package/types/bricks/RichText.ts +123 -0
  18. package/types/bricks/Rive.ts +209 -0
  19. package/types/bricks/Slideshow.ts +155 -0
  20. package/types/bricks/Svg.ts +94 -0
  21. package/types/bricks/Text.ts +143 -0
  22. package/types/bricks/TextInput.ts +231 -0
  23. package/types/bricks/Video.ts +170 -0
  24. package/types/bricks/VideoStreaming.ts +107 -0
  25. package/types/bricks/WebRtcStream.ts +60 -0
  26. package/types/bricks/WebView.ts +157 -0
  27. package/types/bricks/index.ts +20 -0
  28. package/types/common.ts +8 -3
  29. package/types/data.ts +6 -0
  30. package/types/generators/AlarmClock.ts +102 -0
  31. package/types/generators/Assistant.ts +546 -0
  32. package/types/generators/BleCentral.ts +225 -0
  33. package/types/generators/BlePeripheral.ts +202 -0
  34. package/types/generators/CanvasMap.ts +57 -0
  35. package/types/generators/CastlesPay.ts +77 -0
  36. package/types/generators/DataBank.ts +123 -0
  37. package/types/generators/File.ts +351 -0
  38. package/types/generators/GraphQl.ts +124 -0
  39. package/types/generators/Http.ts +117 -0
  40. package/types/generators/HttpServer.ts +164 -0
  41. package/types/generators/Information.ts +97 -0
  42. package/types/generators/Intent.ts +107 -0
  43. package/types/generators/Iterator.ts +95 -0
  44. package/types/generators/Keyboard.ts +85 -0
  45. package/types/generators/LlmAnthropicCompat.ts +188 -0
  46. package/types/generators/LlmGgml.ts +719 -0
  47. package/types/generators/LlmOnnx.ts +184 -0
  48. package/types/generators/LlmOpenAiCompat.ts +206 -0
  49. package/types/generators/LlmQualcommAiEngine.ts +213 -0
  50. package/types/generators/Mcp.ts +294 -0
  51. package/types/generators/McpServer.ts +248 -0
  52. package/types/generators/MediaFlow.ts +142 -0
  53. package/types/generators/MqttBroker.ts +121 -0
  54. package/types/generators/MqttClient.ts +129 -0
  55. package/types/generators/Question.ts +395 -0
  56. package/types/generators/RealtimeTranscription.ts +180 -0
  57. package/types/generators/RerankerGgml.ts +153 -0
  58. package/types/generators/SerialPort.ts +141 -0
  59. package/types/generators/SoundPlayer.ts +86 -0
  60. package/types/generators/SoundRecorder.ts +113 -0
  61. package/types/generators/SpeechToTextGgml.ts +462 -0
  62. package/types/generators/SpeechToTextOnnx.ts +227 -0
  63. package/types/generators/SpeechToTextPlatform.ts +75 -0
  64. package/types/generators/SqLite.ts +118 -0
  65. package/types/generators/Step.ts +101 -0
  66. package/types/generators/TapToPayOnIPhone.ts +175 -0
  67. package/types/generators/Tcp.ts +120 -0
  68. package/types/generators/TcpServer.ts +137 -0
  69. package/types/generators/TextToSpeechGgml.ts +182 -0
  70. package/types/generators/TextToSpeechOnnx.ts +169 -0
  71. package/types/generators/TextToSpeechOpenAiLike.ts +113 -0
  72. package/types/generators/ThermalPrinter.ts +185 -0
  73. package/types/generators/Tick.ts +75 -0
  74. package/types/generators/Udp.ts +109 -0
  75. package/types/generators/VadGgml.ts +211 -0
  76. package/types/generators/VectorStore.ts +223 -0
  77. package/types/generators/Watchdog.ts +96 -0
  78. package/types/generators/WebCrawler.ts +97 -0
  79. package/types/generators/WebRtc.ts +165 -0
  80. package/types/generators/WebSocket.ts +142 -0
  81. package/types/generators/index.ts +51 -0
  82. package/types/system.ts +64 -0
  83. package/utils/data.ts +45 -0
  84. package/utils/event-props.ts +89 -0
  85. package/types/bricks.ts +0 -3168
  86. package/types/generators.ts +0 -7580
@@ -0,0 +1,180 @@
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
+ EventProperty,
10
+ } from '../common'
11
+
12
+ /* Start realtime transcription */
13
+ export type GeneratorRealtimeTranscriptionActionStart = Action & {
14
+ __actionName: 'GENERATOR_REALTIME_TRANSCRIPTION_START'
15
+ }
16
+
17
+ /* Stop realtime transcription */
18
+ export type GeneratorRealtimeTranscriptionActionStop = Action & {
19
+ __actionName: 'GENERATOR_REALTIME_TRANSCRIPTION_STOP'
20
+ }
21
+
22
+ /* Force move to next slice */
23
+ export type GeneratorRealtimeTranscriptionActionNextSlice = Action & {
24
+ __actionName: 'GENERATOR_REALTIME_TRANSCRIPTION_NEXT_SLICE'
25
+ }
26
+
27
+ /* Reset transcriber state */
28
+ export type GeneratorRealtimeTranscriptionActionReset = Action & {
29
+ __actionName: 'GENERATOR_REALTIME_TRANSCRIPTION_RESET'
30
+ }
31
+
32
+ interface GeneratorRealtimeTranscriptionDef {
33
+ /*
34
+ Default property:
35
+ {
36
+ "sttLivePolicy": "only-in-use",
37
+ "vadInferenceLivePolicy": "only-in-use",
38
+ "vadEnabled": true,
39
+ "audioSliceSec": 30,
40
+ "audioMinSec": 1,
41
+ "maxSlicesInMemory": 5,
42
+ "vadStrategy": "use-preset",
43
+ "vadPreset": "default",
44
+ "autoSliceOnSpeechEnd": true,
45
+ "autoSliceThreshold": 2,
46
+ "initialPrompt": "",
47
+ "promptPreviousSlices": false,
48
+ "saveAudio": true,
49
+ "testMode": false,
50
+ "testPlaybackSpeed": 1,
51
+ "testChunkDurationMs": 100,
52
+ "testLoop": false,
53
+ "beginTranscribeEnabled": false,
54
+ "beginTranscribeScript": "\/\* Global variable: inputs = { sliceIndex, duration, vadEvent, variables } \*\/\nreturn true"
55
+ }
56
+ */
57
+ property?: {
58
+ /* STT Generator for Whisper context */
59
+ sttGeneratorId?: string | DataLink
60
+ /* STT Live Policy. If the policy is `only-in-use`, the STT context will be released when not in use. */
61
+ sttLivePolicy?: 'only-in-use' | 'manual' | DataLink
62
+ /* VAD Inference Generator for voice activity detection */
63
+ vadInferenceGeneratorId?: string | DataLink
64
+ /* VAD Inference Live Policy. If the policy is `only-in-use`, the VAD Inference context will be released when not in use. */
65
+ vadInferenceLivePolicy?: 'only-in-use' | 'manual' | DataLink
66
+ /* Enable VAD (Voice Activity Detection) */
67
+ vadEnabled?: boolean | DataLink
68
+ /* Audio slice duration in seconds */
69
+ audioSliceSec?: number | DataLink
70
+ /* Minimum audio duration to start transcription in seconds */
71
+ audioMinSec?: number | DataLink
72
+ /* Maximum number of slices to keep in memory */
73
+ maxSlicesInMemory?: number | DataLink
74
+ /* VAD Strategy */
75
+ vadStrategy?: 'use-preset' | 'use-generator-options' | DataLink
76
+ /* VAD preset configuration */
77
+ vadPreset?:
78
+ | 'default'
79
+ | 'sensitive'
80
+ | 'very-sensitive'
81
+ | 'conservative'
82
+ | 'very-conservative'
83
+ | 'continuous-speech'
84
+ | 'meeting'
85
+ | 'noisy-environment'
86
+ | DataLink
87
+ /* Auto slice on speech end */
88
+ autoSliceOnSpeechEnd?: boolean | DataLink
89
+ /* Auto slice threshold in seconds */
90
+ autoSliceThreshold?: number | DataLink
91
+ /* Initial prompt for transcription */
92
+ initialPrompt?: string | DataLink
93
+ /* Include previous slices in prompt */
94
+ promptPreviousSlices?: boolean | DataLink
95
+ /* Enable audio output saving (auto-generates file path) */
96
+ saveAudio?: boolean | DataLink
97
+ /* Use test mode with file simulation */
98
+ testMode?: boolean | DataLink
99
+ /* Test audio file path for simulation */
100
+ testFilePath?: string | DataLink
101
+ /* Test audio file hash */
102
+ testFileHash?: string | DataLink
103
+ /* Test audio file hash type */
104
+ testFileHashType?: string | DataLink
105
+ /* Test playback speed */
106
+ testPlaybackSpeed?: number | DataLink
107
+ /* Test chunk duration in milliseconds */
108
+ testChunkDurationMs?: number | DataLink
109
+ /* Loop test audio file */
110
+ testLoop?: boolean | DataLink
111
+ /* Enable Begin Transcribe Script to determine transcription */
112
+ beginTranscribeEnabled?: boolean | DataLink
113
+ /* Script to determine whether to proceed with transcription */
114
+ beginTranscribeScript?: string | DataLink
115
+ /* Data to be used in Begin Transcribe Script (object) */
116
+ beginTranscribeScriptData?: {} | DataLink
117
+ }
118
+ events?: {
119
+ /* Event triggered when transcription starts, processes, or ends */
120
+ onTranscribe?: Array<EventAction>
121
+ /* Event triggered on VAD (Voice Activity Detection) events */
122
+ onVad?: Array<EventAction>
123
+ /* Event triggered when error occurs */
124
+ onError?: Array<EventAction>
125
+ /* Event triggered when status changes */
126
+ onStatusChange?: Array<EventAction>
127
+ /* Event triggered when statistics update */
128
+ onStatsUpdate?: Array<EventAction>
129
+ /* Event triggered when transcription ends */
130
+ onEnd?: Array<EventAction>
131
+ }
132
+ outlets?: {
133
+ /* Is realtime transcription currently active */
134
+ isActive?: () => Data
135
+ /* Is currently transcribing audio */
136
+ isTranscribing?: () => Data
137
+ /* Current transcription results */
138
+ results?: () => Data
139
+ /* Current transcription result text */
140
+ resultText?: () => Data
141
+ /* Current statistics */
142
+ statistics?: () => Data
143
+ /* Latest transcribe event */
144
+ lastTranscribeEvent?: () => Data
145
+ /* Latest VAD event */
146
+ lastVadEvent?: () => Data
147
+ /* Audio output file path (auto-generated when saving audio) */
148
+ audioOutputPath?: () => Data
149
+ }
150
+ }
151
+
152
+ /* Realtime speech-to-text transcription using Whisper and VAD with live audio streaming */
153
+ export type GeneratorRealtimeTranscription = Generator &
154
+ GeneratorRealtimeTranscriptionDef & {
155
+ templateKey: 'GENERATOR_REALTIME_TRANSCRIPTION'
156
+ switches: Array<
157
+ SwitchDef &
158
+ GeneratorRealtimeTranscriptionDef & {
159
+ conds?: Array<{
160
+ method: '==' | '!=' | '>' | '<' | '>=' | '<='
161
+ cond:
162
+ | SwitchCondInnerStateCurrentCanvas
163
+ | SwitchCondData
164
+ | {
165
+ __typename: 'SwitchCondInnerStateOutlet'
166
+ outlet:
167
+ | 'isActive'
168
+ | 'isTranscribing'
169
+ | 'results'
170
+ | 'resultText'
171
+ | 'statistics'
172
+ | 'lastTranscribeEvent'
173
+ | 'lastVadEvent'
174
+ | 'audioOutputPath'
175
+ value: any
176
+ }
177
+ }>
178
+ }
179
+ >
180
+ }
@@ -0,0 +1,153 @@
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
+ EventProperty,
10
+ } from '../common'
11
+
12
+ /* Load the model */
13
+ export type GeneratorRerankerActionLoadModel = Action & {
14
+ __actionName: 'GENERATOR_RERANKER_LOAD_MODEL'
15
+ }
16
+
17
+ /* Rerank documents based on query relevance */
18
+ export type GeneratorRerankerActionRerank = ActionWithParams & {
19
+ __actionName: 'GENERATOR_RERANKER_RERANK'
20
+ params?: Array<
21
+ | {
22
+ input: 'query'
23
+ value?: string | DataLink | EventProperty
24
+ mapping?: string
25
+ }
26
+ | {
27
+ input: 'documents'
28
+ value?: Array<any> | DataLink | EventProperty
29
+ mapping?: string
30
+ }
31
+ >
32
+ }
33
+
34
+ /* Release context */
35
+ export type GeneratorRerankerActionReleaseContext = Action & {
36
+ __actionName: 'GENERATOR_RERANKER_RELEASE_CONTEXT'
37
+ }
38
+
39
+ interface GeneratorRerankerDef {
40
+ /*
41
+ Default property:
42
+ {
43
+ "init": false,
44
+ "contextSize": 512,
45
+ "batchSize": 512,
46
+ "uBatchSize": 512,
47
+ "accelVariant": "default",
48
+ "mainGpu": 0,
49
+ "gpuLayers": 0,
50
+ "useMlock": true,
51
+ "useMmap": true,
52
+ "normalize": 1
53
+ }
54
+ */
55
+ property?: {
56
+ /* Initialize the Reranker context on generator initialization */
57
+ init?: boolean | DataLink
58
+ /* The URL or path of reranker model (GGUF format) */
59
+ modelUrl?: string | DataLink
60
+ /* Hash of reranker model */
61
+ modelHash?: string | DataLink
62
+ /* Hash type of reranker model */
63
+ modelHashType?: 'md5' | 'sha256' | 'sha1' | DataLink
64
+ /* Context size (0 ~ 4096) (Default to 512) */
65
+ contextSize?: number | DataLink
66
+ /* Logical batch size for processing (default: 512) */
67
+ batchSize?: number | DataLink
68
+ /* Physical maximum batch size (default: 512) */
69
+ uBatchSize?: number | DataLink
70
+ /* Accelerator variant (default: default) */
71
+ accelVariant?:
72
+ | 'default'
73
+ | 'avx'
74
+ | 'avx2'
75
+ | 'avx512'
76
+ | 'metal'
77
+ | 'opencl'
78
+ | 'vulkan'
79
+ | 'cuda'
80
+ | 'rocm'
81
+ | DataLink
82
+ /* Main GPU index (default: 0) */
83
+ mainGpu?: number | DataLink
84
+ /* Number of layers to store in VRAM (default: 0) */
85
+ gpuLayers?: number | DataLink
86
+ /* Maximum number of threads to use (default: auto) */
87
+ maxThreads?: number | DataLink
88
+ /* Use mlock to keep model in memory (default: true) */
89
+ useMlock?: boolean | DataLink
90
+ /* Use mmap for model loading (default: true) */
91
+ useMmap?: boolean | DataLink
92
+ /* Query text for reranking */
93
+ query?: string | DataLink
94
+ /* Array of documents to rerank */
95
+ documents?: Array<string | DataLink> | DataLink
96
+ /* Normalize reranking scores (default: from model config) */
97
+ normalize?: number | DataLink | boolean | DataLink | DataLink
98
+ /* Maximum number of documents to return (default: unlimited) */
99
+ topK?: number | DataLink
100
+ }
101
+ events?: {
102
+ /* Event triggered when the reranker context state changes (loading, ready, error, released) */
103
+ onContextStateChange?: Array<EventAction>
104
+ /* Event triggered when an error occurs during reranker operations */
105
+ onError?: Array<EventAction>
106
+ }
107
+ outlets?: {
108
+ /* Current state of the reranker context (loading, ready, error, released) */
109
+ contextState?: () => Data
110
+ /* Loading progress of the reranker model (0-100) */
111
+ contextLoadProgress?: () => Data
112
+ /* Detailed information about the reranker context including instance ID and processing status */
113
+ contextDetails?: () => Data
114
+ /* Result of the reranking operation containing scored and ranked documents */
115
+ rerankResult?: () => Data
116
+ /* Boolean indicating whether the reranker is currently processing a request */
117
+ isProcessing?: () => Data
118
+ }
119
+ }
120
+
121
+ /* Local rerank based on GGML and [llama.cpp](https://github.com/ggerganov/llama.cpp)
122
+
123
+ ## Notice
124
+ - The device RAM must be larger than 8GB
125
+ - iOS: Supported GPU acceleration, recommended use M1+ / A17+ chip device
126
+ - macOS: Supported GPU acceleration, recommended use M1+ chip device
127
+ - Android: Currently not supported GPU acceleration (Coming soon), recommended use Android 13+ system
128
+ - Linux / Windows: Supported GPU acceleration, currently only Vulkan backend available */
129
+ export type GeneratorReranker = Generator &
130
+ GeneratorRerankerDef & {
131
+ templateKey: 'GENERATOR_RERANKER'
132
+ switches: Array<
133
+ SwitchDef &
134
+ GeneratorRerankerDef & {
135
+ conds?: Array<{
136
+ method: '==' | '!=' | '>' | '<' | '>=' | '<='
137
+ cond:
138
+ | SwitchCondInnerStateCurrentCanvas
139
+ | SwitchCondData
140
+ | {
141
+ __typename: 'SwitchCondInnerStateOutlet'
142
+ outlet:
143
+ | 'contextState'
144
+ | 'contextLoadProgress'
145
+ | 'contextDetails'
146
+ | 'rerankResult'
147
+ | 'isProcessing'
148
+ value: any
149
+ }
150
+ }>
151
+ }
152
+ >
153
+ }
@@ -0,0 +1,141 @@
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
+ EventProperty,
10
+ } from '../common'
11
+
12
+ /* Get available serial devices */
13
+ export type GeneratorSerialPortActionGeneratorSerialGetDeviceList = Action & {
14
+ __actionName: 'GENERATOR_SERIAL_GET_DEVICE_LIST'
15
+ }
16
+
17
+ /* Attach device */
18
+ export type GeneratorSerialPortActionGeneratorSerialAttach = Action & {
19
+ __actionName: 'GENERATOR_SERIAL_ATTACH'
20
+ }
21
+
22
+ /* Dettach device */
23
+ export type GeneratorSerialPortActionGeneratorSerialDetach = Action & {
24
+ __actionName: 'GENERATOR_SERIAL_DETACH'
25
+ }
26
+
27
+ /* Send string data (ASCII) */
28
+ export type GeneratorSerialPortActionGeneratorSerialSendString = ActionWithParams & {
29
+ __actionName: 'GENERATOR_SERIAL_SEND_STRING'
30
+ params?: Array<
31
+ | {
32
+ input: 'generatorSerialStringValue'
33
+ value?: string | DataLink | EventProperty
34
+ mapping?: string
35
+ }
36
+ | {
37
+ input: 'generatorSerialStringEncoding'
38
+ value?: string | DataLink | EventProperty
39
+ mapping?: string
40
+ }
41
+ >
42
+ }
43
+
44
+ /* Send hex string (e.g. 0123456789ABCDEF) */
45
+ export type GeneratorSerialPortActionGeneratorSerialSendHex = ActionWithParams & {
46
+ __actionName: 'GENERATOR_SERIAL_SEND_HEX'
47
+ params?: Array<{
48
+ input: 'generatorSerialHexValue'
49
+ value?: string | DataLink | EventProperty
50
+ mapping?: string
51
+ }>
52
+ }
53
+
54
+ interface GeneratorSerialPortDef {
55
+ /*
56
+ Default property:
57
+ {
58
+ "attachOnInit": false,
59
+ "driver": "fd",
60
+ "parityBit": "none",
61
+ "dataBits": 8,
62
+ "stopBits": 1,
63
+ "commMode": "raw"
64
+ }
65
+ */
66
+ property?: {
67
+ /* Try attach on generator initialized On web require user activation to attach device */
68
+ attachOnInit?: boolean | DataLink
69
+ /* The serial device driver */
70
+ driver?: 'fd' | 'usb' | DataLink
71
+ /* The serial device path e.g. /dev/ttyS0 or /dev/bus/usb/001/001 For desktop and web is device index number */
72
+ path?: string | DataLink
73
+ /* The serial USB vendor id (autoconnect first) */
74
+ vendorId?: number | DataLink
75
+ /* The serial USB product id */
76
+ productId?: number | DataLink
77
+ /* The super user binary path (For Android root permission) */
78
+ suPath?: string | DataLink
79
+ /* The serial device baud rate */
80
+ baudRate?: number | DataLink
81
+ /* The serial device parity bit */
82
+ parityBit?: 'none' | 'odd' | 'even' | DataLink
83
+ /* The serial device data bits */
84
+ dataBits?: number | DataLink
85
+ /* The serial device stop bits */
86
+ stopBits?: number | DataLink
87
+ /* The serial device communication mode */
88
+ commMode?: 'raw' | 'EDC' | 'Regex Match' | DataLink
89
+ /* The regex match pattern for packets */
90
+ regexMatch?: string | DataLink
91
+ }
92
+ events?: {
93
+ /* Event for attach the device */
94
+ generatorSerialOnAttach?: Array<EventAction>
95
+ /* Event for detach the device */
96
+ generatorSerialOnDetach?: Array<EventAction>
97
+ /* Event on error */
98
+ generatorSerialOnError?: Array<EventAction>
99
+ /* Event for receive data */
100
+ generatorSerialOnData?: Array<EventAction>
101
+ }
102
+ outlets?: {
103
+ /* Available serial devices */
104
+ generatorSerialDeviceList?: () => Data
105
+ /* Is serial open */
106
+ generatorSerialIsOpen?: () => Data
107
+ /* Last rerceive data (Base64) */
108
+ generatorSerialLastDataBase64?: () => Data
109
+ /* Last rerceive plain text */
110
+ generatorSerialLastDataString?: () => Data
111
+ /* Error message */
112
+ generatorSerialErrorMessage?: () => Data
113
+ }
114
+ }
115
+
116
+ /* Serial Port Generator (Unsupported iOS) */
117
+ export type GeneratorSerialPort = Generator &
118
+ GeneratorSerialPortDef & {
119
+ templateKey: 'GENERATOR_SERIAL_PORT'
120
+ switches: Array<
121
+ SwitchDef &
122
+ GeneratorSerialPortDef & {
123
+ conds?: Array<{
124
+ method: '==' | '!=' | '>' | '<' | '>=' | '<='
125
+ cond:
126
+ | SwitchCondInnerStateCurrentCanvas
127
+ | SwitchCondData
128
+ | {
129
+ __typename: 'SwitchCondInnerStateOutlet'
130
+ outlet:
131
+ | 'generatorSerialDeviceList'
132
+ | 'generatorSerialIsOpen'
133
+ | 'generatorSerialLastDataBase64'
134
+ | 'generatorSerialLastDataString'
135
+ | 'generatorSerialErrorMessage'
136
+ value: any
137
+ }
138
+ }>
139
+ }
140
+ >
141
+ }
@@ -0,0 +1,86 @@
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
+ EventProperty,
10
+ } from '../common'
11
+
12
+ /* Start playing sound */
13
+ export type GeneratorSoundPlayerActionPlay = Action & {
14
+ __actionName: 'GENERATOR_SOUND_PLAYER_PLAY'
15
+ }
16
+
17
+ /* Pause playing sound */
18
+ export type GeneratorSoundPlayerActionPause = Action & {
19
+ __actionName: 'GENERATOR_SOUND_PLAYER_PAUSE'
20
+ }
21
+
22
+ /* Resume playing sound from pause */
23
+ export type GeneratorSoundPlayerActionResume = Action & {
24
+ __actionName: 'GENERATOR_SOUND_PLAYER_RESUME'
25
+ }
26
+
27
+ /* Stop playing sound */
28
+ export type GeneratorSoundPlayerActionRelease = Action & {
29
+ __actionName: 'GENERATOR_SOUND_PLAYER_RELEASE'
30
+ }
31
+
32
+ interface GeneratorSoundPlayerDef {
33
+ /*
34
+ Default property:
35
+ {
36
+ "loop": false,
37
+ "volume": 100
38
+ }
39
+ */
40
+ property?: {
41
+ /* Sound file path */
42
+ filePath?: string | DataLink
43
+ /* MD5 */
44
+ md5?: string | DataLink
45
+ /* Repeat playback */
46
+ loop?: boolean | DataLink
47
+ /* Sound volume (0 - 100) */
48
+ volume?: number | DataLink
49
+ }
50
+ events?: {
51
+ /* Sound file loaded successfully */
52
+ onLoad?: Array<EventAction>
53
+ /* Sound file load error */
54
+ onLoadError?: Array<EventAction>
55
+ /* Sound playback complete */
56
+ onPlay?: Array<EventAction>
57
+ /* Sound file playback end */
58
+ onEnd?: Array<EventAction>
59
+ }
60
+ outlets?: {
61
+ /* Whether the sound is playing */
62
+ isPlaying?: () => Data
63
+ }
64
+ }
65
+
66
+ /* Play sound, see supported formats at https://developer.android.com/guide/topics/media/media-formats */
67
+ export type GeneratorSoundPlayer = Generator &
68
+ GeneratorSoundPlayerDef & {
69
+ templateKey: 'GENERATOR_SOUND_PLAYER'
70
+ switches: Array<
71
+ SwitchDef &
72
+ GeneratorSoundPlayerDef & {
73
+ conds?: Array<{
74
+ method: '==' | '!=' | '>' | '<' | '>=' | '<='
75
+ cond:
76
+ | SwitchCondInnerStateCurrentCanvas
77
+ | SwitchCondData
78
+ | {
79
+ __typename: 'SwitchCondInnerStateOutlet'
80
+ outlet: 'isPlaying'
81
+ value: any
82
+ }
83
+ }>
84
+ }
85
+ >
86
+ }
@@ -0,0 +1,113 @@
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
+ EventProperty,
10
+ } from '../common'
11
+
12
+ /* Start record */
13
+ export type GeneratorSoundRecorderActionStart = Action & {
14
+ __actionName: 'GENERATOR_SOUND_RECORDER_START'
15
+ }
16
+
17
+ /* Pause record */
18
+ export type GeneratorSoundRecorderActionPause = Action & {
19
+ __actionName: 'GENERATOR_SOUND_RECORDER_PAUSE'
20
+ }
21
+
22
+ /* Resume record */
23
+ export type GeneratorSoundRecorderActionResume = Action & {
24
+ __actionName: 'GENERATOR_SOUND_RECORDER_RESUME'
25
+ }
26
+
27
+ /* Stop record */
28
+ export type GeneratorSoundRecorderActionStop = Action & {
29
+ __actionName: 'GENERATOR_SOUND_RECORDER_STOP'
30
+ }
31
+
32
+ interface GeneratorSoundRecorderDef {
33
+ /*
34
+ Default property:
35
+ {
36
+ "init": false,
37
+ "sampleRate": 32000,
38
+ "bitDepth": "16bit",
39
+ "channels": "stereo",
40
+ "fileRetainTime": 10000,
41
+ "autoCuttingEnable": false,
42
+ "autoCuttingTimeLimit": 0,
43
+ "autoCuttingVocalFreqMin": 75,
44
+ "autoCuttingVocalFreqMax": 900,
45
+ "autoCuttingFreqClarity": 0.5,
46
+ "autoCuttingSpeakSpacing": 0.5
47
+ }
48
+ */
49
+ property?: {
50
+ /* Start record on init (Need user trigger on Web) */
51
+ init?: boolean | DataLink
52
+ /* Record sample rate */
53
+ sampleRate?: number | DataLink
54
+ /* PCM bit depth */
55
+ bitDepth?: '8bit' | '16bit' | DataLink
56
+ /* Audio channels */
57
+ channels?: 'mono' | 'stereo' | DataLink
58
+ /* Record file retain time, avoid memory exhausted */
59
+ fileRetainTime?: number | DataLink
60
+ /* Enable record auto cutting */
61
+ autoCuttingEnable?: boolean | DataLink
62
+ /* Fragment time limit */
63
+ autoCuttingTimeLimit?: number | DataLink
64
+ /* Minimal vocal frequency of cutting fragments */
65
+ autoCuttingVocalFreqMin?: number | DataLink
66
+ /* Maximal vocal frequency of cutting fragments */
67
+ autoCuttingVocalFreqMax?: number | DataLink
68
+ /* Minimum frequency clarity threshold on speaking (0 ~ 1) */
69
+ autoCuttingFreqClarity?: number | DataLink
70
+ /* Minimum volume threshold on speaking */
71
+ autoCuttingVolumeThreshold?: number | DataLink
72
+ /* Speak spacing of cutting fragments */
73
+ autoCuttingSpeakSpacing?: number | DataLink
74
+ }
75
+ events?: {
76
+ /* Event for chunk data (Base64 encoded PCM) */
77
+ chunk?: Array<EventAction>
78
+ /* Event for recorded file */
79
+ recorded?: Array<EventAction>
80
+ }
81
+ outlets?: {
82
+ /* Is recording */
83
+ isRecording?: () => Data
84
+ /* Recorded file path */
85
+ recordedPath?: () => Data
86
+ /* Current auto-cutting detected volume */
87
+ volume?: () => Data
88
+ /* Error message */
89
+ errorMessage?: () => Data
90
+ }
91
+ }
92
+
93
+ /* Record audio (Microphone) */
94
+ export type GeneratorSoundRecorder = Generator &
95
+ GeneratorSoundRecorderDef & {
96
+ templateKey: 'GENERATOR_SOUND_RECORDER'
97
+ switches: Array<
98
+ SwitchDef &
99
+ GeneratorSoundRecorderDef & {
100
+ conds?: Array<{
101
+ method: '==' | '!=' | '>' | '<' | '>=' | '<='
102
+ cond:
103
+ | SwitchCondInnerStateCurrentCanvas
104
+ | SwitchCondData
105
+ | {
106
+ __typename: 'SwitchCondInnerStateOutlet'
107
+ outlet: 'isRecording' | 'recordedPath' | 'volume' | 'errorMessage'
108
+ value: any
109
+ }
110
+ }>
111
+ }
112
+ >
113
+ }