xlwings-server 1.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (313) hide show
  1. xlwings_server/.env.template +145 -0
  2. xlwings_server/__init__.py +12 -0
  3. xlwings_server/_version.py +34 -0
  4. xlwings_server/auth/__init__.py +0 -0
  5. xlwings_server/auth/custom/__init__.py +26 -0
  6. xlwings_server/auth/entraid/__init__.py +131 -0
  7. xlwings_server/auth/entraid/jwks.py +10 -0
  8. xlwings_server/azure_functions_templates/.funcignore +28 -0
  9. xlwings_server/azure_functions_templates/function_app.py +28 -0
  10. xlwings_server/azure_functions_templates/host.json +22 -0
  11. xlwings_server/azure_functions_templates/local.settings.json +8 -0
  12. xlwings_server/build_utils/__init__.py +9 -0
  13. xlwings_server/build_utils/static_file_hasher.py +212 -0
  14. xlwings_server/cli.py +1592 -0
  15. xlwings_server/config.py +228 -0
  16. xlwings_server/custom_functions/__init__.py +8 -0
  17. xlwings_server/custom_functions/examples.py +177 -0
  18. xlwings_server/custom_scripts/__init__.py +8 -0
  19. xlwings_server/custom_scripts/examples.py +94 -0
  20. xlwings_server/databases.py +19 -0
  21. xlwings_server/dependencies.py +126 -0
  22. xlwings_server/docker_templates/.dockerignore +15 -0
  23. xlwings_server/docker_templates/Dockerfile +60 -0
  24. xlwings_server/docker_templates/docker-compose.yaml +32 -0
  25. xlwings_server/hotreload.py +59 -0
  26. xlwings_server/main.py +242 -0
  27. xlwings_server/models/__init__.py +14 -0
  28. xlwings_server/models/user.py +53 -0
  29. xlwings_server/object_handles.py +142 -0
  30. xlwings_server/routers/__init__.py +0 -0
  31. xlwings_server/routers/manifest.py +82 -0
  32. xlwings_server/routers/root.py +16 -0
  33. xlwings_server/routers/socketio.py +69 -0
  34. xlwings_server/routers/taskpane.py +12 -0
  35. xlwings_server/routers/xlwings.py +197 -0
  36. xlwings_server/security_headers.json +53 -0
  37. xlwings_server/serializers/__init__.py +25 -0
  38. xlwings_server/serializers/default_serializer.py +19 -0
  39. xlwings_server/serializers/dictionary_serializer.py +25 -0
  40. xlwings_server/serializers/framework.py +50 -0
  41. xlwings_server/serializers/numpy_serializer.py +26 -0
  42. xlwings_server/serializers/pandas_serializer.py +95 -0
  43. xlwings_server/static/css/core.css +28 -0
  44. xlwings_server/static/css/style.css +0 -0
  45. xlwings_server/static/images/favicon.png +0 -0
  46. xlwings_server/static/images/xlwings-16.png +0 -0
  47. xlwings_server/static/images/xlwings-32.png +0 -0
  48. xlwings_server/static/images/xlwings-64.png +0 -0
  49. xlwings_server/static/images/xlwings-80.png +0 -0
  50. xlwings_server/static/js/auth.js +13 -0
  51. xlwings_server/static/js/config.js +4 -0
  52. xlwings_server/static/js/core/alpinejs-csp-boilerplate.js +11 -0
  53. xlwings_server/static/js/core/bootstrap-customizations.js +7 -0
  54. xlwings_server/static/js/core/custom-functions-code.js +296 -0
  55. xlwings_server/static/js/core/examples.js +62 -0
  56. xlwings_server/static/js/core/hotreload.js +3 -0
  57. xlwings_server/static/js/core/htmx-handlers.js +86 -0
  58. xlwings_server/static/js/core/officejs-history-fix-part1.js +3 -0
  59. xlwings_server/static/js/core/officejs-history-fix-part2.js +2 -0
  60. xlwings_server/static/js/core/reload-custom-functions.js +79 -0
  61. xlwings_server/static/js/core/socketio-handlers.js +34 -0
  62. xlwings_server/static/js/core/xlwings-alert.js +22 -0
  63. xlwings_server/static/js/core/xlwingsjs/alert.js +85 -0
  64. xlwings_server/static/js/core/xlwingsjs/auth.js +63 -0
  65. xlwings_server/static/js/core/xlwingsjs/sheet-buttons.js +133 -0
  66. xlwings_server/static/js/core/xlwingsjs/utils.js +119 -0
  67. xlwings_server/static/js/core/xlwingsjs/wasm.js +131 -0
  68. xlwings_server/static/js/core/xlwingsjs/xlwings.js +1060 -0
  69. xlwings_server/static/js/main.js +0 -0
  70. xlwings_server/static/js/ribbon.js +17 -0
  71. xlwings_server/static/vendor/@alpinejs/LICENSE +21 -0
  72. xlwings_server/static/vendor/@alpinejs/csp/dist/cdn.min.js +7 -0
  73. xlwings_server/static/vendor/@microsoft/office-js/LICENSE.md +76 -0
  74. xlwings_server/static/vendor/@microsoft/office-js/dist/af-za/office_strings.js +8 -0
  75. xlwings_server/static/vendor/@microsoft/office-js/dist/agaveerrorux/agaveerrorux.js +18 -0
  76. xlwings_server/static/vendor/@microsoft/office-js/dist/agaveerrorux/images/agavedefaulticon32x32.png +0 -0
  77. xlwings_server/static/vendor/@microsoft/office-js/dist/agaveerrorux/images/agavedefaulticon96x96.png +0 -0
  78. xlwings_server/static/vendor/@microsoft/office-js/dist/agaveerrorux/images/businessbarclose_16x16x32.png +0 -0
  79. xlwings_server/static/vendor/@microsoft/office-js/dist/agaveerrorux/images/dropdownarrow_16x16x32.png +0 -0
  80. xlwings_server/static/vendor/@microsoft/office-js/dist/agaveerrorux/images/ellipsis_16x16x32.png +0 -0
  81. xlwings_server/static/vendor/@microsoft/office-js/dist/agaveerrorux/images/miniinfoblue_16x16x32.png +0 -0
  82. xlwings_server/static/vendor/@microsoft/office-js/dist/agaveerrorux/images/moe_default_icon.png +0 -0
  83. xlwings_server/static/vendor/@microsoft/office-js/dist/agaveerrorux/images/moe_status_icons.png +0 -0
  84. xlwings_server/static/vendor/@microsoft/office-js/dist/agaveerrorux/images/office.png +0 -0
  85. xlwings_server/static/vendor/@microsoft/office-js/dist/agaveerrorux/images/refresh_16x16x32.png +0 -0
  86. xlwings_server/static/vendor/@microsoft/office-js/dist/agaveerrorux/index.html +16 -0
  87. xlwings_server/static/vendor/@microsoft/office-js/dist/agaveerrorux/style/agaveerrorux.css +482 -0
  88. xlwings_server/static/vendor/@microsoft/office-js/dist/am-et/office_strings.js +1 -0
  89. xlwings_server/static/vendor/@microsoft/office-js/dist/ar-ae/office_strings.js +8 -0
  90. xlwings_server/static/vendor/@microsoft/office-js/dist/ar-bh/office_strings.js +8 -0
  91. xlwings_server/static/vendor/@microsoft/office-js/dist/ar-dz/office_strings.js +8 -0
  92. xlwings_server/static/vendor/@microsoft/office-js/dist/ar-eg/office_strings.js +8 -0
  93. xlwings_server/static/vendor/@microsoft/office-js/dist/ar-iq/office_strings.js +8 -0
  94. xlwings_server/static/vendor/@microsoft/office-js/dist/ar-jo/office_strings.js +8 -0
  95. xlwings_server/static/vendor/@microsoft/office-js/dist/ar-kw/office_strings.js +8 -0
  96. xlwings_server/static/vendor/@microsoft/office-js/dist/ar-lb/office_strings.js +8 -0
  97. xlwings_server/static/vendor/@microsoft/office-js/dist/ar-ly/office_strings.js +8 -0
  98. xlwings_server/static/vendor/@microsoft/office-js/dist/ar-ma/office_strings.js +8 -0
  99. xlwings_server/static/vendor/@microsoft/office-js/dist/ar-om/office_strings.js +8 -0
  100. xlwings_server/static/vendor/@microsoft/office-js/dist/ar-qa/office_strings.js +8 -0
  101. xlwings_server/static/vendor/@microsoft/office-js/dist/ar-sa/office_strings.js +1 -0
  102. xlwings_server/static/vendor/@microsoft/office-js/dist/ar-sy/office_strings.js +8 -0
  103. xlwings_server/static/vendor/@microsoft/office-js/dist/ar-tn/office_strings.js +8 -0
  104. xlwings_server/static/vendor/@microsoft/office-js/dist/ar-ye/office_strings.js +8 -0
  105. xlwings_server/static/vendor/@microsoft/office-js/dist/ariatelemetry/aria-web-telemetry-2.8.0.min.js +2 -0
  106. xlwings_server/static/vendor/@microsoft/office-js/dist/ariatelemetry/aria-web-telemetry-2.9.0.min.js +2 -0
  107. xlwings_server/static/vendor/@microsoft/office-js/dist/ariatelemetry/aria-web-telemetry.js +1 -0
  108. xlwings_server/static/vendor/@microsoft/office-js/dist/az-latn-az/office_strings.js +8 -0
  109. xlwings_server/static/vendor/@microsoft/office-js/dist/be-by/office_strings.js +8 -0
  110. xlwings_server/static/vendor/@microsoft/office-js/dist/bg-bg/office_strings.js +1 -0
  111. xlwings_server/static/vendor/@microsoft/office-js/dist/bn-in/office_strings.js +1 -0
  112. xlwings_server/static/vendor/@microsoft/office-js/dist/bs-latn-ba/office_strings.js +8 -0
  113. xlwings_server/static/vendor/@microsoft/office-js/dist/ca-es/office_strings.js +1 -0
  114. xlwings_server/static/vendor/@microsoft/office-js/dist/cs-cz/office_strings.js +1 -0
  115. xlwings_server/static/vendor/@microsoft/office-js/dist/cy-gb/office_strings.js +1 -0
  116. xlwings_server/static/vendor/@microsoft/office-js/dist/da-dk/office_strings.js +1 -0
  117. xlwings_server/static/vendor/@microsoft/office-js/dist/de-at/office_strings.js +8 -0
  118. xlwings_server/static/vendor/@microsoft/office-js/dist/de-ch/office_strings.js +8 -0
  119. xlwings_server/static/vendor/@microsoft/office-js/dist/de-de/office_strings.js +1 -0
  120. xlwings_server/static/vendor/@microsoft/office-js/dist/de-li/office_strings.js +8 -0
  121. xlwings_server/static/vendor/@microsoft/office-js/dist/de-lu/office_strings.js +8 -0
  122. xlwings_server/static/vendor/@microsoft/office-js/dist/el-gr/office_strings.js +1 -0
  123. xlwings_server/static/vendor/@microsoft/office-js/dist/en-029/office_strings.js +8 -0
  124. xlwings_server/static/vendor/@microsoft/office-js/dist/en-au/office_strings.js +8 -0
  125. xlwings_server/static/vendor/@microsoft/office-js/dist/en-bz/office_strings.js +8 -0
  126. xlwings_server/static/vendor/@microsoft/office-js/dist/en-ca/office_strings.js +8 -0
  127. xlwings_server/static/vendor/@microsoft/office-js/dist/en-gb/office_strings.js +8 -0
  128. xlwings_server/static/vendor/@microsoft/office-js/dist/en-ie/office_strings.js +8 -0
  129. xlwings_server/static/vendor/@microsoft/office-js/dist/en-in/office_strings.js +8 -0
  130. xlwings_server/static/vendor/@microsoft/office-js/dist/en-jm/office_strings.js +8 -0
  131. xlwings_server/static/vendor/@microsoft/office-js/dist/en-my/office_strings.js +8 -0
  132. xlwings_server/static/vendor/@microsoft/office-js/dist/en-nz/office_strings.js +8 -0
  133. xlwings_server/static/vendor/@microsoft/office-js/dist/en-ph/office_strings.js +8 -0
  134. xlwings_server/static/vendor/@microsoft/office-js/dist/en-sg/office_strings.js +8 -0
  135. xlwings_server/static/vendor/@microsoft/office-js/dist/en-tt/office_strings.js +8 -0
  136. xlwings_server/static/vendor/@microsoft/office-js/dist/en-us/office_strings.js +8 -0
  137. xlwings_server/static/vendor/@microsoft/office-js/dist/en-za/office_strings.js +8 -0
  138. xlwings_server/static/vendor/@microsoft/office-js/dist/en-zw/office_strings.js +8 -0
  139. xlwings_server/static/vendor/@microsoft/office-js/dist/es-ar/office_strings.js +8 -0
  140. xlwings_server/static/vendor/@microsoft/office-js/dist/es-bo/office_strings.js +8 -0
  141. xlwings_server/static/vendor/@microsoft/office-js/dist/es-cl/office_strings.js +8 -0
  142. xlwings_server/static/vendor/@microsoft/office-js/dist/es-co/office_strings.js +8 -0
  143. xlwings_server/static/vendor/@microsoft/office-js/dist/es-cr/office_strings.js +8 -0
  144. xlwings_server/static/vendor/@microsoft/office-js/dist/es-do/office_strings.js +8 -0
  145. xlwings_server/static/vendor/@microsoft/office-js/dist/es-ec/office_strings.js +8 -0
  146. xlwings_server/static/vendor/@microsoft/office-js/dist/es-es/office_strings.js +1 -0
  147. xlwings_server/static/vendor/@microsoft/office-js/dist/es-gt/office_strings.js +8 -0
  148. xlwings_server/static/vendor/@microsoft/office-js/dist/es-hn/office_strings.js +8 -0
  149. xlwings_server/static/vendor/@microsoft/office-js/dist/es-mx/office_strings.js +1 -0
  150. xlwings_server/static/vendor/@microsoft/office-js/dist/es-ni/office_strings.js +8 -0
  151. xlwings_server/static/vendor/@microsoft/office-js/dist/es-pa/office_strings.js +8 -0
  152. xlwings_server/static/vendor/@microsoft/office-js/dist/es-pe/office_strings.js +8 -0
  153. xlwings_server/static/vendor/@microsoft/office-js/dist/es-pr/office_strings.js +8 -0
  154. xlwings_server/static/vendor/@microsoft/office-js/dist/es-py/office_strings.js +8 -0
  155. xlwings_server/static/vendor/@microsoft/office-js/dist/es-sv/office_strings.js +8 -0
  156. xlwings_server/static/vendor/@microsoft/office-js/dist/es-us/office_strings.js +8 -0
  157. xlwings_server/static/vendor/@microsoft/office-js/dist/es-uy/office_strings.js +8 -0
  158. xlwings_server/static/vendor/@microsoft/office-js/dist/es-ve/office_strings.js +8 -0
  159. xlwings_server/static/vendor/@microsoft/office-js/dist/es6-promise.js +5 -0
  160. xlwings_server/static/vendor/@microsoft/office-js/dist/et-ee/office_strings.js +1 -0
  161. xlwings_server/static/vendor/@microsoft/office-js/dist/eu-es/office_strings.js +1 -0
  162. xlwings_server/static/vendor/@microsoft/office-js/dist/excel-15.01.js +11 -0
  163. xlwings_server/static/vendor/@microsoft/office-js/dist/excel-15.02.js +11 -0
  164. xlwings_server/static/vendor/@microsoft/office-js/dist/excel-15.js +11 -0
  165. xlwings_server/static/vendor/@microsoft/office-js/dist/excel-mac-16.00-core.js +11 -0
  166. xlwings_server/static/vendor/@microsoft/office-js/dist/excel-mac-16.00.js +25 -0
  167. xlwings_server/static/vendor/@microsoft/office-js/dist/excel-web-16.00-core.js +11 -0
  168. xlwings_server/static/vendor/@microsoft/office-js/dist/excel-web-16.00.js +25 -0
  169. xlwings_server/static/vendor/@microsoft/office-js/dist/excel-win32-16.00.js +19 -0
  170. xlwings_server/static/vendor/@microsoft/office-js/dist/excel-win32-16.01-core.js +11 -0
  171. xlwings_server/static/vendor/@microsoft/office-js/dist/excel-win32-16.01.js +25 -0
  172. xlwings_server/static/vendor/@microsoft/office-js/dist/excel-winrt-16.00.js +25 -0
  173. xlwings_server/static/vendor/@microsoft/office-js/dist/excelios-15.js +11 -0
  174. xlwings_server/static/vendor/@microsoft/office-js/dist/excelwebapp-15.01.js +11 -0
  175. xlwings_server/static/vendor/@microsoft/office-js/dist/excelwebapp-15.02.js +11 -0
  176. xlwings_server/static/vendor/@microsoft/office-js/dist/excelwebapp-15.js +11 -0
  177. xlwings_server/static/vendor/@microsoft/office-js/dist/fa-ir/office_strings.js +1 -0
  178. xlwings_server/static/vendor/@microsoft/office-js/dist/fi-fi/office_strings.js +1 -0
  179. xlwings_server/static/vendor/@microsoft/office-js/dist/fil-ph/office_strings.js +1 -0
  180. xlwings_server/static/vendor/@microsoft/office-js/dist/fr-be/office_strings.js +8 -0
  181. xlwings_server/static/vendor/@microsoft/office-js/dist/fr-ca/office_strings.js +1 -0
  182. xlwings_server/static/vendor/@microsoft/office-js/dist/fr-ch/office_strings.js +8 -0
  183. xlwings_server/static/vendor/@microsoft/office-js/dist/fr-fr/office_strings.js +1 -0
  184. xlwings_server/static/vendor/@microsoft/office-js/dist/fr-lu/office_strings.js +8 -0
  185. xlwings_server/static/vendor/@microsoft/office-js/dist/fr-mc/office_strings.js +8 -0
  186. xlwings_server/static/vendor/@microsoft/office-js/dist/ga-ie/office_strings.js +8 -0
  187. xlwings_server/static/vendor/@microsoft/office-js/dist/gl-es/office_strings.js +1 -0
  188. xlwings_server/static/vendor/@microsoft/office-js/dist/gu-in/office_strings.js +1 -0
  189. xlwings_server/static/vendor/@microsoft/office-js/dist/he-il/office_strings.js +1 -0
  190. xlwings_server/static/vendor/@microsoft/office-js/dist/hi-in/office_strings.js +1 -0
  191. xlwings_server/static/vendor/@microsoft/office-js/dist/hr-ba/office_strings.js +8 -0
  192. xlwings_server/static/vendor/@microsoft/office-js/dist/hr-hr/office_strings.js +1 -0
  193. xlwings_server/static/vendor/@microsoft/office-js/dist/html2canvas.js +8 -0
  194. xlwings_server/static/vendor/@microsoft/office-js/dist/hu-hu/office_strings.js +1 -0
  195. xlwings_server/static/vendor/@microsoft/office-js/dist/hy-am/office_strings.js +8 -0
  196. xlwings_server/static/vendor/@microsoft/office-js/dist/id-id/office_strings.js +1 -0
  197. xlwings_server/static/vendor/@microsoft/office-js/dist/is-is/office_strings.js +1 -0
  198. xlwings_server/static/vendor/@microsoft/office-js/dist/it-ch/office_strings.js +8 -0
  199. xlwings_server/static/vendor/@microsoft/office-js/dist/it-it/office_strings.js +1 -0
  200. xlwings_server/static/vendor/@microsoft/office-js/dist/ja-jp/office_strings.js +1 -0
  201. xlwings_server/static/vendor/@microsoft/office-js/dist/ka-ge/office_strings.js +8 -0
  202. xlwings_server/static/vendor/@microsoft/office-js/dist/kk-kz/office_strings.js +1 -0
  203. xlwings_server/static/vendor/@microsoft/office-js/dist/km-kh/office_strings.js +8 -0
  204. xlwings_server/static/vendor/@microsoft/office-js/dist/kn-in/office_strings.js +1 -0
  205. xlwings_server/static/vendor/@microsoft/office-js/dist/ko-kr/office_strings.js +1 -0
  206. xlwings_server/static/vendor/@microsoft/office-js/dist/lb-lu/office_strings.js +8 -0
  207. xlwings_server/static/vendor/@microsoft/office-js/dist/lo-la/office_strings.js +1 -0
  208. xlwings_server/static/vendor/@microsoft/office-js/dist/lt-lt/office_strings.js +1 -0
  209. xlwings_server/static/vendor/@microsoft/office-js/dist/lv-lv/office_strings.js +1 -0
  210. xlwings_server/static/vendor/@microsoft/office-js/dist/mk-mk/office_strings.js +8 -0
  211. xlwings_server/static/vendor/@microsoft/office-js/dist/ml-in/office_strings.js +1 -0
  212. xlwings_server/static/vendor/@microsoft/office-js/dist/mn-mn/office_strings.js +8 -0
  213. xlwings_server/static/vendor/@microsoft/office-js/dist/mr-in/office_strings.js +1 -0
  214. xlwings_server/static/vendor/@microsoft/office-js/dist/ms-bn/office_strings.js +8 -0
  215. xlwings_server/static/vendor/@microsoft/office-js/dist/ms-my/office_strings.js +1 -0
  216. xlwings_server/static/vendor/@microsoft/office-js/dist/mt-mt/office_strings.js +8 -0
  217. xlwings_server/static/vendor/@microsoft/office-js/dist/nb-no/office_strings.js +1 -0
  218. xlwings_server/static/vendor/@microsoft/office-js/dist/ne-np/office_strings.js +8 -0
  219. xlwings_server/static/vendor/@microsoft/office-js/dist/nl-be/office_strings.js +8 -0
  220. xlwings_server/static/vendor/@microsoft/office-js/dist/nl-nl/office_strings.js +1 -0
  221. xlwings_server/static/vendor/@microsoft/office-js/dist/nn-no/office_strings.js +1 -0
  222. xlwings_server/static/vendor/@microsoft/office-js/dist/o15apptofilemappingtable.js +11 -0
  223. xlwings_server/static/vendor/@microsoft/office-js/dist/office-vsdoc.js +28596 -0
  224. xlwings_server/static/vendor/@microsoft/office-js/dist/office.js +84 -0
  225. xlwings_server/static/vendor/@microsoft/office-js/dist/pl-pl/office_strings.js +1 -0
  226. xlwings_server/static/vendor/@microsoft/office-js/dist/pt-br/office_strings.js +1 -0
  227. xlwings_server/static/vendor/@microsoft/office-js/dist/pt-pt/office_strings.js +1 -0
  228. xlwings_server/static/vendor/@microsoft/office-js/dist/ro-ro/office_strings.js +1 -0
  229. xlwings_server/static/vendor/@microsoft/office-js/dist/ru-ru/office_strings.js +1 -0
  230. xlwings_server/static/vendor/@microsoft/office-js/dist/si-lk/office_strings.js +8 -0
  231. xlwings_server/static/vendor/@microsoft/office-js/dist/sk-sk/office_strings.js +1 -0
  232. xlwings_server/static/vendor/@microsoft/office-js/dist/sl-si/office_strings.js +1 -0
  233. xlwings_server/static/vendor/@microsoft/office-js/dist/sq-al/office_strings.js +8 -0
  234. xlwings_server/static/vendor/@microsoft/office-js/dist/sr-cyrl-cs/office_strings.js +1 -0
  235. xlwings_server/static/vendor/@microsoft/office-js/dist/sr-cyrl-rs/office_strings.js +1 -0
  236. xlwings_server/static/vendor/@microsoft/office-js/dist/sr-latn-cs/office_strings.js +1 -0
  237. xlwings_server/static/vendor/@microsoft/office-js/dist/sr-latn-rs/office_strings.js +1 -0
  238. xlwings_server/static/vendor/@microsoft/office-js/dist/sv-fi/office_strings.js +8 -0
  239. xlwings_server/static/vendor/@microsoft/office-js/dist/sv-se/office_strings.js +1 -0
  240. xlwings_server/static/vendor/@microsoft/office-js/dist/sw-ke/office_strings.js +1 -0
  241. xlwings_server/static/vendor/@microsoft/office-js/dist/ta-in/office_strings.js +1 -0
  242. xlwings_server/static/vendor/@microsoft/office-js/dist/te-in/office_strings.js +1 -0
  243. xlwings_server/static/vendor/@microsoft/office-js/dist/telemetry/oteljs.js +1 -0
  244. xlwings_server/static/vendor/@microsoft/office-js/dist/telemetry/oteljs_agave.js +1 -0
  245. xlwings_server/static/vendor/@microsoft/office-js/dist/th-th/office_strings.js +1 -0
  246. xlwings_server/static/vendor/@microsoft/office-js/dist/tr-tr/office_strings.js +1 -0
  247. xlwings_server/static/vendor/@microsoft/office-js/dist/uk-ua/office_strings.js +1 -0
  248. xlwings_server/static/vendor/@microsoft/office-js/dist/ur-pk/office_strings.js +1 -0
  249. xlwings_server/static/vendor/@microsoft/office-js/dist/vi-vn/office_strings.js +1 -0
  250. xlwings_server/static/vendor/@microsoft/office-js/dist/webauth/webauth.browserauth.js +77 -0
  251. xlwings_server/static/vendor/@microsoft/office-js/dist/webauth/webauth.implicit.js +35 -0
  252. xlwings_server/static/vendor/@microsoft/office-js/dist/zh-cn/office_strings.js +1 -0
  253. xlwings_server/static/vendor/@microsoft/office-js/dist/zh-hk/office_strings.js +8 -0
  254. xlwings_server/static/vendor/@microsoft/office-js/dist/zh-mo/office_strings.js +8 -0
  255. xlwings_server/static/vendor/@microsoft/office-js/dist/zh-sg/office_strings.js +8 -0
  256. xlwings_server/static/vendor/@microsoft/office-js/dist/zh-tw/office_strings.js +1 -0
  257. xlwings_server/static/vendor/axios/dist/axios.min.js +3 -0
  258. xlwings_server/static/vendor/axios/dist/axios.min.js.map +1 -0
  259. xlwings_server/static/vendor/bootstrap/LICENSE +21 -0
  260. xlwings_server/static/vendor/bootstrap/dist/js/bootstrap.bundle.min.js +7 -0
  261. xlwings_server/static/vendor/bootstrap/dist/js/bootstrap.bundle.min.js.map +1 -0
  262. xlwings_server/static/vendor/bootstrap-xlwings/dist/bootstrap-xlwings.min.css +12 -0
  263. xlwings_server/static/vendor/bootstrap-xlwings/dist/bootstrap-xlwings.min.css.map +1 -0
  264. xlwings_server/static/vendor/htmx-ext-head-support/head-support.js +144 -0
  265. xlwings_server/static/vendor/htmx-ext-loading-states/loading-states.js +184 -0
  266. xlwings_server/static/vendor/htmx.org/LICENSE +13 -0
  267. xlwings_server/static/vendor/htmx.org/dist/htmx.min.js +1 -0
  268. xlwings_server/static/vendor/socket.io/LICENSE +22 -0
  269. xlwings_server/static/vendor/socket.io/client-dist/socket.io.min.js +7 -0
  270. xlwings_server/static/vendor/socket.io/client-dist/socket.io.min.js.map +1 -0
  271. xlwings_server/templates/_book.html +8 -0
  272. xlwings_server/templates/alert_base.html +16 -0
  273. xlwings_server/templates/base.html +117 -0
  274. xlwings_server/templates/examples/alpine/README.md +26 -0
  275. xlwings_server/templates/examples/alpine/taskpane.html +47 -0
  276. xlwings_server/templates/examples/auth/README.md +38 -0
  277. xlwings_server/templates/examples/auth/protected.html +8 -0
  278. xlwings_server/templates/examples/auth/public.html +11 -0
  279. xlwings_server/templates/examples/excel_object_model/README.md +49 -0
  280. xlwings_server/templates/examples/excel_object_model/add_name_form.html +27 -0
  281. xlwings_server/templates/examples/hello_world/README.md +9 -0
  282. xlwings_server/templates/examples/hello_world/taskpane_hello.html +24 -0
  283. xlwings_server/templates/examples/htmx_form/README.md +44 -0
  284. xlwings_server/templates/examples/htmx_form/_greeting.html +6 -0
  285. xlwings_server/templates/examples/htmx_form/taskpane_htmx_form.html +21 -0
  286. xlwings_server/templates/examples/live_form_validation/README.md +60 -0
  287. xlwings_server/templates/examples/live_form_validation/add_name_form.html +33 -0
  288. xlwings_server/templates/examples/multi_app/README.md +34 -0
  289. xlwings_server/templates/examples/multi_app/taskpane1.html +7 -0
  290. xlwings_server/templates/examples/multi_app/taskpane2.html +7 -0
  291. xlwings_server/templates/examples/multi_app/taskpane_loader.html +5 -0
  292. xlwings_server/templates/examples/navigation/README.md +28 -0
  293. xlwings_server/templates/examples/navigation/_navigation.html +16 -0
  294. xlwings_server/templates/examples/navigation/taskpane_one.html +8 -0
  295. xlwings_server/templates/examples/navigation/taskpane_three.html +8 -0
  296. xlwings_server/templates/examples/navigation/taskpane_two.html +8 -0
  297. xlwings_server/templates/examples/pictures/README.md +42 -0
  298. xlwings_server/templates/examples/pictures/_picture.html +4 -0
  299. xlwings_server/templates/examples/pictures/taskpane_pictures.html +26 -0
  300. xlwings_server/templates/manifest.xml +155 -0
  301. xlwings_server/templates/taskpane.html +1 -0
  302. xlwings_server/templates/xlwings_alert.html +27 -0
  303. xlwings_server/templates.py +61 -0
  304. xlwings_server/utils.py +32 -0
  305. xlwings_server/wasm/__init__.py +0 -0
  306. xlwings_server/wasm/config.py +24 -0
  307. xlwings_server/wasm/main.py +236 -0
  308. xlwings_server/wasm/requirements.txt +5 -0
  309. xlwings_server-1.1.0.dist-info/METADATA +61 -0
  310. xlwings_server-1.1.0.dist-info/RECORD +313 -0
  311. xlwings_server-1.1.0.dist-info/WHEEL +4 -0
  312. xlwings_server-1.1.0.dist-info/entry_points.txt +2 -0
  313. xlwings_server-1.1.0.dist-info/licenses/LICENSE.md +223 -0
