@favish/staffbase-utils 0.14.0 → 0.16.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/README.md +3 -1
- package/dist/device.cjs.js +1 -1
- package/dist/device.cjs.js.map +1 -1
- package/dist/device.es.mjs +2 -2
- package/dist/device.es.mjs.map +1 -1
- package/dist/host.cjs.js +2 -0
- package/dist/host.cjs.js.map +1 -0
- package/dist/host.es.mjs +10 -0
- package/dist/host.es.mjs.map +1 -0
- package/dist/shadow/portal.cjs.js +1 -0
- package/dist/shadow/portal.es.mjs +2 -0
- package/dist/shadow/react.cjs.js +1 -1
- package/dist/shadow/react.cjs.js.map +1 -1
- package/dist/shadow/react.es.mjs +10 -10
- package/dist/shadow/react.es.mjs.map +1 -1
- package/dist/src/device/index.d.ts +2 -0
- package/dist/src/device/index.d.ts.map +1 -1
- package/dist/src/device/isMobilePlatform.d.ts +7 -0
- package/dist/src/device/isMobilePlatform.d.ts.map +1 -0
- package/dist/src/device/isNativeApp.d.ts +7 -0
- package/dist/src/device/isNativeApp.d.ts.map +1 -0
- package/dist/src/host/getStaffbaseCsrfToken.d.ts +11 -0
- package/dist/src/host/getStaffbaseCsrfToken.d.ts.map +1 -0
- package/dist/src/host/index.d.ts +2 -0
- package/dist/src/host/index.d.ts.map +1 -0
- package/dist/src/shadow/portal/PortalContainerContext.d.ts.map +1 -0
- package/dist/src/shadow/portal/PortalContainerProvider.d.ts.map +1 -0
- package/dist/src/shadow/portal/index.d.ts +4 -0
- package/dist/src/shadow/portal/index.d.ts.map +1 -0
- package/dist/src/shadow/portal/usePortalContainer.d.ts.map +1 -0
- package/dist/src/shadow/react/index.d.ts +3 -3
- package/dist/src/shadow/react/index.d.ts.map +1 -1
- package/dist/src/types/device/WindowWithStaffbaseRuntime.d.ts +12 -0
- package/dist/src/types/device/WindowWithStaffbaseRuntime.d.ts.map +1 -0
- package/dist/src/types/host/WindowWithStaffbaseAuth.d.ts +13 -0
- package/dist/src/types/host/WindowWithStaffbaseAuth.d.ts.map +1 -0
- package/dist/usePortalContainer-BYW2B6g7.mjs +7 -0
- package/dist/usePortalContainer-BYW2B6g7.mjs.map +1 -0
- package/dist/usePortalContainer-BcMPb5ai.js +2 -0
- package/dist/usePortalContainer-BcMPb5ai.js.map +1 -0
- package/package.json +12 -1
- package/dist/src/shadow/react/PortalContainerContext.d.ts.map +0 -1
- package/dist/src/shadow/react/PortalContainerProvider.d.ts.map +0 -1
- package/dist/src/shadow/react/usePortalContainer.d.ts.map +0 -1
- /package/dist/src/shadow/{react → portal}/PortalContainerContext.d.ts +0 -0
- /package/dist/src/shadow/{react → portal}/PortalContainerProvider.d.ts +0 -0
- /package/dist/src/shadow/{react → portal}/usePortalContainer.d.ts +0 -0
package/README.md
CHANGED
|
@@ -27,9 +27,11 @@ minimumReleaseAgeExclude:
|
|
|
27
27
|
| `@favish/staffbase-utils/content` | `resolveLocalizedContent`, `resolveActiveLanguage`, `detectEditorLanguage`, `detectPreviewLanguage` |
|
|
28
28
|
| `@favish/staffbase-utils/links/react` | `useInAppLinkHandling` (React peer) |
|
|
29
29
|
| `@favish/staffbase-utils/shadow` | `injectShadowStyles`, `isShadowRoot` |
|
|
30
|
-
| `@favish/staffbase-utils/shadow/
|
|
30
|
+
| `@favish/staffbase-utils/shadow/portal` | `PortalContainerProvider`, `usePortalContainer` (React peer only, no Emotion) |
|
|
31
|
+
| `@favish/staffbase-utils/shadow/react` | `ensureShadowMount` (+ re-exports portal) (React + @emotion/cache peers) |
|
|
31
32
|
| `@favish/staffbase-utils/log` | `logError`, `logWarn`, `logDebug`, `setLoggingEnabled` |
|
|
32
33
|
| `@favish/staffbase-utils/dom` | `getDynamicClasses` |
|
|
34
|
+
| `@favish/staffbase-utils/host` | `getStaffbaseCsrfToken` |
|
|
33
35
|
| `@favish/staffbase-utils/types` | `Channel`, `ChannelLink`, `ChannelLinkParameter`, `DropdownOption`, `LocalizedContent`, `ArticleImage`, `ArticleImageVariant` (type-only) |
|
|
34
36
|
|
|
35
37
|
More modules (`/env`, `/device`, `/html`, `/links`, `/widgets`) are added per the
|
package/dist/device.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=()=>{if(typeof navigator>`u`)return!1;let e=navigator.userAgent.toLowerCase(),t=/mobile|android|ios|iphone|ipad|ipod|windows phone/i.test(e),n=/wv|webview/i.test(e);return t||n},t=()=>typeof window>`u`?!1:window.innerWidth<=768,n=()=>e()||t();exports.isMobile=n,exports.isMobileOrWebview=e,exports.isMobileViewport=t;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=()=>{if(typeof navigator>`u`)return!1;let e=navigator.userAgent.toLowerCase(),t=/mobile|android|ios|iphone|ipad|ipod|windows phone/i.test(e),n=/wv|webview/i.test(e);return t||n},t=()=>typeof window>`u`?!1:window.innerWidth<=768,n=()=>e()||t(),r=()=>typeof window>`u`?!1:window.we?.mobile===!0||n(),i=()=>typeof window>`u`?!1:window.we?.native===!0;exports.isMobile=n,exports.isMobileOrWebview=e,exports.isMobilePlatform=r,exports.isMobileViewport=t,exports.isNativeApp=i;
|
|
2
2
|
//# sourceMappingURL=device.cjs.js.map
|
package/dist/device.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device.cjs.js","names":[],"sources":["../src/device/isMobileOrWebview.ts","../src/device/isMobileViewport.ts","../src/device/isMobile.ts"],"sourcesContent":["/**\n * Detects if the current environment is a mobile device or running inside a\n * webview, using userAgent heuristics common on iOS/Android and webviews.\n * Guards against non-browser environments (SSR/tests without navigator).\n * @returns {boolean} True if likely mobile or webview.\n */\nexport const isMobileOrWebview = (): boolean => {\n if (typeof navigator === 'undefined') return false\n\n const userAgent = navigator.userAgent.toLowerCase()\n const isMobilePlatform =\n /mobile|android|ios|iphone|ipad|ipod|windows phone/i.test(userAgent)\n const isWebview = /wv|webview/i.test(userAgent)\n\n return isMobilePlatform || isWebview\n}\n","/**\n * Checks if the viewport width is mobile-sized (<= 768px).\n * Guards against non-browser environments (SSR/tests without window).\n * @returns {boolean} True if the viewport width is 768px or less.\n */\nexport const isMobileViewport = (): boolean => {\n if (typeof window === 'undefined') return false\n return window.innerWidth <= 768\n}\n","import { isMobileOrWebview } from './isMobileOrWebview'\nimport { isMobileViewport } from './isMobileViewport'\n\n/**\n * Checks if the device is mobile either by user agent/webview or viewport size.\n * @returns {boolean} True if either a mobile/webview UA or a mobile viewport.\n */\nexport const isMobile = (): boolean => isMobileOrWebview() || isMobileViewport()\n"],"mappings":"mEAMA,IAAa,MAAmC,CAC9C,GAAI,OAAO,UAAc,IAAa,MAAO,GAE7C,IAAM,EAAY,UAAU,UAAU,YAAY,EAC5C,EACJ,qDAAqD,KAAK,CAAS,EAC/D,EAAY,cAAc,KAAK,CAAS,EAE9C,OAAO,GAAoB,CAC7B,ECVa,MACP,OAAO,OAAW,IAAoB,GACnC,OAAO,YAAc,ICAjB,MAA0B,EAAkB,GAAK,EAAiB"}
|
|
1
|
+
{"version":3,"file":"device.cjs.js","names":[],"sources":["../src/device/isMobileOrWebview.ts","../src/device/isMobileViewport.ts","../src/device/isMobile.ts","../src/device/isMobilePlatform.ts","../src/device/isNativeApp.ts"],"sourcesContent":["/**\n * Detects if the current environment is a mobile device or running inside a\n * webview, using userAgent heuristics common on iOS/Android and webviews.\n * Guards against non-browser environments (SSR/tests without navigator).\n * @returns {boolean} True if likely mobile or webview.\n */\nexport const isMobileOrWebview = (): boolean => {\n if (typeof navigator === 'undefined') return false\n\n const userAgent = navigator.userAgent.toLowerCase()\n const isMobilePlatform =\n /mobile|android|ios|iphone|ipad|ipod|windows phone/i.test(userAgent)\n const isWebview = /wv|webview/i.test(userAgent)\n\n return isMobilePlatform || isWebview\n}\n","/**\n * Checks if the viewport width is mobile-sized (<= 768px).\n * Guards against non-browser environments (SSR/tests without window).\n * @returns {boolean} True if the viewport width is 768px or less.\n */\nexport const isMobileViewport = (): boolean => {\n if (typeof window === 'undefined') return false\n return window.innerWidth <= 768\n}\n","import { isMobileOrWebview } from './isMobileOrWebview'\nimport { isMobileViewport } from './isMobileViewport'\n\n/**\n * Checks if the device is mobile either by user agent/webview or viewport size.\n * @returns {boolean} True if either a mobile/webview UA or a mobile viewport.\n */\nexport const isMobile = (): boolean => isMobileOrWebview() || isMobileViewport()\n","import type { WindowWithStaffbaseRuntime } from '../types/device/WindowWithStaffbaseRuntime'\nimport { isMobile } from './isMobile'\n\n/**\n * Whether the app is running on a mobile platform, per the `window.we.mobile`\n * runtime flag or device detection. Returns false outside a browser.\n * @returns {boolean} True when running on a mobile platform.\n */\nexport const isMobilePlatform = (): boolean => {\n if (typeof window === 'undefined') return false\n\n return (\n (window as unknown as WindowWithStaffbaseRuntime).we?.mobile === true ||\n isMobile()\n )\n}\n","import type { WindowWithStaffbaseRuntime } from '../types/device/WindowWithStaffbaseRuntime'\n\n/**\n * Whether the app is running inside the Staffbase native shell, per the\n * `window.we.native` runtime flag. Returns false outside a browser.\n * @returns {boolean} True when running in the native app.\n */\nexport const isNativeApp = (): boolean => {\n if (typeof window === 'undefined') return false\n\n return (window as unknown as WindowWithStaffbaseRuntime).we?.native === true\n}\n"],"mappings":"mEAMA,IAAa,MAAmC,CAC9C,GAAI,OAAO,UAAc,IAAa,MAAO,GAE7C,IAAM,EAAY,UAAU,UAAU,YAAY,EAC5C,EACJ,qDAAqD,KAAK,CAAS,EAC/D,EAAY,cAAc,KAAK,CAAS,EAE9C,OAAO,GAAoB,CAC7B,ECVa,MACP,OAAO,OAAW,IAAoB,GACnC,OAAO,YAAc,ICAjB,MAA0B,EAAkB,GAAK,EAAiB,ECClE,MACP,OAAO,OAAW,IAAoB,GAGvC,OAAiD,IAAI,SAAW,IACjE,EAAS,ECNA,MACP,OAAO,OAAW,IAAoB,GAElC,OAAiD,IAAI,SAAW"}
|
package/dist/device.es.mjs
CHANGED
|
@@ -3,8 +3,8 @@ var e = () => {
|
|
|
3
3
|
if (typeof navigator > "u") return !1;
|
|
4
4
|
let e = navigator.userAgent.toLowerCase(), t = /mobile|android|ios|iphone|ipad|ipod|windows phone/i.test(e), n = /wv|webview/i.test(e);
|
|
5
5
|
return t || n;
|
|
6
|
-
}, t = () => typeof window > "u" ? !1 : window.innerWidth <= 768, n = () => e() || t();
|
|
6
|
+
}, t = () => typeof window > "u" ? !1 : window.innerWidth <= 768, n = () => e() || t(), r = () => typeof window > "u" ? !1 : window.we?.mobile === !0 || n(), i = () => typeof window > "u" ? !1 : window.we?.native === !0;
|
|
7
7
|
//#endregion
|
|
8
|
-
export { n as isMobile, e as isMobileOrWebview, t as isMobileViewport };
|
|
8
|
+
export { n as isMobile, e as isMobileOrWebview, r as isMobilePlatform, t as isMobileViewport, i as isNativeApp };
|
|
9
9
|
|
|
10
10
|
//# sourceMappingURL=device.es.mjs.map
|
package/dist/device.es.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device.es.mjs","names":[],"sources":["../src/device/isMobileOrWebview.ts","../src/device/isMobileViewport.ts","../src/device/isMobile.ts"],"sourcesContent":["/**\n * Detects if the current environment is a mobile device or running inside a\n * webview, using userAgent heuristics common on iOS/Android and webviews.\n * Guards against non-browser environments (SSR/tests without navigator).\n * @returns {boolean} True if likely mobile or webview.\n */\nexport const isMobileOrWebview = (): boolean => {\n if (typeof navigator === 'undefined') return false\n\n const userAgent = navigator.userAgent.toLowerCase()\n const isMobilePlatform =\n /mobile|android|ios|iphone|ipad|ipod|windows phone/i.test(userAgent)\n const isWebview = /wv|webview/i.test(userAgent)\n\n return isMobilePlatform || isWebview\n}\n","/**\n * Checks if the viewport width is mobile-sized (<= 768px).\n * Guards against non-browser environments (SSR/tests without window).\n * @returns {boolean} True if the viewport width is 768px or less.\n */\nexport const isMobileViewport = (): boolean => {\n if (typeof window === 'undefined') return false\n return window.innerWidth <= 768\n}\n","import { isMobileOrWebview } from './isMobileOrWebview'\nimport { isMobileViewport } from './isMobileViewport'\n\n/**\n * Checks if the device is mobile either by user agent/webview or viewport size.\n * @returns {boolean} True if either a mobile/webview UA or a mobile viewport.\n */\nexport const isMobile = (): boolean => isMobileOrWebview() || isMobileViewport()\n"],"mappings":";AAMA,IAAa,UAAmC;CAC9C,IAAI,OAAO,YAAc,KAAa,OAAO;CAE7C,IAAM,IAAY,UAAU,UAAU,YAAY,GAC5C,IACJ,qDAAqD,KAAK,CAAS,GAC/D,IAAY,cAAc,KAAK,CAAS;CAE9C,OAAO,KAAoB;AAC7B,GCVa,UACP,OAAO,SAAW,MAAoB,KACnC,OAAO,cAAc,KCAjB,UAA0B,EAAkB,KAAK,EAAiB"}
|
|
1
|
+
{"version":3,"file":"device.es.mjs","names":[],"sources":["../src/device/isMobileOrWebview.ts","../src/device/isMobileViewport.ts","../src/device/isMobile.ts","../src/device/isMobilePlatform.ts","../src/device/isNativeApp.ts"],"sourcesContent":["/**\n * Detects if the current environment is a mobile device or running inside a\n * webview, using userAgent heuristics common on iOS/Android and webviews.\n * Guards against non-browser environments (SSR/tests without navigator).\n * @returns {boolean} True if likely mobile or webview.\n */\nexport const isMobileOrWebview = (): boolean => {\n if (typeof navigator === 'undefined') return false\n\n const userAgent = navigator.userAgent.toLowerCase()\n const isMobilePlatform =\n /mobile|android|ios|iphone|ipad|ipod|windows phone/i.test(userAgent)\n const isWebview = /wv|webview/i.test(userAgent)\n\n return isMobilePlatform || isWebview\n}\n","/**\n * Checks if the viewport width is mobile-sized (<= 768px).\n * Guards against non-browser environments (SSR/tests without window).\n * @returns {boolean} True if the viewport width is 768px or less.\n */\nexport const isMobileViewport = (): boolean => {\n if (typeof window === 'undefined') return false\n return window.innerWidth <= 768\n}\n","import { isMobileOrWebview } from './isMobileOrWebview'\nimport { isMobileViewport } from './isMobileViewport'\n\n/**\n * Checks if the device is mobile either by user agent/webview or viewport size.\n * @returns {boolean} True if either a mobile/webview UA or a mobile viewport.\n */\nexport const isMobile = (): boolean => isMobileOrWebview() || isMobileViewport()\n","import type { WindowWithStaffbaseRuntime } from '../types/device/WindowWithStaffbaseRuntime'\nimport { isMobile } from './isMobile'\n\n/**\n * Whether the app is running on a mobile platform, per the `window.we.mobile`\n * runtime flag or device detection. Returns false outside a browser.\n * @returns {boolean} True when running on a mobile platform.\n */\nexport const isMobilePlatform = (): boolean => {\n if (typeof window === 'undefined') return false\n\n return (\n (window as unknown as WindowWithStaffbaseRuntime).we?.mobile === true ||\n isMobile()\n )\n}\n","import type { WindowWithStaffbaseRuntime } from '../types/device/WindowWithStaffbaseRuntime'\n\n/**\n * Whether the app is running inside the Staffbase native shell, per the\n * `window.we.native` runtime flag. Returns false outside a browser.\n * @returns {boolean} True when running in the native app.\n */\nexport const isNativeApp = (): boolean => {\n if (typeof window === 'undefined') return false\n\n return (window as unknown as WindowWithStaffbaseRuntime).we?.native === true\n}\n"],"mappings":";AAMA,IAAa,UAAmC;CAC9C,IAAI,OAAO,YAAc,KAAa,OAAO;CAE7C,IAAM,IAAY,UAAU,UAAU,YAAY,GAC5C,IACJ,qDAAqD,KAAK,CAAS,GAC/D,IAAY,cAAc,KAAK,CAAS;CAE9C,OAAO,KAAoB;AAC7B,GCVa,UACP,OAAO,SAAW,MAAoB,KACnC,OAAO,cAAc,KCAjB,UAA0B,EAAkB,KAAK,EAAiB,GCClE,UACP,OAAO,SAAW,MAAoB,KAGvC,OAAiD,IAAI,WAAW,MACjE,EAAS,GCNA,UACP,OAAO,SAAW,MAAoB,KAElC,OAAiD,IAAI,WAAW"}
|
package/dist/host.cjs.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.cjs.js","names":[],"sources":["../src/host/getStaffbaseCsrfToken.ts"],"sourcesContent":["import type { WindowWithStaffbaseAuth } from '../types/host/WindowWithStaffbaseAuth'\n\n/**\n * Reads the Staffbase CSRF token from the host's global auth manager\n * (`window.we.authMgr.getCsrfToken`).\n *\n * Returns null (instead of an empty string) when the token is unavailable, so\n * callers can fail fast with a clear message rather than firing a request the\n * server is guaranteed to reject with a 403.\n * @returns {string | null} The CSRF token, or null when it cannot be resolved.\n */\nexport const getStaffbaseCsrfToken = (): string | null => {\n if (typeof window === 'undefined') return null\n\n const w = window as unknown as WindowWithStaffbaseAuth\n const token = w?.we?.authMgr?.getCsrfToken?.()\n\n return token && token.length > 0 ? token : null\n}\n"],"mappings":"mEAWA,IAAa,MAA6C,CACxD,GAAI,OAAO,OAAW,IAAa,OAAO,KAG1C,IAAM,EAAQ,QAAG,IAAI,SAAS,eAAe,EAE7C,OAAO,GAAS,EAAM,OAAS,EAAI,EAAQ,IAC7C"}
|
package/dist/host.es.mjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/host/getStaffbaseCsrfToken.ts
|
|
2
|
+
var e = () => {
|
|
3
|
+
if (typeof window > "u") return null;
|
|
4
|
+
let e = window?.we?.authMgr?.getCsrfToken?.();
|
|
5
|
+
return e && e.length > 0 ? e : null;
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { e as getStaffbaseCsrfToken };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=host.es.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.es.mjs","names":[],"sources":["../src/host/getStaffbaseCsrfToken.ts"],"sourcesContent":["import type { WindowWithStaffbaseAuth } from '../types/host/WindowWithStaffbaseAuth'\n\n/**\n * Reads the Staffbase CSRF token from the host's global auth manager\n * (`window.we.authMgr.getCsrfToken`).\n *\n * Returns null (instead of an empty string) when the token is unavailable, so\n * callers can fail fast with a clear message rather than firing a request the\n * server is guaranteed to reject with a 403.\n * @returns {string | null} The CSRF token, or null when it cannot be resolved.\n */\nexport const getStaffbaseCsrfToken = (): string | null => {\n if (typeof window === 'undefined') return null\n\n const w = window as unknown as WindowWithStaffbaseAuth\n const token = w?.we?.authMgr?.getCsrfToken?.()\n\n return token && token.length > 0 ? token : null\n}\n"],"mappings":";AAWA,IAAa,UAA6C;CACxD,IAAI,OAAO,SAAW,KAAa,OAAO;CAG1C,IAAM,IAAQ,QAAG,IAAI,SAAS,eAAe;CAE7C,OAAO,KAAS,EAAM,SAAS,IAAI,IAAQ;AAC7C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../usePortalContainer-BcMPb5ai.js");exports.PortalContainerProvider=e.n,exports.usePortalContainer=e.t;
|
package/dist/shadow/react.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../chunk-CMqjfN_6.js"),t=require("../injectShadowStyles-SjxVBpXH.js")
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../chunk-CMqjfN_6.js"),t=require("../injectShadowStyles-SjxVBpXH.js"),n=require("../usePortalContainer-BcMPb5ai.js");let r=require("@emotion/cache");r=e.t(r);var i=(e,t)=>{let n=e.getElementById(t);if(n instanceof HTMLDivElement)return n;let r=document.createElement(`div`);return r.id=t,e.appendChild(r),r},a=(e,t)=>{let n=e.getElementById(t);if(n instanceof HTMLMetaElement)return n;let r=document.createElement(`meta`);return r.id=t,r.setAttribute(`name`,`emotion-insertion-point`),e.appendChild(r),r},o=`sbu-shadow-styles`,s=`sbu-react-root`,c=`sbu-portal-root`,l=`sbu-emotion-insertion-point`,u=(e,{cacheKey:n,cssText:u})=>{let d=e.shadowRoot??e.attachShadow({mode:`open`}),f=i(d,`${s}-${n}`),p=i(d,`${c}-${n}`),m=a(d,`${l}-${n}`);return t.t(d,u,`${o}-${n}`),{shadowRoot:d,reactMountEl:f,portalContainerEl:p,emotionCache:(0,r.default)({key:n,container:d,insertionPoint:m})}};exports.PortalContainerProvider=n.n,exports.ensureShadowMount=u,exports.usePortalContainer=n.t;
|
|
2
2
|
//# sourceMappingURL=react.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.cjs.js","names":[],"sources":["../../src/shadow/react/getOrCreateDiv.ts","../../src/shadow/react/getOrCreateEmotionInsertionPoint.ts","../../src/shadow/react/ensureShadowMount.ts"
|
|
1
|
+
{"version":3,"file":"react.cjs.js","names":[],"sources":["../../src/shadow/react/getOrCreateDiv.ts","../../src/shadow/react/getOrCreateEmotionInsertionPoint.ts","../../src/shadow/react/ensureShadowMount.ts"],"sourcesContent":["/**\n * Returns the shadow-root child `<div>` with the given id, creating it if absent.\n * @param {ShadowRoot} root - The shadow root to search/append within.\n * @param {string} id - The element id.\n * @returns {HTMLDivElement} The existing or newly created div.\n */\nexport const getOrCreateDiv = (\n root: ShadowRoot,\n id: string,\n): HTMLDivElement => {\n const existing = root.getElementById(id)\n if (existing instanceof HTMLDivElement) return existing\n\n const el = document.createElement('div')\n el.id = id\n root.appendChild(el)\n return el\n}\n","/**\n * Returns the shadow-root `<meta name=\"emotion-insertion-point\">` with the given\n * id, creating it if absent. Keeps Emotion's styles ordered before shadow content.\n * @param {ShadowRoot} root - The shadow root to search/append within.\n * @param {string} id - The element id.\n * @returns {HTMLMetaElement} The existing or newly created insertion-point meta.\n */\nexport const getOrCreateEmotionInsertionPoint = (\n root: ShadowRoot,\n id: string,\n): HTMLMetaElement => {\n const existing = root.getElementById(id)\n if (existing instanceof HTMLMetaElement) return existing\n\n const el = document.createElement('meta')\n el.id = id\n el.setAttribute('name', 'emotion-insertion-point')\n root.appendChild(el)\n return el\n}\n","import createCache from '@emotion/cache'\n\nimport type { EnsureShadowMountOptions } from '../../types/shadow/EnsureShadowMountOptions'\nimport type { ShadowMount } from '../../types/shadow/ShadowMount'\nimport { injectShadowStyles } from '../injectShadowStyles'\nimport { getOrCreateDiv } from './getOrCreateDiv'\nimport { getOrCreateEmotionInsertionPoint } from './getOrCreateEmotionInsertionPoint'\n\nconst STYLE_ELEMENT_ID = 'sbu-shadow-styles'\nconst REACT_MOUNT_ID = 'sbu-react-root'\nconst PORTAL_CONTAINER_ID = 'sbu-portal-root'\nconst EMOTION_INSERTION_POINT_ID = 'sbu-emotion-insertion-point'\n\n/**\n * Ensures a ShadowRoot mount exists on the host element for a widget.\n *\n * Creates stable React-mount and portal-container nodes, injects the widget's CSS\n * into the shadow root only (never into the document), and configures an Emotion\n * cache scoped to the shadow root. All internal ids are namespaced by `cacheKey`\n * so editor and runtime mounts on the same host never collide.\n * @param {HTMLElement} host - The host element to attach the shadow root to.\n * @param {EnsureShadowMountOptions} options - The cache key and the widget's CSS text.\n * @returns {ShadowMount} The shadow root, mount nodes and the scoped Emotion cache.\n */\nexport const ensureShadowMount = (\n host: HTMLElement,\n { cacheKey, cssText }: EnsureShadowMountOptions,\n): ShadowMount => {\n const shadowRoot = host.shadowRoot ?? host.attachShadow({ mode: 'open' })\n\n const reactMountEl = getOrCreateDiv(\n shadowRoot,\n `${REACT_MOUNT_ID}-${cacheKey}`,\n )\n const portalContainerEl = getOrCreateDiv(\n shadowRoot,\n `${PORTAL_CONTAINER_ID}-${cacheKey}`,\n )\n const insertionPoint = getOrCreateEmotionInsertionPoint(\n shadowRoot,\n `${EMOTION_INSERTION_POINT_ID}-${cacheKey}`,\n )\n\n injectShadowStyles(shadowRoot, cssText, `${STYLE_ELEMENT_ID}-${cacheKey}`)\n\n // Emotion's `container` is typed as HTMLElement but supports ShadowRoot targets\n // at runtime; the localized cast keeps the rest of the call type-safe.\n const emotionCache = createCache({\n key: cacheKey,\n container: shadowRoot as unknown as HTMLElement,\n insertionPoint,\n })\n\n return { shadowRoot, reactMountEl, portalContainerEl, emotionCache }\n}\n"],"mappings":"kPAMA,IAAa,GACX,EACA,IACmB,CACnB,IAAM,EAAW,EAAK,eAAe,CAAE,EACvC,GAAI,aAAoB,eAAgB,OAAO,EAE/C,IAAM,EAAK,SAAS,cAAc,KAAK,EAGvC,MAFA,GAAG,GAAK,EACR,EAAK,YAAY,CAAE,EACZ,CACT,ECVa,GACX,EACA,IACoB,CACpB,IAAM,EAAW,EAAK,eAAe,CAAE,EACvC,GAAI,aAAoB,gBAAiB,OAAO,EAEhD,IAAM,EAAK,SAAS,cAAc,MAAM,EAIxC,MAHA,GAAG,GAAK,EACR,EAAG,aAAa,OAAQ,yBAAyB,EACjD,EAAK,YAAY,CAAE,EACZ,CACT,ECXM,EAAmB,oBACnB,EAAiB,iBACjB,EAAsB,kBACtB,EAA6B,8BAatB,GACX,EACA,CAAE,WAAU,aACI,CAChB,IAAM,EAAa,EAAK,YAAc,EAAK,aAAa,CAAE,KAAM,MAAO,CAAC,EAElE,EAAe,EACnB,EACA,GAAG,EAAe,GAAG,GACvB,EACM,EAAoB,EACxB,EACA,GAAG,EAAoB,GAAG,GAC5B,EACM,EAAiB,EACrB,EACA,GAAG,EAA2B,GAAG,GACnC,EAYA,OAVA,EAAA,EAAmB,EAAY,EAAS,GAAG,EAAiB,GAAG,GAAU,EAUlE,CAAE,aAAY,eAAc,oBAAmB,cAAA,EAAA,EAAA,SANrB,CAC/B,IAAK,EACL,UAAW,EACX,gBACF,CAEsD,CAAa,CACrE"}
|
package/dist/shadow/react.es.mjs
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import { t as e } from "../injectShadowStyles-C40qdwKI.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { n as t, t as n } from "../usePortalContainer-BYW2B6g7.mjs";
|
|
3
|
+
import r from "@emotion/cache";
|
|
4
4
|
//#region src/shadow/react/getOrCreateDiv.ts
|
|
5
|
-
var
|
|
5
|
+
var i = (e, t) => {
|
|
6
6
|
let n = e.getElementById(t);
|
|
7
7
|
if (n instanceof HTMLDivElement) return n;
|
|
8
8
|
let r = document.createElement("div");
|
|
9
9
|
return r.id = t, e.appendChild(r), r;
|
|
10
|
-
},
|
|
10
|
+
}, a = (e, t) => {
|
|
11
11
|
let n = e.getElementById(t);
|
|
12
12
|
if (n instanceof HTMLMetaElement) return n;
|
|
13
13
|
let r = document.createElement("meta");
|
|
14
14
|
return r.id = t, r.setAttribute("name", "emotion-insertion-point"), e.appendChild(r), r;
|
|
15
|
-
},
|
|
16
|
-
let d = t.shadowRoot ?? t.attachShadow({ mode: "open" }), f =
|
|
17
|
-
return e(d,
|
|
15
|
+
}, o = "sbu-shadow-styles", s = "sbu-react-root", c = "sbu-portal-root", l = "sbu-emotion-insertion-point", u = (t, { cacheKey: n, cssText: u }) => {
|
|
16
|
+
let d = t.shadowRoot ?? t.attachShadow({ mode: "open" }), f = i(d, `${s}-${n}`), p = i(d, `${c}-${n}`), m = a(d, `${l}-${n}`);
|
|
17
|
+
return e(d, u, `${o}-${n}`), {
|
|
18
18
|
shadowRoot: d,
|
|
19
19
|
reactMountEl: f,
|
|
20
20
|
portalContainerEl: p,
|
|
21
|
-
emotionCache:
|
|
21
|
+
emotionCache: r({
|
|
22
22
|
key: n,
|
|
23
23
|
container: d,
|
|
24
24
|
insertionPoint: m
|
|
25
25
|
})
|
|
26
26
|
};
|
|
27
|
-
}
|
|
27
|
+
};
|
|
28
28
|
//#endregion
|
|
29
|
-
export {
|
|
29
|
+
export { t as PortalContainerProvider, u as ensureShadowMount, n as usePortalContainer };
|
|
30
30
|
|
|
31
31
|
//# sourceMappingURL=react.es.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.es.mjs","names":[],"sources":["../../src/shadow/react/getOrCreateDiv.ts","../../src/shadow/react/getOrCreateEmotionInsertionPoint.ts","../../src/shadow/react/ensureShadowMount.ts"
|
|
1
|
+
{"version":3,"file":"react.es.mjs","names":[],"sources":["../../src/shadow/react/getOrCreateDiv.ts","../../src/shadow/react/getOrCreateEmotionInsertionPoint.ts","../../src/shadow/react/ensureShadowMount.ts"],"sourcesContent":["/**\n * Returns the shadow-root child `<div>` with the given id, creating it if absent.\n * @param {ShadowRoot} root - The shadow root to search/append within.\n * @param {string} id - The element id.\n * @returns {HTMLDivElement} The existing or newly created div.\n */\nexport const getOrCreateDiv = (\n root: ShadowRoot,\n id: string,\n): HTMLDivElement => {\n const existing = root.getElementById(id)\n if (existing instanceof HTMLDivElement) return existing\n\n const el = document.createElement('div')\n el.id = id\n root.appendChild(el)\n return el\n}\n","/**\n * Returns the shadow-root `<meta name=\"emotion-insertion-point\">` with the given\n * id, creating it if absent. Keeps Emotion's styles ordered before shadow content.\n * @param {ShadowRoot} root - The shadow root to search/append within.\n * @param {string} id - The element id.\n * @returns {HTMLMetaElement} The existing or newly created insertion-point meta.\n */\nexport const getOrCreateEmotionInsertionPoint = (\n root: ShadowRoot,\n id: string,\n): HTMLMetaElement => {\n const existing = root.getElementById(id)\n if (existing instanceof HTMLMetaElement) return existing\n\n const el = document.createElement('meta')\n el.id = id\n el.setAttribute('name', 'emotion-insertion-point')\n root.appendChild(el)\n return el\n}\n","import createCache from '@emotion/cache'\n\nimport type { EnsureShadowMountOptions } from '../../types/shadow/EnsureShadowMountOptions'\nimport type { ShadowMount } from '../../types/shadow/ShadowMount'\nimport { injectShadowStyles } from '../injectShadowStyles'\nimport { getOrCreateDiv } from './getOrCreateDiv'\nimport { getOrCreateEmotionInsertionPoint } from './getOrCreateEmotionInsertionPoint'\n\nconst STYLE_ELEMENT_ID = 'sbu-shadow-styles'\nconst REACT_MOUNT_ID = 'sbu-react-root'\nconst PORTAL_CONTAINER_ID = 'sbu-portal-root'\nconst EMOTION_INSERTION_POINT_ID = 'sbu-emotion-insertion-point'\n\n/**\n * Ensures a ShadowRoot mount exists on the host element for a widget.\n *\n * Creates stable React-mount and portal-container nodes, injects the widget's CSS\n * into the shadow root only (never into the document), and configures an Emotion\n * cache scoped to the shadow root. All internal ids are namespaced by `cacheKey`\n * so editor and runtime mounts on the same host never collide.\n * @param {HTMLElement} host - The host element to attach the shadow root to.\n * @param {EnsureShadowMountOptions} options - The cache key and the widget's CSS text.\n * @returns {ShadowMount} The shadow root, mount nodes and the scoped Emotion cache.\n */\nexport const ensureShadowMount = (\n host: HTMLElement,\n { cacheKey, cssText }: EnsureShadowMountOptions,\n): ShadowMount => {\n const shadowRoot = host.shadowRoot ?? host.attachShadow({ mode: 'open' })\n\n const reactMountEl = getOrCreateDiv(\n shadowRoot,\n `${REACT_MOUNT_ID}-${cacheKey}`,\n )\n const portalContainerEl = getOrCreateDiv(\n shadowRoot,\n `${PORTAL_CONTAINER_ID}-${cacheKey}`,\n )\n const insertionPoint = getOrCreateEmotionInsertionPoint(\n shadowRoot,\n `${EMOTION_INSERTION_POINT_ID}-${cacheKey}`,\n )\n\n injectShadowStyles(shadowRoot, cssText, `${STYLE_ELEMENT_ID}-${cacheKey}`)\n\n // Emotion's `container` is typed as HTMLElement but supports ShadowRoot targets\n // at runtime; the localized cast keeps the rest of the call type-safe.\n const emotionCache = createCache({\n key: cacheKey,\n container: shadowRoot as unknown as HTMLElement,\n insertionPoint,\n })\n\n return { shadowRoot, reactMountEl, portalContainerEl, emotionCache }\n}\n"],"mappings":";;;;AAMA,IAAa,KACX,GACA,MACmB;CACnB,IAAM,IAAW,EAAK,eAAe,CAAE;CACvC,IAAI,aAAoB,gBAAgB,OAAO;CAE/C,IAAM,IAAK,SAAS,cAAc,KAAK;CAGvC,OAFA,EAAG,KAAK,GACR,EAAK,YAAY,CAAE,GACZ;AACT,GCVa,KACX,GACA,MACoB;CACpB,IAAM,IAAW,EAAK,eAAe,CAAE;CACvC,IAAI,aAAoB,iBAAiB,OAAO;CAEhD,IAAM,IAAK,SAAS,cAAc,MAAM;CAIxC,OAHA,EAAG,KAAK,GACR,EAAG,aAAa,QAAQ,yBAAyB,GACjD,EAAK,YAAY,CAAE,GACZ;AACT,GCXM,IAAmB,qBACnB,IAAiB,kBACjB,IAAsB,mBACtB,IAA6B,+BAatB,KACX,GACA,EAAE,aAAU,iBACI;CAChB,IAAM,IAAa,EAAK,cAAc,EAAK,aAAa,EAAE,MAAM,OAAO,CAAC,GAElE,IAAe,EACnB,GACA,GAAG,EAAe,GAAG,GACvB,GACM,IAAoB,EACxB,GACA,GAAG,EAAoB,GAAG,GAC5B,GACM,IAAiB,EACrB,GACA,GAAG,EAA2B,GAAG,GACnC;CAYA,OAVA,EAAmB,GAAY,GAAS,GAAG,EAAiB,GAAG,GAAU,GAUlE;EAAE;EAAY;EAAc;EAAmB,cANjC,EAAY;GAC/B,KAAK;GACL,WAAW;GACX;EACF,CAEsD;CAAa;AACrE"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { isMobile } from './isMobile';
|
|
2
2
|
export { isMobileOrWebview } from './isMobileOrWebview';
|
|
3
|
+
export { isMobilePlatform } from './isMobilePlatform';
|
|
3
4
|
export { isMobileViewport } from './isMobileViewport';
|
|
5
|
+
export { isNativeApp } from './isNativeApp';
|
|
4
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/device/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/device/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the app is running on a mobile platform, per the `window.we.mobile`
|
|
3
|
+
* runtime flag or device detection. Returns false outside a browser.
|
|
4
|
+
* @returns {boolean} True when running on a mobile platform.
|
|
5
|
+
*/
|
|
6
|
+
export declare const isMobilePlatform: () => boolean;
|
|
7
|
+
//# sourceMappingURL=isMobilePlatform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isMobilePlatform.d.ts","sourceRoot":"","sources":["../../../src/device/isMobilePlatform.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,QAAO,OAOnC,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the app is running inside the Staffbase native shell, per the
|
|
3
|
+
* `window.we.native` runtime flag. Returns false outside a browser.
|
|
4
|
+
* @returns {boolean} True when running in the native app.
|
|
5
|
+
*/
|
|
6
|
+
export declare const isNativeApp: () => boolean;
|
|
7
|
+
//# sourceMappingURL=isNativeApp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isNativeApp.d.ts","sourceRoot":"","sources":["../../../src/device/isNativeApp.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,WAAW,QAAO,OAI9B,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads the Staffbase CSRF token from the host's global auth manager
|
|
3
|
+
* (`window.we.authMgr.getCsrfToken`).
|
|
4
|
+
*
|
|
5
|
+
* Returns null (instead of an empty string) when the token is unavailable, so
|
|
6
|
+
* callers can fail fast with a clear message rather than firing a request the
|
|
7
|
+
* server is guaranteed to reject with a 403.
|
|
8
|
+
* @returns {string | null} The CSRF token, or null when it cannot be resolved.
|
|
9
|
+
*/
|
|
10
|
+
export declare const getStaffbaseCsrfToken: () => string | null;
|
|
11
|
+
//# sourceMappingURL=getStaffbaseCsrfToken.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getStaffbaseCsrfToken.d.ts","sourceRoot":"","sources":["../../../src/host/getStaffbaseCsrfToken.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,QAAO,MAAM,GAAG,IAOjD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/host/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PortalContainerContext.d.ts","sourceRoot":"","sources":["../../../../src/shadow/portal/PortalContainerContext.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,sBAAsB,6CAA0C,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PortalContainerProvider.d.ts","sourceRoot":"","sources":["../../../../src/shadow/portal/PortalContainerProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAGzC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,iDAAiD,CAAA;AAGnG;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAAI,gCAGrC,4BAA4B,KAAG,YAK/B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/shadow/portal/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,YAAY,EAAE,4BAA4B,EAAE,MAAM,iDAAiD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePortalContainer.d.ts","sourceRoot":"","sources":["../../../../src/shadow/portal/usePortalContainer.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,eAAO,MAAM,kBAAkB,QAAO,WAAW,GAAG,IAEnD,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
export { ensureShadowMount } from './ensureShadowMount';
|
|
2
|
+
export { PortalContainerProvider } from '../portal/PortalContainerProvider';
|
|
3
|
+
export { usePortalContainer } from '../portal/usePortalContainer';
|
|
1
4
|
export type { EnsureShadowMountOptions } from '../../types/shadow/EnsureShadowMountOptions';
|
|
2
5
|
export type { PortalContainerProviderProps } from '../../types/shadow/PortalContainerProviderProps';
|
|
3
6
|
export type { ShadowMount } from '../../types/shadow/ShadowMount';
|
|
4
|
-
export { ensureShadowMount } from './ensureShadowMount';
|
|
5
|
-
export { PortalContainerProvider } from './PortalContainerProvider';
|
|
6
|
-
export { usePortalContainer } from './usePortalContainer';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/shadow/react/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/shadow/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAA;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAA;AACjE,YAAY,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAA;AAC3F,YAAY,EAAE,4BAA4B,EAAE,MAAM,iDAAiD,CAAA;AACnG,YAAY,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Window augmented with the Staffbase runtime flags (`window.we`) that report
|
|
3
|
+
* whether the app is running inside the native shell and on a mobile platform.
|
|
4
|
+
* Optional because the runtime is absent outside the Staffbase shell.
|
|
5
|
+
*/
|
|
6
|
+
export interface WindowWithStaffbaseRuntime {
|
|
7
|
+
we?: {
|
|
8
|
+
native?: boolean;
|
|
9
|
+
mobile?: boolean;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=WindowWithStaffbaseRuntime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WindowWithStaffbaseRuntime.d.ts","sourceRoot":"","sources":["../../../../src/types/device/WindowWithStaffbaseRuntime.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,0BAA0B;IACzC,EAAE,CAAC,EAAE;QACH,MAAM,CAAC,EAAE,OAAO,CAAA;QAChB,MAAM,CAAC,EAAE,OAAO,CAAA;KACjB,CAAA;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Window augmented with the Staffbase host auth manager (`window.we.authMgr`),
|
|
3
|
+
* which exposes the session CSRF token. Every level is optional because the host
|
|
4
|
+
* global may be absent (e.g. outside the Staffbase shell).
|
|
5
|
+
*/
|
|
6
|
+
export interface WindowWithStaffbaseAuth {
|
|
7
|
+
we?: {
|
|
8
|
+
authMgr?: {
|
|
9
|
+
getCsrfToken?: () => string | undefined;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=WindowWithStaffbaseAuth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WindowWithStaffbaseAuth.d.ts","sourceRoot":"","sources":["../../../../src/types/host/WindowWithStaffbaseAuth.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC,EAAE,CAAC,EAAE;QACH,OAAO,CAAC,EAAE;YACR,YAAY,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAA;SACxC,CAAA;KACF,CAAA;CACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createContext as e, createElement as t, useContext as n } from "react";
|
|
2
|
+
//#region src/shadow/portal/PortalContainerContext.ts
|
|
3
|
+
var r = e(null), i = ({ portalContainer: e, children: n }) => t(r.Provider, { value: e }, n), a = () => n(r);
|
|
4
|
+
//#endregion
|
|
5
|
+
export { i as n, a as t };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=usePortalContainer-BYW2B6g7.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePortalContainer-BYW2B6g7.mjs","names":[],"sources":["../src/shadow/portal/PortalContainerContext.ts","../src/shadow/portal/PortalContainerProvider.ts","../src/shadow/portal/usePortalContainer.ts"],"sourcesContent":["import { createContext } from 'react'\n\n/**\n * Holds the DOM element portalled components should render into, so portals stay\n * inside the widget's ShadowRoot (preserving style isolation).\n */\nexport const PortalContainerContext = createContext<HTMLElement | null>(null)\n","import type { ReactElement } from 'react'\nimport { createElement } from 'react'\n\nimport type { PortalContainerProviderProps } from '../../types/shadow/PortalContainerProviderProps'\nimport { PortalContainerContext } from './PortalContainerContext'\n\n/**\n * Provides the portal container element to descendants. Built with createElement\n * (no JSX) so the library has no JSX-runtime build coupling.\n * @param {PortalContainerProviderProps} props - The portal container and children.\n * @returns {ReactElement} The provider element wrapping the children.\n */\nexport const PortalContainerProvider = ({\n portalContainer,\n children,\n}: PortalContainerProviderProps): ReactElement =>\n createElement(\n PortalContainerContext.Provider,\n { value: portalContainer },\n children,\n )\n","import { useContext } from 'react'\n\nimport { PortalContainerContext } from './PortalContainerContext'\n\n/**\n * Returns the portal container element used to keep portals inside the ShadowRoot.\n * @returns {HTMLElement | null} The portal container, or null when not provided.\n */\nexport const usePortalContainer = (): HTMLElement | null => {\n return useContext(PortalContainerContext)\n}\n"],"mappings":";;AAMA,IAAa,IAAyB,EAAkC,IAAI,GCM/D,KAA2B,EACtC,oBACA,kBAEA,EACE,EAAuB,UACvB,EAAE,OAAO,EAAgB,GACzB,CACF,GCZW,UACJ,EAAW,CAAsB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
let e=require("react");var t=(0,e.createContext)(null),n=({portalContainer:n,children:r})=>(0,e.createElement)(t.Provider,{value:n},r),r=()=>(0,e.useContext)(t);Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return r}});
|
|
2
|
+
//# sourceMappingURL=usePortalContainer-BcMPb5ai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePortalContainer-BcMPb5ai.js","names":[],"sources":["../src/shadow/portal/PortalContainerContext.ts","../src/shadow/portal/PortalContainerProvider.ts","../src/shadow/portal/usePortalContainer.ts"],"sourcesContent":["import { createContext } from 'react'\n\n/**\n * Holds the DOM element portalled components should render into, so portals stay\n * inside the widget's ShadowRoot (preserving style isolation).\n */\nexport const PortalContainerContext = createContext<HTMLElement | null>(null)\n","import type { ReactElement } from 'react'\nimport { createElement } from 'react'\n\nimport type { PortalContainerProviderProps } from '../../types/shadow/PortalContainerProviderProps'\nimport { PortalContainerContext } from './PortalContainerContext'\n\n/**\n * Provides the portal container element to descendants. Built with createElement\n * (no JSX) so the library has no JSX-runtime build coupling.\n * @param {PortalContainerProviderProps} props - The portal container and children.\n * @returns {ReactElement} The provider element wrapping the children.\n */\nexport const PortalContainerProvider = ({\n portalContainer,\n children,\n}: PortalContainerProviderProps): ReactElement =>\n createElement(\n PortalContainerContext.Provider,\n { value: portalContainer },\n children,\n )\n","import { useContext } from 'react'\n\nimport { PortalContainerContext } from './PortalContainerContext'\n\n/**\n * Returns the portal container element used to keep portals inside the ShadowRoot.\n * @returns {HTMLElement | null} The portal container, or null when not provided.\n */\nexport const usePortalContainer = (): HTMLElement | null => {\n return useContext(PortalContainerContext)\n}\n"],"mappings":"uBAMA,IAAa,GAAA,EAAA,EAAA,eAA2D,IAAI,ECM/D,GAA2B,CACtC,kBACA,eAAA,EAAA,EAAA,eAGE,EAAuB,SACvB,CAAE,MAAO,CAAgB,EACzB,CACF,ECZW,OACX,EAAA,EAAA,YAAkB,CAAsB"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@favish/staffbase-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Shared internal/host utilities for Staffbase widgets",
|
|
5
5
|
"author": "Favish <dev@favish.com>",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
|
+
"sideEffects": false,
|
|
7
8
|
"files": [
|
|
8
9
|
"dist"
|
|
9
10
|
],
|
|
@@ -33,6 +34,11 @@
|
|
|
33
34
|
"import": "./dist/dom.es.mjs",
|
|
34
35
|
"require": "./dist/dom.cjs.js"
|
|
35
36
|
},
|
|
37
|
+
"./host": {
|
|
38
|
+
"types": "./dist/src/host/index.d.ts",
|
|
39
|
+
"import": "./dist/host.es.mjs",
|
|
40
|
+
"require": "./dist/host.cjs.js"
|
|
41
|
+
},
|
|
36
42
|
"./html": {
|
|
37
43
|
"types": "./dist/src/html/index.d.ts",
|
|
38
44
|
"import": "./dist/html.es.mjs",
|
|
@@ -58,6 +64,11 @@
|
|
|
58
64
|
"import": "./dist/shadow.es.mjs",
|
|
59
65
|
"require": "./dist/shadow.cjs.js"
|
|
60
66
|
},
|
|
67
|
+
"./shadow/portal": {
|
|
68
|
+
"types": "./dist/src/shadow/portal/index.d.ts",
|
|
69
|
+
"import": "./dist/shadow/portal.es.mjs",
|
|
70
|
+
"require": "./dist/shadow/portal.cjs.js"
|
|
71
|
+
},
|
|
61
72
|
"./shadow/react": {
|
|
62
73
|
"types": "./dist/src/shadow/react/index.d.ts",
|
|
63
74
|
"import": "./dist/shadow/react.es.mjs",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PortalContainerContext.d.ts","sourceRoot":"","sources":["../../../../src/shadow/react/PortalContainerContext.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,sBAAsB,6CAA0C,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PortalContainerProvider.d.ts","sourceRoot":"","sources":["../../../../src/shadow/react/PortalContainerProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAGzC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,iDAAiD,CAAA;AAGnG;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAAI,gCAGrC,4BAA4B,KAAG,YAK/B,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"usePortalContainer.d.ts","sourceRoot":"","sources":["../../../../src/shadow/react/usePortalContainer.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,eAAO,MAAM,kBAAkB,QAAO,WAAW,GAAG,IAEnD,CAAA"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|