pythonx-compose 0.1.0a1__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.
Files changed (40) hide show
  1. pythonx/compose/__init__.py +4 -0
  2. pythonx/compose/__init__.pyi +1 -0
  3. pythonx/compose/_reexport.py +512 -0
  4. pythonx/compose/foundation/__init__.py +5 -0
  5. pythonx/compose/foundation/__init__.pyi +17 -0
  6. pythonx/compose/foundation/layout/__init__.py +5 -0
  7. pythonx/compose/foundation/layout/__init__.pyi +2 -0
  8. pythonx/compose/foundation/text/__init__.py +5 -0
  9. pythonx/compose/foundation/text/input/__init__.py +5 -0
  10. pythonx/compose/foundation/text/input/__init__.pyi +78 -0
  11. pythonx/compose/layout/__init__.py +25 -0
  12. pythonx/compose/layout/__init__.pyi +878 -0
  13. pythonx/compose/layout/arrangement.py +34 -0
  14. pythonx/compose/material/__init__.py +8 -0
  15. pythonx/compose/material/__init__.pyi +1 -0
  16. pythonx/compose/material/icons/__init__.py +9 -0
  17. pythonx/compose/material/icons/__init__.pyi +1159 -0
  18. pythonx/compose/material3/__init__.py +24 -0
  19. pythonx/compose/material3/__init__.pyi +3305 -0
  20. pythonx/compose/py.typed +0 -0
  21. pythonx/compose/pythonx-map.toml +73 -0
  22. pythonx/compose/runtime/__init__.py +128 -0
  23. pythonx/compose/runtime/__init__.pyi +180 -0
  24. pythonx/compose/ui/__init__.py +21 -0
  25. pythonx/compose/ui/__init__.pyi +975 -0
  26. pythonx/compose/ui/alignment.py +47 -0
  27. pythonx/compose/ui/graphics/__init__.py +5 -0
  28. pythonx/compose/ui/graphics/__init__.pyi +795 -0
  29. pythonx/compose/ui/graphics/vector/__init__.py +5 -0
  30. pythonx/compose/ui/graphics/vector/__init__.pyi +221 -0
  31. pythonx/compose/ui/modifier.py +110 -0
  32. pythonx/compose/ui/text/__init__.py +5 -0
  33. pythonx/compose/ui/text/__init__.pyi +703 -0
  34. pythonx/compose/ui/unit/__init__.py +19 -0
  35. pythonx/compose/ui/unit/__init__.pyi +348 -0
  36. pythonx_compose-0.1.0a1.dist-info/METADATA +228 -0
  37. pythonx_compose-0.1.0a1.dist-info/RECORD +40 -0
  38. pythonx_compose-0.1.0a1.dist-info/WHEEL +5 -0
  39. pythonx_compose-0.1.0a1.dist-info/licenses/LICENSE +21 -0
  40. pythonx_compose-0.1.0a1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,5 @@
