vidfom commited on
Commit
78628bb
·
verified ·
1 Parent(s): fc1e66e

Upload folder using huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .config/.last_opt_in_prompt.yaml +1 -0
  2. .config/.last_survey_prompt.yaml +1 -0
  3. .config/.last_update_check.json +1 -0
  4. .config/active_config +1 -0
  5. .config/config_sentinel +0 -0
  6. .config/configurations/config_default +6 -0
  7. .config/default_configs.db +0 -0
  8. .config/gce +1 -0
  9. .config/hidden_gcloud_config_universe_descriptor_data_cache_configs.db +0 -0
  10. .config/logs/2026.08.24/13.27.25.202777.log +819 -0
  11. .config/logs/2026.08.24/13.27.48.254038.log +5 -0
  12. .config/logs/2026.08.24/13.27.53.584308.log +164 -0
  13. .config/logs/2026.08.24/13.27.54.687874.log +5 -0
  14. .config/logs/2026.08.24/13.28.00.267545.log +8 -0
  15. .config/logs/2026.08.24/13.28.00.789021.log +8 -0
  16. .gitattributes +13 -0
  17. 1/custom_nodes/ComfyUI-Custom-Scripts/.github/workflows/publish.yml +25 -0
  18. 1/custom_nodes/ComfyUI-Custom-Scripts/.gitignore +5 -0
  19. 1/custom_nodes/ComfyUI-Custom-Scripts/LICENSE +21 -0
  20. 1/custom_nodes/ComfyUI-Custom-Scripts/README.md +160 -0
  21. 1/custom_nodes/ComfyUI-Custom-Scripts/__init__.py +25 -0
  22. 1/custom_nodes/ComfyUI-Custom-Scripts/py/autocomplete.py +29 -0
  23. 1/custom_nodes/ComfyUI-Custom-Scripts/py/better_combos.py +172 -0
  24. 1/custom_nodes/ComfyUI-Custom-Scripts/py/constrain_image.py +71 -0
  25. 1/custom_nodes/ComfyUI-Custom-Scripts/py/constrain_image_for_video.py +72 -0
  26. 1/custom_nodes/ComfyUI-Custom-Scripts/py/math_expression.py +252 -0
  27. 1/custom_nodes/ComfyUI-Custom-Scripts/py/model_info.py +115 -0
  28. 1/custom_nodes/ComfyUI-Custom-Scripts/py/play_sound.py +42 -0
  29. 1/custom_nodes/ComfyUI-Custom-Scripts/py/repeater.py +46 -0
  30. 1/custom_nodes/ComfyUI-Custom-Scripts/py/reroute_primitive.py +59 -0
  31. 1/custom_nodes/ComfyUI-Custom-Scripts/py/show_text.py +49 -0
  32. 1/custom_nodes/ComfyUI-Custom-Scripts/py/string_function.py +49 -0
  33. 1/custom_nodes/ComfyUI-Custom-Scripts/py/system_notification.py +41 -0
  34. 1/custom_nodes/ComfyUI-Custom-Scripts/py/text_files.py +204 -0
  35. 1/custom_nodes/ComfyUI-Custom-Scripts/py/workflows.py +61 -0
  36. 1/custom_nodes/ComfyUI-Custom-Scripts/pyproject.toml +13 -0
  37. 1/custom_nodes/ComfyUI-Custom-Scripts/pysssss.default.json +4 -0
  38. 1/custom_nodes/ComfyUI-Custom-Scripts/pysssss.example.json +7 -0
  39. 1/custom_nodes/ComfyUI-Custom-Scripts/pysssss.py +300 -0
  40. 1/custom_nodes/ComfyUI-Custom-Scripts/user/text_file_dirs.json +5 -0
  41. 1/custom_nodes/ComfyUI-Custom-Scripts/web/js/assets/canvas2svg.js +1192 -0
  42. 1/custom_nodes/ComfyUI-Custom-Scripts/web/js/assets/favicon-active.ico +0 -0
  43. 1/custom_nodes/ComfyUI-Custom-Scripts/web/js/assets/favicon.ico +0 -0
  44. 1/custom_nodes/ComfyUI-Custom-Scripts/web/js/assets/no-image.png +0 -0
  45. 1/custom_nodes/ComfyUI-Custom-Scripts/web/js/assets/notify.mp3 +0 -0
  46. 1/custom_nodes/ComfyUI-Custom-Scripts/web/js/autocompleter.js +602 -0
  47. 1/custom_nodes/ComfyUI-Custom-Scripts/web/js/betterCombos.js +534 -0
  48. 1/custom_nodes/ComfyUI-Custom-Scripts/web/js/common/autocomplete.css +62 -0
  49. 1/custom_nodes/ComfyUI-Custom-Scripts/web/js/common/autocomplete.js +692 -0
  50. 1/custom_nodes/ComfyUI-Custom-Scripts/web/js/common/binding.js +244 -0
.config/.last_opt_in_prompt.yaml ADDED
@@ -0,0 +1 @@
 
 
1
+ {}
.config/.last_survey_prompt.yaml ADDED
@@ -0,0 +1 @@
 
 
1
+ last_prompt_time: 1787578073.1355083
.config/.last_update_check.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"last_update_check_time": 1787578074.3213105, "last_update_check_revision": 20260814074256, "notifications": [], "last_nag_times": {}}
.config/active_config ADDED
@@ -0,0 +1 @@
 
 
1
+ default
.config/config_sentinel ADDED
File without changes
.config/configurations/config_default ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ [component_manager]
2
+ disable_update_check = true
3
+
4
+ [compute]
5
+ gce_metadata_read_timeout_sec = 0
6
+
.config/default_configs.db ADDED
Binary file (12.3 kB). View file
 
.config/gce ADDED
@@ -0,0 +1 @@
 
 
1
+ False
.config/hidden_gcloud_config_universe_descriptor_data_cache_configs.db ADDED
Binary file (12.3 kB). View file
 
