UNPKG

@enonic/react4xp

Version:
72 lines (68 loc) 2.44 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/index.ts var index_exports = {}; __export(index_exports, { COMPONENT_STATS_FILENAME: () => COMPONENT_STATS_FILENAME, ENTRIES_FILENAME: () => ENTRIES_FILENAME, GLOBALS_FILENAME: () => GLOBALS_FILENAME, LIBRARY_NAME: () => LIBRARY_NAME, R4X_TARGETSUBDIR: () => R4X_TARGETSUBDIR, getPublicPath: () => getPublicPath }); module.exports = __toCommonJS(index_exports); // src/constants.runtime.ts var COMPONENT_STATS_FILENAME = "stats.components.json"; var ENTRIES_FILENAME = "entries.json"; var GLOBALS_FILENAME = "globals.json"; var LIBRARY_NAME = "React4xp"; var R4X_TARGETSUBDIR = "r4xAssets"; // src/globals/getPublicPath.ts var getPublicPath = (appName) => { var _a; if (typeof document === "undefined") { return void 0; } const inlineJsonElements = Array.from(document.querySelectorAll( `script[data-react4xp-app-name="${appName}"][data-react4xp-ref][type="application/json"]` )); for (let index = 0; index < inlineJsonElements.length; index++) { const inlineJsonElement = inlineJsonElements[index]; if (inlineJsonElement instanceof HTMLElement) { const json = inlineJsonElement.textContent; let data = {}; try { data = JSON.parse(json); } catch (e) { console.error("Something went wrong while trying to JSON.parse(" + json + ")"); } if ((_a = data.publicPath) == null ? void 0 : _a.length) { return data.publicPath; } } } }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { COMPONENT_STATS_FILENAME, ENTRIES_FILENAME, GLOBALS_FILENAME, LIBRARY_NAME, R4X_TARGETSUBDIR, getPublicPath });