@b9g/crank 0.7.4 → 0.7.6

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/_css.d.ts DELETED
@@ -1,21 +0,0 @@
1
- /**
2
- * CSS utility functions for style property transformation.
3
- *
4
- * This module handles camelCase to kebab-case conversion and automatic
5
- * px unit conversion for numeric CSS values, making Crank more React-compatible.
6
- */
7
- /**
8
- * Converts camelCase CSS property names to kebab-case.
9
- * Handles vendor prefixes correctly (WebkitTransform -> -webkit-transform).
10
- */
11
- export declare function camelToKebabCase(str: string): string;
12
- /**
13
- * CSS properties that should remain unitless when given numeric values.
14
- * Based on React's list of unitless properties.
15
- */
16
- export declare const UNITLESS_PROPERTIES: Set<string>;
17
- /**
18
- * Formats CSS property values, automatically adding "px" to numeric values
19
- * for properties that are not unitless.
20
- */
21
- export declare function formatStyleValue(name: string, value: unknown): string;
package/_utils.d.ts DELETED
@@ -1,14 +0,0 @@
1
- export declare function wrap<T>(value: Array<T> | T | undefined): Array<T>;
2
- export declare function unwrap<T>(arr: Array<T>): Array<T> | T | undefined;
3
- export type NonStringIterable<T> = Iterable<T> & object;
4
- /**
5
- * Ensures a value is an array.
6
- *
7
- * This function does the same thing as wrap() above except it handles nulls
8
- * and iterables, so it is appropriate for wrapping user-provided element
9
- * children.
10
- */
11
- export declare function arrayify<T>(value: NonStringIterable<T> | T | null | undefined): Array<T>;
12
- export declare function isIteratorLike(value: any): value is Iterator<unknown> | AsyncIterator<unknown>;
13
- export declare function isPromiseLike(value: any): value is PromiseLike<unknown>;
14
- export declare function safeRace<T>(contenders: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>>;
package/async.d.ts DELETED
@@ -1,107 +0,0 @@
1
- import type { Children, Component, Context } from "./crank.js";
2
- /**
3
- * Creates a lazy-loaded component from an initializer function.
4
- *
5
- * @param initializer - Function that returns a Promise resolving to a component or module
6
- * @returns A component that loads the target component on first render
7
- *
8
- * @example
9
- * ```jsx
10
- * const LazyComponent = lazy(() => import('./MyComponent'));
11
- *
12
- * <Suspense fallback={<div>Loading...</div>}>
13
- * <LazyComponent prop="value" />
14
- * </Suspense>
15
- * ```
16
- */
17
- export declare function lazy<T extends Component>(initializer: () => Promise<T | {
18
- default: T;
19
- }>): T;
20
- /**
21
- * A component that displays a fallback while its children are loading.
22
- *
23
- * When used within a SuspenseList, coordinates with siblings to control
24
- * reveal order and fallback behavior.
25
- *
26
- * @param children - The content to display when loading is complete
27
- * @param fallback - The content to display while children are loading
28
- * @param timeout - Time in milliseconds before showing fallback (defaults to
29
- * 300ms standalone, or inherits from SuspenseList)
30
- *
31
- * @example
32
- * ```jsx
33
- * <Suspense fallback={<div>Loading...</div>}>
34
- * <AsyncComponent />
35
- * </Suspense>
36
- * ```
37
- */
38
- export declare function Suspense(this: Context, { children, fallback, timeout, }: {
39
- children: Children;
40
- fallback: Children;
41
- timeout?: number;
42
- }): AsyncGenerator<Children>;
43
- declare const SuspenseListController: unique symbol;
44
- interface SuspenseListItem {
45
- ctx: Context;
46
- resolve: () => void;
47
- promise: Promise<void>;
48
- }
49
- interface SuspenseListController {
50
- timeout?: number;
51
- revealOrder?: "forwards" | "backwards" | "together";
52
- tail?: "collapsed" | "hidden";
53
- register(ctx: Context): Promise<Array<SuspenseListItem>>;
54
- isHead(ctx: Context, items: Array<SuspenseListItem>): boolean;
55
- scheduleFallback(ctx: Context, items: Array<SuspenseListItem>): Promise<void>;
56
- scheduleChildren(ctx: Context, items: Array<SuspenseListItem>): Promise<void>;
57
- }
58
- declare global {
59
- namespace Crank {
60
- interface ProvisionMap {
61
- [SuspenseListController]: SuspenseListController;
62
- }
63
- }
64
- }
65
- /**
66
- * Controls when child <Suspense> components show their content or fallbacks
67
- * based on the specified reveal order. The <SuspenseList> resolves when
68
- * coordination effort is complete (not necessarily when all content is
69
- * loaded).
70
- *
71
- * @param revealOrder - How children should be revealed:
72
- * - "forwards" (default): Show children in document order, waiting for
73
- * predecessors
74
- * - "backwards": Show children in reverse order, waiting for successors
75
- * - "together": Show all children simultaneously when all are ready
76
- * In Crank, the default behavior of async components is to render together,
77
- * so "together" might not be necessary if you are not using <Suspense>
78
- * fallbacks.
79
- *e@param tail - How to handle fallbacks:
80
- * - "collapsed" (default): Show only the fallback for the next unresolved
81
- * Suspense component
82
- * - "hidden": Hide all fallbacks
83
- * Tail behavior only applies when revealOrder is not "together".
84
- * @param timeout - Default timeout for Suspense children in milliseconds
85
- * @param children - The elements containing Suspense components to coordinate.
86
- * Suspense components which are not rendered immediately (because they are
87
- * the children of another async component) will not be coordinated.
88
- *
89
- * @example
90
- * ```jsx
91
- * <SuspenseList revealOrder="forwards" tail="collapsed">
92
- * <Suspense fallback={<div>Loading A...</div>}>
93
- * <ComponentA />
94
- * </Suspense>
95
- * <Suspense fallback={<div>Loading B...</div>}>
96
- * <ComponentB />
97
- * </Suspense>
98
- * </SuspenseList>
99
- * ```
100
- */
101
- export declare function SuspenseList(this: Context, { revealOrder, tail, timeout, children, }: {
102
- revealOrder?: "forwards" | "backwards" | "together";
103
- tail?: "collapsed" | "hidden";
104
- timeout?: number;
105
- children: Children;
106
- }): Generator<Children>;
107
- export {};