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,1177 @@
|
|
|
1
|
+
import { setImmediate as yieldToEventLoop } from 'node:timers/promises';
|
|
2
|
+
import { sortDiagnostics } from '../core/diagnostics.js';
|
|
3
|
+
import { assertRenderDimensions } from '../core/render-budget.js';
|
|
4
|
+
import { addMapDiagnostic as addBoundedMapDiagnostic } from './diagnostic-limit.js';
|
|
5
|
+
import { rgbKey } from './bmp.js';
|
|
6
|
+
import { MAP_PROVINCE_ENGINE_MAX_PIXELS } from './model.js';
|
|
7
|
+
const MAP_DIAGNOSTIC_DETAIL_SAMPLE_LIMIT = 100;
|
|
8
|
+
function* cancellationCheckpoint(signal, iteration = 0, stride = 1) {
|
|
9
|
+
if (iteration % stride !== 0)
|
|
10
|
+
return;
|
|
11
|
+
signal?.throwIfAborted();
|
|
12
|
+
yield;
|
|
13
|
+
}
|
|
14
|
+
function completeSynchronously(steps) {
|
|
15
|
+
for (;;) {
|
|
16
|
+
const step = steps.next();
|
|
17
|
+
if (step.done)
|
|
18
|
+
return step.value;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
async function completeCooperatively(steps, signal) {
|
|
22
|
+
let yieldDeadline = performance.now() + 8;
|
|
23
|
+
for (;;) {
|
|
24
|
+
const step = steps.next();
|
|
25
|
+
if (step.done)
|
|
26
|
+
return step.value;
|
|
27
|
+
signal?.throwIfAborted();
|
|
28
|
+
if (performance.now() < yieldDeadline)
|
|
29
|
+
continue;
|
|
30
|
+
await yieldToEventLoop();
|
|
31
|
+
signal?.throwIfAborted();
|
|
32
|
+
yieldDeadline = performance.now() + 8;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function lineLocation(document, oneBasedLine) {
|
|
36
|
+
const line = document.lines[oneBasedLine - 1];
|
|
37
|
+
if (line === undefined)
|
|
38
|
+
return undefined;
|
|
39
|
+
return {
|
|
40
|
+
path: document.file.displayPath,
|
|
41
|
+
start: { line: oneBasedLine, column: 1, offset: line.start },
|
|
42
|
+
end: { line: oneBasedLine, column: line.text.length + 1, offset: line.end },
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function requiredLineLocation(document, oneBasedLine) {
|
|
46
|
+
return (lineLocation(document, oneBasedLine) ?? {
|
|
47
|
+
path: document.file.displayPath,
|
|
48
|
+
start: { line: oneBasedLine, column: 1, offset: 0 },
|
|
49
|
+
end: { line: oneBasedLine, column: 1, offset: 0 },
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function definitionLocation(definition) {
|
|
53
|
+
return requiredLineLocation(definition.document, definition.line);
|
|
54
|
+
}
|
|
55
|
+
function addDiagnostic(diagnostics, options, diagnostic) {
|
|
56
|
+
addBoundedMapDiagnostic(diagnostics, {
|
|
57
|
+
...diagnostic,
|
|
58
|
+
...(diagnostic.operationId !== undefined || options.operationId === undefined
|
|
59
|
+
? {}
|
|
60
|
+
: { operationId: options.operationId }),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function duplicateValues(values, key) {
|
|
64
|
+
const groups = new Map();
|
|
65
|
+
for (const value of values) {
|
|
66
|
+
const id = key(value);
|
|
67
|
+
const group = groups.get(id) ?? [];
|
|
68
|
+
group.push(value);
|
|
69
|
+
groups.set(id, group);
|
|
70
|
+
}
|
|
71
|
+
return new Map([...groups].filter(([, group]) => group.length > 1));
|
|
72
|
+
}
|
|
73
|
+
function contiguousMissing(ids, start) {
|
|
74
|
+
const sorted = [...new Set(ids)].sort((left, right) => left - right);
|
|
75
|
+
const sample = [];
|
|
76
|
+
let total = 0;
|
|
77
|
+
let expected = start;
|
|
78
|
+
for (const id of sorted) {
|
|
79
|
+
if (!Number.isSafeInteger(id) || id < expected)
|
|
80
|
+
continue;
|
|
81
|
+
if (id > expected) {
|
|
82
|
+
const gap = id - expected;
|
|
83
|
+
total += gap;
|
|
84
|
+
for (let missing = expected; missing < id && sample.length < 100; missing += 1) {
|
|
85
|
+
sample.push(missing);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
expected = id + 1;
|
|
89
|
+
}
|
|
90
|
+
return { sample, total };
|
|
91
|
+
}
|
|
92
|
+
function stateLocation(state) {
|
|
93
|
+
return {
|
|
94
|
+
path: state.file.displayPath,
|
|
95
|
+
start: {
|
|
96
|
+
line: state.assignment.key.token.line,
|
|
97
|
+
column: state.assignment.key.token.column,
|
|
98
|
+
offset: state.assignment.start,
|
|
99
|
+
},
|
|
100
|
+
end: {
|
|
101
|
+
line: state.assignment.key.token.line,
|
|
102
|
+
column: state.assignment.key.token.column + state.assignment.key.token.text.length,
|
|
103
|
+
offset: state.assignment.end,
|
|
104
|
+
},
|
|
105
|
+
symbol: String(state.id),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function regionLocation(region) {
|
|
109
|
+
return {
|
|
110
|
+
path: region.file.displayPath,
|
|
111
|
+
start: {
|
|
112
|
+
line: region.assignment.key.token.line,
|
|
113
|
+
column: region.assignment.key.token.column,
|
|
114
|
+
offset: region.assignment.start,
|
|
115
|
+
},
|
|
116
|
+
end: {
|
|
117
|
+
line: region.assignment.key.token.line,
|
|
118
|
+
column: region.assignment.key.token.column + region.assignment.key.token.text.length,
|
|
119
|
+
offset: region.assignment.end,
|
|
120
|
+
},
|
|
121
|
+
symbol: String(region.id),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function* provinceComponents(raster, signal) {
|
|
125
|
+
assertRenderDimensions(raster.width, raster.height, 'map validation raster');
|
|
126
|
+
const visited = new Uint8Array(raster.provinceIds.length);
|
|
127
|
+
const counts = new Map();
|
|
128
|
+
const queue = new Int32Array(raster.provinceIds.length);
|
|
129
|
+
for (let start = 0; start < raster.provinceIds.length; start += 1) {
|
|
130
|
+
yield* cancellationCheckpoint(signal, start, 4096);
|
|
131
|
+
const id = raster.provinceIds[start] ?? -1;
|
|
132
|
+
if (id < 0 || visited[start] === 1)
|
|
133
|
+
continue;
|
|
134
|
+
counts.set(id, (counts.get(id) ?? 0) + 1);
|
|
135
|
+
let head = 0;
|
|
136
|
+
let tail = 0;
|
|
137
|
+
queue[tail++] = start;
|
|
138
|
+
visited[start] = 1;
|
|
139
|
+
while (head < tail) {
|
|
140
|
+
yield* cancellationCheckpoint(signal, head, 4096);
|
|
141
|
+
const offset = queue[head++] ?? -1;
|
|
142
|
+
const x = offset % raster.width;
|
|
143
|
+
const y = Math.floor(offset / raster.width);
|
|
144
|
+
const neighbors = [
|
|
145
|
+
y * raster.width + (x === 0 ? raster.width - 1 : x - 1),
|
|
146
|
+
y * raster.width + (x === raster.width - 1 ? 0 : x + 1),
|
|
147
|
+
y === 0 ? -1 : offset - raster.width,
|
|
148
|
+
y === raster.height - 1 ? -1 : offset + raster.width,
|
|
149
|
+
];
|
|
150
|
+
for (const neighbor of neighbors) {
|
|
151
|
+
if (neighbor < 0 || visited[neighbor] === 1 || raster.provinceIds[neighbor] !== id)
|
|
152
|
+
continue;
|
|
153
|
+
visited[neighbor] = 1;
|
|
154
|
+
queue[tail++] = neighbor;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return counts;
|
|
159
|
+
}
|
|
160
|
+
function* provinceThinPixels(raster, signal) {
|
|
161
|
+
const result = new Set();
|
|
162
|
+
for (let y = 1; y < raster.height - 1; y += 1) {
|
|
163
|
+
yield* cancellationCheckpoint(signal, y, 16);
|
|
164
|
+
for (let x = 0; x < raster.width; x += 1) {
|
|
165
|
+
const offset = y * raster.width + x;
|
|
166
|
+
const id = raster.provinceIds[offset] ?? -1;
|
|
167
|
+
if (id < 0)
|
|
168
|
+
continue;
|
|
169
|
+
const left = raster.provinceIds[y * raster.width + (x === 0 ? raster.width - 1 : x - 1)] === id;
|
|
170
|
+
const right = raster.provinceIds[y * raster.width + (x === raster.width - 1 ? 0 : x + 1)] === id;
|
|
171
|
+
const up = raster.provinceIds[offset - raster.width] === id;
|
|
172
|
+
const down = raster.provinceIds[offset + raster.width] === id;
|
|
173
|
+
if ((left && right && !up && !down) || (!left && !right && up && down))
|
|
174
|
+
result.add(id);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return result;
|
|
178
|
+
}
|
|
179
|
+
function addEulerSample(samples, id, topLeft, topRight, bottomLeft, bottomRight) {
|
|
180
|
+
if (id <= 0)
|
|
181
|
+
return;
|
|
182
|
+
const matches = Number(topLeft === id) +
|
|
183
|
+
Number(topRight === id) +
|
|
184
|
+
Number(bottomLeft === id) +
|
|
185
|
+
Number(bottomRight === id);
|
|
186
|
+
if (matches !== 1 && matches !== 3 && matches !== 2)
|
|
187
|
+
return;
|
|
188
|
+
const current = samples.get(id) ?? { one: 0, three: 0, diagonal: 0 };
|
|
189
|
+
if (matches === 1)
|
|
190
|
+
current.one += 1;
|
|
191
|
+
else if (matches === 3)
|
|
192
|
+
current.three += 1;
|
|
193
|
+
else if ((topLeft === id && bottomRight === id && topRight !== id && bottomLeft !== id) ||
|
|
194
|
+
(topRight === id && bottomLeft === id && topLeft !== id && bottomRight !== id)) {
|
|
195
|
+
current.diagonal += 1;
|
|
196
|
+
}
|
|
197
|
+
samples.set(id, current);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Count enclosed background components with the 4-connected digital Euler
|
|
201
|
+
* characteristic. One padded 2x2 pass covers every province, avoiding a
|
|
202
|
+
* province-by-province flood fill. Provinces touching the horizontally wrapping
|
|
203
|
+
* map seam are omitted because planar padding cannot model their cylindrical
|
|
204
|
+
* topology without inventing a boundary.
|
|
205
|
+
*/
|
|
206
|
+
function* provinceHoleCounts(raster, components, signal) {
|
|
207
|
+
const samples = new Map();
|
|
208
|
+
const at = (x, y) => x < 0 || x >= raster.width || y < 0 || y >= raster.height
|
|
209
|
+
? -1
|
|
210
|
+
: (raster.provinceIds[y * raster.width + x] ?? -1);
|
|
211
|
+
for (let y = -1; y < raster.height; y += 1) {
|
|
212
|
+
yield* cancellationCheckpoint(signal, y + 1, 16);
|
|
213
|
+
for (let x = -1; x < raster.width; x += 1) {
|
|
214
|
+
const topLeft = at(x, y);
|
|
215
|
+
const topRight = at(x + 1, y);
|
|
216
|
+
const bottomLeft = at(x, y + 1);
|
|
217
|
+
const bottomRight = at(x + 1, y + 1);
|
|
218
|
+
addEulerSample(samples, topLeft, topLeft, topRight, bottomLeft, bottomRight);
|
|
219
|
+
if (topRight !== topLeft)
|
|
220
|
+
addEulerSample(samples, topRight, topLeft, topRight, bottomLeft, bottomRight);
|
|
221
|
+
if (bottomLeft !== topLeft && bottomLeft !== topRight)
|
|
222
|
+
addEulerSample(samples, bottomLeft, topLeft, topRight, bottomLeft, bottomRight);
|
|
223
|
+
if (bottomRight !== topLeft && bottomRight !== topRight && bottomRight !== bottomLeft) {
|
|
224
|
+
addEulerSample(samples, bottomRight, topLeft, topRight, bottomLeft, bottomRight);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
const holes = new Map();
|
|
229
|
+
for (const [id, sample] of samples) {
|
|
230
|
+
const geometry = raster.geometry.get(id);
|
|
231
|
+
if (geometry === undefined || geometry.minX === 0 || geometry.maxX === raster.width - 1)
|
|
232
|
+
continue;
|
|
233
|
+
const eulerCharacteristic = Math.round((sample.one - sample.three - 2 * sample.diagonal) / 4);
|
|
234
|
+
const count = (components.get(id) ?? 0) - eulerCharacteristic;
|
|
235
|
+
if (count > 0)
|
|
236
|
+
holes.set(id, count);
|
|
237
|
+
}
|
|
238
|
+
return holes;
|
|
239
|
+
}
|
|
240
|
+
function* validateGeometry(index, diagnostics, options) {
|
|
241
|
+
yield* cancellationCheckpoint(options.signal);
|
|
242
|
+
const bitmap = index.provinceBitmap;
|
|
243
|
+
const raster = index.raster;
|
|
244
|
+
if (bitmap === undefined || raster === undefined)
|
|
245
|
+
return;
|
|
246
|
+
const baselineBitmap = options.baseline?.provinceBitmap;
|
|
247
|
+
if (baselineBitmap !== undefined) {
|
|
248
|
+
const formatChanges = [
|
|
249
|
+
{
|
|
250
|
+
changed: baselineBitmap.width !== bitmap.width || baselineBitmap.height !== bitmap.height,
|
|
251
|
+
code: 'MAP_BMP_DIMENSIONS_CHANGED',
|
|
252
|
+
message: 'Province bitmap dimensions changed from the baseline',
|
|
253
|
+
before: { width: baselineBitmap.width, height: baselineBitmap.height },
|
|
254
|
+
after: { width: bitmap.width, height: bitmap.height },
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
changed: baselineBitmap.dibSize !== bitmap.dibSize,
|
|
258
|
+
code: 'MAP_BMP_DIB_CHANGED',
|
|
259
|
+
message: 'Province bitmap DIB header type changed from the baseline',
|
|
260
|
+
before: baselineBitmap.dibSize,
|
|
261
|
+
after: bitmap.dibSize,
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
changed: baselineBitmap.topDown !== bitmap.topDown,
|
|
265
|
+
code: 'MAP_BMP_ORIENTATION_CHANGED',
|
|
266
|
+
message: 'Province bitmap row orientation changed from the baseline',
|
|
267
|
+
before: baselineBitmap.topDown ? 'top-down' : 'bottom-up',
|
|
268
|
+
after: bitmap.topDown ? 'top-down' : 'bottom-up',
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
changed: baselineBitmap.pixelOffset !== bitmap.pixelOffset,
|
|
272
|
+
code: 'MAP_BMP_PIXEL_OFFSET_CHANGED',
|
|
273
|
+
message: 'Province bitmap pixel-array offset changed from the baseline',
|
|
274
|
+
before: baselineBitmap.pixelOffset,
|
|
275
|
+
after: bitmap.pixelOffset,
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
changed: baselineBitmap.bitsPerPixel !== bitmap.bitsPerPixel,
|
|
279
|
+
code: 'MAP_BMP_BIT_DEPTH_CHANGED',
|
|
280
|
+
message: 'Province bitmap bit depth changed from the baseline',
|
|
281
|
+
before: baselineBitmap.bitsPerPixel,
|
|
282
|
+
after: bitmap.bitsPerPixel,
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
changed: JSON.stringify(baselineBitmap.palette.map(rgbKey)) !==
|
|
286
|
+
JSON.stringify(bitmap.palette.map(rgbKey)),
|
|
287
|
+
code: 'MAP_BMP_PALETTE_CHANGED',
|
|
288
|
+
message: 'Province bitmap palette changed from the baseline',
|
|
289
|
+
before: baselineBitmap.palette.map(rgbKey),
|
|
290
|
+
after: bitmap.palette.map(rgbKey),
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
changed: !baselineBitmap.bytes
|
|
294
|
+
.subarray(0, baselineBitmap.pixelOffset)
|
|
295
|
+
.equals(bitmap.bytes.subarray(0, bitmap.pixelOffset)),
|
|
296
|
+
code: 'MAP_BMP_HEADER_CHANGED',
|
|
297
|
+
message: 'Province bitmap file/DIB header bytes changed from the baseline',
|
|
298
|
+
before: { bytes: baselineBitmap.pixelOffset },
|
|
299
|
+
after: { bytes: bitmap.pixelOffset },
|
|
300
|
+
},
|
|
301
|
+
];
|
|
302
|
+
for (const change of formatChanges) {
|
|
303
|
+
if (!change.changed)
|
|
304
|
+
continue;
|
|
305
|
+
addDiagnostic(diagnostics, options, {
|
|
306
|
+
code: change.code,
|
|
307
|
+
severity: 'blocker',
|
|
308
|
+
category: 'map',
|
|
309
|
+
message: change.message,
|
|
310
|
+
details: { before: change.before, after: change.after },
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
if (bitmap.bitsPerPixel !== 24) {
|
|
315
|
+
addDiagnostic(diagnostics, options, {
|
|
316
|
+
code: 'MAP_PROVINCES_BPP_INVALID',
|
|
317
|
+
severity: 'error',
|
|
318
|
+
category: 'map',
|
|
319
|
+
message: 'provinces.bmp must be an uncompressed 24-bit RGB bitmap',
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
if (bitmap.width % 256 !== 0 || bitmap.height % 256 !== 0) {
|
|
323
|
+
addDiagnostic(diagnostics, options, {
|
|
324
|
+
code: 'MAP_DIMENSIONS_NOT_MULTIPLE_256',
|
|
325
|
+
severity: 'error',
|
|
326
|
+
category: 'map',
|
|
327
|
+
message: 'Province bitmap width and height must be multiples of 256',
|
|
328
|
+
details: { width: bitmap.width, height: bitmap.height },
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
if (bitmap.width * bitmap.height > MAP_PROVINCE_ENGINE_MAX_PIXELS) {
|
|
332
|
+
addDiagnostic(diagnostics, options, {
|
|
333
|
+
code: 'MAP_AREA_ENGINE_LIMIT',
|
|
334
|
+
severity: 'error',
|
|
335
|
+
category: 'map',
|
|
336
|
+
message: 'Province bitmap exceeds the documented engine area limit',
|
|
337
|
+
details: { pixels: bitmap.width * bitmap.height },
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
for (const unknown of raster.unknownColors) {
|
|
341
|
+
addDiagnostic(diagnostics, options, {
|
|
342
|
+
code: 'MAP_BITMAP_COLOR_UNREGISTERED',
|
|
343
|
+
severity: 'error',
|
|
344
|
+
category: 'map',
|
|
345
|
+
message: `Bitmap color ${rgbKey(unknown.color)} has no definition`,
|
|
346
|
+
details: {
|
|
347
|
+
color: rgbKey(unknown.color),
|
|
348
|
+
count: unknown.count,
|
|
349
|
+
firstX: unknown.firstX,
|
|
350
|
+
firstY: unknown.firstY,
|
|
351
|
+
},
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
if (raster.unknownColorCount > raster.unknownColors.length) {
|
|
355
|
+
addDiagnostic(diagnostics, options, {
|
|
356
|
+
code: 'MAP_BITMAP_COLOR_SAMPLE_LIMIT',
|
|
357
|
+
severity: 'blocker',
|
|
358
|
+
category: 'map',
|
|
359
|
+
message: 'Bitmap contains more undefined colors than can be reported individually',
|
|
360
|
+
details: {
|
|
361
|
+
distinctColors: raster.unknownColorCount,
|
|
362
|
+
retainedSamples: raster.unknownColors.length,
|
|
363
|
+
},
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
const components = yield* provinceComponents(raster, options.signal);
|
|
367
|
+
const holes = yield* provinceHoleCounts(raster, components, options.signal);
|
|
368
|
+
const thin = yield* provinceThinPixels(raster, options.signal);
|
|
369
|
+
for (const definition of index.definitions) {
|
|
370
|
+
if (definition.id === 0)
|
|
371
|
+
continue;
|
|
372
|
+
const geometry = raster.geometry.get(definition.id);
|
|
373
|
+
if (geometry === undefined) {
|
|
374
|
+
addDiagnostic(diagnostics, options, {
|
|
375
|
+
code: 'MAP_DEFINITION_UNUSED',
|
|
376
|
+
severity: 'error',
|
|
377
|
+
category: 'map',
|
|
378
|
+
message: `Province ${definition.id} has no pixels in provinces.bmp`,
|
|
379
|
+
location: definitionLocation(definition),
|
|
380
|
+
});
|
|
381
|
+
continue;
|
|
382
|
+
}
|
|
383
|
+
if (geometry.pixelCount <= 8) {
|
|
384
|
+
addDiagnostic(diagnostics, options, {
|
|
385
|
+
code: 'MAP_PROVINCE_TOO_SMALL',
|
|
386
|
+
severity: 'warning',
|
|
387
|
+
category: 'map',
|
|
388
|
+
message: `Province ${definition.id} has only ${geometry.pixelCount} pixels`,
|
|
389
|
+
location: definitionLocation(definition),
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
if (geometry.maxX - geometry.minX + 1 > bitmap.width / 8 ||
|
|
393
|
+
geometry.maxY - geometry.minY + 1 > bitmap.height / 8) {
|
|
394
|
+
addDiagnostic(diagnostics, options, {
|
|
395
|
+
code: 'MAP_PROVINCE_LARGE_BOUNDS',
|
|
396
|
+
severity: 'warning',
|
|
397
|
+
category: 'map',
|
|
398
|
+
message: `Province ${definition.id} spans more than one eighth of a map dimension`,
|
|
399
|
+
location: definitionLocation(definition),
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
if ((components.get(definition.id) ?? 0) > 1) {
|
|
403
|
+
addDiagnostic(diagnostics, options, {
|
|
404
|
+
code: 'MAP_PROVINCE_DISCONNECTED_REVIEW',
|
|
405
|
+
severity: 'warning',
|
|
406
|
+
category: 'map',
|
|
407
|
+
message: `Province ${definition.id} has multiple disconnected components; review islands intentionally`,
|
|
408
|
+
location: definitionLocation(definition),
|
|
409
|
+
details: { components: components.get(definition.id) ?? 0 },
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
if ((holes.get(definition.id) ?? 0) > 0) {
|
|
413
|
+
addDiagnostic(diagnostics, options, {
|
|
414
|
+
code: 'MAP_PROVINCE_HOLE_REVIEW',
|
|
415
|
+
severity: 'warning',
|
|
416
|
+
category: 'map',
|
|
417
|
+
message: `Province ${definition.id} encloses one or more holes; review enclaves and inland regions intentionally`,
|
|
418
|
+
location: definitionLocation(definition),
|
|
419
|
+
details: { holes: holes.get(definition.id) ?? 0 },
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
if (thin.has(definition.id)) {
|
|
423
|
+
addDiagnostic(diagnostics, options, {
|
|
424
|
+
code: 'MAP_PROVINCE_THIN_CORRIDOR_REVIEW',
|
|
425
|
+
severity: 'warning',
|
|
426
|
+
category: 'map',
|
|
427
|
+
message: `Province ${definition.id} contains a one-pixel corridor`,
|
|
428
|
+
location: definitionLocation(definition),
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
const derivedCoastal = raster.coastalProvinceIds.has(definition.id);
|
|
432
|
+
if ((definition.type === 'land' || definition.type === 'sea') &&
|
|
433
|
+
definition.coastal !== derivedCoastal) {
|
|
434
|
+
addDiagnostic(diagnostics, options, {
|
|
435
|
+
code: 'MAP_COASTAL_MISMATCH',
|
|
436
|
+
severity: 'error',
|
|
437
|
+
category: 'map',
|
|
438
|
+
message: `Province ${definition.id} coastal field disagrees with bitmap adjacency`,
|
|
439
|
+
location: definitionLocation(definition),
|
|
440
|
+
details: { declared: definition.coastal, derived: derivedCoastal },
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
for (let y = 0; y + 1 < raster.height; y += 1) {
|
|
445
|
+
yield* cancellationCheckpoint(options.signal, y, 16);
|
|
446
|
+
for (let x = 0; x < raster.width; x += 1) {
|
|
447
|
+
const right = x === raster.width - 1 ? 0 : x + 1;
|
|
448
|
+
const ids = new Set([
|
|
449
|
+
raster.provinceIds[y * raster.width + x] ?? -1,
|
|
450
|
+
raster.provinceIds[y * raster.width + right] ?? -1,
|
|
451
|
+
raster.provinceIds[(y + 1) * raster.width + x] ?? -1,
|
|
452
|
+
raster.provinceIds[(y + 1) * raster.width + right] ?? -1,
|
|
453
|
+
]);
|
|
454
|
+
ids.delete(-1);
|
|
455
|
+
if (ids.size === 4) {
|
|
456
|
+
addDiagnostic(diagnostics, options, {
|
|
457
|
+
code: 'MAP_INVALID_X_CROSSING',
|
|
458
|
+
severity: 'error',
|
|
459
|
+
category: 'map',
|
|
460
|
+
message: `Four provinces meet at one pixel corner near ${x},${y}`,
|
|
461
|
+
details: { x, y, provinceIds: [...ids].sort((left, rightId) => left - rightId) },
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
if (baselineBitmap !== undefined && options.expectedChangedBounds !== undefined) {
|
|
467
|
+
const bounds = baselineBitmap.width === bitmap.width && baselineBitmap.height === bitmap.height
|
|
468
|
+
? baselineBitmap.diffBounds(bitmap)
|
|
469
|
+
: undefined;
|
|
470
|
+
if (bounds !== undefined &&
|
|
471
|
+
(bounds.minX < options.expectedChangedBounds.minX ||
|
|
472
|
+
bounds.minY < options.expectedChangedBounds.minY ||
|
|
473
|
+
bounds.maxX > options.expectedChangedBounds.maxX ||
|
|
474
|
+
bounds.maxY > options.expectedChangedBounds.maxY)) {
|
|
475
|
+
addDiagnostic(diagnostics, options, {
|
|
476
|
+
code: 'MAP_PIXELS_CHANGED_OUTSIDE_OPERATION',
|
|
477
|
+
severity: 'blocker',
|
|
478
|
+
category: 'map',
|
|
479
|
+
message: 'Province bitmap changed outside the operation bounds',
|
|
480
|
+
details: { actual: bounds, expected: options.expectedChangedBounds },
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
function* validateDefinitions(index, diagnostics, options) {
|
|
486
|
+
yield* cancellationCheckpoint(options.signal);
|
|
487
|
+
if (index.definitionFile === undefined) {
|
|
488
|
+
addDiagnostic(diagnostics, options, {
|
|
489
|
+
code: 'MAP_DEFINITION_FILE_MISSING',
|
|
490
|
+
severity: 'error',
|
|
491
|
+
category: 'map',
|
|
492
|
+
message: 'The active definition.csv file is missing',
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
if (index.provinceBitmapFile === undefined) {
|
|
496
|
+
addDiagnostic(diagnostics, options, {
|
|
497
|
+
code: 'MAP_PROVINCE_BITMAP_MISSING',
|
|
498
|
+
severity: 'error',
|
|
499
|
+
category: 'map',
|
|
500
|
+
message: 'The active provinces.bmp file is missing',
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
for (const [id, definitions] of index.duplicateDefinitionIds) {
|
|
504
|
+
if (definitions.length < 2)
|
|
505
|
+
continue;
|
|
506
|
+
const firstDefinition = definitions[0];
|
|
507
|
+
if (firstDefinition === undefined)
|
|
508
|
+
continue;
|
|
509
|
+
const relatedDefinitions = definitions
|
|
510
|
+
.slice(1, MAP_DIAGNOSTIC_DETAIL_SAMPLE_LIMIT + 1)
|
|
511
|
+
.map(definitionLocation);
|
|
512
|
+
addDiagnostic(diagnostics, options, {
|
|
513
|
+
code: 'MAP_PROVINCE_ID_DUPLICATE',
|
|
514
|
+
severity: 'error',
|
|
515
|
+
category: 'map',
|
|
516
|
+
message: `Province ID ${id} is defined more than once`,
|
|
517
|
+
location: definitionLocation(firstDefinition),
|
|
518
|
+
related: relatedDefinitions,
|
|
519
|
+
details: { duplicateLocations: definitions.length - 1 },
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
for (const [color, definitions] of index.duplicateColors) {
|
|
523
|
+
if (definitions.length < 2)
|
|
524
|
+
continue;
|
|
525
|
+
const firstDefinition = definitions[0];
|
|
526
|
+
if (firstDefinition === undefined)
|
|
527
|
+
continue;
|
|
528
|
+
addDiagnostic(diagnostics, options, {
|
|
529
|
+
code: 'MAP_PROVINCE_COLOR_DUPLICATE',
|
|
530
|
+
severity: 'error',
|
|
531
|
+
category: 'map',
|
|
532
|
+
message: `Province color ${color} is assigned more than once`,
|
|
533
|
+
location: definitionLocation(firstDefinition),
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
const missing = contiguousMissing(index.definitions.map(({ id }) => id), 0);
|
|
537
|
+
if (missing.total > 0) {
|
|
538
|
+
addDiagnostic(diagnostics, options, {
|
|
539
|
+
code: 'MAP_PROVINCE_ID_GAP',
|
|
540
|
+
severity: 'error',
|
|
541
|
+
category: 'map',
|
|
542
|
+
message: 'Province IDs must remain contiguous from zero',
|
|
543
|
+
details: { missing: missing.sample, total: missing.total },
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
for (const [definitionIndex, definition] of index.definitions.entries()) {
|
|
547
|
+
yield* cancellationCheckpoint(options.signal, definitionIndex, 256);
|
|
548
|
+
if (definition.type === 'land' && definition.continent === 0) {
|
|
549
|
+
addDiagnostic(diagnostics, options, {
|
|
550
|
+
code: 'MAP_LAND_CONTINENT_MISSING',
|
|
551
|
+
severity: 'error',
|
|
552
|
+
category: 'map',
|
|
553
|
+
message: `Land province ${definition.id} has continent zero`,
|
|
554
|
+
location: definitionLocation(definition),
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
if (definition.type === 'sea' && definition.terrain !== 'ocean') {
|
|
558
|
+
addDiagnostic(diagnostics, options, {
|
|
559
|
+
code: 'MAP_SEA_TERRAIN_INVALID',
|
|
560
|
+
severity: 'error',
|
|
561
|
+
category: 'map',
|
|
562
|
+
message: `Sea province ${definition.id} must use ocean terrain`,
|
|
563
|
+
location: definitionLocation(definition),
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
if (definition.type === 'lake' && definition.terrain !== 'lakes') {
|
|
567
|
+
addDiagnostic(diagnostics, options, {
|
|
568
|
+
code: 'MAP_LAKE_TERRAIN_INVALID',
|
|
569
|
+
severity: 'error',
|
|
570
|
+
category: 'map',
|
|
571
|
+
message: `Lake province ${definition.id} must use lakes terrain`,
|
|
572
|
+
location: definitionLocation(definition),
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
function* validateStatesAndRegions(index, diagnostics, options) {
|
|
578
|
+
yield* cancellationCheckpoint(options.signal);
|
|
579
|
+
for (const [id, states] of duplicateValues(index.states, (state) => String(state.id))) {
|
|
580
|
+
const firstState = states[0];
|
|
581
|
+
if (firstState === undefined)
|
|
582
|
+
continue;
|
|
583
|
+
const relatedStates = states
|
|
584
|
+
.slice(1, MAP_DIAGNOSTIC_DETAIL_SAMPLE_LIMIT + 1)
|
|
585
|
+
.map(stateLocation);
|
|
586
|
+
addDiagnostic(diagnostics, options, {
|
|
587
|
+
code: 'MAP_STATE_ID_DUPLICATE',
|
|
588
|
+
severity: 'error',
|
|
589
|
+
category: 'map',
|
|
590
|
+
message: `State ID ${id} is defined more than once`,
|
|
591
|
+
location: stateLocation(firstState),
|
|
592
|
+
related: relatedStates,
|
|
593
|
+
details: { duplicateLocations: states.length - 1 },
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
const stateMembership = new Map();
|
|
597
|
+
for (const [stateIndex, state] of index.states.entries()) {
|
|
598
|
+
yield* cancellationCheckpoint(options.signal, stateIndex, 64);
|
|
599
|
+
if (state.owner === undefined) {
|
|
600
|
+
addDiagnostic(diagnostics, options, {
|
|
601
|
+
code: 'MAP_STATE_OWNER_MISSING',
|
|
602
|
+
severity: 'warning',
|
|
603
|
+
category: 'map',
|
|
604
|
+
message: `State ${state.id} has no owner and is unsafe for many effects`,
|
|
605
|
+
location: stateLocation(state),
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
if (state.controller !== undefined && state.owner === undefined) {
|
|
609
|
+
addDiagnostic(diagnostics, options, {
|
|
610
|
+
code: 'MAP_STATE_CONTROLLER_WITHOUT_OWNER',
|
|
611
|
+
severity: 'error',
|
|
612
|
+
category: 'map',
|
|
613
|
+
message: `State ${state.id} defines a controller without an owner`,
|
|
614
|
+
location: stateLocation(state),
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
if (!index.localisationKeys.has(`l_english:${state.name}`)) {
|
|
618
|
+
const proposedState = options.baseline !== undefined && !options.baseline.statesById.has(state.id);
|
|
619
|
+
addDiagnostic(diagnostics, options, {
|
|
620
|
+
code: proposedState
|
|
621
|
+
? 'MAP_NEW_STATE_LOCALISATION_MISSING'
|
|
622
|
+
: 'MAP_STATE_LOCALISATION_MISSING',
|
|
623
|
+
severity: proposedState ? 'error' : 'warning',
|
|
624
|
+
category: 'map',
|
|
625
|
+
message: `${proposedState ? 'Proposed' : 'Existing'} state ${state.id} name key ${state.name} has no English localisation`,
|
|
626
|
+
location: stateLocation(state),
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
if (state.capital !== undefined && !state.provinces.includes(state.capital)) {
|
|
630
|
+
addDiagnostic(diagnostics, options, {
|
|
631
|
+
code: 'MAP_STATE_CAPITAL_OUTSIDE_STATE',
|
|
632
|
+
severity: 'error',
|
|
633
|
+
category: 'map',
|
|
634
|
+
message: `State ${state.id} capital ${state.capital} is not a member province`,
|
|
635
|
+
location: stateLocation(state),
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
for (const province of state.provinces) {
|
|
639
|
+
const membership = stateMembership.get(province) ?? [];
|
|
640
|
+
membership.push(state);
|
|
641
|
+
stateMembership.set(province, membership);
|
|
642
|
+
if (!index.definitionsById.has(province)) {
|
|
643
|
+
addDiagnostic(diagnostics, options, {
|
|
644
|
+
code: 'MAP_STATE_PROVINCE_INVALID',
|
|
645
|
+
severity: 'error',
|
|
646
|
+
category: 'map',
|
|
647
|
+
message: `State ${state.id} refers to missing province ${province}`,
|
|
648
|
+
location: stateLocation(state),
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
for (const victoryPoint of state.victoryPoints) {
|
|
653
|
+
if (!state.provinces.includes(victoryPoint.provinceId)) {
|
|
654
|
+
addDiagnostic(diagnostics, options, {
|
|
655
|
+
code: 'MAP_VICTORY_POINT_OUTSIDE_STATE',
|
|
656
|
+
severity: 'error',
|
|
657
|
+
category: 'map',
|
|
658
|
+
message: `Victory point ${victoryPoint.provinceId} is not in state ${state.id}`,
|
|
659
|
+
location: stateLocation(state),
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
for (const province of state.provinceBuildings.keys()) {
|
|
664
|
+
if (!state.provinces.includes(province)) {
|
|
665
|
+
addDiagnostic(diagnostics, options, {
|
|
666
|
+
code: 'MAP_PROVINCE_BUILDING_OUTSIDE_STATE',
|
|
667
|
+
severity: 'error',
|
|
668
|
+
category: 'map',
|
|
669
|
+
message: `Province building entry ${province} is not in state ${state.id}`,
|
|
670
|
+
location: stateLocation(state),
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
for (const [definitionIndex, definition] of index.definitions.entries()) {
|
|
676
|
+
yield* cancellationCheckpoint(options.signal, definitionIndex, 256);
|
|
677
|
+
if (definition.id === 0)
|
|
678
|
+
continue;
|
|
679
|
+
const memberships = stateMembership.get(definition.id) ?? [];
|
|
680
|
+
if (definition.type === 'land' && memberships.length === 0) {
|
|
681
|
+
addDiagnostic(diagnostics, options, {
|
|
682
|
+
code: 'MAP_LAND_PROVINCE_STATE_MISSING',
|
|
683
|
+
severity: 'error',
|
|
684
|
+
category: 'map',
|
|
685
|
+
message: `Land province ${definition.id} is in no state`,
|
|
686
|
+
location: definitionLocation(definition),
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
if (memberships.length > 1) {
|
|
690
|
+
const relatedStates = memberships
|
|
691
|
+
.slice(0, MAP_DIAGNOSTIC_DETAIL_SAMPLE_LIMIT)
|
|
692
|
+
.map(stateLocation);
|
|
693
|
+
addDiagnostic(diagnostics, options, {
|
|
694
|
+
code: 'MAP_PROVINCE_STATE_DUPLICATE',
|
|
695
|
+
severity: 'error',
|
|
696
|
+
category: 'map',
|
|
697
|
+
message: `Province ${definition.id} is assigned to multiple states`,
|
|
698
|
+
location: definitionLocation(definition),
|
|
699
|
+
related: relatedStates,
|
|
700
|
+
details: { memberships: memberships.length },
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
if ((definition.type === 'sea' || definition.type === 'lake') && memberships.length > 0) {
|
|
704
|
+
addDiagnostic(diagnostics, options, {
|
|
705
|
+
code: definition.type === 'sea' ? 'MAP_SEA_PROVINCE_IN_STATE' : 'MAP_LAKE_PROVINCE_IN_STATE',
|
|
706
|
+
severity: 'error',
|
|
707
|
+
category: 'map',
|
|
708
|
+
message: `${definition.type === 'sea' ? 'Sea' : 'Lake'} province ${definition.id} must not be assigned to a state`,
|
|
709
|
+
location: definitionLocation(definition),
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
for (const [id, regions] of duplicateValues(index.regions, (region) => String(region.id))) {
|
|
714
|
+
const firstRegion = regions[0];
|
|
715
|
+
if (firstRegion === undefined)
|
|
716
|
+
continue;
|
|
717
|
+
const relatedRegions = regions
|
|
718
|
+
.slice(1, MAP_DIAGNOSTIC_DETAIL_SAMPLE_LIMIT + 1)
|
|
719
|
+
.map(regionLocation);
|
|
720
|
+
addDiagnostic(diagnostics, options, {
|
|
721
|
+
code: 'MAP_STRATEGIC_REGION_ID_DUPLICATE',
|
|
722
|
+
severity: 'error',
|
|
723
|
+
category: 'map',
|
|
724
|
+
message: `Strategic region ID ${id} is defined more than once`,
|
|
725
|
+
location: regionLocation(firstRegion),
|
|
726
|
+
related: relatedRegions,
|
|
727
|
+
details: { duplicateLocations: regions.length - 1 },
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
const regionMembership = new Map();
|
|
731
|
+
for (const [regionIndex, region] of index.regions.entries()) {
|
|
732
|
+
yield* cancellationCheckpoint(options.signal, regionIndex, 64);
|
|
733
|
+
for (const province of region.provinces) {
|
|
734
|
+
const membership = regionMembership.get(province) ?? [];
|
|
735
|
+
membership.push(region);
|
|
736
|
+
regionMembership.set(province, membership);
|
|
737
|
+
if (!index.definitionsById.has(province)) {
|
|
738
|
+
addDiagnostic(diagnostics, options, {
|
|
739
|
+
code: 'MAP_REGION_PROVINCE_INVALID',
|
|
740
|
+
severity: 'error',
|
|
741
|
+
category: 'map',
|
|
742
|
+
message: `Strategic region ${region.id} refers to missing province ${province}`,
|
|
743
|
+
location: regionLocation(region),
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
for (const [definitionIndex, definition] of index.definitions.entries()) {
|
|
749
|
+
yield* cancellationCheckpoint(options.signal, definitionIndex, 256);
|
|
750
|
+
if (definition.id === 0)
|
|
751
|
+
continue;
|
|
752
|
+
const memberships = regionMembership.get(definition.id) ?? [];
|
|
753
|
+
if (memberships.length === 0) {
|
|
754
|
+
addDiagnostic(diagnostics, options, {
|
|
755
|
+
code: 'MAP_PROVINCE_REGION_MISSING',
|
|
756
|
+
severity: 'error',
|
|
757
|
+
category: 'map',
|
|
758
|
+
message: `Province ${definition.id} is in no strategic region`,
|
|
759
|
+
location: definitionLocation(definition),
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
else if (memberships.length > 1) {
|
|
763
|
+
const relatedRegions = memberships
|
|
764
|
+
.slice(0, MAP_DIAGNOSTIC_DETAIL_SAMPLE_LIMIT)
|
|
765
|
+
.map(regionLocation);
|
|
766
|
+
addDiagnostic(diagnostics, options, {
|
|
767
|
+
code: 'MAP_PROVINCE_REGION_DUPLICATE',
|
|
768
|
+
severity: 'error',
|
|
769
|
+
category: 'map',
|
|
770
|
+
message: `Province ${definition.id} is in multiple strategic regions`,
|
|
771
|
+
location: definitionLocation(definition),
|
|
772
|
+
related: relatedRegions,
|
|
773
|
+
details: { memberships: memberships.length },
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
for (const [stateIndex, state] of index.states.entries()) {
|
|
778
|
+
yield* cancellationCheckpoint(options.signal, stateIndex, 64);
|
|
779
|
+
const regionIds = new Set(state.provinces.flatMap((province) => (regionMembership.get(province) ?? []).map(({ id }) => id)));
|
|
780
|
+
if (regionIds.size > 1) {
|
|
781
|
+
const regionIdList = [...regionIds].sort((left, right) => left - right);
|
|
782
|
+
addDiagnostic(diagnostics, options, {
|
|
783
|
+
code: 'MAP_STATE_CROSSES_STRATEGIC_REGIONS',
|
|
784
|
+
severity: 'error',
|
|
785
|
+
category: 'map',
|
|
786
|
+
message: `State ${state.id} spans multiple strategic regions`,
|
|
787
|
+
location: stateLocation(state),
|
|
788
|
+
details: {
|
|
789
|
+
strategicRegionIds: regionIdList.slice(0, MAP_DIAGNOSTIC_DETAIL_SAMPLE_LIMIT),
|
|
790
|
+
strategicRegionCount: regionIdList.length,
|
|
791
|
+
},
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
function* validateNetworksAndAdjacencies(index, diagnostics, options) {
|
|
797
|
+
yield* cancellationCheckpoint(options.signal);
|
|
798
|
+
const specialPairs = new Set(index.adjacencies
|
|
799
|
+
.filter(({ type }) => type === 'sea')
|
|
800
|
+
.flatMap(({ from, to }) => [`${from}:${to}`, `${to}:${from}`]));
|
|
801
|
+
for (const [adjacencyIndex, adjacency] of index.adjacencies.entries()) {
|
|
802
|
+
yield* cancellationCheckpoint(options.signal, adjacencyIndex, 128);
|
|
803
|
+
const location = lineLocation(adjacency.document, adjacency.line);
|
|
804
|
+
const from = index.definitionsById.get(adjacency.from);
|
|
805
|
+
const to = index.definitionsById.get(adjacency.to);
|
|
806
|
+
if (from === undefined || to === undefined || adjacency.from === adjacency.to) {
|
|
807
|
+
addDiagnostic(diagnostics, options, {
|
|
808
|
+
code: 'MAP_ADJACENCY_PROVINCE_INVALID',
|
|
809
|
+
severity: 'error',
|
|
810
|
+
category: 'map',
|
|
811
|
+
message: `Adjacency ${adjacency.from}-${adjacency.to} has invalid endpoints`,
|
|
812
|
+
...(location === undefined ? {} : { location }),
|
|
813
|
+
});
|
|
814
|
+
continue;
|
|
815
|
+
}
|
|
816
|
+
if (adjacency.type === 'sea') {
|
|
817
|
+
if (from.type !== to.type) {
|
|
818
|
+
addDiagnostic(diagnostics, options, {
|
|
819
|
+
code: 'MAP_SEA_ADJACENCY_TYPE_MISMATCH',
|
|
820
|
+
severity: 'error',
|
|
821
|
+
category: 'map',
|
|
822
|
+
message: 'Sea adjacency endpoints must have the same province type',
|
|
823
|
+
...(location === undefined ? {} : { location }),
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
const directlyAdjacent = index.raster?.adjacency.get(adjacency.from)?.has(adjacency.to) ?? false;
|
|
827
|
+
if (!directlyAdjacent && adjacency.through < 0) {
|
|
828
|
+
addDiagnostic(diagnostics, options, {
|
|
829
|
+
code: 'MAP_ADJACENCY_THROUGH_MISSING',
|
|
830
|
+
severity: 'error',
|
|
831
|
+
category: 'map',
|
|
832
|
+
message: 'Non-border sea adjacency requires a through province',
|
|
833
|
+
...(location === undefined ? {} : { location }),
|
|
834
|
+
});
|
|
835
|
+
}
|
|
836
|
+
if (adjacency.through >= 0 && !index.definitionsById.has(adjacency.through)) {
|
|
837
|
+
addDiagnostic(diagnostics, options, {
|
|
838
|
+
code: 'MAP_ADJACENCY_THROUGH_INVALID',
|
|
839
|
+
severity: 'error',
|
|
840
|
+
category: 'map',
|
|
841
|
+
message: `Adjacency through province ${adjacency.through} does not exist`,
|
|
842
|
+
...(location === undefined ? {} : { location }),
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
else if (adjacency.type === 'impassable') {
|
|
847
|
+
if (adjacency.through !== -1 ||
|
|
848
|
+
adjacency.startX !== -1 ||
|
|
849
|
+
adjacency.startY !== -1 ||
|
|
850
|
+
adjacency.stopX !== -1 ||
|
|
851
|
+
adjacency.stopY !== -1 ||
|
|
852
|
+
adjacency.rule !== '') {
|
|
853
|
+
addDiagnostic(diagnostics, options, {
|
|
854
|
+
code: 'MAP_IMPASSABLE_FIELDS_INVALID',
|
|
855
|
+
severity: 'error',
|
|
856
|
+
category: 'map',
|
|
857
|
+
message: 'Impassable adjacency must leave through, coordinates, and rule unset',
|
|
858
|
+
...(location === undefined ? {} : { location }),
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
else {
|
|
863
|
+
addDiagnostic(diagnostics, options, {
|
|
864
|
+
code: 'MAP_ADJACENCY_TYPE_UNKNOWN',
|
|
865
|
+
severity: 'error',
|
|
866
|
+
category: 'map',
|
|
867
|
+
message: `Unknown adjacency type ${adjacency.type}`,
|
|
868
|
+
...(location === undefined ? {} : { location }),
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
const supplyDuplicates = duplicateValues(index.supplyNodes, ({ provinceId }) => String(provinceId));
|
|
873
|
+
for (const [province, nodes] of supplyDuplicates) {
|
|
874
|
+
const firstNode = nodes[0];
|
|
875
|
+
if (firstNode === undefined)
|
|
876
|
+
continue;
|
|
877
|
+
addDiagnostic(diagnostics, options, {
|
|
878
|
+
code: 'MAP_SUPPLY_NODE_DUPLICATE',
|
|
879
|
+
severity: 'error',
|
|
880
|
+
category: 'map',
|
|
881
|
+
message: `Province ${province} contains multiple starting supply nodes`,
|
|
882
|
+
location: requiredLineLocation(firstNode.document, firstNode.line),
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
for (const [nodeIndex, node] of index.supplyNodes.entries()) {
|
|
886
|
+
yield* cancellationCheckpoint(options.signal, nodeIndex, 128);
|
|
887
|
+
const definition = index.definitionsById.get(node.provinceId);
|
|
888
|
+
if (node.level !== 1 ||
|
|
889
|
+
definition?.type !== 'land' ||
|
|
890
|
+
index.stateForProvince(node.provinceId).length !== 1) {
|
|
891
|
+
addDiagnostic(diagnostics, options, {
|
|
892
|
+
code: 'MAP_SUPPLY_NODE_INVALID',
|
|
893
|
+
severity: 'error',
|
|
894
|
+
category: 'map',
|
|
895
|
+
message: `Supply node ${node.provinceId} must be level 1 in one stateful land province`,
|
|
896
|
+
location: requiredLineLocation(node.document, node.line),
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
for (const [railwayIndex, railway] of index.railways.entries()) {
|
|
901
|
+
yield* cancellationCheckpoint(options.signal, railwayIndex, 64);
|
|
902
|
+
const location = lineLocation(railway.document, railway.line);
|
|
903
|
+
if (railway.level < 1 ||
|
|
904
|
+
railway.level > 5 ||
|
|
905
|
+
railway.declaredCount !== railway.provinces.length ||
|
|
906
|
+
railway.provinces.length < 2) {
|
|
907
|
+
addDiagnostic(diagnostics, options, {
|
|
908
|
+
code: 'MAP_RAILWAY_HEADER_INVALID',
|
|
909
|
+
severity: 'error',
|
|
910
|
+
category: 'map',
|
|
911
|
+
message: 'Railway level, count, or length is invalid',
|
|
912
|
+
...(location === undefined ? {} : { location }),
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
for (const province of railway.provinces) {
|
|
916
|
+
if (index.definitionsById.get(province)?.type !== 'land' ||
|
|
917
|
+
index.stateForProvince(province).length !== 1) {
|
|
918
|
+
addDiagnostic(diagnostics, options, {
|
|
919
|
+
code: 'MAP_RAILWAY_PROVINCE_INVALID',
|
|
920
|
+
severity: 'error',
|
|
921
|
+
category: 'map',
|
|
922
|
+
message: `Railway uses missing or stateless non-land province ${province}`,
|
|
923
|
+
...(location === undefined ? {} : { location }),
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
for (let offset = 1; offset < railway.provinces.length; offset += 1) {
|
|
928
|
+
const left = railway.provinces[offset - 1];
|
|
929
|
+
const right = railway.provinces[offset];
|
|
930
|
+
if (left === undefined || right === undefined)
|
|
931
|
+
continue;
|
|
932
|
+
if (!(index.raster?.adjacency.get(left)?.has(right) ?? false) &&
|
|
933
|
+
!specialPairs.has(`${left}:${right}`)) {
|
|
934
|
+
addDiagnostic(diagnostics, options, {
|
|
935
|
+
code: 'MAP_RAILWAY_DISJOINT',
|
|
936
|
+
severity: 'error',
|
|
937
|
+
category: 'map',
|
|
938
|
+
message: `Railway jumps between non-adjacent provinces ${left} and ${right}`,
|
|
939
|
+
...(location === undefined ? {} : { location }),
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
function* validatePositions(index, diagnostics, options) {
|
|
946
|
+
yield* cancellationCheckpoint(options.signal);
|
|
947
|
+
if (index.activeFiles.byRelativePath.has('map/buildings.txt') &&
|
|
948
|
+
index.buildingPositions.length === 0) {
|
|
949
|
+
addDiagnostic(diagnostics, options, {
|
|
950
|
+
code: 'MAP_BUILDINGS_FILE_EMPTY',
|
|
951
|
+
severity: 'error',
|
|
952
|
+
category: 'map',
|
|
953
|
+
message: 'buildings.txt must not be entirely empty',
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
const navalLocatorProvinces = new Set();
|
|
957
|
+
for (const [positionIndex, position] of index.buildingPositions.entries()) {
|
|
958
|
+
yield* cancellationCheckpoint(options.signal, positionIndex, 128);
|
|
959
|
+
const location = lineLocation(position.document, position.line);
|
|
960
|
+
const state = index.statesById.get(position.stateId);
|
|
961
|
+
const province = index.provinceAtMapCoordinate(position.x, position.z);
|
|
962
|
+
if (state === undefined || province === undefined || !state.provinces.includes(province)) {
|
|
963
|
+
addDiagnostic(diagnostics, options, {
|
|
964
|
+
code: 'MAP_BUILDING_POSITION_INVALID',
|
|
965
|
+
severity: 'error',
|
|
966
|
+
category: 'map',
|
|
967
|
+
message: `Building position does not resolve inside state ${position.stateId}`,
|
|
968
|
+
...(location === undefined ? {} : { location }),
|
|
969
|
+
details: { resolvedProvince: province },
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
if (position.building === 'naval_base_spawn' || position.building === 'floating_harbor') {
|
|
973
|
+
if (province !== undefined)
|
|
974
|
+
navalLocatorProvinces.add(province);
|
|
975
|
+
const adjacent = index.definitionsById.get(position.adjacentSeaProvince);
|
|
976
|
+
if (adjacent?.type !== 'sea') {
|
|
977
|
+
addDiagnostic(diagnostics, options, {
|
|
978
|
+
code: 'MAP_PORT_ADJACENT_SEA_INVALID',
|
|
979
|
+
severity: 'error',
|
|
980
|
+
category: 'map',
|
|
981
|
+
message: `${position.building} must identify an adjacent sea province`,
|
|
982
|
+
...(location === undefined ? {} : { location }),
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
else if (province !== undefined &&
|
|
986
|
+
!(index.raster?.adjacency.get(province)?.has(position.adjacentSeaProvince) ?? false)) {
|
|
987
|
+
addDiagnostic(diagnostics, options, {
|
|
988
|
+
code: 'MAP_PORT_SEA_NOT_ADJACENT',
|
|
989
|
+
severity: 'error',
|
|
990
|
+
category: 'map',
|
|
991
|
+
message: `Port position sea ${position.adjacentSeaProvince} does not border province ${province}`,
|
|
992
|
+
...(location === undefined ? {} : { location }),
|
|
993
|
+
});
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
else if (position.adjacentSeaProvince !== 0) {
|
|
997
|
+
addDiagnostic(diagnostics, options, {
|
|
998
|
+
code: 'MAP_NON_PORT_ADJACENT_SEA_SET',
|
|
999
|
+
severity: 'warning',
|
|
1000
|
+
category: 'map',
|
|
1001
|
+
message: `${position.building} should leave adjacent sea province at zero`,
|
|
1002
|
+
...(location === undefined ? {} : { location }),
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
for (const [stateIndex, state] of index.states.entries()) {
|
|
1007
|
+
yield* cancellationCheckpoint(options.signal, stateIndex, 64);
|
|
1008
|
+
for (const [province, buildings] of state.provinceBuildings) {
|
|
1009
|
+
if ((buildings.get('naval_base') ?? 0) > 0) {
|
|
1010
|
+
if (!(index.raster?.coastalProvinceIds.has(province) ?? false)) {
|
|
1011
|
+
addDiagnostic(diagnostics, options, {
|
|
1012
|
+
code: 'MAP_PORT_NOT_COASTAL',
|
|
1013
|
+
severity: 'error',
|
|
1014
|
+
category: 'map',
|
|
1015
|
+
message: `Naval base province ${province} is not coastal`,
|
|
1016
|
+
location: stateLocation(state),
|
|
1017
|
+
});
|
|
1018
|
+
}
|
|
1019
|
+
if (!navalLocatorProvinces.has(province)) {
|
|
1020
|
+
addDiagnostic(diagnostics, options, {
|
|
1021
|
+
code: 'MAP_PORT_LOCATOR_MISSING',
|
|
1022
|
+
severity: 'error',
|
|
1023
|
+
category: 'map',
|
|
1024
|
+
message: `Naval base province ${province} has no naval_base_spawn entry`,
|
|
1025
|
+
location: stateLocation(state),
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
for (const [positionIndex, position] of index.unitPositions.entries()) {
|
|
1032
|
+
yield* cancellationCheckpoint(options.signal, positionIndex, 128);
|
|
1033
|
+
const location = lineLocation(position.document, position.line);
|
|
1034
|
+
const resolved = index.provinceAtMapCoordinate(position.x, position.z);
|
|
1035
|
+
if (!index.definitionsById.has(position.provinceId) || resolved !== position.provinceId) {
|
|
1036
|
+
addDiagnostic(diagnostics, options, {
|
|
1037
|
+
code: 'MAP_UNIT_POSITION_INVALID',
|
|
1038
|
+
severity: 'error',
|
|
1039
|
+
category: 'map',
|
|
1040
|
+
message: `Unit position for province ${position.provinceId} resolves to ${resolved ?? 'no province'}`,
|
|
1041
|
+
...(location === undefined ? {} : { location }),
|
|
1042
|
+
});
|
|
1043
|
+
}
|
|
1044
|
+
if (position.type < 0 || position.type > 38 || !Number.isInteger(position.type)) {
|
|
1045
|
+
addDiagnostic(diagnostics, options, {
|
|
1046
|
+
code: 'MAP_UNIT_POSITION_TYPE_INVALID',
|
|
1047
|
+
severity: 'error',
|
|
1048
|
+
category: 'map',
|
|
1049
|
+
message: `Unit position type ${position.type} is outside 0..38`,
|
|
1050
|
+
...(location === undefined ? {} : { location }),
|
|
1051
|
+
});
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
let hasSmallWeather = false;
|
|
1055
|
+
let hasBigWeather = false;
|
|
1056
|
+
for (const [positionIndex, position] of index.weatherPositions.entries()) {
|
|
1057
|
+
yield* cancellationCheckpoint(options.signal, positionIndex, 128);
|
|
1058
|
+
if (!index.regionsById.has(position.strategicRegionId)) {
|
|
1059
|
+
addDiagnostic(diagnostics, options, {
|
|
1060
|
+
code: 'MAP_WEATHER_REGION_INVALID',
|
|
1061
|
+
severity: 'error',
|
|
1062
|
+
category: 'map',
|
|
1063
|
+
message: `Weather position refers to missing region ${position.strategicRegionId}`,
|
|
1064
|
+
location: requiredLineLocation(position.document, position.line),
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1067
|
+
hasSmallWeather ||= position.size === 'small';
|
|
1068
|
+
hasBigWeather ||= position.size === 'big';
|
|
1069
|
+
if (position.size !== 'small' && position.size !== 'big') {
|
|
1070
|
+
addDiagnostic(diagnostics, options, {
|
|
1071
|
+
code: 'MAP_WEATHER_SIZE_INVALID',
|
|
1072
|
+
severity: 'error',
|
|
1073
|
+
category: 'map',
|
|
1074
|
+
message: `Weather position size must be small or big, not ${position.size}`,
|
|
1075
|
+
location: requiredLineLocation(position.document, position.line),
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
if (index.weatherPositions.length > 0 && (!hasSmallWeather || !hasBigWeather)) {
|
|
1080
|
+
addDiagnostic(diagnostics, options, {
|
|
1081
|
+
code: 'MAP_WEATHER_SIZE_CLASS_MISSING',
|
|
1082
|
+
severity: 'error',
|
|
1083
|
+
category: 'map',
|
|
1084
|
+
message: 'weatherpositions.txt must contain at least one small and one big object',
|
|
1085
|
+
});
|
|
1086
|
+
}
|
|
1087
|
+
for (const [key, locators] of duplicateValues(index.entityLocators, ({ entity, name }) => `${entity}:${name}`)) {
|
|
1088
|
+
const files = locators
|
|
1089
|
+
.slice(0, MAP_DIAGNOSTIC_DETAIL_SAMPLE_LIMIT)
|
|
1090
|
+
.map(({ file }) => file.displayPath);
|
|
1091
|
+
addDiagnostic(diagnostics, options, {
|
|
1092
|
+
code: 'MAP_ENTITY_LOCATOR_DUPLICATE',
|
|
1093
|
+
severity: 'error',
|
|
1094
|
+
category: 'map',
|
|
1095
|
+
message: `Entity locator ${key} is defined more than once in the same indexed set`,
|
|
1096
|
+
details: { files, fileCount: locators.length },
|
|
1097
|
+
});
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
function* validateMapSteps(index, options = {}) {
|
|
1101
|
+
yield* cancellationCheckpoint(options.signal);
|
|
1102
|
+
const diagnostics = [...index.diagnostics];
|
|
1103
|
+
yield* validateDefinitions(index, diagnostics, options);
|
|
1104
|
+
yield* cancellationCheckpoint(options.signal);
|
|
1105
|
+
yield* validateGeometry(index, diagnostics, options);
|
|
1106
|
+
yield* cancellationCheckpoint(options.signal);
|
|
1107
|
+
yield* validateStatesAndRegions(index, diagnostics, options);
|
|
1108
|
+
yield* cancellationCheckpoint(options.signal);
|
|
1109
|
+
yield* validateNetworksAndAdjacencies(index, diagnostics, options);
|
|
1110
|
+
yield* cancellationCheckpoint(options.signal);
|
|
1111
|
+
yield* validatePositions(index, diagnostics, options);
|
|
1112
|
+
yield* cancellationCheckpoint(options.signal);
|
|
1113
|
+
const sorted = sortDiagnostics(diagnostics);
|
|
1114
|
+
const checks = [
|
|
1115
|
+
{
|
|
1116
|
+
id: 'map-files-and-definitions',
|
|
1117
|
+
passed: !sorted.some(({ code, severity }) => severity === 'error' || severity === 'blocker'
|
|
1118
|
+
? code.startsWith('MAP_DEFINITION') ||
|
|
1119
|
+
code.startsWith('MAP_PROVINCE_ID') ||
|
|
1120
|
+
code.startsWith('MAP_PROVINCE_COLOR') ||
|
|
1121
|
+
code === 'MAP_PROVINCE_BITMAP_MISSING'
|
|
1122
|
+
: false),
|
|
1123
|
+
message: 'Province definitions, IDs, colors, and required files are valid',
|
|
1124
|
+
},
|
|
1125
|
+
{
|
|
1126
|
+
id: 'map-bitmap-geometry',
|
|
1127
|
+
passed: !sorted.some(({ code, severity }) => (severity === 'error' || severity === 'blocker') &&
|
|
1128
|
+
(code.startsWith('MAP_BMP') ||
|
|
1129
|
+
code.startsWith('MAP_BITMAP') ||
|
|
1130
|
+
code.startsWith('MAP_INVALID_X') ||
|
|
1131
|
+
code.startsWith('MAP_DIMENSIONS') ||
|
|
1132
|
+
code.startsWith('MAP_PIXELS'))),
|
|
1133
|
+
message: 'Bitmap format and province geometry are valid',
|
|
1134
|
+
},
|
|
1135
|
+
{
|
|
1136
|
+
id: 'map-state-region-membership',
|
|
1137
|
+
passed: !sorted.some(({ code, severity }) => (severity === 'error' || severity === 'blocker') &&
|
|
1138
|
+
(code.startsWith('MAP_STATE') ||
|
|
1139
|
+
code.startsWith('MAP_LAND_PROVINCE_STATE') ||
|
|
1140
|
+
code.startsWith('MAP_PROVINCE_STATE') ||
|
|
1141
|
+
code.startsWith('MAP_PROVINCE_REGION') ||
|
|
1142
|
+
code.startsWith('MAP_STRATEGIC_REGION'))),
|
|
1143
|
+
message: 'State and strategic-region memberships are valid',
|
|
1144
|
+
},
|
|
1145
|
+
{
|
|
1146
|
+
id: 'map-networks-adjacencies',
|
|
1147
|
+
passed: !sorted.some(({ code, severity }) => (severity === 'error' || severity === 'blocker') &&
|
|
1148
|
+
(code.startsWith('MAP_ADJACENCY') ||
|
|
1149
|
+
code.startsWith('MAP_IMPASSABLE') ||
|
|
1150
|
+
code.startsWith('MAP_SEA_ADJACENCY') ||
|
|
1151
|
+
code.startsWith('MAP_SUPPLY') ||
|
|
1152
|
+
code.startsWith('MAP_RAILWAY'))),
|
|
1153
|
+
message: 'Adjacencies, supply nodes, and railways are valid',
|
|
1154
|
+
},
|
|
1155
|
+
{
|
|
1156
|
+
id: 'map-positions-locators',
|
|
1157
|
+
passed: !sorted.some(({ code, severity }) => (severity === 'error' || severity === 'blocker') &&
|
|
1158
|
+
(code.startsWith('MAP_BUILDING') ||
|
|
1159
|
+
code.startsWith('MAP_PORT') ||
|
|
1160
|
+
code.startsWith('MAP_UNIT_POSITION') ||
|
|
1161
|
+
code.startsWith('MAP_WEATHER') ||
|
|
1162
|
+
code.startsWith('MAP_ENTITY_LOCATOR'))),
|
|
1163
|
+
message: 'Map positions, ports, and entity locators are valid',
|
|
1164
|
+
},
|
|
1165
|
+
];
|
|
1166
|
+
const passed = checks.every((check) => check.passed) &&
|
|
1167
|
+
!sorted.some(({ severity }) => severity === 'error' || severity === 'blocker');
|
|
1168
|
+
return { passed, diagnostics: sorted, checks };
|
|
1169
|
+
}
|
|
1170
|
+
export function validateMap(index, options = {}) {
|
|
1171
|
+
return completeSynchronously(validateMapSteps(index, options));
|
|
1172
|
+
}
|
|
1173
|
+
/** Validates map geometry and records while yielding so protocol cancellation can be delivered. */
|
|
1174
|
+
export async function validateMapAsync(index, options = {}) {
|
|
1175
|
+
return completeCooperatively(validateMapSteps(index, options), options.signal);
|
|
1176
|
+
}
|
|
1177
|
+
//# sourceMappingURL=validation.js.map
|