netless-io / netless-app

Official Apps for the Agora Interactive Whiteboard.
https://netless-io.github.io/netless-app
MIT License
58 stars 42 forks source link

Webpack Compatibility or Load NetlessApp object type #4

Closed parallelmedical closed 3 years ago

parallelmedical commented 3 years ago

I've built a custom plugin using this framework however avoided using svelte.

trying to workout how to port to webpack 4 or ability pass netlessapp type for src instead of string.

any guidance on how i would go about doing this?

export type AddAppParams = { kind: string; // app 地址(本地 app 不需要传) src?: string; // 窗口配置 options?: AddAppOptions; // 初始化 attributes attributes?: any; };

crimx commented 3 years ago

We are still in the progress of finalizing the API but here is an example of how it looks like right now:

https://github.com/netless-io/flat/blob/ee33feed9d0f8039f85b2d48b7893eaea0685c36/desktop/renderer-app/src/tasks/init-register-apps.ts#L4-L19

parallelmedical commented 3 years ago

thanks, i actually just got it working

webpack alias

'dicomViewer': path.join(__dirname, 'src/whiteboardApps/dicom/src/index.tsx'),

then when joining whiteboard rom

let src = () => import('dicomViewer'); const wrapped = async () => { if (typeof src === "function") { const mod = await src(); return "default" in mod ? mod.default : mod; } else { return src; } };

  WindowManager.register({kind: "test", src: wrapped})