chore: remove connectivity probe (example.com) — internet access now via CORS proxy; drop example.com from proxy allowlist; bump 0.1.20
This commit is contained in:
1 parent
79e9ec1128
commit
b42eae810a
3 files changed
+4
-28
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "figma-ai-plugin",
|
||||
"version": "0.1.19",
|
||||
"version": "0.1.20",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@create-figma-plugin/ui": "^4.0.3",
|
||||
|
||||
+1
-17
@@ -3,23 +3,12 @@ import { emit, on, showUI } from '@create-figma-plugin/utilities'
|
||||
// CORS proxy (dev). Figma plugin has origin:null, so direct calls to APIs without
|
||||
// Access-Control-Allow-Origin fail. Route external requests through this proxy, which
|
||||
// adds `Access-Control-Allow-Origin: *`. Target host must be in the proxy allowlist
|
||||
// (api.apinex.bond, apinex.bond, example.com) — no token needed for those.
|
||||
// (api.apinex.bond, apinex.bond) — no token needed for those.
|
||||
const CORS_PROXY = 'https://ai-assistant-fig.dynv6.net/proxy'
|
||||
function viaProxy (target: string): string {
|
||||
return CORS_PROXY + '?url=' + encodeURIComponent(target)
|
||||
}
|
||||
|
||||
// Probe whether the plugin sandbox can reach the public internet.
|
||||
// Used on plugin open (so the user sees network status immediately) and before each model fetch.
|
||||
async function probeConnectivity () {
|
||||
try {
|
||||
const pr = await fetch(viaProxy('https://example.com'))
|
||||
emit('PROBE_RESULT', { msg: 'example.com reachable · status=' + pr.status })
|
||||
} catch (pe) {
|
||||
emit('PROBE_RESULT', { msg: 'example.com UNREACHABLE · ' + (pe != null ? (typeof pe === 'string' ? pe : JSON.stringify(pe)) : 'unknown') })
|
||||
}
|
||||
}
|
||||
|
||||
export default function () {
|
||||
// Глобальный ярлык relaunch в правой панели Figma (команда runAI из manifest.json)
|
||||
figma.root.setRelaunchData({ runAI: '' })
|
||||
@@ -531,8 +520,6 @@ export default function () {
|
||||
emit('MODELS_RESULT', { ok: false, error: 'fetch is not available in the plugin main thread', models: [], status: 0, requestEcho: echo })
|
||||
return
|
||||
}
|
||||
// Diagnostic: can the sandbox reach the public internet at all?
|
||||
await probeConnectivity()
|
||||
const base = String(payload.baseUrl == null ? '' : payload.baseUrl)
|
||||
.replace(/`/g, '') // drop stray markdown backticks
|
||||
.replace(/^@url:\s*/i, '') // drop '@url:' annotation if pasted from chat
|
||||
@@ -586,9 +573,6 @@ export default function () {
|
||||
|
||||
showUI({ width: 380, height: 480, themeColors: true, title: 'AI assistant (MVP)' })
|
||||
|
||||
// On open, proactively probe connectivity so the user sees network status without clicking Fetch.
|
||||
setTimeout(function () { probeConnectivity() }, 600)
|
||||
|
||||
// Restore persisted window placement (saved in clientStorage on the Figma file).
|
||||
// Default when nothing is stored: behave like the Center button (50% viewport, centered).
|
||||
try {
|
||||
|
||||
+2
-10
@@ -30,7 +30,7 @@ const MIN_WINDOW_SIZE = { width: 320, height: 200 }
|
||||
// very high — actual clamp is done by main via clampWindowSize (bounds*zoom).
|
||||
|
||||
// Full plugin version shown in the footer status bar. Keep in sync with package.json "version".
|
||||
const PLUGIN_VERSION = '0.1.19'
|
||||
const PLUGIN_VERSION = '0.1.20'
|
||||
|
||||
const fieldStyle = {
|
||||
display: 'flex',
|
||||
@@ -137,14 +137,6 @@ function SettingsPanel (props: { settings: Settings, setSettings: (s: Settings)
|
||||
return dispose
|
||||
}, [])
|
||||
|
||||
useEffect(function () {
|
||||
const dispose = on('PROBE_RESULT', function (p: { msg: string }) {
|
||||
setFetching(false)
|
||||
logEvent('PROBE: ' + p.msg)
|
||||
})
|
||||
return dispose
|
||||
}, [])
|
||||
|
||||
function patch (p: Partial<ProviderConfig>) {
|
||||
if (provider == null) return
|
||||
setSettings({
|
||||
@@ -608,7 +600,7 @@ function Plugin () {
|
||||
? <SettingsPanel settings={settings} setSettings={setSettings} logEvent={logEvent} fetching={fetching} setFetching={setFetching} />
|
||||
: <Muted>Loading…</Muted>}
|
||||
</main>
|
||||
{/* Live log — shows the actual request flow (PROBE / FETCH / RESULT) from main.ts */}
|
||||
{/* Live log — shows the actual request flow (FETCH / RESULT) from main.ts */}
|
||||
<div style={{ flex: '0 0 auto', maxHeight: '140px', overflow: 'auto', background: 'var(--figma-color-bg-secondary, #1e1e1e)', borderTop: '1px solid var(--figma-color-border)', padding: 'var(--space-4)', margin: 0 }}>
|
||||
<Text style={{ fontSize: '10px', fontWeight: 600, display: 'block', marginBottom: 4 }}>Request log</Text>
|
||||
{log.length === 0
|
||||
|
||||
Reference in new issue
Block a user