bizydraft 0.2.82.dev20251209023307__py3-none-any.whl → 0.2.83.dev20251203095346__py3-none-any.whl

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.
@@ -1,146 +0,0 @@
1
- import { app } from "../../../scripts/app.js";
2
-
3
- // 简单的链式callback实现
4
- function chainCallback(originalCallback, newCallback) {
5
- return function (...args) {
6
- if (originalCallback) {
7
- originalCallback.apply(this, args);
8
- }
9
- newCallback.apply(this, args);
10
- };
11
- }
12
-
13
- // 统一的函数:初始化动态输入相关的 widgets
14
- function initializeDynamicInputs(node) {
15
- // 只处理目标节点类型
16
- if (
17
- node.type !== "BizyAir_Seedream4_5" &&
18
- node.type !== "BizyAir_NanoBananaPro" &&
19
- node.type !== "BizyAir_NanoBananaProOfficial"
20
- ) {
21
- return;
22
- }
23
-
24
- node._type = "IMAGE";
25
-
26
- if (!node.inputs) {
27
- node.inputs = [];
28
- }
29
-
30
- // 先检查是否存在 inputcount widget
31
- let inputCountWidget = node.widgets?.find(
32
- (w) => w.name === "inputcount"
33
- );
34
-
35
- // 如果不存在,先创建 inputcount widget(在按钮之前创建,确保显示顺序)
36
- if (!inputCountWidget) {
37
- // 计算当前 IMAGE 类型输入数量
38
- const currentImageInputs = node.inputs.filter(
39
- (input) => input.type === node._type
40
- ).length;
41
- // 创建 inputcount widget,默认值为当前输入数量或1
42
- // 使用 precision: 0 确保是整数类型
43
- inputCountWidget = node.addWidget(
44
- "number",
45
- "inputcount",
46
- currentImageInputs || 1,
47
- null,
48
- {
49
- min: 1,
50
- max: 10,
51
- step: 10, // 旧参数(兼容性),是 step2 的 10 倍
52
- step2: 1, // 新参数,实际的步长
53
- precision: 0, // 设置为 0 表示整数
54
- }
55
- );
56
- }
57
-
58
- // 检查是否已经存在 "Update inputs" 按钮,避免重复添加
59
- const updateButton = node.widgets?.find(
60
- (w) => w.name === "Update inputs"
61
- );
62
- if (updateButton) {
63
- return; // 已经存在,不需要重复添加
64
- }
65
-
66
- // 然后添加 "Update inputs" 按钮(会在 inputcount 之后显示)
67
- node.addWidget("button", "Update inputs", null, () => {
68
- if (!node.inputs) {
69
- node.inputs = [];
70
- }
71
-
72
- // 查找 inputcount widget
73
- const inputCountWidget = node.widgets?.find(
74
- (w) => w.name === "inputcount"
75
- );
76
-
77
- // 如果仍然找不到,创建它
78
- if (!inputCountWidget) {
79
- const currentImageInputs = node.inputs.filter(
80
- (input) => input.type === node._type
81
- ).length;
82
- node.addWidget(
83
- "number",
84
- "inputcount",
85
- currentImageInputs || 1,
86
- null,
87
- {
88
- min: 1,
89
- max: 10,
90
- step: 10, // 旧参数(兼容性),是 step2 的 10 倍
91
- step2: 1, // 新参数,实际的步长
92
- precision: 0, // 设置为 0 表示整数
93
- }
94
- );
95
- return;
96
- }
97
-
98
- const target_number_of_inputs = inputCountWidget.value || 1;
99
- const num_inputs = node.inputs.filter(
100
- (input) => input.type === node._type
101
- ).length;
102
-
103
- if (target_number_of_inputs === num_inputs) {
104
- return; // already set, do nothing
105
- }
106
-
107
- if (target_number_of_inputs < num_inputs) {
108
- const inputs_to_remove = num_inputs - target_number_of_inputs;
109
- for (let i = 0; i < inputs_to_remove; i++) {
110
- node.removeInput(node.inputs.length - 1);
111
- }
112
- } else {
113
- for (let i = num_inputs + 1; i <= target_number_of_inputs; ++i) {
114
- node.addInput(`image_${i}`, node._type, { shape: 7 });
115
- }
116
- }
117
- });
118
- }
119
-
120
- app.registerExtension({
121
- name: "bizyair.dynamicImageInputs",
122
- async beforeRegisterNodeDef(nodeType, nodeData, app) {
123
- // 只处理目标节点类型
124
- if (
125
- nodeData.name !== "BizyAir_Seedream4_5" &&
126
- nodeData.name !== "BizyAir_NanoBananaPro" &&
127
- nodeData.name !== "BizyAir_NanoBananaProOfficial"
128
- ) {
129
- return;
130
- }
131
-
132
- // 使用 chainCallback 设置 onConfigure,确保在节点配置完成后也初始化 widgets
133
- const originalOnConfigure = nodeType.prototype.onConfigure;
134
- nodeType.prototype.onConfigure = chainCallback(
135
- originalOnConfigure,
136
- function (info) {
137
- // 在 configure 完成后初始化 widgets
138
- initializeDynamicInputs(this);
139
- }
140
- );
141
- },
142
- nodeCreated(node) {
143
- // 在节点创建时也初始化 widgets(用于首次创建节点时)
144
- initializeDynamicInputs(node);
145
- },
146
- });
@@ -1,129 +0,0 @@
1
- import { app } from "../../../scripts/app.js";
2
-
3
- // 简单的链式callback实现(类似useChainCallback)
4
- function chainCallback(originalCallback, newCallback) {
5
- return function (...args) {
6
- if (originalCallback) {
7
- originalCallback.apply(this, args);
8
- }
9
- newCallback.apply(this, args);
10
- };
11
- }
12
-
13
- app.registerExtension({
14
- name: "bizyair.hailuo.limitTimeRange",
15
- nodeCreated(node, app) {
16
- console.log(node.title);
17
- // 只处理 BizyAir_Hailuo2_3_T2V 节点
18
- if (
19
- node.title !== "☁️BizyAir Hailuo2.3 Image To Video" &&
20
- node.title !== "☁️BizyAir Hailuo2.3 Text To Video"
21
- ) {
22
- return;
23
- }
24
- console.log(node.title , `开始处理`);
25
- // 延迟执行,确保 widget 完全初始化
26
- setTimeout(() => {
27
- try {
28
- const resolutionWidget = node.widgets?.find(
29
- (w) => w.name === "resolution"
30
- );
31
- const durationWidget = node.widgets?.find((w) => w.name === "duration");
32
-
33
- if (!resolutionWidget || !durationWidget) {
34
- console.warn("[Hailuo2_3_T2V] 未找到 resolution 或 duration widget");
35
- return;
36
- }
37
-
38
- // 保存 duration widget 的原始选项值
39
- const originalDurationValues = durationWidget.options?.values
40
- ? Array.isArray(durationWidget.options.values)
41
- ? [...durationWidget.options.values]
42
- : typeof durationWidget.options.values === "function"
43
- ? durationWidget.options.values()
44
- : []
45
- : [];
46
-
47
- // 如果没有原始值,无法继续
48
- if (!originalDurationValues || originalDurationValues.length === 0) {
49
- console.warn("[Hailuo2_3_T2V] duration widget 没有可用的选项值");
50
- return;
51
- }
52
-
53
- // 更新 duration 选项的函数
54
- const updateDurationOptions = () => {
55
- const resolutionValue = resolutionWidget.value;
56
- // 支持 "1080p"、"1080P" 等大小写变体
57
- const is1080p =
58
- resolutionValue === "1080p" ||
59
- resolutionValue === "1080P" ||
60
- String(resolutionValue).toUpperCase() === "1080P";
61
-
62
- // 直接修改 widget.options.values 数组
63
- if (!durationWidget.options) {
64
- durationWidget.options = {};
65
- }
66
-
67
- if (is1080p) {
68
- // 如果是 1080p,从 values 数组中删除 10
69
- if (Array.isArray(durationWidget.options.values)) {
70
- // 找到 10 的索引并删除
71
- const index = durationWidget.options.values.indexOf(10);
72
- if (index !== -1) {
73
- durationWidget.options.values.splice(index, 1);
74
- }
75
- } else {
76
- // 如果不是数组,重新创建数组并过滤掉 10
77
- durationWidget.options.values = originalDurationValues.filter(
78
- (val) => val !== 10
79
- );
80
- }
81
- } else {
82
- // 如果不是 1080p,恢复原始值(包括 10)
83
- durationWidget.options.values = [...originalDurationValues];
84
- }
85
-
86
- // 检查当前值是否在新的 values 中,如果不在则调整为第一个可用值
87
- const currentValue = durationWidget.value;
88
- const valuesArray = Array.isArray(durationWidget.options.values)
89
- ? durationWidget.options.values
90
- : [];
91
-
92
- if (valuesArray.length > 0 && !valuesArray.includes(currentValue)) {
93
- const newValue = valuesArray[0];
94
- durationWidget.value = newValue;
95
- // 触发 callback
96
- if (durationWidget.callback) {
97
- durationWidget.callback.call(durationWidget, newValue);
98
- }
99
- }
100
-
101
- // 触发节点和画布更新,确保 UI 刷新
102
- if (node.setDirtyCanvas) {
103
- node.setDirtyCanvas(true, true);
104
- }
105
- if (node.graph && node.graph.setDirtyCanvas) {
106
- node.graph.setDirtyCanvas(true, true);
107
- }
108
- };
109
-
110
- // 保存原始的 resolution callback
111
- const originalResolutionCallback = resolutionWidget.callback;
112
-
113
- // 使用 chainCallback 包装 resolution callback,监听变化
114
- resolutionWidget.callback = chainCallback(
115
- originalResolutionCallback,
116
- function (value) {
117
- // 更新 duration 选项
118
- updateDurationOptions();
119
- }
120
- );
121
-
122
- // 初始化时执行一次,确保选项正确
123
- updateDurationOptions();
124
- } catch (error) {
125
- console.error("[Hailuo2_3_T2V] 初始化时间范围限制失败:", error);
126
- }
127
- }, 200);
128
- },
129
- });