@tamagui/react-native-web-lite
Version:
React Native for Web
139 lines (138 loc) • 6.58 kB
JavaScript
;
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf, __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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
mod
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
var AppRegistry_exports = {};
__export(AppRegistry_exports, {
default: () => AppRegistry
});
module.exports = __toCommonJS(AppRegistry_exports);
var import_react_dom = require("react-dom"), import_react_native_web_internals = require("@tamagui/react-native-web-internals"), import_renderApplication = __toESM(require("./renderApplication"));
function _class_call_check(instance, Constructor) {
if (!(instance instanceof Constructor))
throw new TypeError("Cannot call a class as a function");
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0, "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _create_class(Constructor, protoProps, staticProps) {
return protoProps && _defineProperties(Constructor.prototype, protoProps), staticProps && _defineProperties(Constructor, staticProps), Constructor;
}
var emptyObject = {}, runnables = {}, componentProviderInstrumentationHook = function(component) {
return component();
}, wrapperComponentProvider, AppRegistry = /* @__PURE__ */ function() {
"use strict";
function AppRegistry2() {
_class_call_check(this, AppRegistry2);
}
return _create_class(AppRegistry2, null, [
{
key: "getAppKeys",
value: function() {
return Object.keys(runnables);
}
},
{
key: "getApplication",
value: function(appKey, appParameters) {
var _runnables_appKey_getApplication, _runnables_appKey;
return (0, import_react_native_web_internals.invariant)(runnables[appKey] && runnables[appKey].getApplication, `Application ${appKey} has not been registered. This is either due to an import error during initialization or failure to call AppRegistry.registerComponent.`), (_runnables_appKey = runnables[appKey]) === null || _runnables_appKey === void 0 || (_runnables_appKey_getApplication = _runnables_appKey.getApplication) === null || _runnables_appKey_getApplication === void 0 ? void 0 : _runnables_appKey_getApplication.call(_runnables_appKey, appParameters);
}
},
{
key: "registerComponent",
value: function(appKey, componentProvider) {
return runnables[appKey] = {
getApplication: function(appParameters) {
return (0, import_renderApplication.getApplication)(componentProviderInstrumentationHook(componentProvider), appParameters ? appParameters.initialProps : emptyObject, wrapperComponentProvider && wrapperComponentProvider(appParameters));
},
run: function(appParameters) {
return (0, import_renderApplication.default)(componentProviderInstrumentationHook(componentProvider), wrapperComponentProvider && wrapperComponentProvider(appParameters), appParameters.callback, {
hydrate: appParameters.hydrate || !1,
initialProps: appParameters.initialProps || emptyObject,
mode: appParameters.mode || "legacy",
rootTag: appParameters.rootTag
});
}
}, appKey;
}
},
{
key: "registerConfig",
value: function(config) {
config.forEach(function(param) {
var { appKey, component, run } = param;
run ? AppRegistry2.registerRunnable(appKey, run) : ((0, import_react_native_web_internals.invariant)(component, "No component provider passed in"), AppRegistry2.registerComponent(appKey, component));
});
}
},
{
key: "registerRunnable",
value: (
// TODO: fix style sheet creation when using this method
function(appKey, run) {
return runnables[appKey] = {
run
}, appKey;
}
)
},
{
key: "runApplication",
value: function(appKey, appParameters) {
var isDevelopment = process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test";
if (isDevelopment) {
var params = {
...appParameters
};
params.rootTag = `#${params.rootTag.id}`, console.log(`Running application "${appKey}" with appParams:
`, params, `
Development-level warnings: ${isDevelopment ? "ON" : "OFF"}.
Performance optimizations: ${isDevelopment ? "OFF" : "ON"}.`);
}
return (0, import_react_native_web_internals.invariant)(runnables[appKey] && runnables[appKey].run, `Application "${appKey}" has not been registered. This is either due to an import error during initialization or failure to call AppRegistry.registerComponent.`), runnables[appKey].run(appParameters);
}
},
{
key: "setComponentProviderInstrumentationHook",
value: function(hook) {
componentProviderInstrumentationHook = hook;
}
},
{
key: "setWrapperComponentProvider",
value: function(provider) {
wrapperComponentProvider = provider;
}
},
{
key: "unmountApplicationComponentAtRootTag",
value: function(rootTag) {
(0, import_react_dom.unmountComponentAtNode)(rootTag);
}
}
]), AppRegistry2;
}();
//# sourceMappingURL=index.js.map