Skip to content

Commit 3682ba4

Browse files
committed
Bootstrap the viewer
0 parents  commit 3682ba4

23 files changed

Lines changed: 9188 additions & 0 deletions

.env

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# ---- Authorization Client Settings ----
2+
IMJS_AUTH_CLIENT_CLIENT_ID = ""
3+
IMJS_AUTH_CLIENT_REDIRECT_URI = ""
4+
IMJS_AUTH_CLIENT_LOGOUT_URI = ""
5+
IMJS_AUTH_CLIENT_SCOPES ="itwin-platform"
6+
IMJS_AUTH_AUTHORITY="https://ims.bentley.com"
7+
8+
# ---- Test ids ----
9+
IMJS_ITWIN_ID = ""
10+
IMJS_IMODEL_ID = ""
11+
12+
# Advanced CRA Config: https://create-react-app.dev/docs/advanced-configuration/
13+
SKIP_PREFLIGHT_CHECK=true
14+
15+
# # Advanced iTwin.js CRA Config: https://github.com/imodeljs/create-react-app/blob/imodeljs/packages/react-scripts/README-imodeljs.md
16+
# USE_FAST_SASS=true
17+
# USE_FULL_SOURCEMAP=true
18+
# TRANSPILE_DEPS=false
19+
# # Remove the following env var if using a different package manager
20+
# USING_NPM=true

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
/dist
14+
15+
# misc
16+
.DS_Store
17+
.env.local
18+
.env.development.local
19+
.env.test.local
20+
.env.production.local
21+
22+
npm-debug.log*
23+
yarn-debug.log*
24+
yarn-error.log*

.npmrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@bentley:registry=https://registry.npmjs.org/
2+
@itwin:registry=https://registry.npmjs.org/
3+
legacy-peer-deps=true

LICENSE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# MIT License
2+
3+
Copyright © 2017-2021 Bentley Systems, Incorporated. All rights reserved.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Getting Started with the iTwin Viewer Template
2+
3+
This project was scaffolded with [degit](https://github.com/Rich-Harris/degit).
4+
5+
## Environment Variables
6+
7+
Prior to running the app, you will need to add OIDC client configuration to the variables in the .env file:
8+
9+
```
10+
# ---- Authorization Client Settings ----
11+
IMJS_AUTH_CLIENT_CLIENT_ID=""
12+
IMJS_AUTH_CLIENT_REDIRECT_URI=""
13+
IMJS_AUTH_CLIENT_LOGOUT_URI=""
14+
IMJS_AUTH_CLIENT_SCOPES=""
15+
```
16+
17+
- You can generate a [test client](https://developer.bentley.com/tutorials/web-application-quick-start/#3-register-an-application) to get started.
18+
19+
- Viewer expects the `itwin-platform` scope to be set.
20+
21+
- The application will use the path of the redirect URI to handle the redirection, it must simply match what is defined in your client.
22+
23+
- When you are ready to build a production application, [register here](https://developer.bentley.com/register/).
24+
25+
You should also add a valid iTwinId and iModelId for your user in the this file:
26+
27+
```
28+
# ---- Test ids ----
29+
IMJS_ITWIN_ID = ""
30+
IMJS_IMODEL_ID = ""
31+
```
32+
33+
- For the IMJS_ITWIN_ID variable, you can use the id of one of your existing iTwins. You can obtain their ids via the [iTwin REST APIs](https://developer.bentley.com/apis/itwins/operations/get-itwin/).
34+
35+
- For the IMJS_IMODEL_ID variable, use the id of an iModel that belongs to the iTwin that you specified in the IMJS_ITWIN_ID variable. You can obtain iModel ids via the [iModel REST APIs](https://developer.bentley.com/apis/imodels-v2/operations/get-imodel-details/).
36+
37+
- Alternatively, you can [generate a test iModel](https://developer.bentley.com/tutorials/web-application-quick-start/#4-create-an-imodel) to get started without an existing iModel.
38+
39+
- If at any time you wish to change the iModel that you are viewing, you can change the values of the iTwinId or iModelId query parameters in the url (i.e. localhost:3000?iTwinId=myNewITwinId&iModelId=myNewIModelId)
40+
41+
## Available Scripts
42+
43+
In the project directory, you can run:
44+
45+
### `npm install`
46+
47+
Installs all the dependencies listed in your package.json.
48+
49+
### `npm start`
50+
51+
Runs the app in the development mode.\
52+
It automatically opens [http://localhost:3000](http://localhost:3000) in your default browser.
53+
54+
The page will reload if you make edits.\
55+
56+
### `npm run build`
57+
58+
Builds the app for production to the `dist` folder.\
59+
It bundles your code in production mode and applies optimizations for best performance.
60+
61+
The build is minified and the filenames include the hashes.\
62+
Your app is ready to be deployed!
63+
64+
See the section about [deployment](https://vite.dev/guide/static-deploy.html) for more information.
65+
66+
### `npm run preview`
67+
68+
Once you have built the app using `npm run build` you may test it locally by running this command.
69+
70+
This will boot up a local static web server that serves the files from `dist` at [http://localhost:3000](http://localhost:3000).
71+
72+
### `npm run lint`
73+
74+
Runs ESLint on all source files to check for code style issues and potential errors.
75+
76+
## Next Steps
77+
78+
- [iTwin Viewer options](https://www.npmjs.com/package/@itwin/web-viewer-react)
79+
80+
- [Extending the iTwin Viewer](https://developer.bentley.com/tutorials/itwin-viewer-hello-world/)
81+
82+
- [Using the iTwin Platform](https://developer.bentley.com/)
83+
84+
- [iTwin Developer Program](https://www.youtube.com/playlist?list=PL6YCKeNfXXd_dXq4u9vtSFfsP3OTVcL8N)

eslint.config.mjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import iTwinPlugin from "@itwin/eslint-plugin";
2+
import reactPlugin from "eslint-plugin-react";
3+
4+
export default [
5+
{
6+
files: ["**/*.{ts,tsx}"],
7+
...iTwinPlugin.configs.uiConfig,
8+
},
9+
{
10+
files: ["**/*.{ts,tsx}"],
11+
rules: {
12+
...reactPlugin.configs["jsx-runtime"].rules,
13+
},
14+
},
15+
];

index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<link rel="icon" href="favicon.ico" />
7+
<title>iTwin Viewer React Sample</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/index.tsx"></script>
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)