@pyscript/core 0.4.54 → 0.4.56

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 (50) hide show
  1. package/dist/{codemirror-uEsvwGeX.js → codemirror-BZEh__gm.js} +2 -2
  2. package/dist/{codemirror-uEsvwGeX.js.map → codemirror-BZEh__gm.js.map} +1 -1
  3. package/dist/{codemirror_commands-BjErX5JV.js → codemirror_commands-leH8shna.js} +2 -2
  4. package/dist/{codemirror_commands-BjErX5JV.js.map → codemirror_commands-leH8shna.js.map} +1 -1
  5. package/dist/{codemirror_lang-python-rjOo-iGF.js → codemirror_lang-python-DuOzopOD.js} +2 -2
  6. package/dist/{codemirror_lang-python-rjOo-iGF.js.map → codemirror_lang-python-DuOzopOD.js.map} +1 -1
  7. package/dist/{codemirror_language-oTnz5LmX.js → codemirror_language-Dakzaxks.js} +2 -2
  8. package/dist/{codemirror_language-oTnz5LmX.js.map → codemirror_language-Dakzaxks.js.map} +1 -1
  9. package/dist/codemirror_view-Bm5_2vT5.js +2 -0
  10. package/dist/codemirror_view-Bm5_2vT5.js.map +1 -0
  11. package/dist/core-DKrwnOQh.js +3 -0
  12. package/dist/core-DKrwnOQh.js.map +1 -0
  13. package/dist/core.js +1 -1
  14. package/dist/{deprecations-manager-BxzDUsLg.js → deprecations-manager-BYGF73-y.js} +2 -2
  15. package/dist/{deprecations-manager-BxzDUsLg.js.map → deprecations-manager-BYGF73-y.js.map} +1 -1
  16. package/dist/{error-BiBuvdCh.js → error-DgYfWJQg.js} +2 -2
  17. package/dist/{error-BiBuvdCh.js.map → error-DgYfWJQg.js.map} +1 -1
  18. package/dist/{index-DvH26nkT.js → index-DA5aljNV.js} +2 -2
  19. package/dist/{index-DvH26nkT.js.map → index-DA5aljNV.js.map} +1 -1
  20. package/dist/{mpy-C8arSQdw.js → mpy-DiqSc6w9.js} +2 -2
  21. package/dist/mpy-DiqSc6w9.js.map +1 -0
  22. package/dist/{py-CQbAin00.js → py-DEubHlb_.js} +2 -2
  23. package/dist/{py-CQbAin00.js.map → py-DEubHlb_.js.map} +1 -1
  24. package/dist/{py-editor-Cd7PRgND.js → py-editor-DHmqLMO5.js} +2 -2
  25. package/dist/{py-editor-Cd7PRgND.js.map → py-editor-DHmqLMO5.js.map} +1 -1
  26. package/dist/{py-terminal-DCvjFHnO.js → py-terminal-E6BBcU6N.js} +2 -2
  27. package/dist/{py-terminal-DCvjFHnO.js.map → py-terminal-E6BBcU6N.js.map} +1 -1
  28. package/dist/{zip-BxogYCy6.js → zip-CGWtiqjJ.js} +2 -2
  29. package/dist/zip-CGWtiqjJ.js.map +1 -0
  30. package/package.json +7 -7
  31. package/src/plugins/py-terminal/mpy.js +19 -7
  32. package/src/stdlib/pyscript/event_handling.py +13 -12
  33. package/src/stdlib/pyscript/web/__init__.py +18 -4
  34. package/src/stdlib/pyscript/web/elements.py +898 -723
  35. package/src/stdlib/pyscript.js +3 -14
  36. package/types/core.d.ts +1 -1
  37. package/types/stdlib/pyscript.d.ts +0 -11
  38. package/dist/codemirror_view-CH_aW-qU.js +0 -2
  39. package/dist/codemirror_view-CH_aW-qU.js.map +0 -1
  40. package/dist/core-DsWVYGyA.js +0 -3
  41. package/dist/core-DsWVYGyA.js.map +0 -1
  42. package/dist/mpy-C8arSQdw.js.map +0 -1
  43. package/dist/zip-BxogYCy6.js.map +0 -1
  44. package/src/stdlib/pyscript/web/dom.py +0 -21
  45. package/src/stdlib/pyscript/web/media.py +0 -95
  46. package/src/stdlib/pyweb/__init__.py +0 -2
  47. package/src/stdlib/pyweb/media.py +0 -95
  48. package/src/stdlib/pyweb/pydom.py +0 -569
  49. package/src/stdlib/pyweb/ui/__init__.py +0 -1
  50. package/src/stdlib/pyweb/ui/elements.py +0 -947
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pyscript/core",
3
- "version": "0.4.54",
3
+ "version": "0.4.56",
4
4
  "type": "module",
5
5
  "description": "PyScript",
6
6
  "module": "./index.js",
