one 1.1.311 → 1.1.312
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/cleanUrl.cjs +3 -8
- package/dist/cjs/cleanUrl.cjs.map +2 -2
- package/dist/cjs/cleanUrl.native.js +5 -8
- package/dist/cjs/cleanUrl.native.js.map +2 -2
- package/dist/cjs/cli.cjs +0 -2
- package/dist/cjs/cli.cjs.map +1 -1
- package/dist/cjs/cli.native.js +1 -2
- package/dist/cjs/cli.native.js.map +2 -2
- package/dist/cjs/config.cjs +1 -1
- package/dist/cjs/config.native.js +1 -1
- package/dist/cjs/config.native.js.map +1 -1
- package/dist/cjs/constants.cjs +9 -1
- package/dist/cjs/constants.cjs.map +1 -1
- package/dist/cjs/constants.native.js +9 -1
- package/dist/cjs/constants.native.js.map +2 -2
- package/dist/cjs/createApp.native.cjs +1 -1
- package/dist/cjs/createApp.native.js +1 -1
- package/dist/cjs/createApp.native.js.map +1 -1
- package/dist/cjs/createHandleRequest.cjs +2 -1
- package/dist/cjs/createHandleRequest.cjs.map +1 -1
- package/dist/cjs/createHandleRequest.native.js +2 -2
- package/dist/cjs/createHandleRequest.native.js.map +2 -2
- package/dist/cjs/matchers.cjs +1 -1
- package/dist/cjs/matchers.cjs.map +1 -1
- package/dist/cjs/matchers.native.js +1 -1
- package/dist/cjs/matchers.native.js.map +1 -1
- package/dist/cjs/serve.cjs +3 -3
- package/dist/cjs/serve.cjs.map +1 -1
- package/dist/cjs/serve.native.js +2 -2
- package/dist/cjs/serve.native.js.map +2 -2
- package/dist/cjs/useLoader.cjs +1 -1
- package/dist/cjs/useLoader.native.js +1 -1
- package/dist/cjs/vite/build.cjs +2 -2
- package/dist/cjs/vite/build.cjs.map +1 -1
- package/dist/cjs/vite/build.native.js +1 -1
- package/dist/cjs/vite/build.native.js.map +1 -1
- package/dist/cjs/vite/clientTreeShakePlugin.cjs +1 -1
- package/dist/cjs/vite/clientTreeShakePlugin.native.js +1 -1
- package/dist/cjs/vite/createFileSystemRouter.cjs +1 -1
- package/dist/cjs/vite/createFileSystemRouter.native.js +1 -1
- package/dist/cjs/vite/one.cjs +43 -14
- package/dist/cjs/vite/one.cjs.map +1 -1
- package/dist/cjs/vite/one.native.js +39 -12
- package/dist/cjs/vite/one.native.js.map +2 -2
- package/dist/cjs/vite/virtualEntryPlugin.cjs +5 -5
- package/dist/cjs/vite/virtualEntryPlugin.native.js +5 -5
- package/dist/cjs/vite/virtualEntryPlugin.native.js.map +1 -1
- package/dist/cjs/vite/vitePluginSsrCss.cjs +1 -1
- package/dist/cjs/vite/vitePluginSsrCss.native.js +1 -1
- package/dist/esm/cleanUrl.js +10 -9
- package/dist/esm/cleanUrl.js.map +1 -1
- package/dist/esm/cleanUrl.mjs +4 -9
- package/dist/esm/cleanUrl.mjs.map +1 -1
- package/dist/esm/cleanUrl.native.js +5 -9
- package/dist/esm/cleanUrl.native.js.map +2 -2
- package/dist/esm/cli.js +0 -2
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/cli.mjs +0 -2
- package/dist/esm/cli.mjs.map +1 -1
- package/dist/esm/cli.native.js +0 -2
- package/dist/esm/cli.native.js.map +2 -2
- package/dist/esm/config.js +1 -1
- package/dist/esm/config.mjs +1 -1
- package/dist/esm/config.mjs.map +1 -1
- package/dist/esm/config.native.js +1 -1
- package/dist/esm/config.native.js.map +1 -1
- package/dist/esm/constants.js +5 -1
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/constants.mjs +6 -2
- package/dist/esm/constants.mjs.map +1 -1
- package/dist/esm/constants.native.js +5 -1
- package/dist/esm/constants.native.js.map +2 -2
- package/dist/esm/createApp.native.js +1 -1
- package/dist/esm/createApp.native.js.map +1 -1
- package/dist/esm/createHandleRequest.js +2 -1
- package/dist/esm/createHandleRequest.js.map +1 -1
- package/dist/esm/createHandleRequest.mjs +2 -1
- package/dist/esm/createHandleRequest.mjs.map +1 -1
- package/dist/esm/createHandleRequest.native.js +2 -1
- package/dist/esm/createHandleRequest.native.js.map +2 -2
- package/dist/esm/matchers.js +1 -1
- package/dist/esm/matchers.js.map +1 -1
- package/dist/esm/matchers.mjs +1 -1
- package/dist/esm/matchers.mjs.map +1 -1
- package/dist/esm/matchers.native.js +1 -1
- package/dist/esm/matchers.native.js.map +1 -1
- package/dist/esm/serve.js +4 -4
- package/dist/esm/serve.js.map +1 -1
- package/dist/esm/serve.mjs +4 -4
- package/dist/esm/serve.mjs.map +1 -1
- package/dist/esm/serve.native.js +4 -4
- package/dist/esm/serve.native.js.map +2 -2
- package/dist/esm/useLoader.js +1 -1
- package/dist/esm/useLoader.mjs +1 -1
- package/dist/esm/useLoader.native.js +1 -1
- package/dist/esm/vite/build.js +1 -1
- package/dist/esm/vite/build.js.map +1 -1
- package/dist/esm/vite/build.mjs +1 -1
- package/dist/esm/vite/build.mjs.map +1 -1
- package/dist/esm/vite/build.native.js +1 -1
- package/dist/esm/vite/build.native.js.map +2 -2
- package/dist/esm/vite/clientTreeShakePlugin.js +1 -1
- package/dist/esm/vite/clientTreeShakePlugin.mjs +1 -1
- package/dist/esm/vite/clientTreeShakePlugin.native.js +1 -1
- package/dist/esm/vite/createFileSystemRouter.js +1 -1
- package/dist/esm/vite/createFileSystemRouter.mjs +1 -1
- package/dist/esm/vite/createFileSystemRouter.native.js +1 -1
- package/dist/esm/vite/one.js +43 -14
- package/dist/esm/vite/one.js.map +1 -1
- package/dist/esm/vite/one.mjs +43 -14
- package/dist/esm/vite/one.mjs.map +1 -1
- package/dist/esm/vite/one.native.js +41 -14
- package/dist/esm/vite/one.native.js.map +2 -2
- package/dist/esm/vite/virtualEntryPlugin.js +5 -5
- package/dist/esm/vite/virtualEntryPlugin.mjs +5 -5
- package/dist/esm/vite/virtualEntryPlugin.mjs.map +1 -1
- package/dist/esm/vite/virtualEntryPlugin.native.js +5 -5
- package/dist/esm/vite/virtualEntryPlugin.native.js.map +1 -1
- package/dist/esm/vite/vitePluginSsrCss.js +1 -1
- package/dist/esm/vite/vitePluginSsrCss.mjs +1 -1
- package/dist/esm/vite/vitePluginSsrCss.native.js +1 -1
- package/package.json +8 -8
- package/src/cleanUrl.ts +10 -14
- package/src/cli.ts +0 -3
- package/src/config.ts +1 -1
- package/src/constants.ts +6 -0
- package/src/createApp.native.tsx +2 -2
- package/src/createHandleRequest.ts +2 -1
- package/src/matchers.ts +1 -1
- package/src/serve.ts +5 -3
- package/src/useLoader.ts +1 -1
- package/src/vite/build.ts +2 -1
- package/src/vite/clientTreeShakePlugin.ts +1 -1
- package/src/vite/createFileSystemRouter.tsx +1 -1
- package/src/vite/one.ts +44 -11
- package/src/vite/virtualEntryPlugin.ts +5 -5
- package/src/vite/vitePluginSsrCss.ts +1 -1
- package/types/cleanUrl.d.ts.map +1 -1
- package/types/constants.d.ts +4 -0
- package/types/constants.d.ts.map +1 -1
- package/types/createHandleRequest.d.ts.map +1 -1
- package/types/serve.d.ts.map +1 -1
- package/types/vite/build.d.ts.map +1 -1
- package/types/vite/one.d.ts.map +1 -1
- package/dist/cjs/router/constants.cjs +0 -26
- package/dist/cjs/router/constants.cjs.map +0 -6
- package/dist/cjs/router/constants.native.js +0 -26
- package/dist/cjs/router/constants.native.js.map +0 -6
- package/dist/cjs/vite/loadEnv.cjs +0 -47
- package/dist/cjs/vite/loadEnv.cjs.map +0 -6
- package/dist/cjs/vite/loadEnv.native.js +0 -44
- package/dist/cjs/vite/loadEnv.native.js.map +0 -6
- package/dist/esm/router/constants.js +0 -5
- package/dist/esm/router/constants.js.map +0 -6
- package/dist/esm/router/constants.mjs +0 -3
- package/dist/esm/router/constants.mjs.map +0 -1
- package/dist/esm/router/constants.native.js +0 -5
- package/dist/esm/router/constants.native.js.map +0 -6
- package/dist/esm/vite/loadEnv.js +0 -13
- package/dist/esm/vite/loadEnv.js.map +0 -6
- package/dist/esm/vite/loadEnv.mjs +0 -13
- package/dist/esm/vite/loadEnv.mjs.map +0 -1
- package/dist/esm/vite/loadEnv.native.js +0 -16
- package/dist/esm/vite/loadEnv.native.js.map +0 -6
- package/src/router/constants.ts +0 -4
- package/src/vite/loadEnv.ts +0 -11
- package/types/router/constants.d.ts +0 -2
- package/types/router/constants.d.ts.map +0 -1
- package/types/vite/loadEnv.d.ts +0 -2
- package/types/vite/loadEnv.d.ts.map +0 -1
@@ -2,7 +2,7 @@ var VIRTUAL_ENTRY = "virtual:ssr-css.css";
|
|
2
2
|
function vitePluginSsrCss(pluginOpts) {
|
3
3
|
var server, virtualHref = "/@id/__x00__" + VIRTUAL_ENTRY;
|
4
4
|
return {
|
5
|
-
name: "
|
5
|
+
name: "one-plugin-ssr-css",
|
6
6
|
apply: "serve",
|
7
7
|
configureServer(server_) {
|
8
8
|
server = server_, server.middlewares.use(async function(req, res, next) {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "one",
|
3
|
-
"version": "1.1.
|
3
|
+
"version": "1.1.312",
|
4
4
|
"source": "src/index.ts",
|
5
5
|
"types": "./types/index.d.ts",
|
6
6
|
"sideEffects": false,
|
@@ -82,6 +82,7 @@
|
|
82
82
|
"@babel/parser": "^7.25.4",
|
83
83
|
"@babel/traverse": "^7.25.4",
|
84
84
|
"@radix-ui/react-slot": "^1.0.2",
|
85
|
+
"@react-native-masked-view/masked-view": "^0.3.1",
|
85
86
|
"@react-navigation/bottom-tabs": "~6.5.8",
|
86
87
|
"@react-navigation/core": "6.4.17",
|
87
88
|
"@react-navigation/drawer": "~6.6.3",
|
@@ -90,15 +91,14 @@
|
|
90
91
|
"@react-navigation/native-stack": "~6.9.13",
|
91
92
|
"@react-navigation/routers": "~6.1.9",
|
92
93
|
"@ungap/structured-clone": "^1.2.0",
|
93
|
-
"@vxrn/resolve": "1.1.
|
94
|
-
"@vxrn/tslib-lite": "1.1.
|
95
|
-
"@vxrn/universal-color-scheme": "1.1.
|
96
|
-
"@vxrn/use-isomorphic-layout-effect": "1.1.
|
94
|
+
"@vxrn/resolve": "1.1.312",
|
95
|
+
"@vxrn/tslib-lite": "1.1.312",
|
96
|
+
"@vxrn/universal-color-scheme": "1.1.312",
|
97
|
+
"@vxrn/use-isomorphic-layout-effect": "1.1.312",
|
97
98
|
"babel-dead-code-elimination": "^1.0.6",
|
98
99
|
"citty": "^0.1.6",
|
99
100
|
"core-js": "^3.38.1",
|
100
|
-
"create-vxrn": "1.1.
|
101
|
-
"dotenv": "^16.4.5",
|
101
|
+
"create-vxrn": "1.1.312",
|
102
102
|
"escape-string-regexp": "^5.0.0",
|
103
103
|
"expo-linking": "~6.3.1",
|
104
104
|
"expo-modules-core": "^1.12.24",
|
@@ -120,7 +120,7 @@
|
|
120
120
|
"url-parse": "^1.5.10",
|
121
121
|
"vite": "6.0.0-beta.1",
|
122
122
|
"vite-tsconfig-paths": "^5.0.1",
|
123
|
-
"vxrn": "1.1.
|
123
|
+
"vxrn": "1.1.312",
|
124
124
|
"ws": "^8.18.0",
|
125
125
|
"xxhashjs": "^0.2.2"
|
126
126
|
},
|
package/src/cleanUrl.ts
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
-
import {
|
1
|
+
import {
|
2
|
+
isNative,
|
3
|
+
LOADER_JS_POSTFIX,
|
4
|
+
LOADER_JS_POSTFIX_UNCACHED,
|
5
|
+
PRELOAD_JS_POSTFIX,
|
6
|
+
} from './constants'
|
2
7
|
import { getURL } from './getURL'
|
3
|
-
import { CACHE_KEY } from './router/constants'
|
4
8
|
import { removeSearch } from './utils/removeSearch'
|
5
9
|
|
6
10
|
function cleanUrl(path: string) {
|
@@ -13,11 +17,10 @@ function cleanUrl(path: string) {
|
|
13
17
|
}
|
14
18
|
|
15
19
|
const isClient = typeof window !== 'undefined'
|
16
|
-
const clientSideSearch = isClient ? `?cache=${CACHE_KEY}` : ''
|
17
20
|
const clientSideURL = isClient ? getURL() : ''
|
18
21
|
|
19
22
|
export function getPreloadPath(currentPath: string) {
|
20
|
-
return `${clientSideURL}/assets/${cleanUrl(currentPath.slice(1))}
|
23
|
+
return `${clientSideURL}/assets/${cleanUrl(currentPath.slice(1))}${PRELOAD_JS_POSTFIX}`
|
21
24
|
}
|
22
25
|
|
23
26
|
export function getLoaderPath(
|
@@ -33,20 +36,13 @@ export function getLoaderPath(
|
|
33
36
|
'http://example.com' /* not important, just for `new URL()` to work */
|
34
37
|
)
|
35
38
|
|
36
|
-
return `${baseURL}${devPath}/assets/${cleanUrl(currentPathUrl.pathname.slice(1))}
|
39
|
+
return `${baseURL}${devPath}/assets/${cleanUrl(currentPathUrl.pathname.slice(1))}${LOADER_JS_POSTFIX}`
|
37
40
|
}
|
38
41
|
|
39
42
|
export function getPathFromLoaderPath(loaderPath: string) {
|
40
43
|
return loaderPath
|
41
|
-
.replace(
|
44
|
+
.replace(LOADER_JS_POSTFIX_UNCACHED, '')
|
45
|
+
.replace(/_\d+/, '')
|
42
46
|
.replace(/^(\/_one)?\/assets/, '')
|
43
47
|
.replaceAll(/_/g, '/')
|
44
48
|
}
|
45
|
-
|
46
|
-
function getSearchParams(searchParams) {
|
47
|
-
if (!searchParams) {
|
48
|
-
return clientSideSearch
|
49
|
-
}
|
50
|
-
|
51
|
-
return `${searchParams}&${clientSideSearch.slice(1) /* remove the leading "?" */}`
|
52
|
-
}
|
package/src/cli.ts
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import { defineCommand, runMain } from 'citty'
|
2
2
|
import colors from 'picocolors'
|
3
|
-
import { loadEnv } from './vite/loadEnv'
|
4
3
|
import { readFileSync } from 'node:fs'
|
5
4
|
import path from 'node:path'
|
6
5
|
import { fileURLToPath } from 'node:url'
|
@@ -21,8 +20,6 @@ function getPackageVersion() {
|
|
21
20
|
|
22
21
|
const version = getPackageVersion()
|
23
22
|
|
24
|
-
void loadEnv(process.cwd())
|
25
|
-
|
26
23
|
if (path.sep !== '/') {
|
27
24
|
console.warn(
|
28
25
|
colors.bgYellow('WARNING: UNSUPPORTED OS') +
|
package/src/config.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { isWebServer } from './constants'
|
2
2
|
import type { One } from './vite/types'
|
3
3
|
|
4
|
-
const CLIENT_RENDER_MODE = process.env.
|
4
|
+
const CLIENT_RENDER_MODE = process.env.ONE_DEFAULT_RENDER_MODE as One.RouteRenderMode | undefined
|
5
5
|
|
6
6
|
// works client or server
|
7
7
|
export const getDefaultRenderMode = () => {
|
package/src/constants.ts
CHANGED
@@ -1,3 +1,9 @@
|
|
1
1
|
export const isWebClient = process.env.TAMAGUI_TARGET !== 'native' && typeof window !== 'undefined'
|
2
2
|
export const isWebServer = process.env.TAMAGUI_TARGET !== 'native' && typeof window === 'undefined'
|
3
3
|
export const isNative = process.env.TAMAGUI_TARGET === 'native'
|
4
|
+
|
5
|
+
export const CACHE_KEY = `${process.env.ONE_CACHE_KEY ?? Math.round(Math.random() * 100_000_000)}`
|
6
|
+
|
7
|
+
export const LOADER_JS_POSTFIX_UNCACHED = `_vxrn_loader.js`
|
8
|
+
export const LOADER_JS_POSTFIX = `_${CACHE_KEY}${LOADER_JS_POSTFIX_UNCACHED}`
|
9
|
+
export const PRELOAD_JS_POSTFIX = `_${CACHE_KEY}_preload.js`
|
package/src/createApp.native.tsx
CHANGED
@@ -15,7 +15,7 @@ export function createApp(options: CreateAppProps): void {
|
|
15
15
|
// TODO remove once we get a nice setup in tamagui repo for building native app and loading it
|
16
16
|
AppRegistry.registerComponent('tamaguikitchensink', () => App)
|
17
17
|
|
18
|
-
if (process.env.
|
19
|
-
AppRegistry.registerComponent(process.env.
|
18
|
+
if (process.env.ONE_APP_NAME) {
|
19
|
+
AppRegistry.registerComponent(process.env.ONE_APP_NAME, () => App)
|
20
20
|
}
|
21
21
|
}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { getPathFromLoaderPath } from './cleanUrl'
|
2
|
+
import { LOADER_JS_POSTFIX, LOADER_JS_POSTFIX_UNCACHED } from './constants'
|
2
3
|
import type { RouteInfo } from './server/createRoutesManifest'
|
3
4
|
import { isResponse } from './utils/isResponse'
|
4
5
|
import { promiseWithResolvers } from './utils/promiseWithResolvers'
|
@@ -99,7 +100,7 @@ export function createHandleRequest(
|
|
99
100
|
}
|
100
101
|
|
101
102
|
if (handlers.handleLoader) {
|
102
|
-
const isClientRequestingNewRoute = pathname.endsWith(
|
103
|
+
const isClientRequestingNewRoute = pathname.endsWith(LOADER_JS_POSTFIX_UNCACHED)
|
103
104
|
|
104
105
|
if (isClientRequestingNewRoute) {
|
105
106
|
const originalUrl = getPathFromLoaderPath(pathname)
|
package/src/matchers.ts
CHANGED
@@ -22,7 +22,7 @@ export function matchGroupName(name: string): string | undefined {
|
|
22
22
|
|
23
23
|
/** Match the first array group name `(a,b,c)/(d,c)` -> `'a,b,c'` */
|
24
24
|
export function matchArrayGroupName(name: string) {
|
25
|
-
return name.match(/(?:[^\\(\\)])*?\(([
|
25
|
+
return name.match(/(?:[^\\(\\)])*?\(?([^\\/\(\)]+,[^\\/\(\)]+)\)?.*?$/)?.[1]
|
26
26
|
}
|
27
27
|
|
28
28
|
export function getNameFromFilePath(name: string): string {
|
package/src/serve.ts
CHANGED
@@ -4,16 +4,16 @@ import FSExtra from 'fs-extra'
|
|
4
4
|
import type { Hono } from 'hono'
|
5
5
|
import Path, { join } from 'node:path'
|
6
6
|
import type { VXRNOptions } from 'vxrn'
|
7
|
-
import { getServerEntry, serve as vxrnServe } from 'vxrn'
|
7
|
+
import { getServerEntry, loadEnv, serve as vxrnServe } from 'vxrn'
|
8
|
+
import { labelProcess } from './cli/label-process'
|
8
9
|
import { createHandleRequest } from './createHandleRequest'
|
9
10
|
import type { RenderAppProps } from './types'
|
10
11
|
import { isResponse } from './utils/isResponse'
|
11
12
|
import { isStatusRedirect } from './utils/isStatus'
|
12
13
|
import { removeUndefined } from './utils/removeUndefined'
|
14
|
+
import { loadUserOneOptions } from './vite/one'
|
13
15
|
import { resolveAPIRequest } from './vite/resolveAPIRequest'
|
14
16
|
import type { One } from './vite/types'
|
15
|
-
import { loadUserOneOptions } from './vite/one'
|
16
|
-
import { labelProcess } from './cli/label-process'
|
17
17
|
|
18
18
|
process.on('uncaughtException', (err) => {
|
19
19
|
console.error(`[one] Uncaught exception`, err?.stack || err)
|
@@ -21,6 +21,8 @@ process.on('uncaughtException', (err) => {
|
|
21
21
|
|
22
22
|
export async function serve(args: VXRNOptions['server'] = {}) {
|
23
23
|
labelProcess('serve')
|
24
|
+
loadEnv('production')
|
25
|
+
|
24
26
|
const oneOptions = await loadUserOneOptions('serve')
|
25
27
|
|
26
28
|
// TODO make this better, this ensures we get react 19
|
package/src/useLoader.ts
CHANGED
@@ -91,7 +91,7 @@ export function useLoader<
|
|
91
91
|
try {
|
92
92
|
const response = await (async () => {
|
93
93
|
if (isNative) {
|
94
|
-
const nativeLoaderJSUrl = `${loaderJSUrl}
|
94
|
+
const nativeLoaderJSUrl = `${loaderJSUrl}?platform=ios` /* TODO: platform */
|
95
95
|
|
96
96
|
try {
|
97
97
|
// On native, we need to fetch the loader code and eval it
|
package/src/vite/build.ts
CHANGED
@@ -13,13 +13,13 @@ import {
|
|
13
13
|
type ClientManifestEntry,
|
14
14
|
} from 'vxrn'
|
15
15
|
import { getLoaderPath, getPreloadPath } from '../cleanUrl'
|
16
|
+
import { labelProcess } from '../cli/label-process'
|
16
17
|
import type { RouteInfo } from '../server/createRoutesManifest'
|
17
18
|
import type { LoaderProps, RenderApp } from '../types'
|
18
19
|
import { getManifest } from './getManifest'
|
19
20
|
import { loadUserOneOptions } from './one'
|
20
21
|
import { replaceLoader } from './replaceLoader'
|
21
22
|
import type { One } from './types'
|
22
|
-
import { labelProcess } from '../cli/label-process'
|
23
23
|
|
24
24
|
const { ensureDir, readFile, outputFile } = FSExtra
|
25
25
|
|
@@ -32,6 +32,7 @@ export async function build(args: {
|
|
32
32
|
only?: string
|
33
33
|
}) {
|
34
34
|
labelProcess('build')
|
35
|
+
|
35
36
|
const userOptions = await loadUserOneOptions('build')
|
36
37
|
const serverOutputFormat = userOptions.build?.server?.outputFormat ?? 'esm'
|
37
38
|
|
package/src/vite/one.ts
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
+
import { resolvePath } from '@vxrn/resolve'
|
1
2
|
import events from 'node:events'
|
2
3
|
import path, { dirname, resolve } from 'node:path'
|
3
4
|
import { type Plugin, type PluginOption, type UserConfig, loadConfigFromFile } from 'vite'
|
4
5
|
import tsconfigPaths from 'vite-tsconfig-paths'
|
5
|
-
import { getOptimizeDeps, getOptionsFilled, isWebEnvironment } from 'vxrn'
|
6
|
+
import { getOptimizeDeps, getOptionsFilled, isWebEnvironment, loadEnv } from 'vxrn'
|
7
|
+
import { CACHE_KEY } from '../constants'
|
6
8
|
import '../polyfills-server'
|
7
9
|
import { existsAsync } from '../utils/existsAsync'
|
8
|
-
import { resolvePath } from '@vxrn/resolve'
|
9
10
|
import { clientTreeShakePlugin } from './clientTreeShakePlugin'
|
10
11
|
import { createFileSystemRouter } from './createFileSystemRouter'
|
11
12
|
import { ensureTSConfig } from './ensureTsConfig'
|
12
13
|
import { fixDependenciesPlugin } from './fixDependenciesPlugin'
|
13
14
|
import { generateTypesForRoutes } from './generateTypesForRoutes'
|
14
|
-
import { loadEnv } from './loadEnv'
|
15
15
|
import type { One } from './types'
|
16
16
|
import { createVirtualEntry, virtualEntryId } from './virtualEntryPlugin'
|
17
17
|
import { vitePluginSsrCss } from './vitePluginSsrCss'
|
@@ -24,8 +24,6 @@ globalThis.__vxrnEnableNativeEnv = true
|
|
24
24
|
export function one(options: One.PluginOptions = {}): PluginOption {
|
25
25
|
oneOptions = options
|
26
26
|
|
27
|
-
void loadEnv(process.cwd())
|
28
|
-
|
29
27
|
// ensure tsconfig
|
30
28
|
if (options.config?.ensureTSConfig !== false) {
|
31
29
|
void ensureTSConfig()
|
@@ -46,7 +44,18 @@ export function one(options: One.PluginOptions = {}): PluginOption {
|
|
46
44
|
|
47
45
|
const vxrnOptions = getOptionsFilled()
|
48
46
|
|
47
|
+
const { clientEnvDefine } = loadEnv(vxrnOptions?.mode ?? 'development')
|
48
|
+
|
49
49
|
const devAndProdPlugins = [
|
50
|
+
{
|
51
|
+
name: 'one-define-env',
|
52
|
+
config() {
|
53
|
+
return {
|
54
|
+
define: clientEnvDefine,
|
55
|
+
}
|
56
|
+
},
|
57
|
+
},
|
58
|
+
|
50
59
|
// proxy because you cant add a plugin inside a plugin
|
51
60
|
new Proxy(
|
52
61
|
{
|
@@ -126,16 +135,20 @@ export function one(options: One.PluginOptions = {}): PluginOption {
|
|
126
135
|
return {
|
127
136
|
define: {
|
128
137
|
...(options.web?.defaultRenderMode && {
|
129
|
-
'process.env.
|
138
|
+
'process.env.ONE_DEFAULT_RENDER_MODE': JSON.stringify(options.web.defaultRenderMode),
|
139
|
+
'import.meta.env.ONE_DEFAULT_RENDER_MODE': JSON.stringify(
|
140
|
+
options.web.defaultRenderMode
|
141
|
+
),
|
130
142
|
}),
|
131
143
|
|
132
144
|
...(options.setupFile && {
|
133
|
-
'process.env.
|
145
|
+
'process.env.ONE_SETUP_FILE': JSON.stringify(options.setupFile),
|
134
146
|
}),
|
135
147
|
|
136
148
|
...(process.env.NODE_ENV !== 'production' &&
|
137
149
|
vxrnOptions && {
|
138
150
|
'process.env.ONE_SERVER_URL': JSON.stringify(vxrnOptions.server.url),
|
151
|
+
'import.meta.env.ONE_SERVER_URL': JSON.stringify(vxrnOptions.server.url),
|
139
152
|
}),
|
140
153
|
},
|
141
154
|
|
@@ -143,12 +156,28 @@ export function one(options: One.PluginOptions = {}): PluginOption {
|
|
143
156
|
client: {
|
144
157
|
define: {
|
145
158
|
'process.env.VITE_ENVIRONMENT': '"client"',
|
159
|
+
'import.meta.env.VITE_ENVIRONMENT': '"client"',
|
146
160
|
},
|
147
161
|
},
|
148
162
|
|
149
163
|
ssr: {
|
150
164
|
define: {
|
151
165
|
'process.env.VITE_ENVIRONMENT': '"ssr"',
|
166
|
+
'import.meta.env.VITE_ENVIRONMENT': '"ssr"',
|
167
|
+
},
|
168
|
+
},
|
169
|
+
|
170
|
+
ios: {
|
171
|
+
define: {
|
172
|
+
'process.env.VITE_ENVIRONMENT': '"ios"',
|
173
|
+
'import.meta.env.VITE_ENVIRONMENT': '"ios"',
|
174
|
+
},
|
175
|
+
},
|
176
|
+
|
177
|
+
android: {
|
178
|
+
define: {
|
179
|
+
'process.env.VITE_ENVIRONMENT': '"android"',
|
180
|
+
'import.meta.env.VITE_ENVIRONMENT': '"android"',
|
152
181
|
},
|
153
182
|
},
|
154
183
|
},
|
@@ -232,7 +261,7 @@ export function one(options: One.PluginOptions = {}): PluginOption {
|
|
232
261
|
}),
|
233
262
|
|
234
263
|
{
|
235
|
-
name: 'define-
|
264
|
+
name: 'one-define-environment',
|
236
265
|
config() {
|
237
266
|
if (!options.app?.key) {
|
238
267
|
return
|
@@ -240,14 +269,18 @@ export function one(options: One.PluginOptions = {}): PluginOption {
|
|
240
269
|
|
241
270
|
return {
|
242
271
|
define: {
|
243
|
-
'process.env.
|
272
|
+
'process.env.ONE_APP_NAME': JSON.stringify(options.app.key),
|
273
|
+
'import.meta.env.ONE_APP_NAME': JSON.stringify(options.app.key),
|
274
|
+
|
275
|
+
'process.env.ONE_CACHE_KEY': JSON.stringify(CACHE_KEY),
|
276
|
+
'import.meta.env.ONE_CACHE_KEY': JSON.stringify(CACHE_KEY),
|
244
277
|
},
|
245
278
|
}
|
246
279
|
},
|
247
280
|
} satisfies Plugin,
|
248
281
|
|
249
282
|
{
|
250
|
-
name: 'use-react-18-for-native',
|
283
|
+
name: 'one-use-react-18-for-native',
|
251
284
|
enforce: 'pre',
|
252
285
|
|
253
286
|
async config() {
|
@@ -275,7 +308,7 @@ export function one(options: One.PluginOptions = {}): PluginOption {
|
|
275
308
|
} satisfies Plugin,
|
276
309
|
|
277
310
|
{
|
278
|
-
name: 'optimize-deps-load-web-extensions',
|
311
|
+
name: 'one-optimize-deps-load-web-extensions',
|
279
312
|
enforce: 'pre',
|
280
313
|
|
281
314
|
applyToEnvironment(environment) {
|
@@ -10,9 +10,9 @@ const virtualEntryIdNativeName = `${virtualEntryIdName}-native`
|
|
10
10
|
export const virtualEntryIdNative = `virtual:${virtualEntryIdNativeName}`
|
11
11
|
const resolvedVirtualEntryIdNative = '\0' + virtualEntryIdNativeName
|
12
12
|
|
13
|
-
const
|
14
|
-
if (process.env.
|
15
|
-
import(/* @vite-ignore */ process.env.
|
13
|
+
const USE_ONE_SETUP_FILE = `
|
14
|
+
if (process.env.ONE_SETUP_FILE) {
|
15
|
+
import(/* @vite-ignore */ process.env.ONE_SETUP_FILE)
|
16
16
|
}
|
17
17
|
`
|
18
18
|
|
@@ -36,7 +36,7 @@ export function createVirtualEntry(options: { root: string }): Plugin {
|
|
36
36
|
if (id === resolvedVirtualEntryId) {
|
37
37
|
const prependCode = isNativeEnvironment(this.environment)
|
38
38
|
? '' /* `import()` will not work on native */
|
39
|
-
:
|
39
|
+
: USE_ONE_SETUP_FILE
|
40
40
|
return `
|
41
41
|
${prependCode}
|
42
42
|
|
@@ -52,7 +52,7 @@ export default createApp({
|
|
52
52
|
if (id === resolvedVirtualEntryIdNative) {
|
53
53
|
const prependCode = isNativeEnvironment(this.environment)
|
54
54
|
? '' /* `import()` will not work on native */
|
55
|
-
:
|
55
|
+
: USE_ONE_SETUP_FILE
|
56
56
|
return `
|
57
57
|
${prependCode}
|
58
58
|
|
@@ -12,7 +12,7 @@ export function vitePluginSsrCss(pluginOpts: { entries: string[] }): Plugin {
|
|
12
12
|
const virtualHref = '/@id/__x00__' + VIRTUAL_ENTRY
|
13
13
|
|
14
14
|
return {
|
15
|
-
name: `
|
15
|
+
name: `one-plugin-ssr-css`,
|
16
16
|
apply: 'serve',
|
17
17
|
configureServer(server_) {
|
18
18
|
server = server_
|
package/types/cleanUrl.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cleanUrl.d.ts","sourceRoot":"","sources":["../src/cleanUrl.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"cleanUrl.d.ts","sourceRoot":"","sources":["../src/cleanUrl.ts"],"names":[],"mappings":"AAqBA,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,UAEjD;AAED,wBAAgB,aAAa,CAC3B,WAAW,EAAE,MAAM,EAEnB,UAAU,UAAW,UAWtB;AAED,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,UAMvD"}
|
package/types/constants.d.ts
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
export declare const isWebClient: boolean;
|
2
2
|
export declare const isWebServer: boolean;
|
3
3
|
export declare const isNative: boolean;
|
4
|
+
export declare const CACHE_KEY: string;
|
5
|
+
export declare const LOADER_JS_POSTFIX_UNCACHED = "_vxrn_loader.js";
|
6
|
+
export declare const LOADER_JS_POSTFIX: string;
|
7
|
+
export declare const PRELOAD_JS_POSTFIX: string;
|
4
8
|
//# sourceMappingURL=constants.d.ts.map
|
package/types/constants.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,SAA2E,CAAA;AACnG,eAAO,MAAM,WAAW,SAA2E,CAAA;AACnG,eAAO,MAAM,QAAQ,SAA0C,CAAA"}
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,SAA2E,CAAA;AACnG,eAAO,MAAM,WAAW,SAA2E,CAAA;AACnG,eAAO,MAAM,QAAQ,SAA0C,CAAA;AAE/D,eAAO,MAAM,SAAS,QAA4E,CAAA;AAElG,eAAO,MAAM,0BAA0B,oBAAoB,CAAA;AAC3D,eAAO,MAAM,iBAAiB,QAA+C,CAAA;AAC7E,eAAO,MAAM,kBAAkB,QAA6B,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"createHandleRequest.d.ts","sourceRoot":"","sources":["../src/createHandleRequest.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"createHandleRequest.d.ts","sourceRoot":"","sources":["../src/createHandleRequest.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAI9D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAEvC,KAAK,mBAAmB,CAAC,eAAe,SAAS,MAAM,GAAG,EAAE,IAAI;IAC9D,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,eAAe,CAAA;IAC1C,GAAG,EAAE,GAAG,CAAA;IACR,WAAW,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,CAAA;CAC5D,CAAA;AAED,KAAK,sBAAsB,GAAG,IAAI,GAAG,MAAM,GAAG,QAAQ,CAAA;AAEtD,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,GAAG,CAAC,aAAa,EAC1B,QAAQ,EAAE;IACR,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IACxD,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IAC3D,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;CACzD;;uBA4BgD,OAAO,KAAG,OAAO,CAAC,sBAAsB,CAAC;EAsJ3F"}
|
package/types/serve.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../src/serve.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAA;AAK3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,MAAM,CAAA;AAgBvC,wBAAsB,KAAK,CAAC,IAAI,GAAE,WAAW,CAAC,QAAQ,CAAM;mDAfJ,
|
1
|
+
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../src/serve.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAA;AAK3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,MAAM,CAAA;AAgBvC,wBAAsB,KAAK,CAAC,IAAI,GAAE,WAAW,CAAC,QAAQ,CAAM;mDAfJ,YACvD;+CAC+C,YAChD;gDAEK,YAAY;iDAEV,YAAY;+CAEX,YAAY;mDAGkB,YAAY;GA+BjD"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/vite/build.ts"],"names":[],"mappings":"AA6BA,wBAAsB,KAAK,CAAC,IAAI,EAAE;IAChC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/vite/build.ts"],"names":[],"mappings":"AA6BA,wBAAsB,KAAK,CAAC,IAAI,EAAE;IAChC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,iBAugBA"}
|
package/types/vite/one.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"one.d.ts","sourceRoot":"","sources":["../../src/vite/one.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"one.d.ts","sourceRoot":"","sources":["../../src/vite/one.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,KAAK,YAAY,EAAuC,MAAM,MAAM,CAAA;AAI1F,OAAO,qBAAqB,CAAA;AAO5B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AASlC,wBAAgB,GAAG,CAAC,OAAO,GAAE,GAAG,CAAC,aAAkB,GAAG,YAAY,CAgUjE;AAeD,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,8BAalE"}
|
@@ -1,26 +0,0 @@
|
|
1
|
-
var __defProp = Object.defineProperty;
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
-
var __export = (target, all) => {
|
6
|
-
for (var name in all) __defProp(target, name, {
|
7
|
-
get: all[name],
|
8
|
-
enumerable: !0
|
9
|
-
});
|
10
|
-
},
|
11
|
-
__copyProps = (to, from, except, desc) => {
|
12
|
-
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
13
|
-
get: () => from[key],
|
14
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
15
|
-
});
|
16
|
-
return to;
|
17
|
-
};
|
18
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
19
|
-
value: !0
|
20
|
-
}), mod);
|
21
|
-
var constants_exports = {};
|
22
|
-
__export(constants_exports, {
|
23
|
-
CACHE_KEY: () => CACHE_KEY
|
24
|
-
});
|
25
|
-
module.exports = __toCommonJS(constants_exports);
|
26
|
-
const CACHE_KEY = `${Math.random()}`.slice(3);
|
@@ -1,26 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
-
var __export = (target, all) => {
|
7
|
-
for (var name in all)
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
9
|
-
}, __copyProps = (to, from, except, desc) => {
|
10
|
-
if (from && typeof from == "object" || typeof from == "function")
|
11
|
-
for (let key of __getOwnPropNames(from))
|
12
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
13
|
-
return to;
|
14
|
-
};
|
15
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
16
|
-
var constants_exports = {};
|
17
|
-
__export(constants_exports, {
|
18
|
-
CACHE_KEY: () => CACHE_KEY
|
19
|
-
});
|
20
|
-
module.exports = __toCommonJS(constants_exports);
|
21
|
-
var CACHE_KEY = `${Math.random()}`.slice(3);
|
22
|
-
// Annotate the CommonJS export names for ESM import in node:
|
23
|
-
0 && (module.exports = {
|
24
|
-
CACHE_KEY
|
25
|
-
});
|
26
|
-
//# sourceMappingURL=constants.js.map
|
@@ -1,47 +0,0 @@
|
|
1
|
-
var __create = Object.create;
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __getProtoOf = Object.getPrototypeOf,
|
6
|
-
__hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
-
var __export = (target, all) => {
|
8
|
-
for (var name in all) __defProp(target, name, {
|
9
|
-
get: all[name],
|
10
|
-
enumerable: !0
|
11
|
-
});
|
12
|
-
},
|
13
|
-
__copyProps = (to, from, except, desc) => {
|
14
|
-
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
15
|
-
get: () => from[key],
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
17
|
-
});
|
18
|
-
return to;
|
19
|
-
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
26
|
-
value: mod,
|
27
|
-
enumerable: !0
|
28
|
-
}) : target, mod)),
|
29
|
-
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
30
|
-
value: !0
|
31
|
-
}), mod);
|
32
|
-
var loadEnv_exports = {};
|
33
|
-
__export(loadEnv_exports, {
|
34
|
-
loadEnv: () => loadEnv
|
35
|
-
});
|
36
|
-
module.exports = __toCommonJS(loadEnv_exports);
|
37
|
-
var import_node_fs = __toESM(require("node:fs"), 1),
|
38
|
-
import_node_path = __toESM(require("node:path"), 1);
|
39
|
-
async function loadEnv(root) {
|
40
|
-
const envPath = import_node_path.default.join(root, ".env");
|
41
|
-
if (!import_node_fs.default.existsSync(envPath)) return;
|
42
|
-
const result = (await import("dotenv")).config({
|
43
|
-
path: envPath
|
44
|
-
});
|
45
|
-
if (result.error) throw result.error;
|
46
|
-
return !0;
|
47
|
-
}
|
@@ -1,6 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"version": 3,
|
3
|
-
"sources": ["../../../src/vite/loadEnv.ts"],
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAe,gCACf,mBAAiB;AAEjB,eAAsB,QAAQ,MAAc;AAC1C,QAAM,UAAU,iBAAAA,QAAK,KAAK,MAAM,MAAM;AACtC,MAAI,CAAC,eAAAC,QAAG,WAAW,OAAO,EAAG;AAE7B,QAAM,UADS,MAAM,OAAO,QAAQ,GACd,OAAO,EAAE,MAAM,QAAQ,CAAC;AAC9C,MAAI,OAAO,MAAO,OAAM,OAAO;AAC/B,SAAO;AACT;",
|
5
|
-
"names": ["path", "fs"]
|
6
|
-
}
|