@b9g/crank 0.5.0 → 0.5.2
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/crank.cjs +6 -3
- package/crank.cjs.map +1 -1
- package/crank.d.ts +7 -7
- package/crank.js +6 -3
- package/crank.js.map +1 -1
- package/dom.cjs +3 -4
- package/dom.cjs.map +1 -1
- package/dom.js +3 -4
- package/dom.js.map +1 -1
- package/package.json +10 -2
- package/umd.js +9 -7
- package/umd.js.map +1 -1
package/crank.d.ts
CHANGED
|
@@ -377,20 +377,20 @@ declare class ContextImpl<TNode = unknown, TScope = unknown, TRoot extends TNode
|
|
|
377
377
|
constructor(renderer: RendererImpl<TNode, TScope, TRoot, TResult>, root: TRoot | undefined, host: Retainer<TNode>, parent: ContextImpl<TNode, TScope, TRoot, TResult> | undefined, scope: TScope | undefined, ret: Retainer<TNode>);
|
|
378
378
|
}
|
|
379
379
|
declare const _ContextImpl: unique symbol;
|
|
380
|
-
type ComponentProps<T> = T extends (props: infer U) => any ? U : T;
|
|
380
|
+
type ComponentProps<T> = T extends () => any ? {} : T extends (props: infer U) => any ? U : T;
|
|
381
381
|
/**
|
|
382
382
|
* A class which is instantiated and passed to every component as its this
|
|
383
383
|
* value. Contexts form a tree just like elements and all components in the
|
|
384
384
|
* element tree are connected via contexts. Components can use this tree to
|
|
385
385
|
* communicate data upwards via events and downwards via provisions.
|
|
386
386
|
*
|
|
387
|
-
* @template [
|
|
388
|
-
* component. Used to strongly type the Context iterator methods.
|
|
387
|
+
* @template [T=*] - The expected shape of the props passed to the component,
|
|
388
|
+
* or a component function. Used to strongly type the Context iterator methods.
|
|
389
389
|
* @template [TResult=*] - The readable element value type. It is used in
|
|
390
390
|
* places such as the return value of refresh and the argument passed to
|
|
391
391
|
* schedule and cleanup callbacks.
|
|
392
392
|
*/
|
|
393
|
-
export declare class Context<
|
|
393
|
+
export declare class Context<T = any, TResult = any> implements EventTarget {
|
|
394
394
|
/**
|
|
395
395
|
* @internal
|
|
396
396
|
*/
|
|
@@ -403,7 +403,7 @@ export declare class Context<TProps = any, TResult = any> implements EventTarget
|
|
|
403
403
|
* component or via the context iterator methods. This property is mainly for
|
|
404
404
|
* plugins or utilities which wrap contexts.
|
|
405
405
|
*/
|
|
406
|
-
get props(): ComponentProps<
|
|
406
|
+
get props(): ComponentProps<T>;
|
|
407
407
|
/**
|
|
408
408
|
* The current value of the associated element.
|
|
409
409
|
*
|
|
@@ -412,8 +412,8 @@ export declare class Context<TProps = any, TResult = any> implements EventTarget
|
|
|
412
412
|
* mainly for plugins or utilities which wrap contexts.
|
|
413
413
|
*/
|
|
414
414
|
get value(): TResult;
|
|
415
|
-
[Symbol.iterator](): Generator<ComponentProps<
|
|
416
|
-
[Symbol.asyncIterator](): AsyncGenerator<ComponentProps<
|
|
415
|
+
[Symbol.iterator](): Generator<ComponentProps<T>>;
|
|
416
|
+
[Symbol.asyncIterator](): AsyncGenerator<ComponentProps<T>>;
|
|
417
417
|
/**
|
|
418
418
|
* Re-executes a component.
|
|
419
419
|
*
|
package/crank.js
CHANGED
|
@@ -656,7 +656,10 @@ function updateHost(renderer, root, ctx, scope, ret, oldProps, hydrationData) {
|
|
|
656
656
|
}
|
|
657
657
|
function commitHost(renderer, scope, ret, childValues, oldProps, hydrationValue) {
|
|
658
658
|
const tag = ret.el.tag;
|
|
659
|
-
let value =
|
|
659
|
+
let value = ret.value;
|
|
660
|
+
if (hydrationValue != null) {
|
|
661
|
+
value = ret.value = hydrationValue;
|
|
662
|
+
}
|
|
660
663
|
let props = ret.el.props;
|
|
661
664
|
let copied;
|
|
662
665
|
if (tag !== Portal) {
|
|
@@ -856,8 +859,8 @@ const _ContextImpl = Symbol.for("crank.ContextImpl");
|
|
|
856
859
|
* element tree are connected via contexts. Components can use this tree to
|
|
857
860
|
* communicate data upwards via events and downwards via provisions.
|
|
858
861
|
*
|
|
859
|
-
* @template [
|
|
860
|
-
* component. Used to strongly type the Context iterator methods.
|
|
862
|
+
* @template [T=*] - The expected shape of the props passed to the component,
|
|
863
|
+
* or a component function. Used to strongly type the Context iterator methods.
|
|
861
864
|
* @template [TResult=*] - The readable element value type. It is used in
|
|
862
865
|
* places such as the return value of refresh and the argument passed to
|
|
863
866
|
* schedule and cleanup callbacks.
|