docusaurus-live-brython 3.0.0-beta.8 → 3.0.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 (175) hide show
  1. package/.devcontainer/devcontainer.json +38 -0
  2. package/.prettierignore +17 -0
  3. package/.prettierrc +9 -8
  4. package/CHANGELOG.md +5 -0
  5. package/README.md +7 -4
  6. package/lib/assets/py_back_trace.py +2 -1
  7. package/lib/index.d.ts +1 -7
  8. package/lib/index.d.ts.map +1 -0
  9. package/lib/index.js +94 -16
  10. package/lib/options.d.ts +1 -0
  11. package/lib/options.d.ts.map +1 -0
  12. package/lib/options.js +2 -2
  13. package/lib/theme/CodeBlock/index.d.ts +3 -3
  14. package/lib/theme/CodeBlock/index.d.ts.map +1 -0
  15. package/lib/theme/CodeBlock/index.jsx +24 -14
  16. package/lib/theme/CodeEditor/Actions/DownloadCode.d.ts +1 -0
  17. package/lib/theme/CodeEditor/Actions/DownloadCode.d.ts.map +1 -0
  18. package/lib/theme/CodeEditor/Actions/DownloadCode.jsx +8 -8
  19. package/lib/theme/CodeEditor/Actions/Reset.d.ts +1 -0
  20. package/lib/theme/CodeEditor/Actions/Reset.d.ts.map +1 -0
  21. package/lib/theme/CodeEditor/Actions/Reset.jsx +5 -5
  22. package/lib/theme/CodeEditor/Actions/RunCode.d.ts +2 -1
  23. package/lib/theme/CodeEditor/Actions/RunCode.d.ts.map +1 -0
  24. package/lib/theme/CodeEditor/Actions/RunCode.jsx +4 -4
  25. package/lib/theme/CodeEditor/Actions/ShowRaw.d.ts +1 -0
  26. package/lib/theme/CodeEditor/Actions/ShowRaw.d.ts.map +1 -0
  27. package/lib/theme/CodeEditor/Actions/ShowRaw.jsx +13 -7
  28. package/lib/theme/CodeEditor/Actions/ShowSyncStatus.d.ts +1 -0
  29. package/lib/theme/CodeEditor/Actions/ShowSyncStatus.d.ts.map +1 -0
  30. package/lib/theme/CodeEditor/Actions/ShowSyncStatus.jsx +21 -16
  31. package/lib/theme/CodeEditor/Actions/styles.module.css +2 -3
  32. package/lib/theme/CodeEditor/BrythonCommunicator.d.ts +2 -1
  33. package/lib/theme/CodeEditor/BrythonCommunicator.d.ts.map +1 -0
  34. package/lib/theme/CodeEditor/BrythonCommunicator.jsx +13 -9
  35. package/lib/theme/CodeEditor/Button/index.d.ts +3 -2
  36. package/lib/theme/CodeEditor/Button/index.d.ts.map +1 -0
  37. package/lib/theme/CodeEditor/Button/index.jsx +1 -1
  38. package/lib/theme/CodeEditor/Button/styles.module.css +1 -1
  39. package/lib/theme/CodeEditor/CodeHistory/index.d.ts +1 -0
  40. package/lib/theme/CodeEditor/CodeHistory/index.d.ts.map +1 -0
  41. package/lib/theme/CodeEditor/CodeHistory/index.jsx +26 -15
  42. package/lib/theme/CodeEditor/CodeHistory/styles.module.css +31 -31
  43. package/lib/theme/CodeEditor/ContextEditor/index.d.ts +22 -0
  44. package/lib/theme/CodeEditor/ContextEditor/index.d.ts.map +1 -0
  45. package/lib/theme/CodeEditor/ContextEditor/index.jsx +36 -0
  46. package/lib/theme/CodeEditor/Editor/EditorAce.d.ts +2 -1
  47. package/lib/theme/CodeEditor/Editor/EditorAce.d.ts.map +1 -0
  48. package/lib/theme/CodeEditor/Editor/EditorAce.jsx +17 -14
  49. package/lib/theme/CodeEditor/Editor/Header/index.d.ts +2 -1
  50. package/lib/theme/CodeEditor/Editor/Header/index.d.ts.map +1 -0
  51. package/lib/theme/CodeEditor/Editor/Header/index.jsx +12 -12
  52. package/lib/theme/CodeEditor/Editor/Header/styles.module.css +7 -7
  53. package/lib/theme/CodeEditor/Editor/HiddenCode/index.d.ts +8 -0
  54. package/lib/theme/CodeEditor/Editor/HiddenCode/index.d.ts.map +1 -0
  55. package/lib/theme/CodeEditor/Editor/HiddenCode/index.jsx +27 -0
  56. package/lib/theme/CodeEditor/Editor/HiddenCode/styles.module.css +52 -0
  57. package/lib/theme/CodeEditor/Editor/Result/Graphics/Canvas.d.ts +1 -0
  58. package/lib/theme/CodeEditor/Editor/Result/Graphics/Canvas.d.ts.map +1 -0
  59. package/lib/theme/CodeEditor/Editor/Result/Graphics/Canvas.jsx +8 -9
  60. package/lib/theme/CodeEditor/Editor/Result/Graphics/Turtle.d.ts +1 -0
  61. package/lib/theme/CodeEditor/Editor/Result/Graphics/Turtle.d.ts.map +1 -0
  62. package/lib/theme/CodeEditor/Editor/Result/Graphics/Turtle.jsx +11 -11
  63. package/lib/theme/CodeEditor/Editor/Result/Graphics/index.d.ts +4 -3
  64. package/lib/theme/CodeEditor/Editor/Result/Graphics/index.d.ts.map +1 -0
  65. package/lib/theme/CodeEditor/Editor/Result/Graphics/index.jsx +12 -10
  66. package/lib/theme/CodeEditor/Editor/Result/Graphics/styles.module.css +2 -2
  67. package/lib/theme/CodeEditor/Editor/Result/index.d.ts +2 -3
  68. package/lib/theme/CodeEditor/Editor/Result/index.d.ts.map +1 -0
  69. package/lib/theme/CodeEditor/Editor/Result/index.jsx +6 -9
  70. package/lib/theme/CodeEditor/Editor/Result/styles.module.css +15 -10
  71. package/lib/theme/CodeEditor/Editor/index.d.ts +6 -3
  72. package/lib/theme/CodeEditor/Editor/index.d.ts.map +1 -0
  73. package/lib/theme/CodeEditor/Editor/index.jsx +34 -28
  74. package/lib/theme/CodeEditor/Editor/styles.module.css +15 -7
  75. package/lib/theme/CodeEditor/Editor/utils/checkForButtonClick.d.ts +1 -0
  76. package/lib/theme/CodeEditor/Editor/utils/checkForButtonClick.d.ts.map +1 -0
  77. package/lib/theme/CodeEditor/Editor/utils/saveSvg.d.ts +1 -0
  78. package/lib/theme/CodeEditor/Editor/utils/saveSvg.d.ts.map +1 -0
  79. package/lib/theme/CodeEditor/Editor/utils/saveSvg.js +19 -8
  80. package/lib/theme/CodeEditor/Editor/utils/svgWithoutAnimations.d.ts +1 -0
  81. package/lib/theme/CodeEditor/Editor/utils/svgWithoutAnimations.d.ts.map +1 -0
  82. package/lib/theme/CodeEditor/Editor/utils/svgWithoutAnimations.js +43 -49
  83. package/lib/theme/CodeEditor/Icon/icons.d.ts +4 -1
  84. package/lib/theme/CodeEditor/Icon/icons.d.ts.map +1 -0
  85. package/lib/theme/CodeEditor/Icon/icons.js +3 -1
  86. package/lib/theme/CodeEditor/Icon/index.d.ts +4 -2
  87. package/lib/theme/CodeEditor/Icon/index.d.ts.map +1 -0
  88. package/lib/theme/CodeEditor/Icon/index.jsx +10 -3
  89. package/lib/theme/CodeEditor/Icon/styles.module.css +1 -1
  90. package/lib/theme/CodeEditor/WithScript/ScriptContext.d.ts +8 -0
  91. package/lib/theme/CodeEditor/WithScript/ScriptContext.d.ts.map +1 -0
  92. package/lib/theme/CodeEditor/WithScript/ScriptContext.jsx +27 -0
  93. package/lib/theme/CodeEditor/WithScript/Storage.d.ts +2 -1
  94. package/lib/theme/CodeEditor/WithScript/Storage.d.ts.map +1 -0
  95. package/lib/theme/CodeEditor/WithScript/Types.d.ts +12 -4
  96. package/lib/theme/CodeEditor/WithScript/Types.d.ts.map +1 -0
  97. package/lib/theme/CodeEditor/WithScript/bryRunner.d.ts +3 -0
  98. package/lib/theme/CodeEditor/WithScript/bryRunner.d.ts.map +1 -0
  99. package/lib/theme/CodeEditor/WithScript/bryRunner.js +29 -0
  100. package/lib/theme/CodeEditor/WithScript/createStore.d.ts +4 -0
  101. package/lib/theme/CodeEditor/WithScript/createStore.d.ts.map +1 -0
  102. package/lib/theme/CodeEditor/WithScript/{Store.jsx → createStore.js} +62 -74
  103. package/lib/theme/CodeEditor/WithScript/helpers.d.ts +1 -4
  104. package/lib/theme/CodeEditor/WithScript/helpers.d.ts.map +1 -0
  105. package/lib/theme/CodeEditor/WithScript/helpers.js +4 -14
  106. package/lib/theme/CodeEditor/constants.d.ts +1 -0
  107. package/lib/theme/CodeEditor/constants.d.ts.map +1 -0
  108. package/lib/theme/CodeEditor/hooks/index.d.ts +3 -0
  109. package/lib/theme/CodeEditor/hooks/index.d.ts.map +1 -0
  110. package/lib/theme/CodeEditor/hooks/index.js +2 -0
  111. package/lib/theme/CodeEditor/hooks/useScript.d.ts +3 -0
  112. package/lib/theme/CodeEditor/hooks/useScript.d.ts.map +1 -0
  113. package/lib/theme/CodeEditor/hooks/useScript.js +4 -0
  114. package/lib/theme/CodeEditor/hooks/useStore.d.ts +3 -0
  115. package/lib/theme/CodeEditor/hooks/useStore.d.ts.map +1 -0
  116. package/lib/theme/CodeEditor/hooks/useStore.js +10 -0
  117. package/lib/theme/CodeEditor/index.d.ts +24 -5
  118. package/lib/theme/CodeEditor/index.d.ts.map +1 -0
  119. package/lib/theme/CodeEditor/index.jsx +17 -16
  120. package/lib/theme/CodeEditor/styles.module.css +28 -30
  121. package/og-image.md +23 -0
  122. package/package.json +39 -20
  123. package/src/assets/py_back_trace.py +2 -1
  124. package/src/index.ts +96 -25
  125. package/src/options.ts +12 -12
  126. package/src/theme/CodeBlock/index.tsx +44 -68
  127. package/src/theme/CodeEditor/Actions/DownloadCode.tsx +23 -22
  128. package/src/theme/CodeEditor/Actions/Reset.tsx +14 -12
  129. package/src/theme/CodeEditor/Actions/RunCode.tsx +14 -11
  130. package/src/theme/CodeEditor/Actions/ShowRaw.tsx +17 -11
  131. package/src/theme/CodeEditor/Actions/ShowSyncStatus.tsx +32 -27
  132. package/src/theme/CodeEditor/Actions/styles.module.css +2 -3
  133. package/src/theme/CodeEditor/BrythonCommunicator.tsx +16 -19
  134. package/src/theme/CodeEditor/Button/index.tsx +17 -13
  135. package/src/theme/CodeEditor/Button/styles.module.css +1 -1
  136. package/src/theme/CodeEditor/CodeHistory/index.tsx +32 -20
  137. package/src/theme/CodeEditor/CodeHistory/styles.module.css +31 -31
  138. package/src/theme/CodeEditor/ContextEditor/index.tsx +74 -0
  139. package/src/theme/CodeEditor/Editor/EditorAce.tsx +20 -16
  140. package/src/theme/CodeEditor/Editor/Header/index.tsx +13 -19
  141. package/src/theme/CodeEditor/Editor/Header/styles.module.css +7 -7
  142. package/src/theme/CodeEditor/Editor/HiddenCode/index.tsx +49 -0
  143. package/src/theme/CodeEditor/Editor/HiddenCode/styles.module.css +52 -0
  144. package/src/theme/CodeEditor/Editor/Result/Graphics/Canvas.tsx +25 -22
  145. package/src/theme/CodeEditor/Editor/Result/Graphics/Turtle.tsx +23 -19
  146. package/src/theme/CodeEditor/Editor/Result/Graphics/index.tsx +16 -16
  147. package/src/theme/CodeEditor/Editor/Result/Graphics/styles.module.css +2 -2
  148. package/src/theme/CodeEditor/Editor/Result/index.tsx +7 -13
  149. package/src/theme/CodeEditor/Editor/Result/styles.module.css +15 -10
  150. package/src/theme/CodeEditor/Editor/index.tsx +67 -65
  151. package/src/theme/CodeEditor/Editor/styles.module.css +15 -7
  152. package/src/theme/CodeEditor/Editor/utils/checkForButtonClick.ts +5 -5
  153. package/src/theme/CodeEditor/Editor/utils/saveSvg.ts +63 -53
  154. package/src/theme/CodeEditor/Editor/utils/svgWithoutAnimations.ts +182 -201
  155. package/src/theme/CodeEditor/Icon/icons.ts +27 -13
  156. package/src/theme/CodeEditor/Icon/index.tsx +31 -11
  157. package/src/theme/CodeEditor/Icon/styles.module.css +1 -1
  158. package/src/theme/CodeEditor/WithScript/ScriptContext.tsx +36 -0
  159. package/src/theme/CodeEditor/WithScript/Storage.ts +3 -3
  160. package/src/theme/CodeEditor/WithScript/Types.ts +17 -11
  161. package/src/theme/CodeEditor/WithScript/bryRunner.ts +39 -0
  162. package/src/theme/CodeEditor/WithScript/createStore.ts +276 -0
  163. package/src/theme/CodeEditor/WithScript/helpers.ts +16 -26
  164. package/src/theme/CodeEditor/constants.ts +9 -11
  165. package/src/theme/CodeEditor/hooks/index.ts +2 -0
  166. package/src/theme/CodeEditor/hooks/useScript.ts +9 -0
  167. package/src/theme/CodeEditor/hooks/useStore.ts +15 -0
  168. package/src/theme/CodeEditor/index.tsx +45 -31
  169. package/src/theme/CodeEditor/styles.module.css +28 -30
  170. package/src/typings.d.ts +11 -0
  171. package/lib/theme/CodeEditor/WithScript/Store.d.ts +0 -15
  172. package/lib/types.d.ts +0 -28
  173. package/lib/types.js +0 -1
  174. package/src/theme/CodeEditor/WithScript/Store.tsx +0 -294
  175. package/src/types.ts +0 -29
