@flipdish/portal-library 5.2.0 → 5.3.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/custom-hooks/useMicroFrontendAttributes.cjs.js +1 -1
- package/dist/custom-hooks/useMicroFrontendAttributes.cjs.js.map +1 -1
- package/dist/custom-hooks/useMicroFrontendAttributes.js +1 -1
- package/dist/custom-hooks/useMicroFrontendAttributes.js.map +1 -1
- package/dist/utilities/renderUtilities.cjs.js +1 -1
- package/dist/utilities/renderUtilities.cjs.js.map +1 -1
- package/dist/utilities/renderUtilities.d.ts +8 -4
- package/dist/utilities/renderUtilities.js +1 -1
- package/dist/utilities/renderUtilities.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var t=require("react");const e=["
|
|
1
|
+
"use strict";var t=require("react");const e=["org-id","app-id",{key:"is-flipdish-staff",type:"boolean"}],n=(t,e)=>t||"boolean"===e?"boolean"===e?"true"===t:"number"===e?Number(t):t:null,r=t=>[...e.map((t=>"string"==typeof t?t:t.key)),...t.map((t=>"string"==typeof t?t:t.key))];module.exports=(o=[])=>{const[s,i]=t.useState((()=>(t=>{const e=r(t),n={};return e.forEach((t=>{const e="string"==typeof t?t:t.key;n[e]=null})),n})(o)));return t.useEffect((()=>{const t=document.getElementById("flipdish-micro-frontend");if(!t)return void console.warn("Micro-frontend div not found");const s=r(o),u=[...e,...o],c=()=>{i((e=>{const r={...e};let o=!1;return s.forEach((e=>{const{value:s,key:i}=((t,e,r)=>{const o=((t,e)=>e.find((e=>"string"==typeof e?e===t:e.key===t)))(t,r),s=(t=>t&&"string"!=typeof t&&"type"in t?t.type??"string":"string")(o),i="string"==typeof t?t:t.key,u=(void 0)[`VITE_${i.toUpperCase()}_OVERRIDE`],c=`data-${i}`,a=e.getAttribute(c);return{value:n(u?u.toString():a,s),key:i}})(e,t,u);r[i]!==s&&(r[i]=s,o=!0)})),o?r:e}))};c();const a=new MutationObserver(c);return a.observe(t,{attributes:!0}),()=>a.disconnect()}),[o]),s};
|
|
2
2
|
//# sourceMappingURL=useMicroFrontendAttributes.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMicroFrontendAttributes.cjs.js","sources":["../../src/custom-hooks/useMicroFrontendAttributes.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\n\ntype KeyType = 'boolean' | 'number' | 'string';\n\ninterface KeyConfig {\n key: string;\n type?: KeyType; // type is optional, defaults to 'string'\n}\n\nconst ALWAYS_RETURN_KEYS: (KeyConfig | string)[] = [\n '
|
|
1
|
+
{"version":3,"file":"useMicroFrontendAttributes.cjs.js","sources":["../../src/custom-hooks/useMicroFrontendAttributes.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\n\ntype KeyType = 'boolean' | 'number' | 'string';\n\ninterface KeyConfig {\n key: string;\n type?: KeyType; // type is optional, defaults to 'string'\n}\n\nconst ALWAYS_RETURN_KEYS: (KeyConfig | string)[] = [\n 'org-id',\n 'app-id',\n { key: 'is-flipdish-staff', type: 'boolean' },\n] as const;\n\ntype AlwaysReturnKeys = (typeof ALWAYS_RETURN_KEYS)[number] extends KeyConfig\n ? (typeof ALWAYS_RETURN_KEYS)[number]['key']\n : (typeof ALWAYS_RETURN_KEYS)[number];\n\ntype ExtractKey<T> = T extends KeyConfig ? T['key'] : T;\n\ntype AttributeValue = boolean | number | string | null;\n\n// Utility functions moved outside\ntype KeyArg<T> = AlwaysReturnKeys | T | string;\nconst getKeyConfig = <T extends KeyConfig | string>(key: KeyArg<T>, allConfigs: (KeyConfig | string)[]) => {\n return allConfigs.find((config) => (typeof config === 'string' ? config === key : config.key === key));\n};\n\nconst getValueType = (keyConfig: KeyConfig | string | undefined): KeyType => {\n return keyConfig && typeof keyConfig !== 'string' && 'type' in keyConfig\n ? (keyConfig.type ?? 'string')\n : 'string';\n};\n\nconst parseValue = (value: string | null, type: KeyType): AttributeValue => {\n if (!value && type !== 'boolean') return null;\n if (type === 'boolean') return value === 'true';\n if (type === 'number') return Number(value);\n return value;\n};\n\nconst getAllKeys = <T extends KeyConfig | string>(\n customKeys: (KeyConfig | T)[],\n): (AlwaysReturnKeys | T | string)[] => {\n return [\n ...ALWAYS_RETURN_KEYS.map((key) => (typeof key === 'string' ? key : key.key)),\n ...customKeys.map((key) => (typeof key === 'string' ? key : key.key)),\n ];\n};\n\nconst getInitialState = <T extends KeyConfig | string>(\n customKeys: (KeyConfig | T)[],\n): Record<ExtractKey<AlwaysReturnKeys | T>, AttributeValue> => {\n const allKeys = getAllKeys(customKeys);\n const initialState = {} as Record<ExtractKey<AlwaysReturnKeys | T>, AttributeValue>;\n allKeys.forEach((key) => {\n const typedKey = (typeof key === 'string' ? key : key.key) as ExtractKey<AlwaysReturnKeys | T>;\n initialState[typedKey] = null;\n });\n return initialState;\n};\n\nconst processAttribute = <T extends KeyConfig | string>(\n key: AlwaysReturnKeys | T | string,\n microFrontendDiv: HTMLElement,\n allConfigs: (KeyConfig | string)[],\n): { value: AttributeValue; key: ExtractKey<AlwaysReturnKeys | T> } => {\n const keyConfig = getKeyConfig(key, allConfigs);\n const type = getValueType(keyConfig);\n const keyString = typeof key === 'string' ? key : key.key;\n\n const envVar = import.meta.env[`VITE_${keyString.toUpperCase()}_OVERRIDE`] as string | null | undefined;\n const attributeKey = `data-${keyString}`;\n const domValue = microFrontendDiv.getAttribute(attributeKey);\n\n const value = envVar ? parseValue(envVar.toString(), type) : parseValue(domValue, type);\n return { value, key: keyString as ExtractKey<AlwaysReturnKeys | T> };\n};\n\n/**\n * Custom hook to manage micro-frontend attributes.\n *\n * This hook initializes and updates a set of attributes based on a combination of predefined keys (ALWAYS_RETURN_KEYS)\n * and custom keys provided as arguments. The attributes are fetched from environment variables or DOM attributes\n * and are updated dynamically using a MutationObserver.\n *\n * @template T - The type of custom keys, which can be either a string or a KeyConfig object.\n *\n * @param {Array<T | KeyConfig>} [customKeys=[]] - An array of custom keys or KeyConfig objects to be included in the attributes.\n *\n * @returns {Record<ExtractKey<AlwaysReturnKeys | T>, string | boolean | number | null>} - A record of attributes with their values.\n *\n * @example\n * const attributes = useMicroFrontendAttributes(['customKey1', { key: 'customKey2', type: 'boolean' }]);\n * console.log(attributes);\n */\nconst useMicroFrontendAttributes = <T extends KeyConfig | string>(\n customKeys: (KeyConfig | T)[] = [],\n): Record<ExtractKey<AlwaysReturnKeys | T>, AttributeValue> => {\n const [attributes, setAttributes] = useState(() => getInitialState(customKeys));\n\n useEffect(() => {\n const microFrontendDiv = document.getElementById('flipdish-micro-frontend');\n if (!microFrontendDiv) {\n console.warn('Micro-frontend div not found');\n return;\n }\n\n const allKeys = getAllKeys(customKeys);\n const allConfigs = [...ALWAYS_RETURN_KEYS, ...customKeys];\n\n const updateValues = () => {\n setAttributes((prev) => {\n const newAttributes = { ...prev };\n let isChanged = false;\n\n allKeys.forEach((key) => {\n const { value, key: typedKey } = processAttribute(key, microFrontendDiv, allConfigs);\n if (newAttributes[typedKey] !== value) {\n newAttributes[typedKey] = value;\n isChanged = true;\n }\n });\n\n return isChanged ? newAttributes : prev;\n });\n };\n\n updateValues();\n\n const observer = new MutationObserver(updateValues);\n observer.observe(microFrontendDiv, { attributes: true });\n\n return () => observer.disconnect();\n }, [customKeys]);\n\n return attributes;\n};\n\nexport default useMicroFrontendAttributes;\n"],"names":["ALWAYS_RETURN_KEYS","key","type","parseValue","value","Number","getAllKeys","customKeys","map","attributes","setAttributes","useState","allKeys","initialState","forEach","typedKey","getInitialState","useEffect","microFrontendDiv","document","getElementById","console","warn","allConfigs","updateValues","prev","newAttributes","isChanged","keyConfig","find","config","getKeyConfig","getValueType","keyString","envVar","undefined","toUpperCase","attributeKey","domValue","getAttribute","toString","processAttribute","observer","MutationObserver","observe","disconnect"],"mappings":"oCASA,MAAMA,EAA6C,CACjD,SACA,SACA,CAAEC,IAAK,oBAAqBC,KAAM,YAuB9BC,EAAa,CAACC,EAAsBF,IACnCE,GAAkB,YAATF,EACD,YA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A+BF,EAAnBpC,GACrCD,IAAKgC,IAyCoBQ,CAAiBxC,EAAKiB,EAAkBK,GACrEG,EAAcX,KAAcX,IAC9BsB,EAAcX,GAAYX,EAC1BuB,GAAY,MAITA,EAAYD,EAAgBD,MAIvCD,IAEA,MAAMkB,EAAW,IAAIC,iBAAiBnB,GAGtC,OAFAkB,EAASE,QAAQ1B,EAAkB,CAAET,YAAY,IAE1C,IAAMiC,EAASG,eACrB,CAACtC,IAEGE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useState as t,useEffect as e}from"react";const n=["
|
|
1
|
+
import{useState as t,useEffect as e}from"react";const n=["org-id","app-id",{key:"is-flipdish-staff",type:"boolean"}],o=(t,e)=>t||"boolean"===e?"boolean"===e?"true"===t:"number"===e?Number(t):t:null,r=t=>[...n.map((t=>"string"==typeof t?t:t.key)),...t.map((t=>"string"==typeof t?t:t.key))],i=(i=[])=>{const[s,a]=t((()=>(t=>{const e=r(t),n={};return e.forEach((t=>{const e="string"==typeof t?t:t.key;n[e]=null})),n})(i)));return e((()=>{const t=document.getElementById("flipdish-micro-frontend");if(!t)return void console.warn("Micro-frontend div not found");const e=r(i),s=[...n,...i],p=()=>{a((n=>{const r={...n};let i=!1;return e.forEach((e=>{const{value:n,key:a}=((t,e,n)=>{const r=((t,e)=>e.find((e=>"string"==typeof e?e===t:e.key===t)))(t,n),i=(t=>t&&"string"!=typeof t&&"type"in t?t.type??"string":"string")(r),s="string"==typeof t?t:t.key,a=import.meta.env[`VITE_${s.toUpperCase()}_OVERRIDE`],p=`data-${s}`,c=e.getAttribute(p);return{value:o(a?a.toString():c,i),key:s}})(e,t,s);r[a]!==n&&(r[a]=n,i=!0)})),i?r:n}))};p();const c=new MutationObserver(p);return c.observe(t,{attributes:!0}),()=>c.disconnect()}),[i]),s};export{i as default};
|
|
2
2
|
//# sourceMappingURL=useMicroFrontendAttributes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMicroFrontendAttributes.js","sources":["../../src/custom-hooks/useMicroFrontendAttributes.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\n\ntype KeyType = 'boolean' | 'number' | 'string';\n\ninterface KeyConfig {\n key: string;\n type?: KeyType; // type is optional, defaults to 'string'\n}\n\nconst ALWAYS_RETURN_KEYS: (KeyConfig | string)[] = [\n '
|
|
1
|
+
{"version":3,"file":"useMicroFrontendAttributes.js","sources":["../../src/custom-hooks/useMicroFrontendAttributes.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\n\ntype KeyType = 'boolean' | 'number' | 'string';\n\ninterface KeyConfig {\n key: string;\n type?: KeyType; // type is optional, defaults to 'string'\n}\n\nconst ALWAYS_RETURN_KEYS: (KeyConfig | string)[] = [\n 'org-id',\n 'app-id',\n { key: 'is-flipdish-staff', type: 'boolean' },\n] as const;\n\ntype AlwaysReturnKeys = (typeof ALWAYS_RETURN_KEYS)[number] extends KeyConfig\n ? (typeof ALWAYS_RETURN_KEYS)[number]['key']\n : (typeof ALWAYS_RETURN_KEYS)[number];\n\ntype ExtractKey<T> = T extends KeyConfig ? T['key'] : T;\n\ntype AttributeValue = boolean | number | string | null;\n\n// Utility functions moved outside\ntype KeyArg<T> = AlwaysReturnKeys | T | string;\nconst getKeyConfig = <T extends KeyConfig | string>(key: KeyArg<T>, allConfigs: (KeyConfig | string)[]) => {\n return allConfigs.find((config) => (typeof config === 'string' ? config === key : config.key === key));\n};\n\nconst getValueType = (keyConfig: KeyConfig | string | undefined): KeyType => {\n return keyConfig && typeof keyConfig !== 'string' && 'type' in keyConfig\n ? (keyConfig.type ?? 'string')\n : 'string';\n};\n\nconst parseValue = (value: string | null, type: KeyType): AttributeValue => {\n if (!value && type !== 'boolean') return null;\n if (type === 'boolean') return value === 'true';\n if (type === 'number') return Number(value);\n return value;\n};\n\nconst getAllKeys = <T extends KeyConfig | string>(\n customKeys: (KeyConfig | T)[],\n): (AlwaysReturnKeys | T | string)[] => {\n return [\n ...ALWAYS_RETURN_KEYS.map((key) => (typeof key === 'string' ? key : key.key)),\n ...customKeys.map((key) => (typeof key === 'string' ? key : key.key)),\n ];\n};\n\nconst getInitialState = <T extends KeyConfig | string>(\n customKeys: (KeyConfig | T)[],\n): Record<ExtractKey<AlwaysReturnKeys | T>, AttributeValue> => {\n const allKeys = getAllKeys(customKeys);\n const initialState = {} as Record<ExtractKey<AlwaysReturnKeys | T>, AttributeValue>;\n allKeys.forEach((key) => {\n const typedKey = (typeof key === 'string' ? key : key.key) as ExtractKey<AlwaysReturnKeys | T>;\n initialState[typedKey] = null;\n });\n return initialState;\n};\n\nconst processAttribute = <T extends KeyConfig | string>(\n key: AlwaysReturnKeys | T | string,\n microFrontendDiv: HTMLElement,\n allConfigs: (KeyConfig | string)[],\n): { value: AttributeValue; key: ExtractKey<AlwaysReturnKeys | T> } => {\n const keyConfig = getKeyConfig(key, allConfigs);\n const type = getValueType(keyConfig);\n const keyString = typeof key === 'string' ? key : key.key;\n\n const envVar = import.meta.env[`VITE_${keyString.toUpperCase()}_OVERRIDE`] as string | null | undefined;\n const attributeKey = `data-${keyString}`;\n const domValue = microFrontendDiv.getAttribute(attributeKey);\n\n const value = envVar ? parseValue(envVar.toString(), type) : parseValue(domValue, type);\n return { value, key: keyString as ExtractKey<AlwaysReturnKeys | T> };\n};\n\n/**\n * Custom hook to manage micro-frontend attributes.\n *\n * This hook initializes and updates a set of attributes based on a combination of predefined keys (ALWAYS_RETURN_KEYS)\n * and custom keys provided as arguments. The attributes are fetched from environment variables or DOM attributes\n * and are updated dynamically using a MutationObserver.\n *\n * @template T - The type of custom keys, which can be either a string or a KeyConfig object.\n *\n * @param {Array<T | KeyConfig>} [customKeys=[]] - An array of custom keys or KeyConfig objects to be included in the attributes.\n *\n * @returns {Record<ExtractKey<AlwaysReturnKeys | T>, string | boolean | number | null>} - A record of attributes with their values.\n *\n * @example\n * const attributes = useMicroFrontendAttributes(['customKey1', { key: 'customKey2', type: 'boolean' }]);\n * console.log(attributes);\n */\nconst useMicroFrontendAttributes = <T extends KeyConfig | string>(\n customKeys: (KeyConfig | T)[] = [],\n): Record<ExtractKey<AlwaysReturnKeys | T>, AttributeValue> => {\n const [attributes, setAttributes] = useState(() => getInitialState(customKeys));\n\n useEffect(() => {\n const microFrontendDiv = document.getElementById('flipdish-micro-frontend');\n if (!microFrontendDiv) {\n console.warn('Micro-frontend div not found');\n return;\n }\n\n const allKeys = getAllKeys(customKeys);\n const allConfigs = [...ALWAYS_RETURN_KEYS, ...customKeys];\n\n const updateValues = () => {\n setAttributes((prev) => {\n const newAttributes = { ...prev };\n let isChanged = false;\n\n allKeys.forEach((key) => {\n const { value, key: typedKey } = processAttribute(key, microFrontendDiv, allConfigs);\n if (newAttributes[typedKey] !== value) {\n newAttributes[typedKey] = value;\n isChanged = true;\n }\n });\n\n return isChanged ? newAttributes : prev;\n });\n };\n\n updateValues();\n\n const observer = new MutationObserver(updateValues);\n observer.observe(microFrontendDiv, { attributes: true });\n\n return () => observer.disconnect();\n }, [customKeys]);\n\n return attributes;\n};\n\nexport default useMicroFrontendAttributes;\n"],"names":["ALWAYS_RETURN_KEYS","key","type","parseValue","value","Number","getAllKeys","customKeys","map","useMicroFrontendAttributes","attributes","setAttributes","useState","allKeys","initialState","forEach","typedKey","getInitialState","useEffect","microFrontendDiv","document","getElementById","console","warn","allConfigs","updateValues","prev","newAttributes","isChanged","keyConfig","find","config","getKeyConfig","getValueType","keyString","envVar","env","toUpperCase","attributeKey","domValue","getAttribute","toString","processAttribute","observer","MutationObserver","observe","disconnect"],"mappings":"gDASA,MAAMA,EAA6C,CACjD,SACA,SACA,CAAEC,IAAK,oBAAqBC,KAAM,YAuB9BC,EAAa,CAACC,EAAsBF,IACnCE,GAAkB,YAATF,EACD,YAATA,EAAqC,SAAVE,EAClB,WAATF,EAA0BG,OAAOD,GAC9BA,EAHkC,KAMrCE,EACJC,GAEO,IACFP,EAAmBQ,KAAKP,GAAwB,iBAARA,EAAmBA,EAAMA,EAAIA,SACrEM,EAAWC,KA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,MAAMkB,EAAW,IAAIC,iBAAiBnB,GAGtC,OAFAkB,EAASE,QAAQ1B,EAAkB,CAAET,YAAY,IAE1C,IAAMiC,EAASG,eACrB,CAACvC,IAEGG"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("react");const t=e=>{const t=document.getElementById("flipdish-micro-frontend");return t?.getAttribute(e)||""};exports.getAppId=()=>(void 0).VITE_APPID_OVERRIDE||t("data-
|
|
1
|
+
"use strict";var e=require("react");const t=e=>{const t=document.getElementById("flipdish-micro-frontend");return t?.getAttribute(e)||""};exports.getAppId=()=>(void 0).VITE_APPID_OVERRIDE||t("data-app-id")||t("data-appid"),exports.getBrandId=()=>(void 0).VITE_BRANDID_OVERRIDE||t("data-brand-id")||t("data-brandid"),exports.getIsFlipdishStaff=()=>{const e=(void 0).VITE_ISFLIPDISHSTAFFOVERRIDE||t("data-is-flipdish-staff")||t("data-isflipdishstaff");return"true"===e?.toString()},exports.getMicroFrontendAttribute=t,exports.getOrgId=()=>(void 0).VITE_ORGID_OVERRIDE||t("data-org-id")||t("data-orgid"),exports.lazyWithRetry=t=>e.lazy((async()=>{const e=JSON.parse(window.sessionStorage.getItem("page-has-been-force-refreshed")||"false");try{const e=await t();return window.sessionStorage.setItem("page-has-been-force-refreshed","false"),e}catch(t){if(!e)return window.sessionStorage.setItem("page-has-been-force-refreshed","true"),window.location.reload();throw t}}));
|
|
2
2
|
//# sourceMappingURL=renderUtilities.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderUtilities.cjs.js","sources":["../../src/utilities/renderUtilities.ts"],"sourcesContent":["import { lazy } from 'react';\n\nexport const getMicroFrontendAttribute = (key: string): string => {\n const microFrontendDiv = document.getElementById('flipdish-micro-frontend');\n return microFrontendDiv?.getAttribute(key) || '';\n};\n\n/**\n * Retrieves the AppId.\n *\n * Attempts to get the value from the environment variable `VITE_APPID_OVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-
|
|
1
|
+
{"version":3,"file":"renderUtilities.cjs.js","sources":["../../src/utilities/renderUtilities.ts"],"sourcesContent":["import { lazy } from 'react';\n\nexport const getMicroFrontendAttribute = (key: string): string => {\n const microFrontendDiv = document.getElementById('flipdish-micro-frontend');\n return microFrontendDiv?.getAttribute(key) || '';\n};\n\n/**\n * Retrieves the AppId.\n *\n * Attempts to get the value from the environment variable `VITE_APPID_OVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-app-id`.\n * Fallbacks to `data-appid` for backwards compatibility @flipdish/portal-library@5.1.0 and below\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getAppId = (): string => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return import.meta.env['VITE_APPID_OVERRIDE'] || getMicroFrontendAttribute('data-app-id') || getMicroFrontendAttribute('data-appid');\n};\n\n/**\n * Retrieves the OrgId.\n *\n * Attempts to get the value from the environment variable `VITE_ORGID_OVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-org-id`.\n * Fallbacks to `data-orgid` for backwards compatibility @flipdish/portal-library@5.1.0 and below\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getOrgId = (): string => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return import.meta.env['VITE_ORGID_OVERRIDE'] || getMicroFrontendAttribute('data-org-id') || getMicroFrontendAttribute('data-orgid');\n};\n\n/**\n * Retrieves the BrandId.\n *\n * Attempts to get the value from the environment variable `VITE_BRANDID_OVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-brand-id`.\n * Fallbacks to `data-brandid` for backwards compatibility @flipdish/portal-library@5.1.0 and below\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getBrandId = (): string => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return import.meta.env['VITE_BRANDID_OVERRIDE'] || getMicroFrontendAttribute('data-brand-id') || getMicroFrontendAttribute('data-brandid');\n};\n\n/**\n * Retrieves the isFlipdishStaff attribute.\n *\n * Attempts to get the value from the environment variable `VITE_ISFLIPDISHSTAFFOVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-is-flipdish-staff`.\n * Fallbacks to `data-isflipdishstaff` for backwards compatibility @flipdish/portal-library@5.1.0 and below\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getIsFlipdishStaff = (): boolean => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const stringValue =\n import.meta.env['VITE_ISFLIPDISHSTAFFOVERRIDE'] || getMicroFrontendAttribute('data-is-flipdish-staff') || getMicroFrontendAttribute('data-isflipdishstaff');\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access\n return stringValue?.toString() === 'true';\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const lazyWithRetry = (componentImport: () => any) =>\n lazy(async () => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const pageHasAlreadyBeenForceRefreshed = JSON.parse(\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n window.sessionStorage.getItem('page-has-been-force-refreshed') || 'false',\n );\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const component = await componentImport();\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n window.sessionStorage.setItem('page-has-been-force-refreshed', 'false');\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return component;\n } catch (error) {\n if (!pageHasAlreadyBeenForceRefreshed) {\n // Assuming that the user is not on the latest version of the application.\n // Let's refresh the page immediately.\n window.sessionStorage.setItem('page-has-been-force-refreshed', 'true');\n return window.location.reload();\n }\n\n // The page has already been reloaded\n // Assuming that user is already using the latest version of the application.\n // Let's let the application crash and raise the error.\n throw error;\n }\n });\n"],"names":["getMicroFrontendAttribute","key","microFrontendDiv","document","getElementById","getAttribute","undefined","stringValue","toString","componentImport","lazy","async","pageHasAlreadyBeenForceRefreshed","JSON","parse","window","sessionStorage","getItem","component","setItem","error","location","reload"],"mappings":"oCAEO,MAAMA,EAA6BC,IACxC,MAAMC,EAAmBC,SAASC,eAAe,2BACjD,OAAOF,GAAkBG,aAAaJ,IAAQ,qBAYxB,UAEfK,GAAqC,qBAAKN,EAA0B,gBAAkBA,EAA0B,iCA0B/F,UAEjBM,GAAuC,uBAAKN,EAA0B,kBAAoBA,EAA0B,2CAY3F,KAEhC,MAAMO,QACJD,GAA8C,8BAAKN,EAA0B,2BAA6BA,EAA0B,wBAEtI,MAAmC,SAA5BO,GAAaC,iEAjCE,UAEfF,GAAqC,qBAAKN,EAA0B,gBAAkBA,EAA0B,oCAmC3FS,GAC5BC,EAAAA,MAAKC,UAEH,MAAMC,EAAmCC,KAAKC,MAE5CC,OAAOC,eAAeC,QAAQ,kCAAoC,SAGpE,IAEE,MAAMC,QAAkBT,IAKxB,OAHAM,OAAOC,eAAeG,QAAQ,gCAAiC,SAGxDD,CACT,CAAE,MAAOE,GACP,IAAKR,EAIH,OADAG,OAAOC,eAAeG,QAAQ,gCAAiC,QACxDJ,OAAOM,SAASC,SAMzB,MAAMF,CACR"}
|
|
@@ -5,7 +5,8 @@ declare const getMicroFrontendAttribute: (key: string) => string;
|
|
|
5
5
|
* Retrieves the AppId.
|
|
6
6
|
*
|
|
7
7
|
* Attempts to get the value from the environment variable `VITE_APPID_OVERRIDE`.
|
|
8
|
-
* If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-
|
|
8
|
+
* If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-app-id`.
|
|
9
|
+
* Fallbacks to `data-appid` for backwards compatibility @flipdish/portal-library@5.1.0 and below
|
|
9
10
|
*
|
|
10
11
|
* @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.
|
|
11
12
|
*/
|
|
@@ -14,7 +15,8 @@ declare const getAppId: () => string;
|
|
|
14
15
|
* Retrieves the OrgId.
|
|
15
16
|
*
|
|
16
17
|
* Attempts to get the value from the environment variable `VITE_ORGID_OVERRIDE`.
|
|
17
|
-
* If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-
|
|
18
|
+
* If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-org-id`.
|
|
19
|
+
* Fallbacks to `data-orgid` for backwards compatibility @flipdish/portal-library@5.1.0 and below
|
|
18
20
|
*
|
|
19
21
|
* @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.
|
|
20
22
|
*/
|
|
@@ -23,7 +25,8 @@ declare const getOrgId: () => string;
|
|
|
23
25
|
* Retrieves the BrandId.
|
|
24
26
|
*
|
|
25
27
|
* Attempts to get the value from the environment variable `VITE_BRANDID_OVERRIDE`.
|
|
26
|
-
* If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-
|
|
28
|
+
* If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-brand-id`.
|
|
29
|
+
* Fallbacks to `data-brandid` for backwards compatibility @flipdish/portal-library@5.1.0 and below
|
|
27
30
|
*
|
|
28
31
|
* @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.
|
|
29
32
|
*/
|
|
@@ -32,7 +35,8 @@ declare const getBrandId: () => string;
|
|
|
32
35
|
* Retrieves the isFlipdishStaff attribute.
|
|
33
36
|
*
|
|
34
37
|
* Attempts to get the value from the environment variable `VITE_ISFLIPDISHSTAFFOVERRIDE`.
|
|
35
|
-
* If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-
|
|
38
|
+
* If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-is-flipdish-staff`.
|
|
39
|
+
* Fallbacks to `data-isflipdishstaff` for backwards compatibility @flipdish/portal-library@5.1.0 and below
|
|
36
40
|
*
|
|
37
41
|
* @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.
|
|
38
42
|
*/
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{lazy as e}from"react";const t=e=>{const t=document.getElementById("flipdish-micro-frontend");return t?.getAttribute(e)||""},
|
|
1
|
+
import{lazy as e}from"react";const t=e=>{const t=document.getElementById("flipdish-micro-frontend");return t?.getAttribute(e)||""},a=()=>import.meta.env.VITE_APPID_OVERRIDE||t("data-app-id")||t("data-appid"),r=()=>import.meta.env.VITE_ORGID_OVERRIDE||t("data-org-id")||t("data-orgid"),o=()=>import.meta.env.VITE_BRANDID_OVERRIDE||t("data-brand-id")||t("data-brandid"),s=()=>{const e=import.meta.env.VITE_ISFLIPDISHSTAFFOVERRIDE||t("data-is-flipdish-staff")||t("data-isflipdishstaff");return"true"===e?.toString()},i=t=>e((async()=>{const e=JSON.parse(window.sessionStorage.getItem("page-has-been-force-refreshed")||"false");try{const e=await t();return window.sessionStorage.setItem("page-has-been-force-refreshed","false"),e}catch(t){if(!e)return window.sessionStorage.setItem("page-has-been-force-refreshed","true"),window.location.reload();throw t}}));export{a as getAppId,o as getBrandId,s as getIsFlipdishStaff,t as getMicroFrontendAttribute,r as getOrgId,i as lazyWithRetry};
|
|
2
2
|
//# sourceMappingURL=renderUtilities.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderUtilities.js","sources":["../../src/utilities/renderUtilities.ts"],"sourcesContent":["import { lazy } from 'react';\n\nexport const getMicroFrontendAttribute = (key: string): string => {\n const microFrontendDiv = document.getElementById('flipdish-micro-frontend');\n return microFrontendDiv?.getAttribute(key) || '';\n};\n\n/**\n * Retrieves the AppId.\n *\n * Attempts to get the value from the environment variable `VITE_APPID_OVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-
|
|
1
|
+
{"version":3,"file":"renderUtilities.js","sources":["../../src/utilities/renderUtilities.ts"],"sourcesContent":["import { lazy } from 'react';\n\nexport const getMicroFrontendAttribute = (key: string): string => {\n const microFrontendDiv = document.getElementById('flipdish-micro-frontend');\n return microFrontendDiv?.getAttribute(key) || '';\n};\n\n/**\n * Retrieves the AppId.\n *\n * Attempts to get the value from the environment variable `VITE_APPID_OVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-app-id`.\n * Fallbacks to `data-appid` for backwards compatibility @flipdish/portal-library@5.1.0 and below\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getAppId = (): string => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return import.meta.env['VITE_APPID_OVERRIDE'] || getMicroFrontendAttribute('data-app-id') || getMicroFrontendAttribute('data-appid');\n};\n\n/**\n * Retrieves the OrgId.\n *\n * Attempts to get the value from the environment variable `VITE_ORGID_OVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-org-id`.\n * Fallbacks to `data-orgid` for backwards compatibility @flipdish/portal-library@5.1.0 and below\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getOrgId = (): string => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return import.meta.env['VITE_ORGID_OVERRIDE'] || getMicroFrontendAttribute('data-org-id') || getMicroFrontendAttribute('data-orgid');\n};\n\n/**\n * Retrieves the BrandId.\n *\n * Attempts to get the value from the environment variable `VITE_BRANDID_OVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-brand-id`.\n * Fallbacks to `data-brandid` for backwards compatibility @flipdish/portal-library@5.1.0 and below\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getBrandId = (): string => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return import.meta.env['VITE_BRANDID_OVERRIDE'] || getMicroFrontendAttribute('data-brand-id') || getMicroFrontendAttribute('data-brandid');\n};\n\n/**\n * Retrieves the isFlipdishStaff attribute.\n *\n * Attempts to get the value from the environment variable `VITE_ISFLIPDISHSTAFFOVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-is-flipdish-staff`.\n * Fallbacks to `data-isflipdishstaff` for backwards compatibility @flipdish/portal-library@5.1.0 and below\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getIsFlipdishStaff = (): boolean => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const stringValue =\n import.meta.env['VITE_ISFLIPDISHSTAFFOVERRIDE'] || getMicroFrontendAttribute('data-is-flipdish-staff') || getMicroFrontendAttribute('data-isflipdishstaff');\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access\n return stringValue?.toString() === 'true';\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const lazyWithRetry = (componentImport: () => any) =>\n lazy(async () => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const pageHasAlreadyBeenForceRefreshed = JSON.parse(\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n window.sessionStorage.getItem('page-has-been-force-refreshed') || 'false',\n );\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const component = await componentImport();\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n window.sessionStorage.setItem('page-has-been-force-refreshed', 'false');\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return component;\n } catch (error) {\n if (!pageHasAlreadyBeenForceRefreshed) {\n // Assuming that the user is not on the latest version of the application.\n // Let's refresh the page immediately.\n window.sessionStorage.setItem('page-has-been-force-refreshed', 'true');\n return window.location.reload();\n }\n\n // The page has already been reloaded\n // Assuming that user is already using the latest version of the application.\n // Let's let the application crash and raise the error.\n throw error;\n }\n });\n"],"names":["getMicroFrontendAttribute","key","microFrontendDiv","document","getElementById","getAttribute","getAppId","env","getOrgId","getBrandId","getIsFlipdishStaff","stringValue","toString","lazyWithRetry","componentImport","lazy","async","pageHasAlreadyBeenForceRefreshed","JSON","parse","window","sessionStorage","getItem","component","setItem","error","location","reload"],"mappings":"6BAEO,MAAMA,EAA6BC,IACxC,MAAMC,EAAmBC,SAASC,eAAe,2BACjD,OAAOF,GAAkBG,aAAaJ,IAAQ,IAYnCK,EAAW,gBAEHC,IAAyB,qBAAKP,EAA0B,gBAAkBA,EAA0B,cAY5GQ,EAAW,gBAEHD,IAAyB,qBAAKP,EAA0B,gBAAkBA,EAA0B,cAY5GS,EAAa,gBAELF,IAA2B,uBAAKP,EAA0B,kBAAoBA,EAA0B,gBAYhHU,EAAqB,KAEhC,MAAMC,cACQJ,IAAkC,8BAAKP,EAA0B,2BAA6BA,EAA0B,wBAEtI,MAAmC,SAA5BW,GAAaC,YAITC,EAAiBC,GAC5BC,GAAKC,UAEH,MAAMC,EAAmCC,KAAKC,MAE5CC,OAAOC,eAAeC,QAAQ,kCAAoC,SAGpE,IAEE,MAAMC,QAAkBT,IAKxB,OAHAM,OAAOC,eAAeG,QAAQ,gCAAiC,SAGxDD,CACT,CAAE,MAAOE,GACP,IAAKR,EAIH,OADAG,OAAOC,eAAeG,QAAQ,gCAAiC,QACxDJ,OAAOM,SAASC,SAMzB,MAAMF,CACR"}
|