one
Version:
One is a new React Framework that makes Vite serve both native and web.
68 lines (66 loc) • 3.03 kB
JavaScript
;
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: !0
});
},
__copyProps = (to, from, except, desc) => {
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__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: !0
}), mod);
var constants_exports = {};
__export(constants_exports, {
CACHE_KEY: () => CACHE_KEY,
CSS_PRELOAD_JS_POSTFIX: () => CSS_PRELOAD_JS_POSTFIX,
LOADER_JS_POSTFIX: () => LOADER_JS_POSTFIX,
LOADER_JS_POSTFIX_REGEX: () => LOADER_JS_POSTFIX_REGEX,
LOADER_JS_POSTFIX_REGEX_STRING: () => LOADER_JS_POSTFIX_REGEX_STRING,
LOADER_JS_POSTFIX_UNCACHED: () => LOADER_JS_POSTFIX_UNCACHED,
PRELOAD_JS_POSTFIX: () => PRELOAD_JS_POSTFIX,
SERVER_CONTEXT_KEY: () => SERVER_CONTEXT_KEY,
VIRTUAL_SSR_CSS_ENTRY: () => VIRTUAL_SSR_CSS_ENTRY,
VIRTUAL_SSR_CSS_HREF: () => VIRTUAL_SSR_CSS_HREF,
getSpaHeaderElements: () => getSpaHeaderElements,
isNative: () => isNative,
isWebClient: () => isWebClient,
isWebServer: () => isWebServer
});
module.exports = __toCommonJS(constants_exports);
var import_htmlEscape = require("./utils/htmlEscape.native.js"),
isWebClient = !1,
isWebServer = !1,
isNative = !0,
_process_env_ONE_CACHE_KEY,
CACHE_KEY = `${(_process_env_ONE_CACHE_KEY = process.env.ONE_CACHE_KEY) !== null && _process_env_ONE_CACHE_KEY !== void 0 ? _process_env_ONE_CACHE_KEY : Math.round(Math.random() * 1e8)}`,
LOADER_JS_POSTFIX_UNCACHED = "_vxrn_loader.js",
LOADER_JS_POSTFIX_REGEX_STRING = `_\\d+${LOADER_JS_POSTFIX_UNCACHED}$`,
LOADER_JS_POSTFIX_REGEX = new RegExp(LOADER_JS_POSTFIX_REGEX_STRING),
LOADER_JS_POSTFIX = `_${CACHE_KEY}${LOADER_JS_POSTFIX_UNCACHED}`,
PRELOAD_JS_POSTFIX = `_${CACHE_KEY}_preload.js`,
CSS_PRELOAD_JS_POSTFIX = `_${CACHE_KEY}_preload_css.js`,
VIRTUAL_SSR_CSS_ENTRY = "virtual:ssr-css.css",
VIRTUAL_SSR_CSS_HREF = `/@id/__x00__${VIRTUAL_SSR_CSS_ENTRY}`,
SERVER_CONTEXT_KEY = "__one_server_context__",
getSpaHeaderElements = function () {
var {
serverContext = {}
} = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
return `
<script>globalThis['global'] = globalThis</script>
<script>globalThis['__vxrnIsSPA'] = true</script>
<script>globalThis["${SERVER_CONTEXT_KEY}"] = ${(0, import_htmlEscape.safeJsonStringify)(serverContext)}</script>
<script>globalThis.__oneLoadedCSS = new Set(${(0, import_htmlEscape.safeJsonStringify)(serverContext.css || [])})</script>
`;
};
//# sourceMappingURL=constants.native.js.map