@wix/headless-site 1.12.0 → 1.13.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.
@@ -15,22 +15,19 @@ const createHostModule = () => {
15
15
  host: ({
16
16
  essentials
17
17
  } = {}) => {
18
- const currentLocale = (0, _multilingualUtils.getCurrentLocale)(essentials);
19
18
  return {
20
19
  essentials: {
21
20
  get passThroughHeaders() {
22
- return (0, _headers.getPassThroughHeaders)(essentials);
21
+ return (0, _headers.getPassThroughHeaders)(getNormalizedEssentials(essentials));
23
22
  },
24
23
  get language() {
25
- var _window$essentials;
26
- return (essentials == null ? void 0 : essentials.language) ?? ((_window$essentials = window.essentials) == null ? void 0 : _window$essentials.language) ?? 'en';
24
+ return getNormalizedEssentials(essentials).language ?? 'en';
27
25
  },
28
26
  get locale() {
29
- return currentLocale;
27
+ return (0, _multilingualUtils.getCurrentLocale)(getNormalizedEssentials(essentials));
30
28
  },
31
29
  get timezone() {
32
- var _window$essentials2;
33
- return (essentials == null ? void 0 : essentials.timezone) ?? ((_window$essentials2 = window.essentials) == null ? void 0 : _window$essentials2.timeZone) ?? 'UTC';
30
+ return getNormalizedEssentials(essentials).timezone ?? 'UTC';
34
31
  }
35
32
  },
36
33
  getMonitoringClient: () => {
@@ -51,5 +48,19 @@ const createHostModule = () => {
51
48
  }
52
49
  };
53
50
  };
51
+
52
+ // Normalize essentials by merging with window.essentials, handling property name differences
53
+ // Use a function to maintain reactivity to window.essentials changes
54
54
  exports.createHostModule = createHostModule;
55
+ const getNormalizedEssentials = essentials => {
56
+ var _window$essentials, _window$essentials2, _window$essentials3, _window$essentials4;
57
+ return {
58
+ ...essentials,
59
+ ...(typeof window !== 'undefined' ? window.essentials : {}),
60
+ language: (essentials == null ? void 0 : essentials.language) ?? (typeof window !== 'undefined' ? (_window$essentials = window.essentials) == null ? void 0 : _window$essentials.language : undefined) ?? 'en',
61
+ locale: (essentials == null ? void 0 : essentials.locale) ?? (typeof window !== 'undefined' ? (_window$essentials2 = window.essentials) == null ? void 0 : _window$essentials2.locale : undefined),
62
+ timezone: (essentials == null ? void 0 : essentials.timezone) ?? (typeof window !== 'undefined' ? (_window$essentials3 = window.essentials) == null ? void 0 : _window$essentials3.timeZone : undefined),
63
+ multilingual: (essentials == null ? void 0 : essentials.multilingual) ?? (typeof window !== 'undefined' ? (_window$essentials4 = window.essentials) == null ? void 0 : _window$essentials4.multilingual : undefined)
64
+ };
65
+ };
55
66
  //# sourceMappingURL=host-module.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_monitoringVelo","require","_headers","_authUtils","_multilingualUtils","createHostModule","__type","create","host","essentials","currentLocale","getCurrentLocale","passThroughHeaders","getPassThroughHeaders","language","_window$essentials","window","locale","timezone","_window$essentials2","timeZone","getMonitoringClient","producer","req","document","location","href","Request","createVeloMonitoringClient","namespace","getAuthToken","resolveAuthToken","exports"],"sources":["../../src/host-module.ts"],"sourcesContent":["import type { HostModule, Host } from '@wix/sdk-types';\nimport { createVeloMonitoringClient } from '@wix/monitoring-velo';\nimport { getPassThroughHeaders } from './headers';\nimport { resolveAuthToken } from './utils/auth-utils';\nimport type { SDK, SDKOptions } from './types';\nimport { getCurrentLocale } from './utils/multilingual-utils';\n\nexport const createHostModule = (): HostModule<SDK, Host> & {\n host: (options: SDKOptions) => Host;\n} => {\n return {\n __type: 'host',\n create: () => {\n return {};\n },\n host: ({ essentials }: SDKOptions = {}) => {\n const currentLocale = getCurrentLocale(essentials);\n\n return {\n essentials: {\n get passThroughHeaders() {\n return getPassThroughHeaders(essentials);\n },\n get language() {\n return essentials?.language ?? window.essentials?.language ?? 'en';\n },\n get locale() {\n return currentLocale;\n },\n get timezone() {\n return essentials?.timezone ?? window.essentials?.timeZone ?? 'UTC';\n },\n },\n getMonitoringClient: () => {\n let producer = 'unknown';\n let req: Request | undefined;\n\n if (typeof document !== 'undefined') {\n producer = document.location.href;\n req = new Request(document.location.href);\n }\n\n return createVeloMonitoringClient({\n namespace: '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AACC,QAAQ,CAACC,IAAI;YACjCH,GAAG,GAAG,IAAII,OAAO,CAACH,QAAQ,CAACC,QAAQ,CAACC,IAAI,CAAC;UAC3C;UAEA,OAAO,IAAAE,0CAA0B,EAAC;YAChCC,SAAS,EAAE,UAAU;YACrBP,QAAQ;YACRQ,YAAY,EAAE,MAAAA,CAAA,KAAY,IAAAC,2BAAgB,EAAC,CAAC;YAC5CR;UACF,CAAC,CAAC;QACJ;MACF,CAAC;IACH;EACF,CAAC;AACH,CAAC;AAACS,OAAA,CAAA3B,gBAAA,GAAAA,gBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_monitoringVelo","require","_headers","_authUtils","_multilingualUtils","createHostModule","__type","create","host","essentials","passThroughHeaders","getPassThroughHeaders","getNormalizedEssentials","language","locale","getCurrentLocale","timezone","getMonitoringClient","producer","req","document","location","href","Request","createVeloMonitoringClient","namespace","getAuthToken","resolveAuthToken","exports","_window$essentials","_window$essentials2","_window$essentials3","_window$essentials4","window","undefined","timeZone","multilingual"],"sources":["../../src/host-module.ts"],"sourcesContent":["import type { HostModule, Host } from '@wix/sdk-types';\nimport { createVeloMonitoringClient } from '@wix/monitoring-velo';\nimport { getPassThroughHeaders } from './headers';\nimport { resolveAuthToken } from './utils/auth-utils';\nimport type { Essentials, SDK, SDKOptions } from './types';\nimport { getCurrentLocale } from './utils/multilingual-utils';\n\nexport const createHostModule = (): HostModule<SDK, Host> & {\n host: (options: SDKOptions) => Host;\n} => {\n return {\n __type: 'host',\n create: () => {\n return {};\n },\n host: ({ essentials }: SDKOptions = {}) => {\n return {\n essentials: {\n get passThroughHeaders() {\n return getPassThroughHeaders(getNormalizedEssentials(essentials));\n },\n get language() {\n return getNormalizedEssentials(essentials).language ?? 'en';\n },\n get locale() {\n return getCurrentLocale(getNormalizedEssentials(essentials));\n },\n get timezone() {\n return getNormalizedEssentials(essentials).timezone ?? 'UTC';\n },\n },\n getMonitoringClient: () => {\n let producer = 'unknown';\n let req: Request | undefined;\n\n if (typeof document !== 'undefined') {\n producer = document.location.href;\n req = new Request(document.location.href);\n }\n\n return createVeloMonitoringClient({\n namespace: 'Headless',\n producer,\n getAuthToken: async () => resolveAuthToken(),\n req,\n });\n },\n };\n },\n };\n};\n\n// Normalize essentials by merging with window.essentials, handling property name differences\n// Use a function to maintain reactivity to window.essentials changes\nconst getNormalizedEssentials = (essentials?: Essentials): Essentials => ({\n ...essentials,\n ...(typeof window !== 'undefined' ? window.essentials : {}),\n language:\n essentials?.language ??\n (typeof window !== 'undefined' ? window.essentials?.language : undefined) ??\n 'en',\n locale:\n essentials?.locale ??\n (typeof window !== 'undefined' ? window.essentials?.locale : undefined),\n timezone:\n essentials?.timezone ??\n (typeof window !== 'undefined' ? window.essentials?.timeZone : undefined),\n multilingual:\n essentials?.multilingual ??\n (typeof window !== 'undefined'\n ? window.essentials?.multilingual\n : undefined),\n});\n"],"mappings":";;;;AACA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAEA,IAAAG,kBAAA,GAAAH,OAAA;AAEO,MAAMI,gBAAgB,GAAGA,CAAA,KAE3B;EACH,OAAO;IACLC,MAAM,EAAE,MAAM;IACdC,MAAM,EAAEA,CAAA,KAAM;MACZ,OAAO,CAAC,CAAC;IACX,CAAC;IACDC,IAAI,EAAEA,CAAC;MAAEC;IAAuB,CAAC,GAAG,CAAC,CAAC,KAAK;MACzC,OAAO;QACLA,UAAU,EAAE;UACV,IAAIC,kBAAkBA,CAAA,EAAG;YACvB,OAAO,IAAAC,8BAAqB,EAACC,uBAAuB,CAACH,UAAU,CAAC,CAAC;UACnE,CAAC;UACD,IAAII,QAAQA,CAAA,EAAG;YACb,OAAOD,uBAAuB,CAACH,UAAU,CAAC,CAACI,QAAQ,IAAI,IAAI;UAC7D,CAAC;UACD,IAAIC,MAAMA,CAAA,EAAG;YACX,OAAO,IAAAC,mCAAgB,EAACH,uBAAuB,CAACH,UAAU,CAAC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jBqB,mBAAA,CAAmBhB,MAAM,GAAGoB,SAAS,CAAC;IACzElB,QAAQ,EACN,CAAAP,UAAU,oBAAVA,UAAU,CAAEO,QAAQ,MACnB,OAAOiB,MAAM,KAAK,WAAW,IAAAF,mBAAA,GAAGE,MAAM,CAACxB,UAAU,qBAAjBsB,mBAAA,CAAmBI,QAAQ,GAAGD,SAAS,CAAC;IAC3EE,YAAY,EACV,CAAA3B,UAAU,oBAAVA,UAAU,CAAE2B,YAAY,MACvB,OAAOH,MAAM,KAAK,WAAW,IAAAD,mBAAA,GAC1BC,MAAM,CAACxB,UAAU,qBAAjBuB,mBAAA,CAAmBI,YAAY,GAC/BF,SAAS;EACjB,CAAC;AAAA,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["../../src/types.ts"],"sourcesContent":["export type SDK = {};\n\ndeclare global {\n interface Window {\n essentials: {\n language: string;\n locale?: string;\n timeZone?: string;\n };\n }\n}\n\nexport interface SDKOptions {\n essentials?: Essentials;\n}\n\nexport interface Essentials {\n language?: string;\n locale?: string;\n timezone?: string;\n multilingual?: Multilingual;\n}\n\nexport interface Multilingual {\n supportedLanguages?: SupportedLanguage[];\n}\n\nexport interface SupportedLanguage {\n languageCode?: string;\n isPrimary?: boolean;\n countryCode?: string;\n isVisitorPrimary?: boolean;\n locale?: Locale;\n}\n\nexport interface Locale {\n languageCode?: string;\n country?: string;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["../../src/types.ts"],"sourcesContent":["export type SDK = {};\n\ndeclare global {\n interface Window {\n essentials: {\n language: string;\n locale?: string;\n timeZone?: string;\n multilingual?: Multilingual;\n };\n }\n}\n\nexport interface SDKOptions {\n essentials?: Essentials;\n}\n\nexport interface Essentials {\n language?: string;\n locale?: string;\n timezone?: string;\n multilingual?: Multilingual;\n}\n\nexport interface Multilingual {\n supportedLanguages?: SupportedLanguage[];\n}\n\nexport interface SupportedLanguage {\n languageCode?: string;\n isPrimary?: boolean;\n countryCode?: string;\n isVisitorPrimary?: boolean;\n locale?: Locale;\n}\n\nexport interface Locale {\n languageCode?: string;\n country?: string;\n}\n"],"mappings":"","ignoreList":[]}
@@ -11,7 +11,7 @@ function getLanguageLocale(language) {
11
11
  return [language.languageCode, (_language$locale = language.locale) == null ? void 0 : _language$locale.country].filter(Boolean).join('-');
12
12
  }
13
13
  const getCurrentLocale = essentials => {
14
- var _document, _window$essentials;
14
+ var _document;
15
15
  let locale = essentials == null ? void 0 : essentials.locale;
16
16
  if (typeof document !== 'undefined' && (_document = document) != null && (_document = _document.location) != null && _document.href) {
17
17
  try {
@@ -32,7 +32,7 @@ const getCurrentLocale = essentials => {
32
32
  // Invalid URL, ignore
33
33
  }
34
34
  }
35
- return locale ?? ((_window$essentials = window.essentials) == null ? void 0 : _window$essentials.locale) ?? 'en-US';
35
+ return locale ?? 'en-US';
36
36
  };
37
37
  exports.getCurrentLocale = getCurrentLocale;
38
38
  //# sourceMappingURL=multilingual-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getLanguageLocale","language","_language$locale","languageCode","undefined","locale","country","filter","Boolean","join","getCurrentLocale","essentials","_document","_window$essentials","document","location","href","_document2","url","URL","localeSearchParam","searchParams","get","_essentials$multiling","multilingual","supportedLanguages","find","lang","window","exports"],"sources":["../../../src/utils/multilingual-utils.ts"],"sourcesContent":["import type { SupportedLanguage, Essentials } from '../types';\n\nexport function getLanguageLocale(language: SupportedLanguage) {\n if (!language?.languageCode) {\n return undefined;\n }\n\n return [language.languageCode, language.locale?.country]\n .filter(Boolean)\n .join('-');\n}\n\nexport const getCurrentLocale = (essentials: Essentials | undefined) => {\n let locale = essentials?.locale;\n\n if (typeof document !== 'undefined' && document?.location?.href) {\n try {\n const url = new URL(document?.location?.href);\n\n const localeSearchParam = url.searchParams.get('lang'); // e.g., mysite.com/?lang=en\n\n if (localeSearchParam) {\n const language = essentials?.multilingual?.supportedLanguages?.find(\n (lang: SupportedLanguage) => lang.languageCode === localeSearchParam,\n );\n\n // verify it's a valid locale\n if (language?.languageCode) {\n locale = getLanguageLocale(language);\n }\n }\n } catch {\n // Invalid URL, ignore\n }\n }\n\n return locale ?? window.essentials?.locale ?? 'en-US';\n};\n"],"mappings":";;;;;AAEO,SAASA,iBAAiBA,CAACC,QAA2B,EAAE;EAAA,IAAAC,gBAAA;EAC7D,IAAI,EAACD,QAAQ,YAARA,QAAQ,CAAEE,YAAY,GAAE;IAC3B,OAAOC,SAAS;EAClB;EAEA,OAAO,CAACH,QAAQ,CAACE,YAAY,GAAAD,gBAAA,GAAED,QAAQ,CAACI,MAAM,qBAAfH,gBAAA,CAAiBI,OAAO,CAAC,CACrDC,MAAM,CAACC,OAAO,CAAC,CACfC,IAAI,CAAC,GAAG,CAAC;AACd;AAEO,MAAMC,gBAAgB,GAAIC,UAAkC,IAAK;EAAA,IAAAC,SAAA,EAAAC,kBAAA;EACtE,IAAIR,MAAM,GAAGM,UAAU,oBAAVA,UAAU,CAAEN,MAAM;EAE/B,IAAI,OAAOS,QAAQ,KAAK,WAAW,KAAAF,SAAA,GAAIE,QAAQ,cAAAF,SAAA,GAARA,SAAA,CAAUG,QAAQ,aAAlBH,SAAA,CAAoBI,IAAI,EAAE;IAC/D,IAAI;MAAA,IAAAC,UAAA;MACF,MAAMC,GAAG,GAAG,IAAIC,GAAG,EAAAF,UAAA,GAACH,QAAQ,cAAAG,UAAA,GAARA,UAAA,CAAUF,QAAQ,qBAAlBE,UAAA,CAAoBD,IAAI,CAAC;MAE7C,MAAMI,iBAAiB,GAAGF,GAAG,CAACG,YAAY,CAACC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;;MAExD,IAAIF,iBAAiB,EAAE;QAAA,IAAAG,qBAAA;QACrB,MAAMtB,QAAQ,GAAGU,UAAU,aAAAY,qBAAA,GAAVZ,UAAU,CAAEa,YAAY,cAAAD,qBAAA,GAAxBA,qBAAA,CAA0BE,kBAAkB,qBAA5CF,qBAAA,CAA8CG,IAAI,CAChEC,IAAuB,IAAKA,IAAI,CAACxB,YAAY,KAAKiB,iBACrD,CAAC;;QAED;QACA,IAAInB,QAAQ,YAARA,QAAQ,CAAEE,YAAY,EAAE;UAC1BE,MAAM,GAAGL,iBAAiB,CAACC,QAAQ,CAAC;QACtC;MACF;IACF,CAAC,CAAC,MAAM;MACN;IAAA;EAEJ;EAEA,OAAOI,MAAM,MAAAQ,kBAAA,GAAIe,MAAM,CAACjB,UAAU,qBAAjBE,kBAAA,CAAmBR,MAAM,KAAI,OAAO;AACvD,CAAC;AAACwB,OAAA,CAAAnB,gBAAA,GAAAA,gBAAA","ignoreList":[]}
1
+ {"version":3,"names":["getLanguageLocale","language","_language$locale","languageCode","undefined","locale","country","filter","Boolean","join","getCurrentLocale","essentials","_document","document","location","href","_document2","url","URL","localeSearchParam","searchParams","get","_essentials$multiling","multilingual","supportedLanguages","find","lang","exports"],"sources":["../../../src/utils/multilingual-utils.ts"],"sourcesContent":["import type { SupportedLanguage, Essentials } from '../types';\n\nexport function getLanguageLocale(language: SupportedLanguage) {\n if (!language?.languageCode) {\n return undefined;\n }\n\n return [language.languageCode, language.locale?.country]\n .filter(Boolean)\n .join('-');\n}\n\nexport const getCurrentLocale = (essentials: Essentials | undefined) => {\n let locale = essentials?.locale;\n\n if (typeof document !== 'undefined' && document?.location?.href) {\n try {\n const url = new URL(document?.location?.href);\n\n const localeSearchParam = url.searchParams.get('lang'); // e.g., mysite.com/?lang=en\n\n if (localeSearchParam) {\n const language = essentials?.multilingual?.supportedLanguages?.find(\n (lang: SupportedLanguage) => lang.languageCode === localeSearchParam,\n );\n\n // verify it's a valid locale\n if (language?.languageCode) {\n locale = getLanguageLocale(language);\n }\n }\n } catch {\n // Invalid URL, ignore\n }\n }\n\n return locale ?? 'en-US';\n};\n"],"mappings":";;;;;AAEO,SAASA,iBAAiBA,CAACC,QAA2B,EAAE;EAAA,IAAAC,gBAAA;EAC7D,IAAI,EAACD,QAAQ,YAARA,QAAQ,CAAEE,YAAY,GAAE;I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AAAA,gBAAA","ignoreList":[]}
@@ -12,22 +12,19 @@ export const createHostModule = () => {
12
12
  let {
13
13
  essentials
14
14
  } = _temp === void 0 ? {} : _temp;
15
- const currentLocale = getCurrentLocale(essentials);
16
15
  return {
17
16
  essentials: {
18
17
  get passThroughHeaders() {
19
- return getPassThroughHeaders(essentials);
18
+ return getPassThroughHeaders(getNormalizedEssentials(essentials));
20
19
  },
21
20
  get language() {
22
- var _window$essentials;
23
- return (essentials == null ? void 0 : essentials.language) ?? ((_window$essentials = window.essentials) == null ? void 0 : _window$essentials.language) ?? 'en';
21
+ return getNormalizedEssentials(essentials).language ?? 'en';
24
22
  },
25
23
  get locale() {
26
- return currentLocale;
24
+ return getCurrentLocale(getNormalizedEssentials(essentials));
27
25
  },
28
26
  get timezone() {
29
- var _window$essentials2;
30
- return (essentials == null ? void 0 : essentials.timezone) ?? ((_window$essentials2 = window.essentials) == null ? void 0 : _window$essentials2.timeZone) ?? 'UTC';
27
+ return getNormalizedEssentials(essentials).timezone ?? 'UTC';
31
28
  }
32
29
  },
33
30
  getMonitoringClient: () => {
@@ -48,4 +45,18 @@ export const createHostModule = () => {
48
45
  }
49
46
  };
50
47
  };
48
+
49
+ // Normalize essentials by merging with window.essentials, handling property name differences
50
+ // Use a function to maintain reactivity to window.essentials changes
51
+ const getNormalizedEssentials = essentials => {
52
+ var _window$essentials, _window$essentials2, _window$essentials3, _window$essentials4;
53
+ return {
54
+ ...essentials,
55
+ ...(typeof window !== 'undefined' ? window.essentials : {}),
56
+ language: (essentials == null ? void 0 : essentials.language) ?? (typeof window !== 'undefined' ? (_window$essentials = window.essentials) == null ? void 0 : _window$essentials.language : undefined) ?? 'en',
57
+ locale: (essentials == null ? void 0 : essentials.locale) ?? (typeof window !== 'undefined' ? (_window$essentials2 = window.essentials) == null ? void 0 : _window$essentials2.locale : undefined),
58
+ timezone: (essentials == null ? void 0 : essentials.timezone) ?? (typeof window !== 'undefined' ? (_window$essentials3 = window.essentials) == null ? void 0 : _window$essentials3.timeZone : undefined),
59
+ multilingual: (essentials == null ? void 0 : essentials.multilingual) ?? (typeof window !== 'undefined' ? (_window$essentials4 = window.essentials) == null ? void 0 : _window$essentials4.multilingual : undefined)
60
+ };
61
+ };
51
62
  //# sourceMappingURL=host-module.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createVeloMonitoringClient","getPassThroughHeaders","resolveAuthToken","getCurrentLocale","createHostModule","__type","create","host","_temp","essentials","currentLocale","passThroughHeaders","language","_window$essentials","window","locale","timezone","_window$essentials2","timeZone","getMonitoringClient","producer","req","document","location","href","Request","namespace","getAuthToken"],"sources":["../../src/host-module.ts"],"sourcesContent":["import type { HostModule, Host } from '@wix/sdk-types';\nimport { createVeloMonitoringClient } from '@wix/monitoring-velo';\nimport { getPassThroughHeaders } from './headers';\nimport { resolveAuthToken } from './utils/auth-utils';\nimport type { SDK, SDKOptions } from './types';\nimport { getCurrentLocale } from './utils/multilingual-utils';\n\nexport const createHostModule = (): HostModule<SDK, Host> & {\n host: (options: SDKOptions) => Host;\n} => {\n return {\n __type: 'host',\n create: () => {\n return {};\n },\n host: ({ essentials }: SDKOptions = {}) => {\n const currentLocale = getCurrentLocale(essentials);\n\n return {\n essentials: {\n get passThroughHeaders() {\n return getPassThroughHeaders(essentials);\n },\n get language() {\n return essentials?.language ?? window.essentials?.language ?? 'en';\n },\n get locale() {\n return currentLocale;\n },\n get timezone() {\n return essentials?.timezone ?? window.essentials?.timeZone ?? 'UTC';\n },\n },\n getMonitoringClient: () => {\n let producer = 'unknown';\n let req: Request | undefined;\n\n if (typeof document !== 'undefined') {\n producer = document.location.href;\n req = new Request(document.location.href);\n }\n\n return createVeloMonitoringClient({\n namespace: 'Headless',\n producer,\n getAuthToken: async () => resolveAuthToken(),\n req,\n });\n },\n };\n },\n };\n};\n"],"mappings":"AACA,SAASA,0BAA0B,QAAQ,sBAAsB;AACjE,SAASC,qBAAqB,QAAQ,WAAW;AACjD,SAASC,gBAAgB,QAAQ,oBAAoB;AA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BAA0B,CAAC;YAChC0B,SAAS,EAAE,UAAU;YACrBN,QAAQ;YACRO,YAAY,EAAE,MAAAA,CAAA,KAAYzB,gBAAgB,CAAC,CAAC;YAC5CmB;UACF,CAAC,CAAC;QACJ;MACF,CAAC;IACH;EACF,CAAC;AACH,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["createVeloMonitoringClient","getPassThroughHeaders","resolveAuthToken","getCurrentLocale","createHostModule","__type","create","host","_temp","essentials","passThroughHeaders","getNormalizedEssentials","language","locale","timezone","getMonitoringClient","producer","req","document","location","href","Request","namespace","getAuthToken","_window$essentials","_window$essentials2","_window$essentials3","_window$essentials4","window","undefined","timeZone","multilingual"],"sources":["../../src/host-module.ts"],"sourcesContent":["import type { HostModule, Host } from '@wix/sdk-types';\nimport { createVeloMonitoringClient } from '@wix/monitoring-velo';\nimport { getPassThroughHeaders } from './headers';\nimport { resolveAuthToken } from './utils/auth-utils';\nimport type { Essentials, SDK, SDKOptions } from './types';\nimport { getCurrentLocale } from './utils/multilingual-utils';\n\nexport const createHostModule = (): HostModule<SDK, Host> & {\n host: (options: SDKOptions) => Host;\n} => {\n return {\n __type: 'host',\n create: () => {\n return {};\n },\n host: ({ essentials }: SDKOptions = {}) => {\n return {\n essentials: {\n get passThroughHeaders() {\n return getPassThroughHeaders(getNormalizedEssentials(essentials));\n },\n get language() {\n return getNormalizedEssentials(essentials).language ?? 'en';\n },\n get locale() {\n return getCurrentLocale(getNormalizedEssentials(essentials));\n },\n get timezone() {\n return getNormalizedEssentials(essentials).timezone ?? 'UTC';\n },\n },\n getMonitoringClient: () => {\n let producer = 'unknown';\n let req: Request | undefined;\n\n if (typeof document !== 'undefined') {\n producer = document.location.href;\n req = new Request(document.location.href);\n }\n\n return createVeloMonitoringClient({\n namespace: 'Headless',\n producer,\n getAuthToken: async () => resolveAuthToken(),\n req,\n });\n },\n };\n },\n };\n};\n\n// Normalize essentials by merging with window.essentials, handling property name differences\n// Use a function to maintain reactivity to window.essentials changes\nconst getNormalizedEssentials = (essentials?: Essentials): Essentials => ({\n ...essentials,\n ...(typeof window !== 'undefined' ? window.essentials : {}),\n language:\n essentials?.language ??\n (typeof window !== 'undefined' ? window.essentials?.language : undefined) ??\n 'en',\n locale:\n essentials?.locale ??\n (typeof window !== 'undefined' ? window.essentials?.locale : undefined),\n timezone:\n essentials?.timezone ??\n (typeof window !== 'undefined' ? window.essentials?.timeZone : undefined),\n multilingual:\n essentials?.multilingual ??\n (typeof window !== 'undefined'\n ? window.essentials?.multilingual\n : undefined),\n});\n"],"mappings":"AACA,SAASA,0BAA0B,QAAQ,sBAAsB;AACjE,SAASC,qBAAqB,QAAQ,WAAW;AACjD,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,SAASC,gBAAgB,QAAQ,4BAA4B;AAE7D,OAAO,MAAMC,gBAAgB,GAAGA,CAAA,KAE3B;EACH,OAAO;IACLC,MAAM,EAAE,MAAM;IACdC,MAAM,EAAEA,CAAA,KAAM;MACZ,OAAO,CAAC,CAAC;IACX,CAAC;IACDC,IAAI,EAAE,SAAAA,CAAAC,KAAA,EAAqC;MAAA,IAApC;QAAEC;MAAuB,CAAC,GAAAD,KAAA,cAAG,CAAC,CAAC,GAAAA,KAAA;MACpC,OAAO;QACLC,UAAU,EAAE;UACV,IAAIC,kBAAkBA,CAAA,EAAG;YACvB,OAAOT,qBAAqB,CAACU,uBAAuB,CAACF,UAAU,CAAC,CAAC;UACnE,CAAC;UACD,IAAIG,QAAQA,CAAA,EAAG;YACb,OAAOD,uBAAuB,CAACF,UAAU,CAAC,CAACG,QAAQ,IAAI,IAAI;UAC7D,CAAC;UACD,IAAIC,MAAMA,CAAA,EAAG;YACX,OAAOV,gBAAgB,CAACQ,uBAAuB,CAACF,UAAU,CAAC,CAAC;UAC9D,CAAC;UACD,IAAIK,QAAQA,CAAA,EAAG;YACb,OAAOH,uBAAuB,CAACF,UAAU,CAAC,CAACK,QAAQ,IAAI,KAAK;UAC9D;QACF,CAAC;QACDC,mBAAmB,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mBI,QAAQ,GAAGD,SAAS,CAAC;IAC3EE,YAAY,EACV,CAAAtB,UAAU,oBAAVA,UAAU,CAAEsB,YAAY,MACvB,OAAOH,MAAM,KAAK,WAAW,IAAAD,mBAAA,GAC1BC,MAAM,CAACnB,UAAU,qBAAjBkB,mBAAA,CAAmBI,YAAY,GAC/BF,SAAS;EACjB,CAAC;AAAA,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["../../src/types.ts"],"sourcesContent":["export type SDK = {};\n\ndeclare global {\n interface Window {\n essentials: {\n language: string;\n locale?: string;\n timeZone?: string;\n };\n }\n}\n\nexport interface SDKOptions {\n essentials?: Essentials;\n}\n\nexport interface Essentials {\n language?: string;\n locale?: string;\n timezone?: string;\n multilingual?: Multilingual;\n}\n\nexport interface Multilingual {\n supportedLanguages?: SupportedLanguage[];\n}\n\nexport interface SupportedLanguage {\n languageCode?: string;\n isPrimary?: boolean;\n countryCode?: string;\n isVisitorPrimary?: boolean;\n locale?: Locale;\n}\n\nexport interface Locale {\n languageCode?: string;\n country?: string;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["../../src/types.ts"],"sourcesContent":["export type SDK = {};\n\ndeclare global {\n interface Window {\n essentials: {\n language: string;\n locale?: string;\n timeZone?: string;\n multilingual?: Multilingual;\n };\n }\n}\n\nexport interface SDKOptions {\n essentials?: Essentials;\n}\n\nexport interface Essentials {\n language?: string;\n locale?: string;\n timezone?: string;\n multilingual?: Multilingual;\n}\n\nexport interface Multilingual {\n supportedLanguages?: SupportedLanguage[];\n}\n\nexport interface SupportedLanguage {\n languageCode?: string;\n isPrimary?: boolean;\n countryCode?: string;\n isVisitorPrimary?: boolean;\n locale?: Locale;\n}\n\nexport interface Locale {\n languageCode?: string;\n country?: string;\n}\n"],"mappings":"","ignoreList":[]}
@@ -6,7 +6,7 @@ export function getLanguageLocale(language) {
6
6
  return [language.languageCode, (_language$locale = language.locale) == null ? void 0 : _language$locale.country].filter(Boolean).join('-');
7
7
  }
8
8
  export const getCurrentLocale = essentials => {
9
- var _document, _window$essentials;
9
+ var _document;
10
10
  let locale = essentials == null ? void 0 : essentials.locale;
11
11
  if (typeof document !== 'undefined' && (_document = document) != null && (_document = _document.location) != null && _document.href) {
12
12
  try {
@@ -27,6 +27,6 @@ export const getCurrentLocale = essentials => {
27
27
  // Invalid URL, ignore
28
28
  }
29
29
  }
30
- return locale ?? ((_window$essentials = window.essentials) == null ? void 0 : _window$essentials.locale) ?? 'en-US';
30
+ return locale ?? 'en-US';
31
31
  };
32
32
  //# sourceMappingURL=multilingual-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getLanguageLocale","language","_language$locale","languageCode","undefined","locale","country","filter","Boolean","join","getCurrentLocale","essentials","_document","_window$essentials","document","location","href","_document2","url","URL","localeSearchParam","searchParams","get","_essentials$multiling","multilingual","supportedLanguages","find","lang","window"],"sources":["../../../src/utils/multilingual-utils.ts"],"sourcesContent":["import type { SupportedLanguage, Essentials } from '../types';\n\nexport function getLanguageLocale(language: SupportedLanguage) {\n if (!language?.languageCode) {\n return undefined;\n }\n\n return [language.languageCode, language.locale?.country]\n .filter(Boolean)\n .join('-');\n}\n\nexport const getCurrentLocale = (essentials: Essentials | undefined) => {\n let locale = essentials?.locale;\n\n if (typeof document !== 'undefined' && document?.location?.href) {\n try {\n const url = new URL(document?.location?.href);\n\n const localeSearchParam = url.searchParams.get('lang'); // e.g., mysite.com/?lang=en\n\n if (localeSearchParam) {\n const language = essentials?.multilingual?.supportedLanguages?.find(\n (lang: SupportedLanguage) => lang.languageCode === localeSearchParam,\n );\n\n // verify it's a valid locale\n if (language?.languageCode) {\n locale = getLanguageLocale(language);\n }\n }\n } catch {\n // Invalid URL, ignore\n }\n }\n\n return locale ?? window.essentials?.locale ?? 'en-US';\n};\n"],"mappings":"AAEA,OAAO,SAASA,iBAAiBA,CAACC,QAA2B,EAAE;EAAA,IAAAC,gBAAA;EAC7D,IAAI,EAACD,QAA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,MAAAQ,kBAAA,GAAIe,MAAM,CAACjB,UAAU,qBAAjBE,kBAAA,CAAmBR,MAAM,KAAI,OAAO;AACvD,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["getLanguageLocale","language","_language$locale","languageCode","undefined","locale","country","filter","Boolean","join","getCurrentLocale","essentials","_document","document","location","href","_document2","url","URL","localeSearchParam","searchParams","get","_essentials$multiling","multilingual","supportedLanguages","find","lang"],"sources":["../../../src/utils/multilingual-utils.ts"],"sourcesContent":["import type { SupportedLanguage, Essentials } from '../types';\n\nexport function getLanguageLocale(language: SupportedLanguage) {\n if (!language?.languageCode) {\n return undefined;\n }\n\n return [language.languageCode, language.locale?.country]\n .filter(Boolean)\n .join('-');\n}\n\nexport const getCurrentLocale = (essentials: Essentials | undefined) => {\n let locale = essentials?.locale;\n\n if (typeof document !== 'undefined' && document?.location?.href) {\n try {\n const url = new URL(document?.location?.href);\n\n const localeSearchParam = url.searchParams.get('lang'); // e.g., mysite.com/?lang=en\n\n if (localeSearchParam) {\n const language = essentials?.multilingual?.supportedLanguages?.find(\n (lang: SupportedLanguage) => lang.languageCode === localeSearchParam,\n );\n\n // verify it's a valid locale\n if (language?.languageCode) {\n locale = getLanguageLocale(language);\n }\n }\n } catch {\n // Invalid URL, ignore\n }\n }\n\n return locale ?? 'en-US';\n};\n"],"mappings":"AAEA,OAAO,SAASA,iBAAiBA,CAACC,QAA2B,EAAE;EAAA,IAAAC,gBAAA;EAC7D,IAAI,EAACD,QAAQ,YAARA,QAAQ,CAAEE,YAAY,GAAE;IAC3B,OAAOC,SAAS;EAClB;EAEA,OAAO,CAACH,QAAQ,CAACE,YAAY,GAAAD,gBAAA,GAAED,QAAQ,CAACI,MAAM,qBAAfH,gBAAA,CAAiBI,OAAO,CAAC,CACrDC,MAAM,CAACC,OAAO,CAAC,CACfC,IAAI,CAAC,GAAG,CAAC;AACd;AAEA,OAAO,MAAMC,gBAAgB,GAAIC,UAAkC,IAAK;EAAA,IAAAC,SAAA;EACtE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1
+ {"version":3,"file":"host-module.d.ts","sourceRoot":"","sources":["../../src/host-module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAIvD,OAAO,KAAK,EAAc,GAAG,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAG3D,eAAO,MAAM,gBAAgB;oBACX,UAAU,KAAK,IAAI;CA0CpC,CAAC"}
@@ -5,6 +5,7 @@ declare global {
5
5
  language: string;
6
6
  locale?: string;
7
7
  timeZone?: string;
8
+ multilingual?: Multilingual;
8
9
  };
9
10
  }
10
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,oBAAY,GAAG,GAAG,EAAE,CAAC;AAErB,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,UAAU,EAAE;YACV,QAAQ,EAAE,MAAM,CAAC;YACjB,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;SACnB,CAAC;KACH;CACF;AAED,MAAM,WAAW,UAAU;IACzB,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED,MAAM,WAAW,YAAY;IAC3B,kBAAkB,CAAC,EAAE,iBAAiB,EAAE,CAAC;CAC1C;AAED,MAAM,WAAW,iBAAiB;IAChC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,MAAM;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,oBAAY,GAAG,GAAG,EAAE,CAAC;AAErB,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,UAAU,EAAE;YACV,QAAQ,EAAE,MAAM,CAAC;YACjB,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;YAClB,YAAY,CAAC,EAAE,YAAY,CAAC;SAC7B,CAAC;KACH;CACF;AAED,MAAM,WAAW,UAAU;IACzB,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED,MAAM,WAAW,YAAY;IAC3B,kBAAkB,CAAC,EAAE,iBAAiB,EAAE,CAAC;CAC1C;AAED,MAAM,WAAW,iBAAiB;IAChC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,MAAM;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/headless-site",
3
- "version": "1.12.0",
3
+ "version": "1.13.0",
4
4
  "unpkg": true,
5
5
  "license": "UNLICENSED",
6
6
  "author": {
@@ -87,5 +87,5 @@
87
87
  "wallaby": {
88
88
  "autoDetect": true
89
89
  },
90
- "falconPackageHash": "d6086529060990f177f7d6f865f9c45cb367c780be9a386c226eb691"
90
+ "falconPackageHash": "ff023096062746a93526ff21901e3f3d02cca7e4bf3f4a3bbfaafe2a"
91
91
  }