.config/logs/2026.08.24/13.27.25.202777.log ADDED
@@ -0,0 +1,819 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 2026-08-24 13:27:25,204 DEBUG root Failed to read GCE cache file: [Errno 2] No such file or directory: '/content/.config/gce'
2
+ 2026-08-24 13:27:43,229 DEBUG root Failed to check metadata server: <urlopen error timed out>
3
+ 2026-08-24 13:27:43,231 DEBUG root Loaded Command Group: ['gcloud', 'components']
4
+ 2026-08-24 13:27:43,234 DEBUG root Loaded Command Group: ['gcloud', 'components', 'update']
5
+ 2026-08-24 13:27:43,236 DEBUG root Running [gcloud.components.update] with arguments: [--compile-python: "True", --quiet: "True", COMPONENT-IDS:6: "['core', 'gcloud-deps', 'bq', 'gcloud', 'gcloud-crc32c', 'gsutil']"]
6
+ 2026-08-24 13:27:43,237 INFO ___FILE_ONLY___ Beginning update. This process may take several minutes.
7
+
8
+ 2026-08-24 13:27:43,263 DEBUG root On GCE from memory cache: False
9
+ 2026-08-24 13:27:43,266 DEBUG root On GCE from memory cache: False
10
+ 2026-08-24 13:27:43,268 DEBUG urllib3.connectionpool Starting new HTTPS connection (1): dl.google.com:443
11
+ 2026-08-24 13:27:43,279 DEBUG urllib3.connectionpool https://dl.google.com:443 "GET /dl/cloudsdk/channels/rapid/components-2.json HTTP/1.1" 200 28475
12
+ 2026-08-24 13:27:43,292 INFO ___FILE_ONLY___
13
+
14
+ 2026-08-24 13:27:43,293 INFO ___FILE_ONLY___
15
+ Your current Google Cloud CLI version is: 581.0.0
16
+
17
+ 2026-08-24 13:27:43,293 INFO ___FILE_ONLY___ Installing components from version: 581.0.0
18
+
19
+ 2026-08-24 13:27:43,293 INFO ___FILE_ONLY___
20
+
21
+ 2026-08-24 13:27:43,293 DEBUG root Chosen display Format:table[box,title="These components will be removed."](details.display_name:label=Name:align=left,version.version_string:label=Version:align=right,data.size.size(zero="",min=1048576):label=Size:align=right)
22
+ 2026-08-24 13:27:43,294 DEBUG root Chosen display Format:table[box,title="These components will be updated."](details.display_name:label=Name:align=left,version.version_string:label=Version:align=right,data.size.size(zero="",min=1048576):label=Size:align=right)
23
+ 2026-08-24 13:27:43,294 DEBUG root Chosen display Format:table[box,title="These components will be installed."](details.display_name:label=Name:align=left,version.version_string:label=Version:align=right,data.size.size(zero="",min=1048576):label=Size:align=right)
24
+ 2026-08-24 13:27:43,327 INFO ___FILE_ONLY___ ┌─────────────────────────────────────────────────────────────────────────────┐
25
+ 2026-08-24 13:27:43,327 INFO ___FILE_ONLY___
26
+
27
+ 2026-08-24 13:27:43,327 INFO ___FILE_ONLY___ │ These components will be installed. │
28
+ 2026-08-24 13:27:43,327 INFO ___FILE_ONLY___
29
+
30
+ 2026-08-24 13:27:43,328 INFO ___FILE_ONLY___ ├─────────────────────────────────────────────────────┬────────────┬──────────┤
31
+ 2026-08-24 13:27:43,328 INFO ___FILE_ONLY___
32
+
33
+ 2026-08-24 13:27:43,328 INFO ___FILE_ONLY___ │ Name │ Version │ Size │
34
+ 2026-08-24 13:27:43,328 INFO ___FILE_ONLY___
35
+
36
+ 2026-08-24 13:27:43,328 INFO ___FILE_ONLY___ ├─────────────────────────────────────────────────────┼────────────┼──────────┤
37
+ 2026-08-24 13:27:43,328 INFO ___FILE_ONLY___
38
+
39
+ 2026-08-24 13:27:43,328 INFO ___FILE_ONLY___ │
40
+ 2026-08-24 13:27:43,328 INFO ___FILE_ONLY___ BigQuery Command Line Tool
41
+ 2026-08-24 13:27:43,328 INFO ___FILE_ONLY___
42
+ 2026-08-24 13:27:43,328 INFO ___FILE_ONLY___ │
43
+ 2026-08-24 13:27:43,328 INFO ___FILE_ONLY___ 2.1.37
44
+ 2026-08-24 13:27:43,328 INFO ___FILE_ONLY___
45
+ 2026-08-24 13:27:43,328 INFO ___FILE_ONLY___ │
46
+ 2026-08-24 13:27:43,328 INFO ___FILE_ONLY___ 2.2 MiB
47
+ 2026-08-24 13:27:43,328 INFO ___FILE_ONLY___
48
+ 2026-08-24 13:27:43,329 INFO ___FILE_ONLY___ │
49
+ 2026-08-24 13:27:43,329 INFO ___FILE_ONLY___
50
+
51
+ 2026-08-24 13:27:43,329 INFO ___FILE_ONLY___ │
52
+ 2026-08-24 13:27:43,329 INFO ___FILE_ONLY___ BigQuery Command Line Tool (Platform Specific)
53
+ 2026-08-24 13:27:43,329 INFO ___FILE_ONLY___
54
+ 2026-08-24 13:27:43,329 INFO ___FILE_ONLY___ │
55
+ 2026-08-24 13:27:43,329 INFO ___FILE_ONLY___ 2.1.32
56
+ 2026-08-24 13:27:43,329 INFO ___FILE_ONLY___
57
+ 2026-08-24 13:27:43,329 INFO ___FILE_ONLY___ │
58
+ 2026-08-24 13:27:43,329 INFO ___FILE_ONLY___ < 1 MiB
59
+ 2026-08-24 13:27:43,329 INFO ___FILE_ONLY___
60
+ 2026-08-24 13:27:43,329 INFO ___FILE_ONLY___ │
61
+ 2026-08-24 13:27:43,329 INFO ___FILE_ONLY___
62
+
63
+ 2026-08-24 13:27:43,329 INFO ___FILE_ONLY___ │
64
+ 2026-08-24 13:27:43,330 INFO ___FILE_ONLY___ Bundled Python 3.14 (Platform Specific)
65
+ 2026-08-24 13:27:43,330 INFO ___FILE_ONLY___
66
+ 2026-08-24 13:27:43,330 INFO ___FILE_ONLY___ │
67
+ 2026-08-24 13:27:43,330 INFO ___FILE_ONLY___ 3.14.6
68
+ 2026-08-24 13:27:43,330 INFO ___FILE_ONLY___
69
+ 2026-08-24 13:27:43,330 INFO ___FILE_ONLY___ │
70
+ 2026-08-24 13:27:43,330 INFO ___FILE_ONLY___ 33.0 MiB
71
+ 2026-08-24 13:27:43,330 INFO ___FILE_ONLY___
72
+ 2026-08-24 13:27:43,330 INFO ___FILE_ONLY___ │
73
+ 2026-08-24 13:27:43,330 INFO ___FILE_ONLY___
74
+
75
+ 2026-08-24 13:27:43,330 INFO ___FILE_ONLY___ │
76
+ 2026-08-24 13:27:43,330 INFO ___FILE_ONLY___ Cloud Storage Command Line Tool
77
+ 2026-08-24 13:27:43,330 INFO ___FILE_ONLY___
78
+ 2026-08-24 13:27:43,330 INFO ___FILE_ONLY___ │
79
+ 2026-08-24 13:27:43,330 INFO ___FILE_ONLY___ 5.37
80
+ 2026-08-24 13:27:43,331 INFO ___FILE_ONLY___
81
+ 2026-08-24 13:27:43,331 INFO ___FILE_ONLY___ │
82
+ 2026-08-24 13:27:43,331 INFO ___FILE_ONLY___ 12.4 MiB
83
+ 2026-08-24 13:27:43,331 INFO ___FILE_ONLY___
84
+ 2026-08-24 13:27:43,331 INFO ___FILE_ONLY___ │
85
+ 2026-08-24 13:27:43,331 INFO ___FILE_ONLY___
86
+
87
+ 2026-08-24 13:27:43,331 INFO ___FILE_ONLY___ │
88
+ 2026-08-24 13:27:43,331 INFO ___FILE_ONLY___ Cloud Storage Command Line Tool (Platform Specific)
89
+ 2026-08-24 13:27:43,331 INFO ___FILE_ONLY___
90
+ 2026-08-24 13:27:43,331 INFO ___FILE_ONLY___ │
91
+ 2026-08-24 13:27:43,331 INFO ___FILE_ONLY___ 5.37
92
+ 2026-08-24 13:27:43,331 INFO ___FILE_ONLY___
93
+ 2026-08-24 13:27:43,331 INFO ___FILE_ONLY___ │
94
+ 2026-08-24 13:27:43,331 INFO ___FILE_ONLY___ < 1 MiB
95
+ 2026-08-24 13:27:43,331 INFO ___FILE_ONLY___
96
+ 2026-08-24 13:27:43,331 INFO ___FILE_ONLY___ │
97
+ 2026-08-24 13:27:43,331 INFO ___FILE_ONLY___
98
+
99
+ 2026-08-24 13:27:43,332 INFO ___FILE_ONLY___ │
100
+ 2026-08-24 13:27:43,332 INFO ___FILE_ONLY___ Default set of gcloud commands (Platform Specific)
101
+ 2026-08-24 13:27:43,332 INFO ___FILE_ONLY___
102
+ 2026-08-24 13:27:43,332 INFO ___FILE_ONLY___ │
103
+ 2026-08-24 13:27:43,332 INFO ___FILE_ONLY___ 2026.07.10
104
+ 2026-08-24 13:27:43,332 INFO ___FILE_ONLY___
105
+ 2026-08-24 13:27:43,332 INFO ___FILE_ONLY___ │
106
+ 2026-08-24 13:27:43,332 INFO ___FILE_ONLY___ < 1 MiB
107
+ 2026-08-24 13:27:43,332 INFO ___FILE_ONLY___
108
+ 2026-08-24 13:27:43,332 INFO ___FILE_ONLY___ │
109
+ 2026-08-24 13:27:43,332 INFO ___FILE_ONLY___
110
+
111
+ 2026-08-24 13:27:43,332 INFO ___FILE_ONLY___ │
112
+ 2026-08-24 13:27:43,332 INFO ___FILE_ONLY___ Google Cloud CLI Core Libraries (Platform Specific)
113
+ 2026-08-24 13:27:43,332 INFO ___FILE_ONLY___
114
+ 2026-08-24 13:27:43,332 INFO ___FILE_ONLY___ │
115
+ 2026-08-24 13:27:43,332 INFO ___FILE_ONLY___ 2026.06.05
116
+ 2026-08-24 13:27:43,332 INFO ___FILE_ONLY___
117
+ 2026-08-24 13:27:43,332 INFO ___FILE_ONLY___ │
118
+ 2026-08-24 13:27:43,333 INFO ___FILE_ONLY___ < 1 MiB
119
+ 2026-08-24 13:27:43,333 INFO ___FILE_ONLY___
120
+ 2026-08-24 13:27:43,333 INFO ___FILE_ONLY___ │
121
+ 2026-08-24 13:27:43,333 INFO ___FILE_ONLY___
122
+
123
+ 2026-08-24 13:27:43,333 INFO ___FILE_ONLY___ │
124
+ 2026-08-24 13:27:43,333 INFO ___FILE_ONLY___ Google Cloud CRC32C Hash Tool (Platform Specific)
125
+ 2026-08-24 13:27:43,333 INFO ___FILE_ONLY___
126
+ 2026-08-24 13:27:43,333 INFO ___FILE_ONLY___ │
127
+ 2026-08-24 13:27:43,333 INFO ___FILE_ONLY___ 1.0.0
128
+ 2026-08-24 13:27:43,333 INFO ___FILE_ONLY___
129
+ 2026-08-24 13:27:43,333 INFO ___FILE_ONLY___ │
130
+ 2026-08-24 13:27:43,333 INFO ___FILE_ONLY___ 1.5 MiB
131
+ 2026-08-24 13:27:43,333 INFO ___FILE_ONLY___
132
+ 2026-08-24 13:27:43,333 INFO ___FILE_ONLY___ │
133
+ 2026-08-24 13:27:43,333 INFO ___FILE_ONLY___
134
+
135
+ 2026-08-24 13:27:43,333 INFO ___FILE_ONLY___ │
136
+ 2026-08-24 13:27:43,333 INFO ___FILE_ONLY___ gcloud cli dependencies (Platform Specific)
137
+ 2026-08-24 13:27:43,334 INFO ___FILE_ONLY___
138
+ 2026-08-24 13:27:43,334 INFO ___FILE_ONLY___ │
139
+ 2026-08-24 13:27:43,334 INFO ___FILE_ONLY___ 2021.04.16
140
+ 2026-08-24 13:27:43,334 INFO ___FILE_ONLY___
141
+ 2026-08-24 13:27:43,334 INFO ___FILE_ONLY___ │
142
+ 2026-08-24 13:27:43,334 INFO ___FILE_ONLY___ < 1 MiB
143
+ 2026-08-24 13:27:43,334 INFO ___FILE_ONLY___
144
+ 2026-08-24 13:27:43,334 INFO ___FILE_ONLY___ │
145
+ 2026-08-24 13:27:43,334 INFO ___FILE_ONLY___
146
+
147
+ 2026-08-24 13:27:43,334 INFO ___FILE_ONLY___ └─────────────────────────────────────────────────────┴────────────┴──────────┘
148
+ 2026-08-24 13:27:43,334 INFO ___FILE_ONLY___
149
+
150
+ 2026-08-24 13:27:43,334 INFO ___FILE_ONLY___
151
+
152
+ 2026-08-24 13:27:43,335 DEBUG root On GCE from memory cache: False
153
+ 2026-08-24 13:27:43,336 DEBUG root On GCE from memory cache: False
154
+ 2026-08-24 13:27:43,337 DEBUG urllib3.connectionpool Starting new HTTPS connection (1): dl.google.com:443
155
+ 2026-08-24 13:27:43,352 DEBUG urllib3.connectionpool https://dl.google.com:443 "GET /dl/cloudsdk/channels/rapid/RELEASE_NOTES HTTP/1.1" 200 399308
156
+ 2026-08-24 13:27:43,838 INFO ___FILE_ONLY___ For the latest full release notes, please visit:
157
+ https://cloud.google.com/sdk/release_notes
158
+
159
+
160
+ 2026-08-24 13:27:43,839 INFO ___FILE_ONLY___ Performing in place update...
161
+
162
+
163
+ 2026-08-24 13:27:43,841 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
164
+
165
+ 2026-08-24 13:27:43,842 INFO ___FILE_ONLY___ ╠═ Downloading: BigQuery Command Line Tool ═╣
166
+
167
+ 2026-08-24 13:27:43,842 INFO ___FILE_ONLY___ ╚
168
+ 2026-08-24 13:27:43,843 DEBUG root On GCE from memory cache: False
169
+ 2026-08-24 13:27:43,844 DEBUG root On GCE from memory cache: False
170
+ 2026-08-24 13:27:43,844 DEBUG urllib3.connectionpool Starting new HTTPS connection (1): dl.google.com:443
171
+ 2026-08-24 13:27:43,901 DEBUG urllib3.connectionpool https://dl.google.com:443 "GET /dl/cloudsdk/channels/rapid/components/google-cloud-sdk-bq-20260814074256.tar.gz HTTP/1.1" 200 2286040
172
+ 2026-08-24 13:27:43,927 INFO ___FILE_ONLY___ ═
173
+ 2026-08-24 13:27:43,927 INFO ___FILE_ONLY___ ═
174
+ 2026-08-24 13:27:43,927 INFO ___FILE_ONLY___ ═
175
+ 2026-08-24 13:27:43,928 INFO ___FILE_ONLY___ ═
176
+ 2026-08-24 13:27:43,928 INFO ___FILE_ONLY___ ═
177
+ 2026-08-24 13:27:43,928 INFO ___FILE_ONLY___ ═
178
+ 2026-08-24 13:27:43,928 INFO ___FILE_ONLY___ ═
179
+ 2026-08-24 13:27:43,928 INFO ___FILE_ONLY___ ═
180
+ 2026-08-24 13:27:43,928 INFO ___FILE_ONLY___ ═
181
+ 2026-08-24 13:27:43,928 INFO ___FILE_ONLY___ ═
182
+ 2026-08-24 13:27:43,928 INFO ___FILE_ONLY___ ═
183
+ 2026-08-24 13:27:43,928 INFO ___FILE_ONLY___ ═
184
+ 2026-08-24 13:27:43,929 INFO ___FILE_ONLY___ ═
185
+ 2026-08-24 13:27:43,929 INFO ___FILE_ONLY___ ═
186
+ 2026-08-24 13:27:43,929 INFO ___FILE_ONLY___ ═
187
+ 2026-08-24 13:27:43,929 INFO ___FILE_ONLY___ ═
188
+ 2026-08-24 13:27:43,929 INFO ___FILE_ONLY___ ═
189
+ 2026-08-24 13:27:43,929 INFO ___FILE_ONLY___ ═
190
+ 2026-08-24 13:27:43,929 INFO ___FILE_ONLY___ ═
191
+ 2026-08-24 13:27:43,929 INFO ___FILE_ONLY___ ═
192
+ 2026-08-24 13:27:43,929 INFO ___FILE_ONLY___ ═
193
+ 2026-08-24 13:27:43,929 INFO ___FILE_ONLY___ ═
194
+ 2026-08-24 13:27:43,929 INFO ___FILE_ONLY___ ═
195
+ 2026-08-24 13:27:43,930 INFO ___FILE_ONLY___ ═
196
+ 2026-08-24 13:27:43,930 INFO ___FILE_ONLY___ ═
197
+ 2026-08-24 13:27:43,930 INFO ___FILE_ONLY___ ═
198
+ 2026-08-24 13:27:43,930 INFO ___FILE_ONLY___ ═
199
+ 2026-08-24 13:27:43,930 INFO ___FILE_ONLY___ ═
200
+ 2026-08-24 13:27:43,930 INFO ___FILE_ONLY___ ═
201
+ 2026-08-24 13:27:43,930 INFO ___FILE_ONLY___ ═
202
+ 2026-08-24 13:27:43,930 INFO ___FILE_ONLY___ ═
203
+ 2026-08-24 13:27:43,930 INFO ___FILE_ONLY___ ═
204
+ 2026-08-24 13:27:43,930 INFO ___FILE_ONLY___ ═
205
+ 2026-08-24 13:27:43,931 INFO ___FILE_ONLY___ ═
206
+ 2026-08-24 13:27:43,931 INFO ___FILE_ONLY___ ═
207
+ 2026-08-24 13:27:43,931 INFO ___FILE_ONLY___ ═
208
+ 2026-08-24 13:27:43,931 INFO ___FILE_ONLY___ ═
209
+ 2026-08-24 13:27:43,931 INFO ___FILE_ONLY___ ═
210
+ 2026-08-24 13:27:43,931 INFO ___FILE_ONLY___ ═
211
+ 2026-08-24 13:27:43,931 INFO ___FILE_ONLY___ ═
212
+ 2026-08-24 13:27:43,931 INFO ___FILE_ONLY___ ═
213
+ 2026-08-24 13:27:43,931 INFO ___FILE_ONLY___ ═
214
+ 2026-08-24 13:27:43,931 INFO ___FILE_ONLY___ ═
215
+ 2026-08-24 13:27:43,931 INFO ___FILE_ONLY___ ═
216
+ 2026-08-24 13:27:43,932 INFO ___FILE_ONLY___ ═
217
+ 2026-08-24 13:27:43,932 INFO ___FILE_ONLY___ ═
218
+ 2026-08-24 13:27:43,932 INFO ___FILE_ONLY___ ═
219
+ 2026-08-24 13:27:43,932 INFO ___FILE_ONLY___ ═
220
+ 2026-08-24 13:27:43,932 INFO ___FILE_ONLY___ ═
221
+ 2026-08-24 13:27:43,932 INFO ___FILE_ONLY___ ═
222
+ 2026-08-24 13:27:43,932 INFO ___FILE_ONLY___ ═
223
+ 2026-08-24 13:27:43,932 INFO ___FILE_ONLY___ ═
224
+ 2026-08-24 13:27:43,932 INFO ___FILE_ONLY___ ═
225
+ 2026-08-24 13:27:43,932 INFO ___FILE_ONLY___ ═
226
+ 2026-08-24 13:27:43,932 INFO ___FILE_ONLY___ ═
227
+ 2026-08-24 13:27:43,933 INFO ___FILE_ONLY___ ═
228
+ 2026-08-24 13:27:43,933 INFO ___FILE_ONLY___ ═
229
+ 2026-08-24 13:27:43,933 INFO ___FILE_ONLY___ ═
230
+ 2026-08-24 13:27:43,933 INFO ___FILE_ONLY___ ═
231
+ 2026-08-24 13:27:43,933 INFO ___FILE_ONLY___ ═
232
+ 2026-08-24 13:27:43,933 INFO ___FILE_ONLY___ ╝
233
+
234
+ 2026-08-24 13:27:43,935 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
235
+
236
+ 2026-08-24 13:27:43,935 INFO ___FILE_ONLY___ ╠═ Downloading: BigQuery Command Line Tool (Platform Spe... ═╣
237
+
238
+ 2026-08-24 13:27:43,935 INFO ___FILE_ONLY___ ╚
239
+ 2026-08-24 13:27:43,936 DEBUG root On GCE from memory cache: False
240
+ 2026-08-24 13:27:43,937 DEBUG root On GCE from memory cache: False
241
+ 2026-08-24 13:27:43,938 DEBUG urllib3.connectionpool Starting new HTTPS connection (1): dl.google.com:443
242
+ 2026-08-24 13:27:43,990 DEBUG urllib3.connectionpool https://dl.google.com:443 "GET /dl/cloudsdk/channels/rapid/components/google-cloud-sdk-bq-nix-20260605120704.tar.gz HTTP/1.1" 200 1948
243
+ 2026-08-24 13:27:43,991 INFO ___FILE_ONLY___ ════════════════════════════════════════════════════════════
244
+ 2026-08-24 13:27:43,991 INFO ___FILE_ONLY___ ╝
245
+
246
+ 2026-08-24 13:27:43,993 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
247
+
248
+ 2026-08-24 13:27:43,993 INFO ___FILE_ONLY___ ╠═ Downloading: Bundled Python 3.14 ═╣
249
+
250
+ 2026-08-24 13:27:43,993 INFO ___FILE_ONLY___ ╚
251
+ 2026-08-24 13:27:43,993 INFO ___FILE_ONLY___ ════════════════════════════════════════════════════════════
252
+ 2026-08-24 13:27:43,994 INFO ___FILE_ONLY___ ╝
253
+
254
+ 2026-08-24 13:27:43,995 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
255
+
256
+ 2026-08-24 13:27:43,996 INFO ___FILE_ONLY___ ╠═ Downloading: Bundled Python 3.14 (Platform Specific) ═╣
257
+
258
+ 2026-08-24 13:27:43,996 INFO ___FILE_ONLY___ ╚
259
+ 2026-08-24 13:27:43,997 DEBUG root On GCE from memory cache: False
260
+ 2026-08-24 13:27:43,998 DEBUG root On GCE from memory cache: False
261
+ 2026-08-24 13:27:43,998 DEBUG urllib3.connectionpool Starting new HTTPS connection (1): dl.google.com:443
262
+ 2026-08-24 13:27:44,018 DEBUG urllib3.connectionpool https://dl.google.com:443 "GET /dl/cloudsdk/channels/rapid/components/google-cloud-sdk-bundled-python3-unix-linux-x86_64-20260731054104.tar.gz HTTP/1.1" 200 34630708
263
+ 2026-08-24 13:27:44,156 INFO ___FILE_ONLY___ ═
264
+ 2026-08-24 13:27:44,157 INFO ___FILE_ONLY___ ═
265
+ 2026-08-24 13:27:44,157 INFO ___FILE_ONLY___ ═
266
+ 2026-08-24 13:27:44,158 INFO ___FILE_ONLY___ ═
267
+ 2026-08-24 13:27:44,159 INFO ___FILE_ONLY___ ═
268
+ 2026-08-24 13:27:44,160 INFO ___FILE_ONLY___ ═
269
+ 2026-08-24 13:27:44,161 INFO ___FILE_ONLY___ ═
270
+ 2026-08-24 13:27:44,161 INFO ___FILE_ONLY___ ═
271
+ 2026-08-24 13:27:44,162 INFO ___FILE_ONLY___ ═
272
+ 2026-08-24 13:27:44,163 INFO ___FILE_ONLY___ ═
273
+ 2026-08-24 13:27:44,164 INFO ___FILE_ONLY___ ═
274
+ 2026-08-24 13:27:44,165 INFO ___FILE_ONLY___ ═
275
+ 2026-08-24 13:27:44,165 INFO ___FILE_ONLY___ ═
276
+ 2026-08-24 13:27:44,166 INFO ___FILE_ONLY___ ═
277
+ 2026-08-24 13:27:44,167 INFO ___FILE_ONLY___ ═
278
+ 2026-08-24 13:27:44,168 INFO ___FILE_ONLY___ ═
279
+ 2026-08-24 13:27:44,169 INFO ___FILE_ONLY___ ═
280
+ 2026-08-24 13:27:44,169 INFO ___FILE_ONLY___ ═
281
+ 2026-08-24 13:27:44,170 INFO ___FILE_ONLY___ ═
282
+ 2026-08-24 13:27:44,171 INFO ___FILE_ONLY___ ═
283
+ 2026-08-24 13:27:44,172 INFO ___FILE_ONLY___ ═
284
+ 2026-08-24 13:27:44,173 INFO ___FILE_ONLY___ ═
285
+ 2026-08-24 13:27:44,174 INFO ___FILE_ONLY___ ═
286
+ 2026-08-24 13:27:44,175 INFO ___FILE_ONLY___ ═
287
+ 2026-08-24 13:27:44,176 INFO ___FILE_ONLY___ ═
288
+ 2026-08-24 13:27:44,176 INFO ___FILE_ONLY___ ═
289
+ 2026-08-24 13:27:44,177 INFO ___FILE_ONLY___ ═
290
+ 2026-08-24 13:27:44,178 INFO ___FILE_ONLY___ ═
291
+ 2026-08-24 13:27:44,179 INFO ___FILE_ONLY___ ═
292
+ 2026-08-24 13:27:44,179 INFO ___FILE_ONLY___ ═
293
+ 2026-08-24 13:27:44,180 INFO ___FILE_ONLY___ ═
294
+ 2026-08-24 13:27:44,181 INFO ___FILE_ONLY___ ═
295
+ 2026-08-24 13:27:44,182 INFO ___FILE_ONLY___ ═
296
+ 2026-08-24 13:27:44,183 INFO ___FILE_ONLY___ ═
297
+ 2026-08-24 13:27:44,183 INFO ___FILE_ONLY___ ═
298
+ 2026-08-24 13:27:44,184 INFO ___FILE_ONLY___ ═
299
+ 2026-08-24 13:27:44,185 INFO ___FILE_ONLY___ ═
300
+ 2026-08-24 13:27:44,186 INFO ___FILE_ONLY___ ═
301
+ 2026-08-24 13:27:44,186 INFO ___FILE_ONLY___ ═
302
+ 2026-08-24 13:27:44,187 INFO ___FILE_ONLY___ ═
303
+ 2026-08-24 13:27:44,188 INFO ___FILE_ONLY___ ═
304
+ 2026-08-24 13:27:44,189 INFO ___FILE_ONLY___ ═
305
+ 2026-08-24 13:27:44,189 INFO ___FILE_ONLY___ ═
306
+ 2026-08-24 13:27:44,190 INFO ___FILE_ONLY___ ═
307
+ 2026-08-24 13:27:44,191 INFO ___FILE_ONLY___ ═
308
+ 2026-08-24 13:27:44,192 INFO ___FILE_ONLY___ ═
309
+ 2026-08-24 13:27:44,192 INFO ___FILE_ONLY___ ═
310
+ 2026-08-24 13:27:44,193 INFO ___FILE_ONLY___ ═
311
+ 2026-08-24 13:27:44,194 INFO ___FILE_ONLY___ ═
312
+ 2026-08-24 13:27:44,195 INFO ___FILE_ONLY___ ═
313
+ 2026-08-24 13:27:44,195 INFO ___FILE_ONLY___ ═
314
+ 2026-08-24 13:27:44,196 INFO ___FILE_ONLY___ ═
315
+ 2026-08-24 13:27:44,197 INFO ___FILE_ONLY___ ═
316
+ 2026-08-24 13:27:44,198 INFO ___FILE_ONLY___ ═
317
+ 2026-08-24 13:27:44,198 INFO ___FILE_ONLY___ ═
318
+ 2026-08-24 13:27:44,199 INFO ___FILE_ONLY___ ═
319
+ 2026-08-24 13:27:44,200 INFO ___FILE_ONLY___ ═
320
+ 2026-08-24 13:27:44,201 INFO ___FILE_ONLY___ ═
321
+ 2026-08-24 13:27:44,201 INFO ___FILE_ONLY___ ═
322
+ 2026-08-24 13:27:44,202 INFO ___FILE_ONLY___ ═
323
+ 2026-08-24 13:27:44,202 INFO ___FILE_ONLY___ ╝
324
+
325
+ 2026-08-24 13:27:44,204 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
326
+
327
+ 2026-08-24 13:27:44,204 INFO ___FILE_ONLY___ ╠═ Downloading: Cloud Storage Command Line Tool ═╣
328
+
329
+ 2026-08-24 13:27:44,205 INFO ___FILE_ONLY___ ╚
330
+ 2026-08-24 13:27:44,206 DEBUG root On GCE from memory cache: False
331
+ 2026-08-24 13:27:44,207 DEBUG root On GCE from memory cache: False
332
+ 2026-08-24 13:27:44,207 DEBUG urllib3.connectionpool Starting new HTTPS connection (1): dl.google.com:443
333
+ 2026-08-24 13:27:44,223 DEBUG urllib3.connectionpool https://dl.google.com:443 "GET /dl/cloudsdk/channels/rapid/components/google-cloud-sdk-gsutil-20260501041631.tar.gz HTTP/1.1" 200 12967034
334
+ 2026-08-24 13:27:44,262 INFO ___FILE_ONLY___ ═
335
+ 2026-08-24 13:27:44,263 INFO ___FILE_ONLY___ ═
336
+ 2026-08-24 13:27:44,263 INFO ___FILE_ONLY___ ═
337
+ 2026-08-24 13:27:44,264 INFO ___FILE_ONLY___ ═
338
+ 2026-08-24 13:27:44,264 INFO ___FILE_ONLY___ ═
339
+ 2026-08-24 13:27:44,264 INFO ___FILE_ONLY___ ═
340
+ 2026-08-24 13:27:44,265 INFO ___FILE_ONLY___ ═
341
+ 2026-08-24 13:27:44,265 INFO ___FILE_ONLY___ ═
342
+ 2026-08-24 13:27:44,266 INFO ___FILE_ONLY___ ═
343
+ 2026-08-24 13:27:44,266 INFO ___FILE_ONLY___ ═
344
+ 2026-08-24 13:27:44,266 INFO ___FILE_ONLY___ ═
345
+ 2026-08-24 13:27:44,267 INFO ___FILE_ONLY___ ═
346
+ 2026-08-24 13:27:44,267 INFO ___FILE_ONLY___ ═
347
+ 2026-08-24 13:27:44,267 INFO ___FILE_ONLY___ ═
348
+ 2026-08-24 13:27:44,268 INFO ___FILE_ONLY___ ═
349
+ 2026-08-24 13:27:44,268 INFO ___FILE_ONLY___ ═
350
+ 2026-08-24 13:27:44,269 INFO ___FILE_ONLY___ ═
351
+ 2026-08-24 13:27:44,269 INFO ___FILE_ONLY___ ═
352
+ 2026-08-24 13:27:44,269 INFO ___FILE_ONLY___ ═
353
+ 2026-08-24 13:27:44,270 INFO ___FILE_ONLY___ ═
354
+ 2026-08-24 13:27:44,270 INFO ___FILE_ONLY___ ═
355
+ 2026-08-24 13:27:44,271 INFO ___FILE_ONLY___ ═
356
+ 2026-08-24 13:27:44,271 INFO ___FILE_ONLY___ ═
357
+ 2026-08-24 13:27:44,271 INFO ___FILE_ONLY___ ═
358
+ 2026-08-24 13:27:44,272 INFO ___FILE_ONLY___ ═
359
+ 2026-08-24 13:27:44,272 INFO ___FILE_ONLY___ ═
360
+ 2026-08-24 13:27:44,272 INFO ___FILE_ONLY___ ═
361
+ 2026-08-24 13:27:44,273 INFO ___FILE_ONLY___ ═
362
+ 2026-08-24 13:27:44,273 INFO ___FILE_ONLY___ ═
363
+ 2026-08-24 13:27:44,274 INFO ___FILE_ONLY___ ═
364
+ 2026-08-24 13:27:44,274 INFO ___FILE_ONLY___ ═
365
+ 2026-08-24 13:27:44,274 INFO ___FILE_ONLY___ ═
366
+ 2026-08-24 13:27:44,275 INFO ___FILE_ONLY___ ═
367
+ 2026-08-24 13:27:44,275 INFO ___FILE_ONLY___ ═
368
+ 2026-08-24 13:27:44,275 INFO ___FILE_ONLY___ ═
369
+ 2026-08-24 13:27:44,276 INFO ___FILE_ONLY___ ═
370
+ 2026-08-24 13:27:44,276 INFO ___FILE_ONLY___ ═
371
+ 2026-08-24 13:27:44,276 INFO ___FILE_ONLY___ ═
372
+ 2026-08-24 13:27:44,277 INFO ___FILE_ONLY___ ═
373
+ 2026-08-24 13:27:44,277 INFO ___FILE_ONLY___ ═
374
+ 2026-08-24 13:27:44,278 INFO ___FILE_ONLY___ ═
375
+ 2026-08-24 13:27:44,278 INFO ___FILE_ONLY___ ═
376
+ 2026-08-24 13:27:44,278 INFO ___FILE_ONLY___ ═
377
+ 2026-08-24 13:27:44,279 INFO ___FILE_ONLY___ ═
378
+ 2026-08-24 13:27:44,279 INFO ___FILE_ONLY___ ═
379
+ 2026-08-24 13:27:44,279 INFO ___FILE_ONLY___ ═
380
+ 2026-08-24 13:27:44,280 INFO ___FILE_ONLY___ ═
381
+ 2026-08-24 13:27:44,280 INFO ___FILE_ONLY___ ═
382
+ 2026-08-24 13:27:44,280 INFO ___FILE_ONLY___ ═
383
+ 2026-08-24 13:27:44,281 INFO ___FILE_ONLY___ ═
384
+ 2026-08-24 13:27:44,281 INFO ___FILE_ONLY___ ═
385
+ 2026-08-24 13:27:44,282 INFO ___FILE_ONLY___ ═
386
+ 2026-08-24 13:27:44,282 INFO ___FILE_ONLY___ ═
387
+ 2026-08-24 13:27:44,282 INFO ___FILE_ONLY___ ═
388
+ 2026-08-24 13:27:44,283 INFO ___FILE_ONLY___ ═
389
+ 2026-08-24 13:27:44,283 INFO ___FILE_ONLY___ ═
390
+ 2026-08-24 13:27:44,284 INFO ___FILE_ONLY___ ═
391
+ 2026-08-24 13:27:44,284 INFO ___FILE_ONLY___ ═
392
+ 2026-08-24 13:27:44,284 INFO ___FILE_ONLY___ ═
393
+ 2026-08-24 13:27:44,285 INFO ___FILE_ONLY___ ═
394
+ 2026-08-24 13:27:44,285 INFO ___FILE_ONLY___ ╝
395
+
396
+ 2026-08-24 13:27:44,287 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
397
+
398
+ 2026-08-24 13:27:44,287 INFO ___FILE_ONLY___ ╠═ Downloading: Cloud Storage Command Line Tool (Platfor... ═╣
399
+
400
+ 2026-08-24 13:27:44,287 INFO ___FILE_ONLY___ ╚
401
+ 2026-08-24 13:27:44,288 DEBUG root On GCE from memory cache: False
402
+ 2026-08-24 13:27:44,289 DEBUG root On GCE from memory cache: False
403
+ 2026-08-24 13:27:44,290 DEBUG urllib3.connectionpool Starting new HTTPS connection (1): dl.google.com:443
404
+ 2026-08-24 13:27:44,299 DEBUG urllib3.connectionpool https://dl.google.com:443 "GET /dl/cloudsdk/channels/rapid/components/google-cloud-sdk-gsutil-nix-20260605120704.tar.gz HTTP/1.1" 200 1963
405
+ 2026-08-24 13:27:44,299 INFO ___FILE_ONLY___ ════════════════════════════════════════════════════════════
406
+ 2026-08-24 13:27:44,299 INFO ___FILE_ONLY___ ╝
407
+
408
+ 2026-08-24 13:27:44,301 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
409
+
410
+ 2026-08-24 13:27:44,301 INFO ___FILE_ONLY___ ╠═ Downloading: Default set of gcloud commands ═╣
411
+
412
+ 2026-08-24 13:27:44,301 INFO ___FILE_ONLY___ ╚
413
+ 2026-08-24 13:27:44,302 INFO ___FILE_ONLY___ ════════════════════════════════════════════════════════════
414
+ 2026-08-24 13:27:44,302 INFO ___FILE_ONLY___ ╝
415
+
416
+ 2026-08-24 13:27:44,303 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
417
+
418
+ 2026-08-24 13:27:44,303 INFO ___FILE_ONLY___ ╠═ Downloading: Default set of gcloud commands (Platform... ═╣
419
+
420
+ 2026-08-24 13:27:44,303 INFO ___FILE_ONLY___ ╚
421
+ 2026-08-24 13:27:44,304 DEBUG root On GCE from memory cache: False
422
+ 2026-08-24 13:27:44,305 DEBUG root On GCE from memory cache: False
423
+ 2026-08-24 13:27:44,306 DEBUG urllib3.connectionpool Starting new HTTPS connection (1): dl.google.com:443
424
+ 2026-08-24 13:27:44,316 DEBUG urllib3.connectionpool https://dl.google.com:443 "GET /dl/cloudsdk/channels/rapid/components/google-cloud-sdk-gcloud-linux-x86_64-20260710150251.tar.gz HTTP/1.1" 200 99
425
+ 2026-08-24 13:27:44,317 INFO ___FILE_ONLY___ ════════════════════════════════════════════════════════════
426
+ 2026-08-24 13:27:44,317 INFO ___FILE_ONLY___ ╝
427
+
428
+ 2026-08-24 13:27:44,319 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
429
+
430
+ 2026-08-24 13:27:44,319 INFO ___FILE_ONLY___ ╠═ Downloading: Google Cloud CLI Core Libraries (Platfor... ═╣
431
+
432
+ 2026-08-24 13:27:44,319 INFO ___FILE_ONLY___ ╚
433
+ 2026-08-24 13:27:44,320 DEBUG root On GCE from memory cache: False
434
+ 2026-08-24 13:27:44,321 DEBUG root On GCE from memory cache: False
435
+ 2026-08-24 13:27:44,322 DEBUG urllib3.connectionpool Starting new HTTPS connection (1): dl.google.com:443
436
+ 2026-08-24 13:27:44,369 DEBUG urllib3.connectionpool https://dl.google.com:443 "GET /dl/cloudsdk/channels/rapid/components/google-cloud-sdk-core-nix-20260605120704.tar.gz HTTP/1.1" 200 2342
437
+ 2026-08-24 13:27:44,369 INFO ___FILE_ONLY___ ════════════════════════════════════════════════════════════
438
+ 2026-08-24 13:27:44,370 INFO ___FILE_ONLY___ ╝
439
+
440
+ 2026-08-24 13:27:44,372 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
441
+
442
+ 2026-08-24 13:27:44,372 INFO ___FILE_ONLY___ ╠═ Downloading: Google Cloud CRC32C Hash Tool ═╣
443
+
444
+ 2026-08-24 13:27:44,372 INFO ___FILE_ONLY___ ╚
445
+ 2026-08-24 13:27:44,372 INFO ___FILE_ONLY___ ════════════════════════════════════════════════════════════
446
+ 2026-08-24 13:27:44,372 INFO ___FILE_ONLY___ ╝
447
+
448
+ 2026-08-24 13:27:44,374 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
449
+
450
+ 2026-08-24 13:27:44,374 INFO ___FILE_ONLY___ ╠═ Downloading: Google Cloud CRC32C Hash Tool (Platform ... ═╣
451
+
452
+ 2026-08-24 13:27:44,374 INFO ___FILE_ONLY___ ╚
453
+ 2026-08-24 13:27:44,375 DEBUG root On GCE from memory cache: False
454
+ 2026-08-24 13:27:44,376 DEBUG root On GCE from memory cache: False
455
+ 2026-08-24 13:27:44,377 DEBUG urllib3.connectionpool Starting new HTTPS connection (1): dl.google.com:443
456
+ 2026-08-24 13:27:44,393 DEBUG urllib3.connectionpool https://dl.google.com:443 "GET /dl/cloudsdk/channels/rapid/components/google-cloud-sdk-gcloud-crc32c-linux-x86_64-20260717053915.tar.gz HTTP/1.1" 200 1610486
457
+ 2026-08-24 13:27:44,404 INFO ___FILE_ONLY___ ═
458
+ 2026-08-24 13:27:44,404 INFO ___FILE_ONLY___ ═
459
+ 2026-08-24 13:27:44,404 INFO ___FILE_ONLY___ ═
460
+ 2026-08-24 13:27:44,405 INFO ___FILE_ONLY___ ═
461
+ 2026-08-24 13:27:44,405 INFO ___FILE_ONLY___ ═
462
+ 2026-08-24 13:27:44,405 INFO ___FILE_ONLY___ ═
463
+ 2026-08-24 13:27:44,405 INFO ___FILE_ONLY___ ═
464
+ 2026-08-24 13:27:44,405 INFO ___FILE_ONLY___ ═
465
+ 2026-08-24 13:27:44,405 INFO ___FILE_ONLY___ ═
466
+ 2026-08-24 13:27:44,405 INFO ___FILE_ONLY___ ═
467
+ 2026-08-24 13:27:44,405 INFO ___FILE_ONLY___ ═
468
+ 2026-08-24 13:27:44,406 INFO ___FILE_ONLY___ ═
469
+ 2026-08-24 13:27:44,406 INFO ___FILE_ONLY___ ═
470
+ 2026-08-24 13:27:44,406 INFO ___FILE_ONLY___ ═
471
+ 2026-08-24 13:27:44,406 INFO ___FILE_ONLY___ ═
472
+ 2026-08-24 13:27:44,406 INFO ___FILE_ONLY___ ═
473
+ 2026-08-24 13:27:44,406 INFO ___FILE_ONLY___ ═
474
+ 2026-08-24 13:27:44,406 INFO ___FILE_ONLY___ ═
475
+ 2026-08-24 13:27:44,406 INFO ___FILE_ONLY___ ═
476
+ 2026-08-24 13:27:44,407 INFO ___FILE_ONLY___ ═
477
+ 2026-08-24 13:27:44,407 INFO ___FILE_ONLY___ ═
478
+ 2026-08-24 13:27:44,407 INFO ___FILE_ONLY___ ═
479
+ 2026-08-24 13:27:44,407 INFO ___FILE_ONLY___ ═
480
+ 2026-08-24 13:27:44,407 INFO ___FILE_ONLY___ ═
481
+ 2026-08-24 13:27:44,407 INFO ___FILE_ONLY___ ═
482
+ 2026-08-24 13:27:44,407 INFO ___FILE_ONLY___ ═
483
+ 2026-08-24 13:27:44,407 INFO ___FILE_ONLY___ ═
484
+ 2026-08-24 13:27:44,407 INFO ___FILE_ONLY___ ═
485
+ 2026-08-24 13:27:44,408 INFO ___FILE_ONLY___ ═
486
+ 2026-08-24 13:27:44,408 INFO ___FILE_ONLY___ ═
487
+ 2026-08-24 13:27:44,408 INFO ___FILE_ONLY___ ═
488
+ 2026-08-24 13:27:44,408 INFO ___FILE_ONLY___ ═
489
+ 2026-08-24 13:27:44,408 INFO ___FILE_ONLY___ ═
490
+ 2026-08-24 13:27:44,408 INFO ___FILE_ONLY___ ═
491
+ 2026-08-24 13:27:44,408 INFO ___FILE_ONLY___ ═
492
+ 2026-08-24 13:27:44,408 INFO ___FILE_ONLY___ ═
493
+ 2026-08-24 13:27:44,409 INFO ___FILE_ONLY___ ═
494
+ 2026-08-24 13:27:44,409 INFO ___FILE_ONLY___ ═
495
+ 2026-08-24 13:27:44,409 INFO ___FILE_ONLY___ ═
496
+ 2026-08-24 13:27:44,409 INFO ___FILE_ONLY___ ═
497
+ 2026-08-24 13:27:44,409 INFO ___FILE_ONLY___ ═
498
+ 2026-08-24 13:27:44,409 INFO ___FILE_ONLY___ ═
499
+ 2026-08-24 13:27:44,409 INFO ___FILE_ONLY___ ═
500
+ 2026-08-24 13:27:44,409 INFO ___FILE_ONLY___ ═
501
+ 2026-08-24 13:27:44,410 INFO ___FILE_ONLY___ ═
502
+ 2026-08-24 13:27:44,410 INFO ___FILE_ONLY___ ═
503
+ 2026-08-24 13:27:44,410 INFO ___FILE_ONLY___ ═
504
+ 2026-08-24 13:27:44,410 INFO ___FILE_ONLY___ ═
505
+ 2026-08-24 13:27:44,410 INFO ___FILE_ONLY___ ═
506
+ 2026-08-24 13:27:44,410 INFO ___FILE_ONLY___ ═
507
+ 2026-08-24 13:27:44,410 INFO ___FILE_ONLY___ ═
508
+ 2026-08-24 13:27:44,410 INFO ___FILE_ONLY___ ═
509
+ 2026-08-24 13:27:44,410 INFO ___FILE_ONLY___ ═
510
+ 2026-08-24 13:27:44,411 INFO ___FILE_ONLY___ ═
511
+ 2026-08-24 13:27:44,411 INFO ___FILE_ONLY___ ═
512
+ 2026-08-24 13:27:44,411 INFO ___FILE_ONLY___ ═
513
+ 2026-08-24 13:27:44,411 INFO ___FILE_ONLY___ ═
514
+ 2026-08-24 13:27:44,411 INFO ___FILE_ONLY___ ═
515
+ 2026-08-24 13:27:44,411 INFO ___FILE_ONLY___ ═
516
+ 2026-08-24 13:27:44,411 INFO ___FILE_ONLY___ ═
517
+ 2026-08-24 13:27:44,411 INFO ___FILE_ONLY___ ╝
518
+
519
+ 2026-08-24 13:27:44,413 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
520
+
521
+ 2026-08-24 13:27:44,413 INFO ___FILE_ONLY___ ╠═ Downloading: gcloud cli dependencies (Platform Specific) ═╣
522
+
523
+ 2026-08-24 13:27:44,414 INFO ___FILE_ONLY___ ╚
524
+ 2026-08-24 13:27:44,414 DEBUG root On GCE from memory cache: False
525
+ 2026-08-24 13:27:44,415 DEBUG root On GCE from memory cache: False
526
+ 2026-08-24 13:27:44,416 DEBUG urllib3.connectionpool Starting new HTTPS connection (1): dl.google.com:443
527
+ 2026-08-24 13:27:44,429 DEBUG urllib3.connectionpool https://dl.google.com:443 "GET /dl/cloudsdk/channels/rapid/components/google-cloud-sdk-gcloud-deps-linux-x86_64-20210416153011.tar.gz HTTP/1.1" 200 104
528
+ 2026-08-24 13:27:44,430 INFO ___FILE_ONLY___ ════════════════════════════════════════════════════════════
529
+ 2026-08-24 13:27:44,430 INFO ___FILE_ONLY___ ╝
530
+
531
+ 2026-08-24 13:27:44,432 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
532
+
533
+ 2026-08-24 13:27:44,432 INFO ___FILE_ONLY___ ╠═ Installing: BigQuery Command Line Tool ═╣
534
+
535
+ 2026-08-24 13:27:44,432 INFO ___FILE_ONLY___ ╚
536
+ 2026-08-24 13:27:44,506 INFO ___FILE_ONLY___ ═
537
+ 2026-08-24 13:27:44,509 INFO ___FILE_ONLY___ ═
538
+ 2026-08-24 13:27:44,511 INFO ___FILE_ONLY___ ═
539
+ 2026-08-24 13:27:44,514 INFO ___FILE_ONLY___ ═
540
+ 2026-08-24 13:27:44,516 INFO ___FILE_ONLY___ ═
541
+ 2026-08-24 13:27:44,518 INFO ___FILE_ONLY___ ═
542
+ 2026-08-24 13:27:44,520 INFO ___FILE_ONLY___ ═
543
+ 2026-08-24 13:27:44,523 INFO ___FILE_ONLY___ ═
544
+ 2026-08-24 13:27:44,526 INFO ___FILE_ONLY___ ═
545
+ 2026-08-24 13:27:44,528 INFO ___FILE_ONLY___ ═
546
+ 2026-08-24 13:27:44,530 INFO ___FILE_ONLY___ ═
547
+ 2026-08-24 13:27:44,532 INFO ___FILE_ONLY___ ═
548
+ 2026-08-24 13:27:44,534 INFO ___FILE_ONLY___ ═
549
+ 2026-08-24 13:27:44,537 INFO ___FILE_ONLY___ ═
550
+ 2026-08-24 13:27:44,539 INFO ___FILE_ONLY___ ═
551
+ 2026-08-24 13:27:44,542 INFO ___FILE_ONLY___ ═
552
+ 2026-08-24 13:27:44,544 INFO ___FILE_ONLY___ ═
553
+ 2026-08-24 13:27:44,546 INFO ___FILE_ONLY___ ═
554
+ 2026-08-24 13:27:44,549 INFO ___FILE_ONLY___ ═
555
+ 2026-08-24 13:27:44,551 INFO ___FILE_ONLY___ ═
556
+ 2026-08-24 13:27:44,554 INFO ___FILE_ONLY___ ═
557
+ 2026-08-24 13:27:44,556 INFO ___FILE_ONLY___ ═
558
+ 2026-08-24 13:27:44,558 INFO ___FILE_ONLY___ ═
559
+ 2026-08-24 13:27:44,560 INFO ___FILE_ONLY___ ═
560
+ 2026-08-24 13:27:44,562 INFO ___FILE_ONLY___ ═
561
+ 2026-08-24 13:27:44,564 INFO ___FILE_ONLY___ ═
562
+ 2026-08-24 13:27:44,566 INFO ___FILE_ONLY___ ═
563
+ 2026-08-24 13:27:44,568 INFO ___FILE_ONLY___ ═
564
+ 2026-08-24 13:27:44,570 INFO ___FILE_ONLY___ ═
565
+ 2026-08-24 13:27:44,572 INFO ___FILE_ONLY___ ═
566
+ 2026-08-24 13:27:44,574 INFO ___FILE_ONLY___ ═
567
+ 2026-08-24 13:27:44,575 INFO ___FILE_ONLY___ ═
568
+ 2026-08-24 13:27:44,577 INFO ___FILE_ONLY___ ═
569
+ 2026-08-24 13:27:44,580 INFO ___FILE_ONLY___ ═
570
+ 2026-08-24 13:27:44,582 INFO ___FILE_ONLY___ ═
571
+ 2026-08-24 13:27:44,584 INFO ___FILE_ONLY___ ═
572
+ 2026-08-24 13:27:44,587 INFO ___FILE_ONLY___ ═
573
+ 2026-08-24 13:27:44,590 INFO ___FILE_ONLY___ ═
574
+ 2026-08-24 13:27:44,592 INFO ___FILE_ONLY___ ═
575
+ 2026-08-24 13:27:44,597 INFO ___FILE_ONLY___ ═
576
+ 2026-08-24 13:27:44,601 INFO ___FILE_ONLY___ ═
577
+ 2026-08-24 13:27:44,604 INFO ___FILE_ONLY___ ═
578
+ 2026-08-24 13:27:44,612 INFO ___FILE_ONLY___ ═
579
+ 2026-08-24 13:27:44,614 INFO ___FILE_ONLY___ ═
580
+ 2026-08-24 13:27:44,617 INFO ___FILE_ONLY___ ═
581
+ 2026-08-24 13:27:44,621 INFO ___FILE_ONLY___ ═
582
+ 2026-08-24 13:27:44,623 INFO ___FILE_ONLY___ ═
583
+ 2026-08-24 13:27:44,626 INFO ___FILE_ONLY___ ═
584
+ 2026-08-24 13:27:44,629 INFO ___FILE_ONLY___ ═
585
+ 2026-08-24 13:27:44,631 INFO ___FILE_ONLY___ ═
586
+ 2026-08-24 13:27:44,633 INFO ___FILE_ONLY___ ═
587
+ 2026-08-24 13:27:44,635 INFO ___FILE_ONLY___ ═
588
+ 2026-08-24 13:27:44,638 INFO ___FILE_ONLY___ ═
589
+ 2026-08-24 13:27:44,639 INFO ___FILE_ONLY___ ═
590
+ 2026-08-24 13:27:44,642 INFO ___FILE_ONLY___ ═
591
+ 2026-08-24 13:27:44,644 INFO ___FILE_ONLY___ ═
592
+ 2026-08-24 13:27:44,646 INFO ___FILE_ONLY___ ═
593
+ 2026-08-24 13:27:44,649 INFO ___FILE_ONLY___ ═
594
+ 2026-08-24 13:27:44,651 INFO ___FILE_ONLY___ ═
595
+ 2026-08-24 13:27:44,653 INFO ___FILE_ONLY___ ═
596
+ 2026-08-24 13:27:44,653 INFO ___FILE_ONLY___ ╝
597
+
598
+ 2026-08-24 13:27:44,659 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
599
+
600
+ 2026-08-24 13:27:44,659 INFO ___FILE_ONLY___ ╠═ Installing: BigQuery Command Line Tool (Platform Spec... ═╣
601
+
602
+ 2026-08-24 13:27:44,659 INFO ___FILE_ONLY___ ╚
603
+ 2026-08-24 13:27:44,660 INFO ___FILE_ONLY___ ════════════════════════════════════════════════════════════
604
+ 2026-08-24 13:27:44,660 INFO ___FILE_ONLY___ ╝
605
+
606
+ 2026-08-24 13:27:44,663 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
607
+
608
+ 2026-08-24 13:27:44,663 INFO ___FILE_ONLY___ ╠═ Installing: Bundled Python 3.14 ═╣
609
+
610
+ 2026-08-24 13:27:44,663 INFO ___FILE_ONLY___ ╚
611
+ 2026-08-24 13:27:44,664 INFO ___FILE_ONLY___ ════════════════════════════════════════════════════════════
612
+ 2026-08-24 13:27:44,664 INFO ___FILE_ONLY___ ╝
613
+
614
+ 2026-08-24 13:27:44,666 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
615
+
616
+ 2026-08-24 13:27:44,666 INFO ___FILE_ONLY___ ╠═ Installing: Bundled Python 3.14 (Platform Specific) ═╣
617
+
618
+ 2026-08-24 13:27:44,666 INFO ___FILE_ONLY___ ╚
619
+ 2026-08-24 13:27:45,472 INFO ___FILE_ONLY___ ═
620
+ 2026-08-24 13:27:45,489 INFO ___FILE_ONLY___ ═
621
+ 2026-08-24 13:27:45,509 INFO ___FILE_ONLY___ ═
622
+ 2026-08-24 13:27:45,538 INFO ___FILE_ONLY___ ═
623
+ 2026-08-24 13:27:45,588 INFO ___FILE_ONLY___ ═
624
+ 2026-08-24 13:27:45,605 INFO ___FILE_ONLY___ ═
625
+ 2026-08-24 13:27:45,621 INFO ___FILE_ONLY___ ═
626
+ 2026-08-24 13:27:45,635 INFO ___FILE_ONLY___ ═
627
+ 2026-08-24 13:27:45,653 INFO ___FILE_ONLY___ ═
628
+ 2026-08-24 13:27:45,673 INFO ___FILE_ONLY___ ═
629
+ 2026-08-24 13:27:45,692 INFO ___FILE_ONLY___ ═
630
+ 2026-08-24 13:27:45,707 INFO ___FILE_ONLY___ ═
631
+ 2026-08-24 13:27:45,784 INFO ___FILE_ONLY___ ═
632
+ 2026-08-24 13:27:45,906 INFO ___FILE_ONLY___ ═
633
+ 2026-08-24 13:27:45,920 INFO ___FILE_ONLY___ ═
634
+ 2026-08-24 13:27:45,942 INFO ___FILE_ONLY___ ═
635
+ 2026-08-24 13:27:45,958 INFO ___FILE_ONLY___ ═
636
+ 2026-08-24 13:27:45,976 INFO ___FILE_ONLY___ ═
637
+ 2026-08-24 13:27:45,992 INFO ___FILE_ONLY___ ═
638
+ 2026-08-24 13:27:46,006 INFO ___FILE_ONLY___ ═
639
+ 2026-08-24 13:27:46,024 INFO ___FILE_ONLY___ ═
640
+ 2026-08-24 13:27:46,043 INFO ___FILE_ONLY___ ═
641
+ 2026-08-24 13:27:46,064 INFO ___FILE_ONLY___ ═
642
+ 2026-08-24 13:27:46,075 INFO ___FILE_ONLY___ ═
643
+ 2026-08-24 13:27:46,085 INFO ___FILE_ONLY___ ═
644
+ 2026-08-24 13:27:46,096 INFO ___FILE_ONLY___ ═
645
+ 2026-08-24 13:27:46,106 INFO ___FILE_ONLY___ ═
646
+ 2026-08-24 13:27:46,116 INFO ___FILE_ONLY___ ═
647
+ 2026-08-24 13:27:46,126 INFO ___FILE_ONLY___ ═
648
+ 2026-08-24 13:27:46,137 INFO ___FILE_ONLY___ ═
649
+ 2026-08-24 13:27:46,147 INFO ___FILE_ONLY___ ═
650
+ 2026-08-24 13:27:46,162 INFO ___FILE_ONLY___ ═
651
+ 2026-08-24 13:27:46,178 INFO ___FILE_ONLY___ ═
652
+ 2026-08-24 13:27:46,188 INFO ___FILE_ONLY___ ═
653
+ 2026-08-24 13:27:46,198 INFO ___FILE_ONLY___ ═
654
+ 2026-08-24 13:27:46,209 INFO ___FILE_ONLY___ ═
655
+ 2026-08-24 13:27:46,220 INFO ___FILE_ONLY___ ═
656
+ 2026-08-24 13:27:46,230 INFO ___FILE_ONLY___ ═
657
+ 2026-08-24 13:27:46,241 INFO ___FILE_ONLY___ ═
658
+ 2026-08-24 13:27:46,251 INFO ___FILE_ONLY___ ═
659
+ 2026-08-24 13:27:46,262 INFO ___FILE_ONLY___ ═
660
+ 2026-08-24 13:27:46,274 INFO ___FILE_ONLY___ ═
661
+ 2026-08-24 13:27:46,284 INFO ___FILE_ONLY___ ═
662
+ 2026-08-24 13:27:46,297 INFO ___FILE_ONLY___ ═
663
+ 2026-08-24 13:27:46,308 INFO ___FILE_ONLY___ ═
664
+ 2026-08-24 13:27:46,319 INFO ___FILE_ONLY___ ═
665
+ 2026-08-24 13:27:46,329 INFO ___FILE_ONLY___ ═
666
+ 2026-08-24 13:27:46,340 INFO ___FILE_ONLY___ ═
667
+ 2026-08-24 13:27:46,351 INFO ___FILE_ONLY___ ═
668
+ 2026-08-24 13:27:46,362 INFO ___FILE_ONLY___ ═
669
+ 2026-08-24 13:27:46,373 INFO ___FILE_ONLY___ ═
670
+ 2026-08-24 13:27:46,384 INFO ___FILE_ONLY___ ═
671
+ 2026-08-24 13:27:46,396 INFO ___FILE_ONLY___ ═
672
+ 2026-08-24 13:27:46,408 INFO ___FILE_ONLY___ ═
673
+ 2026-08-24 13:27:46,420 INFO ___FILE_ONLY___ ═
674
+ 2026-08-24 13:27:46,432 INFO ___FILE_ONLY___ ═
675
+ 2026-08-24 13:27:46,446 INFO ___FILE_ONLY___ ═
676
+ 2026-08-24 13:27:46,463 INFO ___FILE_ONLY___ ═
677
+ 2026-08-24 13:27:46,477 INFO ___FILE_ONLY___ ═
678
+ 2026-08-24 13:27:46,606 INFO ___FILE_ONLY___ ═
679
+ 2026-08-24 13:27:46,606 INFO ___FILE_ONLY___ ╝
680
+
681
+ 2026-08-24 13:27:46,636 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
682
+
683
+ 2026-08-24 13:27:46,636 INFO ___FILE_ONLY___ ╠═ Installing: Cloud Storage Command Line Tool ═╣
684
+
685
+ 2026-08-24 13:27:46,636 INFO ___FILE_ONLY___ ╚
686
+ 2026-08-24 13:27:46,992 INFO ___FILE_ONLY___ ═
687
+ 2026-08-24 13:27:47,002 INFO ___FILE_ONLY___ ═
688
+ 2026-08-24 13:27:47,012 INFO ___FILE_ONLY___ ═
689
+ 2026-08-24 13:27:47,022 INFO ___FILE_ONLY___ ═
690
+ 2026-08-24 13:27:47,031 INFO ___FILE_ONLY___ ═
691
+ 2026-08-24 13:27:47,060 INFO ___FILE_ONLY___ ═
692
+ 2026-08-24 13:27:47,072 INFO ___FILE_ONLY___ ═
693
+ 2026-08-24 13:27:47,085 INFO ___FILE_ONLY___ ═
694
+ 2026-08-24 13:27:47,098 INFO ___FILE_ONLY___ ═
695
+ 2026-08-24 13:27:47,112 INFO ___FILE_ONLY___ ═
696
+ 2026-08-24 13:27:47,127 INFO ___FILE_ONLY___ ═
697
+ 2026-08-24 13:27:47,137 INFO ___FILE_ONLY___ ═
698
+ 2026-08-24 13:27:47,148 INFO ___FILE_ONLY___ ═
699
+ 2026-08-24 13:27:47,157 INFO ___FILE_ONLY___ ═
700
+ 2026-08-24 13:27:47,166 INFO ___FILE_ONLY___ ═
701
+ 2026-08-24 13:27:47,183 INFO ___FILE_ONLY___ ═
702
+ 2026-08-24 13:27:47,195 INFO ___FILE_ONLY___ ═
703
+ 2026-08-24 13:27:47,204 INFO ___FILE_ONLY___ ═
704
+ 2026-08-24 13:27:47,215 INFO ___FILE_ONLY___ ═
705
+ 2026-08-24 13:27:47,225 INFO ___FILE_ONLY___ ═
706
+ 2026-08-24 13:27:47,234 INFO ___FILE_ONLY___ ═
707
+ 2026-08-24 13:27:47,245 INFO ___FILE_ONLY___ ═
708
+ 2026-08-24 13:27:47,255 INFO ___FILE_ONLY___ ═
709
+ 2026-08-24 13:27:47,266 INFO ___FILE_ONLY___ ═
710
+ 2026-08-24 13:27:47,276 INFO ___FILE_ONLY___ ═
711
+ 2026-08-24 13:27:47,286 INFO ___FILE_ONLY___ ═
712
+ 2026-08-24 13:27:47,296 INFO ___FILE_ONLY___ ═
713
+ 2026-08-24 13:27:47,309 INFO ___FILE_ONLY___ ═
714
+ 2026-08-24 13:27:47,323 INFO ___FILE_ONLY___ ═
715
+ 2026-08-24 13:27:47,334 INFO ___FILE_ONLY___ ═
716
+ 2026-08-24 13:27:47,345 INFO ___FILE_ONLY___ ═
717
+ 2026-08-24 13:27:47,362 INFO ___FILE_ONLY___ ═
718
+ 2026-08-24 13:27:47,376 INFO ___FILE_ONLY___ ═
719
+ 2026-08-24 13:27:47,392 INFO ___FILE_ONLY___ ═
720
+ 2026-08-24 13:27:47,406 INFO ___FILE_ONLY___ ═
721
+ 2026-08-24 13:27:47,419 INFO ___FILE_ONLY___ ═
722
+ 2026-08-24 13:27:47,428 INFO ___FILE_ONLY___ ═
723
+ 2026-08-24 13:27:47,439 INFO ___FILE_ONLY___ ═
724
+ 2026-08-24 13:27:47,470 INFO ___FILE_ONLY___ ═
725
+ 2026-08-24 13:27:47,482 INFO ___FILE_ONLY___ ═
726
+ 2026-08-24 13:27:47,492 INFO ___FILE_ONLY___ ═
727
+ 2026-08-24 13:27:47,502 INFO ___FILE_ONLY___ ═
728
+ 2026-08-24 13:27:47,511 INFO ___FILE_ONLY___ ═
729
+ 2026-08-24 13:27:47,521 INFO ___FILE_ONLY___ ═
730
+ 2026-08-24 13:27:47,531 INFO ___FILE_ONLY___ ═
731
+ 2026-08-24 13:27:47,540 INFO ___FILE_ONLY___ ═
732
+ 2026-08-24 13:27:47,549 INFO ___FILE_ONLY___ ═
733
+ 2026-08-24 13:27:47,558 INFO ___FILE_ONLY___ ═
734
+ 2026-08-24 13:27:47,567 INFO ___FILE_ONLY___ ═
735
+ 2026-08-24 13:27:47,579 INFO ___FILE_ONLY___ ═
736
+ 2026-08-24 13:27:47,593 INFO ___FILE_ONLY___ ═
737
+ 2026-08-24 13:27:47,605 INFO ___FILE_ONLY___ ═
738
+ 2026-08-24 13:27:47,617 INFO ___FILE_ONLY___ ═
739
+ 2026-08-24 13:27:47,629 INFO ___FILE_ONLY___ ═
740
+ 2026-08-24 13:27:47,640 INFO ___FILE_ONLY___ ═
741
+ 2026-08-24 13:27:47,657 INFO ___FILE_ONLY___ ═
742
+ 2026-08-24 13:27:47,676 INFO ___FILE_ONLY___ ═
743
+ 2026-08-24 13:27:47,702 INFO ___FILE_ONLY___ ═
744
+ 2026-08-24 13:27:47,719 INFO ___FILE_ONLY___ ═
745
+ 2026-08-24 13:27:47,737 INFO ___FILE_ONLY___ ═
746
+ 2026-08-24 13:27:47,738 INFO ___FILE_ONLY___ ╝
747
+
748
+ 2026-08-24 13:27:47,765 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
749
+
750
+ 2026-08-24 13:27:47,765 INFO ___FILE_ONLY___ ╠═ Installing: Cloud Storage Command Line Tool (Platform... ═╣
751
+
752
+ 2026-08-24 13:27:47,765 INFO ___FILE_ONLY___ ╚
753
+ 2026-08-24 13:27:47,766 INFO ___FILE_ONLY___ ════════════════════════════════════════════════════════════
754
+ 2026-08-24 13:27:47,766 INFO ___FILE_ONLY___ ╝
755
+
756
+ 2026-08-24 13:27:47,770 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
757
+
758
+ 2026-08-24 13:27:47,770 INFO ___FILE_ONLY___ ╠═ Installing: Default set of gcloud commands ═╣
759
+
760
+ 2026-08-24 13:27:47,770 INFO ___FILE_ONLY___ ╚
761
+ 2026-08-24 13:27:47,773 INFO ___FILE_ONLY___ ════════════════════════════════════════════════════════════
762
+ 2026-08-24 13:27:47,774 INFO ___FILE_ONLY___ ╝
763
+
764
+ 2026-08-24 13:27:47,775 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
765
+
766
+ 2026-08-24 13:27:47,775 INFO ___FILE_ONLY___ ╠═ Installing: Default set of gcloud commands (Platform ... ═╣
767
+
768
+ 2026-08-24 13:27:47,775 INFO ___FILE_ONLY___ ╚
769
+ 2026-08-24 13:27:47,776 INFO ___FILE_ONLY___ ════════════════════════════════════════════════════════════
770
+ 2026-08-24 13:27:47,776 INFO ___FILE_ONLY___ ╝
771
+
772
+ 2026-08-24 13:27:47,781 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
773
+
774
+ 2026-08-24 13:27:47,781 INFO ___FILE_ONLY___ ╠═ Installing: Google Cloud CLI Core Libraries (Platform... ═╣
775
+
776
+ 2026-08-24 13:27:47,781 INFO ___FILE_ONLY___ ╚
777
+ 2026-08-24 13:27:47,782 INFO ___FILE_ONLY___ ══════════════════════════════
778
+ 2026-08-24 13:27:47,782 INFO ___FILE_ONLY___ ══════════════════════════════
779
+ 2026-08-24 13:27:47,782 INFO ___FILE_ONLY___ ╝
780
+
781
+ 2026-08-24 13:27:47,788 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
782
+
783
+ 2026-08-24 13:27:47,788 INFO ___FILE_ONLY___ ╠═ Installing: Google Cloud CRC32C Hash Tool ��╣
784
+
785
+ 2026-08-24 13:27:47,788 INFO ___FILE_ONLY___ ╚
786
+ 2026-08-24 13:27:47,791 INFO ___FILE_ONLY___ ════════════════════════════════════════════════════════════
787
+ 2026-08-24 13:27:47,791 INFO ___FILE_ONLY___ ╝
788
+
789
+ 2026-08-24 13:27:47,793 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
790
+
791
+ 2026-08-24 13:27:47,793 INFO ___FILE_ONLY___ ╠═ Installing: Google Cloud CRC32C Hash Tool (Platform S... ═╣
792
+
793
+ 2026-08-24 13:27:47,793 INFO ___FILE_ONLY___ ╚
794
+ 2026-08-24 13:27:47,824 INFO ___FILE_ONLY___ ══════════════════════════════
795
+ 2026-08-24 13:27:47,824 INFO ___FILE_ONLY___ ══════════════════════════════
796
+ 2026-08-24 13:27:47,824 INFO ___FILE_ONLY___ ╝
797
+
798
+ 2026-08-24 13:27:47,830 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
799
+
800
+ 2026-08-24 13:27:47,830 INFO ___FILE_ONLY___ ╠═ Installing: gcloud cli dependencies (Platform Specific) ═╣
801
+
802
+ 2026-08-24 13:27:47,830 INFO ___FILE_ONLY___ ╚
803
+ 2026-08-24 13:27:47,831 INFO ___FILE_ONLY___ ════════════════════════════════════════════════════════════
804
+ 2026-08-24 13:27:47,831 INFO ___FILE_ONLY___ ╝
805
+
806
+ 2026-08-24 13:27:47,836 DEBUG root Updating notification cache...
807
+ 2026-08-24 13:27:47,836 INFO ___FILE_ONLY___
808
+
809
+ 2026-08-24 13:27:47,838 INFO ___FILE_ONLY___ Performing post processing steps...
810
+ 2026-08-24 13:27:47,839 DEBUG root Executing command: ['/tools/google-cloud-sdk/bin/gcloud', 'components', 'post-process']
811
+ 2026-08-24 13:27:53,016 DEBUG ___FILE_ONLY___
812
+ 2026-08-24 13:27:53,016 DEBUG ___FILE_ONLY___
813
+ 2026-08-24 13:27:53,131 INFO root descriptor_list: [{'universeDomain': 'googleapis.com', 'universeShortName': '', 'authenticationDomain': 'auth.cloud.google.com', 'projectPrefix': '', 'cloudWebDomain': 'cloud.google.com', 'documentationDomain': 'cloud.google.com', 'version': '1.0.0', 'state': 'primary', 'artifactRegistryDomain': 'pkg.dev'}]
814
+ 2026-08-24 13:27:53,132 INFO ___FILE_ONLY___
815
+ Update done!
816
+
817
+
818
+ 2026-08-24 13:27:53,134 DEBUG root Chosen display Format:none
819
+ 2026-08-24 13:27:53,135 INFO root Display format: "none"
.config/logs/2026.08.24/13.27.48.254038.log ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ 2026-08-24 13:27:48,254 DEBUG root Loaded Command Group: ['gcloud', 'components']
2
+ 2026-08-24 13:27:48,255 DEBUG root Loaded Command Group: ['gcloud', 'components', 'post_process']
3
+ 2026-08-24 13:27:48,257 DEBUG root Running [gcloud.components.post-process] with arguments: []
4
+ 2026-08-24 13:27:52,894 DEBUG root Chosen display Format:none
5
+ 2026-08-24 13:27:52,894 INFO root Display format: "none"
.config/logs/2026.08.24/13.27.53.584308.log ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 2026-08-24 13:27:53,584 DEBUG root Loaded Command Group: ['gcloud', 'components']
2
+ 2026-08-24 13:27:53,611 DEBUG root Loaded Command Group: ['gcloud', 'components', 'update']
3
+ 2026-08-24 13:27:53,612 DEBUG root Running [gcloud.components.update] with arguments: [--quiet: "True", COMPONENT-IDS:8: "['gcloud', 'core', 'bq', 'gsutil', 'compute', 'preview', 'alpha', 'beta']"]
4
+ 2026-08-24 13:27:53,613 DEBUG root On GCE from disk cache: False
5
+ 2026-08-24 13:27:53,613 INFO ___FILE_ONLY___ Beginning update. This process may take several minutes.
6
+
7
+ 2026-08-24 13:27:53,614 DEBUG root On GCE from memory cache: False
8
+ 2026-08-24 13:27:53,616 DEBUG root On GCE from memory cache: False
9
+ 2026-08-24 13:27:53,617 DEBUG urllib3.connectionpool Starting new HTTPS connection (1): dl.google.com:443
10
+ 2026-08-24 13:27:53,628 DEBUG urllib3.connectionpool https://dl.google.com:443 "GET /dl/cloudsdk/channels/rapid/components-2.json HTTP/1.1" 200 28475
11
+ 2026-08-24 13:27:53,636 WARNING root Component [compute] no longer exists.
12
+ 2026-08-24 13:27:53,637 INFO ___FILE_ONLY___
13
+
14
+ 2026-08-24 13:27:53,637 INFO ___FILE_ONLY___
15
+ Your current Google Cloud CLI version is: 581.0.0
16
+
17
+ 2026-08-24 13:27:53,637 INFO ___FILE_ONLY___ Installing components from version: 581.0.0
18
+
19
+ 2026-08-24 13:27:53,637 INFO ___FILE_ONLY___
20
+
21
+ 2026-08-24 13:27:53,637 DEBUG root Chosen display Format:table[box,title="These components will be removed."](details.display_name:label=Name:align=left,version.version_string:label=Version:align=right,data.size.size(zero="",min=1048576):label=Size:align=right)
22
+ 2026-08-24 13:27:53,638 DEBUG root Chosen display Format:table[box,title="These components will be updated."](details.display_name:label=Name:align=left,version.version_string:label=Version:align=right,data.size.size(zero="",min=1048576):label=Size:align=right)
23
+ 2026-08-24 13:27:53,638 DEBUG root Chosen display Format:table[box,title="These components will be installed."](details.display_name:label=Name:align=left,version.version_string:label=Version:align=right,data.size.size(zero="",min=1048576):label=Size:align=right)
24
+ 2026-08-24 13:27:53,653 INFO ___FILE_ONLY___ ┌────────────────────────────────────────────────┐
25
+ 2026-08-24 13:27:53,653 INFO ___FILE_ONLY___
26
+
27
+ 2026-08-24 13:27:53,653 INFO ___FILE_ONLY___ │ These components will be installed. │
28
+ 2026-08-24 13:27:53,653 INFO ___FILE_ONLY___
29
+
30
+ 2026-08-24 13:27:53,653 INFO ___FILE_ONLY___ ├─────────────────────────┬────────────┬─────────┤
31
+ 2026-08-24 13:27:53,653 INFO ___FILE_ONLY___
32
+
33
+ 2026-08-24 13:27:53,653 INFO ___FILE_ONLY___ │ Name │ Version │ Size │
34
+ 2026-08-24 13:27:53,654 INFO ___FILE_ONLY___
35
+
36
+ 2026-08-24 13:27:53,654 INFO ___FILE_ONLY___ ├─────────────────────────┼────────────┼─────────┤
37
+ 2026-08-24 13:27:53,654 INFO ___FILE_ONLY___
38
+
39
+ 2026-08-24 13:27:53,654 INFO ___FILE_ONLY___ │
40
+ 2026-08-24 13:27:53,654 INFO ___FILE_ONLY___ gcloud Alpha Commands
41
+ 2026-08-24 13:27:53,654 INFO ___FILE_ONLY___
42
+ 2026-08-24 13:27:53,654 INFO ___FILE_ONLY___ │
43
+ 2026-08-24 13:27:53,654 INFO ___FILE_ONLY___ 2026.08.14
44
+ 2026-08-24 13:27:53,654 INFO ___FILE_ONLY___
45
+ 2026-08-24 13:27:53,654 INFO ___FILE_ONLY___ │
46
+ 2026-08-24 13:27:53,654 INFO ___FILE_ONLY___ < 1 MiB
47
+ 2026-08-24 13:27:53,654 INFO ___FILE_ONLY___
48
+ 2026-08-24 13:27:53,654 INFO ___FILE_ONLY___ │
49
+ 2026-08-24 13:27:53,654 INFO ___FILE_ONLY___
50
+
51
+ 2026-08-24 13:27:53,654 INFO ___FILE_ONLY___ │
52
+ 2026-08-24 13:27:53,654 INFO ___FILE_ONLY___ gcloud Beta Commands
53
+ 2026-08-24 13:27:53,654 INFO ___FILE_ONLY___
54
+ 2026-08-24 13:27:53,654 INFO ___FILE_ONLY___ │
55
+ 2026-08-24 13:27:53,654 INFO ___FILE_ONLY___ 2026.08.14
56
+ 2026-08-24 13:27:53,654 INFO ___FILE_ONLY___
57
+ 2026-08-24 13:27:53,654 INFO ___FILE_ONLY___ │
58
+ 2026-08-24 13:27:53,655 INFO ___FILE_ONLY___ < 1 MiB
59
+ 2026-08-24 13:27:53,655 INFO ___FILE_ONLY___
60
+ 2026-08-24 13:27:53,655 INFO ___FILE_ONLY___ │
61
+ 2026-08-24 13:27:53,655 INFO ___FILE_ONLY___
62
+
63
+ 2026-08-24 13:27:53,655 INFO ___FILE_ONLY___ │
64
+ 2026-08-24 13:27:53,655 INFO ___FILE_ONLY___ gcloud Preview Commands
65
+ 2026-08-24 13:27:53,655 INFO ___FILE_ONLY___
66
+ 2026-08-24 13:27:53,655 INFO ___FILE_ONLY___ │
67
+ 2026-08-24 13:27:53,655 INFO ___FILE_ONLY___ 2026.08.14
68
+ 2026-08-24 13:27:53,655 INFO ___FILE_ONLY___
69
+ 2026-08-24 13:27:53,655 INFO ___FILE_ONLY___ │
70
+ 2026-08-24 13:27:53,655 INFO ___FILE_ONLY___ < 1 MiB
71
+ 2026-08-24 13:27:53,655 INFO ___FILE_ONLY___
72
+ 2026-08-24 13:27:53,655 INFO ___FILE_ONLY___ │
73
+ 2026-08-24 13:27:53,655 INFO ___FILE_ONLY___
74
+
75
+ 2026-08-24 13:27:53,655 INFO ___FILE_ONLY___ └─────────────────────────┴────────────┴─────────┘
76
+ 2026-08-24 13:27:53,655 INFO ___FILE_ONLY___
77
+
78
+ 2026-08-24 13:27:53,655 INFO ___FILE_ONLY___
79
+
80
+ 2026-08-24 13:27:53,656 DEBUG root On GCE from memory cache: False
81
+ 2026-08-24 13:27:53,657 DEBUG root On GCE from memory cache: False
82
+ 2026-08-24 13:27:53,658 DEBUG urllib3.connectionpool Starting new HTTPS connection (1): dl.google.com:443
83
+ 2026-08-24 13:27:53,673 DEBUG urllib3.connectionpool https://dl.google.com:443 "GET /dl/cloudsdk/channels/rapid/RELEASE_NOTES HTTP/1.1" 200 399308
84
+ 2026-08-24 13:27:54,157 INFO ___FILE_ONLY___ For the latest full release notes, please visit:
85
+ https://cloud.google.com/sdk/release_notes
86
+
87
+
88
+ 2026-08-24 13:27:54,158 INFO ___FILE_ONLY___ Performing in place update...
89
+
90
+
91
+ 2026-08-24 13:27:54,160 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
92
+
93
+ 2026-08-24 13:27:54,160 INFO ___FILE_ONLY___ ╠═ Downloading: gcloud Alpha Commands ═╣
94
+
95
+ 2026-08-24 13:27:54,160 INFO ___FILE_ONLY___ ╚
96
+ 2026-08-24 13:27:54,161 DEBUG root On GCE from memory cache: False
97
+ 2026-08-24 13:27:54,162 DEBUG root On GCE from memory cache: False
98
+ 2026-08-24 13:27:54,162 DEBUG urllib3.connectionpool Starting new HTTPS connection (1): dl.google.com:443
99
+ 2026-08-24 13:27:54,224 DEBUG urllib3.connectionpool https://dl.google.com:443 "GET /dl/cloudsdk/channels/rapid/components/google-cloud-sdk-alpha-20260814074256.tar.gz HTTP/1.1" 200 761
100
+ 2026-08-24 13:27:54,225 INFO ___FILE_ONLY___ ════════════════════════════════════════════════════════════
101
+ 2026-08-24 13:27:54,225 INFO ___FILE_ONLY___ ╝
102
+
103
+ 2026-08-24 13:27:54,227 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
104
+
105
+ 2026-08-24 13:27:54,227 INFO ___FILE_ONLY___ ╠═ Downloading: gcloud Beta Commands ═╣
106
+
107
+ 2026-08-24 13:27:54,227 INFO ___FILE_ONLY___ ╚
108
+ 2026-08-24 13:27:54,228 DEBUG root On GCE from memory cache: False
109
+ 2026-08-24 13:27:54,229 DEBUG root On GCE from memory cache: False
110
+ 2026-08-24 13:27:54,229 DEBUG urllib3.connectionpool Starting new HTTPS connection (1): dl.google.com:443
111
+ 2026-08-24 13:27:54,239 DEBUG urllib3.connectionpool https://dl.google.com:443 "GET /dl/cloudsdk/channels/rapid/components/google-cloud-sdk-beta-20260814074256.tar.gz HTTP/1.1" 200 758
112
+ 2026-08-24 13:27:54,239 INFO ___FILE_ONLY___ ════════════════════════════════════════════════════════════
113
+ 2026-08-24 13:27:54,239 INFO ___FILE_ONLY___ ╝
114
+
115
+ 2026-08-24 13:27:54,241 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
116
+
117
+ 2026-08-24 13:27:54,242 INFO ___FILE_ONLY___ ╠═ Downloading: gcloud Preview Commands ═╣
118
+
119
+ 2026-08-24 13:27:54,242 INFO ___FILE_ONLY___ ╚
120
+ 2026-08-24 13:27:54,242 DEBUG root On GCE from memory cache: False
121
+ 2026-08-24 13:27:54,243 DEBUG root On GCE from memory cache: False
122
+ 2026-08-24 13:27:54,244 DEBUG urllib3.connectionpool Starting new HTTPS connection (1): dl.google.com:443
123
+ 2026-08-24 13:27:54,300 DEBUG urllib3.connectionpool https://dl.google.com:443 "GET /dl/cloudsdk/channels/rapid/components/google-cloud-sdk-preview-20260814074256.tar.gz HTTP/1.1" 200 782
124
+ 2026-08-24 13:27:54,301 INFO ___FILE_ONLY___ ════════════════════════════════════════════════════════════
125
+ 2026-08-24 13:27:54,301 INFO ___FILE_ONLY___ ╝
126
+
127
+ 2026-08-24 13:27:54,303 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
128
+
129
+ 2026-08-24 13:27:54,303 INFO ___FILE_ONLY___ ╠═ Installing: gcloud Alpha Commands ═╣
130
+
131
+ 2026-08-24 13:27:54,303 INFO ___FILE_ONLY___ ╚
132
+ 2026-08-24 13:27:54,304 INFO ___FILE_ONLY___ ═══════════════════════════��════════════════════════════════
133
+ 2026-08-24 13:27:54,304 INFO ___FILE_ONLY___ ╝
134
+
135
+ 2026-08-24 13:27:54,310 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
136
+
137
+ 2026-08-24 13:27:54,310 INFO ___FILE_ONLY___ ╠═ Installing: gcloud Beta Commands ═╣
138
+
139
+ 2026-08-24 13:27:54,310 INFO ___FILE_ONLY___ ╚
140
+ 2026-08-24 13:27:54,311 INFO ___FILE_ONLY___ ════════════════════════════════════════════════════════════
141
+ 2026-08-24 13:27:54,311 INFO ___FILE_ONLY___ ╝
142
+
143
+ 2026-08-24 13:27:54,314 INFO ___FILE_ONLY___ ╔════════════════════════════════════════════════════════════╗
144
+
145
+ 2026-08-24 13:27:54,314 INFO ___FILE_ONLY___ ╠═ Installing: gcloud Preview Commands ═╣
146
+
147
+ 2026-08-24 13:27:54,315 INFO ___FILE_ONLY___ ╚
148
+ 2026-08-24 13:27:54,315 INFO ___FILE_ONLY___ ════════════════════════════════════════════════════════════
149
+ 2026-08-24 13:27:54,315 INFO ___FILE_ONLY___ ╝
150
+
151
+ 2026-08-24 13:27:54,321 DEBUG root Updating notification cache...
152
+ 2026-08-24 13:27:54,321 INFO ___FILE_ONLY___
153
+
154
+ 2026-08-24 13:27:54,323 INFO ___FILE_ONLY___ Performing post processing steps...
155
+ 2026-08-24 13:27:54,324 DEBUG root Executing command: ['/tools/google-cloud-sdk/bin/gcloud', 'components', 'post-process']
156
+ 2026-08-24 13:27:59,763 DEBUG ___FILE_ONLY___
157
+ 2026-08-24 13:27:59,763 DEBUG ___FILE_ONLY___
158
+ 2026-08-24 13:27:59,844 INFO root descriptor_list: [{'universeDomain': 'googleapis.com', 'universeShortName': '', 'authenticationDomain': 'auth.cloud.google.com', 'projectPrefix': '', 'cloudWebDomain': 'cloud.google.com', 'documentationDomain': 'cloud.google.com', 'version': '1.0.0', 'state': 'primary', 'artifactRegistryDomain': 'pkg.dev'}]
159
+ 2026-08-24 13:27:59,844 INFO ___FILE_ONLY___
160
+ Update done!
161
+
162
+
163
+ 2026-08-24 13:27:59,846 DEBUG root Chosen display Format:none
164
+ 2026-08-24 13:27:59,846 INFO root Display format: "none"
.config/logs/2026.08.24/13.27.54.687874.log ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ 2026-08-24 13:27:54,688 DEBUG root Loaded Command Group: ['gcloud', 'components']
2
+ 2026-08-24 13:27:54,689 DEBUG root Loaded Command Group: ['gcloud', 'components', 'post_process']
3
+ 2026-08-24 13:27:54,691 DEBUG root Running [gcloud.components.post-process] with arguments: []
4
+ 2026-08-24 13:27:59,682 DEBUG root Chosen display Format:none
5
+ 2026-08-24 13:27:59,682 INFO root Display format: "none"
.config/logs/2026.08.24/13.28.00.267545.log ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ 2026-08-24 13:28:00,270 DEBUG root Loaded Command Group: ['gcloud', 'config']
2
+ 2026-08-24 13:28:00,340 DEBUG root Loaded Command Group: ['gcloud', 'config', 'set']
3
+ 2026-08-24 13:28:00,342 DEBUG root Running [gcloud.config.set] with arguments: [SECTION/PROPERTY: "component_manager/disable_update_check", VALUE: "true"]
4
+ 2026-08-24 13:28:00,342 INFO ___FILE_ONLY___ Updated property [component_manager/disable_update_check].
5
+
6
+ 2026-08-24 13:28:00,343 DEBUG root Chosen display Format:default
7
+ 2026-08-24 13:28:00,343 INFO root Display format: "default"
8
+ 2026-08-24 13:28:00,347 DEBUG root SDK update checks are disabled.
.config/logs/2026.08.24/13.28.00.789021.log ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ 2026-08-24 13:28:00,792 DEBUG root Loaded Command Group: ['gcloud', 'config']
2
+ 2026-08-24 13:28:00,854 DEBUG root Loaded Command Group: ['gcloud', 'config', 'set']
3
+ 2026-08-24 13:28:00,856 DEBUG root Running [gcloud.config.set] with arguments: [SECTION/PROPERTY: "compute/gce_metadata_read_timeout_sec", VALUE: "0"]
4
+ 2026-08-24 13:28:00,856 INFO ___FILE_ONLY___ Updated property [compute/gce_metadata_read_timeout_sec].
5
+
6
+ 2026-08-24 13:28:00,857 DEBUG root Chosen display Format:default
7
+ 2026-08-24 13:28:00,857 INFO root Display format: "default"
8
+ 2026-08-24 13:28:00,861 DEBUG root SDK update checks are disabled.
.gitattributes CHANGED
@@ -33,3 +33,16 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ 1/custom_nodes/ComfyUI-LTXVideo/example_workflows/assets/base[[:space:]]model[[:space:]]image.png filter=lfs diff=lfs merge=lfs -text
37
+ 1/custom_nodes/ComfyUI-LTXVideo/example_workflows/assets/buildings[[:space:]]ff.png filter=lfs diff=lfs merge=lfs -text
38
+ 1/custom_nodes/ComfyUI-LTXVideo/example_workflows/assets/buildings.mp4 filter=lfs diff=lfs merge=lfs -text
39
+ 1/custom_nodes/ComfyUI-LTXVideo/example_workflows/assets/distilled[[:space:]]image.png filter=lfs diff=lfs merge=lfs -text
40
+ 1/custom_nodes/ComfyUI-LTXVideo/example_workflows/assets/dubit_input.mp4 filter=lfs diff=lfs merge=lfs -text
41
+ 1/custom_nodes/ComfyUI-LTXVideo/example_workflows/assets/hdr_input_video.mp4 filter=lfs diff=lfs merge=lfs -text
42
+ 1/custom_nodes/ComfyUI-LTXVideo/example_workflows/assets/ingredients_input.jpg filter=lfs diff=lfs merge=lfs -text
43
+ 1/custom_nodes/ComfyUI-LTXVideo/example_workflows/assets/inpainting_input.mp4 filter=lfs diff=lfs merge=lfs -text
44
+ 1/custom_nodes/ComfyUI-LTXVideo/example_workflows/assets/instant_shave_input.mp4 filter=lfs diff=lfs merge=lfs -text
45
+ 1/custom_nodes/ComfyUI-LTXVideo/example_workflows/assets/motion_track_input.jpg filter=lfs diff=lfs merge=lfs -text
46
+ 1/custom_nodes/ComfyUI-LTXVideo/example_workflows/assets/outpainting_input.mp4 filter=lfs diff=lfs merge=lfs -text
47
+ 1/custom_nodes/ComfyUI-LTXVideo/example_workflows/assets/spatial_upscale_4x_input.mp4 filter=lfs diff=lfs merge=lfs -text
48
+ 1/custom_nodes/ComfyUI-LTXVideo/gemma_configs/tokenizer.json filter=lfs diff=lfs merge=lfs -text
1/custom_nodes/ComfyUI-Custom-Scripts/.github/workflows/publish.yml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Publish to Comfy registry
2
+ on:
3
+ workflow_dispatch:
4
+ push:
5
+ branches:
6
+ - main
7
+ paths:
8
+ - "pyproject.toml"
9
+
10
+ permissions:
11
+ issues: write
12
+
13
+ jobs:
14
+ publish-node:
15
+ name: Publish Custom Node to registry
16
+ runs-on: ubuntu-latest
17
+ if: ${{ github.repository_owner == 'pythongosssss' }}
18
+ steps:
19
+ - name: Check out code
20
+ uses: actions/checkout@v4
21
+ - name: Publish Custom Node
22
+ uses: Comfy-Org/publish-node-action@v1
23
+ with:
24
+ ## Add your own personal access token to your Github Repository secrets and reference it here.
25
+ personal_access_token: ${{ secrets.REGISTRY_ACCESS_TOKEN }}
1/custom_nodes/ComfyUI-Custom-Scripts/.gitignore ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ __pycache__
2
+ pysssss.json
3
+ user/autocomplete.txt
4
+ web/js/assets/favicon.user.ico
5
+ web/js/assets/favicon-active.user.ico
1/custom_nodes/ComfyUI-Custom-Scripts/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2023 pythongosssss
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
1/custom_nodes/ComfyUI-Custom-Scripts/README.md ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ComfyUI-Custom-Scripts
2
+
3
+ ### ⚠️ While these extensions work for the most part, i'm very busy at the moment and so unable to keep on top of everything here, thanks for your patience!
4
+
5
+ # Installation
6
+
7
+ 1. Clone the repository:
8
+ `git clone https://github.com/pythongosssss/ComfyUI-Custom-Scripts.git`
9
+ to your ComfyUI `custom_nodes` directory
10
+
11
+ The script will then automatically install all custom scripts and nodes.
12
+ It will attempt to use symlinks and junctions to prevent having to copy files and keep them up to date.
13
+
14
+ - For uninstallation:
15
+ - Delete the cloned repo in `custom_nodes`
16
+ - Ensure `web/extensions/pysssss/CustomScripts` has also been removed
17
+
18
+ # Update
19
+ 1. Navigate to the cloned repo e.g. `custom_nodes/ComfyUI-Custom-Scripts`
20
+ 2. `git pull`
21
+
22
+ # Features
23
+
24
+ ## Autocomplete
25
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/b5971135-414f-4f4e-a6cf-2650dc01085f)
26
+ Provides embedding and custom word autocomplete. You can view embedding details by clicking on the info icon on the list.
27
+ Define your list of custom words via the settings.
28
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/160ef61c-7d7e-49d0-b60f-5a1501b74c9d)
29
+ You can quickly default to danbooru tags using the Load button, or load/manage other custom word lists.
30
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/cc180b35-5f45-442f-9285-3ddf3fa320d0)
31
+
32
+ ## Auto Arrange Graph
33
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/04b06081-ca6f-4c0f-8584-d0a157c36747)
34
+ Adds a menu option to auto arrange the graph in order of execution, this makes very wide graphs!
35
+
36
+ ## Always Snap to Grid
37
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/66f36d1f-e579-4959-9880-9a9624922e3a)
38
+ Adds a setting to make moving nodes always snap to grid.
39
+
40
+ ## [Testing] "Better" Loader Lists
41
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/664caa71-f25f-4a96-a04a-1466d6b2b8b4)
42
+ Adds custom Lora and Checkpoint loader nodes, these have the ability to show preview images, just place a png or jpg next to the file and it'll display in the list on hover (e.g. sdxl.safetensors and sdxl.png).
43
+ Optionally enable subfolders via the settings:
44
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/e15b5e83-4f9d-4d57-8324-742bedf75439)
45
+ Adds an "examples" widget to load sample prompts, triggerwords, etc:
46
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/ad1751e4-4c85-42e7-9490-e94fb1cbc8e7)
47
+ These should be stored in a folder matching the name of the model, e.g. if it is `loras/add_detail.safetensors` put your files in as `loras/add_detail/*.txt`
48
+ To quickly save a generated image as the preview to use for the model, you can right click on an image on a node, and select Save as Preview and choose the model to save the preview for:
49
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/9fa8e9db-27b3-45cb-85c2-0860a238fd3a)
50
+
51
+ ## Checkpoint/LoRA/Embedding Info
52
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/6b67bf40-ee17-4fa6-a0c1-7947066bafc2)
53
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/32405df6-b367-404f-a5df-2d4347089a9e)
54
+ Adds "View Info" menu option to view details about the selected LoRA or Checkpoint. To view embedding details, click the info button when using embedding autocomplete.
55
+
56
+ ## Constrain Image
57
+ Adds a node for resizing an image to a max & min size optionally cropping if required.
58
+
59
+ ## Custom Colors
60
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/fa7883f3-f81c-49f6-9ab6-9526e4debab6)
61
+ Adds a custom color picker to nodes & groups
62
+
63
+ ## Favicon Status
64
+ ![image](https://user-images.githubusercontent.com/125205205/230171227-31f061a6-6324-4976-bed9-723a87500cf3.png)
65
+ ![image](https://user-images.githubusercontent.com/125205205/230171445-c7202a45-b511-4d69-87fa-945ad44c063f.png)
66
+ Adds a favicon and title to the window, favicon changes color while generating and the window title includes the number of prompts in the queue
67
+
68
+ ## Image Feed
69
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/caea0d48-85b9-4ca9-9771-5c795db35fbc)
70
+ Adds a panel showing images that have been generated in the current session, you can control the direction that images are added and the position of the panel via the ComfyUI settings screen and the size of the panel and the images via the sliders at the top of the panel.
71
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/ca093d38-41a3-4647-9223-5bd0b9ee4f1e)
72
+
73
+ ## KSampler (Advanced) denoise helper
74
+ Provides a simple method to set custom denoise on the advanced sampler
75
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/42946bd8-0078-4c7a-bfe9-7adb1382b5e2)
76
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/7cfccb22-f155-4848-934b-a2b2a6efe16f)
77
+
78
+ ## Math Expression
79
+ Allows for evaluating complex expressions using values from the graph. You can input `INT`, `FLOAT`, `IMAGE` and `LATENT` values.
80
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/1593edde-67b8-45d8-88cb-e75f52dba039)
81
+ Other nodes values can be referenced via the `Node name for S&R` via the `Properties` menu item on a node, or the node title.
82
+ Supported operators: `+ - * /` (basic ops) `//` (floor division) `**` (power) `^` (xor) `%` (mod)
83
+ Supported functions `floor(num, dp?)` `floor(num)` `ceil(num)` `randomint(min,max)`
84
+ If using a `LATENT` or `IMAGE` you can get the dimensions using `a.width` or `a.height` where `a` is the input name.
85
+
86
+ ## Node Finder
87
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/177d2b67-acbc-4ec3-ab31-7c295a98c194)
88
+ Adds a menu item for following/jumping to the executing node, and a menu to quickly go to a node of a specific type.
89
+
90
+ ## Preset Text
91
+ ![image](https://user-images.githubusercontent.com/125205205/230173939-08459efc-785b-46da-93d1-b02f0300c6f4.png)
92
+ Adds a node that lets you save and use text presets (e.g. for your 'normal' negatives)
93
+
94
+ ## Quick Nodes
95
+ ![image](https://user-images.githubusercontent.com/125205205/230174266-5232831a-a03b-4bf7-bc8b-c45466a0bc64.png)
96
+ Adds various menu items to some nodes for quickly setting up common parts of graphs
97
+
98
+ ## Play Sound
99
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/9bcf9fb3-5898-4432-a974-fb1e17d3b7e8)
100
+ Plays a sound when the node is executed, either after each prompt or only when the queue is empty for queuing multiple prompts.
101
+ You can customize the sound by replacing the mp3 file `ComfyUI/custom_nodes/ComfyUI-Custom-Scripts/web/js/assets/notify.mp3`
102
+
103
+ ## System Notification
104
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/30354775/993fd783-5cd6-4779-aa97-173bc06cc405)
105
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/30354775/e45227fb-5714-4f45-b96b-6601902ef6e2)
106
+
107
+ Sends a system notification via the browser when the node is executed, either after each prompt or only when the queue is empty for queuing multiple prompts.
108
+
109
+ ## [WIP] Repeater
110
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/ec0dac25-14e4-4d44-b975-52193656709d)
111
+ Node allows you to either create a list of N repeats of the input node, or create N outputs from the input node.
112
+ You can optionally decide if you want to reuse the input node, or create a new instance each time (e.g. a Checkpoint Loader would want to be re-used, but a random number would want to be unique)
113
+ TODO: Type safety on the wildcard outputs to require match with input
114
+
115
+ ## Show Text
116
+ ![image](https://user-images.githubusercontent.com/125205205/230174888-c004fd48-da78-4de9-81c2-93a866fcfcd1.png)
117
+ Takes input from a node that produces a string and displays it, useful for things like interrogator, prompt generators, etc.
118
+
119
+ ## Show Image on Menu
120
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/b6ab58f2-583b-448c-bcfc-f93f5cdab0fc)
121
+ Shows the current generating image on the menu at the bottom, you can disable this via the settings menu.
122
+
123
+ ## String Function
124
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/01107137-8a93-4765-bae0-fcc110a09091)
125
+ Supports appending and replacing text
126
+ `tidy_tags` will add commas between parts when in `append` mode.
127
+ `replace` mode supports regex replace by using `/your regex here/` and you can reference capturing groups using `\number` e.g. `\1`
128
+
129
+ ## Touch Support
130
+ Provides basic support for touch screen devices, its not perfect but better than nothing
131
+
132
+ ## Widget Defaults
133
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/3d675032-2b19-4da8-a7d7-fa2d7c555daa)
134
+ Allows you to specify default values for widgets when adding new nodes, the values are configured via the settings menu
135
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/7b57a3d8-98d3-46e9-9b33-6645c0da41e7)
136
+
137
+ ## Workflows
138
+ Adds options to the menu for saving + loading workflows:
139
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/7b5a3012-4c59-47c6-8eea-85cf534403ea)
140
+
141
+ ## Workflow Images
142
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/06453fd2-c020-46ee-a7db-2b8bf5bcba7e)
143
+ Adds menu options for importing/exporting the graph as SVG and PNG showing a view of the nodes
144
+
145
+ ## (Testing) Reroute Primitive
146
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/8b870eef-d572-43f9-b394-cfa7abbd2f98) Provides a node that allows rerouting primitives.
147
+ The node can also be collapsed to a single point that you can drag around.
148
+ ![image](https://github.com/pythongosssss/ComfyUI-Custom-Scripts/assets/125205205/a9bd0112-cf8f-44f3-af6d-f9a8fed152a7)
149
+ Warning: Don't use normal reroutes or primitives with these nodes, it isn't tested and this node replaces their functionality.
150
+
151
+ <br>
152
+ <br>
153
+
154
+
155
+ ## WD14 Tagger
156
+ Moved to: https://github.com/pythongosssss/ComfyUI-WD14-Tagger
157
+
158
+ ## ~~Lock Nodes & Groups~~
159
+ This is now a standard feature of ComfyUI
160
+ ~~Adds a lock option to nodes & groups that prevents you from moving them until unlocked~~
1/custom_nodes/ComfyUI-Custom-Scripts/__init__.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import importlib.util
2
+ import glob
3
+ import os
4
+ import sys
5
+ from .pysssss import init, get_ext_dir
6
+
7
+ NODE_CLASS_MAPPINGS = {}
8
+ NODE_DISPLAY_NAME_MAPPINGS = {}
9
+
10
+ if init():
11
+ py = get_ext_dir("py")
12
+ files = glob.glob(os.path.join(py, "*.py"), recursive=False)
13
+ for file in files:
14
+ name = os.path.splitext(file)[0]
15
+ spec = importlib.util.spec_from_file_location(name, file)
16
+ module = importlib.util.module_from_spec(spec)
17
+ sys.modules[name] = module
18
+ spec.loader.exec_module(module)
19
+ if hasattr(module, "NODE_CLASS_MAPPINGS") and getattr(module, "NODE_CLASS_MAPPINGS") is not None:
20
+ NODE_CLASS_MAPPINGS.update(module.NODE_CLASS_MAPPINGS)
21
+ if hasattr(module, "NODE_DISPLAY_NAME_MAPPINGS") and getattr(module, "NODE_DISPLAY_NAME_MAPPINGS") is not None:
22
+ NODE_DISPLAY_NAME_MAPPINGS.update(module.NODE_DISPLAY_NAME_MAPPINGS)
23
+
24
+ WEB_DIRECTORY = "./web"
25
+ __all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"]
1/custom_nodes/ComfyUI-Custom-Scripts/py/autocomplete.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from server import PromptServer
2
+ from aiohttp import web
3
+ import os
4
+ import folder_paths
5
+
6
+ dir = os.path.abspath(os.path.join(__file__, "../../user"))
7
+ if not os.path.exists(dir):
8
+ os.mkdir(dir)
9
+ file = os.path.join(dir, "autocomplete.txt")
10
+
11
+
12
+ @PromptServer.instance.routes.get("/pysssss/autocomplete")
13
+ async def get_autocomplete(request):
14
+ if os.path.isfile(file):
15
+ return web.FileResponse(file)
16
+ return web.Response(status=404)
17
+
18
+
19
+ @PromptServer.instance.routes.post("/pysssss/autocomplete")
20
+ async def update_autocomplete(request):
21
+ with open(file, "w", encoding="utf-8") as f:
22
+ f.write(await request.text())
23
+ return web.Response(status=200)
24
+
25
+
26
+ @PromptServer.instance.routes.get("/pysssss/loras")
27
+ async def get_loras(request):
28
+ loras = folder_paths.get_filename_list("loras")
29
+ return web.json_response(list(map(lambda a: os.path.splitext(a)[0], loras)))
1/custom_nodes/ComfyUI-Custom-Scripts/py/better_combos.py ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import glob
2
+ import os
3
+ from nodes import LoraLoader, CheckpointLoaderSimple
4
+ import folder_paths
5
+ from server import PromptServer
6
+ from folder_paths import get_directory_by_type
7
+ from aiohttp import web
8
+ import shutil
9
+
10
+
11
+ @PromptServer.instance.routes.get("/pysssss/view/{name}")
12
+ async def view(request):
13
+ name = request.match_info["name"]
14
+ pos = name.index("/")
15
+ type = name[0:pos]
16
+ name = name[pos+1:]
17
+
18
+ image_path = folder_paths.get_full_path(
19
+ type, name)
20
+ if not image_path:
21
+ return web.Response(status=404)
22
+
23
+ filename = os.path.basename(image_path)
24
+ return web.FileResponse(image_path, headers={"Content-Disposition": f"filename=\"{filename}\""})
25
+
26
+
27
+ @PromptServer.instance.routes.post("/pysssss/save/{name}")
28
+ async def save_preview(request):
29
+ name = request.match_info["name"]
30
+ pos = name.index("/")
31
+ type = name[0:pos]
32
+ name = name[pos+1:]
33
+
34
+ body = await request.json()
35
+
36
+ dir = get_directory_by_type(body.get("type", "output"))
37
+ subfolder = body.get("subfolder", "")
38
+ full_output_folder = os.path.join(dir, os.path.normpath(subfolder))
39
+
40
+ filepath = os.path.join(full_output_folder, body.get("filename", ""))
41
+
42
+ if os.path.commonpath((dir, os.path.abspath(filepath))) != dir:
43
+ return web.Response(status=400)
44
+
45
+ image_path = folder_paths.get_full_path(type, name)
46
+ image_path = os.path.splitext(
47
+ image_path)[0] + os.path.splitext(filepath)[1]
48
+
49
+ shutil.copyfile(filepath, image_path)
50
+
51
+ return web.json_response({
52
+ "image": type + "/" + os.path.basename(image_path)
53
+ })
54
+
55
+
56
+ @PromptServer.instance.routes.get("/pysssss/examples/{name}")
57
+ async def get_examples(request):
58
+ name = request.match_info["name"]
59
+ pos = name.index("/")
60
+ type = name[0:pos]
61
+ name = name[pos+1:]
62
+
63
+ file_path = folder_paths.get_full_path(
64
+ type, name)
65
+ if not file_path:
66
+ return web.Response(status=404)
67
+
68
+ file_path_no_ext = os.path.splitext(file_path)[0]
69
+ examples = []
70
+
71
+ if os.path.isdir(file_path_no_ext):
72
+ examples += sorted(map(lambda t: os.path.relpath(t, file_path_no_ext),
73
+ glob.glob(file_path_no_ext + "/*.txt")))
74
+
75
+ if os.path.isfile(file_path_no_ext + ".txt"):
76
+ examples += ["notes"]
77
+
78
+ return web.json_response(examples)
79
+
80
+
81
+ @PromptServer.instance.routes.post("/pysssss/examples/{name}")
82
+ async def save_example(request):
83
+ name = request.match_info["name"]
84
+ pos = name.index("/")
85
+ type = name[0:pos]
86
+ name = name[pos+1:]
87
+ body = await request.json()
88
+ example_name = body["name"]
89
+ example = body["example"]
90
+
91
+ file_path = folder_paths.get_full_path(
92
+ type, name)
93
+ if not file_path:
94
+ return web.Response(status=404)
95
+
96
+ if not example_name.endswith(".txt"):
97
+ example_name += ".txt"
98
+
99
+ file_path_no_ext = os.path.splitext(file_path)[0]
100
+ example_file = os.path.join(file_path_no_ext, example_name)
101
+ if not os.path.exists(file_path_no_ext):
102
+ os.mkdir(file_path_no_ext)
103
+ with open(example_file, 'w', encoding='utf8') as f:
104
+ f.write(example)
105
+
106
+ return web.Response(status=201)
107
+
108
+
109
+ @PromptServer.instance.routes.get("/pysssss/images/{type}")
110
+ async def get_images(request):
111
+ type = request.match_info["type"]
112
+ names = folder_paths.get_filename_list(type)
113
+
114
+ images = {}
115
+ for item_name in names:
116
+ file_name = os.path.splitext(item_name)[0]
117
+ file_path = folder_paths.get_full_path(type, item_name)
118
+
119
+ if file_path is None:
120
+ continue
121
+
122
+ file_path_no_ext = os.path.splitext(file_path)[0]
123
+
124
+ for ext in ["png", "jpg", "jpeg", "preview.png", "preview.jpeg"]:
125
+ if os.path.isfile(file_path_no_ext + "." + ext):
126
+ images[item_name] = f"{type}/{file_name}.{ext}"
127
+ break
128
+
129
+ return web.json_response(images)
130
+
131
+
132
+ class LoraLoaderWithImages(LoraLoader):
133
+ RETURN_TYPES = (*LoraLoader.RETURN_TYPES, "STRING",)
134
+ RETURN_NAMES = (*getattr(LoraLoader, "RETURN_NAMES",
135
+ LoraLoader.RETURN_TYPES), "example")
136
+
137
+ @classmethod
138
+ def INPUT_TYPES(s):
139
+ types = super().INPUT_TYPES()
140
+ types["optional"] = {"prompt": ("STRING", {"hidden": True})}
141
+ return types
142
+
143
+ def load_lora(self, **kwargs):
144
+ prompt = kwargs.pop("prompt", "")
145
+ return (*super().load_lora(**kwargs), prompt)
146
+
147
+
148
+ class CheckpointLoaderSimpleWithImages(CheckpointLoaderSimple):
149
+ RETURN_TYPES = (*CheckpointLoaderSimple.RETURN_TYPES, "STRING",)
150
+ RETURN_NAMES = (*getattr(CheckpointLoaderSimple, "RETURN_NAMES",
151
+ CheckpointLoaderSimple.RETURN_TYPES), "example")
152
+
153
+ @classmethod
154
+ def INPUT_TYPES(s):
155
+ types = super().INPUT_TYPES()
156
+ types["optional"] = {"prompt": ("STRING", {"hidden": True})}
157
+ return types
158
+
159
+ def load_checkpoint(self, **kwargs):
160
+ prompt = kwargs.pop("prompt", "")
161
+ return (*super().load_checkpoint(**kwargs), prompt)
162
+
163
+
164
+ NODE_CLASS_MAPPINGS = {
165
+ "LoraLoader|pysssss": LoraLoaderWithImages,
166
+ "CheckpointLoader|pysssss": CheckpointLoaderSimpleWithImages,
167
+ }
168
+
169
+ NODE_DISPLAY_NAME_MAPPINGS = {
170
+ "LoraLoader|pysssss": "Lora Loader 🐍",
171
+ "CheckpointLoader|pysssss": "Checkpoint Loader 🐍",
172
+ }
1/custom_nodes/ComfyUI-Custom-Scripts/py/constrain_image.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import numpy as np
3
+ from PIL import Image
4
+
5
+ class ConstrainImage:
6
+ """
7
+ A node that constrains an image to a maximum and minimum size while maintaining aspect ratio.
8
+ """
9
+
10
+ @classmethod
11
+ def INPUT_TYPES(cls):
12
+ return {
13
+ "required": {
14
+ "images": ("IMAGE",),
15
+ "max_width": ("INT", {"default": 1024, "min": 0}),
16
+ "max_height": ("INT", {"default": 1024, "min": 0}),
17
+ "min_width": ("INT", {"default": 0, "min": 0}),
18
+ "min_height": ("INT", {"default": 0, "min": 0}),
19
+ "crop_if_required": (["yes", "no"], {"default": "no"}),
20
+ },
21
+ }
22
+
23
+ RETURN_TYPES = ("IMAGE",)
24
+ FUNCTION = "constrain_image"
25
+ CATEGORY = "image"
26
+ OUTPUT_IS_LIST = (True,)
27
+
28
+ def constrain_image(self, images, max_width, max_height, min_width, min_height, crop_if_required):
29
+ crop_if_required = crop_if_required == "yes"
30
+ results = []
31
+ for image in images:
32
+ i = 255. * image.cpu().numpy()
33
+ img = Image.fromarray(np.clip(i, 0, 255).astype(np.uint8)).convert("RGB")
34
+
35
+ current_width, current_height = img.size
36
+ aspect_ratio = current_width / current_height
37
+
38
+ constrained_width = min(max(current_width, min_width), max_width)
39
+ constrained_height = min(max(current_height, min_height), max_height)
40
+
41
+ if constrained_width / constrained_height > aspect_ratio:
42
+ constrained_width = max(int(constrained_height * aspect_ratio), min_width)
43
+ if crop_if_required:
44
+ constrained_height = int(current_height / (current_width / constrained_width))
45
+ else:
46
+ constrained_height = max(int(constrained_width / aspect_ratio), min_height)
47
+ if crop_if_required:
48
+ constrained_width = int(current_width / (current_height / constrained_height))
49
+
50
+ resized_image = img.resize((constrained_width, constrained_height), Image.LANCZOS)
51
+
52
+ if crop_if_required and (constrained_width > max_width or constrained_height > max_height):
53
+ left = max((constrained_width - max_width) // 2, 0)
54
+ top = max((constrained_height - max_height) // 2, 0)
55
+ right = min(constrained_width, max_width) + left
56
+ bottom = min(constrained_height, max_height) + top
57
+ resized_image = resized_image.crop((left, top, right, bottom))
58
+
59
+ resized_image = np.array(resized_image).astype(np.float32) / 255.0
60
+ resized_image = torch.from_numpy(resized_image)[None,]
61
+ results.append(resized_image)
62
+
63
+ return (results,)
64
+
65
+ NODE_CLASS_MAPPINGS = {
66
+ "ConstrainImage|pysssss": ConstrainImage,
67
+ }
68
+
69
+ NODE_DISPLAY_NAME_MAPPINGS = {
70
+ "ConstrainImage|pysssss": "Constrain Image 🐍",
71
+ }
1/custom_nodes/ComfyUI-Custom-Scripts/py/constrain_image_for_video.py ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import numpy as np
3
+ from PIL import Image
4
+
5
+ class ConstrainImageforVideo:
6
+ """
7
+ A node that constrains an image to a maximum and minimum size while maintaining aspect ratio.
8
+ """
9
+
10
+ @classmethod
11
+ def INPUT_TYPES(cls):
12
+ return {
13
+ "required": {
14
+ "images": ("IMAGE",),
15
+ "max_width": ("INT", {"default": 1024, "min": 0}),
16
+ "max_height": ("INT", {"default": 1024, "min": 0}),
17
+ "min_width": ("INT", {"default": 0, "min": 0}),
18
+ "min_height": ("INT", {"default": 0, "min": 0}),
19
+ "crop_if_required": (["yes", "no"], {"default": "no"}),
20
+ },
21
+ }
22
+
23
+ RETURN_TYPES = ("IMAGE",)
24
+ RETURN_NAMES = ("IMAGE",)
25
+ FUNCTION = "constrain_image_for_video"
26
+ CATEGORY = "image"
27
+
28
+ def constrain_image_for_video(self, images, max_width, max_height, min_width, min_height, crop_if_required):
29
+ crop_if_required = crop_if_required == "yes"
30
+ results = []
31
+ for image in images:
32
+ i = 255. * image.cpu().numpy()
33
+ img = Image.fromarray(np.clip(i, 0, 255).astype(np.uint8)).convert("RGB")
34
+
35
+ current_width, current_height = img.size
36
+ aspect_ratio = current_width / current_height
37
+
38
+ constrained_width = max(min(current_width, min_width), max_width)
39
+ constrained_height = max(min(current_height, min_height), max_height)
40
+
41
+ if constrained_width / constrained_height > aspect_ratio:
42
+ constrained_width = max(int(constrained_height * aspect_ratio), min_width)
43
+ if crop_if_required:
44
+ constrained_height = int(current_height / (current_width / constrained_width))
45
+ else:
46
+ constrained_height = max(int(constrained_width / aspect_ratio), min_height)
47
+ if crop_if_required:
48
+ constrained_width = int(current_width / (current_height / constrained_height))
49
+
50
+ resized_image = img.resize((constrained_width, constrained_height), Image.LANCZOS)
51
+
52
+ if crop_if_required and (constrained_width > max_width or constrained_height > max_height):
53
+ left = max((constrained_width - max_width) // 2, 0)
54
+ top = max((constrained_height - max_height) // 2, 0)
55
+ right = min(constrained_width, max_width) + left
56
+ bottom = min(constrained_height, max_height) + top
57
+ resized_image = resized_image.crop((left, top, right, bottom))
58
+
59
+ resized_image = np.array(resized_image).astype(np.float32) / 255.0
60
+ resized_image = torch.from_numpy(resized_image)[None,]
61
+ results.append(resized_image)
62
+ all_images = torch.cat(results, dim=0)
63
+
64
+ return (all_images, all_images.size(0),)
65
+
66
+ NODE_CLASS_MAPPINGS = {
67
+ "ConstrainImageforVideo|pysssss": ConstrainImageforVideo,
68
+ }
69
+
70
+ NODE_DISPLAY_NAME_MAPPINGS = {
71
+ "ConstrainImageforVideo|pysssss": "Constrain Image for Video 🐍",
72
+ }
1/custom_nodes/ComfyUI-Custom-Scripts/py/math_expression.py ADDED
@@ -0,0 +1,252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ast
2
+ import math
3
+ import random
4
+ import operator as op
5
+
6
+ # Hack: string type that is always equal in not equal comparisons
7
+ class AnyType(str):
8
+ def __ne__(self, __value: object) -> bool:
9
+ return False
10
+
11
+
12
+ # Our any instance wants to be a wildcard string
13
+ any = AnyType("*")
14
+
15
+ operators = {
16
+ ast.Add: op.add,
17
+ ast.Sub: op.sub,
18
+ ast.Mult: op.mul,
19
+ ast.Div: op.truediv,
20
+ ast.FloorDiv: op.floordiv,
21
+ ast.Pow: op.pow,
22
+ ast.BitXor: op.xor,
23
+ ast.USub: op.neg,
24
+ ast.Mod: op.mod,
25
+ ast.BitAnd: op.and_,
26
+ ast.BitOr: op.or_,
27
+ ast.Invert: op.invert,
28
+ ast.And: lambda a, b: 1 if a and b else 0,
29
+ ast.Or: lambda a, b: 1 if a or b else 0,
30
+ ast.Not: lambda a: 0 if a else 1,
31
+ ast.RShift: op.rshift,
32
+ ast.LShift: op.lshift
33
+ }
34
+
35
+ # TODO: restructure args to provide more info, generate hint based on args to save duplication
36
+ functions = {
37
+ "round": {
38
+ "args": (1, 2),
39
+ "call": lambda a, b = None: round(a, b),
40
+ "hint": "number, dp? = 0"
41
+ },
42
+ "ceil": {
43
+ "args": (1, 1),
44
+ "call": lambda a: math.ceil(a),
45
+ "hint": "number"
46
+ },
47
+ "floor": {
48
+ "args": (1, 1),
49
+ "call": lambda a: math.floor(a),
50
+ "hint": "number"
51
+ },
52
+ "min": {
53
+ "args": (2, None),
54
+ "call": lambda *args: min(*args),
55
+ "hint": "...numbers"
56
+ },
57
+ "max": {
58
+ "args": (2, None),
59
+ "call": lambda *args: max(*args),
60
+ "hint": "...numbers"
61
+ },
62
+ "randomint": {
63
+ "args": (2, 2),
64
+ "call": lambda a, b: random.randint(a, b),
65
+ "hint": "min, max"
66
+ },
67
+ "randomchoice": {
68
+ "args": (2, None),
69
+ "call": lambda *args: random.choice(args),
70
+ "hint": "...numbers"
71
+ },
72
+ "sqrt": {
73
+ "args": (1, 1),
74
+ "call": lambda a: math.sqrt(a),
75
+ "hint": "number"
76
+ },
77
+ "int": {
78
+ "args": (1, 1),
79
+ "call": lambda a = None: int(a),
80
+ "hint": "number"
81
+ },
82
+ "iif": {
83
+ "args": (3, 3),
84
+ "call": lambda a, b, c = None: b if a else c,
85
+ "hint": "value, truepart, falsepart"
86
+ },
87
+ }
88
+
89
+ autocompleteWords = list({
90
+ "text": x,
91
+ "value": f"{x}()",
92
+ "showValue": False,
93
+ "hint": f"{functions[x]['hint']}",
94
+ "caretOffset": -1
95
+ } for x in functions.keys())
96
+
97
+
98
+ class MathExpression:
99
+
100
+ @classmethod
101
+ def INPUT_TYPES(cls):
102
+ return {
103
+ "required": {
104
+ "expression": ("STRING", {"multiline": True, "dynamicPrompts": False, "pysssss.autocomplete": {
105
+ "words": autocompleteWords,
106
+ "separator": ""
107
+ }}),
108
+ },
109
+ "optional": {
110
+ "a": (any, ),
111
+ "b": (any,),
112
+ "c": (any, ),
113
+ },
114
+ "hidden": {"extra_pnginfo": "EXTRA_PNGINFO",
115
+ "prompt": "PROMPT"},
116
+ }
117
+
118
+ RETURN_TYPES = ("INT", "FLOAT", )
119
+ FUNCTION = "evaluate"
120
+ CATEGORY = "utils"
121
+ OUTPUT_NODE = True
122
+
123
+ @classmethod
124
+ def IS_CHANGED(s, expression, **kwargs):
125
+ if "random" in expression:
126
+ return float("nan")
127
+ return expression
128
+
129
+ def get_widget_value(self, extra_pnginfo, prompt, node_name, widget_name):
130
+ workflow = extra_pnginfo["workflow"] if "workflow" in extra_pnginfo else { "nodes": [] }
131
+ node_id = None
132
+ for node in workflow["nodes"]:
133
+ name = node["type"]
134
+ if "properties" in node:
135
+ if "Node name for S&R" in node["properties"]:
136
+ name = node["properties"]["Node name for S&R"]
137
+ if name == node_name:
138
+ node_id = node["id"]
139
+ break
140
+ if "title" in node:
141
+ name = node["title"]
142
+ if name == node_name:
143
+ node_id = node["id"]
144
+ break
145
+ if node_id is not None:
146
+ values = prompt[str(node_id)]
147
+ if "inputs" in values:
148
+ if widget_name in values["inputs"]:
149
+ value = values["inputs"][widget_name]
150
+ if isinstance(value, list):
151
+ raise ValueError("Converted widgets are not supported via named reference, use the inputs instead.")
152
+ return value
153
+ raise NameError(f"Widget not found: {node_name}.{widget_name}")
154
+ raise NameError(f"Node not found: {node_name}.{widget_name}")
155
+
156
+ def get_size(self, target, property):
157
+ if isinstance(target, dict) and "samples" in target:
158
+ # Latent
159
+ if property == "width":
160
+ return target["samples"].shape[3] * 8
161
+ return target["samples"].shape[2] * 8
162
+ else:
163
+ # Image
164
+ if property == "width":
165
+ return target.shape[2]
166
+ return target.shape[1]
167
+
168
+ def evaluate(self, expression, prompt, extra_pnginfo={}, a=None, b=None, c=None):
169
+ expression = expression.replace('\n', ' ').replace('\r', '')
170
+ node = ast.parse(expression, mode='eval').body
171
+
172
+ lookup = {"a": a, "b": b, "c": c}
173
+
174
+ def eval_op(node, l, r):
175
+ l = eval_expr(l)
176
+ r = eval_expr(r)
177
+ l = l if isinstance(l, int) else float(l)
178
+ r = r if isinstance(r, int) else float(r)
179
+ return operators[type(node.op)](l, r)
180
+
181
+ def eval_expr(node):
182
+ if isinstance(node, ast.Constant) or isinstance(node, ast.Num):
183
+ return node.n
184
+ elif isinstance(node, ast.BinOp):
185
+ return eval_op(node, node.left, node.right)
186
+ elif isinstance(node, ast.BoolOp):
187
+ return eval_op(node, node.values[0], node.values[1])
188
+ elif isinstance(node, ast.UnaryOp):
189
+ return operators[type(node.op)](eval_expr(node.operand))
190
+ elif isinstance(node, ast.Attribute):
191
+ if node.value.id in lookup:
192
+ if node.attr == "width" or node.attr == "height":
193
+ return self.get_size(lookup[node.value.id], node.attr)
194
+
195
+ return self.get_widget_value(extra_pnginfo, prompt, node.value.id, node.attr)
196
+ elif isinstance(node, ast.Name):
197
+ if node.id in lookup:
198
+ val = lookup[node.id]
199
+ if isinstance(val, (int, float, complex)):
200
+ return val
201
+ else:
202
+ raise TypeError(
203
+ f"Compex types (LATENT/IMAGE) need to reference their width/height, e.g. {node.id}.width")
204
+ raise NameError(f"Name not found: {node.id}")
205
+ elif isinstance(node, ast.Call):
206
+ if node.func.id in functions:
207
+ fn = functions[node.func.id]
208
+ l = len(node.args)
209
+ if l < fn["args"][0] or (fn["args"][1] is not None and l > fn["args"][1]):
210
+ if fn["args"][1] is None:
211
+ toErr = " or more"
212
+ else:
213
+ toErr = f" to {fn['args'][1]}"
214
+ raise SyntaxError(
215
+ f"Invalid function call: {node.func.id} requires {fn['args'][0]}{toErr} arguments")
216
+ args = []
217
+ for arg in node.args:
218
+ args.append(eval_expr(arg))
219
+ return fn["call"](*args)
220
+ raise NameError(f"Invalid function call: {node.func.id}")
221
+ elif isinstance(node, ast.Compare):
222
+ l = eval_expr(node.left)
223
+ r = eval_expr(node.comparators[0])
224
+ if isinstance(node.ops[0], ast.Eq):
225
+ return 1 if l == r else 0
226
+ if isinstance(node.ops[0], ast.NotEq):
227
+ return 1 if l != r else 0
228
+ if isinstance(node.ops[0], ast.Gt):
229
+ return 1 if l > r else 0
230
+ if isinstance(node.ops[0], ast.GtE):
231
+ return 1 if l >= r else 0
232
+ if isinstance(node.ops[0], ast.Lt):
233
+ return 1 if l < r else 0
234
+ if isinstance(node.ops[0], ast.LtE):
235
+ return 1 if l <= r else 0
236
+ raise NotImplementedError(
237
+ "Operator " + node.ops[0].__class__.__name__ + " not supported.")
238
+ else:
239
+ raise TypeError(node)
240
+
241
+ r = eval_expr(node)
242
+ return {"ui": {"value": [r]}, "result": (int(r), float(r),)}
243
+
244
+
245
+ NODE_CLASS_MAPPINGS = {
246
+ "MathExpression|pysssss": MathExpression,
247
+ }
248
+
249
+ NODE_DISPLAY_NAME_MAPPINGS = {
250
+ "MathExpression|pysssss": "Math Expression 🐍",
251
+ }
252
+
1/custom_nodes/ComfyUI-Custom-Scripts/py/model_info.py ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import hashlib
2
+ import json
3
+ from aiohttp import web
4
+ from server import PromptServer
5
+ import folder_paths
6
+ import os
7
+
8
+
9
+ def get_metadata(filepath):
10
+ with open(filepath, "rb") as file:
11
+ # https://github.com/huggingface/safetensors#format
12
+ # 8 bytes: N, an unsigned little-endian 64-bit integer, containing the size of the header
13
+ header_size = int.from_bytes(file.read(8), "little", signed=False)
14
+
15
+ if header_size <= 0:
16
+ raise BufferError("Invalid header size")
17
+
18
+ header = file.read(header_size)
19
+ if header_size <= 0:
20
+ raise BufferError("Invalid header")
21
+
22
+ header_json = json.loads(header)
23
+ return header_json["__metadata__"] if "__metadata__" in header_json else None
24
+
25
+
26
+ @PromptServer.instance.routes.post("/pysssss/metadata/notes/{name}")
27
+ async def save_notes(request):
28
+ name = request.match_info["name"]
29
+ pos = name.index("/")
30
+ type = name[0:pos]
31
+ name = name[pos+1:]
32
+
33
+ file_path = None
34
+ if type == "embeddings" or type == "loras":
35
+ name = name.lower()
36
+ files = folder_paths.get_filename_list(type)
37
+ for f in files:
38
+ lower_f = f.lower()
39
+ if lower_f == name:
40
+ file_path = folder_paths.get_full_path(type, f)
41
+ else:
42
+ n = os.path.splitext(f)[0].lower()
43
+ if n == name:
44
+ file_path = folder_paths.get_full_path(type, f)
45
+
46
+ if file_path is not None:
47
+ break
48
+ else:
49
+ file_path = folder_paths.get_full_path(
50
+ type, name)
51
+ if not file_path:
52
+ return web.Response(status=404)
53
+
54
+ file_no_ext = os.path.splitext(file_path)[0]
55
+ info_file = file_no_ext + ".txt"
56
+ with open(info_file, "w") as f:
57
+ f.write(await request.text())
58
+
59
+ return web.Response(status=200)
60
+
61
+
62
+ @PromptServer.instance.routes.get("/pysssss/metadata/{name}")
63
+ async def load_metadata(request):
64
+ name = request.match_info["name"]
65
+ pos = name.index("/")
66
+ type = name[0:pos]
67
+ name = name[pos+1:]
68
+
69
+ file_path = None
70
+ if type == "embeddings" or type == "loras":
71
+ name = name.lower()
72
+ files = folder_paths.get_filename_list(type)
73
+ for f in files:
74
+ lower_f = f.lower()
75
+ if lower_f == name:
76
+ file_path = folder_paths.get_full_path(type, f)
77
+ else:
78
+ n = os.path.splitext(f)[0].lower()
79
+ if n == name:
80
+ file_path = folder_paths.get_full_path(type, f)
81
+
82
+ if file_path is not None:
83
+ break
84
+ else:
85
+ file_path = folder_paths.get_full_path(
86
+ type, name)
87
+ if not file_path:
88
+ return web.Response(status=404)
89
+
90
+ try:
91
+ meta = get_metadata(file_path)
92
+ except:
93
+ meta = None
94
+
95
+ if meta is None:
96
+ meta = {}
97
+
98
+ file_no_ext = os.path.splitext(file_path)[0]
99
+
100
+ info_file = file_no_ext + ".txt"
101
+ if os.path.isfile(info_file):
102
+ with open(info_file, "r") as f:
103
+ meta["pysssss.notes"] = f.read()
104
+
105
+ hash_file = file_no_ext + ".sha256"
106
+ if os.path.isfile(hash_file):
107
+ with open(hash_file, "rt") as f:
108
+ meta["pysssss.sha256"] = f.read()
109
+ else:
110
+ with open(file_path, "rb") as f:
111
+ meta["pysssss.sha256"] = hashlib.sha256(f.read()).hexdigest()
112
+ with open(hash_file, "wt") as f:
113
+ f.write(meta["pysssss.sha256"])
114
+
115
+ return web.json_response(meta)
1/custom_nodes/ComfyUI-Custom-Scripts/py/play_sound.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Hack: string type that is always equal in not equal comparisons
2
+ class AnyType(str):
3
+ def __ne__(self, __value: object) -> bool:
4
+ return False
5
+
6
+
7
+ # Our any instance wants to be a wildcard string
8
+ any = AnyType("*")
9
+
10
+
11
+ class PlaySound:
12
+ @classmethod
13
+ def INPUT_TYPES(s):
14
+ return {"required": {
15
+ "any": (any, {}),
16
+ "mode": (["always", "on empty queue"], {}),
17
+ "volume": ("FLOAT", {"min": 0, "max": 1, "step": 0.1, "default": 0.5}),
18
+ "file": ("STRING", { "default": "notify.mp3" })
19
+ }}
20
+
21
+ FUNCTION = "nop"
22
+ INPUT_IS_LIST = True
23
+ OUTPUT_IS_LIST = (True,)
24
+ OUTPUT_NODE = True
25
+ RETURN_TYPES = (any,)
26
+
27
+ CATEGORY = "utils"
28
+
29
+ def IS_CHANGED(self, **kwargs):
30
+ return float("NaN")
31
+
32
+ def nop(self, any, mode, volume, file):
33
+ return {"ui": {"a": []}, "result": (any,)}
34
+
35
+
36
+ NODE_CLASS_MAPPINGS = {
37
+ "PlaySound|pysssss": PlaySound,
38
+ }
39
+
40
+ NODE_DISPLAY_NAME_MAPPINGS = {
41
+ "PlaySound|pysssss": "PlaySound 🐍",
42
+ }
1/custom_nodes/ComfyUI-Custom-Scripts/py/repeater.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Hack: string type that is always equal in not equal comparisons
2
+ class AnyType(str):
3
+ def __ne__(self, __value: object) -> bool:
4
+ return False
5
+
6
+
7
+ # Our any instance wants to be a wildcard string
8
+ any = AnyType("*")
9
+
10
+
11
+ class Repeater:
12
+ @classmethod
13
+ def INPUT_TYPES(s):
14
+ return {"required": {
15
+ "source": (any, {}),
16
+ "repeats": ("INT", {"min": 0, "max": 5000, "default": 2}),
17
+ "output": (["single", "multi"], {}),
18
+ "node_mode": (["reuse", "create"], {}),
19
+ }}
20
+
21
+ RETURN_TYPES = (any,)
22
+ FUNCTION = "repeat"
23
+ OUTPUT_NODE = False
24
+ OUTPUT_IS_LIST = (True,)
25
+
26
+ CATEGORY = "utils"
27
+
28
+ def repeat(self, repeats, output, node_mode, **kwargs):
29
+ if output == "multi":
30
+ # Multi outputs are split to indiviual nodes on the frontend when serializing
31
+ return ([kwargs["source"]],)
32
+ elif node_mode == "reuse":
33
+ # When reusing we have a single input node, repeat that N times
34
+ return ([kwargs["source"]] * repeats,)
35
+ else:
36
+ # When creating new nodes, they'll be added dynamically when the graph is serialized
37
+ return ((list(kwargs.values())),)
38
+
39
+
40
+ NODE_CLASS_MAPPINGS = {
41
+ "Repeater|pysssss": Repeater,
42
+ }
43
+
44
+ NODE_DISPLAY_NAME_MAPPINGS = {
45
+ "Repeater|pysssss": "Repeater 🐍",
46
+ }
1/custom_nodes/ComfyUI-Custom-Scripts/py/reroute_primitive.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Hack: string type that is always equal in not equal comparisons
2
+ class AnyType(str):
3
+ def __ne__(self, __value: object) -> bool:
4
+ return False
5
+
6
+
7
+ # Our any instance wants to be a wildcard string
8
+ any = AnyType("*")
9
+
10
+
11
+ class ReroutePrimitive:
12
+ @classmethod
13
+ def INPUT_TYPES(cls):
14
+ return {
15
+ "required": {"value": (any, )},
16
+ }
17
+
18
+ @classmethod
19
+ def VALIDATE_INPUTS(s, **kwargs):
20
+ return True
21
+
22
+ RETURN_TYPES = (any,)
23
+ FUNCTION = "route"
24
+ CATEGORY = "__hidden__"
25
+
26
+ def route(self, value):
27
+ return (value,)
28
+
29
+
30
+ class MultiPrimitive:
31
+ @classmethod
32
+ def INPUT_TYPES(cls):
33
+ return {
34
+ "required": {},
35
+ "optional": {"value": (any, )},
36
+ }
37
+
38
+ @classmethod
39
+ def VALIDATE_INPUTS(s, **kwargs):
40
+ return True
41
+
42
+ RETURN_TYPES = (any,)
43
+ FUNCTION = "listify"
44
+ CATEGORY = "utils"
45
+ OUTPUT_IS_LIST = (True,)
46
+
47
+ def listify(self, **kwargs):
48
+ return (list(kwargs.values()),)
49
+
50
+
51
+ NODE_CLASS_MAPPINGS = {
52
+ "ReroutePrimitive|pysssss": ReroutePrimitive,
53
+ # "MultiPrimitive|pysssss": MultiPrimitive,
54
+ }
55
+
56
+ NODE_DISPLAY_NAME_MAPPINGS = {
57
+ "ReroutePrimitive|pysssss": "Reroute Primitive 🐍",
58
+ # "MultiPrimitive|pysssss": "Multi Primitive 🐍",
59
+ }
1/custom_nodes/ComfyUI-Custom-Scripts/py/show_text.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class ShowText:
2
+ @classmethod
3
+ def INPUT_TYPES(s):
4
+ return {
5
+ "required": {
6
+ "text": ("STRING", {"forceInput": True}),
7
+ },
8
+ "hidden": {
9
+ "unique_id": "UNIQUE_ID",
10
+ "extra_pnginfo": "EXTRA_PNGINFO",
11
+ },
12
+ }
13
+
14
+ INPUT_IS_LIST = True
15
+ RETURN_TYPES = ("STRING",)
16
+ FUNCTION = "notify"
17
+ OUTPUT_NODE = True
18
+ OUTPUT_IS_LIST = (True,)
19
+
20
+ CATEGORY = "utils"
21
+
22
+ def notify(self, text, unique_id=None, extra_pnginfo=None):
23
+ if unique_id is not None and extra_pnginfo is not None:
24
+ if not isinstance(extra_pnginfo, list):
25
+ print("Error: extra_pnginfo is not a list")
26
+ elif (
27
+ not isinstance(extra_pnginfo[0], dict)
28
+ or "workflow" not in extra_pnginfo[0]
29
+ ):
30
+ print("Error: extra_pnginfo[0] is not a dict or missing 'workflow' key")
31
+ else:
32
+ workflow = extra_pnginfo[0]["workflow"]
33
+ node = next(
34
+ (x for x in workflow["nodes"] if str(x["id"]) == str(unique_id[0])),
35
+ None,
36
+ )
37
+ if node:
38
+ node["widgets_values"] = [text]
39
+
40
+ return {"ui": {"text": text}, "result": (text,)}
41
+
42
+
43
+ NODE_CLASS_MAPPINGS = {
44
+ "ShowText|pysssss": ShowText,
45
+ }
46
+
47
+ NODE_DISPLAY_NAME_MAPPINGS = {
48
+ "ShowText|pysssss": "Show Text 🐍",
49
+ }
1/custom_nodes/ComfyUI-Custom-Scripts/py/string_function.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+
3
+ class StringFunction:
4
+ @classmethod
5
+ def INPUT_TYPES(s):
6
+ return {
7
+ "required": {
8
+ "action": (["append", "replace"], {}),
9
+ "tidy_tags": (["yes", "no"], {}),
10
+ },
11
+ "optional": {
12
+ "text_a": ("STRING", {"multiline": True, "dynamicPrompts": False}),
13
+ "text_b": ("STRING", {"multiline": True, "dynamicPrompts": False}),
14
+ "text_c": ("STRING", {"multiline": True, "dynamicPrompts": False})
15
+ }
16
+ }
17
+
18
+ RETURN_TYPES = ("STRING",)
19
+ FUNCTION = "exec"
20
+ CATEGORY = "utils"
21
+ OUTPUT_NODE = True
22
+
23
+ def exec(self, action, tidy_tags, text_a="", text_b="", text_c=""):
24
+ tidy_tags = tidy_tags == "yes"
25
+ out = ""
26
+ if action == "append":
27
+ out = (", " if tidy_tags else "").join(filter(None, [text_a, text_b, text_c]))
28
+ else:
29
+ if text_c is None:
30
+ text_c = ""
31
+ if text_b.startswith("/") and text_b.endswith("/"):
32
+ regex = text_b[1:-1]
33
+ out = re.sub(regex, text_c, text_a)
34
+ else:
35
+ out = text_a.replace(text_b, text_c)
36
+ if tidy_tags:
37
+ out = re.sub(r"\s{2,}", " ", out)
38
+ out = out.replace(" ,", ",")
39
+ out = re.sub(r",{2,}", ",", out)
40
+ out = out.strip()
41
+ return {"ui": {"text": (out,)}, "result": (out,)}
42
+
43
+ NODE_CLASS_MAPPINGS = {
44
+ "StringFunction|pysssss": StringFunction,
45
+ }
46
+
47
+ NODE_DISPLAY_NAME_MAPPINGS = {
48
+ "StringFunction|pysssss": "String Function 🐍",
49
+ }
1/custom_nodes/ComfyUI-Custom-Scripts/py/system_notification.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Hack: string type that is always equal in not equal comparisons
2
+ class AnyType(str):
3
+ def __ne__(self, __value: object) -> bool:
4
+ return False
5
+
6
+
7
+ # Our any instance wants to be a wildcard string
8
+ any = AnyType("*")
9
+
10
+
11
+ class SystemNotification:
12
+ @classmethod
13
+ def INPUT_TYPES(s):
14
+ return {"required": {
15
+ "message": ("STRING", {"default": "Your notification has triggered."}),
16
+ "any": (any, {}),
17
+ "mode": (["always", "on empty queue"], {}),
18
+ }}
19
+
20
+ FUNCTION = "nop"
21
+ INPUT_IS_LIST = True
22
+ OUTPUT_IS_LIST = (True,)
23
+ OUTPUT_NODE = True
24
+ RETURN_TYPES = (any,)
25
+
26
+ CATEGORY = "utils"
27
+
28
+ def IS_CHANGED(self, **kwargs):
29
+ return float("NaN")
30
+
31
+ def nop(self, any, message, mode):
32
+ return {"ui": {"message": message, "mode": mode}, "result": (any,)}
33
+
34
+
35
+ NODE_CLASS_MAPPINGS = {
36
+ "SystemNotification|pysssss": SystemNotification,
37
+ }
38
+
39
+ NODE_DISPLAY_NAME_MAPPINGS = {
40
+ "SystemNotification|pysssss": "SystemNotification 🐍",
41
+ }
1/custom_nodes/ComfyUI-Custom-Scripts/py/text_files.py ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import folder_paths
3
+ import json
4
+ from server import PromptServer
5
+ import glob
6
+ from aiohttp import web
7
+
8
+
9
+ def get_allowed_dirs():
10
+ dir = os.path.abspath(os.path.join(__file__, "../../user"))
11
+ file = os.path.join(dir, "text_file_dirs.json")
12
+ with open(file, "r") as f:
13
+ return json.loads(f.read())
14
+
15
+
16
+ def get_valid_dirs():
17
+ return get_allowed_dirs().keys()
18
+
19
+
20
+ def get_dir_from_name(name):
21
+ dirs = get_allowed_dirs()
22
+ if name not in dirs:
23
+ raise KeyError(name + " dir not found")
24
+
25
+ path = dirs[name]
26
+ path = path.replace("$input", folder_paths.get_input_directory())
27
+ path = path.replace("$output", folder_paths.get_output_directory())
28
+ path = path.replace("$temp", folder_paths.get_temp_directory())
29
+ return path
30
+
31
+
32
+ def is_child_dir(parent_path, child_path):
33
+ parent_path = os.path.abspath(parent_path)
34
+ child_path = os.path.abspath(child_path)
35
+ return os.path.commonpath([parent_path]) == os.path.commonpath([parent_path, child_path])
36
+
37
+
38
+ def get_real_path(dir):
39
+ dir = dir.replace("/**/", "/")
40
+ dir = os.path.abspath(dir)
41
+ dir = os.path.split(dir)[0]
42
+ return dir
43
+
44
+
45
+ @PromptServer.instance.routes.get("/pysssss/text-file/{name}")
46
+ async def get_files(request):
47
+ name = request.match_info["name"]
48
+ dir = get_dir_from_name(name)
49
+ recursive = "/**/" in dir
50
+ # Ugh cant use root_path on glob... lazy hack..
51
+ pre = get_real_path(dir)
52
+
53
+ files = list(map(lambda t: os.path.relpath(t, pre),
54
+ glob.glob(dir, recursive=recursive)))
55
+
56
+ if len(files) == 0:
57
+ files = ["[none]"]
58
+ return web.json_response(files)
59
+
60
+
61
+ def get_file(root_dir, file):
62
+ if file == "[none]" or not file or not file.strip():
63
+ raise ValueError("No file")
64
+
65
+ root_dir = get_dir_from_name(root_dir)
66
+ root_dir = get_real_path(root_dir)
67
+ if not os.path.exists(root_dir):
68
+ os.mkdir(root_dir)
69
+ full_path = os.path.join(root_dir, file)
70
+
71
+ file_dir = os.path.dirname(full_path)
72
+ if file_dir and not os.path.exists(file_dir):
73
+ os.makedirs(file_dir, exist_ok=True)
74
+
75
+ if not is_child_dir(root_dir, full_path):
76
+ raise ReferenceError()
77
+
78
+ return full_path
79
+
80
+
81
+ class TextFileNode:
82
+ RETURN_TYPES = ("STRING",)
83
+ CATEGORY = "utils"
84
+
85
+ @classmethod
86
+ def VALIDATE_INPUTS(self, root_dir, file, **kwargs):
87
+ if file == "[none]" or not file or not file.strip():
88
+ return True
89
+ get_file(root_dir, file)
90
+ return True
91
+
92
+ def load_text(self, **kwargs):
93
+ self.file = get_file(kwargs["root_dir"], kwargs["file"])
94
+ with open(self.file, "r") as f:
95
+ return (f.read(), )
96
+
97
+
98
+ class LoadText(TextFileNode):
99
+ @classmethod
100
+ def IS_CHANGED(self, **kwargs):
101
+ return os.path.getmtime(self.file)
102
+
103
+ @classmethod
104
+ def INPUT_TYPES(s):
105
+ return {
106
+ "required": {
107
+ "root_dir": (list(get_valid_dirs()), {}),
108
+ "file": (["[none]"], {
109
+ "pysssss.binding": [{
110
+ "source": "root_dir",
111
+ "callback": [{
112
+ "type": "set",
113
+ "target": "$this.disabled",
114
+ "value": True
115
+ }, {
116
+ "type": "fetch",
117
+ "url": "/pysssss/text-file/{$source.value}",
118
+ "then": [{
119
+ "type": "set",
120
+ "target": "$this.options.values",
121
+ "value": "$result"
122
+ }, {
123
+ "type": "validate-combo"
124
+ }, {
125
+ "type": "set",
126
+ "target": "$this.disabled",
127
+ "value": False
128
+ }]
129
+ }],
130
+ }]
131
+ })
132
+ },
133
+ }
134
+
135
+ FUNCTION = "load_text"
136
+
137
+
138
+ class SaveText(TextFileNode):
139
+ OUTPUT_NODE = True
140
+
141
+ @classmethod
142
+ def IS_CHANGED(self, **kwargs):
143
+ return float("nan")
144
+
145
+ @classmethod
146
+ def INPUT_TYPES(s):
147
+ return {
148
+ "required": {
149
+ "root_dir": (list(get_valid_dirs()), {}),
150
+ "file": ("STRING", {"default": "file.txt"}),
151
+ "append": (["append", "overwrite", "new only"], {}),
152
+ "insert": ("BOOLEAN", {
153
+ "default": True, "label_on": "new line", "label_off": "none",
154
+ "pysssss.binding": [{
155
+ "source": "append",
156
+ "callback": [{
157
+ "type": "if",
158
+ "condition": [{
159
+ "left": "$source.value",
160
+ "op": "eq",
161
+ "right": '"append"'
162
+ }],
163
+ "true": [{
164
+ "type": "set",
165
+ "target": "$this.disabled",
166
+ "value": False
167
+ }],
168
+ "false": [{
169
+ "type": "set",
170
+ "target": "$this.disabled",
171
+ "value": True
172
+ }],
173
+ }]
174
+ }]
175
+ }),
176
+ "text": ("STRING", {"forceInput": True, "multiline": True})
177
+ },
178
+ }
179
+
180
+ FUNCTION = "write_text"
181
+
182
+ def write_text(self, **kwargs):
183
+ self.file = get_file(kwargs["root_dir"], kwargs["file"])
184
+ if kwargs["append"] == "new only" and os.path.exists(self.file):
185
+ raise FileExistsError(
186
+ self.file + " already exists and 'new only' is selected.")
187
+ with open(self.file, "a+" if kwargs["append"] == "append" else "w") as f:
188
+ is_append = f.tell() != 0
189
+ if is_append and kwargs["insert"]:
190
+ f.write("\n")
191
+ f.write(kwargs["text"])
192
+
193
+ return super().load_text(**kwargs)
194
+
195
+
196
+ NODE_CLASS_MAPPINGS = {
197
+ "LoadText|pysssss": LoadText,
198
+ "SaveText|pysssss": SaveText,
199
+ }
200
+
201
+ NODE_DISPLAY_NAME_MAPPINGS = {
202
+ "LoadText|pysssss": "Load Text 🐍",
203
+ "SaveText|pysssss": "Save Text 🐍",
204
+ }
1/custom_nodes/ComfyUI-Custom-Scripts/py/workflows.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from server import PromptServer
2
+ from aiohttp import web
3
+ import os
4
+ import inspect
5
+ import json
6
+ import importlib
7
+ import sys
8
+ sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
9
+ import pysssss
10
+
11
+ root_directory = os.path.dirname(inspect.getfile(PromptServer))
12
+ workflows_directory = os.path.join(root_directory, "pysssss-workflows")
13
+ workflows_directory = pysssss.get_config_value(
14
+ "workflows.directory", workflows_directory)
15
+ if not os.path.isabs(workflows_directory):
16
+ workflows_directory = os.path.abspath(os.path.join(root_directory, workflows_directory))
17
+
18
+ NODE_CLASS_MAPPINGS = {}
19
+ NODE_DISPLAY_NAME_MAPPINGS = {}
20
+
21
+
22
+ @PromptServer.instance.routes.get("/pysssss/workflows")
23
+ async def get_workflows(request):
24
+ files = []
25
+ for dirpath, directories, file in os.walk(workflows_directory):
26
+ for file in file:
27
+ if (file.endswith(".json")):
28
+ files.append(os.path.relpath(os.path.join(
29
+ dirpath, file), workflows_directory))
30
+ return web.json_response(list(map(lambda f: os.path.splitext(f)[0].replace("\\", "/"), files)))
31
+
32
+
33
+ @PromptServer.instance.routes.get("/pysssss/workflows/{name:.+}")
34
+ async def get_workflow(request):
35
+ file = os.path.abspath(os.path.join(
36
+ workflows_directory, request.match_info["name"] + ".json"))
37
+ if os.path.commonpath([file, workflows_directory]) != workflows_directory:
38
+ return web.Response(status=403)
39
+
40
+ return web.FileResponse(file)
41
+
42
+
43
+ @PromptServer.instance.routes.post("/pysssss/workflows")
44
+ async def save_workflow(request):
45
+ json_data = await request.json()
46
+ file = os.path.abspath(os.path.join(
47
+ workflows_directory, json_data["name"] + ".json"))
48
+ if os.path.commonpath([file, workflows_directory]) != workflows_directory:
49
+ return web.Response(status=403)
50
+
51
+ if os.path.exists(file) and ("overwrite" not in json_data or json_data["overwrite"] == False):
52
+ return web.Response(status=409)
53
+
54
+ sub_path = os.path.dirname(file)
55
+ if not os.path.exists(sub_path):
56
+ os.makedirs(sub_path)
57
+
58
+ with open(file, "w") as f:
59
+ f.write(json.dumps(json_data["workflow"]))
60
+
61
+ return web.Response(status=201)
1/custom_nodes/ComfyUI-Custom-Scripts/pyproject.toml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "comfyui-custom-scripts"
3
+ description = "Enhancements & experiments for ComfyUI, mostly focusing on UI features"
4
+ version = "1.2.5"
5
+ license = { file = "LICENSE" }
6
+
7
+ [project.urls]
8
+ Repository = "https://github.com/pythongosssss/ComfyUI-Custom-Scripts"
9
+
10
+ [tool.comfy]
11
+ PublisherId = "pythongosssss"
12
+ DisplayName = "ComfyUI-Custom-Scripts"
13
+ Icon = ""
1/custom_nodes/ComfyUI-Custom-Scripts/pysssss.default.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "name": "CustomScripts",
3
+ "logging": false
4
+ }
1/custom_nodes/ComfyUI-Custom-Scripts/pysssss.example.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "CustomScripts",
3
+ "logging": false,
4
+ "workflows": {
5
+ "directory": "C:\\ComfyUI-Workflows"
6
+ }
7
+ }
1/custom_nodes/ComfyUI-Custom-Scripts/pysssss.py ADDED
@@ -0,0 +1,300 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import asyncio
2
+ import os
3
+ import json
4
+ import shutil
5
+ import inspect
6
+ import aiohttp
7
+ from server import PromptServer
8
+ from tqdm import tqdm
9
+
10
+ config = None
11
+
12
+
13
+ def is_logging_enabled():
14
+ config = get_extension_config()
15
+ if "logging" not in config:
16
+ return False
17
+ return config["logging"]
18
+
19
+
20
+ def log(message, type=None, always=False, name=None):
21
+ if not always and not is_logging_enabled():
22
+ return
23
+
24
+ if type is not None:
25
+ message = f"[{type}] {message}"
26
+
27
+ if name is None:
28
+ name = get_extension_config()["name"]
29
+
30
+ print(f"(pysssss:{name}) {message}")
31
+
32
+
33
+ def get_ext_dir(subpath=None, mkdir=False):
34
+ dir = os.path.dirname(__file__)
35
+ if subpath is not None:
36
+ dir = os.path.join(dir, subpath)
37
+
38
+ dir = os.path.abspath(dir)
39
+
40
+ if mkdir and not os.path.exists(dir):
41
+ os.makedirs(dir)
42
+ return dir
43
+
44
+
45
+ def get_comfy_dir(subpath=None, mkdir=False):
46
+ dir = os.path.dirname(inspect.getfile(PromptServer))
47
+ if subpath is not None:
48
+ dir = os.path.join(dir, subpath)
49
+
50
+ dir = os.path.abspath(dir)
51
+
52
+ if mkdir and not os.path.exists(dir):
53
+ os.makedirs(dir)
54
+ return dir
55
+
56
+
57
+ def get_web_ext_dir():
58
+ config = get_extension_config()
59
+ name = config["name"]
60
+ dir = get_comfy_dir("web/extensions/pysssss")
61
+ if not os.path.exists(dir):
62
+ os.makedirs(dir)
63
+ dir = os.path.join(dir, name)
64
+ return dir
65
+
66
+
67
+ def get_extension_config(reload=False):
68
+ global config
69
+ if reload == False and config is not None:
70
+ return config
71
+
72
+ config_path = get_ext_dir("pysssss.json")
73
+ default_config_path = get_ext_dir("pysssss.default.json")
74
+ if not os.path.exists(config_path):
75
+ if os.path.exists(default_config_path):
76
+ shutil.copy(default_config_path, config_path)
77
+ if not os.path.exists(config_path):
78
+ log(f"Failed to create config at {config_path}", type="ERROR", always=True, name="???")
79
+ print(f"Extension path: {get_ext_dir()}")
80
+ return {"name": "Unknown", "version": -1}
81
+
82
+ else:
83
+ log("Missing pysssss.default.json, this extension may not work correctly. Please reinstall the extension.",
84
+ type="ERROR", always=True, name="???")
85
+ print(f"Extension path: {get_ext_dir()}")
86
+ return {"name": "Unknown", "version": -1}
87
+
88
+ with open(config_path, "r") as f:
89
+ config = json.loads(f.read())
90
+ return config
91
+
92
+
93
+ def link_js(src, dst):
94
+ src = os.path.abspath(src)
95
+ dst = os.path.abspath(dst)
96
+ if os.name == "nt":
97
+ try:
98
+ import _winapi
99
+ _winapi.CreateJunction(src, dst)
100
+ return True
101
+ except:
102
+ pass
103
+ try:
104
+ os.symlink(src, dst)
105
+ return True
106
+ except:
107
+ import logging
108
+ logging.exception('')
109
+ return False
110
+
111
+
112
+ def is_junction(path):
113
+ if os.name != "nt":
114
+ return False
115
+ try:
116
+ return bool(os.readlink(path))
117
+ except OSError:
118
+ return False
119
+
120
+
121
+ def install_js():
122
+ src_dir = get_ext_dir("web/js")
123
+ if not os.path.exists(src_dir):
124
+ log("No JS")
125
+ return
126
+
127
+ should_install = should_install_js()
128
+ if should_install:
129
+ log("it looks like you're running an old version of ComfyUI that requires manual setup of web files, it is recommended you update your installation.", "warning", True)
130
+ dst_dir = get_web_ext_dir()
131
+ linked = os.path.islink(dst_dir) or is_junction(dst_dir)
132
+ if linked or os.path.exists(dst_dir):
133
+ if linked:
134
+ if should_install:
135
+ log("JS already linked")
136
+ else:
137
+ os.unlink(dst_dir)
138
+ log("JS unlinked, PromptServer will serve extension")
139
+ elif not should_install:
140
+ shutil.rmtree(dst_dir)
141
+ log("JS deleted, PromptServer will serve extension")
142
+ return
143
+
144
+ if not should_install:
145
+ log("JS skipped, PromptServer will serve extension")
146
+ return
147
+
148
+ if link_js(src_dir, dst_dir):
149
+ log("JS linked")
150
+ return
151
+
152
+ log("Copying JS files")
153
+ shutil.copytree(src_dir, dst_dir, dirs_exist_ok=True)
154
+
155
+
156
+ def should_install_js():
157
+ return not hasattr(PromptServer.instance, "supports") or "custom_nodes_from_web" not in PromptServer.instance.supports
158
+
159
+
160
+ def init(check_imports=None):
161
+ log("Init")
162
+
163
+ if check_imports is not None:
164
+ import importlib.util
165
+ for imp in check_imports:
166
+ spec = importlib.util.find_spec(imp)
167
+ if spec is None:
168
+ log(f"{imp} is required, please check requirements are installed.",
169
+ type="ERROR", always=True)
170
+ return False
171
+
172
+ install_js()
173
+ return True
174
+
175
+
176
+ def get_async_loop():
177
+ loop = None
178
+ try:
179
+ loop = asyncio.get_event_loop()
180
+ except:
181
+ loop = asyncio.new_event_loop()
182
+ asyncio.set_event_loop(loop)
183
+ return loop
184
+
185
+
186
+ def get_http_session():
187
+ loop = get_async_loop()
188
+ return aiohttp.ClientSession(loop=loop)
189
+
190
+
191
+ async def download(url, stream, update_callback=None, session=None):
192
+ close_session = False
193
+ if session is None:
194
+ close_session = True
195
+ session = get_http_session()
196
+ try:
197
+ async with session.get(url) as response:
198
+ size = int(response.headers.get('content-length', 0)) or None
199
+
200
+ with tqdm(
201
+ unit='B', unit_scale=True, miniters=1, desc=url.split('/')[-1], total=size,
202
+ ) as progressbar:
203
+ perc = 0
204
+ async for chunk in response.content.iter_chunked(2048):
205
+ stream.write(chunk)
206
+ progressbar.update(len(chunk))
207
+ if update_callback is not None and progressbar.total is not None and progressbar.total != 0:
208
+ last = perc
209
+ perc = round(progressbar.n / progressbar.total, 2)
210
+ if perc != last:
211
+ last = perc
212
+ await update_callback(perc)
213
+ finally:
214
+ if close_session and session is not None:
215
+ await session.close()
216
+
217
+
218
+ async def download_to_file(url, destination, update_callback=None, is_ext_subpath=True, session=None):
219
+ if is_ext_subpath:
220
+ destination = get_ext_dir(destination)
221
+ with open(destination, mode='wb') as f:
222
+ download(url, f, update_callback, session)
223
+
224
+
225
+ def wait_for_async(async_fn, loop=None):
226
+ res = []
227
+
228
+ async def run_async():
229
+ r = await async_fn()
230
+ res.append(r)
231
+
232
+ if loop is None:
233
+ try:
234
+ loop = asyncio.get_event_loop()
235
+ except:
236
+ loop = asyncio.new_event_loop()
237
+ asyncio.set_event_loop(loop)
238
+
239
+ loop.run_until_complete(run_async())
240
+
241
+ return res[0]
242
+
243
+
244
+ def update_node_status(client_id, node, text, progress=None):
245
+ if client_id is None:
246
+ client_id = PromptServer.instance.client_id
247
+
248
+ if client_id is None:
249
+ return
250
+
251
+ PromptServer.instance.send_sync("pysssss/update_status", {
252
+ "node": node,
253
+ "progress": progress,
254
+ "text": text
255
+ }, client_id)
256
+
257
+
258
+ async def update_node_status_async(client_id, node, text, progress=None):
259
+ if client_id is None:
260
+ client_id = PromptServer.instance.client_id
261
+
262
+ if client_id is None:
263
+ return
264
+
265
+ await PromptServer.instance.send("pysssss/update_status", {
266
+ "node": node,
267
+ "progress": progress,
268
+ "text": text
269
+ }, client_id)
270
+
271
+
272
+ def get_config_value(key, default=None, throw=False):
273
+ split = key.split(".")
274
+ obj = get_extension_config()
275
+ for s in split:
276
+ if s in obj:
277
+ obj = obj[s]
278
+ else:
279
+ if throw:
280
+ raise KeyError("Configuration key missing: " + key)
281
+ else:
282
+ return default
283
+ return obj
284
+
285
+
286
+ def is_inside_dir(root_dir, check_path):
287
+ root_dir = os.path.abspath(root_dir)
288
+ if not os.path.isabs(check_path):
289
+ check_path = os.path.abspath(os.path.join(root_dir, check_path))
290
+ return os.path.commonpath([check_path, root_dir]) == root_dir
291
+
292
+
293
+ def get_child_dir(root_dir, child_path, throw_if_outside=True):
294
+ child_path = os.path.abspath(os.path.join(root_dir, child_path))
295
+ if is_inside_dir(root_dir, child_path):
296
+ return child_path
297
+ if throw_if_outside:
298
+ raise NotADirectoryError(
299
+ "Saving outside the target folder is not allowed.")
300
+ return None
1/custom_nodes/ComfyUI-Custom-Scripts/user/text_file_dirs.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "input": "$input/**/*.txt",
3
+ "output": "$output/**/*.txt",
4
+ "temp": "$temp/**/*.txt"
5
+ }
1/custom_nodes/ComfyUI-Custom-Scripts/web/js/assets/canvas2svg.js ADDED
@@ -0,0 +1,1192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!!
2
+ * Canvas 2 Svg v1.0.19
3
+ * A low level canvas to SVG converter. Uses a mock canvas context to build an SVG document.
4
+ *
5
+ * Licensed under the MIT license:
6
+ * http://www.opensource.org/licenses/mit-license.php
7
+ *
8
+ * Author:
9
+ * Kerry Liu
10
+ *
11
+ * Copyright (c) 2014 Gliffy Inc.
12
+ */
13
+
14
+ ;(function() {
15
+ "use strict";
16
+
17
+ var STYLES, ctx, CanvasGradient, CanvasPattern, namedEntities;
18
+
19
+ //helper function to format a string
20
+ function format(str, args) {
21
+ var keys = Object.keys(args), i;
22
+ for (i=0; i<keys.length; i++) {
23
+ str = str.replace(new RegExp("\\{" + keys[i] + "\\}", "gi"), args[keys[i]]);
24
+ }
25
+ return str;
26
+ }
27
+
28
+ //helper function that generates a random string
29
+ function randomString(holder) {
30
+ var chars, randomstring, i;
31
+ if (!holder) {
32
+ throw new Error("cannot create a random attribute name for an undefined object");
33
+ }
34
+ chars = "ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
35
+ randomstring = "";
36
+ do {
37
+ randomstring = "";
38
+ for (i = 0; i < 12; i++) {
39
+ randomstring += chars[Math.floor(Math.random() * chars.length)];
40
+ }
41
+ } while (holder[randomstring]);
42
+ return randomstring;
43
+ }
44
+
45
+ //helper function to map named to numbered entities
46
+ function createNamedToNumberedLookup(items, radix) {
47
+ var i, entity, lookup = {}, base10, base16;
48
+ items = items.split(',');
49
+ radix = radix || 10;
50
+ // Map from named to numbered entities.
51
+ for (i = 0; i < items.length; i += 2) {
52
+ entity = '&' + items[i + 1] + ';';
53
+ base10 = parseInt(items[i], radix);
54
+ lookup[entity] = '&#'+base10+';';
55
+ }
56
+ //FF and IE need to create a regex from hex values ie &nbsp; == \xa0
57
+ lookup["\\xa0"] = '&#160;';
58
+ return lookup;
59
+ }
60
+
61
+ //helper function to map canvas-textAlign to svg-textAnchor
62
+ function getTextAnchor(textAlign) {
63
+ //TODO: support rtl languages
64
+ var mapping = {"left":"start", "right":"end", "center":"middle", "start":"start", "end":"end"};
65
+ return mapping[textAlign] || mapping.start;
66
+ }
67
+
68
+ //helper function to map canvas-textBaseline to svg-dominantBaseline
69
+ function getDominantBaseline(textBaseline) {
70
+ //INFO: not supported in all browsers
71
+ var mapping = {"alphabetic": "alphabetic", "hanging": "hanging", "top":"text-before-edge", "bottom":"text-after-edge", "middle":"central"};
72
+ return mapping[textBaseline] || mapping.alphabetic;
73
+ }
74
+
75
+ // Unpack entities lookup where the numbers are in radix 32 to reduce the size
76
+ // entity mapping courtesy of tinymce
77
+ namedEntities = createNamedToNumberedLookup(
78
+ '50,nbsp,51,iexcl,52,cent,53,pound,54,curren,55,yen,56,brvbar,57,sect,58,uml,59,copy,' +
79
+ '5a,ordf,5b,laquo,5c,not,5d,shy,5e,reg,5f,macr,5g,deg,5h,plusmn,5i,sup2,5j,sup3,5k,acute,' +
80
+ '5l,micro,5m,para,5n,middot,5o,cedil,5p,sup1,5q,ordm,5r,raquo,5s,frac14,5t,frac12,5u,frac34,' +
81
+ '5v,iquest,60,Agrave,61,Aacute,62,Acirc,63,Atilde,64,Auml,65,Aring,66,AElig,67,Ccedil,' +
82
+ '68,Egrave,69,Eacute,6a,Ecirc,6b,Euml,6c,Igrave,6d,Iacute,6e,Icirc,6f,Iuml,6g,ETH,6h,Ntilde,' +
83
+ '6i,Ograve,6j,Oacute,6k,Ocirc,6l,Otilde,6m,Ouml,6n,times,6o,Oslash,6p,Ugrave,6q,Uacute,' +
84
+ '6r,Ucirc,6s,Uuml,6t,Yacute,6u,THORN,6v,szlig,70,agrave,71,aacute,72,acirc,73,atilde,74,auml,' +
85
+ '75,aring,76,aelig,77,ccedil,78,egrave,79,eacute,7a,ecirc,7b,euml,7c,igrave,7d,iacute,7e,icirc,' +
86
+ '7f,iuml,7g,eth,7h,ntilde,7i,ograve,7j,oacute,7k,ocirc,7l,otilde,7m,ouml,7n,divide,7o,oslash,' +
87
+ '7p,ugrave,7q,uacute,7r,ucirc,7s,uuml,7t,yacute,7u,thorn,7v,yuml,ci,fnof,sh,Alpha,si,Beta,' +
88
+ 'sj,Gamma,sk,Delta,sl,Epsilon,sm,Zeta,sn,Eta,so,Theta,sp,Iota,sq,Kappa,sr,Lambda,ss,Mu,' +
89
+ 'st,Nu,su,Xi,sv,Omicron,t0,Pi,t1,Rho,t3,Sigma,t4,Tau,t5,Upsilon,t6,Phi,t7,Chi,t8,Psi,' +
90
+ 't9,Omega,th,alpha,ti,beta,tj,gamma,tk,delta,tl,epsilon,tm,zeta,tn,eta,to,theta,tp,iota,' +
91
+ 'tq,kappa,tr,lambda,ts,mu,tt,nu,tu,xi,tv,omicron,u0,pi,u1,rho,u2,sigmaf,u3,sigma,u4,tau,' +
92
+ 'u5,upsilon,u6,phi,u7,chi,u8,psi,u9,omega,uh,thetasym,ui,upsih,um,piv,812,bull,816,hellip,' +
93
+ '81i,prime,81j,Prime,81u,oline,824,frasl,88o,weierp,88h,image,88s,real,892,trade,89l,alefsym,' +
94
+ '8cg,larr,8ch,uarr,8ci,rarr,8cj,darr,8ck,harr,8dl,crarr,8eg,lArr,8eh,uArr,8ei,rArr,8ej,dArr,' +
95
+ '8ek,hArr,8g0,forall,8g2,part,8g3,exist,8g5,empty,8g7,nabla,8g8,isin,8g9,notin,8gb,ni,8gf,prod,' +
96
+ '8gh,sum,8gi,minus,8gn,lowast,8gq,radic,8gt,prop,8gu,infin,8h0,ang,8h7,and,8h8,or,8h9,cap,8ha,cup,' +
97
+ '8hb,int,8hk,there4,8hs,sim,8i5,cong,8i8,asymp,8j0,ne,8j1,equiv,8j4,le,8j5,ge,8k2,sub,8k3,sup,8k4,' +
98
+ 'nsub,8k6,sube,8k7,supe,8kl,oplus,8kn,otimes,8l5,perp,8m5,sdot,8o8,lceil,8o9,rceil,8oa,lfloor,8ob,' +
99
+ 'rfloor,8p9,lang,8pa,rang,9ea,loz,9j0,spades,9j3,clubs,9j5,hearts,9j6,diams,ai,OElig,aj,oelig,b0,' +
100
+ 'Scaron,b1,scaron,bo,Yuml,m6,circ,ms,tilde,802,ensp,803,emsp,809,thinsp,80c,zwnj,80d,zwj,80e,lrm,' +
101
+ '80f,rlm,80j,ndash,80k,mdash,80o,lsquo,80p,rsquo,80q,sbquo,80s,ldquo,80t,rdquo,80u,bdquo,810,dagger,' +
102
+ '811,Dagger,81g,permil,81p,lsaquo,81q,rsaquo,85c,euro', 32);
103
+
104
+
105
+ //Some basic mappings for attributes and default values.
106
+ STYLES = {
107
+ "strokeStyle":{
108
+ svgAttr : "stroke", //corresponding svg attribute
109
+ canvas : "#000000", //canvas default
110
+ svg : "none", //svg default
111
+ apply : "stroke" //apply on stroke() or fill()
112
+ },
113
+ "fillStyle":{
114
+ svgAttr : "fill",
115
+ canvas : "#000000",
116
+ svg : null, //svg default is black, but we need to special case this to handle canvas stroke without fill
117
+ apply : "fill"
118
+ },
119
+ "lineCap":{
120
+ svgAttr : "stroke-linecap",
121
+ canvas : "butt",
122
+ svg : "butt",
123
+ apply : "stroke"
124
+ },
125
+ "lineJoin":{
126
+ svgAttr : "stroke-linejoin",
127
+ canvas : "miter",
128
+ svg : "miter",
129
+ apply : "stroke"
130
+ },
131
+ "miterLimit":{
132
+ svgAttr : "stroke-miterlimit",
133
+ canvas : 10,
134
+ svg : 4,
135
+ apply : "stroke"
136
+ },
137
+ "lineWidth":{
138
+ svgAttr : "stroke-width",
139
+ canvas : 1,
140
+ svg : 1,
141
+ apply : "stroke"
142
+ },
143
+ "globalAlpha": {
144
+ svgAttr : "opacity",
145
+ canvas : 1,
146
+ svg : 1,
147
+ apply : "fill stroke"
148
+ },
149
+ "font":{
150
+ //font converts to multiple svg attributes, there is custom logic for this
151
+ canvas : "10px sans-serif"
152
+ },
153
+ "shadowColor":{
154
+ canvas : "#000000"
155
+ },
156
+ "shadowOffsetX":{
157
+ canvas : 0
158
+ },
159
+ "shadowOffsetY":{
160
+ canvas : 0
161
+ },
162
+ "shadowBlur":{
163
+ canvas : 0
164
+ },
165
+ "textAlign":{
166
+ canvas : "start"
167
+ },
168
+ "textBaseline":{
169
+ canvas : "alphabetic"
170
+ },
171
+ "lineDash" : {
172
+ svgAttr : "stroke-dasharray",
173
+ canvas : [],
174
+ svg : null,
175
+ apply : "stroke"
176
+ }
177
+ };
178
+
179
+ /**
180
+ *
181
+ * @param gradientNode - reference to the gradient
182
+ * @constructor
183
+ */
184
+ CanvasGradient = function(gradientNode, ctx) {
185
+ this.__root = gradientNode;
186
+ this.__ctx = ctx;
187
+ };
188
+
189
+ /**
190
+ * Adds a color stop to the gradient root
191
+ */
192
+ CanvasGradient.prototype.addColorStop = function(offset, color) {
193
+ var stop = this.__ctx.__createElement("stop"), regex, matches;
194
+ stop.setAttribute("offset", offset);
195
+ if(color.indexOf("rgba") !== -1) {
196
+ //separate alpha value, since webkit can't handle it
197
+ regex = /rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi;
198
+ matches = regex.exec(color);
199
+ stop.setAttribute("stop-color", format("rgb({r},{g},{b})", {r:matches[1], g:matches[2], b:matches[3]}));
200
+ stop.setAttribute("stop-opacity", matches[4]);
201
+ } else {
202
+ stop.setAttribute("stop-color", color);
203
+ }
204
+ this.__root.appendChild(stop);
205
+ };
206
+
207
+ CanvasPattern = function(pattern, ctx) {
208
+ this.__root = pattern;
209
+ this.__ctx = ctx;
210
+ };
211
+
212
+ /**
213
+ * The mock canvas context
214
+ * @param o - options include:
215
+ * width - width of your canvas (defaults to 500)
216
+ * height - height of your canvas (defaults to 500)
217
+ * enableMirroring - enables canvas mirroring (get image data) (defaults to false)
218
+ * document - the document object (defaults to the current document)
219
+ */
220
+ ctx = function(o) {
221
+
222
+ var defaultOptions = { width:500, height:500, enableMirroring : false}, options;
223
+
224
+ //keep support for this way of calling C2S: new C2S(width,height)
225
+ if(arguments.length > 1) {
226
+ options = defaultOptions;
227
+ options.width = arguments[0];
228
+ options.height = arguments[1];
229
+ } else if( !o ) {
230
+ options = defaultOptions;
231
+ } else {
232
+ options = o;
233
+ }
234
+
235
+ if(!(this instanceof ctx)) {
236
+ //did someone call this without new?
237
+ return new ctx(options);
238
+ }
239
+
240
+ //setup options
241
+ this.width = options.width || defaultOptions.width;
242
+ this.height = options.height || defaultOptions.height;
243
+ this.enableMirroring = options.enableMirroring !== undefined ? options.enableMirroring : defaultOptions.enableMirroring;
244
+
245
+ this.canvas = this; ///point back to this instance!
246
+ this.__document = options.document || document;
247
+ this.__canvas = this.__document.createElement("canvas");
248
+ this.__ctx = this.__canvas.getContext("2d");
249
+
250
+ this.__setDefaultStyles();
251
+ this.__stack = [this.__getStyleState()];
252
+ this.__groupStack = [];
253
+
254
+ //the root svg element
255
+ this.__root = this.__document.createElementNS("http://www.w3.org/2000/svg", "svg");
256
+ this.__root.setAttribute("version", 1.1);
257
+ this.__root.setAttribute("xmlns", "http://www.w3.org/2000/svg");
258
+ this.__root.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:xlink", "http://www.w3.org/1999/xlink");
259
+ this.__root.setAttribute("width", this.width);
260
+ this.__root.setAttribute("height", this.height);
261
+
262
+ //make sure we don't generate the same ids in defs
263
+ this.__ids = {};
264
+
265
+ //defs tag
266
+ this.__defs = this.__document.createElementNS("http://www.w3.org/2000/svg", "defs");
267
+ this.__root.appendChild(this.__defs);
268
+
269
+ //also add a group child. the svg element can't use the transform attribute
270
+ this.__currentElement = this.__document.createElementNS("http://www.w3.org/2000/svg", "g");
271
+ this.__root.appendChild(this.__currentElement);
272
+ };
273
+
274
+
275
+ /**
276
+ * Creates the specified svg element
277
+ * @private
278
+ */
279
+ ctx.prototype.__createElement = function (elementName, properties, resetFill) {
280
+ if (typeof properties === "undefined") {
281
+ properties = {};
282
+ }
283
+
284
+ var element = this.__document.createElementNS("http://www.w3.org/2000/svg", elementName),
285
+ keys = Object.keys(properties), i, key;
286
+ if(resetFill) {
287
+ //if fill or stroke is not specified, the svg element should not display. By default SVG's fill is black.
288
+ element.setAttribute("fill", "none");
289
+ element.setAttribute("stroke", "none");
290
+ }
291
+ for(i=0; i<keys.length; i++) {
292
+ key = keys[i];
293
+ element.setAttribute(key, properties[key]);
294
+ }
295
+ return element;
296
+ };
297
+
298
+ /**
299
+ * Applies default canvas styles to the context
300
+ * @private
301
+ */
302
+ ctx.prototype.__setDefaultStyles = function() {
303
+ //default 2d canvas context properties see:http://www.w3.org/TR/2dcontext/
304
+ var keys = Object.keys(STYLES), i, key;
305
+ for(i=0; i<keys.length; i++) {
306
+ key = keys[i];
307
+ this[key] = STYLES[key].canvas;
308
+ }
309
+ };
310
+
311
+ /**
312
+ * Applies styles on restore
313
+ * @param styleState
314
+ * @private
315
+ */
316
+ ctx.prototype.__applyStyleState = function(styleState) {
317
+ var keys = Object.keys(styleState), i, key;
318
+ for(i=0; i<keys.length; i++) {
319
+ key = keys[i];
320
+ this[key] = styleState[key];
321
+ }
322
+ };
323
+
324
+ /**
325
+ * Gets the current style state
326
+ * @return {Object}
327
+ * @private
328
+ */
329
+ ctx.prototype.__getStyleState = function() {
330
+ var i, styleState = {}, keys = Object.keys(STYLES), key;
331
+ for(i=0; i<keys.length; i++) {
332
+ key = keys[i];
333
+ styleState[key] = this[key];
334
+ }
335
+ return styleState;
336
+ };
337
+
338
+ /**
339
+ * Apples the current styles to the current SVG element. On "ctx.fill" or "ctx.stroke"
340
+ * @param type
341
+ * @private
342
+ */
343
+ ctx.prototype.__applyStyleToCurrentElement = function(type) {
344
+ var keys = Object.keys(STYLES), i, style, value, id, regex, matches;
345
+ for(i=0; i<keys.length; i++) {
346
+ style = STYLES[keys[i]];
347
+ value = this[keys[i]];
348
+ if(style.apply) {
349
+ //is this a gradient or pattern?
350
+ if(style.apply.indexOf("fill")!==-1 && value instanceof CanvasPattern) {
351
+ //pattern
352
+ if(value.__ctx) {
353
+ //copy over defs
354
+ while(value.__ctx.__defs.childNodes.length) {
355
+ id = value.__ctx.__defs.childNodes[0].getAttribute("id");
356
+ this.__ids[id] = id;
357
+ this.__defs.appendChild(value.__ctx.__defs.childNodes[0]);
358
+ }
359
+ }
360
+ this.__currentElement.setAttribute("fill", format("url(#{id})", {id:value.__root.getAttribute("id")}));
361
+ }
362
+ else if(style.apply.indexOf("fill")!==-1 && value instanceof CanvasGradient) {
363
+ //gradient
364
+ this.__currentElement.setAttribute("fill", format("url(#{id})", {id:value.__root.getAttribute("id")}));
365
+ } else if(style.apply.indexOf(type)!==-1 && style.svg !== value) {
366
+ if((style.svgAttr === "stroke" || style.svgAttr === "fill") && value.indexOf("rgba") !== -1) {
367
+ //separate alpha value, since illustrator can't handle it
368
+ regex = /rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi;
369
+ matches = regex.exec(value);
370
+ this.__currentElement.setAttribute(style.svgAttr, format("rgb({r},{g},{b})", {r:matches[1], g:matches[2], b:matches[3]}));
371
+ //should take globalAlpha here
372
+ var opacity = matches[4];
373
+ var globalAlpha = this.globalAlpha;
374
+ if (globalAlpha != null) {
375
+ opacity *= globalAlpha;
376
+ }
377
+ this.__currentElement.setAttribute(style.svgAttr+"-opacity", opacity);
378
+ } else {
379
+ var attr = style.svgAttr;
380
+ if (keys[i] === 'globalAlpha') {
381
+ attr = type+'-'+style.svgAttr;
382
+ if (this.__currentElement.getAttribute(attr)) {
383
+ //fill-opacity or stroke-opacity has already been set by stroke or fill.
384
+ continue;
385
+ }
386
+ }
387
+ //otherwise only update attribute if right type, and not svg default
388
+ this.__currentElement.setAttribute(attr, value);
389
+
390
+
391
+ }
392
+ }
393
+ }
394
+ }
395
+
396
+ };
397
+
398
+ /**
399
+ * Will return the closest group or svg node. May return the current element.
400
+ * @private
401
+ */
402
+ ctx.prototype.__closestGroupOrSvg = function(node) {
403
+ node = node || this.__currentElement;
404
+ if(node.nodeName === "g" || node.nodeName === "svg") {
405
+ return node;
406
+ } else {
407
+ return this.__closestGroupOrSvg(node.parentNode);
408
+ }
409
+ };
410
+
411
+ /**
412
+ * Returns the serialized value of the svg so far
413
+ * @param fixNamedEntities - Standalone SVG doesn't support named entities, which document.createTextNode encodes.
414
+ * If true, we attempt to find all named entities and encode it as a numeric entity.
415
+ * @return serialized svg
416
+ */
417
+ ctx.prototype.getSerializedSvg = function(fixNamedEntities) {
418
+ var serialized = new XMLSerializer().serializeToString(this.__root),
419
+ keys, i, key, value, regexp, xmlns;
420
+
421
+ //IE search for a duplicate xmnls because they didn't implement setAttributeNS correctly
422
+ xmlns = /xmlns="http:\/\/www\.w3\.org\/2000\/svg".+xmlns="http:\/\/www\.w3\.org\/2000\/svg/gi;
423
+ if(xmlns.test(serialized)) {
424
+ serialized = serialized.replace('xmlns="http://www.w3.org/2000/svg','xmlns:xlink="http://www.w3.org/1999/xlink');
425
+ }
426
+
427
+ if(fixNamedEntities) {
428
+ keys = Object.keys(namedEntities);
429
+ //loop over each named entity and replace with the proper equivalent.
430
+ for(i=0; i<keys.length; i++) {
431
+ key = keys[i];
432
+ value = namedEntities[key];
433
+ regexp = new RegExp(key, "gi");
434
+ if(regexp.test(serialized)) {
435
+ serialized = serialized.replace(regexp, value);
436
+ }
437
+ }
438
+ }
439
+
440
+ return serialized;
441
+ };
442
+
443
+
444
+ /**
445
+ * Returns the root svg
446
+ * @return
447
+ */
448
+ ctx.prototype.getSvg = function() {
449
+ return this.__root;
450
+ };
451
+ /**
452
+ * Will generate a group tag.
453
+ */
454
+ ctx.prototype.save = function() {
455
+ var group = this.__createElement("g"), parent = this.__closestGroupOrSvg();
456
+ this.__groupStack.push(parent);
457
+ parent.appendChild(group);
458
+ this.__currentElement = group;
459
+ this.__stack.push(this.__getStyleState());
460
+ };
461
+ /**
462
+ * Sets current element to parent, or just root if already root
463
+ */
464
+ ctx.prototype.restore = function(){
465
+ this.__currentElement = this.__groupStack.pop();
466
+ //Clearing canvas will make the poped group invalid, currentElement is set to the root group node.
467
+ if (!this.__currentElement) {
468
+ this.__currentElement = this.__root.childNodes[1];
469
+ }
470
+ var state = this.__stack.pop();
471
+ this.__applyStyleState(state);
472
+
473
+ };
474
+
475
+ /**
476
+ * Helper method to add transform
477
+ * @private
478
+ */
479
+ ctx.prototype.__addTransform = function(t) {
480
+
481
+ //if the current element has siblings, add another group
482
+ var parent = this.__closestGroupOrSvg();
483
+ if(parent.childNodes.length > 0) {
484
+ var group = this.__createElement("g");
485
+ parent.appendChild(group);
486
+ this.__currentElement = group;
487
+ }
488
+
489
+ var transform = this.__currentElement.getAttribute("transform");
490
+ if(transform) {
491
+ transform += " ";
492
+ } else {
493
+ transform = "";
494
+ }
495
+ transform += t;
496
+ this.__currentElement.setAttribute("transform", transform);
497
+ };
498
+
499
+ /**
500
+ * scales the current element
501
+ */
502
+ ctx.prototype.scale = function(x, y) {
503
+ if(y === undefined) {
504
+ y = x;
505
+ }
506
+ this.__addTransform(format("scale({x},{y})", {x:x, y:y}));
507
+ };
508
+
509
+ /**
510
+ * rotates the current element
511
+ */
512
+ ctx.prototype.rotate = function(angle){
513
+ var degrees = (angle * 180 / Math.PI);
514
+ this.__addTransform(format("rotate({angle},{cx},{cy})", {angle:degrees, cx:0, cy:0}));
515
+ };
516
+
517
+ /**
518
+ * translates the current element
519
+ */
520
+ ctx.prototype.translate = function(x, y){
521
+ this.__addTransform(format("translate({x},{y})", {x:x,y:y}));
522
+ };
523
+
524
+ /**
525
+ * applies a transform to the current element
526
+ */
527
+ ctx.prototype.transform = function(a, b, c, d, e, f){
528
+ this.__addTransform(format("matrix({a},{b},{c},{d},{e},{f})", {a:a, b:b, c:c, d:d, e:e, f:f}));
529
+ };
530
+
531
+ /**
532
+ * Create a new Path Element
533
+ */
534
+ ctx.prototype.beginPath = function(){
535
+ var path, parent;
536
+
537
+ // Note that there is only one current default path, it is not part of the drawing state.
538
+ // See also: https://html.spec.whatwg.org/multipage/scripting.html#current-default-path
539
+ this.__currentDefaultPath = "";
540
+ this.__currentPosition = {};
541
+
542
+ path = this.__createElement("path", {}, true);
543
+ parent = this.__closestGroupOrSvg();
544
+ parent.appendChild(path);
545
+ this.__currentElement = path;
546
+ };
547
+
548
+ /**
549
+ * Helper function to apply currentDefaultPath to current path element
550
+ * @private
551
+ */
552
+ ctx.prototype.__applyCurrentDefaultPath = function() {
553
+ if(this.__currentElement.nodeName === "path") {
554
+ var d = this.__currentDefaultPath;
555
+ this.__currentElement.setAttribute("d", d);
556
+ } else {
557
+ throw new Error("Attempted to apply path command to node " + this.__currentElement.nodeName);
558
+ }
559
+ };
560
+
561
+ /**
562
+ * Helper function to add path command
563
+ * @private
564
+ */
565
+ ctx.prototype.__addPathCommand = function(command){
566
+ this.__currentDefaultPath += " ";
567
+ this.__currentDefaultPath += command;
568
+ };
569
+
570
+ /**
571
+ * Adds the move command to the current path element,
572
+ * if the currentPathElement is not empty create a new path element
573
+ */
574
+ ctx.prototype.moveTo = function(x,y){
575
+ if(this.__currentElement.nodeName !== "path") {
576
+ this.beginPath();
577
+ }
578
+
579
+ // creates a new subpath with the given point
580
+ this.__currentPosition = {x: x, y: y};
581
+ this.__addPathCommand(format("M {x} {y}", {x:x, y:y}));
582
+ };
583
+
584
+ /**
585
+ * Closes the current path
586
+ */
587
+ ctx.prototype.closePath = function(){
588
+ this.__addPathCommand("Z");
589
+ };
590
+
591
+ /**
592
+ * Adds a line to command
593
+ */
594
+ ctx.prototype.lineTo = function(x, y){
595
+ this.__currentPosition = {x: x, y: y};
596
+ if (this.__currentDefaultPath.indexOf('M') > -1) {
597
+ this.__addPathCommand(format("L {x} {y}", {x:x, y:y}));
598
+ } else {
599
+ this.__addPathCommand(format("M {x} {y}", {x:x, y:y}));
600
+ }
601
+ };
602
+
603
+ /**
604
+ * Add a bezier command
605
+ */
606
+ ctx.prototype.bezierCurveTo = function(cp1x, cp1y, cp2x, cp2y, x, y) {
607
+ this.__currentPosition = {x: x, y: y};
608
+ this.__addPathCommand(format("C {cp1x} {cp1y} {cp2x} {cp2y} {x} {y}",
609
+ {cp1x:cp1x, cp1y:cp1y, cp2x:cp2x, cp2y:cp2y, x:x, y:y}));
610
+ };
611
+
612
+ /**
613
+ * Adds a quadratic curve to command
614
+ */
615
+ ctx.prototype.quadraticCurveTo = function(cpx, cpy, x, y){
616
+ this.__currentPosition = {x: x, y: y};
617
+ this.__addPathCommand(format("Q {cpx} {cpy} {x} {y}", {cpx:cpx, cpy:cpy, x:x, y:y}));
618
+ };
619
+
620
+
621
+ /**
622
+ * Return a new normalized vector of given vector
623
+ */
624
+ var normalize = function(vector) {
625
+ var len = Math.sqrt(vector[0] * vector[0] + vector[1] * vector[1]);
626
+ return [vector[0] / len, vector[1] / len];
627
+ };
628
+
629
+ /**
630
+ * Adds the arcTo to the current path
631
+ *
632
+ * @see http://www.w3.org/TR/2015/WD-2dcontext-20150514/#dom-context-2d-arcto
633
+ */
634
+ ctx.prototype.arcTo = function(x1, y1, x2, y2, radius) {
635
+ // Let the point (x0, y0) be the last point in the subpath.
636
+ var x0 = this.__currentPosition && this.__currentPosition.x;
637
+ var y0 = this.__currentPosition && this.__currentPosition.y;
638
+
639
+ // First ensure there is a subpath for (x1, y1).
640
+ if (typeof x0 == "undefined" || typeof y0 == "undefined") {
641
+ return;
642
+ }
643
+
644
+ // Negative values for radius must cause the implementation to throw an IndexSizeError exception.
645
+ if (radius < 0) {
646
+ throw new Error("IndexSizeError: The radius provided (" + radius + ") is negative.");
647
+ }
648
+
649
+ // If the point (x0, y0) is equal to the point (x1, y1),
650
+ // or if the point (x1, y1) is equal to the point (x2, y2),
651
+ // or if the radius radius is zero,
652
+ // then the method must add the point (x1, y1) to the subpath,
653
+ // and connect that point to the previous point (x0, y0) by a straight line.
654
+ if (((x0 === x1) && (y0 === y1))
655
+ || ((x1 === x2) && (y1 === y2))
656
+ || (radius === 0)) {
657
+ this.lineTo(x1, y1);
658
+ return;
659
+ }
660
+
661
+ // Otherwise, if the points (x0, y0), (x1, y1), and (x2, y2) all lie on a single straight line,
662
+ // then the method must add the point (x1, y1) to the subpath,
663
+ // and connect that point to the previous point (x0, y0) by a straight line.
664
+ var unit_vec_p1_p0 = normalize([x0 - x1, y0 - y1]);
665
+ var unit_vec_p1_p2 = normalize([x2 - x1, y2 - y1]);
666
+ if (unit_vec_p1_p0[0] * unit_vec_p1_p2[1] === unit_vec_p1_p0[1] * unit_vec_p1_p2[0]) {
667
+ this.lineTo(x1, y1);
668
+ return;
669
+ }
670
+
671
+ // Otherwise, let The Arc be the shortest arc given by circumference of the circle that has radius radius,
672
+ // and that has one point tangent to the half-infinite line that crosses the point (x0, y0) and ends at the point (x1, y1),
673
+ // and that has a different point tangent to the half-infinite line that ends at the point (x1, y1), and crosses the point (x2, y2).
674
+ // The points at which this circle touches these two lines are called the start and end tangent points respectively.
675
+
676
+ // note that both vectors are unit vectors, so the length is 1
677
+ var cos = (unit_vec_p1_p0[0] * unit_vec_p1_p2[0] + unit_vec_p1_p0[1] * unit_vec_p1_p2[1]);
678
+ var theta = Math.acos(Math.abs(cos));
679
+
680
+ // Calculate origin
681
+ var unit_vec_p1_origin = normalize([
682
+ unit_vec_p1_p0[0] + unit_vec_p1_p2[0],
683
+ unit_vec_p1_p0[1] + unit_vec_p1_p2[1]
684
+ ]);
685
+ var len_p1_origin = radius / Math.sin(theta / 2);
686
+ var x = x1 + len_p1_origin * unit_vec_p1_origin[0];
687
+ var y = y1 + len_p1_origin * unit_vec_p1_origin[1];
688
+
689
+ // Calculate start angle and end angle
690
+ // rotate 90deg clockwise (note that y axis points to its down)
691
+ var unit_vec_origin_start_tangent = [
692
+ -unit_vec_p1_p0[1],
693
+ unit_vec_p1_p0[0]
694
+ ];
695
+ // rotate 90deg counter clockwise (note that y axis points to its down)
696
+ var unit_vec_origin_end_tangent = [
697
+ unit_vec_p1_p2[1],
698
+ -unit_vec_p1_p2[0]
699
+ ];
700
+ var getAngle = function(vector) {
701
+ // get angle (clockwise) between vector and (1, 0)
702
+ var x = vector[0];
703
+ var y = vector[1];
704
+ if (y >= 0) { // note that y axis points to its down
705
+ return Math.acos(x);
706
+ } else {
707
+ return -Math.acos(x);
708
+ }
709
+ };
710
+ var startAngle = getAngle(unit_vec_origin_start_tangent);
711
+ var endAngle = getAngle(unit_vec_origin_end_tangent);
712
+
713
+ // Connect the point (x0, y0) to the start tangent point by a straight line
714
+ this.lineTo(x + unit_vec_origin_start_tangent[0] * radius,
715
+ y + unit_vec_origin_start_tangent[1] * radius);
716
+
717
+ // Connect the start tangent point to the end tangent point by arc
718
+ // and adding the end tangent point to the subpath.
719
+ this.arc(x, y, radius, startAngle, endAngle);
720
+ };
721
+
722
+ /**
723
+ * Sets the stroke property on the current element
724
+ */
725
+ ctx.prototype.stroke = function(){
726
+ if(this.__currentElement.nodeName === "path") {
727
+ this.__currentElement.setAttribute("paint-order", "fill stroke markers");
728
+ }
729
+ this.__applyCurrentDefaultPath();
730
+ this.__applyStyleToCurrentElement("stroke");
731
+ };
732
+
733
+ /**
734
+ * Sets fill properties on the current element
735
+ */
736
+ ctx.prototype.fill = function(){
737
+ if(this.__currentElement.nodeName === "path") {
738
+ this.__currentElement.setAttribute("paint-order", "stroke fill markers");
739
+ }
740
+ this.__applyCurrentDefaultPath();
741
+ this.__applyStyleToCurrentElement("fill");
742
+ };
743
+
744
+ /**
745
+ * Adds a rectangle to the path.
746
+ */
747
+ ctx.prototype.rect = function(x, y, width, height){
748
+ if(this.__currentElement.nodeName !== "path") {
749
+ this.beginPath();
750
+ }
751
+ this.moveTo(x, y);
752
+ this.lineTo(x+width, y);
753
+ this.lineTo(x+width, y+height);
754
+ this.lineTo(x, y+height);
755
+ this.lineTo(x, y);
756
+ this.closePath();
757
+ };
758
+
759
+
760
+ /**
761
+ * adds a rectangle element
762
+ */
763
+ ctx.prototype.fillRect = function(x, y, width, height){
764
+ var rect, parent;
765
+ rect = this.__createElement("rect", {
766
+ x : x,
767
+ y : y,
768
+ width : width,
769
+ height : height
770
+ }, true);
771
+ parent = this.__closestGroupOrSvg();
772
+ parent.appendChild(rect);
773
+ this.__currentElement = rect;
774
+ this.__applyStyleToCurrentElement("fill");
775
+ };
776
+
777
+ /**
778
+ * Draws a rectangle with no fill
779
+ * @param x
780
+ * @param y
781
+ * @param width
782
+ * @param height
783
+ */
784
+ ctx.prototype.strokeRect = function(x, y, width, height){
785
+ var rect, parent;
786
+ rect = this.__createElement("rect", {
787
+ x : x,
788
+ y : y,
789
+ width : width,
790
+ height : height
791
+ }, true);
792
+ parent = this.__closestGroupOrSvg();
793
+ parent.appendChild(rect);
794
+ this.__currentElement = rect;
795
+ this.__applyStyleToCurrentElement("stroke");
796
+ };
797
+
798
+
799
+ /**
800
+ * Clear entire canvas:
801
+ * 1. save current transforms
802
+ * 2. remove all the childNodes of the root g element
803
+ */
804
+ ctx.prototype.__clearCanvas = function() {
805
+ var current = this.__closestGroupOrSvg(),
806
+ transform = current.getAttribute("transform");
807
+ var rootGroup = this.__root.childNodes[1];
808
+ var childNodes = rootGroup.childNodes;
809
+ for (var i = childNodes.length - 1; i >= 0; i--) {
810
+ if (childNodes[i]) {
811
+ rootGroup.removeChild(childNodes[i]);
812
+ }
813
+ }
814
+ this.__currentElement = rootGroup;
815
+ //reset __groupStack as all the child group nodes are all removed.
816
+ this.__groupStack = [];
817
+ if (transform) {
818
+ this.__addTransform(transform);
819
+ }
820
+ };
821
+
822
+ /**
823
+ * "Clears" a canvas by just drawing a white rectangle in the current group.
824
+ */
825
+ ctx.prototype.clearRect = function(x, y, width, height) {
826
+ //clear entire canvas
827
+ if (x === 0 && y === 0 && width === this.width && height === this.height) {
828
+ this.__clearCanvas();
829
+ return;
830
+ }
831
+ var rect, parent = this.__closestGroupOrSvg();
832
+ rect = this.__createElement("rect", {
833
+ x : x,
834
+ y : y,
835
+ width : width,
836
+ height : height,
837
+ fill : "#FFFFFF"
838
+ }, true);
839
+ parent.appendChild(rect);
840
+ };
841
+
842
+ /**
843
+ * Adds a linear gradient to a defs tag.
844
+ * Returns a canvas gradient object that has a reference to it's parent def
845
+ */
846
+ ctx.prototype.createLinearGradient = function(x1, y1, x2, y2){
847
+ var grad = this.__createElement("linearGradient", {
848
+ id : randomString(this.__ids),
849
+ x1 : x1+"px",
850
+ x2 : x2+"px",
851
+ y1 : y1+"px",
852
+ y2 : y2+"px",
853
+ "gradientUnits" : "userSpaceOnUse"
854
+ }, false);
855
+ this.__defs.appendChild(grad);
856
+ return new CanvasGradient(grad, this);
857
+ };
858
+
859
+ /**
860
+ * Adds a radial gradient to a defs tag.
861
+ * Returns a canvas gradient object that has a reference to it's parent def
862
+ */
863
+ ctx.prototype.createRadialGradient = function(x0, y0, r0, x1, y1, r1){
864
+ var grad = this.__createElement("radialGradient", {
865
+ id : randomString(this.__ids),
866
+ cx : x1+"px",
867
+ cy : y1+"px",
868
+ r : r1+"px",
869
+ fx : x0+"px",
870
+ fy : y0+"px",
871
+ "gradientUnits" : "userSpaceOnUse"
872
+ }, false);
873
+ this.__defs.appendChild(grad);
874
+ return new CanvasGradient(grad, this);
875
+
876
+ };
877
+
878
+ /**
879
+ * Parses the font string and returns svg mapping
880
+ * @private
881
+ */
882
+ ctx.prototype.__parseFont = function() {
883
+ var regex = /^\s*(?=(?:(?:[-a-z]+\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\s*){0,2}(small-caps))?)(?=(?:(?:[-a-z]+\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\1|\2|\3)\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\d]+(?:\%|in|[cem]m|ex|p[ctx]))(?:\s*\/\s*(normal|[.\d]+(?:\%|in|[cem]m|ex|p[ctx])))?\s*([-,\'\"\sa-z]+?)\s*$/i;
884
+ var fontPart = regex.exec( this.font );
885
+ var data = {
886
+ style : fontPart[1] || 'normal',
887
+ size : fontPart[4] || '10px',
888
+ family : fontPart[6] || 'sans-serif',
889
+ weight: fontPart[3] || 'normal',
890
+ decoration : fontPart[2] || 'normal',
891
+ href : null
892
+ };
893
+
894
+ //canvas doesn't support underline natively, but we can pass this attribute
895
+ if(this.__fontUnderline === "underline") {
896
+ data.decoration = "underline";
897
+ }
898
+
899
+ //canvas also doesn't support linking, but we can pass this as well
900
+ if(this.__fontHref) {
901
+ data.href = this.__fontHref;
902
+ }
903
+
904
+ return data;
905
+ };
906
+
907
+ /**
908
+ * Helper to link text fragments
909
+ * @param font
910
+ * @param element
911
+ * @return {*}
912
+ * @private
913
+ */
914
+ ctx.prototype.__wrapTextLink = function(font, element) {
915
+ if(font.href) {
916
+ var a = this.__createElement("a");
917
+ a.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", font.href);
918
+ a.appendChild(element);
919
+ return a;
920
+ }
921
+ return element;
922
+ };
923
+
924
+ /**
925
+ * Fills or strokes text
926
+ * @param text
927
+ * @param x
928
+ * @param y
929
+ * @param action - stroke or fill
930
+ * @private
931
+ */
932
+ ctx.prototype.__applyText = function(text, x, y, action) {
933
+ var font = this.__parseFont(),
934
+ parent = this.__closestGroupOrSvg(),
935
+ textElement = this.__createElement("text", {
936
+ "font-family" : font.family,
937
+ "font-size" : font.size,
938
+ "font-style" : font.style,
939
+ "font-weight" : font.weight,
940
+ "text-decoration" : font.decoration,
941
+ "x" : x,
942
+ "y" : y,
943
+ "text-anchor": getTextAnchor(this.textAlign),
944
+ "dominant-baseline": getDominantBaseline(this.textBaseline)
945
+ }, true);
946
+
947
+ textElement.appendChild(this.__document.createTextNode(text));
948
+ this.__currentElement = textElement;
949
+ this.__applyStyleToCurrentElement(action);
950
+ parent.appendChild(this.__wrapTextLink(font,textElement));
951
+ };
952
+
953
+ /**
954
+ * Creates a text element
955
+ * @param text
956
+ * @param x
957
+ * @param y
958
+ */
959
+ ctx.prototype.fillText = function(text, x, y){
960
+ this.__applyText(text, x, y, "fill");
961
+ };
962
+
963
+ /**
964
+ * Strokes text
965
+ * @param text
966
+ * @param x
967
+ * @param y
968
+ */
969
+ ctx.prototype.strokeText = function(text, x, y){
970
+ this.__applyText(text, x, y, "stroke");
971
+ };
972
+
973
+ /**
974
+ * No need to implement this for svg.
975
+ * @param text
976
+ * @return {TextMetrics}
977
+ */
978
+ ctx.prototype.measureText = function(text){
979
+ this.__ctx.font = this.font;
980
+ return this.__ctx.measureText(text);
981
+ };
982
+
983
+ /**
984
+ * Arc command!
985
+ */
986
+ ctx.prototype.arc = function(x, y, radius, startAngle, endAngle, counterClockwise) {
987
+ // in canvas no circle is drawn if no angle is provided.
988
+ if (startAngle === endAngle) {
989
+ return;
990
+ }
991
+ startAngle = startAngle % (2*Math.PI);
992
+ endAngle = endAngle % (2*Math.PI);
993
+ if(startAngle === endAngle) {
994
+ //circle time! subtract some of the angle so svg is happy (svg elliptical arc can't draw a full circle)
995
+ endAngle = ((endAngle + (2*Math.PI)) - 0.001 * (counterClockwise ? -1 : 1)) % (2*Math.PI);
996
+ }
997
+ var endX = x+radius*Math.cos(endAngle),
998
+ endY = y+radius*Math.sin(endAngle),
999
+ startX = x+radius*Math.cos(startAngle),
1000
+ startY = y+radius*Math.sin(startAngle),
1001
+ sweepFlag = counterClockwise ? 0 : 1,
1002
+ largeArcFlag = 0,
1003
+ diff = endAngle - startAngle;
1004
+
1005
+ // https://github.com/gliffy/canvas2svg/issues/4
1006
+ if(diff < 0) {
1007
+ diff += 2*Math.PI;
1008
+ }
1009
+
1010
+ if(counterClockwise) {
1011
+ largeArcFlag = diff > Math.PI ? 0 : 1;
1012
+ } else {
1013
+ largeArcFlag = diff > Math.PI ? 1 : 0;
1014
+ }
1015
+
1016
+ this.lineTo(startX, startY);
1017
+ this.__addPathCommand(format("A {rx} {ry} {xAxisRotation} {largeArcFlag} {sweepFlag} {endX} {endY}",
1018
+ {rx:radius, ry:radius, xAxisRotation:0, largeArcFlag:largeArcFlag, sweepFlag:sweepFlag, endX:endX, endY:endY}));
1019
+
1020
+ this.__currentPosition = {x: endX, y: endY};
1021
+ };
1022
+
1023
+ /**
1024
+ * Generates a ClipPath from the clip command.
1025
+ */
1026
+ ctx.prototype.clip = function(){
1027
+ var group = this.__closestGroupOrSvg(),
1028
+ clipPath = this.__createElement("clipPath"),
1029
+ id = randomString(this.__ids),
1030
+ newGroup = this.__createElement("g");
1031
+
1032
+ this.__applyCurrentDefaultPath();
1033
+ group.removeChild(this.__currentElement);
1034
+ clipPath.setAttribute("id", id);
1035
+ clipPath.appendChild(this.__currentElement);
1036
+
1037
+ this.__defs.appendChild(clipPath);
1038
+
1039
+ //set the clip path to this group
1040
+ group.setAttribute("clip-path", format("url(#{id})", {id:id}));
1041
+
1042
+ //clip paths can be scaled and transformed, we need to add another wrapper group to avoid later transformations
1043
+ // to this path
1044
+ group.appendChild(newGroup);
1045
+
1046
+ this.__currentElement = newGroup;
1047
+
1048
+ };
1049
+
1050
+ /**
1051
+ * Draws a canvas, image or mock context to this canvas.
1052
+ * Note that all svg dom manipulation uses node.childNodes rather than node.children for IE support.
1053
+ * http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-drawimage
1054
+ */
1055
+ ctx.prototype.drawImage = function(){
1056
+ //convert arguments to a real array
1057
+ var args = Array.prototype.slice.call(arguments),
1058
+ image=args[0],
1059
+ dx, dy, dw, dh, sx=0, sy=0, sw, sh, parent, svg, defs, group,
1060
+ currentElement, svgImage, canvas, context, id;
1061
+
1062
+ if(args.length === 3) {
1063
+ dx = args[1];
1064
+ dy = args[2];
1065
+ sw = image.width;
1066
+ sh = image.height;
1067
+ dw = sw;
1068
+ dh = sh;
1069
+ } else if(args.length === 5) {
1070
+ dx = args[1];
1071
+ dy = args[2];
1072
+ dw = args[3];
1073
+ dh = args[4];
1074
+ sw = image.width;
1075
+ sh = image.height;
1076
+ } else if(args.length === 9) {
1077
+ sx = args[1];
1078
+ sy = args[2];
1079
+ sw = args[3];
1080
+ sh = args[4];
1081
+ dx = args[5];
1082
+ dy = args[6];
1083
+ dw = args[7];
1084
+ dh = args[8];
1085
+ } else {
1086
+ throw new Error("Inavlid number of arguments passed to drawImage: " + arguments.length);
1087
+ }
1088
+
1089
+ parent = this.__closestGroupOrSvg();
1090
+ currentElement = this.__currentElement;
1091
+ var translateDirective = "translate(" + dx + ", " + dy + ")";
1092
+ if(image instanceof ctx) {
1093
+ //canvas2svg mock canvas context. In the future we may want to clone nodes instead.
1094
+ //also I'm currently ignoring dw, dh, sw, sh, sx, sy for a mock context.
1095
+ svg = image.getSvg().cloneNode(true);
1096
+ if (svg.childNodes && svg.childNodes.length > 1) {
1097
+ defs = svg.childNodes[0];
1098
+ while(defs.childNodes.length) {
1099
+ id = defs.childNodes[0].getAttribute("id");
1100
+ this.__ids[id] = id;
1101
+ this.__defs.appendChild(defs.childNodes[0]);
1102
+ }
1103
+ group = svg.childNodes[1];
1104
+ if (group) {
1105
+ //save original transform
1106
+ var originTransform = group.getAttribute("transform");
1107
+ var transformDirective;
1108
+ if (originTransform) {
1109
+ transformDirective = originTransform+" "+translateDirective;
1110
+ } else {
1111
+ transformDirective = translateDirective;
1112
+ }
1113
+ group.setAttribute("transform", transformDirective);
1114
+ parent.appendChild(group);
1115
+ }
1116
+ }
1117
+ } else if(image.nodeName === "CANVAS" || image.nodeName === "IMG") {
1118
+ //canvas or image
1119
+ svgImage = this.__createElement("image");
1120
+ svgImage.setAttribute("width", dw);
1121
+ svgImage.setAttribute("height", dh);
1122
+ svgImage.setAttribute("preserveAspectRatio", "none");
1123
+
1124
+ if(sx || sy || sw !== image.width || sh !== image.height) {
1125
+ //crop the image using a temporary canvas
1126
+ canvas = this.__document.createElement("canvas");
1127
+ canvas.width = dw;
1128
+ canvas.height = dh;
1129
+ context = canvas.getContext("2d");
1130
+ context.drawImage(image, sx, sy, sw, sh, 0, 0, dw, dh);
1131
+ image = canvas;
1132
+ }
1133
+ svgImage.setAttribute("transform", translateDirective);
1134
+ svgImage.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href",
1135
+ image.nodeName === "CANVAS" ? image.toDataURL() : image.getAttribute("src"));
1136
+ parent.appendChild(svgImage);
1137
+ }
1138
+ };
1139
+
1140
+ /**
1141
+ * Generates a pattern tag
1142
+ */
1143
+ ctx.prototype.createPattern = function(image, repetition){
1144
+ var pattern = this.__document.createElementNS("http://www.w3.org/2000/svg", "pattern"), id = randomString(this.__ids),
1145
+ img;
1146
+ pattern.setAttribute("id", id);
1147
+ pattern.setAttribute("width", image.width);
1148
+ pattern.setAttribute("height", image.height);
1149
+ if(image.nodeName === "CANVAS" || image.nodeName === "IMG") {
1150
+ img = this.__document.createElementNS("http://www.w3.org/2000/svg", "image");
1151
+ img.setAttribute("width", image.width);
1152
+ img.setAttribute("height", image.height);
1153
+ img.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href",
1154
+ image.nodeName === "CANVAS" ? image.toDataURL() : image.getAttribute("src"));
1155
+ pattern.appendChild(img);
1156
+ this.__defs.appendChild(pattern);
1157
+ } else if(image instanceof ctx) {
1158
+ pattern.appendChild(image.__root.childNodes[1]);
1159
+ this.__defs.appendChild(pattern);
1160
+ }
1161
+ return new CanvasPattern(pattern, this);
1162
+ };
1163
+
1164
+ ctx.prototype.setLineDash = function(dashArray) {
1165
+ if (dashArray && dashArray.length > 0) {
1166
+ this.lineDash = dashArray.join(",");
1167
+ } else {
1168
+ this.lineDash = null;
1169
+ }
1170
+ };
1171
+
1172
+ /**
1173
+ * Not yet implemented
1174
+ */
1175
+ ctx.prototype.drawFocusRing = function(){};
1176
+ ctx.prototype.createImageData = function(){};
1177
+ ctx.prototype.getImageData = function(){};
1178
+ ctx.prototype.putImageData = function(){};
1179
+ ctx.prototype.globalCompositeOperation = function(){};
1180
+ ctx.prototype.setTransform = function(){};
1181
+
1182
+ //add options for alternative namespace
1183
+ if (typeof window === "object") {
1184
+ window.C2S = ctx;
1185
+ }
1186
+
1187
+ // CommonJS/Browserify
1188
+ if (typeof module === "object" && typeof module.exports === "object") {
1189
+ module.exports = ctx;
1190
+ }
1191
+
1192
+ }());
1/custom_nodes/ComfyUI-Custom-Scripts/web/js/assets/favicon-active.ico ADDED
1/custom_nodes/ComfyUI-Custom-Scripts/web/js/assets/favicon.ico ADDED
1/custom_nodes/ComfyUI-Custom-Scripts/web/js/assets/no-image.png ADDED
1/custom_nodes/ComfyUI-Custom-Scripts/web/js/assets/notify.mp3 ADDED
Binary file (74.4 kB). View file
 
1/custom_nodes/ComfyUI-Custom-Scripts/web/js/autocompleter.js ADDED
@@ -0,0 +1,602 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { app } from "../../../scripts/app.js";
2
+ import { ComfyWidgets } from "../../../scripts/widgets.js";
3
+ import { api } from "../../../scripts/api.js";
4
+ import { $el, ComfyDialog } from "../../../scripts/ui.js";
5
+ import { TextAreaAutoComplete } from "./common/autocomplete.js";
6
+ import { ModelInfoDialog } from "./common/modelInfoDialog.js";
7
+ import { LoraInfoDialog } from "./modelInfo.js";
8
+
9
+ function parseCSV(csvText) {
10
+ const rows = [];
11
+ const delimiter = ",";
12
+ const quote = '"';
13
+ let currentField = "";
14
+ let inQuotedField = false;
15
+
16
+ function pushField() {
17
+ rows[rows.length - 1].push(currentField);
18
+ currentField = "";
19
+ inQuotedField = false;
20
+ }
21
+
22
+ rows.push([]); // Initialize the first row
23
+
24
+ for (let i = 0; i < csvText.length; i++) {
25
+ const char = csvText[i];
26
+ const nextChar = csvText[i + 1];
27
+
28
+ // Special handling for backslash escaped quotes
29
+ if (char === "\\" && nextChar === quote) {
30
+ currentField += quote;
31
+ i++;
32
+ }
33
+
34
+ if (!inQuotedField) {
35
+ if (char === quote) {
36
+ inQuotedField = true;
37
+ } else if (char === delimiter) {
38
+ pushField();
39
+ } else if (char === "\r" || char === "\n" || i === csvText.length - 1) {
40
+ pushField();
41
+ if (nextChar === "\n") {
42
+ i++; // Handle Windows line endings (\r\n)
43
+ }
44
+ rows.push([]); // Start a new row
45
+ } else {
46
+ currentField += char;
47
+ }
48
+ } else {
49
+ if (char === quote && nextChar === quote) {
50
+ currentField += quote;
51
+ i++; // Skip the next quote
52
+ } else if (char === quote) {
53
+ inQuotedField = false;
54
+ } else if (char === "\r" || char === "\n" || i === csvText.length - 1) {
55
+ // Dont allow new lines in quoted text, assume its wrong
56
+ const parsed = parseCSV(currentField);
57
+ rows.pop();
58
+ rows.push(...parsed);
59
+ inQuotedField = false;
60
+ currentField = "";
61
+ rows.push([]);
62
+ } else {
63
+ currentField += char;
64
+ }
65
+ }
66
+ }
67
+
68
+ if (currentField || csvText[csvText.length - 1] === ",") {
69
+ pushField();
70
+ }
71
+
72
+ // Remove the last row if it's empty
73
+ if (rows[rows.length - 1].length === 0) {
74
+ rows.pop();
75
+ }
76
+
77
+ return rows;
78
+ }
79
+
80
+ async function getCustomWords() {
81
+ const resp = await api.fetchApi("/pysssss/autocomplete", { cache: "no-store" });
82
+ if (resp.status === 200) {
83
+ return await resp.text();
84
+ }
85
+ return undefined;
86
+ }
87
+
88
+ async function addCustomWords(text) {
89
+ if (!text) {
90
+ text = await getCustomWords();
91
+ }
92
+ if (text) {
93
+ TextAreaAutoComplete.updateWords(
94
+ "pysssss.customwords",
95
+ parseCSV(text).reduce((p, n) => {
96
+ let text;
97
+ let priority;
98
+ let value;
99
+ let num;
100
+ switch (n.length) {
101
+ case 0:
102
+ return;
103
+ case 1:
104
+ // Single word
105
+ text = n[0];
106
+ break;
107
+ case 2:
108
+ // Word,[priority|alias]
109
+ num = +n[1];
110
+ if (isNaN(num)) {
111
+ text = n[0] + "🔄️" + n[1];
112
+ value = n[0];
113
+ } else {
114
+ text = n[0];
115
+ priority = num;
116
+ }
117
+ break;
118
+ case 4:
119
+ // a1111 csv format?
120
+ value = n[0];
121
+ priority = +n[2];
122
+ const aliases = n[3]?.trim();
123
+ if (aliases && aliases !== "null") { // Weird null in an example csv, maybe they are JSON.parsing the last column?
124
+ const split = aliases.split(",");
125
+ for (const text of split) {
126
+ p[text] = { text, priority, value };
127
+ }
128
+ }
129
+ text = value;
130
+ break;
131
+ default:
132
+ // Word,alias,priority
133
+ text = n[1];
134
+ value = n[0];
135
+ priority = +n[2];
136
+ break;
137
+ }
138
+ p[text] = { text, priority, value };
139
+ return p;
140
+ }, {})
141
+ );
142
+ }
143
+ }
144
+
145
+ function toggleLoras() {
146
+ [TextAreaAutoComplete.globalWords, TextAreaAutoComplete.globalWordsExclLoras] = [
147
+ TextAreaAutoComplete.globalWordsExclLoras,
148
+ TextAreaAutoComplete.globalWords,
149
+ ];
150
+ }
151
+
152
+ class EmbeddingInfoDialog extends ModelInfoDialog {
153
+ async addInfo() {
154
+ super.addInfo();
155
+ const info = await this.addCivitaiInfo();
156
+ if (info) {
157
+ $el("div", {
158
+ parent: this.content,
159
+ innerHTML: info.description,
160
+ style: {
161
+ maxHeight: "250px",
162
+ overflow: "auto",
163
+ },
164
+ });
165
+ }
166
+ }
167
+ }
168
+
169
+ class CustomWordsDialog extends ComfyDialog {
170
+ async show() {
171
+ const text = await getCustomWords();
172
+ this.words = $el("textarea", {
173
+ textContent: text,
174
+ style: {
175
+ width: "70vw",
176
+ height: "70vh",
177
+ },
178
+ });
179
+
180
+ const input = $el("input", {
181
+ style: {
182
+ flex: "auto",
183
+ },
184
+ value:
185
+ "https://gist.githubusercontent.com/pythongosssss/1d3efa6050356a08cea975183088159a/raw/a18fb2f94f9156cf4476b0c24a09544d6c0baec6/danbooru-tags.txt",
186
+ });
187
+
188
+ super.show(
189
+ $el(
190
+ "div",
191
+ {
192
+ style: {
193
+ display: "flex",
194
+ flexDirection: "column",
195
+ overflow: "hidden",
196
+ maxHeight: "100%",
197
+ },
198
+ },
199
+ [
200
+ $el("h2", {
201
+ textContent: "Custom Autocomplete Words",
202
+ style: {
203
+ color: "#fff",
204
+ marginTop: 0,
205
+ textAlign: "center",
206
+ fontFamily: "sans-serif",
207
+ },
208
+ }),
209
+ $el(
210
+ "div",
211
+ {
212
+ style: {
213
+ color: "#fff",
214
+ fontFamily: "sans-serif",
215
+ display: "flex",
216
+ alignItems: "center",
217
+ gap: "5px",
218
+ },
219
+ },
220
+ [
221
+ $el("label", { textContent: "Load Custom List: " }),
222
+ input,
223
+ $el("button", {
224
+ textContent: "Load",
225
+ onclick: async () => {
226
+ try {
227
+ const res = await fetch(input.value);
228
+ if (res.status !== 200) {
229
+ throw new Error("Error loading: " + res.status + " " + res.statusText);
230
+ }
231
+ this.words.value = await res.text();
232
+ } catch (error) {
233
+ alert("Error loading custom list, try manually copy + pasting the list");
234
+ }
235
+ },
236
+ }),
237
+ ]
238
+ ),
239
+ this.words,
240
+ ]
241
+ )
242
+ );
243
+ }
244
+
245
+ createButtons() {
246
+ const btns = super.createButtons();
247
+ const save = $el("button", {
248
+ type: "button",
249
+ textContent: "Save",
250
+ onclick: async (e) => {
251
+ try {
252
+ const res = await api.fetchApi("/pysssss/autocomplete", { method: "POST", body: this.words.value });
253
+ if (res.status !== 200) {
254
+ throw new Error("Error saving: " + res.status + " " + res.statusText);
255
+ }
256
+ save.textContent = "Saved!";
257
+ addCustomWords(this.words.value);
258
+ setTimeout(() => {
259
+ save.textContent = "Save";
260
+ }, 500);
261
+ } catch (error) {
262
+ alert("Error saving word list!");
263
+ console.error(error);
264
+ }
265
+ },
266
+ });
267
+
268
+ btns.unshift(save);
269
+ return btns;
270
+ }
271
+ }
272
+
273
+ const id = "pysssss.AutoCompleter";
274
+
275
+ app.registerExtension({
276
+ name: id,
277
+ init() {
278
+ const STRING = ComfyWidgets.STRING;
279
+ const SKIP_WIDGETS = new Set(["ttN xyPlot.x_values", "ttN xyPlot.y_values"]);
280
+ ComfyWidgets.STRING = function (node, inputName, inputData) {
281
+ const r = STRING.apply(this, arguments);
282
+
283
+ if (inputData[1]?.multiline) {
284
+ // Disabled on this input
285
+ const config = inputData[1]?.["pysssss.autocomplete"];
286
+ if (config === false) return r;
287
+
288
+ // In list of widgets to skip
289
+ const id = `${node.comfyClass}.${inputName}`;
290
+ if (SKIP_WIDGETS.has(id)) return r;
291
+
292
+ let words;
293
+ let separator;
294
+ if (typeof config === "object") {
295
+ separator = config.separator;
296
+ words = {};
297
+ if (config.words) {
298
+ // Custom wordlist, this will have been registered on setup
299
+ Object.assign(words, TextAreaAutoComplete.groups[node.comfyClass + "." + inputName] ?? {});
300
+ }
301
+
302
+ for (const item of config.groups ?? []) {
303
+ if (item === "*") {
304
+ // This widget wants all global words included
305
+ Object.assign(words, TextAreaAutoComplete.globalWords);
306
+ } else {
307
+ // This widget wants a specific group included
308
+ Object.assign(words, TextAreaAutoComplete.groups[item] ?? {});
309
+ }
310
+ }
311
+ }
312
+
313
+ new TextAreaAutoComplete(r.widget.inputEl ?? r.widget.element, words, separator);
314
+ }
315
+
316
+ return r;
317
+ };
318
+
319
+ TextAreaAutoComplete.globalSeparator = localStorage.getItem(id + ".AutoSeparate") ?? ", ";
320
+ const enabledSetting = app.ui.settings.addSetting({
321
+ id,
322
+ name: "🐍 Text Autocomplete",
323
+ defaultValue: true,
324
+ type: (name, setter, value) => {
325
+ return $el("tr", [
326
+ $el("td", [
327
+ $el("label", {
328
+ for: id.replaceAll(".", "-"),
329
+ textContent: name,
330
+ }),
331
+ ]),
332
+ $el("td", [
333
+ $el(
334
+ "label",
335
+ {
336
+ textContent: "Enabled ",
337
+ style: {
338
+ display: "block",
339
+ },
340
+ },
341
+ [
342
+ $el("input", {
343
+ id: id.replaceAll(".", "-"),
344
+ type: "checkbox",
345
+ checked: value,
346
+ onchange: (event) => {
347
+ const checked = !!event.target.checked;
348
+ TextAreaAutoComplete.enabled = checked;
349
+ setter(checked);
350
+ },
351
+ }),
352
+ ]
353
+ ),
354
+ $el(
355
+ "label.comfy-tooltip-indicator",
356
+ {
357
+ title: "This requires other ComfyUI nodes/extensions that support using LoRAs in the prompt.",
358
+ textContent: "Loras enabled ",
359
+ style: {
360
+ display: "block",
361
+ },
362
+ },
363
+ [
364
+ $el("input", {
365
+ type: "checkbox",
366
+ checked: !!TextAreaAutoComplete.lorasEnabled,
367
+ onchange: (event) => {
368
+ const checked = !!event.target.checked;
369
+ TextAreaAutoComplete.lorasEnabled = checked;
370
+ toggleLoras();
371
+ localStorage.setItem(id + ".ShowLoras", TextAreaAutoComplete.lorasEnabled);
372
+ },
373
+ }),
374
+ ]
375
+ ),
376
+ $el(
377
+ "label",
378
+ {
379
+ textContent: "Auto-insert comma ",
380
+ style: {
381
+ display: "block",
382
+ },
383
+ },
384
+ [
385
+ $el("input", {
386
+ type: "checkbox",
387
+ checked: !!TextAreaAutoComplete.globalSeparator,
388
+ onchange: (event) => {
389
+ const checked = !!event.target.checked;
390
+ TextAreaAutoComplete.globalSeparator = checked ? ", " : "";
391
+ localStorage.setItem(id + ".AutoSeparate", TextAreaAutoComplete.globalSeparator);
392
+ },
393
+ }),
394
+ ]
395
+ ),
396
+ $el(
397
+ "label",
398
+ {
399
+ textContent: "Replace _ with space ",
400
+ style: {
401
+ display: "block",
402
+ },
403
+ },
404
+ [
405
+ $el("input", {
406
+ type: "checkbox",
407
+ checked: !!TextAreaAutoComplete.replacer,
408
+ onchange: (event) => {
409
+ const checked = !!event.target.checked;
410
+ TextAreaAutoComplete.replacer = checked ? (v) => v.replaceAll("_", " ") : undefined;
411
+ localStorage.setItem(id + ".ReplaceUnderscore", checked);
412
+ },
413
+ }),
414
+ ]
415
+ ),
416
+ $el(
417
+ "label",
418
+ {
419
+ textContent: "Insert suggestion on: ",
420
+ style: {
421
+ display: "block",
422
+ },
423
+ },
424
+ [
425
+ $el(
426
+ "label",
427
+ {
428
+ textContent: "Tab",
429
+ style: {
430
+ display: "block",
431
+ marginLeft: "20px",
432
+ },
433
+ },
434
+ [
435
+ $el("input", {
436
+ type: "checkbox",
437
+ checked: !!TextAreaAutoComplete.insertOnTab,
438
+ onchange: (event) => {
439
+ const checked = !!event.target.checked;
440
+ TextAreaAutoComplete.insertOnTab = checked;
441
+ localStorage.setItem(id + ".InsertOnTab", checked);
442
+ },
443
+ }),
444
+ ]
445
+ ),
446
+ $el(
447
+ "label",
448
+ {
449
+ textContent: "Enter",
450
+ style: {
451
+ display: "block",
452
+ marginLeft: "20px",
453
+ },
454
+ },
455
+ [
456
+ $el("input", {
457
+ type: "checkbox",
458
+ checked: !!TextAreaAutoComplete.insertOnEnter,
459
+ onchange: (event) => {
460
+ const checked = !!event.target.checked;
461
+ TextAreaAutoComplete.insertOnEnter = checked;
462
+ localStorage.setItem(id + ".InsertOnEnter", checked);
463
+ },
464
+ }),
465
+ ]
466
+ ),
467
+ ]
468
+ ),
469
+ $el(
470
+ "label",
471
+ {
472
+ textContent: "Max suggestions: ",
473
+ style: {
474
+ display: "block",
475
+ },
476
+ },
477
+ [
478
+ $el("input", {
479
+ type: "number",
480
+ value: +TextAreaAutoComplete.suggestionCount,
481
+ style: {
482
+ width: "80px"
483
+ },
484
+ onchange: (event) => {
485
+ const value = +event.target.value;
486
+ TextAreaAutoComplete.suggestionCount = value;;
487
+ localStorage.setItem(id + ".SuggestionCount", TextAreaAutoComplete.suggestionCount);
488
+ },
489
+ }),
490
+ ]
491
+ ),
492
+ $el("button", {
493
+ textContent: "Manage Custom Words",
494
+ onclick: () => {
495
+ try {
496
+ // Try closing old settings window
497
+ if (typeof app.ui.settings.element?.close === "function") {
498
+ app.ui.settings.element.close();
499
+ }
500
+ } catch (error) {
501
+ }
502
+ try {
503
+ // Try closing new vue dialog
504
+ document.querySelector(".p-dialog-close-button").click();
505
+ } catch (error) {
506
+ // Fallback to just hiding the element
507
+ app.ui.settings.element.style.display = "none";
508
+ }
509
+
510
+ new CustomWordsDialog().show();
511
+ },
512
+ style: {
513
+ fontSize: "14px",
514
+ display: "block",
515
+ marginTop: "5px",
516
+ },
517
+ }),
518
+ ]),
519
+ ]);
520
+ },
521
+ });
522
+
523
+ TextAreaAutoComplete.enabled = enabledSetting.value;
524
+ TextAreaAutoComplete.replacer = localStorage.getItem(id + ".ReplaceUnderscore") === "true" ? (v) => v.replaceAll("_", " ") : undefined;
525
+ TextAreaAutoComplete.insertOnTab = localStorage.getItem(id + ".InsertOnTab") !== "false";
526
+ TextAreaAutoComplete.insertOnEnter = localStorage.getItem(id + ".InsertOnEnter") !== "false";
527
+ TextAreaAutoComplete.lorasEnabled = localStorage.getItem(id + ".ShowLoras") === "true";
528
+ TextAreaAutoComplete.suggestionCount = +localStorage.getItem(id + ".SuggestionCount") || 20;
529
+ },
530
+ setup() {
531
+ async function addEmbeddings() {
532
+ const embeddings = await api.getEmbeddings();
533
+ const words = {};
534
+ words["embedding:"] = { text: "embedding:" };
535
+
536
+ for (const emb of embeddings) {
537
+ const v = `embedding:${emb}`;
538
+ words[v] = {
539
+ text: v,
540
+ info: () => new EmbeddingInfoDialog(emb).show("embeddings", emb),
541
+ use_replacer: false,
542
+ };
543
+ }
544
+
545
+ TextAreaAutoComplete.updateWords("pysssss.embeddings", words);
546
+ }
547
+
548
+ async function addLoras() {
549
+ let loras;
550
+ try {
551
+ loras = LiteGraph.registered_node_types["LoraLoader"]?.nodeData.input.required.lora_name[0];
552
+ } catch (error) {}
553
+
554
+ if (!loras?.length) {
555
+ loras = await api.fetchApi("/pysssss/loras", { cache: "no-store" }).then((res) => res.json());
556
+ }
557
+
558
+ const words = {};
559
+ words["lora:"] = { text: "lora:" };
560
+
561
+ for (const lora of loras) {
562
+ const v = `<lora:${lora}:1.0>`;
563
+ words[v] = {
564
+ text: v,
565
+ info: () => new LoraInfoDialog(lora).show("loras", lora),
566
+ use_replacer: false,
567
+ };
568
+ }
569
+
570
+ TextAreaAutoComplete.updateWords("pysssss.loras", words);
571
+ }
572
+
573
+ // store global words with/without loras
574
+ Promise.all([addEmbeddings(), addCustomWords()])
575
+ .then(() => {
576
+ TextAreaAutoComplete.globalWordsExclLoras = Object.assign({}, TextAreaAutoComplete.globalWords);
577
+ })
578
+ .then(addLoras)
579
+ .then(() => {
580
+ if (!TextAreaAutoComplete.lorasEnabled) {
581
+ toggleLoras(); // off by default
582
+ }
583
+ });
584
+ },
585
+ beforeRegisterNodeDef(_, def) {
586
+ // Process each input to see if there is a custom word list for
587
+ // { input: { required: { something: ["STRING", { "pysssss.autocomplete": ["groupid", ["custom", "words"] ] }] } } }
588
+ const inputs = { ...def.input?.required, ...def.input?.optional };
589
+ for (const input in inputs) {
590
+ const config = inputs[input][1]?.["pysssss.autocomplete"];
591
+ if (!config) continue;
592
+ if (typeof config === "object" && config.words) {
593
+ const words = {};
594
+ for (const text of config.words || []) {
595
+ const obj = typeof text === "string" ? { text } : text;
596
+ words[obj.text] = obj;
597
+ }
598
+ TextAreaAutoComplete.updateWords(def.name + "." + input, words, false);
599
+ }
600
+ }
601
+ },
602
+ });
1/custom_nodes/ComfyUI-Custom-Scripts/web/js/betterCombos.js ADDED
@@ -0,0 +1,534 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { app } from "../../../scripts/app.js";
2
+ import { ComfyWidgets } from "../../../scripts/widgets.js";
3
+ import { $el } from "../../../scripts/ui.js";
4
+ import { api } from "../../../scripts/api.js";
5
+
6
+ const CHECKPOINT_LOADER = "CheckpointLoader|pysssss";
7
+ const LORA_LOADER = "LoraLoader|pysssss";
8
+ const IMAGE_WIDTH = 384;
9
+ const IMAGE_HEIGHT = 384;
10
+
11
+ function getType(node) {
12
+ if (node.comfyClass === CHECKPOINT_LOADER) {
13
+ return "checkpoints";
14
+ }
15
+ return "loras";
16
+ }
17
+
18
+ function getWidgetName(type) {
19
+ return type === "checkpoints" ? "ckpt_name" : "lora_name";
20
+ }
21
+
22
+ function encodeRFC3986URIComponent(str) {
23
+ return encodeURIComponent(str).replace(/[!'()*]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`);
24
+ }
25
+
26
+ const calculateImagePosition = (el, bodyRect) => {
27
+ let { top, left, right } = el.getBoundingClientRect();
28
+ const { width: bodyWidth, height: bodyHeight } = bodyRect;
29
+
30
+ const isSpaceRight = right + IMAGE_WIDTH <= bodyWidth;
31
+ if (isSpaceRight) {
32
+ left = right;
33
+ } else {
34
+ left -= IMAGE_WIDTH;
35
+ }
36
+
37
+ top = top - IMAGE_HEIGHT / 2;
38
+ if (top + IMAGE_HEIGHT > bodyHeight) {
39
+ top = bodyHeight - IMAGE_HEIGHT;
40
+ }
41
+ if (top < 0) {
42
+ top = 0;
43
+ }
44
+
45
+ return { left: Math.round(left), top: Math.round(top), isLeft: !isSpaceRight };
46
+ };
47
+
48
+ function showImage(relativeToEl, imageEl) {
49
+ const bodyRect = document.body.getBoundingClientRect();
50
+ if (!bodyRect) return;
51
+
52
+ const { left, top, isLeft } = calculateImagePosition(relativeToEl, bodyRect);
53
+
54
+ imageEl.style.left = `${left}px`;
55
+ imageEl.style.top = `${top}px`;
56
+
57
+ if (isLeft) {
58
+ imageEl.classList.add("left");
59
+ } else {
60
+ imageEl.classList.remove("left");
61
+ }
62
+
63
+ document.body.appendChild(imageEl);
64
+ }
65
+
66
+ let imagesByType = {};
67
+ const loadImageList = async (type) => {
68
+ imagesByType[type] = await (await api.fetchApi(`/pysssss/images/${type}`)).json();
69
+ };
70
+
71
+ app.registerExtension({
72
+ name: "pysssss.Combo++",
73
+ init() {
74
+ const displayOptions = { "List (normal)": 0, "Tree (subfolders)": 1, "Thumbnails (grid)": 2 };
75
+ const displaySetting = app.ui.settings.addSetting({
76
+ id: "pysssss.Combo++.Submenu",
77
+ name: "🐍 Lora & Checkpoint loader display mode",
78
+ defaultValue: 1,
79
+ type: "combo",
80
+ options: (value) => {
81
+ value = +value;
82
+
83
+ return Object.entries(displayOptions).map(([k, v]) => ({
84
+ value: v,
85
+ text: k,
86
+ selected: k === value,
87
+ }));
88
+ },
89
+ });
90
+
91
+ $el("style", {
92
+ textContent: `
93
+ .pysssss-combo-image {
94
+ position: absolute;
95
+ left: 0;
96
+ top: 0;
97
+ width: ${IMAGE_WIDTH}px;
98
+ height: ${IMAGE_HEIGHT}px;
99
+ object-fit: contain;
100
+ object-position: top left;
101
+ z-index: 9999;
102
+ }
103
+ .pysssss-combo-image.left {
104
+ object-position: top right;
105
+ }
106
+ .pysssss-combo-folder { opacity: 0.7 }
107
+ .pysssss-combo-folder-arrow { display: inline-block; width: 15px; }
108
+ .pysssss-combo-folder:hover { background-color: rgba(255, 255, 255, 0.1); }
109
+ .pysssss-combo-prefix { display: none }
110
+
111
+ /* Special handling for when the filter input is populated to revert to normal */
112
+ .litecontextmenu:has(input:not(:placeholder-shown)) .pysssss-combo-folder-contents {
113
+ display: block !important;
114
+ }
115
+ .litecontextmenu:has(input:not(:placeholder-shown)) .pysssss-combo-folder {
116
+ display: none;
117
+ }
118
+ .litecontextmenu:has(input:not(:placeholder-shown)) .pysssss-combo-prefix {
119
+ display: inline;
120
+ }
121
+ .litecontextmenu:has(input:not(:placeholder-shown)) .litemenu-entry {
122
+ padding-left: 2px !important;
123
+ }
124
+
125
+ /* Grid mode */
126
+ .pysssss-combo-grid {
127
+ display: grid;
128
+ grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
129
+ gap: 10px;
130
+ overflow-x: hidden;
131
+ max-width: 60vw;
132
+ }
133
+ .pysssss-combo-grid .comfy-context-menu-filter {
134
+ grid-column: 1 / -1;
135
+ position: sticky;
136
+ top: 0;
137
+ }
138
+ .pysssss-combo-grid .litemenu-entry {
139
+ word-break: break-word;
140
+ display: flex;
141
+ flex-direction: column;
142
+ justify-content: space-between;
143
+ align-items: center;
144
+ }
145
+ .pysssss-combo-grid .litemenu-entry:before {
146
+ content: "";
147
+ display: block;
148
+ width: 100%;
149
+ height: 250px;
150
+ background-size: contain;
151
+ background-position: center;
152
+ background-repeat: no-repeat;
153
+ /* No-image image attribution: Picture icons created by Pixel perfect - Flaticon */
154
+ background-image: var(--background-image, url(extensions/ComfyUI-Custom-Scripts/js/assets/no-image.png));
155
+ }
156
+
157
+ `,
158
+ parent: document.body,
159
+ });
160
+ const p1 = loadImageList("checkpoints");
161
+ const p2 = loadImageList("loras");
162
+
163
+ const refreshComboInNodes = app.refreshComboInNodes;
164
+ app.refreshComboInNodes = async function () {
165
+ const r = await Promise.all([
166
+ refreshComboInNodes.apply(this, arguments),
167
+ loadImageList("checkpoints").catch(() => {}),
168
+ loadImageList("loras").catch(() => {}),
169
+ ]);
170
+ return r[0];
171
+ };
172
+
173
+ const imageHost = $el("img.pysssss-combo-image");
174
+
175
+ const positionMenu = (menu, fillWidth) => {
176
+ // compute best position
177
+ let left = app.canvas.last_mouse[0] - 10;
178
+ let top = app.canvas.last_mouse[1] - 10;
179
+
180
+ const body_rect = document.body.getBoundingClientRect();
181
+ const root_rect = menu.getBoundingClientRect();
182
+
183
+ if (body_rect.width && left > body_rect.width - root_rect.width - 10) left = body_rect.width - root_rect.width - 10;
184
+ if (body_rect.height && top > body_rect.height - root_rect.height - 10) top = body_rect.height - root_rect.height - 10;
185
+
186
+ menu.style.left = `${left}px`;
187
+ menu.style.top = `${top}px`;
188
+ if (fillWidth) {
189
+ menu.style.right = "10px";
190
+ }
191
+ };
192
+
193
+ const updateMenu = async (menu, type) => {
194
+ try {
195
+ await p1;
196
+ await p2;
197
+ } catch (error) {
198
+ console.error(error);
199
+ console.error("Error loading pysssss.betterCombos data");
200
+ }
201
+
202
+ // Clamp max height so it doesn't overflow the screen
203
+ const position = menu.getBoundingClientRect();
204
+ const maxHeight = window.innerHeight - position.top - 20;
205
+ menu.style.maxHeight = `${maxHeight}px`;
206
+
207
+ const images = imagesByType[type];
208
+ const items = menu.querySelectorAll(".litemenu-entry");
209
+
210
+ // Add image handler to items
211
+ const addImageHandler = (item) => {
212
+ const text = item.getAttribute("data-value").trim();
213
+ if (images[text]) {
214
+ const textNode = document.createTextNode("*");
215
+ item.appendChild(textNode);
216
+
217
+ item.addEventListener(
218
+ "mouseover",
219
+ () => {
220
+ imageHost.src = `/pysssss/view/${encodeRFC3986URIComponent(images[text])}?${+new Date()}`;
221
+ document.body.appendChild(imageHost);
222
+ showImage(item, imageHost);
223
+ },
224
+ { passive: true }
225
+ );
226
+ item.addEventListener(
227
+ "mouseout",
228
+ () => {
229
+ imageHost.remove();
230
+ },
231
+ { passive: true }
232
+ );
233
+ item.addEventListener(
234
+ "click",
235
+ () => {
236
+ imageHost.remove();
237
+ },
238
+ { passive: true }
239
+ );
240
+ }
241
+ };
242
+
243
+ const createTree = () => {
244
+ // Create a map to store folder structures
245
+ const folderMap = new Map();
246
+ const rootItems = [];
247
+ const splitBy = (navigator.platform || navigator.userAgent).includes("Win") ? /\/|\\/ : /\//;
248
+ const itemsSymbol = Symbol("items");
249
+
250
+ // First pass - organize items into folder structure
251
+ for (const item of items) {
252
+ const path = item.getAttribute("data-value").split(splitBy);
253
+
254
+ // Remove path from visible text
255
+ item.textContent = path[path.length - 1];
256
+ if (path.length > 1) {
257
+ // Add the prefix path back in so it can be filtered on
258
+ const prefix = $el("span.pysssss-combo-prefix", {
259
+ textContent: path.slice(0, -1).join("/") + "/",
260
+ });
261
+ item.prepend(prefix);
262
+ }
263
+
264
+ addImageHandler(item);
265
+
266
+ if (path.length === 1) {
267
+ rootItems.push(item);
268
+ continue;
269
+ }
270
+
271
+ // Temporarily remove the item from current position
272
+ item.remove();
273
+
274
+ // Create folder hierarchy
275
+ let currentLevel = folderMap;
276
+ for (let i = 0; i < path.length - 1; i++) {
277
+ const folder = path[i];
278
+ if (!currentLevel.has(folder)) {
279
+ currentLevel.set(folder, new Map());
280
+ }
281
+ currentLevel = currentLevel.get(folder);
282
+ }
283
+
284
+ // Store the actual item in the deepest folder
285
+ if (!currentLevel.has(itemsSymbol)) {
286
+ currentLevel.set(itemsSymbol, []);
287
+ }
288
+ currentLevel.get(itemsSymbol).push(item);
289
+ }
290
+
291
+ const createFolderElement = (name) => {
292
+ const folder = $el("div.litemenu-entry.pysssss-combo-folder", {
293
+ innerHTML: `<span class="pysssss-combo-folder-arrow">▶</span> ${name}`,
294
+ style: { paddingLeft: "5px" },
295
+ });
296
+ return folder;
297
+ };
298
+
299
+ const insertFolderStructure = (parentElement, map, level = 0) => {
300
+ for (const [folderName, content] of map.entries()) {
301
+ if (folderName === itemsSymbol) continue;
302
+
303
+ const folderElement = createFolderElement(folderName);
304
+ folderElement.style.paddingLeft = `${level * 10 + 5}px`;
305
+ parentElement.appendChild(folderElement);
306
+
307
+ const childContainer = $el("div.pysssss-combo-folder-contents", {
308
+ style: { display: "none" },
309
+ });
310
+
311
+ // Add items in this folder
312
+ const items = content.get(itemsSymbol) || [];
313
+ for (const item of items) {
314
+ item.style.paddingLeft = `${(level + 1) * 10 + 14}px`;
315
+ childContainer.appendChild(item);
316
+ }
317
+
318
+ // Recursively add subfolders
319
+ insertFolderStructure(childContainer, content, level + 1);
320
+ parentElement.appendChild(childContainer);
321
+
322
+ // Add click handler for folder
323
+ folderElement.addEventListener("click", (e) => {
324
+ e.stopPropagation();
325
+ const arrow = folderElement.querySelector(".pysssss-combo-folder-arrow");
326
+ const contents = folderElement.nextElementSibling;
327
+ if (contents.style.display === "none") {
328
+ contents.style.display = "block";
329
+ arrow.textContent = "▼";
330
+ } else {
331
+ contents.style.display = "none";
332
+ arrow.textContent = "▶";
333
+ }
334
+ });
335
+ }
336
+ };
337
+
338
+ insertFolderStructure(items[0]?.parentElement || menu, folderMap);
339
+ positionMenu(menu);
340
+ };
341
+
342
+ const addImageData = (item) => {
343
+ const text = item.getAttribute("data-value").trim();
344
+ if (images[text]) {
345
+ item.style.setProperty("--background-image", `url(/pysssss/view/${encodeRFC3986URIComponent(images[text])})`);
346
+ }
347
+ };
348
+
349
+ if (displaySetting.value === 1 || displaySetting.value === true) {
350
+ createTree();
351
+ } else if (displaySetting.value === 2) {
352
+ menu.classList.add("pysssss-combo-grid");
353
+
354
+ for (const item of items) {
355
+ addImageData(item);
356
+ }
357
+ positionMenu(menu, true);
358
+ } else {
359
+ for (const item of items) {
360
+ addImageHandler(item);
361
+ }
362
+ }
363
+ };
364
+
365
+ const mutationObserver = new MutationObserver((mutations) => {
366
+ const node = app.canvas.current_node;
367
+
368
+ if (!node || (node.comfyClass !== LORA_LOADER && node.comfyClass !== CHECKPOINT_LOADER)) {
369
+ return;
370
+ }
371
+
372
+ for (const mutation of mutations) {
373
+ for (const removed of mutation.removedNodes) {
374
+ if (removed.classList?.contains("litecontextmenu")) {
375
+ imageHost.remove();
376
+ }
377
+ }
378
+
379
+ for (const added of mutation.addedNodes) {
380
+ if (added.classList?.contains("litecontextmenu")) {
381
+ const overWidget = app.canvas.getWidgetAtCursor();
382
+ const type = getType(node);
383
+ if (overWidget?.name === getWidgetName(type)) {
384
+ requestAnimationFrame(() => {
385
+ // Bad hack to prevent showing on right click menu by checking for the filter input
386
+ if (!added.querySelector(".comfy-context-menu-filter")) return;
387
+ updateMenu(added, type);
388
+ });
389
+ }
390
+ return;
391
+ }
392
+ }
393
+ }
394
+ });
395
+ mutationObserver.observe(document.body, { childList: true, subtree: false });
396
+ },
397
+ async beforeRegisterNodeDef(nodeType, nodeData, app) {
398
+ const isCkpt = nodeData.name === CHECKPOINT_LOADER;
399
+ const isLora = nodeData.name === LORA_LOADER;
400
+ if (isCkpt || isLora) {
401
+ const onAdded = nodeType.prototype.onAdded;
402
+ nodeType.prototype.onAdded = function () {
403
+ onAdded?.apply(this, arguments);
404
+ const { widget: exampleList } = ComfyWidgets["COMBO"](this, "example", [[""], {}], app);
405
+ this.widgets.find((w) => w.name === "prompt").computeSize = () => [0, -4];
406
+ let exampleWidget;
407
+
408
+ const get = async (route, suffix) => {
409
+ const url = encodeRFC3986URIComponent(`${getType(nodeType)}${suffix || ""}`);
410
+ return await api.fetchApi(`/pysssss/${route}/${url}`);
411
+ };
412
+
413
+ const getExample = async () => {
414
+ if (exampleList.value === "[none]") {
415
+ if (exampleWidget) {
416
+ exampleWidget.inputEl.remove();
417
+ exampleWidget = null;
418
+ this.widgets.length -= 1;
419
+ }
420
+ return;
421
+ }
422
+
423
+ const v = this.widgets[0].value;
424
+ const pos = v.lastIndexOf(".");
425
+ const name = v.substr(0, pos);
426
+ let exampleName = exampleList.value;
427
+ let viewPath = `/${name}`;
428
+ if (exampleName === "notes") {
429
+ viewPath += ".txt";
430
+ } else {
431
+ viewPath += `/${exampleName}`;
432
+ }
433
+ const example = await (await get("view", viewPath)).text();
434
+ if (!exampleWidget) {
435
+ exampleWidget = ComfyWidgets["STRING"](this, "prompt", ["STRING", { multiline: true }], app).widget;
436
+ exampleWidget.inputEl.readOnly = true;
437
+ exampleWidget.inputEl.style.opacity = 0.6;
438
+ }
439
+ exampleWidget.value = example;
440
+ };
441
+
442
+ const exampleCb = exampleList.callback;
443
+ exampleList.callback = function () {
444
+ getExample();
445
+ return exampleCb?.apply(this, arguments) ?? exampleList.value;
446
+ };
447
+
448
+ const listExamples = async () => {
449
+ exampleList.disabled = true;
450
+ exampleList.options.values = ["[none]"];
451
+ exampleList.value = "[none]";
452
+ let examples = [];
453
+ if (this.widgets[0].value) {
454
+ try {
455
+ examples = await (await get("examples", `/${this.widgets[0].value}`)).json();
456
+ } catch (error) {}
457
+ }
458
+ exampleList.options.values = ["[none]", ...examples];
459
+ exampleList.value = exampleList.options.values[+!!examples.length];
460
+ exampleList.callback();
461
+ exampleList.disabled = !examples.length;
462
+ app.graph.setDirtyCanvas(true, true);
463
+ };
464
+
465
+ // Expose function to update examples
466
+ nodeType.prototype["pysssss.updateExamples"] = listExamples;
467
+
468
+ const modelWidget = this.widgets[0];
469
+ const modelCb = modelWidget.callback;
470
+ let prev = undefined;
471
+ modelWidget.callback = function () {
472
+ let ret = modelCb?.apply(this, arguments) ?? modelWidget.value;
473
+ if (typeof ret === "object" && "content" in ret) {
474
+ ret = ret.content;
475
+ modelWidget.value = ret;
476
+ }
477
+ let v = ret;
478
+ if (prev !== v) {
479
+ listExamples();
480
+ prev = v;
481
+ }
482
+ return ret;
483
+ };
484
+ setTimeout(() => {
485
+ modelWidget.callback();
486
+ }, 30);
487
+ };
488
+ }
489
+
490
+ const getExtraMenuOptions = nodeType.prototype.getExtraMenuOptions;
491
+ nodeType.prototype.getExtraMenuOptions = function (_, options) {
492
+ if (this.imgs) {
493
+ // If this node has images then we add an open in new tab item
494
+ let img;
495
+ if (this.imageIndex != null) {
496
+ // An image is selected so select that
497
+ img = this.imgs[this.imageIndex];
498
+ } else if (this.overIndex != null) {
499
+ // No image is selected but one is hovered
500
+ img = this.imgs[this.overIndex];
501
+ }
502
+ if (img) {
503
+ const nodes = app.graph._nodes.filter((n) => n.comfyClass === LORA_LOADER || n.comfyClass === CHECKPOINT_LOADER);
504
+ if (nodes.length) {
505
+ options.unshift({
506
+ content: "Save as Preview",
507
+ submenu: {
508
+ options: nodes.map((n) => ({
509
+ content: n.widgets[0].value,
510
+ callback: async () => {
511
+ const url = new URL(img.src);
512
+ await api.fetchApi("/pysssss/save/" + encodeRFC3986URIComponent(`${getType(n)}/${n.widgets[0].value}`), {
513
+ method: "POST",
514
+ body: JSON.stringify({
515
+ filename: url.searchParams.get("filename"),
516
+ subfolder: url.searchParams.get("subfolder"),
517
+ type: url.searchParams.get("type"),
518
+ }),
519
+ headers: {
520
+ "content-type": "application/json",
521
+ },
522
+ });
523
+ loadImageList(getType(n));
524
+ },
525
+ })),
526
+ },
527
+ });
528
+ }
529
+ }
530
+ }
531
+ return getExtraMenuOptions?.apply(this, arguments);
532
+ };
533
+ },
534
+ });
1/custom_nodes/ComfyUI-Custom-Scripts/web/js/common/autocomplete.css ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .pysssss-autocomplete {
2
+ color: var(--descrip-text);
3
+ background-color: var(--comfy-menu-bg);
4
+ position: absolute;
5
+ font-family: sans-serif;
6
+ box-shadow: 3px 3px 8px rgba(0, 0, 0, 0.4);
7
+ z-index: 9999;
8
+ overflow: auto;
9
+ }
10
+
11
+ .pysssss-autocomplete-item {
12
+ cursor: pointer;
13
+ padding: 3px 7px;
14
+ display: flex;
15
+ border-left: 3px solid transparent;
16
+ align-items: center;
17
+ }
18
+
19
+ .pysssss-autocomplete-item--selected {
20
+ border-left-color: dodgerblue;
21
+ }
22
+
23
+ .pysssss-autocomplete-highlight {
24
+ font-weight: bold;
25
+ text-decoration: underline;
26
+ text-decoration-color: dodgerblue;
27
+ }
28
+
29
+ .pysssss-autocomplete-pill {
30
+ margin-left: auto;
31
+ font-size: 10px;
32
+ color: #fff;
33
+ padding: 2px 4px 2px 14px;
34
+ position: relative;
35
+ }
36
+
37
+ .pysssss-autocomplete-pill::after {
38
+ content: "";
39
+ display: block;
40
+ background: rgba(255, 255, 255, 0.25);
41
+ width: calc(100% - 10px);
42
+ height: 100%;
43
+ position: absolute;
44
+ left: 10px;
45
+ top: 0;
46
+ border-radius: 5px;
47
+ }
48
+
49
+ .pysssss-autocomplete-pill + .pysssss-autocomplete-pill {
50
+ margin-left: 0;
51
+ }
52
+
53
+ .pysssss-autocomplete-item-info {
54
+ margin-left: auto;
55
+ transition: filter 0.2s;
56
+ will-change: filter;
57
+ text-decoration: none;
58
+ padding-left: 10px;
59
+ }
60
+ .pysssss-autocomplete-item-info:hover {
61
+ filter: invert(1);
62
+ }
1/custom_nodes/ComfyUI-Custom-Scripts/web/js/common/autocomplete.js ADDED
@@ -0,0 +1,692 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { $el } from "../../../../scripts/ui.js";
2
+ import { addStylesheet } from "./utils.js";
3
+
4
+ addStylesheet(import.meta.url);
5
+
6
+ /*
7
+ https://github.com/component/textarea-caret-position
8
+ The MIT License (MIT)
9
+
10
+ Copyright (c) 2015 Jonathan Ong me@jongleberry.com
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17
+ */
18
+ const getCaretCoordinates = (function () {
19
+ // We'll copy the properties below into the mirror div.
20
+ // Note that some browsers, such as Firefox, do not concatenate properties
21
+ // into their shorthand (e.g. padding-top, padding-bottom etc. -> padding),
22
+ // so we have to list every single property explicitly.
23
+ var properties = [
24
+ "direction", // RTL support
25
+ "boxSizing",
26
+ "width", // on Chrome and IE, exclude the scrollbar, so the mirror div wraps exactly as the textarea does
27
+ "height",
28
+ "overflowX",
29
+ "overflowY", // copy the scrollbar for IE
30
+
31
+ "borderTopWidth",
32
+ "borderRightWidth",
33
+ "borderBottomWidth",
34
+ "borderLeftWidth",
35
+ "borderStyle",
36
+
37
+ "paddingTop",
38
+ "paddingRight",
39
+ "paddingBottom",
40
+ "paddingLeft",
41
+
42
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/font
43
+ "fontStyle",
44
+ "fontVariant",
45
+ "fontWeight",
46
+ "fontStretch",
47
+ "fontSize",
48
+ "fontSizeAdjust",
49
+ "lineHeight",
50
+ "fontFamily",
51
+
52
+ "textAlign",
53
+ "textTransform",
54
+ "textIndent",
55
+ "textDecoration", // might not make a difference, but better be safe
56
+
57
+ "letterSpacing",
58
+ "wordSpacing",
59
+
60
+ "tabSize",
61
+ "MozTabSize",
62
+ ];
63
+
64
+ var isBrowser = typeof window !== "undefined";
65
+ var isFirefox = isBrowser && window.mozInnerScreenX != null;
66
+
67
+ return function getCaretCoordinates(element, position, options) {
68
+ if (!isBrowser) {
69
+ throw new Error("textarea-caret-position#getCaretCoordinates should only be called in a browser");
70
+ }
71
+
72
+ var debug = (options && options.debug) || false;
73
+ if (debug) {
74
+ var el = document.querySelector("#input-textarea-caret-position-mirror-div");
75
+ if (el) el.parentNode.removeChild(el);
76
+ }
77
+
78
+ // The mirror div will replicate the textarea's style
79
+ var div = document.createElement("div");
80
+ div.id = "input-textarea-caret-position-mirror-div";
81
+ document.body.appendChild(div);
82
+
83
+ var style = div.style;
84
+ var computed = window.getComputedStyle ? window.getComputedStyle(element) : element.currentStyle; // currentStyle for IE < 9
85
+ var isInput = element.nodeName === "INPUT";
86
+
87
+ // Default textarea styles
88
+ style.whiteSpace = "pre-wrap";
89
+ if (!isInput) style.wordWrap = "break-word"; // only for textarea-s
90
+
91
+ // Position off-screen
92
+ style.position = "absolute"; // required to return coordinates properly
93
+ if (!debug) style.visibility = "hidden"; // not 'display: none' because we want rendering
94
+
95
+ // Transfer the element's properties to the div
96
+ properties.forEach(function (prop) {
97
+ if (isInput && prop === "lineHeight") {
98
+ // Special case for <input>s because text is rendered centered and line height may be != height
99
+ if (computed.boxSizing === "border-box") {
100
+ var height = parseInt(computed.height);
101
+ var outerHeight =
102
+ parseInt(computed.paddingTop) +
103
+ parseInt(computed.paddingBottom) +
104
+ parseInt(computed.borderTopWidth) +
105
+ parseInt(computed.borderBottomWidth);
106
+ var targetHeight = outerHeight + parseInt(computed.lineHeight);
107
+ if (height > targetHeight) {
108
+ style.lineHeight = height - outerHeight + "px";
109
+ } else if (height === targetHeight) {
110
+ style.lineHeight = computed.lineHeight;
111
+ } else {
112
+ style.lineHeight = 0;
113
+ }
114
+ } else {
115
+ style.lineHeight = computed.height;
116
+ }
117
+ } else {
118
+ style[prop] = computed[prop];
119
+ }
120
+ });
121
+
122
+ if (isFirefox) {
123
+ // Firefox lies about the overflow property for textareas: https://bugzilla.mozilla.org/show_bug.cgi?id=984275
124
+ if (element.scrollHeight > parseInt(computed.height)) style.overflowY = "scroll";
125
+ } else {
126
+ style.overflow = "hidden"; // for Chrome to not render a scrollbar; IE keeps overflowY = 'scroll'
127
+ }
128
+
129
+ div.textContent = element.value.substring(0, position);
130
+ // The second special handling for input type="text" vs textarea:
131
+ // spaces need to be replaced with non-breaking spaces - http://stackoverflow.com/a/13402035/1269037
132
+ if (isInput) div.textContent = div.textContent.replace(/\s/g, "\u00a0");
133
+
134
+ var span = document.createElement("span");
135
+ // Wrapping must be replicated *exactly*, including when a long word gets
136
+ // onto the next line, with whitespace at the end of the line before (#7).
137
+ // The *only* reliable way to do that is to copy the *entire* rest of the
138
+ // textarea's content into the <span> created at the caret position.
139
+ // For inputs, just '.' would be enough, but no need to bother.
140
+ span.textContent = element.value.substring(position) || "."; // || because a completely empty faux span doesn't render at all
141
+ div.appendChild(span);
142
+
143
+ var coordinates = {
144
+ top: span.offsetTop + parseInt(computed["borderTopWidth"]),
145
+ left: span.offsetLeft + parseInt(computed["borderLeftWidth"]),
146
+ height: parseInt(computed["lineHeight"]),
147
+ };
148
+
149
+ if (debug) {
150
+ span.style.backgroundColor = "#aaa";
151
+ } else {
152
+ document.body.removeChild(div);
153
+ }
154
+
155
+ return coordinates;
156
+ };
157
+ })();
158
+
159
+ /*
160
+ Key functions from:
161
+ https://github.com/yuku/textcomplete
162
+ © Yuku Takahashi - This software is licensed under the MIT license.
163
+
164
+ The MIT License (MIT)
165
+
166
+ Copyright (c) 2015 Jonathan Ong me@jongleberry.com
167
+
168
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
169
+
170
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
171
+
172
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
173
+ */
174
+ const CHAR_CODE_ZERO = "0".charCodeAt(0);
175
+ const CHAR_CODE_NINE = "9".charCodeAt(0);
176
+
177
+ class TextAreaCaretHelper {
178
+ constructor(el, getScale) {
179
+ this.el = el;
180
+ this.getScale = getScale;
181
+ }
182
+
183
+ #calculateElementOffset() {
184
+ const rect = this.el.getBoundingClientRect();
185
+ const owner = this.el.ownerDocument;
186
+ if (owner == null) {
187
+ throw new Error("Given element does not belong to document");
188
+ }
189
+ const { defaultView, documentElement } = owner;
190
+ if (defaultView == null) {
191
+ throw new Error("Given element does not belong to window");
192
+ }
193
+ const offset = {
194
+ top: rect.top + defaultView.pageYOffset,
195
+ left: rect.left + defaultView.pageXOffset,
196
+ };
197
+ if (documentElement) {
198
+ offset.top -= documentElement.clientTop;
199
+ offset.left -= documentElement.clientLeft;
200
+ }
201
+ return offset;
202
+ }
203
+
204
+ #isDigit(charCode) {
205
+ return CHAR_CODE_ZERO <= charCode && charCode <= CHAR_CODE_NINE;
206
+ }
207
+
208
+ #getLineHeightPx() {
209
+ const computedStyle = getComputedStyle(this.el);
210
+ const lineHeight = computedStyle.lineHeight;
211
+ // If the char code starts with a digit, it is either a value in pixels,
212
+ // or unitless, as per:
213
+ // https://drafts.csswg.org/css2/visudet.html#propdef-line-height
214
+ // https://drafts.csswg.org/css2/cascade.html#computed-value
215
+ if (this.#isDigit(lineHeight.charCodeAt(0))) {
216
+ const floatLineHeight = parseFloat(lineHeight);
217
+ // In real browsers the value is *always* in pixels, even for unit-less
218
+ // line-heights. However, we still check as per the spec.
219
+ return this.#isDigit(lineHeight.charCodeAt(lineHeight.length - 1))
220
+ ? floatLineHeight * parseFloat(computedStyle.fontSize)
221
+ : floatLineHeight;
222
+ }
223
+ // Otherwise, the value is "normal".
224
+ // If the line-height is "normal", calculate by font-size
225
+ return this.#calculateLineHeightPx(this.el.nodeName, computedStyle);
226
+ }
227
+
228
+ /**
229
+ * Returns calculated line-height of the given node in pixels.
230
+ */
231
+ #calculateLineHeightPx(nodeName, computedStyle) {
232
+ const body = document.body;
233
+ if (!body) return 0;
234
+
235
+ const tempNode = document.createElement(nodeName);
236
+ tempNode.innerHTML = "&nbsp;";
237
+ Object.assign(tempNode.style, {
238
+ fontSize: computedStyle.fontSize,
239
+ fontFamily: computedStyle.fontFamily,
240
+ padding: "0",
241
+ position: "absolute",
242
+ });
243
+ body.appendChild(tempNode);
244
+
245
+ // Make sure textarea has only 1 row
246
+ if (tempNode instanceof HTMLTextAreaElement) {
247
+ tempNode.rows = 1;
248
+ }
249
+
250
+ // Assume the height of the element is the line-height
251
+ const height = tempNode.offsetHeight;
252
+ body.removeChild(tempNode);
253
+
254
+ return height;
255
+ }
256
+
257
+ getCursorOffset() {
258
+ const scale = this.getScale();
259
+ const elOffset = this.#calculateElementOffset();
260
+ const elScroll = this.#getElScroll();
261
+ const cursorPosition = this.#getCursorPosition();
262
+ const lineHeight = this.#getLineHeightPx();
263
+ const top = elOffset.top - (elScroll.top * scale) + (cursorPosition.top + lineHeight) * scale;
264
+ const left = elOffset.left - elScroll.left + cursorPosition.left;
265
+ const clientTop = this.el.getBoundingClientRect().top;
266
+ if (this.el.dir !== "rtl") {
267
+ return { top, left, lineHeight, clientTop };
268
+ } else {
269
+ const right = document.documentElement ? document.documentElement.clientWidth - left : 0;
270
+ return { top, right, lineHeight, clientTop };
271
+ }
272
+ }
273
+
274
+ #getElScroll() {
275
+ return { top: this.el.scrollTop, left: this.el.scrollLeft };
276
+ }
277
+
278
+ #getCursorPosition() {
279
+ return getCaretCoordinates(this.el, this.el.selectionEnd);
280
+ }
281
+
282
+ getBeforeCursor() {
283
+ return this.el.selectionStart !== this.el.selectionEnd ? null : this.el.value.substring(0, this.el.selectionEnd);
284
+ }
285
+
286
+ getAfterCursor() {
287
+ return this.el.value.substring(this.el.selectionEnd);
288
+ }
289
+
290
+ insertAtCursor(value, offset, finalOffset) {
291
+ if (this.el.selectionStart != null) {
292
+ const startPos = this.el.selectionStart;
293
+ const endPos = this.el.selectionEnd;
294
+
295
+ // Move selection to beginning of offset
296
+ this.el.selectionStart = this.el.selectionStart + offset;
297
+
298
+ // Using execCommand to support undo, but since it's officially
299
+ // 'deprecated' we need a backup solution, but it won't support undo :(
300
+ let pasted = true;
301
+ try {
302
+ if (!document.execCommand("insertText", false, value)) {
303
+ pasted = false;
304
+ }
305
+ } catch (e) {
306
+ console.error("Error caught during execCommand:", e);
307
+ pasted = false;
308
+ }
309
+
310
+ if (!pasted) {
311
+ console.error(
312
+ "execCommand unsuccessful; not supported. Adding text manually, no undo support.");
313
+ textarea.setRangeText(modifiedText, this.el.selectionStart, this.el.selectionEnd, 'end');
314
+ }
315
+
316
+ this.el.selectionEnd = this.el.selectionStart = startPos + value.length + offset + (finalOffset ?? 0);
317
+ } else {
318
+ // Using execCommand to support undo, but since it's officially
319
+ // 'deprecated' we need a backup solution, but it won't support undo :(
320
+ let pasted = true;
321
+ try {
322
+ if (!document.execCommand("insertText", false, value)) {
323
+ pasted = false;
324
+ }
325
+ } catch (e) {
326
+ console.error("Error caught during execCommand:", e);
327
+ pasted = false;
328
+ }
329
+
330
+ if (!pasted) {
331
+ console.error(
332
+ "execCommand unsuccessful; not supported. Adding text manually, no undo support.");
333
+ this.el.value += value;
334
+ }
335
+ }
336
+ }
337
+ }
338
+
339
+ /*********************/
340
+
341
+ /**
342
+ * @typedef {{
343
+ * text: string,
344
+ * priority?: number,
345
+ * info?: Function,
346
+ * hint?: string,
347
+ * showValue?: boolean,
348
+ * caretOffset?: number
349
+ * }} AutoCompleteEntry
350
+ */
351
+ export class TextAreaAutoComplete {
352
+ static globalSeparator = "";
353
+ static enabled = true;
354
+ static insertOnTab = true;
355
+ static insertOnEnter = true;
356
+ static replacer = undefined;
357
+ static lorasEnabled = false;
358
+ static suggestionCount = 20;
359
+
360
+ /** @type {Record<string, Record<string, AutoCompleteEntry>>} */
361
+ static groups = {};
362
+ /** @type {Set<string>} */
363
+ static globalGroups = new Set();
364
+ /** @type {Record<string, AutoCompleteEntry>} */
365
+ static globalWords = {};
366
+ /** @type {Record<string, AutoCompleteEntry>} */
367
+ static globalWordsExclLoras = {};
368
+
369
+ /** @type {HTMLTextAreaElement} */
370
+ el;
371
+
372
+ /** @type {Record<string, AutoCompleteEntry>} */
373
+ overrideWords;
374
+ overrideSeparator = "";
375
+
376
+ get words() {
377
+ return this.overrideWords ?? TextAreaAutoComplete.globalWords;
378
+ }
379
+
380
+ get separator() {
381
+ return this.overrideSeparator ?? TextAreaAutoComplete.globalSeparator;
382
+ }
383
+
384
+ /**
385
+ * @param {HTMLTextAreaElement} el
386
+ */
387
+ constructor(el, words = null, separator = null) {
388
+ this.el = el;
389
+ this.helper = new TextAreaCaretHelper(el, () => app.canvas.ds.scale);
390
+ this.dropdown = $el("div.pysssss-autocomplete");
391
+ this.overrideWords = words;
392
+ this.overrideSeparator = separator;
393
+
394
+ this.#setup();
395
+ }
396
+
397
+ #setup() {
398
+ this.el.addEventListener("keydown", this.#keyDown.bind(this));
399
+ this.el.addEventListener("keypress", this.#keyPress.bind(this));
400
+ this.el.addEventListener("keyup", this.#keyUp.bind(this));
401
+ this.el.addEventListener("click", this.#hide.bind(this));
402
+ this.el.addEventListener("blur", () => setTimeout(() => this.#hide(), 150));
403
+ }
404
+
405
+ /**
406
+ * @param {KeyboardEvent} e
407
+ */
408
+ #keyDown(e) {
409
+ if (!TextAreaAutoComplete.enabled) return;
410
+
411
+ if (this.dropdown.parentElement) {
412
+ // We are visible
413
+ switch (e.key) {
414
+ case "ArrowUp":
415
+ e.preventDefault();
416
+ if (this.selected.index) {
417
+ this.#setSelected(this.currentWords[this.selected.index - 1].wordInfo);
418
+ } else {
419
+ this.#setSelected(this.currentWords[this.currentWords.length - 1].wordInfo);
420
+ }
421
+ break;
422
+ case "ArrowDown":
423
+ e.preventDefault();
424
+ if (this.selected.index === this.currentWords.length - 1) {
425
+ this.#setSelected(this.currentWords[0].wordInfo);
426
+ } else {
427
+ this.#setSelected(this.currentWords[this.selected.index + 1].wordInfo);
428
+ }
429
+ break;
430
+ case "Tab":
431
+ if (TextAreaAutoComplete.insertOnTab) {
432
+ this.#insertItem();
433
+ e.preventDefault();
434
+ }
435
+ break;
436
+ }
437
+ }
438
+ }
439
+
440
+ /**
441
+ * @param {KeyboardEvent} e
442
+ */
443
+ #keyPress(e) {
444
+ if (!TextAreaAutoComplete.enabled) return;
445
+ if (this.dropdown.parentElement) {
446
+ // We are visible
447
+ switch (e.key) {
448
+ case "Enter":
449
+ if (!e.ctrlKey) {
450
+ if (TextAreaAutoComplete.insertOnEnter) {
451
+ this.#insertItem();
452
+ e.preventDefault();
453
+ }
454
+ }
455
+ break;
456
+ }
457
+ }
458
+
459
+ if (!e.defaultPrevented) {
460
+ this.#update();
461
+ }
462
+ }
463
+
464
+ #keyUp(e) {
465
+ if (!TextAreaAutoComplete.enabled) return;
466
+ if (this.dropdown.parentElement) {
467
+ // We are visible
468
+ switch (e.key) {
469
+ case "Escape":
470
+ e.preventDefault();
471
+ this.#hide();
472
+ break;
473
+ }
474
+ } else if (e.key.length > 1 && e.key != "Delete" && e.key != "Backspace") {
475
+ return;
476
+ }
477
+ if (!e.defaultPrevented) {
478
+ this.#update();
479
+ }
480
+ }
481
+
482
+ #setSelected(item) {
483
+ if (this.selected) {
484
+ this.selected.el.classList.remove("pysssss-autocomplete-item--selected");
485
+ }
486
+
487
+ this.selected = item;
488
+ this.selected.el.classList.add("pysssss-autocomplete-item--selected");
489
+ }
490
+
491
+ #insertItem() {
492
+ if (!this.selected) return;
493
+ this.selected.el.click();
494
+ }
495
+
496
+ #getFilteredWords(term) {
497
+ term = term.toLocaleLowerCase();
498
+
499
+ const priorityMatches = [];
500
+ const prefixMatches = [];
501
+ const includesMatches = [];
502
+ for (const word of Object.keys(this.words)) {
503
+ const lowerWord = word.toLocaleLowerCase();
504
+ if (lowerWord === term) {
505
+ // Dont include exact matches
506
+ continue;
507
+ }
508
+
509
+ const pos = lowerWord.indexOf(term);
510
+ if (pos === -1) {
511
+ // No match
512
+ continue;
513
+ }
514
+
515
+ const wordInfo = this.words[word];
516
+ if (wordInfo.priority) {
517
+ priorityMatches.push({ pos, wordInfo });
518
+ } else if (pos) {
519
+ includesMatches.push({ pos, wordInfo });
520
+ } else {
521
+ prefixMatches.push({ pos, wordInfo });
522
+ }
523
+ }
524
+
525
+ priorityMatches.sort(
526
+ (a, b) =>
527
+ b.wordInfo.priority - a.wordInfo.priority ||
528
+ a.wordInfo.text.length - b.wordInfo.text.length ||
529
+ a.wordInfo.text.localeCompare(b.wordInfo.text)
530
+ );
531
+
532
+ const top = priorityMatches.length * 0.2;
533
+ return priorityMatches.slice(0, top).concat(prefixMatches, priorityMatches.slice(top), includesMatches).slice(0, TextAreaAutoComplete.suggestionCount);
534
+ }
535
+
536
+ #update() {
537
+ let before = this.helper.getBeforeCursor();
538
+ if (before?.length) {
539
+ const m = before.match(/([^,;"|{}()\n]+)$/);
540
+ if (m) {
541
+ before = m[0]
542
+ .replace(/^\s+/, "")
543
+ .replace(/\s/g, "_") || null;
544
+ } else {
545
+ before = null;
546
+ }
547
+ }
548
+
549
+ if (!before) {
550
+ this.#hide();
551
+ return;
552
+ }
553
+
554
+ this.currentWords = this.#getFilteredWords(before);
555
+ if (!this.currentWords.length) {
556
+ this.#hide();
557
+ return;
558
+ }
559
+
560
+ this.dropdown.style.display = "";
561
+
562
+ let hasSelected = false;
563
+ const items = this.currentWords.map(({ wordInfo, pos }, i) => {
564
+ const parts = [
565
+ $el("span", {
566
+ textContent: wordInfo.text.substr(0, pos),
567
+ }),
568
+ $el("span.pysssss-autocomplete-highlight", {
569
+ textContent: wordInfo.text.substr(pos, before.length),
570
+ }),
571
+ $el("span", {
572
+ textContent: wordInfo.text.substr(pos + before.length),
573
+ }),
574
+ ];
575
+
576
+ if (wordInfo.hint) {
577
+ parts.push(
578
+ $el("span.pysssss-autocomplete-pill", {
579
+ textContent: wordInfo.hint,
580
+ })
581
+ );
582
+ }
583
+
584
+ if (wordInfo.priority) {
585
+ parts.push(
586
+ $el("span.pysssss-autocomplete-pill", {
587
+ textContent: wordInfo.priority,
588
+ })
589
+ );
590
+ }
591
+
592
+ if (wordInfo.value && wordInfo.text !== wordInfo.value && wordInfo.showValue !== false) {
593
+ parts.push(
594
+ $el("span.pysssss-autocomplete-pill", {
595
+ textContent: wordInfo.value,
596
+ })
597
+ );
598
+ }
599
+
600
+ if (wordInfo.info) {
601
+ parts.push(
602
+ $el("a.pysssss-autocomplete-item-info", {
603
+ textContent: "ℹ️",
604
+ title: "View info...",
605
+ onclick: (e) => {
606
+ e.stopPropagation();
607
+ wordInfo.info();
608
+ e.preventDefault();
609
+ },
610
+ })
611
+ );
612
+ }
613
+ const item = $el(
614
+ "div.pysssss-autocomplete-item",
615
+ {
616
+ onclick: () => {
617
+ this.el.focus();
618
+ let value = wordInfo.value ?? wordInfo.text;
619
+ const use_replacer = wordInfo.use_replacer ?? true;
620
+ if (TextAreaAutoComplete.replacer && use_replacer) {
621
+ value = TextAreaAutoComplete.replacer(value);
622
+ }
623
+ value = this.#escapeParentheses(value);
624
+
625
+ const afterCursor = this.helper.getAfterCursor();
626
+ const shouldAddSeparator = !afterCursor.trim().startsWith(this.separator.trim());
627
+ this.helper.insertAtCursor(
628
+ value + (shouldAddSeparator ? this.separator : ''),
629
+ -before.length,
630
+ wordInfo.caretOffset
631
+ );
632
+ setTimeout(() => {
633
+ this.#update();
634
+ }, 150);
635
+ },
636
+ },
637
+ parts
638
+ );
639
+
640
+ if (wordInfo === this.selected) {
641
+ hasSelected = true;
642
+ }
643
+
644
+ wordInfo.index = i;
645
+ wordInfo.el = item;
646
+
647
+ return item;
648
+ });
649
+
650
+ this.#setSelected(hasSelected ? this.selected : this.currentWords[0].wordInfo);
651
+ this.dropdown.replaceChildren(...items);
652
+
653
+ if (!this.dropdown.parentElement) {
654
+ document.body.append(this.dropdown);
655
+ }
656
+
657
+ const position = this.helper.getCursorOffset();
658
+ this.dropdown.style.left = (position.left ?? 0) + "px";
659
+ this.dropdown.style.top = (position.top ?? 0) + "px";
660
+ this.dropdown.style.maxHeight = (window.innerHeight - position.top) + "px";
661
+ }
662
+
663
+ #escapeParentheses(text) {
664
+ return text.replace(/\(/g, '\\(').replace(/\)/g, '\\)');
665
+ }
666
+
667
+ #hide() {
668
+ this.selected = null;
669
+ this.dropdown.remove();
670
+ }
671
+
672
+ static updateWords(id, words, addGlobal = true) {
673
+ const isUpdate = id in TextAreaAutoComplete.groups;
674
+ TextAreaAutoComplete.groups[id] = words;
675
+ if (addGlobal) {
676
+ TextAreaAutoComplete.globalGroups.add(id);
677
+ }
678
+
679
+ if (isUpdate) {
680
+ // Remerge all words
681
+ TextAreaAutoComplete.globalWords = Object.assign(
682
+ {},
683
+ ...Object.keys(TextAreaAutoComplete.groups)
684
+ .filter((k) => TextAreaAutoComplete.globalGroups.has(k))
685
+ .map((k) => TextAreaAutoComplete.groups[k])
686
+ );
687
+ } else if (addGlobal) {
688
+ // Just insert the new words
689
+ Object.assign(TextAreaAutoComplete.globalWords, words);
690
+ }
691
+ }
692
+ }
1/custom_nodes/ComfyUI-Custom-Scripts/web/js/common/binding.js ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-check
2
+ // @ts-ignore
3
+ import { ComfyWidgets } from "../../../../scripts/widgets.js";
4
+ // @ts-ignore
5
+ import { api } from "../../../../scripts/api.js";
6
+ // @ts-ignore
7
+ import { app } from "../../../../scripts/app.js";
8
+
9
+ const PathHelper = {
10
+ get(obj, path) {
11
+ if (typeof path !== "string") {
12
+ // Hardcoded value
13
+ return path;
14
+ }
15
+
16
+ if (path[0] === '"' && path[path.length - 1] === '"') {
17
+ // Hardcoded string
18
+ return JSON.parse(path);
19
+ }
20
+
21
+ // Evaluate the path
22
+ path = path.split(".").filter(Boolean);
23
+ for (const p of path) {
24
+ const k = isNaN(+p) ? p : +p;
25
+ obj = obj[k];
26
+ }
27
+
28
+ return obj;
29
+ },
30
+ set(obj, path, value) {
31
+ // https://stackoverflow.com/a/54733755
32
+ if (Object(obj) !== obj) return obj; // When obj is not an object
33
+ // If not yet an array, get the keys from the string-path
34
+ if (!Array.isArray(path)) path = path.toString().match(/[^.[\]]+/g) || [];
35
+ path.slice(0, -1).reduce(
36
+ (
37
+ a,
38
+ c,
39
+ i // Iterate all of them except the last one
40
+ ) =>
41
+ Object(a[c]) === a[c] // Does the key exist and is its value an object?
42
+ ? // Yes: then follow that path
43
+ a[c]
44
+ : // No: create the key. Is the next key a potential array-index?
45
+ (a[c] =
46
+ Math.abs(path[i + 1]) >> 0 === +path[i + 1]
47
+ ? [] // Yes: assign a new array object
48
+ : {}), // No: assign a new plain object
49
+ obj
50
+ )[path[path.length - 1]] = value; // Finally assign the value to the last key
51
+ return obj; // Return the top-level object to allow chaining
52
+ },
53
+ };
54
+
55
+ /***
56
+ @typedef { {
57
+ left: string;
58
+ op: "eq" | "ne",
59
+ right: string
60
+ } } IfCondition
61
+
62
+ @typedef { {
63
+ type: "if",
64
+ condition: Array<IfCondition>,
65
+ true?: Array<BindingCallback>,
66
+ false?: Array<BindingCallback>
67
+ } } IfCallback
68
+
69
+ @typedef { {
70
+ type: "fetch",
71
+ url: string,
72
+ then: Array<BindingCallback>
73
+ } } FetchCallback
74
+
75
+ @typedef { {
76
+ type: "set",
77
+ target: string,
78
+ value: string
79
+ } } SetCallback
80
+
81
+ @typedef { {
82
+ type: "validate-combo",
83
+ } } ValidateComboCallback
84
+
85
+ @typedef { IfCallback | FetchCallback | SetCallback | ValidateComboCallback } BindingCallback
86
+
87
+ @typedef { {
88
+ source: string,
89
+ callback: Array<BindingCallback>
90
+ } } Binding
91
+ ***/
92
+
93
+ /**
94
+ * @param {IfCondition} condition
95
+ */
96
+ function evaluateCondition(condition, state) {
97
+ const left = PathHelper.get(state, condition.left);
98
+ const right = PathHelper.get(state, condition.right);
99
+
100
+ let r;
101
+ if (condition.op === "eq") {
102
+ r = left === right;
103
+ } else {
104
+ r = left !== right;
105
+ }
106
+
107
+ return r;
108
+ }
109
+
110
+ /**
111
+ * @type { Record<BindingCallback["type"], (cb: any, state: Record<string, any>) => Promise<void>> }
112
+ */
113
+ const callbacks = {
114
+ /**
115
+ * @param {IfCallback} cb
116
+ */
117
+ async if(cb, state) {
118
+ // For now only support ANDs
119
+ let success = true;
120
+ for (const condition of cb.condition) {
121
+ const r = evaluateCondition(condition, state);
122
+ if (!r) {
123
+ success = false;
124
+ break;
125
+ }
126
+ }
127
+
128
+ for (const m of cb[success + ""] ?? []) {
129
+ await invokeCallback(m, state);
130
+ }
131
+ },
132
+ /**
133
+ * @param {FetchCallback} cb
134
+ */
135
+ async fetch(cb, state) {
136
+ const url = cb.url.replace(/\{([^\}]+)\}/g, (m, v) => {
137
+ return PathHelper.get(state, v);
138
+ });
139
+ const res = await (await api.fetchApi(url)).json();
140
+ state["$result"] = res;
141
+ for (const m of cb.then) {
142
+ await invokeCallback(m, state);
143
+ }
144
+ },
145
+ /**
146
+ * @param {SetCallback} cb
147
+ */
148
+ async set(cb, state) {
149
+ const value = PathHelper.get(state, cb.value);
150
+ PathHelper.set(state, cb.target, value);
151
+ },
152
+ async "validate-combo"(cb, state) {
153
+ const w = state["$this"];
154
+ const valid = w.options.values.includes(w.value);
155
+ if (!valid) {
156
+ w.value = w.options.values[0];
157
+ }
158
+ },
159
+ };
160
+
161
+ async function invokeCallback(callback, state) {
162
+ if (callback.type in callbacks) {
163
+ // @ts-ignore
164
+ await callbacks[callback.type](callback, state);
165
+ } else {
166
+ console.warn(
167
+ "%c[🐍 pysssss]",
168
+ "color: limegreen",
169
+ `[binding ${state.$node.comfyClass}.${state.$this.name}]`,
170
+ "unsupported binding callback type:",
171
+ callback.type
172
+ );
173
+ }
174
+ }
175
+
176
+ app.registerExtension({
177
+ name: "pysssss.Binding",
178
+ beforeRegisterNodeDef(node, nodeData) {
179
+ const hasBinding = (v) => {
180
+ if (!v) return false;
181
+ return Object.values(v).find((c) => c[1]?.["pysssss.binding"]);
182
+ };
183
+ const inputs = { ...nodeData.input?.required, ...nodeData.input?.optional };
184
+ if (hasBinding(inputs)) {
185
+ const onAdded = node.prototype.onAdded;
186
+ node.prototype.onAdded = function () {
187
+ const r = onAdded?.apply(this, arguments);
188
+
189
+ for (const widget of this.widgets || []) {
190
+ const bindings = inputs[widget.name][1]?.["pysssss.binding"];
191
+ if (!bindings) continue;
192
+
193
+ for (const binding of bindings) {
194
+ /**
195
+ * @type {import("../../../../../web/types/litegraph.d.ts").IWidget}
196
+ */
197
+ const source = this.widgets.find((w) => w.name === binding.source);
198
+ if (!source) {
199
+ console.warn(
200
+ "%c[🐍 pysssss]",
201
+ "color: limegreen",
202
+ `[binding ${node.comfyClass}.${widget.name}]`,
203
+ "unable to find source binding widget:",
204
+ binding.source,
205
+ binding
206
+ );
207
+ continue;
208
+ }
209
+
210
+ let lastValue;
211
+ async function valueChanged() {
212
+ const state = {
213
+ $this: widget,
214
+ $source: source,
215
+ $node: node,
216
+ };
217
+
218
+ for (const callback of binding.callback) {
219
+ await invokeCallback(callback, state);
220
+ }
221
+
222
+ app.graph.setDirtyCanvas(true, false);
223
+ }
224
+
225
+ const cb = source.callback;
226
+ source.callback = function () {
227
+ const v = cb?.apply(this, arguments) ?? source.value;
228
+ if (v !== lastValue) {
229
+ lastValue = v;
230
+ valueChanged();
231
+ }
232
+ return v;
233
+ };
234
+
235
+ lastValue = source.value;
236
+ valueChanged();
237
+ }
238
+ }
239
+
240
+ return r;
241
+ };
242
+ }
243
+ },
244
+ });