one
Version:
One is a new React Framework that makes Vite serve both native and web.
200 lines (198 loc) • 5.69 kB
JavaScript
;
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
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 __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: true
}) : target, mod));
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
value: true
}), mod);
var SSRNavigationContainer_exports = {};
__export(SSRNavigationContainer_exports, {
SSRNavigationContainer: () => SSRNavigationContainer
});
module.exports = __toCommonJS(SSRNavigationContainer_exports);
var import_jsx_runtime = require("react/jsx-runtime");
var import_NavigationBuilderContext = require("@react-navigation/core/lib/module/NavigationBuilderContext");
var import_NavigationStateContext = require("@react-navigation/core/lib/module/NavigationStateContext");
var import_EnsureSingleNavigator = require("@react-navigation/core/lib/module/EnsureSingleNavigator");
var import_core = require("@react-navigation/core");
var import_native = require("@react-navigation/native");
var React = __toESM(require("react"), 1);
var noop = function () {};
var SSR_LINKING_CTX = {
options: void 0
};
var SSR_BUILDER_CTX = {
onDispatchAction: noop,
onOptionsChange: noop,
// must execute callback immediately — useNavigationBuilder calls this during render
scheduleUpdate: function (cb) {
return cb();
},
flushUpdates: noop,
stackRef: {
current: void 0
}
};
var SSR_SINGLE_NAV_CTX = {
register: noop,
unregister: noop
};
var SSR_NAV_REF = {
dispatch: noop,
navigate: noop,
reset: noop,
goBack: noop,
isFocused: function () {
return false;
},
canGoBack: function () {
return false;
},
getParent: function () {
return void 0;
},
getState: function () {
return void 0;
},
getRootState: function () {
return void 0;
},
getCurrentRoute: function () {
return void 0;
},
getCurrentOptions: function () {
return void 0;
},
isReady: function () {
return false;
},
addListener: function () {
return noop;
},
removeListener: noop,
resetRoot: noop,
setOptions: noop,
// CommonActions methods
setParams: noop,
popTo: noop,
pop: noop,
popToTop: noop,
push: noop,
replace: noop,
jumpTo: noop,
preload: noop
};
var getPartialState = function (state) {
if (!state) return void 0;
var {
key,
routeNames,
...partial
} = state;
return {
...partial,
stale: true,
routes: state.routes.map(function (route) {
return route.state ? {
...route,
state: getPartialState(route.state)
} : route;
})
};
};
var stateCtxCache = /* @__PURE__ */new WeakMap();
function getStateContext(initialState) {
if (!initialState) {
return {
state: void 0,
getKey: function () {
return void 0;
},
setKey: noop,
getState: function () {
return void 0;
},
setState: noop,
getIsInitial: function () {
return true;
}
};
}
var cached = stateCtxCache.get(initialState);
if (cached) return cached;
var partial = getPartialState(initialState);
var ctx = {
state: partial,
getKey: function () {
return void 0;
},
setKey: noop,
getState: function () {
return partial;
},
setState: noop,
getIsInitial: function () {
return true;
}
};
stateCtxCache.set(initialState, ctx);
return ctx;
}
function SSRNavigationContainer(param) {
var {
initialState,
theme,
linking,
children
} = param;
var linkingCtx = linking ? {
options: linking
} : SSR_LINKING_CTX;
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_native.LinkingContext.Provider, {
value: linkingCtx,
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.NavigationContainerRefContext.Provider, {
value: SSR_NAV_REF,
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_NavigationBuilderContext.NavigationBuilderContext.Provider, {
value: SSR_BUILDER_CTX,
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_NavigationStateContext.NavigationStateContext.Provider, {
value: getStateContext(initialState),
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_EnsureSingleNavigator.SingleNavigatorContext.Provider, {
value: SSR_SINGLE_NAV_CTX,
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.ThemeProvider, {
value: theme,
children
})
})
})
})
})
});
}
//# sourceMappingURL=SSRNavigationContainer.native.js.map