Skip to content

Commit 2189ddf

Browse files
committed
Relative linking
- Merge in the latest main
1 parent 769d753 commit 2189ddf

25 files changed

Lines changed: 142 additions & 101 deletions

package-lock.json

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/app-utils/src/components/AppBootstrap.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function renderComponent(client: CoreClient) {
4545
});
4646
return render(
4747
<ApiContext.Provider value={api}>
48-
<AppBootstrap apiUrl={API_URL} pluginsUrl={PLUGINS_URL}>
48+
<AppBootstrap serverUrl={API_URL} pluginsUrl={PLUGINS_URL}>
4949
{mockChild}
5050
</AppBootstrap>
5151
</ApiContext.Provider>
@@ -59,7 +59,7 @@ beforeEach(() => {
5959
it('should throw if api has not been bootstrapped', () => {
6060
expect(() =>
6161
render(
62-
<AppBootstrap apiUrl={API_URL} pluginsUrl={PLUGINS_URL}>
62+
<AppBootstrap serverUrl={API_URL} pluginsUrl={PLUGINS_URL}>
6363
{mockChild}
6464
</AppBootstrap>
6565
)

packages/app-utils/src/components/AppBootstrap.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import FontBootstrap from './FontBootstrap';
99
import PluginsBootstrap from './PluginsBootstrap';
1010
import AuthBootstrap from './AuthBootstrap';
1111
import ConnectionBootstrap from './ConnectionBootstrap';
12-
import { getBaseUrl, getConnectOptions } from '../utils';
12+
import { getConnectOptions } from '../utils';
1313
import FontsLoaded from './FontsLoaded';
1414

1515
export type AppBootstrapProps = {
16-
/** URL of the API to load. */
17-
apiUrl: string;
16+
/** URL of the server. */
17+
serverUrl: string;
1818

1919
/** URL of the plugins to load. */
2020
pluginsUrl: string;
@@ -33,12 +33,11 @@ export type AppBootstrapProps = {
3333
* Will display the children when everything is loaded and authenticated.
3434
*/
3535
export function AppBootstrap({
36-
apiUrl,
3736
fontClassNames,
3837
pluginsUrl,
38+
serverUrl,
3939
children,
4040
}: AppBootstrapProps) {
41-
const serverUrl = getBaseUrl(apiUrl).origin;
4241
const clientOptions = useMemo(() => getConnectOptions(), []);
4342

4443
// On logout, we reset the client and have user login again

packages/babel-preset/index.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,21 @@ module.exports = api => ({
2222
plugins: [
2323
api.env('test')
2424
? [
25-
// This is needed to replace import.meta w/ process in Jest
25+
// This is needed to replace import.meta.env w/ process in Jest
2626
// Jest does not play nicely w/ ESM and Vite uses import.meta
2727
// import.meta is only avaialable in ESM
2828
path.resolve(__dirname, 'importMetaEnvPlugin'),
2929
]
30-
: // The add-import-extension plugin causes Jest to error, but is needed for proper ESM builds
31-
['babel-plugin-add-import-extension'],
30+
: false,
31+
api.env('test')
32+
? [
33+
// Also need to handle import.meta.url
34+
'babel-plugin-transform-import-meta',
35+
]
36+
: false,
37+
api.env('test')
38+
? false // The add-import-extension plugin causes Jest to error, but is needed for proper ESM builds
39+
: ['babel-plugin-add-import-extension'],
3240
[
3341
'transform-rename-import',
3442
{

packages/babel-preset/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"@babel/preset-react": "^7.18.0",
1818
"@babel/preset-typescript": "^7.18.0",
1919
"babel-plugin-add-import-extension": "^1.6.0",
20+
"babel-plugin-transform-import-meta": "^2.2.0",
2021
"babel-plugin-transform-rename-import": "^2.3.0"
2122
},
2223
"publishConfig": {

packages/code-studio/.env

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
1-
# Location of the iris script and API server
2-
# Set this value to __mocks__ to use mock server instead
3-
BASE_URL=/ide/
4-
VITE_CORE_API_URL=/jsapi
1+
# Path at which the app is served
2+
# https://vitejs.dev/guide/build.html#public-base-path
3+
BASE_URL=./
4+
5+
# Location of the core JS API and API server
6+
# We assume that the jsapi is served up as a sibling of the code studio
7+
# I.e. Web UI served at http://www.example.com/ide/, then JS API served at http://www.example.com/jsapi/
8+
# This path is relative to the base URL, so we need to go up one level
9+
VITE_CORE_API_URL=../jsapi
510
VITE_CORE_API_NAME=dh-core.js
6-
VITE_PLUGIN_URL=/ide/plugins/
7-
VITE_PROXY_URL=http://localhost:10000
11+
12+
# Path to plugins that load a module
13+
# See https://github.com/deephaven/deephaven-js-plugin-template/
14+
# Like the CORE_API_URL, we assume this is served up as a sibling of the code studio
15+
VITE_MODULE_PLUGINS_URL=../js-plugins
16+
17+
# Path for notebooks and layouts storage on the gRPCStorageService
18+
# Note these are not URLs, these are file system paths on the server in the gRPCStorageService
819
VITE_NOTEBOOKS_URL=/notebooks
920
VITE_LAYOUTS_URL=/layouts
10-
VITE_ENABLE_LOG_PROXY=true
21+
22+
# Proxy used by Vite
23+
VITE_PROXY_URL=http://localhost:10000
1124
VITE_SUPPORT_LINK=https://github.com/deephaven/web-client-ui/
1225
VITE_DOCS_LINK=https://deephaven.io/core/docs/
1326
VITE_FAVICON=/favicon-cc-app.svg
1427
VITE_BUILD_PATH=./build
15-
VITE_LOG_LEVEL=2
1628

17-
# Plugin URLs
18-
## Path to plugins that load/render as a component (e.g. Table plugins)
19-
## See https://github.com/deephaven/js-plugin-template/ for templates
20-
VITE_COMPONENT_PLUGINS_URL=/ide/plugins/
21-
22-
## Path to plugins that load a module
23-
## See https://github.com/deephaven/deephaven-js-plugin-template/
24-
VITE_MODULE_PLUGINS_URL=/js-plugins
29+
# Proxy the log service to store logs to export easily for support
30+
VITE_ENABLE_LOG_PROXY=true
31+
VITE_LOG_LEVEL=2
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
BASE_URL=/ide/
2+
VITE_LOG_LEVEL=4
13
VITE_ENABLE_LOG_PROXY=false
24
VITE_FAVICON=/favicon-cc-app-dev.svg
35

4-
BASE_URL=/
56
PORT=4000
6-
VITE_LOG_LEVEL=4

packages/code-studio/.env.test

Lines changed: 0 additions & 2 deletions
This file was deleted.

packages/code-studio/README.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,6 @@ One common setup is to override the API server URL to point to another server. F
2222
VITE_CORE_API_URL=https://www.myserver.com/jsapi
2323
```
2424

25-
### VITE_NOTEBOOKS_URL
26-
27-
One common setup is to override the API server URL to point to another server. For example, add the following block to `.env.development.local` to have `npm start` point to a remote server for the API:
28-
29-
```shell
30-
VITE_CORE_API_URL=https://www.myserver.com/notebooks
31-
```
32-
3325
### VITE_LOG_LEVEL
3426

3527
Printing detailed logs when debugging can be handy. The highest level of logging is already set in your `.env.development` file. You can change it in `.env.development.local` if desired.

packages/code-studio/src/index.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,20 @@ const AppBootstrap = React.lazy(async () => {
1717
return { default: module.AppBootstrap };
1818
});
1919

20+
const apiURL = new URL(
21+
`${import.meta.env.VITE_CORE_API_URL}/${import.meta.env.VITE_CORE_API_NAME}`,
22+
document.baseURI
23+
);
24+
25+
const pluginsURL = new URL(
26+
import.meta.env.VITE_MODULE_PLUGINS_URL,
27+
document.baseURI
28+
);
29+
2030
ReactDOM.render(
21-
<ApiBootstrap
22-
apiUrl={`${import.meta.env.VITE_CORE_API_URL}/${
23-
import.meta.env.VITE_CORE_API_NAME
24-
}`}
25-
setGlobally
26-
>
31+
<ApiBootstrap apiUrl={apiURL.href} setGlobally>
2732
<Suspense fallback={<LoadingOverlay />}>
28-
<AppBootstrap
29-
apiUrl={import.meta.env.VITE_CORE_API_URL}
30-
pluginsUrl={import.meta.env.VITE_MODULE_PLUGINS_URL}
31-
>
33+
<AppBootstrap serverUrl={apiURL.origin} pluginsUrl={pluginsURL.href}>
3234
<AppRoot />
3335
</AppBootstrap>
3436
</Suspense>

0 commit comments

Comments
 (0)