pulse-framework 0.1.74__py3-none-any.whl → 0.1.75__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.
- pulse/js/__init__.py +36 -0
- pulse/js/__init__.pyi +48 -0
- pulse/js/abort_controller.py +61 -0
- pulse/js/array_buffer.py +227 -0
- pulse/js/blob.py +60 -0
- pulse/js/crypto.py +69 -0
- pulse/js/custom_event.py +49 -0
- pulse/js/dom_parser.py +40 -0
- pulse/js/fetch_api.py +126 -0
- pulse/js/file.py +72 -0
- pulse/js/file_reader.py +37 -0
- pulse/js/form_data.py +58 -0
- pulse/js/intersection_observer.py +79 -0
- pulse/js/intl.py +101 -0
- pulse/js/mutation_observer.py +87 -0
- pulse/js/performance_observer.py +54 -0
- pulse/js/resize_observer.py +55 -0
- pulse/js/text_encoding.py +66 -0
- pulse/js/url.py +114 -0
- {pulse_framework-0.1.74.dist-info → pulse_framework-0.1.75.dist-info}/METADATA +1 -1
- {pulse_framework-0.1.74.dist-info → pulse_framework-0.1.75.dist-info}/RECORD +23 -6
- {pulse_framework-0.1.74.dist-info → pulse_framework-0.1.75.dist-info}/WHEEL +0 -0
- {pulse_framework-0.1.74.dist-info → pulse_framework-0.1.75.dist-info}/entry_points.txt +0 -0
pulse/js/fetch_api.py
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"""
|
|
2
|
+
JavaScript Fetch API builtins.
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
|
|
6
|
+
```python
|
|
7
|
+
from pulse.js import fetch, Request, Headers, obj
|
|
8
|
+
|
|
9
|
+
@ps.javascript
|
|
10
|
+
async def example():
|
|
11
|
+
req = Request("/api", obj(method="GET"))
|
|
12
|
+
res = await fetch(req)
|
|
13
|
+
return res.json()
|
|
14
|
+
```
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
from collections.abc import Callable as _Callable
|
|
20
|
+
from typing import Any as _Any
|
|
21
|
+
from typing import TypedDict as _TypedDict
|
|
22
|
+
|
|
23
|
+
from pulse.js.abort_controller import AbortSignal
|
|
24
|
+
from pulse.transpiler.js_module import JsModule
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class RequestInit(_TypedDict, total=False):
|
|
28
|
+
method: str
|
|
29
|
+
headers: _Any
|
|
30
|
+
body: _Any
|
|
31
|
+
mode: str
|
|
32
|
+
credentials: str
|
|
33
|
+
cache: str
|
|
34
|
+
redirect: str
|
|
35
|
+
referrer: str
|
|
36
|
+
referrerPolicy: str
|
|
37
|
+
integrity: str
|
|
38
|
+
keepalive: bool
|
|
39
|
+
signal: AbortSignal
|
|
40
|
+
window: _Any
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class ResponseInit(_TypedDict, total=False):
|
|
44
|
+
status: int
|
|
45
|
+
statusText: str
|
|
46
|
+
headers: _Any
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class Headers:
|
|
50
|
+
"""HTTP headers for fetch requests/responses."""
|
|
51
|
+
|
|
52
|
+
def __init__(self, init: _Any | None = None, /) -> None: ...
|
|
53
|
+
|
|
54
|
+
def append(self, name: str, value: str, /) -> None: ...
|
|
55
|
+
|
|
56
|
+
def delete(self, name: str, /) -> None: ...
|
|
57
|
+
|
|
58
|
+
def get(self, name: str, /) -> str | None: ...
|
|
59
|
+
|
|
60
|
+
def has(self, name: str, /) -> bool: ...
|
|
61
|
+
|
|
62
|
+
def set(self, name: str, value: str, /) -> None: ...
|
|
63
|
+
|
|
64
|
+
def forEach(
|
|
65
|
+
self,
|
|
66
|
+
callback: _Callable[[str, str, "Headers"], None],
|
|
67
|
+
thisArg: _Any | None = None,
|
|
68
|
+
/,
|
|
69
|
+
) -> None: ...
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class Request:
|
|
73
|
+
"""Represents a resource request."""
|
|
74
|
+
|
|
75
|
+
def __init__(
|
|
76
|
+
self, input: str | Request, init: RequestInit | None = None, /
|
|
77
|
+
) -> None: ...
|
|
78
|
+
|
|
79
|
+
@property
|
|
80
|
+
def url(self) -> str: ...
|
|
81
|
+
|
|
82
|
+
@property
|
|
83
|
+
def method(self) -> str: ...
|
|
84
|
+
|
|
85
|
+
@property
|
|
86
|
+
def headers(self) -> Headers: ...
|
|
87
|
+
|
|
88
|
+
@property
|
|
89
|
+
def body(self) -> _Any: ...
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class Response:
|
|
93
|
+
"""Represents a response to a request."""
|
|
94
|
+
|
|
95
|
+
def __init__(
|
|
96
|
+
self, body: _Any | None = None, init: ResponseInit | None = None, /
|
|
97
|
+
) -> None: ...
|
|
98
|
+
|
|
99
|
+
@property
|
|
100
|
+
def status(self) -> int: ...
|
|
101
|
+
|
|
102
|
+
@property
|
|
103
|
+
def ok(self) -> bool: ...
|
|
104
|
+
|
|
105
|
+
@property
|
|
106
|
+
def headers(self) -> Headers: ...
|
|
107
|
+
|
|
108
|
+
@property
|
|
109
|
+
def body(self) -> _Any: ...
|
|
110
|
+
|
|
111
|
+
def json(self) -> _Any: ...
|
|
112
|
+
|
|
113
|
+
def text(self) -> _Any: ...
|
|
114
|
+
|
|
115
|
+
def blob(self) -> _Any: ...
|
|
116
|
+
|
|
117
|
+
def formData(self) -> _Any: ...
|
|
118
|
+
|
|
119
|
+
def arrayBuffer(self) -> _Any: ...
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def fetch(input: str | Request, init: RequestInit | None = None, /) -> _Any: ...
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
# Self-register this module as a JS builtin (global identifiers)
|
|
126
|
+
JsModule.register(name=None)
|
pulse/js/file.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"""
|
|
2
|
+
JavaScript File builtin.
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
|
|
6
|
+
```python
|
|
7
|
+
from pulse.js import File, obj
|
|
8
|
+
|
|
9
|
+
@ps.javascript
|
|
10
|
+
def example():
|
|
11
|
+
f = File(["hello"], "greeting.txt", obj(type="text/plain"))
|
|
12
|
+
return f.name
|
|
13
|
+
```
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from typing import Any as _Any
|
|
17
|
+
from typing import TypedDict as _TypedDict
|
|
18
|
+
|
|
19
|
+
from pulse.transpiler.js_module import JsModule
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class FilePropertyBag(_TypedDict, total=False):
|
|
23
|
+
type: str
|
|
24
|
+
endings: str
|
|
25
|
+
lastModified: int
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class File:
|
|
29
|
+
"""File object backed by a Blob."""
|
|
30
|
+
|
|
31
|
+
def __init__(
|
|
32
|
+
self,
|
|
33
|
+
fileBits: list[_Any],
|
|
34
|
+
fileName: str,
|
|
35
|
+
options: FilePropertyBag | None = None,
|
|
36
|
+
/,
|
|
37
|
+
) -> None: ...
|
|
38
|
+
|
|
39
|
+
@property
|
|
40
|
+
def name(self) -> str: ...
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def lastModified(self) -> int: ...
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
def webkitRelativePath(self) -> str: ...
|
|
47
|
+
|
|
48
|
+
@property
|
|
49
|
+
def size(self) -> int: ...
|
|
50
|
+
|
|
51
|
+
@property
|
|
52
|
+
def type(self) -> str: ...
|
|
53
|
+
|
|
54
|
+
def arrayBuffer(self) -> _Any: ...
|
|
55
|
+
|
|
56
|
+
def bytes(self) -> _Any: ...
|
|
57
|
+
|
|
58
|
+
def slice(
|
|
59
|
+
self,
|
|
60
|
+
start: int | None = None,
|
|
61
|
+
end: int | None = None,
|
|
62
|
+
contentType: str | None = None,
|
|
63
|
+
/,
|
|
64
|
+
) -> "File": ...
|
|
65
|
+
|
|
66
|
+
def stream(self) -> _Any: ...
|
|
67
|
+
|
|
68
|
+
def text(self) -> _Any: ...
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# Self-register this module as a JS builtin (global identifiers)
|
|
72
|
+
JsModule.register(name=None)
|
pulse/js/file_reader.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""
|
|
2
|
+
JavaScript FileReader builtin.
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
|
|
6
|
+
```python
|
|
7
|
+
from pulse.js import FileReader
|
|
8
|
+
|
|
9
|
+
@ps.javascript
|
|
10
|
+
def example(blob):
|
|
11
|
+
reader = FileReader()
|
|
12
|
+
reader.readAsText(blob)
|
|
13
|
+
return reader.result
|
|
14
|
+
```
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from typing import Any as _Any
|
|
18
|
+
|
|
19
|
+
from pulse.transpiler.js_module import JsModule
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class FileReader:
|
|
23
|
+
"""Read File/Blob contents."""
|
|
24
|
+
|
|
25
|
+
@property
|
|
26
|
+
def result(self) -> _Any: ...
|
|
27
|
+
|
|
28
|
+
@property
|
|
29
|
+
def readyState(self) -> int: ...
|
|
30
|
+
|
|
31
|
+
def readAsText(self, blob: _Any, encoding: str | None = None, /) -> None: ...
|
|
32
|
+
|
|
33
|
+
def readAsArrayBuffer(self, blob: _Any, /) -> None: ...
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# Self-register this module as a JS builtin (global identifiers)
|
|
37
|
+
JsModule.register(name=None)
|
pulse/js/form_data.py
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"""
|
|
2
|
+
JavaScript FormData builtin.
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
|
|
6
|
+
```python
|
|
7
|
+
from pulse.js import FormData
|
|
8
|
+
|
|
9
|
+
@ps.javascript
|
|
10
|
+
def example():
|
|
11
|
+
form = FormData()
|
|
12
|
+
form.append("name", "Ada")
|
|
13
|
+
return form.get("name")
|
|
14
|
+
```
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from collections.abc import Callable as _Callable
|
|
18
|
+
from collections.abc import Iterable as _Iterable
|
|
19
|
+
from typing import Any as _Any
|
|
20
|
+
|
|
21
|
+
from pulse.transpiler.js_module import JsModule
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class FormData:
|
|
25
|
+
"""FormData key/value collection for multipart requests."""
|
|
26
|
+
|
|
27
|
+
def __init__(self, form: _Any | None = None, /) -> None: ...
|
|
28
|
+
|
|
29
|
+
def append(
|
|
30
|
+
self, name: str, value: _Any, filename: str | None = None, /
|
|
31
|
+
) -> None: ...
|
|
32
|
+
|
|
33
|
+
def set(self, name: str, value: _Any, filename: str | None = None, /) -> None: ...
|
|
34
|
+
|
|
35
|
+
def delete(self, name: str, /) -> None: ...
|
|
36
|
+
|
|
37
|
+
def get(self, name: str, /) -> _Any | None: ...
|
|
38
|
+
|
|
39
|
+
def getAll(self, name: str, /) -> list[_Any]: ...
|
|
40
|
+
|
|
41
|
+
def has(self, name: str, /) -> bool: ...
|
|
42
|
+
|
|
43
|
+
def entries(self) -> _Iterable[tuple[str, _Any]]: ...
|
|
44
|
+
|
|
45
|
+
def keys(self) -> _Iterable[str]: ...
|
|
46
|
+
|
|
47
|
+
def values(self) -> _Iterable[_Any]: ...
|
|
48
|
+
|
|
49
|
+
def forEach(
|
|
50
|
+
self,
|
|
51
|
+
callback: _Callable[[_Any, str, "FormData"], None],
|
|
52
|
+
thisArg: _Any | None = None,
|
|
53
|
+
/,
|
|
54
|
+
) -> None: ...
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
# Self-register this module as a JS builtin (global identifiers)
|
|
58
|
+
JsModule.register(name=None)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"""
|
|
2
|
+
JavaScript IntersectionObserver builtin.
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
|
|
6
|
+
```python
|
|
7
|
+
from pulse.js import IntersectionObserver, obj
|
|
8
|
+
|
|
9
|
+
@ps.javascript
|
|
10
|
+
def example(target):
|
|
11
|
+
observer = IntersectionObserver(lambda entries, obs: None, obj(threshold=0.5))
|
|
12
|
+
observer.observe(target)
|
|
13
|
+
```
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from collections.abc import Callable as _Callable
|
|
17
|
+
from typing import Any as _Any
|
|
18
|
+
from typing import Protocol as _Protocol
|
|
19
|
+
from typing import TypedDict as _TypedDict
|
|
20
|
+
|
|
21
|
+
from pulse.js._types import Element as _Element
|
|
22
|
+
from pulse.transpiler.js_module import JsModule
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class IntersectionObserverInit(_TypedDict, total=False):
|
|
26
|
+
root: _Any
|
|
27
|
+
rootMargin: str
|
|
28
|
+
scrollMargin: str
|
|
29
|
+
threshold: float | list[float]
|
|
30
|
+
delay: int
|
|
31
|
+
trackVisibility: bool
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class IntersectionObserverEntry(_Protocol):
|
|
35
|
+
@property
|
|
36
|
+
def target(self) -> _Element: ...
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def isIntersecting(self) -> bool: ...
|
|
40
|
+
|
|
41
|
+
@property
|
|
42
|
+
def intersectionRatio(self) -> float: ...
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class IntersectionObserver:
|
|
46
|
+
"""Observe element visibility within a root."""
|
|
47
|
+
|
|
48
|
+
def __init__(
|
|
49
|
+
self,
|
|
50
|
+
callback: _Callable[
|
|
51
|
+
[list[IntersectionObserverEntry], "IntersectionObserver"], None
|
|
52
|
+
],
|
|
53
|
+
options: IntersectionObserverInit | None = None,
|
|
54
|
+
/,
|
|
55
|
+
) -> None: ...
|
|
56
|
+
|
|
57
|
+
def observe(self, target: _Element, /) -> None: ...
|
|
58
|
+
|
|
59
|
+
def unobserve(self, target: _Element, /) -> None: ...
|
|
60
|
+
|
|
61
|
+
def disconnect(self) -> None: ...
|
|
62
|
+
|
|
63
|
+
def takeRecords(self) -> list[IntersectionObserverEntry]: ...
|
|
64
|
+
|
|
65
|
+
@property
|
|
66
|
+
def root(self) -> _Any: ...
|
|
67
|
+
|
|
68
|
+
@property
|
|
69
|
+
def rootMargin(self) -> str: ...
|
|
70
|
+
|
|
71
|
+
@property
|
|
72
|
+
def thresholds(self) -> list[float]: ...
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def trackVisibility(self) -> bool: ...
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
# Self-register this module as a JS builtin (global identifiers)
|
|
79
|
+
JsModule.register(name=None)
|
pulse/js/intl.py
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"""
|
|
2
|
+
JavaScript Intl namespace.
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
|
|
6
|
+
```python
|
|
7
|
+
from pulse.js import Intl
|
|
8
|
+
|
|
9
|
+
@ps.javascript
|
|
10
|
+
def example(value: float):
|
|
11
|
+
fmt = Intl.NumberFormat("en-US")
|
|
12
|
+
return fmt.format(value)
|
|
13
|
+
```
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from typing import Any as _Any
|
|
17
|
+
|
|
18
|
+
from pulse.transpiler.js_module import JsModule
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class Collator:
|
|
22
|
+
def __init__(
|
|
23
|
+
self, locales: _Any | None = None, options: _Any | None = None, /
|
|
24
|
+
) -> None: ...
|
|
25
|
+
|
|
26
|
+
def compare(self, x: str, y: str, /) -> int: ...
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class DateTimeFormat:
|
|
30
|
+
def __init__(
|
|
31
|
+
self, locales: _Any | None = None, options: _Any | None = None, /
|
|
32
|
+
) -> None: ...
|
|
33
|
+
|
|
34
|
+
def format(self, date: _Any = None, /) -> str: ...
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class DisplayNames:
|
|
38
|
+
def __init__(
|
|
39
|
+
self, locales: _Any | None = None, options: _Any | None = None, /
|
|
40
|
+
) -> None: ...
|
|
41
|
+
|
|
42
|
+
def of(self, code: str, /) -> str | None: ...
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class ListFormat:
|
|
46
|
+
def __init__(
|
|
47
|
+
self, locales: _Any | None = None, options: _Any | None = None, /
|
|
48
|
+
) -> None: ...
|
|
49
|
+
|
|
50
|
+
def format(self, items: list[str], /) -> str: ...
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class NumberFormat:
|
|
54
|
+
def __init__(
|
|
55
|
+
self, locales: _Any | None = None, options: _Any | None = None, /
|
|
56
|
+
) -> None: ...
|
|
57
|
+
|
|
58
|
+
def format(self, value: _Any, /) -> str: ...
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class PluralRules:
|
|
62
|
+
def __init__(
|
|
63
|
+
self, locales: _Any | None = None, options: _Any | None = None, /
|
|
64
|
+
) -> None: ...
|
|
65
|
+
|
|
66
|
+
def select(self, value: _Any, /) -> str: ...
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class RelativeTimeFormat:
|
|
70
|
+
def __init__(
|
|
71
|
+
self, locales: _Any | None = None, options: _Any | None = None, /
|
|
72
|
+
) -> None: ...
|
|
73
|
+
|
|
74
|
+
def format(self, value: int, unit: str, /) -> str: ...
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class Segmenter:
|
|
78
|
+
def __init__(
|
|
79
|
+
self, locales: _Any | None = None, options: _Any | None = None, /
|
|
80
|
+
) -> None: ...
|
|
81
|
+
|
|
82
|
+
def segment(self, text: str, /) -> _Any: ...
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class Locale:
|
|
86
|
+
def __init__(self, tag: str, options: _Any | None = None, /) -> None: ...
|
|
87
|
+
|
|
88
|
+
@property
|
|
89
|
+
def baseName(self) -> str: ...
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class DurationFormat:
|
|
93
|
+
def __init__(
|
|
94
|
+
self, locales: _Any | None = None, options: _Any | None = None, /
|
|
95
|
+
) -> None: ...
|
|
96
|
+
|
|
97
|
+
def format(self, value: _Any, /) -> str: ...
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
# Self-register this module as a JS builtin namespace
|
|
101
|
+
JsModule.register(name="Intl")
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"""
|
|
2
|
+
JavaScript MutationObserver builtin module.
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
|
|
6
|
+
```python
|
|
7
|
+
from pulse.js import MutationObserver, obj
|
|
8
|
+
|
|
9
|
+
@ps.javascript
|
|
10
|
+
def example(target):
|
|
11
|
+
observer = MutationObserver(lambda records, obs: None)
|
|
12
|
+
observer.observe(target, obj(childList=True))
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
# Or import from module directly:
|
|
16
|
+
from pulse.js.mutation_observer import MutationObserver
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from collections.abc import Callable as _Callable
|
|
20
|
+
from typing import Any as _Any
|
|
21
|
+
from typing import Protocol as _Protocol
|
|
22
|
+
from typing import TypedDict as _TypedDict
|
|
23
|
+
|
|
24
|
+
from pulse.transpiler.js_module import JsModule
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class MutationObserverInit(_TypedDict, total=False):
|
|
28
|
+
"""Options for MutationObserver.observe()."""
|
|
29
|
+
|
|
30
|
+
childList: bool
|
|
31
|
+
attributes: bool
|
|
32
|
+
characterData: bool
|
|
33
|
+
subtree: bool
|
|
34
|
+
attributeOldValue: bool
|
|
35
|
+
characterDataOldValue: bool
|
|
36
|
+
attributeFilter: list[str]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class MutationRecord(_Protocol):
|
|
40
|
+
"""Minimal MutationRecord shape for type checking."""
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def type(self) -> str: ...
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
def target(self) -> _Any: ...
|
|
47
|
+
|
|
48
|
+
@property
|
|
49
|
+
def addedNodes(self) -> _Any: ...
|
|
50
|
+
|
|
51
|
+
@property
|
|
52
|
+
def removedNodes(self) -> _Any: ...
|
|
53
|
+
|
|
54
|
+
@property
|
|
55
|
+
def previousSibling(self) -> _Any: ...
|
|
56
|
+
|
|
57
|
+
@property
|
|
58
|
+
def nextSibling(self) -> _Any: ...
|
|
59
|
+
|
|
60
|
+
@property
|
|
61
|
+
def attributeName(self) -> str | None: ...
|
|
62
|
+
|
|
63
|
+
@property
|
|
64
|
+
def attributeNamespace(self) -> str | None: ...
|
|
65
|
+
|
|
66
|
+
@property
|
|
67
|
+
def oldValue(self) -> str | None: ...
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class MutationObserver:
|
|
71
|
+
"""JavaScript MutationObserver - observe DOM changes."""
|
|
72
|
+
|
|
73
|
+
def __init__(
|
|
74
|
+
self,
|
|
75
|
+
callback: _Callable[[list[MutationRecord], "MutationObserver"], _Any],
|
|
76
|
+
/,
|
|
77
|
+
) -> None: ...
|
|
78
|
+
|
|
79
|
+
def observe(self, target: _Any, options: MutationObserverInit, /) -> None: ...
|
|
80
|
+
|
|
81
|
+
def disconnect(self) -> None: ...
|
|
82
|
+
|
|
83
|
+
def takeRecords(self) -> list[MutationRecord]: ...
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
# Self-register this module as a JS builtin (global identifiers)
|
|
87
|
+
JsModule.register(name=None)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""
|
|
2
|
+
JavaScript PerformanceObserver builtin.
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
|
|
6
|
+
```python
|
|
7
|
+
from pulse.js import PerformanceObserver, obj
|
|
8
|
+
|
|
9
|
+
@ps.javascript
|
|
10
|
+
def example():
|
|
11
|
+
observer = PerformanceObserver(lambda list_, obs: None)
|
|
12
|
+
observer.observe(obj(entryTypes=["mark", "measure"]))
|
|
13
|
+
```
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from collections.abc import Callable as _Callable
|
|
17
|
+
from typing import Any as _Any
|
|
18
|
+
from typing import Protocol as _Protocol
|
|
19
|
+
from typing import TypedDict as _TypedDict
|
|
20
|
+
|
|
21
|
+
from pulse.transpiler.js_module import JsModule
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class PerformanceObserverInit(_TypedDict, total=False):
|
|
25
|
+
buffered: bool
|
|
26
|
+
durationThreshold: float
|
|
27
|
+
entryTypes: list[str]
|
|
28
|
+
type: str
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class PerformanceObserverEntryList(_Protocol):
|
|
32
|
+
def getEntries(self) -> list[_Any]: ...
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class PerformanceObserver:
|
|
36
|
+
"""Observe performance entry events."""
|
|
37
|
+
|
|
38
|
+
def __init__(
|
|
39
|
+
self,
|
|
40
|
+
callback: _Callable[
|
|
41
|
+
[PerformanceObserverEntryList, "PerformanceObserver"], None
|
|
42
|
+
],
|
|
43
|
+
/,
|
|
44
|
+
) -> None: ...
|
|
45
|
+
|
|
46
|
+
def observe(self, options: PerformanceObserverInit, /) -> None: ...
|
|
47
|
+
|
|
48
|
+
def disconnect(self) -> None: ...
|
|
49
|
+
|
|
50
|
+
def takeRecords(self) -> list[_Any]: ...
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
# Self-register this module as a JS builtin (global identifiers)
|
|
54
|
+
JsModule.register(name=None)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""
|
|
2
|
+
JavaScript ResizeObserver builtin.
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
|
|
6
|
+
```python
|
|
7
|
+
from pulse.js import ResizeObserver, obj
|
|
8
|
+
|
|
9
|
+
@ps.javascript
|
|
10
|
+
def example(target):
|
|
11
|
+
observer = ResizeObserver(lambda entries, obs: None)
|
|
12
|
+
observer.observe(target, obj(box="border-box"))
|
|
13
|
+
```
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from collections.abc import Callable as _Callable
|
|
17
|
+
from typing import Protocol as _Protocol
|
|
18
|
+
from typing import TypedDict as _TypedDict
|
|
19
|
+
|
|
20
|
+
from pulse.js._types import Element as _Element
|
|
21
|
+
from pulse.transpiler.js_module import JsModule
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class ResizeObserverOptions(_TypedDict, total=False):
|
|
25
|
+
box: str
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class ResizeObserverEntry(_Protocol):
|
|
29
|
+
@property
|
|
30
|
+
def target(self) -> _Element: ...
|
|
31
|
+
|
|
32
|
+
@property
|
|
33
|
+
def contentRect(self) -> object: ...
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class ResizeObserver:
|
|
37
|
+
"""Observe element size changes."""
|
|
38
|
+
|
|
39
|
+
def __init__(
|
|
40
|
+
self,
|
|
41
|
+
callback: _Callable[[list[ResizeObserverEntry], "ResizeObserver"], None],
|
|
42
|
+
/,
|
|
43
|
+
) -> None: ...
|
|
44
|
+
|
|
45
|
+
def observe(
|
|
46
|
+
self, target: _Element, options: ResizeObserverOptions | None = None, /
|
|
47
|
+
) -> None: ...
|
|
48
|
+
|
|
49
|
+
def unobserve(self, target: _Element, /) -> None: ...
|
|
50
|
+
|
|
51
|
+
def disconnect(self) -> None: ...
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# Self-register this module as a JS builtin (global identifiers)
|
|
55
|
+
JsModule.register(name=None)
|