@@ -0,0 +1,296 @@
1
+ const debug = false;
2
+ let invocations = new Set();
3
+ let bodies = new Set();
4
+ let runtime;
5
+ let socket = null;
6
+
7
+ Office.onReady(function (info) {
8
+ // Socket.io
9
+ socket = globalThis.socket ? globalThis.socket : null;
10
+
11
+ if (socket !== null) {
12
+ socket.on("disconnect", () => {
13
+ if (debug) {
14
+ console.log("disconnect");
15
+ }
16
+ for (let invocation of invocations) {
17
+ invocation.setResult([["Stream disconnected"]]);
18
+ }
19
+ invocations.clear();
20
+ });
21
+
22
+ socket.on("connect", () => {
23
+ // Without this, you'd have to hit Ctrl+Alt+F9, which isn't available on the web
24
+ if (debug) {
25
+ console.log("connect");
26
+ }
27
+ for (let body of bodies) {
28
+ socket.emit("xlwings:function-call", body);
29
+ }
30
+ });
31
+ }
32
+
33
+ // Runtime version
34
+ if (
35
+ Office.context.requirements.isSetSupported("CustomFunctionsRuntime", "1.4")
36
+ ) {
37
+ runtime = "1.4";
38
+ } else if (
39
+ Office.context.requirements.isSetSupported("CustomFunctionsRuntime", "1.3")
40
+ ) {
41
+ runtime = "1.3";
42
+ } else if (
43
+ Office.context.requirements.isSetSupported("CustomFunctionsRuntime", "1.2")
44
+ ) {
45
+ runtime = "1.2";
46
+ } else {
47
+ runtime = "1.1";
48
+ }
49
+ });
50
+
51
+ function flattenVarargsArray(arr) {
52
+ // Turn [ [[0]], [ [[0]], [[0]] ] ] into:
53
+ // result: [ [[0]], [[0]], [[0]] ]
54
+ // indices: [ [ 0 ], [ 1, 0 ], [ 1, 1 ] ]
55
+ const result = [];
56
+ const indices = [];
57
+
58
+ function isTripleNested(item) {
59
+ return (
60
+ Array.isArray(item) && Array.isArray(item[0]) && Array.isArray(item[0][0])
61
+ );
62
+ }
63
+
64
+ for (let i = 0; i < arr.length; i++) {
65
+ const item = arr[i];
66
+
67
+ if (isTripleNested(item)) {
68
+ result.push(...item);
69
+ for (let j = 0; j < item.length; j++) {
70
+ indices.push([i, j]);
71
+ }
72
+ } else {
73
+ result.push(item);
74
+ indices.push([i]);
75
+ }
76
+ }
77
+
78
+ // Create a prototype-less object to return to prevent prototype-pollution-loop
79
+ const returnObject = Object.create(null);
80
+ returnObject.result = result;
81
+ returnObject.indices = indices;
82
+
83
+ return returnObject;
84
+ }
85
+
86
+ // Workbook name
87
+ let cachedWorkbookName = null;
88
+
89
+ async function getWorkbookName() {
90
+ if (cachedWorkbookName) {
91
+ return cachedWorkbookName;
92
+ }
93
+ const context = new Excel.RequestContext();
94
+ const workbook = context.workbook;
95
+ workbook.load("name");
96
+ await context.sync();
97
+ cachedWorkbookName = workbook.name;
98
+ return cachedWorkbookName;
99
+ }
100
+
101
+ class Semaphore {
102
+ constructor(maxConcurrency) {
103
+ this.maxConcurrency = maxConcurrency;
104
+ this.currentConcurrency = 0;
105
+ this.queue = [];
106
+ }
107
+
108
+ async acquire() {
109
+ if (this.currentConcurrency < this.maxConcurrency) {
110
+ this.currentConcurrency++;
111
+ return;
112
+ }
113
+ return new Promise((resolve) => this.queue.push(resolve));
114
+ }
115
+
116
+ release() {
117
+ this.currentConcurrency--;
118
+ if (this.queue.length > 0) {
119
+ this.currentConcurrency++;
120
+ const nextResolve = this.queue.shift();
121
+ nextResolve();
122
+ }
123
+ }
124
+ }
125
+
126
+ const semaphore = new Semaphore(1000);
127
+
128
+ async function base() {
129
+ await Office.onReady(); // Block execution until office.js is ready
130
+ // Arguments
131
+ let argsArr = Array.prototype.slice.call(arguments);
132
+ let funcName = argsArr[0];
133
+ let isStreaming = argsArr[1];
134
+ let args = argsArr.slice(2, -1);
135
+ let invocation = argsArr[argsArr.length - 1];
136
+
137
+ const workbookName = await getWorkbookName();
138
+ const officeApiClient = localStorage.getItem("Office API client");
139
+
140
+ // For arguments that are Entities, replace the arg with their address (cache key).
141
+ // The issues is that invocation.parameterAddresses returns a flat list while args
142
+ // contains a nested array for varargs (in Office.js called 'repeating').
143
+ const { result: flatArgs, indices } = flattenVarargsArray(args);
144
+
145
+ // Process each flattened item with respect to its path
146
+ flatArgs.forEach((item, index) => {
147
+ if (item && item[0][0]?.type === "Entity") {
148
+ const address = `${officeApiClient}[${workbookName}]${invocation.parameterAddresses[index]}`;
149
+
150
+ let target = args;
151
+ const path = indices[index];
152
+
153
+ for (let i = 0; i < path.length - 1; i++) {
154
+ target = target[path[i]];
155
+ }
156
+
157
+ const lastIndex = path[path.length - 1];
158
+ target[lastIndex] = [address];
159
+ }
160
+ });
161
+
162
+ // Body
163
+ let body = {
164
+ client: "Office.js",
165
+ func_name: funcName,
166
+ args: args,
167
+ caller_address: `${officeApiClient}[${workbookName}]${invocation.address}`, // not available for streaming functions
168
+ culture_info_name: await xlwings.getCultureInfoName(),
169
+ date_format: await xlwings.getDateFormat(),
170
+ version: "placeholder_xlwings_version",
171
+ runtime: runtime,
172
+ };
173
+
174
+ // Streaming functions communicate via socket.io
175
+ if (isStreaming) {
176
+ if (socket === null) {
177
+ console.error(
178
+ "To enable streaming functions, you need to load the socket.io js client before xlwings.js and custom-functions-code",
179
+ );
180
+ return;
181
+ }
182
+ let taskKey = `${funcName}_${args}`;
183
+ body.task_key = taskKey;
184
+ socket.emit("xlwings:function-call", body);
185
+ if (debug) {
186
+ console.log(`emit xlwings:function-call ${funcName}`);
187
+ }
188
+ invocation.setResult([["Waiting for stream..."]]);
189
+
190
+ socket.off(`xlwings:set-result-${taskKey}`);
191
+ socket.on(`xlwings:set-result-${taskKey}`, (data) => {
192
+ invocation.setResult(data.result);
193
+ if (debug) {
194
+ console.log(`Set Result`);
195
+ }
196
+ });
197
+
198
+ invocations.add(invocation);
199
+ bodies.add(body);
200
+
201
+ return;
202
+ }
203
+
204
+ // Normal functions communicate via REST API
205
+ if (config.onWasm) {
206
+ return await makeWasmCall(body);
207
+ } else {
208
+ return await makeServerCall(body);
209
+ }
210
+ }
211
+
212
+ async function makeServerCall(body) {
213
+ const MAX_RETRIES = config.customFunctionsMaxRetries;
214
+ const RETRY_CODES = config.customFunctionsRetryCodes;
215
+ let attempt = 0;
216
+
217
+ while (attempt < MAX_RETRIES) {
218
+ attempt++;
219
+ let authResult =
220
+ typeof globalThis.getAuth === "function"
221
+ ? await globalThis.getAuth()
222
+ : { token: "", provider: "" };
223
+ let headers = {
224
+ "Content-Type": "application/json",
225
+ sid: socket && socket.id ? socket.id.toString() : null,
226
+ Authorization: authResult.token,
227
+ "Auth-Provider": authResult.provider,
228
+ };
229
+
230
+ await semaphore.acquire();
231
+ try {
232
+ const response = await axios.post(
233
+ window.location.origin + "placeholder_custom_functions_call_path",
234
+ body,
235
+ {
236
+ headers: headers,
237
+ timeout: config.requestTimeout * 1000,
238
+ },
239
+ );
240
+
241
+ return response.data.result;
242
+ } catch (error) {
243
+ console.error(`Attempt ${attempt}: ${error.toString()}`);
244
+ if (error.response) {
245
+ const errMsg =
246
+ (error.response.data && error.response.data.detail) ||
247
+ (error.response.data && error.response.data.error) ||
248
+ (typeof error.response.data === "object"
249
+ ? JSON.stringify(error.response.data)
250
+ : error.response.data) ||
251
+ error.response.statusText ||
252
+ "Unknown server error";
253
+ console.error(`Attempt ${attempt}: ${errMsg}`);
254
+
255
+ // Only retry if the status code is in the retry codes list
256
+ const shouldRetry = RETRY_CODES.includes(error.response.status);
257
+ if (attempt === MAX_RETRIES || !shouldRetry) {
258
+ return showError(errMsg);
259
+ }
260
+ } else if (attempt === MAX_RETRIES) {
261
+ return showError(error.toString());
262
+ }
263
+ } finally {
264
+ semaphore.release();
265
+ }
266
+ }
267
+ }
268
+
269
+ async function makeWasmCall(body) {
270
+ try {
271
+ let result = await globalThis.wasmCustomFunctionsCall(body);
272
+ if (result.error) {
273
+ console.error(result.details);
274
+ showError(result.error);
275
+ }
276
+ return result;
277
+ } catch (error) {
278
+ console.error(error);
279
+ showError(error);
280
+ }
281
+ }
282
+
283
+ function showError(errorMessage) {
284
+ if (
285
+ Office.context.requirements.isSetSupported("CustomFunctionsRuntime", "1.2")
286
+ ) {
287
+ // Error message is only visible by hovering over the error flag!
288
+ let excelError = new CustomFunctions.Error(
289
+ CustomFunctions.ErrorCode.invalidValue,
290
+ errorMessage,
291
+ );
292
+ throw excelError;
293
+ } else {
294
+ return [[errorMessage]];
295
+ }
296
+ }
@@ -0,0 +1,62 @@
1
+ function alertCallback(arg) {
2
+ let outputContainer = document.getElementById("output-container");
3
+ if (!outputContainer) {
4
+ outputContainer = document.createElement("div");
5
+ outputContainer.id = "output-container";
6
+ document.querySelector(".container-fluid").appendChild(outputContainer);
7
+ }
8
+ outputContainer.textContent = `User clicked: ${arg}`;
9
+ }
10
+ xlwings.registerCallback(alertCallback);
11
+
12
+ const visibility = {
13
+ isOpen: false,
14
+ label: "Show",
15
+ toggle() {
16
+ this.isOpen = !this.isOpen;
17
+ this.label = this.isOpen ? "Hide" : "Show";
18
+ },
19
+ };
20
+ registerAlpineComponent("visibility", visibility);
21
+
22
+ const slider = {
23
+ percentage: 50,
24
+ update() {
25
+ this.percentage = this.$el.value;
26
+ },
27
+ };
28
+ registerAlpineComponent("slider", slider);
29
+
30
+ const nameForm = {
31
+ firstName: "",
32
+ lastName: "",
33
+ fullName: "(empty)",
34
+ focus() {
35
+ this.$el.focus();
36
+ },
37
+ handleInput() {
38
+ this[this.$el.name] = this.$el.value;
39
+ const fullName = `${this.firstName} ${this.lastName}`;
40
+ this.fullName = !this.firstName && !this.lastName ? "(empty)" : fullName;
41
+ },
42
+ };
43
+ registerAlpineComponent("nameForm", nameForm);
44
+
45
+ const appLoader = {
46
+ url: "",
47
+ async init() {
48
+ let bookName = await xlwings.getActiveBookName();
49
+ // Works with both an unsaved book ("Book1") as well as a saved one "Book1.xlsx"
50
+ if (bookName.includes("Book1")) {
51
+ // TODO: fix if app_path is provided
52
+ this.url = "/taskpane?app=1";
53
+ } else {
54
+ this.url = "/taskpane?app=2";
55
+ }
56
+ this.$nextTick(() => {
57
+ htmx.process(this.$el);
58
+ this.$dispatch("app:loadTaskpane");
59
+ });
60
+ },
61
+ };
62
+ registerAlpineComponent("appLoader", appLoader);
@@ -0,0 +1,3 @@
1
+ globalThis.socket.on("reload", () => {
2
+ location.reload();
3
+ });
@@ -0,0 +1,86 @@
1
+ // Config
2
+ htmx.config.includeIndicatorStyles = false; // required by CSP
3
+ htmx.config.historyCacheSize = 0;
4
+ htmx.config.allowEval = false;
5
+ htmx.config.selfRequestsOnly = true;
6
+
7
+ // Error handling
8
+ htmx.on("htmx:sendError", function (event) {
9
+ // Connection issues
10
+ const globalErrorAlert = document.querySelector("#global-error-alert");
11
+ globalErrorAlert.classList.remove("d-none");
12
+ globalErrorAlert.querySelector("span").textContent =
13
+ "Connection error. Please reload the page!";
14
+ });
15
+
16
+ htmx.on("htmx:responseError", function (event) {
17
+ // Unhandled exceptions from Python partials or nginx.
18
+ // Exceptions with full page reloads are handled with FastAPI exceptions handlers.
19
+ const globalErrorAlert = document.querySelector("#global-error-alert");
20
+ const errorCode = event.detail.xhr.status;
21
+ globalErrorAlert.classList.remove("d-none");
22
+ if (errorCode === 404) {
23
+ globalErrorAlert.querySelector("span").textContent =
24
+ `Error ${errorCode}: Page not found`;
25
+ } else if (errorCode === 500) {
26
+ globalErrorAlert.querySelector("span").textContent = `Error ${errorCode}`;
27
+ } else if (errorCode === 401) {
28
+ globalErrorAlert.querySelector("span").textContent =
29
+ `Error ${errorCode}: Unauthorized`;
30
+ } else if (errorCode === 403) {
31
+ globalErrorAlert.querySelector("span").textContent =
32
+ `Error ${errorCode}: Forbidden`;
33
+ } else {
34
+ // Mostly 502/503/504 errors
35
+ globalErrorAlert.querySelector("span").textContent =
36
+ `Error ${errorCode}: Please reload the page!`;
37
+ }
38
+ });
39
+
40
+ // Task pane authentication (see: https://htmx.org/examples/async-auth/)
41
+ // and bookData handling
42
+ let authResult = null;
43
+ let bookData = null;
44
+
45
+ htmx.on("htmx:confirm", async (event) => {
46
+ // Block the request until the token is returned
47
+ event.preventDefault();
48
+ // Auth
49
+ authResult = await globalThis.getAuth();
50
+ // Book
51
+ let element = event.target;
52
+ let includeBook = element.getAttribute("xw-book");
53
+ if (includeBook === "true") {
54
+ let config = element.getAttribute("xw-config")
55
+ ? JSON.parse(element.getAttribute("xw-config"))
56
+ : {};
57
+ // TODO: use default context
58
+ await Excel.run(async (context) => {
59
+ bookData = await xlwings.getBookData(config, context);
60
+ });
61
+ }
62
+
63
+ // Resume the request
64
+ event.detail.issueRequest();
65
+ });
66
+
67
+ htmx.on("htmx:configRequest", (event) => {
68
+ event.detail.headers["Authorization"] = authResult.token;
69
+ event.detail.headers["Auth-Provider"] = authResult.provider;
70
+ let element = event.target;
71
+ let includeBook = element.getAttribute("xw-book");
72
+ if (includeBook === "true") {
73
+ event.detail.parameters["bookData"] = JSON.stringify(bookData);
74
+ }
75
+ });
76
+
77
+ htmx.on("htmx:afterSwap", async (event) => {
78
+ const bookDataElement = document.getElementById("book-data");
79
+ if (bookDataElement) {
80
+ const bookDataJson = JSON.parse(bookDataElement.text);
81
+ await Excel.run(async (context) => {
82
+ xlwings.runActions(bookDataJson, context);
83
+ });
84
+ }
85
+ await xlwings.init();
86
+ });
@@ -0,0 +1,3 @@
1
+ // https://github.com/OfficeDev/office-js/issues/429#issuecomment-1971645795
2
+ const originalReplaceState = history.replaceState;
3
+ const originalPushState = history.pushState;
@@ -0,0 +1,2 @@
1
+ history.replaceState = originalReplaceState;
2
+ history.pushState = originalPushState;
@@ -0,0 +1,79 @@
1
+ async function reloadCustomFunctions(meta = null, code = null) {
2
+ // Unofficial API: https://github.com/OfficeDev/office-js/issues/3486
3
+ // This causes issues when opening a workbook in a running instance of Excel. If
4
+ // Excel is completely closed, it does load the add-in, but not if it is already
5
+ // running.
6
+ // Custom functions will show #NAME? until the task pane is opened
7
+ // manually. That's why this is only loaded in "dev" environment.
8
+ // await Office.addin.setStartupBehavior(Office.StartupBehavior.load); should solve
9
+ // the issue, but you should have a way to switch it off again, as otherwise, if you
10
+ // open the add-in in an unrelated workbook by accident, it would open the add-in
11
+ // every time you open that workbook.
12
+ await Office.onReady();
13
+ let jsonMetadataString;
14
+ let functionCode;
15
+
16
+ if (Office.context.requirements.isSetSupported("CustomFunctions", "1.6")) {
17
+ try {
18
+ if (meta && code) {
19
+ jsonMetadataString = meta;
20
+ functionCode = code;
21
+ } else {
22
+ const [metadataResponse, codeResponse] = await Promise.all([
23
+ fetch(`${config.appPath}/xlwings/custom-functions-meta.json`),
24
+ fetch(`${config.appPath}/xlwings/custom-functions-code.js`),
25
+ ]);
26
+
27
+ if (!metadataResponse.ok || !codeResponse.ok) {
28
+ throw new Error("Failed to fetch custom functions data");
29
+ }
30
+
31
+ jsonMetadataString = await metadataResponse.text();
32
+ functionCode = await codeResponse.text();
33
+ }
34
+
35
+ await Excel.CustomFunctionManager.register(
36
+ jsonMetadataString,
37
+ functionCode,
38
+ );
39
+ // console.log(jsonMetadataString)
40
+ // console.log(functionCode)
41
+ console.log("Successfully reloaded custom functions!");
42
+ } catch (error) {
43
+ console.error("Error reloading custom functions:", error);
44
+ }
45
+ } else {
46
+ try {
47
+ await Excel.run(async (context) => {
48
+ Excel.CustomFunctionManager.newObject(context).register(
49
+ jsonMetadataString,
50
+ functionCode,
51
+ );
52
+ await context.sync();
53
+ });
54
+ } catch (error) {
55
+ console.error("Failed to register custom functions:", error);
56
+ }
57
+ }
58
+ }
59
+
60
+ async function retryReloadCustomFunctions(retries, delay) {
61
+ for (let i = 0; i < retries; i++) {
62
+ try {
63
+ await reloadCustomFunctions();
64
+ // console.log(`Reloaded custom functions code at attempt ${i + 1}`);
65
+ return;
66
+ } catch (error) {
67
+ if (i === retries - 1) throw error;
68
+ await new Promise((resolve) => setTimeout(resolve, delay));
69
+ }
70
+ }
71
+ }
72
+
73
+ if (!config.isOfficialLiteAddin) {
74
+ (async () => {
75
+ const maxRetries = 5;
76
+ const delay = 100;
77
+ await retryReloadCustomFunctions(maxRetries, delay);
78
+ })();
79
+ }
@@ -0,0 +1,34 @@
1
+ // Socket.io
2
+ try {
3
+ globalThis.socket = io({
4
+ transports: ["websocket", "polling"],
5
+ path: `${config.appPath}/socket.io/`,
6
+ auth: async (callback) => {
7
+ let authResult =
8
+ typeof globalThis.getAuth === "function"
9
+ ? await globalThis.getAuth()
10
+ : { token: "", provider: "" };
11
+ callback({
12
+ token: authResult.token,
13
+ provider: authResult.provider,
14
+ });
15
+ },
16
+ });
17
+ } catch (error) {
18
+ console.log("Didn't load socket.io: ", error);
19
+ globalThis.socket = null;
20
+ }
21
+
22
+ globalThis.socket.on("xlwings:trigger-script", async (data) => {
23
+ let authResult =
24
+ typeof globalThis.getAuth === "function"
25
+ ? await globalThis.getAuth()
26
+ : { token: "", provider: "" };
27
+ xlwings.runPython({
28
+ include: data?.include || "",
29
+ exclude: data?.exclude || "",
30
+ auth: authResult.token,
31
+ headers: { "Auth-Provider": authResult.provider },
32
+ scriptName: data.script_name,
33
+ });
34
+ });
@@ -0,0 +1,22 @@
1
+ if (document.getElementById("ok")) {
2
+ document.getElementById("ok").addEventListener("click", buttonCallback);
3
+ }
4
+ if (document.getElementById("yes")) {
5
+ document.getElementById("yes").addEventListener("click", buttonCallback);
6
+ }
7
+ if (document.getElementById("no")) {
8
+ document.getElementById("no").addEventListener("click", buttonCallback);
9
+ }
10
+ if (document.getElementById("cancel")) {
11
+ document.getElementById("cancel").addEventListener("click", buttonCallback);
12
+ }
13
+ function buttonCallback() {
14
+ Office.onReady(() => {
15
+ // This causes this issue: https://github.com/OfficeDev/office-js/issues/3582
16
+ Office.context.ui.messageParent(
17
+ this.id +
18
+ "|" +
19
+ document.getElementById("callback").getAttribute("data-callback"),
20
+ );
21
+ });
22
+ }
@@ -0,0 +1,85 @@
1
+ // https://learn.microsoft.com/en-us/office/dev/add-ins/develop/dialog-api-in-office-add-ins
2
+
3
+ let dialog;
4
+
5
+ function dialogCallback(asyncResult) {
6
+ if (asyncResult.status === Office.AsyncResultStatus.Failed) {
7
+ console.log(`${asyncResult.error.message} [${asyncResult.error.code}]`);
8
+ } else {
9
+ dialog = asyncResult.value;
10
+ // Handle messages and events
11
+ dialog.addEventHandler(
12
+ Office.EventType.DialogMessageReceived,
13
+ processMessage,
14
+ );
15
+ dialog.addEventHandler(
16
+ Office.EventType.DialogEventReceived,
17
+ processDialogEvent,
18
+ );
19
+ }
20
+ }
21
+
22
+ function processMessage(arg) {
23
+ dialog.close();
24
+ let [selection, callback] = arg.message.split("|");
25
+ if (callback !== "" && callback in globalThis.callbacks) {
26
+ globalThis.callbacks[callback](selection);
27
+ } else {
28
+ if (callback !== "" && !(callback in globalThis.callbacks)) {
29
+ throw new Error(
30
+ `Didn't find callback '${callback}'! Make sure to run xlwings.registerCallback(${callback}) before calling runPython.`,
31
+ );
32
+ }
33
+ }
34
+ }
35
+
36
+ function processDialogEvent(arg) {
37
+ switch (arg.error) {
38
+ case 12002:
39
+ console.log(
40
+ "The dialog box has been directed to a page that it cannot find or load, or the URL syntax is invalid.",
41
+ );
42
+ break;
43
+ case 12003:
44
+ console.log("HTTPS is required.");
45
+ break;
46
+ case 12006:
47
+ console.log("Dialog closed by user");
48
+ break;
49
+ default:
50
+ console.log("Unknown error in dialog box");
51
+ break;
52
+ }
53
+ }
54
+
55
+ export async function xlAlert(prompt, title, buttons, mode, callback) {
56
+ await Office.onReady();
57
+ let width;
58
+ let height;
59
+ if (Office.context.platform.toString() === "OfficeOnline") {
60
+ width = 28;
61
+ height = 36;
62
+ } else if (Office.context.platform.toString() === "PC") {
63
+ width = 28; // seems to have a wider min width
64
+ height = 40;
65
+ } else {
66
+ width = 32;
67
+ height = 30;
68
+ }
69
+
70
+ if (dialog) {
71
+ dialog.close();
72
+ console.log("Closed perviously open dialog to prevent error 12007.");
73
+ }
74
+ Office.context.ui.displayDialogAsync(
75
+ window.location.origin +
76
+ config.appPath +
77
+ `/xlwings/alert?prompt=` +
78
+ encodeURIComponent(`${prompt}`) +
79
+ `&title=` +
80
+ encodeURIComponent(`${title}`) +
81
+ `&buttons=${buttons}&mode=${mode}&callback=${callback}`,
82
+ { height: height, width: width, displayInIframe: true },
83
+ dialogCallback,
84
+ );
85
+ }