Files
toolbox-portal/src/test/fixtures.ts
T

159 lines
4.5 KiB
TypeScript

import type {
ToolboxAppManifest,
ToolboxCatalog,
} from '@add-ideas/toolbox-contract';
export const pdfManifest: ToolboxAppManifest = {
schemaVersion: 1,
id: 'de.add-ideas.pdf-tools',
name: 'PDF Workbench',
version: '0.4.3',
description: 'Page-level PDF operations performed locally in the browser.',
entry: './',
icon: './favicon.svg',
categories: ['documents', 'pdf'],
tags: ['merge', 'split'],
integration: {
contextVersion: 1,
launchModes: ['navigate', 'new-tab'],
embedding: 'unsupported',
},
requirements: {
secureContext: true,
workers: true,
indexedDb: true,
crossOriginIsolated: false,
},
privacy: {
processing: 'local',
fileUploads: false,
telemetry: false,
},
source: {
repository: 'https://git.add-ideas.de/lotobo/pdf-tools',
license: 'AGPL-3.0-only',
},
};
export const xsltManifest: ToolboxAppManifest = {
...pdfManifest,
id: 'de.add-ideas.xslt-tools',
name: 'XSLT Workbench',
version: '0.4.2',
description: 'Transform XML locally with XSLT in the browser.',
icon: './xslt.svg',
categories: ['documents', 'developer'],
tags: ['transform', 'xml'],
source: {
repository: 'https://git.add-ideas.de/lotobo/xslt-tools',
license: 'AGPL-3.0-only',
},
};
export const onenoteManifest: ToolboxAppManifest = {
...pdfManifest,
id: 'de.add-ideas.onenote-tools',
name: 'OneNote Reader',
version: '0.3.3',
description: 'Inspect OneNote packages locally in the browser.',
icon: './onenote.svg',
categories: ['documents', 'notes'],
tags: ['onepkg', 'import'],
source: {
repository: 'https://git.add-ideas.de/lotobo/onenote-tools',
license: 'AGPL-3.0-only',
},
};
export const regexManifest: ToolboxAppManifest = {
...pdfManifest,
id: 'de.add-ideas.regex-tools',
name: 'Regex Tools',
version: '0.4.1',
description:
'Develop, explain, test and apply regular expressions locally in the browser.',
icon: './regex.svg',
categories: ['developer', 'text', 'regex'],
tags: ['regular-expression', 'match', 'replace', 'explain', 'test'],
requirements: {
secureContext: false,
workers: true,
indexedDb: true,
crossOriginIsolated: false,
},
source: {
repository: 'https://git.add-ideas.de/lotobo/regex-tools',
license: 'GPL-3.0-or-later',
},
};
export const svgManifest: ToolboxAppManifest = {
...pdfManifest,
id: 'de.add-ideas.svg-tools',
name: 'SVG Tools',
version: '0.1.0',
description:
'Inspect, edit, optimize and transform SVG documents locally in the browser.',
icon: './favicon.svg',
categories: ['graphics', 'design', 'developer'],
tags: [
'svg',
'vector',
'path',
'xml',
'transform',
'optimize',
'accessibility',
],
requirements: {
secureContext: false,
workers: true,
indexedDb: false,
crossOriginIsolated: false,
topLevelContext: false,
},
source: {
repository: 'https://git.add-ideas.de/lotobo/svg-tools',
license: 'GPL-3.0-or-later',
},
assets: ['./canvas-frame-controller.js'],
};
export const catalogue: ToolboxCatalog = {
schemaVersion: 1,
id: 'de.add-ideas.toolbox',
name: 'add·ideas Toolbox',
home: './',
theme: { mode: 'system', brand: 'add·ideas' },
apps: [
{ manifest: './apps/pdf/toolbox-app.json', enabled: true },
{ manifest: './apps/xslt/toolbox-app.json', enabled: true },
{ manifest: './apps/onenote/toolbox-app.json', enabled: true },
{ manifest: './apps/svg/toolbox-app.json', enabled: true },
],
};
export function catalogueFetch(overrides: Record<string, Response> = {}) {
return async (input: string | URL | Request): Promise<Response> => {
const url = new URL(
input instanceof Request ? input.url : String(input),
document.baseURI
);
const custom = overrides[url.pathname];
if (custom) return custom.clone();
if (url.pathname.endsWith('/toolbox.catalog.json'))
return Response.json(catalogue);
if (url.pathname.endsWith('/apps/pdf/toolbox-app.json'))
return Response.json(pdfManifest);
if (url.pathname.endsWith('/apps/xslt/toolbox-app.json'))
return Response.json(xsltManifest);
if (url.pathname.endsWith('/apps/onenote/toolbox-app.json'))
return Response.json(onenoteManifest);
if (url.pathname.endsWith('/apps/regex/toolbox-app.json'))
return Response.json(regexManifest);
if (url.pathname.endsWith('/apps/svg/toolbox-app.json'))
return Response.json(svgManifest);
return new Response('Not found', { status: 404 });
};
}