@kosdev-code/kos-ui-sdk 0.1.0-next.851 → 0.1.0-next.853
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/core/core/transport/mock/mock-recorder.d.ts +7 -0
- package/core/core/transport/mock/mock-recorder.d.ts.map +1 -1
- package/core/core/transport/mock/mock-types.d.ts +26 -0
- package/core/core/transport/mock/mock-types.d.ts.map +1 -1
- package/core/util/kos-config-init.d.ts.map +1 -1
- package/index.cjs +50 -7
- package/index.cjs.map +1 -1
- package/index.js +50 -7
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/ui/hooks/use-kos-model.d.ts +8 -0
- package/ui/hooks/use-kos-model.d.ts.map +1 -1
package/index.js
CHANGED
|
@@ -766,6 +766,17 @@ const defaultConfig = {
|
|
|
766
766
|
};
|
|
767
767
|
const config = globalThis.getKosConfig?.() || JSON.stringify(defaultConfig);
|
|
768
768
|
const configObj = JSON.parse(config);
|
|
769
|
+
const urlProfiles = () => {
|
|
770
|
+
if (typeof window === "undefined") {
|
|
771
|
+
return [];
|
|
772
|
+
}
|
|
773
|
+
const value = getQueryParams()?.["kosProfiles"];
|
|
774
|
+
return value ? value.split(",").map((profile) => profile.trim()).filter(Boolean) : [];
|
|
775
|
+
};
|
|
776
|
+
configObj.profiles = [
|
|
777
|
+
...configObj.profiles ?? [],
|
|
778
|
+
...urlProfiles().filter((profile) => !configObj.profiles?.includes(profile))
|
|
779
|
+
];
|
|
769
780
|
globalThis.kosConfig = configObj;
|
|
770
781
|
const KosGlobalConfig = configObj;
|
|
771
782
|
const resolveKosProfiles = () => KosGlobalConfig.profiles || [];
|
|
@@ -8375,6 +8386,7 @@ class KosMockRecorder {
|
|
|
8375
8386
|
pending = /* @__PURE__ */ new Map();
|
|
8376
8387
|
exchanges = [];
|
|
8377
8388
|
pushes = [];
|
|
8389
|
+
sends = [];
|
|
8378
8390
|
get isRecording() {
|
|
8379
8391
|
return this.recording;
|
|
8380
8392
|
}
|
|
@@ -8386,6 +8398,7 @@ class KosMockRecorder {
|
|
|
8386
8398
|
this.pending.clear();
|
|
8387
8399
|
this.exchanges = [];
|
|
8388
8400
|
this.pushes = [];
|
|
8401
|
+
this.sends = [];
|
|
8389
8402
|
KosLog.info(
|
|
8390
8403
|
`KosMock recorder started${options.name ? ` (${options.name})` : ""}`
|
|
8391
8404
|
);
|
|
@@ -8394,7 +8407,7 @@ class KosMockRecorder {
|
|
|
8394
8407
|
const fixture = this.toFixture();
|
|
8395
8408
|
this.recording = false;
|
|
8396
8409
|
KosLog.info(
|
|
8397
|
-
`KosMock recorder stopped: ${fixture.exchanges.length} exchanges, ${fixture.pushes.length} pushes`
|
|
8410
|
+
`KosMock recorder stopped: ${fixture.exchanges.length} exchanges, ${fixture.pushes.length} pushes, ${fixture.sends?.length ?? 0} sends`
|
|
8398
8411
|
);
|
|
8399
8412
|
return fixture;
|
|
8400
8413
|
}
|
|
@@ -8404,7 +8417,8 @@ class KosMockRecorder {
|
|
|
8404
8417
|
name: this.name,
|
|
8405
8418
|
capturedAt: this.capturedAt,
|
|
8406
8419
|
exchanges: [...this.exchanges],
|
|
8407
|
-
pushes: [...this.pushes]
|
|
8420
|
+
pushes: [...this.pushes],
|
|
8421
|
+
sends: [...this.sends]
|
|
8408
8422
|
};
|
|
8409
8423
|
}
|
|
8410
8424
|
download(filename) {
|
|
@@ -8433,6 +8447,7 @@ class KosMockRecorder {
|
|
|
8433
8447
|
}
|
|
8434
8448
|
const frame = decodeRequestFrame(data);
|
|
8435
8449
|
if (!frame) {
|
|
8450
|
+
this.noteSend(data);
|
|
8436
8451
|
return;
|
|
8437
8452
|
}
|
|
8438
8453
|
this.pending.set(frame.requestId, {
|
|
@@ -8440,7 +8455,31 @@ class KosMockRecorder {
|
|
|
8440
8455
|
method: frame.method,
|
|
8441
8456
|
url: frame.url,
|
|
8442
8457
|
tracker: frame.tracker,
|
|
8443
|
-
requestBody: frame.rawBody
|
|
8458
|
+
requestBody: frame.rawBody,
|
|
8459
|
+
requestHeaders: frame.headers
|
|
8460
|
+
});
|
|
8461
|
+
}
|
|
8462
|
+
/**
|
|
8463
|
+
* Everything else a window sends: alias registration, broker subscribes,
|
|
8464
|
+
* client-sent futures. What a window asked for is not recoverable from the
|
|
8465
|
+
* responses it got back, so it is captured rather than discarded.
|
|
8466
|
+
*/
|
|
8467
|
+
noteSend(data) {
|
|
8468
|
+
if (typeof data !== "string") {
|
|
8469
|
+
return;
|
|
8470
|
+
}
|
|
8471
|
+
let headers;
|
|
8472
|
+
let body;
|
|
8473
|
+
try {
|
|
8474
|
+
({ headers, body } = processKosMessage(data));
|
|
8475
|
+
} catch {
|
|
8476
|
+
return;
|
|
8477
|
+
}
|
|
8478
|
+
this.sends.push({
|
|
8479
|
+
tMs: this.elapsed(),
|
|
8480
|
+
type: headers["type"],
|
|
8481
|
+
headers,
|
|
8482
|
+
...body ? { body } : {}
|
|
8444
8483
|
});
|
|
8445
8484
|
}
|
|
8446
8485
|
/** Interceptor tap: every inbound frame (real, mocked, injected). Internal. */
|
|
@@ -8466,6 +8505,7 @@ class KosMockRecorder {
|
|
|
8466
8505
|
...request2,
|
|
8467
8506
|
status: parseInt(headers["status"] ?? "200", 10) || 200,
|
|
8468
8507
|
responseBody: body ?? "",
|
|
8508
|
+
responseHeaders: headers,
|
|
8469
8509
|
latencyMs: Math.max(0, this.elapsed() - request2.tMs),
|
|
8470
8510
|
...headers[KOS_MOCKED_HEADER] === "true" ? { mocked: true } : {}
|
|
8471
8511
|
});
|
|
@@ -8477,7 +8517,8 @@ class KosMockRecorder {
|
|
|
8477
8517
|
tMs: this.elapsed(),
|
|
8478
8518
|
kind: "topic",
|
|
8479
8519
|
topic,
|
|
8480
|
-
body: body ?? ""
|
|
8520
|
+
body: body ?? "",
|
|
8521
|
+
headers
|
|
8481
8522
|
});
|
|
8482
8523
|
return;
|
|
8483
8524
|
}
|
|
@@ -8491,7 +8532,8 @@ class KosMockRecorder {
|
|
|
8491
8532
|
tMs: this.elapsed(),
|
|
8492
8533
|
kind: "future",
|
|
8493
8534
|
tracker,
|
|
8494
|
-
body: body ?? ""
|
|
8535
|
+
body: body ?? "",
|
|
8536
|
+
headers
|
|
8495
8537
|
});
|
|
8496
8538
|
}
|
|
8497
8539
|
}
|
|
@@ -26863,7 +26905,7 @@ const waitForRetry = (depth = 0) => new Promise((resolve) => {
|
|
|
26863
26905
|
resolve(true);
|
|
26864
26906
|
}, 2 ** depth * 10);
|
|
26865
26907
|
});
|
|
26866
|
-
function
|
|
26908
|
+
function readModelHookEntry(key, fetcher) {
|
|
26867
26909
|
const entry = modelHookCache.get(key);
|
|
26868
26910
|
if (entry) {
|
|
26869
26911
|
if (entry.status === "finished") {
|
|
@@ -26888,7 +26930,7 @@ function fetchData$1(key, fetcher) {
|
|
|
26888
26930
|
throw promise;
|
|
26889
26931
|
}
|
|
26890
26932
|
function useSuspenseData$1(key, fetcher) {
|
|
26891
|
-
const data =
|
|
26933
|
+
const data = readModelHookEntry(key, fetcher);
|
|
26892
26934
|
return data;
|
|
26893
26935
|
}
|
|
26894
26936
|
async function fetchModel$1(kosCore, modelOptions) {
|
|
@@ -29429,6 +29471,7 @@ export {
|
|
|
29429
29471
|
processId,
|
|
29430
29472
|
processMiddleware,
|
|
29431
29473
|
put,
|
|
29474
|
+
readModelHookEntry,
|
|
29432
29475
|
registerCompanionModel,
|
|
29433
29476
|
registerCoreModels,
|
|
29434
29477
|
registerExtensionPoint,
|