talizen 0.0.8 → 0.0.9

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.
Files changed (3) hide show
  1. package/core.d.ts +5 -0
  2. package/core.js +3 -1
  3. package/package.json +1 -1
package/core.d.ts CHANGED
@@ -21,5 +21,10 @@ export interface TalizenRequestOptions extends TalizenClientConfig {
21
21
  }
22
22
  export declare function setTalizenConfig(config: TalizenClientConfig): void;
23
23
  export declare function getTalizenConfig(): TalizenClientConfig;
24
+ declare global {
25
+ interface Window {
26
+ TalizenConfig?: TalizenClientConfig | undefined;
27
+ }
28
+ }
24
29
  export declare function resolveTalizenConfig(config?: TalizenRequestOptions): Required<Pick<TalizenClientConfig, "baseUrl" | "fetch">> & TalizenRequestOptions;
25
30
  export declare function requestJson<T>(path: string, init?: RequestInit, config?: TalizenRequestOptions): Promise<T>;
package/core.js CHANGED
@@ -11,7 +11,9 @@ export function getTalizenConfig() {
11
11
  };
12
12
  }
13
13
  export function resolveTalizenConfig(config) {
14
+ const windowConfig = typeof window !== "undefined" ? window.TalizenConfig : {};
14
15
  const merged = {
16
+ ...windowConfig,
15
17
  ...globalTalizenConfig,
16
18
  ...config,
17
19
  };
@@ -62,7 +64,7 @@ function getDefaultBaseUrl() {
62
64
  if (typeof window !== "undefined" && window.location?.origin) {
63
65
  return window.location.origin;
64
66
  }
65
- throw new Error("Talizen baseUrl is required. Call setTalizenConfig({ baseUrl }) first.");
67
+ throw new Error("Talizen baseUrl is required. set window.TalizenConfig = { baseUrl: 'https://example.com' } first.");
66
68
  }
67
69
  function getDefaultFetch() {
68
70
  if (typeof fetch === "function") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "talizen",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "Talizen frontend SDK types for cms, form and core.",
5
5
  "type": "module",
6
6
  "license": "MIT",