one
Version:
One is a new React Framework that makes Vite serve both native and web.
208 lines (206 loc) • 6.53 kB
JavaScript
"use strict";
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 ErrorBoundary_exports = {};
__export(ErrorBoundary_exports, {
ErrorBoundary: () => ErrorBoundary
});
module.exports = __toCommonJS(ErrorBoundary_exports);
var import_jsx_runtime = require("react/jsx-runtime"),
import_bottom_tabs = require("@react-navigation/bottom-tabs"),
import_react = __toESM(require("react"), 1),
import_react_native = require("react-native"),
import_react_native_safe_area_context = require("react-native-safe-area-context");
function ErrorBoundary(param) {
var {
error,
retry,
route
} = param,
inTabBar = import_react.default.useContext(import_bottom_tabs.BottomTabBarHeightContext),
Wrapper = inTabBar ? import_react_native.View : import_react_native_safe_area_context.SafeAreaView,
isDev = process.env.NODE_ENV === "development";
return console.error("[One] Error in route:", route?.routeName || "unknown", error), /* @__PURE__ */(0, import_jsx_runtime.jsx)(Wrapper, {
style: styles.container,
children: /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_react_native.View, {
style: styles.content,
children: [/* Error icon */
/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.View, {
style: styles.iconContainer,
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.Text, {
style: styles.iconText,
children: "!"
})
}), /* Title */
/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.Text, {
style: styles.title,
children: "Something went wrong"
}), /* Route info */
route?.routeName && /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_react_native.Text, {
style: styles.routeInfo,
children: ["on route: ", route.routeName]
}), /* Error message */
/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.View, {
style: styles.errorBox,
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.Text, {
style: styles.errorMessage,
children: error?.message || "An unexpected error occurred"
})
}), /* Stack trace (dev only) */
isDev && error?.stack && /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_react_native.ScrollView, {
style: styles.stackContainer,
children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.Text, {
style: styles.stackTitle,
children: "Stack trace:"
}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.Text, {
style: styles.stackText,
children: error.stack
})]
}), /* Actions */
/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.View, {
style: styles.actions,
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.Pressable, {
onPress: function () {
return retry();
},
style: function (param2) {
var {
pressed
} = param2;
return [styles.button, styles.primaryButton, pressed && styles.buttonPressed];
},
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.Text, {
style: styles.primaryButtonText,
children: "Try Again"
})
})
})]
})
});
}
var styles = import_react_native.StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#0a0a0f"
},
content: {
flex: 1,
alignItems: "center",
justifyContent: "center",
padding: 24
},
iconContainer: {
width: 64,
height: 64,
backgroundColor: "#ef4444",
borderRadius: 32,
alignItems: "center",
justifyContent: "center",
marginBottom: 24
},
iconText: {
color: "white",
fontSize: 32,
fontWeight: "bold"
},
title: {
fontSize: 22,
fontWeight: "600",
color: "#e8e8e8",
marginBottom: 8,
textAlign: "center"
},
routeInfo: {
fontSize: 13,
color: "#666",
marginBottom: 16
},
errorBox: {
backgroundColor: "#1a1a2e",
borderRadius: 8,
padding: 16,
marginBottom: 16,
width: "100%",
maxWidth: 400
},
errorMessage: {
fontFamily: "monospace",
fontSize: 14,
lineHeight: 20,
color: "#f87171",
textAlign: "center"
},
stackContainer: {
maxHeight: 150,
width: "100%",
maxWidth: 400,
backgroundColor: "#16162a",
borderRadius: 8,
padding: 12,
marginBottom: 16
},
stackTitle: {
fontSize: 11,
color: "#666",
marginBottom: 8
},
stackText: {
fontFamily: "monospace",
fontSize: 10,
lineHeight: 16,
color: "#a0a0a0"
},
actions: {
flexDirection: "row",
gap: 12,
marginTop: 8
},
button: {
paddingVertical: 12,
paddingHorizontal: 24,
borderRadius: 8,
minWidth: 120,
alignItems: "center"
},
primaryButton: {
backgroundColor: "#3b82f6"
},
buttonPressed: {
opacity: 0.8
},
primaryButtonText: {
color: "white",
fontSize: 14,
fontWeight: "500"
}
});
//# sourceMappingURL=ErrorBoundary.native.js.map