@kauakdev/kauak 0.0.0-stage → 0.1.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/LICENSE +202 -0
- package/README.md +186 -2
- package/bin/kauak.js +12 -0
- package/bridge/config.js +34 -0
- package/bridge/context_remote.py +344 -0
- package/bridge/diffs_remote.py +85 -0
- package/bridge/server.js +2387 -0
- package/cli/commands/serve.js +97 -0
- package/cli/errors.js +2 -0
- package/cli/main.js +101 -0
- package/dist/THIRD_PARTY_LICENSES.txt +183 -0
- package/dist/assets/BufferResource-CHYsmqd5.js +195 -0
- package/dist/assets/CanvasRenderer-DY1TnK1M.js +1 -0
- package/dist/assets/Filter-IrwvDh3w.js +1 -0
- package/dist/assets/RenderTargetSystem-CBR4meCp.js +184 -0
- package/dist/assets/WebGLRenderer-DprtkQRW.js +156 -0
- package/dist/assets/WebGPURenderer-ByQ-10KB.js +42 -0
- package/dist/assets/browserAll-B-9xDvMq.js +14 -0
- package/dist/assets/contours-DG3HeJNa.svg +68 -0
- package/dist/assets/demo-DyZsh87s.css +1 -0
- package/dist/assets/demo-mFndvU9t.js +5 -0
- package/dist/assets/index-BxvDL43s.css +32 -0
- package/dist/assets/index-Do5XwO_P.js +349 -0
- package/dist/assets/webworkerAll-gM2Z784I.js +83 -0
- package/dist/index.html +160 -0
- package/dist/kauak.png +0 -0
- package/package.json +24 -4
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// `kauak serve`: start the bridge, which also serves the built office page,
|
|
2
|
+
// and open it in the browser. Settings are the bridge's environment variables
|
|
3
|
+
// (see README); the options below are shortcuts for the common ones, and
|
|
4
|
+
// --appearance names package files the bridge serves beside the folder's.
|
|
5
|
+
|
|
6
|
+
import { spawn } from "node:child_process";
|
|
7
|
+
import fs from "node:fs";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import { fileURLToPath } from "node:url";
|
|
10
|
+
import { UsageError } from "../errors.js";
|
|
11
|
+
|
|
12
|
+
// The npm package carries a bundle of the bridge beside the CLI (packages/bridge/scripts/bundle.js
|
|
13
|
+
// makes it when packing); a checkout has none and runs the bridge's own source in packages/bridge.
|
|
14
|
+
const PACKED = fs.existsSync(new URL("../../bridge/server.js", import.meta.url));
|
|
15
|
+
// The page is built into this package's dist/: in the npm package as in a checkout (packages/kauak/dist).
|
|
16
|
+
const PAGE_DIR = fileURLToPath(new URL("../../dist/", import.meta.url));
|
|
17
|
+
|
|
18
|
+
export const name = "serve";
|
|
19
|
+
export const summary = "start the office and open it in the browser";
|
|
20
|
+
export const usage = `Usage: kauak serve [options]
|
|
21
|
+
|
|
22
|
+
Starts the bridge, which serves the office page and connects it to Herdr,
|
|
23
|
+
and opens the page in the browser. Runs until Ctrl+C.
|
|
24
|
+
|
|
25
|
+
Options:
|
|
26
|
+
-p, --port <n> port for the page and the bridge (default 7788)
|
|
27
|
+
--demo open the demo with simulated agents (no Herdr needed)
|
|
28
|
+
--no-open do not open the browser
|
|
29
|
+
--appearance <file> an appearance package (JSON) to offer in the page's
|
|
30
|
+
settings, besides those in ~/.config/kauak/appearances;
|
|
31
|
+
repeat it for several
|
|
32
|
+
-h, --help show this help
|
|
33
|
+
|
|
34
|
+
Environment: HERDR_SOCKET_PATH, KAUAK_PORT, KAUAK_HOST, KAUAK_ORIGINS,
|
|
35
|
+
KAUAK_CONFIG, KAUAK_APPEARANCES (see the README).
|
|
36
|
+
`;
|
|
37
|
+
export const options = {
|
|
38
|
+
port: { type: "string", short: "p" },
|
|
39
|
+
demo: { type: "boolean" },
|
|
40
|
+
"no-open": { type: "boolean" },
|
|
41
|
+
appearance: { type: "string", multiple: true },
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export async function run(values) {
|
|
45
|
+
const port = values.port;
|
|
46
|
+
if (port !== undefined && (!/^\d+$/.test(port) || Number(port) < 1 || Number(port) > 65535))
|
|
47
|
+
throw new UsageError(`invalid port '${port}' (use 1-65535)`);
|
|
48
|
+
const appearanceFiles = (values.appearance ?? []).map((file) => path.resolve(file));
|
|
49
|
+
for (const file of appearanceFiles) {
|
|
50
|
+
if (!file.toLowerCase().endsWith(".json")) throw new UsageError(`'${file}' is not a .json file (an appearance package is one)`);
|
|
51
|
+
if (!fs.statSync(file, { throwIfNoEntry: false })?.isFile()) throw new UsageError(`no such file '${file}'`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const { resolveConfig } = await import(PACKED ? "../../bridge/config.js" : "../../../bridge/src/config.ts");
|
|
55
|
+
const { createBridge } = await import(PACKED ? "../../bridge/server.js" : "../../../bridge/src/server.ts");
|
|
56
|
+
const config = resolveConfig(process.env, { port: port === undefined ? undefined : Number(port), pageDir: PAGE_DIR, appearanceFiles });
|
|
57
|
+
const bridge = createBridge(config);
|
|
58
|
+
// SSH tunnels and remote context readers are child processes; take them down with the bridge.
|
|
59
|
+
const shutdown = (code = 0) => {
|
|
60
|
+
bridge.close();
|
|
61
|
+
process.exit(code);
|
|
62
|
+
};
|
|
63
|
+
process.on("SIGINT", () => shutdown());
|
|
64
|
+
process.on("SIGTERM", () => shutdown());
|
|
65
|
+
process.on("exit", () => bridge.close());
|
|
66
|
+
|
|
67
|
+
let url;
|
|
68
|
+
try {
|
|
69
|
+
url = await bridge.listen();
|
|
70
|
+
} catch {
|
|
71
|
+
return 1; // the bridge has said why (the port is in use…)
|
|
72
|
+
}
|
|
73
|
+
if (!url) {
|
|
74
|
+
console.error("kauak: the office page is missing from this install (run `pnpm build` in a checkout)");
|
|
75
|
+
return 1;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const page = values.demo ? `${url}?demo` : url;
|
|
79
|
+
console.log(`\n kauak is running at ${page}\n`);
|
|
80
|
+
if (!values.demo && !fs.existsSync(config.herdrSocket)) {
|
|
81
|
+
console.log(` Herdr is not running on this machine (no socket at ${config.herdrSocket}).`);
|
|
82
|
+
console.log(` Start Herdr and the office picks it up on its own, or try the demo: npx @kauakdev/kauak serve --demo\n`);
|
|
83
|
+
}
|
|
84
|
+
console.log(" Press Ctrl+C to stop.\n");
|
|
85
|
+
if (!values["no-open"]) openBrowser(page);
|
|
86
|
+
// Nothing returned: the bridge keeps the process running until Ctrl+C.
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function openBrowser(target) {
|
|
90
|
+
const [cmd, ...rest] =
|
|
91
|
+
process.platform === "darwin" ? ["open"] : process.platform === "win32" ? ["cmd", "/c", "start", ""] : ["xdg-open"];
|
|
92
|
+
try {
|
|
93
|
+
const child = spawn(cmd, [...rest, target], { stdio: "ignore", detached: true });
|
|
94
|
+
child.on("error", () => {}); // no opener (headless box, SSH session): the URL above is enough
|
|
95
|
+
child.unref();
|
|
96
|
+
} catch {}
|
|
97
|
+
}
|
package/cli/errors.js
ADDED
package/cli/main.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// The kauak command line: `kauak [command] [options]`.
|
|
2
|
+
//
|
|
3
|
+
// bin/kauak.js passes its arguments to main(), which finds the command in
|
|
4
|
+
// COMMANDS, parses its options with node:util's parseArgs and runs it. A
|
|
5
|
+
// command is a module in cli/commands/ that exports
|
|
6
|
+
//
|
|
7
|
+
// name the word after `kauak`
|
|
8
|
+
// summary its line in `kauak --help`
|
|
9
|
+
// usage the text of `kauak <name> --help` and `kauak help <name>`
|
|
10
|
+
// options parseArgs options; -h/--help is added to every command
|
|
11
|
+
// run async (values) => an exit code, or nothing while it keeps the
|
|
12
|
+
// process running (as `serve` does, until Ctrl+C)
|
|
13
|
+
//
|
|
14
|
+
// so a new command is one module and one entry in COMMANDS, and the help lists
|
|
15
|
+
// it on its own. Commands stay thin: they read their options and hand the work
|
|
16
|
+
// to the application (`serve` starts the bridge). A command throws UsageError
|
|
17
|
+
// for a bad value; any other error is a bug and surfaces as one.
|
|
18
|
+
//
|
|
19
|
+
// `kauak` alone runs DEFAULT_COMMAND, and so does `kauak` followed by
|
|
20
|
+
// options: the whole command line goes to it (`kauak --demo` is
|
|
21
|
+
// `kauak serve --demo`). Global options count only as the first argument, so
|
|
22
|
+
// a new one must not reuse an option of serve's (-p/--port, --demo,
|
|
23
|
+
// --no-open), or `kauak <that option>` would stop reaching serve.
|
|
24
|
+
//
|
|
25
|
+
// Exit codes: 0 done (help and --version too), 1 the command failed,
|
|
26
|
+
// 2 the command line is wrong (unknown command, bad option).
|
|
27
|
+
|
|
28
|
+
import fs from "node:fs";
|
|
29
|
+
import { parseArgs } from "node:util";
|
|
30
|
+
import * as serve from "./commands/serve.js";
|
|
31
|
+
import { UsageError } from "./errors.js";
|
|
32
|
+
|
|
33
|
+
export const COMMANDS = [serve];
|
|
34
|
+
const DEFAULT_COMMAND = serve;
|
|
35
|
+
|
|
36
|
+
const HELP_OPTION = { type: "boolean", short: "h" };
|
|
37
|
+
|
|
38
|
+
export async function main(argv) {
|
|
39
|
+
const [first, ...rest] = argv;
|
|
40
|
+
if (first === "-v" || first === "--version") return print(`${version()}\n`);
|
|
41
|
+
if (first === "help" || first === "-h" || first === "--help") {
|
|
42
|
+
if (!rest.length) return print(help());
|
|
43
|
+
const command = COMMANDS.find((c) => c.name === rest[0]);
|
|
44
|
+
return command ? print(command.usage) : usageError("kauak", `unknown command '${rest[0]}'`, help());
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const named = first !== undefined && !first.startsWith("-");
|
|
48
|
+
const command = named ? COMMANDS.find((c) => c.name === first) : DEFAULT_COMMAND;
|
|
49
|
+
if (!command) return usageError("kauak", `unknown command '${first}'`, help());
|
|
50
|
+
|
|
51
|
+
let values;
|
|
52
|
+
try {
|
|
53
|
+
({ values } = parseArgs({ args: named ? rest : argv, options: { ...command.options, help: HELP_OPTION }, strict: true }));
|
|
54
|
+
} catch (err) {
|
|
55
|
+
if (!err.code?.startsWith("ERR_PARSE_ARGS_")) throw err;
|
|
56
|
+
return usageError(`kauak ${command.name}`, err.message, command.usage);
|
|
57
|
+
}
|
|
58
|
+
if (values.help) return print(command.usage);
|
|
59
|
+
try {
|
|
60
|
+
return await command.run(values);
|
|
61
|
+
} catch (err) {
|
|
62
|
+
if (!(err instanceof UsageError)) throw err;
|
|
63
|
+
return usageError(`kauak ${command.name}`, err.message, command.usage);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function help() {
|
|
68
|
+
// Command names line up with the options below ("-v, --version").
|
|
69
|
+
const width = Math.max(13, ...COMMANDS.map((c) => c.name.length));
|
|
70
|
+
return `Usage: kauak [command] [options]
|
|
71
|
+
|
|
72
|
+
Shows your Herdr coding agents as a live isometric office.
|
|
73
|
+
|
|
74
|
+
Commands:
|
|
75
|
+
${COMMANDS.map((c) => ` ${c.name.padEnd(width)} ${c.summary}`).join("\n")}
|
|
76
|
+
|
|
77
|
+
Options:
|
|
78
|
+
-h, --help show this help
|
|
79
|
+
-v, --version print the version
|
|
80
|
+
|
|
81
|
+
Run \`kauak help <command>\` for a command's options.
|
|
82
|
+
To start the office: kauak serve (or kauak serve --demo, no Herdr needed)
|
|
83
|
+
\`kauak\` alone runs \`kauak serve\`, and \`kauak --demo\` is \`kauak serve --demo\`.
|
|
84
|
+
`;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Read from the package itself, wherever it is installed. */
|
|
88
|
+
function version() {
|
|
89
|
+
return JSON.parse(fs.readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function print(text) {
|
|
93
|
+
process.stdout.write(text);
|
|
94
|
+
return 0;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function usageError(prefix, message, usage) {
|
|
98
|
+
// parseArgs messages start with a capital ("Unknown option '--x'").
|
|
99
|
+
process.stderr.write(`${prefix}: ${message[0].toLowerCase()}${message.slice(1)}\n\n${usage}`);
|
|
100
|
+
return 2;
|
|
101
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
The kauak office page (index.html and assets/) bundles the third-party
|
|
2
|
+
packages below. Each is listed with the license it is distributed under.
|
|
3
|
+
|
|
4
|
+
------------------------------------------------------------------------
|
|
5
|
+
@pixi/colord 2.9.6 (MIT)
|
|
6
|
+
|
|
7
|
+
The package includes no license file. Its package.json gives the license as MIT and the author as Vlad Shilov <omgovich@ya.ru>.
|
|
8
|
+
|
|
9
|
+
------------------------------------------------------------------------
|
|
10
|
+
@xterm/xterm 6.0.0 (MIT)
|
|
11
|
+
|
|
12
|
+
Copyright (c) 2017-2019, The xterm.js authors (https://github.com/xtermjs/xterm.js)
|
|
13
|
+
Copyright (c) 2014-2016, SourceLair Private Company (https://www.sourcelair.com)
|
|
14
|
+
Copyright (c) 2012-2013, Christopher Jeffrey (https://github.com/chjj/)
|
|
15
|
+
|
|
16
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
17
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
18
|
+
in the Software without restriction, including without limitation the rights
|
|
19
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
20
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
21
|
+
furnished to do so, subject to the following conditions:
|
|
22
|
+
|
|
23
|
+
The above copyright notice and this permission notice shall be included in
|
|
24
|
+
all copies or substantial portions of the Software.
|
|
25
|
+
|
|
26
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
27
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
28
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
29
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
30
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
31
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
32
|
+
THE SOFTWARE.
|
|
33
|
+
|
|
34
|
+
------------------------------------------------------------------------
|
|
35
|
+
earcut 3.2.3 (ISC)
|
|
36
|
+
|
|
37
|
+
ISC License
|
|
38
|
+
|
|
39
|
+
Copyright (c) 2026, Mapbox
|
|
40
|
+
|
|
41
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
42
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
|
43
|
+
and this permission notice appear in all copies.
|
|
44
|
+
|
|
45
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
46
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
47
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
48
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
49
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
50
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
51
|
+
THIS SOFTWARE.
|
|
52
|
+
|
|
53
|
+
------------------------------------------------------------------------
|
|
54
|
+
eventemitter3 5.0.4 (MIT)
|
|
55
|
+
|
|
56
|
+
The MIT License (MIT)
|
|
57
|
+
|
|
58
|
+
Copyright (c) 2014 Arnout Kazemier
|
|
59
|
+
|
|
60
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
61
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
62
|
+
in the Software without restriction, including without limitation the rights
|
|
63
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
64
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
65
|
+
furnished to do so, subject to the following conditions:
|
|
66
|
+
|
|
67
|
+
The above copyright notice and this permission notice shall be included in all
|
|
68
|
+
copies or substantial portions of the Software.
|
|
69
|
+
|
|
70
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
71
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
72
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
73
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
74
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
75
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
76
|
+
SOFTWARE.
|
|
77
|
+
|
|
78
|
+
------------------------------------------------------------------------
|
|
79
|
+
ismobilejs 1.1.1 (MIT)
|
|
80
|
+
|
|
81
|
+
MIT License
|
|
82
|
+
|
|
83
|
+
Copyright (c) 2019 Kai Mallea
|
|
84
|
+
|
|
85
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
86
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
87
|
+
in the Software without restriction, including without limitation the rights
|
|
88
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
89
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
90
|
+
furnished to do so, subject to the following conditions:
|
|
91
|
+
|
|
92
|
+
The above copyright notice and this permission notice shall be included in all
|
|
93
|
+
copies or substantial portions of the Software.
|
|
94
|
+
|
|
95
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
96
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
97
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
98
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
99
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
100
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
101
|
+
SOFTWARE.
|
|
102
|
+
|
|
103
|
+
------------------------------------------------------------------------
|
|
104
|
+
parse-svg-path 0.2.0 (MIT)
|
|
105
|
+
|
|
106
|
+
The MIT License
|
|
107
|
+
|
|
108
|
+
Copyright (c) 2013 Jake Rosoman <jkroso@gmail.com>
|
|
109
|
+
|
|
110
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
111
|
+
a copy of this software and associated documentation files (the
|
|
112
|
+
'Software'), to deal in the Software without restriction, including
|
|
113
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
114
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
115
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
116
|
+
the following conditions:
|
|
117
|
+
|
|
118
|
+
The above copyright notice and this permission notice shall be
|
|
119
|
+
included in all copies or substantial portions of the Software.
|
|
120
|
+
|
|
121
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
122
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
123
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
124
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
125
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
126
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
127
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
128
|
+
|
|
129
|
+
------------------------------------------------------------------------
|
|
130
|
+
pixi.js 8.21.0 (MIT)
|
|
131
|
+
|
|
132
|
+
The MIT License
|
|
133
|
+
|
|
134
|
+
Copyright (c) 2013-2023 Mathew Groves, Chad Engler
|
|
135
|
+
|
|
136
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
137
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
138
|
+
in the Software without restriction, including without limitation the rights
|
|
139
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
140
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
141
|
+
furnished to do so, subject to the following conditions:
|
|
142
|
+
|
|
143
|
+
The above copyright notice and this permission notice shall be included in
|
|
144
|
+
all copies or substantial portions of the Software.
|
|
145
|
+
|
|
146
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
147
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
148
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
149
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
150
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
151
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
152
|
+
THE SOFTWARE.
|
|
153
|
+
|
|
154
|
+
------------------------------------------------------------------------
|
|
155
|
+
tiny-lru 11.4.7 (BSD-3-Clause)
|
|
156
|
+
|
|
157
|
+
Copyright (c) 2026, Jason Mulligan
|
|
158
|
+
All rights reserved.
|
|
159
|
+
|
|
160
|
+
Redistribution and use in source and binary forms, with or without
|
|
161
|
+
modification, are permitted provided that the following conditions are met:
|
|
162
|
+
|
|
163
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
164
|
+
list of conditions and the following disclaimer.
|
|
165
|
+
|
|
166
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
167
|
+
this list of conditions and the following disclaimer in the documentation
|
|
168
|
+
and/or other materials provided with the distribution.
|
|
169
|
+
|
|
170
|
+
* Neither the name of tiny-lru nor the names of its
|
|
171
|
+
contributors may be used to endorse or promote products derived from
|
|
172
|
+
this software without specific prior written permission.
|
|
173
|
+
|
|
174
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
175
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
176
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
177
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
178
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
179
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
180
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
181
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
182
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
183
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import{w as _,g,d as c,u as U,B as y,e as l,E as I,f as m}from"./index-Do5XwO_P.js";const h={name:"local-uniform-bit",vertex:{header:`
|
|
2
|
+
|
|
3
|
+
struct LocalUniforms {
|
|
4
|
+
uTransformMatrix:mat3x3<f32>,
|
|
5
|
+
uColor:vec4<f32>,
|
|
6
|
+
uRound:f32,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
@group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;
|
|
10
|
+
`,main:`
|
|
11
|
+
vColor *= localUniforms.uColor;
|
|
12
|
+
modelMatrix *= localUniforms.uTransformMatrix;
|
|
13
|
+
`,end:`
|
|
14
|
+
if(localUniforms.uRound == 1)
|
|
15
|
+
{
|
|
16
|
+
vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
|
|
17
|
+
}
|
|
18
|
+
`}},E={...h,vertex:{...h.vertex,header:h.vertex.header.replace("group(1)","group(2)")}},B={name:"local-uniform-bit",vertex:{header:`
|
|
19
|
+
|
|
20
|
+
uniform mat3 uTransformMatrix;
|
|
21
|
+
uniform vec4 uColor;
|
|
22
|
+
uniform float uRound;
|
|
23
|
+
`,main:`
|
|
24
|
+
vColor *= uColor;
|
|
25
|
+
modelMatrix = uTransformMatrix;
|
|
26
|
+
`,end:`
|
|
27
|
+
if(uRound == 1.)
|
|
28
|
+
{
|
|
29
|
+
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
|
|
30
|
+
}
|
|
31
|
+
`}},C={name:"texture-bit",vertex:{header:`
|
|
32
|
+
|
|
33
|
+
struct TextureUniforms {
|
|
34
|
+
uTextureMatrix:mat3x3<f32>,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;
|
|
38
|
+
`,main:`
|
|
39
|
+
uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;
|
|
40
|
+
`},fragment:{header:`
|
|
41
|
+
@group(2) @binding(0) var uTexture: texture_2d<f32>;
|
|
42
|
+
@group(2) @binding(1) var uSampler: sampler;
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
`,main:`
|
|
46
|
+
outColor = textureSample(uTexture, uSampler, vUV);
|
|
47
|
+
`}},D={name:"texture-bit",vertex:{header:`
|
|
48
|
+
uniform mat3 uTextureMatrix;
|
|
49
|
+
`,main:`
|
|
50
|
+
uv = (uTextureMatrix * vec3(uv, 1.0)).xy;
|
|
51
|
+
`},fragment:{header:`
|
|
52
|
+
uniform sampler2D uTexture;
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
`,main:`
|
|
56
|
+
outColor = texture(uTexture, vUV);
|
|
57
|
+
`}};function O(e,t){for(const a in e.attributes){const s=e.attributes[a],f=t[a];f?(s.format??(s.format=f.format),s.offset??(s.offset=f.offset),s.instance??(s.instance=f.instance)):_(`Attribute ${a} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}S(e)}function S(e){const{buffers:t,attributes:a}=e,s={},f={};for(const o in t){const r=t[o];s[r.uid]=0,f[r.uid]=0}for(const o in a){const r=a[o];s[r.buffer.uid]+=g(r.format).stride}for(const o in a){const r=a[o];r.stride??(r.stride=s[r.buffer.uid]),r.start??(r.start=f[r.buffer.uid]),f[r.buffer.uid]+=g(r.format).stride}}const d=[];d[c.NONE]=void 0;d[c.DISABLED]={stencilWriteMask:0,stencilReadMask:0};d[c.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}};d[c.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}};d[c.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}};d[c.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}};class R{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!U())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}ensureUniformGroup(t){const a=this.getUniformGroupData(t);t.buffer||(t.buffer=new y({data:new Float32Array(a.layout.size/4),usage:l.UNIFORM|l.COPY_DST}))}getUniformGroupData(t){return this._syncFunctionHash[t._signature]||this._initUniformGroup(t)}_initUniformGroup(t){const a=t._signature;let s=this._syncFunctionHash[a];if(!s){const f=Object.keys(t.uniformStructures).map(n=>t.uniformStructures[n]),o=this._adaptor.createUboElements(f),r=this._generateUboSync(o.uboElements);s=this._syncFunctionHash[a]={layout:o,syncFunction:r}}return this._syncFunctionHash[a]}_generateUboSync(t){return this._adaptor.generateUboSync(t)}syncUniformGroup(t,a,s){const f=this.getUniformGroupData(t);t.buffer||(t.buffer=new y({data:new Float32Array(f.layout.size/4),usage:l.UNIFORM|l.COPY_DST}));let o=null;return a||(a=t.buffer.data,o=t.buffer.dataInt32),s||(s=0),f.syncFunction(t.uniforms,a,o,s),!0}updateUniformGroup(t){if(t.isStatic&&!t._dirtyId)return!1;t._dirtyId=0;const a=this.syncUniformGroup(t);return t.buffer.update(),a}destroy(){this._syncFunctionHash=null}}const p=[{type:"mat3x3<f32>",test:e=>e.value.a!==void 0,ubo:`
|
|
58
|
+
var matrix = uv[name].toArray(true);
|
|
59
|
+
data[offset] = matrix[0];
|
|
60
|
+
data[offset + 1] = matrix[1];
|
|
61
|
+
data[offset + 2] = matrix[2];
|
|
62
|
+
data[offset + 4] = matrix[3];
|
|
63
|
+
data[offset + 5] = matrix[4];
|
|
64
|
+
data[offset + 6] = matrix[5];
|
|
65
|
+
data[offset + 8] = matrix[6];
|
|
66
|
+
data[offset + 9] = matrix[7];
|
|
67
|
+
data[offset + 10] = matrix[8];
|
|
68
|
+
`,uniform:`
|
|
69
|
+
gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));
|
|
70
|
+
`},{type:"vec4<f32>",test:e=>e.type==="vec4<f32>"&&e.size===1&&e.value.width!==void 0,ubo:`
|
|
71
|
+
v = uv[name];
|
|
72
|
+
data[offset] = v.x;
|
|
73
|
+
data[offset + 1] = v.y;
|
|
74
|
+
data[offset + 2] = v.width;
|
|
75
|
+
data[offset + 3] = v.height;
|
|
76
|
+
`,uniform:`
|
|
77
|
+
cv = ud[name].value;
|
|
78
|
+
v = uv[name];
|
|
79
|
+
if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {
|
|
80
|
+
cv[0] = v.x;
|
|
81
|
+
cv[1] = v.y;
|
|
82
|
+
cv[2] = v.width;
|
|
83
|
+
cv[3] = v.height;
|
|
84
|
+
gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);
|
|
85
|
+
}
|
|
86
|
+
`},{type:"vec2<f32>",test:e=>e.type==="vec2<f32>"&&e.size===1&&e.value.x!==void 0,ubo:`
|
|
87
|
+
v = uv[name];
|
|
88
|
+
data[offset] = v.x;
|
|
89
|
+
data[offset + 1] = v.y;
|
|
90
|
+
`,uniform:`
|
|
91
|
+
cv = ud[name].value;
|
|
92
|
+
v = uv[name];
|
|
93
|
+
if (cv[0] !== v.x || cv[1] !== v.y) {
|
|
94
|
+
cv[0] = v.x;
|
|
95
|
+
cv[1] = v.y;
|
|
96
|
+
gl.uniform2f(ud[name].location, v.x, v.y);
|
|
97
|
+
}
|
|
98
|
+
`},{type:"vec4<f32>",test:e=>e.type==="vec4<f32>"&&e.size===1&&e.value.red!==void 0,ubo:`
|
|
99
|
+
v = uv[name];
|
|
100
|
+
data[offset] = v.red;
|
|
101
|
+
data[offset + 1] = v.green;
|
|
102
|
+
data[offset + 2] = v.blue;
|
|
103
|
+
data[offset + 3] = v.alpha;
|
|
104
|
+
`,uniform:`
|
|
105
|
+
cv = ud[name].value;
|
|
106
|
+
v = uv[name];
|
|
107
|
+
if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {
|
|
108
|
+
cv[0] = v.red;
|
|
109
|
+
cv[1] = v.green;
|
|
110
|
+
cv[2] = v.blue;
|
|
111
|
+
cv[3] = v.alpha;
|
|
112
|
+
gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);
|
|
113
|
+
}
|
|
114
|
+
`},{type:"vec3<f32>",test:e=>e.type==="vec3<f32>"&&e.size===1&&e.value.red!==void 0,ubo:`
|
|
115
|
+
v = uv[name];
|
|
116
|
+
data[offset] = v.red;
|
|
117
|
+
data[offset + 1] = v.green;
|
|
118
|
+
data[offset + 2] = v.blue;
|
|
119
|
+
`,uniform:`
|
|
120
|
+
cv = ud[name].value;
|
|
121
|
+
v = uv[name];
|
|
122
|
+
if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {
|
|
123
|
+
cv[0] = v.red;
|
|
124
|
+
cv[1] = v.green;
|
|
125
|
+
cv[2] = v.blue;
|
|
126
|
+
gl.uniform3f(ud[name].location, v.red, v.green, v.blue);
|
|
127
|
+
}
|
|
128
|
+
`}];function A(e,t,a){const s=[`
|
|
129
|
+
var v = null;
|
|
130
|
+
var v2 = null;
|
|
131
|
+
var t = 0;
|
|
132
|
+
var index = 0;
|
|
133
|
+
var name = null;
|
|
134
|
+
var arrayOffset = null;
|
|
135
|
+
`];let f=0;for(let r=0;r<e.length;r++){const n=e[r],x=n.data.name;let b=!1,i=0;for(let u=0;u<p.length;u++)if(p[u].test(n.data)){i=n.offset/4,s.push(`name = "${x}";`,`offset += ${i-f};`,p[u].ubo),b=!0;break}if(!b)if(n.data.size>1)i=n.offset/4,s.push(a(n,i-f));else{const u=t[n.data.type];i=n.offset/4,s.push(`
|
|
136
|
+
v = uv.${x};
|
|
137
|
+
offset += ${i-f};
|
|
138
|
+
${u};
|
|
139
|
+
`)}f=i}const o=s.join(`
|
|
140
|
+
`);return new Function("uv","data","dataInt32","offset",o)}function v(e,t){return`
|
|
141
|
+
for (let i = 0; i < ${e*t}; i++) {
|
|
142
|
+
data[offset + (((i / ${e})|0) * 4) + (i % ${e})] = v[i];
|
|
143
|
+
}
|
|
144
|
+
`}const M={f32:`
|
|
145
|
+
data[offset] = v;`,i32:`
|
|
146
|
+
dataInt32[offset] = v;`,u32:`
|
|
147
|
+
dataInt32[offset] = v;`,"vec2<f32>":`
|
|
148
|
+
data[offset] = v[0];
|
|
149
|
+
data[offset + 1] = v[1];`,"vec3<f32>":`
|
|
150
|
+
data[offset] = v[0];
|
|
151
|
+
data[offset + 1] = v[1];
|
|
152
|
+
data[offset + 2] = v[2];`,"vec4<f32>":`
|
|
153
|
+
data[offset] = v[0];
|
|
154
|
+
data[offset + 1] = v[1];
|
|
155
|
+
data[offset + 2] = v[2];
|
|
156
|
+
data[offset + 3] = v[3];`,"vec2<i32>":`
|
|
157
|
+
dataInt32[offset] = v[0];
|
|
158
|
+
dataInt32[offset + 1] = v[1];`,"vec3<i32>":`
|
|
159
|
+
dataInt32[offset] = v[0];
|
|
160
|
+
dataInt32[offset + 1] = v[1];
|
|
161
|
+
dataInt32[offset + 2] = v[2];`,"vec4<i32>":`
|
|
162
|
+
dataInt32[offset] = v[0];
|
|
163
|
+
dataInt32[offset + 1] = v[1];
|
|
164
|
+
dataInt32[offset + 2] = v[2];
|
|
165
|
+
dataInt32[offset + 3] = v[3];`,"vec2<u32>":`
|
|
166
|
+
dataInt32[offset] = v[0];
|
|
167
|
+
dataInt32[offset + 1] = v[1];`,"vec3<u32>":`
|
|
168
|
+
dataInt32[offset] = v[0];
|
|
169
|
+
dataInt32[offset + 1] = v[1];
|
|
170
|
+
dataInt32[offset + 2] = v[2];`,"vec4<u32>":`
|
|
171
|
+
dataInt32[offset] = v[0];
|
|
172
|
+
dataInt32[offset + 1] = v[1];
|
|
173
|
+
dataInt32[offset + 2] = v[2];
|
|
174
|
+
dataInt32[offset + 3] = v[3];`,"mat2x2<f32>":`
|
|
175
|
+
data[offset] = v[0];
|
|
176
|
+
data[offset + 1] = v[1];
|
|
177
|
+
data[offset + 4] = v[2];
|
|
178
|
+
data[offset + 5] = v[3];`,"mat3x3<f32>":`
|
|
179
|
+
data[offset] = v[0];
|
|
180
|
+
data[offset + 1] = v[1];
|
|
181
|
+
data[offset + 2] = v[2];
|
|
182
|
+
data[offset + 4] = v[3];
|
|
183
|
+
data[offset + 5] = v[4];
|
|
184
|
+
data[offset + 6] = v[5];
|
|
185
|
+
data[offset + 8] = v[6];
|
|
186
|
+
data[offset + 9] = v[7];
|
|
187
|
+
data[offset + 10] = v[8];`,"mat4x4<f32>":`
|
|
188
|
+
for (let i = 0; i < 16; i++) {
|
|
189
|
+
data[offset + i] = v[i];
|
|
190
|
+
}`,"mat3x2<f32>":v(3,2),"mat4x2<f32>":v(4,2),"mat2x3<f32>":v(2,3),"mat4x3<f32>":v(4,3),"mat2x4<f32>":v(2,4),"mat3x4<f32>":v(3,4)},k={...M,"mat2x2<f32>":`
|
|
191
|
+
data[offset] = v[0];
|
|
192
|
+
data[offset + 1] = v[1];
|
|
193
|
+
data[offset + 2] = v[2];
|
|
194
|
+
data[offset + 3] = v[3];
|
|
195
|
+
`};class w extends I{constructor({buffer:t,offset:a,size:s}){super(),this.uid=m("buffer"),this._resourceType="bufferResource",this._resourceId=m("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=t,this.offset=a|0,this.size=s,this.buffer.on("change",this.onBufferChange,this)}get _gcLastUsed(){var t;return((t=this.buffer)==null?void 0:t._gcLastUsed)??-1}set _gcLastUsed(t){this.buffer&&(this.buffer._gcLastUsed=t)}onBufferChange(){this._resourceId=m("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null,this.removeAllListeners()}}export{w as B,d as G,R as U,h as a,M as b,A as c,p as d,O as e,B as f,D as g,E as l,C as t,k as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as P,i as Se,j as Me,m as oe,M as G,l as S,n as Xe,w as we,o as Re,p as Ie,q as ze,C as Ae,T as Be,r as Je,F as Ke,t as Qe,v as Ze,D as He,A as et,R as tt,x as ne}from"./index-Do5XwO_P.js";import{R as st,S as nt,B as at,a as rt,b as ot,c as it,A as ct,C as lt}from"./RenderTargetSystem-CBR4meCp.js";import"./Filter-IrwvDh3w.js";const ge=class X{static _getPatternRepeat(e,t){const s=e&&e!=="clamp-to-edge",n=t&&t!=="clamp-to-edge";return s&&n?"repeat":s?"repeat-x":n?"repeat-y":"no-repeat"}start(e,t,s){}execute(e,t){var c,i,l,u;const s=t.elements;if(!s||!s.length)return;const n=e.renderer,r=n.canvasContext,o=r.activeContext;for(let x=0;x<s.length;x++){const E=s[x];if(!E.packAsQuad)continue;const v=E,f=v.texture,M=f?P.getCanvasSource(f):null;if(!M)continue;const y=f.source.style,A=r.smoothProperty,Y=y.scaleMode!=="nearest";o[A]!==Y&&(o[A]=Y),r.setBlendMode(t.blendMode);const U=((c=n.globalUniforms.globalUniformData)==null?void 0:c.worldColor)??4294967295,W=v.color,k=(U>>>24&255)/255,C=(W>>>24&255)/255,V=((i=n.filter)==null?void 0:i.alphaMultiplier)??1,Q=k*C*V;if(Q<=0)continue;o.globalAlpha=Q;const Z=U&16777215,z=W&16777215,_=Me(oe(z,Z)),w=f.frame,R=y.addressModeU??y.addressMode,ce=y.addressModeV??y.addressMode,ee=X._getPatternRepeat(R,ce),q=f.source._resolution??f.source.resolution??1,$=(u=(l=v.renderable)==null?void 0:l.renderGroup)==null?void 0:u.isCachedAsTexture,p=w.x*q,m=w.y*q,g=w.width*q,L=w.height*q,I=v.bounds,b=n.renderTarget.renderTarget.isRoot,D=I.minX,F=I.minY,B=I.maxX-I.minX,H=I.maxY-I.minY,N=f.rotate,h=f.uvs,O=Math.min(h.x0,h.x1,h.x2,h.x3,h.y0,h.y1,h.y2,h.y3),j=Math.max(h.x0,h.x1,h.x2,h.x3,h.y0,h.y1,h.y2,h.y3),T=ee!=="no-repeat"&&(O<0||j>1),ae=N&&!(!T&&(_!==16777215||N));ae?(X._tempPatternMatrix.copyFrom(v.transform),Se.matrixAppendRotationInv(X._tempPatternMatrix,N,D,F,B,H),r.setContextTransform(X._tempPatternMatrix,v.roundPixels===1,void 0,$&&b)):r.setContextTransform(v.transform,v.roundPixels===1,void 0,$&&b);const le=B,he=H;let te=ae?0:D,se=ae?0:F;if(!ae&&v.roundPixels===1&&(te|=0,se|=0),T){let de=M;const J=_!==16777215&&!N,K=w.width<=f.source.width&&w.height<=f.source.height;J&&K&&(de=P.getTintedCanvas({texture:f},_));const pe=o.createPattern(de,ee);if(!pe)continue;const ye=le,xe=he;if(ye===0||xe===0)continue;const Ce=1/ye,Te=1/xe,Pe=(h.x1-h.x0)*Ce,ke=(h.y1-h.y0)*Ce,_e=(h.x3-h.x0)*Te,be=(h.y3-h.y0)*Te,Ve=h.x0-Pe*te-_e*se,$e=h.y0-ke*te-be*se,ue=f.source.pixelWidth,me=f.source.pixelHeight;X._tempPatternMatrix.set(Pe*ue,ke*me,_e*ue,be*me,Ve*ue,$e*me),P.applyPatternTransform(pe,X._tempPatternMatrix),o.fillStyle=pe,o.fillRect(te,se,le,he)}else{const J=_!==16777215||N?P.getTintedCanvas({texture:f},_):M,K=J!==M;o.drawImage(J,K?0:p,K?0:m,K?J.width:g,K?J.height:L,te,se,le,he)}}}};ge._tempPatternMatrix=new G;ge.extension={type:[S.CanvasPipesAdaptor],name:"batch"};let ht=ge;class Ge{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,s){this._renderer.renderPipes.batch.break(s);const n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&e.mask;const r=this._colorStack[this._colorStackIndex];r!==this._currentColor&&(this._currentColor=r,s.add({renderPipeId:"colorMask",colorMask:r,canBundle:!1})),this._colorStackIndex++}pop(e,t,s){this._renderer.renderPipes.batch.break(s);const n=this._colorStack;this._colorStackIndex--;const r=n[this._colorStackIndex-1];r!==this._currentColor&&(this._currentColor=r,s.add({renderPipeId:"colorMask",colorMask:r,canBundle:!1}))}execute(e){}destroy(){this._renderer=null,this._colorStack=null}}Ge.extension={type:[S.CanvasPipes],name:"colorMask"};function dt(a,e,t,s,n,r){r=Math.max(0,Math.min(r,Math.min(s,n)/2)),a.moveTo(e+r,t),a.lineTo(e+s-r,t),a.quadraticCurveTo(e+s,t,e+s,t+r),a.lineTo(e+s,t+n-r),a.quadraticCurveTo(e+s,t+n,e+s-r,t+n),a.lineTo(e+r,t+n),a.quadraticCurveTo(e,t+n,e,t+n-r),a.lineTo(e,t+r),a.quadraticCurveTo(e,t,e+r,t)}function Ee(a,e){switch(e.type){case"rectangle":{const t=e;a.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;dt(a,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;a.moveTo(t.x+t.radius,t.y),a.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;a.ellipse?(a.moveTo(t.x+t.halfWidth,t.y),a.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2)):(a.save(),a.translate(t.x,t.y),a.scale(t.halfWidth,t.halfHeight),a.moveTo(1,0),a.arc(0,0,1,0,Math.PI*2),a.restore());break}case"triangle":{const t=e;a.moveTo(t.x,t.y),a.lineTo(t.x2,t.y2),a.lineTo(t.x3,t.y3),a.closePath();break}case"polygon":default:{const t=e,s=t.points;if(!(s!=null&&s.length))break;a.moveTo(s[0],s[1]);for(let n=2;n<s.length;n+=2)a.lineTo(s[n],s[n+1]);t.closePath&&a.closePath();break}}}function pt(a,e,t){const s=[],n=[],r=[],o=Re[e.type];if(!(o!=null&&o.build(e,s)))return!1;const c=e.closePath??!0;Ie(s,t,!1,c,n,r);for(let i=0;i<r.length;i+=3){const l=r[i]*2,u=r[i+1]*2,x=r[i+2]*2;a.moveTo(n[l],n[l+1]),a.lineTo(n[u],n[u+1]),a.lineTo(n[x],n[x+1]),a.closePath()}return!0}function ut(a,e){if(!(e!=null&&e.length))return!1;for(let t=0;t<e.length;t++){const s=e[t];if(!(s!=null&&s.shape))continue;const n=s.transform,r=n&&!n.isIdentity();r&&(a.save(),a.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),Ee(a,s.shape),r&&a.restore()}return!0}class We{constructor(e){this._warnedMaskTypes=new Set,this._canvasMaskStack=[],this._renderer=e}push(e,t,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"stencilMask",action:"popMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){var u,x,E;if(e.action!=="pushMaskBegin"&&e.action!=="popMaskEnd")return;const t=this._renderer,s=t.canvasContext,n=s==null?void 0:s.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 r=e.mask.mask;if(!(r instanceof Xe)){this._warnOnce("nonGraphics","CanvasRenderer: only Graphics masks are supported in Canvas2D; skipping mask."),this._canvasMaskStack.push(!1);return}const o=r,c=(u=o.context)==null?void 0:u.instructions;if(!(c!=null&&c.length)){this._canvasMaskStack.push(!1);return}n.save(),s.setContextTransform(o.groupTransform,(t._roundPixels|o._roundPixels)===1),n.beginPath();let i=!1,l=!1;for(let v=0;v<c.length;v++){const f=c[v],M=f.action;if(M!=="fill"&&M!=="stroke")continue;const y=f.data,A=(x=y==null?void 0:y.path)==null?void 0:x.shapePath;if(!((E=A==null?void 0:A.shapePrimitives)!=null&&E.length))continue;const Y=M==="stroke",U=A.shapePrimitives;for(let W=0;W<U.length;W++){const k=U[W];if(!(k!=null&&k.shape))continue;const C=k.transform,V=C&&!C.isIdentity();V&&(n.save(),n.transform(C.a,C.b,C.c,C.d,C.tx,C.ty)),Y&&y.style?i=pt(n,k.shape,y.style)||i:(Ee(n,k.shape),l=ut(n,k.holes)||l,i=!0),V&&n.restore()}}if(!i){n.restore(),this._canvasMaskStack.push(!1);return}l?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),we(t))}}We.extension={type:[S.CanvasPipes],name:"stencilMask"};const d="source-over";function mt(){const a=ze(),e=Object.create(null);return e.inherit=d,e.none=d,e.normal="source-over",e.add="lighter",e.multiply=a?"multiply":d,e.screen=a?"screen":d,e.overlay=a?"overlay":d,e.darken=a?"darken":d,e.lighten=a?"lighten":d,e["color-dodge"]=a?"color-dodge":d,e["color-burn"]=a?"color-burn":d,e["hard-light"]=a?"hard-light":d,e["soft-light"]=a?"soft-light":d,e.difference=a?"difference":d,e.exclusion=a?"exclusion":d,e.saturation=a?"saturation":d,e.color=a?"color":d,e.luminosity=a?"luminosity":d,e["linear-burn"]=a?"color-burn":d,e["linear-dodge"]=a?"color-dodge":d,e["linear-light"]=a?"hard-light":d,e["pin-light"]=a?"hard-light":d,e["vivid-light"]=a?"hard-light":d,e["hard-mix"]=d,e.negation=a?"difference":d,e["normal-npm"]=e.normal,e["add-npm"]=e.add,e["screen-npm"]=e.screen,e.erase="destination-out",e.subtract=d,e.divide=d,e.min=d,e.max=d,e}const ft=new G;class De{constructor(e){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=mt(),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,s,n){var l;const r=n?G.IDENTITY:((l=this._renderer.globalUniforms.globalUniformData)==null?void 0:l.worldTransformMatrix)||G.IDENTITY;let o=ft;o.copyFrom(r),o.append(e);const c=this._projTransform,i=this.activeResolution;if(s=s||i,c){const u=G.shared;u.copyFrom(o),u.prepend(c),o=u}t?this.activeContext.setTransform(o.a*s,o.b*s,o.c*s,o.d*s,o.tx*i|0,o.ty*i|0):this.activeContext.setTransform(o.a*s,o.b*s,o.c*s,o.d*s,o.tx*i,o.ty*i)}clear(e,t){const s=this.activeContext,n=this._renderer;if(s.clearRect(0,0,n.width,n.height),e){const r=Ae.shared.setValue(e);s.globalAlpha=t??r.alpha,s.fillStyle=r.toHex(),s.fillRect(0,0,n.width,n.height),s.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()}}De.extension={type:[S.CanvasSystem],name:"canvasContext"};class Fe{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0}init(){}}Fe.extension={type:[S.CanvasSystem],name:"limits"};const gt="#808080",re=new G,vt=new G,yt=new G,fe=new G,xt=new G;function Ct(a,e,t){a.beginPath();for(let s=0;s<t.length;s+=3){const n=t[s]*2,r=t[s+1]*2,o=t[s+2]*2;a.moveTo(e[n],e[n+1]),a.lineTo(e[r],e[r+1]),a.lineTo(e[o],e[o+1]),a.closePath()}a.fill()}function Tt(a){return`#${(a&16777215).toString(16).padStart(6,"0")}`}function Pt(a,e,t,s,n,r){r=Math.max(0,Math.min(r,Math.min(s,n)/2)),a.moveTo(e+r,t),a.lineTo(e+s-r,t),a.quadraticCurveTo(e+s,t,e+s,t+r),a.lineTo(e+s,t+n-r),a.quadraticCurveTo(e+s,t+n,e+s-r,t+n),a.lineTo(e+r,t+n),a.quadraticCurveTo(e,t+n,e,t+n-r),a.lineTo(e,t+r),a.quadraticCurveTo(e,t,e+r,t)}function ie(a,e){switch(e.type){case"rectangle":{const t=e;a.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;Pt(a,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;a.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;a.ellipse?a.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2):(a.save(),a.translate(t.x,t.y),a.scale(t.halfWidth,t.halfHeight),a.arc(0,0,1,0,Math.PI*2),a.restore());break}case"triangle":{const t=e;a.moveTo(t.x,t.y),a.lineTo(t.x2,t.y2),a.lineTo(t.x3,t.y3),a.closePath();break}case"polygon":default:{const t=e,s=t.points;if(!(s!=null&&s.length))break;a.moveTo(s[0],s[1]);for(let n=2;n<s.length;n+=2)a.lineTo(s[n],s[n+1]);t.closePath&&a.closePath();break}}}function kt(a,e){if(!(e!=null&&e.length))return!1;for(let t=0;t<e.length;t++){const s=e[t];if(!(s!=null&&s.shape))continue;const n=s.transform,r=n&&!n.isIdentity();r&&(a.save(),a.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),ie(a,s.shape),r&&a.restore()}return!0}function _t(a,e,t,s){const n=a.fill;if(n instanceof Ke){n.buildGradient();const o=n.texture;if(o){const c=P.getTintedPattern(o,e),i=t?fe.copyFrom(t).scale(o.source.pixelWidth,o.source.pixelHeight):fe.copyFrom(n.transform);return s&&!a.textureSpace&&i.append(s),P.applyPatternTransform(c,i),c}}if(n instanceof Qe){const o=P.getTintedPattern(n.texture,e);return P.applyPatternTransform(o,n.transform,!1),o}const r=a.texture;if(r&&r!==Be.WHITE){if(!r.source.resource)return gt;const o=P.getTintedPattern(r,e);let c=a.matrix;if(t){const{resolution:i}=r.source;if(c=fe.copyFrom(t),r.rotate){const{uvs:l,orig:u}=r;c.prepend(xt.set(l.x1-l.x0,l.y1-l.y0,l.x3-l.x0,l.y3-l.y0,l.x0,l.y0).invert()).scale(u.width*i,u.height*i)}else c.scale(r.source.pixelWidth,r.source.pixelHeight).translate(-r.frame.x*i,-r.frame.y*i)}return P.applyPatternTransform(o,c),o}return Tt(e)}class Ue{constructor(){this.shader=null}contextChange(e){}execute(e,t){var Y,U,W,k,C,V,Q;const s=e.renderer,n=s.canvasContext,r=n.activeContext,o=t.groupTransform,c=((Y=s.globalUniforms.globalUniformData)==null?void 0:Y.worldColor)??4294967295,i=t.groupColorAlpha,l=(c>>>24&255)/255,u=(i>>>24&255)/255,x=((U=s.filter)==null?void 0:U.alphaMultiplier)??1,E=l*u*x;if(E<=0)return;const v=c&16777215,f=i&16777215,M=Me(oe(f,v)),y=s._roundPixels|t._roundPixels;r.save(),n.setContextTransform(o,y===1),n.setBlendMode(t.groupBlendMode);const A=t.context.instructions;for(let Z=0;Z<A.length;Z++){const z=A[Z];if(z.action==="texture"){const p=z.data,m=p.image,g=m?P.getCanvasSource(m):null;if(!g)continue;const L=p.alpha*E;if(L<=0)continue;const I=oe(p.style,M);r.globalAlpha=L;let b=g;I!==16777215&&(b=P.getTintedCanvas({texture:m},I));const D=m.frame,F=m.source._resolution??m.source.resolution??1;let B=D.x*F,H=D.y*F;const N=D.width*F,h=D.height*F;b!==g&&(B=0,H=0);const O=p.transform,j=O&&!O.isIdentity(),T=m.rotate;j||T?(re.copyFrom(o),j&&re.append(O),T&&Se.matrixAppendRotationInv(re,T,p.dx,p.dy,p.dw,p.dh),n.setContextTransform(re,y===1)):n.setContextTransform(o,y===1),r.drawImage(b,B,H,b===g?N:b.width,b===g?h:b.height,T?0:p.dx,T?0:p.dy,p.dw,p.dh),(j||T)&&n.setContextTransform(o,y===1);continue}const _=z.data,w=(W=_==null?void 0:_.path)==null?void 0:W.shapePath;if(!((k=w==null?void 0:w.shapePrimitives)!=null&&k.length))continue;const R=_.style,ce=oe(R.color,M),ee=R.alpha*E;if(ee<=0)continue;const q=z.action==="stroke";if(r.globalAlpha=ee,q){const p=R;r.lineWidth=p.width,r.lineCap=p.cap,r.lineJoin=p.join,r.miterLimit=p.miterLimit}const $=w.shapePrimitives;if(!q&&((Q=(V=(C=_.hole)==null?void 0:C.shapePath)==null?void 0:V.shapePrimitives)!=null&&Q.length)){const p=$[$.length-1];p.holes=_.hole.shapePath.shapePrimitives}for(let p=0;p<$.length;p++){const m=$[p];if(!(m!=null&&m.shape))continue;const g=m.transform,L=g&&!g.isIdentity(),I=R.texture&&R.texture!==Be.WHITE,b=R.textureSpace==="global"?g:null,D=I?Je(vt,R,m.shape,b):null,F=L?yt.copyFrom(o).append(g):o,B=_t(R,ce,D,F);if(L&&(r.save(),r.transform(g.a,g.b,g.c,g.d,g.tx,g.ty)),q){const H=R;if(H.alignment!==.5&&!H.pixelLine){const h=[],O=[],j=[],T=Re[m.shape.type];if(T!=null&&T.build(m.shape,h)){const ve=m.shape.closePath??!0;Ie(h,H,!1,ve,O,j),r.fillStyle=B,Ct(r,O,j)}else r.strokeStyle=B,r.beginPath(),ie(r,m.shape),r.stroke()}else r.strokeStyle=B,r.beginPath(),ie(r,m.shape),r.stroke()}else r.fillStyle=B,r.beginPath(),ie(r,m.shape),kt(r,m.holes)?r.fill("evenodd"):r.fill();L&&r.restore()}}r.restore()}destroy(){this.shader=null}}Ue.extension={type:[S.CanvasPipesAdaptor],name:"graphics"};class bt{init(e,t){this._renderer=e,this._renderTargetSystem=t}initGpuRenderTarget(e){const t=e.colorTexture,{canvas:s,context:n}=this._ensureCanvas(t);return{canvas:s,context:n,width:s.width,height:s.height}}resizeGpuRenderTarget(e){const t=e.colorTexture,{canvas:s}=this._ensureCanvas(t);s.width=e.pixelWidth,s.height=e.pixelHeight}startRenderPass(e,t,s,n){const r=this._renderTargetSystem.getGpuRenderTarget(e);this._renderer.canvasContext.activeContext=r.context,this._renderer.canvasContext.activeResolution=e.resolution,t&&this.clear(e,t,s,n)}clear(e,t,s,n){const o=this._renderTargetSystem.getGpuRenderTarget(e).context,c=n||{x:0,y:0,width:e.pixelWidth,height:e.pixelHeight};if(o.setTransform(1,0,0,1,0,0),o.clearRect(c.x,c.y,c.width,c.height),s){const i=Ae.shared.setValue(s);i.alpha>0&&(o.globalAlpha=i.alpha,o.fillStyle=i.toHex(),o.fillRect(c.x,c.y,c.width,c.height),o.globalAlpha=1)}}finishRenderPass(){}copyToTexture(e,t,s,n,r){const c=this._renderTargetSystem.getGpuRenderTarget(e).canvas,i=t.source,{context:l}=this._ensureCanvas(i),u=(r==null?void 0:r.x)??0,x=(r==null?void 0:r.y)??0;return l.drawImage(c,s.x,s.y,n.width,n.height,u,x,n.width,n.height),i.update(),t}copyDepthTexture(e,t,s,n,r){we("[CanvasRenderTargetAdaptor] copyDepthTexture is not supported in the canvas renderer")}destroyGpuRenderTarget(e){}_ensureCanvas(e){let t=e.resource;(!t||!Ze.test(t))&&(t=He.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 s=t.getContext("2d");return{canvas:t,context:s}}}class qe extends st{constructor(e){super(e),this.adaptor=new bt,this.adaptor.init(e,this)}}qe.extension={type:[S.CanvasSystem],name:"renderTarget"};class Le{constructor(e){}init(){}initSource(e){}generateCanvas(e){const t=He.get().createCanvas(),s=t.getContext("2d"),n=P.getCanvasSource(e);if(!n)return t;const r=e.frame,o=e.source._resolution??e.source.resolution??1,c=r.x*o,i=r.y*o,l=r.width*o,u=r.height*o;return t.width=Math.ceil(l),t.height=Math.ceil(u),s.drawImage(n,c,i,l,u,0,0,l,u),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(){}}Le.extension={type:[S.CanvasSystem],name:"texture"};const St=[...nt,De,Fe,Le,qe],Mt=[at,rt,ot,it,ct,We,Ge,lt],wt=[ht,Ue],Ne=[],Oe=[],je=[],Ye=[];ne.handleByNamedList(S.CanvasSystem,Ne);ne.handleByNamedList(S.CanvasPipes,Oe);ne.handleByNamedList(S.CanvasPipesAdaptor,je);ne.handleByNamedList(S.CanvasLoader,Ye);ne.add(...St,...Mt,...wt);class Bt extends et{constructor(){const e={name:"canvas",type:tt.CANVAS,systems:Ne,renderPipes:Oe,renderPipeAdaptors:je,loaders:Ye};super(e)}}export{Bt as CanvasRenderer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S as n,a as u,G as o,b as f}from"./index-Do5XwO_P.js";const s=class i extends n{constructor(e){e={...i.defaultOptions,...e},super(e),this.enabled=!0,this._state=u.for2d(),this.blendMode=e.blendMode,this.padding=e.padding,typeof e.antialias=="boolean"?this.antialias=e.antialias?"on":"off":this.antialias=e.antialias,this.resolution=e.resolution,this.blendRequired=e.blendRequired,this.clipToViewport=e.clipToViewport,this.addResource("uTexture",0,1),e.blendRequired&&this.addResource("uBackTexture",0,3)}apply(e,t,a,r){e.applyFilter(this,t,a,r)}get blendMode(){return this._state.blendMode}set blendMode(e){this._state.blendMode=e}static from(e){const{gpu:t,gl:a,...r}=e;let l,d;return t&&(l=o.from(t)),a&&(d=f.from(a)),new i({gpuProgram:l,glProgram:d,...r})}};s.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let b=s;export{b as F};
|