@kiwa-test/component 0.3.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.cjs +172 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +55 -4
- package/dist/index.d.ts +55 -4
- package/dist/index.js +163 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -24,9 +24,14 @@ __export(index_exports, {
|
|
|
24
24
|
addHandler: () => addHandler,
|
|
25
25
|
appendChild: () => appendChild,
|
|
26
26
|
applyOptimisticUpdate: () => applyOptimisticUpdate,
|
|
27
|
+
applyReactActionOptimistic: () => applyOptimisticUpdate2,
|
|
27
28
|
assertAnimation: () => assertAnimation,
|
|
28
29
|
assertMode: () => assertMode,
|
|
30
|
+
assertStaticBoundary: () => assertStaticBoundary,
|
|
31
|
+
beginActionTransition: () => beginActionTransition,
|
|
32
|
+
beginIslandHydration: () => beginIslandHydration,
|
|
29
33
|
beginRscRender: () => beginRscRender,
|
|
34
|
+
bootstrapIslandsRoute: () => bootstrapIslandsRoute,
|
|
30
35
|
buildButton: () => buildButton,
|
|
31
36
|
buildCard: () => buildCard,
|
|
32
37
|
buildForm: () => buildForm,
|
|
@@ -50,12 +55,16 @@ __export(index_exports, {
|
|
|
50
55
|
finishElementTransition: () => finishElementTransition,
|
|
51
56
|
fireEvent: () => fireEvent,
|
|
52
57
|
hashMarkup: () => hashMarkup,
|
|
58
|
+
initializeReactActions: () => initializeReactActions,
|
|
53
59
|
markFormStatusPending: () => markFormStatusPending,
|
|
60
|
+
markIslandInteractive: () => markIslandInteractive,
|
|
54
61
|
markSuspensePending: () => markSuspensePending,
|
|
55
62
|
providerEventName: () => providerEventName,
|
|
56
63
|
query: () => query,
|
|
64
|
+
registerIsland: () => registerIsland,
|
|
57
65
|
rejectFormAction: () => rejectFormAction,
|
|
58
66
|
renderMarkup: () => renderMarkup,
|
|
67
|
+
resolveAction: () => resolveAction,
|
|
59
68
|
resolveAllModes: () => resolveAllModes,
|
|
60
69
|
resolveFormAction: () => resolveFormAction,
|
|
61
70
|
resolveMode: () => resolveMode,
|
|
@@ -1190,6 +1199,19 @@ var COMPONENT_AXIS_TO_EVENTS = {
|
|
|
1190
1199
|
"form.optimistic_applied",
|
|
1191
1200
|
"form.progressive_enhanced",
|
|
1192
1201
|
"form.action_resolved"
|
|
1202
|
+
],
|
|
1203
|
+
// v1.49 advanced III
|
|
1204
|
+
"react-19-actions": [
|
|
1205
|
+
"action.state_initialized",
|
|
1206
|
+
"action.transition_pending",
|
|
1207
|
+
"action.optimistic_committed",
|
|
1208
|
+
"action.resolved"
|
|
1209
|
+
],
|
|
1210
|
+
"islands-architecture": [
|
|
1211
|
+
"islands.registered",
|
|
1212
|
+
"islands.hydration_started",
|
|
1213
|
+
"islands.interactive_ready",
|
|
1214
|
+
"islands.static_boundary_asserted"
|
|
1193
1215
|
]
|
|
1194
1216
|
};
|
|
1195
1217
|
function collectFidelityCoverage(providers = ["storybook8", "playwright-ct", "chromatic"]) {
|
|
@@ -1209,6 +1231,147 @@ function collectFidelityCoverage(providers = ["storybook8", "playwright-ct", "ch
|
|
|
1209
1231
|
return { providers, axes, rows };
|
|
1210
1232
|
}
|
|
1211
1233
|
|
|
1234
|
+
// src/semantics/react-19-actions.ts
|
|
1235
|
+
function emit5(session, neutralEvent, metadata) {
|
|
1236
|
+
const step = {
|
|
1237
|
+
neutralEvent,
|
|
1238
|
+
providerEvent: providerEventName(session.target, neutralEvent),
|
|
1239
|
+
state: session.state,
|
|
1240
|
+
amountCents: 0,
|
|
1241
|
+
metadata: { actionId: session.actionId, ...metadata }
|
|
1242
|
+
};
|
|
1243
|
+
session.history.push(step);
|
|
1244
|
+
return step;
|
|
1245
|
+
}
|
|
1246
|
+
function initializeReactActions(input) {
|
|
1247
|
+
if (input.actionId.length === 0) {
|
|
1248
|
+
throw new Error("initializeReactActions: actionId must not be empty");
|
|
1249
|
+
}
|
|
1250
|
+
const session = {
|
|
1251
|
+
target: input.target,
|
|
1252
|
+
actionId: input.actionId,
|
|
1253
|
+
state: "idle",
|
|
1254
|
+
pendingCount: 0,
|
|
1255
|
+
optimisticValues: [],
|
|
1256
|
+
resolvedValue: null,
|
|
1257
|
+
history: []
|
|
1258
|
+
};
|
|
1259
|
+
emit5(session, "action.state_initialized", { pendingCount: 0 });
|
|
1260
|
+
return session;
|
|
1261
|
+
}
|
|
1262
|
+
function beginActionTransition(session) {
|
|
1263
|
+
if (session.state !== "idle" && session.state !== "resolved") {
|
|
1264
|
+
throw new Error(`beginActionTransition: session is ${session.state}`);
|
|
1265
|
+
}
|
|
1266
|
+
session.state = "transition-pending";
|
|
1267
|
+
session.pendingCount += 1;
|
|
1268
|
+
return emit5(session, "action.transition_pending", {
|
|
1269
|
+
pendingCount: session.pendingCount
|
|
1270
|
+
});
|
|
1271
|
+
}
|
|
1272
|
+
function applyOptimisticUpdate2(session, optimisticValue) {
|
|
1273
|
+
if (session.state !== "transition-pending") {
|
|
1274
|
+
throw new Error(`applyOptimisticUpdate: session is ${session.state}`);
|
|
1275
|
+
}
|
|
1276
|
+
session.state = "optimistic-committed";
|
|
1277
|
+
session.optimisticValues.push(optimisticValue);
|
|
1278
|
+
return emit5(session, "action.optimistic_committed", { optimisticValue });
|
|
1279
|
+
}
|
|
1280
|
+
function resolveAction(session, resolvedValue) {
|
|
1281
|
+
if (session.state !== "transition-pending" && session.state !== "optimistic-committed") {
|
|
1282
|
+
throw new Error(`resolveAction: session is ${session.state}`);
|
|
1283
|
+
}
|
|
1284
|
+
session.state = "resolved";
|
|
1285
|
+
session.resolvedValue = resolvedValue;
|
|
1286
|
+
session.pendingCount = Math.max(0, session.pendingCount - 1);
|
|
1287
|
+
return emit5(session, "action.resolved", {
|
|
1288
|
+
resolvedValue,
|
|
1289
|
+
pendingCount: session.pendingCount,
|
|
1290
|
+
optimisticCount: session.optimisticValues.length
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
// src/semantics/islands-architecture.ts
|
|
1295
|
+
function emit6(session, neutralEvent, metadata) {
|
|
1296
|
+
const step = {
|
|
1297
|
+
neutralEvent,
|
|
1298
|
+
providerEvent: providerEventName(session.target, neutralEvent),
|
|
1299
|
+
state: session.state,
|
|
1300
|
+
amountCents: 0,
|
|
1301
|
+
metadata: { routeId: session.routeId, ...metadata }
|
|
1302
|
+
};
|
|
1303
|
+
session.history.push(step);
|
|
1304
|
+
return step;
|
|
1305
|
+
}
|
|
1306
|
+
function bootstrapIslandsRoute(input) {
|
|
1307
|
+
if (input.routeId.length === 0) {
|
|
1308
|
+
throw new Error("bootstrapIslandsRoute: routeId must not be empty");
|
|
1309
|
+
}
|
|
1310
|
+
return {
|
|
1311
|
+
target: input.target,
|
|
1312
|
+
routeId: input.routeId,
|
|
1313
|
+
islands: [],
|
|
1314
|
+
state: "idle",
|
|
1315
|
+
hydratedIslandIds: [],
|
|
1316
|
+
staticBoundaryIds: [],
|
|
1317
|
+
history: []
|
|
1318
|
+
};
|
|
1319
|
+
}
|
|
1320
|
+
function registerIsland(session, island) {
|
|
1321
|
+
session.islands.push(island);
|
|
1322
|
+
session.state = "registered";
|
|
1323
|
+
return emit6(session, "islands.registered", {
|
|
1324
|
+
islandId: island.islandId,
|
|
1325
|
+
loadStrategy: island.loadStrategy,
|
|
1326
|
+
interactiveBoundary: island.interactiveBoundary
|
|
1327
|
+
});
|
|
1328
|
+
}
|
|
1329
|
+
function beginIslandHydration(session, islandId) {
|
|
1330
|
+
const island = session.islands.find((i) => i.islandId === islandId);
|
|
1331
|
+
if (!island) {
|
|
1332
|
+
throw new Error(`beginIslandHydration: island ${islandId} not registered`);
|
|
1333
|
+
}
|
|
1334
|
+
if (session.state !== "registered" && session.state !== "hydrating") {
|
|
1335
|
+
throw new Error(`beginIslandHydration: session is ${session.state}`);
|
|
1336
|
+
}
|
|
1337
|
+
session.state = "hydrating";
|
|
1338
|
+
return emit6(session, "islands.hydration_started", {
|
|
1339
|
+
islandId,
|
|
1340
|
+
loadStrategy: island.loadStrategy
|
|
1341
|
+
});
|
|
1342
|
+
}
|
|
1343
|
+
function markIslandInteractive(session, islandId) {
|
|
1344
|
+
if (session.state !== "hydrating") {
|
|
1345
|
+
throw new Error(`markIslandInteractive: session is ${session.state}`);
|
|
1346
|
+
}
|
|
1347
|
+
if (session.hydratedIslandIds.includes(islandId)) {
|
|
1348
|
+
throw new Error(`markIslandInteractive: island ${islandId} already interactive`);
|
|
1349
|
+
}
|
|
1350
|
+
session.hydratedIslandIds.push(islandId);
|
|
1351
|
+
const allHydrated = session.hydratedIslandIds.length === session.islands.filter((i) => i.interactiveBoundary).length;
|
|
1352
|
+
if (allHydrated) {
|
|
1353
|
+
session.state = "interactive";
|
|
1354
|
+
}
|
|
1355
|
+
return emit6(session, "islands.interactive_ready", {
|
|
1356
|
+
islandId,
|
|
1357
|
+
hydratedCount: session.hydratedIslandIds.length,
|
|
1358
|
+
allInteractiveReady: allHydrated
|
|
1359
|
+
});
|
|
1360
|
+
}
|
|
1361
|
+
function assertStaticBoundary(session, boundaryId) {
|
|
1362
|
+
if (session.staticBoundaryIds.includes(boundaryId)) {
|
|
1363
|
+
throw new Error(`assertStaticBoundary: boundary ${boundaryId} already asserted`);
|
|
1364
|
+
}
|
|
1365
|
+
session.staticBoundaryIds.push(boundaryId);
|
|
1366
|
+
if (session.state === "interactive") {
|
|
1367
|
+
session.state = "static-verified";
|
|
1368
|
+
}
|
|
1369
|
+
return emit6(session, "islands.static_boundary_asserted", {
|
|
1370
|
+
boundaryId,
|
|
1371
|
+
staticBoundaryCount: session.staticBoundaryIds.length
|
|
1372
|
+
});
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1212
1375
|
// src/real-driver.ts
|
|
1213
1376
|
var TARGET_KEY_ENV = {
|
|
1214
1377
|
storybook8: "STORYBOOK_URL",
|
|
@@ -1247,9 +1410,14 @@ function assertMode(provider, expected, env = process.env) {
|
|
|
1247
1410
|
addHandler,
|
|
1248
1411
|
appendChild,
|
|
1249
1412
|
applyOptimisticUpdate,
|
|
1413
|
+
applyReactActionOptimistic,
|
|
1250
1414
|
assertAnimation,
|
|
1251
1415
|
assertMode,
|
|
1416
|
+
assertStaticBoundary,
|
|
1417
|
+
beginActionTransition,
|
|
1418
|
+
beginIslandHydration,
|
|
1252
1419
|
beginRscRender,
|
|
1420
|
+
bootstrapIslandsRoute,
|
|
1253
1421
|
buildButton,
|
|
1254
1422
|
buildCard,
|
|
1255
1423
|
buildForm,
|
|
@@ -1273,12 +1441,16 @@ function assertMode(provider, expected, env = process.env) {
|
|
|
1273
1441
|
finishElementTransition,
|
|
1274
1442
|
fireEvent,
|
|
1275
1443
|
hashMarkup,
|
|
1444
|
+
initializeReactActions,
|
|
1276
1445
|
markFormStatusPending,
|
|
1446
|
+
markIslandInteractive,
|
|
1277
1447
|
markSuspensePending,
|
|
1278
1448
|
providerEventName,
|
|
1279
1449
|
query,
|
|
1450
|
+
registerIsland,
|
|
1280
1451
|
rejectFormAction,
|
|
1281
1452
|
renderMarkup,
|
|
1453
|
+
resolveAction,
|
|
1282
1454
|
resolveAllModes,
|
|
1283
1455
|
resolveFormAction,
|
|
1284
1456
|
resolveMode,
|