|
| 1 | +import { transformExtensionCode } from '../utils/extensionCodeTransformer.js' |
| 2 | + |
1 | 3 | export const useAppStore = defineStore("app", () => { |
2 | 4 | const stores = [] |
3 | 5 |
|
@@ -89,51 +91,10 @@ export const useAppStore = defineStore("app", () => { |
89 | 91 |
|
90 | 92 | if (path.startsWith('blob:')) { |
91 | 93 | const response = await fetch(path) |
92 | | - let code = await response.text() |
93 | | - |
94 | | - code = code.replace( |
95 | | - /import\s+(?:{([^}]+)}|\*\s+as\s+(\w+)|(\w+))\s+from\s+["']vue["'];?/gs, |
96 | | - (match, namedImports, namespaceImport, defaultImport) => { |
97 | | - if (namedImports) { |
98 | | - const converted = namedImports.replace(/\s+as\s+/g, ': ') |
99 | | - return `const {${converted}} = window.__VUE_RUNTIME__;` |
100 | | - } else if (namespaceImport) { |
101 | | - return `const ${namespaceImport} = window.__VUE_RUNTIME__;` |
102 | | - } else if (defaultImport) { |
103 | | - return `const ${defaultImport} = window.__VUE_RUNTIME__;` |
104 | | - } |
105 | | - return match |
106 | | - } |
107 | | - ) |
108 | | - |
109 | | - code = code.replace( |
110 | | - /import\s+(?:{([^}]+)}|\*\s+as\s+(\w+)|(\w+))\s+from\s+["']pinia["'];?/gs, |
111 | | - (match, namedImports, namespaceImport, defaultImport) => { |
112 | | - if (namedImports) { |
113 | | - const converted = namedImports.replace(/\s+as\s+/g, ': ') |
114 | | - return `const {${converted}} = window.__PINIA__;` |
115 | | - } else if (namespaceImport) { |
116 | | - return `const ${namespaceImport} = window.__PINIA__;` |
117 | | - } else if (defaultImport) { |
118 | | - return `const ${defaultImport} = window.__PINIA__;` |
119 | | - } |
120 | | - return match |
121 | | - } |
122 | | - ) |
123 | | - |
124 | | - code = code.replace( |
125 | | - /import\s+[^;]+from\s+["']@geode\/[^"']+["'];?/gs, |
126 | | - (match) => `/* ${match} */ // External dependency - resolved at runtime\n` |
127 | | - ) |
128 | | - |
129 | | - code = code.replace( |
130 | | - /import\s+[^;]+from\s+["']@ogw_[^"']+["'];?/gs, |
131 | | - (match) => `/* ${match} */ // External dependency - resolved at runtime\n` |
132 | | - ) |
133 | | - |
134 | | - console.log('[AppStore] Rewritten extension code preview:', code.substring(0, 800)) |
| 94 | + const code = await response.text() |
| 95 | + const transformedCode = transformExtensionCode(code) |
135 | 96 |
|
136 | | - const newBlob = new Blob([code], { type: 'application/javascript' }) |
| 97 | + const newBlob = new Blob([transformedCode], { type: 'application/javascript' }) |
137 | 98 | finalURL = URL.createObjectURL(newBlob) |
138 | 99 | } |
139 | 100 |
|
|
0 commit comments