@poolzin/pool-bot 2026.1.38 → 2026.2.0
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/assets/chrome-extension/README.md +3 -3
- package/assets/chrome-extension/background.js +5 -5
- package/assets/chrome-extension/manifest.json +3 -3
- package/assets/chrome-extension/options.html +4 -4
- package/assets/chrome-extension/options.js +1 -1
- package/dist/acp/client.js +3 -3
- package/dist/acp/types.js +1 -1
- package/dist/agents/agent-paths.js +3 -3
- package/dist/agents/auth-profiles/paths.js +3 -3
- package/dist/agents/cli-runner/helpers.js +1 -1
- package/dist/agents/cli-runner.js +2 -2
- package/dist/agents/cloudflare-ai-gateway.js +31 -0
- package/dist/agents/compaction.js +16 -2
- package/dist/agents/context-window-guard.js +13 -10
- package/dist/agents/context.js +4 -4
- package/dist/agents/docs-path.js +1 -1
- package/dist/agents/minimax-vlm.js +1 -1
- package/dist/agents/model-auth.js +12 -1
- package/dist/agents/model-catalog.js +4 -4
- package/dist/agents/model-selection.js +10 -4
- package/dist/agents/models-config.js +3 -3
- package/dist/agents/models-config.providers.js +147 -39
- package/dist/agents/pi-embedded-helpers/openai.js +1 -1
- package/dist/agents/pi-embedded-runner/compact.js +8 -8
- package/dist/agents/pi-embedded-runner/model.js +2 -2
- package/dist/agents/pi-embedded-runner/run/attempt.js +6 -6
- package/dist/agents/pi-embedded-runner/run.js +4 -4
- package/dist/agents/pi-embedded-runner/tool-result-truncation.js +275 -0
- package/dist/agents/pi-embedded-runner/utils.js +1 -1
- package/dist/agents/pi-model-discovery.js +10 -0
- package/dist/agents/pi-tool-definition-adapter.js +50 -9
- package/dist/agents/pi-tools.before-tool-call.js +67 -0
- package/dist/agents/pi-tools.js +10 -5
- package/dist/agents/pi-tools.read.js +2 -2
- package/dist/agents/session-file-repair.js +83 -0
- package/dist/agents/session-transcript-repair.js +68 -0
- package/dist/agents/skills/frontmatter.js +1 -1
- package/dist/agents/skills/workspace.js +2 -2
- package/dist/agents/system-prompt.js +28 -4
- package/dist/agents/together-models.js +127 -0
- package/dist/agents/tool-images.js +1 -1
- package/dist/agents/tool-policy.js +1 -1
- package/dist/agents/tools/browser-tool.js +3 -3
- package/dist/agents/tools/image-tool.js +2 -2
- package/dist/agents/tools/memory-tool.js +94 -7
- package/dist/agents/tools/web-search.js +1 -1
- package/dist/agents/workspace.js +1 -5
- package/dist/auto-reply/commands-registry.data.js +1 -1
- package/dist/auto-reply/reply/commands-context-report.js +2 -2
- package/dist/auto-reply/reply/commands-session.js +2 -2
- package/dist/auto-reply/reply/get-reply-run.js +14 -4
- package/dist/auto-reply/reply/groups.js +1 -1
- package/dist/auto-reply/reply/inbound-context.js +4 -0
- package/dist/auto-reply/reply/inbound-meta.js +130 -0
- package/dist/auto-reply/reply/untrusted-context.js +15 -0
- package/dist/auto-reply/status.js +1 -1
- package/dist/browser/client-fetch.js +1 -1
- package/dist/browser/config.js +1 -1
- package/dist/browser/extension-relay.js +3 -3
- package/dist/browser/server-context.js +2 -2
- package/dist/build-info.json +3 -3
- package/dist/canvas-host/a2ui.js +3 -3
- package/dist/channels/plugins/agent-tools/whatsapp-login.js +1 -17
- package/dist/channels/plugins/catalog.js +2 -2
- package/dist/channels/plugins/onboarding/imessage.js +1 -1
- package/dist/channels/plugins/onboarding/signal.js +1 -1
- package/dist/channels/plugins/onboarding/slack.js +4 -4
- package/dist/channels/plugins/onboarding/whatsapp.js +3 -3
- package/dist/channels/plugins/pairing-message.js +1 -1
- package/dist/cli/browser-cli-extension.js +2 -2
- package/dist/cli/docs-cli.js +1 -1
- package/dist/cli/gateway-cli/dev.js +1 -1
- package/dist/cli/memory-cli.js +25 -15
- package/dist/cli/nodes-cli/register.canvas.js +1 -1
- package/dist/cli/plugins-cli.js +1 -1
- package/dist/cli/run-main.js +2 -2
- package/dist/cli/security-cli.js +1 -1
- package/dist/cli/tagline.js +1 -1
- package/dist/cli/update-cli.js +4 -4
- package/dist/cli/webhooks-cli.js +5 -5
- package/dist/commands/agents.commands.add.js +1 -1
- package/dist/commands/auth-choice.apply.api-providers.js +305 -17
- package/dist/commands/auth-choice.apply.js +4 -1
- package/dist/commands/auth-choice.apply.plugin-provider.js +2 -2
- package/dist/commands/auth-choice.apply.xai.js +63 -0
- package/dist/commands/auth-choice.preferred-provider.js +7 -1
- package/dist/commands/configure.wizard.js +1 -1
- package/dist/commands/dashboard.js +1 -1
- package/dist/commands/docs.js +1 -1
- package/dist/commands/doctor-gateway-services.js +3 -3
- package/dist/commands/doctor-state-integrity.js +2 -14
- package/dist/commands/doctor-update.js +3 -3
- package/dist/commands/doctor.js +1 -1
- package/dist/commands/models/list.probe.js +2 -2
- package/dist/commands/models/list.registry.js +4 -4
- package/dist/commands/models/list.status-command.js +2 -2
- package/dist/commands/onboard-auth.config-core.js +366 -28
- package/dist/commands/onboard-auth.credentials.js +71 -9
- package/dist/commands/onboard-auth.js +3 -3
- package/dist/commands/onboard-auth.models.js +26 -24
- package/dist/commands/onboard-non-interactive/local/auth-choice.js +140 -6
- package/dist/commands/status-all/report-lines.js +1 -1
- package/dist/commands/status.command.js +1 -1
- package/dist/commands/uninstall.js +3 -3
- package/dist/compat/legacy-names.js +1 -1
- package/dist/config/io.js +3 -3
- package/dist/config/schema.js +1 -1
- package/dist/config/types.js +0 -1
- package/dist/config/types.memory.js +1 -0
- package/dist/config/version.js +4 -4
- package/dist/config/zod-schema.js +0 -6
- package/dist/daemon/constants.js +7 -7
- package/dist/daemon/inspect.js +6 -6
- package/dist/daemon/systemd-unit.js +1 -1
- package/dist/discord/monitor/message-handler.process.js +6 -4
- package/dist/gateway/client.js +0 -14
- package/dist/gateway/live-image-probe.js +1 -66
- package/dist/gateway/openai-http.js +2 -2
- package/dist/gateway/openresponses-http.js +4 -4
- package/dist/gateway/server-discovery.js +2 -2
- package/dist/gateway/server-http.js +1 -1
- package/dist/gateway/server.impl.js +2 -6
- package/dist/hooks/frontmatter.js +1 -1
- package/dist/hooks/hooks-status.js +1 -1
- package/dist/hooks/install.js +2 -2
- package/dist/hooks/loader.js +1 -1
- package/dist/hooks/workspace.js +3 -3
- package/dist/index.js +2 -2
- package/dist/infra/bonjour.js +3 -3
- package/dist/infra/path-env.js +3 -3
- package/dist/infra/provider-usage.fetch.minimax.js +1 -1
- package/dist/infra/restart.js +1 -1
- package/dist/infra/tailscale.js +1 -1
- package/dist/macos/relay.js +2 -2
- package/dist/media/input-files.js +1 -1
- package/dist/media/mime.js +4 -0
- package/dist/media/png-encode.js +74 -0
- package/dist/media-understanding/providers/image.js +2 -2
- package/dist/memory/backend-config.js +207 -0
- package/dist/memory/embeddings.js +1 -1
- package/dist/memory/index.js +0 -5
- package/dist/memory/manager.js +3 -25
- package/dist/memory/types.js +1 -0
- package/dist/node-host/runner.js +2 -2
- package/dist/pairing/pairing-messages.js +1 -1
- package/dist/plugins/discovery.js +1 -1
- package/dist/plugins/install.js +2 -2
- package/dist/plugins/update.js +1 -1
- package/dist/security/audit.js +2 -2
- package/dist/shared/text/reasoning-tags.js +52 -7
- package/dist/slack/monitor/message-handler/prepare.js +10 -4
- package/dist/slack/monitor/slash.js +10 -4
- package/dist/tailscale/detect.js +146 -0
- package/dist/telegram/bot-message-context.js +1 -1
- package/dist/test-helpers/workspace.js +11 -0
- package/dist/test-utils/channel-plugins.js +82 -0
- package/dist/test-utils/ports.js +73 -0
- package/dist/utils/shell-argv.js +61 -0
- package/dist/utils.js +10 -0
- package/dist/web/qr-image.js +1 -61
- package/dist/wizard/onboarding.finalize.js +7 -7
- package/dist/wizard/onboarding.js +3 -3
- package/docs/RELEASE_WORKFOTS_COMPARISON.md +3 -3
- package/docs/_config.yml +2 -2
- package/docs/_layouts/default.html +9 -9
- package/docs/concepts/typebox.md +1 -1
- package/docs/docs.json +1 -1
- package/docs/northflank.mdx +7 -7
- package/docs/railway.mdx +3 -3
- package/docs/render.mdx +5 -5
- package/docs/start/lore.md +2 -2
- package/extensions/bluebubbles/index.ts +2 -2
- package/extensions/bluebubbles/package.json +1 -1
- package/extensions/bluebubbles/src/accounts.ts +8 -8
- package/extensions/bluebubbles/src/actions.test.ts +22 -22
- package/extensions/bluebubbles/src/actions.ts +5 -5
- package/extensions/bluebubbles/src/attachments.ts +2 -2
- package/extensions/bluebubbles/src/channel.ts +16 -16
- package/extensions/bluebubbles/src/chat.ts +2 -2
- package/extensions/bluebubbles/src/media-send.ts +2 -2
- package/extensions/bluebubbles/src/monitor.test.ts +46 -46
- package/extensions/bluebubbles/src/monitor.ts +5 -5
- package/extensions/bluebubbles/src/onboarding.ts +7 -7
- package/extensions/bluebubbles/src/reactions.ts +2 -2
- package/extensions/bluebubbles/src/send.ts +2 -2
- package/extensions/copilot-proxy/README.md +1 -1
- package/extensions/copilot-proxy/package.json +1 -1
- package/extensions/diagnostics-otel/index.ts +2 -2
- package/extensions/diagnostics-otel/package.json +1 -1
- package/extensions/diagnostics-otel/src/service.ts +3 -3
- package/extensions/discord/index.ts +2 -2
- package/extensions/discord/package.json +1 -1
- package/extensions/google-antigravity-auth/README.md +1 -1
- package/extensions/google-antigravity-auth/index.ts +1 -1
- package/extensions/google-antigravity-auth/package.json +1 -1
- package/extensions/google-gemini-cli-auth/README.md +1 -1
- package/extensions/google-gemini-cli-auth/oauth.ts +1 -1
- package/extensions/google-gemini-cli-auth/package.json +1 -1
- package/extensions/googlechat/index.ts +3 -3
- package/extensions/googlechat/package.json +1 -1
- package/extensions/googlechat/src/accounts.ts +8 -8
- package/extensions/googlechat/src/actions.ts +6 -6
- package/extensions/googlechat/src/channel.ts +21 -21
- package/extensions/googlechat/src/monitor.ts +8 -8
- package/extensions/googlechat/src/onboarding.ts +10 -10
- package/extensions/imessage/index.ts +2 -2
- package/extensions/imessage/package.json +1 -1
- package/extensions/line/index.ts +2 -2
- package/extensions/line/package.json +1 -1
- package/extensions/line/src/card-command.ts +2 -2
- package/extensions/line/src/channel.logout.test.ts +4 -4
- package/extensions/line/src/channel.sendPayload.test.ts +8 -8
- package/extensions/line/src/channel.ts +3 -3
- package/extensions/llm-task/README.md +3 -3
- package/extensions/llm-task/index.ts +2 -2
- package/extensions/llm-task/package.json +1 -1
- package/extensions/llm-task/src/llm-task-tool.ts +4 -4
- package/extensions/lobster/README.md +6 -6
- package/extensions/lobster/index.ts +2 -2
- package/extensions/lobster/src/lobster-tool.test.ts +4 -4
- package/extensions/lobster/src/lobster-tool.ts +2 -2
- package/extensions/matrix/index.ts +2 -2
- package/extensions/matrix/package.json +1 -1
- package/extensions/matrix/src/matrix/client/config.ts +1 -1
- package/extensions/matrix/src/matrix/monitor/handler.ts +1 -1
- package/extensions/matrix/src/onboarding.ts +1 -1
- package/extensions/mattermost/index.ts +2 -2
- package/extensions/mattermost/package.json +1 -1
- package/extensions/mattermost/src/mattermost/accounts.ts +8 -8
- package/extensions/mattermost/src/mattermost/monitor-helpers.ts +5 -5
- package/extensions/mattermost/src/mattermost/monitor.ts +2 -2
- package/extensions/mattermost/src/onboarding-helpers.ts +3 -3
- package/extensions/mattermost/src/onboarding.ts +2 -2
- package/extensions/memory-core/index.ts +2 -2
- package/extensions/memory-core/package.json +1 -4
- package/extensions/memory-lancedb/index.ts +3 -3
- package/extensions/memory-lancedb/package.json +1 -1
- package/extensions/msteams/index.ts +2 -2
- package/extensions/msteams/package.json +1 -1
- package/extensions/msteams/src/channel.directory.test.ts +2 -2
- package/extensions/msteams/src/channel.ts +2 -2
- package/extensions/msteams/src/graph-upload.ts +4 -4
- package/extensions/msteams/src/monitor-handler.ts +2 -2
- package/extensions/msteams/src/monitor.ts +2 -2
- package/extensions/msteams/src/onboarding.ts +9 -9
- package/extensions/msteams/src/reply-dispatcher.ts +2 -2
- package/extensions/msteams/src/send-context.ts +2 -2
- package/extensions/msteams/src/send.ts +4 -4
- package/extensions/nextcloud-talk/index.ts +2 -2
- package/extensions/nextcloud-talk/package.json +1 -1
- package/extensions/nextcloud-talk/src/channel.ts +7 -7
- package/extensions/nextcloud-talk/src/inbound.ts +7 -7
- package/extensions/nextcloud-talk/src/onboarding.ts +1 -1
- package/extensions/nostr/README.md +2 -2
- package/extensions/nostr/index.ts +5 -5
- package/extensions/nostr/package.json +1 -1
- package/extensions/nostr/src/types.ts +4 -4
- package/extensions/open-prose/index.ts +2 -2
- package/extensions/qwen-portal-auth/README.md +1 -1
- package/extensions/signal/index.ts +2 -2
- package/extensions/signal/package.json +1 -1
- package/extensions/slack/index.ts +2 -2
- package/extensions/slack/package.json +1 -1
- package/extensions/telegram/index.ts +2 -2
- package/extensions/telegram/package.json +1 -1
- package/extensions/telegram/src/channel.ts +2 -2
- package/extensions/tlon/README.md +2 -2
- package/extensions/tlon/index.ts +2 -2
- package/extensions/tlon/package.json +1 -1
- package/extensions/tlon/src/channel.ts +13 -13
- package/extensions/tlon/src/monitor/index.ts +3 -3
- package/extensions/tlon/src/onboarding.ts +3 -3
- package/extensions/tlon/src/types.ts +3 -3
- package/extensions/twitch/README.md +1 -1
- package/extensions/twitch/index.ts +2 -2
- package/extensions/twitch/package.json +1 -1
- package/extensions/twitch/src/config.ts +3 -3
- package/extensions/twitch/src/monitor.ts +3 -3
- package/extensions/twitch/src/onboarding.ts +9 -9
- package/extensions/twitch/src/outbound.test.ts +2 -2
- package/extensions/twitch/src/plugin.test.ts +2 -2
- package/extensions/twitch/src/plugin.ts +8 -8
- package/extensions/twitch/src/send.test.ts +2 -2
- package/extensions/twitch/src/send.ts +4 -4
- package/extensions/twitch/src/token.test.ts +8 -8
- package/extensions/twitch/src/token.ts +3 -3
- package/extensions/twitch/src/twitch-client.ts +3 -3
- package/extensions/twitch/src/types.ts +3 -3
- package/extensions/twitch/src/utils/markdown.ts +1 -1
- package/extensions/voice-call/README.md +3 -3
- package/extensions/voice-call/package.json +1 -1
- package/extensions/voice-call/src/core-bridge.ts +2 -2
- package/extensions/voice-call/src/response-generator.ts +1 -1
- package/extensions/whatsapp/index.ts +2 -2
- package/extensions/whatsapp/package.json +1 -1
- package/extensions/zalo/README.md +1 -1
- package/extensions/zalo/index.ts +2 -2
- package/extensions/zalo/package.json +1 -1
- package/extensions/zalo/src/accounts.ts +8 -8
- package/extensions/zalo/src/actions.ts +4 -4
- package/extensions/zalo/src/channel.directory.test.ts +2 -2
- package/extensions/zalo/src/channel.ts +18 -18
- package/extensions/zalo/src/monitor.ts +9 -9
- package/extensions/zalo/src/monitor.webhook.test.ts +2 -2
- package/extensions/zalo/src/onboarding.ts +24 -24
- package/extensions/zalo/src/send.ts +2 -2
- package/extensions/zalouser/README.md +2 -2
- package/extensions/zalouser/index.ts +2 -2
- package/extensions/zalouser/package.json +1 -1
- package/extensions/zalouser/src/accounts.ts +9 -9
- package/extensions/zalouser/src/channel.ts +24 -24
- package/extensions/zalouser/src/monitor.ts +4 -4
- package/extensions/zalouser/src/onboarding.ts +28 -28
- package/package.json +13 -250
- package/skills/nano-banana-pro/scripts/generate_image.py +1 -1
- package/skills/tmux/scripts/find-sessions.sh +1 -1
- package/CHANGELOG.md +0 -200
- package/README-header.png +0 -0
- package/git-hooks/pre-commit +0 -4
- package/scripts/format-staged.js +0 -148
- package/scripts/postinstall.js +0 -300
- package/scripts/setup-git-hooks.js +0 -96
- package/skills/webgpu-threejs-tsl/REFERENCE.md +0 -283
- package/skills/webgpu-threejs-tsl/SKILL.md +0 -91
- package/skills/webgpu-threejs-tsl/docs/compute-shaders.md +0 -404
- package/skills/webgpu-threejs-tsl/docs/core-concepts.md +0 -453
- package/skills/webgpu-threejs-tsl/docs/materials.md +0 -353
- package/skills/webgpu-threejs-tsl/docs/post-processing.md +0 -434
- package/skills/webgpu-threejs-tsl/docs/wgsl-integration.md +0 -324
- package/skills/webgpu-threejs-tsl/examples/basic-setup.js +0 -87
- package/skills/webgpu-threejs-tsl/examples/custom-material.js +0 -170
- package/skills/webgpu-threejs-tsl/examples/earth-shader.js +0 -292
- package/skills/webgpu-threejs-tsl/examples/particle-system.js +0 -259
- package/skills/webgpu-threejs-tsl/examples/post-processing.js +0 -199
- package/skills/webgpu-threejs-tsl/templates/compute-shader.js +0 -305
- package/skills/webgpu-threejs-tsl/templates/webgpu-project.js +0 -276
package/scripts/postinstall.js
DELETED
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { spawnSync } from "node:child_process";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
|
-
import { setupGitHooks } from "./setup-git-hooks.js";
|
|
6
|
-
|
|
7
|
-
function detectPackageManager(ua = process.env.npm_config_user_agent ?? "") {
|
|
8
|
-
// Examples:
|
|
9
|
-
// - "pnpm/10.23.0 npm/? node/v22.21.1 darwin arm64"
|
|
10
|
-
// - "npm/10.9.4 node/v22.12.0 linux x64"
|
|
11
|
-
// - "bun/1.2.2"
|
|
12
|
-
const normalized = String(ua).trim();
|
|
13
|
-
if (normalized.startsWith("pnpm/")) return "pnpm";
|
|
14
|
-
if (normalized.startsWith("bun/")) return "bun";
|
|
15
|
-
if (normalized.startsWith("npm/")) return "npm";
|
|
16
|
-
if (normalized.startsWith("yarn/")) return "yarn";
|
|
17
|
-
return "unknown";
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function shouldApplyPnpmPatchedDependenciesFallback(pm = detectPackageManager()) {
|
|
21
|
-
// pnpm already applies pnpm.patchedDependencies itself; re-applying would fail.
|
|
22
|
-
return pm !== "pnpm";
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function getRepoRoot() {
|
|
26
|
-
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
27
|
-
return path.resolve(here, "..");
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function ensureExecutable(targetPath) {
|
|
31
|
-
if (process.platform === "win32") return;
|
|
32
|
-
if (!fs.existsSync(targetPath)) return;
|
|
33
|
-
try {
|
|
34
|
-
const mode = fs.statSync(targetPath).mode & 0o777;
|
|
35
|
-
if (mode & 0o100) return;
|
|
36
|
-
fs.chmodSync(targetPath, 0o755);
|
|
37
|
-
} catch (err) {
|
|
38
|
-
console.warn(`[postinstall] chmod failed: ${err}`);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function hasGit(repoRoot) {
|
|
43
|
-
const result = spawnSync("git", ["--version"], { cwd: repoRoot, stdio: "ignore" });
|
|
44
|
-
return result.status === 0;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function extractPackageName(key) {
|
|
48
|
-
if (key.startsWith("@")) {
|
|
49
|
-
const idx = key.indexOf("@", 1);
|
|
50
|
-
if (idx === -1) return key;
|
|
51
|
-
return key.slice(0, idx);
|
|
52
|
-
}
|
|
53
|
-
const idx = key.lastIndexOf("@");
|
|
54
|
-
if (idx <= 0) return key;
|
|
55
|
-
return key.slice(0, idx);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function stripPrefix(p) {
|
|
59
|
-
if (p.startsWith("a/") || p.startsWith("b/")) return p.slice(2);
|
|
60
|
-
return p;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function parseRange(segment) {
|
|
64
|
-
// segment: "-12,5" or "+7"
|
|
65
|
-
const [startRaw, countRaw] = segment.slice(1).split(",");
|
|
66
|
-
const start = Number.parseInt(startRaw, 10);
|
|
67
|
-
const count = countRaw ? Number.parseInt(countRaw, 10) : 1;
|
|
68
|
-
if (Number.isNaN(start) || Number.isNaN(count)) {
|
|
69
|
-
throw new Error(`invalid hunk range: ${segment}`);
|
|
70
|
-
}
|
|
71
|
-
return { start, count };
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function parsePatch(patchText) {
|
|
75
|
-
const lines = patchText.split("\n");
|
|
76
|
-
const files = [];
|
|
77
|
-
let i = 0;
|
|
78
|
-
|
|
79
|
-
while (i < lines.length) {
|
|
80
|
-
if (!lines[i].startsWith("diff --git ")) {
|
|
81
|
-
i += 1;
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const file = { oldPath: null, newPath: null, hunks: [] };
|
|
86
|
-
i += 1;
|
|
87
|
-
|
|
88
|
-
// Skip index line(s)
|
|
89
|
-
while (i < lines.length && lines[i].startsWith("index ")) i += 1;
|
|
90
|
-
|
|
91
|
-
if (i < lines.length && lines[i].startsWith("--- ")) {
|
|
92
|
-
file.oldPath = stripPrefix(lines[i].slice(4).trim());
|
|
93
|
-
i += 1;
|
|
94
|
-
}
|
|
95
|
-
if (i < lines.length && lines[i].startsWith("+++ ")) {
|
|
96
|
-
file.newPath = stripPrefix(lines[i].slice(4).trim());
|
|
97
|
-
i += 1;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
while (i < lines.length && lines[i].startsWith("@@")) {
|
|
101
|
-
const header = lines[i];
|
|
102
|
-
const match = /^@@\s+(-\d+(?:,\d+)?)\s+(\+\d+(?:,\d+)?)\s+@@/.exec(header);
|
|
103
|
-
if (!match) throw new Error(`invalid hunk header: ${header}`);
|
|
104
|
-
const oldRange = parseRange(match[1]);
|
|
105
|
-
const newRange = parseRange(match[2]);
|
|
106
|
-
i += 1;
|
|
107
|
-
|
|
108
|
-
const hunkLines = [];
|
|
109
|
-
while (i < lines.length) {
|
|
110
|
-
const line = lines[i];
|
|
111
|
-
if (line.startsWith("@@") || line.startsWith("diff --git ")) break;
|
|
112
|
-
if (line === "") {
|
|
113
|
-
i += 1;
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
if (line.startsWith("\")) {
|
|
117
|
-
i += 1;
|
|
118
|
-
continue;
|
|
119
|
-
}
|
|
120
|
-
hunkLines.push(line);
|
|
121
|
-
i += 1;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
file.hunks.push({
|
|
125
|
-
oldStart: oldRange.start,
|
|
126
|
-
oldLines: oldRange.count,
|
|
127
|
-
newStart: newRange.start,
|
|
128
|
-
newLines: newRange.count,
|
|
129
|
-
lines: hunkLines,
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (file.newPath && file.hunks.length > 0) {
|
|
134
|
-
files.push(file);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return files;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function readFileLines(targetPath) {
|
|
142
|
-
if (!fs.existsSync(targetPath)) {
|
|
143
|
-
throw new Error(`target file missing: ${targetPath}`);
|
|
144
|
-
}
|
|
145
|
-
const raw = fs.readFileSync(targetPath, "utf-8");
|
|
146
|
-
const hasTrailingNewline = raw.endsWith("\n");
|
|
147
|
-
const parts = raw.split("\n");
|
|
148
|
-
if (hasTrailingNewline) parts.pop();
|
|
149
|
-
return { lines: parts, hasTrailingNewline };
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function writeFileLines(targetPath, lines, hadTrailingNewline) {
|
|
153
|
-
const content = lines.join("\n") + (hadTrailingNewline ? "\n" : "");
|
|
154
|
-
fs.writeFileSync(targetPath, content, "utf-8");
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function applyHunk(lines, hunk, offset) {
|
|
158
|
-
let cursor = hunk.oldStart - 1 + offset;
|
|
159
|
-
const expected = [];
|
|
160
|
-
for (const raw of hunk.lines) {
|
|
161
|
-
const marker = raw[0];
|
|
162
|
-
if (marker === " " || marker === "+") {
|
|
163
|
-
expected.push(raw.slice(1));
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
if (cursor >= 0 && cursor + expected.length <= lines.length) {
|
|
167
|
-
let alreadyApplied = true;
|
|
168
|
-
for (let i = 0; i < expected.length; i += 1) {
|
|
169
|
-
if (lines[cursor + i] !== expected[i]) {
|
|
170
|
-
alreadyApplied = false;
|
|
171
|
-
break;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
if (alreadyApplied) {
|
|
175
|
-
const delta = hunk.newLines - hunk.oldLines;
|
|
176
|
-
return offset + delta;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
for (const raw of hunk.lines) {
|
|
181
|
-
const marker = raw[0];
|
|
182
|
-
const text = raw.slice(1);
|
|
183
|
-
if (marker === " ") {
|
|
184
|
-
if (lines[cursor] !== text) {
|
|
185
|
-
throw new Error(
|
|
186
|
-
`context mismatch at line ${cursor + 1}: expected "${text}", found "${lines[cursor] ?? "<eof>"}"`,
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
cursor += 1;
|
|
190
|
-
} else if (marker === "-") {
|
|
191
|
-
if (lines[cursor] !== text) {
|
|
192
|
-
throw new Error(
|
|
193
|
-
`delete mismatch at line ${cursor + 1}: expected "${text}", found "${lines[cursor] ?? "<eof>"}"`,
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
lines.splice(cursor, 1);
|
|
197
|
-
} else if (marker === "+") {
|
|
198
|
-
lines.splice(cursor, 0, text);
|
|
199
|
-
cursor += 1;
|
|
200
|
-
} else {
|
|
201
|
-
throw new Error(`unexpected hunk marker: ${marker}`);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
const delta = hunk.newLines - hunk.oldLines;
|
|
206
|
-
return offset + delta;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
function applyPatchToFile(targetDir, filePatch) {
|
|
210
|
-
if (filePatch.newPath === "/dev/null") {
|
|
211
|
-
// deletion not needed for our patches
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
const relPath = stripPrefix(filePatch.newPath ?? filePatch.oldPath ?? "");
|
|
215
|
-
const targetPath = path.join(targetDir, relPath);
|
|
216
|
-
const { lines, hasTrailingNewline } = readFileLines(targetPath);
|
|
217
|
-
|
|
218
|
-
let offset = 0;
|
|
219
|
-
for (const hunk of filePatch.hunks) {
|
|
220
|
-
offset = applyHunk(lines, hunk, offset);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
writeFileLines(targetPath, lines, hasTrailingNewline);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
function applyPatchSet({ patchText, targetDir }) {
|
|
227
|
-
let resolvedTarget = path.resolve(targetDir);
|
|
228
|
-
if (!fs.existsSync(resolvedTarget) || !fs.statSync(resolvedTarget).isDirectory()) {
|
|
229
|
-
console.warn(`[postinstall] skip missing target: ${resolvedTarget}`);
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
resolvedTarget = fs.realpathSync(resolvedTarget);
|
|
233
|
-
|
|
234
|
-
const files = parsePatch(patchText);
|
|
235
|
-
if (files.length === 0) return;
|
|
236
|
-
|
|
237
|
-
for (const filePatch of files) {
|
|
238
|
-
applyPatchToFile(resolvedTarget, filePatch);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
function applyPatchFile({ patchPath, targetDir }) {
|
|
243
|
-
const absPatchPath = path.resolve(patchPath);
|
|
244
|
-
if (!fs.existsSync(absPatchPath)) {
|
|
245
|
-
throw new Error(`missing patch: ${absPatchPath}`);
|
|
246
|
-
}
|
|
247
|
-
const patchText = fs.readFileSync(absPatchPath, "utf-8");
|
|
248
|
-
applyPatchSet({ patchText, targetDir });
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
function main() {
|
|
252
|
-
const repoRoot = getRepoRoot();
|
|
253
|
-
process.chdir(repoRoot);
|
|
254
|
-
|
|
255
|
-
ensureExecutable(path.join(repoRoot, "dist", "entry.js"));
|
|
256
|
-
setupGitHooks({ repoRoot });
|
|
257
|
-
|
|
258
|
-
if (!shouldApplyPnpmPatchedDependenciesFallback()) {
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
const pkgPath = path.join(repoRoot, "package.json");
|
|
263
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
264
|
-
const patched = pkg?.pnpm?.patchedDependencies ?? {};
|
|
265
|
-
|
|
266
|
-
// Bun does not support pnpm.patchedDependencies. Apply these patch files to
|
|
267
|
-
// node_modules packages as a best-effort compatibility layer.
|
|
268
|
-
for (const [key, relPatchPath] of Object.entries(patched)) {
|
|
269
|
-
if (typeof relPatchPath !== "string" || !relPatchPath.trim()) continue;
|
|
270
|
-
const pkgName = extractPackageName(String(key));
|
|
271
|
-
if (!pkgName) continue;
|
|
272
|
-
applyPatchFile({
|
|
273
|
-
targetDir: path.join("node_modules", ...pkgName.split("/")),
|
|
274
|
-
patchPath: relPatchPath,
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
try {
|
|
280
|
-
const skip =
|
|
281
|
-
process.env.CLAWDBOT_SKIP_POSTINSTALL === "1" ||
|
|
282
|
-
process.env.VITEST === "true" ||
|
|
283
|
-
process.env.NODE_ENV === "test";
|
|
284
|
-
|
|
285
|
-
if (!skip) {
|
|
286
|
-
main();
|
|
287
|
-
}
|
|
288
|
-
} catch (err) {
|
|
289
|
-
console.error(String(err));
|
|
290
|
-
process.exit(1);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
export {
|
|
294
|
-
applyPatchFile,
|
|
295
|
-
applyPatchSet,
|
|
296
|
-
applyPatchToFile,
|
|
297
|
-
detectPackageManager,
|
|
298
|
-
parsePatch,
|
|
299
|
-
shouldApplyPnpmPatchedDependenciesFallback,
|
|
300
|
-
};
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { spawnSync } from "node:child_process";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
|
-
|
|
6
|
-
const DEFAULT_HOOKS_PATH = "git-hooks";
|
|
7
|
-
const PRE_COMMIT_HOOK = "pre-commit";
|
|
8
|
-
|
|
9
|
-
function getRepoRoot() {
|
|
10
|
-
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
-
return path.resolve(here, "..");
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function runGitCommand(args, options = {}) {
|
|
15
|
-
return spawnSync("git", args, {
|
|
16
|
-
cwd: options.cwd,
|
|
17
|
-
encoding: "utf-8",
|
|
18
|
-
stdio: options.stdio ?? "pipe",
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function ensureExecutable(targetPath) {
|
|
23
|
-
if (process.platform === "win32") return;
|
|
24
|
-
if (!fs.existsSync(targetPath)) return;
|
|
25
|
-
try {
|
|
26
|
-
const mode = fs.statSync(targetPath).mode & 0o777;
|
|
27
|
-
if (mode & 0o100) return;
|
|
28
|
-
fs.chmodSync(targetPath, 0o755);
|
|
29
|
-
} catch (err) {
|
|
30
|
-
console.warn(`[setup-git-hooks] chmod failed: ${err}`);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function isGitAvailable({ repoRoot = getRepoRoot(), runGit = runGitCommand } = {}) {
|
|
35
|
-
const result = runGit(["--version"], { cwd: repoRoot, stdio: "ignore" });
|
|
36
|
-
return result.status === 0;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function isGitRepo({ repoRoot = getRepoRoot(), runGit = runGitCommand } = {}) {
|
|
40
|
-
const result = runGit(["rev-parse", "--is-inside-work-tree"], {
|
|
41
|
-
cwd: repoRoot,
|
|
42
|
-
stdio: "pipe",
|
|
43
|
-
});
|
|
44
|
-
if (result.status !== 0) return false;
|
|
45
|
-
return String(result.stdout ?? "").trim() === "true";
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function setHooksPath({
|
|
49
|
-
repoRoot = getRepoRoot(),
|
|
50
|
-
hooksPath = DEFAULT_HOOKS_PATH,
|
|
51
|
-
runGit = runGitCommand,
|
|
52
|
-
} = {}) {
|
|
53
|
-
const result = runGit(["config", "core.hooksPath", hooksPath], {
|
|
54
|
-
cwd: repoRoot,
|
|
55
|
-
stdio: "ignore",
|
|
56
|
-
});
|
|
57
|
-
return result.status === 0;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function setupGitHooks({
|
|
61
|
-
repoRoot = getRepoRoot(),
|
|
62
|
-
hooksPath = DEFAULT_HOOKS_PATH,
|
|
63
|
-
runGit = runGitCommand,
|
|
64
|
-
} = {}) {
|
|
65
|
-
if (!isGitAvailable({ repoRoot, runGit })) {
|
|
66
|
-
return { ok: false, reason: "git-missing" };
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (!isGitRepo({ repoRoot, runGit })) {
|
|
70
|
-
return { ok: false, reason: "not-repo" };
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (!setHooksPath({ repoRoot, hooksPath, runGit })) {
|
|
74
|
-
return { ok: false, reason: "config-failed" };
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
ensureExecutable(path.join(repoRoot, hooksPath, PRE_COMMIT_HOOK));
|
|
78
|
-
|
|
79
|
-
return { ok: true };
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export {
|
|
83
|
-
DEFAULT_HOOKS_PATH,
|
|
84
|
-
PRE_COMMIT_HOOK,
|
|
85
|
-
ensureExecutable,
|
|
86
|
-
getRepoRoot,
|
|
87
|
-
isGitAvailable,
|
|
88
|
-
isGitRepo,
|
|
89
|
-
runGitCommand,
|
|
90
|
-
setHooksPath,
|
|
91
|
-
setupGitHooks,
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
95
|
-
setupGitHooks();
|
|
96
|
-
}
|
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
# TSL Quick Reference
|
|
2
|
-
|
|
3
|
-
## Imports
|
|
4
|
-
|
|
5
|
-
```javascript
|
|
6
|
-
// WebGPU Three.js
|
|
7
|
-
import * as THREE from 'three/webgpu';
|
|
8
|
-
|
|
9
|
-
// Core TSL
|
|
10
|
-
import {
|
|
11
|
-
float, int, uint, bool,
|
|
12
|
-
vec2, vec3, vec4, color,
|
|
13
|
-
mat2, mat3, mat4,
|
|
14
|
-
uniform, texture, uv,
|
|
15
|
-
Fn, If, Loop, Break, Continue,
|
|
16
|
-
time, deltaTime
|
|
17
|
-
} from 'three/tsl';
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Types
|
|
21
|
-
|
|
22
|
-
| TSL | WGSL | Example |
|
|
23
|
-
|-----|------|---------|
|
|
24
|
-
| `float(1.0)` | `f32` | Scalar float |
|
|
25
|
-
| `int(1)` | `i32` | Signed integer |
|
|
26
|
-
| `uint(1)` | `u32` | Unsigned integer |
|
|
27
|
-
| `bool(true)` | `bool` | Boolean |
|
|
28
|
-
| `vec2(x, y)` | `vec2<f32>` | 2D vector |
|
|
29
|
-
| `vec3(x, y, z)` | `vec3<f32>` | 3D vector |
|
|
30
|
-
| `vec4(x, y, z, w)` | `vec4<f32>` | 4D vector |
|
|
31
|
-
| `color(0xff0000)` | `vec3<f32>` | RGB color |
|
|
32
|
-
| `uniform(value)` | uniform | Dynamic value |
|
|
33
|
-
|
|
34
|
-
## Operators
|
|
35
|
-
|
|
36
|
-
| Operation | TSL | GLSL Equivalent |
|
|
37
|
-
|-----------|-----|-----------------|
|
|
38
|
-
| Add | `a.add(b)` | `a + b` |
|
|
39
|
-
| Subtract | `a.sub(b)` | `a - b` |
|
|
40
|
-
| Multiply | `a.mul(b)` | `a * b` |
|
|
41
|
-
| Divide | `a.div(b)` | `a / b` |
|
|
42
|
-
| Modulo | `a.mod(b)` | `mod(a, b)` |
|
|
43
|
-
| Negate | `a.negate()` | `-a` |
|
|
44
|
-
| Less Than | `a.lessThan(b)` | `a < b` |
|
|
45
|
-
| Greater Than | `a.greaterThan(b)` | `a > b` |
|
|
46
|
-
| Equal | `a.equal(b)` | `a == b` |
|
|
47
|
-
| And | `a.and(b)` | `a && b` |
|
|
48
|
-
| Or | `a.or(b)` | `a \|\| b` |
|
|
49
|
-
| Assign | `a.assign(b)` | `a = b` |
|
|
50
|
-
| Add Assign | `a.addAssign(b)` | `a += b` |
|
|
51
|
-
|
|
52
|
-
## Swizzling
|
|
53
|
-
|
|
54
|
-
```javascript
|
|
55
|
-
const v = vec3(1, 2, 3);
|
|
56
|
-
v.x // 1
|
|
57
|
-
v.xy // vec2(1, 2)
|
|
58
|
-
v.zyx // vec3(3, 2, 1)
|
|
59
|
-
v.rgb // same as xyz
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
## Math Functions
|
|
63
|
-
|
|
64
|
-
| Function | Description |
|
|
65
|
-
|----------|-------------|
|
|
66
|
-
| `abs(x)` | Absolute value |
|
|
67
|
-
| `sign(x)` | Sign (-1, 0, 1) |
|
|
68
|
-
| `floor(x)` | Round down |
|
|
69
|
-
| `ceil(x)` | Round up |
|
|
70
|
-
| `fract(x)` | Fractional part |
|
|
71
|
-
| `min(a, b)` | Minimum |
|
|
72
|
-
| `max(a, b)` | Maximum |
|
|
73
|
-
| `clamp(x, lo, hi)` | Clamp to range |
|
|
74
|
-
| `mix(a, b, t)` | Linear interpolation |
|
|
75
|
-
| `step(edge, x)` | Step function |
|
|
76
|
-
| `smoothstep(a, b, x)` | Smooth step |
|
|
77
|
-
| `sin(x)`, `cos(x)` | Trigonometry |
|
|
78
|
-
| `pow(x, y)` | Power |
|
|
79
|
-
| `sqrt(x)` | Square root |
|
|
80
|
-
| `length(v)` | Vector length |
|
|
81
|
-
| `distance(a, b)` | Distance |
|
|
82
|
-
| `dot(a, b)` | Dot product |
|
|
83
|
-
| `cross(a, b)` | Cross product |
|
|
84
|
-
| `normalize(v)` | Unit vector |
|
|
85
|
-
| `reflect(i, n)` | Reflection |
|
|
86
|
-
|
|
87
|
-
## Geometry Nodes
|
|
88
|
-
|
|
89
|
-
| Node | Description |
|
|
90
|
-
|------|-------------|
|
|
91
|
-
| `positionLocal` | Model space position |
|
|
92
|
-
| `positionWorld` | World space position |
|
|
93
|
-
| `positionView` | Camera space position |
|
|
94
|
-
| `normalLocal` | Model space normal |
|
|
95
|
-
| `normalWorld` | World space normal |
|
|
96
|
-
| `normalView` | Camera space normal |
|
|
97
|
-
| `uv()` | UV coordinates |
|
|
98
|
-
| `uv(1)` | Secondary UVs |
|
|
99
|
-
| `tangentLocal` | Tangent vector |
|
|
100
|
-
| `vertexColor()` | Vertex colors |
|
|
101
|
-
|
|
102
|
-
## Camera Nodes
|
|
103
|
-
|
|
104
|
-
| Node | Description |
|
|
105
|
-
|------|-------------|
|
|
106
|
-
| `cameraPosition` | Camera world position |
|
|
107
|
-
| `cameraNear` | Near plane |
|
|
108
|
-
| `cameraFar` | Far plane |
|
|
109
|
-
| `cameraViewMatrix` | View matrix |
|
|
110
|
-
| `cameraProjectionMatrix` | Projection matrix |
|
|
111
|
-
| `screenUV` | Screen UV (0-1) |
|
|
112
|
-
| `screenSize` | Screen dimensions |
|
|
113
|
-
|
|
114
|
-
## Time
|
|
115
|
-
|
|
116
|
-
| Node | Description |
|
|
117
|
-
|------|-------------|
|
|
118
|
-
| `time` | Seconds since start |
|
|
119
|
-
| `deltaTime` | Frame delta |
|
|
120
|
-
| `oscSine(t)` | Sine wave (0-1) |
|
|
121
|
-
| `oscSquare(t)` | Square wave |
|
|
122
|
-
| `oscTriangle(t)` | Triangle wave |
|
|
123
|
-
| `oscSawtooth(t)` | Sawtooth wave |
|
|
124
|
-
|
|
125
|
-
## Material Properties
|
|
126
|
-
|
|
127
|
-
```javascript
|
|
128
|
-
const mat = new THREE.MeshStandardNodeMaterial();
|
|
129
|
-
|
|
130
|
-
// Basic
|
|
131
|
-
mat.colorNode = color(0xff0000);
|
|
132
|
-
mat.opacityNode = float(0.8);
|
|
133
|
-
mat.alphaTestNode = float(0.5);
|
|
134
|
-
|
|
135
|
-
// PBR
|
|
136
|
-
mat.roughnessNode = float(0.5);
|
|
137
|
-
mat.metalnessNode = float(0.0);
|
|
138
|
-
mat.emissiveNode = color(0x000000);
|
|
139
|
-
mat.normalNode = normalMap(tex);
|
|
140
|
-
|
|
141
|
-
// Physical (MeshPhysicalNodeMaterial)
|
|
142
|
-
mat.clearcoatNode = float(1.0);
|
|
143
|
-
mat.transmissionNode = float(0.9);
|
|
144
|
-
mat.iridescenceNode = float(1.0);
|
|
145
|
-
mat.sheenNode = float(1.0);
|
|
146
|
-
|
|
147
|
-
// Vertex
|
|
148
|
-
mat.positionNode = displaced;
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
## Control Flow
|
|
152
|
-
|
|
153
|
-
```javascript
|
|
154
|
-
// If-Else
|
|
155
|
-
If(condition, () => {
|
|
156
|
-
// true
|
|
157
|
-
}).ElseIf(other, () => {
|
|
158
|
-
// other true
|
|
159
|
-
}).Else(() => {
|
|
160
|
-
// false
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
// Select (ternary)
|
|
164
|
-
const result = select(condition, trueVal, falseVal);
|
|
165
|
-
|
|
166
|
-
// Loop
|
|
167
|
-
Loop(10, ({ i }) => {
|
|
168
|
-
// i = 0 to 9
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
// Loop control
|
|
172
|
-
Break();
|
|
173
|
-
Continue();
|
|
174
|
-
Discard(); // Fragment only
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
## Custom Functions
|
|
178
|
-
|
|
179
|
-
```javascript
|
|
180
|
-
// Basic function
|
|
181
|
-
const myFn = Fn(([a, b]) => {
|
|
182
|
-
return a.add(b);
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
// With defaults
|
|
186
|
-
const myFn = Fn(([a = 1.0, b = 2.0]) => {
|
|
187
|
-
return a.add(b);
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
// Usage
|
|
191
|
-
myFn(x, y);
|
|
192
|
-
myFn(); // uses defaults
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
## Compute Shaders
|
|
196
|
-
|
|
197
|
-
```javascript
|
|
198
|
-
// Storage buffers
|
|
199
|
-
const positions = instancedArray(count, 'vec3');
|
|
200
|
-
const values = instancedArray(count, 'float');
|
|
201
|
-
|
|
202
|
-
// Compute shader
|
|
203
|
-
const compute = Fn(() => {
|
|
204
|
-
const pos = positions.element(instanceIndex);
|
|
205
|
-
pos.addAssign(vec3(0.01, 0, 0));
|
|
206
|
-
})().compute(count);
|
|
207
|
-
|
|
208
|
-
// Execute
|
|
209
|
-
await renderer.computeAsync(compute); // Once
|
|
210
|
-
renderer.compute(compute); // Each frame
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
## Post-Processing
|
|
214
|
-
|
|
215
|
-
```javascript
|
|
216
|
-
import { pass } from 'three/tsl';
|
|
217
|
-
import { bloom } from 'three/addons/tsl/display/BloomNode.js';
|
|
218
|
-
|
|
219
|
-
// Setup
|
|
220
|
-
const postProcessing = new THREE.PostProcessing(renderer);
|
|
221
|
-
const scenePass = pass(scene, camera);
|
|
222
|
-
const color = scenePass.getTextureNode('output');
|
|
223
|
-
|
|
224
|
-
// Apply effects
|
|
225
|
-
const bloomPass = bloom(color);
|
|
226
|
-
postProcessing.outputNode = color.add(bloomPass);
|
|
227
|
-
|
|
228
|
-
// Render
|
|
229
|
-
postProcessing.render();
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
## Common Patterns
|
|
233
|
-
|
|
234
|
-
### Fresnel
|
|
235
|
-
|
|
236
|
-
```javascript
|
|
237
|
-
const viewDir = cameraPosition.sub(positionWorld).normalize();
|
|
238
|
-
const fresnel = float(1).sub(normalWorld.dot(viewDir).saturate()).pow(3);
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
### Animated UV
|
|
242
|
-
|
|
243
|
-
```javascript
|
|
244
|
-
const animUV = uv().add(vec2(time.mul(0.1), 0));
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
### Noise Hash
|
|
248
|
-
|
|
249
|
-
```javascript
|
|
250
|
-
const noise = fract(position.dot(vec3(12.9898, 78.233, 45.543)).sin().mul(43758.5453));
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
### Dissolve
|
|
254
|
-
|
|
255
|
-
```javascript
|
|
256
|
-
const noise = hash(positionLocal.mul(50));
|
|
257
|
-
If(noise.lessThan(threshold), () => Discard());
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
### Color Gradient
|
|
261
|
-
|
|
262
|
-
```javascript
|
|
263
|
-
const gradient = mix(colorA, colorB, positionLocal.y.mul(0.5).add(0.5));
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
## Node Materials
|
|
267
|
-
|
|
268
|
-
| Material | Use Case |
|
|
269
|
-
|----------|----------|
|
|
270
|
-
| `MeshBasicNodeMaterial` | Unlit |
|
|
271
|
-
| `MeshStandardNodeMaterial` | PBR |
|
|
272
|
-
| `MeshPhysicalNodeMaterial` | Advanced PBR |
|
|
273
|
-
| `MeshPhongNodeMaterial` | Phong shading |
|
|
274
|
-
| `MeshToonNodeMaterial` | Cel shading |
|
|
275
|
-
| `PointsNodeMaterial` | Point clouds |
|
|
276
|
-
| `LineBasicNodeMaterial` | Lines |
|
|
277
|
-
| `SpriteNodeMaterial` | Sprites |
|
|
278
|
-
|
|
279
|
-
## Resources
|
|
280
|
-
|
|
281
|
-
- [TSL Wiki](https://github.com/mrdoob/three.js/wiki/Three.js-Shading-Language)
|
|
282
|
-
- [WebGPU Examples](https://github.com/mrdoob/three.js/tree/master/examples)
|
|
283
|
-
- [Three.js Docs](https://threejs.org/docs/)
|