2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-03 12:10:59 +00:00

[Plugin] Plugin context (#9439)

* Pass more stuff to window

* Expose form functions to plugin context

* Breaking: Render plugin component in context tree

- Required due to createRoot function
- Adds necessary context providers

* Fix context

* Provide MantineThemeContext

* Bundle mantine/core

* Hack for useNavigate within ApiForm

- Errors out if called within plugin context
- Workaround to catch the error

* Update build cmd

* Define config for building "Library" mode

* Update package.json

* Add basic index file

* Factor out ApiEndpoints

* factor out ModelType

* Factor out role enums

* Further refactoring

* More refactoring

* Cleanup

* Expose apiUrl function

* Add instance data to plugin context type def

* Tweaks for loading plugin components

- LanguageContext must be on the inside

* Tweak StylishText

* Externalize notifications system

* Update lingui config

* Add functions for checking plugin interface version

* Extract package version at build time

* Enhance version checking

* Revert variable name change

* Public package

* Add README.md

* adjust packge name

* Adjust name to include org

* Update project files

* Add basic changelog info

* Refactoring to expose URL functions

* Refactor navigation functions

* Update package and README

* Improve navigateToLink function

* Refactor stylish text

- Move into ./lib
- Do not require user state

* Revert changes

- StylishText throws error in plugin
- Low priority, can work out later

* expose function to refresh page index

* Provide RemoteComponent with a method to reload itself

* Bump version

* Cleanup tests

* Prevent duplicate --emptyOutDir arg

* Tweak playwright tests

* Expose role and permission enums

* Fix imports

* Updated docs

* Fix spelling, typos, etc

* Include more package version information

* Expose more version context

* Cleanup

* Probably don't need hooks

* Fix links

* Docs updates

* Fix links
This commit is contained in:
Oliver
2025-04-16 00:30:34 +10:00
committed by GitHub
parent f3d804d5ea
commit 5e7e258289
276 changed files with 2797 additions and 1854 deletions

View File

@ -0,0 +1,49 @@
// This config file is used to build the common InvenTree UI library components,
// which are distributed via NPM - to facilitate plugin development
import { resolve } from 'node:path';
import { defineConfig, mergeConfig } from 'vite';
import dts from 'vite-plugin-dts';
import viteConfig from './vite.config';
import { __INVENTREE_VERSION_INFO__ } from './version-info';
export default defineConfig((cfg) =>
mergeConfig(
viteConfig(cfg),
defineConfig({
resolve: {},
build: {
minify: false,
manifest: true,
outDir: 'dist',
sourcemap: true,
rollupOptions: {
output: {
preserveModules: true,
preserveModulesRoot: 'lib'
},
external: ['react', 'react-dom']
},
lib: {
entry: {
index: resolve(__dirname, 'lib/index.ts')
},
name: 'InvenTree',
formats: ['es']
}
},
plugins: [
dts({
entryRoot: 'lib',
outDir: 'dist',
insertTypesEntry: true, // Ensures `dist/index.d.ts` is generated
exclude: ['node_modules/**/*', 'src/**/*']
})
],
define: {
...__INVENTREE_VERSION_INFO__
}
})
)
);