one 1.1.297 → 1.1.299
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/Root.js.map +1 -1
- package/dist/cjs/Root.native.js.map +1 -1
- package/dist/cjs/cleanUrl.js +9 -2
- package/dist/cjs/cleanUrl.js.map +1 -1
- package/dist/cjs/cleanUrl.native.js +5 -2
- package/dist/cjs/cleanUrl.native.js.map +2 -2
- package/dist/cjs/vite/replaceLoader.js +7 -1
- package/dist/cjs/vite/replaceLoader.js.map +1 -1
- package/dist/cjs/vite/replaceLoader.native.js +7 -1
- package/dist/cjs/vite/replaceLoader.native.js.map +1 -1
- package/dist/esm/Root.js.map +1 -1
- package/dist/esm/Root.mjs.map +1 -1
- package/dist/esm/Root.native.js +110 -104
- package/dist/esm/Root.native.js.map +6 -1
- package/dist/esm/Route.native.js +12 -10
- package/dist/esm/Route.native.js.map +6 -1
- package/dist/esm/cleanUrl.js +9 -2
- package/dist/esm/cleanUrl.js.map +1 -1
- package/dist/esm/cleanUrl.mjs +7 -2
- package/dist/esm/cleanUrl.mjs.map +1 -1
- package/dist/esm/cleanUrl.native.js +16 -13
- package/dist/esm/cleanUrl.native.js.map +6 -1
- package/dist/esm/cli/label-process.native.js +5 -4
- package/dist/esm/cli/label-process.native.js.map +6 -1
- package/dist/esm/cli/main.native.js +8 -13
- package/dist/esm/cli/main.native.js.map +6 -1
- package/dist/esm/cli/prebuild.native.js +5 -5
- package/dist/esm/cli/prebuild.native.js.map +6 -1
- package/dist/esm/cli/run.native.js +21 -28
- package/dist/esm/cli/run.native.js.map +6 -1
- package/dist/esm/cli.native.js +119 -148
- package/dist/esm/cli.native.js.map +6 -1
- package/dist/esm/clientLoaderResolver.native.js +9 -6
- package/dist/esm/clientLoaderResolver.native.js.map +6 -1
- package/dist/esm/config.native.js +12 -11
- package/dist/esm/config.native.js.map +6 -1
- package/dist/esm/constants.native.js +7 -5
- package/dist/esm/constants.native.js.map +6 -1
- package/dist/esm/createApp.native.js +13 -9
- package/dist/esm/createApp.native.js.map +6 -1
- package/dist/esm/createHandleRequest.native.js +55 -64
- package/dist/esm/createHandleRequest.native.js.map +6 -1
- package/dist/esm/createRoute.native.js +16 -16
- package/dist/esm/createRoute.native.js.map +6 -1
- package/dist/esm/fallbackViews/Sitemap.native.js +6 -3
- package/dist/esm/fallbackViews/Sitemap.native.js.map +6 -1
- package/dist/esm/fallbackViews/Unmatched.native.js +5 -3
- package/dist/esm/fallbackViews/Unmatched.native.js.map +6 -1
- package/dist/esm/fork/NavigationContainer.native.js +24 -31
- package/dist/esm/fork/NavigationContainer.native.js.map +6 -1
- package/dist/esm/fork/createMemoryHistory.native.js +99 -115
- package/dist/esm/fork/createMemoryHistory.native.js.map +6 -1
- package/dist/esm/fork/extractPathFromURL.native.js +16 -15
- package/dist/esm/fork/extractPathFromURL.native.js.map +6 -1
- package/dist/esm/fork/findFocusedRoute.native.js +6 -5
- package/dist/esm/fork/findFocusedRoute.native.js.map +6 -1
- package/dist/esm/fork/getPathFromState.native.js +127 -140
- package/dist/esm/fork/getPathFromState.native.js.map +6 -1
- package/dist/esm/fork/getStateFromPath.native.js +292 -288
- package/dist/esm/fork/getStateFromPath.native.js.map +6 -1
- package/dist/esm/fork/useLinking.native.js +70 -61
- package/dist/esm/fork/useLinking.native.js.map +6 -1
- package/dist/esm/fork/validatePathConfig.native.js +15 -9
- package/dist/esm/fork/validatePathConfig.native.js.map +6 -1
- package/dist/esm/getLinkingConfig.native.js +11 -6
- package/dist/esm/getLinkingConfig.native.js.map +6 -1
- package/dist/esm/getReactNavigationConfig.native.js +28 -20
- package/dist/esm/getReactNavigationConfig.native.js.map +6 -1
- package/dist/esm/getRoutes.native.js +249 -229
- package/dist/esm/getRoutes.native.js.map +6 -1
- package/dist/esm/getURL.native.js +4 -4
- package/dist/esm/getURL.native.js.map +6 -1
- package/dist/esm/head/Head.android.js +5 -3
- package/dist/esm/head/Head.android.js.map +6 -1
- package/dist/esm/head/Head.ios.js +144 -132
- package/dist/esm/head/Head.ios.js.map +6 -1
- package/dist/esm/head/Head.native.js +7 -7
- package/dist/esm/head/Head.native.js.map +6 -1
- package/dist/esm/head/HeadModule.native.js +6 -6
- package/dist/esm/head/HeadModule.native.js.map +6 -1
- package/dist/esm/head/index.native.js +2 -2
- package/dist/esm/head/index.native.js.map +6 -1
- package/dist/esm/head/types.native.js +1 -2
- package/dist/esm/head/types.native.js.map +6 -1
- package/dist/esm/head/url.native.js +10 -8
- package/dist/esm/head/url.native.js.map +6 -1
- package/dist/esm/hooks.native.js +53 -34
- package/dist/esm/hooks.native.js.map +6 -1
- package/dist/esm/imperative-api.native.js +9 -6
- package/dist/esm/imperative-api.native.js.map +6 -1
- package/dist/esm/import-mode/index.android.js +4 -3
- package/dist/esm/import-mode/index.android.js.map +6 -1
- package/dist/esm/import-mode/index.ios.js +4 -3
- package/dist/esm/import-mode/index.ios.js.map +6 -1
- package/dist/esm/import-mode/index.native.js +3 -1
- package/dist/esm/import-mode/index.native.js.map +6 -1
- package/dist/esm/index.native.js +65 -27
- package/dist/esm/index.native.js.map +6 -1
- package/dist/esm/interfaces/router.native.js +4 -2
- package/dist/esm/interfaces/router.native.js.map +6 -1
- package/dist/esm/layouts/Drawer.native.js +7 -6
- package/dist/esm/layouts/Drawer.native.js.map +6 -1
- package/dist/esm/layouts/Stack.native.js +7 -6
- package/dist/esm/layouts/Stack.native.js.map +6 -1
- package/dist/esm/layouts/Tabs.native.js +42 -39
- package/dist/esm/layouts/Tabs.native.js.map +6 -1
- package/dist/esm/layouts/withLayoutContext.native.js +51 -48
- package/dist/esm/layouts/withLayoutContext.native.js.map +6 -1
- package/dist/esm/link/Link.native.js +62 -53
- package/dist/esm/link/Link.native.js.map +6 -1
- package/dist/esm/link/Redirect.native.js +8 -9
- package/dist/esm/link/Redirect.native.js.map +6 -1
- package/dist/esm/link/href.native.js +28 -27
- package/dist/esm/link/href.native.js.map +6 -1
- package/dist/esm/link/linking.native.js +51 -40
- package/dist/esm/link/linking.native.js.map +6 -1
- package/dist/esm/link/path.native.js +28 -19
- package/dist/esm/link/path.native.js.map +6 -1
- package/dist/esm/link/useLinkTo.native.js +22 -20
- package/dist/esm/link/useLinkTo.native.js.map +6 -1
- package/dist/esm/link/useLoadedNavigation.native.js +30 -23
- package/dist/esm/link/useLoadedNavigation.native.js.map +6 -1
- package/dist/esm/matchers.native.js +16 -3
- package/dist/esm/matchers.native.js.map +6 -1
- package/dist/esm/platform.native.js +4 -2
- package/dist/esm/platform.native.js.map +6 -1
- package/dist/esm/polyfills-mobile.native.js +4 -5
- package/dist/esm/polyfills-mobile.native.js.map +6 -1
- package/dist/esm/polyfills-server.native.js +1 -1
- package/dist/esm/polyfills-server.native.js.map +6 -1
- package/dist/esm/render.native.js +3 -1
- package/dist/esm/render.native.js.map +6 -1
- package/dist/esm/router/RouterStore.native.js +1 -2
- package/dist/esm/router/RouterStore.native.js.map +6 -1
- package/dist/esm/router/constants.native.js +4 -2
- package/dist/esm/router/constants.native.js.map +6 -1
- package/dist/esm/router/getNormalizedStatePath.native.js +18 -17
- package/dist/esm/router/getNormalizedStatePath.native.js.map +6 -1
- package/dist/esm/router/lastAction.native.js +10 -9
- package/dist/esm/router/lastAction.native.js.map +6 -1
- package/dist/esm/router/router.native.js +135 -114
- package/dist/esm/router/router.native.js.map +6 -1
- package/dist/esm/router/serverLocationContext.native.js +4 -2
- package/dist/esm/router/serverLocationContext.native.js.map +6 -1
- package/dist/esm/router/useInitializeOneRouter.native.js +8 -5
- package/dist/esm/router/useInitializeOneRouter.native.js.map +6 -1
- package/dist/esm/serve.native.js +77 -104
- package/dist/esm/serve.native.js.map +6 -1
- package/dist/esm/server/createRoutesManifest.native.js +14 -11
- package/dist/esm/server/createRoutesManifest.native.js.map +6 -1
- package/dist/esm/server/getServerManifest.native.js +61 -67
- package/dist/esm/server/getServerManifest.native.js.map +6 -1
- package/dist/esm/server-render.native.js +9 -10
- package/dist/esm/server-render.native.js.map +6 -1
- package/dist/esm/sortRoutes.native.js +27 -17
- package/dist/esm/sortRoutes.native.js.map +6 -1
- package/dist/esm/typed-routes/generateRouteTypes.native.js +10 -11
- package/dist/esm/typed-routes/generateRouteTypes.native.js.map +6 -1
- package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.native.js +38 -37
- package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.native.js.map +6 -1
- package/dist/esm/types.native.js +1 -2
- package/dist/esm/types.native.js.map +6 -1
- package/dist/esm/useFocusEffect.native.js +25 -22
- package/dist/esm/useFocusEffect.native.js.map +6 -1
- package/dist/esm/useLoader.native.js +50 -50
- package/dist/esm/useLoader.native.js.map +6 -1
- package/dist/esm/useNavigation.native.js +23 -19
- package/dist/esm/useNavigation.native.js.map +6 -1
- package/dist/esm/useScreens.native.js +143 -160
- package/dist/esm/useScreens.native.js.map +6 -1
- package/dist/esm/useViteRoutes.native.js +25 -28
- package/dist/esm/useViteRoutes.native.js.map +6 -1
- package/dist/esm/utils/assertIsReady.native.js +6 -3
- package/dist/esm/utils/assertIsReady.native.js.map +6 -1
- package/dist/esm/utils/dynamicImport.native.js +5 -3
- package/dist/esm/utils/dynamicImport.native.js.map +6 -1
- package/dist/esm/utils/existsAsync.native.js +6 -4
- package/dist/esm/utils/existsAsync.native.js.map +6 -1
- package/dist/esm/utils/getPageExport.native.js +12 -11
- package/dist/esm/utils/getPageExport.native.js.map +6 -1
- package/dist/esm/utils/globDir.native.js +5 -3
- package/dist/esm/utils/globDir.native.js.map +6 -1
- package/dist/esm/utils/hashString.native.js +4 -2
- package/dist/esm/utils/hashString.native.js.map +6 -1
- package/dist/esm/utils/isResponse.native.js +4 -2
- package/dist/esm/utils/isResponse.native.js.map +6 -1
- package/dist/esm/utils/isStatus.native.js +4 -2
- package/dist/esm/utils/isStatus.native.js.map +6 -1
- package/dist/esm/utils/promiseWithResolvers.native.js +7 -7
- package/dist/esm/utils/promiseWithResolvers.native.js.map +6 -1
- package/dist/esm/utils/rand.native.js +5 -3
- package/dist/esm/utils/rand.native.js.map +6 -1
- package/dist/esm/utils/redirect.native.js +7 -5
- package/dist/esm/utils/redirect.native.js.map +6 -1
- package/dist/esm/utils/removeSearch.native.js +4 -2
- package/dist/esm/utils/removeSearch.native.js.map +6 -1
- package/dist/esm/utils/removeUndefined.native.js +6 -3
- package/dist/esm/utils/removeUndefined.native.js.map +6 -1
- package/dist/esm/utils/requireResolve.native.js +4 -2
- package/dist/esm/utils/requireResolve.native.js.map +6 -1
- package/dist/esm/utils/url.native.js +6 -2
- package/dist/esm/utils/url.native.js.map +6 -1
- package/dist/esm/utils/weakKey.native.js +11 -10
- package/dist/esm/utils/weakKey.native.js.map +6 -1
- package/dist/esm/utils/weakMemo.native.js +8 -8
- package/dist/esm/utils/weakMemo.native.js.map +6 -1
- package/dist/esm/views/EmptyRoute.native.js +5 -3
- package/dist/esm/views/EmptyRoute.native.js.map +6 -1
- package/dist/esm/views/ErrorBoundary.native.js +5 -8
- package/dist/esm/views/ErrorBoundary.native.js.map +6 -1
- package/dist/esm/views/LoadProgressBar.native.js +58 -57
- package/dist/esm/views/LoadProgressBar.native.js.map +6 -1
- package/dist/esm/views/Navigator.native.js +54 -71
- package/dist/esm/views/Navigator.native.js.map +6 -1
- package/dist/esm/views/PreloadLinks.native.js +3 -1
- package/dist/esm/views/PreloadLinks.native.js.map +6 -1
- package/dist/esm/views/RootErrorBoundary.native.js +39 -29
- package/dist/esm/views/RootErrorBoundary.native.js.map +6 -1
- package/dist/esm/views/Screen.native.js +12 -12
- package/dist/esm/views/Screen.native.js.map +6 -1
- package/dist/esm/views/ScrollRestoration.native.js +27 -27
- package/dist/esm/views/ScrollRestoration.native.js.map +6 -1
- package/dist/esm/views/Try.native.js +40 -37
- package/dist/esm/views/Try.native.js.map +6 -1
- package/dist/esm/vite/build.native.js +260 -295
- package/dist/esm/vite/build.native.js.map +6 -1
- package/dist/esm/vite/clientTreeShakePlugin.native.js +34 -33
- package/dist/esm/vite/clientTreeShakePlugin.native.js.map +6 -1
- package/dist/esm/vite/constants.native.js +6 -4
- package/dist/esm/vite/constants.native.js.map +6 -1
- package/dist/esm/vite/createFileSystemRouter.native.js +99 -130
- package/dist/esm/vite/createFileSystemRouter.native.js.map +6 -1
- package/dist/esm/vite/customNodeExternals.native.js +9 -10
- package/dist/esm/vite/customNodeExternals.native.js.map +6 -1
- package/dist/esm/vite/ensureTsConfig.native.js +7 -5
- package/dist/esm/vite/ensureTsConfig.native.js.map +6 -1
- package/dist/esm/vite/findDepsToOptimize.native.js +27 -19
- package/dist/esm/vite/findDepsToOptimize.native.js.map +6 -1
- package/dist/esm/vite/fixDependenciesPlugin.native.js +5 -3
- package/dist/esm/vite/fixDependenciesPlugin.native.js.map +6 -1
- package/dist/esm/vite/generateTypesForRoutes.native.js +9 -9
- package/dist/esm/vite/generateTypesForRoutes.native.js.map +6 -1
- package/dist/esm/vite/getManifest.native.js +6 -4
- package/dist/esm/vite/getManifest.native.js.map +6 -1
- package/dist/esm/vite/headers.native.js +11 -5
- package/dist/esm/vite/headers.native.js.map +6 -1
- package/dist/esm/vite/loadEnv.native.js +7 -6
- package/dist/esm/vite/loadEnv.native.js.map +6 -1
- package/dist/esm/vite/makePluginWebOnly.native.js +9 -5
- package/dist/esm/vite/makePluginWebOnly.native.js.map +6 -1
- package/dist/esm/vite/one.native.js +142 -127
- package/dist/esm/vite/one.native.js.map +6 -1
- package/dist/esm/vite/removeReactNativeWebAnimatedPlugin.native.js +14 -11
- package/dist/esm/vite/removeReactNativeWebAnimatedPlugin.native.js.map +6 -1
- package/dist/esm/vite/replaceLoader.js +7 -1
- package/dist/esm/vite/replaceLoader.js.map +1 -1
- package/dist/esm/vite/replaceLoader.mjs +5 -1
- package/dist/esm/vite/replaceLoader.mjs.map +1 -1
- package/dist/esm/vite/replaceLoader.native.js +13 -10
- package/dist/esm/vite/replaceLoader.native.js.map +6 -1
- package/dist/esm/vite/resolveAPIRequest.native.js +44 -47
- package/dist/esm/vite/resolveAPIRequest.native.js.map +6 -1
- package/dist/esm/vite/server.native.js +5 -4
- package/dist/esm/vite/server.native.js.map +6 -1
- package/dist/esm/vite/types.native.js +1 -2
- package/dist/esm/vite/types.native.js.map +6 -1
- package/dist/esm/vite/virtualEntryPlugin.native.js +21 -16
- package/dist/esm/vite/virtualEntryPlugin.native.js.map +6 -1
- package/dist/esm/vite/vitePluginSsrCss.native.js +61 -50
- package/dist/esm/vite/vitePluginSsrCss.native.js.map +6 -1
- package/dist/esm/vite.native.js +19 -10
- package/dist/esm/vite.native.js.map +6 -1
- package/dist/esm/zero/getQueryKey.native.js +5 -3
- package/dist/esm/zero/getQueryKey.native.js.map +6 -1
- package/dist/esm/zero/isZeroQuery.native.js +4 -2
- package/dist/esm/zero/isZeroQuery.native.js.map +6 -1
- package/dist/esm/zero/resolveQuery.native.js +9 -8
- package/dist/esm/zero/resolveQuery.native.js.map +6 -1
- package/dist/esm/zero/subscribeToQuery.native.js +5 -3
- package/dist/esm/zero/subscribeToQuery.native.js.map +6 -1
- package/dist/esm/zero/types.native.js +1 -2
- package/dist/esm/zero/types.native.js.map +6 -1
- package/dist/esm/zero/useQuery.native.js +12 -12
- package/dist/esm/zero/useQuery.native.js.map +6 -1
- package/dist/esm/zero/useQueryZero.native.js +24 -20
- package/dist/esm/zero/useQueryZero.native.js.map +6 -1
- package/dist/esm/zero.native.js +9 -5
- package/dist/esm/zero.native.js.map +6 -1
- package/package.json +7 -7
- package/src/Root.tsx +20 -16
- package/src/cleanUrl.ts +15 -1
- package/src/vite/replaceLoader.ts +7 -1
- package/types/cleanUrl.d.ts.map +1 -1
- package/types/vite/replaceLoader.d.ts.map +1 -1
package/dist/esm/serve.native.js
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
import "./polyfills-server
|
1
|
+
import "./polyfills-server";
|
2
2
|
import FSExtra from "fs-extra";
|
3
3
|
import Path, { join } from "node:path";
|
4
4
|
import { getServerEntry, serve as vxrnServe } from "vxrn";
|
5
|
-
import { createHandleRequest } from "./createHandleRequest
|
6
|
-
import { isResponse } from "./utils/isResponse
|
7
|
-
import { isStatusRedirect } from "./utils/isStatus
|
8
|
-
import { removeUndefined } from "./utils/removeUndefined
|
9
|
-
import { resolveAPIRequest } from "./vite/resolveAPIRequest
|
10
|
-
import { loadUserOneOptions } from "./vite/one
|
11
|
-
import { labelProcess } from "./cli/label-process
|
12
|
-
process.on("uncaughtException", function
|
5
|
+
import { createHandleRequest } from "./createHandleRequest";
|
6
|
+
import { isResponse } from "./utils/isResponse";
|
7
|
+
import { isStatusRedirect } from "./utils/isStatus";
|
8
|
+
import { removeUndefined } from "./utils/removeUndefined";
|
9
|
+
import { resolveAPIRequest } from "./vite/resolveAPIRequest";
|
10
|
+
import { loadUserOneOptions } from "./vite/one";
|
11
|
+
import { labelProcess } from "./cli/label-process";
|
12
|
+
process.on("uncaughtException", function(err) {
|
13
13
|
console.error("[one] Uncaught exception", err?.stack || err);
|
14
14
|
});
|
15
15
|
async function serve() {
|
@@ -36,50 +36,37 @@ async function serve() {
|
|
36
36
|
});
|
37
37
|
}
|
38
38
|
async function oneServe(options, vxrnOptions, app) {
|
39
|
-
var _options_web,
|
40
|
-
|
41
|
-
|
42
|
-
root = options.root || vxrnOptions.root || ".",
|
43
|
-
isAPIRequest = /* @__PURE__ */new WeakMap(),
|
44
|
-
toAbsolute = function (p) {
|
45
|
-
return Path.resolve(root, p);
|
46
|
-
},
|
47
|
-
redirects = (_options_web = options.web) === null || _options_web === void 0 ? void 0 : _options_web.redirects;
|
39
|
+
var _options_web, _options_build_api, _options_build, root = options.root || vxrnOptions.root || ".", isAPIRequest = /* @__PURE__ */ new WeakMap(), toAbsolute = function(p) {
|
40
|
+
return Path.resolve(root, p);
|
41
|
+
}, redirects = (_options_web = options.web) === null || _options_web === void 0 ? void 0 : _options_web.redirects;
|
48
42
|
if (redirects) {
|
49
|
-
var _iteratorNormalCompletion = !0,
|
50
|
-
_didIteratorError = !1,
|
51
|
-
_iteratorError = void 0;
|
43
|
+
var _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
52
44
|
try {
|
53
|
-
for (var _loop = function
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
});
|
60
|
-
return context.redirect(destinationUrl, redirect.permanent ? 301 : 302);
|
45
|
+
for (var _loop = function() {
|
46
|
+
var redirect = _step.value;
|
47
|
+
app.get(redirect.source, function(context) {
|
48
|
+
var destinationUrl = redirect.destination.replace(/:\w+/g, function(param) {
|
49
|
+
var paramName = param.substring(1);
|
50
|
+
return context.req.param(paramName) || "";
|
61
51
|
});
|
62
|
-
|
52
|
+
return context.redirect(destinationUrl, redirect.permanent ? 301 : 302);
|
53
|
+
});
|
54
|
+
}, _iterator = redirects[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) _loop();
|
63
55
|
} catch (err) {
|
64
56
|
_didIteratorError = !0, _iteratorError = err;
|
65
57
|
} finally {
|
66
58
|
try {
|
67
59
|
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
68
60
|
} finally {
|
69
|
-
if (_didIteratorError)
|
61
|
+
if (_didIteratorError)
|
62
|
+
throw _iteratorError;
|
70
63
|
}
|
71
64
|
}
|
72
65
|
}
|
73
66
|
var buildInfo = await FSExtra.readJSON(toAbsolute("dist/buildInfo.json"));
|
74
|
-
if (!buildInfo)
|
75
|
-
|
76
|
-
|
77
|
-
builtRoutes
|
78
|
-
} = buildInfo,
|
79
|
-
routeToBuildInfo = {},
|
80
|
-
_iteratorNormalCompletion1 = !0,
|
81
|
-
_didIteratorError1 = !1,
|
82
|
-
_iteratorError1 = void 0;
|
67
|
+
if (!buildInfo)
|
68
|
+
throw new Error("No build info found, have you run build?");
|
69
|
+
var { routeMap, builtRoutes } = buildInfo, routeToBuildInfo = {}, _iteratorNormalCompletion1 = !0, _didIteratorError1 = !1, _iteratorError1 = void 0;
|
83
70
|
try {
|
84
71
|
for (var _iterator1 = builtRoutes[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = !0) {
|
85
72
|
var route = _step1.value;
|
@@ -91,30 +78,21 @@ async function oneServe(options, vxrnOptions, app) {
|
|
91
78
|
try {
|
92
79
|
!_iteratorNormalCompletion1 && _iterator1.return != null && _iterator1.return();
|
93
80
|
} finally {
|
94
|
-
if (_didIteratorError1)
|
81
|
+
if (_didIteratorError1)
|
82
|
+
throw _iteratorError1;
|
95
83
|
}
|
96
84
|
}
|
97
85
|
var serverOptions = {
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
route: route2,
|
109
|
-
request,
|
110
|
-
loaderProps
|
111
|
-
} = param,
|
112
|
-
apiFile = join(process.cwd(), "dist", "api", route2.page.replace("[", "_").replace("]", "_") + (apiCJS ? ".cjs" : ".js"));
|
113
|
-
return isAPIRequest.set(request, !0), resolveAPIRequest(async function () {
|
114
|
-
try {
|
115
|
-
return await import(apiFile);
|
116
|
-
} catch (err) {
|
117
|
-
return console.error(`
|
86
|
+
...options,
|
87
|
+
root
|
88
|
+
}, entryServer = getServerEntry(serverOptions), entry = await import(entryServer), render = entry.default.render, apiCJS = ((_options_build = options.build) === null || _options_build === void 0 || (_options_build_api = _options_build.api) === null || _options_build_api === void 0 ? void 0 : _options_build_api.outputFormat) === "cjs", handleRequest = createHandleRequest({}, {
|
89
|
+
async handleAPI(param) {
|
90
|
+
var { route: route2, request, loaderProps } = param, apiFile = join(process.cwd(), "dist", "api", route2.page.replace("[", "_").replace("]", "_") + (apiCJS ? ".cjs" : ".js"));
|
91
|
+
return isAPIRequest.set(request, !0), resolveAPIRequest(async function() {
|
92
|
+
try {
|
93
|
+
return await import(apiFile);
|
94
|
+
} catch (err) {
|
95
|
+
return console.error(`
|
118
96
|
[one] Error importing API route at ${apiFile}:
|
119
97
|
|
120
98
|
${err}
|
@@ -127,65 +105,58 @@ async function oneServe(options, vxrnOptions, app) {
|
|
127
105
|
import('${apiFile}')
|
128
106
|
|
129
107
|
`), {};
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
var buildInfo2 =
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
preloads
|
153
|
-
}), {
|
154
|
-
headers
|
155
|
-
});
|
156
|
-
} catch (err) {
|
157
|
-
var _err_stack;
|
158
|
-
console.error(`[one] Error rendering SSR route ${route2.page}
|
108
|
+
}
|
109
|
+
}, request, loaderProps?.params || {});
|
110
|
+
},
|
111
|
+
async handleSSR(param) {
|
112
|
+
var { route: route2, url, loaderProps } = param;
|
113
|
+
if (route2.type === "ssr") {
|
114
|
+
var buildInfo2 = routeToBuildInfo[route2.page];
|
115
|
+
if (!buildInfo2)
|
116
|
+
throw new Error(`No buildinfo found for ${url}, route: ${route2.page}`);
|
117
|
+
try {
|
118
|
+
var _exported_loader, exported = await import(buildInfo2.serverJsPath), loaderData = await ((_exported_loader = exported.loader) === null || _exported_loader === void 0 ? void 0 : _exported_loader.call(exported, loaderProps)), preloads = buildInfo2.preloads, headers = new Headers();
|
119
|
+
return headers.set("content-type", "text/html"), new Response(await render({
|
120
|
+
loaderData,
|
121
|
+
loaderProps,
|
122
|
+
path: loaderProps?.path || "/",
|
123
|
+
preloads
|
124
|
+
}), {
|
125
|
+
headers
|
126
|
+
});
|
127
|
+
} catch (err) {
|
128
|
+
var _err_stack;
|
129
|
+
console.error(`[one] Error rendering SSR route ${route2.page}
|
159
130
|
|
160
131
|
${(_err_stack = err?.stack) !== null && _err_stack !== void 0 ? _err_stack : err}
|
161
132
|
|
162
133
|
url: ${url}`);
|
163
|
-
}
|
164
134
|
}
|
165
135
|
}
|
166
|
-
}
|
167
|
-
|
136
|
+
}
|
137
|
+
}), htmlFiles = {};
|
168
138
|
for (var key in routeMap) {
|
169
139
|
var info = routeToBuildInfo[key];
|
170
140
|
info?.type !== "ssr" && (htmlFiles[key] = await FSExtra.readFile(join("dist/client", routeMap[key]), "utf-8"));
|
171
141
|
}
|
172
|
-
app.use(async function
|
142
|
+
app.use(async function(context, next) {
|
173
143
|
var html = htmlFiles[context.req.path];
|
174
|
-
if (html)
|
144
|
+
if (html)
|
145
|
+
return context.html(html);
|
175
146
|
try {
|
176
|
-
var request = context.req.raw,
|
177
|
-
response = await handleRequest.handler(request);
|
147
|
+
var request = context.req.raw, response = await handleRequest.handler(request);
|
178
148
|
if (response) {
|
179
149
|
if (isResponse(response)) {
|
180
150
|
if (isStatusRedirect(response.status)) {
|
181
151
|
var location = `${response.headers.get("location") || ""}`;
|
182
152
|
return context.redirect(location, response.status);
|
183
153
|
}
|
184
|
-
if (isAPIRequest.get(request))
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
154
|
+
if (isAPIRequest.get(request))
|
155
|
+
try {
|
156
|
+
response.headers.set("Cache-Control", "no-store");
|
157
|
+
} catch (err) {
|
158
|
+
console.info(`Error udpating cache header on api route "${context.req.path}" to no-store, it is ${response.headers.get("cache-control")}, continue`, err);
|
159
|
+
}
|
189
160
|
return response;
|
190
161
|
}
|
191
162
|
return context.json(response, 200, isAPIRequest.get(request) ? {
|
@@ -198,5 +169,7 @@ async function oneServe(options, vxrnOptions, app) {
|
|
198
169
|
await next();
|
199
170
|
});
|
200
171
|
}
|
201
|
-
export {
|
202
|
-
|
172
|
+
export {
|
173
|
+
serve
|
174
|
+
};
|
175
|
+
//# sourceMappingURL=serve.js.map
|
@@ -1 +1,6 @@
|
|
1
|
-
{
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../src/Users/n8/one/packages/one/src/serve.ts"],
|
4
|
+
"mappings": "AAAA,OAAO;AAEP,OAAOA,aAAa;AAEpB,OAAOC,QAAQC,YAAY;AAE3B,SAASC,gBAAgBC,SAASC,iBAAiB;AACnD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AI8B,OAAAA,IACb;UACE,iBAAiB;QACnB,IACAjD,MAAAA;MAER;IACF,SAASV,KAAK;AACZC,cAAQC,MAAM,kCAAmCF,IAAY,KAAQ,EAAE;IACzE;AAEA,UAAMmF,KAAAA;EACR,CAAA;AACF;",
|
5
|
+
"names": ["FSExtra", "Path", "join", "getServerEntry", "serve", "vxrnServe", "createHandleRequest", "isResponse", "isStatusRedirect", "removeUndefined", "resolveAPIRequest", "loadUserOneOptions", "labelProcess", "process", "on", "err", "console", "error", "stack", "args", "oneOptions", "env", "VXRN_REACT_19", "server", "port", "undefined", "host", "compress", "platform", "cacheHeaders", "beforeStart", "options", "app", "oneServe", "vxrnOptions", "root", "isAPIRequest", "WeakMap", "toAbsolute", "p", "resolve", "redirects", "web", "redirect", "get", "source", "context", "destinationUrl", "destination", "replace", "param", "paramName", "substring", "req", "permanent", "buildInfo", "readJSON", "Error", "routeMap", "builtRoutes", "routeToBuildInfo", "route", "cleanPath", "serverOptions", "entryServer", "entry", "render", "default", "apiCJS", "build", "api", "outputFormat", "handleRequest", "handleAPI", "request", "loaderProps", "apiFile", "cwd", "page", "set", "params", "handleSSR", "url", "type", "exported", "serverJsPath", "loaderData", "loader", "preloads", "headers", "Headers", "Response", "path", "htmlFiles", "key", "info", "readFile", "use", "next", "html", "raw", "response", "handler", "status", "location", "json"]
|
6
|
+
}
|
@@ -1,14 +1,14 @@
|
|
1
|
-
import { getRoutes } from "../getRoutes
|
2
|
-
import { getServerManifest } from "./getServerManifest
|
1
|
+
import { getRoutes } from "../getRoutes";
|
2
|
+
import { getServerManifest } from "./getServerManifest";
|
3
3
|
function createMockModuleWithContext() {
|
4
|
-
var map = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [],
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
};
|
4
|
+
var map = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], contextModule = function(key) {
|
5
|
+
return {
|
6
|
+
default() {
|
7
|
+
}
|
9
8
|
};
|
9
|
+
};
|
10
10
|
return Object.defineProperty(contextModule, "keys", {
|
11
|
-
value: function
|
11
|
+
value: function() {
|
12
12
|
return map;
|
13
13
|
}
|
14
14
|
}), contextModule;
|
@@ -21,8 +21,11 @@ function createRoutesManifest(paths, options) {
|
|
21
21
|
ignoreEntryPoints: !0,
|
22
22
|
platform: "web"
|
23
23
|
});
|
24
|
-
if (!routeTree)
|
24
|
+
if (!routeTree)
|
25
|
+
throw new Error(`No route tree found in paths: ${JSON.stringify(paths)}`);
|
25
26
|
return getServerManifest(routeTree);
|
26
27
|
}
|
27
|
-
export {
|
28
|
-
|
28
|
+
export {
|
29
|
+
createRoutesManifest
|
30
|
+
};
|
31
|
+
//# sourceMappingURL=createRoutesManifest.js.map
|
@@ -1 +1,6 @@
|
|
1
|
-
{
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../src/server/Users/n8/one/packages/one/src/server/createRoutesManifest.ts"],
|
4
|
+
"mappings": "AAAA,SAAuBA,iBAAiB;AACxC,SAASC,yBAAyB;AAqBlC,SAASC,8BAAAA;MAA4BC,MAAAA,UAAAA,SAAAA,KAAAA,UAAAA,CAAAA,MAAAA,SAAAA,UAAAA,CAAAA,IAAgB,CAAA,GAC7CC,gBAAgB,SAACC,KAAAA;WAAS;MAAEC,UAAAA;MAAW;IAAE;;AAE/CC,gBAAOC,eAAeJ,eAAe,QAAQ;IAC3CK,OAAO,WAAA;aAAMN;;EACf,CAAA,GAEOC;AACT;AAEO,SAASM,qBAAqBC,OAAiBC,SAAgB;AACpE,MAAMC,YAAYb,UAAUE,4BAA4BS,KAAAA,GAAQ;IAC9D,GAAGC;IACHE,mBAAmB;IACnBC,qBAAqB;IACrBC,mBAAmB;IACnBC,UAAU;EACZ,CAAA;AAEA,MAAI,CAACJ;AACH,UAAM,IAAIK,MAAM,iCAAiCC,KAAKC,UAAUT,KAAAA,CAAAA,EAAQ;AAG1E,SAAOV,kBAAkBY,SAAAA;AAC3B;",
|
5
|
+
"names": ["getRoutes", "getServerManifest", "createMockModuleWithContext", "map", "contextModule", "key", "default", "Object", "defineProperty", "value", "createRoutesManifest", "paths", "options", "routeTree", "preserveApiRoutes", "ignoreRequireErrors", "ignoreEntryPoints", "platform", "Error", "JSON", "stringify"]
|
6
|
+
}
|
@@ -1,35 +1,43 @@
|
|
1
|
-
import { getContextKey, matchGroupName } from "../matchers
|
2
|
-
import { sortRoutes } from "../sortRoutes
|
1
|
+
import { getContextKey, matchGroupName } from "../matchers";
|
2
|
+
import { sortRoutes } from "../sortRoutes";
|
3
3
|
function isNotFoundRoute(route) {
|
4
4
|
return !!(route.dynamic && route.dynamic[route.dynamic.length - 1].notFound);
|
5
5
|
}
|
6
6
|
function getServerManifest(route) {
|
7
7
|
function getFlatNodes(route2, layouts) {
|
8
|
-
if (route2.children.length)
|
9
|
-
return
|
10
|
-
|
8
|
+
if (route2.children.length)
|
9
|
+
return route2.children.flatMap(function(child) {
|
10
|
+
return getFlatNodes(child, [
|
11
|
+
...layouts || [],
|
12
|
+
route2
|
13
|
+
]);
|
14
|
+
});
|
11
15
|
var key;
|
12
|
-
if (route2.type === "api")
|
13
|
-
|
16
|
+
if (route2.type === "api")
|
17
|
+
key = getContextKey(route2.contextKey).replace(/\/index$/, "") || "/";
|
18
|
+
else {
|
19
|
+
var parentSegments = layouts?.flatMap(function(route3) {
|
14
20
|
var key2 = getContextKey(route3.route).replace(/\/index$/, "") || "/";
|
15
|
-
return key2 === "/" || key2.startsWith("/(") ? [] : [
|
21
|
+
return key2 === "/" || key2.startsWith("/(") ? [] : [
|
22
|
+
key2
|
23
|
+
];
|
16
24
|
});
|
17
25
|
key = parentSegments + getContextKey(route2.route).replace(/\/index$/, "") || "/";
|
18
26
|
}
|
19
|
-
return [
|
20
|
-
|
21
|
-
|
22
|
-
|
27
|
+
return [
|
28
|
+
[
|
29
|
+
key,
|
30
|
+
{
|
31
|
+
...route2,
|
32
|
+
layouts
|
33
|
+
}
|
34
|
+
]
|
35
|
+
];
|
23
36
|
}
|
24
|
-
var flat = getFlatNodes(route).sort(function
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
}).reverse(),
|
29
|
-
pathToRoute = {},
|
30
|
-
_iteratorNormalCompletion = !0,
|
31
|
-
_didIteratorError = !1,
|
32
|
-
_iteratorError = void 0;
|
37
|
+
var flat = getFlatNodes(route).sort(function(param, param1) {
|
38
|
+
var [, a] = param, [, b] = param1;
|
39
|
+
return sortRoutes(b, a);
|
40
|
+
}).reverse(), pathToRoute = {}, _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
33
41
|
try {
|
34
42
|
for (var _iterator = flat[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
35
43
|
var [path, _$route] = _step.value;
|
@@ -43,14 +51,11 @@ function getServerManifest(route) {
|
|
43
51
|
try {
|
44
52
|
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
45
53
|
} finally {
|
46
|
-
if (_didIteratorError)
|
54
|
+
if (_didIteratorError)
|
55
|
+
throw _iteratorError;
|
47
56
|
}
|
48
57
|
}
|
49
|
-
var apiRoutes = [],
|
50
|
-
pageRoutes = [],
|
51
|
-
_iteratorNormalCompletion1 = !0,
|
52
|
-
_didIteratorError1 = !1,
|
53
|
-
_iteratorError1 = void 0;
|
58
|
+
var apiRoutes = [], pageRoutes = [], _iteratorNormalCompletion1 = !0, _didIteratorError1 = !1, _iteratorError1 = void 0;
|
54
59
|
try {
|
55
60
|
for (var _iterator1 = flat[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = !0) {
|
56
61
|
var [path1, node] = _step1.value;
|
@@ -66,7 +71,8 @@ function getServerManifest(route) {
|
|
66
71
|
try {
|
67
72
|
!_iteratorNormalCompletion1 && _iterator1.return != null && _iterator1.return();
|
68
73
|
} finally {
|
69
|
-
if (_didIteratorError1)
|
74
|
+
if (_didIteratorError1)
|
75
|
+
throw _iteratorError1;
|
70
76
|
}
|
71
77
|
}
|
72
78
|
return {
|
@@ -93,10 +99,10 @@ function getNamedRouteRegex(normalizedRoute, node) {
|
|
93
99
|
};
|
94
100
|
}
|
95
101
|
function buildGetSafeRouteKey() {
|
96
|
-
var currentCharCode = 96,
|
97
|
-
|
98
|
-
|
99
|
-
|
102
|
+
var currentCharCode = 96, currentLength = 1;
|
103
|
+
return function() {
|
104
|
+
for (var result = "", incrementNext = !0, i = 0; i < currentLength; i++)
|
105
|
+
incrementNext && (currentCharCode++, currentCharCode > 122 ? (currentCharCode = 97, incrementNext = !0) : incrementNext = !1), result = String.fromCharCode(currentCharCode) + result;
|
100
106
|
return incrementNext && (currentLength++, currentCharCode = 96), result;
|
101
107
|
};
|
102
108
|
}
|
@@ -104,54 +110,42 @@ function removeTrailingSlash(route) {
|
|
104
110
|
return route.replace(/\/$/, "") || "/";
|
105
111
|
}
|
106
112
|
function getNamedRegex(route) {
|
107
|
-
var segments = removeTrailingSlash(route).slice(1).split("/"),
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
return (cleanedKey.length === 0 || cleanedKey.length > 30) && (invalidKey = !0), Number.isNaN(Number.parseInt(cleanedKey.slice(0, 1), 10)) || (invalidKey = !0), cleanedKey in routeKeys && (invalidKey = !0), invalidKey && (cleanedKey = getSafeRouteKey()), routeKeys[cleanedKey] = name, repeat ? optional ? `(?:/(?<${cleanedKey}>.+?))?` : `/(?<${cleanedKey}>.+?)` : `/(?<${cleanedKey}>[^/]+?)`;
|
120
|
-
}
|
121
|
-
if (insideParensRegex.test(segment)) {
|
122
|
-
var groupName = matchGroupName(segment).split(",").map(function (group) {
|
123
|
-
return group.trim();
|
124
|
-
}).filter(Boolean);
|
125
|
-
if (groupName.length > 1) {
|
126
|
-
var optionalSegment = `\\((?:${groupName.map(escapeStringRegexp).join("|")})\\)`;
|
127
|
-
return `(?:/${optionalSegment})?`;
|
128
|
-
}
|
129
|
-
return `(?:/${escapeStringRegexp(segment)})?`;
|
113
|
+
var segments = removeTrailingSlash(route).slice(1).split("/"), getSafeRouteKey = buildGetSafeRouteKey(), routeKeys = {}, routeSegments = segments.map(function(segment, index) {
|
114
|
+
if (segment === "+not-found" && index === segments.length - 1 && (segment = "[...not-found]"), /^\[.*\]$/.test(segment)) {
|
115
|
+
var { name, optional, repeat } = parseParam(segment), cleanedKey = name.replace(/\W/g, ""), invalidKey = !1;
|
116
|
+
return (cleanedKey.length === 0 || cleanedKey.length > 30) && (invalidKey = !0), Number.isNaN(Number.parseInt(cleanedKey.slice(0, 1), 10)) || (invalidKey = !0), cleanedKey in routeKeys && (invalidKey = !0), invalidKey && (cleanedKey = getSafeRouteKey()), routeKeys[cleanedKey] = name, repeat ? optional ? `(?:/(?<${cleanedKey}>.+?))?` : `/(?<${cleanedKey}>.+?)` : `/(?<${cleanedKey}>[^/]+?)`;
|
117
|
+
}
|
118
|
+
if (insideParensRegex.test(segment)) {
|
119
|
+
var groupName = matchGroupName(segment).split(",").map(function(group) {
|
120
|
+
return group.trim();
|
121
|
+
}).filter(Boolean);
|
122
|
+
if (groupName.length > 1) {
|
123
|
+
var optionalSegment = `\\((?:${groupName.map(escapeStringRegexp).join("|")})\\)`;
|
124
|
+
return `(?:/${optionalSegment})?`;
|
130
125
|
}
|
131
|
-
return
|
132
|
-
}
|
126
|
+
return `(?:/${escapeStringRegexp(segment)})?`;
|
127
|
+
}
|
128
|
+
return `/${escapeStringRegexp(segment)}`;
|
129
|
+
}).join("");
|
133
130
|
return {
|
134
131
|
namedRegex: `^${routeSegments}(?:/)?$`,
|
135
132
|
routeKeys
|
136
133
|
};
|
137
134
|
}
|
138
|
-
var insideBracketsRegex = /^\[.*\]$/,
|
139
|
-
insideParensRegex = /^\(.*\)$/,
|
140
|
-
tripleDotRegex = /^\.\.\./,
|
141
|
-
replaceRegex = /[|\\{}()[\]^$+*?.-]/g,
|
142
|
-
hasRegExpRegex = /[|\\{}()[\]^$+*?.-]/;
|
135
|
+
var insideBracketsRegex = /^\[.*\]$/, insideParensRegex = /^\(.*\)$/, tripleDotRegex = /^\.\.\./, replaceRegex = /[|\\{}()[\]^$+*?.-]/g, hasRegExpRegex = /[|\\{}()[\]^$+*?.-]/;
|
143
136
|
function escapeStringRegexp(str) {
|
144
137
|
return hasRegExpRegex.test(str) ? str.replace(replaceRegex, "\\$&") : str;
|
145
138
|
}
|
146
139
|
function parseParam(param) {
|
147
|
-
var repeat = !1,
|
148
|
-
optional = !1,
|
149
|
-
name = param;
|
140
|
+
var repeat = !1, optional = !1, name = param;
|
150
141
|
return insideBracketsRegex.test(name) && (optional = !0, name = name.slice(1, -1)), tripleDotRegex.test(name) && (repeat = !0, name = name.slice(3)), {
|
151
142
|
name,
|
152
143
|
repeat,
|
153
144
|
optional
|
154
145
|
};
|
155
146
|
}
|
156
|
-
export {
|
157
|
-
|
147
|
+
export {
|
148
|
+
getServerManifest,
|
149
|
+
parseParam
|
150
|
+
};
|
151
|
+
//# sourceMappingURL=getServerManifest.js.map
|
@@ -1 +1,6 @@
|
|
1
|
-
{
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../src/server/Users/n8/one/packages/one/src/server/getServerManifest.ts"],
|
4
|
+
"mappings": "AAWA,SAASA,eAAeC,sBAAsB;AAC9C,SAASC,kBAAkB;AA+B3B,SAASC,gBAAgBC,OAAgB;AACvC,SAAOC,GAAQD,MAAME,WAAWF,MAAME,QAAQF,MAAME,QAAQC,SAAS,CAAA,EAAGC;AAC1E;AAGO,SAASC,kBAAkBL,OAAgB;AAChD,WAASM,aAAaN,QAAkBO,SAAqB;AAC3D,QAAIP,OAAMQ,SAASL;AACjB,aAAOH,OAAMQ,SAASC,QAAQ,SAACC,OAAAA;AAC7B,eAAOJ,aAAaI,OAAO;aAAKH,WAAW,CAAA;UAAKP;SAAM;MACxD,CAAA;A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O,IAAIkB,mBAAmBlB,OAAAA,CAAAA;EAChC,CAAA,EACCmB,KAAK,EAAA;AAER,SAAO;IACLnC,YAAY,IAAIc,aAAAA;IAChBb;EACF;AACF;AAEA,IAAMmC,sBAAsB,YACtBR,oBAAoB,YACpBS,iBAAiB,WACjBC,eAAe,wBAEfC,iBAAiB;AAEvB,SAASL,mBAAmBM,KAAW;AAErC,SAAID,eAAerB,KAAKsB,GAAAA,IACfA,IAAIjE,QAAQ+D,cAAc,MAAA,IAE5BE;AACT;AAEO,SAASlB,WAAWmB,OAAa;AACtC,MAAIpB,SAAS,IACTD,WAAW,IACXD,OAAOsB;AAEX,SAAIL,oBAAoBlB,KAAKC,IAAAA,MAC3BC,WAAW,IACXD,OAAOA,KAAKR,MAAM,GAAG,EAAC,IAGpB0B,eAAenB,KAAKC,IAAAA,MACtBE,SAAS,IACTF,OAAOA,KAAKR,MAAM,CAAA,IAGb;IAAEQ;IAAME;IAAQD;EAAS;AAClC;",
|
5
|
+
"names": ["getContextKey", "matchGroupName", "sortRoutes", "isNotFoundRoute", "route", "Boolean", "dynamic", "length", "notFound", "getServerManifest", "getFlatNodes", "layouts", "children", "flatMap", "child", "key", "type", "contextKey", "replace", "parentSegments", "startsWith", "flat", "sort", "a", "b", "reverse", "pathToRoute", "path", "console", "warn", "apiRoutes", "pageRoutes", "node", "push", "getGeneratedNamedRouteRegex", "normalizedRoute", "getNamedRouteRegex", "generated", "isNotFound", "result", "getNamedRegex", "file", "page", "namedRegex", "routeKeys", "buildGetSafeRouteKey", "currentCharCode", "currentLength", "incrementNext", "i", "String", "fromCharCode", "removeTrailingSlash", "segments", "slice", "split", "getSafeRouteKey", "routeSegments", "map", "segment", "index", "test", "name", "optional", "repeat", "parseParam", "cleanedKey", "invalidKey", "Number", "isNaN", "parseInt", "insideParensRegex", "groupName", "group", "trim", "filter", "optionalSegment", "escapeStringRegexp", "join", "insideBracketsRegex", "tripleDotRegex", "replaceRegex", "hasRegExpRegex", "str", "param"]
|
6
|
+
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import ReactDOMServer from "react-dom/server.browser";
|
2
|
-
var renderToString = async function
|
2
|
+
var renderToString = async function(app, options) {
|
3
3
|
var readableStream = await ReactDOMServer.renderToReadableStream(app, {
|
4
4
|
bootstrapModules: options.preloads
|
5
5
|
});
|
@@ -9,12 +9,8 @@ var renderToString = async function (app, options) {
|
|
9
9
|
};
|
10
10
|
async function streamToString(stream) {
|
11
11
|
var decoder = new TextDecoder("utf-8", {
|
12
|
-
|
13
|
-
|
14
|
-
result = "",
|
15
|
-
_iteratorNormalCompletion = !0,
|
16
|
-
_didIteratorError = !1,
|
17
|
-
_iteratorError = void 0;
|
12
|
+
fatal: !0
|
13
|
+
}), result = "", _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
18
14
|
try {
|
19
15
|
for (var _iterator = stream[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
20
16
|
var chunk = _step.value;
|
@@ -28,10 +24,13 @@ async function streamToString(stream) {
|
|
28
24
|
try {
|
29
25
|
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
30
26
|
} finally {
|
31
|
-
if (_didIteratorError)
|
27
|
+
if (_didIteratorError)
|
28
|
+
throw _iteratorError;
|
32
29
|
}
|
33
30
|
}
|
34
31
|
return result += decoder.decode(), result;
|
35
32
|
}
|
36
|
-
export {
|
37
|
-
|
33
|
+
export {
|
34
|
+
renderToString
|
35
|
+
};
|
36
|
+
//# sourceMappingURL=server-render.js.map
|
@@ -1 +1,6 @@
|
|
1
|
-
{
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../src/Users/n8/one/packages/one/src/server-render.tsx"],
|
4
|
+
"mappings": "AACA,OAAOA,oBAAoB;AAEpB,IAAMC,iBAAiB,eAAOC,KAAyBC,SAAAA;AAC5D,MAAMC,iBAAiB,MAAMJ,eAAeK,uBAAuBH,KAAK;IACtEI,kBAAkBH,QAAQI;EAC5B,CAAA;AACA,QAAMH,eAAeI;AACrB,MAAMC,MAAM,MAAMC,eAAeN,cAAAA;AACjC,SAAOK;AACT;AAEA,eAAeC,eAAeC,QAAkC;AAC9D,MAAMC,UAAU,IAAIC,YAAY,SAAS;IAAEC,OAAO;EAAK,CAAA,GACnDC,SAAS,IAGF,4BAAA,IAAA,oBAAA,IAAA,iBAAA;;AAAX,aAAW,YAAeJ,OAAAA,OAAAA,QAAAA,EAAAA,GAAf,OAAA,EAAA,6BAAA,QAAA,UAAA,KAAA,GAAA,OAAA,4BAAA,IAAuB;AAAvB,UAAMK,QAAN,MAAA;AACTD,gBAAUH,QAAQK,OAAOD,OAAO;QAAEL,QAAQ;MAAK,CAAA;IACjD;;AAFW,wBAAA,IAAA,iBAAA;;;OAAA,6BAAA,UAAA,UAAA,QAAA,UAAA,OAAA;;UAAA;cAAA;;;AAIXI,mBAAUH,QAAQK,OAAM,GACjBF;AACT;",
|
5
|
+
"names": ["ReactDOMServer", "renderToString", "app", "options", "readableStream", "renderToReadableStream", "bootstrapModules", "preloads", "allReady", "out", "streamToString", "stream", "decoder", "TextDecoder", "fatal", "result", "chunk", "decode"]
|
6
|
+
}
|