This repository was archived by the owner on Apr 10, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
fix: pixel shift and MQTT connection handling #106
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -290,7 +290,7 @@ export const useMqttStore = create<MqttStore>((set, get) => { | |||||
| protocol: (protocol ?? 'wss') as 'ws' | 'wss', | ||||||
| host, | ||||||
| port: port ? parseInt(String(port), 10) : (protocol ?? 'wss') === 'wss' ? 8883 : 1883, | ||||||
| path: path ?? '/mqtt', | ||||||
| path: path ? (path.startsWith('/') ? path : `/${path}`) : '/mqtt', | ||||||
| }; | ||||||
| } catch (error) { | ||||||
| throw new Error( | ||||||
|
|
@@ -312,31 +312,31 @@ export const useMqttStore = create<MqttStore>((set, get) => { | |||||
| const { protocol, host, port, path } = parseMqttUrl(config.url); | ||||||
| const clientId = `microflow_${appName}_${config.uniqueId}_${Date.now().toString(36)}`; | ||||||
|
|
||||||
| // Construct the full URL for WebSocket connections | ||||||
| // mqtt.js requires the URL as the first argument for proper clientId handling | ||||||
| const url = `${protocol}://${host}:${port}${path}`; | ||||||
|
|
||||||
| console.debug('[MQTT] <connect> Parsed URL:', { | ||||||
| input: config.url, | ||||||
| protocol, | ||||||
| host, | ||||||
| port, | ||||||
| path, | ||||||
| constructedUrl: url, | ||||||
| clientId, | ||||||
| }); | ||||||
|
|
||||||
| // Build connection options (without protocol/host/port/path when using URL) | ||||||
| // Build connection options | ||||||
| // For WebSocket connections, use object form to ensure clientId is properly set | ||||||
| const connectionOptions: mqtt.IClientOptions = { | ||||||
| username: config.username, | ||||||
| password: config.password, | ||||||
| protocol: protocol === 'wss' ? 'wss' : protocol === 'ws' ? 'ws' : 'wss', | ||||||
| hostname: host, | ||||||
| port: port, | ||||||
| path: path, | ||||||
| ...(config.username && { username: config.username }), | ||||||
| ...(config.password && { password: config.password }), | ||||||
| clientId, | ||||||
| // connectTimeout: 30000, // 30 seconds | ||||||
| // keepalive: 60, // 60 seconds | ||||||
| // clean: true, // Start with a clean session | ||||||
| // reconnectPeriod: 1000, // Reconnect after 1 second | ||||||
| // For WSS connections, ensure proper SSL handling | ||||||
| ...(protocol === 'wss' | ||||||
| ...(protocol === 'wss' || protocol === 'ws' | ||||||
|
||||||
| ...(protocol === 'wss' || protocol === 'ws' | |
| ...(protocol === 'wss' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,20 +1,29 @@ | ||||||
| export function transformValueToBoolean(value: unknown) { | ||||||
| if (typeof value === 'boolean') return value; | ||||||
|
|
||||||
| if (typeof value === 'number') return value > 0; | ||||||
|
|
||||||
| const isTruthy = ['1', 'true', 'on', 'yes'].includes(String(value).toLowerCase()); | ||||||
| const isSecretlyPositiveNumber = !Number.isNaN(Number(value)) && Number(value) > 0; | ||||||
|
|
||||||
| return isTruthy || isSecretlyPositiveNumber; | ||||||
| switch (typeof value) { | ||||||
| case 'boolean': | ||||||
| return value; | ||||||
| case 'number': | ||||||
| return value > 0; | ||||||
| case 'string': | ||||||
| const isTruthy = ['1', 'true', 'on', 'yes'].includes(String(value).toLowerCase()); | ||||||
|
||||||
| const isTruthy = ['1', 'true', 'on', 'yes'].includes(String(value).toLowerCase()); | |
| const isTruthy = ['1', 'true', 'on', 'yes'].includes(value.toLowerCase()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The protocol variable is already typed as 'ws' | 'wss' from parseMqttUrl, so this ternary expression is redundant. You can simplify this to just
protocol: protocolor use the shorthandprotocol.