hoi4-agent-tools 0.0.0-bootstrap.1 → 0.1.3
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/CHANGELOG.md +50 -0
- package/LICENSE +201 -0
- package/README.md +140 -2
- package/SECURITY.md +17 -0
- package/dist/bin/http.d.ts +3 -0
- package/dist/bin/http.d.ts.map +1 -0
- package/dist/bin/http.js +27 -0
- package/dist/bin/http.js.map +1 -0
- package/dist/bin/setup.d.ts +3 -0
- package/dist/bin/setup.d.ts.map +1 -0
- package/dist/bin/setup.js +188 -0
- package/dist/bin/setup.js.map +1 -0
- package/dist/bin/stdio.d.ts +3 -0
- package/dist/bin/stdio.d.ts.map +1 -0
- package/dist/bin/stdio.js +36 -0
- package/dist/bin/stdio.js.map +1 -0
- package/dist/hoi4_agent_tools/core/artifacts.d.ts +117 -0
- package/dist/hoi4_agent_tools/core/artifacts.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/artifacts.js +1047 -0
- package/dist/hoi4_agent_tools/core/artifacts.js.map +1 -0
- package/dist/hoi4_agent_tools/core/canonical.d.ts +13 -0
- package/dist/hoi4_agent_tools/core/canonical.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/canonical.js +41 -0
- package/dist/hoi4_agent_tools/core/canonical.js.map +1 -0
- package/dist/hoi4_agent_tools/core/configuration.d.ts +137 -0
- package/dist/hoi4_agent_tools/core/configuration.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/configuration.js +383 -0
- package/dist/hoi4_agent_tools/core/configuration.js.map +1 -0
- package/dist/hoi4_agent_tools/core/diagnostic-collector.d.ts +18 -0
- package/dist/hoi4_agent_tools/core/diagnostic-collector.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/diagnostic-collector.js +45 -0
- package/dist/hoi4_agent_tools/core/diagnostic-collector.js.map +1 -0
- package/dist/hoi4_agent_tools/core/diagnostics.d.ts +26 -0
- package/dist/hoi4_agent_tools/core/diagnostics.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/diagnostics.js +25 -0
- package/dist/hoi4_agent_tools/core/diagnostics.js.map +1 -0
- package/dist/hoi4_agent_tools/core/diff.d.ts +22 -0
- package/dist/hoi4_agent_tools/core/diff.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/diff.js +93 -0
- package/dist/hoi4_agent_tools/core/diff.js.map +1 -0
- package/dist/hoi4_agent_tools/core/engine.d.ts +56 -0
- package/dist/hoi4_agent_tools/core/engine.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/engine.js +319 -0
- package/dist/hoi4_agent_tools/core/engine.js.map +1 -0
- package/dist/hoi4_agent_tools/core/image-diff.d.ts +14 -0
- package/dist/hoi4_agent_tools/core/image-diff.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/image-diff.js +121 -0
- package/dist/hoi4_agent_tools/core/image-diff.js.map +1 -0
- package/dist/hoi4_agent_tools/core/index.d.ts +64 -0
- package/dist/hoi4_agent_tools/core/index.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/index.js +963 -0
- package/dist/hoi4_agent_tools/core/index.js.map +1 -0
- package/dist/hoi4_agent_tools/core/index.public.d.ts +16 -0
- package/dist/hoi4_agent_tools/core/index.public.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/index.public.js +16 -0
- package/dist/hoi4_agent_tools/core/index.public.js.map +1 -0
- package/dist/hoi4_agent_tools/core/render-budget.d.ts +51 -0
- package/dist/hoi4_agent_tools/core/render-budget.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/render-budget.js +109 -0
- package/dist/hoi4_agent_tools/core/render-budget.js.map +1 -0
- package/dist/hoi4_agent_tools/core/result.d.ts +45 -0
- package/dist/hoi4_agent_tools/core/result.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/result.js +26 -0
- package/dist/hoi4_agent_tools/core/result.js.map +1 -0
- package/dist/hoi4_agent_tools/core/scanner.d.ts +28 -0
- package/dist/hoi4_agent_tools/core/scanner.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/scanner.js +136 -0
- package/dist/hoi4_agent_tools/core/scanner.js.map +1 -0
- package/dist/hoi4_agent_tools/core/server-state.d.ts +31 -0
- package/dist/hoi4_agent_tools/core/server-state.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/server-state.js +413 -0
- package/dist/hoi4_agent_tools/core/server-state.js.map +1 -0
- package/dist/hoi4_agent_tools/core/source/encoding.d.ts +10 -0
- package/dist/hoi4_agent_tools/core/source/encoding.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/source/encoding.js +54 -0
- package/dist/hoi4_agent_tools/core/source/encoding.js.map +1 -0
- package/dist/hoi4_agent_tools/core/source/index.d.ts +7 -0
- package/dist/hoi4_agent_tools/core/source/index.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/source/index.js +7 -0
- package/dist/hoi4_agent_tools/core/source/index.js.map +1 -0
- package/dist/hoi4_agent_tools/core/source/lexer.d.ts +30 -0
- package/dist/hoi4_agent_tools/core/source/lexer.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/source/lexer.js +266 -0
- package/dist/hoi4_agent_tools/core/source/lexer.js.map +1 -0
- package/dist/hoi4_agent_tools/core/source/limits.d.ts +21 -0
- package/dist/hoi4_agent_tools/core/source/limits.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/source/limits.js +49 -0
- package/dist/hoi4_agent_tools/core/source/limits.js.map +1 -0
- package/dist/hoi4_agent_tools/core/source/localisation.d.ts +20 -0
- package/dist/hoi4_agent_tools/core/source/localisation.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/source/localisation.js +163 -0
- package/dist/hoi4_agent_tools/core/source/localisation.js.map +1 -0
- package/dist/hoi4_agent_tools/core/source/parser.d.ts +44 -0
- package/dist/hoi4_agent_tools/core/source/parser.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/source/parser.js +334 -0
- package/dist/hoi4_agent_tools/core/source/parser.js.map +1 -0
- package/dist/hoi4_agent_tools/core/source/rewrite.d.ts +10 -0
- package/dist/hoi4_agent_tools/core/source/rewrite.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/source/rewrite.js +28 -0
- package/dist/hoi4_agent_tools/core/source/rewrite.js.map +1 -0
- package/dist/hoi4_agent_tools/core/svg-text.d.ts +34 -0
- package/dist/hoi4_agent_tools/core/svg-text.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/svg-text.js +127 -0
- package/dist/hoi4_agent_tools/core/svg-text.js.map +1 -0
- package/dist/hoi4_agent_tools/core/transaction-limits.d.ts +9 -0
- package/dist/hoi4_agent_tools/core/transaction-limits.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/transaction-limits.js +9 -0
- package/dist/hoi4_agent_tools/core/transaction-limits.js.map +1 -0
- package/dist/hoi4_agent_tools/core/transactions.d.ts +162 -0
- package/dist/hoi4_agent_tools/core/transactions.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/transactions.js +1181 -0
- package/dist/hoi4_agent_tools/core/transactions.js.map +1 -0
- package/dist/hoi4_agent_tools/core/workspace.d.ts +68 -0
- package/dist/hoi4_agent_tools/core/workspace.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/workspace.js +794 -0
- package/dist/hoi4_agent_tools/core/workspace.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/compiler.d.ts +9 -0
- package/dist/hoi4_agent_tools/focus/compiler.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/compiler.js +273 -0
- package/dist/hoi4_agent_tools/focus/compiler.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/continuous-render.d.ts +32 -0
- package/dist/hoi4_agent_tools/focus/continuous-render.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/continuous-render.js +179 -0
- package/dist/hoi4_agent_tools/focus/continuous-render.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/drift.d.ts +22 -0
- package/dist/hoi4_agent_tools/focus/drift.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/drift.js +124 -0
- package/dist/hoi4_agent_tools/focus/drift.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/geometry.d.ts +17 -0
- package/dist/hoi4_agent_tools/focus/geometry.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/geometry.js +35 -0
- package/dist/hoi4_agent_tools/focus/geometry.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/importer.d.ts +9 -0
- package/dist/hoi4_agent_tools/focus/importer.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/importer.js +732 -0
- package/dist/hoi4_agent_tools/focus/importer.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/index.d.ts +14 -0
- package/dist/hoi4_agent_tools/focus/index.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/index.js +14 -0
- package/dist/hoi4_agent_tools/focus/index.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/layout.d.ts +5 -0
- package/dist/hoi4_agent_tools/focus/layout.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/layout.js +653 -0
- package/dist/hoi4_agent_tools/focus/layout.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/limits.d.ts +9 -0
- package/dist/hoi4_agent_tools/focus/limits.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/limits.js +9 -0
- package/dist/hoi4_agent_tools/focus/limits.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/lint.d.ts +14 -0
- package/dist/hoi4_agent_tools/focus/lint.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/lint.js +839 -0
- package/dist/hoi4_agent_tools/focus/lint.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/model.d.ts +303 -0
- package/dist/hoi4_agent_tools/focus/model.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/model.js +20 -0
- package/dist/hoi4_agent_tools/focus/model.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/native-effects.d.ts +9 -0
- package/dist/hoi4_agent_tools/focus/native-effects.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/native-effects.js +563 -0
- package/dist/hoi4_agent_tools/focus/native-effects.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/planning.d.ts +15 -0
- package/dist/hoi4_agent_tools/focus/planning.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/planning.js +241 -0
- package/dist/hoi4_agent_tools/focus/planning.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/presentation.d.ts +24 -0
- package/dist/hoi4_agent_tools/focus/presentation.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/presentation.js +204 -0
- package/dist/hoi4_agent_tools/focus/presentation.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/render.d.ts +35 -0
- package/dist/hoi4_agent_tools/focus/render.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/render.js +491 -0
- package/dist/hoi4_agent_tools/focus/render.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/service.d.ts +82 -0
- package/dist/hoi4_agent_tools/focus/service.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/service.js +492 -0
- package/dist/hoi4_agent_tools/focus/service.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/source-update.d.ts +6 -0
- package/dist/hoi4_agent_tools/focus/source-update.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/source-update.js +328 -0
- package/dist/hoi4_agent_tools/focus/source-update.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/animation-manifest.d.ts +37 -0
- package/dist/hoi4_agent_tools/gui/animation-manifest.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/animation-manifest.js +66 -0
- package/dist/hoi4_agent_tools/gui/animation-manifest.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/assets.d.ts +71 -0
- package/dist/hoi4_agent_tools/gui/assets.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/assets.js +629 -0
- package/dist/hoi4_agent_tools/gui/assets.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/dds.d.ts +17 -0
- package/dist/hoi4_agent_tools/gui/dds.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/dds.js +245 -0
- package/dist/hoi4_agent_tools/gui/dds.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/helpers.d.ts +101 -0
- package/dist/hoi4_agent_tools/gui/helpers.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/helpers.js +1072 -0
- package/dist/hoi4_agent_tools/gui/helpers.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/index.d.ts +15 -0
- package/dist/hoi4_agent_tools/gui/index.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/index.js +15 -0
- package/dist/hoi4_agent_tools/gui/index.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/layout.d.ts +6 -0
- package/dist/hoi4_agent_tools/gui/layout.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/layout.js +753 -0
- package/dist/hoi4_agent_tools/gui/layout.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/limits.d.ts +25 -0
- package/dist/hoi4_agent_tools/gui/limits.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/limits.js +27 -0
- package/dist/hoi4_agent_tools/gui/limits.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/renderer.d.ts +18 -0
- package/dist/hoi4_agent_tools/gui/renderer.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/renderer.js +388 -0
- package/dist/hoi4_agent_tools/gui/renderer.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/scenario.d.ts +66 -0
- package/dist/hoi4_agent_tools/gui/scenario.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/scenario.js +191 -0
- package/dist/hoi4_agent_tools/gui/scenario.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/source-graph.d.ts +7 -0
- package/dist/hoi4_agent_tools/gui/source-graph.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/source-graph.js +1074 -0
- package/dist/hoi4_agent_tools/gui/source-graph.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/source-patch.d.ts +13 -0
- package/dist/hoi4_agent_tools/gui/source-patch.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/source-patch.js +90 -0
- package/dist/hoi4_agent_tools/gui/source-patch.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/studio.d.ts +86 -0
- package/dist/hoi4_agent_tools/gui/studio.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/studio.js +830 -0
- package/dist/hoi4_agent_tools/gui/studio.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/tga.d.ts +16 -0
- package/dist/hoi4_agent_tools/gui/tga.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/tga.js +157 -0
- package/dist/hoi4_agent_tools/gui/tga.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/types.d.ts +322 -0
- package/dist/hoi4_agent_tools/gui/types.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/types.js +19 -0
- package/dist/hoi4_agent_tools/gui/types.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/validators.d.ts +8 -0
- package/dist/hoi4_agent_tools/gui/validators.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/validators.js +951 -0
- package/dist/hoi4_agent_tools/gui/validators.js.map +1 -0
- package/dist/hoi4_agent_tools/map/bmp.d.ts +62 -0
- package/dist/hoi4_agent_tools/map/bmp.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/map/bmp.js +363 -0
- package/dist/hoi4_agent_tools/map/bmp.js.map +1 -0
- package/dist/hoi4_agent_tools/map/diagnostic-limit.d.ts +5 -0
- package/dist/hoi4_agent_tools/map/diagnostic-limit.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/map/diagnostic-limit.js +21 -0
- package/dist/hoi4_agent_tools/map/diagnostic-limit.js.map +1 -0
- package/dist/hoi4_agent_tools/map/index.d.ts +8 -0
- package/dist/hoi4_agent_tools/map/index.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/map/index.js +8 -0
- package/dist/hoi4_agent_tools/map/index.js.map +1 -0
- package/dist/hoi4_agent_tools/map/limits.d.ts +13 -0
- package/dist/hoi4_agent_tools/map/limits.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/map/limits.js +13 -0
- package/dist/hoi4_agent_tools/map/limits.js.map +1 -0
- package/dist/hoi4_agent_tools/map/model.d.ts +269 -0
- package/dist/hoi4_agent_tools/map/model.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/map/model.js +1114 -0
- package/dist/hoi4_agent_tools/map/model.js.map +1 -0
- package/dist/hoi4_agent_tools/map/operations.d.ts +401 -0
- package/dist/hoi4_agent_tools/map/operations.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/map/operations.js +2717 -0
- package/dist/hoi4_agent_tools/map/operations.js.map +1 -0
- package/dist/hoi4_agent_tools/map/render.d.ts +90 -0
- package/dist/hoi4_agent_tools/map/render.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/map/render.js +759 -0
- package/dist/hoi4_agent_tools/map/render.js.map +1 -0
- package/dist/hoi4_agent_tools/map/service.d.ts +81 -0
- package/dist/hoi4_agent_tools/map/service.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/map/service.js +695 -0
- package/dist/hoi4_agent_tools/map/service.js.map +1 -0
- package/dist/hoi4_agent_tools/map/validation.d.ts +23 -0
- package/dist/hoi4_agent_tools/map/validation.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/map/validation.js +1177 -0
- package/dist/hoi4_agent_tools/map/validation.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/prompts/register.d.ts +3 -0
- package/dist/hoi4_agent_tools/mcp/prompts/register.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/prompts/register.js +50 -0
- package/dist/hoi4_agent_tools/mcp/prompts/register.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/registry/metadata.d.ts +9 -0
- package/dist/hoi4_agent_tools/mcp/registry/metadata.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/registry/metadata.js +10 -0
- package/dist/hoi4_agent_tools/mcp/registry/metadata.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/resources/register.d.ts +5 -0
- package/dist/hoi4_agent_tools/mcp/resources/register.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/resources/register.js +278 -0
- package/dist/hoi4_agent_tools/mcp/resources/register.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/security/auth.d.ts +24 -0
- package/dist/hoi4_agent_tools/mcp/security/auth.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/security/auth.js +234 -0
- package/dist/hoi4_agent_tools/mcp/security/auth.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/server/base-tools.d.ts +35 -0
- package/dist/hoi4_agent_tools/mcp/server/base-tools.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/server/base-tools.js +835 -0
- package/dist/hoi4_agent_tools/mcp/server/base-tools.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/server/create.d.ts +5 -0
- package/dist/hoi4_agent_tools/mcp/server/create.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/server/create.js +26 -0
- package/dist/hoi4_agent_tools/mcp/server/create.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/server/output-schemas.d.ts +133 -0
- package/dist/hoi4_agent_tools/mcp/server/output-schemas.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/server/output-schemas.js +127 -0
- package/dist/hoi4_agent_tools/mcp/server/output-schemas.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/server/progress.d.ts +8 -0
- package/dist/hoi4_agent_tools/mcp/server/progress.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/server/progress.js +21 -0
- package/dist/hoi4_agent_tools/mcp/server/progress.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/server/result.d.ts +232 -0
- package/dist/hoi4_agent_tools/mcp/server/result.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/server/result.js +353 -0
- package/dist/hoi4_agent_tools/mcp/server/result.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/tools/focus.d.ts +5 -0
- package/dist/hoi4_agent_tools/mcp/tools/focus.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/tools/focus.js +1059 -0
- package/dist/hoi4_agent_tools/mcp/tools/focus.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/tools/gui.d.ts +111 -0
- package/dist/hoi4_agent_tools/mcp/tools/gui.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/tools/gui.js +598 -0
- package/dist/hoi4_agent_tools/mcp/tools/gui.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/tools/map.d.ts +5 -0
- package/dist/hoi4_agent_tools/mcp/tools/map.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/tools/map.js +685 -0
- package/dist/hoi4_agent_tools/mcp/tools/map.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/transports/bounded-stdio.d.ts +58 -0
- package/dist/hoi4_agent_tools/mcp/transports/bounded-stdio.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/transports/bounded-stdio.js +181 -0
- package/dist/hoi4_agent_tools/mcp/transports/bounded-stdio.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/transports/event-store.d.ts +26 -0
- package/dist/hoi4_agent_tools/mcp/transports/event-store.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/transports/event-store.js +86 -0
- package/dist/hoi4_agent_tools/mcp/transports/event-store.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/transports/http.d.ts +28 -0
- package/dist/hoi4_agent_tools/mcp/transports/http.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/transports/http.js +744 -0
- package/dist/hoi4_agent_tools/mcp/transports/http.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/transports/protocol-gate.d.ts +15 -0
- package/dist/hoi4_agent_tools/mcp/transports/protocol-gate.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/transports/protocol-gate.js +51 -0
- package/dist/hoi4_agent_tools/mcp/transports/protocol-gate.js.map +1 -0
- package/dist/hoi4_agent_tools/runtime.d.ts +4 -0
- package/dist/hoi4_agent_tools/runtime.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/runtime.js +27 -0
- package/dist/hoi4_agent_tools/runtime.js.map +1 -0
- package/dist/hoi4_agent_tools/schemas/common.d.ts +74 -0
- package/dist/hoi4_agent_tools/schemas/common.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/schemas/common.js +51 -0
- package/dist/hoi4_agent_tools/schemas/common.js.map +1 -0
- package/dist/hoi4_agent_tools/schemas/focus.d.ts +784 -0
- package/dist/hoi4_agent_tools/schemas/focus.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/schemas/focus.js +330 -0
- package/dist/hoi4_agent_tools/schemas/focus.js.map +1 -0
- package/dist/hoi4_agent_tools/schemas/index.d.ts +5 -0
- package/dist/hoi4_agent_tools/schemas/index.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/schemas/index.js +5 -0
- package/dist/hoi4_agent_tools/schemas/index.js.map +1 -0
- package/dist/hoi4_agent_tools/schemas/map.d.ts +654 -0
- package/dist/hoi4_agent_tools/schemas/map.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/schemas/map.js +570 -0
- package/dist/hoi4_agent_tools/schemas/map.js.map +1 -0
- package/dist/hoi4_agent_tools/schemas/transaction.d.ts +259 -0
- package/dist/hoi4_agent_tools/schemas/transaction.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/schemas/transaction.js +104 -0
- package/dist/hoi4_agent_tools/schemas/transaction.js.map +1 -0
- package/dist/hoi4_agent_tools/version.d.ts +6 -0
- package/dist/hoi4_agent_tools/version.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/version.js +7 -0
- package/dist/hoi4_agent_tools/version.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/docs/README.md +22 -0
- package/docs/adr/0001-runtime-and-language.md +16 -0
- package/docs/adr/0002-lossless-source-model.md +18 -0
- package/docs/adr/0003-image-and-font-codecs.md +18 -0
- package/docs/adr/0004-focus-layout.md +16 -0
- package/docs/adr/0005-offline-rendering.md +18 -0
- package/docs/adr/0006-mcp-sdk-and-protocol.md +16 -0
- package/docs/adr/0007-storage-and-transactions.md +24 -0
- package/docs/adr/0008-test-strategy.md +18 -0
- package/docs/adr/0009-packaging-and-registry.md +16 -0
- package/docs/adr/0010-unsupported-and-refusal-policy.md +18 -0
- package/docs/adr/0011-http-security.md +16 -0
- package/docs/adr/README.md +13 -0
- package/docs/architecture.md +60 -0
- package/docs/artifacts.md +133 -0
- package/docs/compatibility.md +33 -0
- package/docs/completion-report.md +69 -0
- package/docs/configuration.md +285 -0
- package/docs/focus-workflow.md +68 -0
- package/docs/gui-workflow.md +121 -0
- package/docs/limitations.md +30 -0
- package/docs/map-workflow.md +89 -0
- package/docs/performance.md +117 -0
- package/docs/release.md +200 -0
- package/docs/research/mcp-2026-07-10.md +46 -0
- package/docs/research/source-ledger.md +68 -0
- package/docs/security.md +139 -0
- package/docs/self-hosting.md +168 -0
- package/docs/testing.md +43 -0
- package/docs/third-party-notices.md +11 -0
- package/docs/transactions.md +162 -0
- package/docs/troubleshooting.md +46 -0
- package/package.json +98 -5
- package/schemas/configuration.schema.json +794 -0
- package/schemas/continuous-focus-palette.schema.json +325 -0
- package/schemas/focus-plan.schema.json +902 -0
- package/schemas/focus-planning-sidecar.schema.json +364 -0
- package/schemas/gui-animation-source.schema.json +176 -0
- package/schemas/gui-helper.schema.json +301 -0
- package/schemas/gui-scenario.schema.json +298 -0
- package/schemas/map-operation.schema.json +2284 -0
- package/schemas/operation-result.schema.json +344 -0
- package/schemas/transaction-manifest.schema.json +685 -0
- package/server.json +32 -0
|
@@ -0,0 +1,759 @@
|
|
|
1
|
+
import sharp from 'sharp';
|
|
2
|
+
import { compareCodeUnits, canonicalJson, sha256Bytes } from '../core/canonical.js';
|
|
3
|
+
import { assertRenderDimensions, RenderBudget, RENDER_MAX_PIXELS } from '../core/render-budget.js';
|
|
4
|
+
import { ServiceError } from '../core/result.js';
|
|
5
|
+
import { validateMapAsync } from './validation.js';
|
|
6
|
+
function stableColor(key) {
|
|
7
|
+
const hash = sha256Bytes(key);
|
|
8
|
+
const first = Number.parseInt(hash.slice(0, 2), 16);
|
|
9
|
+
const second = Number.parseInt(hash.slice(2, 4), 16);
|
|
10
|
+
const third = Number.parseInt(hash.slice(4, 6), 16);
|
|
11
|
+
return {
|
|
12
|
+
r: 48 + (first % 176),
|
|
13
|
+
g: 48 + (second % 176),
|
|
14
|
+
b: 48 + (third % 176),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function stateId(index, provinceId) {
|
|
18
|
+
const states = index.stateForProvince(provinceId);
|
|
19
|
+
return states.length === 1 ? states[0]?.id : undefined;
|
|
20
|
+
}
|
|
21
|
+
function regionId(index, provinceId) {
|
|
22
|
+
const regions = index.regionForProvince(provinceId);
|
|
23
|
+
return regions.length === 1 ? regions[0]?.id : undefined;
|
|
24
|
+
}
|
|
25
|
+
function baseColor(index, provinceId, layer) {
|
|
26
|
+
const definition = index.definitionsById.get(provinceId);
|
|
27
|
+
if (definition === undefined)
|
|
28
|
+
return { r: 255, g: 0, b: 255 };
|
|
29
|
+
const state = stateId(index, provinceId);
|
|
30
|
+
const stateRecord = state === undefined ? undefined : index.statesById.get(state);
|
|
31
|
+
if (layer === 'province')
|
|
32
|
+
return definition.color;
|
|
33
|
+
if (layer === 'state')
|
|
34
|
+
return stableColor(state === undefined ? 'state:none' : `state:${state}`);
|
|
35
|
+
if (layer === 'strategic-region') {
|
|
36
|
+
const region = regionId(index, provinceId);
|
|
37
|
+
return stableColor(region === undefined ? 'region:none' : `region:${region}`);
|
|
38
|
+
}
|
|
39
|
+
if (layer === 'terrain')
|
|
40
|
+
return stableColor(`terrain:${definition.terrain}`);
|
|
41
|
+
if (layer === 'continent')
|
|
42
|
+
return stableColor(`continent:${definition.continent}`);
|
|
43
|
+
if (layer === 'owner')
|
|
44
|
+
return stableColor(`owner:${stateRecord?.owner ?? 'none'}`);
|
|
45
|
+
if (layer === 'controller')
|
|
46
|
+
return stableColor(`controller:${stateRecord?.controller ?? stateRecord?.owner ?? 'none'}`);
|
|
47
|
+
if (layer === 'cores')
|
|
48
|
+
return stableColor(`cores:${[...(stateRecord?.cores ?? [])].sort().join(',') || 'none'}`);
|
|
49
|
+
if (layer === 'claims')
|
|
50
|
+
return stableColor(`claims:${[...(stateRecord?.claims ?? [])].sort().join(',') || 'none'}`);
|
|
51
|
+
return index.raster?.coastalProvinceIds.has(provinceId)
|
|
52
|
+
? definition.type === 'land'
|
|
53
|
+
? { r: 227, g: 186, b: 65 }
|
|
54
|
+
: { r: 44, g: 158, b: 202 }
|
|
55
|
+
: { r: 45, g: 51, b: 58 };
|
|
56
|
+
}
|
|
57
|
+
function setPixel(bytes, width, height, x, y, color, alpha = 255) {
|
|
58
|
+
if (x < 0 || y < 0 || x >= width || y >= height)
|
|
59
|
+
return;
|
|
60
|
+
const offset = (y * width + x) * 4;
|
|
61
|
+
bytes[offset] = color.r;
|
|
62
|
+
bytes[offset + 1] = color.g;
|
|
63
|
+
bytes[offset + 2] = color.b;
|
|
64
|
+
bytes[offset + 3] = alpha;
|
|
65
|
+
}
|
|
66
|
+
function marker(bytes, width, height, x, y, color, radius = 2) {
|
|
67
|
+
for (let dy = -radius; dy <= radius; dy += 1) {
|
|
68
|
+
for (let dx = -radius; dx <= radius; dx += 1) {
|
|
69
|
+
if (dx * dx + dy * dy <= radius * radius)
|
|
70
|
+
setPixel(bytes, width, height, Math.round(x) + dx, Math.round(y) + dy, color);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function line(bytes, width, height, from, to, color) {
|
|
75
|
+
let x0 = Math.round(from.centerX);
|
|
76
|
+
let y0 = Math.round(from.centerY);
|
|
77
|
+
const x1 = Math.round(to.centerX);
|
|
78
|
+
const y1 = Math.round(to.centerY);
|
|
79
|
+
const dx = Math.abs(x1 - x0);
|
|
80
|
+
const sx = x0 < x1 ? 1 : -1;
|
|
81
|
+
const dy = -Math.abs(y1 - y0);
|
|
82
|
+
const sy = y0 < y1 ? 1 : -1;
|
|
83
|
+
let error = dx + dy;
|
|
84
|
+
for (;;) {
|
|
85
|
+
marker(bytes, width, height, x0, y0, color, 1);
|
|
86
|
+
if (x0 === x1 && y0 === y1)
|
|
87
|
+
break;
|
|
88
|
+
const doubled = error * 2;
|
|
89
|
+
if (doubled >= dy) {
|
|
90
|
+
error += dy;
|
|
91
|
+
x0 += sx;
|
|
92
|
+
}
|
|
93
|
+
if (doubled <= dx) {
|
|
94
|
+
error += dx;
|
|
95
|
+
y0 += sy;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function provinceCenter(index, provinceId) {
|
|
100
|
+
return index.raster?.geometry.get(provinceId);
|
|
101
|
+
}
|
|
102
|
+
function stateCenter(index, state) {
|
|
103
|
+
let pixels = 0;
|
|
104
|
+
let weightedX = 0;
|
|
105
|
+
let weightedY = 0;
|
|
106
|
+
let minX = Number.POSITIVE_INFINITY;
|
|
107
|
+
let minY = Number.POSITIVE_INFINITY;
|
|
108
|
+
let maxX = Number.NEGATIVE_INFINITY;
|
|
109
|
+
let maxY = Number.NEGATIVE_INFINITY;
|
|
110
|
+
for (const provinceId of state.provinces) {
|
|
111
|
+
const geometry = provinceCenter(index, provinceId);
|
|
112
|
+
if (geometry === undefined)
|
|
113
|
+
continue;
|
|
114
|
+
pixels += geometry.pixelCount;
|
|
115
|
+
weightedX += geometry.centerX * geometry.pixelCount;
|
|
116
|
+
weightedY += geometry.centerY * geometry.pixelCount;
|
|
117
|
+
minX = Math.min(minX, geometry.minX);
|
|
118
|
+
minY = Math.min(minY, geometry.minY);
|
|
119
|
+
maxX = Math.max(maxX, geometry.maxX);
|
|
120
|
+
maxY = Math.max(maxY, geometry.maxY);
|
|
121
|
+
}
|
|
122
|
+
if (pixels === 0)
|
|
123
|
+
return undefined;
|
|
124
|
+
return {
|
|
125
|
+
id: state.id,
|
|
126
|
+
pixelCount: pixels,
|
|
127
|
+
minX,
|
|
128
|
+
minY,
|
|
129
|
+
maxX,
|
|
130
|
+
maxY,
|
|
131
|
+
centerX: weightedX / pixels,
|
|
132
|
+
centerY: weightedY / pixels,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function valueMarkers(bytes, width, height, center, values, namespace, phase) {
|
|
136
|
+
const entries = [...values].sort(([left], [right]) => compareCodeUnits(left, right));
|
|
137
|
+
for (const [index, [key, value]] of entries.entries()) {
|
|
138
|
+
const angle = ((index + phase) % 8) * (Math.PI / 4);
|
|
139
|
+
const ring = 3 + Math.floor((index + phase) / 8) * 3;
|
|
140
|
+
marker(bytes, width, height, center.centerX + Math.cos(angle) * ring, center.centerY + Math.sin(angle) * ring, stableColor(`${namespace}:${key}`), Math.min(4, Math.max(1, Math.ceil(Math.log2(Math.max(0, value) + 1)))));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
async function renderCheckpoint(signal) {
|
|
144
|
+
signal?.throwIfAborted();
|
|
145
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
146
|
+
signal?.throwIfAborted();
|
|
147
|
+
}
|
|
148
|
+
function mapCoordinateToPixel(index, x, z) {
|
|
149
|
+
const raster = index.raster;
|
|
150
|
+
if (raster === undefined)
|
|
151
|
+
return undefined;
|
|
152
|
+
const pixel = { x: Math.floor(x), y: raster.height - 1 - Math.floor(z) };
|
|
153
|
+
return pixel.x < 0 || pixel.y < 0 || pixel.x >= raster.width || pixel.y >= raster.height
|
|
154
|
+
? undefined
|
|
155
|
+
: pixel;
|
|
156
|
+
}
|
|
157
|
+
async function applyOverlays(index, bytes, overlays, signal) {
|
|
158
|
+
const raster = index.raster;
|
|
159
|
+
if (raster === undefined)
|
|
160
|
+
return;
|
|
161
|
+
if (overlays.has('coastlines')) {
|
|
162
|
+
for (let y = 0; y < raster.height; y += 1) {
|
|
163
|
+
if (y % 32 === 0)
|
|
164
|
+
await renderCheckpoint(signal);
|
|
165
|
+
for (let x = 0; x < raster.width; x += 1) {
|
|
166
|
+
const id = raster.provinceIds[y * raster.width + x] ?? -1;
|
|
167
|
+
const definition = index.definitionsById.get(id);
|
|
168
|
+
if (definition?.type !== 'land')
|
|
169
|
+
continue;
|
|
170
|
+
const neighbors = [
|
|
171
|
+
raster.provinceIds[y * raster.width + (x === 0 ? raster.width - 1 : x - 1)] ?? -1,
|
|
172
|
+
raster.provinceIds[y * raster.width + (x === raster.width - 1 ? 0 : x + 1)] ?? -1,
|
|
173
|
+
y === 0 ? -1 : (raster.provinceIds[(y - 1) * raster.width + x] ?? -1),
|
|
174
|
+
y === raster.height - 1 ? -1 : (raster.provinceIds[(y + 1) * raster.width + x] ?? -1),
|
|
175
|
+
];
|
|
176
|
+
if (neighbors.some((neighbor) => index.definitionsById.get(neighbor)?.type === 'sea')) {
|
|
177
|
+
setPixel(bytes, raster.width, raster.height, x, y, { r: 65, g: 223, b: 255 });
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (overlays.has('ports')) {
|
|
183
|
+
for (const state of index.states) {
|
|
184
|
+
for (const [provinceId, buildings] of state.provinceBuildings) {
|
|
185
|
+
if ((buildings.get('naval_base') ?? 0) <= 0)
|
|
186
|
+
continue;
|
|
187
|
+
const center = provinceCenter(index, provinceId);
|
|
188
|
+
if (center !== undefined)
|
|
189
|
+
marker(bytes, raster.width, raster.height, center.centerX, center.centerY, { r: 46, g: 221, b: 255 }, 3);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (overlays.has('victory-points')) {
|
|
194
|
+
for (const state of index.states) {
|
|
195
|
+
for (const point of state.victoryPoints) {
|
|
196
|
+
const center = provinceCenter(index, point.provinceId);
|
|
197
|
+
if (center !== undefined)
|
|
198
|
+
marker(bytes, raster.width, raster.height, center.centerX, center.centerY, { r: 255, g: 223, b: 72 }, Math.min(5, Math.max(2, Math.ceil(point.value / 10))));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (overlays.has('resources')) {
|
|
203
|
+
for (const state of [...index.states].sort((left, right) => left.id - right.id)) {
|
|
204
|
+
signal?.throwIfAborted();
|
|
205
|
+
const center = stateCenter(index, state);
|
|
206
|
+
if (center !== undefined)
|
|
207
|
+
valueMarkers(bytes, raster.width, raster.height, center, state.resources, 'resource', 0);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (overlays.has('state-buildings')) {
|
|
211
|
+
for (const state of [...index.states].sort((left, right) => left.id - right.id)) {
|
|
212
|
+
signal?.throwIfAborted();
|
|
213
|
+
const center = stateCenter(index, state);
|
|
214
|
+
if (center !== undefined)
|
|
215
|
+
valueMarkers(bytes, raster.width, raster.height, center, state.stateBuildings, 'state-building', 2);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (overlays.has('province-buildings')) {
|
|
219
|
+
for (const state of [...index.states].sort((left, right) => left.id - right.id)) {
|
|
220
|
+
for (const [provinceId, buildings] of [...state.provinceBuildings].sort(([left], [right]) => left - right)) {
|
|
221
|
+
signal?.throwIfAborted();
|
|
222
|
+
const center = provinceCenter(index, provinceId);
|
|
223
|
+
if (center !== undefined)
|
|
224
|
+
valueMarkers(bytes, raster.width, raster.height, center, buildings, 'province-building', 4);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (overlays.has('supply-nodes')) {
|
|
229
|
+
for (const node of index.supplyNodes) {
|
|
230
|
+
const center = provinceCenter(index, node.provinceId);
|
|
231
|
+
if (center !== undefined)
|
|
232
|
+
marker(bytes, raster.width, raster.height, center.centerX, center.centerY, { r: 241, g: 76, b: 76 }, 3);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (overlays.has('railways')) {
|
|
236
|
+
for (const railway of index.railways) {
|
|
237
|
+
for (let position = 1; position < railway.provinces.length; position += 1) {
|
|
238
|
+
const fromId = railway.provinces[position - 1];
|
|
239
|
+
const toId = railway.provinces[position];
|
|
240
|
+
if (fromId === undefined || toId === undefined)
|
|
241
|
+
continue;
|
|
242
|
+
const from = provinceCenter(index, fromId);
|
|
243
|
+
const to = provinceCenter(index, toId);
|
|
244
|
+
if (from !== undefined && to !== undefined)
|
|
245
|
+
line(bytes, raster.width, raster.height, from, to, { r: 94, g: 233, b: 121 });
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
if (overlays.has('adjacencies')) {
|
|
250
|
+
for (const adjacency of index.adjacencies) {
|
|
251
|
+
const from = provinceCenter(index, adjacency.from);
|
|
252
|
+
const to = provinceCenter(index, adjacency.to);
|
|
253
|
+
if (from !== undefined && to !== undefined)
|
|
254
|
+
line(bytes, raster.width, raster.height, from, to, adjacency.type === 'impassable' ? { r: 255, g: 72, b: 72 } : { r: 211, g: 102, b: 255 });
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
if (overlays.has('building-positions')) {
|
|
258
|
+
for (const position of index.buildingPositions) {
|
|
259
|
+
const pixel = mapCoordinateToPixel(index, position.x, position.z);
|
|
260
|
+
if (pixel !== undefined)
|
|
261
|
+
marker(bytes, raster.width, raster.height, pixel.x, pixel.y, { r: 255, g: 153, b: 51 }, 2);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
if (overlays.has('unit-positions')) {
|
|
265
|
+
for (const position of index.unitPositions) {
|
|
266
|
+
const pixel = mapCoordinateToPixel(index, position.x, position.z);
|
|
267
|
+
if (pixel !== undefined)
|
|
268
|
+
marker(bytes, raster.width, raster.height, pixel.x, pixel.y, { r: 255, g: 255, b: 255 }, 2);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (overlays.has('weather-positions')) {
|
|
272
|
+
for (const position of index.weatherPositions) {
|
|
273
|
+
const pixel = mapCoordinateToPixel(index, position.x, position.z);
|
|
274
|
+
if (pixel !== undefined)
|
|
275
|
+
marker(bytes, raster.width, raster.height, pixel.x, pixel.y, { r: 88, g: 174, b: 255 }, position.size === 'big' ? 4 : 2);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
async function renderMetadata(index, options, signal) {
|
|
280
|
+
const victoryPoints = index.states
|
|
281
|
+
.flatMap((state) => state.victoryPoints.map(({ provinceId, value }) => ({
|
|
282
|
+
stateId: state.id,
|
|
283
|
+
provinceId,
|
|
284
|
+
value,
|
|
285
|
+
sourcePath: state.file.displayPath,
|
|
286
|
+
})))
|
|
287
|
+
.sort((left, right) => left.stateId - right.stateId ||
|
|
288
|
+
left.provinceId - right.provinceId ||
|
|
289
|
+
left.value - right.value);
|
|
290
|
+
const normalAdjacencies = [...(index.raster?.adjacency ?? [])]
|
|
291
|
+
.flatMap(([from, neighbors]) => [...neighbors].flatMap((to) => (from < to ? [{ from, to }] : [])))
|
|
292
|
+
.sort((left, right) => left.from - right.from || left.to - right.to);
|
|
293
|
+
return {
|
|
294
|
+
offline: true,
|
|
295
|
+
renderer: 'hoi4-agent-tools-agent-nudger',
|
|
296
|
+
layer: options.layer,
|
|
297
|
+
overlays: options.overlays,
|
|
298
|
+
scale: options.scale,
|
|
299
|
+
width: index.raster?.width ?? 0,
|
|
300
|
+
height: index.raster?.height ?? 0,
|
|
301
|
+
definitions: index.definitions.map(({ id, color, type, coastal, terrain, continent }) => ({
|
|
302
|
+
id,
|
|
303
|
+
color,
|
|
304
|
+
type,
|
|
305
|
+
coastal,
|
|
306
|
+
terrain,
|
|
307
|
+
continent,
|
|
308
|
+
})),
|
|
309
|
+
states: [...index.states]
|
|
310
|
+
.sort((left, right) => left.id - right.id)
|
|
311
|
+
.map(({ id, name, capital, provinces, resources, stateBuildings, provinceBuildings, owner, controller, cores, claims, }) => ({
|
|
312
|
+
id,
|
|
313
|
+
name,
|
|
314
|
+
capital: capital ?? null,
|
|
315
|
+
manpower: index.statesById.get(id)?.manpower ?? 0,
|
|
316
|
+
category: index.statesById.get(id)?.category ?? '',
|
|
317
|
+
provinces: [...provinces].sort((a, b) => a - b),
|
|
318
|
+
resources: Object.fromEntries([...resources].sort(([left], [right]) => compareCodeUnits(left, right))),
|
|
319
|
+
stateBuildings: Object.fromEntries([...stateBuildings].sort(([left], [right]) => compareCodeUnits(left, right))),
|
|
320
|
+
provinceBuildings: Object.fromEntries([...provinceBuildings]
|
|
321
|
+
.sort(([left], [right]) => left - right)
|
|
322
|
+
.map(([provinceId, buildings]) => [
|
|
323
|
+
String(provinceId),
|
|
324
|
+
Object.fromEntries([...buildings].sort(([left], [right]) => compareCodeUnits(left, right))),
|
|
325
|
+
])),
|
|
326
|
+
owner: owner ?? null,
|
|
327
|
+
controller: controller ?? null,
|
|
328
|
+
cores: [...cores].sort(),
|
|
329
|
+
claims: [...claims].sort(),
|
|
330
|
+
})),
|
|
331
|
+
regions: [...index.regions]
|
|
332
|
+
.sort((left, right) => left.id - right.id)
|
|
333
|
+
.map(({ id, name, provinces }) => ({
|
|
334
|
+
id,
|
|
335
|
+
name,
|
|
336
|
+
provinces: [...provinces].sort((a, b) => a - b),
|
|
337
|
+
})),
|
|
338
|
+
victoryPoints,
|
|
339
|
+
ports: [...index.ports]
|
|
340
|
+
.sort((left, right) => left.stateId - right.stateId || left.provinceId - right.provinceId)
|
|
341
|
+
.map(({ stateId, provinceId, level, coastal, adjacentSeaProvinceIds, positions }) => ({
|
|
342
|
+
stateId,
|
|
343
|
+
provinceId,
|
|
344
|
+
level,
|
|
345
|
+
coastal,
|
|
346
|
+
adjacentSeaProvinceIds: [...adjacentSeaProvinceIds].sort((left, right) => left - right),
|
|
347
|
+
positions: positions.map(({ building, x, y, z, rotation, adjacentSeaProvince, document, line }) => ({
|
|
348
|
+
building,
|
|
349
|
+
x,
|
|
350
|
+
y,
|
|
351
|
+
z,
|
|
352
|
+
rotation,
|
|
353
|
+
adjacentSeaProvince,
|
|
354
|
+
sourcePath: document.file.displayPath,
|
|
355
|
+
line,
|
|
356
|
+
})),
|
|
357
|
+
})),
|
|
358
|
+
supplyNodes: index.supplyNodes.map(({ level, provinceId, document, line }) => ({
|
|
359
|
+
level,
|
|
360
|
+
provinceId,
|
|
361
|
+
sourcePath: document.file.displayPath,
|
|
362
|
+
line,
|
|
363
|
+
})),
|
|
364
|
+
railways: index.railways.map(({ level, declaredCount, provinces, document, line }, ordinal) => ({
|
|
365
|
+
ordinal,
|
|
366
|
+
level,
|
|
367
|
+
declaredCount,
|
|
368
|
+
provinces: [...provinces],
|
|
369
|
+
sourcePath: document.file.displayPath,
|
|
370
|
+
line,
|
|
371
|
+
})),
|
|
372
|
+
adjacencies: index.adjacencies.map(({ from, to, type, through, startX, startY, stopX, stopY, rule, comment, document, line }, ordinal) => ({
|
|
373
|
+
ordinal,
|
|
374
|
+
from,
|
|
375
|
+
to,
|
|
376
|
+
type,
|
|
377
|
+
through,
|
|
378
|
+
startX,
|
|
379
|
+
startY,
|
|
380
|
+
stopX,
|
|
381
|
+
stopY,
|
|
382
|
+
rule,
|
|
383
|
+
comment,
|
|
384
|
+
sourcePath: document.file.displayPath,
|
|
385
|
+
line,
|
|
386
|
+
})),
|
|
387
|
+
normalAdjacencies,
|
|
388
|
+
buildingPositions: index.buildingPositions.map(({ stateId, building, x, y, z, rotation, adjacentSeaProvince, document, line }) => ({
|
|
389
|
+
stateId,
|
|
390
|
+
building,
|
|
391
|
+
x,
|
|
392
|
+
y,
|
|
393
|
+
z,
|
|
394
|
+
rotation,
|
|
395
|
+
adjacentSeaProvince,
|
|
396
|
+
sourcePath: document.file.displayPath,
|
|
397
|
+
line,
|
|
398
|
+
})),
|
|
399
|
+
unitPositions: index.unitPositions.map(({ provinceId, type, x, y, z, rotation, offset, document, line }) => ({
|
|
400
|
+
provinceId,
|
|
401
|
+
type,
|
|
402
|
+
x,
|
|
403
|
+
y,
|
|
404
|
+
z,
|
|
405
|
+
rotation,
|
|
406
|
+
offset,
|
|
407
|
+
sourcePath: document.file.displayPath,
|
|
408
|
+
line,
|
|
409
|
+
})),
|
|
410
|
+
weatherPositions: index.weatherPositions.map(({ strategicRegionId, x, y, z, size, document, line }) => ({
|
|
411
|
+
strategicRegionId,
|
|
412
|
+
x,
|
|
413
|
+
y,
|
|
414
|
+
z,
|
|
415
|
+
size,
|
|
416
|
+
sourcePath: document.file.displayPath,
|
|
417
|
+
line,
|
|
418
|
+
})),
|
|
419
|
+
entityLocators: [...index.entityLocators]
|
|
420
|
+
.sort((left, right) => compareCodeUnits(left.entity, right.entity) || compareCodeUnits(left.name, right.name))
|
|
421
|
+
.map(({ entity, name, position, file }) => ({
|
|
422
|
+
entity,
|
|
423
|
+
name,
|
|
424
|
+
position: [...position],
|
|
425
|
+
sourcePath: file.displayPath,
|
|
426
|
+
})),
|
|
427
|
+
validation: await validateMapAsync(index, signal === undefined ? {} : { signal }),
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
function htmlDocument(title, png, json) {
|
|
431
|
+
const escapedTitle = title
|
|
432
|
+
.replaceAll('&', '&')
|
|
433
|
+
.replaceAll('<', '<')
|
|
434
|
+
.replaceAll('>', '>');
|
|
435
|
+
const escapedJson = json.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>');
|
|
436
|
+
return `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${escapedTitle}</title><style>html{background:#10151b;color:#edf2f7;font:14px system-ui}body{margin:20px}.controls{display:flex;gap:8px;align-items:center;margin:12px 0}button{background:#263241;color:#edf2f7;border:1px solid #526173;border-radius:4px;padding:6px 10px}.viewport{height:70vh;overflow:hidden;border:1px solid #48515c;background:#080b0f;position:relative;touch-action:none}.viewport img{image-rendering:pixelated;transform-origin:0 0;position:absolute;max-width:none;cursor:grab;user-select:none}.viewport img.dragging{cursor:grabbing}pre{white-space:pre-wrap;overflow-wrap:anywhere}</style></head><body><h1>${escapedTitle}</h1><p>Offline deterministic map representation; not an in-game screenshot or source editor.</p><div class="controls"><button id="out" type="button">-</button><button id="reset" type="button">Reset</button><button id="in" type="button">+</button><output id="zoom">100%</output></div><div class="viewport" id="viewport"><img id="map" draggable="false" alt="${escapedTitle}" src="data:image/png;base64,${png.toString('base64')}"></div><details><summary>Render metadata</summary><pre>${escapedJson}</pre></details><script>(()=>{const image=document.getElementById('map'),viewport=document.getElementById('viewport'),label=document.getElementById('zoom');let scale=1,x=0,y=0,drag=false,lastX=0,lastY=0;const draw=()=>{image.style.transform='translate('+x+'px,'+y+'px) scale('+scale+')';label.value=Math.round(scale*100)+'%'};const zoom=(factor,cx=viewport.clientWidth/2,cy=viewport.clientHeight/2)=>{const next=Math.min(16,Math.max(.1,scale*factor));x=cx-(cx-x)*(next/scale);y=cy-(cy-y)*(next/scale);scale=next;draw()};document.getElementById('in').onclick=()=>zoom(1.25);document.getElementById('out').onclick=()=>zoom(.8);document.getElementById('reset').onclick=()=>{scale=1;x=0;y=0;draw()};viewport.addEventListener('wheel',event=>{event.preventDefault();const bounds=viewport.getBoundingClientRect();zoom(event.deltaY<0?1.15:.87,event.clientX-bounds.left,event.clientY-bounds.top)},{passive:false});image.addEventListener('pointerdown',event=>{drag=true;lastX=event.clientX;lastY=event.clientY;image.setPointerCapture(event.pointerId);image.classList.add('dragging')});image.addEventListener('pointermove',event=>{if(!drag)return;x+=event.clientX-lastX;y+=event.clientY-lastY;lastX=event.clientX;lastY=event.clientY;draw()});image.addEventListener('pointerup',()=>{drag=false;image.classList.remove('dragging')});draw()})();</script></body></html>`;
|
|
437
|
+
}
|
|
438
|
+
async function encodePng(raw, width, height, scale) {
|
|
439
|
+
assertRenderDimensions(width, height, 'map Sharp source raster');
|
|
440
|
+
assertRenderDimensions(width * scale, height * scale, 'map Sharp output raster');
|
|
441
|
+
let pipeline = sharp(raw, {
|
|
442
|
+
raw: { width, height, channels: 4 },
|
|
443
|
+
limitInputPixels: RENDER_MAX_PIXELS,
|
|
444
|
+
});
|
|
445
|
+
if (scale !== 1)
|
|
446
|
+
pipeline = pipeline.resize(width * scale, height * scale, { kernel: 'nearest' });
|
|
447
|
+
return pipeline.png({ compressionLevel: 9, adaptiveFiltering: false, palette: false }).toBuffer();
|
|
448
|
+
}
|
|
449
|
+
export async function renderMap(index, options = {}) {
|
|
450
|
+
const raster = index.raster;
|
|
451
|
+
if (raster === undefined) {
|
|
452
|
+
const budgetDiagnostic = index.diagnostics.find(({ code }) => code.startsWith('RENDER_'));
|
|
453
|
+
if (budgetDiagnostic !== undefined) {
|
|
454
|
+
throw new ServiceError(budgetDiagnostic.code, budgetDiagnostic.message, budgetDiagnostic.details ?? {});
|
|
455
|
+
}
|
|
456
|
+
throw new ServiceError('MAP_RENDER_RASTER_MISSING', 'Cannot render without a valid province bitmap and definitions');
|
|
457
|
+
}
|
|
458
|
+
const resolved = {
|
|
459
|
+
layer: options.layer ?? 'province',
|
|
460
|
+
overlays: [...new Set(options.overlays ?? [])].sort(),
|
|
461
|
+
scale: options.scale ?? 1,
|
|
462
|
+
};
|
|
463
|
+
if (!Number.isInteger(resolved.scale) || resolved.scale < 1 || resolved.scale > 16)
|
|
464
|
+
throw new ServiceError('MAP_RENDER_SCALE_INVALID', 'Map render scale must be an integer from 1 through 16');
|
|
465
|
+
const budget = options.budget ?? new RenderBudget();
|
|
466
|
+
assertRenderDimensions(raster.width, raster.height, 'map RGBA source plane');
|
|
467
|
+
const outputDimensions = budget.reserve(raster.width * resolved.scale, raster.height * resolved.scale, 'map PNG output');
|
|
468
|
+
const raw = Buffer.alloc(raster.width * raster.height * 4);
|
|
469
|
+
for (let offset = 0; offset < raster.provinceIds.length; offset += 1) {
|
|
470
|
+
if (offset % Math.max(raster.width * 32, 1) === 0)
|
|
471
|
+
await renderCheckpoint(options.signal);
|
|
472
|
+
const color = baseColor(index, raster.provinceIds[offset] ?? -1, resolved.layer);
|
|
473
|
+
const target = offset * 4;
|
|
474
|
+
raw[target] = color.r;
|
|
475
|
+
raw[target + 1] = color.g;
|
|
476
|
+
raw[target + 2] = color.b;
|
|
477
|
+
raw[target + 3] = 255;
|
|
478
|
+
}
|
|
479
|
+
await applyOverlays(index, raw, new Set(resolved.overlays), options.signal);
|
|
480
|
+
options.signal?.throwIfAborted();
|
|
481
|
+
const png = await encodePng(raw, raster.width, raster.height, resolved.scale);
|
|
482
|
+
options.signal?.throwIfAborted();
|
|
483
|
+
const json = `${canonicalJson(await renderMetadata(index, resolved, options.signal))}\n`;
|
|
484
|
+
const html = htmlDocument(`Agent Nudger map - ${resolved.layer}`, png, json);
|
|
485
|
+
return {
|
|
486
|
+
width: outputDimensions.width,
|
|
487
|
+
height: outputDimensions.height,
|
|
488
|
+
png,
|
|
489
|
+
json,
|
|
490
|
+
html,
|
|
491
|
+
hashes: { png: sha256Bytes(png), json: sha256Bytes(json), html: sha256Bytes(html) },
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
function definitionSignature(index, id) {
|
|
495
|
+
const value = index.definitionsById.get(id);
|
|
496
|
+
return value === undefined
|
|
497
|
+
? null
|
|
498
|
+
: canonicalJson({
|
|
499
|
+
color: value.color,
|
|
500
|
+
type: value.type,
|
|
501
|
+
coastal: value.coastal,
|
|
502
|
+
terrain: value.terrain,
|
|
503
|
+
continent: value.continent,
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
function listSignature(value) {
|
|
507
|
+
return canonicalJson(value);
|
|
508
|
+
}
|
|
509
|
+
function stateSignature(index, id) {
|
|
510
|
+
const state = index.statesById.get(id);
|
|
511
|
+
return state === undefined
|
|
512
|
+
? null
|
|
513
|
+
: canonicalJson({
|
|
514
|
+
name: state.name,
|
|
515
|
+
capital: state.capital ?? null,
|
|
516
|
+
manpower: state.manpower,
|
|
517
|
+
category: state.category,
|
|
518
|
+
resources: Object.fromEntries(state.resources),
|
|
519
|
+
owner: state.owner ?? null,
|
|
520
|
+
controller: state.controller ?? null,
|
|
521
|
+
cores: [...state.cores].sort(),
|
|
522
|
+
claims: [...state.claims].sort(),
|
|
523
|
+
victoryPoints: state.victoryPoints
|
|
524
|
+
.map(({ provinceId, value }) => ({ provinceId, value }))
|
|
525
|
+
.sort((left, right) => left.provinceId - right.provinceId || left.value - right.value),
|
|
526
|
+
stateBuildings: Object.fromEntries(state.stateBuildings),
|
|
527
|
+
provinceBuildings: Object.fromEntries([...state.provinceBuildings]
|
|
528
|
+
.sort(([left], [right]) => left - right)
|
|
529
|
+
.map(([provinceId, buildings]) => [String(provinceId), Object.fromEntries(buildings)])),
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
function diffRecordMaps(before, after) {
|
|
533
|
+
return [...new Set([...before.keys(), ...after.keys()])]
|
|
534
|
+
.sort((left, right) => compareCodeUnits(left, right))
|
|
535
|
+
.flatMap((key) => {
|
|
536
|
+
const left = before.get(key) ?? null;
|
|
537
|
+
const right = after.get(key) ?? null;
|
|
538
|
+
return left === right ? [] : [{ key, before: left, after: right }];
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
function occurrenceRecordMap(values, groupKey, signature) {
|
|
542
|
+
const occurrences = new Map();
|
|
543
|
+
const result = new Map();
|
|
544
|
+
for (const value of values) {
|
|
545
|
+
const group = groupKey(value);
|
|
546
|
+
const occurrence = occurrences.get(group) ?? 0;
|
|
547
|
+
occurrences.set(group, occurrence + 1);
|
|
548
|
+
result.set(`${group}:${occurrence}`, canonicalJson(signature(value)));
|
|
549
|
+
}
|
|
550
|
+
return result;
|
|
551
|
+
}
|
|
552
|
+
export function semanticMapDiff(before, after) {
|
|
553
|
+
const provinceIds = uniqueNumbers([
|
|
554
|
+
...before.definitionsById.keys(),
|
|
555
|
+
...after.definitionsById.keys(),
|
|
556
|
+
]);
|
|
557
|
+
const definitions = provinceIds.flatMap((id) => {
|
|
558
|
+
const left = definitionSignature(before, id);
|
|
559
|
+
const right = definitionSignature(after, id);
|
|
560
|
+
return left === right ? [] : [{ id, before: left, after: right }];
|
|
561
|
+
});
|
|
562
|
+
const stateMembership = provinceIds.flatMap((provinceId) => {
|
|
563
|
+
const left = before
|
|
564
|
+
.stateForProvince(provinceId)
|
|
565
|
+
.map(({ id }) => id)
|
|
566
|
+
.sort((a, b) => a - b);
|
|
567
|
+
const right = after
|
|
568
|
+
.stateForProvince(provinceId)
|
|
569
|
+
.map(({ id }) => id)
|
|
570
|
+
.sort((a, b) => a - b);
|
|
571
|
+
return listSignature(left) === listSignature(right)
|
|
572
|
+
? []
|
|
573
|
+
: [{ provinceId, before: left, after: right }];
|
|
574
|
+
});
|
|
575
|
+
const regionMembership = provinceIds.flatMap((provinceId) => {
|
|
576
|
+
const left = before
|
|
577
|
+
.regionForProvince(provinceId)
|
|
578
|
+
.map(({ id }) => id)
|
|
579
|
+
.sort((a, b) => a - b);
|
|
580
|
+
const right = after
|
|
581
|
+
.regionForProvince(provinceId)
|
|
582
|
+
.map(({ id }) => id)
|
|
583
|
+
.sort((a, b) => a - b);
|
|
584
|
+
return listSignature(left) === listSignature(right)
|
|
585
|
+
? []
|
|
586
|
+
: [{ provinceId, before: left, after: right }];
|
|
587
|
+
});
|
|
588
|
+
const stateIds = uniqueNumbers([...before.statesById.keys(), ...after.statesById.keys()]);
|
|
589
|
+
const states = stateIds.flatMap((id) => {
|
|
590
|
+
const left = stateSignature(before, id);
|
|
591
|
+
const right = stateSignature(after, id);
|
|
592
|
+
return left === right ? [] : [{ key: String(id), before: left, after: right }];
|
|
593
|
+
});
|
|
594
|
+
const portRecords = (index) => new Map(index.ports.map((port) => [
|
|
595
|
+
`${port.stateId}:${port.provinceId}`,
|
|
596
|
+
canonicalJson({
|
|
597
|
+
level: port.level,
|
|
598
|
+
coastal: port.coastal,
|
|
599
|
+
adjacentSeaProvinceIds: port.adjacentSeaProvinceIds,
|
|
600
|
+
positionCount: port.positions.length,
|
|
601
|
+
}),
|
|
602
|
+
]));
|
|
603
|
+
const buildingPositionRecords = (index) => occurrenceRecordMap(index.buildingPositions, ({ stateId, building }) => `${stateId}:${building}`, ({ stateId, building, x, y, z, rotation, adjacentSeaProvince }) => ({
|
|
604
|
+
stateId,
|
|
605
|
+
building,
|
|
606
|
+
x,
|
|
607
|
+
y,
|
|
608
|
+
z,
|
|
609
|
+
rotation,
|
|
610
|
+
adjacentSeaProvince,
|
|
611
|
+
}));
|
|
612
|
+
const unitPositionRecords = (index) => occurrenceRecordMap(index.unitPositions, ({ provinceId, type }) => `${provinceId}:${type}`, ({ provinceId, type, x, y, z, rotation, offset }) => ({
|
|
613
|
+
provinceId,
|
|
614
|
+
type,
|
|
615
|
+
x,
|
|
616
|
+
y,
|
|
617
|
+
z,
|
|
618
|
+
rotation,
|
|
619
|
+
offset,
|
|
620
|
+
}));
|
|
621
|
+
const weatherPositionRecords = (index) => occurrenceRecordMap(index.weatherPositions, ({ strategicRegionId, size }) => `${strategicRegionId}:${size}`, ({ strategicRegionId, x, y, z, size }) => ({ strategicRegionId, x, y, z, size }));
|
|
622
|
+
const entityLocatorRecords = (index) => occurrenceRecordMap(index.entityLocators, ({ entity, name }) => `${entity}:${name}`, ({ entity, name, position }) => ({ entity, name, position }));
|
|
623
|
+
const supplyNodeRecords = (index) => occurrenceRecordMap(index.supplyNodes, ({ provinceId }) => String(provinceId), ({ level, provinceId }) => ({ level, provinceId }));
|
|
624
|
+
const railwayRecords = (index) => new Map(index.railways.map(({ level, provinces }, position) => [
|
|
625
|
+
String(position),
|
|
626
|
+
canonicalJson({ level, provinces }),
|
|
627
|
+
]));
|
|
628
|
+
const adjacencyRecords = (index) => occurrenceRecordMap(index.adjacencies, ({ from, to, type }) => `${Math.min(from, to)}:${Math.max(from, to)}:${type}`, ({ from, to, type, through, startX, startY, stopX, stopY, rule, comment }) => ({
|
|
629
|
+
from,
|
|
630
|
+
to,
|
|
631
|
+
type,
|
|
632
|
+
through,
|
|
633
|
+
startX,
|
|
634
|
+
startY,
|
|
635
|
+
stopX,
|
|
636
|
+
stopY,
|
|
637
|
+
rule,
|
|
638
|
+
comment,
|
|
639
|
+
}));
|
|
640
|
+
const normalAdjacencyRecords = (index) => {
|
|
641
|
+
const result = new Map();
|
|
642
|
+
for (const [from, neighbors] of index.raster?.adjacency ?? []) {
|
|
643
|
+
for (const to of neighbors) {
|
|
644
|
+
if (from >= to)
|
|
645
|
+
continue;
|
|
646
|
+
result.set(`${from}:${to}`, canonicalJson({ from, to }));
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
return result;
|
|
650
|
+
};
|
|
651
|
+
const beforeNormalAdjacencies = normalAdjacencyRecords(before);
|
|
652
|
+
const afterNormalAdjacencies = normalAdjacencyRecords(after);
|
|
653
|
+
const normalAdjacencies = diffRecordMaps(beforeNormalAdjacencies, afterNormalAdjacencies);
|
|
654
|
+
return {
|
|
655
|
+
definitions,
|
|
656
|
+
stateMembership,
|
|
657
|
+
regionMembership,
|
|
658
|
+
states,
|
|
659
|
+
ports: diffRecordMaps(portRecords(before), portRecords(after)),
|
|
660
|
+
buildingPositions: diffRecordMaps(buildingPositionRecords(before), buildingPositionRecords(after)),
|
|
661
|
+
unitPositions: diffRecordMaps(unitPositionRecords(before), unitPositionRecords(after)),
|
|
662
|
+
weatherPositions: diffRecordMaps(weatherPositionRecords(before), weatherPositionRecords(after)),
|
|
663
|
+
entityLocators: diffRecordMaps(entityLocatorRecords(before), entityLocatorRecords(after)),
|
|
664
|
+
supplyNodes: diffRecordMaps(supplyNodeRecords(before), supplyNodeRecords(after)),
|
|
665
|
+
railways: diffRecordMaps(railwayRecords(before), railwayRecords(after)),
|
|
666
|
+
adjacencies: diffRecordMaps(adjacencyRecords(before), adjacencyRecords(after)),
|
|
667
|
+
normalAdjacencies,
|
|
668
|
+
supplyNodesChanged: listSignature(before.supplyNodes.map(({ level, provinceId }) => ({ level, provinceId }))) !==
|
|
669
|
+
listSignature(after.supplyNodes.map(({ level, provinceId }) => ({ level, provinceId }))),
|
|
670
|
+
railwaysChanged: listSignature(before.railways.map(({ level, provinces }) => ({ level, provinces }))) !==
|
|
671
|
+
listSignature(after.railways.map(({ level, provinces }) => ({ level, provinces }))),
|
|
672
|
+
adjacenciesChanged: listSignature(before.adjacencies.map(({ from, to, type, through, rule }) => ({
|
|
673
|
+
from,
|
|
674
|
+
to,
|
|
675
|
+
type,
|
|
676
|
+
through,
|
|
677
|
+
rule,
|
|
678
|
+
}))) !==
|
|
679
|
+
listSignature(after.adjacencies.map(({ from, to, type, through, rule }) => ({
|
|
680
|
+
from,
|
|
681
|
+
to,
|
|
682
|
+
type,
|
|
683
|
+
through,
|
|
684
|
+
rule,
|
|
685
|
+
}))),
|
|
686
|
+
normalAdjacenciesChanged: normalAdjacencies.length > 0,
|
|
687
|
+
};
|
|
688
|
+
}
|
|
689
|
+
function uniqueNumbers(values) {
|
|
690
|
+
return [...new Set(values)].sort((left, right) => left - right);
|
|
691
|
+
}
|
|
692
|
+
export async function renderMapDiff(before, after, options = {}) {
|
|
693
|
+
const left = before.provinceBitmap;
|
|
694
|
+
const right = after.provinceBitmap;
|
|
695
|
+
if (left === undefined || right?.width !== left.width || left.height !== right.height) {
|
|
696
|
+
const budgetDiagnostic = [...before.diagnostics, ...after.diagnostics].find(({ code }) => code.startsWith('RENDER_'));
|
|
697
|
+
if (budgetDiagnostic !== undefined) {
|
|
698
|
+
throw new ServiceError(budgetDiagnostic.code, budgetDiagnostic.message, budgetDiagnostic.details ?? {});
|
|
699
|
+
}
|
|
700
|
+
throw new ServiceError('MAP_DIFF_BITMAP_MISMATCH', 'Map diff requires same-sized baseline and proposed province bitmaps');
|
|
701
|
+
}
|
|
702
|
+
const scale = options.scale ?? 1;
|
|
703
|
+
if (!Number.isInteger(scale) || scale < 1 || scale > 16)
|
|
704
|
+
throw new ServiceError('MAP_RENDER_SCALE_INVALID', 'Map render scale must be an integer from 1 through 16');
|
|
705
|
+
const budget = options.budget ?? new RenderBudget();
|
|
706
|
+
assertRenderDimensions(left.width, left.height, 'map diff RGBA source plane');
|
|
707
|
+
const outputDimensions = budget.reserve(left.width * scale, left.height * scale, 'map diff PNG output');
|
|
708
|
+
const raw = Buffer.alloc(left.width * left.height * 4);
|
|
709
|
+
const changedProvinceIds = new Set();
|
|
710
|
+
for (let y = 0; y < left.height; y += 1) {
|
|
711
|
+
if (y % 32 === 0)
|
|
712
|
+
await renderCheckpoint(options.signal);
|
|
713
|
+
for (let x = 0; x < left.width; x += 1) {
|
|
714
|
+
const beforeColor = left.rgbAt(x, y);
|
|
715
|
+
const afterColor = right.rgbAt(x, y);
|
|
716
|
+
const changed = beforeColor.r !== afterColor.r ||
|
|
717
|
+
beforeColor.g !== afterColor.g ||
|
|
718
|
+
beforeColor.b !== afterColor.b;
|
|
719
|
+
setPixel(raw, left.width, left.height, x, y, changed ? { r: 255, g: 54, b: 124 } : { r: 43, g: 48, b: 55 }, 255);
|
|
720
|
+
if (changed) {
|
|
721
|
+
const offset = y * left.width + x;
|
|
722
|
+
const beforeId = before.raster?.provinceIds[offset] ?? -1;
|
|
723
|
+
const afterId = after.raster?.provinceIds[offset] ?? -1;
|
|
724
|
+
if (beforeId >= 0)
|
|
725
|
+
changedProvinceIds.add(beforeId);
|
|
726
|
+
if (afterId >= 0)
|
|
727
|
+
changedProvinceIds.add(afterId);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
options.signal?.throwIfAborted();
|
|
732
|
+
const png = await encodePng(raw, left.width, left.height, scale);
|
|
733
|
+
options.signal?.throwIfAborted();
|
|
734
|
+
const semantic = semanticMapDiff(before, after);
|
|
735
|
+
const changedBounds = left.diffBounds(right);
|
|
736
|
+
const metadata = {
|
|
737
|
+
offline: true,
|
|
738
|
+
renderer: 'hoi4-agent-tools-agent-nudger-diff',
|
|
739
|
+
changedBounds: changedBounds ?? null,
|
|
740
|
+
changedProvinceIds: [...changedProvinceIds].sort((a, b) => a - b),
|
|
741
|
+
semantic,
|
|
742
|
+
...(options.review === undefined ? {} : { review: options.review }),
|
|
743
|
+
};
|
|
744
|
+
const json = `${canonicalJson(metadata)}\n`;
|
|
745
|
+
const html = htmlDocument('Agent Nudger pixel and semantic diff', png, json);
|
|
746
|
+
return {
|
|
747
|
+
width: outputDimensions.width,
|
|
748
|
+
height: outputDimensions.height,
|
|
749
|
+
png,
|
|
750
|
+
json,
|
|
751
|
+
html,
|
|
752
|
+
hashes: { png: sha256Bytes(png), json: sha256Bytes(json), html: sha256Bytes(html) },
|
|
753
|
+
...(changedBounds === undefined ? {} : { changedBounds }),
|
|
754
|
+
changedProvinceIds: metadata.changedProvinceIds,
|
|
755
|
+
semantic,
|
|
756
|
+
...(options.review === undefined ? {} : { review: options.review }),
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
//# sourceMappingURL=render.js.map
|