ob-plugin.ts 787 B

123456789101112131415161718192021222324252627282930
  1. import type Plugin from '@oceanbase-odc/monaco-plugin-ob';
  2. let plugin: Plugin;
  3. export async function register(): Promise<Plugin> {
  4. window.obMonaco = {
  5. getWorkerUrl: (type: string) => {
  6. switch (type) {
  7. case 'mysql': {
  8. return location.origin + '/_next/static/ob-workers/mysql.js';
  9. }
  10. case 'obmysql': {
  11. return location.origin + '/_next/static/ob-workers/obmysql.js';
  12. }
  13. case 'oboracle': {
  14. return location.origin + '/_next/static/ob-workers/oracle.js';
  15. }
  16. }
  17. return '';
  18. },
  19. };
  20. const module = await import('@oceanbase-odc/monaco-plugin-ob');
  21. const Plugin = module.default;
  22. if (plugin) {
  23. return plugin;
  24. }
  25. plugin = new Plugin();
  26. plugin.setup(['mysql']);
  27. return plugin;
  28. }