expxagents 0.17.17 → 0.18.1
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/dist/cli/src/commands/info.d.ts +2 -0
- package/dist/cli/src/commands/info.js +28 -0
- package/dist/cli/src/commands/ingest.d.ts +5 -0
- package/dist/cli/src/commands/ingest.js +96 -0
- package/dist/cli/src/commands/knowledge.d.ts +4 -0
- package/dist/cli/src/commands/knowledge.js +80 -0
- package/dist/cli/src/commands/login.d.ts +2 -0
- package/dist/cli/src/commands/login.js +41 -0
- package/dist/cli/src/commands/logout.d.ts +2 -0
- package/dist/cli/src/commands/logout.js +8 -0
- package/dist/cli/src/commands/publish.d.ts +2 -0
- package/dist/cli/src/commands/publish.js +24 -0
- package/dist/cli/src/commands/registry-install.d.ts +2 -0
- package/dist/cli/src/commands/registry-install.js +28 -0
- package/dist/cli/src/commands/search.d.ts +2 -0
- package/dist/cli/src/commands/search.js +35 -0
- package/dist/cli/src/commands/server.js +13 -0
- package/dist/cli/src/commands/whoami.d.ts +2 -0
- package/dist/cli/src/commands/whoami.js +23 -0
- package/dist/cli/src/index.js +29 -0
- package/dist/dashboard/assets/{BufferResource-DoD0ZP17.js → BufferResource-CLv7EZ_5.js} +1 -1
- package/dist/dashboard/assets/{CanvasRenderer-CtcL92QP.js → CanvasRenderer-B6OT6Eju.js} +1 -1
- package/dist/dashboard/assets/{JarvisView-DPhFsNKf.js → JarvisView-DY_DfOO_.js} +1 -1
- package/dist/dashboard/assets/{RenderTargetSystem-BeKLdFHC.js → RenderTargetSystem-oHTzuh-F.js} +1 -1
- package/dist/dashboard/assets/{ThreeBackground-Blgzt6n0.js → ThreeBackground-DNuijkpe.js} +1 -1
- package/dist/dashboard/assets/{WebGLRenderer-4T1gBRLJ.js → WebGLRenderer-Cbi_mVTn.js} +1 -1
- package/dist/dashboard/assets/{WebGPURenderer-gVQWm7HA.js → WebGPURenderer-Cu04nEL8.js} +1 -1
- package/dist/dashboard/assets/{browserAll-B4n_3XXz.js → browserAll-DtIBJ0M2.js} +1 -1
- package/dist/dashboard/assets/index-C_t8dRMU.js +1155 -0
- package/dist/dashboard/assets/{webworkerAll-MnVkt-yw.js → webworkerAll-zhS3J6-M.js} +1 -1
- package/dist/dashboard/index.html +1 -1
- package/dist/server/api/chat-api-routes.d.ts +4 -0
- package/dist/server/api/chat-api-routes.d.ts.map +1 -0
- package/dist/server/api/chat-api-routes.js +28 -0
- package/dist/server/api/chat-api-routes.js.map +1 -0
- package/dist/server/api/knowledge-routes.d.ts +8 -0
- package/dist/server/api/knowledge-routes.d.ts.map +1 -0
- package/dist/server/api/knowledge-routes.js +82 -0
- package/dist/server/api/knowledge-routes.js.map +1 -0
- package/dist/server/api/registry-routes.d.ts +7 -0
- package/dist/server/api/registry-routes.d.ts.map +1 -0
- package/dist/server/api/registry-routes.js +51 -0
- package/dist/server/api/registry-routes.js.map +1 -0
- package/dist/server/api/system-routes.d.ts +2 -0
- package/dist/server/api/system-routes.d.ts.map +1 -1
- package/dist/server/api/system-routes.js +94 -0
- package/dist/server/api/system-routes.js.map +1 -1
- package/dist/server/app.d.ts.map +1 -1
- package/dist/server/app.js +30 -13
- package/dist/server/app.js.map +1 -1
- package/dist/server/bridge/__tests__/chat-handler.test.js +1 -0
- package/dist/server/bridge/__tests__/chat-handler.test.js.map +1 -1
- package/dist/server/bridge/__tests__/chat-integration.test.js +1 -0
- package/dist/server/bridge/__tests__/chat-integration.test.js.map +1 -1
- package/dist/server/bridge/chat-handler.d.ts +3 -2
- package/dist/server/bridge/chat-handler.d.ts.map +1 -1
- package/dist/server/bridge/chat-handler.js +22 -2
- package/dist/server/bridge/chat-handler.js.map +1 -1
- package/dist/server/bridge/claude-bridge.d.ts +3 -24
- package/dist/server/bridge/claude-bridge.d.ts.map +1 -1
- package/dist/server/bridge/claude-bridge.js +9 -0
- package/dist/server/bridge/claude-bridge.js.map +1 -1
- package/dist/server/bridge/engine-manager.d.ts +13 -0
- package/dist/server/bridge/engine-manager.d.ts.map +1 -0
- package/dist/server/bridge/engine-manager.js +54 -0
- package/dist/server/bridge/engine-manager.js.map +1 -0
- package/dist/server/bridge/engine.d.ts +37 -0
- package/dist/server/bridge/engine.d.ts.map +1 -0
- package/dist/server/bridge/engine.js +2 -0
- package/dist/server/bridge/engine.js.map +1 -0
- package/dist/server/bridge/factory.d.ts +4 -0
- package/dist/server/bridge/factory.d.ts.map +1 -0
- package/dist/server/bridge/factory.js +58 -0
- package/dist/server/bridge/factory.js.map +1 -0
- package/dist/server/bridge/opencode-bridge.d.ts +21 -0
- package/dist/server/bridge/opencode-bridge.d.ts.map +1 -0
- package/dist/server/bridge/opencode-bridge.js +144 -0
- package/dist/server/bridge/opencode-bridge.js.map +1 -0
- package/dist/server/config/engine-config.d.ts +4 -0
- package/dist/server/config/engine-config.d.ts.map +1 -0
- package/dist/server/config/engine-config.js +24 -0
- package/dist/server/config/engine-config.js.map +1 -0
- package/dist/server/config.d.ts +1 -0
- package/dist/server/config.d.ts.map +1 -1
- package/dist/server/config.js +3 -0
- package/dist/server/config.js.map +1 -1
- package/dist/server/index.js +13 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/mcp/expxagents-mcp.d.ts +2 -0
- package/dist/server/mcp/expxagents-mcp.d.ts.map +1 -0
- package/dist/server/mcp/expxagents-mcp.js +230 -0
- package/dist/server/mcp/expxagents-mcp.js.map +1 -0
- package/dist/server/scheduler/job-runner.d.ts +9 -2
- package/dist/server/scheduler/job-runner.d.ts.map +1 -1
- package/dist/server/scheduler/job-runner.js +41 -0
- package/dist/server/scheduler/job-runner.js.map +1 -1
- package/dist/server/services/squad-registry.d.ts +23 -0
- package/dist/server/services/squad-registry.d.ts.map +1 -0
- package/dist/server/services/squad-registry.js +91 -0
- package/dist/server/services/squad-registry.js.map +1 -0
- package/dist/server/ws/ws-handler.d.ts +1 -0
- package/dist/server/ws/ws-handler.d.ts.map +1 -1
- package/dist/server/ws/ws-handler.js +2 -1
- package/dist/server/ws/ws-handler.js.map +1 -1
- package/package.json +3 -2
- package/dist/dashboard/assets/index-D7CI6lgH.js +0 -1023
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { RegistryClient, readCredentials } from '@expxagents/registry-client';
|
|
3
|
+
export const infoCommand = new Command('info')
|
|
4
|
+
.description('Show squad details from the registry')
|
|
5
|
+
.argument('<name>', 'Squad name (@scope/name)')
|
|
6
|
+
.action(async (name) => {
|
|
7
|
+
const creds = readCredentials();
|
|
8
|
+
const client = new RegistryClient({
|
|
9
|
+
registryUrl: creds?.registryUrl || 'https://registry.expxagents.dev',
|
|
10
|
+
});
|
|
11
|
+
try {
|
|
12
|
+
const squad = await client.getSquad(name);
|
|
13
|
+
console.log(`${squad.icon || ''} ${squad.fullName}`);
|
|
14
|
+
console.log(` ${squad.description || 'No description'}\n`);
|
|
15
|
+
console.log(` Latest: ${squad.latestVersion || 'none'}`);
|
|
16
|
+
console.log(` Versions: ${squad.versions.join(', ')}`);
|
|
17
|
+
console.log(` Category: ${squad.category || 'none'}`);
|
|
18
|
+
console.log(` Tags: ${squad.tags.join(', ') || 'none'}`);
|
|
19
|
+
console.log(` Downloads: ${squad.downloads}`);
|
|
20
|
+
console.log(` Rating: ${squad.rating > 0 ? `${squad.rating.toFixed(1)} (${squad.ratingCount} votes)` : 'none'}`);
|
|
21
|
+
console.log(` Author: @${squad.scope}`);
|
|
22
|
+
console.log(` Visibility: ${squad.visibility}`);
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
console.error(`\u2717 ${err.message}`);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
export async function ingestCommand(targetPath, options) {
|
|
4
|
+
const serverUrl = process.env.EXPX_SERVER_URL ?? `http://localhost:${process.env.PORT ?? '3001'}`;
|
|
5
|
+
const apiKey = process.env.EXPX_API_KEY ?? '';
|
|
6
|
+
const resolved = path.resolve(targetPath);
|
|
7
|
+
if (!fs.existsSync(resolved)) {
|
|
8
|
+
console.error(`Path not found: ${resolved}`);
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
const files = fs.statSync(resolved).isDirectory()
|
|
12
|
+
? walkFiles(resolved)
|
|
13
|
+
: [resolved];
|
|
14
|
+
console.log(`Ingesting ${files.length} file(s)...`);
|
|
15
|
+
let success = 0;
|
|
16
|
+
let skipped = 0;
|
|
17
|
+
let failed = 0;
|
|
18
|
+
for (const file of files) {
|
|
19
|
+
try {
|
|
20
|
+
const content = fs.readFileSync(file, 'utf-8');
|
|
21
|
+
const title = path.basename(file);
|
|
22
|
+
const tags = options.tags?.split(',').map((t) => t.trim()) ?? undefined;
|
|
23
|
+
const response = await fetch(`${serverUrl}/api/knowledge/ingest-text`, {
|
|
24
|
+
method: 'POST',
|
|
25
|
+
headers: {
|
|
26
|
+
'Content-Type': 'application/json',
|
|
27
|
+
Authorization: `Bearer ${apiKey}`,
|
|
28
|
+
},
|
|
29
|
+
body: JSON.stringify({ content, title, squad_code: options.squad, tags }),
|
|
30
|
+
});
|
|
31
|
+
if (!response.ok) {
|
|
32
|
+
console.error(` FAIL ${file}: ${response.status}`);
|
|
33
|
+
failed++;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const result = (await response.json());
|
|
37
|
+
if (result.skipped) {
|
|
38
|
+
console.log(` SKIP ${file} (unchanged)`);
|
|
39
|
+
skipped++;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
console.log(` OK ${file} (${result.chunks_count} chunks)`);
|
|
43
|
+
success++;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
console.error(` FAIL ${file}: ${err.message}`);
|
|
48
|
+
failed++;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
console.log(`\nDone: ${success} ingested, ${skipped} skipped, ${failed} failed`);
|
|
52
|
+
if (options.watch) {
|
|
53
|
+
console.log(`\nWatching ${resolved} for changes... (Ctrl+C to stop)`);
|
|
54
|
+
const chokidar = await import('chokidar');
|
|
55
|
+
const watcher = chokidar.watch(resolved, { ignoreInitial: true, depth: 5 });
|
|
56
|
+
watcher.on('add', (fp) => handleWatchEvent(fp, serverUrl, apiKey, options));
|
|
57
|
+
watcher.on('change', (fp) => handleWatchEvent(fp, serverUrl, apiKey, options));
|
|
58
|
+
process.on('SIGINT', () => { watcher.close(); process.exit(0); });
|
|
59
|
+
await new Promise(() => { });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async function handleWatchEvent(file, serverUrl, apiKey, options) {
|
|
63
|
+
const ext = path.extname(file).toLowerCase();
|
|
64
|
+
const SUPPORTED = new Set(['.md', '.txt', '.json', '.yaml', '.yml']);
|
|
65
|
+
if (!SUPPORTED.has(ext))
|
|
66
|
+
return;
|
|
67
|
+
try {
|
|
68
|
+
const content = fs.readFileSync(file, 'utf-8');
|
|
69
|
+
const response = await fetch(`${serverUrl}/api/knowledge/ingest-text`, {
|
|
70
|
+
method: 'POST',
|
|
71
|
+
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${apiKey}` },
|
|
72
|
+
body: JSON.stringify({ content, title: path.basename(file), squad_code: options.squad }),
|
|
73
|
+
});
|
|
74
|
+
const result = (await response.json());
|
|
75
|
+
console.log(` ${result.skipped ? 'SKIP' : 'OK'} ${file}`);
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
console.error(` FAIL ${file}: ${err.message}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function walkFiles(dir) {
|
|
82
|
+
const SUPPORTED = new Set(['.md', '.txt', '.json', '.yaml', '.yml']);
|
|
83
|
+
const results = [];
|
|
84
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
85
|
+
if (entry.name.startsWith('.') || entry.name.startsWith('_'))
|
|
86
|
+
continue;
|
|
87
|
+
const full = path.join(dir, entry.name);
|
|
88
|
+
if (entry.isDirectory()) {
|
|
89
|
+
results.push(...walkFiles(full));
|
|
90
|
+
}
|
|
91
|
+
else if (SUPPORTED.has(path.extname(entry.name).toLowerCase())) {
|
|
92
|
+
results.push(full);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return results;
|
|
96
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export async function knowledgeCommand(action, args, options) {
|
|
2
|
+
const serverUrl = process.env.EXPX_SERVER_URL ?? `http://localhost:${process.env.PORT ?? '3001'}`;
|
|
3
|
+
const apiKey = process.env.EXPX_API_KEY ?? '';
|
|
4
|
+
const headers = { Authorization: `Bearer ${apiKey}` };
|
|
5
|
+
switch (action) {
|
|
6
|
+
case 'search': {
|
|
7
|
+
const query = args.join(' ');
|
|
8
|
+
if (!query) {
|
|
9
|
+
console.error('Usage: expxagents knowledge search "query"');
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
const params = new URLSearchParams({ q: query, mode: options.mode ?? 'auto' });
|
|
13
|
+
if (options.squad)
|
|
14
|
+
params.set('squad', options.squad);
|
|
15
|
+
const res = await fetch(`${serverUrl}/api/knowledge/query?${params}`, { headers });
|
|
16
|
+
const data = (await res.json());
|
|
17
|
+
for (const r of data.results ?? []) {
|
|
18
|
+
console.log(`[${r.score.toFixed(3)}] ${r.source.document_title}`);
|
|
19
|
+
console.log(` ${r.content.slice(0, 200)}${r.content.length > 200 ? '...' : ''}`);
|
|
20
|
+
console.log();
|
|
21
|
+
}
|
|
22
|
+
if (!data.results?.length)
|
|
23
|
+
console.log('No results found.');
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
case 'stats': {
|
|
27
|
+
const res = await fetch(`${serverUrl}/api/knowledge/stats`, { headers });
|
|
28
|
+
const stats = (await res.json());
|
|
29
|
+
console.log(`Documents: ${stats.documents}`);
|
|
30
|
+
console.log(`Chunks: ${stats.chunks}`);
|
|
31
|
+
console.log(`Entities: ${stats.entities}`);
|
|
32
|
+
console.log(`Relations: ${stats.relations}`);
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
case 'list': {
|
|
36
|
+
const res = await fetch(`${serverUrl}/api/knowledge/documents`, { headers });
|
|
37
|
+
const data = (await res.json());
|
|
38
|
+
for (const doc of data.documents ?? []) {
|
|
39
|
+
console.log(`${doc.id} ${doc.title} [${doc.source_type}] ${doc.ingested_at}`);
|
|
40
|
+
}
|
|
41
|
+
if (!data.documents?.length)
|
|
42
|
+
console.log('No documents found.');
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
case 'delete': {
|
|
46
|
+
const id = args[0];
|
|
47
|
+
if (!id) {
|
|
48
|
+
console.error('Usage: expxagents knowledge delete <doc-id>');
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
const res = await fetch(`${serverUrl}/api/knowledge/documents/${id}`, { method: 'DELETE', headers });
|
|
52
|
+
if (res.ok)
|
|
53
|
+
console.log(`Deleted document ${id}`);
|
|
54
|
+
else
|
|
55
|
+
console.error(`Failed to delete: ${res.status}`);
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
case 'rebuild': {
|
|
59
|
+
console.log('Rebuilding knowledge base (re-extracting failed documents)...');
|
|
60
|
+
const res = await fetch(`${serverUrl}/api/knowledge/documents`, { headers });
|
|
61
|
+
const data = (await res.json());
|
|
62
|
+
const failed = (data.documents ?? []).filter((d) => d.extraction_status === 'failed');
|
|
63
|
+
console.log(`Found ${failed.length} failed documents to re-process.`);
|
|
64
|
+
for (const doc of failed) {
|
|
65
|
+
if (doc.source_path) {
|
|
66
|
+
await fetch(`${serverUrl}/api/knowledge/ingest-text`, {
|
|
67
|
+
method: 'POST',
|
|
68
|
+
headers: { ...headers, 'Content-Type': 'application/json' },
|
|
69
|
+
body: JSON.stringify({ content: '(rebuild)', title: doc.title }),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
console.log('Rebuild complete.');
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
default:
|
|
77
|
+
console.error(`Unknown action: ${action}. Available: search, stats, list, delete, rebuild`);
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { RegistryClient, writeCredentials } from '@expxagents/registry-client';
|
|
3
|
+
const DEFAULT_REGISTRY = 'https://registry.expxagents.dev';
|
|
4
|
+
export const loginCommand = new Command('login')
|
|
5
|
+
.description('Authenticate with the ExpxAgents registry')
|
|
6
|
+
.option('--registry <url>', 'Registry URL', DEFAULT_REGISTRY)
|
|
7
|
+
.option('--scope <scope>', 'Author scope')
|
|
8
|
+
.option('--name <name>', 'Author display name')
|
|
9
|
+
.option('--api-key <key>', 'Existing API key (skip registration)')
|
|
10
|
+
.action(async (options) => {
|
|
11
|
+
const registryUrl = options.registry;
|
|
12
|
+
if (options.apiKey) {
|
|
13
|
+
const client = new RegistryClient({ registryUrl, apiKey: options.apiKey });
|
|
14
|
+
try {
|
|
15
|
+
const { author } = await client.whoami();
|
|
16
|
+
writeCredentials({ apiKey: options.apiKey, registryUrl });
|
|
17
|
+
console.log(`\u2713 Logged in as @${author.scope}`);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
console.error('\u2717 Invalid API key');
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (!options.scope) {
|
|
26
|
+
console.error('--scope is required for registration. Example: expxagents login --scope my-org');
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
const client = new RegistryClient({ registryUrl });
|
|
30
|
+
try {
|
|
31
|
+
const result = await client.register(options.scope, options.name);
|
|
32
|
+
writeCredentials({ apiKey: result.apiKey, registryUrl });
|
|
33
|
+
console.log(`\u2713 Registered as @${result.author.scope}`);
|
|
34
|
+
console.log(` API Key: ${result.apiKey}`);
|
|
35
|
+
console.log(' \u26a0 Save this key \u2014 it will not be shown again.');
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
console.error(`\u2717 Registration failed: ${err.message}`);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { removeCredentials } from '@expxagents/registry-client';
|
|
3
|
+
export const logoutCommand = new Command('logout')
|
|
4
|
+
.description('Remove registry credentials')
|
|
5
|
+
.action(() => {
|
|
6
|
+
removeCredentials();
|
|
7
|
+
console.log('\u2713 Logged out');
|
|
8
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { RegistryClient, readCredentials } from '@expxagents/registry-client';
|
|
4
|
+
export const publishCommand = new Command('publish')
|
|
5
|
+
.description('Publish a squad to the registry')
|
|
6
|
+
.argument('[dir]', 'Squad directory', '.')
|
|
7
|
+
.option('--version <version>', 'Override version')
|
|
8
|
+
.action(async (dir, options) => {
|
|
9
|
+
const creds = readCredentials();
|
|
10
|
+
if (!creds) {
|
|
11
|
+
console.error('Not logged in. Run: expxagents login');
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
const squadDir = resolve(dir);
|
|
15
|
+
const client = new RegistryClient({ registryUrl: creds.registryUrl, apiKey: creds.apiKey });
|
|
16
|
+
try {
|
|
17
|
+
const result = await client.publish(squadDir, options.version);
|
|
18
|
+
console.log(`\u2713 Published ${result.squad?.fullName || 'squad'}@${result.version?.version}`);
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
console.error(`\u2717 Publish failed: ${err.message}`);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { RegistryClient, readCredentials } from '@expxagents/registry-client';
|
|
4
|
+
export const registryInstallCommand = new Command('add')
|
|
5
|
+
.description('Install a squad from the global registry (@scope/name)')
|
|
6
|
+
.argument('<name>', 'Squad name (@scope/name)')
|
|
7
|
+
.option('--version <version>', 'Version or range', 'latest')
|
|
8
|
+
.option('--dir <dir>', 'Target squads directory', './squads')
|
|
9
|
+
.action(async (name, options) => {
|
|
10
|
+
const creds = readCredentials();
|
|
11
|
+
const client = new RegistryClient({
|
|
12
|
+
registryUrl: creds?.registryUrl || 'https://registry.expxagents.dev',
|
|
13
|
+
apiKey: creds?.apiKey,
|
|
14
|
+
});
|
|
15
|
+
const targetDir = resolve(options.dir);
|
|
16
|
+
try {
|
|
17
|
+
console.log(`Installing ${name}@${options.version}...`);
|
|
18
|
+
const result = await client.installWithDeps(name, options.version, targetDir);
|
|
19
|
+
console.log(`\u2713 Installed ${result.root}`);
|
|
20
|
+
for (const dep of result.installed) {
|
|
21
|
+
console.log(` + ${dep.fullName}@${dep.version}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
console.error(`\u2717 Install failed: ${err.message}`);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { RegistryClient, readCredentials } from '@expxagents/registry-client';
|
|
3
|
+
export const searchCommand = new Command('search')
|
|
4
|
+
.description('Search squads in the registry')
|
|
5
|
+
.argument('<query>', 'Search query')
|
|
6
|
+
.option('--category <cat>', 'Filter by category')
|
|
7
|
+
.option('--limit <n>', 'Max results', '10')
|
|
8
|
+
.action(async (query, options) => {
|
|
9
|
+
const creds = readCredentials();
|
|
10
|
+
const client = new RegistryClient({
|
|
11
|
+
registryUrl: creds?.registryUrl || 'https://registry.expxagents.dev',
|
|
12
|
+
});
|
|
13
|
+
try {
|
|
14
|
+
const result = await client.search({
|
|
15
|
+
q: query,
|
|
16
|
+
category: options.category,
|
|
17
|
+
limit: parseInt(options.limit),
|
|
18
|
+
});
|
|
19
|
+
if (result.squads.length === 0) {
|
|
20
|
+
console.log('No squads found.');
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
console.log(`Found ${result.total} squad(s):\n`);
|
|
24
|
+
for (const squad of result.squads) {
|
|
25
|
+
const stars = squad.rating > 0 ? ` \u2605${squad.rating.toFixed(1)}` : '';
|
|
26
|
+
console.log(` ${squad.fullName}${stars}`);
|
|
27
|
+
console.log(` ${squad.description || 'No description'}`);
|
|
28
|
+
console.log(` v${squad.latestVersion || '?'} | \u2193${squad.downloads}\n`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
console.error(`\u2717 Search failed: ${err.message}`);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
@@ -3,6 +3,16 @@ import path from 'path';
|
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import { resolveServerPaths } from '../utils/server-paths.js';
|
|
5
5
|
import { findPackageRoot } from '../utils/config.js';
|
|
6
|
+
function getEngineFromFile(cwd) {
|
|
7
|
+
const engineFile = path.join(cwd, '.engine');
|
|
8
|
+
if (fs.existsSync(engineFile)) {
|
|
9
|
+
const content = fs.readFileSync(engineFile, 'utf-8').trim();
|
|
10
|
+
if (['claude-code', 'opencode', 'auto'].includes(content)) {
|
|
11
|
+
return content;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
6
16
|
export async function serverCommand(options = {}) {
|
|
7
17
|
const userProjectDir = process.cwd();
|
|
8
18
|
const port = process.env.PORT ?? '3001';
|
|
@@ -16,6 +26,8 @@ export async function serverCommand(options = {}) {
|
|
|
16
26
|
pkgVersion = pkg.version ?? '0.0.0';
|
|
17
27
|
}
|
|
18
28
|
catch { /* ignore */ }
|
|
29
|
+
// Read engine from .engine file (for engine switching)
|
|
30
|
+
const engineFromFile = getEngineFromFile(userProjectDir);
|
|
19
31
|
console.log(`Starting ExpxAgents server v${pkgVersion}...`);
|
|
20
32
|
const child = spawn('node', [serverEntry], {
|
|
21
33
|
cwd: userProjectDir,
|
|
@@ -29,6 +41,7 @@ export async function serverCommand(options = {}) {
|
|
|
29
41
|
DOTENV_PATH: path.join(userProjectDir, '.env'),
|
|
30
42
|
PORT: port,
|
|
31
43
|
EXPXAGENTS_VERSION: pkgVersion,
|
|
44
|
+
...(engineFromFile ? { AGENT_ENGINE: engineFromFile } : {}),
|
|
32
45
|
},
|
|
33
46
|
});
|
|
34
47
|
child.on('error', (err) => {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { RegistryClient, readCredentials } from '@expxagents/registry-client';
|
|
3
|
+
export const whoamiCommand = new Command('whoami')
|
|
4
|
+
.description('Show current registry identity')
|
|
5
|
+
.action(async () => {
|
|
6
|
+
const creds = readCredentials();
|
|
7
|
+
if (!creds) {
|
|
8
|
+
console.error('Not logged in. Run: expxagents login');
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
const client = new RegistryClient({ registryUrl: creds.registryUrl, apiKey: creds.apiKey });
|
|
12
|
+
try {
|
|
13
|
+
const { author } = await client.whoami();
|
|
14
|
+
console.log(`@${author.scope}`);
|
|
15
|
+
if (author.name)
|
|
16
|
+
console.log(` Name: ${author.name}`);
|
|
17
|
+
console.log(` Registry: ${creds.registryUrl}`);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
console.error('\u2717 Invalid credentials. Run: expxagents login');
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
});
|
package/dist/cli/src/index.js
CHANGED
|
@@ -14,6 +14,15 @@ import { virtualOfficeCommand } from './commands/virtual-office.js';
|
|
|
14
14
|
import { jarvisCommand } from './commands/jarvis.js';
|
|
15
15
|
import { schedulerCommand } from './commands/scheduler.js';
|
|
16
16
|
import { reorganizeCommand } from './commands/reorganize.js';
|
|
17
|
+
import { ingestCommand } from './commands/ingest.js';
|
|
18
|
+
import { knowledgeCommand } from './commands/knowledge.js';
|
|
19
|
+
import { loginCommand } from './commands/login.js';
|
|
20
|
+
import { logoutCommand } from './commands/logout.js';
|
|
21
|
+
import { whoamiCommand } from './commands/whoami.js';
|
|
22
|
+
import { publishCommand } from './commands/publish.js';
|
|
23
|
+
import { registryInstallCommand } from './commands/registry-install.js';
|
|
24
|
+
import { searchCommand } from './commands/search.js';
|
|
25
|
+
import { infoCommand } from './commands/info.js';
|
|
17
26
|
import { findPackageRoot } from './utils/config.js';
|
|
18
27
|
function getVersion() {
|
|
19
28
|
try {
|
|
@@ -85,4 +94,24 @@ program
|
|
|
85
94
|
.description('Open Jarvis voice assistant in browser')
|
|
86
95
|
.action(jarvisCommand);
|
|
87
96
|
program.addCommand(schedulerCommand());
|
|
97
|
+
program
|
|
98
|
+
.command('ingest <path>')
|
|
99
|
+
.description('Ingest documents into the knowledge base')
|
|
100
|
+
.option('--squad <code>', 'Associate with a squad')
|
|
101
|
+
.option('--tags <tags>', 'Comma-separated tags')
|
|
102
|
+
.option('--watch', 'Watch for changes and auto-ingest')
|
|
103
|
+
.action((targetPath, options) => ingestCommand(targetPath, options));
|
|
104
|
+
program
|
|
105
|
+
.command('knowledge <action> [args...]')
|
|
106
|
+
.description('Query and manage the knowledge base (search, stats, list, delete, rebuild)')
|
|
107
|
+
.option('--mode <mode>', 'Query mode: search, graph, auto', 'auto')
|
|
108
|
+
.option('--squad <code>', 'Filter by squad')
|
|
109
|
+
.action((action, args, options) => knowledgeCommand(action, args, options));
|
|
110
|
+
program.addCommand(loginCommand);
|
|
111
|
+
program.addCommand(logoutCommand);
|
|
112
|
+
program.addCommand(whoamiCommand);
|
|
113
|
+
program.addCommand(publishCommand);
|
|
114
|
+
program.addCommand(registryInstallCommand);
|
|
115
|
+
program.addCommand(searchCommand);
|
|
116
|
+
program.addCommand(infoCommand);
|
|
88
117
|
program.parse();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{w as U,g,S as c,e as S,B as _,f as m,E as I,h as p}from"./index-
|
|
1
|
+
import{w as U,g,S as c,e as S,B as _,f as m,E as I,h as p}from"./index-C_t8dRMU.js";const x={name:"local-uniform-bit",vertex:{header:`
|
|
2
2
|
|
|
3
3
|
struct LocalUniforms {
|
|
4
4
|
uTransformMatrix:mat3x3<f32>,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as E,C as ee,i as D,k as Re,m as ce,M as F,l as R,G as Xe,w as $e,T as He,n as ze,o as Je,p as Ke,F as Qe,q as Ze,t as et,A as tt,R as nt,v as he}from"./index-D7CI6lgH.js";import{R as at,S as st,B as ot,a as rt,b as it,c as ct,A as lt,C as ht}from"./RenderTargetSystem-BeKLdFHC.js";let Z;function Ae(o){const e=E.get().createCanvas(6,1),t=e.getContext("2d");return t.fillStyle=o,t.fillRect(0,0,6,1),e}function Be(){if(Z!==void 0)return Z;try{const o=Ae("#ff00ff"),e=Ae("#ffff00"),a=E.get().createCanvas(6,1).getContext("2d");a.globalCompositeOperation="multiply",a.drawImage(o,0,0),a.drawImage(e,2,0);const n=a.getImageData(2,0,1,1);if(!n)Z=!1;else{const s=n.data;Z=s[0]===255&&s[1]===0&&s[2]===0}}catch{Z=!1}return Z}const d={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:Be(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:o=>{const e=o.source,t=e==null?void 0:e.resource;if(!t)return null;const a=e.alphaMode==="premultiplied-alpha",n=e.resourceWidth??e.pixelWidth,s=e.resourceHeight??e.pixelHeight,r=n!==e.pixelWidth||s!==e.pixelHeight;if(a){if((t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)&&!r)return t;const i=d._unpremultipliedCache.get(e);if((i==null?void 0:i.resourceId)===e._resourceId)return i.canvas}if(t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||t instanceof Uint16Array||t instanceof Int16Array||t instanceof Uint32Array||t instanceof Int32Array||t instanceof Float32Array||t instanceof ArrayBuffer){const i=d._canvasSourceCache.get(e);if((i==null?void 0:i.resourceId)===e._resourceId)return i.canvas;const c=E.get().createCanvas(e.pixelWidth,e.pixelHeight),h=c.getContext("2d"),l=h.createImageData(e.pixelWidth,e.pixelHeight),f=l.data,x=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(e.format==="bgra8unorm")for(let p=0;p<f.length&&p+3<x.length;p+=4)f[p]=x[p+2],f[p+1]=x[p+1],f[p+2]=x[p],f[p+3]=x[p+3];else f.set(x.subarray(0,f.length));return h.putImageData(l,0,0),d._canvasSourceCache.set(e,{canvas:c,resourceId:e._resourceId}),c}if(a){const i=E.get().createCanvas(e.pixelWidth,e.pixelHeight),c=i.getContext("2d",{willReadFrequently:!0});i.width=e.pixelWidth,i.height=e.pixelHeight,c.drawImage(t,0,0);const h=c.getImageData(0,0,i.width,i.height),l=h.data;for(let f=0;f<l.length;f+=4){const x=l[f+3];if(x>0){const p=255/x;l[f]=Math.min(255,l[f]*p+.5),l[f+1]=Math.min(255,l[f+1]*p+.5),l[f+2]=Math.min(255,l[f+2]*p+.5)}}return c.putImageData(h,0,0),d._unpremultipliedCache.set(e,{canvas:i,resourceId:e._resourceId}),i}if(r){const i=d._canvasSourceCache.get(e);if((i==null?void 0:i.resourceId)===e._resourceId)return i.canvas;const c=E.get().createCanvas(e.pixelWidth,e.pixelHeight),h=c.getContext("2d");return c.width=e.pixelWidth,c.height=e.pixelHeight,h.drawImage(t,0,0),d._canvasSourceCache.set(e,{canvas:c,resourceId:e._resourceId}),c}return t},getTintedCanvas:(o,e)=>{const t=o.texture,a=ee.shared.setValue(e).toHex(),n=t.tintCache||(t.tintCache={}),s=n[a],r=t.source._resourceId;if((s==null?void 0:s.tintId)===r)return s;const i=s&&"getContext"in s?s:E.get().createCanvas();return d.tintMethod(t,e,i),i.tintId=r,n[a]=i,n[a]},getTintedPattern:(o,e)=>{const t=ee.shared.setValue(e).toHex(),a=o.patternCache||(o.patternCache={}),n=o.source._resourceId;let s=a[t];return(s==null?void 0:s.tintId)===n||(d.canvas||(d.canvas=E.get().createCanvas()),d.tintMethod(o,e,d.canvas),s=d.canvas.getContext("2d").createPattern(d.canvas,"repeat"),s.tintId=n,a[t]=s),s},applyPatternTransform:(o,e,t=!0)=>{if(!e)return;const a=o;if(!a.setTransform)return;const n=globalThis.DOMMatrix;if(!n)return;const s=new n([e.a,e.b,e.c,e.d,e.tx,e.ty]);a.setTransform(t?s.inverse():s)},tintWithMultiply:(o,e,t)=>{const a=t.getContext("2d"),n=o.frame.clone(),s=o.source._resolution??o.source.resolution??1,r=o.rotate;n.x*=s,n.y*=s,n.width*=s,n.height*=s;const i=D.isVertical(r),c=i?n.height:n.width,h=i?n.width:n.height;t.width=Math.ceil(c),t.height=Math.ceil(h),a.save(),a.fillStyle=ee.shared.setValue(e).toHex(),a.fillRect(0,0,c,h),a.globalCompositeOperation="multiply";const l=d.getCanvasSource(o);if(!l){a.restore();return}r&&d._applyInverseRotation(a,r,n.width,n.height),a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.globalCompositeOperation="destination-atop",a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.restore()},tintWithOverlay:(o,e,t)=>{const a=t.getContext("2d"),n=o.frame.clone(),s=o.source._resolution??o.source.resolution??1,r=o.rotate;n.x*=s,n.y*=s,n.width*=s,n.height*=s;const i=D.isVertical(r),c=i?n.height:n.width,h=i?n.width:n.height;t.width=Math.ceil(c),t.height=Math.ceil(h),a.save(),a.globalCompositeOperation="copy",a.fillStyle=ee.shared.setValue(e).toHex(),a.fillRect(0,0,c,h),a.globalCompositeOperation="destination-atop";const l=d.getCanvasSource(o);if(!l){a.restore();return}r&&d._applyInverseRotation(a,r,n.width,n.height),a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.restore()},tintWithPerPixel:(o,e,t)=>{const a=t.getContext("2d"),n=o.frame.clone(),s=o.source._resolution??o.source.resolution??1,r=o.rotate;n.x*=s,n.y*=s,n.width*=s,n.height*=s;const i=D.isVertical(r),c=i?n.height:n.width,h=i?n.width:n.height;t.width=Math.ceil(c),t.height=Math.ceil(h),a.save(),a.globalCompositeOperation="copy";const l=d.getCanvasSource(o);if(!l){a.restore();return}r&&d._applyInverseRotation(a,r,n.width,n.height),a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.restore();const f=e>>16&255,x=e>>8&255,p=e&255,y=a.getImageData(0,0,c,h),T=y.data;for(let v=0;v<T.length;v+=4)T[v]=T[v]*f/255,T[v+1]=T[v+1]*x/255,T[v+2]=T[v+2]*p/255;a.putImageData(y,0,0)},_applyInverseRotation:(o,e,t,a)=>{const n=D.inv(e),s=D.uX(n),r=D.uY(n),i=D.vX(n),c=D.vY(n),h=-Math.min(0,s*t,i*a,s*t+i*a),l=-Math.min(0,r*t,c*a,r*t+c*a);o.transform(s,r,i,c,h,l)}};d.tintMethod=d.canUseMultiply?d.tintWithMultiply:d.tintWithPerPixel;const xe=class z{static _getPatternRepeat(e,t){const a=e&&e!=="clamp-to-edge",n=t&&t!=="clamp-to-edge";return a&&n?"repeat":a?"repeat-x":n?"repeat-y":"no-repeat"}start(e,t,a){}execute(e,t){var i,c,h,l;const a=t.elements;if(!a||!a.length)return;const n=e.renderer,s=n.canvasContext,r=s.activeContext;for(let f=0;f<a.length;f++){const x=a[f];if(!x.packAsQuad)continue;const p=x,y=p.texture,T=y?d.getCanvasSource(y):null;if(!T)continue;const v=y.source.style,H=s.smoothProperty,V=v.scaleMode!=="nearest";r[H]!==V&&(r[H]=V),s.setBlendMode(t.blendMode);const G=((i=n.globalUniforms.globalUniformData)==null?void 0:i.worldColor)??4294967295,b=p.color,P=(G>>>24&255)/255,X=(b>>>24&255)/255,se=((c=n.filter)==null?void 0:c.alphaMultiplier)??1,te=P*X*se;if(te<=0)continue;r.globalAlpha=te;const ne=G&16777215,J=b&16777215,w=Re(ce(J,ne)),S=y.frame,I=v.addressModeU??v.addressMode,de=v.addressModeV??v.addressMode,ae=z._getPatternRepeat(I,de),q=y.source._resolution??y.source.resolution??1,$=(l=(h=p.renderable)==null?void 0:h.renderGroup)==null?void 0:l.isCachedAsTexture,m=S.x*q,C=S.y*q,_=S.width*q,L=S.height*q,A=p.bounds,k=n.renderTarget.renderTarget.isRoot,U=A.minX,O=A.minY,B=A.maxX-A.minX,W=A.maxY-A.minY,N=y.rotate,u=y.uvs,Y=Math.min(u.x0,u.x1,u.x2,u.x3,u.y0,u.y1,u.y2,u.y3),j=Math.max(u.x0,u.x1,u.x2,u.x3,u.y0,u.y1,u.y2,u.y3),M=ae!=="no-repeat"&&(Y<0||j>1),pe=N&&!(!M&&(w!==16777215||N));pe?(z._tempPatternMatrix.copyFrom(p.transform),D.matrixAppendRotationInv(z._tempPatternMatrix,N,U,O,B,W),s.setContextTransform(z._tempPatternMatrix,p.roundPixels===1,void 0,$&&k)):s.setContextTransform(p.transform,p.roundPixels===1,void 0,$&&k);const oe=pe?0:U,re=pe?0:O,ue=B,fe=W;if(M){let ge=T;const K=w!==16777215&&!N,Q=S.width<=y.source.width&&S.height<=y.source.height;K&&Q&&(ge=d.getTintedCanvas({texture:y},w));const me=r.createPattern(ge,ae);if(!me)continue;const _e=ue,Pe=fe;if(_e===0||Pe===0)continue;const Me=1/_e,be=1/Pe,we=(u.x1-u.x0)*Me,ke=(u.y1-u.y0)*Me,Se=(u.x3-u.x0)*be,Ie=(u.y3-u.y0)*be,Ye=u.x0-we*oe-Se*re,je=u.y0-ke*oe-Ie*re,ve=y.source.pixelWidth,ye=y.source.pixelHeight;z._tempPatternMatrix.set(we*ve,ke*ye,Se*ve,Ie*ye,Ye*ve,je*ye),d.applyPatternTransform(me,z._tempPatternMatrix),r.fillStyle=me,r.fillRect(oe,re,ue,fe)}else{const K=w!==16777215||N?d.getTintedCanvas({texture:y},w):T,Q=K!==T;r.drawImage(K,Q?0:m,Q?0:C,Q?K.width:_,Q?K.height:L,oe,re,ue,fe)}}}};xe._tempPatternMatrix=new F;xe.extension={type:[R.CanvasPipesAdaptor],name:"batch"};let dt=xe;class We{constructor(e){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=e}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(e,t,a){this._renderer.renderPipes.batch.break(a);const n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&e.mask;const s=this._colorStack[this._colorStackIndex];s!==this._currentColor&&(this._currentColor=s,a.add({renderPipeId:"colorMask",colorMask:s,canBundle:!1})),this._colorStackIndex++}pop(e,t,a){this._renderer.renderPipes.batch.break(a);const n=this._colorStack;this._colorStackIndex--;const s=n[this._colorStackIndex-1];s!==this._currentColor&&(this._currentColor=s,a.add({renderPipeId:"colorMask",colorMask:s,canBundle:!1}))}execute(e){}destroy(){this._renderer=null,this._colorStack=null}}We.extension={type:[R.CanvasPipes],name:"colorMask"};function pt(o,e,t,a,n,s){s=Math.max(0,Math.min(s,Math.min(a,n)/2)),o.moveTo(e+s,t),o.lineTo(e+a-s,t),o.quadraticCurveTo(e+a,t,e+a,t+s),o.lineTo(e+a,t+n-s),o.quadraticCurveTo(e+a,t+n,e+a-s,t+n),o.lineTo(e+s,t+n),o.quadraticCurveTo(e,t+n,e,t+n-s),o.lineTo(e,t+s),o.quadraticCurveTo(e,t,e+s,t)}function De(o,e){switch(e.type){case"rectangle":{const t=e;o.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;pt(o,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;o.moveTo(t.x+t.radius,t.y),o.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;o.ellipse?(o.moveTo(t.x+t.halfWidth,t.y),o.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2)):(o.save(),o.translate(t.x,t.y),o.scale(t.halfWidth,t.halfHeight),o.moveTo(1,0),o.arc(0,0,1,0,Math.PI*2),o.restore());break}case"triangle":{const t=e;o.moveTo(t.x,t.y),o.lineTo(t.x2,t.y2),o.lineTo(t.x3,t.y3),o.closePath();break}case"polygon":default:{const t=e,a=t.points;if(!(a!=null&&a.length))break;o.moveTo(a[0],a[1]);for(let n=2;n<a.length;n+=2)o.lineTo(a[n],a[n+1]);t.closePath&&o.closePath();break}}}function ut(o,e){if(!(e!=null&&e.length))return!1;for(let t=0;t<e.length;t++){const a=e[t];if(!(a!=null&&a.shape))continue;const n=a.transform,s=n&&!n.isIdentity();s&&(o.save(),o.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),De(o,a.shape),s&&o.restore()}return!0}class Ge{constructor(e){this._warnedMaskTypes=new Set,this._canvasMaskStack=[],this._renderer=e}push(e,t,a){this._renderer.renderPipes.batch.break(a),a.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,a){this._renderer.renderPipes.batch.break(a),a.add({renderPipeId:"stencilMask",action:"popMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){var l,f,x;if(e.action!=="pushMaskBegin"&&e.action!=="popMaskEnd")return;const t=this._renderer,a=t.canvasContext,n=a==null?void 0:a.activeContext;if(!n)return;if(e.action==="popMaskEnd"){this._canvasMaskStack.pop()&&n.restore();return}e.inverse&&this._warnOnce("inverse","CanvasRenderer: inverse masks are not supported on Canvas2D; ignoring inverse flag.");const s=e.mask.mask;if(!(s instanceof Xe)){this._warnOnce("nonGraphics","CanvasRenderer: only Graphics masks are supported in Canvas2D; skipping mask."),this._canvasMaskStack.push(!1);return}const r=s,i=(l=r.context)==null?void 0:l.instructions;if(!(i!=null&&i.length)){this._canvasMaskStack.push(!1);return}n.save(),a.setContextTransform(r.groupTransform,(t._roundPixels|r._roundPixels)===1),n.beginPath();let c=!1,h=!1;for(let p=0;p<i.length;p++){const y=i[p],T=y.action;if(T!=="fill"&&T!=="stroke")continue;const v=y.data,H=(f=v==null?void 0:v.path)==null?void 0:f.shapePath;if(!((x=H==null?void 0:H.shapePrimitives)!=null&&x.length))continue;const V=H.shapePrimitives;for(let G=0;G<V.length;G++){const b=V[G];if(!(b!=null&&b.shape))continue;const P=b.transform,X=P&&!P.isIdentity();X&&(n.save(),n.transform(P.a,P.b,P.c,P.d,P.tx,P.ty)),De(n,b.shape),h=ut(n,b.holes)||h,c=!0,X&&n.restore()}}if(!c){n.restore(),this._canvasMaskStack.push(!1);return}h?n.clip("evenodd"):n.clip(),this._canvasMaskStack.push(!0)}destroy(){this._renderer=null,this._warnedMaskTypes=null,this._canvasMaskStack=null}_warnOnce(e,t){this._warnedMaskTypes.has(e)||(this._warnedMaskTypes.add(e),$e(t))}}Ge.extension={type:[R.CanvasPipes],name:"stencilMask"};const g="source-over";function ft(){const o=Be(),e=Object.create(null);return e.inherit=g,e.none=g,e.normal="source-over",e.add="lighter",e.multiply=o?"multiply":g,e.screen=o?"screen":g,e.overlay=o?"overlay":g,e.darken=o?"darken":g,e.lighten=o?"lighten":g,e["color-dodge"]=o?"color-dodge":g,e["color-burn"]=o?"color-burn":g,e["hard-light"]=o?"hard-light":g,e["soft-light"]=o?"soft-light":g,e.difference=o?"difference":g,e.exclusion=o?"exclusion":g,e.saturation=o?"saturation":g,e.color=o?"color":g,e.luminosity=o?"luminosity":g,e["linear-burn"]=o?"color-burn":g,e["linear-dodge"]=o?"color-dodge":g,e["linear-light"]=o?"hard-light":g,e["pin-light"]=o?"hard-light":g,e["vivid-light"]=o?"hard-light":g,e["hard-mix"]=g,e.negation=o?"difference":g,e["normal-npm"]=e.normal,e["add-npm"]=e.add,e["screen-npm"]=e.screen,e.erase="destination-out",e.subtract=g,e.divide=g,e.min=g,e.max=g,e}const gt=new F;class Ue{constructor(e){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=ft(),this._activeBlendMode="normal",this._projTransform=null,this._outerBlend=!1,this._warnedBlendModes=new Set,this._renderer=e}resolutionChange(e){this.activeResolution=e}init(){const e=this._renderer.background.alpha<1;if(this.rootContext=this._renderer.canvas.getContext("2d",{alpha:e}),this.activeContext=this.rootContext,this.activeResolution=this._renderer.resolution,!this.rootContext.imageSmoothingEnabled){const t=this.rootContext;t.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":t.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":t.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":t.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")}}setContextTransform(e,t,a,n){var h;const s=n?F.IDENTITY:((h=this._renderer.globalUniforms.globalUniformData)==null?void 0:h.worldTransformMatrix)||F.IDENTITY;let r=gt;r.copyFrom(s),r.append(e);const i=this._projTransform,c=this.activeResolution;if(a=a||c,i){const l=F.shared;l.copyFrom(r),l.prepend(i),r=l}t?this.activeContext.setTransform(r.a*a,r.b*a,r.c*a,r.d*a,r.tx*c|0,r.ty*c|0):this.activeContext.setTransform(r.a*a,r.b*a,r.c*a,r.d*a,r.tx*c,r.ty*c)}clear(e,t){const a=this.activeContext,n=this._renderer;if(a.clearRect(0,0,n.width,n.height),e){const s=ee.shared.setValue(e);a.globalAlpha=t??s.alpha,a.fillStyle=s.toHex(),a.fillRect(0,0,n.width,n.height),a.globalAlpha=1}}setBlendMode(e){if(this._activeBlendMode===e)return;this._activeBlendMode=e,this._outerBlend=!1;const t=this.blendModes[e];if(!t){this._warnedBlendModes.has(e)||(console.warn(`CanvasRenderer: blend mode "${e}" is not supported in Canvas2D; falling back to "source-over".`),this._warnedBlendModes.add(e)),this.activeContext.globalCompositeOperation="source-over";return}this.activeContext.globalCompositeOperation=t}destroy(){this.rootContext=null,this.activeContext=null,this._warnedBlendModes.clear()}}Ue.extension={type:[R.CanvasSystem],name:"canvasContext"};class Oe{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0}init(){}}Oe.extension={type:[R.CanvasSystem],name:"limits"};const mt="#808080",ie=new F,vt=new F,yt=new F,Ce=new F;function Ct(o,e,t){o.beginPath();for(let a=0;a<t.length;a+=3){const n=t[a]*2,s=t[a+1]*2,r=t[a+2]*2;o.moveTo(e[n],e[n+1]),o.lineTo(e[s],e[s+1]),o.lineTo(e[r],e[r+1]),o.closePath()}o.fill()}function xt(o){return`#${(o&16777215).toString(16).padStart(6,"0")}`}function Tt(o,e,t,a,n,s){s=Math.max(0,Math.min(s,Math.min(a,n)/2)),o.moveTo(e+s,t),o.lineTo(e+a-s,t),o.quadraticCurveTo(e+a,t,e+a,t+s),o.lineTo(e+a,t+n-s),o.quadraticCurveTo(e+a,t+n,e+a-s,t+n),o.lineTo(e+s,t+n),o.quadraticCurveTo(e,t+n,e,t+n-s),o.lineTo(e,t+s),o.quadraticCurveTo(e,t,e+s,t)}function le(o,e){switch(e.type){case"rectangle":{const t=e;o.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;Tt(o,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;o.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;o.ellipse?o.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2):(o.save(),o.translate(t.x,t.y),o.scale(t.halfWidth,t.halfHeight),o.arc(0,0,1,0,Math.PI*2),o.restore());break}case"triangle":{const t=e;o.moveTo(t.x,t.y),o.lineTo(t.x2,t.y2),o.lineTo(t.x3,t.y3),o.closePath();break}case"polygon":default:{const t=e,a=t.points;if(!(a!=null&&a.length))break;o.moveTo(a[0],a[1]);for(let n=2;n<a.length;n+=2)o.lineTo(a[n],a[n+1]);t.closePath&&o.closePath();break}}}function _t(o,e){if(!(e!=null&&e.length))return!1;for(let t=0;t<e.length;t++){const a=e[t];if(!(a!=null&&a.shape))continue;const n=a.transform,s=n&&!n.isIdentity();s&&(o.save(),o.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),le(o,a.shape),s&&o.restore()}return!0}function Pt(o,e,t,a){const n=o.fill;if(n instanceof Qe){n.buildGradient();const r=n.texture;if(r){const i=d.getTintedPattern(r,e),c=t?Ce.copyFrom(t).scale(r.source.pixelWidth,r.source.pixelHeight):Ce.copyFrom(n.transform);return a&&!o.textureSpace&&c.append(a),d.applyPatternTransform(i,c),i}}if(n instanceof Ze){const r=d.getTintedPattern(n.texture,e);return d.applyPatternTransform(r,n.transform),r}const s=o.texture;if(s&&s!==He.WHITE){if(!s.source.resource)return mt;const r=d.getTintedPattern(s,e),i=t?Ce.copyFrom(t).scale(s.source.pixelWidth,s.source.pixelHeight):o.matrix;return d.applyPatternTransform(r,i),r}return xt(e)}class Ee{constructor(){this.shader=null}contextChange(e){}execute(e,t){var V,G,b,P,X,se,te;const a=e.renderer,n=a.canvasContext,s=n.activeContext,r=t.groupTransform,i=((V=a.globalUniforms.globalUniformData)==null?void 0:V.worldColor)??4294967295,c=t.groupColorAlpha,h=(i>>>24&255)/255,l=(c>>>24&255)/255,f=((G=a.filter)==null?void 0:G.alphaMultiplier)??1,x=h*l*f;if(x<=0)return;const p=i&16777215,y=c&16777215,T=Re(ce(y,p)),v=a._roundPixels|t._roundPixels;s.save(),n.setContextTransform(r,v===1),n.setBlendMode(t.groupBlendMode);const H=t.context.instructions;for(let ne=0;ne<H.length;ne++){const J=H[ne];if(J.action==="texture"){const m=J.data,C=m.image,_=C?d.getCanvasSource(C):null;if(!_)continue;const L=m.alpha*x;if(L<=0)continue;const A=ce(m.style,T);s.globalAlpha=L;let k=_;A!==16777215&&(k=d.getTintedCanvas({texture:C},A));const U=C.frame,O=C.source._resolution??C.source.resolution??1;let B=U.x*O,W=U.y*O;const N=U.width*O,u=U.height*O;k!==_&&(B=0,W=0);const Y=m.transform,j=Y&&!Y.isIdentity(),M=C.rotate;j||M?(ie.copyFrom(r),j&&ie.append(Y),M&&D.matrixAppendRotationInv(ie,M,m.dx,m.dy,m.dw,m.dh),n.setContextTransform(ie,v===1)):n.setContextTransform(r,v===1),s.drawImage(k,B,W,k===_?N:k.width,k===_?u:k.height,M?0:m.dx,M?0:m.dy,m.dw,m.dh),(j||M)&&n.setContextTransform(r,v===1);continue}const w=J.data,S=(b=w==null?void 0:w.path)==null?void 0:b.shapePath;if(!((P=S==null?void 0:S.shapePrimitives)!=null&&P.length))continue;const I=w.style,de=ce(I.color,T),ae=I.alpha*x;if(ae<=0)continue;const q=J.action==="stroke";if(s.globalAlpha=ae,q){const m=I;s.lineWidth=m.width,s.lineCap=m.cap,s.lineJoin=m.join,s.miterLimit=m.miterLimit}const $=S.shapePrimitives;if(!q&&((te=(se=(X=w.hole)==null?void 0:X.shapePath)==null?void 0:se.shapePrimitives)!=null&&te.length)){const m=$[$.length-1];m.holes=w.hole.shapePath.shapePrimitives}for(let m=0;m<$.length;m++){const C=$[m];if(!(C!=null&&C.shape))continue;const _=C.transform,L=_&&!_.isIdentity(),A=I.texture&&I.texture!==He.WHITE,k=I.textureSpace==="global"?_:null,U=A?ze(vt,I,C.shape,k):null,O=L?yt.copyFrom(r).append(_):r,B=Pt(I,de,U,O);if(L&&(s.save(),s.transform(_.a,_.b,_.c,_.d,_.tx,_.ty)),q){const W=I;if(W.alignment!==.5&&!W.pixelLine){const u=[],Y=[],j=[],M=Je[C.shape.type];if(M!=null&&M.build(C.shape,u)){const Te=C.shape.closePath??!0;Ke(u,W,!1,Te,Y,j),s.fillStyle=B,Ct(s,Y,j)}else s.strokeStyle=B,s.beginPath(),le(s,C.shape),s.stroke()}else s.strokeStyle=B,s.beginPath(),le(s,C.shape),s.stroke()}else s.fillStyle=B,s.beginPath(),le(s,C.shape),_t(s,C.holes)?s.fill("evenodd"):s.fill();L&&s.restore()}}s.restore()}destroy(){this.shader=null}}Ee.extension={type:[R.CanvasPipesAdaptor],name:"graphics"};class Mt{init(e,t){this._renderer=e,this._renderTargetSystem=t}initGpuRenderTarget(e){const t=e.colorTexture,{canvas:a,context:n}=this._ensureCanvas(t);return{canvas:a,context:n,width:a.width,height:a.height}}resizeGpuRenderTarget(e){const t=e.colorTexture,{canvas:a}=this._ensureCanvas(t);a.width=e.pixelWidth,a.height=e.pixelHeight}startRenderPass(e,t,a,n){const s=this._renderTargetSystem.getGpuRenderTarget(e);this._renderer.canvasContext.activeContext=s.context,this._renderer.canvasContext.activeResolution=e.resolution,t&&this.clear(e,t,a,n)}clear(e,t,a,n){const r=this._renderTargetSystem.getGpuRenderTarget(e).context,i=n||{x:0,y:0,width:e.pixelWidth,height:e.pixelHeight};if(r.setTransform(1,0,0,1,0,0),r.clearRect(i.x,i.y,i.width,i.height),a){const c=ee.shared.setValue(a);c.alpha>0&&(r.globalAlpha=c.alpha,r.fillStyle=c.toHex(),r.fillRect(i.x,i.y,i.width,i.height),r.globalAlpha=1)}}finishRenderPass(){}copyToTexture(e,t,a,n,s){const i=this._renderTargetSystem.getGpuRenderTarget(e).canvas,c=t.source,{context:h}=this._ensureCanvas(c),l=(s==null?void 0:s.x)??0,f=(s==null?void 0:s.y)??0;return h.drawImage(i,a.x,a.y,n.width,n.height,l,f,n.width,n.height),c.update(),t}destroyGpuRenderTarget(e){}_ensureCanvas(e){let t=e.resource;(!t||!et.test(t))&&(t=E.get().createCanvas(e.pixelWidth,e.pixelHeight),e.resource=t),(t.width!==e.pixelWidth||t.height!==e.pixelHeight)&&(t.width=e.pixelWidth,t.height=e.pixelHeight);const a=t.getContext("2d");return{canvas:t,context:a}}}class Fe extends at{constructor(e){super(e),this.adaptor=new Mt,this.adaptor.init(e,this)}}Fe.extension={type:[R.CanvasSystem],name:"renderTarget"};class Ve{constructor(e){}init(){}initSource(e){}generateCanvas(e){const t=E.get().createCanvas(),a=t.getContext("2d"),n=d.getCanvasSource(e);if(!n)return t;const s=e.frame,r=e.source._resolution??e.source.resolution??1,i=s.x*r,c=s.y*r,h=s.width*r,l=s.height*r;return t.width=Math.ceil(h),t.height=Math.ceil(l),a.drawImage(n,i,c,h,l,0,0,h,l),t}getPixels(e){const t=this.generateCanvas(e);return{pixels:t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,t.width,t.height).data,width:t.width,height:t.height}}destroy(){}}Ve.extension={type:[R.CanvasSystem],name:"texture"};const bt=[...st,Ue,Oe,Ve,Fe],wt=[ot,rt,it,ct,lt,Ge,We,ht],kt=[dt,Ee],qe=[],Le=[],Ne=[];he.handleByNamedList(R.CanvasSystem,qe);he.handleByNamedList(R.CanvasPipes,Le);he.handleByNamedList(R.CanvasPipesAdaptor,Ne);he.add(...bt,...wt,...kt);class At extends tt{constructor(){const e={name:"canvas",type:nt.CANVAS,systems:qe,renderPipes:Le,renderPipeAdaptors:Ne};super(e)}}export{At as CanvasRenderer};
|
|
1
|
+
import{D as E,C as ee,i as D,k as Re,m as ce,M as F,l as R,G as Xe,w as $e,T as He,n as ze,o as Je,p as Ke,F as Qe,q as Ze,t as et,A as tt,R as nt,v as he}from"./index-C_t8dRMU.js";import{R as at,S as st,B as ot,a as rt,b as it,c as ct,A as lt,C as ht}from"./RenderTargetSystem-oHTzuh-F.js";let Z;function Ae(o){const e=E.get().createCanvas(6,1),t=e.getContext("2d");return t.fillStyle=o,t.fillRect(0,0,6,1),e}function Be(){if(Z!==void 0)return Z;try{const o=Ae("#ff00ff"),e=Ae("#ffff00"),a=E.get().createCanvas(6,1).getContext("2d");a.globalCompositeOperation="multiply",a.drawImage(o,0,0),a.drawImage(e,2,0);const n=a.getImageData(2,0,1,1);if(!n)Z=!1;else{const s=n.data;Z=s[0]===255&&s[1]===0&&s[2]===0}}catch{Z=!1}return Z}const d={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:Be(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:o=>{const e=o.source,t=e==null?void 0:e.resource;if(!t)return null;const a=e.alphaMode==="premultiplied-alpha",n=e.resourceWidth??e.pixelWidth,s=e.resourceHeight??e.pixelHeight,r=n!==e.pixelWidth||s!==e.pixelHeight;if(a){if((t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)&&!r)return t;const i=d._unpremultipliedCache.get(e);if((i==null?void 0:i.resourceId)===e._resourceId)return i.canvas}if(t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||t instanceof Uint16Array||t instanceof Int16Array||t instanceof Uint32Array||t instanceof Int32Array||t instanceof Float32Array||t instanceof ArrayBuffer){const i=d._canvasSourceCache.get(e);if((i==null?void 0:i.resourceId)===e._resourceId)return i.canvas;const c=E.get().createCanvas(e.pixelWidth,e.pixelHeight),h=c.getContext("2d"),l=h.createImageData(e.pixelWidth,e.pixelHeight),f=l.data,x=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(e.format==="bgra8unorm")for(let p=0;p<f.length&&p+3<x.length;p+=4)f[p]=x[p+2],f[p+1]=x[p+1],f[p+2]=x[p],f[p+3]=x[p+3];else f.set(x.subarray(0,f.length));return h.putImageData(l,0,0),d._canvasSourceCache.set(e,{canvas:c,resourceId:e._resourceId}),c}if(a){const i=E.get().createCanvas(e.pixelWidth,e.pixelHeight),c=i.getContext("2d",{willReadFrequently:!0});i.width=e.pixelWidth,i.height=e.pixelHeight,c.drawImage(t,0,0);const h=c.getImageData(0,0,i.width,i.height),l=h.data;for(let f=0;f<l.length;f+=4){const x=l[f+3];if(x>0){const p=255/x;l[f]=Math.min(255,l[f]*p+.5),l[f+1]=Math.min(255,l[f+1]*p+.5),l[f+2]=Math.min(255,l[f+2]*p+.5)}}return c.putImageData(h,0,0),d._unpremultipliedCache.set(e,{canvas:i,resourceId:e._resourceId}),i}if(r){const i=d._canvasSourceCache.get(e);if((i==null?void 0:i.resourceId)===e._resourceId)return i.canvas;const c=E.get().createCanvas(e.pixelWidth,e.pixelHeight),h=c.getContext("2d");return c.width=e.pixelWidth,c.height=e.pixelHeight,h.drawImage(t,0,0),d._canvasSourceCache.set(e,{canvas:c,resourceId:e._resourceId}),c}return t},getTintedCanvas:(o,e)=>{const t=o.texture,a=ee.shared.setValue(e).toHex(),n=t.tintCache||(t.tintCache={}),s=n[a],r=t.source._resourceId;if((s==null?void 0:s.tintId)===r)return s;const i=s&&"getContext"in s?s:E.get().createCanvas();return d.tintMethod(t,e,i),i.tintId=r,n[a]=i,n[a]},getTintedPattern:(o,e)=>{const t=ee.shared.setValue(e).toHex(),a=o.patternCache||(o.patternCache={}),n=o.source._resourceId;let s=a[t];return(s==null?void 0:s.tintId)===n||(d.canvas||(d.canvas=E.get().createCanvas()),d.tintMethod(o,e,d.canvas),s=d.canvas.getContext("2d").createPattern(d.canvas,"repeat"),s.tintId=n,a[t]=s),s},applyPatternTransform:(o,e,t=!0)=>{if(!e)return;const a=o;if(!a.setTransform)return;const n=globalThis.DOMMatrix;if(!n)return;const s=new n([e.a,e.b,e.c,e.d,e.tx,e.ty]);a.setTransform(t?s.inverse():s)},tintWithMultiply:(o,e,t)=>{const a=t.getContext("2d"),n=o.frame.clone(),s=o.source._resolution??o.source.resolution??1,r=o.rotate;n.x*=s,n.y*=s,n.width*=s,n.height*=s;const i=D.isVertical(r),c=i?n.height:n.width,h=i?n.width:n.height;t.width=Math.ceil(c),t.height=Math.ceil(h),a.save(),a.fillStyle=ee.shared.setValue(e).toHex(),a.fillRect(0,0,c,h),a.globalCompositeOperation="multiply";const l=d.getCanvasSource(o);if(!l){a.restore();return}r&&d._applyInverseRotation(a,r,n.width,n.height),a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.globalCompositeOperation="destination-atop",a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.restore()},tintWithOverlay:(o,e,t)=>{const a=t.getContext("2d"),n=o.frame.clone(),s=o.source._resolution??o.source.resolution??1,r=o.rotate;n.x*=s,n.y*=s,n.width*=s,n.height*=s;const i=D.isVertical(r),c=i?n.height:n.width,h=i?n.width:n.height;t.width=Math.ceil(c),t.height=Math.ceil(h),a.save(),a.globalCompositeOperation="copy",a.fillStyle=ee.shared.setValue(e).toHex(),a.fillRect(0,0,c,h),a.globalCompositeOperation="destination-atop";const l=d.getCanvasSource(o);if(!l){a.restore();return}r&&d._applyInverseRotation(a,r,n.width,n.height),a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.restore()},tintWithPerPixel:(o,e,t)=>{const a=t.getContext("2d"),n=o.frame.clone(),s=o.source._resolution??o.source.resolution??1,r=o.rotate;n.x*=s,n.y*=s,n.width*=s,n.height*=s;const i=D.isVertical(r),c=i?n.height:n.width,h=i?n.width:n.height;t.width=Math.ceil(c),t.height=Math.ceil(h),a.save(),a.globalCompositeOperation="copy";const l=d.getCanvasSource(o);if(!l){a.restore();return}r&&d._applyInverseRotation(a,r,n.width,n.height),a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.restore();const f=e>>16&255,x=e>>8&255,p=e&255,y=a.getImageData(0,0,c,h),T=y.data;for(let v=0;v<T.length;v+=4)T[v]=T[v]*f/255,T[v+1]=T[v+1]*x/255,T[v+2]=T[v+2]*p/255;a.putImageData(y,0,0)},_applyInverseRotation:(o,e,t,a)=>{const n=D.inv(e),s=D.uX(n),r=D.uY(n),i=D.vX(n),c=D.vY(n),h=-Math.min(0,s*t,i*a,s*t+i*a),l=-Math.min(0,r*t,c*a,r*t+c*a);o.transform(s,r,i,c,h,l)}};d.tintMethod=d.canUseMultiply?d.tintWithMultiply:d.tintWithPerPixel;const xe=class z{static _getPatternRepeat(e,t){const a=e&&e!=="clamp-to-edge",n=t&&t!=="clamp-to-edge";return a&&n?"repeat":a?"repeat-x":n?"repeat-y":"no-repeat"}start(e,t,a){}execute(e,t){var i,c,h,l;const a=t.elements;if(!a||!a.length)return;const n=e.renderer,s=n.canvasContext,r=s.activeContext;for(let f=0;f<a.length;f++){const x=a[f];if(!x.packAsQuad)continue;const p=x,y=p.texture,T=y?d.getCanvasSource(y):null;if(!T)continue;const v=y.source.style,H=s.smoothProperty,V=v.scaleMode!=="nearest";r[H]!==V&&(r[H]=V),s.setBlendMode(t.blendMode);const G=((i=n.globalUniforms.globalUniformData)==null?void 0:i.worldColor)??4294967295,b=p.color,P=(G>>>24&255)/255,X=(b>>>24&255)/255,se=((c=n.filter)==null?void 0:c.alphaMultiplier)??1,te=P*X*se;if(te<=0)continue;r.globalAlpha=te;const ne=G&16777215,J=b&16777215,w=Re(ce(J,ne)),S=y.frame,I=v.addressModeU??v.addressMode,de=v.addressModeV??v.addressMode,ae=z._getPatternRepeat(I,de),q=y.source._resolution??y.source.resolution??1,$=(l=(h=p.renderable)==null?void 0:h.renderGroup)==null?void 0:l.isCachedAsTexture,m=S.x*q,C=S.y*q,_=S.width*q,L=S.height*q,A=p.bounds,k=n.renderTarget.renderTarget.isRoot,U=A.minX,O=A.minY,B=A.maxX-A.minX,W=A.maxY-A.minY,N=y.rotate,u=y.uvs,Y=Math.min(u.x0,u.x1,u.x2,u.x3,u.y0,u.y1,u.y2,u.y3),j=Math.max(u.x0,u.x1,u.x2,u.x3,u.y0,u.y1,u.y2,u.y3),M=ae!=="no-repeat"&&(Y<0||j>1),pe=N&&!(!M&&(w!==16777215||N));pe?(z._tempPatternMatrix.copyFrom(p.transform),D.matrixAppendRotationInv(z._tempPatternMatrix,N,U,O,B,W),s.setContextTransform(z._tempPatternMatrix,p.roundPixels===1,void 0,$&&k)):s.setContextTransform(p.transform,p.roundPixels===1,void 0,$&&k);const oe=pe?0:U,re=pe?0:O,ue=B,fe=W;if(M){let ge=T;const K=w!==16777215&&!N,Q=S.width<=y.source.width&&S.height<=y.source.height;K&&Q&&(ge=d.getTintedCanvas({texture:y},w));const me=r.createPattern(ge,ae);if(!me)continue;const _e=ue,Pe=fe;if(_e===0||Pe===0)continue;const Me=1/_e,be=1/Pe,we=(u.x1-u.x0)*Me,ke=(u.y1-u.y0)*Me,Se=(u.x3-u.x0)*be,Ie=(u.y3-u.y0)*be,Ye=u.x0-we*oe-Se*re,je=u.y0-ke*oe-Ie*re,ve=y.source.pixelWidth,ye=y.source.pixelHeight;z._tempPatternMatrix.set(we*ve,ke*ye,Se*ve,Ie*ye,Ye*ve,je*ye),d.applyPatternTransform(me,z._tempPatternMatrix),r.fillStyle=me,r.fillRect(oe,re,ue,fe)}else{const K=w!==16777215||N?d.getTintedCanvas({texture:y},w):T,Q=K!==T;r.drawImage(K,Q?0:m,Q?0:C,Q?K.width:_,Q?K.height:L,oe,re,ue,fe)}}}};xe._tempPatternMatrix=new F;xe.extension={type:[R.CanvasPipesAdaptor],name:"batch"};let dt=xe;class We{constructor(e){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=e}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(e,t,a){this._renderer.renderPipes.batch.break(a);const n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&e.mask;const s=this._colorStack[this._colorStackIndex];s!==this._currentColor&&(this._currentColor=s,a.add({renderPipeId:"colorMask",colorMask:s,canBundle:!1})),this._colorStackIndex++}pop(e,t,a){this._renderer.renderPipes.batch.break(a);const n=this._colorStack;this._colorStackIndex--;const s=n[this._colorStackIndex-1];s!==this._currentColor&&(this._currentColor=s,a.add({renderPipeId:"colorMask",colorMask:s,canBundle:!1}))}execute(e){}destroy(){this._renderer=null,this._colorStack=null}}We.extension={type:[R.CanvasPipes],name:"colorMask"};function pt(o,e,t,a,n,s){s=Math.max(0,Math.min(s,Math.min(a,n)/2)),o.moveTo(e+s,t),o.lineTo(e+a-s,t),o.quadraticCurveTo(e+a,t,e+a,t+s),o.lineTo(e+a,t+n-s),o.quadraticCurveTo(e+a,t+n,e+a-s,t+n),o.lineTo(e+s,t+n),o.quadraticCurveTo(e,t+n,e,t+n-s),o.lineTo(e,t+s),o.quadraticCurveTo(e,t,e+s,t)}function De(o,e){switch(e.type){case"rectangle":{const t=e;o.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;pt(o,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;o.moveTo(t.x+t.radius,t.y),o.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;o.ellipse?(o.moveTo(t.x+t.halfWidth,t.y),o.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2)):(o.save(),o.translate(t.x,t.y),o.scale(t.halfWidth,t.halfHeight),o.moveTo(1,0),o.arc(0,0,1,0,Math.PI*2),o.restore());break}case"triangle":{const t=e;o.moveTo(t.x,t.y),o.lineTo(t.x2,t.y2),o.lineTo(t.x3,t.y3),o.closePath();break}case"polygon":default:{const t=e,a=t.points;if(!(a!=null&&a.length))break;o.moveTo(a[0],a[1]);for(let n=2;n<a.length;n+=2)o.lineTo(a[n],a[n+1]);t.closePath&&o.closePath();break}}}function ut(o,e){if(!(e!=null&&e.length))return!1;for(let t=0;t<e.length;t++){const a=e[t];if(!(a!=null&&a.shape))continue;const n=a.transform,s=n&&!n.isIdentity();s&&(o.save(),o.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),De(o,a.shape),s&&o.restore()}return!0}class Ge{constructor(e){this._warnedMaskTypes=new Set,this._canvasMaskStack=[],this._renderer=e}push(e,t,a){this._renderer.renderPipes.batch.break(a),a.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,a){this._renderer.renderPipes.batch.break(a),a.add({renderPipeId:"stencilMask",action:"popMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){var l,f,x;if(e.action!=="pushMaskBegin"&&e.action!=="popMaskEnd")return;const t=this._renderer,a=t.canvasContext,n=a==null?void 0:a.activeContext;if(!n)return;if(e.action==="popMaskEnd"){this._canvasMaskStack.pop()&&n.restore();return}e.inverse&&this._warnOnce("inverse","CanvasRenderer: inverse masks are not supported on Canvas2D; ignoring inverse flag.");const s=e.mask.mask;if(!(s instanceof Xe)){this._warnOnce("nonGraphics","CanvasRenderer: only Graphics masks are supported in Canvas2D; skipping mask."),this._canvasMaskStack.push(!1);return}const r=s,i=(l=r.context)==null?void 0:l.instructions;if(!(i!=null&&i.length)){this._canvasMaskStack.push(!1);return}n.save(),a.setContextTransform(r.groupTransform,(t._roundPixels|r._roundPixels)===1),n.beginPath();let c=!1,h=!1;for(let p=0;p<i.length;p++){const y=i[p],T=y.action;if(T!=="fill"&&T!=="stroke")continue;const v=y.data,H=(f=v==null?void 0:v.path)==null?void 0:f.shapePath;if(!((x=H==null?void 0:H.shapePrimitives)!=null&&x.length))continue;const V=H.shapePrimitives;for(let G=0;G<V.length;G++){const b=V[G];if(!(b!=null&&b.shape))continue;const P=b.transform,X=P&&!P.isIdentity();X&&(n.save(),n.transform(P.a,P.b,P.c,P.d,P.tx,P.ty)),De(n,b.shape),h=ut(n,b.holes)||h,c=!0,X&&n.restore()}}if(!c){n.restore(),this._canvasMaskStack.push(!1);return}h?n.clip("evenodd"):n.clip(),this._canvasMaskStack.push(!0)}destroy(){this._renderer=null,this._warnedMaskTypes=null,this._canvasMaskStack=null}_warnOnce(e,t){this._warnedMaskTypes.has(e)||(this._warnedMaskTypes.add(e),$e(t))}}Ge.extension={type:[R.CanvasPipes],name:"stencilMask"};const g="source-over";function ft(){const o=Be(),e=Object.create(null);return e.inherit=g,e.none=g,e.normal="source-over",e.add="lighter",e.multiply=o?"multiply":g,e.screen=o?"screen":g,e.overlay=o?"overlay":g,e.darken=o?"darken":g,e.lighten=o?"lighten":g,e["color-dodge"]=o?"color-dodge":g,e["color-burn"]=o?"color-burn":g,e["hard-light"]=o?"hard-light":g,e["soft-light"]=o?"soft-light":g,e.difference=o?"difference":g,e.exclusion=o?"exclusion":g,e.saturation=o?"saturation":g,e.color=o?"color":g,e.luminosity=o?"luminosity":g,e["linear-burn"]=o?"color-burn":g,e["linear-dodge"]=o?"color-dodge":g,e["linear-light"]=o?"hard-light":g,e["pin-light"]=o?"hard-light":g,e["vivid-light"]=o?"hard-light":g,e["hard-mix"]=g,e.negation=o?"difference":g,e["normal-npm"]=e.normal,e["add-npm"]=e.add,e["screen-npm"]=e.screen,e.erase="destination-out",e.subtract=g,e.divide=g,e.min=g,e.max=g,e}const gt=new F;class Ue{constructor(e){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=ft(),this._activeBlendMode="normal",this._projTransform=null,this._outerBlend=!1,this._warnedBlendModes=new Set,this._renderer=e}resolutionChange(e){this.activeResolution=e}init(){const e=this._renderer.background.alpha<1;if(this.rootContext=this._renderer.canvas.getContext("2d",{alpha:e}),this.activeContext=this.rootContext,this.activeResolution=this._renderer.resolution,!this.rootContext.imageSmoothingEnabled){const t=this.rootContext;t.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":t.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":t.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":t.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")}}setContextTransform(e,t,a,n){var h;const s=n?F.IDENTITY:((h=this._renderer.globalUniforms.globalUniformData)==null?void 0:h.worldTransformMatrix)||F.IDENTITY;let r=gt;r.copyFrom(s),r.append(e);const i=this._projTransform,c=this.activeResolution;if(a=a||c,i){const l=F.shared;l.copyFrom(r),l.prepend(i),r=l}t?this.activeContext.setTransform(r.a*a,r.b*a,r.c*a,r.d*a,r.tx*c|0,r.ty*c|0):this.activeContext.setTransform(r.a*a,r.b*a,r.c*a,r.d*a,r.tx*c,r.ty*c)}clear(e,t){const a=this.activeContext,n=this._renderer;if(a.clearRect(0,0,n.width,n.height),e){const s=ee.shared.setValue(e);a.globalAlpha=t??s.alpha,a.fillStyle=s.toHex(),a.fillRect(0,0,n.width,n.height),a.globalAlpha=1}}setBlendMode(e){if(this._activeBlendMode===e)return;this._activeBlendMode=e,this._outerBlend=!1;const t=this.blendModes[e];if(!t){this._warnedBlendModes.has(e)||(console.warn(`CanvasRenderer: blend mode "${e}" is not supported in Canvas2D; falling back to "source-over".`),this._warnedBlendModes.add(e)),this.activeContext.globalCompositeOperation="source-over";return}this.activeContext.globalCompositeOperation=t}destroy(){this.rootContext=null,this.activeContext=null,this._warnedBlendModes.clear()}}Ue.extension={type:[R.CanvasSystem],name:"canvasContext"};class Oe{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0}init(){}}Oe.extension={type:[R.CanvasSystem],name:"limits"};const mt="#808080",ie=new F,vt=new F,yt=new F,Ce=new F;function Ct(o,e,t){o.beginPath();for(let a=0;a<t.length;a+=3){const n=t[a]*2,s=t[a+1]*2,r=t[a+2]*2;o.moveTo(e[n],e[n+1]),o.lineTo(e[s],e[s+1]),o.lineTo(e[r],e[r+1]),o.closePath()}o.fill()}function xt(o){return`#${(o&16777215).toString(16).padStart(6,"0")}`}function Tt(o,e,t,a,n,s){s=Math.max(0,Math.min(s,Math.min(a,n)/2)),o.moveTo(e+s,t),o.lineTo(e+a-s,t),o.quadraticCurveTo(e+a,t,e+a,t+s),o.lineTo(e+a,t+n-s),o.quadraticCurveTo(e+a,t+n,e+a-s,t+n),o.lineTo(e+s,t+n),o.quadraticCurveTo(e,t+n,e,t+n-s),o.lineTo(e,t+s),o.quadraticCurveTo(e,t,e+s,t)}function le(o,e){switch(e.type){case"rectangle":{const t=e;o.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;Tt(o,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;o.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;o.ellipse?o.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2):(o.save(),o.translate(t.x,t.y),o.scale(t.halfWidth,t.halfHeight),o.arc(0,0,1,0,Math.PI*2),o.restore());break}case"triangle":{const t=e;o.moveTo(t.x,t.y),o.lineTo(t.x2,t.y2),o.lineTo(t.x3,t.y3),o.closePath();break}case"polygon":default:{const t=e,a=t.points;if(!(a!=null&&a.length))break;o.moveTo(a[0],a[1]);for(let n=2;n<a.length;n+=2)o.lineTo(a[n],a[n+1]);t.closePath&&o.closePath();break}}}function _t(o,e){if(!(e!=null&&e.length))return!1;for(let t=0;t<e.length;t++){const a=e[t];if(!(a!=null&&a.shape))continue;const n=a.transform,s=n&&!n.isIdentity();s&&(o.save(),o.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),le(o,a.shape),s&&o.restore()}return!0}function Pt(o,e,t,a){const n=o.fill;if(n instanceof Qe){n.buildGradient();const r=n.texture;if(r){const i=d.getTintedPattern(r,e),c=t?Ce.copyFrom(t).scale(r.source.pixelWidth,r.source.pixelHeight):Ce.copyFrom(n.transform);return a&&!o.textureSpace&&c.append(a),d.applyPatternTransform(i,c),i}}if(n instanceof Ze){const r=d.getTintedPattern(n.texture,e);return d.applyPatternTransform(r,n.transform),r}const s=o.texture;if(s&&s!==He.WHITE){if(!s.source.resource)return mt;const r=d.getTintedPattern(s,e),i=t?Ce.copyFrom(t).scale(s.source.pixelWidth,s.source.pixelHeight):o.matrix;return d.applyPatternTransform(r,i),r}return xt(e)}class Ee{constructor(){this.shader=null}contextChange(e){}execute(e,t){var V,G,b,P,X,se,te;const a=e.renderer,n=a.canvasContext,s=n.activeContext,r=t.groupTransform,i=((V=a.globalUniforms.globalUniformData)==null?void 0:V.worldColor)??4294967295,c=t.groupColorAlpha,h=(i>>>24&255)/255,l=(c>>>24&255)/255,f=((G=a.filter)==null?void 0:G.alphaMultiplier)??1,x=h*l*f;if(x<=0)return;const p=i&16777215,y=c&16777215,T=Re(ce(y,p)),v=a._roundPixels|t._roundPixels;s.save(),n.setContextTransform(r,v===1),n.setBlendMode(t.groupBlendMode);const H=t.context.instructions;for(let ne=0;ne<H.length;ne++){const J=H[ne];if(J.action==="texture"){const m=J.data,C=m.image,_=C?d.getCanvasSource(C):null;if(!_)continue;const L=m.alpha*x;if(L<=0)continue;const A=ce(m.style,T);s.globalAlpha=L;let k=_;A!==16777215&&(k=d.getTintedCanvas({texture:C},A));const U=C.frame,O=C.source._resolution??C.source.resolution??1;let B=U.x*O,W=U.y*O;const N=U.width*O,u=U.height*O;k!==_&&(B=0,W=0);const Y=m.transform,j=Y&&!Y.isIdentity(),M=C.rotate;j||M?(ie.copyFrom(r),j&&ie.append(Y),M&&D.matrixAppendRotationInv(ie,M,m.dx,m.dy,m.dw,m.dh),n.setContextTransform(ie,v===1)):n.setContextTransform(r,v===1),s.drawImage(k,B,W,k===_?N:k.width,k===_?u:k.height,M?0:m.dx,M?0:m.dy,m.dw,m.dh),(j||M)&&n.setContextTransform(r,v===1);continue}const w=J.data,S=(b=w==null?void 0:w.path)==null?void 0:b.shapePath;if(!((P=S==null?void 0:S.shapePrimitives)!=null&&P.length))continue;const I=w.style,de=ce(I.color,T),ae=I.alpha*x;if(ae<=0)continue;const q=J.action==="stroke";if(s.globalAlpha=ae,q){const m=I;s.lineWidth=m.width,s.lineCap=m.cap,s.lineJoin=m.join,s.miterLimit=m.miterLimit}const $=S.shapePrimitives;if(!q&&((te=(se=(X=w.hole)==null?void 0:X.shapePath)==null?void 0:se.shapePrimitives)!=null&&te.length)){const m=$[$.length-1];m.holes=w.hole.shapePath.shapePrimitives}for(let m=0;m<$.length;m++){const C=$[m];if(!(C!=null&&C.shape))continue;const _=C.transform,L=_&&!_.isIdentity(),A=I.texture&&I.texture!==He.WHITE,k=I.textureSpace==="global"?_:null,U=A?ze(vt,I,C.shape,k):null,O=L?yt.copyFrom(r).append(_):r,B=Pt(I,de,U,O);if(L&&(s.save(),s.transform(_.a,_.b,_.c,_.d,_.tx,_.ty)),q){const W=I;if(W.alignment!==.5&&!W.pixelLine){const u=[],Y=[],j=[],M=Je[C.shape.type];if(M!=null&&M.build(C.shape,u)){const Te=C.shape.closePath??!0;Ke(u,W,!1,Te,Y,j),s.fillStyle=B,Ct(s,Y,j)}else s.strokeStyle=B,s.beginPath(),le(s,C.shape),s.stroke()}else s.strokeStyle=B,s.beginPath(),le(s,C.shape),s.stroke()}else s.fillStyle=B,s.beginPath(),le(s,C.shape),_t(s,C.holes)?s.fill("evenodd"):s.fill();L&&s.restore()}}s.restore()}destroy(){this.shader=null}}Ee.extension={type:[R.CanvasPipesAdaptor],name:"graphics"};class Mt{init(e,t){this._renderer=e,this._renderTargetSystem=t}initGpuRenderTarget(e){const t=e.colorTexture,{canvas:a,context:n}=this._ensureCanvas(t);return{canvas:a,context:n,width:a.width,height:a.height}}resizeGpuRenderTarget(e){const t=e.colorTexture,{canvas:a}=this._ensureCanvas(t);a.width=e.pixelWidth,a.height=e.pixelHeight}startRenderPass(e,t,a,n){const s=this._renderTargetSystem.getGpuRenderTarget(e);this._renderer.canvasContext.activeContext=s.context,this._renderer.canvasContext.activeResolution=e.resolution,t&&this.clear(e,t,a,n)}clear(e,t,a,n){const r=this._renderTargetSystem.getGpuRenderTarget(e).context,i=n||{x:0,y:0,width:e.pixelWidth,height:e.pixelHeight};if(r.setTransform(1,0,0,1,0,0),r.clearRect(i.x,i.y,i.width,i.height),a){const c=ee.shared.setValue(a);c.alpha>0&&(r.globalAlpha=c.alpha,r.fillStyle=c.toHex(),r.fillRect(i.x,i.y,i.width,i.height),r.globalAlpha=1)}}finishRenderPass(){}copyToTexture(e,t,a,n,s){const i=this._renderTargetSystem.getGpuRenderTarget(e).canvas,c=t.source,{context:h}=this._ensureCanvas(c),l=(s==null?void 0:s.x)??0,f=(s==null?void 0:s.y)??0;return h.drawImage(i,a.x,a.y,n.width,n.height,l,f,n.width,n.height),c.update(),t}destroyGpuRenderTarget(e){}_ensureCanvas(e){let t=e.resource;(!t||!et.test(t))&&(t=E.get().createCanvas(e.pixelWidth,e.pixelHeight),e.resource=t),(t.width!==e.pixelWidth||t.height!==e.pixelHeight)&&(t.width=e.pixelWidth,t.height=e.pixelHeight);const a=t.getContext("2d");return{canvas:t,context:a}}}class Fe extends at{constructor(e){super(e),this.adaptor=new Mt,this.adaptor.init(e,this)}}Fe.extension={type:[R.CanvasSystem],name:"renderTarget"};class Ve{constructor(e){}init(){}initSource(e){}generateCanvas(e){const t=E.get().createCanvas(),a=t.getContext("2d"),n=d.getCanvasSource(e);if(!n)return t;const s=e.frame,r=e.source._resolution??e.source.resolution??1,i=s.x*r,c=s.y*r,h=s.width*r,l=s.height*r;return t.width=Math.ceil(h),t.height=Math.ceil(l),a.drawImage(n,i,c,h,l,0,0,h,l),t}getPixels(e){const t=this.generateCanvas(e);return{pixels:t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,t.width,t.height).data,width:t.width,height:t.height}}destroy(){}}Ve.extension={type:[R.CanvasSystem],name:"texture"};const bt=[...st,Ue,Oe,Ve,Fe],wt=[ot,rt,it,ct,lt,Ge,We,ht],kt=[dt,Ee],qe=[],Le=[],Ne=[];he.handleByNamedList(R.CanvasSystem,qe);he.handleByNamedList(R.CanvasPipes,Le);he.handleByNamedList(R.CanvasPipesAdaptor,Ne);he.add(...bt,...wt,...kt);class At extends tt{constructor(){const e={name:"canvas",type:nt.CANVAS,systems:qe,renderPipes:Le,renderPipeAdaptors:Ne};super(e)}}export{At as CanvasRenderer};
|