@anionex/dsh-vision-toolkit 0.1.32 → 0.1.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.i18n.yaml +2 -2
- package/README.md +53 -158
- package/README.zh.md +58 -166
- package/assets/upstream/README.md +4 -2
- package/assets/upstream/focus-hint-comparison-1.webp +0 -0
- package/assets/upstream/focus-hint-comparison-2.webp +0 -0
- package/assets/upstream/ui-fast-restore-reference.webp +0 -0
- package/assets/upstream/ui-fast-restore-result.webp +0 -0
- package/docs/python-runtime.i18n.yaml +6 -0
- package/docs/python-runtime.md +75 -0
- package/docs/python-runtime.zh.md +75 -0
- package/lib/client.js +270 -4
- package/lib/client.js.map +1 -1
- package/lib/config.js +2 -0
- package/lib/config.js.map +1 -1
- package/lib/image-input-variants.js +18 -5
- package/lib/image-input-variants.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/runtime-manager.js +10 -3
- package/lib/runtime-manager.js.map +1 -1
- package/lib/types/client/display-config.d.ts +24 -0
- package/lib/types/client/display-config.d.ts.map +1 -0
- package/lib/types/client/index.d.ts +10 -0
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/model-variants-hider.d.ts +40 -0
- package/lib/types/client/model-variants-hider.d.ts.map +1 -0
- package/lib/types/client/paste-images.d.ts.map +1 -1
- package/lib/types/config.d.ts +10 -0
- package/lib/types/config.d.ts.map +1 -1
- package/lib/types/image-input-variants.d.ts +2 -1
- package/lib/types/image-input-variants.d.ts.map +1 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/runtime-manager.d.ts.map +1 -1
- package/lib/types/web.d.ts +17 -1
- package/lib/types/web.d.ts.map +1 -1
- package/lib/web.js +36 -1
- package/lib/web.js.map +1 -1
- package/package.json +1 -1
- package/src/client/display-config.ts +62 -0
- package/src/client/index.tsx +44 -2
- package/src/client/model-variants-hider.ts +159 -0
- package/src/client/paste-images.tsx +5 -1
- package/src/config.ts +12 -0
- package/src/image-input-variants.ts +16 -3
- package/src/index.ts +1 -0
- package/src/runtime-manager.ts +10 -2
- package/src/web.ts +39 -0
- package/assets/upstream/image-qa.webp +0 -0
- package/assets/upstream/screenshot-debugging.webp +0 -0
package/src/web.ts
CHANGED
|
@@ -46,6 +46,9 @@ import { sameOriginPost, sameOriginRequest } from './web-request.ts'
|
|
|
46
46
|
/** Exact route used by the browser Settings page. */
|
|
47
47
|
export const SETTINGS_ROUTE = '/_dsh/vision-toolkit/settings'
|
|
48
48
|
|
|
49
|
+
/** Same-origin route used by the browser client to read display-mode flags. */
|
|
50
|
+
export const DISPLAY_CONFIG_ROUTE = '/_dsh/vision-toolkit/display-config'
|
|
51
|
+
|
|
49
52
|
/** Public Settings snapshot; credential values are deliberately impossible here. */
|
|
50
53
|
export interface VisionToolkitSettingsSnapshot {
|
|
51
54
|
schemaVersion: 1
|
|
@@ -504,6 +507,34 @@ export function createPastePolicyHandler(
|
|
|
504
507
|
}
|
|
505
508
|
}
|
|
506
509
|
|
|
510
|
+
/**
|
|
511
|
+
* Same-origin display-config handler: exposes whether transparent routing is
|
|
512
|
+
* active. The paste integration uses it to choose its notice text; the model
|
|
513
|
+
* selector hides upstream twins synchronously from DOM display names and does
|
|
514
|
+
* not depend on this route.
|
|
515
|
+
* @param getDisplayConfig - resolves the current display-mode flags.
|
|
516
|
+
* @returns the HTTP handler.
|
|
517
|
+
*/
|
|
518
|
+
export function createDisplayConfigHandler(
|
|
519
|
+
getDisplayConfig: () => { hidden: boolean },
|
|
520
|
+
): (req: IncomingMessage, res: ServerResponse) => void {
|
|
521
|
+
return (req, res) => {
|
|
522
|
+
try {
|
|
523
|
+
if (req.method !== 'GET') {
|
|
524
|
+
requestError(res, 405, 'method-not-allowed', 'Use GET')
|
|
525
|
+
return
|
|
526
|
+
}
|
|
527
|
+
if (!sameOriginRequest(req)) {
|
|
528
|
+
requestError(res, 403, 'origin-rejected', 'The request must originate from this DSH Web application')
|
|
529
|
+
return
|
|
530
|
+
}
|
|
531
|
+
responseJson(res, 200, { ok: true, value: getDisplayConfig() })
|
|
532
|
+
} catch (error) {
|
|
533
|
+
requestError(res, 500, 'display-config-failed', publicMessage(error))
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
507
538
|
/**
|
|
508
539
|
* Attach optional Web routes whenever a webServer service is present.
|
|
509
540
|
* @param ctx - plugin context owning route effects.
|
|
@@ -511,6 +542,7 @@ export function createPastePolicyHandler(
|
|
|
511
542
|
* @param artifacts - signed Artifact handler.
|
|
512
543
|
* @param pastedImages - pasted-image workspace handler.
|
|
513
544
|
* @param pastePolicy - paste-policy verdict resolver (sessionId, selection, modelLabel).
|
|
545
|
+
* @param getDisplayConfig - resolves display-mode flags for the browser client.
|
|
514
546
|
*/
|
|
515
547
|
export function installVisionToolkitWeb(
|
|
516
548
|
ctx: Context,
|
|
@@ -518,6 +550,7 @@ export function installVisionToolkitWeb(
|
|
|
518
550
|
artifacts: ArtifactAccessController,
|
|
519
551
|
pastedImages: PastedImageBackend,
|
|
520
552
|
pastePolicy: (sessionId: string, selection?: PasteSelectionQuery, modelLabel?: string) => Promise<PasteVerdict>,
|
|
553
|
+
getDisplayConfig: () => { hidden: boolean },
|
|
521
554
|
): void {
|
|
522
555
|
ctx.inject(['webServer'], (webCtx) => {
|
|
523
556
|
webCtx.effect(() => {
|
|
@@ -543,7 +576,13 @@ export function installVisionToolkitWeb(
|
|
|
543
576
|
path: PASTE_POLICY_ROUTE,
|
|
544
577
|
handler: createPastePolicyHandler(pastePolicy),
|
|
545
578
|
})
|
|
579
|
+
const disposeDisplayConfig = webCtx.webServer.register({
|
|
580
|
+
kind: 'exact',
|
|
581
|
+
path: DISPLAY_CONFIG_ROUTE,
|
|
582
|
+
handler: createDisplayConfigHandler(getDisplayConfig),
|
|
583
|
+
})
|
|
546
584
|
return () => {
|
|
585
|
+
disposeDisplayConfig()
|
|
547
586
|
disposePastePolicy()
|
|
548
587
|
disposePasteImages()
|
|
549
588
|
disposeSettings()
|
|
Binary file
|
|
Binary file
|