llms-py 3.0.0b6__py3-none-any.whl → 3.0.0b8__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 (181) hide show
  1. llms/__pycache__/main.cpython-314.pyc +0 -0
  2. llms/{ui/modules/analytics.mjs → extensions/analytics/ui/index.mjs} +55 -164
  3. llms/extensions/app/__init__.py +519 -0
  4. llms/extensions/app/__pycache__/__init__.cpython-314.pyc +0 -0
  5. llms/extensions/app/__pycache__/db.cpython-314.pyc +0 -0
  6. llms/extensions/app/__pycache__/db_manager.cpython-314.pyc +0 -0
  7. llms/extensions/app/db.py +641 -0
  8. llms/extensions/app/db_manager.py +195 -0
  9. llms/extensions/app/requests.json +9073 -0
  10. llms/extensions/app/threads.json +15290 -0
  11. llms/{ui/modules/threads → extensions/app/ui}/Recents.mjs +82 -55
  12. llms/{ui/modules/threads → extensions/app/ui}/index.mjs +83 -20
  13. llms/extensions/app/ui/threadStore.mjs +407 -0
  14. llms/extensions/core_tools/__init__.py +598 -0
  15. llms/extensions/core_tools/__pycache__/__init__.cpython-314.pyc +0 -0
  16. llms/extensions/core_tools/ui/codemirror/addon/edit/closebrackets.js +201 -0
  17. llms/extensions/core_tools/ui/codemirror/addon/edit/closetag.js +185 -0
  18. llms/extensions/core_tools/ui/codemirror/addon/edit/continuelist.js +101 -0
  19. llms/extensions/core_tools/ui/codemirror/addon/edit/matchbrackets.js +160 -0
  20. llms/extensions/core_tools/ui/codemirror/addon/edit/matchtags.js +66 -0
  21. llms/extensions/core_tools/ui/codemirror/addon/edit/trailingspace.js +27 -0
  22. llms/extensions/core_tools/ui/codemirror/addon/selection/active-line.js +72 -0
  23. llms/extensions/core_tools/ui/codemirror/addon/selection/mark-selection.js +119 -0
  24. llms/extensions/core_tools/ui/codemirror/addon/selection/selection-pointer.js +98 -0
  25. llms/extensions/core_tools/ui/codemirror/doc/docs.css +225 -0
  26. llms/extensions/core_tools/ui/codemirror/doc/source_sans.woff +0 -0
  27. llms/extensions/core_tools/ui/codemirror/lib/codemirror.css +344 -0
  28. llms/extensions/core_tools/ui/codemirror/lib/codemirror.js +9884 -0
  29. llms/extensions/core_tools/ui/codemirror/mode/clike/clike.js +942 -0
  30. llms/extensions/core_tools/ui/codemirror/mode/javascript/index.html +118 -0
  31. llms/extensions/core_tools/ui/codemirror/mode/javascript/javascript.js +962 -0
  32. llms/extensions/core_tools/ui/codemirror/mode/javascript/typescript.html +62 -0
  33. llms/extensions/core_tools/ui/codemirror/mode/python/python.js +402 -0
  34. llms/extensions/core_tools/ui/codemirror/theme/dracula.css +40 -0
  35. llms/extensions/core_tools/ui/codemirror/theme/mocha.css +135 -0
  36. llms/extensions/core_tools/ui/index.mjs +650 -0
  37. llms/extensions/gallery/__init__.py +61 -0
  38. llms/extensions/gallery/__pycache__/__init__.cpython-314.pyc +0 -0
  39. llms/extensions/gallery/__pycache__/db.cpython-314.pyc +0 -0
  40. llms/extensions/gallery/db.py +298 -0
  41. llms/extensions/gallery/ui/index.mjs +481 -0
  42. llms/extensions/katex/__init__.py +6 -0
  43. llms/extensions/katex/__pycache__/__init__.cpython-314.pyc +0 -0
  44. llms/extensions/katex/ui/README.md +125 -0
  45. llms/extensions/katex/ui/contrib/auto-render.js +338 -0
  46. llms/extensions/katex/ui/contrib/auto-render.min.js +1 -0
  47. llms/extensions/katex/ui/contrib/auto-render.mjs +244 -0
  48. llms/extensions/katex/ui/contrib/copy-tex.js +127 -0
  49. llms/extensions/katex/ui/contrib/copy-tex.min.js +1 -0
  50. llms/extensions/katex/ui/contrib/copy-tex.mjs +105 -0
  51. llms/extensions/katex/ui/contrib/mathtex-script-type.js +109 -0
  52. llms/extensions/katex/ui/contrib/mathtex-script-type.min.js +1 -0
  53. llms/extensions/katex/ui/contrib/mathtex-script-type.mjs +24 -0
  54. llms/extensions/katex/ui/contrib/mhchem.js +3213 -0
  55. llms/extensions/katex/ui/contrib/mhchem.min.js +1 -0
  56. llms/extensions/katex/ui/contrib/mhchem.mjs +3109 -0
  57. llms/extensions/katex/ui/contrib/render-a11y-string.js +887 -0
  58. llms/extensions/katex/ui/contrib/render-a11y-string.min.js +1 -0
  59. llms/extensions/katex/ui/contrib/render-a11y-string.mjs +800 -0
  60. llms/extensions/katex/ui/fonts/KaTeX_AMS-Regular.ttf +0 -0
  61. llms/extensions/katex/ui/fonts/KaTeX_AMS-Regular.woff +0 -0
  62. llms/extensions/katex/ui/fonts/KaTeX_AMS-Regular.woff2 +0 -0
  63. llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
  64. llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
  65. llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
  66. llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
  67. llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
  68. llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  69. llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
  70. llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Bold.woff +0 -0
  71. llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  72. llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
  73. llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Regular.woff +0 -0
  74. llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  75. llms/extensions/katex/ui/fonts/KaTeX_Main-Bold.ttf +0 -0
  76. llms/extensions/katex/ui/fonts/KaTeX_Main-Bold.woff +0 -0
  77. llms/extensions/katex/ui/fonts/KaTeX_Main-Bold.woff2 +0 -0
  78. llms/extensions/katex/ui/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
  79. llms/extensions/katex/ui/fonts/KaTeX_Main-BoldItalic.woff +0 -0
  80. llms/extensions/katex/ui/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
  81. llms/extensions/katex/ui/fonts/KaTeX_Main-Italic.ttf +0 -0
  82. llms/extensions/katex/ui/fonts/KaTeX_Main-Italic.woff +0 -0
  83. llms/extensions/katex/ui/fonts/KaTeX_Main-Italic.woff2 +0 -0
  84. llms/extensions/katex/ui/fonts/KaTeX_Main-Regular.ttf +0 -0
  85. llms/extensions/katex/ui/fonts/KaTeX_Main-Regular.woff +0 -0
  86. llms/extensions/katex/ui/fonts/KaTeX_Main-Regular.woff2 +0 -0
  87. llms/extensions/katex/ui/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
  88. llms/extensions/katex/ui/fonts/KaTeX_Math-BoldItalic.woff +0 -0
  89. llms/extensions/katex/ui/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  90. llms/extensions/katex/ui/fonts/KaTeX_Math-Italic.ttf +0 -0
  91. llms/extensions/katex/ui/fonts/KaTeX_Math-Italic.woff +0 -0
  92. llms/extensions/katex/ui/fonts/KaTeX_Math-Italic.woff2 +0 -0
  93. llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
  94. llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Bold.woff +0 -0
  95. llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  96. llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
  97. llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Italic.woff +0 -0
  98. llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  99. llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
  100. llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Regular.woff +0 -0
  101. llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  102. llms/extensions/katex/ui/fonts/KaTeX_Script-Regular.ttf +0 -0
  103. llms/extensions/katex/ui/fonts/KaTeX_Script-Regular.woff +0 -0
  104. llms/extensions/katex/ui/fonts/KaTeX_Script-Regular.woff2 +0 -0
  105. llms/extensions/katex/ui/fonts/KaTeX_Size1-Regular.ttf +0 -0
  106. llms/extensions/katex/ui/fonts/KaTeX_Size1-Regular.woff +0 -0
  107. llms/extensions/katex/ui/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  108. llms/extensions/katex/ui/fonts/KaTeX_Size2-Regular.ttf +0 -0
  109. llms/extensions/katex/ui/fonts/KaTeX_Size2-Regular.woff +0 -0
  110. llms/extensions/katex/ui/fonts/KaTeX_Size2-Regular.woff2 +0 -0
  111. llms/extensions/katex/ui/fonts/KaTeX_Size3-Regular.ttf +0 -0
  112. llms/extensions/katex/ui/fonts/KaTeX_Size3-Regular.woff +0 -0
  113. llms/extensions/katex/ui/fonts/KaTeX_Size3-Regular.woff2 +0 -0
  114. llms/extensions/katex/ui/fonts/KaTeX_Size4-Regular.ttf +0 -0
  115. llms/extensions/katex/ui/fonts/KaTeX_Size4-Regular.woff +0 -0
  116. llms/extensions/katex/ui/fonts/KaTeX_Size4-Regular.woff2 +0 -0
  117. llms/extensions/katex/ui/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
  118. llms/extensions/katex/ui/fonts/KaTeX_Typewriter-Regular.woff +0 -0
  119. llms/extensions/katex/ui/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  120. llms/extensions/katex/ui/index.mjs +92 -0
  121. llms/extensions/katex/ui/katex-swap.css +1230 -0
  122. llms/extensions/katex/ui/katex-swap.min.css +1 -0
  123. llms/extensions/katex/ui/katex.css +1230 -0
  124. llms/extensions/katex/ui/katex.js +19080 -0
  125. llms/extensions/katex/ui/katex.min.css +1 -0
  126. llms/extensions/katex/ui/katex.min.js +1 -0
  127. llms/extensions/katex/ui/katex.min.mjs +1 -0
  128. llms/extensions/katex/ui/katex.mjs +18547 -0
  129. llms/extensions/providers/__init__.py +18 -0
  130. llms/extensions/providers/__pycache__/__init__.cpython-314.pyc +0 -0
  131. llms/extensions/providers/__pycache__/anthropic.cpython-314.pyc +0 -0
  132. llms/extensions/providers/__pycache__/chutes.cpython-314.pyc +0 -0
  133. llms/extensions/providers/__pycache__/google.cpython-314.pyc +0 -0
  134. llms/{providers → extensions/providers}/__pycache__/nvidia.cpython-314.pyc +0 -0
  135. llms/{providers → extensions/providers}/__pycache__/openai.cpython-314.pyc +0 -0
  136. llms/extensions/providers/__pycache__/openrouter.cpython-314.pyc +0 -0
  137. llms/{providers → extensions/providers}/anthropic.py +45 -5
  138. llms/{providers → extensions/providers}/chutes.py +21 -18
  139. llms/{providers → extensions/providers}/google.py +99 -27
  140. llms/{providers → extensions/providers}/nvidia.py +6 -8
  141. llms/{providers → extensions/providers}/openai.py +3 -6
  142. llms/{providers → extensions/providers}/openrouter.py +12 -10
  143. llms/extensions/system_prompts/__init__.py +45 -0
  144. llms/extensions/system_prompts/__pycache__/__init__.cpython-314.pyc +0 -0
  145. llms/extensions/system_prompts/ui/index.mjs +285 -0
  146. llms/extensions/system_prompts/ui/prompts.json +1067 -0
  147. llms/extensions/tools/__init__.py +5 -0
  148. llms/extensions/tools/__pycache__/__init__.cpython-314.pyc +0 -0
  149. llms/{ui/modules/tools.mjs → extensions/tools/ui/index.mjs} +12 -10
  150. llms/index.html +26 -38
  151. llms/llms.json +20 -1
  152. llms/main.py +845 -245
  153. llms/providers-extra.json +0 -32
  154. llms/ui/App.mjs +18 -20
  155. llms/ui/ai.mjs +38 -15
  156. llms/ui/app.css +1440 -59
  157. llms/ui/ctx.mjs +154 -18
  158. llms/ui/index.mjs +17 -14
  159. llms/ui/lib/vue.min.mjs +10 -9
  160. llms/ui/lib/vue.mjs +1796 -1635
  161. llms/ui/markdown.mjs +4 -2
  162. llms/ui/modules/chat/ChatBody.mjs +101 -334
  163. llms/ui/modules/chat/HomeTools.mjs +12 -0
  164. llms/ui/modules/chat/SettingsDialog.mjs +1 -1
  165. llms/ui/modules/chat/index.mjs +351 -314
  166. llms/ui/modules/layout.mjs +2 -26
  167. llms/ui/modules/model-selector.mjs +3 -3
  168. llms/ui/tailwind.input.css +35 -1
  169. llms/ui/utils.mjs +33 -3
  170. {llms_py-3.0.0b6.dist-info → llms_py-3.0.0b8.dist-info}/METADATA +1 -1
  171. llms_py-3.0.0b8.dist-info/RECORD +198 -0
  172. llms/providers/__pycache__/anthropic.cpython-314.pyc +0 -0
  173. llms/providers/__pycache__/chutes.cpython-314.pyc +0 -0
  174. llms/providers/__pycache__/google.cpython-314.pyc +0 -0
  175. llms/providers/__pycache__/openrouter.cpython-314.pyc +0 -0
  176. llms/ui/modules/threads/threadStore.mjs +0 -586
  177. llms_py-3.0.0b6.dist-info/RECORD +0 -66
  178. {llms_py-3.0.0b6.dist-info → llms_py-3.0.0b8.dist-info}/WHEEL +0 -0
  179. {llms_py-3.0.0b6.dist-info → llms_py-3.0.0b8.dist-info}/entry_points.txt +0 -0
  180. {llms_py-3.0.0b6.dist-info → llms_py-3.0.0b8.dist-info}/licenses/LICENSE +0 -0
  181. {llms_py-3.0.0b6.dist-info → llms_py-3.0.0b8.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,127 @@
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if(typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory();
4
+ else if(typeof define === 'function' && define.amd)
5
+ define([], factory);
6
+ else {
7
+ var a = factory();
8
+ for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
9
+ }
10
+ })((typeof self !== 'undefined' ? self : this), function() {
11
+ return /******/ (function() { // webpackBootstrap
12
+ /******/ "use strict";
13
+ var __webpack_exports__ = {};
14
+
15
+ ;// CONCATENATED MODULE: ./contrib/copy-tex/katex2tex.js
16
+ // Set these to how you want inline and display math to be delimited.
17
+ const defaultCopyDelimiters = {
18
+ inline: ['$', '$'],
19
+ // alternative: ['\(', '\)']
20
+ display: ['$$', '$$'] // alternative: ['\[', '\]']
21
+
22
+ }; // Replace .katex elements with their TeX source (<annotation> element).
23
+ // Modifies fragment in-place. Useful for writing your own 'copy' handler,
24
+ // as in copy-tex.js.
25
+
26
+ function katexReplaceWithTex(fragment, copyDelimiters) {
27
+ if (copyDelimiters === void 0) {
28
+ copyDelimiters = defaultCopyDelimiters;
29
+ }
30
+
31
+ // Remove .katex-html blocks that are preceded by .katex-mathml blocks
32
+ // (which will get replaced below).
33
+ const katexHtml = fragment.querySelectorAll('.katex-mathml + .katex-html');
34
+
35
+ for (let i = 0; i < katexHtml.length; i++) {
36
+ const element = katexHtml[i];
37
+
38
+ if (element.remove) {
39
+ element.remove();
40
+ } else if (element.parentNode) {
41
+ element.parentNode.removeChild(element);
42
+ }
43
+ } // Replace .katex-mathml elements with their annotation (TeX source)
44
+ // descendant, with inline delimiters.
45
+
46
+
47
+ const katexMathml = fragment.querySelectorAll('.katex-mathml');
48
+
49
+ for (let i = 0; i < katexMathml.length; i++) {
50
+ const element = katexMathml[i];
51
+ const texSource = element.querySelector('annotation');
52
+
53
+ if (texSource) {
54
+ if (element.replaceWith) {
55
+ element.replaceWith(texSource);
56
+ } else if (element.parentNode) {
57
+ element.parentNode.replaceChild(texSource, element);
58
+ }
59
+
60
+ texSource.innerHTML = copyDelimiters.inline[0] + texSource.innerHTML + copyDelimiters.inline[1];
61
+ }
62
+ } // Switch display math to display delimiters.
63
+
64
+
65
+ const displays = fragment.querySelectorAll('.katex-display annotation');
66
+
67
+ for (let i = 0; i < displays.length; i++) {
68
+ const element = displays[i];
69
+ element.innerHTML = copyDelimiters.display[0] + element.innerHTML.substr(copyDelimiters.inline[0].length, element.innerHTML.length - copyDelimiters.inline[0].length - copyDelimiters.inline[1].length) + copyDelimiters.display[1];
70
+ }
71
+
72
+ return fragment;
73
+ }
74
+ /* harmony default export */ var katex2tex = (katexReplaceWithTex);
75
+ ;// CONCATENATED MODULE: ./contrib/copy-tex/copy-tex.js
76
+ // Return <div class="katex"> element containing node, or null if not found.
77
+
78
+ function closestKatex(node) {
79
+ // If node is a Text Node, for example, go up to containing Element,
80
+ // where we can apply the `closest` method.
81
+ const element = node instanceof Element ? node : node.parentElement;
82
+ return element && element.closest('.katex');
83
+ } // Global copy handler to modify behavior on/within .katex elements.
84
+
85
+
86
+ document.addEventListener('copy', function (event) {
87
+ const selection = window.getSelection();
88
+
89
+ if (selection.isCollapsed || !event.clipboardData) {
90
+ return; // default action OK if selection is empty or unchangeable
91
+ }
92
+
93
+ const clipboardData = event.clipboardData;
94
+ const range = selection.getRangeAt(0); // When start point is within a formula, expand to entire formula.
95
+
96
+ const startKatex = closestKatex(range.startContainer);
97
+
98
+ if (startKatex) {
99
+ range.setStartBefore(startKatex);
100
+ } // Similarly, when end point is within a formula, expand to entire formula.
101
+
102
+
103
+ const endKatex = closestKatex(range.endContainer);
104
+
105
+ if (endKatex) {
106
+ range.setEndAfter(endKatex);
107
+ }
108
+
109
+ const fragment = range.cloneContents();
110
+
111
+ if (!fragment.querySelector('.katex-mathml')) {
112
+ return; // default action OK if no .katex-mathml elements
113
+ }
114
+
115
+ const htmlContents = Array.prototype.map.call(fragment.childNodes, el => el instanceof Text ? el.textContent : el.outerHTML).join(''); // Preserve usual HTML copy/paste behavior.
116
+
117
+ clipboardData.setData('text/html', htmlContents); // Rewrite plain-text version.
118
+
119
+ clipboardData.setData('text/plain', katex2tex(fragment).textContent); // Prevent normal copy handling.
120
+
121
+ event.preventDefault();
122
+ });
123
+ __webpack_exports__ = __webpack_exports__["default"];
124
+ /******/ return __webpack_exports__;
125
+ /******/ })()
126
+ ;
127
+ });
@@ -0,0 +1 @@
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}("undefined"!=typeof self?self:this,(function(){return function(){"use strict";var e={};const t={inline:["$","$"],display:["$$","$$"]};var n=function(e,n){void 0===n&&(n=t);const o=e.querySelectorAll(".katex-mathml + .katex-html");for(let e=0;e<o.length;e++){const t=o[e];t.remove?t.remove():t.parentNode&&t.parentNode.removeChild(t)}const r=e.querySelectorAll(".katex-mathml");for(let e=0;e<r.length;e++){const t=r[e],o=t.querySelector("annotation");o&&(t.replaceWith?t.replaceWith(o):t.parentNode&&t.parentNode.replaceChild(o,t),o.innerHTML=n.inline[0]+o.innerHTML+n.inline[1])}const l=e.querySelectorAll(".katex-display annotation");for(let e=0;e<l.length;e++){const t=l[e];t.innerHTML=n.display[0]+t.innerHTML.substr(n.inline[0].length,t.innerHTML.length-n.inline[0].length-n.inline[1].length)+n.display[1]}return e};function o(e){const t=e instanceof Element?e:e.parentElement;return t&&t.closest(".katex")}return document.addEventListener("copy",(function(e){const t=window.getSelection();if(t.isCollapsed||!e.clipboardData)return;const r=e.clipboardData,l=t.getRangeAt(0),i=o(l.startContainer);i&&l.setStartBefore(i);const a=o(l.endContainer);a&&l.setEndAfter(a);const s=l.cloneContents();if(!s.querySelector(".katex-mathml"))return;const c=Array.prototype.map.call(s.childNodes,(e=>e instanceof Text?e.textContent:e.outerHTML)).join("");r.setData("text/html",c),r.setData("text/plain",n(s).textContent),e.preventDefault()})),e=e.default}()}));
@@ -0,0 +1,105 @@
1
+ // Set these to how you want inline and display math to be delimited.
2
+ var defaultCopyDelimiters = {
3
+ inline: ['$', '$'],
4
+ // alternative: ['\(', '\)']
5
+ display: ['$$', '$$'] // alternative: ['\[', '\]']
6
+
7
+ }; // Replace .katex elements with their TeX source (<annotation> element).
8
+ // Modifies fragment in-place. Useful for writing your own 'copy' handler,
9
+ // as in copy-tex.js.
10
+
11
+ function katexReplaceWithTex(fragment, copyDelimiters) {
12
+ if (copyDelimiters === void 0) {
13
+ copyDelimiters = defaultCopyDelimiters;
14
+ }
15
+
16
+ // Remove .katex-html blocks that are preceded by .katex-mathml blocks
17
+ // (which will get replaced below).
18
+ var katexHtml = fragment.querySelectorAll('.katex-mathml + .katex-html');
19
+
20
+ for (var i = 0; i < katexHtml.length; i++) {
21
+ var element = katexHtml[i];
22
+
23
+ if (element.remove) {
24
+ element.remove();
25
+ } else if (element.parentNode) {
26
+ element.parentNode.removeChild(element);
27
+ }
28
+ } // Replace .katex-mathml elements with their annotation (TeX source)
29
+ // descendant, with inline delimiters.
30
+
31
+
32
+ var katexMathml = fragment.querySelectorAll('.katex-mathml');
33
+
34
+ for (var _i = 0; _i < katexMathml.length; _i++) {
35
+ var _element = katexMathml[_i];
36
+
37
+ var texSource = _element.querySelector('annotation');
38
+
39
+ if (texSource) {
40
+ if (_element.replaceWith) {
41
+ _element.replaceWith(texSource);
42
+ } else if (_element.parentNode) {
43
+ _element.parentNode.replaceChild(texSource, _element);
44
+ }
45
+
46
+ texSource.innerHTML = copyDelimiters.inline[0] + texSource.innerHTML + copyDelimiters.inline[1];
47
+ }
48
+ } // Switch display math to display delimiters.
49
+
50
+
51
+ var displays = fragment.querySelectorAll('.katex-display annotation');
52
+
53
+ for (var _i2 = 0; _i2 < displays.length; _i2++) {
54
+ var _element2 = displays[_i2];
55
+ _element2.innerHTML = copyDelimiters.display[0] + _element2.innerHTML.substr(copyDelimiters.inline[0].length, _element2.innerHTML.length - copyDelimiters.inline[0].length - copyDelimiters.inline[1].length) + copyDelimiters.display[1];
56
+ }
57
+
58
+ return fragment;
59
+ }
60
+
61
+ function closestKatex(node) {
62
+ // If node is a Text Node, for example, go up to containing Element,
63
+ // where we can apply the `closest` method.
64
+ var element = node instanceof Element ? node : node.parentElement;
65
+ return element && element.closest('.katex');
66
+ } // Global copy handler to modify behavior on/within .katex elements.
67
+
68
+
69
+ document.addEventListener('copy', function (event) {
70
+ var selection = window.getSelection();
71
+
72
+ if (selection.isCollapsed || !event.clipboardData) {
73
+ return; // default action OK if selection is empty or unchangeable
74
+ }
75
+
76
+ var clipboardData = event.clipboardData;
77
+ var range = selection.getRangeAt(0); // When start point is within a formula, expand to entire formula.
78
+
79
+ var startKatex = closestKatex(range.startContainer);
80
+
81
+ if (startKatex) {
82
+ range.setStartBefore(startKatex);
83
+ } // Similarly, when end point is within a formula, expand to entire formula.
84
+
85
+
86
+ var endKatex = closestKatex(range.endContainer);
87
+
88
+ if (endKatex) {
89
+ range.setEndAfter(endKatex);
90
+ }
91
+
92
+ var fragment = range.cloneContents();
93
+
94
+ if (!fragment.querySelector('.katex-mathml')) {
95
+ return; // default action OK if no .katex-mathml elements
96
+ }
97
+
98
+ var htmlContents = Array.prototype.map.call(fragment.childNodes, el => el instanceof Text ? el.textContent : el.outerHTML).join(''); // Preserve usual HTML copy/paste behavior.
99
+
100
+ clipboardData.setData('text/html', htmlContents); // Rewrite plain-text version.
101
+
102
+ clipboardData.setData('text/plain', katexReplaceWithTex(fragment).textContent); // Prevent normal copy handling.
103
+
104
+ event.preventDefault();
105
+ });
@@ -0,0 +1,109 @@
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if(typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory(require("katex"));
4
+ else if(typeof define === 'function' && define.amd)
5
+ define(["katex"], factory);
6
+ else {
7
+ var a = typeof exports === 'object' ? factory(require("katex")) : factory(root["katex"]);
8
+ for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
9
+ }
10
+ })((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__757__) {
11
+ return /******/ (function() { // webpackBootstrap
12
+ /******/ "use strict";
13
+ /******/ var __webpack_modules__ = ({
14
+
15
+ /***/ 757:
16
+ /***/ (function(module) {
17
+
18
+ module.exports = __WEBPACK_EXTERNAL_MODULE__757__;
19
+
20
+ /***/ })
21
+
22
+ /******/ });
23
+ /************************************************************************/
24
+ /******/ // The module cache
25
+ /******/ var __webpack_module_cache__ = {};
26
+ /******/
27
+ /******/ // The require function
28
+ /******/ function __webpack_require__(moduleId) {
29
+ /******/ // Check if module is in cache
30
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
31
+ /******/ if (cachedModule !== undefined) {
32
+ /******/ return cachedModule.exports;
33
+ /******/ }
34
+ /******/ // Create a new module (and put it into the cache)
35
+ /******/ var module = __webpack_module_cache__[moduleId] = {
36
+ /******/ // no module.id needed
37
+ /******/ // no module.loaded needed
38
+ /******/ exports: {}
39
+ /******/ };
40
+ /******/
41
+ /******/ // Execute the module function
42
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
43
+ /******/
44
+ /******/ // Return the exports of the module
45
+ /******/ return module.exports;
46
+ /******/ }
47
+ /******/
48
+ /************************************************************************/
49
+ /******/ /* webpack/runtime/compat get default export */
50
+ /******/ !function() {
51
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
52
+ /******/ __webpack_require__.n = function(module) {
53
+ /******/ var getter = module && module.__esModule ?
54
+ /******/ function() { return module['default']; } :
55
+ /******/ function() { return module; };
56
+ /******/ __webpack_require__.d(getter, { a: getter });
57
+ /******/ return getter;
58
+ /******/ };
59
+ /******/ }();
60
+ /******/
61
+ /******/ /* webpack/runtime/define property getters */
62
+ /******/ !function() {
63
+ /******/ // define getter functions for harmony exports
64
+ /******/ __webpack_require__.d = function(exports, definition) {
65
+ /******/ for(var key in definition) {
66
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
67
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
68
+ /******/ }
69
+ /******/ }
70
+ /******/ };
71
+ /******/ }();
72
+ /******/
73
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
74
+ /******/ !function() {
75
+ /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
76
+ /******/ }();
77
+ /******/
78
+ /************************************************************************/
79
+ var __webpack_exports__ = {};
80
+ /* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(757);
81
+ /* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(katex__WEBPACK_IMPORTED_MODULE_0__);
82
+
83
+ let scripts = document.body.getElementsByTagName("script");
84
+ scripts = Array.prototype.slice.call(scripts);
85
+ scripts.forEach(function (script) {
86
+ if (!script.type || !script.type.match(/math\/tex/i)) {
87
+ return -1;
88
+ }
89
+
90
+ const display = script.type.match(/mode\s*=\s*display(;|\s|\n|$)/) != null;
91
+ const katexElement = document.createElement(display ? "div" : "span");
92
+ katexElement.setAttribute("class", display ? "equation" : "inline-equation");
93
+
94
+ try {
95
+ katex__WEBPACK_IMPORTED_MODULE_0___default().render(script.text, katexElement, {
96
+ displayMode: display
97
+ });
98
+ } catch (err) {
99
+ //console.error(err); linter doesn't like this
100
+ katexElement.textContent = script.text;
101
+ }
102
+
103
+ script.parentNode.replaceChild(katexElement, script);
104
+ });
105
+ __webpack_exports__ = __webpack_exports__["default"];
106
+ /******/ return __webpack_exports__;
107
+ /******/ })()
108
+ ;
109
+ });
@@ -0,0 +1 @@
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("katex"));else if("function"==typeof define&&define.amd)define(["katex"],t);else{var n="object"==typeof exports?t(require("katex")):t(e.katex);for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}("undefined"!=typeof self?self:this,(function(e){return function(){"use strict";var t={757:function(t){t.exports=e}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,r),i.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};var o={},i=r(757),a=r.n(i);let u=document.body.getElementsByTagName("script");return u=Array.prototype.slice.call(u),u.forEach((function(e){if(!e.type||!e.type.match(/math\/tex/i))return-1;const t=null!=e.type.match(/mode\s*=\s*display(;|\s|\n|$)/),n=document.createElement(t?"div":"span");n.setAttribute("class",t?"equation":"inline-equation");try{a().render(e.text,n,{displayMode:t})}catch(t){n.textContent=e.text}e.parentNode.replaceChild(n,e)})),o=o.default}()}));
@@ -0,0 +1,24 @@
1
+ import katex from '../katex.mjs';
2
+
3
+ var scripts = document.body.getElementsByTagName("script");
4
+ scripts = Array.prototype.slice.call(scripts);
5
+ scripts.forEach(function (script) {
6
+ if (!script.type || !script.type.match(/math\/tex/i)) {
7
+ return -1;
8
+ }
9
+
10
+ var display = script.type.match(/mode\s*=\s*display(;|\s|\n|$)/) != null;
11
+ var katexElement = document.createElement(display ? "div" : "span");
12
+ katexElement.setAttribute("class", display ? "equation" : "inline-equation");
13
+
14
+ try {
15
+ katex.render(script.text, katexElement, {
16
+ displayMode: display
17
+ });
18
+ } catch (err) {
19
+ //console.error(err); linter doesn't like this
20
+ katexElement.textContent = script.text;
21
+ }
22
+
23
+ script.parentNode.replaceChild(katexElement, script);
24
+ });