speckle-server/packages/frontend
Alessandro Magionami 146060355f
Alessandro/web 2161 commits (#3511)
* chore(multiregion): commits resolvers multiregion

* chore(multiregion): fix tests
2024-11-19 16:00:45 +01:00
..
.vscode chore(server): core IoC #40 - favoriteStreamFactory (#3252) 2024-10-14 10:44:45 +02:00
nginx fix(frontend & frontend-2): `x-frame-options` header for `/authn` routes should be `DENY` (#1719) 2023-07-24 15:17:16 +01:00
public refactor(frontend): vue cli v4 -> vite (#1000) 2022-10-05 15:59:11 +03:00
src Alessandro/web 2161 commits (#3511) 2024-11-19 16:00:45 +01:00
.browserslistrc feat: fixed viewer & objectloader build configs 2022-04-08 12:46:34 +03:00
Dockerfile chore: updating ws everywhere to resolve SNYK-JS-WS-7266574 (#2385) 2024-06-18 13:26:01 +03:00
README.md feat(frontend): comments in viewer embed + refactored frontend viewer foundations 2022-08-01 12:43:50 +03:00
apollo.config.js fix(monorepo): make sure to use 127.0.0.1 instead of localhost 2023-08-03 10:28:57 +02:00
babel.config.js feat(frontend): build speed & chunk structure optimization (#690) 2022-04-13 10:21:24 +03:00
codegen.yml bump fe1 branch query limit and disregard broken pagination logic (#1875) 2023-11-17 13:11:21 +01:00
eslint.config.mjs chore: upgrade to eslint 9 (#2348) 2024-06-12 14:38:02 +03:00
index.html refactor(frontend): vue cli v4 -> vite (#1000) 2022-10-05 15:59:11 +03:00
package.json chore(deps): bump dompurify from 2.3.6 to 2.5.4 (#3014) 2024-11-07 21:04:44 +00:00
tsconfig.eslint.json chore: upgrade to eslint 9 (#2348) 2024-06-12 14:38:02 +03:00
tsconfig.json chore: upgrade to eslint 9 (#2348) 2024-06-12 14:38:02 +03:00
vite.config.js chore: upgrade to eslint 9 (#2348) 2024-06-12 14:38:02 +03:00

README.md

The Speckle Frontend App

Twitter Follow Community forum users website docs

Disclaimer

We're working to stabilize the 2.0 API, and until then there will be breaking changes.

Notes:

  • In development mode, the Speckle Server will proxy the frontend from localhost:3000 to localhost:8080. If you don't see anything, ensure you've run yarn serve in the frontend package.

  • In production mode, the Speckle Frontend will be statically served by nginx (see the Dockerfile in the current directory).

Documentation

Comprehensive developer and user documentation can be found in our:

📚 Speckle Docs website

Project setup

Make sure you follow the Developing and Debugging section in the project root readme.

Running

Dev server with hot reload:

yarn dev

Build static build & serve it (for development, otherwise use docker image):

yarn build && yarn serve

Apollo Client

We're on Apollo Client v3 and Vue Apollo v4 (both the options API and composition API) in this package, so pretty much all of the latest and greatest features are there and ready to be used.

Note: Do not import anything from @apollo/client, use @apollo/client/core instead! Otherwise you risk bundling in React dependencies, which we definitely do not need!

TypeScript

This project also supports TypeScript, both in Vue SFCs and outside them. It's preferred that you use it when writing new code and also migrate JS files when there's a good oppurtunity to do so.

TS in Vue

  1. Set <script lang="ts"> in your .vue SFC
  2. Make sure you do export default defineComponent({...}) or export default Vue.extend({...}) (or something else that is explicity typed to be a Vue component) not just export default, otherwise it's not clear to TS that the exported object is a Vue component
  3. If Vetur reports incorrect errors, check this out: https://vuejs.github.io/vetur/guide/FAQ.html

Note: If you're defining a Vue component in a non-standard way (e.g. vueWithMixins([]).extends({...})), make sure you add a // @vue/component comment right above the Vue component object definition so that ESLint shows Vue appropriate linting rules, otherwise it won't.

Improved GraphQL DX w/ TS

Run yarn gqlgen to generate relevant TS types from the GraphQL Schema (introspected from server which must be running) and operations defined in the frontend. Afterwards make sure you import them from the generated graphql.ts file, not the original file where you defined the operation/fragment.

Packaging for production

If you plan to package the frontend to use in a production setting, see our Server deployment instructions (chapter Run your speckle-server fork)

Troubleshooting

Vue TypeScript types get stuck in VSCode

Restart the Vetur Vue Language Server (VLS) through the command palette. Vetur is a bit janky and sometimes it gets stuck and isn't able to find new types/code.

Property 'xxx' does not exist on type 'CombinedVueInstance'

If you are getting a lot of Property 'xxx' does not exist on type 'CombinedVueInstance' errors, it's an issue with Vue's typing and TypeScript. You can work around it by annotating the return type for each computed/data property, making sure data/props keys are defined even if they're empty.

Vue Apollo Options API fetchMore() doesn't update the state/template quickly enough

This seems to be an issue that appeared after the Apollo Client v2 -> Apollo Client v3 upgrade. It only becomes an issue when you're trying to use vue-infinite-loader with fetchMore(), because the infinite loader triggers an infinite amount of requests with the old cursor, because the cursor hasn't been updated yet at that point.

The workaround is simple - use the Vue Apollo Composition API fetchMore

Community

If in trouble, the Speckle Community hangs out on the forum. Do join and introduce yourself! We're happy to help.

License

Unless otherwise described, the code in this repository is licensed under the Apache-2.0 License. Please note that some modules, extensions or code herein might be otherwise licensed. This is indicated either in the root of the containing folder under a different license file, or in the respective file's header. If you have any questions, don't hesitate to get in touch with us via email.