@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/LICENSE +21 -0
- package/dist/index.cjs +666 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +198 -1
- package/dist/index.d.ts +198 -1
- package/dist/index.js +628 -1
- package/dist/index.js.map +1 -1
- package/package.json +18 -12
package/dist/index.js
CHANGED
|
@@ -733,25 +733,652 @@ var componentFixtures = {
|
|
|
733
733
|
Modal: buildModal,
|
|
734
734
|
Card: buildCard
|
|
735
735
|
};
|
|
736
|
+
|
|
737
|
+
// src/semantics/types.ts
|
|
738
|
+
var dialect = {
|
|
739
|
+
storybook8: {
|
|
740
|
+
"rsc.render_started": "storybook.play.start",
|
|
741
|
+
"rsc.suspense_boundary": "storybook.suspense.fallback",
|
|
742
|
+
"rsc.html_chunk_streamed": "storybook.stream.chunk",
|
|
743
|
+
"rsc.render_completed": "storybook.play.done",
|
|
744
|
+
"ssr.suspense_pending": "storybook.suspense.pending",
|
|
745
|
+
"ssr.error_boundary_captured": "storybook.error.boundary",
|
|
746
|
+
"ssr.progressive_hydration_started": "storybook.hydration.progressive",
|
|
747
|
+
"ssr.selective_hydration_completed": "storybook.hydration.selective",
|
|
748
|
+
"transition.element_started": "storybook.transition.element.start",
|
|
749
|
+
"transition.element_finished": "storybook.transition.element.finish",
|
|
750
|
+
"transition.document_started": "storybook.transition.document.start",
|
|
751
|
+
"transition.animation_asserted": "storybook.animation.assert",
|
|
752
|
+
"form.status_pending": "storybook.form.pending",
|
|
753
|
+
"form.optimistic_applied": "storybook.form.optimistic",
|
|
754
|
+
"form.progressive_enhanced": "storybook.form.enhanced",
|
|
755
|
+
"form.action_resolved": "storybook.form.resolved"
|
|
756
|
+
},
|
|
757
|
+
"playwright-ct": {
|
|
758
|
+
"rsc.render_started": "pwct.mount.rsc.start",
|
|
759
|
+
"rsc.suspense_boundary": "pwct.locator.suspense.fallback",
|
|
760
|
+
"rsc.html_chunk_streamed": "pwct.response.chunk",
|
|
761
|
+
"rsc.render_completed": "pwct.mount.rsc.done",
|
|
762
|
+
"ssr.suspense_pending": "pwct.suspense.pending",
|
|
763
|
+
"ssr.error_boundary_captured": "pwct.error.boundary",
|
|
764
|
+
"ssr.progressive_hydration_started": "pwct.hydration.progressive",
|
|
765
|
+
"ssr.selective_hydration_completed": "pwct.hydration.selective",
|
|
766
|
+
"transition.element_started": "pwct.transition.element.start",
|
|
767
|
+
"transition.element_finished": "pwct.transition.element.finish",
|
|
768
|
+
"transition.document_started": "pwct.transition.document.start",
|
|
769
|
+
"transition.animation_asserted": "pwct.animation.assert",
|
|
770
|
+
"form.status_pending": "pwct.form.pending",
|
|
771
|
+
"form.optimistic_applied": "pwct.form.optimistic",
|
|
772
|
+
"form.progressive_enhanced": "pwct.form.enhanced",
|
|
773
|
+
"form.action_resolved": "pwct.form.resolved"
|
|
774
|
+
},
|
|
775
|
+
chromatic: {
|
|
776
|
+
"rsc.render_started": "chromatic.capture.rsc.start",
|
|
777
|
+
"rsc.suspense_boundary": "chromatic.capture.suspense",
|
|
778
|
+
"rsc.html_chunk_streamed": "chromatic.capture.chunk",
|
|
779
|
+
"rsc.render_completed": "chromatic.capture.rsc.done",
|
|
780
|
+
"ssr.suspense_pending": "chromatic.suspense.pending",
|
|
781
|
+
"ssr.error_boundary_captured": "chromatic.error.snapshot",
|
|
782
|
+
"ssr.progressive_hydration_started": "chromatic.hydration.progressive",
|
|
783
|
+
"ssr.selective_hydration_completed": "chromatic.hydration.selective",
|
|
784
|
+
"transition.element_started": "chromatic.transition.element.start",
|
|
785
|
+
"transition.element_finished": "chromatic.transition.element.finish",
|
|
786
|
+
"transition.document_started": "chromatic.transition.document.start",
|
|
787
|
+
"transition.animation_asserted": "chromatic.animation.assert",
|
|
788
|
+
"form.status_pending": "chromatic.form.pending",
|
|
789
|
+
"form.optimistic_applied": "chromatic.form.optimistic",
|
|
790
|
+
"form.progressive_enhanced": "chromatic.form.enhanced",
|
|
791
|
+
"form.action_resolved": "chromatic.form.resolved"
|
|
792
|
+
}
|
|
793
|
+
};
|
|
794
|
+
function providerEventName(target, neutral) {
|
|
795
|
+
return dialect[target][neutral] ?? neutral;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
// src/semantics/rsc-harness.ts
|
|
799
|
+
function startRscHarness(input) {
|
|
800
|
+
if (input.componentId.length === 0) {
|
|
801
|
+
throw new Error("startRscHarness: componentId must not be empty");
|
|
802
|
+
}
|
|
803
|
+
return {
|
|
804
|
+
target: input.target,
|
|
805
|
+
componentId: input.componentId,
|
|
806
|
+
state: "idle",
|
|
807
|
+
chunks: [],
|
|
808
|
+
suspenseFallback: input.suspenseFallback ?? null,
|
|
809
|
+
history: [],
|
|
810
|
+
error: null
|
|
811
|
+
};
|
|
812
|
+
}
|
|
813
|
+
function beginRscRender(session) {
|
|
814
|
+
if (session.state !== "idle") {
|
|
815
|
+
throw new Error(`beginRscRender: session is ${session.state}, not idle`);
|
|
816
|
+
}
|
|
817
|
+
session.state = "rendering";
|
|
818
|
+
return emit(session, "rsc.render_started", { componentId: session.componentId });
|
|
819
|
+
}
|
|
820
|
+
function enterSuspenseBoundary(session, fallback = session.suspenseFallback ?? '<template data-suspense="pending"></template>') {
|
|
821
|
+
if (session.state !== "rendering") {
|
|
822
|
+
throw new Error(`enterSuspenseBoundary: session is ${session.state}, not rendering`);
|
|
823
|
+
}
|
|
824
|
+
session.state = "suspended";
|
|
825
|
+
session.suspenseFallback = fallback;
|
|
826
|
+
return emit(session, "rsc.suspense_boundary", { fallback });
|
|
827
|
+
}
|
|
828
|
+
function streamHtmlChunk(session, chunk) {
|
|
829
|
+
if (session.state !== "rendering" && session.state !== "suspended" && session.state !== "streaming") {
|
|
830
|
+
throw new Error(`streamHtmlChunk: session is ${session.state}, cannot stream`);
|
|
831
|
+
}
|
|
832
|
+
if (chunk.length === 0) {
|
|
833
|
+
throw new Error("streamHtmlChunk: chunk must not be empty");
|
|
834
|
+
}
|
|
835
|
+
session.state = "streaming";
|
|
836
|
+
session.chunks.push(chunk);
|
|
837
|
+
return emit(session, "rsc.html_chunk_streamed", {
|
|
838
|
+
chunk,
|
|
839
|
+
chunkIndex: session.chunks.length - 1,
|
|
840
|
+
bytes: chunk.length
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
function completeRscRender(session) {
|
|
844
|
+
if (session.state !== "rendering" && session.state !== "suspended" && session.state !== "streaming") {
|
|
845
|
+
throw new Error(`completeRscRender: session is ${session.state}, cannot complete`);
|
|
846
|
+
}
|
|
847
|
+
session.state = "completed";
|
|
848
|
+
return emit(session, "rsc.render_completed", {
|
|
849
|
+
chunkCount: session.chunks.length,
|
|
850
|
+
html: session.chunks.join("")
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
function failRscRender(session, error) {
|
|
854
|
+
if (session.state === "completed") {
|
|
855
|
+
throw new Error("failRscRender: completed session cannot fail");
|
|
856
|
+
}
|
|
857
|
+
session.state = "errored";
|
|
858
|
+
session.error = typeof error === "string" ? error : error.message;
|
|
859
|
+
return emit(session, "ssr.error_boundary_captured", {
|
|
860
|
+
componentId: session.componentId,
|
|
861
|
+
error: session.error
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
function emit(session, neutralEvent, metadata) {
|
|
865
|
+
const step = {
|
|
866
|
+
neutralEvent,
|
|
867
|
+
providerEvent: providerEventName(session.target, neutralEvent),
|
|
868
|
+
state: session.state,
|
|
869
|
+
amountCents: 0,
|
|
870
|
+
metadata: { target: session.target, ...metadata }
|
|
871
|
+
};
|
|
872
|
+
session.history.push(step);
|
|
873
|
+
return step;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
// src/semantics/streaming-ssr.ts
|
|
877
|
+
function startStreamingSsr(input) {
|
|
878
|
+
if (input.routeId.length === 0) {
|
|
879
|
+
throw new Error("startStreamingSsr: routeId must not be empty");
|
|
880
|
+
}
|
|
881
|
+
return {
|
|
882
|
+
target: input.target,
|
|
883
|
+
routeId: input.routeId,
|
|
884
|
+
state: "idle",
|
|
885
|
+
pendingBoundaries: /* @__PURE__ */ new Set(),
|
|
886
|
+
hydratedBoundaries: /* @__PURE__ */ new Set(),
|
|
887
|
+
errors: [],
|
|
888
|
+
history: []
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
function markSuspensePending(session, boundaryId) {
|
|
892
|
+
assertBoundaryId(boundaryId);
|
|
893
|
+
session.state = "suspense-pending";
|
|
894
|
+
session.pendingBoundaries.add(boundaryId);
|
|
895
|
+
return emit2(session, "ssr.suspense_pending", { boundaryId, pendingCount: session.pendingBoundaries.size });
|
|
896
|
+
}
|
|
897
|
+
function captureErrorBoundary(session, input) {
|
|
898
|
+
assertBoundaryId(input.boundaryId);
|
|
899
|
+
const message = typeof input.error === "string" ? input.error : input.error.message;
|
|
900
|
+
session.state = "error-captured";
|
|
901
|
+
session.errors.push({ boundaryId: input.boundaryId, message });
|
|
902
|
+
if (input.recoverable === false) {
|
|
903
|
+
session.pendingBoundaries.delete(input.boundaryId);
|
|
904
|
+
}
|
|
905
|
+
return emit2(session, "ssr.error_boundary_captured", {
|
|
906
|
+
boundaryId: input.boundaryId,
|
|
907
|
+
message,
|
|
908
|
+
recoverable: input.recoverable ?? true
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
function startProgressiveHydration(session, boundaryId) {
|
|
912
|
+
assertBoundaryId(boundaryId);
|
|
913
|
+
if (!session.pendingBoundaries.has(boundaryId)) {
|
|
914
|
+
throw new Error(`startProgressiveHydration: ${boundaryId} is not pending`);
|
|
915
|
+
}
|
|
916
|
+
session.state = "progressive-hydrating";
|
|
917
|
+
return emit2(session, "ssr.progressive_hydration_started", { boundaryId });
|
|
918
|
+
}
|
|
919
|
+
function completeSelectiveHydration(session, boundaryId) {
|
|
920
|
+
assertBoundaryId(boundaryId);
|
|
921
|
+
if (!session.pendingBoundaries.has(boundaryId)) {
|
|
922
|
+
throw new Error(`completeSelectiveHydration: ${boundaryId} is not pending`);
|
|
923
|
+
}
|
|
924
|
+
session.pendingBoundaries.delete(boundaryId);
|
|
925
|
+
session.hydratedBoundaries.add(boundaryId);
|
|
926
|
+
session.state = "selective-hydrated";
|
|
927
|
+
return emit2(session, "ssr.selective_hydration_completed", {
|
|
928
|
+
boundaryId,
|
|
929
|
+
hydratedCount: session.hydratedBoundaries.size,
|
|
930
|
+
remainingPending: session.pendingBoundaries.size
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
function assertBoundaryId(boundaryId) {
|
|
934
|
+
if (boundaryId.length === 0) {
|
|
935
|
+
throw new Error("boundaryId must not be empty");
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
function emit2(session, neutralEvent, metadata) {
|
|
939
|
+
const step = {
|
|
940
|
+
neutralEvent,
|
|
941
|
+
providerEvent: providerEventName(session.target, neutralEvent),
|
|
942
|
+
state: session.state,
|
|
943
|
+
amountCents: 0,
|
|
944
|
+
metadata: { target: session.target, routeId: session.routeId, ...metadata }
|
|
945
|
+
};
|
|
946
|
+
session.history.push(step);
|
|
947
|
+
return step;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
// src/semantics/view-transitions.ts
|
|
951
|
+
function startViewTransitionSession(input) {
|
|
952
|
+
if (input.transitionId.length === 0) {
|
|
953
|
+
throw new Error("startViewTransitionSession: transitionId must not be empty");
|
|
954
|
+
}
|
|
955
|
+
return {
|
|
956
|
+
target: input.target,
|
|
957
|
+
transitionId: input.transitionId,
|
|
958
|
+
state: "idle",
|
|
959
|
+
activeElements: /* @__PURE__ */ new Set(),
|
|
960
|
+
documentTransition: null,
|
|
961
|
+
assertions: [],
|
|
962
|
+
history: []
|
|
963
|
+
};
|
|
964
|
+
}
|
|
965
|
+
function startElementTransition(session, input) {
|
|
966
|
+
if (input.elementId.length === 0) {
|
|
967
|
+
throw new Error("startElementTransition: elementId must not be empty");
|
|
968
|
+
}
|
|
969
|
+
session.state = "element-transitioning";
|
|
970
|
+
session.activeElements.add(input.elementId);
|
|
971
|
+
return emit3(session, "transition.element_started", input);
|
|
972
|
+
}
|
|
973
|
+
function finishElementTransition(session, elementId) {
|
|
974
|
+
if (!session.activeElements.has(elementId)) {
|
|
975
|
+
throw new Error(`finishElementTransition: ${elementId} is not active`);
|
|
976
|
+
}
|
|
977
|
+
session.activeElements.delete(elementId);
|
|
978
|
+
session.state = session.activeElements.size === 0 ? "finished" : "element-transitioning";
|
|
979
|
+
return emit3(session, "transition.element_finished", {
|
|
980
|
+
elementId,
|
|
981
|
+
remaining: session.activeElements.size
|
|
982
|
+
});
|
|
983
|
+
}
|
|
984
|
+
function startDocumentTransition(session, input) {
|
|
985
|
+
if (input.name.length === 0) {
|
|
986
|
+
throw new Error("startDocumentTransition: name must not be empty");
|
|
987
|
+
}
|
|
988
|
+
session.state = "document-transitioning";
|
|
989
|
+
session.documentTransition = input.name;
|
|
990
|
+
return emit3(session, "transition.document_started", input);
|
|
991
|
+
}
|
|
992
|
+
function assertAnimation(session, input) {
|
|
993
|
+
if (input.durationMs < 0) {
|
|
994
|
+
throw new Error("assertAnimation: durationMs must be >= 0");
|
|
995
|
+
}
|
|
996
|
+
session.state = "asserted";
|
|
997
|
+
session.assertions.push(input.assertionId);
|
|
998
|
+
return emit3(session, "transition.animation_asserted", {
|
|
999
|
+
assertionId: input.assertionId,
|
|
1000
|
+
durationMs: input.durationMs,
|
|
1001
|
+
easing: input.easing ?? "linear"
|
|
1002
|
+
});
|
|
1003
|
+
}
|
|
1004
|
+
function emit3(session, neutralEvent, metadata) {
|
|
1005
|
+
const step = {
|
|
1006
|
+
neutralEvent,
|
|
1007
|
+
providerEvent: providerEventName(session.target, neutralEvent),
|
|
1008
|
+
state: session.state,
|
|
1009
|
+
amountCents: 0,
|
|
1010
|
+
metadata: { target: session.target, transitionId: session.transitionId, ...metadata }
|
|
1011
|
+
};
|
|
1012
|
+
session.history.push(step);
|
|
1013
|
+
return step;
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
// src/semantics/form-action-advanced.ts
|
|
1017
|
+
function startFormActionSession(input) {
|
|
1018
|
+
if (input.formId.length === 0) {
|
|
1019
|
+
throw new Error("startFormActionSession: formId must not be empty");
|
|
1020
|
+
}
|
|
1021
|
+
return {
|
|
1022
|
+
target: input.target,
|
|
1023
|
+
formId: input.formId,
|
|
1024
|
+
state: "idle",
|
|
1025
|
+
form: { ...input.initial },
|
|
1026
|
+
optimisticPatches: [],
|
|
1027
|
+
enhanced: false,
|
|
1028
|
+
history: [],
|
|
1029
|
+
error: null
|
|
1030
|
+
};
|
|
1031
|
+
}
|
|
1032
|
+
function markFormStatusPending(session, submitter) {
|
|
1033
|
+
if (session.state === "pending") {
|
|
1034
|
+
throw new Error("markFormStatusPending: form is already pending");
|
|
1035
|
+
}
|
|
1036
|
+
session.state = "pending";
|
|
1037
|
+
return emit4(session, "form.status_pending", { submitter });
|
|
1038
|
+
}
|
|
1039
|
+
function applyOptimisticUpdate(session, patch) {
|
|
1040
|
+
if (session.state !== "pending" && session.state !== "optimistic") {
|
|
1041
|
+
throw new Error(`applyOptimisticUpdate: session is ${session.state}, not pending`);
|
|
1042
|
+
}
|
|
1043
|
+
session.state = "optimistic";
|
|
1044
|
+
session.optimisticPatches.push(patch);
|
|
1045
|
+
session.form = { ...session.form, ...patch };
|
|
1046
|
+
return emit4(session, "form.optimistic_applied", {
|
|
1047
|
+
patchKeys: Object.keys(patch).join(","),
|
|
1048
|
+
patchCount: session.optimisticPatches.length
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1051
|
+
function enableProgressiveEnhancement(session, input) {
|
|
1052
|
+
if (input.actionUrl.length === 0) {
|
|
1053
|
+
throw new Error("enableProgressiveEnhancement: actionUrl must not be empty");
|
|
1054
|
+
}
|
|
1055
|
+
session.enhanced = true;
|
|
1056
|
+
session.state = "enhanced";
|
|
1057
|
+
return emit4(session, "form.progressive_enhanced", {
|
|
1058
|
+
method: input.method ?? "post",
|
|
1059
|
+
actionUrl: input.actionUrl
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1062
|
+
function resolveFormAction(session, result) {
|
|
1063
|
+
if (session.state === "idle") {
|
|
1064
|
+
throw new Error("resolveFormAction: action was not submitted");
|
|
1065
|
+
}
|
|
1066
|
+
session.state = "resolved";
|
|
1067
|
+
session.form = { ...session.form, ...result };
|
|
1068
|
+
return emit4(session, "form.action_resolved", {
|
|
1069
|
+
resultKeys: Object.keys(result).join(","),
|
|
1070
|
+
enhanced: session.enhanced
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
function rejectFormAction(session, error) {
|
|
1074
|
+
if (session.state === "resolved") {
|
|
1075
|
+
throw new Error("rejectFormAction: resolved action cannot reject");
|
|
1076
|
+
}
|
|
1077
|
+
session.state = "rejected";
|
|
1078
|
+
session.error = typeof error === "string" ? error : error.message;
|
|
1079
|
+
return emit4(session, "form.action_resolved", {
|
|
1080
|
+
rejected: true,
|
|
1081
|
+
error: session.error
|
|
1082
|
+
});
|
|
1083
|
+
}
|
|
1084
|
+
function emit4(session, neutralEvent, metadata) {
|
|
1085
|
+
const step = {
|
|
1086
|
+
neutralEvent,
|
|
1087
|
+
providerEvent: providerEventName(session.target, neutralEvent),
|
|
1088
|
+
state: session.state,
|
|
1089
|
+
amountCents: 0,
|
|
1090
|
+
metadata: { target: session.target, formId: session.formId, ...metadata }
|
|
1091
|
+
};
|
|
1092
|
+
session.history.push(step);
|
|
1093
|
+
return step;
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
// src/semantics/fidelity.ts
|
|
1097
|
+
var COMPONENT_AXIS_TO_EVENTS = {
|
|
1098
|
+
"rsc-harness": [
|
|
1099
|
+
"rsc.render_started",
|
|
1100
|
+
"rsc.suspense_boundary",
|
|
1101
|
+
"rsc.html_chunk_streamed",
|
|
1102
|
+
"rsc.render_completed"
|
|
1103
|
+
],
|
|
1104
|
+
"streaming-ssr": [
|
|
1105
|
+
"ssr.suspense_pending",
|
|
1106
|
+
"ssr.error_boundary_captured",
|
|
1107
|
+
"ssr.progressive_hydration_started",
|
|
1108
|
+
"ssr.selective_hydration_completed"
|
|
1109
|
+
],
|
|
1110
|
+
"view-transitions": [
|
|
1111
|
+
"transition.element_started",
|
|
1112
|
+
"transition.element_finished",
|
|
1113
|
+
"transition.document_started",
|
|
1114
|
+
"transition.animation_asserted"
|
|
1115
|
+
],
|
|
1116
|
+
"form-action-advanced": [
|
|
1117
|
+
"form.status_pending",
|
|
1118
|
+
"form.optimistic_applied",
|
|
1119
|
+
"form.progressive_enhanced",
|
|
1120
|
+
"form.action_resolved"
|
|
1121
|
+
],
|
|
1122
|
+
// v1.49 advanced III
|
|
1123
|
+
"react-19-actions": [
|
|
1124
|
+
"action.state_initialized",
|
|
1125
|
+
"action.transition_pending",
|
|
1126
|
+
"action.optimistic_committed",
|
|
1127
|
+
"action.resolved"
|
|
1128
|
+
],
|
|
1129
|
+
"islands-architecture": [
|
|
1130
|
+
"islands.registered",
|
|
1131
|
+
"islands.hydration_started",
|
|
1132
|
+
"islands.interactive_ready",
|
|
1133
|
+
"islands.static_boundary_asserted"
|
|
1134
|
+
]
|
|
1135
|
+
};
|
|
1136
|
+
function collectFidelityCoverage(providers = ["storybook8", "playwright-ct", "chromatic"]) {
|
|
1137
|
+
const axes = Object.keys(COMPONENT_AXIS_TO_EVENTS);
|
|
1138
|
+
const rows = [];
|
|
1139
|
+
for (const provider of providers) {
|
|
1140
|
+
for (const axis of axes) {
|
|
1141
|
+
const neutralEvents = COMPONENT_AXIS_TO_EVENTS[axis];
|
|
1142
|
+
rows.push({
|
|
1143
|
+
provider,
|
|
1144
|
+
axis,
|
|
1145
|
+
neutralEvents,
|
|
1146
|
+
providerEvents: neutralEvents.map((event) => providerEventName(provider, event))
|
|
1147
|
+
});
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
return { providers, axes, rows };
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
// src/semantics/react-19-actions.ts
|
|
1154
|
+
function emit5(session, neutralEvent, metadata) {
|
|
1155
|
+
const step = {
|
|
1156
|
+
neutralEvent,
|
|
1157
|
+
providerEvent: providerEventName(session.target, neutralEvent),
|
|
1158
|
+
state: session.state,
|
|
1159
|
+
amountCents: 0,
|
|
1160
|
+
metadata: { actionId: session.actionId, ...metadata }
|
|
1161
|
+
};
|
|
1162
|
+
session.history.push(step);
|
|
1163
|
+
return step;
|
|
1164
|
+
}
|
|
1165
|
+
function initializeReactActions(input) {
|
|
1166
|
+
if (input.actionId.length === 0) {
|
|
1167
|
+
throw new Error("initializeReactActions: actionId must not be empty");
|
|
1168
|
+
}
|
|
1169
|
+
const session = {
|
|
1170
|
+
target: input.target,
|
|
1171
|
+
actionId: input.actionId,
|
|
1172
|
+
state: "idle",
|
|
1173
|
+
pendingCount: 0,
|
|
1174
|
+
optimisticValues: [],
|
|
1175
|
+
resolvedValue: null,
|
|
1176
|
+
history: []
|
|
1177
|
+
};
|
|
1178
|
+
emit5(session, "action.state_initialized", { pendingCount: 0 });
|
|
1179
|
+
return session;
|
|
1180
|
+
}
|
|
1181
|
+
function beginActionTransition(session) {
|
|
1182
|
+
if (session.state !== "idle" && session.state !== "resolved") {
|
|
1183
|
+
throw new Error(`beginActionTransition: session is ${session.state}`);
|
|
1184
|
+
}
|
|
1185
|
+
session.state = "transition-pending";
|
|
1186
|
+
session.pendingCount += 1;
|
|
1187
|
+
return emit5(session, "action.transition_pending", {
|
|
1188
|
+
pendingCount: session.pendingCount
|
|
1189
|
+
});
|
|
1190
|
+
}
|
|
1191
|
+
function applyOptimisticUpdate2(session, optimisticValue) {
|
|
1192
|
+
if (session.state !== "transition-pending") {
|
|
1193
|
+
throw new Error(`applyOptimisticUpdate: session is ${session.state}`);
|
|
1194
|
+
}
|
|
1195
|
+
session.state = "optimistic-committed";
|
|
1196
|
+
session.optimisticValues.push(optimisticValue);
|
|
1197
|
+
return emit5(session, "action.optimistic_committed", { optimisticValue });
|
|
1198
|
+
}
|
|
1199
|
+
function resolveAction(session, resolvedValue) {
|
|
1200
|
+
if (session.state !== "transition-pending" && session.state !== "optimistic-committed") {
|
|
1201
|
+
throw new Error(`resolveAction: session is ${session.state}`);
|
|
1202
|
+
}
|
|
1203
|
+
session.state = "resolved";
|
|
1204
|
+
session.resolvedValue = resolvedValue;
|
|
1205
|
+
session.pendingCount = Math.max(0, session.pendingCount - 1);
|
|
1206
|
+
return emit5(session, "action.resolved", {
|
|
1207
|
+
resolvedValue,
|
|
1208
|
+
pendingCount: session.pendingCount,
|
|
1209
|
+
optimisticCount: session.optimisticValues.length
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
// src/semantics/islands-architecture.ts
|
|
1214
|
+
function emit6(session, neutralEvent, metadata) {
|
|
1215
|
+
const step = {
|
|
1216
|
+
neutralEvent,
|
|
1217
|
+
providerEvent: providerEventName(session.target, neutralEvent),
|
|
1218
|
+
state: session.state,
|
|
1219
|
+
amountCents: 0,
|
|
1220
|
+
metadata: { routeId: session.routeId, ...metadata }
|
|
1221
|
+
};
|
|
1222
|
+
session.history.push(step);
|
|
1223
|
+
return step;
|
|
1224
|
+
}
|
|
1225
|
+
function bootstrapIslandsRoute(input) {
|
|
1226
|
+
if (input.routeId.length === 0) {
|
|
1227
|
+
throw new Error("bootstrapIslandsRoute: routeId must not be empty");
|
|
1228
|
+
}
|
|
1229
|
+
return {
|
|
1230
|
+
target: input.target,
|
|
1231
|
+
routeId: input.routeId,
|
|
1232
|
+
islands: [],
|
|
1233
|
+
state: "idle",
|
|
1234
|
+
hydratedIslandIds: [],
|
|
1235
|
+
staticBoundaryIds: [],
|
|
1236
|
+
history: []
|
|
1237
|
+
};
|
|
1238
|
+
}
|
|
1239
|
+
function registerIsland(session, island) {
|
|
1240
|
+
session.islands.push(island);
|
|
1241
|
+
session.state = "registered";
|
|
1242
|
+
return emit6(session, "islands.registered", {
|
|
1243
|
+
islandId: island.islandId,
|
|
1244
|
+
loadStrategy: island.loadStrategy,
|
|
1245
|
+
interactiveBoundary: island.interactiveBoundary
|
|
1246
|
+
});
|
|
1247
|
+
}
|
|
1248
|
+
function beginIslandHydration(session, islandId) {
|
|
1249
|
+
const island = session.islands.find((i) => i.islandId === islandId);
|
|
1250
|
+
if (!island) {
|
|
1251
|
+
throw new Error(`beginIslandHydration: island ${islandId} not registered`);
|
|
1252
|
+
}
|
|
1253
|
+
if (session.state !== "registered" && session.state !== "hydrating") {
|
|
1254
|
+
throw new Error(`beginIslandHydration: session is ${session.state}`);
|
|
1255
|
+
}
|
|
1256
|
+
session.state = "hydrating";
|
|
1257
|
+
return emit6(session, "islands.hydration_started", {
|
|
1258
|
+
islandId,
|
|
1259
|
+
loadStrategy: island.loadStrategy
|
|
1260
|
+
});
|
|
1261
|
+
}
|
|
1262
|
+
function markIslandInteractive(session, islandId) {
|
|
1263
|
+
if (session.state !== "hydrating") {
|
|
1264
|
+
throw new Error(`markIslandInteractive: session is ${session.state}`);
|
|
1265
|
+
}
|
|
1266
|
+
if (session.hydratedIslandIds.includes(islandId)) {
|
|
1267
|
+
throw new Error(`markIslandInteractive: island ${islandId} already interactive`);
|
|
1268
|
+
}
|
|
1269
|
+
session.hydratedIslandIds.push(islandId);
|
|
1270
|
+
const allHydrated = session.hydratedIslandIds.length === session.islands.filter((i) => i.interactiveBoundary).length;
|
|
1271
|
+
if (allHydrated) {
|
|
1272
|
+
session.state = "interactive";
|
|
1273
|
+
}
|
|
1274
|
+
return emit6(session, "islands.interactive_ready", {
|
|
1275
|
+
islandId,
|
|
1276
|
+
hydratedCount: session.hydratedIslandIds.length,
|
|
1277
|
+
allInteractiveReady: allHydrated
|
|
1278
|
+
});
|
|
1279
|
+
}
|
|
1280
|
+
function assertStaticBoundary(session, boundaryId) {
|
|
1281
|
+
if (session.staticBoundaryIds.includes(boundaryId)) {
|
|
1282
|
+
throw new Error(`assertStaticBoundary: boundary ${boundaryId} already asserted`);
|
|
1283
|
+
}
|
|
1284
|
+
session.staticBoundaryIds.push(boundaryId);
|
|
1285
|
+
if (session.state === "interactive") {
|
|
1286
|
+
session.state = "static-verified";
|
|
1287
|
+
}
|
|
1288
|
+
return emit6(session, "islands.static_boundary_asserted", {
|
|
1289
|
+
boundaryId,
|
|
1290
|
+
staticBoundaryCount: session.staticBoundaryIds.length
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
// src/real-driver.ts
|
|
1295
|
+
var TARGET_KEY_ENV = {
|
|
1296
|
+
storybook8: "STORYBOOK_URL",
|
|
1297
|
+
"playwright-ct": "PLAYWRIGHT_CT_URL",
|
|
1298
|
+
chromatic: "CHROMATIC_TOKEN"
|
|
1299
|
+
};
|
|
1300
|
+
function resolveMode(provider, env = process.env) {
|
|
1301
|
+
const rawMode = env.KIWA_MODE?.toLowerCase();
|
|
1302
|
+
if (rawMode !== void 0 && rawMode !== "real" && rawMode !== "mock") {
|
|
1303
|
+
return { provider, mode: "mock", reason: "invalid-mode" };
|
|
1304
|
+
}
|
|
1305
|
+
if (rawMode !== "real") {
|
|
1306
|
+
return { provider, mode: "mock", reason: "default-mock" };
|
|
1307
|
+
}
|
|
1308
|
+
const keyValue = env[TARGET_KEY_ENV[provider]];
|
|
1309
|
+
if (typeof keyValue !== "string" || keyValue.length === 0) {
|
|
1310
|
+
return { provider, mode: "mock", reason: "missing-key" };
|
|
1311
|
+
}
|
|
1312
|
+
return { provider, mode: "real", reason: "kiwa-mode-real" };
|
|
1313
|
+
}
|
|
1314
|
+
function resolveAllModes(env = process.env) {
|
|
1315
|
+
const providers = ["storybook8", "playwright-ct", "chromatic"];
|
|
1316
|
+
return providers.map((provider) => resolveMode(provider, env));
|
|
1317
|
+
}
|
|
1318
|
+
function assertMode(provider, expected, env = process.env) {
|
|
1319
|
+
const resolved = resolveMode(provider, env);
|
|
1320
|
+
if (resolved.mode !== expected) {
|
|
1321
|
+
throw new Error(
|
|
1322
|
+
`expected ${provider} in ${expected} mode but resolved ${resolved.mode} (${resolved.reason})`
|
|
1323
|
+
);
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
736
1326
|
export {
|
|
1327
|
+
COMPONENT_AXIS_TO_EVENTS,
|
|
737
1328
|
addHandler,
|
|
738
1329
|
appendChild,
|
|
1330
|
+
applyOptimisticUpdate,
|
|
1331
|
+
applyOptimisticUpdate2 as applyReactActionOptimistic,
|
|
1332
|
+
assertAnimation,
|
|
1333
|
+
assertMode,
|
|
1334
|
+
assertStaticBoundary,
|
|
1335
|
+
beginActionTransition,
|
|
1336
|
+
beginIslandHydration,
|
|
1337
|
+
beginRscRender,
|
|
1338
|
+
bootstrapIslandsRoute,
|
|
739
1339
|
buildButton,
|
|
740
1340
|
buildCard,
|
|
741
1341
|
buildForm,
|
|
742
1342
|
buildInput,
|
|
743
1343
|
buildModal,
|
|
1344
|
+
captureErrorBoundary,
|
|
1345
|
+
collectFidelityCoverage,
|
|
1346
|
+
completeRscRender,
|
|
1347
|
+
completeSelectiveHydration,
|
|
744
1348
|
componentFixtures,
|
|
745
1349
|
createCanvas,
|
|
746
1350
|
createChromaticVisualMock,
|
|
747
1351
|
createNode,
|
|
748
1352
|
createPlaywrightCTMock,
|
|
749
1353
|
createStoryRegistry,
|
|
1354
|
+
enableProgressiveEnhancement,
|
|
1355
|
+
enterSuspenseBoundary,
|
|
1356
|
+
failRscRender,
|
|
750
1357
|
findByRole,
|
|
751
1358
|
findByText,
|
|
1359
|
+
finishElementTransition,
|
|
752
1360
|
fireEvent,
|
|
753
1361
|
hashMarkup,
|
|
1362
|
+
initializeReactActions,
|
|
1363
|
+
markFormStatusPending,
|
|
1364
|
+
markIslandInteractive,
|
|
1365
|
+
markSuspensePending,
|
|
1366
|
+
providerEventName,
|
|
754
1367
|
query,
|
|
755
|
-
|
|
1368
|
+
registerIsland,
|
|
1369
|
+
rejectFormAction,
|
|
1370
|
+
renderMarkup,
|
|
1371
|
+
resolveAction,
|
|
1372
|
+
resolveAllModes,
|
|
1373
|
+
resolveFormAction,
|
|
1374
|
+
resolveMode,
|
|
1375
|
+
startDocumentTransition,
|
|
1376
|
+
startElementTransition,
|
|
1377
|
+
startFormActionSession,
|
|
1378
|
+
startProgressiveHydration,
|
|
1379
|
+
startRscHarness,
|
|
1380
|
+
startStreamingSsr,
|
|
1381
|
+
startViewTransitionSession,
|
|
1382
|
+
streamHtmlChunk
|
|
756
1383
|
};
|
|
757
1384
|
//# sourceMappingURL=index.js.map
|