@@ -1,28 +1,26 @@
1
- import { parse } from "svg-parser";
1
+ import { parse } from 'svg-parser';
2
2
  const objToAttr = (obj) => {
3
3
  return Object.entries(obj || {})
4
4
  .map((v) => `${v[0]}="${v[1]}"`)
5
- .join(" ");
5
+ .join(' ');
6
6
  };
7
7
  const mergeSvgProps = (parsedSvg, svgProps) => {
8
- if (parsedSvg.type === "root") {
8
+ if (parsedSvg.type === 'root') {
9
9
  parsedSvg.children.forEach((child) => {
10
10
  mergeSvgProps(child, svgProps);
11
11
  });
12
12
  }
13
- else if (parsedSvg.type === "element" &&
14
- parsedSvg.tagName === "svg" &&
15
- "properties" in parsedSvg) {
13
+ else if (parsedSvg.type === 'element' && parsedSvg.tagName === 'svg' && 'properties' in parsedSvg) {
16
14
  parsedSvg.properties = { ...(parsedSvg.properties || {}), ...svgProps };
17
15
  }
18
16
  };
19
17
  const svgWithoutAnimations = (element) => {
20
- if (typeof element === "string") {
18
+ if (typeof element === 'string') {
21
19
  return [element];
22
20
  }
23
21
  const newSvg = [];
24
22
  // const { properties, tagName, type, children } = element;
25
- if (element.type === "root") {
23
+ if (element.type === 'root') {
26
24
  element.children.forEach((child) => {
27
25
  newSvg.push(...svgWithoutAnimations(child));
28
26
  });
@@ -31,7 +29,7 @@ const svgWithoutAnimations = (element) => {
31
29
  const { tagName, type, children } = element;
32
30
  const properties = element.properties || {};
33
31
  switch (element.tagName) {
34
- case "svg":
32
+ case 'svg':
35
33
  if (element.metadata) {
36
34
  newSvg.push(element.metadata);
37
35
  }
@@ -41,18 +39,17 @@ const svgWithoutAnimations = (element) => {
41
39
  });
42
40
  newSvg.push(`</svg>`);
43
41
  break;
44
- case "rect":
42
+ case 'rect':
45
43
  children.forEach((child) => {
46
- if (typeof child === "string" || child.type !== "element") {
44
+ if (typeof child === 'string' || child.type !== 'element') {
47
45
  return;
48
46
  }
49
- if (["animate", "set"].includes(child.tagName || '') && !!child.properties) {
47
+ if (['animate', 'set'].includes(child.tagName || '') && !!child.properties) {
50
48
  const animProps = child.properties;
51
- if (!("to" in animProps) || !("attributeName" in animProps)) {
49
+ if (!('to' in animProps) || !('attributeName' in animProps)) {
52
50
  return;
53
51
  }
54
- if (animProps.attributeName === "display" &&
55
- animProps.attributeType === "CSS") {
52
+ if (animProps.attributeName === 'display' && animProps.attributeType === 'CSS') {
56
53
  properties.style = `${properties.style}`.replace(/display:\s*\b\w+\b;/g, `display: ${animProps.to};`);
57
54
  }
58
55
  properties[animProps.attributeName] = animProps.to;
@@ -60,7 +57,7 @@ const svgWithoutAnimations = (element) => {
60
57
  });
61
58
  newSvg.push(`<rect ${objToAttr(properties)}></rect>`);
62
59
  break;
63
- case "g":
60
+ case 'g':
64
61
  if ((children || []).length === 0) {
65
62
  return newSvg;
66
63
  }
@@ -68,16 +65,16 @@ const svgWithoutAnimations = (element) => {
68
65
  children.forEach((child) => {
69
66
  newSvg.push(...svgWithoutAnimations(child));
70
67
  });
71
- newSvg.push("</g>");
68
+ newSvg.push('</g>');
72
69
  break;
73
- case "line":
70
+ case 'line':
74
71
  children.forEach((child) => {
75
- if (typeof child === "string" || child.type !== "element") {
72
+ if (typeof child === 'string' || child.type !== 'element') {
76
73
  return;
77
74
  }
78
- if (["animate", "set"].includes(child.tagName || '') && !!child.properties) {
75
+ if (['animate', 'set'].includes(child.tagName || '') && !!child.properties) {
79
76
  const animProps = child.properties;
80
- if (!("to" in animProps) || !("attributeName" in animProps)) {
77
+ if (!('to' in animProps) || !('attributeName' in animProps)) {
81
78
  return;
82
79
  }
83
80
  properties[animProps.attributeName] = animProps.to;
@@ -85,28 +82,27 @@ const svgWithoutAnimations = (element) => {
85
82
  });
86
83
  newSvg.push(`<line ${objToAttr(properties)}></line>`);
87
84
  break;
88
- case "circle":
85
+ case 'circle':
89
86
  children.forEach((child) => {
90
- if (typeof child === "string" || child.type !== "element") {
87
+ if (typeof child === 'string' || child.type !== 'element') {
91
88
  return;
92
89
  }
93
- if (["animate", "set"].includes(child.tagName || '') && !!child.properties) {
90
+ if (['animate', 'set'].includes(child.tagName || '') && !!child.properties) {
94
91
  const animProps = child.properties;
95
- if (!("to" in animProps) || !("attributeName" in animProps)) {
92
+ if (!('to' in animProps) || !('attributeName' in animProps)) {
96
93
  return;
97
94
  }
98
- if (properties.attributeName === "display" &&
99
- properties.attributeType === "CSS") {
95
+ if (properties.attributeName === 'display' && properties.attributeType === 'CSS') {
100
96
  properties.style = `${properties.style}`.replace(/display:\s*\b\w+\b;/g, `display: ${animProps.to}`);
101
97
  }
102
98
  }
103
99
  });
104
100
  if (properties.style && /\s*display:\s*none;\s*/.test(`${properties.style}`)) {
105
- properties.style = `${properties.style}`.replace(/\s*display:\s*none;\s*/g, "");
101
+ properties.style = `${properties.style}`.replace(/\s*display:\s*none;\s*/g, '');
106
102
  }
107
103
  newSvg.push(`<circle ${objToAttr(properties)}></circle>`);
108
104
  break;
109
- case "text":
105
+ case 'text':
110
106
  var text;
111
107
  children.forEach((child) => {
112
108
  if (typeof child === 'string') {
@@ -114,19 +110,18 @@ const svgWithoutAnimations = (element) => {
114
110
  return;
115
111
  }
116
112
  switch (child.type) {
117
- case "text":
113
+ case 'text':
118
114
  text = child.value;
119
115
  break;
120
- case "element":
116
+ case 'element':
121
117
  const textProps = child.properties;
122
- if (!textProps || !["animate", "set"].includes(child.tagName || '')) {
118
+ if (!textProps || !['animate', 'set'].includes(child.tagName || '')) {
123
119
  return;
124
120
  }
125
- if (!("to" in textProps) || !("attributeName" in textProps)) {
121
+ if (!('to' in textProps) || !('attributeName' in textProps)) {
126
122
  return;
127
123
  }
128
- if (textProps.attributeName === "display" &&
129
- textProps.attributeType === "CSS") {
124
+ if (textProps.attributeName === 'display' && textProps.attributeType === 'CSS') {
130
125
  properties.style = `${properties.style}`.replace(/display:\s*\b\w+\b;/g, `display: ${textProps.to};`);
131
126
  }
132
127
  properties[textProps.attributeName] = textProps.to;
@@ -135,33 +130,32 @@ const svgWithoutAnimations = (element) => {
135
130
  });
136
131
  newSvg.push(`<text ${objToAttr(properties)}>${text}</text>`);
137
132
  break;
138
- case "polygon":
139
- var endRot = "0,0,0";
140
- var endPos = "0,0";
133
+ case 'polygon':
134
+ var endRot = '0,0,0';
135
+ var endPos = '0,0';
141
136
  children.forEach((child) => {
142
- if (typeof child === "string" || child.type !== "element" || !child.properties) {
137
+ if (typeof child === 'string' || child.type !== 'element' || !child.properties) {
143
138
  return;
144
139
  }
145
140
  const polyProps = child.properties;
146
141
  switch (child.tagName) {
147
- case "set":
148
- case "animate":
149
- if (!("to" in polyProps) || !("attributeName" in polyProps)) {
142
+ case 'set':
143
+ case 'animate':
144
+ if (!('to' in polyProps) || !('attributeName' in polyProps)) {
150
145
  return;
151
146
  }
152
- if (polyProps.attributeName === "display" &&
153
- polyProps.attributeType === "CSS") {
147
+ if (polyProps.attributeName === 'display' && polyProps.attributeType === 'CSS') {
154
148
  properties.style = `${properties.style}`.replace(/display:\s*\b\w+\b;/g, `display: ${polyProps.to};`);
155
149
  }
156
150
  properties[polyProps.attributeName] = polyProps.to;
157
151
  break;
158
- case "animateTransform":
159
- if (child.properties.type === "rotate") {
152
+ case 'animateTransform':
153
+ if (child.properties.type === 'rotate') {
160
154
  endRot = `${child.properties.to}`;
161
155
  }
162
156
  break;
163
- case "animateMotion":
164
- if ("to" in child.properties) {
157
+ case 'animateMotion':
158
+ if ('to' in child.properties) {
165
159
  endPos = `${child.properties.to}`;
166
160
  }
167
161
  break;
@@ -178,6 +172,6 @@ const removeAnimations = (svg, svgProps) => {
178
172
  mergeSvgProps(parsed, svgProps);
179
173
  }
180
174
  const elements = svgWithoutAnimations(parsed);
181
- return elements.join("\n");
175
+ return elements.join('\n');
182
176
  };
183
177
  export { removeAnimations };
@@ -9,4 +9,7 @@ declare const ErrorIcon = "M12,2C17.53,2 22,6.47 22,12C22,17.53 17.53,22 12,22C6
9
9
  declare const EditCode = "M 9.54 13.65 L 11.63 15.74 L 10.35 17 L 7 13.65 L 10.35 10.3 L 11.63 11.56 L 9.54 13.65 M 17 13.65 L 13.65 17 L 12.38 15.74 L 14.47 13.65 L 12.38 11.56 L 13.65 10.3 l 3.35 3.35 Z M 10 20 H 6 V 4 H 13 V 9 H 18 V 12.1 L 20 10.1 V 8 L 14 2 H 6 A 2 2 0 0 0 4 4 V 20 A 2 2 0 0 0 6 22 H 10 V 20 M 20.2 13 C 20.3 13 20.5 13.1 20.6 13.2 L 21.9 14.5 C 22.1 14.7 22.1 15.1 21.9 15.3 L 20.9 16.3 L 18.8 14.2 L 19.8 13.2 C 19.9 13.1 20 13 20.2 13 M 20.2 16.9 L 14.1 23 H 12 V 20.9 L 18.1 14.8 L 20.2 16.9 Z";
10
10
  declare const Code = "M14 2H6C4.89 2 4 2.9 4 4V20C4 21.11 4.89 22 6 22H18C19.11 22 20 21.11 20 20V8L14 2M18 20H6V4H13V9H18V20M9.54 15.65L11.63 17.74L10.35 19L7 15.65L10.35 12.3L11.63 13.56L9.54 15.65M17 15.65L13.65 19L12.38 17.74L14.47 15.65L12.38 13.56L13.65 12.3L17 15.65Z";
11
11
  declare const Reset = "M13,3A9,9 0 0,0 4,12H1L4.89,15.89L4.96,16.03L9,12H6A7,7 0 0,1 13,5A7,7 0 0,1 20,12A7,7 0 0,1 13,19C11.07,19 9.32,18.21 8.06,16.94L6.64,18.36C8.27,20 10.5,21 13,21A9,9 0 0,0 22,12A9,9 0 0,0 13,3Z";
12
- export { Download, Python, Play, Close, AnimationPlay, Sync, Check, ErrorIcon, EditCode, Code, Reset };
12
+ declare const TrayPlus = "M2 12H4V17H20V12H22V17A2 2 0 0 1 20 19H4A2 2 0 0 1 2 17M11 5H13V8H16V10H13V13H11V10H8V8H11Z";
13
+ declare const TrayMinus = "M16 10H8V8H16M2 17A2 2 0 0 0 4 19H20A2 2 0 0 0 22 17V12H20V17H4V12H2Z";
14
+ export { Download, Python, Play, Close, AnimationPlay, Sync, Check, ErrorIcon, EditCode, Code, Reset, TrayPlus, TrayMinus };
15
+ //# sourceMappingURL=icons.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../../../src/theme/CodeEditor/Icon/icons.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,QAAQ,8CAA8C,CAAC;AAC7D,QAAA,MAAM,MAAM,ixBACswB,CAAC;AACnxB,QAAA,MAAM,IAAI,2RACkR,CAAC;AAC7R,QAAA,MAAM,KAAK,mHACyG,CAAC;AACrH,QAAA,MAAM,aAAa,qNACmM,CAAC;AACvN,QAAA,MAAM,IAAI,uOAC8N,CAAC;AACzO,QAAA,MAAM,KAAK,wHAC8G,CAAC;AAC1H,QAAA,MAAM,SAAS,6MAC+L,CAAC;AAC/M,QAAA,MAAM,QAAQ,mfACse,CAAC;AACrf,QAAA,MAAM,IAAI,iQACwP,CAAC;AACnQ,QAAA,MAAM,KAAK,uMAC6L,CAAC;AACzM,QAAA,MAAM,QAAQ,gGACmF,CAAC;AAClG,QAAA,MAAM,SAAS,0EAA0E,CAAC;AAE1F,OAAO,EACH,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,KAAK,EACL,aAAa,EACb,IAAI,EACJ,KAAK,EACL,SAAS,EACT,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,SAAS,EACZ,CAAC"}
@@ -9,4 +9,6 @@ const ErrorIcon = 'M12,2C17.53,2 22,6.47 22,12C22,17.53 17.53,22 12,22C6.47,22 2
9
9
  const EditCode = 'M 9.54 13.65 L 11.63 15.74 L 10.35 17 L 7 13.65 L 10.35 10.3 L 11.63 11.56 L 9.54 13.65 M 17 13.65 L 13.65 17 L 12.38 15.74 L 14.47 13.65 L 12.38 11.56 L 13.65 10.3 l 3.35 3.35 Z M 10 20 H 6 V 4 H 13 V 9 H 18 V 12.1 L 20 10.1 V 8 L 14 2 H 6 A 2 2 0 0 0 4 4 V 20 A 2 2 0 0 0 6 22 H 10 V 20 M 20.2 13 C 20.3 13 20.5 13.1 20.6 13.2 L 21.9 14.5 C 22.1 14.7 22.1 15.1 21.9 15.3 L 20.9 16.3 L 18.8 14.2 L 19.8 13.2 C 19.9 13.1 20 13 20.2 13 M 20.2 16.9 L 14.1 23 H 12 V 20.9 L 18.1 14.8 L 20.2 16.9 Z';
10
10
  const Code = 'M14 2H6C4.89 2 4 2.9 4 4V20C4 21.11 4.89 22 6 22H18C19.11 22 20 21.11 20 20V8L14 2M18 20H6V4H13V9H18V20M9.54 15.65L11.63 17.74L10.35 19L7 15.65L10.35 12.3L11.63 13.56L9.54 15.65M17 15.65L13.65 19L12.38 17.74L14.47 15.65L12.38 13.56L13.65 12.3L17 15.65Z';
11
11
  const Reset = 'M13,3A9,9 0 0,0 4,12H1L4.89,15.89L4.96,16.03L9,12H6A7,7 0 0,1 13,5A7,7 0 0,1 20,12A7,7 0 0,1 13,19C11.07,19 9.32,18.21 8.06,16.94L6.64,18.36C8.27,20 10.5,21 13,21A9,9 0 0,0 22,12A9,9 0 0,0 13,3Z';
12
- export { Download, Python, Play, Close, AnimationPlay, Sync, Check, ErrorIcon, EditCode, Code, Reset };
12
+ const TrayPlus = 'M2 12H4V17H20V12H22V17A2 2 0 0 1 20 19H4A2 2 0 0 1 2 17M11 5H13V8H16V10H13V13H11V10H8V8H11Z';
13
+ const TrayMinus = 'M16 10H8V8H16M2 17A2 2 0 0 0 4 19H20A2 2 0 0 0 22 17V12H20V17H4V12H2Z';
14
+ export { Download, Python, Play, Close, AnimationPlay, Sync, Check, ErrorIcon, EditCode, Code, Reset, TrayPlus, TrayMinus };
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import * as Icons from 'docusaurus-live-brython/theme/CodeEditor/Icon/icons';
2
+ import * as Icons from '@theme/CodeEditor/Icon/icons';
3
3
  export declare enum Color {
4
4
  Primary = "var(--ifm-color-primary)",
5
5
  Secondary = "var(--ifm-color-secondary)",
@@ -9,12 +9,14 @@ export declare enum Color {
9
9
  Danger = "var(--ifm-color-danger)",
10
10
  Link = "var(--ifm-color-link)"
11
11
  }
12
- interface Props {
12
+ export interface Props {
13
13
  icon: keyof typeof Icons;
14
14
  size?: number | string;
15
15
  spin?: boolean;
16
+ rotate?: number;
16
17
  color?: string;
17
18
  className?: string;
18
19
  }
19
20
  declare const Icon: (props: Props) => React.JSX.Element;
20
21
  export default Icon;
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/theme/CodeEditor/Icon/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,KAAK,MAAM,8BAA8B,CAAC;AAItD,oBAAY,KAAK;IACb,OAAO,6BAA6B;IACpC,SAAS,+BAA+B;IACxC,OAAO,6BAA6B;IACpC,IAAI,0BAA0B;IAC9B,OAAO,6BAA6B;IACpC,MAAM,4BAA4B;IAClC,IAAI,0BAA0B;CACjC;AAED,MAAM,WAAW,KAAK;IAClB,IAAI,EAAE,MAAM,OAAO,KAAK,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,QAAA,MAAM,IAAI,GAAI,OAAO,KAAK,sBAsCzB,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import * as Icons from 'docusaurus-live-brython/theme/CodeEditor/Icon/icons';
2
+ import * as Icons from '@theme/CodeEditor/Icon/icons';
3
3
  import styles from './styles.module.css';
4
4
  import clsx from 'clsx';
5
5
  export var Color;
@@ -17,12 +17,19 @@ const Icon = (props) => {
17
17
  if (props.spin) {
18
18
  return (<svg viewBox="0 0 24 24" role="presentation" style={{ width: size, height: size }} className={clsx(props.className, styles.icon, styles.spin)}>
19
19
  <style>{`@keyframes spin-inverse { to { transform: rotate(-360deg) } }`}</style>
20
- <g style={{ animation: '2s linear 0s infinite normal none running spin-inverse', transformOrigin: 'center center' }}>
20
+ <g style={{
21
+ animation: '2s linear 0s infinite normal none running spin-inverse',
22
+ transformOrigin: 'center center'
23
+ }}>
21
24
  <path d={Icons[props.icon]} style={{ fill: props.color || 'currentcolor' }}></path>
22
25
  </g>
23
26
  </svg>);
24
27
  }
25
- return (<svg viewBox="0 0 24 24" role="presentation" style={{ width: size, height: size }} className={clsx(props.className, styles.icon)}>
28
+ return (<svg viewBox="0 0 24 24" role="presentation" style={{
29
+ width: size,
30
+ height: size,
31
+ transform: `translateY(15%) rotate(${props.rotate || 0}deg)`
32
+ }} className={clsx(props.className, styles.icon)}>
26
33
  <path d={Icons[props.icon]} style={{ fill: props.color || 'currentcolor' }}></path>
27
34
  </svg>);
28
35
  };
@@ -1,3 +1,3 @@
1
1
  .icon {
2
2
  transform: translateY(15%);
3
- }
3
+ }
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { type InitState, type Document } from '@theme/CodeEditor/WithScript/Types';
3
+ export declare const Context: React.Context<Document<import("@theme/CodeEditor/WithScript/Types").Script>>;
4
+ declare const ScriptContext: (props: InitState & {
5
+ children: React.ReactNode;
6
+ }) => React.JSX.Element;
7
+ export default ScriptContext;
8
+ //# sourceMappingURL=ScriptContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScriptContext.d.ts","sourceRoot":"","sources":["../../../../src/theme/CodeEditor/WithScript/ScriptContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAKnF,eAAO,MAAM,OAAO,8EAAuD,CAAC;AAE5E,QAAA,MAAM,aAAa,GAAI,OAAO,SAAS,GAAG;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,sBAwBtE,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import { usePluginData } from '@docusaurus/useGlobalData';
3
+ import { createStore } from '@theme/CodeEditor/WithScript/createStore';
4
+ import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
5
+ import BrowserOnly from '@docusaurus/BrowserOnly';
6
+ import CodeBlock from '@theme/CodeBlock';
7
+ export const Context = React.createContext(undefined);
8
+ const ScriptContext = (props) => {
9
+ const { libDir, syncMaxOnceEvery } = usePluginData('docusaurus-live-brython');
10
+ const [store, setStore] = React.useState(null);
11
+ const { siteConfig } = useDocusaurusContext();
12
+ React.useEffect(() => {
13
+ const router = siteConfig.future.experimental_router;
14
+ const store = createStore(props, libDir, syncMaxOnceEvery, router);
15
+ setStore(store);
16
+ store.load();
17
+ }, [props.id, libDir, siteConfig]);
18
+ return (<BrowserOnly fallback={<CodeBlock language={props.lang}>{props.code}</CodeBlock>}>
19
+ {() => {
20
+ if (!store) {
21
+ return <CodeBlock language={props.lang}>{props.code}</CodeBlock>;
22
+ }
23
+ return <Context.Provider value={store}>{props.children}</Context.Provider>;
24
+ }}
25
+ </BrowserOnly>);
26
+ };
27
+ export default ScriptContext;
@@ -1,3 +1,4 @@
1
- import type { StorageSlot, StoredScript } from "docusaurus-live-brython/theme/CodeEditor/WithScript/Types";
1
+ import type { StorageSlot, StoredScript } from '@theme/CodeEditor/WithScript/Types';
2
2
  export declare const getStorageScript: (storage: StorageSlot) => StoredScript | undefined;
3
3
  export declare const syncStorageScript: (script: StoredScript, storage: StorageSlot) => boolean;
4
+ //# sourceMappingURL=Storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Storage.d.ts","sourceRoot":"","sources":["../../../../src/theme/CodeEditor/WithScript/Storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAEpF,eAAO,MAAM,gBAAgB,GAAI,SAAS,WAAW,KAAG,YAAY,GAAG,SActE,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,QAAQ,YAAY,EAAE,SAAS,WAAW,KAAG,OAQ9E,CAAC"}
@@ -10,6 +10,7 @@ export interface StoredScript {
10
10
  updatedAt: Date;
11
11
  versions: Version[];
12
12
  }
13
+ export type Selector<T, R> = (state: T) => R;
13
14
  export interface Script extends StoredScript {
14
15
  /**
15
16
  * this is normally a uuid
@@ -27,16 +28,17 @@ export interface Script extends StoredScript {
27
28
  showRaw: boolean;
28
29
  isExecuting?: boolean;
29
30
  preCode: string;
31
+ postCode: string;
30
32
  lang: 'py' | string;
31
33
  logs: LogMessage[];
32
- isGraphicsmodalOpen: boolean;
34
+ graphicsModalExecutionNr: number;
33
35
  hasGraphicsOutput: boolean;
34
36
  hasTurtleOutput: boolean;
35
37
  hasCanvasOutput: boolean;
36
38
  hasEdits: boolean;
37
39
  /**
38
40
  * Storage props
39
- */
41
+ */
40
42
  isLoaded: boolean;
41
43
  status: Status;
42
44
  versionsLoaded: boolean;
@@ -63,11 +65,13 @@ export interface InitState {
63
65
  id: string | undefined;
64
66
  lang: 'py' | string;
65
67
  title: string;
66
- raw: string;
68
+ code: string;
69
+ preCode: string;
70
+ postCode: string;
67
71
  readonly: boolean;
68
72
  versioned: boolean;
69
73
  }
70
- export interface Store<T = Script> {
74
+ export interface Document<T = Script> {
71
75
  getState: () => T;
72
76
  setState: (fn: (state: Script) => Script) => void;
73
77
  subscribe: (listener: () => void) => () => void;
@@ -81,4 +85,8 @@ export interface Store<T = Script> {
81
85
  clearLogMessages: () => void;
82
86
  load: () => Promise<Status>;
83
87
  loadVersions: () => Promise<void>;
88
+ setIsPasted: (isPasted: boolean) => void;
89
+ setShowRaw: (showRaw: boolean) => void;
90
+ setStatus: (status: Status) => void;
84
91
  }
92
+ //# sourceMappingURL=Types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Types.d.ts","sourceRoot":"","sources":["../../../../src/theme/CodeEditor/WithScript/Types.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,3 @@
1
+ import { RouterType } from '@docusaurus/types';
2
+ export declare const runCode: (code: string, preCode: string, postCode: string, codeId: string, libDir: string, router: RouterType, cache?: boolean) => string;
3
+ //# sourceMappingURL=bryRunner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bryRunner.d.ts","sourceRoot":"","sources":["../../../../src/theme/CodeEditor/WithScript/bryRunner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI/C,eAAO,MAAM,OAAO,GAChB,MAAM,MAAM,EACZ,SAAS,MAAM,EACf,UAAU,MAAM,EAChB,QAAQ,MAAM,EACd,QAAQ,MAAM,EACd,QAAQ,UAAU,EAClB,QAAO,OAAc,WA2BxB,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { DOM_ELEMENT_IDS } from '../constants';
2
+ import { sanitizePyScript } from './helpers';
3
+ export const runCode = (code, preCode, postCode, codeId, libDir, router, cache = true) => {
4
+ const lineShift = preCode
5
+ .trim()
6
+ .split(/\n/)
7
+ .filter((l) => l.length > 0).length;
8
+ const pre = lineShift > 0 ? `${preCode.trim()}\n` : '';
9
+ const post = postCode.trim().length > 0 ? `\n${postCode.trim()}` : '';
10
+ const toExec = `${pre}${code}${post}`;
11
+ const src = `from brython_runner import run\nrun("""${sanitizePyScript(toExec || '')}""", '${codeId}', ${lineShift})\n`;
12
+ if (!window.__BRYTHON__) {
13
+ alert('Brython not loaded');
14
+ return;
15
+ }
16
+ const active = document.getElementById(DOM_ELEMENT_IDS.communicator(codeId));
17
+ active.setAttribute('data--start-time', `${Date.now()}`);
18
+ /**
19
+ * ensure that the script is executed after the current event loop.
20
+ * Otherwise, the brython script will not be able to access the graphics output.
21
+ */
22
+ setTimeout(() => {
23
+ window.__BRYTHON__.runPythonSource(src, {
24
+ pythonpath: router === 'hash' ? [] : [libDir],
25
+ cache: cache
26
+ });
27
+ }, 0);
28
+ return src;
29
+ };
@@ -0,0 +1,4 @@
1
+ import { type InitState, type Document } from '@theme/CodeEditor/WithScript/Types';
2
+ import { RouterType } from '@docusaurus/types';
3
+ export declare const createStore: (props: InitState, libDir: string, syncMaxOnceEvery: number, router: RouterType) => Document;
4
+ //# sourceMappingURL=createStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createStore.d.ts","sourceRoot":"","sources":["../../../../src/theme/CodeEditor/WithScript/createStore.ts"],"names":[],"mappings":"AAQA,OAAO,EACH,KAAK,SAAS,EAId,KAAK,QAAQ,EAGhB,MAAM,oCAAoC,CAAC;AAG5C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,eAAO,MAAM,WAAW,GACpB,OAAO,SAAS,EAChB,QAAQ,MAAM,EACd,kBAAkB,MAAM,EACxB,QAAQ,UAAU,KACnB,QAwPF,CAAC"}