1
+ """`pythonx.compose.ui.graphics.vector` -- the Pythonic view of `androidx.compose.ui.graphics.vector` (see `pythonx/compose/_reexport.py`)."""
2
+
3
+ from pythonx.compose._reexport import reexport
4
+
5
+ __getattr__, __dir__ = reexport(__name__)
@@ -0,0 +1,221 @@
1
+ # GENERATED by scripts/gen_stubs.py from python-multiplatform's Kotlin-named stubs (artifact kotlin-stubs, workflow run 37103737430, commit a5028618, Compose 1.11.1). Do not edit.
2
+ import typing as _t
3
+ import pythonx.compose.runtime
4
+ import pythonx.compose.ui.graphics
5
+
6
+ class _ImageVector_Builder_materialPath(_t.Protocol):
7
+ def __call__(self, fill_alpha: float = ..., stroke_alpha: float = ..., path_fill_type: _t.Any = ..., *, path_builder: _t.Callable[[PathBuilder], None]) -> ImageVector.Builder: ...
8
+
9
+ class _ImageVector_Builder_path(_t.Protocol):
10
+ def __call__(self, name: str, fill: pythonx.compose.ui.graphics.Brush | None, fill_alpha: float, stroke: pythonx.compose.ui.graphics.Brush | None, stroke_alpha: float, stroke_line_width: float, stroke_line_cap: _t.Any, stroke_line_join: _t.Any, stroke_line_miter: float, path_fill_type: _t.Any, path_builder: _t.Callable[[PathBuilder], None]) -> ImageVector.Builder: ...
11
+
12
+ class ImageVector:
13
+ """Kotlin: androidx.compose.ui.graphics.vector.ImageVector"""
14
+ @property
15
+ def auto_mirror(self) -> bool:
16
+ """Kotlin property: androidx.compose.ui.graphics.vector.ImageVector.autoMirror (androidx.compose.ui.graphics.vector.ImageVector.autoMirror: kotlin.Boolean)"""
17
+ ...
18
+ @property
19
+ def default_height(self) -> float:
20
+ """Kotlin property: androidx.compose.ui.graphics.vector.ImageVector.defaultHeight (androidx.compose.ui.graphics.vector.ImageVector.defaultHeight: androidx.compose.ui.unit.Dp)"""
21
+ ...
22
+ @property
23
+ def default_width(self) -> float:
24
+ """Kotlin property: androidx.compose.ui.graphics.vector.ImageVector.defaultWidth (androidx.compose.ui.graphics.vector.ImageVector.defaultWidth: androidx.compose.ui.unit.Dp)"""
25
+ ...
26
+ @property
27
+ def name(self) -> str:
28
+ """Kotlin property: androidx.compose.ui.graphics.vector.ImageVector.name (androidx.compose.ui.graphics.vector.ImageVector.name: kotlin.String)"""
29
+ ...
30
+ @property
31
+ def root(self) -> VectorGroup:
32
+ """Kotlin property: androidx.compose.ui.graphics.vector.ImageVector.root (androidx.compose.ui.graphics.vector.ImageVector.root: androidx.compose.ui.graphics.vector.VectorGroup)"""
33
+ ...
34
+ @property
35
+ def tint_blend_mode(self) -> _t.Any:
36
+ """Kotlin property: androidx.compose.ui.graphics.vector.ImageVector.tintBlendMode (androidx.compose.ui.graphics.vector.ImageVector.tintBlendMode: androidx.compose.ui.graphics.BlendMode)"""
37
+ ...
38
+ @property
39
+ def tint_color(self) -> _t.Any:
40
+ """Kotlin property: androidx.compose.ui.graphics.vector.ImageVector.tintColor (androidx.compose.ui.graphics.vector.ImageVector.tintColor: androidx.compose.ui.graphics.Color)"""
41
+ ...
42
+ @property
43
+ def viewport_height(self) -> float:
44
+ """Kotlin property: androidx.compose.ui.graphics.vector.ImageVector.viewportHeight (androidx.compose.ui.graphics.vector.ImageVector.viewportHeight: kotlin.Float)"""
45
+ ...
46
+ @property
47
+ def viewport_width(self) -> float:
48
+ """Kotlin property: androidx.compose.ui.graphics.vector.ImageVector.viewportWidth (androidx.compose.ui.graphics.vector.ImageVector.viewportWidth: kotlin.Float)"""
49
+ ...
50
+ class Builder:
51
+ """Kotlin: androidx.compose.ui.graphics.vector.ImageVector.Builder"""
52
+ material_path: _t.ClassVar[_ImageVector_Builder_materialPath]
53
+ path: _t.ClassVar[_ImageVector_Builder_path]
54
+
55
+ class PathBuilder:
56
+ """Kotlin: androidx.compose.ui.graphics.vector.PathBuilder"""
57
+ def __init__(self) -> None:
58
+ """Kotlin constructor: androidx.compose.ui.graphics.vector.PathBuilder (androidx.compose.ui.graphics.vector.PathBuilder(): androidx.compose.ui.graphics.vector.PathBuilder)"""
59
+ ...
60
+
61
+ class PathNode:
62
+ """Kotlin: androidx.compose.ui.graphics.vector.PathNode"""
63
+ @property
64
+ def is_curve(self) -> bool:
65
+ """Kotlin property: androidx.compose.ui.graphics.vector.PathNode.isCurve (androidx.compose.ui.graphics.vector.PathNode.isCurve: kotlin.Boolean)"""
66
+ ...
67
+ @property
68
+ def is_quad(self) -> bool:
69
+ """Kotlin property: androidx.compose.ui.graphics.vector.PathNode.isQuad (androidx.compose.ui.graphics.vector.PathNode.isQuad: kotlin.Boolean)"""
70
+ ...
71
+
72
+ class PathParser:
73
+ """Kotlin: androidx.compose.ui.graphics.vector.PathParser"""
74
+ def __init__(self) -> None:
75
+ """Kotlin constructor: androidx.compose.ui.graphics.vector.PathParser (androidx.compose.ui.graphics.vector.PathParser(): androidx.compose.ui.graphics.vector.PathParser)"""
76
+ ...
77
+
78
+ class VNode:
79
+ """Kotlin: androidx.compose.ui.graphics.vector.VNode"""
80
+
81
+ class VectorApplier(pythonx.compose.runtime.AbstractApplier, pythonx.compose.runtime.Applier):
82
+ """Kotlin: androidx.compose.ui.graphics.vector.VectorApplier"""
83
+ def __init__(self, root: VNode) -> None:
84
+ """Kotlin constructor: androidx.compose.ui.graphics.vector.VectorApplier (androidx.compose.ui.graphics.vector.VectorApplier(root: androidx.compose.ui.graphics.vector.VNode): androidx.compose.ui.graphics.vector.VectorApplier)"""
85
+ ...
86
+
87
+ class VectorGroup:
88
+ """Kotlin: androidx.compose.ui.graphics.vector.VectorGroup"""
89
+ @property
90
+ def name(self) -> str:
91
+ """Kotlin property: androidx.compose.ui.graphics.vector.VectorGroup.name (androidx.compose.ui.graphics.vector.VectorGroup.name: kotlin.String)"""
92
+ ...
93
+ @property
94
+ def pivot_x(self) -> float:
95
+ """Kotlin property: androidx.compose.ui.graphics.vector.VectorGroup.pivotX (androidx.compose.ui.graphics.vector.VectorGroup.pivotX: kotlin.Float)"""
96
+ ...
97
+ @property
98
+ def pivot_y(self) -> float:
99
+ """Kotlin property: androidx.compose.ui.graphics.vector.VectorGroup.pivotY (androidx.compose.ui.graphics.vector.VectorGroup.pivotY: kotlin.Float)"""
100
+ ...
101
+ @property
102
+ def rotation(self) -> float:
103
+ """Kotlin property: androidx.compose.ui.graphics.vector.VectorGroup.rotation (androidx.compose.ui.graphics.vector.VectorGroup.rotation: kotlin.Float)"""
104
+ ...
105
+ @property
106
+ def scale_x(self) -> float:
107
+ """Kotlin property: androidx.compose.ui.graphics.vector.VectorGroup.scaleX (androidx.compose.ui.graphics.vector.VectorGroup.scaleX: kotlin.Float)"""
108
+ ...
109
+ @property
110
+ def scale_y(self) -> float:
111
+ """Kotlin property: androidx.compose.ui.graphics.vector.VectorGroup.scaleY (androidx.compose.ui.graphics.vector.VectorGroup.scaleY: kotlin.Float)"""
112
+ ...
113
+ @property
114
+ def size(self) -> int:
115
+ """Kotlin property: androidx.compose.ui.graphics.vector.VectorGroup.size (androidx.compose.ui.graphics.vector.VectorGroup.size: kotlin.Int)"""
116
+ ...
117
+ @property
118
+ def translation_x(self) -> float:
119
+ """Kotlin property: androidx.compose.ui.graphics.vector.VectorGroup.translationX (androidx.compose.ui.graphics.vector.VectorGroup.translationX: kotlin.Float)"""
120
+ ...
121
+ @property
122
+ def translation_y(self) -> float:
123
+ """Kotlin property: androidx.compose.ui.graphics.vector.VectorGroup.translationY (androidx.compose.ui.graphics.vector.VectorGroup.translationY: kotlin.Float)"""
124
+ ...
125
+
126
+ class VectorPainter(_t.Any):
127
+ """Kotlin: androidx.compose.ui.graphics.vector.VectorPainter"""
128
+ @property
129
+ def intrinsic_size(self) -> int:
130
+ """Kotlin property: androidx.compose.ui.graphics.vector.VectorPainter.intrinsicSize (androidx.compose.ui.graphics.vector.VectorPainter.intrinsicSize: androidx.compose.ui.geometry.Size)"""
131
+ ...
132
+
133
+ class VectorPath:
134
+ """Kotlin: androidx.compose.ui.graphics.vector.VectorPath"""
135
+ @property
136
+ def fill(self) -> pythonx.compose.ui.graphics.Brush | None:
137
+ """Kotlin property: androidx.compose.ui.graphics.vector.VectorPath.fill (androidx.compose.ui.graphics.vector.VectorPath.fill: androidx.compose.ui.graphics.Brush?)"""
138
+ ...
139
+ @property
140
+ def fill_alpha(self) -> float:
141
+ """Kotlin property: androidx.compose.ui.graphics.vector.VectorPath.fillAlpha (androidx.compose.ui.graphics.vector.VectorPath.fillAlpha: kotlin.Float)"""
142
+ ...
143
+ @property
144
+ def name(self) -> str:
145
+ """Kotlin property: androidx.compose.ui.graphics.vector.VectorPath.name (androidx.compose.ui.graphics.vector.VectorPath.name: kotlin.String)"""
146
+ ...
147
+ @property
148
+ def path_fill_type(self) -> _t.Any:
149
+ """Kotlin property: androidx.compose.ui.graphics.vector.VectorPath.pathFillType (androidx.compose.ui.graphics.vector.VectorPath.pathFillType: androidx.compose.ui.graphics.PathFillType)"""
150
+ ...
151
+ @property
152
+ def stroke(self) -> pythonx.compose.ui.graphics.Brush | None:
153
+ """Kotlin property: androidx.compose.ui.graphics.vector.VectorPath.stroke (androidx.compose.ui.graphics.vector.VectorPath.stroke: androidx.compose.ui.graphics.Brush?)"""
154
+ ...
155
+ @property
156
+ def stroke_alpha(self) -> float:
157
+ """Kotlin property: androidx.compose.ui.graphics.vector.VectorPath.strokeAlpha (androidx.compose.ui.graphics.vector.VectorPath.strokeAlpha: kotlin.Float)"""
158
+ ...
159
+ @property
160
+ def stroke_line_cap(self) -> _t.Any:
161
+ """Kotlin property: androidx.compose.ui.graphics.vector.VectorPath.strokeLineCap (androidx.compose.ui.graphics.vector.VectorPath.strokeLineCap: androidx.compose.ui.graphics.StrokeCap)"""
162
+ ...
163
+ @property
164
+ def stroke_line_join(self) -> _t.Any:
165
+ """Kotlin property: androidx.compose.ui.graphics.vector.VectorPath.strokeLineJoin (androidx.compose.ui.graphics.vector.VectorPath.strokeLineJoin: androidx.compose.ui.graphics.StrokeJoin)"""
166
+ ...
167
+ @property
168
+ def stroke_line_miter(self) -> float:
169
+ """Kotlin property: androidx.compose.ui.graphics.vector.VectorPath.strokeLineMiter (androidx.compose.ui.graphics.vector.VectorPath.strokeLineMiter: kotlin.Float)"""
170
+ ...
171
+ @property
172
+ def stroke_line_width(self) -> float:
173
+ """Kotlin property: androidx.compose.ui.graphics.vector.VectorPath.strokeLineWidth (androidx.compose.ui.graphics.vector.VectorPath.strokeLineWidth: kotlin.Float)"""
174
+ ...
175
+ @property
176
+ def trim_path_end(self) -> float:
177
+ """Kotlin property: androidx.compose.ui.graphics.vector.VectorPath.trimPathEnd (androidx.compose.ui.graphics.vector.VectorPath.trimPathEnd: kotlin.Float)"""
178
+ ...
179
+ @property
180
+ def trim_path_offset(self) -> float:
181
+ """Kotlin property: androidx.compose.ui.graphics.vector.VectorPath.trimPathOffset (androidx.compose.ui.graphics.vector.VectorPath.trimPathOffset: kotlin.Float)"""
182
+ ...
183
+ @property
184
+ def trim_path_start(self) -> float:
185
+ """Kotlin property: androidx.compose.ui.graphics.vector.VectorPath.trimPathStart (androidx.compose.ui.graphics.vector.VectorPath.trimPathStart: kotlin.Float)"""
186
+ ...
187
+
188
+ def Group(name: str = ..., rotation: float = ..., pivot_x: float = ..., pivot_y: float = ..., scale_x: float = ..., scale_y: float = ..., translation_x: float = ..., translation_y: float = ..., clip_path_data: _t.Any = ..., *, content: _t.Callable[[], None]) -> None:
189
+ """Kotlin: androidx.compose.ui.graphics.vector.Group(name: kotlin.String, rotation: kotlin.Float, pivotX: kotlin.Float, pivotY: kotlin.Float, scaleX: kotlin.Float, scaleY: kotlin.Float, translationX: kotlin.Float, translationY: kotlin.Float, clipPathData: kotlin.collections.List, content: kotlin.Function0): kotlin.Unit"""
190
+ ...
191
+
192
+ def Path(path_data: _t.Any, path_fill_type: _t.Any = ..., name: str = ..., fill: pythonx.compose.ui.graphics.Brush | None = ..., fill_alpha: float = ..., stroke: pythonx.compose.ui.graphics.Brush | None = ..., stroke_alpha: float = ..., stroke_line_width: float = ..., stroke_line_cap: _t.Any = ..., stroke_line_join: _t.Any = ..., stroke_line_miter: float = ..., trim_path_start: float = ..., trim_path_end: float = ..., trim_path_offset: float = ...) -> None:
193
+ """Kotlin: androidx.compose.ui.graphics.vector.Path(pathData: kotlin.collections.List, pathFillType: androidx.compose.ui.graphics.PathFillType, name: kotlin.String, fill: androidx.compose.ui.graphics.Brush?, fillAlpha: kotlin.Float, stroke: androidx.compose.ui.graphics.Brush?, strokeAlpha: kotlin.Float, strokeLineWidth: kotlin.Float, strokeLineCap: androidx.compose.ui.graphics.StrokeCap, strokeLineJoin: androidx.compose.ui.graphics.StrokeJoin, strokeLineMiter: kotlin.Float, trimPathStart: kotlin.Float, trimPathEnd: kotlin.Float, trimPathOffset: kotlin.Float): kotlin.Unit"""
194
+ ...
195
+
196
+ def RenderVectorGroup(group: VectorGroup, configs: _t.Any = ...) -> None:
197
+ """Kotlin: androidx.compose.ui.graphics.vector.RenderVectorGroup(group: androidx.compose.ui.graphics.vector.VectorGroup, configs: kotlin.collections.Map): kotlin.Unit"""
198
+ ...
199
+
200
+ def path(receiver: ImageVector.Builder, /, name: str, fill: pythonx.compose.ui.graphics.Brush | None, fill_alpha: float, stroke: pythonx.compose.ui.graphics.Brush | None, stroke_alpha: float, stroke_line_width: float, stroke_line_cap: _t.Any, stroke_line_join: _t.Any, stroke_line_miter: float, path_fill_type: _t.Any, path_builder: _t.Callable[[PathBuilder], None]) -> ImageVector.Builder:
201
+ """Kotlin: androidx.compose.ui.graphics.vector.ImageVector.Builder.path(name: kotlin.String, fill: androidx.compose.ui.graphics.Brush?, fillAlpha: kotlin.Float, stroke: androidx.compose.ui.graphics.Brush?, strokeAlpha: kotlin.Float, strokeLineWidth: kotlin.Float, strokeLineCap: androidx.compose.ui.graphics.StrokeCap, strokeLineJoin: androidx.compose.ui.graphics.StrokeJoin, strokeLineMiter: kotlin.Float, pathFillType: androidx.compose.ui.graphics.PathFillType, pathBuilder: kotlin.Function1): androidx.compose.ui.graphics.vector.ImageVector.Builder"""
202
+ ...
203
+
204
+ def remember_vector_painter__Dp_Dp_Float_Float_String_Color_BlendMode_Boolean_Unit(default_width: float, default_height: float, viewport_width: float = ..., viewport_height: float = ..., name: str = ..., tint_color: _t.Any = ..., tint_blend_mode: _t.Any = ..., auto_mirror: bool = ..., *, content: _t.Callable[[float, float], None]) -> VectorPainter:
205
+ """Kotlin: androidx.compose.ui.graphics.vector.rememberVectorPainter(defaultWidth: androidx.compose.ui.unit.Dp, defaultHeight: androidx.compose.ui.unit.Dp, viewportWidth: kotlin.Float, viewportHeight: kotlin.Float, name: kotlin.String, tintColor: androidx.compose.ui.graphics.Color, tintBlendMode: androidx.compose.ui.graphics.BlendMode, autoMirror: kotlin.Boolean, content: kotlin.Function2): androidx.compose.ui.graphics.vector.VectorPainter"""
206
+ ...
207
+
208
+ def remember_vector_painter__Dp_Dp_Float_Float_String_Color_BlendMode_Unit(default_width: float, default_height: float, viewport_width: float = ..., viewport_height: float = ..., name: str = ..., tint_color: _t.Any = ..., tint_blend_mode: _t.Any = ..., *, content: _t.Callable[[float, float], None]) -> VectorPainter:
209
+ """Kotlin: androidx.compose.ui.graphics.vector.rememberVectorPainter(defaultWidth: androidx.compose.ui.unit.Dp, defaultHeight: androidx.compose.ui.unit.Dp, viewportWidth: kotlin.Float, viewportHeight: kotlin.Float, name: kotlin.String, tintColor: androidx.compose.ui.graphics.Color, tintBlendMode: androidx.compose.ui.graphics.BlendMode, content: kotlin.Function2): androidx.compose.ui.graphics.vector.VectorPainter"""
210
+ ...
211
+
212
+ def remember_vector_painter__ImageVector(image: ImageVector) -> VectorPainter:
213
+ """Kotlin: androidx.compose.ui.graphics.vector.rememberVectorPainter(image: androidx.compose.ui.graphics.vector.ImageVector): androidx.compose.ui.graphics.vector.VectorPainter"""
214
+ ...
215
+
216
+ @_t.overload
217
+ def remember_vector_painter(default_width: float, default_height: float, viewport_width: float = ..., viewport_height: float = ..., name: str = ..., tint_color: _t.Any = ..., tint_blend_mode: _t.Any = ..., auto_mirror: bool = ..., *, content: _t.Callable[[float, float], None]) -> VectorPainter: ...
218
+ @_t.overload
219
+ def remember_vector_painter(default_width: float, default_height: float, viewport_width: float = ..., viewport_height: float = ..., name: str = ..., tint_color: _t.Any = ..., tint_blend_mode: _t.Any = ..., *, content: _t.Callable[[float, float], None]) -> VectorPainter: ... # type: ignore[overload-cannot-match]
220
+ @_t.overload
221
+ def remember_vector_painter(image: ImageVector) -> VectorPainter: ... # type: ignore[overload-cannot-match]
@@ -0,0 +1,110 @@
1
+ """Where a `Modifier` chain starts -- and the only thing about `Modifier` that is hand-written.
2
+
3
+ ## What used to be here
4
+
5
+ A copy of the Button wrapper. `padding()` composed nothing, `fill_max_size()` returned `self`, and
6
+ lines 20-22 searched `ButtonKt.__dict__` for a name beginning `"Button-"` -- a prefix search over
7
+ Kotlin's value-class mangling suffix. That search is not merely broken, it is *impossible*: the
8
+ suffix hashes the value-class signature only, so `padding`, `size`, `width` and `height` all mangle
9
+ to `-3ABfNKs` and a name lookup cannot tell them apart. Looking a Kotlin declaration up by JVM name
10
+ is a removed option (`agent-rules.md` §12); the binder generates Kotlin source and lets `kotlinc`
11
+ mangle it.
12
+
13
+ ## What replaced it, and where that lives
14
+
15
+ Not here. `Modifier` is an ordinary proxy the binder builds from the upcall table and serves as
16
+ `androidx.compose.ui.Modifier`; `pythonx.compose.ui.Modifier` is that same class, re-exported by
17
+ the naming rule in `pythonx/compose/_reexport.py`.
18
+ Every one of its methods is a `Modifier` extension the artefact walker bound out of Compose's own
19
+ jars -- 104 of them at last count (`docs/kotlin-extensions-in-python.md` §3.2) -- and each is
20
+ attached to the proxy type on first read and never resolved again. So:
21
+
22
+ Modifier.padding(16).size(24) # chained, with zero hand-written wrappers
23
+ padding(m, horizontal=8, vertical=4) # dispatched among four `padding` overloads
24
+
25
+ None of that is per-declaration Python, which is exactly why none of it is a file
26
+ (`docs/pythonx-adapter-design.md` §7). **If this file ever grows a `def padding`, the 2024 mistake
27
+ has been made again.**
28
+
29
+ ## What is left, and why it cannot be derived
30
+
31
+ One fact, and it is data rather than code: **the name of a Kotlin function that returns an empty
32
+ `Modifier`.**
33
+
34
+ `Modifier` as a Kotlin *expression* is `Modifier.Companion`, an object instance, and the artefact
35
+ walker binds functions. So the empty modifier every chain starts from has **no bound name**, and the
36
+ adaptation layer refuses to invent one -- `Modifier.padding(16)` raises a `TypeError` naming
37
+ `register_empty` rather than guessing. Registering that name is the seam, and this file is it.
38
+
39
+ **No such function exists in Compose today.** `androidx.compose.ui.emptyModifier` is the name
40
+ `ComposeShapedFragment` uses for the fixture, and it is a placeholder: against the real jars nothing
41
+ is bound under it, so the class-object spelling does not yet work and only the instance spelling
42
+ (`m.padding(16)`, on a `Modifier` Kotlin handed out) does. Closing that needs one line of Kotlin in
43
+ the consuming application -- `fun emptyModifier(): Modifier = Modifier`, picked up by KSP -- and
44
+ [install] is where its name is supplied.
45
+
46
+ ## How this module is reached
47
+
48
+ As `pythonx.compose.ui.modifier`, an ordinary module of this package. It needs the binder's layer
49
+ (`python_multiplatform.binding`) to be installed by the host before [install] can do anything.
50
+ """
51
+
52
+ from __future__ import annotations
53
+
54
+ import importlib
55
+ import sys
56
+
57
+ BINDING_MODULE = "python_multiplatform.binding"
58
+
59
+ KOTLIN_PACKAGE = "androidx.compose.ui"
60
+
61
+ KOTLIN_TYPE = KOTLIN_PACKAGE + ".Modifier"
62
+ """The Kotlin type the proxy stands for. The walker reports it as `receiverTypeName`."""
63
+
64
+ PLACEHOLDER_EMPTY_FACTORY = "androidx.compose.ui.emptyModifier"
65
+ """A name that is **not** bound by Compose. See the module docstring; supply your own to [install]."""
66
+
67
+
68
+ def adapter():
69
+ """The binder's installed binding layer, or a `RuntimeError` that says what did not happen.
70
+
71
+ The Kotlin host installs it (`PythonxAdapter.install()`), not an import, so its absence means
72
+ the host never ran it -- a different failure from a missing package, with a different message.
73
+ """
74
+ module = sys.modules.get(BINDING_MODULE)
75
+ if module is None or not hasattr(module, "register_empty"):
76
+ raise RuntimeError(
77
+ "the python-multiplatform binding layer is not installed: the Kotlin host must run "
78
+ "PythonxAdapter.install() before anything here can resolve a Modifier"
79
+ )
80
+ return module
81
+
82
+
83
+ def modifier_type(layer=None):
84
+ """The `Modifier` proxy class -- the same object `pythonx.compose.ui.Modifier` is."""
85
+ if layer is None:
86
+ adapter()
87
+ # Through this package's own module, so the manifest's value-class allowlist is in force.
88
+ return importlib.import_module("pythonx.compose.ui").Modifier
89
+
90
+
91
+ def install(empty_factory=PLACEHOLDER_EMPTY_FACTORY, layer=None):
92
+ """Register where an empty `Modifier` comes from, and return the proxy class.
93
+
94
+ :param empty_factory: the fully-qualified Kotlin name of a zero-argument function returning
95
+ `Modifier`. Must be bound in the upcall table; nothing in Compose is, so this is normally a
96
+ one-line function in the consuming application's own Kotlin.
97
+ :param layer: the adaptation layer, for tests that hold one directly.
98
+ """
99
+ layer = layer or adapter()
100
+ layer.register_empty(KOTLIN_TYPE, empty_factory)
101
+ return modifier_type(layer)
102
+
103
+
104
+ def __getattr__(name):
105
+ # `Modifier` is resolved rather than defined, so that this module cannot hold a stale class
106
+ # across a table reinstall -- `_register_table` invalidates every proxy, and a module-level
107
+ # binding made at import time would outlive that.
108
+ if name == "Modifier":
109
+ return modifier_type()
110
+ raise AttributeError(name)
@@ -0,0 +1,5 @@
1
+ """`pythonx.compose.ui.text` -- the Pythonic view of `androidx.compose.ui.text` (see `pythonx/compose/_reexport.py`)."""
2
+
3
+ from pythonx.compose._reexport import reexport
4
+
5
+ __getattr__, __dir__ = reexport(__name__)