@calmdown/pyxis 1.0.0-rc.1 → 1.0.0-rc.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/dist/core-dev.d.ts +23 -20
- package/dist/core-dev.js +112 -95
- package/dist/core-dev.js.map +1 -1
- package/dist/core.d.ts +23 -20
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/dist/main.d.ts +4 -2
- package/dist/main.js +1 -0
- package/package.json +1 -1
package/dist/core-dev.d.ts
CHANGED
|
@@ -3,10 +3,6 @@
|
|
|
3
3
|
* Puts `T` into a union with `null` and `undefined`.
|
|
4
4
|
*/
|
|
5
5
|
type Nil<T> = T | null | undefined;
|
|
6
|
-
/**
|
|
7
|
-
* Converts the union `U` into an intersection type.
|
|
8
|
-
*/
|
|
9
|
-
type Intersection<U, TEmpty = {}> = [U] extends [never] ? TEmpty : (U extends any ? (u: U) => void : never) extends ((i: infer I) => void) ? I : never;
|
|
10
6
|
/**
|
|
11
7
|
* A type describing any map of intrinsic elements and their props.
|
|
12
8
|
*/
|
|
@@ -156,7 +152,7 @@ interface Extension<TNode, TExtensionKey extends string = string, TIntrinsicElem
|
|
|
156
152
|
readonly set: (node: TNode, prop: string, value: any, group: MountingGroup<TNode>) => void;
|
|
157
153
|
}
|
|
158
154
|
type ExtensionsType<TNode> = { [_ in string]?: Extension<TNode>; };
|
|
159
|
-
type ExtensionProps<TExtensionKey extends string, TProps extends PropsType> =
|
|
155
|
+
type ExtensionProps<TExtensionKey extends string, TProps extends PropsType> = { readonly [TExtPropKey in `${TExtensionKey}:${keyof TProps & string}`]?: (TExtPropKey extends `${TExtensionKey}:${infer TPropKey}` ? TProps[TPropKey] : never); };
|
|
160
156
|
//#endregion
|
|
161
157
|
//#region src/data/Atom.d.ts
|
|
162
158
|
/**
|
|
@@ -164,7 +160,7 @@ type ExtensionProps<TExtensionKey extends string, TProps extends PropsType> = In
|
|
|
164
160
|
*/
|
|
165
161
|
declare const S_ATOM: unique symbol;
|
|
166
162
|
/** Contract for Atoms where they need to be read. */
|
|
167
|
-
interface
|
|
163
|
+
interface ReadAtom<out T> extends DependencyList {
|
|
168
164
|
/** Pyxis Atom type guard marker. */
|
|
169
165
|
readonly [S_ATOM]: true;
|
|
170
166
|
/**
|
|
@@ -183,7 +179,7 @@ interface ReadonlyAtom<out T> extends DependencyList {
|
|
|
183
179
|
* @see {@link read}
|
|
184
180
|
* @see {@link write}
|
|
185
181
|
*/
|
|
186
|
-
interface Atom<T = unknown> extends
|
|
182
|
+
interface Atom<T = unknown> extends ReadAtom<T> {
|
|
187
183
|
/**
|
|
188
184
|
* Sets the value of this Atom. Does nothing if this Atom is readonly. Only use this method when
|
|
189
185
|
* the target is guaranteed to be an Atom, otherwise it is recommended to use the `write` or
|
|
@@ -213,7 +209,7 @@ type MaybeAtom<T> = Atom<T> | T;
|
|
|
213
209
|
* @see {@link peek}
|
|
214
210
|
* @see {@link isAtom}
|
|
215
211
|
*/
|
|
216
|
-
type
|
|
212
|
+
type MaybeReadAtom<T> = ReadAtom<T> | T;
|
|
217
213
|
/**
|
|
218
214
|
* Creates an empty Atom; i.e. value set to `undefined`.
|
|
219
215
|
*/
|
|
@@ -228,7 +224,7 @@ declare function atomOf<T>(initialValue: MaybeAtom<T>, lifecycle?: Lifecycle, de
|
|
|
228
224
|
* Atom type guard, checks if the provided input is an Atom.
|
|
229
225
|
*/
|
|
230
226
|
declare function isAtom<T = unknown>(input: Nil<MaybeAtom<T>>): input is Atom<T>;
|
|
231
|
-
declare function isAtom<T = unknown>(input: Nil<
|
|
227
|
+
declare function isAtom<T = unknown>(input: Nil<MaybeReadAtom<T>>): input is ReadAtom<T>;
|
|
232
228
|
declare function isAtom<T = unknown>(input: unknown): input is Atom<T>;
|
|
233
229
|
/**
|
|
234
230
|
* Checks if the provided input is an Atom and reads its value. Non-atom inputs are returned as-is.
|
|
@@ -238,7 +234,7 @@ declare function isAtom<T = unknown>(input: unknown): input is Atom<T>;
|
|
|
238
234
|
* @see {@link peek}
|
|
239
235
|
* @see {@link update}
|
|
240
236
|
*/
|
|
241
|
-
declare function read<A>(input: A): A extends
|
|
237
|
+
declare function read<A>(input: A): A extends MaybeReadAtom<infer T> ? T : never;
|
|
242
238
|
/**
|
|
243
239
|
* Checks if the provided input is an Atom and reads its value. Non-atom inputs are returned as-is.
|
|
244
240
|
* Does NOT report read access when inside an effect.
|
|
@@ -247,7 +243,7 @@ declare function read<A>(input: A): A extends MaybeReadonlyAtom<infer T> ? T : n
|
|
|
247
243
|
* @see {@link write}
|
|
248
244
|
* @see {@link update}
|
|
249
245
|
*/
|
|
250
|
-
declare function peek<A>(input: A): A extends
|
|
246
|
+
declare function peek<A>(input: A): A extends MaybeReadAtom<infer T> ? T : never;
|
|
251
247
|
/**
|
|
252
248
|
* Checks if the provided input is an Atom, writes its value and returns the new value.
|
|
253
249
|
*
|
|
@@ -311,7 +307,7 @@ type JsxChildrenProp<T> = T extends readonly [any, any, ...any[]] ? T extends re
|
|
|
311
307
|
/**
|
|
312
308
|
* Primitive types accepted to render as text.
|
|
313
309
|
*/
|
|
314
|
-
type JsxText =
|
|
310
|
+
type JsxText = MaybeReadAtom<Nil<string | number | boolean | bigint>>;
|
|
315
311
|
/**
|
|
316
312
|
* Describes the objects returned by JSX factories.
|
|
317
313
|
*
|
|
@@ -517,9 +513,9 @@ interface ReadonlyList<T> extends Iterable<T>, DependencyList {
|
|
|
517
513
|
*/
|
|
518
514
|
delta(): ListDelta<T> | null;
|
|
519
515
|
/**
|
|
520
|
-
* Gets the underlying array of items. The array is read-only,
|
|
521
|
-
*
|
|
522
|
-
*
|
|
516
|
+
* Gets the underlying array of items. The array is read-only, mutating it will cause observers
|
|
517
|
+
* to go out of sync.
|
|
518
|
+
* Non-reactive in effects and derivations.
|
|
523
519
|
*/
|
|
524
520
|
raw(): readonly T[];
|
|
525
521
|
/**
|
|
@@ -650,13 +646,13 @@ interface ShowDataProps<T> {
|
|
|
650
646
|
when?: MaybeAtom<boolean>;
|
|
651
647
|
proxy?: never;
|
|
652
648
|
data: MaybeAtom<T>;
|
|
653
|
-
children: [template: DataTemplate<T> |
|
|
649
|
+
children: [template: DataTemplate<T> | ReadAtom<Nil<DataTemplate<T>>>];
|
|
654
650
|
}
|
|
655
651
|
interface ShowProxyDataProps<T, P extends readonly (keyof T)[]> {
|
|
656
652
|
when?: MaybeAtom<boolean>;
|
|
657
653
|
proxy: P;
|
|
658
654
|
data: MaybeAtom<T>;
|
|
659
|
-
children: [template: DataTemplate<Proxied<T, P>> |
|
|
655
|
+
children: [template: DataTemplate<Proxied<T, P>> | ReadAtom<Nil<DataTemplate<Proxied<T, P>>>>];
|
|
660
656
|
}
|
|
661
657
|
/**
|
|
662
658
|
* The built-in Show Component dynamically mounting and unmounting a Template
|
|
@@ -700,7 +696,7 @@ declare function consumerOf<T>(context: Context<T>): Atom<T> | null;
|
|
|
700
696
|
* `consumerOf(context)`.
|
|
701
697
|
* @see {@link consumerOf}
|
|
702
698
|
*/
|
|
703
|
-
declare function host<
|
|
699
|
+
declare function host<C>(context: C, defaultValue?: C extends Context<infer T> ? T : never, devId?: string): C extends Context<infer T> ? ContextAtom<T> : never;
|
|
704
700
|
//#endregion
|
|
705
701
|
//#region src/data/Effect.d.ts
|
|
706
702
|
interface EffectBlock {
|
|
@@ -715,6 +711,11 @@ interface Effect<T> {}
|
|
|
715
711
|
* unmount.
|
|
716
712
|
*/
|
|
717
713
|
declare function effect(block: EffectBlock, lifecycle?: Lifecycle): void;
|
|
714
|
+
/**
|
|
715
|
+
* Runs a block of code removed from any effects. Accessing atoms within this block will be ignored
|
|
716
|
+
* by any effect that may otherwise be observing this code.
|
|
717
|
+
*/
|
|
718
|
+
declare function noEffect<T>(block: () => T): T;
|
|
718
719
|
//#endregion
|
|
719
720
|
//#region src/data/Derivation.d.ts
|
|
720
721
|
/**
|
|
@@ -773,8 +774,10 @@ declare function peeks(strings: TemplateStringsArray, ...values: JsxText[]): str
|
|
|
773
774
|
//#region src/Builder.d.ts
|
|
774
775
|
interface PyxisBuilder<TNode, TIntrinsicElements extends ElementsType> {
|
|
775
776
|
build: () => Renderer<TNode, TIntrinsicElements>;
|
|
776
|
-
extend: <TExtensionKey extends string, TExtendedIntrinsicElements extends ElementsType>(extensionKey: TExtensionKey, extension: (extensionKey: TExtensionKey, intrinsicElements: TIntrinsicElements) => TExtendedIntrinsicElements) => PyxisBuilder<TNode, TExtendedIntrinsicElements
|
|
777
|
+
extend: <TExtensionKey extends string, TExtendedIntrinsicElements extends ElementsType>(extensionKey: TExtensionKey, extension: (extensionKey: TExtensionKey, intrinsicElements: TIntrinsicElements) => TExtendedIntrinsicElements) => PyxisBuilder<TNode, Merged<TExtendedIntrinsicElements>>;
|
|
777
778
|
}
|
|
779
|
+
type MergeIntersection<T> = { [K in keyof T]: T[K]; } & {};
|
|
780
|
+
type Merged<T> = { [K in keyof T]: MergeIntersection<T[K]>; };
|
|
778
781
|
declare function pyxis<TNode, TIntrinsicElements extends ElementsType>(adapter: Adapter<TNode, TIntrinsicElements>): PyxisBuilder<TNode, TIntrinsicElements>;
|
|
779
782
|
//#endregion
|
|
780
783
|
//#region src/jsx.d.ts
|
|
@@ -783,5 +786,5 @@ declare function jsx<TProps extends PropsType>(component: Component<TProps>, pro
|
|
|
783
786
|
declare function jsxs(tagName: string, props: PropsType, key?: any): JsxResult;
|
|
784
787
|
declare function jsxs<TProps extends PropsType>(component: Component<TProps>, props: TProps, key?: any): JsxResult;
|
|
785
788
|
//#endregion
|
|
786
|
-
export { type Adapter, type Atom, ChangeKind, type Component, type Context, type DataTemplate, type Derivation, type EffectBlock, type ElementsOf, type ElementsType, type Equals, type Extension, type ExtensionProps, type ExtensionsType, Fragment, type FragmentProps, type HNode,
|
|
789
|
+
export { type Adapter, type Atom, ChangeKind, type Component, type Context, type DataTemplate, type Derivation, type EffectBlock, type ElementsOf, type ElementsType, type Equals, type Extension, type ExtensionProps, type ExtensionsType, Fragment, type FragmentProps, type HNode, Iterator, type JsxChildren, type JsxChildrenProp, type JsxObject, type JsxProps, type JsxResult, type JsxText, type Lifecycle, type List, type ListChange, type ListCleared, type ListDelta, type ListItemChanged, type ListItemInserted, type ListItemRemoved, type MaybeAtom, type MaybeReadAtom, type MountBlock, type MountingGroup, Native, type Nil, type NodeType, type PropsOf, type PropsType, type Proxied, type ProxyAtom, type ProxyIteratorProps, type PyxisBuilder, type ReadAtom, type ReadonlyList, RefExtension, type RefExtensionType, type RefFn, type RemountIteratorProps, type Renderer, type S_ATOM, type S_NODE_TYPE, Show, type ShowProps, type TickFn, type UnmountBlock, type WithChildren, atomOf, bind, component, consumerOf, createContext, derived, effect, fork, getLifecycle, host, insert, isAtom, jsx, jsxs, listOf, mount, mountJsx, mounted, noEffect, peek, peeks, proxyOf, pyxis, read, reads, sync, tick, tock, track, unmount, unmounted, untrack, update, withLifecycle, write };
|
|
787
790
|
//# sourceMappingURL=core-dev.d.ts.map
|
package/dist/core-dev.js
CHANGED
|
@@ -388,6 +388,19 @@ function reportAccess(atom) {
|
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
390
|
/**
|
|
391
|
+
* Runs a block of code removed from any effects. Accessing atoms within this block will be ignored
|
|
392
|
+
* by any effect that may otherwise be observing this code.
|
|
393
|
+
*/
|
|
394
|
+
function noEffect(block) {
|
|
395
|
+
const previousEffect = $currentEffect;
|
|
396
|
+
$currentEffect = null;
|
|
397
|
+
try {
|
|
398
|
+
return block();
|
|
399
|
+
} finally {
|
|
400
|
+
$currentEffect = previousEffect;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
391
404
|
* Asserts that the current code is not running within an effect block.
|
|
392
405
|
* Only used in development; In production, this function should be removed by the bundler.
|
|
393
406
|
*/
|
|
@@ -503,97 +516,6 @@ function Text(jsx, hParent, nUsedParent, _nRealParent, nBefore, isBatch) {
|
|
|
503
516
|
insert(node, null, hParent, nUsedParent, nBefore, isBatch);
|
|
504
517
|
}
|
|
505
518
|
|
|
506
|
-
//#endregion
|
|
507
|
-
//#region src/data/Context.ts
|
|
508
|
-
function createContext() {
|
|
509
|
-
let $symbol = Symbol();
|
|
510
|
-
{
|
|
511
|
-
const devId = arguments[0];
|
|
512
|
-
$symbol = globalThis.__PYXIS_HMR__.state.restore(createContext, devId) ?? $symbol;
|
|
513
|
-
globalThis.__PYXIS_HMR__.state.preserve(createContext, devId, $symbol);
|
|
514
|
-
}
|
|
515
|
-
return { $symbol };
|
|
516
|
-
}
|
|
517
|
-
let $currentContainer;
|
|
518
|
-
let $isNewContainer = false;
|
|
519
|
-
/** @internal */
|
|
520
|
-
function getContextContainer() {
|
|
521
|
-
return $currentContainer;
|
|
522
|
-
}
|
|
523
|
-
/** @internal */
|
|
524
|
-
function setContextContainer(container) {
|
|
525
|
-
$currentContainer = container;
|
|
526
|
-
$isNewContainer = false;
|
|
527
|
-
}
|
|
528
|
-
/**
|
|
529
|
-
* Gets a consumer Atom for the given Context. This atom will be read-only.
|
|
530
|
-
* @see {@link host}
|
|
531
|
-
*/
|
|
532
|
-
function consumerOf(context) {
|
|
533
|
-
__DEV__assertNotEffect();
|
|
534
|
-
const { $symbol } = context;
|
|
535
|
-
let ptr = $currentContainer;
|
|
536
|
-
let atom;
|
|
537
|
-
while (ptr && !(atom = ptr[$symbol])) ptr = ptr.$parent;
|
|
538
|
-
return atom ?? null;
|
|
539
|
-
}
|
|
540
|
-
function host(context, defaultValue) {
|
|
541
|
-
__DEV__assertNotEffect();
|
|
542
|
-
if (!$isNewContainer || !$currentContainer) {
|
|
543
|
-
$isNewContainer = true;
|
|
544
|
-
$currentContainer = { $parent: $currentContainer };
|
|
545
|
-
}
|
|
546
|
-
const lifecycle = getLifecycle();
|
|
547
|
-
{
|
|
548
|
-
const devId = arguments[2];
|
|
549
|
-
globalThis.__PYXIS_HMR__.state.restore(lifecycle, devId, (value) => {
|
|
550
|
-
defaultValue = value;
|
|
551
|
-
});
|
|
552
|
-
}
|
|
553
|
-
const localAtom = {
|
|
554
|
-
[S_ATOM]: true,
|
|
555
|
-
$lifecycle: lifecycle,
|
|
556
|
-
$tracksValue: true,
|
|
557
|
-
$value: defaultValue,
|
|
558
|
-
get: getLocalValue,
|
|
559
|
-
set: setValue$1
|
|
560
|
-
};
|
|
561
|
-
if (defaultValue === void 0) {
|
|
562
|
-
const ancestorAtom = consumerOf(context);
|
|
563
|
-
if (ancestorAtom) {
|
|
564
|
-
localAtom.get = getAncestorValue;
|
|
565
|
-
localAtom.$ancestor = ancestorAtom;
|
|
566
|
-
link(lifecycle, ancestorAtom, localAtom.$dep = {
|
|
567
|
-
$fn: notify$1,
|
|
568
|
-
$a0: localAtom
|
|
569
|
-
});
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
localAtom.$devId = arguments[2];
|
|
573
|
-
if (Object.hasOwn($currentContainer, context.$symbol)) throw new Error("Component declares multiple hosts of the same Context.");
|
|
574
|
-
$currentContainer[context.$symbol] = localAtom;
|
|
575
|
-
return localAtom;
|
|
576
|
-
}
|
|
577
|
-
function getAncestorValue() {
|
|
578
|
-
return this.$ancestor.get();
|
|
579
|
-
}
|
|
580
|
-
function getLocalValue() {
|
|
581
|
-
return this.$value;
|
|
582
|
-
}
|
|
583
|
-
function setValue$1(value) {
|
|
584
|
-
let oldValue;
|
|
585
|
-
if (this.$ancestor) {
|
|
586
|
-
oldValue = this.$ancestor.get();
|
|
587
|
-
unlink(this.$dep);
|
|
588
|
-
this.$dep = null;
|
|
589
|
-
this.$ancestor = null;
|
|
590
|
-
this.get = getLocalValue;
|
|
591
|
-
} else oldValue = this.$value;
|
|
592
|
-
this.$value = value;
|
|
593
|
-
globalThis.__PYXIS_HMR__.state.preserve(this.$lifecycle, this.$devId, value);
|
|
594
|
-
return !Object.is(oldValue, value);
|
|
595
|
-
}
|
|
596
|
-
|
|
597
519
|
//#endregion
|
|
598
520
|
//#region src/Renderer.ts
|
|
599
521
|
/** @internal */
|
|
@@ -635,7 +557,6 @@ function fork(hParent, hBefore = null) {
|
|
|
635
557
|
$scheduler: ng.$scheduler,
|
|
636
558
|
$extensions: ng.$extensions,
|
|
637
559
|
$life: 1,
|
|
638
|
-
$context: getContextContainer(),
|
|
639
560
|
$pg: ng,
|
|
640
561
|
$ng: null
|
|
641
562
|
};
|
|
@@ -694,7 +615,6 @@ function mount(jsx, hGroup, nUsedParent, nRealParent, nBefore, isBatch) {
|
|
|
694
615
|
return;
|
|
695
616
|
}
|
|
696
617
|
const previousLifecycle = setLifecycle(hGroup);
|
|
697
|
-
setContextContainer(hGroup.$context);
|
|
698
618
|
try {
|
|
699
619
|
mountJsx(jsx, hGroup, nUsedParent, nRealParent, nBefore, isBatch);
|
|
700
620
|
} finally {
|
|
@@ -838,6 +758,97 @@ function Fragment(jsx, hParent, nUsedParent, nRealParent, nBefore, isBatch) {
|
|
|
838
758
|
mountJsx(jsx.children, hParent, nUsedParent, nRealParent, nBefore, isBatch);
|
|
839
759
|
}
|
|
840
760
|
|
|
761
|
+
//#endregion
|
|
762
|
+
//#region src/data/Context.ts
|
|
763
|
+
function createContext() {
|
|
764
|
+
let $symbol = Symbol();
|
|
765
|
+
{
|
|
766
|
+
const devId = arguments[0];
|
|
767
|
+
$symbol = globalThis.__PYXIS_HMR__.state.restore(createContext, devId) ?? $symbol;
|
|
768
|
+
globalThis.__PYXIS_HMR__.state.preserve(createContext, devId, $symbol);
|
|
769
|
+
}
|
|
770
|
+
return { $symbol };
|
|
771
|
+
}
|
|
772
|
+
let $currentContainer = null;
|
|
773
|
+
let $isNewContainer = false;
|
|
774
|
+
/** @internal */
|
|
775
|
+
function getContextContainer() {
|
|
776
|
+
return $currentContainer;
|
|
777
|
+
}
|
|
778
|
+
/** @internal */
|
|
779
|
+
function setContextContainer(container) {
|
|
780
|
+
$currentContainer = container;
|
|
781
|
+
$isNewContainer = false;
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* Gets a consumer Atom for the given Context. This atom will be read-only.
|
|
785
|
+
* @see {@link host}
|
|
786
|
+
*/
|
|
787
|
+
function consumerOf(context) {
|
|
788
|
+
__DEV__assertNotEffect();
|
|
789
|
+
const { $symbol } = context;
|
|
790
|
+
let ptr = $currentContainer;
|
|
791
|
+
let atom;
|
|
792
|
+
while (ptr && !(atom = ptr[$symbol])) ptr = ptr.$parent;
|
|
793
|
+
return atom ?? null;
|
|
794
|
+
}
|
|
795
|
+
function host(context, defaultValue) {
|
|
796
|
+
__DEV__assertNotEffect();
|
|
797
|
+
if (!$isNewContainer || !$currentContainer) {
|
|
798
|
+
$isNewContainer = true;
|
|
799
|
+
$currentContainer = { $parent: $currentContainer };
|
|
800
|
+
}
|
|
801
|
+
const lifecycle = getLifecycle();
|
|
802
|
+
{
|
|
803
|
+
const devId = arguments[2];
|
|
804
|
+
globalThis.__PYXIS_HMR__.state.restore(lifecycle, devId, (value) => {
|
|
805
|
+
defaultValue = value;
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
const localAtom = {
|
|
809
|
+
[S_ATOM]: true,
|
|
810
|
+
$lifecycle: lifecycle,
|
|
811
|
+
$tracksValue: true,
|
|
812
|
+
$value: defaultValue,
|
|
813
|
+
get: getLocalValue,
|
|
814
|
+
set: setValue$1
|
|
815
|
+
};
|
|
816
|
+
if (defaultValue === void 0) {
|
|
817
|
+
const ancestorAtom = consumerOf(context);
|
|
818
|
+
if (ancestorAtom) {
|
|
819
|
+
localAtom.get = getAncestorValue;
|
|
820
|
+
localAtom.$ancestor = ancestorAtom;
|
|
821
|
+
link(lifecycle, ancestorAtom, localAtom.$dep = {
|
|
822
|
+
$fn: notify$1,
|
|
823
|
+
$a0: localAtom
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
localAtom.$devId = arguments[2];
|
|
828
|
+
if (Object.hasOwn($currentContainer, context.$symbol)) throw new Error("Component declares multiple hosts of the same Context.");
|
|
829
|
+
$currentContainer[context.$symbol] = localAtom;
|
|
830
|
+
return localAtom;
|
|
831
|
+
}
|
|
832
|
+
function getAncestorValue() {
|
|
833
|
+
return this.$ancestor.get();
|
|
834
|
+
}
|
|
835
|
+
function getLocalValue() {
|
|
836
|
+
return this.$value;
|
|
837
|
+
}
|
|
838
|
+
function setValue$1(value) {
|
|
839
|
+
let oldValue;
|
|
840
|
+
if (this.$ancestor) {
|
|
841
|
+
oldValue = this.$ancestor.get();
|
|
842
|
+
unlink(this.$dep);
|
|
843
|
+
this.$dep = null;
|
|
844
|
+
this.$ancestor = null;
|
|
845
|
+
this.get = getLocalValue;
|
|
846
|
+
} else oldValue = this.$value;
|
|
847
|
+
this.$value = value;
|
|
848
|
+
globalThis.__PYXIS_HMR__.state.preserve(this.$lifecycle, this.$devId, value);
|
|
849
|
+
return !Object.is(oldValue, value);
|
|
850
|
+
}
|
|
851
|
+
|
|
841
852
|
//#endregion
|
|
842
853
|
//#region src/data/ListDelta.ts
|
|
843
854
|
/** @internal */
|
|
@@ -1269,6 +1280,7 @@ function Iterator(jsx, hParent, nUsedParent, nRealParent, nBefore, isBatch) {
|
|
|
1269
1280
|
const isProxy = proxyKeys !== void 0;
|
|
1270
1281
|
const template = jsx.children[0];
|
|
1271
1282
|
const hGroup = fork(hParent);
|
|
1283
|
+
const context = getContextContainer();
|
|
1272
1284
|
const { adapter } = hGroup;
|
|
1273
1285
|
const shouldBatch = Boolean(adapter.batch);
|
|
1274
1286
|
const nListEndMarker = adapter.marker("/Iterator");
|
|
@@ -1307,6 +1319,7 @@ function Iterator(jsx, hParent, nUsedParent, nRealParent, nBefore, isBatch) {
|
|
|
1307
1319
|
unmount(item);
|
|
1308
1320
|
ref = items[oi]?.$marker ?? nListEndMarker;
|
|
1309
1321
|
insert(item.$marker, null, item, nRealParent, ref, false);
|
|
1322
|
+
setContextContainer(context);
|
|
1310
1323
|
mount(withLifecycle(item, template, item.$data = change.newItem), item, nRealParent, nRealParent, ref, false);
|
|
1311
1324
|
}
|
|
1312
1325
|
break;
|
|
@@ -1323,6 +1336,7 @@ function Iterator(jsx, hParent, nUsedParent, nRealParent, nBefore, isBatch) {
|
|
|
1323
1336
|
nBatchBefore = null;
|
|
1324
1337
|
} else nBatchBefore = ref;
|
|
1325
1338
|
insert(item.$marker, null, item, nBatchParent, nBatchBefore, isLocalBatch);
|
|
1339
|
+
setContextContainer(context);
|
|
1326
1340
|
mount(withLifecycle(item, template, item.$data), item, nBatchParent, nRealParent, nBatchBefore, isLocalBatch);
|
|
1327
1341
|
if (isLocalBatch && (inserted >= lengthChange || !(tmp = changes[ci + 1]) || tmp.kind !== 2 || tmp.index !== ni)) {
|
|
1328
1342
|
adapter.insert(nBatchParent, nRealParent, ref);
|
|
@@ -1361,6 +1375,7 @@ function Iterator(jsx, hParent, nUsedParent, nRealParent, nBefore, isBatch) {
|
|
|
1361
1375
|
item = newItems[tmp.$index] = recycled[ri--];
|
|
1362
1376
|
updateProxy(item.$data, tmp.$item, proxyKeys);
|
|
1363
1377
|
track(item, hGroup, ref = newItems[tmp.$index + 1]);
|
|
1378
|
+
setContextContainer(context);
|
|
1364
1379
|
mount(withLifecycle(item, template, item.$data), item, nRealParent, nRealParent, ref?.$marker ?? nListEndMarker, false);
|
|
1365
1380
|
}
|
|
1366
1381
|
while (ri >= 0) {
|
|
@@ -1451,6 +1466,7 @@ function Show(jsx, hParent, nUsedParent, nRealParent, nBefore, isBatch) {
|
|
|
1451
1466
|
return;
|
|
1452
1467
|
}
|
|
1453
1468
|
const hGroup = fork(hParent);
|
|
1469
|
+
const context = getContextContainer();
|
|
1454
1470
|
let nMarker = nBefore;
|
|
1455
1471
|
effect(() => {
|
|
1456
1472
|
if (read(when) === false) return;
|
|
@@ -1461,6 +1477,7 @@ function Show(jsx, hParent, nUsedParent, nRealParent, nBefore, isBatch) {
|
|
|
1461
1477
|
nBatchParent = adapter.batch();
|
|
1462
1478
|
nBatchBefore = null;
|
|
1463
1479
|
}
|
|
1480
|
+
setContextContainer(context);
|
|
1464
1481
|
mount(withLifecycle(hGroup, read(template), read(dataOrProxy)), hGroup, nBatchParent, nRealParent, nBatchBefore, isLocalBatch || isBatch);
|
|
1465
1482
|
if (isLocalBatch) adapter.insert(nBatchParent, nUsedParent, nMarker);
|
|
1466
1483
|
return () => unmount(hGroup);
|
|
@@ -1581,7 +1598,6 @@ function delta() {
|
|
|
1581
1598
|
return this.$delta;
|
|
1582
1599
|
}
|
|
1583
1600
|
function raw() {
|
|
1584
|
-
reportAccess(this);
|
|
1585
1601
|
return this.$items;
|
|
1586
1602
|
}
|
|
1587
1603
|
function forEach(callback, thisArg) {
|
|
@@ -1787,6 +1803,7 @@ function component(block) {
|
|
|
1787
1803
|
insert(nMarker, null, hParent, nUsedParent, nBefore, isBatch);
|
|
1788
1804
|
unmounted(globalThis.__PYXIS_HMR__.component.subscribe(devId, (impl) => {
|
|
1789
1805
|
unmount(hGroup);
|
|
1806
|
+
setContextContainer(context);
|
|
1790
1807
|
mount({
|
|
1791
1808
|
...jsx,
|
|
1792
1809
|
[S_COMPONENT]: (() => mountJsx(impl(jsx), hGroup, nUsedParent, nRealParent, nMarker, isBatch))
|
|
@@ -1824,5 +1841,5 @@ function jsxs(componentOrTagName, props, key) {
|
|
|
1824
1841
|
}
|
|
1825
1842
|
|
|
1826
1843
|
//#endregion
|
|
1827
|
-
export { ChangeKind, Fragment, Iterator, Native, RefExtension, Show, atomOf, bind, component, consumerOf, createContext, derived, effect, fork, getLifecycle, host, insert, isAtom, jsx, jsxs, listOf, mount, mountJsx, mounted, peek, peeks, proxyOf, pyxis, read, reads, sync, tick, tock, track, unmount, unmounted, untrack, update, withLifecycle, write };
|
|
1844
|
+
export { ChangeKind, Fragment, Iterator, Native, RefExtension, Show, atomOf, bind, component, consumerOf, createContext, derived, effect, fork, getLifecycle, host, insert, isAtom, jsx, jsxs, listOf, mount, mountJsx, mounted, noEffect, peek, peeks, proxyOf, pyxis, read, reads, sync, tick, tock, track, unmount, unmounted, untrack, update, withLifecycle, write };
|
|
1828
1845
|
//# sourceMappingURL=core-dev.js.map
|