branchkit 0.2.0__tar.gz → 0.3.0__tar.gz

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 (36) hide show
  1. {branchkit-0.2.0 → branchkit-0.3.0}/PKG-INFO +1 -1
  2. {branchkit-0.2.0 → branchkit-0.3.0}/branchkit/plugin.py +25 -0
  3. {branchkit-0.2.0 → branchkit-0.3.0}/branchkit.egg-info/PKG-INFO +1 -1
  4. {branchkit-0.2.0 → branchkit-0.3.0}/pyproject.toml +1 -1
  5. {branchkit-0.2.0 → branchkit-0.3.0}/tests/test_settings_tabs.py +16 -0
  6. {branchkit-0.2.0 → branchkit-0.3.0}/LICENSE +0 -0
  7. {branchkit-0.2.0 → branchkit-0.3.0}/README.md +0 -0
  8. {branchkit-0.2.0 → branchkit-0.3.0}/branchkit/__init__.py +0 -0
  9. {branchkit-0.2.0 → branchkit-0.3.0}/branchkit/actor.py +0 -0
  10. {branchkit-0.2.0 → branchkit-0.3.0}/branchkit/closed_vocab_gen.py +0 -0
  11. {branchkit-0.2.0 → branchkit-0.3.0}/branchkit/collection.py +0 -0
  12. {branchkit-0.2.0 → branchkit-0.3.0}/branchkit/collection_log.py +0 -0
  13. {branchkit-0.2.0 → branchkit-0.3.0}/branchkit/commands.py +0 -0
  14. {branchkit-0.2.0 → branchkit-0.3.0}/branchkit/contracts_gen.py +0 -0
  15. {branchkit-0.2.0 → branchkit-0.3.0}/branchkit/correlation.py +0 -0
  16. {branchkit-0.2.0 → branchkit-0.3.0}/branchkit/debug.py +0 -0
  17. {branchkit-0.2.0 → branchkit-0.3.0}/branchkit/effects.py +0 -0
  18. {branchkit-0.2.0 → branchkit-0.3.0}/branchkit/harness.py +0 -0
  19. {branchkit-0.2.0 → branchkit-0.3.0}/branchkit/hud.py +0 -0
  20. {branchkit-0.2.0 → branchkit-0.3.0}/branchkit/listen.py +0 -0
  21. {branchkit-0.2.0 → branchkit-0.3.0}/branchkit/log.py +0 -0
  22. {branchkit-0.2.0 → branchkit-0.3.0}/branchkit/log_events_gen.py +0 -0
  23. {branchkit-0.2.0 → branchkit-0.3.0}/branchkit/methods_gen.py +0 -0
  24. {branchkit-0.2.0 → branchkit-0.3.0}/branchkit/mirror.py +0 -0
  25. {branchkit-0.2.0 → branchkit-0.3.0}/branchkit/proxy.py +0 -0
  26. {branchkit-0.2.0 → branchkit-0.3.0}/branchkit/settings.py +0 -0
  27. {branchkit-0.2.0 → branchkit-0.3.0}/branchkit/settings_route.py +0 -0
  28. {branchkit-0.2.0 → branchkit-0.3.0}/branchkit/types_gen.py +0 -0
  29. {branchkit-0.2.0 → branchkit-0.3.0}/branchkit/ui.py +0 -0
  30. {branchkit-0.2.0 → branchkit-0.3.0}/branchkit/upstream.py +0 -0
  31. {branchkit-0.2.0 → branchkit-0.3.0}/branchkit.egg-info/SOURCES.txt +0 -0
  32. {branchkit-0.2.0 → branchkit-0.3.0}/branchkit.egg-info/dependency_links.txt +0 -0
  33. {branchkit-0.2.0 → branchkit-0.3.0}/branchkit.egg-info/top_level.txt +0 -0
  34. {branchkit-0.2.0 → branchkit-0.3.0}/setup.cfg +0 -0
  35. {branchkit-0.2.0 → branchkit-0.3.0}/tests/test_collection.py +0 -0
  36. {branchkit-0.2.0 → branchkit-0.3.0}/tests/test_kernel.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: branchkit
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: BranchKit plugin SDK for Python
5
5
  Author: BranchKit
6
6
  License-Expression: MIT
@@ -211,6 +211,31 @@ class PluginCore:
211
211
  self._action_handlers[action] = fn
212
212
  return fn
213
213
 
214
+ def handle_command(self, method: str, fn: Callable | None = None):
215
+ """Register a command: a method a settings control posts to. A
216
+ command changes state and returns nothing — the platform's method
217
+ proxy answers the post with 204 and re-renders the tab through its
218
+ stream, and refuses any result with 422 and the
219
+ settings-method-result diagnostic. Whatever `fn` returns is dropped
220
+ here; the response carries ``"result": null``. Usable directly or
221
+ as a decorator (``@plugin.handle_command("set_volume")``); plain
222
+ ``def`` or ``async def``, as with ``handle``.
223
+
224
+ Use ``handle`` for a method whose result another caller reads — a
225
+ platform hook, or another plugin — never for a settings control."""
226
+ if fn is None:
227
+ def deco(f):
228
+ self.handle_command(method, f)
229
+ return f
230
+ return deco
231
+
232
+ async def command(params):
233
+ await self._invoke(fn, params if params is not None else {})
234
+ return None
235
+
236
+ self.handle(method, command)
237
+ return fn
238
+
214
239
  # The design-doc registration idiom (`@plugin.action("…")`) — an alias
215
240
  # of handle_action, which keeps the Go/TS name greppable too.
216
241
  action = handle_action
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: branchkit
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: BranchKit plugin SDK for Python
5
5
  Author: BranchKit
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "branchkit"
7
- version = "0.2.0"
7
+ version = "0.3.0"
8
8
  description = "BranchKit plugin SDK for Python"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -2,6 +2,7 @@
2
2
  registered stylesheet on every response, an error for a key nobody
3
3
  registered, and every settings mirror refreshed before the tab draws."""
4
4
 
5
+ import asyncio
5
6
  import unittest
6
7
 
7
8
  import branchkit
@@ -71,6 +72,21 @@ class TestSettingsTabs(unittest.IsolatedAsyncioTestCase):
71
72
  with self.assertRaisesRegex(RuntimeError, "settings_tab"):
72
73
  b.handle("render_settings", lambda params: {})
73
74
 
75
+ # A command answers with no result however its handler is written — the
76
+ # proxy refuses anything else with 422; this is the SDK's half.
77
+ def test_handle_command_drops_the_return_value(self):
78
+ p = fake_plugin({})
79
+ seen = {}
80
+
81
+ @p.handle_command("set_volume")
82
+ def set_volume(req):
83
+ seen["volume"] = req["volume"]
84
+ return {"leak": True}
85
+
86
+ fn = p._handlers["set_volume"]
87
+ self.assertIsNone(asyncio.run(fn({"volume": 3})))
88
+ self.assertEqual(seen, {"volume": 3})
89
+
74
90
 
75
91
  if __name__ == "__main__":
76
92
  unittest.main()
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes