@kosdev-code/kos-ui-sdk 3.0.29 → 3.0.31

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.
@@ -1,3 +1,5 @@
1
1
  export * from './mock-types';
2
2
  export { KosMock } from './mock-registry';
3
+ export { ensureKosMockBoot } from './mock-boot';
4
+ export type { KosMockBoot } from './mock-boot';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../packages/kos-ui-sdk/src/core/core/transport/mock/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../packages/kos-ui-sdk/src/core/core/transport/mock/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * The KosMock boot switches a page needs: `?kosMock`, `?kosFixtureServer`,
3
+ * `?kosFixture` and `?kosSetup`.
4
+ *
5
+ * @kosService core.mock
6
+ * @kosApiLevel 26
7
+ */
8
+ export interface KosMockBoot {
9
+ /** `on` mocks over a live device (default); `standalone` boots offline. */
10
+ mode?: "on" | "standalone";
11
+ /** Fixture server URL; the default server when omitted. */
12
+ fixtureServer?: string;
13
+ /** Fixture to play at boot. */
14
+ fixture?: string;
15
+ /** Setup modules to install at boot. */
16
+ setups?: string[];
17
+ }
18
+ /** The URL that boots `href` with `boot`'s switches, or undefined when `href` already does. */
19
+ export declare function kosMockBootUrl(href: string, boot?: KosMockBoot): string | undefined;
20
+ /**
21
+ * Reloads the page with `boot`'s KosMock switches when it booted with different
22
+ * ones, so the data it loads at boot comes from those mocks. Without `boot` it
23
+ * reloads without switches. Returns true when a reload is under way; render
24
+ * nothing then.
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * // Storybook preview: a story asks for mocks with parameters.kosMock.
29
+ * export const decorators = [
30
+ * (Story, { parameters }) =>
31
+ * ensureKosMockBoot(parameters.kosMock) ? null : <Story />,
32
+ * ];
33
+ * ```
34
+ *
35
+ * @kosService core.mock
36
+ * @kosApiLevel 26
37
+ */
38
+ export declare function ensureKosMockBoot(boot?: KosMockBoot, location?: Pick<Location, "href" | "replace">): boolean;
39
+ //# sourceMappingURL=mock-boot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock-boot.d.ts","sourceRoot":"","sources":["../../../../../../../packages/kos-ui-sdk/src/core/core/transport/mock/mock-boot.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,2EAA2E;IAC3E,IAAI,CAAC,EAAE,IAAI,GAAG,YAAY,CAAC;IAC3B,2DAA2D;IAC3D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAaD,+FAA+F;AAC/F,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,WAAW,GACjB,MAAM,GAAG,SAAS,CAcpB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,CAAC,EAAE,WAAW,EAClB,QAAQ,GAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAmB,GAC7D,OAAO,CAKT"}
package/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const service$8 = require("./software-info-registration-CA13_Qc_.cjs");
3
+ const service$8 = require("./software-info-registration-BPN4QLfN.cjs");
4
4
  const mobx = require("mobx");
5
5
  const jsxRuntime = require("@emotion/react/jsx-runtime");
6
6
  const styled = require("@emotion/styled");
@@ -661,6 +661,33 @@ function kosViewModel(options) {
661
661
  return ProxiedClass;
662
662
  };
663
663
  }
664
+ const BOOT_PARAMS = ["kosMock", "kosFixtureServer", "kosFixture", "kosSetup"];
665
+ const bootKey = (params) => BOOT_PARAMS.map((name) => {
666
+ const value = params.get(name);
667
+ if (value === null) return "";
668
+ return name === "kosSetup" ? value.split(",").filter(Boolean).sort().join(",") : value;
669
+ }).join("|");
670
+ function kosMockBootUrl(href, boot) {
671
+ const url = new URL(href);
672
+ const before = bootKey(url.searchParams);
673
+ for (const name of BOOT_PARAMS) url.searchParams.delete(name);
674
+ const setups = boot?.setups?.filter(Boolean) ?? [];
675
+ if (boot && (boot.mode || boot.fixture || setups.length > 0)) {
676
+ url.searchParams.set("kosMock", boot.mode ?? "on");
677
+ if (boot.fixture || setups.length > 0) {
678
+ url.searchParams.set("kosFixtureServer", boot.fixtureServer ?? "");
679
+ }
680
+ if (boot.fixture) url.searchParams.set("kosFixture", boot.fixture);
681
+ if (setups.length > 0) url.searchParams.set("kosSetup", setups.join(","));
682
+ }
683
+ return bootKey(url.searchParams) === before ? void 0 : url.toString();
684
+ }
685
+ function ensureKosMockBoot(boot, location = window.location) {
686
+ const target = kosMockBootUrl(location.href, boot);
687
+ if (target === void 0) return false;
688
+ location.replace(target);
689
+ return true;
690
+ }
664
691
  class AncestorPathVisitor extends service$8.KosModelVisitor {
665
692
  targetId;
666
693
  currentPath = [];
@@ -1514,7 +1541,7 @@ const updateRegion = async (region) => {
1514
1541
  regionInfo.updateProperty(region);
1515
1542
  };
1516
1543
  async function getKosServiceApi() {
1517
- const { default: API } = await Promise.resolve().then(() => require("./software-info-registration-CA13_Qc_.cjs")).then((n) => n.service);
1544
+ const { default: API } = await Promise.resolve().then(() => require("./software-info-registration-BPN4QLfN.cjs")).then((n) => n.service);
1518
1545
  return API;
1519
1546
  }
1520
1547
  function kosServiceRequest$7(params) {
@@ -2969,6 +2996,7 @@ const KosTranslationProvider = ({
2969
2996
  appContext,
2970
2997
  locale = "en",
2971
2998
  resolver,
2999
+ bundleResolver,
2972
3000
  rootUrl,
2973
3001
  descriptorResolver,
2974
3002
  excludeNamespaces = []
@@ -3008,6 +3036,7 @@ const KosTranslationProvider = ({
3008
3036
  descriptor: localization,
3009
3037
  defaultNamespace: "common",
3010
3038
  resolver,
3039
+ bundleResolver,
3011
3040
  rootUrl: _rootUrl
3012
3041
  });
3013
3042
  setTranslations(translations2);
@@ -3015,7 +3044,7 @@ const KosTranslationProvider = ({
3015
3044
  }
3016
3045
  }
3017
3046
  initLocalization();
3018
- }, [locale, localization, resolver, resolvedRootUrl]);
3047
+ }, [locale, localization, resolver, bundleResolver, resolvedRootUrl]);
3019
3048
  const value = React.useMemo(() => {
3020
3049
  if (ready) {
3021
3050
  return {
@@ -4869,7 +4898,7 @@ function withProjectReloading(WrappedComponent) {
4869
4898
  return reloading ? /* @__PURE__ */ jsxRuntime.jsx(LoadingMessage, { message: "Wait a moment while your project reloads..." }) : /* @__PURE__ */ jsxRuntime.jsx(WrappedComponent, { ...props });
4870
4899
  };
4871
4900
  }
4872
- registerApiLevels({ "kos-ui-sdk": 25 });
4901
+ registerApiLevels({ "kos-ui-sdk": 26 });
4873
4902
  exports.AuthState = service$8.AuthState;
4874
4903
  Object.defineProperty(exports, "BASE_URL", {
4875
4904
  enumerable: true,
@@ -5311,6 +5340,7 @@ exports.clearServiceResponse = clearServiceResponse;
5311
5340
  exports.collectLocaleOptions = collectLocaleOptions;
5312
5341
  exports.convertFileSizeRaw = convertFileSizeRaw;
5313
5342
  exports.debounce = debounce;
5343
+ exports.ensureKosMockBoot = ensureKosMockBoot;
5314
5344
  exports.executeServiceRequest = executeServiceRequest;
5315
5345
  exports.fetchModel = fetchModel;
5316
5346
  exports.formatDate = formatDate;