@tur-ng/std 0.0.9 → 0.0.11
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 +2 -2
- package/src/index.d.ts +127 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tur-ng/std",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "src/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -16,6 +16,6 @@
|
|
|
16
16
|
"directory": "js/packages/tur-std"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@tur-ng/core": "0.0.
|
|
19
|
+
"@tur-ng/core": "0.0.8"
|
|
20
20
|
}
|
|
21
21
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -422,6 +422,45 @@ declare module "tur:std" {
|
|
|
422
422
|
queryKey?: Val<string[]>;
|
|
423
423
|
}
|
|
424
424
|
|
|
425
|
+
/** One `Table.columns` entry. `width` = fixed px; `flex` = share of the
|
|
426
|
+
* leftover width (proportional to the total flex weight). A column with
|
|
427
|
+
* neither defaults to `flex: 1`. `minWidth` clamps the distributed
|
|
428
|
+
* share up (may overflow the available width). */
|
|
429
|
+
export interface TableColumnDef {
|
|
430
|
+
width?: number;
|
|
431
|
+
flex?: number;
|
|
432
|
+
minWidth?: number;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/** A non-scrollable data table with shared column geometry: the header
|
|
436
|
+
* row and every body row lay their cells at the same resolved column
|
|
437
|
+
* widths (CSS `table-layout: fixed` semantics). `rows` is a reactive
|
|
438
|
+
* array — writing a new array value rebuilds the row subtrees (write a
|
|
439
|
+
* fresh array; in-place mutation of the same array object with an
|
|
440
|
+
* unchanged length is not observed). `build` returns one row's cells,
|
|
441
|
+
* positionally mapped to the columns: a `null` entry is an empty cell
|
|
442
|
+
* box (the column advances), entries beyond the column count are
|
|
443
|
+
* ignored. `buildHeader` follows the same mapping and runs ONCE at
|
|
444
|
+
* build — reactive header content flows through `Val` props inside
|
|
445
|
+
* the returned cells. Without an extent, a row's height is the max
|
|
446
|
+
* intrinsic cell height (cells get loose height constraints); with
|
|
447
|
+
* one, cells fill it. Wrap in a `ScrollView` to scroll. */
|
|
448
|
+
export interface TableProps<T> {
|
|
449
|
+
columns: TableColumnDef[];
|
|
450
|
+
rows: Readable<T[]>;
|
|
451
|
+
build: (item: T, index: number) => (Element | null)[];
|
|
452
|
+
buildHeader?: () => (Element | null)[];
|
|
453
|
+
headerExtent?: Val<number>;
|
|
454
|
+
rowExtent?: Val<number>;
|
|
455
|
+
rowSpacing?: Val<number>;
|
|
456
|
+
/** Painted under odd body rows. */
|
|
457
|
+
stripeColor?: Val<Brush | null>;
|
|
458
|
+
/** Horizontal rules between body rows + under the header. */
|
|
459
|
+
dividerColor?: Val<Brush | null>;
|
|
460
|
+
dividerThickness?: Val<number>;
|
|
461
|
+
queryKey?: Val<string[]>;
|
|
462
|
+
}
|
|
463
|
+
|
|
425
464
|
export interface EachProps<T> {
|
|
426
465
|
items: Readable<T[]>;
|
|
427
466
|
build: (item: T, index: number) => Element;
|
|
@@ -664,6 +703,7 @@ declare module "tur:std" {
|
|
|
664
703
|
export function Each<T>(props: EachProps<T>): Element;
|
|
665
704
|
export function LazyList(props: LazyListProps): Element;
|
|
666
705
|
export function Grid(props: GridProps): Element;
|
|
706
|
+
export function Table<T>(props: TableProps<T>): Element;
|
|
667
707
|
export function LazyGrid(props: LazyGridProps): Element;
|
|
668
708
|
export function ScrollView(props: ScrollViewProps): Element;
|
|
669
709
|
export function Scrollbar(props: ScrollbarProps): Element;
|
|
@@ -817,4 +857,91 @@ declare module "tur:std" {
|
|
|
817
857
|
|
|
818
858
|
/** Encode a string into a Uint8Array of UTF-8 bytes. */
|
|
819
859
|
export function encodeUtf8(text: string): Uint8Array;
|
|
860
|
+
|
|
861
|
+
// ------------------------------------------------------------------
|
|
862
|
+
// Virtual apps — VirtualAppView hosts a complete nested engine
|
|
863
|
+
// instance (own worker, realm, store, tree) and draws the child's
|
|
864
|
+
// frames from its own paint. The controller is a lazy declaration:
|
|
865
|
+
// nothing runs until an element binds it (`app$` resolving to a
|
|
866
|
+
// controller); unbinding destroys the child unless `keepAlive`.
|
|
867
|
+
// ------------------------------------------------------------------
|
|
868
|
+
|
|
869
|
+
/**
|
|
870
|
+
* Opaque handle to a registered module source (`createModuleSource`).
|
|
871
|
+
* The source string never crosses the JS API again — only this handle
|
|
872
|
+
* does (the JS mirror of the Rust-side `ModuleSourceRegistry` /
|
|
873
|
+
* `load_module_source` flow).
|
|
874
|
+
*/
|
|
875
|
+
export interface ModuleSourceHandle {
|
|
876
|
+
readonly __moduleSource: unique symbol;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* Opaque handle to a worker pool registered on the runtime
|
|
881
|
+
* (`forWorkerPool`). The JS mirror of the Rust-side `WorkerPoolHandle`
|
|
882
|
+
* — resolved eagerly against the registry, so an unknown name throws
|
|
883
|
+
* at the call site.
|
|
884
|
+
*/
|
|
885
|
+
export interface WorkerPoolHandle {
|
|
886
|
+
readonly __workerPool: unique symbol;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
/** Lifecycle state of a hosted virtual app. */
|
|
890
|
+
export type VirtualAppStatus =
|
|
891
|
+
| "idle"
|
|
892
|
+
| "spawning"
|
|
893
|
+
| "running"
|
|
894
|
+
| "error"
|
|
895
|
+
| "destroyed";
|
|
896
|
+
|
|
897
|
+
/** A hosted virtual app's controller — a lazy declaration. */
|
|
898
|
+
export interface VirtualAppController {
|
|
899
|
+
/** Reactive status — read via `store.get(app.status$)`. */
|
|
900
|
+
readonly status$: Readable<VirtualAppStatus>;
|
|
901
|
+
/** Error detail (module load / start failures) — read via `store.get`. */
|
|
902
|
+
readonly errorMsg$: Readable<string>;
|
|
903
|
+
/**
|
|
904
|
+
* The ONLY lifecycle action — a control mutation (the `watch`
|
|
905
|
+
* `{ start$, stop$ }` convention: side effects ride the mutation
|
|
906
|
+
* rail). Dispatch via `store.set(app.destroy$)`. New code =
|
|
907
|
+
* destroy$ + a new controller with a new source.
|
|
908
|
+
*/
|
|
909
|
+
readonly destroy$: Mutation;
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
/** Register a module source once; reference it by opaque handle. */
|
|
913
|
+
export function createModuleSource(source: string): ModuleSourceHandle;
|
|
914
|
+
|
|
915
|
+
/**
|
|
916
|
+
* Resolve a registered worker pool by name — eagerly (an unknown name
|
|
917
|
+
* throws right here). The only source of the handle
|
|
918
|
+
* `createVirtualAppController({ pool })` accepts.
|
|
919
|
+
*/
|
|
920
|
+
export function forWorkerPool(name: string): WorkerPoolHandle;
|
|
921
|
+
|
|
922
|
+
/** Create a virtual-app controller (lazy — spawns on first bind). */
|
|
923
|
+
export function createVirtualAppController(opts: {
|
|
924
|
+
source: ModuleSourceHandle;
|
|
925
|
+
/**
|
|
926
|
+
* Target worker pool, from `forWorkerPool(name)` (handle-only — raw
|
|
927
|
+
* strings are rejected). Omit for the default `"virtual"` pool.
|
|
928
|
+
*/
|
|
929
|
+
pool?: WorkerPoolHandle;
|
|
930
|
+
/** Survive element unbind (default `false`). */
|
|
931
|
+
keepAlive?: boolean;
|
|
932
|
+
}): VirtualAppController;
|
|
933
|
+
|
|
934
|
+
/** Element hosting a virtual app; draws the child's latest frame. */
|
|
935
|
+
export function VirtualAppView(props: {
|
|
936
|
+
/** Reactive controller binding — `null` unbinds (destroys). */
|
|
937
|
+
app$: Readable<VirtualAppController | null>;
|
|
938
|
+
background?: Val<Color>;
|
|
939
|
+
width?: Val<number>;
|
|
940
|
+
height?: Val<number>;
|
|
941
|
+
queryKey?: Array<string>;
|
|
942
|
+
/** Painted while the child isn't live. */
|
|
943
|
+
fallback?: Element;
|
|
944
|
+
/** Painted on error. */
|
|
945
|
+
errorView?: Element;
|
|
946
|
+
}): Element;
|
|
820
947
|
}
|