Creating packages
Place packages inside your project at packages/MyWidgets.package/. Add
"MyWidgets": "1.0.0" to packages in project.json, alongside "Video2D": "1.0.0". Add "package_overrides": {"MyWidgets": {"path": "packages/MyWidgets.package"}} while editing the package in your project; never edit the generated lock.
The directory name must match the manifest ID.
{
"id": "MyWidgets", "version": "1.0.0", "api_version": 1,
"description": "Reusable animation widgets", "dependencies": {"Neutral": "^1.0.0"},
"compatibility": {"host": 1, "dom": 1, "python": "python-3.13-v1", "video2d": "^1.0.0"},
"plugins": [
{"id": "widgets.python", "type": "python", "entry": "python/widgets.py", "description": "Widgets"},
{"id": "widgets.colors", "type": "color-scheme", "entry": "colors.json", "description": "Widget colors"}
]
}
Keep a package self-contained and export only its public entry points. A
minimal Python-only package has package.json plus python/widgets.py; add a
palette, renderer, or data source as separate plugins when the feature needs
one. Python entry modules should expose a register() function for properties
that must be registered before any entity is constructed.
Python components and animations
Export public classes/functions from the entry module. Project code imports them
with from manifest.widgets import Widget. All selected Python plugins activate
automatically, including dependencies. Package modules still receive their own injected manifest;
use manifest.python() to access declared dependencies. Put one-time property
registration in a register() function. Use relative imports for helper modules.
Build compound components by extending EntityWithChildren and constructing
primitive children attached to the component. Expose meaningful child groups so
callers can animate them independently. Compose reusable animations with Sequence
and Bundle; an animation protocol implementation supplies timeline() returning
its relative timeline. Do not mutate returned timeline structure after insertion.
Avoid concurrent writes to the same property.
Colors
colors.json maps names to RGB arrays, for example {"accent": [80, 160, 240]}.
Use manifest.color_schemes['widgets.colors']['accent'] rather than embedding the RGB triple in components. Override named scheme values through color_schemes in project.json. Keep each palette associated with its plugin ID.
For JavaScript renderer extensions, see Creating Render Plugins.
Published package versions cannot change bytes. The lock stores exact versions, content hashes, dependencies, sources, and the Python execution profile. Explicit local overrides capture a new immutable hash on each build. Opening an older project uses its locked artifacts; a missing artifact is an error, never a request to substitute the current package.
Data sources
Declare a data-source plugin and call manifest.data.read(plugin_id, request).
Animate manages service connections and credentials. Code's code.syntax
plugin provides syntax highlighting. Use recorded or stub responses when testing
your own data-source package.
Documentation and validation
Write Google-style docstrings describing arguments, returns, units, side effects, and examples. Include a README with setup, dependencies, and a runnable project. Mark the intended disclosure level on public interfaces and source examples. Choose Save & Run in an example project, then inspect its first, middle, and last frames. Use the Packages panel to select package versions.
For the owner workflow and immutable releases, see Publishing Packages.
Complete package walkthrough
Create the files below in your project. Its complete directory layout is:
main.py
project.json
packages/
Badges.package/
package.json
colors.json
python/badge.py
renderer/tint.mjs
The project selects Badges; its dependency brings in Neutral. The Python component uses ordinary white rectangle geometry plus two extra properties. A reusable animation changes the tint strength, while the renderer reads the resolved strength at each frame and applies a color. Because it computes the whole effect from the current state, backward seeks and repeated export frames produce the same result.

