-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from sipherxyz/develop
Release v1.0.6
- Loading branch information
Showing
7 changed files
with
318 additions
and
76 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { app } from '../../../scripts/app.js'; | ||
import { ComfyWidgets } from '../../../scripts/widgets.js'; | ||
|
||
import { | ||
addKVState, | ||
chainCallback, | ||
hideWidgetForGood, | ||
addWidgetChangeCallback, | ||
} from './utils.js'; | ||
|
||
function addTextSwitchCaseWidget(nodeType) { | ||
chainCallback(nodeType.prototype, 'onNodeCreated', function () { | ||
const dataWidget = this.widgets.find((w) => w.name === 'switch_cases'); | ||
const delimiterWidget = this.widgets.find((w) => w.name === 'delimiter'); | ||
this.widgets = this.widgets.filter((w) => w.name !== 'condition'); | ||
|
||
let conditionCombo = null; | ||
|
||
const updateConditionCombo = () => { | ||
if (!delimiterWidget.value) return; | ||
|
||
const cases = (dataWidget.value ?? '') | ||
.split('\n') | ||
.filter((line) => line.includes(delimiterWidget.value)) | ||
.map((line) => line.split(delimiterWidget.value)[0]); | ||
|
||
if (!conditionCombo) { | ||
conditionCombo = ComfyWidgets['COMBO'](this, 'condition', [ | ||
['__default__', ...(cases ?? [])], | ||
]).widget; | ||
} else { | ||
conditionCombo.options.values = ['__default__', ...cases]; | ||
} | ||
}; | ||
|
||
updateConditionCombo(); | ||
dataWidget.inputEl.addEventListener('input', updateConditionCombo); | ||
addWidgetChangeCallback(delimiterWidget, updateConditionCombo); | ||
}); | ||
} | ||
|
||
app.registerExtension({ | ||
name: 'ArtVenture.TextSwitchCase', | ||
async beforeRegisterNodeDef(nodeType, nodeData) { | ||
if (!nodeData) return; | ||
if (nodeData.name !== 'TextSwitchCase') { | ||
return; | ||
} | ||
|
||
addKVState(nodeType); | ||
addTextSwitchCaseWidget(nodeType); | ||
}, | ||
}); |
This file contains 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.