@kiwa-test/component 0.2.0 → 0.4.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
@@ -531,4 +531,201 @@ declare const buildCard: ComponentRender<CardArgs>;
531
531
  /** 全 component の render function を 1 record にまとめる (test 一括登録用)。 */
532
532
  declare const componentFixtures: Record<string, ComponentRender<Record<string, unknown>>>;
533
533
 
534
- export { type A11yViolation, type ButtonArgs, type CanvasElement, type CardArgs, type ChromaticConfig, type ChromaticVisualMock, type ComponentLocator, type ComponentProvider, type ComponentRender, type FormArgs, type FormField, type InputArgs, type MockEvent, type MockNode, type ModalArgs, type NodeLocator, type NodeOptions, type PlayContext, type PlaywrightCTMock, type StoryEntry, type StoryMeta, type StoryMountResult, type StoryObj, type StoryParameters, type StoryPlayResult, type StoryRegistry, type VisualBaseline, type VisualDiff, type VisualReviewAction, type VisualReviewEntry, addHandler, appendChild, buildButton, buildCard, buildForm, buildInput, buildModal, componentFixtures, createCanvas, createChromaticVisualMock, createNode, createPlaywrightCTMock, createStoryRegistry, findByRole, findByText, fireEvent, hashMarkup, query, renderMarkup };
534
+ /**
535
+ * Advanced component semantics — target-neutral axis SSOT.
536
+ *
537
+ * The component package spans Storybook 8, Playwright Component Testing, and
538
+ * Chromatic. These helpers model the observable semantics without importing
539
+ * any of those runtimes, so the same axis can be replayed against each target.
540
+ */
541
+ type ComponentTarget = 'storybook8' | 'playwright-ct' | 'chromatic';
542
+ type ComponentAxis = 'rsc-harness' | 'streaming-ssr' | 'view-transitions' | 'form-action-advanced' | 'react-19-actions' | 'islands-architecture';
543
+ type NeutralEventName = 'rsc.render_started' | 'rsc.suspense_boundary' | 'rsc.html_chunk_streamed' | 'rsc.render_completed' | 'ssr.suspense_pending' | 'ssr.error_boundary_captured' | 'ssr.progressive_hydration_started' | 'ssr.selective_hydration_completed' | 'transition.element_started' | 'transition.element_finished' | 'transition.document_started' | 'transition.animation_asserted' | 'form.status_pending' | 'form.optimistic_applied' | 'form.progressive_enhanced' | 'form.action_resolved' | 'action.state_initialized' | 'action.transition_pending' | 'action.optimistic_committed' | 'action.resolved' | 'islands.registered' | 'islands.hydration_started' | 'islands.interactive_ready' | 'islands.static_boundary_asserted';
544
+ interface AxisStep<TState extends string> {
545
+ neutralEvent: NeutralEventName;
546
+ providerEvent: string;
547
+ state: TState;
548
+ amountCents: number;
549
+ metadata: Record<string, string | number | boolean>;
550
+ }
551
+ declare function providerEventName(target: ComponentTarget, neutral: NeutralEventName): string;
552
+
553
+ type RscHarnessState = 'idle' | 'rendering' | 'suspended' | 'streaming' | 'completed' | 'errored';
554
+ interface RscHarnessSession {
555
+ target: ComponentTarget;
556
+ componentId: string;
557
+ state: RscHarnessState;
558
+ chunks: string[];
559
+ suspenseFallback: string | null;
560
+ history: AxisStep<RscHarnessState>[];
561
+ error: string | null;
562
+ }
563
+ declare function startRscHarness(input: {
564
+ target: ComponentTarget;
565
+ componentId: string;
566
+ suspenseFallback?: string;
567
+ }): RscHarnessSession;
568
+ declare function beginRscRender(session: RscHarnessSession): AxisStep<RscHarnessState>;
569
+ declare function enterSuspenseBoundary(session: RscHarnessSession, fallback?: string): AxisStep<RscHarnessState>;
570
+ declare function streamHtmlChunk(session: RscHarnessSession, chunk: string): AxisStep<RscHarnessState>;
571
+ declare function completeRscRender(session: RscHarnessSession): AxisStep<RscHarnessState>;
572
+ declare function failRscRender(session: RscHarnessSession, error: Error | string): AxisStep<RscHarnessState>;
573
+
574
+ type StreamingSsrState = 'idle' | 'suspense-pending' | 'error-captured' | 'progressive-hydrating' | 'selective-hydrated';
575
+ interface StreamingSsrSession {
576
+ target: ComponentTarget;
577
+ routeId: string;
578
+ state: StreamingSsrState;
579
+ pendingBoundaries: Set<string>;
580
+ hydratedBoundaries: Set<string>;
581
+ errors: Array<{
582
+ boundaryId: string;
583
+ message: string;
584
+ }>;
585
+ history: AxisStep<StreamingSsrState>[];
586
+ }
587
+ declare function startStreamingSsr(input: {
588
+ target: ComponentTarget;
589
+ routeId: string;
590
+ }): StreamingSsrSession;
591
+ declare function markSuspensePending(session: StreamingSsrSession, boundaryId: string): AxisStep<StreamingSsrState>;
592
+ declare function captureErrorBoundary(session: StreamingSsrSession, input: {
593
+ boundaryId: string;
594
+ error: Error | string;
595
+ recoverable?: boolean;
596
+ }): AxisStep<StreamingSsrState>;
597
+ declare function startProgressiveHydration(session: StreamingSsrSession, boundaryId: string): AxisStep<StreamingSsrState>;
598
+ declare function completeSelectiveHydration(session: StreamingSsrSession, boundaryId: string): AxisStep<StreamingSsrState>;
599
+
600
+ type ViewTransitionState = 'idle' | 'element-transitioning' | 'document-transitioning' | 'asserted' | 'finished';
601
+ interface ViewTransitionSession {
602
+ target: ComponentTarget;
603
+ transitionId: string;
604
+ state: ViewTransitionState;
605
+ activeElements: Set<string>;
606
+ documentTransition: string | null;
607
+ assertions: string[];
608
+ history: AxisStep<ViewTransitionState>[];
609
+ }
610
+ declare function startViewTransitionSession(input: {
611
+ target: ComponentTarget;
612
+ transitionId: string;
613
+ }): ViewTransitionSession;
614
+ declare function startElementTransition(session: ViewTransitionSession, input: {
615
+ elementId: string;
616
+ from: string;
617
+ to: string;
618
+ }): AxisStep<ViewTransitionState>;
619
+ declare function finishElementTransition(session: ViewTransitionSession, elementId: string): AxisStep<ViewTransitionState>;
620
+ declare function startDocumentTransition(session: ViewTransitionSession, input: {
621
+ name: string;
622
+ fromUrl: string;
623
+ toUrl: string;
624
+ }): AxisStep<ViewTransitionState>;
625
+ declare function assertAnimation(session: ViewTransitionSession, input: {
626
+ assertionId: string;
627
+ durationMs: number;
628
+ easing?: string;
629
+ }): AxisStep<ViewTransitionState>;
630
+
631
+ type FormActionState = 'idle' | 'pending' | 'optimistic' | 'enhanced' | 'resolved' | 'rejected';
632
+ interface FormActionSession<TForm extends Record<string, unknown> = Record<string, unknown>> {
633
+ target: ComponentTarget;
634
+ formId: string;
635
+ state: FormActionState;
636
+ form: TForm;
637
+ optimisticPatches: Array<Partial<TForm>>;
638
+ enhanced: boolean;
639
+ history: AxisStep<FormActionState>[];
640
+ error: string | null;
641
+ }
642
+ declare function startFormActionSession<TForm extends Record<string, unknown>>(input: {
643
+ target: ComponentTarget;
644
+ formId: string;
645
+ initial: TForm;
646
+ }): FormActionSession<TForm>;
647
+ declare function markFormStatusPending<TForm extends Record<string, unknown>>(session: FormActionSession<TForm>, submitter: string): AxisStep<FormActionState>;
648
+ declare function applyOptimisticUpdate$1<TForm extends Record<string, unknown>>(session: FormActionSession<TForm>, patch: Partial<TForm>): AxisStep<FormActionState>;
649
+ declare function enableProgressiveEnhancement<TForm extends Record<string, unknown>>(session: FormActionSession<TForm>, input: {
650
+ method?: 'post' | 'get';
651
+ actionUrl: string;
652
+ }): AxisStep<FormActionState>;
653
+ declare function resolveFormAction<TForm extends Record<string, unknown>>(session: FormActionSession<TForm>, result: Partial<TForm>): AxisStep<FormActionState>;
654
+ declare function rejectFormAction<TForm extends Record<string, unknown>>(session: FormActionSession<TForm>, error: Error | string): AxisStep<FormActionState>;
655
+
656
+ interface FidelityRow {
657
+ provider: ComponentTarget;
658
+ axis: ComponentAxis;
659
+ neutralEvents: NeutralEventName[];
660
+ providerEvents: string[];
661
+ }
662
+ interface FidelityCoverage {
663
+ providers: ComponentTarget[];
664
+ axes: ComponentAxis[];
665
+ rows: FidelityRow[];
666
+ }
667
+ declare const COMPONENT_AXIS_TO_EVENTS: Record<ComponentAxis, NeutralEventName[]>;
668
+ declare function collectFidelityCoverage(providers?: ComponentTarget[]): FidelityCoverage;
669
+
670
+ /**
671
+ * v1.49 react-19-actions axis — useActionState + useOptimistic + useFormStatus
672
+ * を統合した React 19 Actions API の deterministic state machine。
673
+ */
674
+ type ReactActionsState = 'idle' | 'transition-pending' | 'optimistic-committed' | 'resolved';
675
+ interface ReactActionsSession {
676
+ target: ComponentTarget;
677
+ actionId: string;
678
+ state: ReactActionsState;
679
+ pendingCount: number;
680
+ optimisticValues: string[];
681
+ resolvedValue: string | null;
682
+ history: AxisStep<ReactActionsState>[];
683
+ }
684
+ declare function initializeReactActions(input: {
685
+ target: ComponentTarget;
686
+ actionId: string;
687
+ }): ReactActionsSession;
688
+ declare function beginActionTransition(session: ReactActionsSession): AxisStep<ReactActionsState>;
689
+ declare function applyOptimisticUpdate(session: ReactActionsSession, optimisticValue: string): AxisStep<ReactActionsState>;
690
+ declare function resolveAction(session: ReactActionsSession, resolvedValue: string): AxisStep<ReactActionsState>;
691
+
692
+ /**
693
+ * v1.49 islands-architecture axis — Astro / Deno Fresh / Solid Start の
694
+ * Islands architecture (partial hydration + selective interactivity) を
695
+ * target-neutral に扱う state machine。
696
+ */
697
+ type IslandsState = 'idle' | 'registered' | 'hydrating' | 'interactive' | 'static-verified';
698
+ interface IslandSpec {
699
+ islandId: string;
700
+ loadStrategy: 'load' | 'idle' | 'visible' | 'media' | 'only';
701
+ interactiveBoundary: boolean;
702
+ }
703
+ interface IslandsSession {
704
+ target: ComponentTarget;
705
+ routeId: string;
706
+ islands: IslandSpec[];
707
+ state: IslandsState;
708
+ hydratedIslandIds: string[];
709
+ staticBoundaryIds: string[];
710
+ history: AxisStep<IslandsState>[];
711
+ }
712
+ declare function bootstrapIslandsRoute(input: {
713
+ target: ComponentTarget;
714
+ routeId: string;
715
+ }): IslandsSession;
716
+ declare function registerIsland(session: IslandsSession, island: IslandSpec): AxisStep<IslandsState>;
717
+ declare function beginIslandHydration(session: IslandsSession, islandId: string): AxisStep<IslandsState>;
718
+ declare function markIslandInteractive(session: IslandsSession, islandId: string): AxisStep<IslandsState>;
719
+ declare function assertStaticBoundary(session: IslandsSession, boundaryId: string): AxisStep<IslandsState>;
720
+
721
+ type KiwaTestMode = 'mock' | 'real';
722
+ interface ResolvedMode {
723
+ mode: KiwaTestMode;
724
+ provider: ComponentTarget;
725
+ reason: 'default-mock' | 'kiwa-mode-real' | 'missing-key' | 'invalid-mode';
726
+ }
727
+ declare function resolveMode(provider: ComponentTarget, env?: Record<string, string | undefined>): ResolvedMode;
728
+ declare function resolveAllModes(env?: Record<string, string | undefined>): ResolvedMode[];
729
+ declare function assertMode(provider: ComponentTarget, expected: KiwaTestMode, env?: Record<string, string | undefined>): void;
730
+
731
+ export { type A11yViolation, type AxisStep, type ButtonArgs, COMPONENT_AXIS_TO_EVENTS, type CanvasElement, type CardArgs, type ChromaticConfig, type ChromaticVisualMock, type ComponentAxis, type ComponentLocator, type ComponentProvider, type ComponentRender, type ComponentTarget, type FidelityCoverage, type FidelityRow, type FormActionSession, type FormActionState, type FormArgs, type FormField, type InputArgs, type IslandSpec, type IslandsSession, type IslandsState, type KiwaTestMode, type MockEvent, type MockNode, type ModalArgs, type NeutralEventName, type NodeLocator, type NodeOptions, type PlayContext, type PlaywrightCTMock, type ReactActionsSession, type ReactActionsState, type ResolvedMode, type RscHarnessSession, type RscHarnessState, type StoryEntry, type StoryMeta, type StoryMountResult, type StoryObj, type StoryParameters, type StoryPlayResult, type StoryRegistry, type StreamingSsrSession, type StreamingSsrState, type ViewTransitionSession, type ViewTransitionState, type VisualBaseline, type VisualDiff, type VisualReviewAction, type VisualReviewEntry, addHandler, appendChild, applyOptimisticUpdate$1 as applyOptimisticUpdate, applyOptimisticUpdate as applyReactActionOptimistic, assertAnimation, assertMode, assertStaticBoundary, beginActionTransition, beginIslandHydration, beginRscRender, bootstrapIslandsRoute, buildButton, buildCard, buildForm, buildInput, buildModal, captureErrorBoundary, collectFidelityCoverage, completeRscRender, completeSelectiveHydration, componentFixtures, createCanvas, createChromaticVisualMock, createNode, createPlaywrightCTMock, createStoryRegistry, enableProgressiveEnhancement, enterSuspenseBoundary, failRscRender, findByRole, findByText, finishElementTransition, fireEvent, hashMarkup, initializeReactActions, markFormStatusPending, markIslandInteractive, markSuspensePending, providerEventName, query, registerIsland, rejectFormAction, renderMarkup, resolveAction, resolveAllModes, resolveFormAction, resolveMode, startDocumentTransition, startElementTransition, startFormActionSession, startProgressiveHydration, startRscHarness, startStreamingSsr, startViewTransitionSession, streamHtmlChunk };