main.py
from manifest.badges import Badge, Pulse
from manifest import color_schemes
from manifest import Video2d, Position, Move
colors = color_schemes['neutral.colors']
def build(seq, frame):
badge = Badge(frame, Position(80, 100))
seq.show(Pulse(badge), Move(badge, Position(200, 0), time=1))
seq.show(0.5)
def make_video():
return Video2d(build, resolution=(640, 360), fps=30, background_color=colors['background'])
packages/Badges.package/colors.json
{"badge_accent": [80, 160, 240]}
packages/Badges.package/package.json
{
"id": "Badges",
"version": "1.0.0",
"api_version": 1,
"description": "A reusable badge with a palette and renderer effect.",
"dependencies": {
"Neutral": "^1.0.0"
},
"plugins": [
{
"id": "badges.python",
"type": "python",
"entry": "python/badge.py",
"description": "Badge component and pulse animation."
},
{
"id": "badges.colors",
"type": "color-scheme",
"entry": "colors.json",
"description": "Badge accent color."
},
{
"id": "badges.tint",
"type": "renderer",
"entry": "renderer/tint.mjs",
"description": "Tint white badge geometry from its animated strength."
}
],
"compatibility": {
"host": 1,
"dom": 1,
"python": "python-3.13-v1",
"video2d": "^1.0.0",
"extension": 1
}
}
packages/Badges.package/python/badge.py
"""Reusable badge geometry; manifest is supplied by the package loader."""
from codeanimate.video2d import Rectangle, Position, AbsoluteTransition, Sequence
__all__ = ['Badge', 'Pulse']
class Badge(Rectangle):
"""A white badge with an animated tint supplied by badges.tint.
Args:
parent: Parent entity.
position: Local top-left position.
size: Width and height; defaults to 180 by 80.
"""
def __init__(self, parent, position, size=None):
super().__init__(parent, position, Position(180, 80) if size is None else size, fill=(255, 255, 255), badge_tint=0, badge_color=manifest.color_schemes['badges.colors']['badge_accent'])
class Pulse(Sequence):
"""Tint a badge to its accent and return to white over one second."""
def __init__(self, badge):
super().__init__(AbsoluteTransition('badge_tint', badge, 1, time=0.5), AbsoluteTransition('badge_tint', badge, 0, time=0.5))
packages/Badges.package/renderer/tint.mjs
export const extensionApiVersion = 1;
export function create() {
return {
register(registry) {
registry.registerEffect('badges.tint', {
applies(_node, props) { return Array.isArray(props.badge_color); },
paint(context, draw) {
const { kit, canvas, props } = context;
const strength = Math.max(0, Math.min(1, Number(props.badge_tint ?? 0)));
const channels = props.badge_color.map(channel => (255 + (channel - 255) * strength) / 255);
const filter = kit.ColorFilter.MakeMatrix([
channels[0], 0, 0, 0, 0,
0, channels[1], 0, 0, 0,
0, 0, channels[2], 0, 0,
0, 0, 0, 1, 0,
]);
const paint = new kit.Paint();
paint.setColorFilter(filter);
canvas.saveLayer(paint, context.localBounds ?? undefined);
try {
return draw();
}
finally {
canvas.restore();
paint.delete();
filter.delete();
}
},
});
},
dispose() { },
};
}
project.json
{
"version": 2,
"packages": {
"Video2D": "1.0.0",
"Badges": "1.0.0"
},
"assets": {},
"fonts": {
"JetBrains Mono": [
{
"path": "assets/fonts/jetbrains-mono/JetBrainsMono-Regular.ttf",
"weight": 400,
"style": "normal"
}
]
},
"package_overrides": {
"Badges": {
"path": "packages/Badges.package"
}
}
}
The __all__ declaration makes the intended Python exports explicit. Use
from manifest.badges import Badge, not a filesystem import into the package directory. The package
loader injects the selected manifest into the entry module. A regular standalone
import badge does not provide that manifest.
Override badge_accent under color_schemes["badges.colors"] in project.json to change this package’s color. A Python-only package can omit the renderer declaration and renderer file;
a palette-only package needs only the color declaration and colors.json. To add
a custom property shared by a core entity class, use register() and defineProp
before constructing entities; constructor-supplied properties are enough here.
The example's JavaScript effect targets Animate preview and export. Standalone native renderers need their own implementation of that plugin. Package versions are descriptive labels; content hashes pin the actual code, palettes and renderer files used by a revision. Local package edits enter the next revision on Save & Run.
Data-source package template
A data-source declaration identifies a service; it does not start it:
{"id":"weather.forecast","type":"data-source","entry":"data-sources/weather.json","description":"Forecast observations"}
Ask the project administrator to configure the declared service. Keep credentials out of project code. Call manifest.data.read('weather.forecast', {'city': 'Boston'}) to read it. Test with recorded or stub responses.
Import namespaces
The core library owns the top-level manifest package; projects do not contain a
manifest.py file. A Python plugin ID loses its trailing .python, and remaining
punctuation becomes underscores: widgets.python exposes manifest.widgets,
while widgets.extra.python exposes manifest.widgets_extra. Names must be public
Python identifiers and cannot be keywords. Conflicting names, including core
exports such as colors, fail with a namespace error instead of silently replacing
an export. Prefer short lowercase IDs ending in .python.
Palette-only, renderer, and data-source plugins do not create Python submodules.
Use from manifest import colors, assets, data, project for project configuration.
Renderers are still instantiated by the viewer; data services are called on demand.
Within reusable package source, keep using the injected manifest.python(...) for
package dependencies and relative imports for helpers. The project-facing namespace
is published after package initialization; importing it from plugin initialization
would create a circular dependency.