one 1.1.384 → 1.1.386
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Root.cjs +2 -67
- package/dist/cjs/Root.js +3 -70
- package/dist/cjs/Root.js.map +1 -1
- package/dist/cjs/Root.native.js +3 -79
- package/dist/cjs/Root.native.js.map +2 -2
- package/dist/cjs/cli/build.cjs +65 -63
- package/dist/cjs/cli/build.js +67 -62
- package/dist/cjs/cli/build.js.map +2 -2
- package/dist/cjs/cli/build.native.js +4 -3
- package/dist/cjs/cli/build.native.js.map +2 -2
- package/dist/cjs/createApp.cjs +107 -8
- package/dist/cjs/createApp.js +91 -5
- package/dist/cjs/createApp.js.map +2 -2
- package/dist/cjs/createApp.native.js +1 -0
- package/dist/cjs/createApp.native.js.map +2 -2
- package/dist/cjs/fork/NavigationContainer.js.map +1 -1
- package/dist/cjs/fork/NavigationContainer.native.js.map +2 -2
- package/dist/cjs/getRoutes.js.map +1 -1
- package/dist/cjs/getRoutes.native.js.map +1 -1
- package/dist/cjs/server/oneServe.cjs +1 -0
- package/dist/cjs/server/oneServe.js +1 -0
- package/dist/cjs/server/oneServe.js.map +1 -1
- package/dist/cjs/server/oneServe.native.js +1 -0
- package/dist/cjs/server/oneServe.native.js.map +2 -2
- package/dist/cjs/setup.cjs +28 -3
- package/dist/cjs/setup.js +23 -2
- package/dist/cjs/setup.js.map +1 -1
- package/dist/cjs/vite/one.cjs +11 -9
- package/dist/cjs/vite/one.js +11 -12
- package/dist/cjs/vite/one.js.map +1 -1
- package/dist/cjs/vite/one.native.js +11 -9
- package/dist/cjs/vite/one.native.js.map +2 -2
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.cjs +1 -0
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.js +1 -0
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.js.map +1 -1
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js +1 -0
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js.map +2 -2
- package/dist/esm/Root.js +3 -71
- package/dist/esm/Root.js.map +2 -2
- package/dist/esm/Root.mjs +3 -68
- package/dist/esm/Root.mjs.map +1 -1
- package/dist/esm/Root.native.js +3 -80
- package/dist/esm/Root.native.js.map +2 -2
- package/dist/esm/cli/build.js +67 -62
- package/dist/esm/cli/build.js.map +1 -1
- package/dist/esm/cli/build.mjs +65 -63
- package/dist/esm/cli/build.mjs.map +1 -1
- package/dist/esm/cli/build.native.js +4 -3
- package/dist/esm/cli/build.native.js.map +2 -2
- package/dist/esm/createApp.js +84 -3
- package/dist/esm/createApp.js.map +1 -1
- package/dist/esm/createApp.mjs +93 -5
- package/dist/esm/createApp.mjs.map +1 -1
- package/dist/esm/createApp.native.js +1 -0
- package/dist/esm/createApp.native.js.map +2 -2
- package/dist/esm/fork/NavigationContainer.js.map +1 -1
- package/dist/esm/fork/NavigationContainer.mjs.map +1 -1
- package/dist/esm/fork/NavigationContainer.native.js.map +2 -2
- package/dist/esm/getRoutes.js.map +1 -1
- package/dist/esm/getRoutes.mjs.map +1 -1
- package/dist/esm/getRoutes.native.js.map +1 -1
- package/dist/esm/server/oneServe.js +1 -0
- package/dist/esm/server/oneServe.js.map +1 -1
- package/dist/esm/server/oneServe.mjs +1 -0
- package/dist/esm/server/oneServe.mjs.map +1 -1
- package/dist/esm/server/oneServe.native.js +1 -0
- package/dist/esm/server/oneServe.native.js.map +2 -2
- package/dist/esm/setup.js +3 -2
- package/dist/esm/setup.js.map +1 -1
- package/dist/esm/setup.mjs +5 -2
- package/dist/esm/setup.mjs.map +1 -1
- package/dist/esm/vite/one.js +11 -12
- package/dist/esm/vite/one.js.map +1 -1
- package/dist/esm/vite/one.mjs +11 -9
- package/dist/esm/vite/one.mjs.map +1 -1
- package/dist/esm/vite/one.native.js +11 -9
- package/dist/esm/vite/one.native.js.map +2 -2
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.js +1 -0
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.js.map +1 -1
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.mjs +1 -0
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.mjs.map +1 -1
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.native.js +1 -0
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.native.js.map +2 -2
- package/package.json +8 -8
- package/src/Root.tsx +1 -76
- package/src/cli/build.ts +83 -76
- package/src/createApp.native.tsx +1 -1
- package/src/createApp.tsx +108 -12
- package/src/fork/NavigationContainer.tsx +0 -6
- package/src/getRoutes.ts +0 -1
- package/src/server/oneServe.ts +1 -0
- package/src/setup.ts +3 -4
- package/src/types.ts +3 -0
- package/src/vite/one.ts +13 -10
- package/src/vite/plugins/fileSystemRouterPlugin.tsx +1 -0
- package/types/Root.d.ts +0 -1
- package/types/Root.d.ts.map +1 -1
- package/types/cli/build.d.ts.map +1 -1
- package/types/createApp.d.ts.map +1 -1
- package/types/fork/NavigationContainer.d.ts.map +1 -1
- package/types/server/oneServe.d.ts.map +1 -1
- package/types/setup.d.ts.map +1 -1
- package/types/types.d.ts +2 -0
- package/types/types.d.ts.map +1 -1
- package/types/vite/one.d.ts.map +1 -1
- package/types/vite/plugins/fileSystemRouterPlugin.d.ts.map +1 -1
package/src/cli/build.ts
CHANGED
@@ -93,85 +93,85 @@ export async function build(args: {
|
|
93
93
|
const outputFormat = oneOptions?.build?.api?.outputFormat ?? serverOutputFormat
|
94
94
|
const treeshake = oneOptions?.build?.api?.treeshake
|
95
95
|
|
96
|
-
const
|
97
|
-
|
98
|
-
|
99
|
-
configFile: false,
|
100
|
-
|
101
|
-
plugins: [
|
102
|
-
nodeExternals({
|
103
|
-
exclude: optimizeDeps.include,
|
104
|
-
}) as any,
|
105
|
-
],
|
106
|
-
|
107
|
-
define: {
|
108
|
-
...processEnvDefines,
|
109
|
-
},
|
96
|
+
const mergedConfig = mergeConfig(apiBuildConfig, {
|
97
|
+
appType: 'custom',
|
98
|
+
configFile: false,
|
110
99
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
100
|
+
plugins: [
|
101
|
+
nodeExternals({
|
102
|
+
exclude: optimizeDeps.include,
|
103
|
+
}) as any,
|
104
|
+
],
|
105
|
+
|
106
|
+
define: {
|
107
|
+
...processEnvDefines,
|
108
|
+
},
|
109
|
+
|
110
|
+
ssr: {
|
111
|
+
noExternal: true,
|
112
|
+
// we patched them to switch to react 19
|
113
|
+
external: ['react', 'react-dom'],
|
114
|
+
optimizeDeps,
|
115
|
+
},
|
117
116
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
},
|
117
|
+
build: {
|
118
|
+
ssr: true,
|
119
|
+
emptyOutDir: false,
|
120
|
+
outDir: `dist/${subFolder}`,
|
121
|
+
copyPublicDir: false,
|
122
|
+
minify: false,
|
123
|
+
rollupOptions: {
|
124
|
+
treeshake: treeshake ?? {
|
125
|
+
moduleSideEffects: false,
|
126
|
+
},
|
127
|
+
|
128
|
+
plugins: [
|
129
|
+
// otherwise rollup is leaving commonjs-only top level imports...
|
130
|
+
outputFormat === 'esm' ? rollupRemoveUnusedImportsPlugin : null,
|
131
|
+
].filter(Boolean),
|
132
|
+
|
133
|
+
// too many issues
|
134
|
+
// treeshake: {
|
135
|
+
// moduleSideEffects: false,
|
136
|
+
// },
|
137
|
+
// prevents it from shaking out the exports
|
138
|
+
preserveEntrySignatures: 'strict',
|
139
|
+
input: input,
|
140
|
+
external: externalRegex,
|
141
|
+
output: {
|
142
|
+
entryFileNames: '[name]',
|
143
|
+
exports: 'auto',
|
144
|
+
...(outputFormat === 'esm'
|
145
|
+
? {
|
146
|
+
format: 'esm',
|
147
|
+
esModule: true,
|
148
|
+
}
|
149
|
+
: {
|
150
|
+
format: 'cjs',
|
151
|
+
// Preserve folder structure and use .cjs extension
|
152
|
+
entryFileNames: (chunkInfo) => {
|
153
|
+
const name = chunkInfo.name.replace(/\.js$/, '.cjs')
|
154
|
+
return name
|
155
|
+
},
|
156
|
+
chunkFileNames: (chunkInfo) => {
|
157
|
+
const dir = Path.dirname(chunkInfo.name)
|
158
|
+
const name = Path.basename(chunkInfo.name, Path.extname(chunkInfo.name))
|
159
|
+
return Path.join(dir, `${name}-[hash].cjs`)
|
160
|
+
},
|
161
|
+
assetFileNames: (assetInfo) => {
|
162
|
+
const name = assetInfo.name ?? ''
|
163
|
+
const dir = Path.dirname(name)
|
164
|
+
const baseName = Path.basename(name, Path.extname(name))
|
165
|
+
const ext = Path.extname(name)
|
166
|
+
return Path.join(dir, `${baseName}-[hash]${ext}`)
|
167
|
+
},
|
168
|
+
}),
|
171
169
|
},
|
172
170
|
},
|
173
|
-
}
|
174
|
-
)
|
171
|
+
},
|
172
|
+
} satisfies InlineConfig)
|
173
|
+
|
174
|
+
const output = await viteBuild(mergedConfig)
|
175
175
|
|
176
176
|
return output as RollupOutput
|
177
177
|
}
|
@@ -481,7 +481,14 @@ export async function build(args: {
|
|
481
481
|
}
|
482
482
|
|
483
483
|
if (foundRoute.type === 'ssg') {
|
484
|
-
const html = await render({
|
484
|
+
const html = await render({
|
485
|
+
path,
|
486
|
+
preloads,
|
487
|
+
loaderProps,
|
488
|
+
loaderData,
|
489
|
+
css: allCSS,
|
490
|
+
mode: 'ssg',
|
491
|
+
})
|
485
492
|
await outputFile(htmlOutPath, html)
|
486
493
|
continue
|
487
494
|
}
|
package/src/createApp.native.tsx
CHANGED
@@ -11,7 +11,7 @@ LogBox.ignoreLogs([/Sending .* with no listeners registered/])
|
|
11
11
|
|
12
12
|
export function createApp(options: CreateAppProps): void {
|
13
13
|
const App = () => {
|
14
|
-
let contents = <Root isClient routes={options.routes} path="/" />
|
14
|
+
let contents = <Root mode="spa" isClient routes={options.routes} path="/" />
|
15
15
|
|
16
16
|
// if (process.env.ONE_ENABLE_REACT_SCAN) {
|
17
17
|
// console.warn(`React Scan enabled with options: ${process.env.ONE_ENABLE_REACT_SCAN}`)
|
package/src/createApp.tsx
CHANGED
@@ -1,22 +1,128 @@
|
|
1
1
|
import './setup'
|
2
2
|
|
3
|
+
import { AppRegistry } from 'react-native'
|
3
4
|
import { Root } from './Root'
|
4
5
|
import { resolveClientLoader } from './clientLoaderResolver'
|
5
6
|
import { render } from './render'
|
6
7
|
import { renderToString } from './server-render'
|
7
8
|
import type { RenderAppProps } from './types'
|
9
|
+
import { rand } from './utils/rand'
|
10
|
+
// @ts-ignore
|
11
|
+
import ReactDOMServer from 'react-dom/server.browser'
|
8
12
|
|
9
13
|
export type CreateAppProps = { routes: Record<string, () => Promise<unknown>> }
|
10
14
|
|
15
|
+
// replacing Vites since we control the root
|
16
|
+
function DevHead({ ssrID }: { ssrID: string }) {
|
17
|
+
if (process.env.NODE_ENV === 'development') {
|
18
|
+
return (
|
19
|
+
<>
|
20
|
+
<link rel="preload" href={ssrID} as="style" />
|
21
|
+
<link rel="stylesheet" href={ssrID} data-ssr-css />
|
22
|
+
<script
|
23
|
+
type="module"
|
24
|
+
dangerouslySetInnerHTML={{
|
25
|
+
__html: `import { createHotContext } from "/@vite/client";
|
26
|
+
const hot = createHotContext("/__clear_ssr_css");
|
27
|
+
hot.on("vite:afterUpdate", () => {
|
28
|
+
document
|
29
|
+
.querySelectorAll("[data-ssr-css]")
|
30
|
+
.forEach(node => node.remove());
|
31
|
+
});`,
|
32
|
+
}}
|
33
|
+
/>
|
34
|
+
<script
|
35
|
+
type="module"
|
36
|
+
dangerouslySetInnerHTML={{
|
37
|
+
__html: `import { injectIntoGlobalHook } from "/@react-refresh";
|
38
|
+
injectIntoGlobalHook(window);
|
39
|
+
window.$RefreshReg$ = () => {};
|
40
|
+
window.$RefreshSig$ = () => (type) => type;`,
|
41
|
+
}}
|
42
|
+
/>
|
43
|
+
</>
|
44
|
+
)
|
45
|
+
}
|
46
|
+
|
47
|
+
return null
|
48
|
+
}
|
49
|
+
|
11
50
|
export function createApp(options: CreateAppProps) {
|
12
51
|
if (import.meta.env.SSR) {
|
13
52
|
return {
|
14
53
|
options,
|
15
54
|
render: async (props: RenderAppProps) => {
|
16
|
-
|
55
|
+
const App = () => {
|
56
|
+
let { loaderData, loaderProps, css, mode } = props
|
57
|
+
|
58
|
+
return (
|
59
|
+
<html lang="en-US">
|
60
|
+
<head>
|
61
|
+
{process.env.NODE_ENV === 'development' ? (
|
62
|
+
<DevHead ssrID={`/@id/__x00__virtual:ssr-css.css?t=${rand()}`} />
|
63
|
+
) : null}
|
64
|
+
|
65
|
+
<script
|
66
|
+
dangerouslySetInnerHTML={{
|
67
|
+
__html: `globalThis['global'] = globalThis`,
|
68
|
+
}}
|
69
|
+
/>
|
70
|
+
|
71
|
+
{css?.map((file) => {
|
72
|
+
return <link key={file} rel="stylesheet" href={file} />
|
73
|
+
})}
|
74
|
+
</head>
|
75
|
+
<body>
|
76
|
+
<Root routes={options.routes} {...props} />
|
77
|
+
</body>
|
78
|
+
{/* could this just be loaded via the same loader.js? as a preload? i think so... */}
|
79
|
+
<script
|
80
|
+
async
|
81
|
+
// @ts-ignore
|
82
|
+
href="one-loader-data"
|
83
|
+
dangerouslySetInnerHTML={{
|
84
|
+
__html: `
|
85
|
+
globalThis['__vxrnPostRenderData__'] = { __vxrn__: 'post-render' };
|
86
|
+
globalThis['__vxrnLoaderData__'] = ${JSON.stringify(loaderData)};
|
87
|
+
globalThis['__vxrnLoaderProps__'] = ${JSON.stringify(loaderProps)};
|
88
|
+
globalThis['__vxrnHydrateMode__'] = ${JSON.stringify(mode)};
|
89
|
+
`,
|
90
|
+
}}
|
91
|
+
/>
|
92
|
+
</html>
|
93
|
+
)
|
94
|
+
}
|
95
|
+
|
96
|
+
AppRegistry.registerComponent('App', () => App)
|
97
|
+
|
98
|
+
// @ts-expect-error
|
99
|
+
const Application = AppRegistry.getApplication('App', {})
|
100
|
+
|
101
|
+
// we've got to remove the outer containers because it messes up the fact we render root html
|
102
|
+
const rootElement = Application.element.props.children
|
103
|
+
|
104
|
+
let html = await renderToString(rootElement, {
|
17
105
|
preloads: props.preloads,
|
18
106
|
})
|
19
107
|
|
108
|
+
try {
|
109
|
+
const styleTag = Application.getStyleElement({ nonce: process.env.ONE_NONCE })
|
110
|
+
if (styleTag) {
|
111
|
+
const rnwStyleHTML = ReactDOMServer.renderToStaticMarkup(styleTag)
|
112
|
+
if (rnwStyleHTML) {
|
113
|
+
html = html.replace(`</head>`, `${rnwStyleHTML}</head>`)
|
114
|
+
}
|
115
|
+
}
|
116
|
+
} catch (err) {
|
117
|
+
// react-native-web-lite has a bug but its fine we don't need it for now
|
118
|
+
// but TODO is fix this in react-native-web-lite
|
119
|
+
if (`${err}`.includes(`sheet is not defined`)) {
|
120
|
+
// ok
|
121
|
+
} else {
|
122
|
+
throw err
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
20
126
|
// now we can grab and serialize in our zero queries
|
21
127
|
const serverData = globalThis['__vxrnServerData__']
|
22
128
|
if (serverData) {
|
@@ -26,16 +132,6 @@ export function createApp(options: CreateAppProps) {
|
|
26
132
|
}
|
27
133
|
}
|
28
134
|
|
29
|
-
// // adds support for modulepreload scripts to browsers that dont support (safari and ff)
|
30
|
-
// // https://guybedford.com/es-module-preloading-integrity#modulepreload-polyfill
|
31
|
-
// html = html.replace(
|
32
|
-
// '</body>',
|
33
|
-
// `<script>
|
34
|
-
// const h="modulepreload",E=function(i){return"/"+i},a={},y=function(u,s,v){let c=Promise.resolve();if(s&&s.length>0){document.getElementsByTagName("link");const e=document.querySelector("meta[property=csp-nonce]"),t=(e==null?void 0:e.nonce)||(e==null?void 0:e.getAttribute("nonce"));c=Promise.allSettled(s.map(r=>{if(r=E(r),r in a)return;a[r]=!0;const o=r.endsWith(".css"),d=o?'[rel="stylesheet"]':"";if(document.querySelector('link[href="' + r + '"]' + d))return;const n=document.createElement("link");if(n.rel=o?"stylesheet":h,o||(n.as="script"),n.crossOrigin="",n.href=r,t&&n.setAttribute("nonce",t),document.head.appendChild(n),o)return new Promise((f,m)=>{n.addEventListener("load",f),n.addEventListener("error",()=>m(new Error('Unable to preload CSS for ' + r)))})}))}function l(e){const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return c.then(e=>{for(const t of e||[])t.status==="rejected"&&l(t.reason);return u().catch(l)})};
|
35
|
-
// y()
|
36
|
-
// </script>` + '</body>'
|
37
|
-
// )
|
38
|
-
|
39
135
|
return html
|
40
136
|
},
|
41
137
|
}
|
@@ -53,7 +149,7 @@ export function createApp(options: CreateAppProps) {
|
|
53
149
|
})
|
54
150
|
.then(() => {
|
55
151
|
// on client we just render
|
56
|
-
render(<Root isClient routes={options.routes} path={window.location.href} />)
|
152
|
+
render(<Root mode="spa" isClient routes={options.routes} path={window.location.href} />)
|
57
153
|
})
|
58
154
|
.catch((err) => {
|
59
155
|
console.error(`Error running client loader resolver "onClientLoaderResolve":`, err)
|
@@ -129,12 +129,6 @@ function NavigationContainerInner(
|
|
129
129
|
)
|
130
130
|
}
|
131
131
|
|
132
|
-
const cache = {
|
133
|
-
done: false,
|
134
|
-
promise: null as any,
|
135
|
-
val: 0 as any,
|
136
|
-
}
|
137
|
-
|
138
132
|
const NavigationContainer = React.forwardRef(NavigationContainerInner) as <
|
139
133
|
RootParamList extends object = ReactNavigation.RootParamList,
|
140
134
|
>(
|
package/src/getRoutes.ts
CHANGED
package/src/server/oneServe.ts
CHANGED
package/src/setup.ts
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
// FIXME: This will break the release build of the React Native app.
|
2
|
-
import { scan } from 'react-scan'
|
3
|
-
|
4
1
|
if (process.env.ONE_ENABLE_REACT_SCAN) {
|
5
|
-
scan
|
2
|
+
import('react-scan').then(({ scan }) => {
|
3
|
+
scan(JSON.parse(`${process.env.ONE_ENABLE_REACT_SCAN}`))
|
4
|
+
})
|
6
5
|
}
|
7
6
|
|
8
7
|
// fixes bad import error in expo-modules-core
|
package/src/types.ts
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
// TODO merge into vite/types
|
2
2
|
|
3
|
+
import type { One } from './vite/types'
|
4
|
+
|
3
5
|
/** The list of input keys will become optional, everything else will remain the same. */
|
4
6
|
export type PickPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>
|
5
7
|
|
@@ -26,6 +28,7 @@ export type LoaderProps<Params extends Object = Record<string, string>> = {
|
|
26
28
|
}
|
27
29
|
|
28
30
|
export type RenderAppProps = {
|
31
|
+
mode: One.RouteRenderMode
|
29
32
|
path: string
|
30
33
|
preloads?: string[]
|
31
34
|
css?: string[]
|
package/src/vite/one.ts
CHANGED
@@ -296,6 +296,14 @@ export function one(options: One.PluginOptions = {}): PluginOption {
|
|
296
296
|
// react scan
|
297
297
|
const scan = options.react?.scan
|
298
298
|
|
299
|
+
const reactScanPlugin = {
|
300
|
+
name: `one:react-scan`,
|
301
|
+
config() {
|
302
|
+
return reactScanConfig
|
303
|
+
},
|
304
|
+
}
|
305
|
+
devAndProdPlugins.push(reactScanPlugin)
|
306
|
+
|
299
307
|
// do it here because it gets called a few times
|
300
308
|
const reactScanConfig = ((): UserConfig => {
|
301
309
|
const stringify = (obj: Object) => JSON.stringify(JSON.stringify(obj))
|
@@ -303,7 +311,7 @@ export function one(options: One.PluginOptions = {}): PluginOption {
|
|
303
311
|
const configs = {
|
304
312
|
disabled: {
|
305
313
|
define: {
|
306
|
-
'process.env.ONE_ENABLE_REACT_SCAN': '
|
314
|
+
'process.env.ONE_ENABLE_REACT_SCAN': '""',
|
307
315
|
},
|
308
316
|
},
|
309
317
|
enabled: {
|
@@ -318,6 +326,9 @@ export function one(options: One.PluginOptions = {}): PluginOption {
|
|
318
326
|
} satisfies Record<string, UserConfig>
|
319
327
|
|
320
328
|
const getConfigFor = (platform: 'ios' | 'android' | 'client'): UserConfig => {
|
329
|
+
if (process.env.NODE_ENV === 'production') {
|
330
|
+
return configs.disabled
|
331
|
+
}
|
321
332
|
if (!scan) {
|
322
333
|
return configs.disabled
|
323
334
|
}
|
@@ -358,15 +369,7 @@ export function one(options: One.PluginOptions = {}): PluginOption {
|
|
358
369
|
})()
|
359
370
|
|
360
371
|
// TODO move to single config and through environments
|
361
|
-
const nativeWebDevAndProdPlugsin: Plugin[] = [
|
362
|
-
clientTreeShakePlugin(),
|
363
|
-
{
|
364
|
-
name: `one:react-scan`,
|
365
|
-
config() {
|
366
|
-
return reactScanConfig
|
367
|
-
},
|
368
|
-
},
|
369
|
-
]
|
372
|
+
const nativeWebDevAndProdPlugsin: Plugin[] = [clientTreeShakePlugin(), reactScanPlugin]
|
370
373
|
|
371
374
|
// TODO make this passed into vxrn through real API
|
372
375
|
globalThis.__vxrnAddNativePlugins = nativeWebDevAndProdPlugsin
|
@@ -78,6 +78,7 @@ export function createFileSystemRouterPlugin(options: One.PluginOptions): Plugin
|
|
78
78
|
const is404 = route.isNotFound || !exported.default
|
79
79
|
|
80
80
|
const html = await render({
|
81
|
+
mode: route.type === 'ssg' ? 'ssg' : route.type === 'ssr' ? 'ssr' : 'spa',
|
81
82
|
loaderData,
|
82
83
|
loaderProps,
|
83
84
|
path: loaderProps?.path || '/',
|
package/types/Root.d.ts
CHANGED
@@ -3,7 +3,6 @@ import { type FunctionComponent, type ReactNode } from 'react';
|
|
3
3
|
import type { GlobbedRouteImports, RenderAppProps } from './types';
|
4
4
|
import type { One } from './vite/types';
|
5
5
|
type RootProps = RenderAppProps & Omit<InnerProps, 'context'> & {
|
6
|
-
mode?: One.RouteRenderMode;
|
7
6
|
isClient?: boolean;
|
8
7
|
routes: GlobbedRouteImports;
|
9
8
|
routeOptions?: One.RouteOptions;
|
package/types/Root.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Root.d.ts","sourceRoot":"","sources":["../src/Root.tsx"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,wBAAwB,EAC9B,MAAM,0BAA0B,CAAA;AAEjC,OAAO,EAAiC,KAAK,iBAAiB,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAK7F,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;
|
1
|
+
{"version":3,"file":"Root.d.ts","sourceRoot":"","sources":["../src/Root.tsx"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,wBAAwB,EAC9B,MAAM,0BAA0B,CAAA;AAEjC,OAAO,EAAiC,KAAK,iBAAiB,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAK7F,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAKlE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAQvC,KAAK,SAAS,GAAG,cAAc,GAC7B,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,GAAG;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,MAAM,EAAE,mBAAmB,CAAA;IAC3B,YAAY,CAAC,EAAE,GAAG,CAAC,YAAY,CAAA;CAChC,CAAA;AAEH,KAAK,UAAU,GAAG;IAChB,OAAO,EAAE,GAAG,CAAC,YAAY,CAAA;IACzB,QAAQ,CAAC,EAAE,GAAG,CAAA;IACd,OAAO,CAAC,EAAE,iBAAiB,CAAC;QAAE,QAAQ,EAAE,SAAS,CAAA;KAAE,CAAC,CAAA;IACpD,wBAAwB,CAAC,EAAE,wBAAwB,GAAG;QACpD,KAAK,CAAC,EAAE;YACN,IAAI,EAAE,OAAO,CAAA;YACb,MAAM,EAAE;gBACN,OAAO,EAAE,MAAM,CAAA;gBACf,UAAU,EAAE,MAAM,CAAA;gBAClB,IAAI,EAAE,MAAM,CAAA;gBACZ,IAAI,EAAE,MAAM,CAAA;gBACZ,MAAM,EAAE,MAAM,CAAA;gBACd,YAAY,EAAE,MAAM,CAAA;aACrB,CAAA;SACF,CAAA;KACF,CAAA;CACF,CAAA;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,kDA0FpC"}
|
package/types/cli/build.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/cli/build.ts"],"names":[],"mappings":"AA+BA,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/cli/build.ts"],"names":[],"mappings":"AA+BA,wBAAsB,KAAK,CAAC,IAAI,EAAE;IAChC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,iBAslBA"}
|
package/types/createApp.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"createApp.d.ts","sourceRoot":"","sources":["../src/createApp.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,CAAA;
|
1
|
+
{"version":3,"file":"createApp.d.ts","sourceRoot":"","sources":["../src/createApp.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,CAAA;AAOhB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAK7C,MAAM,MAAM,cAAc,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA;CAAE,CAAA;AAqC/E,wBAAgB,SAAS,CAAC,OAAO,EAAE,cAAc;;oBAIrB,cAAc;EA2GzC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"NavigationContainer.d.ts","sourceRoot":"","sources":["../../src/fork/NavigationContainer.tsx"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,oBAAoB,EAEzB,KAAK,cAAc,EAEnB,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAE3B,KAAK,KAAK,EAMX,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAU9B,KAAK,KAAK,CAAC,SAAS,SAAS,MAAM,IAAI,wBAAwB,GAAG;IAChE,SAAS,CAAC,EAAE,eAAe,CAAA;IAC3B,aAAa,CAAC,EAAE,oBAAoB,CAAA;IACpC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,OAAO,CAAC,EAAE,cAAc,CAAC,SAAS,CAAC,CAAA;IACnC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;
|
1
|
+
{"version":3,"file":"NavigationContainer.d.ts","sourceRoot":"","sources":["../../src/fork/NavigationContainer.tsx"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,oBAAoB,EAEzB,KAAK,cAAc,EAEnB,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAE3B,KAAK,KAAK,EAMX,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAU9B,KAAK,KAAK,CAAC,SAAS,SAAS,MAAM,IAAI,wBAAwB,GAAG;IAChE,SAAS,CAAC,EAAE,eAAe,CAAA;IAC3B,aAAa,CAAC,EAAE,oBAAoB,CAAA;IACpC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,OAAO,CAAC,EAAE,cAAc,CAAC,SAAS,CAAC,CAAA;IACnC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AA8FD,QAAA,MAAM,mBAAmB,EAAiD,CACxE,aAAa,SAAS,MAAM,GAAG,eAAe,CAAC,aAAa,EAE5D,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG;IAC5B,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,CAAA;CACvD,KACE,KAAK,CAAC,YAAY,CAAA;AAEvB,eAAe,mBAAmB,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"oneServe.d.ts","sourceRoot":"","sources":["../../src/server/oneServe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAqB,MAAM,MAAM,CAAA;AASnD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AAIxC,wBAAsB,QAAQ,CAC5B,UAAU,EAAE,GAAG,CAAC,aAAa,EAC7B,SAAS,EAAE,GAAG,CAAC,SAAS,EACxB,GAAG,EAAE,IAAI,EACT,WAAW,UAAO,
|
1
|
+
{"version":3,"file":"oneServe.d.ts","sourceRoot":"","sources":["../../src/server/oneServe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAqB,MAAM,MAAM,CAAA;AASnD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AAIxC,wBAAsB,QAAQ,CAC5B,UAAU,EAAE,GAAG,CAAC,aAAa,EAC7B,SAAS,EAAE,GAAG,CAAC,SAAS,EACxB,GAAG,EAAE,IAAI,EACT,WAAW,UAAO,iBA8LnB"}
|
package/types/setup.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AASA,OAAO,wCAAwC,CAAA"}
|
package/types/types.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import type { One } from './vite/types';
|
1
2
|
/** The list of input keys will become optional, everything else will remain the same. */
|
2
3
|
export type PickPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
3
4
|
export type GlobbedRouteImports = Record<string, () => Promise<unknown>>;
|
@@ -18,6 +19,7 @@ export type LoaderProps<Params extends Object = Record<string, string>> = {
|
|
18
19
|
request?: Request;
|
19
20
|
};
|
20
21
|
export type RenderAppProps = {
|
22
|
+
mode: One.RouteRenderMode;
|
21
23
|
path: string;
|
22
24
|
preloads?: string[];
|
23
25
|
css?: string[];
|
package/types/types.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,yFAAyF;AACzF,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AAEhF,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA;AAExE,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;AAE1E,MAAM,MAAM,OAAO,GAAG;IACpB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,UAA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3,"file":"one.d.ts","sourceRoot":"","sources":["../../src/vite/one.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAU,YAAY,EAAc,MAAM,MAAM,CAAA;AAW5D,OAAO,qBAAqB,CAAA;AAY5B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAkBlC,wBAAgB,GAAG,CAAC,OAAO,GAAE,GAAG,CAAC,aAAkB,GAAG,YAAY,CA8ajE"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fileSystemRouterPlugin.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/fileSystemRouterPlugin.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAW,MAAM,EAAiB,MAAM,MAAM,CAAA;AAU1D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAM3C,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,GAAG,CAAC,aAAa,GAAG,MAAM,
|
1
|
+
{"version":3,"file":"fileSystemRouterPlugin.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/fileSystemRouterPlugin.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAW,MAAM,EAAiB,MAAM,MAAM,CAAA;AAU1D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAM3C,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,GAAG,CAAC,aAAa,GAAG,MAAM,CAqX/E"}
|