@fugood/bricks-project 2.22.0-beta.9 → 2.22.1

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 (85) hide show
  1. package/compile/action-name-map.ts +108 -17
  2. package/compile/index.ts +10 -1
  3. package/package.json +3 -4
  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 +19 -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/Tcp.ts +120 -0
  67. package/types/generators/TcpServer.ts +137 -0
  68. package/types/generators/TextToSpeechGgml.ts +182 -0
  69. package/types/generators/TextToSpeechOnnx.ts +169 -0
  70. package/types/generators/TextToSpeechOpenAiLike.ts +113 -0
  71. package/types/generators/ThermalPrinter.ts +185 -0
  72. package/types/generators/Tick.ts +75 -0
  73. package/types/generators/Udp.ts +109 -0
  74. package/types/generators/VadGgml.ts +211 -0
  75. package/types/generators/VectorStore.ts +223 -0
  76. package/types/generators/Watchdog.ts +96 -0
  77. package/types/generators/WebCrawler.ts +97 -0
  78. package/types/generators/WebRtc.ts +165 -0
  79. package/types/generators/WebSocket.ts +142 -0
  80. package/types/generators/index.ts +50 -0
  81. package/types/system.ts +64 -0
  82. package/utils/data.ts +45 -0
  83. package/utils/event-props.ts +89 -13
  84. package/types/bricks.ts +0 -3168
  85. package/types/generators.ts +0 -7633
