Other Utilities

Supporting modules used by the viewer and app builder.

  • assets_helper – locate and serve Kaolin’s bundled Dash assets.

  • behavior_manifest – read the build-time library behavior manifest shipped with the wheel.

  • user_behavior_scan – discover behaviors registered in user-supplied asset directories at runtime.

The two discovery modules below are merged behind BehaviorLibrary, so most code never calls them directly. For the browser-side window.kaolin API, see the JavaScript API.

Asset serving

Helper utilities for serving Kaolin Dash library assets.

kaolin.visualize.dash.assets_helper.get_kaolin_assets_source_path() str

Get the absolute path to Kaolin’s library assets folder.

Returns

Absolute path to the assets directory

Return type

str

Behavior manifest

Python lookup for the library-side behavior manifest.

The manifest is emitted at build time by kaolin/visualize/dash/components/scripts/dump_behavior_manifest.ts (wired into npm run build:dash) and ships with the wheel under kaolin/visualize/dash/components/autogen/behavior_manifest.json.

Use get_behavior_manifest() for the full dict and get_behavior_meta() for a single entry. The unified accessor that also merges user-side scans lives in kaolin.visualize.dash.builtins.

kaolin.visualize.dash.behavior_manifest.BEHAVIOR_MANIFEST_RESOURCE = 'behavior_manifest.json'

Resource name of the manifest JSON inside the autogen package.

kaolin.visualize.dash.behavior_manifest.get_behavior_manifest() dict[str, kaolin.visualize.dash.option.BehaviorMeta]

Return the full library behavior manifest as {name: BehaviorMeta} (cached).

Each value is a kaolin.visualize.dash.option.BehaviorMeta with a description and options (a {name: OptionSpec} mapping). Returns an empty dict if the manifest has not been generated yet (a warning is logged once).

kaolin.visualize.dash.behavior_manifest.get_behavior_meta(name: str) kaolin.visualize.dash.option.BehaviorMeta | None

Return one library behavior’s BehaviorMeta, or None if unknown.

Parameters

name – behavior name as passed to BehaviorRegister.register on the JS side (e.g. 'drawing', 'konva_drawing').

User behavior scanning

Runtime regex scanner for user-side behavior assets.

V0 just discovers behavior names: every call to BehaviorRegister.register in a user-provided directory’s .js/.ts/.tsx files is matched (anchored on the dotted suffix so namespaced calls like window.kaolin.interact.behavior_register.BehaviorRegister.register("foo", ...) match). The shape returned per entry mirrors kaolin/visualize/dash/components/autogen/behavior_manifest.json for the library so the unified accessor in kaolin.visualize.dash.builtins can return either origin without callers caring which.

Future versions can extend this to parse static schema = {...} and tag isElementBound / elementType by walking class declarations; the public return shape is forward-compatible.

kaolin.visualize.dash.user_behavior_scan.USER_BEHAVIOR_FILE_SUFFIXES: frozenset[str] = frozenset({'.js', '.ts', '.tsx'})

File extensions the scanner inspects.

kaolin.visualize.dash.user_behavior_scan.scan_user_behavior_names(directories: Iterable[str | pathlib.Path]) dict[str, kaolin.visualize.dash.option.BehaviorMeta]

Scan directories recursively for BehaviorRegister.register(...) calls.

Parameters

directories – directories to scan (typically a per-app assets/ folder). Missing directories are skipped with a warning.

Returns

{behavior_name: BehaviorMeta} where each BehaviorMeta carries the source_path of the file that registered the behavior (description and options are empty in V0). If the same behavior name appears in multiple files, the last file wins (a warning is logged).