@jay-framework/runtime 0.11.0 → 0.13.0

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/index.d.ts CHANGED
@@ -69,20 +69,22 @@ type JayEventHandlerWrapper<EventType, ViewState, Returns> = (orig: JayEventHand
69
69
  interface ContextMarker<ContextType> {
70
70
  }
71
71
  declare const _jayContractBrand: unique symbol;
72
- type JayContract<ViewState extends object, Refs extends object, SlowViewState extends object = never, FastViewState extends object = never, InteractiveViewState extends object = never> = {
72
+ type JayContract<ViewState extends object, Refs extends object, SlowViewState extends object = never, FastViewState extends object = never, InteractiveViewState extends object = never, Props extends object = {}> = {
73
73
  readonly [_jayContractBrand]: {
74
74
  viewState: ViewState;
75
75
  refs: Refs;
76
76
  slowViewState: SlowViewState;
77
77
  fastViewState: FastViewState;
78
78
  interactiveViewState: InteractiveViewState;
79
+ props: Props;
79
80
  };
80
81
  };
81
- type ExtractViewState<A> = A extends JayContract<infer ViewState, any, any, any, any> ? ViewState : never;
82
- type ExtractRefs<A> = A extends JayContract<any, infer Refs, any, any, any> ? Refs : never;
83
- type ExtractSlowViewState<A> = A extends JayContract<any, any, infer SlowViewState, any, any> ? SlowViewState : never;
84
- type ExtractFastViewState<A> = A extends JayContract<any, any, any, infer FastViewState, any> ? FastViewState : never;
85
- type ExtractInteractiveViewState<A> = A extends JayContract<any, any, any, any, infer InteractiveViewState> ? InteractiveViewState : never;
82
+ type ExtractViewState<A> = A extends JayContract<infer ViewState, any, any, any, any, any> ? ViewState : never;
83
+ type ExtractRefs<A> = A extends JayContract<any, infer Refs, any, any, any, any> ? Refs : never;
84
+ type ExtractSlowViewState<A> = A extends JayContract<any, any, infer SlowViewState, any, any, any> ? SlowViewState : never;
85
+ type ExtractFastViewState<A> = A extends JayContract<any, any, any, infer FastViewState, any, any> ? FastViewState : never;
86
+ type ExtractInteractiveViewState<A> = A extends JayContract<any, any, any, any, infer InteractiveViewState, any> ? InteractiveViewState : never;
87
+ type ExtractProps<A> = A extends JayContract<any, any, any, any, any, infer Props> ? Props : never;
86
88
  declare enum LogType {
87
89
  ASYNC_ERROR = 0,
88
90
  CONTEXT_NOT_FOUND = 1
@@ -484,12 +486,12 @@ declare function forEach<T, Item>(getItems: (T: any) => Array<Item>, elemCreator
484
486
  * specific array item, so child bindings like {price} work correctly
485
487
  * (they resolve to item.price, not viewState.price).
486
488
  *
487
- * @param arrayName - The property name of the array in the parent ViewState
489
+ * @param getItems - Function to get the array from the parent ViewState (handles nested paths)
488
490
  * @param index - The jayIndex value (position in the pre-rendered array)
489
491
  * @param trackByValue - The jayTrackBy value (identity for reconciliation)
490
492
  * @param elementCreator - Function that creates the pre-rendered element (called within item context)
491
493
  */
492
- declare function slowForEachItem<ParentVS, ItemVS>(arrayName: keyof ParentVS, index: number, trackByValue: string, elementCreator: () => BaseJayElement<ItemVS>): BaseJayElement<ParentVS>;
494
+ declare function slowForEachItem<ParentVS, ItemVS>(getItems: (parentData: ParentVS) => ItemVS[], index: number, trackByValue: string, elementCreator: () => BaseJayElement<ItemVS>): BaseJayElement<ParentVS>;
493
495
  interface ForEach<ViewState, Item> {
494
496
  getItems: (T: any) => Array<Item>;
495
497
  elemCreator: (Item: any, String: any) => BaseJayElement<Item>;
@@ -567,10 +569,12 @@ declare class ConstructContext<ViewState> {
567
569
  private readonly coordinateBase;
568
570
  constructor(data: ViewState, forStaticElements?: boolean, coordinateBase?: Coordinate);
569
571
  get currData(): ViewState;
572
+ /** The accumulated coordinate base (trackBy values from ancestor forEach loops) */
573
+ get dataIds(): Coordinate;
570
574
  coordinate: (refName: string) => Coordinate;
571
575
  forItem<ChildViewState>(childViewState: ChildViewState, id: string): ConstructContext<ChildViewState>;
572
576
  forAsync<ChildViewState>(childViewState: ChildViewState): ConstructContext<ChildViewState>;
573
577
  static withRootContext<ViewState, Refs>(viewState: ViewState, refManager: ReferencesManager, elementConstructor: () => BaseJayElement<ViewState>): JayElement<ViewState, Refs>;
574
578
  }
575
579
 
576
- export { type Attribute, type Attributes, type BaseJayElement, BaseReferencesManager, type ComponentCollectionProxy, ComponentCollectionRefImpl, type ComponentProxy, ComponentRefImpl, ComponentRefsImpl, type Conditional, ConstructContext, type ContextMarker, type Coordinate, type DynamicAttributeOrProperty, EVENT_TRAP, type ElementFrom, type EventEmitter, type EventTypeFrom, type ExtractFastViewState, type ExtractInteractiveViewState, type ExtractRefs, type ExtractSlowViewState, type ExtractViewState, type ForEach, GetTrapProxy, type GlobalJayEvents, type HTMLElementCollectionProxy, type HTMLElementCollectionProxyTarget, type HTMLElementProxy, type HTMLElementProxyTarget, type HTMLNativeExec, type HeadLink, type JayComponent, type JayComponentConstructor, type JayContract, type JayElement, type JayEvent, type JayEventHandler, type JayEventHandlerWrapper, type JayLog, type JayNativeEventBuilder, type JayNativeFunction, LogType, type ManagedRefConstructor, ManagedRefType, type ManagedRefs, type MapEventEmitterViewState, type MountFunc, type OnlyEventEmitters, type PreRenderElement, type PrivateRef, type PrivateRefConstructor, PrivateRefs, type PropsFrom, ReferencesManager, type RenderElement, type RenderElementOptions, type TextElement, VIEW_STATE_CHANGE_EVENT, type ViewStateFrom, type When, WhenRole, type WithData, booleanAttribute, childComp, clearGlobalContextRegistry, conditional, createJayContext, currentConstructionContext, defaultEventWrapper, dynamicAttribute, dynamicElement, dynamicElementNS, dynamicProperty, dynamicText, element, findContext, forEach, injectHeadLinks, isCondition, isForEach, isWhen, isWithData, jayLog, mathMLDynamicElement, mathMLElement, mkUpdateCollection, noop, noopMount, noopUpdate, normalizeMount, normalizeUpdates, pending, registerGlobalContext, rejected, resolved, restoreContext, saveContext, slowForEachItem, svgDynamicElement, svgElement, type updateFunc, useContext, useGlobalContext, withContext, withData };
580
+ export { type Attribute, type Attributes, type BaseJayElement, BaseReferencesManager, type ComponentCollectionProxy, ComponentCollectionRefImpl, type ComponentProxy, ComponentRefImpl, ComponentRefsImpl, type Conditional, ConstructContext, type ContextMarker, type Coordinate, type DynamicAttributeOrProperty, EVENT_TRAP, type ElementFrom, type EventEmitter, type EventTypeFrom, type ExtractFastViewState, type ExtractInteractiveViewState, type ExtractProps, type ExtractRefs, type ExtractSlowViewState, type ExtractViewState, type ForEach, GetTrapProxy, type GlobalJayEvents, type HTMLElementCollectionProxy, type HTMLElementCollectionProxyTarget, type HTMLElementProxy, type HTMLElementProxyTarget, type HTMLNativeExec, type HeadLink, type JayComponent, type JayComponentConstructor, type JayContract, type JayElement, type JayEvent, type JayEventHandler, type JayEventHandlerWrapper, type JayLog, type JayNativeEventBuilder, type JayNativeFunction, LogType, type ManagedRefConstructor, ManagedRefType, type ManagedRefs, type MapEventEmitterViewState, type MountFunc, type OnlyEventEmitters, type PreRenderElement, type PrivateRef, type PrivateRefConstructor, PrivateRefs, type PropsFrom, ReferencesManager, type RenderElement, type RenderElementOptions, type TextElement, VIEW_STATE_CHANGE_EVENT, type ViewStateFrom, type When, WhenRole, type WithData, booleanAttribute, childComp, clearGlobalContextRegistry, conditional, createJayContext, currentConstructionContext, defaultEventWrapper, dynamicAttribute, dynamicElement, dynamicElementNS, dynamicProperty, dynamicText, element, findContext, forEach, injectHeadLinks, isCondition, isForEach, isWhen, isWithData, jayLog, mathMLDynamicElement, mathMLElement, mkUpdateCollection, noop, noopMount, noopUpdate, normalizeMount, normalizeUpdates, pending, registerGlobalContext, rejected, resolved, restoreContext, saveContext, slowForEachItem, svgDynamicElement, svgElement, type updateFunc, useContext, useGlobalContext, withContext, withData };
package/dist/index.js CHANGED
@@ -179,6 +179,10 @@ class ConstructContext {
179
179
  get currData() {
180
180
  return this.data;
181
181
  }
182
+ /** The accumulated coordinate base (trackBy values from ancestor forEach loops) */
183
+ get dataIds() {
184
+ return this.coordinateBase;
185
+ }
182
186
  forItem(childViewState, id) {
183
187
  return new ConstructContext(childViewState, false, [...this.coordinateBase, id]);
184
188
  }
@@ -368,17 +372,17 @@ function mkWhenPendingCondition(when2, group) {
368
372
  function forEach(getItems, elemCreator, matchBy) {
369
373
  return { getItems, elemCreator, trackBy: matchBy };
370
374
  }
371
- function slowForEachItem(arrayName, index, trackByValue, elementCreator) {
375
+ function slowForEachItem(getItems, index, trackByValue, elementCreator) {
372
376
  const parentContext = currentConstructionContext();
373
377
  const savedContext = saveContext();
374
378
  const parentData = parentContext.currData;
375
- const array = parentData[arrayName];
379
+ const array = getItems(parentData);
376
380
  const initialItem = array?.[index];
377
381
  const childContext = parentContext.forItem(initialItem, trackByValue);
378
382
  const element2 = withContext(CONSTRUCTION_CONTEXT_MARKER, childContext, elementCreator);
379
383
  const originalUpdate = element2.update;
380
384
  const update = (newParentData) => {
381
- const newArray = newParentData[arrayName];
385
+ const newArray = getItems(newParentData);
382
386
  const newItem = newArray?.[index];
383
387
  const updateChildContext = parentContext.forItem(newItem, trackByValue);
384
388
  restoreContext(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/runtime",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",
@@ -23,11 +23,11 @@
23
23
  "test:watch": "vitest"
24
24
  },
25
25
  "dependencies": {
26
- "@jay-framework/list-compare": "^0.11.0",
27
- "@jay-framework/reactive": "^0.11.0"
26
+ "@jay-framework/list-compare": "^0.13.0",
27
+ "@jay-framework/reactive": "^0.13.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@jay-framework/dev-environment": "^0.11.0",
30
+ "@jay-framework/dev-environment": "^0.13.0",
31
31
  "@testing-library/jest-dom": "^6.2.0",
32
32
  "@types/jsdom": "^21.1.6",
33
33
  "@types/node": "^20.11.5",