@stlite/desktop 0.101.0 → 0.101.1

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 (106) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/assets/{ArrowVegaLiteChart-BPRH3gBe-BAbt2P_J.js → ArrowVegaLiteChart-CatHU5ye-DE4k_KZP.js} +1 -1
  3. package/build/assets/{Audio-CoZBGqWO-DVgjOuuv.js → Audio-Y9nq0mPc-DJn2U9cz.js} +1 -1
  4. package/build/assets/{AudioInput-CP7K7uZB-DEV8Xl4i.js → AudioInput-Csthtpwn-Gk0F2DgH.js} +1 -1
  5. package/build/assets/{Balloons-Dskp5L92-ZNEwM3D8.js → Balloons-CAfRmkgd-z1flYTjg.js} +1 -1
  6. package/build/assets/{BidiComponent-DxYVG75b-CJQGNxg7.js → BidiComponent-C0W-jB8K-D7KrGlkt.js} +1 -1
  7. package/build/assets/{Button-5Ajtxbwn-BDegkHP-.js → Button-CtzCBW58-BD91cO69.js} +1 -1
  8. package/build/assets/{ButtonGroup-pGxlWp89-DmbuGG5M.js → ButtonGroup-tARGP97W-k1H0Zd3f.js} +1 -1
  9. package/build/assets/{CameraInput-vKKDhL6--Bpo-2dKV.js → CameraInput-CiV08N6Y-BKRxm_ar.js} +1 -1
  10. package/build/assets/{ChatInput-B6oFIFHm-uQa-NGtx.js → ChatInput-CFv2o38z-D_M_04yy.js} +1 -1
  11. package/build/assets/{Checkbox-DkJE55dj-CY83TfqD.js → Checkbox-DWGcKBjY-KBwPglLJ.js} +1 -1
  12. package/build/assets/{ColorPicker-BMz1lxCB-B2MaPR-H.js → ColorPicker-DFXf_KfZ-CnAPoS0z.js} +1 -1
  13. package/build/assets/{ComponentInstance-Cemgj4S0-BMxea-Y3.js → ComponentInstance-Dlz3boBV-ElD3LiR-.js} +1 -1
  14. package/build/assets/{DataFrame-CE79SZpX-CVHFe_Oz.js → DataFrame-ZHi5iyDV-DOvZAfc9.js} +5 -5
  15. package/build/assets/{DateInput-CEc2d-u8-CCDK405-.js → DateInput-DY0AqEEz-CqSRF0qe.js} +1 -1
  16. package/build/assets/{DateTimeInput-Dxlp0suj-lPuiAonQ.js → DateTimeInput-CXPUXbNs-be2fi1AZ.js} +1 -1
  17. package/build/assets/{DeckGlJsonChart-BW5EAwx1-BE5y5UXu.js → DeckGlJsonChart-3OvaJ57f-UNRd4a-y.js} +1 -1
  18. package/build/assets/{DownloadButton-DV8eX00c-kOA1BAvU.js → DownloadButton-DmVVeFJl-Do7BZpDb.js} +1 -1
  19. package/build/assets/{ErrorOutline.esm-iPLqAm6s-BL6R0-E8.js → ErrorOutline.esm-YgtldkCQ-CemIM7Sw.js} +1 -1
  20. package/build/assets/{Feedback-MVQzrJry-Dd1sPXaV.js → Feedback-BcHw2pQG-CaKtB97h.js} +1 -1
  21. package/build/assets/{FileDownload.esm-8YapEt7k-NoDtFt6j.js → FileDownload.esm-DA6EBJWo-CxqNcH-o.js} +1 -1
  22. package/build/assets/{FileUploader-Bq3BegdV-B3r5TUWB.js → FileUploader-Dpa-JOXx-BcyQjtX1.js} +1 -1
  23. package/build/assets/{FormSubmitContent-DD_l2XQL-BimOkDO8.js → FormSubmitContent-BjnJlt70-CMef_LQq.js} +1 -1
  24. package/build/assets/{GraphVizChart-j4WovvTA-C0wWJ_pD.js → GraphVizChart-DvlJXY81-DgyqPG63.js} +1 -1
  25. package/build/assets/{Html-D79N9lS4-DAD924qV.js → Html-B0_sFMha-C_dmalFu.js} +1 -1
  26. package/build/assets/{IFrame-C-0ir_lX-COQZFQmq.js → IFrame-DRaylZUz-BDLId26Q.js} +1 -1
  27. package/build/assets/{ImageList-DITlvS6g-BFNsGTg4.js → ImageList-C_I_gGvM-DLKWaXo_.js} +1 -1
  28. package/build/assets/{InputInstructions-nOmuO-zQ-DLhhHeOF.js → InputInstructions-BQBBgzXB-CiqDziMj.js} +1 -1
  29. package/build/assets/{Json-dkGVRbLV-BZzUtwOp.js → Json-C6_T-DWT-DkBsT-1G.js} +1 -1
  30. package/build/assets/{LinkButton-CxeesGpD-XutrRy0n.js → LinkButton-6uqUWhGF-D7wFQ281.js} +1 -1
  31. package/build/assets/{MenuButton-UcWUeA29-CQZ7nqVP.js → MenuButton-Bmt95URR-DWfL9ITb.js} +1 -1
  32. package/build/assets/{Metric-E6w6g5y9-Dk-6h2Zo.js → Metric-SKreeL3S-D11O16iU.js} +1 -1
  33. package/build/assets/{Multiselect-C_J-6rRf-BBLmmdLo.js → Multiselect-C7QmmmLa-DswxpHA8.js} +1 -1
  34. package/build/assets/{NumberInput-CmmPAj3n-BvWR0X5L.js → NumberInput-zpxbqqaI-BemEeZnC.js} +1 -1
  35. package/build/assets/{PageLink-B_F10WTa-BFWV94JC.js → PageLink-CS25U8sD-DuDcJ3as.js} +1 -1
  36. package/build/assets/{Particles-Dg4BbwYl-DxeaHInY.js → Particles-CvcHVa3B-D8gsFknc.js} +1 -1
  37. package/build/assets/{PlotlyChart-D4XY8twK-DVP8NFHB.js → PlotlyChart-CvayS3p7-Chny3tV_.js} +1 -1
  38. package/build/assets/{Progress-B1iI3faW-BbsFPR94.js → Progress-DGYWLpfg-CRiA40l6.js} +1 -1
  39. package/build/assets/{ProgressBar-Dxdjhh5v-CTb2XLYl.js → ProgressBar-DhIwITyC-B3HjvnkD.js} +1 -1
  40. package/build/assets/{Radio-BrYX5pm0-CF7BRVxx.js → Radio-DpOh-J7A-CQZUGZrw.js} +1 -1
  41. package/build/assets/{Selectbox-sP6HTvqf-DlF5ZFtf.js → Selectbox-3CDAXdnY-CsatfdqB.js} +1 -1
  42. package/build/assets/{Slider-D98WJ7GD-BEhH17Zd.js → Slider-DMZ19nRR-D59HIM6O.js} +1 -1
  43. package/build/assets/{Snow-BEe0B8y4-DD2qBOW1.js → Snow-5YC5Tskh-CYK5UTTk.js} +1 -1
  44. package/build/assets/{Spinner-iDUBO9CD-D_zDEDrL.js → Spinner-B3_-SaXN-McIq5xMY.js} +1 -1
  45. package/build/assets/{StreamlitSyntaxHighlighter-B0XLn_aG-C0Kyhnly.js → StreamlitSyntaxHighlighter-BQaPTFQq-D7Uj2Adi.js} +1 -1
  46. package/build/assets/{Table-BN3amuUX-_h5zNOPx.js → Table-Bc9x-fDk-DqKxodLp.js} +1 -1
  47. package/build/assets/{TableChart.esm-BEJJfW1D-DZXow7YN.js → TableChart.esm-DqSB-klz-DFWt0snW.js} +1 -1
  48. package/build/assets/{TextArea-BEB_9fLu-CW8pYEVM.js → TextArea-B1xQzjI6-B02nvgg-.js} +1 -1
  49. package/build/assets/{TextInput-CnKuZu4D-BpWqERh9.js → TextInput-D1xd0P97-BixpGDSG.js} +1 -1
  50. package/build/assets/{TimeInput-p5WNkWhN-5G1YCgeW.js → TimeInput-DuMfskY4-BipgeoUn.js} +1 -1
  51. package/build/assets/{Toast-CamIWrFG-D9p31VL8.js → Toast-CJKq1jpo-CCJnP6c1.js} +1 -1
  52. package/build/assets/{Video-QwWFy5xP-BpsExZGv.js → Video-B1N4EHQq-nnkWrBjK.js} +1 -1
  53. package/build/assets/{WidgetLabel-UxhCOQGD-Outa0e9S.js → WidgetLabel-CQfHGtry-H2bBW1_F.js} +1 -1
  54. package/build/assets/{WidgetLabelHelpIcon-B9x-Yn7N-DaZaIL2I.js → WidgetLabelHelpIcon-C6IRqJ_I-CThDB-RY.js} +1 -1
  55. package/build/assets/{WidgetLabelHelpIconInline-DpAdsUdv-BJmzytr_.js → WidgetLabelHelpIconInline-BTmzKeRa-Duj2btUF.js} +1 -1
  56. package/build/assets/{_baseAssignValue-5yAp7ssZ-B_y2bL7u.js → _baseAssignValue-CvLdsscI-CrqCsrMj.js} +1 -1
  57. package/build/assets/{base-input-BruRHirU-Dc9fKcQ_.js → base-input-Drzzu2Q6-ChupVbXS.js} +1 -1
  58. package/build/assets/{checkbox-SGVQt8CZ-CUyChNRB.js → checkbox-BlFkpHIT--ezfhS9t.js} +1 -1
  59. package/build/assets/{constants-BAtobv15-hfdyP7sx.js → constants-yZa2TGaZ-C7XGmSjZ.js} +1 -1
  60. package/build/assets/{createDownloadLinkElement-hdE2s_AI-2rp2KBS8.js → createDownloadLinkElement-CnWgptKS-DPufZYcx.js} +1 -1
  61. package/build/assets/{createSuper-DStVJdot-BgJXIEaD.js → createSuper-DfsXhqeB-CdsievJ8.js} +1 -1
  62. package/build/assets/{data-grid-overlay-editor-CpKwlh0F-Ot5bveZo.js → data-grid-overlay-editor-BylJk6rz-B2d0C4wn.js} +1 -1
  63. package/build/assets/{downloader-CZ7qD7NY-DO5yuo_B.js → downloader-CZ7qD7NY-bknF4iTS.js} +1 -1
  64. package/build/assets/{embed-BWbkDQKD-CQt2Xn8d.js → embed-C21m9f7b-B4FzBzhy.js} +1 -1
  65. package/build/assets/{es6-BxevHr5y-BFwhOTke.js → es6-BxevHr5y-CS3OejqZ.js} +1 -1
  66. package/build/assets/{formatNumber-CK08KwyC-BpCoyciY.js → formatNumber-B9NmJPl4-Bduke_Pe.js} +1 -1
  67. package/build/assets/{iconPosition-CaL2HY1u-D4CYRoRA.js → iconPosition-Cpqwt3HE-D1Z0gR4v.js} +1 -1
  68. package/build/assets/{iframeResizer.contentWindow-DwDNXvbk-Cmn9AtXP.js → iframeResizer.contentWindow-CaUMNiuy-bR3yN29o.js} +1 -1
  69. package/build/assets/{index-BWg7VeLm-DVMf1gfQ.js → index-B7jxgHEF-tvzMtMrO.js} +1 -1
  70. package/build/assets/{index-cRrBqQzO-ixGPBxWO.js → index-DINISCAW-ClgNywT7.js} +1 -1
  71. package/build/assets/{index-B14K3STS-DjuURwqx.js → index-DZZFubxH-pza9foUu.js} +1 -1
  72. package/build/assets/{index-CC2oI2tl-B1Janb2E.js → index-Dk9oWC2N-Cm5J-5pS.js} +1 -1
  73. package/build/assets/{index-DtJJZPfU-CoZOkYgP.js → index-DmoOfsTG-CbezIXlt.js} +1 -1
  74. package/build/assets/{index-B4fa-n2i.js → index-lR-QVdnh.js} +5 -5
  75. package/build/assets/{input-CK4OtyRn-yU_-c-Kx.js → input-CClPhvPt-ZRbRIlPm.js} +1 -1
  76. package/build/assets/{memory-C-LDMFc2-CqsiY5qN.js → memory-C-LDMFc2-grfew3Ct.js} +1 -1
  77. package/build/assets/{moment-C29_LcvN-KXJiUm6M.js → moment-C29_LcvN-DWLtgoJ3.js} +1 -1
  78. package/build/assets/{number-overlay-editor-Cdrkus19-CUUZ-u43.js → number-overlay-editor-CQ3u-ilh-C8RlzGdo.js} +1 -1
  79. package/build/assets/{pandasStylerUtils-CY1NqKTm-DwfIUg29.js → pandasStylerUtils-lPQUevWP-DCEaT5gM.js} +1 -1
  80. package/build/assets/{possibleConstructorReturn-Dp3x_67l-DW084-po.js → possibleConstructorReturn-BHiKHPYz-Ct6Qmz2B.js} +1 -1
  81. package/build/assets/{reactJsonViewCompat-BhHQdMb3-D8YsIkW1.js → reactJsonViewCompat-BZlB_0r4-DL51cX9L.js} +1 -1
  82. package/build/assets/{sandbox-DbnteG5V-DNuXtcQa.js → sandbox-DbnteG5V-HPERfLXa.js} +1 -1
  83. package/build/assets/{select-zCQ7w46r-igC065UB.js → select-DyvsciAf-taVHCqSw.js} +1 -1
  84. package/build/assets/{sprintfjs-COS3ohU3-DoDOU6OA.js → sprintfjs-pgmg3ABV-kczlFpH1.js} +1 -1
  85. package/build/assets/{stateful-menu-B1me4S43-BQ0PQHe9.js → stateful-menu-CW-YE2l8-eSvRA0_x.js} +1 -1
  86. package/build/assets/{styled-components-CQF9Arpx-CYVHnd6_.js → styled-components-BDZ1Vzrp-DV4YFEHI.js} +1 -1
  87. package/build/assets/{styled-components-k0rbnWKx-D5DoPNuy.js → styled-components-CZBaXqHz-WpjbtMki.js} +1 -1
  88. package/build/assets/{styled-components-vQd9mwpf-HK_7dsCd.js → styled-components-Cxzc3DcQ-Dx1RKHWs.js} +1 -1
  89. package/build/assets/{timepicker-EzC3uiD--BM84grrq.js → timepicker-Bp949u0W-CdL6sZaL.js} +1 -1
  90. package/build/assets/{toConsumableArray-BtKF-zGi-DY9ZxPdB.js → toConsumableArray-8hd4ivs--CUX5d2F_.js} +1 -1
  91. package/build/assets/{useBasicWidgetState-BMBMOmTg-D4BUrDbU.js → useBasicWidgetState-D3zHnRUK-J72gaU7U.js} +1 -1
  92. package/build/assets/{useIntlLocale-DqYWg-Yk-vlpPga3p.js → useIntlLocale-DdLGxiZO-DJttkOFe.js} +1 -1
  93. package/build/assets/{useSelectCommon-CTMZGTGc-Ce0_Hd3P.js → useSelectCommon-CZP9dNty-DYUDYQZN.js} +1 -1
  94. package/build/assets/{useTextInputAutoExpand-CnKMosrs-B4eb5Sf7.js → useTextInputAutoExpand-D9pA1iXq-B_21ViwV.js} +1 -1
  95. package/build/assets/{useUpdateUiValue-B9f-9GF1-ClPAYOW9.js → useUpdateUiValue-CsBMIrnj-BopSFNwe.js} +1 -1
  96. package/build/assets/{useWaveformController-vz6xEIpB-By40P5gh.js → useWaveformController-rxqEhP00-CEw8q0Aj.js} +1 -1
  97. package/build/assets/{utils-C0gaaqVX-vUUpSioz.js → utils-CotIDfd1-2L45u02v.js} +1 -1
  98. package/build/assets/{withCalculatedWidth-B-DDl_d6-BCYIlY-Q.js → withCalculatedWidth-DwrWHMUR-B2yMBY1O.js} +1 -1
  99. package/build/assets/{withFullScreenWrapper-CuXVCIWH-BixTXCsJ.js → withFullScreenWrapper-tGGSjEWy-BaPaU-BF.js} +1 -1
  100. package/build/assets/worker-BOAT2Vs2-B55LI3Y4.js +1020 -0
  101. package/build/electron/worker.js +9 -9
  102. package/build/index.html +1 -1
  103. package/package.json +3 -3
  104. package/wheels/stlite_lib-0.1.0-py3-none-any.whl +0 -0
  105. package/wheels/streamlit-1.57.0-cp313-none-any.whl +0 -0
  106. package/build/assets/worker-au3nYZmM-CULfdmAh.js +0 -930
