UNPKG

2.97 kBSource Map (JSON)View Raw
1{"version":3,"file":"Layer.notification.js","sourceRoot":"../src/","sources":["components/Layer/Layer.notification.ts"],"names":[],"mappings":"AAAA,IAAM,eAAe,GAAyC,EAAE,CAAC;AAEjE,IAAI,oBAAwC,CAAC;AAE7C;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,MAAc,EAAE,QAAoB;IAChE,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE;QAC5B,eAAe,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;KAC9B;IAED,eAAe,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACzC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,MAAc,EAAE,QAAoB;IAClE,IAAI,eAAe,CAAC,MAAM,CAAC,EAAE;QAC3B,IAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACtD,IAAI,GAAG,IAAI,CAAC,EAAE;YACZ,eAAe,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YACvC,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;gBACxC,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;aAChC;SACF;KACF;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAAU;IAC1C,IAAI,eAAe,CAAC,EAAE,CAAC,EAAE;QACvB,eAAe,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,UAAA,QAAQ,IAAI,OAAA,QAAQ,EAAE,EAAV,CAAU,CAAC,CAAC;KACrD;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAiB;IAChD,oBAAoB,GAAG,QAAQ,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,oBAAoB,CAAC;AAC9B,CAAC","sourcesContent":["const _layersByHostId: { [hostId: string]: (() => void)[] } = {};\n\nlet _defaultHostSelector: string | undefined;\n\n/**\n * Register a layer for a given host id\n * @param hostId Id of the layer host\n * @param layer Layer instance\n */\nexport function registerLayer(hostId: string, callback: () => void) {\n if (!_layersByHostId[hostId]) {\n _layersByHostId[hostId] = [];\n }\n\n _layersByHostId[hostId].push(callback);\n}\n\n/**\n * Unregister a layer for a given host id\n * @param hostId Id of the layer host\n * @param layer Layer instance\n */\nexport function unregisterLayer(hostId: string, callback: () => void) {\n if (_layersByHostId[hostId]) {\n const idx = _layersByHostId[hostId].indexOf(callback);\n if (idx >= 0) {\n _layersByHostId[hostId].splice(idx, 1);\n if (_layersByHostId[hostId].length === 0) {\n delete _layersByHostId[hostId];\n }\n }\n }\n}\n\n/**\n * Used for notifying applicable Layers that a host is available/unavailable and to re-evaluate Layers that\n * care about the specific host.\n */\nexport function notifyHostChanged(id: string) {\n if (_layersByHostId[id]) {\n _layersByHostId[id].forEach(callback => callback());\n }\n}\n\n/**\n * Sets the default target selector to use when determining the host in which\n * Layered content will be injected into. If not provided, an element will be\n * created at the end of the document body.\n *\n * Passing in a falsey value will clear the default target and reset back to\n * using a created element at the end of document body.\n */\nexport function setDefaultTarget(selector?: string) {\n _defaultHostSelector = selector;\n}\n\n/**\n * Get the default target selector when determining a host\n */\nexport function getDefaultTarget(): string | undefined {\n return _defaultHostSelector;\n}\n"]}
\No newline at end of file