@@ -0,0 +1,182 @@
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 GeneratorGGMLTTSActionLoadModel = Action & {
14
+ __actionName: 'GENERATOR_GGML_TTS_LOAD_MODEL'
15
+ }
16
+
17
+ /* Generate audio */
18
+ export type GeneratorGGMLTTSActionGenerate = ActionWithParams & {
19
+ __actionName: 'GENERATOR_GGML_TTS_GENERATE'
20
+ params?: Array<{
21
+ input: 'text'
22
+ value?: string | DataLink | EventProperty
23
+ mapping?: string
24
+ }>
25
+ }
26
+
27
+ /* Clean cache */
28
+ export type GeneratorGGMLTTSActionCleanCache = Action & {
29
+ __actionName: 'GENERATOR_GGML_TTS_CLEAN_CACHE'
30
+ }
31
+
32
+ /* Release context */
33
+ export type GeneratorGGMLTTSActionReleaseContext = Action & {
34
+ __actionName: 'GENERATOR_GGML_TTS_RELEASE_CONTEXT'
35
+ }
36
+
37
+ /* Cancel current generation and clear queue */
38
+ export type GeneratorGGMLTTSActionCancel = Action & {
39
+ __actionName: 'GENERATOR_GGML_TTS_CANCEL'
40
+ }
41
+
42
+ interface GeneratorGGMLTTSDef {
43
+ /*
44
+ Default property:
45
+ {
46
+ "vocoderUrl": "https://huggingface.co/ggml-org/WavTokenizer/resolve/main/WavTokenizer-Large-75-F16.gguf",
47
+ "vocoderHashType": "sha256",
48
+ "vocoderHash": "2356baa8631cc2995ea3465196a017a2733600d849a91180c0f97fa7fb375bbe",
49
+ "vocoderBatchSize": 4096,
50
+ "outputType": "play",
51
+ "cacheGenerated": true,
52
+ "autoInferEnable": false,
53
+ "softBreakRegex": "^[^\\r\\n\\t\\f\\v]*([\\r\\n]+|[。!?!?.]\\B)",
54
+ "hardBreakTime": 500,
55
+ "completionTemperature": 0.1,
56
+ "completionRepetitionPenalty": 1.1,
57
+ "completionTopK": 40,
58
+ "completionTopP": 0.9,
59
+ "completionMinP": 0.05,
60
+ "useGuideToken": true,
61
+ "contextSize": 8192,
62
+ "batchSize": 8192,
63
+ "microBatchSize": 512,
64
+ "maxThreads": 2,
65
+ "accelVariant": "default",
66
+ "mainGpu": 0,
67
+ "gpuLayers": 0,
68
+ "useMlock": true,
69
+ "useMmap": true,
70
+ "useFlashAttn": "off"
71
+ }
72
+ */
73
+ property?: {
74
+ /* Initialize the TTS context on generator initialization */
75
+ init?: boolean | DataLink
76
+ /* The URL or path of model
77
+ We used GGUF format model, please refer to https://github.com/ggerganov/llama.cpp/tree/master#description */
78
+ modelUrl?: string | DataLink
79
+ /* Hash type of model */
80
+ modelHashType?: 'md5' | 'sha256' | 'sha1' | DataLink
81
+ /* Hash of model */
82
+ modelHash?: string | DataLink
83
+ /* The URL or path of vocoder model */
84
+ vocoderUrl?: string | DataLink
85
+ /* Hash type of vocoder model */
86
+ vocoderHashType?: 'md5' | 'sha256' | 'sha1' | DataLink
87
+ /* Hash of vocoder model */
88
+ vocoderHash?: string | DataLink
89
+ /* Batch size of vocoder model */
90
+ vocoderBatchSize?: number | DataLink
91
+ /* Output mode */
92
+ outputType?: 'play' | 'file' | DataLink
93
+ /* Enable cache for generated audio */
94
+ cacheGenerated?: boolean | DataLink
95
+ /* Text to generate */
96
+ prompt?: string | DataLink
97
+ /* Speaker JSON */
98
+ speaker?: {} | DataLink
99
+ /* Auto inference when prompt changes */
100
+ autoInferEnable?: boolean | DataLink
101
+ /* Segmentation rule for auto inference */
102
+ softBreakRegex?: string | DataLink
103
+ /* Time to force inference when softBreakRegex is not satisfied */
104
+ hardBreakTime?: number | DataLink
105
+ /* Temperature */
106
+ completionTemperature?: number | DataLink
107
+ /* Repetition Penalty */
108
+ completionRepetitionPenalty?: number | DataLink
109
+ /* Top K sampling */
110
+ completionTopK?: number | DataLink
111
+ /* Top P sampling */
112
+ completionTopP?: number | DataLink
113
+ /* Min P sampling */
114
+ completionMinP?: number | DataLink
115
+ /* Set the random number generator (RNG) seed (default: -1, -1 = random seed) */
116
+ completionSeed?: number | DataLink
117
+ /* Number of tokens to predict */
118
+ completionPredict?: number | DataLink
119
+ /* Enable guide token to help prevent hallucinations by forcing the TTS to use the correct words. */
120
+ useGuideToken?: boolean | DataLink
121
+ /* Context size, for OutTTS recommended 4096 ~ 8192 (Default to 4096) */
122
+ contextSize?: number | DataLink
123
+ /* Logical batch size for prompt processing */
124
+ batchSize?: number | DataLink
125
+ /* Physical batch size for prompt processing */
126
+ microBatchSize?: number | DataLink
127
+ /* Number of threads */
128
+ maxThreads?: number | DataLink
129
+ /* Accelerator variant (Only for desktop)
130
+ `default` - CPU / Metal (macOS)
131
+ `vulkan` - Use Vulkan
132
+ `cuda` - Use CUDA */
133
+ accelVariant?: 'default' | 'vulkan' | 'cuda' | DataLink
134
+ /* Main GPU index */
135
+ mainGpu?: number | DataLink
136
+ /* Number of GPU layers (NOTE: Currently not supported for Android) */
137
+ gpuLayers?: number | DataLink
138
+ /* Use memory lock */
139
+ useMlock?: boolean | DataLink
140
+ /* Use mmap */
141
+ useMmap?: boolean | DataLink
142
+ /* Use Flash Attention for inference (Recommended with GPU enabled) */
143
+ useFlashAttn?: 'auto' | 'on' | 'off' | DataLink
144
+ }
145
+ events?: {
146
+ /* Event triggered when state change */
147
+ onContextStateChange?: Array<EventAction>
148
+ /* Event triggered when error occurs */
149
+ onError?: Array<EventAction>
150
+ }
151
+ outlets?: {
152
+ /* Context state */
153
+ contextState?: () => Data
154
+ /* Generated audio file */
155
+ generatedAudio?: () => Data
156
+ /* Generated audio file is playing */
157
+ generatedAudioPlaying?: () => Data
158
+ }
159
+ }
160
+
161
+ /* Local Text-to-Speech (TTS) inference based on GGML and [llama.cpp](https://github.com/ggerganov/llama.cpp)
162
+ You can use any converted model on HuggingFace. */
163
+ export type GeneratorGGMLTTS = Generator &
164
+ GeneratorGGMLTTSDef & {
165
+ templateKey: 'GENERATOR_GGML_TTS'
166
+ switches: Array<
167
+ SwitchDef &
168
+ GeneratorGGMLTTSDef & {
169
+ conds?: Array<{
170
+ method: '==' | '!=' | '>' | '<' | '>=' | '<='
171
+ cond:
172
+ | SwitchCondInnerStateCurrentCanvas
173
+ | SwitchCondData
174
+ | {
175
+ __typename: 'SwitchCondInnerStateOutlet'
176
+ outlet: 'contextState' | 'generatedAudio' | 'generatedAudioPlaying'
177
+ value: any
178
+ }
179
+ }>
180
+ }
181
+ >
182
+ }
@@ -0,0 +1,169 @@
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 GeneratorTTSActionLoadModel = Action & {
14
+ __actionName: 'GENERATOR_TTS_LOAD_MODEL'
15
+ }
16
+
17
+ /* Generate audio */
18
+ export type GeneratorTTSActionGenerate = ActionWithParams & {
19
+ __actionName: 'GENERATOR_TTS_GENERATE'
20
+ params?: Array<{
21
+ input: 'text'
22
+ value?: string | DataLink | EventProperty
23
+ mapping?: string
24
+ }>
25
+ }
26
+
27
+ /* Clean cache */
28
+ export type GeneratorTTSActionCleanCache = Action & {
29
+ __actionName: 'GENERATOR_TTS_CLEAN_CACHE'
30
+ }
31
+
32
+ /* Release context */
33
+ export type GeneratorTTSActionReleaseContext = Action & {
34
+ __actionName: 'GENERATOR_TTS_RELEASE_CONTEXT'
35
+ }
36
+
37
+ /* Cancel current generation and clear queue */
38
+ export type GeneratorTTSActionCancel = Action & {
39
+ __actionName: 'GENERATOR_TTS_CANCEL'
40
+ }
41
+
42
+ interface GeneratorTTSDef {
43
+ /*
44
+ Default property:
45
+ {
46
+ "model": "BricksDisplay/vits-eng",
47
+ "modelType": "auto",
48
+ "vocoderModel": "speecht5_hifigan",
49
+ "maxLength": 4096,
50
+ "temperature": 0.1,
51
+ "repetitionPenalty": 1.1,
52
+ "doSample": true,
53
+ "outputType": "play",
54
+ "cacheGenerated": true,
55
+ "speed": 1,
56
+ "autoInferEnable": false,
57
+ "softBreakRegex": "^[^\\r\\n\\t\\f\\v]*([\\r\\n]+|[。!?!?.]\\B)",
58
+ "hardBreakTime": 500,
59
+ "executionMode": "sequential"
60
+ }
61
+ */
62
+ property?: {
63
+ /* Initialize the TTS context on generator initialization */
64
+ init?: boolean | DataLink
65
+ /* TTS model
66
+ The mms-tts models are licensed under CC-BY-NC-4.0 */
67
+ model?: string | DataLink
68
+ /* Model type */
69
+ modelType?: string | DataLink
70
+ /* Quantize type */
71
+ quantizeType?:
72
+ | 'auto'
73
+ | 'none'
74
+ | 'fp16'
75
+ | 'q8'
76
+ | 'int8'
77
+ | 'uint8'
78
+ | 'q4'
79
+ | 'bnb4'
80
+ | 'q4f16'
81
+ | DataLink
82
+ /* Vocoder model for SpeechT5 */
83
+ vocoderModel?: 'Custom' | 'speecht5_hifigan' | DataLink
84
+ /* Custom vocoder model
85
+ Choose model from https://huggingface.co/models?library=transformers.js&other=hifigan */
86
+ customVocoderModel?: string | DataLink
87
+ /* Speaker embedding, for SpeechT5 or StyleTTS (Kokoro) */
88
+ speakerEmbedUrl?: string | DataLink
89
+ /* Hash of `speakerEmbedUrl` */
90
+ speakerEmbedHash?: string | DataLink
91
+ /* Hash type of `speakerEmbedUrl` */
92
+ speakerEmbedHashType?: 'md5' | 'sha256' | 'sha1' | DataLink
93
+ /* Speaker config, for OuteTTS model */
94
+ speakerConfig?: {} | DataLink
95
+ /* Audio token generation max length */
96
+ maxLength?: number | DataLink
97
+ /* Audio token generation temperature */
98
+ temperature?: number | DataLink
99
+ /* Audio token generation repetition penalty */
100
+ repetitionPenalty?: number | DataLink
101
+ /* Use greedy sampling for audio token generation */
102
+ doSample?: boolean | DataLink
103
+ /* Output mode */
104
+ outputType?: 'play' | 'file' | DataLink
105
+ /* Enable cache for generated audio */
106
+ cacheGenerated?: boolean | DataLink
107
+ /* Speed of the generated audio, for StyleTTS (Kokoro) */
108
+ speed?: number | DataLink
109
+ /* Text to generate */
110
+ prompt?: string | DataLink
111
+ /* Auto inference when prompt changes */
112
+ autoInferEnable?: boolean | DataLink
113
+ /* Segmentation rule for auto inference */
114
+ softBreakRegex?: string | DataLink
115
+ /* Time to force inference when softBreakRegex is not satisfied */
116
+ hardBreakTime?: number | DataLink
117
+ /* Executor candidates, descending order of priority
118
+ Default will be xnnpack, wasm, cpu */
119
+ executors?:
120
+ | Array<'qnn' | 'dml' | 'nnapi' | 'xnnpack' | 'coreml' | 'cpu' | 'wasm' | 'webgpu' | DataLink>
121
+ | DataLink
122
+ /* Execution mode
123
+ Usually when the model has many branches, setting this option to `parallel` will give you better performance. */
124
+ executionMode?: 'sequential' | 'parallel' | DataLink
125
+ /* QNN backend */
126
+ qnnBackend?: 'HTP' | 'HTA' | 'DSP' | 'GPU' | 'CPU' | DataLink
127
+ /* Enable FP16 for QNN HTP */
128
+ qnnHtpEnableFp16?: boolean | DataLink
129
+ /* Enable QNN debug */
130
+ qnnEnableDebug?: boolean | DataLink
131
+ }
132
+ events?: {
133
+ /* Event triggered when state change */
134
+ onContextStateChange?: Array<EventAction>
135
+ /* Event triggered when error occurs */
136
+ onError?: Array<EventAction>
137
+ }
138
+ outlets?: {
139
+ /* Context state */
140
+ contextState?: () => Data
141
+ /* Generated audio file */
142
+ generatedAudio?: () => Data
143
+ /* Generated audio file is playing */
144
+ generatedAudioPlaying?: () => Data
145
+ }
146
+ }
147
+
148
+ /* Local Text-to-Speech (TTS) inference based on ONNX Runtime and [transformers.js](https://huggingface.co/docs/transformers.js)
149
+ You can use any converted model on HuggingFace. */
150
+ export type GeneratorTTS = Generator &
151
+ GeneratorTTSDef & {
152
+ templateKey: 'GENERATOR_TTS'
153
+ switches: Array<
154
+ SwitchDef &
155
+ GeneratorTTSDef & {
156
+ conds?: Array<{
157
+ method: '==' | '!=' | '>' | '<' | '>=' | '<='
158
+ cond:
159
+ | SwitchCondInnerStateCurrentCanvas
160
+ | SwitchCondData
161
+ | {
162
+ __typename: 'SwitchCondInnerStateOutlet'
163
+ outlet: 'contextState' | 'generatedAudio' | 'generatedAudioPlaying'
164
+ value: any
165
+ }
166
+ }>
167
+ }
168
+ >
169
+ }
@@ -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
+ /* Generate audio */
13
+ export type GeneratorOpenAiTTSActionGenerate = ActionWithParams & {
14
+ __actionName: 'GENERATOR_OPENAI_TTS_GENERATE'
15
+ params?: Array<{
16
+ input: 'text'
17
+ value?: string | DataLink | EventProperty
18
+ mapping?: string
19
+ }>
20
+ }
21
+
22
+ /* Clean cache */
23
+ export type GeneratorOpenAiTTSActionCleanCache = Action & {
24
+ __actionName: 'GENERATOR_OPENAI_TTS_CLEAN_CACHE'
25
+ }
26
+
27
+ /* Cancel current generation and clear queue */
28
+ export type GeneratorOpenAiTTSActionCancel = Action & {
29
+ __actionName: 'GENERATOR_OPENAI_TTS_CANCEL'
30
+ }
31
+
32
+ interface GeneratorOpenAiTTSDef {
33
+ /*
34
+ Default property:
35
+ {
36
+ "apiEndpoint": "https://api.openai.com/v1",
37
+ "model": "tts-1",
38
+ "voice": "alloy",
39
+ "speed": 1,
40
+ "outputType": "play",
41
+ "playbackVolume": 100,
42
+ "cacheGenerated": true,
43
+ "autoInferEnable": false,
44
+ "softBreakRegex": "^[^\\r\\n\\t\\f\\v]*([\\r\\n]+|[。!?!?.]\\B)",
45
+ "hardBreakTime": 500
46
+ }
47
+ */
48
+ property?: {
49
+ /* API endpoint URL */
50
+ apiEndpoint?: string | DataLink
51
+ /* OpenAI API Key */
52
+ apiKey?: string | DataLink
53
+ /* OpenAI TTS model */
54
+ model?: string | DataLink
55
+ /* Voice to use
56
+ Select voice from https://openai.fm , default alloy */
57
+ voice?: string | DataLink
58
+ /* Additional instructions for the speech generation */
59
+ instructions?: string | DataLink
60
+ /* Speed of the generated audio */
61
+ speed?: number | DataLink
62
+ /* Output mode */
63
+ outputType?: 'play' | 'file' | DataLink
64
+ /* Playback volume (0 - 100) */
65
+ playbackVolume?: number | DataLink
66
+ /* Enable cache for generated audio */
67
+ cacheGenerated?: boolean | DataLink
68
+ /* Text to generate */
69
+ prompt?: string | DataLink
70
+ /* Auto inference when prompt changes */
71
+ autoInferEnable?: boolean | DataLink
72
+ /* Segmentation rule for auto inference */
73
+ softBreakRegex?: string | DataLink
74
+ /* Time to force inference when softBreakRegex is not satisfied */
75
+ hardBreakTime?: number | DataLink
76
+ }
77
+ events?: {
78
+ /* Event triggered when state change */
79
+ onContextStateChange?: Array<EventAction>
80
+ /* Event triggered when error occurs */
81
+ onError?: Array<EventAction>
82
+ }
83
+ outlets?: {
84
+ /* Context state */
85
+ contextState?: () => Data
86
+ /* Generated audio file */
87
+ generatedAudio?: () => Data
88
+ /* Generated audio file is playing */
89
+ generatedAudioPlaying?: () => Data
90
+ }
91
+ }
92
+
93
+ /* Generate speech from text using OpenAI's Text-to-Speech API */
94
+ export type GeneratorOpenAiTTS = Generator &
95
+ GeneratorOpenAiTTSDef & {
96
+ templateKey: 'GENERATOR_OPENAI_TTS'
97
+ switches: Array<
98
+ SwitchDef &
99
+ GeneratorOpenAiTTSDef & {
100
+ conds?: Array<{
101
+ method: '==' | '!=' | '>' | '<' | '>=' | '<='
102
+ cond:
103
+ | SwitchCondInnerStateCurrentCanvas
104
+ | SwitchCondData
105
+ | {
106
+ __typename: 'SwitchCondInnerStateOutlet'
107
+ outlet: 'contextState' | 'generatedAudio' | 'generatedAudioPlaying'
108
+ value: any
109
+ }
110
+ }>
111
+ }
112
+ >
113
+ }
@@ -0,0 +1,185 @@
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
+ /* Init thermal printer connection */
13
+ export type GeneratorThermalPrinterActionInit = Action & {
14
+ __actionName: 'GENERATOR_THERMAL_PRINTER_INIT'
15
+ }
16
+
17
+ /* Scan thermal printer */
18
+ export type GeneratorThermalPrinterActionScan = Action & {
19
+ __actionName: 'GENERATOR_THERMAL_PRINTER_SCAN'
20
+ }
21
+
22
+ /* Dispose thermal printer connection */
23
+ export type GeneratorThermalPrinterActionDispose = Action & {
24
+ __actionName: 'GENERATOR_THERMAL_PRINTER_DISPOSE'
25
+ }
26
+
27
+ /* Start print */
28
+ export type GeneratorThermalPrinterActionPrint = ActionWithParams & {
29
+ __actionName: 'GENERATOR_THERMAL_PRINTER_PRINT'
30
+ params?: Array<
31
+ | {
32
+ input: 'options'
33
+ value?: {} | DataLink | EventProperty
34
+ mapping?: string
35
+ }
36
+ | {
37
+ input: 'payload'
38
+ value?: Array<any> | DataLink | EventProperty
39
+ mapping?: string
40
+ }
41
+ | {
42
+ input: 'rawCommands'
43
+ value?: string | DataLink | EventProperty
44
+ mapping?: string
45
+ }
46
+ >
47
+ }
48
+
49
+ /* Check thermal printer status */
50
+ export type GeneratorThermalPrinterActionCheckStatus = Action & {
51
+ __actionName: 'GENERATOR_THERMAL_PRINTER_CHECK_STATUS'
52
+ }
53
+
54
+ interface GeneratorThermalPrinterDef {
55
+ /*
56
+ Default property:
57
+ {
58
+ "init": false,
59
+ "lang": "ANK",
60
+ "scanTimeout": 5000,
61
+ "stateUpdateInterval": 5000,
62
+ "cutMode": "PARTIAL"
63
+ }
64
+ */
65
+ property?: {
66
+ /* Connect printer on generator initialized */
67
+ init?: boolean | DataLink
68
+ /* Connection driver */
69
+ driver?: 'escpos' | 'star' | 'tsc' | DataLink
70
+ /* The address of the printer */
71
+ connectString?: string | DataLink
72
+ /* The language of the printer (only for EPSON) */
73
+ lang?: 'ANK' | 'CHINESE' | 'TAIWAN' | 'KOREAN' | 'THAI' | 'SOUTHASIA' | DataLink
74
+ /* The timeout of scanning */
75
+ scanTimeout?: number | DataLink
76
+ /* State update interval, 0 means no update automatically */
77
+ stateUpdateInterval?: number | DataLink
78
+ /* Enable page mode on printing */
79
+ pageMode?: boolean | DataLink
80
+ /* Printable page area width */
81
+ pageWidth?: number | DataLink
82
+ /* Printable page area height */
83
+ pageHeight?: number | DataLink
84
+ /* Cut mode at the end of printing */
85
+ cutMode?: 'NONE' | 'FULL' | 'PARTIAL' | DataLink
86
+ /* Print payload
87
+ example:
88
+ { type: 'text', content: 'Hello, World!' }
89
+ { type: 'feed', feedLines: 1 }
90
+ { type: 'reverse-feed', feedLines: 1 }
91
+ { type: 'image', content: '/path/to/file' }
92
+ { type: 'line-space', lineSpace: 1 }
93
+ { type: 'barcode', content: '1234567890', barcodeType: 'CODE128' }
94
+ { type: 'symbol', content: '1234567890', symbolType: 'QRCODE' }
95
+ Notes:
96
+ - `reverse-feed` only works on ESC/POS driver
97
+ - `width` and `height` in Star driver is magnification factor
98
+ - `y` position in ESC/POS is use feed lines to offset
99
+ - `textFont` only works on TSC driver */
100
+ payload?:
101
+ | Array<
102
+ | DataLink
103
+ | {
104
+ type?:
105
+ | 'text'
106
+ | 'image'
107
+ | 'barcode'
108
+ | 'qrcode'
109
+ | 'line-space'
110
+ | 'feed'
111
+ | 'reverse-feed'
112
+ | DataLink
113
+ content?: string | DataLink
114
+ width?: number | DataLink
115
+ height?: number | DataLink
116
+ x?: number | DataLink
117
+ y?: number | DataLink
118
+ align?: 'LEFT' | 'CENTER' | 'RIGHT' | DataLink
119
+ textSmooth?: boolean | DataLink
120
+ textEmphasize?: boolean | DataLink
121
+ textUnderline?: boolean | DataLink
122
+ textLang?: 'EN' | 'JA' | 'ZH_CN' | 'ZH_TW' | 'KO' | 'TH' | 'VI' | 'MULTI' | DataLink
123
+ textFont?: string | DataLink
124
+ barcodeType?:
125
+ | 'CODE39'
126
+ | 'CODE93'
127
+ | 'CODE128'
128
+ | 'EAN13'
129
+ | 'JAN13'
130
+ | 'EAN8'
131
+ | 'JAN8'
132
+ | 'UPC_A'
133
+ | 'UPC_E'
134
+ | 'ITF'
135
+ | DataLink
136
+ barcodeHRI?: 'OFF' | 'ABOVE' | 'BELOW' | 'BOTH' | DataLink
137
+ qrcodeModel?: '1' | '2' | DataLink
138
+ qrcodeSize?: number | DataLink
139
+ qrcodeLevel?: 'L' | 'M' | 'Q' | 'H' | DataLink
140
+ qrcodeMask?: 'S0' | 'S1' | 'S2' | 'S3' | 'S4' | 'S5' | 'S6' | 'S7' | DataLink
141
+ feedLines?: number | DataLink
142
+ lineSpace?: number | DataLink
143
+ }
144
+ >
145
+ | DataLink
146
+ /* Raw ASCII commands to print */
147
+ rawCommands?: string | DataLink
148
+ }
149
+ events?: {
150
+ /* Event of connection error */
151
+ onError?: Array<EventAction>
152
+ }
153
+ outlets?: {
154
+ /* Is thermal printer initialized */
155
+ initialized?: () => Data
156
+ /* Thermal printer status */
157
+ status?: () => Data
158
+ /* Discovered devices */
159
+ discoveredDevices?: () => Data
160
+ /* Last error message */
161
+ lastError?: () => Data
162
+ }
163
+ }
164
+
165
+ /* Thermal Printer */
166
+ export type GeneratorThermalPrinter = Generator &
167
+ GeneratorThermalPrinterDef & {
168
+ templateKey: 'GENERATOR_THERMAL_PRINTER'
169
+ switches: Array<
170
+ SwitchDef &
171
+ GeneratorThermalPrinterDef & {
172
+ conds?: Array<{
173
+ method: '==' | '!=' | '>' | '<' | '>=' | '<='
174
+ cond:
175
+ | SwitchCondInnerStateCurrentCanvas
176
+ | SwitchCondData
177
+ | {
178
+ __typename: 'SwitchCondInnerStateOutlet'
179
+ outlet: 'initialized' | 'status' | 'discoveredDevices' | 'lastError'
180
+ value: any
181
+ }
182
+ }>
183
+ }
184
+ >
185
+ }