Class ByteboxExtension
bytebox { } block.
bytebox {
handlerClass = "com.example.MyWorker"
size {
module = ModuleType.AUTO
budget = "250KiB"
}
wrangler {
name = "my-worker"
compatibilityDate = "2026-08-22"
routes("example.com/*")
crons("*/5 * * * *")
}
bindings {
kv()
d1()
}
}
- Since:
- 1.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbindings(BindingType... types) Declares bindings by type, each taking its default name.voidDeclares bindings.voiddurableObjects(String... classes) Exposes Java classes as Durable Objects.Returns the declared bindings.abstract org.gradle.api.provider.Property<Boolean> Returns whether applying the plugin puts bytebox on the classpath, which it does by default.abstract org.gradle.api.provider.Property<String> Returns the version ofbytebox-coreto add, defaulting to the plugin's own.abstract org.gradle.api.provider.ListProperty<String> Returns the Java classes to expose as Durable Objects, fully qualified.abstract org.gradle.api.provider.Property<String> Returns the class implementing one or more of the trigger interfaces.abstract org.gradle.api.provider.ListProperty<String> Returns the types to generate JSON codecs for, fully qualified.abstract org.gradle.api.provider.ListProperty<String> Returns the npm packages to generate Java bindings for.abstract org.gradle.api.provider.Property<Boolean> Returns whether the generator may import a package to read exports no static analysis can see.abstract org.gradle.api.provider.ListProperty<String> Returns the npm packages the compiled program imports, asname@range.abstract org.gradle.api.provider.Property<String> Returns which runtime runs the Wrangler CLI.abstract org.gradle.api.provider.ListProperty<String> Returns the types to generatejava.ioserialization codecs for, fully qualified.getSize()Returns how the compiled module is packed and how big it is allowed to get.Returns what goes into the generated Wrangler configuration.voidAdds types to generate JSON codecs for.voidDeclares an npm package the compiled program imports.voidnpmBindings(String... packages) Asks for generated Java bindings for packages already declared withnpm(java.lang.String, java.lang.String).voidserialTypes(String... types) Adds types to generate serialization codecs for.voidConfigures packing and the size budget.voidwrangler(org.gradle.api.Action<WranglerSpec> action) Configures the generated Wrangler configuration.
-
Constructor Details
-
ByteboxExtension
@Inject public ByteboxExtension(org.gradle.api.model.ObjectFactory objects) - Parameters:
objects- Gradle's factory, for the nested blocks
-
-
Method Details
-
getHandlerClass
Returns the class implementing one or more of the trigger interfaces.Which interfaces it implements decides which handlers the generated Worker exports and which trigger keys the generated Wrangler configuration carries. An unimplemented trigger produces neither.
- Returns:
- the class implementing one or more of the trigger interfaces
-
getCoreDependency
Returns whether applying the plugin puts bytebox on the classpath, which it does by default.Set this false for a project that resolves bytebox some other way: a composite build, a local jar, or a version catalog entry it would rather own.
- Returns:
- whether applying the plugin puts bytebox on the classpath, which it does by default
-
getCoreVersion
Returns the version ofbytebox-coreto add, defaulting to the plugin's own.The two are released together, so the default is the pair that was tested. A project that pins something else is choosing to compile against a surface these generators may not write.
- Returns:
- the version of
bytebox-coreto add, defaulting to the plugin's own
-
getRunner
Returns which runtime runs the Wrangler CLI.Resolved once, in this order: a
wrangleralready onPATH, thenbunx, thendeno, thennpx. Set this to pin one.- Returns:
- which runtime runs the Wrangler CLI
-
getJSONTypes
Returns the types to generate JSON codecs for, fully qualified.Only needed for a type the annotation cannot reach: one in a dependency, or one whose source you do not control. Anything annotated
@JSONTypein this project is found on its own.- Returns:
- the types to generate JSON codecs for, fully qualified
-
jsonTypes
Adds types to generate JSON codecs for.- Parameters:
types- the fully qualified type names
-
getDurableObjectClasses
Returns the Java classes to expose as Durable Objects, fully qualified.Which handlers each one gets is read from the interfaces it implements, so an object that takes no alarm has no alarm handler in the generated JavaScript class.
- Returns:
- the Java classes to expose as Durable Objects, fully qualified
-
durableObjects
Exposes Java classes as Durable Objects.The build writes the JavaScript class the runtime instantiates, the binding, and the migration that creates the class. One Java instance exists per Durable Object instance, so a field on it is that object's memory.
bytebox { durableObjects("com.example.Counter", "com.example.Room") }- Parameters:
classes- the fully qualified class names
-
getSerialTypes
Returns the types to generatejava.ioserialization codecs for, fully qualified.Only needed for a type the annotation cannot reach. Anything annotated
@SerialTypein this project is found on its own.- Returns:
- the types to generate
java.ioserialization codecs for, fully qualified
-
serialTypes
Adds types to generate serialization codecs for.- Parameters:
types- the fully qualified type names
-
getNPMPackages
Returns the npm packages the compiled program imports, asname@range.An npm package is JavaScript, so it never enters the WebAssembly. It stays on the JavaScript side and costs bundle bytes rather than module bytes.
- Returns:
- the npm packages the compiled program imports, as
name@range
-
npm
Declares an npm package the compiled program imports.Writes it into the generated
package.jsonand emits a static import beside the loader, which is what makes it resolvable: a package name reached only from inside the WebAssembly lives in a custom section, and no bundler can follow that.Reach it from Java with
@JSBodyImport:@JSBody( params = "size", imports = @JSBodyImport(alias = "nanoid", fromModule = "nanoid"), script = "return nanoid.nanoid(size);" ) private static native String id(int size);- Parameters:
name- the package nameversion- the version range
-
getNPMBindingPackages
Returns the npm packages to generate Java bindings for.A subset of
getNPMPackages(), because generating needs the package installed and a JavaScript runtime onPATHwhile merely depending on one does not.- Returns:
- the npm packages to generate Java bindings for
-
npmBindings
Asks for generated Java bindings for packages already declared withnpm(java.lang.String, java.lang.String).generateNpmBindingsreads each package's TypeScript types and writes a class of@JSBodymethods onto the main source set, so the package is callable without a line of hand-written interop. A subpath export is named the way an import names it:bytebox { npm("nanoid", "^5.0.9") npmBindings("nanoid", "edgeport/smtp") }What a package's types cannot express becomes
TSObject, and the task prints which tier each package resolved on, so a thin binding is visible rather than a surprise.- Parameters:
packages- the package specifiers
-
getNPMIntrospection
Returns whether the generator may import a package to read exports no static analysis can see.On by default. Installing a package already runs its own install scripts, so importing one is not a new trust boundary — but it is the only tier that executes third-party code, and this is how a build says it may not.
- Returns:
- whether the generator may import a package to read exports no static analysis can see
-
getSize
Returns how the compiled module is packed and how big it is allowed to get.- Returns:
- how the compiled module is packed and how big it is allowed to get
-
size
Configures packing and the size budget.- Parameters:
action- the configuration
-
getWrangler
Returns what goes into the generated Wrangler configuration.- Returns:
- what goes into the generated Wrangler configuration
-
wrangler
Configures the generated Wrangler configuration.- Parameters:
action- the configuration
-
getBindings
Returns the declared bindings.- Returns:
- the declared bindings
-
bindings
Declares bindings.- Parameters:
action- the configuration
-
bindings
Declares bindings by type, each taking its default name.- Parameters:
types- the types
-