@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.
- package/dist/{codemirror-uEsvwGeX.js → codemirror-BZEh__gm.js} +2 -2
- package/dist/{codemirror-uEsvwGeX.js.map → codemirror-BZEh__gm.js.map} +1 -1
- package/dist/{codemirror_commands-BjErX5JV.js → codemirror_commands-leH8shna.js} +2 -2
- package/dist/{codemirror_commands-BjErX5JV.js.map → codemirror_commands-leH8shna.js.map} +1 -1
- package/dist/{codemirror_lang-python-rjOo-iGF.js → codemirror_lang-python-DuOzopOD.js} +2 -2
- package/dist/{codemirror_lang-python-rjOo-iGF.js.map → codemirror_lang-python-DuOzopOD.js.map} +1 -1
- package/dist/{codemirror_language-oTnz5LmX.js → codemirror_language-Dakzaxks.js} +2 -2
- package/dist/{codemirror_language-oTnz5LmX.js.map → codemirror_language-Dakzaxks.js.map} +1 -1
- package/dist/codemirror_view-Bm5_2vT5.js +2 -0
- package/dist/codemirror_view-Bm5_2vT5.js.map +1 -0
- package/dist/core-DKrwnOQh.js +3 -0
- package/dist/core-DKrwnOQh.js.map +1 -0
- package/dist/core.js +1 -1
- package/dist/{deprecations-manager-BxzDUsLg.js → deprecations-manager-BYGF73-y.js} +2 -2
- package/dist/{deprecations-manager-BxzDUsLg.js.map → deprecations-manager-BYGF73-y.js.map} +1 -1
- package/dist/{error-BiBuvdCh.js → error-DgYfWJQg.js} +2 -2
- package/dist/{error-BiBuvdCh.js.map → error-DgYfWJQg.js.map} +1 -1
- package/dist/{index-DvH26nkT.js → index-DA5aljNV.js} +2 -2
- package/dist/{index-DvH26nkT.js.map → index-DA5aljNV.js.map} +1 -1
- package/dist/{mpy-C8arSQdw.js → mpy-DiqSc6w9.js} +2 -2
- package/dist/mpy-DiqSc6w9.js.map +1 -0
- package/dist/{py-CQbAin00.js → py-DEubHlb_.js} +2 -2
- package/dist/{py-CQbAin00.js.map → py-DEubHlb_.js.map} +1 -1
- package/dist/{py-editor-Cd7PRgND.js → py-editor-DHmqLMO5.js} +2 -2
- package/dist/{py-editor-Cd7PRgND.js.map → py-editor-DHmqLMO5.js.map} +1 -1
- package/dist/{py-terminal-DCvjFHnO.js → py-terminal-E6BBcU6N.js} +2 -2
- package/dist/{py-terminal-DCvjFHnO.js.map → py-terminal-E6BBcU6N.js.map} +1 -1
- package/dist/{zip-BxogYCy6.js → zip-CGWtiqjJ.js} +2 -2
- package/dist/zip-CGWtiqjJ.js.map +1 -0
- package/package.json +7 -7
- package/src/plugins/py-terminal/mpy.js +19 -7
- package/src/stdlib/pyscript/event_handling.py +13 -12
- package/src/stdlib/pyscript/web/__init__.py +18 -4
- package/src/stdlib/pyscript/web/elements.py +898 -723
- package/src/stdlib/pyscript.js +3 -14
- package/types/core.d.ts +1 -1
- package/types/stdlib/pyscript.d.ts +0 -11
- package/dist/codemirror_view-CH_aW-qU.js +0 -2
- package/dist/codemirror_view-CH_aW-qU.js.map +0 -1
- package/dist/core-DsWVYGyA.js +0 -3
- package/dist/core-DsWVYGyA.js.map +0 -1
- package/dist/mpy-C8arSQdw.js.map +0 -1
- package/dist/zip-BxogYCy6.js.map +0 -1
- package/src/stdlib/pyscript/web/dom.py +0 -21
- package/src/stdlib/pyscript/web/media.py +0 -95
- package/src/stdlib/pyweb/__init__.py +0 -2
- package/src/stdlib/pyweb/media.py +0 -95
- package/src/stdlib/pyweb/pydom.py +0 -569
- package/src/stdlib/pyweb/ui/__init__.py +0 -1
- 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,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
|
-
]
|