@tur-ng/std 0.0.9 → 0.0.10
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.
- package/package.json +1 -1
- package/src/index.d.ts +87 -0
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -817,4 +817,91 @@ declare module "tur:std" {
|
|
|
817
817
|
|
|
818
818
|
/** Encode a string into a Uint8Array of UTF-8 bytes. */
|
|
819
819
|
export function encodeUtf8(text: string): Uint8Array;
|
|
820
|
+
|
|
821
|
+
// ------------------------------------------------------------------
|
|
822
|
+
// Virtual apps — VirtualAppView hosts a complete nested engine
|
|
823
|
+
// instance (own worker, realm, store, tree) and draws the child's
|
|
824
|
+
// frames from its own paint. The controller is a lazy declaration:
|
|
825
|
+
// nothing runs until an element binds it (`app$` resolving to a
|
|
826
|
+
// controller); unbinding destroys the child unless `keepAlive`.
|
|
827
|
+
// ------------------------------------------------------------------
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* Opaque handle to a registered module source (`createModuleSource`).
|
|
831
|
+
* The source string never crosses the JS API again — only this handle
|
|
832
|
+
* does (the JS mirror of the Rust-side `ModuleSourceRegistry` /
|
|
833
|
+
* `load_module_source` flow).
|
|
834
|
+
*/
|
|
835
|
+
export interface ModuleSourceHandle {
|
|
836
|
+
readonly __moduleSource: unique symbol;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
* Opaque handle to a worker pool registered on the runtime
|
|
841
|
+
* (`forWorkerPool`). The JS mirror of the Rust-side `WorkerPoolHandle`
|
|
842
|
+
* — resolved eagerly against the registry, so an unknown name throws
|
|
843
|
+
* at the call site.
|
|
844
|
+
*/
|
|
845
|
+
export interface WorkerPoolHandle {
|
|
846
|
+
readonly __workerPool: unique symbol;
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
/** Lifecycle state of a hosted virtual app. */
|
|
850
|
+
export type VirtualAppStatus =
|
|
851
|
+
| "idle"
|
|
852
|
+
| "spawning"
|
|
853
|
+
| "running"
|
|
854
|
+
| "error"
|
|
855
|
+
| "destroyed";
|
|
856
|
+
|
|
857
|
+
/** A hosted virtual app's controller — a lazy declaration. */
|
|
858
|
+
export interface VirtualAppController {
|
|
859
|
+
/** Reactive status — read via `store.get(app.status$)`. */
|
|
860
|
+
readonly status$: Readable<VirtualAppStatus>;
|
|
861
|
+
/** Error detail (module load / start failures) — read via `store.get`. */
|
|
862
|
+
readonly errorMsg$: Readable<string>;
|
|
863
|
+
/**
|
|
864
|
+
* The ONLY lifecycle action — a control mutation (the `watch`
|
|
865
|
+
* `{ start$, stop$ }` convention: side effects ride the mutation
|
|
866
|
+
* rail). Dispatch via `store.set(app.destroy$)`. New code =
|
|
867
|
+
* destroy$ + a new controller with a new source.
|
|
868
|
+
*/
|
|
869
|
+
readonly destroy$: Mutation;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
/** Register a module source once; reference it by opaque handle. */
|
|
873
|
+
export function createModuleSource(source: string): ModuleSourceHandle;
|
|
874
|
+
|
|
875
|
+
/**
|
|
876
|
+
* Resolve a registered worker pool by name — eagerly (an unknown name
|
|
877
|
+
* throws right here). The only source of the handle
|
|
878
|
+
* `createVirtualAppController({ pool })` accepts.
|
|
879
|
+
*/
|
|
880
|
+
export function forWorkerPool(name: string): WorkerPoolHandle;
|
|
881
|
+
|
|
882
|
+
/** Create a virtual-app controller (lazy — spawns on first bind). */
|
|
883
|
+
export function createVirtualAppController(opts: {
|
|
884
|
+
source: ModuleSourceHandle;
|
|
885
|
+
/**
|
|
886
|
+
* Target worker pool, from `forWorkerPool(name)` (handle-only — raw
|
|
887
|
+
* strings are rejected). Omit for the default `"virtual"` pool.
|
|
888
|
+
*/
|
|
889
|
+
pool?: WorkerPoolHandle;
|
|
890
|
+
/** Survive element unbind (default `false`). */
|
|
891
|
+
keepAlive?: boolean;
|
|
892
|
+
}): VirtualAppController;
|
|
893
|
+
|
|
894
|
+
/** Element hosting a virtual app; draws the child's latest frame. */
|
|
895
|
+
export function VirtualAppView(props: {
|
|
896
|
+
/** Reactive controller binding — `null` unbinds (destroys). */
|
|
897
|
+
app$: Readable<VirtualAppController | null>;
|
|
898
|
+
background?: Val<Color>;
|
|
899
|
+
width?: Val<number>;
|
|
900
|
+
height?: Val<number>;
|
|
901
|
+
queryKey?: Array<string>;
|
|
902
|
+
/** Painted while the child isn't live. */
|
|
903
|
+
fallback?: Element;
|
|
904
|
+
/** Painted on error. */
|
|
905
|
+
errorView?: Element;
|
|
906
|
+
}): Element;
|
|
820
907
|
}
|