{
"repo": "bare-kit",
"timestamp": "2026-01-16T23:39:43.316Z",
"entryPoint": "index.js",
"exports": {
"packageJson": {}
},
"api": {},
"readme": {
"content": "# bare-kit\n\nBare for native application development. The kit provides a web worker-like API to start and manage isolated Bare threads, called worklets[^1], that expose an IPC abstraction with bindings for various languages.\n\n[^1]: This term was chosen to avoid ambiguity with worker threads as implemented by <https://github.com/holepunchto/bare-worker>.\n\n## Worklet\n\nIn this section, we will learn how to create a worklet both iOS and Android.\n\n### iOS\n\nThis is a basic example of how to create a worklet in Objective-C:\n\n```objc\n#import <BareKit/BareKit.h>\n#import <Foundation/Foundation.h>\n\nint\nmain() {\n BareWorkletConfiguration *options = [BareWorkletConfiguration defaultWorkletConfiguration];\n options.memoryLimit = 1024 * 1024 * 24; // 24 MiB\n\n BareWorklet *worklet = [[BareWorklet alloc] initWithConfiguration:options];\n\n NSString *source = @\"console.log('hello from the worklet')\";\n\n [worklet start:@\"/app.js\" source:[source dataUsingEncoding:NSUTF8StringEncoding] arguments:@[]];\n\n [",
"sections": [
"intro",
"worklet",
"ipc",
"notifications",
"license"
],
"hasApi": false,
"hasExamples": true,
"exampleCount": 14,
"examples": [
"You can create a `BareWorkletConfiguration` to optionally set the memory limit or attach assets. This step is optional.\n\nThe configuration is then passed to the `BareWorklet`, which represents the running worklet instance.\n\nAvailable actions on a worklet include:\n\n- `[worklet start]`: starts the worklet\n- `[worklet suspend]`: suspends the execution of the worklet\n- `[worklet suspendWithLinger]`: suspends the worklet for a specified duration; the linger integer (in milliseconds) defines how long to keep the process alive before it fully exits\n- `[worklet resume]`: resumes a suspended worklet\n- `[worklet terminate]`: terminates the worklet\n\n> [!TIP]\n> For a full API reference, see [`apple/BareKit/BareKit.h`](apple/BareKit/BareKit.h).\n\n### Android\n\nThis is a basic example of how to create a worklet in Java:",
"You can create a `Worklet.Options` to optionally set the memory limit or attach assets. This step is optional.\n\nThe configuration is then passed to the `Worklet`, which represents the running worklet instance.\n\nAvailable actions on a worklet include:\n\n- `worklet.start()`: starts the worklet\n- `worklet.suspend()`: suspends the execution of the worklet\n- `worklet.suspend(linger)`: suspends the worklet for a specified duration; the linger integer (in milliseconds) defines how long to keep the process alive before it fully exits\n- `worklet.resume()`: resumes a suspended worklet\n- `worklet.terminate()`: terminates the worklet\n\n> [!TIP]\n> For a full API reference, see [`android/src/main/java/to/holepunch/bare/kit/Worklet.java`](android/src/main/java/to/holepunch/bare/kit/Worklet.java).\n\n## IPC\n\nBare Kit provides an IPC (Inter-Process Communication) abstraction that allows communication between the main application and worklets. The IPC interface provides both synchronous and asynchronous read/write operations with callback-based event handling.\n\n> [!IMPORTANT]\n> IPC operations are **non-blocking** regardless of whether you use synchronous or asynchronous APIs. They may return partial results (e.g., writing fewer bytes than requested) and require polling to complete the operation.\n\n### iOS\n\n#### Polling IPC\n\nThe `BareIPC` class provides these methods for polling IPC:\n\n- `ipc.readable`: callback property for when data is available to read\n- `ipc.writable`: callback property for when data can be written\n- `[ipc read]`: synchronously reads available data, returns `nil` if no data is available\n- `[ipc write:data]`: synchronously writes data, returns the number of bytes written",
"> [!NOTE]\n> On iOS, IPC callbacks run on a dedicated queue, so callers must be mindful of synchronization when accessing shared resources from these callbacks.\n\n#### Async IPC\n\nThe `BareIPC` class provides these methods for async IPC:\n\n- `[ipc read:completion]`: asynchronously reads data with a completion callback\n- `[ipc write:data completion:]`: asynchronously writes data with a completion callback"
]
},
"patterns": []
}