octane 0.2.4 → 0.2.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/dist/runtime.d.ts CHANGED
@@ -619,6 +619,8 @@ interface OffscreenCapture {
619
619
  }
620
620
  /** @internal Preserve the owning renderer's scheduler without racing a staged commit. */
621
621
  export declare function scheduleRenderCleanup(schedule: (callback: () => void) => void, receiver: unknown, cleanup: () => void, onDiscard?: () => void): void;
622
+ /** Whether a testing helper is executing within an active act callback. */
623
+ export declare function isInActScope(): boolean;
622
624
  /**
623
625
  * Test-environment opt-in. When true, scheduleRender() calls that happen
624
626
  * outside a flushSync or an act() callback emit a console.error mirroring
@@ -677,17 +679,17 @@ export declare function drainPassiveEffects(): void;
677
679
  */
678
680
  export declare function hasPendingWork(): boolean;
679
681
  /**
680
- * React-parity `act(...)`. Wrap test code that triggers updates so all of
682
+ * Wrap test code that triggers updates so all of
681
683
  * the scheduled work commits before the assertion phase runs.
682
684
  *
683
- * TWO modes, matching React exactly:
685
+ * Two callback modes:
684
686
  * - SYNC callback → all scheduled work (renders + INSERTION/LAYOUT/PASSIVE
685
687
  * effects) is flushed SYNCHRONOUSLY before act returns, so
686
688
  * `act(() => setState(...)); expect(...)` works WITHOUT awaiting — the
687
- * dominant pattern in ported React test suites. The returned (already
688
- * resolved) promise still carries the callback's result; a callback throw
689
- * REJECTS the promise rather than throwing synchronously (React's act is
690
- * a thenable with the same contract).
689
+ * dominant pattern in ported React test suites. Nested callbacks join the
690
+ * outer callback's transaction. The returned promise also drains promise
691
+ * work and carries the callback's result. Callback and render errors reject
692
+ * it rather than escaping through the scheduler.
691
693
  * - ASYNC callback (returns a thenable) → awaited, then the scheduler is
692
694
  * drained across microtask ticks until quiescent (renders, effects, and
693
695
  * microtask chains from `use(promise)` / transition retries).
@@ -696,7 +698,7 @@ export declare function hasPendingWork(): boolean;
696
698
  * dev warning is suppressed (see `IS_OCTANE_ACT_ENVIRONMENT` and
697
699
  * `setIsOctaneActEnvironment`).
698
700
  *
699
- * The async double-loop (5 microtask ticks × up to ACT_DRAIN_LIMIT iterations)
701
+ * Complete promise checkpoints, bounded by ACT_DRAIN_LIMIT iterations,
700
702
  * drains cascades like `use(promise)` → status flip → retry → renderBlock
701
703
  * that wouldn't settle in a single tick.
702
704
  */
@@ -708,6 +710,8 @@ declare const SLOT_FLAG_TEARDOWN: number;
708
710
  export declare function invokeManualHook<T>(fn: (...args: any[]) => T, receiver: unknown, args: IArguments): T;
709
711
  /** @internal Adapt an expression provider that owns the trailing hook-slot ABI. */
710
712
  export declare function manualHook<F extends (...args: any[]) => any>(fn: F, name?: string): F;
713
+ /** Invoke a cached optional-chain method without consulting its call/bind properties. */
714
+ export declare function callWithReceiver<T>(fn: (...args: any[]) => T, receiver: unknown, ...args: any[]): T;
711
715
  export declare function withSlot<T>(sym: symbol, fn: (...a: any[]) => T, ...args: any[]): T;
712
716
  /** @internal Optional native hooks use the existing compiler slot and Scope lifetime. */
713
717
  export declare function nativeLocalHook<T>(name: string, initialize: () => T, dispose: (value: T) => void, slot?: HookSlot): T;
@@ -1581,7 +1585,7 @@ export declare function setFormControlSources(el: Element, sources: ReadonlyArra
1581
1585
  interface PortalSlot {
1582
1586
  __kind: 'portalSlotSlot';
1583
1587
  block: Block | null;
1584
- target: Element | null;
1588
+ target: Element | DocumentFragment | null;
1585
1589
  key: string | null;
1586
1590
  host: Node;
1587
1591
  start: Comment | null;
@@ -1597,7 +1601,7 @@ interface PortalSlot {
1597
1601
  * the portal body in place. Unmounting the enclosing Block tears the portal
1598
1602
  * down and removes its DOM from `target`.
1599
1603
  */
1600
- export declare function portal(parentScope: Scope, slotKey: number, target: Element, body: ComponentBody, props: any, host?: Node, env?: any[], fragmentOwners?: FragmentInstance | readonly FragmentInstance[], fragmentAnchor?: Node): void;
1604
+ export declare function portal(parentScope: Scope, slotKey: number, target: Element | DocumentFragment, body: ComponentBody, props: any, host?: Node, env?: any[], fragmentOwners?: FragmentInstance | readonly FragmentInstance[], fragmentAnchor?: Node): void;
1601
1605
  /**
1602
1606
  * `createPortal(children, target, keyOrProps?)`. A string/number third argument
1603
1607
  * is a reconciliation key. An object remains Octane's optional props for a
@@ -1612,10 +1616,10 @@ export interface PortalDescriptor {
1612
1616
  $$kind: typeof PORTAL_TAG;
1613
1617
  key: string | null;
1614
1618
  body: ComponentBody | ElementDescriptor | unknown;
1615
- target: Element;
1619
+ target: Element | DocumentFragment;
1616
1620
  props: any;
1617
1621
  }
1618
- export declare function createPortal(body: ComponentBody | ElementDescriptor | unknown, target: Element, props?: any): PortalDescriptor;
1622
+ export declare function createPortal(body: ComponentBody | ElementDescriptor | unknown, target: Element | DocumentFragment, props?: any): PortalDescriptor;
1619
1623
  declare const ELEMENT_TAG: unique symbol;
1620
1624
  export interface ElementDescriptor<P = any> {
1621
1625
  $$kind: typeof ELEMENT_TAG;
@@ -1941,7 +1945,7 @@ interface ForSlot {
1941
1945
  plainDeopt: boolean;
1942
1946
  selectionItems?: ArrayLike<any>;
1943
1947
  }
1944
- export declare function forBlock<T>(parentScope: Scope, slotKey: number, domParent: Node, items: ArrayLike<T>, getKey: (item: T, index: number) => any, itemBody: (item: T, scope: Scope) => void, flags?: number, deps?: any[], emptyBody?: ComponentBody | null, anchor?: Node | null, ownEnd?: boolean): void;
1948
+ export declare function forBlock<T>(parentScope: Scope, slotKey: number, domParent: Node, inputItems: ArrayLike<T> | Iterable<T>, getKey: (item: T, index: number) => any, itemBody: (item: T, scope: Scope) => void, flags?: number, deps?: any[], emptyBody?: ComponentBody | null, anchor?: Node | null, ownEnd?: boolean): void;
1945
1949
  /**
1946
1950
  * Compiler-only keyed-selection entry. Keeping the specialization outside
1947
1951
  * forBlock lets applications without a proven selection tree-shake its cost.