@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
@@ -1,21 +0,0 @@
1
- from pyscript import document
2
- from pyscript.web.elements import Element, ElementCollection
3
-
4
-
5
- class PyDom:
6
- # Add objects we want to expose to the DOM namespace since this class instance is being
7
- # remapped as "the module" itself
8
- ElementCollection = ElementCollection
9
-
10
- def __init__(self):
11
- self._js = document
12
-
13
- self.body = Element(document.body)
14
- self.head = Element(document.head)
15
-
16
- def __getitem__(self, key):
17
- elements = self._js.querySelectorAll(key)
18
- return ElementCollection([Element(el) for el in elements])
19
-
20
-
21
- dom = PyDom()
@@ -1,95 +0,0 @@
1
- from pyodide.ffi import to_js
2
- from pyscript import window
3
-
4
-
5
- class Device:
6
- """Device represents a media input or output device, such as a microphone,
7
- camera, or headset.
8
- """
9
-
10
- def __init__(self, device):
11
- self._js = device
12
-
13
- @property
14
- def id(self):
15
- return self._js.deviceId
16
-
17
- @property
18
- def group(self):
19
- return self._js.groupId
20
-
21
- @property
22
- def kind(self):
23
- return self._js.kind
24
-
25
- @property
26
- def label(self):
27
- return self._js.label
28
-
29
- def __getitem__(self, key):
30
- return getattr(self, key)
31
-
32
- @classmethod
33
- async def load(cls, audio=False, video=True):
34
- """Load the device stream."""
35
- options = window.Object.new()
36
- options.audio = audio
37
- if isinstance(video, bool):
38
- options.video = video
39
- else:
40
- # TODO: Think this can be simplified but need to check it on the pyodide side
41
-
42
- # TODO: this is pyodide specific. shouldn't be!
43
- options.video = window.Object.new()
44
- for k in video:
45
- setattr(
46
- options.video,
47
- k,
48
- to_js(video[k], dict_converter=window.Object.fromEntries),
49
- )
50
-
51
- stream = await window.navigator.mediaDevices.getUserMedia(options)
52
- return stream
53
-
54
- async def get_stream(self):
55
- key = self.kind.replace("input", "").replace("output", "")
56
- options = {key: {"deviceId": {"exact": self.id}}}
57
-
58
- return await self.load(**options)
59
-
60
-
61
- async def list_devices() -> list[dict]:
62
- """
63
- Return the list of the currently available media input and output devices,
64
- such as microphones, cameras, headsets, and so forth.
65
-
66
- Output:
67
-
68
- list(dict) - list of dictionaries representing the available media devices.
69
- Each dictionary has the following keys:
70
- * deviceId: a string that is an identifier for the represented device
71
- that is persisted across sessions. It is un-guessable by other
72
- applications and unique to the origin of the calling application.
73
- It is reset when the user clears cookies (for Private Browsing, a
74
- different identifier is used that is not persisted across sessions).
75
-
76
- * groupId: a string that is a group identifier. Two devices have the same
77
- group identifier if they belong to the same physical device — for
78
- example a monitor with both a built-in camera and a microphone.
79
-
80
- * kind: an enumerated value that is either "videoinput", "audioinput"
81
- or "audiooutput".
82
-
83
- * label: a string describing this device (for example "External USB
84
- Webcam").
85
-
86
- Note: the returned list will omit any devices that are blocked by the document
87
- Permission Policy: microphone, camera, speaker-selection (for output devices),
88
- and so on. Access to particular non-default devices is also gated by the
89
- Permissions API, and the list will omit devices for which the user has not
90
- granted explicit permission.
91
- """
92
- # https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/enumerateDevices
93
- return [
94
- Device(obj) for obj in await window.navigator.mediaDevices.enumerateDevices()
95
- ]
@@ -1,2 +0,0 @@
1
- from .pydom import JSProperty
2
- from .pydom import dom as pydom
@@ -1,95 +0,0 @@
1
- from pyodide.ffi import to_js
2
- from pyscript import window
3
-
4
-
5
- class Device:
6
- """Device represents a media input or output device, such as a microphone,
7
- camera, or headset.
8
- """
9
-
10
- def __init__(self, device):
11
- self._js = device
12
-
13
- @property
14
- def id(self):
15
- return self._js.deviceId
16
-
17
- @property
18
- def group(self):
19
- return self._js.groupId
20
-
21
- @property
22
- def kind(self):
23
- return self._js.kind
24
-
25
- @property
26
- def label(self):
27
- return self._js.label
28
-
29
- def __getitem__(self, key):
30
- return getattr(self, key)
31
-
32
- @classmethod
33
- async def load(cls, audio=False, video=True):
34
- """Load the device stream."""
35
- options = window.Object.new()
36
- options.audio = audio
37
- if isinstance(video, bool):
38
- options.video = video
39
- else:
40
- # TODO: Think this can be simplified but need to check it on the pyodide side
41
-
42
- # TODO: this is pyodide specific. shouldn't be!
43
- options.video = window.Object.new()
44
- for k in video:
45
- setattr(
46
- options.video,
47
- k,
48
- to_js(video[k], dict_converter=window.Object.fromEntries),
49
- )
50
-
51
- stream = await window.navigator.mediaDevices.getUserMedia(options)
52
- return stream
53
-
54
- async def get_stream(self):
55
- key = self.kind.replace("input", "").replace("output", "")
56
- options = {key: {"deviceId": {"exact": self.id}}}
57
-
58
- return await self.load(**options)
59
-
60
-
61
- async def list_devices() -> list[dict]:
62
- """
63
- Return the list of the currently available media input and output devices,
64
- such as microphones, cameras, headsets, and so forth.
65
-
66
- Output:
67
-
68
- list(dict) - list of dictionaries representing the available media devices.
69
- Each dictionary has the following keys:
70
- * deviceId: a string that is an identifier for the represented device
71
- that is persisted across sessions. It is un-guessable by other
72
- applications and unique to the origin of the calling application.
73
- It is reset when the user clears cookies (for Private Browsing, a
74
- different identifier is used that is not persisted across sessions).
75
-
76
- * groupId: a string that is a group identifier. Two devices have the same
77
- group identifier if they belong to the same physical device — for
78
- example a monitor with both a built-in camera and a microphone.
79
-
80
- * kind: an enumerated value that is either "videoinput", "audioinput"
81
- or "audiooutput".
82
-
83
- * label: a string describing this device (for example "External USB
84
- Webcam").
85
-
86
- Note: the returned list will omit any devices that are blocked by the document
87
- Permission Policy: microphone, camera, speaker-selection (for output devices),
88
- and so on. Access to particular non-default devices is also gated by the
89
- Permissions API, and the list will omit devices for which the user has not
90
- granted explicit permission.
91
- """
92
- # https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/enumerateDevices
93
- return [
94
- Device(obj) for obj in await window.navigator.mediaDevices.enumerateDevices()
95
- ]