@kiwa-test/component 0.2.0 → 0.3.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 +494 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +147 -1
- package/dist/index.d.ts +147 -1
- package/dist/index.js +465 -1
- package/dist/index.js.map +1 -1
- package/package.json +18 -12
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 cardene777
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
CHANGED
|
@@ -20,25 +20,53 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
COMPONENT_AXIS_TO_EVENTS: () => COMPONENT_AXIS_TO_EVENTS,
|
|
23
24
|
addHandler: () => addHandler,
|
|
24
25
|
appendChild: () => appendChild,
|
|
26
|
+
applyOptimisticUpdate: () => applyOptimisticUpdate,
|
|
27
|
+
assertAnimation: () => assertAnimation,
|
|
28
|
+
assertMode: () => assertMode,
|
|
29
|
+
beginRscRender: () => beginRscRender,
|
|
25
30
|
buildButton: () => buildButton,
|
|
26
31
|
buildCard: () => buildCard,
|
|
27
32
|
buildForm: () => buildForm,
|
|
28
33
|
buildInput: () => buildInput,
|
|
29
34
|
buildModal: () => buildModal,
|
|
35
|
+
captureErrorBoundary: () => captureErrorBoundary,
|
|
36
|
+
collectFidelityCoverage: () => collectFidelityCoverage,
|
|
37
|
+
completeRscRender: () => completeRscRender,
|
|
38
|
+
completeSelectiveHydration: () => completeSelectiveHydration,
|
|
30
39
|
componentFixtures: () => componentFixtures,
|
|
31
40
|
createCanvas: () => createCanvas,
|
|
32
41
|
createChromaticVisualMock: () => createChromaticVisualMock,
|
|
33
42
|
createNode: () => createNode,
|
|
34
43
|
createPlaywrightCTMock: () => createPlaywrightCTMock,
|
|
35
44
|
createStoryRegistry: () => createStoryRegistry,
|
|
45
|
+
enableProgressiveEnhancement: () => enableProgressiveEnhancement,
|
|
46
|
+
enterSuspenseBoundary: () => enterSuspenseBoundary,
|
|
47
|
+
failRscRender: () => failRscRender,
|
|
36
48
|
findByRole: () => findByRole,
|
|
37
49
|
findByText: () => findByText,
|
|
50
|
+
finishElementTransition: () => finishElementTransition,
|
|
38
51
|
fireEvent: () => fireEvent,
|
|
39
52
|
hashMarkup: () => hashMarkup,
|
|
53
|
+
markFormStatusPending: () => markFormStatusPending,
|
|
54
|
+
markSuspensePending: () => markSuspensePending,
|
|
55
|
+
providerEventName: () => providerEventName,
|
|
40
56
|
query: () => query,
|
|
41
|
-
|
|
57
|
+
rejectFormAction: () => rejectFormAction,
|
|
58
|
+
renderMarkup: () => renderMarkup,
|
|
59
|
+
resolveAllModes: () => resolveAllModes,
|
|
60
|
+
resolveFormAction: () => resolveFormAction,
|
|
61
|
+
resolveMode: () => resolveMode,
|
|
62
|
+
startDocumentTransition: () => startDocumentTransition,
|
|
63
|
+
startElementTransition: () => startElementTransition,
|
|
64
|
+
startFormActionSession: () => startFormActionSession,
|
|
65
|
+
startProgressiveHydration: () => startProgressiveHydration,
|
|
66
|
+
startRscHarness: () => startRscHarness,
|
|
67
|
+
startStreamingSsr: () => startStreamingSsr,
|
|
68
|
+
startViewTransitionSession: () => startViewTransitionSession,
|
|
69
|
+
streamHtmlChunk: () => streamHtmlChunk
|
|
42
70
|
});
|
|
43
71
|
module.exports = __toCommonJS(index_exports);
|
|
44
72
|
|
|
@@ -777,26 +805,490 @@ var componentFixtures = {
|
|
|
777
805
|
Modal: buildModal,
|
|
778
806
|
Card: buildCard
|
|
779
807
|
};
|
|
808
|
+
|
|
809
|
+
// src/semantics/types.ts
|
|
810
|
+
var dialect = {
|
|
811
|
+
storybook8: {
|
|
812
|
+
"rsc.render_started": "storybook.play.start",
|
|
813
|
+
"rsc.suspense_boundary": "storybook.suspense.fallback",
|
|
814
|
+
"rsc.html_chunk_streamed": "storybook.stream.chunk",
|
|
815
|
+
"rsc.render_completed": "storybook.play.done",
|
|
816
|
+
"ssr.suspense_pending": "storybook.suspense.pending",
|
|
817
|
+
"ssr.error_boundary_captured": "storybook.error.boundary",
|
|
818
|
+
"ssr.progressive_hydration_started": "storybook.hydration.progressive",
|
|
819
|
+
"ssr.selective_hydration_completed": "storybook.hydration.selective",
|
|
820
|
+
"transition.element_started": "storybook.transition.element.start",
|
|
821
|
+
"transition.element_finished": "storybook.transition.element.finish",
|
|
822
|
+
"transition.document_started": "storybook.transition.document.start",
|
|
823
|
+
"transition.animation_asserted": "storybook.animation.assert",
|
|
824
|
+
"form.status_pending": "storybook.form.pending",
|
|
825
|
+
"form.optimistic_applied": "storybook.form.optimistic",
|
|
826
|
+
"form.progressive_enhanced": "storybook.form.enhanced",
|
|
827
|
+
"form.action_resolved": "storybook.form.resolved"
|
|
828
|
+
},
|
|
829
|
+
"playwright-ct": {
|
|
830
|
+
"rsc.render_started": "pwct.mount.rsc.start",
|
|
831
|
+
"rsc.suspense_boundary": "pwct.locator.suspense.fallback",
|
|
832
|
+
"rsc.html_chunk_streamed": "pwct.response.chunk",
|
|
833
|
+
"rsc.render_completed": "pwct.mount.rsc.done",
|
|
834
|
+
"ssr.suspense_pending": "pwct.suspense.pending",
|
|
835
|
+
"ssr.error_boundary_captured": "pwct.error.boundary",
|
|
836
|
+
"ssr.progressive_hydration_started": "pwct.hydration.progressive",
|
|
837
|
+
"ssr.selective_hydration_completed": "pwct.hydration.selective",
|
|
838
|
+
"transition.element_started": "pwct.transition.element.start",
|
|
839
|
+
"transition.element_finished": "pwct.transition.element.finish",
|
|
840
|
+
"transition.document_started": "pwct.transition.document.start",
|
|
841
|
+
"transition.animation_asserted": "pwct.animation.assert",
|
|
842
|
+
"form.status_pending": "pwct.form.pending",
|
|
843
|
+
"form.optimistic_applied": "pwct.form.optimistic",
|
|
844
|
+
"form.progressive_enhanced": "pwct.form.enhanced",
|
|
845
|
+
"form.action_resolved": "pwct.form.resolved"
|
|
846
|
+
},
|
|
847
|
+
chromatic: {
|
|
848
|
+
"rsc.render_started": "chromatic.capture.rsc.start",
|
|
849
|
+
"rsc.suspense_boundary": "chromatic.capture.suspense",
|
|
850
|
+
"rsc.html_chunk_streamed": "chromatic.capture.chunk",
|
|
851
|
+
"rsc.render_completed": "chromatic.capture.rsc.done",
|
|
852
|
+
"ssr.suspense_pending": "chromatic.suspense.pending",
|
|
853
|
+
"ssr.error_boundary_captured": "chromatic.error.snapshot",
|
|
854
|
+
"ssr.progressive_hydration_started": "chromatic.hydration.progressive",
|
|
855
|
+
"ssr.selective_hydration_completed": "chromatic.hydration.selective",
|
|
856
|
+
"transition.element_started": "chromatic.transition.element.start",
|
|
857
|
+
"transition.element_finished": "chromatic.transition.element.finish",
|
|
858
|
+
"transition.document_started": "chromatic.transition.document.start",
|
|
859
|
+
"transition.animation_asserted": "chromatic.animation.assert",
|
|
860
|
+
"form.status_pending": "chromatic.form.pending",
|
|
861
|
+
"form.optimistic_applied": "chromatic.form.optimistic",
|
|
862
|
+
"form.progressive_enhanced": "chromatic.form.enhanced",
|
|
863
|
+
"form.action_resolved": "chromatic.form.resolved"
|
|
864
|
+
}
|
|
865
|
+
};
|
|
866
|
+
function providerEventName(target, neutral) {
|
|
867
|
+
return dialect[target][neutral] ?? neutral;
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
// src/semantics/rsc-harness.ts
|
|
871
|
+
function startRscHarness(input) {
|
|
872
|
+
if (input.componentId.length === 0) {
|
|
873
|
+
throw new Error("startRscHarness: componentId must not be empty");
|
|
874
|
+
}
|
|
875
|
+
return {
|
|
876
|
+
target: input.target,
|
|
877
|
+
componentId: input.componentId,
|
|
878
|
+
state: "idle",
|
|
879
|
+
chunks: [],
|
|
880
|
+
suspenseFallback: input.suspenseFallback ?? null,
|
|
881
|
+
history: [],
|
|
882
|
+
error: null
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
function beginRscRender(session) {
|
|
886
|
+
if (session.state !== "idle") {
|
|
887
|
+
throw new Error(`beginRscRender: session is ${session.state}, not idle`);
|
|
888
|
+
}
|
|
889
|
+
session.state = "rendering";
|
|
890
|
+
return emit(session, "rsc.render_started", { componentId: session.componentId });
|
|
891
|
+
}
|
|
892
|
+
function enterSuspenseBoundary(session, fallback = session.suspenseFallback ?? '<template data-suspense="pending"></template>') {
|
|
893
|
+
if (session.state !== "rendering") {
|
|
894
|
+
throw new Error(`enterSuspenseBoundary: session is ${session.state}, not rendering`);
|
|
895
|
+
}
|
|
896
|
+
session.state = "suspended";
|
|
897
|
+
session.suspenseFallback = fallback;
|
|
898
|
+
return emit(session, "rsc.suspense_boundary", { fallback });
|
|
899
|
+
}
|
|
900
|
+
function streamHtmlChunk(session, chunk) {
|
|
901
|
+
if (session.state !== "rendering" && session.state !== "suspended" && session.state !== "streaming") {
|
|
902
|
+
throw new Error(`streamHtmlChunk: session is ${session.state}, cannot stream`);
|
|
903
|
+
}
|
|
904
|
+
if (chunk.length === 0) {
|
|
905
|
+
throw new Error("streamHtmlChunk: chunk must not be empty");
|
|
906
|
+
}
|
|
907
|
+
session.state = "streaming";
|
|
908
|
+
session.chunks.push(chunk);
|
|
909
|
+
return emit(session, "rsc.html_chunk_streamed", {
|
|
910
|
+
chunk,
|
|
911
|
+
chunkIndex: session.chunks.length - 1,
|
|
912
|
+
bytes: chunk.length
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
function completeRscRender(session) {
|
|
916
|
+
if (session.state !== "rendering" && session.state !== "suspended" && session.state !== "streaming") {
|
|
917
|
+
throw new Error(`completeRscRender: session is ${session.state}, cannot complete`);
|
|
918
|
+
}
|
|
919
|
+
session.state = "completed";
|
|
920
|
+
return emit(session, "rsc.render_completed", {
|
|
921
|
+
chunkCount: session.chunks.length,
|
|
922
|
+
html: session.chunks.join("")
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
function failRscRender(session, error) {
|
|
926
|
+
if (session.state === "completed") {
|
|
927
|
+
throw new Error("failRscRender: completed session cannot fail");
|
|
928
|
+
}
|
|
929
|
+
session.state = "errored";
|
|
930
|
+
session.error = typeof error === "string" ? error : error.message;
|
|
931
|
+
return emit(session, "ssr.error_boundary_captured", {
|
|
932
|
+
componentId: session.componentId,
|
|
933
|
+
error: session.error
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
function emit(session, neutralEvent, metadata) {
|
|
937
|
+
const step = {
|
|
938
|
+
neutralEvent,
|
|
939
|
+
providerEvent: providerEventName(session.target, neutralEvent),
|
|
940
|
+
state: session.state,
|
|
941
|
+
amountCents: 0,
|
|
942
|
+
metadata: { target: session.target, ...metadata }
|
|
943
|
+
};
|
|
944
|
+
session.history.push(step);
|
|
945
|
+
return step;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
// src/semantics/streaming-ssr.ts
|
|
949
|
+
function startStreamingSsr(input) {
|
|
950
|
+
if (input.routeId.length === 0) {
|
|
951
|
+
throw new Error("startStreamingSsr: routeId must not be empty");
|
|
952
|
+
}
|
|
953
|
+
return {
|
|
954
|
+
target: input.target,
|
|
955
|
+
routeId: input.routeId,
|
|
956
|
+
state: "idle",
|
|
957
|
+
pendingBoundaries: /* @__PURE__ */ new Set(),
|
|
958
|
+
hydratedBoundaries: /* @__PURE__ */ new Set(),
|
|
959
|
+
errors: [],
|
|
960
|
+
history: []
|
|
961
|
+
};
|
|
962
|
+
}
|
|
963
|
+
function markSuspensePending(session, boundaryId) {
|
|
964
|
+
assertBoundaryId(boundaryId);
|
|
965
|
+
session.state = "suspense-pending";
|
|
966
|
+
session.pendingBoundaries.add(boundaryId);
|
|
967
|
+
return emit2(session, "ssr.suspense_pending", { boundaryId, pendingCount: session.pendingBoundaries.size });
|
|
968
|
+
}
|
|
969
|
+
function captureErrorBoundary(session, input) {
|
|
970
|
+
assertBoundaryId(input.boundaryId);
|
|
971
|
+
const message = typeof input.error === "string" ? input.error : input.error.message;
|
|
972
|
+
session.state = "error-captured";
|
|
973
|
+
session.errors.push({ boundaryId: input.boundaryId, message });
|
|
974
|
+
if (input.recoverable === false) {
|
|
975
|
+
session.pendingBoundaries.delete(input.boundaryId);
|
|
976
|
+
}
|
|
977
|
+
return emit2(session, "ssr.error_boundary_captured", {
|
|
978
|
+
boundaryId: input.boundaryId,
|
|
979
|
+
message,
|
|
980
|
+
recoverable: input.recoverable ?? true
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
function startProgressiveHydration(session, boundaryId) {
|
|
984
|
+
assertBoundaryId(boundaryId);
|
|
985
|
+
if (!session.pendingBoundaries.has(boundaryId)) {
|
|
986
|
+
throw new Error(`startProgressiveHydration: ${boundaryId} is not pending`);
|
|
987
|
+
}
|
|
988
|
+
session.state = "progressive-hydrating";
|
|
989
|
+
return emit2(session, "ssr.progressive_hydration_started", { boundaryId });
|
|
990
|
+
}
|
|
991
|
+
function completeSelectiveHydration(session, boundaryId) {
|
|
992
|
+
assertBoundaryId(boundaryId);
|
|
993
|
+
if (!session.pendingBoundaries.has(boundaryId)) {
|
|
994
|
+
throw new Error(`completeSelectiveHydration: ${boundaryId} is not pending`);
|
|
995
|
+
}
|
|
996
|
+
session.pendingBoundaries.delete(boundaryId);
|
|
997
|
+
session.hydratedBoundaries.add(boundaryId);
|
|
998
|
+
session.state = "selective-hydrated";
|
|
999
|
+
return emit2(session, "ssr.selective_hydration_completed", {
|
|
1000
|
+
boundaryId,
|
|
1001
|
+
hydratedCount: session.hydratedBoundaries.size,
|
|
1002
|
+
remainingPending: session.pendingBoundaries.size
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
1005
|
+
function assertBoundaryId(boundaryId) {
|
|
1006
|
+
if (boundaryId.length === 0) {
|
|
1007
|
+
throw new Error("boundaryId must not be empty");
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
function emit2(session, neutralEvent, metadata) {
|
|
1011
|
+
const step = {
|
|
1012
|
+
neutralEvent,
|
|
1013
|
+
providerEvent: providerEventName(session.target, neutralEvent),
|
|
1014
|
+
state: session.state,
|
|
1015
|
+
amountCents: 0,
|
|
1016
|
+
metadata: { target: session.target, routeId: session.routeId, ...metadata }
|
|
1017
|
+
};
|
|
1018
|
+
session.history.push(step);
|
|
1019
|
+
return step;
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
// src/semantics/view-transitions.ts
|
|
1023
|
+
function startViewTransitionSession(input) {
|
|
1024
|
+
if (input.transitionId.length === 0) {
|
|
1025
|
+
throw new Error("startViewTransitionSession: transitionId must not be empty");
|
|
1026
|
+
}
|
|
1027
|
+
return {
|
|
1028
|
+
target: input.target,
|
|
1029
|
+
transitionId: input.transitionId,
|
|
1030
|
+
state: "idle",
|
|
1031
|
+
activeElements: /* @__PURE__ */ new Set(),
|
|
1032
|
+
documentTransition: null,
|
|
1033
|
+
assertions: [],
|
|
1034
|
+
history: []
|
|
1035
|
+
};
|
|
1036
|
+
}
|
|
1037
|
+
function startElementTransition(session, input) {
|
|
1038
|
+
if (input.elementId.length === 0) {
|
|
1039
|
+
throw new Error("startElementTransition: elementId must not be empty");
|
|
1040
|
+
}
|
|
1041
|
+
session.state = "element-transitioning";
|
|
1042
|
+
session.activeElements.add(input.elementId);
|
|
1043
|
+
return emit3(session, "transition.element_started", input);
|
|
1044
|
+
}
|
|
1045
|
+
function finishElementTransition(session, elementId) {
|
|
1046
|
+
if (!session.activeElements.has(elementId)) {
|
|
1047
|
+
throw new Error(`finishElementTransition: ${elementId} is not active`);
|
|
1048
|
+
}
|
|
1049
|
+
session.activeElements.delete(elementId);
|
|
1050
|
+
session.state = session.activeElements.size === 0 ? "finished" : "element-transitioning";
|
|
1051
|
+
return emit3(session, "transition.element_finished", {
|
|
1052
|
+
elementId,
|
|
1053
|
+
remaining: session.activeElements.size
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1056
|
+
function startDocumentTransition(session, input) {
|
|
1057
|
+
if (input.name.length === 0) {
|
|
1058
|
+
throw new Error("startDocumentTransition: name must not be empty");
|
|
1059
|
+
}
|
|
1060
|
+
session.state = "document-transitioning";
|
|
1061
|
+
session.documentTransition = input.name;
|
|
1062
|
+
return emit3(session, "transition.document_started", input);
|
|
1063
|
+
}
|
|
1064
|
+
function assertAnimation(session, input) {
|
|
1065
|
+
if (input.durationMs < 0) {
|
|
1066
|
+
throw new Error("assertAnimation: durationMs must be >= 0");
|
|
1067
|
+
}
|
|
1068
|
+
session.state = "asserted";
|
|
1069
|
+
session.assertions.push(input.assertionId);
|
|
1070
|
+
return emit3(session, "transition.animation_asserted", {
|
|
1071
|
+
assertionId: input.assertionId,
|
|
1072
|
+
durationMs: input.durationMs,
|
|
1073
|
+
easing: input.easing ?? "linear"
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1076
|
+
function emit3(session, neutralEvent, metadata) {
|
|
1077
|
+
const step = {
|
|
1078
|
+
neutralEvent,
|
|
1079
|
+
providerEvent: providerEventName(session.target, neutralEvent),
|
|
1080
|
+
state: session.state,
|
|
1081
|
+
amountCents: 0,
|
|
1082
|
+
metadata: { target: session.target, transitionId: session.transitionId, ...metadata }
|
|
1083
|
+
};
|
|
1084
|
+
session.history.push(step);
|
|
1085
|
+
return step;
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
// src/semantics/form-action-advanced.ts
|
|
1089
|
+
function startFormActionSession(input) {
|
|
1090
|
+
if (input.formId.length === 0) {
|
|
1091
|
+
throw new Error("startFormActionSession: formId must not be empty");
|
|
1092
|
+
}
|
|
1093
|
+
return {
|
|
1094
|
+
target: input.target,
|
|
1095
|
+
formId: input.formId,
|
|
1096
|
+
state: "idle",
|
|
1097
|
+
form: { ...input.initial },
|
|
1098
|
+
optimisticPatches: [],
|
|
1099
|
+
enhanced: false,
|
|
1100
|
+
history: [],
|
|
1101
|
+
error: null
|
|
1102
|
+
};
|
|
1103
|
+
}
|
|
1104
|
+
function markFormStatusPending(session, submitter) {
|
|
1105
|
+
if (session.state === "pending") {
|
|
1106
|
+
throw new Error("markFormStatusPending: form is already pending");
|
|
1107
|
+
}
|
|
1108
|
+
session.state = "pending";
|
|
1109
|
+
return emit4(session, "form.status_pending", { submitter });
|
|
1110
|
+
}
|
|
1111
|
+
function applyOptimisticUpdate(session, patch) {
|
|
1112
|
+
if (session.state !== "pending" && session.state !== "optimistic") {
|
|
1113
|
+
throw new Error(`applyOptimisticUpdate: session is ${session.state}, not pending`);
|
|
1114
|
+
}
|
|
1115
|
+
session.state = "optimistic";
|
|
1116
|
+
session.optimisticPatches.push(patch);
|
|
1117
|
+
session.form = { ...session.form, ...patch };
|
|
1118
|
+
return emit4(session, "form.optimistic_applied", {
|
|
1119
|
+
patchKeys: Object.keys(patch).join(","),
|
|
1120
|
+
patchCount: session.optimisticPatches.length
|
|
1121
|
+
});
|
|
1122
|
+
}
|
|
1123
|
+
function enableProgressiveEnhancement(session, input) {
|
|
1124
|
+
if (input.actionUrl.length === 0) {
|
|
1125
|
+
throw new Error("enableProgressiveEnhancement: actionUrl must not be empty");
|
|
1126
|
+
}
|
|
1127
|
+
session.enhanced = true;
|
|
1128
|
+
session.state = "enhanced";
|
|
1129
|
+
return emit4(session, "form.progressive_enhanced", {
|
|
1130
|
+
method: input.method ?? "post",
|
|
1131
|
+
actionUrl: input.actionUrl
|
|
1132
|
+
});
|
|
1133
|
+
}
|
|
1134
|
+
function resolveFormAction(session, result) {
|
|
1135
|
+
if (session.state === "idle") {
|
|
1136
|
+
throw new Error("resolveFormAction: action was not submitted");
|
|
1137
|
+
}
|
|
1138
|
+
session.state = "resolved";
|
|
1139
|
+
session.form = { ...session.form, ...result };
|
|
1140
|
+
return emit4(session, "form.action_resolved", {
|
|
1141
|
+
resultKeys: Object.keys(result).join(","),
|
|
1142
|
+
enhanced: session.enhanced
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
function rejectFormAction(session, error) {
|
|
1146
|
+
if (session.state === "resolved") {
|
|
1147
|
+
throw new Error("rejectFormAction: resolved action cannot reject");
|
|
1148
|
+
}
|
|
1149
|
+
session.state = "rejected";
|
|
1150
|
+
session.error = typeof error === "string" ? error : error.message;
|
|
1151
|
+
return emit4(session, "form.action_resolved", {
|
|
1152
|
+
rejected: true,
|
|
1153
|
+
error: session.error
|
|
1154
|
+
});
|
|
1155
|
+
}
|
|
1156
|
+
function emit4(session, neutralEvent, metadata) {
|
|
1157
|
+
const step = {
|
|
1158
|
+
neutralEvent,
|
|
1159
|
+
providerEvent: providerEventName(session.target, neutralEvent),
|
|
1160
|
+
state: session.state,
|
|
1161
|
+
amountCents: 0,
|
|
1162
|
+
metadata: { target: session.target, formId: session.formId, ...metadata }
|
|
1163
|
+
};
|
|
1164
|
+
session.history.push(step);
|
|
1165
|
+
return step;
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
// src/semantics/fidelity.ts
|
|
1169
|
+
var COMPONENT_AXIS_TO_EVENTS = {
|
|
1170
|
+
"rsc-harness": [
|
|
1171
|
+
"rsc.render_started",
|
|
1172
|
+
"rsc.suspense_boundary",
|
|
1173
|
+
"rsc.html_chunk_streamed",
|
|
1174
|
+
"rsc.render_completed"
|
|
1175
|
+
],
|
|
1176
|
+
"streaming-ssr": [
|
|
1177
|
+
"ssr.suspense_pending",
|
|
1178
|
+
"ssr.error_boundary_captured",
|
|
1179
|
+
"ssr.progressive_hydration_started",
|
|
1180
|
+
"ssr.selective_hydration_completed"
|
|
1181
|
+
],
|
|
1182
|
+
"view-transitions": [
|
|
1183
|
+
"transition.element_started",
|
|
1184
|
+
"transition.element_finished",
|
|
1185
|
+
"transition.document_started",
|
|
1186
|
+
"transition.animation_asserted"
|
|
1187
|
+
],
|
|
1188
|
+
"form-action-advanced": [
|
|
1189
|
+
"form.status_pending",
|
|
1190
|
+
"form.optimistic_applied",
|
|
1191
|
+
"form.progressive_enhanced",
|
|
1192
|
+
"form.action_resolved"
|
|
1193
|
+
]
|
|
1194
|
+
};
|
|
1195
|
+
function collectFidelityCoverage(providers = ["storybook8", "playwright-ct", "chromatic"]) {
|
|
1196
|
+
const axes = Object.keys(COMPONENT_AXIS_TO_EVENTS);
|
|
1197
|
+
const rows = [];
|
|
1198
|
+
for (const provider of providers) {
|
|
1199
|
+
for (const axis of axes) {
|
|
1200
|
+
const neutralEvents = COMPONENT_AXIS_TO_EVENTS[axis];
|
|
1201
|
+
rows.push({
|
|
1202
|
+
provider,
|
|
1203
|
+
axis,
|
|
1204
|
+
neutralEvents,
|
|
1205
|
+
providerEvents: neutralEvents.map((event) => providerEventName(provider, event))
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
return { providers, axes, rows };
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
// src/real-driver.ts
|
|
1213
|
+
var TARGET_KEY_ENV = {
|
|
1214
|
+
storybook8: "STORYBOOK_URL",
|
|
1215
|
+
"playwright-ct": "PLAYWRIGHT_CT_URL",
|
|
1216
|
+
chromatic: "CHROMATIC_TOKEN"
|
|
1217
|
+
};
|
|
1218
|
+
function resolveMode(provider, env = process.env) {
|
|
1219
|
+
const rawMode = env.KIWA_MODE?.toLowerCase();
|
|
1220
|
+
if (rawMode !== void 0 && rawMode !== "real" && rawMode !== "mock") {
|
|
1221
|
+
return { provider, mode: "mock", reason: "invalid-mode" };
|
|
1222
|
+
}
|
|
1223
|
+
if (rawMode !== "real") {
|
|
1224
|
+
return { provider, mode: "mock", reason: "default-mock" };
|
|
1225
|
+
}
|
|
1226
|
+
const keyValue = env[TARGET_KEY_ENV[provider]];
|
|
1227
|
+
if (typeof keyValue !== "string" || keyValue.length === 0) {
|
|
1228
|
+
return { provider, mode: "mock", reason: "missing-key" };
|
|
1229
|
+
}
|
|
1230
|
+
return { provider, mode: "real", reason: "kiwa-mode-real" };
|
|
1231
|
+
}
|
|
1232
|
+
function resolveAllModes(env = process.env) {
|
|
1233
|
+
const providers = ["storybook8", "playwright-ct", "chromatic"];
|
|
1234
|
+
return providers.map((provider) => resolveMode(provider, env));
|
|
1235
|
+
}
|
|
1236
|
+
function assertMode(provider, expected, env = process.env) {
|
|
1237
|
+
const resolved = resolveMode(provider, env);
|
|
1238
|
+
if (resolved.mode !== expected) {
|
|
1239
|
+
throw new Error(
|
|
1240
|
+
`expected ${provider} in ${expected} mode but resolved ${resolved.mode} (${resolved.reason})`
|
|
1241
|
+
);
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
780
1244
|
// Annotate the CommonJS export names for ESM import in node:
|
|
781
1245
|
0 && (module.exports = {
|
|
1246
|
+
COMPONENT_AXIS_TO_EVENTS,
|
|
782
1247
|
addHandler,
|
|
783
1248
|
appendChild,
|
|
1249
|
+
applyOptimisticUpdate,
|
|
1250
|
+
assertAnimation,
|
|
1251
|
+
assertMode,
|
|
1252
|
+
beginRscRender,
|
|
784
1253
|
buildButton,
|
|
785
1254
|
buildCard,
|
|
786
1255
|
buildForm,
|
|
787
1256
|
buildInput,
|
|
788
1257
|
buildModal,
|
|
1258
|
+
captureErrorBoundary,
|
|
1259
|
+
collectFidelityCoverage,
|
|
1260
|
+
completeRscRender,
|
|
1261
|
+
completeSelectiveHydration,
|
|
789
1262
|
componentFixtures,
|
|
790
1263
|
createCanvas,
|
|
791
1264
|
createChromaticVisualMock,
|
|
792
1265
|
createNode,
|
|
793
1266
|
createPlaywrightCTMock,
|
|
794
1267
|
createStoryRegistry,
|
|
1268
|
+
enableProgressiveEnhancement,
|
|
1269
|
+
enterSuspenseBoundary,
|
|
1270
|
+
failRscRender,
|
|
795
1271
|
findByRole,
|
|
796
1272
|
findByText,
|
|
1273
|
+
finishElementTransition,
|
|
797
1274
|
fireEvent,
|
|
798
1275
|
hashMarkup,
|
|
1276
|
+
markFormStatusPending,
|
|
1277
|
+
markSuspensePending,
|
|
1278
|
+
providerEventName,
|
|
799
1279
|
query,
|
|
800
|
-
|
|
1280
|
+
rejectFormAction,
|
|
1281
|
+
renderMarkup,
|
|
1282
|
+
resolveAllModes,
|
|
1283
|
+
resolveFormAction,
|
|
1284
|
+
resolveMode,
|
|
1285
|
+
startDocumentTransition,
|
|
1286
|
+
startElementTransition,
|
|
1287
|
+
startFormActionSession,
|
|
1288
|
+
startProgressiveHydration,
|
|
1289
|
+
startRscHarness,
|
|
1290
|
+
startStreamingSsr,
|
|
1291
|
+
startViewTransitionSession,
|
|
1292
|
+
streamHtmlChunk
|
|
801
1293
|
});
|
|
802
1294
|
//# sourceMappingURL=index.cjs.map
|