@@ -1,930 +0,0 @@
1
- function ne(r) {
2
- return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
3
- }
4
- var I, x;
5
- function ae() {
6
- if (x) return I;
7
- x = 1;
8
- function r(i) {
9
- if (typeof i != "string")
10
- throw new TypeError("Path must be a string. Received " + JSON.stringify(i));
11
- }
12
- function o(i, e) {
13
- for (var t = "", a = 0, s = -1, g = 0, n, l = 0; l <= i.length; ++l) {
14
- if (l < i.length)
15
- n = i.charCodeAt(l);
16
- else {
17
- if (n === 47)
18
- break;
19
- n = 47;
20
- }
21
- if (n === 47) {
22
- if (!(s === l - 1 || g === 1)) if (s !== l - 1 && g === 2) {
23
- if (t.length < 2 || a !== 2 || t.charCodeAt(t.length - 1) !== 46 || t.charCodeAt(t.length - 2) !== 46) {
24
- if (t.length > 2) {
25
- var m = t.lastIndexOf("/");
26
- if (m !== t.length - 1) {
27
- m === -1 ? (t = "", a = 0) : (t = t.slice(0, m), a = t.length - 1 - t.lastIndexOf("/")), s = l, g = 0;
28
- continue;
29
- }
30
- } else if (t.length === 2 || t.length === 1) {
31
- t = "", a = 0, s = l, g = 0;
32
- continue;
33
- }
34
- }
35
- e && (t.length > 0 ? t += "/.." : t = "..", a = 2);
36
- } else
37
- t.length > 0 ? t += "/" + i.slice(s + 1, l) : t = i.slice(s + 1, l), a = l - s - 1;
38
- s = l, g = 0;
39
- } else n === 46 && g !== -1 ? ++g : g = -1;
40
- }
41
- return t;
42
- }
43
- function c(i, e) {
44
- var t = e.dir || e.root, a = e.base || (e.name || "") + (e.ext || "");
45
- return t ? t === e.root ? t + a : t + i + a : a;
46
- }
47
- var d = {
48
- // path.resolve([from ...], to)
49
- resolve: function() {
50
- for (var e = "", t = !1, a, s = arguments.length - 1; s >= -1 && !t; s--) {
51
- var g;
52
- s >= 0 ? g = arguments[s] : (a === void 0 && (a = process.cwd()), g = a), r(g), g.length !== 0 && (e = g + "/" + e, t = g.charCodeAt(0) === 47);
53
- }
54
- return e = o(e, !t), t ? e.length > 0 ? "/" + e : "/" : e.length > 0 ? e : ".";
55
- },
56
- normalize: function(e) {
57
- if (r(e), e.length === 0) return ".";
58
- var t = e.charCodeAt(0) === 47, a = e.charCodeAt(e.length - 1) === 47;
59
- return e = o(e, !t), e.length === 0 && !t && (e = "."), e.length > 0 && a && (e += "/"), t ? "/" + e : e;
60
- },
61
- isAbsolute: function(e) {
62
- return r(e), e.length > 0 && e.charCodeAt(0) === 47;
63
- },
64
- join: function() {
65
- if (arguments.length === 0)
66
- return ".";
67
- for (var e, t = 0; t < arguments.length; ++t) {
68
- var a = arguments[t];
69
- r(a), a.length > 0 && (e === void 0 ? e = a : e += "/" + a);
70
- }
71
- return e === void 0 ? "." : d.normalize(e);
72
- },
73
- relative: function(e, t) {
74
- if (r(e), r(t), e === t || (e = d.resolve(e), t = d.resolve(t), e === t)) return "";
75
- for (var a = 1; a < e.length && e.charCodeAt(a) === 47; ++a)
76
- ;
77
- for (var s = e.length, g = s - a, n = 1; n < t.length && t.charCodeAt(n) === 47; ++n)
78
- ;
79
- for (var l = t.length, m = l - n, y = g < m ? g : m, w = -1, b = 0; b <= y; ++b) {
80
- if (b === y) {
81
- if (m > y) {
82
- if (t.charCodeAt(n + b) === 47)
83
- return t.slice(n + b + 1);
84
- if (b === 0)
85
- return t.slice(n + b);
86
- } else g > y && (e.charCodeAt(a + b) === 47 ? w = b : b === 0 && (w = 0));
87
- break;
88
- }
89
- var A = e.charCodeAt(a + b), P = t.charCodeAt(n + b);
90
- if (A !== P)
91
- break;
92
- A === 47 && (w = b);
93
- }
94
- var R = "";
95
- for (b = a + w + 1; b <= s; ++b)
96
- (b === s || e.charCodeAt(b) === 47) && (R.length === 0 ? R += ".." : R += "/..");
97
- return R.length > 0 ? R + t.slice(n + w) : (n += w, t.charCodeAt(n) === 47 && ++n, t.slice(n));
98
- },
99
- _makeLong: function(e) {
100
- return e;
101
- },
102
- dirname: function(e) {
103
- if (r(e), e.length === 0) return ".";
104
- for (var t = e.charCodeAt(0), a = t === 47, s = -1, g = !0, n = e.length - 1; n >= 1; --n)
105
- if (t = e.charCodeAt(n), t === 47) {
106
- if (!g) {
107
- s = n;
108
- break;
109
- }
110
- } else
111
- g = !1;
112
- return s === -1 ? a ? "/" : "." : a && s === 1 ? "//" : e.slice(0, s);
113
- },
114
- basename: function(e, t) {
115
- if (t !== void 0 && typeof t != "string") throw new TypeError('"ext" argument must be a string');
116
- r(e);
117
- var a = 0, s = -1, g = !0, n;
118
- if (t !== void 0 && t.length > 0 && t.length <= e.length) {
119
- if (t.length === e.length && t === e) return "";
120
- var l = t.length - 1, m = -1;
121
- for (n = e.length - 1; n >= 0; --n) {
122
- var y = e.charCodeAt(n);
123
- if (y === 47) {
124
- if (!g) {
125
- a = n + 1;
126
- break;
127
- }
128
- } else
129
- m === -1 && (g = !1, m = n + 1), l >= 0 && (y === t.charCodeAt(l) ? --l === -1 && (s = n) : (l = -1, s = m));
130
- }
131
- return a === s ? s = m : s === -1 && (s = e.length), e.slice(a, s);
132
- } else {
133
- for (n = e.length - 1; n >= 0; --n)
134
- if (e.charCodeAt(n) === 47) {
135
- if (!g) {
136
- a = n + 1;
137
- break;
138
- }
139
- } else s === -1 && (g = !1, s = n + 1);
140
- return s === -1 ? "" : e.slice(a, s);
141
- }
142
- },
143
- extname: function(e) {
144
- r(e);
145
- for (var t = -1, a = 0, s = -1, g = !0, n = 0, l = e.length - 1; l >= 0; --l) {
146
- var m = e.charCodeAt(l);
147
- if (m === 47) {
148
- if (!g) {
149
- a = l + 1;
150
- break;
151
- }
152
- continue;
153
- }
154
- s === -1 && (g = !1, s = l + 1), m === 46 ? t === -1 ? t = l : n !== 1 && (n = 1) : t !== -1 && (n = -1);
155
- }
156
- return t === -1 || s === -1 || // We saw a non-dot character immediately before the dot
157
- n === 0 || // The (right-most) trimmed path component is exactly '..'
158
- n === 1 && t === s - 1 && t === a + 1 ? "" : e.slice(t, s);
159
- },
160
- format: function(e) {
161
- if (e === null || typeof e != "object")
162
- throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof e);
163
- return c("/", e);
164
- },
165
- parse: function(e) {
166
- r(e);
167
- var t = { root: "", dir: "", base: "", ext: "", name: "" };
168
- if (e.length === 0) return t;
169
- var a = e.charCodeAt(0), s = a === 47, g;
170
- s ? (t.root = "/", g = 1) : g = 0;
171
- for (var n = -1, l = 0, m = -1, y = !0, w = e.length - 1, b = 0; w >= g; --w) {
172
- if (a = e.charCodeAt(w), a === 47) {
173
- if (!y) {
174
- l = w + 1;
175
- break;
176
- }
177
- continue;
178
- }
179
- m === -1 && (y = !1, m = w + 1), a === 46 ? n === -1 ? n = w : b !== 1 && (b = 1) : n !== -1 && (b = -1);
180
- }
181
- return n === -1 || m === -1 || // We saw a non-dot character immediately before the dot
182
- b === 0 || // The (right-most) trimmed path component is exactly '..'
183
- b === 1 && n === m - 1 && n === l + 1 ? m !== -1 && (l === 0 && s ? t.base = t.name = e.slice(1, m) : t.base = t.name = e.slice(l, m)) : (l === 0 && s ? (t.name = e.slice(1, n), t.base = e.slice(1, m)) : (t.name = e.slice(l, n), t.base = e.slice(l, m)), t.ext = e.slice(n, m)), l > 0 ? t.dir = e.slice(0, l - 1) : s && (t.dir = "/"), t;
184
- },
185
- sep: "/",
186
- delimiter: ":",
187
- win32: null,
188
- posix: null
189
- };
190
- return d.posix = d, I = d, I;
191
- }
192
- var ie = ae(), F = /* @__PURE__ */ ne(ie);
193
- const $ = "/home/pyodide", B = (r) => `${$}/${r}`, E = (r, o) => r == null ? F.resolve($, o) : F.resolve(B(r), o);
194
- function N(r, o) {
195
- const c = F.normalize(o), i = F.dirname(c).split(/(?=\/)/);
196
- let e = "";
197
- for (const t of i) {
198
- e += t;
199
- const a = r.FS.analyzePath(e);
200
- if (a.exists && a.object) {
201
- if (!r.FS.isDir(a.object.mode))
202
- throw new Error(`"${e}" already exists and is not a directory.`);
203
- continue;
204
- }
205
- try {
206
- r.FS.mkdir(e);
207
- } catch (s) {
208
- throw console.error(`Failed to create a directory "${e}"`), s;
209
- }
210
- }
211
- }
212
- function z(r, o, c, d) {
213
- N(r, o), r.FS.writeFile(o, c, d);
214
- }
215
- function le(r, o, c) {
216
- N(r, c), r.FS.rename(o, c);
217
- }
218
- const ce = "[", de = "(<=>!~", ue = ";", pe = "@", fe = new RegExp(`[${ce + de + ue + pe}]`);
219
- function ge(r) {
220
- return r.split(fe)[0].trim();
221
- }
222
- function q(r) {
223
- return r.forEach((c) => {
224
- let d;
225
- try {
226
- d = new URL(c);
227
- } catch {
228
- return;
229
- }
230
- if (d.protocol === "emfs:" || d.protocol === "file:")
231
- throw new Error(`"emfs:" and "file:" protocols are not allowed for the requirement (${c})`);
232
- }), r.filter((c) => ge(c) === "streamlit" ? (console.warn(`Streamlit is specified in the requirements ("${c}"), but it will be ignored. A built-in version of Streamlit will be used.`), !1) : !0);
233
- }
234
- async function me(r) {
235
- const o = typeof process < "u" && process.versions?.node;
236
- let c;
237
- o ? c = (await import(
238
- /* webpackIgnore: true */
239
- "./__vite-browser-external-CPvbk0mb.js"
240
- )).sep : c = "/";
241
- const d = r.slice(0, r.lastIndexOf(c) + 1);
242
- if (r.endsWith(".mjs")) {
243
- if (o) {
244
- const i = await import(
245
- /* webpackIgnore: true */
246
- "./__vite-browser-external-CPvbk0mb.js"
247
- ), e = await import(
248
- /* webpackIgnore: true */
249
- "./__vite-browser-external-CPvbk0mb.js"
250
- );
251
- !r.includes("://") && i.isAbsolute(r) && (r = e.pathToFileURL(r).href);
252
- }
253
- return {
254
- scriptURL: r,
255
- pyodideIndexURL: d,
256
- isESModule: !0
257
- };
258
- } else
259
- return {
260
- scriptURL: r,
261
- pyodideIndexURL: d,
262
- isESModule: !1
263
- };
264
- }
265
- async function he(r, o) {
266
- const { scriptURL: c, pyodideIndexURL: d, isESModule: i } = await me(r);
267
- let e;
268
- return i ? e = (await import(
269
- /* webpackIgnore: true */
270
- /* @vite-ignore */
271
- c
272
- )).loadPyodide : (importScripts(c), e = self.loadPyodide), e({ ...o, indexURL: d });
273
- }
274
- function ye(r) {
275
- r.runPython(`
276
- import micropip
277
- micropip.add_mock_package(
278
- "pyarrow", "0.0.1",
279
- modules={
280
- "pyarrow": """
281
- __version__ = '0.0.1' # TODO: Update when releasing
282
-
283
-
284
- class Table:
285
- @classmethod
286
- def from_pandas(*args, **kwargs):
287
- raise NotImplementedError("stlite is not supporting this method.")
288
-
289
-
290
- class Array:
291
- def __init__(self, *args, **kwargs):
292
- raise NotImplementedError("stlite is not supporting PyArrow.Array")
293
-
294
-
295
- class ChunkedArray:
296
- def __init__(self, *args, **kwargs):
297
- raise NotImplementedError("stlite is not supporting PyArrow.ChunkedArray")
298
- """
299
- }
300
- )
301
- `);
302
- }
303
- function be(r, o, c) {
304
- const d = r.pyimport("pyodide"), i = (n) => d.code.find_imports(n).toJs(), e = c.map((n) => i(n)), s = Array.from(new Set(e.flat())).filter((n) => !r.runPython(`__import__('importlib').util.find_spec('${n}')`)).map((n) => r._api._import_name_to_package_name.get(n)).filter((n) => n);
305
- if (s.length === 0)
306
- return Promise.resolve();
307
- const g = r.loadPackage(s);
308
- return o(s, g), g.then();
309
- }
310
- function J(r, o, c) {
311
- const d = be(r, o, c);
312
- r.runPython(`
313
- def __set_module_auto_load_promise__(promise):
314
- from streamlit.runtime.scriptrunner import script_runner
315
- script_runner.moduleAutoLoadPromise = promise
316
-
317
- __set_module_auto_load_promise__`)(d);
318
- }
319
- async function _e(r, o, c) {
320
- const { line: d, column: i } = c, e = r.Script(o);
321
- if (d > e._code_lines.length)
322
- return [];
323
- const t = e.complete.callKwargs({
324
- line: d,
325
- column: i,
326
- fuzzy: !1
327
- }), a = [];
328
- for (const s of t.toJs())
329
- a.push({
330
- name: s.name,
331
- type: s.$type,
332
- // PyProxy.type is overridden in Pyodide. We need to access it this way. Ref: https://github.com/pyodide/pyodide/issues/4032
333
- docstring: s.docstring.callKwargs({ raw: !0 }),
334
- complete: s.complete
335
- }), s.destroy();
336
- return a;
337
- }
338
- const G = { version: "3.0", spec_version: "2.3" }, K = "1.1";
339
- class we {
340
- items = [];
341
- waiters = [];
342
- enqueue(o) {
343
- const c = this.waiters.shift();
344
- c ? c(o) : this.items.push(o);
345
- }
346
- dequeue() {
347
- const o = this.items.shift();
348
- return o !== void 0 ? Promise.resolve(o) : new Promise((c) => {
349
- this.waiters.push(c);
350
- });
351
- }
352
- }
353
- function ve(r) {
354
- const o = new URL(r.path, "http://stlite.local"), c = Object.entries(r.headers).map(([d, i]) => [
355
- new TextEncoder().encode(d.toLowerCase()),
356
- new TextEncoder().encode(i)
357
- ]);
358
- return {
359
- type: "http",
360
- asgi: G,
361
- http_version: K,
362
- method: r.method.toUpperCase(),
363
- scheme: "http",
364
- path: o.pathname,
365
- raw_path: new TextEncoder().encode(o.pathname),
366
- query_string: new TextEncoder().encode(o.search.replace(/^\?/, "")),
367
- root_path: "",
368
- headers: c,
369
- client: ["stlite", 0],
370
- server: ["stlite", 80]
371
- };
372
- }
373
- function ke(r) {
374
- return typeof r == "string" ? new TextEncoder().encode(r) : new Uint8Array(r);
375
- }
376
- function Q(r) {
377
- return r && typeof r.toJs == "function" ? r.toJs({ dict_converter: Object.fromEntries }) : r;
378
- }
379
- async function Se(r, o) {
380
- const c = ve(o), d = ke(o.body);
381
- let i = !1;
382
- const e = async () => i ? { type: "http.disconnect" } : (i = !0, {
383
- type: "http.request",
384
- body: d,
385
- more_body: !1
386
- });
387
- let t = 0;
388
- const a = new Headers(), s = [];
389
- await r(c, e, async (y) => {
390
- const w = Q(y);
391
- if (w.type === "http.response.start") {
392
- t = w.status ?? 0;
393
- const b = w.headers ?? [];
394
- for (const [A, P] of b)
395
- a.append(D(A), D(P));
396
- } else if (w.type === "http.response.body") {
397
- const b = w.body;
398
- b && b.byteLength > 0 && s.push(b);
399
- }
400
- });
401
- const n = s.reduce((y, w) => y + w.byteLength, 0), l = new Uint8Array(n);
402
- let m = 0;
403
- for (const y of s)
404
- l.set(y, m), m += y.byteLength;
405
- return { statusCode: t, headers: a, body: l };
406
- }
407
- function Pe(r) {
408
- const o = new URL(r.path, "ws://stlite.local"), c = Object.entries(r.headers ?? {}).map(([d, i]) => [
409
- new TextEncoder().encode(d.toLowerCase()),
410
- new TextEncoder().encode(i)
411
- ]);
412
- return {
413
- type: "websocket",
414
- asgi: G,
415
- http_version: K,
416
- scheme: "ws",
417
- path: o.pathname,
418
- raw_path: new TextEncoder().encode(o.pathname),
419
- query_string: new TextEncoder().encode(o.search.replace(/^\?/, "")),
420
- root_path: "",
421
- headers: c,
422
- client: ["stlite", 0],
423
- server: ["stlite", 80],
424
- subprotocols: r.subprotocols ?? []
425
- };
426
- }
427
- class Ae {
428
- asgiApp;
429
- scope;
430
- onServerSend;
431
- receiveQueue = new we();
432
- acceptedResolve;
433
- acceptedReject;
434
- acceptedPromise;
435
- appTask = null;
436
- closed = !1;
437
- constructor(o, c, d) {
438
- this.asgiApp = o, this.scope = c, this.onServerSend = d, this.acceptedPromise = new Promise((i, e) => {
439
- this.acceptedResolve = i, this.acceptedReject = e;
440
- });
441
- }
442
- start() {
443
- this.receiveQueue.enqueue({ type: "websocket.connect" });
444
- const o = () => this.receiveQueue.dequeue(), c = async (i) => {
445
- const e = Q(i);
446
- if (e.type === "websocket.accept") {
447
- this.acceptedResolve(e.subprotocol ?? null);
448
- return;
449
- }
450
- e.type === "websocket.close" && !this.closed && this.acceptedReject(new Error(`WebSocket closed before accept (code=${e.code ?? "?"})`)), this.onServerSend(e);
451
- }, d = this.asgiApp(this.scope, o, c);
452
- return this.appTask = Promise.resolve(d), this.appTask.catch((i) => {
453
- this.acceptedReject(i);
454
- }), this.acceptedPromise;
455
- }
456
- postClientMessage(o) {
457
- if (this.closed)
458
- return;
459
- const c = typeof o == "string" ? { type: "websocket.receive", text: o } : { type: "websocket.receive", bytes: o };
460
- this.receiveQueue.enqueue(c);
461
- }
462
- async close(o = 1e3) {
463
- if (!this.closed && (this.closed = !0, this.receiveQueue.enqueue({ type: "websocket.disconnect", code: o }), this.appTask))
464
- try {
465
- await this.appTask;
466
- } catch {
467
- }
468
- }
469
- }
470
- function D(r) {
471
- return new TextDecoder("utf-8").decode(r);
472
- }
473
- let M = null, j = Promise.resolve(), O = !1;
474
- async function Re(r, o, c, d, i) {
475
- const { files: e, archives: t, requirements: a, prebuiltPackageNames: s, wheels: g, installs: n, pyodideUrl: l = r, streamlitConfig: m, idbfsMountpoints: y, nodefsMountpoints: w, moduleAutoLoad: b, env: A, languageServer: P } = c, R = q(a);
476
- M ? (i("Pyodide is already loaded."), console.debug("Pyodide is already loaded.")) : (i("Loading Pyodide."), console.debug("Loading Pyodide."), M = he(l, {
477
- stdout: console.log,
478
- stderr: console.error
479
- }), console.debug("Loaded Pyodide"));
480
- const h = (
481
- // XXX: `{ FS: any }` is a temporary workaround to fix the type error.
482
- await M
483
- );
484
- if (A) {
485
- console.debug("Setting environment variables", A);
486
- const f = h.pyimport("os");
487
- f.environ.update(h.toPy(A)), console.debug("Set environment variables", f.environ);
488
- }
489
- let L = !1;
490
- y && (L = !0, y.forEach((f) => {
491
- h.FS.mkdir(f), h.FS.mount(h.FS.filesystems.IDBFS, {}, f);
492
- }), await new Promise((f, v) => {
493
- h.FS.syncfs(!0, (S) => {
494
- S ? v(S) : f();
495
- });
496
- })), w && Object.entries(w).forEach(([f, v]) => {
497
- h.FS.mkdir(f), h.FS.mount(h.FS.filesystems.NODEFS, { root: v }, f);
498
- }), i("Mounting files.");
499
- const p = [];
500
- await Promise.all(Object.keys(e).map(async (f) => {
501
- const v = e[f];
502
- f = E(o, f);
503
- let S;
504
- "url" in v ? (console.debug(`Fetch a file from ${v.url}`), S = await fetch(v.url).then((C) => C.arrayBuffer()).then((C) => new Uint8Array(C))) : S = v.data, console.debug(`Write a file "${f}"`), z(h, f, S, e.opts), f.endsWith(".py") && p.push(f);
505
- })), i("Unpacking archives."), await Promise.all(t.map(async (f) => {
506
- let v;
507
- "url" in f ? (console.debug(`Fetch an archive from ${f.url}`), v = await fetch(f.url).then((se) => se.arrayBuffer())) : v = f.buffer;
508
- const { format: S, options: C } = f;
509
- console.debug("Unpack an archive", { format: S, options: C }), h.unpackArchive(v, S, C);
510
- })), await h.loadPackage("micropip");
511
- const u = h.pyimport("micropip");
512
- i("Mocking some packages."), console.debug("Mock pyarrow"), ye(h), console.debug("Mocked pyarrow"), i("Installing packages."), console.debug("Installing the prebuilt packages:", s), await h.loadPackage(s), console.debug("Installed the prebuilt packages");
513
- const _ = async () => {
514
- console.debug("Installing the packages:", {
515
- requirements: R,
516
- systemPackagesInstalled: O
517
- });
518
- const f = [];
519
- O || (console.debug("System packages will be installed"), g && (f.push("protobuf>=7.34.1,<8"), f.push(g.streamlit), f.push(g.stliteLib)), P && f.push("jedi"));
520
- const v = [...f, ...R];
521
- console.debug("Installing the packages:", v), await u.install.callKwargs(v, { keep_going: !0 }), f.length > 0 && (console.debug("Installed the system packages"), O = !0), console.debug("Installed the packages");
522
- }, k = j.then(() => _());
523
- if (j = k.catch((f) => {
524
- console.error("Package installation failed:", f);
525
- }), await k, n && (console.debug("Installing the additional requirements"), await Promise.all(n.map(({ requirements: f, options: v }) => {
526
- const S = q(f);
527
- return console.debug("Installing the requirements:", S), u.install.callKwargs(S, v ?? {});
528
- }))), b) {
529
- const f = p.map((v) => h.FS.readFile(v, { encoding: "utf8" }));
530
- J(h, d, f);
531
- }
532
- await h.runPythonAsync(`
533
- import importlib
534
- importlib.invalidate_caches()
535
- `), i("Loading streamlit package."), console.debug("Loading the Streamlit package"), await h.runPythonAsync(`
536
- import streamlit.runtime
537
- `), console.debug("Loaded the Streamlit package"), i("Setting up the loggers."), console.debug("Setting the loggers"), await h.runPythonAsync(`
538
- import logging
539
- import streamlit.logger
540
-
541
- streamlit.logger.get_logger = logging.getLogger
542
- streamlit.logger.setup_formatter = None
543
- streamlit.logger.update_formatter = lambda *a, **k: None
544
- streamlit.logger.set_log_level = lambda *a, **k: None
545
-
546
- for name in streamlit.logger._loggers.keys():
547
- if name == "root":
548
- name = "streamlit"
549
- logger = logging.getLogger(name)
550
- logger.propagate = True
551
- logger.handlers.clear()
552
- logger.setLevel(logging.NOTSET)
553
-
554
- streamlit.logger._loggers = {}
555
- `);
556
- const X = (f, v) => {
557
- f >= 40 ? console.error(v) : f >= 30 ? console.warn(v) : f >= 20 ? console.info(v) : console.debug(v);
558
- }, Y = h.runPython(`
559
- def __setup_loggers__(streamlit_level, streamlit_message_format, callback):
560
- class JsHandler(logging.Handler):
561
- def emit(self, record):
562
- msg = self.format(record)
563
- callback(record.levelno, msg)
564
-
565
-
566
- root_message_format = "%(levelname)s:%(name)s:%(message)s"
567
-
568
- root_logger = logging.getLogger()
569
- root_logger.handlers.clear()
570
- root_formatter = logging.Formatter(root_message_format)
571
- root_handler = JsHandler()
572
- root_handler.setFormatter(root_formatter)
573
- root_logger.addHandler(root_handler)
574
- root_logger.setLevel(logging.DEBUG)
575
-
576
- streamlit_logger = logging.getLogger("streamlit")
577
- streamlit_logger.propagate = False
578
- streamlit_logger.handlers.clear()
579
- streamlit_formatter = logging.Formatter(streamlit_message_format)
580
- streamlit_handler = JsHandler()
581
- streamlit_handler.setFormatter(streamlit_formatter)
582
- streamlit_logger.addHandler(streamlit_handler)
583
- streamlit_logger.setLevel(streamlit_level.upper())
584
-
585
- __setup_loggers__`), Z = (m?.["logger.level"] ?? "INFO").toString(), ee = m?.["logger.messageFormat"] ?? "%(asctime)s %(message)s";
586
- if (Y(Z, ee, X), console.debug("Set the loggers"), i("Mocking some Streamlit functions for the browser environment."), console.debug("Mocking some Streamlit functions"), await h.runPythonAsync(`
587
- import streamlit
588
-
589
- def is_cacheable_msg(msg):
590
- return False
591
-
592
- streamlit.runtime.runtime.is_cacheable_msg = is_cacheable_msg
593
- `), console.debug("Mocked some Streamlit functions"), L) {
594
- i("Setting up the IndexedDB filesystem synchronizer."), console.debug("Setting up the IndexedDB filesystem synchronizer");
595
- let f = !1;
596
- const v = () => {
597
- console.debug("The script has finished. Syncing the filesystem."), f || (f = !0, h.FS.syncfs(!1, (C) => {
598
- f = !1, C && console.error(C);
599
- }));
600
- };
601
- (await h.runPython(`
602
- def __setup_script_finished_callback__(callback):
603
- from streamlit.runtime.app_session import AppSession
604
- from streamlit.runtime.scriptrunner import ScriptRunnerEvent
605
-
606
- def wrap_app_session_on_scriptrunner_event(original_method):
607
- def wrapped(self, *args, **kwargs):
608
- if "event" in kwargs:
609
- event = kwargs["event"]
610
- if event == ScriptRunnerEvent.SCRIPT_STOPPED_WITH_SUCCESS or event == ScriptRunnerEvent.SCRIPT_STOPPED_FOR_RERUN or event == ScriptRunnerEvent.SHUTDOWN:
611
- callback()
612
- return original_method(self, *args, **kwargs)
613
- return wrapped
614
-
615
- AppSession._on_scriptrunner_event = wrap_app_session_on_scriptrunner_event(AppSession._on_scriptrunner_event)
616
-
617
- __setup_script_finished_callback__`))(v), console.debug("Set up the IndexedDB filesystem synchronizer");
618
- }
619
- console.debug("Setting up the Streamlit configuration");
620
- const { load_config_options: te } = h.pyimport("stlite_lib.bootstrap"), re = {
621
- // gatherUsageStats is disabled as default, but can be enabled explicitly by setting it to true.
622
- "browser.gatherUsageStats": !1,
623
- ...m,
624
- "runner.fastReruns": !1
625
- // Fast reruns do not work well with the async script runner of stlite. See https://github.com/whitphx/stlite/pull/550#issuecomment-1505485865.
626
- }, oe = o != null;
627
- te(h.toPy(re), oe), console.debug("Set up the Streamlit configuration");
628
- let T;
629
- if (P) {
630
- i("Loading auto-completion engine."), console.debug("Loading Jedi");
631
- try {
632
- T = await h.pyimport("jedi"), console.debug("Loaded Jedi");
633
- } catch (f) {
634
- console.error("Failed to load Jedi:", f), T = void 0;
635
- }
636
- }
637
- return {
638
- pyodide: h,
639
- micropip: u,
640
- jedi: T,
641
- initData: c
642
- };
643
- }
644
- async function H(r, o, c) {
645
- const d = E(o, c);
646
- console.debug("Preparing the Streamlit environment");
647
- const { prepare: i } = r.pyimport("stlite_lib.bootstrap");
648
- i(d, []), console.debug("Prepared the Streamlit environment"), console.debug("Booting up the Streamlit ASGI app");
649
- const e = r.pyimport("stlite_lib.asgi_app"), t = e.create_app(d), a = await e.run_lifespan_startup(t);
650
- e.bind_runtime_to_current_context(t);
651
- const s = e.make_call_asgi(t, o ? B(o) : void 0);
652
- return console.debug("Booted up the Streamlit ASGI app"), { asgiApp: s, lifespanState: a };
653
- }
654
- async function Ce(r, o) {
655
- const { run_lifespan_shutdown: c } = r.pyimport("stlite_lib.asgi_app");
656
- await c(o.lifespanState), o.lifespanState.destroy();
657
- }
658
- function U(r, o, c, d) {
659
- function i(n) {
660
- o({
661
- type: "event:loadProgress",
662
- data: {
663
- message: n
664
- }
665
- });
666
- }
667
- const e = (n, l) => {
668
- const m = new MessageChannel();
669
- o({
670
- type: "event:moduleAutoLoad",
671
- data: {
672
- packagesToLoad: n
673
- }
674
- }, [m.port2]), l.then((y) => {
675
- m.port1.postMessage({
676
- type: "moduleAutoLoad:success",
677
- data: {
678
- loadedPackages: y
679
- }
680
- }), m.port1.close();
681
- }).catch((y) => {
682
- throw m.port1.postMessage({
683
- type: "moduleAutoLoad:error",
684
- error: y
685
- }), m.port1.close(), y;
686
- });
687
- };
688
- let t = null, a = null, s = null;
689
- const g = async (n) => {
690
- const l = n.data;
691
- if (l.type === "initData") {
692
- const p = l.data, u = {
693
- ...c,
694
- ...p
695
- };
696
- console.debug("Initial data", u), t = Re(r, d, u, e, i), t.then(({ pyodide: _ }) => (i("Booting up the Streamlit server."), a = H(_, d, u.entrypoint), a)).then(() => {
697
- o({
698
- type: "event:loadFinished"
699
- });
700
- }).catch((_) => {
701
- console.error(_), o({
702
- type: "event:loadError",
703
- data: {
704
- error: _
705
- }
706
- });
707
- });
708
- return;
709
- }
710
- if (!t)
711
- throw new Error("Pyodide initialization has not been started yet.");
712
- if (!a)
713
- throw new Error("Streamlit ASGI app has not been started yet.");
714
- const m = await t, y = m.pyodide, w = m.micropip, b = m.jedi, { moduleAutoLoad: A } = m.initData;
715
- let P = await a;
716
- const R = n.ports[0];
717
- function h(p) {
718
- R.postMessage(p);
719
- }
720
- function L(p) {
721
- if (p.type !== "websocket.send")
722
- return;
723
- const u = p.bytes;
724
- if (u) {
725
- const k = u.buffer.slice(u.byteOffset, u.byteOffset + u.byteLength);
726
- o({ type: "websocket:message", data: { payload: k } }, [k]);
727
- return;
728
- }
729
- const _ = p.text;
730
- typeof _ == "string" && o({ type: "websocket:message", data: { payload: _ } });
731
- }
732
- try {
733
- switch (l.type) {
734
- case "reboot": {
735
- console.debug("Reboot the Streamlit server", l.data);
736
- const { entrypoint: p } = l.data;
737
- s && (await s.close(), s = null), await Ce(y, P), console.debug("Booting up the Streamlit ASGI app"), a = H(y, d, p), P = await a, console.debug("Booted up the Streamlit ASGI app"), h({
738
- type: "reply"
739
- });
740
- break;
741
- }
742
- case "websocket:connect": {
743
- console.debug("websocket:connect", l.data);
744
- const { path: p } = l.data;
745
- s && (await s.close(), s = null);
746
- const u = Pe({
747
- path: p,
748
- headers: {
749
- host: "stlite.local",
750
- origin: "http://stlite.local"
751
- }
752
- });
753
- s = new Ae(P.asgiApp, u, L), await s.start(), h({
754
- type: "reply"
755
- });
756
- break;
757
- }
758
- case "websocket:send": {
759
- console.debug("websocket:send", l.data);
760
- const { payload: p } = l.data;
761
- s && s.postClientMessage(p);
762
- break;
763
- }
764
- case "http:request": {
765
- console.debug("http:request", l.data);
766
- const { request: p } = l.data;
767
- Se(P.asgiApp, {
768
- ...p,
769
- path: decodeURIComponent(p.path)
770
- }).then((u) => {
771
- h({
772
- type: "http:response",
773
- data: {
774
- response: {
775
- statusCode: u.statusCode,
776
- headers: new Map(u.headers.entries()),
777
- body: u.body
778
- }
779
- }
780
- });
781
- }).catch((u) => {
782
- console.error("http:request dispatch failed", u), h({
783
- type: "http:response",
784
- data: {
785
- response: {
786
- statusCode: 500,
787
- headers: /* @__PURE__ */ new Map([
788
- ["content-type", "text/plain; charset=utf-8"]
789
- ]),
790
- body: new TextEncoder().encode(`Internal server error: ${String(u)}`)
791
- }
792
- }
793
- });
794
- });
795
- break;
796
- }
797
- case "file:write": {
798
- const { path: p, data: u, opts: _ } = l.data, k = E(d, p);
799
- A && typeof u == "string" && k.endsWith(".py") && (console.debug(`Auto install the requirements in ${k}`), J(y, e, [u])), console.debug(`Write a file "${k}"`), z(y, k, u, _), h({
800
- type: "reply"
801
- });
802
- break;
803
- }
804
- case "file:rename": {
805
- const { oldPath: p, newPath: u } = l.data, _ = E(d, p), k = E(d, u);
806
- console.debug(`Rename "${_}" to ${k}`), le(y, _, k), h({
807
- type: "reply"
808
- });
809
- break;
810
- }
811
- case "file:unlink": {
812
- const { path: p } = l.data, u = E(d, p);
813
- console.debug(`Remove "${u}`), y.FS.unlink(u), h({
814
- type: "reply"
815
- });
816
- break;
817
- }
818
- case "file:read": {
819
- const { path: p, opts: u } = l.data;
820
- console.debug(`Read "${p}"`);
821
- const _ = y.FS.readFile(p, u);
822
- h({
823
- type: "reply:file:read",
824
- data: {
825
- content: _
826
- }
827
- });
828
- break;
829
- }
830
- case "install": {
831
- const { requirements: p, options: u } = l.data, _ = q(p);
832
- console.debug("Install the requirements:", _), await w.install.callKwargs(_, u ?? {}).then(() => {
833
- console.debug("Successfully installed"), h({
834
- type: "reply"
835
- });
836
- });
837
- break;
838
- }
839
- case "setEnv": {
840
- const { env: p } = l.data;
841
- y.pyimport("os").environ.update(y.toPy(p)), console.debug("Successfully set the environment variables", p), h({
842
- type: "reply"
843
- });
844
- break;
845
- }
846
- case "code_completion": {
847
- if (!b)
848
- throw new Error("Jedi is not installed");
849
- const { code: p, line: u, column: _ } = l.data, k = await _e(b, p, {
850
- line: u,
851
- column: _
852
- });
853
- h({
854
- type: "reply:code_completion",
855
- data: {
856
- codeCompletions: k
857
- }
858
- });
859
- break;
860
- }
861
- case "run_python": {
862
- const { code: p } = l.data;
863
- console.debug("Run python code", p);
864
- const u = await y.runPythonAsync(p);
865
- let _;
866
- u instanceof y.ffi.PyProxy ? (console.debug("The result is a PyProxy object"), _ = u.toJs(), u.destroy(), console.debug("Converted the result to a JS object", _)) : (_ = u, console.debug("The result is a JS primitive", _)), h({
867
- type: "reply:run_python",
868
- data: {
869
- result: _
870
- }
871
- });
872
- break;
873
- }
874
- case "add_mock_package": {
875
- const { name: p, version: u, modules: _, persistent: k } = l.data;
876
- console.debug("Add a mock package:", {
877
- name: p,
878
- version: u,
879
- modules: _,
880
- persistent: k
881
- }), w.add_mock_package.callKwargs({
882
- name: p,
883
- version: u,
884
- modules: y.toPy(_),
885
- persistent: k
886
- }), h({
887
- type: "reply"
888
- });
889
- break;
890
- }
891
- }
892
- } catch (p) {
893
- if (console.error(p), !(p instanceof Error))
894
- throw p;
895
- const u = new Error(p.message);
896
- u.name = p.name, u.stack = p.stack, h({
897
- type: "reply",
898
- error: u
899
- });
900
- }
901
- };
902
- return o({
903
- type: "event:envSetup"
904
- }), g;
905
- }
906
- const V = "abcdefghijklmnopqrstuvwxyz", Ee = V.length;
907
- function Le(r) {
908
- let o = "";
909
- for (let c = 0; c < r; c++) {
910
- const d = Math.floor(Math.random() * Ee);
911
- o += V[d];
912
- }
913
- return o;
914
- }
915
- const W = "https://cdn.jsdelivr.net/pyodide/v0.29.3/full/pyodide.mjs";
916
- if ("postMessage" in self)
917
- self.onmessage = U(W, (r, o) => o ? self.postMessage(r, o) : self.postMessage(r));
918
- else {
919
- const r = [];
920
- self.onconnect = (o) => {
921
- let c;
922
- do
923
- c = Le(4);
924
- while (r.includes(c));
925
- r.push(c), console.debug("SharedWorker mode.", { appId: c });
926
- const d = o.ports[0];
927
- d.onmessage = U(W, (i, e) => e ? d.postMessage(i, e) : d.postMessage(i), void 0, c), d.start();
928
- };
929
- }
930
- //# sourceMappingURL=worker-au3nYZmM.js.map