bare-kit 0.1.0__py3-none-win_arm64.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.
bare_kit/__init__.py ADDED
@@ -0,0 +1,11 @@
1
+ """Python bindings for Bare Kit."""
2
+
3
+ from .worklet import BareKitError, Worklet, optimize_for_memory, start, teardown
4
+
5
+ __all__ = [
6
+ "BareKitError",
7
+ "Worklet",
8
+ "optimize_for_memory",
9
+ "start",
10
+ "teardown",
11
+ ]
bare_kit/_host.py ADDED
@@ -0,0 +1,25 @@
1
+ import platform
2
+ import sys
3
+
4
+ SYSTEMS = {"darwin", "linux", "win32"}
5
+ ARCHS = {"arm64": "arm64", "aarch64": "arm64", "x86_64": "x64", "amd64": "x64"}
6
+
7
+
8
+ def host():
9
+ """The host triple of the running platform, named as by Bare."""
10
+ arch = ARCHS.get(platform.machine().lower())
11
+
12
+ if sys.platform not in SYSTEMS or arch is None:
13
+ raise OSError(f"Unsupported platform {sys.platform}-{platform.machine()}")
14
+
15
+ return f"{sys.platform}-{arch}"
16
+
17
+
18
+ def library_name(host):
19
+ if host.startswith("win32"):
20
+ return "bare-kit.dll"
21
+
22
+ if host.startswith("darwin"):
23
+ return "libbare-kit.dylib"
24
+
25
+ return "libbare-kit.so"
bare_kit/_native.py ADDED
@@ -0,0 +1,104 @@
1
+ import ctypes
2
+ from functools import cache
3
+ from pathlib import Path
4
+
5
+ from ._host import host, library_name
6
+
7
+ READABLE = 0x1
8
+ WRITABLE = 0x2
9
+
10
+ WOULD_BLOCK = -1
11
+ ERROR = -2
12
+
13
+ READ_BUFFER_SIZE = 64 * 1024
14
+
15
+ ExitCallback = ctypes.CFUNCTYPE(None, ctypes.c_int, ctypes.c_void_p)
16
+ PollCallback = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_int)
17
+
18
+
19
+ class WorkletOptions(ctypes.Structure):
20
+ _fields_ = [
21
+ ("version", ctypes.c_int),
22
+ ("memory_limit", ctypes.c_size_t),
23
+ ("platform", ctypes.c_void_p * 8),
24
+ ]
25
+
26
+
27
+ SIGNATURES = {
28
+ "bare_worklet_optimize_for_memory": (ctypes.c_int, [ctypes.c_bool]),
29
+ "bare_worklet_teardown": (ctypes.c_int, []),
30
+ "bare_worklet_create": (
31
+ ctypes.c_int,
32
+ [ctypes.POINTER(WorkletOptions), ctypes.POINTER(ctypes.c_void_p)],
33
+ ),
34
+ "bare_worklet_destroy": (None, [ctypes.c_void_p]),
35
+ "bare_worklet_on_exit": (
36
+ ctypes.c_int,
37
+ [ctypes.c_void_p, ExitCallback, ctypes.c_void_p],
38
+ ),
39
+ "bare_worklet_start": (
40
+ ctypes.c_int,
41
+ [
42
+ ctypes.c_void_p,
43
+ ctypes.c_char_p,
44
+ ctypes.c_void_p,
45
+ ctypes.c_size_t,
46
+ ctypes.c_int,
47
+ ctypes.POINTER(ctypes.c_char_p),
48
+ ],
49
+ ),
50
+ "bare_worklet_suspend": (ctypes.c_int, [ctypes.c_void_p, ctypes.c_int]),
51
+ "bare_worklet_resume": (ctypes.c_int, [ctypes.c_void_p]),
52
+ "bare_worklet_wakeup": (ctypes.c_int, [ctypes.c_void_p, ctypes.c_int]),
53
+ "bare_worklet_terminate": (ctypes.c_int, [ctypes.c_void_p]),
54
+ "bare_ipc_create": (
55
+ ctypes.c_int,
56
+ [ctypes.c_void_p, ctypes.POINTER(ctypes.c_void_p)],
57
+ ),
58
+ "bare_ipc_close": (None, [ctypes.c_void_p]),
59
+ "bare_ipc_end": (None, [ctypes.c_void_p]),
60
+ "bare_ipc_destroy": (None, [ctypes.c_void_p]),
61
+ "bare_ipc_read": (
62
+ ctypes.c_int,
63
+ [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_size_t],
64
+ ),
65
+ "bare_ipc_write": (
66
+ ctypes.c_int,
67
+ [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_size_t],
68
+ ),
69
+ "bare_ipc_poll_create": (
70
+ ctypes.c_int,
71
+ [ctypes.c_void_p, ctypes.POINTER(ctypes.c_void_p)],
72
+ ),
73
+ "bare_ipc_poll_destroy": (None, [ctypes.c_void_p]),
74
+ "bare_ipc_poll_get_data": (ctypes.c_void_p, [ctypes.c_void_p]),
75
+ "bare_ipc_poll_set_data": (None, [ctypes.c_void_p, ctypes.c_void_p]),
76
+ "bare_ipc_poll_start": (
77
+ ctypes.c_int,
78
+ [ctypes.c_void_p, ctypes.c_int, PollCallback],
79
+ ),
80
+ "bare_ipc_poll_stop": (ctypes.c_int, [ctypes.c_void_p]),
81
+ }
82
+
83
+
84
+ def path():
85
+ """The path of the Bare Kit library shipped for the running platform."""
86
+ current = host()
87
+ path = Path(__file__).parent / "prebuilds" / current / library_name(current)
88
+
89
+ if not path.is_file():
90
+ raise FileNotFoundError(f"No Bare Kit prebuild for {current}")
91
+
92
+ return path
93
+
94
+
95
+ @cache
96
+ def library():
97
+ lib = ctypes.CDLL(str(path()))
98
+
99
+ for name, (restype, argtypes) in SIGNATURES.items():
100
+ fn = getattr(lib, name)
101
+ fn.restype = restype
102
+ fn.argtypes = argtypes
103
+
104
+ return lib
@@ -0,0 +1,4 @@
1
+ [diffend] Oversized file quarantined before diffing.
2
+ name: bare_kit/prebuilds/win32-arm64/bare-kit.dll
3
+ size: 41411072 bytes
4
+ sha256: 5c84cacf80ace0ac9eb8a80150371ec6e97267a9917f363e88b820af6853250d
bare_kit/py.typed ADDED
File without changes
bare_kit/worklet.py ADDED
@@ -0,0 +1,403 @@
1
+ import asyncio
2
+ import ctypes
3
+ import itertools
4
+ import os
5
+ from collections import deque
6
+ from contextlib import suppress
7
+
8
+ from ._native import (
9
+ ERROR,
10
+ READ_BUFFER_SIZE,
11
+ READABLE,
12
+ WOULD_BLOCK,
13
+ WRITABLE,
14
+ ExitCallback,
15
+ PollCallback,
16
+ WorkletOptions,
17
+ library,
18
+ )
19
+
20
+
21
+ class BareKitError(Exception):
22
+ """A call into Bare Kit failed with ``status``."""
23
+
24
+ def __init__(self, status):
25
+ super().__init__(f"Bare Kit failed with status {status}")
26
+ self.status = status
27
+
28
+
29
+ def _check(status):
30
+ if status != 0:
31
+ raise BareKitError(status)
32
+
33
+
34
+ def optimize_for_memory(enabled):
35
+ """Trade performance for memory. Must be configured before starting the
36
+ first worklet."""
37
+ library().bare_worklet_optimize_for_memory(enabled)
38
+
39
+
40
+ def teardown():
41
+ """Tear down the state shared by the worklets of the process.
42
+
43
+ Every worklet must have been closed first. Must be called at most once,
44
+ after which starting a worklet fails. A process that runs worklets for as
45
+ long as it lives need not call it.
46
+ """
47
+ library().bare_worklet_teardown()
48
+
49
+
50
+ # Bare Kit calls back from threads of its own, possibly after the worklet that a
51
+ # callback is for has been released, so the callbacks are shared and look the
52
+ # worklet up by key.
53
+ _worklets = {}
54
+ _keys = itertools.count(1)
55
+
56
+
57
+ @ExitCallback
58
+ def _on_exit(code, data):
59
+ worklet = _worklets.get(data)
60
+
61
+ if worklet is not None:
62
+ worklet._call_soon(worklet._on_exit, code)
63
+
64
+
65
+ @PollCallback
66
+ def _on_poll(poll, events):
67
+ # Polls are level-triggered, so the poll is stopped until the loop has
68
+ # handled the events and starts it again.
69
+ library().bare_ipc_poll_stop(poll)
70
+
71
+ worklet = _worklets.get(library().bare_ipc_poll_get_data(poll))
72
+
73
+ if worklet is not None:
74
+ worklet._call_soon(worklet._on_poll)
75
+
76
+
77
+ async def start(filename, *args, source=None, memory_limit=0):
78
+ """Start ``filename`` in a worklet with an IPC connection to it and return
79
+ its ``Worklet``.
80
+
81
+ ``args`` are passed to the worklet as ``Bare.argv``. ``source`` is the
82
+ source of the module, read from ``filename`` if ``None``. ``memory_limit``
83
+ is the memory limit of each JavaScript heap in bytes, or 0 to infer it from
84
+ the amount of physical memory of the device.
85
+ """
86
+ worklet = Worklet(asyncio.get_running_loop(), memory_limit)
87
+
88
+ try:
89
+ worklet._start(filename, args, source)
90
+ except BaseException:
91
+ worklet._destroy()
92
+ raise
93
+
94
+ return worklet
95
+
96
+
97
+ class Worklet:
98
+ """A Bare runtime running on a thread of its own, connected to its
99
+ ``Bare.IPC``.
100
+
101
+ Iterating it with ``async for`` yields the data the worklet writes to
102
+ ``Bare.IPC`` until the connection ends, and leaving ``async with`` closes
103
+ it. Use ``start()`` to start one.
104
+ """
105
+
106
+ def __init__(self, loop, memory_limit):
107
+ lib = library()
108
+
109
+ self._loop = loop
110
+ self._key = next(_keys)
111
+ self._handle = ctypes.c_void_p()
112
+ self._ipc = ctypes.c_void_p()
113
+ self._poll = ctypes.c_void_p()
114
+ self._buffer = ctypes.create_string_buffer(READ_BUFFER_SIZE)
115
+ self._exited = loop.create_future()
116
+ self._started = False
117
+ self._closed = False
118
+
119
+ self._events = 0
120
+ self._chunks = deque()
121
+ self._buffered = 0
122
+ self._eof = False
123
+ self._reader = None
124
+ self._writes = deque()
125
+ self._ending = False
126
+ self._ended = False
127
+ self._disconnected = False
128
+
129
+ options = WorkletOptions(version=0, memory_limit=memory_limit)
130
+
131
+ _check(
132
+ lib.bare_worklet_create(ctypes.byref(options), ctypes.byref(self._handle))
133
+ )
134
+
135
+ try:
136
+ _check(lib.bare_ipc_create(self._handle, ctypes.byref(self._ipc)))
137
+ _check(lib.bare_ipc_poll_create(self._ipc, ctypes.byref(self._poll)))
138
+ except BaseException:
139
+ self._destroy()
140
+ raise
141
+
142
+ lib.bare_ipc_poll_set_data(self._poll, self._key)
143
+ lib.bare_worklet_on_exit(self._handle, _on_exit, self._key)
144
+
145
+ _worklets[self._key] = self
146
+
147
+ def _start(self, filename, args, source):
148
+ argv = [os.fsencode(arg) for arg in args]
149
+
150
+ _check(
151
+ library().bare_worklet_start(
152
+ self._handle,
153
+ os.fsencode(filename),
154
+ source,
155
+ 0 if source is None else len(source),
156
+ len(argv),
157
+ (ctypes.c_char_p * (len(argv) + 1))(*argv, None),
158
+ )
159
+ )
160
+
161
+ self._started = True
162
+ self._update()
163
+
164
+ @property
165
+ def exit_code(self):
166
+ """The exit code of the worklet, or ``None`` while it is running."""
167
+ return self._exited.result() if self._exited.done() else None
168
+
169
+ async def read(self, n=65536):
170
+ """Read up to ``n`` bytes from the worklet, or ``b""`` once it has
171
+ ended its end of the connection."""
172
+ while not self._chunks and not self._eof:
173
+ self._reader = self._loop.create_future()
174
+
175
+ try:
176
+ await self._reader
177
+ finally:
178
+ self._reader = None
179
+
180
+ if not self._chunks:
181
+ self._close_ipc()
182
+ return b""
183
+
184
+ chunk = self._chunks.popleft()
185
+
186
+ if len(chunk) > n:
187
+ self._chunks.appendleft(chunk[n:])
188
+ chunk = chunk[:n]
189
+
190
+ self._buffered -= len(chunk)
191
+ self._update()
192
+
193
+ return chunk
194
+
195
+ def __aiter__(self):
196
+ return self._chunks_until_eof()
197
+
198
+ async def _chunks_until_eof(self):
199
+ while chunk := await self.read():
200
+ yield chunk
201
+
202
+ async def write(self, data):
203
+ """Write ``data`` to the worklet and wait for it to drain.
204
+
205
+ Data written once the connection has ended or closed, such as while the
206
+ worklet exits, is dropped, as its exit already accounts for it.
207
+ """
208
+ if self._ending or not data:
209
+ return
210
+
211
+ written = self._loop.create_future()
212
+
213
+ self._writes.append([bytes(data), 0, written])
214
+ self._flush()
215
+ self._update()
216
+
217
+ await written
218
+
219
+ def end(self):
220
+ """End the data written to the worklet once the pending writes drain,
221
+ after which ``Bare.IPC`` reads end-of-stream while reading continues."""
222
+ if self._ending:
223
+ return
224
+
225
+ self._ending = True
226
+ self._flush()
227
+ self._update()
228
+
229
+ def suspend(self, linger=-1):
230
+ """Suspend the worklet, emitting ``suspend`` on ``Bare``.
231
+
232
+ ``linger`` is how long in milliseconds the worklet may keep running
233
+ before it goes idle, or -1 for as long as the platform allows.
234
+ """
235
+ library().bare_worklet_suspend(self._handle, linger)
236
+
237
+ def resume(self):
238
+ """Resume a suspended worklet, emitting ``resume`` on ``Bare``."""
239
+ library().bare_worklet_resume(self._handle)
240
+
241
+ def wakeup(self, deadline=-1):
242
+ """Wake up a suspended worklet, emitting ``wakeup`` on ``Bare``.
243
+
244
+ ``deadline`` is how long in milliseconds the worklet may run before it
245
+ goes idle again, or -1 for as long as the platform allows.
246
+ """
247
+ library().bare_worklet_wakeup(self._handle, deadline)
248
+
249
+ def terminate(self):
250
+ """Ask the worklet to exit unless it has already exited."""
251
+ library().bare_worklet_terminate(self._handle)
252
+
253
+ async def wait(self):
254
+ """Wait for the worklet to exit and return its exit code."""
255
+ return await asyncio.shield(self._exited)
256
+
257
+ async def close(self):
258
+ """Close the connection, terminating the worklet if it is still
259
+ running, and wait for it to exit."""
260
+ if self._closed:
261
+ return
262
+
263
+ self._close_ipc()
264
+ self.terminate()
265
+
266
+ await self.wait()
267
+
268
+ self._destroy()
269
+
270
+ async def __aenter__(self):
271
+ return self
272
+
273
+ async def __aexit__(self, *exc):
274
+ await self.close()
275
+
276
+ def _call_soon(self, callback, *args):
277
+ # The loop may have been closed while a worklet was left running.
278
+ with suppress(RuntimeError):
279
+ self._loop.call_soon_threadsafe(callback, *args)
280
+
281
+ def _on_exit(self, code):
282
+ if not self._exited.done():
283
+ self._exited.set_result(code)
284
+
285
+ def _on_poll(self):
286
+ if self._closed:
287
+ return
288
+
289
+ self._events = 0
290
+ self._drain()
291
+ self._flush()
292
+ self._update()
293
+
294
+ def _drain(self):
295
+ lib = library()
296
+
297
+ while not self._eof and self._buffered < READ_BUFFER_SIZE:
298
+ read = lib.bare_ipc_read(self._ipc, self._buffer, READ_BUFFER_SIZE)
299
+
300
+ if read > 0:
301
+ self._chunks.append(ctypes.string_at(self._buffer, read))
302
+ self._buffered += read
303
+ else:
304
+ if read == 0:
305
+ self._eof = True
306
+
307
+ break
308
+
309
+ if self._reader is not None and not self._reader.done():
310
+ if self._chunks or self._eof:
311
+ self._reader.set_result(None)
312
+
313
+ def _flush(self):
314
+ lib = library()
315
+
316
+ while self._writes:
317
+ write = self._writes[0]
318
+ data, offset, written = write
319
+
320
+ result = lib.bare_ipc_write(
321
+ self._ipc,
322
+ ctypes.cast(data, ctypes.c_void_p).value + offset,
323
+ len(data) - offset,
324
+ )
325
+
326
+ if result == WOULD_BLOCK:
327
+ break
328
+
329
+ if result == ERROR:
330
+ self._drop_writes()
331
+ break
332
+
333
+ write[1] = offset = offset + result
334
+
335
+ if offset == len(data):
336
+ self._writes.popleft()
337
+
338
+ if not written.done():
339
+ written.set_result(None)
340
+
341
+ if self._ending and not self._writes and not self._ended:
342
+ self._ended = True
343
+ lib.bare_ipc_end(self._ipc)
344
+
345
+ def _drop_writes(self):
346
+ while self._writes:
347
+ _, _, written = self._writes.popleft()
348
+
349
+ if not written.done():
350
+ written.set_result(None)
351
+
352
+ def _update(self):
353
+ if self._closed or not self._started:
354
+ return
355
+
356
+ events = 0
357
+
358
+ if not self._eof and self._buffered < READ_BUFFER_SIZE:
359
+ events |= READABLE
360
+
361
+ if self._writes:
362
+ events |= WRITABLE
363
+
364
+ if events == self._events:
365
+ return
366
+
367
+ self._events = events
368
+
369
+ if events:
370
+ library().bare_ipc_poll_start(self._poll, events, _on_poll)
371
+ else:
372
+ library().bare_ipc_poll_stop(self._poll)
373
+
374
+ def _close_ipc(self):
375
+ """Close the connection, which the worklet waits for before it exits
376
+ once it has ended its side."""
377
+ if self._ipc and not self._disconnected:
378
+ self._disconnected = True
379
+ library().bare_ipc_close(self._ipc)
380
+
381
+ self._ending = self._ended = True
382
+ self._eof = True
383
+ self._drop_writes()
384
+
385
+ if self._reader is not None and not self._reader.done():
386
+ self._reader.set_result(None)
387
+
388
+ def _destroy(self):
389
+ lib = library()
390
+
391
+ self._closed = True
392
+ self._close_ipc()
393
+
394
+ _worklets.pop(self._key, None)
395
+
396
+ if self._poll:
397
+ lib.bare_ipc_poll_destroy(self._poll)
398
+
399
+ if self._ipc:
400
+ lib.bare_ipc_destroy(self._ipc)
401
+
402
+ if self._handle:
403
+ lib.bare_worklet_destroy(self._handle)
@@ -0,0 +1,56 @@
1
+ Metadata-Version: 2.5
2
+ Name: bare-kit
3
+ Version: 0.1.0
4
+ Summary: Python bindings for Bare Kit
5
+ Project-URL: Homepage, https://github.com/holepunchto/bare-kit-python
6
+ Project-URL: Repository, https://github.com/holepunchto/bare-kit-python
7
+ Project-URL: Issues, https://github.com/holepunchto/bare-kit-python/issues
8
+ Author: Holepunch
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ License-File: NOTICE
12
+ Requires-Python: >=3.10
13
+ Provides-Extra: dev
14
+ Requires-Dist: pytest>=8; extra == 'dev'
15
+ Requires-Dist: ruff>=0.6; extra == 'dev'
16
+ Description-Content-Type: text/markdown
17
+
18
+ # bare-kit-python
19
+
20
+ Python bindings for [Bare Kit](https://github.com/holepunchto/bare-kit), which runs Bare in a thread of its own within the application, known as a worklet, with an IPC to it exposed as `Bare.IPC` inside the worklet.
21
+
22
+ ```
23
+ pip install bare-kit
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ ```python
29
+ import asyncio
30
+ from pathlib import Path
31
+
32
+ from bare_kit import start
33
+
34
+
35
+ async def main():
36
+ async with await start(Path(__file__).parent / "app.bundle") as worklet:
37
+ await worklet.write(b"Hello world")
38
+
39
+ async for data in worklet:
40
+ print(data.decode())
41
+
42
+
43
+ asyncio.run(main())
44
+ ```
45
+
46
+ Where `app.bundle` is a Bare bundle using `Bare.IPC`:
47
+
48
+ ```js
49
+ Bare.IPC.on('data', (data) => Bare.IPC.end(data))
50
+ ```
51
+
52
+ Closing a worklet terminates it, so keep it open for as long as it should run.
53
+
54
+ ## License
55
+
56
+ Apache-2.0
@@ -0,0 +1,11 @@
1
+ bare_kit/__init__.py,sha256=dsLKs63xR2TZnhzDiyqitpVdYmWALdZi9z4ZFpeEUhQ,224
2
+ bare_kit/_host.py,sha256=hjXblZSiHrTxv43Z_aacG6RzdCo9RWRY5Srh7tO0CxQ,640
3
+ bare_kit/_native.py,sha256=q4sFHqoCNQ9fApxnScJMw9VOAiDsJUeco89fomswsCQ,3025
4
+ bare_kit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ bare_kit/worklet.py,sha256=DWuOgCx9b6P74VQlcC0uT7jVc9_uNsPslZwjyG0Ir2I,11343
6
+ bare_kit/prebuilds/win32-arm64/bare-kit.dll,sha256=XITKz4Cs4KyeuKgBUDcexulyZ6mRfzY-iLggr2hTJQ0,41411072
7
+ bare_kit-0.1.0.dist-info/METADATA,sha256=oBc-IyLJXGiO8b4XMEvBreEwkMLSA-44s9JuRZXyu0U,1376
8
+ bare_kit-0.1.0.dist-info/WHEEL,sha256=WFezGyxI7afY59fTEbTiueKbbEV_hMxzB_HK5n-3eUY,94
9
+ bare_kit-0.1.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
10
+ bare_kit-0.1.0.dist-info/licenses/NOTICE,sha256=hdAkJJsXX3Bg31bhcXn-xt_HHvZOAp-Yb3rwwHPxWzU,554
11
+ bare_kit-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: false
4
+ Tag: py3-none-win_arm64
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,13 @@
1
+ Copyright 2026 Holepunch Inc
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.