@@ -44,7 +44,7 @@
44
44
  "dependencies": {
45
45
  "@ungap/with-resolvers": "^0.1.0",
46
46
  "basic-devtools": "^0.1.6",
47
- "polyscript": "^0.13.8",
47
+ "polyscript": "^0.13.10",
48
48
  "sticky-module": "^0.1.1",
49
49
  "to-json-callback": "^0.1.1",
50
50
  "type-checked-collections": "^0.1.7"
@@ -54,20 +54,20 @@
54
54
  "@codemirror/lang-python": "^6.1.6",
55
55
  "@codemirror/language": "^6.10.2",
56
56
  "@codemirror/state": "^6.4.1",
57
- "@codemirror/view": "^6.28.3",
58
- "@playwright/test": "^1.45.1",
57
+ "@codemirror/view": "^6.28.5",
58
+ "@playwright/test": "^1.45.2",
59
59
  "@rollup/plugin-commonjs": "^26.0.1",
60
60
  "@rollup/plugin-node-resolve": "^15.2.3",
61
61
  "@rollup/plugin-terser": "^0.4.4",
62
62
  "@webreflection/toml-j0.4": "^1.1.3",
63
63
  "@xterm/addon-fit": "^0.10.0",
64
64
  "@xterm/addon-web-links": "^0.11.0",
65
- "bun": "^1.1.17",
65
+ "bun": "^1.1.20",
66
66
  "chokidar": "^3.6.0",
67
67
  "codemirror": "^6.0.1",
68
- "eslint": "^9.6.0",
68
+ "eslint": "^9.7.0",
69
69
  "flatted": "^3.3.1",
70
- "rollup": "^4.18.0",
70
+ "rollup": "^4.18.1",
71
71
  "rollup-plugin-postcss": "^4.0.2",
72
72
  "rollup-plugin-string": "^3.0.0",
73
73
  "static-handler": "^0.4.3",
@@ -164,13 +164,25 @@ export default async (element) => {
164
164
  };
165
165
  terminal.onData((buffer) => {
166
166
  if (promisedChunks) {
167
- readChunks += buffer;
168
- terminal.write(buffer);
169
- if (readChunks.endsWith("\r")) {
170
- terminal.write("\n");
171
- promisedChunks.resolve(readChunks.slice(0, -1));
172
- promisedChunks = null;
173
- readChunks = "";
167
+ // handle backspace on input
168
+ if (buffer === "\x7f") {
169
+ // avoid over-greedy backspace
170
+ if (readChunks.length) {
171
+ readChunks = readChunks.slice(0, -1);
172
+ // override previous char position
173
+ // put an empty space to clear the char
174
+ // move back position again
175
+ buffer = "\b \b";
176
+ } else buffer = "";
177
+ } else readChunks += buffer;
178
+ if (buffer) {
179
+ terminal.write(buffer);
180
+ if (readChunks.endsWith("\r")) {
181
+ terminal.write("\n");
182
+ promisedChunks.resolve(readChunks.slice(0, -1));
183
+ promisedChunks = null;
184
+ readChunks = "";
185
+ }
174
186
  }
175
187
  } else {
176
188
  stream.write(buffer);
@@ -19,22 +19,23 @@ def when(event_type=None, selector=None):
19
19
  """
20
20
 
21
21
  def decorator(func):
22
+
23
+ from pyscript.web.elements import Element, ElementCollection
24
+
22
25
  if isinstance(selector, str):
23
26
  elements = document.querySelectorAll(selector)
27
+ # TODO: This is a hack that will be removed when pyscript becomes a package
28
+ # and we can better manage the imports without circular dependencies
29
+ elif isinstance(selector, Element):
30
+ elements = [selector._dom_element]
31
+ elif isinstance(selector, ElementCollection):
32
+ elements = [el._dom_element for el in selector]
24
33
  else:
25
- # TODO: This is a hack that will be removed when pyscript becomes a package
26
- # and we can better manage the imports without circular dependencies
27
- from pyweb import pydom
28
-
29
- if isinstance(selector, pydom.Element):
30
- elements = [selector._js]
31
- elif isinstance(selector, pydom.ElementCollection):
32
- elements = [el._js for el in selector]
34
+ if isinstance(selector, list):
35
+ elements = selector
33
36
  else:
34
- raise ValueError(
35
- f"Invalid selector: {selector}. Selector must"
36
- " be a string, a pydom.Element or a pydom.ElementCollection."
37
- )
37
+ elements = [selector]
38
+
38
39
  try:
39
40
  sig = inspect.signature(func)
40
41
  # Function doesn't receive events
@@ -1,5 +1,19 @@
1
- from . import elements
1
+ from pyscript import document
2
+ from pyscript.web.elements import ElementCollection, element_from_dom
2
3
 
3
- # Ugly trick to hide the dom module in the web package since we want the module
4
- # to allow querying right away.
5
- from .dom import dom
4
+
5
+ class DOM:
6
+ def __init__(self):
7
+ self.body = element_from_dom(document.body)
8
+ self.head = element_from_dom(document.head)
9
+
10
+ def __getitem__(self, selector):
11
+ return self.find(selector)
12
+
13
+ def find(self, selector):
14
+ return ElementCollection(
15
+ [element_from_dom(el) for el in document.querySelectorAll(selector)]
16
+ )
17
+
18
+
19
+ dom = DOM()